gsd-pi 2.74.0-dev.6e23363 → 2.74.0-dev.b2838e6
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/resources/extensions/gsd/auto/phases.js +51 -6
- package/dist/resources/extensions/gsd/auto-model-selection.js +3 -3
- package/dist/resources/extensions/gsd/auto-post-unit.js +7 -3
- package/dist/resources/extensions/gsd/auto-recovery.js +24 -10
- package/dist/resources/extensions/gsd/auto-worktree.js +2 -0
- package/dist/resources/extensions/gsd/bootstrap/provider-error-resume.js +5 -3
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +10 -1
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +61 -9
- package/dist/resources/extensions/gsd/cache.js +16 -5
- package/dist/resources/extensions/gsd/commands/catalog.js +6 -1
- package/dist/resources/extensions/gsd/commands/handlers/core.js +5 -1
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +5 -0
- package/dist/resources/extensions/gsd/commands-extract-learnings.js +225 -0
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +50 -3
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +2 -0
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +144 -0
- package/dist/resources/extensions/gsd/ecosystem/loader.js +145 -0
- package/dist/resources/extensions/gsd/guided-flow.js +8 -6
- package/dist/resources/extensions/gsd/preferences-types.js +1 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +10 -0
- package/dist/resources/extensions/gsd/preferences.js +5 -0
- package/dist/resources/extensions/gsd/safety/evidence-collector.js +15 -30
- package/dist/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +8 -8
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +8 -8
- package/dist/web/standalone/.next/server/chunks/6897.js +3 -3
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/package.json +1 -1
- package/packages/mcp-server/dist/readers/graph.d.ts +1 -1
- package/packages/mcp-server/dist/readers/graph.d.ts.map +1 -1
- package/packages/mcp-server/dist/readers/graph.js +107 -0
- package/packages/mcp-server/dist/readers/graph.js.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +88 -6
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/src/readers/graph.test.ts +178 -0
- package/packages/mcp-server/src/readers/graph.ts +148 -1
- package/packages/mcp-server/src/workflow-tools.ts +95 -10
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/index.d.ts +1 -9
- package/packages/pi-ai/dist/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/index.js +1 -9
- package/packages/pi-ai/dist/index.js.map +1 -1
- package/packages/pi-ai/dist/models/capability-patches.d.ts +19 -0
- package/packages/pi-ai/dist/models/capability-patches.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/capability-patches.js +36 -0
- package/packages/pi-ai/dist/models/capability-patches.js.map +1 -0
- package/packages/pi-ai/dist/{models.custom.d.ts → models/custom.d.ts} +1 -1
- package/packages/pi-ai/dist/models/custom.d.ts.map +1 -0
- package/packages/pi-ai/dist/{models.custom.js → models/custom.js} +4 -4
- package/packages/pi-ai/dist/models/custom.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.d.ts +1482 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.js +1484 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/anthropic.d.ts +377 -0
- package/packages/pi-ai/dist/models/generated/anthropic.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/anthropic.js +379 -0
- package/packages/pi-ai/dist/models/generated/anthropic.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.d.ts +700 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.js +702 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/cerebras.d.ts +71 -0
- package/packages/pi-ai/dist/models/generated/cerebras.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/cerebras.js +73 -0
- package/packages/pi-ai/dist/models/generated/cerebras.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.d.ts +590 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.js +444 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.d.ts +156 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.js +158 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.d.ts +105 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.js +107 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.d.ts +207 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.js +209 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google.d.ts +462 -0
- package/packages/pi-ai/dist/models/generated/google.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google.js +464 -0
- package/packages/pi-ai/dist/models/generated/google.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/groq.d.ts +309 -0
- package/packages/pi-ai/dist/models/generated/groq.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/groq.js +311 -0
- package/packages/pi-ai/dist/models/generated/groq.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/huggingface.d.ts +383 -0
- package/packages/pi-ai/dist/models/generated/huggingface.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/huggingface.js +347 -0
- package/packages/pi-ai/dist/models/generated/huggingface.js.map +1 -0
- package/packages/pi-ai/dist/{models.generated.d.ts → models/generated/index.d.ts} +1 -1
- package/packages/pi-ai/dist/{models.generated.d.ts.map → models/generated/index.d.ts.map} +1 -1
- package/packages/pi-ai/dist/models/generated/index.js +51 -0
- package/packages/pi-ai/dist/models/generated/index.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.d.ts +37 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.js +39 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.d.ts +105 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.js +107 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax.d.ts +105 -0
- package/packages/pi-ai/dist/models/generated/minimax.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax.js +107 -0
- package/packages/pi-ai/dist/models/generated/minimax.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/mistral.d.ts +445 -0
- package/packages/pi-ai/dist/models/generated/mistral.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/mistral.js +447 -0
- package/packages/pi-ai/dist/models/generated/mistral.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.d.ts +139 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.js +141 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai.d.ts +700 -0
- package/packages/pi-ai/dist/models/generated/openai.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai.js +702 -0
- package/packages/pi-ai/dist/models/generated/openai.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.d.ts +122 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.js +124 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode.d.ts +530 -0
- package/packages/pi-ai/dist/models/generated/opencode.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode.js +532 -0
- package/packages/pi-ai/dist/models/generated/opencode.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/openrouter.d.ts +4270 -0
- package/packages/pi-ai/dist/models/generated/openrouter.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/openrouter.js +4272 -0
- package/packages/pi-ai/dist/models/generated/openrouter.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.d.ts +2604 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.js +2606 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/xai.d.ts +411 -0
- package/packages/pi-ai/dist/models/generated/xai.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/xai.js +413 -0
- package/packages/pi-ai/dist/models/generated/xai.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/zai.d.ts +276 -0
- package/packages/pi-ai/dist/models/generated/zai.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/zai.js +239 -0
- package/packages/pi-ai/dist/models/generated/zai.js.map +1 -0
- package/packages/pi-ai/dist/models/index.d.ts +27 -0
- package/packages/pi-ai/dist/models/index.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/index.js +80 -0
- package/packages/pi-ai/dist/models/index.js.map +1 -0
- package/packages/pi-ai/dist/models.d.ts +1 -36
- package/packages/pi-ai/dist/models.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.test.js +1 -2
- package/packages/pi-ai/dist/models.generated.test.js.map +1 -1
- package/packages/pi-ai/dist/models.js +3 -112
- package/packages/pi-ai/dist/models.js.map +1 -1
- package/packages/pi-ai/dist/models.test.js +6 -5
- package/packages/pi-ai/dist/models.test.js.map +1 -1
- package/packages/pi-ai/scripts/generate-models.ts +74 -40
- package/packages/pi-ai/src/index.ts +1 -9
- package/packages/pi-ai/src/models/capability-patches.ts +40 -0
- package/packages/pi-ai/src/{models.custom.ts → models/custom.ts} +4 -4
- package/packages/pi-ai/src/models/generated/amazon-bedrock.ts +1486 -0
- package/packages/pi-ai/src/models/generated/anthropic.ts +381 -0
- package/packages/pi-ai/src/models/generated/azure-openai-responses.ts +704 -0
- package/packages/pi-ai/src/models/generated/cerebras.ts +75 -0
- package/packages/pi-ai/src/models/generated/github-copilot.ts +446 -0
- package/packages/pi-ai/src/models/generated/google-antigravity.ts +160 -0
- package/packages/pi-ai/src/models/generated/google-gemini-cli.ts +109 -0
- package/packages/pi-ai/src/models/generated/google-vertex.ts +211 -0
- package/packages/pi-ai/src/models/generated/google.ts +466 -0
- package/packages/pi-ai/src/models/generated/groq.ts +313 -0
- package/packages/pi-ai/src/models/generated/huggingface.ts +349 -0
- package/packages/pi-ai/src/models/generated/index.ts +52 -0
- package/packages/pi-ai/src/models/generated/kimi-coding.ts +41 -0
- package/packages/pi-ai/src/models/generated/minimax-cn.ts +109 -0
- package/packages/pi-ai/src/models/generated/minimax.ts +109 -0
- package/packages/pi-ai/src/models/generated/mistral.ts +449 -0
- package/packages/pi-ai/src/models/generated/openai-codex.ts +143 -0
- package/packages/pi-ai/src/models/generated/openai.ts +704 -0
- package/packages/pi-ai/src/models/generated/opencode-go.ts +126 -0
- package/packages/pi-ai/src/models/generated/opencode.ts +534 -0
- package/packages/pi-ai/src/models/generated/openrouter.ts +4274 -0
- package/packages/pi-ai/src/models/generated/vercel-ai-gateway.ts +2608 -0
- package/packages/pi-ai/src/models/generated/xai.ts +415 -0
- package/packages/pi-ai/src/models/generated/zai.ts +241 -0
- package/packages/pi-ai/src/models/index.ts +106 -0
- package/packages/pi-ai/src/models.generated.test.ts +1 -2
- package/packages/pi-ai/src/models.test.ts +6 -5
- package/packages/pi-ai/src/models.ts +3 -153
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +8 -2
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +359 -7
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js +61 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +23 -9
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +53 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts +8 -5
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +27 -13
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +8 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +68 -8
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js +22 -22
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +192 -22
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js +38 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +14 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +70 -6
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +12 -6
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +453 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.ts +92 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +19 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +25 -10
- package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +75 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/compaction-summary-message.ts +36 -15
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +83 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/user-message.ts +23 -26
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +253 -45
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-ordering.test.ts +44 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +92 -6
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +9 -2
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/src/tui.ts +9 -1
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/src/resources/extensions/gsd/auto/phases.ts +70 -6
- package/src/resources/extensions/gsd/auto-model-selection.ts +3 -3
- package/src/resources/extensions/gsd/auto-post-unit.ts +7 -3
- package/src/resources/extensions/gsd/auto-recovery.ts +29 -9
- package/src/resources/extensions/gsd/auto-worktree.ts +1 -0
- package/src/resources/extensions/gsd/bootstrap/provider-error-resume.ts +5 -3
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +15 -1
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +72 -8
- package/src/resources/extensions/gsd/cache.ts +16 -5
- package/src/resources/extensions/gsd/commands/catalog.ts +6 -1
- package/src/resources/extensions/gsd/commands/handlers/core.ts +5 -1
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +5 -0
- package/src/resources/extensions/gsd/commands-extract-learnings.ts +304 -0
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +57 -3
- package/src/resources/extensions/gsd/docs/preferences-reference.md +2 -0
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +228 -0
- package/src/resources/extensions/gsd/ecosystem/loader.ts +201 -0
- package/src/resources/extensions/gsd/guided-flow.ts +4 -2
- package/src/resources/extensions/gsd/preferences-types.ts +6 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +10 -0
- package/src/resources/extensions/gsd/preferences.ts +6 -0
- package/src/resources/extensions/gsd/safety/evidence-collector.ts +15 -31
- package/src/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
- package/src/resources/extensions/gsd/tests/artifacts-table-preserved-on-cache-invalidate.test.ts +177 -0
- package/src/resources/extensions/gsd/tests/auto-retry-mcp-churn-fixes.test.ts +272 -0
- package/src/resources/extensions/gsd/tests/auto-warning-noise-regression.test.ts +117 -0
- package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +340 -0
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/preferences.test.ts +145 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +57 -2
- package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +1 -1
- package/src/resources/extensions/gsd/types.ts +13 -0
- package/src/resources/extensions/gsd/workflow-logger.ts +2 -1
- package/packages/pi-ai/dist/models.custom.d.ts.map +0 -1
- package/packages/pi-ai/dist/models.custom.js.map +0 -1
- package/packages/pi-ai/dist/models.generated.js +0 -14343
- package/packages/pi-ai/dist/models.generated.js.map +0 -1
- package/packages/pi-ai/src/models.generated.ts +0 -14345
- /package/dist/web/standalone/.next/static/{bc2gRVFTgD7j--BsJE7vP → wuiYdNtJdo9ISED55DAkz}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{bc2gRVFTgD7j--BsJE7vP → wuiYdNtJdo9ISED55DAkz}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSD Command — /gsd extract-learnings
|
|
3
|
+
*
|
|
4
|
+
* Analyses completed milestone artefacts and dispatches an LLM turn that
|
|
5
|
+
* extracts structured knowledge into 4 categories:
|
|
6
|
+
* Decisions · Lessons · Patterns · Surprises
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import { join, basename } from "node:path";
|
|
10
|
+
import { gsdRoot, resolveMilestonePath } from "./paths.js";
|
|
11
|
+
import { projectRoot } from "./commands/context.js";
|
|
12
|
+
// ─── Pure functions ───────────────────────────────────────────────────────────
|
|
13
|
+
export function parseExtractLearningsArgs(args) {
|
|
14
|
+
const trimmed = args.trim();
|
|
15
|
+
return { milestoneId: trimmed || null };
|
|
16
|
+
}
|
|
17
|
+
export function buildLearningsOutputPath(milestoneDir, milestoneId) {
|
|
18
|
+
return join(milestoneDir, `${milestoneId}-LEARNINGS.md`);
|
|
19
|
+
}
|
|
20
|
+
export function resolvePhaseArtifacts(milestoneDir, milestoneId) {
|
|
21
|
+
const missingRequired = [];
|
|
22
|
+
const planFile = `${milestoneId}-PLAN.md`;
|
|
23
|
+
const summaryFile = `${milestoneId}-SUMMARY.md`;
|
|
24
|
+
const verificationFile = `${milestoneId}-VERIFICATION.md`;
|
|
25
|
+
const uatFile = `${milestoneId}-UAT.md`;
|
|
26
|
+
const planPath = join(milestoneDir, planFile);
|
|
27
|
+
const summaryPath = join(milestoneDir, summaryFile);
|
|
28
|
+
const verificationPath = join(milestoneDir, verificationFile);
|
|
29
|
+
const uatPath = join(milestoneDir, uatFile);
|
|
30
|
+
const plan = existsSync(planPath) ? planPath : null;
|
|
31
|
+
const summary = existsSync(summaryPath) ? summaryPath : null;
|
|
32
|
+
const verification = existsSync(verificationPath) ? verificationPath : null;
|
|
33
|
+
const uat = existsSync(uatPath) ? uatPath : null;
|
|
34
|
+
if (!plan)
|
|
35
|
+
missingRequired.push(planFile);
|
|
36
|
+
if (!summary)
|
|
37
|
+
missingRequired.push(summaryFile);
|
|
38
|
+
return { plan, summary, verification, uat, missingRequired };
|
|
39
|
+
}
|
|
40
|
+
export function buildExtractLearningsPrompt(ctx) {
|
|
41
|
+
const optionalSections = [];
|
|
42
|
+
if (ctx.verificationContent) {
|
|
43
|
+
optionalSections.push(`## Verification Report\n\n${ctx.verificationContent}`);
|
|
44
|
+
}
|
|
45
|
+
if (ctx.uatContent) {
|
|
46
|
+
optionalSections.push(`## UAT Report\n\n${ctx.uatContent}`);
|
|
47
|
+
}
|
|
48
|
+
const missingNote = ctx.missingArtifacts.length > 0
|
|
49
|
+
? `\nNote: The following optional artefacts were not available: ${ctx.missingArtifacts.join(", ")}\n`
|
|
50
|
+
: "";
|
|
51
|
+
return `# Extract Learnings — ${ctx.milestoneId}: ${ctx.milestoneName}
|
|
52
|
+
|
|
53
|
+
**Project:** ${ctx.projectName}
|
|
54
|
+
**Output file:** ${ctx.outputPath}
|
|
55
|
+
|
|
56
|
+
## Your Task
|
|
57
|
+
|
|
58
|
+
Analyse the artefacts below and extract structured knowledge from milestone **${ctx.milestoneId}**.
|
|
59
|
+
|
|
60
|
+
Write a LEARNINGS document to \`${ctx.outputPath}\` with the following 4 sections:
|
|
61
|
+
|
|
62
|
+
### Decisions
|
|
63
|
+
Key architectural and design decisions made during this milestone, including the rationale and alternatives considered.
|
|
64
|
+
|
|
65
|
+
### Lessons
|
|
66
|
+
What the team learned — technical discoveries, process insights, and knowledge gaps that were filled.
|
|
67
|
+
|
|
68
|
+
### Patterns
|
|
69
|
+
Reusable patterns, approaches, or solutions that emerged and should be applied in future work.
|
|
70
|
+
|
|
71
|
+
### Surprises
|
|
72
|
+
Unexpected challenges, discoveries, or outcomes — things that deviated from assumptions.
|
|
73
|
+
|
|
74
|
+
### Source Attribution (REQUIRED)
|
|
75
|
+
|
|
76
|
+
Every extracted item MUST include a \`Source:\` line immediately after the item text.
|
|
77
|
+
Format: \`Source: {artifact-filename}/{section}\`
|
|
78
|
+
Example: \`Source: M001-PLAN.md/Architecture Decisions\`
|
|
79
|
+
|
|
80
|
+
Items without a Source attribution are invalid and must not be included in the output.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Artefacts
|
|
85
|
+
|
|
86
|
+
### Plan
|
|
87
|
+
|
|
88
|
+
${ctx.planContent}
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### Summary
|
|
93
|
+
|
|
94
|
+
${ctx.summaryContent}
|
|
95
|
+
|
|
96
|
+
${optionalSections.join("\n\n---\n\n")}
|
|
97
|
+
${missingNote}
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Output Format
|
|
101
|
+
|
|
102
|
+
Write the LEARNINGS file to \`${ctx.relativeOutputPath}\` with YAML frontmatter followed by the 4 sections above.
|
|
103
|
+
Each section should contain concise, actionable bullet points.
|
|
104
|
+
Every bullet point MUST be followed by a source line, for example:
|
|
105
|
+
|
|
106
|
+
\`\`\`
|
|
107
|
+
### Decisions
|
|
108
|
+
- Chose PostgreSQL over SQLite for concurrent write support.
|
|
109
|
+
Source: M001-PLAN.md/Architecture Decisions
|
|
110
|
+
\`\`\`
|
|
111
|
+
|
|
112
|
+
Items without a \`Source:\` line are invalid.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Optional: Capture Individual Learnings
|
|
117
|
+
|
|
118
|
+
If the \`capture_thought\` tool is available, call it once for each extracted item with:
|
|
119
|
+
- category: "decision" | "lesson" | "pattern" | "surprise"
|
|
120
|
+
- phase: "${ctx.milestoneId}"
|
|
121
|
+
- content: {the learning text}
|
|
122
|
+
- source: {artifact filename}
|
|
123
|
+
|
|
124
|
+
If \`capture_thought\` is not available, skip this step silently — do not report an error.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Rebuild Knowledge Graph
|
|
129
|
+
|
|
130
|
+
After writing LEARNINGS.md, call the \`gsd_graph\` tool with \`{ "mode": "build" }\` to rebuild the knowledge graph so the new learnings are immediately queryable by future milestone prompts.
|
|
131
|
+
|
|
132
|
+
If the \`gsd_graph\` tool is not available, skip this step silently.
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
export function buildFrontmatter(ctx) {
|
|
136
|
+
const missingList = ctx.missingArtifacts.length > 0
|
|
137
|
+
? ctx.missingArtifacts.map((a) => ` - ${a}`).join("\n")
|
|
138
|
+
: " []";
|
|
139
|
+
const missingValue = ctx.missingArtifacts.length > 0
|
|
140
|
+
? `\n${missingList}`
|
|
141
|
+
: " []";
|
|
142
|
+
return `---
|
|
143
|
+
phase: ${ctx.milestoneId}
|
|
144
|
+
phase_name: ${ctx.milestoneName}
|
|
145
|
+
project: ${ctx.projectName}
|
|
146
|
+
generated: ${ctx.generatedAt}
|
|
147
|
+
counts:
|
|
148
|
+
decisions: ${ctx.counts.decisions}
|
|
149
|
+
lessons: ${ctx.counts.lessons}
|
|
150
|
+
patterns: ${ctx.counts.patterns}
|
|
151
|
+
surprises: ${ctx.counts.surprises}
|
|
152
|
+
missing_artifacts:${missingValue}
|
|
153
|
+
---`;
|
|
154
|
+
}
|
|
155
|
+
export function extractProjectName(basePath) {
|
|
156
|
+
const projectMdPath = join(gsdRoot(basePath), "PROJECT.md");
|
|
157
|
+
if (existsSync(projectMdPath)) {
|
|
158
|
+
try {
|
|
159
|
+
const content = readFileSync(projectMdPath, "utf-8");
|
|
160
|
+
const match = content.match(/^name:\s*(.+)$/m);
|
|
161
|
+
if (match)
|
|
162
|
+
return match[1].trim();
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// non-fatal
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return basename(basePath);
|
|
169
|
+
}
|
|
170
|
+
// ─── Handler ──────────────────────────────────────────────────────────────────
|
|
171
|
+
export async function handleExtractLearnings(args, ctx, pi) {
|
|
172
|
+
const { milestoneId } = parseExtractLearningsArgs(args);
|
|
173
|
+
if (!milestoneId) {
|
|
174
|
+
ctx.ui.notify("Usage: /gsd extract-learnings <milestoneId> (e.g. M001)", "warning");
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
// projectRoot() throws GSDNoProjectError if no project found — intentional, handled by dispatcher
|
|
178
|
+
const basePath = projectRoot();
|
|
179
|
+
const milestoneDir = resolveMilestonePath(basePath, milestoneId);
|
|
180
|
+
if (!milestoneDir) {
|
|
181
|
+
ctx.ui.notify(`Milestone not found: ${milestoneId}`, "error");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const artifacts = resolvePhaseArtifacts(milestoneDir, milestoneId);
|
|
185
|
+
if (artifacts.missingRequired.length > 0) {
|
|
186
|
+
ctx.ui.notify(`Cannot extract learnings — required artefacts missing: ${artifacts.missingRequired.join(", ")}`, "error");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
// Read required artefacts
|
|
190
|
+
const planContent = readFileSync(artifacts.plan, "utf-8");
|
|
191
|
+
const summaryContent = readFileSync(artifacts.summary, "utf-8");
|
|
192
|
+
// Read optional artefacts
|
|
193
|
+
const verificationContent = artifacts.verification
|
|
194
|
+
? readFileSync(artifacts.verification, "utf-8")
|
|
195
|
+
: null;
|
|
196
|
+
const uatContent = artifacts.uat
|
|
197
|
+
? readFileSync(artifacts.uat, "utf-8")
|
|
198
|
+
: null;
|
|
199
|
+
// Determine missing optional artefacts for context
|
|
200
|
+
const missingArtifacts = [];
|
|
201
|
+
if (!artifacts.verification)
|
|
202
|
+
missingArtifacts.push(`${milestoneId}-VERIFICATION.md`);
|
|
203
|
+
if (!artifacts.uat)
|
|
204
|
+
missingArtifacts.push(`${milestoneId}-UAT.md`);
|
|
205
|
+
// Extract milestone name from Plan H1 or fall back to milestoneId
|
|
206
|
+
const h1Match = planContent.match(/^#\s+(.+)$/m);
|
|
207
|
+
const milestoneName = h1Match?.[1]?.trim() ?? milestoneId;
|
|
208
|
+
const projectName = extractProjectName(basePath);
|
|
209
|
+
const outputPath = buildLearningsOutputPath(milestoneDir, milestoneId);
|
|
210
|
+
const relativeOutputPath = outputPath.replace(basePath + "/", "");
|
|
211
|
+
const prompt = buildExtractLearningsPrompt({
|
|
212
|
+
milestoneId,
|
|
213
|
+
milestoneName,
|
|
214
|
+
outputPath,
|
|
215
|
+
relativeOutputPath,
|
|
216
|
+
planContent,
|
|
217
|
+
summaryContent,
|
|
218
|
+
verificationContent,
|
|
219
|
+
uatContent,
|
|
220
|
+
missingArtifacts,
|
|
221
|
+
projectName,
|
|
222
|
+
});
|
|
223
|
+
ctx.ui.notify(`Extracting learnings for ${milestoneId}: "${milestoneName}"...`, "info");
|
|
224
|
+
pi.sendMessage({ customType: "gsd-extract-learnings", content: prompt, display: false }, { triggerTurn: true });
|
|
225
|
+
}
|
|
@@ -642,8 +642,8 @@ export async function handlePrefsWizard(ctx, scope) {
|
|
|
642
642
|
export function yamlSafeString(val) {
|
|
643
643
|
if (typeof val !== "string")
|
|
644
644
|
return String(val);
|
|
645
|
-
if (/[:#{\[\]'"
|
|
646
|
-
return `"${val.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
645
|
+
if (/[:#{\[\]'"`,|>&*!?@%\r\n]/.test(val) || val.trim() !== val || val === "") {
|
|
646
|
+
return `"${val.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\r/g, "\\r").replace(/\n/g, "\\n")}"`;
|
|
647
647
|
}
|
|
648
648
|
return val;
|
|
649
649
|
}
|
|
@@ -708,7 +708,7 @@ export function serializePreferencesToFrontmatter(prefs) {
|
|
|
708
708
|
"dynamic_routing", "uok", "token_profile", "phases", "parallel",
|
|
709
709
|
"auto_visualize", "auto_report",
|
|
710
710
|
"verification_commands", "verification_auto_fix", "verification_max_retries",
|
|
711
|
-
"search_provider", "context_selection",
|
|
711
|
+
"search_provider", "context_selection", "language",
|
|
712
712
|
];
|
|
713
713
|
const seen = new Set();
|
|
714
714
|
for (const key of orderedKeys) {
|
|
@@ -739,3 +739,50 @@ export async function ensurePreferencesFile(path, ctx, scope) {
|
|
|
739
739
|
ctx.ui.notify(`Using existing ${scope} GSD skill preferences at ${path}`, "info");
|
|
740
740
|
}
|
|
741
741
|
}
|
|
742
|
+
/**
|
|
743
|
+
* Handle `/gsd language [code]` — set or clear the global language preference.
|
|
744
|
+
* Without an argument, shows the current setting.
|
|
745
|
+
* Project-level override can be set by editing `.gsd/preferences.md` directly
|
|
746
|
+
* (project language overrides global when both are set).
|
|
747
|
+
*/
|
|
748
|
+
export async function handleLanguage(args, ctx) {
|
|
749
|
+
const path = getGlobalGSDPreferencesPath();
|
|
750
|
+
const lang = args.trim();
|
|
751
|
+
// Show current setting when called without argument
|
|
752
|
+
if (!lang) {
|
|
753
|
+
const loaded = loadGlobalGSDPreferences();
|
|
754
|
+
const current = loaded?.preferences.language;
|
|
755
|
+
if (current) {
|
|
756
|
+
ctx.ui.notify(`Current language preference: ${current}\nUse /gsd language <name> to change, or /gsd language off to clear.`, "info");
|
|
757
|
+
}
|
|
758
|
+
else {
|
|
759
|
+
ctx.ui.notify("No language preference set. Use /gsd language <name> to set one (e.g. /gsd language Chinese).", "info");
|
|
760
|
+
}
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
// Ensure preferences file exists with the canonical template
|
|
764
|
+
await ensurePreferencesFile(path, ctx, "global");
|
|
765
|
+
// Read via the same validated path as other handlers
|
|
766
|
+
const existing = loadGlobalGSDPreferences();
|
|
767
|
+
const prefs = existing?.preferences ? { ...existing.preferences } : { version: 1 };
|
|
768
|
+
if (lang === "off" || lang === "none" || lang === "clear") {
|
|
769
|
+
delete prefs.language;
|
|
770
|
+
ctx.ui.notify("Language preference cleared. GSD will use the default language.", "info");
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
// Validate before writing — reject values that would fail on next load
|
|
774
|
+
if (lang.length > 50 || /[\r\n]/.test(lang)) {
|
|
775
|
+
ctx.ui.notify("Language value must be 50 characters or fewer with no newlines (e.g. /gsd language Chinese).", "warning");
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
prefs.language = lang;
|
|
779
|
+
ctx.ui.notify(`Language preference set to: ${lang}\nGSD will now respond in ${lang} across all sessions.`, "info");
|
|
780
|
+
}
|
|
781
|
+
const rawContent = existsSync(path) ? readFileSync(path, "utf-8") : `---\nversion: 1\n---\n`;
|
|
782
|
+
const frontmatter = serializePreferencesToFrontmatter(prefs);
|
|
783
|
+
const body = extractBodyAfterFrontmatter(rawContent)
|
|
784
|
+
?? "\n# GSD Skill Preferences\n\nSee `~/.gsd/agent/extensions/gsd/docs/preferences-reference.md` for full field documentation and examples.\n";
|
|
785
|
+
await saveFile(path, `---\n${frontmatter}---${body}`);
|
|
786
|
+
await ctx.waitForIdle();
|
|
787
|
+
await ctx.reload();
|
|
788
|
+
}
|
|
@@ -102,6 +102,8 @@ Setting `prefer_skills: []` does **not** disable skill discovery — it just mea
|
|
|
102
102
|
|
|
103
103
|
- `custom_instructions`: extra durable instructions related to skill use. For operational project knowledge (recurring rules, gotchas, patterns), use `.gsd/KNOWLEDGE.md` instead — it's injected into every agent prompt automatically and agents can append to it during execution.
|
|
104
104
|
|
|
105
|
+
- `language`: preferred response language for all GSD interactions. Accepts any language name or code — `"Chinese"`, `"zh"`, `"German"`, `"de"`, `"日本語"`, etc. When set, GSD injects "Always respond in \<language\>" into every agent's system prompt, including after `/clear`. Quickest way to set it: `/gsd language <name>`. To clear: `/gsd language off`.
|
|
106
|
+
|
|
105
107
|
- `models`: per-stage model selection (applies to both auto-mode and guided-flow dispatches). Keys: `research`, `planning`, `discuss`, `execution`, `execution_simple`, `completion`, `validation`, `subagent`. Values can be:
|
|
106
108
|
- Simple string: `"claude-sonnet-4-6"` — single model, no fallbacks
|
|
107
109
|
- Provider-qualified string: `"bedrock/claude-sonnet-4-6"` — targets a specific provider when the same model ID exists across multiple providers
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// GSD2 — Ecosystem Extension API wrapper
|
|
2
|
+
// Wraps pi's ExtensionAPI to expose typed GSD context (phase + active unit)
|
|
3
|
+
// to extensions loaded from `./.gsd/extensions/`. The wrapper intercepts only
|
|
4
|
+
// `on("before_agent_start", ...)` so GSD can dispatch ecosystem handlers AFTER
|
|
5
|
+
// refreshing state — fixing the load-order race where third-party
|
|
6
|
+
// `.pi/extensions/` handlers see a stale module-level snapshot (#3338).
|
|
7
|
+
//
|
|
8
|
+
// SINGLE-SESSION INVARIANT: the module-level `_snapshot` is per-process.
|
|
9
|
+
// Worktree or project switches do NOT reload extensions, matching pi's
|
|
10
|
+
// `.pi/extensions/` behavior. Only re-launching the CLI rebinds the snapshot.
|
|
11
|
+
import { isGSDActive, getCurrentPhase } from "../../shared/gsd-phase-state.js";
|
|
12
|
+
import { logWarning } from "../workflow-logger.js";
|
|
13
|
+
// ─── Auto-loop phase mapping ────────────────────────────────────────────
|
|
14
|
+
const AUTO_LOOP_PHASE_MAP = {
|
|
15
|
+
"plan-milestone": "planning",
|
|
16
|
+
"plan-slice": "planning",
|
|
17
|
+
"research": "researching",
|
|
18
|
+
"discuss": "discussing",
|
|
19
|
+
"execute-task": "executing",
|
|
20
|
+
"verify": "verifying",
|
|
21
|
+
"summarize-task": "summarizing",
|
|
22
|
+
"summarize-slice": "summarizing",
|
|
23
|
+
"advance": "advancing",
|
|
24
|
+
"validate-milestone": "validating-milestone",
|
|
25
|
+
"complete-milestone": "completing-milestone",
|
|
26
|
+
"replan-slice": "replanning-slice",
|
|
27
|
+
};
|
|
28
|
+
/** Exposed for unit tests. Returns null for unknown keys (does NOT default). */
|
|
29
|
+
export function mapAutoLoopPhase(raw) {
|
|
30
|
+
return AUTO_LOOP_PHASE_MAP[raw] ?? null;
|
|
31
|
+
}
|
|
32
|
+
function resolvePhase(state) {
|
|
33
|
+
if (!state)
|
|
34
|
+
return null;
|
|
35
|
+
if (isGSDActive()) {
|
|
36
|
+
const raw = getCurrentPhase();
|
|
37
|
+
if (raw != null) {
|
|
38
|
+
const mapped = AUTO_LOOP_PHASE_MAP[raw];
|
|
39
|
+
if (mapped)
|
|
40
|
+
return mapped;
|
|
41
|
+
logWarning("ecosystem", `unknown auto-loop phase: ${raw}`);
|
|
42
|
+
// FALL THROUGH to state.phase rather than defaulting to "executing".
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return state.phase;
|
|
46
|
+
}
|
|
47
|
+
function resolveActiveUnit(state) {
|
|
48
|
+
if (!state)
|
|
49
|
+
return null;
|
|
50
|
+
const m = state.activeMilestone;
|
|
51
|
+
const s = state.activeSlice;
|
|
52
|
+
const t = state.activeTask;
|
|
53
|
+
if (!m || !s || !t)
|
|
54
|
+
return null;
|
|
55
|
+
return {
|
|
56
|
+
milestoneId: m.id,
|
|
57
|
+
milestoneTitle: m.title,
|
|
58
|
+
sliceId: s.id,
|
|
59
|
+
sliceTitle: s.title,
|
|
60
|
+
taskId: t.id,
|
|
61
|
+
taskTitle: t.title,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
let _snapshot = { phase: null, activeUnit: null };
|
|
65
|
+
/** Refresh the snapshot from a freshly derived GSDState (or null on failure). */
|
|
66
|
+
export function updateSnapshot(state) {
|
|
67
|
+
_snapshot = {
|
|
68
|
+
phase: resolvePhase(state),
|
|
69
|
+
activeUnit: resolveActiveUnit(state),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function getSnapshotPhase() {
|
|
73
|
+
return _snapshot.phase;
|
|
74
|
+
}
|
|
75
|
+
export function getSnapshotActiveUnit() {
|
|
76
|
+
return _snapshot.activeUnit;
|
|
77
|
+
}
|
|
78
|
+
/** Test-only: reset the snapshot to its initial empty state. */
|
|
79
|
+
export function _resetSnapshot() {
|
|
80
|
+
_snapshot = { phase: null, activeUnit: null };
|
|
81
|
+
}
|
|
82
|
+
// ─── Wrapper factory ────────────────────────────────────────────────────
|
|
83
|
+
/**
|
|
84
|
+
* Build a GSDExtensionAPI by manually delegating every ExtensionAPI method
|
|
85
|
+
* to the underlying pi instance, except `on("before_agent_start", ...)`
|
|
86
|
+
* which is captured into `sharedHandlers` for GSD-owned dispatch.
|
|
87
|
+
*
|
|
88
|
+
* Uses `satisfies GSDExtensionAPI` (NOT `as`) so TypeScript catches drift
|
|
89
|
+
* when pi adds new ExtensionAPI methods.
|
|
90
|
+
*/
|
|
91
|
+
export function createGSDExtensionAPI(pi, sharedHandlers) {
|
|
92
|
+
const wrapper = {
|
|
93
|
+
// ── Event subscription (single intercept point) ────────────────────
|
|
94
|
+
on(event, handler) {
|
|
95
|
+
if (event === "before_agent_start") {
|
|
96
|
+
sharedHandlers.push(handler);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
pi.on(event, handler);
|
|
100
|
+
},
|
|
101
|
+
// ── Event emission ─────────────────────────────────────────────────
|
|
102
|
+
emitBeforeModelSelect: (...args) => pi.emitBeforeModelSelect(...args),
|
|
103
|
+
emitAdjustToolSet: (...args) => pi.emitAdjustToolSet(...args),
|
|
104
|
+
// ── Tool / command / shortcut / flag registration ──────────────────
|
|
105
|
+
registerTool: ((tool) => pi.registerTool(tool)),
|
|
106
|
+
registerCommand: (...args) => pi.registerCommand(...args),
|
|
107
|
+
registerBeforeInstall: (...args) => pi.registerBeforeInstall(...args),
|
|
108
|
+
registerAfterInstall: (...args) => pi.registerAfterInstall(...args),
|
|
109
|
+
registerBeforeRemove: (...args) => pi.registerBeforeRemove(...args),
|
|
110
|
+
registerAfterRemove: (...args) => pi.registerAfterRemove(...args),
|
|
111
|
+
registerShortcut: (...args) => pi.registerShortcut(...args),
|
|
112
|
+
registerFlag: (...args) => pi.registerFlag(...args),
|
|
113
|
+
getFlag: (...args) => pi.getFlag(...args),
|
|
114
|
+
// ── Message rendering ──────────────────────────────────────────────
|
|
115
|
+
registerMessageRenderer: ((customType, renderer) => pi.registerMessageRenderer(customType, renderer)),
|
|
116
|
+
// ── Actions ────────────────────────────────────────────────────────
|
|
117
|
+
sendMessage: ((message, options) => pi.sendMessage(message, options)),
|
|
118
|
+
sendUserMessage: (...args) => pi.sendUserMessage(...args),
|
|
119
|
+
retryLastTurn: () => pi.retryLastTurn(),
|
|
120
|
+
appendEntry: ((customType, data) => pi.appendEntry(customType, data)),
|
|
121
|
+
// ── Session metadata ───────────────────────────────────────────────
|
|
122
|
+
setSessionName: (...args) => pi.setSessionName(...args),
|
|
123
|
+
getSessionName: () => pi.getSessionName(),
|
|
124
|
+
setLabel: (...args) => pi.setLabel(...args),
|
|
125
|
+
exec: (...args) => pi.exec(...args),
|
|
126
|
+
getActiveTools: () => pi.getActiveTools(),
|
|
127
|
+
getAllTools: () => pi.getAllTools(),
|
|
128
|
+
setActiveTools: (...args) => pi.setActiveTools(...args),
|
|
129
|
+
getCommands: () => pi.getCommands(),
|
|
130
|
+
// ── Model & thinking ───────────────────────────────────────────────
|
|
131
|
+
setModel: (...args) => pi.setModel(...args),
|
|
132
|
+
getThinkingLevel: () => pi.getThinkingLevel(),
|
|
133
|
+
setThinkingLevel: (...args) => pi.setThinkingLevel(...args),
|
|
134
|
+
// ── Provider registration ──────────────────────────────────────────
|
|
135
|
+
registerProvider: (...args) => pi.registerProvider(...args),
|
|
136
|
+
unregisterProvider: (...args) => pi.unregisterProvider(...args),
|
|
137
|
+
// ── Shared event bus (passthrough property) ────────────────────────
|
|
138
|
+
events: pi.events,
|
|
139
|
+
// ── GSD-specific additions ─────────────────────────────────────────
|
|
140
|
+
getPhase: () => _snapshot.phase,
|
|
141
|
+
getActiveUnit: () => _snapshot.activeUnit,
|
|
142
|
+
};
|
|
143
|
+
return wrapper;
|
|
144
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// GSD2 — Ecosystem extension loader for ./.gsd/extensions/
|
|
2
|
+
// Discovers and registers single-file extensions that consume GSDExtensionAPI.
|
|
3
|
+
// Trust-gated (mirrors pi's `.pi/extensions/` model) and isolated from pi's
|
|
4
|
+
// own loader chain — handlers run in GSD's own dispatch step, not pi's.
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { getAgentDir } from "@gsd/pi-coding-agent";
|
|
9
|
+
import { logWarning } from "../workflow-logger.js";
|
|
10
|
+
import { createGSDExtensionAPI, } from "./gsd-extension-api.js";
|
|
11
|
+
// ─── Trust check (inlined; pi does not export isProjectTrusted from its
|
|
12
|
+
// package root, and constraint forbids modifying packages/pi-coding-agent/) ─
|
|
13
|
+
const TRUSTED_PROJECTS_FILE = "trusted-projects.json";
|
|
14
|
+
function isProjectTrusted(projectPath, agentDir) {
|
|
15
|
+
const canonical = path.resolve(projectPath);
|
|
16
|
+
const trustedPath = path.join(agentDir, TRUSTED_PROJECTS_FILE);
|
|
17
|
+
try {
|
|
18
|
+
const content = fs.readFileSync(trustedPath, "utf-8");
|
|
19
|
+
const parsed = JSON.parse(content);
|
|
20
|
+
if (Array.isArray(parsed)) {
|
|
21
|
+
return parsed.includes(canonical);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// missing or malformed — treat as untrusted
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
// ─── Ready-promise singleton ────────────────────────────────────────────
|
|
30
|
+
let _readyPromise = null;
|
|
31
|
+
let _untrustedWarned = false;
|
|
32
|
+
/**
|
|
33
|
+
* Discover and register ecosystem extensions from `./.gsd/extensions/`.
|
|
34
|
+
* Idempotent: subsequent calls with the same arguments return the same
|
|
35
|
+
* pending promise (no double-load).
|
|
36
|
+
*/
|
|
37
|
+
export function loadEcosystemExtensions(pi, sharedHandlers, cwd = process.cwd()) {
|
|
38
|
+
if (_readyPromise)
|
|
39
|
+
return _readyPromise;
|
|
40
|
+
_readyPromise = _loadEcosystemExtensionsImpl(pi, sharedHandlers, cwd);
|
|
41
|
+
return _readyPromise;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns a promise that resolves when ecosystem loading has completed.
|
|
45
|
+
* If loading was never kicked off this returns a resolved promise so the
|
|
46
|
+
* `before_agent_start` handler can `await` unconditionally.
|
|
47
|
+
*/
|
|
48
|
+
export function getEcosystemReadyPromise() {
|
|
49
|
+
return _readyPromise ?? Promise.resolve();
|
|
50
|
+
}
|
|
51
|
+
/** Test-only: clear the singleton so tests can re-run loading. */
|
|
52
|
+
export function _resetEcosystemLoader() {
|
|
53
|
+
_readyPromise = null;
|
|
54
|
+
_untrustedWarned = false;
|
|
55
|
+
}
|
|
56
|
+
// ─── Implementation ─────────────────────────────────────────────────────
|
|
57
|
+
async function _loadEcosystemExtensionsImpl(pi, sharedHandlers, cwd) {
|
|
58
|
+
const extDir = path.join(cwd, ".gsd", "extensions");
|
|
59
|
+
if (!fs.existsSync(extDir))
|
|
60
|
+
return;
|
|
61
|
+
// Trust gate: refuse to load arbitrary code from untrusted project dirs.
|
|
62
|
+
if (!isProjectTrusted(cwd, getAgentDir())) {
|
|
63
|
+
if (!_untrustedWarned) {
|
|
64
|
+
_untrustedWarned = true;
|
|
65
|
+
logWarning("ecosystem", ".gsd/extensions present but project is not trusted — skipping ecosystem extensions. Run `pi trust` to opt in.");
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Resolve realpath ONCE so symlink-escape detection has a stable anchor.
|
|
70
|
+
let realExtDir;
|
|
71
|
+
try {
|
|
72
|
+
realExtDir = fs.realpathSync(extDir);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
logWarning("ecosystem", `failed to resolve extensions dir: ${err instanceof Error ? err.message : String(err)}`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let entries;
|
|
79
|
+
try {
|
|
80
|
+
entries = fs
|
|
81
|
+
.readdirSync(extDir)
|
|
82
|
+
.filter((f) => f.endsWith(".js") || f.endsWith(".ts"))
|
|
83
|
+
.sort(); // deterministic load order
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
logWarning("ecosystem", `failed to read extensions dir: ${err instanceof Error ? err.message : String(err)}`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// The wrapper api is built once per loader run and shared by all extensions
|
|
90
|
+
// so they all read from the same module-level snapshot.
|
|
91
|
+
const api = createGSDExtensionAPI(pi, sharedHandlers);
|
|
92
|
+
for (const entry of entries) {
|
|
93
|
+
await _loadOne(extDir, realExtDir, entry, api);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function _loadOne(extDir, realExtDir, entry, api) {
|
|
97
|
+
const fullPath = path.join(extDir, entry);
|
|
98
|
+
// Symlink-escape guard: reject entries whose realpath is not under realExtDir.
|
|
99
|
+
let realFullPath;
|
|
100
|
+
try {
|
|
101
|
+
realFullPath = fs.realpathSync(fullPath);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
logWarning("ecosystem", `failed to resolve ${entry}: ${err instanceof Error ? err.message : String(err)}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const realExtDirWithSep = realExtDir.endsWith(path.sep) ? realExtDir : realExtDir + path.sep;
|
|
108
|
+
if (realFullPath !== realExtDir &&
|
|
109
|
+
!realFullPath.startsWith(realExtDirWithSep)) {
|
|
110
|
+
logWarning("ecosystem", `rejecting ${entry}: realpath escapes extensions dir`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// For .ts files, require a sibling compiled .js — we do not run a TS loader
|
|
114
|
+
// in production. Drop mtime heuristics: if .js exists, prefer it; otherwise warn.
|
|
115
|
+
let importPath = realFullPath;
|
|
116
|
+
if (entry.endsWith(".ts")) {
|
|
117
|
+
const jsSibling = realFullPath.slice(0, -3) + ".js";
|
|
118
|
+
if (fs.existsSync(jsSibling)) {
|
|
119
|
+
importPath = jsSibling;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
logWarning("ecosystem", `${entry}: TypeScript source has no compiled .js sibling — compile it first`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let mod;
|
|
127
|
+
try {
|
|
128
|
+
mod = await import(pathToFileURL(importPath).href);
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
logWarning("ecosystem", `failed to import ${entry}: ${err instanceof Error ? err.message : String(err)}`);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const factory = mod?.default;
|
|
135
|
+
if (typeof factory !== "function") {
|
|
136
|
+
logWarning("ecosystem", `${entry}: default export is not a function`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
await factory(api);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
logWarning("ecosystem", `factory threw for ${entry}: ${err instanceof Error ? err.message : String(err)}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -212,14 +212,16 @@ export function checkAutoStartAfterDiscuss() {
|
|
|
212
212
|
logWarning("guided", `CONTEXT-DRAFT.md unlink failed: ${e.message}`);
|
|
213
213
|
}
|
|
214
214
|
// Cleanup: remove discussion manifest after auto-start (only needed during discussion)
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
if (existsSync(manifestPath)) {
|
|
216
|
+
try {
|
|
217
|
+
unlinkSync(manifestPath);
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
logWarning("guided", `manifest unlink failed: ${e.message}`);
|
|
221
|
+
}
|
|
220
222
|
}
|
|
221
223
|
pendingAutoStartMap.delete(basePath);
|
|
222
|
-
ctx.ui.notify(`Milestone ${milestoneId} ready.`, "
|
|
224
|
+
ctx.ui.notify(`Milestone ${milestoneId} ready.`, "success");
|
|
223
225
|
startAutoDetached(ctx, pi, basePath, false, { step });
|
|
224
226
|
return true;
|
|
225
227
|
}
|
|
@@ -1144,5 +1144,15 @@ export function validatePreferences(preferences) {
|
|
|
1144
1144
|
errors.push(`discuss_depth must be one of: quick, standard, thorough`);
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
+
// ─── Language ────────────────────────────────────────────────────────
|
|
1148
|
+
if (preferences.language !== undefined) {
|
|
1149
|
+
const trimmed = typeof preferences.language === "string" ? preferences.language.trim() : undefined;
|
|
1150
|
+
if (trimmed && trimmed.length <= 50 && !/[\r\n]/.test(trimmed)) {
|
|
1151
|
+
validated.language = trimmed;
|
|
1152
|
+
}
|
|
1153
|
+
else {
|
|
1154
|
+
errors.push(`language must be a non-empty string up to 50 characters with no newlines (e.g. "Chinese", "de", "日本語")`);
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1147
1157
|
return { preferences: validated, errors, warnings };
|
|
1148
1158
|
}
|
|
@@ -360,6 +360,7 @@ function mergePreferences(base, override) {
|
|
|
360
360
|
slice_parallel: (base.slice_parallel || override.slice_parallel)
|
|
361
361
|
? { ...(base.slice_parallel ?? {}), ...(override.slice_parallel ?? {}) }
|
|
362
362
|
: undefined,
|
|
363
|
+
language: override.language ?? base.language,
|
|
363
364
|
};
|
|
364
365
|
}
|
|
365
366
|
function mergeStringLists(base, override) {
|
|
@@ -454,6 +455,10 @@ export function renderPreferencesForSystemPrompt(preferences, resolutions) {
|
|
|
454
455
|
lines.push(` - ${instruction}`);
|
|
455
456
|
}
|
|
456
457
|
}
|
|
458
|
+
if (preferences.language) {
|
|
459
|
+
const safeLang = preferences.language.replace(/[\r\n]/g, " ").slice(0, 50);
|
|
460
|
+
lines.push(`- Language: Always respond in ${safeLang}.`);
|
|
461
|
+
}
|
|
457
462
|
return lines.join("\n");
|
|
458
463
|
}
|
|
459
464
|
// ─── Hook Resolution ──────────────────────────────────────────────────────────
|