gsd-pi 2.80.0-dev.c5f2443b3 → 2.80.0-dev.d4fc28e6b
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/cli.js +0 -19
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/GSD-WORKFLOW.md +2 -2
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +29 -0
- package/dist/resources/extensions/github-sync/templates.js +39 -8
- package/dist/resources/extensions/gsd/auto/loop.js +119 -18
- package/dist/resources/extensions/gsd/auto/phases.js +212 -135
- package/dist/resources/extensions/gsd/auto/resolve.js +29 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +41 -45
- package/dist/resources/extensions/gsd/auto/session.js +8 -0
- package/dist/resources/extensions/gsd/auto/workflow-dispatch-claim.js +33 -1
- package/dist/resources/extensions/gsd/auto/workflow-worker-heartbeat.js +9 -1
- package/dist/resources/extensions/gsd/auto-dashboard.js +51 -15
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +5 -32
- package/dist/resources/extensions/gsd/auto-dispatch.js +26 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +27 -14
- package/dist/resources/extensions/gsd/auto-prompts.js +214 -17
- package/dist/resources/extensions/gsd/auto-recovery.js +197 -9
- package/dist/resources/extensions/gsd/auto-start.js +199 -9
- 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 +95 -27
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +103 -3
- 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 +330 -55
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +82 -23
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +129 -1
- package/dist/resources/extensions/gsd/clean-root-preflight.js +65 -9
- package/dist/resources/extensions/gsd/commands/dispatcher.js +5 -0
- package/dist/resources/extensions/gsd/commands-extract-learnings.js +17 -12
- 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/custom-workflow-engine.js +22 -2
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +92 -0
- package/dist/resources/extensions/gsd/db-base-schema.js +18 -2
- package/dist/resources/extensions/gsd/db-migration-steps.js +22 -0
- package/dist/resources/extensions/gsd/detection.js +106 -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/graph.js +9 -3
- package/dist/resources/extensions/gsd/gsd-db.js +146 -13
- package/dist/resources/extensions/gsd/guided-flow.js +129 -44
- 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/pr-evidence.js +57 -16
- 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 +21 -19
- 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-milestone.md +3 -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/safety/evidence-collector.js +10 -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/working-output-messages.js +64 -0
- package/dist/resources/extensions/gsd/worktree-manager.js +16 -14
- 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 +11 -11
- 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/react-loadable-manifest.json +1 -1
- 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/api/onboarding/route.js +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 +11 -11
- package/dist/web/standalone/.next/server/chunks/6897.js +3 -3
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-react-loadable-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/dist/web/standalone/.next/static/chunks/{8336.6f6f30e410419aff.js → 8336.631939fb583761fa.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/{webpack-d82dbee6356c1733.js → webpack-0481f1221120a7c6.js} +1 -1
- package/dist/welcome-screen.d.ts +2 -0
- package/dist/welcome-screen.js +9 -7
- package/package.json +12 -8
- package/packages/contracts/package.json +1 -1
- 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-ai/dist/models/fake-model.d.ts +12 -0
- package/packages/pi-ai/dist/models/fake-model.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/fake-model.js +27 -0
- package/packages/pi-ai/dist/models/fake-model.js.map +1 -0
- package/packages/pi-ai/dist/models/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/models/index.js +8 -0
- package/packages/pi-ai/dist/models/index.js.map +1 -1
- package/packages/pi-ai/dist/providers/fake.d.ts +42 -0
- package/packages/pi-ai/dist/providers/fake.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/fake.js +319 -0
- package/packages/pi-ai/dist/providers/fake.js.map +1 -0
- package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/register-builtins.js +24 -0
- package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -1
- package/packages/pi-ai/src/models/fake-model.ts +30 -0
- package/packages/pi-ai/src/models/index.ts +9 -0
- package/packages/pi-ai/src/providers/fake.ts +376 -0
- package/packages/pi-ai/src/providers/register-builtins.ts +23 -0
- package/packages/pi-ai/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 +76 -0
- 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 +5 -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 +20 -7
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +102 -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/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +5 -0
- package/packages/pi-coding-agent/dist/core/model-registry.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 +24 -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 +33 -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/slash-commands.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.js +1 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.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/__tests__/chat-frame-compaction-tone.test.js +6 -4
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +54 -15
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts +26 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js +112 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js +51 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +10 -9
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +3 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +7 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +17 -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 +109 -17
- 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 +69 -2
- 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 +93 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +3 -0
- 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 +26 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +20 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.js +79 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts +12 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js +13 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +18 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +36 -27
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.d.ts +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.js +18 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js +48 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js.map +1 -0
- 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 +89 -0
- 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 +113 -3
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +24 -6
- 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/model-registry.ts +4 -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 +51 -1
- package/packages/pi-coding-agent/src/core/skill-tool.test.ts +28 -0
- package/packages/pi-coding-agent/src/core/slash-commands.ts +1 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +8 -10
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.ts +7 -5
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +78 -15
- package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.test.ts +59 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.ts +160 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +10 -9
- package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +15 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +10 -9
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +122 -17
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +99 -1
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +92 -3
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-state.ts +1 -1
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +28 -0
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.test.ts +95 -0
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +24 -1
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.ts +13 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +32 -2
- package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +36 -27
- package/packages/pi-coding-agent/src/modes/interactive/tui-mode.test.ts +65 -0
- package/packages/pi-coding-agent/src/modes/interactive/tui-mode.ts +29 -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/__tests__/style.test.d.ts +2 -0
- package/packages/pi-tui/dist/__tests__/style.test.d.ts.map +1 -0
- package/packages/pi-tui/dist/__tests__/style.test.js +63 -0
- package/packages/pi-tui/dist/__tests__/style.test.js.map +1 -0
- package/packages/pi-tui/dist/__tests__/tui.test.js +24 -3
- package/packages/pi-tui/dist/__tests__/tui.test.js.map +1 -1
- package/packages/pi-tui/dist/index.d.ts +1 -0
- package/packages/pi-tui/dist/index.d.ts.map +1 -1
- package/packages/pi-tui/dist/index.js +2 -0
- package/packages/pi-tui/dist/index.js.map +1 -1
- package/packages/pi-tui/dist/style.d.ts +41 -0
- package/packages/pi-tui/dist/style.d.ts.map +1 -0
- package/packages/pi-tui/dist/style.js +158 -0
- package/packages/pi-tui/dist/style.js.map +1 -0
- package/packages/pi-tui/dist/tui.d.ts +0 -1
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +21 -16
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/src/__tests__/style.test.ts +76 -0
- package/packages/pi-tui/src/__tests__/tui.test.ts +29 -3
- package/packages/pi-tui/src/index.ts +9 -0
- package/packages/pi-tui/src/style.ts +225 -0
- package/packages/pi-tui/src/tui.ts +23 -16
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/pkg/dist/modes/interactive/theme/theme-schema.d.ts +12 -0
- package/pkg/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme-schema.js +13 -0
- package/pkg/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +18 -1
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/themes.js +36 -27
- package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
- package/src/resources/GSD-WORKFLOW.md +2 -2
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +30 -0
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +26 -0
- package/src/resources/extensions/github-sync/templates.ts +38 -8
- package/src/resources/extensions/github-sync/tests/inline-code.test.ts +66 -0
- package/src/resources/extensions/gsd/auto/loop-deps.ts +3 -2
- package/src/resources/extensions/gsd/auto/loop.ts +151 -26
- package/src/resources/extensions/gsd/auto/phases.ts +289 -196
- package/src/resources/extensions/gsd/auto/resolve.ts +42 -1
- package/src/resources/extensions/gsd/auto/run-unit.ts +52 -44
- package/src/resources/extensions/gsd/auto/session.ts +8 -0
- package/src/resources/extensions/gsd/auto/workflow-dispatch-claim.ts +63 -1
- package/src/resources/extensions/gsd/auto/workflow-worker-heartbeat.ts +14 -1
- package/src/resources/extensions/gsd/auto-dashboard.ts +57 -8
- package/src/resources/extensions/gsd/auto-direct-dispatch.ts +8 -34
- package/src/resources/extensions/gsd/auto-dispatch.ts +33 -0
- package/src/resources/extensions/gsd/auto-post-unit.ts +28 -14
- package/src/resources/extensions/gsd/auto-prompts.ts +228 -16
- package/src/resources/extensions/gsd/auto-recovery.ts +207 -7
- package/src/resources/extensions/gsd/auto-start.ts +237 -15
- 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 +110 -22
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +119 -2
- 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 +386 -55
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +90 -22
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +135 -1
- package/src/resources/extensions/gsd/clean-root-preflight.ts +72 -9
- package/src/resources/extensions/gsd/commands/dispatcher.ts +6 -0
- package/src/resources/extensions/gsd/commands-extract-learnings.ts +17 -12
- 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/custom-workflow-engine.ts +24 -1
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +107 -0
- package/src/resources/extensions/gsd/db-base-schema.ts +19 -2
- package/src/resources/extensions/gsd/db-migration-steps.ts +25 -0
- package/src/resources/extensions/gsd/detection.ts +128 -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/graph.ts +12 -5
- package/src/resources/extensions/gsd/gsd-db.ts +168 -13
- package/src/resources/extensions/gsd/guided-flow.ts +150 -51
- 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/pr-evidence.ts +63 -5
- 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 +21 -19
- 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-milestone.md +3 -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/safety/evidence-collector.ts +11 -2
- package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/auto-abort-pause-regression.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +33 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +516 -15
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +56 -13
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +184 -2
- 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 +97 -2
- package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +9 -0
- 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 +117 -7
- package/src/resources/extensions/gsd/tests/custom-workflow-engine.test.ts +40 -2
- package/src/resources/extensions/gsd/tests/db-migration-steps.integration.test.ts +428 -0
- package/src/resources/extensions/gsd/tests/db-schema-metadata.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/detection.test.ts +140 -0
- 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/fixtures/pr-body/commands-ship-basic.md +52 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/commands-ship-empty-optionals.md +42 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-no-blockers.md +55 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-with-blockers.md +60 -0
- package/src/resources/extensions/gsd/tests/graph-operations.test.ts +10 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/has-pending-deep-stage.test.ts +33 -1
- 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/pr-evidence-equivalence.test.ts +102 -0
- package/src/resources/extensions/gsd/tests/pr-evidence-hardening.test.ts +165 -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/right-sized-workflow-prompts.test.ts +192 -0
- package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +29 -0
- 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-start-footer.test.ts +77 -0
- package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +166 -0
- package/src/resources/extensions/gsd/tests/signal-handlers.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +38 -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 +101 -2
- 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 +80 -1
- 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/uok-plan-v2-wiring.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/workflow-dispatch-claim.test.ts +142 -0
- 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/workflow-worker-heartbeat.test.ts +32 -1
- package/src/resources/extensions/gsd/tests/working-output-messages.test.ts +93 -0
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +37 -6
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +7 -0
- package/src/resources/extensions/gsd/tests/worktree-nested-git-safety.test.ts +9 -2
- 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/tests/worktree-write-gate.test.ts +179 -0
- 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/working-output-messages.ts +120 -0
- package/src/resources/extensions/gsd/worktree-manager.ts +15 -4
- package/src/resources/extensions/gsd/worktree-resolver.ts +85 -19
- package/packages/contracts/tsconfig.tsbuildinfo +0 -1
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +0 -97
- /package/dist/web/standalone/.next/static/{bQDK5_LtkGVS64AirQgQG → cWaxzf-sdbSSbbwYu8q7a}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{bQDK5_LtkGVS64AirQgQG → cWaxzf-sdbSSbbwYu8q7a}/_ssgManifest.js +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Project/App: GSD-2
|
|
2
|
+
// File Purpose: System prompt and hidden context bootstrap for GSD sessions.
|
|
1
3
|
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
2
4
|
import { join } from "node:path";
|
|
3
5
|
import { logWarning } from "../workflow-logger.js";
|
|
@@ -17,6 +19,11 @@ import { formatOverridesSection, formatShortcut, loadActiveOverrides, loadFile,
|
|
|
17
19
|
import { toPosixPath } from "../../shared/mod.js";
|
|
18
20
|
import { autoEnableCmuxPreferences } from "../commands-cmux.js";
|
|
19
21
|
import { gsdHome } from "../gsd-home.js";
|
|
22
|
+
const DEFAULT_CONTEXT_MESSAGE_MAX_CHARS = 4_000;
|
|
23
|
+
const DEFAULT_KNOWLEDGE_MAX_CHARS = 12_000;
|
|
24
|
+
const DEFAULT_CODEBASE_MAX_CHARS = 8_000;
|
|
25
|
+
const MIN_CONTEXT_MESSAGE_MAX_CHARS = 1_000;
|
|
26
|
+
const MIN_KNOWLEDGE_MAX_CHARS = 1_000;
|
|
20
27
|
/**
|
|
21
28
|
* Bundled skill triggers — resolved dynamically at runtime instead of
|
|
22
29
|
* hardcoding absolute paths in the system prompt template. Only skills
|
|
@@ -135,7 +142,6 @@ export async function buildBeforeAgentStartResult(event, ctx) {
|
|
|
135
142
|
catch (e) {
|
|
136
143
|
logWarning("bootstrap", `decisions backfill failed: ${e.message}`);
|
|
137
144
|
}
|
|
138
|
-
const memoryBlock = await loadMemoryBlock(event.prompt ?? "");
|
|
139
145
|
let newSkillsBlock = "";
|
|
140
146
|
if (hasSkillSnapshot()) {
|
|
141
147
|
const newSkills = detectNewSkills();
|
|
@@ -165,11 +171,10 @@ export async function buildBeforeAgentStartResult(event, ctx) {
|
|
|
165
171
|
if (rawContent) {
|
|
166
172
|
// Cap injection size to ~2 000 tokens to avoid bloating every request.
|
|
167
173
|
// Full map is always available at .gsd/CODEBASE.md.
|
|
168
|
-
const MAX_CODEBASE_CHARS = 8_000;
|
|
169
174
|
const generatedMatch = rawContent.match(/Generated: (\S+)/);
|
|
170
175
|
const generatedAt = generatedMatch?.[1] ?? "unknown";
|
|
171
|
-
const content = rawContent.length >
|
|
172
|
-
? rawContent.slice(0,
|
|
176
|
+
const content = rawContent.length > DEFAULT_CODEBASE_MAX_CHARS
|
|
177
|
+
? rawContent.slice(0, DEFAULT_CODEBASE_MAX_CHARS) + "\n\n*(truncated — see .gsd/CODEBASE.md for full map)*"
|
|
173
178
|
: rawContent;
|
|
174
179
|
codebaseBlock = `\n\n[PROJECT CODEBASE — File structure and descriptions (generated ${generatedAt}, auto-refreshed when GSD detects tracked file changes; use /gsd codebase stats for status)]\n\n${content}`;
|
|
175
180
|
}
|
|
@@ -180,6 +185,9 @@ export async function buildBeforeAgentStartResult(event, ctx) {
|
|
|
180
185
|
}
|
|
181
186
|
warnDeprecatedAgentInstructions();
|
|
182
187
|
const injection = await buildGuidedExecuteContextInjection(event.prompt, process.cwd());
|
|
188
|
+
const memoryBlock = await loadMemoryBlock(event.prompt ?? "", {
|
|
189
|
+
includePromptRelevant: !(injection && isLowEntropyResumePrompt(event.prompt ?? "")),
|
|
190
|
+
});
|
|
183
191
|
// Re-inject forensics context on follow-up turns (#2941)
|
|
184
192
|
const forensicsInjection = !injection ? buildForensicsContextInjection(process.cwd(), event.prompt) : null;
|
|
185
193
|
const worktreeBlock = buildWorktreeContextBlock();
|
|
@@ -188,12 +196,9 @@ export async function buildBeforeAgentStartResult(event, ctx) {
|
|
|
188
196
|
? `\n\n## Subagent Model\n\nWhen spawning subagents via the \`subagent\` tool, always pass \`model: "${subagentModelConfig.primary}"\` in the tool call parameters. Never omit this — always specify it explicitly.`
|
|
189
197
|
: "";
|
|
190
198
|
// memoryBlock is FTS-queried against the user prompt and changes per call.
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
//
|
|
194
|
-
// memoryBlock injected via the context message may itself be cached up to
|
|
195
|
-
// that boundary; that's orthogonal and unchanged from prior behavior. The
|
|
196
|
-
// load-bearing win here is preserving the system+tools cache hit. (#5019)
|
|
199
|
+
// Keeping it out of `fullSystem` preserves provider prompt-cache stability
|
|
200
|
+
// for the static system/tool prefix. The dynamic memory block rides the
|
|
201
|
+
// volatile context message instead. (#5019)
|
|
197
202
|
const fullSystem = `${event.systemPrompt}\n\n[SYSTEM CONTEXT — GSD]\n\n${systemContent}${preferenceBlock}${knowledgeBlock}${codebaseBlock}${newSkillsBlock}${worktreeBlock}${subagentModelBlock}`;
|
|
198
203
|
stopContextTimer({
|
|
199
204
|
systemPromptSize: fullSystem.length,
|
|
@@ -217,20 +222,49 @@ export async function buildBeforeAgentStartResult(event, ctx) {
|
|
|
217
222
|
* filesystem and DB dependencies to exercise this routing logic in-place.
|
|
218
223
|
*/
|
|
219
224
|
export function buildContextMessage(opts) {
|
|
220
|
-
const
|
|
225
|
+
const contextCharLimit = getContextMessageCharLimit();
|
|
226
|
+
const memoryContent = markMemoryContextSupplied(opts.memoryBlock.trim());
|
|
221
227
|
if (opts.injection) {
|
|
222
|
-
const content = memoryContent ? `${memoryContent}\n\n${opts.injection}` : opts.injection;
|
|
228
|
+
const content = limitContextMessageContent(memoryContent ? `${memoryContent}\n\n${opts.injection}` : opts.injection, contextCharLimit);
|
|
223
229
|
return { customType: "gsd-guided-context", content, display: false };
|
|
224
230
|
}
|
|
225
231
|
if (opts.forensicsInjection) {
|
|
226
|
-
const content = memoryContent ? `${memoryContent}\n\n${opts.forensicsInjection}` : opts.forensicsInjection;
|
|
232
|
+
const content = limitContextMessageContent(memoryContent ? `${memoryContent}\n\n${opts.forensicsInjection}` : opts.forensicsInjection, contextCharLimit);
|
|
227
233
|
return { customType: "gsd-forensics", content, display: false };
|
|
228
234
|
}
|
|
229
235
|
if (memoryContent) {
|
|
230
|
-
return {
|
|
236
|
+
return {
|
|
237
|
+
customType: "gsd-memory",
|
|
238
|
+
content: limitContextMessageContent(memoryContent, contextCharLimit),
|
|
239
|
+
display: false,
|
|
240
|
+
};
|
|
231
241
|
}
|
|
232
242
|
return null;
|
|
233
243
|
}
|
|
244
|
+
function getContextMessageCharLimit() {
|
|
245
|
+
const raw = process.env.PI_GSD_CONTEXT_MAX_CHARS;
|
|
246
|
+
if (!raw)
|
|
247
|
+
return DEFAULT_CONTEXT_MESSAGE_MAX_CHARS;
|
|
248
|
+
if (raw === "0")
|
|
249
|
+
return null;
|
|
250
|
+
const parsed = Number(raw);
|
|
251
|
+
if (!Number.isFinite(parsed) || parsed < MIN_CONTEXT_MESSAGE_MAX_CHARS) {
|
|
252
|
+
return DEFAULT_CONTEXT_MESSAGE_MAX_CHARS;
|
|
253
|
+
}
|
|
254
|
+
return Math.floor(parsed);
|
|
255
|
+
}
|
|
256
|
+
function limitContextMessageContent(content, limit) {
|
|
257
|
+
if (!limit || content.length <= limit)
|
|
258
|
+
return content;
|
|
259
|
+
const suffix = "\n\n[GSD Context Truncated]\nFull context is available from the referenced .gsd files and tools; read on demand only if this excerpt lacks required evidence.";
|
|
260
|
+
const headBudget = Math.max(0, limit - suffix.length);
|
|
261
|
+
return `${content.slice(0, headBudget).trimEnd()}${suffix}`;
|
|
262
|
+
}
|
|
263
|
+
function markMemoryContextSupplied(memoryContent) {
|
|
264
|
+
if (!memoryContent)
|
|
265
|
+
return "";
|
|
266
|
+
return `[GSD Context Metadata]\n- Memory supplied: yes\n\n${memoryContent}`;
|
|
267
|
+
}
|
|
234
268
|
/**
|
|
235
269
|
* ADR-013 step 4 — auto-injection parity for the memories table.
|
|
236
270
|
*
|
|
@@ -249,7 +283,7 @@ export function buildContextMessage(opts) {
|
|
|
249
283
|
* with a token-budget cap. Failures degrade gracefully — the function never
|
|
250
284
|
* throws and returns "" so the system prompt construction continues.
|
|
251
285
|
*/
|
|
252
|
-
export async function loadMemoryBlock(userPrompt) {
|
|
286
|
+
export async function loadMemoryBlock(userPrompt, opts = {}) {
|
|
253
287
|
try {
|
|
254
288
|
const { formatMemoriesForPrompt, getActiveMemoriesRanked, queryMemoriesRanked } = await import("../memory-store.js");
|
|
255
289
|
// Categories that belong in every turn. Pre-ADR-013 this was just
|
|
@@ -268,7 +302,7 @@ export async function loadMemoryBlock(userPrompt) {
|
|
|
268
302
|
const criticalIds = new Set(critical.map((m) => m.id));
|
|
269
303
|
let relevant = [];
|
|
270
304
|
const trimmed = userPrompt.trim();
|
|
271
|
-
if (trimmed) {
|
|
305
|
+
if (trimmed && opts.includePromptRelevant !== false) {
|
|
272
306
|
const hits = queryMemoriesRanked({ query: trimmed, k: QUERY_K });
|
|
273
307
|
relevant = hits.map((h) => h.memory).filter((m) => !criticalIds.has(m.id));
|
|
274
308
|
}
|
|
@@ -319,15 +353,37 @@ export function loadKnowledgeBlock(gsdHomeDir, cwd) {
|
|
|
319
353
|
return { block: "", globalSizeKb: 0 };
|
|
320
354
|
}
|
|
321
355
|
const parts = [];
|
|
322
|
-
if (globalKnowledge)
|
|
323
|
-
parts.push(`## Global Knowledge\n\n${globalKnowledge}`);
|
|
324
|
-
|
|
325
|
-
|
|
356
|
+
if (globalKnowledge) {
|
|
357
|
+
parts.push(`## Global Knowledge\nSource: \`${globalKnowledgePath}\`\n\n${globalKnowledge}`);
|
|
358
|
+
}
|
|
359
|
+
if (projectKnowledge) {
|
|
360
|
+
parts.push(`## Project Knowledge\nSource: \`${knowledgePath}\`\n\n${projectKnowledge}`);
|
|
361
|
+
}
|
|
362
|
+
const body = limitKnowledgeBlock(parts.join("\n\n"), getKnowledgeCharLimit());
|
|
326
363
|
return {
|
|
327
|
-
block: `\n\n[KNOWLEDGE — Rules, patterns, and lessons learned]\n\n${
|
|
364
|
+
block: `\n\n[KNOWLEDGE — Rules, patterns, and lessons learned]\n\n${body}`,
|
|
328
365
|
globalSizeKb,
|
|
329
366
|
};
|
|
330
367
|
}
|
|
368
|
+
function getKnowledgeCharLimit() {
|
|
369
|
+
const raw = process.env.PI_GSD_KNOWLEDGE_MAX_CHARS;
|
|
370
|
+
if (!raw)
|
|
371
|
+
return DEFAULT_KNOWLEDGE_MAX_CHARS;
|
|
372
|
+
if (raw === "0")
|
|
373
|
+
return null;
|
|
374
|
+
const parsed = Number(raw);
|
|
375
|
+
if (!Number.isFinite(parsed) || parsed < MIN_KNOWLEDGE_MAX_CHARS) {
|
|
376
|
+
return DEFAULT_KNOWLEDGE_MAX_CHARS;
|
|
377
|
+
}
|
|
378
|
+
return Math.floor(parsed);
|
|
379
|
+
}
|
|
380
|
+
function limitKnowledgeBlock(content, limit) {
|
|
381
|
+
if (!limit || content.length <= limit)
|
|
382
|
+
return content;
|
|
383
|
+
const suffix = "\n\n[Knowledge Truncated]\nFull KNOWLEDGE.md content remains available at the source path(s) above; read on demand only if this excerpt lacks a required rule.";
|
|
384
|
+
const headBudget = Math.max(0, limit - suffix.length);
|
|
385
|
+
return `${content.slice(0, headBudget).trimEnd()}${suffix}`;
|
|
386
|
+
}
|
|
331
387
|
function buildWorktreeContextBlock() {
|
|
332
388
|
const worktreeName = getActiveWorktreeName();
|
|
333
389
|
const worktreeMainCwd = getWorktreeOriginalCwd();
|
|
@@ -376,6 +432,10 @@ function buildWorktreeContextBlock() {
|
|
|
376
432
|
* Tested against the trimmed, lowercased prompt with trailing punctuation stripped.
|
|
377
433
|
*/
|
|
378
434
|
const RESUME_INTENT_PATTERNS = /^(continue|resume|ok|go|go ahead|proceed|keep going|carry on|next|yes|yeah|yep|sure|do it|let's go|pick up where you left off)$/;
|
|
435
|
+
export function isLowEntropyResumePrompt(prompt) {
|
|
436
|
+
const trimmed = prompt.trim().toLowerCase().replace(/[.!?,]+$/g, "");
|
|
437
|
+
return RESUME_INTENT_PATTERNS.test(trimmed);
|
|
438
|
+
}
|
|
379
439
|
async function buildGuidedExecuteContextInjection(prompt, basePath) {
|
|
380
440
|
const ensureStateDbOpen = async () => {
|
|
381
441
|
const { ensureDbOpen } = await import("./dynamic-tools.js");
|
|
@@ -402,8 +462,7 @@ async function buildGuidedExecuteContextInjection(prompt, basePath) {
|
|
|
402
462
|
// control/help/diagnostic prompts with unrelated execution context.
|
|
403
463
|
// Phase-gated: only fire during "executing" to avoid misrouting during
|
|
404
464
|
// replanning, gate evaluation, or other non-execution phases.
|
|
405
|
-
|
|
406
|
-
if (RESUME_INTENT_PATTERNS.test(trimmed)) {
|
|
465
|
+
if (isLowEntropyResumePrompt(prompt)) {
|
|
407
466
|
await ensureStateDbOpen();
|
|
408
467
|
const state = await deriveState(basePath);
|
|
409
468
|
if (state.phase === "executing" && state.activeTask && state.activeMilestone && state.activeSlice) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { minimatch } from "minimatch";
|
|
4
|
+
import { getIsolationMode } from "../preferences.js";
|
|
4
5
|
import { logWarning } from "../workflow-logger.js";
|
|
6
|
+
import { isGsdWorktreePath, resolveWorktreeProjectRoot } from "../worktree-root.js";
|
|
5
7
|
/**
|
|
6
8
|
* Regex matching milestone CONTEXT.md file names in both legacy M001
|
|
7
9
|
* and unique M001-abc123 formats. Exported so regex-hardening tests
|
|
@@ -728,3 +730,129 @@ export function shouldBlockPlanningUnit(toolName, pathOrCommand, basePath, unitT
|
|
|
728
730
|
// avoids breaking gsd_* MCP tools or future safe additions.
|
|
729
731
|
return { block: false };
|
|
730
732
|
}
|
|
733
|
+
// ─── Worktree isolation write gate (#5199) ────────────────────────────────
|
|
734
|
+
//
|
|
735
|
+
// When `git.isolation: worktree` is configured, the per-unit commit pipeline
|
|
736
|
+
// only runs inside the auto-mode loop (`auto-post-unit.ts`). If the LLM
|
|
737
|
+
// authors code at the project root before auto-mode is started, those writes
|
|
738
|
+
// land in the working tree but never reach a commit — they're silently
|
|
739
|
+
// orphaned outside git history. This guard blocks those writes at the
|
|
740
|
+
// tool_call seam so the agent receives a clear error instead.
|
|
741
|
+
const WORKTREE_GATE_BOOTSTRAP_UNITS = new Set([
|
|
742
|
+
"discuss-milestone",
|
|
743
|
+
"plan-milestone",
|
|
744
|
+
"init",
|
|
745
|
+
]);
|
|
746
|
+
function realpathOrResolve(p) {
|
|
747
|
+
const abs = resolve(p);
|
|
748
|
+
try {
|
|
749
|
+
return realpathSync(abs);
|
|
750
|
+
}
|
|
751
|
+
catch {
|
|
752
|
+
// Path doesn't exist (yet) — realpath the deepest existing ancestor so
|
|
753
|
+
// platforms where /tmp -> /private/tmp don't break containment checks.
|
|
754
|
+
let dir = abs;
|
|
755
|
+
const tail = [];
|
|
756
|
+
while (dir && dir !== resolve(dir, "..")) {
|
|
757
|
+
try {
|
|
758
|
+
const real = realpathSync(dir);
|
|
759
|
+
return tail.length ? join(real, ...tail.reverse()) : real;
|
|
760
|
+
}
|
|
761
|
+
catch {
|
|
762
|
+
const idx = dir.lastIndexOf(sep);
|
|
763
|
+
if (idx <= 0)
|
|
764
|
+
break;
|
|
765
|
+
tail.push(dir.slice(idx + 1));
|
|
766
|
+
dir = dir.slice(0, idx) || sep;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return abs;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function isPathContained(target, container) {
|
|
773
|
+
if (target === container)
|
|
774
|
+
return true;
|
|
775
|
+
return target.startsWith(container.endsWith(sep) ? container : container + sep);
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Block planning-write tool calls that would land code at the project root
|
|
779
|
+
* while `git.isolation: worktree` is in effect and auto-mode hasn't created
|
|
780
|
+
* (or flipped cwd into) the milestone worktree.
|
|
781
|
+
*
|
|
782
|
+
* Pure / unit-testable. Callers in `register-hooks.ts` supply the resolved
|
|
783
|
+
* project root and current auto liveness; this function does no I/O beyond
|
|
784
|
+
* realpath resolution.
|
|
785
|
+
*
|
|
786
|
+
* Allow rules (in order):
|
|
787
|
+
* 1. Tool isn't a planning-write (write/edit/multi_edit/notebook_edit).
|
|
788
|
+
* 2. `GSD_DISABLE_WORKTREE_WRITE_GUARD=1` self-hosting bypass.
|
|
789
|
+
* 3. Isolation mode is not "worktree".
|
|
790
|
+
* 4. Active unit is a bootstrap unit (discuss-milestone/plan-milestone/init).
|
|
791
|
+
* 5. Target is inside `<projectRoot>/.gsd/worktrees/` (a real worktree).
|
|
792
|
+
* 6. Target is inside `<projectRoot>/.gsd/` and isn't masquerading as a
|
|
793
|
+
* worktrees sibling (rejects the `.gsd/worktrees-extra/…` prefix trick).
|
|
794
|
+
* 7. Auto is live AND `effectiveBasePath` is itself a `.gsd/worktrees/…` path.
|
|
795
|
+
*
|
|
796
|
+
* Otherwise: block with a message that points the agent at `/gsd` to start
|
|
797
|
+
* auto-mode.
|
|
798
|
+
*/
|
|
799
|
+
export function shouldBlockWorktreeWrite(toolName, targetPath, effectiveBasePath, isAutoLive, currentUnitType) {
|
|
800
|
+
const tool = canonicalToolName(toolName);
|
|
801
|
+
if (!PLANNING_WRITE_TOOLS.has(tool))
|
|
802
|
+
return { block: false };
|
|
803
|
+
if (process.env.GSD_DISABLE_WORKTREE_WRITE_GUARD === "1")
|
|
804
|
+
return { block: false };
|
|
805
|
+
if (getIsolationMode(effectiveBasePath) !== "worktree")
|
|
806
|
+
return { block: false };
|
|
807
|
+
if (currentUnitType && WORKTREE_GATE_BOOTSTRAP_UNITS.has(currentUnitType))
|
|
808
|
+
return { block: false };
|
|
809
|
+
if (!targetPath) {
|
|
810
|
+
return {
|
|
811
|
+
block: true,
|
|
812
|
+
reason: [
|
|
813
|
+
`HARD BLOCK: ${tool} called with empty path while \`git.isolation: worktree\` is configured`,
|
|
814
|
+
`and auto-mode is not active. Refusing to allow writes that cannot be located.`,
|
|
815
|
+
].join(" "),
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
// Resolve the target relative to the project root, then realpath to defeat
|
|
819
|
+
// symlink-based escapes and prefix tricks (e.g. .gsd/worktrees-extra/).
|
|
820
|
+
const projectRoot = resolveWorktreeProjectRoot(effectiveBasePath);
|
|
821
|
+
const absTarget = isAbsolute(targetPath) ? targetPath : resolve(projectRoot, targetPath);
|
|
822
|
+
const realTarget = realpathOrResolve(absTarget);
|
|
823
|
+
const realRoot = realpathOrResolve(projectRoot);
|
|
824
|
+
const realGsd = realpathOrResolve(join(projectRoot, ".gsd"));
|
|
825
|
+
const realWorktreesDir = realpathOrResolve(join(projectRoot, ".gsd", "worktrees"));
|
|
826
|
+
// Allow writes inside the legitimate worktrees subtree.
|
|
827
|
+
if (isPathContained(realTarget, realWorktreesDir))
|
|
828
|
+
return { block: false };
|
|
829
|
+
// Allow writes to .gsd/ planning artifacts, but reject siblings whose name
|
|
830
|
+
// starts with "worktrees" (the worktrees-extra prefix trick — case 4).
|
|
831
|
+
if (isPathContained(realTarget, realGsd)) {
|
|
832
|
+
const rel = relative(realGsd, realTarget);
|
|
833
|
+
const firstSeg = rel.split(/[\/\\]/)[0] ?? "";
|
|
834
|
+
if (!firstSeg.startsWith("worktrees"))
|
|
835
|
+
return { block: false };
|
|
836
|
+
// fall through: looks like worktrees<something> sibling — block
|
|
837
|
+
}
|
|
838
|
+
// Auto is live and the caller is operating inside a worktree path —
|
|
839
|
+
// host tool's write happens in worktree context; let it through.
|
|
840
|
+
if (isAutoLive && isGsdWorktreePath(effectiveBasePath))
|
|
841
|
+
return { block: false };
|
|
842
|
+
// Block. Provide enough context that the agent can self-correct.
|
|
843
|
+
const displayTarget = isPathContained(realTarget, realRoot)
|
|
844
|
+
? relative(realRoot, realTarget) || "."
|
|
845
|
+
: realTarget;
|
|
846
|
+
return {
|
|
847
|
+
block: true,
|
|
848
|
+
reason: [
|
|
849
|
+
`HARD BLOCK: Worktree isolation is configured (\`git.isolation: worktree\`) but auto-mode is`,
|
|
850
|
+
`not running and the target "${displayTarget}" is not inside \`.gsd/worktrees/<MID>/\`.`,
|
|
851
|
+
`Code edits at the project root would be lost — only the auto-mode commit pipeline`,
|
|
852
|
+
`(auto-post-unit) commits work, and it never runs outside the loop.`,
|
|
853
|
+
`Required action: start auto-mode with \`/gsd\` so the milestone worktree is created,`,
|
|
854
|
+
`then write inside it. To disable this guard for self-hosting development, set`,
|
|
855
|
+
`GSD_DISABLE_WORKTREE_WRITE_GUARD=1.`,
|
|
856
|
+
].join(" "),
|
|
857
|
+
};
|
|
858
|
+
}
|
|
@@ -3,19 +3,44 @@
|
|
|
3
3
|
*
|
|
4
4
|
* #2909: Adds a fast-path git status check before milestone completion merges.
|
|
5
5
|
* When the working tree is dirty the user is warned and changes are auto-stashed
|
|
6
|
-
* so the merge can proceed cleanly.
|
|
7
|
-
* restores the stashed changes.
|
|
6
|
+
* so the merge can proceed cleanly. After the merge completes, postflightPopStash
|
|
7
|
+
* restores the stashed changes and reports whether manual recovery is needed.
|
|
8
8
|
*
|
|
9
9
|
* Design constraints (from Trek-e approval):
|
|
10
10
|
* - Warn the user before stashing (no silent surprises)
|
|
11
11
|
* - git stash push / git stash pop only — no custom stash management layer
|
|
12
|
-
* - Stash/pop errors are logged but MUST NOT block the merge
|
|
12
|
+
* - Stash/pop errors are logged but MUST NOT block the merge itself
|
|
13
13
|
* - Fast-path status check — clean trees pay no extra cost
|
|
14
14
|
*/
|
|
15
15
|
import { execFileSync } from "node:child_process";
|
|
16
16
|
import { GIT_NO_PROMPT_ENV } from "./git-constants.js";
|
|
17
17
|
import { logWarning } from "./workflow-logger.js";
|
|
18
18
|
import { nativeHasChanges } from "./native-git-bridge.js";
|
|
19
|
+
function findPreflightStashRef(basePath, milestoneId, stashMarker) {
|
|
20
|
+
const markerPrefix = `gsd-preflight-stash:${milestoneId}:`;
|
|
21
|
+
let fallbackRef = null;
|
|
22
|
+
try {
|
|
23
|
+
const list = execFileSync("git", ["stash", "list", "--format=%gd%x00%s"], {
|
|
24
|
+
cwd: basePath,
|
|
25
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
26
|
+
encoding: "utf-8",
|
|
27
|
+
env: GIT_NO_PROMPT_ENV,
|
|
28
|
+
});
|
|
29
|
+
for (const line of list.split("\n")) {
|
|
30
|
+
const [ref, subject] = line.split("\x00");
|
|
31
|
+
if (!ref || !subject)
|
|
32
|
+
continue;
|
|
33
|
+
if (stashMarker && subject.includes(stashMarker))
|
|
34
|
+
return ref;
|
|
35
|
+
if (!fallbackRef && subject.includes(markerPrefix))
|
|
36
|
+
fallbackRef = ref;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
logWarning("preflight", `stash list failed before restore: ${err instanceof Error ? err.message : String(err)}`);
|
|
41
|
+
}
|
|
42
|
+
return fallbackRef;
|
|
43
|
+
}
|
|
19
44
|
/**
|
|
20
45
|
* Check the working tree for dirty files before a milestone merge.
|
|
21
46
|
*
|
|
@@ -47,7 +72,8 @@ export function preflightCleanRoot(basePath, milestoneId, notify) {
|
|
|
47
72
|
notify(warnMsg, "warning");
|
|
48
73
|
// Push the stash
|
|
49
74
|
try {
|
|
50
|
-
|
|
75
|
+
const stashMarker = `gsd-preflight-stash:${milestoneId}:${process.pid}:${Date.now()}:${process.hrtime.bigint().toString(36)}`;
|
|
76
|
+
execFileSync("git", ["stash", "push", "--include-untracked", "-m", `gsd-preflight-stash [${stashMarker}]`], {
|
|
51
77
|
cwd: basePath,
|
|
52
78
|
stdio: ["ignore", "pipe", "pipe"],
|
|
53
79
|
encoding: "utf-8",
|
|
@@ -55,6 +81,7 @@ export function preflightCleanRoot(basePath, milestoneId, notify) {
|
|
|
55
81
|
});
|
|
56
82
|
return {
|
|
57
83
|
stashPushed: true,
|
|
84
|
+
stashMarker,
|
|
58
85
|
summary: `Stashed uncommitted changes before merge (milestone ${milestoneId}).`,
|
|
59
86
|
};
|
|
60
87
|
}
|
|
@@ -71,23 +98,52 @@ export function preflightCleanRoot(basePath, milestoneId, notify) {
|
|
|
71
98
|
*
|
|
72
99
|
* Only called when preflightCleanRoot returned stashPushed=true.
|
|
73
100
|
* Any pop error (e.g. conflict) is logged and notified but does NOT throw —
|
|
74
|
-
* the merge already completed successfully.
|
|
101
|
+
* the merge already completed successfully. Callers must treat
|
|
102
|
+
* needsManualRecovery=true as a dirty workspace stop, not a clean completion.
|
|
75
103
|
*/
|
|
76
|
-
export function postflightPopStash(basePath, milestoneId, notify) {
|
|
104
|
+
export function postflightPopStash(basePath, milestoneId, stashMarker, notify) {
|
|
105
|
+
let stashRef = null;
|
|
77
106
|
try {
|
|
78
|
-
|
|
107
|
+
stashRef = findPreflightStashRef(basePath, milestoneId, stashMarker);
|
|
108
|
+
if (!stashRef) {
|
|
109
|
+
const msg = `No matching GSD preflight stash found for milestone ${milestoneId}; leaving stash list untouched.`;
|
|
110
|
+
logWarning("preflight", msg);
|
|
111
|
+
notify(msg, "warning");
|
|
112
|
+
return {
|
|
113
|
+
restored: false,
|
|
114
|
+
needsManualRecovery: true,
|
|
115
|
+
message: msg,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
execFileSync("git", ["stash", "pop", stashRef], {
|
|
79
119
|
cwd: basePath,
|
|
80
120
|
stdio: ["ignore", "pipe", "pipe"],
|
|
81
121
|
encoding: "utf-8",
|
|
82
122
|
env: GIT_NO_PROMPT_ENV,
|
|
83
123
|
});
|
|
84
|
-
|
|
124
|
+
const msg = `Restored stashed changes after milestone ${milestoneId} merge.`;
|
|
125
|
+
notify(msg, "info");
|
|
126
|
+
return {
|
|
127
|
+
restored: true,
|
|
128
|
+
needsManualRecovery: false,
|
|
129
|
+
message: msg,
|
|
130
|
+
stashRef,
|
|
131
|
+
};
|
|
85
132
|
}
|
|
86
133
|
catch (err) {
|
|
87
134
|
// Pop conflicts mean the merged code collides with the stashed changes.
|
|
88
135
|
// Log a warning — the user needs to resolve manually, but the merge succeeded.
|
|
89
|
-
const
|
|
136
|
+
const restoreHint = stashRef
|
|
137
|
+
? `Run "git stash pop ${stashRef}" or "git stash apply ${stashRef}" manually to restore the correct stash.`
|
|
138
|
+
: `Run "git stash list" to find the matching GSD preflight stash before restoring manually.`;
|
|
139
|
+
const msg = `git stash pop ${stashRef ?? ""}`.trim() + ` failed after merge of milestone ${milestoneId}: ${err instanceof Error ? err.message : String(err)}. ${restoreHint}`;
|
|
90
140
|
logWarning("preflight", msg);
|
|
91
141
|
notify(msg, "warning");
|
|
142
|
+
return {
|
|
143
|
+
restored: false,
|
|
144
|
+
needsManualRecovery: true,
|
|
145
|
+
message: msg,
|
|
146
|
+
...(stashRef ? { stashRef } : {}),
|
|
147
|
+
};
|
|
92
148
|
}
|
|
93
149
|
}
|
|
@@ -33,5 +33,10 @@ export async function handleGSDCommand(args, ctx, pi) {
|
|
|
33
33
|
}
|
|
34
34
|
if (handled)
|
|
35
35
|
return;
|
|
36
|
+
if (trimmed.includes(" ")) {
|
|
37
|
+
const { handleDo } = await import("../commands-do.js");
|
|
38
|
+
await handleDo(trimmed, ctx, pi);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
36
41
|
ctx.ui.notify(`Unknown: /gsd ${trimmed}. Run /gsd help for available commands.`, "warning");
|
|
37
42
|
}
|
|
@@ -114,14 +114,19 @@ Using the \`write\` tool, persist the full structured report to
|
|
|
114
114
|
LEARNINGS.md is the full, cited audit trail. Write it first — subsequent steps
|
|
115
115
|
feed from its content.
|
|
116
116
|
|
|
117
|
-
### Step 3 —
|
|
117
|
+
### Step 3 — Run one bounded duplicate check
|
|
118
118
|
|
|
119
|
-
Before persisting
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
Before persisting extracted items in Steps 4–6, do at most one duplicate-check
|
|
120
|
+
pass for the durable Decisions, Lessons, and Patterns from this milestone. Use
|
|
121
|
+
the already-written LEARNINGS.md content and call \`memory_query\` once with a
|
|
122
|
+
compact keyword summary for the whole batch. If that result clearly shows a
|
|
123
|
+
semantically equivalent high-confidence memory for an item, mark only that item
|
|
124
|
+
as already captured and skip it in its respective persistence step.
|
|
125
|
+
|
|
126
|
+
Do not re-read milestone artefacts or repeat memory queries category-by-category
|
|
127
|
+
after this point. The memory store is the single source of truth for
|
|
128
|
+
cross-session durable knowledge — no other persistence call is part of this
|
|
129
|
+
flow.
|
|
125
130
|
|
|
126
131
|
### Step 4 — Persist Patterns via \`capture_thought\`
|
|
127
132
|
|
|
@@ -160,11 +165,11 @@ later projection back to a human-visible decisions register stays lossless
|
|
|
160
165
|
|
|
161
166
|
### Step 7 — Deduplication rule (applies to Steps 4, 5, 6)
|
|
162
167
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
over creating a second slightly-different row
|
|
167
|
-
signal.
|
|
168
|
+
Use only the duplicate-check result from Step 3. If that bounded check returned
|
|
169
|
+
a semantically equivalent memory at high confidence for an extracted item, skip
|
|
170
|
+
the capture entirely. Otherwise, persist the item once via \`capture_thought\`.
|
|
171
|
+
Prefer skipping a near-duplicate over creating a second slightly-different row
|
|
172
|
+
— redundancy degrades the signal.
|
|
168
173
|
|
|
169
174
|
### Step 8 — Surprises stay only in LEARNINGS.md
|
|
170
175
|
|
|
@@ -17,6 +17,8 @@ import { isAutoActive, checkRemoteAutoSession } from "./auto.js";
|
|
|
17
17
|
import { getAutoWorktreePath } from "./auto-worktree.js";
|
|
18
18
|
import { currentDirectoryRoot, projectRoot } from "./commands/context.js";
|
|
19
19
|
import { loadPrompt } from "./prompt-loader.js";
|
|
20
|
+
import { buildDoctorHealIssuePayload, buildDoctorHealSummary, buildWorkflowDispatchContent, } from "./workflow-protocol.js";
|
|
21
|
+
import { restoreGsdWorkflowTools, scopeGsdWorkflowToolsForDispatch, } from "./bootstrap/register-hooks.js";
|
|
20
22
|
const UPDATE_REGISTRY_URL = "https://registry.npmjs.org/gsd-pi/latest";
|
|
21
23
|
const UPDATE_FETCH_TIMEOUT_MS = 5000;
|
|
22
24
|
// Detects a bun-installed gsd via `process.argv[1]`. Mirrors isBunInstall in
|
|
@@ -64,13 +66,19 @@ export function dispatchDoctorHeal(pi, scope, reportText, structuredIssues) {
|
|
|
64
66
|
const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(gsdHome(), "agent", "GSD-WORKFLOW.md");
|
|
65
67
|
const workflow = readFileSync(workflowPath, "utf-8");
|
|
66
68
|
const prompt = loadPrompt("doctor-heal", {
|
|
67
|
-
doctorSummary: reportText,
|
|
68
|
-
structuredIssues,
|
|
69
|
+
doctorSummary: buildDoctorHealSummary(reportText),
|
|
70
|
+
structuredIssues: buildDoctorHealIssuePayload(structuredIssues),
|
|
69
71
|
scopeLabel: scope ?? "active milestone / blocking scope",
|
|
70
72
|
doctorCommandSuffix: scope ? ` ${scope}` : "",
|
|
71
73
|
});
|
|
72
|
-
const content =
|
|
73
|
-
|
|
74
|
+
const content = buildWorkflowDispatchContent({ workflow, workflowPath, task: prompt });
|
|
75
|
+
const savedTools = scopeGsdWorkflowToolsForDispatch(pi);
|
|
76
|
+
try {
|
|
77
|
+
pi.sendMessage({ customType: "gsd-doctor-heal", content, display: false }, { triggerTurn: true });
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
restoreGsdWorkflowTools(pi, savedTools);
|
|
81
|
+
}
|
|
74
82
|
}
|
|
75
83
|
/** Parse doctor command args into structured flags and positionals (pure, no I/O). */
|
|
76
84
|
export function parseDoctorArgs(args) {
|
|
@@ -213,11 +221,17 @@ export async function handleTriage(ctx, pi, basePath) {
|
|
|
213
221
|
});
|
|
214
222
|
const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(gsdHome(), "agent", "GSD-WORKFLOW.md");
|
|
215
223
|
const workflow = readFileSync(workflowPath, "utf-8");
|
|
216
|
-
pi
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
224
|
+
const savedTools = scopeGsdWorkflowToolsForDispatch(pi);
|
|
225
|
+
try {
|
|
226
|
+
pi.sendMessage({
|
|
227
|
+
customType: "gsd-triage",
|
|
228
|
+
content: buildWorkflowDispatchContent({ workflow, workflowPath, task: prompt }),
|
|
229
|
+
display: false,
|
|
230
|
+
}, { triggerTurn: true });
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
restoreGsdWorkflowTools(pi, savedTools);
|
|
234
|
+
}
|
|
221
235
|
}
|
|
222
236
|
export async function handleSteer(change, ctx, pi) {
|
|
223
237
|
const basePath = currentDirectoryRoot();
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @see D001 (module location), D002 (200K fallback), D003 (section-boundary truncation)
|
|
9
9
|
*/
|
|
10
|
-
import { getCharsPerToken } from "./token-counter.js";
|
|
10
|
+
import { getCharsPerToken, isAccurateCountingAvailable, countTokensSync, } from "./token-counter.js";
|
|
11
11
|
// ─── Budget ratio constants ──────────────────────────────────────────────────
|
|
12
12
|
// Percentages of total context window allocated to each budget category.
|
|
13
13
|
// These are applied after tokens→chars conversion.
|
|
@@ -23,6 +23,22 @@ const CHARS_PER_TOKEN = 4;
|
|
|
23
23
|
const DEFAULT_CONTEXT_WINDOW = 200_000;
|
|
24
24
|
/** Conservative effective context for Claude Code subscription routing (#4676) */
|
|
25
25
|
const CLAUDE_CODE_EFFECTIVE_CONTEXT_WINDOW = 200_000;
|
|
26
|
+
/**
|
|
27
|
+
* Cached empirical chars-per-token from a tiktoken probe, keyed by provider.
|
|
28
|
+
* countTokensSync's fallback path is provider-aware, so we cache per-provider
|
|
29
|
+
* to preserve that distinction once the encoder warms. The cl100k_base encoder
|
|
30
|
+
* itself gives a stable ratio for ASCII English so a single probe per provider
|
|
31
|
+
* key is sufficient. Empty map means "not yet probed" or "encoder unavailable".
|
|
32
|
+
*/
|
|
33
|
+
const _empiricalCharsPerTokenByProvider = new Map();
|
|
34
|
+
/**
|
|
35
|
+
* Test hook — clears the empirical chars-per-token cache so test cases that
|
|
36
|
+
* assert against the static char-ratio fallback aren't polluted by a prior
|
|
37
|
+
* tiktoken-warmed run in the same process. Production code must not call this.
|
|
38
|
+
*/
|
|
39
|
+
export function _resetEmpiricalCacheForTest() {
|
|
40
|
+
_empiricalCharsPerTokenByProvider.clear();
|
|
41
|
+
}
|
|
26
42
|
/** Percentage of context consumed before suggesting a continue-here checkpoint */
|
|
27
43
|
const CONTINUE_THRESHOLD_PERCENT = 70;
|
|
28
44
|
// ─── Task count bounds ───────────────────────────────────────────────────────
|
|
@@ -46,7 +62,26 @@ const TASK_COUNT_TIERS = [
|
|
|
46
62
|
export function computeBudgets(contextWindow, provider) {
|
|
47
63
|
const effectiveWindow = contextWindow > 0 ? contextWindow : DEFAULT_CONTEXT_WINDOW;
|
|
48
64
|
const charsPerToken = provider ? getCharsPerToken(provider) : CHARS_PER_TOKEN;
|
|
49
|
-
|
|
65
|
+
// Prefer the tiktoken encoder for total-char estimation when it has been
|
|
66
|
+
// warmed (initTokenCounter resolved). The cl100k_base ratio is stable for
|
|
67
|
+
// ASCII English, so probe once per provider and cache — computeBudgets is
|
|
68
|
+
// called multiple times per prompt build and the probe encode is otherwise
|
|
69
|
+
// wasted work.
|
|
70
|
+
let totalChars;
|
|
71
|
+
if (isAccurateCountingAvailable()) {
|
|
72
|
+
const providerKey = provider ?? "__default__";
|
|
73
|
+
let empirical = _empiricalCharsPerTokenByProvider.get(providerKey);
|
|
74
|
+
if (empirical === undefined) {
|
|
75
|
+
const probe = "the quick brown fox jumps over the lazy dog ".repeat(64);
|
|
76
|
+
const probeTokens = countTokensSync(probe, provider);
|
|
77
|
+
empirical = probeTokens > 0 ? probe.length / probeTokens : charsPerToken;
|
|
78
|
+
_empiricalCharsPerTokenByProvider.set(providerKey, empirical);
|
|
79
|
+
}
|
|
80
|
+
totalChars = effectiveWindow * empirical;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
totalChars = effectiveWindow * charsPerToken;
|
|
84
|
+
}
|
|
50
85
|
return {
|
|
51
86
|
summaryBudgetChars: Math.floor(totalChars * SUMMARY_RATIO),
|
|
52
87
|
inlineContextBudgetChars: Math.floor(totalChars * INLINE_CONTEXT_RATIO),
|