gsd-pi 2.10.12 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled-extension-paths.d.ts +2 -0
- package/dist/bundled-extension-paths.js +10 -0
- package/dist/loader.js +45 -28
- package/dist/onboarding.js +100 -0
- package/dist/resource-loader.js +12 -3
- package/dist/resources/GSD-WORKFLOW.md +661 -0
- package/dist/resources/agents/researcher.md +29 -0
- package/dist/resources/agents/scout.md +56 -0
- package/dist/resources/agents/worker.md +31 -0
- package/dist/resources/extensions/ask-user-questions.ts +289 -0
- package/dist/resources/extensions/async-jobs/async-bash-tool.ts +211 -0
- package/dist/resources/extensions/async-jobs/await-tool.ts +101 -0
- package/dist/resources/extensions/async-jobs/cancel-job-tool.ts +34 -0
- package/dist/resources/extensions/async-jobs/index.ts +133 -0
- package/dist/resources/extensions/async-jobs/job-manager.ts +211 -0
- package/dist/resources/extensions/bg-shell/index.ts +3179 -0
- package/dist/resources/extensions/browser-tools/BROWSER-TOOLS-V2-PROPOSAL.md +1277 -0
- package/dist/resources/extensions/browser-tools/capture.ts +165 -0
- package/dist/resources/extensions/browser-tools/core.d.ts +205 -0
- package/dist/resources/extensions/browser-tools/core.js +1057 -0
- package/dist/resources/extensions/browser-tools/evaluate-helpers.ts +184 -0
- package/dist/resources/extensions/browser-tools/index.ts +51 -0
- package/dist/resources/extensions/browser-tools/lifecycle.ts +270 -0
- package/dist/resources/extensions/browser-tools/package.json +24 -0
- package/dist/resources/extensions/browser-tools/refs.ts +264 -0
- package/dist/resources/extensions/browser-tools/settle.ts +197 -0
- package/dist/resources/extensions/browser-tools/state.ts +408 -0
- package/dist/resources/extensions/browser-tools/tests/browser-tools-integration.test.mjs +652 -0
- package/dist/resources/extensions/browser-tools/tests/browser-tools-unit.test.cjs +614 -0
- package/dist/resources/extensions/browser-tools/tools/assertions.ts +342 -0
- package/dist/resources/extensions/browser-tools/tools/forms.ts +801 -0
- package/dist/resources/extensions/browser-tools/tools/inspection.ts +492 -0
- package/dist/resources/extensions/browser-tools/tools/intent.ts +614 -0
- package/dist/resources/extensions/browser-tools/tools/interaction.ts +865 -0
- package/dist/resources/extensions/browser-tools/tools/navigation.ts +232 -0
- package/dist/resources/extensions/browser-tools/tools/pages.ts +303 -0
- package/dist/resources/extensions/browser-tools/tools/refs.ts +541 -0
- package/dist/resources/extensions/browser-tools/tools/screenshot.ts +83 -0
- package/dist/resources/extensions/browser-tools/tools/session.ts +400 -0
- package/dist/resources/extensions/browser-tools/tools/wait.ts +247 -0
- package/dist/resources/extensions/browser-tools/utils.ts +660 -0
- package/dist/resources/extensions/context7/index.ts +428 -0
- package/dist/resources/extensions/context7/package.json +11 -0
- package/dist/resources/extensions/get-secrets-from-user.ts +625 -0
- package/dist/resources/extensions/google-search/index.ts +336 -0
- package/dist/resources/extensions/google-search/package.json +9 -0
- package/dist/resources/extensions/gsd/activity-log.ts +116 -0
- package/dist/resources/extensions/gsd/auto.ts +3732 -0
- package/dist/resources/extensions/gsd/commands.ts +544 -0
- package/dist/resources/extensions/gsd/crash-recovery.ts +105 -0
- package/dist/resources/extensions/gsd/dashboard-overlay.ts +564 -0
- package/dist/resources/extensions/gsd/dispatch-guard.ts +78 -0
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +278 -0
- package/dist/resources/extensions/gsd/doctor.ts +766 -0
- package/dist/resources/extensions/gsd/exit-command.ts +18 -0
- package/dist/resources/extensions/gsd/files.ts +857 -0
- package/dist/resources/extensions/gsd/git-service.ts +904 -0
- package/dist/resources/extensions/gsd/gitignore.ts +200 -0
- package/dist/resources/extensions/gsd/guided-flow.ts +1054 -0
- package/dist/resources/extensions/gsd/index.ts +735 -0
- package/dist/resources/extensions/gsd/metrics.ts +374 -0
- package/dist/resources/extensions/gsd/migrate/command.ts +218 -0
- package/dist/resources/extensions/gsd/migrate/index.ts +42 -0
- package/dist/resources/extensions/gsd/migrate/parser.ts +323 -0
- package/dist/resources/extensions/gsd/migrate/parsers.ts +624 -0
- package/dist/resources/extensions/gsd/migrate/preview.ts +48 -0
- package/dist/resources/extensions/gsd/migrate/transformer.ts +346 -0
- package/dist/resources/extensions/gsd/migrate/types.ts +370 -0
- package/dist/resources/extensions/gsd/migrate/validator.ts +55 -0
- package/dist/resources/extensions/gsd/migrate/writer.ts +539 -0
- package/dist/resources/extensions/gsd/native-git-bridge.ts +181 -0
- package/dist/resources/extensions/gsd/native-parser-bridge.ts +135 -0
- package/dist/resources/extensions/gsd/observability-validator.ts +408 -0
- package/dist/resources/extensions/gsd/package.json +11 -0
- package/dist/resources/extensions/gsd/paths.ts +339 -0
- package/dist/resources/extensions/gsd/post-unit-hooks.ts +449 -0
- package/dist/resources/extensions/gsd/preferences.ts +988 -0
- package/dist/resources/extensions/gsd/prompt-loader.ts +92 -0
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +25 -0
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +27 -0
- package/dist/resources/extensions/gsd/prompts/discuss.md +237 -0
- package/dist/resources/extensions/gsd/prompts/doctor-heal.md +29 -0
- package/dist/resources/extensions/gsd/prompts/execute-task.md +63 -0
- package/dist/resources/extensions/gsd/prompts/guided-complete-slice.md +3 -0
- package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +5 -0
- package/dist/resources/extensions/gsd/prompts/guided-discuss-slice.md +61 -0
- package/dist/resources/extensions/gsd/prompts/guided-execute-task.md +3 -0
- package/dist/resources/extensions/gsd/prompts/guided-plan-milestone.md +29 -0
- package/dist/resources/extensions/gsd/prompts/guided-plan-slice.md +3 -0
- package/dist/resources/extensions/gsd/prompts/guided-research-slice.md +13 -0
- package/dist/resources/extensions/gsd/prompts/guided-resume-task.md +1 -0
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +78 -0
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +55 -0
- package/dist/resources/extensions/gsd/prompts/queue.md +100 -0
- package/dist/resources/extensions/gsd/prompts/reassess-roadmap.md +48 -0
- package/dist/resources/extensions/gsd/prompts/replan-slice.md +39 -0
- package/dist/resources/extensions/gsd/prompts/research-milestone.md +37 -0
- package/dist/resources/extensions/gsd/prompts/research-slice.md +28 -0
- package/dist/resources/extensions/gsd/prompts/review-migration.md +66 -0
- package/dist/resources/extensions/gsd/prompts/run-uat.md +109 -0
- package/dist/resources/extensions/gsd/prompts/system.md +190 -0
- package/dist/resources/extensions/gsd/prompts/worktree-merge.md +123 -0
- package/dist/resources/extensions/gsd/roadmap-slices.ts +50 -0
- package/dist/resources/extensions/gsd/session-forensics.ts +500 -0
- package/dist/resources/extensions/gsd/skill-discovery.ts +137 -0
- package/dist/resources/extensions/gsd/state.ts +569 -0
- package/dist/resources/extensions/gsd/templates/context.md +76 -0
- package/dist/resources/extensions/gsd/templates/decisions.md +8 -0
- package/dist/resources/extensions/gsd/templates/milestone-summary.md +73 -0
- package/dist/resources/extensions/gsd/templates/plan.md +131 -0
- package/dist/resources/extensions/gsd/templates/preferences.md +23 -0
- package/dist/resources/extensions/gsd/templates/project.md +31 -0
- package/dist/resources/extensions/gsd/templates/reassessment.md +28 -0
- package/dist/resources/extensions/gsd/templates/requirements.md +81 -0
- package/dist/resources/extensions/gsd/templates/research.md +46 -0
- package/dist/resources/extensions/gsd/templates/roadmap.md +118 -0
- package/dist/resources/extensions/gsd/templates/secrets-manifest.md +22 -0
- package/dist/resources/extensions/gsd/templates/slice-context.md +58 -0
- package/dist/resources/extensions/gsd/templates/slice-summary.md +99 -0
- package/dist/resources/extensions/gsd/templates/state.md +19 -0
- package/dist/resources/extensions/gsd/templates/task-plan.md +52 -0
- package/dist/resources/extensions/gsd/templates/task-summary.md +57 -0
- package/dist/resources/extensions/gsd/templates/uat.md +54 -0
- package/dist/resources/extensions/gsd/tests/activity-log-prune.test.ts +297 -0
- package/dist/resources/extensions/gsd/tests/activity-log-save.test.ts +127 -0
- package/dist/resources/extensions/gsd/tests/auto-draft-pause.test.ts +109 -0
- package/dist/resources/extensions/gsd/tests/auto-preflight.test.ts +45 -0
- package/dist/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +196 -0
- package/dist/resources/extensions/gsd/tests/auto-supervisor.test.mjs +53 -0
- package/dist/resources/extensions/gsd/tests/collect-from-manifest.test.ts +469 -0
- package/dist/resources/extensions/gsd/tests/complete-milestone.test.ts +200 -0
- package/dist/resources/extensions/gsd/tests/cost-projection.test.ts +134 -0
- package/dist/resources/extensions/gsd/tests/derive-state-deps.test.ts +312 -0
- package/dist/resources/extensions/gsd/tests/derive-state-draft.test.ts +299 -0
- package/dist/resources/extensions/gsd/tests/derive-state.test.ts +660 -0
- package/dist/resources/extensions/gsd/tests/discuss-prompt.test.ts +27 -0
- package/dist/resources/extensions/gsd/tests/dispatch-guard.test.ts +91 -0
- package/dist/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +170 -0
- package/dist/resources/extensions/gsd/tests/doctor.test.ts +594 -0
- package/dist/resources/extensions/gsd/tests/draft-promotion.test.ts +169 -0
- package/dist/resources/extensions/gsd/tests/exit-command.test.ts +50 -0
- package/dist/resources/extensions/gsd/tests/git-service.test.ts +1788 -0
- package/dist/resources/extensions/gsd/tests/idle-recovery.test.ts +577 -0
- package/dist/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +580 -0
- package/dist/resources/extensions/gsd/tests/manifest-status.test.ts +283 -0
- package/dist/resources/extensions/gsd/tests/metrics-io.test.ts +176 -0
- package/dist/resources/extensions/gsd/tests/metrics.test.ts +188 -0
- package/dist/resources/extensions/gsd/tests/migrate-command.test.ts +369 -0
- package/dist/resources/extensions/gsd/tests/migrate-parser.test.ts +757 -0
- package/dist/resources/extensions/gsd/tests/migrate-transformer.test.ts +635 -0
- package/dist/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +414 -0
- package/dist/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +297 -0
- package/dist/resources/extensions/gsd/tests/migrate-writer.test.ts +398 -0
- package/dist/resources/extensions/gsd/tests/must-have-parser.test.ts +291 -0
- package/dist/resources/extensions/gsd/tests/network-error-fallback.test.ts +54 -0
- package/dist/resources/extensions/gsd/tests/next-milestone-id.test.ts +66 -0
- package/dist/resources/extensions/gsd/tests/orphaned-branch.test.ts +353 -0
- package/dist/resources/extensions/gsd/tests/parsers.test.ts +1664 -0
- package/dist/resources/extensions/gsd/tests/plan-milestone.test.ts +133 -0
- package/dist/resources/extensions/gsd/tests/plan-quality-validator.test.ts +363 -0
- package/dist/resources/extensions/gsd/tests/post-unit-hooks.test.ts +297 -0
- package/dist/resources/extensions/gsd/tests/preferences-hooks.test.ts +226 -0
- package/dist/resources/extensions/gsd/tests/queue-draft-detection.test.ts +126 -0
- package/dist/resources/extensions/gsd/tests/reassess-prompt.test.ts +142 -0
- package/dist/resources/extensions/gsd/tests/regex-hardening.test.ts +281 -0
- package/dist/resources/extensions/gsd/tests/remote-questions.test.ts +155 -0
- package/dist/resources/extensions/gsd/tests/remote-status.test.ts +99 -0
- package/dist/resources/extensions/gsd/tests/replan-slice.test.ts +493 -0
- package/dist/resources/extensions/gsd/tests/requirements.test.ts +106 -0
- package/dist/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +35 -0
- package/dist/resources/extensions/gsd/tests/resolve-ts.mjs +11 -0
- package/dist/resources/extensions/gsd/tests/roadmap-slices.test.ts +41 -0
- package/dist/resources/extensions/gsd/tests/run-uat.test.ts +316 -0
- package/dist/resources/extensions/gsd/tests/secure-env-collect.test.ts +185 -0
- package/dist/resources/extensions/gsd/tests/smart-entry-draft.test.ts +123 -0
- package/dist/resources/extensions/gsd/tests/test-helpers.ts +61 -0
- package/dist/resources/extensions/gsd/tests/unique-milestone-ids.test.ts +219 -0
- package/dist/resources/extensions/gsd/tests/unit-runtime.test.ts +234 -0
- package/dist/resources/extensions/gsd/tests/workspace-index.test.ts +75 -0
- package/dist/resources/extensions/gsd/tests/worktree-integration.test.ts +234 -0
- package/dist/resources/extensions/gsd/tests/worktree-manager.test.ts +141 -0
- package/dist/resources/extensions/gsd/tests/worktree.test.ts +597 -0
- package/dist/resources/extensions/gsd/tests/write-gate.test.ts +122 -0
- package/dist/resources/extensions/gsd/types.ts +296 -0
- package/dist/resources/extensions/gsd/unit-runtime.ts +184 -0
- package/dist/resources/extensions/gsd/workspace-index.ts +189 -0
- package/dist/resources/extensions/gsd/worktree-command.ts +845 -0
- package/dist/resources/extensions/gsd/worktree-manager.ts +459 -0
- package/dist/resources/extensions/gsd/{worktree.js → worktree.ts} +92 -61
- package/dist/resources/extensions/mac-tools/index.ts +852 -0
- package/dist/resources/extensions/mac-tools/swift-cli/Package.swift +22 -0
- package/dist/resources/extensions/mac-tools/swift-cli/Sources/main.swift +1318 -0
- package/dist/resources/extensions/mcporter/index.ts +429 -0
- package/dist/resources/extensions/remote-questions/config.ts +81 -0
- package/dist/resources/extensions/remote-questions/discord-adapter.ts +128 -0
- package/dist/resources/extensions/remote-questions/format.ts +163 -0
- package/dist/resources/extensions/remote-questions/manager.ts +192 -0
- package/dist/resources/extensions/remote-questions/remote-command.ts +361 -0
- package/dist/resources/extensions/remote-questions/slack-adapter.ts +92 -0
- package/dist/resources/extensions/remote-questions/status.ts +31 -0
- package/dist/resources/extensions/remote-questions/store.ts +77 -0
- package/dist/resources/extensions/remote-questions/types.ts +75 -0
- package/dist/resources/extensions/search-the-web/cache.ts +78 -0
- package/dist/resources/extensions/search-the-web/command-search-provider.ts +99 -0
- package/dist/resources/extensions/search-the-web/format.ts +258 -0
- package/dist/resources/extensions/search-the-web/http.ts +238 -0
- package/dist/resources/extensions/search-the-web/index.ts +65 -0
- package/dist/resources/extensions/search-the-web/native-search.ts +165 -0
- package/dist/resources/extensions/search-the-web/provider.ts +136 -0
- package/dist/resources/extensions/search-the-web/tavily.ts +116 -0
- package/dist/resources/extensions/search-the-web/tool-fetch-page.ts +581 -0
- package/dist/resources/extensions/search-the-web/tool-llm-context.ts +620 -0
- package/dist/resources/extensions/search-the-web/tool-search.ts +635 -0
- package/dist/resources/extensions/search-the-web/url-utils.ts +91 -0
- package/dist/resources/extensions/shared/bundled-extension-paths.ts +11 -0
- package/dist/resources/extensions/shared/confirm-ui.ts +126 -0
- package/dist/resources/extensions/shared/interview-ui.ts +613 -0
- package/dist/resources/extensions/shared/next-action-ui.ts +197 -0
- package/dist/resources/extensions/shared/progress-widget.ts +282 -0
- package/dist/resources/extensions/shared/terminal.ts +23 -0
- package/dist/resources/extensions/shared/thinking-widget.ts +107 -0
- package/dist/resources/extensions/shared/ui.ts +400 -0
- package/dist/resources/extensions/shared/wizard-ui.ts +551 -0
- package/dist/resources/extensions/slash-commands/audit.ts +88 -0
- package/dist/resources/extensions/slash-commands/clear.ts +10 -0
- package/dist/resources/extensions/slash-commands/create-extension.ts +297 -0
- package/dist/resources/extensions/slash-commands/create-slash-command.ts +234 -0
- package/dist/resources/extensions/slash-commands/index.ts +12 -0
- package/dist/resources/extensions/subagent/agents.ts +126 -0
- package/dist/resources/extensions/subagent/index.ts +1072 -0
- package/dist/resources/extensions/subagent/isolation.ts +498 -0
- package/dist/resources/extensions/ttsr/index.ts +163 -0
- package/dist/resources/extensions/ttsr/rule-loader.ts +121 -0
- package/dist/resources/extensions/ttsr/ttsr-interrupt.md +6 -0
- package/dist/resources/extensions/ttsr/ttsr-manager.ts +430 -0
- package/dist/resources/extensions/universal-config/discovery.ts +78 -0
- package/dist/resources/extensions/universal-config/format.ts +160 -0
- package/dist/resources/extensions/universal-config/index.ts +118 -0
- package/dist/resources/extensions/universal-config/package.json +11 -0
- package/dist/resources/extensions/universal-config/scanners.ts +579 -0
- package/dist/resources/extensions/universal-config/tests/discovery.test.ts +111 -0
- package/dist/resources/extensions/universal-config/tests/format.test.ts +111 -0
- package/dist/resources/extensions/universal-config/tests/scanners.test.ts +438 -0
- package/dist/resources/extensions/universal-config/tools.ts +60 -0
- package/dist/resources/extensions/universal-config/types.ts +116 -0
- package/dist/resources/extensions/voice/index.ts +271 -0
- package/dist/resources/extensions/voice/speech-recognizer.py +504 -0
- package/dist/resources/extensions/voice/speech-recognizer.swift +154 -0
- package/dist/resources/skills/debug-like-expert/SKILL.md +231 -0
- package/dist/resources/skills/debug-like-expert/references/debugging-mindset.md +253 -0
- package/dist/resources/skills/debug-like-expert/references/hypothesis-testing.md +373 -0
- package/dist/resources/skills/debug-like-expert/references/investigation-techniques.md +337 -0
- package/dist/resources/skills/debug-like-expert/references/verification-patterns.md +425 -0
- package/dist/resources/skills/debug-like-expert/references/when-to-research.md +361 -0
- package/dist/resources/skills/frontend-design/SKILL.md +45 -0
- package/dist/resources/skills/github-workflows/SKILL.md +92 -0
- package/dist/resources/skills/github-workflows/references/gh/SKILL.md +255 -0
- package/dist/resources/skills/github-workflows/references/gh/references/issue-stories.md +204 -0
- package/dist/resources/skills/github-workflows/references/gh/references/labels.md +170 -0
- package/dist/resources/skills/github-workflows/references/gh/references/milestones.md +158 -0
- package/dist/resources/skills/github-workflows/references/gh/references/projects-v2.md +177 -0
- package/dist/resources/skills/github-workflows/references/gh/scripts/experiment_cleanup.py +191 -0
- package/dist/resources/skills/github-workflows/references/gh/scripts/github_project_setup.py +799 -0
- package/dist/resources/skills/github-workflows/references/gh/tests/__init__.py +0 -0
- package/dist/resources/skills/github-workflows/references/gh/tests/test_github_project_setup.py +608 -0
- package/dist/resources/skills/swiftui/SKILL.md +208 -0
- package/dist/resources/skills/swiftui/references/animations.md +921 -0
- package/dist/resources/skills/swiftui/references/architecture.md +1561 -0
- package/dist/resources/skills/swiftui/references/layout-system.md +1186 -0
- package/dist/resources/skills/swiftui/references/navigation.md +1492 -0
- package/dist/resources/skills/swiftui/references/networking-async.md +214 -0
- package/dist/resources/skills/swiftui/references/performance.md +1706 -0
- package/dist/resources/skills/swiftui/references/platform-integration.md +204 -0
- package/dist/resources/skills/swiftui/references/state-management.md +1443 -0
- package/dist/resources/skills/swiftui/references/swiftdata.md +297 -0
- package/dist/resources/skills/swiftui/references/testing-debugging.md +247 -0
- package/dist/resources/skills/swiftui/references/uikit-appkit-interop.md +218 -0
- package/dist/resources/skills/swiftui/workflows/add-feature.md +191 -0
- package/dist/resources/skills/swiftui/workflows/build-new-app.md +311 -0
- package/dist/resources/skills/swiftui/workflows/debug-swiftui.md +192 -0
- package/dist/resources/skills/swiftui/workflows/optimize-performance.md +197 -0
- package/dist/resources/skills/swiftui/workflows/ship-app.md +203 -0
- package/dist/resources/skills/swiftui/workflows/write-tests.md +235 -0
- package/dist/wizard.js +1 -0
- package/package.json +8 -6
- package/packages/native/dist/fd/index.d.ts +1 -0
- package/packages/native/dist/fd/index.js +1 -0
- package/packages/native/dist/grep/index.d.ts +2 -1
- package/packages/native/dist/grep/index.js +1 -0
- package/packages/native/src/__tests__/fd.test.mjs +35 -0
- package/packages/native/src/__tests__/grep.test.mjs +26 -9
- package/packages/native/src/fd/index.ts +1 -0
- package/packages/native/src/grep/index.ts +3 -2
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +169 -55
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +13 -1
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +16 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/dist/types.d.ts +91 -1
- 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.ts +273 -63
- package/packages/pi-agent-core/src/agent.ts +24 -0
- package/packages/pi-agent-core/src/types.ts +98 -0
- package/packages/pi-ai/dist/env-api-keys.js +2 -0
- package/packages/pi-ai/dist/env-api-keys.js.map +1 -1
- package/packages/pi-ai/dist/models.generated.d.ts +314 -0
- package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.js +236 -0
- package/packages/pi-ai/dist/models.generated.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.js +6 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +2 -0
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +1 -1
- 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/src/env-api-keys.ts +2 -0
- package/packages/pi-ai/src/models.generated.ts +236 -0
- package/packages/pi-ai/src/providers/google-gemini-cli.ts +8 -0
- package/packages/pi-ai/src/providers/openai-completions.ts +3 -0
- package/packages/pi-ai/src/types.ts +2 -1
- package/packages/pi-coding-agent/dist/cli/args.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/cli/args.js +1 -0
- package/packages/pi-coding-agent/dist/cli/args.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +26 -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 +137 -22
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +20 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.js +43 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/fallback-resolver.d.ts +51 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.js +119 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.test.js +183 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/index.js +1 -0
- package/packages/pi-coding-agent/dist/core/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.js +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts +12 -1
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +37 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/session-manager.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.test.js +61 -0
- package/packages/pi-coding-agent/dist/core/session-manager.test.js.map +1 -0
- 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 +47 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/find.js +1 -0
- package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +6 -15
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +18 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +46 -4
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +25 -2
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/src/cli/args.ts +1 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +167 -22
- package/packages/pi-coding-agent/src/core/auth-storage.ts +45 -0
- package/packages/pi-coding-agent/src/core/fallback-resolver.test.ts +229 -0
- package/packages/pi-coding-agent/src/core/fallback-resolver.ts +165 -0
- package/packages/pi-coding-agent/src/core/index.ts +1 -0
- package/packages/pi-coding-agent/src/core/model-resolver.ts +1 -0
- package/packages/pi-coding-agent/src/core/session-manager.test.ts +65 -0
- package/packages/pi-coding-agent/src/core/session-manager.ts +51 -1
- package/packages/pi-coding-agent/src/core/settings-manager.ts +66 -0
- package/packages/pi-coding-agent/src/core/tools/find.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +6 -16
- package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +49 -4
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +28 -2
- package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -1
- package/packages/pi-tui/dist/autocomplete.js +3 -4
- package/packages/pi-tui/dist/autocomplete.js.map +1 -1
- package/packages/pi-tui/dist/components/editor.d.ts +7 -0
- package/packages/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/editor.js +57 -50
- package/packages/pi-tui/dist/components/editor.js.map +1 -1
- package/packages/pi-tui/src/autocomplete.ts +3 -5
- package/packages/pi-tui/src/components/editor.ts +70 -49
- package/pkg/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/pkg/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/pkg/dist/core/export-html/ansi-to-html.js +249 -0
- package/pkg/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/pkg/dist/core/export-html/index.d.ts +37 -0
- package/pkg/dist/core/export-html/index.d.ts.map +1 -0
- package/pkg/dist/core/export-html/index.js +223 -0
- package/pkg/dist/core/export-html/index.js.map +1 -0
- package/pkg/dist/core/export-html/template.css +971 -0
- package/pkg/dist/core/export-html/template.html +54 -0
- package/pkg/dist/core/export-html/template.js +1583 -0
- package/pkg/dist/core/export-html/tool-renderer.d.ts +38 -0
- package/pkg/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/pkg/dist/core/export-html/tool-renderer.js +70 -0
- package/pkg/dist/core/export-html/tool-renderer.js.map +1 -0
- package/pkg/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/pkg/dist/core/export-html/vendor/marked.min.js +6 -0
- package/scripts/postinstall.js +30 -17
- package/src/resources/extensions/bg-shell/index.ts +51 -7
- package/src/resources/extensions/gsd/activity-log.ts +61 -14
- package/src/resources/extensions/gsd/auto.ts +288 -19
- package/src/resources/extensions/gsd/commands.ts +9 -3
- package/src/resources/extensions/gsd/dashboard-overlay.ts +55 -12
- package/src/resources/extensions/gsd/docs/preferences-reference.md +25 -0
- package/src/resources/extensions/gsd/doctor.ts +60 -3
- package/src/resources/extensions/gsd/files.ts +45 -1
- package/src/resources/extensions/gsd/git-service.ts +46 -41
- package/src/resources/extensions/gsd/guided-flow.ts +81 -9
- package/src/resources/extensions/gsd/index.ts +62 -1
- package/src/resources/extensions/gsd/native-git-bridge.ts +181 -0
- package/src/resources/extensions/gsd/paths.ts +35 -4
- package/src/resources/extensions/gsd/post-unit-hooks.ts +449 -0
- package/src/resources/extensions/gsd/preferences.ts +232 -1
- package/src/resources/extensions/gsd/prompt-loader.ts +45 -3
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -3
- package/src/resources/extensions/gsd/prompts/discuss.md +10 -8
- package/src/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/src/resources/extensions/gsd/prompts/guided-complete-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-discuss-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-execute-task.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +4 -2
- package/src/resources/extensions/gsd/prompts/guided-plan-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-research-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +9 -12
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -3
- package/src/resources/extensions/gsd/prompts/queue.md +3 -1
- package/src/resources/extensions/gsd/prompts/research-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/src/resources/extensions/gsd/state.ts +130 -18
- package/src/resources/extensions/gsd/templates/context.md +1 -1
- package/src/resources/extensions/gsd/templates/state.md +3 -3
- package/src/resources/extensions/gsd/tests/activity-log-save.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +5 -1
- package/src/resources/extensions/gsd/tests/doctor.test.ts +115 -1
- package/src/resources/extensions/gsd/tests/draft-promotion.test.ts +6 -2
- package/src/resources/extensions/gsd/tests/git-service.test.ts +35 -35
- package/src/resources/extensions/gsd/tests/idle-recovery.test.ts +8 -8
- package/src/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +4 -1
- package/src/resources/extensions/gsd/tests/network-error-fallback.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/orphaned-branch.test.ts +5 -5
- package/src/resources/extensions/gsd/tests/post-unit-hooks.test.ts +297 -0
- package/src/resources/extensions/gsd/tests/preferences-hooks.test.ts +226 -0
- package/src/resources/extensions/gsd/tests/regex-hardening.test.ts +12 -0
- package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +6 -0
- package/src/resources/extensions/gsd/tests/worktree-integration.test.ts +4 -4
- package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +4 -4
- package/src/resources/extensions/gsd/tests/worktree.test.ts +19 -19
- package/src/resources/extensions/gsd/types.ts +109 -0
- package/src/resources/extensions/gsd/worktree-manager.ts +72 -13
- package/src/resources/extensions/gsd/worktree.ts +5 -4
- package/src/resources/extensions/search-the-web/command-search-provider.ts +8 -4
- package/src/resources/extensions/search-the-web/native-search.ts +32 -23
- package/src/resources/extensions/search-the-web/provider.ts +19 -2
- package/src/resources/extensions/search-the-web/tool-fetch-page.ts +62 -0
- package/src/resources/extensions/search-the-web/tool-llm-context.ts +62 -3
- package/src/resources/extensions/search-the-web/tool-search.ts +62 -3
- package/src/resources/extensions/shared/bundled-extension-paths.ts +11 -0
- package/src/resources/extensions/subagent/index.ts +2 -1
- package/src/resources/skills/github-workflows/SKILL.md +5 -0
- package/dist/resources/extensions/gsd/git-service.d.ts +0 -225
- package/dist/resources/extensions/gsd/git-service.js +0 -756
- package/dist/resources/extensions/gsd/preferences.d.ts +0 -122
- package/dist/resources/extensions/gsd/preferences.js +0 -616
- package/dist/resources/extensions/gsd/worktree.d.ts +0 -106
- package/dist/resources/extensions/remote-questions/config.d.ts +0 -14
- package/dist/resources/extensions/remote-questions/config.js +0 -68
- package/dist/resources/extensions/remote-questions/discord-adapter.d.ts +0 -17
- package/dist/resources/extensions/remote-questions/discord-adapter.js +0 -118
- package/dist/resources/extensions/remote-questions/format.d.ts +0 -38
- package/dist/resources/extensions/remote-questions/format.js +0 -119
- package/dist/resources/extensions/remote-questions/manager.d.ts +0 -23
- package/dist/resources/extensions/remote-questions/manager.js +0 -161
- package/dist/resources/extensions/remote-questions/remote-command.d.ts +0 -6
- package/dist/resources/extensions/remote-questions/remote-command.js +0 -358
- package/dist/resources/extensions/remote-questions/slack-adapter.d.ts +0 -15
- package/dist/resources/extensions/remote-questions/slack-adapter.js +0 -82
- package/dist/resources/extensions/remote-questions/status.d.ts +0 -9
- package/dist/resources/extensions/remote-questions/status.js +0 -25
- package/dist/resources/extensions/remote-questions/store.d.ts +0 -11
- package/dist/resources/extensions/remote-questions/store.js +0 -66
- package/dist/resources/extensions/remote-questions/types.d.ts +0 -68
- package/dist/resources/extensions/remote-questions/types.js +0 -4
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSD Command — /gsd
|
|
3
|
+
*
|
|
4
|
+
* One command, one wizard. Routes to smart entry or status.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@gsd/pi-coding-agent";
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import { join, dirname } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { deriveState } from "./state.js";
|
|
12
|
+
import { GSDDashboardOverlay } from "./dashboard-overlay.js";
|
|
13
|
+
import { showQueue, showDiscuss } from "./guided-flow.js";
|
|
14
|
+
import { startAuto, stopAuto, isAutoActive, isAutoPaused, isStepMode } from "./auto.js";
|
|
15
|
+
import {
|
|
16
|
+
getGlobalGSDPreferencesPath,
|
|
17
|
+
getLegacyGlobalGSDPreferencesPath,
|
|
18
|
+
getProjectGSDPreferencesPath,
|
|
19
|
+
loadGlobalGSDPreferences,
|
|
20
|
+
loadProjectGSDPreferences,
|
|
21
|
+
loadEffectiveGSDPreferences,
|
|
22
|
+
resolveAllSkillReferences,
|
|
23
|
+
} from "./preferences.js";
|
|
24
|
+
import { loadFile, saveFile } from "./files.js";
|
|
25
|
+
import {
|
|
26
|
+
formatDoctorIssuesForPrompt,
|
|
27
|
+
formatDoctorReport,
|
|
28
|
+
runGSDDoctor,
|
|
29
|
+
selectDoctorScope,
|
|
30
|
+
filterDoctorIssues,
|
|
31
|
+
} from "./doctor.js";
|
|
32
|
+
import { loadPrompt } from "./prompt-loader.js";
|
|
33
|
+
import { handleMigrate } from "./migrate/command.js";
|
|
34
|
+
import { handleRemote } from "../remote-questions/remote-command.js";
|
|
35
|
+
|
|
36
|
+
function dispatchDoctorHeal(pi: ExtensionAPI, scope: string | undefined, reportText: string, structuredIssues: string): void {
|
|
37
|
+
const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(process.env.HOME ?? "~", ".pi", "GSD-WORKFLOW.md");
|
|
38
|
+
const workflow = readFileSync(workflowPath, "utf-8");
|
|
39
|
+
const prompt = loadPrompt("doctor-heal", {
|
|
40
|
+
doctorSummary: reportText,
|
|
41
|
+
structuredIssues,
|
|
42
|
+
scopeLabel: scope ?? "active milestone / blocking scope",
|
|
43
|
+
doctorCommandSuffix: scope ? ` ${scope}` : "",
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const content = `Read the following GSD workflow protocol and execute exactly.\n\n${workflow}\n\n## Your Task\n\n${prompt}`;
|
|
47
|
+
|
|
48
|
+
pi.sendMessage(
|
|
49
|
+
{ customType: "gsd-doctor-heal", content, display: false },
|
|
50
|
+
{ triggerTurn: true },
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function registerGSDCommand(pi: ExtensionAPI): void {
|
|
55
|
+
pi.registerCommand("gsd", {
|
|
56
|
+
description: "GSD — Get Shit Done: /gsd next|auto|stop|status|queue|prefs|hooks|doctor|migrate|remote",
|
|
57
|
+
|
|
58
|
+
getArgumentCompletions: (prefix: string) => {
|
|
59
|
+
const subcommands = ["next", "auto", "stop", "status", "queue", "discuss", "prefs", "hooks", "doctor", "migrate", "remote"];
|
|
60
|
+
const parts = prefix.trim().split(/\s+/);
|
|
61
|
+
|
|
62
|
+
if (parts.length <= 1) {
|
|
63
|
+
return subcommands
|
|
64
|
+
.filter((cmd) => cmd.startsWith(parts[0] ?? ""))
|
|
65
|
+
.map((cmd) => ({ value: cmd, label: cmd }));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (parts[0] === "auto" && parts.length <= 2) {
|
|
69
|
+
const flagPrefix = parts[1] ?? "";
|
|
70
|
+
return ["--verbose"]
|
|
71
|
+
.filter((f) => f.startsWith(flagPrefix))
|
|
72
|
+
.map((f) => ({ value: `auto ${f}`, label: f }));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (parts[0] === "prefs" && parts.length <= 2) {
|
|
76
|
+
const subPrefix = parts[1] ?? "";
|
|
77
|
+
return ["global", "project", "status", "wizard", "setup"]
|
|
78
|
+
.filter((cmd) => cmd.startsWith(subPrefix))
|
|
79
|
+
.map((cmd) => ({ value: `prefs ${cmd}`, label: cmd }));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (parts[0] === "remote" && parts.length <= 2) {
|
|
83
|
+
const subPrefix = parts[1] ?? "";
|
|
84
|
+
return ["slack", "discord", "status", "disconnect"]
|
|
85
|
+
.filter((cmd) => cmd.startsWith(subPrefix))
|
|
86
|
+
.map((cmd) => ({ value: `remote ${cmd}`, label: cmd }));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (parts[0] === "doctor") {
|
|
90
|
+
const modePrefix = parts[1] ?? "";
|
|
91
|
+
const modes = ["fix", "heal", "audit"];
|
|
92
|
+
|
|
93
|
+
if (parts.length <= 2) {
|
|
94
|
+
return modes
|
|
95
|
+
.filter((cmd) => cmd.startsWith(modePrefix))
|
|
96
|
+
.map((cmd) => ({ value: `doctor ${cmd}`, label: cmd }));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return [];
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
async handler(args: string, ctx: ExtensionCommandContext) {
|
|
106
|
+
const trimmed = (typeof args === "string" ? args : "").trim();
|
|
107
|
+
|
|
108
|
+
if (trimmed === "status") {
|
|
109
|
+
await handleStatus(ctx);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (trimmed === "prefs" || trimmed.startsWith("prefs ")) {
|
|
114
|
+
await handlePrefs(trimmed.replace(/^prefs\s*/, "").trim(), ctx);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (trimmed === "doctor" || trimmed.startsWith("doctor ")) {
|
|
119
|
+
await handleDoctor(trimmed.replace(/^doctor\s*/, "").trim(), ctx, pi);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (trimmed === "next" || trimmed.startsWith("next ")) {
|
|
124
|
+
const verboseMode = trimmed.includes("--verbose");
|
|
125
|
+
await startAuto(ctx, pi, process.cwd(), verboseMode, { step: true });
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (trimmed === "auto" || trimmed.startsWith("auto ")) {
|
|
130
|
+
const verboseMode = trimmed.includes("--verbose");
|
|
131
|
+
await startAuto(ctx, pi, process.cwd(), verboseMode);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (trimmed === "stop") {
|
|
136
|
+
if (!isAutoActive() && !isAutoPaused()) {
|
|
137
|
+
ctx.ui.notify("Auto-mode is not running.", "info");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
await stopAuto(ctx, pi);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (trimmed === "queue") {
|
|
145
|
+
await showQueue(ctx, pi, process.cwd());
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (trimmed === "discuss") {
|
|
150
|
+
await showDiscuss(ctx, pi, process.cwd());
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (trimmed === "hooks") {
|
|
155
|
+
const { formatHookStatus } = await import("./post-unit-hooks.js");
|
|
156
|
+
ctx.ui.notify(formatHookStatus(), "info");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (trimmed === "migrate" || trimmed.startsWith("migrate ")) {
|
|
161
|
+
await handleMigrate(trimmed.replace(/^migrate\s*/, "").trim(), ctx, pi);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (trimmed === "remote" || trimmed.startsWith("remote ")) {
|
|
166
|
+
await handleRemote(trimmed.replace(/^remote\s*/, "").trim(), ctx, pi);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (trimmed === "") {
|
|
171
|
+
// Bare /gsd defaults to step mode
|
|
172
|
+
await startAuto(ctx, pi, process.cwd(), false, { step: true });
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
ctx.ui.notify(
|
|
177
|
+
`Unknown: /gsd ${trimmed}. Use /gsd, /gsd next, /gsd auto, /gsd stop, /gsd status, /gsd queue, /gsd discuss, /gsd prefs [global|project|status|wizard|setup], /gsd hooks, /gsd doctor [audit|fix|heal] [M###/S##], /gsd migrate <path>, or /gsd remote [slack|discord|status|disconnect].`,
|
|
178
|
+
"warning",
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function handleStatus(ctx: ExtensionCommandContext): Promise<void> {
|
|
185
|
+
const basePath = process.cwd();
|
|
186
|
+
const state = await deriveState(basePath);
|
|
187
|
+
|
|
188
|
+
if (state.registry.length === 0) {
|
|
189
|
+
ctx.ui.notify("No GSD milestones found. Run /gsd to start.", "info");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
await ctx.ui.custom<void>(
|
|
194
|
+
(tui, theme, _kb, done) => {
|
|
195
|
+
return new GSDDashboardOverlay(tui, theme, () => done());
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
overlay: true,
|
|
199
|
+
overlayOptions: {
|
|
200
|
+
width: "70%",
|
|
201
|
+
minWidth: 60,
|
|
202
|
+
maxHeight: "90%",
|
|
203
|
+
anchor: "center",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export async function fireStatusViaCommand(
|
|
210
|
+
ctx: import("@gsd/pi-coding-agent").ExtensionContext,
|
|
211
|
+
): Promise<void> {
|
|
212
|
+
await handleStatus(ctx as ExtensionCommandContext);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function handlePrefs(args: string, ctx: ExtensionCommandContext): Promise<void> {
|
|
216
|
+
const trimmed = args.trim();
|
|
217
|
+
|
|
218
|
+
if (trimmed === "" || trimmed === "global") {
|
|
219
|
+
await ensurePreferencesFile(getGlobalGSDPreferencesPath(), ctx, "global");
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (trimmed === "project") {
|
|
224
|
+
await ensurePreferencesFile(getProjectGSDPreferencesPath(), ctx, "project");
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (trimmed === "wizard" || trimmed === "setup" || trimmed === "wizard global" || trimmed === "setup global"
|
|
229
|
+
|| trimmed === "wizard project" || trimmed === "setup project") {
|
|
230
|
+
const scope = trimmed.includes("project") ? "project" : "global";
|
|
231
|
+
await handlePrefsWizard(ctx, scope);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (trimmed === "status") {
|
|
236
|
+
const globalPrefs = loadGlobalGSDPreferences();
|
|
237
|
+
const projectPrefs = loadProjectGSDPreferences();
|
|
238
|
+
const canonicalGlobal = getGlobalGSDPreferencesPath();
|
|
239
|
+
const legacyGlobal = getLegacyGlobalGSDPreferencesPath();
|
|
240
|
+
const globalStatus = globalPrefs
|
|
241
|
+
? `present: ${globalPrefs.path}${globalPrefs.path === legacyGlobal ? " (legacy fallback)" : ""}`
|
|
242
|
+
: `missing: ${canonicalGlobal}`;
|
|
243
|
+
const projectStatus = projectPrefs ? `present: ${projectPrefs.path}` : `missing: ${getProjectGSDPreferencesPath()}`;
|
|
244
|
+
|
|
245
|
+
const lines = [`GSD skill prefs — global ${globalStatus}; project ${projectStatus}`];
|
|
246
|
+
|
|
247
|
+
const effective = loadEffectiveGSDPreferences();
|
|
248
|
+
let hasUnresolved = false;
|
|
249
|
+
if (effective) {
|
|
250
|
+
const report = resolveAllSkillReferences(effective.preferences, process.cwd());
|
|
251
|
+
const resolved = [...report.resolutions.values()].filter(r => r.method !== "unresolved");
|
|
252
|
+
hasUnresolved = report.warnings.length > 0;
|
|
253
|
+
if (resolved.length > 0 || hasUnresolved) {
|
|
254
|
+
lines.push(`Skills: ${resolved.length} resolved, ${report.warnings.length} unresolved`);
|
|
255
|
+
}
|
|
256
|
+
if (hasUnresolved) {
|
|
257
|
+
lines.push(`Unresolved: ${report.warnings.join(", ")}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
ctx.ui.notify(lines.join("\n"), hasUnresolved ? "warning" : "info");
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
ctx.ui.notify("Usage: /gsd prefs [global|project|status|wizard|setup]", "info");
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
async function handleDoctor(args: string, ctx: ExtensionCommandContext, pi: ExtensionAPI): Promise<void> {
|
|
269
|
+
const trimmed = args.trim();
|
|
270
|
+
const parts = trimmed ? trimmed.split(/\s+/) : [];
|
|
271
|
+
const mode = parts[0] === "fix" || parts[0] === "heal" || parts[0] === "audit" ? parts[0] : "doctor";
|
|
272
|
+
const requestedScope = mode === "doctor" ? parts[0] : parts[1];
|
|
273
|
+
const scope = await selectDoctorScope(process.cwd(), requestedScope);
|
|
274
|
+
const effectiveScope = mode === "audit" ? requestedScope : scope;
|
|
275
|
+
const report = await runGSDDoctor(process.cwd(), {
|
|
276
|
+
fix: mode === "fix" || mode === "heal",
|
|
277
|
+
scope: effectiveScope,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const reportText = formatDoctorReport(report, {
|
|
281
|
+
scope: effectiveScope,
|
|
282
|
+
includeWarnings: mode === "audit",
|
|
283
|
+
maxIssues: mode === "audit" ? 50 : 12,
|
|
284
|
+
title: mode === "audit" ? "GSD doctor audit." : mode === "heal" ? "GSD doctor heal prep." : undefined,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
ctx.ui.notify(reportText, report.ok ? "info" : "warning");
|
|
288
|
+
|
|
289
|
+
if (mode === "heal") {
|
|
290
|
+
const unresolved = filterDoctorIssues(report.issues, {
|
|
291
|
+
scope: effectiveScope,
|
|
292
|
+
includeWarnings: true,
|
|
293
|
+
});
|
|
294
|
+
const actionable = unresolved.filter(issue => issue.severity === "error" || issue.code === "all_tasks_done_missing_slice_uat" || issue.code === "slice_checked_missing_uat");
|
|
295
|
+
if (actionable.length === 0) {
|
|
296
|
+
ctx.ui.notify("Doctor heal found nothing actionable to hand off to the LLM.", "info");
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const structuredIssues = formatDoctorIssuesForPrompt(actionable);
|
|
301
|
+
dispatchDoctorHeal(pi, effectiveScope, reportText, structuredIssues);
|
|
302
|
+
ctx.ui.notify(`Doctor heal dispatched ${actionable.length} issue(s) to the LLM.`, "info");
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// ─── Preferences Wizard ───────────────────────────────────────────────────────
|
|
307
|
+
|
|
308
|
+
async function handlePrefsWizard(
|
|
309
|
+
ctx: ExtensionCommandContext,
|
|
310
|
+
scope: "global" | "project",
|
|
311
|
+
): Promise<void> {
|
|
312
|
+
const path = scope === "project" ? getProjectGSDPreferencesPath() : getGlobalGSDPreferencesPath();
|
|
313
|
+
const existing = scope === "project" ? loadProjectGSDPreferences() : loadGlobalGSDPreferences();
|
|
314
|
+
const prefs: Record<string, unknown> = existing?.preferences ? { ...existing.preferences } : {};
|
|
315
|
+
|
|
316
|
+
ctx.ui.notify(`GSD preferences wizard (${scope}) — press Escape at any prompt to skip it.`, "info");
|
|
317
|
+
|
|
318
|
+
// ─── Models ──────────────────────────────────────────────────────────────
|
|
319
|
+
const modelPhases = ["research", "planning", "execution", "completion"] as const;
|
|
320
|
+
const models: Record<string, string> = (prefs.models as Record<string, string>) ?? {};
|
|
321
|
+
|
|
322
|
+
for (const phase of modelPhases) {
|
|
323
|
+
const current = models[phase] ?? "";
|
|
324
|
+
const input = await ctx.ui.input(
|
|
325
|
+
`Model for ${phase} phase${current ? ` (current: ${current})` : ""}:`,
|
|
326
|
+
current || "e.g. claude-sonnet-4-20250514",
|
|
327
|
+
);
|
|
328
|
+
if (input !== null && input !== undefined) {
|
|
329
|
+
const val = input.trim();
|
|
330
|
+
if (val) {
|
|
331
|
+
models[phase] = val;
|
|
332
|
+
} else if (current) {
|
|
333
|
+
// User cleared it — remove
|
|
334
|
+
delete models[phase];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
// null/undefined = Escape/skip — keep existing value
|
|
338
|
+
}
|
|
339
|
+
if (Object.keys(models).length > 0) {
|
|
340
|
+
prefs.models = models;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// ─── Auto-supervisor timeouts ────────────────────────────────────────────
|
|
344
|
+
const autoSup: Record<string, unknown> = (prefs.auto_supervisor as Record<string, unknown>) ?? {};
|
|
345
|
+
const timeoutFields = [
|
|
346
|
+
{ key: "soft_timeout_minutes", label: "Soft timeout (minutes)", defaultVal: "20" },
|
|
347
|
+
{ key: "idle_timeout_minutes", label: "Idle timeout (minutes)", defaultVal: "10" },
|
|
348
|
+
{ key: "hard_timeout_minutes", label: "Hard timeout (minutes)", defaultVal: "30" },
|
|
349
|
+
] as const;
|
|
350
|
+
|
|
351
|
+
for (const field of timeoutFields) {
|
|
352
|
+
const current = autoSup[field.key];
|
|
353
|
+
const currentStr = current !== undefined && current !== null ? String(current) : "";
|
|
354
|
+
const input = await ctx.ui.input(
|
|
355
|
+
`${field.label}${currentStr ? ` (current: ${currentStr})` : ` (default: ${field.defaultVal})`}:`,
|
|
356
|
+
currentStr || field.defaultVal,
|
|
357
|
+
);
|
|
358
|
+
if (input !== null && input !== undefined) {
|
|
359
|
+
const val = input.trim();
|
|
360
|
+
if (val && /^\d+$/.test(val)) {
|
|
361
|
+
autoSup[field.key] = Number(val);
|
|
362
|
+
} else if (val && !/^\d+$/.test(val)) {
|
|
363
|
+
ctx.ui.notify(`Invalid value "${val}" for ${field.label} — must be a whole number. Keeping previous value.`, "warning");
|
|
364
|
+
} else if (!val && currentStr) {
|
|
365
|
+
delete autoSup[field.key];
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (Object.keys(autoSup).length > 0) {
|
|
370
|
+
prefs.auto_supervisor = autoSup;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// ─── Git main branch ────────────────────────────────────────────────────
|
|
374
|
+
const git: Record<string, unknown> = (prefs.git as Record<string, unknown>) ?? {};
|
|
375
|
+
const currentBranch = git.main_branch ? String(git.main_branch) : "";
|
|
376
|
+
const branchInput = await ctx.ui.input(
|
|
377
|
+
`Git main branch${currentBranch ? ` (current: ${currentBranch})` : ""}:`,
|
|
378
|
+
currentBranch || "main",
|
|
379
|
+
);
|
|
380
|
+
if (branchInput !== null && branchInput !== undefined) {
|
|
381
|
+
const val = branchInput.trim();
|
|
382
|
+
if (val) {
|
|
383
|
+
git.main_branch = val;
|
|
384
|
+
} else if (currentBranch) {
|
|
385
|
+
delete git.main_branch;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (Object.keys(git).length > 0) {
|
|
389
|
+
prefs.git = git;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// ─── Skill discovery mode ───────────────────────────────────────────────
|
|
393
|
+
const currentDiscovery = (prefs.skill_discovery as string) ?? "";
|
|
394
|
+
const discoveryChoice = await ctx.ui.select(
|
|
395
|
+
`Skill discovery mode${currentDiscovery ? ` (current: ${currentDiscovery})` : ""}:`,
|
|
396
|
+
["auto", "suggest", "off", "(keep current)"],
|
|
397
|
+
);
|
|
398
|
+
if (discoveryChoice && discoveryChoice !== "(keep current)") {
|
|
399
|
+
prefs.skill_discovery = discoveryChoice;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// ─── Unique milestone IDs ──────────────────────────────────────────────
|
|
403
|
+
const currentUnique = prefs.unique_milestone_ids;
|
|
404
|
+
const uniqueChoice = await ctx.ui.select(
|
|
405
|
+
`Unique milestone IDs${currentUnique !== undefined ? ` (current: ${currentUnique})` : ""}:`,
|
|
406
|
+
["true", "false", "(keep current)"],
|
|
407
|
+
);
|
|
408
|
+
if (uniqueChoice && uniqueChoice !== "(keep current)") {
|
|
409
|
+
prefs.unique_milestone_ids = uniqueChoice === "true";
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// ─── Serialize to frontmatter ───────────────────────────────────────────
|
|
413
|
+
prefs.version = prefs.version || 1;
|
|
414
|
+
const frontmatter = serializePreferencesToFrontmatter(prefs);
|
|
415
|
+
|
|
416
|
+
// Preserve existing body content (everything after closing ---)
|
|
417
|
+
let body = "\n# GSD Skill Preferences\n\nSee `~/.gsd/agent/extensions/gsd/docs/preferences-reference.md` for full field documentation and examples.\n";
|
|
418
|
+
if (existsSync(path)) {
|
|
419
|
+
const existingContent = readFileSync(path, "utf-8");
|
|
420
|
+
const closingIdx = existingContent.indexOf("\n---", existingContent.indexOf("---"));
|
|
421
|
+
if (closingIdx !== -1) {
|
|
422
|
+
const afterFrontmatter = existingContent.slice(closingIdx + 4); // skip past "\n---"
|
|
423
|
+
if (afterFrontmatter.trim()) {
|
|
424
|
+
body = afterFrontmatter;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const content = `---\n${frontmatter}---${body}`;
|
|
430
|
+
|
|
431
|
+
await saveFile(path, content);
|
|
432
|
+
await ctx.waitForIdle();
|
|
433
|
+
await ctx.reload();
|
|
434
|
+
ctx.ui.notify(`Saved ${scope} preferences to ${path}`, "info");
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** Wrap a YAML value in double quotes if it contains special characters. */
|
|
438
|
+
function yamlSafeString(val: unknown): string {
|
|
439
|
+
if (typeof val !== "string") return String(val);
|
|
440
|
+
if (/[:#{\[\]'"`,|>&*!?@%]/.test(val) || val.trim() !== val || val === "") {
|
|
441
|
+
return `"${val.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
442
|
+
}
|
|
443
|
+
return val;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function serializePreferencesToFrontmatter(prefs: Record<string, unknown>): string {
|
|
447
|
+
const lines: string[] = [];
|
|
448
|
+
|
|
449
|
+
function serializeValue(key: string, value: unknown, indent: number): void {
|
|
450
|
+
const prefix = " ".repeat(indent);
|
|
451
|
+
if (value === null || value === undefined) return;
|
|
452
|
+
|
|
453
|
+
if (Array.isArray(value)) {
|
|
454
|
+
if (value.length === 0) {
|
|
455
|
+
lines.push(`${prefix}${key}: []`);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
lines.push(`${prefix}${key}:`);
|
|
459
|
+
for (const item of value) {
|
|
460
|
+
if (typeof item === "object" && item !== null) {
|
|
461
|
+
const entries = Object.entries(item as Record<string, unknown>);
|
|
462
|
+
if (entries.length > 0) {
|
|
463
|
+
const [firstKey, firstVal] = entries[0];
|
|
464
|
+
lines.push(`${prefix} - ${firstKey}: ${yamlSafeString(firstVal)}`);
|
|
465
|
+
for (let i = 1; i < entries.length; i++) {
|
|
466
|
+
const [k, v] = entries[i];
|
|
467
|
+
if (Array.isArray(v)) {
|
|
468
|
+
lines.push(`${prefix} ${k}:`);
|
|
469
|
+
for (const arrItem of v) {
|
|
470
|
+
lines.push(`${prefix} - ${yamlSafeString(arrItem)}`);
|
|
471
|
+
}
|
|
472
|
+
} else {
|
|
473
|
+
lines.push(`${prefix} ${k}: ${yamlSafeString(v)}`);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
} else {
|
|
478
|
+
lines.push(`${prefix} - ${yamlSafeString(item)}`);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (typeof value === "object") {
|
|
485
|
+
const entries = Object.entries(value as Record<string, unknown>);
|
|
486
|
+
if (entries.length === 0) {
|
|
487
|
+
lines.push(`${prefix}${key}: {}`);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
lines.push(`${prefix}${key}:`);
|
|
491
|
+
for (const [k, v] of entries) {
|
|
492
|
+
serializeValue(k, v, indent + 1);
|
|
493
|
+
}
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
lines.push(`${prefix}${key}: ${yamlSafeString(value)}`);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Ordered keys for consistent output
|
|
501
|
+
const orderedKeys = [
|
|
502
|
+
"version", "always_use_skills", "prefer_skills", "avoid_skills",
|
|
503
|
+
"skill_rules", "custom_instructions", "models", "skill_discovery",
|
|
504
|
+
"auto_supervisor", "uat_dispatch", "unique_milestone_ids", "budget_ceiling", "remote_questions", "git",
|
|
505
|
+
];
|
|
506
|
+
|
|
507
|
+
const seen = new Set<string>();
|
|
508
|
+
for (const key of orderedKeys) {
|
|
509
|
+
if (key in prefs) {
|
|
510
|
+
serializeValue(key, prefs[key], 0);
|
|
511
|
+
seen.add(key);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
// Any remaining keys not in the ordered list
|
|
515
|
+
for (const [key, value] of Object.entries(prefs)) {
|
|
516
|
+
if (!seen.has(key)) {
|
|
517
|
+
serializeValue(key, value, 0);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return lines.join("\n") + "\n";
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
async function ensurePreferencesFile(
|
|
525
|
+
path: string,
|
|
526
|
+
ctx: ExtensionCommandContext,
|
|
527
|
+
scope: "global" | "project",
|
|
528
|
+
): Promise<void> {
|
|
529
|
+
if (!existsSync(path)) {
|
|
530
|
+
const template = await loadFile(join(dirname(fileURLToPath(import.meta.url)), "templates", "preferences.md"));
|
|
531
|
+
if (!template) {
|
|
532
|
+
ctx.ui.notify("Could not load GSD preferences template.", "error");
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
await saveFile(path, template);
|
|
536
|
+
ctx.ui.notify(`Created ${scope} GSD skill preferences at ${path}`, "info");
|
|
537
|
+
} else {
|
|
538
|
+
ctx.ui.notify(`Using existing ${scope} GSD skill preferences at ${path}`, "info");
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
await ctx.waitForIdle();
|
|
542
|
+
await ctx.reload();
|
|
543
|
+
ctx.ui.notify(`Edit ${path} to update ${scope} GSD skill preferences.`, "info");
|
|
544
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSD Crash Recovery
|
|
3
|
+
*
|
|
4
|
+
* Detects interrupted auto-mode sessions via a lock file.
|
|
5
|
+
* Written on auto-start, updated on each unit dispatch, deleted on clean stop.
|
|
6
|
+
* If the lock file exists on next startup, the previous session crashed.
|
|
7
|
+
*
|
|
8
|
+
* The lock records the pi session file path so crash recovery can read the
|
|
9
|
+
* surviving JSONL (pi appends entries incrementally via appendFileSync,
|
|
10
|
+
* so the file on disk reflects every tool call up to the crash point).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { writeFileSync, readFileSync, unlinkSync, existsSync } from "node:fs";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { gsdRoot } from "./paths.js";
|
|
16
|
+
|
|
17
|
+
const LOCK_FILE = "auto.lock";
|
|
18
|
+
|
|
19
|
+
export interface LockData {
|
|
20
|
+
pid: number;
|
|
21
|
+
startedAt: string;
|
|
22
|
+
unitType: string;
|
|
23
|
+
unitId: string;
|
|
24
|
+
unitStartedAt: string;
|
|
25
|
+
completedUnits: number;
|
|
26
|
+
/** Path to the pi session JSONL file that was active when this unit started. */
|
|
27
|
+
sessionFile?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function lockPath(basePath: string): string {
|
|
31
|
+
return join(gsdRoot(basePath), LOCK_FILE);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Write or update the lock file with current auto-mode state. */
|
|
35
|
+
export function writeLock(
|
|
36
|
+
basePath: string,
|
|
37
|
+
unitType: string,
|
|
38
|
+
unitId: string,
|
|
39
|
+
completedUnits: number,
|
|
40
|
+
sessionFile?: string,
|
|
41
|
+
): void {
|
|
42
|
+
try {
|
|
43
|
+
const data: LockData = {
|
|
44
|
+
pid: process.pid,
|
|
45
|
+
startedAt: new Date().toISOString(),
|
|
46
|
+
unitType,
|
|
47
|
+
unitId,
|
|
48
|
+
unitStartedAt: new Date().toISOString(),
|
|
49
|
+
completedUnits,
|
|
50
|
+
sessionFile,
|
|
51
|
+
};
|
|
52
|
+
writeFileSync(lockPath(basePath), JSON.stringify(data, null, 2), "utf-8");
|
|
53
|
+
} catch { /* non-fatal */ }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Remove the lock file on clean stop. */
|
|
57
|
+
export function clearLock(basePath: string): void {
|
|
58
|
+
try {
|
|
59
|
+
const p = lockPath(basePath);
|
|
60
|
+
if (existsSync(p)) unlinkSync(p);
|
|
61
|
+
} catch { /* non-fatal */ }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Check if a crash lock exists and return its data. */
|
|
65
|
+
export function readCrashLock(basePath: string): LockData | null {
|
|
66
|
+
try {
|
|
67
|
+
const p = lockPath(basePath);
|
|
68
|
+
if (!existsSync(p)) return null;
|
|
69
|
+
const raw = readFileSync(p, "utf-8");
|
|
70
|
+
return JSON.parse(raw) as LockData;
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Check whether the process that wrote the lock is still running.
|
|
78
|
+
* Uses `process.kill(pid, 0)` which sends no signal but checks liveness.
|
|
79
|
+
* Returns false if the PID matches our own (recycled PID from a prior run).
|
|
80
|
+
*/
|
|
81
|
+
export function isLockProcessAlive(lock: LockData): boolean {
|
|
82
|
+
const pid = lock.pid;
|
|
83
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
84
|
+
if (pid === process.pid) return false;
|
|
85
|
+
try {
|
|
86
|
+
process.kill(pid, 0);
|
|
87
|
+
return true;
|
|
88
|
+
} catch (err) {
|
|
89
|
+
// EPERM means the process exists but we lack permission — treat as alive.
|
|
90
|
+
// ESRCH means the process does not exist — treat as dead (stale lock).
|
|
91
|
+
if ((err as NodeJS.ErrnoException).code === "EPERM") return true;
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Format crash info for display or injection into a prompt. */
|
|
97
|
+
export function formatCrashInfo(lock: LockData): string {
|
|
98
|
+
return [
|
|
99
|
+
`Previous auto-mode session was interrupted.`,
|
|
100
|
+
` Was executing: ${lock.unitType} (${lock.unitId})`,
|
|
101
|
+
` Started at: ${lock.unitStartedAt}`,
|
|
102
|
+
` Units completed before crash: ${lock.completedUnits}`,
|
|
103
|
+
` PID: ${lock.pid}`,
|
|
104
|
+
].join("\n");
|
|
105
|
+
}
|