apex-code 0.4.0 → 0.5.1
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 +280 -6
- package/README.md +624 -0
- package/dist/bun/cli.d.ts +3 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +3 -9
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/runtime-setup.d.ts +2 -0
- package/dist/bun/runtime-setup.d.ts.map +1 -0
- package/dist/bun/runtime-setup.js +9 -0
- package/dist/bun/runtime-setup.js.map +1 -0
- package/dist/bun/sandbox-env-setup.d.ts +2 -0
- package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
- package/dist/bun/sandbox-env-setup.js +4 -0
- package/dist/bun/sandbox-env-setup.js.map +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +16 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +2 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/setup.d.ts +2 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +13 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +16 -8
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +85 -15
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +685 -266
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +55 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +291 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +103 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +356 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +4 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +163 -66
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/context/pipeline.d.ts +8 -8
- package/dist/core/context/pipeline.d.ts.map +1 -1
- package/dist/core/context/pipeline.js +21 -12
- package/dist/core/context/pipeline.js.map +1 -1
- package/dist/core/crash-log.d.ts +27 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +139 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/export-html/template.js +6 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +4 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +4 -0
- package/dist/core/extensions/jiti-static-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +40 -59
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +24 -8
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +195 -72
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +142 -55
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +41 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +1 -20
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +2 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +6 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +5 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +168 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +44 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +4 -3
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +12 -6
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/permissions/store.d.ts.map +1 -1
- package/dist/core/permissions/store.js +11 -8
- package/dist/core/permissions/store.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +61 -35
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts +4 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +29 -2
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +3 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +6 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +6 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +63 -42
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +6 -2
- package/dist/core/session-export.d.ts.map +1 -1
- package/dist/core/session-export.js +14 -13
- package/dist/core/session-export.js.map +1 -1
- package/dist/core/session-manager.d.ts +66 -15
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +295 -115
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +27 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +56 -8
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +5 -4
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +140 -79
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +9 -15
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +20 -137
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +2 -2
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -12
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +6 -204
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +4 -55
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +4 -60
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +4 -49
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts +4 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +10 -122
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +18 -0
- package/dist/core/tools/renderers/bash.d.ts.map +1 -0
- package/dist/core/tools/renderers/bash.js +126 -0
- package/dist/core/tools/renderers/bash.js.map +1 -0
- package/dist/core/tools/renderers/edit.d.ts +23 -0
- package/dist/core/tools/renderers/edit.d.ts.map +1 -0
- package/dist/core/tools/renderers/edit.js +207 -0
- package/dist/core/tools/renderers/edit.js.map +1 -0
- package/dist/core/tools/renderers/find.d.ts +10 -0
- package/dist/core/tools/renderers/find.d.ts.map +1 -0
- package/dist/core/tools/renderers/find.js +64 -0
- package/dist/core/tools/renderers/find.js.map +1 -0
- package/dist/core/tools/renderers/grep.d.ts +10 -0
- package/dist/core/tools/renderers/grep.d.ts.map +1 -0
- package/dist/core/tools/renderers/grep.js +69 -0
- package/dist/core/tools/renderers/grep.js.map +1 -0
- package/dist/core/tools/renderers/index.d.ts +34 -0
- package/dist/core/tools/renderers/index.d.ts.map +1 -0
- package/dist/core/tools/renderers/index.js +47 -0
- package/dist/core/tools/renderers/index.js.map +1 -0
- package/dist/core/tools/renderers/ls.d.ts +10 -0
- package/dist/core/tools/renderers/ls.d.ts.map +1 -0
- package/dist/core/tools/renderers/ls.js +58 -0
- package/dist/core/tools/renderers/ls.js.map +1 -0
- package/dist/core/tools/renderers/read.d.ts +11 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -0
- package/dist/core/tools/renderers/read.js +132 -0
- package/dist/core/tools/renderers/read.js.map +1 -0
- package/dist/core/tools/renderers/write.d.ts +10 -0
- package/dist/core/tools/renderers/write.d.ts.map +1 -0
- package/dist/core/tools/renderers/write.js +152 -0
- package/dist/core/tools/renderers/write.js.map +1 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +6 -147
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/usage-totals.d.ts +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +5 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +2 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +7 -3
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +20 -5
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +3 -2
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +21 -13
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +16 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +167 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts +20 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/chat-viewport.js +28 -0
- package/dist/modes/interactive/chat-viewport.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +7 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +63 -27
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/autocomplete-source.d.ts +8 -0
- package/dist/modes/interactive/components/autocomplete-source.d.ts.map +1 -0
- package/dist/modes/interactive/components/autocomplete-source.js +23 -0
- package/dist/modes/interactive/components/autocomplete-source.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +6 -4
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +12 -5
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +12 -5
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/composer-dock.d.ts +12 -0
- package/dist/modes/interactive/components/composer-dock.d.ts.map +1 -0
- package/dist/modes/interactive/components/composer-dock.js +24 -0
- package/dist/modes/interactive/components/composer-dock.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +11 -9
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +12 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +38 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/error-summary.d.ts +11 -0
- package/dist/modes/interactive/components/error-summary.d.ts.map +1 -0
- package/dist/modes/interactive/components/error-summary.js +31 -0
- package/dist/modes/interactive/components/error-summary.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +15 -10
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +15 -5
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +2 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +15 -10
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +6 -6
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +12 -4
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +21 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +34 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +27 -23
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +16 -20
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +7 -6
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/permission-preview.d.ts.map +1 -1
- package/dist/modes/interactive/components/permission-preview.js +3 -3
- package/dist/modes/interactive/components/permission-preview.js.map +1 -1
- package/dist/modes/interactive/components/prompt-input.d.ts +12 -0
- package/dist/modes/interactive/components/prompt-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/prompt-input.js +18 -0
- package/dist/modes/interactive/components/prompt-input.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +17 -18
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +100 -67
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +5 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +74 -16
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.js +8 -6
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +10 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +14 -9
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +28 -16
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +73 -80
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-panel.js +7 -2
- package/dist/modes/interactive/components/tool-panel.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +18 -5
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +12 -12
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +2 -2
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +6 -3
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +50 -31
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +494 -229
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +2 -1
- package/dist/modes/interactive/theme/light.json +2 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +5 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +84 -0
- package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-json.js +130 -0
- package/dist/modes/interactive/theme/theme-json.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +6 -2
- package/dist/modes/interactive/theme/theme.d.ts +14 -5
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +18 -119
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts +21 -0
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/tui-renderer.js +66 -0
- package/dist/modes/interactive/tui-renderer.js.map +1 -0
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +49 -23
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/testing/replay/recorded-provider.d.ts +2 -2
- package/dist/testing/replay/recorded-provider.d.ts.map +1 -1
- package/dist/testing/replay/recorded-provider.js +2 -5
- package/dist/testing/replay/recorded-provider.js.map +1 -1
- package/dist/testing/replay/runner.d.ts.map +1 -1
- package/dist/testing/replay/runner.js +0 -1
- package/dist/testing/replay/runner.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +53 -81
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +111 -121
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +21 -21
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tool-result-images.d.ts +3 -1
- package/dist/utils/tool-result-images.d.ts.map +1 -1
- package/dist/utils/tool-result-images.js +4 -1
- package/dist/utils/tool-result-images.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +11 -2
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/cli-integration.md +107 -0
- package/docs/cli.md +269 -0
- package/docs/compaction.md +73 -24
- package/docs/configuration.md +45 -0
- package/docs/containerization.md +22 -21
- package/docs/custom-provider.md +21 -12
- package/docs/development.md +19 -0
- package/docs/docs.json +139 -95
- package/docs/extensions.md +243 -371
- package/docs/how-pi-works.md +49 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/index.md +3 -3
- package/docs/json.md +43 -3
- package/docs/keybindings.md +57 -54
- package/docs/llama-cpp.md +2 -2
- package/docs/message-types.md +261 -0
- package/docs/models.md +103 -49
- package/docs/packages.md +49 -47
- package/docs/prompt-templates.md +29 -56
- package/docs/providers.md +91 -139
- package/docs/quickstart.md +42 -14
- package/docs/rpc-commands.md +854 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +121 -223
- package/docs/sdk.md +99 -124
- package/docs/security.md +7 -7
- package/docs/session-format.md +85 -82
- package/docs/sessions.md +41 -57
- package/docs/settings.md +95 -88
- package/docs/shell-aliases.md +68 -3
- package/docs/skills.md +62 -49
- package/docs/slash-commands.md +60 -0
- package/docs/terminal-setup.md +86 -55
- package/docs/termux.md +65 -75
- package/docs/themes.md +64 -86
- package/docs/tmux.md +29 -7
- package/docs/tui.md +67 -122
- package/docs/usage.md +31 -42
- package/docs/windows.md +41 -13
- package/examples/README.md +16 -2
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +18 -12
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +2 -0
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/plugins/pi-example-plugin/README.md +38 -0
- package/examples/plugins/pi-example-plugin/package.json +10 -0
- package/examples/plugins/pi-example-plugin/src/contract.ts +13 -0
- package/examples/plugins/pi-example-plugin/src/session.ts +24 -0
- package/examples/plugins/pi-example-plugin/src/tui.ts +31 -0
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +25 -5
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +861 -513
- package/package.json +27 -18
- package/dist/bun/register-bedrock.d.ts +0 -2
- package/dist/bun/register-bedrock.d.ts.map +0 -1
- package/dist/bun/register-bedrock.js +0 -4
- package/dist/bun/register-bedrock.js.map +0 -1
- package/dist/cli/experimental/auth.d.ts +0 -16
- package/dist/cli/experimental/auth.d.ts.map +0 -1
- package/dist/cli/experimental/auth.js +0 -13
- package/dist/cli/experimental/auth.js.map +0 -1
- package/dist/cli/experimental/cli.d.ts +0 -6
- package/dist/cli/experimental/cli.d.ts.map +0 -1
- package/dist/cli/experimental/cli.js +0 -5
- package/dist/cli/experimental/cli.js.map +0 -1
- package/dist/cli/experimental/command-options.d.ts +0 -17
- package/dist/cli/experimental/command-options.d.ts.map +0 -1
- package/dist/cli/experimental/command-options.js +0 -35
- package/dist/cli/experimental/command-options.js.map +0 -1
- package/dist/cli/experimental/command.d.ts +0 -63
- package/dist/cli/experimental/command.d.ts.map +0 -1
- package/dist/cli/experimental/command.js +0 -130
- package/dist/cli/experimental/command.js.map +0 -1
- package/dist/cli/experimental/commands/client.d.ts +0 -13
- package/dist/cli/experimental/commands/client.d.ts.map +0 -1
- package/dist/cli/experimental/commands/client.js +0 -25
- package/dist/cli/experimental/commands/client.js.map +0 -1
- package/dist/cli/experimental/commands/pi.d.ts +0 -15
- package/dist/cli/experimental/commands/pi.d.ts.map +0 -1
- package/dist/cli/experimental/commands/pi.js +0 -28
- package/dist/cli/experimental/commands/pi.js.map +0 -1
- package/dist/cli/experimental/commands/server.d.ts +0 -13
- package/dist/cli/experimental/commands/server.d.ts.map +0 -1
- package/dist/cli/experimental/commands/server.js +0 -25
- package/dist/cli/experimental/commands/server.js.map +0 -1
- package/dist/cli/experimental/transport-address.d.ts +0 -10
- package/dist/cli/experimental/transport-address.d.ts.map +0 -1
- package/dist/cli/experimental/transport-address.js +0 -38
- package/dist/cli/experimental/transport-address.js.map +0 -1
- package/dist/client/index.d.ts +0 -3
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -3
- package/dist/client/index.js.map +0 -1
- package/dist/client/remote-session.d.ts +0 -53
- package/dist/client/remote-session.d.ts.map +0 -1
- package/dist/client/remote-session.js +0 -340
- package/dist/client/remote-session.js.map +0 -1
- package/dist/client/transcript.d.ts +0 -12
- package/dist/client/transcript.d.ts.map +0 -1
- package/dist/client/transcript.js +0 -98
- package/dist/client/transcript.js.map +0 -1
- package/dist/modes/interactive/components/message-spine.d.ts +0 -14
- package/dist/modes/interactive/components/message-spine.d.ts.map +0 -1
- package/dist/modes/interactive/components/message-spine.js +0 -19
- package/dist/modes/interactive/components/message-spine.js.map +0 -1
- package/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
package/docs/session-format.md
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Sessions are stored as JSONL (JSON Lines) files. Each line is a JSON object with a `type` field. Session entries form a tree structure via `id`/`parentId` fields, enabling in-place branching without creating new files.
|
|
4
4
|
|
|
5
|
+
For programmatic creation, persistence, and tree navigation, see the [`SessionManager` API](sdk.md#sessionmanager-api).
|
|
6
|
+
|
|
7
|
+
|
|
5
8
|
## File Location
|
|
6
9
|
|
|
7
10
|
```
|
|
8
11
|
~/.apex-code/agent/sessions/--<path>--/<timestamp>_<uuid>.jsonl
|
|
9
12
|
```
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
By default, `<session-id>` is a UUID. Callers can supply a custom ID through the SDK or `--session-id`. For `<path>`, Pi removes the leading path separator and replaces `/`, `\\`, and `:` with `-`.
|
|
12
15
|
|
|
13
16
|
## Deleting Sessions
|
|
14
17
|
|
|
@@ -36,9 +39,9 @@ Forked source on GitHub ([apex-code](https://github.com/Fchery87/apex-code)); ba
|
|
|
36
39
|
|
|
37
40
|
For TypeScript definitions in your project, inspect `node_modules/apex-code/dist/` and `node_modules/@earendil-works/pi-ai/dist/`.
|
|
38
41
|
|
|
39
|
-
##
|
|
42
|
+
## Messages
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
A `message` entry stores an [`AgentMessage`](message-types.md). Message content blocks, roles, usage, and message timestamps are defined in [Message Types](message-types.md).
|
|
42
45
|
|
|
43
46
|
### Content Blocks
|
|
44
47
|
|
|
@@ -48,6 +51,7 @@ Messages contain arrays of typed content blocks:
|
|
|
48
51
|
interface TextContent {
|
|
49
52
|
type: "text";
|
|
50
53
|
text: string;
|
|
54
|
+
textSignature?: string;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
interface ImageContent {
|
|
@@ -59,6 +63,8 @@ interface ImageContent {
|
|
|
59
63
|
interface ThinkingContent {
|
|
60
64
|
type: "thinking";
|
|
61
65
|
thinking: string;
|
|
66
|
+
thinkingSignature?: string;
|
|
67
|
+
redacted?: boolean;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
interface ToolCall {
|
|
@@ -66,12 +72,22 @@ interface ToolCall {
|
|
|
66
72
|
id: string;
|
|
67
73
|
name: string;
|
|
68
74
|
arguments: Record<string, any>;
|
|
75
|
+
thoughtSignature?: string;
|
|
76
|
+
namespace?: string;
|
|
69
77
|
}
|
|
70
78
|
```
|
|
71
79
|
|
|
72
80
|
### Base Message Types (from pi-ai)
|
|
73
81
|
|
|
74
82
|
```typescript
|
|
83
|
+
interface SystemMessage {
|
|
84
|
+
role: "system";
|
|
85
|
+
content: string | TextContent[];
|
|
86
|
+
toolsAdded?: Tool[];
|
|
87
|
+
toolsRemoved?: Array<{ name: string }>;
|
|
88
|
+
timestamp: number; // Unix ms
|
|
89
|
+
}
|
|
90
|
+
|
|
75
91
|
interface UserMessage {
|
|
76
92
|
role: "user";
|
|
77
93
|
content: string | (TextContent | ImageContent)[];
|
|
@@ -84,9 +100,16 @@ interface AssistantMessage {
|
|
|
84
100
|
api: string;
|
|
85
101
|
provider: string;
|
|
86
102
|
model: string;
|
|
103
|
+
responseModel?: string;
|
|
104
|
+
responseId?: string;
|
|
105
|
+
providerThinkingLevel?: string;
|
|
106
|
+
diagnostics?: AssistantMessageDiagnostic[];
|
|
87
107
|
usage: Usage;
|
|
88
|
-
stopReason: "stop" | "length" | "toolUse" | "error" | "aborted";
|
|
108
|
+
stopReason: "pending" | "stop" | "length" | "toolUse" | "error" | "aborted" | "deferred";
|
|
109
|
+
deferred?: DeferredHandle;
|
|
89
110
|
errorMessage?: string;
|
|
111
|
+
rawStopReason?: string;
|
|
112
|
+
endTurn?: boolean;
|
|
90
113
|
timestamp: number;
|
|
91
114
|
}
|
|
92
115
|
|
|
@@ -106,6 +129,8 @@ interface Usage {
|
|
|
106
129
|
output: number;
|
|
107
130
|
cacheRead: number;
|
|
108
131
|
cacheWrite: number;
|
|
132
|
+
cacheWrite1h?: number;
|
|
133
|
+
reasoning?: number;
|
|
109
134
|
totalTokens: number;
|
|
110
135
|
cost: {
|
|
111
136
|
input: number;
|
|
@@ -146,7 +171,7 @@ interface CustomMessage {
|
|
|
146
171
|
interface BranchSummaryMessage {
|
|
147
172
|
role: "branchSummary";
|
|
148
173
|
summary: string;
|
|
149
|
-
fromId: string;
|
|
174
|
+
fromId: string | null; // Previous leaf whose abandoned path was summarized
|
|
150
175
|
timestamp: number;
|
|
151
176
|
}
|
|
152
177
|
|
|
@@ -162,6 +187,7 @@ interface CompactionSummaryMessage {
|
|
|
162
187
|
|
|
163
188
|
```typescript
|
|
164
189
|
type AgentMessage =
|
|
190
|
+
| SystemMessage
|
|
165
191
|
| UserMessage
|
|
166
192
|
| AssistantMessage
|
|
167
193
|
| ToolResultMessage
|
|
@@ -178,8 +204,8 @@ All entries (except `SessionHeader`) extend `SessionEntryBase`:
|
|
|
178
204
|
```typescript
|
|
179
205
|
interface SessionEntryBase {
|
|
180
206
|
type: string;
|
|
181
|
-
id: string; // 8-char hex ID
|
|
182
|
-
parentId: string | null; // Parent entry ID (null for
|
|
207
|
+
id: string; // Usually an 8-char hex ID; may fall back to a full UUID
|
|
208
|
+
parentId: string | null; // Parent entry ID (null for a root entry)
|
|
183
209
|
timestamp: string; // ISO timestamp
|
|
184
210
|
}
|
|
185
211
|
```
|
|
@@ -202,12 +228,19 @@ For sessions with a parent (created via `/fork`, `/clone`, or `newSession({ pare
|
|
|
202
228
|
|
|
203
229
|
### SessionMessageEntry
|
|
204
230
|
|
|
205
|
-
A message in the conversation. The `message` field contains an `AgentMessage`.
|
|
231
|
+
A message in the conversation. The `message` field contains an `AgentMessage`. System messages carry the prompt and tool loadout: the first request of a session persists one with every prompt section and tool declaration, and later changes persist as system messages that patch `sections` by name (`null` removes one) and list `toolsAdded`/`toolsRemoved`. Replaying them in order yields the current prompt and tools; there is no separate prompt state entry.
|
|
232
|
+
|
|
233
|
+
```json
|
|
234
|
+
{"type":"message","id":"a0b1c2d3","parentId":null,"timestamp":"2024-12-03T14:00:00.000Z","message":{"role":"system","content":"","sections":{"preamble":"You are an expert coding assistant...","tools":"<tools>\n- read: ...\n</tools>","cwd":"/project"},"toolsAdded":[{"name":"read","description":"...","parameters":{}}],"timestamp":1733234400000}}
|
|
235
|
+
{"type":"message","id":"d4e5f6g7","parentId":"c3d4e5f6","timestamp":"2024-12-03T14:04:00.000Z","message":{"role":"system","content":"","sections":{"skills":"<skills>...</skills>"},"toolsRemoved":[{"name":"write"}],"timestamp":1733234640000}}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Sessions created before system messages existed have no leading system message; the first request declares the current prompt as a later system message, which replays the same way.
|
|
206
239
|
|
|
207
240
|
```json
|
|
208
|
-
{"type":"message","id":"a1b2c3d4","parentId":"prev1234","timestamp":"2024-12-03T14:00:01.000Z","message":{"role":"user","content":"Hello"}}
|
|
209
|
-
{"type":"message","id":"b2c3d4e5","parentId":"a1b2c3d4","timestamp":"2024-12-03T14:00:02.000Z","message":{"role":"assistant","content":[{"type":"text","text":"Hi!"}],"provider":"anthropic","model":"claude-sonnet-4-5","usage":{...},"stopReason":"stop"}}
|
|
210
|
-
{"type":"message","id":"c3d4e5f6","parentId":"b2c3d4e5","timestamp":"2024-12-03T14:00:03.000Z","message":{"role":"toolResult","toolCallId":"call_123","toolName":"bash","content":[{"type":"text","text":"output"}],"isError":false}}
|
|
241
|
+
{"type":"message","id":"a1b2c3d4","parentId":"prev1234","timestamp":"2024-12-03T14:00:01.000Z","message":{"role":"user","content":"Hello","timestamp":1733234401000}}
|
|
242
|
+
{"type":"message","id":"b2c3d4e5","parentId":"a1b2c3d4","timestamp":"2024-12-03T14:00:02.000Z","message":{"role":"assistant","content":[{"type":"text","text":"Hi!"}],"api":"anthropic-messages","provider":"anthropic","model":"claude-sonnet-4-5","usage":{...},"stopReason":"stop","timestamp":1733234402000}}
|
|
243
|
+
{"type":"message","id":"c3d4e5f6","parentId":"b2c3d4e5","timestamp":"2024-12-03T14:00:03.000Z","message":{"role":"toolResult","toolCallId":"call_123","toolName":"bash","content":[{"type":"text","text":"output"}],"isError":false,"timestamp":1733234403000}}
|
|
211
244
|
```
|
|
212
245
|
|
|
213
246
|
### ModelChangeEntry
|
|
@@ -226,27 +259,43 @@ Emitted when the user changes the thinking/reasoning level.
|
|
|
226
259
|
{"type":"thinking_level_change","id":"e5f6g7h8","parentId":"d4e5f6g7","timestamp":"2024-12-03T14:06:00.000Z","thinkingLevel":"high"}
|
|
227
260
|
```
|
|
228
261
|
|
|
229
|
-
###
|
|
262
|
+
### UsageEntry
|
|
230
263
|
|
|
231
|
-
|
|
264
|
+
Records model-attributed usage that is not an assistant message and does not participate in LLM context. `kind` is an arbitrary string identifying the operation; for example, cache warming uses `"cache_warm"`.
|
|
232
265
|
|
|
233
266
|
```json
|
|
234
|
-
{"type":"
|
|
267
|
+
{"type":"usage","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:08:00.000Z","kind":"cache_warm","provider":"anthropic","model":"claude-sonnet-4-5","usage":{"input":0,"output":0,"cacheRead":50000,"cacheWrite":0,"totalTokens":50000,"cost":{"input":0,"output":0,"cacheRead":0.015,"cacheWrite":0,"total":0.015}}}
|
|
235
268
|
```
|
|
236
269
|
|
|
237
|
-
|
|
270
|
+
Usage entries contribute to session token and cost totals. Pi hides them from the conversation tree. Consumers should treat unknown `kind` values as normal usage rather than rejecting them.
|
|
271
|
+
|
|
272
|
+
### CompactionEntry
|
|
273
|
+
|
|
274
|
+
Created when context is compacted. Stores a summary of earlier messages and a complete system prompt/tool checkpoint.
|
|
238
275
|
|
|
239
276
|
```json
|
|
240
|
-
{"type":"compaction","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:10:00.000Z","summary":"User discussed X, Y, Z...","tokensBefore":50000,"
|
|
277
|
+
{"type":"compaction","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:10:00.000Z","summary":"User discussed X, Y, Z...","firstKeptEntryId":"c3d4e5f6","tokensBefore":50000,"systemMessage":{"role":"system","content":"You are a coding assistant.","toolsAdded":[],"timestamp":1733235000000}}
|
|
241
278
|
```
|
|
242
279
|
|
|
280
|
+
`firstKeptEntryId` is required. It identifies the first entry retained from before the compaction entry. When rebuilding context, Pi replaces older summarized entries with the compaction summary and keeps the range beginning at this entry. A retain-none compaction stores its own ID in this field, so no preceding entries are retained.
|
|
281
|
+
|
|
243
282
|
Optional fields:
|
|
283
|
+
- `systemMessage`: The replayed prompt sections and tool declarations at the compaction boundary; it becomes the leading system message of the compacted context, and system messages among the kept entries are dropped in its favor. It is absent on older session entries.
|
|
244
284
|
- `usage`: LLM usage from generating the summary; included in session token and cost totals
|
|
245
|
-
- `retainedTail`: Materialized `AgentMessage[]` kept after compaction. This is optional only for backward compatibility with older sessions. Newer harness-generated compactions include it so we can rebuild context from this checkpoint without walking older entries before the compaction entry.
|
|
246
285
|
- `details`: Implementation-specific data (e.g., `{ readFiles: string[], modifiedFiles: string[] }` for default, or custom data for extensions)
|
|
247
286
|
- `fromHook`: `true` if generated by an extension, `false`/`undefined` if generated by Apex Code itself (legacy field name)
|
|
248
287
|
- `firstKeptEntryId`: for compatibility with old entry format.
|
|
249
288
|
|
|
289
|
+
### ContextEditEntry
|
|
290
|
+
|
|
291
|
+
Append-only edit of one earlier context-producing entry. It changes only future model context; the target entry and its metadata remain unchanged in raw history, UI, exports, and session accounting.
|
|
292
|
+
|
|
293
|
+
```json
|
|
294
|
+
{"type":"context_edit","id":"g6h7i8j9","parentId":"f6g7h8i9","timestamp":"2024-12-03T14:11:00.000Z","targetId":"c3d4e5f6","replacement":null}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Targets may be user, assistant, tool-result, or custom-message entries. `replacement: null` omits the target from model context. A non-null `replacement` replaces only the target message content. String replacements for assistant and tool-result entries are normalized to one text block because those roles require content arrays. If several edits target the same entry, the latest edit on the active branch wins. Edits are branch-relative: navigating to a point before the edit reveals the target's original contribution again.
|
|
298
|
+
|
|
250
299
|
### BranchSummaryEntry
|
|
251
300
|
|
|
252
301
|
Created when switching branches via `/tree` with an LLM generated summary of the left branch up to the common ancestor. Captures context from the abandoned path.
|
|
@@ -255,6 +304,8 @@ Created when switching branches via `/tree` with an LLM generated summary of the
|
|
|
255
304
|
{"type":"branch_summary","id":"g7h8i9j0","parentId":"a1b2c3d4","timestamp":"2024-12-03T14:15:00.000Z","fromId":"f6g7h8i9","summary":"Branch explored approach A..."}
|
|
256
305
|
```
|
|
257
306
|
|
|
307
|
+
`parentId` is the entry from which the new branch continues. `fromId` is the previous leaf whose abandoned path was summarized.
|
|
308
|
+
|
|
258
309
|
Optional fields:
|
|
259
310
|
- `usage`: LLM usage from generating the summary; included in session token and cost totals
|
|
260
311
|
- `details`: File tracking data (`{ readFiles: string[], modifiedFiles: string[] }`) for default, or custom data for extensions
|
|
@@ -305,11 +356,12 @@ The session name is displayed in the session selector (`/resume`) instead of the
|
|
|
305
356
|
|
|
306
357
|
## Tree Structure
|
|
307
358
|
|
|
308
|
-
Entries form
|
|
309
|
-
-
|
|
310
|
-
- Each
|
|
359
|
+
Entries normally form one tree, but navigation APIs can create multiple roots:
|
|
360
|
+
- A root entry has `parentId: null`; the first entry is initially the root
|
|
361
|
+
- Each non-root entry points to its parent via `parentId`
|
|
311
362
|
- Branching creates new children from an earlier entry
|
|
312
363
|
- The "leaf" is the current position in the tree
|
|
364
|
+
- Calling `resetLeaf()` or `branchWithSummary(null, ...)` allows a later entry to become another root
|
|
313
365
|
|
|
314
366
|
```
|
|
315
367
|
[user msg] ─── [assistant] ─── [user msg] ─── [assistant] ─┬─ [user msg] ← current leaf
|
|
@@ -322,24 +374,26 @@ Entries form a tree:
|
|
|
322
374
|
`buildContextEntries()` walks from the current leaf to the root, producing the active entry list while honoring compaction:
|
|
323
375
|
|
|
324
376
|
1. Collects all entries on the path
|
|
325
|
-
2. If
|
|
377
|
+
2. If one or more `CompactionEntry` values are on the path, uses the latest one:
|
|
326
378
|
- Includes the compaction entry first
|
|
327
|
-
-
|
|
328
|
-
-
|
|
329
|
-
- Then entries after compaction are included
|
|
379
|
+
- Includes non-system entries from `firstKeptEntryId` up to, but not including, the compaction entry
|
|
380
|
+
- Includes entries after the compaction entry
|
|
330
381
|
3. Preserves non-message entries in the selected range so interactive mode can render them
|
|
331
382
|
|
|
332
|
-
`
|
|
383
|
+
`buildSessionProjection()` then applies the latest `context_edit` for each selected target. It returns the model-visible messages together with their source entries. Omitted targets produce no message; replacements retain the source entry's role and metadata while changing only content. The raw selected entries are not modified.
|
|
384
|
+
|
|
385
|
+
`buildSessionContext()` builds on that projection to produce the message list for the LLM:
|
|
333
386
|
|
|
334
387
|
1. Extracts current model and thinking level settings from the full path
|
|
335
388
|
2. Converts selected entries to messages:
|
|
336
389
|
- `message` -> stored `AgentMessage`
|
|
337
|
-
- `compaction` ->
|
|
390
|
+
- `compaction` -> complete system checkpoint followed by `compactionSummary`
|
|
338
391
|
- `branch_summary` -> `branchSummary`
|
|
339
392
|
- `custom_message` -> `CustomMessage`
|
|
340
|
-
- `
|
|
393
|
+
- `context_edit` -> no context message of its own
|
|
394
|
+
- `usage` and `custom` -> no context message
|
|
341
395
|
|
|
342
|
-
|
|
396
|
+
The compaction summary replaces entries before `firstKeptEntryId`. Pre-compaction system messages are folded into the complete checkpoint rather than replayed from the retained range. Retained non-system entries and all entries after the compaction remain available to the LLM.
|
|
343
397
|
|
|
344
398
|
## Parsing Example
|
|
345
399
|
|
|
@@ -364,6 +418,9 @@ for (const line of lines) {
|
|
|
364
418
|
case "branch_summary":
|
|
365
419
|
console.log(`[${entry.id}] Branch from ${entry.fromId}`);
|
|
366
420
|
break;
|
|
421
|
+
case "usage":
|
|
422
|
+
console.log(`[${entry.id}] Usage (${entry.kind}): ${entry.usage.totalTokens} tokens`);
|
|
423
|
+
break;
|
|
367
424
|
case "custom":
|
|
368
425
|
console.log(`[${entry.id}] Custom (${entry.customType}): ${JSON.stringify(entry.data)}`);
|
|
369
426
|
break;
|
|
@@ -382,57 +439,3 @@ for (const line of lines) {
|
|
|
382
439
|
}
|
|
383
440
|
}
|
|
384
441
|
```
|
|
385
|
-
|
|
386
|
-
## SessionManager API
|
|
387
|
-
|
|
388
|
-
Key methods for working with sessions programmatically.
|
|
389
|
-
|
|
390
|
-
### Static Creation Methods
|
|
391
|
-
- `SessionManager.create(cwd, sessionDir?)` - New session
|
|
392
|
-
- `SessionManager.open(path, sessionDir?)` - Open existing session file
|
|
393
|
-
- `SessionManager.continueRecent(cwd, sessionDir?)` - Continue most recent or create new
|
|
394
|
-
- `SessionManager.inMemory(cwd?)` - No file persistence
|
|
395
|
-
- `SessionManager.forkFrom(sourcePath, targetCwd, sessionDir?)` - Fork session from another project
|
|
396
|
-
|
|
397
|
-
### Static Listing Methods
|
|
398
|
-
- `SessionManager.list(cwd, sessionDir?, onProgress?)` - List sessions for a directory
|
|
399
|
-
- `SessionManager.listAll(onProgress?)` - List all sessions across all projects
|
|
400
|
-
|
|
401
|
-
### Instance Methods - Session Management
|
|
402
|
-
- `newSession(options?)` - Start a new session (options: `{ parentSession?: string }`)
|
|
403
|
-
- `setSessionFile(path)` - Switch to a different session file
|
|
404
|
-
- `createBranchedSession(leafId)` - Extract branch to new session file
|
|
405
|
-
|
|
406
|
-
### Instance Methods - Appending (all return entry ID)
|
|
407
|
-
- `appendMessage(message)` - Add message
|
|
408
|
-
- `appendThinkingLevelChange(level)` - Record thinking change
|
|
409
|
-
- `appendModelChange(provider, modelId)` - Record model change
|
|
410
|
-
- `appendCompaction(summary, firstKeptEntryId, tokensBefore, details?, fromHook?)` - Add compaction
|
|
411
|
-
- `appendCustomEntry(customType, data?)` - Extension state (not in context)
|
|
412
|
-
- `appendSessionInfo(name)` - Set session display name
|
|
413
|
-
- `appendCustomMessageEntry(customType, content, display, details?)` - Extension message (in context)
|
|
414
|
-
- `appendLabelChange(targetId, label)` - Set/clear label
|
|
415
|
-
|
|
416
|
-
### Instance Methods - Tree Navigation
|
|
417
|
-
- `getLeafId()` - Current position
|
|
418
|
-
- `getLeafEntry()` - Get current leaf entry
|
|
419
|
-
- `getEntry(id)` - Get entry by ID
|
|
420
|
-
- `getBranch(fromId?)` - Walk from entry to root
|
|
421
|
-
- `getTree()` - Get full tree structure
|
|
422
|
-
- `getChildren(parentId)` - Get direct children
|
|
423
|
-
- `getLabel(id)` - Get label for entry
|
|
424
|
-
- `branch(entryId)` - Move leaf to earlier entry
|
|
425
|
-
- `resetLeaf()` - Reset leaf to null (before any entries)
|
|
426
|
-
- `branchWithSummary(entryId, summary, details?, fromHook?)` - Branch with context summary
|
|
427
|
-
|
|
428
|
-
### Instance Methods - Context & Info
|
|
429
|
-
- `buildContextEntries()` - Get active branch entries with compaction applied
|
|
430
|
-
- `buildSessionContext()` - Get messages, thinkingLevel, and model for LLM
|
|
431
|
-
- `getEntries()` - All entries (excluding header)
|
|
432
|
-
- `getHeader()` - Session header metadata
|
|
433
|
-
- `getSessionName()` - Get display name from latest session_info entry
|
|
434
|
-
- `getCwd()` - Working directory
|
|
435
|
-
- `getSessionDir()` - Session storage directory
|
|
436
|
-
- `getSessionId()` - Session UUID
|
|
437
|
-
- `getSessionFile()` - Session file path (undefined for in-memory)
|
|
438
|
-
- `isPersisted()` - Whether session is saved to disk
|
package/docs/sessions.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Sessions
|
|
1
|
+
# Sessions and Context
|
|
2
2
|
|
|
3
3
|
Apex Code saves conversations as sessions so you can continue work, branch from earlier turns, and revisit previous paths.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Continue or switch sessions
|
|
6
6
|
|
|
7
7
|
Sessions auto-save to `~/.apex-code/agent/sessions/`, organized by working directory. Each session is a JSONL file with a tree structure.
|
|
8
8
|
|
|
@@ -15,49 +15,31 @@ apex-code --session <path|id> # Use a specific session file or partial session I
|
|
|
15
15
|
apex-code --fork <path|id> # Fork a session file or partial session ID into a new session
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
`--continue` opens the most recent session for the current working directory. `--resume` opens the session picker. In interactive mode, `/resume` opens the same picker and `/new` starts a new session.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Use `/name` or `--name` to assign a recognizable session name. Run `/session` to verify the current session file, ID, message count, token usage, and cost.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
The session picker lets you search, rename, and delete sessions. It can also show paths, change sorting, and limit results to named sessions. See [Keybindings](keybindings.md#sessions) for its shortcuts.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|---------|-------------|
|
|
26
|
-
| `/resume` | Browse and select previous sessions |
|
|
27
|
-
| `/new` | Start a new session |
|
|
28
|
-
| `/name <name>` | Set the current session display name |
|
|
29
|
-
| `/session` | Show session info |
|
|
30
|
-
| `/tree` | Navigate the current session tree |
|
|
31
|
-
| `/fork` | Create a new session from a previous user message |
|
|
32
|
-
| `/clone` | Duplicate the current active branch into a new session |
|
|
33
|
-
| `/compact [prompt]` | Summarize older context; see [Compaction](compaction.md) |
|
|
34
|
-
| `/export [file]` | Export session to HTML |
|
|
35
|
-
| `/share` | Upload as private GitHub gist with shareable HTML link |
|
|
24
|
+
## Choose how to branch
|
|
36
25
|
|
|
37
|
-
|
|
26
|
+
Apex Code stores entries as a tree, so returning to an earlier point does not erase the branch you leave.
|
|
38
27
|
|
|
39
28
|
`/resume` opens an interactive session picker for the current project. `apex-code -r` opens the same picker at startup.
|
|
40
29
|
|
|
41
|
-
In the
|
|
30
|
+
In `/tree`, select a user message to put its text back in the editor. Edit and submit it to create another branch. Selecting an assistant response or another entry continues after that entry with an empty editor.
|
|
42
31
|
|
|
43
|
-
|
|
44
|
-
- toggle path display with Ctrl+P
|
|
45
|
-
- toggle sort mode with Ctrl+S
|
|
46
|
-
- filter to named sessions with Ctrl+N
|
|
47
|
-
- rename with Ctrl+R
|
|
48
|
-
- delete with Ctrl+D, then confirm
|
|
32
|
+
When you leave a branch, Apex Code can summarize it and attach that summary to the branch you enter. This preserves relevant work from the abandoned path without including every message from it.
|
|
49
33
|
|
|
50
34
|
When available, Apex Code uses the `trash` CLI for deletion instead of permanently removing files.
|
|
51
35
|
|
|
52
|
-
##
|
|
36
|
+
## Manage conversation context
|
|
53
37
|
|
|
54
|
-
|
|
38
|
+
The model receives the active branch, not every branch in the session file. Apex Code combines that history with the system prompt, discovered context files, available tools, and loaded skill descriptions. [How Apex Code Works](how-pi-works.md#context) describes how those inputs are assembled.
|
|
55
39
|
|
|
56
|
-
|
|
57
|
-
/name Refactor auth module
|
|
58
|
-
```
|
|
40
|
+
The footer shows current context usage. When the active context approaches the model's limit, Apex Code normally compacts older history automatically. Compaction adds a summary and keeps recent messages. It does not delete the original session entries.
|
|
59
41
|
|
|
60
|
-
|
|
42
|
+
Run `/compact` to compact manually. You can add instructions when the summary should preserve a particular topic or decision. Configure automatic compaction and retained history through [Settings](settings.md#compaction).
|
|
61
43
|
|
|
62
44
|
```bash
|
|
63
45
|
apex-code --name "Refactor auth module"
|
|
@@ -66,40 +48,23 @@ apex-code --name "CI audit" -p "Review this build failure"
|
|
|
66
48
|
|
|
67
49
|
Named sessions are easier to find in `/resume` and `apex-code -r`.
|
|
68
50
|
|
|
69
|
-
##
|
|
51
|
+
## Control session storage
|
|
70
52
|
|
|
71
|
-
|
|
53
|
+
By default, Apex Code stores sessions under `~/.apex-code/agent/sessions/`, grouped by working directory. Use `--session-dir`, `APEX_CODE_CODING_AGENT_SESSION_DIR`, or the `sessionDir` setting to choose another location. The CLI option has highest precedence.
|
|
72
54
|
|
|
73
|
-
|
|
55
|
+
Use `--no-session` for an ephemeral run. An ephemeral session cannot be resumed after Apex Code exits.
|
|
74
56
|
|
|
75
|
-
|
|
57
|
+
Use `--session` when you already know the session path or ID. Use `--fork` to create a new session from an existing session before interactive mode starts.
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
├─ user: "Hello, can you help..."
|
|
79
|
-
│ └─ assistant: "Of course! I can..."
|
|
80
|
-
│ ├─ user: "Let's try approach A..."
|
|
81
|
-
│ │ └─ assistant: "For approach A..."
|
|
82
|
-
│ │ └─ user: "That worked..." ← active
|
|
83
|
-
│ └─ user: "Actually, approach B..."
|
|
84
|
-
│ └─ assistant: "For approach B..."
|
|
85
|
-
```
|
|
59
|
+
## Export or share a session
|
|
86
60
|
|
|
87
|
-
|
|
61
|
+
Use `/export` to write the current session as HTML or JSONL. `/share` asks before uploading the complete HTML session to an unlisted GitHub Gist. It returns the Gist URL and adds a preview link only when `APEX_CODE_SHARE_VIEWER_URL` names a viewer.
|
|
88
62
|
|
|
89
|
-
|
|
90
|
-
|-----|--------|
|
|
91
|
-
| ↑/↓ | Navigate visible entries |
|
|
92
|
-
| ←/→ | Page up/down |
|
|
93
|
-
| Ctrl+←/Ctrl+→ or Alt+←/Alt+→ | Fold/unfold or jump between branch segments |
|
|
94
|
-
| Shift+L | Set or clear a label on the selected entry |
|
|
95
|
-
| Shift+T | Toggle label timestamps |
|
|
96
|
-
| Enter | Select entry |
|
|
97
|
-
| Escape/Ctrl+C | Cancel |
|
|
98
|
-
| Ctrl+O | Cycle filter mode |
|
|
63
|
+
Review exported or shared sessions first. They can contain prompts, model responses, tool arguments, command output, file contents, and extension messages.
|
|
99
64
|
|
|
100
|
-
|
|
65
|
+
## Report a bug
|
|
101
66
|
|
|
102
|
-
|
|
67
|
+
Run `/bug [description]` to prepare a local ZIP report. Apex Code does not upload bug reports. You can include the session transcript, omit it, or ask the current model to summarize the problem. Review any transcript or generated summary because it can contain sensitive conversation data.
|
|
103
68
|
|
|
104
69
|
Selecting a user or custom message:
|
|
105
70
|
|
|
@@ -138,6 +103,25 @@ When prompted, choose one of:
|
|
|
138
103
|
|
|
139
104
|
See [Compaction](compaction.md) for branch summarization internals and extension hooks.
|
|
140
105
|
|
|
106
|
+
## Reporting Bugs
|
|
107
|
+
|
|
108
|
+
`/bug [description]` writes a ZIP archive in the current directory. The dialog asks whether to include the session transcript. If you decline, Apex Code can ask the current model to summarize the problem; that sends the conversation to your configured provider, and only the summary is attached to the archive.
|
|
109
|
+
|
|
110
|
+
Both contain the same files:
|
|
111
|
+
|
|
112
|
+
| File | Content |
|
|
113
|
+
|------|---------|
|
|
114
|
+
| `report.json` | Apex Code version, runtime, OS, terminal, current model and provider configuration, loaded extensions, and settings. API keys, header values, URL credentials, and the analytics tracking id are never included. |
|
|
115
|
+
| `diagnostics.json` | Provider and runtime error diagnostics attached to assistant messages across the whole session (failed or aborted turns, retries, error messages), plus any recorded crashes. Always included; message content is not. |
|
|
116
|
+
| `session.jsonl` | The current branch of the session, only when you chose to include it. It contains file contents and command output read during the session. |
|
|
117
|
+
| `summary.md` | The model-written summary, only when you chose to generate one. |
|
|
118
|
+
|
|
119
|
+
Each report has a UUID. Apex Code shows it after export and records it in the session as an `apex-code.bug-report` entry.
|
|
120
|
+
|
|
121
|
+
### Crashes
|
|
122
|
+
|
|
123
|
+
When Apex Code exits because of an uncaught exception or fatal runtime error, it stores the error message and stack trace in `~/.apex-code/agent/crashes.json` (the newest five). The next interactive start shows a warning once; running `/bug` can include stored crashes in the local ZIP export. Resume the crashed session with `apex-code -r` first if you want the transcript in the report.
|
|
124
|
+
|
|
141
125
|
## Session Format
|
|
142
126
|
|
|
143
127
|
Session files are JSONL and contain message entries, model changes, thinking-level changes, labels, compactions, branch summaries, and extension entries.
|