@qduc/term2 0.5.0 → 0.6.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 (488) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +55 -7
  4. package/dist/agent.js.map +1 -1
  5. package/dist/agent.test.js +135 -10
  6. package/dist/agent.test.js.map +1 -1
  7. package/dist/app.d.ts +15 -0
  8. package/dist/app.d.ts.map +1 -1
  9. package/dist/app.js +86 -16
  10. package/dist/app.js.map +1 -1
  11. package/dist/app.startup-banner.test.js +48 -1
  12. package/dist/app.startup-banner.test.js.map +1 -1
  13. package/dist/cli.js +226 -28
  14. package/dist/cli.js.map +1 -1
  15. package/dist/components/ApprovalPrompt.d.ts.map +1 -1
  16. package/dist/components/ApprovalPrompt.js +11 -35
  17. package/dist/components/ApprovalPrompt.js.map +1 -1
  18. package/dist/components/Banner.d.ts.map +1 -1
  19. package/dist/components/Banner.js +2 -7
  20. package/dist/components/Banner.js.map +1 -1
  21. package/dist/components/BottomArea.d.ts +7 -1
  22. package/dist/components/BottomArea.d.ts.map +1 -1
  23. package/dist/components/BottomArea.js +2 -2
  24. package/dist/components/BottomArea.js.map +1 -1
  25. package/dist/components/CommandMessage.d.ts.map +1 -1
  26. package/dist/components/CommandMessage.js +38 -42
  27. package/dist/components/CommandMessage.js.map +1 -1
  28. package/dist/components/CommandMessage.test.js +69 -0
  29. package/dist/components/CommandMessage.test.js.map +1 -1
  30. package/dist/components/DiffView.d.ts +7 -0
  31. package/dist/components/DiffView.d.ts.map +1 -0
  32. package/dist/components/DiffView.js +80 -0
  33. package/dist/components/DiffView.js.map +1 -0
  34. package/dist/components/DiffView.test.d.ts +2 -0
  35. package/dist/components/DiffView.test.d.ts.map +1 -0
  36. package/dist/components/DiffView.test.js +45 -0
  37. package/dist/components/DiffView.test.js.map +1 -0
  38. package/dist/components/Input/PopupManager.d.ts +7 -0
  39. package/dist/components/Input/PopupManager.d.ts.map +1 -1
  40. package/dist/components/Input/PopupManager.js +4 -2
  41. package/dist/components/Input/PopupManager.js.map +1 -1
  42. package/dist/components/Input/determine-active-menu.d.ts.map +1 -1
  43. package/dist/components/Input/determine-active-menu.js +4 -1
  44. package/dist/components/Input/determine-active-menu.js.map +1 -1
  45. package/dist/components/Input/popup-props.d.ts +3 -1
  46. package/dist/components/Input/popup-props.d.ts.map +1 -1
  47. package/dist/components/Input/popup-props.js +7 -1
  48. package/dist/components/Input/popup-props.js.map +1 -1
  49. package/dist/components/InputBox.d.ts +6 -0
  50. package/dist/components/InputBox.d.ts.map +1 -1
  51. package/dist/components/InputBox.js +74 -11
  52. package/dist/components/InputBox.js.map +1 -1
  53. package/dist/components/InputBox.menu-logic.test.js +16 -1
  54. package/dist/components/InputBox.menu-logic.test.js.map +1 -1
  55. package/dist/components/InputBox.test.js +1 -0
  56. package/dist/components/InputBox.test.js.map +1 -1
  57. package/dist/components/MarkdownRenderer.d.ts.map +1 -1
  58. package/dist/components/MarkdownRenderer.js +52 -1
  59. package/dist/components/MarkdownRenderer.js.map +1 -1
  60. package/dist/components/MessageList.d.ts.map +1 -1
  61. package/dist/components/MessageList.js +3 -2
  62. package/dist/components/MessageList.js.map +1 -1
  63. package/dist/components/MessageList.test.js +16 -0
  64. package/dist/components/MessageList.test.js.map +1 -1
  65. package/dist/components/SettingsValueSelectionMenu.d.ts.map +1 -1
  66. package/dist/components/SettingsValueSelectionMenu.js +4 -1
  67. package/dist/components/SettingsValueSelectionMenu.js.map +1 -1
  68. package/dist/components/StatusBar.d.ts.map +1 -1
  69. package/dist/components/StatusBar.js +5 -3
  70. package/dist/components/StatusBar.js.map +1 -1
  71. package/dist/components/StatusBar.test.js +24 -0
  72. package/dist/components/StatusBar.test.js.map +1 -1
  73. package/dist/components/SubagentActivityMessage.d.ts.map +1 -1
  74. package/dist/components/SubagentActivityMessage.js +16 -1
  75. package/dist/components/SubagentActivityMessage.js.map +1 -1
  76. package/dist/components/UndoSelectionMenu.d.ts +12 -0
  77. package/dist/components/UndoSelectionMenu.d.ts.map +1 -0
  78. package/dist/components/UndoSelectionMenu.js +46 -0
  79. package/dist/components/UndoSelectionMenu.js.map +1 -0
  80. package/dist/components/UndoSelectionMenu.test.d.ts +2 -0
  81. package/dist/components/UndoSelectionMenu.test.d.ts.map +1 -0
  82. package/dist/components/UndoSelectionMenu.test.js +40 -0
  83. package/dist/components/UndoSelectionMenu.test.js.map +1 -0
  84. package/dist/components/theme.d.ts +1 -1
  85. package/dist/components/theme.d.ts.map +1 -1
  86. package/dist/components/theme.js +1 -3
  87. package/dist/components/theme.js.map +1 -1
  88. package/dist/context/InputContext.d.ts +1 -1
  89. package/dist/context/InputContext.d.ts.map +1 -1
  90. package/dist/context/InputContext.js.map +1 -1
  91. package/dist/hooks/use-app-commands.d.ts +14 -2
  92. package/dist/hooks/use-app-commands.d.ts.map +1 -1
  93. package/dist/hooks/use-app-commands.js +115 -32
  94. package/dist/hooks/use-app-commands.js.map +1 -1
  95. package/dist/hooks/use-app-commands.test.js +231 -1
  96. package/dist/hooks/use-app-commands.test.js.map +1 -1
  97. package/dist/hooks/use-conversation.clear.test.d.ts +2 -0
  98. package/dist/hooks/use-conversation.clear.test.d.ts.map +1 -0
  99. package/dist/hooks/use-conversation.clear.test.js +49 -0
  100. package/dist/hooks/use-conversation.clear.test.js.map +1 -0
  101. package/dist/hooks/use-conversation.d.ts +12 -2
  102. package/dist/hooks/use-conversation.d.ts.map +1 -1
  103. package/dist/hooks/use-conversation.js +88 -5
  104. package/dist/hooks/use-conversation.js.map +1 -1
  105. package/dist/hooks/use-conversation.max-turns-undo.test.d.ts +2 -0
  106. package/dist/hooks/use-conversation.max-turns-undo.test.d.ts.map +1 -0
  107. package/dist/hooks/use-conversation.max-turns-undo.test.js +118 -0
  108. package/dist/hooks/use-conversation.max-turns-undo.test.js.map +1 -0
  109. package/dist/hooks/use-conversation.resume.test.d.ts +2 -0
  110. package/dist/hooks/use-conversation.resume.test.d.ts.map +1 -0
  111. package/dist/hooks/use-conversation.resume.test.js +26 -0
  112. package/dist/hooks/use-conversation.resume.test.js.map +1 -0
  113. package/dist/hooks/use-escape-key.d.ts.map +1 -1
  114. package/dist/hooks/use-escape-key.js +14 -7
  115. package/dist/hooks/use-escape-key.js.map +1 -1
  116. package/dist/hooks/use-escape-key.test.js +168 -4
  117. package/dist/hooks/use-escape-key.test.js.map +1 -1
  118. package/dist/hooks/use-input-history.d.ts +4 -3
  119. package/dist/hooks/use-input-history.d.ts.map +1 -1
  120. package/dist/hooks/use-input-history.js +10 -8
  121. package/dist/hooks/use-input-history.js.map +1 -1
  122. package/dist/hooks/use-input-history.test.d.ts +2 -0
  123. package/dist/hooks/use-input-history.test.d.ts.map +1 -0
  124. package/dist/hooks/use-input-history.test.js +43 -0
  125. package/dist/hooks/use-input-history.test.js.map +1 -0
  126. package/dist/hooks/use-mode-handlers.d.ts +10 -2
  127. package/dist/hooks/use-mode-handlers.d.ts.map +1 -1
  128. package/dist/hooks/use-mode-handlers.js +21 -2
  129. package/dist/hooks/use-mode-handlers.js.map +1 -1
  130. package/dist/hooks/use-model-selection.d.ts +3 -0
  131. package/dist/hooks/use-model-selection.d.ts.map +1 -1
  132. package/dist/hooks/use-model-selection.js +3 -0
  133. package/dist/hooks/use-model-selection.js.map +1 -1
  134. package/dist/hooks/use-runtime-settings.d.ts.map +1 -1
  135. package/dist/hooks/use-runtime-settings.js +15 -6
  136. package/dist/hooks/use-runtime-settings.js.map +1 -1
  137. package/dist/hooks/use-settings-completion.d.ts.map +1 -1
  138. package/dist/hooks/use-settings-completion.js +0 -1
  139. package/dist/hooks/use-settings-completion.js.map +1 -1
  140. package/dist/hooks/use-settings-value-completion.d.ts +1 -0
  141. package/dist/hooks/use-settings-value-completion.d.ts.map +1 -1
  142. package/dist/hooks/use-settings-value-completion.js +25 -19
  143. package/dist/hooks/use-settings-value-completion.js.map +1 -1
  144. package/dist/hooks/use-shell-mode.d.ts.map +1 -1
  145. package/dist/hooks/use-shell-mode.js +2 -1
  146. package/dist/hooks/use-shell-mode.js.map +1 -1
  147. package/dist/hooks/use-slash-commands.d.ts +1 -0
  148. package/dist/hooks/use-slash-commands.d.ts.map +1 -1
  149. package/dist/hooks/use-slash-commands.js +10 -1
  150. package/dist/hooks/use-slash-commands.js.map +1 -1
  151. package/dist/hooks/use-undo-selection.d.ts +19 -0
  152. package/dist/hooks/use-undo-selection.d.ts.map +1 -0
  153. package/dist/hooks/use-undo-selection.js +76 -0
  154. package/dist/hooks/use-undo-selection.js.map +1 -0
  155. package/dist/lib/openai-agent-client.chat.test.js +40 -0
  156. package/dist/lib/openai-agent-client.chat.test.js.map +1 -1
  157. package/dist/lib/openai-agent-client.d.ts +10 -1
  158. package/dist/lib/openai-agent-client.d.ts.map +1 -1
  159. package/dist/lib/openai-agent-client.js +114 -6
  160. package/dist/lib/openai-agent-client.js.map +1 -1
  161. package/dist/lib/openai-agent-client.test.js +23 -0
  162. package/dist/lib/openai-agent-client.test.js.map +1 -1
  163. package/dist/lib/retry-executor.js +45 -7
  164. package/dist/lib/retry-executor.js.map +1 -1
  165. package/dist/lib/retry-executor.test.js +63 -0
  166. package/dist/lib/retry-executor.test.js.map +1 -1
  167. package/dist/non-interactive.d.ts +7 -1
  168. package/dist/non-interactive.d.ts.map +1 -1
  169. package/dist/non-interactive.js +73 -5
  170. package/dist/non-interactive.js.map +1 -1
  171. package/dist/non-interactive.test.js +184 -2
  172. package/dist/non-interactive.test.js.map +1 -1
  173. package/dist/prompts/orchestrator.md +46 -0
  174. package/dist/prompts/plan-mode-info.md +17 -0
  175. package/dist/prompts/prompt-selector.d.ts +2 -1
  176. package/dist/prompts/prompt-selector.d.ts.map +1 -1
  177. package/dist/prompts/prompt-selector.js +5 -1
  178. package/dist/prompts/prompt-selector.js.map +1 -1
  179. package/dist/prompts/prompt-selector.test.js +7 -0
  180. package/dist/prompts/prompt-selector.test.js.map +1 -1
  181. package/dist/prompts/prompt-selector.test.ts +18 -0
  182. package/dist/prompts/prompt-selector.ts +7 -1
  183. package/dist/prompts/reasoning-efficiency.d.ts +7 -0
  184. package/dist/prompts/reasoning-efficiency.d.ts.map +1 -0
  185. package/dist/prompts/reasoning-efficiency.js +19 -0
  186. package/dist/prompts/reasoning-efficiency.js.map +1 -0
  187. package/dist/prompts/reasoning-efficiency.ts +18 -0
  188. package/dist/prompts/search-via-shell.test.js +17 -17
  189. package/dist/prompts/search-via-shell.test.js.map +1 -1
  190. package/dist/prompts/search-via-shell.test.ts +17 -17
  191. package/dist/prompts/shell-auto-approval.d.ts +3 -0
  192. package/dist/prompts/shell-auto-approval.d.ts.map +1 -0
  193. package/dist/prompts/shell-auto-approval.js +23 -0
  194. package/dist/prompts/shell-auto-approval.js.map +1 -0
  195. package/dist/prompts/shell-auto-approval.ts +23 -0
  196. package/dist/prompts/subagent-delegation.d.ts +10 -0
  197. package/dist/prompts/subagent-delegation.d.ts.map +1 -0
  198. package/dist/prompts/subagent-delegation.js +33 -0
  199. package/dist/prompts/subagent-delegation.js.map +1 -0
  200. package/dist/prompts/subagent-delegation.test.d.ts +2 -0
  201. package/dist/prompts/subagent-delegation.test.d.ts.map +1 -0
  202. package/dist/prompts/subagent-delegation.test.js +17 -0
  203. package/dist/prompts/subagent-delegation.test.js.map +1 -0
  204. package/dist/prompts/subagent-delegation.test.ts +21 -0
  205. package/dist/prompts/subagent-delegation.ts +40 -0
  206. package/dist/prompts/subagents/explorer.md +1 -2
  207. package/dist/prompts/subagents/mentor.md +0 -1
  208. package/dist/prompts/subagents/researcher.md +0 -1
  209. package/dist/prompts/subagents/worker.md +3 -4
  210. package/dist/providers/ai-sdk-anthropic.provider.d.ts +1 -0
  211. package/dist/providers/ai-sdk-anthropic.provider.d.ts.map +1 -1
  212. package/dist/providers/ai-sdk-anthropic.provider.js +67 -1
  213. package/dist/providers/ai-sdk-anthropic.provider.js.map +1 -1
  214. package/dist/providers/ai-sdk-anthropic.provider.test.d.ts +2 -0
  215. package/dist/providers/ai-sdk-anthropic.provider.test.d.ts.map +1 -0
  216. package/dist/providers/ai-sdk-anthropic.provider.test.js +87 -0
  217. package/dist/providers/ai-sdk-anthropic.provider.test.js.map +1 -0
  218. package/dist/providers/ai-sdk-logging-fetch.d.ts +1 -1
  219. package/dist/providers/ai-sdk-logging-fetch.d.ts.map +1 -1
  220. package/dist/providers/ai-sdk-logging-fetch.js +67 -44
  221. package/dist/providers/ai-sdk-logging-fetch.js.map +1 -1
  222. package/dist/providers/ai-sdk-logging-fetch.test.js +59 -5
  223. package/dist/providers/ai-sdk-logging-fetch.test.js.map +1 -1
  224. package/dist/providers/common/openai-compatible-messages.d.ts.map +1 -1
  225. package/dist/providers/common/openai-compatible-messages.js +10 -4
  226. package/dist/providers/common/openai-compatible-messages.js.map +1 -1
  227. package/dist/providers/common/openai-compatible-messages.test.js +22 -0
  228. package/dist/providers/common/openai-compatible-messages.test.js.map +1 -1
  229. package/dist/providers/custom-provider-adapter.test.js +39 -1
  230. package/dist/providers/custom-provider-adapter.test.js.map +1 -1
  231. package/dist/providers/openai-compatible.provider.d.ts +11 -1
  232. package/dist/providers/openai-compatible.provider.d.ts.map +1 -1
  233. package/dist/providers/openai-compatible.provider.js +122 -8
  234. package/dist/providers/openai-compatible.provider.js.map +1 -1
  235. package/dist/providers/openai-compatible.provider.test.js +61 -0
  236. package/dist/providers/openai-compatible.provider.test.js.map +1 -1
  237. package/dist/providers/openai.provider.js +21 -1
  238. package/dist/providers/openai.provider.js.map +1 -1
  239. package/dist/providers/openrouter.provider.d.ts +2 -0
  240. package/dist/providers/openrouter.provider.d.ts.map +1 -1
  241. package/dist/providers/openrouter.provider.js +20 -2
  242. package/dist/providers/openrouter.provider.js.map +1 -1
  243. package/dist/providers/openrouter.provider.request-preprocessing.test.d.ts +2 -0
  244. package/dist/providers/openrouter.provider.request-preprocessing.test.d.ts.map +1 -0
  245. package/dist/providers/openrouter.provider.request-preprocessing.test.js +48 -0
  246. package/dist/providers/openrouter.provider.request-preprocessing.test.js.map +1 -0
  247. package/dist/providers/registry.test.js +27 -2
  248. package/dist/providers/registry.test.js.map +1 -1
  249. package/dist/scripts/eval-auto-approval/dataset.d.ts +2 -2
  250. package/dist/services/agent-stream.d.ts +1 -0
  251. package/dist/services/agent-stream.d.ts.map +1 -1
  252. package/dist/services/approval-flow-coordinator.d.ts +2 -0
  253. package/dist/services/approval-flow-coordinator.d.ts.map +1 -1
  254. package/dist/services/approval-flow-coordinator.js +45 -18
  255. package/dist/services/approval-flow-coordinator.js.map +1 -1
  256. package/dist/services/approval-flow-coordinator.test.js +87 -0
  257. package/dist/services/approval-flow-coordinator.test.js.map +1 -1
  258. package/dist/services/approval-state.d.ts +4 -0
  259. package/dist/services/approval-state.d.ts.map +1 -1
  260. package/dist/services/approval-state.js +2 -0
  261. package/dist/services/approval-state.js.map +1 -1
  262. package/dist/services/approval-state.test.js +21 -0
  263. package/dist/services/approval-state.test.js.map +1 -1
  264. package/dist/services/conversation-clear-save.test.d.ts +2 -0
  265. package/dist/services/conversation-clear-save.test.d.ts.map +1 -0
  266. package/dist/services/conversation-clear-save.test.js +85 -0
  267. package/dist/services/conversation-clear-save.test.js.map +1 -0
  268. package/dist/services/conversation-history-repair.d.ts +25 -0
  269. package/dist/services/conversation-history-repair.d.ts.map +1 -0
  270. package/dist/services/conversation-history-repair.js +227 -0
  271. package/dist/services/conversation-history-repair.js.map +1 -0
  272. package/dist/services/conversation-history-repair.test.d.ts +2 -0
  273. package/dist/services/conversation-history-repair.test.d.ts.map +1 -0
  274. package/dist/services/conversation-history-repair.test.js +76 -0
  275. package/dist/services/conversation-history-repair.test.js.map +1 -0
  276. package/dist/services/conversation-persistence.d.ts +55 -0
  277. package/dist/services/conversation-persistence.d.ts.map +1 -0
  278. package/dist/services/conversation-persistence.js +216 -0
  279. package/dist/services/conversation-persistence.js.map +1 -0
  280. package/dist/services/conversation-persistence.test.d.ts +2 -0
  281. package/dist/services/conversation-persistence.test.d.ts.map +1 -0
  282. package/dist/services/conversation-persistence.test.js +713 -0
  283. package/dist/services/conversation-persistence.test.js.map +1 -0
  284. package/dist/services/conversation-result-builder.d.ts.map +1 -1
  285. package/dist/services/conversation-result-builder.js +13 -0
  286. package/dist/services/conversation-result-builder.js.map +1 -1
  287. package/dist/services/conversation-retry-policy.d.ts +7 -0
  288. package/dist/services/conversation-retry-policy.d.ts.map +1 -1
  289. package/dist/services/conversation-retry-policy.js +34 -0
  290. package/dist/services/conversation-retry-policy.js.map +1 -1
  291. package/dist/services/conversation-retry-policy.test.js +44 -2
  292. package/dist/services/conversation-retry-policy.test.js.map +1 -1
  293. package/dist/services/conversation-service.d.ts +25 -2
  294. package/dist/services/conversation-service.d.ts.map +1 -1
  295. package/dist/services/conversation-service.js +29 -3
  296. package/dist/services/conversation-service.js.map +1 -1
  297. package/dist/services/conversation-session.auto-approval.test.js +7 -10
  298. package/dist/services/conversation-session.auto-approval.test.js.map +1 -1
  299. package/dist/services/conversation-session.d.ts +28 -1
  300. package/dist/services/conversation-session.d.ts.map +1 -1
  301. package/dist/services/conversation-session.js +300 -95
  302. package/dist/services/conversation-session.js.map +1 -1
  303. package/dist/services/conversation-store.d.ts +42 -0
  304. package/dist/services/conversation-store.d.ts.map +1 -1
  305. package/dist/services/conversation-store.js +188 -6
  306. package/dist/services/conversation-store.js.map +1 -1
  307. package/dist/services/conversation-store.test.js +344 -1
  308. package/dist/services/conversation-store.test.js.map +1 -1
  309. package/dist/services/history-service.d.ts +6 -1
  310. package/dist/services/history-service.d.ts.map +1 -1
  311. package/dist/services/history-service.js +46 -6
  312. package/dist/services/history-service.js.map +1 -1
  313. package/dist/services/history-service.test.d.ts +2 -0
  314. package/dist/services/history-service.test.d.ts.map +1 -0
  315. package/dist/services/history-service.test.js +77 -0
  316. package/dist/services/history-service.test.js.map +1 -0
  317. package/dist/services/input-surge-guard.d.ts +37 -0
  318. package/dist/services/input-surge-guard.d.ts.map +1 -0
  319. package/dist/services/input-surge-guard.js +190 -0
  320. package/dist/services/input-surge-guard.js.map +1 -0
  321. package/dist/services/input-surge-guard.test.d.ts +2 -0
  322. package/dist/services/input-surge-guard.test.d.ts.map +1 -0
  323. package/dist/services/input-surge-guard.test.js +126 -0
  324. package/dist/services/input-surge-guard.test.js.map +1 -0
  325. package/dist/services/logging-contract.d.ts +1 -1
  326. package/dist/services/logging-service.d.ts +4 -0
  327. package/dist/services/logging-service.d.ts.map +1 -1
  328. package/dist/services/logging-service.js +91 -33
  329. package/dist/services/logging-service.js.map +1 -1
  330. package/dist/services/mode-notices.d.ts +11 -0
  331. package/dist/services/mode-notices.d.ts.map +1 -0
  332. package/dist/services/mode-notices.js +16 -0
  333. package/dist/services/mode-notices.js.map +1 -0
  334. package/dist/services/model-service.d.ts.map +1 -1
  335. package/dist/services/model-service.js +0 -1
  336. package/dist/services/model-service.js.map +1 -1
  337. package/dist/services/plan-mode-interceptor.d.ts +10 -0
  338. package/dist/services/plan-mode-interceptor.d.ts.map +1 -0
  339. package/dist/services/plan-mode-interceptor.js +38 -0
  340. package/dist/services/plan-mode-interceptor.js.map +1 -0
  341. package/dist/services/plan-mode-interceptor.test.d.ts +2 -0
  342. package/dist/services/plan-mode-interceptor.test.d.ts.map +1 -0
  343. package/dist/services/plan-mode-interceptor.test.js +55 -0
  344. package/dist/services/plan-mode-interceptor.test.js.map +1 -0
  345. package/dist/services/provider-traffic.d.ts +87 -0
  346. package/dist/services/provider-traffic.d.ts.map +1 -0
  347. package/dist/services/provider-traffic.js +545 -0
  348. package/dist/services/provider-traffic.js.map +1 -0
  349. package/dist/services/provider-traffic.test.d.ts +2 -0
  350. package/dist/services/provider-traffic.test.d.ts.map +1 -0
  351. package/dist/services/provider-traffic.test.js +383 -0
  352. package/dist/services/provider-traffic.test.js.map +1 -0
  353. package/dist/services/service-interfaces.d.ts +20 -1
  354. package/dist/services/service-interfaces.d.ts.map +1 -1
  355. package/dist/services/settings-persistence.js +1 -1
  356. package/dist/services/settings-schema.d.ts +107 -4
  357. package/dist/services/settings-schema.d.ts.map +1 -1
  358. package/dist/services/settings-schema.js +103 -5
  359. package/dist/services/settings-schema.js.map +1 -1
  360. package/dist/services/settings-schema.test.js +35 -1
  361. package/dist/services/settings-schema.test.js.map +1 -1
  362. package/dist/services/settings-service.d.ts +3 -1
  363. package/dist/services/settings-service.d.ts.map +1 -1
  364. package/dist/services/settings-service.js +40 -4
  365. package/dist/services/settings-service.js.map +1 -1
  366. package/dist/services/settings-sources.d.ts.map +1 -1
  367. package/dist/services/settings-sources.js +2 -1
  368. package/dist/services/settings-sources.js.map +1 -1
  369. package/dist/services/settings-sources.test.js +4 -0
  370. package/dist/services/settings-sources.test.js.map +1 -1
  371. package/dist/services/shell-auto-approval-evaluator.d.ts +3 -2
  372. package/dist/services/shell-auto-approval-evaluator.d.ts.map +1 -1
  373. package/dist/services/shell-auto-approval-evaluator.js +287 -101
  374. package/dist/services/shell-auto-approval-evaluator.js.map +1 -1
  375. package/dist/services/shell-auto-approval-evaluator.test.js +216 -18
  376. package/dist/services/shell-auto-approval-evaluator.test.js.map +1 -1
  377. package/dist/services/shell-auto-approval-resolver.test.js +1 -1
  378. package/dist/services/shell-auto-approval-resolver.test.js.map +1 -1
  379. package/dist/services/stream-event-processor.d.ts.map +1 -1
  380. package/dist/services/stream-event-processor.js +5 -0
  381. package/dist/services/stream-event-processor.js.map +1 -1
  382. package/dist/services/stream-event-processor.test.js +27 -0
  383. package/dist/services/stream-event-processor.test.js.map +1 -1
  384. package/dist/services/subagents/reasoning-inheritance.test.d.ts +2 -0
  385. package/dist/services/subagents/reasoning-inheritance.test.d.ts.map +1 -0
  386. package/dist/services/subagents/reasoning-inheritance.test.js +73 -0
  387. package/dist/services/subagents/reasoning-inheritance.test.js.map +1 -0
  388. package/dist/services/subagents/subagent-manager.d.ts +2 -0
  389. package/dist/services/subagents/subagent-manager.d.ts.map +1 -1
  390. package/dist/services/subagents/subagent-manager.js +204 -33
  391. package/dist/services/subagents/subagent-manager.js.map +1 -1
  392. package/dist/services/subagents/subagent-manager.test.js +331 -42
  393. package/dist/services/subagents/subagent-manager.test.js.map +1 -1
  394. package/dist/services/subagents/types.d.ts +6 -0
  395. package/dist/services/subagents/types.d.ts.map +1 -1
  396. package/dist/services/terminal-result-collector.d.ts.map +1 -1
  397. package/dist/services/terminal-result-collector.js +1 -2
  398. package/dist/services/terminal-result-collector.js.map +1 -1
  399. package/dist/slash-commands.d.ts +1 -0
  400. package/dist/slash-commands.d.ts.map +1 -1
  401. package/dist/slash-commands.js +8 -1
  402. package/dist/slash-commands.js.map +1 -1
  403. package/dist/slash-commands.test.d.ts +2 -0
  404. package/dist/slash-commands.test.d.ts.map +1 -0
  405. package/dist/slash-commands.test.js +22 -0
  406. package/dist/slash-commands.test.js.map +1 -0
  407. package/dist/tools/apply-patch.d.ts.map +1 -1
  408. package/dist/tools/apply-patch.js +2 -6
  409. package/dist/tools/apply-patch.js.map +1 -1
  410. package/dist/tools/apply-patch.test.js +2 -13
  411. package/dist/tools/apply-patch.test.js.map +1 -1
  412. package/dist/tools/code-context.test.js +4 -3
  413. package/dist/tools/code-context.test.js.map +1 -1
  414. package/dist/tools/create-file.d.ts.map +1 -1
  415. package/dist/tools/create-file.js +2 -3
  416. package/dist/tools/create-file.js.map +1 -1
  417. package/dist/tools/create-file.test.js +3 -14
  418. package/dist/tools/create-file.test.js.map +1 -1
  419. package/dist/tools/edit-healing.d.ts +3 -3
  420. package/dist/tools/edit-healing.d.ts.map +1 -1
  421. package/dist/tools/edit-healing.js.map +1 -1
  422. package/dist/tools/edit-healing.test.js +0 -1
  423. package/dist/tools/edit-healing.test.js.map +1 -1
  424. package/dist/tools/find-files.test.js +3 -2
  425. package/dist/tools/find-files.test.js.map +1 -1
  426. package/dist/tools/grep.d.ts +1 -0
  427. package/dist/tools/grep.d.ts.map +1 -1
  428. package/dist/tools/grep.js +65 -4
  429. package/dist/tools/grep.js.map +1 -1
  430. package/dist/tools/grep.test.js +39 -0
  431. package/dist/tools/grep.test.js.map +1 -0
  432. package/dist/tools/read-file.d.ts +1 -0
  433. package/dist/tools/read-file.d.ts.map +1 -1
  434. package/dist/tools/read-file.js +7 -5
  435. package/dist/tools/read-file.js.map +1 -1
  436. package/dist/tools/read-file.test.js +3 -2
  437. package/dist/tools/read-file.test.js.map +1 -1
  438. package/dist/tools/run-subagent.d.ts +1 -1
  439. package/dist/tools/run-subagent.d.ts.map +1 -1
  440. package/dist/tools/run-subagent.js +27 -23
  441. package/dist/tools/run-subagent.js.map +1 -1
  442. package/dist/tools/run-subagent.test.js +55 -8
  443. package/dist/tools/run-subagent.test.js.map +1 -1
  444. package/dist/tools/search-replace.d.ts +13 -5
  445. package/dist/tools/search-replace.d.ts.map +1 -1
  446. package/dist/tools/search-replace.js +46 -115
  447. package/dist/tools/search-replace.js.map +1 -1
  448. package/dist/tools/search-replace.test.js +275 -240
  449. package/dist/tools/search-replace.test.js.map +1 -1
  450. package/dist/tools/shell.d.ts +1 -0
  451. package/dist/tools/shell.d.ts.map +1 -1
  452. package/dist/tools/shell.js +14 -6
  453. package/dist/tools/shell.js.map +1 -1
  454. package/dist/tools/shell.test.js +52 -0
  455. package/dist/tools/shell.test.js.map +1 -1
  456. package/dist/tools/tool-parameter-schema.test.js +13 -4
  457. package/dist/tools/tool-parameter-schema.test.js.map +1 -1
  458. package/dist/tools/types.d.ts +1 -1
  459. package/dist/tools/types.d.ts.map +1 -1
  460. package/dist/tools/web-fetch.d.ts.map +1 -1
  461. package/dist/tools/web-fetch.js +29 -4
  462. package/dist/tools/web-fetch.js.map +1 -1
  463. package/dist/tools/web-fetch.test.js +64 -0
  464. package/dist/tools/web-fetch.test.js.map +1 -1
  465. package/dist/utils/command-safety/path-analysis.d.ts.map +1 -1
  466. package/dist/utils/command-safety/path-analysis.js +143 -35
  467. package/dist/utils/command-safety/path-analysis.js.map +1 -1
  468. package/dist/utils/conversation-event-handler.d.ts.map +1 -1
  469. package/dist/utils/conversation-event-handler.js +23 -3
  470. package/dist/utils/conversation-event-handler.js.map +1 -1
  471. package/dist/utils/conversation-event-handler.test.js +94 -0
  472. package/dist/utils/conversation-event-handler.test.js.map +1 -1
  473. package/dist/utils/execute-shell.d.ts +2 -0
  474. package/dist/utils/execute-shell.d.ts.map +1 -1
  475. package/dist/utils/execute-shell.js +25 -1
  476. package/dist/utils/execute-shell.js.map +1 -1
  477. package/dist/utils/execute-shell.test.js +22 -0
  478. package/dist/utils/execute-shell.test.js.map +1 -1
  479. package/dist/utils/model-settings.d.ts.map +1 -1
  480. package/dist/utils/model-settings.js +18 -0
  481. package/dist/utils/model-settings.js.map +1 -1
  482. package/dist/utils/output-trim.d.ts.map +1 -1
  483. package/dist/utils/output-trim.js +14 -6
  484. package/dist/utils/output-trim.js.map +1 -1
  485. package/dist/utils/token-usage.test.js +31 -0
  486. package/dist/utils/token-usage.test.js.map +1 -1
  487. package/package.json +3 -3
  488. package/readme.md +271 -44
