gsd-pi 2.33.1-dev.235d83a → 2.33.1-dev.29a8268
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/dist/cli.js +0 -16
- package/dist/resource-loader.d.ts +0 -2
- package/dist/resource-loader.js +3 -36
- package/dist/resources/extensions/ask-user-questions.ts +290 -0
- package/dist/resources/extensions/async-jobs/async-bash-tool.ts +212 -0
- package/dist/resources/extensions/async-jobs/await-tool.ts +103 -0
- package/dist/resources/extensions/async-jobs/cancel-job-tool.ts +35 -0
- package/dist/resources/extensions/async-jobs/index.ts +141 -0
- package/dist/resources/extensions/async-jobs/job-manager.ts +211 -0
- package/dist/resources/extensions/aws-auth/index.ts +144 -0
- package/dist/resources/extensions/bg-shell/bg-shell-command.ts +219 -0
- package/dist/resources/extensions/bg-shell/bg-shell-lifecycle.ts +400 -0
- package/dist/resources/extensions/bg-shell/bg-shell-tool.ts +985 -0
- package/dist/resources/extensions/bg-shell/index.ts +59 -0
- package/dist/resources/extensions/bg-shell/interaction.ts +198 -0
- package/dist/resources/extensions/bg-shell/output-formatter.ts +279 -0
- package/dist/resources/extensions/bg-shell/overlay.ts +437 -0
- package/dist/resources/extensions/bg-shell/process-manager.ts +464 -0
- package/dist/resources/extensions/bg-shell/readiness-detector.ts +126 -0
- package/dist/resources/extensions/bg-shell/types.ts +303 -0
- package/dist/resources/extensions/bg-shell/utilities.ts +57 -0
- package/dist/resources/extensions/browser-tools/capture.ts +199 -0
- package/dist/resources/extensions/browser-tools/core.ts +1196 -0
- package/dist/resources/extensions/browser-tools/{evaluate-helpers.js → evaluate-helpers.ts} +1 -0
- package/dist/resources/extensions/browser-tools/index.ts +71 -0
- package/dist/resources/extensions/browser-tools/lifecycle.ts +270 -0
- package/dist/resources/extensions/browser-tools/refs.ts +264 -0
- package/dist/resources/extensions/browser-tools/settle.ts +197 -0
- package/dist/resources/extensions/browser-tools/state.ts +408 -0
- package/dist/resources/extensions/browser-tools/tools/action-cache.ts +216 -0
- package/dist/resources/extensions/browser-tools/tools/assertions.ts +342 -0
- package/dist/resources/extensions/browser-tools/tools/codegen.ts +274 -0
- package/dist/resources/extensions/browser-tools/tools/device.ts +183 -0
- package/dist/resources/extensions/browser-tools/tools/extract.ts +229 -0
- package/dist/resources/extensions/browser-tools/tools/forms.ts +801 -0
- package/dist/resources/extensions/browser-tools/tools/injection-detect.ts +221 -0
- package/dist/resources/extensions/browser-tools/tools/inspection.ts +492 -0
- package/dist/resources/extensions/browser-tools/tools/intent.ts +614 -0
- package/dist/resources/extensions/browser-tools/tools/interaction.ts +865 -0
- package/dist/resources/extensions/browser-tools/tools/navigation.ts +232 -0
- package/dist/resources/extensions/browser-tools/tools/network-mock.ts +244 -0
- package/dist/resources/extensions/browser-tools/tools/pages.ts +303 -0
- package/dist/resources/extensions/browser-tools/tools/pdf.ts +92 -0
- package/dist/resources/extensions/browser-tools/tools/refs.ts +541 -0
- package/dist/resources/extensions/browser-tools/tools/screenshot.ts +101 -0
- package/dist/resources/extensions/browser-tools/tools/session.ts +400 -0
- package/dist/resources/extensions/browser-tools/tools/state-persistence.ts +202 -0
- package/dist/resources/extensions/browser-tools/tools/visual-diff.ts +209 -0
- package/dist/resources/extensions/browser-tools/tools/wait.ts +247 -0
- package/dist/resources/extensions/browser-tools/tools/zoom.ts +104 -0
- package/dist/resources/extensions/browser-tools/utils.ts +660 -0
- package/dist/resources/extensions/context7/index.ts +428 -0
- package/dist/resources/extensions/get-secrets-from-user.ts +607 -0
- package/dist/resources/extensions/google-search/index.ts +466 -0
- package/dist/resources/extensions/gsd/activity-log.ts +162 -0
- package/dist/resources/extensions/gsd/atomic-write.ts +35 -0
- package/dist/resources/extensions/gsd/auto/session.ts +236 -0
- package/dist/resources/extensions/gsd/auto-budget.ts +32 -0
- package/dist/resources/extensions/gsd/{auto-constants.js → auto-constants.ts} +1 -0
- package/dist/resources/extensions/gsd/auto-dashboard.ts +626 -0
- package/dist/resources/extensions/gsd/auto-direct-dispatch.ts +224 -0
- package/dist/resources/extensions/gsd/auto-dispatch.ts +409 -0
- package/dist/resources/extensions/gsd/auto-idempotency.ts +151 -0
- package/dist/resources/extensions/gsd/auto-model-selection.ts +179 -0
- package/dist/resources/extensions/gsd/auto-observability.ts +72 -0
- package/dist/resources/extensions/gsd/auto-post-unit.ts +618 -0
- package/dist/resources/extensions/gsd/auto-prompts.ts +1273 -0
- package/dist/resources/extensions/gsd/auto-recovery.ts +578 -0
- package/dist/resources/extensions/gsd/auto-start.ts +483 -0
- package/dist/resources/extensions/gsd/auto-stuck-detection.ts +221 -0
- package/dist/resources/extensions/gsd/{auto-supervisor.js → auto-supervisor.ts} +33 -25
- package/dist/resources/extensions/gsd/auto-timeout-recovery.ts +263 -0
- package/dist/resources/extensions/gsd/auto-timers.ts +224 -0
- package/dist/resources/extensions/gsd/auto-tool-tracking.ts +54 -0
- package/dist/resources/extensions/gsd/auto-unit-closeout.ts +48 -0
- package/dist/resources/extensions/gsd/auto-verification.ts +229 -0
- package/dist/resources/extensions/gsd/auto-worktree.ts +658 -0
- package/dist/resources/extensions/gsd/auto.ts +1834 -0
- package/dist/resources/extensions/gsd/{cache.js → cache.ts} +7 -5
- package/dist/resources/extensions/gsd/captures.ts +427 -0
- package/dist/resources/extensions/gsd/claude-import.ts +656 -0
- package/dist/resources/extensions/gsd/collision-diagnostics.ts +332 -0
- package/dist/resources/extensions/gsd/commands-config.ts +102 -0
- package/dist/resources/extensions/gsd/commands-extensions.ts +328 -0
- package/dist/resources/extensions/gsd/commands-handlers.ts +395 -0
- package/dist/resources/extensions/gsd/commands-inspect.ts +91 -0
- package/dist/resources/extensions/gsd/commands-logs.ts +536 -0
- package/dist/resources/extensions/gsd/commands-maintenance.ts +206 -0
- package/dist/resources/extensions/gsd/commands-prefs-wizard.ts +780 -0
- package/dist/resources/extensions/gsd/commands-workflow-templates.ts +543 -0
- package/dist/resources/extensions/gsd/commands.ts +1149 -0
- package/dist/resources/extensions/gsd/complexity-classifier.ts +320 -0
- package/dist/resources/extensions/gsd/{constants.js → constants.ts} +6 -0
- package/dist/resources/extensions/gsd/context-budget.ts +266 -0
- package/dist/resources/extensions/gsd/context-store.ts +195 -0
- package/dist/resources/extensions/gsd/crash-recovery.ts +121 -0
- package/dist/resources/extensions/gsd/dashboard-overlay.ts +681 -0
- package/dist/resources/extensions/gsd/db-writer.ts +360 -0
- package/dist/resources/extensions/gsd/debug-logger.ts +178 -0
- package/dist/resources/extensions/gsd/detection.ts +470 -0
- package/dist/resources/extensions/gsd/diff-context.ts +214 -0
- package/dist/resources/extensions/gsd/dispatch-guard.ts +81 -0
- package/dist/resources/extensions/gsd/doctor-checks.ts +612 -0
- package/dist/resources/extensions/gsd/doctor-environment.ts +497 -0
- package/dist/resources/extensions/gsd/doctor-format.ts +78 -0
- package/dist/resources/extensions/gsd/doctor-proactive.ts +292 -0
- package/dist/resources/extensions/gsd/doctor-providers.ts +343 -0
- package/dist/resources/extensions/gsd/doctor-types.ts +87 -0
- package/dist/resources/extensions/gsd/doctor.ts +722 -0
- package/dist/resources/extensions/gsd/error-utils.ts +6 -0
- package/dist/resources/extensions/gsd/{errors.js → errors.ts} +11 -6
- package/dist/resources/extensions/gsd/exit-command.ts +18 -0
- package/dist/resources/extensions/gsd/{export-html.js → export-html.ts} +614 -482
- package/dist/resources/extensions/gsd/export.ts +317 -0
- package/dist/resources/extensions/gsd/file-watcher.ts +97 -0
- package/dist/resources/extensions/gsd/files.ts +1058 -0
- package/dist/resources/extensions/gsd/forensics.ts +629 -0
- package/dist/resources/extensions/gsd/{git-constants.js → git-constants.ts} +5 -4
- package/dist/resources/extensions/gsd/git-self-heal.ts +127 -0
- package/dist/resources/extensions/gsd/git-service.ts +586 -0
- package/dist/resources/extensions/gsd/{gitignore.js → gitignore.ts} +125 -98
- package/dist/resources/extensions/gsd/gsd-db.ts +685 -0
- package/dist/resources/extensions/gsd/guided-flow-queue.ts +440 -0
- package/dist/resources/extensions/gsd/guided-flow.ts +1303 -0
- package/dist/resources/extensions/gsd/health-widget.ts +167 -0
- package/dist/resources/extensions/gsd/history.ts +143 -0
- package/dist/resources/extensions/gsd/index.ts +1401 -0
- package/dist/resources/extensions/gsd/init-wizard.ts +587 -0
- package/dist/resources/extensions/gsd/json-persistence.ts +67 -0
- package/dist/resources/extensions/gsd/{jsonl-utils.js → jsonl-utils.ts} +7 -10
- package/dist/resources/extensions/gsd/key-manager.ts +996 -0
- package/dist/resources/extensions/gsd/marketplace-discovery.ts +508 -0
- package/dist/resources/extensions/gsd/md-importer.ts +527 -0
- package/dist/resources/extensions/gsd/mechanical-completion.ts +430 -0
- package/dist/resources/extensions/gsd/memory-extractor.ts +352 -0
- package/dist/resources/extensions/gsd/memory-store.ts +441 -0
- package/dist/resources/extensions/gsd/metrics.ts +532 -0
- package/dist/resources/extensions/gsd/migrate/command.ts +219 -0
- package/dist/resources/extensions/gsd/migrate/index.ts +42 -0
- package/dist/resources/extensions/gsd/migrate/parser.ts +323 -0
- package/dist/resources/extensions/gsd/migrate/parsers.ts +539 -0
- package/dist/resources/extensions/gsd/migrate/preview.ts +48 -0
- package/dist/resources/extensions/gsd/migrate/transformer.ts +346 -0
- package/dist/resources/extensions/gsd/migrate/types.ts +370 -0
- package/dist/resources/extensions/gsd/migrate/validator.ts +55 -0
- package/dist/resources/extensions/gsd/migrate/writer.ts +579 -0
- package/dist/resources/extensions/gsd/migrate-external.ts +140 -0
- package/dist/resources/extensions/gsd/milestone-actions.ts +126 -0
- package/dist/resources/extensions/gsd/{milestone-ids.js → milestone-ids.ts} +63 -50
- package/dist/resources/extensions/gsd/model-cost-table.ts +65 -0
- package/dist/resources/extensions/gsd/model-router.ts +256 -0
- package/dist/resources/extensions/gsd/namespaced-registry.ts +467 -0
- package/dist/resources/extensions/gsd/namespaced-resolver.ts +307 -0
- package/dist/resources/extensions/gsd/native-git-bridge.ts +1041 -0
- package/dist/resources/extensions/gsd/native-parser-bridge.ts +267 -0
- package/dist/resources/extensions/gsd/notifications.ts +87 -0
- package/dist/resources/extensions/gsd/observability-validator.ts +429 -0
- package/dist/resources/extensions/gsd/parallel-eligibility.ts +233 -0
- package/dist/resources/extensions/gsd/parallel-merge.ts +157 -0
- package/dist/resources/extensions/gsd/parallel-orchestrator.ts +826 -0
- package/dist/resources/extensions/gsd/paths.ts +449 -0
- package/dist/resources/extensions/gsd/plugin-importer.ts +411 -0
- package/dist/resources/extensions/gsd/post-unit-hooks.ts +520 -0
- package/dist/resources/extensions/gsd/preferences-models.ts +329 -0
- package/dist/resources/extensions/gsd/preferences-skills.ts +169 -0
- package/dist/resources/extensions/gsd/preferences-types.ts +229 -0
- package/dist/resources/extensions/gsd/preferences-validation.ts +590 -0
- package/dist/resources/extensions/gsd/preferences.ts +416 -0
- package/dist/resources/extensions/gsd/progress-score.ts +273 -0
- package/dist/resources/extensions/gsd/prompt-cache-optimizer.ts +213 -0
- package/dist/resources/extensions/gsd/prompt-compressor.ts +508 -0
- package/dist/resources/extensions/gsd/prompt-loader.ts +130 -0
- package/dist/resources/extensions/gsd/prompt-ordering.ts +200 -0
- package/dist/resources/extensions/gsd/provider-error-pause.ts +88 -0
- package/dist/resources/extensions/gsd/queue-order.ts +230 -0
- package/dist/resources/extensions/gsd/queue-reorder-ui.ts +276 -0
- package/dist/resources/extensions/gsd/quick.ts +212 -0
- package/dist/resources/extensions/gsd/repo-identity.ts +169 -0
- package/dist/resources/extensions/gsd/{reports.js → reports.ts} +241 -146
- package/dist/resources/extensions/gsd/{resource-version.js → resource-version.ts} +53 -50
- package/dist/resources/extensions/gsd/roadmap-slices.ts +149 -0
- package/dist/resources/extensions/gsd/routing-history.ts +286 -0
- package/dist/resources/extensions/gsd/safe-fs.ts +47 -0
- package/dist/resources/extensions/gsd/semantic-chunker.ts +336 -0
- package/dist/resources/extensions/gsd/session-forensics.ts +537 -0
- package/dist/resources/extensions/gsd/session-lock.ts +426 -0
- package/dist/resources/extensions/gsd/session-status-io.ts +179 -0
- package/dist/resources/extensions/gsd/skill-discovery.ts +139 -0
- package/dist/resources/extensions/gsd/skill-health.ts +417 -0
- package/dist/resources/extensions/gsd/{skill-telemetry.js → skill-telemetry.ts} +74 -58
- package/dist/resources/extensions/gsd/state.ts +727 -0
- package/dist/resources/extensions/gsd/structured-data-formatter.ts +144 -0
- package/dist/resources/extensions/gsd/summary-distiller.ts +258 -0
- package/dist/resources/extensions/gsd/tests/activity-log.test.ts +213 -0
- package/dist/resources/extensions/gsd/tests/agent-end-retry.test.ts +107 -0
- package/dist/resources/extensions/gsd/tests/all-milestones-complete-merge.test.ts +200 -0
- package/dist/resources/extensions/gsd/tests/auto-budget-alerts.test.ts +50 -0
- package/dist/resources/extensions/gsd/tests/auto-dashboard.test.ts +166 -0
- package/dist/resources/extensions/gsd/tests/auto-dispatch-loop.test.ts +691 -0
- package/dist/resources/extensions/gsd/tests/auto-lock-creation.test.ts +186 -0
- package/dist/resources/extensions/gsd/tests/auto-preflight.test.ts +40 -0
- package/dist/resources/extensions/gsd/tests/auto-recovery.test.ts +640 -0
- package/dist/resources/extensions/gsd/tests/auto-reentrancy-guard.test.ts +127 -0
- package/dist/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +302 -0
- package/dist/resources/extensions/gsd/tests/auto-session-encapsulation.test.ts +257 -0
- package/dist/resources/extensions/gsd/tests/auto-skip-loop.test.ts +123 -0
- package/dist/resources/extensions/gsd/tests/auto-worktree-milestone-merge.test.ts +340 -0
- package/dist/resources/extensions/gsd/tests/auto-worktree.test.ts +167 -0
- package/dist/resources/extensions/gsd/tests/budget-prediction.test.ts +220 -0
- package/dist/resources/extensions/gsd/tests/cache-staleness-regression.test.ts +317 -0
- package/dist/resources/extensions/gsd/tests/captures.test.ts +438 -0
- package/dist/resources/extensions/gsd/tests/claude-import-tui.test.ts +351 -0
- package/dist/resources/extensions/gsd/tests/collect-from-manifest.test.ts +469 -0
- package/dist/resources/extensions/gsd/tests/collision-diagnostics.test.ts +705 -0
- package/dist/resources/extensions/gsd/tests/commands-logs.test.ts +241 -0
- package/dist/resources/extensions/gsd/tests/complete-milestone.test.ts +209 -0
- package/dist/resources/extensions/gsd/tests/complexity-classifier.test.ts +181 -0
- package/dist/resources/extensions/gsd/tests/context-budget.test.ts +352 -0
- package/dist/resources/extensions/gsd/tests/context-compression.test.ts +193 -0
- package/dist/resources/extensions/gsd/tests/context-store.test.ts +462 -0
- package/dist/resources/extensions/gsd/tests/continue-here.test.ts +285 -0
- package/dist/resources/extensions/gsd/tests/cost-projection.test.ts +134 -0
- package/dist/resources/extensions/gsd/tests/crash-recovery.test.ts +134 -0
- package/dist/resources/extensions/gsd/tests/dashboard-budget.test.ts +346 -0
- package/dist/resources/extensions/gsd/tests/db-writer.test.ts +602 -0
- package/dist/resources/extensions/gsd/tests/debug-logger.test.ts +185 -0
- package/dist/resources/extensions/gsd/tests/derive-state-db.test.ts +405 -0
- package/dist/resources/extensions/gsd/tests/derive-state-deps.test.ts +421 -0
- package/dist/resources/extensions/gsd/tests/derive-state-draft.test.ts +308 -0
- package/dist/resources/extensions/gsd/tests/derive-state.test.ts +788 -0
- package/dist/resources/extensions/gsd/tests/detection.test.ts +398 -0
- package/dist/resources/extensions/gsd/tests/diff-context.test.ts +136 -0
- package/dist/resources/extensions/gsd/tests/discuss-prompt.test.ts +15 -0
- package/dist/resources/extensions/gsd/tests/dispatch-guard.test.ts +128 -0
- package/dist/resources/extensions/gsd/tests/dispatch-missing-task-plans.test.ts +132 -0
- package/dist/resources/extensions/gsd/tests/dispatch-stall-guard.test.ts +126 -0
- package/dist/resources/extensions/gsd/tests/doctor-environment.test.ts +314 -0
- package/dist/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +245 -0
- package/dist/resources/extensions/gsd/tests/doctor-git.test.ts +344 -0
- package/dist/resources/extensions/gsd/tests/doctor-proactive.test.ts +278 -0
- package/dist/resources/extensions/gsd/tests/doctor-providers.test.ts +298 -0
- package/dist/resources/extensions/gsd/tests/doctor-runtime.test.ts +302 -0
- package/dist/resources/extensions/gsd/tests/doctor.test.ts +652 -0
- package/dist/resources/extensions/gsd/tests/draft-promotion.test.ts +169 -0
- package/dist/resources/extensions/gsd/tests/exit-command.test.ts +50 -0
- package/dist/resources/extensions/gsd/tests/export-html-all.test.ts +105 -0
- package/dist/resources/extensions/gsd/tests/export-html-enhancements.test.ts +378 -0
- package/dist/resources/extensions/gsd/tests/extension-selector-separator.test.ts +144 -0
- package/dist/resources/extensions/gsd/tests/feature-branch-lifecycle-integration.test.ts +424 -0
- package/dist/resources/extensions/gsd/tests/git-self-heal.test.ts +131 -0
- package/dist/resources/extensions/gsd/tests/git-service.test.ts +1181 -0
- package/dist/resources/extensions/gsd/tests/gsd-db.test.ts +353 -0
- package/dist/resources/extensions/gsd/tests/gsd-inspect.test.ts +125 -0
- package/dist/resources/extensions/gsd/tests/gsd-tools.test.ts +326 -0
- package/dist/resources/extensions/gsd/tests/headless-answers.test.ts +340 -0
- package/dist/resources/extensions/gsd/tests/headless-query.test.ts +162 -0
- package/dist/resources/extensions/gsd/tests/idle-recovery.test.ts +485 -0
- package/dist/resources/extensions/gsd/tests/in-flight-tool-tracking.test.ts +32 -0
- package/dist/resources/extensions/gsd/tests/init-wizard.test.ts +197 -0
- package/dist/resources/extensions/gsd/tests/integration/headless-command.ts +534 -0
- package/dist/resources/extensions/gsd/tests/integration-edge.test.ts +228 -0
- package/dist/resources/extensions/gsd/tests/integration-lifecycle.test.ts +277 -0
- package/dist/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +523 -0
- package/dist/resources/extensions/gsd/tests/key-manager.test.ts +414 -0
- package/dist/resources/extensions/gsd/tests/knowledge.test.ts +161 -0
- package/dist/resources/extensions/gsd/tests/loop-regression.test.ts +877 -0
- package/dist/resources/extensions/gsd/tests/manifest-status.test.ts +283 -0
- package/dist/resources/extensions/gsd/tests/marketplace-test-fixtures.ts +91 -0
- package/dist/resources/extensions/gsd/tests/md-importer.test.ts +410 -0
- package/dist/resources/extensions/gsd/tests/mechanical-completion.test.ts +356 -0
- package/dist/resources/extensions/gsd/tests/memory-extractor.test.ts +180 -0
- package/dist/resources/extensions/gsd/tests/memory-leak-guards.test.ts +91 -0
- package/dist/resources/extensions/gsd/tests/memory-store.test.ts +345 -0
- package/dist/resources/extensions/gsd/tests/metrics.test.ts +253 -0
- package/dist/resources/extensions/gsd/tests/migrate-command.test.ts +369 -0
- package/dist/resources/extensions/gsd/tests/migrate-parser.test.ts +757 -0
- package/dist/resources/extensions/gsd/tests/migrate-transformer.test.ts +635 -0
- package/dist/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +414 -0
- package/dist/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +303 -0
- package/dist/resources/extensions/gsd/tests/migrate-writer.test.ts +398 -0
- package/dist/resources/extensions/gsd/tests/milestone-transition-worktree.test.ts +147 -0
- package/dist/resources/extensions/gsd/tests/model-cost-table.test.ts +69 -0
- package/dist/resources/extensions/gsd/tests/model-isolation.test.ts +157 -0
- package/dist/resources/extensions/gsd/tests/model-router.test.ts +167 -0
- package/dist/resources/extensions/gsd/tests/must-have-parser.test.ts +291 -0
- package/dist/resources/extensions/gsd/tests/namespaced-registry.test.ts +1027 -0
- package/dist/resources/extensions/gsd/tests/namespaced-resolver.test.ts +671 -0
- package/dist/resources/extensions/gsd/tests/native-has-changes-cache.test.ts +61 -0
- package/dist/resources/extensions/gsd/tests/next-milestone-id.test.ts +23 -0
- package/dist/resources/extensions/gsd/tests/none-mode-gates.test.ts +114 -0
- package/dist/resources/extensions/gsd/tests/notifications.test.ts +67 -0
- package/dist/resources/extensions/gsd/tests/overrides.test.ts +131 -0
- package/dist/resources/extensions/gsd/tests/parallel-budget-atomicity.test.ts +331 -0
- package/dist/resources/extensions/gsd/tests/parallel-crash-recovery.test.ts +298 -0
- package/dist/resources/extensions/gsd/tests/parallel-merge.test.ts +468 -0
- package/dist/resources/extensions/gsd/tests/parallel-orchestration.test.ts +685 -0
- package/dist/resources/extensions/gsd/tests/parallel-worker-monitoring.test.ts +171 -0
- package/dist/resources/extensions/gsd/tests/parallel-workers-multi-milestone-e2e.test.ts +354 -0
- package/dist/resources/extensions/gsd/tests/park-edge-cases.test.ts +276 -0
- package/dist/resources/extensions/gsd/tests/park-milestone.test.ts +401 -0
- package/dist/resources/extensions/gsd/tests/parsers.test.ts +1704 -0
- package/dist/resources/extensions/gsd/tests/plan-milestone.test.ts +133 -0
- package/dist/resources/extensions/gsd/tests/plan-quality-validator.test.ts +363 -0
- package/dist/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +42 -0
- package/dist/resources/extensions/gsd/tests/plugin-importer-live.test.ts +481 -0
- package/dist/resources/extensions/gsd/tests/plugin-importer.test.ts +1383 -0
- package/dist/resources/extensions/gsd/tests/post-unit-hooks.test.ts +337 -0
- package/dist/resources/extensions/gsd/tests/preferences.test.ts +276 -0
- package/dist/resources/extensions/gsd/tests/progress-score.test.ts +206 -0
- package/dist/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +464 -0
- package/dist/resources/extensions/gsd/tests/prompt-cache-optimizer.test.ts +314 -0
- package/dist/resources/extensions/gsd/tests/prompt-compressor.test.ts +529 -0
- package/dist/resources/extensions/gsd/tests/prompt-db.test.ts +385 -0
- package/dist/resources/extensions/gsd/tests/prompt-ordering.test.ts +296 -0
- package/dist/resources/extensions/gsd/tests/provider-errors.test.ts +338 -0
- package/dist/resources/extensions/gsd/tests/queue-draft-detection.test.ts +126 -0
- package/dist/resources/extensions/gsd/tests/queue-order.test.ts +204 -0
- package/dist/resources/extensions/gsd/tests/queue-reorder-e2e.test.ts +282 -0
- package/dist/resources/extensions/gsd/tests/reassess-detection.test.ts +154 -0
- package/dist/resources/extensions/gsd/tests/reassess-prompt.test.ts +145 -0
- package/dist/resources/extensions/gsd/tests/regex-hardening.test.ts +281 -0
- package/dist/resources/extensions/gsd/tests/remote-questions.test.ts +642 -0
- package/dist/resources/extensions/gsd/tests/remote-status.test.ts +99 -0
- package/dist/resources/extensions/gsd/tests/replan-slice.test.ts +538 -0
- package/dist/resources/extensions/gsd/tests/requirements.test.ts +106 -0
- package/dist/resources/extensions/gsd/tests/roadmap-parse-regression.test.ts +358 -0
- package/dist/resources/extensions/gsd/tests/roadmap-slices.test.ts +66 -0
- package/dist/resources/extensions/gsd/tests/routing-history.test.ts +240 -0
- package/dist/resources/extensions/gsd/tests/run-uat.test.ts +416 -0
- package/dist/resources/extensions/gsd/tests/secure-env-collect.test.ts +185 -0
- package/dist/resources/extensions/gsd/tests/semantic-chunker.test.ts +426 -0
- package/dist/resources/extensions/gsd/tests/session-lock-regression.test.ts +216 -0
- package/dist/resources/extensions/gsd/tests/session-lock.test.ts +434 -0
- package/dist/resources/extensions/gsd/tests/skill-lifecycle.test.ts +126 -0
- package/dist/resources/extensions/gsd/tests/smart-entry-draft.test.ts +123 -0
- package/dist/resources/extensions/gsd/tests/stale-worktree-cwd.test.ts +142 -0
- package/dist/resources/extensions/gsd/tests/stop-auto-remote.test.ts +156 -0
- package/dist/resources/extensions/gsd/tests/structured-data-formatter.test.ts +365 -0
- package/dist/resources/extensions/gsd/tests/summary-distiller.test.ts +323 -0
- package/dist/resources/extensions/gsd/tests/test-helpers.ts +61 -0
- package/dist/resources/extensions/gsd/tests/token-counter.test.ts +129 -0
- package/dist/resources/extensions/gsd/tests/token-optimization-benchmark.test.ts +1272 -0
- package/dist/resources/extensions/gsd/tests/token-optimization-prefs.test.ts +164 -0
- package/dist/resources/extensions/gsd/tests/token-profile.test.ts +268 -0
- package/dist/resources/extensions/gsd/tests/token-savings.test.ts +366 -0
- package/dist/resources/extensions/gsd/tests/triage-dispatch.test.ts +340 -0
- package/dist/resources/extensions/gsd/tests/triage-resolution.test.ts +416 -0
- package/dist/resources/extensions/gsd/tests/undo.test.ts +136 -0
- package/dist/resources/extensions/gsd/tests/unique-milestone-ids.test.ts +219 -0
- package/dist/resources/extensions/gsd/tests/unit-runtime.test.ts +258 -0
- package/dist/resources/extensions/gsd/tests/update-command.test.ts +67 -0
- package/dist/resources/extensions/gsd/tests/validate-directory.test.ts +222 -0
- package/dist/resources/extensions/gsd/tests/validate-milestone.test.ts +375 -0
- package/dist/resources/extensions/gsd/tests/verification-evidence.test.ts +745 -0
- package/dist/resources/extensions/gsd/tests/verification-gate.test.ts +1208 -0
- package/dist/resources/extensions/gsd/tests/visualizer-critical-path.test.ts +145 -0
- package/dist/resources/extensions/gsd/tests/visualizer-data.test.ts +446 -0
- package/dist/resources/extensions/gsd/tests/visualizer-overlay.test.ts +237 -0
- package/dist/resources/extensions/gsd/tests/visualizer-views.test.ts +718 -0
- package/dist/resources/extensions/gsd/tests/worker-registry.test.ts +148 -0
- package/dist/resources/extensions/gsd/tests/workflow-templates.test.ts +173 -0
- package/dist/resources/extensions/gsd/tests/workspace-index.test.ts +38 -0
- package/dist/resources/extensions/gsd/tests/worktree-bugfix.test.ts +120 -0
- package/dist/resources/extensions/gsd/tests/worktree-e2e.test.ts +244 -0
- package/dist/resources/extensions/gsd/tests/worktree-integration.test.ts +207 -0
- package/dist/resources/extensions/gsd/tests/worktree-manager.test.ts +141 -0
- package/dist/resources/extensions/gsd/tests/worktree-post-create-hook.test.ts +165 -0
- package/dist/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +206 -0
- package/dist/resources/extensions/gsd/tests/worktree.test.ts +171 -0
- package/dist/resources/extensions/gsd/tests/write-gate.test.ts +211 -0
- package/dist/resources/extensions/gsd/token-counter.ts +65 -0
- package/dist/resources/extensions/gsd/triage-resolution.ts +284 -0
- package/dist/resources/extensions/gsd/triage-ui.ts +175 -0
- package/dist/resources/extensions/gsd/types.ts +425 -0
- package/dist/resources/extensions/gsd/undo.ts +223 -0
- package/dist/resources/extensions/gsd/unit-id.ts +14 -0
- package/dist/resources/extensions/gsd/unit-runtime.ts +192 -0
- package/dist/resources/extensions/gsd/validate-directory.ts +164 -0
- package/dist/resources/extensions/gsd/verification-evidence.ts +188 -0
- package/dist/resources/extensions/gsd/verification-gate.ts +643 -0
- package/dist/resources/extensions/gsd/visualizer-data.ts +866 -0
- package/dist/resources/extensions/gsd/visualizer-overlay.ts +566 -0
- package/dist/resources/extensions/gsd/visualizer-views.ts +1171 -0
- package/dist/resources/extensions/gsd/workflow-templates.ts +241 -0
- package/dist/resources/extensions/gsd/workspace-index.ts +217 -0
- package/dist/resources/extensions/gsd/worktree-command.ts +807 -0
- package/dist/resources/extensions/gsd/worktree-manager.ts +449 -0
- package/dist/resources/extensions/gsd/worktree.ts +257 -0
- package/dist/resources/extensions/mac-tools/index.ts +852 -0
- package/dist/resources/extensions/mcp-client/index.ts +459 -0
- package/dist/resources/extensions/remote-questions/config.ts +83 -0
- package/dist/resources/extensions/remote-questions/discord-adapter.ts +148 -0
- package/dist/resources/extensions/remote-questions/format.ts +315 -0
- package/dist/resources/extensions/remote-questions/http-client.ts +76 -0
- package/dist/resources/extensions/remote-questions/manager.ts +184 -0
- package/dist/resources/extensions/remote-questions/{mod.js → mod.ts} +10 -1
- package/dist/resources/extensions/remote-questions/notify.ts +90 -0
- package/dist/resources/extensions/remote-questions/remote-command.ts +457 -0
- package/dist/resources/extensions/remote-questions/slack-adapter.ts +141 -0
- package/dist/resources/extensions/remote-questions/status.ts +31 -0
- package/dist/resources/extensions/remote-questions/store.ts +81 -0
- package/dist/resources/extensions/remote-questions/telegram-adapter.ts +149 -0
- package/dist/resources/extensions/remote-questions/types.ts +102 -0
- package/dist/resources/extensions/search-the-web/cache.ts +78 -0
- package/dist/resources/extensions/search-the-web/command-search-provider.ts +101 -0
- package/dist/resources/extensions/search-the-web/format.ts +258 -0
- package/dist/resources/extensions/search-the-web/http.ts +238 -0
- package/dist/resources/extensions/search-the-web/index.ts +65 -0
- package/dist/resources/extensions/search-the-web/native-search.ts +193 -0
- package/dist/resources/extensions/search-the-web/provider.ts +148 -0
- package/dist/resources/extensions/search-the-web/tavily.ts +116 -0
- package/dist/resources/extensions/search-the-web/tool-fetch-page.ts +589 -0
- package/dist/resources/extensions/search-the-web/tool-llm-context.ts +608 -0
- package/dist/resources/extensions/search-the-web/tool-search.ts +649 -0
- package/dist/resources/extensions/search-the-web/url-utils.ts +125 -0
- package/dist/resources/extensions/shared/confirm-ui.ts +126 -0
- package/dist/resources/extensions/shared/{format-utils.js → format-utils.ts} +91 -85
- package/dist/resources/extensions/shared/frontmatter.ts +117 -0
- package/dist/resources/extensions/shared/interview-ui.ts +613 -0
- package/dist/resources/extensions/shared/{mod.js → mod.ts} +24 -2
- package/dist/resources/extensions/shared/next-action-ui.ts +212 -0
- package/dist/resources/extensions/shared/{path-display.js → path-display.ts} +3 -2
- package/dist/resources/extensions/shared/sanitize.ts +19 -0
- package/dist/resources/extensions/shared/terminal.ts +23 -0
- package/dist/resources/extensions/shared/tests/format-utils.test.ts +153 -0
- package/dist/resources/extensions/shared/ui.ts +400 -0
- package/dist/resources/extensions/shared/wizard-ui.ts +551 -0
- package/dist/resources/extensions/slash-commands/audit.ts +88 -0
- package/dist/resources/extensions/slash-commands/clear.ts +10 -0
- package/dist/resources/extensions/slash-commands/create-extension.ts +297 -0
- package/dist/resources/extensions/slash-commands/create-slash-command.ts +234 -0
- package/dist/resources/extensions/slash-commands/index.ts +12 -0
- package/dist/resources/extensions/subagent/agents.ts +126 -0
- package/dist/resources/extensions/subagent/index.ts +1121 -0
- package/dist/resources/extensions/subagent/isolation.ts +501 -0
- package/dist/resources/extensions/subagent/worker-registry.ts +99 -0
- package/dist/resources/extensions/ttsr/index.ts +168 -0
- package/dist/resources/extensions/ttsr/rule-loader.ts +74 -0
- package/dist/resources/extensions/ttsr/ttsr-manager.ts +456 -0
- package/dist/resources/extensions/universal-config/discovery.ts +104 -0
- package/dist/resources/extensions/universal-config/format.ts +191 -0
- package/dist/resources/extensions/universal-config/index.ts +120 -0
- package/dist/resources/extensions/universal-config/scanners.ts +642 -0
- package/dist/resources/extensions/universal-config/tests/discovery.test.ts +119 -0
- package/dist/resources/extensions/universal-config/tests/format.test.ts +127 -0
- package/dist/resources/extensions/universal-config/tests/scanners.test.ts +456 -0
- package/dist/resources/extensions/universal-config/tools.ts +60 -0
- package/dist/resources/extensions/universal-config/types.ts +135 -0
- package/dist/resources/extensions/voice/index.ts +272 -0
- package/dist/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +51 -0
- package/dist/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +143 -0
- package/package.json +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.js +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 +0 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +4 -31
- package/packages/pi-coding-agent/dist/core/extensions/loader.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 +1 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/src/core/extensions/index.ts +0 -1
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +4 -35
- package/packages/pi-coding-agent/src/index.ts +0 -1
- package/src/resources/extensions/bg-shell/index.ts +46 -41
- package/src/resources/extensions/browser-tools/index.ts +67 -156
- package/src/resources/extensions/gsd/auto-verification.ts +2 -20
- package/src/resources/extensions/gsd/auto-worktree.ts +2 -3
- package/src/resources/extensions/gsd/commands.ts +31 -39
- package/src/resources/extensions/gsd/git-service.ts +0 -7
- package/src/resources/extensions/gsd/index.ts +32 -93
- package/src/resources/extensions/gsd/quick.ts +3 -52
- package/src/resources/extensions/gsd/repo-identity.ts +22 -56
- package/src/resources/extensions/gsd/tests/loop-regression.test.ts +4 -1
- package/src/resources/extensions/gsd/tests/verification-gate.test.ts +0 -65
- package/src/resources/extensions/gsd/types.ts +0 -4
- package/src/resources/extensions/gsd/verification-evidence.ts +1 -1
- package/src/resources/extensions/gsd/verification-gate.ts +2 -23
- package/src/resources/extensions/gsd/worktree-command.ts +11 -17
- package/src/resources/extensions/search-the-web/command-search-provider.ts +1 -1
- package/src/resources/extensions/search-the-web/index.ts +52 -35
- package/src/resources/extensions/search-the-web/tavily.ts +1 -1
- package/dist/resources/extensions/ask-user-questions.js +0 -217
- package/dist/resources/extensions/async-jobs/async-bash-tool.js +0 -180
- package/dist/resources/extensions/async-jobs/await-tool.js +0 -90
- package/dist/resources/extensions/async-jobs/cancel-job-tool.js +0 -28
- package/dist/resources/extensions/async-jobs/index.js +0 -119
- package/dist/resources/extensions/async-jobs/job-manager.js +0 -159
- package/dist/resources/extensions/aws-auth/index.js +0 -138
- package/dist/resources/extensions/bg-shell/bg-shell-command.js +0 -182
- package/dist/resources/extensions/bg-shell/bg-shell-lifecycle.js +0 -343
- package/dist/resources/extensions/bg-shell/bg-shell-tool.js +0 -831
- package/dist/resources/extensions/bg-shell/index.js +0 -41
- package/dist/resources/extensions/bg-shell/interaction.js +0 -160
- package/dist/resources/extensions/bg-shell/output-formatter.js +0 -245
- package/dist/resources/extensions/bg-shell/overlay.js +0 -378
- package/dist/resources/extensions/bg-shell/process-manager.js +0 -413
- package/dist/resources/extensions/bg-shell/readiness-detector.js +0 -109
- package/dist/resources/extensions/bg-shell/types.js +0 -96
- package/dist/resources/extensions/bg-shell/utilities.js +0 -50
- package/dist/resources/extensions/browser-tools/capture.js +0 -179
- package/dist/resources/extensions/browser-tools/core.js +0 -899
- package/dist/resources/extensions/browser-tools/index.js +0 -123
- package/dist/resources/extensions/browser-tools/lifecycle.js +0 -222
- package/dist/resources/extensions/browser-tools/refs.js +0 -254
- package/dist/resources/extensions/browser-tools/settle.js +0 -173
- package/dist/resources/extensions/browser-tools/state.js +0 -126
- package/dist/resources/extensions/browser-tools/tools/action-cache.js +0 -179
- package/dist/resources/extensions/browser-tools/tools/assertions.js +0 -320
- package/dist/resources/extensions/browser-tools/tools/codegen.js +0 -242
- package/dist/resources/extensions/browser-tools/tools/device.js +0 -162
- package/dist/resources/extensions/browser-tools/tools/extract.js +0 -191
- package/dist/resources/extensions/browser-tools/tools/forms.js +0 -710
- package/dist/resources/extensions/browser-tools/tools/injection-detect.js +0 -178
- package/dist/resources/extensions/browser-tools/tools/inspection.js +0 -426
- package/dist/resources/extensions/browser-tools/tools/intent.js +0 -556
- package/dist/resources/extensions/browser-tools/tools/interaction.js +0 -776
- package/dist/resources/extensions/browser-tools/tools/navigation.js +0 -208
- package/dist/resources/extensions/browser-tools/tools/network-mock.js +0 -194
- package/dist/resources/extensions/browser-tools/tools/pages.js +0 -280
- package/dist/resources/extensions/browser-tools/tools/pdf.js +0 -74
- package/dist/resources/extensions/browser-tools/tools/refs.js +0 -485
- package/dist/resources/extensions/browser-tools/tools/screenshot.js +0 -87
- package/dist/resources/extensions/browser-tools/tools/session.js +0 -375
- package/dist/resources/extensions/browser-tools/tools/state-persistence.js +0 -180
- package/dist/resources/extensions/browser-tools/tools/visual-diff.js +0 -174
- package/dist/resources/extensions/browser-tools/tools/wait.js +0 -201
- package/dist/resources/extensions/browser-tools/tools/zoom.js +0 -90
- package/dist/resources/extensions/browser-tools/utils.js +0 -490
- package/dist/resources/extensions/context7/index.js +0 -337
- package/dist/resources/extensions/get-secrets-from-user.js +0 -492
- package/dist/resources/extensions/google-search/index.js +0 -373
- package/dist/resources/extensions/gsd/activity-log.js +0 -146
- package/dist/resources/extensions/gsd/atomic-write.js +0 -38
- package/dist/resources/extensions/gsd/auto/session.js +0 -187
- package/dist/resources/extensions/gsd/auto-budget.js +0 -30
- package/dist/resources/extensions/gsd/auto-dashboard.js +0 -509
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +0 -180
- package/dist/resources/extensions/gsd/auto-dispatch.js +0 -382
- package/dist/resources/extensions/gsd/auto-idempotency.js +0 -106
- package/dist/resources/extensions/gsd/auto-model-selection.js +0 -133
- package/dist/resources/extensions/gsd/auto-observability.js +0 -54
- package/dist/resources/extensions/gsd/auto-post-unit.js +0 -495
- package/dist/resources/extensions/gsd/auto-prompts.js +0 -1121
- package/dist/resources/extensions/gsd/auto-recovery.js +0 -550
- package/dist/resources/extensions/gsd/auto-start.js +0 -393
- package/dist/resources/extensions/gsd/auto-stuck-detection.js +0 -165
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +0 -183
- package/dist/resources/extensions/gsd/auto-timers.js +0 -181
- package/dist/resources/extensions/gsd/auto-tool-tracking.js +0 -50
- package/dist/resources/extensions/gsd/auto-unit-closeout.js +0 -30
- package/dist/resources/extensions/gsd/auto-verification.js +0 -209
- package/dist/resources/extensions/gsd/auto-worktree.js +0 -594
- package/dist/resources/extensions/gsd/auto.js +0 -1485
- package/dist/resources/extensions/gsd/captures.js +0 -348
- package/dist/resources/extensions/gsd/claude-import.js +0 -540
- package/dist/resources/extensions/gsd/collision-diagnostics.js +0 -226
- package/dist/resources/extensions/gsd/commands-bootstrap.js +0 -223
- package/dist/resources/extensions/gsd/commands-config.js +0 -89
- package/dist/resources/extensions/gsd/commands-extensions.js +0 -259
- package/dist/resources/extensions/gsd/commands-handlers.js +0 -310
- package/dist/resources/extensions/gsd/commands-inspect.js +0 -70
- package/dist/resources/extensions/gsd/commands-logs.js +0 -468
- package/dist/resources/extensions/gsd/commands-maintenance.js +0 -185
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +0 -660
- package/dist/resources/extensions/gsd/commands-workflow-templates.js +0 -408
- package/dist/resources/extensions/gsd/commands.js +0 -1024
- package/dist/resources/extensions/gsd/complexity-classifier.js +0 -257
- package/dist/resources/extensions/gsd/context-budget.js +0 -187
- package/dist/resources/extensions/gsd/context-store.js +0 -165
- package/dist/resources/extensions/gsd/crash-recovery.js +0 -110
- package/dist/resources/extensions/gsd/dashboard-overlay.js +0 -562
- package/dist/resources/extensions/gsd/db-writer.js +0 -298
- package/dist/resources/extensions/gsd/debug-logger.js +0 -161
- package/dist/resources/extensions/gsd/detection.js +0 -373
- package/dist/resources/extensions/gsd/diff-context.js +0 -168
- package/dist/resources/extensions/gsd/dispatch-guard.js +0 -76
- package/dist/resources/extensions/gsd/doctor-checks.js +0 -563
- package/dist/resources/extensions/gsd/doctor-environment.js +0 -429
- package/dist/resources/extensions/gsd/doctor-format.js +0 -71
- package/dist/resources/extensions/gsd/doctor-proactive.js +0 -239
- package/dist/resources/extensions/gsd/doctor-providers.js +0 -292
- package/dist/resources/extensions/gsd/doctor-types.js +0 -12
- package/dist/resources/extensions/gsd/doctor.js +0 -672
- package/dist/resources/extensions/gsd/error-utils.js +0 -6
- package/dist/resources/extensions/gsd/exit-command.js +0 -11
- package/dist/resources/extensions/gsd/export.js +0 -268
- package/dist/resources/extensions/gsd/file-watcher.js +0 -76
- package/dist/resources/extensions/gsd/files.js +0 -937
- package/dist/resources/extensions/gsd/forensics.js +0 -511
- package/dist/resources/extensions/gsd/git-self-heal.js +0 -113
- package/dist/resources/extensions/gsd/git-service.js +0 -460
- package/dist/resources/extensions/gsd/gsd-db.js +0 -590
- package/dist/resources/extensions/gsd/guided-flow-queue.js +0 -366
- package/dist/resources/extensions/gsd/guided-flow.js +0 -1149
- package/dist/resources/extensions/gsd/health-widget.js +0 -141
- package/dist/resources/extensions/gsd/history.js +0 -118
- package/dist/resources/extensions/gsd/index.js +0 -1250
- package/dist/resources/extensions/gsd/init-wizard.js +0 -479
- package/dist/resources/extensions/gsd/json-persistence.js +0 -62
- package/dist/resources/extensions/gsd/key-manager.js +0 -829
- package/dist/resources/extensions/gsd/marketplace-discovery.js +0 -356
- package/dist/resources/extensions/gsd/md-importer.js +0 -440
- package/dist/resources/extensions/gsd/mechanical-completion.js +0 -351
- package/dist/resources/extensions/gsd/memory-extractor.js +0 -295
- package/dist/resources/extensions/gsd/memory-store.js +0 -351
- package/dist/resources/extensions/gsd/metrics.js +0 -377
- package/dist/resources/extensions/gsd/migrate/command.js +0 -157
- package/dist/resources/extensions/gsd/migrate/index.js +0 -7
- package/dist/resources/extensions/gsd/migrate/parser.js +0 -268
- package/dist/resources/extensions/gsd/migrate/parsers.js +0 -477
- package/dist/resources/extensions/gsd/migrate/preview.js +0 -47
- package/dist/resources/extensions/gsd/migrate/transformer.js +0 -278
- package/dist/resources/extensions/gsd/migrate/types.js +0 -4
- package/dist/resources/extensions/gsd/migrate/validator.js +0 -41
- package/dist/resources/extensions/gsd/migrate/writer.js +0 -477
- package/dist/resources/extensions/gsd/migrate-external.js +0 -130
- package/dist/resources/extensions/gsd/milestone-actions.js +0 -111
- package/dist/resources/extensions/gsd/model-cost-table.js +0 -48
- package/dist/resources/extensions/gsd/model-router.js +0 -187
- package/dist/resources/extensions/gsd/namespaced-registry.js +0 -322
- package/dist/resources/extensions/gsd/namespaced-resolver.js +0 -176
- package/dist/resources/extensions/gsd/native-git-bridge.js +0 -842
- package/dist/resources/extensions/gsd/native-parser-bridge.js +0 -156
- package/dist/resources/extensions/gsd/notifications.js +0 -58
- package/dist/resources/extensions/gsd/observability-validator.js +0 -398
- package/dist/resources/extensions/gsd/parallel-eligibility.js +0 -182
- package/dist/resources/extensions/gsd/parallel-merge.js +0 -121
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +0 -687
- package/dist/resources/extensions/gsd/paths.js +0 -414
- package/dist/resources/extensions/gsd/plugin-importer.js +0 -254
- package/dist/resources/extensions/gsd/post-unit-hooks.js +0 -433
- package/dist/resources/extensions/gsd/preferences-models.js +0 -294
- package/dist/resources/extensions/gsd/preferences-skills.js +0 -154
- package/dist/resources/extensions/gsd/preferences-types.js +0 -73
- package/dist/resources/extensions/gsd/preferences-validation.js +0 -607
- package/dist/resources/extensions/gsd/preferences.js +0 -325
- package/dist/resources/extensions/gsd/progress-score.js +0 -197
- package/dist/resources/extensions/gsd/prompt-cache-optimizer.js +0 -150
- package/dist/resources/extensions/gsd/prompt-compressor.js +0 -393
- package/dist/resources/extensions/gsd/prompt-loader.js +0 -119
- package/dist/resources/extensions/gsd/prompt-ordering.js +0 -170
- package/dist/resources/extensions/gsd/provider-error-pause.js +0 -60
- package/dist/resources/extensions/gsd/queue-order.js +0 -178
- package/dist/resources/extensions/gsd/queue-reorder-ui.js +0 -234
- package/dist/resources/extensions/gsd/quick.js +0 -230
- package/dist/resources/extensions/gsd/repo-identity.js +0 -187
- package/dist/resources/extensions/gsd/roadmap-slices.js +0 -130
- package/dist/resources/extensions/gsd/routing-history.js +0 -210
- package/dist/resources/extensions/gsd/safe-fs.js +0 -52
- package/dist/resources/extensions/gsd/semantic-chunker.js +0 -254
- package/dist/resources/extensions/gsd/session-forensics.js +0 -427
- package/dist/resources/extensions/gsd/session-lock.js +0 -376
- package/dist/resources/extensions/gsd/session-status-io.js +0 -134
- package/dist/resources/extensions/gsd/skill-discovery.js +0 -121
- package/dist/resources/extensions/gsd/skill-health.js +0 -324
- package/dist/resources/extensions/gsd/state.js +0 -653
- package/dist/resources/extensions/gsd/structured-data-formatter.js +0 -97
- package/dist/resources/extensions/gsd/summary-distiller.js +0 -212
- package/dist/resources/extensions/gsd/token-counter.js +0 -54
- package/dist/resources/extensions/gsd/triage-resolution.js +0 -217
- package/dist/resources/extensions/gsd/triage-ui.js +0 -125
- package/dist/resources/extensions/gsd/types.js +0 -4
- package/dist/resources/extensions/gsd/undo.js +0 -210
- package/dist/resources/extensions/gsd/unit-id.js +0 -7
- package/dist/resources/extensions/gsd/unit-runtime.js +0 -130
- package/dist/resources/extensions/gsd/validate-directory.js +0 -143
- package/dist/resources/extensions/gsd/verification-evidence.js +0 -123
- package/dist/resources/extensions/gsd/verification-gate.js +0 -543
- package/dist/resources/extensions/gsd/visualizer-data.js +0 -612
- package/dist/resources/extensions/gsd/visualizer-overlay.js +0 -501
- package/dist/resources/extensions/gsd/visualizer-views.js +0 -893
- package/dist/resources/extensions/gsd/workflow-templates.js +0 -188
- package/dist/resources/extensions/gsd/workspace-index.js +0 -139
- package/dist/resources/extensions/gsd/worktree-command-bootstrap.js +0 -40
- package/dist/resources/extensions/gsd/worktree-command.js +0 -676
- package/dist/resources/extensions/gsd/worktree-manager.js +0 -359
- package/dist/resources/extensions/gsd/worktree.js +0 -236
- package/dist/resources/extensions/mac-tools/index.js +0 -768
- package/dist/resources/extensions/mcp-client/index.js +0 -363
- package/dist/resources/extensions/package.json +0 -3
- package/dist/resources/extensions/remote-questions/config.js +0 -70
- package/dist/resources/extensions/remote-questions/discord-adapter.js +0 -134
- package/dist/resources/extensions/remote-questions/format.js +0 -234
- package/dist/resources/extensions/remote-questions/http-client.js +0 -43
- package/dist/resources/extensions/remote-questions/manager.js +0 -156
- package/dist/resources/extensions/remote-questions/notify.js +0 -89
- package/dist/resources/extensions/remote-questions/remote-command.js +0 -453
- package/dist/resources/extensions/remote-questions/slack-adapter.js +0 -123
- package/dist/resources/extensions/remote-questions/status.js +0 -25
- package/dist/resources/extensions/remote-questions/store.js +0 -70
- package/dist/resources/extensions/remote-questions/telegram-adapter.js +0 -123
- package/dist/resources/extensions/remote-questions/types.js +0 -5
- package/dist/resources/extensions/search-the-web/cache.js +0 -74
- package/dist/resources/extensions/search-the-web/command-search-provider.js +0 -79
- package/dist/resources/extensions/search-the-web/format.js +0 -161
- package/dist/resources/extensions/search-the-web/http.js +0 -178
- package/dist/resources/extensions/search-the-web/index.js +0 -41
- package/dist/resources/extensions/search-the-web/native-search.js +0 -166
- package/dist/resources/extensions/search-the-web/provider.js +0 -143
- package/dist/resources/extensions/search-the-web/tavily.js +0 -82
- package/dist/resources/extensions/search-the-web/tool-fetch-page.js +0 -452
- package/dist/resources/extensions/search-the-web/tool-llm-context.js +0 -455
- package/dist/resources/extensions/search-the-web/tool-search.js +0 -482
- package/dist/resources/extensions/search-the-web/url-utils.js +0 -121
- package/dist/resources/extensions/shared/confirm-ui.js +0 -96
- package/dist/resources/extensions/shared/frontmatter.js +0 -109
- package/dist/resources/extensions/shared/interview-ui.js +0 -569
- package/dist/resources/extensions/shared/next-action-ui.js +0 -168
- package/dist/resources/extensions/shared/sanitize.js +0 -17
- package/dist/resources/extensions/shared/terminal.js +0 -21
- package/dist/resources/extensions/shared/ui.js +0 -245
- package/dist/resources/extensions/shared/wizard-ui.js +0 -478
- package/dist/resources/extensions/slash-commands/audit.js +0 -72
- package/dist/resources/extensions/slash-commands/clear.js +0 -8
- package/dist/resources/extensions/slash-commands/create-extension.js +0 -264
- package/dist/resources/extensions/slash-commands/create-slash-command.js +0 -208
- package/dist/resources/extensions/slash-commands/index.js +0 -10
- package/dist/resources/extensions/subagent/agents.js +0 -103
- package/dist/resources/extensions/subagent/index.js +0 -905
- package/dist/resources/extensions/subagent/isolation.js +0 -384
- package/dist/resources/extensions/subagent/worker-registry.js +0 -73
- package/dist/resources/extensions/ttsr/index.js +0 -144
- package/dist/resources/extensions/ttsr/rule-loader.js +0 -70
- package/dist/resources/extensions/ttsr/ttsr-manager.js +0 -380
- package/dist/resources/extensions/universal-config/discovery.js +0 -94
- package/dist/resources/extensions/universal-config/format.js +0 -178
- package/dist/resources/extensions/universal-config/index.js +0 -99
- package/dist/resources/extensions/universal-config/scanners.js +0 -574
- package/dist/resources/extensions/universal-config/tools.js +0 -57
- package/dist/resources/extensions/universal-config/types.js +0 -8
- package/dist/resources/extensions/voice/index.js +0 -247
- package/dist/startup-timings.d.ts +0 -2
- package/dist/startup-timings.js +0 -22
- package/src/resources/extensions/gsd/commands-bootstrap.ts +0 -252
- package/src/resources/extensions/gsd/tests/quick-branch-lifecycle.test.ts +0 -281
- package/src/resources/extensions/gsd/tests/repo-identity-worktree.test.ts +0 -71
- package/src/resources/extensions/gsd/worktree-command-bootstrap.ts +0 -46
- package/src/resources/extensions/package.json +0 -3
|
@@ -0,0 +1,1121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Tool - Delegate tasks to specialized agents
|
|
3
|
+
*
|
|
4
|
+
* Spawns a separate `pi` process for each subagent invocation,
|
|
5
|
+
* giving it an isolated context window.
|
|
6
|
+
*
|
|
7
|
+
* Supports three modes:
|
|
8
|
+
* - Single: { agent: "name", task: "..." }
|
|
9
|
+
* - Parallel: { tasks: [{ agent: "name", task: "..." }, ...] }
|
|
10
|
+
* - Chain: { chain: [{ agent: "name", task: "... {previous} ..." }, ...] }
|
|
11
|
+
*
|
|
12
|
+
* Uses JSON mode to capture structured output from subagents.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { spawn, type ChildProcess } from "node:child_process";
|
|
16
|
+
import * as crypto from "node:crypto";
|
|
17
|
+
import * as fs from "node:fs";
|
|
18
|
+
import * as os from "node:os";
|
|
19
|
+
import * as path from "node:path";
|
|
20
|
+
import type { AgentToolResult } from "@gsd/pi-agent-core";
|
|
21
|
+
import type { Message } from "@gsd/pi-ai";
|
|
22
|
+
import { StringEnum } from "@gsd/pi-ai";
|
|
23
|
+
import { type ExtensionAPI, getMarkdownTheme } from "@gsd/pi-coding-agent";
|
|
24
|
+
import { Container, Markdown, Spacer, Text } from "@gsd/pi-tui";
|
|
25
|
+
import { Type } from "@sinclair/typebox";
|
|
26
|
+
import { type AgentConfig, type AgentScope, discoverAgents } from "./agents.js";
|
|
27
|
+
import {
|
|
28
|
+
type IsolationEnvironment,
|
|
29
|
+
type IsolationMode,
|
|
30
|
+
type MergeResult,
|
|
31
|
+
createIsolation,
|
|
32
|
+
mergeDeltaPatches,
|
|
33
|
+
readIsolationMode,
|
|
34
|
+
} from "./isolation.js";
|
|
35
|
+
import { registerWorker, updateWorker } from "./worker-registry.js";
|
|
36
|
+
|
|
37
|
+
const MAX_PARALLEL_TASKS = 8;
|
|
38
|
+
const MAX_CONCURRENCY = 4;
|
|
39
|
+
const COLLAPSED_ITEM_COUNT = 10;
|
|
40
|
+
const liveSubagentProcesses = new Set<ChildProcess>();
|
|
41
|
+
|
|
42
|
+
async function stopLiveSubagents(): Promise<void> {
|
|
43
|
+
const active = Array.from(liveSubagentProcesses);
|
|
44
|
+
if (active.length === 0) return;
|
|
45
|
+
|
|
46
|
+
for (const proc of active) {
|
|
47
|
+
try {
|
|
48
|
+
proc.kill("SIGTERM");
|
|
49
|
+
} catch {
|
|
50
|
+
/* ignore */
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
await Promise.all(
|
|
55
|
+
active.map(
|
|
56
|
+
(proc) =>
|
|
57
|
+
new Promise<void>((resolve) => {
|
|
58
|
+
const done = () => resolve();
|
|
59
|
+
const timer = setTimeout(done, 500);
|
|
60
|
+
proc.once("exit", () => {
|
|
61
|
+
clearTimeout(timer);
|
|
62
|
+
resolve();
|
|
63
|
+
});
|
|
64
|
+
}),
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
for (const proc of active) {
|
|
69
|
+
if (proc.exitCode === null) {
|
|
70
|
+
try {
|
|
71
|
+
proc.kill("SIGKILL");
|
|
72
|
+
} catch {
|
|
73
|
+
/* ignore */
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function formatTokens(count: number): string {
|
|
80
|
+
if (count < 1000) return count.toString();
|
|
81
|
+
if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
|
|
82
|
+
if (count < 1000000) return `${Math.round(count / 1000)}k`;
|
|
83
|
+
return `${(count / 1000000).toFixed(1)}M`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function formatUsageStats(
|
|
87
|
+
usage: {
|
|
88
|
+
input: number;
|
|
89
|
+
output: number;
|
|
90
|
+
cacheRead: number;
|
|
91
|
+
cacheWrite: number;
|
|
92
|
+
cost: number;
|
|
93
|
+
contextTokens?: number;
|
|
94
|
+
turns?: number;
|
|
95
|
+
},
|
|
96
|
+
model?: string,
|
|
97
|
+
): string {
|
|
98
|
+
const parts: string[] = [];
|
|
99
|
+
if (usage.turns) parts.push(`${usage.turns} turn${usage.turns > 1 ? "s" : ""}`);
|
|
100
|
+
if (usage.input) parts.push(`↑${formatTokens(usage.input)}`);
|
|
101
|
+
if (usage.output) parts.push(`↓${formatTokens(usage.output)}`);
|
|
102
|
+
if (usage.cacheRead) parts.push(`R${formatTokens(usage.cacheRead)}`);
|
|
103
|
+
if (usage.cacheWrite) parts.push(`W${formatTokens(usage.cacheWrite)}`);
|
|
104
|
+
if (usage.cost) parts.push(`$${(Number(usage.cost) || 0).toFixed(4)}`);
|
|
105
|
+
if (usage.contextTokens && usage.contextTokens > 0) {
|
|
106
|
+
parts.push(`ctx:${formatTokens(usage.contextTokens)}`);
|
|
107
|
+
}
|
|
108
|
+
if (model) parts.push(model);
|
|
109
|
+
return parts.join(" ");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function formatToolCall(
|
|
113
|
+
toolName: string,
|
|
114
|
+
args: Record<string, unknown>,
|
|
115
|
+
themeFg: (color: any, text: string) => string,
|
|
116
|
+
): string {
|
|
117
|
+
const shortenPath = (p: string) => {
|
|
118
|
+
const home = os.homedir();
|
|
119
|
+
return p.startsWith(home) ? `~${p.slice(home.length)}` : p;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
switch (toolName) {
|
|
123
|
+
case "bash": {
|
|
124
|
+
const command = (args.command as string) || "...";
|
|
125
|
+
const preview = command.length > 60 ? `${command.slice(0, 60)}...` : command;
|
|
126
|
+
return themeFg("muted", "$ ") + themeFg("toolOutput", preview);
|
|
127
|
+
}
|
|
128
|
+
case "read": {
|
|
129
|
+
const rawPath = (args.file_path || args.path || "...") as string;
|
|
130
|
+
const filePath = shortenPath(rawPath);
|
|
131
|
+
const offset = args.offset as number | undefined;
|
|
132
|
+
const limit = args.limit as number | undefined;
|
|
133
|
+
let text = themeFg("accent", filePath);
|
|
134
|
+
if (offset !== undefined || limit !== undefined) {
|
|
135
|
+
const startLine = offset ?? 1;
|
|
136
|
+
const endLine = limit !== undefined ? startLine + limit - 1 : "";
|
|
137
|
+
text += themeFg("warning", `:${startLine}${endLine ? `-${endLine}` : ""}`);
|
|
138
|
+
}
|
|
139
|
+
return themeFg("muted", "read ") + text;
|
|
140
|
+
}
|
|
141
|
+
case "write": {
|
|
142
|
+
const rawPath = (args.file_path || args.path || "...") as string;
|
|
143
|
+
const filePath = shortenPath(rawPath);
|
|
144
|
+
const content = (args.content || "") as string;
|
|
145
|
+
const lines = content.split("\n").length;
|
|
146
|
+
let text = themeFg("muted", "write ") + themeFg("accent", filePath);
|
|
147
|
+
if (lines > 1) text += themeFg("dim", ` (${lines} lines)`);
|
|
148
|
+
return text;
|
|
149
|
+
}
|
|
150
|
+
case "edit": {
|
|
151
|
+
const rawPath = (args.file_path || args.path || "...") as string;
|
|
152
|
+
return themeFg("muted", "edit ") + themeFg("accent", shortenPath(rawPath));
|
|
153
|
+
}
|
|
154
|
+
case "ls": {
|
|
155
|
+
const rawPath = (args.path || ".") as string;
|
|
156
|
+
return themeFg("muted", "ls ") + themeFg("accent", shortenPath(rawPath));
|
|
157
|
+
}
|
|
158
|
+
case "find": {
|
|
159
|
+
const pattern = (args.pattern || "*") as string;
|
|
160
|
+
const rawPath = (args.path || ".") as string;
|
|
161
|
+
return themeFg("muted", "find ") + themeFg("accent", pattern) + themeFg("dim", ` in ${shortenPath(rawPath)}`);
|
|
162
|
+
}
|
|
163
|
+
case "grep": {
|
|
164
|
+
const pattern = (args.pattern || "") as string;
|
|
165
|
+
const rawPath = (args.path || ".") as string;
|
|
166
|
+
return (
|
|
167
|
+
themeFg("muted", "grep ") +
|
|
168
|
+
themeFg("accent", `/${pattern}/`) +
|
|
169
|
+
themeFg("dim", ` in ${shortenPath(rawPath)}`)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
default: {
|
|
173
|
+
const argsStr = JSON.stringify(args);
|
|
174
|
+
const preview = argsStr.length > 50 ? `${argsStr.slice(0, 50)}...` : argsStr;
|
|
175
|
+
return themeFg("accent", toolName) + themeFg("dim", ` ${preview}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
interface UsageStats {
|
|
181
|
+
input: number;
|
|
182
|
+
output: number;
|
|
183
|
+
cacheRead: number;
|
|
184
|
+
cacheWrite: number;
|
|
185
|
+
cost: number;
|
|
186
|
+
contextTokens: number;
|
|
187
|
+
turns: number;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
interface SingleResult {
|
|
191
|
+
agent: string;
|
|
192
|
+
agentSource: "user" | "project" | "unknown";
|
|
193
|
+
task: string;
|
|
194
|
+
exitCode: number;
|
|
195
|
+
messages: Message[];
|
|
196
|
+
stderr: string;
|
|
197
|
+
usage: UsageStats;
|
|
198
|
+
model?: string;
|
|
199
|
+
stopReason?: string;
|
|
200
|
+
errorMessage?: string;
|
|
201
|
+
step?: number;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
interface SubagentDetails {
|
|
205
|
+
mode: "single" | "parallel" | "chain";
|
|
206
|
+
agentScope: AgentScope;
|
|
207
|
+
projectAgentsDir: string | null;
|
|
208
|
+
results: SingleResult[];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function getFinalOutput(messages: Message[]): string {
|
|
212
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
213
|
+
const msg = messages[i];
|
|
214
|
+
if (msg.role === "assistant") {
|
|
215
|
+
for (const part of msg.content) {
|
|
216
|
+
if (part.type === "text") return part.text;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return "";
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
type DisplayItem = { type: "text"; text: string } | { type: "toolCall"; name: string; args: Record<string, any> };
|
|
224
|
+
|
|
225
|
+
function getDisplayItems(messages: Message[]): DisplayItem[] {
|
|
226
|
+
const items: DisplayItem[] = [];
|
|
227
|
+
for (const msg of messages) {
|
|
228
|
+
if (msg.role === "assistant") {
|
|
229
|
+
for (const part of msg.content) {
|
|
230
|
+
if (part.type === "text") items.push({ type: "text", text: part.text });
|
|
231
|
+
else if (part.type === "toolCall") items.push({ type: "toolCall", name: part.name, args: part.arguments });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return items;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async function mapWithConcurrencyLimit<TIn, TOut>(
|
|
239
|
+
items: TIn[],
|
|
240
|
+
concurrency: number,
|
|
241
|
+
fn: (item: TIn, index: number) => Promise<TOut>,
|
|
242
|
+
): Promise<TOut[]> {
|
|
243
|
+
if (items.length === 0) return [];
|
|
244
|
+
const limit = Math.max(1, Math.min(concurrency, items.length));
|
|
245
|
+
const results: TOut[] = new Array(items.length);
|
|
246
|
+
let nextIndex = 0;
|
|
247
|
+
const workers = new Array(limit).fill(null).map(async () => {
|
|
248
|
+
while (true) {
|
|
249
|
+
const current = nextIndex++;
|
|
250
|
+
if (current >= items.length) return;
|
|
251
|
+
results[current] = await fn(items[current], current);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
await Promise.all(workers);
|
|
255
|
+
return results;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function writePromptToTempFile(agentName: string, prompt: string): { dir: string; filePath: string } {
|
|
259
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagent-"));
|
|
260
|
+
const safeName = agentName.replace(/[^\w.-]+/g, "_");
|
|
261
|
+
const filePath = path.join(tmpDir, `prompt-${safeName}.md`);
|
|
262
|
+
fs.writeFileSync(filePath, prompt, { encoding: "utf-8", mode: 0o600 });
|
|
263
|
+
return { dir: tmpDir, filePath };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
type OnUpdateCallback = (partial: AgentToolResult<SubagentDetails>) => void;
|
|
267
|
+
|
|
268
|
+
async function runSingleAgent(
|
|
269
|
+
defaultCwd: string,
|
|
270
|
+
agents: AgentConfig[],
|
|
271
|
+
agentName: string,
|
|
272
|
+
task: string,
|
|
273
|
+
cwd: string | undefined,
|
|
274
|
+
step: number | undefined,
|
|
275
|
+
signal: AbortSignal | undefined,
|
|
276
|
+
onUpdate: OnUpdateCallback | undefined,
|
|
277
|
+
makeDetails: (results: SingleResult[]) => SubagentDetails,
|
|
278
|
+
): Promise<SingleResult> {
|
|
279
|
+
const agent = agents.find((a) => a.name === agentName);
|
|
280
|
+
|
|
281
|
+
if (!agent) {
|
|
282
|
+
const available = agents.map((a) => `"${a.name}"`).join(", ") || "none";
|
|
283
|
+
return {
|
|
284
|
+
agent: agentName,
|
|
285
|
+
agentSource: "unknown",
|
|
286
|
+
task,
|
|
287
|
+
exitCode: 1,
|
|
288
|
+
messages: [],
|
|
289
|
+
stderr: `Unknown agent: "${agentName}". Available agents: ${available}.`,
|
|
290
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
291
|
+
step,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const args: string[] = ["--mode", "json", "-p", "--no-session"];
|
|
296
|
+
if (agent.model) args.push("--model", agent.model);
|
|
297
|
+
if (agent.tools && agent.tools.length > 0) args.push("--tools", agent.tools.join(","));
|
|
298
|
+
|
|
299
|
+
let tmpPromptDir: string | null = null;
|
|
300
|
+
let tmpPromptPath: string | null = null;
|
|
301
|
+
|
|
302
|
+
const currentResult: SingleResult = {
|
|
303
|
+
agent: agentName,
|
|
304
|
+
agentSource: agent.source,
|
|
305
|
+
task,
|
|
306
|
+
exitCode: 0,
|
|
307
|
+
messages: [],
|
|
308
|
+
stderr: "",
|
|
309
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
310
|
+
model: agent.model,
|
|
311
|
+
step,
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const emitUpdate = () => {
|
|
315
|
+
if (onUpdate) {
|
|
316
|
+
onUpdate({
|
|
317
|
+
content: [{ type: "text", text: getFinalOutput(currentResult.messages) || "(running...)" }],
|
|
318
|
+
details: makeDetails([currentResult]),
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
try {
|
|
324
|
+
if (agent.systemPrompt.trim()) {
|
|
325
|
+
const tmp = writePromptToTempFile(agent.name, agent.systemPrompt);
|
|
326
|
+
tmpPromptDir = tmp.dir;
|
|
327
|
+
tmpPromptPath = tmp.filePath;
|
|
328
|
+
args.push("--append-system-prompt", tmpPromptPath);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
args.push(`Task: ${task}`);
|
|
332
|
+
let wasAborted = false;
|
|
333
|
+
|
|
334
|
+
const exitCode = await new Promise<number>((resolve) => {
|
|
335
|
+
const bundledPaths = (process.env.GSD_BUNDLED_EXTENSION_PATHS ?? "").split(path.delimiter).map(s => s.trim()).filter(Boolean);
|
|
336
|
+
const extensionArgs = bundledPaths.flatMap(p => ["--extension", p]);
|
|
337
|
+
const proc = spawn(
|
|
338
|
+
process.execPath,
|
|
339
|
+
[process.env.GSD_BIN_PATH!, ...extensionArgs, ...args],
|
|
340
|
+
{ cwd: cwd ?? defaultCwd, shell: false, stdio: ["ignore", "pipe", "pipe"] },
|
|
341
|
+
);
|
|
342
|
+
liveSubagentProcesses.add(proc);
|
|
343
|
+
let buffer = "";
|
|
344
|
+
|
|
345
|
+
const processLine = (line: string) => {
|
|
346
|
+
if (!line.trim()) return;
|
|
347
|
+
let event: any;
|
|
348
|
+
try {
|
|
349
|
+
event = JSON.parse(line);
|
|
350
|
+
} catch {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (event.type === "message_end" && event.message) {
|
|
355
|
+
const msg = event.message as Message;
|
|
356
|
+
currentResult.messages.push(msg);
|
|
357
|
+
|
|
358
|
+
if (msg.role === "assistant") {
|
|
359
|
+
currentResult.usage.turns++;
|
|
360
|
+
const usage = msg.usage;
|
|
361
|
+
if (usage) {
|
|
362
|
+
currentResult.usage.input += usage.input || 0;
|
|
363
|
+
currentResult.usage.output += usage.output || 0;
|
|
364
|
+
currentResult.usage.cacheRead += usage.cacheRead || 0;
|
|
365
|
+
currentResult.usage.cacheWrite += usage.cacheWrite || 0;
|
|
366
|
+
currentResult.usage.cost += usage.cost?.total || 0;
|
|
367
|
+
currentResult.usage.contextTokens = usage.totalTokens || 0;
|
|
368
|
+
}
|
|
369
|
+
if (!currentResult.model && msg.model) currentResult.model = msg.model;
|
|
370
|
+
if (msg.stopReason) currentResult.stopReason = msg.stopReason;
|
|
371
|
+
if (msg.errorMessage) currentResult.errorMessage = msg.errorMessage;
|
|
372
|
+
}
|
|
373
|
+
emitUpdate();
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (event.type === "tool_result_end" && event.message) {
|
|
377
|
+
currentResult.messages.push(event.message as Message);
|
|
378
|
+
emitUpdate();
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
proc.stdout.on("data", (data) => {
|
|
383
|
+
buffer += data.toString();
|
|
384
|
+
const lines = buffer.split("\n");
|
|
385
|
+
buffer = lines.pop() || "";
|
|
386
|
+
for (const line of lines) processLine(line);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
proc.stderr.on("data", (data) => {
|
|
390
|
+
currentResult.stderr += data.toString();
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
proc.on("close", (code) => {
|
|
394
|
+
liveSubagentProcesses.delete(proc);
|
|
395
|
+
if (buffer.trim()) processLine(buffer);
|
|
396
|
+
resolve(code ?? 0);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
proc.on("error", () => {
|
|
400
|
+
liveSubagentProcesses.delete(proc);
|
|
401
|
+
resolve(1);
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
if (signal) {
|
|
405
|
+
const killProc = () => {
|
|
406
|
+
wasAborted = true;
|
|
407
|
+
proc.kill("SIGTERM");
|
|
408
|
+
setTimeout(() => {
|
|
409
|
+
if (!proc.killed) proc.kill("SIGKILL");
|
|
410
|
+
}, 5000);
|
|
411
|
+
};
|
|
412
|
+
if (signal.aborted) killProc();
|
|
413
|
+
else signal.addEventListener("abort", killProc, { once: true });
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
currentResult.exitCode = exitCode;
|
|
418
|
+
if (wasAborted) throw new Error("Subagent was aborted");
|
|
419
|
+
return currentResult;
|
|
420
|
+
} finally {
|
|
421
|
+
if (tmpPromptPath)
|
|
422
|
+
try {
|
|
423
|
+
fs.unlinkSync(tmpPromptPath);
|
|
424
|
+
} catch {
|
|
425
|
+
/* ignore */
|
|
426
|
+
}
|
|
427
|
+
if (tmpPromptDir)
|
|
428
|
+
try {
|
|
429
|
+
fs.rmdirSync(tmpPromptDir);
|
|
430
|
+
} catch {
|
|
431
|
+
/* ignore */
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const TaskItem = Type.Object({
|
|
437
|
+
agent: Type.String({ description: "Name of the agent to invoke" }),
|
|
438
|
+
task: Type.String({ description: "Task to delegate to the agent" }),
|
|
439
|
+
cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
const ChainItem = Type.Object({
|
|
443
|
+
agent: Type.String({ description: "Name of the agent to invoke" }),
|
|
444
|
+
task: Type.String({ description: "Task with optional {previous} placeholder for prior output" }),
|
|
445
|
+
cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
const AgentScopeSchema = StringEnum(["user", "project", "both"] as const, {
|
|
449
|
+
description: 'Which agent directories to use. Default: "both" (user + project-local).',
|
|
450
|
+
default: "both",
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
const SubagentParams = Type.Object({
|
|
454
|
+
agent: Type.Optional(Type.String({ description: "Name of the agent to invoke (for single mode)" })),
|
|
455
|
+
task: Type.Optional(Type.String({ description: "Task to delegate (for single mode)" })),
|
|
456
|
+
tasks: Type.Optional(Type.Array(TaskItem, { description: "Array of {agent, task} for parallel execution" })),
|
|
457
|
+
chain: Type.Optional(Type.Array(ChainItem, { description: "Array of {agent, task} for sequential execution" })),
|
|
458
|
+
agentScope: Type.Optional(AgentScopeSchema),
|
|
459
|
+
confirmProjectAgents: Type.Optional(
|
|
460
|
+
Type.Boolean({ description: "Prompt before running project-local agents. Default: false.", default: false }),
|
|
461
|
+
),
|
|
462
|
+
cwd: Type.Optional(Type.String({ description: "Working directory for the agent process (single mode)" })),
|
|
463
|
+
isolated: Type.Optional(
|
|
464
|
+
Type.Boolean({
|
|
465
|
+
description:
|
|
466
|
+
"Run the subagent in an isolated filesystem (git worktree). " +
|
|
467
|
+
"Changes are captured as patches and merged back. " +
|
|
468
|
+
"Only available when taskIsolation.mode is configured in settings.",
|
|
469
|
+
default: false,
|
|
470
|
+
}),
|
|
471
|
+
),
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
export default function (pi: ExtensionAPI) {
|
|
475
|
+
pi.on("session_shutdown", async () => {
|
|
476
|
+
await stopLiveSubagents();
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
// /subagent command - list available agents
|
|
480
|
+
pi.registerCommand("subagent", {
|
|
481
|
+
description: "List available subagents",
|
|
482
|
+
handler: async (_args, ctx) => {
|
|
483
|
+
const discovery = discoverAgents(ctx.cwd, "both");
|
|
484
|
+
if (discovery.agents.length === 0) {
|
|
485
|
+
ctx.ui.notify("No agents found. Add .md files to ~/.gsd/agent/agents/ or .gsd/agents/", "warning");
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const lines = discovery.agents.map(
|
|
489
|
+
(a) => ` ${a.name} [${a.source}]${a.model ? ` (${a.model})` : ""}: ${a.description}`,
|
|
490
|
+
);
|
|
491
|
+
ctx.ui.notify(`Available agents (${discovery.agents.length}):\n${lines.join("\n")}`, "info");
|
|
492
|
+
},
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
pi.registerTool({
|
|
496
|
+
name: "subagent",
|
|
497
|
+
label: "Subagent",
|
|
498
|
+
description: [
|
|
499
|
+
"Delegate tasks to specialized subagents with isolated context windows.",
|
|
500
|
+
"Each subagent is a separate pi process with its own tools, model, and system prompt.",
|
|
501
|
+
"Modes: single ({ agent, task }), parallel ({ tasks: [{agent, task},...] }), chain ({ chain: [{agent, task},...] } with {previous} placeholder).",
|
|
502
|
+
"Agents are defined as .md files in ~/.gsd/agent/agents/ (user) or .gsd/agents/ (project).",
|
|
503
|
+
"Use the /subagent command to list available agents and their descriptions.",
|
|
504
|
+
"Use chain mode to pipeline: scout finds context, planner designs, worker implements.",
|
|
505
|
+
].join(" "),
|
|
506
|
+
promptGuidelines: [
|
|
507
|
+
"Use subagent to delegate self-contained tasks that benefit from an isolated context window.",
|
|
508
|
+
"Use scout agent first when you need codebase context before implementing.",
|
|
509
|
+
"Use chain mode for scout→planner→worker or worker→reviewer→worker pipelines.",
|
|
510
|
+
"Use parallel mode when tasks are independent and don't need each other's output.",
|
|
511
|
+
"Always check available agents with /subagent before choosing one.",
|
|
512
|
+
],
|
|
513
|
+
parameters: SubagentParams,
|
|
514
|
+
|
|
515
|
+
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
516
|
+
const agentScope: AgentScope = params.agentScope ?? "both";
|
|
517
|
+
const discovery = discoverAgents(ctx.cwd, agentScope);
|
|
518
|
+
const agents = discovery.agents;
|
|
519
|
+
const confirmProjectAgents = params.confirmProjectAgents ?? false;
|
|
520
|
+
|
|
521
|
+
// Resolve isolation mode
|
|
522
|
+
const isolationMode = readIsolationMode();
|
|
523
|
+
const useIsolation = Boolean(params.isolated) && isolationMode !== "none";
|
|
524
|
+
|
|
525
|
+
const hasChain = (params.chain?.length ?? 0) > 0;
|
|
526
|
+
const hasTasks = (params.tasks?.length ?? 0) > 0;
|
|
527
|
+
const hasSingle = Boolean(params.agent && params.task);
|
|
528
|
+
const modeCount = Number(hasChain) + Number(hasTasks) + Number(hasSingle);
|
|
529
|
+
|
|
530
|
+
const makeDetails =
|
|
531
|
+
(mode: "single" | "parallel" | "chain") =>
|
|
532
|
+
(results: SingleResult[]): SubagentDetails => ({
|
|
533
|
+
mode,
|
|
534
|
+
agentScope,
|
|
535
|
+
projectAgentsDir: discovery.projectAgentsDir,
|
|
536
|
+
results,
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
if (modeCount !== 1) {
|
|
540
|
+
const available = agents.map((a) => `${a.name} (${a.source})`).join(", ") || "none";
|
|
541
|
+
return {
|
|
542
|
+
content: [
|
|
543
|
+
{
|
|
544
|
+
type: "text",
|
|
545
|
+
text: `Invalid parameters. Provide exactly one mode.\nAvailable agents: ${available}`,
|
|
546
|
+
},
|
|
547
|
+
],
|
|
548
|
+
details: makeDetails("single")([]),
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if ((agentScope === "project" || agentScope === "both") && confirmProjectAgents && ctx.hasUI) {
|
|
553
|
+
const requestedAgentNames = new Set<string>();
|
|
554
|
+
if (params.chain) for (const step of params.chain) requestedAgentNames.add(step.agent);
|
|
555
|
+
if (params.tasks) for (const t of params.tasks) requestedAgentNames.add(t.agent);
|
|
556
|
+
if (params.agent) requestedAgentNames.add(params.agent);
|
|
557
|
+
|
|
558
|
+
const projectAgentsRequested = Array.from(requestedAgentNames)
|
|
559
|
+
.map((name) => agents.find((a) => a.name === name))
|
|
560
|
+
.filter((a): a is AgentConfig => a?.source === "project");
|
|
561
|
+
|
|
562
|
+
if (projectAgentsRequested.length > 0) {
|
|
563
|
+
const names = projectAgentsRequested.map((a) => a.name).join(", ");
|
|
564
|
+
const dir = discovery.projectAgentsDir ?? "(unknown)";
|
|
565
|
+
const ok = await ctx.ui.confirm(
|
|
566
|
+
"Run project-local agents?",
|
|
567
|
+
`Agents: ${names}\nSource: ${dir}\n\nProject agents are repo-controlled. Only continue for trusted repositories.`,
|
|
568
|
+
);
|
|
569
|
+
if (!ok)
|
|
570
|
+
return {
|
|
571
|
+
content: [{ type: "text", text: "Canceled: project-local agents not approved." }],
|
|
572
|
+
details: makeDetails(hasChain ? "chain" : hasTasks ? "parallel" : "single")([]),
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (params.chain && params.chain.length > 0) {
|
|
578
|
+
const results: SingleResult[] = [];
|
|
579
|
+
let previousOutput = "";
|
|
580
|
+
|
|
581
|
+
for (let i = 0; i < params.chain.length; i++) {
|
|
582
|
+
const step = params.chain[i];
|
|
583
|
+
const taskWithContext = step.task.replace(/\{previous\}/g, previousOutput);
|
|
584
|
+
|
|
585
|
+
// Create update callback that includes all previous results
|
|
586
|
+
const chainUpdate: OnUpdateCallback | undefined = onUpdate
|
|
587
|
+
? (partial) => {
|
|
588
|
+
// Combine completed results with current streaming result
|
|
589
|
+
const currentResult = partial.details?.results[0];
|
|
590
|
+
if (currentResult) {
|
|
591
|
+
const allResults = [...results, currentResult];
|
|
592
|
+
onUpdate({
|
|
593
|
+
content: partial.content,
|
|
594
|
+
details: makeDetails("chain")(allResults),
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
: undefined;
|
|
599
|
+
|
|
600
|
+
const result = await runSingleAgent(
|
|
601
|
+
ctx.cwd,
|
|
602
|
+
agents,
|
|
603
|
+
step.agent,
|
|
604
|
+
taskWithContext,
|
|
605
|
+
step.cwd,
|
|
606
|
+
i + 1,
|
|
607
|
+
signal,
|
|
608
|
+
chainUpdate,
|
|
609
|
+
makeDetails("chain"),
|
|
610
|
+
);
|
|
611
|
+
results.push(result);
|
|
612
|
+
|
|
613
|
+
const isError =
|
|
614
|
+
result.exitCode !== 0 || result.stopReason === "error" || result.stopReason === "aborted";
|
|
615
|
+
if (isError) {
|
|
616
|
+
const errorMsg =
|
|
617
|
+
result.errorMessage || result.stderr || getFinalOutput(result.messages) || "(no output)";
|
|
618
|
+
return {
|
|
619
|
+
content: [{ type: "text", text: `Chain stopped at step ${i + 1} (${step.agent}): ${errorMsg}` }],
|
|
620
|
+
details: makeDetails("chain")(results),
|
|
621
|
+
isError: true,
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
previousOutput = getFinalOutput(result.messages);
|
|
625
|
+
}
|
|
626
|
+
return {
|
|
627
|
+
content: [{ type: "text", text: getFinalOutput(results[results.length - 1].messages) || "(no output)" }],
|
|
628
|
+
details: makeDetails("chain")(results),
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (params.tasks && params.tasks.length > 0) {
|
|
633
|
+
if (params.tasks.length > MAX_PARALLEL_TASKS)
|
|
634
|
+
return {
|
|
635
|
+
content: [
|
|
636
|
+
{
|
|
637
|
+
type: "text",
|
|
638
|
+
text: `Too many parallel tasks (${params.tasks.length}). Max is ${MAX_PARALLEL_TASKS}.`,
|
|
639
|
+
},
|
|
640
|
+
],
|
|
641
|
+
details: makeDetails("parallel")([]),
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
// Track all results for streaming updates
|
|
645
|
+
const allResults: SingleResult[] = new Array(params.tasks.length);
|
|
646
|
+
|
|
647
|
+
// Initialize placeholder results
|
|
648
|
+
for (let i = 0; i < params.tasks.length; i++) {
|
|
649
|
+
allResults[i] = {
|
|
650
|
+
agent: params.tasks[i].agent,
|
|
651
|
+
agentSource: "unknown",
|
|
652
|
+
task: params.tasks[i].task,
|
|
653
|
+
exitCode: -1, // -1 = still running
|
|
654
|
+
messages: [],
|
|
655
|
+
stderr: "",
|
|
656
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
const emitParallelUpdate = () => {
|
|
661
|
+
if (onUpdate) {
|
|
662
|
+
const running = allResults.filter((r) => r.exitCode === -1).length;
|
|
663
|
+
const done = allResults.filter((r) => r.exitCode !== -1).length;
|
|
664
|
+
onUpdate({
|
|
665
|
+
content: [
|
|
666
|
+
{ type: "text", text: `Parallel: ${done}/${allResults.length} done, ${running} running...` },
|
|
667
|
+
],
|
|
668
|
+
details: makeDetails("parallel")([...allResults]),
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
const MAX_RETRIES = 1; // Retry failed tasks once
|
|
674
|
+
const batchId = crypto.randomUUID();
|
|
675
|
+
const batchSize = params.tasks.length;
|
|
676
|
+
const results = await mapWithConcurrencyLimit(params.tasks, MAX_CONCURRENCY, async (t, index) => {
|
|
677
|
+
const workerId = registerWorker(t.agent, t.task, index, batchSize, batchId);
|
|
678
|
+
let result = await runSingleAgent(
|
|
679
|
+
ctx.cwd,
|
|
680
|
+
agents,
|
|
681
|
+
t.agent,
|
|
682
|
+
t.task,
|
|
683
|
+
t.cwd,
|
|
684
|
+
undefined,
|
|
685
|
+
signal,
|
|
686
|
+
// Per-task update callback
|
|
687
|
+
(partial) => {
|
|
688
|
+
if (partial.details?.results[0]) {
|
|
689
|
+
allResults[index] = partial.details.results[0];
|
|
690
|
+
emitParallelUpdate();
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
makeDetails("parallel"),
|
|
694
|
+
);
|
|
695
|
+
|
|
696
|
+
// Auto-retry failed tasks (likely API rate limit or transient error)
|
|
697
|
+
const isFailed = result.exitCode !== 0 || (result.messages.length === 0 && !signal?.aborted);
|
|
698
|
+
if (isFailed && MAX_RETRIES > 0 && !signal?.aborted) {
|
|
699
|
+
result = await runSingleAgent(
|
|
700
|
+
ctx.cwd,
|
|
701
|
+
agents,
|
|
702
|
+
t.agent,
|
|
703
|
+
t.task,
|
|
704
|
+
t.cwd,
|
|
705
|
+
undefined,
|
|
706
|
+
signal,
|
|
707
|
+
(partial) => {
|
|
708
|
+
if (partial.details?.results[0]) {
|
|
709
|
+
allResults[index] = partial.details.results[0];
|
|
710
|
+
emitParallelUpdate();
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
makeDetails("parallel"),
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
updateWorker(workerId, result.exitCode === 0 ? "completed" : "failed");
|
|
718
|
+
allResults[index] = result;
|
|
719
|
+
emitParallelUpdate();
|
|
720
|
+
return result;
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
const successCount = results.filter((r) => r.exitCode === 0).length;
|
|
724
|
+
const summaries = results.map((r) => {
|
|
725
|
+
const isError = r.exitCode !== 0 || r.stopReason === "error" || r.stopReason === "aborted";
|
|
726
|
+
const output = isError
|
|
727
|
+
? (r.errorMessage || r.stderr || getFinalOutput(r.messages) || "(no output)")
|
|
728
|
+
: getFinalOutput(r.messages);
|
|
729
|
+
return `[${r.agent}] ${r.exitCode === 0 ? "completed" : `failed (exit ${r.exitCode})`}: ${output || "(no output)"}`;
|
|
730
|
+
});
|
|
731
|
+
return {
|
|
732
|
+
content: [
|
|
733
|
+
{
|
|
734
|
+
type: "text",
|
|
735
|
+
text: `Parallel: ${successCount}/${results.length} succeeded\n\n${summaries.join("\n\n")}`,
|
|
736
|
+
},
|
|
737
|
+
],
|
|
738
|
+
details: makeDetails("parallel")(results),
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
if (params.agent && params.task) {
|
|
743
|
+
let isolation: IsolationEnvironment | null = null;
|
|
744
|
+
let mergeResult: MergeResult | undefined;
|
|
745
|
+
try {
|
|
746
|
+
const effectiveCwd = params.cwd ?? ctx.cwd;
|
|
747
|
+
|
|
748
|
+
if (useIsolation) {
|
|
749
|
+
const taskId = crypto.randomUUID();
|
|
750
|
+
isolation = await createIsolation(effectiveCwd, taskId, isolationMode);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
const result = await runSingleAgent(
|
|
754
|
+
ctx.cwd,
|
|
755
|
+
agents,
|
|
756
|
+
params.agent,
|
|
757
|
+
params.task,
|
|
758
|
+
isolation ? isolation.workDir : params.cwd,
|
|
759
|
+
undefined,
|
|
760
|
+
signal,
|
|
761
|
+
onUpdate,
|
|
762
|
+
makeDetails("single"),
|
|
763
|
+
);
|
|
764
|
+
|
|
765
|
+
// Capture and merge delta if isolated
|
|
766
|
+
if (isolation) {
|
|
767
|
+
const patches = await isolation.captureDelta();
|
|
768
|
+
if (patches.length > 0) {
|
|
769
|
+
mergeResult = await mergeDeltaPatches(effectiveCwd, patches);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
const isError = result.exitCode !== 0 || result.stopReason === "error" || result.stopReason === "aborted";
|
|
774
|
+
if (isError) {
|
|
775
|
+
const errorMsg =
|
|
776
|
+
result.errorMessage || result.stderr || getFinalOutput(result.messages) || "(no output)";
|
|
777
|
+
return {
|
|
778
|
+
content: [{ type: "text", text: `Agent ${result.stopReason || "failed"}: ${errorMsg}` }],
|
|
779
|
+
details: makeDetails("single")([result]),
|
|
780
|
+
isError: true,
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
let outputText = getFinalOutput(result.messages) || "(no output)";
|
|
785
|
+
if (mergeResult && !mergeResult.success) {
|
|
786
|
+
outputText += `\n\n⚠ Patch merge failed: ${mergeResult.error || "unknown error"}`;
|
|
787
|
+
}
|
|
788
|
+
return {
|
|
789
|
+
content: [{ type: "text", text: outputText }],
|
|
790
|
+
details: makeDetails("single")([result]),
|
|
791
|
+
};
|
|
792
|
+
} finally {
|
|
793
|
+
if (isolation) {
|
|
794
|
+
await isolation.cleanup();
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
const available = agents.map((a) => `${a.name} (${a.source})`).join(", ") || "none";
|
|
800
|
+
return {
|
|
801
|
+
content: [{ type: "text", text: `Invalid parameters. Available agents: ${available}` }],
|
|
802
|
+
details: makeDetails("single")([]),
|
|
803
|
+
};
|
|
804
|
+
},
|
|
805
|
+
|
|
806
|
+
renderCall(args, theme) {
|
|
807
|
+
const scope: AgentScope = args.agentScope ?? "both";
|
|
808
|
+
if (args.chain && args.chain.length > 0) {
|
|
809
|
+
let text =
|
|
810
|
+
theme.fg("toolTitle", theme.bold("subagent ")) +
|
|
811
|
+
theme.fg("accent", `chain (${args.chain.length} steps)`) +
|
|
812
|
+
theme.fg("muted", ` [${scope}]`);
|
|
813
|
+
for (let i = 0; i < Math.min(args.chain.length, 3); i++) {
|
|
814
|
+
const step = args.chain[i];
|
|
815
|
+
// Clean up {previous} placeholder for display
|
|
816
|
+
const cleanTask = step.task.replace(/\{previous\}/g, "").trim();
|
|
817
|
+
const preview = cleanTask.length > 40 ? `${cleanTask.slice(0, 40)}...` : cleanTask;
|
|
818
|
+
text +=
|
|
819
|
+
"\n " +
|
|
820
|
+
theme.fg("muted", `${i + 1}.`) +
|
|
821
|
+
" " +
|
|
822
|
+
theme.fg("accent", step.agent) +
|
|
823
|
+
theme.fg("dim", ` ${preview}`);
|
|
824
|
+
}
|
|
825
|
+
if (args.chain.length > 3) text += `\n ${theme.fg("muted", `... +${args.chain.length - 3} more`)}`;
|
|
826
|
+
return new Text(text, 0, 0);
|
|
827
|
+
}
|
|
828
|
+
if (args.tasks && args.tasks.length > 0) {
|
|
829
|
+
let text =
|
|
830
|
+
theme.fg("toolTitle", theme.bold("subagent ")) +
|
|
831
|
+
theme.fg("accent", `parallel (${args.tasks.length} tasks)`) +
|
|
832
|
+
theme.fg("muted", ` [${scope}]`);
|
|
833
|
+
for (const t of args.tasks.slice(0, 3)) {
|
|
834
|
+
const preview = t.task.length > 40 ? `${t.task.slice(0, 40)}...` : t.task;
|
|
835
|
+
text += `\n ${theme.fg("accent", t.agent)}${theme.fg("dim", ` ${preview}`)}`;
|
|
836
|
+
}
|
|
837
|
+
if (args.tasks.length > 3) text += `\n ${theme.fg("muted", `... +${args.tasks.length - 3} more`)}`;
|
|
838
|
+
return new Text(text, 0, 0);
|
|
839
|
+
}
|
|
840
|
+
const agentName = args.agent || "...";
|
|
841
|
+
const preview = args.task ? (args.task.length > 60 ? `${args.task.slice(0, 60)}...` : args.task) : "...";
|
|
842
|
+
let text =
|
|
843
|
+
theme.fg("toolTitle", theme.bold("subagent ")) +
|
|
844
|
+
theme.fg("accent", agentName) +
|
|
845
|
+
theme.fg("muted", ` [${scope}]`);
|
|
846
|
+
text += `\n ${theme.fg("dim", preview)}`;
|
|
847
|
+
return new Text(text, 0, 0);
|
|
848
|
+
},
|
|
849
|
+
|
|
850
|
+
renderResult(result, { expanded }, theme) {
|
|
851
|
+
const details = result.details as SubagentDetails | undefined;
|
|
852
|
+
if (!details || details.results.length === 0) {
|
|
853
|
+
const text = result.content[0];
|
|
854
|
+
return new Text(text?.type === "text" ? text.text : "(no output)", 0, 0);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
const mdTheme = getMarkdownTheme();
|
|
858
|
+
|
|
859
|
+
const renderDisplayItems = (items: DisplayItem[], limit?: number) => {
|
|
860
|
+
const toShow = limit ? items.slice(-limit) : items;
|
|
861
|
+
const skipped = limit && items.length > limit ? items.length - limit : 0;
|
|
862
|
+
let text = "";
|
|
863
|
+
if (skipped > 0) text += theme.fg("muted", `... ${skipped} earlier items\n`);
|
|
864
|
+
for (const item of toShow) {
|
|
865
|
+
if (item.type === "text") {
|
|
866
|
+
const preview = expanded ? item.text : item.text.split("\n").slice(0, 3).join("\n");
|
|
867
|
+
text += `${theme.fg("toolOutput", preview)}\n`;
|
|
868
|
+
} else {
|
|
869
|
+
text += `${theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme))}\n`;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return text.trimEnd();
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
if (details.mode === "single" && details.results.length === 1) {
|
|
876
|
+
const r = details.results[0];
|
|
877
|
+
const isError = r.exitCode !== 0 || r.stopReason === "error" || r.stopReason === "aborted";
|
|
878
|
+
const icon = isError ? theme.fg("error", "✗") : theme.fg("success", "✓");
|
|
879
|
+
const displayItems = getDisplayItems(r.messages);
|
|
880
|
+
const finalOutput = getFinalOutput(r.messages);
|
|
881
|
+
|
|
882
|
+
if (expanded) {
|
|
883
|
+
const container = new Container();
|
|
884
|
+
let header = `${icon} ${theme.fg("toolTitle", theme.bold(r.agent))}${theme.fg("muted", ` (${r.agentSource})`)}`;
|
|
885
|
+
if (isError && r.stopReason) header += ` ${theme.fg("error", `[${r.stopReason}]`)}`;
|
|
886
|
+
container.addChild(new Text(header, 0, 0));
|
|
887
|
+
if (isError && r.errorMessage)
|
|
888
|
+
container.addChild(new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0));
|
|
889
|
+
container.addChild(new Spacer(1));
|
|
890
|
+
container.addChild(new Text(theme.fg("muted", "─── Task ───"), 0, 0));
|
|
891
|
+
container.addChild(new Text(theme.fg("dim", r.task), 0, 0));
|
|
892
|
+
container.addChild(new Spacer(1));
|
|
893
|
+
container.addChild(new Text(theme.fg("muted", "─── Output ───"), 0, 0));
|
|
894
|
+
if (displayItems.length === 0 && !finalOutput) {
|
|
895
|
+
container.addChild(new Text(theme.fg("muted", "(no output)"), 0, 0));
|
|
896
|
+
} else {
|
|
897
|
+
for (const item of displayItems) {
|
|
898
|
+
if (item.type === "toolCall")
|
|
899
|
+
container.addChild(
|
|
900
|
+
new Text(
|
|
901
|
+
theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme)),
|
|
902
|
+
0,
|
|
903
|
+
0,
|
|
904
|
+
),
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
if (finalOutput) {
|
|
908
|
+
container.addChild(new Spacer(1));
|
|
909
|
+
container.addChild(new Markdown(finalOutput.trim(), 0, 0, mdTheme));
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
const usageStr = formatUsageStats(r.usage, r.model);
|
|
913
|
+
if (usageStr) {
|
|
914
|
+
container.addChild(new Spacer(1));
|
|
915
|
+
container.addChild(new Text(theme.fg("dim", usageStr), 0, 0));
|
|
916
|
+
}
|
|
917
|
+
return container;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
let text = `${icon} ${theme.fg("toolTitle", theme.bold(r.agent))}${theme.fg("muted", ` (${r.agentSource})`)}`;
|
|
921
|
+
if (isError && r.stopReason) text += ` ${theme.fg("error", `[${r.stopReason}]`)}`;
|
|
922
|
+
if (isError && r.errorMessage) text += `\n${theme.fg("error", `Error: ${r.errorMessage}`)}`;
|
|
923
|
+
else if (displayItems.length === 0) text += `\n${theme.fg("muted", "(no output)")}`;
|
|
924
|
+
else {
|
|
925
|
+
text += `\n${renderDisplayItems(displayItems, COLLAPSED_ITEM_COUNT)}`;
|
|
926
|
+
if (displayItems.length > COLLAPSED_ITEM_COUNT) text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
927
|
+
}
|
|
928
|
+
const usageStr = formatUsageStats(r.usage, r.model);
|
|
929
|
+
if (usageStr) text += `\n${theme.fg("dim", usageStr)}`;
|
|
930
|
+
return new Text(text, 0, 0);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
const aggregateUsage = (results: SingleResult[]) => {
|
|
934
|
+
const total = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 };
|
|
935
|
+
for (const r of results) {
|
|
936
|
+
total.input += r.usage.input;
|
|
937
|
+
total.output += r.usage.output;
|
|
938
|
+
total.cacheRead += r.usage.cacheRead;
|
|
939
|
+
total.cacheWrite += r.usage.cacheWrite;
|
|
940
|
+
total.cost += r.usage.cost;
|
|
941
|
+
total.turns += r.usage.turns;
|
|
942
|
+
}
|
|
943
|
+
return total;
|
|
944
|
+
};
|
|
945
|
+
|
|
946
|
+
if (details.mode === "chain") {
|
|
947
|
+
const successCount = details.results.filter((r) => r.exitCode === 0).length;
|
|
948
|
+
const icon = successCount === details.results.length ? theme.fg("success", "✓") : theme.fg("error", "✗");
|
|
949
|
+
|
|
950
|
+
if (expanded) {
|
|
951
|
+
const container = new Container();
|
|
952
|
+
container.addChild(
|
|
953
|
+
new Text(
|
|
954
|
+
icon +
|
|
955
|
+
" " +
|
|
956
|
+
theme.fg("toolTitle", theme.bold("chain ")) +
|
|
957
|
+
theme.fg("accent", `${successCount}/${details.results.length} steps`),
|
|
958
|
+
0,
|
|
959
|
+
0,
|
|
960
|
+
),
|
|
961
|
+
);
|
|
962
|
+
|
|
963
|
+
for (const r of details.results) {
|
|
964
|
+
const rIcon = r.exitCode === 0 ? theme.fg("success", "✓") : theme.fg("error", "✗");
|
|
965
|
+
const displayItems = getDisplayItems(r.messages);
|
|
966
|
+
const finalOutput = getFinalOutput(r.messages);
|
|
967
|
+
|
|
968
|
+
container.addChild(new Spacer(1));
|
|
969
|
+
container.addChild(
|
|
970
|
+
new Text(
|
|
971
|
+
`${theme.fg("muted", `─── Step ${r.step}: `) + theme.fg("accent", r.agent)} ${rIcon}`,
|
|
972
|
+
0,
|
|
973
|
+
0,
|
|
974
|
+
),
|
|
975
|
+
);
|
|
976
|
+
container.addChild(new Text(theme.fg("muted", "Task: ") + theme.fg("dim", r.task), 0, 0));
|
|
977
|
+
|
|
978
|
+
// Show tool calls
|
|
979
|
+
for (const item of displayItems) {
|
|
980
|
+
if (item.type === "toolCall") {
|
|
981
|
+
container.addChild(
|
|
982
|
+
new Text(
|
|
983
|
+
theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme)),
|
|
984
|
+
0,
|
|
985
|
+
0,
|
|
986
|
+
),
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// Show final output as markdown
|
|
992
|
+
if (finalOutput) {
|
|
993
|
+
container.addChild(new Spacer(1));
|
|
994
|
+
container.addChild(new Markdown(finalOutput.trim(), 0, 0, mdTheme));
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
const stepUsage = formatUsageStats(r.usage, r.model);
|
|
998
|
+
if (stepUsage) container.addChild(new Text(theme.fg("dim", stepUsage), 0, 0));
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
const usageStr = formatUsageStats(aggregateUsage(details.results));
|
|
1002
|
+
if (usageStr) {
|
|
1003
|
+
container.addChild(new Spacer(1));
|
|
1004
|
+
container.addChild(new Text(theme.fg("dim", `Total: ${usageStr}`), 0, 0));
|
|
1005
|
+
}
|
|
1006
|
+
return container;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// Collapsed view
|
|
1010
|
+
let text =
|
|
1011
|
+
icon +
|
|
1012
|
+
" " +
|
|
1013
|
+
theme.fg("toolTitle", theme.bold("chain ")) +
|
|
1014
|
+
theme.fg("accent", `${successCount}/${details.results.length} steps`);
|
|
1015
|
+
for (const r of details.results) {
|
|
1016
|
+
const rIcon = r.exitCode === 0 ? theme.fg("success", "✓") : theme.fg("error", "✗");
|
|
1017
|
+
const displayItems = getDisplayItems(r.messages);
|
|
1018
|
+
text += `\n\n${theme.fg("muted", `─── Step ${r.step}: `)}${theme.fg("accent", r.agent)} ${rIcon}`;
|
|
1019
|
+
if (displayItems.length === 0) text += `\n${theme.fg("muted", "(no output)")}`;
|
|
1020
|
+
else text += `\n${renderDisplayItems(displayItems, 5)}`;
|
|
1021
|
+
}
|
|
1022
|
+
const usageStr = formatUsageStats(aggregateUsage(details.results));
|
|
1023
|
+
if (usageStr) text += `\n\n${theme.fg("dim", `Total: ${usageStr}`)}`;
|
|
1024
|
+
text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
1025
|
+
return new Text(text, 0, 0);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
if (details.mode === "parallel") {
|
|
1029
|
+
const running = details.results.filter((r) => r.exitCode === -1).length;
|
|
1030
|
+
const successCount = details.results.filter((r) => r.exitCode === 0).length;
|
|
1031
|
+
const failCount = details.results.filter((r) => r.exitCode > 0).length;
|
|
1032
|
+
const isRunning = running > 0;
|
|
1033
|
+
const icon = isRunning
|
|
1034
|
+
? theme.fg("warning", "⏳")
|
|
1035
|
+
: failCount > 0
|
|
1036
|
+
? theme.fg("warning", "◐")
|
|
1037
|
+
: theme.fg("success", "✓");
|
|
1038
|
+
const status = isRunning
|
|
1039
|
+
? `${successCount + failCount}/${details.results.length} done, ${running} running`
|
|
1040
|
+
: `${successCount}/${details.results.length} tasks`;
|
|
1041
|
+
|
|
1042
|
+
if (expanded && !isRunning) {
|
|
1043
|
+
const container = new Container();
|
|
1044
|
+
container.addChild(
|
|
1045
|
+
new Text(
|
|
1046
|
+
`${icon} ${theme.fg("toolTitle", theme.bold("parallel "))}${theme.fg("accent", status)}`,
|
|
1047
|
+
0,
|
|
1048
|
+
0,
|
|
1049
|
+
),
|
|
1050
|
+
);
|
|
1051
|
+
|
|
1052
|
+
for (const r of details.results) {
|
|
1053
|
+
const rIcon = r.exitCode === 0 ? theme.fg("success", "✓") : theme.fg("error", "✗");
|
|
1054
|
+
const displayItems = getDisplayItems(r.messages);
|
|
1055
|
+
const finalOutput = getFinalOutput(r.messages);
|
|
1056
|
+
|
|
1057
|
+
container.addChild(new Spacer(1));
|
|
1058
|
+
container.addChild(
|
|
1059
|
+
new Text(`${theme.fg("muted", "─── ") + theme.fg("accent", r.agent)} ${rIcon}`, 0, 0),
|
|
1060
|
+
);
|
|
1061
|
+
container.addChild(new Text(theme.fg("muted", "Task: ") + theme.fg("dim", r.task), 0, 0));
|
|
1062
|
+
|
|
1063
|
+
// Show tool calls
|
|
1064
|
+
for (const item of displayItems) {
|
|
1065
|
+
if (item.type === "toolCall") {
|
|
1066
|
+
container.addChild(
|
|
1067
|
+
new Text(
|
|
1068
|
+
theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme)),
|
|
1069
|
+
0,
|
|
1070
|
+
0,
|
|
1071
|
+
),
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// Show final output as markdown
|
|
1077
|
+
if (finalOutput) {
|
|
1078
|
+
container.addChild(new Spacer(1));
|
|
1079
|
+
container.addChild(new Markdown(finalOutput.trim(), 0, 0, mdTheme));
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
const taskUsage = formatUsageStats(r.usage, r.model);
|
|
1083
|
+
if (taskUsage) container.addChild(new Text(theme.fg("dim", taskUsage), 0, 0));
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
const usageStr = formatUsageStats(aggregateUsage(details.results));
|
|
1087
|
+
if (usageStr) {
|
|
1088
|
+
container.addChild(new Spacer(1));
|
|
1089
|
+
container.addChild(new Text(theme.fg("dim", `Total: ${usageStr}`), 0, 0));
|
|
1090
|
+
}
|
|
1091
|
+
return container;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
// Collapsed view (or still running)
|
|
1095
|
+
let text = `${icon} ${theme.fg("toolTitle", theme.bold("parallel "))}${theme.fg("accent", status)}`;
|
|
1096
|
+
for (const r of details.results) {
|
|
1097
|
+
const rIcon =
|
|
1098
|
+
r.exitCode === -1
|
|
1099
|
+
? theme.fg("warning", "⏳")
|
|
1100
|
+
: r.exitCode === 0
|
|
1101
|
+
? theme.fg("success", "✓")
|
|
1102
|
+
: theme.fg("error", "✗");
|
|
1103
|
+
const displayItems = getDisplayItems(r.messages);
|
|
1104
|
+
text += `\n\n${theme.fg("muted", "─── ")}${theme.fg("accent", r.agent)} ${rIcon}`;
|
|
1105
|
+
if (displayItems.length === 0)
|
|
1106
|
+
text += `\n${theme.fg("muted", r.exitCode === -1 ? "(running...)" : "(no output)")}`;
|
|
1107
|
+
else text += `\n${renderDisplayItems(displayItems, 5)}`;
|
|
1108
|
+
}
|
|
1109
|
+
if (!isRunning) {
|
|
1110
|
+
const usageStr = formatUsageStats(aggregateUsage(details.results));
|
|
1111
|
+
if (usageStr) text += `\n\n${theme.fg("dim", `Total: ${usageStr}`)}`;
|
|
1112
|
+
}
|
|
1113
|
+
if (!expanded) text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
1114
|
+
return new Text(text, 0, 0);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
const text = result.content[0];
|
|
1118
|
+
return new Text(text?.type === "text" ? text.text : "(no output)", 0, 0);
|
|
1119
|
+
},
|
|
1120
|
+
});
|
|
1121
|
+
}
|