kin: auto-commit after pipeline

This commit is contained in:
Gros Frumos 2026-03-17 18:31:00 +02:00
parent c30a4c0fc4
commit 33fc38b01f
4 changed files with 459 additions and 67 deletions

View file

@ -0,0 +1,117 @@
"""Regression tests for KIN-100 — human-readable agent output format.
Verifies that reviewer.md and tester.md prompts contain the two-block format
instructions (## Verdict + ## Details), ensuring agents produce output that
is both human-readable and machine-parseable.
"""
import os
PROMPTS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "agents", "prompts")
def _read_prompt(name: str) -> str:
path = os.path.join(PROMPTS_DIR, name)
with open(path, encoding="utf-8") as f:
return f.read()
class TestReviewerPromptFormat:
def test_reviewer_prompt_contains_verdict_section(self):
content = _read_prompt("reviewer.md")
assert "## Verdict" in content, "reviewer.md must contain '## Verdict' section"
def test_reviewer_prompt_contains_details_section(self):
content = _read_prompt("reviewer.md")
assert "## Details" in content, "reviewer.md must contain '## Details' section"
def test_reviewer_prompt_verdict_instructs_plain_russian(self):
"""Verdict section must instruct plain Russian for the project director."""
content = _read_prompt("reviewer.md")
assert "Russian" in content or "russian" in content, (
"reviewer.md must mention Russian language for the Verdict section"
)
def test_reviewer_prompt_details_uses_json_fence(self):
"""Details section must specify JSON output in a ```json code fence."""
content = _read_prompt("reviewer.md")
assert "```json" in content, "reviewer.md Details section must use ```json fence"
def test_reviewer_prompt_verdict_forbids_json(self):
"""Verdict description must explicitly say no JSON/code in that section."""
content = _read_prompt("reviewer.md")
# The prompt should say something like "No JSON" near the Verdict section
assert "No JSON" in content or "no JSON" in content or "no code" in content.lower(), (
"reviewer.md Verdict section must explicitly say no JSON/code snippets"
)
def test_reviewer_prompt_has_example_verdict(self):
"""Prompt must contain an example of a plain-language verdict."""
content = _read_prompt("reviewer.md")
# The examples in the prompt contain Russian text after ## Verdict
assert "Реализация" in content or "проверен" in content.lower(), (
"reviewer.md must contain a Russian-language example verdict"
)
class TestTesterPromptFormat:
def test_tester_prompt_contains_verdict_section(self):
content = _read_prompt("tester.md")
assert "## Verdict" in content, "tester.md must contain '## Verdict' section"
def test_tester_prompt_contains_details_section(self):
content = _read_prompt("tester.md")
assert "## Details" in content, "tester.md must contain '## Details' section"
def test_tester_prompt_verdict_instructs_plain_russian(self):
content = _read_prompt("tester.md")
assert "Russian" in content or "russian" in content, (
"tester.md must mention Russian language for the Verdict section"
)
def test_tester_prompt_details_uses_json_fence(self):
content = _read_prompt("tester.md")
assert "```json" in content, "tester.md Details section must use ```json fence"
def test_tester_prompt_verdict_forbids_json(self):
content = _read_prompt("tester.md")
assert "No JSON" in content or "no JSON" in content or "no code" in content.lower(), (
"tester.md Verdict section must explicitly say no JSON/code snippets"
)
def test_tester_prompt_has_example_verdict(self):
content = _read_prompt("tester.md")
# The examples contain Russian text
assert "Написано" in content or "тест" in content.lower(), (
"tester.md must contain a Russian-language example verdict"
)
class TestBothPromptsStructure:
def test_reviewer_verdict_comes_before_details(self):
"""## Verdict section must appear before ## Details in reviewer.md."""
content = _read_prompt("reviewer.md")
verdict_pos = content.find("## Verdict")
details_pos = content.find("## Details")
assert verdict_pos != -1, "## Verdict must exist"
assert details_pos != -1, "## Details must exist"
assert verdict_pos < details_pos, "## Verdict must come before ## Details"
def test_tester_verdict_comes_before_details(self):
"""## Verdict section must appear before ## Details in tester.md."""
content = _read_prompt("tester.md")
verdict_pos = content.find("## Verdict")
details_pos = content.find("## Details")
assert verdict_pos != -1
assert details_pos != -1
assert verdict_pos < details_pos, "## Verdict must come before ## Details in tester.md"
def test_reviewer_details_status_field_documented(self):
"""Details JSON must document a 'verdict' field."""
content = _read_prompt("reviewer.md")
assert '"verdict"' in content, "reviewer.md Details must document 'verdict' field"
def test_tester_details_status_field_documented(self):
"""Details JSON must document a 'status' field."""
content = _read_prompt("tester.md")
assert '"status"' in content, "tester.md Details must document 'status' field"

