commandmate 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +131 -131
- package/.next/app-path-routes-manifest.json +23 -23
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +9 -9
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update-check/route.js +1 -1
- package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/subscriptions/route.js +1 -1
- package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/[todoId]/route.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/route.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/route.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/todos/route.js +1 -1
- package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/verification/runs/[runId]/route.js +1 -1
- package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/verification/runs/route.js +1 -1
- package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-tool/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branches/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/commit/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/diff/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/log/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/reset/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/revert/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/staged/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/push/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/status/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/working-diff/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/[filename]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/marp-render/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/messages/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/active/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/slash-commands/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/start-polling/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tasks/route.js +2 -2
- package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/history/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/more/page_client-reference-manifest.js +1 -1
- package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
- package/.next/server/app/review/page_client-reference-manifest.js +1 -1
- package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/page.js +1 -1
- package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +23 -23
- package/.next/server/chunks/1117.js +1 -1
- package/.next/server/chunks/3042.js +1 -1
- package/.next/server/chunks/3753.js +19 -23
- package/.next/server/chunks/5959.js +3 -3
- package/.next/server/chunks/6130.js +1 -1
- package/.next/server/chunks/6274.js +5 -4
- package/.next/server/chunks/6283.js +1 -1
- package/.next/server/chunks/8681.js +1 -1
- package/.next/server/chunks/8807.js +492 -487
- package/.next/server/chunks/8856.js +1 -1
- package/.next/server/middleware-manifest.json +5 -5
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{6488-109e3825c7249e47.js → 6488-2c412c29258637b6.js} +1 -1
- package/.next/static/chunks/app/worktrees/[id]/{page-12b3c5f32fc6094e.js → page-f6e09d25cd3b56f9.js} +1 -1
- package/.next/trace +12 -12
- package/dist/cli/commands/auto-yes.d.ts.map +1 -1
- package/dist/cli/commands/auto-yes.js +9 -2
- package/dist/cli/commands/capture.d.ts +1 -0
- package/dist/cli/commands/capture.d.ts.map +1 -1
- package/dist/cli/commands/capture.js +112 -2
- package/dist/cli/commands/instances.d.ts +24 -0
- package/dist/cli/commands/instances.d.ts.map +1 -1
- package/dist/cli/commands/instances.js +44 -0
- package/dist/cli/commands/respond.d.ts.map +1 -1
- package/dist/cli/commands/respond.js +10 -2
- package/dist/cli/commands/send.d.ts.map +1 -1
- package/dist/cli/commands/send.js +20 -11
- package/dist/cli/commands/wait.d.ts +4 -1
- package/dist/cli/commands/wait.d.ts.map +1 -1
- package/dist/cli/commands/wait.js +80 -6
- package/dist/cli/types/index.d.ts +16 -0
- package/dist/cli/types/index.d.ts.map +1 -1
- package/dist/cli/utils/pager.d.ts +28 -0
- package/dist/cli/utils/pager.d.ts.map +1 -0
- package/dist/cli/utils/pager.js +57 -0
- package/dist/lib/detection/ansi.d.ts +30 -0
- package/dist/lib/detection/ansi.d.ts.map +1 -0
- package/dist/lib/detection/ansi.js +39 -0
- package/dist/lib/tmux/transcript-squeeze.d.ts +76 -0
- package/dist/lib/tmux/transcript-squeeze.d.ts.map +1 -0
- package/dist/lib/tmux/transcript-squeeze.js +96 -0
- package/dist/server/server.js +18 -0
- package/dist/server/src/config/tmux-pane-config.js +33 -1
- package/dist/server/src/lib/cli-tools/antigravity.js +2 -1
- package/dist/server/src/lib/cli-tools/codex.js +3 -2
- package/dist/server/src/lib/cli-tools/copilot.js +2 -2
- package/dist/server/src/lib/cli-tools/gemini.js +2 -2
- package/dist/server/src/lib/cli-tools/opencode.js +2 -2
- package/dist/server/src/lib/cli-tools/vibe-local.js +2 -2
- package/dist/server/src/lib/db/agent-instances-db.js +53 -0
- package/dist/server/src/lib/db/migrations/index.js +2 -0
- package/dist/server/src/lib/db/migrations/runner.js +1 -1
- package/dist/server/src/lib/db/migrations/v52-orphaned-worktree-children.js +76 -0
- package/dist/server/src/lib/db/migrations/worktree-child-tables.js +119 -0
- package/dist/server/src/lib/db/worktree-db.js +65 -42
- package/dist/server/src/lib/detection/cli-patterns.js +24 -1
- package/dist/server/src/lib/detection/status-detector.js +52 -2
- package/dist/server/src/lib/session/claude-session.js +4 -2
- package/dist/server/src/lib/tmux/read-mode-pager.js +161 -0
- package/dist/server/src/lib/tmux/read-mode.js +327 -0
- package/dist/server/src/lib/tmux/tmux.js +43 -5
- package/package.json +1 -1
- /package/.next/static/{-BSmW0Ae2YsxyCl_ue7_d → -E7I667pJDTBamyG8M_Z-}/_buildManifest.js +0 -0
- /package/.next/static/{-BSmW0Ae2YsxyCl_ue7_d → -E7I667pJDTBamyG8M_Z-}/_ssgManifest.js +0 -0
|
@@ -1,451 +1,36 @@
|
|
|
1
|
-
"use strict";exports.id=8807,exports.ids=[8807],exports.modules={
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
`).run(b).changes}},43167:(a,b,c)=>{c.d(b,{CF:()=>h,gn:()=>i,jA:()=>g,jJ:()=>j,th:()=>k});var d=c(55511);function e(a){return{id:a.id,endpoint:a.endpoint,keys:{p256dh:a.p256dh,auth:a.auth},deviceLabel:a.device_label,enabledPrompt:1===a.enabled_prompt,enabledCompletion:1===a.enabled_completion,locale:a.locale,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}let f=`
|
|
32
|
-
id, endpoint, p256dh, auth, device_label,
|
|
33
|
-
enabled_prompt, enabled_completion, locale, created_at, updated_at
|
|
34
|
-
`;function g(a,b){let c=Date.now(),e=b.deviceLabel??null,f=b.locale??null;a.prepare(`
|
|
35
|
-
INSERT INTO push_subscriptions (
|
|
36
|
-
id, endpoint, p256dh, auth, device_label,
|
|
37
|
-
enabled_prompt, enabled_completion, locale, created_at, updated_at
|
|
38
|
-
)
|
|
39
|
-
VALUES (?, ?, ?, ?, ?, 1, 1, ?, ?, ?)
|
|
40
|
-
ON CONFLICT(endpoint) DO UPDATE SET
|
|
41
|
-
p256dh = excluded.p256dh,
|
|
42
|
-
auth = excluded.auth,
|
|
43
|
-
device_label = excluded.device_label,
|
|
44
|
-
locale = COALESCE(excluded.locale, push_subscriptions.locale),
|
|
45
|
-
updated_at = excluded.updated_at
|
|
46
|
-
`).run((0,d.randomUUID)(),b.endpoint,b.p256dh,b.auth,e,f,c,c);let g=h(a,b.endpoint);if(!g)throw Error("Failed to persist push subscription");return g}function h(a,b){let c=a.prepare(`SELECT ${f} FROM push_subscriptions WHERE endpoint = ?`).get(b);return c?e(c):null}function i(a,b){return a.prepare(`SELECT ${f} FROM push_subscriptions WHERE ${"prompt"===b?"enabled_prompt":"enabled_completion"} = 1 ORDER BY created_at ASC`).all().map(e)}function j(a,b,c){let d=["updated_at = ?"],e=[Date.now()];return void 0!==c.enabledPrompt&&(d.push("enabled_prompt = ?"),e.push(+!!c.enabledPrompt)),void 0!==c.enabledCompletion&&(d.push("enabled_completion = ?"),e.push(+!!c.enabledCompletion)),e.push(b),a.prepare(`UPDATE push_subscriptions SET ${d.join(", ")} WHERE endpoint = ?`).run(...e),h(a,b)}function k(a,b){return a.prepare("DELETE FROM push_subscriptions WHERE endpoint = ?").run(b).changes>0}},48524:(a,b,c)=>{c.d(b,{MH:()=>o,UT:()=>j,Vk:()=>l,Zj:()=>n,gg:()=>k,xZ:()=>m});var d=c(55511);let e=["succeeded","failed","not_started","cancelled"],f=["running","waiting_input","verifying"],g=[...f,"failed","not_started"],h=`
|
|
47
|
-
id, worktree_id, cli_tool_id, instance_id, title, goal, contract_path, contract_json,
|
|
48
|
-
status, last_verification_run_id, created_at, updated_at, started_at, finished_at
|
|
49
|
-
`;function i(a){return{id:a.id,worktreeId:a.worktree_id,cliToolId:a.cli_tool_id,instanceId:a.instance_id,title:a.title,goal:a.goal,contractPath:a.contract_path,contract:JSON.parse(a.contract_json),status:a.status,lastVerificationRunId:a.last_verification_run_id,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at),startedAt:null===a.started_at?null:new Date(a.started_at),finishedAt:null===a.finished_at?null:new Date(a.finished_at)}}function j(a,b){let c=Date.now(),e=(0,d.randomUUID)(),f=b.status??"pending";a.prepare(`
|
|
50
|
-
INSERT INTO tasks (
|
|
51
|
-
id, worktree_id, cli_tool_id, instance_id, title, goal, contract_path, contract_json,
|
|
52
|
-
status, last_verification_run_id, created_at, updated_at, started_at, finished_at
|
|
53
|
-
)
|
|
54
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, NULL)
|
|
55
|
-
`).run(e,b.worktreeId,b.cliToolId,b.instanceId??null,b.contract.title,b.contract.goal,b.contractPath??null,JSON.stringify(b.contract),f,c,c,"pending"===f?null:c);let g=k(a,e);if(!g)throw Error("Failed to persist task");return g}function k(a,b){let c=a.prepare(`SELECT ${h} FROM tasks WHERE id = ?`).get(b);return c?i(c):null}function l(a,b,c=20){return a.prepare(`
|
|
56
|
-
SELECT ${h} FROM tasks
|
|
57
|
-
WHERE worktree_id = ?
|
|
58
|
-
ORDER BY created_at DESC, rowid DESC
|
|
59
|
-
LIMIT ?
|
|
60
|
-
`).all(b,c).map(i)}function m(a,b,c,d={}){let f=Date.now();if(0===a.prepare(`
|
|
61
|
-
UPDATE tasks
|
|
62
|
-
SET status = ?,
|
|
63
|
-
updated_at = ?,
|
|
64
|
-
started_at = CASE WHEN ? = 'pending' THEN started_at ELSE COALESCE(started_at, ?) END,
|
|
65
|
-
finished_at = CASE WHEN ? = 1 THEN ? ELSE finished_at END,
|
|
66
|
-
last_verification_run_id = COALESCE(?, last_verification_run_id)
|
|
67
|
-
WHERE id = ?
|
|
68
|
-
`).run(c,f,c,f,+!!e.includes(c),f,d.lastVerificationRunId??null,b).changes)throw Error(`Task ${b} not found`);return k(a,b)}function n(a,b){let c=g.map(()=>"?").join(", "),d=a.prepare(`
|
|
69
|
-
SELECT ${h} FROM tasks
|
|
70
|
-
WHERE worktree_id = ? AND status IN (${c})
|
|
71
|
-
ORDER BY updated_at DESC, created_at DESC, rowid DESC
|
|
72
|
-
LIMIT 1
|
|
73
|
-
`).get(b,...g);return d?i(d):null}function o(a,b,c,d){let e=d===c,g=f.map(()=>"?").join(", "),j=a.prepare(`
|
|
74
|
-
SELECT ${h} FROM tasks
|
|
75
|
-
WHERE worktree_id = ?
|
|
76
|
-
AND cli_tool_id = ?
|
|
77
|
-
AND (instance_id = ? OR (instance_id IS NULL AND ?))
|
|
78
|
-
AND status IN (${g})
|
|
79
|
-
ORDER BY updated_at DESC, created_at DESC, rowid DESC
|
|
80
|
-
LIMIT 1
|
|
81
|
-
`).get(b,c,d,+!!e,...f);return j?i(j):null}},87374:(a,b,c)=>{c.d(b,{Dr:()=>i,HR:()=>h,Ky:()=>f,XS:()=>e,ms:()=>g,u8:()=>d}),Array.from({length:Math.floor(104)+1},(a,b)=>3e5+3e5*b);let d=5,e=50,f=100,g=1e4,h={PENDING:"pending",SENDING:"sending",SENT:"sent",FAILED:"failed",CANCELLED:"cancelled",NO_SESSION:"no_session"};function i(a){return"number"==typeof a&&a>=3e5&&a<=315e5&&a%3e5==0}},88807:(a,b,c)=>{c.r(b),c.d(b,{closeDbInstance:()=>p,getDbInstance:()=>o});var d=c(33873),e=c.n(d),f=c(92046),g=c(79646),h=c(87550),i=c.n(h);let j=!1;function k(a){return a instanceof Error&&"ERR_DLOPEN_FAILED"===a.code&&a.message.includes("NODE_MODULE_VERSION")}function l(a,b){let c=["better-sqlite3 could not be loaded: it was built for a different Node.js version.","This usually happens after switching Node.js versions (nvm, fnm, Homebrew, ...).","",`Automatic recovery failed: ${a}`,"","How to fix it manually:"];return b?c.push(" The install directory is not writable by the current user, so the addon"," cannot be rebuilt in place. Do not re-run this with sudo — root-owned"," files there will break future installs and updates.",""," Either switch back to the Node.js version CommandMate was installed with:",` node -v (currently ${process.version}, NODE_MODULE_VERSION ${process.versions.modules})`,""," Or reinstall CommandMate under a Node.js version manager, which keeps"," global packages in a user-owned directory:"," nvm use <version> && npm install -g commandmate"):c.push(` 1. cd ${process.cwd()}`," 2. npm rebuild better-sqlite3"," 3. Start CommandMate again",""," If that fails, reinstalling picks up the current Node.js version:"," npm install -g commandmate"),c.join("\n")}var m=c(87447);let n=null;function o(){if(!n){let a=(0,m._$)().CM_DB_PATH,b=c(29021),d=e().dirname(a);b.existsSync(d)||b.mkdirSync(d,{recursive:!0,mode:448});let h=function(a){try{return new(i())(a)}catch(c){if(!k(c))throw c;if(j)throw Error(l("a rebuild was already attempted in this process.",!1));j=!0,console.error("[commandmate] better-sqlite3 was built for a different Node.js version.\n[commandmate] Rebuilding it automatically — this can take a few minutes...");let b=function(){let a=(0,g.spawnSync)("npm",["rebuild","better-sqlite3"],{cwd:process.cwd(),encoding:"utf-8",timeout:3e5,env:{...process.env,PATH:`${e().dirname(process.execPath)}${e().delimiter}${process.env.PATH??""}`}}),b=`${a.stdout??""}${a.stderr??""}`;return a.error||0!==a.status?{success:!1,permissionDenied:/EACCES|permission denied/i.test(b),output:b}:{success:!0,permissionDenied:!1,output:b}}();if(!b.success)throw Error(l("npm rebuild better-sqlite3 failed.",b.permissionDenied));console.error("[commandmate] Rebuild succeeded. Continuing startup.");try{return new(i())(a)}catch(a){if(k(a))throw Error(l("the addon still reports a version mismatch after rebuilding.",!1));throw a}}}(a);h.pragma("foreign_keys = ON"),h.pragma("journal_mode = WAL"),h.pragma("busy_timeout = 5000");try{(0,f.vI)(h)}catch(a){throw h.close(),a}n=h}return n}function p(){n&&(n.close(),n=null)}},90444:(a,b,c)=>{function d(a){a.exec(`
|
|
82
|
-
CREATE TABLE IF NOT EXISTS worktrees (
|
|
83
|
-
id TEXT PRIMARY KEY,
|
|
84
|
-
name TEXT NOT NULL,
|
|
85
|
-
path TEXT NOT NULL UNIQUE,
|
|
86
|
-
last_message_summary TEXT,
|
|
87
|
-
updated_at INTEGER
|
|
88
|
-
);
|
|
89
|
-
`),a.exec(`
|
|
90
|
-
CREATE INDEX IF NOT EXISTS idx_worktrees_updated_at
|
|
91
|
-
ON worktrees(updated_at DESC);
|
|
92
|
-
`),a.exec(`
|
|
93
|
-
CREATE TABLE IF NOT EXISTS chat_messages (
|
|
94
|
-
id TEXT PRIMARY KEY,
|
|
95
|
-
worktree_id TEXT NOT NULL,
|
|
96
|
-
role TEXT NOT NULL CHECK(role IN ('user', 'assistant')),
|
|
97
|
-
content TEXT NOT NULL,
|
|
98
|
-
summary TEXT,
|
|
99
|
-
timestamp INTEGER NOT NULL,
|
|
100
|
-
log_file_name TEXT,
|
|
101
|
-
request_id TEXT,
|
|
102
|
-
message_type TEXT DEFAULT 'normal',
|
|
103
|
-
prompt_data TEXT,
|
|
104
|
-
cli_tool_id TEXT DEFAULT 'claude',
|
|
105
|
-
archived INTEGER DEFAULT 0,
|
|
1
|
+
"use strict";exports.id=8807,exports.ids=[8807],exports.modules={14520:(a,b,c)=>{c.d(b,{vI:()=>U});var d=c(33873),e=c.n(d);function f(a){try{let b=a.prepare("SELECT MAX(version) as version FROM schema_version").get();return b?.version??0}catch{return 0}}function g(a){let b=c(29021),d=a;for(;d!==e().dirname(d);){let a=e().join(d,".git");if(b.existsSync(a)){let c=b.statSync(a);if(c.isDirectory())return d;if(c.isFile()){let c=b.readFileSync(a,"utf-8").trim().match(/^gitdir:\s*(.+)$/);if(c)return c[1].split("/.git/")[0]}}d=e().dirname(d)}return a}var h=c(90444);let i=[{version:1,name:"initial-schema",up:a=>{(0,h.s4)(a)},down:a=>{a.exec("DROP TABLE IF EXISTS session_states;"),a.exec("DROP TABLE IF EXISTS chat_messages;"),a.exec("DROP TABLE IF EXISTS worktrees;")}},{version:2,name:"add-multi-repo-and-memo-support",up:a=>{a.exec(`
|
|
2
|
+
ALTER TABLE worktrees ADD COLUMN repository_path TEXT;
|
|
3
|
+
ALTER TABLE worktrees ADD COLUMN repository_name TEXT;
|
|
4
|
+
ALTER TABLE worktrees ADD COLUMN memo TEXT;
|
|
5
|
+
ALTER TABLE worktrees ADD COLUMN last_user_message TEXT;
|
|
6
|
+
ALTER TABLE worktrees ADD COLUMN last_user_message_at INTEGER;
|
|
7
|
+
`),a.exec(`
|
|
8
|
+
CREATE INDEX IF NOT EXISTS idx_worktrees_repository
|
|
9
|
+
ON worktrees(repository_path);
|
|
10
|
+
`);let b=a.prepare("SELECT id, path FROM worktrees").all(),c=a.prepare(`
|
|
11
|
+
UPDATE worktrees
|
|
12
|
+
SET repository_path = ?,
|
|
13
|
+
repository_name = ?
|
|
14
|
+
WHERE id = ?
|
|
15
|
+
`);for(let a of b){let b=g(a.path),d=e().basename(b);c.run(b,d,a.id)}let d=a.prepare(`
|
|
16
|
+
UPDATE worktrees
|
|
17
|
+
SET last_user_message = ?,
|
|
18
|
+
last_user_message_at = ?
|
|
19
|
+
WHERE id = ?
|
|
20
|
+
`);for(let c of b){let b=a.prepare(`
|
|
21
|
+
SELECT content, timestamp
|
|
22
|
+
FROM chat_messages
|
|
23
|
+
WHERE worktree_id = ? AND role = 'user'
|
|
24
|
+
ORDER BY timestamp DESC
|
|
25
|
+
LIMIT 1
|
|
26
|
+
`).get(c.id);if(b){let a=b.content.substring(0,200);d.run(a,b.timestamp,c.id)}}},down:a=>{a.exec(`
|
|
27
|
+
-- Create backup table
|
|
28
|
+
CREATE TABLE worktrees_backup AS
|
|
29
|
+
SELECT id, name, path, last_message_summary, updated_at
|
|
30
|
+
FROM worktrees;
|
|
106
31
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
`),a.exec(`
|
|
110
|
-
CREATE INDEX IF NOT EXISTS idx_messages_worktree_time
|
|
111
|
-
ON chat_messages(worktree_id, timestamp DESC);
|
|
112
|
-
`),a.exec(`
|
|
113
|
-
CREATE INDEX IF NOT EXISTS idx_messages_request_id
|
|
114
|
-
ON chat_messages(request_id);
|
|
115
|
-
`),a.exec(`
|
|
116
|
-
CREATE INDEX IF NOT EXISTS idx_messages_type
|
|
117
|
-
ON chat_messages(message_type, worktree_id);
|
|
118
|
-
`),a.exec(`
|
|
119
|
-
CREATE INDEX IF NOT EXISTS idx_messages_cli_tool
|
|
120
|
-
ON chat_messages(worktree_id, cli_tool_id, timestamp DESC);
|
|
121
|
-
`),a.exec(`
|
|
122
|
-
CREATE INDEX IF NOT EXISTS idx_messages_worktree_role_archived_time
|
|
123
|
-
ON chat_messages(worktree_id, role, archived, timestamp DESC);
|
|
124
|
-
`),a.exec(`
|
|
125
|
-
CREATE TABLE IF NOT EXISTS session_states (
|
|
126
|
-
worktree_id TEXT NOT NULL,
|
|
127
|
-
cli_tool_id TEXT NOT NULL DEFAULT 'claude',
|
|
128
|
-
last_captured_line INTEGER DEFAULT 0,
|
|
129
|
-
|
|
130
|
-
PRIMARY KEY (worktree_id, cli_tool_id),
|
|
131
|
-
FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
|
|
132
|
-
);
|
|
133
|
-
`)}c.d(b,{AC:()=>k.AC,Tu:()=>as,ug:()=>k.ug,eP:()=>au,mg:()=>at,lm:()=>m,af:()=>ag,KG:()=>C,cD:()=>X,Jj:()=>Y,YX:()=>i,G4:()=>S,hL:()=>$,qp:()=>U,hl:()=>an,To:()=>q,oH:()=>f.oH,UT:()=>ax.UT,py:()=>z,rY:()=>al,yy:()=>H,pE:()=>f.pE,z2:()=>ae,cP:()=>s,DF:()=>f.DF,lA:()=>f.lA,Qp:()=>f.Qp,th:()=>af.th,oZ:()=>e.oZ,ZP:()=>j,Ys:()=>B,vg:()=>J,Rm:()=>e.Rm,C8:()=>ao,u$:()=>am,MH:()=>ax.MH,BN:()=>k.BN,m0:()=>k.m0,Tk:()=>x,iT:()=>Q,gp:()=>R,yE:()=>Z,BE:()=>W,qK:()=>ac,p4:()=>e.p4,r8:()=>f.r8,of:()=>aa,DN:()=>p,pZ:()=>o,kA:()=>f.kA,VL:()=>f.VL,CF:()=>af.CF,NV:()=>e.NV,ce:()=>ab,WZ:()=>aq,y1:()=>g,gg:()=>ax.gg,Nr:()=>y,ob:()=>w,fr:()=>F,J6:()=>ap,Ui:()=>e.Ui,P9:()=>e.P9,eN:()=>G,vi:()=>e.vi,uJ:()=>e.uJ,s4:()=>d,yT:()=>D,Vk:()=>ax.Vk,Mt:()=>ar,UE:()=>aw,PL:()=>f.PL,jp:()=>f.jp,nQ:()=>t,yb:()=>K,GA:()=>e.GA,Cs:()=>k.Cs,xR:()=>T,az:()=>_,nZ:()=>V,PP:()=>ad,Dx:()=>e.Dx,O:()=>e.O,EU:()=>f.EU,HZ:()=>e.HZ,UY:()=>r,cw:()=>f.cw,jJ:()=>af.jJ,DC:()=>e.DC,gb:()=>h,yB:()=>e.yB,uy:()=>A,s:()=>e.s,iu:()=>e.iu,hq:()=>e.hq,z1:()=>e.z1,bl:()=>I,jA:()=>af.jA,ZL:()=>e.ZL});var e=c(73753),f=c(52660);function g(a,b,c="claude"){let d=a.prepare(`
|
|
134
|
-
SELECT worktree_id, cli_tool_id, instance_id, last_captured_line, in_progress_message_id
|
|
135
|
-
FROM session_states
|
|
136
|
-
WHERE worktree_id = ? AND instance_id = ?
|
|
137
|
-
`).get(b,c);return d?{worktreeId:d.worktree_id,cliToolId:d.cli_tool_id,instanceId:d.instance_id,lastCapturedLine:d.last_captured_line,inProgressMessageId:d.in_progress_message_id||null}:null}function h(a,b,c,d,e){let f=e??c;a.prepare(`
|
|
138
|
-
INSERT INTO session_states (worktree_id, cli_tool_id, instance_id, last_captured_line)
|
|
139
|
-
VALUES (?, ?, ?, ?)
|
|
140
|
-
ON CONFLICT(worktree_id, instance_id) DO UPDATE SET
|
|
141
|
-
last_captured_line = excluded.last_captured_line,
|
|
142
|
-
cli_tool_id = excluded.cli_tool_id
|
|
143
|
-
`).run(b,c,f,d)}function i(a,b,c,d){let e=d??c;a.prepare(`
|
|
144
|
-
INSERT INTO session_states (worktree_id, cli_tool_id, instance_id, last_captured_line, in_progress_message_id)
|
|
145
|
-
VALUES (?, ?, ?, 0, ?)
|
|
146
|
-
ON CONFLICT(worktree_id, instance_id) DO UPDATE SET
|
|
147
|
-
in_progress_message_id = excluded.in_progress_message_id,
|
|
148
|
-
cli_tool_id = excluded.cli_tool_id
|
|
149
|
-
`).run(b,c,e,null)}function j(a,b,c,d){d?a.prepare(`
|
|
150
|
-
DELETE FROM session_states
|
|
151
|
-
WHERE worktree_id = ? AND instance_id = ?
|
|
152
|
-
`).run(b,d):c?a.prepare(`
|
|
153
|
-
DELETE FROM session_states
|
|
154
|
-
WHERE worktree_id = ? AND cli_tool_id = ?
|
|
155
|
-
`).run(b,c):a.prepare(`
|
|
156
|
-
DELETE FROM session_states
|
|
157
|
-
WHERE worktree_id = ?
|
|
158
|
-
`).run(b)}var k=c(28274),l=c(55511);class m extends Error{constructor(a,b,c){super(a),this.code=b,this.cause=c,this.name="MemoDbError"}}function n(a){return{id:a.id,worktreeId:a.worktree_id,title:a.title,content:a.content,position:a.position,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}function o(a,b){return a.prepare(`
|
|
159
|
-
SELECT id, worktree_id, title, content, position, created_at, updated_at
|
|
160
|
-
FROM worktree_memos
|
|
161
|
-
WHERE worktree_id = ?
|
|
162
|
-
ORDER BY position ASC
|
|
163
|
-
`).all(b).map(n)}function p(a,b){let c=a.prepare(`
|
|
164
|
-
SELECT id, worktree_id, title, content, position, created_at, updated_at
|
|
165
|
-
FROM worktree_memos
|
|
166
|
-
WHERE id = ?
|
|
167
|
-
`).get(b);return c?n(c):null}function q(a,b,c){let d=(0,l.randomUUID)(),e=Date.now(),f=c.title??"Memo",g=c.content??"",h=a.prepare(`
|
|
168
|
-
INSERT INTO worktree_memos (id, worktree_id, title, content, position, created_at, updated_at)
|
|
169
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
170
|
-
`);try{h.run(d,b,f,g,c.position,e,e)}catch(a){if(a instanceof Error&&a.message.includes("UNIQUE constraint"))throw new m(`Memo position ${c.position} is already in use for worktree "${b}"`,"DUPLICATE_POSITION",a);throw a}return{id:d,worktreeId:b,title:f,content:g,position:c.position,createdAt:new Date(e),updatedAt:new Date(e)}}function r(a,b,c){let d=Date.now(),e=["updated_at = ?"],f=[d];void 0!==c.title&&(e.push("title = ?"),f.push(c.title)),void 0!==c.content&&(e.push("content = ?"),f.push(c.content)),f.push(b),a.prepare(`
|
|
171
|
-
UPDATE worktree_memos
|
|
172
|
-
SET ${e.join(", ")}
|
|
173
|
-
WHERE id = ?
|
|
174
|
-
`).run(...f)}function s(a,b){a.prepare(`
|
|
175
|
-
DELETE FROM worktree_memos
|
|
176
|
-
WHERE id = ?
|
|
177
|
-
`).run(b)}function t(a,b,c){if(0===c.length)return;let d=Date.now();a.transaction(()=>{let b=a.prepare(`
|
|
178
|
-
UPDATE worktree_memos
|
|
179
|
-
SET position = -1 - position
|
|
180
|
-
WHERE id = ?
|
|
181
|
-
`);for(let a of c)b.run(a);let e=a.prepare(`
|
|
182
|
-
UPDATE worktree_memos
|
|
183
|
-
SET position = ?, updated_at = ?
|
|
184
|
-
WHERE id = ?
|
|
185
|
-
`);c.forEach((a,b)=>{e.run(b,d,a)})})()}let u=`
|
|
186
|
-
SELECT
|
|
187
|
-
t.id,
|
|
188
|
-
t.repository_id,
|
|
189
|
-
r.name AS repository_name,
|
|
190
|
-
r.display_name AS repository_display_name,
|
|
191
|
-
t.content,
|
|
192
|
-
t.done,
|
|
193
|
-
t.position,
|
|
194
|
-
t.created_at,
|
|
195
|
-
t.updated_at
|
|
196
|
-
FROM repository_todos t
|
|
197
|
-
JOIN repositories r ON r.id = t.repository_id
|
|
198
|
-
`;function v(a){return{id:a.id,repositoryId:a.repository_id,repositoryName:a.repository_name,repositoryDisplayName:a.repository_display_name||void 0,content:a.content,done:1===a.done,position:a.position,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}function w(a,b){return a.prepare(`
|
|
199
|
-
${u}
|
|
200
|
-
WHERE t.repository_id = ?
|
|
201
|
-
ORDER BY t.position ASC, t.created_at ASC
|
|
202
|
-
`).all(b).map(v)}function x(a){return a.prepare(`
|
|
203
|
-
${u}
|
|
204
|
-
ORDER BY
|
|
205
|
-
COALESCE(NULLIF(TRIM(r.display_name), ''), r.name) COLLATE NOCASE ASC,
|
|
206
|
-
t.position ASC,
|
|
207
|
-
t.created_at ASC,
|
|
208
|
-
t.id ASC
|
|
209
|
-
`).all().map(v)}function y(a,b){let c=a.prepare(`
|
|
210
|
-
${u}
|
|
211
|
-
WHERE t.id = ?
|
|
212
|
-
`).get(b);return c?v(c):null}function z(a,b,c){let d=(0,l.randomUUID)(),e=Date.now();a.prepare(`
|
|
213
|
-
INSERT INTO repository_todos (id, repository_id, content, done, position, created_at, updated_at)
|
|
214
|
-
VALUES (?, ?, ?, 0, ?, ?, ?)
|
|
215
|
-
`).run(d,b,c.content,c.position,e,e);let f=y(a,d);if(!f)throw Error(`Failed to load created todo '${d}'`);return f}function A(a,b,c){let d=Date.now(),e=["updated_at = ?"],f=[d];void 0!==c.content&&(e.push("content = ?"),f.push(c.content)),void 0!==c.done&&(e.push("done = ?"),f.push(+!!c.done)),f.push(b),a.prepare(`
|
|
216
|
-
UPDATE repository_todos
|
|
217
|
-
SET ${e.join(", ")}
|
|
218
|
-
WHERE id = ?
|
|
219
|
-
`).run(...f)}function B(a,b){a.prepare(`
|
|
220
|
-
DELETE FROM repository_todos
|
|
221
|
-
WHERE id = ?
|
|
222
|
-
`).run(b)}let C=["todo","doing","done"];function D(a){return"todo"===a||"doing"===a||"done"===a}function E(a){var b,c;let d=(b=a.status,c=a.done,D(b)?b:1===c?"done":"todo");return{id:a.id,worktreeId:a.worktree_id,content:a.content,detail:a.detail??"",status:d,done:"done"===d,position:a.position,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}function F(a,b){return a.prepare(`
|
|
223
|
-
SELECT id, worktree_id, content, detail, done, status, position, created_at, updated_at
|
|
224
|
-
FROM worktree_todos
|
|
225
|
-
WHERE worktree_id = ?
|
|
226
|
-
ORDER BY position ASC, created_at ASC
|
|
227
|
-
`).all(b).map(E)}function G(a,b){let c=a.prepare(`
|
|
228
|
-
SELECT id, worktree_id, content, detail, done, status, position, created_at, updated_at
|
|
229
|
-
FROM worktree_todos
|
|
230
|
-
WHERE id = ?
|
|
231
|
-
`).get(b);return c?E(c):null}function H(a,b,c){let d=(0,l.randomUUID)(),e=Date.now(),f=c.status??"todo",g=c.detail??"";return a.prepare(`
|
|
232
|
-
INSERT INTO worktree_todos (id, worktree_id, content, detail, done, status, position, created_at, updated_at)
|
|
233
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
234
|
-
`).run(d,b,c.content,g,+("done"===f),f,c.position,e,e),{id:d,worktreeId:b,content:c.content,detail:g,status:f,done:"done"===f,position:c.position,createdAt:new Date(e),updatedAt:new Date(e)}}function I(a,b,c){let d,e=Date.now(),f=["updated_at = ?"],g=[e];void 0!==c.content&&(f.push("content = ?"),g.push(c.content)),void 0!==c.detail&&(f.push("detail = ?"),g.push(c.detail)),void 0!==c.status?d=c.status:void 0!==c.done&&(d=c.done?"done":"todo"),void 0!==d&&(f.push("status = ?"),g.push(d),f.push("done = ?"),g.push(+("done"===d))),g.push(b),a.prepare(`
|
|
235
|
-
UPDATE worktree_todos
|
|
236
|
-
SET ${f.join(", ")}
|
|
237
|
-
WHERE id = ?
|
|
238
|
-
`).run(...g)}function J(a,b){a.prepare(`
|
|
239
|
-
DELETE FROM worktree_todos
|
|
240
|
-
WHERE id = ?
|
|
241
|
-
`).run(b)}function K(a,b,c){if(0===c.length)return;let d=Date.now();a.transaction(()=>{let e=a.prepare(`
|
|
242
|
-
UPDATE worktree_todos
|
|
243
|
-
SET position = -1 - position
|
|
244
|
-
WHERE id = ? AND worktree_id = ?
|
|
245
|
-
`);for(let a of c)e.run(a,b);let f=a.prepare(`
|
|
246
|
-
UPDATE worktree_todos
|
|
247
|
-
SET position = ?, updated_at = ?
|
|
248
|
-
WHERE id = ? AND worktree_id = ?
|
|
249
|
-
`);c.forEach((a,c)=>{f.run(c,d,a,b)})})()}function L(a,b){return Buffer.byteLength(a,"utf-8")<=b?a:Buffer.from(a,"utf-8").subarray(0,b).toString("utf-8")}function M(a){return{id:a.id,repositoryId:a.repository_id,cliToolId:a.cli_tool_id,workingDirectory:a.working_directory,executionMode:a.execution_mode??"interactive",resumeSessionId:a.resume_session_id??void 0,lastExecutionId:a.last_execution_id??void 0,sessionName:a.session_name??void 0,status:"idle"===a.status?"stopped":a.status,lastStartedAt:a.last_started_at?new Date(a.last_started_at):void 0,lastStoppedAt:a.last_stopped_at?new Date(a.last_stopped_at):void 0,contextSentAt:a.context_sent_at?new Date(a.context_sent_at):void 0,contextSnapshot:a.context_snapshot??void 0,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at),archived:1===a.archived}}function N(a){return{id:a.id,conversationId:a.conversation_id,role:a.role,content:a.content,summary:a.summary??void 0,timestamp:new Date(a.timestamp),messageType:a.message_type,deliveryStatus:a.delivery_status??void 0,archived:1===a.archived}}function O(a){return{id:a.id,conversationId:a.conversation_id,cliToolId:a.cli_tool_id,status:a.status,pid:a.pid??void 0,commandLine:a.command_line,promptText:a.prompt_text,stdoutText:a.stdout_text??void 0,stderrText:a.stderr_text??void 0,finalMessageText:a.final_message_text??void 0,exitCode:a.exit_code,resumeSessionIdBefore:a.resume_session_id_before??void 0,resumeSessionIdAfter:a.resume_session_id_after??void 0,startedAt:a.started_at?new Date(a.started_at):void 0,finishedAt:a.finished_at?new Date(a.finished_at):void 0,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}function P(a,b,c){a.prepare(`
|
|
250
|
-
UPDATE assistant_conversations
|
|
251
|
-
SET updated_at = ?
|
|
252
|
-
WHERE id = ?
|
|
253
|
-
`).run(c.getTime(),b)}function Q(a,b,c={}){let d=`
|
|
254
|
-
SELECT *
|
|
255
|
-
FROM assistant_conversations
|
|
256
|
-
WHERE id = ?
|
|
257
|
-
${c.includeArchived?"":"AND archived = 0"}
|
|
258
|
-
LIMIT 1
|
|
259
|
-
`,e=a.prepare(d).get(b);return e?M(e):null}function R(a,b,c,d={}){let e=`
|
|
260
|
-
SELECT *
|
|
261
|
-
FROM assistant_conversations
|
|
262
|
-
WHERE repository_id = ?
|
|
263
|
-
AND cli_tool_id = ?
|
|
264
|
-
${d.includeArchived?"":"AND archived = 0"}
|
|
265
|
-
LIMIT 1
|
|
266
|
-
`,f=a.prepare(e).get(b,c);return f?M(f):null}function S(a,b){let c=(0,l.randomUUID)(),d=Date.now();return a.prepare(`
|
|
267
|
-
INSERT INTO assistant_conversations (
|
|
268
|
-
id, repository_id, cli_tool_id, working_directory, execution_mode, resume_session_id,
|
|
269
|
-
last_execution_id, session_name, status,
|
|
270
|
-
last_started_at, last_stopped_at, context_sent_at, created_at, updated_at, archived
|
|
271
|
-
)
|
|
272
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0)
|
|
273
|
-
`).run(c,b.repositoryId,b.cliToolId,b.workingDirectory,b.executionMode??"interactive",b.resumeSessionId??null,b.lastExecutionId??null,b.sessionName??null,b.status??"stopped",b.lastStartedAt?.getTime()??null,b.lastStoppedAt?.getTime()??null,b.contextSentAt?.getTime()??null,d,d),{id:c,repositoryId:b.repositoryId,cliToolId:b.cliToolId,workingDirectory:b.workingDirectory,executionMode:b.executionMode??"interactive",resumeSessionId:b.resumeSessionId,lastExecutionId:b.lastExecutionId,sessionName:b.sessionName,status:b.status??"stopped",contextSentAt:b.contextSentAt,lastStartedAt:b.lastStartedAt,lastStoppedAt:b.lastStoppedAt,createdAt:new Date(d),updatedAt:new Date(d),archived:!1}}function T(a,b,c){let d=[],e=[];void 0!==c.workingDirectory&&(d.push("working_directory = ?"),e.push(c.workingDirectory)),void 0!==c.executionMode&&(d.push("execution_mode = ?"),e.push(c.executionMode)),void 0!==c.resumeSessionId&&(d.push("resume_session_id = ?"),e.push(c.resumeSessionId)),void 0!==c.lastExecutionId&&(d.push("last_execution_id = ?"),e.push(c.lastExecutionId)),void 0!==c.sessionName&&(d.push("session_name = ?"),e.push(c.sessionName)),void 0!==c.status&&(d.push("status = ?"),e.push(c.status)),void 0!==c.lastStartedAt&&(d.push("last_started_at = ?"),e.push(c.lastStartedAt?.getTime()??null)),void 0!==c.lastStoppedAt&&(d.push("last_stopped_at = ?"),e.push(c.lastStoppedAt?.getTime()??null)),void 0!==c.contextSentAt&&(d.push("context_sent_at = ?"),e.push(c.contextSentAt?.getTime()??null)),void 0!==c.contextSnapshot&&(d.push("context_snapshot = ?"),e.push(c.contextSnapshot??null)),void 0!==c.archived&&(d.push("archived = ?"),e.push(+!!c.archived));let f=c.updatedAt??new Date;return d.push("updated_at = ?"),e.push(f.getTime()),e.push(b),a.prepare(`
|
|
274
|
-
UPDATE assistant_conversations
|
|
275
|
-
SET ${d.join(", ")}
|
|
276
|
-
WHERE id = ?
|
|
277
|
-
`).run(...e),Q(a,b,{includeArchived:!0})}function U(a,b){let c=(0,l.randomUUID)();return a.prepare(`
|
|
278
|
-
INSERT INTO assistant_messages (
|
|
279
|
-
id, conversation_id, role, content, summary, timestamp, message_type, delivery_status, archived
|
|
280
|
-
)
|
|
281
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0)
|
|
282
|
-
`).run(c,b.conversationId,b.role,b.content,b.summary??null,b.timestamp.getTime(),b.messageType,b.deliveryStatus??null),P(a,b.conversationId,b.timestamp),{id:c,...b,archived:!1}}function V(a,b,c){a.prepare(`
|
|
283
|
-
UPDATE assistant_messages
|
|
284
|
-
SET delivery_status = ?
|
|
285
|
-
WHERE id = ?
|
|
286
|
-
`).run(c,b)}function W(a,b,c={}){let{limit:d=200,before:e,includeArchived:f=!1}=c,g=[b,e?.getTime()??null,e?.getTime()??null],h=`
|
|
287
|
-
SELECT *
|
|
288
|
-
FROM assistant_messages
|
|
289
|
-
WHERE conversation_id = ?
|
|
290
|
-
AND (? IS NULL OR timestamp < ?)
|
|
291
|
-
`;return f||(h+=" AND archived = 0"),h+=" ORDER BY timestamp DESC LIMIT ?",g.push(d),a.prepare(h).all(...g).map(N)}function X(a,b){return a.prepare(`
|
|
292
|
-
UPDATE assistant_messages
|
|
293
|
-
SET archived = 1
|
|
294
|
-
WHERE conversation_id = ?
|
|
295
|
-
AND archived = 0
|
|
296
|
-
`).run(b).changes}function Y(a,b,c){return a.prepare(`
|
|
297
|
-
UPDATE assistant_messages
|
|
298
|
-
SET archived = 1
|
|
299
|
-
WHERE conversation_id = ?
|
|
300
|
-
AND archived = 0
|
|
301
|
-
AND timestamp >= ?
|
|
302
|
-
`).run(b,c).changes}function Z(a,b){let c=a.prepare(`
|
|
303
|
-
SELECT * FROM assistant_messages WHERE id = ?
|
|
304
|
-
`).get(b);return c?N(c):null}function $(a,b){let c=(0,l.randomUUID)(),d=Date.now();return a.prepare(`
|
|
305
|
-
INSERT INTO assistant_executions (
|
|
306
|
-
id, conversation_id, cli_tool_id, status, pid, command_line, prompt_text,
|
|
307
|
-
stdout_text, stderr_text, final_message_text, exit_code, resume_session_id_before,
|
|
308
|
-
resume_session_id_after, started_at, finished_at, created_at, updated_at
|
|
309
|
-
)
|
|
310
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
311
|
-
`).run(c,b.conversationId,b.cliToolId,b.status??"queued",b.pid??null,b.commandLine,L(b.promptText,65536),L(b.stdoutText??"",262144)||null,L(b.stderrText??"",262144)||null,b.finalMessageText?L(b.finalMessageText,65536):null,b.exitCode??null,b.resumeSessionIdBefore??null,b.resumeSessionIdAfter??null,b.startedAt?.getTime()??null,b.finishedAt?.getTime()??null,d,d),P(a,b.conversationId,new Date(d)),{id:c,conversationId:b.conversationId,cliToolId:b.cliToolId,status:b.status??"queued",pid:b.pid,commandLine:b.commandLine,promptText:L(b.promptText,65536),stdoutText:b.stdoutText?L(b.stdoutText,262144):void 0,stderrText:b.stderrText?L(b.stderrText,262144):void 0,finalMessageText:b.finalMessageText?L(b.finalMessageText,65536):void 0,exitCode:b.exitCode,resumeSessionIdBefore:b.resumeSessionIdBefore,resumeSessionIdAfter:b.resumeSessionIdAfter,startedAt:b.startedAt,finishedAt:b.finishedAt,createdAt:new Date(d),updatedAt:new Date(d)}}function _(a,b,c){let d=[],e=[];void 0!==c.status&&(d.push("status = ?"),e.push(c.status)),void 0!==c.pid&&(d.push("pid = ?"),e.push(c.pid)),void 0!==c.stdoutText&&(d.push("stdout_text = ?"),e.push(c.stdoutText?L(c.stdoutText,262144):null)),void 0!==c.stderrText&&(d.push("stderr_text = ?"),e.push(c.stderrText?L(c.stderrText,262144):null)),void 0!==c.finalMessageText&&(d.push("final_message_text = ?"),e.push(c.finalMessageText?L(c.finalMessageText,65536):null)),void 0!==c.exitCode&&(d.push("exit_code = ?"),e.push(c.exitCode)),void 0!==c.resumeSessionIdAfter&&(d.push("resume_session_id_after = ?"),e.push(c.resumeSessionIdAfter)),void 0!==c.startedAt&&(d.push("started_at = ?"),e.push(c.startedAt?.getTime()??null)),void 0!==c.finishedAt&&(d.push("finished_at = ?"),e.push(c.finishedAt?.getTime()??null));let f=c.updatedAt??new Date;return d.push("updated_at = ?"),e.push(f.getTime(),b),a.prepare(`
|
|
312
|
-
UPDATE assistant_executions
|
|
313
|
-
SET ${d.join(", ")}
|
|
314
|
-
WHERE id = ?
|
|
315
|
-
`).run(...e),function(a,b){let c=a.prepare(`
|
|
316
|
-
SELECT *
|
|
317
|
-
FROM assistant_executions
|
|
318
|
-
WHERE id = ?
|
|
319
|
-
LIMIT 1
|
|
320
|
-
`).get(b);return c?O(c):null}(a,b)}function aa(a,b){let c=a.prepare(`
|
|
321
|
-
SELECT *
|
|
322
|
-
FROM assistant_executions
|
|
323
|
-
WHERE conversation_id = ?
|
|
324
|
-
ORDER BY created_at DESC
|
|
325
|
-
LIMIT 1
|
|
326
|
-
`).get(b);return c?O(c):null}function ab(a,b){let c=a.prepare(`
|
|
327
|
-
SELECT *
|
|
328
|
-
FROM assistant_executions
|
|
329
|
-
WHERE conversation_id = ?
|
|
330
|
-
AND status = 'running'
|
|
331
|
-
ORDER BY created_at DESC
|
|
332
|
-
LIMIT 1
|
|
333
|
-
`).get(b);return c?O(c):null}function ac(a,b){let c=a.prepare(`
|
|
334
|
-
SELECT conversation_id, last_captured_line, in_progress_message_id
|
|
335
|
-
FROM assistant_session_states
|
|
336
|
-
WHERE conversation_id = ?
|
|
337
|
-
`).get(b);return c?{conversationId:c.conversation_id,lastCapturedLine:c.last_captured_line,inProgressMessageId:c.in_progress_message_id}:null}function ad(a,b,c,d){a.prepare(`
|
|
338
|
-
INSERT INTO assistant_session_states (conversation_id, last_captured_line, in_progress_message_id)
|
|
339
|
-
VALUES (?, ?, ?)
|
|
340
|
-
ON CONFLICT(conversation_id) DO UPDATE SET
|
|
341
|
-
last_captured_line = excluded.last_captured_line,
|
|
342
|
-
in_progress_message_id = excluded.in_progress_message_id
|
|
343
|
-
`).run(b,c,d??null)}function ae(a,b){a.prepare(`
|
|
344
|
-
DELETE FROM assistant_session_states
|
|
345
|
-
WHERE conversation_id = ?
|
|
346
|
-
`).run(b)}c(34129);var af=c(43167);let ag=["manual","wait","api","task"],ah=`
|
|
347
|
-
id, worktree_id, instance_id, task_id, trigger, status, base_ref, started_at, finished_at
|
|
348
|
-
`,ai=`
|
|
349
|
-
id, run_id, gate_id, command, status, exit_code, duration_ms, log_tail, started_at, finished_at
|
|
350
|
-
`;function aj(a){return{id:a.id,worktreeId:a.worktree_id,instanceId:a.instance_id,taskId:a.task_id,trigger:a.trigger,status:a.status,baseRef:a.base_ref,startedAt:new Date(a.started_at),finishedAt:null===a.finished_at?null:new Date(a.finished_at)}}function ak(a){return{id:a.id,runId:a.run_id,gateId:a.gate_id,command:a.command,status:a.status,exitCode:a.exit_code,durationMs:a.duration_ms,logTail:a.log_tail,startedAt:new Date(a.started_at),finishedAt:null===a.finished_at?null:new Date(a.finished_at),timingsMeasured:null!==a.finished_at&&null!==a.duration_ms&&a.finished_at-a.started_at===a.duration_ms}}function al(a,b){let c=Date.now(),d=a.prepare(`
|
|
351
|
-
INSERT INTO verification_runs (
|
|
352
|
-
worktree_id, instance_id, task_id, trigger, status, base_ref, started_at, finished_at
|
|
353
|
-
)
|
|
354
|
-
VALUES (?, ?, ?, ?, 'running', ?, ?, NULL)
|
|
355
|
-
`).run(b.worktreeId,b.instanceId??null,b.taskId??null,b.trigger,b.baseRef??null,c),e=a.prepare(`SELECT ${ah} FROM verification_runs WHERE id = ?`).get(Number(d.lastInsertRowid));if(!e)throw Error("Failed to persist verification run");return aj(e)}function am(a,b,c){if(0===a.prepare("UPDATE verification_runs SET status = ?, finished_at = ? WHERE id = ?").run(c,Date.now(),b).changes)throw Error(`Verification run ${b} not found`)}function an(a,b,c){let d=Date.now(),e=a.prepare(`
|
|
356
|
-
INSERT INTO verification_gate_results (
|
|
357
|
-
run_id, gate_id, command, status, exit_code, duration_ms, log_tail, started_at, finished_at
|
|
358
|
-
)
|
|
359
|
-
VALUES (?, ?, ?, 'running', NULL, NULL, NULL, ?, NULL)
|
|
360
|
-
`).run(b,c.gateId,c.command,d),f=a.prepare(`SELECT ${ai} FROM verification_gate_results WHERE id = ?`).get(Number(e.lastInsertRowid));if(!f)throw Error("Failed to persist verification gate result");return ak(f)}function ao(a,b,c){if(0===a.prepare(`
|
|
361
|
-
UPDATE verification_gate_results
|
|
362
|
-
SET status = ?, exit_code = ?, duration_ms = ?, log_tail = ?,
|
|
363
|
-
started_at = COALESCE(?, started_at),
|
|
364
|
-
finished_at = ?
|
|
365
|
-
WHERE id = ?
|
|
366
|
-
`).run(c.status,c.exitCode??null,c.durationMs??null,c.logTail??null,c.executionWindow?.startedAt??null,c.executionWindow?.finishedAt??Date.now(),b).changes)throw Error(`Verification gate result ${b} not found`)}function ap(a,b){let c=a.prepare(`SELECT ${ah} FROM verification_runs WHERE id = ?`).get(b);if(!c)return null;let d=a.prepare(`
|
|
367
|
-
SELECT ${ai} FROM verification_gate_results
|
|
368
|
-
WHERE run_id = ?
|
|
369
|
-
ORDER BY started_at ASC, id ASC
|
|
370
|
-
`).all(b);return{...aj(c),gates:d.map(ak)}}function aq(a,b){let c=a.prepare(`
|
|
371
|
-
SELECT ${ah} FROM verification_runs
|
|
372
|
-
WHERE worktree_id = ? AND status = 'running'
|
|
373
|
-
ORDER BY id DESC
|
|
374
|
-
LIMIT 1
|
|
375
|
-
`).get(b);return c?aj(c):null}function ar(a,b,c=20){return a.prepare(`
|
|
376
|
-
SELECT ${ah} FROM verification_runs
|
|
377
|
-
WHERE worktree_id = ?
|
|
378
|
-
ORDER BY started_at DESC, id DESC
|
|
379
|
-
LIMIT ?
|
|
380
|
-
`).all(b,c).map(aj)}let as=50,at=500,au=90;function av(a,b,c,d){return void 0!==a&&Number.isFinite(a)?Math.min(Math.max(Math.trunc(a),c),d):b}function aw(a,b={}){let c=av(b.limit,as,1,at),d=[],e=[];if(void 0!==b.worktreeId&&(d.push("worktree_id = ?"),e.push(b.worktreeId)),void 0!==b.days){let a=av(b.days,au,1,au);d.push("started_at >= ?"),e.push(Date.now()-864e5*a)}let f=d.length>0?`WHERE ${d.join(" AND ")}`:"",g=a.prepare(`
|
|
381
|
-
SELECT ${ah} FROM verification_runs
|
|
382
|
-
${f}
|
|
383
|
-
ORDER BY started_at DESC, id DESC
|
|
384
|
-
LIMIT ?
|
|
385
|
-
`).all(...e,c);if(0===g.length)return[];let h=g.map(()=>"?").join(", "),i=a.prepare(`
|
|
386
|
-
SELECT run_id, gate_id, status, exit_code, duration_ms
|
|
387
|
-
FROM verification_gate_results
|
|
388
|
-
WHERE run_id IN (${h})
|
|
389
|
-
ORDER BY started_at ASC, id ASC
|
|
390
|
-
`).all(...g.map(a=>a.id)),j=new Map;for(let a of i){let b={gateId:a.gate_id,status:a.status,exitCode:a.exit_code,durationMs:a.duration_ms},c=j.get(a.run_id);c?c.push(b):j.set(a.run_id,[b])}return g.map(a=>({...aj(a),gates:j.get(a.id)??[]}))}var ax=c(48524)},92046:(a,b,c)=>{c.d(b,{vI:()=>m});var d=c(33873),e=c.n(d);function f(a){try{let b=a.prepare("SELECT MAX(version) as version FROM schema_version").get();return b?.version??0}catch{return 0}}function g(a){let b=c(29021),d=a;for(;d!==e().dirname(d);){let a=e().join(d,".git");if(b.existsSync(a)){let c=b.statSync(a);if(c.isDirectory())return d;if(c.isFile()){let c=b.readFileSync(a,"utf-8").trim().match(/^gitdir:\s*(.+)$/);if(c)return c[1].split("/.git/")[0]}}d=e().dirname(d)}return a}var h=c(90444);let i=`
|
|
391
|
-
id, worktree_id, skill_id, version, install_root, receipt_sha256,
|
|
392
|
-
source_repository, source_ref, source_commit, artifact_sha256,
|
|
393
|
-
effective_risk, operation_id, installed_at, updated_at
|
|
394
|
-
`,j=`
|
|
395
|
-
id TEXT PRIMARY KEY,
|
|
396
|
-
worktree_id TEXT NOT NULL,
|
|
397
|
-
skill_id TEXT NOT NULL,
|
|
398
|
-
version TEXT NOT NULL,
|
|
399
|
-
install_root TEXT NOT NULL,
|
|
400
|
-
receipt_sha256 TEXT NOT NULL,
|
|
401
|
-
source_repository TEXT NOT NULL,
|
|
402
|
-
source_ref TEXT NOT NULL,
|
|
403
|
-
source_commit TEXT NOT NULL,
|
|
404
|
-
artifact_sha256 TEXT NOT NULL,
|
|
405
|
-
effective_risk TEXT NOT NULL,
|
|
406
|
-
operation_id TEXT NOT NULL,
|
|
407
|
-
installed_at INTEGER NOT NULL,
|
|
408
|
-
updated_at INTEGER NOT NULL,
|
|
409
|
-
UNIQUE (worktree_id, skill_id)
|
|
410
|
-
`;function k(a){a.exec(`
|
|
411
|
-
CREATE INDEX IF NOT EXISTS idx_skill_installations_worktree
|
|
412
|
-
ON skill_installations(worktree_id);
|
|
413
|
-
`),a.exec(`
|
|
414
|
-
CREATE INDEX IF NOT EXISTS idx_skill_installations_skill
|
|
415
|
-
ON skill_installations(skill_id, version);
|
|
416
|
-
`)}let l=[{version:1,name:"initial-schema",up:a=>{(0,h.s4)(a)},down:a=>{a.exec("DROP TABLE IF EXISTS session_states;"),a.exec("DROP TABLE IF EXISTS chat_messages;"),a.exec("DROP TABLE IF EXISTS worktrees;")}},{version:2,name:"add-multi-repo-and-memo-support",up:a=>{a.exec(`
|
|
417
|
-
ALTER TABLE worktrees ADD COLUMN repository_path TEXT;
|
|
418
|
-
ALTER TABLE worktrees ADD COLUMN repository_name TEXT;
|
|
419
|
-
ALTER TABLE worktrees ADD COLUMN memo TEXT;
|
|
420
|
-
ALTER TABLE worktrees ADD COLUMN last_user_message TEXT;
|
|
421
|
-
ALTER TABLE worktrees ADD COLUMN last_user_message_at INTEGER;
|
|
422
|
-
`),a.exec(`
|
|
423
|
-
CREATE INDEX IF NOT EXISTS idx_worktrees_repository
|
|
424
|
-
ON worktrees(repository_path);
|
|
425
|
-
`);let b=a.prepare("SELECT id, path FROM worktrees").all(),c=a.prepare(`
|
|
426
|
-
UPDATE worktrees
|
|
427
|
-
SET repository_path = ?,
|
|
428
|
-
repository_name = ?
|
|
429
|
-
WHERE id = ?
|
|
430
|
-
`);for(let a of b){let b=g(a.path),d=e().basename(b);c.run(b,d,a.id)}let d=a.prepare(`
|
|
431
|
-
UPDATE worktrees
|
|
432
|
-
SET last_user_message = ?,
|
|
433
|
-
last_user_message_at = ?
|
|
434
|
-
WHERE id = ?
|
|
435
|
-
`);for(let c of b){let b=a.prepare(`
|
|
436
|
-
SELECT content, timestamp
|
|
437
|
-
FROM chat_messages
|
|
438
|
-
WHERE worktree_id = ? AND role = 'user'
|
|
439
|
-
ORDER BY timestamp DESC
|
|
440
|
-
LIMIT 1
|
|
441
|
-
`).get(c.id);if(b){let a=b.content.substring(0,200);d.run(a,b.timestamp,c.id)}}},down:a=>{a.exec(`
|
|
442
|
-
-- Create backup table
|
|
443
|
-
CREATE TABLE worktrees_backup AS
|
|
444
|
-
SELECT id, name, path, last_message_summary, updated_at
|
|
445
|
-
FROM worktrees;
|
|
446
|
-
|
|
447
|
-
-- Drop original table
|
|
448
|
-
DROP TABLE worktrees;
|
|
32
|
+
-- Drop original table
|
|
33
|
+
DROP TABLE worktrees;
|
|
449
34
|
|
|
450
35
|
-- Recreate original table
|
|
451
36
|
CREATE TABLE worktrees (
|
|
@@ -485,7 +70,7 @@
|
|
|
485
70
|
ON worktrees(status);
|
|
486
71
|
`)},down:a=>{a.exec(`
|
|
487
72
|
DROP INDEX IF EXISTS idx_worktrees_status;
|
|
488
|
-
`)}},{version:6,name:"add-link-field",up:a=>{a.exec(`
|
|
73
|
+
`)}}],j=[{version:6,name:"add-link-field",up:a=>{a.exec(`
|
|
489
74
|
ALTER TABLE worktrees ADD COLUMN link TEXT DEFAULT NULL;
|
|
490
75
|
`)},down:()=>{console.log("No rollback needed for link field")}},{version:7,name:"add-cli-tool-id",up:a=>{a.exec(`
|
|
491
76
|
ALTER TABLE worktrees ADD COLUMN cli_tool_id TEXT DEFAULT 'claude';
|
|
@@ -591,7 +176,7 @@
|
|
|
591
176
|
`).all(),e=a.prepare(`
|
|
592
177
|
INSERT INTO worktree_memos (id, worktree_id, title, content, position, created_at, updated_at)
|
|
593
178
|
VALUES (?, ?, 'Memo', ?, 0, ?, ?)
|
|
594
|
-
`),f=Date.now();for(let a of d)e.run(b(),a.id,a.memo,f,f);console.log("Created worktree_memos table"),console.log(`Migrated ${d.length} existing memos to new table`)},down:a=>{a.exec("DROP TABLE IF EXISTS worktree_memos"),console.log("Dropped worktree_memos table")}},{version:11,name:"add-viewed-tracking",up:a=>{a.exec(`
|
|
179
|
+
`),f=Date.now();for(let a of d)e.run(b(),a.id,a.memo,f,f);console.log("Created worktree_memos table"),console.log(`Migrated ${d.length} existing memos to new table`)},down:a=>{a.exec("DROP TABLE IF EXISTS worktree_memos"),console.log("Dropped worktree_memos table")}}],k=[{version:11,name:"add-viewed-tracking",up:a=>{a.exec(`
|
|
595
180
|
ALTER TABLE worktrees ADD COLUMN last_viewed_at TEXT;
|
|
596
181
|
`),a.exec(`
|
|
597
182
|
CREATE INDEX IF NOT EXISTS idx_chat_messages_assistant_latest
|
|
@@ -736,7 +321,7 @@
|
|
|
736
321
|
|
|
737
322
|
CREATE INDEX IF NOT EXISTS idx_worktrees_cli_tool
|
|
738
323
|
ON worktrees(cli_tool_id);
|
|
739
|
-
`),console.log("Removed initial_branch column from worktrees table")}},{version:16,name:"add-issue-no-to-external-apps",up:a=>{a.exec(`
|
|
324
|
+
`),console.log("Removed initial_branch column from worktrees table")}}],l=[{version:16,name:"add-issue-no-to-external-apps",up:a=>{a.exec(`
|
|
740
325
|
ALTER TABLE external_apps ADD COLUMN issue_no INTEGER;
|
|
741
326
|
`),a.exec(`
|
|
742
327
|
CREATE INDEX IF NOT EXISTS idx_external_apps_issue_no ON external_apps(issue_no);
|
|
@@ -851,7 +436,7 @@
|
|
|
851
436
|
ALTER TABLE worktrees ADD COLUMN vibe_local_model TEXT DEFAULT NULL;
|
|
852
437
|
`),console.log("Added vibe_local_model column to worktrees table")},down:()=>{console.log("No rollback for vibe_local_model column (SQLite limitation)")}},{version:20,name:"add-vibe-local-context-window-column",up:a=>{a.exec(`
|
|
853
438
|
ALTER TABLE worktrees ADD COLUMN vibe_local_context_window INTEGER DEFAULT NULL;
|
|
854
|
-
`),console.log("Added vibe_local_context_window column to worktrees table")},down:()=>{console.log("No rollback for vibe_local_context_window column (SQLite limitation)")}},{version:21,name:"add-scheduled-executions-worktree-enabled-index",up:a=>{a.exec(`
|
|
439
|
+
`),console.log("Added vibe_local_context_window column to worktrees table")},down:()=>{console.log("No rollback for vibe_local_context_window column (SQLite limitation)")}}],m=[{version:21,name:"add-scheduled-executions-worktree-enabled-index",up:a=>{a.exec(`
|
|
855
440
|
CREATE INDEX IF NOT EXISTS idx_scheduled_executions_worktree_enabled
|
|
856
441
|
ON scheduled_executions(worktree_id, enabled);
|
|
857
442
|
`),console.log("Created composite index idx_scheduled_executions_worktree_enabled")},down:a=>{a.exec("DROP INDEX IF EXISTS idx_scheduled_executions_worktree_enabled"),console.log("Dropped idx_scheduled_executions_worktree_enabled index")}},{version:22,name:"add-archived-column-to-chat-messages",up:a=>{a.exec(`
|
|
@@ -884,7 +469,7 @@
|
|
|
884
469
|
DROP INDEX IF EXISTS idx_timer_messages_status_scheduled;
|
|
885
470
|
DROP INDEX IF EXISTS idx_timer_messages_worktree_status;
|
|
886
471
|
DROP TABLE IF EXISTS timer_messages;
|
|
887
|
-
`)}},{version:24,name:"add-daily-reports-table",up:a=>{a.exec(`
|
|
472
|
+
`)}}],n=[{version:24,name:"add-daily-reports-table",up:a=>{a.exec(`
|
|
888
473
|
CREATE TABLE daily_reports (
|
|
889
474
|
date TEXT PRIMARY KEY,
|
|
890
475
|
content TEXT NOT NULL,
|
|
@@ -893,7 +478,7 @@
|
|
|
893
478
|
created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
|
|
894
479
|
updated_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
|
|
895
480
|
);
|
|
896
|
-
`),console.log("Created daily_reports table")},down:a=>{a.exec("DROP TABLE IF EXISTS daily_reports"),console.log("Dropped daily_reports table")}},{version:25,name:"add-report-templates-table",up:a=>{a.exec(`
|
|
481
|
+
`),console.log("Created daily_reports table")},down:a=>{a.exec("DROP TABLE IF EXISTS daily_reports"),console.log("Dropped daily_reports table")}}],o=[{version:25,name:"add-report-templates-table",up:a=>{a.exec(`
|
|
897
482
|
CREATE TABLE report_templates (
|
|
898
483
|
id TEXT PRIMARY KEY,
|
|
899
484
|
name TEXT NOT NULL,
|
|
@@ -902,14 +487,14 @@
|
|
|
902
487
|
created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
|
|
903
488
|
updated_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
|
|
904
489
|
);
|
|
905
|
-
`),console.log("Created report_templates table")},down:a=>{a.exec("DROP TABLE IF EXISTS report_templates"),console.log("Dropped report_templates table")}},{version:26,name:"add-repository-display-name",up:a=>{a.exec("ALTER TABLE repositories ADD COLUMN display_name TEXT;"),console.log("Added display_name column to repositories table")},down:a=>{a.exec("ALTER TABLE repositories DROP COLUMN display_name;"),console.log("Removed display_name column from repositories table")}},{version:27,name:"add-app-settings-table",up:a=>{a.exec(`
|
|
490
|
+
`),console.log("Created report_templates table")},down:a=>{a.exec("DROP TABLE IF EXISTS report_templates"),console.log("Dropped report_templates table")}}],p=[{version:26,name:"add-repository-display-name",up:a=>{a.exec("ALTER TABLE repositories ADD COLUMN display_name TEXT;"),console.log("Added display_name column to repositories table")},down:a=>{a.exec("ALTER TABLE repositories DROP COLUMN display_name;"),console.log("Removed display_name column from repositories table")}}],q=[{version:27,name:"add-app-settings-table",up:a=>{a.exec(`
|
|
906
491
|
CREATE TABLE IF NOT EXISTS app_settings (
|
|
907
492
|
key TEXT PRIMARY KEY,
|
|
908
493
|
value TEXT NOT NULL,
|
|
909
494
|
created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
|
|
910
495
|
updated_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
|
|
911
496
|
);
|
|
912
|
-
`)},down:a=>{a.exec("DROP TABLE IF EXISTS app_settings")}},{version:28,name:"add-assistant-conversation-tables",up:a=>{a.exec(`
|
|
497
|
+
`)},down:a=>{a.exec("DROP TABLE IF EXISTS app_settings")}}],r=[{version:28,name:"add-assistant-conversation-tables",up:a=>{a.exec(`
|
|
913
498
|
CREATE TABLE IF NOT EXISTS assistant_conversations (
|
|
914
499
|
id TEXT PRIMARY KEY,
|
|
915
500
|
repository_id TEXT NOT NULL,
|
|
@@ -962,7 +547,7 @@
|
|
|
962
547
|
DROP TABLE IF EXISTS assistant_session_states;
|
|
963
548
|
DROP TABLE IF EXISTS assistant_messages;
|
|
964
549
|
DROP TABLE IF EXISTS assistant_conversations;
|
|
965
|
-
`)}},{version:29,name:"add-assistant-non-interactive-executions",up:a=>{a.exec(`
|
|
550
|
+
`)}}],s=[{version:29,name:"add-assistant-non-interactive-executions",up:a=>{a.exec(`
|
|
966
551
|
ALTER TABLE assistant_conversations
|
|
967
552
|
ADD COLUMN execution_mode TEXT NOT NULL DEFAULT 'interactive';
|
|
968
553
|
|
|
@@ -1012,19 +597,19 @@
|
|
|
1012
597
|
ON assistant_executions(status, updated_at DESC);
|
|
1013
598
|
`)},down:a=>{a.exec(`
|
|
1014
599
|
DROP TABLE IF EXISTS assistant_executions;
|
|
1015
|
-
`)}},{version:30,name:"add-assistant-context-snapshot",up:a=>{a.exec(`
|
|
600
|
+
`)}}],t=[{version:30,name:"add-assistant-context-snapshot",up:a=>{a.exec(`
|
|
1016
601
|
ALTER TABLE assistant_conversations
|
|
1017
602
|
ADD COLUMN context_snapshot TEXT;
|
|
1018
603
|
`)},down:a=>{a.exec(`
|
|
1019
604
|
ALTER TABLE assistant_conversations
|
|
1020
605
|
DROP COLUMN context_snapshot;
|
|
1021
|
-
`)}},{version:31,name:"add-repository-visible",up:a=>{a.exec("ALTER TABLE repositories ADD COLUMN visible INTEGER NOT NULL DEFAULT 1;")},down:a=>{a.exec("ALTER TABLE repositories DROP COLUMN visible;")}},{version:32,name:"add-messages-role-composite-index",up:a=>{a.exec(`
|
|
606
|
+
`)}}],u=[{version:31,name:"add-repository-visible",up:a=>{a.exec("ALTER TABLE repositories ADD COLUMN visible INTEGER NOT NULL DEFAULT 1;")},down:a=>{a.exec("ALTER TABLE repositories DROP COLUMN visible;")}}],v=[{version:32,name:"add-messages-role-composite-index",up:a=>{a.exec(`
|
|
1022
607
|
CREATE INDEX IF NOT EXISTS idx_messages_worktree_role_archived_time
|
|
1023
608
|
ON chat_messages(worktree_id, role, archived, timestamp DESC);
|
|
1024
609
|
`),a.exec("DROP INDEX IF EXISTS idx_messages_archived;")},down:a=>{a.exec("DROP INDEX IF EXISTS idx_messages_worktree_role_archived_time;"),a.exec(`
|
|
1025
610
|
CREATE INDEX IF NOT EXISTS idx_messages_archived
|
|
1026
611
|
ON chat_messages(worktree_id, archived, timestamp DESC);
|
|
1027
|
-
`)}},{version:33,name:"add-agent-instances",up:a=>{a.exec(`
|
|
612
|
+
`)}}],w=[{version:33,name:"add-agent-instances",up:a=>{a.exec(`
|
|
1028
613
|
CREATE TABLE session_states_new (
|
|
1029
614
|
worktree_id TEXT NOT NULL,
|
|
1030
615
|
cli_tool_id TEXT NOT NULL DEFAULT 'claude',
|
|
@@ -1092,7 +677,7 @@
|
|
|
1092
677
|
SELECT worktree_id, cli_tool_id, last_captured_line, in_progress_message_id
|
|
1093
678
|
FROM session_states
|
|
1094
679
|
WHERE instance_id = cli_tool_id;
|
|
1095
|
-
`),a.exec("DROP TABLE session_states;"),a.exec("ALTER TABLE session_states_old RENAME TO session_states;"),console.log("Rolled back agent_instances migration (v33)")}},{version:34,name:"add-repository-todos",up:a=>{a.exec(`
|
|
680
|
+
`),a.exec("DROP TABLE session_states;"),a.exec("ALTER TABLE session_states_old RENAME TO session_states;"),console.log("Rolled back agent_instances migration (v33)")}}],x=[{version:34,name:"add-repository-todos",up:a=>{a.exec(`
|
|
1096
681
|
CREATE TABLE IF NOT EXISTS repository_todos (
|
|
1097
682
|
id TEXT PRIMARY KEY,
|
|
1098
683
|
repository_id TEXT NOT NULL,
|
|
@@ -1106,13 +691,13 @@
|
|
|
1106
691
|
`),a.exec(`
|
|
1107
692
|
CREATE INDEX IF NOT EXISTS idx_repository_todos_repo
|
|
1108
693
|
ON repository_todos(repository_id, position);
|
|
1109
|
-
`)},down:a=>{a.exec("DROP TABLE IF EXISTS repository_todos;")}},{version:35,name:"add-instance-id-to-timer-messages",up:a=>{a.exec(`
|
|
694
|
+
`)},down:a=>{a.exec("DROP TABLE IF EXISTS repository_todos;")}}],y=[{version:35,name:"add-instance-id-to-timer-messages",up:a=>{a.exec(`
|
|
1110
695
|
ALTER TABLE timer_messages ADD COLUMN instance_id TEXT;
|
|
1111
696
|
`),a.exec(`
|
|
1112
697
|
UPDATE timer_messages SET instance_id = cli_tool_id WHERE instance_id IS NULL;
|
|
1113
|
-
`),console.log("Added instance_id column to timer_messages table")},down:()=>{console.log("No rollback for instance_id column (SQLite limitation)")}},{version:36,name:"add-branch-to-worktrees",up:a=>{a.exec(`
|
|
698
|
+
`),console.log("Added instance_id column to timer_messages table")},down:()=>{console.log("No rollback for instance_id column (SQLite limitation)")}}],z=[{version:36,name:"add-branch-to-worktrees",up:a=>{a.exec(`
|
|
1114
699
|
ALTER TABLE worktrees ADD COLUMN branch TEXT;
|
|
1115
|
-
`),console.log("Added branch column to worktrees table")},down:()=>{console.log("No rollback for branch column (SQLite limitation)")}},{version:37,name:"add-worktree-todos",up:a=>{a.exec(`
|
|
700
|
+
`),console.log("Added branch column to worktrees table")},down:()=>{console.log("No rollback for branch column (SQLite limitation)")}}],A=[{version:37,name:"add-worktree-todos",up:a=>{a.exec(`
|
|
1116
701
|
CREATE TABLE IF NOT EXISTS worktree_todos (
|
|
1117
702
|
id TEXT PRIMARY KEY,
|
|
1118
703
|
worktree_id TEXT NOT NULL,
|
|
@@ -1126,17 +711,17 @@
|
|
|
1126
711
|
`),a.exec(`
|
|
1127
712
|
CREATE INDEX IF NOT EXISTS idx_worktree_todos_wt
|
|
1128
713
|
ON worktree_todos(worktree_id, position);
|
|
1129
|
-
`)},down:a=>{a.exec("DROP TABLE IF EXISTS worktree_todos;")}},{version:38,name:"add-status-to-worktree-todos",up:a=>{a.exec(`
|
|
714
|
+
`)},down:a=>{a.exec("DROP TABLE IF EXISTS worktree_todos;")}}],B=[{version:38,name:"add-status-to-worktree-todos",up:a=>{a.exec(`
|
|
1130
715
|
ALTER TABLE worktree_todos
|
|
1131
716
|
ADD COLUMN status TEXT NOT NULL DEFAULT 'todo';
|
|
1132
717
|
`),a.exec(`
|
|
1133
718
|
UPDATE worktree_todos SET status = 'done' WHERE done = 1;
|
|
1134
|
-
`)},down:()=>{}},{version:39,name:"add-detail-to-worktree-todos",up:a=>{a.exec(`
|
|
719
|
+
`)},down:()=>{}}],C=[{version:39,name:"add-detail-to-worktree-todos",up:a=>{a.exec(`
|
|
1135
720
|
ALTER TABLE worktree_todos
|
|
1136
721
|
ADD COLUMN detail TEXT NOT NULL DEFAULT '';
|
|
1137
|
-
`)},down:()=>{}},{version:40,name:"add-error-to-timer-messages",up:a=>{a.exec(`
|
|
722
|
+
`)},down:()=>{}}],D=[{version:40,name:"add-error-to-timer-messages",up:a=>{a.exec(`
|
|
1138
723
|
ALTER TABLE timer_messages ADD COLUMN error TEXT;
|
|
1139
|
-
`),console.log("Added error column to timer_messages table")},down:()=>{console.log("No rollback for error column (SQLite limitation)")}},{version:41,name:"add-push-subscriptions",up:a=>{a.exec(`
|
|
724
|
+
`),console.log("Added error column to timer_messages table")},down:()=>{console.log("No rollback for error column (SQLite limitation)")}}],E=[{version:41,name:"add-push-subscriptions",up:a=>{a.exec(`
|
|
1140
725
|
CREATE TABLE IF NOT EXISTS push_subscriptions (
|
|
1141
726
|
id TEXT PRIMARY KEY,
|
|
1142
727
|
endpoint TEXT NOT NULL UNIQUE,
|
|
@@ -1151,16 +736,16 @@
|
|
|
1151
736
|
`),a.exec(`
|
|
1152
737
|
CREATE INDEX IF NOT EXISTS idx_push_subscriptions_endpoint
|
|
1153
738
|
ON push_subscriptions(endpoint);
|
|
1154
|
-
`)},down:a=>{a.exec("DROP TABLE IF EXISTS push_subscriptions;")}},{version:42,name:"add-locale-to-push-subscriptions",up:a=>{a.exec(`
|
|
739
|
+
`)},down:a=>{a.exec("DROP TABLE IF EXISTS push_subscriptions;")}}],F=[{version:42,name:"add-locale-to-push-subscriptions",up:a=>{a.exec(`
|
|
1155
740
|
ALTER TABLE push_subscriptions ADD COLUMN locale TEXT;
|
|
1156
741
|
`)},down:a=>{a.exec(`
|
|
1157
742
|
ALTER TABLE push_subscriptions DROP COLUMN locale;
|
|
1158
|
-
`)}},{version:43,name:"remove-cm-root-dir-ghost-repository",up:a=>{let b=function(){let a=process.env.CM_ROOT_DIR??process.env.MCBD_ROOT_DIR;return a&&a.trim()?e().resolve(a.trim()):null}();return b?(function(){let a=process.env.WORKTREE_REPOS;return a&&a.trim()?a.split(",").map(a=>a.trim()).filter(a=>a.length>0).map(a=>e().resolve(a)):[]})().includes(b)?void console.log(`Migration 43: ${b} is a WORKTREE_REPOS entry; keeping its repository row`):void(a.prepare(`DELETE FROM repositories
|
|
743
|
+
`)}}],G=[{version:43,name:"remove-cm-root-dir-ghost-repository",up:a=>{let b=function(){let a=process.env.CM_ROOT_DIR??process.env.MCBD_ROOT_DIR;return a&&a.trim()?e().resolve(a.trim()):null}();return b?(function(){let a=process.env.WORKTREE_REPOS;return a&&a.trim()?a.split(",").map(a=>a.trim()).filter(a=>a.length>0).map(a=>e().resolve(a)):[]})().includes(b)?void console.log(`Migration 43: ${b} is a WORKTREE_REPOS entry; keeping its repository row`):void(a.prepare(`DELETE FROM repositories
|
|
1159
744
|
WHERE path = ?
|
|
1160
745
|
AND is_env_managed = 1
|
|
1161
746
|
AND NOT EXISTS (
|
|
1162
747
|
SELECT 1 FROM worktrees WHERE worktrees.repository_path = ?
|
|
1163
|
-
)`).run(b,b).changes>0?console.log(`Migration 43: removed CM_ROOT_DIR ghost repository row (${b})`):console.log(`Migration 43: no ghost repository row at ${b}`)):void console.log("Migration 43: CM_ROOT_DIR is not set; no ghost row to remove")},down:()=>{console.log("No rollback for the CM_ROOT_DIR ghost row removal")}},{version:44,name:"add-skill-operations",up:a=>{a.exec(`
|
|
748
|
+
)`).run(b,b).changes>0?console.log(`Migration 43: removed CM_ROOT_DIR ghost repository row (${b})`):console.log(`Migration 43: no ghost repository row at ${b}`)):void console.log("Migration 43: CM_ROOT_DIR is not set; no ghost row to remove")},down:()=>{console.log("No rollback for the CM_ROOT_DIR ghost row removal")}}],H=[{version:44,name:"add-skill-operations",up:a=>{a.exec(`
|
|
1164
749
|
CREATE TABLE IF NOT EXISTS skill_operations (
|
|
1165
750
|
id TEXT PRIMARY KEY,
|
|
1166
751
|
operation_id TEXT NOT NULL,
|
|
@@ -1204,7 +789,7 @@
|
|
|
1204
789
|
BEGIN
|
|
1205
790
|
SELECT RAISE(ABORT, 'skill_operations is append-only');
|
|
1206
791
|
END;
|
|
1207
|
-
`)},down:a=>{a.exec("DROP TRIGGER IF EXISTS skill_operations_no_delete;"),a.exec("DROP TRIGGER IF EXISTS skill_operations_no_update;"),a.exec("DROP TABLE IF EXISTS skill_operations;")}},{version:45,name:"add-skill-installations",up:a=>{a.exec(`
|
|
792
|
+
`)},down:a=>{a.exec("DROP TRIGGER IF EXISTS skill_operations_no_delete;"),a.exec("DROP TRIGGER IF EXISTS skill_operations_no_update;"),a.exec("DROP TABLE IF EXISTS skill_operations;")}}],I=[{version:45,name:"add-skill-installations",up:a=>{a.exec(`
|
|
1208
793
|
CREATE TABLE IF NOT EXISTS skill_installations (
|
|
1209
794
|
id TEXT PRIMARY KEY,
|
|
1210
795
|
worktree_id TEXT NOT NULL,
|
|
@@ -1228,24 +813,50 @@
|
|
|
1228
813
|
`),a.exec(`
|
|
1229
814
|
CREATE INDEX IF NOT EXISTS idx_skill_installations_skill
|
|
1230
815
|
ON skill_installations(skill_id, version);
|
|
1231
|
-
`)},down:a=>{a.exec("DROP INDEX IF EXISTS idx_skill_installations_skill;"),a.exec("DROP INDEX IF EXISTS idx_skill_installations_worktree;"),a.exec("DROP TABLE IF EXISTS skill_installations;")}},
|
|
816
|
+
`)},down:a=>{a.exec("DROP INDEX IF EXISTS idx_skill_installations_skill;"),a.exec("DROP INDEX IF EXISTS idx_skill_installations_worktree;"),a.exec("DROP TABLE IF EXISTS skill_installations;")}}],J=`
|
|
817
|
+
id, worktree_id, skill_id, version, install_root, receipt_sha256,
|
|
818
|
+
source_repository, source_ref, source_commit, artifact_sha256,
|
|
819
|
+
effective_risk, operation_id, installed_at, updated_at
|
|
820
|
+
`,K=`
|
|
821
|
+
id TEXT PRIMARY KEY,
|
|
822
|
+
worktree_id TEXT NOT NULL,
|
|
823
|
+
skill_id TEXT NOT NULL,
|
|
824
|
+
version TEXT NOT NULL,
|
|
825
|
+
install_root TEXT NOT NULL,
|
|
826
|
+
receipt_sha256 TEXT NOT NULL,
|
|
827
|
+
source_repository TEXT NOT NULL,
|
|
828
|
+
source_ref TEXT NOT NULL,
|
|
829
|
+
source_commit TEXT NOT NULL,
|
|
830
|
+
artifact_sha256 TEXT NOT NULL,
|
|
831
|
+
effective_risk TEXT NOT NULL,
|
|
832
|
+
operation_id TEXT NOT NULL,
|
|
833
|
+
installed_at INTEGER NOT NULL,
|
|
834
|
+
updated_at INTEGER NOT NULL,
|
|
835
|
+
UNIQUE (worktree_id, skill_id)
|
|
836
|
+
`;function L(a){a.exec(`
|
|
837
|
+
CREATE INDEX IF NOT EXISTS idx_skill_installations_worktree
|
|
838
|
+
ON skill_installations(worktree_id);
|
|
839
|
+
`),a.exec(`
|
|
840
|
+
CREATE INDEX IF NOT EXISTS idx_skill_installations_skill
|
|
841
|
+
ON skill_installations(skill_id, version);
|
|
842
|
+
`)}let M=[{version:46,name:"skill-installations-worktree-cascade",up:a=>{a.exec(`
|
|
1232
843
|
CREATE TABLE skill_installations_new (
|
|
1233
|
-
${
|
|
844
|
+
${K},
|
|
1234
845
|
FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
|
|
1235
846
|
);
|
|
1236
847
|
`),a.exec(`
|
|
1237
|
-
INSERT INTO skill_installations_new (${
|
|
1238
|
-
SELECT ${
|
|
848
|
+
INSERT INTO skill_installations_new (${J})
|
|
849
|
+
SELECT ${J} FROM skill_installations
|
|
1239
850
|
WHERE worktree_id IN (SELECT id FROM worktrees);
|
|
1240
851
|
`);let b=a.prepare(`SELECT COUNT(*) AS n FROM skill_installations
|
|
1241
|
-
WHERE worktree_id NOT IN (SELECT id FROM worktrees)`).get();a.exec("DROP TABLE skill_installations;"),a.exec("ALTER TABLE skill_installations_new RENAME TO skill_installations;"),
|
|
852
|
+
WHERE worktree_id NOT IN (SELECT id FROM worktrees)`).get();a.exec("DROP TABLE skill_installations;"),a.exec("ALTER TABLE skill_installations_new RENAME TO skill_installations;"),L(a),b.n>0&&console.log(`Removed ${b.n} skill_installations row(s) with no worktree`),console.log("skill_installations now cascades with its worktree")},down:a=>{a.exec(`
|
|
1242
853
|
CREATE TABLE skill_installations_old (
|
|
1243
|
-
${
|
|
854
|
+
${K}
|
|
1244
855
|
);
|
|
1245
856
|
`),a.exec(`
|
|
1246
|
-
INSERT INTO skill_installations_old (${
|
|
1247
|
-
SELECT ${
|
|
1248
|
-
`),a.exec("DROP TABLE skill_installations;"),a.exec("ALTER TABLE skill_installations_old RENAME TO skill_installations;"),
|
|
857
|
+
INSERT INTO skill_installations_old (${J})
|
|
858
|
+
SELECT ${J} FROM skill_installations;
|
|
859
|
+
`),a.exec("DROP TABLE skill_installations;"),a.exec("ALTER TABLE skill_installations_old RENAME TO skill_installations;"),L(a),console.log("Rolled back skill_installations cascade (v46)")}}],N=[{version:47,name:"add-skill-installations-roots",up:a=>{a.exec("ALTER TABLE skill_installations ADD COLUMN install_roots TEXT;")},down:a=>{a.exec(`
|
|
1249
860
|
CREATE TABLE skill_installations__v46 (
|
|
1250
861
|
id TEXT PRIMARY KEY,
|
|
1251
862
|
worktree_id TEXT NOT NULL,
|
|
@@ -1280,7 +891,7 @@
|
|
|
1280
891
|
`),a.exec(`
|
|
1281
892
|
CREATE INDEX IF NOT EXISTS idx_skill_installations_skill
|
|
1282
893
|
ON skill_installations(skill_id, version);
|
|
1283
|
-
`)}},{version:48,name:"add-skill-operations-audit-index",up:a=>{a.exec("ALTER TABLE skill_operations ADD COLUMN from_version TEXT;"),a.exec("ALTER TABLE skill_operations ADD COLUMN to_version TEXT;"),a.exec(`
|
|
894
|
+
`)}}],O=[{version:48,name:"add-skill-operations-audit-index",up:a=>{a.exec("ALTER TABLE skill_operations ADD COLUMN from_version TEXT;"),a.exec("ALTER TABLE skill_operations ADD COLUMN to_version TEXT;"),a.exec(`
|
|
1284
895
|
CREATE INDEX IF NOT EXISTS idx_skill_operations_recent
|
|
1285
896
|
ON skill_operations(recorded_at DESC, id DESC);
|
|
1286
897
|
`),a.exec(`
|
|
@@ -1343,7 +954,7 @@
|
|
|
1343
954
|
BEGIN
|
|
1344
955
|
SELECT RAISE(ABORT, 'skill_operations is append-only');
|
|
1345
956
|
END;
|
|
1346
|
-
`)}},{version:49,name:"add-verification-runs",up:a=>{a.exec(`
|
|
957
|
+
`)}}],P=[{version:49,name:"add-verification-runs",up:a=>{a.exec(`
|
|
1347
958
|
CREATE TABLE IF NOT EXISTS verification_runs (
|
|
1348
959
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1349
960
|
worktree_id TEXT NOT NULL,
|
|
@@ -1374,7 +985,7 @@
|
|
|
1374
985
|
`),a.exec(`
|
|
1375
986
|
CREATE INDEX IF NOT EXISTS idx_verification_gate_results_run
|
|
1376
987
|
ON verification_gate_results(run_id);
|
|
1377
|
-
`)},down:a=>{a.exec("DROP TABLE IF EXISTS verification_gate_results;"),a.exec("DROP TABLE IF EXISTS verification_runs;")}},{version:50,name:"add-tasks",up:a=>{a.exec(`
|
|
988
|
+
`)},down:a=>{a.exec("DROP TABLE IF EXISTS verification_gate_results;"),a.exec("DROP TABLE IF EXISTS verification_runs;")}}],Q=[{version:50,name:"add-tasks",up:a=>{a.exec(`
|
|
1378
989
|
CREATE TABLE IF NOT EXISTS tasks (
|
|
1379
990
|
id TEXT PRIMARY KEY,
|
|
1380
991
|
worktree_id TEXT NOT NULL,
|
|
@@ -1394,7 +1005,7 @@
|
|
|
1394
1005
|
`),a.exec(`
|
|
1395
1006
|
CREATE INDEX IF NOT EXISTS idx_tasks_worktree
|
|
1396
1007
|
ON tasks(worktree_id, created_at DESC);
|
|
1397
|
-
`)},down:a=>{a.exec("DROP TABLE IF EXISTS tasks;")}},{version:51,name:"add-task-events",up:a=>{a.exec(`
|
|
1008
|
+
`)},down:a=>{a.exec("DROP TABLE IF EXISTS tasks;")}}],R=[{version:51,name:"add-task-events",up:a=>{a.exec(`
|
|
1398
1009
|
CREATE TABLE IF NOT EXISTS task_events (
|
|
1399
1010
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1400
1011
|
task_id TEXT NOT NULL,
|
|
@@ -1407,13 +1018,407 @@
|
|
|
1407
1018
|
`),a.exec(`
|
|
1408
1019
|
CREATE INDEX IF NOT EXISTS idx_task_events_task
|
|
1409
1020
|
ON task_events(task_id, created_at);
|
|
1410
|
-
`)},down:a=>{a.exec("DROP TABLE IF EXISTS task_events;")}}];
|
|
1021
|
+
`)},down:a=>{a.exec("DROP TABLE IF EXISTS task_events;")}}];var S=c(40277);let T=[...i,...j,...k,...l,...m,...n,...o,...p,...q,...r,...s,...t,...u,...v,...w,...x,...y,...z,...A,...B,...C,...D,...E,...F,...G,...H,...I,...M,...N,...O,...P,...Q,...R,{version:52,name:"delete-orphaned-worktree-children",up:a=>{let b=0;for(let{table:c,column:d}of(0,S.ZN)(a)){let e=a.prepare(`DELETE FROM "${c}"
|
|
1022
|
+
WHERE "${d}" IS NOT NULL
|
|
1023
|
+
AND NOT EXISTS (
|
|
1024
|
+
SELECT 1 FROM worktrees AS cm_parent
|
|
1025
|
+
WHERE cm_parent.id = "${c}"."${d}"
|
|
1026
|
+
)`).run();e.changes>0&&(console.log(`Deleted ${e.changes} orphaned row(s) from ${c}.${d}`),b+=e.changes)}0===b&&console.log("No orphaned worktree child rows found")},down:()=>{console.log("No rollback for orphaned child row cleanup (rows are gone)")}}];function U(a){!function(a,b){a.exec(`
|
|
1411
1027
|
CREATE TABLE IF NOT EXISTS schema_version (
|
|
1412
1028
|
version INTEGER PRIMARY KEY,
|
|
1413
1029
|
name TEXT NOT NULL,
|
|
1414
1030
|
applied_at INTEGER NOT NULL
|
|
1415
1031
|
);
|
|
1416
|
-
`);let c=f(a);if(console.log(`Current schema version: ${c}`),c>
|
|
1032
|
+
`);let c=f(a);if(console.log(`Current schema version: ${c}`),c>52)throw Error(`This database (schema v${c}) was created by a newer version of CommandMate (this build supports up to v52). Please update: commandmate update`);let d=b.filter(a=>a.version>c);if(0===d.length)return console.log("Schema is up to date");for(let b of(console.log(`Found ${d.length} pending migration(s)`),d)){console.log(`Applying migration ${b.version}: ${b.name}...`);try{a.transaction(()=>{b.up(a),a.prepare(`
|
|
1417
1033
|
INSERT INTO schema_version (version, name, applied_at)
|
|
1418
1034
|
VALUES (?, ?, ?)
|
|
1419
|
-
`).run(b.version,b.name,Date.now())})(),console.log(`Migration ${b.version} applied successfully`)}catch(c){let a=c instanceof Error?c.message:String(c);throw console.error(`Migration ${b.version} failed:`,a),Error(`Migration ${b.version} (${b.name}) failed: ${a}`)}}console.log(`All migrations completed. Current version: ${f(a)}`)}(a,
|
|
1035
|
+
`).run(b.version,b.name,Date.now())})(),console.log(`Migration ${b.version} applied successfully`)}catch(c){let a=c instanceof Error?c.message:String(c);throw console.error(`Migration ${b.version} failed:`,a),Error(`Migration ${b.version} (${b.name}) failed: ${a}`)}}console.log(`All migrations completed. Current version: ${f(a)}`)}(a,T)}},28274:(a,b,c)=>{c.d(b,{AC:()=>e,BN:()=>i,Cs:()=>k,m0:()=>h,sB:()=>j,ug:()=>f});var d=c(15194);class e extends Error{constructor(a,b=d.Ab){super(`Worktree ${a} cannot have more than ${b} agent instances`),this.name="AgentInstanceLimitError"}}class f extends Error{constructor(a){super(a),this.name="InvalidAgentInstanceError"}}function g(a){let b=a.cli_tool_id,c=a.alias&&a.alias.length>0?a.alias:(0,d.hR)(a.cli_tool_id)?(0,d.oo)(b):a.cli_tool_id;return{id:a.instance_id,cliTool:b,alias:c,order:a.sort_order}}function h(a,b){return a.prepare(`
|
|
1036
|
+
SELECT worktree_id, instance_id, cli_tool_id, alias, sort_order, created_at
|
|
1037
|
+
FROM agent_instances
|
|
1038
|
+
WHERE worktree_id = ?
|
|
1039
|
+
ORDER BY sort_order ASC, instance_id ASC
|
|
1040
|
+
`).all(b).map(g)}function i(a,b,c){let d=a.prepare(`
|
|
1041
|
+
SELECT worktree_id, instance_id, cli_tool_id, alias, sort_order, created_at
|
|
1042
|
+
FROM agent_instances
|
|
1043
|
+
WHERE worktree_id = ? AND instance_id = ?
|
|
1044
|
+
`).get(b,c);return d?g(d):null}function j(a,b,c,e){if(!c)return{ok:!0,cliToolId:e??null};let f=i(a,b,c);return f&&(0,d.hR)(f.cliTool)?e&&e!==f.cliTool?{ok:!1,instanceId:c,rosterCliTool:f.cliTool,requestedCliTool:e}:{ok:!0,cliToolId:f.cliTool}:e?{ok:!0,cliToolId:e}:(0,d.hR)(c)?{ok:!0,cliToolId:c}:{ok:!0,cliToolId:null}}function k(a,b,c){if(c.length>d.Ab)throw new e(b);let g=new Set;for(let a of c){if(!(0,d.n6)(a.id))throw new f(`Invalid instance id: ${String(a.id)}`);if(!(0,d.hR)(a.cliTool))throw new f(`Invalid CLI tool: ${String(a.cliTool)}`);if("string"==typeof a.alias&&a.alias.length>d.pQ)throw new f(`Alias exceeds ${d.pQ} characters`);if(g.has(a.id))throw new f(`Duplicate instance id: ${a.id}`);g.add(a.id)}let h=Date.now();a.transaction(()=>{a.prepare("DELETE FROM agent_instances WHERE worktree_id = ?").run(b);let d=a.prepare(`
|
|
1045
|
+
INSERT INTO agent_instances
|
|
1046
|
+
(worktree_id, instance_id, cli_tool_id, alias, sort_order, created_at)
|
|
1047
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
1048
|
+
`);c.forEach((a,c)=>{let e=a.alias??"",f=Number.isInteger(a.order)?a.order:c;d.run(b,a.id,a.cliTool,e,f,h)})})()}},34129:(a,b,c)=>{c.d(b,{$$:()=>m,CR:()=>h,DP:()=>i,GF:()=>n,Ud:()=>l,j2:()=>k,jf:()=>o,kx:()=>j});var d=c(55511),e=c(87374);let f="id, worktree_id, cli_tool_id, instance_id, message, delay_ms, scheduled_send_time, status, created_at, sent_at, error";function g(a){return{id:a.id,worktreeId:a.worktree_id,cliToolId:a.cli_tool_id,instanceId:a.instance_id??a.cli_tool_id,message:a.message,delayMs:a.delay_ms,scheduledSendTime:a.scheduled_send_time,status:a.status,createdAt:a.created_at,sentAt:a.sent_at,error:a.error??null}}function h(a,b){let c=(0,d.randomUUID)(),e=Date.now(),f=e+b.delayMs,g=b.instanceId??b.cliToolId;return a.prepare(`
|
|
1049
|
+
INSERT INTO timer_messages (id, worktree_id, cli_tool_id, instance_id, message, delay_ms, scheduled_send_time, status, created_at, sent_at)
|
|
1050
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, 'pending', ?, NULL)
|
|
1051
|
+
`).run(c,b.worktreeId,b.cliToolId,g,b.message,b.delayMs,f,e),{id:c,worktreeId:b.worktreeId,cliToolId:b.cliToolId,instanceId:g,message:b.message,delayMs:b.delayMs,scheduledSendTime:f,status:"pending",createdAt:e,sentAt:null,error:null}}function i(a,b,c){let{before:d,limit:h=e.XS}=c??{},i=`SELECT ${f} FROM timer_messages WHERE worktree_id = ?`,j=[b];return void 0!==d&&(i+=" AND created_at < ?",j.push(d)),i+=" ORDER BY created_at DESC LIMIT ?",j.push(h+1),a.prepare(i).all(...j).map(g)}function j(a,b){let c=a.prepare(`
|
|
1052
|
+
SELECT ${f}
|
|
1053
|
+
FROM timer_messages
|
|
1054
|
+
WHERE id = ?
|
|
1055
|
+
`).get(b);return c?g(c):void 0}function k(a,b,c,d,e){let f=["status = ?"],g=[c];void 0!==d&&(f.push("sent_at = ?"),g.push(d)),void 0!==e&&(f.push("error = ?"),g.push(e)),g.push(b),a.prepare(`UPDATE timer_messages SET ${f.join(", ")} WHERE id = ?`).run(...g)}function l(a,b){return a.prepare(`
|
|
1056
|
+
UPDATE timer_messages SET status = 'cancelled' WHERE id = ? AND status = 'pending'
|
|
1057
|
+
`).run(b).changes>0}function m(a,b){return a.prepare(`
|
|
1058
|
+
UPDATE timer_messages SET status = 'cancelled' WHERE worktree_id = ? AND status = 'pending'
|
|
1059
|
+
`).run(b).changes}function n(a,b){return a.prepare(`
|
|
1060
|
+
SELECT COUNT(*) as count FROM timer_messages WHERE worktree_id = ? AND status = 'pending'
|
|
1061
|
+
`).get(b).count}function o(a,b){return a.prepare(`
|
|
1062
|
+
DELETE FROM timer_messages
|
|
1063
|
+
WHERE worktree_id = ?
|
|
1064
|
+
AND status NOT IN ('pending', 'sending')
|
|
1065
|
+
`).run(b).changes}},43167:(a,b,c)=>{c.d(b,{CF:()=>h,gn:()=>i,jA:()=>g,jJ:()=>j,th:()=>k});var d=c(55511);function e(a){return{id:a.id,endpoint:a.endpoint,keys:{p256dh:a.p256dh,auth:a.auth},deviceLabel:a.device_label,enabledPrompt:1===a.enabled_prompt,enabledCompletion:1===a.enabled_completion,locale:a.locale,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}let f=`
|
|
1066
|
+
id, endpoint, p256dh, auth, device_label,
|
|
1067
|
+
enabled_prompt, enabled_completion, locale, created_at, updated_at
|
|
1068
|
+
`;function g(a,b){let c=Date.now(),e=b.deviceLabel??null,f=b.locale??null;a.prepare(`
|
|
1069
|
+
INSERT INTO push_subscriptions (
|
|
1070
|
+
id, endpoint, p256dh, auth, device_label,
|
|
1071
|
+
enabled_prompt, enabled_completion, locale, created_at, updated_at
|
|
1072
|
+
)
|
|
1073
|
+
VALUES (?, ?, ?, ?, ?, 1, 1, ?, ?, ?)
|
|
1074
|
+
ON CONFLICT(endpoint) DO UPDATE SET
|
|
1075
|
+
p256dh = excluded.p256dh,
|
|
1076
|
+
auth = excluded.auth,
|
|
1077
|
+
device_label = excluded.device_label,
|
|
1078
|
+
locale = COALESCE(excluded.locale, push_subscriptions.locale),
|
|
1079
|
+
updated_at = excluded.updated_at
|
|
1080
|
+
`).run((0,d.randomUUID)(),b.endpoint,b.p256dh,b.auth,e,f,c,c);let g=h(a,b.endpoint);if(!g)throw Error("Failed to persist push subscription");return g}function h(a,b){let c=a.prepare(`SELECT ${f} FROM push_subscriptions WHERE endpoint = ?`).get(b);return c?e(c):null}function i(a,b){return a.prepare(`SELECT ${f} FROM push_subscriptions WHERE ${"prompt"===b?"enabled_prompt":"enabled_completion"} = 1 ORDER BY created_at ASC`).all().map(e)}function j(a,b,c){let d=["updated_at = ?"],e=[Date.now()];return void 0!==c.enabledPrompt&&(d.push("enabled_prompt = ?"),e.push(+!!c.enabledPrompt)),void 0!==c.enabledCompletion&&(d.push("enabled_completion = ?"),e.push(+!!c.enabledCompletion)),e.push(b),a.prepare(`UPDATE push_subscriptions SET ${d.join(", ")} WHERE endpoint = ?`).run(...e),h(a,b)}function k(a,b){return a.prepare("DELETE FROM push_subscriptions WHERE endpoint = ?").run(b).changes>0}},48524:(a,b,c)=>{c.d(b,{MH:()=>o,UT:()=>j,Vk:()=>l,Zj:()=>n,gg:()=>k,xZ:()=>m});var d=c(55511);let e=["succeeded","failed","not_started","cancelled"],f=["running","waiting_input","verifying"],g=[...f,"failed","not_started"],h=`
|
|
1081
|
+
id, worktree_id, cli_tool_id, instance_id, title, goal, contract_path, contract_json,
|
|
1082
|
+
status, last_verification_run_id, created_at, updated_at, started_at, finished_at
|
|
1083
|
+
`;function i(a){return{id:a.id,worktreeId:a.worktree_id,cliToolId:a.cli_tool_id,instanceId:a.instance_id,title:a.title,goal:a.goal,contractPath:a.contract_path,contract:JSON.parse(a.contract_json),status:a.status,lastVerificationRunId:a.last_verification_run_id,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at),startedAt:null===a.started_at?null:new Date(a.started_at),finishedAt:null===a.finished_at?null:new Date(a.finished_at)}}function j(a,b){let c=Date.now(),e=(0,d.randomUUID)(),f=b.status??"pending";a.prepare(`
|
|
1084
|
+
INSERT INTO tasks (
|
|
1085
|
+
id, worktree_id, cli_tool_id, instance_id, title, goal, contract_path, contract_json,
|
|
1086
|
+
status, last_verification_run_id, created_at, updated_at, started_at, finished_at
|
|
1087
|
+
)
|
|
1088
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, NULL)
|
|
1089
|
+
`).run(e,b.worktreeId,b.cliToolId,b.instanceId??null,b.contract.title,b.contract.goal,b.contractPath??null,JSON.stringify(b.contract),f,c,c,"pending"===f?null:c);let g=k(a,e);if(!g)throw Error("Failed to persist task");return g}function k(a,b){let c=a.prepare(`SELECT ${h} FROM tasks WHERE id = ?`).get(b);return c?i(c):null}function l(a,b,c=20){return a.prepare(`
|
|
1090
|
+
SELECT ${h} FROM tasks
|
|
1091
|
+
WHERE worktree_id = ?
|
|
1092
|
+
ORDER BY created_at DESC, rowid DESC
|
|
1093
|
+
LIMIT ?
|
|
1094
|
+
`).all(b,c).map(i)}function m(a,b,c,d={}){let f=Date.now();if(0===a.prepare(`
|
|
1095
|
+
UPDATE tasks
|
|
1096
|
+
SET status = ?,
|
|
1097
|
+
updated_at = ?,
|
|
1098
|
+
started_at = CASE WHEN ? = 'pending' THEN started_at ELSE COALESCE(started_at, ?) END,
|
|
1099
|
+
finished_at = CASE WHEN ? = 1 THEN ? ELSE finished_at END,
|
|
1100
|
+
last_verification_run_id = COALESCE(?, last_verification_run_id)
|
|
1101
|
+
WHERE id = ?
|
|
1102
|
+
`).run(c,f,c,f,+!!e.includes(c),f,d.lastVerificationRunId??null,b).changes)throw Error(`Task ${b} not found`);return k(a,b)}function n(a,b){let c=g.map(()=>"?").join(", "),d=a.prepare(`
|
|
1103
|
+
SELECT ${h} FROM tasks
|
|
1104
|
+
WHERE worktree_id = ? AND status IN (${c})
|
|
1105
|
+
ORDER BY updated_at DESC, created_at DESC, rowid DESC
|
|
1106
|
+
LIMIT 1
|
|
1107
|
+
`).get(b,...g);return d?i(d):null}function o(a,b,c,d){let e=d===c,g=f.map(()=>"?").join(", "),j=a.prepare(`
|
|
1108
|
+
SELECT ${h} FROM tasks
|
|
1109
|
+
WHERE worktree_id = ?
|
|
1110
|
+
AND cli_tool_id = ?
|
|
1111
|
+
AND (instance_id = ? OR (instance_id IS NULL AND ?))
|
|
1112
|
+
AND status IN (${g})
|
|
1113
|
+
ORDER BY updated_at DESC, created_at DESC, rowid DESC
|
|
1114
|
+
LIMIT 1
|
|
1115
|
+
`).get(b,c,d,+!!e,...f);return j?i(j):null}},87374:(a,b,c)=>{c.d(b,{Dr:()=>i,HR:()=>h,Ky:()=>f,XS:()=>e,ms:()=>g,u8:()=>d}),Array.from({length:Math.floor(104)+1},(a,b)=>3e5+3e5*b);let d=5,e=50,f=100,g=1e4,h={PENDING:"pending",SENDING:"sending",SENT:"sent",FAILED:"failed",CANCELLED:"cancelled",NO_SESSION:"no_session"};function i(a){return"number"==typeof a&&a>=3e5&&a<=315e5&&a%3e5==0}},88807:(a,b,c)=>{c.r(b),c.d(b,{closeDbInstance:()=>p,getDbInstance:()=>o});var d=c(33873),e=c.n(d),f=c(14520),g=c(79646),h=c(87550),i=c.n(h);let j=!1;function k(a){return a instanceof Error&&"ERR_DLOPEN_FAILED"===a.code&&a.message.includes("NODE_MODULE_VERSION")}function l(a,b){let c=["better-sqlite3 could not be loaded: it was built for a different Node.js version.","This usually happens after switching Node.js versions (nvm, fnm, Homebrew, ...).","",`Automatic recovery failed: ${a}`,"","How to fix it manually:"];return b?c.push(" The install directory is not writable by the current user, so the addon"," cannot be rebuilt in place. Do not re-run this with sudo — root-owned"," files there will break future installs and updates.",""," Either switch back to the Node.js version CommandMate was installed with:",` node -v (currently ${process.version}, NODE_MODULE_VERSION ${process.versions.modules})`,""," Or reinstall CommandMate under a Node.js version manager, which keeps"," global packages in a user-owned directory:"," nvm use <version> && npm install -g commandmate"):c.push(` 1. cd ${process.cwd()}`," 2. npm rebuild better-sqlite3"," 3. Start CommandMate again",""," If that fails, reinstalling picks up the current Node.js version:"," npm install -g commandmate"),c.join("\n")}var m=c(87447);let n=null;function o(){if(!n){let a=(0,m._$)().CM_DB_PATH,b=c(29021),d=e().dirname(a);b.existsSync(d)||b.mkdirSync(d,{recursive:!0,mode:448});let h=function(a){try{return new(i())(a)}catch(c){if(!k(c))throw c;if(j)throw Error(l("a rebuild was already attempted in this process.",!1));j=!0,console.error("[commandmate] better-sqlite3 was built for a different Node.js version.\n[commandmate] Rebuilding it automatically — this can take a few minutes...");let b=function(){let a=(0,g.spawnSync)("npm",["rebuild","better-sqlite3"],{cwd:process.cwd(),encoding:"utf-8",timeout:3e5,env:{...process.env,PATH:`${e().dirname(process.execPath)}${e().delimiter}${process.env.PATH??""}`}}),b=`${a.stdout??""}${a.stderr??""}`;return a.error||0!==a.status?{success:!1,permissionDenied:/EACCES|permission denied/i.test(b),output:b}:{success:!0,permissionDenied:!1,output:b}}();if(!b.success)throw Error(l("npm rebuild better-sqlite3 failed.",b.permissionDenied));console.error("[commandmate] Rebuild succeeded. Continuing startup.");try{return new(i())(a)}catch(a){if(k(a))throw Error(l("the addon still reports a version mismatch after rebuilding.",!1));throw a}}}(a);h.pragma("foreign_keys = ON"),h.pragma("journal_mode = WAL"),h.pragma("busy_timeout = 5000");try{(0,f.vI)(h)}catch(a){throw h.close(),a}n=h}return n}function p(){n&&(n.close(),n=null)}},90444:(a,b,c)=>{function d(a){a.exec(`
|
|
1116
|
+
CREATE TABLE IF NOT EXISTS worktrees (
|
|
1117
|
+
id TEXT PRIMARY KEY,
|
|
1118
|
+
name TEXT NOT NULL,
|
|
1119
|
+
path TEXT NOT NULL UNIQUE,
|
|
1120
|
+
last_message_summary TEXT,
|
|
1121
|
+
updated_at INTEGER
|
|
1122
|
+
);
|
|
1123
|
+
`),a.exec(`
|
|
1124
|
+
CREATE INDEX IF NOT EXISTS idx_worktrees_updated_at
|
|
1125
|
+
ON worktrees(updated_at DESC);
|
|
1126
|
+
`),a.exec(`
|
|
1127
|
+
CREATE TABLE IF NOT EXISTS chat_messages (
|
|
1128
|
+
id TEXT PRIMARY KEY,
|
|
1129
|
+
worktree_id TEXT NOT NULL,
|
|
1130
|
+
role TEXT NOT NULL CHECK(role IN ('user', 'assistant')),
|
|
1131
|
+
content TEXT NOT NULL,
|
|
1132
|
+
summary TEXT,
|
|
1133
|
+
timestamp INTEGER NOT NULL,
|
|
1134
|
+
log_file_name TEXT,
|
|
1135
|
+
request_id TEXT,
|
|
1136
|
+
message_type TEXT DEFAULT 'normal',
|
|
1137
|
+
prompt_data TEXT,
|
|
1138
|
+
cli_tool_id TEXT DEFAULT 'claude',
|
|
1139
|
+
archived INTEGER DEFAULT 0,
|
|
1140
|
+
|
|
1141
|
+
FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
|
|
1142
|
+
);
|
|
1143
|
+
`),a.exec(`
|
|
1144
|
+
CREATE INDEX IF NOT EXISTS idx_messages_worktree_time
|
|
1145
|
+
ON chat_messages(worktree_id, timestamp DESC);
|
|
1146
|
+
`),a.exec(`
|
|
1147
|
+
CREATE INDEX IF NOT EXISTS idx_messages_request_id
|
|
1148
|
+
ON chat_messages(request_id);
|
|
1149
|
+
`),a.exec(`
|
|
1150
|
+
CREATE INDEX IF NOT EXISTS idx_messages_type
|
|
1151
|
+
ON chat_messages(message_type, worktree_id);
|
|
1152
|
+
`),a.exec(`
|
|
1153
|
+
CREATE INDEX IF NOT EXISTS idx_messages_cli_tool
|
|
1154
|
+
ON chat_messages(worktree_id, cli_tool_id, timestamp DESC);
|
|
1155
|
+
`),a.exec(`
|
|
1156
|
+
CREATE INDEX IF NOT EXISTS idx_messages_worktree_role_archived_time
|
|
1157
|
+
ON chat_messages(worktree_id, role, archived, timestamp DESC);
|
|
1158
|
+
`),a.exec(`
|
|
1159
|
+
CREATE TABLE IF NOT EXISTS session_states (
|
|
1160
|
+
worktree_id TEXT NOT NULL,
|
|
1161
|
+
cli_tool_id TEXT NOT NULL DEFAULT 'claude',
|
|
1162
|
+
last_captured_line INTEGER DEFAULT 0,
|
|
1163
|
+
|
|
1164
|
+
PRIMARY KEY (worktree_id, cli_tool_id),
|
|
1165
|
+
FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
|
|
1166
|
+
);
|
|
1167
|
+
`)}c.d(b,{AC:()=>k.AC,Tu:()=>as,ug:()=>k.ug,eP:()=>au,mg:()=>at,lm:()=>m,af:()=>ag,KG:()=>C,cD:()=>X,Jj:()=>Y,YX:()=>i,G4:()=>S,hL:()=>$,qp:()=>U,hl:()=>an,To:()=>q,oH:()=>f.oH,UT:()=>ax.UT,py:()=>z,rY:()=>al,yy:()=>H,pE:()=>f.pE,z2:()=>ae,cP:()=>s,DF:()=>f.DF,lA:()=>f.lA,Qp:()=>f.Qp,th:()=>af.th,oZ:()=>e.oZ,ZP:()=>j,Ys:()=>B,vg:()=>J,Rm:()=>e.Rm,C8:()=>ao,u$:()=>am,MH:()=>ax.MH,BN:()=>k.BN,m0:()=>k.m0,Tk:()=>x,iT:()=>Q,gp:()=>R,yE:()=>Z,BE:()=>W,qK:()=>ac,p4:()=>e.p4,r8:()=>f.r8,of:()=>aa,DN:()=>p,pZ:()=>o,kA:()=>f.kA,VL:()=>f.VL,CF:()=>af.CF,NV:()=>e.NV,ce:()=>ab,WZ:()=>aq,y1:()=>g,gg:()=>ax.gg,Nr:()=>y,ob:()=>w,fr:()=>F,J6:()=>ap,Ui:()=>e.Ui,P9:()=>e.P9,eN:()=>G,vi:()=>e.vi,uJ:()=>e.uJ,s4:()=>d,yT:()=>D,Vk:()=>ax.Vk,Mt:()=>ar,UE:()=>aw,PL:()=>f.PL,jp:()=>f.jp,nQ:()=>t,yb:()=>K,GA:()=>e.GA,Cs:()=>k.Cs,xR:()=>T,az:()=>_,nZ:()=>V,PP:()=>ad,Dx:()=>e.Dx,O:()=>e.O,EU:()=>f.EU,HZ:()=>e.HZ,UY:()=>r,cw:()=>f.cw,jJ:()=>af.jJ,DC:()=>e.DC,gb:()=>h,yB:()=>e.yB,uy:()=>A,s:()=>e.s,iu:()=>e.iu,hq:()=>e.hq,z1:()=>e.z1,bl:()=>I,jA:()=>af.jA,ZL:()=>e.ZL});var e=c(73753),f=c(52660);function g(a,b,c="claude"){let d=a.prepare(`
|
|
1168
|
+
SELECT worktree_id, cli_tool_id, instance_id, last_captured_line, in_progress_message_id
|
|
1169
|
+
FROM session_states
|
|
1170
|
+
WHERE worktree_id = ? AND instance_id = ?
|
|
1171
|
+
`).get(b,c);return d?{worktreeId:d.worktree_id,cliToolId:d.cli_tool_id,instanceId:d.instance_id,lastCapturedLine:d.last_captured_line,inProgressMessageId:d.in_progress_message_id||null}:null}function h(a,b,c,d,e){let f=e??c;a.prepare(`
|
|
1172
|
+
INSERT INTO session_states (worktree_id, cli_tool_id, instance_id, last_captured_line)
|
|
1173
|
+
VALUES (?, ?, ?, ?)
|
|
1174
|
+
ON CONFLICT(worktree_id, instance_id) DO UPDATE SET
|
|
1175
|
+
last_captured_line = excluded.last_captured_line,
|
|
1176
|
+
cli_tool_id = excluded.cli_tool_id
|
|
1177
|
+
`).run(b,c,f,d)}function i(a,b,c,d){let e=d??c;a.prepare(`
|
|
1178
|
+
INSERT INTO session_states (worktree_id, cli_tool_id, instance_id, last_captured_line, in_progress_message_id)
|
|
1179
|
+
VALUES (?, ?, ?, 0, ?)
|
|
1180
|
+
ON CONFLICT(worktree_id, instance_id) DO UPDATE SET
|
|
1181
|
+
in_progress_message_id = excluded.in_progress_message_id,
|
|
1182
|
+
cli_tool_id = excluded.cli_tool_id
|
|
1183
|
+
`).run(b,c,e,null)}function j(a,b,c,d){d?a.prepare(`
|
|
1184
|
+
DELETE FROM session_states
|
|
1185
|
+
WHERE worktree_id = ? AND instance_id = ?
|
|
1186
|
+
`).run(b,d):c?a.prepare(`
|
|
1187
|
+
DELETE FROM session_states
|
|
1188
|
+
WHERE worktree_id = ? AND cli_tool_id = ?
|
|
1189
|
+
`).run(b,c):a.prepare(`
|
|
1190
|
+
DELETE FROM session_states
|
|
1191
|
+
WHERE worktree_id = ?
|
|
1192
|
+
`).run(b)}var k=c(28274),l=c(55511);class m extends Error{constructor(a,b,c){super(a),this.code=b,this.cause=c,this.name="MemoDbError"}}function n(a){return{id:a.id,worktreeId:a.worktree_id,title:a.title,content:a.content,position:a.position,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}function o(a,b){return a.prepare(`
|
|
1193
|
+
SELECT id, worktree_id, title, content, position, created_at, updated_at
|
|
1194
|
+
FROM worktree_memos
|
|
1195
|
+
WHERE worktree_id = ?
|
|
1196
|
+
ORDER BY position ASC
|
|
1197
|
+
`).all(b).map(n)}function p(a,b){let c=a.prepare(`
|
|
1198
|
+
SELECT id, worktree_id, title, content, position, created_at, updated_at
|
|
1199
|
+
FROM worktree_memos
|
|
1200
|
+
WHERE id = ?
|
|
1201
|
+
`).get(b);return c?n(c):null}function q(a,b,c){let d=(0,l.randomUUID)(),e=Date.now(),f=c.title??"Memo",g=c.content??"",h=a.prepare(`
|
|
1202
|
+
INSERT INTO worktree_memos (id, worktree_id, title, content, position, created_at, updated_at)
|
|
1203
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
1204
|
+
`);try{h.run(d,b,f,g,c.position,e,e)}catch(a){if(a instanceof Error&&a.message.includes("UNIQUE constraint"))throw new m(`Memo position ${c.position} is already in use for worktree "${b}"`,"DUPLICATE_POSITION",a);throw a}return{id:d,worktreeId:b,title:f,content:g,position:c.position,createdAt:new Date(e),updatedAt:new Date(e)}}function r(a,b,c){let d=Date.now(),e=["updated_at = ?"],f=[d];void 0!==c.title&&(e.push("title = ?"),f.push(c.title)),void 0!==c.content&&(e.push("content = ?"),f.push(c.content)),f.push(b),a.prepare(`
|
|
1205
|
+
UPDATE worktree_memos
|
|
1206
|
+
SET ${e.join(", ")}
|
|
1207
|
+
WHERE id = ?
|
|
1208
|
+
`).run(...f)}function s(a,b){a.prepare(`
|
|
1209
|
+
DELETE FROM worktree_memos
|
|
1210
|
+
WHERE id = ?
|
|
1211
|
+
`).run(b)}function t(a,b,c){if(0===c.length)return;let d=Date.now();a.transaction(()=>{let b=a.prepare(`
|
|
1212
|
+
UPDATE worktree_memos
|
|
1213
|
+
SET position = -1 - position
|
|
1214
|
+
WHERE id = ?
|
|
1215
|
+
`);for(let a of c)b.run(a);let e=a.prepare(`
|
|
1216
|
+
UPDATE worktree_memos
|
|
1217
|
+
SET position = ?, updated_at = ?
|
|
1218
|
+
WHERE id = ?
|
|
1219
|
+
`);c.forEach((a,b)=>{e.run(b,d,a)})})()}let u=`
|
|
1220
|
+
SELECT
|
|
1221
|
+
t.id,
|
|
1222
|
+
t.repository_id,
|
|
1223
|
+
r.name AS repository_name,
|
|
1224
|
+
r.display_name AS repository_display_name,
|
|
1225
|
+
t.content,
|
|
1226
|
+
t.done,
|
|
1227
|
+
t.position,
|
|
1228
|
+
t.created_at,
|
|
1229
|
+
t.updated_at
|
|
1230
|
+
FROM repository_todos t
|
|
1231
|
+
JOIN repositories r ON r.id = t.repository_id
|
|
1232
|
+
`;function v(a){return{id:a.id,repositoryId:a.repository_id,repositoryName:a.repository_name,repositoryDisplayName:a.repository_display_name||void 0,content:a.content,done:1===a.done,position:a.position,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}function w(a,b){return a.prepare(`
|
|
1233
|
+
${u}
|
|
1234
|
+
WHERE t.repository_id = ?
|
|
1235
|
+
ORDER BY t.position ASC, t.created_at ASC
|
|
1236
|
+
`).all(b).map(v)}function x(a){return a.prepare(`
|
|
1237
|
+
${u}
|
|
1238
|
+
ORDER BY
|
|
1239
|
+
COALESCE(NULLIF(TRIM(r.display_name), ''), r.name) COLLATE NOCASE ASC,
|
|
1240
|
+
t.position ASC,
|
|
1241
|
+
t.created_at ASC,
|
|
1242
|
+
t.id ASC
|
|
1243
|
+
`).all().map(v)}function y(a,b){let c=a.prepare(`
|
|
1244
|
+
${u}
|
|
1245
|
+
WHERE t.id = ?
|
|
1246
|
+
`).get(b);return c?v(c):null}function z(a,b,c){let d=(0,l.randomUUID)(),e=Date.now();a.prepare(`
|
|
1247
|
+
INSERT INTO repository_todos (id, repository_id, content, done, position, created_at, updated_at)
|
|
1248
|
+
VALUES (?, ?, ?, 0, ?, ?, ?)
|
|
1249
|
+
`).run(d,b,c.content,c.position,e,e);let f=y(a,d);if(!f)throw Error(`Failed to load created todo '${d}'`);return f}function A(a,b,c){let d=Date.now(),e=["updated_at = ?"],f=[d];void 0!==c.content&&(e.push("content = ?"),f.push(c.content)),void 0!==c.done&&(e.push("done = ?"),f.push(+!!c.done)),f.push(b),a.prepare(`
|
|
1250
|
+
UPDATE repository_todos
|
|
1251
|
+
SET ${e.join(", ")}
|
|
1252
|
+
WHERE id = ?
|
|
1253
|
+
`).run(...f)}function B(a,b){a.prepare(`
|
|
1254
|
+
DELETE FROM repository_todos
|
|
1255
|
+
WHERE id = ?
|
|
1256
|
+
`).run(b)}let C=["todo","doing","done"];function D(a){return"todo"===a||"doing"===a||"done"===a}function E(a){var b,c;let d=(b=a.status,c=a.done,D(b)?b:1===c?"done":"todo");return{id:a.id,worktreeId:a.worktree_id,content:a.content,detail:a.detail??"",status:d,done:"done"===d,position:a.position,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}function F(a,b){return a.prepare(`
|
|
1257
|
+
SELECT id, worktree_id, content, detail, done, status, position, created_at, updated_at
|
|
1258
|
+
FROM worktree_todos
|
|
1259
|
+
WHERE worktree_id = ?
|
|
1260
|
+
ORDER BY position ASC, created_at ASC
|
|
1261
|
+
`).all(b).map(E)}function G(a,b){let c=a.prepare(`
|
|
1262
|
+
SELECT id, worktree_id, content, detail, done, status, position, created_at, updated_at
|
|
1263
|
+
FROM worktree_todos
|
|
1264
|
+
WHERE id = ?
|
|
1265
|
+
`).get(b);return c?E(c):null}function H(a,b,c){let d=(0,l.randomUUID)(),e=Date.now(),f=c.status??"todo",g=c.detail??"";return a.prepare(`
|
|
1266
|
+
INSERT INTO worktree_todos (id, worktree_id, content, detail, done, status, position, created_at, updated_at)
|
|
1267
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1268
|
+
`).run(d,b,c.content,g,+("done"===f),f,c.position,e,e),{id:d,worktreeId:b,content:c.content,detail:g,status:f,done:"done"===f,position:c.position,createdAt:new Date(e),updatedAt:new Date(e)}}function I(a,b,c){let d,e=Date.now(),f=["updated_at = ?"],g=[e];void 0!==c.content&&(f.push("content = ?"),g.push(c.content)),void 0!==c.detail&&(f.push("detail = ?"),g.push(c.detail)),void 0!==c.status?d=c.status:void 0!==c.done&&(d=c.done?"done":"todo"),void 0!==d&&(f.push("status = ?"),g.push(d),f.push("done = ?"),g.push(+("done"===d))),g.push(b),a.prepare(`
|
|
1269
|
+
UPDATE worktree_todos
|
|
1270
|
+
SET ${f.join(", ")}
|
|
1271
|
+
WHERE id = ?
|
|
1272
|
+
`).run(...g)}function J(a,b){a.prepare(`
|
|
1273
|
+
DELETE FROM worktree_todos
|
|
1274
|
+
WHERE id = ?
|
|
1275
|
+
`).run(b)}function K(a,b,c){if(0===c.length)return;let d=Date.now();a.transaction(()=>{let e=a.prepare(`
|
|
1276
|
+
UPDATE worktree_todos
|
|
1277
|
+
SET position = -1 - position
|
|
1278
|
+
WHERE id = ? AND worktree_id = ?
|
|
1279
|
+
`);for(let a of c)e.run(a,b);let f=a.prepare(`
|
|
1280
|
+
UPDATE worktree_todos
|
|
1281
|
+
SET position = ?, updated_at = ?
|
|
1282
|
+
WHERE id = ? AND worktree_id = ?
|
|
1283
|
+
`);c.forEach((a,c)=>{f.run(c,d,a,b)})})()}function L(a,b){return Buffer.byteLength(a,"utf-8")<=b?a:Buffer.from(a,"utf-8").subarray(0,b).toString("utf-8")}function M(a){return{id:a.id,repositoryId:a.repository_id,cliToolId:a.cli_tool_id,workingDirectory:a.working_directory,executionMode:a.execution_mode??"interactive",resumeSessionId:a.resume_session_id??void 0,lastExecutionId:a.last_execution_id??void 0,sessionName:a.session_name??void 0,status:"idle"===a.status?"stopped":a.status,lastStartedAt:a.last_started_at?new Date(a.last_started_at):void 0,lastStoppedAt:a.last_stopped_at?new Date(a.last_stopped_at):void 0,contextSentAt:a.context_sent_at?new Date(a.context_sent_at):void 0,contextSnapshot:a.context_snapshot??void 0,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at),archived:1===a.archived}}function N(a){return{id:a.id,conversationId:a.conversation_id,role:a.role,content:a.content,summary:a.summary??void 0,timestamp:new Date(a.timestamp),messageType:a.message_type,deliveryStatus:a.delivery_status??void 0,archived:1===a.archived}}function O(a){return{id:a.id,conversationId:a.conversation_id,cliToolId:a.cli_tool_id,status:a.status,pid:a.pid??void 0,commandLine:a.command_line,promptText:a.prompt_text,stdoutText:a.stdout_text??void 0,stderrText:a.stderr_text??void 0,finalMessageText:a.final_message_text??void 0,exitCode:a.exit_code,resumeSessionIdBefore:a.resume_session_id_before??void 0,resumeSessionIdAfter:a.resume_session_id_after??void 0,startedAt:a.started_at?new Date(a.started_at):void 0,finishedAt:a.finished_at?new Date(a.finished_at):void 0,createdAt:new Date(a.created_at),updatedAt:new Date(a.updated_at)}}function P(a,b,c){a.prepare(`
|
|
1284
|
+
UPDATE assistant_conversations
|
|
1285
|
+
SET updated_at = ?
|
|
1286
|
+
WHERE id = ?
|
|
1287
|
+
`).run(c.getTime(),b)}function Q(a,b,c={}){let d=`
|
|
1288
|
+
SELECT *
|
|
1289
|
+
FROM assistant_conversations
|
|
1290
|
+
WHERE id = ?
|
|
1291
|
+
${c.includeArchived?"":"AND archived = 0"}
|
|
1292
|
+
LIMIT 1
|
|
1293
|
+
`,e=a.prepare(d).get(b);return e?M(e):null}function R(a,b,c,d={}){let e=`
|
|
1294
|
+
SELECT *
|
|
1295
|
+
FROM assistant_conversations
|
|
1296
|
+
WHERE repository_id = ?
|
|
1297
|
+
AND cli_tool_id = ?
|
|
1298
|
+
${d.includeArchived?"":"AND archived = 0"}
|
|
1299
|
+
LIMIT 1
|
|
1300
|
+
`,f=a.prepare(e).get(b,c);return f?M(f):null}function S(a,b){let c=(0,l.randomUUID)(),d=Date.now();return a.prepare(`
|
|
1301
|
+
INSERT INTO assistant_conversations (
|
|
1302
|
+
id, repository_id, cli_tool_id, working_directory, execution_mode, resume_session_id,
|
|
1303
|
+
last_execution_id, session_name, status,
|
|
1304
|
+
last_started_at, last_stopped_at, context_sent_at, created_at, updated_at, archived
|
|
1305
|
+
)
|
|
1306
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0)
|
|
1307
|
+
`).run(c,b.repositoryId,b.cliToolId,b.workingDirectory,b.executionMode??"interactive",b.resumeSessionId??null,b.lastExecutionId??null,b.sessionName??null,b.status??"stopped",b.lastStartedAt?.getTime()??null,b.lastStoppedAt?.getTime()??null,b.contextSentAt?.getTime()??null,d,d),{id:c,repositoryId:b.repositoryId,cliToolId:b.cliToolId,workingDirectory:b.workingDirectory,executionMode:b.executionMode??"interactive",resumeSessionId:b.resumeSessionId,lastExecutionId:b.lastExecutionId,sessionName:b.sessionName,status:b.status??"stopped",contextSentAt:b.contextSentAt,lastStartedAt:b.lastStartedAt,lastStoppedAt:b.lastStoppedAt,createdAt:new Date(d),updatedAt:new Date(d),archived:!1}}function T(a,b,c){let d=[],e=[];void 0!==c.workingDirectory&&(d.push("working_directory = ?"),e.push(c.workingDirectory)),void 0!==c.executionMode&&(d.push("execution_mode = ?"),e.push(c.executionMode)),void 0!==c.resumeSessionId&&(d.push("resume_session_id = ?"),e.push(c.resumeSessionId)),void 0!==c.lastExecutionId&&(d.push("last_execution_id = ?"),e.push(c.lastExecutionId)),void 0!==c.sessionName&&(d.push("session_name = ?"),e.push(c.sessionName)),void 0!==c.status&&(d.push("status = ?"),e.push(c.status)),void 0!==c.lastStartedAt&&(d.push("last_started_at = ?"),e.push(c.lastStartedAt?.getTime()??null)),void 0!==c.lastStoppedAt&&(d.push("last_stopped_at = ?"),e.push(c.lastStoppedAt?.getTime()??null)),void 0!==c.contextSentAt&&(d.push("context_sent_at = ?"),e.push(c.contextSentAt?.getTime()??null)),void 0!==c.contextSnapshot&&(d.push("context_snapshot = ?"),e.push(c.contextSnapshot??null)),void 0!==c.archived&&(d.push("archived = ?"),e.push(+!!c.archived));let f=c.updatedAt??new Date;return d.push("updated_at = ?"),e.push(f.getTime()),e.push(b),a.prepare(`
|
|
1308
|
+
UPDATE assistant_conversations
|
|
1309
|
+
SET ${d.join(", ")}
|
|
1310
|
+
WHERE id = ?
|
|
1311
|
+
`).run(...e),Q(a,b,{includeArchived:!0})}function U(a,b){let c=(0,l.randomUUID)();return a.prepare(`
|
|
1312
|
+
INSERT INTO assistant_messages (
|
|
1313
|
+
id, conversation_id, role, content, summary, timestamp, message_type, delivery_status, archived
|
|
1314
|
+
)
|
|
1315
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0)
|
|
1316
|
+
`).run(c,b.conversationId,b.role,b.content,b.summary??null,b.timestamp.getTime(),b.messageType,b.deliveryStatus??null),P(a,b.conversationId,b.timestamp),{id:c,...b,archived:!1}}function V(a,b,c){a.prepare(`
|
|
1317
|
+
UPDATE assistant_messages
|
|
1318
|
+
SET delivery_status = ?
|
|
1319
|
+
WHERE id = ?
|
|
1320
|
+
`).run(c,b)}function W(a,b,c={}){let{limit:d=200,before:e,includeArchived:f=!1}=c,g=[b,e?.getTime()??null,e?.getTime()??null],h=`
|
|
1321
|
+
SELECT *
|
|
1322
|
+
FROM assistant_messages
|
|
1323
|
+
WHERE conversation_id = ?
|
|
1324
|
+
AND (? IS NULL OR timestamp < ?)
|
|
1325
|
+
`;return f||(h+=" AND archived = 0"),h+=" ORDER BY timestamp DESC LIMIT ?",g.push(d),a.prepare(h).all(...g).map(N)}function X(a,b){return a.prepare(`
|
|
1326
|
+
UPDATE assistant_messages
|
|
1327
|
+
SET archived = 1
|
|
1328
|
+
WHERE conversation_id = ?
|
|
1329
|
+
AND archived = 0
|
|
1330
|
+
`).run(b).changes}function Y(a,b,c){return a.prepare(`
|
|
1331
|
+
UPDATE assistant_messages
|
|
1332
|
+
SET archived = 1
|
|
1333
|
+
WHERE conversation_id = ?
|
|
1334
|
+
AND archived = 0
|
|
1335
|
+
AND timestamp >= ?
|
|
1336
|
+
`).run(b,c).changes}function Z(a,b){let c=a.prepare(`
|
|
1337
|
+
SELECT * FROM assistant_messages WHERE id = ?
|
|
1338
|
+
`).get(b);return c?N(c):null}function $(a,b){let c=(0,l.randomUUID)(),d=Date.now();return a.prepare(`
|
|
1339
|
+
INSERT INTO assistant_executions (
|
|
1340
|
+
id, conversation_id, cli_tool_id, status, pid, command_line, prompt_text,
|
|
1341
|
+
stdout_text, stderr_text, final_message_text, exit_code, resume_session_id_before,
|
|
1342
|
+
resume_session_id_after, started_at, finished_at, created_at, updated_at
|
|
1343
|
+
)
|
|
1344
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1345
|
+
`).run(c,b.conversationId,b.cliToolId,b.status??"queued",b.pid??null,b.commandLine,L(b.promptText,65536),L(b.stdoutText??"",262144)||null,L(b.stderrText??"",262144)||null,b.finalMessageText?L(b.finalMessageText,65536):null,b.exitCode??null,b.resumeSessionIdBefore??null,b.resumeSessionIdAfter??null,b.startedAt?.getTime()??null,b.finishedAt?.getTime()??null,d,d),P(a,b.conversationId,new Date(d)),{id:c,conversationId:b.conversationId,cliToolId:b.cliToolId,status:b.status??"queued",pid:b.pid,commandLine:b.commandLine,promptText:L(b.promptText,65536),stdoutText:b.stdoutText?L(b.stdoutText,262144):void 0,stderrText:b.stderrText?L(b.stderrText,262144):void 0,finalMessageText:b.finalMessageText?L(b.finalMessageText,65536):void 0,exitCode:b.exitCode,resumeSessionIdBefore:b.resumeSessionIdBefore,resumeSessionIdAfter:b.resumeSessionIdAfter,startedAt:b.startedAt,finishedAt:b.finishedAt,createdAt:new Date(d),updatedAt:new Date(d)}}function _(a,b,c){let d=[],e=[];void 0!==c.status&&(d.push("status = ?"),e.push(c.status)),void 0!==c.pid&&(d.push("pid = ?"),e.push(c.pid)),void 0!==c.stdoutText&&(d.push("stdout_text = ?"),e.push(c.stdoutText?L(c.stdoutText,262144):null)),void 0!==c.stderrText&&(d.push("stderr_text = ?"),e.push(c.stderrText?L(c.stderrText,262144):null)),void 0!==c.finalMessageText&&(d.push("final_message_text = ?"),e.push(c.finalMessageText?L(c.finalMessageText,65536):null)),void 0!==c.exitCode&&(d.push("exit_code = ?"),e.push(c.exitCode)),void 0!==c.resumeSessionIdAfter&&(d.push("resume_session_id_after = ?"),e.push(c.resumeSessionIdAfter)),void 0!==c.startedAt&&(d.push("started_at = ?"),e.push(c.startedAt?.getTime()??null)),void 0!==c.finishedAt&&(d.push("finished_at = ?"),e.push(c.finishedAt?.getTime()??null));let f=c.updatedAt??new Date;return d.push("updated_at = ?"),e.push(f.getTime(),b),a.prepare(`
|
|
1346
|
+
UPDATE assistant_executions
|
|
1347
|
+
SET ${d.join(", ")}
|
|
1348
|
+
WHERE id = ?
|
|
1349
|
+
`).run(...e),function(a,b){let c=a.prepare(`
|
|
1350
|
+
SELECT *
|
|
1351
|
+
FROM assistant_executions
|
|
1352
|
+
WHERE id = ?
|
|
1353
|
+
LIMIT 1
|
|
1354
|
+
`).get(b);return c?O(c):null}(a,b)}function aa(a,b){let c=a.prepare(`
|
|
1355
|
+
SELECT *
|
|
1356
|
+
FROM assistant_executions
|
|
1357
|
+
WHERE conversation_id = ?
|
|
1358
|
+
ORDER BY created_at DESC
|
|
1359
|
+
LIMIT 1
|
|
1360
|
+
`).get(b);return c?O(c):null}function ab(a,b){let c=a.prepare(`
|
|
1361
|
+
SELECT *
|
|
1362
|
+
FROM assistant_executions
|
|
1363
|
+
WHERE conversation_id = ?
|
|
1364
|
+
AND status = 'running'
|
|
1365
|
+
ORDER BY created_at DESC
|
|
1366
|
+
LIMIT 1
|
|
1367
|
+
`).get(b);return c?O(c):null}function ac(a,b){let c=a.prepare(`
|
|
1368
|
+
SELECT conversation_id, last_captured_line, in_progress_message_id
|
|
1369
|
+
FROM assistant_session_states
|
|
1370
|
+
WHERE conversation_id = ?
|
|
1371
|
+
`).get(b);return c?{conversationId:c.conversation_id,lastCapturedLine:c.last_captured_line,inProgressMessageId:c.in_progress_message_id}:null}function ad(a,b,c,d){a.prepare(`
|
|
1372
|
+
INSERT INTO assistant_session_states (conversation_id, last_captured_line, in_progress_message_id)
|
|
1373
|
+
VALUES (?, ?, ?)
|
|
1374
|
+
ON CONFLICT(conversation_id) DO UPDATE SET
|
|
1375
|
+
last_captured_line = excluded.last_captured_line,
|
|
1376
|
+
in_progress_message_id = excluded.in_progress_message_id
|
|
1377
|
+
`).run(b,c,d??null)}function ae(a,b){a.prepare(`
|
|
1378
|
+
DELETE FROM assistant_session_states
|
|
1379
|
+
WHERE conversation_id = ?
|
|
1380
|
+
`).run(b)}c(34129);var af=c(43167);let ag=["manual","wait","api","task"],ah=`
|
|
1381
|
+
id, worktree_id, instance_id, task_id, trigger, status, base_ref, started_at, finished_at
|
|
1382
|
+
`,ai=`
|
|
1383
|
+
id, run_id, gate_id, command, status, exit_code, duration_ms, log_tail, started_at, finished_at
|
|
1384
|
+
`;function aj(a){return{id:a.id,worktreeId:a.worktree_id,instanceId:a.instance_id,taskId:a.task_id,trigger:a.trigger,status:a.status,baseRef:a.base_ref,startedAt:new Date(a.started_at),finishedAt:null===a.finished_at?null:new Date(a.finished_at)}}function ak(a){return{id:a.id,runId:a.run_id,gateId:a.gate_id,command:a.command,status:a.status,exitCode:a.exit_code,durationMs:a.duration_ms,logTail:a.log_tail,startedAt:new Date(a.started_at),finishedAt:null===a.finished_at?null:new Date(a.finished_at),timingsMeasured:null!==a.finished_at&&null!==a.duration_ms&&a.finished_at-a.started_at===a.duration_ms}}function al(a,b){let c=Date.now(),d=a.prepare(`
|
|
1385
|
+
INSERT INTO verification_runs (
|
|
1386
|
+
worktree_id, instance_id, task_id, trigger, status, base_ref, started_at, finished_at
|
|
1387
|
+
)
|
|
1388
|
+
VALUES (?, ?, ?, ?, 'running', ?, ?, NULL)
|
|
1389
|
+
`).run(b.worktreeId,b.instanceId??null,b.taskId??null,b.trigger,b.baseRef??null,c),e=a.prepare(`SELECT ${ah} FROM verification_runs WHERE id = ?`).get(Number(d.lastInsertRowid));if(!e)throw Error("Failed to persist verification run");return aj(e)}function am(a,b,c){if(0===a.prepare("UPDATE verification_runs SET status = ?, finished_at = ? WHERE id = ?").run(c,Date.now(),b).changes)throw Error(`Verification run ${b} not found`)}function an(a,b,c){let d=Date.now(),e=a.prepare(`
|
|
1390
|
+
INSERT INTO verification_gate_results (
|
|
1391
|
+
run_id, gate_id, command, status, exit_code, duration_ms, log_tail, started_at, finished_at
|
|
1392
|
+
)
|
|
1393
|
+
VALUES (?, ?, ?, 'running', NULL, NULL, NULL, ?, NULL)
|
|
1394
|
+
`).run(b,c.gateId,c.command,d),f=a.prepare(`SELECT ${ai} FROM verification_gate_results WHERE id = ?`).get(Number(e.lastInsertRowid));if(!f)throw Error("Failed to persist verification gate result");return ak(f)}function ao(a,b,c){if(0===a.prepare(`
|
|
1395
|
+
UPDATE verification_gate_results
|
|
1396
|
+
SET status = ?, exit_code = ?, duration_ms = ?, log_tail = ?,
|
|
1397
|
+
started_at = COALESCE(?, started_at),
|
|
1398
|
+
finished_at = ?
|
|
1399
|
+
WHERE id = ?
|
|
1400
|
+
`).run(c.status,c.exitCode??null,c.durationMs??null,c.logTail??null,c.executionWindow?.startedAt??null,c.executionWindow?.finishedAt??Date.now(),b).changes)throw Error(`Verification gate result ${b} not found`)}function ap(a,b){let c=a.prepare(`SELECT ${ah} FROM verification_runs WHERE id = ?`).get(b);if(!c)return null;let d=a.prepare(`
|
|
1401
|
+
SELECT ${ai} FROM verification_gate_results
|
|
1402
|
+
WHERE run_id = ?
|
|
1403
|
+
ORDER BY started_at ASC, id ASC
|
|
1404
|
+
`).all(b);return{...aj(c),gates:d.map(ak)}}function aq(a,b){let c=a.prepare(`
|
|
1405
|
+
SELECT ${ah} FROM verification_runs
|
|
1406
|
+
WHERE worktree_id = ? AND status = 'running'
|
|
1407
|
+
ORDER BY id DESC
|
|
1408
|
+
LIMIT 1
|
|
1409
|
+
`).get(b);return c?aj(c):null}function ar(a,b,c=20){return a.prepare(`
|
|
1410
|
+
SELECT ${ah} FROM verification_runs
|
|
1411
|
+
WHERE worktree_id = ?
|
|
1412
|
+
ORDER BY started_at DESC, id DESC
|
|
1413
|
+
LIMIT ?
|
|
1414
|
+
`).all(b,c).map(aj)}let as=50,at=500,au=90;function av(a,b,c,d){return void 0!==a&&Number.isFinite(a)?Math.min(Math.max(Math.trunc(a),c),d):b}function aw(a,b={}){let c=av(b.limit,as,1,at),d=[],e=[];if(void 0!==b.worktreeId&&(d.push("worktree_id = ?"),e.push(b.worktreeId)),void 0!==b.days){let a=av(b.days,au,1,au);d.push("started_at >= ?"),e.push(Date.now()-864e5*a)}let f=d.length>0?`WHERE ${d.join(" AND ")}`:"",g=a.prepare(`
|
|
1415
|
+
SELECT ${ah} FROM verification_runs
|
|
1416
|
+
${f}
|
|
1417
|
+
ORDER BY started_at DESC, id DESC
|
|
1418
|
+
LIMIT ?
|
|
1419
|
+
`).all(...e,c);if(0===g.length)return[];let h=g.map(()=>"?").join(", "),i=a.prepare(`
|
|
1420
|
+
SELECT run_id, gate_id, status, exit_code, duration_ms
|
|
1421
|
+
FROM verification_gate_results
|
|
1422
|
+
WHERE run_id IN (${h})
|
|
1423
|
+
ORDER BY started_at ASC, id ASC
|
|
1424
|
+
`).all(...g.map(a=>a.id)),j=new Map;for(let a of i){let b={gateId:a.gate_id,status:a.status,exitCode:a.exit_code,durationMs:a.duration_ms},c=j.get(a.run_id);c?c.push(b):j.set(a.run_id,[b])}return g.map(a=>({...aj(a),gates:j.get(a.id)??[]}))}var ax=c(48524)}};
|