package/readme.md CHANGED
@@ -13,12 +13,15 @@ https://github.com/user-attachments/assets/ac960d65-f7c8-453a-9440-91f6397ae842
13
13
 
14
14
  ## Features
15
15
 
16
- - 🎭 **Three Operating Modes** - Default (full-power), Lite (fast & safe), and Mentor (get help from a smarter model on complex problems)
16
+ - 🎭 **Four Operating Modes** - Standard (full-power, auto-approves patches), Lite (fast & safe), Mentor (expert model advice), and Plan (read-only research/implementation drafting)
17
17
  - 🌍 **Open Source** - MIT licensed, hackable, auditable, community-driven
18
18
  - 🤖 **Multi-Provider Support** - Works with OpenAI, OpenRouter, OpenAI-compatible APIs, and Vercel AI SDK providers
19
19
  - 🔒 **Safe Execution** - Every command requires your explicit approval with diff preview
20
- - 🛠️ **Advanced Tools** - Shell execution, file patching, search/replace (with `<...>` gap matching), grep, find files, file reading, file creation, web search, and mentor consultation
21
- - 💬 **Slash Commands** - Quick actions like `/clear`, `/quit`, `/model`, `/mentor`, `/lite`, `/copy`, `/auto-approve` for easy control
20
+ - 🛠️ **Advanced Tools** - Shell execution, file patching, search/replace (with `<...>` gap matching), grep, find files, file reading, file creation, web search, web fetching, code outline & context search, mentor consultation, and subagent invocation
21
+ - 👥 **Subagent Delegation** - Spawn specialized, synchronous subagents (`explorer`, `worker`, `researcher`, `mentor`) to perform sub-tasks in parallel while conserving your main context
22
+ - ⏪ **Conversation Undo & Rewind** - Undo the last turn or select any past user message to rewind the conversation state back to that point
23
+ - 💾 **Conversation Resumption** - Saved conversations are persisted and can be resumed later using the `--resume` flag
24
+ - 💬 **Slash Commands** - Quick actions like `/clear`, `/quit`, `/model`, `/mentor`, `/lite`, `/copy`, `/auto-approve`, `/plan`, `/undo`, `/usage`, and `/effort` for easy control
22
25
  - 📝 **Smart Context** - The assistant understands your environment and provides relevant help
