@pentoshi/clai 4.19.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (701) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/PROVIDERS.md +15 -2
  3. package/REA.md +96 -0
  4. package/README.md +5 -1
  5. package/dist/agent/compaction/compaction-prompt.d.ts +49 -0
  6. package/dist/agent/compaction/compaction-prompt.js +164 -0
  7. package/dist/agent/compaction/compaction-prompt.js.map +1 -0
  8. package/dist/agent/compaction/memory-sections.d.ts +27 -0
  9. package/dist/agent/compaction/memory-sections.js +144 -0
  10. package/dist/agent/compaction/memory-sections.js.map +1 -0
  11. package/dist/agent/compaction-summary.d.ts +2 -33
  12. package/dist/agent/compaction-summary.js +3 -113
  13. package/dist/agent/compaction-summary.js.map +1 -1
  14. package/dist/agent/context/compact-with-summary.d.ts +2 -4
  15. package/dist/agent/context/compact-with-summary.js +45 -68
  16. package/dist/agent/context/compact-with-summary.js.map +1 -1
  17. package/dist/agent/context/compaction-recent-history.d.ts +4 -3
  18. package/dist/agent/context/compaction-recent-history.js +30 -52
  19. package/dist/agent/context/compaction-recent-history.js.map +1 -1
  20. package/dist/agent/context/compaction-skills.d.ts +4 -0
  21. package/dist/agent/context/compaction-skills.js +136 -0
  22. package/dist/agent/context/compaction-skills.js.map +1 -0
  23. package/dist/agent/context/compaction-user-instructions.d.ts +5 -6
  24. package/dist/agent/context/compaction-user-instructions.js +156 -231
  25. package/dist/agent/context/compaction-user-instructions.js.map +1 -1
  26. package/dist/agent/context-manager.js +20 -8
  27. package/dist/agent/context-manager.js.map +1 -1
  28. package/dist/agent/events.d.ts +10 -0
  29. package/dist/agent/loop-guard.d.ts +1 -0
  30. package/dist/agent/loop-guard.js +29 -6
  31. package/dist/agent/loop-guard.js.map +1 -1
  32. package/dist/agent/outcomes.js +4 -0
  33. package/dist/agent/outcomes.js.map +1 -1
  34. package/dist/agent/parser/arg-formatting.js +8 -2
  35. package/dist/agent/parser/arg-formatting.js.map +1 -1
  36. package/dist/agent/parser/dsml.d.ts +30 -0
  37. package/dist/agent/parser/dsml.js +233 -0
  38. package/dist/agent/parser/dsml.js.map +1 -0
  39. package/dist/agent/parser/vendor-protocols.d.ts +2 -5
  40. package/dist/agent/parser/vendor-protocols.js +4 -93
  41. package/dist/agent/parser/vendor-protocols.js.map +1 -1
  42. package/dist/agent/plan-implement-compact.js +2 -2
  43. package/dist/agent/plan-implement-compact.js.map +1 -1
  44. package/dist/agent/reliability-policy.d.ts +3 -1
  45. package/dist/agent/reliability-policy.js +21 -31
  46. package/dist/agent/reliability-policy.js.map +1 -1
  47. package/dist/agent/runner.js +12 -1
  48. package/dist/agent/runner.js.map +1 -1
  49. package/dist/agent/subagents/read-only-tools.js +7 -8
  50. package/dist/agent/subagents/read-only-tools.js.map +1 -1
  51. package/dist/agent/tool-call-parser.js +6 -8
  52. package/dist/agent/tool-call-parser.js.map +1 -1
  53. package/dist/agent/turn/event-emitter.js +2 -0
  54. package/dist/agent/turn/event-emitter.js.map +1 -1
  55. package/dist/agent/turn/loop/answer-path.js +3 -1
  56. package/dist/agent/turn/loop/answer-path.js.map +1 -1
  57. package/dist/agent/turn/loop/canonicalize-turn-call.js +5 -3
  58. package/dist/agent/turn/loop/canonicalize-turn-call.js.map +1 -1
  59. package/dist/agent/turn/loop/native-tool-calls.js +2 -2
  60. package/dist/agent/turn/loop/native-tool-calls.js.map +1 -1
  61. package/dist/agent/turn/loop/output-budget.d.ts +0 -1
  62. package/dist/agent/turn/loop/output-budget.js +5 -13
  63. package/dist/agent/turn/loop/output-budget.js.map +1 -1
  64. package/dist/agent/turn/loop/pending-tool-calls.d.ts +16 -0
  65. package/dist/agent/turn/loop/pending-tool-calls.js +53 -0
  66. package/dist/agent/turn/loop/pending-tool-calls.js.map +1 -0
  67. package/dist/agent/turn/loop/request-assembly.js +39 -33
  68. package/dist/agent/turn/loop/request-assembly.js.map +1 -1
  69. package/dist/agent/turn/loop/round-request.js +32 -18
  70. package/dist/agent/turn/loop/round-request.js.map +1 -1
  71. package/dist/agent/turn/loop/run-rounds.js +2 -2
  72. package/dist/agent/turn/loop/run-rounds.js.map +1 -1
  73. package/dist/agent/turn/loop/stream-session.d.ts +5 -7
  74. package/dist/agent/turn/loop/stream-session.js +43 -31
  75. package/dist/agent/turn/loop/stream-session.js.map +1 -1
  76. package/dist/agent/turn/loop/tool-call-recovery.d.ts +2 -0
  77. package/dist/agent/turn/loop/tool-call-recovery.js +26 -11
  78. package/dist/agent/turn/loop/tool-call-recovery.js.map +1 -1
  79. package/dist/agent/turn/mcp-agent-tools.d.ts +3 -0
  80. package/dist/agent/turn/mcp-agent-tools.js +11 -2
  81. package/dist/agent/turn/mcp-agent-tools.js.map +1 -1
  82. package/dist/agent/turn/prompt-sections.js +1 -0
  83. package/dist/agent/turn/prompt-sections.js.map +1 -1
  84. package/dist/agent/turn/scaffold-preflight.d.ts +6 -1
  85. package/dist/agent/turn/scaffold-preflight.js +10 -2
  86. package/dist/agent/turn/scaffold-preflight.js.map +1 -1
  87. package/dist/agent/turn/setup/mcp-agent-ports.d.ts +5 -1
  88. package/dist/agent/turn/setup/mcp-agent-ports.js +2 -0
  89. package/dist/agent/turn/setup/mcp-agent-ports.js.map +1 -1
  90. package/dist/agent/turn/system-sections.d.ts +2 -0
  91. package/dist/agent/turn/system-sections.js +12 -8
  92. package/dist/agent/turn/system-sections.js.map +1 -1
  93. package/dist/agent/turn/tool-execution/deps.d.ts +2 -0
  94. package/dist/agent/turn/tool-execution/single-tool.js +4 -1
  95. package/dist/agent/turn/tool-execution/single-tool.js.map +1 -1
  96. package/dist/agent/turn/tool-result-recorder.js +1 -0
  97. package/dist/agent/turn/tool-result-recorder.js.map +1 -1
  98. package/dist/agent/turn/turn-counters.d.ts +1 -0
  99. package/dist/agent/turn/turn-counters.js +2 -0
  100. package/dist/agent/turn/turn-counters.js.map +1 -1
  101. package/dist/agent/turn/workspace-setup.d.ts +7 -2
  102. package/dist/agent/turn/workspace-setup.js +45 -30
  103. package/dist/agent/turn/workspace-setup.js.map +1 -1
  104. package/dist/agent/workspace-orient.d.ts +4 -0
  105. package/dist/agent/workspace-orient.js +83 -37
  106. package/dist/agent/workspace-orient.js.map +1 -1
  107. package/dist/app/adapters/agent-event-adapter.d.ts +2 -0
  108. package/dist/app/adapters/agent-event-adapter.js +32 -2
  109. package/dist/app/adapters/agent-event-adapter.js.map +1 -1
  110. package/dist/app/adapters/current-agent-adapter.js +1 -0
  111. package/dist/app/adapters/current-agent-adapter.js.map +1 -1
  112. package/dist/app/adapters/current-store-adapter.js +3 -0
  113. package/dist/app/adapters/current-store-adapter.js.map +1 -1
  114. package/dist/app/commands/catalog.js +10 -4
  115. package/dist/app/commands/catalog.js.map +1 -1
  116. package/dist/app/controllers/session-compact-helper.js +2 -5
  117. package/dist/app/controllers/session-compact-helper.js.map +1 -1
  118. package/dist/app/controllers/session-controller.js +34 -3
  119. package/dist/app/controllers/session-controller.js.map +1 -1
  120. package/dist/app/controllers/session-prompt-queue.d.ts +13 -1
  121. package/dist/app/controllers/session-prompt-queue.js +96 -24
  122. package/dist/app/controllers/session-prompt-queue.js.map +1 -1
  123. package/dist/app/controllers/turn-controller.d.ts +1 -0
  124. package/dist/app/controllers/turn-controller.js +14 -1
  125. package/dist/app/controllers/turn-controller.js.map +1 -1
  126. package/dist/app/events/app-event.d.ts +5 -0
  127. package/dist/app/events/app-event.js.map +1 -1
  128. package/dist/app/ports/agent-port.d.ts +1 -0
  129. package/dist/app/ports/persistence-port.d.ts +7 -0
  130. package/dist/app/ports/transcript-item.d.ts +2 -0
  131. package/dist/classic/app/app-wiring.d.ts +5 -2
  132. package/dist/classic/app/app-wiring.js +7 -3
  133. package/dist/classic/app/app-wiring.js.map +1 -1
  134. package/dist/classic/app/paint-pacing.js +2 -2
  135. package/dist/classic/app/paint-pacing.js.map +1 -1
  136. package/dist/classic/app/use-feed.js +7 -9
  137. package/dist/classic/app/use-feed.js.map +1 -1
  138. package/dist/classic/app/wiring-disclosure.js +1 -1
  139. package/dist/classic/app/wiring-disclosure.js.map +1 -1
  140. package/dist/classic/app/wiring-feed-scroll.d.ts +5 -0
  141. package/dist/classic/app/wiring-feed-scroll.js +39 -0
  142. package/dist/classic/app/wiring-feed-scroll.js.map +1 -0
  143. package/dist/classic/app/wiring-interactions.d.ts +0 -3
  144. package/dist/classic/app/wiring-interactions.js +6 -28
  145. package/dist/classic/app/wiring-interactions.js.map +1 -1
  146. package/dist/classic/app/wiring-lifecycle.d.ts +1 -0
  147. package/dist/classic/app/wiring-lifecycle.js +11 -1
  148. package/dist/classic/app/wiring-lifecycle.js.map +1 -1
  149. package/dist/classic/app/wiring-selection.js +46 -37
  150. package/dist/classic/app/wiring-selection.js.map +1 -1
  151. package/dist/classic/app/wiring-types.d.ts +5 -2
  152. package/dist/classic/blocks/intro-lines.js +1 -0
  153. package/dist/classic/blocks/intro-lines.js.map +1 -1
  154. package/dist/classic/blocks/thinking-lines.d.ts +6 -0
  155. package/dist/classic/blocks/thinking-lines.js +22 -7
  156. package/dist/classic/blocks/thinking-lines.js.map +1 -1
  157. package/dist/classic/blocks/tool-lines.js +9 -4
  158. package/dist/classic/blocks/tool-lines.js.map +1 -1
  159. package/dist/classic/blocks/turn-summary-lines.d.ts +1 -1
  160. package/dist/classic/blocks/turn-summary-lines.js +5 -3
  161. package/dist/classic/blocks/turn-summary-lines.js.map +1 -1
  162. package/dist/classic/bootstrap/start-classic.js +4 -1
  163. package/dist/classic/bootstrap/start-classic.js.map +1 -1
  164. package/dist/classic/chrome/composer-mentions.js +2 -1
  165. package/dist/classic/chrome/composer-mentions.js.map +1 -1
  166. package/dist/classic/chrome/directory-row.js +5 -5
  167. package/dist/classic/chrome/directory-row.js.map +1 -1
  168. package/dist/classic/chrome/status-rows.d.ts +2 -1
  169. package/dist/classic/chrome/status-rows.js +18 -8
  170. package/dist/classic/chrome/status-rows.js.map +1 -1
  171. package/dist/classic/feed/feed-blocks.js +6 -4
  172. package/dist/classic/feed/feed-blocks.js.map +1 -1
  173. package/dist/classic/feed/transcript-selection.d.ts +2 -1
  174. package/dist/classic/feed/transcript-selection.js +15 -10
  175. package/dist/classic/feed/transcript-selection.js.map +1 -1
  176. package/dist/classic/panels/confirm-panel.js +1 -0
  177. package/dist/classic/panels/confirm-panel.js.map +1 -1
  178. package/dist/classic/panels/jobs-panel.js +1 -1
  179. package/dist/classic/panels/jobs-panel.js.map +1 -1
  180. package/dist/classic/panels/plan-panel.js +1 -1
  181. package/dist/classic/panels/plan-panel.js.map +1 -1
  182. package/dist/classic/render/shell-width.js +1 -1
  183. package/dist/classic/render/shell-width.js.map +1 -1
  184. package/dist/classic/render/widest-line.d.ts +1 -0
  185. package/dist/classic/render/widest-line.js +5 -0
  186. package/dist/classic/render/widest-line.js.map +1 -0
  187. package/dist/commands/doctor.js +2 -1
  188. package/dist/commands/doctor.js.map +1 -1
  189. package/dist/index.js +5 -4
  190. package/dist/index.js.map +1 -1
  191. package/dist/instructions/scaffold.js +2 -1
  192. package/dist/instructions/scaffold.js.map +1 -1
  193. package/dist/llm/agentrouter.js +6 -11
  194. package/dist/llm/agentrouter.js.map +1 -1
  195. package/dist/llm/anthropic.js +6 -8
  196. package/dist/llm/anthropic.js.map +1 -1
  197. package/dist/llm/bynara.js +6 -10
  198. package/dist/llm/bynara.js.map +1 -1
  199. package/dist/llm/capabilities.js +5 -5
  200. package/dist/llm/capabilities.js.map +1 -1
  201. package/dist/llm/capability/state.d.ts +1 -1
  202. package/dist/llm/capability/tool-dialect.js +1 -0
  203. package/dist/llm/capability/tool-dialect.js.map +1 -1
  204. package/dist/llm/capability/vision-patterns.js +1 -0
  205. package/dist/llm/capability/vision-patterns.js.map +1 -1
  206. package/dist/llm/capability/vision-registry.js +1 -1
  207. package/dist/llm/capability/vision-registry.js.map +1 -1
  208. package/dist/llm/cline.js +3 -2
  209. package/dist/llm/cline.js.map +1 -1
  210. package/dist/llm/codex-models.d.ts +1 -1
  211. package/dist/llm/codex-models.js +11 -6
  212. package/dist/llm/codex-models.js.map +1 -1
  213. package/dist/llm/codex.js +2 -1
  214. package/dist/llm/codex.js.map +1 -1
  215. package/dist/llm/constellation.js +5 -0
  216. package/dist/llm/constellation.js.map +1 -1
  217. package/dist/llm/context-windows.js +17 -13
  218. package/dist/llm/context-windows.js.map +1 -1
  219. package/dist/llm/copilot.js +19 -21
  220. package/dist/llm/copilot.js.map +1 -1
  221. package/dist/llm/custom-providers.d.ts +2 -1
  222. package/dist/llm/custom-providers.js +16 -10
  223. package/dist/llm/custom-providers.js.map +1 -1
  224. package/dist/llm/deepseek.js +6 -11
  225. package/dist/llm/deepseek.js.map +1 -1
  226. package/dist/llm/explabs.js +8 -9
  227. package/dist/llm/explabs.js.map +1 -1
  228. package/dist/llm/fireworks.js +9 -11
  229. package/dist/llm/fireworks.js.map +1 -1
  230. package/dist/llm/free-default-model.js +5 -3
  231. package/dist/llm/free-default-model.js.map +1 -1
  232. package/dist/llm/free-model-limits.js +2 -1
  233. package/dist/llm/free-model-limits.js.map +1 -1
  234. package/dist/llm/free.js +20 -23
  235. package/dist/llm/free.js.map +1 -1
  236. package/dist/llm/freebuff-models.js +11 -2
  237. package/dist/llm/freebuff-models.js.map +1 -1
  238. package/dist/llm/freebuff.js +2 -1
  239. package/dist/llm/freebuff.js.map +1 -1
  240. package/dist/llm/generation-metrics.d.ts +11 -0
  241. package/dist/llm/generation-metrics.js +54 -0
  242. package/dist/llm/generation-metrics.js.map +1 -0
  243. package/dist/llm/generation-submission.d.ts +2 -0
  244. package/dist/llm/generation-submission.js +13 -0
  245. package/dist/llm/generation-submission.js.map +1 -0
  246. package/dist/llm/glm.js +6 -11
  247. package/dist/llm/glm.js.map +1 -1
  248. package/dist/llm/hetzner.js +9 -11
  249. package/dist/llm/hetzner.js.map +1 -1
  250. package/dist/llm/hinoki-models.d.ts +3 -0
  251. package/dist/llm/hinoki-models.js +52 -0
  252. package/dist/llm/hinoki-models.js.map +1 -0
  253. package/dist/llm/hinoki-profile.d.ts +4 -0
  254. package/dist/llm/hinoki-profile.js +58 -0
  255. package/dist/llm/hinoki-profile.js.map +1 -0
  256. package/dist/llm/hinoki.d.ts +3 -0
  257. package/dist/llm/hinoki.js +149 -0
  258. package/dist/llm/hinoki.js.map +1 -0
  259. package/dist/llm/kimi.js +6 -11
  260. package/dist/llm/kimi.js.map +1 -1
  261. package/dist/llm/kiro.js +11 -10
  262. package/dist/llm/kiro.js.map +1 -1
  263. package/dist/llm/lightning.js +6 -10
  264. package/dist/llm/lightning.js.map +1 -1
  265. package/dist/llm/merge-gateway.js +9 -10
  266. package/dist/llm/merge-gateway.js.map +1 -1
  267. package/dist/llm/meta.js +6 -10
  268. package/dist/llm/meta.js.map +1 -1
  269. package/dist/llm/mimo.js +6 -11
  270. package/dist/llm/mimo.js.map +1 -1
  271. package/dist/llm/minimax.js +6 -11
  272. package/dist/llm/minimax.js.map +1 -1
  273. package/dist/llm/mistral.js +10 -5
  274. package/dist/llm/mistral.js.map +1 -1
  275. package/dist/llm/modal.js +6 -11
  276. package/dist/llm/modal.js.map +1 -1
  277. package/dist/llm/model-discovery.d.ts +4 -1
  278. package/dist/llm/model-discovery.js +5 -2
  279. package/dist/llm/model-discovery.js.map +1 -1
  280. package/dist/llm/model-limit-store.d.ts +2 -0
  281. package/dist/llm/model-limit-store.js +44 -12
  282. package/dist/llm/model-limit-store.js.map +1 -1
  283. package/dist/llm/model-list-cache.d.ts +15 -0
  284. package/dist/llm/model-list-cache.js +55 -0
  285. package/dist/llm/model-list-cache.js.map +1 -0
  286. package/dist/llm/nvidia.js +9 -10
  287. package/dist/llm/nvidia.js.map +1 -1
  288. package/dist/llm/ollama.js +4 -0
  289. package/dist/llm/ollama.js.map +1 -1
  290. package/dist/llm/omnirush.js +10 -14
  291. package/dist/llm/omnirush.js.map +1 -1
  292. package/dist/llm/openrouter.js +6 -11
  293. package/dist/llm/openrouter.js.map +1 -1
  294. package/dist/llm/operation-usage.js +22 -5
  295. package/dist/llm/operation-usage.js.map +1 -1
  296. package/dist/llm/orcarouter.js +9 -13
  297. package/dist/llm/orcarouter.js.map +1 -1
  298. package/dist/llm/provider-identity.js +5 -0
  299. package/dist/llm/provider-identity.js.map +1 -1
  300. package/dist/llm/provider-info-text.js +24 -1
  301. package/dist/llm/provider-info-text.js.map +1 -1
  302. package/dist/llm/provider-model-layers.js +7 -0
  303. package/dist/llm/provider-model-layers.js.map +1 -1
  304. package/dist/llm/provider-profile-layers.js +5 -1
  305. package/dist/llm/provider-profile-layers.js.map +1 -1
  306. package/dist/llm/provider-profiles.d.ts +1 -0
  307. package/dist/llm/provider-profiles.js +5 -1
  308. package/dist/llm/provider-profiles.js.map +1 -1
  309. package/dist/llm/qoder/qoder.js +6 -10
  310. package/dist/llm/qoder/qoder.js.map +1 -1
  311. package/dist/llm/qwen-cloud.js +6 -9
  312. package/dist/llm/qwen-cloud.js.map +1 -1
  313. package/dist/llm/reasoning-capability.js +1 -0
  314. package/dist/llm/reasoning-capability.js.map +1 -1
  315. package/dist/llm/request-plan.js +4 -2
  316. package/dist/llm/request-plan.js.map +1 -1
  317. package/dist/llm/river-models.d.ts +1 -0
  318. package/dist/llm/river-models.js +3 -0
  319. package/dist/llm/river-models.js.map +1 -1
  320. package/dist/llm/routing/provider-selection.js +3 -0
  321. package/dist/llm/routing/provider-selection.js.map +1 -1
  322. package/dist/llm/routing/request-option-fallback.d.ts +6 -0
  323. package/dist/llm/routing/request-option-fallback.js +63 -3
  324. package/dist/llm/routing/request-option-fallback.js.map +1 -1
  325. package/dist/llm/token-usage.js +7 -2
  326. package/dist/llm/token-usage.js.map +1 -1
  327. package/dist/llm/tokenharbor.js +10 -13
  328. package/dist/llm/tokenharbor.js.map +1 -1
  329. package/dist/llm/tokenrouter.js +10 -14
  330. package/dist/llm/tokenrouter.js.map +1 -1
  331. package/dist/llm/vercel.js +12 -12
  332. package/dist/llm/vercel.js.map +1 -1
  333. package/dist/llm/wire/chat-body.js +9 -5
  334. package/dist/llm/wire/chat-body.js.map +1 -1
  335. package/dist/llm/wire/openai-stream.js +2 -1
  336. package/dist/llm/wire/openai-stream.js.map +1 -1
  337. package/dist/llm/zen-catalog.d.ts +3 -1
  338. package/dist/llm/zen-catalog.js +9 -3
  339. package/dist/llm/zen-catalog.js.map +1 -1
  340. package/dist/mcp/argument-hint.d.ts +9 -0
  341. package/dist/mcp/argument-hint.js +17 -0
  342. package/dist/mcp/argument-hint.js.map +1 -0
  343. package/dist/mcp/catalog.js +5 -5
  344. package/dist/mcp/catalog.js.map +1 -1
  345. package/dist/mcp/manager.d.ts +2 -0
  346. package/dist/mcp/manager.js +21 -1
  347. package/dist/mcp/manager.js.map +1 -1
  348. package/dist/mcp/runtime.d.ts +5 -1
  349. package/dist/mcp/runtime.js +33 -2
  350. package/dist/mcp/runtime.js.map +1 -1
  351. package/dist/noninteractive/stream-renderer.js +3 -0
  352. package/dist/noninteractive/stream-renderer.js.map +1 -1
  353. package/dist/os/runtime-error.d.ts +2 -0
  354. package/dist/os/runtime-error.js +39 -0
  355. package/dist/os/runtime-error.js.map +1 -0
  356. package/dist/prompts/embedded.js +1 -1
  357. package/dist/prompts/embedded.js.map +1 -1
  358. package/dist/prompts/index.js +21 -18
  359. package/dist/prompts/index.js.map +1 -1
  360. package/dist/prompts/system.agent.md +10 -9
  361. package/dist/rea/availability.d.ts +22 -0
  362. package/dist/rea/availability.js +82 -0
  363. package/dist/rea/availability.js.map +1 -0
  364. package/dist/rea/connection.d.ts +8 -0
  365. package/dist/rea/connection.js +12 -0
  366. package/dist/rea/connection.js.map +1 -0
  367. package/dist/rea/distribution.d.ts +13 -0
  368. package/dist/rea/distribution.js +140 -0
  369. package/dist/rea/distribution.js.map +1 -0
  370. package/dist/rea/download.d.ts +22 -0
  371. package/dist/rea/download.js +198 -0
  372. package/dist/rea/download.js.map +1 -0
  373. package/dist/rea/engine-report.d.ts +4 -0
  374. package/dist/rea/engine-report.js +77 -0
  375. package/dist/rea/engine-report.js.map +1 -0
  376. package/dist/rea/engine-status.d.ts +24 -0
  377. package/dist/rea/engine-status.js +103 -0
  378. package/dist/rea/engine-status.js.map +1 -0
  379. package/dist/rea/engines.d.ts +43 -0
  380. package/dist/rea/engines.js +160 -0
  381. package/dist/rea/engines.js.map +1 -0
  382. package/dist/rea/ghidra.d.ts +83 -0
  383. package/dist/rea/ghidra.js +316 -0
  384. package/dist/rea/ghidra.js.map +1 -0
  385. package/dist/rea/guide.d.ts +14 -0
  386. package/dist/rea/guide.js +178 -0
  387. package/dist/rea/guide.js.map +1 -0
  388. package/dist/rea/hints.d.ts +3 -0
  389. package/dist/rea/hints.js +99 -0
  390. package/dist/rea/hints.js.map +1 -0
  391. package/dist/rea/install.d.ts +10 -0
  392. package/dist/rea/install.js +173 -0
  393. package/dist/rea/install.js.map +1 -0
  394. package/dist/rea/jdk.d.ts +50 -0
  395. package/dist/rea/jdk.js +171 -0
  396. package/dist/rea/jdk.js.map +1 -0
  397. package/dist/rea/node.d.ts +22 -0
  398. package/dist/rea/node.js +150 -0
  399. package/dist/rea/node.js.map +1 -0
  400. package/dist/rea/runtime.d.ts +11 -0
  401. package/dist/rea/runtime.js +186 -0
  402. package/dist/rea/runtime.js.map +1 -0
  403. package/dist/rea/tool-index.d.ts +7 -0
  404. package/dist/rea/tool-index.js +105 -0
  405. package/dist/rea/tool-index.js.map +1 -0
  406. package/dist/rea/types.d.ts +36 -0
  407. package/dist/rea/types.js +2 -0
  408. package/dist/rea/types.js.map +1 -0
  409. package/dist/rea/workflow.d.ts +14 -0
  410. package/dist/rea/workflow.js +60 -0
  411. package/dist/rea/workflow.js.map +1 -0
  412. package/dist/rea/zip.d.ts +19 -0
  413. package/dist/rea/zip.js +257 -0
  414. package/dist/rea/zip.js.map +1 -0
  415. package/dist/safety/tool-classification.js +6 -0
  416. package/dist/safety/tool-classification.js.map +1 -1
  417. package/dist/skills/bundled-catalog.generated.d.ts +2 -0
  418. package/dist/skills/bundled-catalog.generated.js +25 -0
  419. package/dist/skills/bundled-catalog.generated.js.map +1 -0
  420. package/dist/skills/bundled-content.generated.d.ts +1 -0
  421. package/dist/skills/bundled-content.generated.js +20 -0
  422. package/dist/skills/bundled-content.generated.js.map +1 -0
  423. package/dist/skills/bundled.d.ts +4 -0
  424. package/dist/skills/bundled.js +111 -0
  425. package/dist/skills/bundled.js.map +1 -0
  426. package/dist/skills/catalog.js +7 -4
  427. package/dist/skills/catalog.js.map +1 -1
  428. package/dist/skills/discover.js +1 -0
  429. package/dist/skills/discover.js.map +1 -1
  430. package/dist/skills/registry.js +24 -16
  431. package/dist/skills/registry.js.map +1 -1
  432. package/dist/skills/types.d.ts +9 -1
  433. package/dist/skills/types.js.map +1 -1
  434. package/dist/store/config/endpoints.js +1 -0
  435. package/dist/store/config/endpoints.js.map +1 -1
  436. package/dist/store/config.js +2 -0
  437. package/dist/store/config.js.map +1 -1
  438. package/dist/store/history/jsonl-backend.d.ts +0 -1
  439. package/dist/store/history/jsonl-backend.js +3 -136
  440. package/dist/store/history/jsonl-backend.js.map +1 -1
  441. package/dist/store/history/legacy-migration.d.ts +6 -0
  442. package/dist/store/history/legacy-migration.js +127 -0
  443. package/dist/store/history/legacy-migration.js.map +1 -0
  444. package/dist/store/history/lifecycle.js +11 -2
  445. package/dist/store/history/lifecycle.js.map +1 -1
  446. package/dist/store/history/recovery.js +6 -1
  447. package/dist/store/history/recovery.js.map +1 -1
  448. package/dist/store/history/session-frames.d.ts +74 -0
  449. package/dist/store/history/session-frames.js +234 -0
  450. package/dist/store/history/session-frames.js.map +1 -0
  451. package/dist/store/history/session-index.d.ts +13 -0
  452. package/dist/store/history/session-index.js +135 -0
  453. package/dist/store/history/session-index.js.map +1 -0
  454. package/dist/store/history/session-log.d.ts +44 -0
  455. package/dist/store/history/session-log.js +386 -0
  456. package/dist/store/history/session-log.js.map +1 -0
  457. package/dist/store/history/session-paths.d.ts +11 -0
  458. package/dist/store/history/session-paths.js +35 -0
  459. package/dist/store/history/session-paths.js.map +1 -0
  460. package/dist/store/history/session-queries.js +34 -16
  461. package/dist/store/history/session-queries.js.map +1 -1
  462. package/dist/store/history/session-store.d.ts +11 -0
  463. package/dist/store/history/session-store.js +202 -0
  464. package/dist/store/history/session-store.js.map +1 -0
  465. package/dist/store/history-index.d.ts +0 -2
  466. package/dist/store/history-index.js +0 -16
  467. package/dist/store/history-index.js.map +1 -1
  468. package/dist/store/history.d.ts +2 -0
  469. package/dist/store/history.js +76 -56
  470. package/dist/store/history.js.map +1 -1
  471. package/dist/store/session-queue.d.ts +4 -0
  472. package/dist/store/session-queue.js +62 -0
  473. package/dist/store/session-queue.js.map +1 -0
  474. package/dist/store/session-workspace-activity.d.ts +4 -0
  475. package/dist/store/session-workspace-activity.js +69 -0
  476. package/dist/store/session-workspace-activity.js.map +1 -0
  477. package/dist/store/session-workspace-cleanup.d.ts +4 -0
  478. package/dist/store/session-workspace-cleanup.js +246 -0
  479. package/dist/store/session-workspace-cleanup.js.map +1 -0
  480. package/dist/store/session-workspace.js +6 -0
  481. package/dist/store/session-workspace.js.map +1 -1
  482. package/dist/tools/definitions/aggregate.js +9 -1
  483. package/dist/tools/definitions/aggregate.js.map +1 -1
  484. package/dist/tools/definitions/files.js +4 -4
  485. package/dist/tools/definitions/files.js.map +1 -1
  486. package/dist/tools/definitions/fs-read.js +2 -2
  487. package/dist/tools/definitions/fs-read.js.map +1 -1
  488. package/dist/tools/definitions/shell.js +2 -2
  489. package/dist/tools/definitions/shell.js.map +1 -1
  490. package/dist/tools/definitions.js +2 -1
  491. package/dist/tools/definitions.js.map +1 -1
  492. package/dist/tools/fs/mutations.js +1 -1
  493. package/dist/tools/fs/mutations.js.map +1 -1
  494. package/dist/tools/fs/read-input.js +33 -20
  495. package/dist/tools/fs/read-input.js.map +1 -1
  496. package/dist/tools/handlers/files-2.js +1 -1
  497. package/dist/tools/handlers/files-2.js.map +1 -1
  498. package/dist/tools/http/agents.d.ts +4 -5
  499. package/dist/tools/http/agents.js +4 -12
  500. package/dist/tools/http/agents.js.map +1 -1
  501. package/dist/tools/http/fetch.js +3 -10
  502. package/dist/tools/http/fetch.js.map +1 -1
  503. package/dist/tools/registry.d.ts +1 -0
  504. package/dist/tools/registry.js +3 -0
  505. package/dist/tools/registry.js.map +1 -1
  506. package/dist/tools/shell/artifact.d.ts +7 -0
  507. package/dist/tools/shell/artifact.js +85 -0
  508. package/dist/tools/shell/artifact.js.map +1 -0
  509. package/dist/tools/shell/capture.d.ts +1 -5
  510. package/dist/tools/shell/capture.js +1 -18
  511. package/dist/tools/shell/capture.js.map +1 -1
  512. package/dist/tools/shell/exec-attempt.js +9 -27
  513. package/dist/tools/shell/exec-attempt.js.map +1 -1
  514. package/dist/tools/shell/spawn-argv.js +7 -21
  515. package/dist/tools/shell/spawn-argv.js.map +1 -1
  516. package/dist/tools/skills.js +11 -1
  517. package/dist/tools/skills.js.map +1 -1
  518. package/dist/tui-v2/app/App.js +5 -9
  519. package/dist/tui-v2/app/App.js.map +1 -1
  520. package/dist/tui-v2/app/layout-widths.js +3 -2
  521. package/dist/tui-v2/app/layout-widths.js.map +1 -1
  522. package/dist/tui-v2/bootstrap/patch-opentui-selection.d.ts +6 -0
  523. package/dist/tui-v2/bootstrap/patch-opentui-selection.js +27 -0
  524. package/dist/tui-v2/bootstrap/patch-opentui-selection.js.map +1 -0
  525. package/dist/tui-v2/bootstrap/patch-opentui-wheel.d.ts +9 -0
  526. package/dist/tui-v2/bootstrap/patch-opentui-wheel.js +23 -0
  527. package/dist/tui-v2/bootstrap/patch-opentui-wheel.js.map +1 -0
  528. package/dist/tui-v2/bootstrap/runtime-view.js +4 -0
  529. package/dist/tui-v2/bootstrap/runtime-view.js.map +1 -1
  530. package/dist/tui-v2/bootstrap/start-tui-v2.js +8 -1
  531. package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
  532. package/dist/tui-v2/components/jobs/jobs-panel.js +1 -9
  533. package/dist/tui-v2/components/jobs/jobs-panel.js.map +1 -1
  534. package/dist/tui-v2/components/modal/confirm-modal.js +1 -0
  535. package/dist/tui-v2/components/modal/confirm-modal.js.map +1 -1
  536. package/dist/tui-v2/components/pager/pager.js +2 -2
  537. package/dist/tui-v2/components/pager/pager.js.map +1 -1
  538. package/dist/tui-v2/components/plan/plan-view.js +24 -4
  539. package/dist/tui-v2/components/plan/plan-view.js.map +1 -1
  540. package/dist/tui-v2/components/status/context-limit-chip.js +2 -2
  541. package/dist/tui-v2/components/status/status-line.js +13 -12
  542. package/dist/tui-v2/components/status/status-line.js.map +1 -1
  543. package/dist/tui-v2/components/transcript/compacted-row.js +3 -1
  544. package/dist/tui-v2/components/transcript/compacted-row.js.map +1 -1
  545. package/dist/tui-v2/components/transcript/intro-card.js +5 -8
  546. package/dist/tui-v2/components/transcript/intro-card.js.map +1 -1
  547. package/dist/tui-v2/components/transcript/linkable-text.d.ts +2 -0
  548. package/dist/tui-v2/components/transcript/linkable-text.js +22 -2
  549. package/dist/tui-v2/components/transcript/linkable-text.js.map +1 -1
  550. package/dist/tui-v2/components/transcript/pending-arguments.d.ts +6 -0
  551. package/dist/tui-v2/components/transcript/pending-arguments.js +16 -0
  552. package/dist/tui-v2/components/transcript/pending-arguments.js.map +1 -0
  553. package/dist/tui-v2/components/transcript/selection-snap.d.ts +43 -0
  554. package/dist/tui-v2/components/transcript/selection-snap.js +68 -0
  555. package/dist/tui-v2/components/transcript/selection-snap.js.map +1 -0
  556. package/dist/tui-v2/components/transcript/thinking-block.d.ts +2 -0
  557. package/dist/tui-v2/components/transcript/thinking-block.js +37 -19
  558. package/dist/tui-v2/components/transcript/thinking-block.js.map +1 -1
  559. package/dist/tui-v2/components/transcript/thinking-presentation.d.ts +0 -2
  560. package/dist/tui-v2/components/transcript/thinking-presentation.js +0 -52
  561. package/dist/tui-v2/components/transcript/thinking-presentation.js.map +1 -1
  562. package/dist/tui-v2/components/transcript/tool-card.js +4 -3
  563. package/dist/tui-v2/components/transcript/tool-card.js.map +1 -1
  564. package/dist/tui-v2/components/transcript/transcript-row.js +20 -6
  565. package/dist/tui-v2/components/transcript/transcript-row.js.map +1 -1
  566. package/dist/tui-v2/components/transcript/transcript-scroll-port.d.ts +2 -0
  567. package/dist/tui-v2/components/transcript/transcript-scroll-port.js +37 -0
  568. package/dist/tui-v2/components/transcript/transcript-scroll-port.js.map +1 -1
  569. package/dist/tui-v2/components/transcript/transcript-view.js +159 -109
  570. package/dist/tui-v2/components/transcript/transcript-view.js.map +1 -1
  571. package/dist/tui-v2/composer/composer-editor.js +2 -4
  572. package/dist/tui-v2/composer/composer-editor.js.map +1 -1
  573. package/dist/tui-v2/composer/composer-highlight.js +2 -1
  574. package/dist/tui-v2/composer/composer-highlight.js.map +1 -1
  575. package/dist/tui-v2/composer/composer-wheel.d.ts +1 -1
  576. package/dist/tui-v2/composer/composer-wheel.js +4 -4
  577. package/dist/tui-v2/composer/composer-wheel.js.map +1 -1
  578. package/dist/tui-v2/rendering/ansi-to-styled.js +16 -20
  579. package/dist/tui-v2/rendering/ansi-to-styled.js.map +1 -1
  580. package/dist/types.d.ts +10 -7
  581. package/dist/types.js +1 -0
  582. package/dist/types.js.map +1 -1
  583. package/dist/ui/mentions/expand.js +4 -0
  584. package/dist/ui/mentions/expand.js.map +1 -1
  585. package/dist/ui-core/bootstrap/fatal-diagnostics.d.ts +1 -0
  586. package/dist/ui-core/bootstrap/fatal-diagnostics.js +9 -0
  587. package/dist/ui-core/bootstrap/fatal-diagnostics.js.map +1 -0
  588. package/dist/ui-core/bootstrap/lifecycle.d.ts +4 -0
  589. package/dist/ui-core/bootstrap/lifecycle.js +27 -4
  590. package/dist/ui-core/bootstrap/lifecycle.js.map +1 -1
  591. package/dist/ui-core/commands/command-handlers.js +2 -0
  592. package/dist/ui-core/commands/command-handlers.js.map +1 -1
  593. package/dist/ui-core/commands/picker-commands.d.ts +6 -2
  594. package/dist/ui-core/commands/picker-commands.js +31 -17
  595. package/dist/ui-core/commands/picker-commands.js.map +1 -1
  596. package/dist/ui-core/commands/rea-commands.d.ts +3 -0
  597. package/dist/ui-core/commands/rea-commands.js +176 -0
  598. package/dist/ui-core/commands/rea-commands.js.map +1 -0
  599. package/dist/ui-core/commands/rea-engines-commands.d.ts +37 -0
  600. package/dist/ui-core/commands/rea-engines-commands.js +433 -0
  601. package/dist/ui-core/commands/rea-engines-commands.js.map +1 -0
  602. package/dist/ui-core/composer/completion.js +3 -0
  603. package/dist/ui-core/composer/completion.js.map +1 -1
  604. package/dist/ui-core/controllers/overlay-controller.d.ts +1 -1
  605. package/dist/ui-core/controllers/selection-controller.d.ts +2 -1
  606. package/dist/ui-core/controllers/selection-controller.js +27 -0
  607. package/dist/ui-core/controllers/selection-controller.js.map +1 -1
  608. package/dist/ui-core/layout/compute-layout.d.ts +2 -2
  609. package/dist/ui-core/layout/compute-layout.js +3 -3
  610. package/dist/ui-core/layout/compute-layout.js.map +1 -1
  611. package/dist/ui-core/motion/wheel-scroll.d.ts +9 -0
  612. package/dist/ui-core/motion/wheel-scroll.js +36 -0
  613. package/dist/ui-core/motion/wheel-scroll.js.map +1 -0
  614. package/dist/ui-core/rendering/compaction-pager-source.d.ts +4 -0
  615. package/dist/ui-core/rendering/compaction-pager-source.js +65 -0
  616. package/dist/ui-core/rendering/compaction-pager-source.js.map +1 -0
  617. package/dist/ui-core/rendering/duration.d.ts +3 -1
  618. package/dist/ui-core/rendering/duration.js +12 -3
  619. package/dist/ui-core/rendering/duration.js.map +1 -1
  620. package/dist/ui-core/rendering/incremental-strip.js +4 -1
  621. package/dist/ui-core/rendering/incremental-strip.js.map +1 -1
  622. package/dist/ui-core/rendering/intro-header.d.ts +3 -0
  623. package/dist/ui-core/rendering/intro-header.js +146 -161
  624. package/dist/ui-core/rendering/intro-header.js.map +1 -1
  625. package/dist/ui-core/rendering/job-tail-source.js +30 -2
  626. package/dist/ui-core/rendering/job-tail-source.js.map +1 -1
  627. package/dist/ui-core/rendering/markdown/bold-lines.d.ts +1 -0
  628. package/dist/ui-core/rendering/markdown/bold-lines.js +79 -0
  629. package/dist/ui-core/rendering/markdown/bold-lines.js.map +1 -0
  630. package/dist/ui-core/rendering/markdown.d.ts +1 -0
  631. package/dist/ui-core/rendering/markdown.js +19 -13
  632. package/dist/ui-core/rendering/markdown.js.map +1 -1
  633. package/dist/ui-core/rendering/open-tool-output.d.ts +1 -0
  634. package/dist/ui-core/rendering/open-tool-output.js +8 -0
  635. package/dist/ui-core/rendering/open-tool-output.js.map +1 -1
  636. package/dist/ui-core/rendering/pending-arguments.d.ts +2 -0
  637. package/dist/ui-core/rendering/pending-arguments.js +6 -0
  638. package/dist/ui-core/rendering/pending-arguments.js.map +1 -0
  639. package/dist/ui-core/rendering/plan-view.js +0 -4
  640. package/dist/ui-core/rendering/plan-view.js.map +1 -1
  641. package/dist/ui-core/rendering/render-markdown-lines.d.ts +1 -0
  642. package/dist/ui-core/rendering/render-markdown-lines.js +1 -0
  643. package/dist/ui-core/rendering/render-markdown-lines.js.map +1 -1
  644. package/dist/ui-core/rendering/streaming-markdown.js +1 -1
  645. package/dist/ui-core/rendering/streaming-markdown.js.map +1 -1
  646. package/dist/ui-core/rendering/strip-tool-surfaces.js +7 -7
  647. package/dist/ui-core/rendering/strip-tool-surfaces.js.map +1 -1
  648. package/dist/ui-core/rendering/text-width.d.ts +1 -0
  649. package/dist/ui-core/rendering/text-width.js +22 -2
  650. package/dist/ui-core/rendering/text-width.js.map +1 -1
  651. package/dist/ui-core/rendering/thinking-tail.js +6 -2
  652. package/dist/ui-core/rendering/thinking-tail.js.map +1 -1
  653. package/dist/ui-core/rendering/tool-output-pager-source.d.ts +4 -0
  654. package/dist/ui-core/rendering/tool-output-pager-source.js +94 -0
  655. package/dist/ui-core/rendering/tool-output-pager-source.js.map +1 -0
  656. package/dist/ui-core/rendering/tool-presenter.js +47 -64
  657. package/dist/ui-core/rendering/tool-presenter.js.map +1 -1
  658. package/dist/ui-core/state/hydrate/classic-transcript.js +2 -0
  659. package/dist/ui-core/state/hydrate/classic-transcript.js.map +1 -1
  660. package/dist/ui-core/state/semantic-document.d.ts +4 -0
  661. package/dist/ui-core/state/semantic-document.js.map +1 -1
  662. package/dist/ui-core/state/transcript/apply-app-event.d.ts +2 -2
  663. package/dist/ui-core/state/transcript/apply-app-event.js +164 -384
  664. package/dist/ui-core/state/transcript/apply-app-event.js.map +1 -1
  665. package/dist/ui-core/state/transcript/tool-lifecycle.d.ts +19 -0
  666. package/dist/ui-core/state/transcript/tool-lifecycle.js +102 -0
  667. package/dist/ui-core/state/transcript/tool-lifecycle.js.map +1 -0
  668. package/dist/ui-core/state/transcript-hydrate.js +3 -0
  669. package/dist/ui-core/state/transcript-hydrate.js.map +1 -1
  670. package/dist/ui-core/state/transcript-types.d.ts +3 -0
  671. package/dist/ui-core/state/transcript-types.js.map +1 -1
  672. package/dist/ui-core/state/transcript-window.d.ts +9 -0
  673. package/dist/ui-core/state/transcript-window.js +9 -0
  674. package/dist/ui-core/state/transcript-window.js.map +1 -1
  675. package/dist/version.generated.d.ts +2 -2
  676. package/dist/version.generated.js +2 -2
  677. package/dist/version.generated.js.map +1 -1
  678. package/guides/security-skill.md +59 -0
  679. package/package.json +11 -3
  680. package/resources/skills/clai-superman-skill/SKILL.md +73 -0
  681. package/resources/skills/clai-superman-skill/references/ai-agents.md +51 -0
  682. package/resources/skills/clai-superman-skill/references/cloud-platform.md +48 -0
  683. package/resources/skills/clai-superman-skill/references/code-supply-chain.md +61 -0
  684. package/resources/skills/clai-superman-skill/references/crypto-contracts.md +46 -0
  685. package/resources/skills/clai-superman-skill/references/evidence-reporting.md +86 -0
  686. package/resources/skills/clai-superman-skill/references/identity-ad.md +51 -0
  687. package/resources/skills/clai-superman-skill/references/mobile-client.md +52 -0
  688. package/resources/skills/clai-superman-skill/references/novel-research.md +97 -0
  689. package/resources/skills/clai-superman-skill/references/operations.md +109 -0
  690. package/resources/skills/clai-superman-skill/references/security-operations.md +55 -0
  691. package/resources/skills/clai-superman-skill/references/sources.md +51 -0
  692. package/resources/skills/clai-superman-skill/references/systems-protocols.md +52 -0
  693. package/resources/skills/clai-superman-skill/references/web-api.md +65 -0
  694. package/resources/skills/clai-superman-skill/references/wireless-iot-ot.md +49 -0
  695. package/test/fixtures/security-skill-scenarios.json +191 -0
  696. package/dist/agent/context/compaction-work-history.d.ts +0 -13
  697. package/dist/agent/context/compaction-work-history.js +0 -150
  698. package/dist/agent/context/compaction-work-history.js.map +0 -1
  699. package/dist/tui-v2/components/transcript/transcript-scrollbar.d.ts +0 -29
  700. package/dist/tui-v2/components/transcript/transcript-scrollbar.js +0 -211
  701. package/dist/tui-v2/components/transcript/transcript-scrollbar.js.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,119 @@
