@pentoshi/clai 4.12.1 → 4.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (483) hide show
  1. package/CODE_OF_CONDUCT.md +132 -0
  2. package/CONTRIBUTING.md +102 -0
  3. package/PROVIDERS.md +149 -0
  4. package/README.md +217 -464
  5. package/SECURITY.md +33 -0
  6. package/dist/agent/compaction/summary-execution.js +2 -2
  7. package/dist/agent/compaction/summary-execution.js.map +1 -1
  8. package/dist/agent/compaction-summary.d.ts +5 -2
  9. package/dist/agent/compaction-summary.js +10 -4
  10. package/dist/agent/compaction-summary.js.map +1 -1
  11. package/dist/agent/context/compact-with-summary.d.ts +1 -0
  12. package/dist/agent/context/compact-with-summary.js +25 -3
  13. package/dist/agent/context/compact-with-summary.js.map +1 -1
  14. package/dist/agent/context/compaction-recent-history.d.ts +12 -0
  15. package/dist/agent/context/compaction-recent-history.js +114 -0
  16. package/dist/agent/context/compaction-recent-history.js.map +1 -0
  17. package/dist/agent/context/user-credentials.d.ts +1 -0
  18. package/dist/agent/context/user-credentials.js +3 -0
  19. package/dist/agent/context/user-credentials.js.map +1 -1
  20. package/dist/agent/context-manager.js +2 -1
  21. package/dist/agent/context-manager.js.map +1 -1
  22. package/dist/agent/evidence/task-classification.js +2 -5
  23. package/dist/agent/evidence/task-classification.js.map +1 -1
  24. package/dist/agent/loop-guard.js +1 -5
  25. package/dist/agent/loop-guard.js.map +1 -1
  26. package/dist/agent/outcomes.js +9 -1
  27. package/dist/agent/outcomes.js.map +1 -1
  28. package/dist/agent/parser/arg-formatting.js +3 -16
  29. package/dist/agent/parser/arg-formatting.js.map +1 -1
  30. package/dist/agent/parser/bare-recognition.js +12 -6
  31. package/dist/agent/parser/bare-recognition.js.map +1 -1
  32. package/dist/agent/parser/xml-protocol.js +0 -2
  33. package/dist/agent/parser/xml-protocol.js.map +1 -1
  34. package/dist/agent/plan-implement-compact.js +2 -1
  35. package/dist/agent/plan-implement-compact.js.map +1 -1
  36. package/dist/agent/request-budget.d.ts +1 -0
  37. package/dist/agent/request-budget.js +6 -1
  38. package/dist/agent/request-budget.js.map +1 -1
  39. package/dist/agent/runner.js +2 -2
  40. package/dist/agent/runner.js.map +1 -1
  41. package/dist/agent/session-policy.d.ts +1 -0
  42. package/dist/agent/session-policy.js +1 -4
  43. package/dist/agent/session-policy.js.map +1 -1
  44. package/dist/agent/subagents/manager.d.ts +5 -1
  45. package/dist/agent/subagents/manager.js +95 -15
  46. package/dist/agent/subagents/manager.js.map +1 -1
  47. package/dist/agent/subagents/read-only-tools.js +44 -20
  48. package/dist/agent/subagents/read-only-tools.js.map +1 -1
  49. package/dist/agent/subagents/tools.d.ts +8 -1
  50. package/dist/agent/subagents/tools.js +21 -13
  51. package/dist/agent/subagents/tools.js.map +1 -1
  52. package/dist/agent/subagents/types.d.ts +7 -0
  53. package/dist/agent/subagents/worker.js +48 -7
  54. package/dist/agent/subagents/worker.js.map +1 -1
  55. package/dist/agent/task-evidence.js +2 -11
  56. package/dist/agent/task-evidence.js.map +1 -1
  57. package/dist/agent/tool-output-formatting.js +8 -2
  58. package/dist/agent/tool-output-formatting.js.map +1 -1
  59. package/dist/agent/turn/automatic-compaction-execution.js +1 -0
  60. package/dist/agent/turn/automatic-compaction-execution.js.map +1 -1
  61. package/dist/agent/turn/compaction-coordinator.js +4 -4
  62. package/dist/agent/turn/compaction-coordinator.js.map +1 -1
  63. package/dist/agent/turn/compaction-replay-selection.js +1 -0
  64. package/dist/agent/turn/compaction-replay-selection.js.map +1 -1
  65. package/dist/agent/turn/loop/run-rounds.js +11 -3
  66. package/dist/agent/turn/loop/run-rounds.js.map +1 -1
  67. package/dist/agent/turn/prompt-sections.js +4 -9
  68. package/dist/agent/turn/prompt-sections.js.map +1 -1
  69. package/dist/agent/turn/setup/turn-messages.js +2 -1
  70. package/dist/agent/turn/setup/turn-messages.js.map +1 -1
  71. package/dist/agent/turn/subagent-inbox.d.ts +5 -5
  72. package/dist/agent/turn/subagent-inbox.js +90 -11
  73. package/dist/agent/turn/subagent-inbox.js.map +1 -1
  74. package/dist/agent/turn/system-sections.d.ts +1 -0
  75. package/dist/agent/turn/system-sections.js +1 -1
  76. package/dist/agent/turn/system-sections.js.map +1 -1
  77. package/dist/agent/turn/task-autostart.js +2 -0
  78. package/dist/agent/turn/task-autostart.js.map +1 -1
  79. package/dist/agent/turn/tool-execution/single-tool.js +1 -3
  80. package/dist/agent/turn/tool-execution/single-tool.js.map +1 -1
  81. package/dist/agent/turn/tool-result-recorder.js +5 -0
  82. package/dist/agent/turn/tool-result-recorder.js.map +1 -1
  83. package/dist/agent/turn/tool-routing.d.ts +1 -1
  84. package/dist/agent/turn/tool-routing.js +11 -11
  85. package/dist/agent/turn/tool-routing.js.map +1 -1
  86. package/dist/agent/workspace-orient.js +2 -2
  87. package/dist/agent/workspace-orient.js.map +1 -1
  88. package/dist/app/adapters/agent-event-adapter.js +5 -0
  89. package/dist/app/adapters/agent-event-adapter.js.map +1 -1
  90. package/dist/app/adapters/current-store-adapter.js +2 -2
  91. package/dist/app/adapters/current-store-adapter.js.map +1 -1
  92. package/dist/app/commands/catalog.js +2 -0
  93. package/dist/app/commands/catalog.js.map +1 -1
  94. package/dist/app/commands/registry.js +1 -1
  95. package/dist/app/commands/registry.js.map +1 -1
  96. package/dist/app/controllers/session-compact-helper.js +1 -0
  97. package/dist/app/controllers/session-compact-helper.js.map +1 -1
  98. package/dist/app/controllers/session-controller.d.ts +8 -0
  99. package/dist/app/controllers/session-controller.js +58 -10
  100. package/dist/app/controllers/session-controller.js.map +1 -1
  101. package/dist/app/controllers/session-naming.d.ts +4 -5
  102. package/dist/app/controllers/session-naming.js +38 -80
  103. package/dist/app/controllers/session-naming.js.map +1 -1
  104. package/dist/app/controllers/session-prompt-history.d.ts +4 -0
  105. package/dist/app/controllers/session-prompt-history.js +33 -0
  106. package/dist/app/controllers/session-prompt-history.js.map +1 -0
  107. package/dist/app/controllers/session-prompt-queue.d.ts +1 -0
  108. package/dist/app/controllers/session-prompt-queue.js +1 -1
  109. package/dist/app/controllers/session-prompt-queue.js.map +1 -1
  110. package/dist/app/events/artifact-output.d.ts +1 -0
  111. package/dist/app/events/artifact-output.js +32 -0
  112. package/dist/app/events/artifact-output.js.map +1 -0
  113. package/dist/app/events/event-buffer.d.ts +13 -1
  114. package/dist/app/events/event-buffer.js +92 -4
  115. package/dist/app/events/event-buffer.js.map +1 -1
  116. package/dist/app/operation-review.js +1 -1
  117. package/dist/app/operation-review.js.map +1 -1
  118. package/dist/app/ports/persistence-port.d.ts +2 -1
  119. package/dist/classic/app/ClassicApp.js +33 -2
  120. package/dist/classic/app/ClassicApp.js.map +1 -1
  121. package/dist/classic/app/action-handlers.js +0 -2
  122. package/dist/classic/app/action-handlers.js.map +1 -1
  123. package/dist/classic/app/app-wiring.d.ts +1 -2
  124. package/dist/classic/app/app-wiring.js +1 -8
  125. package/dist/classic/app/app-wiring.js.map +1 -1
  126. package/dist/classic/app/wiring-interactions.d.ts +0 -2
  127. package/dist/classic/app/wiring-interactions.js +5 -13
  128. package/dist/classic/app/wiring-interactions.js.map +1 -1
  129. package/dist/classic/app/wiring-types.d.ts +2 -2
  130. package/dist/classic/blocks/batch-lines.js +10 -8
  131. package/dist/classic/blocks/batch-lines.js.map +1 -1
  132. package/dist/classic/blocks/block-context.d.ts +1 -0
  133. package/dist/classic/blocks/block-context.js.map +1 -1
  134. package/dist/classic/blocks/tool-lines.js +20 -39
  135. package/dist/classic/blocks/tool-lines.js.map +1 -1
  136. package/dist/classic/bootstrap/renderer-handle.d.ts +5 -1
  137. package/dist/classic/bootstrap/renderer-handle.js.map +1 -1
  138. package/dist/classic/bootstrap/start-classic.js +12 -12
  139. package/dist/classic/bootstrap/start-classic.js.map +1 -1
  140. package/dist/classic/chrome/context-limit-editor.d.ts +7 -0
  141. package/dist/classic/chrome/context-limit-editor.js +5 -0
  142. package/dist/classic/chrome/context-limit-editor.js.map +1 -1
  143. package/dist/classic/chrome/status-rows.d.ts +4 -0
  144. package/dist/classic/chrome/status-rows.js +11 -0
  145. package/dist/classic/chrome/status-rows.js.map +1 -1
  146. package/dist/classic/feed/feed-blocks.d.ts +1 -1
  147. package/dist/classic/feed/feed-blocks.js +13 -6
  148. package/dist/classic/feed/feed-blocks.js.map +1 -1
  149. package/dist/classic/panels/keys-panel.js +12 -3
  150. package/dist/classic/panels/keys-panel.js.map +1 -1
  151. package/dist/classic/panels/pager-panel.js +0 -6
  152. package/dist/classic/panels/pager-panel.js.map +1 -1
  153. package/dist/classic/panels/pager-source-controller.d.ts +34 -0
  154. package/dist/classic/panels/pager-source-controller.js +209 -0
  155. package/dist/classic/panels/pager-source-controller.js.map +1 -0
  156. package/dist/classic/panels/panel-controller.d.ts +1 -5
  157. package/dist/classic/panels/panel-controller.js +19 -88
  158. package/dist/classic/panels/panel-controller.js.map +1 -1
  159. package/dist/classic/panels/panel-effect.d.ts +0 -4
  160. package/dist/classic/panels/panel-effect.js.map +1 -1
  161. package/dist/classic/panels/panel-effects.js +0 -6
  162. package/dist/classic/panels/panel-effects.js.map +1 -1
  163. package/dist/classic/panels/panel-types.d.ts +0 -2
  164. package/dist/classic/panels/picker-panel.js +1 -1
  165. package/dist/classic/panels/picker-panel.js.map +1 -1
  166. package/dist/commands/providers.d.ts +1 -0
  167. package/dist/commands/providers.js +1 -0
  168. package/dist/commands/providers.js.map +1 -1
  169. package/dist/commands/qoder.d.ts +8 -0
  170. package/dist/commands/qoder.js +85 -0
  171. package/dist/commands/qoder.js.map +1 -0
  172. package/dist/index.js +19 -15
  173. package/dist/index.js.map +1 -1
  174. package/dist/interactive-session/transport-node-pty.js +3 -5
  175. package/dist/interactive-session/transport-node-pty.js.map +1 -1
  176. package/dist/llm/capability/state.d.ts +1 -1
  177. package/dist/llm/capability/tool-dialect.js +1 -0
  178. package/dist/llm/capability/tool-dialect.js.map +1 -1
  179. package/dist/llm/capability/vision-patterns.js +1 -0
  180. package/dist/llm/capability/vision-patterns.js.map +1 -1
  181. package/dist/llm/context-windows.js +2 -3
  182. package/dist/llm/context-windows.js.map +1 -1
  183. package/dist/llm/provider-identity.js +5 -0
  184. package/dist/llm/provider-identity.js.map +1 -1
  185. package/dist/llm/provider-info-text.js +25 -0
  186. package/dist/llm/provider-info-text.js.map +1 -1
  187. package/dist/llm/qoder/qoder-accounts.d.ts +9 -0
  188. package/dist/llm/qoder/qoder-accounts.js +53 -0
  189. package/dist/llm/qoder/qoder-accounts.js.map +1 -0
  190. package/dist/llm/qoder/qoder-auth.d.ts +59 -0
  191. package/dist/llm/qoder/qoder-auth.js +203 -0
  192. package/dist/llm/qoder/qoder-auth.js.map +1 -0
  193. package/dist/llm/qoder/qoder-credential.d.ts +31 -0
  194. package/dist/llm/qoder/qoder-credential.js +82 -0
  195. package/dist/llm/qoder/qoder-credential.js.map +1 -0
  196. package/dist/llm/qoder/qoder-login.d.ts +28 -0
  197. package/dist/llm/qoder/qoder-login.js +153 -0
  198. package/dist/llm/qoder/qoder-login.js.map +1 -0
  199. package/dist/llm/qoder/qoder-refresh.d.ts +4 -0
  200. package/dist/llm/qoder/qoder-refresh.js +165 -0
  201. package/dist/llm/qoder/qoder-refresh.js.map +1 -0
  202. package/dist/llm/qoder/qoder-signer.d.ts +66 -0
  203. package/dist/llm/qoder/qoder-signer.js +119 -0
  204. package/dist/llm/qoder/qoder-signer.js.map +1 -0
  205. package/dist/llm/qoder/qoder.d.ts +20 -0
  206. package/dist/llm/qoder/qoder.js +441 -0
  207. package/dist/llm/qoder/qoder.js.map +1 -0
  208. package/dist/llm/qoder/signer-glue.generated.d.ts +1 -0
  209. package/dist/llm/qoder/signer-glue.generated.js +4 -0
  210. package/dist/llm/qoder/signer-glue.generated.js.map +1 -0
  211. package/dist/llm/qoder/signer-wasm.generated.d.ts +3 -0
  212. package/dist/llm/qoder/signer-wasm.generated.js +6 -0
  213. package/dist/llm/qoder/signer-wasm.generated.js.map +1 -0
  214. package/dist/llm/reasoning-capability.js +1 -0
  215. package/dist/llm/reasoning-capability.js.map +1 -1
  216. package/dist/llm/routing/attempt-complete.js +4 -2
  217. package/dist/llm/routing/attempt-complete.js.map +1 -1
  218. package/dist/llm/routing/attempt-request.d.ts +2 -1
  219. package/dist/llm/routing/attempt-request.js +35 -1
  220. package/dist/llm/routing/attempt-request.js.map +1 -1
  221. package/dist/llm/routing/attempt-stream.js +4 -2
  222. package/dist/llm/routing/attempt-stream.js.map +1 -1
  223. package/dist/llm/routing/provider-selection.js +3 -0
  224. package/dist/llm/routing/provider-selection.js.map +1 -1
  225. package/dist/llm/tool-protocol.js +6 -0
  226. package/dist/llm/tool-protocol.js.map +1 -1
  227. package/dist/llm/wire/reasoning-payload.d.ts +1 -1
  228. package/dist/llm/wire/reasoning-payload.js +6 -0
  229. package/dist/llm/wire/reasoning-payload.js.map +1 -1
  230. package/dist/modes/ask.js +26 -10
  231. package/dist/modes/ask.js.map +1 -1
  232. package/dist/noninteractive/stream-blocks.d.ts +2 -4
  233. package/dist/noninteractive/stream-blocks.js +5 -5
  234. package/dist/noninteractive/stream-blocks.js.map +1 -1
  235. package/dist/noninteractive/stream-renderer.js +1 -1
  236. package/dist/noninteractive/stream-renderer.js.map +1 -1
  237. package/dist/prompts/embedded.js +2 -2
  238. package/dist/prompts/embedded.js.map +1 -1
  239. package/dist/prompts/index.d.ts +3 -1
  240. package/dist/prompts/index.js +25 -9
  241. package/dist/prompts/index.js.map +1 -1
  242. package/dist/prompts/system.agent.md +11 -11
  243. package/dist/prompts/system.ask.md +5 -3
  244. package/dist/safety/shell-command-words.d.ts +11 -0
  245. package/dist/safety/shell-command-words.js +193 -0
  246. package/dist/safety/shell-command-words.js.map +1 -0
  247. package/dist/safety/shell-filesystem-effects.js +46 -40
  248. package/dist/safety/shell-filesystem-effects.js.map +1 -1
  249. package/dist/safety/tool-classification.js +0 -14
  250. package/dist/safety/tool-classification.js.map +1 -1
  251. package/dist/session-runtime/binding.js +4 -1
  252. package/dist/session-runtime/binding.js.map +1 -1
  253. package/dist/session-runtime/client.js +111 -7
  254. package/dist/session-runtime/client.js.map +1 -1
  255. package/dist/session-runtime/discovery.d.ts +1 -1
  256. package/dist/session-runtime/discovery.js +2 -2
  257. package/dist/session-runtime/discovery.js.map +1 -1
  258. package/dist/session-runtime/host.d.ts +10 -2
  259. package/dist/session-runtime/host.js +206 -83
  260. package/dist/session-runtime/host.js.map +1 -1
  261. package/dist/session-runtime/input-commands.d.ts +2 -0
  262. package/dist/session-runtime/input-commands.js +11 -0
  263. package/dist/session-runtime/input-commands.js.map +1 -0
  264. package/dist/session-runtime/input-stream.d.ts +15 -0
  265. package/dist/session-runtime/input-stream.js +128 -0
  266. package/dist/session-runtime/input-stream.js.map +1 -0
  267. package/dist/session-runtime/types.d.ts +9 -0
  268. package/dist/store/config.js +1 -0
  269. package/dist/store/config.js.map +1 -1
  270. package/dist/store/history/freshness.d.ts +9 -0
  271. package/dist/store/history/freshness.js +29 -0
  272. package/dist/store/history/freshness.js.map +1 -0
  273. package/dist/store/history/jsonl-backend.js +2 -16
  274. package/dist/store/history/jsonl-backend.js.map +1 -1
  275. package/dist/store/history/lifecycle.js +6 -2
  276. package/dist/store/history/lifecycle.js.map +1 -1
  277. package/dist/store/history/recovery.d.ts +1 -3
  278. package/dist/store/history/recovery.js +72 -111
  279. package/dist/store/history/recovery.js.map +1 -1
  280. package/dist/store/history/session-queries.js +5 -5
  281. package/dist/store/history/session-queries.js.map +1 -1
  282. package/dist/store/history-index.d.ts +5 -0
  283. package/dist/store/history-index.js +41 -9
  284. package/dist/store/history-index.js.map +1 -1
  285. package/dist/store/history.d.ts +7 -2
  286. package/dist/store/history.js +13 -7
  287. package/dist/store/history.js.map +1 -1
  288. package/dist/store/rtk-usage.d.ts +2 -0
  289. package/dist/store/rtk-usage.js +44 -0
  290. package/dist/store/rtk-usage.js.map +1 -0
  291. package/dist/store/session-prompts-format.d.ts +2 -0
  292. package/dist/store/session-prompts-format.js +29 -0
  293. package/dist/store/session-prompts-format.js.map +1 -0
  294. package/dist/store/session-prompts.d.ts +40 -0
  295. package/dist/store/session-prompts.js +213 -0
  296. package/dist/store/session-prompts.js.map +1 -0
  297. package/dist/store/subagents.d.ts +5 -1
  298. package/dist/store/subagents.js +64 -4
  299. package/dist/store/subagents.js.map +1 -1
  300. package/dist/tools/call-normalization.js +0 -3
  301. package/dist/tools/call-normalization.js.map +1 -1
  302. package/dist/tools/definitions/aggregate.js +0 -4
  303. package/dist/tools/definitions/aggregate.js.map +1 -1
  304. package/dist/tools/definitions/define.js +0 -3
  305. package/dist/tools/definitions/define.js.map +1 -1
  306. package/dist/tools/definitions/files.js +3 -111
  307. package/dist/tools/definitions/files.js.map +1 -1
  308. package/dist/tools/definitions/fs-read.d.ts +3 -0
  309. package/dist/tools/definitions/fs-read.js +43 -0
  310. package/dist/tools/definitions/fs-read.js.map +1 -0
  311. package/dist/tools/definitions/selection.js +0 -45
  312. package/dist/tools/definitions/selection.js.map +1 -1
  313. package/dist/tools/fs/read-budget.d.ts +8 -0
  314. package/dist/tools/fs/read-budget.js +30 -0
  315. package/dist/tools/fs/read-budget.js.map +1 -0
  316. package/dist/tools/fs/read-input.d.ts +16 -0
  317. package/dist/tools/fs/read-input.js +73 -0
  318. package/dist/tools/fs/read-input.js.map +1 -0
  319. package/dist/tools/fs/read-many.d.ts +6 -0
  320. package/dist/tools/fs/read-many.js +50 -0
  321. package/dist/tools/fs/read-many.js.map +1 -0
  322. package/dist/tools/fs/read-sections.d.ts +11 -0
  323. package/dist/tools/fs/read-sections.js +71 -0
  324. package/dist/tools/fs/read-sections.js.map +1 -0
  325. package/dist/tools/fs/read-window.d.ts +1 -1
  326. package/dist/tools/fs/read-window.js +57 -25
  327. package/dist/tools/fs/read-window.js.map +1 -1
  328. package/dist/tools/fs/read.d.ts +0 -4
  329. package/dist/tools/fs/read.js +34 -17
  330. package/dist/tools/fs/read.js.map +1 -1
  331. package/dist/tools/fs.d.ts +2 -2
  332. package/dist/tools/fs.js +1 -2
  333. package/dist/tools/fs.js.map +1 -1
  334. package/dist/tools/handlers/files-1.js +11 -35
  335. package/dist/tools/handlers/files-1.js.map +1 -1
  336. package/dist/tools/handlers/files-2.js.map +1 -1
  337. package/dist/tools/handlers/shell-1.js +8 -2
  338. package/dist/tools/handlers/shell-1.js.map +1 -1
  339. package/dist/tools/jobs/types.d.ts +3 -0
  340. package/dist/tools/jobs.js +8 -1
  341. package/dist/tools/jobs.js.map +1 -1
  342. package/dist/tools/read-only-shell.d.ts +2 -0
  343. package/dist/tools/read-only-shell.js +65 -0
  344. package/dist/tools/read-only-shell.js.map +1 -0
  345. package/dist/tools/registry.js +0 -9
  346. package/dist/tools/registry.js.map +1 -1
  347. package/dist/tools/retired-tools.js +1 -1
  348. package/dist/tools/retired-tools.js.map +1 -1
  349. package/dist/tools/rtk/rewrite.d.ts +3 -2
  350. package/dist/tools/rtk/rewrite.js +4 -5
  351. package/dist/tools/rtk/rewrite.js.map +1 -1
  352. package/dist/tools/shell/exec-attempt.js +1 -0
  353. package/dist/tools/shell/exec-attempt.js.map +1 -1
  354. package/dist/tools/shell/spawn-argv.js +1 -1
  355. package/dist/tools/shell/spawn-argv.js.map +1 -1
  356. package/dist/tools/shell.d.ts +1 -0
  357. package/dist/tools/shell.js.map +1 -1
  358. package/dist/tui-v2/bootstrap/start-tui-v2.js +0 -2
  359. package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
  360. package/dist/tui-v2/components/modal/keys-modal.js +42 -6
  361. package/dist/tui-v2/components/modal/keys-modal.js.map +1 -1
  362. package/dist/tui-v2/components/pager/pager.js +36 -58
  363. package/dist/tui-v2/components/pager/pager.js.map +1 -1
  364. package/dist/tui-v2/components/transcript/tool-card.js +21 -19
  365. package/dist/tui-v2/components/transcript/tool-card.js.map +1 -1
  366. package/dist/tui-v2/components/transcript/transcript-view.js +24 -21
  367. package/dist/tui-v2/components/transcript/transcript-view.js.map +1 -1
  368. package/dist/tui-v2/components/transcript/use-transcript-selection.d.ts +1 -0
  369. package/dist/tui-v2/components/transcript/use-transcript-selection.js +12 -1
  370. package/dist/tui-v2/components/transcript/use-transcript-selection.js.map +1 -1
  371. package/dist/types.d.ts +16 -1
  372. package/dist/types.js +1 -0
  373. package/dist/types.js.map +1 -1
  374. package/dist/ui/mentions/expand.js +1 -1
  375. package/dist/ui-core/actions/action-id.d.ts +1 -1
  376. package/dist/ui-core/actions/action-id.js +0 -2
  377. package/dist/ui-core/actions/action-id.js.map +1 -1
  378. package/dist/ui-core/actions/format-shortcuts.js +0 -2
  379. package/dist/ui-core/actions/format-shortcuts.js.map +1 -1
  380. package/dist/ui-core/actions/keymap.js +0 -6
  381. package/dist/ui-core/actions/keymap.js.map +1 -1
  382. package/dist/ui-core/bootstrap/composition-root.d.ts +0 -3
  383. package/dist/ui-core/bootstrap/composition-root.js +0 -8
  384. package/dist/ui-core/bootstrap/composition-root.js.map +1 -1
  385. package/dist/ui-core/bootstrap/session-resume.d.ts +5 -0
  386. package/dist/ui-core/bootstrap/session-resume.js +13 -35
  387. package/dist/ui-core/bootstrap/session-resume.js.map +1 -1
  388. package/dist/ui-core/commands/command-handlers.js +3 -1
  389. package/dist/ui-core/commands/command-handlers.js.map +1 -1
  390. package/dist/ui-core/commands/config-commands.js +5 -1
  391. package/dist/ui-core/commands/config-commands.js.map +1 -1
  392. package/dist/ui-core/commands/key-commands.js +50 -30
  393. package/dist/ui-core/commands/key-commands.js.map +1 -1
  394. package/dist/ui-core/commands/keys/auth-picker.d.ts +3 -0
  395. package/dist/ui-core/commands/keys/auth-picker.js +29 -0
  396. package/dist/ui-core/commands/keys/auth-picker.js.map +1 -0
  397. package/dist/ui-core/commands/keys/qoder.d.ts +4 -0
  398. package/dist/ui-core/commands/keys/qoder.js +194 -0
  399. package/dist/ui-core/commands/keys/qoder.js.map +1 -0
  400. package/dist/ui-core/commands/picker-commands.js +19 -1
  401. package/dist/ui-core/commands/picker-commands.js.map +1 -1
  402. package/dist/ui-core/commands/prompt-commands.d.ts +2 -0
  403. package/dist/ui-core/commands/prompt-commands.js +10 -0
  404. package/dist/ui-core/commands/prompt-commands.js.map +1 -0
  405. package/dist/ui-core/commands/rtk-commands.js +35 -16
  406. package/dist/ui-core/commands/rtk-commands.js.map +1 -1
  407. package/dist/ui-core/commands/session-commands.js +13 -5
  408. package/dist/ui-core/commands/session-commands.js.map +1 -1
  409. package/dist/ui-core/controllers/overlay-controller.d.ts +7 -0
  410. package/dist/ui-core/controllers/overlay-controller.js +6 -0
  411. package/dist/ui-core/controllers/overlay-controller.js.map +1 -1
  412. package/dist/ui-core/rendering/batch-sections.d.ts +1 -1
  413. package/dist/ui-core/rendering/batch-sections.js +18 -4
  414. package/dist/ui-core/rendering/batch-sections.js.map +1 -1
  415. package/dist/ui-core/rendering/duration.js +1 -1
  416. package/dist/ui-core/rendering/duration.js.map +1 -1
  417. package/dist/ui-core/rendering/open-tool-output.js +4 -1
  418. package/dist/ui-core/rendering/open-tool-output.js.map +1 -1
  419. package/dist/ui-core/rendering/pager-source.js +3 -0
  420. package/dist/ui-core/rendering/pager-source.js.map +1 -1
  421. package/dist/ui-core/rendering/pager-text.js +3 -0
  422. package/dist/ui-core/rendering/pager-text.js.map +1 -1
  423. package/dist/ui-core/rendering/pager-view-policy.js +4 -2
  424. package/dist/ui-core/rendering/pager-view-policy.js.map +1 -1
  425. package/dist/ui-core/rendering/session-prompts-pager-source.d.ts +3 -0
  426. package/dist/ui-core/rendering/session-prompts-pager-source.js +40 -0
  427. package/dist/ui-core/rendering/session-prompts-pager-source.js.map +1 -0
  428. package/dist/ui-core/rendering/subagent-source.d.ts +1 -1
  429. package/dist/ui-core/rendering/subagent-source.js +37 -1
  430. package/dist/ui-core/rendering/subagent-source.js.map +1 -1
  431. package/dist/ui-core/rendering/text-width.d.ts +1 -0
  432. package/dist/ui-core/rendering/text-width.js +31 -0
  433. package/dist/ui-core/rendering/text-width.js.map +1 -1
  434. package/dist/ui-core/rendering/tool-presenter.d.ts +9 -4
  435. package/dist/ui-core/rendering/tool-presenter.js +43 -91
  436. package/dist/ui-core/rendering/tool-presenter.js.map +1 -1
  437. package/dist/ui-core/state/transcript-store.js +7 -2
  438. package/dist/ui-core/state/transcript-store.js.map +1 -1
  439. package/dist/ui-core/state/transcript-types.d.ts +1 -1
  440. package/dist/ui-core/state/transcript-types.js +4 -2
  441. package/dist/ui-core/state/transcript-types.js.map +1 -1
  442. package/dist/version.generated.d.ts +2 -2
  443. package/dist/version.generated.js +2 -2
  444. package/package.json +8 -3
  445. package/dist/agent/turn/pentest-tools.d.ts +0 -3
  446. package/dist/agent/turn/pentest-tools.js +0 -17
  447. package/dist/agent/turn/pentest-tools.js.map +0 -1
  448. package/dist/classic/bootstrap/suspend-port.d.ts +0 -14
  449. package/dist/classic/bootstrap/suspend-port.js +0 -29
  450. package/dist/classic/bootstrap/suspend-port.js.map +0 -1
  451. package/dist/tools/capabilities.d.ts +0 -12
  452. package/dist/tools/capabilities.js +0 -225
  453. package/dist/tools/capabilities.js.map +0 -1
  454. package/dist/tools/definitions/network.d.ts +0 -2
  455. package/dist/tools/definitions/network.js +0 -17
  456. package/dist/tools/definitions/network.js.map +0 -1
  457. package/dist/tools/definitions/orchestration.d.ts +0 -2
  458. package/dist/tools/definitions/orchestration.js +0 -27
  459. package/dist/tools/definitions/orchestration.js.map +0 -1
  460. package/dist/tools/fs/search.d.ts +0 -32
  461. package/dist/tools/fs/search.js +0 -431
  462. package/dist/tools/fs/search.js.map +0 -1
  463. package/dist/tools/handlers/network-3.d.ts +0 -2
  464. package/dist/tools/handlers/network-3.js +0 -13
  465. package/dist/tools/handlers/network-3.js.map +0 -1
  466. package/dist/tools/handlers/orchestration-2.d.ts +0 -2
  467. package/dist/tools/handlers/orchestration-2.js +0 -16
  468. package/dist/tools/handlers/orchestration-2.js.map +0 -1
  469. package/dist/tools/net-ping-sweep.d.ts +0 -18
  470. package/dist/tools/net-ping-sweep.js +0 -274
  471. package/dist/tools/net-ping-sweep.js.map +0 -1
  472. package/dist/tools/wordlists.d.ts +0 -6
  473. package/dist/tools/wordlists.js +0 -390
  474. package/dist/tools/wordlists.js.map +0 -1
  475. package/dist/tui-v2/bootstrap/pager-export.d.ts +0 -7
  476. package/dist/tui-v2/bootstrap/pager-export.js +0 -19
  477. package/dist/tui-v2/bootstrap/pager-export.js.map +0 -1
  478. package/dist/ui-core/ports/pager-export-port.d.ts +0 -16
  479. package/dist/ui-core/ports/pager-export-port.js +0 -68
  480. package/dist/ui-core/ports/pager-export-port.js.map +0 -1
  481. package/dist/ui-core/rendering/fs-search-summary.d.ts +0 -11
  482. package/dist/ui-core/rendering/fs-search-summary.js +0 -65
  483. package/dist/ui-core/rendering/fs-search-summary.js.map +0 -1