23
26
  - 🎯 **Streaming Responses** - See the AI's thoughts and reasoning in real-time
24
27
  - 🧠 **Reasoning Effort Control** - Configurable reasoning levels (minimal to high) for O1/O3 models
@@ -27,21 +30,22 @@ https://github.com/user-attachments/assets/ac960d65-f7c8-453a-9440-91f6397ae842
27
30
  - 🔄 **Retry Logic** - Automatic recovery from tool hallucinations and upstream errors
28
31
  - 🌐 **SSH Mode** - Execute commands and edit files on remote servers over SSH
29
32
  - 🤖 **Non-Interactive Mode** - Run commands from the CLI without starting the full UI
30
- - ✏️ **Edit Mode** - Press `Shift+Tab` to auto-approve file edits in your workspace for faster development
31
- - 🤖 **Auto-Approval** - Optional LLM-based safety evaluation can automatically approve safe shell commands
33
+ - ✏️ **Standard Mode** - Auto-approves file edits in your workspace for faster development (active by default)
34
+ - 🛡️ **Smart Shell Auto-Approval** - A hybrid local-heuristic + LLM-based safety evaluator that auto-approves safe commands, eliminating prompt fatigue while strictly blocking risky ones (with detailed reasoning explanations)
32
35
  - 🖼️ **Image Pasting** - Paste images from your clipboard directly into the terminal for vision-model analysis
