gsd-pi 2.80.0-dev.2848d9009 → 2.80.0-dev.3065f7bfa
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/README.md +4 -2
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/extensions/gsd/auto/loop.js +32 -1
- package/dist/resources/extensions/gsd/auto/phases.js +178 -108
- package/dist/resources/extensions/gsd/auto/resolve.js +17 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +20 -30
- package/dist/resources/extensions/gsd/auto/session.js +8 -0
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +5 -32
- package/dist/resources/extensions/gsd/auto-dispatch.js +16 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +17 -4
- package/dist/resources/extensions/gsd/auto-prompts.js +103 -16
- package/dist/resources/extensions/gsd/auto-recovery.js +43 -1
- package/dist/resources/extensions/gsd/auto-start.js +197 -6
- package/dist/resources/extensions/gsd/auto-supervisor.js +8 -1
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +2 -2
- package/dist/resources/extensions/gsd/auto-worktree.js +111 -1
- package/dist/resources/extensions/gsd/auto.js +86 -26
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +42 -2
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +49 -36
- package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +15 -5
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +33 -20
- package/dist/resources/extensions/gsd/bootstrap/journal-tools.js +7 -1
- package/dist/resources/extensions/gsd/bootstrap/memory-tools.js +9 -3
- package/dist/resources/extensions/gsd/bootstrap/query-tools.js +8 -2
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +259 -28
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +82 -23
- package/dist/resources/extensions/gsd/clean-root-preflight.js +24 -6
- package/dist/resources/extensions/gsd/commands-handlers.js +23 -9
- package/dist/resources/extensions/gsd/context-budget.js +37 -2
- package/dist/resources/extensions/gsd/crash-recovery.js +56 -10
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +39 -0
- package/dist/resources/extensions/gsd/db-base-schema.js +4 -2
- package/dist/resources/extensions/gsd/db-migration-steps.js +6 -0
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +2 -0
- package/dist/resources/extensions/gsd/git-service.js +36 -4
- package/dist/resources/extensions/gsd/gsd-db.js +46 -13
- package/dist/resources/extensions/gsd/guided-flow.js +99 -38
- package/dist/resources/extensions/gsd/memory-store.js +69 -12
- package/dist/resources/extensions/gsd/migrate/command.js +40 -1
- package/dist/resources/extensions/gsd/migration-auto-check.js +87 -0
- package/dist/resources/extensions/gsd/native-git-bridge.js +32 -8
- package/dist/resources/extensions/gsd/orphan-stash-audit.js +101 -0
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +13 -3
- package/dist/resources/extensions/gsd/planning-path-scope.js +26 -0
- package/dist/resources/extensions/gsd/pre-execution-checks.js +22 -0
- package/dist/resources/extensions/gsd/prompt-loader.js +28 -2
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +16 -13
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/quick-task.md +1 -5
- package/dist/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
- package/dist/resources/extensions/gsd/quick.js +34 -2
- package/dist/resources/extensions/gsd/tools/context-mode-tool-result.js +15 -0
- package/dist/resources/extensions/gsd/tools/exec-search-tool.js +5 -0
- package/dist/resources/extensions/gsd/tools/exec-tool.js +3 -15
- package/dist/resources/extensions/gsd/tools/memory-tools.js +1 -0
- package/dist/resources/extensions/gsd/tools/plan-slice.js +9 -0
- package/dist/resources/extensions/gsd/tools/plan-task.js +9 -0
- package/dist/resources/extensions/gsd/tools/resume-tool.js +5 -0
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +1 -1
- package/dist/resources/extensions/gsd/unit-context-composer.js +12 -3
- package/dist/resources/extensions/gsd/unit-runtime.js +22 -0
- package/dist/resources/extensions/gsd/workflow-protocol.js +131 -0
- package/dist/resources/extensions/gsd/worktree-resolver.js +68 -21
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +15 -15
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- 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.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- 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 +1 -1
- 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/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- 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 +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +15 -15
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/package.json +3 -3
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +22 -17
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/src/workflow-tools.test.ts +75 -2
- package/packages/mcp-server/src/workflow-tools.ts +30 -16
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/native/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +4 -1
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +5 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +2 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/dist/index.d.ts +1 -0
- package/packages/pi-agent-core/dist/index.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/index.js +2 -0
- package/packages/pi-agent-core/dist/index.js.map +1 -1
- package/packages/pi-agent-core/dist/token-audit.d.ts +47 -0
- package/packages/pi-agent-core/dist/token-audit.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/token-audit.js +221 -0
- package/packages/pi-agent-core/dist/token-audit.js.map +1 -0
- package/packages/pi-agent-core/dist/types.d.ts +9 -0
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/types.js.map +1 -1
- package/packages/pi-agent-core/src/agent-loop.test.ts +128 -0
- package/packages/pi-agent-core/src/agent-loop.ts +4 -1
- package/packages/pi-agent-core/src/agent.ts +8 -0
- package/packages/pi-agent-core/src/index.ts +2 -0
- package/packages/pi-agent-core/src/token-audit.test.ts +189 -0
- package/packages/pi-agent-core/src/token-audit.ts +287 -0
- package/packages/pi-agent-core/src/types.ts +14 -0
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js +32 -0
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js +18 -0
- package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +12 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +44 -7
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +3 -1
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +11 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js +9 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js +103 -0
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts +15 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.js +66 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.js +24 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +8 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +3 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +6 -6
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +5 -3
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +39 -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/hooks-runner.test.js +2 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js +46 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts +10 -2
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +74 -2
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +20 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +25 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/skill-tool.test.js +22 -0
- package/packages/pi-coding-agent/dist/core/skill-tool.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +6 -7
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +2 -3
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +3 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +13 -5
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js +53 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +3 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js +10 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js +3 -2
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +36 -0
- package/packages/pi-coding-agent/src/core/agent-session-tool-refresh.test.ts +25 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +48 -7
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +3 -1
- package/packages/pi-coding-agent/src/core/compaction/compaction.ts +18 -0
- package/packages/pi-coding-agent/src/core/compaction-threshold.test.ts +121 -0
- package/packages/pi-coding-agent/src/core/db-snapshot.test.ts +32 -0
- package/packages/pi-coding-agent/src/core/db-snapshot.ts +66 -0
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +10 -0
- package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +5 -3
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +8 -5
- package/packages/pi-coding-agent/src/core/extensions/types.ts +42 -1
- package/packages/pi-coding-agent/src/core/hooks-runner.test.ts +2 -0
- package/packages/pi-coding-agent/src/core/sdk-tool-filter.test.ts +60 -0
- package/packages/pi-coding-agent/src/core/sdk.ts +85 -3
- package/packages/pi-coding-agent/src/core/settings-manager.ts +39 -1
- package/packages/pi-coding-agent/src/core/skill-tool.test.ts +28 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +8 -10
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +4 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +56 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +22 -7
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +3 -0
- package/packages/pi-coding-agent/src/resources/extensions/memory/storage-safety-guard.test.ts +14 -0
- package/packages/pi-coding-agent/src/resources/extensions/memory/storage.ts +3 -2
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +18 -8
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/src/tui.ts +20 -8
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/src/resources/extensions/gsd/auto/loop-deps.ts +2 -2
- package/src/resources/extensions/gsd/auto/loop.ts +50 -8
- package/src/resources/extensions/gsd/auto/phases.ts +251 -172
- package/src/resources/extensions/gsd/auto/resolve.ts +23 -1
- package/src/resources/extensions/gsd/auto/run-unit.ts +25 -30
- package/src/resources/extensions/gsd/auto/session.ts +8 -0
- package/src/resources/extensions/gsd/auto-direct-dispatch.ts +8 -34
- package/src/resources/extensions/gsd/auto-dispatch.ts +16 -0
- package/src/resources/extensions/gsd/auto-post-unit.ts +18 -4
- package/src/resources/extensions/gsd/auto-prompts.ts +112 -15
- package/src/resources/extensions/gsd/auto-recovery.ts +54 -0
- package/src/resources/extensions/gsd/auto-start.ts +230 -9
- package/src/resources/extensions/gsd/auto-supervisor.ts +7 -0
- package/src/resources/extensions/gsd/auto-timeout-recovery.ts +2 -2
- package/src/resources/extensions/gsd/auto-worktree.ts +123 -0
- package/src/resources/extensions/gsd/auto.ts +98 -21
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +49 -1
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +50 -36
- package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +16 -5
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +34 -19
- package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +8 -1
- package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +10 -3
- package/src/resources/extensions/gsd/bootstrap/query-tools.ts +9 -2
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +305 -28
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +90 -22
- package/src/resources/extensions/gsd/clean-root-preflight.ts +32 -7
- package/src/resources/extensions/gsd/commands-handlers.ts +34 -15
- package/src/resources/extensions/gsd/context-budget.ts +44 -2
- package/src/resources/extensions/gsd/crash-recovery.ts +67 -10
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +41 -0
- package/src/resources/extensions/gsd/db-base-schema.ts +4 -2
- package/src/resources/extensions/gsd/db-migration-steps.ts +8 -0
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +3 -0
- package/src/resources/extensions/gsd/git-service.ts +46 -8
- package/src/resources/extensions/gsd/gsd-db.ts +50 -13
- package/src/resources/extensions/gsd/guided-flow.ts +123 -45
- package/src/resources/extensions/gsd/memory-store.ts +77 -12
- package/src/resources/extensions/gsd/migrate/command.ts +47 -1
- package/src/resources/extensions/gsd/migration-auto-check.ts +129 -0
- package/src/resources/extensions/gsd/native-git-bridge.ts +39 -6
- package/src/resources/extensions/gsd/orphan-stash-audit.ts +117 -0
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +13 -3
- package/src/resources/extensions/gsd/planning-path-scope.ts +35 -0
- package/src/resources/extensions/gsd/pre-execution-checks.ts +23 -0
- package/src/resources/extensions/gsd/preferences-types.ts +1 -1
- package/src/resources/extensions/gsd/prompt-loader.ts +27 -2
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +16 -13
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/quick-task.md +1 -5
- package/src/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
- package/src/resources/extensions/gsd/quick.ts +37 -2
- package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +417 -10
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +56 -13
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +14 -1
- package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +168 -6
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +15 -6
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +14 -1
- package/src/resources/extensions/gsd/tests/complete-milestone-excerpt.test.ts +31 -0
- package/src/resources/extensions/gsd/tests/complete-slice-composer.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/context-budget.test.ts +10 -1
- package/src/resources/extensions/gsd/tests/context-store.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/crash-handler-secondary.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +22 -0
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +5 -1
- package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +313 -0
- package/src/resources/extensions/gsd/tests/exec-history.test.ts +15 -0
- package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +65 -0
- package/src/resources/extensions/gsd/tests/execute-task-rendering.test.ts +5 -2
- package/src/resources/extensions/gsd/tests/fast-forward-reused-milestone-branch.test.ts +219 -0
- package/src/resources/extensions/gsd/tests/finalize-survivor-branch.test.ts +132 -0
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +6 -3
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +239 -1
- package/src/resources/extensions/gsd/tests/journal-query-tool.test.ts +32 -0
- package/src/resources/extensions/gsd/tests/knowledge.test.ts +47 -0
- package/src/resources/extensions/gsd/tests/memory-decay-factor.test.ts +90 -0
- package/src/resources/extensions/gsd/tests/merge-conflict-stops-loop.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +48 -0
- package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/milestone-merge-stash-restore.test.ts +242 -0
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +34 -2
- package/src/resources/extensions/gsd/tests/originalbase-path-comparison.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/orphan-merge-bootstrap.test.ts +133 -0
- package/src/resources/extensions/gsd/tests/orphan-stash-audit.test.ts +201 -0
- package/src/resources/extensions/gsd/tests/parallel-orchestrator-fast-forward.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/plan-slice.test.ts +50 -0
- package/src/resources/extensions/gsd/tests/plan-task.test.ts +21 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +45 -5
- package/src/resources/extensions/gsd/tests/prompt-duplication-cuts.test.ts +230 -0
- package/src/resources/extensions/gsd/tests/prompt-path-audit.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/query-tools-db-open.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/quick-external-gsd.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +38 -17
- package/src/resources/extensions/gsd/tests/schema-v27-v28-sequence.test.ts +156 -0
- package/src/resources/extensions/gsd/tests/select-resumable-milestone.test.ts +96 -0
- package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +106 -0
- package/src/resources/extensions/gsd/tests/signal-handlers.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +49 -1
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/status-db-open.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/system-context-memory.test.ts +112 -0
- package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +7 -9
- package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +291 -0
- package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +136 -4
- package/src/resources/extensions/gsd/tests/unit-dispatches.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +37 -0
- package/src/resources/extensions/gsd/tests/unstructured-continue-context-injection.test.ts +5 -4
- package/src/resources/extensions/gsd/tests/workflow-protocol-excerpt.test.ts +99 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/worktree-path-injection.test.ts +22 -19
- package/src/resources/extensions/gsd/tests/worktree-project-root-degrade.test.ts +66 -0
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +167 -4
- package/src/resources/extensions/gsd/tools/context-mode-tool-result.ts +25 -0
- package/src/resources/extensions/gsd/tools/exec-search-tool.ts +7 -7
- package/src/resources/extensions/gsd/tools/exec-tool.ts +4 -23
- package/src/resources/extensions/gsd/tools/memory-tools.ts +1 -0
- package/src/resources/extensions/gsd/tools/plan-slice.ts +13 -0
- package/src/resources/extensions/gsd/tools/plan-task.ts +10 -0
- package/src/resources/extensions/gsd/tools/resume-tool.ts +7 -7
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +1 -1
- package/src/resources/extensions/gsd/unit-context-composer.ts +19 -4
- package/src/resources/extensions/gsd/unit-runtime.ts +25 -0
- package/src/resources/extensions/gsd/workflow-protocol.ts +160 -0
- package/src/resources/extensions/gsd/worktree-resolver.ts +85 -19
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +0 -97
- /package/dist/web/standalone/.next/static/{vaQ47E8aNlbbNEDoeME6G → O2WvnXROue6l7nAp_4dhC}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{vaQ47E8aNlbbNEDoeME6G → O2WvnXROue6l7nAp_4dhC}/_ssgManifest.js +0 -0
|
@@ -8,6 +8,7 @@ import { renderAllProjections } from "../workflow-projections.js";
|
|
|
8
8
|
import { writeManifest } from "../workflow-manifest.js";
|
|
9
9
|
import { appendEvent } from "../workflow-events.js";
|
|
10
10
|
import { logWarning } from "../workflow-logger.js";
|
|
11
|
+
import { validatePlanningPathScope } from "../planning-path-scope.js";
|
|
11
12
|
function validateParams(params) {
|
|
12
13
|
if (!isNonEmptyString(params?.milestoneId))
|
|
13
14
|
throw new Error("milestoneId is required");
|
|
@@ -41,6 +42,14 @@ export async function handlePlanTask(rawParams, basePath) {
|
|
|
41
42
|
catch (err) {
|
|
42
43
|
return { error: `validation failed: ${err.message}` };
|
|
43
44
|
}
|
|
45
|
+
const pathScopeError = validatePlanningPathScope(basePath, [
|
|
46
|
+
{ field: "files", values: params.files },
|
|
47
|
+
{ field: "inputs", values: params.inputs },
|
|
48
|
+
{ field: "expectedOutput", values: params.expectedOutput },
|
|
49
|
+
]);
|
|
50
|
+
if (pathScopeError) {
|
|
51
|
+
return { error: `validation failed: ${pathScopeError}` };
|
|
52
|
+
}
|
|
44
53
|
// ── Guards + DB writes inside a single transaction (prevents TOCTOU) ───
|
|
45
54
|
// Guards must be inside the transaction so the state they check cannot
|
|
46
55
|
// change between the read and the write (#2723).
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
// agents can re-orient after compaction or session resume without
|
|
3
3
|
// re-deriving project memory state.
|
|
4
4
|
import { readCompactionSnapshot } from "../compaction-snapshot.js";
|
|
5
|
+
import { isContextModeEnabled } from "../preferences-types.js";
|
|
6
|
+
import { contextModeDisabledResult } from "./context-mode-tool-result.js";
|
|
5
7
|
export function executeResume(_params, opts) {
|
|
8
|
+
if (!isContextModeEnabled(opts.preferences)) {
|
|
9
|
+
return contextModeDisabledResult("gsd_resume");
|
|
10
|
+
}
|
|
6
11
|
const snapshot = readCompactionSnapshot(opts.baseDir);
|
|
7
12
|
if (snapshot == null) {
|
|
8
13
|
return {
|
|
@@ -680,7 +680,7 @@ export async function executeMilestoneStatus(params, basePath = process.cwd()) {
|
|
|
680
680
|
};
|
|
681
681
|
return {
|
|
682
682
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
683
|
-
details: { operation: "milestone_status",
|
|
683
|
+
details: { operation: "milestone_status", ...result },
|
|
684
684
|
};
|
|
685
685
|
});
|
|
686
686
|
}
|
|
@@ -80,7 +80,15 @@ const CONTEXT_MODE_LANE_LABELS = {
|
|
|
80
80
|
orchestration: "orchestration",
|
|
81
81
|
docs: "documentation",
|
|
82
82
|
};
|
|
83
|
-
const
|
|
83
|
+
const CONTEXT_MODE_GUIDANCE_BY_LANE = {
|
|
84
|
+
interview: "Use `gsd_resume` to restore prior discussion, `gsd_exec` for noisy discovery, and `gsd_exec_search` before repeating scans.",
|
|
85
|
+
research: "Use `gsd_exec` for noisy research scans, `gsd_exec_search` before reruns, and `gsd_resume` to restore prior findings.",
|
|
86
|
+
planning: "Use `gsd_resume` for planning continuity, `gsd_exec` for noisy checks, and `gsd_exec_search` before rerunning diagnostics.",
|
|
87
|
+
execution: "Use `gsd_exec` for builds, tests, and diagnostics, `gsd_exec_search` before reruns, and `gsd_resume` after compaction or resume.",
|
|
88
|
+
verification: "Use `gsd_exec` for verification commands, `gsd_exec_search` to reuse prior evidence, and `gsd_resume` after compaction or resume.",
|
|
89
|
+
orchestration: "Use `gsd_resume` before resuming orchestration, `gsd_exec_search` to reuse prior runs, and `gsd_exec` for noisy coordination checks.",
|
|
90
|
+
docs: "Use `gsd_resume` for prior context, `gsd_exec_search` for saved evidence, and `gsd_exec` for noisy doc validation commands.",
|
|
91
|
+
};
|
|
84
92
|
/**
|
|
85
93
|
* Render the Context Mode instruction lane for a unit type. Unknown unit
|
|
86
94
|
* types, disabled config, and explicit `contextMode: "none"` all omit the
|
|
@@ -93,14 +101,15 @@ export function composeContextModeInstructions(unitType, opts) {
|
|
|
93
101
|
if (!manifest || manifest.contextMode === "none")
|
|
94
102
|
return "";
|
|
95
103
|
const lane = CONTEXT_MODE_LANE_LABELS[manifest.contextMode];
|
|
104
|
+
const guidance = CONTEXT_MODE_GUIDANCE_BY_LANE[manifest.contextMode];
|
|
96
105
|
if (opts.renderMode === "nested") {
|
|
97
|
-
return `Context Mode (${lane} lane): ${
|
|
106
|
+
return `Context Mode (${lane} lane): ${guidance}`;
|
|
98
107
|
}
|
|
99
108
|
return [
|
|
100
109
|
"## Context Mode",
|
|
101
110
|
"",
|
|
102
111
|
`Lane: **${lane} lane**.`,
|
|
103
|
-
|
|
112
|
+
guidance,
|
|
104
113
|
].join("\n");
|
|
105
114
|
}
|
|
106
115
|
const SECTION_SEPARATOR = "\n\n---\n\n";
|
|
@@ -4,6 +4,8 @@ import { atomicWriteSync } from "./atomic-write.js";
|
|
|
4
4
|
import { gsdRoot, relSliceFile, relTaskFile, resolveSliceFile, resolveTaskFile, } from "./paths.js";
|
|
5
5
|
import { loadFile, parseTaskPlanMustHaves, countMustHavesMentionedInSummary } from "./files.js";
|
|
6
6
|
import { parseUnitId } from "./unit-id.js";
|
|
7
|
+
import { getTask, isDbAvailable, refreshOpenDatabaseFromDisk } from "./gsd-db.js";
|
|
8
|
+
import { isClosedStatus } from "./status-guards.js";
|
|
7
9
|
// Per-record advisory lock — prevents read-modify-write races between
|
|
8
10
|
// concurrent writers updating disjoint fields of the same runtime record.
|
|
9
11
|
// Within a single Node process this is moot (writeUnitRuntimeRecord is sync),
|
|
@@ -67,6 +69,17 @@ function withRecordLock(recordPath, fn) {
|
|
|
67
69
|
catch { /* best-effort */ }
|
|
68
70
|
}
|
|
69
71
|
}
|
|
72
|
+
export const IN_FLIGHT_RUNTIME_PHASES = new Set([
|
|
73
|
+
"dispatched",
|
|
74
|
+
"wrapup-warning-sent",
|
|
75
|
+
"timeout",
|
|
76
|
+
"finalize-timeout",
|
|
77
|
+
"crashed",
|
|
78
|
+
"paused",
|
|
79
|
+
]);
|
|
80
|
+
export function isInFlightRuntimePhase(phase) {
|
|
81
|
+
return IN_FLIGHT_RUNTIME_PHASES.has(phase);
|
|
82
|
+
}
|
|
70
83
|
function runtimeDir(basePath) {
|
|
71
84
|
return join(gsdRoot(basePath), "runtime", "units");
|
|
72
85
|
}
|
|
@@ -154,6 +167,12 @@ export async function inspectExecuteTaskDurability(basePath, unitId) {
|
|
|
154
167
|
const escapedTid = tid.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
155
168
|
const taskChecked = !!planContent && new RegExp(`^- \\[[xX]\\] \\*\\*${escapedTid}:`, "m").test(planContent);
|
|
156
169
|
const nextActionAdvanced = !new RegExp(`Execute ${tid}\\b`).test(stateContent);
|
|
170
|
+
let dbComplete = false;
|
|
171
|
+
if (isDbAvailable()) {
|
|
172
|
+
refreshOpenDatabaseFromDisk();
|
|
173
|
+
const task = getTask(mid, sid, tid);
|
|
174
|
+
dbComplete = !!task && isClosedStatus(task.status);
|
|
175
|
+
}
|
|
157
176
|
// Must-have coverage: load task plan and count mentions in summary
|
|
158
177
|
let mustHaveCount = 0;
|
|
159
178
|
let mustHavesMentionedInSummary = 0;
|
|
@@ -177,11 +196,14 @@ export async function inspectExecuteTaskDurability(basePath, unitId) {
|
|
|
177
196
|
summaryExists,
|
|
178
197
|
taskChecked,
|
|
179
198
|
nextActionAdvanced,
|
|
199
|
+
dbComplete,
|
|
180
200
|
mustHaveCount,
|
|
181
201
|
mustHavesMentionedInSummary,
|
|
182
202
|
};
|
|
183
203
|
}
|
|
184
204
|
export function formatExecuteTaskRecoveryStatus(status) {
|
|
205
|
+
if (status.dbComplete)
|
|
206
|
+
return "DB task status is closed";
|
|
185
207
|
const missing = [];
|
|
186
208
|
if (!status.summaryExists)
|
|
187
209
|
missing.push(`summary missing (${status.summaryPath})`);
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Project/App: GSD-2
|
|
2
|
+
// File Purpose: Shared capped workflow protocol and doctor-heal prompt payload helpers.
|
|
3
|
+
const DEFAULT_WORKFLOW_PROTOCOL_EXCERPT_CHARS = 4_000;
|
|
4
|
+
const MIN_WORKFLOW_PROTOCOL_EXCERPT_CHARS = 1_000;
|
|
5
|
+
const DEFAULT_DOCTOR_SUMMARY_CHARS = 2_400;
|
|
6
|
+
const DEFAULT_DOCTOR_ISSUE_CHARS = 300;
|
|
7
|
+
const DEFAULT_DOCTOR_MAX_ISSUES = 12;
|
|
8
|
+
const DEFAULT_DOCTOR_ISSUES_CHARS = 4_000;
|
|
9
|
+
export function buildWorkflowProtocolExcerpt(workflow, workflowPath, opts = {}) {
|
|
10
|
+
const limit = opts.maxChars ?? getWorkflowProtocolExcerptLimit();
|
|
11
|
+
const trimmed = workflow.trim();
|
|
12
|
+
const excerpt = buildPrioritizedWorkflowExcerpt(trimmed, limit);
|
|
13
|
+
const truncated = trimmed.length > limit;
|
|
14
|
+
const lines = [
|
|
15
|
+
"## GSD Workflow Protocol Excerpt",
|
|
16
|
+
`Source: \`${workflowPath}\``,
|
|
17
|
+
"",
|
|
18
|
+
excerpt,
|
|
19
|
+
];
|
|
20
|
+
if (truncated) {
|
|
21
|
+
lines.push("", "[Workflow Protocol Truncated]", "The full workflow protocol remains available at the source path above. Read it only if this excerpt lacks a rule required for the dispatched task.");
|
|
22
|
+
}
|
|
23
|
+
return lines.join("\n");
|
|
24
|
+
}
|
|
25
|
+
export function buildWorkflowDispatchContent(opts) {
|
|
26
|
+
return [
|
|
27
|
+
"Read the following GSD workflow protocol excerpt and execute exactly. Use the source path for a full protocol read only if the excerpt lacks a required rule.",
|
|
28
|
+
"",
|
|
29
|
+
buildWorkflowProtocolExcerpt(opts.workflow, opts.workflowPath, { maxChars: opts.maxProtocolChars }),
|
|
30
|
+
"",
|
|
31
|
+
"## Your Task",
|
|
32
|
+
"",
|
|
33
|
+
opts.task.trim(),
|
|
34
|
+
].join("\n");
|
|
35
|
+
}
|
|
36
|
+
export function buildDoctorHealSummary(reportText, opts = {}) {
|
|
37
|
+
const limit = opts.maxChars ?? DEFAULT_DOCTOR_SUMMARY_CHARS;
|
|
38
|
+
const lines = reportText.split(/\r?\n/).map((line) => line.trimEnd());
|
|
39
|
+
const summaryLines = lines.filter((line) => line.length > 0 && (/^#/.test(line) ||
|
|
40
|
+
/^(scope|status|summary|checks?|errors?|warnings?|fixes?|issues?)\b/i.test(line) ||
|
|
41
|
+
/doctor/i.test(line)));
|
|
42
|
+
const selected = summaryLines.length > 0 ? summaryLines : lines.filter((line) => line.trim()).slice(0, 24);
|
|
43
|
+
return capText(selected.join("\n"), limit, "Full doctor report is available in the command output; use the structured issue list below for repairs.");
|
|
44
|
+
}
|
|
45
|
+
export function buildDoctorHealIssuePayload(structuredIssues, opts = {}) {
|
|
46
|
+
const maxIssues = opts.maxIssues ?? DEFAULT_DOCTOR_MAX_ISSUES;
|
|
47
|
+
const maxIssueChars = opts.maxIssueChars ?? DEFAULT_DOCTOR_ISSUE_CHARS;
|
|
48
|
+
const maxChars = opts.maxChars ?? DEFAULT_DOCTOR_ISSUES_CHARS;
|
|
49
|
+
const blocks = splitIssueBlocks(structuredIssues);
|
|
50
|
+
const topBlocks = blocks.slice(0, maxIssues).map((block) => capText(block, maxIssueChars, "Issue details truncated; inspect the relevant artifact before editing."));
|
|
51
|
+
if (blocks.length > maxIssues) {
|
|
52
|
+
topBlocks.push(`[${blocks.length - maxIssues} additional actionable issue(s) omitted from prompt. Re-run /gsd doctor heal after this repair pass.]`);
|
|
53
|
+
}
|
|
54
|
+
return capText(topBlocks.join("\n\n"), maxChars, "Structured issue list truncated; repair top actionable issues first and re-run doctor heal.");
|
|
55
|
+
}
|
|
56
|
+
function getWorkflowProtocolExcerptLimit() {
|
|
57
|
+
const raw = process.env.PI_GSD_WORKFLOW_PROTOCOL_MAX_CHARS;
|
|
58
|
+
if (!raw)
|
|
59
|
+
return DEFAULT_WORKFLOW_PROTOCOL_EXCERPT_CHARS;
|
|
60
|
+
const parsed = Number(raw);
|
|
61
|
+
if (!Number.isFinite(parsed) || parsed < MIN_WORKFLOW_PROTOCOL_EXCERPT_CHARS) {
|
|
62
|
+
return DEFAULT_WORKFLOW_PROTOCOL_EXCERPT_CHARS;
|
|
63
|
+
}
|
|
64
|
+
return Math.floor(parsed);
|
|
65
|
+
}
|
|
66
|
+
function buildPrioritizedWorkflowExcerpt(workflow, limit) {
|
|
67
|
+
if (workflow.length <= limit)
|
|
68
|
+
return workflow;
|
|
69
|
+
const sections = splitMarkdownSections(workflow);
|
|
70
|
+
const wanted = [
|
|
71
|
+
/^# /,
|
|
72
|
+
/^## Quick Start\b/i,
|
|
73
|
+
/^## The Hierarchy\b/i,
|
|
74
|
+
/^## The Phases\b/i,
|
|
75
|
+
/^### Phase 4: Execute\b/i,
|
|
76
|
+
/^### Phase 5: Verify\b/i,
|
|
77
|
+
/^### Observable Truths\b/i,
|
|
78
|
+
/^### Artifacts\b/i,
|
|
79
|
+
/^### Key Links\b/i,
|
|
80
|
+
/^### Phase 6: Summarize\b/i,
|
|
81
|
+
/^### Phase 7: Advance\b/i,
|
|
82
|
+
];
|
|
83
|
+
const selected = [];
|
|
84
|
+
const used = new Set();
|
|
85
|
+
for (const pattern of wanted) {
|
|
86
|
+
const index = sections.findIndex((section, sectionIndex) => !used.has(sectionIndex) && pattern.test(section.heading));
|
|
87
|
+
if (index >= 0) {
|
|
88
|
+
used.add(index);
|
|
89
|
+
selected.push(sections[index].text);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const body = selected.length > 0 ? selected.join("\n\n") : workflow;
|
|
93
|
+
return capText(body, limit, "Workflow protocol excerpt capped; read the source path for omitted details.");
|
|
94
|
+
}
|
|
95
|
+
function splitMarkdownSections(markdown) {
|
|
96
|
+
const lines = markdown.split(/\r?\n/);
|
|
97
|
+
const sections = [];
|
|
98
|
+
let currentHeading = lines[0]?.startsWith("#") ? lines[0] : "# Preamble";
|
|
99
|
+
let current = [];
|
|
100
|
+
for (const line of lines) {
|
|
101
|
+
if (/^#{1,3}\s+/.test(line) && current.length > 0) {
|
|
102
|
+
sections.push({ heading: currentHeading, text: current.join("\n").trim() });
|
|
103
|
+
currentHeading = line;
|
|
104
|
+
current = [line];
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (/^#{1,3}\s+/.test(line))
|
|
108
|
+
currentHeading = line;
|
|
109
|
+
current.push(line);
|
|
110
|
+
}
|
|
111
|
+
if (current.length > 0) {
|
|
112
|
+
sections.push({ heading: currentHeading, text: current.join("\n").trim() });
|
|
113
|
+
}
|
|
114
|
+
return sections.filter((section) => section.text.length > 0);
|
|
115
|
+
}
|
|
116
|
+
function splitIssueBlocks(structuredIssues) {
|
|
117
|
+
const trimmed = structuredIssues.trim();
|
|
118
|
+
if (!trimmed)
|
|
119
|
+
return ["No structured issue details were provided."];
|
|
120
|
+
const split = trimmed.split(/\n(?=(?:#{2,6}\s+|\d+\.\s+|- \*\*|- \[[ x]\]))/i)
|
|
121
|
+
.map((block) => block.trim())
|
|
122
|
+
.filter(Boolean);
|
|
123
|
+
return split.length > 0 ? split : [trimmed];
|
|
124
|
+
}
|
|
125
|
+
function capText(text, limit, notice) {
|
|
126
|
+
if (text.length <= limit)
|
|
127
|
+
return text;
|
|
128
|
+
const suffix = `\n\n[Truncated]\n${notice}`;
|
|
129
|
+
const headBudget = Math.max(0, limit - suffix.length);
|
|
130
|
+
return `${text.slice(0, headBudget).trimEnd()}${suffix}`;
|
|
131
|
+
}
|
|
@@ -22,7 +22,7 @@ import { emitWorktreeCreated, emitWorktreeMerged } from "./worktree-telemetry.js
|
|
|
22
22
|
import { getCollapseCadence, getMilestoneResquash, resquashMilestoneOnMain } from "./slice-cadence.js";
|
|
23
23
|
import { loadEffectiveGSDPreferences } from "./preferences.js";
|
|
24
24
|
import { resolveWorktreeProjectRoot, normalizeWorktreePathForCompare } from "./worktree-root.js";
|
|
25
|
-
import { claimMilestoneLease, releaseMilestoneLease } from "./db/milestone-leases.js";
|
|
25
|
+
import { claimMilestoneLease, refreshMilestoneLease, releaseMilestoneLease } from "./db/milestone-leases.js";
|
|
26
26
|
// ─── Path Comparison Helper ────────────────────────────────────────────────
|
|
27
27
|
/**
|
|
28
28
|
* Compare two paths for physical identity, tolerating trailing slashes,
|
|
@@ -35,6 +35,14 @@ import { claimMilestoneLease, releaseMilestoneLease } from "./db/milestone-lease
|
|
|
35
35
|
function isSamePath(a, b) {
|
|
36
36
|
return normalizeWorktreePathForCompare(a) === normalizeWorktreePathForCompare(b);
|
|
37
37
|
}
|
|
38
|
+
class UserNotifiedError extends Error {
|
|
39
|
+
cause;
|
|
40
|
+
constructor(message, cause) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = "UserNotifiedError";
|
|
43
|
+
this.cause = cause;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
38
46
|
// ─── Path Helpers ──────────────────────────────────────────────────────────
|
|
39
47
|
/**
|
|
40
48
|
* Resolve the project root from session path state.
|
|
@@ -119,24 +127,40 @@ export class WorktreeResolver {
|
|
|
119
127
|
// milestone (re-entry within the same session).
|
|
120
128
|
if (this.s.workerId) {
|
|
121
129
|
if (this.s.currentMilestoneId === milestoneId && this.s.milestoneLeaseToken !== null) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
130
|
+
const refreshed = refreshMilestoneLease(this.s.workerId, milestoneId, this.s.milestoneLeaseToken);
|
|
131
|
+
if (refreshed) {
|
|
132
|
+
debugLog("WorktreeResolver", {
|
|
133
|
+
action: "enterMilestone",
|
|
134
|
+
milestoneId,
|
|
135
|
+
leaseRefreshed: true,
|
|
136
|
+
fencingToken: this.s.milestoneLeaseToken,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
debugLog("WorktreeResolver", {
|
|
141
|
+
action: "enterMilestone",
|
|
142
|
+
milestoneId,
|
|
143
|
+
staleLeaseToken: this.s.milestoneLeaseToken,
|
|
144
|
+
});
|
|
138
145
|
this.s.milestoneLeaseToken = null;
|
|
139
146
|
}
|
|
147
|
+
}
|
|
148
|
+
// If we held a different milestone, release it first so other
|
|
149
|
+
// workers don't have to wait for TTL.
|
|
150
|
+
if (this.s.currentMilestoneId && this.s.currentMilestoneId !== milestoneId && this.s.milestoneLeaseToken !== null) {
|
|
151
|
+
try {
|
|
152
|
+
releaseMilestoneLease(this.s.workerId, this.s.currentMilestoneId, this.s.milestoneLeaseToken);
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
debugLog("WorktreeResolver", {
|
|
156
|
+
action: "enterMilestone",
|
|
157
|
+
milestoneId,
|
|
158
|
+
releasePriorLeaseError: err instanceof Error ? err.message : String(err),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
this.s.milestoneLeaseToken = null;
|
|
162
|
+
}
|
|
163
|
+
if (this.s.milestoneLeaseToken === null) {
|
|
140
164
|
try {
|
|
141
165
|
const claim = claimMilestoneLease(this.s.workerId, milestoneId);
|
|
142
166
|
if (claim.ok) {
|
|
@@ -647,16 +671,35 @@ export class WorktreeResolver {
|
|
|
647
671
|
const currentBranch = this.deps.getCurrentBranch(this.s.basePath);
|
|
648
672
|
const milestoneBranch = this.deps.autoWorktreeBranch(milestoneId);
|
|
649
673
|
if (currentBranch !== milestoneBranch) {
|
|
674
|
+
// #5538-followup: previous behavior was to silently `return false`
|
|
675
|
+
// when HEAD wasn't on the milestone branch — that let the loop
|
|
676
|
+
// advance with the milestone's commits stranded on the branch (the
|
|
677
|
+
// exact failure mode reported in the test12345 repro). Attempt
|
|
678
|
+
// recovery by force-checking-out the milestone branch; if the
|
|
679
|
+
// checkout fails, throw so the caller pauses auto-mode and the user
|
|
680
|
+
// sees the failure instead of a silent merge skip.
|
|
650
681
|
debugLog("WorktreeResolver", {
|
|
651
682
|
action: "mergeAndExit",
|
|
652
683
|
milestoneId,
|
|
653
684
|
mode: "branch",
|
|
654
|
-
|
|
655
|
-
reason: "not-on-milestone-branch",
|
|
685
|
+
recovery: "checkout-milestone-branch",
|
|
656
686
|
currentBranch,
|
|
657
687
|
milestoneBranch,
|
|
658
688
|
});
|
|
659
|
-
|
|
689
|
+
try {
|
|
690
|
+
this.deps.checkoutBranch(this.s.basePath, milestoneBranch);
|
|
691
|
+
}
|
|
692
|
+
catch (checkoutErr) {
|
|
693
|
+
const checkoutMsg = checkoutErr instanceof Error ? checkoutErr.message : String(checkoutErr);
|
|
694
|
+
ctx.notify(`Cannot merge milestone ${milestoneId}: working tree is on ${currentBranch} and checkout to ${milestoneBranch} failed (${checkoutMsg}). Resolve manually and run /gsd auto to resume.`, "error");
|
|
695
|
+
throw new UserNotifiedError(checkoutMsg, checkoutErr);
|
|
696
|
+
}
|
|
697
|
+
const reverify = this.deps.getCurrentBranch(this.s.basePath);
|
|
698
|
+
if (reverify !== milestoneBranch) {
|
|
699
|
+
const reverifyMsg = `branch checkout to ${milestoneBranch} reported success but current branch is ${reverify}`;
|
|
700
|
+
ctx.notify(`Cannot merge milestone ${milestoneId}: ${reverifyMsg}. Resolve manually and run /gsd auto to resume.`, "error");
|
|
701
|
+
throw new UserNotifiedError(reverifyMsg);
|
|
702
|
+
}
|
|
660
703
|
}
|
|
661
704
|
const roadmapPath = this.deps.resolveMilestoneFile(this.s.basePath, milestoneId, "ROADMAP");
|
|
662
705
|
if (!roadmapPath) {
|
|
@@ -697,7 +740,9 @@ export class WorktreeResolver {
|
|
|
697
740
|
result: "error",
|
|
698
741
|
error: msg,
|
|
699
742
|
});
|
|
700
|
-
|
|
743
|
+
if (!(err instanceof UserNotifiedError)) {
|
|
744
|
+
ctx.notify(`Milestone merge failed (branch mode): ${msg}`, "warning");
|
|
745
|
+
}
|
|
701
746
|
// Re-throw all errors so callers can apply their own recovery logic (#4380).
|
|
702
747
|
throw err;
|
|
703
748
|
}
|
|
@@ -720,6 +765,8 @@ export class WorktreeResolver {
|
|
|
720
765
|
this.mergeAndExit(currentMilestoneId, ctx);
|
|
721
766
|
}
|
|
722
767
|
catch (err) {
|
|
768
|
+
if (err instanceof UserNotifiedError)
|
|
769
|
+
throw err;
|
|
723
770
|
// mergeAndExit emits a warning and restores state when it fails during
|
|
724
771
|
// merge/cleanup. But if it throws before recovery runs (e.g., in
|
|
725
772
|
// validateMilestoneId or emitJournalEvent), basePath won't be restored
|