1
+ # Changelog
2
+
3
+ ## v5.1.0 — 2026-10-23
4
+
5
+ This release adds the Hinoki provider and a bundled, on-demand security skill, improves skill recovery after compaction, and fixes tool progress and terminal rendering. It covers all changes since **v5.0.0**.
6
+
7
+ ### Hinoki provider
8
+
9
+ - Add `hinoki` with the default `hinoki-offensive` model, authenticated model discovery, streaming answers and reasoning, function calls, and image support. Configure it with `clai set hinoki` and `clai use hinoki`, or `HINOKI_API_KEY`; `HINOKI_BASE_URL` and saved endpoints can override the default URL.
10
+ - Use published model metadata for context/output limits, tools, vision, and reasoning controls. Retain learned limits between sessions, coalesce concurrent catalog requests, and isolate caches by credential and endpoint. Temporary catalog failures retain the last successful result with a retry cooldown; authentication errors remain visible for key rotation.
11
+ - Preserve complete conversation and tool-result replay, per-session cache affinity, shared key failover, and measured cached-input, cache-write, and reasoning-token usage when the API reports it. Cache hits and workspace credit balances are not inferred.
12
+
13
+ ### Bundled skills and compaction recovery
14
+
15
+ - Ship `clai-superman-skill`, an on-demand security investigation library covering web/API, identity, cloud, mobile, native systems, wireless/OT, AI agents, supply chains, and related research workflows. Include its usage guide and evaluation scenarios in the npm package.
16
+ - Discover bundled skill metadata without eagerly loading reference content. Embed the library in standalone binaries and materialize its files only when loaded. Project, user, and custom-root skills with the same name continue to override the bundle.
17
+ - Preserve a bounded index of loaded skills and previously read references through both summarized and mechanical compaction. Tell the agent to reload still-relevant instructions when their full content has left live context, rather than treating a historical load marker as sufficient.
18
+ - Allow necessary skill reloads after compaction without authorizing replay of side-effecting tool sequences. Keep stable prompt/tool prefixes and cache affinity intact when loading or recovering guidance.
19
+
20
+ ### Tool progress and file reads
21
+
22
+ - Show a pending tool card as soon as the provider identifies a streamed call, before its arguments finish. Animate argument preparation in both interfaces, stop the thinking timer at the tool boundary, and update the same card when complete arguments arrive and execution begins.
23
+ - Reconcile parallel calls by wire ID or stream order, deduplicate legacy progress signals, and settle incomplete previews on cancellation, errors, or retry. Partial argument bytes are not displayed, and an unfinished preview is never recorded as a successful tool execution.
24
+ - Use one `fs.read` input parser across execution, tool schemas, argument display, outcome handling, and read-only subagents. Normalize unambiguous single-file and multi-file inputs while rejecting conflicting paths, ranges, and ambiguous filter placement with actionable errors.
25
+
26
+ ### Terminal rendering and responsiveness
27
+
28
+ - Make wheel scrolling in Classic and OpenTUI follow current input instead of replaying a long frame-by-frame backlog. Preserve single-notch precision, catch up after delayed frames, and cancel remaining motion on reversal, boundaries, and explicit jumps.
29
+ - Keep clipped artifact paths and other one-row text stable while the transcript scrolls. Middle-clip long whole-text links to preserve both ends without losing their target.
30
+ - Pin the OpenTUI status line to the terminal bottom across viewport resizes, and restore the trailing gap after turn summaries.
31
+ - Restore a dedicated version row on startup cards in both interfaces, including the compact `ver` label at narrow widths.
32
+ - Keep bold reasoning titles on their own rows in both interfaces without changing ordinary assistant emphasis or losing streamed markdown consistency.
33
+ - Color Responder-owned plan rows by task state, matching their glyphs and phase chips. Adjust split and overlay pane widths to retain a clean gutter.
34
+
35
+ ### Validation and packaging
36
+
37
+ - Check generated bundled-skill content for drift during CI and normal builds, and include it in native compilation.
38
+ - Expand regressions for Hinoki routing/catalogs/streaming, skill discovery and packaging, cache continuity through compaction, pending tool lifecycles, file-read parsing, real terminal geometry, scrolling, and plan rendering.
39
+ - Repair catalog, updater, snapshot, and loaded-machine timing regressions so the release remains gated on the complete cross-platform CI suite.
40
+
41
+ ### Upgrade notes
42
+
43
+ - No configuration or session migration is required for this release. Existing providers and user/project skills remain supported.
44
+ - Hinoki requires its own API key; generation is charged against the provider's workspace credits. See [PROVIDERS.md](https://github.com/pentoshi007/clai/blob/v5.1.0/PROVIDERS.md#hinoki) for setup and capability details.
45
+ - The bundled security skill loads on demand and does not grant extra tool permissions or change engagement scope. Override it through a normal project/user/custom skill, not by editing its generated cache. See the [security skill guide](https://github.com/pentoshi007/clai/blob/v5.1.0/guides/security-skill.md).
46
+
47
+ [Full comparison since v5.0.0](https://github.com/pentoshi007/clai/compare/v5.0.0...v5.1.0)
48
+
49
+ ## v5.0.0 — 2026-10-22
50
+
51
+ This release covers all changes since **v4.19.0**, including the REA integration, session and interface improvements, provider fixes, and the reliability work below.
52
+
53
+ ### Accurate completion statistics
54
+
55
+ - Show output tokens per second alongside elapsed time, file changes, and `/changes` in Classic and OpenTUI, including narrow layouts and restored transcripts.
56
+ - Calculate TPS from reported output tokens and model-active generation time across foreground calls. Tool execution, user waits, auxiliary calls, and compaction do not inflate the rate; reasoning tokens are not counted twice.
57
+ - Preserve earlier valid measurements when a later generation is interrupted. Aborted turns retain measured TPS, and exact partial usage is included when the provider reports it. Missing usage is never replaced with guessed token counts.
58
+
59
+ ### Live output and durable queued prompts
60
+
61
+ - Keep tool-output and job pagers live in both interfaces, following streamed output, spool replacement, final artifacts, externally appended job logs, and log rotation.
62
+ - Preserve paused scrolling when output completes, with explicit follow controls, bounded reads, redacted output, and cleanup of subscriptions and file watchers.
63
+ - Stream the OpenTUI compaction pager through progress, replacement, final summaries, and failures instead of opening a frozen snapshot.
64
+ - Persist unsent queued prompts per session with validated, redacted, atomic storage. Recover them after crashes, normal shutdown, session switches, and composer editing.
65
+ - Remove a queued prompt only after foreground model submission is acknowledged. Pre-submission failures retain and pause the prompt rather than silently losing it or retrying indefinitely. Private/no-history sessions do not persist the queue.
66
+
67
+ ### On-demand reverse engineering with REA
68
+
69
+ - Add managed REA installation, updates, connection controls, and status, with `@rea`, `/rea <task>`, and an in-app `/rea guide` in both interfaces.
70
+ - Attach a version-matched, grouped tool index and workflow only when needed, preserving the stable system prompt and native tool catalog. Indicate tools that need an open target, an analysis engine, or unavailable prerequisites.
71
+ - Add explicit user-run `/rea engines` status, install, use, and remove workflows for Ghidra, Java, and configured external engines. The agent cannot install analysis engines on its own.
72
+ - Harden downloads with trusted HTTPS hosts, redirect validation, published SHA-256 checks, streamed size limits, stall detection, and disk-space checks. Reject unsafe archive entries and corrupted extraction.
73
+ - Improve macOS, Linux x64/ARM64, and Windows installation behavior, including native decompiler builds where required, Windows path and rename handling, stale staging cleanup, selected-engine environment precedence, and clear unsupported-platform guidance.
74
+ - Improve cancellation, reconnect sequencing, staged-update version reporting, installation contention messages, strict argument hints, exact tool lookup, and lazy archive loading.
75
+
76
+ ### Sessions, compaction, and terminal interfaces
77
+
78
+ - Store sessions in individual append-only delta logs, automatically importing legacy `history.jsonl` while preserving the original file. Keep rejected frames separately and avoid unnecessary history reloads.
79
+ - Rebuild compaction memory around the active goal, scoped instructions, gathered context, completed work, next steps, relevant files, genuine issues, and the latest user prompts. Preserve inherited instruction scope and stable replay prefixes.
80
+ - Reduce per-frame transcript work and smooth wheel scrolling in both interfaces. Fix OpenTUI wheel stalls, duplicate acceleration, window-update races, and final-tool-card reachability without discarding saved history.
81
+ - Refresh startup cards with clearer mode and permission badges, responsive labels, a consolidated version/welcome row, and correct provider/model pairing in Classic.
82
+ - Improve whole-cell mouse selection, padding-origin drags, selectable startup and plan content, and plain-click behavior. Remove the transcript scrollbar.
83
+ - Render markdown in completed and streaming reasoning, including emphasis and fenced code, with incremental caches. Improve status spacing, context chips, and tool durations.
84
+ - Print large piped `history --show` output completely under Bun and regenerate the README preview from the real OpenTUI renderer.
85
+
86
+ ### Providers and agent reliability
87
+
88
+ - Cache model lists for two minutes instead of up to thirty; never cache empty or fallback lists. Add `/model refresh` and `/models refresh [filter]`, bypass stale/in-flight results, and identify unavailable live catalogs accurately.
89
+ - Size reasoning output budgets from learned, live, remembered, or documented model limits, up to 131,072 tokens where supported. Preserve context fit and learn actual output caps from provider rejections with a bounded retry.
90
+ - Send a stable per-session River `prompt_cache_key`, preserve DeepSeek reasoning on tool-bearing requests, and derive Free/Zen context limits from the live catalog.
91
+ - Recover from malformed DSML tool calls rather than terminating the turn.
92
+ - Allow `http.fetch` to reach private, loopback, CGNAT, and metadata addresses while retaining engagement-scope enforcement.
93
+ - Recover from asynchronous shell artifact open, write, and flush failures without crashing Bun or discarding bounded output. Surface actionable storage warnings and fatal-shutdown diagnostics.
94
+ - Clean recognized session scratch folders after ten days of inactivity, checking at most daily across processes. Protect active sessions, recently modified files, and symlink targets; leave saved conversations and global/custom artifact retention unchanged. Compare expiry conservatively at millisecond precision so filesystem timestamp rounding cannot delete a folder at the exact ten-day boundary.
95
+
96
+ ### Safer tools and agent guidance
97
+
98
+ - Allow `fs.edit` replacements of `""` to delete exact matching text. Keep empty search text invalid with actionable guidance rather than a generic argument error.
99
+ - Clarify exact current `oldText`, whitespace and line endings, safe creation/insertion alternatives, stale-preview risks, and the requirement to re-read after a no-match result.
100
+ - Require Responder delegation for finite work expected to exceed four to five minutes, including long suites, builds, scans, and CI watches. Keep interactive sessions in terminal tools and persistent servers/watchers in named normal background jobs.
101
+ - Preserve useful prompt safeguards and raise the native prompt-overhead guard to 23,000 estimated tokens.
102
+ - Keep deliverables out of scratch directories and avoid adopting unrelated same-named projects. Scope persistent instructions to the actual project while preserving cross-turn prompt-cache prefixes.
103
+ - Prevent MCP fuzzy matching from overriding built-in tool names or wire spellings, preserving built-in confirmation and parallel-safety rules.
104
+
105
+ ### Validation and distribution
106
+
107
+ - Expand regressions for provider cancellation and exact TPS, both terminal interfaces, live pagers, queue submission/restart/shutdown behavior, atomic storage, tool edits, prompt variants, cache stability, and platform-specific REA behavior.
108
+ - Isolate test home directories and disable the real keychain during tests so placeholder provider keys cannot overwrite developer credentials.
109
+ - Harden CI checkout credentials and require SHA-256 evidence in the REA smoke test.
110
+ - Synchronize the v5 version across runtime metadata, npm lockfile, Homebrew and Scoop templates, and include this changelog in the npm package.
111
+
112
+ ### Upgrade notes
113
+
114
+ - Existing configuration remains supported; legacy session history is imported automatically and retained.
115
+ - Queued-prompt persistence does not promise distributed exactly-once delivery across a crash between remote acceptance and local acknowledgement.
116
+ - TPS is omitted when exact provider usage is unavailable rather than displaying a fabricated rate.
117
+ - REA engine setup remains an explicit user action; platform prerequisites and limitations are documented in [REA.md](REA.md).
118
+
119
+ [Full comparison since v4.19.0](https://github.com/pentoshi007/clai/compare/v4.19.0...v5.0.0)
package/PROVIDERS.md CHANGED
@@ -110,6 +110,7 @@ An environment credential is also used directly when no stored credentials take
110
110
  | ExpLabs | `explabs` | `EXPLABS_API_KEY` |
111
111
  | Fireworks | `fireworks` | `FIREWORKS_API_KEY` |
112
112
  | Hetzner | `hetzner` | `HETZNER_API_KEY` |
113
+ | Hinoki | `hinoki` | `HINOKI_API_KEY` |
113
114
  | Lightning AI | `lightning` | `LIGHTNING_API_KEY` |
114
115
  | Merge Gateway | `merge-gateway` | `MERGE_GATEWAY_API_KEY` |
115
116
  | Meta Model API | `meta` | `MODEL_API_KEY` |
@@ -125,14 +126,26 @@ For model choice, use `/model` or `clai model <name>`. Use the `/provider` picke
125
126
 
126
127
  The `free` integration discovers free models from two gateways: `free-1/<model>` uses [OpenCode Zen](https://opencode.ai/docs/zen/), and `free-2/<model>` uses [Kilo](https://kilo.ai/docs/gateway/api-reference). Model availability can change independently at each gateway. Zen's Jev decision models use the separate System One API and are omitted from the chat model picker.
127
128
 
128
- Kilo's model catalog supplies context and output limits directly. Zen's model list currently omits those limits, so clai fills missing values from the exact model entry in the OpenCode provider catalog on [Models.dev](https://github.com/anomalyco/models.dev#api). Discovery follows live model IDs, including newly added models, without a clai update or a hardcoded limit entry. Values reported by the gateway take precedence. The two sources keep separate limits even when model names match; older unprefixed Zen model selections also use the discovered limits.
129
+ Kilo's model catalog supplies context and output limits directly. Zen models are discovered from the live [OpenCode provider catalog](https://models.opencode.ai/api.json): non-deprecated, zero-cost entries determine the list, including models omitted from Zen's `/models` response. Missing gateway limits come from each exact catalog entry, without per-model allowlists, context pins, or upstream model-name guesses. Values reported by the gateway take precedence. The two sources keep separate limits even when model names match; older unprefixed Zen model selections also use the discovered limits.
129
130
 
130
- Discovered limits are cached for 30 minutes and retained locally for later sessions. A newly discovered Zen model ID can trigger an earlier metadata refresh; retries for unpublished limits or failed lookups have a one-minute cooldown. When discovery is unavailable, clai keeps previously learned limits, then uses its model table or the 200,000-token default if no limit is known. A 200k context can also be an actual gateway limit, rather than a fallback. Use `/context` to inspect the selected session's context budget.
131
+ Discovered limits are cached for 30 minutes and retained locally for later sessions. A newly discovered Zen model ID can trigger an earlier metadata refresh; retries for unpublished limits or failed lookups have a one-minute cooldown. For Zen only, a published 200,000-token context is configured as 250,000 tokens in clai; every other published limit is used unchanged. This is a clai policy, not a guarantee that the gateway accepts more than its published limit. When discovery is unavailable, clai keeps previously learned limits; unknown Zen limits use the conservative 200,000-token default, not the upstream model table. Explicit session context overrides remain available. Use `/context` to inspect the selected session's context budget.
131
132
 
132
133
  Agent turns retry temporary HTTP 429 failures up to four times, with visible waits of 5, 8, 10, and 15 seconds. This includes gateway responses that report an unavailable upstream endpoint. Shorter provider retry hints can shorten a wait. Standalone requests allow three retries by default.
133
134
 
134
135
  Retries preserve the conversation and tool definitions; cancelling the turn cancels the wait. Explicit billing or insufficient account quota errors require an account or provider change. If the gateway remains unavailable after the retry budget, select another model with `/model` or provider with `/provider`. Cross-provider fallback follows `/fallback` and `/freeonly` settings.
135
136
 
137
+ ### Hinoki
138
+
139
+ Configure `clai set hinoki` and `clai use hinoki`, or set `HINOKI_API_KEY`. Existing `hinoki` credentials in `~/.clai/keys.json`, including multiple key slots, use the same selection, disabled-key handling, cooldowns, and failover as other providers. The default endpoint is `https://inference.hinoki.security/v1`, and the default model is `hinoki-offensive`. `HINOKI_BASE_URL` or a saved endpoint can override the URL.
140
+
141
+ `/model` discovers the authenticated `/models` catalog. Published context/output limits, vision, tools, and reasoning metadata take precedence over fallback capabilities. Context limits are retained locally for later sessions. Generation reuses the catalog for five minutes; explicit model discovery refreshes it. Concurrent reads are coalesced and caches are isolated by key and endpoint. Temporary failures keep the last successful route catalog with a one-minute retry cooldown; authentication failures remain visible for shared key rotation.
142
+
143
+ `/effort` uses advertised or runtime-learned settings; when metadata is absent, the endpoint's verified effort vocabulary is `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. These are accepted API controls, not a guarantee of visible reasoning at every level. Returned reasoning streams separately from the answer. Hidden reasoning-token counts still appear in session usage. Images and function calls are supported by `hinoki-offensive`; future models follow their catalog metadata and shared runtime capability handling.
144
+
145
+ The integration uses Chat Completions for streaming and sends the full conversation, function calls, and tool results on every request. It never relies on saved responses or `previous_response_id`. Stable conversation/tool prefixes and a hashed per-session `prompt_cache_key` preserve cache affinity; cache hits depend on Hinoki's upstream infrastructure and cannot be guaranteed. Subagents and auxiliary requests retain their separate shared affinity.
146
+
147
+ `/usage` reports measured session input, output, total, cached-input, cache-write, and reasoning tokens when returned by the API, including trailing usage-only stream events. Unknown counters are not fabricated. Workspace credit balances are not available through this integration; use Hinoki's workspace settings for those. API usage is charged against workspace credits.
148
+
136
149
  ### Constellation Gate
137
150
 
138
151
  Create a `sk-gw-…` key in the [Gate dashboard](https://app.constellationgate.ai/), then run `clai set constellation` and `clai use constellation`, or set `GATE_API_KEY`. Aliases include `gate`, `constellationgate`, and `constellation-gate`. The integration uses [pay-through-Gate authentication](https://docs.constellationgate.ai/getting-started/authentication/), not BYOK upstream headers; prepaid balance and model access rules apply. Key verification sends a one-token request because the catalog is public and does not validate credentials.
package/REA.md ADDED
@@ -0,0 +1,96 @@
1
+ # REA: Reverse Engineer Anything
2
+
3
+ clai integrates the official [morluto/rea](https://github.com/morluto/rea) project as an on-demand capability. Use `/rea` in either terminal interface to open its picker.
4
+
5
+ | Command | Effect |
6
+ | --- | --- |
7
+ | `/rea install` | Install the latest official `rea-agents` package privately for clai. |
8
+ | `/rea setup` | Install if needed and connect clai's managed REA server. |
9
+ | `/rea update` | Verify and stage the latest release without interrupting an existing analysis. |
10
+ | `/rea use` | Connect if necessary and insert an editable `@rea` token in your draft. |
11
+ | `/rea on` | Enable REA for the session without editing the draft. |
12
+ | `/rea off` | Stop only clai's managed REA server. |
13
+ | `/rea status` | Check installation, connection and maintenance state without starting a server. |
14
+ | `/rea reconnect` | Reconnect or adopt an update when it is safe to discard the current analysis connection. |
15
+ | `/rea guide` | Open the usage guide in a markdown pager: commands, how the agent uses REA, supported targets and prerequisites for your OS, permissions, resource use and troubleshooting. |
16
+ | `/rea engines` | Show which analysis engines (Ghidra, Hopper, IDA, Kuna) are ready on this machine and the exact command that fixes each one that is not. |
17
+ | `/rea engines install ghidra` | After a confirmation, download the official Ghidra release and make it usable by REA. |
18
+ | `/rea engines install java` | After a confirmation, install a private JDK 21 for REA's server when Java is what is missing. |
19
+ | `/rea engines use <engine> <location>` | Use an installation you already have: a Ghidra folder, a JDK home, the Hopper launcher, an IDA MCP registration file or a Kuna executable. |
20
+ | `/rea engines remove <engine>` | Forget an engine; clai asks before deleting anything it installed. |
21
+ | `/rea <task>` | Submit `@rea <task>`, for example `/rea inspect this Electron app`. |
22
+
23
+ `/rea` is the command that opens these options; `@rea` is the token that attaches REA to a prompt. Type `@rea` anywhere in a normal prompt. The token is highlighted in both composers, like `@mcp:` and skill mentions, and is never treated as a file (attach a file that is really named `rea` as `@./rea`). When a turn contains `@rea`, clai connects an installed REA before the model is called and gives the model the workflow and the tool index described below; if REA is not installed, the model is told to run `rea.manage action=setup`. The agent can also choose REA through `rea.manage` when the task warrants it; no manual activation is required. Installation and agent-initiated state changes use the normal permission policy. Ask/plan mode can inspect status and guidance but cannot install or change REA state.
24
+
25
+ ## Installation without npm or npx
26
+
27
+ The installer uses clai's existing JavaScript runtime and HTTPS APIs; it does not invoke a shell, Homebrew, curl, PowerShell, tar, unzip, npm or npx from PATH. A compatible existing Node installation with its npm CLI is reused, looked up in this order: `CLAI_REA_NODE`, the Node that is running clai, then `node` on PATH. Otherwise clai downloads an official Node 24 LTS runtime with npm into its private installation. The native compiled clai binary therefore does not require a preinstalled Node toolchain.
28
+
29
+ A compatible Node is 22.19+, 24.15+ or 26+ (upstream REA also accepts 24.11 to 24.14, but SQLite inspection needs 24.15+ or 26+). `CLAI_REA_NODE` must point at the `node` executable and is read when REA is installed; to move an existing installation to a different Node, remove `current.json` and run `/rea setup`. Installation is cancellable with Esc from either interface, and a download is abandoned after 60 seconds without data rather than after a fixed total time, so slow links can finish.
30
+
31
+ Supported portable targets are macOS, Linux and Windows on x64/ARM64, subject to the official Node release's OS/libc support. nodejs.org does not publish Linux musl builds (Alpine), so install Node with the system package manager there. Unavailable architectures/builds produce an error that names the required Node versions and `CLAI_REA_NODE`, not an incompatible executable. Native engine support is a separate upstream constraint.
32
+
33
+ Files live under `~/.clai/tools/rea` (or `$CLAI_DATA_DIR/tools/rea`). Node archives are checked against the official SHA-256 manifest; REA/npm tarballs use registry SHA-512 integrity. npm verifies dependency integrity, lifecycle scripts are disabled, and the install uses isolated registry/config/cache settings. Package acquisition requires access to `nodejs.org` and `registry.npmjs.org` as applicable. TLS/registry checksum verification is not an independent publisher-signature guarantee.
34
+
35
+ A staged release is published only after its launcher reports the expected version, and the pointer file is replaced atomically (retrying briefly on Windows when another process holds it). Failures leave the previous release intact. Concurrent maintenance is serialized across processes and deduplicated within a process; a second clai session that waits too long is told that another session is installing. The current and previous releases are always kept so running MCP processes are not broken by an update; reconnect explicitly when ready. Releases older than that, including leftovers from interrupted installs, are removed once they are seven days old. An install takes about 250 MB with an existing Node and about 450 MB when clai also downloads one (the npm cache is shared across releases). Setup never changes Claude Code, Codex, other clients' registrations, skills, or the project's MCP configuration.
36
+
37
+ ## Efficient agent use
38
+
39
+ REA is for shipped artifacts, decompilation, JavaScript/Electron applications, managed assemblies, Android, firmware, saved captures and requested runtime evidence—not ordinary source-repository reading.
40
+
41
+ Only one small `rea.manage` tool is permanently advertised. Installing does not start a server. Enabling registers `clai-rea` for the current runtime, preserves other selected MCP servers, and connects once. Repeated enables reuse the analysis. REA's tools are not added to the provider's native tool catalog; the agent calls them through `mcp.call`.
42
+
43
+ On `@rea`, on enable and on a `guide` request the model receives, once per conversation, a workflow of about 4,200 characters, an `ENGINE:` line and a version-matched index generated from the live catalog: every tool name, grouped by verb, with its required arguments, `~` where the tool accepts `detail` and `!` where it changes state or the target (about 8,300 characters for REA 6.7.0's 207 tools, bounded at 10,000). The index lets the agent call tools directly; `mcp.tools` with an exact tool name returns just that tool's full schema for optional fields and structured arguments. REA schemas are strict, so an argument a tool does not list is rejected and clai appends the accepted argument names to the error. The context is sent once per conversation: later turns that repeat `@rea` reuse it, and it is sent again, once, only if it changed (for example after you install an engine and reconnect).
44
+
45
+ So that the agent does not call tools that cannot work, clai asks REA once per connection (one `binary_session` call, about 2 seconds and 50 KB, not repeated) which tools need an open target, an analysis engine or a missing prerequisite, and marks the index: `#` acts on the binary opened by `open_binary` and takes no path, `^` also needs an analysis engine, `%` is unavailable on this machine. The `ENGINE:` line says which engines are ready. When a call still fails, clai replaces REA's long machine-readable error with a short instruction: pass no `path` to a `#` tool and call `open_binary` first; thin a universal Mach-O to one slice with `lipo` before Ghidra or Kuna can read it; or, when no engine is ready, do not retry and tell the user to run `/rea engines`. If the availability report cannot be read, the plain index is used. Repeating `enable` on a live connection returns it again on request, without restarting anything. The always-advertised `rea.manage` description is kept to about 450 characters because it is sent with every request. The long human-oriented usage guide is shown only by `/rea guide` and is never sent to the model. Version-matched detailed workflow references remain on disk for focused reading. Prefer summaries, retained Evidence IDs, selected fields and bounded pages instead of repeating analysis or requesting full results. A host timeout does not establish that server work stopped: inspect state/Evidence before retrying. Inspect the actual current schema or returned remediation rather than guessing arguments or reinstalling.
46
+
47
+ REA activation never rewrites the stable system prompt, native tool schemas, or prior messages. State and workflow changes enter the append-only conversation context. Cache-prefix regression tests cover installation, activation, discovery, calls, update, reconnect, disable and subsequent composer selection in both native/text tool modes and multiple provider wire formats. Provider cache eviction, compaction and switching providers/models remain independent of this guarantee.
48
+
49
+ ## Analysis engines
50
+
51
+ Static JavaScript and Electron inspection, managed (.NET) assemblies, archives, Mach-O headers, plists, signatures and metadata need no engine. Native decompilation (procedures, pseudocode, strings, cross-references, assembly) needs one of Ghidra, Hopper, IDA or Kuna, and REA does not ship any of them.
52
+
53
+ Engines are installed by you, never by the agent. `/rea engines` shows what is ready and what to run, and `/rea setup` points at it when it connects REA with no engine ready. `install` shows what it will download and where it will write (press `ctrl+o` for the full plan), asks for confirmation, shows progress and can be cancelled with Esc; `remove` asks before deleting anything clai installed, reconnects REA first so nothing is still using the files, refuses while a turn is running with REA connected, and says so if a folder could not be deleted (on Windows a folder that REA's Ghidra has open can be neither moved nor removed). The agent's workflow tells it not to install or configure an engine and to send you to `/rea engines` instead, and `rea.manage` has no engine action. Only one engine operation runs at a time. If REA is connected and idle when an install finishes, clai reconnects it so the new engine is used straight away; the engine is verified with REA before the install is reported as done.
54
+
55
+ | System | `install ghidra` | `install java` |
56
+ | --- | --- | --- |
57
+ | macOS arm64 and x64 | Yes. Ghidra does not ship a macOS decompiler, so clai builds it once (one to three minutes; needs the Xcode Command Line Tools). | Yes |
58
+ | Linux x64 | Yes; the decompiler is in the download. | Yes (glibc) |
59
+ | Linux arm64 | Yes; builds the decompiler once (needs make, g++ and bison). | Yes (glibc) |
60
+ | Windows x64 | Yes; the decompiler is in the download. REA's Windows Ghidra support is experimental upstream. | Yes |
61
+ | Anything else (Windows arm64, Alpine and other musl Linux, 32-bit) | Not offered; `/rea engines` says so and why. Use `/rea engines use ghidra <folder>` with your own installation. | Not offered for musl; use `/rea engines use java <JDK home>` |
62
+
63
+ Hopper is a commercial macOS and Linux application and Kuna is not available on Windows; clai does not install either. IDA needs your own installation and an MCP registration file. These are connected with `/rea engines use`. Android, firmware, capture and similar tools (JADX, apktool, binwalk, tshark and others) have their own prerequisites; `/rea engines` lists the ones that block tools on your machine with the fix REA reports, and clai does not install them.
64
+
65
+ What `install ghidra` does:
66
+
67
+ - Resolves the newest Ghidra 12.1.x release on GitHub (the series REA 6.7.0 needs) and refuses to continue unless GitHub publishes a SHA-256 for the download. Downloads are HTTPS only, limited to `github.com`, `*.githubusercontent.com`, `api.github.com` and `api.adoptium.net`, with every redirect re-checked, a size limit and a 60-second stall guard.
68
+ - Checks free disk space first (about 570 MB to download, 1.6 GB while installing and 900 MB afterwards), extracts the archive itself (no `unzip`), and rejects absolute paths, `..`, symlinks, encrypted or ZIP64 entries and checksum mismatches.
69
+ - Builds the native decompiler where needed with `make` using at most four jobs, with a 30-minute limit. It checks for the build tools before downloading anything and tells you what to install.
70
+ - Stages everything in a temporary folder, moves it into `~/.clai/tools/ghidra/<version>` only when it is complete, then asks REA whether Ghidra is usable. A failed or cancelled install leaves nothing behind and keeps the previous version; after a successful one, older versions that clai installed are removed.
71
+
72
+ Ghidra also needs a JDK 21 or newer. `install ghidra` does not change your system Java: if REA reports that Java is missing or too old, clai offers `install java`, which puts Eclipse Temurin 21 (about 200 MB, SHA-256 verified) in `~/.clai/tools/jdk/` and uses it for REA's server only.
73
+
74
+ Settings live in `~/.clai/tools/rea/engines.json` (mode 0600; `$CLAI_DATA_DIR/tools/rea` if set). They are passed to REA's server as `GHIDRA_INSTALL_DIR`, `JAVA_HOME`, `HOPPER_LAUNCHER_PATH`, `REA_IDA_MCP_CONFIG` and `REA_KUNA_COMMAND`; a choice made with `/rea engines` takes precedence over the same variable in your own environment, for REA's server only (your shell is untouched), and `/rea engines remove` hands control back to your environment. Variables you have not set through `/rea engines` are passed through unchanged. Reconnect REA (`/rea reconnect`) after changing them yourself.
75
+
76
+ Ghidra and Kuna cannot open universal (fat) Mach-O files such as most system binaries on macOS. The agent is told to thin one slice into the session scratch directory with `lipo <file> -thin <arch> -output <scratch>/<name>-<arch>` (`llvm-lipo` when `lipo` is missing) and open that. Hopper opens universal files directly.
77
+
78
+ ## Limits
79
+
80
+ clai does not execute the target. On Linux, owned-process analysis needs a procps-compatible `ps`. The agent follows the selected tool's actual prerequisite or remediation and continues with supported work.
81
+
82
+ Portable archives and failure cases have deterministic cross-platform fixtures. The implementation was live-tested on Linux ARM64 with REA 6.7.0 and portable Node/npm, including a standalone compiled integration smoke with no system executables on PATH. That smoke bootstrapped Node 24.22.0, discovered 207 tools, performed a digest-bound static analysis and disabled the server without removing the installation.
83
+
84
+ The engine installers were run for real on freshly provisioned GitHub-hosted machines: Linux x64 and arm64, Windows x64, macOS arm64 and macOS Intel. Each one already exported its own Java (17 on Linux and Windows, 21 on macOS) and had no engine. On each, the shipped code installed Temurin 21 and Ghidra 12.1.4, REA reported Ghidra ready, and `open_binary`, `list_procedures`, `search_procedures` and `procedure_pseudo_code` returned decompiled code for a real system binary (an ELF `ls`, Windows' `whoami.exe`, a thinned Mach-O `ls`). Timings on GitHub's network, where the 543 MB download is quick; on a home connection the download dominates:
85
+
86
+ | Machine | JDK | Ghidra | Decompiler |
87
+ | --- | --- | --- | --- |
88
+ | Linux x64 | 4 s | 11 s | in the download |
89
+ | Linux arm64 | 3 s | 53 s | built (make, g++ and bison were present) |
90
+ | macOS arm64 | 5 s | 73 s | built |
91
+ | macOS Intel | 10 s | 184 s | built |
92
+ | Windows x64 | 5 s | 18 s | in the download |
93
+
94
+ The JDK takes 310 to 345 MB on disk and Ghidra 864 to 877 MB. The whole check on each machine, REA's own installation included, stayed under 500 MB of memory in clai's process; measured on its own on macOS arm64, the Ghidra install peaked at about 260 MB and used about 33 seconds of CPU. An Alpine container and a Windows 11 ARM machine report themselves as unsupported with the reason; nothing is downloaded there.
95
+
96
+ Not exercised live: Hopper, IDA and Kuna, the interactive install dialogs on Windows terminals (they run the same code as the macOS ones, which were driven through a pseudo-terminal), and the unauthenticated GitHub API limit (60 requests per hour per address, which clai explains when it is hit).
package/README.md CHANGED
@@ -151,7 +151,7 @@ Run `clai set <provider>` to add a key (`--from-env <variable>` imports one from
151
151
  </details>
152
152
 
153
153
  <details>
154
- <summary><b>API, keyless and local providers</b>: 30 providers including Free, Ollama, Anthropic, OpenAI, Gemini, DeepSeek, OpenRouter</summary>
154
+ <summary><b>API, keyless and local providers</b>: 31 providers including Free, Ollama, Anthropic, OpenAI, Gemini, DeepSeek, OpenRouter, Hinoki</summary>
155
155
 
156
156
  | Provider | Provider ID | Credential or endpoint variable |
157
157
  | --- | --- | --- |
@@ -165,6 +165,7 @@ Run `clai set <provider>` to add a key (`--from-env <variable>` imports one from
165
165
  | MiniMax | `minimax` | `MINIMAX_API_KEY` |
166
166
  | Mistral | `mistral` | `MISTRAL_API_KEY`; optional `MISTRAL_BASE_URL` for regional endpoints. |
167
167
  | River | `river` | `RIVER_API_KEY`; optional `RIVER_BASE_URL`. |
168
+ | Hinoki | `hinoki` | `HINOKI_API_KEY`; optional `HINOKI_BASE_URL`. |
168
169
  | Xiaomi MiMo | `mimo` | `MIMO_API_KEY` |
169
170
  | NVIDIA NIM | `nvidia` | `NVIDIA_API_KEY` |
170
171
  | OpenAI | `openai` | `OPENAI_API_KEY` |
@@ -202,6 +203,7 @@ Run `clai set <provider>` to add a key (`--from-env <variable>` imports one from
202
203
  | `/jobs`, `/output` | Background jobs and retained tool output |
203
204
  | `/subagents`, `/orchestrator` | Delegate work to subagents |
204
205
  | `/mcp`, `/skills` | MCP servers and Agent Skills |
206
+ | `/rea` | Install, update and use Reverse Engineer Anything and its analysis engines; `@rea` attaches it to a prompt |
205
207
  | `/minimise` | Detach and keep the agent running |
206
208
 
207
209
  Type `/` for suggestions and `@` to mention files. `/help` lists everything and `/shortcuts` shows key bindings. See the [command reference](guides/commands.md).
@@ -212,12 +214,14 @@ Type `/` for suggestions and `@` to mention files. `/help` lists everything and
212
214
  | --- | --- |
213
215
  | [Persistent sessions](guides/sessions.md) | Detach and resume, SSH and multiple terminals, sudo, history and compaction |
214
216
  | [Working with clai](guides/usage.md) | Modes and permissions, subagents, background jobs, interactive terminals, security testing, models and key rotation, project context, skills and MCP |
217
+ | [Security investigation skill](guides/security-skill.md) | Bundled on-demand security methodology, cross-domain research, evidence and coverage, packaging and behavioral evaluation |
215
218
  | [Terminal interface](guides/interface.md) | OpenTUI and Classic, terminals, keyboard shortcuts, paste and transcript controls |
216
219
  | [Commands](guides/commands.md) | Every slash command and CLI flag |
217
220
  | [Configuration and privacy](guides/configuration.md) | Config file, private mode, retention, credential storage and the encrypted `/creds` vault |
218
221
  | [Updating](guides/updating.md) | How `clai update` handles each installation method |
219
222
  | [Providers](PROVIDERS.md) | Account flows, API keys, endpoints and provider-specific behavior |
220
223
  | [MCP](MCP.md) | Adding, authenticating and troubleshooting MCP servers |
224
+ | [REA](REA.md) | On-demand reverse engineering, portable installation and cache-safe agent workflows |
221
225
 
222
226
  ## Privacy and security
223
227
 
@@ -0,0 +1,49 @@
1
+ import type { ChatMessage } from "../../types.js";
2
+ export type CompactionPurpose = "default" | "plan-implement";
3
+ export interface CompactionSituation {
4
+ readonly turnInProgress: boolean;
5
+ readonly hasPriorMemory: boolean;
6
+ readonly promptAnchors: string;
7
+ readonly instructionAnchors: string;
8
+ }
9
+ export type CompactionSource = {
10
+ readonly kind: "conversation";
11
+ } | {
12
+ readonly kind: "transcript";
13
+ readonly text: string;
14
+ } | {
15
+ readonly kind: "regions";
16
+ readonly regions: readonly string[];
17
+ };
18
+ export interface CompactionPromptInput {
19
+ readonly source: CompactionSource;
20
+ readonly situation?: CompactionSituation | undefined;
21
+ readonly durableState?: string | undefined;
22
+ readonly purpose?: CompactionPurpose | undefined;
23
+ readonly partialSource?: boolean | undefined;
24
+ }
25
+ export declare const COMPACTION_SYSTEM_PROMPT: string;
26
+ export declare function compactionSituation(messages: readonly ChatMessage[], options?: {
27
+ readonly turnInProgress?: boolean | undefined;
28
+ }): CompactionSituation;
29
+ export declare function buildCompactionUserPrompt(input: CompactionPromptInput): string;
30
+ export declare function buildDirectCompactionPrompt(input: {
31
+ readonly messages: readonly ChatMessage[];
32
+ readonly durableState?: string | undefined;
33
+ readonly purpose?: CompactionPurpose | undefined;
34
+ readonly turnInProgress?: boolean | undefined;
35
+ }): string;
36
+ export declare function buildCompactionChunkPrompt(input: {
37
+ readonly chunk: string;
38
+ readonly index: number;
39
+ readonly total: number;
40
+ readonly purpose?: CompactionPurpose | undefined;
41
+ }): string;
42
+ export declare function buildCompactionReducePrompt(input: {
43
+ readonly partials: readonly string[];
44
+ readonly situation?: CompactionSituation | undefined;
45
+ readonly durableState?: string | undefined;
46
+ readonly purpose?: CompactionPurpose | undefined;
47
+ }): string;
48
+ export type CompactionRetryReason = "truncated" | "incomplete" | "reasoning-only" | "replayed";
49
+ export declare function buildCompactionRetryPrompt(prompt: string, reason: CompactionRetryReason): string;
@@ -0,0 +1,164 @@
1
+ import { compactionPromptAnchors, hasCompletedConversationTurn } from "../context/compaction-recent-history.js";
2
+ import { inheritedInstructionAnchors } from "../context/compaction-user-instructions.js";
3
+ import { ACTIVE_GOAL_HEADING, CONTEXT_GATHERED_HEADING, CURRENT_STATE_HEADING, isCompactionMemoryMessage, ISSUES_HEADING, PAST_WORK_HEADING, RECENT_PROMPTS_HEADING, RELEVANT_FILES_HEADING, USER_INSTRUCTIONS_HEADING, WORK_DONE_HEADING, } from "./memory-sections.js";
4
+ export const COMPACTION_SYSTEM_PROMPT = [
5
+ "You write continuation memory for an autonomous coding and security agent whose conversation is being compacted.",
6
+ "Follow the format in the user message exactly. You are summarizing the session, not continuing it: never answer the user, call tools, continue the task, or invent findings, file contents, receipts, exit codes or completions.",
7
+ ].join("\n");
8
+ export function compactionSituation(messages, options = {}) {
9
+ return {
10
+ turnInProgress: options.turnInProgress ?? !hasCompletedConversationTurn(messages),
11
+ hasPriorMemory: messages.some((message) => message.compaction !== undefined || isCompactionMemoryMessage(message)),
12
+ promptAnchors: compactionPromptAnchors(messages),
13
+ instructionAnchors: inheritedInstructionAnchors(messages),
14
+ };
15
+ }
16
+ const ROLE = [
17
+ "CONTEXT COMPACTION",
18
+ "",
19
+ "Pause the task for this one response. The conversation has reached its context limit and is about to be replaced by the continuation memory you write now. Afterwards the agent continues with only the system prompt, this memory, re-injected session state (active plan, durable envelope, project instructions, skills) and the most recent messages. Anything you leave out is gone, so the memory must let the agent resume exactly where it stopped, without repeating finished work, drifting from the user's intent, or forgetting a rule.",
20
+ "",
21
+ "Write the memory only. Do not answer the user, call tools, continue the work, or invent results, file contents, receipts, exit codes or completions. Use your own words.",
22
+ ];
23
+ const PLAN_HANDOFF = [
24
+ "",
25
+ "PURPOSE: the user accepted the plan built in plan mode and the agent now implements it. The active goal is to execute that accepted plan; the plan itself is re-injected separately, so reference its tasks instead of copying them. Context gathered carries the plan-mode research evidence (for security work: targets, scope, confirmed findings, negative results and untested areas). Plan-mode restrictions such as gather-only or wait-for-approval are historical now, while engagement scope and safety rules still apply.",
26
+ ];
27
+ function situationLines(input) {
28
+ const { situation, source } = input;
29
+ if (!situation)
30
+ return [];
31
+ const lines = ["", "SITUATION"];
32
+ if (input.partialSource) {
33
+ lines.push("- The source covers only the older part of the session; the newer turns stay in the live history right after this memory. Summarize the source completely and do not guess about the newer turns.");
34
+ }
35
+ lines.push(situation.turnInProgress
36
+ ? "- The agent was in the middle of the latest user request when the limit was hit. The latest user message is kept verbatim after the memory; the memory must say precisely what was in progress and what comes next."
37
+ : "- The latest turn ended with a final answer. Unless the conversation shows unfinished commitments, the latest task is complete.");
38
+ if (situation.hasPriorMemory) {
39
+ lines.push("- An earlier compaction memory appears in the source. It is the only record of everything before it: carry every still-relevant fact forward, merged with the newer turns and rewritten into the sections below. Move tasks that have since finished into Past completed work; never drop earlier completed work.");
40
+ }
41
+ if (source.kind === "regions") {
42
+ lines.push("- The source is a set of chronological region notes of one session; merge them into one memory and let later regions override earlier ones.");
43
+ }
44
+ if (situation.promptAnchors)
45
+ lines.push("", situation.promptAnchors);
46
+ if (situation.instructionAnchors)
47
+ lines.push("", situation.instructionAnchors);
48
+ return lines;
49
+ }
50
+ const FORMAT = [
51
+ "",
52
+ "FORMAT: write these sections in this exact order with these exact headings. Every section is required except Issues and risks, which you omit entirely when there is no genuine issue.",
53
+ "",
54
+ ACTIVE_GOAL_HEADING,
55
+ "The one goal the agent pursues next, as a precise, self-contained brief. Build it from the latest unfinished user task combined with every later follow-up, correction and piece of feedback; when the user changed direction mid-task, state the new direction and what it replaces. Include the definition of done (acceptance criteria and required verification such as tests, build, commit or push) and any scope limits or non-goals the user or the work established. If every task is finished, write \"No active task.\", name what was completed last, and say the agent should wait for the next request. Older finished tasks do not belong here.",
56
+ "",
57
+ USER_INSTRUCTIONS_HEADING,
58
+ "Rules the user gave about how to work, rewritten concisely in your own words while keeping exact values (limits, names, versions, paths, required wording). One bullet each:",
59
+ "- [S1] (session) a rule for all work in this session or project, such as code style, \"write like a senior developer\", \"no file over 300 lines\", git and commit rules, tools to use or avoid.",
60
+ "- [T1] (task: short task name) a rule that applies only within one task, such as \"while changing the UI, do not increase the composer width\".",
61
+ "Requests to do something (\"fix this UI\", \"change the color\", \"add /creds\") are tasks, not instructions; they belong in Active goal, Work done or Past completed work. Reuse carried IDs and give new rules the next free S or T number. Session rules last for the whole session. Keep a task rule only while its task is active or unfinished, and drop it once that task is done or abandoned. When the user changes or revokes a session rule, write \"- [S1] (retired) user: \\\"exact newer user quote\\\"\" and add the replacement as a new bullet. Rules from project instruction files (AGENTS.md, .clai/INSTRUCTIONS.md and similar) are re-injected separately, so do not copy them here, and never persist session or task rules into those files. Write \"None\" when there are no rules. Never write secret values.",
62
+ "",
63
+ CONTEXT_GATHERED_HEADING,
64
+ "Everything learned that the active goal depends on, so the agent never has to rediscover it: what exists and where (paths with line numbers, symbols, functions, components, config keys, endpoints, data shapes), how the relevant code or system works, why the problem happens (root cause and evidence), environment facts (stack, package manager, working commands, versions), constraints, decisions the user made or the work applied with their reasons (an approach nobody has chosen or applied yet is not a decision: put it in next steps as a proposal), and findings from tools, web research and subagents. For non-coding work, record each relevant command or tool finding with its key result. Quote code only where the exact text matters, such as a signature or an error message.",
65
+ "",
66
+ WORK_DONE_HEADING,
67
+ "Everything already done toward the active goal: each change as `path:line` or symbol, what changed (before → after) and why; files created or deleted; commands run with a short result (test counts, build status, commit hashes, pushes). Mark clearly what was applied and verified versus attempted, failed, reverted or only partly applied. Write \"Nothing yet.\" when no work has started.",
68
+ "",
69
+ CURRENT_STATE_HEADING,
70
+ "The most important section: it decides whether the agent resumes correctly. State exactly where the work stopped: what was in progress at the moment of compaction (the step, file or command, and what had and had not been applied), the workspace state (uncommitted changes, branch, running processes, background jobs, subagents and whether their results were read) and the latest user follow-up the agent must honor. Then give a numbered list of concrete next actions, starting with the very next one, each with how to verify it. Never list completed work as a next step, never re-plan finished steps, and never invent new tasks. When nothing remains, say so.",
71
+ "",
72
+ PAST_WORK_HEADING,
73
+ "Every earlier task in this session that is finished and is not the active goal, oldest first, one bullet per task: what the user asked, what was done (key files and symbols), the outcome and its verification, and its delivery state (uncommitted, committed with hash, pushed, PR open, merged, or unknown). Merge the entries from any earlier memory and rewrite them as tasks finish. Say when a past task relates to the active goal. Write \"None.\" when the active goal is the first task.",
74
+ "",
75
+ RELEVANT_FILES_HEADING,
76
+ "Files the agent needs for the active goal, most important first, as `path:line-range` — symbol and why it matters. At most about 20 entries; never list every file that was read.",
77
+ "",
78
+ ISSUES_HEADING,
79
+ "Only genuine open problems: failing tests, unresolved errors, blockers, risky partial edits, conflicting requirements, decisions the user must make. Omit the whole section when there are none.",
80
+ "",
81
+ `Do not write a "${RECENT_PROMPTS_HEADING.replace(/^## /, "")}" section; the application appends the verbatim prompts.`,
82
+ ];
83
+ const QUALITY = [
84
+ "",
85
+ "QUALITY",
86
+ "- Be concrete and complete. Prefer exact identifiers, paths, line numbers, commands, values and error text over paraphrase; vague phrases such as \"updated the logic\" are useless to the next agent.",
87
+ "- Read the source to the very end: the latest tool call, result and user message define the current state. Decisions that were replaced or reverted are superseded; record only the final choice and why.",
88
+ "- Separate fact from intent: a decision, scope limit or design counts as made only when the user stated it or the work applied it. Your own suggestions for how to proceed belong in Current state and next steps, phrased as proposed steps.",
89
+ "- State each fact once, in the section where the next agent will look for it.",
90
+ "- Delegated workers are subagents: record each one's id and attempt, task, status, whether its result was read, and the conclusions of results already read; retained reports stay recoverable by id and attempt. Keep background jobs and Responder tasks separate from subagents. The RESPONDER RESULT LEDGER is authoritative: never describe a consumed=true result as unread, and keep unread results pending.",
91
+ "- Approval and mode gates: plan-mode gather-only or wait-for-approval limits end only when the user accepts the plan; research-only or no-implementation limits the user set for the current topic stay in force. Compaction never grants approval, and an answered question never authorizes new work.",
92
+ "- Record names and exact paths of still-relevant skills and references, not copies of their instructions. A prior load is historical, not proof that its full body survives compaction; never tell the next agent not to reload content that was lost. The application appends authoritative skill-recovery guidance.",
93
+ "- Refer to credentials and secrets by purpose only; their values are carried separately.",
94
+ "- Length: as long as needed to lose nothing that matters and no longer, usually 1,500 to 4,000 tokens and up to about 6,000 for long sessions with several tasks. Plain Markdown with bullets, no code fences around the whole memory. Finish every section and end on a complete sentence.",
95
+ ];
96
+ function sourceLines(source) {
97
+ switch (source.kind) {
98
+ case "conversation":
99
+ return ["", "SOURCE: the entire conversation above this message, up to and including the most recent turn. This message itself is not part of the session."];
100
+ case "transcript":
101
+ return ["", "SOURCE (session transcript, oldest first):", "", source.text];
102
+ case "regions":
103
+ return ["", "SOURCE (region notes, oldest first):", "", source.regions.map((region, index) => `REGION ${index + 1}:\n${region}`).join("\n\n")];
104
+ }
105
+ }
106
+ export function buildCompactionUserPrompt(input) {
107
+ const durable = input.durableState?.trim();
108
+ return [
109
+ ...ROLE,
110
+ ...(input.purpose === "plan-implement" ? PLAN_HANDOFF : []),
111
+ ...situationLines(input),
112
+ ...(durable ? ["", "DURABLE STATE (authoritative for plan, task, job and result statuses):", durable] : []),
113
+ ...FORMAT,
114
+ ...QUALITY,
115
+ ...sourceLines(input.source),
116
+ ].join("\n");
117
+ }
118
+ export function buildDirectCompactionPrompt(input) {
119
+ return buildCompactionUserPrompt({
120
+ source: { kind: "conversation" },
121
+ situation: compactionSituation(input.messages, { turnInProgress: input.turnInProgress }),
122
+ durableState: input.durableState,
123
+ purpose: input.purpose,
124
+ });
125
+ }
126
+ export function buildCompactionChunkPrompt(input) {
127
+ return [
128
+ `REGION NOTES ${input.index + 1} OF ${input.total}`,
129
+ "",
130
+ "This is one chronological region of a long session that is being compacted. Write dense notes that a later pass will merge into the final memory. Summarize only what this region shows; do not answer the user, call tools, continue the work or guess about other regions.",
131
+ ...(input.purpose === "plan-implement" ? ["The session is a plan-mode research phase whose accepted plan will be implemented next; keep research evidence, findings, negative results and open areas."] : []),
132
+ "",
133
+ "Use these headings and keep every consequential detail:",
134
+ "### Tasks requested — each user request in order, with every later follow-up or correction, and whether it finished in this region.",
135
+ "### User instructions — each rule about how to work, quoted exactly, marked session-wide or tied to one task; prompts that ask for work are tasks, not instructions.",
136
+ "### Context gathered — paths with line numbers, symbols, mechanisms, root causes, environment facts, decisions with reasons, tool, web and subagent findings.",
137
+ "### Work done — each change as path:line or symbol (before → after), commands with short results, commits and pushes, failed or reverted attempts.",
138
+ "### State at the end of the region — what was in progress, pending next steps, open problems.",
139
+ "",
140
+ "Use exact identifiers. Never copy transcript lines, tool-call syntax or long output, and never write secret values.",
141
+ "",
142
+ "SOURCE (region):",
143
+ "",
144
+ input.chunk,
145
+ ].join("\n");
146
+ }
147
+ export function buildCompactionReducePrompt(input) {
148
+ return buildCompactionUserPrompt({
149
+ source: { kind: "regions", regions: input.partials },
150
+ situation: input.situation,
151
+ durableState: input.durableState,
152
+ purpose: input.purpose,
153
+ });
154
+ }
155
+ const RETRY_ISSUES = {
156
+ truncated: "The previous draft hit its output limit.",
157
+ "reasoning-only": "The previous draft contained no visible memory.",
158
+ replayed: "The previous draft copied transcript lines or tool-call syntax.",
159
+ incomplete: "The previous draft ended abruptly or missed required sections.",
160
+ };
161
+ export function buildCompactionRetryPrompt(prompt, reason) {
162
+ return `${prompt}\n\nQUALITY RETRY: ${RETRY_ISSUES[reason]} Write the complete memory again from the source, not as a continuation of the failed draft. Use every required section, keep every consequential fact once, and end on a complete sentence.`;
163
+ }
164
+ //# sourceMappingURL=compaction-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction-prompt.js","sourceRoot":"","sources":["../../../src/agent/compaction/compaction-prompt.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,27 @@
1
+ import type { ChatMessage } from "../../types.js";
2
+ export declare const COMPACTION_MEMORY_PREFIX = "Session memory from compacted earlier turns:";
3
+ export declare const PLAN_IMPLEMENT_MEMORY_PREFIX = "PLAN MODE HANDOFF: research memory for the accepted implementation phase. Gather-only/await-approval gates are historical; ACTIVE PLAN and SESSION STATE are authoritative:";
4
+ export declare const LEGACY_PLAN_IMPLEMENT_MEMORY_PREFIX = "Session memory from PLAN MODE research that was used to build the comprehensive detailed plan and tasks you are seeing now (handoff to agent implement \u2014 gather-only phase is over; execute approved tasks):";
5
+ export declare const MECHANICAL_MEMORY_PREFIX = "Earlier turns in this session, summarized";
6
+ export declare function isCompactionMemoryMessage(message: ChatMessage): boolean;
7
+ export declare const ACTIVE_GOAL_HEADING = "## Active goal";
8
+ export declare const USER_INSTRUCTIONS_HEADING = "## User instructions";
9
+ export declare const CONTEXT_GATHERED_HEADING = "## Context gathered";
10
+ export declare const WORK_DONE_HEADING = "## Work done";
11
+ export declare const CURRENT_STATE_HEADING = "## Current state and next steps";
12
+ export declare const PAST_WORK_HEADING = "## Past completed work";
13
+ export declare const RELEVANT_FILES_HEADING = "## Relevant files";
14
+ export declare const ISSUES_HEADING = "## Issues and risks";
15
+ export declare const RECENT_PROMPTS_HEADING = "## Last 3 user prompts (latest first)";
16
+ export declare const MODEL_MEMORY_HEADINGS: readonly ["## Active goal", "## User instructions", "## Context gathered", "## Work done", "## Current state and next steps", "## Past completed work", "## Relevant files", "## Issues and risks"];
17
+ export interface SectionRange {
18
+ readonly start: number;
19
+ readonly end: number;
20
+ readonly body: string;
21
+ }
22
+ export declare function sectionRanges(text: string, heading: string): SectionRange[];
23
+ export declare function sectionBody(text: string, heading: string): string | undefined;
24
+ export declare function replaceSections(text: string, heading: string, replacement: string): string;
25
+ export declare function withoutSection(text: string, heading: string): string;
26
+ export declare function insertSectionAfter(text: string, previous: readonly string[], section: string): string;
27
+ export declare function canonicalMemoryLayout(text: string): string;