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,996 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Manager — /gsd keys
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive CLI for managing API keys: list, add, remove, test, rotate, doctor.
|
|
5
|
+
* Works with AuthStorage from pi-coding-agent — no core package changes needed.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionCommandContext } from "@gsd/pi-coding-agent";
|
|
9
|
+
import {
|
|
10
|
+
AuthStorage,
|
|
11
|
+
type AuthCredential,
|
|
12
|
+
type ApiKeyCredential,
|
|
13
|
+
type OAuthCredential,
|
|
14
|
+
} from "@gsd/pi-coding-agent";
|
|
15
|
+
import { getEnvApiKey } from "@gsd/pi-ai";
|
|
16
|
+
import { existsSync, statSync, chmodSync } from "node:fs";
|
|
17
|
+
import { join, dirname } from "node:path";
|
|
18
|
+
import { mkdirSync } from "node:fs";
|
|
19
|
+
import { getErrorMessage } from "./error-utils.js";
|
|
20
|
+
|
|
21
|
+
// ─── Provider Registry ─────────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
export type ProviderCategory = "llm" | "tool" | "search" | "remote";
|
|
24
|
+
|
|
25
|
+
export interface ProviderInfo {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
category: ProviderCategory;
|
|
29
|
+
envVar?: string;
|
|
30
|
+
prefixes?: string[];
|
|
31
|
+
hasOAuth?: boolean;
|
|
32
|
+
dashboardUrl?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const PROVIDER_REGISTRY: ProviderInfo[] = [
|
|
36
|
+
// LLM Providers
|
|
37
|
+
{ id: "anthropic", label: "Anthropic (Claude)", category: "llm", envVar: "ANTHROPIC_API_KEY", prefixes: ["sk-ant-"], hasOAuth: true, dashboardUrl: "console.anthropic.com" },
|
|
38
|
+
{ id: "openai", label: "OpenAI", category: "llm", envVar: "OPENAI_API_KEY", prefixes: ["sk-"], dashboardUrl: "platform.openai.com/api-keys" },
|
|
39
|
+
{ id: "github-copilot", label: "GitHub Copilot", category: "llm", envVar: "GITHUB_TOKEN", hasOAuth: true },
|
|
40
|
+
{ id: "openai-codex", label: "ChatGPT Plus/Pro (Codex)",category: "llm", hasOAuth: true },
|
|
41
|
+
{ id: "google-gemini-cli",label: "Google Gemini CLI", category: "llm", hasOAuth: true },
|
|
42
|
+
{ id: "google-antigravity",label: "Antigravity", category: "llm", hasOAuth: true },
|
|
43
|
+
{ id: "google", label: "Google (Gemini)", category: "llm", envVar: "GEMINI_API_KEY", dashboardUrl: "aistudio.google.com/apikey" },
|
|
44
|
+
{ id: "groq", label: "Groq", category: "llm", envVar: "GROQ_API_KEY", dashboardUrl: "console.groq.com" },
|
|
45
|
+
{ id: "xai", label: "xAI (Grok)", category: "llm", envVar: "XAI_API_KEY", dashboardUrl: "console.x.ai" },
|
|
46
|
+
{ id: "openrouter", label: "OpenRouter", category: "llm", envVar: "OPENROUTER_API_KEY", dashboardUrl: "openrouter.ai/keys" },
|
|
47
|
+
{ id: "mistral", label: "Mistral", category: "llm", envVar: "MISTRAL_API_KEY", dashboardUrl: "console.mistral.ai" },
|
|
48
|
+
{ id: "ollama-cloud", label: "Ollama Cloud", category: "llm", envVar: "OLLAMA_API_KEY" },
|
|
49
|
+
{ id: "custom-openai", label: "Custom (OpenAI-compat)", category: "llm", envVar: "CUSTOM_OPENAI_API_KEY" },
|
|
50
|
+
{ id: "cerebras", label: "Cerebras", category: "llm", envVar: "CEREBRAS_API_KEY" },
|
|
51
|
+
{ id: "azure-openai-responses", label: "Azure OpenAI", category: "llm", envVar: "AZURE_OPENAI_API_KEY" },
|
|
52
|
+
|
|
53
|
+
// Tool Keys
|
|
54
|
+
{ id: "context7", label: "Context7 Docs", category: "tool", envVar: "CONTEXT7_API_KEY", dashboardUrl: "context7.com/dashboard" },
|
|
55
|
+
{ id: "jina", label: "Jina Page Extract", category: "tool", envVar: "JINA_API_KEY", dashboardUrl: "jina.ai/api" },
|
|
56
|
+
|
|
57
|
+
// Search Providers
|
|
58
|
+
{ id: "tavily", label: "Tavily Search", category: "search", envVar: "TAVILY_API_KEY", dashboardUrl: "tavily.com/app/api-keys" },
|
|
59
|
+
{ id: "brave", label: "Brave Search", category: "search", envVar: "BRAVE_API_KEY", dashboardUrl: "brave.com/search/api" },
|
|
60
|
+
|
|
61
|
+
// Remote Integrations
|
|
62
|
+
{ id: "discord_bot", label: "Discord Bot", category: "remote", envVar: "DISCORD_BOT_TOKEN" },
|
|
63
|
+
{ id: "slack_bot", label: "Slack Bot", category: "remote", envVar: "SLACK_BOT_TOKEN", prefixes: ["xoxb-"] },
|
|
64
|
+
{ id: "telegram_bot", label: "Telegram Bot", category: "remote", envVar: "TELEGRAM_BOT_TOKEN" },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
// ─── Utilities ──────────────────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Mask an API key for display: show first 4 + last 4 chars.
|
|
71
|
+
* Keys shorter than 12 chars show only first 2 + last 2.
|
|
72
|
+
*/
|
|
73
|
+
export function maskKey(key: string): string {
|
|
74
|
+
if (!key) return "(empty)";
|
|
75
|
+
if (key.length <= 8) return key.slice(0, 2) + "***" + key.slice(-2);
|
|
76
|
+
return key.slice(0, 4) + "***" + key.slice(-4);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Format a duration in milliseconds to human-readable.
|
|
81
|
+
*/
|
|
82
|
+
export function formatDuration(ms: number): string {
|
|
83
|
+
if (ms <= 0) return "expired";
|
|
84
|
+
const seconds = Math.floor(ms / 1000);
|
|
85
|
+
if (seconds < 60) return `${seconds}s`;
|
|
86
|
+
const minutes = Math.floor(seconds / 60);
|
|
87
|
+
if (minutes < 60) return `${minutes}m`;
|
|
88
|
+
const hours = Math.floor(minutes / 60);
|
|
89
|
+
const remainMinutes = minutes % 60;
|
|
90
|
+
return remainMinutes > 0 ? `${hours}h ${remainMinutes}m` : `${hours}h`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Describe a credential's type and status.
|
|
95
|
+
*/
|
|
96
|
+
export function describeCredential(cred: AuthCredential): string {
|
|
97
|
+
if (cred.type === "api_key") {
|
|
98
|
+
const apiCred = cred as ApiKeyCredential;
|
|
99
|
+
if (!apiCred.key) return "empty key";
|
|
100
|
+
return `API key (${maskKey(apiCred.key)})`;
|
|
101
|
+
}
|
|
102
|
+
if (cred.type === "oauth") {
|
|
103
|
+
const oauthCred = cred as OAuthCredential;
|
|
104
|
+
const remaining = oauthCred.expires - Date.now();
|
|
105
|
+
if (remaining <= 0) return "OAuth (expired — will auto-refresh)";
|
|
106
|
+
return `OAuth (expires in ${formatDuration(remaining)})`;
|
|
107
|
+
}
|
|
108
|
+
return "unknown";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get the auth.json path.
|
|
113
|
+
*/
|
|
114
|
+
export function getAuthPath(): string {
|
|
115
|
+
return join(process.env.HOME ?? "~", ".gsd", "agent", "auth.json");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Create an AuthStorage instance for key management.
|
|
120
|
+
*/
|
|
121
|
+
export function getKeyManagerAuthStorage(): AuthStorage {
|
|
122
|
+
const authPath = getAuthPath();
|
|
123
|
+
mkdirSync(dirname(authPath), { recursive: true });
|
|
124
|
+
return AuthStorage.create(authPath);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Look up a provider by ID (case-insensitive).
|
|
129
|
+
*/
|
|
130
|
+
export function findProvider(idOrLabel: string): ProviderInfo | undefined {
|
|
131
|
+
const lower = idOrLabel.toLowerCase();
|
|
132
|
+
return PROVIDER_REGISTRY.find(
|
|
133
|
+
(p) => p.id.toLowerCase() === lower || p.label.toLowerCase() === lower,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ─── Key Status / List ──────────────────────────────────────────────────────────
|
|
138
|
+
|
|
139
|
+
export interface KeyStatus {
|
|
140
|
+
provider: ProviderInfo;
|
|
141
|
+
configured: boolean;
|
|
142
|
+
source: "auth.json" | "env" | "none";
|
|
143
|
+
credentialCount: number;
|
|
144
|
+
description: string;
|
|
145
|
+
backedOff: boolean;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Get the status of all known providers.
|
|
150
|
+
*/
|
|
151
|
+
export function getAllKeyStatuses(auth: AuthStorage): KeyStatus[] {
|
|
152
|
+
return PROVIDER_REGISTRY.map((provider) => {
|
|
153
|
+
const creds = auth.getCredentialsForProvider(provider.id);
|
|
154
|
+
const envKey = provider.envVar ? process.env[provider.envVar] : undefined;
|
|
155
|
+
|
|
156
|
+
if (creds.length > 0) {
|
|
157
|
+
const firstCred = creds[0];
|
|
158
|
+
// Skip empty keys (from skipped onboarding)
|
|
159
|
+
if (firstCred.type === "api_key" && !(firstCred as ApiKeyCredential).key) {
|
|
160
|
+
return {
|
|
161
|
+
provider,
|
|
162
|
+
configured: false,
|
|
163
|
+
source: "none" as const,
|
|
164
|
+
credentialCount: 0,
|
|
165
|
+
description: "empty key (skipped setup)",
|
|
166
|
+
backedOff: false,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const desc =
|
|
170
|
+
creds.length > 1
|
|
171
|
+
? `${creds.length} keys (round-robin)`
|
|
172
|
+
: describeCredential(firstCred);
|
|
173
|
+
return {
|
|
174
|
+
provider,
|
|
175
|
+
configured: true,
|
|
176
|
+
source: "auth.json" as const,
|
|
177
|
+
credentialCount: creds.length,
|
|
178
|
+
description: desc,
|
|
179
|
+
backedOff: auth.areAllCredentialsBackedOff(provider.id),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (envKey) {
|
|
184
|
+
return {
|
|
185
|
+
provider,
|
|
186
|
+
configured: true,
|
|
187
|
+
source: "env" as const,
|
|
188
|
+
credentialCount: 1,
|
|
189
|
+
description: `env ${provider.envVar}`,
|
|
190
|
+
backedOff: false,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
provider,
|
|
196
|
+
configured: false,
|
|
197
|
+
source: "none" as const,
|
|
198
|
+
credentialCount: 0,
|
|
199
|
+
description: provider.dashboardUrl
|
|
200
|
+
? `not configured (${provider.dashboardUrl})`
|
|
201
|
+
: provider.envVar
|
|
202
|
+
? `not configured (env: ${provider.envVar})`
|
|
203
|
+
: "not configured",
|
|
204
|
+
backedOff: false,
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Format statuses into a grouped dashboard string.
|
|
211
|
+
*/
|
|
212
|
+
export function formatKeyDashboard(statuses: KeyStatus[]): string {
|
|
213
|
+
const categories: { label: string; key: ProviderCategory }[] = [
|
|
214
|
+
{ label: "LLM Providers", key: "llm" },
|
|
215
|
+
{ label: "Search Providers", key: "search" },
|
|
216
|
+
{ label: "Tool Keys", key: "tool" },
|
|
217
|
+
{ label: "Remote Integrations", key: "remote" },
|
|
218
|
+
];
|
|
219
|
+
|
|
220
|
+
const lines: string[] = ["GSD API Key Manager\n"];
|
|
221
|
+
|
|
222
|
+
for (const cat of categories) {
|
|
223
|
+
const items = statuses.filter((s) => s.provider.category === cat.key);
|
|
224
|
+
if (items.length === 0) continue;
|
|
225
|
+
|
|
226
|
+
lines.push(` ${cat.label}`);
|
|
227
|
+
for (const item of items) {
|
|
228
|
+
const icon = item.configured ? "✓" : "✗";
|
|
229
|
+
const backoff = item.backedOff ? " [backed off]" : "";
|
|
230
|
+
const pad = item.provider.id.padEnd(20);
|
|
231
|
+
lines.push(` ${icon} ${pad} — ${item.description}${backoff}`);
|
|
232
|
+
}
|
|
233
|
+
lines.push("");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Summary
|
|
237
|
+
const configured = statuses.filter((s) => s.configured);
|
|
238
|
+
const fromAuth = configured.filter((s) => s.source === "auth.json");
|
|
239
|
+
const fromEnv = configured.filter((s) => s.source === "env");
|
|
240
|
+
const oauthCount = statuses.filter((s) => {
|
|
241
|
+
if (!s.configured || s.source !== "auth.json") return false;
|
|
242
|
+
return s.description.startsWith("OAuth");
|
|
243
|
+
}).length;
|
|
244
|
+
|
|
245
|
+
const parts: string[] = [];
|
|
246
|
+
parts.push(`${configured.length} configured`);
|
|
247
|
+
if (fromAuth.length > 0) parts.push(`${fromAuth.length} in auth.json`);
|
|
248
|
+
if (fromEnv.length > 0) parts.push(`${fromEnv.length} from env`);
|
|
249
|
+
if (oauthCount > 0) parts.push(`${oauthCount} OAuth`);
|
|
250
|
+
|
|
251
|
+
lines.push(` Source: ${getAuthPath()}`);
|
|
252
|
+
lines.push(` ${parts.join(" | ")}`);
|
|
253
|
+
|
|
254
|
+
return lines.join("\n");
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ─── Add Key ────────────────────────────────────────────────────────────────────
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Add a key interactively.
|
|
261
|
+
*/
|
|
262
|
+
export async function handleAddKey(
|
|
263
|
+
providerArg: string,
|
|
264
|
+
ctx: ExtensionCommandContext,
|
|
265
|
+
auth: AuthStorage,
|
|
266
|
+
): Promise<boolean> {
|
|
267
|
+
let provider: ProviderInfo | undefined;
|
|
268
|
+
|
|
269
|
+
if (providerArg) {
|
|
270
|
+
provider = findProvider(providerArg);
|
|
271
|
+
if (!provider) {
|
|
272
|
+
ctx.ui.notify(`Unknown provider: "${providerArg}". Use /gsd keys list to see available providers.`, "error");
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
// Interactive provider picker
|
|
277
|
+
const options = PROVIDER_REGISTRY.map((p) => {
|
|
278
|
+
const creds = auth.getCredentialsForProvider(p.id);
|
|
279
|
+
const existing = creds.length > 0 ? " (configured)" : "";
|
|
280
|
+
return `[${p.category}] ${p.label}${existing}`;
|
|
281
|
+
});
|
|
282
|
+
const choice = await ctx.ui.select("Add key for which provider?", options);
|
|
283
|
+
if (!choice || typeof choice !== "string") return false;
|
|
284
|
+
|
|
285
|
+
const idx = options.indexOf(choice);
|
|
286
|
+
if (idx === -1) return false;
|
|
287
|
+
provider = PROVIDER_REGISTRY[idx];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// If OAuth is available, offer choice
|
|
291
|
+
if (provider.hasOAuth) {
|
|
292
|
+
const methods = ["API key", "Browser login (OAuth)"];
|
|
293
|
+
const method = await ctx.ui.select(
|
|
294
|
+
`${provider.label} — how do you want to authenticate?`,
|
|
295
|
+
methods,
|
|
296
|
+
);
|
|
297
|
+
if (!method || typeof method !== "string") return false;
|
|
298
|
+
|
|
299
|
+
if (method.includes("OAuth")) {
|
|
300
|
+
ctx.ui.notify(
|
|
301
|
+
`Use /login to authenticate via OAuth with ${provider.label}.\n` +
|
|
302
|
+
`The /login command handles the full browser flow.`,
|
|
303
|
+
"info",
|
|
304
|
+
);
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// API key input
|
|
310
|
+
const input = await ctx.ui.input(
|
|
311
|
+
`API key for ${provider.label}:`,
|
|
312
|
+
provider.envVar ? `or set ${provider.envVar} env var` : "paste your key here",
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
if (input === null || input === undefined) return false;
|
|
316
|
+
const key = input.trim();
|
|
317
|
+
if (!key) {
|
|
318
|
+
ctx.ui.notify("No key provided.", "warning");
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Prefix validation
|
|
323
|
+
if (provider.prefixes && provider.prefixes.length > 0) {
|
|
324
|
+
const valid = provider.prefixes.some((pfx) => key.startsWith(pfx));
|
|
325
|
+
if (!valid) {
|
|
326
|
+
ctx.ui.notify(
|
|
327
|
+
`Warning: key doesn't start with expected prefix (${provider.prefixes.join(" or ")}). Saving anyway.`,
|
|
328
|
+
"warning",
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
auth.set(provider.id, { type: "api_key", key });
|
|
334
|
+
if (provider.envVar) {
|
|
335
|
+
process.env[provider.envVar] = key;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
ctx.ui.notify(`Key saved for ${provider.label}: ${maskKey(key)}`, "success");
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// ─── Remove Key ─────────────────────────────────────────────────────────────────
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Remove a key interactively.
|
|
346
|
+
*/
|
|
347
|
+
export async function handleRemoveKey(
|
|
348
|
+
providerArg: string,
|
|
349
|
+
ctx: ExtensionCommandContext,
|
|
350
|
+
auth: AuthStorage,
|
|
351
|
+
): Promise<boolean> {
|
|
352
|
+
let provider: ProviderInfo | undefined;
|
|
353
|
+
|
|
354
|
+
if (providerArg) {
|
|
355
|
+
provider = findProvider(providerArg);
|
|
356
|
+
if (!provider) {
|
|
357
|
+
ctx.ui.notify(`Unknown provider: "${providerArg}".`, "error");
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
} else {
|
|
361
|
+
// Show only configured providers
|
|
362
|
+
const configured = PROVIDER_REGISTRY.filter((p) => {
|
|
363
|
+
const creds = auth.getCredentialsForProvider(p.id);
|
|
364
|
+
return creds.length > 0;
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
if (configured.length === 0) {
|
|
368
|
+
ctx.ui.notify("No keys configured to remove.", "info");
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const options = configured.map((p) => p.label);
|
|
373
|
+
const choice = await ctx.ui.select("Remove key for which provider?", options);
|
|
374
|
+
if (!choice || typeof choice !== "string") return false;
|
|
375
|
+
|
|
376
|
+
provider = configured.find((p) => p.label === choice);
|
|
377
|
+
if (!provider) return false;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const creds = auth.getCredentialsForProvider(provider.id);
|
|
381
|
+
if (creds.length === 0) {
|
|
382
|
+
ctx.ui.notify(`No keys found for ${provider.label}.`, "info");
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Multi-key handling
|
|
387
|
+
if (creds.length > 1) {
|
|
388
|
+
const options = creds.map((c, i) => `[${i + 1}] ${describeCredential(c)}`);
|
|
389
|
+
options.push("Remove all");
|
|
390
|
+
|
|
391
|
+
const choice = await ctx.ui.select(
|
|
392
|
+
`${provider.label} has ${creds.length} keys. Remove which?`,
|
|
393
|
+
options,
|
|
394
|
+
);
|
|
395
|
+
if (!choice || typeof choice !== "string") return false;
|
|
396
|
+
|
|
397
|
+
if (choice === "Remove all") {
|
|
398
|
+
auth.remove(provider.id);
|
|
399
|
+
} else {
|
|
400
|
+
// Remove specific index — need to rebuild the array without that entry
|
|
401
|
+
const idx = options.indexOf(choice);
|
|
402
|
+
if (idx === -1 || idx >= creds.length) return false;
|
|
403
|
+
const remaining = creds.filter((_, i) => i !== idx);
|
|
404
|
+
auth.remove(provider.id);
|
|
405
|
+
for (const c of remaining) {
|
|
406
|
+
auth.set(provider.id, c);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
const confirmed = await ctx.ui.confirm(
|
|
411
|
+
"Remove key?",
|
|
412
|
+
`Remove ${describeCredential(creds[0])} for ${provider.label}?`,
|
|
413
|
+
);
|
|
414
|
+
if (!confirmed) return false;
|
|
415
|
+
auth.remove(provider.id);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// Clear env var
|
|
419
|
+
if (provider.envVar && process.env[provider.envVar]) {
|
|
420
|
+
delete process.env[provider.envVar];
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
ctx.ui.notify(`Key removed for ${provider.label}.`, "success");
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// ─── Test Key ───────────────────────────────────────────────────────────────────
|
|
428
|
+
|
|
429
|
+
export interface TestResult {
|
|
430
|
+
provider: ProviderInfo;
|
|
431
|
+
status: "valid" | "invalid" | "rate_limited" | "error" | "skipped";
|
|
432
|
+
message: string;
|
|
433
|
+
latencyMs?: number;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** Test endpoint configurations per provider */
|
|
437
|
+
const TEST_ENDPOINTS: Record<string, { url: string; method?: string; headers?: (key: string) => Record<string, string>; body?: string }> = {
|
|
438
|
+
anthropic: {
|
|
439
|
+
url: "https://api.anthropic.com/v1/messages",
|
|
440
|
+
method: "POST",
|
|
441
|
+
headers: (key) => ({
|
|
442
|
+
"x-api-key": key,
|
|
443
|
+
"anthropic-version": "2023-06-01",
|
|
444
|
+
"content-type": "application/json",
|
|
445
|
+
}),
|
|
446
|
+
body: JSON.stringify({ model: "claude-sonnet-4-20250514", max_tokens: 1, messages: [{ role: "user", content: "hi" }] }),
|
|
447
|
+
},
|
|
448
|
+
openai: {
|
|
449
|
+
url: "https://api.openai.com/v1/models",
|
|
450
|
+
headers: (key) => ({ Authorization: `Bearer ${key}` }),
|
|
451
|
+
},
|
|
452
|
+
google: {
|
|
453
|
+
url: "https://generativelanguage.googleapis.com/v1beta/models",
|
|
454
|
+
headers: (key) => ({ "x-goog-api-key": key }),
|
|
455
|
+
},
|
|
456
|
+
groq: {
|
|
457
|
+
url: "https://api.groq.com/openai/v1/models",
|
|
458
|
+
headers: (key) => ({ Authorization: `Bearer ${key}` }),
|
|
459
|
+
},
|
|
460
|
+
brave: {
|
|
461
|
+
url: "https://api.search.brave.com/res/v1/web/search?q=test&count=1",
|
|
462
|
+
headers: (key) => ({ "X-Subscription-Token": key }),
|
|
463
|
+
},
|
|
464
|
+
tavily: {
|
|
465
|
+
url: "https://api.tavily.com/search",
|
|
466
|
+
method: "POST",
|
|
467
|
+
headers: () => ({ "content-type": "application/json" }),
|
|
468
|
+
body: JSON.stringify({ query: "test", max_results: 1 }),
|
|
469
|
+
},
|
|
470
|
+
discord_bot: {
|
|
471
|
+
url: "https://discord.com/api/v10/users/@me",
|
|
472
|
+
headers: (key) => ({ Authorization: `Bot ${key}` }),
|
|
473
|
+
},
|
|
474
|
+
slack_bot: {
|
|
475
|
+
url: "https://slack.com/api/auth.test",
|
|
476
|
+
headers: (key) => ({ Authorization: `Bearer ${key}` }),
|
|
477
|
+
},
|
|
478
|
+
telegram_bot: {
|
|
479
|
+
url: "", // Constructed dynamically with token in URL
|
|
480
|
+
headers: () => ({}),
|
|
481
|
+
},
|
|
482
|
+
xai: {
|
|
483
|
+
url: "https://api.x.ai/v1/models",
|
|
484
|
+
headers: (key) => ({ Authorization: `Bearer ${key}` }),
|
|
485
|
+
},
|
|
486
|
+
mistral: {
|
|
487
|
+
url: "https://api.mistral.ai/v1/models",
|
|
488
|
+
headers: (key) => ({ Authorization: `Bearer ${key}` }),
|
|
489
|
+
},
|
|
490
|
+
openrouter: {
|
|
491
|
+
url: "https://openrouter.ai/api/v1/models",
|
|
492
|
+
headers: (key) => ({ Authorization: `Bearer ${key}` }),
|
|
493
|
+
},
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Test a single provider's key.
|
|
498
|
+
*/
|
|
499
|
+
export async function testProviderKey(
|
|
500
|
+
provider: ProviderInfo,
|
|
501
|
+
auth: AuthStorage,
|
|
502
|
+
): Promise<TestResult> {
|
|
503
|
+
// Get the API key
|
|
504
|
+
const key = await auth.getApiKey(provider.id);
|
|
505
|
+
if (!key || key === "<authenticated>") {
|
|
506
|
+
if (!key) {
|
|
507
|
+
return { provider, status: "skipped", message: "not configured" };
|
|
508
|
+
}
|
|
509
|
+
return { provider, status: "skipped", message: "uses credential chain (not testable)" };
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const endpoint = TEST_ENDPOINTS[provider.id];
|
|
513
|
+
if (!endpoint) {
|
|
514
|
+
return { provider, status: "skipped", message: "no test endpoint configured" };
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Special handling for Telegram (token in URL)
|
|
518
|
+
let url = endpoint.url;
|
|
519
|
+
if (provider.id === "telegram_bot") {
|
|
520
|
+
url = `https://api.telegram.org/bot${key}/getMe`;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// Special handling for Tavily (API key in body)
|
|
524
|
+
let body = endpoint.body;
|
|
525
|
+
if (provider.id === "tavily" && body) {
|
|
526
|
+
const parsed = JSON.parse(body);
|
|
527
|
+
parsed.api_key = key;
|
|
528
|
+
body = JSON.stringify(parsed);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const start = Date.now();
|
|
532
|
+
try {
|
|
533
|
+
const res = await fetch(url, {
|
|
534
|
+
method: endpoint.method ?? "GET",
|
|
535
|
+
headers: endpoint.headers?.(key) ?? {},
|
|
536
|
+
body: body ?? undefined,
|
|
537
|
+
signal: AbortSignal.timeout(15_000),
|
|
538
|
+
});
|
|
539
|
+
const latencyMs = Date.now() - start;
|
|
540
|
+
|
|
541
|
+
if (res.ok) {
|
|
542
|
+
return { provider, status: "valid", message: "valid", latencyMs };
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
if (res.status === 401 || res.status === 403) {
|
|
546
|
+
return { provider, status: "invalid", message: `invalid key (${res.status})`, latencyMs };
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (res.status === 429) {
|
|
550
|
+
return { provider, status: "rate_limited", message: "rate limited", latencyMs };
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return { provider, status: "error", message: `HTTP ${res.status}`, latencyMs };
|
|
554
|
+
} catch (err) {
|
|
555
|
+
const latencyMs = Date.now() - start;
|
|
556
|
+
const msg = getErrorMessage(err);
|
|
557
|
+
if (msg.includes("timeout") || msg.includes("AbortError")) {
|
|
558
|
+
return { provider, status: "error", message: "timeout (15s)", latencyMs };
|
|
559
|
+
}
|
|
560
|
+
return { provider, status: "error", message: msg, latencyMs };
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Format test results for display.
|
|
566
|
+
*/
|
|
567
|
+
export function formatTestResults(results: TestResult[]): string {
|
|
568
|
+
const lines: string[] = ["API Key Test Results\n"];
|
|
569
|
+
|
|
570
|
+
for (const r of results) {
|
|
571
|
+
const icon =
|
|
572
|
+
r.status === "valid" ? "✓" :
|
|
573
|
+
r.status === "invalid" ? "✗" :
|
|
574
|
+
r.status === "rate_limited" ? "⚠" :
|
|
575
|
+
r.status === "error" ? "✗" :
|
|
576
|
+
"—";
|
|
577
|
+
const pad = r.provider.id.padEnd(20);
|
|
578
|
+
const latency = r.latencyMs !== undefined ? ` ${r.latencyMs}ms` : "";
|
|
579
|
+
lines.push(` ${icon} ${pad} — ${r.message}${latency}`);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
lines.push("");
|
|
583
|
+
const valid = results.filter((r) => r.status === "valid").length;
|
|
584
|
+
const invalid = results.filter((r) => r.status === "invalid").length;
|
|
585
|
+
const rateLimited = results.filter((r) => r.status === "rate_limited").length;
|
|
586
|
+
const errors = results.filter((r) => r.status === "error").length;
|
|
587
|
+
const skipped = results.filter((r) => r.status === "skipped").length;
|
|
588
|
+
|
|
589
|
+
const parts: string[] = [];
|
|
590
|
+
if (valid > 0) parts.push(`${valid} valid`);
|
|
591
|
+
if (invalid > 0) parts.push(`${invalid} invalid`);
|
|
592
|
+
if (rateLimited > 0) parts.push(`${rateLimited} rate-limited`);
|
|
593
|
+
if (errors > 0) parts.push(`${errors} errors`);
|
|
594
|
+
if (skipped > 0) parts.push(`${skipped} skipped`);
|
|
595
|
+
lines.push(` ${parts.join(" | ")}`);
|
|
596
|
+
|
|
597
|
+
return lines.join("\n");
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// ─── Rotate Key ─────────────────────────────────────────────────────────────────
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Rotate a key: show current, prompt for new, optionally test, then save.
|
|
604
|
+
*/
|
|
605
|
+
export async function handleRotateKey(
|
|
606
|
+
providerArg: string,
|
|
607
|
+
ctx: ExtensionCommandContext,
|
|
608
|
+
auth: AuthStorage,
|
|
609
|
+
): Promise<boolean> {
|
|
610
|
+
let provider: ProviderInfo | undefined;
|
|
611
|
+
|
|
612
|
+
if (providerArg) {
|
|
613
|
+
provider = findProvider(providerArg);
|
|
614
|
+
if (!provider) {
|
|
615
|
+
ctx.ui.notify(`Unknown provider: "${providerArg}".`, "error");
|
|
616
|
+
return false;
|
|
617
|
+
}
|
|
618
|
+
} else {
|
|
619
|
+
// Show only configured API key providers
|
|
620
|
+
const configured = PROVIDER_REGISTRY.filter((p) => {
|
|
621
|
+
const creds = auth.getCredentialsForProvider(p.id);
|
|
622
|
+
return creds.some((c) => c.type === "api_key");
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
if (configured.length === 0) {
|
|
626
|
+
ctx.ui.notify("No API keys configured to rotate.", "info");
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
const options = configured.map((p) => p.label);
|
|
631
|
+
const choice = await ctx.ui.select("Rotate key for which provider?", options);
|
|
632
|
+
if (!choice || typeof choice !== "string") return false;
|
|
633
|
+
|
|
634
|
+
provider = configured.find((p) => p.label === choice);
|
|
635
|
+
if (!provider) return false;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
const creds = auth.getCredentialsForProvider(provider.id);
|
|
639
|
+
const apiKeyCreds = creds.filter((c) => c.type === "api_key") as ApiKeyCredential[];
|
|
640
|
+
|
|
641
|
+
if (apiKeyCreds.length === 0) {
|
|
642
|
+
ctx.ui.notify(`No API keys for ${provider.label} (may use OAuth instead).`, "info");
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// Show current key(s)
|
|
647
|
+
const currentDesc = apiKeyCreds.map((c) => maskKey(c.key)).join(", ");
|
|
648
|
+
ctx.ui.notify(`Current key${apiKeyCreds.length > 1 ? "s" : ""}: ${currentDesc}`, "info");
|
|
649
|
+
|
|
650
|
+
// Prompt for new key
|
|
651
|
+
const input = await ctx.ui.input(
|
|
652
|
+
`New API key for ${provider.label}:`,
|
|
653
|
+
"paste your new key here",
|
|
654
|
+
);
|
|
655
|
+
|
|
656
|
+
if (input === null || input === undefined) return false;
|
|
657
|
+
const newKey = input.trim();
|
|
658
|
+
if (!newKey) {
|
|
659
|
+
ctx.ui.notify("No key provided. Rotation cancelled.", "warning");
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// Prefix validation
|
|
664
|
+
if (provider.prefixes && provider.prefixes.length > 0) {
|
|
665
|
+
const valid = provider.prefixes.some((pfx) => newKey.startsWith(pfx));
|
|
666
|
+
if (!valid) {
|
|
667
|
+
ctx.ui.notify(
|
|
668
|
+
`Warning: key doesn't start with expected prefix (${provider.prefixes.join(" or ")}).`,
|
|
669
|
+
"warning",
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// Offer to test before saving
|
|
675
|
+
const shouldTest = await ctx.ui.confirm(
|
|
676
|
+
"Test key?",
|
|
677
|
+
"Validate the new key before saving?",
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
if (shouldTest) {
|
|
681
|
+
// Temporarily test the new key
|
|
682
|
+
const tempAuth = AuthStorage.inMemory({ [provider.id]: { type: "api_key", key: newKey } });
|
|
683
|
+
const result = await testProviderKey(provider, tempAuth);
|
|
684
|
+
|
|
685
|
+
if (result.status === "invalid") {
|
|
686
|
+
ctx.ui.notify(`Key validation failed: ${result.message}. Rotation cancelled.`, "error");
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (result.status === "valid") {
|
|
691
|
+
ctx.ui.notify(`Key validated successfully (${result.latencyMs}ms).`, "success");
|
|
692
|
+
} else {
|
|
693
|
+
ctx.ui.notify(`Key test result: ${result.message}. Proceeding anyway.`, "warning");
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// Remove old keys and add new one
|
|
698
|
+
// Preserve any OAuth credentials
|
|
699
|
+
const oauthCreds = creds.filter((c) => c.type === "oauth");
|
|
700
|
+
auth.remove(provider.id);
|
|
701
|
+
for (const c of oauthCreds) {
|
|
702
|
+
auth.set(provider.id, c);
|
|
703
|
+
}
|
|
704
|
+
auth.set(provider.id, { type: "api_key", key: newKey });
|
|
705
|
+
|
|
706
|
+
if (provider.envVar) {
|
|
707
|
+
process.env[provider.envVar] = newKey;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
ctx.ui.notify(`Key rotated for ${provider.label}: ${maskKey(newKey)}`, "success");
|
|
711
|
+
return true;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// ─── Key Doctor ─────────────────────────────────────────────────────────────────
|
|
715
|
+
|
|
716
|
+
export interface DoctorFinding {
|
|
717
|
+
severity: "error" | "warning" | "info" | "fixed";
|
|
718
|
+
provider?: string;
|
|
719
|
+
message: string;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Run health checks on all API keys.
|
|
724
|
+
*/
|
|
725
|
+
export function runKeyDoctor(auth: AuthStorage): DoctorFinding[] {
|
|
726
|
+
const findings: DoctorFinding[] = [];
|
|
727
|
+
|
|
728
|
+
// 1. Check auth.json permissions
|
|
729
|
+
const authPath = getAuthPath();
|
|
730
|
+
if (existsSync(authPath)) {
|
|
731
|
+
try {
|
|
732
|
+
const stats = statSync(authPath);
|
|
733
|
+
const mode = stats.mode & 0o777;
|
|
734
|
+
if (mode !== 0o600) {
|
|
735
|
+
chmodSync(authPath, 0o600);
|
|
736
|
+
findings.push({
|
|
737
|
+
severity: "fixed",
|
|
738
|
+
message: `auth.json permissions were ${mode.toString(8)} — fixed to 600`,
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
} catch {
|
|
742
|
+
// Can't check permissions — skip
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// 2. Check for empty keys
|
|
747
|
+
for (const provider of PROVIDER_REGISTRY) {
|
|
748
|
+
const creds = auth.getCredentialsForProvider(provider.id);
|
|
749
|
+
for (const cred of creds) {
|
|
750
|
+
if (cred.type === "api_key" && !(cred as ApiKeyCredential).key) {
|
|
751
|
+
findings.push({
|
|
752
|
+
severity: "warning",
|
|
753
|
+
provider: provider.id,
|
|
754
|
+
message: `${provider.label}: empty key stored (from skipped setup) — run /gsd keys add ${provider.id}`,
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
// 3. Check expired OAuth
|
|
761
|
+
for (const provider of PROVIDER_REGISTRY) {
|
|
762
|
+
const creds = auth.getCredentialsForProvider(provider.id);
|
|
763
|
+
for (const cred of creds) {
|
|
764
|
+
if (cred.type === "oauth") {
|
|
765
|
+
const oauthCred = cred as OAuthCredential;
|
|
766
|
+
const remaining = oauthCred.expires - Date.now();
|
|
767
|
+
if (remaining <= 0) {
|
|
768
|
+
findings.push({
|
|
769
|
+
severity: "warning",
|
|
770
|
+
provider: provider.id,
|
|
771
|
+
message: `${provider.label}: OAuth token expired — will auto-refresh on next use`,
|
|
772
|
+
});
|
|
773
|
+
} else if (remaining < 5 * 60 * 1000) {
|
|
774
|
+
findings.push({
|
|
775
|
+
severity: "info",
|
|
776
|
+
provider: provider.id,
|
|
777
|
+
message: `${provider.label}: OAuth token expires in ${formatDuration(remaining)} — will auto-refresh`,
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// 4. Check for env var conflicts
|
|
785
|
+
for (const provider of PROVIDER_REGISTRY) {
|
|
786
|
+
if (!provider.envVar) continue;
|
|
787
|
+
const envValue = process.env[provider.envVar];
|
|
788
|
+
if (!envValue) continue;
|
|
789
|
+
|
|
790
|
+
const creds = auth.getCredentialsForProvider(provider.id);
|
|
791
|
+
const apiKey = creds.find((c) => c.type === "api_key") as ApiKeyCredential | undefined;
|
|
792
|
+
if (apiKey?.key && apiKey.key !== envValue) {
|
|
793
|
+
findings.push({
|
|
794
|
+
severity: "warning",
|
|
795
|
+
provider: provider.id,
|
|
796
|
+
message: `${provider.label}: env ${provider.envVar} differs from auth.json — auth.json takes priority`,
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// 5. Check for backed-off keys
|
|
802
|
+
for (const provider of PROVIDER_REGISTRY) {
|
|
803
|
+
if (auth.areAllCredentialsBackedOff(provider.id)) {
|
|
804
|
+
const remaining = auth.getProviderBackoffRemaining(provider.id);
|
|
805
|
+
findings.push({
|
|
806
|
+
severity: "warning",
|
|
807
|
+
provider: provider.id,
|
|
808
|
+
message: `${provider.label}: all keys in backoff${remaining > 0 ? ` (${formatDuration(remaining)} remaining)` : ""}`,
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// 6. Check for missing LLM provider
|
|
814
|
+
const llmProviders = PROVIDER_REGISTRY.filter((p) => p.category === "llm");
|
|
815
|
+
const hasAnyLlm = llmProviders.some((p) => {
|
|
816
|
+
const creds = auth.getCredentialsForProvider(p.id);
|
|
817
|
+
const hasValidKey = creds.some((c) => c.type === "api_key" ? !!(c as ApiKeyCredential).key : true);
|
|
818
|
+
const hasEnv = p.envVar ? !!process.env[p.envVar] : false;
|
|
819
|
+
return hasValidKey || hasEnv;
|
|
820
|
+
});
|
|
821
|
+
if (!hasAnyLlm) {
|
|
822
|
+
findings.push({
|
|
823
|
+
severity: "error",
|
|
824
|
+
message: "No LLM provider configured — run /gsd keys add or /login",
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// 7. Check for duplicate keys across providers
|
|
829
|
+
const keyToProviders = new Map<string, string[]>();
|
|
830
|
+
for (const provider of PROVIDER_REGISTRY) {
|
|
831
|
+
const creds = auth.getCredentialsForProvider(provider.id);
|
|
832
|
+
for (const cred of creds) {
|
|
833
|
+
if (cred.type === "api_key" && (cred as ApiKeyCredential).key) {
|
|
834
|
+
const key = (cred as ApiKeyCredential).key;
|
|
835
|
+
const existing = keyToProviders.get(key) ?? [];
|
|
836
|
+
existing.push(provider.id);
|
|
837
|
+
keyToProviders.set(key, existing);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
for (const [, providers] of keyToProviders) {
|
|
842
|
+
if (providers.length > 1) {
|
|
843
|
+
findings.push({
|
|
844
|
+
severity: "warning",
|
|
845
|
+
message: `Same key used by multiple providers: ${providers.join(", ")}`,
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
return findings;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Format doctor findings for display.
|
|
855
|
+
*/
|
|
856
|
+
export function formatDoctorFindings(findings: DoctorFinding[]): string {
|
|
857
|
+
if (findings.length === 0) {
|
|
858
|
+
return "API Key Health Check\n\n All checks passed. No issues found.";
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
const lines: string[] = ["API Key Health Check\n"];
|
|
862
|
+
|
|
863
|
+
for (const f of findings) {
|
|
864
|
+
const icon =
|
|
865
|
+
f.severity === "error" ? "✗" :
|
|
866
|
+
f.severity === "warning" ? "⚠" :
|
|
867
|
+
f.severity === "fixed" ? "✓" :
|
|
868
|
+
"ℹ";
|
|
869
|
+
lines.push(` ${icon} ${f.message}`);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
lines.push("");
|
|
873
|
+
const errors = findings.filter((f) => f.severity === "error").length;
|
|
874
|
+
const warnings = findings.filter((f) => f.severity === "warning").length;
|
|
875
|
+
const fixed = findings.filter((f) => f.severity === "fixed").length;
|
|
876
|
+
const info = findings.filter((f) => f.severity === "info").length;
|
|
877
|
+
|
|
878
|
+
const parts: string[] = [];
|
|
879
|
+
if (errors > 0) parts.push(`${errors} error${errors > 1 ? "s" : ""}`);
|
|
880
|
+
if (warnings > 0) parts.push(`${warnings} warning${warnings > 1 ? "s" : ""}`);
|
|
881
|
+
if (fixed > 0) parts.push(`${fixed} fixed`);
|
|
882
|
+
if (info > 0) parts.push(`${info} info`);
|
|
883
|
+
lines.push(` ${parts.join(" | ")}`);
|
|
884
|
+
|
|
885
|
+
return lines.join("\n");
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// ─── Main Handler ───────────────────────────────────────────────────────────────
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Main entry point for /gsd keys [subcommand].
|
|
892
|
+
*/
|
|
893
|
+
export async function handleKeys(
|
|
894
|
+
args: string,
|
|
895
|
+
ctx: ExtensionCommandContext,
|
|
896
|
+
): Promise<void> {
|
|
897
|
+
const auth = getKeyManagerAuthStorage();
|
|
898
|
+
const parts = args.trim().split(/\s+/);
|
|
899
|
+
const subcommand = parts[0] || "";
|
|
900
|
+
const subArgs = parts.slice(1).join(" ").trim();
|
|
901
|
+
|
|
902
|
+
switch (subcommand) {
|
|
903
|
+
case "":
|
|
904
|
+
case "list":
|
|
905
|
+
case "status": {
|
|
906
|
+
const statuses = getAllKeyStatuses(auth);
|
|
907
|
+
ctx.ui.notify(formatKeyDashboard(statuses), "info");
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
case "add": {
|
|
912
|
+
const changed = await handleAddKey(subArgs, ctx, auth);
|
|
913
|
+
if (changed) {
|
|
914
|
+
await ctx.waitForIdle();
|
|
915
|
+
await ctx.reload();
|
|
916
|
+
}
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
case "remove":
|
|
921
|
+
case "rm":
|
|
922
|
+
case "delete": {
|
|
923
|
+
const changed = await handleRemoveKey(subArgs, ctx, auth);
|
|
924
|
+
if (changed) {
|
|
925
|
+
await ctx.waitForIdle();
|
|
926
|
+
await ctx.reload();
|
|
927
|
+
}
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
case "test":
|
|
932
|
+
case "validate": {
|
|
933
|
+
let providers: ProviderInfo[];
|
|
934
|
+
if (subArgs) {
|
|
935
|
+
const p = findProvider(subArgs);
|
|
936
|
+
if (!p) {
|
|
937
|
+
ctx.ui.notify(`Unknown provider: "${subArgs}".`, "error");
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
providers = [p];
|
|
941
|
+
} else {
|
|
942
|
+
// Test all configured providers
|
|
943
|
+
const statuses = getAllKeyStatuses(auth);
|
|
944
|
+
providers = statuses
|
|
945
|
+
.filter((s) => s.configured)
|
|
946
|
+
.map((s) => s.provider);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
if (providers.length === 0) {
|
|
950
|
+
ctx.ui.notify("No configured keys to test.", "info");
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
ctx.ui.notify(`Testing ${providers.length} key${providers.length > 1 ? "s" : ""}...`, "info");
|
|
955
|
+
|
|
956
|
+
const results: TestResult[] = [];
|
|
957
|
+
for (const p of providers) {
|
|
958
|
+
const result = await testProviderKey(p, auth);
|
|
959
|
+
results.push(result);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
ctx.ui.notify(formatTestResults(results), "info");
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
case "rotate": {
|
|
967
|
+
const changed = await handleRotateKey(subArgs, ctx, auth);
|
|
968
|
+
if (changed) {
|
|
969
|
+
await ctx.waitForIdle();
|
|
970
|
+
await ctx.reload();
|
|
971
|
+
}
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
case "doctor":
|
|
976
|
+
case "health": {
|
|
977
|
+
const findings = runKeyDoctor(auth);
|
|
978
|
+
ctx.ui.notify(formatDoctorFindings(findings), "info");
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
default:
|
|
983
|
+
ctx.ui.notify(
|
|
984
|
+
"Usage: /gsd keys [list|add|remove|test|rotate|doctor]\n\n" +
|
|
985
|
+
" /gsd keys Show key status dashboard\n" +
|
|
986
|
+
" /gsd keys list List all configured keys\n" +
|
|
987
|
+
" /gsd keys add [id] Add a key for a provider\n" +
|
|
988
|
+
" /gsd keys remove [id] Remove a key\n" +
|
|
989
|
+
" /gsd keys test [id] Validate key(s) with API call\n" +
|
|
990
|
+
" /gsd keys rotate [id] Replace an existing key\n" +
|
|
991
|
+
" /gsd keys doctor Health check all keys",
|
|
992
|
+
"info",
|
|
993
|
+
);
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
}
|