kin: KIN-083 Healthcheck claude CLI auth: перед запуском pipeline проверять что claude залогинен (быстрый claude -p 'ok' --output-format json, проверить is_error и 'Not logged in'). Если не залогинен — не запускать pipeline, а показать ошибку 'Claude CLI requires login' в GUI с инструкцией.
This commit is contained in:
parent
a80679ae72
commit
bfc8f1c0bb
18 changed files with 1390 additions and 57 deletions
34
core/db.py
34
core/db.py
|
|
@ -457,13 +457,20 @@ def _seed_default_hooks(conn: sqlite3.Connection):
|
|||
Creates rebuild-frontend hook only when:
|
||||
- project 'kin' exists in the projects table
|
||||
- the hook doesn't already exist (no duplicate)
|
||||
|
||||
Also updates existing hooks to the correct command/config if outdated.
|
||||
"""
|
||||
kin_exists = conn.execute(
|
||||
"SELECT 1 FROM projects WHERE id = 'kin'"
|
||||
kin_row = conn.execute(
|
||||
"SELECT path FROM projects WHERE id = 'kin'"
|
||||
).fetchone()
|
||||
if not kin_exists:
|
||||
if not kin_row or not kin_row["path"]:
|
||||
return
|
||||
|
||||
_PROJECT_PATH = kin_row["path"].rstrip("/")
|
||||
_REBUILD_SCRIPT = f"{_PROJECT_PATH}/scripts/rebuild-frontend.sh"
|
||||
_REBUILD_TRIGGER = "web/frontend/*"
|
||||
_REBUILD_WORKDIR = _PROJECT_PATH
|
||||
|
||||
exists = conn.execute(
|
||||
"SELECT 1 FROM hooks"
|
||||
" WHERE project_id = 'kin'"
|
||||
|
|
@ -472,12 +479,25 @@ def _seed_default_hooks(conn: sqlite3.Connection):
|
|||
).fetchone()
|
||||
if not exists:
|
||||
conn.execute(
|
||||
"""INSERT INTO hooks (project_id, name, event, command, enabled)
|
||||
"""INSERT INTO hooks
|
||||
(project_id, name, event, trigger_module_path, command,
|
||||
working_dir, timeout_seconds, enabled)
|
||||
VALUES ('kin', 'rebuild-frontend', 'pipeline_completed',
|
||||
'cd /Users/grosfrumos/projects/kin/web/frontend && npm run build',
|
||||
1)"""
|
||||
?, ?, ?, 300, 1)""",
|
||||
(_REBUILD_TRIGGER, _REBUILD_SCRIPT, _REBUILD_WORKDIR),
|
||||
)
|
||||
conn.commit()
|
||||
else:
|
||||
# Migrate existing hook: set trigger_module_path, correct command, working_dir
|
||||
conn.execute(
|
||||
"""UPDATE hooks
|
||||
SET trigger_module_path = ?,
|
||||
command = ?,
|
||||
working_dir = ?,
|
||||
timeout_seconds = 300
|
||||
WHERE project_id = 'kin' AND name = 'rebuild-frontend'""",
|
||||
(_REBUILD_TRIGGER, _REBUILD_SCRIPT, _REBUILD_WORKDIR),
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
# Enable autocommit for kin project (opt-in, idempotent)
|
||||
conn.execute(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue