@bastani/atomic 0.9.8 → 0.9.9-alpha.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.
Files changed (348) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/builtin/cursor/CHANGELOG.md +6 -0
  3. package/dist/builtin/cursor/package.json +2 -2
  4. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  5. package/dist/builtin/intercom/package.json +1 -1
  6. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  9. package/dist/builtin/subagents/package.json +1 -1
  10. package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +2 -0
  11. package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +7 -1
  12. package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +2 -0
  13. package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +8 -2
  14. package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +2 -0
  15. package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +2 -0
  16. package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +2 -1
  17. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +2 -0
  18. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
  19. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
  20. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -0
  21. package/dist/builtin/subagents/src/runs/shared/pi-args.ts +6 -0
  22. package/dist/builtin/subagents/src/shared/types-config.ts +4 -0
  23. package/dist/builtin/subagents/src/shared/types-depth.ts +29 -2
  24. package/dist/builtin/web-access/CHANGELOG.md +6 -0
  25. package/dist/builtin/web-access/package.json +1 -1
  26. package/dist/builtin/workflows/CHANGELOG.md +22 -0
  27. package/dist/builtin/workflows/README.md +17 -8
  28. package/dist/builtin/workflows/builtin/goal-prompts.ts +8 -2
  29. package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +26 -9
  30. package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +1 -1
  31. package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +8 -3
  32. package/dist/builtin/workflows/builtin/ralph-runner.ts +2 -0
  33. package/dist/builtin/workflows/builtin/shared-prompts.ts +24 -1
  34. package/dist/builtin/workflows/package.json +1 -1
  35. package/dist/builtin/workflows/src/durable/backend.ts +53 -15
  36. package/dist/builtin/workflows/src/durable/completed-catalog.ts +245 -0
  37. package/dist/builtin/workflows/src/durable/completed-inspection.ts +213 -0
  38. package/dist/builtin/workflows/src/durable/dbos-backend.ts +120 -170
  39. package/dist/builtin/workflows/src/durable/dbos-envelope.ts +84 -8
  40. package/dist/builtin/workflows/src/durable/dbos-metadata.ts +98 -0
  41. package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +27 -0
  42. package/dist/builtin/workflows/src/durable/factory.ts +1 -1
  43. package/dist/builtin/workflows/src/durable/file-backend.ts +247 -241
  44. package/dist/builtin/workflows/src/durable/file-lock.ts +153 -0
  45. package/dist/builtin/workflows/src/durable/file-state.ts +104 -0
  46. package/dist/builtin/workflows/src/durable/format-version.ts +12 -0
  47. package/dist/builtin/workflows/src/durable/index.ts +12 -0
  48. package/dist/builtin/workflows/src/durable/resume-catalog.ts +16 -27
  49. package/dist/builtin/workflows/src/durable/resume-eligibility.ts +20 -0
  50. package/dist/builtin/workflows/src/durable/resume-runtime.ts +29 -29
  51. package/dist/builtin/workflows/src/durable/scoped-backend.ts +20 -3
  52. package/dist/builtin/workflows/src/durable/stage-primitive.ts +29 -8
  53. package/dist/builtin/workflows/src/durable/types.ts +3 -0
  54. package/dist/builtin/workflows/src/engine/primitives/task.ts +1 -0
  55. package/dist/builtin/workflows/src/engine/run.ts +14 -14
  56. package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +39 -9
  57. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +10 -0
  58. package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +133 -0
  59. package/dist/builtin/workflows/src/extension/runtime.ts +15 -40
  60. package/dist/builtin/workflows/src/extension/wiring.ts +9 -6
  61. package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +226 -0
  62. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +1 -0
  63. package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +66 -112
  64. package/dist/builtin/workflows/src/extension/workflow-schema.ts +5 -5
  65. package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +16 -1
  66. package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +50 -43
  67. package/dist/builtin/workflows/src/runs/foreground/executor-direct-output.ts +91 -0
  68. package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +95 -46
  69. package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +3 -1
  70. package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +1 -1
  71. package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +3 -0
  72. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +1 -1
  73. package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +36 -7
  74. package/dist/builtin/workflows/src/runs/shared/worktree-cache-lifecycle.ts +25 -0
  75. package/dist/builtin/workflows/src/runs/shared/worktree-cwd.ts +103 -0
  76. package/dist/builtin/workflows/src/runs/shared/worktree-generation.ts +57 -0
  77. package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +134 -8
  78. package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -0
  79. package/dist/builtin/workflows/src/shared/resumable-workflow-notices.ts +43 -0
  80. package/dist/builtin/workflows/src/shared/timing.ts +4 -0
  81. package/dist/builtin/workflows/src/shared/types.ts +5 -3
  82. package/dist/builtin/workflows/src/tui/graph-view-constants.ts +1 -0
  83. package/dist/builtin/workflows/src/tui/graph-view-input.ts +24 -14
  84. package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +43 -13
  85. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  86. package/dist/core/agent-session-auto-compaction.js +5 -7
  87. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  88. package/dist/core/agent-session-compaction.d.ts +6 -34
  89. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  90. package/dist/core/agent-session-compaction.js +95 -233
  91. package/dist/core/agent-session-compaction.js.map +1 -1
  92. package/dist/core/agent-session-message-queue.d.ts +0 -4
  93. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  94. package/dist/core/agent-session-message-queue.js +1 -5
  95. package/dist/core/agent-session-message-queue.js.map +1 -1
  96. package/dist/core/agent-session-methods.d.ts +5 -6
  97. package/dist/core/agent-session-methods.d.ts.map +1 -1
  98. package/dist/core/agent-session-methods.js.map +1 -1
  99. package/dist/core/agent-session-types.d.ts +2 -12
  100. package/dist/core/agent-session-types.d.ts.map +1 -1
  101. package/dist/core/agent-session-types.js.map +1 -1
  102. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  103. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  104. package/dist/core/compaction/branch-summarization.js +1 -2
  105. package/dist/core/compaction/branch-summarization.js.map +1 -1
  106. package/dist/core/compaction/compaction-boundary.d.ts +9 -0
  107. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -0
  108. package/dist/core/compaction/compaction-boundary.js +115 -0
  109. package/dist/core/compaction/compaction-boundary.js.map +1 -0
  110. package/dist/core/compaction/compaction-parameters.d.ts +5 -0
  111. package/dist/core/compaction/compaction-parameters.d.ts.map +1 -0
  112. package/dist/core/compaction/compaction-parameters.js +27 -0
  113. package/dist/core/compaction/compaction-parameters.js.map +1 -0
  114. package/dist/core/compaction/compaction-runner.d.ts +14 -0
  115. package/dist/core/compaction/compaction-runner.d.ts.map +1 -0
  116. package/dist/core/compaction/compaction-runner.js +29 -0
  117. package/dist/core/compaction/compaction-runner.js.map +1 -0
  118. package/dist/core/compaction/compaction-types.d.ts +79 -0
  119. package/dist/core/compaction/compaction-types.d.ts.map +1 -0
  120. package/dist/core/compaction/compaction-types.js +6 -0
  121. package/dist/core/compaction/compaction-types.js.map +1 -0
  122. package/dist/core/compaction/deleted-ranges.d.ts +6 -0
  123. package/dist/core/compaction/deleted-ranges.d.ts.map +1 -0
  124. package/dist/core/compaction/deleted-ranges.js +134 -0
  125. package/dist/core/compaction/deleted-ranges.js.map +1 -0
  126. package/dist/core/compaction/index.d.ts +7 -1
  127. package/dist/core/compaction/index.d.ts.map +1 -1
  128. package/dist/core/compaction/index.js +7 -1
  129. package/dist/core/compaction/index.js.map +1 -1
  130. package/dist/core/compaction/range-planner.d.ts +21 -0
  131. package/dist/core/compaction/range-planner.d.ts.map +1 -0
  132. package/dist/core/compaction/range-planner.js +145 -0
  133. package/dist/core/compaction/range-planner.js.map +1 -0
  134. package/dist/core/compaction/transcript-serialization.d.ts +11 -0
  135. package/dist/core/compaction/transcript-serialization.d.ts.map +1 -0
  136. package/dist/core/compaction/transcript-serialization.js +104 -0
  137. package/dist/core/compaction/transcript-serialization.js.map +1 -0
  138. package/dist/core/extensions/context-types.d.ts +2 -2
  139. package/dist/core/extensions/context-types.d.ts.map +1 -1
  140. package/dist/core/extensions/context-types.js.map +1 -1
  141. package/dist/core/extensions/event-results.d.ts +2 -2
  142. package/dist/core/extensions/event-results.d.ts.map +1 -1
  143. package/dist/core/extensions/event-results.js.map +1 -1
  144. package/dist/core/extensions/session-events.d.ts +7 -7
  145. package/dist/core/extensions/session-events.d.ts.map +1 -1
  146. package/dist/core/extensions/session-events.js.map +1 -1
  147. package/dist/core/index.d.ts +1 -1
  148. package/dist/core/index.d.ts.map +1 -1
  149. package/dist/core/index.js.map +1 -1
  150. package/dist/core/messages.d.ts +4 -0
  151. package/dist/core/messages.d.ts.map +1 -1
  152. package/dist/core/messages.js +11 -0
  153. package/dist/core/messages.js.map +1 -1
  154. package/dist/core/provider-context-usage.d.ts.map +1 -1
  155. package/dist/core/provider-context-usage.js +1 -2
  156. package/dist/core/provider-context-usage.js.map +1 -1
  157. package/dist/core/session-manager-archive.d.ts +2 -1
  158. package/dist/core/session-manager-archive.d.ts.map +1 -1
  159. package/dist/core/session-manager-archive.js +2 -2
  160. package/dist/core/session-manager-archive.js.map +1 -1
  161. package/dist/core/session-manager-classification.d.ts +9 -0
  162. package/dist/core/session-manager-classification.d.ts.map +1 -0
  163. package/dist/core/session-manager-classification.js +37 -0
  164. package/dist/core/session-manager-classification.js.map +1 -0
  165. package/dist/core/session-manager-core.d.ts +4 -4
  166. package/dist/core/session-manager-core.d.ts.map +1 -1
  167. package/dist/core/session-manager-core.js +13 -8
  168. package/dist/core/session-manager-core.js.map +1 -1
  169. package/dist/core/session-manager-entries.d.ts +4 -3
  170. package/dist/core/session-manager-entries.d.ts.map +1 -1
  171. package/dist/core/session-manager-entries.js +12 -10
  172. package/dist/core/session-manager-entries.js.map +1 -1
  173. package/dist/core/session-manager-history.d.ts +6 -23
  174. package/dist/core/session-manager-history.d.ts.map +1 -1
  175. package/dist/core/session-manager-history.js +23 -256
  176. package/dist/core/session-manager-history.js.map +1 -1
  177. package/dist/core/session-manager-list.d.ts.map +1 -1
  178. package/dist/core/session-manager-list.js +3 -3
  179. package/dist/core/session-manager-list.js.map +1 -1
  180. package/dist/core/session-manager-storage.d.ts +1 -1
  181. package/dist/core/session-manager-storage.d.ts.map +1 -1
  182. package/dist/core/session-manager-storage.js +3 -2
  183. package/dist/core/session-manager-storage.js.map +1 -1
  184. package/dist/core/session-manager-types.d.ts +14 -15
  185. package/dist/core/session-manager-types.d.ts.map +1 -1
  186. package/dist/core/session-manager-types.js.map +1 -1
  187. package/dist/core/session-manager.d.ts +3 -2
  188. package/dist/core/session-manager.d.ts.map +1 -1
  189. package/dist/core/session-manager.js +1 -1
  190. package/dist/core/session-manager.js.map +1 -1
  191. package/dist/core/slash-commands.d.ts.map +1 -1
  192. package/dist/core/slash-commands.js +1 -1
  193. package/dist/core/slash-commands.js.map +1 -1
  194. package/dist/index.d.ts +3 -2
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +2 -1
  197. package/dist/index.js.map +1 -1
  198. package/dist/main-session.d.ts +1 -0
  199. package/dist/main-session.d.ts.map +1 -1
  200. package/dist/main-session.js +7 -0
  201. package/dist/main-session.js.map +1 -1
  202. package/dist/main.d.ts.map +1 -1
  203. package/dist/main.js +2 -2
  204. package/dist/main.js.map +1 -1
  205. package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -1
  206. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  207. package/dist/modes/interactive/components/chat-message-renderer.js +12 -22
  208. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  209. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  210. package/dist/modes/interactive/components/chat-session-host-events.js +5 -11
  211. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  212. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  213. package/dist/modes/interactive/components/chat-session-host-rendering.js +3 -0
  214. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  215. package/dist/modes/interactive/components/chat-session-host-state.d.ts +1 -0
  216. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  217. package/dist/modes/interactive/components/chat-session-host-state.js +1 -0
  218. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  219. package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
  220. package/dist/modes/interactive/components/chat-session-host-utils.js +1 -1
  221. package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
  222. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  223. package/dist/modes/interactive/components/chat-session-host.js +1 -0
  224. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  225. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +20 -0
  226. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -0
  227. package/dist/modes/interactive/components/compaction-boundary-message.js +48 -0
  228. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -0
  229. package/dist/modes/interactive/components/index.d.ts +1 -1
  230. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  231. package/dist/modes/interactive/components/index.js +1 -1
  232. package/dist/modes/interactive/components/index.js.map +1 -1
  233. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  234. package/dist/modes/interactive/components/session-selector-list.js +3 -0
  235. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  236. package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
  237. package/dist/modes/interactive/interactive-agent-events.js +3 -47
  238. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  239. package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
  240. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  241. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  242. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  243. package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -3
  244. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  245. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  246. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  247. package/dist/modes/interactive/interactive-render-chat.js +21 -12
  248. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  249. package/dist/modes/rpc/rpc-client.d.ts +3 -5
  250. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  251. package/dist/modes/rpc/rpc-client.js +1 -6
  252. package/dist/modes/rpc/rpc-client.js.map +1 -1
  253. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  254. package/dist/modes/rpc/rpc-command-handler.js +0 -4
  255. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  256. package/dist/modes/rpc/rpc-types.d.ts +2 -11
  257. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  258. package/dist/modes/rpc/rpc-types.js.map +1 -1
  259. package/docs/compaction.md +97 -772
  260. package/docs/extensions.md +25 -29
  261. package/docs/json.md +2 -2
  262. package/docs/rpc.md +32 -24
  263. package/docs/sdk.md +3 -3
  264. package/docs/session-format.md +49 -30
  265. package/docs/sessions.md +5 -3
  266. package/docs/settings.md +14 -4
  267. package/docs/usage.md +1 -1
  268. package/docs/workflows.md +30 -15
  269. package/examples/extensions/custom-compaction.ts +14 -58
  270. package/examples/extensions/handoff.ts +2 -3
  271. package/npm-shrinkwrap.json +23 -23
  272. package/package.json +2 -2
  273. package/dist/core/compaction/context-assistant-turns.d.ts +0 -42
  274. package/dist/core/compaction/context-assistant-turns.d.ts.map +0 -1
  275. package/dist/core/compaction/context-assistant-turns.js +0 -87
  276. package/dist/core/compaction/context-assistant-turns.js.map +0 -1
  277. package/dist/core/compaction/context-compaction-critical.d.ts +0 -15
  278. package/dist/core/compaction/context-compaction-critical.d.ts.map +0 -1
  279. package/dist/core/compaction/context-compaction-critical.js +0 -57
  280. package/dist/core/compaction/context-compaction-critical.js.map +0 -1
  281. package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +0 -18
  282. package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +0 -1
  283. package/dist/core/compaction/context-compaction-eviction-alternates.js +0 -186
  284. package/dist/core/compaction/context-compaction-eviction-alternates.js.map +0 -1
  285. package/dist/core/compaction/context-compaction-eviction.d.ts +0 -12
  286. package/dist/core/compaction/context-compaction-eviction.d.ts.map +0 -1
  287. package/dist/core/compaction/context-compaction-eviction.js +0 -222
  288. package/dist/core/compaction/context-compaction-eviction.js.map +0 -1
  289. package/dist/core/compaction/context-compaction-metrics.d.ts +0 -28
  290. package/dist/core/compaction/context-compaction-metrics.d.ts.map +0 -1
  291. package/dist/core/compaction/context-compaction-metrics.js +0 -107
  292. package/dist/core/compaction/context-compaction-metrics.js.map +0 -1
  293. package/dist/core/compaction/context-compaction-prompt.d.ts +0 -9
  294. package/dist/core/compaction/context-compaction-prompt.d.ts.map +0 -1
  295. package/dist/core/compaction/context-compaction-prompt.js +0 -163
  296. package/dist/core/compaction/context-compaction-prompt.js.map +0 -1
  297. package/dist/core/compaction/context-compaction-runner.d.ts +0 -11
  298. package/dist/core/compaction/context-compaction-runner.d.ts.map +0 -1
  299. package/dist/core/compaction/context-compaction-runner.js +0 -273
  300. package/dist/core/compaction/context-compaction-runner.js.map +0 -1
  301. package/dist/core/compaction/context-compaction-strategy.d.ts +0 -5
  302. package/dist/core/compaction/context-compaction-strategy.d.ts.map +0 -1
  303. package/dist/core/compaction/context-compaction-strategy.js +0 -27
  304. package/dist/core/compaction/context-compaction-strategy.js.map +0 -1
  305. package/dist/core/compaction/context-compaction-types.d.ts +0 -75
  306. package/dist/core/compaction/context-compaction-types.d.ts.map +0 -1
  307. package/dist/core/compaction/context-compaction-types.js +0 -6
  308. package/dist/core/compaction/context-compaction-types.js.map +0 -1
  309. package/dist/core/compaction/context-compaction.d.ts +0 -10
  310. package/dist/core/compaction/context-compaction.d.ts.map +0 -1
  311. package/dist/core/compaction/context-compaction.js +0 -8
  312. package/dist/core/compaction/context-compaction.js.map +0 -1
  313. package/dist/core/compaction/context-deletion-application.d.ts +0 -14
  314. package/dist/core/compaction/context-deletion-application.d.ts.map +0 -1
  315. package/dist/core/compaction/context-deletion-application.js +0 -261
  316. package/dist/core/compaction/context-deletion-application.js.map +0 -1
  317. package/dist/core/compaction/context-deletion-store.d.ts +0 -78
  318. package/dist/core/compaction/context-deletion-store.d.ts.map +0 -1
  319. package/dist/core/compaction/context-deletion-store.js +0 -162
  320. package/dist/core/compaction/context-deletion-store.js.map +0 -1
  321. package/dist/core/compaction/context-deletion-targets.d.ts +0 -43
  322. package/dist/core/compaction/context-deletion-targets.d.ts.map +0 -1
  323. package/dist/core/compaction/context-deletion-targets.js +0 -292
  324. package/dist/core/compaction/context-deletion-targets.js.map +0 -1
  325. package/dist/core/compaction/context-deletion-tool-definitions.d.ts +0 -193
  326. package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +0 -1
  327. package/dist/core/compaction/context-deletion-tool-definitions.js +0 -98
  328. package/dist/core/compaction/context-deletion-tool-definitions.js.map +0 -1
  329. package/dist/core/compaction/context-deletion-tool-helpers.d.ts +0 -19
  330. package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +0 -1
  331. package/dist/core/compaction/context-deletion-tool-helpers.js +0 -210
  332. package/dist/core/compaction/context-deletion-tool-helpers.js.map +0 -1
  333. package/dist/core/compaction/context-deletion-tools.d.ts +0 -4
  334. package/dist/core/compaction/context-deletion-tools.d.ts.map +0 -1
  335. package/dist/core/compaction/context-deletion-tools.js +0 -403
  336. package/dist/core/compaction/context-deletion-tools.js.map +0 -1
  337. package/dist/core/compaction/context-transcript-analysis.d.ts +0 -11
  338. package/dist/core/compaction/context-transcript-analysis.d.ts.map +0 -1
  339. package/dist/core/compaction/context-transcript-analysis.js +0 -228
  340. package/dist/core/compaction/context-transcript-analysis.js.map +0 -1
  341. package/dist/core/session-manager-tool-dependencies.d.ts +0 -10
  342. package/dist/core/session-manager-tool-dependencies.d.ts.map +0 -1
  343. package/dist/core/session-manager-tool-dependencies.js +0 -133
  344. package/dist/core/session-manager-tool-dependencies.js.map +0 -1
  345. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +0 -17
  346. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +0 -1
  347. package/dist/modes/interactive/components/context-compaction-summary-message.js +0 -83
  348. package/dist/modes/interactive/components/context-compaction-summary-message.js.map +0 -1
