gsd-pi 2.45.0 → 2.46.0-dev.cc9d310
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/dist/help-text.js +1 -1
- package/dist/loader.js +34 -0
- package/dist/resources/extensions/gsd/auto/phases.js +27 -42
- package/dist/resources/extensions/gsd/auto/run-unit.js +6 -3
- package/dist/resources/extensions/gsd/auto/session.js +0 -11
- package/dist/resources/extensions/gsd/auto-artifact-paths.js +112 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +25 -96
- package/dist/resources/extensions/gsd/auto-start.js +2 -3
- package/dist/resources/extensions/gsd/auto-worktree.js +5 -4
- package/dist/resources/extensions/gsd/auto.js +12 -57
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +15 -12
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +18 -0
- package/dist/resources/extensions/gsd/commands/context.js +0 -4
- package/dist/resources/extensions/gsd/commands/handlers/parallel.js +1 -1
- package/dist/resources/extensions/gsd/crash-recovery.js +2 -4
- package/dist/resources/extensions/gsd/dashboard-overlay.js +0 -44
- package/dist/resources/extensions/gsd/db-writer.js +9 -9
- package/dist/resources/extensions/gsd/doctor-checks.js +167 -2
- package/dist/resources/extensions/gsd/doctor.js +5 -3
- package/dist/resources/extensions/gsd/gsd-db.js +16 -3
- package/dist/resources/extensions/gsd/guided-flow.js +1 -2
- package/dist/resources/extensions/gsd/parallel-merge.js +1 -1
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +5 -18
- package/dist/resources/extensions/gsd/preferences-types.js +2 -2
- package/dist/resources/extensions/gsd/preferences.js +8 -4
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +21 -8
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +10 -23
- package/dist/resources/extensions/gsd/prompts/discuss.md +2 -2
- package/dist/resources/extensions/gsd/prompts/execute-task.md +5 -15
- package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/guided-discuss-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/guided-plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/guided-research-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +4 -2
- package/dist/resources/extensions/gsd/prompts/queue.md +2 -2
- package/dist/resources/extensions/gsd/prompts/quick-task.md +2 -0
- package/dist/resources/extensions/gsd/prompts/reactive-execute.md +1 -1
- package/dist/resources/extensions/gsd/prompts/research-slice.md +3 -3
- package/dist/resources/extensions/gsd/prompts/rethink.md +7 -2
- package/dist/resources/extensions/gsd/prompts/system.md +1 -1
- package/dist/resources/extensions/gsd/session-lock.js +1 -3
- package/dist/resources/extensions/gsd/state.js +7 -0
- package/dist/resources/extensions/gsd/sync-lock.js +89 -0
- package/dist/resources/extensions/gsd/tools/complete-milestone.js +61 -11
- package/dist/resources/extensions/gsd/tools/complete-slice.js +56 -11
- package/dist/resources/extensions/gsd/tools/complete-task.js +50 -2
- package/dist/resources/extensions/gsd/tools/plan-milestone.js +37 -1
- package/dist/resources/extensions/gsd/tools/plan-slice.js +30 -1
- package/dist/resources/extensions/gsd/tools/plan-task.js +27 -1
- package/dist/resources/extensions/gsd/tools/reassess-roadmap.js +32 -2
- package/dist/resources/extensions/gsd/tools/reopen-slice.js +86 -0
- package/dist/resources/extensions/gsd/tools/reopen-task.js +90 -0
- package/dist/resources/extensions/gsd/tools/replan-slice.js +32 -2
- package/dist/resources/extensions/gsd/unit-ownership.js +85 -0
- package/dist/resources/extensions/gsd/workflow-events.js +102 -0
- package/dist/resources/extensions/gsd/workflow-logger.js +193 -0
- package/dist/resources/extensions/gsd/workflow-manifest.js +244 -0
- package/dist/resources/extensions/gsd/workflow-migration.js +280 -0
- package/dist/resources/extensions/gsd/workflow-projections.js +373 -0
- package/dist/resources/extensions/gsd/workflow-reconcile.js +411 -0
- package/dist/resources/extensions/gsd/worktree-manager.js +4 -3
- package/dist/resources/extensions/gsd/worktree-resolver.js +37 -0
- package/dist/resources/extensions/gsd/write-intercept.js +84 -0
- package/dist/resources/extensions/voice/index.js +11 -16
- package/dist/resources/extensions/voice/linux-ready.js +67 -0
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +17 -17
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/required-server-files.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
- package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +5 -5
- package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +4 -4
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +4 -4
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/page.js +2 -2
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +17 -17
- package/dist/web/standalone/.next/server/chunks/229.js +1 -1
- package/dist/web/standalone/.next/server/chunks/471.js +3 -3
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware.js +2 -2
- package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
- package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +2 -2
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-2f24283c162b6ab3.js → page-f2a7482d42a5614b.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/{layout-9ecfd95f343793f0.js → layout-a16c7a7ecdf0c2cf.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/page-6654a8cca61a3d1c.js +1 -0
- package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +1 -0
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +1 -0
- package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
- package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
- package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
- package/dist/web/standalone/server.js +1 -1
- package/package.json +2 -1
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js +2 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +2 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lifecycle-hooks.d.ts +4 -0
- package/packages/pi-coding-agent/dist/core/lifecycle-hooks.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lifecycle-hooks.js +10 -5
- package/packages/pi-coding-agent/dist/core/lifecycle-hooks.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lifecycle-hooks.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/lifecycle-hooks.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/lifecycle-hooks.test.js +185 -0
- package/packages/pi-coding-agent/dist/core/lifecycle-hooks.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js +239 -10
- package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +2 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +20 -2
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/package-commands.test.js +206 -195
- package/packages/pi-coding-agent/dist/core/package-commands.test.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/compaction-orchestrator.ts +2 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +2 -1
- package/packages/pi-coding-agent/src/core/lifecycle-hooks.test.ts +227 -0
- package/packages/pi-coding-agent/src/core/lifecycle-hooks.ts +11 -5
- package/packages/pi-coding-agent/src/core/model-registry-auth-mode.test.ts +297 -11
- package/packages/pi-coding-agent/src/core/model-registry.ts +30 -3
- package/packages/pi-coding-agent/src/core/package-commands.test.ts +227 -205
- package/pkg/package.json +1 -1
- package/src/resources/extensions/gsd/auto/loop-deps.ts +0 -19
- package/src/resources/extensions/gsd/auto/phases.ts +24 -44
- package/src/resources/extensions/gsd/auto/run-unit.ts +6 -3
- package/src/resources/extensions/gsd/auto/session.ts +0 -18
- package/src/resources/extensions/gsd/auto-artifact-paths.ts +131 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +0 -1
- package/src/resources/extensions/gsd/auto-post-unit.ts +25 -106
- package/src/resources/extensions/gsd/auto-start.ts +1 -3
- package/src/resources/extensions/gsd/auto-worktree.ts +8 -5
- package/src/resources/extensions/gsd/auto.ts +7 -83
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +15 -12
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +22 -0
- package/src/resources/extensions/gsd/commands/context.ts +0 -5
- package/src/resources/extensions/gsd/commands/handlers/parallel.ts +1 -1
- package/src/resources/extensions/gsd/crash-recovery.ts +1 -5
- package/src/resources/extensions/gsd/dashboard-overlay.ts +0 -50
- package/src/resources/extensions/gsd/db-writer.ts +9 -17
- package/src/resources/extensions/gsd/doctor-checks.ts +180 -2
- package/src/resources/extensions/gsd/doctor-types.ts +7 -1
- package/src/resources/extensions/gsd/doctor.ts +6 -3
- package/src/resources/extensions/gsd/gsd-db.ts +16 -3
- package/src/resources/extensions/gsd/guided-flow.ts +1 -2
- package/src/resources/extensions/gsd/journal.ts +6 -1
- package/src/resources/extensions/gsd/parallel-merge.ts +1 -1
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +5 -21
- package/src/resources/extensions/gsd/preferences-types.ts +2 -2
- package/src/resources/extensions/gsd/preferences.ts +7 -3
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +21 -8
- package/src/resources/extensions/gsd/prompts/complete-slice.md +10 -23
- package/src/resources/extensions/gsd/prompts/discuss.md +2 -2
- package/src/resources/extensions/gsd/prompts/execute-task.md +5 -15
- package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/guided-discuss-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/guided-plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/guided-research-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-slice.md +4 -2
- package/src/resources/extensions/gsd/prompts/queue.md +2 -2
- package/src/resources/extensions/gsd/prompts/quick-task.md +2 -0
- package/src/resources/extensions/gsd/prompts/reactive-execute.md +1 -1
- package/src/resources/extensions/gsd/prompts/research-slice.md +3 -3
- package/src/resources/extensions/gsd/prompts/rethink.md +7 -2
- package/src/resources/extensions/gsd/prompts/system.md +1 -1
- package/src/resources/extensions/gsd/session-lock.ts +0 -4
- package/src/resources/extensions/gsd/state.ts +8 -0
- package/src/resources/extensions/gsd/sync-lock.ts +94 -0
- package/src/resources/extensions/gsd/tests/auto-lock-creation.test.ts +5 -13
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +6 -10
- package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +96 -0
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +264 -228
- package/src/resources/extensions/gsd/tests/complete-task.test.ts +317 -250
- package/src/resources/extensions/gsd/tests/crash-recovery.test.ts +2 -8
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +0 -3
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/idle-recovery.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/integration-proof.test.ts +15 -24
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +0 -3
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/merge-conflict-stops-loop.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/milestone-transition-state-rebuild.test.ts +8 -9
- package/src/resources/extensions/gsd/tests/none-mode-gates.test.ts +42 -3
- package/src/resources/extensions/gsd/tests/parallel-budget-atomicity.test.ts +0 -1
- package/src/resources/extensions/gsd/tests/parallel-crash-recovery.test.ts +0 -7
- package/src/resources/extensions/gsd/tests/parallel-merge.test.ts +7 -8
- package/src/resources/extensions/gsd/tests/parallel-orchestration.test.ts +20 -24
- package/src/resources/extensions/gsd/tests/parallel-worker-monitoring.test.ts +0 -2
- package/src/resources/extensions/gsd/tests/plan-milestone.test.ts +9 -6
- package/src/resources/extensions/gsd/tests/post-mutation-hook.test.ts +171 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +7 -9
- package/src/resources/extensions/gsd/tests/projection-regression.test.ts +174 -0
- package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +15 -14
- package/src/resources/extensions/gsd/tests/reopen-slice.test.ts +155 -0
- package/src/resources/extensions/gsd/tests/reopen-task.test.ts +165 -0
- package/src/resources/extensions/gsd/tests/session-lock-regression.test.ts +1 -4
- package/src/resources/extensions/gsd/tests/stop-auto-remote.test.ts +2 -3
- package/src/resources/extensions/gsd/tests/sync-lock.test.ts +122 -0
- package/src/resources/extensions/gsd/tests/unit-ownership.test.ts +175 -0
- package/src/resources/extensions/gsd/tests/workflow-events.test.ts +205 -0
- package/src/resources/extensions/gsd/tests/workflow-logger.test.ts +275 -0
- package/src/resources/extensions/gsd/tests/workflow-manifest.test.ts +186 -0
- package/src/resources/extensions/gsd/tests/workflow-projections.test.ts +171 -0
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +220 -0
- package/src/resources/extensions/gsd/tests/write-intercept.test.ts +76 -0
- package/src/resources/extensions/gsd/tools/complete-milestone.ts +74 -11
- package/src/resources/extensions/gsd/tools/complete-slice.ts +68 -11
- package/src/resources/extensions/gsd/tools/complete-task.ts +63 -1
- package/src/resources/extensions/gsd/tools/plan-milestone.ts +45 -0
- package/src/resources/extensions/gsd/tools/plan-slice.ts +38 -0
- package/src/resources/extensions/gsd/tools/plan-task.ts +35 -1
- package/src/resources/extensions/gsd/tools/reassess-roadmap.ts +39 -1
- package/src/resources/extensions/gsd/tools/reopen-slice.ts +125 -0
- package/src/resources/extensions/gsd/tools/reopen-task.ts +129 -0
- package/src/resources/extensions/gsd/tools/replan-slice.ts +38 -1
- package/src/resources/extensions/gsd/types.ts +8 -0
- package/src/resources/extensions/gsd/unit-ownership.ts +104 -0
- package/src/resources/extensions/gsd/workflow-events.ts +154 -0
- package/src/resources/extensions/gsd/workflow-logger.ts +243 -0
- package/src/resources/extensions/gsd/workflow-manifest.ts +334 -0
- package/src/resources/extensions/gsd/workflow-migration.ts +345 -0
- package/src/resources/extensions/gsd/workflow-projections.ts +425 -0
- package/src/resources/extensions/gsd/workflow-reconcile.ts +503 -0
- package/src/resources/extensions/gsd/worktree-manager.ts +4 -9
- package/src/resources/extensions/gsd/worktree-resolver.ts +37 -0
- package/src/resources/extensions/gsd/write-intercept.ts +90 -0
- package/src/resources/extensions/voice/index.ts +11 -21
- package/src/resources/extensions/voice/linux-ready.ts +87 -0
- package/src/resources/extensions/voice/tests/linux-ready.test.ts +124 -0
- package/dist/web/standalone/.next/static/chunks/app/page-12dd5ece0df4badc.js +0 -1
- package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +0 -1
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +0 -1
- /package/dist/web/standalone/.next/static/{wUzEX1U3CmFcMry2SUDJn → ZIDqryyYDroh_8AnaAOSG}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{wUzEX1U3CmFcMry2SUDJn → ZIDqryyYDroh_8AnaAOSG}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { mkdirSync, existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
3
|
+
import { readEvents, findForkPoint, appendEvent, getSessionId } from "./workflow-events.js";
|
|
4
|
+
import type { WorkflowEvent } from "./workflow-events.js";
|
|
5
|
+
import {
|
|
6
|
+
transaction,
|
|
7
|
+
updateTaskStatus,
|
|
8
|
+
updateSliceStatus,
|
|
9
|
+
insertVerificationEvidence,
|
|
10
|
+
upsertDecision,
|
|
11
|
+
openDatabase,
|
|
12
|
+
} from "./gsd-db.js";
|
|
13
|
+
import { writeManifest } from "./workflow-manifest.js";
|
|
14
|
+
import { atomicWriteSync } from "./atomic-write.js";
|
|
15
|
+
import { acquireSyncLock, releaseSyncLock } from "./sync-lock.js";
|
|
16
|
+
|
|
17
|
+
// ─── Public Types ─────────────────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
export interface ConflictEntry {
|
|
20
|
+
entityType: string;
|
|
21
|
+
entityId: string;
|
|
22
|
+
mainSideEvents: WorkflowEvent[];
|
|
23
|
+
worktreeSideEvents: WorkflowEvent[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ReconcileResult {
|
|
27
|
+
autoMerged: number;
|
|
28
|
+
conflicts: ConflictEntry[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ─── replayEvents ─────────────────────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Replay a list of WorkflowEvents by dispatching each to the appropriate
|
|
35
|
+
* gsd-db function. This replaces the old engine.replayAll() pattern with
|
|
36
|
+
* direct DB calls.
|
|
37
|
+
*/
|
|
38
|
+
function replayEvents(events: WorkflowEvent[]): void {
|
|
39
|
+
transaction(() => {
|
|
40
|
+
for (const event of events) {
|
|
41
|
+
const p = event.params;
|
|
42
|
+
switch (event.cmd) {
|
|
43
|
+
case "complete_task": {
|
|
44
|
+
const milestoneId = p["milestoneId"] as string;
|
|
45
|
+
const sliceId = p["sliceId"] as string;
|
|
46
|
+
const taskId = p["taskId"] as string;
|
|
47
|
+
updateTaskStatus(milestoneId, sliceId, taskId, "done", event.ts);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case "start_task": {
|
|
51
|
+
const milestoneId = p["milestoneId"] as string;
|
|
52
|
+
const sliceId = p["sliceId"] as string;
|
|
53
|
+
const taskId = p["taskId"] as string;
|
|
54
|
+
updateTaskStatus(milestoneId, sliceId, taskId, "in-progress", event.ts);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case "report_blocker": {
|
|
58
|
+
// report_blocker marks the task with blocker_discovered = 1
|
|
59
|
+
// The DB helper updateTaskStatus doesn't handle blockers,
|
|
60
|
+
// so we just update status to "blocked" as a best-effort replay.
|
|
61
|
+
const milestoneId = p["milestoneId"] as string;
|
|
62
|
+
const sliceId = p["sliceId"] as string;
|
|
63
|
+
const taskId = p["taskId"] as string;
|
|
64
|
+
updateTaskStatus(milestoneId, sliceId, taskId, "blocked");
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case "record_verification": {
|
|
68
|
+
const milestoneId = p["milestoneId"] as string;
|
|
69
|
+
const sliceId = p["sliceId"] as string;
|
|
70
|
+
const taskId = p["taskId"] as string;
|
|
71
|
+
insertVerificationEvidence({
|
|
72
|
+
taskId,
|
|
73
|
+
sliceId,
|
|
74
|
+
milestoneId,
|
|
75
|
+
command: (p["command"] as string) ?? "",
|
|
76
|
+
exitCode: (p["exitCode"] as number) ?? 0,
|
|
77
|
+
verdict: (p["verdict"] as string) ?? "",
|
|
78
|
+
durationMs: (p["durationMs"] as number) ?? 0,
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "complete_slice": {
|
|
83
|
+
const milestoneId = p["milestoneId"] as string;
|
|
84
|
+
const sliceId = p["sliceId"] as string;
|
|
85
|
+
updateSliceStatus(milestoneId, sliceId, "done", event.ts);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "plan_slice": {
|
|
89
|
+
// plan_slice events are informational — slice should already exist.
|
|
90
|
+
// No DB mutation needed during replay (the slice was inserted at plan time).
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case "save_decision": {
|
|
94
|
+
upsertDecision({
|
|
95
|
+
id: (p["id"] as string) ?? `${p["scope"]}:${p["decision"]}`,
|
|
96
|
+
when_context: (p["when_context"] as string) ?? (p["whenContext"] as string) ?? "",
|
|
97
|
+
scope: (p["scope"] as string) ?? "",
|
|
98
|
+
decision: (p["decision"] as string) ?? "",
|
|
99
|
+
choice: (p["choice"] as string) ?? "",
|
|
100
|
+
rationale: (p["rationale"] as string) ?? "",
|
|
101
|
+
revisable: (p["revisable"] as string) ?? "yes",
|
|
102
|
+
made_by: ((p["made_by"] as string) ?? (p["madeBy"] as string) ?? "agent") as "agent",
|
|
103
|
+
superseded_by: (p["superseded_by"] as string) ?? (p["supersededBy"] as string) ?? null,
|
|
104
|
+
});
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
default:
|
|
108
|
+
// Unknown commands are silently skipped during replay
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}); // end transaction
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ─── extractEntityKey ─────────────────────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Map a WorkflowEvent command to its affected entity type and ID.
|
|
119
|
+
* Returns null for commands that don't touch a named entity
|
|
120
|
+
* (e.g. unknown or future cmds).
|
|
121
|
+
*/
|
|
122
|
+
export function extractEntityKey(
|
|
123
|
+
event: WorkflowEvent,
|
|
124
|
+
): { type: string; id: string } | null {
|
|
125
|
+
const p = event.params;
|
|
126
|
+
|
|
127
|
+
switch (event.cmd) {
|
|
128
|
+
case "complete_task":
|
|
129
|
+
case "start_task":
|
|
130
|
+
case "report_blocker":
|
|
131
|
+
case "record_verification":
|
|
132
|
+
return typeof p["taskId"] === "string"
|
|
133
|
+
? { type: "task", id: p["taskId"] }
|
|
134
|
+
: null;
|
|
135
|
+
|
|
136
|
+
case "complete_slice":
|
|
137
|
+
return typeof p["sliceId"] === "string"
|
|
138
|
+
? { type: "slice", id: p["sliceId"] }
|
|
139
|
+
: null;
|
|
140
|
+
|
|
141
|
+
case "plan_slice":
|
|
142
|
+
return typeof p["sliceId"] === "string"
|
|
143
|
+
? { type: "slice_plan", id: p["sliceId"] }
|
|
144
|
+
: null;
|
|
145
|
+
|
|
146
|
+
case "save_decision":
|
|
147
|
+
if (typeof p["scope"] === "string" && typeof p["decision"] === "string") {
|
|
148
|
+
return { type: "decision", id: `${p["scope"]}:${p["decision"]}` };
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
|
|
152
|
+
default:
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ─── detectConflicts ──────────────────────────────────────────────────────────
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Compare two sets of diverged events. Returns conflict entries for any
|
|
161
|
+
* entity touched by both sides.
|
|
162
|
+
*
|
|
163
|
+
* Entity-level granularity: if both sides touched task T01 (with any cmd),
|
|
164
|
+
* that is one conflict regardless of field-level differences.
|
|
165
|
+
*/
|
|
166
|
+
export function detectConflicts(
|
|
167
|
+
mainDiverged: WorkflowEvent[],
|
|
168
|
+
wtDiverged: WorkflowEvent[],
|
|
169
|
+
): ConflictEntry[] {
|
|
170
|
+
// Group each side's events by entity key
|
|
171
|
+
const mainByEntity = new Map<string, WorkflowEvent[]>();
|
|
172
|
+
for (const event of mainDiverged) {
|
|
173
|
+
const key = extractEntityKey(event);
|
|
174
|
+
if (!key) continue;
|
|
175
|
+
const bucket = mainByEntity.get(`${key.type}:${key.id}`) ?? [];
|
|
176
|
+
bucket.push(event);
|
|
177
|
+
mainByEntity.set(`${key.type}:${key.id}`, bucket);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const wtByEntity = new Map<string, WorkflowEvent[]>();
|
|
181
|
+
for (const event of wtDiverged) {
|
|
182
|
+
const key = extractEntityKey(event);
|
|
183
|
+
if (!key) continue;
|
|
184
|
+
const bucket = wtByEntity.get(`${key.type}:${key.id}`) ?? [];
|
|
185
|
+
bucket.push(event);
|
|
186
|
+
wtByEntity.set(`${key.type}:${key.id}`, bucket);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Find entities touched by both sides
|
|
190
|
+
const conflicts: ConflictEntry[] = [];
|
|
191
|
+
for (const [entityKey, mainEvents] of mainByEntity) {
|
|
192
|
+
const wtEvents = wtByEntity.get(entityKey);
|
|
193
|
+
if (!wtEvents) continue;
|
|
194
|
+
|
|
195
|
+
const colonIdx = entityKey.indexOf(":");
|
|
196
|
+
const entityType = entityKey.slice(0, colonIdx);
|
|
197
|
+
const entityId = entityKey.slice(colonIdx + 1);
|
|
198
|
+
|
|
199
|
+
conflicts.push({
|
|
200
|
+
entityType,
|
|
201
|
+
entityId,
|
|
202
|
+
mainSideEvents: mainEvents,
|
|
203
|
+
worktreeSideEvents: wtEvents,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return conflicts;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// ─── writeConflictsFile ───────────────────────────────────────────────────────
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Write a human-readable CONFLICTS.md to basePath/.gsd/CONFLICTS.md.
|
|
214
|
+
* Lists each conflict with both sides' event payloads and resolution instructions.
|
|
215
|
+
*/
|
|
216
|
+
export function writeConflictsFile(
|
|
217
|
+
basePath: string,
|
|
218
|
+
conflicts: ConflictEntry[],
|
|
219
|
+
worktreePath: string,
|
|
220
|
+
): void {
|
|
221
|
+
const timestamp = new Date().toISOString();
|
|
222
|
+
const lines: string[] = [
|
|
223
|
+
`# Merge Conflicts — ${timestamp}`,
|
|
224
|
+
"",
|
|
225
|
+
`Conflicts detected merging worktree \`${worktreePath}\` into \`${basePath}\`.`,
|
|
226
|
+
`Run \`gsd resolve-conflict\` to resolve each conflict.`,
|
|
227
|
+
"",
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
conflicts.forEach((conflict, idx) => {
|
|
231
|
+
lines.push(`## Conflict ${idx + 1}: ${conflict.entityType} ${conflict.entityId}`);
|
|
232
|
+
lines.push("");
|
|
233
|
+
lines.push("**Main side events:**");
|
|
234
|
+
for (const event of conflict.mainSideEvents) {
|
|
235
|
+
lines.push(`- ${event.cmd} at ${event.ts} (hash: ${event.hash})`);
|
|
236
|
+
lines.push(` params: ${JSON.stringify(event.params)}`);
|
|
237
|
+
}
|
|
238
|
+
lines.push("");
|
|
239
|
+
lines.push("**Worktree side events:**");
|
|
240
|
+
for (const event of conflict.worktreeSideEvents) {
|
|
241
|
+
lines.push(`- ${event.cmd} at ${event.ts} (hash: ${event.hash})`);
|
|
242
|
+
lines.push(` params: ${JSON.stringify(event.params)}`);
|
|
243
|
+
}
|
|
244
|
+
lines.push("");
|
|
245
|
+
lines.push(`**Resolve with:** \`gsd resolve-conflict --entity ${conflict.entityType}:${conflict.entityId} --pick [main|worktree]\``);
|
|
246
|
+
lines.push("");
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const content = lines.join("\n");
|
|
250
|
+
const dir = join(basePath, ".gsd");
|
|
251
|
+
mkdirSync(dir, { recursive: true });
|
|
252
|
+
atomicWriteSync(join(dir, "CONFLICTS.md"), content);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ─── reconcileWorktreeLogs ────────────────────────────────────────────────────
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Event-log-based reconciliation algorithm:
|
|
259
|
+
*
|
|
260
|
+
* 1. Read both event logs
|
|
261
|
+
* 2. Find fork point (last common event by hash)
|
|
262
|
+
* 3. Slice diverged sets from each side
|
|
263
|
+
* 4. If no divergence on either side → return autoMerged: 0, conflicts: []
|
|
264
|
+
* 5. detectConflicts() — if any, writeConflictsFile + return early (D-04 all-or-nothing)
|
|
265
|
+
* 6. If clean: sort merged = mainDiverged + wtDiverged by timestamp, replayAll
|
|
266
|
+
* 7. Write merged event log (base + merged in timestamp order)
|
|
267
|
+
* 8. writeManifest
|
|
268
|
+
* 9. Return { autoMerged: merged.length, conflicts: [] }
|
|
269
|
+
*/
|
|
270
|
+
export function reconcileWorktreeLogs(
|
|
271
|
+
mainBasePath: string,
|
|
272
|
+
worktreeBasePath: string,
|
|
273
|
+
): ReconcileResult {
|
|
274
|
+
// Acquire advisory lock to prevent concurrent reconcile + append races
|
|
275
|
+
const lock = acquireSyncLock(mainBasePath);
|
|
276
|
+
if (!lock.acquired) {
|
|
277
|
+
process.stderr.write(
|
|
278
|
+
`[gsd] reconcile: could not acquire sync lock — another reconciliation may be in progress\n`,
|
|
279
|
+
);
|
|
280
|
+
return { autoMerged: 0, conflicts: [] };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
try {
|
|
284
|
+
return _reconcileWorktreeLogsInner(mainBasePath, worktreeBasePath);
|
|
285
|
+
} finally {
|
|
286
|
+
releaseSyncLock(mainBasePath);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function _reconcileWorktreeLogsInner(
|
|
291
|
+
mainBasePath: string,
|
|
292
|
+
worktreeBasePath: string,
|
|
293
|
+
): ReconcileResult {
|
|
294
|
+
// Step 1: Read both logs
|
|
295
|
+
const mainLogPath = join(mainBasePath, ".gsd", "event-log.jsonl");
|
|
296
|
+
const wtLogPath = join(worktreeBasePath, ".gsd", "event-log.jsonl");
|
|
297
|
+
|
|
298
|
+
const mainEvents = readEvents(mainLogPath);
|
|
299
|
+
const wtEvents = readEvents(wtLogPath);
|
|
300
|
+
|
|
301
|
+
// Step 2: Find fork point
|
|
302
|
+
const forkPoint = findForkPoint(mainEvents, wtEvents);
|
|
303
|
+
|
|
304
|
+
// Step 3: Slice diverged sets
|
|
305
|
+
const mainDiverged = mainEvents.slice(forkPoint + 1);
|
|
306
|
+
const wtDiverged = wtEvents.slice(forkPoint + 1);
|
|
307
|
+
|
|
308
|
+
// Step 4: No divergence on either side
|
|
309
|
+
if (mainDiverged.length === 0 && wtDiverged.length === 0) {
|
|
310
|
+
return { autoMerged: 0, conflicts: [] };
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Step 5: Detect conflicts (entity-level)
|
|
314
|
+
const conflicts = detectConflicts(mainDiverged, wtDiverged);
|
|
315
|
+
if (conflicts.length > 0) {
|
|
316
|
+
// D-04: atomic all-or-nothing — block entire merge
|
|
317
|
+
writeConflictsFile(mainBasePath, conflicts, worktreeBasePath);
|
|
318
|
+
process.stderr.write(
|
|
319
|
+
`[gsd] reconcile: ${conflicts.length} conflict(s) detected — see ${join(mainBasePath, ".gsd", "CONFLICTS.md")}\n`,
|
|
320
|
+
);
|
|
321
|
+
return { autoMerged: 0, conflicts };
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Step 6: Clean merge — stable sort by timestamp (index-based tiebreaker)
|
|
325
|
+
const indexed = [...mainDiverged, ...wtDiverged].map((e, i) => ({ e, i }));
|
|
326
|
+
indexed.sort((a, b) => a.e.ts.localeCompare(b.e.ts) || a.i - b.i);
|
|
327
|
+
const merged = indexed.map(({ e }) => e);
|
|
328
|
+
|
|
329
|
+
// Step 7: Write merged event log FIRST (so crash recovery can re-derive DB state)
|
|
330
|
+
const baseEvents = mainEvents.slice(0, forkPoint + 1);
|
|
331
|
+
const mergedLog = baseEvents.concat(merged);
|
|
332
|
+
const logContent = mergedLog.map((e) => JSON.stringify(e)).join("\n") + (mergedLog.length > 0 ? "\n" : "");
|
|
333
|
+
mkdirSync(join(mainBasePath, ".gsd"), { recursive: true });
|
|
334
|
+
atomicWriteSync(join(mainBasePath, ".gsd", "event-log.jsonl"), logContent);
|
|
335
|
+
|
|
336
|
+
// Step 8: Replay into DB (wrapped in a transaction by replayEvents)
|
|
337
|
+
openDatabase(join(mainBasePath, ".gsd", "gsd.db"));
|
|
338
|
+
replayEvents(merged);
|
|
339
|
+
|
|
340
|
+
// Step 9: Write manifest
|
|
341
|
+
try {
|
|
342
|
+
writeManifest(mainBasePath);
|
|
343
|
+
} catch (err) {
|
|
344
|
+
process.stderr.write(
|
|
345
|
+
`[gsd] reconcile: manifest write failed (non-fatal): ${(err as Error).message}\n`,
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return { autoMerged: merged.length, conflicts: [] };
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// ─── Conflict Resolution (D-06) ─────────────────────────────────────────────
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Parse CONFLICTS.md and return structured ConflictEntry[].
|
|
356
|
+
* Returns empty array when CONFLICTS.md does not exist.
|
|
357
|
+
*
|
|
358
|
+
* Parses the format written by writeConflictsFile:
|
|
359
|
+
* ## Conflict N: {entityType} {entityId}
|
|
360
|
+
* **Main side events:**
|
|
361
|
+
* - {cmd} at {ts} (hash: {hash})
|
|
362
|
+
* params: {JSON}
|
|
363
|
+
* **Worktree side events:**
|
|
364
|
+
* - {cmd} at {ts} (hash: {hash})
|
|
365
|
+
* params: {JSON}
|
|
366
|
+
*/
|
|
367
|
+
export function listConflicts(basePath: string): ConflictEntry[] {
|
|
368
|
+
const conflictsPath = join(basePath, ".gsd", "CONFLICTS.md");
|
|
369
|
+
if (!existsSync(conflictsPath)) return [];
|
|
370
|
+
|
|
371
|
+
const content = readFileSync(conflictsPath, "utf-8");
|
|
372
|
+
const conflicts: ConflictEntry[] = [];
|
|
373
|
+
|
|
374
|
+
// Split into per-conflict sections on "## Conflict N:" headings
|
|
375
|
+
const sections = content.split(/^## Conflict \d+:/m).slice(1);
|
|
376
|
+
|
|
377
|
+
for (const section of sections) {
|
|
378
|
+
// Extract entity type and id from first line: " {entityType} {entityId}"
|
|
379
|
+
const headingMatch = section.match(/^\s+(\S+)\s+(\S+)/);
|
|
380
|
+
if (!headingMatch) continue;
|
|
381
|
+
const entityType = headingMatch[1]!;
|
|
382
|
+
const entityId = headingMatch[2]!;
|
|
383
|
+
|
|
384
|
+
// Split into main/worktree blocks
|
|
385
|
+
const mainMatch = section.split("**Main side events:**")[1];
|
|
386
|
+
const wtMatch = mainMatch?.split("**Worktree side events:**");
|
|
387
|
+
|
|
388
|
+
const mainBlock = wtMatch?.[0] ?? "";
|
|
389
|
+
const wtBlock = wtMatch?.[1] ?? "";
|
|
390
|
+
|
|
391
|
+
const mainSideEvents = parseEventBlock(mainBlock);
|
|
392
|
+
const worktreeSideEvents = parseEventBlock(wtBlock);
|
|
393
|
+
|
|
394
|
+
conflicts.push({ entityType, entityId, mainSideEvents, worktreeSideEvents });
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return conflicts;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Parse a block of event lines from CONFLICTS.md into WorkflowEvent[].
|
|
402
|
+
* Each event spans two lines:
|
|
403
|
+
* - {cmd} at {ts} (hash: {hash})
|
|
404
|
+
* params: {JSON}
|
|
405
|
+
*/
|
|
406
|
+
function parseEventBlock(block: string): WorkflowEvent[] {
|
|
407
|
+
const events: WorkflowEvent[] = [];
|
|
408
|
+
// Find lines starting with "- " (event lines)
|
|
409
|
+
const lines = block.split("\n");
|
|
410
|
+
let i = 0;
|
|
411
|
+
while (i < lines.length) {
|
|
412
|
+
const line = lines[i]!.trim();
|
|
413
|
+
if (line.startsWith("- ")) {
|
|
414
|
+
// Parse: - {cmd} at {ts} (hash: {hash})
|
|
415
|
+
const eventMatch = line.match(/^-\s+(\S+)\s+at\s+(\S+)\s+\(hash:\s+(\S+)\)$/);
|
|
416
|
+
if (eventMatch) {
|
|
417
|
+
const cmd = eventMatch[1]!;
|
|
418
|
+
const ts = eventMatch[2]!;
|
|
419
|
+
const hash = eventMatch[3]!;
|
|
420
|
+
|
|
421
|
+
// Next line: " params: {JSON}"
|
|
422
|
+
let params: Record<string, unknown> = {};
|
|
423
|
+
const nextLine = lines[i + 1];
|
|
424
|
+
if (nextLine) {
|
|
425
|
+
const paramsMatch = nextLine.trim().match(/^params:\s+(.+)$/);
|
|
426
|
+
if (paramsMatch) {
|
|
427
|
+
try {
|
|
428
|
+
params = JSON.parse(paramsMatch[1]!) as Record<string, unknown>;
|
|
429
|
+
} catch {
|
|
430
|
+
// Keep empty params on parse error
|
|
431
|
+
}
|
|
432
|
+
i++; // consume params line
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
events.push({ cmd, params, ts, hash, actor: "agent", session_id: getSessionId() });
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
i++;
|
|
440
|
+
}
|
|
441
|
+
return events;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Resolve a single conflict by picking one side's events.
|
|
446
|
+
* Replays the picked events through the DB helpers, appends them to the event log,
|
|
447
|
+
* and updates or removes CONFLICTS.md.
|
|
448
|
+
*
|
|
449
|
+
* When the last conflict is resolved, non-conflicting events from both sides
|
|
450
|
+
* are also replayed (they were blocked by the all-or-nothing D-04 rule).
|
|
451
|
+
*/
|
|
452
|
+
export function resolveConflict(
|
|
453
|
+
basePath: string,
|
|
454
|
+
worktreeBasePath: string,
|
|
455
|
+
entityKey: string, // e.g. "task:T01"
|
|
456
|
+
pick: "main" | "worktree",
|
|
457
|
+
): void {
|
|
458
|
+
const conflicts = listConflicts(basePath);
|
|
459
|
+
const colonIdx = entityKey.indexOf(":");
|
|
460
|
+
const entityType = entityKey.slice(0, colonIdx);
|
|
461
|
+
const entityId = entityKey.slice(colonIdx + 1);
|
|
462
|
+
|
|
463
|
+
const idx = conflicts.findIndex((c) => c.entityType === entityType && c.entityId === entityId);
|
|
464
|
+
if (idx === -1) throw new Error(`No conflict found for entity ${entityKey}`);
|
|
465
|
+
|
|
466
|
+
const conflict = conflicts[idx]!;
|
|
467
|
+
const eventsToReplay = pick === "main" ? conflict.mainSideEvents : conflict.worktreeSideEvents;
|
|
468
|
+
|
|
469
|
+
// Replay resolved events through the DB (updates DB state)
|
|
470
|
+
openDatabase(join(basePath, ".gsd", "gsd.db"));
|
|
471
|
+
replayEvents(eventsToReplay);
|
|
472
|
+
|
|
473
|
+
// Append resolved events to the event log
|
|
474
|
+
for (const event of eventsToReplay) {
|
|
475
|
+
appendEvent(basePath, { cmd: event.cmd, params: event.params, ts: event.ts, actor: event.actor });
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// Remove resolved conflict from list
|
|
479
|
+
conflicts.splice(idx, 1);
|
|
480
|
+
|
|
481
|
+
if (conflicts.length === 0) {
|
|
482
|
+
// All conflicts resolved — remove CONFLICTS.md and re-run reconciliation
|
|
483
|
+
// to pick up non-conflicting events that were blocked by D-04 all-or-nothing.
|
|
484
|
+
removeConflictsFile(basePath);
|
|
485
|
+
if (worktreeBasePath) {
|
|
486
|
+
reconcileWorktreeLogs(basePath, worktreeBasePath);
|
|
487
|
+
}
|
|
488
|
+
} else {
|
|
489
|
+
// Re-write CONFLICTS.md with remaining conflicts
|
|
490
|
+
writeConflictsFile(basePath, conflicts, worktreeBasePath);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Remove CONFLICTS.md — called when all conflicts are resolved.
|
|
496
|
+
* No-op if CONFLICTS.md does not exist.
|
|
497
|
+
*/
|
|
498
|
+
export function removeConflictsFile(basePath: string): void {
|
|
499
|
+
const conflictsPath = join(basePath, ".gsd", "CONFLICTS.md");
|
|
500
|
+
if (existsSync(conflictsPath)) {
|
|
501
|
+
unlinkSync(conflictsPath);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
@@ -19,6 +19,7 @@ import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync } from "node:
|
|
|
19
19
|
import { execFileSync } from "node:child_process";
|
|
20
20
|
import { join, resolve, sep } from "node:path";
|
|
21
21
|
import { GSDError, GSD_PARSE_ERROR, GSD_STALE_STATE, GSD_LOCK_HELD, GSD_GIT_ERROR, GSD_MERGE_CONFLICT } from "./errors.js";
|
|
22
|
+
import { logWarning } from "./workflow-logger.js";
|
|
22
23
|
import {
|
|
23
24
|
nativeBranchDelete,
|
|
24
25
|
nativeBranchExists,
|
|
@@ -136,9 +137,7 @@ export function createWorktree(basePath: string, name: string, opts: { branch?:
|
|
|
136
137
|
// worktree can be created in its place.
|
|
137
138
|
const gitFilePath = join(wtPath, ".git");
|
|
138
139
|
if (!existsSync(gitFilePath)) {
|
|
139
|
-
|
|
140
|
-
`[GSD] Removing stale worktree directory (no .git file): ${wtPath}`,
|
|
141
|
-
);
|
|
140
|
+
logWarning("reconcile", `Removing stale worktree directory (no .git file): ${wtPath}`, { worktree: name });
|
|
142
141
|
rmSync(wtPath, { recursive: true, force: true });
|
|
143
142
|
} else {
|
|
144
143
|
throw new GSDError(GSD_STALE_STATE, `Worktree "${name}" already exists at ${wtPath}`);
|
|
@@ -345,14 +344,10 @@ export function removeWorktree(
|
|
|
345
344
|
"git", ["stash", "push", "-m", "gsd: auto-stash submodule changes before worktree teardown"],
|
|
346
345
|
{ cwd: resolvedWtPath, stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8" },
|
|
347
346
|
);
|
|
348
|
-
|
|
349
|
-
`[GSD] WARNING: Stashed uncommitted submodule changes in ${resolvedWtPath} before worktree teardown.\n`,
|
|
350
|
-
);
|
|
347
|
+
logWarning("reconcile", `Stashed uncommitted submodule changes before worktree teardown`, { worktree: name, path: resolvedWtPath });
|
|
351
348
|
} catch {
|
|
352
349
|
// Stash failed — warn the user that submodule changes may be lost
|
|
353
|
-
|
|
354
|
-
`[GSD] WARNING: Submodule changes detected in ${resolvedWtPath} — stash failed, changes may be lost during force removal.\n`,
|
|
355
|
-
);
|
|
350
|
+
logWarning("reconcile", `Submodule changes detected — stash failed, changes may be lost during force removal`, { worktree: name, path: resolvedWtPath });
|
|
356
351
|
}
|
|
357
352
|
}
|
|
358
353
|
} catch {
|
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { existsSync, unlinkSync } from "node:fs";
|
|
17
|
+
import { randomUUID } from "node:crypto";
|
|
17
18
|
import { join } from "node:path";
|
|
18
19
|
import type { AutoSession } from "./auto/session.js";
|
|
19
20
|
import { debugLog } from "./debug-logger.js";
|
|
20
21
|
import { MergeConflictError } from "./git-service.js";
|
|
22
|
+
import { emitJournalEvent } from "./journal.js";
|
|
21
23
|
|
|
22
24
|
// ─── Dependency Interface ──────────────────────────────────────────────────
|
|
23
25
|
|
|
@@ -155,6 +157,13 @@ export class WorktreeResolver {
|
|
|
155
157
|
skipped: true,
|
|
156
158
|
reason: "isolation-disabled",
|
|
157
159
|
});
|
|
160
|
+
emitJournalEvent(this.s.originalBasePath || this.s.basePath, {
|
|
161
|
+
ts: new Date().toISOString(),
|
|
162
|
+
flowId: randomUUID(),
|
|
163
|
+
seq: 0,
|
|
164
|
+
eventType: "worktree-skip",
|
|
165
|
+
data: { milestoneId, reason: "isolation-disabled" },
|
|
166
|
+
});
|
|
158
167
|
return;
|
|
159
168
|
}
|
|
160
169
|
|
|
@@ -184,6 +193,13 @@ export class WorktreeResolver {
|
|
|
184
193
|
result: "success",
|
|
185
194
|
wtPath,
|
|
186
195
|
});
|
|
196
|
+
emitJournalEvent(this.s.originalBasePath || this.s.basePath, {
|
|
197
|
+
ts: new Date().toISOString(),
|
|
198
|
+
flowId: randomUUID(),
|
|
199
|
+
seq: 0,
|
|
200
|
+
eventType: "worktree-enter",
|
|
201
|
+
data: { milestoneId, wtPath, created: !existingPath },
|
|
202
|
+
});
|
|
187
203
|
ctx.notify(`Entered worktree for ${milestoneId} at ${wtPath}`, "info");
|
|
188
204
|
} catch (err) {
|
|
189
205
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -193,6 +209,13 @@ export class WorktreeResolver {
|
|
|
193
209
|
result: "error",
|
|
194
210
|
error: msg,
|
|
195
211
|
});
|
|
212
|
+
emitJournalEvent(this.s.originalBasePath || this.s.basePath, {
|
|
213
|
+
ts: new Date().toISOString(),
|
|
214
|
+
flowId: randomUUID(),
|
|
215
|
+
seq: 0,
|
|
216
|
+
eventType: "worktree-create-failed",
|
|
217
|
+
data: { milestoneId, error: msg, fallback: "project-root" },
|
|
218
|
+
});
|
|
196
219
|
ctx.notify(
|
|
197
220
|
`Auto-worktree creation for ${milestoneId} failed: ${msg}. Continuing in project root.`,
|
|
198
221
|
"warning",
|
|
@@ -288,6 +311,13 @@ export class WorktreeResolver {
|
|
|
288
311
|
mode,
|
|
289
312
|
basePath: this.s.basePath,
|
|
290
313
|
});
|
|
314
|
+
emitJournalEvent(this.s.originalBasePath || this.s.basePath, {
|
|
315
|
+
ts: new Date().toISOString(),
|
|
316
|
+
flowId: randomUUID(),
|
|
317
|
+
seq: 0,
|
|
318
|
+
eventType: "worktree-merge-start",
|
|
319
|
+
data: { milestoneId, mode },
|
|
320
|
+
});
|
|
291
321
|
|
|
292
322
|
if (mode === "none") {
|
|
293
323
|
debugLog("WorktreeResolver", {
|
|
@@ -408,6 +438,13 @@ export class WorktreeResolver {
|
|
|
408
438
|
error: msg,
|
|
409
439
|
fallback: "chdir-to-project-root",
|
|
410
440
|
});
|
|
441
|
+
emitJournalEvent(this.s.originalBasePath || this.s.basePath, {
|
|
442
|
+
ts: new Date().toISOString(),
|
|
443
|
+
flowId: randomUUID(),
|
|
444
|
+
seq: 0,
|
|
445
|
+
eventType: "worktree-merge-failed",
|
|
446
|
+
data: { milestoneId, error: msg },
|
|
447
|
+
});
|
|
411
448
|
// Surface a clear, actionable error. The worktree and milestone branch are
|
|
412
449
|
// intentionally preserved — nothing has been deleted. The user can retry
|
|
413
450
|
// /gsd dispatch complete-milestone or merge manually once the underlying issue is fixed
|