gsd-pi 2.78.0 → 2.78.1-dev.82bcf6b71
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 +26 -12
- 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-direct-dispatch.js +55 -21
- package/dist/resources/extensions/gsd/auto-dispatch.js +18 -6
- package/dist/resources/extensions/gsd/auto-prompts.js +69 -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 +75 -13
- package/dist/resources/extensions/gsd/auto.js +39 -14
- 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/guided-discuss-milestone.md +2 -0
- package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +2 -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/prompts/rewrite-docs.md +2 -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 +28 -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/resources/skills/lint/SKILL.md +4 -0
- package/dist/resources/skills/review/SKILL.md +4 -0
- package/dist/resources/skills/test/SKILL.md +3 -0
- 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 +19 -19
- 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 +19 -19
- 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 +26 -12
- 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-direct-dispatch.ts +60 -24
- package/src/resources/extensions/gsd/auto-dispatch.ts +18 -6
- package/src/resources/extensions/gsd/auto-prompts.ts +66 -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 +97 -12
- package/src/resources/extensions/gsd/auto.ts +37 -10
- 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/guided-discuss-milestone.md +2 -0
- package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +2 -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/prompts/rewrite-docs.md +2 -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 +179 -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/stash-pop-gsd-conflict.test.ts +8 -2
- package/src/resources/extensions/gsd/tests/stash-queued-context-files.test.ts +12 -6
- 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-path-injection.test.ts +235 -0
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +85 -0
- 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 +28 -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/src/resources/skills/lint/SKILL.md +4 -0
- package/src/resources/skills/review/SKILL.md +4 -0
- package/src/resources/skills/test/SKILL.md +3 -0
- 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 → hcvW7f3yv1JHzlWe7tIc6}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{C1zT2kEfoLhDdbWPWKrXd → hcvW7f3yv1JHzlWe7tIc6}/_ssgManifest.js +0 -0
|
@@ -1 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AQ,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wCAAwC,EAAE,GAAG,EAAE;QACnD,MAAM,KAAK,GAAG,kCAAkC,CAAC;QACjD,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, test } from \"node:test\";\nimport assert from \"node:assert/strict\";\nimport { repairToolJson, hasYamlBulletLists, hasXmlParameterTags, hasTruncatedNumbers } from \"../repair-tool-json.js\";\n\ndescribe(\"repairToolJson — YAML bullet list repair (#2660)\", () => {\n\t// ── Detection ──────────────────────────────────────────────────────────\n\n\ttest(\"hasYamlBulletLists detects YAML-style bullets\", () => {\n\t\tassert.equal(\n\t\t\thasYamlBulletLists('\"keyDecisions\": - Used Web Notification API'),\n\t\t\ttrue,\n\t\t);\n\t});\n\n\ttest(\"hasYamlBulletLists ignores negative numbers\", () => {\n\t\tassert.equal(\n\t\t\thasYamlBulletLists('\"offset\": -1'),\n\t\t\tfalse,\n\t\t\t\"negative number should not be detected as YAML bullet\",\n\t\t);\n\t});\n\n\ttest(\"hasYamlBulletLists returns false for valid JSON\", () => {\n\t\tassert.equal(\n\t\t\thasYamlBulletLists('{\"keyDecisions\": [\"item1\", \"item2\"]}'),\n\t\t\tfalse,\n\t\t);\n\t});\n\n\t// ── Single bullet item ────────────────────────────────────────────────\n\n\ttest(\"repairs single YAML bullet to JSON array\", () => {\n\t\tconst malformed = '{\"keyDecisions\": - Used Web Notification API}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.deepEqual(parsed.keyDecisions, [\"Used Web Notification API\"]);\n\t});\n\n\t// ── Multiple bullet items (newline-separated) ─────────────────────────\n\n\ttest(\"repairs multiple YAML bullets separated by newlines\", () => {\n\t\tconst malformed =\n\t\t\t'{\"keyDecisions\": - Used Web Notification API\\n - Chose Tauri over Electron\\n - Adopted SQLite for storage, \"title\": \"M005\"}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.deepEqual(parsed.keyDecisions, [\n\t\t\t\"Used Web Notification API\",\n\t\t\t\"Chose Tauri over Electron\",\n\t\t\t\"Adopted SQLite for storage\",\n\t\t]);\n\t\tassert.equal(parsed.title, \"M005\");\n\t});\n\n\t// ── Multiple fields with YAML bullets ─────────────────────────────────\n\n\ttest(\"repairs multiple fields each with YAML bullet lists\", () => {\n\t\tconst malformed =\n\t\t\t'{\"keyDecisions\": - decision one\\n - decision two, \"keyFiles\": - src/lib.rs — Extended menu\\n - src/main.ts — Entry point, \"title\": \"done\"}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.deepEqual(parsed.keyDecisions, [\"decision one\", \"decision two\"]);\n\t\tassert.deepEqual(parsed.keyFiles, [\n\t\t\t\"src/lib.rs \\u2014 Extended menu\",\n\t\t\t\"src/main.ts \\u2014 Entry point\",\n\t\t]);\n\t\tassert.equal(parsed.title, \"done\");\n\t});\n\n\t// ── Exact reproduction from issue #2660 ───────────────────────────────\n\n\ttest(\"repairs the exact malformed JSON from issue #2660\", () => {\n\t\tconst malformed = `{\"milestoneId\": \"M005\", \"title\": \"Native Desktop Polish\", \"oneLiner\": \"summary\", \"narrative\": \"details\", \"successCriteriaResults\": \"all pass\", \"definitionOfDoneResults\": \"all done\", \"requirementOutcomes\": \"met\", \"keyDecisions\": - Used Web Notification API (new window.Notification()) instead of Tauri sendNotification wrapper, \"keyFiles\": - src-tauri/src/lib.rs \\u2014 Extended menu builder with notification toggle, \"lessonsLearned\": - Always test notification permissions before sending, \"followUps\": \"none\", \"deviations\": \"none\", \"verificationPassed\": true}`;\n\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\n\t\tassert.equal(parsed.milestoneId, \"M005\");\n\t\tassert.equal(parsed.title, \"Native Desktop Polish\");\n\t\tassert.ok(Array.isArray(parsed.keyDecisions), \"keyDecisions should be an array\");\n\t\tassert.ok(parsed.keyDecisions[0].includes(\"Web Notification API\"));\n\t\tassert.ok(Array.isArray(parsed.keyFiles), \"keyFiles should be an array\");\n\t\tassert.ok(parsed.keyFiles[0].includes(\"src-tauri/src/lib.rs\"));\n\t\tassert.ok(Array.isArray(parsed.lessonsLearned), \"lessonsLearned should be an array\");\n\t\tassert.equal(parsed.verificationPassed, true);\n\t});\n\n\t// ── Passthrough for valid JSON ────────────────────────────────────────\n\n\ttest(\"returns valid JSON unchanged\", () => {\n\t\tconst valid = '{\"keyDecisions\": [\"item1\", \"item2\"], \"count\": -5}';\n\t\tconst result = repairToolJson(valid);\n\t\tassert.equal(result, valid, \"valid JSON should be returned unchanged\");\n\t});\n\n\t// ── Negative numbers are preserved ────────────────────────────────────\n\n\ttest(\"does not mangle negative numbers\", () => {\n\t\tconst valid = '{\"offset\": -1, \"limit\": -100}';\n\t\tconst result = repairToolJson(valid);\n\t\tassert.equal(result, valid);\n\t});\n});\n\n// ═══════════════════════════════════════════════════════════════════════════\n// XML parameter tag repair (#3403)\n// ═══════════════════════════════════════════════════════════════════════════\n\ndescribe(\"repairToolJson — XML parameter tag stripping (#3403)\", () => {\n\ttest(\"hasXmlParameterTags detects opening tags\", () => {\n\t\tassert.equal(\n\t\t\thasXmlParameterTags('<parameter name=\"narrative\">some text</parameter>'),\n\t\t\ttrue,\n\t\t);\n\t});\n\n\ttest(\"hasXmlParameterTags returns false for clean JSON\", () => {\n\t\tassert.equal(\n\t\t\thasXmlParameterTags('{\"narrative\": \"some text\"}'),\n\t\t\tfalse,\n\t\t);\n\t});\n\n\ttest(\"strips XML parameter tags from JSON values\", () => {\n\t\tconst malformed = '{\"sliceId\": \"S03\", \"narrative\": <parameter name=\"narrative\">The slice work</parameter>}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\t// After stripping tags, the content should be parseable or at least tag-free\n\t\tassert.ok(!repaired.includes(\"<parameter\"), \"should not contain <parameter tags\");\n\t\tassert.ok(!repaired.includes(\"</parameter>\"), \"should not contain </parameter> tags\");\n\t});\n\n\ttest(\"handles mixed XML and JSON content\", () => {\n\t\tconst malformed = '{\"oneLiner\": \"done\", \"verification\": <parameter name=\"verification\">all tests pass</parameter>}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tassert.ok(!repaired.includes(\"<parameter\"), \"XML tags should be stripped\");\n\t\tassert.ok(repaired.includes(\"all tests pass\"), \"content should be preserved\");\n\t});\n\n\ttest(\"promotes XML parameters trapped inside valid JSON string values\", () => {\n\t\tconst malformed =\n\t\t\t'{\"narrative\":\"text.</narrative>\\\\n<parameter name=\\\\\"verification\\\\\">all tests pass</parameter>\\\\n<parameter name=\\\\\"verificationEvidence\\\\\">[\\\\\"npm test\\\\\"]</parameter>\",\"oneLiner\":\"done\"}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\n\t\tassert.equal(parsed.narrative, \"text.\");\n\t\tassert.equal(parsed.verification, \"all tests pass\");\n\t\tassert.deepEqual(parsed.verificationEvidence, [\"npm test\"]);\n\t\tassert.equal(parsed.oneLiner, \"done\");\n\t\tassert.ok(!parsed.narrative.includes(\"<parameter\"), \"narrative should not retain leaked XML\");\n\t});\n});\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Truncated number repair (#3464)\n// ═══════════════════════════════════════════════════════════════════════════\n\ndescribe(\"repairToolJson — truncated number repair (#3464)\", () => {\n\ttest(\"hasTruncatedNumbers detects bare comma after colon\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"exitCode\": ,'), true);\n\t});\n\n\ttest(\"hasTruncatedNumbers detects bare minus before comma\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"exitCode\": -,'), true);\n\t});\n\n\ttest(\"hasTruncatedNumbers detects bare minus before closing brace\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"durationMs\": -}'), true);\n\t});\n\n\ttest(\"hasTruncatedNumbers returns false for valid numbers\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"exitCode\": 0, \"durationMs\": 1234'), false);\n\t});\n\n\ttest(\"hasTruncatedNumbers returns false for negative numbers\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"exitCode\": -1, \"offset\": -100'), false);\n\t});\n\n\ttest(\"repairs truncated exitCode with bare comma\", () => {\n\t\tconst malformed = '{\"command\": \"npm test\", \"exitCode\": , \"verdict\": \"pass\", \"durationMs\": 500}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.equal(parsed.exitCode, 0);\n\t\tassert.equal(parsed.durationMs, 500);\n\t});\n\n\ttest(\"repairs truncated exitCode with bare minus\", () => {\n\t\tconst malformed = '{\"command\": \"npm test\", \"exitCode\": -, \"verdict\": \"pass\", \"durationMs\": 1234}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.equal(parsed.exitCode, 0);\n\t\tassert.equal(parsed.verdict, \"pass\");\n\t});\n\n\ttest(\"repairs truncated durationMs at end of object\", () => {\n\t\tconst malformed = '{\"command\": \"npm test\", \"exitCode\": 0, \"verdict\": \"pass\", \"durationMs\": -}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.equal(parsed.durationMs, 0);\n\t\tassert.equal(parsed.exitCode, 0);\n\t});\n\n\ttest(\"does not mangle valid negative numbers\", () => {\n\t\tconst valid = '{\"exitCode\": -1, \"offset\": -100}';\n\t\tconst repaired = repairToolJson(valid);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.equal(parsed.exitCode, -1);\n\t\tassert.equal(parsed.offset, -100);\n\t});\n});\n"]}
|
|
1
|
+
{"version":3,"file":"repair-tool-json.test.js","sourceRoot":"","sources":["../../../src/utils/tests/repair-tool-json.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEtH,QAAQ,CAAC,kDAAkD,EAAE,GAAG,EAAE;IACjE,0EAA0E;IAE1E,IAAI,CAAC,+CAA+C,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,KAAK,CACX,kBAAkB,CAAC,6CAA6C,CAAC,EACjE,IAAI,CACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,KAAK,CACX,kBAAkB,CAAC,cAAc,CAAC,EAClC,KAAK,EACL,uDAAuD,CACvD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,iDAAiD,EAAE,GAAG,EAAE;QAC5D,MAAM,CAAC,KAAK,CACX,kBAAkB,CAAC,sCAAsC,CAAC,EAC1D,KAAK,CACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,yEAAyE;IAEzE,IAAI,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACrD,MAAM,SAAS,GAAG,+CAA+C,CAAC;QAClE,MAAM,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,2BAA2B,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAE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,EAAE,GAAG,EAAE;QAC1D,MAAM,SAAS,GAAG,4EAA4E,CAAC;QAC/F,MAAM,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wCAAwC,EAAE,GAAG,EAAE;QACnD,MAAM,KAAK,GAAG,kCAAkC,CAAC;QACjD,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, test } from \"node:test\";\nimport assert from \"node:assert/strict\";\nimport { repairToolJson, hasYamlBulletLists, hasXmlParameterTags, hasTruncatedNumbers } from \"../repair-tool-json.js\";\n\ndescribe(\"repairToolJson — YAML bullet list repair (#2660)\", () => {\n\t// ── Detection ──────────────────────────────────────────────────────────\n\n\ttest(\"hasYamlBulletLists detects YAML-style bullets\", () => {\n\t\tassert.equal(\n\t\t\thasYamlBulletLists('\"keyDecisions\": - Used Web Notification API'),\n\t\t\ttrue,\n\t\t);\n\t});\n\n\ttest(\"hasYamlBulletLists ignores negative numbers\", () => {\n\t\tassert.equal(\n\t\t\thasYamlBulletLists('\"offset\": -1'),\n\t\t\tfalse,\n\t\t\t\"negative number should not be detected as YAML bullet\",\n\t\t);\n\t});\n\n\ttest(\"hasYamlBulletLists returns false for valid JSON\", () => {\n\t\tassert.equal(\n\t\t\thasYamlBulletLists('{\"keyDecisions\": [\"item1\", \"item2\"]}'),\n\t\t\tfalse,\n\t\t);\n\t});\n\n\t// ── Single bullet item ────────────────────────────────────────────────\n\n\ttest(\"repairs single YAML bullet to JSON array\", () => {\n\t\tconst malformed = '{\"keyDecisions\": - Used Web Notification API}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.deepEqual(parsed.keyDecisions, [\"Used Web Notification API\"]);\n\t});\n\n\t// ── Multiple bullet items (newline-separated) ─────────────────────────\n\n\ttest(\"repairs multiple YAML bullets separated by newlines\", () => {\n\t\tconst malformed =\n\t\t\t'{\"keyDecisions\": - Used Web Notification API\\n - Chose Tauri over Electron\\n - Adopted SQLite for storage, \"title\": \"M005\"}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.deepEqual(parsed.keyDecisions, [\n\t\t\t\"Used Web Notification API\",\n\t\t\t\"Chose Tauri over Electron\",\n\t\t\t\"Adopted SQLite for storage\",\n\t\t]);\n\t\tassert.equal(parsed.title, \"M005\");\n\t});\n\n\t// ── Multiple fields with YAML bullets ─────────────────────────────────\n\n\ttest(\"repairs multiple fields each with YAML bullet lists\", () => {\n\t\tconst malformed =\n\t\t\t'{\"keyDecisions\": - decision one\\n - decision two, \"keyFiles\": - src/lib.rs — Extended menu\\n - src/main.ts — Entry point, \"title\": \"done\"}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.deepEqual(parsed.keyDecisions, [\"decision one\", \"decision two\"]);\n\t\tassert.deepEqual(parsed.keyFiles, [\n\t\t\t\"src/lib.rs \\u2014 Extended menu\",\n\t\t\t\"src/main.ts \\u2014 Entry point\",\n\t\t]);\n\t\tassert.equal(parsed.title, \"done\");\n\t});\n\n\t// ── Exact reproduction from issue #2660 ───────────────────────────────\n\n\ttest(\"repairs the exact malformed JSON from issue #2660\", () => {\n\t\tconst malformed = `{\"milestoneId\": \"M005\", \"title\": \"Native Desktop Polish\", \"oneLiner\": \"summary\", \"narrative\": \"details\", \"successCriteriaResults\": \"all pass\", \"definitionOfDoneResults\": \"all done\", \"requirementOutcomes\": \"met\", \"keyDecisions\": - Used Web Notification API (new window.Notification()) instead of Tauri sendNotification wrapper, \"keyFiles\": - src-tauri/src/lib.rs \\u2014 Extended menu builder with notification toggle, \"lessonsLearned\": - Always test notification permissions before sending, \"followUps\": \"none\", \"deviations\": \"none\", \"verificationPassed\": true}`;\n\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\n\t\tassert.equal(parsed.milestoneId, \"M005\");\n\t\tassert.equal(parsed.title, \"Native Desktop Polish\");\n\t\tassert.ok(Array.isArray(parsed.keyDecisions), \"keyDecisions should be an array\");\n\t\tassert.ok(parsed.keyDecisions[0].includes(\"Web Notification API\"));\n\t\tassert.ok(Array.isArray(parsed.keyFiles), \"keyFiles should be an array\");\n\t\tassert.ok(parsed.keyFiles[0].includes(\"src-tauri/src/lib.rs\"));\n\t\tassert.ok(Array.isArray(parsed.lessonsLearned), \"lessonsLearned should be an array\");\n\t\tassert.equal(parsed.verificationPassed, true);\n\t});\n\n\t// ── Passthrough for valid JSON ────────────────────────────────────────\n\n\ttest(\"returns valid JSON unchanged\", () => {\n\t\tconst valid = '{\"keyDecisions\": [\"item1\", \"item2\"], \"count\": -5}';\n\t\tconst result = repairToolJson(valid);\n\t\tassert.equal(result, valid, \"valid JSON should be returned unchanged\");\n\t});\n\n\t// ── Negative numbers are preserved ────────────────────────────────────\n\n\ttest(\"does not mangle negative numbers\", () => {\n\t\tconst valid = '{\"offset\": -1, \"limit\": -100}';\n\t\tconst result = repairToolJson(valid);\n\t\tassert.equal(result, valid);\n\t});\n});\n\n// ═══════════════════════════════════════════════════════════════════════════\n// XML parameter tag repair (#3403)\n// ═══════════════════════════════════════════════════════════════════════════\n\ndescribe(\"repairToolJson — XML parameter tag stripping (#3403)\", () => {\n\ttest(\"hasXmlParameterTags detects opening tags\", () => {\n\t\tassert.equal(\n\t\t\thasXmlParameterTags('<parameter name=\"narrative\">some text</parameter>'),\n\t\t\ttrue,\n\t\t);\n\t});\n\n\ttest(\"hasXmlParameterTags returns false for clean JSON\", () => {\n\t\tassert.equal(\n\t\t\thasXmlParameterTags('{\"narrative\": \"some text\"}'),\n\t\t\tfalse,\n\t\t);\n\t});\n\n\ttest(\"strips XML parameter tags from JSON values\", () => {\n\t\tconst malformed = '{\"sliceId\": \"S03\", \"narrative\": <parameter name=\"narrative\">The slice work</parameter>}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\t// After stripping tags, the content should be parseable or at least tag-free\n\t\tassert.ok(!repaired.includes(\"<parameter\"), \"should not contain <parameter tags\");\n\t\tassert.ok(!repaired.includes(\"</parameter>\"), \"should not contain </parameter> tags\");\n\t});\n\n\ttest(\"handles mixed XML and JSON content\", () => {\n\t\tconst malformed = '{\"oneLiner\": \"done\", \"verification\": <parameter name=\"verification\">all tests pass</parameter>}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tassert.ok(!repaired.includes(\"<parameter\"), \"XML tags should be stripped\");\n\t\tassert.ok(repaired.includes(\"all tests pass\"), \"content should be preserved\");\n\t});\n\n\ttest(\"promotes XML parameters trapped inside valid JSON string values\", () => {\n\t\tconst malformed =\n\t\t\t'{\"narrative\":\"text.</narrative>\\\\n<parameter name=\\\\\"verification\\\\\">all tests pass</parameter>\\\\n<parameter name=\\\\\"verificationEvidence\\\\\">[\\\\\"npm test\\\\\"]</parameter>\",\"oneLiner\":\"done\"}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\n\t\tassert.equal(parsed.narrative, \"text.\");\n\t\tassert.equal(parsed.verification, \"all tests pass\");\n\t\tassert.deepEqual(parsed.verificationEvidence, [\"npm test\"]);\n\t\tassert.equal(parsed.oneLiner, \"done\");\n\t\tassert.ok(!parsed.narrative.includes(\"<parameter\"), \"narrative should not retain leaked XML\");\n\t});\n\n\ttest(\"promotes dangling XML parameters trapped inside valid JSON string values\", () => {\n\t\tconst malformed = JSON.stringify({\n\t\t\tnarrative:\n\t\t\t\t'text.\\n<parameter name=\"verification\">all tests pass\\n<parameter name=\"verificationEvidence\">[\"npm test\"]',\n\t\t\toneLiner: \"done\",\n\t\t});\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\n\t\tassert.equal(parsed.narrative, \"text.\");\n\t\tassert.equal(parsed.verification, \"all tests pass\");\n\t\tassert.deepEqual(parsed.verificationEvidence, [\"npm test\"]);\n\t\tassert.equal(parsed.oneLiner, \"done\");\n\t\tassert.ok(!parsed.narrative.includes(\"<parameter\"), \"narrative should not retain leaked XML\");\n\t});\n\n\ttest(\"promotes mixed dangling and closed XML parameters from valid JSON string values\", () => {\n\t\tconst malformed = JSON.stringify({\n\t\t\tnarrative:\n\t\t\t\t'text.\\n<parameter name=\"verification\">all tests pass\\n<parameter name=\"verificationEvidence\">[\"npm test\"]</parameter>',\n\t\t\toneLiner: \"done\",\n\t\t});\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\n\t\tassert.equal(parsed.narrative, \"text.\");\n\t\tassert.equal(parsed.verification, \"all tests pass\");\n\t\tassert.deepEqual(parsed.verificationEvidence, [\"npm test\"]);\n\t\tassert.equal(parsed.oneLiner, \"done\");\n\t\tassert.ok(!parsed.narrative.includes(\"<parameter\"), \"narrative should not retain leaked XML\");\n\t});\n});\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Truncated number repair (#3464)\n// ═══════════════════════════════════════════════════════════════════════════\n\ndescribe(\"repairToolJson — truncated number repair (#3464)\", () => {\n\ttest(\"hasTruncatedNumbers detects bare comma after colon\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"exitCode\": ,'), true);\n\t});\n\n\ttest(\"hasTruncatedNumbers detects bare minus before comma\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"exitCode\": -,'), true);\n\t});\n\n\ttest(\"hasTruncatedNumbers detects bare minus before closing brace\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"durationMs\": -}'), true);\n\t});\n\n\ttest(\"hasTruncatedNumbers returns false for valid numbers\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"exitCode\": 0, \"durationMs\": 1234'), false);\n\t});\n\n\ttest(\"hasTruncatedNumbers returns false for negative numbers\", () => {\n\t\tassert.equal(hasTruncatedNumbers('\"exitCode\": -1, \"offset\": -100'), false);\n\t});\n\n\ttest(\"repairs truncated exitCode with bare comma\", () => {\n\t\tconst malformed = '{\"command\": \"npm test\", \"exitCode\": , \"verdict\": \"pass\", \"durationMs\": 500}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.equal(parsed.exitCode, 0);\n\t\tassert.equal(parsed.durationMs, 500);\n\t});\n\n\ttest(\"repairs truncated exitCode with bare minus\", () => {\n\t\tconst malformed = '{\"command\": \"npm test\", \"exitCode\": -, \"verdict\": \"pass\", \"durationMs\": 1234}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.equal(parsed.exitCode, 0);\n\t\tassert.equal(parsed.verdict, \"pass\");\n\t});\n\n\ttest(\"repairs truncated durationMs at end of object\", () => {\n\t\tconst malformed = '{\"command\": \"npm test\", \"exitCode\": 0, \"verdict\": \"pass\", \"durationMs\": -}';\n\t\tconst repaired = repairToolJson(malformed);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.equal(parsed.durationMs, 0);\n\t\tassert.equal(parsed.exitCode, 0);\n\t});\n\n\ttest(\"does not mangle valid negative numbers\", () => {\n\t\tconst valid = '{\"exitCode\": -1, \"offset\": -100}';\n\t\tconst repaired = repairToolJson(valid);\n\t\tconst parsed = JSON.parse(repaired);\n\t\tassert.equal(parsed.exitCode, -1);\n\t\tassert.equal(parsed.offset, -100);\n\t});\n});\n"]}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
// @gsd/pi-ai + anthropic-shared.cache-breakpoint.test — coverage for #5027.
|
|
2
|
+
// `convertMessages` must apply Anthropic `cache_control` to:
|
|
3
|
+
// - the last message (existing volatile-suffix anchor — preserved)
|
|
4
|
+
// - the most recent message flagged with `cacheBreakpoint: true`
|
|
5
|
+
// (new compaction-boundary anchor)
|
|
6
|
+
// And it must NOT exceed the 4-breakpoint limit by treating multiple
|
|
7
|
+
// breakpoints as one — only the most recent earns the marker.
|
|
8
|
+
|
|
9
|
+
import { describe, test } from "node:test";
|
|
10
|
+
import assert from "node:assert/strict";
|
|
11
|
+
|
|
12
|
+
import { buildParams, convertMessages } from "./anthropic-shared.js";
|
|
13
|
+
import type { Context, Message, Model, Tool } from "../types.js";
|
|
14
|
+
import type { AnthropicApi } from "./anthropic-shared.js";
|
|
15
|
+
|
|
16
|
+
// Minimal model stub — convertMessages only reads `input` to decide whether to
|
|
17
|
+
// drop image blocks. Returning ["image"] keeps the conversion paths exercised.
|
|
18
|
+
const model = { input: ["text", "image"] } as unknown as Model<AnthropicApi>;
|
|
19
|
+
const cacheControl = { type: "ephemeral" as const };
|
|
20
|
+
|
|
21
|
+
function userMsg(text: string, opts: { cacheBreakpoint?: boolean } = {}): Message {
|
|
22
|
+
return {
|
|
23
|
+
role: "user",
|
|
24
|
+
content: text,
|
|
25
|
+
timestamp: 0,
|
|
26
|
+
...(opts.cacheBreakpoint ? { cacheBreakpoint: true } : {}),
|
|
27
|
+
} as Message;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Produces a UserMessage whose content is an array of text blocks —
|
|
31
|
+
* the production shape emitted by `convertToLlm()` for compaction summaries. */
|
|
32
|
+
function userMsgArray(text: string, opts: { cacheBreakpoint?: boolean } = {}): Message {
|
|
33
|
+
return {
|
|
34
|
+
role: "user",
|
|
35
|
+
content: [{ type: "text", text }],
|
|
36
|
+
timestamp: 0,
|
|
37
|
+
...(opts.cacheBreakpoint ? { cacheBreakpoint: true } : {}),
|
|
38
|
+
} as Message;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function assistantMsg(text: string): Message {
|
|
42
|
+
return {
|
|
43
|
+
role: "assistant",
|
|
44
|
+
content: [{ type: "text", text }],
|
|
45
|
+
api: "anthropic-messages",
|
|
46
|
+
provider: "anthropic",
|
|
47
|
+
model: "claude-sonnet-4-6",
|
|
48
|
+
usage: {
|
|
49
|
+
input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0,
|
|
50
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
51
|
+
},
|
|
52
|
+
stopReason: "stop",
|
|
53
|
+
timestamp: 0,
|
|
54
|
+
} as Message;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Returns whether the message at the given index has cache_control on its last block. */
|
|
58
|
+
function hasCacheControl(params: ReturnType<typeof convertMessages>, index: number): boolean {
|
|
59
|
+
const param = params[index];
|
|
60
|
+
if (!param || param.role !== "user") return false;
|
|
61
|
+
if (!Array.isArray(param.content)) return false;
|
|
62
|
+
const lastBlock = param.content[param.content.length - 1];
|
|
63
|
+
return Boolean(lastBlock && (lastBlock as any).cache_control);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
describe("convertMessages — cache breakpoints (#5027)", () => {
|
|
67
|
+
test("with no cacheControl option: no breakpoints are placed", () => {
|
|
68
|
+
const result = convertMessages([userMsg("hello"), assistantMsg("hi"), userMsg("again")], model, false);
|
|
69
|
+
for (let i = 0; i < result.length; i++) {
|
|
70
|
+
assert.equal(hasCacheControl(result, i), false, `index ${i} should have no cache_control`);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("no cacheBreakpoint anywhere: only the last message gets cache_control (existing behavior preserved)", () => {
|
|
75
|
+
const result = convertMessages(
|
|
76
|
+
[userMsg("first"), assistantMsg("response"), userMsg("second")],
|
|
77
|
+
model,
|
|
78
|
+
false,
|
|
79
|
+
cacheControl,
|
|
80
|
+
);
|
|
81
|
+
assert.equal(hasCacheControl(result, 0), false, "first user msg has no breakpoint");
|
|
82
|
+
assert.equal(hasCacheControl(result, result.length - 1), true, "last msg gets the volatile-suffix anchor");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("one cacheBreakpoint message: both that message AND the last message get breakpoints", () => {
|
|
86
|
+
const result = convertMessages(
|
|
87
|
+
[
|
|
88
|
+
userMsg("ancient"),
|
|
89
|
+
assistantMsg("ancient response"),
|
|
90
|
+
userMsg("[COMPACTION SUMMARY]", { cacheBreakpoint: true }),
|
|
91
|
+
assistantMsg("post-compaction response"),
|
|
92
|
+
userMsg("new turn"),
|
|
93
|
+
],
|
|
94
|
+
model,
|
|
95
|
+
false,
|
|
96
|
+
cacheControl,
|
|
97
|
+
);
|
|
98
|
+
// Find the compaction-summary index (it's the third user-shaped param)
|
|
99
|
+
const compactionIdx = result.findIndex(
|
|
100
|
+
(p) => p.role === "user" && Array.isArray(p.content) && (p.content as any)[0]?.text?.includes("COMPACTION SUMMARY"),
|
|
101
|
+
);
|
|
102
|
+
assert.ok(compactionIdx >= 0, "compaction summary should be in the params");
|
|
103
|
+
assert.equal(hasCacheControl(result, compactionIdx), true, "compaction boundary gets a breakpoint");
|
|
104
|
+
assert.equal(hasCacheControl(result, result.length - 1), true, "last msg still gets the volatile-suffix anchor");
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("array-content cacheBreakpoint message: breakpoint is applied (production shape for compaction summary)", () => {
|
|
108
|
+
// convertToLlm() emits compaction summaries as content:[{type:"text",...}];
|
|
109
|
+
// this exercises the array-backed branch in anthropic-shared.ts.
|
|
110
|
+
const result = convertMessages(
|
|
111
|
+
[
|
|
112
|
+
userMsgArray("[COMPACTION SUMMARY]", { cacheBreakpoint: true }),
|
|
113
|
+
assistantMsg("post-compaction response"),
|
|
114
|
+
userMsg("post-compaction turn"),
|
|
115
|
+
],
|
|
116
|
+
model,
|
|
117
|
+
false,
|
|
118
|
+
cacheControl,
|
|
119
|
+
);
|
|
120
|
+
const compactionIdx = result.findIndex(
|
|
121
|
+
(p) =>
|
|
122
|
+
p.role === "user" &&
|
|
123
|
+
Array.isArray(p.content) &&
|
|
124
|
+
(p.content as any)[0]?.text?.includes("COMPACTION SUMMARY"),
|
|
125
|
+
);
|
|
126
|
+
assert.ok(compactionIdx >= 0, "compaction summary param should be present");
|
|
127
|
+
assert.equal(hasCacheControl(result, compactionIdx), true, "array-content boundary gets cache_control");
|
|
128
|
+
assert.equal(hasCacheControl(result, result.length - 1), true, "last msg still gets the volatile-suffix anchor");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("multiple cacheBreakpoint messages: only the most recent one earns a breakpoint (4-limit safety)", () => {
|
|
132
|
+
const result = convertMessages(
|
|
133
|
+
[
|
|
134
|
+
userMsg("[OLD COMPACTION]", { cacheBreakpoint: true }),
|
|
135
|
+
assistantMsg("post-old response"),
|
|
136
|
+
userMsg("[NEW COMPACTION]", { cacheBreakpoint: true }),
|
|
137
|
+
assistantMsg("post-new response"),
|
|
138
|
+
userMsg("latest turn"),
|
|
139
|
+
],
|
|
140
|
+
model,
|
|
141
|
+
false,
|
|
142
|
+
cacheControl,
|
|
143
|
+
);
|
|
144
|
+
const oldIdx = result.findIndex(
|
|
145
|
+
(p) => p.role === "user" && Array.isArray(p.content) && (p.content as any)[0]?.text?.includes("OLD COMPACTION"),
|
|
146
|
+
);
|
|
147
|
+
const newIdx = result.findIndex(
|
|
148
|
+
(p) => p.role === "user" && Array.isArray(p.content) && (p.content as any)[0]?.text?.includes("NEW COMPACTION"),
|
|
149
|
+
);
|
|
150
|
+
assert.equal(hasCacheControl(result, oldIdx), false, "older boundary should not earn a breakpoint");
|
|
151
|
+
assert.equal(hasCacheControl(result, newIdx), true, "most recent boundary earns the breakpoint");
|
|
152
|
+
assert.equal(hasCacheControl(result, result.length - 1), true, "last msg still gets the volatile-suffix anchor");
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("cacheBreakpoint on the LAST message: only one breakpoint applied (deduplication)", () => {
|
|
156
|
+
// When the boundary message IS the last message, applying twice would be
|
|
157
|
+
// a no-op overwrite but the deduplication guard avoids the double-call.
|
|
158
|
+
const result = convertMessages(
|
|
159
|
+
[userMsg("hello"), userMsg("[BOUNDARY AS LAST]", { cacheBreakpoint: true })],
|
|
160
|
+
model,
|
|
161
|
+
false,
|
|
162
|
+
cacheControl,
|
|
163
|
+
);
|
|
164
|
+
assert.equal(hasCacheControl(result, result.length - 1), true);
|
|
165
|
+
// Only one user message besides the last, with no breakpoint
|
|
166
|
+
assert.equal(hasCacheControl(result, 0), false);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("cacheBreakpoint flag is ignored when no cacheControl option is provided", () => {
|
|
170
|
+
const result = convertMessages(
|
|
171
|
+
[userMsg("[COMPACTION]", { cacheBreakpoint: true }), userMsg("turn")],
|
|
172
|
+
model,
|
|
173
|
+
false,
|
|
174
|
+
);
|
|
175
|
+
for (let i = 0; i < result.length; i++) {
|
|
176
|
+
assert.equal(hasCacheControl(result, i), false, `index ${i} should have no cache_control`);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("array-content cacheBreakpoint on last message: deduplication guard prevents double application", () => {
|
|
181
|
+
// The boundary IS the last message — both anchors target the same param,
|
|
182
|
+
// so cache_control should appear exactly once.
|
|
183
|
+
const result = convertMessages(
|
|
184
|
+
[userMsg("prior turn"), userMsgArray("[BOUNDARY AS LAST]", { cacheBreakpoint: true })],
|
|
185
|
+
model,
|
|
186
|
+
false,
|
|
187
|
+
cacheControl,
|
|
188
|
+
);
|
|
189
|
+
const lastParam = result[result.length - 1];
|
|
190
|
+
assert.ok(lastParam && Array.isArray(lastParam.content), "last param has array content");
|
|
191
|
+
const cacheBlocks = (lastParam!.content as any[]).filter((b) => b.cache_control);
|
|
192
|
+
assert.equal(cacheBlocks.length, 1, "cache_control applied exactly once");
|
|
193
|
+
assert.equal(hasCacheControl(result, 0), false, "prior turn has no cache_control");
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// ─── 4-breakpoint-limit safety at buildParams level (OAuth path) ──────────
|
|
198
|
+
|
|
199
|
+
/** Count cache_control occurrences across system + tools + messages params. */
|
|
200
|
+
function countBreakpoints(params: { system?: any; tools?: any[]; messages: any[] }): number {
|
|
201
|
+
let n = 0;
|
|
202
|
+
if (Array.isArray(params.system)) {
|
|
203
|
+
for (const block of params.system) if (block.cache_control) n++;
|
|
204
|
+
}
|
|
205
|
+
if (Array.isArray(params.tools)) {
|
|
206
|
+
for (const tool of params.tools) if ((tool as any).cache_control) n++;
|
|
207
|
+
}
|
|
208
|
+
for (const m of params.messages) {
|
|
209
|
+
if (m.role === "user" && Array.isArray(m.content)) {
|
|
210
|
+
for (const block of m.content) if (block.cache_control) n++;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return n;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const buildParamsModel = {
|
|
217
|
+
id: "claude-sonnet-4-6",
|
|
218
|
+
baseUrl: "https://api.anthropic.com",
|
|
219
|
+
api: "anthropic-messages",
|
|
220
|
+
input: ["text", "image"],
|
|
221
|
+
maxTokens: 64000,
|
|
222
|
+
} as unknown as Model<AnthropicApi>;
|
|
223
|
+
|
|
224
|
+
describe("buildParams — 4-breakpoint limit safety in OAuth + boundary scenario (#5027)", () => {
|
|
225
|
+
test("OAuth + system prompt + last user: ≤2 breakpoints (no boundary, no tools)", () => {
|
|
226
|
+
const ctx: Context = {
|
|
227
|
+
messages: [userMsg("hello")],
|
|
228
|
+
systemPrompt: "You are a helpful coding assistant.",
|
|
229
|
+
} as Context;
|
|
230
|
+
const params = buildParams(buildParamsModel, ctx, true) as any;
|
|
231
|
+
assert.ok(countBreakpoints(params) <= 4, `expected ≤4 breakpoints, got ${countBreakpoints(params)}`);
|
|
232
|
+
// One on user system block, one on last user msg.
|
|
233
|
+
assert.equal(countBreakpoints(params), 2);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test("OAuth + system prompt + boundary + last user: ≤3 breakpoints (system de-duplicated)", () => {
|
|
237
|
+
const ctx: Context = {
|
|
238
|
+
messages: [
|
|
239
|
+
userMsg("[COMPACTION SUMMARY]", { cacheBreakpoint: true }),
|
|
240
|
+
userMsg("post-compaction turn"),
|
|
241
|
+
],
|
|
242
|
+
systemPrompt: "You are a helpful coding assistant.",
|
|
243
|
+
} as Context;
|
|
244
|
+
const params = buildParams(buildParamsModel, ctx, true) as any;
|
|
245
|
+
const count = countBreakpoints(params);
|
|
246
|
+
assert.ok(count <= 4, `must stay under Anthropic's 4-breakpoint limit, got ${count}`);
|
|
247
|
+
// system(1, the user's prompt — Claude Code header skipped) + boundary(1) + last(1) = 3.
|
|
248
|
+
assert.equal(count, 3);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
test("OAuth + system prompt + tools + boundary + last user: exactly 4 breakpoints (ceiling)", () => {
|
|
252
|
+
// Worst-case breakpoint budget:
|
|
253
|
+
// system(user prompt, 1) + last tool(1) + boundary(1) + last user(1) = 4.
|
|
254
|
+
// The "You are Claude Code" header intentionally carries NO cache_control
|
|
255
|
+
// when a user systemPrompt is present (#5027), which keeps us at 4 rather than 5.
|
|
256
|
+
const tool: Tool = {
|
|
257
|
+
name: "Read",
|
|
258
|
+
description: "Read a file from disk.",
|
|
259
|
+
parameters: {
|
|
260
|
+
type: "object" as const,
|
|
261
|
+
properties: {
|
|
262
|
+
path: { type: "string" },
|
|
263
|
+
},
|
|
264
|
+
required: ["path"],
|
|
265
|
+
} as any,
|
|
266
|
+
};
|
|
267
|
+
const ctx: Context = {
|
|
268
|
+
messages: [
|
|
269
|
+
userMsg("[COMPACTION SUMMARY]", { cacheBreakpoint: true }),
|
|
270
|
+
userMsg("post-compaction turn"),
|
|
271
|
+
],
|
|
272
|
+
systemPrompt: "You are a helpful coding assistant.",
|
|
273
|
+
tools: [tool],
|
|
274
|
+
} as Context;
|
|
275
|
+
const params = buildParams(buildParamsModel, ctx, true) as any;
|
|
276
|
+
const count = countBreakpoints(params);
|
|
277
|
+
assert.ok(count <= 4, `must stay under Anthropic's 4-breakpoint limit, got ${count}`);
|
|
278
|
+
// system(1) + tool(1) + boundary(1) + last-user(1) = 4 exactly.
|
|
279
|
+
assert.equal(count, 4);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test("OAuth header WITHOUT user systemPrompt still cache-marks the header", () => {
|
|
283
|
+
// When there's no user systemPrompt, the Claude Code header IS the
|
|
284
|
+
// last system block, so it correctly carries cache_control.
|
|
285
|
+
const ctx: Context = { messages: [userMsg("hello")] } as Context;
|
|
286
|
+
const params = buildParams(buildParamsModel, ctx, true) as any;
|
|
287
|
+
assert.equal(countBreakpoints(params), 2, "header(1) + last user(1) = 2");
|
|
288
|
+
});
|
|
289
|
+
});
|
|
@@ -262,6 +262,11 @@ export function convertMessages(
|
|
|
262
262
|
cacheControl?: { type: "ephemeral"; ttl?: "1h" },
|
|
263
263
|
): MessageParam[] {
|
|
264
264
|
const params: MessageParam[] = [];
|
|
265
|
+
// Indices into `params` for messages flagged with `cacheBreakpoint: true` —
|
|
266
|
+
// e.g. compaction summaries. We apply cache_control to the most recent one
|
|
267
|
+
// (in addition to the last message) so the stable summary + kept-history
|
|
268
|
+
// block can earn cache reads on every post-compaction turn. (#5027)
|
|
269
|
+
const breakpointIndices: number[] = [];
|
|
265
270
|
|
|
266
271
|
const transformedMessages = transformMessagesWithReport(messages, model, normalizeToolCallId, "anthropic-messages");
|
|
267
272
|
|
|
@@ -275,6 +280,7 @@ export function convertMessages(
|
|
|
275
280
|
role: "user",
|
|
276
281
|
content: sanitizeSurrogates(msg.content),
|
|
277
282
|
});
|
|
283
|
+
if (msg.cacheBreakpoint) breakpointIndices.push(params.length - 1);
|
|
278
284
|
}
|
|
279
285
|
} else {
|
|
280
286
|
const blocks: ContentBlockParam[] = msg.content.map((item) => {
|
|
@@ -306,6 +312,7 @@ export function convertMessages(
|
|
|
306
312
|
role: "user",
|
|
307
313
|
content: filteredBlocks,
|
|
308
314
|
});
|
|
315
|
+
if (msg.cacheBreakpoint) breakpointIndices.push(params.length - 1);
|
|
309
316
|
}
|
|
310
317
|
} else if (msg.role === "assistant") {
|
|
311
318
|
const blocks: ContentBlockParam[] = [];
|
|
@@ -403,31 +410,50 @@ export function convertMessages(
|
|
|
403
410
|
}
|
|
404
411
|
|
|
405
412
|
if (cacheControl && params.length > 0) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
lastMessage.content = [
|
|
418
|
-
{
|
|
419
|
-
type: "text",
|
|
420
|
-
text: lastMessage.content,
|
|
421
|
-
cache_control: cacheControl,
|
|
422
|
-
},
|
|
423
|
-
] as any;
|
|
424
|
-
}
|
|
413
|
+
// Apply to the volatile suffix anchor (last user message) — existing behavior.
|
|
414
|
+
applyCacheControlToParam(params, params.length - 1, cacheControl);
|
|
415
|
+
|
|
416
|
+
// Apply to the most recent compaction-boundary message, if any. Capping at
|
|
417
|
+
// one boundary keeps us safely under Anthropic's 4-breakpoint limit
|
|
418
|
+
// (system + tools + boundary + last user = 4). If multiple
|
|
419
|
+
// cacheBreakpoint messages are present, only the most recent one — the
|
|
420
|
+
// freshest stable boundary — earns the breakpoint. (#5027)
|
|
421
|
+
const mostRecentBreakpoint = breakpointIndices[breakpointIndices.length - 1];
|
|
422
|
+
if (mostRecentBreakpoint !== undefined && mostRecentBreakpoint !== params.length - 1) {
|
|
423
|
+
applyCacheControlToParam(params, mostRecentBreakpoint, cacheControl);
|
|
425
424
|
}
|
|
426
425
|
}
|
|
427
426
|
|
|
428
427
|
return params;
|
|
429
428
|
}
|
|
430
429
|
|
|
430
|
+
/** Apply `cache_control` to the last cacheable block of the user-role param at `index`. No-op for non-user roles. */
|
|
431
|
+
function applyCacheControlToParam(
|
|
432
|
+
params: MessageParam[],
|
|
433
|
+
index: number,
|
|
434
|
+
cacheControl: { type: "ephemeral"; ttl?: "1h" },
|
|
435
|
+
): void {
|
|
436
|
+
const param = params[index];
|
|
437
|
+
if (!param || param.role !== "user") return;
|
|
438
|
+
if (Array.isArray(param.content)) {
|
|
439
|
+
const lastBlock = param.content[param.content.length - 1];
|
|
440
|
+
if (
|
|
441
|
+
lastBlock &&
|
|
442
|
+
(lastBlock.type === "text" || lastBlock.type === "image" || lastBlock.type === "tool_result")
|
|
443
|
+
) {
|
|
444
|
+
(lastBlock as any).cache_control = cacheControl;
|
|
445
|
+
}
|
|
446
|
+
} else if (typeof param.content === "string") {
|
|
447
|
+
param.content = [
|
|
448
|
+
{
|
|
449
|
+
type: "text",
|
|
450
|
+
text: param.content,
|
|
451
|
+
cache_control: cacheControl,
|
|
452
|
+
},
|
|
453
|
+
] as any;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
431
457
|
/** Convert GSD tools to Anthropic SDK tool definitions, applying cache control to the last entry. */
|
|
432
458
|
export function convertTools(
|
|
433
459
|
tools: Tool[],
|
|
@@ -475,11 +501,17 @@ export function buildParams(
|
|
|
475
501
|
};
|
|
476
502
|
|
|
477
503
|
if (isOAuthToken) {
|
|
504
|
+
// Only the LAST system block carries `cache_control` — the boundary
|
|
505
|
+
// covers the entire system prefix up to that point. Putting cache_control
|
|
506
|
+
// on the short "You are Claude Code" header AND the user systemPrompt
|
|
507
|
+
// would consume two of Anthropic's 4 breakpoint slots for redundant
|
|
508
|
+
// coverage, leaving no room for a compaction-summary breakpoint. (#5027)
|
|
509
|
+
const hasUserSystemPrompt = Boolean(context.systemPrompt);
|
|
478
510
|
params.system = [
|
|
479
511
|
{
|
|
480
512
|
type: "text",
|
|
481
513
|
text: "You are Claude Code, Anthropic's official CLI for Claude.",
|
|
482
|
-
...(cacheControl ? { cache_control: cacheControl } : {}),
|
|
514
|
+
...(cacheControl && !hasUserSystemPrompt ? { cache_control: cacheControl } : {}),
|
|
483
515
|
},
|
|
484
516
|
];
|
|
485
517
|
if (context.systemPrompt) {
|
|
@@ -201,6 +201,19 @@ export interface UserMessage {
|
|
|
201
201
|
role: "user";
|
|
202
202
|
content: string | (TextContent | ImageContent)[];
|
|
203
203
|
timestamp: number; // Unix timestamp in milliseconds
|
|
204
|
+
/**
|
|
205
|
+
* Hint to provider adapters that this message marks a stable point in the
|
|
206
|
+
* conversation suitable as a prompt-cache anchor. Providers that support
|
|
207
|
+
* prompt caching (e.g. Anthropic) may apply a `cache_control` breakpoint
|
|
208
|
+
* here so the prefix up to and including this message can earn cache
|
|
209
|
+
* reads on subsequent turns.
|
|
210
|
+
*
|
|
211
|
+
* Optional and additive — providers that do not support caching, or
|
|
212
|
+
* messages without the hint, behave exactly as before. Set by upstream
|
|
213
|
+
* code that knows the message represents a stable boundary (e.g. a
|
|
214
|
+
* compaction summary). (#5027)
|
|
215
|
+
*/
|
|
216
|
+
cacheBreakpoint?: boolean;
|
|
204
217
|
}
|
|
205
218
|
|
|
206
219
|
export interface AssistantMessage {
|
|
@@ -61,6 +61,7 @@ type XmlParameterBlock = {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const xmlParameterBlockPattern = /<parameter\s+name="([^"]+)"\s*>([\s\S]*?)<\/parameter>/g;
|
|
64
|
+
const xmlParameterOpenPattern = /<parameter\s+name="([^"]+)"\s*>/g;
|
|
64
65
|
|
|
65
66
|
function parseXmlParameterValue(raw: string): unknown {
|
|
66
67
|
const trimmed = raw.trim();
|
|
@@ -73,11 +74,31 @@ function parseXmlParameterValue(raw: string): unknown {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
function extractXmlParameterBlocks(text: string): XmlParameterBlock[] {
|
|
76
|
-
const
|
|
77
|
+
const strictBlocks: XmlParameterBlock[] = [];
|
|
78
|
+
let hasNestedParameterOpening = false;
|
|
77
79
|
for (const match of text.matchAll(xmlParameterBlockPattern)) {
|
|
78
|
-
|
|
80
|
+
const rawValue = match[2] ?? "";
|
|
81
|
+
hasNestedParameterOpening ||= rawValue.includes("<parameter");
|
|
82
|
+
strictBlocks.push({
|
|
79
83
|
name: match[1],
|
|
80
|
-
value: parseXmlParameterValue(
|
|
84
|
+
value: parseXmlParameterValue(rawValue),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (strictBlocks.length > 0 && !hasNestedParameterOpening) return strictBlocks;
|
|
88
|
+
|
|
89
|
+
const blocks: XmlParameterBlock[] = [];
|
|
90
|
+
const openings = [...text.matchAll(xmlParameterOpenPattern)];
|
|
91
|
+
for (let i = 0; i < openings.length; i++) {
|
|
92
|
+
const current = openings[i];
|
|
93
|
+
const next = openings[i + 1];
|
|
94
|
+
if (current.index === undefined) continue;
|
|
95
|
+
|
|
96
|
+
const start = current.index + current[0].length;
|
|
97
|
+
const end = next?.index ?? text.length;
|
|
98
|
+
const rawValue = text.slice(start, end).replace(/\s*<\/parameter>\s*$/, "");
|
|
99
|
+
blocks.push({
|
|
100
|
+
name: current[1],
|
|
101
|
+
value: parseXmlParameterValue(rawValue),
|
|
81
102
|
});
|
|
82
103
|
}
|
|
83
104
|
return blocks;
|
|
@@ -147,6 +147,38 @@ describe("repairToolJson — XML parameter tag stripping (#3403)", () => {
|
|
|
147
147
|
assert.equal(parsed.oneLiner, "done");
|
|
148
148
|
assert.ok(!parsed.narrative.includes("<parameter"), "narrative should not retain leaked XML");
|
|
149
149
|
});
|
|
150
|
+
|
|
151
|
+
test("promotes dangling XML parameters trapped inside valid JSON string values", () => {
|
|
152
|
+
const malformed = JSON.stringify({
|
|
153
|
+
narrative:
|
|
154
|
+
'text.\n<parameter name="verification">all tests pass\n<parameter name="verificationEvidence">["npm test"]',
|
|
155
|
+
oneLiner: "done",
|
|
156
|
+
});
|
|
157
|
+
const repaired = repairToolJson(malformed);
|
|
158
|
+
const parsed = JSON.parse(repaired);
|
|
159
|
+
|
|
160
|
+
assert.equal(parsed.narrative, "text.");
|
|
161
|
+
assert.equal(parsed.verification, "all tests pass");
|
|
162
|
+
assert.deepEqual(parsed.verificationEvidence, ["npm test"]);
|
|
163
|
+
assert.equal(parsed.oneLiner, "done");
|
|
164
|
+
assert.ok(!parsed.narrative.includes("<parameter"), "narrative should not retain leaked XML");
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("promotes mixed dangling and closed XML parameters from valid JSON string values", () => {
|
|
168
|
+
const malformed = JSON.stringify({
|
|
169
|
+
narrative:
|
|
170
|
+
'text.\n<parameter name="verification">all tests pass\n<parameter name="verificationEvidence">["npm test"]</parameter>',
|
|
171
|
+
oneLiner: "done",
|
|
172
|
+
});
|
|
173
|
+
const repaired = repairToolJson(malformed);
|
|
174
|
+
const parsed = JSON.parse(repaired);
|
|
175
|
+
|
|
176
|
+
assert.equal(parsed.narrative, "text.");
|
|
177
|
+
assert.equal(parsed.verification, "all tests pass");
|
|
178
|
+
assert.deepEqual(parsed.verificationEvidence, ["npm test"]);
|
|
179
|
+
assert.equal(parsed.oneLiner, "done");
|
|
180
|
+
assert.ok(!parsed.narrative.includes("<parameter"), "narrative should not retain leaked XML");
|
|
181
|
+
});
|
|
150
182
|
});
|
|
151
183
|
|
|
152
184
|
// ═══════════════════════════════════════════════════════════════════════════
|