iosm-cli 0.1.0
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/CHANGELOG.md +55 -0
- package/LICENSE +21 -0
- package/README.md +650 -0
- package/dist/cli/args.d.ts +54 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +331 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +15 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +88 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +262 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-profiles.d.ts +29 -0
- package/dist/core/agent-profiles.d.ts.map +1 -0
- package/dist/core/agent-profiles.js +86 -0
- package/dist/core/agent-profiles.js.map +1 -0
- package/dist/core/agent-session.d.ts +688 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +3112 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/agent-teams.d.ts +41 -0
- package/dist/core/agent-teams.d.ts.map +1 -0
- package/dist/core/agent-teams.js +90 -0
- package/dist/core/agent-teams.js.map +1 -0
- package/dist/core/ask-user-tool.d.ts +22 -0
- package/dist/core/ask-user-tool.d.ts.map +1 -0
- package/dist/core/ask-user-tool.js +115 -0
- package/dist/core/ask-user-tool.js.map +1 -0
- package/dist/core/auth-storage.d.ts +133 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +391 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +49 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +213 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +610 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +35 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +138 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +34 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +222 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +971 -0
- package/dist/core/export-html/template.html +54 -0
- package/dist/core/export-html/template.js +1590 -0
- package/dist/core/export-html/tool-renderer.d.ts +35 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +63 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +25 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +447 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +146 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +652 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1074 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +27 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +32 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +134 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/hooks.d.ts +53 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +332 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +55 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +157 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/mcp/cli.d.ts +27 -0
- package/dist/core/mcp/cli.d.ts.map +1 -0
- package/dist/core/mcp/cli.js +275 -0
- package/dist/core/mcp/cli.js.map +1 -0
- package/dist/core/mcp/config.d.ts +11 -0
- package/dist/core/mcp/config.d.ts.map +1 -0
- package/dist/core/mcp/config.js +310 -0
- package/dist/core/mcp/config.js.map +1 -0
- package/dist/core/mcp/index.d.ts +5 -0
- package/dist/core/mcp/index.d.ts.map +1 -0
- package/dist/core/mcp/index.js +4 -0
- package/dist/core/mcp/index.js.map +1 -0
- package/dist/core/mcp/runtime.d.ts +42 -0
- package/dist/core/mcp/runtime.d.ts.map +1 -0
- package/dist/core/mcp/runtime.js +387 -0
- package/dist/core/mcp/runtime.js.map +1 -0
- package/dist/core/mcp/types.d.ts +76 -0
- package/dist/core/mcp/types.d.ts.map +1 -0
- package/dist/core/mcp/types.js +2 -0
- package/dist/core/mcp/types.js.map +1 -0
- package/dist/core/memory.d.ts +27 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +203 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/messages.d.ts +84 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +141 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +115 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +549 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +104 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +448 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/package-manager.d.ts +156 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1465 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/parallel-task-agent.d.ts +19 -0
- package/dist/core/parallel-task-agent.d.ts.map +1 -0
- package/dist/core/parallel-task-agent.js +482 -0
- package/dist/core/parallel-task-agent.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +50 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +251 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/qwen-cli-provider.d.ts +10 -0
- package/dist/core/qwen-cli-provider.d.ts.map +1 -0
- package/dist/core/qwen-cli-provider.js +271 -0
- package/dist/core/qwen-cli-provider.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +17 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +60 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +195 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +820 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +106 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +460 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-manager.d.ts +323 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1094 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +243 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +691 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +58 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +364 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +64 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/subagent-runs.d.ts +16 -0
- package/dist/core/subagent-runs.d.ts.map +1 -0
- package/dist/core/subagent-runs.js +70 -0
- package/dist/core/subagent-runs.js.map +1 -0
- package/dist/core/subagents.d.ts +45 -0
- package/dist/core/subagents.d.ts.map +1 -0
- package/dist/core/subagents.js +467 -0
- package/dist/core/subagents.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +196 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/task-plan.d.ts +32 -0
- package/dist/core/task-plan.d.ts.map +1 -0
- package/dist/core/task-plan.js +155 -0
- package/dist/core/task-plan.js.map +1 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +26 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +58 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +275 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +63 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +243 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +42 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +158 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/find.d.ts +39 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +219 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +45 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +254 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/ignore-filter.d.ts +5 -0
- package/dist/core/tools/ignore-filter.d.ts.map +1 -0
- package/dist/core/tools/ignore-filter.js +97 -0
- package/dist/core/tools/ignore-filter.js.map +1 -0
- package/dist/core/tools/index.d.ts +97 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +78 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +46 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +136 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/permissions.d.ts +8 -0
- package/dist/core/tools/permissions.d.ts.map +1 -0
- package/dist/core/tools/permissions.js +2 -0
- package/dist/core/tools/permissions.js.map +1 -0
- package/dist/core/tools/read.d.ts +39 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +166 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/task.d.ts +109 -0
- package/dist/core/tools/task.d.ts.map +1 -0
- package/dist/core/tools/task.js +1065 -0
- package/dist/core/tools/task.js.map +1 -0
- package/dist/core/tools/todo.d.ts +42 -0
- package/dist/core/tools/todo.d.ts.map +1 -0
- package/dist/core/tools/todo.js +159 -0
- package/dist/core/tools/todo.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +205 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +32 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +90 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/iosm/agent-verification.d.ts +16 -0
- package/dist/iosm/agent-verification.d.ts.map +1 -0
- package/dist/iosm/agent-verification.js +138 -0
- package/dist/iosm/agent-verification.js.map +1 -0
- package/dist/iosm/automation.d.ts +40 -0
- package/dist/iosm/automation.d.ts.map +1 -0
- package/dist/iosm/automation.js +76 -0
- package/dist/iosm/automation.js.map +1 -0
- package/dist/iosm/config.d.ts +151 -0
- package/dist/iosm/config.d.ts.map +1 -0
- package/dist/iosm/config.js +323 -0
- package/dist/iosm/config.js.map +1 -0
- package/dist/iosm/context-loader.d.ts +12 -0
- package/dist/iosm/context-loader.d.ts.map +1 -0
- package/dist/iosm/context-loader.js +50 -0
- package/dist/iosm/context-loader.js.map +1 -0
- package/dist/iosm/cycle.d.ts +51 -0
- package/dist/iosm/cycle.d.ts.map +1 -0
- package/dist/iosm/cycle.js +861 -0
- package/dist/iosm/cycle.js.map +1 -0
- package/dist/iosm/guide.d.ts +31 -0
- package/dist/iosm/guide.d.ts.map +1 -0
- package/dist/iosm/guide.js +101 -0
- package/dist/iosm/guide.js.map +1 -0
- package/dist/iosm/index.d.ts +12 -0
- package/dist/iosm/index.d.ts.map +1 -0
- package/dist/iosm/index.js +11 -0
- package/dist/iosm/index.js.map +1 -0
- package/dist/iosm/init.d.ts +58 -0
- package/dist/iosm/init.d.ts.map +1 -0
- package/dist/iosm/init.js +1221 -0
- package/dist/iosm/init.js.map +1 -0
- package/dist/iosm/metrics.d.ts +23 -0
- package/dist/iosm/metrics.d.ts.map +1 -0
- package/dist/iosm/metrics.js +336 -0
- package/dist/iosm/metrics.js.map +1 -0
- package/dist/iosm/paths.d.ts +24 -0
- package/dist/iosm/paths.d.ts.map +1 -0
- package/dist/iosm/paths.js +77 -0
- package/dist/iosm/paths.js.map +1 -0
- package/dist/iosm/runtime-context.d.ts +20 -0
- package/dist/iosm/runtime-context.d.ts.map +1 -0
- package/dist/iosm/runtime-context.js +170 -0
- package/dist/iosm/runtime-context.js.map +1 -0
- package/dist/iosm/types.d.ts +151 -0
- package/dist/iosm/types.d.ts.map +1 -0
- package/dist/iosm/types.js +3 -0
- package/dist/iosm/types.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +1478 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +261 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +329 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/ascii-logo.d.ts +11 -0
- package/dist/modes/interactive/components/ascii-logo.d.ts.map +1 -0
- package/dist/modes/interactive/components/ascii-logo.js +25 -0
- package/dist/modes/interactive/components/ascii-logo.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +92 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +36 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +170 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +48 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +42 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +43 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +470 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +28 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +63 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +74 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +138 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/decrypt-loader.d.ts +25 -0
- package/dist/modes/interactive/components/decrypt-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/decrypt-loader.js +102 -0
- package/dist/modes/interactive/components/decrypt-loader.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +105 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +55 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +71 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +39 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +285 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +33 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +34 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +50 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +85 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +139 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/mcp-selector.d.ts +31 -0
- package/dist/modes/interactive/components/mcp-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/mcp-selector.js +171 -0
- package/dist/modes/interactive/components/mcp-selector.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +51 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +292 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +134 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +271 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +839 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +60 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +311 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +34 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +45 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/subagent-message.d.ts +91 -0
- package/dist/modes/interactive/components/subagent-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/subagent-message.js +306 -0
- package/dist/modes/interactive/components/subagent-message.js.map +1 -0
- package/dist/modes/interactive/components/task-plan-message.d.ts +12 -0
- package/dist/modes/interactive/components/task-plan-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-plan-message.js +61 -0
- package/dist/modes/interactive/components/task-plan-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +44 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +46 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +78 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +880 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +70 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +921 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +110 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +27 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +453 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +8669 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +944 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +101 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +404 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +580 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +162 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +163 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +181 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +26 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +186 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +251 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/README.md +32 -0
- package/docs/cli-reference.md +342 -0
- package/docs/configuration.md +301 -0
- package/docs/development-and-testing.md +295 -0
- package/docs/extensions-packages-themes.md +415 -0
- package/docs/getting-started.md +246 -0
- package/docs/interactive-mode.md +272 -0
- package/docs/iosm-init-and-cycles.md +355 -0
- package/docs/orchestration-and-subagents.md +273 -0
- package/docs/rpc-json-sdk.md +353 -0
- package/docs/sessions-traces-export.md +260 -0
- package/examples/README.md +120 -0
- package/examples/extensions/README.md +306 -0
- package/examples/extensions/antigravity-image-gen.ts +415 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/built-in-tool-renderer.ts +246 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +114 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/custom-provider-qwen-cli/index.ts +345 -0
- package/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/handoff.ts +150 -0
- package/examples/extensions/hello.ts +25 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +881 -0
- package/examples/extensions/overlay-test.ts +150 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +398 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/qna.ts +119 -0
- package/examples/extensions/question.ts +264 -0
- package/examples/extensions/questionnaire.ts +427 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +124 -0
- package/examples/extensions/sandbox/index.ts +318 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +40 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +964 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +195 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +299 -0
- package/examples/extensions/tool-override.ts +143 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +40 -0
- package/examples/extensions/truncated-tool.ts +192 -0
- package/examples/extensions/widget-placement.ts +17 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +55 -0
- package/examples/sdk/04-skills.ts +46 -0
- package/examples/sdk/05-tools.ts +56 -0
- package/examples/sdk/06-extensions.ts +88 -0
- package/examples/sdk/07-context-files.ts +40 -0
- package/examples/sdk/08-prompt-templates.ts +47 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/examples/sdk/10-settings.ts +51 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +82 -0
- package/examples/sdk/README.md +337 -0
- package/examples/tsconfig.json +3 -0
- package/package.json +107 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Tool Renderer Example - Custom rendering for built-in tools
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates how to override the rendering of built-in tools (read, bash,
|
|
5
|
+
* edit, write) without changing their behavior. Each tool is re-registered
|
|
6
|
+
* with the same name, delegating execution to the original implementation
|
|
7
|
+
* while providing compact custom renderCall/renderResult functions.
|
|
8
|
+
*
|
|
9
|
+
* This is useful for users who prefer more concise tool output, or who want
|
|
10
|
+
* to highlight specific information (e.g., showing only the diff stats for
|
|
11
|
+
* edit, or just the exit code for bash).
|
|
12
|
+
*
|
|
13
|
+
* How it works:
|
|
14
|
+
* - registerTool() with the same name as a built-in replaces it entirely
|
|
15
|
+
* - We create instances of the original tools via createReadTool(), etc.
|
|
16
|
+
* and delegate execute() to them
|
|
17
|
+
* - renderCall() controls what's shown when the tool is invoked
|
|
18
|
+
* - renderResult() controls what's shown after execution completes
|
|
19
|
+
* - The `expanded` flag in renderResult indicates whether the user has
|
|
20
|
+
* toggled the tool output open (via ctrl+e or clicking)
|
|
21
|
+
*
|
|
22
|
+
* Usage:
|
|
23
|
+
* pi -e ./built-in-tool-renderer.ts
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { BashToolDetails, EditToolDetails, ExtensionAPI, ReadToolDetails } from "iosm-cli";
|
|
27
|
+
import { createBashTool, createEditTool, createReadTool, createWriteTool } from "iosm-cli";
|
|
28
|
+
import { Text } from "@mariozechner/pi-tui";
|
|
29
|
+
|
|
30
|
+
export default function (pi: ExtensionAPI) {
|
|
31
|
+
const cwd = process.cwd();
|
|
32
|
+
|
|
33
|
+
// --- Read tool: show path and line count ---
|
|
34
|
+
const originalRead = createReadTool(cwd);
|
|
35
|
+
pi.registerTool({
|
|
36
|
+
name: "read",
|
|
37
|
+
label: "read",
|
|
38
|
+
description: originalRead.description,
|
|
39
|
+
parameters: originalRead.parameters,
|
|
40
|
+
|
|
41
|
+
async execute(toolCallId, params, signal, onUpdate) {
|
|
42
|
+
return originalRead.execute(toolCallId, params, signal, onUpdate);
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
renderCall(args, theme) {
|
|
46
|
+
let text = theme.fg("toolTitle", theme.bold("read "));
|
|
47
|
+
text += theme.fg("accent", args.path);
|
|
48
|
+
if (args.offset || args.limit) {
|
|
49
|
+
const parts: string[] = [];
|
|
50
|
+
if (args.offset) parts.push(`offset=${args.offset}`);
|
|
51
|
+
if (args.limit) parts.push(`limit=${args.limit}`);
|
|
52
|
+
text += theme.fg("dim", ` (${parts.join(", ")})`);
|
|
53
|
+
}
|
|
54
|
+
return new Text(text, 0, 0);
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
58
|
+
if (isPartial) return new Text(theme.fg("warning", "Reading..."), 0, 0);
|
|
59
|
+
|
|
60
|
+
const details = result.details as ReadToolDetails | undefined;
|
|
61
|
+
const content = result.content[0];
|
|
62
|
+
|
|
63
|
+
if (content?.type === "image") {
|
|
64
|
+
return new Text(theme.fg("success", "Image loaded"), 0, 0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (content?.type !== "text") {
|
|
68
|
+
return new Text(theme.fg("error", "No content"), 0, 0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const lineCount = content.text.split("\n").length;
|
|
72
|
+
let text = theme.fg("success", `${lineCount} lines`);
|
|
73
|
+
|
|
74
|
+
if (details?.truncation?.truncated) {
|
|
75
|
+
text += theme.fg("warning", ` (truncated from ${details.truncation.totalLines})`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (expanded) {
|
|
79
|
+
const lines = content.text.split("\n").slice(0, 15);
|
|
80
|
+
for (const line of lines) {
|
|
81
|
+
text += `\n${theme.fg("dim", line)}`;
|
|
82
|
+
}
|
|
83
|
+
if (lineCount > 15) {
|
|
84
|
+
text += `\n${theme.fg("muted", `... ${lineCount - 15} more lines`)}`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return new Text(text, 0, 0);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// --- Bash tool: show command and exit code ---
|
|
93
|
+
const originalBash = createBashTool(cwd);
|
|
94
|
+
pi.registerTool({
|
|
95
|
+
name: "bash",
|
|
96
|
+
label: "bash",
|
|
97
|
+
description: originalBash.description,
|
|
98
|
+
parameters: originalBash.parameters,
|
|
99
|
+
|
|
100
|
+
async execute(toolCallId, params, signal, onUpdate) {
|
|
101
|
+
return originalBash.execute(toolCallId, params, signal, onUpdate);
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
renderCall(args, theme) {
|
|
105
|
+
let text = theme.fg("toolTitle", theme.bold("$ "));
|
|
106
|
+
const cmd = args.command.length > 80 ? `${args.command.slice(0, 77)}...` : args.command;
|
|
107
|
+
text += theme.fg("accent", cmd);
|
|
108
|
+
if (args.timeout) {
|
|
109
|
+
text += theme.fg("dim", ` (timeout: ${args.timeout}s)`);
|
|
110
|
+
}
|
|
111
|
+
return new Text(text, 0, 0);
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
115
|
+
if (isPartial) return new Text(theme.fg("warning", "Running..."), 0, 0);
|
|
116
|
+
|
|
117
|
+
const details = result.details as BashToolDetails | undefined;
|
|
118
|
+
const content = result.content[0];
|
|
119
|
+
const output = content?.type === "text" ? content.text : "";
|
|
120
|
+
|
|
121
|
+
const exitMatch = output.match(/exit code: (\d+)/);
|
|
122
|
+
const exitCode = exitMatch ? parseInt(exitMatch[1], 10) : null;
|
|
123
|
+
const lineCount = output.split("\n").filter((l) => l.trim()).length;
|
|
124
|
+
|
|
125
|
+
let text = "";
|
|
126
|
+
if (exitCode === 0 || exitCode === null) {
|
|
127
|
+
text += theme.fg("success", "done");
|
|
128
|
+
} else {
|
|
129
|
+
text += theme.fg("error", `exit ${exitCode}`);
|
|
130
|
+
}
|
|
131
|
+
text += theme.fg("dim", ` (${lineCount} lines)`);
|
|
132
|
+
|
|
133
|
+
if (details?.truncation?.truncated) {
|
|
134
|
+
text += theme.fg("warning", " [truncated]");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (expanded) {
|
|
138
|
+
const lines = output.split("\n").slice(0, 20);
|
|
139
|
+
for (const line of lines) {
|
|
140
|
+
text += `\n${theme.fg("dim", line)}`;
|
|
141
|
+
}
|
|
142
|
+
if (output.split("\n").length > 20) {
|
|
143
|
+
text += `\n${theme.fg("muted", "... more output")}`;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return new Text(text, 0, 0);
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// --- Edit tool: show path and diff stats ---
|
|
152
|
+
const originalEdit = createEditTool(cwd);
|
|
153
|
+
pi.registerTool({
|
|
154
|
+
name: "edit",
|
|
155
|
+
label: "edit",
|
|
156
|
+
description: originalEdit.description,
|
|
157
|
+
parameters: originalEdit.parameters,
|
|
158
|
+
|
|
159
|
+
async execute(toolCallId, params, signal, onUpdate) {
|
|
160
|
+
return originalEdit.execute(toolCallId, params, signal, onUpdate);
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
renderCall(args, theme) {
|
|
164
|
+
let text = theme.fg("toolTitle", theme.bold("edit "));
|
|
165
|
+
text += theme.fg("accent", args.path);
|
|
166
|
+
return new Text(text, 0, 0);
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
170
|
+
if (isPartial) return new Text(theme.fg("warning", "Editing..."), 0, 0);
|
|
171
|
+
|
|
172
|
+
const details = result.details as EditToolDetails | undefined;
|
|
173
|
+
const content = result.content[0];
|
|
174
|
+
|
|
175
|
+
if (content?.type === "text" && content.text.startsWith("Error")) {
|
|
176
|
+
return new Text(theme.fg("error", content.text.split("\n")[0]), 0, 0);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (!details?.diff) {
|
|
180
|
+
return new Text(theme.fg("success", "Applied"), 0, 0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Count additions and removals from the diff
|
|
184
|
+
const diffLines = details.diff.split("\n");
|
|
185
|
+
let additions = 0;
|
|
186
|
+
let removals = 0;
|
|
187
|
+
for (const line of diffLines) {
|
|
188
|
+
if (line.startsWith("+") && !line.startsWith("+++")) additions++;
|
|
189
|
+
if (line.startsWith("-") && !line.startsWith("---")) removals++;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
let text = theme.fg("success", `+${additions}`);
|
|
193
|
+
text += theme.fg("dim", " / ");
|
|
194
|
+
text += theme.fg("error", `-${removals}`);
|
|
195
|
+
|
|
196
|
+
if (expanded) {
|
|
197
|
+
for (const line of diffLines.slice(0, 30)) {
|
|
198
|
+
if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
199
|
+
text += `\n${theme.fg("success", line)}`;
|
|
200
|
+
} else if (line.startsWith("-") && !line.startsWith("---")) {
|
|
201
|
+
text += `\n${theme.fg("error", line)}`;
|
|
202
|
+
} else {
|
|
203
|
+
text += `\n${theme.fg("dim", line)}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (diffLines.length > 30) {
|
|
207
|
+
text += `\n${theme.fg("muted", `... ${diffLines.length - 30} more diff lines`)}`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return new Text(text, 0, 0);
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// --- Write tool: show path and size ---
|
|
216
|
+
const originalWrite = createWriteTool(cwd);
|
|
217
|
+
pi.registerTool({
|
|
218
|
+
name: "write",
|
|
219
|
+
label: "write",
|
|
220
|
+
description: originalWrite.description,
|
|
221
|
+
parameters: originalWrite.parameters,
|
|
222
|
+
|
|
223
|
+
async execute(toolCallId, params, signal, onUpdate) {
|
|
224
|
+
return originalWrite.execute(toolCallId, params, signal, onUpdate);
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
renderCall(args, theme) {
|
|
228
|
+
let text = theme.fg("toolTitle", theme.bold("write "));
|
|
229
|
+
text += theme.fg("accent", args.path);
|
|
230
|
+
const lineCount = args.content.split("\n").length;
|
|
231
|
+
text += theme.fg("dim", ` (${lineCount} lines)`);
|
|
232
|
+
return new Text(text, 0, 0);
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
renderResult(result, { isPartial }, theme) {
|
|
236
|
+
if (isPartial) return new Text(theme.fg("warning", "Writing..."), 0, 0);
|
|
237
|
+
|
|
238
|
+
const content = result.content[0];
|
|
239
|
+
if (content?.type === "text" && content.text.startsWith("Error")) {
|
|
240
|
+
return new Text(theme.fg("error", content.text.split("\n")[0]), 0, 0);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return new Text(theme.fg("success", "Written"), 0, 0);
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Rules Extension
|
|
3
|
+
*
|
|
4
|
+
* Scans the project's .claude/rules/ folder for rule files and lists them
|
|
5
|
+
* in the system prompt. The agent can then use the read tool to load
|
|
6
|
+
* specific rules when needed.
|
|
7
|
+
*
|
|
8
|
+
* Best practices for .claude/rules/:
|
|
9
|
+
* - Keep rules focused: Each file should cover one topic (e.g., testing.md, api-design.md)
|
|
10
|
+
* - Use descriptive filenames: The filename should indicate what the rules cover
|
|
11
|
+
* - Use conditional rules sparingly: Only add paths frontmatter when rules truly apply to specific file types
|
|
12
|
+
* - Organize with subdirectories: Group related rules (e.g., frontend/, backend/)
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* 1. Copy this file to ~/.iosm/agent/extensions/ or your project's .iosm/extensions/
|
|
16
|
+
* 2. Create .claude/rules/ folder in your project root
|
|
17
|
+
* 3. Add .md files with your rules
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import * as fs from "node:fs";
|
|
21
|
+
import * as path from "node:path";
|
|
22
|
+
import type { ExtensionAPI } from "iosm-cli";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Recursively find all .md files in a directory
|
|
26
|
+
*/
|
|
27
|
+
function findMarkdownFiles(dir: string, basePath: string = ""): string[] {
|
|
28
|
+
const results: string[] = [];
|
|
29
|
+
|
|
30
|
+
if (!fs.existsSync(dir)) {
|
|
31
|
+
return results;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
35
|
+
|
|
36
|
+
for (const entry of entries) {
|
|
37
|
+
const relativePath = basePath ? `${basePath}/${entry.name}` : entry.name;
|
|
38
|
+
|
|
39
|
+
if (entry.isDirectory()) {
|
|
40
|
+
results.push(...findMarkdownFiles(path.join(dir, entry.name), relativePath));
|
|
41
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
42
|
+
results.push(relativePath);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return results;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default function claudeRulesExtension(pi: ExtensionAPI) {
|
|
50
|
+
let ruleFiles: string[] = [];
|
|
51
|
+
let rulesDir: string = "";
|
|
52
|
+
|
|
53
|
+
// Scan for rules on session start
|
|
54
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
55
|
+
rulesDir = path.join(ctx.cwd, ".claude", "rules");
|
|
56
|
+
ruleFiles = findMarkdownFiles(rulesDir);
|
|
57
|
+
|
|
58
|
+
if (ruleFiles.length > 0) {
|
|
59
|
+
ctx.ui.notify(`Found ${ruleFiles.length} rule(s) in .claude/rules/`, "info");
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Append available rules to system prompt
|
|
64
|
+
pi.on("before_agent_start", async (event) => {
|
|
65
|
+
if (ruleFiles.length === 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const rulesList = ruleFiles.map((f) => `- .claude/rules/${f}`).join("\n");
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
systemPrompt:
|
|
73
|
+
event.systemPrompt +
|
|
74
|
+
`
|
|
75
|
+
|
|
76
|
+
## Project Rules
|
|
77
|
+
|
|
78
|
+
The following project rules are available in .claude/rules/:
|
|
79
|
+
|
|
80
|
+
${rulesList}
|
|
81
|
+
|
|
82
|
+
When working on tasks related to these rules, use the read tool to load the relevant rule files for guidance.
|
|
83
|
+
`,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands Extension
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates the pi.getCommands() API by providing a /commands command
|
|
5
|
+
* that lists all available slash commands in the current session.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* 1. Copy this file to ~/.iosm/agent/extensions/ or your project's .iosm/extensions/
|
|
9
|
+
* 2. Use /commands to see available commands
|
|
10
|
+
* 3. Use /commands extensions to filter by source
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ExtensionAPI, SlashCommandInfo } from "iosm-cli";
|
|
14
|
+
|
|
15
|
+
export default function commandsExtension(pi: ExtensionAPI) {
|
|
16
|
+
pi.registerCommand("commands", {
|
|
17
|
+
description: "List available slash commands",
|
|
18
|
+
getArgumentCompletions: (prefix) => {
|
|
19
|
+
const sources = ["extension", "prompt", "skill"];
|
|
20
|
+
const filtered = sources.filter((s) => s.startsWith(prefix));
|
|
21
|
+
return filtered.length > 0 ? filtered.map((s) => ({ value: s, label: s })) : null;
|
|
22
|
+
},
|
|
23
|
+
handler: async (args, ctx) => {
|
|
24
|
+
const commands = pi.getCommands();
|
|
25
|
+
const sourceFilter = args.trim() as "extension" | "prompt" | "skill" | "";
|
|
26
|
+
|
|
27
|
+
// Filter by source if specified
|
|
28
|
+
const filtered = sourceFilter ? commands.filter((c) => c.source === sourceFilter) : commands;
|
|
29
|
+
|
|
30
|
+
if (filtered.length === 0) {
|
|
31
|
+
ctx.ui.notify(sourceFilter ? `No ${sourceFilter} commands found` : "No commands found", "info");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Build selection items grouped by source
|
|
36
|
+
const formatCommand = (cmd: SlashCommandInfo): string => {
|
|
37
|
+
const desc = cmd.description ? ` - ${cmd.description}` : "";
|
|
38
|
+
return `/${cmd.name}${desc}`;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const items: string[] = [];
|
|
42
|
+
const sources: Array<{ key: "extension" | "prompt" | "skill"; label: string }> = [
|
|
43
|
+
{ key: "extension", label: "Extensions" },
|
|
44
|
+
{ key: "prompt", label: "Prompts" },
|
|
45
|
+
{ key: "skill", label: "Skills" },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
for (const { key, label } of sources) {
|
|
49
|
+
const cmds = filtered.filter((c) => c.source === key);
|
|
50
|
+
if (cmds.length > 0) {
|
|
51
|
+
items.push(`--- ${label} ---`);
|
|
52
|
+
items.push(...cmds.map(formatCommand));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Show in a selector (user can scroll and see all commands)
|
|
57
|
+
const selected = await ctx.ui.select("Available Commands", items);
|
|
58
|
+
|
|
59
|
+
// If user selected a command (not a header), offer to show its path
|
|
60
|
+
if (selected && !selected.startsWith("---")) {
|
|
61
|
+
const cmdName = selected.split(" - ")[0].slice(1); // Remove leading /
|
|
62
|
+
const cmd = commands.find((c) => c.name === cmdName);
|
|
63
|
+
if (cmd?.path) {
|
|
64
|
+
const showPath = await ctx.ui.confirm(cmd.name, `View source path?\n${cmd.path}`);
|
|
65
|
+
if (showPath) {
|
|
66
|
+
ctx.ui.notify(cmd.path, "info");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirm Destructive Actions Extension
|
|
3
|
+
*
|
|
4
|
+
* Prompts for confirmation before destructive session actions (clear, switch, branch).
|
|
5
|
+
* Demonstrates how to cancel session events using the before_* events.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI, SessionBeforeSwitchEvent, SessionMessageEntry } from "iosm-cli";
|
|
9
|
+
|
|
10
|
+
export default function (pi: ExtensionAPI) {
|
|
11
|
+
pi.on("session_before_switch", async (event: SessionBeforeSwitchEvent, ctx) => {
|
|
12
|
+
if (!ctx.hasUI) return;
|
|
13
|
+
|
|
14
|
+
if (event.reason === "new") {
|
|
15
|
+
const confirmed = await ctx.ui.confirm(
|
|
16
|
+
"Clear session?",
|
|
17
|
+
"This will delete all messages in the current session.",
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
if (!confirmed) {
|
|
21
|
+
ctx.ui.notify("Clear cancelled", "info");
|
|
22
|
+
return { cancel: true };
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// reason === "resume" - check if there are unsaved changes (messages since last assistant response)
|
|
28
|
+
const entries = ctx.sessionManager.getEntries();
|
|
29
|
+
const hasUnsavedWork = entries.some(
|
|
30
|
+
(e): e is SessionMessageEntry => e.type === "message" && e.message.role === "user",
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (hasUnsavedWork) {
|
|
34
|
+
const confirmed = await ctx.ui.confirm(
|
|
35
|
+
"Switch session?",
|
|
36
|
+
"You have messages in the current session. Switch anyway?",
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (!confirmed) {
|
|
40
|
+
ctx.ui.notify("Switch cancelled", "info");
|
|
41
|
+
return { cancel: true };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
pi.on("session_before_fork", async (event, ctx) => {
|
|
47
|
+
if (!ctx.hasUI) return;
|
|
48
|
+
|
|
49
|
+
const choice = await ctx.ui.select(`Fork from entry ${event.entryId.slice(0, 8)}?`, [
|
|
50
|
+
"Yes, create fork",
|
|
51
|
+
"No, stay in current session",
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
if (choice !== "Yes, create fork") {
|
|
55
|
+
ctx.ui.notify("Fork cancelled", "info");
|
|
56
|
+
return { cancel: true };
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Compaction Extension
|
|
3
|
+
*
|
|
4
|
+
* Replaces the default compaction behavior with a full summary of the entire context.
|
|
5
|
+
* Instead of keeping the last 20k tokens of conversation turns, this extension:
|
|
6
|
+
* 1. Summarizes ALL messages (messagesToSummarize + turnPrefixMessages)
|
|
7
|
+
* 2. Discards all old turns completely, keeping only the summary
|
|
8
|
+
*
|
|
9
|
+
* This example also demonstrates using a different model (Gemini Flash) for summarization,
|
|
10
|
+
* which can be cheaper/faster than the main conversation model.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* pi --extension examples/extensions/custom-compaction.ts
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { complete } from "@mariozechner/pi-ai";
|
|
17
|
+
import type { ExtensionAPI } from "iosm-cli";
|
|
18
|
+
import { convertToLlm, serializeConversation } from "iosm-cli";
|
|
19
|
+
|
|
20
|
+
export default function (pi: ExtensionAPI) {
|
|
21
|
+
pi.on("session_before_compact", async (event, ctx) => {
|
|
22
|
+
ctx.ui.notify("Custom compaction extension triggered", "info");
|
|
23
|
+
|
|
24
|
+
const { preparation, branchEntries: _, signal } = event;
|
|
25
|
+
const { messagesToSummarize, turnPrefixMessages, tokensBefore, firstKeptEntryId, previousSummary } = preparation;
|
|
26
|
+
|
|
27
|
+
// Use Gemini Flash for summarization (cheaper/faster than most conversation models)
|
|
28
|
+
const model = ctx.modelRegistry.find("google", "gemini-2.5-flash");
|
|
29
|
+
if (!model) {
|
|
30
|
+
ctx.ui.notify(`Could not find Gemini Flash model, using default compaction`, "warning");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Resolve API key for the summarization model
|
|
35
|
+
const apiKey = await ctx.modelRegistry.getApiKey(model);
|
|
36
|
+
if (!apiKey) {
|
|
37
|
+
ctx.ui.notify(`No API key for ${model.provider}, using default compaction`, "warning");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Combine all messages for full summary
|
|
42
|
+
const allMessages = [...messagesToSummarize, ...turnPrefixMessages];
|
|
43
|
+
|
|
44
|
+
ctx.ui.notify(
|
|
45
|
+
`Custom compaction: summarizing ${allMessages.length} messages (${tokensBefore.toLocaleString()} tokens) with ${model.id}...`,
|
|
46
|
+
"info",
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// Convert messages to readable text format
|
|
50
|
+
const conversationText = serializeConversation(convertToLlm(allMessages));
|
|
51
|
+
|
|
52
|
+
// Include previous summary context if available
|
|
53
|
+
const previousContext = previousSummary ? `\n\nPrevious session summary for context:\n${previousSummary}` : "";
|
|
54
|
+
|
|
55
|
+
// Build messages that ask for a comprehensive summary
|
|
56
|
+
const summaryMessages = [
|
|
57
|
+
{
|
|
58
|
+
role: "user" as const,
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
type: "text" as const,
|
|
62
|
+
text: `You are a conversation summarizer. Create a comprehensive summary of this conversation that captures:${previousContext}
|
|
63
|
+
|
|
64
|
+
1. The main goals and objectives discussed
|
|
65
|
+
2. Key decisions made and their rationale
|
|
66
|
+
3. Important code changes, file modifications, or technical details
|
|
67
|
+
4. Current state of any ongoing work
|
|
68
|
+
5. Any blockers, issues, or open questions
|
|
69
|
+
6. Next steps that were planned or suggested
|
|
70
|
+
|
|
71
|
+
Be thorough but concise. The summary will replace the ENTIRE conversation history, so include all information needed to continue the work effectively.
|
|
72
|
+
|
|
73
|
+
Format the summary as structured markdown with clear sections.
|
|
74
|
+
|
|
75
|
+
<conversation>
|
|
76
|
+
${conversationText}
|
|
77
|
+
</conversation>`,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
timestamp: Date.now(),
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
// Pass signal to honor abort requests (e.g., user cancels compaction)
|
|
86
|
+
const response = await complete(model, { messages: summaryMessages }, { apiKey, maxTokens: 8192, signal });
|
|
87
|
+
|
|
88
|
+
const summary = response.content
|
|
89
|
+
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
90
|
+
.map((c) => c.text)
|
|
91
|
+
.join("\n");
|
|
92
|
+
|
|
93
|
+
if (!summary.trim()) {
|
|
94
|
+
if (!signal.aborted) ctx.ui.notify("Compaction summary was empty, using default compaction", "warning");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Return compaction content - SessionManager adds id/parentId
|
|
99
|
+
// Use firstKeptEntryId from preparation to keep recent messages
|
|
100
|
+
return {
|
|
101
|
+
compaction: {
|
|
102
|
+
summary,
|
|
103
|
+
firstKeptEntryId,
|
|
104
|
+
tokensBefore,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
ctx.ui.notify(`Compaction failed: ${message}`, "error");
|
|
110
|
+
// Fall back to default compaction on error
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Footer Extension - demonstrates ctx.ui.setFooter()
|
|
3
|
+
*
|
|
4
|
+
* footerData exposes data not otherwise accessible:
|
|
5
|
+
* - getGitBranch(): current git branch
|
|
6
|
+
* - getExtensionStatuses(): texts from ctx.ui.setStatus()
|
|
7
|
+
*
|
|
8
|
+
* Token stats come from ctx.sessionManager/ctx.model (already accessible).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { AssistantMessage } from "@mariozechner/pi-ai";
|
|
12
|
+
import type { ExtensionAPI } from "iosm-cli";
|
|
13
|
+
import { truncateToWidth, visibleWidth } from "@mariozechner/pi-tui";
|
|
14
|
+
|
|
15
|
+
export default function (pi: ExtensionAPI) {
|
|
16
|
+
let enabled = false;
|
|
17
|
+
|
|
18
|
+
pi.registerCommand("footer", {
|
|
19
|
+
description: "Toggle custom footer",
|
|
20
|
+
handler: async (_args, ctx) => {
|
|
21
|
+
enabled = !enabled;
|
|
22
|
+
|
|
23
|
+
if (enabled) {
|
|
24
|
+
ctx.ui.setFooter((tui, theme, footerData) => {
|
|
25
|
+
const unsub = footerData.onBranchChange(() => tui.requestRender());
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
dispose: unsub,
|
|
29
|
+
invalidate() {},
|
|
30
|
+
render(width: number): string[] {
|
|
31
|
+
// Compute tokens from ctx (already accessible to extensions)
|
|
32
|
+
let input = 0,
|
|
33
|
+
output = 0,
|
|
34
|
+
cost = 0;
|
|
35
|
+
for (const e of ctx.sessionManager.getBranch()) {
|
|
36
|
+
if (e.type === "message" && e.message.role === "assistant") {
|
|
37
|
+
const m = e.message as AssistantMessage;
|
|
38
|
+
input += m.usage.input;
|
|
39
|
+
output += m.usage.output;
|
|
40
|
+
cost += m.usage.cost.total;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Get git branch (not otherwise accessible)
|
|
45
|
+
const branch = footerData.getGitBranch();
|
|
46
|
+
const fmt = (n: number) => (n < 1000 ? `${n}` : `${(n / 1000).toFixed(1)}k`);
|
|
47
|
+
|
|
48
|
+
const left = theme.fg("dim", `↑${fmt(input)} ↓${fmt(output)} $${cost.toFixed(3)}`);
|
|
49
|
+
const branchStr = branch ? ` (${branch})` : "";
|
|
50
|
+
const right = theme.fg("dim", `${ctx.model?.id || "no-model"}${branchStr}`);
|
|
51
|
+
|
|
52
|
+
const pad = " ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(right)));
|
|
53
|
+
return [truncateToWidth(left + pad + right, width)];
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
ctx.ui.notify("Custom footer enabled", "info");
|
|
58
|
+
} else {
|
|
59
|
+
ctx.ui.setFooter(undefined);
|
|
60
|
+
ctx.ui.notify("Default footer restored", "info");
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|