package/README.md CHANGED
@@ -1,460 +1,308 @@
1
1
  # clai
2
2
 
3
- > A fast, terminal-native AI agent that runs real tools — built to run on **free API tiers and subscriptions you already pay for**, stay alive across rate limits with **multi-key + multi-provider switching**, and do serious work: **building, debugging, and scope-based pentesting / bug bounty**.
3
+ clai is a terminal AI assistant for software development, debugging, shell tasks, and authorized security testing. It can inspect a repository, edit files, run checks, manage background processes, and delegate independent research to subagents.
4
4
 
5
- `clai` is an agentic CLI. It doesn't just describe what to do — it edits files, runs shell commands, scans hosts, fetches HTTP evidence, keeps a durable task plan, and verifies its own work before claiming success. It runs in your terminal with three full surfaces — an OpenTUI full-screen console (default on macOS/Linux), a classic Ink UI (default on Windows), and a noninteractive stream renderer for prompts and pipes. Every interactive surface is a full-screen app sharing the same features, commands, and session state.
5
+ Use a hosted API, an account sign-in, or a local Ollama model. Interactive sessions support live reattachment from multiple terminals on the same machine, so you can reconnect over SSH and continue working with the same agent.
6
6
 
7
- Why people pick it over other agent CLIs:
7
+ - **Persistent sessions:** streaming output and agent work continue after a terminal disconnect or `/minimise`; type from any attached terminal.
8
+ - **Three working modes:** ask questions, execute tasks, or review a plan before implementation.
9
+ - **Provider flexibility:** multiple credentials, automatic key rotation, and optional fallback between configured providers.
10
+ - **Tools and integrations:** file editing, shell commands, background jobs, interactive terminals, web search, MCP servers, and Agent Skills.
11
+ - **Long sessions:** saved transcripts, durable subagent findings, context compaction, and pagers for large outputs.
8
12
 