View file

@ -2602,3 +2602,165 @@ class TestCheckClaudeAuth:
def test_ok_when_timeout(self, mock_run):
"""При TimeoutExpired не бросает исключение (не блокируем на timeout)."""
check_claude_auth() # должна вернуть None без исключений
# ---------------------------------------------------------------------------
# KIN-OBS-030: PM-шаг инструментирован в pipeline_log
# ---------------------------------------------------------------------------
class TestPMStepPipelineLog:
"""Проверяет, что PM-шаг записывается в pipeline_log после run_pipeline."""
@patch("agents.runner._run_autocommit")
@patch("agents.runner._run_learning_extraction")
@patch("agents.runner.subprocess.run")
def test_pm_log_entry_written_when_pm_result_provided(
self, mock_run, mock_learn, mock_autocommit, conn
):
"""Если pm_result передан в run_pipeline, в pipeline_log появляется запись PM-шага."""
mock_run.return_value = _mock_claude_success({"result": "done"})
mock_learn.return_value = {"added": 0, "skipped": 0}
pm_result = {"success": True, "duration_seconds": 5, "tokens_used": 1000, "cost_usd": 0.01}
steps = [{"role": "debugger", "brief": "find bug"}]
run_pipeline(
conn, "VDOL-001", steps,
pm_result=pm_result,
pm_started_at="2026-03-17T10:00:00",
pm_ended_at="2026-03-17T10:00:05",
)
logs = conn.execute(
"SELECT * FROM pipeline_log WHERE message='PM step: task decomposed'"
).fetchall()
assert len(logs) == 1
@patch("agents.runner._run_autocommit")
@patch("agents.runner._run_learning_extraction")
@patch("agents.runner.subprocess.run")
def test_pm_log_entry_has_correct_pipeline_id(
self, mock_run, mock_learn, mock_autocommit, conn
):
"""pipeline_id в PM-записи pipeline_log совпадает с реальным pipeline."""
mock_run.return_value = _mock_claude_success({"result": "done"})
mock_learn.return_value = {"added": 0, "skipped": 0}
pm_result = {"success": True, "duration_seconds": 3, "tokens_used": 800, "cost_usd": 0.008}
steps = [{"role": "debugger", "brief": "find bug"}]
run_pipeline(
conn, "VDOL-001", steps,
pm_result=pm_result,
pm_started_at="2026-03-17T10:00:00",
pm_ended_at="2026-03-17T10:00:03",
)
pipeline = conn.execute("SELECT * FROM pipelines WHERE task_id='VDOL-001'").fetchone()
assert pipeline is not None
pm_log = conn.execute(
"SELECT * FROM pipeline_log WHERE message='PM step: task decomposed'"
).fetchone()
assert pm_log is not None
assert pm_log["pipeline_id"] == pipeline["id"]
@patch("agents.runner._run_autocommit")
@patch("agents.runner._run_learning_extraction")
@patch("agents.runner.subprocess.run")
def test_pm_log_entry_has_step_pm_in_extra(
self, mock_run, mock_learn, mock_autocommit, conn
):
"""extra_json PM-записи содержит role='pm' и корректные данные тайминга."""
mock_run.return_value = _mock_claude_success({"result": "done"})
mock_learn.return_value = {"added": 0, "skipped": 0}
pm_result = {"success": True, "duration_seconds": 7, "tokens_used": 1500, "cost_usd": 0.02}
steps = [{"role": "debugger", "brief": "find bug"}]
run_pipeline(
conn, "VDOL-001", steps,
pm_result=pm_result,
pm_started_at="2026-03-17T10:00:00",
pm_ended_at="2026-03-17T10:00:07",
)
row = conn.execute(
"SELECT extra_json FROM pipeline_log WHERE message='PM step: task decomposed'"
).fetchone()
assert row is not None
extra = json.loads(row["extra_json"])
assert extra["role"] == "pm"
assert extra["duration_seconds"] == 7
assert extra["pm_started_at"] == "2026-03-17T10:00:00"
assert extra["pm_ended_at"] == "2026-03-17T10:00:07"
@patch("agents.runner._run_autocommit")
@patch("agents.runner._run_learning_extraction")
@patch("agents.runner.subprocess.run")
def test_pm_log_not_written_when_pm_result_is_none(
self, mock_run, mock_learn, mock_autocommit, conn
):
"""Если pm_result не передан (None), записи PM-шага в pipeline_log нет."""
mock_run.return_value = _mock_claude_success({"result": "done"})
mock_learn.return_value = {"added": 0, "skipped": 0}
steps = [{"role": "debugger", "brief": "find bug"}]
run_pipeline(conn, "VDOL-001", steps) # pm_result=None по умолчанию
pm_logs = conn.execute(
"SELECT * FROM pipeline_log WHERE message='PM step: task decomposed'"
).fetchall()
assert len(pm_logs) == 0
@patch("agents.runner._run_autocommit")
@patch("agents.runner._run_learning_extraction")
@patch("agents.runner.subprocess.run")
def test_pm_log_not_written_for_sub_pipeline(
self, mock_run, mock_learn, mock_autocommit, conn
):
"""PM-лог НЕ записывается в sub-pipeline (parent_pipeline_id задан)."""
mock_run.return_value = _mock_claude_success({"result": "done"})
mock_learn.return_value = {"added": 0, "skipped": 0}
# Сначала создаём родительский pipeline
parent_pipeline = models.create_pipeline(conn, "VDOL-001", "vdol", "linear", [])
pm_result = {"success": True, "duration_seconds": 4, "tokens_used": 900, "cost_usd": 0.009}
steps = [{"role": "debugger", "brief": "find bug"}]
run_pipeline(
conn, "VDOL-001", steps,
pm_result=pm_result,
pm_started_at="2026-03-17T10:00:00",
pm_ended_at="2026-03-17T10:00:04",
parent_pipeline_id=parent_pipeline["id"],
)
pm_logs = conn.execute(
"SELECT * FROM pipeline_log WHERE message='PM step: task decomposed'"
).fetchall()
assert len(pm_logs) == 0
@patch("agents.runner._run_autocommit")
@patch("agents.runner._run_learning_extraction")
@patch("agents.runner.subprocess.run")
def test_pm_log_no_orphan_records(
self, mock_run, mock_learn, mock_autocommit, conn
):
"""FK integrity: все записи pipeline_log ссылаются на существующий pipeline."""
mock_run.return_value = _mock_claude_success({"result": "done"})
mock_learn.return_value = {"added": 0, "skipped": 0}
pm_result = {"success": True, "duration_seconds": 2, "tokens_used": 500, "cost_usd": 0.005}
steps = [{"role": "debugger", "brief": "find bug"}]
run_pipeline(
conn, "VDOL-001", steps,
pm_result=pm_result,
pm_started_at="2026-03-17T10:00:00",
pm_ended_at="2026-03-17T10:00:02",
)
# Проверяем FK через JOIN — orphan-записей не должно быть
orphans = conn.execute(
"""SELECT pl.id FROM pipeline_log pl
LEFT JOIN pipelines p ON pl.pipeline_id = p.id
WHERE p.id IS NULL"""
).fetchall()
assert len(orphans) == 0

