gsd-pi 2.80.0-dev.4ea7d80e7 → 2.80.0-dev.7582bf37a
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/claude-cli-check.d.ts +30 -0
- package/dist/claude-cli-check.js +18 -7
- package/dist/cli.js +0 -19
- package/dist/headless-query.d.ts +10 -0
- package/dist/headless-query.js +6 -4
- package/dist/loader-entrypoint.d.ts +8 -0
- package/dist/loader-entrypoint.js +27 -0
- package/dist/loader.js +2 -11
- package/dist/mcp-server.d.ts +1 -0
- package/dist/mcp-server.js +6 -3
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/GSD-WORKFLOW.md +2 -2
- package/dist/resources/extensions/claude-code-cli/readiness.js +18 -7
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +40 -3
- package/dist/resources/extensions/github-sync/sync.js +4 -1
- package/dist/resources/extensions/gsd/auto/loop.js +103 -9
- package/dist/resources/extensions/gsd/auto/phases.js +240 -139
- package/dist/resources/extensions/gsd/auto/resolve.js +29 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +22 -30
- 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-direct-dispatch.js +5 -32
- package/dist/resources/extensions/gsd/auto-dispatch.js +16 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +104 -86
- package/dist/resources/extensions/gsd/auto-prompts.js +214 -17
- package/dist/resources/extensions/gsd/auto-recovery.js +43 -1
- package/dist/resources/extensions/gsd/auto-start.js +238 -12
- 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 +209 -81
- package/dist/resources/extensions/gsd/auto.js +159 -44
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +99 -10
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +44 -37
- package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +37 -10
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +30 -20
- package/dist/resources/extensions/gsd/bootstrap/journal-tools.js +4 -1
- package/dist/resources/extensions/gsd/bootstrap/memory-tools.js +6 -4
- package/dist/resources/extensions/gsd/bootstrap/query-tools.js +5 -3
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +1 -1
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +319 -54
- package/dist/resources/extensions/gsd/bootstrap/sanitize-complete-milestone.js +4 -0
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +82 -23
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +19 -2
- 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/handlers/ops.js +2 -2
- package/dist/resources/extensions/gsd/commands-config.js +1 -1
- package/dist/resources/extensions/gsd/commands-eval-review.js +2 -2
- 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/dashboard-overlay.js +1 -1
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +92 -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/detection.js +106 -0
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +2 -0
- package/dist/resources/extensions/gsd/git-service.js +73 -5
- package/dist/resources/extensions/gsd/gsd-db.js +46 -13
- package/dist/resources/extensions/gsd/guided-flow.js +141 -46
- package/dist/resources/extensions/gsd/init-wizard.js +4 -1
- 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 +27 -23
- 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/slice-cadence.js +45 -2
- package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +15 -9
- package/dist/resources/extensions/gsd/tools/complete-milestone.js +6 -7
- package/dist/resources/extensions/gsd/tools/complete-task.js +1 -1
- 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-manager.js +16 -14
- package/dist/resources/extensions/gsd/worktree-resolver.js +90 -22
- package/dist/resources/skills/web-quality-audit/scripts/analyze.sh +0 -0
- 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 +14 -14
- 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 +2 -2
- package/dist/web/standalone/.next/required-server-files.json +1 -1
- package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +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/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +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 +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
- 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/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +14 -14
- 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/middleware.js +3 -3
- 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/8359.e059d86b255fce1c.js +10 -0
- package/dist/web/standalone/.next/static/chunks/app/{page-fab3ebb85b006001.js → page-752f1e2ebdaa3e45.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/{webpack-0481f1221120a7c6.js → webpack-de742b64187e13fe.js} +1 -1
- package/dist/web/standalone/server.js +1 -1
- package/dist/welcome-screen.d.ts +2 -0
- package/dist/welcome-screen.js +9 -7
- 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-ai/dist/providers/anthropic-auth.test.js +35 -13
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js +21 -11
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts +7 -0
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +9 -7
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js +23 -14
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +2 -0
- package/packages/pi-ai/dist/types.d.ts.map +1 -1
- package/packages/pi-ai/dist/types.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js +48 -21
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js +22 -21
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js +22 -21
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js.map +1 -1
- package/packages/pi-ai/src/providers/anthropic-auth.test.ts +39 -25
- package/packages/pi-ai/src/providers/anthropic-bearer-auth.test.ts +26 -22
- package/packages/pi-ai/src/providers/anthropic.ts +22 -9
- package/packages/pi-ai/src/providers/minimax-tool-name.test.ts +34 -21
- package/packages/pi-ai/src/types.ts +3 -0
- package/packages/pi-ai/src/utils/oauth/github-copilot.test.ts +56 -22
- package/packages/pi-ai/src/utils/oauth/google-antigravity.test.ts +24 -28
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.test.ts +24 -28
- 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 +30 -1
- 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 +17 -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 +52 -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 +6 -2
- 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 +41 -3
- 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 +81 -4
- 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/core/tools/bash-spawn-windows.test.js +22 -56
- package/packages/pi-coding-agent/dist/core/tools/bash-spawn-windows.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.js +3 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/edit.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/edit.js +12 -1
- package/packages/pi-coding-agent/dist/core/tools/edit.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/find.js +14 -6
- package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/grep.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/grep.js +12 -3
- package/packages/pi-coding-agent/dist/core/tools/grep.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/hashline-read.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/hashline-read.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/hashline-read.js +3 -1
- package/packages/pi-coding-agent/dist/core/tools/hashline-read.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts +2 -1
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.js +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/ls.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/ls.js +10 -3
- package/packages/pi-coding-agent/dist/core/tools/ls.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/read.js +3 -1
- package/packages/pi-coding-agent/dist/core/tools/read.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/spawn-shell-windows.test.js +7 -62
- package/packages/pi-coding-agent/dist/core/tools/spawn-shell-windows.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.js +115 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target-metadata.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target.d.ts +19 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target.js +20 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-target.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/write.d.ts +4 -0
- package/packages/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/write.js +9 -1
- package/packages/pi-coding-agent/dist/core/tools/write.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +89 -2
- 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/tool-card-cleanup-and-success-runtime.test.js +25 -1
- 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 +6 -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 +155 -7
- 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 +31 -6
- 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 +71 -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 +2 -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 +22 -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 +28 -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 +40 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +59 -7
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +6 -2
- 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 +44 -2
- 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 +92 -4
- 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/core/tools/bash-spawn-windows.test.ts +22 -66
- package/packages/pi-coding-agent/src/core/tools/bash.ts +4 -1
- package/packages/pi-coding-agent/src/core/tools/edit.ts +13 -1
- package/packages/pi-coding-agent/src/core/tools/find.ts +15 -6
- package/packages/pi-coding-agent/src/core/tools/grep.ts +13 -3
- package/packages/pi-coding-agent/src/core/tools/hashline-read.ts +4 -1
- package/packages/pi-coding-agent/src/core/tools/index.ts +8 -0
- package/packages/pi-coding-agent/src/core/tools/ls.ts +11 -3
- package/packages/pi-coding-agent/src/core/tools/read.ts +4 -1
- package/packages/pi-coding-agent/src/core/tools/spawn-shell-windows.test.ts +11 -72
- package/packages/pi-coding-agent/src/core/tools/tool-target-metadata.test.ts +127 -0
- package/packages/pi-coding-agent/src/core/tools/tool-target.ts +48 -0
- package/packages/pi-coding-agent/src/core/tools/write.ts +14 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +119 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +31 -1
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +180 -7
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +75 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +39 -8
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +24 -0
- package/packages/pi-coding-agent/src/resources/extensions/memory/storage-safety-guard.test.ts +31 -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/GSD-WORKFLOW.md +2 -2
- package/src/resources/extensions/claude-code-cli/readiness.ts +25 -7
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +42 -3
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +67 -0
- package/src/resources/extensions/github-sync/sync.ts +8 -1
- package/src/resources/extensions/github-sync/tests/sync-source.test.ts +6 -18
- package/src/resources/extensions/gsd/auto/loop-deps.ts +3 -2
- package/src/resources/extensions/gsd/auto/loop.ts +134 -16
- package/src/resources/extensions/gsd/auto/phases.ts +328 -200
- package/src/resources/extensions/gsd/auto/resolve.ts +42 -1
- package/src/resources/extensions/gsd/auto/run-unit.ts +28 -30
- 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-direct-dispatch.ts +8 -34
- package/src/resources/extensions/gsd/auto-dispatch.ts +16 -0
- package/src/resources/extensions/gsd/auto-post-unit.ts +117 -88
- package/src/resources/extensions/gsd/auto-prompts.ts +228 -16
- package/src/resources/extensions/gsd/auto-recovery.ts +54 -0
- package/src/resources/extensions/gsd/auto-start.ts +286 -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 +241 -72
- package/src/resources/extensions/gsd/auto.ts +208 -39
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +120 -8
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +45 -37
- package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +36 -10
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +32 -19
- package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +5 -1
- package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +7 -4
- package/src/resources/extensions/gsd/bootstrap/query-tools.ts +6 -3
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +1 -1
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +369 -54
- package/src/resources/extensions/gsd/bootstrap/sanitize-complete-milestone.ts +4 -0
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +90 -22
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +19 -2
- 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/handlers/ops.ts +4 -2
- package/src/resources/extensions/gsd/commands-config.ts +1 -1
- package/src/resources/extensions/gsd/commands-eval-review.ts +2 -2
- 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/dashboard-overlay.ts +1 -1
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +107 -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/detection.ts +128 -0
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +3 -0
- package/src/resources/extensions/gsd/git-service.ts +87 -10
- package/src/resources/extensions/gsd/gsd-db.ts +50 -13
- package/src/resources/extensions/gsd/guided-flow.ts +167 -53
- package/src/resources/extensions/gsd/init-wizard.ts +5 -1
- 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 +27 -23
- 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/slice-cadence.ts +49 -2
- package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +23 -9
- package/src/resources/extensions/gsd/tests/agent-end-retry.test.ts +59 -89
- package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +47 -172
- package/src/resources/extensions/gsd/tests/artifacts-table-preserved-on-cache-invalidate.test.ts +0 -35
- package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +35 -9
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +433 -11
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +80 -59
- package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +3 -47
- package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +76 -18
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +160 -11
- package/src/resources/extensions/gsd/tests/auto-pr-bugs.test.ts +54 -95
- package/src/resources/extensions/gsd/tests/auto-project-root-env.test.ts +67 -26
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +14 -1
- package/src/resources/extensions/gsd/tests/auto-remediate-slice-status.test.ts +32 -30
- package/src/resources/extensions/gsd/tests/auto-start-bootstrap-await-3420.test.ts +32 -128
- package/src/resources/extensions/gsd/tests/auto-start-clean-runtime-db-gated.test.ts +20 -54
- package/src/resources/extensions/gsd/tests/auto-start-cold-db-bootstrap.test.ts +20 -30
- package/src/resources/extensions/gsd/tests/auto-start-index-lock.test.ts +17 -29
- package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +138 -0
- package/src/resources/extensions/gsd/tests/auto-start-time-persistence.test.ts +21 -39
- package/src/resources/extensions/gsd/tests/auto-start-worktree-db-path.test.ts +15 -24
- package/src/resources/extensions/gsd/tests/auto-thinking-restore.test.ts +44 -29
- package/src/resources/extensions/gsd/tests/auto-warning-noise-regression.test.ts +39 -51
- package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +159 -213
- package/src/resources/extensions/gsd/tests/bootstrap-derive-state-db-open.test.ts +15 -32
- package/src/resources/extensions/gsd/tests/browser-teardown.test.ts +0 -41
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +97 -2
- package/src/resources/extensions/gsd/tests/clear-stale-autostart.test.ts +34 -27
- package/src/resources/extensions/gsd/tests/cmux.test.ts +51 -53
- package/src/resources/extensions/gsd/tests/cold-resume-db-reopen.test.ts +39 -61
- package/src/resources/extensions/gsd/tests/commands-config.test.ts +26 -19
- 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-milestone.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/complete-slice-composer.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/complete-task-normalize-lists.test.ts +29 -33
- package/src/resources/extensions/gsd/tests/completed-units-metrics-sync.test.ts +45 -108
- 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 +90 -31
- 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/cwd-fallback-hardening.test.ts +138 -0
- package/src/resources/extensions/gsd/tests/dashboard-custom-engine.test.ts +4 -68
- package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +4 -9
- package/src/resources/extensions/gsd/tests/deferred-milestone-dir-4996.test.ts +14 -65
- package/src/resources/extensions/gsd/tests/detection.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/discuss-tool-scoping.test.ts +44 -37
- package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +58 -40
- package/src/resources/extensions/gsd/tests/dispatch-guard-closed-status.test.ts +25 -15
- package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +313 -0
- package/src/resources/extensions/gsd/tests/dispatcher-stuck-planning.test.ts +35 -17
- package/src/resources/extensions/gsd/tests/error-success-mask.test.ts +16 -21
- package/src/resources/extensions/gsd/tests/est-annotation-timeout.test.ts +15 -82
- 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/flat-rate-routing-guard.test.ts +2 -20
- package/src/resources/extensions/gsd/tests/frontmatter-parse-noise.test.ts +18 -26
- package/src/resources/extensions/gsd/tests/init-skip-git.test.ts +9 -12
- package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/integration/commands-eval-review.integration.test.ts +4 -2
- package/src/resources/extensions/gsd/tests/integration/git-locale.test.ts +31 -20
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +66 -0
- package/src/resources/extensions/gsd/tests/integration/milestone-transition-worktree.test.ts +0 -47
- package/src/resources/extensions/gsd/tests/interactive-routing-bypass.test.ts +60 -202
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +13 -56
- 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/lazy-pi-tui-import.test.ts +44 -6
- package/src/resources/extensions/gsd/tests/memory-decay-factor.test.ts +90 -0
- package/src/resources/extensions/gsd/tests/memory-pressure-stuck-state.test.ts +21 -35
- 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/milestone-transition-state-rebuild.test.ts +79 -98
- package/src/resources/extensions/gsd/tests/model-unittype-mapping.test.ts +70 -278
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +34 -2
- package/src/resources/extensions/gsd/tests/needs-remediation-revalidation.test.ts +37 -30
- package/src/resources/extensions/gsd/tests/note-captures-executed.test.ts +32 -28
- 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/phantom-ghost-detection.test.ts +24 -37
- package/src/resources/extensions/gsd/tests/phantom-milestone-default-queued.test.ts +9 -24
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +91 -75
- 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/post-unit-state-rebuild.test.ts +36 -22
- package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +36 -30
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +45 -5
- package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +74 -4
- package/src/resources/extensions/gsd/tests/preferences-worktree-sync.test.ts +20 -22
- package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +130 -32
- package/src/resources/extensions/gsd/tests/project-root-cwd-crash.test.ts +18 -36
- package/src/resources/extensions/gsd/tests/projection-no-plan-overwrite.test.ts +35 -73
- package/src/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +76 -138
- 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 +70 -106
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +59 -161
- package/src/resources/extensions/gsd/tests/query-tools-db-open.test.ts +33 -29
- package/src/resources/extensions/gsd/tests/queue-auto-guard.test.ts +22 -196
- package/src/resources/extensions/gsd/tests/quick-auto-guard.test.ts +23 -93
- package/src/resources/extensions/gsd/tests/quick-external-gsd.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/quick-turn-end-cleanup.test.ts +50 -79
- package/src/resources/extensions/gsd/tests/reassess-default-optin.test.ts +27 -13
- package/src/resources/extensions/gsd/tests/remote-questions.test.ts +151 -251
- package/src/resources/extensions/gsd/tests/resource-loader-import-path.test.ts +41 -29
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +58 -69
- package/src/resources/extensions/gsd/tests/resume-dispatch-worktree.test.ts +32 -164
- package/src/resources/extensions/gsd/tests/right-sized-workflow-prompts.test.ts +192 -0
- package/src/resources/extensions/gsd/tests/run-uat-replay-cap.test.ts +57 -41
- 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-model-override.test.ts +14 -9
- 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/show-config-command.test.ts +44 -42
- package/src/resources/extensions/gsd/tests/signal-handlers.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/skip-slice-state-rebuild.test.ts +56 -24
- package/src/resources/extensions/gsd/tests/skipped-validation-db-atomicity.test.ts +51 -11
- package/src/resources/extensions/gsd/tests/slice-cadence.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/slice-context-injection.test.ts +66 -50
- package/src/resources/extensions/gsd/tests/slice-parallel-orchestrator.test.ts +68 -107
- package/src/resources/extensions/gsd/tests/slice-sequence-insert.test.ts +115 -42
- package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +21 -59
- package/src/resources/extensions/gsd/tests/smart-entry-draft.test.ts +25 -116
- package/src/resources/extensions/gsd/tests/sqlite-unavailable-gate.test.ts +21 -57
- package/src/resources/extensions/gsd/tests/stale-dirlistcache-4648.test.ts +29 -76
- package/src/resources/extensions/gsd/tests/stale-lockfile-recovery.test.ts +33 -24
- package/src/resources/extensions/gsd/tests/stale-slice-rows.test.ts +39 -30
- 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 +35 -40
- package/src/resources/extensions/gsd/tests/stop-auto-merge-back.test.ts +48 -46
- package/src/resources/extensions/gsd/tests/stop-auto-race-null-unit.test.ts +14 -102
- package/src/resources/extensions/gsd/tests/subagent-model-dispatch.test.ts +78 -232
- package/src/resources/extensions/gsd/tests/sync-worktree-skip-current.test.ts +32 -35
- 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-profile.test.ts +84 -309
- package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +291 -0
- package/src/resources/extensions/gsd/tests/triage-dispatch.test.ts +134 -341
- package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +136 -4
- package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +8 -25
- 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 -99
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +43 -36
- package/src/resources/extensions/gsd/tests/visualizer-data.test.ts +84 -444
- package/src/resources/extensions/gsd/tests/workflow-dispatch-claim.test.ts +142 -0
- package/src/resources/extensions/gsd/tests/workflow-logger-wiring.test.ts +44 -189
- package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +2 -57
- 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/worktree-db-same-file.test.ts +21 -44
- package/src/resources/extensions/gsd/tests/worktree-expected-warnings.test.ts +27 -26
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +38 -6
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/worktree-main-branch.test.ts +20 -18
- 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 +203 -4
- package/src/resources/extensions/gsd/tests/write-gate.test.ts +40 -1
- package/src/resources/extensions/gsd/tests/zero-slice-roadmap-guided.test.ts +19 -13
- package/src/resources/extensions/gsd/tools/complete-milestone.ts +14 -15
- package/src/resources/extensions/gsd/tools/complete-task.ts +1 -1
- 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-manager.ts +15 -4
- package/src/resources/extensions/gsd/worktree-resolver.ts +119 -20
- package/src/resources/skills/create-gsd-extension/templates/templates.test.ts +86 -40
- package/src/resources/skills/web-quality-audit/scripts/analyze.sh +0 -0
- package/dist/web/standalone/.next/static/chunks/8336.631939fb583761fa.js +0 -10
- /package/dist/web/standalone/.next/static/{vIAZSyxIuvqNkCvXt9oqb → Y9yOOsO4ZA5BPTOS8ixvP}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{vIAZSyxIuvqNkCvXt9oqb → Y9yOOsO4ZA5BPTOS8ixvP}/_ssgManifest.js +0 -0
|
@@ -16,7 +16,7 @@ import { invalidateAllCaches } from "./cache.js";
|
|
|
16
16
|
import { startAutoDetached } from "./auto.js";
|
|
17
17
|
import { clearLock } from "./crash-recovery.js";
|
|
18
18
|
import { assessInterruptedSession, formatInterruptedSessionRunningMessage, formatInterruptedSessionSummary, } from "./interrupted-session.js";
|
|
19
|
-
import { listUnitRuntimeRecords, clearUnitRuntimeRecord } from "./unit-runtime.js";
|
|
19
|
+
import { listUnitRuntimeRecords, clearUnitRuntimeRecord, isInFlightRuntimePhase } from "./unit-runtime.js";
|
|
20
20
|
import { resolveExpectedArtifactPath } from "./auto.js";
|
|
21
21
|
import { gsdHome } from "./gsd-home.js";
|
|
22
22
|
import { gsdRoot, milestonesDir, resolveMilestoneFile, resolveMilestonePath, resolveSliceFile, resolveSlicePath, resolveGsdRootFile, relGsdRootFile, relMilestoneFile, relSliceFile, clearPathCache, } from "./paths.js";
|
|
@@ -45,12 +45,32 @@ import { runPreparation, formatCodebaseBrief, formatPriorContextBrief, } from ".
|
|
|
45
45
|
import { verifyExpectedArtifact } from "./auto-recovery.js";
|
|
46
46
|
import { createWorkspace, scopeMilestone } from "./workspace.js";
|
|
47
47
|
import { getPendingGate, extractDepthVerificationMilestoneId } from "./bootstrap/write-gate.js";
|
|
48
|
+
export function shouldSkipGitBootstrapAfterInit(result) {
|
|
49
|
+
return result.gitEnabled === false;
|
|
50
|
+
}
|
|
48
51
|
// ─── Re-exports (preserve public API for existing importers) ────────────────
|
|
49
52
|
export { MILESTONE_ID_RE, generateMilestoneSuffix, nextMilestoneId, extractMilestoneSeq, parseMilestoneId, milestoneIdSort, maxMilestoneNum, findMilestoneIds, reserveMilestoneId, claimReservedId, getReservedMilestoneIds, clearReservedMilestoneIds, } from "./milestone-ids.js";
|
|
50
53
|
export { showQueue, handleQueueReorder, showQueueAdd, buildExistingMilestonesContext, } from "./guided-flow-queue.js";
|
|
51
54
|
import { logWarning } from "./workflow-logger.js";
|
|
52
55
|
import { deleteRuntimeKv } from "./db/runtime-kv.js";
|
|
53
56
|
import { PAUSED_SESSION_KV_KEY } from "./interrupted-session.js";
|
|
57
|
+
import { buildWorkflowDispatchContent } from "./workflow-protocol.js";
|
|
58
|
+
import { isFullGsdToolSurfaceRequested, restoreGsdWorkflowTools, scopeGsdWorkflowToolsForDispatch } from "./bootstrap/register-hooks.js";
|
|
59
|
+
function scheduleAutoStartAfterIdle(ctx, pi, basePath, verboseMode, options, launch = startAutoDetached) {
|
|
60
|
+
const waitForIdle = typeof ctx.waitForIdle === "function"
|
|
61
|
+
? ctx.waitForIdle.bind(ctx)
|
|
62
|
+
: async () => { };
|
|
63
|
+
void waitForIdle()
|
|
64
|
+
.then(() => {
|
|
65
|
+
setTimeout(() => launch(ctx, pi, basePath, verboseMode, options), 0);
|
|
66
|
+
})
|
|
67
|
+
.catch((err) => {
|
|
68
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
69
|
+
ctx.ui.notify(`Auto-start failed while waiting for the prior turn to settle: ${message}`, "error");
|
|
70
|
+
logWarning("guided", `auto-start idle wait failed: ${message}`);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export const _scheduleAutoStartAfterIdleForTest = scheduleAutoStartAfterIdle;
|
|
54
74
|
// ─── Scope-based validator wrappers ──────────────────────────────────────────
|
|
55
75
|
// These thin wrappers accept a MilestoneScope so callers that already hold a
|
|
56
76
|
// pinned scope never have to re-derive (basePath, milestoneId) separately.
|
|
@@ -71,6 +91,19 @@ export function verifyExpectedArtifactForScope(scope, unitType, unitId) {
|
|
|
71
91
|
export function resolveExpectedArtifactPathForScope(scope, unitType, unitId) {
|
|
72
92
|
return resolveExpectedArtifactPath(unitType, unitId, scope.workspace.projectRoot);
|
|
73
93
|
}
|
|
94
|
+
async function runQuickTaskChoice(ctx, pi) {
|
|
95
|
+
if (!ctx.hasUI) {
|
|
96
|
+
ctx.ui.notify("Run /gsd quick <task> for small bounded work, or /gsd do <task> for natural-language routing.", "info");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const task = (await ctx.ui.input("Quick task", "Describe the small task to run with /gsd quick"))?.trim();
|
|
100
|
+
if (!task) {
|
|
101
|
+
ctx.ui.notify("Quick task cancelled.", "info");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const { handleQuick } = await import("./quick.js");
|
|
105
|
+
await handleQuick(task, ctx, pi);
|
|
106
|
+
}
|
|
74
107
|
/**
|
|
75
108
|
* Scope-based overload of isGhostMilestone.
|
|
76
109
|
* Binds basePath and milestoneId from the scope, ensuring path resolution
|
|
@@ -101,6 +134,13 @@ function runPlanV2Gate(ctx, basePath, state) {
|
|
|
101
134
|
}
|
|
102
135
|
return "pass";
|
|
103
136
|
}
|
|
137
|
+
export const _needsPlanV2GateForTest = needsPlanV2Gate;
|
|
138
|
+
export const _runPlanV2GateForTest = runPlanV2Gate;
|
|
139
|
+
export function _roadmapHasParseableSlicesForTest(roadmapContent) {
|
|
140
|
+
if (!roadmapContent)
|
|
141
|
+
return false;
|
|
142
|
+
return parseRoadmapSlices(roadmapContent).length > 0;
|
|
143
|
+
}
|
|
104
144
|
// ─── Commit Instruction Helpers ──────────────────────────────────────────────
|
|
105
145
|
/** Build commit instruction for planning prompts. .gsd/ is managed externally and always gitignored. */
|
|
106
146
|
function buildDocsCommitInstruction(_message) {
|
|
@@ -124,7 +164,7 @@ const USER_DRIVEN_DEEP_SETUP_UNITS = new Set([
|
|
|
124
164
|
"discuss-requirements",
|
|
125
165
|
"research-decision",
|
|
126
166
|
]);
|
|
127
|
-
const FOREGROUND_DEEP_SETUP_RULE_NAMES = new Set([
|
|
167
|
+
export const FOREGROUND_DEEP_SETUP_RULE_NAMES = new Set([
|
|
128
168
|
"deep: pre-planning (no workflow prefs) → workflow-preferences",
|
|
129
169
|
"deep: pre-planning (no PROJECT) → discuss-project",
|
|
130
170
|
"deep: pre-planning (no REQUIREMENTS) → discuss-requirements",
|
|
@@ -312,7 +352,7 @@ async function dispatchNextDeepProjectSetupStage(entry) {
|
|
|
312
352
|
const { DISPATCH_RULES, hasPendingDeepStage } = await import("./auto-dispatch.js");
|
|
313
353
|
if (!hasPendingDeepStage(prefs, entry.basePath)) {
|
|
314
354
|
pendingDeepProjectSetupMap.delete(entry.basePath);
|
|
315
|
-
|
|
355
|
+
scheduleAutoStartAfterIdle(entry.ctx, entry.pi, entry.basePath, false, { step: entry.step });
|
|
316
356
|
return true;
|
|
317
357
|
}
|
|
318
358
|
const state = await deriveState(entry.basePath);
|
|
@@ -346,14 +386,14 @@ async function dispatchNextDeepProjectSetupStage(entry) {
|
|
|
346
386
|
}
|
|
347
387
|
else if (hasPendingDeepStage(prefs, entry.basePath)) {
|
|
348
388
|
pendingDeepProjectSetupMap.delete(entry.basePath);
|
|
349
|
-
|
|
389
|
+
scheduleAutoStartAfterIdle(entry.ctx, entry.pi, entry.basePath, false, { step: entry.step });
|
|
350
390
|
return true;
|
|
351
391
|
}
|
|
352
392
|
return false;
|
|
353
393
|
}
|
|
354
394
|
if (!USER_DRIVEN_DEEP_SETUP_UNITS.has(result.unitType)) {
|
|
355
395
|
pendingDeepProjectSetupMap.delete(entry.basePath);
|
|
356
|
-
|
|
396
|
+
scheduleAutoStartAfterIdle(entry.ctx, entry.pi, entry.basePath, false, { step: entry.step });
|
|
357
397
|
return true;
|
|
358
398
|
}
|
|
359
399
|
entry.currentUnitType = result.unitType;
|
|
@@ -531,7 +571,7 @@ export function checkAutoStartAfterDiscuss() {
|
|
|
531
571
|
}
|
|
532
572
|
pendingAutoStartMap.delete(basePath);
|
|
533
573
|
ctx.ui.notify(`Milestone ${milestoneId} ready.`, "success");
|
|
534
|
-
|
|
574
|
+
scheduleAutoStartAfterIdle(ctx, pi, basePath, false, { step });
|
|
535
575
|
return true;
|
|
536
576
|
}
|
|
537
577
|
/**
|
|
@@ -817,40 +857,58 @@ async function dispatchWorkflow(pi, note, customType = "gsd-run", ctx, unitType)
|
|
|
817
857
|
return;
|
|
818
858
|
}
|
|
819
859
|
}
|
|
820
|
-
// Scope tools for
|
|
860
|
+
// Scope tools for guided workflow turns (#2949, token-consumption savings).
|
|
821
861
|
// Providers with grammar-based constrained decoding (xAI/Grok) return
|
|
822
862
|
// "Grammar is too complex" when the combined tool schema is too large.
|
|
823
|
-
//
|
|
824
|
-
//
|
|
863
|
+
// Guided workflow turns only need the active unit's tool surface; strip
|
|
864
|
+
// unrelated GSD tools and broad non-GSD tools for this queued turn, then
|
|
865
|
+
// restore so the narrowed surface does not leak into future dispatches.
|
|
825
866
|
let savedTools = null;
|
|
826
|
-
|
|
867
|
+
try {
|
|
827
868
|
const currentTools = pi.getActiveTools();
|
|
828
|
-
savedTools =
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
869
|
+
savedTools = {
|
|
870
|
+
tools: currentTools,
|
|
871
|
+
visibleSkills: typeof pi.getVisibleSkills === "function" ? pi.getVisibleSkills() : undefined,
|
|
872
|
+
restoreVisibleSkills: typeof pi.setVisibleSkills === "function",
|
|
873
|
+
};
|
|
874
|
+
if (unitType?.startsWith("discuss-") && !isFullGsdToolSurfaceRequested()) {
|
|
875
|
+
// Keep all non-GSD tools (builtins, other extensions) and only the
|
|
876
|
+
// GSD tools on the discuss allowlist.
|
|
877
|
+
const scopedTools = currentTools.filter((t) => !t.startsWith("gsd_") || DISCUSS_TOOLS_ALLOWLIST.includes(t));
|
|
878
|
+
pi.setActiveTools(scopedTools);
|
|
879
|
+
const scopedState = scopeGsdWorkflowToolsForDispatch(pi, unitType);
|
|
880
|
+
savedTools = {
|
|
881
|
+
tools: currentTools,
|
|
882
|
+
visibleSkills: scopedState?.visibleSkills ?? savedTools.visibleSkills,
|
|
883
|
+
restoreVisibleSkills: scopedState?.restoreVisibleSkills ?? savedTools.restoreVisibleSkills,
|
|
884
|
+
};
|
|
885
|
+
debugLog("discuss-tool-scoping", {
|
|
886
|
+
unitType,
|
|
887
|
+
before: currentTools.length,
|
|
888
|
+
after: pi.getActiveTools().length,
|
|
889
|
+
removed: currentTools.length - pi.getActiveTools().length,
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
savedTools = scopeGsdWorkflowToolsForDispatch(pi, unitType) ?? savedTools;
|
|
894
|
+
}
|
|
895
|
+
const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(gsdHome(), "agent", "GSD-WORKFLOW.md");
|
|
896
|
+
const workflow = readFileSync(workflowPath, "utf-8");
|
|
897
|
+
pi.sendMessage({
|
|
898
|
+
customType,
|
|
899
|
+
content: buildWorkflowDispatchContent({ workflow, workflowPath, task: note }),
|
|
900
|
+
display: false,
|
|
901
|
+
}, { triggerTurn: true });
|
|
902
|
+
}
|
|
903
|
+
finally {
|
|
904
|
+
// Restore full tool set after the message is queued. The LLM turn has
|
|
905
|
+
// already captured the scoped set — restoring prevents the narrowed
|
|
906
|
+
// tools from leaking into subsequent dispatches (#3628). The finally
|
|
907
|
+
// block ensures restoration even if sendMessage throws.
|
|
908
|
+
restoreGsdWorkflowTools(pi, savedTools);
|
|
852
909
|
}
|
|
853
910
|
}
|
|
911
|
+
export const _dispatchWorkflowForTest = dispatchWorkflow;
|
|
854
912
|
function getStructuredQuestionsAvailability(pi, ctx) {
|
|
855
913
|
if (!ctx)
|
|
856
914
|
return "false";
|
|
@@ -1469,8 +1527,8 @@ function selfHealRuntimeRecords(basePath, ctx) {
|
|
|
1469
1527
|
cleared++;
|
|
1470
1528
|
continue;
|
|
1471
1529
|
}
|
|
1472
|
-
// Clear records stuck in
|
|
1473
|
-
if (phase
|
|
1530
|
+
// Clear records stuck in an in-flight phase (process died mid-unit).
|
|
1531
|
+
if (isInFlightRuntimePhase(phase)) {
|
|
1474
1532
|
clearUnitRuntimeRecord(basePath, unitType, unitId);
|
|
1475
1533
|
cleared++;
|
|
1476
1534
|
}
|
|
@@ -1619,7 +1677,7 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
|
|
|
1619
1677
|
const result = await showProjectInit(ctx, pi, basePath, detection);
|
|
1620
1678
|
if (!result.completed)
|
|
1621
1679
|
return; // User cancelled
|
|
1622
|
-
skipGitBootstrap = result
|
|
1680
|
+
skipGitBootstrap = shouldSkipGitBootstrapAfterInit(result);
|
|
1623
1681
|
// Init wizard bootstrapped .gsd/ — fall through to the normal flow below
|
|
1624
1682
|
// which will detect "no milestones" and start the discuss prompt
|
|
1625
1683
|
}
|
|
@@ -1695,6 +1753,20 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
|
|
|
1695
1753
|
return;
|
|
1696
1754
|
}
|
|
1697
1755
|
}
|
|
1756
|
+
if (interrupted.classification !== "recoverable") {
|
|
1757
|
+
try {
|
|
1758
|
+
const { autoImportMarkdownHierarchyIfDbMismatch } = await import("./migration-auto-check.js");
|
|
1759
|
+
const result = await autoImportMarkdownHierarchyIfDbMismatch(basePath);
|
|
1760
|
+
if (result.action === "imported") {
|
|
1761
|
+
ctx.ui.notify(`Recovered migrated planning state into gsd.db (${result.reason}): ${result.afterDb.milestones} milestone(s), ${result.afterDb.slices} slice(s), ${result.afterDb.tasks} task(s).`, "info");
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
catch (err) {
|
|
1765
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1766
|
+
ctx.ui.notify(`GSD could not auto-import existing planning state into gsd.db: ${message}`, "warning");
|
|
1767
|
+
logWarning("guided", `planning state auto-import failed: ${message}`, { file: "guided-flow.ts" });
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1698
1770
|
// Always derive from the project root — the assessment may have derived
|
|
1699
1771
|
// state from a worktree path that was cleaned up in the stale branch above.
|
|
1700
1772
|
const state = await deriveState(basePath);
|
|
@@ -1780,16 +1852,24 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
|
|
|
1780
1852
|
title: "GSD — Get Shit Done",
|
|
1781
1853
|
summary: ["No active milestone."],
|
|
1782
1854
|
actions: [
|
|
1855
|
+
{
|
|
1856
|
+
id: "quick_task",
|
|
1857
|
+
label: "Quick task",
|
|
1858
|
+
description: "For small bounded work, run /gsd quick <task> or /gsd do <task>.",
|
|
1859
|
+
recommended: true,
|
|
1860
|
+
},
|
|
1783
1861
|
{
|
|
1784
1862
|
id: "new_milestone",
|
|
1785
1863
|
label: "Create next milestone",
|
|
1786
|
-
description: "Define
|
|
1787
|
-
recommended: true,
|
|
1864
|
+
description: "Define a larger body of work with planning artifacts.",
|
|
1788
1865
|
},
|
|
1789
1866
|
],
|
|
1790
1867
|
notYetMessage: "Run /gsd when ready.",
|
|
1791
1868
|
});
|
|
1792
|
-
if (choice === "
|
|
1869
|
+
if (choice === "quick_task") {
|
|
1870
|
+
await runQuickTaskChoice(ctx, pi);
|
|
1871
|
+
}
|
|
1872
|
+
else if (choice === "new_milestone") {
|
|
1793
1873
|
setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode });
|
|
1794
1874
|
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId, `New milestone ${nextId}.`, basePath), "gsd-run", ctx, "discuss-milestone");
|
|
1795
1875
|
}
|
|
@@ -1809,11 +1889,16 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
|
|
|
1809
1889
|
title: `GSD — ${milestoneId}: ${milestoneTitle}`,
|
|
1810
1890
|
summary: ["All milestones complete."],
|
|
1811
1891
|
actions: [
|
|
1892
|
+
{
|
|
1893
|
+
id: "quick_task",
|
|
1894
|
+
label: "Quick task",
|
|
1895
|
+
description: "Do a small bounded task without opening a milestone.",
|
|
1896
|
+
recommended: true,
|
|
1897
|
+
},
|
|
1812
1898
|
{
|
|
1813
1899
|
id: "new_milestone",
|
|
1814
1900
|
label: "Start new milestone",
|
|
1815
1901
|
description: "Define and plan the next milestone.",
|
|
1816
|
-
recommended: true,
|
|
1817
1902
|
},
|
|
1818
1903
|
{
|
|
1819
1904
|
id: "status",
|
|
@@ -1823,7 +1908,10 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
|
|
|
1823
1908
|
],
|
|
1824
1909
|
notYetMessage: "Run /gsd when ready.",
|
|
1825
1910
|
});
|
|
1826
|
-
if (choice === "
|
|
1911
|
+
if (choice === "quick_task") {
|
|
1912
|
+
await runQuickTaskChoice(ctx, pi);
|
|
1913
|
+
}
|
|
1914
|
+
else if (choice === "new_milestone") {
|
|
1827
1915
|
const milestoneIds = findMilestoneIds(basePath);
|
|
1828
1916
|
const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
|
|
1829
1917
|
const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds, basePath);
|
|
@@ -1907,8 +1995,7 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
|
|
|
1907
1995
|
if (hasRoadmap) {
|
|
1908
1996
|
const roadmapContent = await loadFile(roadmapFile);
|
|
1909
1997
|
if (roadmapContent) {
|
|
1910
|
-
|
|
1911
|
-
roadmapHasSlices = parsed.length > 0;
|
|
1998
|
+
roadmapHasSlices = _roadmapHasParseableSlicesForTest(roadmapContent);
|
|
1912
1999
|
}
|
|
1913
2000
|
}
|
|
1914
2001
|
if (!hasRoadmap || !roadmapHasSlices) {
|
|
@@ -1916,13 +2003,18 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
|
|
|
1916
2003
|
const contextFile = resolveMilestoneFile(basePath, milestoneId, "CONTEXT");
|
|
1917
2004
|
const hasContext = !!(contextFile && await loadFile(contextFile));
|
|
1918
2005
|
const actions = [
|
|
2006
|
+
{
|
|
2007
|
+
id: "quick_task",
|
|
2008
|
+
label: "Quick task instead",
|
|
2009
|
+
description: "Use this when the work is small and should not become a milestone.",
|
|
2010
|
+
recommended: true,
|
|
2011
|
+
},
|
|
1919
2012
|
{
|
|
1920
2013
|
id: "plan",
|
|
1921
2014
|
label: "Create roadmap",
|
|
1922
2015
|
description: hasContext
|
|
1923
2016
|
? "Context captured. Decompose into slices with a boundary map."
|
|
1924
2017
|
: "Decompose the milestone into slices with a boundary map.",
|
|
1925
|
-
recommended: true,
|
|
1926
2018
|
},
|
|
1927
2019
|
...(!hasContext ? [{
|
|
1928
2020
|
id: "discuss",
|
|
@@ -1946,7 +2038,10 @@ export async function showSmartEntry(ctx, pi, basePath, options) {
|
|
|
1946
2038
|
actions,
|
|
1947
2039
|
notYetMessage: "Run /gsd when ready.",
|
|
1948
2040
|
});
|
|
1949
|
-
if (choice === "
|
|
2041
|
+
if (choice === "quick_task") {
|
|
2042
|
+
await runQuickTaskChoice(ctx, pi);
|
|
2043
|
+
}
|
|
2044
|
+
else if (choice === "plan") {
|
|
1950
2045
|
setPendingAutoStart(basePath, { ctx, pi, basePath, milestoneId, step: stepMode });
|
|
1951
2046
|
await dispatchWorkflow(pi, await buildPlanMilestonePrompt(milestoneId, milestoneTitle, basePath), "gsd-run", ctx, "plan-milestone");
|
|
1952
2047
|
}
|
|
@@ -15,6 +15,9 @@ import { assertSafeDirectory } from "./validate-directory.js";
|
|
|
15
15
|
import { runSkillInstallStep } from "./skill-catalog.js";
|
|
16
16
|
import { generateCodebaseMap, writeCodebaseMap } from "./codebase-generator.js";
|
|
17
17
|
import { handlePrefsWizard, writePreferencesFile } from "./commands-prefs-wizard.js";
|
|
18
|
+
export function shouldWriteGitFiles(gitEnabled) {
|
|
19
|
+
return gitEnabled;
|
|
20
|
+
}
|
|
18
21
|
// ─── Defaults ───────────────────────────────────────────────────────────────────
|
|
19
22
|
const DEFAULT_PREFS = {
|
|
20
23
|
mode: "solo",
|
|
@@ -247,7 +250,7 @@ export async function showProjectInit(ctx, pi, basePath, detection) {
|
|
|
247
250
|
}
|
|
248
251
|
// Ensure .gitignore only when git is active. A user who selected "Skip"
|
|
249
252
|
// should not have git initialized or git-related files mutated later.
|
|
250
|
-
if (gitEnabled) {
|
|
253
|
+
if (shouldWriteGitFiles(gitEnabled)) {
|
|
251
254
|
ensureGitignore(basePath);
|
|
252
255
|
untrackRuntimeFiles(basePath);
|
|
253
256
|
}
|
|
@@ -14,6 +14,27 @@ const CATEGORY_PRIORITY = {
|
|
|
14
14
|
environment: 4,
|
|
15
15
|
preference: 5,
|
|
16
16
|
};
|
|
17
|
+
// ─── Scoring Helpers ─────────────────────────────────────────────────────────
|
|
18
|
+
/**
|
|
19
|
+
* Time-decay factor for memory relevance scoring.
|
|
20
|
+
* Returns 1.0 for never-hit or recently-hit memories, decaying linearly to
|
|
21
|
+
* 0.7 for memories not accessed in 90+ days. Floor at 0.7 keeps old-but-valid
|
|
22
|
+
* knowledge from being fully suppressed.
|
|
23
|
+
*
|
|
24
|
+
* Defensive parsing: invalid timestamp strings (NaN from Date.parse) are
|
|
25
|
+
* treated as "no decay" rather than propagating NaN into score arithmetic.
|
|
26
|
+
* Future timestamps (clock skew, manual DB edits) clamp to daysAgo=0 so the
|
|
27
|
+
* factor stays in the documented [0.7, 1.0] contract.
|
|
28
|
+
*/
|
|
29
|
+
export function memoryDecayFactor(lastHitAt) {
|
|
30
|
+
if (!lastHitAt)
|
|
31
|
+
return 1.0;
|
|
32
|
+
const ts = Date.parse(lastHitAt);
|
|
33
|
+
if (!Number.isFinite(ts))
|
|
34
|
+
return 1.0;
|
|
35
|
+
const daysAgo = Math.max(0, (Date.now() - ts) / 86_400_000);
|
|
36
|
+
return Math.max(0.7, 1.0 - 0.3 * Math.min(1.0, daysAgo / 90));
|
|
37
|
+
}
|
|
17
38
|
// ─── Row Mapping ────────────────────────────────────────────────────────────
|
|
18
39
|
function rowToMemory(row) {
|
|
19
40
|
return {
|
|
@@ -31,6 +52,7 @@ function rowToMemory(row) {
|
|
|
31
52
|
scope: row['scope'] ?? 'project',
|
|
32
53
|
tags: parseTags(row['tags']),
|
|
33
54
|
structured_fields: parseStructuredFields(row['structured_fields']),
|
|
55
|
+
last_hit_at: row['last_hit_at'] ?? null,
|
|
34
56
|
};
|
|
35
57
|
}
|
|
36
58
|
function parseStructuredFields(raw) {
|
|
@@ -114,15 +136,37 @@ export function queryMemoriesRanked(opts) {
|
|
|
114
136
|
? semanticSearch(adapter, opts.queryVector, activeClause, 50)
|
|
115
137
|
: [];
|
|
116
138
|
if (keywordHits.length === 0 && semanticHits.length === 0 && !trimmedQuery) {
|
|
117
|
-
// No query at all —
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
139
|
+
// No query at all — return top-k by decay-aware ranked score.
|
|
140
|
+
//
|
|
141
|
+
// Build the candidate pool from a direct SQL query that honors the
|
|
142
|
+
// request's activeClause (i.e. include_superseded). Using
|
|
143
|
+
// getActiveMemoriesRanked here would silently drop superseded rows even
|
|
144
|
+
// when the caller explicitly opted in, and would slice by raw score
|
|
145
|
+
// before decay/filters had a chance to reorder.
|
|
146
|
+
const candidatePool = Math.min(Math.max(k * 5, 50), 500);
|
|
147
|
+
const rows = adapter
|
|
148
|
+
.prepare(`SELECT * FROM memories ${activeClause}
|
|
149
|
+
ORDER BY (confidence * (1.0 + hit_count * 0.1)) DESC
|
|
150
|
+
LIMIT :limit`)
|
|
151
|
+
.all({ ':limit': candidatePool });
|
|
152
|
+
const ranked = [];
|
|
153
|
+
for (const row of rows) {
|
|
154
|
+
const memory = rowToMemory(row);
|
|
155
|
+
if (!passesFilters(memory, opts))
|
|
156
|
+
continue;
|
|
157
|
+
const decay = memoryDecayFactor(memory.last_hit_at);
|
|
158
|
+
const score = memory.confidence * (1 + memory.hit_count * 0.1) * decay;
|
|
159
|
+
ranked.push({
|
|
160
|
+
memory,
|
|
161
|
+
score,
|
|
162
|
+
keywordRank: null,
|
|
163
|
+
semanticRank: null,
|
|
164
|
+
confidenceBoost: score,
|
|
165
|
+
reason: 'ranked',
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
ranked.sort((a, b) => b.score - a.score);
|
|
169
|
+
return ranked.slice(0, k);
|
|
126
170
|
}
|
|
127
171
|
// 3) Reciprocal rank fusion — each hit contributes 1/(rrfK + rank).
|
|
128
172
|
const fused = new Map();
|
|
@@ -155,7 +199,7 @@ export function queryMemoriesRanked(opts) {
|
|
|
155
199
|
for (const entry of fused.values()) {
|
|
156
200
|
if (!passesFilters(entry.memory, opts))
|
|
157
201
|
continue;
|
|
158
|
-
const boost = entry.memory.confidence * (1 + entry.memory.hit_count * 0.1);
|
|
202
|
+
const boost = entry.memory.confidence * (1 + entry.memory.hit_count * 0.1) * memoryDecayFactor(entry.memory.last_hit_at);
|
|
159
203
|
const reason = entry.kwRank != null && entry.semRank != null
|
|
160
204
|
? 'both'
|
|
161
205
|
: entry.kwRank != null
|
|
@@ -194,6 +238,7 @@ function passesFilters(memory, filters) {
|
|
|
194
238
|
}
|
|
195
239
|
return true;
|
|
196
240
|
}
|
|
241
|
+
let ftsWarningEmitted = false;
|
|
197
242
|
function keywordSearch(adapter, rawQuery, activeClause, limit) {
|
|
198
243
|
const ftsAvailable = isFtsAvailable(adapter);
|
|
199
244
|
if (ftsAvailable) {
|
|
@@ -215,14 +260,26 @@ function keywordSearch(adapter, rawQuery, activeClause, limit) {
|
|
|
215
260
|
// fall through to LIKE
|
|
216
261
|
}
|
|
217
262
|
}
|
|
218
|
-
// LIKE fallback — scans
|
|
263
|
+
// LIKE fallback — scans a capped candidate pool.
|
|
264
|
+
if (!ftsWarningEmitted) {
|
|
265
|
+
ftsWarningEmitted = true;
|
|
266
|
+
logWarning('memory-store', 'FTS5 unavailable — using LIKE fallback scan (consider enabling FTS5)');
|
|
267
|
+
}
|
|
219
268
|
const terms = rawQuery
|
|
220
269
|
.toLowerCase()
|
|
221
270
|
.split(/[^a-z0-9_]+/)
|
|
222
271
|
.filter((t) => t.length >= 2);
|
|
223
272
|
if (terms.length === 0)
|
|
224
273
|
return [];
|
|
225
|
-
const
|
|
274
|
+
const preScanCap = Math.min(limit * 20, 2000);
|
|
275
|
+
// ORDER BY confidence-weighted hit_count DESC so the cap keeps the most
|
|
276
|
+
// valuable candidates instead of the oldest-by-rowid (which would silently
|
|
277
|
+
// exclude recently-stored memories on tables larger than preScanCap).
|
|
278
|
+
const rows = adapter
|
|
279
|
+
.prepare(`SELECT * FROM memories ${activeClause}
|
|
280
|
+
ORDER BY (confidence * (1.0 + hit_count * 0.1)) DESC
|
|
281
|
+
LIMIT :preScanCap`)
|
|
282
|
+
.all({ ':preScanCap': preScanCap });
|
|
226
283
|
const scored = [];
|
|
227
284
|
for (const row of rows) {
|
|
228
285
|
const memory = rowToMemory(row);
|
|
@@ -15,6 +15,43 @@ import { fileURLToPath } from "node:url";
|
|
|
15
15
|
import { showNextAction } from "../../shared/tui.js";
|
|
16
16
|
import { validatePlanningDirectory, parsePlanningDirectory, transformToGSD, generatePreview, writeGSDDirectory, } from "./index.js";
|
|
17
17
|
import { homedir } from "node:os";
|
|
18
|
+
import { ensureDbOpen } from "../bootstrap/dynamic-tools.js";
|
|
19
|
+
import { clearEngineHierarchy, transaction } from "../gsd-db.js";
|
|
20
|
+
import { migrateFromMarkdown } from "../md-importer.js";
|
|
21
|
+
import { invalidateStateCache } from "../state.js";
|
|
22
|
+
function assertMigrationImportMatchesPreview(imported, preview) {
|
|
23
|
+
const mismatches = [];
|
|
24
|
+
if (imported.hierarchy.milestones !== preview.milestoneCount) {
|
|
25
|
+
mismatches.push(`milestones ${imported.hierarchy.milestones}/${preview.milestoneCount}`);
|
|
26
|
+
}
|
|
27
|
+
if (imported.hierarchy.slices !== preview.totalSlices) {
|
|
28
|
+
mismatches.push(`slices ${imported.hierarchy.slices}/${preview.totalSlices}`);
|
|
29
|
+
}
|
|
30
|
+
if (imported.hierarchy.tasks !== preview.totalTasks) {
|
|
31
|
+
mismatches.push(`tasks ${imported.hierarchy.tasks}/${preview.totalTasks}`);
|
|
32
|
+
}
|
|
33
|
+
if (imported.requirements !== preview.requirements.total) {
|
|
34
|
+
mismatches.push(`requirements ${imported.requirements}/${preview.requirements.total}`);
|
|
35
|
+
}
|
|
36
|
+
if (mismatches.length > 0) {
|
|
37
|
+
throw new Error(`migration DB import verification failed: ${mismatches.join(", ")}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function importWrittenMigrationToDb(basePath, preview) {
|
|
41
|
+
const opened = await ensureDbOpen(basePath);
|
|
42
|
+
if (!opened) {
|
|
43
|
+
throw new Error(`failed to open or create the GSD database at ${basePath}`);
|
|
44
|
+
}
|
|
45
|
+
const counts = transaction(() => {
|
|
46
|
+
clearEngineHierarchy();
|
|
47
|
+
const imported = migrateFromMarkdown(basePath);
|
|
48
|
+
if (preview)
|
|
49
|
+
assertMigrationImportMatchesPreview(imported, preview);
|
|
50
|
+
return imported;
|
|
51
|
+
});
|
|
52
|
+
invalidateStateCache();
|
|
53
|
+
return counts;
|
|
54
|
+
}
|
|
18
55
|
/** Format preview stats for embedding in the review prompt. */
|
|
19
56
|
function formatPreviewStats(preview) {
|
|
20
57
|
const lines = [
|
|
@@ -126,12 +163,14 @@ export async function handleMigrate(args, ctx, pi) {
|
|
|
126
163
|
ctx.ui.notify("Writing .gsd directory…", "info");
|
|
127
164
|
const result = await writeGSDDirectory(project, process.cwd());
|
|
128
165
|
const gsdPath = gsdRoot(process.cwd());
|
|
129
|
-
|
|
166
|
+
const imported = await importWrittenMigrationToDb(process.cwd(), preview);
|
|
167
|
+
ctx.ui.notify(`✓ Migration complete — ${result.paths.length} file(s) written to .gsd/ and ${imported.hierarchy.milestones}M/${imported.hierarchy.slices}S/${imported.hierarchy.tasks}T imported to the database`, "info");
|
|
130
168
|
// ── Post-write review offer ────────────────────────────────────────────────
|
|
131
169
|
const reviewChoice = await showNextAction(ctx, {
|
|
132
170
|
title: "Migration written",
|
|
133
171
|
summary: [
|
|
134
172
|
`${result.paths.length} files written to .gsd/`,
|
|
173
|
+
`${imported.hierarchy.milestones} milestone(s), ${imported.hierarchy.slices} slice(s), and ${imported.hierarchy.tasks} task(s) imported to gsd.db`,
|
|
135
174
|
"",
|
|
136
175
|
"The agent can now review the migrated output against GSD-2 standards —",
|
|
137
176
|
"checking structure, content quality, deriveState() round-trip, and",
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { ensureDbOpen } from "./bootstrap/dynamic-tools.js";
|
|
3
|
+
import { clearEngineHierarchy, getAllMilestones, getMilestoneSlices, getSliceTasks, isDbAvailable, transaction, } from "./gsd-db.js";
|
|
4
|
+
import { migrateHierarchyToDb } from "./md-importer.js";
|
|
5
|
+
import { parsePlan, parseRoadmap } from "./parsers-legacy.js";
|
|
6
|
+
import { milestonesDir, resolveMilestoneFile, resolveSliceFile, } from "./paths.js";
|
|
7
|
+
import { invalidateStateCache } from "./state.js";
|
|
8
|
+
function zeroCounts() {
|
|
9
|
+
return { milestones: 0, slices: 0, tasks: 0 };
|
|
10
|
+
}
|
|
11
|
+
function sameCounts(a, b) {
|
|
12
|
+
return a.milestones === b.milestones && a.slices === b.slices && a.tasks === b.tasks;
|
|
13
|
+
}
|
|
14
|
+
export function countMarkdownHierarchy(basePath) {
|
|
15
|
+
const root = milestonesDir(basePath);
|
|
16
|
+
if (!existsSync(root))
|
|
17
|
+
return zeroCounts();
|
|
18
|
+
const counts = zeroCounts();
|
|
19
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
20
|
+
if (!entry.isDirectory() || !/^M\d+/.test(entry.name))
|
|
21
|
+
continue;
|
|
22
|
+
counts.milestones++;
|
|
23
|
+
const roadmapPath = resolveMilestoneFile(basePath, entry.name, "ROADMAP");
|
|
24
|
+
if (!roadmapPath || !existsSync(roadmapPath))
|
|
25
|
+
continue;
|
|
26
|
+
const roadmap = parseRoadmap(readFileSync(roadmapPath, "utf-8"));
|
|
27
|
+
counts.slices += roadmap.slices.length;
|
|
28
|
+
for (const slice of roadmap.slices) {
|
|
29
|
+
const planPath = resolveSliceFile(basePath, entry.name, slice.id, "PLAN");
|
|
30
|
+
if (!planPath || !existsSync(planPath))
|
|
31
|
+
continue;
|
|
32
|
+
const plan = parsePlan(readFileSync(planPath, "utf-8"));
|
|
33
|
+
counts.tasks += plan.tasks.length;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return counts;
|
|
37
|
+
}
|
|
38
|
+
export function countDbHierarchy() {
|
|
39
|
+
if (!isDbAvailable())
|
|
40
|
+
return zeroCounts();
|
|
41
|
+
const counts = zeroCounts();
|
|
42
|
+
const milestones = getAllMilestones();
|
|
43
|
+
counts.milestones = milestones.length;
|
|
44
|
+
for (const milestone of milestones) {
|
|
45
|
+
const slices = getMilestoneSlices(milestone.id);
|
|
46
|
+
counts.slices += slices.length;
|
|
47
|
+
for (const slice of slices) {
|
|
48
|
+
counts.tasks += getSliceTasks(milestone.id, slice.id).length;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return counts;
|
|
52
|
+
}
|
|
53
|
+
export async function autoImportMarkdownHierarchyIfDbMismatch(basePath) {
|
|
54
|
+
const markdown = countMarkdownHierarchy(basePath);
|
|
55
|
+
if (sameCounts(markdown, zeroCounts())) {
|
|
56
|
+
return {
|
|
57
|
+
action: "none",
|
|
58
|
+
reason: "no-markdown",
|
|
59
|
+
markdown,
|
|
60
|
+
beforeDb: zeroCounts(),
|
|
61
|
+
afterDb: zeroCounts(),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const opened = await ensureDbOpen(basePath);
|
|
65
|
+
if (!opened || !isDbAvailable()) {
|
|
66
|
+
throw new Error(`failed to open or create the GSD database at ${basePath}`);
|
|
67
|
+
}
|
|
68
|
+
const beforeDb = countDbHierarchy();
|
|
69
|
+
if (sameCounts(markdown, beforeDb)) {
|
|
70
|
+
return { action: "none", reason: "in-sync", markdown, beforeDb, afterDb: beforeDb };
|
|
71
|
+
}
|
|
72
|
+
const reason = sameCounts(beforeDb, zeroCounts()) ? "db-empty" : "count-mismatch";
|
|
73
|
+
const imported = transaction(() => {
|
|
74
|
+
clearEngineHierarchy();
|
|
75
|
+
return migrateHierarchyToDb(basePath);
|
|
76
|
+
});
|
|
77
|
+
invalidateStateCache();
|
|
78
|
+
const afterDb = {
|
|
79
|
+
milestones: imported.milestones,
|
|
80
|
+
slices: imported.slices,
|
|
81
|
+
tasks: imported.tasks,
|
|
82
|
+
};
|
|
83
|
+
if (!sameCounts(markdown, afterDb)) {
|
|
84
|
+
throw new Error(`migration auto-import verification failed: markdown ${markdown.milestones}M/${markdown.slices}S/${markdown.tasks}T, db ${afterDb.milestones}M/${afterDb.slices}S/${afterDb.tasks}T`);
|
|
85
|
+
}
|
|
86
|
+
return { action: "imported", reason, markdown, beforeDb, afterDb };
|
|
87
|
+
}
|