33
36
  - 📈 **Real-time Token Usage** - Live token consumption displayed during streaming
34
37
 
38
+
35
39
  ## Why term2 vs Alternatives?
36
40
 
37
- | | **term2** | Claude Code | Warp |
38
- | ----------------- | :-----------------------------------: | :------------: | :------------------: |
39
- | **Open Source** | ✅ MIT | ❌ Proprietary | Proprietary |
40
- | **Cost** | Pay-per-use | $20-200/mo | Freemium |
41
- | **AI Providers** | Any (OpenAI, OpenRouter, local, etc.) | Anthropic only | selected models only |
42
- | **SSH Remote** | ✅ Native | No | ✅ Yes |
43
- | **Mentor Mode** | ✅ Built-in | ❌ No | ❌ No |
44
- | **Self-Hostable** | | | |
41
+ | | **term2** | **Claude Code** | **Warp** |
42
+ | --- | --- | --- | --- |
43
+ | **Open Source** | ✅ MIT | ❌ Proprietary | ✅ Open Source |
44
+ | **Cost** | Pay-per-use API | $20 - $200/mo (or API) | Freemium / Paid tiers |
45
+ | **AI Providers** | Any (OpenAI, OpenRouter, local) | Anthropic only | Selected models / BYOLLM |
46
+ | **SSH / Remote** | ✅ Native | ✅ Yes (Remote Control/SSH) | ✅ Yes |
47
+ | **Mentor Mode** | ✅ Built-in | ❌ No | ❌ No |
48
+ | **Self-Hostable** | Yes | No (Requires Anthropic) | Cloud elements (Oz) |
45
49
 
