gsd-pi 2.74.0-dev.2b524c3 → 2.74.0-dev.703eabc
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/cli.js +85 -0
- package/dist/headless-query.js +4 -1
- package/dist/help-text.js +23 -0
- package/dist/resources/extensions/gsd/activity-log.js +16 -0
- package/dist/resources/extensions/gsd/auto/detect-stuck.js +11 -4
- package/dist/resources/extensions/gsd/auto/loop.js +147 -10
- package/dist/resources/extensions/gsd/auto/phases.js +158 -4
- package/dist/resources/extensions/gsd/auto/session.js +10 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +11 -1
- package/dist/resources/extensions/gsd/auto-model-selection.js +51 -5
- package/dist/resources/extensions/gsd/auto-post-unit.js +220 -17
- package/dist/resources/extensions/gsd/auto-prompts.js +12 -0
- package/dist/resources/extensions/gsd/auto-unit-closeout.js +18 -0
- package/dist/resources/extensions/gsd/auto-verification.js +100 -2
- package/dist/resources/extensions/gsd/auto.js +36 -4
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +30 -8
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +45 -4
- package/dist/resources/extensions/gsd/commands/catalog.js +26 -1
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +25 -0
- package/dist/resources/extensions/gsd/commands/handlers/workflow.js +68 -9
- package/dist/resources/extensions/gsd/commands-add-tests.js +111 -0
- package/dist/resources/extensions/gsd/commands-backlog.js +140 -0
- package/dist/resources/extensions/gsd/commands-do.js +79 -0
- package/dist/resources/extensions/gsd/commands-extract-learnings.js +225 -0
- package/dist/resources/extensions/gsd/commands-maintenance.js +6 -6
- package/dist/resources/extensions/gsd/commands-pr-branch.js +180 -0
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +1 -1
- package/dist/resources/extensions/gsd/commands-session-report.js +82 -0
- package/dist/resources/extensions/gsd/commands-ship.js +187 -0
- package/dist/resources/extensions/gsd/db-writer.js +3 -5
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +14 -1
- 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/git-service.js +49 -1
- package/dist/resources/extensions/gsd/graph-context.js +157 -0
- package/dist/resources/extensions/gsd/gsd-db.js +581 -2
- package/dist/resources/extensions/gsd/guided-flow.js +23 -0
- package/dist/resources/extensions/gsd/index.js +15 -2
- package/dist/resources/extensions/gsd/init-wizard.js +1 -0
- package/dist/resources/extensions/gsd/journal.js +27 -0
- package/dist/resources/extensions/gsd/md-importer.js +3 -4
- package/dist/resources/extensions/gsd/memory-store.js +19 -51
- package/dist/resources/extensions/gsd/metrics.js +19 -0
- package/dist/resources/extensions/gsd/milestone-validation-gates.js +13 -12
- package/dist/resources/extensions/gsd/native-git-bridge.js +7 -4
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +33 -1
- package/dist/resources/extensions/gsd/preferences-models.js +20 -3
- package/dist/resources/extensions/gsd/preferences-types.js +1 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +108 -2
- package/dist/resources/extensions/gsd/preferences.js +26 -0
- package/dist/resources/extensions/gsd/prompts/add-tests.md +35 -0
- package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +12 -2
- package/dist/resources/extensions/gsd/state.js +5 -1
- package/dist/resources/extensions/gsd/templates/PREFERENCES.md +18 -0
- package/dist/resources/extensions/gsd/tools/complete-slice.js +20 -0
- package/dist/resources/extensions/gsd/tools/validate-milestone.js +39 -4
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +3 -14
- package/dist/resources/extensions/gsd/triage-resolution.js +2 -5
- package/dist/resources/extensions/gsd/unit-ownership.js +1 -1
- package/dist/resources/extensions/gsd/uok/audit-toggle.js +7 -0
- package/dist/resources/extensions/gsd/uok/audit.js +40 -0
- package/dist/resources/extensions/gsd/uok/contracts.js +1 -0
- package/dist/resources/extensions/gsd/uok/execution-graph.js +179 -0
- package/dist/resources/extensions/gsd/uok/flags.js +29 -0
- package/dist/resources/extensions/gsd/uok/gate-runner.js +109 -0
- package/dist/resources/extensions/gsd/uok/gitops.js +53 -0
- package/dist/resources/extensions/gsd/uok/kernel.js +80 -0
- package/dist/resources/extensions/gsd/uok/loop-adapter.js +133 -0
- package/dist/resources/extensions/gsd/uok/model-policy.js +66 -0
- package/dist/resources/extensions/gsd/uok/plan-v2.js +132 -0
- package/dist/resources/extensions/gsd/workflow-logger.js +22 -0
- package/dist/resources/extensions/gsd/workflow-manifest.js +8 -69
- package/dist/resources/extensions/gsd/workflow-migration.js +21 -22
- package/dist/resources/extensions/gsd/workflow-projections.js +4 -1
- package/dist/resources/extensions/gsd/workflow-reconcile.js +14 -11
- package/dist/resources/extensions/ttsr/ttsr-manager.js +3 -1
- package/dist/tsconfig.extensions.tsbuildinfo +1 -0
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
- 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 +12 -12
- 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 +3 -2
- package/packages/daemon/package.json +2 -2
- package/packages/mcp-server/dist/index.d.ts +3 -0
- package/packages/mcp-server/dist/index.d.ts.map +1 -1
- package/packages/mcp-server/dist/index.js +3 -0
- package/packages/mcp-server/dist/index.js.map +1 -1
- package/packages/mcp-server/dist/readers/graph.d.ts +87 -0
- package/packages/mcp-server/dist/readers/graph.d.ts.map +1 -0
- package/packages/mcp-server/dist/readers/graph.js +655 -0
- package/packages/mcp-server/dist/readers/graph.js.map +1 -0
- package/packages/mcp-server/dist/readers/index.d.ts +2 -0
- package/packages/mcp-server/dist/readers/index.d.ts.map +1 -1
- package/packages/mcp-server/dist/readers/index.js +1 -0
- package/packages/mcp-server/dist/readers/index.js.map +1 -1
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +65 -0
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/package.json +2 -2
- package/packages/mcp-server/src/index.ts +15 -0
- package/packages/mcp-server/src/readers/graph.test.ts +604 -0
- package/packages/mcp-server/src/readers/graph.ts +855 -0
- package/packages/mcp-server/src/readers/index.ts +12 -0
- package/packages/mcp-server/src/server.ts +83 -0
- package/packages/mcp-server/tsconfig.json +1 -0
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -0
- package/packages/native/package.json +2 -2
- package/packages/native/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-agent-core/tsconfig.json +1 -0
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -0
- 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/package.json +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.json +1 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -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 +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 +472 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.js +52 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +2 -2
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- 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 +47 -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/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +51 -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 +232 -18
- 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 +13 -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 +53 -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 +612 -0
- package/packages/pi-coding-agent/src/core/model-registry-env-fallback.test.ts +59 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +2 -1
- 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 +67 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +66 -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 +298 -41
- 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 +73 -6
- package/packages/pi-coding-agent/src/types/ambient-modules.d.ts +69 -0
- package/packages/pi-coding-agent/tsconfig.json +3 -2
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-tui/package.json +1 -1
- package/packages/pi-tui/tsconfig.json +1 -0
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -0
- package/packages/rpc-client/package.json +1 -1
- package/packages/rpc-client/tsconfig.json +1 -0
- package/packages/rpc-client/tsconfig.tsbuildinfo +1 -0
- package/src/resources/extensions/gsd/activity-log.ts +21 -0
- package/src/resources/extensions/gsd/auto/detect-stuck.ts +12 -4
- package/src/resources/extensions/gsd/auto/loop-deps.ts +10 -0
- package/src/resources/extensions/gsd/auto/loop.ts +159 -10
- package/src/resources/extensions/gsd/auto/phases.ts +191 -4
- package/src/resources/extensions/gsd/auto/session.ts +10 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +16 -6
- package/src/resources/extensions/gsd/auto-model-selection.ts +66 -5
- package/src/resources/extensions/gsd/auto-post-unit.ts +238 -18
- package/src/resources/extensions/gsd/auto-prompts.ts +13 -0
- package/src/resources/extensions/gsd/auto-unit-closeout.ts +25 -1
- package/src/resources/extensions/gsd/auto-verification.ts +129 -2
- package/src/resources/extensions/gsd/auto.ts +41 -2
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +38 -8
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +56 -3
- package/src/resources/extensions/gsd/commands/catalog.ts +26 -1
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +25 -0
- package/src/resources/extensions/gsd/commands/handlers/workflow.ts +74 -9
- package/src/resources/extensions/gsd/commands-add-tests.ts +137 -0
- package/src/resources/extensions/gsd/commands-backlog.ts +182 -0
- package/src/resources/extensions/gsd/commands-do.ts +109 -0
- package/src/resources/extensions/gsd/commands-extract-learnings.ts +304 -0
- package/src/resources/extensions/gsd/commands-maintenance.ts +6 -6
- package/src/resources/extensions/gsd/commands-pr-branch.ts +234 -0
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +1 -1
- package/src/resources/extensions/gsd/commands-session-report.ts +101 -0
- package/src/resources/extensions/gsd/commands-ship.ts +219 -0
- package/src/resources/extensions/gsd/db-writer.ts +3 -5
- package/src/resources/extensions/gsd/docs/preferences-reference.md +14 -1
- 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/git-service.ts +68 -0
- package/src/resources/extensions/gsd/graph-context.ts +212 -0
- package/src/resources/extensions/gsd/gsd-db.ts +788 -3
- package/src/resources/extensions/gsd/guided-flow.ts +32 -0
- package/src/resources/extensions/gsd/index.ts +18 -2
- package/src/resources/extensions/gsd/init-wizard.ts +3 -2
- package/src/resources/extensions/gsd/journal.ts +30 -0
- package/src/resources/extensions/gsd/md-importer.ts +3 -5
- package/src/resources/extensions/gsd/memory-store.ts +31 -62
- package/src/resources/extensions/gsd/metrics.ts +26 -0
- package/src/resources/extensions/gsd/milestone-validation-gates.ts +13 -14
- package/src/resources/extensions/gsd/native-git-bridge.ts +11 -12
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +40 -1
- package/src/resources/extensions/gsd/preferences-models.ts +20 -3
- package/src/resources/extensions/gsd/preferences-types.ts +32 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +107 -2
- package/src/resources/extensions/gsd/preferences.ts +28 -0
- package/src/resources/extensions/gsd/prompts/add-tests.md +35 -0
- package/src/resources/extensions/gsd/session-lock.ts +14 -2
- package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +20 -1
- package/src/resources/extensions/gsd/state.ts +9 -2
- package/src/resources/extensions/gsd/templates/PREFERENCES.md +18 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +7 -3
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/auto-project-root-env.test.ts +7 -3
- package/src/resources/extensions/gsd/tests/cold-resume-db-reopen.test.ts +6 -2
- package/src/resources/extensions/gsd/tests/commands-backlog.test.ts +158 -0
- package/src/resources/extensions/gsd/tests/commands-do.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +340 -0
- package/src/resources/extensions/gsd/tests/commands-pr-branch.test.ts +68 -0
- package/src/resources/extensions/gsd/tests/commands-session-report.test.ts +82 -0
- package/src/resources/extensions/gsd/tests/commands-ship.test.ts +71 -0
- package/src/resources/extensions/gsd/tests/commands-workflow-custom.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/complete-task.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/extension-bootstrap-isolation.test.ts +154 -0
- package/src/resources/extensions/gsd/tests/finalize-timeout-guard.test.ts +10 -7
- package/src/resources/extensions/gsd/tests/graph-context.test.ts +337 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +68 -1
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +1 -2
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -3
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +79 -1
- package/src/resources/extensions/gsd/tests/post-unit-state-rebuild.test.ts +2 -1
- package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +40 -1
- package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/single-writer-invariant.test.ts +180 -0
- package/src/resources/extensions/gsd/tests/token-profile.test.ts +8 -5
- package/src/resources/extensions/gsd/tests/uok-audit-unified.test.ts +101 -0
- package/src/resources/extensions/gsd/tests/uok-contracts.test.ts +85 -0
- package/src/resources/extensions/gsd/tests/uok-execution-graph.test.ts +69 -0
- package/src/resources/extensions/gsd/tests/uok-flags.test.ts +39 -0
- package/src/resources/extensions/gsd/tests/uok-gate-runner.test.ts +70 -0
- package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +85 -0
- package/src/resources/extensions/gsd/tests/uok-gitops-wiring.test.ts +35 -0
- package/src/resources/extensions/gsd/tests/uok-model-policy.test.ts +89 -0
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +167 -0
- package/src/resources/extensions/gsd/tests/uok-preferences.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/validate-milestone-write-order.test.ts +39 -0
- package/src/resources/extensions/gsd/tests/workflow-logger-wiring.test.ts +223 -0
- package/src/resources/extensions/gsd/tools/complete-slice.ts +26 -0
- package/src/resources/extensions/gsd/tools/validate-milestone.ts +48 -3
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +3 -11
- package/src/resources/extensions/gsd/triage-resolution.ts +2 -7
- package/src/resources/extensions/gsd/types.ts +14 -1
- package/src/resources/extensions/gsd/unit-ownership.ts +2 -2
- package/src/resources/extensions/gsd/uok/audit-toggle.ts +9 -0
- package/src/resources/extensions/gsd/uok/audit.ts +51 -0
- package/src/resources/extensions/gsd/uok/contracts.ts +135 -0
- package/src/resources/extensions/gsd/uok/execution-graph.ts +241 -0
- package/src/resources/extensions/gsd/uok/flags.ts +45 -0
- package/src/resources/extensions/gsd/uok/gate-runner.ts +146 -0
- package/src/resources/extensions/gsd/uok/gitops.ts +75 -0
- package/src/resources/extensions/gsd/uok/kernel.ts +105 -0
- package/src/resources/extensions/gsd/uok/loop-adapter.ts +162 -0
- package/src/resources/extensions/gsd/uok/model-policy.ts +112 -0
- package/src/resources/extensions/gsd/uok/plan-v2.ts +156 -0
- package/src/resources/extensions/gsd/workflow-logger.ts +27 -1
- package/src/resources/extensions/gsd/workflow-manifest.ts +9 -104
- package/src/resources/extensions/gsd/workflow-migration.ts +21 -29
- package/src/resources/extensions/gsd/workflow-projections.ts +8 -1
- package/src/resources/extensions/gsd/workflow-reconcile.ts +15 -15
- package/src/resources/extensions/ttsr/ttsr-manager.ts +10 -5
- 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/{YzIEI9sxJy4t5xgClF08g → 3U-oZ5FT59BM7sm2GInic}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{YzIEI9sxJy4t5xgClF08g → 3U-oZ5FT59BM7sm2GInic}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,304 @@
|
|
|
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
|
+
|
|
9
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@gsd/pi-coding-agent";
|
|
10
|
+
|
|
11
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
12
|
+
import { join, basename } from "node:path";
|
|
13
|
+
|
|
14
|
+
import { gsdRoot, resolveMilestonePath } from "./paths.js";
|
|
15
|
+
import { projectRoot } from "./commands/context.js";
|
|
16
|
+
|
|
17
|
+
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
export interface PhaseArtifacts {
|
|
20
|
+
plan: string | null;
|
|
21
|
+
summary: string | null;
|
|
22
|
+
verification: string | null;
|
|
23
|
+
uat: string | null;
|
|
24
|
+
missingRequired: string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ExtractLearningsPromptContext {
|
|
28
|
+
milestoneId: string;
|
|
29
|
+
milestoneName: string;
|
|
30
|
+
outputPath: string;
|
|
31
|
+
relativeOutputPath: string;
|
|
32
|
+
planContent: string;
|
|
33
|
+
summaryContent: string;
|
|
34
|
+
verificationContent: string | null;
|
|
35
|
+
uatContent: string | null;
|
|
36
|
+
missingArtifacts: string[];
|
|
37
|
+
projectName: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface FrontmatterContext {
|
|
41
|
+
milestoneId: string;
|
|
42
|
+
milestoneName: string;
|
|
43
|
+
projectName: string;
|
|
44
|
+
generatedAt: string;
|
|
45
|
+
counts: {
|
|
46
|
+
decisions: number;
|
|
47
|
+
lessons: number;
|
|
48
|
+
patterns: number;
|
|
49
|
+
surprises: number;
|
|
50
|
+
};
|
|
51
|
+
missingArtifacts: string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ─── Pure functions ───────────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
export function parseExtractLearningsArgs(args: string): { milestoneId: string | null } {
|
|
57
|
+
const trimmed = args.trim();
|
|
58
|
+
return { milestoneId: trimmed || null };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function buildLearningsOutputPath(milestoneDir: string, milestoneId: string): string {
|
|
62
|
+
return join(milestoneDir, `${milestoneId}-LEARNINGS.md`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function resolvePhaseArtifacts(milestoneDir: string, milestoneId: string): PhaseArtifacts {
|
|
66
|
+
const missingRequired: string[] = [];
|
|
67
|
+
|
|
68
|
+
const planFile = `${milestoneId}-PLAN.md`;
|
|
69
|
+
const summaryFile = `${milestoneId}-SUMMARY.md`;
|
|
70
|
+
const verificationFile = `${milestoneId}-VERIFICATION.md`;
|
|
71
|
+
const uatFile = `${milestoneId}-UAT.md`;
|
|
72
|
+
|
|
73
|
+
const planPath = join(milestoneDir, planFile);
|
|
74
|
+
const summaryPath = join(milestoneDir, summaryFile);
|
|
75
|
+
const verificationPath = join(milestoneDir, verificationFile);
|
|
76
|
+
const uatPath = join(milestoneDir, uatFile);
|
|
77
|
+
|
|
78
|
+
const plan = existsSync(planPath) ? planPath : null;
|
|
79
|
+
const summary = existsSync(summaryPath) ? summaryPath : null;
|
|
80
|
+
const verification = existsSync(verificationPath) ? verificationPath : null;
|
|
81
|
+
const uat = existsSync(uatPath) ? uatPath : null;
|
|
82
|
+
|
|
83
|
+
if (!plan) missingRequired.push(planFile);
|
|
84
|
+
if (!summary) missingRequired.push(summaryFile);
|
|
85
|
+
|
|
86
|
+
return { plan, summary, verification, uat, missingRequired };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function buildExtractLearningsPrompt(ctx: ExtractLearningsPromptContext): string {
|
|
90
|
+
const optionalSections: string[] = [];
|
|
91
|
+
|
|
92
|
+
if (ctx.verificationContent) {
|
|
93
|
+
optionalSections.push(`## Verification Report\n\n${ctx.verificationContent}`);
|
|
94
|
+
}
|
|
95
|
+
if (ctx.uatContent) {
|
|
96
|
+
optionalSections.push(`## UAT Report\n\n${ctx.uatContent}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const missingNote = ctx.missingArtifacts.length > 0
|
|
100
|
+
? `\nNote: The following optional artefacts were not available: ${ctx.missingArtifacts.join(", ")}\n`
|
|
101
|
+
: "";
|
|
102
|
+
|
|
103
|
+
return `# Extract Learnings — ${ctx.milestoneId}: ${ctx.milestoneName}
|
|
104
|
+
|
|
105
|
+
**Project:** ${ctx.projectName}
|
|
106
|
+
**Output file:** ${ctx.outputPath}
|
|
107
|
+
|
|
108
|
+
## Your Task
|
|
109
|
+
|
|
110
|
+
Analyse the artefacts below and extract structured knowledge from milestone **${ctx.milestoneId}**.
|
|
111
|
+
|
|
112
|
+
Write a LEARNINGS document to \`${ctx.outputPath}\` with the following 4 sections:
|
|
113
|
+
|
|
114
|
+
### Decisions
|
|
115
|
+
Key architectural and design decisions made during this milestone, including the rationale and alternatives considered.
|
|
116
|
+
|
|
117
|
+
### Lessons
|
|
118
|
+
What the team learned — technical discoveries, process insights, and knowledge gaps that were filled.
|
|
119
|
+
|
|
120
|
+
### Patterns
|
|
121
|
+
Reusable patterns, approaches, or solutions that emerged and should be applied in future work.
|
|
122
|
+
|
|
123
|
+
### Surprises
|
|
124
|
+
Unexpected challenges, discoveries, or outcomes — things that deviated from assumptions.
|
|
125
|
+
|
|
126
|
+
### Source Attribution (REQUIRED)
|
|
127
|
+
|
|
128
|
+
Every extracted item MUST include a \`Source:\` line immediately after the item text.
|
|
129
|
+
Format: \`Source: {artifact-filename}/{section}\`
|
|
130
|
+
Example: \`Source: M001-PLAN.md/Architecture Decisions\`
|
|
131
|
+
|
|
132
|
+
Items without a Source attribution are invalid and must not be included in the output.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Artefacts
|
|
137
|
+
|
|
138
|
+
### Plan
|
|
139
|
+
|
|
140
|
+
${ctx.planContent}
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### Summary
|
|
145
|
+
|
|
146
|
+
${ctx.summaryContent}
|
|
147
|
+
|
|
148
|
+
${optionalSections.join("\n\n---\n\n")}
|
|
149
|
+
${missingNote}
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Output Format
|
|
153
|
+
|
|
154
|
+
Write the LEARNINGS file to \`${ctx.relativeOutputPath}\` with YAML frontmatter followed by the 4 sections above.
|
|
155
|
+
Each section should contain concise, actionable bullet points.
|
|
156
|
+
Every bullet point MUST be followed by a source line, for example:
|
|
157
|
+
|
|
158
|
+
\`\`\`
|
|
159
|
+
### Decisions
|
|
160
|
+
- Chose PostgreSQL over SQLite for concurrent write support.
|
|
161
|
+
Source: M001-PLAN.md/Architecture Decisions
|
|
162
|
+
\`\`\`
|
|
163
|
+
|
|
164
|
+
Items without a \`Source:\` line are invalid.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Optional: Capture Individual Learnings
|
|
169
|
+
|
|
170
|
+
If the \`capture_thought\` tool is available, call it once for each extracted item with:
|
|
171
|
+
- category: "decision" | "lesson" | "pattern" | "surprise"
|
|
172
|
+
- phase: "${ctx.milestoneId}"
|
|
173
|
+
- content: {the learning text}
|
|
174
|
+
- source: {artifact filename}
|
|
175
|
+
|
|
176
|
+
If \`capture_thought\` is not available, skip this step silently — do not report an error.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Rebuild Knowledge Graph
|
|
181
|
+
|
|
182
|
+
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.
|
|
183
|
+
|
|
184
|
+
If the \`gsd_graph\` tool is not available, skip this step silently.
|
|
185
|
+
`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function buildFrontmatter(ctx: FrontmatterContext): string {
|
|
189
|
+
const missingList = ctx.missingArtifacts.length > 0
|
|
190
|
+
? ctx.missingArtifacts.map((a) => ` - ${a}`).join("\n")
|
|
191
|
+
: " []";
|
|
192
|
+
|
|
193
|
+
const missingValue = ctx.missingArtifacts.length > 0
|
|
194
|
+
? `\n${missingList}`
|
|
195
|
+
: " []";
|
|
196
|
+
|
|
197
|
+
return `---
|
|
198
|
+
phase: ${ctx.milestoneId}
|
|
199
|
+
phase_name: ${ctx.milestoneName}
|
|
200
|
+
project: ${ctx.projectName}
|
|
201
|
+
generated: ${ctx.generatedAt}
|
|
202
|
+
counts:
|
|
203
|
+
decisions: ${ctx.counts.decisions}
|
|
204
|
+
lessons: ${ctx.counts.lessons}
|
|
205
|
+
patterns: ${ctx.counts.patterns}
|
|
206
|
+
surprises: ${ctx.counts.surprises}
|
|
207
|
+
missing_artifacts:${missingValue}
|
|
208
|
+
---`;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function extractProjectName(basePath: string): string {
|
|
212
|
+
const projectMdPath = join(gsdRoot(basePath), "PROJECT.md");
|
|
213
|
+
|
|
214
|
+
if (existsSync(projectMdPath)) {
|
|
215
|
+
try {
|
|
216
|
+
const content = readFileSync(projectMdPath, "utf-8");
|
|
217
|
+
const match = content.match(/^name:\s*(.+)$/m);
|
|
218
|
+
if (match) return match[1].trim();
|
|
219
|
+
} catch {
|
|
220
|
+
// non-fatal
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return basename(basePath);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ─── Handler ──────────────────────────────────────────────────────────────────
|
|
228
|
+
|
|
229
|
+
export async function handleExtractLearnings(
|
|
230
|
+
args: string,
|
|
231
|
+
ctx: ExtensionCommandContext,
|
|
232
|
+
pi: ExtensionAPI,
|
|
233
|
+
): Promise<void> {
|
|
234
|
+
const { milestoneId } = parseExtractLearningsArgs(args);
|
|
235
|
+
|
|
236
|
+
if (!milestoneId) {
|
|
237
|
+
ctx.ui.notify("Usage: /gsd extract-learnings <milestoneId> (e.g. M001)", "warning");
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// projectRoot() throws GSDNoProjectError if no project found — intentional, handled by dispatcher
|
|
242
|
+
const basePath = projectRoot();
|
|
243
|
+
const milestoneDir = resolveMilestonePath(basePath, milestoneId);
|
|
244
|
+
|
|
245
|
+
if (!milestoneDir) {
|
|
246
|
+
ctx.ui.notify(`Milestone not found: ${milestoneId}`, "error");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const artifacts = resolvePhaseArtifacts(milestoneDir, milestoneId);
|
|
251
|
+
|
|
252
|
+
if (artifacts.missingRequired.length > 0) {
|
|
253
|
+
ctx.ui.notify(
|
|
254
|
+
`Cannot extract learnings — required artefacts missing: ${artifacts.missingRequired.join(", ")}`,
|
|
255
|
+
"error",
|
|
256
|
+
);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Read required artefacts
|
|
261
|
+
const planContent = readFileSync(artifacts.plan!, "utf-8");
|
|
262
|
+
const summaryContent = readFileSync(artifacts.summary!, "utf-8");
|
|
263
|
+
|
|
264
|
+
// Read optional artefacts
|
|
265
|
+
const verificationContent = artifacts.verification
|
|
266
|
+
? readFileSync(artifacts.verification, "utf-8")
|
|
267
|
+
: null;
|
|
268
|
+
const uatContent = artifacts.uat
|
|
269
|
+
? readFileSync(artifacts.uat, "utf-8")
|
|
270
|
+
: null;
|
|
271
|
+
|
|
272
|
+
// Determine missing optional artefacts for context
|
|
273
|
+
const missingArtifacts: string[] = [];
|
|
274
|
+
if (!artifacts.verification) missingArtifacts.push(`${milestoneId}-VERIFICATION.md`);
|
|
275
|
+
if (!artifacts.uat) missingArtifacts.push(`${milestoneId}-UAT.md`);
|
|
276
|
+
|
|
277
|
+
// Extract milestone name from Plan H1 or fall back to milestoneId
|
|
278
|
+
const h1Match = planContent.match(/^#\s+(.+)$/m);
|
|
279
|
+
const milestoneName = h1Match?.[1]?.trim() ?? milestoneId;
|
|
280
|
+
|
|
281
|
+
const projectName = extractProjectName(basePath);
|
|
282
|
+
const outputPath = buildLearningsOutputPath(milestoneDir, milestoneId);
|
|
283
|
+
const relativeOutputPath = outputPath.replace(basePath + "/", "");
|
|
284
|
+
|
|
285
|
+
const prompt = buildExtractLearningsPrompt({
|
|
286
|
+
milestoneId,
|
|
287
|
+
milestoneName,
|
|
288
|
+
outputPath,
|
|
289
|
+
relativeOutputPath,
|
|
290
|
+
planContent,
|
|
291
|
+
summaryContent,
|
|
292
|
+
verificationContent,
|
|
293
|
+
uatContent,
|
|
294
|
+
missingArtifacts,
|
|
295
|
+
projectName,
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
ctx.ui.notify(`Extracting learnings for ${milestoneId}: "${milestoneName}"...`, "info");
|
|
299
|
+
|
|
300
|
+
pi.sendMessage(
|
|
301
|
+
{ customType: "gsd-extract-learnings", content: prompt, display: false },
|
|
302
|
+
{ triggerTurn: true },
|
|
303
|
+
);
|
|
304
|
+
}
|
|
@@ -488,7 +488,7 @@ export async function handleCleanupProjects(args: string, ctx: ExtensionCommandC
|
|
|
488
488
|
* Prints counts of recovered items and the resulting project phase.
|
|
489
489
|
*/
|
|
490
490
|
export async function handleRecover(ctx: ExtensionCommandContext, basePath: string): Promise<void> {
|
|
491
|
-
const { isDbAvailable: dbAvailable,
|
|
491
|
+
const { isDbAvailable: dbAvailable, clearEngineHierarchy, transaction: dbTransaction } = await import("./gsd-db.js");
|
|
492
492
|
const { migrateHierarchyToDb } = await import("./md-importer.js");
|
|
493
493
|
const { invalidateStateCache } = await import("./state.js");
|
|
494
494
|
|
|
@@ -498,12 +498,12 @@ export async function handleRecover(ctx: ExtensionCommandContext, basePath: stri
|
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
try {
|
|
501
|
-
// 1. Delete + re-populate inside a single transaction for atomicity
|
|
502
|
-
|
|
501
|
+
// 1. Delete + re-populate inside a single transaction for atomicity.
|
|
502
|
+
// clearEngineHierarchy() uses transaction() internally but transaction()
|
|
503
|
+
// is re-entrant, so wrapping in dbTransaction() keeps the whole
|
|
504
|
+
// clear+repopulate atomic.
|
|
503
505
|
const counts = dbTransaction(() => {
|
|
504
|
-
|
|
505
|
-
db.exec("DELETE FROM slices");
|
|
506
|
-
db.exec("DELETE FROM milestones");
|
|
506
|
+
clearEngineHierarchy();
|
|
507
507
|
return migrateHierarchyToDb(basePath);
|
|
508
508
|
});
|
|
509
509
|
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSD Command — /gsd pr-branch
|
|
3
|
+
*
|
|
4
|
+
* Creates a clean PR branch by cherry-picking commits while stripping
|
|
5
|
+
* any changes to .gsd/, .planning/, and PLAN.md paths. Useful for
|
|
6
|
+
* upstream PRs where planning artifacts should not be included.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { ExtensionCommandContext } from "@gsd/pi-coding-agent";
|
|
10
|
+
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
nativeGetCurrentBranch,
|
|
15
|
+
nativeDetectMainBranch,
|
|
16
|
+
nativeBranchExists,
|
|
17
|
+
} from "./native-git-bridge.js";
|
|
18
|
+
|
|
19
|
+
const EXCLUDED_PATHS = [".gsd", ".planning", "PLAN.md"] as const;
|
|
20
|
+
|
|
21
|
+
function git(basePath: string, args: readonly string[]): string {
|
|
22
|
+
return execFileSync("git", args, { cwd: basePath, encoding: "utf-8" }).trim();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function gitAllowFail(basePath: string, args: readonly string[]): void {
|
|
26
|
+
try {
|
|
27
|
+
execFileSync("git", args, { cwd: basePath, encoding: "utf-8", stdio: "pipe" });
|
|
28
|
+
} catch {
|
|
29
|
+
// ignored — caller opts into non-fatal behavior
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function hasStagedChanges(basePath: string): boolean {
|
|
34
|
+
try {
|
|
35
|
+
execFileSync("git", ["diff", "--cached", "--quiet"], {
|
|
36
|
+
cwd: basePath,
|
|
37
|
+
stdio: "pipe",
|
|
38
|
+
});
|
|
39
|
+
return false;
|
|
40
|
+
} catch {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isValidBranchName(name: string): boolean {
|
|
46
|
+
try {
|
|
47
|
+
execFileSync("git", ["check-ref-format", "--branch", name], { stdio: "pipe" });
|
|
48
|
+
return true;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getCodeOnlyCommits(basePath: string, base: string, head: string): string[] {
|
|
55
|
+
try {
|
|
56
|
+
const allCommits = git(basePath, ["log", "--format=%H", `${base}..${head}`])
|
|
57
|
+
.split("\n")
|
|
58
|
+
.filter(Boolean);
|
|
59
|
+
const codeCommits: string[] = [];
|
|
60
|
+
|
|
61
|
+
for (const sha of allCommits) {
|
|
62
|
+
const files = git(basePath, ["diff-tree", "--no-commit-id", "--name-only", "-r", sha])
|
|
63
|
+
.split("\n")
|
|
64
|
+
.filter(Boolean);
|
|
65
|
+
const hasCodeChanges = files.some(
|
|
66
|
+
(f) => !f.startsWith(".gsd/") && !f.startsWith(".planning/") && f !== "PLAN.md",
|
|
67
|
+
);
|
|
68
|
+
if (hasCodeChanges) {
|
|
69
|
+
codeCommits.push(sha);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return codeCommits.reverse(); // chronological for cherry-picking
|
|
74
|
+
} catch {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Cherry-pick a commit while stripping excluded paths from the resulting
|
|
81
|
+
* commit. Returns true if a commit was produced, false if nothing remained
|
|
82
|
+
* after filtering.
|
|
83
|
+
*/
|
|
84
|
+
function cherryPickFiltered(basePath: string, sha: string): boolean {
|
|
85
|
+
git(basePath, ["cherry-pick", "--no-commit", "--allow-empty", sha]);
|
|
86
|
+
|
|
87
|
+
// Unstage any excluded paths introduced by the cherry-pick.
|
|
88
|
+
gitAllowFail(basePath, ["reset", "HEAD", "--", ...EXCLUDED_PATHS]);
|
|
89
|
+
|
|
90
|
+
// Restore worktree state for excluded paths from HEAD (if tracked),
|
|
91
|
+
// then remove any newly introduced untracked files under those paths.
|
|
92
|
+
gitAllowFail(basePath, ["checkout", "HEAD", "--", ...EXCLUDED_PATHS]);
|
|
93
|
+
gitAllowFail(basePath, ["clean", "-fdq", "--", ...EXCLUDED_PATHS]);
|
|
94
|
+
|
|
95
|
+
if (!hasStagedChanges(basePath)) {
|
|
96
|
+
// Nothing remained after filtering — discard worktree residue and skip.
|
|
97
|
+
git(basePath, ["reset", "--hard", "HEAD"]);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
git(basePath, ["commit", "-C", sha]);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function assertNoExcludedPaths(basePath: string, base: string): void {
|
|
106
|
+
const files = git(basePath, [
|
|
107
|
+
"diff",
|
|
108
|
+
"--name-only",
|
|
109
|
+
`${base}..HEAD`,
|
|
110
|
+
])
|
|
111
|
+
.split("\n")
|
|
112
|
+
.filter(Boolean);
|
|
113
|
+
const leaked = files.filter(
|
|
114
|
+
(f) => f.startsWith(".gsd/") || f.startsWith(".planning/") || f === "PLAN.md",
|
|
115
|
+
);
|
|
116
|
+
if (leaked.length > 0) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
`PR branch still contains excluded paths: ${leaked.slice(0, 5).join(", ")}${
|
|
119
|
+
leaked.length > 5 ? ` (+${leaked.length - 5} more)` : ""
|
|
120
|
+
}`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function handlePrBranch(
|
|
126
|
+
args: string,
|
|
127
|
+
ctx: ExtensionCommandContext,
|
|
128
|
+
): Promise<void> {
|
|
129
|
+
const basePath = process.cwd();
|
|
130
|
+
const dryRun = args.includes("--dry-run");
|
|
131
|
+
const nameMatch = args.match(/--name\s+(\S+)/);
|
|
132
|
+
|
|
133
|
+
const currentBranch = nativeGetCurrentBranch(basePath);
|
|
134
|
+
const mainBranch = nativeDetectMainBranch(basePath);
|
|
135
|
+
|
|
136
|
+
// Determine base ref (prefer upstream/main if available)
|
|
137
|
+
let baseRef: string;
|
|
138
|
+
try {
|
|
139
|
+
git(basePath, ["rev-parse", "--verify", "upstream/main"]);
|
|
140
|
+
baseRef = "upstream/main";
|
|
141
|
+
} catch {
|
|
142
|
+
baseRef = mainBranch;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Find commits with code changes
|
|
146
|
+
const commits = getCodeOnlyCommits(basePath, baseRef, "HEAD");
|
|
147
|
+
|
|
148
|
+
if (commits.length === 0) {
|
|
149
|
+
ctx.ui.notify("No code-only commits found (all commits only touch .gsd/ files).", "info");
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (dryRun) {
|
|
154
|
+
const lines = [`Would create PR branch with ${commits.length} commits (filtering .gsd/ paths):\n`];
|
|
155
|
+
for (const sha of commits) {
|
|
156
|
+
const msg = git(basePath, ["log", "--format=%s", "-1", sha]);
|
|
157
|
+
lines.push(` ${sha.slice(0, 8)} ${msg}`);
|
|
158
|
+
}
|
|
159
|
+
ctx.ui.notify(lines.join("\n"), "info");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const requestedName = nameMatch?.[1];
|
|
164
|
+
if (requestedName && !isValidBranchName(requestedName)) {
|
|
165
|
+
ctx.ui.notify(
|
|
166
|
+
`Invalid branch name: ${requestedName}. Must satisfy git check-ref-format.`,
|
|
167
|
+
"error",
|
|
168
|
+
);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const defaultName = `pr/${currentBranch}`;
|
|
173
|
+
const prBranch = requestedName ?? defaultName;
|
|
174
|
+
|
|
175
|
+
if (!isValidBranchName(prBranch)) {
|
|
176
|
+
ctx.ui.notify(
|
|
177
|
+
`Derived branch name is invalid: ${prBranch}. Use --name to override.`,
|
|
178
|
+
"error",
|
|
179
|
+
);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (nativeBranchExists(basePath, prBranch)) {
|
|
184
|
+
ctx.ui.notify(
|
|
185
|
+
`Branch ${prBranch} already exists. Use --name to specify a different name, or delete it first.`,
|
|
186
|
+
"warning",
|
|
187
|
+
);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
// Create clean branch from base
|
|
193
|
+
git(basePath, ["checkout", "-b", prBranch, baseRef]);
|
|
194
|
+
|
|
195
|
+
// Cherry-pick with path filter
|
|
196
|
+
let picked = 0;
|
|
197
|
+
let skipped = 0;
|
|
198
|
+
for (const sha of commits) {
|
|
199
|
+
try {
|
|
200
|
+
if (cherryPickFiltered(basePath, sha)) {
|
|
201
|
+
picked++;
|
|
202
|
+
} else {
|
|
203
|
+
skipped++;
|
|
204
|
+
}
|
|
205
|
+
} catch (pickErr) {
|
|
206
|
+
gitAllowFail(basePath, ["cherry-pick", "--abort"]);
|
|
207
|
+
gitAllowFail(basePath, ["reset", "--hard", "HEAD"]);
|
|
208
|
+
const detail = pickErr instanceof Error ? pickErr.message : String(pickErr);
|
|
209
|
+
ctx.ui.notify(
|
|
210
|
+
`Cherry-pick conflict at ${sha.slice(0, 8)}. Picked ${picked}/${commits.length} commits. Resolve manually.\n${detail}`,
|
|
211
|
+
"warning",
|
|
212
|
+
);
|
|
213
|
+
git(basePath, ["checkout", currentBranch]);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Post-condition: no excluded paths should appear in the PR branch diff.
|
|
219
|
+
assertNoExcludedPaths(basePath, baseRef);
|
|
220
|
+
|
|
221
|
+
const skippedMsg = skipped > 0 ? ` (${skipped} skipped — contained only planning artifacts)` : "";
|
|
222
|
+
ctx.ui.notify(
|
|
223
|
+
`Created ${prBranch} with ${picked} commits${skippedMsg} (no .gsd/ artifacts).\nSwitch back: git checkout ${currentBranch}`,
|
|
224
|
+
"success",
|
|
225
|
+
);
|
|
226
|
+
} catch (err) {
|
|
227
|
+
// Restore original branch on failure
|
|
228
|
+
gitAllowFail(basePath, ["cherry-pick", "--abort"]);
|
|
229
|
+
gitAllowFail(basePath, ["reset", "--hard", "HEAD"]);
|
|
230
|
+
gitAllowFail(basePath, ["checkout", currentBranch]);
|
|
231
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
232
|
+
ctx.ui.notify(`Failed to create PR branch: ${msg}`, "error");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -822,7 +822,7 @@ export function serializePreferencesToFrontmatter(prefs: Record<string, unknown>
|
|
|
822
822
|
"budget_ceiling", "budget_enforcement", "context_pause_threshold",
|
|
823
823
|
"notifications", "cmux", "remote_questions", "git",
|
|
824
824
|
"post_unit_hooks", "pre_dispatch_hooks",
|
|
825
|
-
"dynamic_routing", "token_profile", "phases", "parallel",
|
|
825
|
+
"dynamic_routing", "uok", "token_profile", "phases", "parallel",
|
|
826
826
|
"auto_visualize", "auto_report",
|
|
827
827
|
"verification_commands", "verification_auto_fix", "verification_max_retries",
|
|
828
828
|
"search_provider", "context_selection",
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSD Command — /gsd session-report
|
|
3
|
+
*
|
|
4
|
+
* Summarizes the current session: tasks completed, cost, tokens,
|
|
5
|
+
* duration, model usage breakdown.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionCommandContext } from "@gsd/pi-coding-agent";
|
|
9
|
+
|
|
10
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
|
|
13
|
+
import { getLedger, getProjectTotals, aggregateByModel, formatCost, formatTokenCount, loadLedgerFromDisk } from "./metrics.js";
|
|
14
|
+
import type { UnitMetrics } from "./metrics.js";
|
|
15
|
+
import { gsdRoot } from "./paths.js";
|
|
16
|
+
import { formatDuration } from "../shared/format-utils.js";
|
|
17
|
+
|
|
18
|
+
function formatSessionReport(units: UnitMetrics[]): string {
|
|
19
|
+
const totals = getProjectTotals(units);
|
|
20
|
+
const byModel = aggregateByModel(units);
|
|
21
|
+
|
|
22
|
+
const lines: string[] = [];
|
|
23
|
+
lines.push("╭─ Session Report ──────────────────────────────────────╮");
|
|
24
|
+
|
|
25
|
+
if (totals.duration > 0) {
|
|
26
|
+
lines.push(`│ Duration: ${formatDuration(totals.duration).padEnd(40)}│`);
|
|
27
|
+
}
|
|
28
|
+
lines.push(`│ Units: ${String(units.length).padEnd(40)}│`);
|
|
29
|
+
lines.push(`│ Cost: ${formatCost(totals.cost).padEnd(40)}│`);
|
|
30
|
+
lines.push(`│ Tokens: ${`${formatTokenCount(totals.tokens.input)} in / ${formatTokenCount(totals.tokens.output)} out`.padEnd(40)}│`);
|
|
31
|
+
lines.push("│ │");
|
|
32
|
+
|
|
33
|
+
// Work completed
|
|
34
|
+
if (units.length > 0) {
|
|
35
|
+
lines.push("│ Work Completed: │");
|
|
36
|
+
for (const unit of units) {
|
|
37
|
+
const finished = unit.finishedAt > 0;
|
|
38
|
+
const status = finished ? "✓" : "•";
|
|
39
|
+
const label = ` ${status} ${unit.id ?? "unknown"}`;
|
|
40
|
+
lines.push(`│ ${label.padEnd(53)}│`);
|
|
41
|
+
}
|
|
42
|
+
lines.push("│ │");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Model usage
|
|
46
|
+
if (byModel.length > 0) {
|
|
47
|
+
lines.push("│ Model Usage: │");
|
|
48
|
+
for (const m of byModel) {
|
|
49
|
+
const label = ` ${m.model}: ${m.units} units (${formatCost(m.cost)})`;
|
|
50
|
+
lines.push(`│ ${label.padEnd(53)}│`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
lines.push("╰───────────────────────────────────────────────────────╯");
|
|
55
|
+
return lines.join("\n");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function handleSessionReport(
|
|
59
|
+
args: string,
|
|
60
|
+
ctx: ExtensionCommandContext,
|
|
61
|
+
): Promise<void> {
|
|
62
|
+
const basePath = process.cwd();
|
|
63
|
+
|
|
64
|
+
// Get units from in-memory ledger or disk
|
|
65
|
+
const ledger = getLedger();
|
|
66
|
+
let units: UnitMetrics[];
|
|
67
|
+
|
|
68
|
+
if (ledger && ledger.units.length > 0) {
|
|
69
|
+
units = ledger.units;
|
|
70
|
+
} else {
|
|
71
|
+
const diskLedger = loadLedgerFromDisk(basePath);
|
|
72
|
+
if (!diskLedger || diskLedger.units.length === 0) {
|
|
73
|
+
ctx.ui.notify("No session data — no units have been executed yet.", "info");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
units = diskLedger.units;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// JSON output
|
|
80
|
+
if (args.includes("--json")) {
|
|
81
|
+
const totals = getProjectTotals(units);
|
|
82
|
+
const byModel = aggregateByModel(units);
|
|
83
|
+
ctx.ui.notify(JSON.stringify({ units: units.length, totals, byModel }, null, 2), "info");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Save to file
|
|
88
|
+
if (args.includes("--save")) {
|
|
89
|
+
const report = formatSessionReport(units);
|
|
90
|
+
const reportsDir = join(gsdRoot(basePath), "reports");
|
|
91
|
+
mkdirSync(reportsDir, { recursive: true });
|
|
92
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
93
|
+
const outPath = join(reportsDir, `session-${timestamp}.md`);
|
|
94
|
+
writeFileSync(outPath, `\`\`\`\n${report}\n\`\`\`\n`, "utf-8");
|
|
95
|
+
ctx.ui.notify(`Report saved: ${outPath}`, "success");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Display
|
|
100
|
+
ctx.ui.notify(formatSessionReport(units), "info");
|
|
101
|
+
}
|