View file

@ -792,7 +792,7 @@ describe('KIN-015: TaskDetail — Edit button и форма редактиров
// ─────────────────────────────────────────────────────────────
describe('KIN-049: TaskDetail — кнопка Deploy', () => {
function makeDeployTask(status: string, deployCommand: string | null) {
function makeDeployTask(status: string, deployCommand: string | null, deployRuntime: string | null = null) {
return {
id: 'KIN-049',
project_id: 'KIN',
@ -805,6 +805,9 @@ describe('KIN-049: TaskDetail — кнопка Deploy', () => {
spec: null,
execution_mode: null,
project_deploy_command: deployCommand,
project_deploy_host: null,
project_deploy_path: null,
project_deploy_runtime: deployRuntime,
created_at: '2024-01-01',
updated_at: '2024-01-01',
pipeline_steps: [],
@ -827,8 +830,8 @@ describe('KIN-049: TaskDetail — кнопка Deploy', () => {
expect(deployBtn?.exists(), 'Кнопка Deploy должна быть видна при done + deploy_command').toBe(true)
})
it('Кнопка Deploy скрыта при status=done но без project_deploy_command', async () => {
vi.mocked(api.taskFull).mockResolvedValue(makeDeployTask('done', null) as any)
it('Кнопка Deploy скрыта при status=done без project_deploy_command и project_deploy_runtime', async () => {
vi.mocked(api.taskFull).mockResolvedValue(makeDeployTask('done', null, null) as any)
const router = makeRouter()
await router.push('/task/KIN-049')
@ -839,7 +842,22 @@ describe('KIN-049: TaskDetail — кнопка Deploy', () => {
await flushPromises()
const hasDeployBtn = wrapper.findAll('button').some(b => b.text().includes('Deploy'))
expect(hasDeployBtn, 'Deploy не должна быть видна без deploy_command').toBe(false)
expect(hasDeployBtn, 'Deploy не должна быть видна без deploy_command и deploy_runtime').toBe(false)
})
it('Кнопка Deploy видна при status=done и только project_deploy_runtime задан', async () => {
vi.mocked(api.taskFull).mockResolvedValue(makeDeployTask('done', null, 'node') as any)
const router = makeRouter()
await router.push('/task/KIN-049')
const wrapper = mount(TaskDetail, {
props: { id: 'KIN-049' },
global: { plugins: [router] },
})
await flushPromises()
const deployBtn = wrapper.findAll('button').find(b => b.text().includes('Deploy'))
expect(deployBtn?.exists(), 'Кнопка Deploy должна быть видна при done + deploy_runtime').toBe(true)
})
it('Кнопка Deploy скрыта при status=pending (даже с deploy_command)', async () => {

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { api, type Project, type ObsidianSyncResult } from '../api'
import { api, type Project, type ObsidianSyncResult, type ProjectLink } from '../api'
const projects = ref<Project[]>([])
const vaultPaths = ref<Record<string, string>>({})
@ -8,12 +8,10 @@ const deployCommands = ref<Record<string, string>>({})
const testCommands = ref<Record<string, string>>({})
const autoTestEnabled = ref<Record<string, boolean>>({})
const saving = ref<Record<string, boolean>>({})
const savingDeploy = ref<Record<string, boolean>>({})
const savingTest = ref<Record<string, boolean>>({})
const savingAutoTest = ref<Record<string, boolean>>({})
const syncing = ref<Record<string, boolean>>({})
const saveStatus = ref<Record<string, string>>({})
const saveDeployStatus = ref<Record<string, string>>({})
const saveTestStatus = ref<Record<string, string>>({})
const saveAutoTestStatus = ref<Record<string, string>>({})
const syncResults = ref<Record<string, ObsidianSyncResult | null>>({})
@ -27,9 +25,19 @@ const deployRestartCmds = ref<Record<string, string>>({})
const savingDeployConfig = ref<Record<string, boolean>>({})
const saveDeployConfigStatus = ref<Record<string, string>>({})
// Project Links
const projectLinksMap = ref<Record<string, ProjectLink[]>>({})
const linksLoading = ref<Record<string, boolean>>({})
const showAddLinkForm = ref<Record<string, boolean>>({})
const linkForms = ref<Record<string, { to_project: string; link_type: string; description: string }>>({})
const linkSaving = ref<Record<string, boolean>>({})
const linkError = ref<Record<string, string>>({})
const allProjectList = ref<{ id: string; name: string }[]>([])
onMounted(async () => {
try {
projects.value = await api.projects()
allProjectList.value = projects.value.map(p => ({ id: p.id, name: p.name }))
for (const p of projects.value) {
vaultPaths.value[p.id] = p.obsidian_vault_path ?? ''
deployCommands.value[p.id] = p.deploy_command ?? ''
@ -39,9 +47,12 @@ onMounted(async () => {
deployPaths.value[p.id] = p.deploy_path ?? ''
deployRuntimes.value[p.id] = p.deploy_runtime ?? ''
deployRestartCmds.value[p.id] = p.deploy_restart_cmd ?? ''
linkForms.value[p.id] = { to_project: '', link_type: 'depends_on', description: '' }
projectLinksMap.value[p.id] = []
}
} catch (e) {
error.value = String(e)
await Promise.all(projects.value.map(p => loadLinks(p.id)))
} catch (e: unknown) {
error.value = e instanceof Error ? e.message : String(e)
}
})
@ -50,14 +61,15 @@ async function saveDeployConfig(projectId: string) {
saveDeployConfigStatus.value[projectId] = ''
try {
await api.patchProject(projectId, {
deploy_host: deployHosts.value[projectId],
deploy_path: deployPaths.value[projectId],
deploy_runtime: deployRuntimes.value[projectId],
deploy_restart_cmd: deployRestartCmds.value[projectId],
deploy_host: deployHosts.value[projectId] || undefined,
deploy_path: deployPaths.value[projectId] || undefined,
deploy_runtime: deployRuntimes.value[projectId] || undefined,
deploy_restart_cmd: deployRestartCmds.value[projectId] || undefined,
deploy_command: deployCommands.value[projectId] || undefined,
})
saveDeployConfigStatus.value[projectId] = 'Saved'
} catch (e) {
saveDeployConfigStatus.value[projectId] = `Error: ${e}`
} catch (e: unknown) {
saveDeployConfigStatus.value[projectId] = `Error: ${e instanceof Error ? e.message : String(e)}`
} finally {
savingDeployConfig.value[projectId] = false
}
@ -69,34 +81,21 @@ async function saveVaultPath(projectId: string) {
try {
await api.patchProject(projectId, { obsidian_vault_path: vaultPaths.value[projectId] })
saveStatus.value[projectId] = 'Saved'
} catch (e) {
saveStatus.value[projectId] = `Error: ${e}`
} catch (e: unknown) {
saveStatus.value[projectId] = `Error: ${e instanceof Error ? e.message : String(e)}`
} finally {
saving.value[projectId] = false
}
}
async function saveDeployCommand(projectId: string) {
savingDeploy.value[projectId] = true
saveDeployStatus.value[projectId] = ''
try {
await api.patchProject(projectId, { deploy_command: deployCommands.value[projectId] })
saveDeployStatus.value[projectId] = 'Saved'
} catch (e) {
saveDeployStatus.value[projectId] = `Error: ${e}`
} finally {
savingDeploy.value[projectId] = false
}
}
async function saveTestCommand(projectId: string) {
savingTest.value[projectId] = true
saveTestStatus.value[projectId] = ''
try {
await api.patchProject(projectId, { test_command: testCommands.value[projectId] })
saveTestStatus.value[projectId] = 'Saved'
} catch (e) {
saveTestStatus.value[projectId] = `Error: ${e}`
} catch (e: unknown) {
saveTestStatus.value[projectId] = `Error: ${e instanceof Error ? e.message : String(e)}`
} finally {
savingTest.value[projectId] = false
}
@ -109,9 +108,9 @@ async function toggleAutoTest(projectId: string) {
try {
await api.patchProject(projectId, { auto_test_enabled: autoTestEnabled.value[projectId] })
saveAutoTestStatus.value[projectId] = 'Saved'
} catch (e) {
} catch (e: unknown) {
autoTestEnabled.value[projectId] = !autoTestEnabled.value[projectId]
saveAutoTestStatus.value[projectId] = `Error: ${e}`
saveAutoTestStatus.value[projectId] = `Error: ${e instanceof Error ? e.message : String(e)}`
} finally {
savingAutoTest.value[projectId] = false
}
@ -124,12 +123,55 @@ async function runSync(projectId: string) {
try {
await api.patchProject(projectId, { obsidian_vault_path: vaultPaths.value[projectId] })
syncResults.value[projectId] = await api.syncObsidian(projectId)
} catch (e) {
saveStatus.value[projectId] = `Sync error: ${e}`
} catch (e: unknown) {
saveStatus.value[projectId] = `Sync error: ${e instanceof Error ? e.message : String(e)}`
} finally {
syncing.value[projectId] = false
}
}
async function loadLinks(projectId: string) {
linksLoading.value[projectId] = true
try {
projectLinksMap.value[projectId] = await api.projectLinks(projectId)
} catch (e: unknown) {
linkError.value[projectId] = e instanceof Error ? e.message : String(e)
} finally {
linksLoading.value[projectId] = false
}
}
async function addLink(projectId: string) {
const form = linkForms.value[projectId]
if (!form.to_project) { linkError.value[projectId] = '&#x412;&#x44B;&#x431;&#x435;&#x440;&#x438;&#x442;&#x435; &#x43F;&#x440;&#x43E;&#x435;&#x43A;&#x442;'; return }
linkSaving.value[projectId] = true
linkError.value[projectId] = ''
try {
await api.createProjectLink({
from_project: projectId,
to_project: form.to_project,
link_type: form.link_type,
description: form.description || undefined,
})
showAddLinkForm.value[projectId] = false
linkForms.value[projectId] = { to_project: '', link_type: 'depends_on', description: '' }
await loadLinks(projectId)
} catch (e: unknown) {
linkError.value[projectId] = e instanceof Error ? e.message : String(e)
} finally {
linkSaving.value[projectId] = false
}
}
async function deleteLink(projectId: string, linkId: number) {
if (!confirm('&#x423;&#x434;&#x430;&#x43B;&#x438;&#x442;&#x44C; &#x441;&#x432;&#x44F;&#x437;&#x44C;?')) return
try {
await api.deleteProjectLink(linkId)
await loadLinks(projectId)
} catch (e: unknown) {
linkError.value[projectId] = e instanceof Error ? e.message : String(e)
}
}
</script>
<template>
@ -154,30 +196,6 @@ async function runSync(projectId: string) {
/>
</div>
<div class="mb-3">
<label class="block text-xs text-gray-400 mb-1">Deploy Command</label>
<input
v-model="deployCommands[project.id]"
type="text"
placeholder="git push origin main"
class="w-full bg-gray-900 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
/>
<p class="text-xs text-gray-600 mt-1">Команда выполняется через shell в директории проекта. Настраивается только администратором.</p>
</div>
<div class="flex items-center gap-3 flex-wrap mb-3">
<button
@click="saveDeployCommand(project.id)"
:disabled="savingDeploy[project.id]"
class="px-3 py-1.5 text-sm bg-gray-700 hover:bg-gray-600 text-gray-200 rounded disabled:opacity-50"
>
{{ savingDeploy[project.id] ? 'Saving…' : 'Save Deploy' }}
</button>
<span v-if="saveDeployStatus[project.id]" class="text-xs" :class="saveDeployStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">
{{ saveDeployStatus[project.id] }}
</span>
</div>
<div class="mb-3">
<label class="block text-xs text-gray-400 mb-1">Test Command</label>
<input
@ -186,7 +204,7 @@ async function runSync(projectId: string) {
placeholder="make test"
class="w-full bg-gray-900 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
/>
<p class="text-xs text-gray-600 mt-1">Команда запуска тестов, выполняется через shell в директории проекта.</p>
<p class="text-xs text-gray-600 mt-1">&#x41A;&#x43E;&#x43C;&#x430;&#x43D;&#x434;&#x430; &#x437;&#x430;&#x43F;&#x443;&#x441;&#x43A;&#x430; &#x442;&#x435;&#x441;&#x442;&#x43E;&#x432;, &#x432;&#x44B;&#x43F;&#x43E;&#x43B;&#x43D;&#x44F;&#x435;&#x442;&#x441;&#x44F; &#x447;&#x435;&#x440;&#x435;&#x437; shell &#x432; &#x434;&#x438;&#x440;&#x435;&#x43A;&#x442;&#x43E;&#x440;&#x438;&#x438; &#x43F;&#x440;&#x43E;&#x435;&#x43A;&#x442;&#x430;.</p>
</div>
<div class="flex items-center gap-3 flex-wrap mb-3">
@ -195,7 +213,7 @@ async function runSync(projectId: string) {
:disabled="savingTest[project.id]"
class="px-3 py-1.5 text-sm bg-gray-700 hover:bg-gray-600 text-gray-200 rounded disabled:opacity-50"
>
{{ savingTest[project.id] ? 'Saving' : 'Save Test' }}
{{ savingTest[project.id] ? 'Saving&#x2026;' : 'Save Test' }}
</button>
<span v-if="saveTestStatus[project.id]" class="text-xs" :class="saveTestStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">
{{ saveTestStatus[project.id] }}
@ -229,7 +247,7 @@ async function runSync(projectId: string) {
v-model="deployRuntimes[project.id]"
class="w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-300 focus:outline-none focus:border-gray-500"
>
<option value=""> выберите runtime </option>
<option value="">&#x2014; &#x432;&#x44B;&#x431;&#x435;&#x440;&#x438;&#x442;&#x435; runtime &#x2014;</option>
<option value="docker">docker</option>
<option value="node">node</option>
<option value="python">python</option>
@ -245,13 +263,22 @@ async function runSync(projectId: string) {
class="w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
/>
</div>
<div class="mb-2">
<label class="block text-xs text-gray-500 mb-1">Fallback command (legacy, used when runtime not set)</label>
<input
v-model="deployCommands[project.id]"
type="text"
placeholder="git push origin main"
class="w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
/>
</div>
<div class="flex items-center gap-3 flex-wrap mb-3">
<button
@click="saveDeployConfig(project.id)"
:disabled="savingDeployConfig[project.id]"
class="px-3 py-1.5 text-sm bg-teal-900/50 text-teal-400 border border-teal-800 rounded hover:bg-teal-900 disabled:opacity-50"
>
{{ savingDeployConfig[project.id] ? 'Saving…' : 'Save Deploy Config' }}
{{ savingDeployConfig[project.id] ? 'Saving&#x2026;' : 'Save Deploy Config' }}
</button>
<span v-if="saveDeployConfigStatus[project.id]" class="text-xs" :class="saveDeployConfigStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">
{{ saveDeployConfigStatus[project.id] }}
@ -259,6 +286,74 @@ async function runSync(projectId: string) {
</div>
</div>
<!-- Project Links -->
<div class="mb-2 pt-2 border-t border-gray-800">
<div class="flex items-center justify-between mb-2">
<p class="text-xs font-semibold text-gray-400">Project Links</p>
<button
@click="showAddLinkForm[project.id] = !showAddLinkForm[project.id]"
class="px-2 py-0.5 text-xs bg-gray-800 text-gray-300 border border-gray-700 rounded hover:bg-gray-700"
>
+ Add Link
</button>
</div>
<p v-if="linksLoading[project.id]" class="text-xs text-gray-500">&#x417;&#x430;&#x433;&#x440;&#x443;&#x437;&#x43A;&#x430;...</p>
<p v-else-if="linkError[project.id]" class="text-xs text-red-400">{{ linkError[project.id] }}</p>
<div v-else-if="!projectLinksMap[project.id]?.length" class="text-xs text-gray-600">&#x41D;&#x435;&#x442; &#x441;&#x432;&#x44F;&#x437;&#x435;&#x439;</div>
<div v-else class="space-y-1 mb-2">
<div v-for="link in projectLinksMap[project.id]" :key="link.id"
class="flex items-center gap-2 px-2 py-1 bg-gray-900 border border-gray-800 rounded text-xs">
<span class="text-gray-500 font-mono">{{ link.from_project }}</span>
<span class="text-gray-600">&#x2192;</span>
<span class="text-gray-500 font-mono">{{ link.to_project }}</span>
<span class="px-1 bg-indigo-900/30 text-indigo-400 border border-indigo-800 rounded">{{ link.link_type }}</span>
<span v-if="link.description" class="text-gray-600">{{ link.description }}</span>
<button @click="deleteLink(project.id, link.id)"
class="ml-auto text-red-500 hover:text-red-400 bg-transparent border-none cursor-pointer text-xs shrink-0">
&#x2715;
</button>
</div>
</div>
<form v-if="showAddLinkForm[project.id]" @submit.prevent="addLink(project.id)" class="space-y-2 p-2 bg-gray-900 border border-gray-800 rounded">
<div>
<label class="block text-[10px] text-gray-500 mb-0.5">From (current)</label>
<input :value="project.id" disabled class="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-500 font-mono" />
</div>
<div>
<label class="block text-[10px] text-gray-500 mb-0.5">To project</label>
<select v-model="linkForms[project.id].to_project" required
class="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-300">
<option value="">&#x2014; &#x432;&#x44B;&#x431;&#x435;&#x440;&#x438;&#x442;&#x435; &#x43F;&#x440;&#x43E;&#x435;&#x43A;&#x442; &#x2014;</option>
<option v-for="p in allProjectList.filter(p => p.id !== project.id)" :key="p.id" :value="p.id">{{ p.id }} &#x2014; {{ p.name }}</option>
</select>
</div>
<div>
<label class="block text-[10px] text-gray-500 mb-0.5">Link type</label>
<select v-model="linkForms[project.id].link_type"
class="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-300">
<option value="depends_on">depends_on</option>
<option value="triggers">triggers</option>
<option value="related_to">related_to</option>
</select>
</div>
<div>
<label class="block text-[10px] text-gray-500 mb-0.5">Description (optional)</label>
<input v-model="linkForms[project.id].description" placeholder="e.g. API used by frontend"
class="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600" />
</div>
<div class="flex gap-2">
<button type="submit" :disabled="linkSaving[project.id]"
class="px-3 py-1 text-xs bg-blue-900/50 text-blue-400 border border-blue-800 rounded hover:bg-blue-900 disabled:opacity-50">
{{ linkSaving[project.id] ? 'Saving...' : 'Add' }}
</button>
<button type="button" @click="showAddLinkForm[project.id] = false; linkError[project.id] = ''"
class="px-3 py-1 text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none cursor-pointer">
&#x41E;&#x442;&#x43C;&#x435;&#x43D;&#x430;
</button>
</div>
</form>
</div>
<div class="flex items-center gap-3 mb-3">
<label class="flex items-center gap-2 cursor-pointer select-none">
<input
@ -269,7 +364,7 @@ async function runSync(projectId: string) {
class="w-4 h-4 rounded border-gray-600 bg-gray-800 accent-blue-500 cursor-pointer disabled:opacity-50"
/>
<span class="text-sm text-gray-300">Auto-test</span>
<span class="text-xs text-gray-500"> запускать тесты автоматически после pipeline</span>
<span class="text-xs text-gray-500">&#x2014; &#x437;&#x430;&#x43F;&#x443;&#x441;&#x43A;&#x430;&#x442;&#x44C; &#x442;&#x435;&#x441;&#x442;&#x44B; &#x430;&#x432;&#x442;&#x43E;&#x43C;&#x430;&#x442;&#x438;&#x447;&#x435;&#x441;&#x43A;&#x438; &#x43F;&#x43E;&#x441;&#x43B;&#x435; pipeline</span>
</label>
<span v-if="saveAutoTestStatus[project.id]" class="text-xs" :class="saveAutoTestStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">
{{ saveAutoTestStatus[project.id] }}
@ -282,7 +377,7 @@ async function runSync(projectId: string) {
:disabled="saving[project.id]"
class="px-3 py-1.5 text-sm bg-gray-700 hover:bg-gray-600 text-gray-200 rounded disabled:opacity-50"
>
{{ saving[project.id] ? 'Saving' : 'Save Vault' }}
{{ saving[project.id] ? 'Saving&#x2026;' : 'Save Vault' }}
</button>
<button
@ -290,7 +385,7 @@ async function runSync(projectId: string) {
:disabled="syncing[project.id] || !vaultPaths[project.id]"
class="px-3 py-1.5 text-sm bg-indigo-700 hover:bg-indigo-600 text-white rounded disabled:opacity-50"
>
{{ syncing[project.id] ? 'Syncing' : 'Sync Obsidian' }}
{{ syncing[project.id] ? 'Syncing&#x2026;' : 'Sync Obsidian' }}
</button>
<span v-if="saveStatus[project.id]" class="text-xs" :class="saveStatus[project.id].startsWith('Error') ? 'text-red-400' : 'text-green-400'">