@@ -338,9 +338,9 @@ user sends another prompt ◄─────────────────
338
338
  └─► resources_discover { reason: "startup" }
339
339
 
340
340
  /compact or auto-compaction
341
- ├─► compaction_start / compaction_end (deletion-only context compaction status)
342
- ├─► session_before_compact (can cancel or provide a deletion request)
343
- └─► session_compact (after the context_compaction entry is persisted)
341
+ ├─► compaction_start / compaction_end (verbatim line-compaction status)
342
+ ├─► session_before_compact (can cancel or provide compactedText)
343
+ └─► session_compact (after the compaction boundary is persisted)
344
344
 
345
345
  /tree navigation
346
346
  ├─► session_before_tree (can cancel or customize)
@@ -460,40 +460,36 @@ Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `
460
460
 
461
461
  #### session_before_compact / session_compact
462
462
 
463
- Fired by `/compact` and auto-compaction. Compaction is deletion-only: extensions can cancel the run or return exact entry/content-block deletion targets for Atomic to validate locally. Extensions cannot return generated summaries.
463
+ Fired by `/compact` and auto-compaction. Atomic prepares a protected recent tail and a numbered compactable region. Extensions may cancel or provide a complete, non-empty `compactedText` replacement for that region; they cannot move `firstKeptEntryId`. The override is persisted verbatim and works without provider credentials.
464
464
 
465
465
  ```typescript