46
50
  **term2 gives you:**
47
51
 
@@ -75,7 +79,7 @@ export OPENAI_API_KEY="your-api-key-here"
75
79
  Start the assistant:
76
80
 
77
81
  ```bash
78
- term2 # Start in default mode (full capabilities)
82
+ term2 # Start in standard mode (full capabilities, auto-approves patches)
79
83
  term2 --lite # Start in lite mode (fast, read-only)
80
84
  ```
81
85
 
@@ -83,7 +87,7 @@ Then simply chat with the AI! Type your question or request, press Enter, and th
83
87
 
84
88
  **New to term2?**
85
89
 
86
- - Working on a codebase/project? Use default mode: `term2`
90
+ - Working on a codebase/project? Use standard mode: `term2`
87
91
  - Just need general terminal help? Use lite mode: `term2 --lite`
88
92
  - Tackling a complex problem? Enable mentor mode with `/mentor` command
89
93
 
@@ -119,9 +123,13 @@ term2 --model gpt-5-mini # Use GPT-5 mini for faster/cheaper responses
119
123
  term2 -r high # Set reasoning effort to high (for GPT-5 models)
120
124
  term2 --reasoning medium # Set reasoning effort to medium
121
125
 
122
- # Operating modes (see "Operating Modes" section above for details)
126
+ # Operating modes (see "Operating Modes" section below for details)
123
127
  term2 --lite # Start in lite mode for general terminal work (no codebase)
