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,459 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSD Worktree Manager
|
|
3
|
+
*
|
|
4
|
+
* Creates and manages git worktrees under .gsd/worktrees/<name>/.
|
|
5
|
+
* Each worktree gets its own branch (worktree/<name>) and a full
|
|
6
|
+
* working copy of the project, enabling parallel work streams.
|
|
7
|
+
*
|
|
8
|
+
* The merge helper compares .gsd/ artifacts between a worktree and
|
|
9
|
+
* the main branch, then dispatches an LLM-guided merge flow.
|
|
10
|
+
*
|
|
11
|
+
* Flow:
|
|
12
|
+
* 1. create() — git worktree add .gsd/worktrees/<name> -b worktree/<name>
|
|
13
|
+
* 2. user works in the worktree (new plans, milestones, etc.)
|
|
14
|
+
* 3. merge() — LLM-guided reconciliation of .gsd/ artifacts back to main
|
|
15
|
+
* 4. remove() — git worktree remove + branch cleanup
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { existsSync, mkdirSync, realpathSync } from "node:fs";
|
|
19
|
+
import { execSync } from "node:child_process";
|
|
20
|
+
import { join, resolve } from "node:path";
|
|
21
|
+
|
|
22
|
+
// ─── Types ─────────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
export interface WorktreeInfo {
|
|
25
|
+
name: string;
|
|
26
|
+
path: string;
|
|
27
|
+
branch: string;
|
|
28
|
+
exists: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Per-file line change stats from git diff --numstat. */
|
|
32
|
+
export interface FileLineStat {
|
|
33
|
+
file: string;
|
|
34
|
+
added: number;
|
|
35
|
+
removed: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface WorktreeDiffSummary {
|
|
39
|
+
/** Files only in the worktree .gsd/ (new artifacts) */
|
|
40
|
+
added: string[];
|
|
41
|
+
/** Files in both but with different content */
|
|
42
|
+
modified: string[];
|
|
43
|
+
/** Files only in main .gsd/ (deleted in worktree) */
|
|
44
|
+
removed: string[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ─── Git Helpers ───────────────────────────────────────────────────────────
|
|
48
|
+
|
|
49
|
+
/** Env overlay that suppresses interactive git credential prompts and git-svn noise. */
|
|
50
|
+
const GIT_NO_PROMPT_ENV = {
|
|
51
|
+
...process.env,
|
|
52
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
53
|
+
GIT_ASKPASS: "",
|
|
54
|
+
GIT_SVN_ID: "",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Strip git-svn noise from error messages.
|
|
59
|
+
* Some systems have a buggy git-svn Perl module that emits warnings
|
|
60
|
+
* on every git invocation. See #404.
|
|
61
|
+
*/
|
|
62
|
+
function filterGitSvnNoise(message: string): string {
|
|
63
|
+
return message
|
|
64
|
+
.replace(/Duplicate specification "[^"]*" for option "[^"]*"\n?/g, "")
|
|
65
|
+
.replace(/Unable to determine upstream SVN information from .*\n?/g, "")
|
|
66
|
+
.replace(/Perhaps the repository is empty\. at .*git-svn.*\n?/g, "")
|
|
67
|
+
.trim();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function runGit(cwd: string, args: string[], opts: { allowFailure?: boolean } = {}): string {
|
|
71
|
+
try {
|
|
72
|
+
return execSync(`git ${args.join(" ")}`, {
|
|
73
|
+
cwd,
|
|
74
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
75
|
+
encoding: "utf-8",
|
|
76
|
+
env: GIT_NO_PROMPT_ENV,
|
|
77
|
+
}).trim();
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (opts.allowFailure) return "";
|
|
80
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
81
|
+
throw new Error(`git ${args.join(" ")} failed in ${cwd}: ${filterGitSvnNoise(message)}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function normalizePathForComparison(path: string): string {
|
|
86
|
+
const normalized = path
|
|
87
|
+
.replaceAll("\\", "/")
|
|
88
|
+
.replace(/^\/\/\?\//, "")
|
|
89
|
+
.replace(/\/+$/, "");
|
|
90
|
+
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function getMainBranch(basePath: string): string {
|
|
94
|
+
const symbolic = runGit(basePath, ["symbolic-ref", "refs/remotes/origin/HEAD"], { allowFailure: true });
|
|
95
|
+
if (symbolic) {
|
|
96
|
+
const match = symbolic.match(/refs\/remotes\/origin\/(.+)$/);
|
|
97
|
+
if (match) return match[1]!;
|
|
98
|
+
}
|
|
99
|
+
if (runGit(basePath, ["show-ref", "--verify", "refs/heads/main"], { allowFailure: true })) return "main";
|
|
100
|
+
if (runGit(basePath, ["show-ref", "--verify", "refs/heads/master"], { allowFailure: true })) return "master";
|
|
101
|
+
return runGit(basePath, ["branch", "--show-current"]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ─── Path Helpers ──────────────────────────────────────────────────────────
|
|
105
|
+
|
|
106
|
+
export function worktreesDir(basePath: string): string {
|
|
107
|
+
return join(basePath, ".gsd", "worktrees");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function worktreePath(basePath: string, name: string): string {
|
|
111
|
+
return join(worktreesDir(basePath), name);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function worktreeBranchName(name: string): string {
|
|
115
|
+
return `worktree/${name}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ─── Core Operations ───────────────────────────────────────────────────────
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Create a new git worktree under .gsd/worktrees/<name>/ with branch worktree/<name>.
|
|
122
|
+
* The branch is created from the current HEAD of the main branch.
|
|
123
|
+
*/
|
|
124
|
+
export function createWorktree(basePath: string, name: string): WorktreeInfo {
|
|
125
|
+
// Validate name: alphanumeric, hyphens, underscores only
|
|
126
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(name)) {
|
|
127
|
+
throw new Error(`Invalid worktree name "${name}". Use only letters, numbers, hyphens, and underscores.`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const wtPath = worktreePath(basePath, name);
|
|
131
|
+
const branch = worktreeBranchName(name);
|
|
132
|
+
|
|
133
|
+
if (existsSync(wtPath)) {
|
|
134
|
+
throw new Error(`Worktree "${name}" already exists at ${wtPath}`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Ensure the .gsd/worktrees/ directory exists
|
|
138
|
+
const wtDir = worktreesDir(basePath);
|
|
139
|
+
mkdirSync(wtDir, { recursive: true });
|
|
140
|
+
|
|
141
|
+
// Prune any stale worktree entries from a previous removal
|
|
142
|
+
runGit(basePath, ["worktree", "prune"], { allowFailure: true });
|
|
143
|
+
|
|
144
|
+
// Check if the branch already exists (leftover from a previous worktree)
|
|
145
|
+
const branchExists = runGit(basePath, ["show-ref", "--verify", `refs/heads/${branch}`], { allowFailure: true });
|
|
146
|
+
const mainBranch = getMainBranch(basePath);
|
|
147
|
+
|
|
148
|
+
if (branchExists) {
|
|
149
|
+
// Check if the branch is actively used by an existing worktree.
|
|
150
|
+
// `git branch -f` will fail if the branch is checked out somewhere.
|
|
151
|
+
const worktreeUsing = runGit(basePath, ["worktree", "list", "--porcelain"], { allowFailure: true });
|
|
152
|
+
const branchInUse = worktreeUsing.includes(`branch refs/heads/${branch}`);
|
|
153
|
+
|
|
154
|
+
if (branchInUse) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`Branch "${branch}" is already in use by another worktree. ` +
|
|
157
|
+
`Remove the existing worktree first with /worktree remove ${name}.`,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Reset the stale branch to current main, then attach worktree to it
|
|
162
|
+
runGit(basePath, ["branch", "-f", branch, mainBranch]);
|
|
163
|
+
runGit(basePath, ["worktree", "add", wtPath, branch]);
|
|
164
|
+
} else {
|
|
165
|
+
runGit(basePath, ["worktree", "add", "-b", branch, wtPath, mainBranch]);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
name,
|
|
170
|
+
path: wtPath,
|
|
171
|
+
branch,
|
|
172
|
+
exists: true,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* List all GSD-managed worktrees.
|
|
178
|
+
* Parses `git worktree list` and filters to those under .gsd/worktrees/.
|
|
179
|
+
*/
|
|
180
|
+
export function listWorktrees(basePath: string): WorktreeInfo[] {
|
|
181
|
+
const baseVariants = [resolve(basePath)];
|
|
182
|
+
if (existsSync(basePath)) {
|
|
183
|
+
baseVariants.push(realpathSync(basePath));
|
|
184
|
+
}
|
|
185
|
+
const seenRoots = new Set<string>();
|
|
186
|
+
const worktreeRoots = baseVariants
|
|
187
|
+
.map(baseVariant => {
|
|
188
|
+
const path = join(baseVariant, ".gsd", "worktrees");
|
|
189
|
+
return {
|
|
190
|
+
normalized: normalizePathForComparison(path),
|
|
191
|
+
};
|
|
192
|
+
})
|
|
193
|
+
.filter(root => {
|
|
194
|
+
if (seenRoots.has(root.normalized)) return false;
|
|
195
|
+
seenRoots.add(root.normalized);
|
|
196
|
+
return true;
|
|
197
|
+
});
|
|
198
|
+
const rawList = runGit(basePath, ["worktree", "list", "--porcelain"]);
|
|
199
|
+
|
|
200
|
+
if (!rawList.trim()) return [];
|
|
201
|
+
|
|
202
|
+
const worktrees: WorktreeInfo[] = [];
|
|
203
|
+
const entries = rawList.replaceAll("\r\n", "\n").split("\n\n").filter(Boolean);
|
|
204
|
+
|
|
205
|
+
for (const entry of entries) {
|
|
206
|
+
const lines = entry.split("\n");
|
|
207
|
+
const wtLine = lines.find(l => l.startsWith("worktree "));
|
|
208
|
+
const branchLine = lines.find(l => l.startsWith("branch "));
|
|
209
|
+
|
|
210
|
+
if (!wtLine || !branchLine) continue;
|
|
211
|
+
|
|
212
|
+
const entryPath = wtLine.replace("worktree ", "");
|
|
213
|
+
const branch = branchLine.replace("branch refs/heads/", "");
|
|
214
|
+
const branchWorktreeName = branch.startsWith("worktree/") ? branch.slice("worktree/".length) : null;
|
|
215
|
+
const entryVariants = [resolve(entryPath)];
|
|
216
|
+
if (existsSync(entryPath)) {
|
|
217
|
+
entryVariants.push(realpathSync(entryPath));
|
|
218
|
+
}
|
|
219
|
+
const normalizedEntryVariants = [...new Set(entryVariants.map(normalizePathForComparison))];
|
|
220
|
+
const matchedRoot = worktreeRoots.find(root =>
|
|
221
|
+
normalizedEntryVariants.some(entryVariant => entryVariant.startsWith(`${root.normalized}/`)),
|
|
222
|
+
);
|
|
223
|
+
const matchesBranchLeaf = branchWorktreeName
|
|
224
|
+
? normalizedEntryVariants.some(entryVariant => entryVariant.split("/").pop() === branchWorktreeName)
|
|
225
|
+
: false;
|
|
226
|
+
|
|
227
|
+
// Only include worktrees under .gsd/worktrees/
|
|
228
|
+
if (!matchedRoot && !matchesBranchLeaf) continue;
|
|
229
|
+
|
|
230
|
+
const matchedEntryPath = normalizedEntryVariants.find(entryVariant =>
|
|
231
|
+
matchedRoot ? entryVariant.startsWith(`${matchedRoot.normalized}/`) : false,
|
|
232
|
+
);
|
|
233
|
+
let name = matchedRoot ? matchedEntryPath?.slice(matchedRoot.normalized.length + 1) ?? "" : "";
|
|
234
|
+
|
|
235
|
+
// Git on Windows can report a path form that does not map cleanly back to the
|
|
236
|
+
// repo root even when the branch naming is still authoritative.
|
|
237
|
+
if ((!name || name.includes("/")) && branchWorktreeName && matchesBranchLeaf) {
|
|
238
|
+
name = branchWorktreeName;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (!name || name.includes("/")) continue;
|
|
242
|
+
|
|
243
|
+
const resolvedEntryPath = existsSync(entryPath) ? realpathSync(entryPath) : resolve(entryPath);
|
|
244
|
+
|
|
245
|
+
worktrees.push({
|
|
246
|
+
name,
|
|
247
|
+
path: resolvedEntryPath,
|
|
248
|
+
branch,
|
|
249
|
+
exists: existsSync(resolvedEntryPath),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return worktrees;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Remove a worktree and optionally delete its branch.
|
|
258
|
+
* If the process is currently inside the worktree, chdir out first.
|
|
259
|
+
*/
|
|
260
|
+
export function removeWorktree(
|
|
261
|
+
basePath: string,
|
|
262
|
+
name: string,
|
|
263
|
+
opts: { deleteBranch?: boolean; force?: boolean } = {},
|
|
264
|
+
): void {
|
|
265
|
+
const wtPath = worktreePath(basePath, name);
|
|
266
|
+
const resolvedWtPath = existsSync(wtPath) ? realpathSync(wtPath) : wtPath;
|
|
267
|
+
const branch = worktreeBranchName(name);
|
|
268
|
+
const { deleteBranch = true, force = false } = opts;
|
|
269
|
+
|
|
270
|
+
// If we're inside the worktree, move out first — git can't remove an in-use directory
|
|
271
|
+
const cwd = process.cwd();
|
|
272
|
+
const resolvedCwd = existsSync(cwd) ? realpathSync(cwd) : cwd;
|
|
273
|
+
if (resolvedCwd === resolvedWtPath || resolvedCwd.startsWith(resolvedWtPath + "/")) {
|
|
274
|
+
process.chdir(basePath);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (!existsSync(wtPath)) {
|
|
278
|
+
runGit(basePath, ["worktree", "prune"], { allowFailure: true });
|
|
279
|
+
if (deleteBranch) {
|
|
280
|
+
runGit(basePath, ["branch", "-D", branch], { allowFailure: true });
|
|
281
|
+
}
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Force-remove to handle dirty worktrees
|
|
286
|
+
runGit(basePath, ["worktree", "remove", "--force", wtPath], { allowFailure: true });
|
|
287
|
+
|
|
288
|
+
// If the directory is still there (e.g. locked), try harder
|
|
289
|
+
if (existsSync(wtPath)) {
|
|
290
|
+
runGit(basePath, ["worktree", "remove", "--force", "--force", wtPath], { allowFailure: true });
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Prune stale entries so git knows the worktree is gone
|
|
294
|
+
runGit(basePath, ["worktree", "prune"], { allowFailure: true });
|
|
295
|
+
|
|
296
|
+
if (deleteBranch) {
|
|
297
|
+
runGit(basePath, ["branch", "-D", branch], { allowFailure: true });
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Paths to skip in all worktree diffs (internal/runtime artifacts). */
|
|
302
|
+
const SKIP_PATHS = [".gsd/worktrees/", ".gsd/runtime/", ".gsd/activity/"];
|
|
303
|
+
const SKIP_EXACT = [".gsd/STATE.md", ".gsd/auto.lock", ".gsd/metrics.json"];
|
|
304
|
+
|
|
305
|
+
function shouldSkipPath(filePath: string): boolean {
|
|
306
|
+
if (SKIP_PATHS.some(p => filePath.startsWith(p))) return true;
|
|
307
|
+
if (SKIP_EXACT.includes(filePath)) return true;
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function parseDiffNameStatus(diffOutput: string): WorktreeDiffSummary {
|
|
312
|
+
const added: string[] = [];
|
|
313
|
+
const modified: string[] = [];
|
|
314
|
+
const removed: string[] = [];
|
|
315
|
+
|
|
316
|
+
if (!diffOutput.trim()) return { added, modified, removed };
|
|
317
|
+
|
|
318
|
+
for (const line of diffOutput.split("\n").filter(Boolean)) {
|
|
319
|
+
const [status, ...pathParts] = line.split("\t");
|
|
320
|
+
const filePath = pathParts.join("\t");
|
|
321
|
+
|
|
322
|
+
if (shouldSkipPath(filePath)) continue;
|
|
323
|
+
|
|
324
|
+
switch (status) {
|
|
325
|
+
case "A": added.push(filePath); break;
|
|
326
|
+
case "M": modified.push(filePath); break;
|
|
327
|
+
case "D": removed.push(filePath); break;
|
|
328
|
+
default:
|
|
329
|
+
// Renames, copies — treat as modified
|
|
330
|
+
if (status?.startsWith("R") || status?.startsWith("C")) {
|
|
331
|
+
modified.push(filePath);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return { added, modified, removed };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Diff the .gsd/ directory between the worktree branch and main branch.
|
|
341
|
+
* Returns a summary of added, modified, and removed GSD artifacts.
|
|
342
|
+
*/
|
|
343
|
+
export function diffWorktreeGSD(basePath: string, name: string): WorktreeDiffSummary {
|
|
344
|
+
const branch = worktreeBranchName(name);
|
|
345
|
+
const mainBranch = getMainBranch(basePath);
|
|
346
|
+
|
|
347
|
+
const diffOutput = runGit(basePath, [
|
|
348
|
+
"diff", "--name-status", `${mainBranch}...${branch}`, "--", ".gsd/",
|
|
349
|
+
], { allowFailure: true });
|
|
350
|
+
|
|
351
|
+
return parseDiffNameStatus(diffOutput);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Diff ALL files between the worktree branch and main branch.
|
|
356
|
+
* Returns a summary of added, modified, and removed files across the entire repo.
|
|
357
|
+
*/
|
|
358
|
+
/**
|
|
359
|
+
* Diff ALL files between the worktree branch and main branch.
|
|
360
|
+
* Uses direct diff (no merge-base) to show what will actually change
|
|
361
|
+
* on main when the merge is applied. If both branches have identical
|
|
362
|
+
* content, this correctly returns an empty diff.
|
|
363
|
+
*/
|
|
364
|
+
export function diffWorktreeAll(basePath: string, name: string): WorktreeDiffSummary {
|
|
365
|
+
const branch = worktreeBranchName(name);
|
|
366
|
+
const mainBranch = getMainBranch(basePath);
|
|
367
|
+
|
|
368
|
+
const diffOutput = runGit(basePath, [
|
|
369
|
+
"diff", "--name-status", mainBranch, branch,
|
|
370
|
+
], { allowFailure: true });
|
|
371
|
+
|
|
372
|
+
return parseDiffNameStatus(diffOutput);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Get per-file line addition/deletion stats for what will change on main.
|
|
377
|
+
* Uses direct diff (not merge-base) so the preview matches the actual merge outcome.
|
|
378
|
+
*/
|
|
379
|
+
export function diffWorktreeNumstat(basePath: string, name: string): FileLineStat[] {
|
|
380
|
+
const branch = worktreeBranchName(name);
|
|
381
|
+
const mainBranch = getMainBranch(basePath);
|
|
382
|
+
|
|
383
|
+
const raw = runGit(basePath, [
|
|
384
|
+
"diff", "--numstat", mainBranch, branch,
|
|
385
|
+
], { allowFailure: true });
|
|
386
|
+
|
|
387
|
+
if (!raw.trim()) return [];
|
|
388
|
+
|
|
389
|
+
const stats: FileLineStat[] = [];
|
|
390
|
+
for (const line of raw.split("\n").filter(Boolean)) {
|
|
391
|
+
const [a, r, ...pathParts] = line.split("\t");
|
|
392
|
+
const file = pathParts.join("\t");
|
|
393
|
+
if (shouldSkipPath(file)) continue;
|
|
394
|
+
const added = a === "-" ? 0 : parseInt(a ?? "0", 10);
|
|
395
|
+
const removed = r === "-" ? 0 : parseInt(r ?? "0", 10);
|
|
396
|
+
stats.push({ file, added, removed });
|
|
397
|
+
}
|
|
398
|
+
return stats;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Get the full diff content for .gsd/ between the worktree branch and main.
|
|
403
|
+
* Returns the raw unified diff for LLM consumption.
|
|
404
|
+
*/
|
|
405
|
+
export function getWorktreeGSDDiff(basePath: string, name: string): string {
|
|
406
|
+
const branch = worktreeBranchName(name);
|
|
407
|
+
const mainBranch = getMainBranch(basePath);
|
|
408
|
+
|
|
409
|
+
return runGit(basePath, [
|
|
410
|
+
"diff", `${mainBranch}...${branch}`, "--", ".gsd/",
|
|
411
|
+
], { allowFailure: true });
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Get the full diff content for non-.gsd/ files between the worktree branch and main.
|
|
416
|
+
* Returns the raw unified diff for LLM consumption.
|
|
417
|
+
*/
|
|
418
|
+
export function getWorktreeCodeDiff(basePath: string, name: string): string {
|
|
419
|
+
const branch = worktreeBranchName(name);
|
|
420
|
+
const mainBranch = getMainBranch(basePath);
|
|
421
|
+
|
|
422
|
+
// Get full diff, then exclude .gsd/ paths
|
|
423
|
+
// We use pathspec magic to exclude .gsd/
|
|
424
|
+
return runGit(basePath, [
|
|
425
|
+
"diff", `${mainBranch}...${branch}`, "--", ".", ":(exclude).gsd/",
|
|
426
|
+
], { allowFailure: true });
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Get commit log for the worktree branch since it diverged from main.
|
|
431
|
+
*/
|
|
432
|
+
export function getWorktreeLog(basePath: string, name: string): string {
|
|
433
|
+
const branch = worktreeBranchName(name);
|
|
434
|
+
const mainBranch = getMainBranch(basePath);
|
|
435
|
+
|
|
436
|
+
return runGit(basePath, [
|
|
437
|
+
"log", "--oneline", `${mainBranch}..${branch}`,
|
|
438
|
+
], { allowFailure: true });
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Merge the worktree branch into main using squash merge.
|
|
443
|
+
* Must be called from the main working tree (not the worktree itself).
|
|
444
|
+
* Returns the merge commit message.
|
|
445
|
+
*/
|
|
446
|
+
export function mergeWorktreeToMain(basePath: string, name: string, commitMessage: string): string {
|
|
447
|
+
const branch = worktreeBranchName(name);
|
|
448
|
+
const mainBranch = getMainBranch(basePath);
|
|
449
|
+
const current = runGit(basePath, ["branch", "--show-current"]);
|
|
450
|
+
|
|
451
|
+
if (current !== mainBranch) {
|
|
452
|
+
throw new Error(`Must be on ${mainBranch} to merge. Currently on ${current}.`);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
runGit(basePath, ["merge", "--squash", branch]);
|
|
456
|
+
runGit(basePath, ["commit", "-m", commitMessage]);
|
|
457
|
+
|
|
458
|
+
return commitMessage;
|
|
459
|
+
}
|