9
- - **Zero cost of entry.** A fresh install runs **keyless out of the box** on the built-in Free provider — no signup, no API key, no card. It stays useful at $0: Freebuff, Gemini, OpenRouter, NVIDIA NIM, Cline, Hetzner and Bynara are all first-class free options, and `/freeonly on` restricts cross-provider fallback to configured free-tier providers.
10
- - **Account sign-in in the terminal.** Freebuff, ChatGPT, GitHub Copilot, Cline, and Kiro support account-based sign-in. Freebuff uses its browser/device approval flow and a hosted session; the subscription-backed providers use their respective subscription credentials.
11
- - **One agent, ~25 providers.** DeepSeek, Kimi, GLM, MiniMax, MiMo, Qwen, OpenAI, Anthropic, Gemini, local Ollama, and a dozen OpenAI-compatible gateways — switch with one command, mid-session if you like.
12
- - **It doesn't die on rate limits.** Up to 10 keys per provider with sticky rotation, optional cross-provider fallback, and retry/backoff tuned per provider. Long jobs survive flaky free tiers.
13
- - **It's honest.** Findings need real tool output. Builds get typechecked/run before "done." Compaction and history keep long sessions coherent instead of hallucinating progress.
13
+ [Installation](#installation) · [Quick start](#quick-start) · [Persistent sessions](#persistent-sessions) · [Providers](#supported-providers) · [Terminals](#terminal-compatibility-and-recommendations) · [Commands](#commands) · [Contributing](CONTRIBUTING.md)
14
14
 
15
- ---
15
+ ## Installation
16
16
 
17
- ## Highlights
17
+ This guide follows the `main` branch. Packaged releases can lag recent changes; use [source setup](CONTRIBUTING.md#source-setup) to run the current development version.
18
18
 
19
- - **Free-tier first.** Built-in **keyless Free** gateway (`free-2/kilo-auto/free`) so a fresh install runs at no cost with zero setup — no API key required.
20
- - **Account sign-in.** `clai auth <freebuff|cline|chatgpt|copilot|kiro|omnirush>` — provider-specific browser/device approval, with supported `--import` paths and multi-credential rotation.
21
- - **Multi-key smart switching.** Up to 10 keys per provider with a *sticky* active key and circular rotation on rate-limit, quota, transient, or 5xx errors. Disable any key to skip it without deleting it. Optional cross-provider fallback and a free-only filter.
22
- - **Broad provider support.** 25+ built-in providers: Freebuff, DeepSeek, Kimi (Moonshot), GLM (Zhipu AI), MiniMax, Xiaomi MiMo, OpenAI, Anthropic, Google Gemini, Ollama, NVIDIA NIM, OpenRouter, Qwen Cloud, Cline, Codex (ChatGPT), GitHub Copilot, Kiro, OmniRush, AgentRouter, AWS Mantle, TokenRouter, Token Harbor, Lightning AI, Modal, Meta, Fireworks, Hetzner, OrcaRouter, Merge Gateway, ExpLabs, Vercel AI Gateway — plus custom OpenAI-compatible endpoints.
23
- - **Parallel subagents.** Independent investigations (recon, research, large refactors) run as read-only subagents concurrently; `/orchestrator` and `/subagents` control and inspect them, with per-role model chains.
24
- - **Agent Skills.** Loads `SKILL.md`-based skills on demand — `/skills` manages them, and relevant skills surface automatically per prompt.
25
- - **Scope-based pentesting.** Opt-in engagement scope with authorized/excluded targets, allowed phases, rate and concurrency ceilings, redirect and DNS-rebinding escape detection, and out-of-scope flagging — designed for authorized pentests and bug-bounty programs.
26
- - **Real building & debugging.** Scaffolds apps, edits code surgically, installs packages, runs builds/tests, starts dev servers as background jobs, and probes them before reporting success.
27
- - **Durable plans.** `plan.create` / `task.update` drive a live checklist that survives context compaction and reloads with `/history` — the agent works task-by-task and won't fake completion.
28
- - **State-preserving compaction.** Automatic and manual `/compact` keep the latest user request verbatim alongside a deterministic work envelope: subagents (id, title, status, and a digest of results already read), live and finished background jobs, Responder-delegated tasks with their read state, touched files, and any credentials you supplied for the task. Before each model dispatch, clai estimates the current assembled request, including the incoming prompt and tool schemas, calibrated with provider-reported usage when available; it does not ask the model to guess its context size. Injected system blocks cannot displace the latest prompt, and successful manual compaction is saved even when the message count stays unchanged. When the history fits the model's window, the summary request replays the cached conversation prefix, so compaction is mostly a cache read.
29
- - **Durable agent sessions.** Interactive sessions run behind a local broker, so an agent keeps working after `/minimise`, an SSH disconnect, or switching to another history session; `clai --resume <id>` reattaches to the same live UI and output stream.
30
- - **Persistent interactive terminals.** Conversation-owned PTY or pipe sessions keep REPLs such as Python, Metasploit, Meterpreter, database consoles, and debuggers open across model turns.
31
- - **Native + text tool calling.** Uses provider-native function calling where available, with a text-fence fallback (`toolCalling: auto|native|text`).
32
- - **MCP, explicitly controlled.** Discovers local stdio and remote HTTP/SSE servers from project configs. MCP tools are off by default; `/mcp` inspects and adds servers, and picking one drops an editable `@mcp:<server>` token into your prompt.
33
- - **Safety gate you control.** Every action is classified safe / confirm / block; deletes always confirm with a preview; destructive patterns are blocked.
19
+ Native releases are available for macOS, Linux, and Windows on x64 and ARM64. They include the runtime; Node.js is required for the npm package and development from source.
34
20
 
35
- ---
21
+ ### macOS and Linux
36
22
 
37
- ## Install
38
-
39
- ### macOS
40
23
  ```sh
41
- brew tap pentoshi007/clai && brew install clai
42
- # or
43
24
  curl -fsSL https://downloads.clai.aniketpandey.website/install/install.sh | sh
44
25
  ```
45
26
 
46
- ### Linux
27
+ The installer verifies the binary's published SHA256 checksum. It installs to `/usr/local/bin` by default; `CLAI_BIN_DIR` selects another directory.
28
+
29
+ Homebrew is also available:
30
+
47
31
  ```sh
48
- curl -fsSL https://downloads.clai.aniketpandey.website/install/install.sh | sh
32
+ brew tap pentoshi007/clai
33
+ brew install clai
49
34
  ```
50
35
 
51
36
  ### Windows
37
+
38
+ Run in PowerShell:
39
+
52
40
  ```powershell
53
41
  irm https://downloads.clai.aniketpandey.website/install/install.ps1 | iex
54
- # or
55
- scoop bucket add clai https://github.com/pentoshi007/clai && scoop install clai
56
42
  ```
57
43
 
58
- ### npm / from source
44
+ ### npm
45
+
46
+ Requires Node.js 22 or later:
47
+
59
48
  ```sh
60
- npm i -g @pentoshi/clai
61
- # or
62
- git clone https://github.com/pentoshi007/clai.git
63
- cd clai && npm install && npm run build && npm start
49
+ npm install -g @pentoshi/clai
64
50
  ```
65
51
 
66
- Node.js ≥ 22. Type `clai` in any terminal to start.
67
-
68
- > **Tip for Linux users:** For the best mouse and hover support in the full-screen TUI, modern GPU-rendered terminals like **Kitty**, **Alacritty**, or **WezTerm** are recommended. On macOS, **iTerm2** and the default Terminal work out of the box.
52
+ On macOS and Linux, the npm installer sets up Bun for the OpenTUI interface when needed. Set `CLAI_NO_BUN_AUTO_INSTALL=1` to skip that setup and use `clai --classic`.
69
53
 
70
- ---
54
+ For manual downloads, use [GitHub Releases](https://github.com/pentoshi007/clai/releases). For a source checkout, follow [CONTRIBUTING.md](CONTRIBUTING.md).
71
55
 
72
56
  ## Quick start
73
57
 
74
- Out of the box, `clai` runs **keyless** on the built-in Free provider — no signup, no API key:
75
-
76
58
  ```sh
77
- clai # launch the full-screen agent console (already on the free provider)
59
+ clai
78
60
  ```
79
61
 
80
- Have a ChatGPT, Copilot, Cline, or Kiro subscription? Sign in instead of buying API credit:
62
+ A fresh configuration uses the keyless Free provider and **ask** mode. Hosted availability and limits depend on the provider. Use `/agent` to enable task execution or `/plan` to prepare a plan for review.
63
+
64
+ To sign in with an existing account, for example ChatGPT:
81
65
 
82
66
  ```sh
83
- clai auth chatgpt # browser or device-code sign-in
67
+ clai auth chatgpt
84
68
  clai use chatgpt
85
69
  clai
86
70
  ```
87
71
 
88
- Prefer a plain API key? Set it and start:
72
+ To use an API key, `clai set` prompts with hidden input when the key is omitted:
89
73
 
90
74
  ```sh
91
- # Add an API key (DeepSeek shown; Gemini, OpenAI, Anthropic, Kimi, etc. work the same)
92
- clai set deepseek sk-your_key_here
75
+ clai set deepseek
93
76
  clai use deepseek
94
-
95
- # Launch the full-screen agent console
96
77
  clai
97
-
98
- # Or one-shot directly from the shell
99
- clai "explain what this repo does and find the entrypoint"
100
- clai --mode agent "add a /health endpoint to the Express app and run the tests"
101
78
  ```
102
79
 
103
- Prefer fully local and offline? Point at Ollama:
80
+ For a local model, start Ollama and download the model you intend to use, then configure its endpoint:
104
81
 
105
82
  ```sh
106
83
  clai set ollama --url http://localhost:11434
107
84
  clai use ollama
85
+ clai model <downloaded-model>
86
+ clai
108
87
  ```
109
88
 
110
- ---
111
-
112
- ## Providers & Key Management
113
-
114
- ### Account sign-in providers (no conventional API key needed)
115
-
116
- Sign in with an account you already have. Browser/device-code flows work on headless servers through a copyable link; `--import` reuses supported local sign-ins or imports provider tokens.
117
-
118
- | Provider | Sign-in | Notes |
119
- |----------|---------|-------|
120
- | **Freebuff** | `clai auth freebuff` | Free, session-gated catalog; browser sign-in or headless link |
121
- | **ChatGPT (Codex)** | `clai auth chatgpt` | Any ChatGPT tier incl. Free; mimics the official Codex CLI |
122
- | **GitHub Copilot** | `clai auth copilot` | Incl. Copilot Free; mimics VS Code Copilot Chat |
123
- | **Cline** | `clai auth cline` | Free `cline-free/*` models plus frontier catalog |
124
- | **Kiro (AWS)** | `clai auth kiro` | AWS Builder ID, Google/GitHub social login, or IAM Identity Center SSO |
125
- | **OmniRush** | `clai auth omnirush` | Device-code sign-in; `--import` reuses an existing OmniRush CLI login |
126
-
127
- Up to 10 credentials can be stored per provider, with automatic key rotation on applicable authentication/quota errors. `clai auth <p> --import` imports supported local sign-ins; Freebuff also imports `FREEBUFF_API_KEY`, `CODEBUFF_API_KEY`, or the upstream `~/.config/manicode/credentials.json` token.
128
-
129
- ### API-key providers
130
-
131
- | Provider | Default Model | Tier | Environment Variable |
132
- |----------|---------------|------|----------------------|
133
- | **Free (keyless)** | `free-2/kilo-auto/free` | Free · Keyless | — (no key needed) |
134
- | **DeepSeek** | `deepseek-chat` | Paid / Usage | `DEEPSEEK_API_KEY` |
135
- | **Kimi (Moonshot)** | `kimi-k3` | Paid / Usage | `KIMI_API_KEY` / `MOONSHOT_API_KEY` |
136
- | **GLM (Zhipu AI)** | `glm-4-plus` | Free tier / Paid | `GLM_API_KEY` / `ZHIPU_API_KEY` |
137
- | **MiniMax** | `MiniMax-Text-01` | Paid / Usage | `MINIMAX_API_KEY` |
138
- | **Xiaomi MiMo** | `mimo-v2.6-pro` | Paid / Usage | `MIMO_API_KEY` |
139
- | **Google Gemini** | `gemini-3.5-flash` | Free tier / Paid | `GEMINI_API_KEY` |
140
- | **NVIDIA NIM** | `openai/gpt-oss-20b` | Free tier | `NVIDIA_API_KEY` |
141
- | **OpenRouter** | `meta-llama/llama-3.3-70b-instruct:free` | Free / Paid | `OPENROUTER_API_KEY` |
142
- | **Ollama** | `llama3.1:8b` | Local / Free | `OLLAMA_HOST` |
143
- | **OpenAI** | `gpt-5.4-mini` | Paid | `OPENAI_API_KEY` |
144
- | **Anthropic** | `claude-3-5-haiku-latest` | Paid | `ANTHROPIC_API_KEY` |
145
- | **Qwen Cloud** | `qwen3.7-plus` | Paid (DashScope) | `DASHSCOPE_API_KEY` |
146
- | **Bynara** | `mimo-v2.5-free` | Free | `BYNARA_API_KEY` |
147
- | **Hetzner** | `Qwen/Qwen3.6-35B-A3B-FP8` | Free (experiment) | `HETZNER_API_KEY` |
148
- | **AgentRouter** | `claude-opus-4-6` | Paid gateway | `AGENTROUTER_API_KEY` |
149
- | **AWS Mantle** | `anthropic.claude-haiku-4-5` | Paid (AWS) | `ANTHROPIC_API_KEY` |
150
- | **TokenRouter** | `moonshotai/kimi-k3` | Paid gateway | `TOKENROUTER_API_KEY` |
151
- | **Token Harbor** | `claude-sonnet-5.5` | Paid gateway (free tier) | `TOKENHARBOR_API_KEY` |
152
- | **Lightning AI** | `openai/gpt-5` | Free grant / Paid | `LIGHTNING_API_KEY` |
153
- | **Modal** | `moonshotai/Kimi-K3` | Your own endpoint ($30/mo credit) | `MODAL_PROXY_TOKEN_ID` |
154
- | **Meta (Muse)** | `muse-spark-1.2` | Paid | `MODEL_API_KEY` |
155
- | **Fireworks** | `accounts/fireworks/models/kimi-k2p6` | Paid | `FIREWORKS_API_KEY` |
156
- | **OrcaRouter** | `openai/gpt-4o-mini` | Paid gateway (zero markup) | `ORCAROUTER_API_KEY` |
157
- | **Merge Gateway** | `openai/gpt-5.2` | Paid gateway | `MERGE_GATEWAY_API_KEY` |
158
- | **ExpLabs** | `claude-fable-5.1` | Paid / BYOK gateway | `EXPLABS_API_KEY` |
159
- | **Vercel AI Gateway** | `openai/gpt-5.4-mini` | Paid gateway | `AI_GATEWAY_API_KEY` |
160
-
161
- Model catalogs use each provider's supported discovery source; most expose a dedicated models endpoint. Freebuff does not: clai reads account-visible model IDs from its read-only session endpoint and merges them with a source-versioned fallback. You can switch models anytime using `/model` or `clai model <name>`, browse the whole fleet with `/models`, and read setup details for any provider with `/info <provider>`.
162
-
163
- ### Freebuff setup and behavior
164
-
165
- Freebuff is a hosted, free-tier provider that requires an account sign-in. Free-mode inference is only served to the genuine freebuff CLI: the server refuses direct API calls (free_mode_cli_required), so clai manages sign-in and the live model catalog but refuses generation requests fast with an actionable message. The default model is `z-ai/glm-5.3-flash`.
89
+ You can also run a prompt directly or pipe input:
166
90
 
167
91
  ```sh
168
- clai auth freebuff # sign in, then approve in your browser
169
- clai use freebuff
170
- clai # start the interactive agent
171
- clai model z-ai/glm-5.3-flash # set a model from the catalog
172
- # in the interactive console: /model · /info freebuff
92
+ clai "explain this repository and identify its entrypoint"
93
+ clai --mode agent "add a health endpoint and run the relevant tests"
94
+ git diff | clai --quiet "review this diff for bugs"
173
95
  ```
174
96
 
175
- On a desktop, `clai auth freebuff` opens the approval page when possible. On SSH/headless Linux it prints a URL to open on any device; no localhost callback or port-forwarding is required. To import an existing token, use `clai auth freebuff --import`. Import checks `FREEBUFF_API_KEY`, `CODEBUFF_API_KEY`, then the upstream `~/.config/manicode/credentials.json` file (or `FREEBUFF_CONFIG_DIR`). A token can also be entered with `clai set freebuff <token>`. clai stores credentials through its existing secure key storage; up to 10 credentials can be configured and rotated on authentication or quota errors.
176
-
177
- The login token is an opaque bearer credential. It has no refresh token or documented expiry; if the server returns 401, sign in again or replace the token. Keep it secret and do not paste it into chat or commit it to a repository.
178
-
179
- #### Sessions, models, and spending
180
-
181
- clai admits no Freebuff session for inference and spends no wallet Freebucks: every direct inference attempt is refused server-side, so the request stops before any session state mutates. To use these models, run the genuine client (`npm i -g freebuff`, then `freebuff`). Because inference is unavailable, Freebuff is intentionally excluded from automatic cross-provider fallback; select it explicitly only for sign-in and catalog browsing.
97
+ ## Persistent sessions
182
98
 
183
- `/model` lists only the models the server currently reports as applicable to the signed-in account (live rate-limit pools plus zero-price models, minus plan-gated ids), cached per credential for up to 30 minutes. The bundled model-ID table is only an offline fallback when the session probe is unreachable; nothing is hardcoded into the live list. Freebuff does not provide the separately probed `/api/v1/models` endpoint, nor does the session catalog publish per-model context-window limits. Context sizes therefore use clai's generic estimates rather than claimed live Freebuff limits. Modality and reasoning support are recognized from known model patterns; not every catalog item is guaranteed to support images or a configurable effort.
99
+ ### Detach and resume
184
100
 
185
- #### Tools, images, thinking, and caching
101
+ Run `/minimise` inside the interactive console to return to your shell while the agent continues. `/minimize` and `/minmize` are aliases. The detach message includes the session ID and a resume command.
186
102
 
187
- clai does not run Freebuff inference, so no Chat Completions or SSE streaming path is exercised against this provider. `/model` lists only the models the server currently reports as applicable to the signed-in account (live rate-limit pools plus zero-price models, minus plan-gated ids), cached per credential for up to 30 minutes. The bundled model-ID table is only an offline fallback when the session probe is unreachable; nothing is hardcoded into the live list.
103
+ | Command | Behavior |
104
+ | --- | --- |
105
+ | `clai --resume` | Resume the most recently updated live or saved session across directories. |
106
+ | `clai --resume <id>` | Resume a specific session; a unique ID prefix also works. |
107
+ | `clai -c` or `clai --continue` | Prefer the latest session for the current directory, with a saved-session fallback when none matches. |
108
+ | `clai history` or `/history` | Find saved sessions and see whether an agent is running, attached, or detached. |
188
109
 
189
- On clean TUI shutdown and after a noninteractive run, clai awaits best-effort deletion of its own CLI session claims. Forced termination, process crashes, or an unreachable server can prevent that request; the server-side session expiry still applies. clai never sends a delete for a claim it does not own.
110
+ Reattaching to a live session opens its existing UI. Resuming a saved session restores its conversation and transcript. Bare `--resume` also uses the original working directory if it still exists. Resume flags apply to interactive sessions; prompts supplied on the command line run separately.
190
111
 
191
- #### Troubleshooting
112
+ ### SSH and multiple terminals
192
113
 
193
- - **401 / invalid token:** run `clai auth freebuff` again or replace the saved token. There is no refresh-token flow.
194
- - **409 session_superseded / 403 free_mode_cli_required on generation:** expected. The server only serves free-mode turns to the genuine freebuff CLI; clai refuses before spending anything. Use `freebuff` for these models or `/provider` for another provider.
195
- - **Quota, model-unavailable, country, or account refusal:** follow the server's message; wait for the indicated reset/window or choose a currently available model with `/model`.
196
- - **Wallet consent required:** clai has not spent anything. It always requests zero wallet spend; use a free-eligible model or review the purchase in a Freebuff-supported surface.
197
- - **Catalog does not refresh:** `/model` uses the account-visible session response and a 30-minute per-account cache. If the session probe is unreachable, clai displays its bundled catalog fallback; the hosted `/api/v1/models` endpoint is not available.
198
- - **Session remains after a forced stop:** clean exits attempt deletion; otherwise Freebuff's server-side expiry clears it.
114
+ After an SSH disconnect, reconnect to the same machine as the same OS user and run `clai --resume`. To share a particular live session, run `clai --resume <id>` in another terminal or SSH connection.
199
115
 
200
- ### ChatGPT (Codex) subscription behavior
116
+ Every attachment sees the same live screen and can type immediately, including prompts and shortcuts. Attachments share one composer and one running agent. The screen fits the smallest attached terminal. Closing or minimising one attachment keeps the agent and the other attachments running.
201
117
 
202
- - `clai auth chatgpt` signs in with ChatGPT; `--headless` uses a device code, and `--import` reuses an existing Codex CLI sign-in.
203
- - `/model` uses the live account-visible catalog and installed Codex client version. Model context limits and supported reasoning levels follow the catalog; account-scoped results refresh every five minutes and are cached for offline use.
204
- - `/usage` shows ChatGPT subscription limits, reset times, and credits when the account reports them, alongside session token and cache usage. Subscription allowances are separate from session token totals.
118
+ Durable sessions require an interactive terminal, a compatible PTY transport, and history enabled. Private mode and `--no-history` use foreground sessions. Saved history remains available after the live process ends; an active process still depends on its host machine remaining running.
205
119
 
206
- ### OmniRush session uploads
120
+ ### History and context
207
121
 
208
- For OmniRush sessions, clai invokes the OmniRush CLI to upload a **synthetic lifecycle workspace** after turns and at session close. It contains the session id, sequence, lifecycle phase, status, and timestamp—not your project source, prompts, or tool-output transcript. The CLI must be available and signed in; missing CLI or login errors produce a notice without failing the agent turn.
122
+ `/new` starts a fresh session and saves the previous one. If work is still running, it remains in its previous session. `/save <name>` names a session, and `/prompts` browses sent prompts with their timestamps and provider, model, and effort metadata.
209
123
 
210
- Uploads are disabled by `--no-history`, private mode (`/privacy on`), or `CLAI_OMNIRUSH_SESSION_UPLOAD=0` (also accepts `false`, `off`, or `no`). `OMNIRUSH_CLI_PATH` selects a custom OmniRush executable.
124
+ Context compaction reduces what the model receives while retaining recent requests, plans, task state, and available research findings. It does not erase the saved chat transcript. Use `/compact` to compact manually, `/context` to inspect context size, and `/output` to read retained tool output.
211
125
 
212
- ### Manage Keys
126
+ `/clear` deletes the current session and starts fresh. `/reset` clears all saved history. These are deletion commands; use `/new` when you want to keep the previous conversation.
213
127
 
214
- ```sh
215
- clai set deepseek sk-first_key # store a key
216
- clai set deepseek sk-second_key # add another key for multi-key rotation
217
- clai set gemini --from-env GEMINI_API_KEY
218
- echo "sk-..." | clai set deepseek --stdin
219
- clai set ollama --url http://localhost:11434
220
- clai keys # list providers with masked keys (★ active)
221
- clai use deepseek # set active provider
222
- clai provider # interactive provider/model selector
223
- clai unset deepseek # remove keys for a provider
224
- ```
225
-
226
- In the interactive console:
227
- - **`/set`** opens the multi-row key editor. Add keys (`+`), set the active key (★), or disable a key (`○`) without deleting it.
228
- - **`/keys`** displays configured keys (masked) and active status.
229
- - **`/provider`** and **`/model`** open interactive pickers for switching providers and models on the fly.
230
- - **`/info <provider>`** shows per-provider setup, pricing, and endpoint details.
231
-
232
- ### Smart Switching & Resilience
233
-
234
- - **Multi-key rotation** — Store up to **10 keys per provider**. The last key that worked is *sticky*. On encountering a rate limit (HTTP 429), quota limit, auth error, or 5xx server error, `clai` automatically rotates to the next available key.
235
- - **Disable without deleting** — Toggle any key disabled in the `/set` editor; rotation skips it until you re-enable it.
236
- - **Cross-provider fallback** *(opt-in)* — `/fallback on` lets `clai` fall back to other configured providers when the active provider is exhausted.
237
- - **Token-saving shell output** *(opt-in)* — `/rtk on` routes foreground `shell.exec` commands through [rtk](https://github.com/rtk-ai/rtk) via `rtk rewrite`, so the model reads compact output. Only the executed command changes: the model's tool call, approvals, and history keep the original, and the system prompt and tool schemas never change, so the prompt cache prefix is never invalidated. Background jobs, interactive/PTY sessions, sudo, and commands clai already reduces (nmap, ffuf, …) are never rewritten; if rtk is missing, busy updating, or fails, commands run unmodified. No rtk yet? `/rtk install` (or **Install rtk** on the `/rtk` screen) uses Homebrew, else rtk's checksum-verified installer, else cargo (winget, else cargo, on Windows) in the background; `/rtk update` upgrades through whichever tool installed it. rtk is found even when its directory is not on `PATH`, and a same-named impostor binary is skipped. All rewrite rules live in rtk itself, so updating rtk never requires a clai release.
238
- - **Free-only mode** *(opt-in)* — `/freeonly on` restricts fallback strictly to free tiers (Free, Gemini, OpenRouter, NIM, Bynara, Hetzner, and the free-lane subscription providers) so you never accidentally spend.
239
- - **Usage visibility** — `/usage` shows token consumption per provider and model, including cache reads and writes, so you can see what a session actually cost. It counts every billed request: subagents, title generation, compaction, and retried attempts whose stream died after the provider had already billed the prompt.
240
-
241
- ---
242
-
243
- ## What clai is good at
244
-
245
- ### Building & debugging
128
+ ## Providers and usage
246
129
 
247
- The same agent that runs recon also ships code. It explores before it writes, matches your existing stack from lockfiles, edits surgically, and proves the result:
130
+ clai supports API credentials, account sign-ins, and local endpoints. Account integrations include ChatGPT, GitHub Copilot, Cline, Kiro, OmniRush, and Qoder. Freebuff has separate admission requirements described in the [provider guide](PROVIDERS.md#freebuff).
248
131
 
249
- - Scaffolds and extends apps; replaces starter boilerplate with real features.
250
- - Surgical file tools: `fs.edit`, `fs.replaceLines`, `fs.append`, plus multi-file writes.
251
- - Runs the checks that apply — typecheck, build, unit/integration tests — and fixes failures before claiming success.
252
- - Starts dev servers as background jobs, tails until ready, probes `localhost`, and reports the URL / port / job id with the server left running.
253
- - Debugging loop: reproduce → read the actual error → fix root cause → re-verify.
132
+ ### Supported providers
254
133
 
255
- ```sh
256
- clai --mode agent "convert this Vite React app to Next.js App Router, keep all features, run the build"
257
- clai --mode agent "this test is flaky — find the race and fix it"
258
- ```
259
-
260
- ### Parallel subagents & Agent Skills
134
+ Account sign-in integrations:
261
135
 
262
- For work with several independent threads — recon on multiple targets, researching unrelated bugs, surveying a large codebase — `clai` delegates read-only investigations to **subagents** that run concurrently and report back with evidence:
136
+ | Provider | Sign-in command | Notes |
137
+ | --- | --- | --- |
138
+ | ChatGPT (Codex) | `clai auth chatgpt` | Stored as `codex`; browser/headless sign-in or existing Codex CLI import. |
139
+ | GitHub Copilot | `clai auth copilot` | Browser/device sign-in or supported credential import. |
140
+ | Cline | `clai auth cline` | Account sign-in or supported credential import. |
141
+ | Kiro | `clai auth kiro` | Social login, AWS Builder ID, or IAM Identity Center. |
142
+ | OmniRush | `clai auth omnirush` | Device-code sign-in or existing OmniRush CLI import. |
143
+ | Qoder | `clai auth qoder` | Browser/headless sign-in, CLI import, or PAT via `--pat`. |
144
+ | Freebuff | `clai auth freebuff` | Sign-in and catalog support; inference requires server admission. |
263
145
 
264
- - `/orchestrator on|off|status|models` — control delegation and assign cheaper models to subagent roles.
265
- - `/subagents` — inspect live assignments; stop or restart one by id.
146
+ API, keyless, and local integrations:
266
147
 
267
- **Agent Skills** extend the agent with reusable `SKILL.md` playbooks (bundled or your own). Skills are discovered from standard locations, ranked per prompt, and loaded on demand; `/skills list|refresh` manages them.
148
+ | Provider | Provider ID | Credential or endpoint variable |
149
+ | --- | --- | --- |
150
+ | Free | `free` | Keyless models; optional `FREE_API_KEY` for authenticated access. |
151
+ | Ollama | `ollama` | Local endpoint through `OLLAMA_HOST` or `clai set ollama --url <url>`. |
152
+ | Anthropic | `anthropic` | `ANTHROPIC_API_KEY` |
153
+ | DeepSeek | `deepseek` | `DEEPSEEK_API_KEY` |
154
+ | Google Gemini | `gemini` | `GEMINI_API_KEY` |
155
+ | GLM / Zhipu | `glm` | `GLM_API_KEY`, `ZHIPU_API_KEY`, or `ZAI_API_KEY` |
156
+ | Kimi / Moonshot | `kimi` | `KIMI_API_KEY` or `MOONSHOT_API_KEY` |
157
+ | MiniMax | `minimax` | `MINIMAX_API_KEY` |
158
+ | Xiaomi MiMo | `mimo` | `MIMO_API_KEY` |
159
+ | NVIDIA NIM | `nvidia` | `NVIDIA_API_KEY` |
160
+ | OpenAI | `openai` | `OPENAI_API_KEY` |
161
+ | OpenRouter | `openrouter` | `OPENROUTER_API_KEY` |
162
+ | Qwen Cloud / DashScope | `qwen-cloud` | `DASHSCOPE_API_KEY` |
163
+ | AgentRouter | `agentrouter` | `AGENTROUTER_API_KEY` |
164
+ | AWS Mantle | `aws-mantle` | `ANTHROPIC_API_KEY` for the configured Mantle endpoint. |
165
+ | Bynara | `bynara` | `BYNARA_API_KEY` |
166
+ | ExpLabs | `explabs` | `EXPLABS_API_KEY` |
167
+ | Fireworks | `fireworks` | `FIREWORKS_API_KEY` |
168
+ | Hetzner | `hetzner` | `HETZNER_API_KEY` |
169
+ | Lightning AI | `lightning` | `LIGHTNING_API_KEY` |
170
+ | Merge Gateway | `merge-gateway` | `MERGE_GATEWAY_API_KEY` |
171
+ | Meta Model API | `meta` | `MODEL_API_KEY` |
172
+ | Modal | `modal` | Both `MODAL_PROXY_TOKEN_ID` and `MODAL_PROXY_TOKEN_SECRET`; deployed endpoint required. |
173
+ | OrcaRouter | `orcarouter` | `ORCAROUTER_API_KEY` |
174
+ | Token Harbor | `tokenharbor` | `TOKENHARBOR_API_KEY` |
175
+ | TokenRouter | `tokenrouter` | `TOKENROUTER_API_KEY` |
176
+ | Vercel AI Gateway | `vercel` | `AI_GATEWAY_API_KEY` |
268
177
 
269
- ### Scope-based pentesting & bug bounty
178
+ Use `clai set <provider>` for a hidden-input credential prompt, or `--from-env <variable>` to import a credential. The [provider guide](PROVIDERS.md) includes account flows, endpoint setup, and provider-specific behavior. `/model` shows model choices; access, limits, and prices depend on the provider and account.
270
179
 
271
- `clai` is built to run real, authorized security work — not to narrate it. It follows a recon-first methodology and keeps you inside the boundaries you set.
180
+ ### Models, rotation, and usage
272
181
 
273
- ```
274
- recon / discovery → fingerprint stack → plan.create (kind=pentest)
275
- ↑ │
276
- │ /implement (approve)
277
- │ ↓
278
- └──── enumerate → exploit → post-ex → report
279
- (revise the plan as surface grows; keep completed tasks)
280
- ```
182
+ - `/provider` selects a provider; `/model` selects its model; `/models` browses models across providers.
183
+ - `/set` manages up to 10 credentials per provider, including disabled keys and the active key. Applicable authentication, quota, rate-limit, and server failures can trigger rotation.
184
+ - `/fallback on` enables cross-provider fallback; it is off by default. `/freeonly on` filters fallback using clai's provider categories. Check the selected model and account's billing terms when controlling spending.
185
+ - `/effort` configures reasoning where supported. Qoder uses the selected effort, including `xhigh`, and displays thinking when returned by the model.
186
+ - `/usage` shows reported token and cache usage across main turns, subagents, and auxiliary requests. Supported account providers also expose quota or subscription information. Token totals are not a billing invoice.
281
187
 
282
- 1. **Authorize once**, then optionally **define scope** — authorized targets, exclusions, allowed phases, rate/concurrency ceilings, and an expiry.
283
- 2. **Recon first** (read-only discovery needs no plan): whois, DNS, `net.pingSweep`, `http.fetch`, and shell tools like `nmap`, `ffuf`, `nuclei`, `sqlmap` — orchestrated with durable checkpoints.
284
- 3. **Analyze real evidence**, then `plan.create` with `kind=pentest` from actual ports/services/endpoints — then stop for your approval.
285
- 4. `/implement` and execute task-by-task; expand the plan as new attack surface appears without wiping completed work.
286
- 5. **Report** with structure — title, severity, evidence, reproduction, impact, remediation — and honest residual/untested notes.
287
-
288
- **Scope enforcement is real, not cosmetic.** When scope is active, `clai` checks each target against your authorized/excluded lists, enforces token-bucket rate limits and a concurrency ceiling, detects **redirects that leave scope** and **DNS-rebinding escapes**, and flags out-of-scope hosts instead of touching them.
289
-
290
- ```sh
291
- clai authorize-pentest AGREE
292
- clai scope new --targets lab.example.com,10.10.0.0/24 --exclude prod.example.com \
293
- --phases recon,enumeration --max-rate 5 --max-concurrency 2
294
- # in the console: /scope show · /scope add <targets> · /scope clear
295
- ```
188
+ The [provider guide](PROVIDERS.md) covers authentication, environment variables, endpoint configuration, and provider-specific behavior. Model catalogs and account access can change; use `/model` and the provider's own dashboard for availability.
296
189
 
297
- ### General security & sysadmin workflows
190
+ ## Working with clai
298
191
 
299
- Log triage, config hardening, packaging, network analysis, OCR of a screenshot or PDF report, quick OSINT — all handled by the same agent under the same safety gate.
192
+ ### Modes and permissions
300
193
 
301
- ---
194
+ | Mode | Purpose |
195
+ | --- | --- |
196
+ | `ask` | Questions, explanations, and read-only investigation. This is the initial default. |
197
+ | `agent` | Execute tasks with file, shell, and other tools under the configured permission policy. |
198
+ | `plan` | Gather evidence and prepare a plan. Review it with `/view-plan`, then use `/implement` to approve execution or `/discard` to remove it. |
302
199
 
303
- ## Modes & reasoning
200
+ Switch modes with `/ask`, `/agent`, `/plan`, or `Shift+Tab`. `clai mode <mode>` sets the default for new sessions.
304
201
 
305
- Codex subscription sessions preserve compatible encrypted reasoning for normal continuation. If a restored session's `/compact` request rejects it with `invalid_encrypted_content`, clai retries once on the same model without the rejected opaque replay, retaining visible text, tool history, and generation settings. Unrelated errors or failures after streamed output do not trigger this recovery; failed compaction retains the original context.
202
+ Fresh configurations use **auto-allow** permissions. `/permissions default` enables the more conservative confirmation policy; `/permissions auto-allow` allows eligible actions automatically while retaining confirmation for out-of-folder or unresolved deletions. `/permissions full-access` further relaxes confirmations. Ask/plan restrictions, OS permissions, engagement scope, and hard safety blocks still apply.
306
203
 
307
- Three modes, switchable anytime with a slash command, `Shift+Tab`, or `clai --mode`:
204
+ When an approval prompt appears, `Ctrl+O` opens the complete pending operation, including its arguments and working directory. Reading the operation does not approve it. These policies govern clai's tool execution; they are not an OS sandbox.
308
205
 
309
- | Mode | Use |
310
- |------|-----|
311
- | **ask** | Answers, methodology, and read-only tools — no mutations, no attacks. |
312
- | **agent** | Executes: edits, installs, scans, verifies, works the plan. |
313
- | **plan** | Research and design a durable plan; approve with `/implement` before execution. |
206
+ ### Subagents and background work
314
207
 
315
- **Reasoning / thinking** is controlled with `/effort` (alias `/reasoning`), accepting `on`, `off`, `none`, `minimal`, `low`, `medium`, `high`, or `xhigh`. `clai` sends reasoning options only to models that support them.
208
+ `/orchestrator` controls delegation and subagent model choices. `/subagents` shows assignments and lets you stop or restart an investigation. Retained findings and delivery state help the parent reuse completed research after compaction or resuming a session.
316
209
 
317
- ---
210
+ The agent can keep development servers and long commands running as background jobs. Use `/jobs` to inspect them and `/output` to browse output. Conversation-owned interactive terminals support REPLs, debuggers, and database consoles across model turns.
318
211
 
319
- ## Safety gate
212
+ `/rtk on` optionally compresses eligible foreground shell output through [rtk](https://github.com/rtk-ai/rtk). It is off by default; `/rtk install`, `/rtk update`, and `/rtk status` manage the integration.
320
213
 
321
- You own authorization; `clai` gates risk on every action:
214
+ ### Authorized security testing
322
215
 
323
- | Level | Behavior |
324
- |-------|----------|
325
- | **safe** | Auto-runs read-only work: `fs.read/list/search`, `tool.check`, `http.fetch` GET, `web.search`/`web.fetch`, recon commands. |
326
- | **confirm** | Applies the selected permission mode to mutations; filesystem scope can require approval even with `--yes` or a tool allow-list. |
327
- | **block** | Refuses destructive patterns (`rm -rf /`, fork bombs, exfiltration signatures) and SSRF-prone fetches. |
216
+ clai can assist with reconnaissance, enumeration, scoped testing, and reporting using installed tools. Test systems you own or have permission to assess.
328
217
 
329
- Use `/permissions` in either UI to select a persistent permission mode:
218
+ `clai authorize-pentest AGREE` stores the authorization acknowledgement. Use `clai scope` to configure the default engagement scope inherited by new sessions, or `/scope` to configure the current session. Scope can define authorized targets, exclusions, phases, and limits. Plan mode supports evidence gathering before you approve implementation.
330
219
 
331
- | Permission mode | Writes, creates, edits | File deletion (`fs.delete` and shell `rm`) |
332
- |-----------------|-----------------------|-------------------------------------------|
333
- | **default** | Allowed inside the active folder; outside writes ask | Always asks |
334
- | **auto-allow** *(default)* | Allowed everywhere | Allowed inside the active folder; outside or unresolved targets ask |
335
- | **full-access everywhere** | Allowed everywhere | Allowed everywhere without confirmation |
220
+ ## Terminal interface
336
221
 
337
- Set a mode directly with `/permissions default`, `/permissions auto-allow`, or `/permissions full-access`, or from the CLI with `clai config set permissions <mode>`. The legacy `allow-all` value remains an alias for auto-allow; existing explicit choices survive upgrades and restarts. `/allow` and `/disallow` manage per-session tool allowances, but cannot bypass a required filesystem-scope prompt.
222
+ OpenTUI is selected by default on macOS and Linux when the terminal is at least 60 columns by 14 rows and the runtime is available. Windows and smaller terminals use Classic, which runs on React and Ink. `clai --classic` selects Classic explicitly; `clai --tui` requests OpenTUI with a Classic fallback when unavailable.
338
223
 
339
- The active folder is the pinned project root, or the current working directory when no project is pinned—not every temporary directory. Shell checks cover direct, piped, compound, and wrapped deletion commands and account for explicit cwd, traversal, and symlink escapes. Dynamic targets, unsupported shell syntax, and indirect deletion with unresolved inputs require approval under auto-allow; this policy is not an OS sandbox. Full-access changes confirmation policy, not ask-mode restrictions, OS permissions, engagement scope, or hard safety blocks.
224
+ Both interfaces provide streaming chat, tool output, plans, session history, and provider controls.
340
225
 
341
- ### Reviewing what you approve
226
+ ### Terminal compatibility and recommendations
342
227
 
343
- Before you authorize anything, press **Ctrl+O** on any approval or password prompt to page the *complete* pending operation—the same way plan mode lets you read the plan before implementing. The review shows the operation name, working directory, active folder, resolved filesystem paths, and the full untruncated arguments, including complete shell commands and surrounding `cwd`.
228
+ Choose a terminal for the OS on your local device. These recommendations link to each terminal's official setup information:
344
229
 
345
- - Press **Ctrl+O** on a tool, pentest, or sudo/secret prompt to open the review pager. Scroll it, search it, and close it to return to the pending prompt.
346
- - Viewing approves nothing, cancels nothing, and executes nothing. The prompt stays pending until you answer it explicitly.
347
- - Deletion prompts keep **v** for the existing file-content preview; **Ctrl+O** shows the operation descriptor instead. The content preview is capped while the descriptor is not.
348
- - Sensitive values stay masked: password, secret, token, cookie and API-key fields are redacted, as are recognizable provider keys and `Bearer` credentials. Control characters are shown as escapes so nothing is silently hidden.
349
- - Terminal/`-y` (non-interactive) runs page the same review before the y/n question when stdin is a TTY; without a TTY they still fail closed instead of reading a piped answer.
350
- - Returning from the pager never authorizes. A partially typed password survives the round trip, and `esc` still cancels.
230
+ | Local OS | Recommended terminal | Alternatives |
231
+ | --- | --- | --- |
232
+ | Linux | [Kitty](https://sw.kovidgoyal.net/kitty/binary/) | [WezTerm](https://wezterm.org/installation.html) or [Alacritty](https://alacritty.org/). |
233
+ | macOS | [iTerm2](https://iterm2.com/) | [Kitty](https://sw.kovidgoyal.net/kitty/binary/), [WezTerm](https://wezterm.org/installation.html), or [Alacritty](https://alacritty.org/); the built-in Terminal app is also an option. |
234
+ | Windows | [Windows Terminal](https://learn.microsoft.com/en-us/windows/terminal/) | [WezTerm](https://wezterm.org/installation.html) or [Alacritty](https://alacritty.org/). |
351
235
 
352
- ---
236
+ clai selects its interface using the OS where it runs. Native Windows uses Classic; WSL and SSH sessions on a Linux host use the Linux interface selection, even when the local window is Windows Terminal or iTerm2. Over SSH, key, mouse, and clipboard capabilities come from your local terminal and any intervening multiplexer.
353
237
 
354
- ## Terminal UI
238
+ Standard terminals can handle ordinary text input and output. Modified keys, mouse motion/hover, and clipboard integration vary by terminal and configuration. If `Shift+Enter` is not distinguishable from `Enter`, use `Ctrl+N` or `Alt+Enter` for a newline. Use `clai --classic` if OpenTUI cannot start, and `F5` or `/redraw` to repaint a scrambled screen.
355
239
 
356
- The interactive console provides streaming chat, nested tool cards, file diffs, a live plan pane, pickers, session history, and masked key prompts.
240
+ ### Keyboard shortcuts
357
241
 
358
- | Action | Key |
359
- |--------|-----|
360
- | Send / newline | `Enter` / `Shift+Enter` |
361
- | Abort turn (keeps results) | `Esc` |
362
- | Interrupt / quit | `Ctrl+C` (twice to quit) |
363
- | Cycle mode (ask→agent→plan) | `Shift+Tab` |
364
- | Plan pane / plan detail | `Ctrl+H` / `Ctrl+P` |
242
+ | Action | Shortcut |
243
+ | --- | --- |
244
+ | Send prompt | `Enter` |
245
+ | Insert newline | `Shift+Enter`, `Alt+Enter`, or `Ctrl+N` |
246
+ | Cancel current turn | `Esc` |
247
+ | Interrupt; press again to quit | `Ctrl+C` |
248
+ | Cycle mode | `Shift+Tab` |
249
+ | Toggle plan pane / details | `Ctrl+H` / `Ctrl+P` |
365
250
  | Background jobs | `Ctrl+J` |
366
251
  | Expand thinking / tool output | `Ctrl+T` / `Ctrl+O` |
367
- | Copy focused thinking block | `c` |
368
- | Search transcript | `Ctrl+R` |
369
- | Copy selection | `Ctrl+Shift+C` |
370
- | Commands / file mentions | `/` · `@` |
371
- | MCP servers / project config | `/mcp` |
372
- | Command help / shortcut reference | `Ctrl+G` / `/shortcuts` |
373
-
374
- - **Thinking blocks:** Clickable `✦ Thought for 3.2s` rows open internal reasoning in a scrollable card (`Ctrl+T`). Pressing `c` copies the reasoning text.
375
- - **Tool cards:** Show running commands with live elapsed timers, status indicators, and expandable output pagers (`Ctrl+O`) with search and copy capabilities. Large tool outputs spill to artifacts automatically, keeping the transcript and context window lean.
376
- - **File diffs:** Edits and writes render clean inline diff previews before changes take effect.
377
-
378
- ### Background sessions, minimise, and SSH reattach
379
-
380
- Interactive sessions run behind a local broker so an agent continues working across terminal disconnects:
381
-
382
- - **`/minimise`** (or `/minimize`) detaches immediately and returns you to your shell without interrupting the turn. It displays the session ID and resume command.
383
- - **SSH disconnects:** If an SSH session drops, reconnect and run `clai --resume <id>` (or `clai -c` to continue the latest session in the current directory).
384
- - **`/history`** lists all active, attached, and detached sessions.
385
-
386
- ---
387
-
388
- ## Slash commands
389
-
390
- | Command | Does |
391
- |---------|------|
392
- | `/ask` · `/agent` · `/plan` | Switch mode (plan = design a plan you approve before anything runs) |
393
- | `/view-plan` | View the current plan without changing mode |
394
- | `/implement` · `/discard` | Approve and execute or drop the current plan |
395
- | `/model [name]` · `/models [filter]` | Select model · browse all models across providers |
396
- | `/provider [name]` | Switch provider or open picker |
397
- | `/set [provider]` · `/unset [provider]` · `/keys` | Manage API keys and view provider configuration |
398
- | `/info [provider]` | Setup, pricing, and endpoint details for a provider |
399
- | `/effort [level]` · `/reasoning [level]` | Configure thinking / reasoning effort |
400
- | `/freeonly [on\|off]` · `/fallback [on\|off]` | Free-only filter · cross-provider fallback |
401
- | `/orchestrator [...]` · `/subagents` | Control subagent delegation · inspect live subagents |
402
- | `/rtk [on\|off\|status\|install\|update]` | Compress shell output through [rtk](https://github.com/rtk-ai/rtk) (off by default) · install or update rtk |
403
- | `/skills [name\|list\|refresh]` | Manage Agent Skills |
404
- | `/search [provider]` · `/search-provider` | Choose web-search backend |
405
- | `/mcp [...]` | Browse, configure, start, or stop MCP servers |
406
- | `/scope [show\|add\|new\|clear]` | Manage engagement scope |
407
- | `/output [last\|id\|list]` | Open full tool output pager (also `Ctrl+O`) |
408
- | `/jobs` | View background jobs (also `Ctrl+J`) |
409
- | `/compact` · `/context` · `/usage` | Compact history · context size · token usage per provider/model |
410
- | `/history` · `/save <name>` · `/new` · `/clear` · `/reset` | Session lifecycle management |
411
- | `/allow <tool>` · `/disallow <tool>` · `/permissions` | Tool permission management |
412
- | `/cwd <path>` | Change working directory |
413
- | `/think` · `/thinking` | Show thinking from the last response |
414
- | `/privacy [...]` | Private mode · clear history, logs, or artifacts |
415
- | `/minimise` · `/minimize` | Detach terminal while the session runs in background |
416
- | `/update` · `/help` · `/shortcuts` · `/exit` | Utilities and exit |
417
-
418
- ---
419
-
420
- ## CLI commands
421
-
422
- ```sh
423
- clai [prompt...] # interactive UI, or one-shot with a prompt
424
- --mode <ask|agent|plan> --provider <p> --model <m>
425
- -y/--yes --no-history
426
- --show-thinking --verbose --quiet # one-shot stream controls
427
- --tui --classic
428
- --resume <sessionId> -c/--continue # reattach live or reopen saved session
429
-
430
- clai auth <provider> # OAuth sign-in: cline, chatgpt, copilot, kiro
431
- # --import · --browser · --headless
432
- clai set <provider> [key] # --from-env <VAR> | --stdin | --url <url> | --skip-ping
433
- clai unset <provider> [--url] # remove all keys (or endpoint URLs) for a provider
434
- clai keys # list providers with masked keys
435
- clai use <provider> # set active provider
436
- clai provider [provider] # switch provider or open picker
437
- clai model <model> # set model for the active provider
438
- clai mode <ask|agent|plan> # set default mode
439
- clai search-provider <brave|tavily|exa|duckduckgo>
440
- clai config [key] [value] # view or update configuration
441
- clai doctor # check installed tools + provider config
442
- clai history [--show <id>] # list saved sessions
443
- clai update # check for updates and upgrade
444
- clai authorize-pentest AGREE # enable scan/attack tools (one-time ack)
445
- clai scope <show|new|add|clear> # engagement scope management
446
- clai privacy <status|on|off|clear-all> # privacy and history clearing
447
- ```
448
-
449
- ---
450
-
451
- ## Model Context Protocol (MCP)
452
-
453
- `clai` can discover and call tools from local or remote MCP servers. MCP tools are **off by default**; they are activated when a prompt mentions `@mcp:<server>` or via `/mcp all`.
454
-
455
- ### Project configuration
456
-
457
- Define MCP servers in `.clai/mcp.json` (or standard `.vscode/mcp.json` / `.cursor/mcp.json` locations):
252
+ | Search transcript when focused | `Ctrl+R` |
253
+ | Repaint screen | `F5` or `/redraw` |
254
+ | Help / full shortcut reference | `Ctrl+G` / `/shortcuts` |
255
+
256
+ Type `/` for command suggestions and `@` for file mentions. Terminal support affects which modified key combinations are available; `/shortcuts` lists bindings by context.
257
+
258
+ ## Commands
259
+
260
+ Run `clai --help` for CLI flags and `clai <command> --help` for a subcommand. In the interactive console, `/help` lists slash commands.
261
+
262
+ | Slash command | Purpose |
263
+ | --- | --- |
264
+ | `/ask`, `/agent`, `/plan` | Switch working mode. |
265
+ | `/view-plan`, `/implement`, `/discard` | Review, execute, or discard a plan. |
266
+ | `/provider [name]`, `/model [name]`, `/models [filter]` | Select providers and models. |
267
+ | `/set [provider]`, `/unset [provider]`, `/keys`, `/info [provider]` | Configure credentials and inspect provider setup. |
268
+ | `/effort [level]`, `/reasoning [level]` | Set reasoning effort or open its picker. |
269
+ | `/fallback [on\|off]`, `/freeonly [on\|off]` | Configure fallback. |
270
+ | `/orchestrator`, `/subagents` | Manage delegation and inspect subagents. |
271
+ | `/rtk [on\|off\|status\|install\|update]` | Manage shell output compression. |
272
+ | `/skills [name\|list\|refresh]`, `/mcp` | Manage skills and MCP servers. |
273
+ | `/search [provider]`, `/search-provider` | Select the web-search backend. |
274
+ | `/scope [show\|new\|add\|clear]` | Configure this session's engagement scope. |
275
+ | `/jobs`, `/output [last\|id\|list]` | Inspect jobs and tool output. |
276
+ | `/compact`, `/context`, `/usage` | Manage context and inspect usage. |
277
+ | `/history`, `/save <name>`, `/new`, `/prompts` | Browse, name, create, and inspect sessions. |
278
+ | `/clear`, `/reset` | Delete the current session or all saved history. |
279
+ | `/allow <tool>`, `/disallow <tool>`, `/permissions` | Configure tool permissions. |
280
+ | `/cwd <path>` | Change the working directory. |
281
+ | `/think`, `/thinking` | Show the last response's thinking. |
282
+ | `/privacy` | Manage private mode and clear retained data. |
283
+ | `/minimise`, `/minimize`, `/minmize` | Detach this terminal. |
284
+ | `/redraw`, `/refresh` | Repaint the screen. |
285
+ | `/update`, `/help`, `/shortcuts`, `/exit`, `/quit` | Updates, help, and exit. |
286
+
287
+ Useful CLI flags:
288
+
289
+ | Flag | Purpose |
290
+ | --- | --- |
291
+ | `--mode <ask\|agent\|plan>` | Set the mode for this invocation. |
292
+ | `--provider <id>`, `--model <name>` | Override the configured provider or model. |
293
+ | `--resume [id]`, `-c`, `--continue` | Resume an interactive session. |
294
+ | `--classic`, `--tui`, `--ui <classic\|tui>` | Select the interactive interface. |
295
+ | `--no-history` | Disable history persistence for this invocation. |
296
+ | `-y`, `--yes` | Auto-confirm eligible tool actions in a one-shot agent run. |
297
+ | `--quiet`, `--verbose`, `--show-thinking` | Control one-shot answer, tool output, and reasoning display. |
298
+
299
+ ## Project context, skills, and MCP
300
+
301
+ Place project notes in `.clai/context.md` in the working directory to supply architecture, conventions, or testing context. Project skills live under `.clai/skills/` as `SKILL.md` playbooks; `/skills list` shows discovered skills and `/skills refresh` rescans them.
302
+
303
+ MCP servers can expose local or remote tools. Tools are disabled by default; activate a server with an `@mcp:<server>` prompt mention or enable all configured servers with `/mcp all`. `/mcp` also supports configuration, connection status, authentication, and logs.
304
+
305
+ Example `.clai/mcp.json`:
458
306
 
459
307
  ```json
460
308
  {
@@ -462,130 +310,35 @@ Define MCP servers in `.clai/mcp.json` (or standard `.vscode/mcp.json` / `.curso
462
310
  "local": {
463
311
  "command": "my-mcp-server",
464
312
  "args": ["--root", "${workspaceFolder}"],
465
- "env": {
466
- "MCP_TOKEN": "${env:MCP_TOKEN}"
467
- }
313
+ "env": { "MCP_TOKEN": "${env:MCP_TOKEN}" }
468
314
  },
469
315
  "remote": {
470
316
  "url": "https://mcp.example.com/mcp",
471
- "headers": {
472
- "Authorization": "Bearer ${env:MCP_TOKEN}"
473
- }
317
+ "headers": { "Authorization": "Bearer ${env:MCP_TOKEN}" }
474
318
  }
475
319
  }
476
320
  }
477
321
  ```
478
322
 
479
- Use `/mcp` inside the interactive console to browse servers, inspect available tools, view logs, restart connections, or add new servers interactively.
480
-
481
- ---
482
-
483
- ## Built-in tools
484
-
485
- | Group | Tools |
486
- |-------|-------|
487
- | **Files** | `fs.read` · `fs.list` · `fs.search` · `fs.write` · `fs.writeMany` · `fs.edit` · `fs.replaceLines` · `fs.append` · `fs.delete` |
488
- | **Shell & jobs** | `shell.exec` (servers: `background:"always"` + `name`) · `shell.jobs` · `shell.tail` · `shell.wait` · `shell.stop` |
489
- | **Terminals** | `terminal.start` · `terminal.send` · `terminal.read` · `terminal.status` · `terminal.close` |
490
- | **Network** | `tool.check` (with the install command for this OS) · `net.pingSweep` · `wordlist.find` (pentest sessions; plus `nmap`, `ffuf`, etc. via shell) |
491
- | **HTTP / web** | `http.fetch` (raw evidence) · `web.search` · `web.fetch` (readable) |
492
- | **Orchestration** | `subagent.start` · `subagent.list` · `subagent.wait` · `subagent.read` · `subagent.stop` — independent read-only tool calls in one response run in parallel |
493
- | **Plan** | `plan.create` · `plan.clear` · `task.add` · `task.update` · `task.move` · `agent.handoff` |
494
- | **MCP** | `mcp.list` · `mcp.tools` · `mcp.call` · `mcp.enable` · `mcp.connect` · `mcp.login` · `mcp.add` |
495
- | **Context** | `image.ocr` · `image.view` · `pdf.read` · `skill.load` — OS, shell, and cwd arrive with every request |
496
-
497
- ---
498
-
499
- ## Web search / OSINT
500
-
501
- | Provider | Key | Environment Variable |
502
- |----------|-----|----------------------|
503
- | **DuckDuckGo** | None (default) | — |
504
- | **Brave** | Required | `BRAVE_SEARCH_API_KEY` |
505
- | **Tavily** | Required | `TAVILY_API_KEY` |
506
- | **Exa** | Required | `EXA_API_KEY` |
507
-
508
- ```sh
509
- clai set brave bsx-...
510
- clai set tavily tvly-...
511
- clai search-provider tavily
512
- ```
513
-
514
- ---
323
+ ## Configuration and privacy
515
324
 
516
- ## Per-project context
517
-
518
- Drop a `.clai/context.md` in any project root, and its content is injected automatically on every turn — repo architecture, stack conventions, testing instructions, or scope rules. Project-level Agent Skills live alongside it under `.clai/skills/`.
519
-
520
- ---
521
-
522
- ## Interactive REPLs and terminals
523
-
524
- When a task requires multi-step interactive terminal interactions, `clai` maintains a persistent terminal session attached to the conversation:
525
-
526
- ```text
527
- Start a Python REPL, test the regular expression against our test cases, and show me the output.
528
- ```
529
-
530
- The agent runs interactive commands in persistent PTY sessions, reads incremental output, sends follow-up commands, and safely terminates processes upon completion.
531
-
532
- ---
533
-
534
- ## Configuration & privacy
325
+ `clai config` prints the configuration and its location. Use `clai mode`, `clai model`, and `clai use` to change defaults. History, prompt journals, logs, and runtime data normally live under `~/.clai/`; saved chat records include `history.jsonl`. Large outputs may also use per-session temporary directories.
535
326
 
536
327
  ```sh
537
- clai config # view current config
538
- clai mode agent # set default mode
539
- clai model <name> # set default model
540
- /privacy on # private mode: don't persist this session
541
- /privacy clear-all # wipe history, logs, and artifacts
328
+ clai privacy status
329
+ clai privacy on
330
+ clai privacy off
331
+ clai privacy retention 0
542
332
  ```
543
333
 
544
- Config is stored locally in your OS user directory (e.g. `~/.config/clai/`). Keys are stored locally and never exposed in plain text.
334
+ Private mode disables chat and prompt persistence and durable background attachment; `--no-history` applies to a single invocation. Retention defaults to `0` (unlimited saved sessions). These settings do not erase previously saved data. `clai privacy clear-history`, `clear-logs`, `clear-artifacts`, and `clear-all` explicitly delete retained data; the corresponding `/privacy` actions are available in the UI.
545
335
 
546
- ---
547
-
548
- ## Development
549
-
550
- ```sh
551
- npm install
552
- npm run dev # run from source
553
- npm run typecheck
554
- npm run build
555
- npm run test:deterministic
556
- npm run test:host
557
- npm run compile # compile native binaries with Bun
558
- ```
559
-
560
- ---
561
-
562
- ## Architecture
563
-
564
- ```
565
- clai/
566
- ├─ src/
567
- │ ├─ index.ts # CLI entry + subcommands
568
- │ ├─ agent/ # loop, plans, compaction, resume orientation, tool parsing
569
- │ ├─ llm/ # providers, OAuth auth flows, streaming, key rotation + fallback
570
- │ ├─ mcp/ # discovery, validation, transports, lifecycle, and tool dispatch
571
- │ ├─ tools/ # fs, shell, terminal, net, http, web, batch, plan, subagents
572
- │ ├─ skills/ # Agent Skills discovery, catalog, and on-demand loading
573
- │ ├─ safety/ # risk classifier + engagement (scope) policy
574
- │ ├─ store/ # config, history, keys, plans, scope
575
- │ ├─ ui-core/ # renderer-neutral state, actions, layout, rendering, and ports
576
- │ ├─ classic/ # React + Ink classic UI and POSIX terminal bootstrap
577
- │ ├─ tui-v2/ # OpenTUI full-screen renderer
578
- │ ├─ noninteractive/ # stdout/stderr-split one-shot stream renderer
579
- │ ├─ app/ # session controllers, commands, events, and ports
580
- │ └─ prompts/ # agent methodology (embedded for the compiled binary)
581
- ├─ install/ · manifests/
582
- └─ package.json
583
- ```
336
+ Credentials saved with `clai set` or account sign-in are retained in `~/.clai/keys.json`, a **plaintext** file with restricted permissions (`0600` on POSIX). clai also attempts to store them in the OS keyring when available; the local file is retained for recovery. Recognized secrets are masked or redacted in supported displays and storage paths, but review logs and transcripts before sharing them.
584
337
 
585
- ---
338
+ Cloud requests send the model's context and relevant tool results to the selected provider. Provider-specific metadata uploads, including OmniRush's optional lifecycle upload, are described in the [provider guide](PROVIDERS.md#omnirush-lifecycle-uploads).
586
339
 
587
- ## License
340
+ ## Development and support
588
341
 
589
- MIT.
342
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for source setup, architecture boundaries, and the CI checks. Report reproducible bugs through [GitHub Issues](https://github.com/pentoshi007/clai/issues), and use [Discussions](https://github.com/pentoshi007/clai/discussions) for questions. Follow [SECURITY.md](SECURITY.md) for vulnerability reporting and the [Code of Conduct](CODE_OF_CONDUCT.md) when participating.
590
343
 
591
- **Use only on systems you are authorized to test.** clai is an operator's tool: authorization, scope, and impact are yours. The agent executes with the gates and confirmations you configure — nothing more.
344
+ Licensed under the [MIT License](LICENSE).