124
128
 
129
+ # Resuming past conversations
130
+ term2 --resume # Resume the last conversation session
131
+ term2 -R <conversation-uuid> # Resume a specific conversation by ID
132
+
125
133
  # SSH Mode - execute on remote servers
126
134
  term2 --ssh user@host --remote-dir /path/to/project
127
135
  term2 --ssh deploy@server.com --remote-dir /var/www/app --ssh-port 2222
@@ -141,23 +149,49 @@ While in the chat, you can use these commands:
141
149
  - `/clear` - Clear the conversation history
142
150
  - `/quit` - Exit the application
143
151
  - `/model [model-name]` - Switch to a different model
144
- - `/mentor` - Toggle mentor mode (see "Operating Modes" section for details)
145
- - `/lite` - Toggle lite mode (see "Operating Modes" section for details)
146
- - `/copy` - Copy the latest assistant response
152
+ - `/mentor` - Toggle mentor mode
153
+ - `/lite` - Toggle lite mode (requires `/clear` first if a session is active)
154
+ - `/plan` - Toggle plan mode (read-only research/planning mode)
155
+ - `/undo [last]` - Open the conversation rewind menu, or revert the last turn immediately if `last` is specified
156
+ - `/usage` - Show token usage breakdown for the current session (includes subagent usage)
157
+ - `/effort [level]` - Set reasoning effort for O1/O3 models (e.g. none, minimal, low, medium, high)
158
+ - `/copy` - Copy the latest assistant response to the clipboard
147
159
  - `/auto-approve [off|advisory|auto]` - Set or cycle shell auto-approval mode
148
160
  - `/settings [key] [value]` - Modify runtime settings (e.g., `/settings agent.temperature 0.7`)
149
161
 
162
+
150
163
  ## Operating Modes
151
164
 
152
- term2 offers three modes tailored to different workflows. Choose the mode that matches your current task.
165
+ term2 offers multiple operating modes tailored to different workflows.
153
166
 
154
167
  ### Quick Reference
155
168
 
156
- | Mode | Start with | Best for | Tools Available | Context |
157
- | ----------- | -------------- | ------------------------------------ | ----------------- | ------------- |
158
- | **Default** | `term2` | Codebase work & development | All editing tools | Full codebase |
159
- | **Lite** | `term2 --lite` | General terminal tasks (no codebase) | Read-only | None |
160
- | **Mentor** | Use `/mentor` | Complex codebase problems | All + mentor | Full codebase |
169
+ | Mode | Toggle / Start with | Best for | Tools Available | Context |
170
+ | ----------- | ------------------- | ------------------------------------ | -------------------- | ------------- |
171
+ | **Standard**| `term2` | Codebase work & development | Auto-approves patches| Full codebase |
172
+ | **Plan** | `/plan` | Researching and designing plans | Read-only tools | Full codebase |
173
+ | **Lite** | `term2 --lite` | General terminal tasks (no codebase) | Read-only tools | None |
174
+ | **Mentor** | `/mentor` | Complex codebase problems | All + mentor tool | Full codebase |
175
+
176
+ ### Standard Mode - Rapid Development
177
+
178
+ **The problem it solves:** Prompting for approval on every single file modification can slow down fast-paced development.
179
+
180
+ Standard Mode automatically approves `apply_patch` operations within the workspace, allowing the assistant to write and edit code at high speed. Destructive operations (like out-of-workspace writes or terminal shell commands) still require explicit confirmation for safety.
181
+
182
+ - ⚡ **High velocity** - Speeds up iterative coding cycles
183
+ - 🛠️ **Workspace bounded** - Only auto-approves changes inside the active directory
184
+ - 🔄 **Active by default** - Standard mode is the default mode when starting `term2` without flags; use `Shift+Tab` to cycle to Plan mode
185
+
186
+ ### Plan Mode - Read-only Research & Strategy
187
+
188
+ **The problem it solves:** You want the assistant to research a complex issue and propose an implementation plan without modifying the workspace or executing mutating shell commands.
189
+
190
+ Plan Mode enforces a strict **read-only** safety boundary. Any state-changing commands or writing tools are blocked by the system. The assistant focuses entirely on exploring the codebase, running read-only checks, and proposing a step-by-step implementation plan.
191
+
192
+ - 🔒 **Zero-risk exploration** - Securely analyze files and run logs
193
+ - 📝 **Structured plans** - Grounded in current codebase files and symbols
194
+ - 🔄 **Toggleable** - Switch with the `/plan` command or cycle with `Shift+Tab`
161
195
 
162
196
  ### Lite Mode - Everyday Terminal Assistant
163
197
 
@@ -171,7 +205,7 @@ Lite mode is designed for general terminal work: system administration, file man
171
205
  - 🔧 **General terminal tools** - Shell commands, grep, read files, find files (no code editing)
172
206
  - 🌐 **Perfect for SSH** - Ideal for remote server management and investigation
173
207
  - 🔄 **Toggleable** - Switch on/off mid-session with `/lite` command
174
- - 🐚 **Shell mode** - Press Shift+Tab to toggle direct shell command execution
208
+ - 🐚 **Shell mode** - Press `Shift+Tab` to toggle direct shell command execution
175
209
 
176
210
  **When to use Lite mode:**
177
211
 
@@ -216,7 +250,7 @@ Mentor mode gives you two AI minds working together on your codebase. Your prima
216
250
  4. Mentor challenges assumptions and provides strategic guidance
217
251
  5. AI implements the solution based on the guidance
218
252
 
219
- **Important:** The mentor model doesn't have direct access to your codebase. Your primary AI must share all relevant information (code snippets, file paths, findings) when consulting the mentor. This forces clear problem articulation and save cost on the more expensive mentor model.
253
+ **Important:** The mentor model doesn't have direct access to your codebase. Your primary AI must share all relevant information (code snippets, file paths, findings) when consulting the mentor. This forces clear problem articulation and saves cost on the more expensive mentor model.
220
254
 
221
255
  **When to use Mentor mode:**
222
256
 