466
- pi.on("session_before_compact", async (event, ctx) => {
467
- const { preparation, branchEntries, reason, signal } = event;
468
- const { transcript } = preparation;
466
+ pi.on("session_before_compact", async (event) => {
467
+ const { preparation, branchEntries, parameters, reason, signal } = event;
469
468
 
470
- // transcript.entries - compactable entries on the active branch
471
- // transcript.protectedEntryIds - entries validation will reject if directly deleted
472
- // transcript.tokensBefore - token estimate before compaction
473
- // branchEntries - raw session entries on the current branch
469
+ // preparation.region.lines - unnumbered compactable transcript lines
470
+ // preparation.firstKeptEntryId - fixed start of the verbatim tail
471
+ // preparation.tokensBefore - whole-context token estimate
472
+ // parameters - compression_ratio, preserve_recent, query
473
+ // branchEntries - raw entries on the active branch
474
474
  // reason - "manual" | "threshold" | "overflow"
475
+ // preparation is a deep-frozen clone
475
476
 
476
477
  if (signal.aborted) return { cancel: true };
477
478
 
478
479
  // Cancel compaction:
479
480
  return { cancel: true };
480
481
 
481
- // Or provide a deletion request. Atomic validates IDs, protected targets,
482
- // tool-call/tool-result pairing, and non-empty remaining context before saving.
482
+ // Or replace only the prepared region. Whitespace-only text is rejected.
483
483
  return {
484
- deletionRequest: {
485
- deletions: [
486
- { kind: "entry", entryId: "abc123", rationale: "Old successful command output" },
487
- { kind: "content_block", entryId: "def456", blockIndex: 2, rationale: "Verbose obsolete log" },
488
- ],
489
- },
484
+ compactedText: preparation.region.lines.slice(0, 40).join("\n"),
490
485
  };
491
486
  });
492
487
 
493
- pi.on("session_compact", async (event, ctx) => {
494
- // event.result - ContextCompactionResult with deletedTargets/protectedEntryIds/stats
495
- // event.contextCompactionEntry - the saved context_compaction entry
496
- // event.fromExtension - true if session_before_compact provided deletionRequest
488
+ pi.on("session_compact", async (event) => {
489
+ // event.result - VerbatimCompactionResult (text, boundary, stats, parameters, rung)
490
+ // event.compactionEntry - saved CompactionEntry with strategy "verbatim-lines"
491
+ // event.fromExtension - true when session_before_compact provided compactedText
492
+ // Observe-only: errors are isolated after persistence.
497
493
  });
498
494
  ```
499
495
 
@@ -1049,15 +1045,15 @@ if (usage && usage.tokens > 100_000) {
1049
1045
 
1050
1046
  ### ctx.compact()
1051
1047
 
1052
- Trigger Atomic's default Verbatim Compaction without awaiting completion. This is deletion-only Context Compaction: the internal planner searches/reads transcript slices, records exact entry/content-block deletion targets with transcript-bound tools, and Atomic applies only locally validated logical deletions. Retained transcript content stays unchanged. The approach is informed by Morph's Context Compaction write-up: [Morph's Context Compaction](https://www.morphllm.com/context-compaction). Use `compression_ratio`, `preserve_recent`, and `query` to tune the run, and `onComplete`/`onError` for follow-up actions.
1048
+ Trigger Atomic's verbatim line compactor without awaiting completion. The planner emits numbered deleted-line ranges only; Atomic validates them and reconstructs retained text mechanically. Use `compression_ratio` (fraction of compactable lines to keep), client-side `preserve_recent`, and `query` to tune the run, and `onComplete`/`onError` for follow-up actions.
1053
1049
 
1054
1050
  ```typescript
1055
1051
  ctx.compact({
1056
- compression_ratio: 0.5, // fraction to keep: 0.3 aggressive, 0.7 light
1057
- preserve_recent: 2, // keep the last N context-eligible messages
1052
+ compression_ratio: 0.5, // fraction of compactable lines to keep
1053
+ preserve_recent: 2, // keep recent messages and widen to a user-turn start
1058
1054
  query: "keep active migration details",
1059
1055
  onComplete: (result) => {
1060
- ctx.ui.notify(`Compaction deleted ${result.stats.objectsDeleted} objects`, "info");
1056
+ ctx.ui.notify(`Compaction kept ${result.stats.linesKept}/${result.stats.linesBefore} lines`, "info");
1061
1057
  },
1062
1058
  onError: (error) => {
1063
1059
  ctx.ui.notify(`Compaction failed: ${error.message}`, "error");
@@ -1065,7 +1061,7 @@ ctx.compact({
1065
1061
  });
1066
1062
  ```
1067
1063
 
1068
- Verbatim Compaction uses a fixed internal prompt; no custom summary text can be injected. The `query` parameter guides relevance-based pruning inside that fixed prompt; it is not replacement summary text.
1064
+ The planner cannot author context text: only validated line ranges enter the mechanical reconstruction path. The `query` parameter guides relevance selection inside the fixed prompt; it is not replacement prose. Extensions that need an offline replacement can return `compactedText` from `session_before_compact`.
1069
1065
 
1070
1066
  ### ctx.getSystemPrompt()
1071
1067
 
@@ -2657,7 +2653,7 @@ All examples in [examples/extensions/](https://github.com/bastani-inc/atomic/tre
2657
2653
  | `prompt-customizer.ts` | Add context-aware tool guidance using `systemPromptOptions` | `on("before_agent_start")`, `BuildSystemPromptOptions` |
2658
2654
  | `file-trigger.ts` | File watcher triggers messages | `sendMessage` |
2659
2655
  | **Compaction & Sessions** |||
2660
- | `custom-compaction.ts` | Custom deletion-request compaction policy | `on("session_before_compact")` |
2656
+ | `custom-compaction.ts` | Offline compacted-text override | `on("session_before_compact")` |
2661
2657
  | `trigger-compact.ts` | Trigger compaction manually | `compact()` |
2662
2658
  | `git-checkpoint.ts` | Git stash on turns | `on("turn_start")`, `on("session_before_fork")`, `exec` |
2663
2659
  | `auto-commit-on-exit.ts` | Commit on shutdown | `on("session_shutdown")`, `exec` |
package/docs/json.md CHANGED
@@ -19,12 +19,12 @@ type AgentSessionEvent =
19
19
  | { type: "model_changed"; model: Model<Api>; previousModel: Model<Api> | undefined; source: "set" | "cycle" | "restore" }
20
20
  | { type: "thinking_level_changed"; level: ThinkingLevel }
21
21
  | { type: "context_window_changed"; contextWindow: number }
22
- | { type: "compaction_end"; reason: "manual" | "threshold" | "overflow"; result: ContextCompactionResult | undefined; aborted: boolean; willRetry: boolean; unresolvedOverflow?: boolean; errorMessage?: string }
22
+ | { type: "compaction_end"; reason: "manual" | "threshold" | "overflow"; result: VerbatimCompactionResult | undefined; aborted: boolean; willRetry: boolean; unresolvedOverflow?: boolean; errorMessage?: string }
23
23
  | { type: "auto_retry_start"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string }
24
24
  | { type: "auto_retry_end"; success: boolean; attempt: number; finalError?: string };
25
25
  ```
26
26
 
27
- `queue_update` emits the full pending steering and follow-up queues whenever they change. `session_info_changed`, `model_changed`, `thinking_level_changed`, and `context_window_changed` report interactive session metadata changes. `context_window_changed` carries the active token budget after `AgentSession.setContextWindow()` or branch navigation replay applies a branch-scoped `context_window_change`; branch replay does not add another session journal entry or write settings. `compaction_start` and `compaction_end` cover both manual and automatic Verbatim Compaction, Atomic's transcript-bound, deletion-only Context Compaction approach inspired by [Morph's Context Compaction](https://www.morphllm.com/context-compaction).
27
+ `queue_update` emits the full pending steering and follow-up queues whenever they change. `session_info_changed`, `model_changed`, `thinking_level_changed`, and `context_window_changed` report interactive session metadata changes. `context_window_changed` carries the active token budget after `AgentSession.setContextWindow()` or branch navigation replay applies a branch-scoped `context_window_change`; branch replay does not add another session journal entry or write settings. `compaction_start` and `compaction_end` cover manual and automatic verbatim line compaction: the model emits deleted ranges and Atomic mechanically reconstructs retained text.
28
28
 
29
29
  For automatic compaction, `compaction_end.willRetry === true` means the agent is retrying the interrupted turn after compaction; `AgentSession.prompt()` waits for that continuation before resolving. This includes overflow recovery and live threshold compaction for retry-worthy interrupted work such as output-token truncation or OpenAI Responses output-budget underflow errors. Generic provider `invalid_request_body` failures still compact with `willRetry: false` when threshold compaction is warranted. If the same-model compact-and-retry overflow path is exhausted, `compaction_end` includes `unresolvedOverflow: true` plus an `errorMessage` so orchestration layers can fallback to another model instead of treating the prompt as successful.
30
30
 
package/docs/rpc.md CHANGED
@@ -414,7 +414,7 @@ Response:
414
414
 
415
415
  #### compact
416
416
 
417
- Run Atomic's default Verbatim Compaction to reduce token usage. This command has no prompt/config fields; send no custom instructions. The selected model runs Atomic's fixed internal planner with transcript-bound tools (`context_search_transcript`, `context_read_entry`, `context_delete`, and `context_grep_delete`); Atomic validates the cumulative deletion targets locally, appends a `context_compaction` entry, and rebuilds active context with surviving entries/content blocks reused verbatim. This deletion-only Context Compaction approach is informed by Morph's article: [Morph's Context Compaction](https://www.morphllm.com/context-compaction).
417
+ Run Atomic's verbatim line compactor. The selected session model receives a numbered transcript and returns JSON deleted ranges; Atomic validates them and mechanically reconstructs retained lines with `(filtered N lines)` markers. The command appends a durable `compaction` entry with `details.strategy: "verbatim-lines"`. Recent logical turns remain ordinary messages.
418
418
 
419
419
  ```json
420
420
  {"type": "compact"}
@@ -427,16 +427,24 @@ Response:
427
427
  "command": "compact",
428
428
  "success": true,
429
429
  "data": {
430
- "promptVersion": 1,
431
- "deletedTargets": [{ "kind": "entry", "entryId": "abc123" }],
432
- "protectedEntryIds": ["user-task-entry"],
430
+ "compactedText": "[User]: fix the test\n(filtered 42 lines)\n[Assistant]: Fixed.",
431
+ "firstKeptEntryId": "m7",
432
+ "tokensBefore": 150000,
433
+ "promptVersion": 2,
434
+ "parameters": {
435
+ "compression_ratio": 0.5,
436
+ "preserve_recent": 2,
437
+ "query": "fix the test"
438
+ },
439
+ "rung": "standard",
433
440
  "stats": {
434
- "objectsBefore": 20,
435
- "objectsAfter": 19,
436
- "objectsDeleted": 1,
441
+ "linesBefore": 812,
442
+ "linesDeleted": 417,
443
+ "linesKept": 395,
444
+ "rangeCount": 63,
437
445
  "tokensBefore": 150000,
438
- "tokensAfter": 120000,
439
- "percentReduction": 20
446
+ "tokensAfter": 72000,
447
+ "percentReduction": 52
440
448
  },
441
449
  "backupPath": "/path/to/session.jsonl.2026-06-06T00-00-00-000Z.compact.bak"
442
450
  }
@@ -880,10 +888,8 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
880
888
  | `tool_execution_end` | Tool completes |
881
889
  | `queue_update` | Pending steering/follow-up queue changed |
882
890
  | `context_window_changed` | Active context-window token budget changed |
883
- | `compaction_start` | Default Verbatim Compaction begins |
884
- | `compaction_end` | Default Verbatim Compaction completes |
885
- | `context_compaction_start` | Compatibility `context_compact` RPC begins |
886
- | `context_compaction_end` | Compatibility `context_compact` RPC completes |
891
+ | `compaction_start` | Verbatim line compaction begins |
892
+ | `compaction_end` | Verbatim line compaction completes |
887
893
  | `auto_retry_start` | Auto-retry begins (after transient error) |
888
894
  | `auto_retry_end` | Auto-retry completes (success or final failure) |
889
895
  | `extension_error` | Extension threw an error |
@@ -1059,16 +1065,20 @@ The `reason` field is `"manual"`, `"threshold"`, or `"overflow"`.
1059
1065
  "type": "compaction_end",
1060
1066
  "reason": "threshold",
1061
1067
  "result": {
1062
- "promptVersion": 1,
1063
- "deletedTargets": [{ "kind": "entry", "entryId": "abc123" }],
1064
- "protectedEntryIds": ["user-task-entry"],
1068
+ "compactedText": "[User]: fix the test\n(filtered 42 lines)",
1069
+ "firstKeptEntryId": "m7",
1070
+ "tokensBefore": 150000,
1071
+ "promptVersion": 2,
1072
+ "parameters": {"compression_ratio": 0.5, "preserve_recent": 2, "query": "fix the test"},
1073
+ "rung": "standard",
1065
1074
  "stats": {
1066
- "objectsBefore": 20,
1067
- "objectsAfter": 19,
1068
- "objectsDeleted": 1,
1075
+ "linesBefore": 812,
1076
+ "linesDeleted": 417,
1077
+ "linesKept": 395,
1078
+ "rangeCount": 63,
1069
1079
  "tokensBefore": 150000,
1070
- "tokensAfter": 120000,
1071
- "percentReduction": 20
1080
+ "tokensAfter": 72000,
1081
+ "percentReduction": 52
1072
1082
  }
1073
1083
  },
1074
1084
  "aborted": false,
@@ -1084,9 +1094,7 @@ If compaction failed (e.g., API quota exceeded), `result` is `null`, `aborted` i
1084
1094
 
1085
1095
  If overflow recovery exhausts the same-model compact-and-retry attempt, `compaction_end` includes `"unresolvedOverflow": true` and an `errorMessage`. Workflow orchestration treats that signal as a context-length failure that can advance configured model fallback tiers.
1086
1096
 
1087
- ### context_compaction_start / context_compaction_end
1088
-
1089
- The compatibility RPC command `context_compact` emits these events. It uses the same deletion-only Verbatim Compaction path as `compact`, but reports the historical context-compaction event names. The result contains `deletedTargets`, `protectedEntryIds`, `stats`, `promptVersion`, and optional `backupPath`.
1097
+ There is no `context_compact` command; Atomic reports it as an unknown command. Use `compact`. Only `compaction_start` and `compaction_end` events are emitted.
1090
1098
 
1091
1099
  ### auto_retry_start / auto_retry_end
1092
1100
 
package/docs/sdk.md CHANGED
@@ -126,8 +126,8 @@ interface AgentSession {
126
126
  // In-place tree navigation within the current session file
127
127
  navigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;
128
128
 
129
- // Verbatim Compaction (deletion-only Context Compaction)
130
- compact(): Promise<ContextCompactionResult>;
129
+ // Verbatim line compaction
130
+ compact(options?: Partial<VerbatimCompactionParameters>): Promise<VerbatimCompactionResult>;
131
131
  abortCompaction(): void;
132
132
 
133
133
  // Abort current operation
@@ -138,7 +138,7 @@ interface AgentSession {
138
138
  }
139
139
  ```
140
140
 
141
- `compact()` accepts no custom summary instructions. It runs the same transcript-bound Verbatim Compaction planner as `/compact`: inspect transcript slices, record exact deletion targets, validate them locally, append a `context_compaction` entry, and rebuild active context with retained content unchanged.
141
+ `compact()` serializes older context to numbered lines, asks the session model for JSON deleted ranges, validates them, and mechanically reconstructs a durable verbatim transcript string. It appends a `compaction` entry with `details.strategy: "verbatim-lines"`; the recent tail remains ordinary messages. The model never authors replacement context text.
142
142
 
143
143
  Session replacement APIs such as new-session, resume, fork, and import live on `AgentSessionRuntime`, not on `AgentSession`.
144
144
 
@@ -146,7 +146,7 @@ interface BranchSummaryMessage {
146
146
  }
147
147
  ```
148
148
 
149
- Historical sessions may contain retired `compactionSummary` role messages from the old summary-compaction implementation. Atomic no longer produces them, they are not part of the active `AgentMessage` union, and they are not injected when active LLM context is rebuilt.
149
+ `compactionSummary` is a historical message role that appears only in older session files; Atomic never produces it and treats historical occurrences as inert. Active verbatim boundaries are synthesized at rebuild time as visible `custom` messages with `customType: "compaction"`; `convertToLlm()` maps them to provider-facing user messages.
150
150
 
151
151
  ### AgentMessage Union
152
152
 
@@ -158,7 +158,7 @@ type AgentMessage =
158
158
  | BashExecutionMessage
159
159
  | CustomMessage
160
160
  | BranchSummaryMessage;
161
- // CompactionSummaryMessage was removed; it is no longer part of the active union.
161
+ // compactionSummary appears only in older session files and is not part of the active union.
162
162
  ```
163
163
 
164
164
  ## Entry Base
@@ -190,12 +190,14 @@ For sessions with a parent (created via `/fork`, `/clone`, or `newSession({ pare
190
190
  {"type":"session","version":3,"id":"uuid","timestamp":"2024-12-03T14:00:00.000Z","cwd":"/path/to/project","parentSession":"/path/to/original/session.jsonl"}
191
191
  ```
192
192
 
193
- Sessions created by automated machinery (notably workflow stage sessions) carry an `internal` flag and optional `workflow` linkage so they can be excluded from the standard `/resume` history while remaining resumable through their owning workflow:
193
+ Workflow-owned sessions carry both `internal: true` and complete `workflow` linkage. Atomic writes this classification before the transcript becomes visible wherever possible, including workflow stage forks and fresh/forked subagents. A session is excluded from normal resume history only when `internal` is the exact boolean `true` and `workflow.runId`, `workflow.stageId`, and `workflow.stageName` are all non-empty strings:
194
194
 
195
195
  ```json
196
196
  {"type":"session","version":3,"id":"uuid","timestamp":"2024-12-03T14:00:00.000Z","cwd":"/path/to/project","internal":true,"workflow":{"runId":"run-1","stageId":"stage-build","stageName":"build"}}
197
197
  ```
198
198
 
199
+ Malformed, incomplete, workflow-only, or truthy non-boolean legacy markers remain visible in normal history. Atomic does not infer workflow ownership from `parentSession`, so ordinary user-created forks are unaffected. Valid workflow classification is inherited when an internal workflow transcript is branched or forked.
200
+
199
201
  ### SessionMessageEntry
200
202
 
201
203
  A message in the conversation. The `message` field contains an `AgentMessage`.
@@ -234,25 +236,27 @@ Emitted when the user selects a supported context-window size for the active mod
234
236
 
235
237
  ### CompactionEntry
236
238
 
237
- Retired summary-compaction entry. Atomic no longer produces this entry type, does not treat it as an active compaction boundary, and does not inject its generated summary into active LLM context. Historical JSONL files may still contain these lines for audit/export compatibility.
239
+ Created by `/compact`, RPC `compact`, and automatic compaction. The `summary` field contains the mechanically reconstructed verbatim transcript string, not generated summary prose. `firstKeptEntryId` points to the first ordinary message retained after the boundary.
240
+
241
+ An entry is active only when `details.strategy` is exactly `"verbatim-lines"`:
238
242
 
239
243
  ```json
240
- {"type":"compaction","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:10:00.000Z","summary":"User discussed X, Y, Z...","firstKeptEntryId":"c3d4e5f6","tokensBefore":50000}
244
+ {"type":"compaction","id":"c1","parentId":"m9","timestamp":"2026-07-13T10:00:00.000Z","summary":"[User]: fix the test\n(filtered 42 lines)\n[Assistant]: Fixed.","firstKeptEntryId":"m7","tokensBefore":51234,"details":{"strategy":"verbatim-lines","promptVersion":2,"rung":"standard","parameters":{"compression_ratio":0.5,"preserve_recent":2,"query":"fix the test"},"stats":{"linesBefore":812,"linesDeleted":417,"linesKept":395,"rangeCount":63,"tokensBefore":51234,"tokensAfter":24980,"percentReduction":51.2}}}
241
245
  ```
242
246
 
243
- Optional historical fields:
244
- - `details`: Legacy implementation-specific data
245
- - `fromHook`: `true` if generated by an extension, `false`/`undefined` if Atomic-generated (legacy field name)
247
+ On rebuild, Atomic emits the durable `summary` as a synthesized visible custom message, then emits original entries beginning at `firstKeptEntryId`. This exact string survives resume without rerunning a planner. `details.rung` is `"standard"`, `"critical"`, `"deterministic"`, or `"extension"`; `details.backupPath` is optional.
248
+
249
+ Historical `compaction` records without `details.strategy: "verbatim-lines"` are retired summary-compaction records. They remain parseable and visible to audit/export tools but are inert in active LLM context.
246
250
 
247
- ### ContextCompactionEntry
251
+ ### ContextCompactionEntry (Retired)
248
252
 
249
- Created by `/compact`, RPC compaction commands, and auto-compaction. Stores Atomic's default **Verbatim Compaction** data: validated logical deletion targets, not replacement text. The internal planner can search/read transcript slices and record exact entry/content-block targets with transcript-bound tools; Atomic validates those targets locally before saving. During `buildSessionContext()`, matching entries/content blocks are filtered from active LLM context while retained content remains verbatim. This deletion-only Context Compaction approach is informed by Morph's write-up at [Morph's Context Compaction](https://www.morphllm.com/context-compaction).
253
+ Older Atomic versions stored logical entry/content-block deletions in `type:"context_compaction"` records:
250
254
 
251
255
  ```json
252
- {"type":"context_compaction","id":"ctx12345","parentId":"f6g7h8i9","timestamp":"2024-12-03T14:12:00.000Z","promptVersion":1,"deletedTargets":[{"kind":"entry","entryId":"b2c3d4e5"}],"protectedEntryIds":["a1b2c3d4"],"stats":{"objectsBefore":20,"objectsAfter":19,"objectsDeleted":1,"tokensBefore":50000,"tokensAfter":43000,"percentReduction":14},"backupPath":"/path/session.jsonl.2024-12-03T14-12-00-000Z.compact.bak"}
256
+ {"type":"context_compaction","id":"ctx12345","parentId":"f6g7h8i9","timestamp":"2024-12-03T14:12:00.000Z","promptVersion":1,"deletedTargets":[{"kind":"entry","entryId":"b2c3d4e5"}],"protectedEntryIds":["a1b2c3d4"],"stats":{"objectsBefore":20,"objectsAfter":19,"objectsDeleted":1,"tokensBefore":50000,"tokensAfter":43000,"percentReduction":14}}
253
257
  ```
254
258
 
255
- `deletedTargets` entries are either whole entries (`{ kind: "entry", entryId }`) or content blocks (`{ kind: "content_block", entryId, blockIndex }`). Content-block targets are not applied to retained assistant messages that contain `thinking` or `redacted_thinking`; those assistant messages are replay-sensitive for Anthropic-compatible extended-thinking providers and are restored as full content arrays during active context rebuild. The JSONL file remains append-only; this is logical deletion for active context rebuild.
259
+ These records are archival and never produced or applied by current Atomic. When an old session resumes, previously hidden content may re-enter context until verbatim-line compaction creates an active boundary.
256
260
 
257
261
  ### BranchSummaryEntry
258
262
 
@@ -325,14 +329,12 @@ Entries form a tree:
325
329
 
326
330
  ## Context Building
327
331
 
328
- `buildSessionContext()` walks from the current leaf to the root, producing the message list for the LLM:
329
-
330
- 1. Collects all entries on the active branch path
331
- 2. Extracts current model, thinking level, and context-window settings
332
- 3. Applies every `ContextCompactionEntry` logical deletion on that path, filtering targeted entries/content blocks from active context while leaving retained content unchanged
333
- 4. Converts `BranchSummaryEntry` and `CustomMessageEntry` to appropriate message formats
334
- 5. Ignores retired `CompactionEntry` lines for active LLM context; they remain archival JSONL data only
332
+ `buildSessionContext()` walks the active branch from root to leaf and replays model, thinking-level, and context-window changes. It selects the latest `compaction` entry whose `details.strategy` is `"verbatim-lines"`.
335
333
 
334
+ - With no active boundary, normal message, custom-message, and branch-summary entries are emitted verbatim.
335
+ - With a boundary, Atomic emits its durable string as a custom-role `customType:"compaction"` message, then original messages from `firstKeptEntryId` onward, including messages appended after the boundary.
336
+ - If a corrupt/foreign boundary's `firstKeptEntryId` is absent, Atomic emits the boundary followed by post-boundary messages rather than resurrecting all older content.
337
+ - Legacy `context_compaction` entries and non-verbatim `compaction` entries are skipped as inert archival records.
336
338
  ## Parsing Example
337
339
 
338
340
  ```typescript
@@ -351,10 +353,14 @@ for (const line of lines) {
351
353
  console.log(`[${entry.id}] ${entry.message.role}: ${JSON.stringify(entry.message.content)}`);
352
354
  break;
353
355
  case "compaction":
354
- console.log(`[${entry.id}] Retired summary-compaction record: ${entry.tokensBefore} tokens summarized historically`);
356
+ if (entry.details?.strategy === "verbatim-lines") {
357
+ console.log(`[${entry.id}] Verbatim compaction: ${entry.details.stats.linesKept}/${entry.details.stats.linesBefore} lines kept`);
358
+ } else {
359
+ console.log(`[${entry.id}] Retired summary-compaction record`);
360
+ }
355
361
  break;
356
362
  case "context_compaction":
357
- console.log(`[${entry.id}] Context compaction: ${entry.stats.objectsDeleted} objects deleted`);
363
+ console.log(`[${entry.id}] Retired logical-deletion compaction record`);
358
364
  break;
359
365
  case "branch_summary":
360
366
  console.log(`[${entry.id}] Branch from ${entry.fromId}`);
@@ -386,18 +392,31 @@ for (const line of lines) {
386
392
  Key methods for working with sessions programmatically.
387
393
 
388
394
  ### Static Creation Methods
389
- - `SessionManager.create(cwd, sessionDir?)` - New session
390
- - `SessionManager.open(path, sessionDir?)` - Open existing session file
391
- - `SessionManager.continueRecent(cwd, sessionDir?)` - Continue most recent or create new
392
- - `SessionManager.inMemory(cwd?)` - No file persistence
393
- - `SessionManager.forkFrom(sourcePath, targetCwd, sessionDir?)` - Fork session from another project
395
+
396
+ - `SessionManager.create(cwd, sessionDir?, options?)` - New session. Workflow-owned sessions require the pair `internal: true` and `workflow: { runId, stageId, stageName }`.
397
+ - `SessionManager.open(path, sessionDir?)` - Open a specific session file directly, including an internal session.
398
+ - `SessionManager.continueRecent(cwd, sessionDir?, options?)` - Continue the most recent regular session or create a new one. Pass `{ includeInternal: true }` only for workflow-specific recovery or diagnostics.
399
+ - `SessionManager.inMemory(cwd?, options?)` - No file persistence
400
+ - `SessionManager.forkFrom(sourcePath, targetCwd, sessionDir?, options?)` - Fork a session from another project. Relevant `NewSessionOptions`, including valid workflow classification, are written in the initial header.
394
401
 
395
402
  ### Static Listing Methods
396
- - `SessionManager.list(cwd, sessionDir?, onProgress?)` - List sessions for a directory
397
- - `SessionManager.listAll(onProgress?)` - List all sessions across all projects
403
+
404
+ - `SessionManager.list(cwd, sessionDir?, onProgress?, options?)` - List project sessions. Internal workflow sessions are excluded by default; pass `{ includeInternal: true }` to include them and expose their `SessionInfo.workflow` linkage.
405
+ - `SessionManager.listAll(sessionDir?, onProgress?, options?)` - List sessions across projects, or from a custom session directory. The same `includeInternal` default and opt-in apply.
406
+
407
+ Normal `/resume`, `atomic -r`, and `--continue` callers use the default filtering. Workflow-specific code can opt in without changing user-facing history:
408
+
409
+ ```typescript
410
+ const stages = await SessionManager.list(cwd, sessionDir, undefined, { includeInternal: true });
411
+ for (const stage of stages.filter((session) => session.internal)) {
412
+ console.log(stage.workflow?.runId, stage.workflow?.stageId, stage.path);
413
+ }
414
+ ```
398
415
 
399
416
  ### Instance Methods - Session Management
400
- - `newSession(options?)` - Start a new session (options: `{ parentSession?: string }`)
417
+
418
+ - `newSession(options?)` - Start a new session. Options include `parentSession`, `internal`, and workflow run/stage linkage; classification requires a complete marker pair.
419
+ - `markSessionInternal(workflow?)` - Apply valid workflow ownership to the current session, repairing malformed markers while preserving an existing valid marker.
401
420
  - `setSessionFile(path)` - Switch to a different session file
402
421
  - `createBranchedSession(leafId)` - Extract branch to new session file
403
422
 
@@ -406,7 +425,7 @@ Key methods for working with sessions programmatically.
406
425
  - `appendThinkingLevelChange(level)` - Record thinking change
407
426
  - `appendContextWindowChange(contextWindow)` - Record context-window selection in tokens
408
427
  - `appendModelChange(provider, modelId)` - Record model change
409
- - `appendContextCompaction(deletedTargets, protectedEntryIds, stats, backupPath?)` - Add logical deletion compaction
428
+ - `appendCompaction(compactedText, firstKeptEntryId, tokensBefore, details)` - Add a durable verbatim-line compaction boundary
410
429
  - `appendCustomEntry(customType, data?)` - Extension state (not in context)
411
430
  - `appendSessionInfo(name)` - Set session display name
412
431
  - `appendCustomMessageEntry(customType, content, display, details?)` - Extension message (in context)
package/docs/sessions.md CHANGED
@@ -34,7 +34,7 @@ For the JSONL file format and SessionManager API, see [Session Format](/session-
34
34
  | `/tree` | Navigate the current session tree |
35
35
  | `/fork` | Create a new session from a previous user message |
36
36
  | `/clone` | Duplicate the current active branch into a new session |
37
- | `/compact` | Apply Verbatim Compaction with transcript-bound, validated logical deletions; see [Compaction](/compaction) |
37
+ | `/compact` | Compact older transcript lines verbatim while preserving recent logical turns; see [Compaction](/compaction) |
38
38
  | `/export [file]` | Export session to HTML |
39
39
  | `/share` | Upload as private GitHub gist with shareable HTML link |
40
40
 
@@ -42,6 +42,8 @@ For the JSONL file format and SessionManager API, see [Session Format](/session-
42
42
 
43
43
  `/resume` opens an interactive session picker for the current project. `atomic -r` opens the same picker at startup.
44
44
 
45
+ When Atomic reconstructs a resumed session, the latest active verbatim `compaction` entry supplies a durable compacted transcript string followed by the original kept tail. Resume does not rerun a planner or re-derive omissions. Legacy logical-deletion `context_compaction` entries are inert archival records, so previously hidden content can re-enter context in sessions created by older versions.
46
+
45
47
  In the picker you can:
46
48
 
47
49
  - search by typing
@@ -146,12 +148,12 @@ When prompted, choose one of:
146
148
  2. summarize with the default prompt
147
149
  3. summarize with custom focus instructions
148
150
 
149
- Branch summaries are separate from `/compact`: branch navigation can generate summary prose (optionally with focus instructions), while Verbatim Compaction records validated deletion targets and does not accept summary instructions.
151
+ Branch summaries are separate from `/compact`: branch navigation can generate summary prose (optionally with focus instructions), while Verbatim Compaction lets a model select numbered line ranges and reconstructs retained text mechanically.
150
152
 
151
153
  See [Compaction](/compaction) for Verbatim Compaction, branch summarization internals, and extension hooks.
152
154
 
153
155
  ## Session Format
154
156
 
155
- Session files are JSONL and contain message entries, model changes, thinking-level changes, context-window changes, labels, context compactions, branch summaries, extension entries, and retired legacy `type:"compaction"` records from older sessions.
157
+ Session files are JSONL and contain message entries, model changes, thinking-level changes, context-window changes, labels, active verbatim `compaction` boundaries, branch summaries, and extension entries. Retired `context_compaction` and non-verbatim `compaction` records remain parseable but inert.
156
158
 
157
159
  For parsers, extensions, SDK usage, and the full SessionManager API, see [Session Format](/session-format).
package/docs/settings.md CHANGED
@@ -134,18 +134,26 @@ Set `ATOMIC_SKIP_VERSION_CHECK=1` to disable the Atomic version update check. Us
134
134
 
135
135
  | Setting | Type | Default | Description |
136
136
  |---------|------|---------|-------------|
137
- | `compaction.enabled` | boolean | `true` | Enable automatic Verbatim Compaction |
138
- | `compaction.reserveTokens` | number | `16384` | Tokens reserved for LLM response |
137
+ | `compaction.enabled` | boolean | `true` | Enable automatic verbatim line compaction |
138
+ | `compaction.reserveTokens` | number | `16384` | Tokens reserved for the next model response; automatic threshold compaction begins before this reserve is consumed |
139
+ | `compaction.compression_ratio` | number | `0.5` | Fraction of compactable transcript **lines to keep** (`0 < value < 1`) |
140
+ | `compaction.preserve_recent` | number | `2` | Recent context-visible messages kept outside the compactable region; Atomic widens the cut to a user-turn start and always retains the final logical turn |
141
+ | `compaction.query` | string | last user message | Optional relevance focus for selecting older lines to retain |
139
142
 
140
143
  ```json
141
144
  {
142
145
  "compaction": {
143
146
  "enabled": true,
144
- "reserveTokens": 16384
147
+ "reserveTokens": 16384,
148
+ "compression_ratio": 0.5,
149
+ "preserve_recent": 2,
150
+ "query": "optional focus"
145
151
  }
146
152
  }
147
153
  ```
148
154
 
155
+ The model emits numbered line ranges only; Atomic reconstructs retained text mechanically. `preserve_recent` is enforced client-side and is not a provider parameter.
156
+
149
157
  ### Branch Summary
150
158
 
151
159
  | Setting | Type | Default | Description |
@@ -350,7 +358,9 @@ See [Atomic packages](/packages) for package management details.
350
358
  "theme": "dark",
351
359
  "compaction": {
352
360
  "enabled": true,
353
- "reserveTokens": 16384
361
+ "reserveTokens": 16384,
362
+ "compression_ratio": 0.5,
363
+ "preserve_recent": 2
354
364
  },
355
365
  "retry": {
356
366
  "enabled": true,
package/docs/usage.md CHANGED
@@ -93,7 +93,7 @@ Useful session commands:
93
93
  - `/tree` navigates the in-file session tree and can summarize abandoned branches.
94
94
  - `/fork` creates a new session from an earlier user message.
95
95
  - `/clone` duplicates the current active branch into a new session file.
96
- - `/compact` uses Verbatim Compaction: a fixed no-argument deletion-only planner searches/reads transcript slices, records exact deletion targets, and applies only locally validated logical deletions. Retained transcript content stays verbatim. Atomic's approach is informed by Morph's Context Compaction article: [Morph's Context Compaction](https://www.morphllm.com/context-compaction).
96
+ - `/compact` uses verbatim line compaction: the model selects one-based numbered ranges to delete, Atomic validates them, and retained text is reconstructed mechanically with `(filtered N lines)` markers. Recent logical turns remain ordinary messages.
97
97
 
98
98
  See [Sessions](/sessions) and [Compaction](/compaction) for details.
99
99