gsd-pi 2.34.0-dev.ed0bfbf → 2.35.0-dev.30eec3f
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 +7 -2
- package/dist/resource-loader.d.ts +1 -1
- package/dist/resource-loader.js +13 -1
- package/dist/resources/extensions/async-jobs/await-tool.js +0 -2
- package/dist/resources/extensions/async-jobs/job-manager.js +0 -6
- package/dist/resources/extensions/bg-shell/output-formatter.js +1 -19
- package/dist/resources/extensions/bg-shell/process-manager.js +0 -4
- package/dist/resources/extensions/bg-shell/types.js +0 -2
- package/dist/resources/extensions/context7/index.js +5 -0
- package/dist/resources/extensions/get-secrets-from-user.js +2 -30
- package/dist/resources/extensions/google-search/index.js +5 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +43 -1
- package/dist/resources/extensions/gsd/auto-loop.js +10 -1
- package/dist/resources/extensions/gsd/auto-recovery.js +35 -0
- package/dist/resources/extensions/gsd/auto-start.js +35 -2
- package/dist/resources/extensions/gsd/auto.js +59 -4
- package/dist/resources/extensions/gsd/changelog.js +162 -0
- package/dist/resources/extensions/gsd/commands-bootstrap.js +1 -0
- package/dist/resources/extensions/gsd/commands-handlers.js +2 -2
- package/dist/resources/extensions/gsd/commands-inspect.js +10 -3
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +5 -1
- package/dist/resources/extensions/gsd/commands.js +8 -1
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +10 -0
- package/dist/resources/extensions/gsd/doctor-checks.js +113 -5
- package/dist/resources/extensions/gsd/doctor-environment.js +26 -17
- package/dist/resources/extensions/gsd/doctor-proactive.js +22 -0
- package/dist/resources/extensions/gsd/doctor.js +36 -0
- package/dist/resources/extensions/gsd/files.js +11 -2
- package/dist/resources/extensions/gsd/gitignore.js +54 -7
- package/dist/resources/extensions/gsd/guided-flow.js +5 -3
- package/dist/resources/extensions/gsd/health-widget-core.js +96 -0
- package/dist/resources/extensions/gsd/health-widget.js +97 -46
- package/dist/resources/extensions/gsd/index.js +10 -1
- package/dist/resources/extensions/gsd/migrate-external.js +55 -2
- package/dist/resources/extensions/gsd/paths.js +74 -7
- package/dist/resources/extensions/gsd/post-unit-hooks.js +4 -1
- package/dist/resources/extensions/gsd/preferences-validation.js +54 -1
- package/dist/resources/extensions/gsd/preferences.js +2 -0
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +2 -0
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
- package/dist/resources/extensions/gsd/roadmap-mutations.js +55 -0
- package/dist/resources/extensions/gsd/session-lock.js +26 -2
- package/dist/resources/extensions/gsd/templates/plan.md +8 -0
- package/dist/resources/extensions/gsd/worktree-resolver.js +12 -0
- package/dist/resources/extensions/remote-questions/remote-command.js +2 -22
- package/dist/resources/extensions/shared/mod.js +1 -1
- package/dist/resources/extensions/shared/sanitize.js +30 -0
- package/dist/resources/extensions/subagent/index.js +6 -14
- package/dist/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
- package/package.json +2 -1
- package/packages/pi-agent-core/dist/agent-loop.d.ts +14 -0
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +24 -27
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +1 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +11 -22
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/proxy.js +2 -8
- package/packages/pi-agent-core/dist/proxy.js.map +1 -1
- package/packages/pi-agent-core/src/agent-loop.ts +30 -27
- package/packages/pi-agent-core/src/agent.ts +12 -23
- package/packages/pi-agent-core/src/proxy.ts +2 -8
- package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/azure-openai-responses.js +5 -41
- package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +10 -73
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.js +9 -80
- package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-shared.d.ts +65 -0
- package/packages/pi-ai/dist/providers/openai-shared.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-shared.js +146 -0
- package/packages/pi-ai/dist/providers/openai-shared.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +7 -135
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +7 -135
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts +46 -0
- package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js +160 -0
- package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js.map +1 -0
- package/packages/pi-ai/src/providers/azure-openai-responses.ts +11 -45
- package/packages/pi-ai/src/providers/openai-completions.ts +16 -86
- package/packages/pi-ai/src/providers/openai-responses.ts +16 -96
- package/packages/pi-ai/src/providers/openai-shared.ts +193 -0
- package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +14 -162
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +13 -161
- package/packages/pi-ai/src/utils/oauth/google-oauth-utils.ts +201 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +16 -63
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +104 -641
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +0 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.js +4 -35
- package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js +5 -43
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js +11 -69
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +40 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/utils.js +78 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts +77 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js +331 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +2 -2
- 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/runner.d.ts +15 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +129 -243
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +49 -42
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js +2 -21
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lock-utils.d.ts +39 -0
- package/packages/pi-coding-agent/dist/core/lock-utils.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/lock-utils.js +89 -0
- package/packages/pi-coding-agent/dist/core/lock-utils.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/lsp/config.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/lsp/config.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/config.js +4 -1
- package/packages/pi-coding-agent/dist/core/lsp/config.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/index.js +52 -107
- package/packages/pi-coding-agent/dist/core/lsp/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.js +2 -21
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/types.d.ts +0 -1
- package/packages/pi-coding-agent/dist/core/lsp/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/types.js +0 -28
- package/packages/pi-coding-agent/dist/core/lsp/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/package-manager.js +2 -4
- package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +2 -4
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/resource-loader.js +46 -60
- package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/retry-handler.d.ts +87 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.js +295 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts +0 -1
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +3 -28
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +8 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +76 -166
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/skills.js +1 -3
- package/packages/pi-coding-agent/dist/core/skills.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/dist/modes/interactive/components/session-selector.d.ts +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js +9 -26
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +1 -13
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts +44 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js +61 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +6 -9
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +65 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +6 -16
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts +12 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +175 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts +6 -0
- package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js +15 -0
- package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/print-mode.js +2 -30
- package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +2 -28
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts +19 -0
- package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js +45 -0
- package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/error.d.ts +5 -0
- package/packages/pi-coding-agent/dist/utils/error.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/error.js +7 -0
- package/packages/pi-coding-agent/dist/utils/error.js.map +1 -0
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +117 -745
- package/packages/pi-coding-agent/src/core/auth-storage.ts +4 -38
- package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +7 -53
- package/packages/pi-coding-agent/src/core/compaction/compaction.ts +14 -74
- package/packages/pi-coding-agent/src/core/compaction/utils.ts +100 -0
- package/packages/pi-coding-agent/src/core/compaction-orchestrator.ts +424 -0
- package/packages/pi-coding-agent/src/core/extensions/index.ts +1 -21
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +119 -243
- package/packages/pi-coding-agent/src/core/extensions/types.ts +50 -69
- package/packages/pi-coding-agent/src/core/lock-utils.ts +113 -0
- package/packages/pi-coding-agent/src/core/lsp/config.ts +4 -1
- package/packages/pi-coding-agent/src/core/lsp/index.ts +83 -152
- package/packages/pi-coding-agent/src/core/lsp/lspmux.ts +2 -22
- package/packages/pi-coding-agent/src/core/lsp/types.ts +0 -29
- package/packages/pi-coding-agent/src/core/package-manager.ts +1 -4
- package/packages/pi-coding-agent/src/core/resource-loader.ts +56 -69
- package/packages/pi-coding-agent/src/core/retry-handler.ts +359 -0
- package/packages/pi-coding-agent/src/core/session-manager.ts +3 -30
- package/packages/pi-coding-agent/src/core/settings-manager.ts +85 -164
- package/packages/pi-coding-agent/src/core/skills.ts +1 -4
- package/packages/pi-coding-agent/src/index.ts +1 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +17 -29
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +1 -13
- package/packages/pi-coding-agent/src/modes/interactive/components/tree-render-utils.ts +81 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +14 -19
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +7 -18
- package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +196 -0
- package/packages/pi-coding-agent/src/modes/interactive/utils/shorten-path.ts +14 -0
- package/packages/pi-coding-agent/src/modes/print-mode.ts +2 -30
- package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +2 -28
- package/packages/pi-coding-agent/src/modes/shared/command-context-actions.ts +53 -0
- package/packages/pi-coding-agent/src/utils/error.ts +6 -0
- package/packages/pi-tui/dist/components/markdown.d.ts +5 -0
- package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/markdown.js +25 -31
- package/packages/pi-tui/dist/components/markdown.js.map +1 -1
- package/packages/pi-tui/dist/keys.d.ts +0 -4
- package/packages/pi-tui/dist/keys.d.ts.map +1 -1
- package/packages/pi-tui/dist/keys.js +94 -162
- package/packages/pi-tui/dist/keys.js.map +1 -1
- package/packages/pi-tui/src/components/markdown.ts +25 -29
- package/packages/pi-tui/src/keys.ts +94 -173
- package/pkg/dist/modes/interactive/theme/theme.d.ts +65 -0
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +6 -16
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/themes.d.ts +12 -0
- package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -0
- package/pkg/dist/modes/interactive/theme/themes.js +175 -0
- package/pkg/dist/modes/interactive/theme/themes.js.map +1 -0
- package/pkg/package.json +1 -1
- package/src/resources/extensions/async-jobs/await-tool.ts +0 -2
- package/src/resources/extensions/async-jobs/job-manager.ts +0 -7
- package/src/resources/extensions/bg-shell/output-formatter.ts +0 -17
- package/src/resources/extensions/bg-shell/process-manager.ts +0 -4
- package/src/resources/extensions/bg-shell/types.ts +0 -12
- package/src/resources/extensions/context7/index.ts +7 -0
- package/src/resources/extensions/get-secrets-from-user.ts +2 -35
- package/src/resources/extensions/google-search/index.ts +7 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +49 -1
- package/src/resources/extensions/gsd/auto-loop.ts +11 -1
- package/src/resources/extensions/gsd/auto-recovery.ts +39 -0
- package/src/resources/extensions/gsd/auto-start.ts +42 -2
- package/src/resources/extensions/gsd/auto.ts +61 -3
- package/src/resources/extensions/gsd/changelog.ts +213 -0
- package/src/resources/extensions/gsd/commands-bootstrap.ts +1 -0
- package/src/resources/extensions/gsd/commands-handlers.ts +2 -2
- package/src/resources/extensions/gsd/commands-inspect.ts +10 -3
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +5 -1
- package/src/resources/extensions/gsd/commands.ts +9 -1
- package/src/resources/extensions/gsd/docs/preferences-reference.md +10 -0
- package/src/resources/extensions/gsd/doctor-checks.ts +107 -5
- package/src/resources/extensions/gsd/doctor-environment.ts +26 -16
- package/src/resources/extensions/gsd/doctor-proactive.ts +24 -0
- package/src/resources/extensions/gsd/doctor-types.ts +9 -1
- package/src/resources/extensions/gsd/doctor.ts +35 -0
- package/src/resources/extensions/gsd/files.ts +12 -2
- package/src/resources/extensions/gsd/gitignore.ts +54 -7
- package/src/resources/extensions/gsd/guided-flow.ts +5 -3
- package/src/resources/extensions/gsd/health-widget-core.ts +129 -0
- package/src/resources/extensions/gsd/health-widget.ts +103 -59
- package/src/resources/extensions/gsd/index.ts +10 -1
- package/src/resources/extensions/gsd/migrate-external.ts +47 -2
- package/src/resources/extensions/gsd/paths.ts +73 -7
- package/src/resources/extensions/gsd/post-unit-hooks.ts +5 -1
- package/src/resources/extensions/gsd/preferences-validation.ts +54 -1
- package/src/resources/extensions/gsd/preferences.ts +2 -0
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +2 -0
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
- package/src/resources/extensions/gsd/roadmap-mutations.ts +66 -0
- package/src/resources/extensions/gsd/session-lock.ts +29 -2
- package/src/resources/extensions/gsd/templates/plan.md +8 -0
- package/src/resources/extensions/gsd/tests/commands-inspect-open-db.test.ts +46 -0
- package/src/resources/extensions/gsd/tests/doctor-git.test.ts +98 -2
- package/src/resources/extensions/gsd/tests/doctor-runtime.test.ts +59 -3
- package/src/resources/extensions/gsd/tests/files-loadfile-eisdir.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/gitignore-tracked-gsd.test.ts +214 -0
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +158 -0
- package/src/resources/extensions/gsd/tests/paths.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +40 -2
- package/src/resources/extensions/gsd/tests/test-utils.ts +165 -0
- package/src/resources/extensions/gsd/tests/validate-directory.test.ts +15 -0
- package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +32 -0
- package/src/resources/extensions/gsd/worktree-resolver.ts +11 -0
- package/src/resources/extensions/remote-questions/remote-command.ts +2 -23
- package/src/resources/extensions/shared/mod.ts +1 -1
- package/src/resources/extensions/shared/sanitize.ts +36 -0
- package/src/resources/extensions/subagent/index.ts +6 -12
- package/src/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
- package/dist/resources/extensions/shared/wizard-ui.js +0 -478
- package/packages/pi-coding-agent/dist/modes/interactive/theme/dark.json +0 -85
- package/packages/pi-coding-agent/dist/modes/interactive/theme/light.json +0 -84
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -335
- package/packages/pi-coding-agent/src/modes/interactive/theme/dark.json +0 -85
- package/packages/pi-coding-agent/src/modes/interactive/theme/light.json +0 -84
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.json +0 -335
- package/pkg/dist/modes/interactive/theme/dark.json +0 -85
- package/pkg/dist/modes/interactive/theme/light.json +0 -84
- package/pkg/dist/modes/interactive/theme/theme-schema.json +0 -335
- package/src/resources/extensions/shared/wizard-ui.ts +0 -551
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared test utilities for GSD extension tests.
|
|
3
|
+
*
|
|
4
|
+
* Provides cross-platform helpers for creating temporary git repos,
|
|
5
|
+
* safe cleanup, file creation, and shell-free git operations.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { git, makeTempRepo, cleanup, createFile } from "./test-utils.ts";
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
import {
|
|
13
|
+
existsSync,
|
|
14
|
+
mkdirSync,
|
|
15
|
+
mkdtempSync,
|
|
16
|
+
readFileSync,
|
|
17
|
+
rmSync,
|
|
18
|
+
statSync,
|
|
19
|
+
writeFileSync,
|
|
20
|
+
} from "node:fs";
|
|
21
|
+
import { dirname, join } from "node:path";
|
|
22
|
+
import { tmpdir } from "node:os";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Shell-free git helper — uses execFileSync to bypass shell entirely.
|
|
26
|
+
* No quoting issues, no Windows cmd.exe incompatibilities.
|
|
27
|
+
*
|
|
28
|
+
* @param cwd - Working directory for git command
|
|
29
|
+
* @param args - Git arguments (e.g., "add", "-A")
|
|
30
|
+
* @returns trimmed stdout
|
|
31
|
+
*/
|
|
32
|
+
export function git(cwd: string, ...args: string[]): string {
|
|
33
|
+
return execFileSync("git", args, {
|
|
34
|
+
cwd,
|
|
35
|
+
encoding: "utf-8",
|
|
36
|
+
stdio: "pipe",
|
|
37
|
+
}).trim();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a temporary git repository with an initial commit.
|
|
42
|
+
* Configures user.email, user.name, and core.autocrlf=false for
|
|
43
|
+
* consistent behavior across platforms.
|
|
44
|
+
*
|
|
45
|
+
* @param prefix - Optional prefix for the temp directory name
|
|
46
|
+
* @returns absolute path to the temp repo
|
|
47
|
+
*/
|
|
48
|
+
export function makeTempRepo(prefix: string = "gsd-test-"): string {
|
|
49
|
+
const dir = mkdtempSync(join(tmpdir(), prefix));
|
|
50
|
+
git(dir, "init");
|
|
51
|
+
git(dir, "config", "user.email", "test@test.com");
|
|
52
|
+
git(dir, "config", "user.name", "Test");
|
|
53
|
+
git(dir, "config", "core.autocrlf", "false");
|
|
54
|
+
writeFileSync(join(dir, "README.md"), "# init\n");
|
|
55
|
+
git(dir, "add", "-A");
|
|
56
|
+
git(dir, "commit", "-m", "init");
|
|
57
|
+
git(dir, "branch", "-M", "main");
|
|
58
|
+
return dir;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Create a temporary directory (not a git repo).
|
|
63
|
+
*
|
|
64
|
+
* @param prefix - Optional prefix for the temp directory name
|
|
65
|
+
* @returns absolute path to the temp directory
|
|
66
|
+
*/
|
|
67
|
+
export function makeTempDir(prefix: string = "gsd-test-"): string {
|
|
68
|
+
return mkdtempSync(join(tmpdir(), prefix));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Safely clean up a temporary directory.
|
|
73
|
+
* Non-fatal — Windows may hold file descriptors briefly.
|
|
74
|
+
*/
|
|
75
|
+
export function cleanup(dir: string): void {
|
|
76
|
+
try {
|
|
77
|
+
rmSync(dir, { recursive: true, force: true });
|
|
78
|
+
} catch {
|
|
79
|
+
// ignore — Windows may hold file descriptors briefly after test
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Create a file with intermediate directories.
|
|
85
|
+
*
|
|
86
|
+
* @param base - Base directory
|
|
87
|
+
* @param relativePath - Relative path within base (e.g., "src/index.ts")
|
|
88
|
+
* @param content - File content (defaults to empty string)
|
|
89
|
+
* @returns absolute path to the created file
|
|
90
|
+
*/
|
|
91
|
+
export function createFile(base: string, relativePath: string, content: string = ""): string {
|
|
92
|
+
const fullPath = join(base, relativePath);
|
|
93
|
+
mkdirSync(dirname(fullPath), { recursive: true });
|
|
94
|
+
writeFileSync(fullPath, content, "utf-8");
|
|
95
|
+
return fullPath;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Safely read a file, returning null if it doesn't exist or is a directory.
|
|
100
|
+
* Prevents EISDIR errors.
|
|
101
|
+
*/
|
|
102
|
+
export function safeReadFile(filePath: string): string | null {
|
|
103
|
+
try {
|
|
104
|
+
if (!existsSync(filePath)) return null;
|
|
105
|
+
if (!statSync(filePath).isFile()) return null;
|
|
106
|
+
return readFileSync(filePath, "utf-8");
|
|
107
|
+
} catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Create a minimal GSD milestone structure in a temp directory.
|
|
114
|
+
*
|
|
115
|
+
* @param base - Base directory (should have .gsd/ or be a temp repo)
|
|
116
|
+
* @param mid - Milestone ID (e.g., "M001")
|
|
117
|
+
* @param options - What to create
|
|
118
|
+
*/
|
|
119
|
+
export function writeMilestoneFixture(
|
|
120
|
+
base: string,
|
|
121
|
+
mid: string,
|
|
122
|
+
options: {
|
|
123
|
+
roadmap?: string;
|
|
124
|
+
context?: string;
|
|
125
|
+
summary?: string;
|
|
126
|
+
validation?: string;
|
|
127
|
+
slices?: Array<{
|
|
128
|
+
id: string;
|
|
129
|
+
plan?: string;
|
|
130
|
+
summary?: string;
|
|
131
|
+
uat?: string;
|
|
132
|
+
}>;
|
|
133
|
+
} = {},
|
|
134
|
+
): void {
|
|
135
|
+
const milestoneDir = join(base, ".gsd", "milestones", mid);
|
|
136
|
+
mkdirSync(milestoneDir, { recursive: true });
|
|
137
|
+
|
|
138
|
+
if (options.roadmap) {
|
|
139
|
+
writeFileSync(join(milestoneDir, `${mid}-ROADMAP.md`), options.roadmap);
|
|
140
|
+
}
|
|
141
|
+
if (options.context) {
|
|
142
|
+
writeFileSync(join(milestoneDir, `${mid}-CONTEXT.md`), options.context);
|
|
143
|
+
}
|
|
144
|
+
if (options.summary) {
|
|
145
|
+
writeFileSync(join(milestoneDir, `${mid}-SUMMARY.md`), options.summary);
|
|
146
|
+
}
|
|
147
|
+
if (options.validation) {
|
|
148
|
+
writeFileSync(join(milestoneDir, `${mid}-VALIDATION.md`), options.validation);
|
|
149
|
+
}
|
|
150
|
+
if (options.slices) {
|
|
151
|
+
for (const slice of options.slices) {
|
|
152
|
+
const sliceDir = join(milestoneDir, "slices", slice.id);
|
|
153
|
+
mkdirSync(sliceDir, { recursive: true });
|
|
154
|
+
if (slice.plan) {
|
|
155
|
+
writeFileSync(join(sliceDir, `${slice.id}-PLAN.md`), slice.plan);
|
|
156
|
+
}
|
|
157
|
+
if (slice.summary) {
|
|
158
|
+
writeFileSync(join(sliceDir, `${slice.id}-SUMMARY.md`), slice.summary);
|
|
159
|
+
}
|
|
160
|
+
if (slice.uat) {
|
|
161
|
+
writeFileSync(join(sliceDir, `${slice.id}-UAT.md`), slice.uat);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -101,6 +101,21 @@ test("validateDirectory: subdirectory of home is NOT blocked", () => {
|
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
+
// Regression test for #1317: GSD worktree inside $HOME must not be blocked even
|
|
105
|
+
// when the resolved project root equals $HOME (e.g. home dir is a git repo).
|
|
106
|
+
test("validateDirectory: GSD worktree path nested under home is NOT blocked (#1317)", () => {
|
|
107
|
+
const worktreePath = join(homedir(), ".gsd", "worktrees", "M001");
|
|
108
|
+
mkdirSync(worktreePath, { recursive: true });
|
|
109
|
+
try {
|
|
110
|
+
// The worktree CWD itself is a valid location — it must pass.
|
|
111
|
+
const result = validateDirectory(worktreePath);
|
|
112
|
+
assert.equal(result.safe, true, "GSD worktree path should be safe to run in");
|
|
113
|
+
assert.equal(result.severity, "ok");
|
|
114
|
+
} finally {
|
|
115
|
+
rmSync(join(homedir(), ".gsd", "worktrees", "M001"), { recursive: true, force: true });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
104
119
|
// ─── Temp directory root ─────────────────────────────────────────────────────────
|
|
105
120
|
|
|
106
121
|
test("validateDirectory: temp directory root is blocked", () => {
|
|
@@ -196,6 +196,7 @@ test("dispatch rule matches validating-milestone phase", async () => {
|
|
|
196
196
|
try {
|
|
197
197
|
// Set up minimal milestone structure for the prompt builder
|
|
198
198
|
writeRoadmap(base, "M001", ALL_DONE_ROADMAP);
|
|
199
|
+
writeSliceSummary(base, "M001", "S01", "# S01 Summary\nDone."); // Guard requires slice summaries (#1368)
|
|
199
200
|
|
|
200
201
|
const ctx: DispatchContext = {
|
|
201
202
|
basePath: base,
|
|
@@ -231,6 +232,7 @@ test("dispatch rule skips when skip_milestone_validation preference is set", asy
|
|
|
231
232
|
const base = makeTmpBase();
|
|
232
233
|
try {
|
|
233
234
|
writeRoadmap(base, "M001", ALL_DONE_ROADMAP);
|
|
235
|
+
writeSliceSummary(base, "M001", "S01", "# S01 Summary\nDone."); // Guard requires slice summaries (#1368)
|
|
234
236
|
|
|
235
237
|
const ctx: DispatchContext = {
|
|
236
238
|
basePath: base,
|
|
@@ -19,6 +19,7 @@ import { join } from 'node:path';
|
|
|
19
19
|
import { tmpdir } from 'node:os';
|
|
20
20
|
|
|
21
21
|
import { syncProjectRootToWorktree } from '../auto-worktree-sync.ts';
|
|
22
|
+
import { syncGsdStateToWorktree } from '../auto-worktree.ts';
|
|
22
23
|
import { createTestContext } from './test-helpers.ts';
|
|
23
24
|
|
|
24
25
|
const { assertTrue, report } = createTestContext();
|
|
@@ -148,6 +149,37 @@ async function main(): Promise<void> {
|
|
|
148
149
|
assertTrue(true, 'no crash on missing directories');
|
|
149
150
|
}
|
|
150
151
|
|
|
152
|
+
// ─── 7. milestones/ directory created in worktree when missing ────────
|
|
153
|
+
console.log('\n=== 7. milestones/ directory created in worktree when missing ===');
|
|
154
|
+
{
|
|
155
|
+
const mainBase = createBase('main');
|
|
156
|
+
const wtBase = mkdtempSync(join(tmpdir(), 'gsd-wt-sync-wt-'));
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
// Worktree has .gsd/ but NO milestones/ subdirectory
|
|
160
|
+
mkdirSync(join(wtBase, '.gsd'), { recursive: true });
|
|
161
|
+
|
|
162
|
+
// Main repo has M001
|
|
163
|
+
const m001Dir = join(mainBase, '.gsd', 'milestones', 'M001');
|
|
164
|
+
mkdirSync(m001Dir, { recursive: true });
|
|
165
|
+
writeFileSync(join(m001Dir, 'M001-CONTEXT.md'), '# M001 Context');
|
|
166
|
+
writeFileSync(join(m001Dir, 'M001-ROADMAP.md'), '# M001 Roadmap');
|
|
167
|
+
|
|
168
|
+
assertTrue(!existsSync(join(wtBase, '.gsd', 'milestones')), 'milestones/ missing before sync');
|
|
169
|
+
|
|
170
|
+
const result = syncGsdStateToWorktree(mainBase, wtBase);
|
|
171
|
+
|
|
172
|
+
assertTrue(existsSync(join(wtBase, '.gsd', 'milestones')), 'milestones/ created in worktree');
|
|
173
|
+
assertTrue(existsSync(join(wtBase, '.gsd', 'milestones', 'M001')), 'M001 synced to worktree');
|
|
174
|
+
assertTrue(existsSync(join(wtBase, '.gsd', 'milestones', 'M001', 'M001-CONTEXT.md')), 'M001 CONTEXT synced');
|
|
175
|
+
assertTrue(existsSync(join(wtBase, '.gsd', 'milestones', 'M001', 'M001-ROADMAP.md')), 'M001 ROADMAP synced');
|
|
176
|
+
assertTrue(result.synced.length > 0, 'sync reported files');
|
|
177
|
+
} finally {
|
|
178
|
+
cleanup(mainBase);
|
|
179
|
+
rmSync(wtBase, { recursive: true, force: true });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
151
183
|
report();
|
|
152
184
|
}
|
|
153
185
|
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* `process.chdir()` internally — this class MUST NOT double-chdir.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import { existsSync, unlinkSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
16
18
|
import type { AutoSession } from "./auto/session.js";
|
|
17
19
|
import { debugLog } from "./debug-logger.js";
|
|
18
20
|
|
|
@@ -372,6 +374,15 @@ export class WorktreeResolver {
|
|
|
372
374
|
});
|
|
373
375
|
ctx.notify(`Milestone merge failed: ${msg}`, "warning");
|
|
374
376
|
|
|
377
|
+
// Clean up stale merge state left by failed squash-merge (#1389)
|
|
378
|
+
try {
|
|
379
|
+
const gitDir = join(originalBase || this.s.basePath, ".git");
|
|
380
|
+
for (const f of ["SQUASH_MSG", "MERGE_HEAD", "MERGE_MSG"]) {
|
|
381
|
+
const p = join(gitDir, f);
|
|
382
|
+
if (existsSync(p)) unlinkSync(p);
|
|
383
|
+
}
|
|
384
|
+
} catch { /* best-effort */ }
|
|
385
|
+
|
|
375
386
|
// Error recovery: always restore to project root
|
|
376
387
|
if (originalBase) {
|
|
377
388
|
try {
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import type { ExtensionAPI, ExtensionCommandContext } from "@gsd/pi-coding-agent";
|
|
6
6
|
import { AuthStorage } from "@gsd/pi-coding-agent";
|
|
7
|
-
import {
|
|
7
|
+
import { Editor, type EditorTheme, Key, matchesKey, truncateToWidth } from "@gsd/pi-tui";
|
|
8
8
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
10
10
|
import { getGlobalGSDPreferencesPath, loadEffectiveGSDPreferences } from "../gsd/preferences.js";
|
|
11
11
|
import { getRemoteConfigStatus, isValidChannelId, resolveRemoteConfig } from "./config.js";
|
|
12
|
-
import { sanitizeError } from "../shared/
|
|
12
|
+
import { maskEditorLine, sanitizeError } from "../shared/mod.js";
|
|
13
13
|
import { getLatestPromptSummary } from "./status.js";
|
|
14
14
|
|
|
15
15
|
export async function handleRemote(
|
|
@@ -353,27 +353,6 @@ function removeRemoteQuestionsConfig(): void {
|
|
|
353
353
|
writeFileSync(prefsPath, next, "utf-8");
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
function maskEditorLine(line: string): string {
|
|
357
|
-
let output = "";
|
|
358
|
-
let i = 0;
|
|
359
|
-
while (i < line.length) {
|
|
360
|
-
if (line.startsWith(CURSOR_MARKER, i)) {
|
|
361
|
-
output += CURSOR_MARKER;
|
|
362
|
-
i += CURSOR_MARKER.length;
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
|
-
const ansiMatch = /^\x1b\[[0-9;]*m/.exec(line.slice(i));
|
|
366
|
-
if (ansiMatch) {
|
|
367
|
-
output += ansiMatch[0];
|
|
368
|
-
i += ansiMatch[0].length;
|
|
369
|
-
continue;
|
|
370
|
-
}
|
|
371
|
-
output += line[i] === " " ? " " : "*";
|
|
372
|
-
i += 1;
|
|
373
|
-
}
|
|
374
|
-
return output;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
356
|
async function promptMaskedInput(ctx: ExtensionCommandContext, label: string, hint: string): Promise<string | null> {
|
|
378
357
|
if (!ctx.hasUI) return null;
|
|
379
358
|
return ctx.ui.custom<string | null>((tui: any, theme: any, _kb: any, done: (r: string | null) => void) => {
|
|
@@ -28,6 +28,6 @@ export { showInterviewRound } from "./interview-ui.js";
|
|
|
28
28
|
export type { Question, QuestionOption, RoundResult } from "./interview-ui.js";
|
|
29
29
|
export { showNextAction } from "./next-action-ui.js";
|
|
30
30
|
export { showConfirm } from "./confirm-ui.js";
|
|
31
|
-
export { sanitizeError } from "./sanitize.js";
|
|
31
|
+
export { sanitizeError, maskEditorLine } from "./sanitize.js";
|
|
32
32
|
export { formatDateShort, truncateWithEllipsis } from "./format-utils.js";
|
|
33
33
|
export { splitFrontmatter, parseFrontmatterMap } from "./frontmatter.js";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sanitize error messages by redacting token-like strings before surfacing.
|
|
3
|
+
* Also provides maskEditorLine for masking sensitive TUI editor input.
|
|
3
4
|
*/
|
|
4
5
|
|
|
6
|
+
import { CURSOR_MARKER } from "@gsd/pi-tui";
|
|
7
|
+
|
|
5
8
|
const TOKEN_PATTERNS = [
|
|
6
9
|
/xoxb-[A-Za-z0-9\-]+/g, // Slack bot tokens
|
|
7
10
|
/xoxp-[A-Za-z0-9\-]+/g, // Slack user tokens
|
|
@@ -17,3 +20,36 @@ export function sanitizeError(msg: string): string {
|
|
|
17
20
|
}
|
|
18
21
|
return sanitized;
|
|
19
22
|
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Replace editor visible text with masked characters while preserving
|
|
26
|
+
* ANSI cursor/sequencer codes. Keeps border/metadata lines readable.
|
|
27
|
+
*/
|
|
28
|
+
export function maskEditorLine(line: string): string {
|
|
29
|
+
if (line.startsWith("─")) {
|
|
30
|
+
return line;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let output = "";
|
|
34
|
+
let i = 0;
|
|
35
|
+
while (i < line.length) {
|
|
36
|
+
if (line.startsWith(CURSOR_MARKER, i)) {
|
|
37
|
+
output += CURSOR_MARKER;
|
|
38
|
+
i += CURSOR_MARKER.length;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const ansiMatch = /^\x1b\[[0-9;]*m/.exec(line.slice(i));
|
|
43
|
+
if (ansiMatch) {
|
|
44
|
+
output += ansiMatch[0];
|
|
45
|
+
i += ansiMatch[0].length;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const ch = line[i] as string;
|
|
50
|
+
output += ch === " " ? " " : "*";
|
|
51
|
+
i += 1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
@@ -23,6 +23,7 @@ import { StringEnum } from "@gsd/pi-ai";
|
|
|
23
23
|
import { type ExtensionAPI, getMarkdownTheme } from "@gsd/pi-coding-agent";
|
|
24
24
|
import { Container, Markdown, Spacer, Text } from "@gsd/pi-tui";
|
|
25
25
|
import { Type } from "@sinclair/typebox";
|
|
26
|
+
import { formatTokenCount } from "../shared/mod.js";
|
|
26
27
|
import { type AgentConfig, type AgentScope, discoverAgents } from "./agents.js";
|
|
27
28
|
import {
|
|
28
29
|
type IsolationEnvironment,
|
|
@@ -76,13 +77,6 @@ async function stopLiveSubagents(): Promise<void> {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
function formatTokens(count: number): string {
|
|
80
|
-
if (count < 1000) return count.toString();
|
|
81
|
-
if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
|
|
82
|
-
if (count < 1000000) return `${Math.round(count / 1000)}k`;
|
|
83
|
-
return `${(count / 1000000).toFixed(1)}M`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
80
|
function formatUsageStats(
|
|
87
81
|
usage: {
|
|
88
82
|
input: number;
|
|
@@ -97,13 +91,13 @@ function formatUsageStats(
|
|
|
97
91
|
): string {
|
|
98
92
|
const parts: string[] = [];
|
|
99
93
|
if (usage.turns) parts.push(`${usage.turns} turn${usage.turns > 1 ? "s" : ""}`);
|
|
100
|
-
if (usage.input) parts.push(`↑${
|
|
101
|
-
if (usage.output) parts.push(`↓${
|
|
102
|
-
if (usage.cacheRead) parts.push(`R${
|
|
103
|
-
if (usage.cacheWrite) parts.push(`W${
|
|
94
|
+
if (usage.input) parts.push(`↑${formatTokenCount(usage.input)}`);
|
|
95
|
+
if (usage.output) parts.push(`↓${formatTokenCount(usage.output)}`);
|
|
96
|
+
if (usage.cacheRead) parts.push(`R${formatTokenCount(usage.cacheRead)}`);
|
|
97
|
+
if (usage.cacheWrite) parts.push(`W${formatTokenCount(usage.cacheWrite)}`);
|
|
104
98
|
if (usage.cost) parts.push(`$${(Number(usage.cost) || 0).toFixed(4)}`);
|
|
105
99
|
if (usage.contextTokens && usage.contextTokens > 0) {
|
|
106
|
-
parts.push(`ctx:${
|
|
100
|
+
parts.push(`ctx:${formatTokenCount(usage.contextTokens)}`);
|
|
107
101
|
}
|
|
108
102
|
if (model) parts.push(model);
|
|
109
103
|
return parts.join(" ");
|
|
@@ -61,10 +61,10 @@ pi.on("tool_call", async (event, ctx) => {
|
|
|
61
61
|
|
|
62
62
|
**tool_result** — Fired after tool executes. Can modify result. Handlers chain like middleware.
|
|
63
63
|
```typescript
|
|
64
|
-
import {
|
|
64
|
+
import { isToolResultEventType } from "@mariozechner/pi-coding-agent";
|
|
65
65
|
|
|
66
66
|
pi.on("tool_result", async (event, ctx) => {
|
|
67
|
-
if (
|
|
67
|
+
if (isToolResultEventType("bash", event)) {
|
|
68
68
|
// event.details is typed as BashToolDetails
|
|
69
69
|
}
|
|
70
70
|
// Return partial patch: { content, details, isError }
|
|
@@ -105,7 +105,7 @@ pi.on("model_select", async (event, ctx) => {
|
|
|
105
105
|
Built-in type guards for tool events:
|
|
106
106
|
|
|
107
107
|
```typescript
|
|
108
|
-
import { isToolCallEventType,
|
|
108
|
+
import { isToolCallEventType, isToolResultEventType } from "@mariozechner/pi-coding-agent";
|
|
109
109
|
|
|
110
110
|
// Tool calls — narrows event.input type
|
|
111
111
|
if (isToolCallEventType("bash", event)) { /* event.input: { command, timeout? } */ }
|
|
@@ -114,7 +114,7 @@ if (isToolCallEventType("write", event)) { /* event.input: { path, content } */
|
|
|
114
114
|
if (isToolCallEventType("edit", event)) { /* event.input: { path, oldText, newText } */ }
|
|
115
115
|
|
|
116
116
|
// Tool results — narrows event.details type
|
|
117
|
-
if (
|
|
117
|
+
if (isToolResultEventType("bash", event)) { /* event.details: BashToolDetails */ }
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
For custom tools, export your input type and use explicit type params:
|