@@ -257,13 +291,14 @@ AI: [Does additional checks based on mentor's questions]
257
291
 
258
292
  ### Switching Modes
259
293
 
260
- Modes are mutually exclusive—each represents a different working style matched to your task. You can switch modes mid-session:
294
+ Modes represent different working styles matched to your task. You can switch modes mid-session:
261
295
 
262
- - `/lite` - Toggle lite mode (requires clearing history first if session is active)
296
+ - `/lite` - Toggle lite mode (requires clearing history first with `/clear` if session is active)
263
297
  - `/mentor` - Toggle mentor mode
264
- - `Shift+Tab` - Toggle edit mode (auto-approves file edits in workspace)
265
- - Switching to lite mode automatically disables edit/mentor modes
266
- - Enabling lite mode disables edit and mentor modes
298
+ - `/plan` - Toggle plan mode
299
+ - `Shift+Tab` - Cycles through `Default -> Edit -> Plan -> Default` (or toggles Shell Mode in Lite Mode)
300
+ - Switch triggers handle mutual exclusions automatically (e.g. enabling Plan Mode disables Edit/Lite modes)
301
+
267
302
 
268
303
  ## SSH Mode
269
304
 
@@ -357,13 +392,78 @@ ANSWER=$(term2 "is there any TODO in source/cli.tsx?")
357
392
  echo "The answer is: $ANSWER"
358
393
  ```
359
394
 
360
- ### Default Mode vs Lite Mode
395
+ ### Standard Mode vs Lite Mode
361
396
 
362
- - When running **with** `--auto-approve`, term2 defaults to **Default Mode** (full codebase context).
397
+ - When running **with** `--auto-approve`, term2 defaults to **Standard Mode** (full codebase context).
363
398
  - When running **without** `--auto-approve`, term2 defaults to **Lite Mode** (no codebase context, safe/fast).
364
399
 
365
400
  You can always override this by passing `--lite` or running in a directory without a codebase.
366
401
 
402
+ ## Shell Auto-Approval
403
+
404
+ One of the most powerful and unique safety features of `term2` is its **Smart Shell Auto-Approval** system.
405
+
406
+ Instead of forcing you to manually approve every single trivial command (like `git status` or `ls`), or exposing you to the security risks of completely unchecked execution, `term2` uses a **hybrid local-heuristic + LLM-based safety evaluation engine**. This system effectively minimizes "prompt fatigue" while maintaining strong, robust safety boundaries.
407
+
408
+ ### The Problem: Prompt Fatigue vs. Security Risks
409
+ When using terminal-based AI assistants, you are typically forced into one of two extremes:
410
+ 1. **Manual Confirmation of Everything:** The assistant halts and prompts you to approve every single read-only or diagnostic command. This breaks your flow and leads to "prompt fatigue"—where you start blindly approving everything.
411
+ 2. **Full Auto-Run:** The assistant runs commands automatically. While fast, this poses severe security risks if the AI decides to run a destructive command, deletes data, or executes untrusted code.
412
+
413
+ ### The Solution: Hybrid Safety Architecture
414
+ `term2` solves this by introducing a dual-layer safety check before any shell command executes:
415
+
416
+ ```mermaid
417
+ graph TD
418
+ A[Shell Command Execution Request] --> B[Layer 1: Local Heuristic Check]
419
+ B -->|Risky / Red Pattern| C[Reject Auto-Approval]
420
+ B -->|Safe Heuristics| D[Layer 2: LLM Task Context Check]
421
+ D -->|Blocked / Unaligned / Risky| C
422
+ D -->|Approved as Safe| E{Auto-Approval Mode}
423
+ E -->|off| F[Prompt user for confirmation]
424
+ E -->|advisory| G[Show LLM reasoning + prompt user]
425
+ E -->|auto| H[Execute command automatically]
426
+ C --> I[Show safety reasoning + prompt user]
427
+ ```
428
+
429
+ 1. **Layer 1: Local Heuristics (Safety Classification)**
430
+ Before any command is sent to the LLM, a fast local analyzer checks it against known risky pattern sets. Any destructive flags, deletions (`rm`), state resets, database cleaning, network exfiltration patterns, credential access, or process termination are immediately classified as **RED**. If classified as RED, the command is blocked from auto-approval and must be manually confirmed by the user.
431
+
432
+ 2. **Layer 2: LLM Task Context Check**
433
+ If the command passes the local safety heuristics, it is sent to a fast, cost-efficient secondary LLM (default: `gpt-5.4-mini` or similar). The LLM is provided with:
434
+ - The current **task context** (the last few turns of the active conversation).
435
+ - The precise commands to evaluate.
436
+
437
+ The LLM checks if the command is task-aligned, non-destructive, and low-risk. Commands that do not align with what you asked the AI to do are blocked, preventing accidental execution of out-of-context commands.
438
+
439
+ 3. **Layer 3: Explanation & Reasoning**
440
+ For every evaluated command, the auto-approval engine generates a concise reasoning sentence explaining what the command does, whether it aligns with the task, and why it was approved or blocked.
441
+
442
+ ### Auto-Approval Modes
443
+ You can toggle between three auto-approval modes mid-session using the `/auto-approve` command, the `/settings` command, or via runtime settings:
444
+
445
+ * **`off` (Default):** Every command requires manual confirmation. No background LLM safety checks are performed.
446
+ * **`advisory`:** Commands still require manual confirmation, but the UI displays the LLM's safety reasoning alongside the prompt. This is incredibly useful for reviewing complex or unfamiliar shell scripts before you approve them.
447
+ * **`auto`:** Safe, task-aligned, and non-destructive commands are executed automatically without interrupting your flow. High-risk, destructive, or task-unaligned commands are held for manual confirmation and shown with the LLM's explanation.
448
+
449
+ ### Configuration
450
+ You can configure the auto-approval mode and customize which provider/model is used for safety evaluation in your `settings.json`:
451
+
452
+ ```json
453
+ {
454
+ "shell": {
455
+ "autoApproveMode": "auto"
456
+ },
457
+ "agent": {
458
+ "autoApproveProvider": "openai",
459
+ "autoApproveModel": "gpt-5.4-mini"
460
+ }
461
+ }
462
+ ```
463
+
464
+ > [!TIP]
465
+ > Use a fast, lightweight model (like `gpt-5.4-mini` or `haiku`) as your `autoApproveModel` to ensure safety checks complete in milliseconds without adding noticeable latency to your terminal flow.
466
+
367
467
  ## Configuration
368
468
 
369
469
  term2 stores its configuration in:
@@ -411,8 +511,7 @@ You can easily switch between providers by editing `settings.json`.
411
511
  {
412
512
  "agent": {
413
513
  "provider": "openai",
414
- "model": "gpt-5.1",
415
- "temperature": 0.7
514
+ "model": "gpt-5.5"
416
515
  }
417
516
  }
418
517
  ```
@@ -424,7 +523,7 @@ Access a wide range of models.
424
523
  {
425
524
  "agent": {
426
525
  "provider": "openrouter",
427
- "model": "anthropic/claude-4.5-sonnet"
526
+ "model": "anthropic/claude-sonnet-4.6"
428
527
  }
429
528
  }
430
529
  ```
@@ -439,12 +538,13 @@ _Llama.cpp Example:_
439
538
  "providers": [
440
539
  {
441
540
  "name": "llama.cpp",
541
+ "type": "llama.cpp",
442
542
  "baseUrl": "http://127.0.0.1:8080/v1"
443
543
  }
444
544
  ],
445
545
  "agent": {
446
546
  "provider": "llama.cpp",
447
- "model": "qwen3-coder"
547
+ "model": "qwen3.6-35b-a3b"
448
548
  }
449
549
  }
450
550
  ```
@@ -456,6 +556,7 @@ _LM Studio Example:_
456
556
  "providers": [
457
557
  {
458
558
  "name": "lm-studio",
559
+ "type": "openai-compatible",
459
560
  "baseUrl": "http://localhost:1234/v1"
460
561
  }
461
562
  ],
@@ -466,21 +567,123 @@ _LM Studio Example:_
466
567
  }
