gsd-pi 2.80.0-dev.c5f2443b3 → 2.80.0-dev.cf9433f56
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 +4 -2
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/GSD-WORKFLOW.md +2 -2
- package/dist/resources/extensions/github-sync/templates.js +39 -8
- package/dist/resources/extensions/gsd/auto/loop.js +48 -10
- package/dist/resources/extensions/gsd/auto/phases.js +66 -45
- package/dist/resources/extensions/gsd/auto/resolve.js +17 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +32 -16
- package/dist/resources/extensions/gsd/auto-dashboard.js +51 -15
- package/dist/resources/extensions/gsd/auto-dispatch.js +10 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +10 -10
- package/dist/resources/extensions/gsd/auto-prompts.js +124 -2
- package/dist/resources/extensions/gsd/auto-recovery.js +197 -9
- package/dist/resources/extensions/gsd/auto-start.js +2 -3
- package/dist/resources/extensions/gsd/auto-supervisor.js +8 -1
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +2 -2
- package/dist/resources/extensions/gsd/auto.js +77 -5
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +36 -3
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +27 -20
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +32 -1
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +129 -1
- package/dist/resources/extensions/gsd/clean-root-preflight.js +42 -4
- package/dist/resources/extensions/gsd/commands/dispatcher.js +5 -0
- package/dist/resources/extensions/gsd/commands-extract-learnings.js +17 -12
- package/dist/resources/extensions/gsd/context-budget.js +37 -2
- package/dist/resources/extensions/gsd/crash-recovery.js +56 -10
- package/dist/resources/extensions/gsd/custom-workflow-engine.js +22 -2
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +39 -0
- package/dist/resources/extensions/gsd/db-base-schema.js +18 -2
- package/dist/resources/extensions/gsd/db-migration-steps.js +22 -0
- package/dist/resources/extensions/gsd/detection.js +106 -0
- package/dist/resources/extensions/gsd/git-service.js +36 -4
- package/dist/resources/extensions/gsd/graph.js +9 -3
- package/dist/resources/extensions/gsd/gsd-db.js +146 -13
- package/dist/resources/extensions/gsd/guided-flow.js +82 -16
- package/dist/resources/extensions/gsd/memory-store.js +69 -12
- package/dist/resources/extensions/gsd/migrate/command.js +40 -1
- package/dist/resources/extensions/gsd/migration-auto-check.js +87 -0
- package/dist/resources/extensions/gsd/planning-path-scope.js +26 -0
- package/dist/resources/extensions/gsd/pr-evidence.js +57 -16
- package/dist/resources/extensions/gsd/pre-execution-checks.js +7 -0
- package/dist/resources/extensions/gsd/prompt-loader.js +28 -2
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +19 -19
- package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/quick-task.md +1 -5
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
- package/dist/resources/extensions/gsd/quick.js +34 -2
- package/dist/resources/extensions/gsd/safety/evidence-collector.js +10 -2
- package/dist/resources/extensions/gsd/tools/context-mode-tool-result.js +15 -0
- package/dist/resources/extensions/gsd/tools/exec-search-tool.js +5 -0
- package/dist/resources/extensions/gsd/tools/exec-tool.js +3 -15
- package/dist/resources/extensions/gsd/tools/memory-tools.js +1 -0
- package/dist/resources/extensions/gsd/tools/plan-slice.js +9 -0
- package/dist/resources/extensions/gsd/tools/plan-task.js +9 -0
- package/dist/resources/extensions/gsd/tools/resume-tool.js +5 -0
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +1 -1
- package/dist/resources/extensions/gsd/unit-context-composer.js +12 -3
- package/dist/resources/extensions/gsd/unit-runtime.js +22 -0
- package/dist/resources/extensions/gsd/working-output-messages.js +64 -0
- package/dist/resources/extensions/gsd/worktree-manager.js +16 -14
- package/dist/resources/extensions/gsd/worktree-resolver.js +33 -17
- 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 +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.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/api/onboarding/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 +10 -10
- 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-react-loadable-manifest.js +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/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/{8336.6f6f30e410419aff.js → 8336.631939fb583761fa.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/{webpack-d82dbee6356c1733.js → webpack-0481f1221120a7c6.js} +1 -1
- package/package.json +12 -8
- package/packages/contracts/package.json +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +22 -17
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/src/workflow-tools.test.ts +75 -2
- package/packages/mcp-server/src/workflow-tools.ts +30 -16
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/native/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/models/fake-model.d.ts +12 -0
- package/packages/pi-ai/dist/models/fake-model.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/fake-model.js +27 -0
- package/packages/pi-ai/dist/models/fake-model.js.map +1 -0
- package/packages/pi-ai/dist/models/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/models/index.js +8 -0
- package/packages/pi-ai/dist/models/index.js.map +1 -1
- package/packages/pi-ai/dist/providers/fake.d.ts +42 -0
- package/packages/pi-ai/dist/providers/fake.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/fake.js +319 -0
- package/packages/pi-ai/dist/providers/fake.js.map +1 -0
- package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/register-builtins.js +24 -0
- package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -1
- package/packages/pi-ai/src/models/fake-model.ts +30 -0
- package/packages/pi-ai/src/models/index.ts +9 -0
- package/packages/pi-ai/src/providers/fake.ts +376 -0
- package/packages/pi-ai/src/providers/register-builtins.ts +23 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js +32 -0
- 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.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +8 -0
- 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 +76 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +11 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js +9 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js +103 -0
- package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts +15 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.js +66 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.js +24 -0
- package/packages/pi-coding-agent/dist/core/db-snapshot.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +3 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +17 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +99 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +7 -0
- 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/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +5 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +24 -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 +33 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.js +1 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js +6 -4
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +54 -15
- 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/adaptive-layout.d.ts +26 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js +112 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js +51 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.test.js.map +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.map +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 +10 -9
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +3 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +7 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +17 -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 +109 -17
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.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 +69 -2
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js +93 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +3 -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 +26 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +20 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.js +79 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts +12 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js +13 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +18 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +36 -27
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.d.ts +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.js +18 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js +48 -0
- package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js +10 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js +3 -2
- package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +36 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +8 -0
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +89 -0
- package/packages/pi-coding-agent/src/core/compaction/compaction.ts +18 -0
- package/packages/pi-coding-agent/src/core/compaction-threshold.test.ts +121 -0
- package/packages/pi-coding-agent/src/core/db-snapshot.test.ts +32 -0
- package/packages/pi-coding-agent/src/core/db-snapshot.ts +66 -0
- package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +110 -0
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +19 -1
- package/packages/pi-coding-agent/src/core/extensions/types.ts +7 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +4 -0
- package/packages/pi-coding-agent/src/core/settings-manager.ts +51 -1
- package/packages/pi-coding-agent/src/core/slash-commands.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.ts +7 -5
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +78 -15
- package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.test.ts +59 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.ts +160 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +10 -9
- package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +15 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +10 -9
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +122 -17
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +99 -1
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +92 -3
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-state.ts +1 -1
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +28 -0
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.test.ts +95 -0
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +24 -1
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.ts +13 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +32 -2
- package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +36 -27
- package/packages/pi-coding-agent/src/modes/interactive/tui-mode.test.ts +65 -0
- package/packages/pi-coding-agent/src/modes/interactive/tui-mode.ts +29 -0
- package/packages/pi-coding-agent/src/resources/extensions/memory/storage-safety-guard.test.ts +14 -0
- package/packages/pi-coding-agent/src/resources/extensions/memory/storage.ts +3 -2
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/dist/__tests__/style.test.d.ts +2 -0
- package/packages/pi-tui/dist/__tests__/style.test.d.ts.map +1 -0
- package/packages/pi-tui/dist/__tests__/style.test.js +63 -0
- package/packages/pi-tui/dist/__tests__/style.test.js.map +1 -0
- package/packages/pi-tui/dist/__tests__/tui.test.js +24 -3
- package/packages/pi-tui/dist/__tests__/tui.test.js.map +1 -1
- package/packages/pi-tui/dist/index.d.ts +1 -0
- package/packages/pi-tui/dist/index.d.ts.map +1 -1
- package/packages/pi-tui/dist/index.js +2 -0
- package/packages/pi-tui/dist/index.js.map +1 -1
- package/packages/pi-tui/dist/style.d.ts +41 -0
- package/packages/pi-tui/dist/style.d.ts.map +1 -0
- package/packages/pi-tui/dist/style.js +158 -0
- package/packages/pi-tui/dist/style.js.map +1 -0
- package/packages/pi-tui/dist/tui.d.ts +0 -1
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +21 -16
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/src/__tests__/style.test.ts +76 -0
- package/packages/pi-tui/src/__tests__/tui.test.ts +29 -3
- package/packages/pi-tui/src/index.ts +9 -0
- package/packages/pi-tui/src/style.ts +225 -0
- package/packages/pi-tui/src/tui.ts +23 -16
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/pkg/dist/modes/interactive/theme/theme-schema.d.ts +12 -0
- package/pkg/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme-schema.js +13 -0
- package/pkg/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +18 -1
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/themes.js +36 -27
- package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
- package/src/resources/GSD-WORKFLOW.md +2 -2
- package/src/resources/extensions/github-sync/templates.ts +38 -8
- package/src/resources/extensions/github-sync/tests/inline-code.test.ts +66 -0
- package/src/resources/extensions/gsd/auto/loop-deps.ts +1 -0
- package/src/resources/extensions/gsd/auto/loop.ts +67 -18
- package/src/resources/extensions/gsd/auto/phases.ts +77 -48
- package/src/resources/extensions/gsd/auto/resolve.ts +23 -1
- package/src/resources/extensions/gsd/auto/run-unit.ts +42 -15
- package/src/resources/extensions/gsd/auto-dashboard.ts +57 -8
- package/src/resources/extensions/gsd/auto-dispatch.ts +17 -0
- package/src/resources/extensions/gsd/auto-post-unit.ts +10 -10
- package/src/resources/extensions/gsd/auto-prompts.ts +133 -2
- package/src/resources/extensions/gsd/auto-recovery.ts +207 -7
- package/src/resources/extensions/gsd/auto-start.ts +7 -6
- package/src/resources/extensions/gsd/auto-supervisor.ts +7 -0
- package/src/resources/extensions/gsd/auto-timeout-recovery.ts +2 -2
- package/src/resources/extensions/gsd/auto.ts +92 -4
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +37 -2
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +27 -19
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +39 -1
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +135 -1
- package/src/resources/extensions/gsd/clean-root-preflight.ts +41 -3
- package/src/resources/extensions/gsd/commands/dispatcher.ts +6 -0
- package/src/resources/extensions/gsd/commands-extract-learnings.ts +17 -12
- package/src/resources/extensions/gsd/context-budget.ts +44 -2
- package/src/resources/extensions/gsd/crash-recovery.ts +67 -10
- package/src/resources/extensions/gsd/custom-workflow-engine.ts +24 -1
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +41 -0
- package/src/resources/extensions/gsd/db-base-schema.ts +19 -2
- package/src/resources/extensions/gsd/db-migration-steps.ts +25 -0
- package/src/resources/extensions/gsd/detection.ts +128 -0
- package/src/resources/extensions/gsd/git-service.ts +46 -8
- package/src/resources/extensions/gsd/graph.ts +12 -5
- package/src/resources/extensions/gsd/gsd-db.ts +168 -13
- package/src/resources/extensions/gsd/guided-flow.ts +98 -16
- package/src/resources/extensions/gsd/memory-store.ts +77 -12
- package/src/resources/extensions/gsd/migrate/command.ts +47 -1
- package/src/resources/extensions/gsd/migration-auto-check.ts +129 -0
- package/src/resources/extensions/gsd/planning-path-scope.ts +35 -0
- package/src/resources/extensions/gsd/pr-evidence.ts +63 -5
- package/src/resources/extensions/gsd/pre-execution-checks.ts +7 -0
- package/src/resources/extensions/gsd/preferences-types.ts +1 -1
- package/src/resources/extensions/gsd/prompt-loader.ts +27 -2
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +19 -19
- package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/quick-task.md +1 -5
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
- package/src/resources/extensions/gsd/quick.ts +37 -2
- package/src/resources/extensions/gsd/safety/evidence-collector.ts +11 -2
- package/src/resources/extensions/gsd/tests/auto-abort-pause-regression.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +33 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +155 -5
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +56 -13
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +184 -2
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +88 -2
- package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +14 -1
- package/src/resources/extensions/gsd/tests/context-budget.test.ts +10 -1
- package/src/resources/extensions/gsd/tests/crash-handler-secondary.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +22 -0
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +112 -6
- package/src/resources/extensions/gsd/tests/custom-workflow-engine.test.ts +40 -2
- package/src/resources/extensions/gsd/tests/db-migration-steps.integration.test.ts +428 -0
- package/src/resources/extensions/gsd/tests/db-schema-metadata.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/detection.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +313 -0
- package/src/resources/extensions/gsd/tests/exec-history.test.ts +15 -0
- package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +65 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/commands-ship-basic.md +52 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/commands-ship-empty-optionals.md +42 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-no-blockers.md +55 -0
- package/src/resources/extensions/gsd/tests/fixtures/pr-body/swarm-lane-with-blockers.md +60 -0
- package/src/resources/extensions/gsd/tests/graph-operations.test.ts +10 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/has-pending-deep-stage.test.ts +33 -1
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +234 -0
- package/src/resources/extensions/gsd/tests/memory-decay-factor.test.ts +90 -0
- package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +48 -0
- package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/plan-slice.test.ts +50 -0
- package/src/resources/extensions/gsd/tests/plan-task.test.ts +21 -0
- package/src/resources/extensions/gsd/tests/pr-evidence-equivalence.test.ts +102 -0
- package/src/resources/extensions/gsd/tests/pr-evidence-hardening.test.ts +165 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/prompt-path-audit.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/quick-external-gsd.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/right-sized-workflow-prompts.test.ts +192 -0
- package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +29 -0
- package/src/resources/extensions/gsd/tests/schema-v27-v28-sequence.test.ts +156 -0
- package/src/resources/extensions/gsd/tests/signal-handlers.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +49 -1
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +101 -2
- package/src/resources/extensions/gsd/tests/status-db-open.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/unit-context-composer.test.ts +136 -4
- package/src/resources/extensions/gsd/tests/unit-dispatches.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +37 -0
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/working-output-messages.test.ts +93 -0
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +37 -6
- package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +7 -0
- package/src/resources/extensions/gsd/tests/worktree-nested-git-safety.test.ts +9 -2
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +63 -1
- package/src/resources/extensions/gsd/tests/worktree-write-gate.test.ts +179 -0
- package/src/resources/extensions/gsd/tools/context-mode-tool-result.ts +25 -0
- package/src/resources/extensions/gsd/tools/exec-search-tool.ts +7 -7
- package/src/resources/extensions/gsd/tools/exec-tool.ts +4 -23
- package/src/resources/extensions/gsd/tools/memory-tools.ts +1 -0
- package/src/resources/extensions/gsd/tools/plan-slice.ts +13 -0
- package/src/resources/extensions/gsd/tools/plan-task.ts +10 -0
- package/src/resources/extensions/gsd/tools/resume-tool.ts +7 -7
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +1 -1
- package/src/resources/extensions/gsd/unit-context-composer.ts +19 -4
- package/src/resources/extensions/gsd/unit-runtime.ts +25 -0
- package/src/resources/extensions/gsd/working-output-messages.ts +120 -0
- package/src/resources/extensions/gsd/worktree-manager.ts +15 -4
- package/src/resources/extensions/gsd/worktree-resolver.ts +36 -15
- package/packages/contracts/tsconfig.tsbuildinfo +0 -1
- /package/dist/web/standalone/.next/static/{bQDK5_LtkGVS64AirQgQG → -5nHJWzSdG-WkPMul_khA}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{bQDK5_LtkGVS64AirQgQG → -5nHJWzSdG-WkPMul_khA}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSD-2 fake LLM provider — deterministic JSONL replay for e2e tests.
|
|
3
|
+
*
|
|
4
|
+
* Activated only when `GSD_FAKE_LLM_TRANSCRIPT` env var is set. Reads a
|
|
5
|
+
* JSONL transcript file (one turn per line) and replays scripted responses
|
|
6
|
+
* sequentially. Each turn carries structural assertions about the incoming
|
|
7
|
+
* request — if the request shape drifts, the provider fails loudly so tests
|
|
8
|
+
* surface it instead of silently consuming wrong inputs.
|
|
9
|
+
*
|
|
10
|
+
* IMPORTANT: env var must be set BEFORE pi-ai is imported. Tests achieve
|
|
11
|
+
* this by setting it on the subprocess they spawn. In-process tests cannot
|
|
12
|
+
* mix fake and real providers in the same Node process.
|
|
13
|
+
*
|
|
14
|
+
* Transcript format (JSONL, one turn per line):
|
|
15
|
+
* {
|
|
16
|
+
* "turn": 1,
|
|
17
|
+
* "expect": {
|
|
18
|
+
* "modelId": "gsd-fake-model",
|
|
19
|
+
* "messageCount": 2, // optional, exact match
|
|
20
|
+
* "lastUserText": "do X", // optional, substring match
|
|
21
|
+
* "systemContains": ["..."], // optional, all must be present
|
|
22
|
+
* "toolNames": ["read_file"], // optional, exact set
|
|
23
|
+
* "hasToolResultFor": "read_file" // optional, last message is a toolResult for this name
|
|
24
|
+
* },
|
|
25
|
+
* "emit": { "kind": "text", "text": "...", "stopReason": "stop" }
|
|
26
|
+
* | { "kind": "tool_use", "calls": [...], "stopReason": "toolUse" }
|
|
27
|
+
* | { "kind": "error_429", "message": "rate limited", "retryAfterMs": 1000 }
|
|
28
|
+
* | { "kind": "malformed" }
|
|
29
|
+
* | { "kind": "timeout", "delayMs": 60000 }
|
|
30
|
+
* }
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import { readFileSync } from "node:fs";
|
|
34
|
+
import type { ApiProvider } from "../api-registry.js";
|
|
35
|
+
import type {
|
|
36
|
+
AssistantMessage,
|
|
37
|
+
Context,
|
|
38
|
+
Model,
|
|
39
|
+
SimpleStreamOptions,
|
|
40
|
+
StreamOptions,
|
|
41
|
+
ToolCall,
|
|
42
|
+
UserMessage,
|
|
43
|
+
} from "../types.js";
|
|
44
|
+
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
45
|
+
|
|
46
|
+
export const FAKE_API = "fake" as const;
|
|
47
|
+
|
|
48
|
+
interface ExpectFields {
|
|
49
|
+
modelId?: string;
|
|
50
|
+
messageCount?: number;
|
|
51
|
+
lastUserText?: string;
|
|
52
|
+
systemContains?: string[];
|
|
53
|
+
toolNames?: string[];
|
|
54
|
+
hasToolResultFor?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type EmitSpec =
|
|
58
|
+
| { kind: "text"; text: string; stopReason?: "stop" | "length" }
|
|
59
|
+
| {
|
|
60
|
+
kind: "tool_use";
|
|
61
|
+
calls: { id?: string; name: string; input: Record<string, unknown> }[];
|
|
62
|
+
stopReason?: "toolUse";
|
|
63
|
+
}
|
|
64
|
+
| { kind: "error_429"; message?: string; retryAfterMs?: number }
|
|
65
|
+
| { kind: "malformed"; message?: string }
|
|
66
|
+
| { kind: "timeout"; delayMs?: number };
|
|
67
|
+
|
|
68
|
+
interface TranscriptTurn {
|
|
69
|
+
turn: number;
|
|
70
|
+
expect?: ExpectFields;
|
|
71
|
+
emit: EmitSpec;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function parseTranscript(path: string): TranscriptTurn[] {
|
|
75
|
+
const raw = readFileSync(path, "utf8");
|
|
76
|
+
const lines = raw.split("\n").filter((l) => l.trim().length > 0);
|
|
77
|
+
const turns: TranscriptTurn[] = [];
|
|
78
|
+
for (const [i, line] of lines.entries()) {
|
|
79
|
+
try {
|
|
80
|
+
turns.push(JSON.parse(line));
|
|
81
|
+
} catch (err) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`fake-llm: failed to parse transcript ${path} line ${i + 1}: ${(err as Error).message}\n line: ${line}`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return turns;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function lastUserMessage(ctx: Context): UserMessage | undefined {
|
|
91
|
+
for (let i = ctx.messages.length - 1; i >= 0; i--) {
|
|
92
|
+
const m = ctx.messages[i];
|
|
93
|
+
if (m.role === "user") return m;
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function userText(m: UserMessage): string {
|
|
99
|
+
if (typeof m.content === "string") return m.content;
|
|
100
|
+
return m.content
|
|
101
|
+
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
102
|
+
.map((c) => c.text)
|
|
103
|
+
.join("\n");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function checkExpectations(model: Model<typeof FAKE_API>, ctx: Context, turn: TranscriptTurn): void {
|
|
107
|
+
const e = turn.expect;
|
|
108
|
+
if (!e) return;
|
|
109
|
+
const fail = (msg: string): never => {
|
|
110
|
+
// Surface mismatch with enough context to debug, then throw.
|
|
111
|
+
const detail = {
|
|
112
|
+
turn: turn.turn,
|
|
113
|
+
modelId: model.id,
|
|
114
|
+
messageCount: ctx.messages.length,
|
|
115
|
+
lastUserText: lastUserMessage(ctx) ? userText(lastUserMessage(ctx)!).slice(0, 200) : null,
|
|
116
|
+
toolNames: ctx.tools?.map((t) => t.name) ?? [],
|
|
117
|
+
};
|
|
118
|
+
throw new Error(`fake-llm: turn ${turn.turn} expectation mismatch: ${msg}\n actual: ${JSON.stringify(detail)}`);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
if (e.modelId !== undefined && model.id !== e.modelId) {
|
|
122
|
+
fail(`expected modelId=${e.modelId}, got ${model.id}`);
|
|
123
|
+
}
|
|
124
|
+
if (e.messageCount !== undefined && ctx.messages.length !== e.messageCount) {
|
|
125
|
+
fail(`expected messageCount=${e.messageCount}, got ${ctx.messages.length}`);
|
|
126
|
+
}
|
|
127
|
+
if (e.lastUserText !== undefined) {
|
|
128
|
+
const last = lastUserMessage(ctx);
|
|
129
|
+
if (!last) fail(`expected lastUserText to contain "${e.lastUserText}", but no user messages found`);
|
|
130
|
+
const text = userText(last!);
|
|
131
|
+
if (!text.includes(e.lastUserText)) {
|
|
132
|
+
fail(`expected lastUserText to contain "${e.lastUserText}", got "${text.slice(0, 200)}"`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (e.systemContains && e.systemContains.length > 0) {
|
|
136
|
+
const sys = ctx.systemPrompt ?? "";
|
|
137
|
+
for (const needle of e.systemContains) {
|
|
138
|
+
if (!sys.includes(needle)) fail(`expected systemPrompt to contain "${needle}"`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (e.toolNames) {
|
|
142
|
+
const actual = (ctx.tools ?? []).map((t) => t.name).sort();
|
|
143
|
+
const expected = [...e.toolNames].sort();
|
|
144
|
+
if (actual.length !== expected.length || actual.some((n, i) => n !== expected[i])) {
|
|
145
|
+
fail(`expected toolNames=${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (e.hasToolResultFor !== undefined) {
|
|
149
|
+
const last = ctx.messages[ctx.messages.length - 1];
|
|
150
|
+
if (!last || last.role !== "toolResult" || last.toolName !== e.hasToolResultFor) {
|
|
151
|
+
fail(`expected last message to be a toolResult for "${e.hasToolResultFor}"`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function buildAssistantMessage(
|
|
157
|
+
model: Model<typeof FAKE_API>,
|
|
158
|
+
emit: EmitSpec,
|
|
159
|
+
): AssistantMessage {
|
|
160
|
+
const content: AssistantMessage["content"] = [];
|
|
161
|
+
let stopReason: AssistantMessage["stopReason"] = "stop";
|
|
162
|
+
|
|
163
|
+
if (emit.kind === "text") {
|
|
164
|
+
content.push({ type: "text", text: emit.text });
|
|
165
|
+
stopReason = emit.stopReason ?? "stop";
|
|
166
|
+
} else if (emit.kind === "tool_use") {
|
|
167
|
+
for (const [i, call] of emit.calls.entries()) {
|
|
168
|
+
const tc: ToolCall = {
|
|
169
|
+
type: "toolCall",
|
|
170
|
+
id: call.id ?? `fake-tool-${Date.now()}-${i}`,
|
|
171
|
+
name: call.name,
|
|
172
|
+
arguments: call.input,
|
|
173
|
+
};
|
|
174
|
+
content.push(tc);
|
|
175
|
+
}
|
|
176
|
+
stopReason = "toolUse";
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
role: "assistant",
|
|
181
|
+
content,
|
|
182
|
+
api: model.api,
|
|
183
|
+
provider: model.provider,
|
|
184
|
+
model: model.id,
|
|
185
|
+
usage: {
|
|
186
|
+
input: 0,
|
|
187
|
+
output: 0,
|
|
188
|
+
cacheRead: 0,
|
|
189
|
+
cacheWrite: 0,
|
|
190
|
+
totalTokens: 0,
|
|
191
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
192
|
+
},
|
|
193
|
+
stopReason,
|
|
194
|
+
timestamp: Date.now(),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Create a fake provider bound to a transcript file. Each call to stream()
|
|
200
|
+
* advances the turn cursor by one. Caller is responsible for ensuring the
|
|
201
|
+
* transcript has enough turns.
|
|
202
|
+
*/
|
|
203
|
+
export function createFakeProvider(opts: { transcriptPath: string }): ApiProvider<typeof FAKE_API> {
|
|
204
|
+
const transcript = parseTranscript(opts.transcriptPath);
|
|
205
|
+
let cursor = 0;
|
|
206
|
+
|
|
207
|
+
function nextTurn(): TranscriptTurn {
|
|
208
|
+
if (cursor >= transcript.length) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`fake-llm: provider invoked ${cursor + 1} times but transcript only has ${transcript.length} turns. Add another turn to ${opts.transcriptPath}.`,
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
return transcript[cursor++];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function streamTurn(model: Model<typeof FAKE_API>, ctx: Context): AssistantMessageEventStream {
|
|
217
|
+
const stream = new AssistantMessageEventStream();
|
|
218
|
+
const turn = nextTurn();
|
|
219
|
+
|
|
220
|
+
// Synchronously validate expectations BEFORE doing any async work — this
|
|
221
|
+
// way drift mismatches are reported with the request that caused them.
|
|
222
|
+
checkExpectations(model, ctx, turn);
|
|
223
|
+
|
|
224
|
+
const emit = turn.emit;
|
|
225
|
+
|
|
226
|
+
queueMicrotask(async () => {
|
|
227
|
+
try {
|
|
228
|
+
if (emit.kind === "error_429") {
|
|
229
|
+
const errorMsg: AssistantMessage = {
|
|
230
|
+
role: "assistant",
|
|
231
|
+
content: [],
|
|
232
|
+
api: model.api,
|
|
233
|
+
provider: model.provider,
|
|
234
|
+
model: model.id,
|
|
235
|
+
usage: {
|
|
236
|
+
input: 0,
|
|
237
|
+
output: 0,
|
|
238
|
+
cacheRead: 0,
|
|
239
|
+
cacheWrite: 0,
|
|
240
|
+
totalTokens: 0,
|
|
241
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
242
|
+
},
|
|
243
|
+
stopReason: "error",
|
|
244
|
+
errorMessage: emit.message ?? "rate_limit_exceeded",
|
|
245
|
+
retryAfterMs: emit.retryAfterMs,
|
|
246
|
+
timestamp: Date.now(),
|
|
247
|
+
};
|
|
248
|
+
stream.push({ type: "error", reason: "error", error: errorMsg });
|
|
249
|
+
stream.end(errorMsg);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (emit.kind === "malformed") {
|
|
254
|
+
// Simulate a provider that emits a corrupted/incomplete response.
|
|
255
|
+
// The agent loop converts this to stopReason: "error".
|
|
256
|
+
const errorMsg: AssistantMessage = {
|
|
257
|
+
role: "assistant",
|
|
258
|
+
content: [],
|
|
259
|
+
api: model.api,
|
|
260
|
+
provider: model.provider,
|
|
261
|
+
model: model.id,
|
|
262
|
+
usage: {
|
|
263
|
+
input: 0,
|
|
264
|
+
output: 0,
|
|
265
|
+
cacheRead: 0,
|
|
266
|
+
cacheWrite: 0,
|
|
267
|
+
totalTokens: 0,
|
|
268
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
269
|
+
},
|
|
270
|
+
stopReason: "error",
|
|
271
|
+
errorMessage: emit.message ?? "malformed_response",
|
|
272
|
+
timestamp: Date.now(),
|
|
273
|
+
};
|
|
274
|
+
stream.push({ type: "error", reason: "error", error: errorMsg });
|
|
275
|
+
stream.end(errorMsg);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (emit.kind === "timeout") {
|
|
280
|
+
const delay = emit.delayMs ?? 60_000;
|
|
281
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
282
|
+
// If the caller hasn't already aborted, emit a synthetic timeout error.
|
|
283
|
+
const errorMsg: AssistantMessage = {
|
|
284
|
+
role: "assistant",
|
|
285
|
+
content: [],
|
|
286
|
+
api: model.api,
|
|
287
|
+
provider: model.provider,
|
|
288
|
+
model: model.id,
|
|
289
|
+
usage: {
|
|
290
|
+
input: 0,
|
|
291
|
+
output: 0,
|
|
292
|
+
cacheRead: 0,
|
|
293
|
+
cacheWrite: 0,
|
|
294
|
+
totalTokens: 0,
|
|
295
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
296
|
+
},
|
|
297
|
+
stopReason: "error",
|
|
298
|
+
errorMessage: "timeout",
|
|
299
|
+
timestamp: Date.now(),
|
|
300
|
+
};
|
|
301
|
+
stream.push({ type: "error", reason: "error", error: errorMsg });
|
|
302
|
+
stream.end(errorMsg);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const message = buildAssistantMessage(model, emit);
|
|
307
|
+
stream.push({ type: "start", partial: { ...message, content: [] } });
|
|
308
|
+
|
|
309
|
+
if (emit.kind === "text") {
|
|
310
|
+
stream.push({ type: "text_start", contentIndex: 0, partial: message });
|
|
311
|
+
stream.push({
|
|
312
|
+
type: "text_delta",
|
|
313
|
+
contentIndex: 0,
|
|
314
|
+
delta: emit.text,
|
|
315
|
+
partial: message,
|
|
316
|
+
});
|
|
317
|
+
stream.push({
|
|
318
|
+
type: "text_end",
|
|
319
|
+
contentIndex: 0,
|
|
320
|
+
content: emit.text,
|
|
321
|
+
partial: message,
|
|
322
|
+
});
|
|
323
|
+
} else if (emit.kind === "tool_use") {
|
|
324
|
+
for (const [i, c] of message.content.entries()) {
|
|
325
|
+
if (c.type !== "toolCall") continue;
|
|
326
|
+
stream.push({ type: "toolcall_start", contentIndex: i, partial: message });
|
|
327
|
+
stream.push({
|
|
328
|
+
type: "toolcall_end",
|
|
329
|
+
contentIndex: i,
|
|
330
|
+
toolCall: c,
|
|
331
|
+
partial: message,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
stream.push({
|
|
337
|
+
type: "done",
|
|
338
|
+
reason: message.stopReason as "stop" | "length" | "toolUse" | "pauseTurn",
|
|
339
|
+
message,
|
|
340
|
+
});
|
|
341
|
+
stream.end(message);
|
|
342
|
+
} catch (err) {
|
|
343
|
+
const errorMsg: AssistantMessage = {
|
|
344
|
+
role: "assistant",
|
|
345
|
+
content: [],
|
|
346
|
+
api: model.api,
|
|
347
|
+
provider: model.provider,
|
|
348
|
+
model: model.id,
|
|
349
|
+
usage: {
|
|
350
|
+
input: 0,
|
|
351
|
+
output: 0,
|
|
352
|
+
cacheRead: 0,
|
|
353
|
+
cacheWrite: 0,
|
|
354
|
+
totalTokens: 0,
|
|
355
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
356
|
+
},
|
|
357
|
+
stopReason: "error",
|
|
358
|
+
errorMessage: (err as Error).message,
|
|
359
|
+
timestamp: Date.now(),
|
|
360
|
+
};
|
|
361
|
+
stream.push({ type: "error", reason: "error", error: errorMsg });
|
|
362
|
+
stream.end(errorMsg);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
return stream;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return {
|
|
370
|
+
api: FAKE_API,
|
|
371
|
+
stream: ((model: Model<typeof FAKE_API>, ctx: Context, _opts?: StreamOptions) =>
|
|
372
|
+
streamTurn(model, ctx)) as ApiProvider<typeof FAKE_API>["stream"],
|
|
373
|
+
streamSimple: ((model: Model<typeof FAKE_API>, ctx: Context, _opts?: SimpleStreamOptions) =>
|
|
374
|
+
streamTurn(model, ctx)) as ApiProvider<typeof FAKE_API>["streamSimple"],
|
|
375
|
+
};
|
|
376
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { clearApiProviders, registerApiProvider } from "../api-registry.js";
|
|
2
|
+
import { createFakeProvider } from "./fake.js";
|
|
2
3
|
import type { AssistantMessage, AssistantMessageEvent, Context, Model, SimpleStreamOptions } from "../types.js";
|
|
3
4
|
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
4
5
|
import type { BedrockOptions } from "./amazon-bedrock.js";
|
|
@@ -188,6 +189,28 @@ function registerBuiltInApiProviders(): void {
|
|
|
188
189
|
export function resetApiProviders(): void {
|
|
189
190
|
clearApiProviders();
|
|
190
191
|
registerBuiltInApiProviders();
|
|
192
|
+
registerFakeProviderIfEnabled();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* E2E-test-only: when `GSD_FAKE_LLM_TRANSCRIPT` is set, register a
|
|
197
|
+
* deterministic JSONL-replay provider under api "fake". The env var must
|
|
198
|
+
* be set BEFORE this module is imported. Subprocess-spawned e2e tests do
|
|
199
|
+
* this by setting it on the spawn env.
|
|
200
|
+
*
|
|
201
|
+
* Synchronous registration: any failure throws here so the CLI startup
|
|
202
|
+
* fails loudly instead of silently falling through to a real provider.
|
|
203
|
+
*/
|
|
204
|
+
function registerFakeProviderIfEnabled(): void {
|
|
205
|
+
const transcriptPath = process.env.GSD_FAKE_LLM_TRANSCRIPT;
|
|
206
|
+
if (!transcriptPath) return;
|
|
207
|
+
try {
|
|
208
|
+
registerApiProvider(createFakeProvider({ transcriptPath }), "fake");
|
|
209
|
+
} catch (err) {
|
|
210
|
+
process.stderr.write(`fake-llm: failed to register: ${(err as Error).message}\n`);
|
|
211
|
+
throw err;
|
|
212
|
+
}
|
|
191
213
|
}
|
|
192
214
|
|
|
193
215
|
registerBuiltInApiProviders();
|
|
216
|
+
registerFakeProviderIfEnabled();
|