gsd-pi 2.76.0 → 2.77.0-dev.c9c8932c6
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 +32 -30
- package/dist/claude-cli-check.js +32 -3
- package/dist/cli.js +14 -0
- package/dist/extension-discovery.d.ts +6 -0
- package/dist/extension-discovery.js +37 -0
- package/dist/extension-registry.d.ts +3 -0
- package/dist/extension-sort.d.ts +18 -0
- package/dist/extension-sort.js +114 -0
- package/dist/extension-validator.d.ts +47 -0
- package/dist/extension-validator.js +127 -0
- package/dist/loader.js +35 -7
- package/dist/mcp-server.d.ts +7 -0
- package/dist/mcp-server.js +35 -1
- package/dist/onboarding.js +45 -0
- package/dist/resource-loader.d.ts +1 -1
- package/dist/resource-loader.js +2 -8
- package/dist/resources/agents/researcher.md +1 -1
- package/dist/resources/extensions/claude-code-cli/readiness.js +31 -8
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +134 -57
- package/dist/resources/extensions/cmux/index.js +20 -0
- package/dist/resources/extensions/google-search/extension-manifest.json +5 -4
- package/dist/resources/extensions/google-search/index.js +2 -375
- package/dist/resources/extensions/gsd/auto/loop.js +9 -0
- package/dist/resources/extensions/gsd/auto/phases.js +104 -11
- package/dist/resources/extensions/gsd/auto/run-unit.js +38 -2
- package/dist/resources/extensions/gsd/auto/session.js +22 -1
- package/dist/resources/extensions/gsd/auto-dispatch.js +56 -17
- package/dist/resources/extensions/gsd/auto-model-selection.js +53 -16
- package/dist/resources/extensions/gsd/auto-post-unit.js +59 -2
- package/dist/resources/extensions/gsd/auto-prompts.js +14 -0
- package/dist/resources/extensions/gsd/auto-recovery.js +69 -1
- package/dist/resources/extensions/gsd/auto-start.js +74 -59
- package/dist/resources/extensions/gsd/auto-verification.js +33 -0
- package/dist/resources/extensions/gsd/auto-worktree.js +51 -53
- package/dist/resources/extensions/gsd/auto.js +92 -37
- package/dist/resources/extensions/gsd/blocked-models.js +68 -0
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +93 -1
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +39 -9
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +93 -0
- package/dist/resources/extensions/gsd/bootstrap/memory-tools.js +3 -0
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +23 -0
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +52 -6
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +95 -29
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +34 -2
- package/dist/resources/extensions/gsd/clean-root-preflight.js +93 -0
- package/dist/resources/extensions/gsd/commands-cmux.js +9 -6
- package/dist/resources/extensions/gsd/commands-extensions.js +634 -43
- package/dist/resources/extensions/gsd/commands-extract-learnings.js +54 -89
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +968 -23
- package/dist/resources/extensions/gsd/compaction-snapshot.js +121 -0
- package/dist/resources/extensions/gsd/complexity-classifier.js +5 -3
- package/dist/resources/extensions/gsd/db-writer.js +88 -16
- package/dist/resources/extensions/gsd/dispatch-guard.js +44 -3
- package/dist/resources/extensions/gsd/doctor-git-checks.js +23 -29
- package/dist/resources/extensions/gsd/doctor-providers.js +51 -5
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +1 -0
- package/dist/resources/extensions/gsd/error-classifier.js +31 -3
- package/dist/resources/extensions/gsd/exec-history.js +120 -0
- package/dist/resources/extensions/gsd/exec-sandbox.js +258 -0
- package/dist/resources/extensions/gsd/gitignore.js +1 -0
- package/dist/resources/extensions/gsd/gsd-db.js +168 -23
- package/dist/resources/extensions/gsd/guided-flow.js +190 -1
- package/dist/resources/extensions/gsd/health-widget.js +4 -1
- package/dist/resources/extensions/gsd/hook-emitter.js +108 -0
- package/dist/resources/extensions/gsd/init-wizard.js +15 -1
- package/dist/resources/extensions/gsd/key-manager.js +28 -0
- package/dist/resources/extensions/gsd/memory-backfill.js +126 -0
- package/dist/resources/extensions/gsd/memory-store.js +19 -0
- package/dist/resources/extensions/gsd/model-router.js +36 -3
- package/dist/resources/extensions/gsd/notifications.js +30 -16
- package/dist/resources/extensions/gsd/pre-execution-checks.js +44 -9
- package/dist/resources/extensions/gsd/preferences-types.js +9 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +83 -0
- package/dist/resources/extensions/gsd/preferences.js +17 -17
- package/dist/resources/extensions/gsd/prompt-loader.js +22 -7
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +2 -2
- package/dist/resources/extensions/gsd/prompts/debug-diagnose.md +2 -0
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +8 -0
- package/dist/resources/extensions/gsd/prompts/discuss.md +29 -2
- package/dist/resources/extensions/gsd/prompts/execute-task.md +3 -2
- package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +5 -2
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -0
- package/dist/resources/extensions/gsd/prompts/research-slice.md +1 -0
- package/dist/resources/extensions/gsd/prompts/system.md +1 -0
- package/dist/resources/extensions/gsd/safety/evidence-collector.js +96 -0
- package/dist/resources/extensions/gsd/safety/file-change-validator.js +13 -5
- package/dist/resources/extensions/gsd/safety/safety-harness.js +5 -1
- package/dist/resources/extensions/gsd/state.js +43 -4
- package/dist/resources/extensions/gsd/token-counter.js +22 -5
- package/dist/resources/extensions/gsd/tools/complete-milestone.js +16 -10
- package/dist/resources/extensions/gsd/tools/exec-search-tool.js +59 -0
- package/dist/resources/extensions/gsd/tools/exec-tool.js +126 -0
- package/dist/resources/extensions/gsd/tools/memory-tools.js +26 -1
- package/dist/resources/extensions/gsd/tools/resume-tool.js +23 -0
- package/dist/resources/extensions/gsd/uok/plan-v2.js +20 -3
- package/dist/resources/extensions/gsd/workflow-mcp.js +3 -0
- package/dist/resources/extensions/gsd/workflow-templates/spike.md +6 -0
- package/dist/resources/extensions/gsd/worktree-resolver.js +50 -10
- package/dist/resources/extensions/search-the-web/command-search-provider.js +5 -4
- package/dist/resources/extensions/search-the-web/native-search.js +45 -13
- package/dist/resources/extensions/shared/cmux-events.js +12 -0
- package/dist/resources/extensions/shared/rtk-session-stats.js +1 -2
- package/dist/resources/skills/api-design/SKILL.md +190 -0
- package/dist/resources/skills/create-mcp-server/SKILL.md +121 -0
- package/dist/resources/skills/decompose-into-slices/SKILL.md +139 -0
- package/dist/resources/skills/dependency-upgrade/SKILL.md +158 -0
- package/dist/resources/skills/design-an-interface/SKILL.md +102 -0
- package/dist/resources/skills/forensics/SKILL.md +153 -0
- package/dist/resources/skills/grill-me/SKILL.md +93 -0
- package/dist/resources/skills/handoff/SKILL.md +121 -0
- package/dist/resources/skills/observability/SKILL.md +174 -0
- package/dist/resources/skills/security-review/SKILL.md +181 -0
- package/dist/resources/skills/spike-wrap-up/SKILL.md +138 -0
- package/dist/resources/skills/tdd/SKILL.md +112 -0
- package/dist/resources/skills/verify-before-complete/SKILL.md +98 -0
- package/dist/resources/skills/write-docs/SKILL.md +82 -0
- package/dist/resources/skills/write-milestone-brief/SKILL.md +135 -0
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
- 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 +1 -1
- package/dist/web/standalone/.next/required-server-files.json +4 -4
- 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 +2 -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 +12 -12
- package/dist/web/standalone/.next/server/chunks/63.js +3 -3
- package/dist/web/standalone/.next/server/chunks/6897.js +3 -3
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- package/dist/web/standalone/.next/server/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/static/chunks/2826.d445fb428ef41fa1.js +9 -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-5b113fd32bc2a1c3.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-5fc74f13a25fa1bb.js → webpack-1832629448831fdc.js} +1 -1
- 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/server.js +1 -1
- package/dist/welcome-screen.js +6 -1
- package/dist/wizard.js +2 -0
- package/package.json +14 -12
- package/packages/daemon/package.json +2 -2
- package/packages/mcp-server/dist/remote-questions.d.ts +45 -0
- package/packages/mcp-server/dist/remote-questions.d.ts.map +1 -0
- package/packages/mcp-server/dist/remote-questions.js +732 -0
- package/packages/mcp-server/dist/remote-questions.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts +7 -0
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +70 -8
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/dist/session-manager.d.ts +14 -0
- package/packages/mcp-server/dist/session-manager.d.ts.map +1 -1
- package/packages/mcp-server/dist/session-manager.js +49 -1
- package/packages/mcp-server/dist/session-manager.js.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +163 -25
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/package.json +9 -3
- package/packages/mcp-server/src/mcp-server.test.ts +67 -0
- package/packages/mcp-server/src/readers/readers.test.ts +5 -1
- package/packages/mcp-server/src/remote-questions.test.ts +294 -0
- package/packages/mcp-server/src/remote-questions.ts +916 -0
- package/packages/mcp-server/src/server.ts +89 -14
- package/packages/mcp-server/src/session-manager.ts +43 -1
- package/packages/mcp-server/src/workflow-tools.test.ts +146 -1
- package/packages/mcp-server/src/workflow-tools.ts +215 -43
- package/packages/mcp-server/tsconfig.test.json +19 -0
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/native/package.json +6 -1
- package/packages/native/src/__tests__/clipboard.test.mjs +69 -23
- package/packages/native/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +12 -0
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/types.d.ts +30 -0
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/types.js.map +1 -1
- package/packages/pi-agent-core/package.json +6 -1
- package/packages/pi-agent-core/src/agent-loop.test.ts +220 -15
- package/packages/pi-agent-core/src/agent-loop.ts +14 -0
- package/packages/pi-agent-core/src/types.ts +34 -0
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/models/custom.d.ts +38 -0
- package/packages/pi-ai/dist/models/custom.d.ts.map +1 -1
- package/packages/pi-ai/dist/models/custom.js +41 -0
- package/packages/pi-ai/dist/models/custom.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js +1 -1
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js +13 -0
- package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.js +27 -4
- package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +13 -4
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js +80 -0
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +60 -15
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.d.ts +10 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.js +16 -1
- package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
- package/packages/pi-ai/dist/providers/think-tag-parser.d.ts +17 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.js +75 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.js.map +1 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.js +41 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js +12 -2
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js +164 -14
- package/packages/pi-ai/dist/utils/oauth/github-copilot.test.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +15 -3
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.d.ts +2 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js +67 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.test.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +16 -3
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.d.ts +2 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js +67 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.test.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/oauth-providers.test.d.ts +2 -0
- package/packages/pi-ai/dist/utils/oauth/oauth-providers.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/oauth-providers.test.js +289 -0
- package/packages/pi-ai/dist/utils/oauth/oauth-providers.test.js.map +1 -0
- package/packages/pi-ai/package.json +6 -1
- package/packages/pi-ai/src/models/custom.ts +42 -0
- package/packages/pi-ai/src/providers/anthropic-auth.test.ts +1 -1
- package/packages/pi-ai/src/providers/anthropic-bearer-auth.test.ts +26 -0
- package/packages/pi-ai/src/providers/anthropic-shared.ts +26 -5
- package/packages/pi-ai/src/providers/anthropic.ts +15 -4
- package/packages/pi-ai/src/providers/minimax-tool-name.test.ts +98 -0
- package/packages/pi-ai/src/providers/openai-completions.ts +57 -16
- package/packages/pi-ai/src/providers/simple-options.ts +17 -1
- package/packages/pi-ai/src/providers/think-tag-parser.test.ts +44 -0
- package/packages/pi-ai/src/providers/think-tag-parser.ts +94 -0
- package/packages/pi-ai/src/utils/oauth/github-copilot.test.ts +200 -23
- package/packages/pi-ai/src/utils/oauth/github-copilot.ts +12 -2
- package/packages/pi-ai/src/utils/oauth/google-antigravity.test.ts +84 -0
- package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +15 -5
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.test.ts +84 -0
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +16 -5
- package/packages/pi-ai/src/utils/oauth/oauth-providers.test.ts +363 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js +3 -2
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +32 -2
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +25 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js +105 -6
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.test.js +230 -28
- package/packages/pi-coding-agent/dist/core/compaction/compaction.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +30 -2
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/utils.js +113 -12
- package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js +8 -2
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.js +56 -1
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/discovery-cache.test.js +8 -15
- package/packages/pi-coding-agent/dist/core/discovery-cache.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/extension-discovery.d.ts +25 -0
- package/packages/pi-coding-agent/dist/core/extensions/extension-discovery.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/extension-discovery.js +109 -0
- package/packages/pi-coding-agent/dist/core/extensions/extension-discovery.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/extension-registry.d.ts +67 -0
- package/packages/pi-coding-agent/dist/core/extensions/extension-registry.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/extension-registry.js +167 -0
- package/packages/pi-coding-agent/dist/core/extensions/extension-registry.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts +3 -2
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +28 -8
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +35 -2
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +233 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +212 -2
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/hooks-runner.d.ts +53 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.js +337 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js +234 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/index.js +1 -0
- package/packages/pi-coding-agent/dist/core/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lsp-integration.test.js +11 -0
- package/packages/pi-coding-agent/dist/core/lsp/lsp-integration.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.d.ts +3 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.js +92 -12
- package/packages/pi-coding-agent/dist/core/model-discovery.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.test.js +16 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry-auth-header.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry-auth-header.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-auth-header.test.js +40 -0
- package/packages/pi-coding-agent/dist/core/model-registry-auth-header.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js +2 -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-custom-caps.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.js +203 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-discovery.test.js +61 -1
- package/packages/pi-coding-agent/dist/core/model-registry-discovery.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +5 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +90 -10
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/redact-secrets.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.js +49 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.js +67 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.js +1 -1
- package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +10 -6
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.js +45 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +55 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +3 -3
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/path-utils.test.js +2 -1
- package/packages/pi-coding-agent/dist/core/tools/path-utils.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +5 -4
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.js +13 -7
- package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +7 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +29 -21
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js +14 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +13 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/package.json +6 -1
- package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +3 -2
- package/packages/pi-coding-agent/src/core/agent-session.ts +38 -2
- package/packages/pi-coding-agent/src/core/compaction/compaction.test.ts +368 -28
- package/packages/pi-coding-agent/src/core/compaction/compaction.ts +122 -6
- package/packages/pi-coding-agent/src/core/compaction/utils.ts +111 -13
- package/packages/pi-coding-agent/src/core/compaction-orchestrator.ts +8 -1
- package/packages/pi-coding-agent/src/core/compaction-utils.test.ts +68 -1
- package/packages/pi-coding-agent/src/core/discovery-cache.test.ts +9 -18
- package/packages/pi-coding-agent/src/core/extensions/extension-discovery.ts +119 -0
- package/packages/pi-coding-agent/src/core/extensions/extension-registry.ts +222 -0
- package/packages/pi-coding-agent/src/core/extensions/index.ts +16 -0
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +29 -11
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +351 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +266 -0
- package/packages/pi-coding-agent/src/core/hooks-runner.test.ts +269 -0
- package/packages/pi-coding-agent/src/core/hooks-runner.ts +460 -0
- package/packages/pi-coding-agent/src/core/index.ts +10 -0
- package/packages/pi-coding-agent/src/core/lsp/lsp-integration.test.ts +13 -0
- package/packages/pi-coding-agent/src/core/model-discovery.test.ts +19 -0
- package/packages/pi-coding-agent/src/core/model-discovery.ts +99 -12
- package/packages/pi-coding-agent/src/core/model-registry-auth-header.test.ts +44 -0
- package/packages/pi-coding-agent/src/core/model-registry-auth-mode.test.ts +2 -2
- package/packages/pi-coding-agent/src/core/model-registry-custom-caps.test.ts +245 -0
- package/packages/pi-coding-agent/src/core/model-registry-discovery.test.ts +75 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +102 -10
- package/packages/pi-coding-agent/src/core/redact-secrets.test.ts +86 -0
- package/packages/pi-coding-agent/src/core/redact-secrets.ts +58 -0
- package/packages/pi-coding-agent/src/core/resource-loader.ts +1 -1
- package/packages/pi-coding-agent/src/core/session-manager.test.ts +65 -1
- package/packages/pi-coding-agent/src/core/session-manager.ts +10 -6
- package/packages/pi-coding-agent/src/core/settings-manager.ts +57 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +3 -3
- package/packages/pi-coding-agent/src/core/tools/path-utils.test.ts +2 -1
- package/packages/pi-coding-agent/src/index.ts +16 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +6 -6
- package/packages/pi-coding-agent/src/modes/interactive/components/provider-manager.ts +16 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts +36 -22
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +14 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +13 -1
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/dist/__tests__/autocomplete.test.js +12 -5
- package/packages/pi-tui/dist/__tests__/autocomplete.test.js.map +1 -1
- package/packages/pi-tui/package.json +6 -1
- package/packages/pi-tui/src/__tests__/autocomplete.test.ts +20 -5
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/packages/rpc-client/package.json +6 -1
- package/pkg/package.json +1 -1
- package/scripts/install.js +512 -0
- package/scripts/lib/workspace-manifest.cjs +86 -0
- package/scripts/link-workspace-packages.cjs +5 -16
- package/scripts/postinstall.js +9 -178
- package/src/resources/agents/researcher.md +1 -1
- package/src/resources/extensions/claude-code-cli/readiness.ts +32 -8
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +148 -61
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +236 -5
- package/src/resources/extensions/cmux/index.ts +35 -10
- package/src/resources/extensions/google-search/extension-manifest.json +5 -4
- package/src/resources/extensions/google-search/index.ts +8 -470
- package/src/resources/extensions/gsd/auto/loop-deps.ts +15 -1
- package/src/resources/extensions/gsd/auto/loop.ts +9 -0
- package/src/resources/extensions/gsd/auto/phases.ts +131 -10
- package/src/resources/extensions/gsd/auto/run-unit.ts +40 -2
- package/src/resources/extensions/gsd/auto/session.ts +35 -2
- package/src/resources/extensions/gsd/auto/types.ts +1 -1
- package/src/resources/extensions/gsd/auto-dispatch.ts +59 -16
- package/src/resources/extensions/gsd/auto-model-selection.ts +71 -15
- package/src/resources/extensions/gsd/auto-post-unit.ts +62 -3
- package/src/resources/extensions/gsd/auto-prompts.ts +28 -1
- package/src/resources/extensions/gsd/auto-recovery.ts +62 -1
- package/src/resources/extensions/gsd/auto-start.ts +80 -74
- package/src/resources/extensions/gsd/auto-verification.ts +33 -0
- package/src/resources/extensions/gsd/auto-worktree.ts +62 -63
- package/src/resources/extensions/gsd/auto.ts +100 -41
- package/src/resources/extensions/gsd/blocked-models.ts +98 -0
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +120 -1
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +40 -9
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +109 -0
- package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +5 -0
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +26 -0
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +54 -6
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +102 -35
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +35 -2
- package/src/resources/extensions/gsd/clean-root-preflight.ts +111 -0
- package/src/resources/extensions/gsd/commands-cmux.ts +10 -6
- package/src/resources/extensions/gsd/commands-extensions.ts +747 -41
- package/src/resources/extensions/gsd/commands-extract-learnings.ts +55 -90
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +898 -32
- package/src/resources/extensions/gsd/compaction-snapshot.ts +165 -0
- package/src/resources/extensions/gsd/complexity-classifier.ts +5 -3
- package/src/resources/extensions/gsd/db-writer.ts +88 -17
- package/src/resources/extensions/gsd/dispatch-guard.ts +44 -2
- package/src/resources/extensions/gsd/doctor-git-checks.ts +23 -27
- package/src/resources/extensions/gsd/doctor-providers.ts +59 -6
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +2 -0
- package/src/resources/extensions/gsd/error-classifier.ts +36 -3
- package/src/resources/extensions/gsd/exec-history.ts +153 -0
- package/src/resources/extensions/gsd/exec-sandbox.ts +326 -0
- package/src/resources/extensions/gsd/gitignore.ts +1 -1
- package/src/resources/extensions/gsd/gsd-db.ts +186 -23
- package/src/resources/extensions/gsd/guided-flow.ts +222 -1
- package/src/resources/extensions/gsd/health-widget.ts +3 -1
- package/src/resources/extensions/gsd/hook-emitter.ts +188 -0
- package/src/resources/extensions/gsd/init-wizard.ts +15 -1
- package/src/resources/extensions/gsd/journal.ts +2 -1
- package/src/resources/extensions/gsd/key-manager.ts +28 -0
- package/src/resources/extensions/gsd/memory-backfill.ts +140 -0
- package/src/resources/extensions/gsd/memory-store.ts +26 -0
- package/src/resources/extensions/gsd/model-router.ts +42 -1
- package/src/resources/extensions/gsd/notifications.ts +27 -15
- package/src/resources/extensions/gsd/pre-execution-checks.ts +46 -10
- package/src/resources/extensions/gsd/preferences-types.ts +46 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +79 -0
- package/src/resources/extensions/gsd/preferences.ts +17 -17
- package/src/resources/extensions/gsd/prompt-loader.ts +30 -7
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/complete-slice.md +2 -2
- package/src/resources/extensions/gsd/prompts/debug-diagnose.md +2 -0
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +8 -0
- package/src/resources/extensions/gsd/prompts/discuss.md +29 -2
- package/src/resources/extensions/gsd/prompts/execute-task.md +3 -2
- package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +5 -2
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -0
- package/src/resources/extensions/gsd/prompts/research-slice.md +1 -0
- package/src/resources/extensions/gsd/prompts/system.md +1 -0
- package/src/resources/extensions/gsd/safety/evidence-collector.ts +119 -0
- package/src/resources/extensions/gsd/safety/file-change-validator.ts +17 -4
- package/src/resources/extensions/gsd/safety/safety-harness.ts +9 -0
- package/src/resources/extensions/gsd/state.ts +45 -4
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +188 -2
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +95 -1
- package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +12 -0
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +122 -0
- package/src/resources/extensions/gsd/tests/auto-start-bootstrap-await-3420.test.ts +141 -0
- package/src/resources/extensions/gsd/tests/auto-start-clean-runtime-db-gated.test.ts +63 -0
- package/src/resources/extensions/gsd/tests/auto-start-model-capture.test.ts +33 -3
- package/src/resources/extensions/gsd/tests/auto-thinking-restore.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/blocked-models.test.ts +98 -0
- package/src/resources/extensions/gsd/tests/bundled-skill-triggers.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +186 -0
- package/src/resources/extensions/gsd/tests/cmux.test.ts +5 -9
- package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +68 -66
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +123 -0
- package/src/resources/extensions/gsd/tests/complete-milestone-false-merge.test.ts +15 -0
- package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +61 -1
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/complete-task.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/complexity-classifier.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/derive-state-helpers.test.ts +8 -4
- package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +9 -9
- package/src/resources/extensions/gsd/tests/dispatch-guard-summary-db-mismatch.test.ts +77 -0
- package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +148 -3
- package/src/resources/extensions/gsd/tests/double-merge-guard.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/ensure-db-open.test.ts +306 -1
- package/src/resources/extensions/gsd/tests/escalation.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/exec-history.test.ts +237 -0
- package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +210 -0
- package/src/resources/extensions/gsd/tests/file-change-validator.test.ts +58 -0
- package/src/resources/extensions/gsd/tests/flat-rate-routing-guard.test.ts +40 -9
- package/src/resources/extensions/gsd/tests/freeform-decisions.test.ts +62 -0
- package/src/resources/extensions/gsd/tests/google-search-stub.test.ts +121 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +447 -1
- package/src/resources/extensions/gsd/tests/init-wizard.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/integration/doctor-git-symlink-cwd.test.ts +11 -0
- package/src/resources/extensions/gsd/tests/integration/doctor-git.test.ts +78 -0
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/integration/gitignore-tracked-gsd.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/integration/idle-recovery.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/integration/worktree-e2e.test.ts +11 -0
- package/src/resources/extensions/gsd/tests/interactive-routing-bypass.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/issue-4540-regressions.test.ts +288 -0
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +37 -0
- package/src/resources/extensions/gsd/tests/key-manager.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/load-memory-block.test.ts +36 -0
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/memory-pressure-stuck-state.test.ts +12 -0
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/milestone-status-authoritative.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/milestone-transition-state-rebuild.test.ts +4 -2
- package/src/resources/extensions/gsd/tests/parallel-commit-scope.test.ts +5 -0
- package/src/resources/extensions/gsd/tests/parallel-research-dispatch.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/parallel-skill-prompt-integration.test.ts +150 -0
- package/src/resources/extensions/gsd/tests/plan-gate-failed-doctor-heal-hint.test.ts +37 -0
- package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/pre-exec-gate-loop.test.ts +272 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +356 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +110 -0
- package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/prompt-loader-extension-dir.test.ts +49 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +103 -4
- package/src/resources/extensions/gsd/tests/ready-phrase-no-files-4573.test.ts +388 -0
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +9 -3
- package/src/resources/extensions/gsd/tests/resume-dispatch-worktree.test.ts +230 -0
- package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +205 -0
- package/src/resources/extensions/gsd/tests/save-gate-result-render.test.ts +95 -0
- package/src/resources/extensions/gsd/tests/schema-v21-sequence.test.ts +413 -0
- package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +32 -40
- package/src/resources/extensions/gsd/tests/stash-queued-context-files.test.ts +56 -0
- package/src/resources/extensions/gsd/tests/token-counter.test.ts +105 -1
- package/src/resources/extensions/gsd/tests/tool-compatibility.test.ts +107 -0
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/validate-extension-package.test.ts +168 -0
- package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +136 -8
- package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +25 -2
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +65 -2
- package/src/resources/extensions/gsd/tests/worktree-db.test.ts +35 -0
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +6 -1
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +78 -5
- package/src/resources/extensions/gsd/tests/write-gate.test.ts +64 -0
- package/src/resources/extensions/gsd/tests/zombie-gsd-state.test.ts +3 -1
- package/src/resources/extensions/gsd/token-counter.ts +22 -5
- package/src/resources/extensions/gsd/tools/complete-milestone.ts +15 -9
- package/src/resources/extensions/gsd/tools/exec-search-tool.ts +81 -0
- package/src/resources/extensions/gsd/tools/exec-tool.ts +183 -0
- package/src/resources/extensions/gsd/tools/memory-tools.ts +31 -1
- package/src/resources/extensions/gsd/tools/resume-tool.ts +40 -0
- package/src/resources/extensions/gsd/uok/plan-v2.ts +26 -3
- package/src/resources/extensions/gsd/workflow-logger.ts +4 -1
- package/src/resources/extensions/gsd/workflow-mcp.ts +3 -0
- package/src/resources/extensions/gsd/workflow-templates/spike.md +6 -0
- package/src/resources/extensions/gsd/worktree-resolver.ts +54 -9
- package/src/resources/extensions/search-the-web/command-search-provider.ts +5 -4
- package/src/resources/extensions/search-the-web/native-search.ts +48 -12
- package/src/resources/extensions/shared/cmux-events.ts +59 -0
- package/src/resources/extensions/shared/rtk-session-stats.ts +1 -2
- package/src/resources/skills/api-design/SKILL.md +190 -0
- package/src/resources/skills/create-mcp-server/SKILL.md +121 -0
- package/src/resources/skills/decompose-into-slices/SKILL.md +139 -0
- package/src/resources/skills/dependency-upgrade/SKILL.md +158 -0
- package/src/resources/skills/design-an-interface/SKILL.md +102 -0
- package/src/resources/skills/forensics/SKILL.md +153 -0
- package/src/resources/skills/grill-me/SKILL.md +93 -0
- package/src/resources/skills/handoff/SKILL.md +121 -0
- package/src/resources/skills/observability/SKILL.md +174 -0
- package/src/resources/skills/security-review/SKILL.md +181 -0
- package/src/resources/skills/spike-wrap-up/SKILL.md +138 -0
- package/src/resources/skills/tdd/SKILL.md +112 -0
- package/src/resources/skills/verify-before-complete/SKILL.md +98 -0
- package/src/resources/skills/write-docs/SKILL.md +82 -0
- package/src/resources/skills/write-milestone-brief/SKILL.md +135 -0
- package/dist/web/standalone/.next/static/chunks/2826.e59e8578e2e28639.js +0 -9
- 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/{ssX7BLv3Dw9Fb4CtrCGeR → H51SzzS_EEgdBsDVhrLBv}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{ssX7BLv3Dw9Fb4CtrCGeR → H51SzzS_EEgdBsDVhrLBv}/_ssgManifest.js +0 -0
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
computeFileLists,
|
|
17
17
|
createFileOps,
|
|
18
18
|
createSummarizationMessage,
|
|
19
|
+
estimateSerializedTokens,
|
|
19
20
|
extractFileOpsFromMessage,
|
|
20
21
|
extractTextContent,
|
|
21
22
|
type FileOperations,
|
|
@@ -500,7 +501,13 @@ export function chunkMessages(messages: AgentMessage[], maxTokensPerChunk: numbe
|
|
|
500
501
|
let currentTokens = 0;
|
|
501
502
|
|
|
502
503
|
for (const msg of messages) {
|
|
503
|
-
|
|
504
|
+
// Use POST-truncation token estimate: serializeConversation caps every
|
|
505
|
+
// large content block to TOOL_RESULT_MAX_CHARS before sending to the LLM,
|
|
506
|
+
// so chunk sizing must reflect what the LLM will actually see. Using the
|
|
507
|
+
// pre-truncation `estimateTokens` here was the root cause of issue #4665:
|
|
508
|
+
// a single 400K-char tool result looked like 100K tokens but serialized
|
|
509
|
+
// to ~600 tokens, producing tens of tiny information-starved chunks.
|
|
510
|
+
const msgTokens = estimateSerializedTokens(msg);
|
|
504
511
|
|
|
505
512
|
if (currentChunk.length > 0 && currentTokens + msgTokens > maxTokensPerChunk) {
|
|
506
513
|
// Current chunk is full — start a new one
|
|
@@ -520,6 +527,39 @@ export function chunkMessages(messages: AgentMessage[], maxTokensPerChunk: numbe
|
|
|
520
527
|
return chunks;
|
|
521
528
|
}
|
|
522
529
|
|
|
530
|
+
// ============================================================================
|
|
531
|
+
// Degenerate summary detection (issue #4665)
|
|
532
|
+
// ============================================================================
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Heuristic: does this summary look like the "empty conversation" degenerate
|
|
536
|
+
* output that poisons the iterative UPDATE_SUMMARIZATION_PROMPT chain?
|
|
537
|
+
*
|
|
538
|
+
* The LLM occasionally returns short empty-sounding summaries when a chunk
|
|
539
|
+
* contains only truncated tool-call preambles without results. If the chain
|
|
540
|
+
* propagates this forward, every subsequent chunk is told to "PRESERVE all
|
|
541
|
+
* existing information" — which preserves the emptiness.
|
|
542
|
+
*
|
|
543
|
+
* Conservative match: an explicit substring hit OR length < 100 chars. We keep
|
|
544
|
+
* this deterministic (no fuzzy scoring) because fuzzy matching is where
|
|
545
|
+
* quality gates become flaky and hard to test.
|
|
546
|
+
*
|
|
547
|
+
* Exported for test access only.
|
|
548
|
+
*/
|
|
549
|
+
export function isDegenerateSummary(summary: string | undefined): boolean {
|
|
550
|
+
// undefined means "no summary was produced yet" (first chunk before any call)
|
|
551
|
+
// — not degenerate. Empty string IS degenerate: the LLM returned nothing.
|
|
552
|
+
if (summary === undefined) return false;
|
|
553
|
+
const lower = summary.toLowerCase();
|
|
554
|
+
if (lower.includes("empty conversation")) return true;
|
|
555
|
+
if (lower.includes("no conversation to summarize")) return true;
|
|
556
|
+
if (lower.includes("no messages to summarize")) return true;
|
|
557
|
+
// Length guard: any summary shorter than 100 chars is almost certainly
|
|
558
|
+
// degenerate for a multi-chunk pipeline.
|
|
559
|
+
if (summary.trim().length < 100) return true;
|
|
560
|
+
return false;
|
|
561
|
+
}
|
|
562
|
+
|
|
523
563
|
/** Type for the completion function, allowing injection for tests. */
|
|
524
564
|
type CompleteFn = typeof completeSimple;
|
|
525
565
|
|
|
@@ -545,10 +585,12 @@ export async function generateSummary(
|
|
|
545
585
|
): Promise<string> {
|
|
546
586
|
const complete = _completeFn ?? completeSimple;
|
|
547
587
|
|
|
548
|
-
// Estimate total tokens
|
|
588
|
+
// Estimate total tokens using the POST-truncation serializer view (issue #4665).
|
|
589
|
+
// serializeConversation caps large content blocks to TOOL_RESULT_MAX_CHARS
|
|
590
|
+
// before sending, so asking "does this fit in one pass?" must reflect that.
|
|
549
591
|
let totalTokens = 0;
|
|
550
592
|
for (const msg of currentMessages) {
|
|
551
|
-
totalTokens +=
|
|
593
|
+
totalTokens += estimateSerializedTokens(msg);
|
|
552
594
|
}
|
|
553
595
|
|
|
554
596
|
// Overhead for the prompt framing, system prompt, and response budget
|
|
@@ -561,12 +603,12 @@ export async function generateSummary(
|
|
|
561
603
|
return singlePassSummary(currentMessages, model, reserveTokens, apiKey, signal, customInstructions, previousSummary, complete);
|
|
562
604
|
}
|
|
563
605
|
|
|
564
|
-
// Chunked fallback: split messages and iteratively summarize
|
|
606
|
+
// Chunked fallback: split messages and iteratively summarize.
|
|
565
607
|
const chunks = chunkMessages(currentMessages, maxInputTokens);
|
|
566
608
|
let runningSummary = previousSummary;
|
|
567
609
|
|
|
568
610
|
for (let i = 0; i < chunks.length; i++) {
|
|
569
|
-
|
|
611
|
+
const chunkSummary = await singlePassSummary(
|
|
570
612
|
chunks[i],
|
|
571
613
|
model,
|
|
572
614
|
reserveTokens,
|
|
@@ -576,9 +618,83 @@ export async function generateSummary(
|
|
|
576
618
|
runningSummary,
|
|
577
619
|
complete,
|
|
578
620
|
);
|
|
621
|
+
|
|
622
|
+
// Degenerate-summary guard (issue #4665). UPDATE_SUMMARIZATION_PROMPT says
|
|
623
|
+
// "PRESERVE all existing information" — so if a chunk summary is empty or
|
|
624
|
+
// near-empty, propagating it forward actively reinforces the emptiness
|
|
625
|
+
// for every subsequent chunk.
|
|
626
|
+
//
|
|
627
|
+
// Strategy per chunk:
|
|
628
|
+
// 1. If degenerate, retry once. For the FIRST chunk with no prior
|
|
629
|
+
// context, retry with the initial prompt (undefined previousSummary)
|
|
630
|
+
// to break the poison chain at its source. For later chunks, retry
|
|
631
|
+
// with the same prompt state (runningSummary preserved) since the
|
|
632
|
+
// first failure may have been transient.
|
|
633
|
+
// 2. If the retry is also degenerate, warn and continue WITHOUT
|
|
634
|
+
// updating runningSummary — losing that chunk's content is still
|
|
635
|
+
// preferable to propagating emptiness forward, but the drop is now
|
|
636
|
+
// observable in logs.
|
|
637
|
+
if (isDegenerateSummary(chunkSummary)) {
|
|
638
|
+
const retryPreviousSummary = i === 0 && runningSummary === undefined
|
|
639
|
+
? undefined
|
|
640
|
+
: runningSummary;
|
|
641
|
+
const retry = await singlePassSummary(
|
|
642
|
+
chunks[i],
|
|
643
|
+
model,
|
|
644
|
+
reserveTokens,
|
|
645
|
+
apiKey,
|
|
646
|
+
signal,
|
|
647
|
+
customInstructions,
|
|
648
|
+
retryPreviousSummary,
|
|
649
|
+
complete,
|
|
650
|
+
);
|
|
651
|
+
if (!isDegenerateSummary(retry)) {
|
|
652
|
+
runningSummary = retry;
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
// Both attempts degenerate — log and skip without poisoning the chain.
|
|
656
|
+
// Using process.stderr directly so this doesn't require the logger
|
|
657
|
+
// dependency graph. Visible to operators reviewing compaction health.
|
|
658
|
+
process.stderr.write(
|
|
659
|
+
`[compaction] WARN: chunk ${i + 1}/${chunks.length} produced a degenerate summary on both attempts; dropping chunk content from summary.\n`,
|
|
660
|
+
);
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
runningSummary = chunkSummary;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// R6 (issue #4665 follow-up): if every chunk was degenerate and we have no
|
|
668
|
+
// runningSummary, do NOT silently return "" — the caller would write an
|
|
669
|
+
// empty compaction entry, destroying all context with no signal. Fall back
|
|
670
|
+
// to the original previousSummary if available; otherwise throw a named
|
|
671
|
+
// error so the compaction pipeline can skip appending the entry.
|
|
672
|
+
if (runningSummary === undefined) {
|
|
673
|
+
if (previousSummary !== undefined) {
|
|
674
|
+
process.stderr.write(
|
|
675
|
+
"[compaction] WARN: every chunk produced a degenerate summary; falling back to existing previousSummary.\n",
|
|
676
|
+
);
|
|
677
|
+
return previousSummary;
|
|
678
|
+
}
|
|
679
|
+
throw new CompactionProducedNoSummaryError(
|
|
680
|
+
`Compaction produced no usable summary: all ${chunks.length} chunk(s) were degenerate and no previousSummary was available.`,
|
|
681
|
+
);
|
|
579
682
|
}
|
|
580
683
|
|
|
581
|
-
return runningSummary
|
|
684
|
+
return runningSummary;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Thrown when `generateSummary` could not produce any non-degenerate summary
|
|
689
|
+
* from the provided messages AND no previous summary was available to fall
|
|
690
|
+
* back to. Callers should catch this and skip writing a compaction entry
|
|
691
|
+
* rather than writing an empty string to the session history (issue #4665).
|
|
692
|
+
*/
|
|
693
|
+
export class CompactionProducedNoSummaryError extends Error {
|
|
694
|
+
constructor(message: string) {
|
|
695
|
+
super(message);
|
|
696
|
+
this.name = "CompactionProducedNoSummaryError";
|
|
697
|
+
}
|
|
582
698
|
}
|
|
583
699
|
|
|
584
700
|
/**
|
|
@@ -3,8 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { AgentMessage } from "@gsd/pi-agent-core";
|
|
6
|
-
import type { Message } from "@gsd/pi-ai";
|
|
6
|
+
import type { AssistantMessage, Message } from "@gsd/pi-ai";
|
|
7
7
|
import { TOOL_RESULT_MAX_CHARS } from "../constants.js";
|
|
8
|
+
|
|
9
|
+
// Head/tail split for head+tail truncation. Keeps first half + last half up to
|
|
10
|
+
// TOOL_RESULT_MAX_CHARS total. Tool results and other large blocks put their
|
|
11
|
+
// information-dense content (exit codes, verdicts, commit hashes, pass/fail
|
|
12
|
+
// counts) at the tail — pure head-slicing discards that signal. See issue #4665.
|
|
13
|
+
const HEAD_TAIL_HALF = Math.floor(TOOL_RESULT_MAX_CHARS / 2);
|
|
8
14
|
import {
|
|
9
15
|
createBranchSummaryMessage,
|
|
10
16
|
createCompactionSummaryMessage,
|
|
@@ -189,13 +195,20 @@ export function createSummarizationMessage(promptText: string): [{ role: "user";
|
|
|
189
195
|
// TOOL_RESULT_MAX_CHARS imported from ../constants.js
|
|
190
196
|
|
|
191
197
|
/**
|
|
192
|
-
* Truncate text to a maximum character length for summarization
|
|
193
|
-
*
|
|
198
|
+
* Truncate text to a maximum character length for summarization, keeping both
|
|
199
|
+
* the head AND the tail. The tail is where information density lives for tool
|
|
200
|
+
* output (exit codes, verdicts, pass/fail counts, commit hashes), so pure
|
|
201
|
+
* head-slicing produced degenerate summaries (see issue #4665).
|
|
202
|
+
*
|
|
203
|
+
* Exported for test access only.
|
|
194
204
|
*/
|
|
195
|
-
function truncateForSummary(text: string, maxChars: number): string {
|
|
205
|
+
export function truncateForSummary(text: string, maxChars: number): string {
|
|
196
206
|
if (text.length <= maxChars) return text;
|
|
197
|
-
const
|
|
198
|
-
|
|
207
|
+
const half = Math.floor(maxChars / 2);
|
|
208
|
+
const head = text.slice(0, half);
|
|
209
|
+
const tail = text.slice(text.length - half);
|
|
210
|
+
const truncatedChars = text.length - (head.length + tail.length);
|
|
211
|
+
return `${head}\n\n[... ${truncatedChars} more characters truncated ...]\n\n${tail}`;
|
|
199
212
|
}
|
|
200
213
|
|
|
201
214
|
/**
|
|
@@ -203,11 +216,15 @@ function truncateForSummary(text: string, maxChars: number): string {
|
|
|
203
216
|
* This prevents the model from treating it as a conversation to continue.
|
|
204
217
|
* Call convertToLlm() first to handle custom message types.
|
|
205
218
|
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
219
|
+
* Every content block with a character count above TOOL_RESULT_MAX_CHARS is
|
|
220
|
+
* head+tail truncated. The issue #4665 fix broadened this from tool-results-
|
|
221
|
+
* only to every block type — large user pastes, assistant thinking, tool-call
|
|
222
|
+
* args, and bashExecution-derived blocks also bloat summarization input if
|
|
223
|
+
* uncapped.
|
|
208
224
|
*/
|
|
209
225
|
export function serializeConversation(messages: Message[]): string {
|
|
210
226
|
const parts: string[] = [];
|
|
227
|
+
const cap = TOOL_RESULT_MAX_CHARS;
|
|
211
228
|
|
|
212
229
|
for (const msg of messages) {
|
|
213
230
|
if (msg.role === "user") {
|
|
@@ -218,7 +235,7 @@ export function serializeConversation(messages: Message[]): string {
|
|
|
218
235
|
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
219
236
|
.map((c) => c.text)
|
|
220
237
|
.join("");
|
|
221
|
-
if (content) parts.push(`**User said:** ${content}`);
|
|
238
|
+
if (content) parts.push(`**User said:** ${truncateForSummary(content, cap)}`);
|
|
222
239
|
} else if (msg.role === "assistant") {
|
|
223
240
|
const textParts: string[] = [];
|
|
224
241
|
const thinkingParts: string[] = [];
|
|
@@ -239,13 +256,13 @@ export function serializeConversation(messages: Message[]): string {
|
|
|
239
256
|
}
|
|
240
257
|
|
|
241
258
|
if (thinkingParts.length > 0) {
|
|
242
|
-
parts.push(`**Assistant thinking:** ${thinkingParts.join("\n")}`);
|
|
259
|
+
parts.push(`**Assistant thinking:** ${truncateForSummary(thinkingParts.join("\n"), cap)}`);
|
|
243
260
|
}
|
|
244
261
|
if (textParts.length > 0) {
|
|
245
|
-
parts.push(`**Assistant responded:** ${textParts.join("\n")}`);
|
|
262
|
+
parts.push(`**Assistant responded:** ${truncateForSummary(textParts.join("\n"), cap)}`);
|
|
246
263
|
}
|
|
247
264
|
if (toolCalls.length > 0) {
|
|
248
|
-
parts.push(`**Assistant tool calls:** ${toolCalls.join("; ")}`);
|
|
265
|
+
parts.push(`**Assistant tool calls:** ${truncateForSummary(toolCalls.join("; "), cap)}`);
|
|
249
266
|
}
|
|
250
267
|
} else if (msg.role === "toolResult") {
|
|
251
268
|
const content = msg.content
|
|
@@ -253,7 +270,7 @@ export function serializeConversation(messages: Message[]): string {
|
|
|
253
270
|
.map((c) => c.text)
|
|
254
271
|
.join("");
|
|
255
272
|
if (content) {
|
|
256
|
-
parts.push(`**Tool result:** ${truncateForSummary(content,
|
|
273
|
+
parts.push(`**Tool result:** ${truncateForSummary(content, cap)}`);
|
|
257
274
|
}
|
|
258
275
|
}
|
|
259
276
|
}
|
|
@@ -261,6 +278,87 @@ export function serializeConversation(messages: Message[]): string {
|
|
|
261
278
|
return parts.join("\n\n");
|
|
262
279
|
}
|
|
263
280
|
|
|
281
|
+
// ============================================================================
|
|
282
|
+
// Token estimation for post-serialization size
|
|
283
|
+
// ============================================================================
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Estimate tokens for a message AFTER the summarization serializer will have
|
|
287
|
+
* capped its large content blocks. Use this when deciding chunk sizes for
|
|
288
|
+
* summarization — NOT when deciding whether to compact in the first place
|
|
289
|
+
* (that needs the real in-memory content size via `estimateTokens`).
|
|
290
|
+
*
|
|
291
|
+
* See issue #4665: the old chunker used real content size but the serializer
|
|
292
|
+
* truncated tool results to 2000 chars, so a single 400K-char tool result
|
|
293
|
+
* looked like 100K tokens (triggering tens of unnecessary chunks) but actually
|
|
294
|
+
* serialized to ~600 tokens.
|
|
295
|
+
*
|
|
296
|
+
* Colocated with `truncateForSummary` / `serializeConversation` so the two
|
|
297
|
+
* stay in sync — if the serialization cap changes, both functions pick it up
|
|
298
|
+
* from `TOOL_RESULT_MAX_CHARS`.
|
|
299
|
+
*/
|
|
300
|
+
export function estimateSerializedTokens(message: AgentMessage): number {
|
|
301
|
+
const cap = TOOL_RESULT_MAX_CHARS;
|
|
302
|
+
const capLen = (len: number) => Math.min(len, cap);
|
|
303
|
+
let chars = 0;
|
|
304
|
+
|
|
305
|
+
switch (message.role) {
|
|
306
|
+
case "user": {
|
|
307
|
+
const content = (message as { content: string | Array<{ type: string; text?: string }> }).content;
|
|
308
|
+
if (typeof content === "string") {
|
|
309
|
+
chars = capLen(content.length);
|
|
310
|
+
} else if (Array.isArray(content)) {
|
|
311
|
+
let total = 0;
|
|
312
|
+
for (const block of content) {
|
|
313
|
+
if (block.type === "text" && block.text) total += block.text.length;
|
|
314
|
+
}
|
|
315
|
+
chars = capLen(total);
|
|
316
|
+
}
|
|
317
|
+
return Math.ceil(chars / 4);
|
|
318
|
+
}
|
|
319
|
+
case "assistant": {
|
|
320
|
+
const assistant = message as AssistantMessage;
|
|
321
|
+
let textLen = 0;
|
|
322
|
+
let thinkingLen = 0;
|
|
323
|
+
let toolCallsLen = 0;
|
|
324
|
+
for (const block of assistant.content) {
|
|
325
|
+
if (block.type === "text") textLen += block.text.length;
|
|
326
|
+
else if (block.type === "thinking") thinkingLen += block.thinking.length;
|
|
327
|
+
else if (block.type === "toolCall") toolCallsLen += block.name.length + JSON.stringify(block.arguments).length;
|
|
328
|
+
}
|
|
329
|
+
chars = capLen(textLen) + capLen(thinkingLen) + capLen(toolCallsLen);
|
|
330
|
+
return Math.ceil(chars / 4);
|
|
331
|
+
}
|
|
332
|
+
case "custom":
|
|
333
|
+
case "toolResult": {
|
|
334
|
+
if (typeof message.content === "string") {
|
|
335
|
+
chars = capLen(message.content.length);
|
|
336
|
+
} else {
|
|
337
|
+
let textLen = 0;
|
|
338
|
+
let imageChars = 0;
|
|
339
|
+
for (const block of message.content) {
|
|
340
|
+
if (block.type === "text" && block.text) textLen += block.text.length;
|
|
341
|
+
if (block.type === "image") imageChars += 4800;
|
|
342
|
+
}
|
|
343
|
+
chars = capLen(textLen) + imageChars;
|
|
344
|
+
}
|
|
345
|
+
return Math.ceil(chars / 4);
|
|
346
|
+
}
|
|
347
|
+
case "bashExecution": {
|
|
348
|
+
chars = capLen(message.command.length + message.output.length);
|
|
349
|
+
return Math.ceil(chars / 4);
|
|
350
|
+
}
|
|
351
|
+
case "branchSummary":
|
|
352
|
+
case "compactionSummary": {
|
|
353
|
+
// Summary messages are already concise; don't truncate them.
|
|
354
|
+
chars = message.summary.length;
|
|
355
|
+
return Math.ceil(chars / 4);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return 0;
|
|
360
|
+
}
|
|
361
|
+
|
|
264
362
|
// ============================================================================
|
|
265
363
|
// Summarization System Prompt
|
|
266
364
|
// ============================================================================
|
|
@@ -14,6 +14,7 @@ import type { AssistantMessage, Model } from "@gsd/pi-ai";
|
|
|
14
14
|
import { isContextOverflow } from "@gsd/pi-ai";
|
|
15
15
|
import {
|
|
16
16
|
type CompactionResult,
|
|
17
|
+
CompactionProducedNoSummaryError,
|
|
17
18
|
calculateContextTokens,
|
|
18
19
|
compact,
|
|
19
20
|
estimateContextTokens,
|
|
@@ -408,7 +409,13 @@ export class CompactionOrchestrator {
|
|
|
408
409
|
}, 100);
|
|
409
410
|
}
|
|
410
411
|
} catch (error) {
|
|
411
|
-
|
|
412
|
+
// Distinguish the "no usable summary" failure (issue #4665) so the UI
|
|
413
|
+
// can surface a clearer message than a generic compaction failure.
|
|
414
|
+
// Either way we drop the would-be compaction entry rather than writing
|
|
415
|
+
// an empty string to the session history.
|
|
416
|
+
const errorMessage = error instanceof CompactionProducedNoSummaryError
|
|
417
|
+
? `Compaction produced no usable summary — session history preserved as-is. (${error.message})`
|
|
418
|
+
: getErrorMessage(error);
|
|
412
419
|
this._deps.emit({
|
|
413
420
|
type: "auto_compaction_end",
|
|
414
421
|
result: undefined,
|
|
@@ -3,7 +3,7 @@ import test from "node:test";
|
|
|
3
3
|
|
|
4
4
|
import type { Message } from "@gsd/pi-ai";
|
|
5
5
|
|
|
6
|
-
import { serializeConversation } from "./compaction/index.js";
|
|
6
|
+
import { serializeConversation, truncateForSummary } from "./compaction/index.js";
|
|
7
7
|
|
|
8
8
|
test("serializeConversation uses narrative role markers instead of chat-style delimiters (#4054)", () => {
|
|
9
9
|
const messages: Message[] = [
|
|
@@ -48,3 +48,70 @@ test("serializeConversation uses narrative role markers instead of chat-style de
|
|
|
48
48
|
assert.ok(!serialized.includes("[Assistant]:"), "chat-style [Assistant]: markers should not remain");
|
|
49
49
|
assert.ok(!serialized.includes("[Tool result]:"), "chat-style [Tool result]: markers should not remain");
|
|
50
50
|
});
|
|
51
|
+
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// #4665 regression: head+tail truncation keeps verdicts/results
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
test("(#4665) truncateForSummary keeps both head AND tail — tail carries result/verdict text", () => {
|
|
57
|
+
// Construct a 10K-char fixture where the HEAD is "setup noise" and the TAIL
|
|
58
|
+
// contains a result line. The old head-only truncation would drop the tail
|
|
59
|
+
// and lose the result. The fix preserves both.
|
|
60
|
+
const head = "setup log line A\n".repeat(500); // ~8500 chars of setup
|
|
61
|
+
const tail = "RESULT: 258 passed, 0 failed. exit_code=0 commit=abc1234";
|
|
62
|
+
const input = head + tail;
|
|
63
|
+
|
|
64
|
+
const out = truncateForSummary(input, 2_000);
|
|
65
|
+
|
|
66
|
+
assert.ok(out.length < input.length, "must truncate when over cap");
|
|
67
|
+
assert.ok(out.includes("setup log line A"), "head content preserved");
|
|
68
|
+
assert.ok(out.includes("RESULT: 258 passed"), "tail content preserved (issue #4665)");
|
|
69
|
+
assert.match(out, /more characters truncated/, "emits an elision marker");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("(#4665) truncateForSummary is a no-op when input is within the cap", () => {
|
|
73
|
+
const input = "short enough";
|
|
74
|
+
assert.equal(truncateForSummary(input, 2_000), input);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("(#4665) serializeConversation caps large user content, not just tool results", () => {
|
|
78
|
+
// Pre-fix, only toolResult blocks were capped. A large user paste could
|
|
79
|
+
// still blow out the chunker's token math and the LLM's input budget.
|
|
80
|
+
const hugeUserText = "U".repeat(100_000);
|
|
81
|
+
const hugeAssistantText = "A".repeat(100_000);
|
|
82
|
+
const hugeToolResult = "T".repeat(100_000);
|
|
83
|
+
|
|
84
|
+
const messages: Message[] = [
|
|
85
|
+
{ role: "user", content: hugeUserText } as Message,
|
|
86
|
+
{
|
|
87
|
+
role: "assistant",
|
|
88
|
+
content: [{ type: "text", text: hugeAssistantText }],
|
|
89
|
+
api: "anthropic-messages",
|
|
90
|
+
provider: "anthropic",
|
|
91
|
+
model: "claude-sonnet-4-6",
|
|
92
|
+
usage: {
|
|
93
|
+
input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0,
|
|
94
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
95
|
+
},
|
|
96
|
+
stopReason: "stop",
|
|
97
|
+
timestamp: Date.now(),
|
|
98
|
+
} as Message,
|
|
99
|
+
{
|
|
100
|
+
role: "toolResult",
|
|
101
|
+
content: [{ type: "text", text: hugeToolResult }],
|
|
102
|
+
toolName: "Bash",
|
|
103
|
+
toolCallId: "tool-huge",
|
|
104
|
+
} as Message,
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
const serialized = serializeConversation(messages);
|
|
108
|
+
|
|
109
|
+
// Each block is truncated independently to TOOL_RESULT_MAX_CHARS plus the
|
|
110
|
+
// framing marker, so the serialized output should be a tiny fraction of
|
|
111
|
+
// the raw 300K chars of content.
|
|
112
|
+
assert.ok(
|
|
113
|
+
serialized.length < 10_000,
|
|
114
|
+
`serialized output should be small after capping all blocks, got ${serialized.length} chars`,
|
|
115
|
+
);
|
|
116
|
+
assert.match(serialized, /more characters truncated/, "truncation marker present");
|
|
117
|
+
});
|
|
@@ -8,6 +8,12 @@ import { ModelDiscoveryCache } from "./discovery-cache.js";
|
|
|
8
8
|
let testDir: string;
|
|
9
9
|
let cachePath: string;
|
|
10
10
|
|
|
11
|
+
function markEntryStale(cache: ModelDiscoveryCache, provider: string): void {
|
|
12
|
+
const entry = cache.get(provider);
|
|
13
|
+
assert.ok(entry, `expected cache entry for ${provider}`);
|
|
14
|
+
entry.fetchedAt = Date.now() - entry.ttlMs - 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
beforeEach(() => {
|
|
12
18
|
testDir = join(tmpdir(), `discovery-cache-test-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
|
13
19
|
mkdirSync(testDir, { recursive: true });
|
|
@@ -92,12 +98,7 @@ describe("ModelDiscoveryCache — staleness", () => {
|
|
|
92
98
|
it("entries with expired TTL are stale", () => {
|
|
93
99
|
const cache = new ModelDiscoveryCache(cachePath);
|
|
94
100
|
cache.set("openai", [{ id: "gpt-4o" }], 1); // 1ms TTL
|
|
95
|
-
|
|
96
|
-
// Wait for TTL to expire
|
|
97
|
-
const start = Date.now();
|
|
98
|
-
while (Date.now() - start < 5) {
|
|
99
|
-
// busy wait
|
|
100
|
-
}
|
|
101
|
+
markEntryStale(cache, "openai");
|
|
101
102
|
|
|
102
103
|
assert.equal(cache.isStale("openai"), true);
|
|
103
104
|
});
|
|
@@ -110,12 +111,7 @@ describe("ModelDiscoveryCache — getAll", () => {
|
|
|
110
111
|
const cache = new ModelDiscoveryCache(cachePath);
|
|
111
112
|
cache.set("openai", [{ id: "gpt-4o" }]);
|
|
112
113
|
cache.set("stale", [{ id: "old" }], 1);
|
|
113
|
-
|
|
114
|
-
// Wait for stale TTL
|
|
115
|
-
const start = Date.now();
|
|
116
|
-
while (Date.now() - start < 5) {
|
|
117
|
-
// busy wait
|
|
118
|
-
}
|
|
114
|
+
markEntryStale(cache, "stale");
|
|
119
115
|
|
|
120
116
|
const all = cache.getAll();
|
|
121
117
|
assert.ok(all.has("openai"));
|
|
@@ -126,12 +122,7 @@ describe("ModelDiscoveryCache — getAll", () => {
|
|
|
126
122
|
const cache = new ModelDiscoveryCache(cachePath);
|
|
127
123
|
cache.set("openai", [{ id: "gpt-4o" }]);
|
|
128
124
|
cache.set("stale", [{ id: "old" }], 1);
|
|
129
|
-
|
|
130
|
-
// Wait for stale TTL
|
|
131
|
-
const start = Date.now();
|
|
132
|
-
while (Date.now() - start < 5) {
|
|
133
|
-
// busy wait
|
|
134
|
-
}
|
|
125
|
+
markEntryStale(cache, "stale");
|
|
135
126
|
|
|
136
127
|
const all = cache.getAll(true);
|
|
137
128
|
assert.ok(all.has("openai"));
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
|
2
|
+
import { join, resolve } from 'node:path'
|
|
3
|
+
import { readManifest, readManifestFromEntryPath } from './extension-registry.js'
|
|
4
|
+
|
|
5
|
+
function isExtensionFile(name: string): boolean {
|
|
6
|
+
return name.endsWith('.ts') || name.endsWith('.js')
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the entry-point file(s) for a single extension directory.
|
|
11
|
+
*
|
|
12
|
+
* 1. If the directory contains a package.json with a `pi` manifest object,
|
|
13
|
+
* the manifest is authoritative:
|
|
14
|
+
* - `pi.extensions` array → resolve each entry relative to the directory.
|
|
15
|
+
* - `pi: {}` (no extensions) → return empty (library opt-out, e.g. cmux).
|
|
16
|
+
* 2. Only when no `pi` manifest exists does it fall back to `index.ts` → `index.js`.
|
|
17
|
+
*/
|
|
18
|
+
export function resolveExtensionEntries(dir: string): string[] {
|
|
19
|
+
const packageJsonPath = join(dir, 'package.json')
|
|
20
|
+
if (existsSync(packageJsonPath)) {
|
|
21
|
+
try {
|
|
22
|
+
const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
|
|
23
|
+
if (pkg?.pi && typeof pkg.pi === 'object') {
|
|
24
|
+
// When a pi manifest exists, it is authoritative — don't fall through
|
|
25
|
+
// to index.ts/index.js auto-detection. This allows library directories
|
|
26
|
+
// (like cmux) to opt out by declaring "pi": {} with no extensions.
|
|
27
|
+
const declared = pkg.pi.extensions
|
|
28
|
+
if (!Array.isArray(declared) || declared.length === 0) {
|
|
29
|
+
return []
|
|
30
|
+
}
|
|
31
|
+
return declared
|
|
32
|
+
.filter((entry: unknown): entry is string => typeof entry === 'string')
|
|
33
|
+
.map((entry: string) => resolve(dir, entry))
|
|
34
|
+
.filter((entry: string) => existsSync(entry))
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
// Ignore malformed manifests and fall back to index.ts/index.js discovery.
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const indexTs = join(dir, 'index.ts')
|
|
42
|
+
if (existsSync(indexTs)) {
|
|
43
|
+
return [indexTs]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const indexJs = join(dir, 'index.js')
|
|
47
|
+
if (existsSync(indexJs)) {
|
|
48
|
+
return [indexJs]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return []
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Discovers all extension entry-point paths under an extensions directory.
|
|
56
|
+
*
|
|
57
|
+
* - Top-level .ts/.js files are treated as standalone extension entry points.
|
|
58
|
+
* - Subdirectories are resolved via `resolveExtensionEntries()` (package.json →
|
|
59
|
+
* pi.extensions, then index.ts/index.js fallback).
|
|
60
|
+
*/
|
|
61
|
+
export function discoverExtensionEntryPaths(extensionsDir: string): string[] {
|
|
62
|
+
if (!existsSync(extensionsDir)) {
|
|
63
|
+
return []
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const discovered: string[] = []
|
|
67
|
+
for (const entry of readdirSync(extensionsDir, { withFileTypes: true })) {
|
|
68
|
+
const entryPath = join(extensionsDir, entry.name)
|
|
69
|
+
|
|
70
|
+
if ((entry.isFile() || entry.isSymbolicLink()) && isExtensionFile(entry.name)) {
|
|
71
|
+
discovered.push(entryPath)
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (entry.isDirectory() || entry.isSymbolicLink()) {
|
|
76
|
+
discovered.push(...resolveExtensionEntries(entryPath))
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return discovered
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Merge bundled and installed extension entry paths.
|
|
85
|
+
* Installed extensions with the same manifest ID as a bundled extension take precedence (D-14).
|
|
86
|
+
* Loader stays dumb — receives a pre-merged path list (D-15).
|
|
87
|
+
*/
|
|
88
|
+
export function mergeExtensionEntryPaths(bundledPaths: string[], installedExtDir: string): string[] {
|
|
89
|
+
if (!existsSync(installedExtDir)) return bundledPaths
|
|
90
|
+
|
|
91
|
+
// Build map: manifest ID → entry paths for installed extensions
|
|
92
|
+
const installedById = new Map<string, string[]>()
|
|
93
|
+
for (const entry of readdirSync(installedExtDir, { withFileTypes: true })) {
|
|
94
|
+
if (!entry.isDirectory()) continue
|
|
95
|
+
const dir = join(installedExtDir, entry.name)
|
|
96
|
+
const manifest = readManifest(dir)
|
|
97
|
+
const entries = resolveExtensionEntries(dir)
|
|
98
|
+
if (manifest && entries.length > 0) {
|
|
99
|
+
installedById.set(manifest.id, entries)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (installedById.size === 0) return bundledPaths
|
|
104
|
+
|
|
105
|
+
// Filter bundled paths: skip any whose manifest id is shadowed by installed
|
|
106
|
+
const merged: string[] = []
|
|
107
|
+
for (const entryPath of bundledPaths) {
|
|
108
|
+
const manifest = readManifestFromEntryPath(entryPath)
|
|
109
|
+
if (manifest && installedById.has(manifest.id)) continue // shadowed by installed
|
|
110
|
+
merged.push(entryPath)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Append all installed entries
|
|
114
|
+
for (const entries of installedById.values()) {
|
|
115
|
+
merged.push(...entries)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return merged
|
|
119
|
+
}
|