@bastani/atomic 0.8.27 → 0.8.28-alpha.2
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 +75 -0
- package/README.md +120 -118
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +2 -2
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +22 -0
- package/dist/builtin/workflows/README.md +11 -9
- package/dist/builtin/workflows/builtin/open-claude-design.ts +150 -13
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +5 -2
- package/dist/builtin/workflows/src/extension/background-ui-adapter.ts +3 -1
- package/dist/builtin/workflows/src/extension/hil-answer-notifications.ts +17 -25
- package/dist/builtin/workflows/src/extension/index.ts +133 -18
- package/dist/builtin/workflows/src/extension/render-result.ts +22 -2
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +3 -3
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +210 -16
- package/dist/builtin/workflows/src/sdk-surface.ts +1 -1
- package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +42 -5
- package/dist/builtin/workflows/src/shared/store-types.ts +8 -2
- package/dist/builtin/workflows/src/shared/store.ts +51 -0
- package/dist/builtin/workflows/src/shared/types.ts +14 -4
- package/dist/builtin/workflows/src/tui/chat-surface.ts +32 -33
- package/dist/builtin/workflows/src/tui/graph-view.ts +4 -1
- package/dist/builtin/workflows/src/tui/prompt-card.ts +6 -0
- package/dist/builtin/workflows/src/tui/run-detail.ts +11 -4
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +11 -1
- package/dist/builtin/workflows/src/tui/status-list.ts +32 -2
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +35 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/project-trust.d.ts +10 -0
- package/dist/cli/project-trust.d.ts.map +1 -0
- package/dist/cli/project-trust.js +36 -0
- package/dist/cli/project-trust.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +7 -0
- package/dist/cli/startup-ui.d.ts.map +1 -0
- package/dist/cli/startup-ui.js +57 -0
- package/dist/cli/startup-ui.js.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +24 -3
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +3 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +1 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +2 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +9 -5
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +205 -51
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts +10 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js +26 -1
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -3
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +5 -3
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +16 -10
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +4 -84
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -502
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-compaction.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction.js +39 -82
- package/dist/core/compaction/context-compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +1 -1
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -1
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +1 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/experimental.d.ts +2 -0
- package/dist/core/experimental.d.ts.map +1 -0
- package/dist/core/experimental.js +5 -0
- package/dist/core/experimental.js.map +1 -0
- package/dist/core/export-html/template.js +19 -6
- 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/loader.d.ts +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +6 -4
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +11 -4
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +53 -3
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +44 -12
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +2 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +27 -1
- package/dist/core/footer-data-provider.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 +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/messages.d.ts +1 -11
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +10 -25
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +64 -7
- 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 +1 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/output-guard.d.ts +1 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +52 -22
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +20 -8
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/project-trust.d.ts +15 -0
- package/dist/core/project-trust.d.ts.map +1 -0
- package/dist/core/project-trust.js +58 -0
- package/dist/core/project-trust.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +5 -4
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +30 -29
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.d.ts +4 -0
- package/dist/core/provider-attribution.d.ts.map +1 -0
- package/dist/core/provider-attribution.js +73 -0
- package/dist/core/provider-attribution.js.map +1 -0
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +3 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts +9 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +134 -11
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts +12 -2
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +108 -18
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +12 -42
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +11 -15
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +111 -111
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +15 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +69 -14
- package/dist/core/settings-manager.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.map +1 -1
- package/dist/core/system-prompt.js +0 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +7 -10
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/oversized-tool-result.d.ts +53 -0
- package/dist/core/tools/oversized-tool-result.d.ts.map +1 -0
- package/dist/core/tools/oversized-tool-result.js +206 -0
- package/dist/core/tools/oversized-tool-result.js.map +1 -0
- package/dist/core/tools/read.d.ts +12 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +99 -34
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +6 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +17 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +6 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/tool-limits.d.ts +25 -0
- package/dist/core/tools/tool-limits.d.ts.map +1 -0
- package/dist/core/tools/tool-limits.js +25 -0
- package/dist/core/tools/tool-limits.js.map +1 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts +31 -0
- package/dist/core/trust-manager.d.ts.map +1 -0
- package/dist/core/trust-manager.js +196 -0
- package/dist/core/trust-manager.js.map +1 -0
- package/dist/index.d.ts +12 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +142 -30
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +3 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +325 -7
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +2 -2
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -5
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +5 -9
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +0 -3
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +6 -0
- 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 +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +9 -16
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +20 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +22 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/trust-selector.js +85 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +9 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +134 -36
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +10 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +1 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +4 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +52 -8
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +24 -5
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +1 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +6 -2
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +104 -10
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/changelog.d.ts +1 -0
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +72 -0
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +54 -22
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/docs/compaction.md +210 -181
- package/docs/containerization.md +111 -0
- package/docs/custom-provider.md +9 -9
- package/docs/development.md +1 -1
- package/docs/docs.json +2 -0
- package/docs/extensions.md +71 -24
- package/docs/index.md +2 -0
- package/docs/json.md +3 -4
- package/docs/models.md +10 -10
- package/docs/packages.md +1 -1
- package/docs/prompt-templates.md +9 -2
- package/docs/providers.md +18 -5
- package/docs/quickstart.md +1 -0
- package/docs/rpc.md +3 -2
- package/docs/sdk.md +5 -0
- package/docs/security.md +56 -0
- package/docs/session-format.md +14 -23
- package/docs/sessions.md +11 -1
- package/docs/settings.md +23 -9
- package/docs/skills.md +1 -1
- package/docs/terminal-setup.md +44 -2
- package/docs/themes.md +1 -1
- package/docs/tmux.md +4 -2
- package/docs/tui.md +14 -5
- package/docs/usage.md +17 -3
- package/docs/workflows.md +11 -9
- package/examples/README.md +1 -1
- package/examples/extensions/README.md +9 -6
- package/examples/extensions/bash-spawn-hook.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +1 -1
- package/examples/extensions/claude-rules.ts +1 -1
- package/examples/extensions/commands.ts +1 -1
- package/examples/extensions/custom-compaction.ts +43 -106
- package/examples/extensions/custom-header.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +3 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
- package/examples/extensions/custom-provider-anthropic/package.json +6 -6
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +55 -4
- package/examples/extensions/custom-provider-gitlab-duo/package.json +3 -3
- package/examples/extensions/doom-overlay/README.md +1 -1
- package/examples/extensions/doom-overlay/index.ts +2 -2
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/gondolin/index.ts +523 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +7 -45
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/inline-bash.ts +2 -2
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/input-transform.ts +3 -3
- package/examples/extensions/interactive-shell.ts +2 -2
- package/examples/extensions/mac-system-theme.ts +2 -2
- package/examples/extensions/minimal-mode.ts +1 -1
- package/examples/extensions/modal-editor.ts +1 -1
- package/examples/extensions/model-status.ts +1 -1
- package/examples/extensions/overlay-qa-tests.ts +198 -179
- package/examples/extensions/overlay-test.ts +1 -1
- package/examples/extensions/pirate.ts +1 -1
- package/examples/extensions/preset.ts +14 -12
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +1 -1
- package/examples/extensions/qna.ts +1 -1
- package/examples/extensions/question.ts +1 -1
- package/examples/extensions/questionnaire.ts +1 -1
- package/examples/extensions/rainbow-editor.ts +1 -1
- package/examples/extensions/sandbox/index.ts +16 -14
- package/examples/extensions/sandbox/package-lock.json +90 -90
- package/examples/extensions/sandbox/package.json +17 -17
- package/examples/extensions/snake.ts +1 -1
- package/examples/extensions/space-invaders.ts +1 -1
- package/examples/extensions/ssh.ts +2 -2
- package/examples/extensions/subagent/README.md +13 -13
- package/examples/extensions/subagent/agents.ts +4 -2
- package/examples/extensions/subagent/index.ts +6 -6
- package/examples/extensions/summarize.ts +1 -1
- package/examples/extensions/tic-tac-toe.ts +1 -1
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/todo.ts +1 -1
- package/examples/extensions/tool-override.ts +1 -1
- package/examples/extensions/tools.ts +6 -1
- package/examples/extensions/trigger-compact.ts +5 -4
- package/examples/extensions/with-deps/package-lock.json +4 -4
- package/examples/extensions/with-deps/package.json +7 -7
- package/examples/extensions/working-indicator.ts +4 -4
- package/examples/extensions/working-message-test.ts +1 -1
- package/examples/sdk/01-minimal.ts +1 -1
- package/examples/sdk/03-custom-prompt.ts +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/examples/sdk/06-extensions.ts +2 -2
- package/examples/sdk/08-prompt-templates.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +2 -2
- package/examples/sdk/README.md +2 -2
- package/package.json +8 -8
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +0 -43
- package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
package/docs/compaction.md
CHANGED
|
@@ -1,32 +1,54 @@
|
|
|
1
1
|
# Compaction & Branch Summarization
|
|
2
2
|
|
|
3
|
-
LLMs have limited context windows. When conversations grow too long, Atomic's
|
|
3
|
+
LLMs have limited context windows. When conversations grow too long, Atomic's compaction behavior uses **Verbatim Compaction**: it deletes safe older transcript objects while preserving every retained object exactly as it was recorded. This page covers default auto/manual compaction, how it compares to the retired legacy summary compaction, and branch summarization.
|
|
4
4
|
|
|
5
|
-
Atomic's
|
|
5
|
+
Atomic's compaction design and terminology are informed by Morph's Context Compaction work: [Morph's Context Compaction](https://www.morphllm.com/context-compaction). Atomic follows the same core idea that coding agents often benefit more from deleting low-signal context than from rewriting high-signal details like file paths, line numbers, commands, and error strings into a lossy summary.
|
|
6
6
|
|
|
7
7
|
**Source files** ([atomic](https://github.com/bastani-inc/atomic)):
|
|
8
8
|
|
|
9
9
|
- [`packages/coding-agent/src/core/compaction/context-compaction.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/context-compaction.ts) - Verbatim Compaction planner, transcript tools, validation, and prompt
|
|
10
|
-
- [`packages/coding-agent/src/core/compaction/compaction.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) - Legacy summary compaction logic and shared threshold helpers
|
|
11
10
|
- [`packages/coding-agent/src/core/compaction/branch-summarization.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts) - Branch summarization
|
|
12
11
|
- [`packages/coding-agent/src/core/compaction/utils.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/utils.ts) - Shared utilities (file tracking, serialization)
|
|
13
|
-
- [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/session-manager.ts) - Entry types (`ContextCompactionEntry`, `
|
|
12
|
+
- [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/session-manager.ts) - Entry types (`ContextCompactionEntry`, `BranchSummaryEntry`) and active-context rebuild logic
|
|
14
13
|
- [`packages/coding-agent/src/core/extensions/types.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/extensions/types.ts) - Extension event types
|
|
15
14
|
|
|
16
15
|
For TypeScript definitions in your project, inspect `node_modules/@bastani/atomic/dist/`.
|
|
17
16
|
|
|
18
17
|
## Overview
|
|
19
18
|
|
|
20
|
-
Atomic has
|
|
19
|
+
Atomic has one context compaction behavior and one separate branch-summarization mechanism:
|
|
21
20
|
|
|
22
21
|
| Mechanism | Trigger | Purpose |
|
|
23
22
|
|-----------|---------|---------|
|
|
24
|
-
| Verbatim Compaction (
|
|
25
|
-
| Summary compaction internals | Legacy core APIs and legacy extension hooks | Summarize old messages into replacement context |
|
|
23
|
+
| Verbatim Compaction (context compaction) | Context exceeds threshold, context overflow, or `/compact` | Delete safe old transcript entries/content blocks while retaining surviving content verbatim |
|
|
26
24
|
| Branch summarization | `/tree` navigation | Preserve useful context when switching branches |
|
|
27
25
|
|
|
26
|
+
Summary compaction — the earlier behavior that generated replacement prose — has been removed as an active runtime path. Historical JSONL lines with `type:"compaction"` remain readable on disk but are not injected into active LLM context. See [Legacy Summary Compaction (Retired)](#legacy-summary-compaction-retired) for a comparison and historical reference.
|
|
27
|
+
|
|
28
28
|
`/compact` has no user-facing arguments. It uses a fixed internal prompt, transcript-bound inspection/deletion tools, local validation, and a `context_compaction` session entry. Auto-compaction uses the same deletion-only path.
|
|
29
29
|
|
|
30
|
+
## Verbatim vs. Summary Compaction
|
|
31
|
+
|
|
32
|
+
Atomic uses Verbatim Compaction as its sole compaction strategy. The following comparison explains why, and documents what legacy summary compaction used to do.
|
|
33
|
+
|
|
34
|
+
| Property | Verbatim Compaction | Summary Compaction (retired) |
|
|
35
|
+
|----------|---------------------|------------------------------|
|
|
36
|
+
| Mechanism | Deletes entries/content blocks | Rewrites earlier context into new prose |
|
|
37
|
+
| Surviving content | Exact original transcript content | Generated summary text |
|
|
38
|
+
| File paths / commands / errors | Kept exact or deleted | Can be paraphrased or omitted |
|
|
39
|
+
| Line numbers and stack traces | Kept exact or deleted | Can be distorted in summary |
|
|
40
|
+
| Auditability | Deleted targets are listed and inspectable | Omission/paraphrase is hard to audit |
|
|
41
|
+
| Recoverability | Pre-compaction backup snapshot; deleted targets listed in entry | Generated summary cannot be losslessly reversed |
|
|
42
|
+
| Failure mode | Needed context may be deleted (mitigated by validation and backups) | Needed context may be silently distorted |
|
|
43
|
+
| Atomic end state | **Canonical behavior** | **Removed runtime behavior** |
|
|
44
|
+
|
|
45
|
+
Coding agents depend on exact file paths (`src/foo.ts:42`), exact commands (`npm run build`), exact error strings, and exact line numbers. A generated summary that says "an error occurred in the auth module" instead of recording the actual stack trace loses irreplaceable information. Deletion is honest: what remains is unchanged, and what was deleted is listed in an inspectable `context_compaction` entry.
|
|
46
|
+
|
|
47
|
+
Deletion can still lose needed context. Atomic mitigates this with:
|
|
48
|
+
- **Local validation**: Protected entries (user tasks, recent context, unresolved errors, failed commands) cannot be deleted in standard mode.
|
|
49
|
+
- **Pre-compaction backups**: A `.compact.bak` snapshot is written before each compaction for persisted sessions.
|
|
50
|
+
- **Auditable targets**: The `context_compaction` entry records every deleted entry/content-block ID.
|
|
51
|
+
|
|
30
52
|
## Default Context Compaction (Verbatim Compaction)
|
|
31
53
|
|
|
32
54
|
### What "Verbatim" Means
|
|
@@ -36,7 +58,7 @@ Verbatim Compaction never asks a model to rewrite the conversation for the main
|
|
|
36
58
|
- **Whole entries** such as an old assistant message or obsolete tool result.
|
|
37
59
|
- **Individual content blocks** inside a multi-block message, such as one stale tool call block while keeping other blocks.
|
|
38
60
|
|
|
39
|
-
Atomic records those targets in an append-only `context_compaction` entry. When the active branch is rebuilt, Atomic filters the targeted objects out and reuses every retained entry/content block unchanged. There is no generated summary, no paraphrasing, and no replacement message inserted
|
|
61
|
+
Atomic records those targets in an append-only `context_compaction` entry. When the active branch is rebuilt, Atomic filters the targeted objects out and reuses every retained entry/content block unchanged. There is no generated summary, no paraphrasing, and no replacement message inserted.
|
|
40
62
|
|
|
41
63
|
The raw session JSONL remains append-only. Deleted objects stay available in the stored session file and backup snapshot; they are only omitted from future active LLM context on that branch.
|
|
42
64
|
|
|
@@ -50,11 +72,34 @@ contextTokens > contextWindow - reserveTokens
|
|
|
50
72
|
|
|
51
73
|
By default, `reserveTokens` is 16384 tokens. Configure it in `~/.atomic/agent/settings.json` or `<project-dir>/.atomic/settings.json`; legacy `.pi` paths are also supported. This leaves room for the LLM's response.
|
|
52
74
|
|
|
53
|
-
You can also trigger compaction manually with `/compact`. Custom summary instructions are
|
|
75
|
+
You can also trigger compaction manually with `/compact`. Custom summary instructions are not accepted because Verbatim Compaction is deletion-only and retained transcript content stays verbatim.
|
|
54
76
|
|
|
55
77
|
### How It Works
|
|
56
78
|
|
|
57
|
-
|
|
79
|
+
```mermaid
|
|
80
|
+
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#f8f9fa','primaryTextColor':'#2c3e50','primaryBorderColor':'#4a5568','lineColor':'#4a90e2','secondaryColor':'#ffffff','tertiaryColor':'#e9ecef'}}}%%
|
|
81
|
+
flowchart TD
|
|
82
|
+
A["🗣 /compact · auto-threshold · auto-overflow"]
|
|
83
|
+
B["collect active branch context\napply prior context_compaction deletions"]
|
|
84
|
+
C["build compactable transcript\n(entry IDs · roles · token estimates · text)"]
|
|
85
|
+
D["mark protected context\n(user tasks · recent 5 entries · errors · failed commands)"]
|
|
86
|
+
E["write temporary transcript file\nsend manifest to planner"]
|
|
87
|
+
F["internal deletion planner\nfixed prompt · lowest thinking level"]
|
|
88
|
+
G["transcript-bound tools\ncontext_search · context_read · context_delete · context_grep_delete"]
|
|
89
|
+
H["validateContextDeletionRequest()\nlocal airlock: unknown · protected · orphaning · empty checks"]
|
|
90
|
+
I["write pre-compaction backup snapshot"]
|
|
91
|
+
J["appendContextCompaction()\ndeletedTargets · protectedEntryIds · stats · backupPath"]
|
|
92
|
+
K["buildSessionContext()\nfilter deleted targets · reuse survivors verbatim"]
|
|
93
|
+
L["emit session_compact event\nContextCompactionResult · contextCompactionEntry"]
|
|
94
|
+
|
|
95
|
+
A --> B --> C --> D --> E --> F
|
|
96
|
+
F <--> G
|
|
97
|
+
G --> H
|
|
98
|
+
H -->|validated| I --> J --> K --> L
|
|
99
|
+
H -->|rejected| F
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
1. **Collect active branch context.** Atomic walks the current session branch and applies any earlier `context_compaction` logical deletions.
|
|
58
103
|
2. **Build a compactable transcript.** Each compactable entry includes a stable `entryId`, role, token estimate, full text, content-block indexes, tool-call IDs, and tool-result links.
|
|
59
104
|
3. **Mark protected context.** Standard compaction protects user instructions, custom messages, branch/summary messages, the last five context-eligible entries, unresolved assistant/tool errors, and failed bash executions.
|
|
60
105
|
4. **Write a temporary transcript file.** The compaction assistant receives a compact manifest plus the path to a JSONL transcript file. It should inspect with tools instead of loading the whole transcript into prompt context.
|
|
@@ -82,7 +127,7 @@ Tool calls are cumulative during one compaction run. The assistant can apply sev
|
|
|
82
127
|
In standard mode, Atomic protects:
|
|
83
128
|
|
|
84
129
|
- User messages and user-provided task context.
|
|
85
|
-
- Custom messages, branch summaries, and
|
|
130
|
+
- Custom messages, branch summaries, and branch-summary context.
|
|
86
131
|
- The last five context-eligible entries on the active branch.
|
|
87
132
|
- Assistant messages whose stop reason is an error.
|
|
88
133
|
- Tool results marked as errors.
|
|
@@ -172,111 +217,80 @@ No generated summary is inserted. Every surviving entry/content block is reused
|
|
|
172
217
|
verbatim; deleted objects are simply omitted from the active LLM context.
|
|
173
218
|
```
|
|
174
219
|
|
|
175
|
-
##
|
|
220
|
+
## Extension Hooks for Compaction
|
|
176
221
|
|
|
177
|
-
|
|
222
|
+
Extensions can observe, cancel, or contribute exact deletion targets to the compaction pipeline. They cannot provide generated summaries.
|
|
178
223
|
|
|
179
|
-
|
|
180
|
-
Before summary compaction:
|
|
224
|
+
### session_before_compact
|
|
181
225
|
|
|
182
|
-
|
|
183
|
-
┌─────┬─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┐
|
|
184
|
-
│ hdr │ usr │ ass │ tool │ usr │ ass │ tool │ tool │ ass │ tool│
|
|
185
|
-
└─────┴─────┴─────┴──────┴─────┴─────┴──────┴──────┴─────┴─────┘
|
|
186
|
-
└────────┬───────┘ └──────────────┬──────────────┘
|
|
187
|
-
messagesToSummarize kept messages
|
|
188
|
-
↑
|
|
189
|
-
firstKeptEntryId (entry 4)
|
|
226
|
+
Fired before the internal deletion planner runs. Extensions can cancel compaction or provide their own validated deletion request.
|
|
190
227
|
|
|
191
|
-
|
|
228
|
+
```typescript
|
|
229
|
+
pi.on("session_before_compact", async (event, ctx) => {
|
|
230
|
+
const { preparation, branchEntries, reason, mode, signal } = event;
|
|
192
231
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
↑
|
|
200
|
-
starts from firstKeptEntryId
|
|
232
|
+
// preparation.transcript.entries - entries eligible for deletion
|
|
233
|
+
// preparation.transcript.protectedEntryIds - entries that cannot be deleted in standard mode
|
|
234
|
+
// preparation.transcript.tokensBefore - context token estimate before compaction
|
|
235
|
+
// branchEntries - all entries on current branch
|
|
236
|
+
// reason - "manual" | "threshold" | "overflow"
|
|
237
|
+
// mode - "standard" | "critical_overflow"
|
|
201
238
|
|
|
202
|
-
|
|
239
|
+
// Cancel compaction:
|
|
240
|
+
return { cancel: true };
|
|
203
241
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
242
|
+
// Or provide a deletion request (Atomic validates it locally before persisting):
|
|
243
|
+
return {
|
|
244
|
+
deletionRequest: {
|
|
245
|
+
deletions: [
|
|
246
|
+
{ kind: "entry", entryId: "abc123" },
|
|
247
|
+
{ kind: "content_block", entryId: "def456", blockIndex: 2 },
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
});
|
|
209
252
|
```
|
|
210
253
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
### Split Turns
|
|
254
|
+
If `{ cancel: true }` is returned, compaction aborts with a cancellation error. If `{ deletionRequest }` is returned, Atomic validates it through the same local airlock as model-proposed deletions — unknown IDs, protected targets, orphaning, and empty-context plans are rejected — and skips the internal planner. If nothing is returned, the internal planner runs normally.
|
|
214
255
|
|
|
215
|
-
|
|
256
|
+
### session_compact
|
|
216
257
|
|
|
217
|
-
|
|
258
|
+
Fired after compaction succeeds and the `context_compaction` entry is persisted.
|
|
218
259
|
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
messagesToSummarize = [] (no complete turns before)
|
|
234
|
-
turnPrefixMessages = [usr, ass, tool, ass, tool, tool]
|
|
260
|
+
```typescript
|
|
261
|
+
pi.on("session_compact", async (event, ctx) => {
|
|
262
|
+
// event.result - ContextCompactionResult
|
|
263
|
+
// event.contextCompactionEntry - the saved ContextCompactionEntry
|
|
264
|
+
// event.reason - "manual" | "threshold" | "overflow"
|
|
265
|
+
// event.fromExtension - true if extension provided the deletionRequest
|
|
266
|
+
|
|
267
|
+
const { result } = event;
|
|
268
|
+
ctx.ui.notify(
|
|
269
|
+
`Compaction: deleted ${result.stats.objectsDeleted} objects, ` +
|
|
270
|
+
`${result.stats.percentReduction}% token reduction`,
|
|
271
|
+
"info",
|
|
272
|
+
);
|
|
273
|
+
});
|
|
235
274
|
```
|
|
236
275
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
1. **History summary**: Previous context (if any)
|
|
240
|
-
2. **Turn prefix summary**: The early part of the split turn
|
|
241
|
-
|
|
242
|
-
### Cut Point Rules
|
|
243
|
-
|
|
244
|
-
Valid legacy summary-compaction cut points are:
|
|
276
|
+
### ctx.compact()
|
|
245
277
|
|
|
246
|
-
|
|
247
|
-
- Assistant messages
|
|
248
|
-
- BashExecution messages
|
|
249
|
-
- Custom messages (custom_message, branch_summary)
|
|
250
|
-
|
|
251
|
-
Never cut at tool results because they must stay with their tool call.
|
|
252
|
-
|
|
253
|
-
### CompactionEntry Structure
|
|
254
|
-
|
|
255
|
-
Defined in [`session-manager.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/session-manager.ts):
|
|
278
|
+
Trigger Verbatim Compaction without awaiting completion. See [Extensions](/extensions) for full `ctx.compact()` documentation.
|
|
256
279
|
|
|
257
280
|
```typescript
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
fromHook?: boolean; // true if provided by extension (legacy field name)
|
|
267
|
-
details?: T; // implementation-specific data
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// Legacy summary compaction uses this for details (from compaction.ts):
|
|
271
|
-
interface CompactionDetails {
|
|
272
|
-
readFiles: string[];
|
|
273
|
-
modifiedFiles: string[];
|
|
274
|
-
}
|
|
281
|
+
ctx.compact({
|
|
282
|
+
onComplete: (result) => {
|
|
283
|
+
ctx.ui.notify(`Compacted: deleted ${result.stats.objectsDeleted} objects`, "info");
|
|
284
|
+
},
|
|
285
|
+
onError: (error) => {
|
|
286
|
+
ctx.ui.notify(`Compaction failed: ${error.message}`, "error");
|
|
287
|
+
},
|
|
288
|
+
});
|
|
275
289
|
```
|
|
276
290
|
|
|
277
|
-
|
|
291
|
+
`ctx.compact()` does not accept custom instructions. Verbatim Compaction uses a fixed internal prompt; no custom summary text can be injected.
|
|
278
292
|
|
|
279
|
-
See [
|
|
293
|
+
See [examples/extensions/trigger-compact.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/trigger-compact.ts) for a full example.
|
|
280
294
|
|
|
281
295
|
## Branch Summarization
|
|
282
296
|
|
|
@@ -284,6 +298,8 @@ See [`prepareCompaction()`](https://github.com/bastani-inc/atomic/blob/main/pack
|
|
|
284
298
|
|
|
285
299
|
When you use `/tree` to navigate to a different branch, Atomic offers to summarize the work you're leaving. This injects context from the left branch into the new branch.
|
|
286
300
|
|
|
301
|
+
Branch summarization is a separate mechanism from context compaction. It generates a summary of the abandoned branch path and injects it into the new branch position. This is appropriate here because the alternative (losing branch context entirely on navigation) is worse than a lossy summary.
|
|
302
|
+
|
|
287
303
|
### How It Works
|
|
288
304
|
|
|
289
305
|
1. **Find common ancestor**: Deepest node shared by old and new positions
|
|
@@ -292,6 +308,20 @@ When you use `/tree` to navigate to a different branch, Atomic offers to summari
|
|
|
292
308
|
4. **Generate summary**: Call LLM with structured format
|
|
293
309
|
5. **Append entry**: Save `BranchSummaryEntry` at navigation point
|
|
294
310
|
|
|
311
|
+
```mermaid
|
|
312
|
+
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#f8f9fa','primaryTextColor':'#2c3e50','primaryBorderColor':'#4a5568','lineColor':'#4a90e2','secondaryColor':'#ffffff','tertiaryColor':'#e9ecef'}}}%%
|
|
313
|
+
flowchart TD
|
|
314
|
+
A["user navigates /tree\nold leaf → new target"]
|
|
315
|
+
B["find common ancestor"]
|
|
316
|
+
C["collect abandoned branch entries\n(old leaf → common ancestor)"]
|
|
317
|
+
D["prepare with token budget\n(newest first)"]
|
|
318
|
+
E["generate branch summary\nLLM call · structured format"]
|
|
319
|
+
F["append BranchSummaryEntry\nat common ancestor or new target"]
|
|
320
|
+
G["navigate to new target\nbranch summary context carried forward"]
|
|
321
|
+
|
|
322
|
+
A --> B --> C --> D --> E --> F --> G
|
|
323
|
+
```
|
|
324
|
+
|
|
295
325
|
```text
|
|
296
326
|
Tree before navigation:
|
|
297
327
|
|
|
@@ -311,12 +341,12 @@ After navigation with summary:
|
|
|
311
341
|
|
|
312
342
|
### Cumulative File Tracking
|
|
313
343
|
|
|
314
|
-
|
|
344
|
+
Branch summarization tracks files cumulatively. When generating a summary, Atomic extracts file operations from:
|
|
315
345
|
|
|
316
346
|
- Tool calls in the messages being summarized
|
|
317
|
-
- Previous
|
|
347
|
+
- Previous branch summary `details` (if any)
|
|
318
348
|
|
|
319
|
-
This means file tracking accumulates across
|
|
349
|
+
This means file tracking accumulates across nested branch summaries, preserving the full history of read and modified files.
|
|
320
350
|
|
|
321
351
|
### BranchSummaryEntry Structure
|
|
322
352
|
|
|
@@ -341,13 +371,13 @@ interface BranchSummaryDetails {
|
|
|
341
371
|
}
|
|
342
372
|
```
|
|
343
373
|
|
|
344
|
-
|
|
374
|
+
Extensions can store custom data in `details`.
|
|
345
375
|
|
|
346
376
|
See [`collectEntriesForBranchSummary()`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts), [`prepareBranchEntries()`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts), and [`generateBranchSummary()`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts) for the implementation.
|
|
347
377
|
|
|
348
|
-
##
|
|
378
|
+
## Branch Summary Format
|
|
349
379
|
|
|
350
|
-
|
|
380
|
+
Branch summarization uses a structured format:
|
|
351
381
|
|
|
352
382
|
```markdown
|
|
353
383
|
## Goal
|
|
@@ -385,9 +415,9 @@ path/to/changed.ts
|
|
|
385
415
|
</modified-files>
|
|
386
416
|
```
|
|
387
417
|
|
|
388
|
-
### Message Serialization
|
|
418
|
+
### Message Serialization for Branch Summaries
|
|
389
419
|
|
|
390
|
-
Before
|
|
420
|
+
Before branch summarization, messages are serialized to text via [`serializeConversation()`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/utils.ts):
|
|
391
421
|
|
|
392
422
|
```text
|
|
393
423
|
[User]: What they said
|
|
@@ -399,81 +429,9 @@ Before legacy summarization, messages are serialized to text via [`serializeConv
|
|
|
399
429
|
|
|
400
430
|
This prevents the model from treating it as a conversation to continue.
|
|
401
431
|
|
|
402
|
-
Tool results are truncated to 2000 characters during serialization. Content beyond that limit is replaced with a marker indicating how many characters were truncated.
|
|
432
|
+
Tool results are truncated to 2000 characters during serialization. Content beyond that limit is replaced with a marker indicating how many characters were truncated.
|
|
403
433
|
|
|
404
|
-
##
|
|
405
|
-
|
|
406
|
-
Extensions can still customize the legacy summary compaction pipeline and branch summarization. Default `/compact` and auto-compaction use deletion-only Verbatim Compaction and do not call summary customization hooks. See [`extensions/types.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/extensions/types.ts) for event type definitions.
|
|
407
|
-
|
|
408
|
-
### session_before_compact
|
|
409
|
-
|
|
410
|
-
Fired before legacy summary compaction. Can cancel or provide custom summary. See `SessionBeforeCompactEvent` and `CompactionPreparation` in the types file.
|
|
411
|
-
|
|
412
|
-
```typescript
|
|
413
|
-
pi.on("session_before_compact", async (event, ctx) => {
|
|
414
|
-
const { preparation, branchEntries, customInstructions, signal } = event;
|
|
415
|
-
|
|
416
|
-
// preparation.messagesToSummarize - messages to summarize
|
|
417
|
-
// preparation.turnPrefixMessages - split turn prefix (if isSplitTurn)
|
|
418
|
-
// preparation.previousSummary - previous compaction summary
|
|
419
|
-
// preparation.fileOps - extracted file operations
|
|
420
|
-
// preparation.tokensBefore - context tokens before compaction
|
|
421
|
-
// preparation.firstKeptEntryId - where kept messages start
|
|
422
|
-
// preparation.settings - compaction settings
|
|
423
|
-
|
|
424
|
-
// branchEntries - all entries on current branch (for custom state)
|
|
425
|
-
// signal - AbortSignal (pass to LLM calls)
|
|
426
|
-
|
|
427
|
-
// Cancel:
|
|
428
|
-
return { cancel: true };
|
|
429
|
-
|
|
430
|
-
// Custom summary:
|
|
431
|
-
return {
|
|
432
|
-
compaction: {
|
|
433
|
-
summary: "Your summary...",
|
|
434
|
-
firstKeptEntryId: preparation.firstKeptEntryId,
|
|
435
|
-
tokensBefore: preparation.tokensBefore,
|
|
436
|
-
details: { /* custom data */ },
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
});
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
#### Converting Messages to Text
|
|
443
|
-
|
|
444
|
-
To generate a summary with your own model, convert messages to text using `serializeConversation`:
|
|
445
|
-
|
|
446
|
-
```typescript
|
|
447
|
-
import { convertToLlm, serializeConversation } from "@bastani/atomic";
|
|
448
|
-
|
|
449
|
-
pi.on("session_before_compact", async (event, ctx) => {
|
|
450
|
-
const { preparation } = event;
|
|
451
|
-
|
|
452
|
-
// Convert AgentMessage[] to Message[], then serialize to text
|
|
453
|
-
const conversationText = serializeConversation(
|
|
454
|
-
convertToLlm(preparation.messagesToSummarize)
|
|
455
|
-
);
|
|
456
|
-
// Returns:
|
|
457
|
-
// [User]: message text
|
|
458
|
-
// [Assistant thinking]: thinking content
|
|
459
|
-
// [Assistant]: response text
|
|
460
|
-
// [Assistant tool calls]: read(path="..."); bash(command="...")
|
|
461
|
-
// [Tool result]: output text
|
|
462
|
-
|
|
463
|
-
// Now send to your model for summarization
|
|
464
|
-
const summary = await myModel.summarize(conversationText);
|
|
465
|
-
|
|
466
|
-
return {
|
|
467
|
-
compaction: {
|
|
468
|
-
summary,
|
|
469
|
-
firstKeptEntryId: preparation.firstKeptEntryId,
|
|
470
|
-
tokensBefore: preparation.tokensBefore,
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
});
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
See [custom-compaction.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/custom-compaction.ts) for a complete example using a different model.
|
|
434
|
+
## Extension Hooks for Branch Summarization
|
|
477
435
|
|
|
478
436
|
### session_before_tree
|
|
479
437
|
|
|
@@ -514,8 +472,7 @@ Configure compaction in `~/.atomic/agent/settings.json` or `<project-dir>/.atomi
|
|
|
514
472
|
{
|
|
515
473
|
"compaction": {
|
|
516
474
|
"enabled": true,
|
|
517
|
-
"reserveTokens": 16384
|
|
518
|
-
"keepRecentTokens": 20000
|
|
475
|
+
"reserveTokens": 16384
|
|
519
476
|
}
|
|
520
477
|
}
|
|
521
478
|
```
|
|
@@ -524,6 +481,78 @@ Configure compaction in `~/.atomic/agent/settings.json` or `<project-dir>/.atomi
|
|
|
524
481
|
|---------|---------|-------------|
|
|
525
482
|
| `enabled` | `true` | Enable automatic Verbatim Compaction. |
|
|
526
483
|
| `reserveTokens` | `16384` | Tokens to reserve for the next LLM response; auto-compaction starts when context usage exceeds `contextWindow - reserveTokens`. |
|
|
527
|
-
| `keepRecentTokens` | `20000` | Legacy summary-compaction retained-token budget. Default Verbatim Compaction protects recent entries structurally instead of using this as a token cut point. |
|
|
528
484
|
|
|
529
485
|
Disable auto-compaction with `"enabled": false`. You can still compact manually with `/compact`.
|
|
486
|
+
|
|
487
|
+
## Legacy Summary Compaction (Retired)
|
|
488
|
+
|
|
489
|
+
Summary compaction — an earlier behavior that generated replacement prose for older context — has been removed as an active runtime path in Atomic. This section documents it for historical reference only.
|
|
490
|
+
|
|
491
|
+
### What it did
|
|
492
|
+
|
|
493
|
+
The summary compaction pipeline:
|
|
494
|
+
1. Selected a cut point (user message boundary) called `firstKeptEntryId`.
|
|
495
|
+
2. Passed all messages before that cut point to an LLM to generate a replacement summary.
|
|
496
|
+
3. Appended a `CompactionEntry` with `type:"compaction"` to the session JSONL.
|
|
497
|
+
4. When rebuilding active context, injected a `compactionSummary` message at the boundary.
|
|
498
|
+
|
|
499
|
+
```text
|
|
500
|
+
(Historical — no longer the active behavior)
|
|
501
|
+
|
|
502
|
+
Before summary compaction:
|
|
503
|
+
|
|
504
|
+
entry: 0 1 2 3 4 5 6 7 8 9
|
|
505
|
+
┌─────┬─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┐
|
|
506
|
+
│ hdr │ usr │ ass │ tool │ usr │ ass │ tool │ tool │ ass │ tool│
|
|
507
|
+
└─────┴─────┴─────┴──────┴─────┴─────┴──────┴──────┴─────┴─────┘
|
|
508
|
+
└────────┬───────┘ └──────────────┬──────────────┘
|
|
509
|
+
messagesToSummarize kept messages
|
|
510
|
+
↑
|
|
511
|
+
firstKeptEntryId (entry 4)
|
|
512
|
+
|
|
513
|
+
After compaction (new entry appended):
|
|
514
|
+
|
|
515
|
+
entry: 0 1 2 3 4 5 6 7 8 9 10
|
|
516
|
+
┌─────┬─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┬─────┐
|
|
517
|
+
│ hdr │ usr │ ass │ tool │ usr │ ass │ tool │ tool │ ass │ tool│ cmp │
|
|
518
|
+
└─────┴─────┴─────┴──────┴─────┴─────┴──────┴──────┴─────┴─────┴─────┘
|
|
519
|
+
└──────────┬──────┘ └──────────────────────┬───────────────────┘
|
|
520
|
+
not sent to LLM sent to LLM
|
|
521
|
+
↑
|
|
522
|
+
starts from firstKeptEntryId
|
|
523
|
+
|
|
524
|
+
What the LLM saw:
|
|
525
|
+
|
|
526
|
+
┌────────┬─────────┬─────┬─────┬──────┬──────┬─────┬──────┐
|
|
527
|
+
│ system │ summary │ usr │ ass │ tool │ tool │ ass │ tool │
|
|
528
|
+
└────────┴─────────┴─────┴─────┴──────┴──────┴─────┴──────┘
|
|
529
|
+
↑ ↑ └─────────────────┬────────────────┘
|
|
530
|
+
prompt from cmp messages from firstKeptEntryId
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### Why it was removed
|
|
534
|
+
|
|
535
|
+
The core problem: a generated summary can paraphrase or omit exact file paths (`src/auth/middleware.ts:87`), commands (`npm run build -- --watch`), error strings, and line numbers. For coding agents, this loss of precision frequently causes confusion and regressions. Verbatim Compaction is honest: what remains is unchanged, and what was deleted is recorded.
|
|
536
|
+
|
|
537
|
+
See [Verbatim vs. Summary Compaction](#verbatim-vs-summary-compaction) for the full comparison.
|
|
538
|
+
|
|
539
|
+
### Historical entry types
|
|
540
|
+
|
|
541
|
+
`type:"compaction"` JSONL lines may exist in sessions created before the removal. They remain readable on disk and visible in session exports, but Atomic does not inject them as active LLM context. If you encounter sessions with these entries, they are safe to leave in place.
|
|
542
|
+
|
|
543
|
+
`type:"compaction"` entry structure (historical):
|
|
544
|
+
```typescript
|
|
545
|
+
interface CompactionEntry {
|
|
546
|
+
type: "compaction";
|
|
547
|
+
id: string;
|
|
548
|
+
parentId: string | null;
|
|
549
|
+
timestamp: string;
|
|
550
|
+
summary: string; // generated replacement prose
|
|
551
|
+
firstKeptEntryId: string; // cut point boundary
|
|
552
|
+
tokensBefore: number;
|
|
553
|
+
fromHook?: boolean;
|
|
554
|
+
details?: unknown;
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
This entry type is no longer produced by Atomic. Extension hooks that returned `{ compaction: { summary, firstKeptEntryId, tokensBefore } }` no longer have effect; update extensions to use the new `{ cancel: true }` or `{ deletionRequest }` hook returns instead.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Containerization
|
|
2
|
+
|
|
3
|
+
Atomic runs with all permissions by default, but in some cases, you will want to have more control over what directories Atomic can write to and which accesses it has.
|
|
4
|
+
|
|
5
|
+
There are two general options. You can either
|
|
6
|
+
1. run the whole `atomic` process inside an isolated environment, or
|
|
7
|
+
2. run `atomic` on the host and route tool execution into an isolated environment.
|
|
8
|
+
|
|
9
|
+
## Choose a pattern
|
|
10
|
+
|
|
11
|
+
| Pattern | What is isolated | Best for | Notes |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| OpenShell | Whole `atomic` process in a policy-controlled sandbox | Local or remote managed sandbox | Requires an OpenShell gateway |
|
|
14
|
+
| Gondolin extension | Built-in tools and `!` commands | Local micro-VM isolation while keeping auth on host | See [`examples/extensions/gondolin/`](https://github.com/bastani-inc/atomic/tree/main/packages/coding-agent/examples/extensions/gondolin). |
|
|
15
|
+
| Plain Docker | Whole `atomic` process in a local container | Simple local isolation | Provider API keys enter the container. |
|
|
16
|
+
|
|
17
|
+
Extensions run wherever the `atomic` process runs. If you run host `atomic` with a tool-routing extension, other custom extension tools still run on the host unless they also delegate their operations.
|
|
18
|
+
|
|
19
|
+
## OpenShell
|
|
20
|
+
|
|
21
|
+
Use [NVIDIA OpenShell](https://docs.nvidia.com/openshell/about/overview) when you want a policy-controlled sandbox with filesystem, process, network, credential, and inference controls.
|
|
22
|
+
OpenShell can run sandboxes through a local gateway backed by Docker, Podman, or a VM runtime, or through a remote Kubernetes gateway.
|
|
23
|
+
|
|
24
|
+
Every sandbox requires an active gateway.
|
|
25
|
+
Register and select one before creating a sandbox:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
openshell gateway add <gateway-url> --name <name>
|
|
29
|
+
openshell gateway select <name>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Launch `atomic` inside an OpenShell sandbox:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
openshell sandbox create --name atomic-sandbox --from atomic -- atomic
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
In this pattern, the whole `atomic` process runs inside the sandbox.
|
|
39
|
+
Built-in tools, `!` commands, and extension tools execute inside the OpenShell boundary.
|
|
40
|
+
|
|
41
|
+
If the gateway is remote, project files are not bind-mounted from the host, meaning writes in the sandbox are not reflected on your machine.
|
|
42
|
+
Clone the repository inside the sandbox or use OpenShell file transfer commands:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
openshell sandbox upload atomic-sandbox ./repo /workspace
|
|
46
|
+
openshell sandbox download atomic-sandbox /workspace/repo ./repo-out
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
OpenShell providers can keep raw model API keys outside the sandbox.
|
|
50
|
+
When inference routing is configured, code inside the sandbox can call `https://inference.local`, and the gateway injects the configured provider credentials upstream.
|
|
51
|
+
Configure Atomic to use the corresponding OpenAI-compatible or Anthropic-compatible endpoint if you want model traffic to use this route.
|
|
52
|
+
|
|
53
|
+
## Gondolin
|
|
54
|
+
|
|
55
|
+
[Gondolin](https://github.com/earendil-works/gondolin) is a local Linux micro-VM.
|
|
56
|
+
Use the [example extension](https://github.com/bastani-inc/atomic/tree/main/packages/coding-agent/examples/extensions/gondolin) when you want `atomic` on the host but all built-in tools routed into the VM.
|
|
57
|
+
|
|
58
|
+
Setup:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cp -R packages/coding-agent/examples/extensions/gondolin ~/.atomic/agent/extensions/gondolin
|
|
62
|
+
cd ~/.atomic/agent/extensions/gondolin
|
|
63
|
+
npm install --ignore-scripts
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Run from the project you want mounted:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cd /path/to/project
|
|
70
|
+
atomic -e ~/.atomic/agent/extensions/gondolin
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The extension mounts the host cwd at `/workspace` in the VM and overrides `read`, `write`, `edit`, `bash`, `grep`, `find`, and `ls`.
|
|
74
|
+
User `!` commands are routed into the VM, as well.
|
|
75
|
+
File changes under `/workspace` write through to the host.
|
|
76
|
+
|
|
77
|
+
Requirements: Node.js >= 23.6.0 for `@earendil-works/gondolin`, plus QEMU (requires installation through your package manager).
|
|
78
|
+
|
|
79
|
+
## Plain Docker
|
|
80
|
+
|
|
81
|
+
Run the whole `atomic` process in Docker when you want the simplest local container boundary.
|
|
82
|
+
|
|
83
|
+
`Dockerfile.atomic`:
|
|
84
|
+
|
|
85
|
+
```dockerfile
|
|
86
|
+
FROM node:24-bookworm-slim
|
|
87
|
+
|
|
88
|
+
RUN apt-get update \
|
|
89
|
+
&& apt-get install -y --no-install-recommends bash ca-certificates git ripgrep \
|
|
90
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
91
|
+
RUN npm install -g --ignore-scripts @bastani/atomic
|
|
92
|
+
|
|
93
|
+
WORKDIR /workspace
|
|
94
|
+
ENTRYPOINT ["atomic"]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Build and run:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
docker build -t atomic-sandbox -f Dockerfile.atomic .
|
|
101
|
+
|
|
102
|
+
docker run --rm -it \
|
|
103
|
+
-e ANTHROPIC_API_KEY \
|
|
104
|
+
-v "$PWD:/workspace" \
|
|
105
|
+
-v atomic-agent-home:/root/.atomic/agent \
|
|
106
|
+
atomic-sandbox
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The `-v "$PWD:/workspace"` mounts your current directory into the container at /workspace such that reads and writes in `/workspace` inside Docker directly affect your host files, like in the Gondolin example.
|
|
110
|
+
|
|
111
|
+
Use a named volume for `/root/.atomic/agent` if you want container-local settings and sessions. Mounting your host `~/.atomic/agent` exposes host auth and session files to the container.
|