gsd-pi 2.78.0 → 2.78.1-dev.8a893322c
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 +60 -23
- package/dist/bundled-resource-path.d.ts +7 -0
- package/dist/bundled-resource-path.js +34 -2
- package/dist/claude-cli-check.js +104 -33
- package/dist/cli-policy.d.ts +13 -0
- package/dist/cli-policy.js +17 -0
- package/dist/cli.js +95 -55
- package/dist/headless-query.d.ts +22 -0
- package/dist/headless-query.js +43 -8
- package/dist/headless.d.ts +10 -0
- package/dist/headless.js +16 -1
- package/dist/loader.js +9 -13
- package/dist/onboarding.d.ts +10 -0
- package/dist/onboarding.js +2 -2
- package/dist/provider-migrations.d.ts +2 -2
- package/dist/provider-migrations.js +5 -2
- package/dist/resource-loader.d.ts +5 -2
- package/dist/resource-loader.js +30 -13
- package/dist/resources/.managed-resources-content-hash +1 -0
- package/dist/resources/extensions/claude-code-cli/readiness.js +128 -32
- package/dist/resources/extensions/google-search/index.js +2 -6
- package/dist/resources/extensions/gsd/auto/loop.js +23 -0
- package/dist/resources/extensions/gsd/auto/phases.js +5 -13
- package/dist/resources/extensions/gsd/auto/run-unit.js +3 -1
- package/dist/resources/extensions/gsd/auto/session.js +5 -6
- package/dist/resources/extensions/gsd/auto-dashboard.js +3 -2
- package/dist/resources/extensions/gsd/auto-dispatch.js +18 -6
- package/dist/resources/extensions/gsd/auto-prompts.js +63 -2
- package/dist/resources/extensions/gsd/auto-recovery.js +43 -4
- package/dist/resources/extensions/gsd/auto-runtime-state.js +31 -0
- package/dist/resources/extensions/gsd/auto-start.js +1 -1
- package/dist/resources/extensions/gsd/auto-tool-tracking.js +2 -2
- package/dist/resources/extensions/gsd/auto-worktree.js +60 -13
- package/dist/resources/extensions/gsd/auto.js +14 -5
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +14 -2
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +7 -5
- package/dist/resources/extensions/gsd/bootstrap/query-tools.js +2 -2
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +5 -4
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +112 -31
- package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +11 -6
- package/dist/resources/extensions/gsd/bootstrap/subagent-input.js +22 -0
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +45 -8
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +121 -3
- package/dist/resources/extensions/gsd/commands/catalog.js +76 -5
- package/dist/resources/extensions/gsd/commands/handlers/core.js +23 -1
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +8 -0
- package/dist/resources/extensions/gsd/commands-config.js +3 -2
- package/dist/resources/extensions/gsd/commands-extensions.js +46 -3
- package/dist/resources/extensions/gsd/commands-handlers.js +3 -2
- package/dist/resources/extensions/gsd/commands-mcp-status.js +3 -1
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +10 -1
- package/dist/resources/extensions/gsd/commands-worktree.js +309 -0
- package/dist/resources/extensions/gsd/dashboard-overlay.js +1 -1
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +10 -0
- package/dist/resources/extensions/gsd/doctor-providers.js +2 -1
- package/dist/resources/extensions/gsd/doctor-runtime-checks.js +39 -1
- package/dist/resources/extensions/gsd/error-classifier.js +1 -1
- package/dist/resources/extensions/gsd/forensics.js +10 -8
- package/dist/resources/extensions/gsd/git-service.js +12 -5
- package/dist/resources/extensions/gsd/gsd-db.js +11 -2
- package/dist/resources/extensions/gsd/guided-flow.js +25 -24
- package/dist/resources/extensions/gsd/home-dir.js +16 -0
- package/dist/resources/extensions/gsd/key-manager.js +2 -1
- package/dist/resources/extensions/gsd/memory-store.js +66 -31
- package/dist/resources/extensions/gsd/migrate/command.js +3 -2
- package/dist/resources/extensions/gsd/milestone-id-reservation.js +36 -0
- package/dist/resources/extensions/gsd/model-router.js +114 -9
- package/dist/resources/extensions/gsd/native-git-bridge.js +7 -1
- package/dist/resources/extensions/gsd/preferences-models.js +91 -15
- package/dist/resources/extensions/gsd/preferences-types.js +2 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +32 -0
- package/dist/resources/extensions/gsd/preferences.js +5 -3
- package/dist/resources/extensions/gsd/prompt-loader.js +23 -12
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +10 -0
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +10 -0
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +10 -0
- package/dist/resources/extensions/gsd/prompts/refine-slice.md +10 -0
- package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +9 -3
- package/dist/resources/extensions/gsd/state.js +42 -0
- package/dist/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
- package/dist/resources/extensions/gsd/tools/memory-tools.js +18 -1
- package/dist/resources/extensions/gsd/unit-context-manifest.js +29 -4
- package/dist/resources/extensions/gsd/visualizer-overlay.js +1 -1
- package/dist/resources/extensions/gsd/watch/header-renderer.js +3 -1
- package/dist/resources/extensions/gsd/worktree-command.js +26 -46
- package/dist/resources/extensions/gsd/worktree-manager.js +20 -1
- package/dist/resources/extensions/gsd/worktree-resolver.js +4 -13
- package/dist/resources/extensions/gsd/worktree-root.js +124 -0
- package/dist/resources/extensions/gsd/worktree-session-state.js +33 -0
- package/dist/resources/extensions/gsd/worktree.js +4 -115
- package/dist/resources/extensions/mcp-client/index.js +6 -9
- package/dist/resources/extensions/ollama/index.js +15 -2
- package/dist/resources/extensions/ollama/model-capabilities.js +31 -0
- package/dist/resources/extensions/ollama/ollama-client.js +40 -4
- package/dist/resources/extensions/slash-commands/create-extension.js +36 -22
- package/dist/resources/extensions/subagent/index.js +324 -178
- package/dist/resources/skills/create-gsd-extension/SKILL.md +9 -5
- package/dist/resources/skills/create-gsd-extension/references/custom-commands.md +1 -1
- package/dist/resources/skills/create-gsd-extension/references/custom-rendering.md +5 -5
- package/dist/resources/skills/create-gsd-extension/references/custom-tools.md +4 -4
- package/dist/resources/skills/create-gsd-extension/references/custom-ui.md +6 -6
- package/dist/resources/skills/create-gsd-extension/references/events-reference.md +3 -3
- package/dist/resources/skills/create-gsd-extension/references/packaging-distribution.md +1 -1
- package/dist/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +3 -3
- package/dist/resources/skills/create-gsd-extension/workflows/create-extension.md +32 -12
- package/dist/rtk-shared.d.ts +3 -0
- package/dist/rtk-shared.js +17 -0
- package/dist/rtk.d.ts +2 -5
- package/dist/rtk.js +3 -20
- package/dist/runtime-checks.d.ts +27 -0
- package/dist/runtime-checks.js +38 -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 +15 -15
- package/dist/web/standalone/.next/build-manifest.json +4 -4
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +44 -4
- package/dist/web/standalone/.next/required-server-files.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +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/page.js +2 -2
- package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- 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 +3 -3
- 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/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +4 -2
- package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +4 -4
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +4 -4
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
- 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 +3 -3
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/page.js +2 -2
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +15 -15
- package/dist/web/standalone/.next/server/chunks/63.js +3 -3
- package/dist/web/standalone/.next/server/chunks/6897.js +1 -1
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware.js +2 -2
- package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
- package/dist/web/standalone/.next/server/next-font-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/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/server/webpack-runtime.js +1 -1
- package/dist/web/standalone/.next/static/chunks/2556.0527fea66e123b7f.js +1 -0
- package/dist/web/standalone/.next/static/chunks/2824.08296bc2f9654698.js +1 -0
- package/dist/web/standalone/.next/static/chunks/3026.3af53b279375f082.js +1 -0
- package/dist/web/standalone/.next/static/chunks/315.6f68ae79b67d25cf.js +1 -0
- package/dist/web/standalone/.next/static/chunks/3497.4bfc60a3b3dea717.js +1 -0
- package/dist/web/standalone/.next/static/chunks/5516.4a07c872b5c3a663.js +1 -0
- package/dist/web/standalone/.next/static/chunks/8336.31b019697882acfb.js +10 -0
- package/dist/web/standalone/.next/static/chunks/8845.c9702695e8c5a9c5.js +2 -0
- package/dist/web/standalone/.next/static/chunks/9058.01ef3a463bda88f1.js +20 -0
- package/dist/web/standalone/.next/static/chunks/9441.1081da1125d1764f.js +1 -0
- package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-2f24283c162b6ab3.js → page-f2a7482d42a5614b.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/{layout-9ecfd95f343793f0.js → layout-a16c7a7ecdf0c2cf.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/page-9bf2e0c50fb2ca05.js +1 -0
- package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +1 -0
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +1 -0
- package/dist/web/standalone/.next/static/chunks/webpack-f9f0dc45e4f3ac10.js +1 -0
- package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
- package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
- package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
- package/dist/web/standalone/package.json +2 -1
- package/dist/web/standalone/server.js +1 -1
- package/dist/welcome-screen.js +27 -1
- package/dist/worktree-cli.d.ts +1 -0
- package/dist/worktree-cli.js +9 -3
- package/dist/worktree-status-banner.d.ts +1 -0
- package/dist/worktree-status-banner.js +132 -0
- package/package.json +1 -3
- package/packages/daemon/package.json +2 -2
- package/packages/mcp-server/dist/alias-telemetry.d.ts +8 -0
- package/packages/mcp-server/dist/alias-telemetry.d.ts.map +1 -0
- package/packages/mcp-server/dist/alias-telemetry.js +30 -0
- package/packages/mcp-server/dist/alias-telemetry.js.map +1 -0
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +74 -46
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/package.json +2 -2
- package/packages/mcp-server/src/alias-telemetry.test.ts +78 -0
- package/packages/mcp-server/src/alias-telemetry.ts +30 -0
- package/packages/mcp-server/src/workflow-tools.test.ts +78 -0
- package/packages/mcp-server/src/workflow-tools.ts +93 -58
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/native/package.json +1 -1
- package/packages/native/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.js +231 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.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 +48 -19
- package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +13 -0
- package/packages/pi-ai/dist/types.d.ts.map +1 -1
- package/packages/pi-ai/dist/types.js.map +1 -1
- package/packages/pi-ai/dist/utils/repair-tool-json.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/repair-tool-json.js +24 -3
- package/packages/pi-ai/dist/utils/repair-tool-json.js.map +1 -1
- package/packages/pi-ai/dist/utils/tests/repair-tool-json.test.js +26 -0
- package/packages/pi-ai/dist/utils/tests/repair-tool-json.test.js.map +1 -1
- package/packages/pi-ai/package.json +1 -1
- package/packages/pi-ai/src/providers/anthropic-shared.cache-breakpoint.test.ts +289 -0
- package/packages/pi-ai/src/providers/anthropic-shared.ts +52 -20
- package/packages/pi-ai/src/types.ts +13 -0
- package/packages/pi-ai/src/utils/repair-tool-json.ts +24 -3
- package/packages/pi-ai/src/utils/tests/repair-tool-json.test.ts +32 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +6 -0
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/messages.js +4 -0
- package/packages/pi-coding-agent/dist/core/messages.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js +19 -2
- package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +10 -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 +18 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +13 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +20 -16
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/token-telemetry.d.ts +37 -0
- package/packages/pi-coding-agent/dist/core/token-telemetry.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/token-telemetry.js +49 -0
- package/packages/pi-coding-agent/dist/core/token-telemetry.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +133 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js +14 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.js +78 -0
- package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/tests/token-telemetry.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/tests/token-telemetry.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/tests/token-telemetry.test.js +181 -0
- package/packages/pi-coding-agent/dist/tests/token-telemetry.test.js.map +1 -0
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +7 -0
- package/packages/pi-coding-agent/src/core/messages.ts +4 -0
- package/packages/pi-coding-agent/src/core/model-registry-auth-mode.test.ts +32 -2
- package/packages/pi-coding-agent/src/core/model-registry.ts +21 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +33 -15
- package/packages/pi-coding-agent/src/core/token-telemetry.ts +77 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +212 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +17 -1
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.ts +1 -1
- package/packages/pi-coding-agent/src/tests/system-prompt-cache-stability.test.ts +102 -0
- package/packages/pi-coding-agent/src/tests/token-telemetry.test.ts +200 -0
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/dist/__tests__/autocomplete.test.js +17 -3
- package/packages/pi-tui/dist/__tests__/autocomplete.test.js.map +1 -1
- package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.d.ts +2 -0
- package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.js +161 -0
- package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.js.map +1 -0
- package/packages/pi-tui/package.json +1 -1
- package/packages/pi-tui/src/__tests__/autocomplete.test.ts +20 -3
- package/packages/pi-tui/src/components/__tests__/leak-fixes-runtime.test.ts +219 -0
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/packages/rpc-client/package.json +1 -1
- package/pkg/package.json +1 -1
- package/src/resources/extensions/claude-code-cli/readiness.ts +130 -30
- package/src/resources/extensions/google-search/index.ts +2 -9
- package/src/resources/extensions/gsd/auto/loop.ts +24 -2
- package/src/resources/extensions/gsd/auto/phases.ts +6 -14
- package/src/resources/extensions/gsd/auto/run-unit.ts +3 -1
- package/src/resources/extensions/gsd/auto/session.ts +5 -6
- package/src/resources/extensions/gsd/auto/types.ts +1 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +3 -2
- package/src/resources/extensions/gsd/auto-dispatch.ts +18 -6
- package/src/resources/extensions/gsd/auto-prompts.ts +60 -2
- package/src/resources/extensions/gsd/auto-recovery.ts +46 -8
- package/src/resources/extensions/gsd/auto-runtime-state.ts +51 -0
- package/src/resources/extensions/gsd/auto-start.ts +1 -1
- package/src/resources/extensions/gsd/auto-tool-tracking.ts +2 -4
- package/src/resources/extensions/gsd/auto-worktree.ts +82 -12
- package/src/resources/extensions/gsd/auto.ts +14 -4
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +15 -13
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +8 -7
- package/src/resources/extensions/gsd/bootstrap/query-tools.ts +2 -2
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +10 -9
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +121 -31
- package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +12 -6
- package/src/resources/extensions/gsd/bootstrap/subagent-input.ts +20 -0
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +50 -8
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +141 -11
- package/src/resources/extensions/gsd/commands/catalog.ts +82 -5
- package/src/resources/extensions/gsd/commands/handlers/core.ts +23 -1
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +10 -0
- package/src/resources/extensions/gsd/commands-config.ts +3 -2
- package/src/resources/extensions/gsd/commands-extensions.ts +43 -3
- package/src/resources/extensions/gsd/commands-handlers.ts +3 -2
- package/src/resources/extensions/gsd/commands-mcp-status.ts +3 -1
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +15 -1
- package/src/resources/extensions/gsd/commands-worktree.ts +383 -0
- package/src/resources/extensions/gsd/dashboard-overlay.ts +1 -1
- package/src/resources/extensions/gsd/docs/preferences-reference.md +10 -0
- package/src/resources/extensions/gsd/doctor-providers.ts +2 -1
- package/src/resources/extensions/gsd/doctor-runtime-checks.ts +39 -1
- package/src/resources/extensions/gsd/doctor-types.ts +3 -1
- package/src/resources/extensions/gsd/error-classifier.ts +1 -1
- package/src/resources/extensions/gsd/forensics.ts +12 -7
- package/src/resources/extensions/gsd/git-service.ts +13 -5
- package/src/resources/extensions/gsd/gsd-db.ts +12 -2
- package/src/resources/extensions/gsd/guided-flow.ts +27 -26
- package/src/resources/extensions/gsd/home-dir.ts +19 -0
- package/src/resources/extensions/gsd/journal.ts +4 -1
- package/src/resources/extensions/gsd/key-manager.ts +2 -1
- package/src/resources/extensions/gsd/memory-store.ts +81 -28
- package/src/resources/extensions/gsd/migrate/command.ts +3 -2
- package/src/resources/extensions/gsd/milestone-id-reservation.ts +47 -0
- package/src/resources/extensions/gsd/model-router.ts +172 -9
- package/src/resources/extensions/gsd/native-git-bridge.ts +7 -1
- package/src/resources/extensions/gsd/preferences-models.ts +101 -15
- package/src/resources/extensions/gsd/preferences-types.ts +6 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +35 -0
- package/src/resources/extensions/gsd/preferences.ts +16 -2
- package/src/resources/extensions/gsd/prompt-loader.ts +26 -12
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +10 -0
- package/src/resources/extensions/gsd/prompts/complete-slice.md +10 -0
- package/src/resources/extensions/gsd/prompts/plan-slice.md +10 -0
- package/src/resources/extensions/gsd/prompts/refine-slice.md +10 -0
- package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +9 -3
- package/src/resources/extensions/gsd/state.ts +42 -0
- package/src/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +178 -1
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +58 -0
- package/src/resources/extensions/gsd/tests/auto-session-encapsulation.test.ts +24 -5
- package/src/resources/extensions/gsd/tests/auto-supervisor.test.mjs +21 -4
- package/src/resources/extensions/gsd/tests/bootstrap-derive-state-db-open.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/budget-prediction.test.ts +138 -211
- package/src/resources/extensions/gsd/tests/bundled-skill-triggers.test.ts +50 -27
- package/src/resources/extensions/gsd/tests/commands-extensions-version-compare.test.ts +58 -0
- package/src/resources/extensions/gsd/tests/commands-worktree-clean.test.ts +48 -0
- package/src/resources/extensions/gsd/tests/complete-slice-verification-gate.test.ts +142 -59
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +7 -4
- package/src/resources/extensions/gsd/tests/completed-at-reconcile.test.ts +89 -32
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +41 -23
- package/src/resources/extensions/gsd/tests/db-path-worktree-symlink.test.ts +3 -43
- package/src/resources/extensions/gsd/tests/debug-logger.test.ts +5 -3
- package/src/resources/extensions/gsd/tests/deferred-milestone-dir-4996.test.ts +116 -0
- package/src/resources/extensions/gsd/tests/discuss-empty-db-fallback.test.ts +22 -87
- package/src/resources/extensions/gsd/tests/discuss-queued-milestones.test.ts +7 -118
- package/src/resources/extensions/gsd/tests/discuss-tool-scope-leak.test.ts +18 -60
- package/src/resources/extensions/gsd/tests/doctor-orphan-milestone-4996.test.ts +100 -0
- package/src/resources/extensions/gsd/tests/double-merge-guard.test.ts +14 -76
- package/src/resources/extensions/gsd/tests/ensure-preconditions-guard-4996.test.ts +93 -0
- package/src/resources/extensions/gsd/tests/false-degraded-mode-warning.test.ts +22 -83
- package/src/resources/extensions/gsd/tests/finalize-timeout-guard.test.ts +1 -63
- package/src/resources/extensions/gsd/tests/find-missing-summaries-closed-runtime.test.ts +47 -0
- package/src/resources/extensions/gsd/tests/forensics-stuck-loops.test.ts +26 -1
- package/src/resources/extensions/gsd/tests/gitignore-bg-shell-runtime.test.ts +63 -0
- package/src/resources/extensions/gsd/tests/google-search-stub.test.ts +25 -65
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/gsd-no-project-error-runtime.test.ts +81 -0
- package/src/resources/extensions/gsd/tests/headless-answers.test.ts +14 -4
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +22 -12
- package/src/resources/extensions/gsd/tests/help-menu-coverage.test.ts +57 -0
- package/src/resources/extensions/gsd/tests/home-dir.test.ts +52 -0
- package/src/resources/extensions/gsd/tests/import-done-milestones-runtime.test.ts +145 -0
- package/src/resources/extensions/gsd/tests/init-prefs-routing.test.ts +64 -1
- package/src/resources/extensions/gsd/tests/integration/auto-worktree.test.ts +72 -1
- package/src/resources/extensions/gsd/tests/integration/token-savings.test.ts +0 -23
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +128 -0
- package/src/resources/extensions/gsd/tests/memory-tools.test.ts +33 -1
- package/src/resources/extensions/gsd/tests/merge-self-branch-guard.test.ts +124 -0
- package/src/resources/extensions/gsd/tests/milestone-id-gap-reuse-4996.test.ts +152 -0
- package/src/resources/extensions/gsd/tests/milestone-report-path.test.ts +18 -1
- package/src/resources/extensions/gsd/tests/model-router.test.ts +169 -8
- package/src/resources/extensions/gsd/tests/native-git-infra-errors.test.ts +50 -0
- package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +8 -0
- package/src/resources/extensions/gsd/tests/parallel-crash-recovery.test.ts +32 -43
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +4 -10
- package/src/resources/extensions/gsd/tests/preferences.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +16 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +7 -0
- package/src/resources/extensions/gsd/tests/quick-turn-end-cleanup.test.ts +6 -6
- package/src/resources/extensions/gsd/tests/register-hooks-compaction-checkpoint.test.ts +93 -0
- package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +34 -0
- package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +168 -19
- package/src/resources/extensions/gsd/tests/slice-parallel-orchestrator.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +23 -1
- package/src/resources/extensions/gsd/tests/steer-worktree-path.test.ts +17 -1
- package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +101 -0
- package/src/resources/extensions/gsd/tests/token-profile.test.ts +51 -4
- package/src/resources/extensions/gsd/tests/turn-epoch.test.ts +7 -16
- package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +38 -3
- package/src/resources/extensions/gsd/tests/unstructured-continue-context-injection.test.ts +5 -7
- package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +15 -1
- package/src/resources/extensions/gsd/tests/visualizer-overlay.test.ts +6 -6
- package/src/resources/extensions/gsd/tests/worktree-symlink-removal.test.ts +34 -33
- package/src/resources/extensions/gsd/tests/worktree.test.ts +8 -0
- package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +131 -1
- package/src/resources/extensions/gsd/tools/memory-tools.ts +17 -1
- package/src/resources/extensions/gsd/unit-context-manifest.ts +44 -12
- package/src/resources/extensions/gsd/visualizer-overlay.ts +1 -1
- package/src/resources/extensions/gsd/watch/header-renderer.ts +3 -1
- package/src/resources/extensions/gsd/workflow-logger.ts +1 -0
- package/src/resources/extensions/gsd/worktree-command.ts +31 -44
- package/src/resources/extensions/gsd/worktree-manager.ts +40 -1
- package/src/resources/extensions/gsd/worktree-resolver.ts +4 -14
- package/src/resources/extensions/gsd/worktree-root.ts +144 -0
- package/src/resources/extensions/gsd/worktree-session-state.ts +35 -0
- package/src/resources/extensions/gsd/worktree.ts +8 -119
- package/src/resources/extensions/mcp-client/index.ts +6 -10
- package/src/resources/extensions/mcp-client/tests/global-config.test.ts +91 -0
- package/src/resources/extensions/ollama/index.ts +16 -2
- package/src/resources/extensions/ollama/model-capabilities.ts +34 -0
- package/src/resources/extensions/ollama/ollama-client.ts +41 -4
- package/src/resources/extensions/ollama/tests/model-capabilities.test.ts +96 -0
- package/src/resources/extensions/ollama/tests/ollama-client-timeout-env.test.ts +147 -0
- package/src/resources/extensions/slash-commands/create-extension.ts +38 -24
- package/src/resources/extensions/subagent/index.ts +165 -7
- package/src/resources/skills/create-gsd-extension/SKILL.md +9 -5
- package/src/resources/skills/create-gsd-extension/references/custom-commands.md +1 -1
- package/src/resources/skills/create-gsd-extension/references/custom-rendering.md +5 -5
- package/src/resources/skills/create-gsd-extension/references/custom-tools.md +4 -4
- package/src/resources/skills/create-gsd-extension/references/custom-ui.md +6 -6
- package/src/resources/skills/create-gsd-extension/references/events-reference.md +3 -3
- package/src/resources/skills/create-gsd-extension/references/packaging-distribution.md +1 -1
- package/src/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +3 -3
- package/src/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +2 -2
- package/src/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +3 -3
- package/src/resources/skills/create-gsd-extension/templates/templates.test.ts +58 -0
- package/src/resources/skills/create-gsd-extension/workflows/create-extension.md +32 -12
- package/dist/resources/extensions/browser-tools/tests/browser-tools-integration.test.mjs +0 -601
- package/dist/resources/extensions/browser-tools/tests/browser-tools-unit.test.cjs +0 -651
- package/dist/resources/extensions/browser-tools/tests/capture-sharp-optional.test.cjs +0 -91
- package/dist/resources/extensions/gsd/tests/auto-supervisor.test.mjs +0 -53
- package/dist/resources/extensions/gsd/tests/dist-redirect.mjs +0 -112
- package/dist/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +0 -23
- package/dist/resources/extensions/gsd/tests/resolve-ts.mjs +0 -5
- package/dist/resources/skills/github-workflows/references/gh/tests/__init__.py +0 -0
- package/dist/resources/skills/github-workflows/references/gh/tests/test_github_project_setup.py +0 -608
- package/dist/web/standalone/.next/static/chunks/2826.e9f5195e91f9cad2.js +0 -11
- package/dist/web/standalone/.next/static/chunks/3621.fc7480022c972438.js +0 -20
- package/dist/web/standalone/.next/static/chunks/app/page-151349214571e2b6.js +0 -1
- package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +0 -1
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +0 -1
- package/dist/web/standalone/.next/static/chunks/webpack-2e68521d7c82f7c2.js +0 -1
- package/src/resources/extensions/gsd/tests/copy-planning-artifacts-samepath.test.ts +0 -22
- package/src/resources/extensions/gsd/tests/discuss-slice-structured-questions.test.ts +0 -47
- package/src/resources/extensions/gsd/tests/empty-content-abort-loop.test.ts +0 -75
- /package/dist/web/standalone/.next/static/{C1zT2kEfoLhDdbWPWKrXd → QK8fABiGPmonfTgboN0Y9}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{C1zT2kEfoLhDdbWPWKrXd → QK8fABiGPmonfTgboN0Y9}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-telemetry.js","sourceRoot":"","sources":["../../src/core/token-telemetry.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,gEAAgE;AAChE,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,oEAAoE;AACpE,EAAE;AACF,6EAA6E;AA8B7E,kEAAkE;AAClE,MAAM,UAAU,yBAAyB,CAAC,GAAqB;IAC9D,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,EAAE,UAAU,IAAI,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,SAAS,GAAG,KAAK,CAAC;IAChC,MAAM,aAAa,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAExD,OAAO;QACN,EAAE,EAAE,GAAG,CAAC,SAAS;QACjB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,KAAK;QACL,MAAM;QACN,SAAS;QACT,UAAU;QACV,SAAS;QACT,aAAa;KACb,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAqB;IACvD,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,GAAG;QAAE,OAAO;IACnD,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,yBAAyB,CAAC,GAAG,CAAC,CAAC;QAC9C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACR,sDAAsD;IACvD,CAAC;AACF,CAAC","sourcesContent":["// @gsd/pi-coding-agent + token-telemetry — opt-in per-call token observability\n//\n// Emits a single JSON line per assistant message to stderr when\n// `PI_TOKEN_TELEMETRY=1` is set. Captures the cache_read_input_tokens and\n// cache_creation_input_tokens fields the providers already extract — so we\n// can empirically measure prompt-cache effectiveness (e.g. for #5019 and\n// future cache strategy work). Off by default — no behavior change.\n//\n// Capture pattern: `PI_TOKEN_TELEMETRY=1 npm start 2> token-telemetry.jsonl`\n\nimport type { AssistantMessage } from \"@gsd/pi-ai\";\n\n/** Schema of one telemetry line. JSON-stable for downstream ingestion. */\nexport interface TokenTelemetryRecord {\n\tts: number;\n\tmodel: string;\n\tstopReason: string;\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\t/**\n\t * `usage.cost.total` from the provider. `0` when the provider's cost\n\t * registry has no rates for this model (e.g. unknown third-party providers)\n\t * — distinguish from a true zero-cost call by checking your model registry.\n\t */\n\tcostTotal: number;\n\t/**\n\t * Fraction of new prompt tokens served from cache:\n\t * `cacheRead / (cacheRead + input)`. Range [0, 1].\n\t * - `0` when neither cacheRead nor input is present (no division by zero).\n\t * - `1` on a full cache hit (input = 0, cacheRead > 0).\n\t * Note: `input` here is `input_tokens` from the API, which already excludes\n\t * cache reads/writes — the denominator is total prompt tokens consumed.\n\t */\n\tcacheHitRatio: number;\n}\n\n/** Build a telemetry record from a finished assistant message. */\nexport function buildTokenTelemetryRecord(msg: AssistantMessage): TokenTelemetryRecord {\n\tconst input = msg.usage?.input ?? 0;\n\tconst output = msg.usage?.output ?? 0;\n\tconst cacheRead = msg.usage?.cacheRead ?? 0;\n\tconst cacheWrite = msg.usage?.cacheWrite ?? 0;\n\tconst costTotal = msg.usage?.cost?.total ?? 0;\n\tconst denom = cacheRead + input;\n\tconst cacheHitRatio = denom > 0 ? cacheRead / denom : 0;\n\n\treturn {\n\t\tts: msg.timestamp,\n\t\tmodel: msg.model,\n\t\tstopReason: msg.stopReason,\n\t\tinput,\n\t\toutput,\n\t\tcacheRead,\n\t\tcacheWrite,\n\t\tcostTotal,\n\t\tcacheHitRatio,\n\t};\n}\n\n/**\n * Emit a token-telemetry line if `PI_TOKEN_TELEMETRY=1`. No-op otherwise.\n *\n * Writes to stderr so it doesn't interfere with TUI/stdout. One JSON object\n * per line. Errors during emission are swallowed — telemetry must never\n * break the agent loop.\n */\nexport function emitTokenTelemetry(msg: AssistantMessage): void {\n\tif (process.env.PI_TOKEN_TELEMETRY !== \"1\") return;\n\ttry {\n\t\tconst record = buildTokenTelemetryRecord(msg);\n\t\tprocess.stderr.write(`${JSON.stringify(record)}\\n`);\n\t} catch {\n\t\t// Telemetry must never break the agent loop. Swallow.\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-card-cleanup-and-success-runtime.test.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Runtime regression tests for the post-compaction tool-card cleanup and the
|
|
2
|
+
// green-bordered success-notification rendering. Replaces the source-grep
|
|
3
|
+
// `src/tests/tui-running-and-success-box.test.ts` that was deleted in #4875
|
|
4
|
+
// (tracked as #4872).
|
|
5
|
+
//
|
|
6
|
+
// The previous tests asserted on identifier presence and method signature
|
|
7
|
+
// shape via regex. A regression that routed `success` notifications through
|
|
8
|
+
// `showStatus` (dim text) by accident would not have failed because the
|
|
9
|
+
// `showSuccess` method would still exist and still match the regex. These
|
|
10
|
+
// tests instead drive the components through the actual scenario and assert
|
|
11
|
+
// on rendered output.
|
|
12
|
+
import assert from "node:assert/strict";
|
|
13
|
+
import { describe, it, before } from "node:test";
|
|
14
|
+
import { Container, Text } from "@gsd/pi-tui";
|
|
15
|
+
import stripAnsi from "strip-ansi";
|
|
16
|
+
import { initTheme, theme } from "../theme/theme.js";
|
|
17
|
+
import { DynamicBorder } from "./dynamic-border.js";
|
|
18
|
+
import { ToolExecutionComponent } from "./tool-execution.js";
|
|
19
|
+
// Theme is a globalThis-shared singleton that throws if not initialized.
|
|
20
|
+
// Initialize once before any test that exercises themed rendering.
|
|
21
|
+
before(() => {
|
|
22
|
+
initTheme("dark");
|
|
23
|
+
});
|
|
24
|
+
function makeMockTUI() {
|
|
25
|
+
return {
|
|
26
|
+
renderCount: 0,
|
|
27
|
+
requestRender() {
|
|
28
|
+
this.renderCount++;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// ─── Bug 1: tool cards stuck in "Running" after compaction ──────────────
|
|
33
|
+
describe("ToolExecutionComponent post-compaction cleanup", () => {
|
|
34
|
+
it("renders 'Running' status while the tool call has no result", () => {
|
|
35
|
+
// Baseline: a freshly-constructed component (mid-stream) must show
|
|
36
|
+
// the running badge — this is the state we need to flip OUT of when
|
|
37
|
+
// compaction removes the result message.
|
|
38
|
+
const ui = makeMockTUI();
|
|
39
|
+
const c = new ToolExecutionComponent("read_file", { path: "/tmp/x.txt" }, {}, undefined, ui);
|
|
40
|
+
const rendered = c.render(60).map(stripAnsi).join("\n");
|
|
41
|
+
assert.ok(rendered.includes("Running"), "freshly constructed component should render 'Running' badge");
|
|
42
|
+
});
|
|
43
|
+
it("markHistoricalNoResult flips a stuck tool card OUT of 'Running'", () => {
|
|
44
|
+
// Real bug: after session-history replay (post-compaction or session
|
|
45
|
+
// switch), tool calls without matching tool_result messages stay in
|
|
46
|
+
// isPartial = true forever. markHistoricalNoResult must produce a
|
|
47
|
+
// rendered output that no longer reads "Running".
|
|
48
|
+
const ui = makeMockTUI();
|
|
49
|
+
const c = new ToolExecutionComponent("read_file", { path: "/tmp/x.txt" }, {}, undefined, ui);
|
|
50
|
+
c.markHistoricalNoResult();
|
|
51
|
+
const rendered = c.render(60).map(stripAnsi).join("\n");
|
|
52
|
+
assert.ok(!rendered.includes("Running"), "after markHistoricalNoResult, the tool card must NOT render 'Running' — got:\n" +
|
|
53
|
+
rendered);
|
|
54
|
+
assert.ok(rendered.includes("Done"), "flipped card should render 'Done' status (no-result success)");
|
|
55
|
+
});
|
|
56
|
+
it("markHistoricalNoResult is idempotent when a real result already exists", () => {
|
|
57
|
+
// Late-arriving stream events must not clobber legitimate results.
|
|
58
|
+
// We observe the no-clobber via behaviour: a card that completed
|
|
59
|
+
// with a real result keeps its "Done" badge and content even if
|
|
60
|
+
// markHistoricalNoResult fires again afterwards.
|
|
61
|
+
const ui = makeMockTUI();
|
|
62
|
+
const c = new ToolExecutionComponent("read_file", { path: "/tmp/x.txt" }, {}, undefined, ui);
|
|
63
|
+
// Use the public completion path the runtime calls.
|
|
64
|
+
c.updateResult({
|
|
65
|
+
content: [{ type: "text", text: "real-result-payload" }],
|
|
66
|
+
isError: false,
|
|
67
|
+
}, false);
|
|
68
|
+
const before = c.render(60).map(stripAnsi).join("\n");
|
|
69
|
+
assert.ok(before.includes("Done"), "after complete(), card shows 'Done'");
|
|
70
|
+
c.markHistoricalNoResult(); // must early-return
|
|
71
|
+
const after = c.render(60).map(stripAnsi).join("\n");
|
|
72
|
+
assert.equal(after, before, "markHistoricalNoResult must NOT mutate state when a real result is already present");
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
// ─── Bug 2: success notifications render as a green bordered box ────────
|
|
76
|
+
describe("Success-notification rendering — DynamicBorder + success theme", () => {
|
|
77
|
+
// We drive the same component composition that interactive-mode.showSuccess
|
|
78
|
+
// builds (DynamicBorder + Text + DynamicBorder, all themed with
|
|
79
|
+
// theme.fg("success", …)) and assert on the rendered output, rather than
|
|
80
|
+
// trying to instantiate the full InteractiveMode (which requires a real
|
|
81
|
+
// session, bridge, and TUI runtime).
|
|
82
|
+
function buildSuccessNotification(message) {
|
|
83
|
+
const c = new Container();
|
|
84
|
+
const successColor = (text) => theme.fg("success", text);
|
|
85
|
+
c.addChild(new DynamicBorder(successColor));
|
|
86
|
+
c.addChild(new Text(theme.fg("success", message), 1, 0));
|
|
87
|
+
c.addChild(new DynamicBorder(successColor));
|
|
88
|
+
return c;
|
|
89
|
+
}
|
|
90
|
+
it("renders a top and bottom horizontal border framing the message", () => {
|
|
91
|
+
const c = buildSuccessNotification("Milestone M042 ready.");
|
|
92
|
+
const lines = c.render(40);
|
|
93
|
+
// First and last lines should be horizontal-rule borders
|
|
94
|
+
// (DynamicBorder renders a row of "─" characters).
|
|
95
|
+
const firstStripped = stripAnsi(lines[0]);
|
|
96
|
+
const lastStripped = stripAnsi(lines[lines.length - 1]);
|
|
97
|
+
assert.ok(firstStripped.includes("─"), `first line should be a border (got: ${JSON.stringify(firstStripped)})`);
|
|
98
|
+
assert.ok(lastStripped.includes("─"), `last line should be a border (got: ${JSON.stringify(lastStripped)})`);
|
|
99
|
+
assert.ok(lines.length >= 3, `success notification must have at least 3 lines (top border, message, bottom border) — got ${lines.length}`);
|
|
100
|
+
});
|
|
101
|
+
it("the message text appears between the two borders", () => {
|
|
102
|
+
const c = buildSuccessNotification("Milestone M042 ready.");
|
|
103
|
+
const lines = c.render(40);
|
|
104
|
+
const messageRow = lines.findIndex((l) => stripAnsi(l).includes("Milestone M042 ready."));
|
|
105
|
+
assert.ok(messageRow > 0, "message must appear after the top border");
|
|
106
|
+
assert.ok(messageRow < lines.length - 1, "message must appear before the bottom border");
|
|
107
|
+
});
|
|
108
|
+
it("borders carry ANSI styling (not plain dim text like showStatus)", () => {
|
|
109
|
+
// Goodhart-resistant: if a regression routed success through
|
|
110
|
+
// showStatus, the borders would be missing AND the rendered text
|
|
111
|
+
// would be plain (or only dim-styled, not success-colored). We
|
|
112
|
+
// observe the border lines carry ANSI escape codes — the literal
|
|
113
|
+
// foreground color depends on the theme (which is system-dependent
|
|
114
|
+
// in CI), so we don't pin a specific code but DO require styling
|
|
115
|
+
// to be present.
|
|
116
|
+
const c = buildSuccessNotification("ok");
|
|
117
|
+
const lines = c.render(40);
|
|
118
|
+
const top = lines[0];
|
|
119
|
+
assert.ok(top !== stripAnsi(top), "top border must contain ANSI styling — a plain unstyled border " +
|
|
120
|
+
"would indicate the rendering bypassed theme.fg('success', ...)");
|
|
121
|
+
});
|
|
122
|
+
it("plain Text status (the showStatus path) does NOT produce a bordered box", () => {
|
|
123
|
+
// Counter-test: this is what the bug looked like — a single dim Text
|
|
124
|
+
// with no surrounding border. If anyone ever "fixes" the showSuccess
|
|
125
|
+
// regression by also adding borders to showStatus, this test will
|
|
126
|
+
// surface the conflation.
|
|
127
|
+
const plain = new Text(theme.fg("dim", "Milestone M042 ready."), 1, 0);
|
|
128
|
+
const lines = plain.render(40);
|
|
129
|
+
const joined = lines.map(stripAnsi).join("\n");
|
|
130
|
+
assert.ok(!joined.includes("─"), "plain Text (showStatus path) must NOT contain border characters");
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=tool-card-cleanup-and-success-runtime.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-card-cleanup-and-success-runtime.test.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,0EAA0E;AAC1E,4EAA4E;AAC5E,sBAAsB;AACtB,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,wEAAwE;AACxE,0EAA0E;AAC1E,4EAA4E;AAC5E,sBAAsB;AAEtB,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,yEAAyE;AACzE,mEAAmE;AACnE,MAAM,CAAC,GAAG,EAAE;IACX,SAAS,CAAC,MAAM,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC;AAOH,SAAS,WAAW;IACnB,OAAO;QACN,WAAW,EAAE,CAAC;QACd,aAAa;YACZ,IAAI,CAAC,WAAW,EAAE,CAAC;QACpB,CAAC;KACD,CAAC;AACH,CAAC;AAED,2EAA2E;AAE3E,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC/D,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACrE,mEAAmE;QACnE,oEAAoE;QACpE,yCAAyC;QACzC,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,IAAI,sBAAsB,CACnC,WAAW,EACX,EAAE,IAAI,EAAE,YAAY,EAAE,EACtB,EAAE,EACF,SAAS,EACT,EAAW,CACX,CAAC;QACF,MAAM,QAAQ,GAAG,CAAC,CAA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AAE,CACR,UAAU,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAC7B,8CAA8C,CAC9C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QAC1E,6DAA6D;QAC7D,iEAAiE;QACjE,+DAA+D;QAC/D,iEAAiE;QACjE,mEAAmE;QACnE,iEAAiE;QACjE,iBAAiB;QACjB,MAAM,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC3B,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,EAAE,CACR,GAAG,KAAK,SAAS,CAAC,GAAG,CAAC,EACtB,iEAAiE;YAChE,gEAAgE,CACjE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QAClF,qEAAqE;QACrE,qEAAqE;QACrE,kEAAkE;QAClE,0BAA0B;QAC1B,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,CAAC,EAAE,CACR,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EACrB,iEAAiE,CACjE,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["// Runtime regression tests for the post-compaction tool-card cleanup and the\n// green-bordered success-notification rendering. Replaces the source-grep\n// `src/tests/tui-running-and-success-box.test.ts` that was deleted in #4875\n// (tracked as #4872).\n//\n// The previous tests asserted on identifier presence and method signature\n// shape via regex. A regression that routed `success` notifications through\n// `showStatus` (dim text) by accident would not have failed because the\n// `showSuccess` method would still exist and still match the regex. These\n// tests instead drive the components through the actual scenario and assert\n// on rendered output.\n\nimport assert from \"node:assert/strict\";\nimport { describe, it, before } from \"node:test\";\n\nimport { Container, Text } from \"@gsd/pi-tui\";\nimport stripAnsi from \"strip-ansi\";\n\nimport { initTheme, theme } from \"../theme/theme.js\";\nimport { DynamicBorder } from \"./dynamic-border.js\";\nimport { ToolExecutionComponent } from \"./tool-execution.js\";\n\n// Theme is a globalThis-shared singleton that throws if not initialized.\n// Initialize once before any test that exercises themed rendering.\nbefore(() => {\n\tinitTheme(\"dark\");\n});\n\ninterface MockTui {\n\trenderCount: number;\n\trequestRender(): void;\n}\n\nfunction makeMockTUI(): MockTui {\n\treturn {\n\t\trenderCount: 0,\n\t\trequestRender() {\n\t\t\tthis.renderCount++;\n\t\t},\n\t};\n}\n\n// ─── Bug 1: tool cards stuck in \"Running\" after compaction ──────────────\n\ndescribe(\"ToolExecutionComponent post-compaction cleanup\", () => {\n\tit(\"renders 'Running' status while the tool call has no result\", () => {\n\t\t// Baseline: a freshly-constructed component (mid-stream) must show\n\t\t// the running badge — this is the state we need to flip OUT of when\n\t\t// compaction removes the result message.\n\t\tconst ui = makeMockTUI();\n\t\tconst c = new ToolExecutionComponent(\n\t\t\t\"read_file\",\n\t\t\t{ path: \"/tmp/x.txt\" },\n\t\t\t{},\n\t\t\tundefined,\n\t\t\tui as never,\n\t\t);\n\t\tconst rendered = c.render(60).map(stripAnsi).join(\"\\n\");\n\t\tassert.ok(\n\t\t\trendered.includes(\"Running\"),\n\t\t\t\"freshly constructed component should render 'Running' badge\",\n\t\t);\n\t});\n\n\tit(\"markHistoricalNoResult flips a stuck tool card OUT of 'Running'\", () => {\n\t\t// Real bug: after session-history replay (post-compaction or session\n\t\t// switch), tool calls without matching tool_result messages stay in\n\t\t// isPartial = true forever. markHistoricalNoResult must produce a\n\t\t// rendered output that no longer reads \"Running\".\n\t\tconst ui = makeMockTUI();\n\t\tconst c = new ToolExecutionComponent(\n\t\t\t\"read_file\",\n\t\t\t{ path: \"/tmp/x.txt\" },\n\t\t\t{},\n\t\t\tundefined,\n\t\t\tui as never,\n\t\t);\n\n\t\tc.markHistoricalNoResult();\n\n\t\tconst rendered = c.render(60).map(stripAnsi).join(\"\\n\");\n\t\tassert.ok(\n\t\t\t!rendered.includes(\"Running\"),\n\t\t\t\"after markHistoricalNoResult, the tool card must NOT render 'Running' — got:\\n\" +\n\t\t\t\trendered,\n\t\t);\n\t\tassert.ok(\n\t\t\trendered.includes(\"Done\"),\n\t\t\t\"flipped card should render 'Done' status (no-result success)\",\n\t\t);\n\t});\n\n\tit(\"markHistoricalNoResult is idempotent when a real result already exists\", () => {\n\t\t// Late-arriving stream events must not clobber legitimate results.\n\t\t// We observe the no-clobber via behaviour: a card that completed\n\t\t// with a real result keeps its \"Done\" badge and content even if\n\t\t// markHistoricalNoResult fires again afterwards.\n\t\tconst ui = makeMockTUI();\n\t\tconst c = new ToolExecutionComponent(\n\t\t\t\"read_file\",\n\t\t\t{ path: \"/tmp/x.txt\" },\n\t\t\t{},\n\t\t\tundefined,\n\t\t\tui as never,\n\t\t);\n\n\t\t// Use the public completion path the runtime calls.\n\t\tc.updateResult(\n\t\t\t{\n\t\t\t\tcontent: [{ type: \"text\", text: \"real-result-payload\" }],\n\t\t\t\tisError: false,\n\t\t\t},\n\t\t\tfalse, // isPartial = false → \"Done\"\n\t\t);\n\n\t\tconst before = c.render(60).map(stripAnsi).join(\"\\n\");\n\t\tassert.ok(before.includes(\"Done\"), \"after complete(), card shows 'Done'\");\n\n\t\tc.markHistoricalNoResult(); // must early-return\n\t\tconst after = c.render(60).map(stripAnsi).join(\"\\n\");\n\t\tassert.equal(\n\t\t\tafter,\n\t\t\tbefore,\n\t\t\t\"markHistoricalNoResult must NOT mutate state when a real result is already present\",\n\t\t);\n\t});\n});\n\n// ─── Bug 2: success notifications render as a green bordered box ────────\n\ndescribe(\"Success-notification rendering — DynamicBorder + success theme\", () => {\n\t// We drive the same component composition that interactive-mode.showSuccess\n\t// builds (DynamicBorder + Text + DynamicBorder, all themed with\n\t// theme.fg(\"success\", …)) and assert on the rendered output, rather than\n\t// trying to instantiate the full InteractiveMode (which requires a real\n\t// session, bridge, and TUI runtime).\n\tfunction buildSuccessNotification(message: string): Container {\n\t\tconst c = new Container();\n\t\tconst successColor = (text: string) => theme.fg(\"success\", text);\n\t\tc.addChild(new DynamicBorder(successColor));\n\t\tc.addChild(new Text(theme.fg(\"success\", message), 1, 0));\n\t\tc.addChild(new DynamicBorder(successColor));\n\t\treturn c;\n\t}\n\n\tit(\"renders a top and bottom horizontal border framing the message\", () => {\n\t\tconst c = buildSuccessNotification(\"Milestone M042 ready.\");\n\t\tconst lines = c.render(40);\n\n\t\t// First and last lines should be horizontal-rule borders\n\t\t// (DynamicBorder renders a row of \"─\" characters).\n\t\tconst firstStripped = stripAnsi(lines[0]);\n\t\tconst lastStripped = stripAnsi(lines[lines.length - 1]);\n\n\t\tassert.ok(\n\t\t\tfirstStripped.includes(\"─\"),\n\t\t\t`first line should be a border (got: ${JSON.stringify(firstStripped)})`,\n\t\t);\n\t\tassert.ok(\n\t\t\tlastStripped.includes(\"─\"),\n\t\t\t`last line should be a border (got: ${JSON.stringify(lastStripped)})`,\n\t\t);\n\t\tassert.ok(\n\t\t\tlines.length >= 3,\n\t\t\t`success notification must have at least 3 lines (top border, message, bottom border) — got ${lines.length}`,\n\t\t);\n\t});\n\n\tit(\"the message text appears between the two borders\", () => {\n\t\tconst c = buildSuccessNotification(\"Milestone M042 ready.\");\n\t\tconst lines = c.render(40);\n\n\t\tconst messageRow = lines.findIndex((l) => stripAnsi(l).includes(\"Milestone M042 ready.\"));\n\t\tassert.ok(messageRow > 0, \"message must appear after the top border\");\n\t\tassert.ok(\n\t\t\tmessageRow < lines.length - 1,\n\t\t\t\"message must appear before the bottom border\",\n\t\t);\n\t});\n\n\tit(\"borders carry ANSI styling (not plain dim text like showStatus)\", () => {\n\t\t// Goodhart-resistant: if a regression routed success through\n\t\t// showStatus, the borders would be missing AND the rendered text\n\t\t// would be plain (or only dim-styled, not success-colored). We\n\t\t// observe the border lines carry ANSI escape codes — the literal\n\t\t// foreground color depends on the theme (which is system-dependent\n\t\t// in CI), so we don't pin a specific code but DO require styling\n\t\t// to be present.\n\t\tconst c = buildSuccessNotification(\"ok\");\n\t\tconst lines = c.render(40);\n\t\tconst top = lines[0];\n\t\tassert.ok(\n\t\t\ttop !== stripAnsi(top),\n\t\t\t\"top border must contain ANSI styling — a plain unstyled border \" +\n\t\t\t\t\"would indicate the rendering bypassed theme.fg('success', ...)\",\n\t\t);\n\t});\n\n\tit(\"plain Text status (the showStatus path) does NOT produce a bordered box\", () => {\n\t\t// Counter-test: this is what the bug looked like — a single dim Text\n\t\t// with no surrounding border. If anyone ever \"fixes\" the showSuccess\n\t\t// regression by also adding borders to showStatus, this test will\n\t\t// surface the conflation.\n\t\tconst plain = new Text(theme.fg(\"dim\", \"Milestone M042 ready.\"), 1, 0);\n\t\tconst lines = plain.render(40);\n\t\tconst joined = lines.map(stripAnsi).join(\"\\n\");\n\t\tassert.ok(\n\t\t\t!joined.includes(\"─\"),\n\t\t\t\"plain Text (showStatus path) must NOT contain border characters\",\n\t\t);\n\t});\n});\n"]}
|
|
@@ -108,7 +108,7 @@ export function setupEditorSubmitHandler(host) {
|
|
|
108
108
|
// submitPromptsDirectly is false — still dispatch via session.prompt so user input
|
|
109
109
|
// is not silently discarded.
|
|
110
110
|
try {
|
|
111
|
-
await host.session.prompt(text);
|
|
111
|
+
await host.session.prompt(text, { images });
|
|
112
112
|
}
|
|
113
113
|
catch (error) {
|
|
114
114
|
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-controller.js","sourceRoot":"","sources":["../../../../src/modes/interactive/controllers/input-controller.ts"],"names":[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,CAAC,CAAC;IACvC,mEAAmE;IACnE,wFAAwF;IACxF,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { ImageContent } from \"@gsd/pi-ai\";\nimport { dispatchSlashCommand } from \"../slash-command-handlers.js\";\nimport type { InteractiveModeStateHost } from \"../interactive-mode-state.js\";\nimport type { ContextualTips } from \"../../../core/contextual-tips.js\";\n\n/**\n * Consume and clear any pending pasted images from the host.\n * Returns undefined if there are no pending images.\n */\nfunction consumePendingImages(host: InteractiveModeStateHost): ImageContent[] | undefined {\n\tif (host.pendingImages.length === 0) return undefined;\n\tconst images = [...host.pendingImages];\n\thost.pendingImages.length = 0;\n\treturn images;\n}\n\nexport function setupEditorSubmitHandler(host: InteractiveModeStateHost & {\n\tgetSlashCommandContext: () => any;\n\thandleBashCommand: (command: string, excludeFromContext?: boolean) => Promise<void>;\n\tshowWarning: (message: string) => void;\n\tshowError: (message: string) => void;\n\tshowTip: (message: string) => void;\n\tupdateEditorBorderColor: () => void;\n\tisExtensionCommand: (text: string) => boolean;\n\tisKnownSlashCommand: (text: string) => boolean;\n\tqueueCompactionMessage: (text: string, mode: \"steer\" | \"followUp\") => void;\n\tupdatePendingMessagesDisplay: () => void;\n\tflushPendingBashComponents: () => void;\n\tcontextualTips: ContextualTips;\n\tgetContextPercent: () => number | undefined;\n\toptions?: { submitPromptsDirectly?: boolean };\n}): void {\n\thost.defaultEditor.onSubmit = async (text: string) => {\n\t\ttext = text.trim();\n\t\tif (!text) return;\n\n\t\tif (text.startsWith(\"/\") && !looksLikeFilePath(text)) {\n\t\t\tconst handled = await dispatchSlashCommand(text, host.getSlashCommandContext());\n\t\t\tif (handled) {\n\t\t\t\thost.editor.setText(\"\");\n\t\t\t\tconsumePendingImages(host); // discard images on slash command\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!host.isKnownSlashCommand(text)) {\n\t\t\t\tconst command = text.split(/\\s/)[0];\n\t\t\t\thost.showError(`Unknown command: ${command}. Use slash autocomplete to see available commands.`);\n\t\t\t\thost.editor.setText(\"\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (text.startsWith(\"!\")) {\n\t\t\tconst isExcluded = text.startsWith(\"!!\");\n\t\t\tconst command = isExcluded ? text.slice(2).trim() : text.slice(1).trim();\n\t\t\tif (command) {\n\t\t\t\tif (host.session.isBashRunning) {\n\t\t\t\t\thost.showWarning(\"A bash command is already running. Press Esc to cancel it first.\");\n\t\t\t\t\thost.editor.setText(text);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Track included bash commands for double-bang tip\n\t\t\t\tif (!isExcluded) {\n\t\t\t\t\thost.contextualTips.recordBashIncluded();\n\t\t\t\t}\n\t\t\t\thost.editor.addToHistory?.(text);\n\t\t\t\tawait host.handleBashCommand(command, isExcluded);\n\t\t\t\thost.isBashMode = false;\n\t\t\t\thost.updateEditorBorderColor();\n\t\t\t\tconsumePendingImages(host); // discard images on bash command\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Consume pending images for prompt submissions\n\t\tconst images = consumePendingImages(host);\n\n\t\t// Evaluate contextual tips before sending to agent\n\t\tconst tip = host.contextualTips.evaluate({\n\t\t\tinput: text,\n\t\t\tisStreaming: host.session.isStreaming,\n\t\t\tthinkingLevel: host.session.thinkingLevel,\n\t\t\tcontextPercent: host.getContextPercent(),\n\t\t});\n\t\tif (tip) {\n\t\t\thost.showTip(tip);\n\t\t}\n\n\t\tif (host.session.isCompacting) {\n\t\t\tif (host.isExtensionCommand(text)) {\n\t\t\t\thost.editor.addToHistory?.(text);\n\t\t\t\thost.editor.setText(\"\");\n\t\t\t\ttry {\n\t\t\t\t\tawait host.session.prompt(text, { images });\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tconst errorMessage = error instanceof Error ? error.message : \"Unknown error occurred\";\n\t\t\t\t\thost.showError(errorMessage);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thost.queueCompactionMessage(text, \"steer\");\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (host.session.isStreaming) {\n\t\t\thost.editor.addToHistory?.(text);\n\t\t\thost.editor.setText(\"\");\n\t\t\tawait host.session.prompt(text, { streamingBehavior: \"steer\", images });\n\t\t\thost.updatePendingMessagesDisplay();\n\t\t\thost.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\thost.flushPendingBashComponents();\n\n\t\tif (host.onInputCallback) {\n\t\t\thost.onInputCallback(text);\n\t\t\thost.editor.addToHistory?.(text);\n\t\t\treturn;\n\t\t}\n\n\t\tif (host.options?.submitPromptsDirectly) {\n\t\t\thost.editor.addToHistory?.(text);\n\t\t\ttry {\n\t\t\t\tawait host.session.prompt(text, { images });\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst errorMessage = error instanceof Error ? error.message : \"Unknown error occurred\";\n\t\t\t\thost.showError(errorMessage);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\thost.editor.addToHistory?.(text);\n\t\t// submitPromptsDirectly is false — still dispatch via session.prompt so user input\n\t\t// is not silently discarded.\n\t\ttry {\n\t\t\tawait host.session.prompt(text);\n\t\t} catch (error: unknown) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : \"Unknown error occurred\";\n\t\t\thost.showError(errorMessage);\n\t\t}\n\t};\n}\n\n/**\n * Distinguish absolute file paths from slash commands (#3478).\n * Drag-and-drop inserts paths like \"/Users/name/Desktop/file.png\" which\n * should be treated as plain text input, not a /Users command.\n *\n * Heuristic: a slash command is a single token like \"/help\" or \"/gsd auto\".\n * File paths have a second \"/\" within the first token (e.g., \"/Users/...\").\n */\nfunction looksLikeFilePath(text: string): boolean {\n\tconst firstToken = text.split(/\\s/)[0];\n\t// Slash commands: /help, /gsd, /commit — single \"/\" at start only.\n\t// File paths: /Users/name/file, /home/user/file, /tmp/x — contain \"/\" after position 0.\n\treturn firstToken.indexOf(\"/\", 1) !== -1;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"input-controller.js","sourceRoot":"","sources":["../../../../src/modes/interactive/controllers/input-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAIpE;;;GAGG;AACH,SAAS,oBAAoB,CAAC,IAA8B;IAC3D,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACtD,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9B,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAexC;IACA,IAAI,CAAC,aAAa,CAAC,QAAQ,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;QACpD,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;YACtD,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC;YAChF,IAAI,OAAO,EAAE,CAAC;gBACb,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBACxB,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,kCAAkC;gBAC9D,OAAO;YACR,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpC,IAAI,CAAC,SAAS,CAAC,oBAAoB,OAAO,qDAAqD,CAAC,CAAC;gBACjG,I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H,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACtC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,mEAAmE;IACnE,wFAAwF;IACxF,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { ImageContent } from \"@gsd/pi-ai\";\nimport { dispatchSlashCommand } from \"../slash-command-handlers.js\";\nimport type { InteractiveModeStateHost } from \"../interactive-mode-state.js\";\nimport type { ContextualTips } from \"../../../core/contextual-tips.js\";\n\n/**\n * Consume and clear any pending pasted images from the host.\n * Returns undefined if there are no pending images.\n */\nfunction consumePendingImages(host: InteractiveModeStateHost): ImageContent[] | undefined {\n\tif (host.pendingImages.length === 0) return undefined;\n\tconst images = [...host.pendingImages];\n\thost.pendingImages.length = 0;\n\treturn images;\n}\n\nexport function setupEditorSubmitHandler(host: InteractiveModeStateHost & {\n\tgetSlashCommandContext: () => any;\n\thandleBashCommand: (command: string, excludeFromContext?: boolean) => Promise<void>;\n\tshowWarning: (message: string) => void;\n\tshowError: (message: string) => void;\n\tshowTip: (message: string) => void;\n\tupdateEditorBorderColor: () => void;\n\tisExtensionCommand: (text: string) => boolean;\n\tisKnownSlashCommand: (text: string) => boolean;\n\tqueueCompactionMessage: (text: string, mode: \"steer\" | \"followUp\") => void;\n\tupdatePendingMessagesDisplay: () => void;\n\tflushPendingBashComponents: () => void;\n\tcontextualTips: ContextualTips;\n\tgetContextPercent: () => number | undefined;\n\toptions?: { submitPromptsDirectly?: boolean };\n}): void {\n\thost.defaultEditor.onSubmit = async (text: string) => {\n\t\ttext = text.trim();\n\t\tif (!text) return;\n\n\t\tif (text.startsWith(\"/\") && !looksLikeFilePath(text)) {\n\t\t\tconst handled = await dispatchSlashCommand(text, host.getSlashCommandContext());\n\t\t\tif (handled) {\n\t\t\t\thost.editor.setText(\"\");\n\t\t\t\tconsumePendingImages(host); // discard images on slash command\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!host.isKnownSlashCommand(text)) {\n\t\t\t\tconst command = text.split(/\\s/)[0];\n\t\t\t\thost.showError(`Unknown command: ${command}. Use slash autocomplete to see available commands.`);\n\t\t\t\thost.editor.setText(\"\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (text.startsWith(\"!\")) {\n\t\t\tconst isExcluded = text.startsWith(\"!!\");\n\t\t\tconst command = isExcluded ? text.slice(2).trim() : text.slice(1).trim();\n\t\t\tif (command) {\n\t\t\t\tif (host.session.isBashRunning) {\n\t\t\t\t\thost.showWarning(\"A bash command is already running. Press Esc to cancel it first.\");\n\t\t\t\t\thost.editor.setText(text);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Track included bash commands for double-bang tip\n\t\t\t\tif (!isExcluded) {\n\t\t\t\t\thost.contextualTips.recordBashIncluded();\n\t\t\t\t}\n\t\t\t\thost.editor.addToHistory?.(text);\n\t\t\t\tawait host.handleBashCommand(command, isExcluded);\n\t\t\t\thost.isBashMode = false;\n\t\t\t\thost.updateEditorBorderColor();\n\t\t\t\tconsumePendingImages(host); // discard images on bash command\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Consume pending images for prompt submissions\n\t\tconst images = consumePendingImages(host);\n\n\t\t// Evaluate contextual tips before sending to agent\n\t\tconst tip = host.contextualTips.evaluate({\n\t\t\tinput: text,\n\t\t\tisStreaming: host.session.isStreaming,\n\t\t\tthinkingLevel: host.session.thinkingLevel,\n\t\t\tcontextPercent: host.getContextPercent(),\n\t\t});\n\t\tif (tip) {\n\t\t\thost.showTip(tip);\n\t\t}\n\n\t\tif (host.session.isCompacting) {\n\t\t\tif (host.isExtensionCommand(text)) {\n\t\t\t\thost.editor.addToHistory?.(text);\n\t\t\t\thost.editor.setText(\"\");\n\t\t\t\ttry {\n\t\t\t\t\tawait host.session.prompt(text, { images });\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tconst errorMessage = error instanceof Error ? error.message : \"Unknown error occurred\";\n\t\t\t\t\thost.showError(errorMessage);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thost.queueCompactionMessage(text, \"steer\");\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (host.session.isStreaming) {\n\t\t\thost.editor.addToHistory?.(text);\n\t\t\thost.editor.setText(\"\");\n\t\t\tawait host.session.prompt(text, { streamingBehavior: \"steer\", images });\n\t\t\thost.updatePendingMessagesDisplay();\n\t\t\thost.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\thost.flushPendingBashComponents();\n\n\t\tif (host.onInputCallback) {\n\t\t\thost.onInputCallback(text);\n\t\t\thost.editor.addToHistory?.(text);\n\t\t\treturn;\n\t\t}\n\n\t\tif (host.options?.submitPromptsDirectly) {\n\t\t\thost.editor.addToHistory?.(text);\n\t\t\ttry {\n\t\t\t\tawait host.session.prompt(text, { images });\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst errorMessage = error instanceof Error ? error.message : \"Unknown error occurred\";\n\t\t\t\thost.showError(errorMessage);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\thost.editor.addToHistory?.(text);\n\t\t// submitPromptsDirectly is false — still dispatch via session.prompt so user input\n\t\t// is not silently discarded.\n\t\ttry {\n\t\t\tawait host.session.prompt(text, { images });\n\t\t} catch (error: unknown) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : \"Unknown error occurred\";\n\t\t\thost.showError(errorMessage);\n\t\t}\n\t};\n}\n\n/**\n * Distinguish absolute file paths from slash commands (#3478).\n * Drag-and-drop inserts paths like \"/Users/name/Desktop/file.png\" which\n * should be treated as plain text input, not a /Users command.\n *\n * Heuristic: a slash command is a single token like \"/help\" or \"/gsd auto\".\n * File paths have a second \"/\" within the first token (e.g., \"/Users/...\").\n */\nfunction looksLikeFilePath(text: string): boolean {\n\tconst firstToken = text.split(/\\s/)[0];\n\t// Slash commands: /help, /gsd, /commit — single \"/\" at start only.\n\t// File paths: /Users/name/file, /home/user/file, /tmp/x — contain \"/\" after position 0.\n\treturn firstToken.indexOf(\"/\", 1) !== -1;\n}\n"]}
|
package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js
CHANGED
|
@@ -132,6 +132,7 @@ function getSlashCommandName(text) {
|
|
|
132
132
|
}
|
|
133
133
|
function createHost(options = {}) {
|
|
134
134
|
const prompted = [];
|
|
135
|
+
const promptOptions = [];
|
|
135
136
|
const errors = [];
|
|
136
137
|
const warnings = [];
|
|
137
138
|
const tips = [];
|
|
@@ -157,8 +158,9 @@ function createHost(options = {}) {
|
|
|
157
158
|
isBashRunning: false,
|
|
158
159
|
isCompacting: false,
|
|
159
160
|
isStreaming: false,
|
|
160
|
-
prompt: async (text) => {
|
|
161
|
+
prompt: async (text, options) => {
|
|
161
162
|
prompted.push(text);
|
|
163
|
+
promptOptions.push(options);
|
|
162
164
|
},
|
|
163
165
|
},
|
|
164
166
|
ui: {
|
|
@@ -204,6 +206,7 @@ function createHost(options = {}) {
|
|
|
204
206
|
return {
|
|
205
207
|
host: host,
|
|
206
208
|
prompted,
|
|
209
|
+
promptOptions,
|
|
207
210
|
errors,
|
|
208
211
|
warnings,
|
|
209
212
|
tips,
|
|
@@ -212,6 +215,16 @@ function createHost(options = {}) {
|
|
|
212
215
|
getSettingsOpened: () => settingsOpened,
|
|
213
216
|
};
|
|
214
217
|
}
|
|
218
|
+
test("input-controller: regular prompt submit preserves pending images", async () => {
|
|
219
|
+
const { host, prompted, promptOptions } = createHost();
|
|
220
|
+
host.pendingImages.push({ ...TEST_IMAGE });
|
|
221
|
+
await host.defaultEditor.onSubmit("describe this image [Image #1]");
|
|
222
|
+
assert.deepEqual(prompted, ["describe this image [Image #1]"]);
|
|
223
|
+
assert.equal(promptOptions[0]?.images?.length, 1);
|
|
224
|
+
assert.equal(promptOptions[0].images[0].mimeType, "image/png");
|
|
225
|
+
assert.equal(promptOptions[0].images[0].data, TEST_IMAGE.data);
|
|
226
|
+
assert.equal(host.pendingImages.length, 0);
|
|
227
|
+
});
|
|
215
228
|
test("input-controller: built-in slash commands stay in TUI dispatch", async () => {
|
|
216
229
|
const { host, prompted, errors, getSettingsOpened, getEditorText } = createHost();
|
|
217
230
|
await host.defaultEditor.onSubmit("/settings");
|
package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-controller.test.js","sourceRoot":"","sources":["../../../../src/modes/interactive/controllers/input-controller.test.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,4DAA4D;AAE5D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAIlE,+FAA+F;AAC/F,SAAS,cAAc;IACtB,MAAM,WAAW,GAA2C,EAAE,CAAC;IAC/D,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,IAAI,UAAU,GAAG,EAAE,CAAC;IAEpB,MAAM,IAAI,GAAG;QACZ,aAAa,EAAE;YACd,QAAQ,EAAE,SAA0D;YACpE,YAAY,EAAE,CAAC,IAAY,EAAE,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC5D,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,GAAG,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;YACjD,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU;SACzB;QACD,MAAM,EAAE;YACP,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,GAAG,UAAU,GAAG,IAAI,CAAC,CAAC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,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IAEhD,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAC;IAEnE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,sDAAsD,CAAC,CAAC;IACrF,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,+BAA+B,CAAC,EAAE,2CAA2C,CAAC,CAAC;AAC5G,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wEAAwE,EAAE,KAAK,IAAI,EAAE;IACzF,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IAEhD,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAExD,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC7B,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC","sourcesContent":["// GSD2 — Tests for input-controller image pasting behavior\n// Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>\n\nimport { describe, it, beforeEach } from \"node:test\";\nimport assert from \"node:assert/strict\";\nimport test from \"node:test\";\nimport { setupEditorSubmitHandler } from \"./input-controller.js\";\nimport { ContextualTips } from \"../../../core/contextual-tips.js\";\nimport type { InteractiveModeStateHost } from \"../interactive-mode-state.js\";\nimport type { ImageContent } from \"@gsd/pi-ai\";\n\n/** Minimal mock host satisfying InteractiveModeStateHost + setupEditorSubmitHandler extras. */\nfunction createMockHost() {\n\tconst promptCalls: Array<{ text: string; options?: any }> = [];\n\tconst historyCalls: string[] = [];\n\tlet editorText = \"\";\n\n\tconst host = {\n\t\tdefaultEditor: {\n\t\t\tonSubmit: undefined as ((text: string) => Promise<void>) | undefined,\n\t\t\taddToHistory: (text: string) => { historyCalls.push(text); },\n\t\t\tsetText: (text: string) => { editorText = text; },\n\t\t\tgetText: () => editorText,\n\t\t},\n\t\teditor: {\n\t\t\tsetText: (text: string) => { editorText = text; },\n\t\t\tgetText: () => editorText,\n\t\t\taddToHistory: (text: string) => { historyCalls.push(text); },\n\t\t},\n\t\tsession: {\n\t\t\tisStreaming: false,\n\t\t\tisCompacting: false,\n\t\t\tisBashRunning: false,\n\t\t\tthinkingLevel: undefined,\n\t\t\tprompt: async (text: string, options?: any) => { promptCalls.push({ text, options }); },\n\t\t},\n\t\tui: { requestRender: () => {} },\n\t\tfooter: {},\n\t\tkeybindings: {},\n\t\tstatusContainer: {},\n\t\tchatContainer: {},\n\t\tpinnedMessageContainer: {},\n\t\tsettingsManager: {},\n\t\tpendingTools: new Map(),\n\t\ttoolOutputExpanded: false,\n\t\thideThinkingBlock: false,\n\t\tisBashMode: false,\n\t\tonInputCallback: undefined,\n\t\tisInitialized: true,\n\t\tloadingAnimation: undefined,\n\t\tpendingWorkingMessage: undefined,\n\t\tdefaultWorkingMessage: \"Working...\",\n\t\tstreamingComponent: undefined,\n\t\tstreamingMessage: undefined,\n\t\tretryEscapeHandler: undefined,\n\t\tretryLoader: undefined,\n\t\tautoCompactionLoader: undefined,\n\t\tautoCompactionEscapeHandler: undefined,\n\t\tcompactionQueuedMessages: [] as Array<{ text: string; mode: \"steer\" | \"followUp\" }>,\n\t\textensionSelector: undefined,\n\t\textensionInput: undefined,\n\t\textensionEditor: undefined,\n\t\teditorContainer: {},\n\t\tkeybindingsManager: undefined,\n\t\tpendingImages: [] as ImageContent[],\n\n\t\t// Extra methods required by setupEditorSubmitHandler\n\t\tgetSlashCommandContext: () => ({}),\n\t\thandleBashCommand: async (_command: string, _excludeFromContext?: boolean) => {},\n\t\tshowWarning: (_message: string) => {},\n\t\tshowError: (_message: string) => {},\n\t\tshowTip: (_message: string) => {},\n\t\tupdateEditorBorderColor: () => {},\n\t\tisExtensionCommand: (_text: string) => false,\n\t\tisKnownSlashCommand: (_text: string) => false,\n\t\tqueueCompactionMessage: (_text: string, _mode: \"steer\" | \"followUp\") => {},\n\t\tupdatePendingMessagesDisplay: () => {},\n\t\tflushPendingBashComponents: () => {},\n\t\tcontextualTips: new ContextualTips(),\n\t\tgetContextPercent: () => undefined,\n\t\toptions: { submitPromptsDirectly: true },\n\t} satisfies InteractiveModeStateHost & Parameters<typeof setupEditorSubmitHandler>[0];\n\n\treturn { host, promptCalls, historyCalls };\n}\n\nconst TEST_IMAGE: ImageContent = {\n\ttype: \"image\",\n\tdata: \"iVBORw0KGgo=\",\n\tmimeType: \"image/png\",\n};\n\ndescribe(\"input-controller pending images\", () => {\n\tlet host: ReturnType<typeof createMockHost>[\"host\"];\n\tlet promptCalls: ReturnType<typeof createMockHost>[\"promptCalls\"];\n\n\tbeforeEach(() => {\n\t\tconst mock = createMockHost();\n\t\thost = mock.host;\n\t\tpromptCalls = mock.promptCalls;\n\t\tsetupEditorSubmitHandler(host);\n\t});\n\n\tit(\"passes pending images to session.prompt on submit\", async () => {\n\t\thost.pendingImages.push({ ...TEST_IMAGE });\n\t\tawait host.defaultEditor.onSubmit!(\"describe this image\");\n\n\t\tassert.equal(promptCalls.length, 1);\n\t\tassert.equal(promptCalls[0].text, \"describe this image\");\n\t\tassert.ok(promptCalls[0].options?.images);\n\t\tassert.equal(promptCalls[0].options.images.length, 1);\n\t\tassert.equal(promptCalls[0].options.images[0].mimeType, \"image/png\");\n\t});\n\n\tit(\"clears pending images after submit\", async () => {\n\t\thost.pendingImages.push({ ...TEST_IMAGE });\n\t\tawait host.defaultEditor.onSubmit!(\"describe this image\");\n\n\t\tassert.equal(host.pendingImages.length, 0);\n\t});\n\n\tit(\"passes undefined images when no images are pending\", async () => {\n\t\tawait host.defaultEditor.onSubmit!(\"hello\");\n\n\t\tassert.equal(promptCalls.length, 1);\n\t\tassert.equal(promptCalls[0].options?.images, undefined);\n\t});\n\n\tit(\"passes multiple images in order\", async () => {\n\t\tconst img1: ImageContent = { type: \"image\", data: \"aaa=\", mimeType: \"image/png\" };\n\t\tconst img2: ImageContent = { type: \"image\", data: \"bbb=\", mimeType: \"image/jpeg\" };\n\t\thost.pendingImages.push(img1, img2);\n\n\t\tawait host.defaultEditor.onSubmit!(\"describe these images\");\n\n\t\tassert.equal(promptCalls[0].options.images.length, 2);\n\t\tassert.equal(promptCalls[0].options.images[0].data, \"aaa=\");\n\t\tassert.equal(promptCalls[0].options.images[1].data, \"bbb=\");\n\t});\n\n\tit(\"discards pending images on bash command\", async () => {\n\t\thost.pendingImages.push({ ...TEST_IMAGE });\n\t\tawait host.defaultEditor.onSubmit!(\"! ls -la\");\n\n\t\tassert.equal(host.pendingImages.length, 0);\n\t\tassert.equal(promptCalls.length, 0); // bash commands don't go through prompt\n\t});\n});\n\ntype HostOptions = {\n\tknownSlashCommands?: string[];\n};\n\nfunction getSlashCommandName(text: string): string {\n\tconst trimmed = text.trim();\n\tconst spaceIndex = trimmed.indexOf(\" \");\n\treturn spaceIndex === -1 ? trimmed.slice(1) : trimmed.slice(1, spaceIndex);\n}\n\nfunction createHost(options: HostOptions = {}) {\n\tconst prompted: string[] = [];\n\tconst errors: string[] = [];\n\tconst warnings: string[] = [];\n\tconst tips: string[] = [];\n\tconst history: string[] = [];\n\tconst knownSlashCommands = new Set(options.knownSlashCommands ?? []);\n\tlet editorText = \"\";\n\tlet settingsOpened = 0;\n\n\tconst editor = {\n\t\tsetText(text: string) {\n\t\t\teditorText = text;\n\t\t},\n\t\tgetText() {\n\t\t\treturn editorText;\n\t\t},\n\t\taddToHistory(text: string) {\n\t\t\thistory.push(text);\n\t\t},\n\t};\n\n\tconst host = {\n\t\tdefaultEditor: editor as typeof editor & { onSubmit?: (text: string) => Promise<void> },\n\t\teditor,\n\t\tsession: {\n\t\t\tisBashRunning: false,\n\t\t\tisCompacting: false,\n\t\t\tisStreaming: false,\n\t\t\tprompt: async (text: string) => {\n\t\t\t\tprompted.push(text);\n\t\t\t},\n\t\t},\n\t\tui: {\n\t\t\trequestRender() {},\n\t\t},\n\t\tpendingImages: [] as ImageContent[],\n\t\tgetSlashCommandContext: () => ({\n\t\t\tshowSettingsSelector: () => {\n\t\t\t\tsettingsOpened += 1;\n\t\t\t},\n\t\t}),\n\t\thandleBashCommand: async () => {},\n\t\tshowWarning(message: string) {\n\t\t\twarnings.push(message);\n\t\t},\n\t\tshowError(message: string) {\n\t\t\terrors.push(message);\n\t\t},\n\t\tshowTip(message: string) {\n\t\t\ttips.push(message);\n\t\t},\n\t\tupdateEditorBorderColor() {},\n\t\tisExtensionCommand() {\n\t\t\treturn false;\n\t\t},\n\t\tisKnownSlashCommand(text: string) {\n\t\t\treturn knownSlashCommands.has(getSlashCommandName(text));\n\t\t},\n\t\tqueueCompactionMessage() {},\n\t\tupdatePendingMessagesDisplay() {},\n\t\tflushPendingBashComponents() {},\n\t\tcontextualTips: {\n\t\t\trecordBashIncluded() {},\n\t\t\tevaluate() {\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t},\n\t\tgetContextPercent() {\n\t\t\treturn undefined;\n\t\t},\n\t};\n\n\tsetupEditorSubmitHandler(host as any);\n\n\treturn {\n\t\thost: host as typeof host & { defaultEditor: typeof editor & { onSubmit: (text: string) => Promise<void> } },\n\t\tprompted,\n\t\terrors,\n\t\twarnings,\n\t\ttips,\n\t\thistory,\n\t\tgetEditorText: () => editorText,\n\t\tgetSettingsOpened: () => settingsOpened,\n\t};\n}\n\ntest(\"input-controller: built-in slash commands stay in TUI dispatch\", async () => {\n\tconst { host, prompted, errors, getSettingsOpened, getEditorText } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/settings\");\n\n\tassert.equal(getSettingsOpened(), 1, \"built-in /settings should open the settings selector\");\n\tassert.deepEqual(prompted, [], \"built-in slash commands should not reach session.prompt\");\n\tassert.deepEqual(errors, [], \"built-in slash commands should not show errors\");\n\tassert.equal(getEditorText(), \"\", \"built-in slash commands should clear the editor after handling\");\n});\n\ntest(\"input-controller: extension slash commands fall through to session.prompt\", async () => {\n\tconst { host, prompted, errors, history } = createHost({ knownSlashCommands: [\"gsd\"] });\n\n\tawait host.defaultEditor.onSubmit(\"/gsd help\");\n\n\tassert.deepEqual(prompted, [\"/gsd help\"], \"known extension slash commands should reach session.prompt\");\n\tassert.deepEqual(errors, [], \"known extension slash commands should not show unknown-command errors\");\n\tassert.deepEqual(history, [\"/gsd help\"], \"known extension slash commands should still be added to history\");\n});\n\ntest(\"input-controller: prompt template slash commands fall through to session.prompt\", async () => {\n\tconst { host, prompted, errors } = createHost({ knownSlashCommands: [\"daily\"] });\n\n\tawait host.defaultEditor.onSubmit(\"/daily focus area\");\n\n\tassert.deepEqual(prompted, [\"/daily focus area\"]);\n\tassert.deepEqual(errors, []);\n});\n\ntest(\"input-controller: skill slash commands fall through to session.prompt\", async () => {\n\tconst { host, prompted, errors } = createHost({ knownSlashCommands: [\"skill:create-skill\"] });\n\n\tawait host.defaultEditor.onSubmit(\"/skill:create-skill routing bug\");\n\n\tassert.deepEqual(prompted, [\"/skill:create-skill routing bug\"]);\n\tassert.deepEqual(errors, []);\n});\n\ntest(\"input-controller: disabled skill slash commands stay unknown\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/skill:create-skill routing bug\");\n\n\tassert.deepEqual(prompted, []);\n\tassert.deepEqual(errors, [\"Unknown command: /skill:create-skill. Use slash autocomplete to see available commands.\"]);\n});\n\ntest(\"input-controller: /export prefix does not swallow unrelated slash commands\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/exportfoo\");\n\n\tassert.deepEqual(prompted, []);\n\tassert.deepEqual(errors, [\"Unknown command: /exportfoo. Use slash autocomplete to see available commands.\"]);\n});\n\ntest(\"input-controller: truly unknown slash commands stop before session.prompt\", async () => {\n\tconst { host, prompted, errors, getEditorText } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/definitely-not-a-command\");\n\n\tassert.deepEqual(prompted, [], \"unknown slash commands should not reach session.prompt\");\n\tassert.deepEqual(\n\t\terrors,\n\t\t[\"Unknown command: /definitely-not-a-command. Use slash autocomplete to see available commands.\"],\n\t);\n\tassert.equal(getEditorText(), \"\", \"unknown slash commands should clear the editor after showing the error\");\n});\n\ntest(\"input-controller: absolute file paths are not treated as slash commands (#3478)\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/Users/name/Desktop/screenshot.png\");\n\n\tassert.deepEqual(errors, [], \"file paths should not trigger unknown command error\");\n\tassert.deepEqual(prompted, [\"/Users/name/Desktop/screenshot.png\"], \"file paths should be sent as plain input\");\n});\n\ntest(\"input-controller: Linux absolute paths are not treated as slash commands (#3478)\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/home/user/documents/file.txt\");\n\n\tassert.deepEqual(errors, [], \"Linux paths should not trigger unknown command error\");\n\tassert.deepEqual(prompted, [\"/home/user/documents/file.txt\"], \"Linux paths should be sent as plain input\");\n});\n\ntest(\"input-controller: /tmp paths are not treated as slash commands (#3478)\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/tmp/some-file.log\");\n\n\tassert.deepEqual(errors, []);\n\tassert.deepEqual(prompted, [\"/tmp/some-file.log\"]);\n});\n"]}
|
|
1
|
+
{"version":3,"file":"input-controller.test.js","sourceRoot":"","sources":["../../../../src/modes/interactive/controllers/input-controller.test.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,4DAA4D;AAE5D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAIlE,+FAA+F;AAC/F,SAAS,cAAc;IACtB,MAAM,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pF,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,oCAAoC,CAAC,EAAE,0CAA0C,CAAC,CAAC;AAChH,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kFAAkF,EAAE,KAAK,IAAI,EAAE;IACnG,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IAEhD,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAC;IAEnE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,sDAAsD,CAAC,CAAC;IACrF,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,+BAA+B,CAAC,EAAE,2CAA2C,CAAC,CAAC;AAC5G,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wEAAwE,EAAE,KAAK,IAAI,EAAE;IACzF,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IAEhD,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAExD,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC7B,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC","sourcesContent":["// GSD2 — Tests for input-controller image pasting behavior\n// Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>\n\nimport { describe, it, beforeEach } from \"node:test\";\nimport assert from \"node:assert/strict\";\nimport test from \"node:test\";\nimport { setupEditorSubmitHandler } from \"./input-controller.js\";\nimport { ContextualTips } from \"../../../core/contextual-tips.js\";\nimport type { InteractiveModeStateHost } from \"../interactive-mode-state.js\";\nimport type { ImageContent } from \"@gsd/pi-ai\";\n\n/** Minimal mock host satisfying InteractiveModeStateHost + setupEditorSubmitHandler extras. */\nfunction createMockHost() {\n\tconst promptCalls: Array<{ text: string; options?: any }> = [];\n\tconst historyCalls: string[] = [];\n\tlet editorText = \"\";\n\n\tconst host = {\n\t\tdefaultEditor: {\n\t\t\tonSubmit: undefined as ((text: string) => Promise<void>) | undefined,\n\t\t\taddToHistory: (text: string) => { historyCalls.push(text); },\n\t\t\tsetText: (text: string) => { editorText = text; },\n\t\t\tgetText: () => editorText,\n\t\t},\n\t\teditor: {\n\t\t\tsetText: (text: string) => { editorText = text; },\n\t\t\tgetText: () => editorText,\n\t\t\taddToHistory: (text: string) => { historyCalls.push(text); },\n\t\t},\n\t\tsession: {\n\t\t\tisStreaming: false,\n\t\t\tisCompacting: false,\n\t\t\tisBashRunning: false,\n\t\t\tthinkingLevel: undefined,\n\t\t\tprompt: async (text: string, options?: any) => { promptCalls.push({ text, options }); },\n\t\t},\n\t\tui: { requestRender: () => {} },\n\t\tfooter: {},\n\t\tkeybindings: {},\n\t\tstatusContainer: {},\n\t\tchatContainer: {},\n\t\tpinnedMessageContainer: {},\n\t\tsettingsManager: {},\n\t\tpendingTools: new Map(),\n\t\ttoolOutputExpanded: false,\n\t\thideThinkingBlock: false,\n\t\tisBashMode: false,\n\t\tonInputCallback: undefined,\n\t\tisInitialized: true,\n\t\tloadingAnimation: undefined,\n\t\tpendingWorkingMessage: undefined,\n\t\tdefaultWorkingMessage: \"Working...\",\n\t\tstreamingComponent: undefined,\n\t\tstreamingMessage: undefined,\n\t\tretryEscapeHandler: undefined,\n\t\tretryLoader: undefined,\n\t\tautoCompactionLoader: undefined,\n\t\tautoCompactionEscapeHandler: undefined,\n\t\tcompactionQueuedMessages: [] as Array<{ text: string; mode: \"steer\" | \"followUp\" }>,\n\t\textensionSelector: undefined,\n\t\textensionInput: undefined,\n\t\textensionEditor: undefined,\n\t\teditorContainer: {},\n\t\tkeybindingsManager: undefined,\n\t\tpendingImages: [] as ImageContent[],\n\n\t\t// Extra methods required by setupEditorSubmitHandler\n\t\tgetSlashCommandContext: () => ({}),\n\t\thandleBashCommand: async (_command: string, _excludeFromContext?: boolean) => {},\n\t\tshowWarning: (_message: string) => {},\n\t\tshowError: (_message: string) => {},\n\t\tshowTip: (_message: string) => {},\n\t\tupdateEditorBorderColor: () => {},\n\t\tisExtensionCommand: (_text: string) => false,\n\t\tisKnownSlashCommand: (_text: string) => false,\n\t\tqueueCompactionMessage: (_text: string, _mode: \"steer\" | \"followUp\") => {},\n\t\tupdatePendingMessagesDisplay: () => {},\n\t\tflushPendingBashComponents: () => {},\n\t\tcontextualTips: new ContextualTips(),\n\t\tgetContextPercent: () => undefined,\n\t\toptions: { submitPromptsDirectly: true },\n\t} satisfies InteractiveModeStateHost & Parameters<typeof setupEditorSubmitHandler>[0];\n\n\treturn { host, promptCalls, historyCalls };\n}\n\nconst TEST_IMAGE: ImageContent = {\n\ttype: \"image\",\n\tdata: \"iVBORw0KGgo=\",\n\tmimeType: \"image/png\",\n};\n\ndescribe(\"input-controller pending images\", () => {\n\tlet host: ReturnType<typeof createMockHost>[\"host\"];\n\tlet promptCalls: ReturnType<typeof createMockHost>[\"promptCalls\"];\n\n\tbeforeEach(() => {\n\t\tconst mock = createMockHost();\n\t\thost = mock.host;\n\t\tpromptCalls = mock.promptCalls;\n\t\tsetupEditorSubmitHandler(host);\n\t});\n\n\tit(\"passes pending images to session.prompt on submit\", async () => {\n\t\thost.pendingImages.push({ ...TEST_IMAGE });\n\t\tawait host.defaultEditor.onSubmit!(\"describe this image\");\n\n\t\tassert.equal(promptCalls.length, 1);\n\t\tassert.equal(promptCalls[0].text, \"describe this image\");\n\t\tassert.ok(promptCalls[0].options?.images);\n\t\tassert.equal(promptCalls[0].options.images.length, 1);\n\t\tassert.equal(promptCalls[0].options.images[0].mimeType, \"image/png\");\n\t});\n\n\tit(\"clears pending images after submit\", async () => {\n\t\thost.pendingImages.push({ ...TEST_IMAGE });\n\t\tawait host.defaultEditor.onSubmit!(\"describe this image\");\n\n\t\tassert.equal(host.pendingImages.length, 0);\n\t});\n\n\tit(\"passes undefined images when no images are pending\", async () => {\n\t\tawait host.defaultEditor.onSubmit!(\"hello\");\n\n\t\tassert.equal(promptCalls.length, 1);\n\t\tassert.equal(promptCalls[0].options?.images, undefined);\n\t});\n\n\tit(\"passes multiple images in order\", async () => {\n\t\tconst img1: ImageContent = { type: \"image\", data: \"aaa=\", mimeType: \"image/png\" };\n\t\tconst img2: ImageContent = { type: \"image\", data: \"bbb=\", mimeType: \"image/jpeg\" };\n\t\thost.pendingImages.push(img1, img2);\n\n\t\tawait host.defaultEditor.onSubmit!(\"describe these images\");\n\n\t\tassert.equal(promptCalls[0].options.images.length, 2);\n\t\tassert.equal(promptCalls[0].options.images[0].data, \"aaa=\");\n\t\tassert.equal(promptCalls[0].options.images[1].data, \"bbb=\");\n\t});\n\n\tit(\"discards pending images on bash command\", async () => {\n\t\thost.pendingImages.push({ ...TEST_IMAGE });\n\t\tawait host.defaultEditor.onSubmit!(\"! ls -la\");\n\n\t\tassert.equal(host.pendingImages.length, 0);\n\t\tassert.equal(promptCalls.length, 0); // bash commands don't go through prompt\n\t});\n});\n\ntype HostOptions = {\n\tknownSlashCommands?: string[];\n};\n\nfunction getSlashCommandName(text: string): string {\n\tconst trimmed = text.trim();\n\tconst spaceIndex = trimmed.indexOf(\" \");\n\treturn spaceIndex === -1 ? trimmed.slice(1) : trimmed.slice(1, spaceIndex);\n}\n\nfunction createHost(options: HostOptions = {}) {\n\tconst prompted: string[] = [];\n\tconst promptOptions: any[] = [];\n\tconst errors: string[] = [];\n\tconst warnings: string[] = [];\n\tconst tips: string[] = [];\n\tconst history: string[] = [];\n\tconst knownSlashCommands = new Set(options.knownSlashCommands ?? []);\n\tlet editorText = \"\";\n\tlet settingsOpened = 0;\n\n\tconst editor = {\n\t\tsetText(text: string) {\n\t\t\teditorText = text;\n\t\t},\n\t\tgetText() {\n\t\t\treturn editorText;\n\t\t},\n\t\taddToHistory(text: string) {\n\t\t\thistory.push(text);\n\t\t},\n\t};\n\n\tconst host = {\n\t\tdefaultEditor: editor as typeof editor & { onSubmit?: (text: string) => Promise<void> },\n\t\teditor,\n\t\tsession: {\n\t\t\tisBashRunning: false,\n\t\t\tisCompacting: false,\n\t\t\tisStreaming: false,\n\t\t\tprompt: async (text: string, options?: any) => {\n\t\t\t\tprompted.push(text);\n\t\t\t\tpromptOptions.push(options);\n\t\t\t},\n\t\t},\n\t\tui: {\n\t\t\trequestRender() {},\n\t\t},\n\t\tpendingImages: [] as ImageContent[],\n\t\tgetSlashCommandContext: () => ({\n\t\t\tshowSettingsSelector: () => {\n\t\t\t\tsettingsOpened += 1;\n\t\t\t},\n\t\t}),\n\t\thandleBashCommand: async () => {},\n\t\tshowWarning(message: string) {\n\t\t\twarnings.push(message);\n\t\t},\n\t\tshowError(message: string) {\n\t\t\terrors.push(message);\n\t\t},\n\t\tshowTip(message: string) {\n\t\t\ttips.push(message);\n\t\t},\n\t\tupdateEditorBorderColor() {},\n\t\tisExtensionCommand() {\n\t\t\treturn false;\n\t\t},\n\t\tisKnownSlashCommand(text: string) {\n\t\t\treturn knownSlashCommands.has(getSlashCommandName(text));\n\t\t},\n\t\tqueueCompactionMessage() {},\n\t\tupdatePendingMessagesDisplay() {},\n\t\tflushPendingBashComponents() {},\n\t\tcontextualTips: {\n\t\t\trecordBashIncluded() {},\n\t\t\tevaluate() {\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t},\n\t\tgetContextPercent() {\n\t\t\treturn undefined;\n\t\t},\n\t};\n\n\tsetupEditorSubmitHandler(host as any);\n\n\treturn {\n\t\thost: host as typeof host & { defaultEditor: typeof editor & { onSubmit: (text: string) => Promise<void> } },\n\t\tprompted,\n\t\tpromptOptions,\n\t\terrors,\n\t\twarnings,\n\t\ttips,\n\t\thistory,\n\t\tgetEditorText: () => editorText,\n\t\tgetSettingsOpened: () => settingsOpened,\n\t};\n}\n\ntest(\"input-controller: regular prompt submit preserves pending images\", async () => {\n\tconst { host, prompted, promptOptions } = createHost();\n\thost.pendingImages.push({ ...TEST_IMAGE });\n\n\tawait host.defaultEditor.onSubmit(\"describe this image [Image #1]\");\n\n\tassert.deepEqual(prompted, [\"describe this image [Image #1]\"]);\n\tassert.equal(promptOptions[0]?.images?.length, 1);\n\tassert.equal(promptOptions[0].images[0].mimeType, \"image/png\");\n\tassert.equal(promptOptions[0].images[0].data, TEST_IMAGE.data);\n\tassert.equal(host.pendingImages.length, 0);\n});\n\ntest(\"input-controller: built-in slash commands stay in TUI dispatch\", async () => {\n\tconst { host, prompted, errors, getSettingsOpened, getEditorText } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/settings\");\n\n\tassert.equal(getSettingsOpened(), 1, \"built-in /settings should open the settings selector\");\n\tassert.deepEqual(prompted, [], \"built-in slash commands should not reach session.prompt\");\n\tassert.deepEqual(errors, [], \"built-in slash commands should not show errors\");\n\tassert.equal(getEditorText(), \"\", \"built-in slash commands should clear the editor after handling\");\n});\n\ntest(\"input-controller: extension slash commands fall through to session.prompt\", async () => {\n\tconst { host, prompted, errors, history } = createHost({ knownSlashCommands: [\"gsd\"] });\n\n\tawait host.defaultEditor.onSubmit(\"/gsd help\");\n\n\tassert.deepEqual(prompted, [\"/gsd help\"], \"known extension slash commands should reach session.prompt\");\n\tassert.deepEqual(errors, [], \"known extension slash commands should not show unknown-command errors\");\n\tassert.deepEqual(history, [\"/gsd help\"], \"known extension slash commands should still be added to history\");\n});\n\ntest(\"input-controller: prompt template slash commands fall through to session.prompt\", async () => {\n\tconst { host, prompted, errors } = createHost({ knownSlashCommands: [\"daily\"] });\n\n\tawait host.defaultEditor.onSubmit(\"/daily focus area\");\n\n\tassert.deepEqual(prompted, [\"/daily focus area\"]);\n\tassert.deepEqual(errors, []);\n});\n\ntest(\"input-controller: skill slash commands fall through to session.prompt\", async () => {\n\tconst { host, prompted, errors } = createHost({ knownSlashCommands: [\"skill:create-skill\"] });\n\n\tawait host.defaultEditor.onSubmit(\"/skill:create-skill routing bug\");\n\n\tassert.deepEqual(prompted, [\"/skill:create-skill routing bug\"]);\n\tassert.deepEqual(errors, []);\n});\n\ntest(\"input-controller: disabled skill slash commands stay unknown\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/skill:create-skill routing bug\");\n\n\tassert.deepEqual(prompted, []);\n\tassert.deepEqual(errors, [\"Unknown command: /skill:create-skill. Use slash autocomplete to see available commands.\"]);\n});\n\ntest(\"input-controller: /export prefix does not swallow unrelated slash commands\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/exportfoo\");\n\n\tassert.deepEqual(prompted, []);\n\tassert.deepEqual(errors, [\"Unknown command: /exportfoo. Use slash autocomplete to see available commands.\"]);\n});\n\ntest(\"input-controller: truly unknown slash commands stop before session.prompt\", async () => {\n\tconst { host, prompted, errors, getEditorText } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/definitely-not-a-command\");\n\n\tassert.deepEqual(prompted, [], \"unknown slash commands should not reach session.prompt\");\n\tassert.deepEqual(\n\t\terrors,\n\t\t[\"Unknown command: /definitely-not-a-command. Use slash autocomplete to see available commands.\"],\n\t);\n\tassert.equal(getEditorText(), \"\", \"unknown slash commands should clear the editor after showing the error\");\n});\n\ntest(\"input-controller: absolute file paths are not treated as slash commands (#3478)\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/Users/name/Desktop/screenshot.png\");\n\n\tassert.deepEqual(errors, [], \"file paths should not trigger unknown command error\");\n\tassert.deepEqual(prompted, [\"/Users/name/Desktop/screenshot.png\"], \"file paths should be sent as plain input\");\n});\n\ntest(\"input-controller: Linux absolute paths are not treated as slash commands (#3478)\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/home/user/documents/file.txt\");\n\n\tassert.deepEqual(errors, [], \"Linux paths should not trigger unknown command error\");\n\tassert.deepEqual(prompted, [\"/home/user/documents/file.txt\"], \"Linux paths should be sent as plain input\");\n});\n\ntest(\"input-controller: /tmp paths are not treated as slash commands (#3478)\", async () => {\n\tconst { host, prompted, errors } = createHost();\n\n\tawait host.defaultEditor.onSubmit(\"/tmp/some-file.log\");\n\n\tassert.deepEqual(errors, []);\n\tassert.deepEqual(prompted, [\"/tmp/some-file.log\"]);\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt-cache-stability.test.d.ts","sourceRoot":"","sources":["../../src/tests/system-prompt-cache-stability.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// @gsd/pi-coding-agent + system-prompt-cache-stability.test — regression
|
|
2
|
+
// coverage for #5019. The system prompt must NOT include a per-call timestamp
|
|
3
|
+
// by default; embedding `Date.toLocaleString()` in the cached prefix
|
|
4
|
+
// invalidates Anthropic prompt-cache hits on every request and incurs the
|
|
5
|
+
// cache-write premium. The opt-in `includeDateTime` flag preserves the prior
|
|
6
|
+
// behavior for callers that explicitly want clock awareness.
|
|
7
|
+
import test from "node:test";
|
|
8
|
+
import assert from "node:assert/strict";
|
|
9
|
+
import { buildSystemPrompt } from "../core/system-prompt.js";
|
|
10
|
+
// ─── Default branch (no customPrompt) ──────────────────────────────────────
|
|
11
|
+
test("buildSystemPrompt: default omits 'Current date and time' line", () => {
|
|
12
|
+
const prompt = buildSystemPrompt({ selectedTools: ["read", "edit"] });
|
|
13
|
+
assert.ok(!prompt.includes("Current date and time:"), `prompt should not include the dateTime line by default. Got:\n${prompt}`);
|
|
14
|
+
});
|
|
15
|
+
test("buildSystemPrompt: includeDateTime=true emits 'Current date and time' line", () => {
|
|
16
|
+
const prompt = buildSystemPrompt({
|
|
17
|
+
selectedTools: ["read", "edit"],
|
|
18
|
+
includeDateTime: true,
|
|
19
|
+
});
|
|
20
|
+
assert.match(prompt, /Current date and time: /, "prompt should include the dateTime line when explicitly opted in");
|
|
21
|
+
});
|
|
22
|
+
test("buildSystemPrompt: includeDateTime=false explicit also omits the line", () => {
|
|
23
|
+
const prompt = buildSystemPrompt({
|
|
24
|
+
selectedTools: ["read", "edit"],
|
|
25
|
+
includeDateTime: false,
|
|
26
|
+
});
|
|
27
|
+
assert.ok(!prompt.includes("Current date and time:"));
|
|
28
|
+
});
|
|
29
|
+
// ─── Custom-prompt branch ──────────────────────────────────────────────────
|
|
30
|
+
test("buildSystemPrompt (customPrompt): default omits 'Current date and time' line", () => {
|
|
31
|
+
const prompt = buildSystemPrompt({
|
|
32
|
+
customPrompt: "CUSTOM BASE",
|
|
33
|
+
selectedTools: ["read"],
|
|
34
|
+
});
|
|
35
|
+
assert.ok(!prompt.includes("Current date and time:"));
|
|
36
|
+
});
|
|
37
|
+
test("buildSystemPrompt (customPrompt): includeDateTime=true emits the line", () => {
|
|
38
|
+
const prompt = buildSystemPrompt({
|
|
39
|
+
customPrompt: "CUSTOM BASE",
|
|
40
|
+
selectedTools: ["read"],
|
|
41
|
+
includeDateTime: true,
|
|
42
|
+
});
|
|
43
|
+
assert.match(prompt, /Current date and time: /);
|
|
44
|
+
});
|
|
45
|
+
// ─── Cache-stability invariant ─────────────────────────────────────────────
|
|
46
|
+
test("buildSystemPrompt: two back-to-back default calls produce identical prompts", async () => {
|
|
47
|
+
// The bug: the previous default-on `dateTime` line included `second: "2-digit"`,
|
|
48
|
+
// so two calls within the same second could match but any longer gap busted
|
|
49
|
+
// the cache. Asserting equality across a deliberate sub-second sleep proves
|
|
50
|
+
// the byte-for-byte stability that Anthropic prompt caching requires.
|
|
51
|
+
const first = buildSystemPrompt({ selectedTools: ["read", "edit"], cwd: "/tmp/example" });
|
|
52
|
+
await new Promise((resolve) => setTimeout(resolve, 1100));
|
|
53
|
+
const second = buildSystemPrompt({ selectedTools: ["read", "edit"], cwd: "/tmp/example" });
|
|
54
|
+
assert.equal(first, second, "system prompt must be byte-for-byte stable across calls so the prompt cache can hit");
|
|
55
|
+
});
|
|
56
|
+
test("buildSystemPrompt: includeDateTime=true intentionally produces different prompts across the second boundary", async () => {
|
|
57
|
+
// Inverse of the cache-stability test: when callers opt in, the dateTime
|
|
58
|
+
// line is expected to vary. This documents the trade-off the flag exists
|
|
59
|
+
// to surface.
|
|
60
|
+
const first = buildSystemPrompt({
|
|
61
|
+
selectedTools: ["read"],
|
|
62
|
+
cwd: "/tmp/example",
|
|
63
|
+
includeDateTime: true,
|
|
64
|
+
});
|
|
65
|
+
await new Promise((resolve) => setTimeout(resolve, 1100));
|
|
66
|
+
const second = buildSystemPrompt({
|
|
67
|
+
selectedTools: ["read"],
|
|
68
|
+
cwd: "/tmp/example",
|
|
69
|
+
includeDateTime: true,
|
|
70
|
+
});
|
|
71
|
+
assert.notEqual(first, second, "opt-in dateTime is expected to vary across the second boundary");
|
|
72
|
+
});
|
|
73
|
+
// ─── Cwd preservation ──────────────────────────────────────────────────────
|
|
74
|
+
test("buildSystemPrompt: 'Current working directory' line is preserved (only dateTime is removed)", () => {
|
|
75
|
+
const prompt = buildSystemPrompt({ selectedTools: ["read"], cwd: "/tmp/example" });
|
|
76
|
+
assert.match(prompt, /Current working directory: \/tmp\/example/);
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=system-prompt-cache-stability.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt-cache-stability.test.js","sourceRoot":"","sources":["../../src/tests/system-prompt-cache-stability.test.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8EAA8E;AAC9E,qEAAqE;AACrE,0EAA0E;AAC1E,6EAA6E;AAC7E,6DAA6D;AAE7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,8EAA8E;AAE9E,IAAI,CAAC,+DAA+D,EAAE,GAAG,EAAE;IAC1E,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IACtE,MA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,GAAG,EAAE;IACxG,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,aAAa,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC;IACnF,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,2CAA2C,CAAC,CAAC;AACnE,CAAC,CAAC,CAAC","sourcesContent":["// @gsd/pi-coding-agent + system-prompt-cache-stability.test — regression\n// coverage for #5019. The system prompt must NOT include a per-call timestamp\n// by default; embedding `Date.toLocaleString()` in the cached prefix\n// invalidates Anthropic prompt-cache hits on every request and incurs the\n// cache-write premium. The opt-in `includeDateTime` flag preserves the prior\n// behavior for callers that explicitly want clock awareness.\n\nimport test from \"node:test\";\nimport assert from \"node:assert/strict\";\n\nimport { buildSystemPrompt } from \"../core/system-prompt.js\";\n\n// ─── Default branch (no customPrompt) ──────────────────────────────────────\n\ntest(\"buildSystemPrompt: default omits 'Current date and time' line\", () => {\n\tconst prompt = buildSystemPrompt({ selectedTools: [\"read\", \"edit\"] });\n\tassert.ok(\n\t\t!prompt.includes(\"Current date and time:\"),\n\t\t`prompt should not include the dateTime line by default. Got:\\n${prompt}`,\n\t);\n});\n\ntest(\"buildSystemPrompt: includeDateTime=true emits 'Current date and time' line\", () => {\n\tconst prompt = buildSystemPrompt({\n\t\tselectedTools: [\"read\", \"edit\"],\n\t\tincludeDateTime: true,\n\t});\n\tassert.match(\n\t\tprompt,\n\t\t/Current date and time: /,\n\t\t\"prompt should include the dateTime line when explicitly opted in\",\n\t);\n});\n\ntest(\"buildSystemPrompt: includeDateTime=false explicit also omits the line\", () => {\n\tconst prompt = buildSystemPrompt({\n\t\tselectedTools: [\"read\", \"edit\"],\n\t\tincludeDateTime: false,\n\t});\n\tassert.ok(!prompt.includes(\"Current date and time:\"));\n});\n\n// ─── Custom-prompt branch ──────────────────────────────────────────────────\n\ntest(\"buildSystemPrompt (customPrompt): default omits 'Current date and time' line\", () => {\n\tconst prompt = buildSystemPrompt({\n\t\tcustomPrompt: \"CUSTOM BASE\",\n\t\tselectedTools: [\"read\"],\n\t});\n\tassert.ok(!prompt.includes(\"Current date and time:\"));\n});\n\ntest(\"buildSystemPrompt (customPrompt): includeDateTime=true emits the line\", () => {\n\tconst prompt = buildSystemPrompt({\n\t\tcustomPrompt: \"CUSTOM BASE\",\n\t\tselectedTools: [\"read\"],\n\t\tincludeDateTime: true,\n\t});\n\tassert.match(prompt, /Current date and time: /);\n});\n\n// ─── Cache-stability invariant ─────────────────────────────────────────────\n\ntest(\"buildSystemPrompt: two back-to-back default calls produce identical prompts\", async () => {\n\t// The bug: the previous default-on `dateTime` line included `second: \"2-digit\"`,\n\t// so two calls within the same second could match but any longer gap busted\n\t// the cache. Asserting equality across a deliberate sub-second sleep proves\n\t// the byte-for-byte stability that Anthropic prompt caching requires.\n\tconst first = buildSystemPrompt({ selectedTools: [\"read\", \"edit\"], cwd: \"/tmp/example\" });\n\tawait new Promise((resolve) => setTimeout(resolve, 1100));\n\tconst second = buildSystemPrompt({ selectedTools: [\"read\", \"edit\"], cwd: \"/tmp/example\" });\n\tassert.equal(\n\t\tfirst,\n\t\tsecond,\n\t\t\"system prompt must be byte-for-byte stable across calls so the prompt cache can hit\",\n\t);\n});\n\ntest(\"buildSystemPrompt: includeDateTime=true intentionally produces different prompts across the second boundary\", async () => {\n\t// Inverse of the cache-stability test: when callers opt in, the dateTime\n\t// line is expected to vary. This documents the trade-off the flag exists\n\t// to surface.\n\tconst first = buildSystemPrompt({\n\t\tselectedTools: [\"read\"],\n\t\tcwd: \"/tmp/example\",\n\t\tincludeDateTime: true,\n\t});\n\tawait new Promise((resolve) => setTimeout(resolve, 1100));\n\tconst second = buildSystemPrompt({\n\t\tselectedTools: [\"read\"],\n\t\tcwd: \"/tmp/example\",\n\t\tincludeDateTime: true,\n\t});\n\tassert.notEqual(first, second, \"opt-in dateTime is expected to vary across the second boundary\");\n});\n\n// ─── Cwd preservation ──────────────────────────────────────────────────────\n\ntest(\"buildSystemPrompt: 'Current working directory' line is preserved (only dateTime is removed)\", () => {\n\tconst prompt = buildSystemPrompt({ selectedTools: [\"read\"], cwd: \"/tmp/example\" });\n\tassert.match(prompt, /Current working directory: \\/tmp\\/example/);\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-telemetry.test.d.ts","sourceRoot":"","sources":["../../src/tests/token-telemetry.test.ts"],"names":[],"mappings":""}
|