gsd-pi 2.76.0 → 2.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -25
- package/dist/claude-cli-check.js +32 -3
- package/dist/mcp-server.d.ts +7 -0
- package/dist/mcp-server.js +35 -1
- package/dist/onboarding.js +45 -0
- package/dist/resource-loader.d.ts +1 -1
- package/dist/resource-loader.js +2 -8
- package/dist/resources/agents/researcher.md +1 -1
- package/dist/resources/extensions/claude-code-cli/readiness.js +31 -8
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +77 -17
- package/dist/resources/extensions/gsd/auto/loop.js +9 -0
- package/dist/resources/extensions/gsd/auto/phases.js +104 -11
- package/dist/resources/extensions/gsd/auto/run-unit.js +38 -2
- package/dist/resources/extensions/gsd/auto/session.js +22 -1
- package/dist/resources/extensions/gsd/auto-dispatch.js +16 -3
- package/dist/resources/extensions/gsd/auto-model-selection.js +53 -16
- package/dist/resources/extensions/gsd/auto-post-unit.js +25 -2
- package/dist/resources/extensions/gsd/auto-prompts.js +14 -0
- package/dist/resources/extensions/gsd/auto-recovery.js +32 -1
- package/dist/resources/extensions/gsd/auto-start.js +58 -57
- package/dist/resources/extensions/gsd/auto-verification.js +33 -0
- package/dist/resources/extensions/gsd/auto-worktree.js +51 -53
- package/dist/resources/extensions/gsd/auto.js +70 -28
- package/dist/resources/extensions/gsd/blocked-models.js +68 -0
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +93 -1
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +39 -9
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +93 -0
- package/dist/resources/extensions/gsd/bootstrap/memory-tools.js +3 -0
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +12 -0
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +52 -6
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +84 -23
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +34 -2
- package/dist/resources/extensions/gsd/clean-root-preflight.js +93 -0
- package/dist/resources/extensions/gsd/commands-extract-learnings.js +54 -89
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +968 -23
- package/dist/resources/extensions/gsd/compaction-snapshot.js +121 -0
- package/dist/resources/extensions/gsd/complexity-classifier.js +5 -3
- package/dist/resources/extensions/gsd/db-writer.js +88 -16
- package/dist/resources/extensions/gsd/doctor-git-checks.js +23 -29
- package/dist/resources/extensions/gsd/doctor-providers.js +51 -5
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +1 -0
- package/dist/resources/extensions/gsd/error-classifier.js +31 -3
- package/dist/resources/extensions/gsd/exec-history.js +120 -0
- package/dist/resources/extensions/gsd/exec-sandbox.js +258 -0
- package/dist/resources/extensions/gsd/gitignore.js +1 -0
- package/dist/resources/extensions/gsd/gsd-db.js +168 -23
- package/dist/resources/extensions/gsd/guided-flow.js +190 -1
- package/dist/resources/extensions/gsd/health-widget.js +4 -1
- package/dist/resources/extensions/gsd/hook-emitter.js +108 -0
- package/dist/resources/extensions/gsd/init-wizard.js +15 -1
- package/dist/resources/extensions/gsd/key-manager.js +28 -0
- package/dist/resources/extensions/gsd/memory-backfill.js +126 -0
- package/dist/resources/extensions/gsd/memory-store.js +19 -0
- package/dist/resources/extensions/gsd/model-router.js +36 -3
- package/dist/resources/extensions/gsd/pre-execution-checks.js +44 -9
- package/dist/resources/extensions/gsd/preferences-types.js +9 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +83 -0
- package/dist/resources/extensions/gsd/preferences.js +17 -17
- package/dist/resources/extensions/gsd/prompt-loader.js +22 -7
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +2 -2
- package/dist/resources/extensions/gsd/prompts/debug-diagnose.md +2 -0
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +8 -0
- package/dist/resources/extensions/gsd/prompts/discuss.md +29 -2
- package/dist/resources/extensions/gsd/prompts/execute-task.md +3 -2
- package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +5 -2
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -0
- package/dist/resources/extensions/gsd/prompts/research-slice.md +1 -0
- package/dist/resources/extensions/gsd/safety/evidence-collector.js +96 -0
- package/dist/resources/extensions/gsd/safety/file-change-validator.js +13 -5
- package/dist/resources/extensions/gsd/safety/safety-harness.js +5 -1
- package/dist/resources/extensions/gsd/state.js +43 -4
- package/dist/resources/extensions/gsd/token-counter.js +22 -5
- package/dist/resources/extensions/gsd/tools/complete-milestone.js +16 -10
- package/dist/resources/extensions/gsd/tools/exec-search-tool.js +59 -0
- package/dist/resources/extensions/gsd/tools/exec-tool.js +126 -0
- package/dist/resources/extensions/gsd/tools/memory-tools.js +26 -1
- package/dist/resources/extensions/gsd/tools/resume-tool.js +23 -0
- package/dist/resources/extensions/gsd/uok/plan-v2.js +20 -3
- package/dist/resources/extensions/gsd/workflow-mcp.js +3 -0
- package/dist/resources/extensions/gsd/workflow-templates/spike.md +6 -0
- package/dist/resources/extensions/gsd/worktree-resolver.js +50 -10
- package/dist/resources/extensions/search-the-web/command-search-provider.js +5 -4
- package/dist/resources/extensions/search-the-web/native-search.js +45 -13
- package/dist/resources/skills/api-design/SKILL.md +190 -0
- package/dist/resources/skills/create-mcp-server/SKILL.md +121 -0
- package/dist/resources/skills/decompose-into-slices/SKILL.md +139 -0
- package/dist/resources/skills/dependency-upgrade/SKILL.md +158 -0
- package/dist/resources/skills/design-an-interface/SKILL.md +102 -0
- package/dist/resources/skills/forensics/SKILL.md +153 -0
- package/dist/resources/skills/grill-me/SKILL.md +93 -0
- package/dist/resources/skills/handoff/SKILL.md +121 -0
- package/dist/resources/skills/observability/SKILL.md +174 -0
- package/dist/resources/skills/security-review/SKILL.md +181 -0
- package/dist/resources/skills/spike-wrap-up/SKILL.md +138 -0
- package/dist/resources/skills/tdd/SKILL.md +112 -0
- package/dist/resources/skills/verify-before-complete/SKILL.md +98 -0
- package/dist/resources/skills/write-docs/SKILL.md +82 -0
- package/dist/resources/skills/write-milestone-brief/SKILL.md +135 -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 +10 -10
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/required-server-files.json +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +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 +10 -10
- package/dist/web/standalone/.next/server/chunks/6897.js +2 -2
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +1 -1
- 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/server.js +1 -1
- package/dist/welcome-screen.js +6 -1
- package/dist/wizard.js +2 -0
- package/package.json +1 -1
- package/packages/daemon/package.json +2 -2
- package/packages/mcp-server/dist/remote-questions.d.ts +45 -0
- package/packages/mcp-server/dist/remote-questions.d.ts.map +1 -0
- package/packages/mcp-server/dist/remote-questions.js +732 -0
- package/packages/mcp-server/dist/remote-questions.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts +7 -0
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +70 -8
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/dist/session-manager.d.ts +14 -0
- package/packages/mcp-server/dist/session-manager.d.ts.map +1 -1
- package/packages/mcp-server/dist/session-manager.js +49 -1
- package/packages/mcp-server/dist/session-manager.js.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +163 -25
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/package.json +4 -3
- package/packages/mcp-server/src/mcp-server.test.ts +67 -0
- package/packages/mcp-server/src/remote-questions.test.ts +294 -0
- package/packages/mcp-server/src/remote-questions.ts +916 -0
- package/packages/mcp-server/src/server.ts +89 -14
- package/packages/mcp-server/src/session-manager.ts +43 -1
- package/packages/mcp-server/src/workflow-tools.test.ts +146 -1
- package/packages/mcp-server/src/workflow-tools.ts +215 -43
- package/packages/mcp-server/tsconfig.test.json +19 -0
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/native/package.json +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +12 -0
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/types.d.ts +30 -0
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/types.js.map +1 -1
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-agent-core/src/agent-loop.ts +14 -0
- package/packages/pi-agent-core/src/types.ts +34 -0
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/models/custom.d.ts +38 -0
- package/packages/pi-ai/dist/models/custom.d.ts.map +1 -1
- package/packages/pi-ai/dist/models/custom.js +41 -0
- package/packages/pi-ai/dist/models/custom.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js +1 -1
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js +13 -0
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.js +27 -4
- package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +13 -4
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js +80 -0
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +60 -15
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.d.ts +10 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.js +16 -1
- package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
- package/packages/pi-ai/dist/providers/think-tag-parser.d.ts +17 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.js +75 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.js.map +1 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.js +41 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js +12 -2
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js +164 -14
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +15 -3
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.d.ts +2 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js +67 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +16 -3
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.d.ts +2 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js +67 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/oauth-providers.test.d.ts +2 -0
- package/packages/pi-ai/dist/utils/oauth/oauth-providers.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/oauth-providers.test.js +289 -0
- package/packages/pi-ai/dist/utils/oauth/oauth-providers.test.js.map +1 -0
- package/packages/pi-ai/package.json +1 -1
- package/packages/pi-ai/src/models/custom.ts +42 -0
- package/packages/pi-ai/src/providers/anthropic-auth.test.ts +1 -1
- package/packages/pi-ai/src/providers/anthropic-bearer-auth.test.ts +26 -0
- package/packages/pi-ai/src/providers/anthropic-shared.ts +26 -5
- package/packages/pi-ai/src/providers/anthropic.ts +15 -4
- package/packages/pi-ai/src/providers/minimax-tool-name.test.ts +98 -0
- package/packages/pi-ai/src/providers/openai-completions.ts +57 -16
- package/packages/pi-ai/src/providers/simple-options.ts +17 -1
- package/packages/pi-ai/src/providers/think-tag-parser.test.ts +44 -0
- package/packages/pi-ai/src/providers/think-tag-parser.ts +94 -0
- package/packages/pi-ai/src/utils/oauth/github-copilot.test.ts +200 -23
- package/packages/pi-ai/src/utils/oauth/github-copilot.ts +12 -2
- package/packages/pi-ai/src/utils/oauth/google-antigravity.test.ts +84 -0
- package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +15 -5
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.test.ts +84 -0
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +16 -5
- package/packages/pi-ai/src/utils/oauth/oauth-providers.test.ts +363 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js +3 -2
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +2 -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 +32 -2
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +4 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +35 -2
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +233 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +205 -2
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/hooks-runner.d.ts +53 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.js +337 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js +234 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/index.js +1 -0
- package/packages/pi-coding-agent/dist/core/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.d.ts +3 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.js +92 -12
- package/packages/pi-coding-agent/dist/core/model-discovery.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.test.js +16 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry-auth-header.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry-auth-header.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-auth-header.test.js +40 -0
- package/packages/pi-coding-agent/dist/core/model-registry-auth-header.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.js +203 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-discovery.test.js +61 -1
- package/packages/pi-coding-agent/dist/core/model-registry-discovery.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +5 -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 +90 -10
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/redact-secrets.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.js +49 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.js +67 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +10 -6
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.js +45 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +55 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +5 -4
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.js +13 -7
- package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +7 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +29 -21
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +13 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +3 -2
- package/packages/pi-coding-agent/src/core/agent-session.ts +38 -2
- package/packages/pi-coding-agent/src/core/extensions/index.ts +16 -0
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +5 -0
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +351 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +258 -0
- package/packages/pi-coding-agent/src/core/hooks-runner.test.ts +269 -0
- package/packages/pi-coding-agent/src/core/hooks-runner.ts +460 -0
- package/packages/pi-coding-agent/src/core/index.ts +10 -0
- package/packages/pi-coding-agent/src/core/model-discovery.test.ts +19 -0
- package/packages/pi-coding-agent/src/core/model-discovery.ts +99 -12
- package/packages/pi-coding-agent/src/core/model-registry-auth-header.test.ts +44 -0
- package/packages/pi-coding-agent/src/core/model-registry-custom-caps.test.ts +245 -0
- package/packages/pi-coding-agent/src/core/model-registry-discovery.test.ts +75 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +102 -10
- package/packages/pi-coding-agent/src/core/redact-secrets.test.ts +86 -0
- package/packages/pi-coding-agent/src/core/redact-secrets.ts +58 -0
- package/packages/pi-coding-agent/src/core/session-manager.test.ts +65 -1
- package/packages/pi-coding-agent/src/core/session-manager.ts +10 -6
- package/packages/pi-coding-agent/src/core/settings-manager.ts +57 -0
- package/packages/pi-coding-agent/src/index.ts +16 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +6 -6
- package/packages/pi-coding-agent/src/modes/interactive/components/provider-manager.ts +16 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts +36 -22
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +13 -1
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/package.json +1 -1
- package/packages/rpc-client/package.json +1 -1
- package/pkg/package.json +1 -1
- package/scripts/link-workspace-packages.cjs +1 -0
- package/src/resources/agents/researcher.md +1 -1
- package/src/resources/extensions/claude-code-cli/readiness.ts +32 -8
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +78 -17
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +149 -5
- package/src/resources/extensions/gsd/auto/loop-deps.ts +14 -0
- package/src/resources/extensions/gsd/auto/loop.ts +9 -0
- package/src/resources/extensions/gsd/auto/phases.ts +131 -10
- package/src/resources/extensions/gsd/auto/run-unit.ts +40 -2
- package/src/resources/extensions/gsd/auto/session.ts +35 -2
- package/src/resources/extensions/gsd/auto-dispatch.ts +16 -3
- package/src/resources/extensions/gsd/auto-model-selection.ts +71 -15
- package/src/resources/extensions/gsd/auto-post-unit.ts +29 -3
- package/src/resources/extensions/gsd/auto-prompts.ts +28 -1
- package/src/resources/extensions/gsd/auto-recovery.ts +26 -1
- package/src/resources/extensions/gsd/auto-start.ts +60 -68
- package/src/resources/extensions/gsd/auto-verification.ts +33 -0
- package/src/resources/extensions/gsd/auto-worktree.ts +62 -63
- package/src/resources/extensions/gsd/auto.ts +73 -28
- package/src/resources/extensions/gsd/blocked-models.ts +98 -0
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +120 -1
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +40 -9
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +109 -0
- package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +5 -0
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +15 -0
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +54 -6
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +89 -26
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +35 -2
- package/src/resources/extensions/gsd/clean-root-preflight.ts +111 -0
- package/src/resources/extensions/gsd/commands-extract-learnings.ts +55 -90
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +898 -32
- package/src/resources/extensions/gsd/compaction-snapshot.ts +165 -0
- package/src/resources/extensions/gsd/complexity-classifier.ts +5 -3
- package/src/resources/extensions/gsd/db-writer.ts +88 -17
- package/src/resources/extensions/gsd/doctor-git-checks.ts +23 -27
- package/src/resources/extensions/gsd/doctor-providers.ts +59 -6
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +2 -0
- package/src/resources/extensions/gsd/error-classifier.ts +36 -3
- package/src/resources/extensions/gsd/exec-history.ts +153 -0
- package/src/resources/extensions/gsd/exec-sandbox.ts +326 -0
- package/src/resources/extensions/gsd/gitignore.ts +1 -1
- package/src/resources/extensions/gsd/gsd-db.ts +186 -23
- package/src/resources/extensions/gsd/guided-flow.ts +222 -1
- package/src/resources/extensions/gsd/health-widget.ts +3 -1
- package/src/resources/extensions/gsd/hook-emitter.ts +188 -0
- package/src/resources/extensions/gsd/init-wizard.ts +15 -1
- package/src/resources/extensions/gsd/journal.ts +2 -1
- package/src/resources/extensions/gsd/key-manager.ts +28 -0
- package/src/resources/extensions/gsd/memory-backfill.ts +140 -0
- package/src/resources/extensions/gsd/memory-store.ts +26 -0
- package/src/resources/extensions/gsd/model-router.ts +42 -1
- package/src/resources/extensions/gsd/pre-execution-checks.ts +46 -10
- package/src/resources/extensions/gsd/preferences-types.ts +46 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +79 -0
- package/src/resources/extensions/gsd/preferences.ts +17 -17
- package/src/resources/extensions/gsd/prompt-loader.ts +30 -7
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/complete-slice.md +2 -2
- package/src/resources/extensions/gsd/prompts/debug-diagnose.md +2 -0
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +8 -0
- package/src/resources/extensions/gsd/prompts/discuss.md +29 -2
- package/src/resources/extensions/gsd/prompts/execute-task.md +3 -2
- package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +5 -2
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -0
- package/src/resources/extensions/gsd/prompts/research-slice.md +1 -0
- package/src/resources/extensions/gsd/safety/evidence-collector.ts +119 -0
- package/src/resources/extensions/gsd/safety/file-change-validator.ts +17 -4
- package/src/resources/extensions/gsd/safety/safety-harness.ts +9 -0
- package/src/resources/extensions/gsd/state.ts +45 -4
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +188 -2
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +95 -1
- package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +12 -0
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +49 -0
- package/src/resources/extensions/gsd/tests/auto-start-bootstrap-await-3420.test.ts +141 -0
- package/src/resources/extensions/gsd/tests/auto-start-model-capture.test.ts +33 -3
- package/src/resources/extensions/gsd/tests/auto-thinking-restore.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/blocked-models.test.ts +98 -0
- package/src/resources/extensions/gsd/tests/bundled-skill-triggers.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +186 -0
- package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +68 -66
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +123 -0
- package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +61 -1
- 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/complexity-classifier.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/derive-state-helpers.test.ts +8 -4
- package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +148 -3
- package/src/resources/extensions/gsd/tests/double-merge-guard.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/ensure-db-open.test.ts +306 -1
- package/src/resources/extensions/gsd/tests/escalation.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/exec-history.test.ts +237 -0
- package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +210 -0
- package/src/resources/extensions/gsd/tests/file-change-validator.test.ts +58 -0
- package/src/resources/extensions/gsd/tests/flat-rate-routing-guard.test.ts +40 -9
- package/src/resources/extensions/gsd/tests/freeform-decisions.test.ts +62 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +447 -1
- package/src/resources/extensions/gsd/tests/init-wizard.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/integration/doctor-git-symlink-cwd.test.ts +11 -0
- package/src/resources/extensions/gsd/tests/integration/doctor-git.test.ts +78 -0
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/integration/gitignore-tracked-gsd.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/integration/idle-recovery.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/interactive-routing-bypass.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/issue-4540-regressions.test.ts +288 -0
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +37 -0
- package/src/resources/extensions/gsd/tests/key-manager.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/load-memory-block.test.ts +36 -0
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/memory-pressure-stuck-state.test.ts +12 -0
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/parallel-research-dispatch.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/plan-gate-failed-doctor-heal-hint.test.ts +37 -0
- package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/pre-exec-gate-loop.test.ts +272 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +356 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +110 -0
- package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/prompt-loader-extension-dir.test.ts +49 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +103 -4
- package/src/resources/extensions/gsd/tests/ready-phrase-no-files-4573.test.ts +388 -0
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +9 -3
- package/src/resources/extensions/gsd/tests/resume-dispatch-worktree.test.ts +230 -0
- package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +205 -0
- package/src/resources/extensions/gsd/tests/save-gate-result-render.test.ts +95 -0
- package/src/resources/extensions/gsd/tests/schema-v21-sequence.test.ts +413 -0
- package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +32 -40
- package/src/resources/extensions/gsd/tests/stash-queued-context-files.test.ts +56 -0
- package/src/resources/extensions/gsd/tests/token-counter.test.ts +105 -1
- package/src/resources/extensions/gsd/tests/tool-compatibility.test.ts +107 -0
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +9 -3
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +65 -2
- package/src/resources/extensions/gsd/tests/worktree-db.test.ts +35 -0
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +6 -1
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +78 -5
- package/src/resources/extensions/gsd/tests/write-gate.test.ts +64 -0
- package/src/resources/extensions/gsd/tests/zombie-gsd-state.test.ts +3 -1
- package/src/resources/extensions/gsd/token-counter.ts +22 -5
- package/src/resources/extensions/gsd/tools/complete-milestone.ts +15 -9
- package/src/resources/extensions/gsd/tools/exec-search-tool.ts +81 -0
- package/src/resources/extensions/gsd/tools/exec-tool.ts +183 -0
- package/src/resources/extensions/gsd/tools/memory-tools.ts +31 -1
- package/src/resources/extensions/gsd/tools/resume-tool.ts +40 -0
- package/src/resources/extensions/gsd/uok/plan-v2.ts +26 -3
- package/src/resources/extensions/gsd/workflow-logger.ts +4 -1
- package/src/resources/extensions/gsd/workflow-mcp.ts +3 -0
- package/src/resources/extensions/gsd/workflow-templates/spike.md +6 -0
- package/src/resources/extensions/gsd/worktree-resolver.ts +54 -9
- package/src/resources/extensions/search-the-web/command-search-provider.ts +5 -4
- package/src/resources/extensions/search-the-web/native-search.ts +48 -12
- package/src/resources/skills/api-design/SKILL.md +190 -0
- package/src/resources/skills/create-mcp-server/SKILL.md +121 -0
- package/src/resources/skills/decompose-into-slices/SKILL.md +139 -0
- package/src/resources/skills/dependency-upgrade/SKILL.md +158 -0
- package/src/resources/skills/design-an-interface/SKILL.md +102 -0
- package/src/resources/skills/forensics/SKILL.md +153 -0
- package/src/resources/skills/grill-me/SKILL.md +93 -0
- package/src/resources/skills/handoff/SKILL.md +121 -0
- package/src/resources/skills/observability/SKILL.md +174 -0
- package/src/resources/skills/security-review/SKILL.md +181 -0
- package/src/resources/skills/spike-wrap-up/SKILL.md +138 -0
- package/src/resources/skills/tdd/SKILL.md +112 -0
- package/src/resources/skills/verify-before-complete/SKILL.md +98 -0
- package/src/resources/skills/write-docs/SKILL.md +82 -0
- package/src/resources/skills/write-milestone-brief/SKILL.md +135 -0
- /package/dist/web/standalone/.next/static/{ssX7BLv3Dw9Fb4CtrCGeR → pV-mPo7rYGb5JBC09C8GG}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{ssX7BLv3Dw9Fb4CtrCGeR → pV-mPo7rYGb5JBC09C8GG}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
|
|
7
|
+
import { listExecHistory, searchExecHistory } from '../exec-history.ts';
|
|
8
|
+
import { executeExecSearch } from '../tools/exec-search-tool.ts';
|
|
9
|
+
|
|
10
|
+
function freshBase(): string {
|
|
11
|
+
return mkdtempSync(join(tmpdir(), 'gsd-exec-history-'));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function cleanup(dir: string): void {
|
|
15
|
+
rmSync(dir, { recursive: true, force: true });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function writeRun(base: string, id: string, overrides: Record<string, unknown> = {}): void {
|
|
19
|
+
const dir = join(base, '.gsd', 'exec');
|
|
20
|
+
mkdirSync(dir, { recursive: true });
|
|
21
|
+
const stdoutPath = join(dir, `${id}.stdout`);
|
|
22
|
+
const stderrPath = join(dir, `${id}.stderr`);
|
|
23
|
+
const metaPath = join(dir, `${id}.meta.json`);
|
|
24
|
+
writeFileSync(stdoutPath, (overrides.stdout as string | undefined) ?? `stdout for ${id}\n`);
|
|
25
|
+
writeFileSync(stderrPath, '');
|
|
26
|
+
writeFileSync(
|
|
27
|
+
metaPath,
|
|
28
|
+
JSON.stringify({
|
|
29
|
+
id,
|
|
30
|
+
runtime: 'bash',
|
|
31
|
+
purpose: `purpose for ${id}`,
|
|
32
|
+
started_at: '2026-04-20T12:00:00.000Z',
|
|
33
|
+
finished_at: '2026-04-20T12:00:00.100Z',
|
|
34
|
+
duration_ms: 100,
|
|
35
|
+
exit_code: 0,
|
|
36
|
+
signal: null,
|
|
37
|
+
timed_out: false,
|
|
38
|
+
stdout_bytes: 12,
|
|
39
|
+
stderr_bytes: 0,
|
|
40
|
+
stdout_truncated: false,
|
|
41
|
+
stderr_truncated: false,
|
|
42
|
+
stdout_path: stdoutPath,
|
|
43
|
+
stderr_path: stderrPath,
|
|
44
|
+
...overrides,
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
test('listExecHistory: returns empty list when .gsd/exec missing', () => {
|
|
50
|
+
const base = freshBase();
|
|
51
|
+
try {
|
|
52
|
+
assert.deepEqual(listExecHistory(base), []);
|
|
53
|
+
} finally {
|
|
54
|
+
cleanup(base);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('listExecHistory: skips malformed meta files', () => {
|
|
59
|
+
const base = freshBase();
|
|
60
|
+
try {
|
|
61
|
+
const dir = join(base, '.gsd', 'exec');
|
|
62
|
+
mkdirSync(dir, { recursive: true });
|
|
63
|
+
writeFileSync(join(dir, 'bad.meta.json'), '{not-json');
|
|
64
|
+
writeRun(base, 'ok-1');
|
|
65
|
+
const list = listExecHistory(base);
|
|
66
|
+
assert.equal(list.length, 1);
|
|
67
|
+
assert.equal(list[0]!.id, 'ok-1');
|
|
68
|
+
} finally {
|
|
69
|
+
cleanup(base);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('searchExecHistory: filters by query, runtime, and failing_only', () => {
|
|
74
|
+
const base = freshBase();
|
|
75
|
+
try {
|
|
76
|
+
writeRun(base, 'playwright-run', { purpose: 'playwright snapshot' });
|
|
77
|
+
writeRun(base, 'grep-run', { purpose: 'grep TODOs' });
|
|
78
|
+
writeRun(base, 'failing-run', { exit_code: 1, purpose: 'boom' });
|
|
79
|
+
writeRun(base, 'node-run', { runtime: 'node', purpose: 'dedupe' });
|
|
80
|
+
|
|
81
|
+
const playwrightHits = searchExecHistory(base, { query: 'playwright' });
|
|
82
|
+
assert.equal(playwrightHits.length, 1);
|
|
83
|
+
assert.equal(playwrightHits[0]!.entry.id, 'playwright-run');
|
|
84
|
+
|
|
85
|
+
const failingHits = searchExecHistory(base, { failing_only: true });
|
|
86
|
+
assert.equal(failingHits.length, 1);
|
|
87
|
+
assert.equal(failingHits[0]!.entry.id, 'failing-run');
|
|
88
|
+
|
|
89
|
+
const nodeHits = searchExecHistory(base, { runtime: 'node' });
|
|
90
|
+
assert.equal(nodeHits.length, 1);
|
|
91
|
+
assert.equal(nodeHits[0]!.entry.runtime, 'node');
|
|
92
|
+
|
|
93
|
+
const unlimited = searchExecHistory(base, {});
|
|
94
|
+
assert.equal(unlimited.length, 4);
|
|
95
|
+
} finally {
|
|
96
|
+
cleanup(base);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('executeExecSearch: returns helpful empty-state message when no matches', () => {
|
|
101
|
+
const base = freshBase();
|
|
102
|
+
try {
|
|
103
|
+
const result = executeExecSearch({ query: 'missing' }, { baseDir: base });
|
|
104
|
+
assert.ok(!result.isError);
|
|
105
|
+
assert.match(result.content[0].text, /No prior gsd_exec runs/);
|
|
106
|
+
} finally {
|
|
107
|
+
cleanup(base);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('executeExecSearch: includes stdout_path and preview in details', () => {
|
|
112
|
+
const base = freshBase();
|
|
113
|
+
try {
|
|
114
|
+
writeRun(base, 'summary-run', { stdout: 'found 42 TODOs\n' });
|
|
115
|
+
const result = executeExecSearch({ query: 'summary' }, { baseDir: base });
|
|
116
|
+
const details = result.details as { results: Array<{ id: string; stdout_path: string }> };
|
|
117
|
+
assert.equal(details.results.length, 1);
|
|
118
|
+
assert.equal(details.results[0]!.id, 'summary-run');
|
|
119
|
+
assert.match(details.results[0]!.stdout_path, /summary-run\.stdout$/);
|
|
120
|
+
assert.match(result.content[0].text, /found 42 TODOs/);
|
|
121
|
+
} finally {
|
|
122
|
+
cleanup(base);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// ── Path traversal security tests (issue #4590) ───────────────────────────
|
|
127
|
+
|
|
128
|
+
test('safeReadMeta: ignores malicious stdout_path in JSON, derives path from meta file location', () => {
|
|
129
|
+
// Arrange: write a .meta.json whose JSON content has a path-traversal value
|
|
130
|
+
// in stdout_path / stderr_path. The read-side must silently discard these
|
|
131
|
+
// and derive sibling paths from the actual .meta.json location instead.
|
|
132
|
+
const base = freshBase();
|
|
133
|
+
try {
|
|
134
|
+
const dir = join(base, '.gsd', 'exec');
|
|
135
|
+
mkdirSync(dir, { recursive: true });
|
|
136
|
+
const id = 'traversal-test-run';
|
|
137
|
+
const metaPath = join(dir, `${id}.meta.json`);
|
|
138
|
+
const stdoutPath = join(dir, `${id}.stdout`);
|
|
139
|
+
const stderrPath = join(dir, `${id}.stderr`);
|
|
140
|
+
// Write real sibling files so digest_preview can succeed.
|
|
141
|
+
writeFileSync(stdoutPath, 'legitimate stdout content\n');
|
|
142
|
+
writeFileSync(stderrPath, '');
|
|
143
|
+
// Write a meta.json that tries to point stdout_path outside the exec dir.
|
|
144
|
+
writeFileSync(
|
|
145
|
+
metaPath,
|
|
146
|
+
JSON.stringify({
|
|
147
|
+
id,
|
|
148
|
+
runtime: 'bash',
|
|
149
|
+
purpose: 'test run',
|
|
150
|
+
started_at: '2026-04-20T12:00:00.000Z',
|
|
151
|
+
finished_at: '2026-04-20T12:00:00.100Z',
|
|
152
|
+
duration_ms: 100,
|
|
153
|
+
exit_code: 0,
|
|
154
|
+
signal: null,
|
|
155
|
+
timed_out: false,
|
|
156
|
+
stdout_bytes: 24,
|
|
157
|
+
stderr_bytes: 0,
|
|
158
|
+
stdout_truncated: false,
|
|
159
|
+
stderr_truncated: false,
|
|
160
|
+
// These malicious values must NEVER be used as filesystem paths.
|
|
161
|
+
stdout_path: '../../etc/passwd',
|
|
162
|
+
stderr_path: '../../etc/shadow',
|
|
163
|
+
}),
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const entries = listExecHistory(base);
|
|
167
|
+
assert.equal(entries.length, 1);
|
|
168
|
+
const entry = entries[0]!;
|
|
169
|
+
|
|
170
|
+
// stdout_path must be derived from the meta file location, not from JSON.
|
|
171
|
+
assert.equal(entry.stdout_path, stdoutPath,
|
|
172
|
+
`stdout_path must be a sibling of the meta file; got: ${entry.stdout_path}`);
|
|
173
|
+
assert.equal(entry.stderr_path, stderrPath,
|
|
174
|
+
`stderr_path must be a sibling of the meta file; got: ${entry.stderr_path}`);
|
|
175
|
+
|
|
176
|
+
// Verify neither traversal string leaked into the returned entry.
|
|
177
|
+
assert.ok(!entry.stdout_path.includes('..'),
|
|
178
|
+
`stdout_path must not contain path traversal sequences: ${entry.stdout_path}`);
|
|
179
|
+
assert.ok(!entry.stderr_path.includes('..'),
|
|
180
|
+
`stderr_path must not contain path traversal sequences: ${entry.stderr_path}`);
|
|
181
|
+
assert.ok(!entry.stdout_path.includes('etc/passwd'),
|
|
182
|
+
`stdout_path must not point to /etc/passwd: ${entry.stdout_path}`);
|
|
183
|
+
} finally {
|
|
184
|
+
cleanup(base);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('searchExecHistory: digest_preview is read from derived sibling path, not JSON stdout_path', () => {
|
|
189
|
+
// Arrange: a .meta.json with a malicious stdout_path pointing to /etc/passwd.
|
|
190
|
+
// The digest_preview should be read from the real sibling .stdout file,
|
|
191
|
+
// not from the JSON-supplied path.
|
|
192
|
+
const base = freshBase();
|
|
193
|
+
try {
|
|
194
|
+
const dir = join(base, '.gsd', 'exec');
|
|
195
|
+
mkdirSync(dir, { recursive: true });
|
|
196
|
+
const id = 'preview-traversal-run';
|
|
197
|
+
const metaPath = join(dir, `${id}.meta.json`);
|
|
198
|
+
const stdoutPath = join(dir, `${id}.stdout`);
|
|
199
|
+
writeFileSync(stdoutPath, 'safe-sentinel-content\n');
|
|
200
|
+
writeFileSync(join(dir, `${id}.stderr`), '');
|
|
201
|
+
writeFileSync(
|
|
202
|
+
metaPath,
|
|
203
|
+
JSON.stringify({
|
|
204
|
+
id,
|
|
205
|
+
runtime: 'bash',
|
|
206
|
+
purpose: null,
|
|
207
|
+
started_at: '2026-04-20T12:00:00.000Z',
|
|
208
|
+
finished_at: '2026-04-20T12:00:00.100Z',
|
|
209
|
+
duration_ms: 50,
|
|
210
|
+
exit_code: 0,
|
|
211
|
+
signal: null,
|
|
212
|
+
timed_out: false,
|
|
213
|
+
stdout_bytes: 21,
|
|
214
|
+
stderr_bytes: 0,
|
|
215
|
+
stdout_truncated: false,
|
|
216
|
+
stderr_truncated: false,
|
|
217
|
+
// Attacker-controlled path — must be ignored.
|
|
218
|
+
stdout_path: '/etc/passwd',
|
|
219
|
+
stderr_path: '/etc/shadow',
|
|
220
|
+
}),
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const hits = searchExecHistory(base, {});
|
|
224
|
+
assert.equal(hits.length, 1);
|
|
225
|
+
const hit = hits[0]!;
|
|
226
|
+
|
|
227
|
+
// The preview must come from the safe sibling, not /etc/passwd.
|
|
228
|
+
assert.ok(
|
|
229
|
+
hit.digest_preview?.includes('safe-sentinel-content'),
|
|
230
|
+
`digest_preview should contain safe-sentinel-content; got: ${hit.digest_preview}`,
|
|
231
|
+
);
|
|
232
|
+
// Ensure the entry paths are the derived ones.
|
|
233
|
+
assert.equal(hit.entry.stdout_path, stdoutPath);
|
|
234
|
+
} finally {
|
|
235
|
+
cleanup(base);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
|
|
7
|
+
import { EXEC_DEFAULTS, runExecSandbox, type ExecSandboxOptions } from '../exec-sandbox.ts';
|
|
8
|
+
import { buildExecOptions, executeGsdExec } from '../tools/exec-tool.ts';
|
|
9
|
+
import { isContextModeEnabled } from '../preferences-types.ts';
|
|
10
|
+
|
|
11
|
+
function freshBase(): string {
|
|
12
|
+
return mkdtempSync(join(tmpdir(), 'gsd-exec-test-'));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function cleanup(dir: string): void {
|
|
16
|
+
rmSync(dir, { recursive: true, force: true });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function baseOpts(base: string, overrides: Partial<ExecSandboxOptions> = {}): ExecSandboxOptions {
|
|
20
|
+
return {
|
|
21
|
+
baseDir: base,
|
|
22
|
+
clamp_timeout_ms: EXEC_DEFAULTS.clampTimeoutMs,
|
|
23
|
+
default_timeout_ms: 10_000,
|
|
24
|
+
stdout_cap_bytes: 1_024,
|
|
25
|
+
stderr_cap_bytes: 1_024,
|
|
26
|
+
digest_chars: 120,
|
|
27
|
+
env_allowlist: EXEC_DEFAULTS.envAllowlist,
|
|
28
|
+
...overrides,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
test('runExecSandbox: captures stdout, persists artifacts, returns digest', async () => {
|
|
33
|
+
const base = freshBase();
|
|
34
|
+
try {
|
|
35
|
+
const result = await runExecSandbox(
|
|
36
|
+
{ runtime: 'bash', script: 'echo hello world' },
|
|
37
|
+
baseOpts(base),
|
|
38
|
+
);
|
|
39
|
+
assert.equal(result.exit_code, 0);
|
|
40
|
+
assert.equal(result.timed_out, false);
|
|
41
|
+
assert.ok(result.digest.includes('hello world'), `digest should contain stdout: ${result.digest}`);
|
|
42
|
+
assert.ok(result.stdout_path.startsWith(join(base, '.gsd', 'exec')), 'stdout path under .gsd/exec');
|
|
43
|
+
assert.equal(readFileSync(result.stdout_path, 'utf-8').trim(), 'hello world');
|
|
44
|
+
const meta = JSON.parse(readFileSync(result.meta_path, 'utf-8')) as Record<string, unknown>;
|
|
45
|
+
assert.equal(meta.runtime, 'bash');
|
|
46
|
+
assert.equal(meta.exit_code, 0);
|
|
47
|
+
} finally {
|
|
48
|
+
cleanup(base);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('runExecSandbox: enforces stdout cap and marks truncation', async () => {
|
|
53
|
+
const base = freshBase();
|
|
54
|
+
try {
|
|
55
|
+
const result = await runExecSandbox(
|
|
56
|
+
// Emit far more than the cap so truncation triggers.
|
|
57
|
+
{ runtime: 'bash', script: 'head -c 8000 /dev/urandom | base64' },
|
|
58
|
+
baseOpts(base, { stdout_cap_bytes: 256 }),
|
|
59
|
+
);
|
|
60
|
+
assert.equal(result.stdout_truncated, true, 'should mark stdout truncated');
|
|
61
|
+
assert.ok(result.stdout_bytes <= 256, `stdout_bytes within cap (got ${result.stdout_bytes})`);
|
|
62
|
+
const stdout = readFileSync(result.stdout_path, 'utf-8');
|
|
63
|
+
assert.ok(stdout.endsWith('[truncated: stdout cap reached]\n'), 'truncation marker appended');
|
|
64
|
+
} finally {
|
|
65
|
+
cleanup(base);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('runExecSandbox: enforces timeout and surfaces timed_out', async () => {
|
|
70
|
+
const base = freshBase();
|
|
71
|
+
try {
|
|
72
|
+
const started = Date.now();
|
|
73
|
+
const result = await runExecSandbox(
|
|
74
|
+
{ runtime: 'bash', script: 'sleep 10' },
|
|
75
|
+
baseOpts(base, { default_timeout_ms: 150, clamp_timeout_ms: 150 }),
|
|
76
|
+
);
|
|
77
|
+
const elapsed = Date.now() - started;
|
|
78
|
+
assert.equal(result.timed_out, true);
|
|
79
|
+
assert.ok(elapsed < 5_000, `should return well before 10s (took ${elapsed}ms)`);
|
|
80
|
+
} finally {
|
|
81
|
+
cleanup(base);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('runExecSandbox: forwards only allowlisted env vars', async () => {
|
|
86
|
+
const base = freshBase();
|
|
87
|
+
try {
|
|
88
|
+
const result = await runExecSandbox(
|
|
89
|
+
{ runtime: 'bash', script: 'echo PATH=$PATH SECRET=$GSD_TEST_SECRET' },
|
|
90
|
+
baseOpts(base, {
|
|
91
|
+
env_allowlist: [],
|
|
92
|
+
env: { PATH: '/usr/bin:/bin', HOME: '/tmp', GSD_TEST_SECRET: 'should-be-blocked' },
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
95
|
+
const stdout = readFileSync(result.stdout_path, 'utf-8');
|
|
96
|
+
assert.ok(stdout.includes('PATH=/usr/bin:/bin'), 'PATH forwarded');
|
|
97
|
+
assert.ok(!stdout.includes('should-be-blocked'), 'non-allowlisted var blocked');
|
|
98
|
+
} finally {
|
|
99
|
+
cleanup(base);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('runExecSandbox: node runtime executes JS', async () => {
|
|
104
|
+
const base = freshBase();
|
|
105
|
+
try {
|
|
106
|
+
const result = await runExecSandbox(
|
|
107
|
+
{ runtime: 'node', script: 'console.log("node-ok:" + (1+2))' },
|
|
108
|
+
baseOpts(base),
|
|
109
|
+
);
|
|
110
|
+
assert.equal(result.exit_code, 0);
|
|
111
|
+
assert.ok(result.digest.includes('node-ok:3'));
|
|
112
|
+
} finally {
|
|
113
|
+
cleanup(base);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// ── exec-tool executor ────────────────────────────────────────────────────
|
|
118
|
+
|
|
119
|
+
test('executeGsdExec: runs by default when context_mode is unset', async () => {
|
|
120
|
+
const base = freshBase();
|
|
121
|
+
try {
|
|
122
|
+
const result = await executeGsdExec(
|
|
123
|
+
{ runtime: 'bash', script: 'echo default-on-run' },
|
|
124
|
+
{ baseDir: base, preferences: {} },
|
|
125
|
+
);
|
|
126
|
+
assert.ok(!result.isError, 'should succeed with no preferences');
|
|
127
|
+
assert.equal(result.details.operation, 'gsd_exec');
|
|
128
|
+
assert.equal(result.details.exit_code, 0);
|
|
129
|
+
assert.ok(result.content[0].text.includes('default-on-run'));
|
|
130
|
+
} finally {
|
|
131
|
+
cleanup(base);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('executeGsdExec: runs when preferences is null (fresh project)', async () => {
|
|
136
|
+
const base = freshBase();
|
|
137
|
+
try {
|
|
138
|
+
const result = await executeGsdExec(
|
|
139
|
+
{ runtime: 'bash', script: 'echo null-prefs-run' },
|
|
140
|
+
{ baseDir: base, preferences: null },
|
|
141
|
+
);
|
|
142
|
+
assert.ok(!result.isError, 'null preferences should not disable');
|
|
143
|
+
assert.ok(result.content[0].text.includes('null-prefs-run'));
|
|
144
|
+
} finally {
|
|
145
|
+
cleanup(base);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('executeGsdExec: blocked only when context_mode.enabled=false', async () => {
|
|
150
|
+
const base = freshBase();
|
|
151
|
+
try {
|
|
152
|
+
const result = await executeGsdExec(
|
|
153
|
+
{ runtime: 'bash', script: 'echo should-not-run' },
|
|
154
|
+
{ baseDir: base, preferences: { context_mode: { enabled: false } } },
|
|
155
|
+
);
|
|
156
|
+
assert.equal(result.isError, true);
|
|
157
|
+
assert.equal((result.details as { error?: string }).error, 'context_mode_disabled');
|
|
158
|
+
} finally {
|
|
159
|
+
cleanup(base);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('executeGsdExec: runs when enabled explicitly set to true', async () => {
|
|
164
|
+
const base = freshBase();
|
|
165
|
+
try {
|
|
166
|
+
const result = await executeGsdExec(
|
|
167
|
+
{ runtime: 'bash', script: 'echo explicit-on' },
|
|
168
|
+
{ baseDir: base, preferences: { context_mode: { enabled: true } } },
|
|
169
|
+
);
|
|
170
|
+
assert.ok(!result.isError);
|
|
171
|
+
assert.ok(result.content[0].text.includes('explicit-on'));
|
|
172
|
+
} finally {
|
|
173
|
+
cleanup(base);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('executeGsdExec: rejects empty script', async () => {
|
|
178
|
+
const base = freshBase();
|
|
179
|
+
try {
|
|
180
|
+
const result = await executeGsdExec(
|
|
181
|
+
{ runtime: 'bash', script: ' ' },
|
|
182
|
+
{ baseDir: base, preferences: { context_mode: { enabled: true } } },
|
|
183
|
+
);
|
|
184
|
+
assert.equal(result.isError, true);
|
|
185
|
+
assert.equal((result.details as { error?: string }).error, 'invalid_params');
|
|
186
|
+
} finally {
|
|
187
|
+
cleanup(base);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('isContextModeEnabled: defaults to true; only explicit false disables', () => {
|
|
192
|
+
assert.equal(isContextModeEnabled(undefined), true, 'undefined prefs → on');
|
|
193
|
+
assert.equal(isContextModeEnabled(null), true, 'null prefs → on');
|
|
194
|
+
assert.equal(isContextModeEnabled({}), true, 'empty prefs → on');
|
|
195
|
+
assert.equal(isContextModeEnabled({ context_mode: {} }), true, 'empty block → on');
|
|
196
|
+
assert.equal(isContextModeEnabled({ context_mode: { enabled: true } }), true);
|
|
197
|
+
assert.equal(isContextModeEnabled({ context_mode: { enabled: false } }), false);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('buildExecOptions: clamps out-of-range values to safe defaults', () => {
|
|
201
|
+
const opts = buildExecOptions('/tmp/base', {
|
|
202
|
+
enabled: true,
|
|
203
|
+
exec_timeout_ms: 999_999_999,
|
|
204
|
+
exec_stdout_cap_bytes: 1,
|
|
205
|
+
exec_digest_chars: -20,
|
|
206
|
+
});
|
|
207
|
+
assert.equal(opts.default_timeout_ms, EXEC_DEFAULTS.clampTimeoutMs, 'timeout clamped to upper bound');
|
|
208
|
+
assert.equal(opts.stdout_cap_bytes, 4_096, 'stdout cap clamped to floor');
|
|
209
|
+
assert.equal(opts.digest_chars, 0, 'digest chars clamped to floor');
|
|
210
|
+
});
|
|
@@ -15,6 +15,64 @@ function git(cwd: string, ...args: string[]): string {
|
|
|
15
15
|
}).trim();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
test("validateFileChanges works on repos with a single commit (no HEAD~1)", (t) => {
|
|
19
|
+
const base = mkdtempSync(join(tmpdir(), "gsd-file-change-validator-"));
|
|
20
|
+
t.after(() => rmSync(base, { recursive: true, force: true }));
|
|
21
|
+
|
|
22
|
+
git(base, "init");
|
|
23
|
+
git(base, "config", "user.email", "test@example.com");
|
|
24
|
+
git(base, "config", "user.name", "Test User");
|
|
25
|
+
|
|
26
|
+
writeFileSync(join(base, "foo.ts"), "export const x = 1;\n");
|
|
27
|
+
git(base, "add", ".");
|
|
28
|
+
git(base, "commit", "-m", "initial");
|
|
29
|
+
|
|
30
|
+
// With only one commit, HEAD~1 doesn't exist — this must not throw
|
|
31
|
+
const audit = validateFileChanges(base, ["foo.ts"], []);
|
|
32
|
+
|
|
33
|
+
assert.ok(audit, "audit should be produced for single-commit repo");
|
|
34
|
+
assert.deepEqual(audit.unexpectedFiles, []);
|
|
35
|
+
assert.deepEqual(audit.missingFiles, []);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("validateFileChanges excludes allowlisted files from unexpected-change warnings", (t) => {
|
|
39
|
+
const base = mkdtempSync(join(tmpdir(), "gsd-file-change-validator-"));
|
|
40
|
+
t.after(() => rmSync(base, { recursive: true, force: true }));
|
|
41
|
+
|
|
42
|
+
mkdirSync(join(base, "tracking", "history"), { recursive: true });
|
|
43
|
+
git(base, "init");
|
|
44
|
+
git(base, "config", "user.email", "test@example.com");
|
|
45
|
+
git(base, "config", "user.name", "Test User");
|
|
46
|
+
|
|
47
|
+
writeFileSync(join(base, "src.ts"), "initial\n");
|
|
48
|
+
writeFileSync(join(base, "tracking", "history", "2026-04-20-snapshot.md"), "initial\n");
|
|
49
|
+
git(base, "add", ".");
|
|
50
|
+
git(base, "commit", "-m", "initial");
|
|
51
|
+
|
|
52
|
+
writeFileSync(join(base, "src.ts"), "updated\n");
|
|
53
|
+
writeFileSync(join(base, "tracking", "history", "2026-04-20-snapshot.md"), "updated\n");
|
|
54
|
+
git(base, "add", ".");
|
|
55
|
+
git(base, "commit", "-m", "update");
|
|
56
|
+
|
|
57
|
+
// Without allowlist: tracking/history snapshot is unexpected
|
|
58
|
+
const auditWithout = validateFileChanges(base, ["src.ts"], []);
|
|
59
|
+
assert.ok(auditWithout, "audit should be produced");
|
|
60
|
+
assert.ok(
|
|
61
|
+
auditWithout.unexpectedFiles.includes("tracking/history/2026-04-20-snapshot.md"),
|
|
62
|
+
"snapshot should be unexpected without allowlist",
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// With glob allowlist: snapshot is excluded
|
|
66
|
+
const auditWith = validateFileChanges(base, ["src.ts"], [], ["tracking/history/**"]);
|
|
67
|
+
assert.ok(auditWith, "audit should be produced with allowlist");
|
|
68
|
+
assert.deepEqual(auditWith.unexpectedFiles, [], "no unexpected files when snapshot is allowlisted");
|
|
69
|
+
assert.equal(
|
|
70
|
+
auditWith.violations.filter(v => v.severity === "warning").length,
|
|
71
|
+
0,
|
|
72
|
+
"no warnings when all unexpected files are allowlisted",
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
18
76
|
test("validateFileChanges ignores inline descriptions in expected output paths", (t) => {
|
|
19
77
|
const base = mkdtempSync(join(tmpdir(), "gsd-file-change-validator-"));
|
|
20
78
|
t.after(() => rmSync(base, { recursive: true, force: true }));
|
|
@@ -39,19 +39,50 @@ describe("flat-rate provider routing guard (#3453)", () => {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
test("resolvePreferredModelConfig returns undefined for copilot start model", () => {
|
|
42
|
+
const originalCwd = process.cwd();
|
|
43
|
+
const originalGsdHome = process.env.GSD_HOME;
|
|
44
|
+
const tempProject = mkdtempSync(join(tmpdir(), "gsd-flat-rate-project-"));
|
|
45
|
+
const tempGsdHome = mkdtempSync(join(tmpdir(), "gsd-flat-rate-home-"));
|
|
46
|
+
|
|
42
47
|
// When the user's start model is on a flat-rate provider,
|
|
43
48
|
// resolvePreferredModelConfig should not synthesize a routing
|
|
44
49
|
// config from tier_models — it should return undefined so the
|
|
45
50
|
// user's selected model is preserved.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
try {
|
|
52
|
+
mkdirSync(join(tempProject, ".gsd"), { recursive: true });
|
|
53
|
+
writeFileSync(
|
|
54
|
+
join(tempProject, ".gsd", "PREFERENCES.md"),
|
|
55
|
+
[
|
|
56
|
+
"---",
|
|
57
|
+
"dynamic_routing:",
|
|
58
|
+
" enabled: true",
|
|
59
|
+
" tier_models:",
|
|
60
|
+
" light: gpt-4o-mini",
|
|
61
|
+
" standard: claude-sonnet-4-6",
|
|
62
|
+
" heavy: claude-opus-4-6",
|
|
63
|
+
"---",
|
|
64
|
+
].join("\n"),
|
|
65
|
+
"utf-8",
|
|
66
|
+
);
|
|
67
|
+
process.env.GSD_HOME = tempGsdHome;
|
|
68
|
+
process.chdir(tempProject);
|
|
69
|
+
|
|
70
|
+
const result = resolvePreferredModelConfig("execute-task", {
|
|
71
|
+
provider: "github-copilot",
|
|
72
|
+
id: "claude-sonnet-4",
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Should be undefined (no routing config created for flat-rate)
|
|
76
|
+
// Note: this only tests the synthesis guard — explicit per-unit config
|
|
77
|
+
// still takes precedence when the user configured one.
|
|
78
|
+
assert.equal(result, undefined, "Should not create routing config for copilot");
|
|
79
|
+
} finally {
|
|
80
|
+
process.chdir(originalCwd);
|
|
81
|
+
if (originalGsdHome === undefined) delete process.env.GSD_HOME;
|
|
82
|
+
else process.env.GSD_HOME = originalGsdHome;
|
|
83
|
+
rmSync(tempProject, { recursive: true, force: true });
|
|
84
|
+
rmSync(tempGsdHome, { recursive: true, force: true });
|
|
85
|
+
}
|
|
55
86
|
});
|
|
56
87
|
});
|
|
57
88
|
|
|
@@ -6,6 +6,7 @@ import * as fs from 'node:fs';
|
|
|
6
6
|
import {
|
|
7
7
|
openDatabase,
|
|
8
8
|
closeDatabase,
|
|
9
|
+
_getAdapter,
|
|
9
10
|
} from '../gsd-db.ts';
|
|
10
11
|
import {
|
|
11
12
|
parseDecisionsTable,
|
|
@@ -30,6 +31,13 @@ function cleanupDir(dir: string): void {
|
|
|
30
31
|
} catch { /* swallow */ }
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
/** Query all decisions from the DB ordered by seq. */
|
|
35
|
+
function queryAllDecisions(): Array<Record<string, unknown>> {
|
|
36
|
+
const adapter = _getAdapter();
|
|
37
|
+
if (!adapter) return [];
|
|
38
|
+
return adapter.prepare('SELECT * FROM decisions ORDER BY seq').all();
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
34
42
|
// Bug reproduction: freeform DECISIONS.md content destroyed (#2301)
|
|
35
43
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -87,6 +95,13 @@ describe('freeform-decisions', () => {
|
|
|
87
95
|
|
|
88
96
|
assert.deepStrictEqual(result.id, 'D001', 'decision ID assigned correctly');
|
|
89
97
|
|
|
98
|
+
// ── Assert DB state ──
|
|
99
|
+
const dbRows = queryAllDecisions();
|
|
100
|
+
assert.equal(dbRows.length, 1, 'DB has exactly 1 decision after first save');
|
|
101
|
+
assert.equal(dbRows[0]['id'], 'D001', 'DB row has correct ID');
|
|
102
|
+
assert.equal(dbRows[0]['scope'], 'testing', 'DB row has correct scope');
|
|
103
|
+
assert.equal(dbRows[0]['decision'], 'Use Jest for unit tests', 'DB row has correct decision text');
|
|
104
|
+
|
|
90
105
|
// Read back the file
|
|
91
106
|
const afterContent = fs.readFileSync(mdPath, 'utf-8');
|
|
92
107
|
|
|
@@ -125,6 +140,13 @@ describe('freeform-decisions', () => {
|
|
|
125
140
|
|
|
126
141
|
assert.deepStrictEqual(result2.id, 'D002', 'second decision ID assigned correctly');
|
|
127
142
|
|
|
143
|
+
// ── Assert DB state after second save ──
|
|
144
|
+
const dbRows2 = queryAllDecisions();
|
|
145
|
+
assert.equal(dbRows2.length, 2, 'DB has exactly 2 decisions after second save');
|
|
146
|
+
assert.equal(dbRows2[0]['id'], 'D001', 'first DB row still D001');
|
|
147
|
+
assert.equal(dbRows2[1]['id'], 'D002', 'second DB row is D002');
|
|
148
|
+
assert.equal(dbRows2[1]['scope'], 'ci', 'second DB row has correct scope');
|
|
149
|
+
|
|
128
150
|
const afterContent2 = fs.readFileSync(mdPath, 'utf-8');
|
|
129
151
|
|
|
130
152
|
assert.ok(
|
|
@@ -182,6 +204,12 @@ describe('freeform-decisions', () => {
|
|
|
182
204
|
// But the new decision should be there.
|
|
183
205
|
assert.deepStrictEqual(result.id, 'D001', 'gets D001 since DB was empty');
|
|
184
206
|
|
|
207
|
+
// ── Assert DB state ──
|
|
208
|
+
const dbRows = queryAllDecisions();
|
|
209
|
+
assert.equal(dbRows.length, 1, 'DB has exactly 1 decision');
|
|
210
|
+
assert.equal(dbRows[0]['id'], 'D001', 'DB row has correct ID');
|
|
211
|
+
assert.equal(dbRows[0]['decision'], 'Use Vitest', 'DB row has correct decision text');
|
|
212
|
+
|
|
185
213
|
const afterContent = fs.readFileSync(mdPath, 'utf-8');
|
|
186
214
|
// Table-format file gets fully regenerated — this is the normal path
|
|
187
215
|
assert.ok(
|
|
@@ -218,6 +246,13 @@ describe('freeform-decisions', () => {
|
|
|
218
246
|
assert.deepStrictEqual(result.id, 'D001', 'first decision gets D001');
|
|
219
247
|
assert.ok(fs.existsSync(mdPath), 'DECISIONS.md created');
|
|
220
248
|
|
|
249
|
+
// ── Assert DB state ──
|
|
250
|
+
const dbRows = queryAllDecisions();
|
|
251
|
+
assert.equal(dbRows.length, 1, 'DB has exactly 1 decision');
|
|
252
|
+
assert.equal(dbRows[0]['id'], 'D001', 'DB row ID is D001');
|
|
253
|
+
assert.equal(dbRows[0]['scope'], 'arch', 'DB row scope is arch');
|
|
254
|
+
assert.equal(dbRows[0]['decision'], 'Brand new decision', 'DB row decision text matches');
|
|
255
|
+
|
|
221
256
|
const content = fs.readFileSync(mdPath, 'utf-8');
|
|
222
257
|
assert.ok(content.includes('# Decisions Register'), 'new file has header');
|
|
223
258
|
assert.ok(content.includes('Brand new decision'), 'new file has decision');
|
|
@@ -227,6 +262,33 @@ describe('freeform-decisions', () => {
|
|
|
227
262
|
}
|
|
228
263
|
});
|
|
229
264
|
|
|
265
|
+
test('parallel saveDecisionToDb calls assign unique IDs', async () => {
|
|
266
|
+
const tmpDir = makeTmpDir();
|
|
267
|
+
const dbPath = path.join(tmpDir, '.gsd', 'gsd.db');
|
|
268
|
+
openDatabase(dbPath);
|
|
269
|
+
|
|
270
|
+
try {
|
|
271
|
+
const [r1, r2, r3] = await Promise.all([
|
|
272
|
+
saveDecisionToDb({ scope: 'a', decision: 'Decision A', choice: 'A', rationale: 'A' }, tmpDir),
|
|
273
|
+
saveDecisionToDb({ scope: 'b', decision: 'Decision B', choice: 'B', rationale: 'B' }, tmpDir),
|
|
274
|
+
saveDecisionToDb({ scope: 'c', decision: 'Decision C', choice: 'C', rationale: 'C' }, tmpDir),
|
|
275
|
+
]);
|
|
276
|
+
|
|
277
|
+
const ids = new Set([r1.id, r2.id, r3.id]);
|
|
278
|
+
assert.strictEqual(ids.size, 3, `expected 3 unique IDs but got: ${[r1.id, r2.id, r3.id]}`);
|
|
279
|
+
|
|
280
|
+
// Verify all 3 decisions exist in the markdown file
|
|
281
|
+
const mdPath = path.join(tmpDir, '.gsd', 'DECISIONS.md');
|
|
282
|
+
const content = fs.readFileSync(mdPath, 'utf-8');
|
|
283
|
+
assert.ok(content.includes('Decision A'), 'Decision A in file');
|
|
284
|
+
assert.ok(content.includes('Decision B'), 'Decision B in file');
|
|
285
|
+
assert.ok(content.includes('Decision C'), 'Decision C in file');
|
|
286
|
+
} finally {
|
|
287
|
+
closeDatabase();
|
|
288
|
+
cleanupDir(tmpDir);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
230
292
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
231
293
|
|
|
232
294
|
});
|