467
568
  ```
468
569
 
570
+ **4. Other Custom Providers**
571
+ You can also define custom providers for direct API integrations (which use their default base URLs if omitted) or generic OpenAI-compatible endpoints:
572
+
573
+ _Anthropic Direct Example:_
574
+ (Note: Ensure your `ANTHROPIC_API_KEY` is set in your environment.)
575
+
576
+ ```json
577
+ {
578
+ "providers": [
579
+ {
580
+ "name": "anthropic-direct",
581
+ "type": "anthropic"
582
+ }
583
+ ],
584
+ "agent": {
585
+ "provider": "anthropic-direct",
586
+ "model": "claude-sonnet-4-6"
587
+ }
588
+ }
589
+ ```
590
+
591
+ _Google Gemini Direct Example:_
592
+ (Note: Ensure your `GOOGLE_GENERATIVE_AI_API_KEY` is set in your environment.)
593
+
594
+ ```json
595
+ {
596
+ "providers": [
597
+ {
598
+ "name": "google-direct",
599
+ "type": "google"
600
+ }
601
+ ],
602
+ "agent": {
603
+ "provider": "google-direct",
604
+ "model": "gemini-3.5-flash"
605
+ }
606
+ }
607
+ ```
608
+
609
+ _OpenCode Direct Example:_
610
+ (Note: Ensure your `OPENCODE_API_KEY` is set in your environment.)
611
+
612
+ ```json
613
+ {
614
+ "providers": [
615
+ {
616
+ "name": "opencode-direct",
617
+ "type": "opencode"
618
+ }
619
+ ],
620
+ "agent": {
621
+ "provider": "opencode-direct",
622
+ "model": "opencode-model"
623
+ }
624
+ }
625
+ ```
626
+
627
+ _Custom OpenAI Endpoint Example (using the OpenAI Responses API):_
628
+
629
+ ```json
630
+ {
631
+ "providers": [
632
+ {
633
+ "name": "custom-openai",
634
+ "type": "openai",
635
+ "baseUrl": "https://api.custom-openai-proxy.com/v1",
636
+ "apiKey": "your-api-key-here"
637
+ }
638
+ ],
639
+ "agent": {
640
+ "provider": "custom-openai",
641
+ "model": "custom-model-name"
642
+ }
643
+ }
644
+ ```
645
+
469
646
  ### General Settings
470
647
 
648
+ Here is a comprehensive example demonstrating the most useful settings keys you can configure in `settings.json`:
649
+
471
650
  ```json
472
651
  {
652
+ "agent": {
653
+ "model": "gpt-5.4",
654
+ "provider": "openai",
655
+ "reasoningEffort": "default",
656
+ "temperature": 1,
657
+ "mentorModel": "gpt-5.5",
658
+ "mentorProvider": "openai",
659
+ "mentorReasoningEffort": "high",
660
+
661
+ // Subagent model overrides (defaults to agent.model/agent.provider if unset)
662
+ "subagentExplorerModel": "gpt-5.4-mini",
663
+ "subagentWorkerModel": "gpt-5.3-codex",
664
+ "subagentResearcherModel": "gpt-5.4-mini"
665
+ },
473
666
  "shell": {
474
667
  "timeout": 120000,
475
- "maxOutputLines": 1000
668
+ "maxOutputLines": 1000,
669
+ "maxOutputChars": 10000,
670
+ "autoApproveMode": "off",
671
+ "useRtkCompression": false
476
672
  },
477
- "agent": {
478
- "reasoningEffort": "medium",
479
- "mentorModel": "gpt-5.2"
673
+ "webSearch": {
674
+ "provider": "tavily"
675
+ },
676
+ "app": {
677
+ "searchViaShell": false,
678
+ "editMode": false,
679
+ "planMode": false,
680
+ "mentorMode": false,
681
+ "liteMode": false
480
682
  }
481
683
  }
482
684
  ```
483
685
 
686
+
484
687
  ## Supported Models
485
688
 
486
689
  term2 works with multiple AI providers:
@@ -512,6 +715,30 @@ term2 can connect to any OpenAI-compatible API. This allows you to use:
512
715
  - **Self-Hosted**: Connect to private deployments of models.
513
716
  - **Other Providers**: Any service offering an OpenAI-compatible endpoint (e.g., Groq, Together AI).
514
717
 
718
+ ## Subagents
719
+
720
+ For complex, multi-step tasks, the primary assistant can delegate work to specialized, synchronous **Subagents** using the `run_subagent` tool. This allows the main assistant to offload research, file modification, or exploration tasks to a separate agent context, preventing context-window bloat in the main session.
721
+
722
+ Each subagent runs with its own tailored prompt and can perform operations based on its designated role:
723
+
724
+ - **Explorer (`explorer`)**: Specialized in scanning files, mapping structures, and reading codebase outline.
725
+ - **Worker (`worker`)**: Specialized in executing modifications, writing scripts, and running tests.
726
+ - **Researcher (`researcher`)**: Specialized in web search, reading documentation, and gathering information.
727
+ - **Mentor (`mentor`)**: Specialized in providing strategic guidance and high-level architectural feedback.
728
+
729
+ Subagent logs and outputs stream in real-time within the terminal, allowing you to track their progress. You can configure model, provider, and reasoning effort overrides specifically for subagents in settings (e.g. `agent.subagentWorkerModel`).
730
+
731
+ ## Conversation Resumption & Persistence
732
+
733
+ term2 automatically saves your conversation history, settings, and provider state at the end of each session. This allows you to resume any past chat exactly where you left off.
734
+
735
+ - **Auto-save**: Every active chat session is saved on exit or interrupt to your system's log directory:
736
+ - **Linux**: `~/.local/state/term2/log/conversations/`
737
+ - **macOS**: `~/Library/Logs/term2/conversations/`
738
+ - **Resume Last Session**: Run `term2 --resume` to reload the most recent conversation.
739
+ - **Resume Specific Session**: Use `term2 --resume <session-uuid>` to load a specific conversation history.
740
+ - **Listing Sessions**: You can inspect saved sessions and their UUIDs in the log or state files.
741
+
515
742
  ## Safety Features
516
743
 
517
744
  - **Command Approval** - Every destructive operation requires your explicit confirmation
@@ -615,14 +842,14 @@ term2 --ssh user@host --lite
615
842
 
616
843
  ## Tips
617
844
 
618
- - **Choose the right mode** - Use lite mode for general terminal work (not codebase), default mode for codebase work, mentor mode for complex codebase problems (see "Operating Modes" section)
845
+ - **Choose the right mode** - Use lite mode for general terminal work (not codebase), standard mode for codebase work, mentor mode for complex codebase problems (see "Operating Modes" section)
619
846
  - The assistant won't run dangerous commands without your approval
620
847
  - You can reject any command by choosing 'No' when prompted
621
848
  - Press Ctrl+C to exit the chat at any time
622
849
  - Use arrow keys to navigate through your command history
623
850
  - Be specific in your requests for better results
624
851
  - Use `/mentor` to get expert consultation on difficult architectural decisions
625
- - Use `Shift+Tab` to toggle edit mode for faster file editing workflows
852
+ - Use `Shift+Tab` to toggle standard mode for faster file editing workflows
626
853
  - Use `/auto-approve` to enable LLM-based safety evaluation for faster shell command workflows
627
854
  - Paste images directly into the terminal when using vision-capable models
628
855
  - Use `--lite` flag when SSH'ing to servers for general system work without codebase context