@diffra-ai/cli 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/CHANGELOG.md +47 -7
  2. package/dist/bundle/chunks/{anthropic-messages-RDYSW7WM.js → anthropic-messages-HME6WDIM.js} +1 -1
  3. package/dist/bundle/chunks/{azure-openai-responses-HB77OIU4.js → azure-openai-responses-WKSFBZF5.js} +1 -1
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  5. package/dist/bundle/chunks/{chunk-QRII7KJY.js → chunk-3MKQN3ZR.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-VJQ6ZYW4.js → chunk-4NMBWIZG.js} +5 -5
  7. package/dist/bundle/chunks/{chunk-INTHKDF2.js → chunk-65DC2T66.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-762GZFUO.js → chunk-6L2FT6AE.js} +1 -1
  9. package/dist/bundle/chunks/chunk-6ZD23B2R.js +2 -0
  10. package/dist/bundle/chunks/{chunk-ZVEA4XD4.js → chunk-E3MJ4MPN.js} +1 -1
  11. package/dist/bundle/chunks/chunk-GRDBYTYT.js +2003 -0
  12. package/dist/bundle/chunks/{chunk-RJRIMI6M.js → chunk-GRYHVZSI.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-Z72M6UD7.js → chunk-MITPYV3F.js} +1 -1
  14. package/dist/bundle/chunks/{chunk-JJOJ6QJX.js → chunk-MJRIJM22.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-B4DODQSC.js → chunk-PQGGR7SQ.js} +1 -1
  16. package/dist/bundle/chunks/{chunk-Z36XYVPO.js → chunk-PXE534VH.js} +2 -2
  17. package/dist/bundle/chunks/{chunk-OYSUJGUM.js → chunk-QMZGTPRI.js} +1 -1
  18. package/dist/bundle/chunks/{chunk-VSFRR6IC.js → chunk-QQ6NVGNW.js} +1 -1
  19. package/dist/bundle/chunks/{chunk-DWKLYVGO.js → chunk-RUI3NOFB.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-6S2AQWGR.js → chunk-SI7T4LPD.js} +4 -4
  21. package/dist/bundle/chunks/{chunk-V5GJW5IX.js → chunk-SMYD2SB5.js} +1 -1
  22. package/dist/bundle/chunks/{chunk-B3FUE2LF.js → chunk-XAA355T2.js} +1 -1
  23. package/dist/bundle/chunks/{cli-SYWCWCZU.js → cli-GKHAGQO6.js} +1 -1
  24. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-AASXI4DD.js → cloudflare-workers-ai-system-one-PVUECIVD.js} +1 -1
  25. package/dist/bundle/chunks/{easter-egg-3d-QN5RJMZR.js → easter-egg-3d-VAZ2JWDP.js} +1 -1
  26. package/dist/bundle/chunks/{execute-3J63CQJG.js → execute-OEFRHFHI.js} +1 -1
  27. package/dist/bundle/chunks/{google-generative-ai-6HC6JYFU.js → google-generative-ai-2YH7DK5J.js} +1 -1
  28. package/dist/bundle/chunks/{google-vertex-UJFQATKN.js → google-vertex-QNIS4SPE.js} +1 -1
  29. package/dist/bundle/chunks/{llama-cpp-classify-GCDAR6VP.js → llama-cpp-classify-EMBT3ZMY.js} +1 -1
  30. package/dist/bundle/chunks/{mistral-conversations-CF3OZSLK.js → mistral-conversations-RCHJWX2M.js} +1 -1
  31. package/dist/bundle/chunks/{openai-codex-responses-L3IPEYDP.js → openai-codex-responses-LBZQ7HUY.js} +1 -1
  32. package/dist/bundle/chunks/{openai-completions-UXPSYQS7.js → openai-completions-U7NS5GFY.js} +1 -1
  33. package/dist/bundle/chunks/{openai-decisions-DML6VHFQ.js → openai-decisions-YC4ZEGAR.js} +1 -1
  34. package/dist/bundle/chunks/{openai-responses-46Z64FIE.js → openai-responses-4YX6XMEO.js} +1 -1
  35. package/dist/bundle/chunks/{openrouter-images-EI7VO7CT.js → openrouter-images-QPPGKFJY.js} +1 -1
  36. package/dist/bundle/chunks/{pi-messages-4MV3SCQE.js → pi-messages-5W3GZ7B6.js} +1 -1
  37. package/dist/bundle/chunks/{runtime-KEVIZBAR.js → runtime-SI4R3AXJ.js} +1 -1
  38. package/dist/bundle/chunks/{typesafe-system-one-FZU6TH2G.js → typesafe-system-one-GWMQ2NLX.js} +1 -1
  39. package/dist/bundle/chunks/virtual-modules-ENTYMDSQ.js +2 -0
  40. package/dist/bundle/cli-runtime.js +1 -1
  41. package/dist/bundle/index.js +1 -1
  42. package/dist/bundle/rpc-entry.js +1 -1
  43. package/dist/cli/args.d.ts +2 -0
  44. package/dist/cli/args.d.ts.map +1 -1
  45. package/dist/cli/args.js +13 -0
  46. package/dist/cli/args.js.map +1 -1
  47. package/dist/cli/sandbox-command.d.ts +8 -0
  48. package/dist/cli/sandbox-command.d.ts.map +1 -0
  49. package/dist/cli/sandbox-command.js +52 -0
  50. package/dist/cli/sandbox-command.js.map +1 -0
  51. package/dist/config.d.ts +7 -0
  52. package/dist/config.d.ts.map +1 -1
  53. package/dist/config.js +14 -0
  54. package/dist/config.js.map +1 -1
  55. package/dist/core/agent-session.d.ts +20 -0
  56. package/dist/core/agent-session.d.ts.map +1 -1
  57. package/dist/core/agent-session.js +72 -2
  58. package/dist/core/agent-session.js.map +1 -1
  59. package/dist/core/approval-mode.d.ts +28 -0
  60. package/dist/core/approval-mode.d.ts.map +1 -0
  61. package/dist/core/approval-mode.js +34 -0
  62. package/dist/core/approval-mode.js.map +1 -0
  63. package/dist/core/extensions/loader.d.ts.map +1 -1
  64. package/dist/core/extensions/loader.js +15 -0
  65. package/dist/core/extensions/loader.js.map +1 -1
  66. package/dist/core/extensions/runner.d.ts.map +1 -1
  67. package/dist/core/extensions/runner.js +3 -0
  68. package/dist/core/extensions/runner.js.map +1 -1
  69. package/dist/core/extensions/types.d.ts +28 -1
  70. package/dist/core/extensions/types.d.ts.map +1 -1
  71. package/dist/core/extensions/types.js.map +1 -1
  72. package/dist/core/fast-model.d.ts +10 -0
  73. package/dist/core/fast-model.d.ts.map +1 -0
  74. package/dist/core/fast-model.js +13 -0
  75. package/dist/core/fast-model.js.map +1 -0
  76. package/dist/core/keybindings.d.ts +8 -0
  77. package/dist/core/keybindings.d.ts.map +1 -1
  78. package/dist/core/keybindings.js +4 -0
  79. package/dist/core/keybindings.js.map +1 -1
  80. package/dist/core/sandbox/escalation.d.ts +32 -0
  81. package/dist/core/sandbox/escalation.d.ts.map +1 -0
  82. package/dist/core/sandbox/escalation.js +70 -0
  83. package/dist/core/sandbox/escalation.js.map +1 -0
  84. package/dist/core/sandbox/launch.d.ts +14 -0
  85. package/dist/core/sandbox/launch.d.ts.map +1 -0
  86. package/dist/core/sandbox/launch.js +18 -0
  87. package/dist/core/sandbox/launch.js.map +1 -0
  88. package/dist/core/sandbox/policy.d.ts +50 -0
  89. package/dist/core/sandbox/policy.d.ts.map +1 -0
  90. package/dist/core/sandbox/policy.js +96 -0
  91. package/dist/core/sandbox/policy.js.map +1 -0
  92. package/dist/core/sandbox/seatbelt.d.ts +17 -0
  93. package/dist/core/sandbox/seatbelt.d.ts.map +1 -0
  94. package/dist/core/sandbox/seatbelt.js +169 -0
  95. package/dist/core/sandbox/seatbelt.js.map +1 -0
  96. package/dist/core/sandbox/windows.d.ts +30 -0
  97. package/dist/core/sandbox/windows.d.ts.map +1 -0
  98. package/dist/core/sandbox/windows.js +104 -0
  99. package/dist/core/sandbox/windows.js.map +1 -0
  100. package/dist/core/settings-defaults.d.ts +28 -0
  101. package/dist/core/settings-defaults.d.ts.map +1 -1
  102. package/dist/core/settings-defaults.js +28 -0
  103. package/dist/core/settings-defaults.js.map +1 -1
  104. package/dist/core/settings-manager.d.ts +9 -1
  105. package/dist/core/settings-manager.d.ts.map +1 -1
  106. package/dist/core/settings-manager.js +58 -1
  107. package/dist/core/settings-manager.js.map +1 -1
  108. package/dist/core/settings-schema.d.ts +124 -0
  109. package/dist/core/settings-schema.d.ts.map +1 -1
  110. package/dist/core/settings-schema.js +177 -0
  111. package/dist/core/settings-schema.js.map +1 -1
  112. package/dist/core/tools/bash.d.ts +12 -2
  113. package/dist/core/tools/bash.d.ts.map +1 -1
  114. package/dist/core/tools/bash.js +27 -7
  115. package/dist/core/tools/bash.js.map +1 -1
  116. package/dist/core/tools/edit.d.ts +3 -0
  117. package/dist/core/tools/edit.d.ts.map +1 -1
  118. package/dist/core/tools/edit.js +2 -0
  119. package/dist/core/tools/edit.js.map +1 -1
  120. package/dist/core/tools/powershell.d.ts +3 -2
  121. package/dist/core/tools/powershell.d.ts.map +1 -1
  122. package/dist/core/tools/powershell.js +4 -6
  123. package/dist/core/tools/powershell.js.map +1 -1
  124. package/dist/core/tools/render-utils.d.ts +2 -2
  125. package/dist/core/tools/render-utils.js +5 -5
  126. package/dist/core/tools/render-utils.js.map +1 -1
  127. package/dist/core/tools/renderers/edit.d.ts.map +1 -1
  128. package/dist/core/tools/renderers/edit.js +16 -19
  129. package/dist/core/tools/renderers/edit.js.map +1 -1
  130. package/dist/core/tools/write.d.ts +3 -0
  131. package/dist/core/tools/write.d.ts.map +1 -1
  132. package/dist/core/tools/write.js +2 -0
  133. package/dist/core/tools/write.js.map +1 -1
  134. package/dist/extensions/agents/agent-tool.d.ts +61 -0
  135. package/dist/extensions/agents/agent-tool.d.ts.map +1 -0
  136. package/dist/extensions/agents/agent-tool.js +277 -0
  137. package/dist/extensions/agents/agent-tool.js.map +1 -0
  138. package/dist/extensions/agents/background.d.ts +56 -0
  139. package/dist/extensions/agents/background.d.ts.map +1 -0
  140. package/dist/extensions/agents/background.js +142 -0
  141. package/dist/extensions/agents/background.js.map +1 -0
  142. package/dist/extensions/agents/builtin-agents.d.ts +8 -0
  143. package/dist/extensions/agents/builtin-agents.d.ts.map +1 -0
  144. package/dist/extensions/agents/builtin-agents.js +38 -0
  145. package/dist/extensions/agents/builtin-agents.js.map +1 -0
  146. package/dist/extensions/agents/call-scopes.d.ts +34 -0
  147. package/dist/extensions/agents/call-scopes.d.ts.map +1 -0
  148. package/dist/extensions/agents/call-scopes.js +36 -0
  149. package/dist/extensions/agents/call-scopes.js.map +1 -0
  150. package/dist/extensions/agents/definitions.d.ts +64 -0
  151. package/dist/extensions/agents/definitions.d.ts.map +1 -0
  152. package/dist/extensions/agents/definitions.js +216 -0
  153. package/dist/extensions/agents/definitions.js.map +1 -0
  154. package/dist/extensions/agents/index.d.ts +15 -0
  155. package/dist/extensions/agents/index.d.ts.map +1 -0
  156. package/dist/extensions/agents/index.js +327 -0
  157. package/dist/extensions/agents/index.js.map +1 -0
  158. package/dist/extensions/agents/runner.d.ts +63 -0
  159. package/dist/extensions/agents/runner.d.ts.map +1 -0
  160. package/dist/extensions/agents/runner.js +156 -0
  161. package/dist/extensions/agents/runner.js.map +1 -0
  162. package/dist/extensions/approval/auto-classifier.d.ts +32 -0
  163. package/dist/extensions/approval/auto-classifier.d.ts.map +1 -0
  164. package/dist/extensions/approval/auto-classifier.js +116 -0
  165. package/dist/extensions/approval/auto-classifier.js.map +1 -0
  166. package/dist/extensions/approval/exit-plan-mode.d.ts +24 -0
  167. package/dist/extensions/approval/exit-plan-mode.d.ts.map +1 -0
  168. package/dist/extensions/approval/exit-plan-mode.js +99 -0
  169. package/dist/extensions/approval/exit-plan-mode.js.map +1 -0
  170. package/dist/extensions/approval/index.d.ts +15 -0
  171. package/dist/extensions/approval/index.d.ts.map +1 -0
  172. package/dist/extensions/approval/index.js +329 -0
  173. package/dist/extensions/approval/index.js.map +1 -0
  174. package/dist/extensions/approval/plan-reminders.d.ts +9 -0
  175. package/dist/extensions/approval/plan-reminders.d.ts.map +1 -0
  176. package/dist/extensions/approval/plan-reminders.js +42 -0
  177. package/dist/extensions/approval/plan-reminders.js.map +1 -0
  178. package/dist/extensions/approval/policy.d.ts +52 -0
  179. package/dist/extensions/approval/policy.d.ts.map +1 -0
  180. package/dist/extensions/approval/policy.js +124 -0
  181. package/dist/extensions/approval/policy.js.map +1 -0
  182. package/dist/extensions/approval/shell-safety.d.ts +11 -0
  183. package/dist/extensions/approval/shell-safety.d.ts.map +1 -0
  184. package/dist/extensions/approval/shell-safety.js +264 -0
  185. package/dist/extensions/approval/shell-safety.js.map +1 -0
  186. package/dist/extensions/cron/cron-expression.d.ts +30 -0
  187. package/dist/extensions/cron/cron-expression.d.ts.map +1 -0
  188. package/dist/extensions/cron/cron-expression.js +119 -0
  189. package/dist/extensions/cron/cron-expression.js.map +1 -0
  190. package/dist/extensions/cron/index.d.ts +19 -0
  191. package/dist/extensions/cron/index.d.ts.map +1 -0
  192. package/dist/extensions/cron/index.js +215 -0
  193. package/dist/extensions/cron/index.js.map +1 -0
  194. package/dist/extensions/cron/loop-args.d.ts +35 -0
  195. package/dist/extensions/cron/loop-args.d.ts.map +1 -0
  196. package/dist/extensions/cron/loop-args.js +95 -0
  197. package/dist/extensions/cron/loop-args.js.map +1 -0
  198. package/dist/extensions/cron/loop-texts.d.ts +29 -0
  199. package/dist/extensions/cron/loop-texts.d.ts.map +1 -0
  200. package/dist/extensions/cron/loop-texts.js +83 -0
  201. package/dist/extensions/cron/loop-texts.js.map +1 -0
  202. package/dist/extensions/cron/scheduler.d.ts +79 -0
  203. package/dist/extensions/cron/scheduler.d.ts.map +1 -0
  204. package/dist/extensions/cron/scheduler.js +146 -0
  205. package/dist/extensions/cron/scheduler.js.map +1 -0
  206. package/dist/extensions/cron/tools.d.ts +47 -0
  207. package/dist/extensions/cron/tools.d.ts.map +1 -0
  208. package/dist/extensions/cron/tools.js +141 -0
  209. package/dist/extensions/cron/tools.js.map +1 -0
  210. package/dist/extensions/goals/evidence.d.ts +20 -0
  211. package/dist/extensions/goals/evidence.d.ts.map +1 -0
  212. package/dist/extensions/goals/evidence.js +77 -0
  213. package/dist/extensions/goals/evidence.js.map +1 -0
  214. package/dist/extensions/goals/index.d.ts +45 -0
  215. package/dist/extensions/goals/index.d.ts.map +1 -0
  216. package/dist/extensions/goals/index.js +438 -0
  217. package/dist/extensions/goals/index.js.map +1 -0
  218. package/dist/extensions/goals/prompts.d.ts +15 -0
  219. package/dist/extensions/goals/prompts.d.ts.map +1 -0
  220. package/dist/extensions/goals/prompts.js +51 -0
  221. package/dist/extensions/goals/prompts.js.map +1 -0
  222. package/dist/extensions/goals/state.d.ts +88 -0
  223. package/dist/extensions/goals/state.d.ts.map +1 -0
  224. package/dist/extensions/goals/state.js +204 -0
  225. package/dist/extensions/goals/state.js.map +1 -0
  226. package/dist/extensions/goals/tools.d.ts +40 -0
  227. package/dist/extensions/goals/tools.d.ts.map +1 -0
  228. package/dist/extensions/goals/tools.js +118 -0
  229. package/dist/extensions/goals/tools.js.map +1 -0
  230. package/dist/extensions/goals/verifier.d.ts +30 -0
  231. package/dist/extensions/goals/verifier.d.ts.map +1 -0
  232. package/dist/extensions/goals/verifier.js +89 -0
  233. package/dist/extensions/goals/verifier.js.map +1 -0
  234. package/dist/extensions/hooks/aggregate.d.ts +30 -0
  235. package/dist/extensions/hooks/aggregate.d.ts.map +1 -0
  236. package/dist/extensions/hooks/aggregate.js +103 -0
  237. package/dist/extensions/hooks/aggregate.js.map +1 -0
  238. package/dist/extensions/hooks/config.d.ts +47 -0
  239. package/dist/extensions/hooks/config.d.ts.map +1 -0
  240. package/dist/extensions/hooks/config.js +169 -0
  241. package/dist/extensions/hooks/config.js.map +1 -0
  242. package/dist/extensions/hooks/file-watcher.d.ts +31 -0
  243. package/dist/extensions/hooks/file-watcher.d.ts.map +1 -0
  244. package/dist/extensions/hooks/file-watcher.js +106 -0
  245. package/dist/extensions/hooks/file-watcher.js.map +1 -0
  246. package/dist/extensions/hooks/index.d.ts +17 -0
  247. package/dist/extensions/hooks/index.d.ts.map +1 -0
  248. package/dist/extensions/hooks/index.js +349 -0
  249. package/dist/extensions/hooks/index.js.map +1 -0
  250. package/dist/extensions/hooks/matcher.d.ts +10 -0
  251. package/dist/extensions/hooks/matcher.d.ts.map +1 -0
  252. package/dist/extensions/hooks/matcher.js +85 -0
  253. package/dist/extensions/hooks/matcher.js.map +1 -0
  254. package/dist/extensions/hooks/runner.d.ts +54 -0
  255. package/dist/extensions/hooks/runner.d.ts.map +1 -0
  256. package/dist/extensions/hooks/runner.js +197 -0
  257. package/dist/extensions/hooks/runner.js.map +1 -0
  258. package/dist/extensions/index.d.ts.map +1 -1
  259. package/dist/extensions/index.js +29 -2
  260. package/dist/extensions/index.js.map +1 -1
  261. package/dist/extensions/lsp/config.d.ts +40 -0
  262. package/dist/extensions/lsp/config.d.ts.map +1 -0
  263. package/dist/extensions/lsp/config.js +92 -0
  264. package/dist/extensions/lsp/config.js.map +1 -0
  265. package/dist/extensions/lsp/connection.d.ts +32 -0
  266. package/dist/extensions/lsp/connection.d.ts.map +1 -0
  267. package/dist/extensions/lsp/connection.js +124 -0
  268. package/dist/extensions/lsp/connection.js.map +1 -0
  269. package/dist/extensions/lsp/index.d.ts +15 -0
  270. package/dist/extensions/lsp/index.d.ts.map +1 -0
  271. package/dist/extensions/lsp/index.js +103 -0
  272. package/dist/extensions/lsp/index.js.map +1 -0
  273. package/dist/extensions/lsp/server.d.ts +68 -0
  274. package/dist/extensions/lsp/server.d.ts.map +1 -0
  275. package/dist/extensions/lsp/server.js +373 -0
  276. package/dist/extensions/lsp/server.js.map +1 -0
  277. package/dist/extensions/lsp/tool.d.ts +43 -0
  278. package/dist/extensions/lsp/tool.d.ts.map +1 -0
  279. package/dist/extensions/lsp/tool.js +534 -0
  280. package/dist/extensions/lsp/tool.js.map +1 -0
  281. package/dist/extensions/memory/index.d.ts +15 -0
  282. package/dist/extensions/memory/index.d.ts.map +1 -0
  283. package/dist/extensions/memory/index.js +336 -0
  284. package/dist/extensions/memory/index.js.map +1 -0
  285. package/dist/extensions/memory/memory-agent.d.ts +29 -0
  286. package/dist/extensions/memory/memory-agent.d.ts.map +1 -0
  287. package/dist/extensions/memory/memory-agent.js +102 -0
  288. package/dist/extensions/memory/memory-agent.js.map +1 -0
  289. package/dist/extensions/memory/prompts.d.ts +18 -0
  290. package/dist/extensions/memory/prompts.d.ts.map +1 -0
  291. package/dist/extensions/memory/prompts.js +124 -0
  292. package/dist/extensions/memory/prompts.js.map +1 -0
  293. package/dist/extensions/memory/recall.d.ts +14 -0
  294. package/dist/extensions/memory/recall.d.ts.map +1 -0
  295. package/dist/extensions/memory/recall.js +80 -0
  296. package/dist/extensions/memory/recall.js.map +1 -0
  297. package/dist/extensions/memory/store.d.ts +48 -0
  298. package/dist/extensions/memory/store.d.ts.map +1 -0
  299. package/dist/extensions/memory/store.js +132 -0
  300. package/dist/extensions/memory/store.js.map +1 -0
  301. package/dist/extensions/skills/bundled/batch/SKILL.md +74 -0
  302. package/dist/extensions/skills/bundled/review/SKILL.md +93 -0
  303. package/dist/extensions/skills/index.d.ts +15 -0
  304. package/dist/extensions/skills/index.d.ts.map +1 -0
  305. package/dist/extensions/skills/index.js +68 -0
  306. package/dist/extensions/skills/index.js.map +1 -0
  307. package/dist/extensions/skills/learn.d.ts +9 -0
  308. package/dist/extensions/skills/learn.d.ts.map +1 -0
  309. package/dist/extensions/skills/learn.js +46 -0
  310. package/dist/extensions/skills/learn.js.map +1 -0
  311. package/dist/extensions/todo/index.d.ts +14 -0
  312. package/dist/extensions/todo/index.d.ts.map +1 -0
  313. package/dist/extensions/todo/index.js +55 -0
  314. package/dist/extensions/todo/index.js.map +1 -0
  315. package/dist/extensions/todo/todos.d.ts +64 -0
  316. package/dist/extensions/todo/todos.d.ts.map +1 -0
  317. package/dist/extensions/todo/todos.js +145 -0
  318. package/dist/extensions/todo/todos.js.map +1 -0
  319. package/dist/extensions/todo/tool.d.ts +23 -0
  320. package/dist/extensions/todo/tool.d.ts.map +1 -0
  321. package/dist/extensions/todo/tool.js +104 -0
  322. package/dist/extensions/todo/tool.js.map +1 -0
  323. package/dist/extensions/web-fetch/fetch-tool.d.ts +27 -0
  324. package/dist/extensions/web-fetch/fetch-tool.d.ts.map +1 -0
  325. package/dist/extensions/web-fetch/fetch-tool.js +319 -0
  326. package/dist/extensions/web-fetch/fetch-tool.js.map +1 -0
  327. package/dist/extensions/web-fetch/html-to-markdown.d.ts +7 -0
  328. package/dist/extensions/web-fetch/html-to-markdown.d.ts.map +1 -0
  329. package/dist/extensions/web-fetch/html-to-markdown.js +21 -0
  330. package/dist/extensions/web-fetch/html-to-markdown.js.map +1 -0
  331. package/dist/extensions/web-fetch/index.d.ts +10 -0
  332. package/dist/extensions/web-fetch/index.d.ts.map +1 -0
  333. package/dist/extensions/web-fetch/index.js +13 -0
  334. package/dist/extensions/web-fetch/index.js.map +1 -0
  335. package/dist/extensions/web-fetch/page-fetch.d.ts +45 -0
  336. package/dist/extensions/web-fetch/page-fetch.d.ts.map +1 -0
  337. package/dist/extensions/web-fetch/page-fetch.js +117 -0
  338. package/dist/extensions/web-fetch/page-fetch.js.map +1 -0
  339. package/dist/extensions/web-fetch/pdf-text.d.ts +29 -0
  340. package/dist/extensions/web-fetch/pdf-text.d.ts.map +1 -0
  341. package/dist/extensions/web-fetch/pdf-text.js +71 -0
  342. package/dist/extensions/web-fetch/pdf-text.js.map +1 -0
  343. package/dist/extensions/web-fetch/preapproved-hosts.d.ts +7 -0
  344. package/dist/extensions/web-fetch/preapproved-hosts.d.ts.map +1 -0
  345. package/dist/extensions/web-fetch/preapproved-hosts.js +110 -0
  346. package/dist/extensions/web-fetch/preapproved-hosts.js.map +1 -0
  347. package/dist/extensions/web-search/dashscope-search.d.ts +29 -0
  348. package/dist/extensions/web-search/dashscope-search.d.ts.map +1 -0
  349. package/dist/extensions/web-search/dashscope-search.js +279 -0
  350. package/dist/extensions/web-search/dashscope-search.js.map +1 -0
  351. package/dist/extensions/web-search/index.d.ts +15 -0
  352. package/dist/extensions/web-search/index.d.ts.map +1 -0
  353. package/dist/extensions/web-search/index.js +51 -0
  354. package/dist/extensions/web-search/index.js.map +1 -0
  355. package/dist/extensions/web-search/search-config.d.ts +53 -0
  356. package/dist/extensions/web-search/search-config.d.ts.map +1 -0
  357. package/dist/extensions/web-search/search-config.js +174 -0
  358. package/dist/extensions/web-search/search-config.js.map +1 -0
  359. package/dist/extensions/web-search/search-tool.d.ts +29 -0
  360. package/dist/extensions/web-search/search-tool.d.ts.map +1 -0
  361. package/dist/extensions/web-search/search-tool.js +149 -0
  362. package/dist/extensions/web-search/search-tool.js.map +1 -0
  363. package/dist/extensions/worktree/git-worktree.d.ts +69 -0
  364. package/dist/extensions/worktree/git-worktree.d.ts.map +1 -0
  365. package/dist/extensions/worktree/git-worktree.js +199 -0
  366. package/dist/extensions/worktree/git-worktree.js.map +1 -0
  367. package/dist/extensions/worktree/index.d.ts +27 -0
  368. package/dist/extensions/worktree/index.d.ts.map +1 -0
  369. package/dist/extensions/worktree/index.js +188 -0
  370. package/dist/extensions/worktree/index.js.map +1 -0
  371. package/dist/extensions/worktree/startup.d.ts +17 -0
  372. package/dist/extensions/worktree/startup.d.ts.map +1 -0
  373. package/dist/extensions/worktree/startup.js +56 -0
  374. package/dist/extensions/worktree/startup.js.map +1 -0
  375. package/dist/main.d.ts.map +1 -1
  376. package/dist/main.js +28 -4
  377. package/dist/main.js.map +1 -1
  378. package/dist/modes/interactive/components/custom-editor.d.ts +18 -0
  379. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  380. package/dist/modes/interactive/components/custom-editor.js +87 -20
  381. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  382. package/dist/modes/interactive/components/diffra-logo.d.ts +6 -0
  383. package/dist/modes/interactive/components/diffra-logo.d.ts.map +1 -1
  384. package/dist/modes/interactive/components/diffra-logo.js +30 -4
  385. package/dist/modes/interactive/components/diffra-logo.js.map +1 -1
  386. package/dist/modes/interactive/components/dynamic-border.d.ts +1 -1
  387. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  388. package/dist/modes/interactive/components/dynamic-border.js +3 -3
  389. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  390. package/dist/modes/interactive/components/footer.d.ts +16 -0
  391. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  392. package/dist/modes/interactive/components/footer.js +84 -46
  393. package/dist/modes/interactive/components/footer.js.map +1 -1
  394. package/dist/modes/interactive/components/tool-execution.d.ts +5 -2
  395. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  396. package/dist/modes/interactive/components/tool-execution.js +152 -62
  397. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  398. package/dist/modes/interactive/components/tool-status.d.ts +5 -0
  399. package/dist/modes/interactive/components/tool-status.d.ts.map +1 -0
  400. package/dist/modes/interactive/components/tool-status.js +15 -0
  401. package/dist/modes/interactive/components/tool-status.js.map +1 -0
  402. package/dist/modes/interactive/components/user-message.d.ts +4 -8
  403. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  404. package/dist/modes/interactive/components/user-message.js +38 -36
  405. package/dist/modes/interactive/components/user-message.js.map +1 -1
  406. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  407. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  408. package/dist/modes/interactive/interactive-mode.js +24 -8
  409. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  410. package/dist/modes/interactive/theme/dark.json +3 -2
  411. package/dist/modes/interactive/theme/light.json +3 -2
  412. package/dist/modes/interactive/theme/system-theme.d.ts +1 -0
  413. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
  414. package/dist/modes/interactive/theme/system-theme.js +41 -14
  415. package/dist/modes/interactive/theme/system-theme.js.map +1 -1
  416. package/dist/utils/shell.d.ts +1 -1
  417. package/dist/utils/shell.d.ts.map +1 -1
  418. package/dist/utils/shell.js +12 -2
  419. package/dist/utils/shell.js.map +1 -1
  420. package/dist/utils/tools-manager.d.ts +5 -1
  421. package/dist/utils/tools-manager.d.ts.map +1 -1
  422. package/dist/utils/tools-manager.js +81 -47
  423. package/dist/utils/tools-manager.js.map +1 -1
  424. package/docs/approval-modes.md +99 -0
  425. package/docs/builtin-skills.md +53 -0
  426. package/docs/cli.md +380 -356
  427. package/docs/docs.json +264 -220
  428. package/docs/environment-variables.md +110 -103
  429. package/docs/extensions.md +24 -0
  430. package/docs/goals.md +84 -0
  431. package/docs/hooks.md +112 -0
  432. package/docs/keybindings.md +1 -0
  433. package/docs/lsp.md +71 -0
  434. package/docs/memory.md +71 -0
  435. package/docs/sandbox.md +108 -0
  436. package/docs/scheduled-tasks.md +84 -0
  437. package/docs/security.md +100 -99
  438. package/docs/settings.md +198 -173
  439. package/docs/shell-aliases.md +1 -1
  440. package/docs/skills.md +4 -0
  441. package/docs/slash-commands.md +15 -0
  442. package/docs/subagents.md +102 -0
  443. package/docs/web-tools.md +83 -0
  444. package/docs/windows.md +2 -1
  445. package/docs/worktrees.md +52 -0
  446. package/examples/extensions/README.md +1 -1
  447. package/examples/extensions/plan-mode/README.md +2 -2
  448. package/examples/extensions/plan-mode/index.ts +7 -4
  449. package/examples/extensions/subagent/README.md +2 -0
  450. package/examples/extensions/subagent/index.ts +3 -0
  451. package/examples/extensions/todo.ts +4 -0
  452. package/package.json +9 -8
  453. package/schemas/keybindings.schema.json +4 -0
  454. package/schemas/settings.schema.json +421 -0
  455. package/dist/bundle/chunks/chunk-EIL6ZC3J.js +0 -1240
  456. package/dist/bundle/chunks/chunk-GCKVPVMH.js +0 -2
  457. package/dist/bundle/chunks/virtual-modules-RGWFZDWP.js +0 -2
@@ -1,103 +1,110 @@
1
- # Environment Variables
2
-
3
- Diffra uses environment variables in three ways:
4
-
5
- - Variables such as `DIFFRA_OFFLINE` configure the Diffra process.
6
- - Diffra sets process markers so child processes can identify Diffra as the launching agent.
7
- - Commands run by the LLM-callable shell tools receive `PI_*` variables describing the current session.
8
-
9
- Provider API-key variables are documented separately in [Providers](providers.md#use-an-api-key-from-the-environment).
10
-
11
- ## Process Marker
12
-
13
- The CLI and RPC entry points set two process markers:
14
-
15
- - `AI_AGENT=diffra` is a generic marker that lets tooling identify Diffra as the agent that launched the process.
16
- - `DIFFRA_CODING_AGENT=true` is Pi-specific and lets child processes detect that they run inside Diffra.
17
-
18
- Child processes inherit both markers. They are not session-specific and are not set automatically when Diffra is embedded through the SDK.
19
-
20
- ## Shell Tool Session Environment
21
-
22
- Commands run by the `bash` and `powershell` tools receive the current Diffra session state:
23
-
24
- | Variable | Description |
25
- |----------|-------------|
26
- | `DIFFRA_SESSION_ID` | Current session ID |
27
- | `DIFFRA_SESSION_FILE` | Absolute path to the current session JSONL file; unset for ephemeral sessions |
28
- | `DIFFRA_PROVIDER` | Currently selected model provider |
29
- | `DIFFRA_MODEL` | Currently selected model ID |
30
- | `DIFFRA_REASONING_LEVEL` | Current effective reasoning level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` |
31
-
32
- The values are resolved when each command starts. Switching models or changing the reasoning level therefore affects the next shell command without restarting Diffra. `DIFFRA_PROVIDER` and `DIFFRA_MODEL` identify the selected Diffra model, not a different upstream model that a router may choose internally.
33
-
34
- When asked which model or provider is running, inspect these variables instead of inferring the answer from the system prompt:
35
-
36
- ```bash
37
- printf '%s/%s\n' "$DIFFRA_PROVIDER" "$DIFFRA_MODEL"
38
- printf 'reasoning=%s session=%s\n' "$DIFFRA_REASONING_LEVEL" "$DIFFRA_SESSION_ID"
39
- ```
40
-
41
- The session file can be inspected directly when the session is persistent:
42
-
43
- ```bash
44
- if [ -n "$DIFFRA_SESSION_FILE" ]; then
45
- tail -n 1 "$DIFFRA_SESSION_FILE"
46
- fi
47
- ```
48
-
49
- These variables are injected into the LLM-callable `bash` and `powershell` tools. They are not injected into user-entered `!` or `!!` commands.
50
-
51
- ### Custom Shell Tools
52
-
53
- Tools created with `createBashTool()` or `createPowerShellTool()` expose the session environment by default when registered with Diffra. Injection happens before `spawnHook`, so a hook receives the variables in `ctx.env`:
54
-
55
- ```typescript
56
- const bashTool = createBashTool(cwd, {
57
- spawnHook: (ctx) => ({
58
- ...ctx,
59
- env: { ...ctx.env, CI: "1" },
60
- }),
61
- });
62
- ```
63
-
64
- Disable session metadata independently of the spawn hook:
65
-
66
- ```typescript
67
- const powershellTool = createPowerShellTool(cwd, {
68
- exposeSessionEnvironment: false,
69
- spawnHook: (ctx) => ctx,
70
- });
71
- ```
72
-
73
- When disabled, Diffra removes inherited values for these variables so nested Diffra processes do not expose stale parent-session metadata.
74
-
75
- ## Diffra Process Configuration
76
-
77
- These variables are read by Diffra itself:
78
-
79
- | Variable | Description |
80
- |----------|-------------|
81
- | `DIFFRA_CODING_AGENT_DIR` | Override the config directory; default is `~/.diffra/agent` |
82
- | `DIFFRA_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
83
- | `DIFFRA_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
84
- | `DIFFRA_OFFLINE` | Disable automatic network activity, including model catalog refreshes |
85
- | `DIFFRA_SKIP_VERSION_CHECK` | Disable the npm registry latest-version request |
86
- | `DIFFRA_SELF_UPDATE_COMMAND` | Command `diffra update` runs to update Diffra itself, split on whitespace, with `{packageName}`, `{version}`, and `{installSpec}` placeholders. Takes precedence over the `selfUpdateCommand` setting. See [Custom update command](cli.md#custom-update-command) |
87
- | `DIFFRA_TELEMETRY` | Override provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
88
- | `DIFFRA_CODEMODE_MAX_WORKERS` | Maximum codemode workers alive at once across all sessions in the process; default `2`. Each worker's script may use up to 256 MB. Raise it when one process runs several sessions, such as in-process subagents. Further scripts wait for a free worker. See [Codemode](codemode.md) |
89
- | `DIFFRA_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
90
- | `DIFFRA_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
91
- | `DIFFRA_RADIUS_GATEWAY` | Override the Radius gateway origin used by `/bug` uploads |
92
- | `DIFFRA_CLEAR_ON_SHRINK` | Set to `1` to clear empty rows when rendered content shrinks; the `terminal.clearOnShrink` setting takes precedence. See [Settings](settings.md) |
93
- | `DIFFRA_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
94
- | `DIFFRA_CLIPBOARD_OSC52` | Set to `1` to also send copied text to the terminal with OSC 52 after the local clipboard write, as Diffra does over SSH. Use it when a remote client reaches Diffra without SSH variables, such as a multiplexer attached from another machine or a remote IDE daemon |
95
- | `DIFFRA_HYPERLINKS` | Override OSC 8 hyperlink detection with `1`, `0`, or `auto` |
96
- | `DIFFRA_PROGRAM_STATUS` | Override OSC 7501 program status detection: `1` always reports, `0` never reports; otherwise Diffra reports only after the terminal confirms support. See [Terminal setup](terminal-setup.md#program-status) |
97
- | `DIFFRA_IMAGE_PROTOCOL` | Override inline image detection with `kitty`, `iterm2`, `none`, or `auto` |
98
- | `DIFFRA_TRUE_COLOR` | Override truecolor detection with `1`, `0`, or `auto` |
99
- | `DIFFRA_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase if Alt-key input is misread as Escape |
100
- | `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
101
- | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
102
-
103
- Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and provider-specific configuration are listed in [Providers](providers.md#use-an-api-key-from-the-environment).
1
+ # Environment Variables
2
+
3
+ Diffra uses environment variables in three ways:
4
+
5
+ - Variables such as `DIFFRA_OFFLINE` configure the Diffra process.
6
+ - Diffra sets process markers so child processes can identify Diffra as the launching agent.
7
+ - Commands run by the LLM-callable shell tools receive `PI_*` variables describing the current session.
8
+
9
+ Provider API-key variables are documented separately in [Providers](providers.md#use-an-api-key-from-the-environment).
10
+
11
+ ## Process Marker
12
+
13
+ The CLI and RPC entry points set two process markers:
14
+
15
+ - `AI_AGENT=diffra` is a generic marker that lets tooling identify Diffra as the agent that launched the process.
16
+ - `DIFFRA_CODING_AGENT=true` is Pi-specific and lets child processes detect that they run inside Diffra.
17
+
18
+ Child processes inherit both markers. They are not session-specific and are not set automatically when Diffra is embedded through the SDK.
19
+
20
+ ## Shell Tool Session Environment
21
+
22
+ Commands run by the `bash` and `powershell` tools receive the current Diffra session state:
23
+
24
+ | Variable | Description |
25
+ |----------|-------------|
26
+ | `DIFFRA_SESSION_ID` | Current session ID |
27
+ | `DIFFRA_SESSION_FILE` | Absolute path to the current session JSONL file; unset for ephemeral sessions |
28
+ | `DIFFRA_PROVIDER` | Currently selected model provider |
29
+ | `DIFFRA_MODEL` | Currently selected model ID |
30
+ | `DIFFRA_REASONING_LEVEL` | Current effective reasoning level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` |
31
+
32
+ The values are resolved when each command starts. Switching models or changing the reasoning level therefore affects the next shell command without restarting Diffra. `DIFFRA_PROVIDER` and `DIFFRA_MODEL` identify the selected Diffra model, not a different upstream model that a router may choose internally.
33
+
34
+ When asked which model or provider is running, inspect these variables instead of inferring the answer from the system prompt:
35
+
36
+ ```bash
37
+ printf '%s/%s\n' "$DIFFRA_PROVIDER" "$DIFFRA_MODEL"
38
+ printf 'reasoning=%s session=%s\n' "$DIFFRA_REASONING_LEVEL" "$DIFFRA_SESSION_ID"
39
+ ```
40
+
41
+ The session file can be inspected directly when the session is persistent:
42
+
43
+ ```bash
44
+ if [ -n "$DIFFRA_SESSION_FILE" ]; then
45
+ tail -n 1 "$DIFFRA_SESSION_FILE"
46
+ fi
47
+ ```
48
+
49
+ These variables are injected into the LLM-callable `bash` and `powershell` tools. They are not injected into user-entered `!` or `!!` commands.
50
+
51
+ ### Custom Shell Tools
52
+
53
+ Tools created with `createBashTool()` or `createPowerShellTool()` expose the session environment by default when registered with Diffra. Injection happens before `spawnHook`, so a hook receives the variables in `ctx.env`:
54
+
55
+ ```typescript
56
+ const bashTool = createBashTool(cwd, {
57
+ spawnHook: (ctx) => ({
58
+ ...ctx,
59
+ env: { ...ctx.env, CI: "1" },
60
+ }),
61
+ });
62
+ ```
63
+
64
+ Disable session metadata independently of the spawn hook:
65
+
66
+ ```typescript
67
+ const powershellTool = createPowerShellTool(cwd, {
68
+ exposeSessionEnvironment: false,
69
+ spawnHook: (ctx) => ctx,
70
+ });
71
+ ```
72
+
73
+ When disabled, Diffra removes inherited values for these variables so nested Diffra processes do not expose stale parent-session metadata.
74
+
75
+ ## Diffra Process Configuration
76
+
77
+ These variables are read by Diffra itself:
78
+
79
+ | Variable | Description |
80
+ |----------|-------------|
81
+ | `DIFFRA_CODING_AGENT_DIR` | Override the config directory; default is `~/.diffra/agent` |
82
+ | `DIFFRA_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
83
+ | `DIFFRA_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
84
+ | `DIFFRA_OFFLINE` | Disable automatic network activity, including model catalog refreshes |
85
+ | `DIFFRA_SANDBOX_HELPER` | Path of a `diffra-sandbox.exe` to use instead of the downloaded one (Windows [sandbox](sandbox.md)) |
86
+ | `DIFFRA_MEMORY_BASE_DIR` | Base directory of [auto memory](memory.md) instead of the agent directory |
87
+ | `DIFFRA_ENABLE_LSP`, `DIFFRA_DISABLE_LSP` | Set to `1` to turn [LSP code intelligence](lsp.md) on or off; off wins |
88
+ | `DIFFRA_DISABLE_CRON` | Set to `1` to turn [scheduled tasks](scheduled-tasks.md) off |
89
+ | `DIFFRA_CRON_MAX_AGE_DAYS` | Days until a recurring scheduled job expires, overriding `experimental.cronRecurringMaxAgeDays`; `0` for never |
90
+ | `DIFFRA_WEB_FETCH_PROCESSING_TIMEOUT_MS` | Time limit of `web_fetch`'s model step (default 300000) |
91
+ | `ENABLE_WEB_SEARCH`, `WEB_SEARCH_*` | Configure [`web_search`](web-tools.md#settings) |
92
+ | `DIFFRA_SKIP_VERSION_CHECK` | Disable the npm registry latest-version request |
93
+ | `DIFFRA_SELF_UPDATE_COMMAND` | Command `diffra update` runs to update Diffra itself, split on whitespace, with `{packageName}`, `{version}`, and `{installSpec}` placeholders. Takes precedence over the `selfUpdateCommand` setting. See [Custom update command](cli.md#custom-update-command) |
94
+ | `DIFFRA_TELEMETRY` | Override provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
95
+ | `DIFFRA_CODEMODE_MAX_WORKERS` | Maximum codemode workers alive at once across all sessions in the process; default `2`. Each worker's script may use up to 256 MB. Raise it when one process runs several sessions, such as in-process subagents. Further scripts wait for a free worker. See [Codemode](codemode.md) |
96
+ | `DIFFRA_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
97
+ | `DIFFRA_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
98
+ | `DIFFRA_RADIUS_GATEWAY` | Override the Radius gateway origin used by `/bug` uploads |
99
+ | `DIFFRA_CLEAR_ON_SHRINK` | Set to `1` to clear empty rows when rendered content shrinks; the `terminal.clearOnShrink` setting takes precedence. See [Settings](settings.md) |
100
+ | `DIFFRA_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
101
+ | `DIFFRA_CLIPBOARD_OSC52` | Set to `1` to also send copied text to the terminal with OSC 52 after the local clipboard write, as Diffra does over SSH. Use it when a remote client reaches Diffra without SSH variables, such as a multiplexer attached from another machine or a remote IDE daemon |
102
+ | `DIFFRA_HYPERLINKS` | Override OSC 8 hyperlink detection with `1`, `0`, or `auto` |
103
+ | `DIFFRA_PROGRAM_STATUS` | Override OSC 7501 program status detection: `1` always reports, `0` never reports; otherwise Diffra reports only after the terminal confirms support. See [Terminal setup](terminal-setup.md#program-status) |
104
+ | `DIFFRA_IMAGE_PROTOCOL` | Override inline image detection with `kitty`, `iterm2`, `none`, or `auto` |
105
+ | `DIFFRA_TRUE_COLOR` | Override truecolor detection with `1`, `0`, or `auto` |
106
+ | `DIFFRA_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase if Alt-key input is misread as Escape |
107
+ | `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
108
+ | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
109
+
110
+ Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and provider-specific configuration are listed in [Providers](providers.md#use-an-api-key-from-the-environment).
@@ -966,6 +966,17 @@ diffra.on("thinking_level_select", async (event, ctx) => {
966
966
 
967
967
  Use this to update extension UI when `diffra.setThinkingLevel()`, model changes, or built-in thinking-level controls change the active thinking level.
968
968
 
969
+ #### approval_mode_change
970
+
971
+ Fired when the session's [approval mode](approval-modes.md) changes, from `/approval-mode`, `/plan`, the cycle keybinding, `exit_plan_mode`, or `diffra.setApprovalMode()`. This is notification-only.
972
+
973
+ ```typescript
974
+ diffra.on("approval_mode_change", async (event, ctx) => {
975
+ // event.mode - "plan" | "default" | "auto-edit" | "auto" | "yolo"
976
+ // event.previousMode - the mode before the change
977
+ });
978
+ ```
979
+
969
980
  <a id="tool-call-events"></a>
970
981
 
971
982
  ### Tool Events
@@ -1962,6 +1973,15 @@ const current = diffra.getThinkingLevel(); // "off" | "minimal" | "low" | "medi
1962
1973
  diffra.setThinkingLevel("high");
1963
1974
  ```
1964
1975
 
1976
+ ### diffra.getApprovalMode() / diffra.setApprovalMode(mode, options?)
1977
+
1978
+ Get or change the session's [approval mode](approval-modes.md). Changes are recorded on the session branch, so resume, `/tree`, and fork keep them, and emit `approval_mode_change`. `options.persist` (`"user"` or `"project"`) also saves the mode as the `approvalMode` default for new sessions. The built-in approval extension enforces the mode; the mode itself does not block tool calls.
1979
+
1980
+ ```typescript
1981
+ if (diffra.getApprovalMode() === "plan") return;
1982
+ diffra.setApprovalMode("auto-edit");
1983
+ ```
1984
+
1965
1985
  ### diffra.events
1966
1986
 
1967
1987
  Shared event bus for communication between extensions:
@@ -2135,6 +2155,10 @@ diffra.registerToolRenderer((toolName, next) => {
2135
2155
 
2136
2156
  Return a copy of the effective settings, with global and project settings merged and overrides applied.
2137
2157
 
2158
+ ### diffra.getGlobalSettings()
2159
+
2160
+ Return a copy of the user's global settings alone. Use it for options a project must not be able to turn on, such as starting programs the repository names.
2161
+
2138
2162
  <a id="persist-state"></a>
2139
2163
 
2140
2164
  ## State Management
package/docs/goals.md ADDED
@@ -0,0 +1,84 @@
1
+ # Work Toward a Goal
2
+
3
+ A Goal is an objective the agent keeps working on across turns, without you prompting each one. `/goal <objective>` sets it; after every turn Diffra starts the next one, until the agent proposes that the Goal is complete or blocked and an independent verifier accepts the proposal, or you pause or clear the Goal, or a budget, a failure, or three idle turns stop it. Goals come from the built-in extension `builtin:goals`.
4
+
5
+ ```text
6
+ /goal make `npm test` pass without skipping tests
7
+ ```
8
+
9
+ ## Commands
10
+
11
+ | Command | Does |
12
+ |---|---|
13
+ | `/goal` | Show the Goal: status, turns, active time, tokens, objective, and the last reason |
14
+ | `/goal <objective>`, `/goal set <objective>` | Set a Goal. A Goal already set is replaced: new meters, new evidence |
15
+ | `/goal edit <objective>` | Change the objective. The evidence starts over and a spent budget gets a new window; a paused Goal stays paused |
16
+ | `/goal pause` | Pause an active Goal. The running turn finishes; no new one starts |
17
+ | `/goal resume` | Resume a paused, blocked, or usage-limited Goal |
18
+ | `/goal clear` | Remove the Goal (also `stop`, `off`, `reset`, `none`, `cancel`) |
19
+
20
+ A keyword counts as a command only on its own: `/goal pause the world` sets that objective. Line breaks in an objective become spaces. The objective is sent again on every turn, so keep it short, around 1,200 characters at most. `set`, `edit`, and `resume` need a trusted project (see `/trust`).
21
+
22
+ A good objective says what done looks like and what must not happen, for example: "All tests in `packages/api` pass with `npm test`; do not change test files."
23
+
24
+ ## How a Goal runs
25
+
26
+ Each turn the runtime starts gets a continuation prompt: the objective as runtime data, the budget figures, the verifier's feedback on the last proposal, and rules for proving the work: re-run the decisive checks right before proposing, do not substitute an easier result, judge the previous turn, and treat completion as unproven. A message you send while a Goal is active runs as the next Goal turn; Diffra continues after it.
27
+
28
+ While a Goal is active the agent has two tools:
29
+
30
+ - `get_goal` reads the objective, status, budgets, and verifier feedback.
31
+ - `update_goal` proposes `complete` or `blocked`, with a reason. It only records the proposal; a ready proposal ends the turn. A `blocked` proposal names a `blockerKind`: `authority` (needs your permission or choice), `external` (needs an outside change), and `infeasible` (cannot be met as written) go to the verifier at once; `repeated`, the default, goes to the verifier only when the same blocker with the same reason is reported on three consecutive turns.
32
+
33
+ ## The verifier
34
+
35
+ After a turn with a ready proposal, a separate model call judges it: the [`fastModel`](settings.md) when set, otherwise the session model, with no tools and a 2-minute limit. It reads a JSON request with the objective, the proposal, and the evidence of this Goal's turns, newest first: your messages, the agent's replies, and tool results, each capped at 8,000 bytes, up to 256,000 bytes in all. Each record says what it can prove:
36
+
37
+ | Kind | Records | Proves |
38
+ |---|---|---|
39
+ | `user_input` | Your messages | What you said, confirmed, or chose |
40
+ | `delivered_output` | The agent's replies | Only that the agent said it |
41
+ | `external_fact` | Results of tools the agent ran | Facts about the workspace and the world |
42
+ | `execution_output` | Results of `agent` and `codemode` | Nothing on their own: they can repeat the agent's claims |
43
+
44
+ Missing evidence means rejection. An accepted proposal makes the Goal `complete` or `blocked`; a rejected one keeps it active and its reason goes to the next turn as feedback. When the verifier fails or times out, the Goal pauses.
45
+
46
+ ## Budgets
47
+
48
+ | Setting | Default | Range |
49
+ |---|---|---|
50
+ | `goals.tokenBudget` | 30,000,000 tokens | 1 to 300,000,000; `-1` for none |
51
+ | `goals.maxTurns` | none | 1 to 10,000; `-1` for none |
52
+ | `goals.maxActiveMinutes` | none | 1 to 10,080 (one week); `-1` for none |
53
+
54
+ Tokens count every model call of the Goal's turns (each with its full context), foreground subagents, and verifier checks. Turns count finished Goal turns, including yours. Active time runs while the Goal is active, between turns too; paused time and time while Diffra is closed do not count. A new Goal arms the budgets of the settings; `/goal` refuses to start with an invalid setting.
55
+
56
+ When a budget is spent, the Goal gets one last turn to write a hand-off (what was done, what remains, the next step), then stops as `usage limited`. `/goal resume` gives the spent budget another window ahead of what was used; the meters never reset.
57
+
58
+ ## When a Goal pauses
59
+
60
+ | Reason |
61
+ |---|
62
+ | You pressed Escape during a Goal turn |
63
+ | `/goal pause` |
64
+ | Three runtime turns in a row ran no tool besides `get_goal` and `update_goal` and proposed nothing |
65
+ | A turn ended with a model error, or the verifier could not judge |
66
+ | The objective and proposal leave the verifier no room for evidence |
67
+ | Diffra closed during a Goal turn or check |
68
+ | A print-mode run ended while the Goal was still active |
69
+
70
+ While a Goal is paused, your messages are ordinary conversation: the model is told not to continue the objective until you resume it.
71
+
72
+ ## Status and sessions
73
+
74
+ The footer shows `◎ goal active`, `○ goal checking`, `! goal paused`, `✕ goal blocked`, or `! goal usage limited`, with the tokens spent and the active time. Every change of the Goal is recorded in the session and drawn as a card in the transcript, so a Goal survives `/resume`; an active one continues when the session opens again.
75
+
76
+ In print mode (`diffra -p "/goal ..."`), the command returns once the Goal stops, so one run drives the Goal to the end.
77
+
78
+ ## Differences from Qwen Code
79
+
80
+ - The budgets are the `goals.tokenBudget`, `goals.maxTurns`, and `goals.maxActiveMinutes` settings instead of `model.goalTokenBudget`, `model.goalMaxTurns`, and `model.goalMaxActiveMinutes`. New values apply to the next Goal without a restart.
81
+ - `get_goal` and `update_goal` are declared to the model only while a Goal is active.
82
+ - There is no `propose_goal` tool, no `/goal-draft` skill, and no `goals.modelProposed` setting: only you set Goals.
83
+ - Results of tools a `codemode` script calls are not recorded separately, so they reach the verifier only as the script's `execution_output`.
84
+ - The session token limit and the Stop-hook cap do not pause a Goal: Diffra has no session token limit, and Stop hooks end their own loop.
package/docs/hooks.md ADDED
@@ -0,0 +1,112 @@
1
+ # Run Hooks on Events
2
+
3
+ Hooks run your commands, HTTP endpoints, or prompts when something happens in a session: before and after tool calls, when you submit a prompt, when the agent is about to stop, when a session starts or ends, around compaction, when subagents start and stop, and when watched files change. A hook can block a tool call or a prompt, change a tool's input, add context for the model, or keep the agent working. Hooks come from the built-in extension `builtin:hooks` and are on by default; `"disableAllHooks": true` turns them off.
4
+
5
+ ## Configure hooks
6
+
7
+ Declare hooks in the `hooks` setting of `~/.diffra/agent/settings.json` or a project's `.diffra/settings.json`. Each event has matcher groups, and each group has hooks:
8
+
9
+ ```json
10
+ {
11
+ "hooks": {
12
+ "PreToolUse": [
13
+ {
14
+ "matcher": "bash",
15
+ "hooks": [{ "type": "command", "command": "node .diffra/hooks/check-command.js", "timeout": 10 }]
16
+ }
17
+ ],
18
+ "PostToolUse": [
19
+ {
20
+ "matcher": "Write|Edit",
21
+ "hooks": [{ "type": "command", "command": "npx prettier --write \"$(jq -r .tool_input.path)\"" }]
22
+ }
23
+ ]
24
+ }
25
+ }
26
+ ```
27
+
28
+ The hooks of user and project settings all run; in a sequential group, project hooks come first. Project settings, and with them project hooks, load only in a [trusted project](configuration.md). The same hook listed twice runs once.
29
+
30
+ | Field | Hook types | Meaning |
31
+ |---|---|---|
32
+ | `type` | all | `command`, `http`, or `prompt` |
33
+ | `command` | command | Shell command; it gets the event as JSON on stdin |
34
+ | `url` | http | Endpoint that gets the event as a JSON `POST` body |
35
+ | `prompt` | prompt | Prompt for a model; `$ARGUMENTS` becomes the event JSON |
36
+ | `model` | prompt | `provider/model-id`; default: the [`fastModel`](settings.md) or the session model |
37
+ | `timeout` | all | Seconds; defaults: command 60, http 600, prompt 30. A command timeout of 1000 or more is read as milliseconds |
38
+ | `async` | command | Run without waiting; what it prints reaches the model with your next prompt. At most 10 run at once |
39
+ | `env` | command | Extra environment variables |
40
+ | `shell` | command | `bash` (the default shell, see [Shell](settings.md#shell)) or `powershell` |
41
+ | `headers`, `allowedEnvVars` | http | Request headers; `$VAR` and `${VAR}` in them expand only for names in `allowedEnvVars` |
42
+ | `once` | http | Run once per event per session |
43
+ | `name`, `description`, `statusMessage` | all | Shown in `/hooks`; `statusMessage` shows in the footer while the hook runs |
44
+
45
+ A group's `matcher` selects what the hooks run for: empty, `*`, or `.*` match everything; an exact name matches; `A|B` lists names; anything else is a regular expression, not anchored. Tool matchers also accept Claude Code tool names: `Bash`, `Read`, `Write`, `Edit`, `Grep`, `Glob`, `LS`, `WebFetch`, `WebSearch`, `Task`/`Agent`, `TodoWrite`. A group with `"sequential": true` makes the event's hooks run one after another, and each sees the changes of the ones before; otherwise they run in parallel.
46
+
47
+ ## Events
48
+
49
+ Every hook gets `hook_event_name`, `session_id`, `transcript_path` (the session file), `cwd`, `timestamp`, and `permission_mode` (`plan`, `default`, `auto_edit`, `auto`, or `yolo`), plus the event's fields:
50
+
51
+ | Event | When | Matcher | Fields | Can |
52
+ |---|---|---|---|---|
53
+ | `PreToolUse` | Before a tool call runs, before [approval](approval-modes.md) checks | tool name | `tool_name`, `tool_input`, `tool_use_id` | Block, ask, replace the input, add context |
54
+ | `PostToolUse` | After a successful call | tool name | `tool_name`, `tool_input`, `tool_response`, `tool_use_id` | Add context, stop the run |
55
+ | `PostToolUseFailure` | After a failed call | tool name | `tool_name`, `tool_input`, `error`, `tool_use_id` | Add context, stop the run |
56
+ | `UserPromptSubmit` | Before your prompt is sent | none | `prompt`, `submitted_prompt` | Block the prompt, add context |
57
+ | `Stop` | When the agent is about to finish | none | `stop_hook_active`, `last_assistant_message` | Keep the agent working |
58
+ | `StopFailure` | When a run ends with an error | error | `error`, `last_assistant_message` | Nothing |
59
+ | `SessionStart` | When a session starts, resumes, clears, or forks | source: `startup`, `resume`, `clear`, `branch` | `source`, `model` | Add context, watch files |
60
+ | `SessionEnd` | When the session ends | reason | `reason` | Nothing |
61
+ | `SubagentStart` | When a [subagent](subagents.md) starts | agent type | `agent_id`, `agent_type` | Nothing |
62
+ | `SubagentStop` | When a subagent finishes | agent type | `agent_id`, `agent_type`, `last_assistant_message` | Nothing |
63
+ | `PreCompact` | Before compaction | `manual` or `auto` | `trigger`, `custom_instructions` | Nothing |
64
+ | `PostCompact` | After compaction | `manual` or `auto` | `trigger`, `compact_summary` | Nothing |
65
+ | `FileChanged` | When a watched file is added, changed, or deleted | file name | `file_path`, `event` (`add`, `change`, `unlink`) | Watch files |
66
+
67
+ ## Hook results
68
+
69
+ A command hook's exit code decides what happens:
70
+
71
+ - **0**: success. Stdout may be a JSON object (below). Plain text is context for the model on `SessionStart` and `UserPromptSubmit` and a message for you on other events.
72
+ - **2**: block. Stderr is the reason (or a JSON object). It blocks `PreToolUse`, `UserPromptSubmit`, and `Stop` (which then keeps the agent working).
73
+ - **Anything else**: a warning; nothing is blocked. Failures, timeouts, and invalid JSON never stop Diffra.
74
+
75
+ The JSON object can have:
76
+
77
+ | Field | Meaning |
78
+ |---|---|
79
+ | `decision` | `block` or `deny` blocks (as exit code 2); `allow`, `approve`, and `ask` matter for `PreToolUse` |
80
+ | `reason` | Why; given to the model when a call is blocked or the agent continues |
81
+ | `continue` | `false` stops: the tool call is blocked or the run stops, and on `Stop` the agent continues |
82
+ | `stopReason` | The reason for `continue: false` |
83
+ | `systemMessage` | A message shown to you |
84
+ | `suppressOutput` | Do not show `systemMessage` |
85
+ | `hookSpecificOutput.permissionDecision` | `PreToolUse`: `allow`, `ask` (you confirm in a dialog; without a UI it is denied), or `deny`, with `permissionDecisionReason` |
86
+ | `hookSpecificOutput.updatedInput` | `PreToolUse`: the complete replacement tool input |
87
+ | `hookSpecificOutput.additionalContext` | Context for the model: added to the tool result for tool events, sent with the next prompt for `UserPromptSubmit` and `SessionStart` |
88
+ | `hookSpecificOutput.watchPaths` | `SessionStart` and `FileChanged`: absolute files or directories to watch; a list replaces the previous one, `[]` clears it |
89
+
90
+ When several hooks run for an event, any block blocks, the strictest `permissionDecision` wins (`deny`, then `ask`, then `allow`), the last `updatedInput` wins, and all contexts are kept. `PreToolUse` `allow` does not skip approval checks.
91
+
92
+ A `Stop` hook that keeps blocking stops being obeyed after 8 times in a row. An HTTP hook succeeds with any 2xx response; a JSON body (with `Content-Type: application/json`) is read like stdout, other text becomes a message. A prompt hook's model answers `{"ok": true}`, or `{"ok": false, "reason": "..."}` to block.
93
+
94
+ Command hooks run in the session's working directory with `DIFFRA_PROJECT_DIR` (and `CLAUDE_PROJECT_DIR`, for hooks written for Claude Code) set to it. Stdout and stderr are each read up to 1 MiB. A hook that runs past its timeout is killed.
95
+
96
+ ## Watch files
97
+
98
+ `FileChanged` hooks run for files named in their matcher, such as `"matcher": "package.json|.env"`: plain file names, resolved against the working directory, also when they do not exist yet. `SessionStart` and `FileChanged` hooks can add absolute files or directories (watched recursively, without `.git` and `node_modules`) through `watchPaths`. Changes are reported once writes settle for 200 ms.
99
+
100
+ ## List hooks
101
+
102
+ `/hooks` lists the configured hooks by event and matcher.
103
+
104
+ ## Differences from Qwen Code
105
+
106
+ - Events not supported: `PostToolBatch`, `UserPromptExpansion`, `SessionDelete`, `MessageDisplay`, `Notification`, `PermissionRequest`, `PermissionDenied`, `TodoCreated`, `TodoCompleted`, and `InstructionsLoaded`. Configuring them shows a warning.
107
+ - `SubagentStop` cannot keep a subagent working, and `StopFailure` reports the error as `unknown`.
108
+ - `PreToolUse` runs after Diffra validates the tool input, and a replacement input is not validated again.
109
+ - Project hooks need a trusted project; there is no separate approval dialog for a project's hooks block.
110
+ - Hooks get `DIFFRA_PROJECT_DIR` instead of `QWEN_PROJECT_DIR`, and context is wrapped in `<diffra:hook-context>`.
111
+ - A hook past its timeout is killed at once, without a grace period. HTTP hooks have no URL allowlist or private-network block.
112
+ - `/hooks` prints the list instead of opening a browser dialog.
@@ -154,6 +154,7 @@ On native Windows, `app.suspend` has no default because Windows terminals do not
154
154
  | `app.model.cycleBackward` | `shift+ctrl+p` (`alt+p` on Windows and WSL) | Cycle to previous model |
155
155
  | `app.models.save` | `ctrl+s` | Save the selected default model or scoped model configuration to settings |
156
156
  | `app.thinking.cycle` | `shift+tab` | Cycle thinking level |
157
+ | `app.approvalMode.cycle` | `alt+m` | Cycle approval mode: plan, default, auto-edit, auto, yolo (see [Approve Tool Calls](approval-modes.md)) |
157
158
  | `app.thinking.save` | `ctrl+s` | Save current thinking level to settings |
158
159
  | `app.thinking.toggle` | `ctrl+t` | Collapse or expand thinking blocks |
159
160
 
package/docs/lsp.md ADDED
@@ -0,0 +1,71 @@
1
+ # Use Language Servers (Experimental)
2
+
3
+ With LSP on, the agent can ask your project's language servers about code through the `lsp` tool: where a symbol is defined, implemented, and used, its type, the symbols of a file or the workspace, the call hierarchy, compiler diagnostics, and code actions. LSP is experimental and off by default. It comes from the built-in extension `builtin:lsp`.
4
+
5
+ ## Turn it on
6
+
7
+ Any of these turns LSP on for the session:
8
+
9
+ - `--experimental-lsp`
10
+ - `DIFFRA_ENABLE_LSP=1`
11
+ - `"tools": { "lspEnabled": true }` in your user settings (`~/.diffra/agent/settings.json`). Project settings cannot turn it on, because it starts programs.
12
+
13
+ `DIFFRA_DISABLE_LSP=1` turns it off and wins over the others. The setting is read when a session starts.
14
+
15
+ ## Configure servers
16
+
17
+ Diffra bundles and detects no servers: install them yourself and list them in `.lsp.json` at the project root. Each key is a language id:
18
+
19
+ ```json
20
+ {
21
+ "typescript": {
22
+ "command": "typescript-language-server",
23
+ "args": ["--stdio"],
24
+ "extensionToLanguage": { ".ts": "typescript", ".tsx": "typescriptreact" }
25
+ },
26
+ "go": { "command": "gopls" }
27
+ }
28
+ ```
29
+
30
+ | Field | Default | Meaning |
31
+ |---|---|---|
32
+ | `command` | required for `stdio` | Program to run: a name found on `PATH`, an absolute path, or a path inside the project |
33
+ | `args` | `[]` | Its arguments |
34
+ | `transport` | `stdio` | `stdio`, or `tcp`/`socket` with `socket: { host, port }` or `socket: { path }`; `command` is then optional and started first |
35
+ | `env` | `{}` | Extra environment. `PATH`, `NODE_OPTIONS`, `LD_PRELOAD`, and similar keys are ignored |
36
+ | `extensionToLanguage` | common extensions | File extensions the server serves, mapped to language ids |
37
+ | `initializationOptions` | none | Sent with `initialize` |
38
+ | `settings` | none | Sent with `workspace/didChangeConfiguration` and returned for `workspace/configuration` |
39
+ | `workspaceFolder` | project root | A folder inside the project to open |
40
+ | `startupTimeout`, `shutdownTimeout` | 10000, 5000 ms | Limits for starting and stopping |
41
+ | `restartOnCrash`, `maxRestarts` | `false`, 3 | Restart a server that exits |
42
+
43
+ Servers run without a shell. On Windows, start a `.cmd` shim through `cmd`: `"command": "cmd", "args": ["/c", "typescript-language-server", "--stdio"]`.
44
+
45
+ Servers start with the session, after `<command> --version` shows that the command exists. A repository's `.lsp.json` names programs to run, so its servers start only in a folder you explicitly trusted with `/trust` (or the trust prompt); otherwise `/lsp` shows them as skipped.
46
+
47
+ `/lsp` lists the servers with their command, languages, and status (`starting`, `ready`, `failed` with the reason, or `skipped`).
48
+
49
+ ## The lsp tool
50
+
51
+ | Operation | Needs | Returns |
52
+ |---|---|---|
53
+ | `goToDefinition`, `goToImplementation`, `findReferences` | `filePath`, `line` (`character`) | Locations, as `path:line:column [server]` |
54
+ | `hover` | `filePath`, `line` (`character`) | Type and documentation |
55
+ | `documentSymbol` | `filePath` | Symbols with kind and container |
56
+ | `workspaceSymbol` | `query` | Matching symbols, and the references of the best match |
57
+ | `prepareCallHierarchy` | `filePath`, `line` (`character`) | Call hierarchy items, with JSON to pass on |
58
+ | `incomingCalls`, `outgoingCalls` | `callHierarchyItem` | Callers or callees |
59
+ | `diagnostics` | `filePath` | Errors and warnings of the file |
60
+ | `workspaceDiagnostics` | nothing | Diagnostics of all files the servers reported |
61
+ | `codeActions` | `filePath`, `line` (`endLine`, `endCharacter`, `diagnostics`, `codeActionKinds`) | Available fixes and refactorings |
62
+
63
+ Lines and columns are 1-based. `serverName` asks one server; `limit` caps the results (defaults: 20 definitions, implementations, workspace symbols, call hierarchy items, and code actions; 50 references, document symbols, and workspace diagnostics). With several servers for a file, the first one with results answers. Each request may take 15 seconds; a server that is still loading the project on its first request can need longer, so ask again.
64
+
65
+ Diagnostics come from the server's pull diagnostics where it offers them, otherwise from what it pushed after the file was opened. Edits do not report diagnostics on their own: the agent asks with `diagnostics`.
66
+
67
+ ## Differences from Qwen Code
68
+
69
+ - Servers come only from the project's `.lsp.json`; extensions cannot add servers.
70
+ - A project's servers need a trust decision saved for the folder; Diffra's automatic trust of folders without project resources is not enough.
71
+ - There is no `--debug` log of LSP traffic and no line in `/status`.
package/docs/memory.md ADDED
@@ -0,0 +1,71 @@
1
+ # Keep Auto Memory
2
+
3
+ Auto memory lets the agent keep notes across sessions: your preferences and corrections, decisions and context of a project, and pointers to external resources. Diffra saves them in the background after your turns, puts the relevant ones in front of the model, and consolidates them from time to time. It comes from the built-in extension `builtin:memory` and is on by default.
4
+
5
+ ## Where memory lives
6
+
7
+ - **User memory**, shared by all projects: `<agent dir>/memories/` (`~/.diffra/agent/memories/` by default)
8
+ - **Project memory**, one per git repository (or per directory outside a repository): `<agent dir>/projects/<repository path>/memory/`
9
+
10
+ `DIFFRA_MEMORY_BASE_DIR` replaces the agent directory as the base. Each directory holds one Markdown file per memory under `user/`, `feedback/`, `project/`, or `reference/`, and a `MEMORY.md` index with one `- [Title](type/file.md) — hook` line per memory:
11
+
12
+ ```markdown
13
+ ---
14
+ name: Use pnpm
15
+ description: The user prefers pnpm over npm in every project
16
+ type: feedback
17
+ keywords: ["pnpm", "package manager"]
18
+ ---
19
+ Use pnpm instead of npm.
20
+ **Why:** npm broke their lockfile workflow.
21
+ **How to apply:** for installs and scripts in any project.
22
+ ```
23
+
24
+ | Type | Holds | Directory |
25
+ |---|---|---|
26
+ | `user` | Who you are: role, expertise, preferences | User |
27
+ | `feedback` | How you want the agent to work | User; project for a convention of one project |
28
+ | `project` | Goals, decisions, and constraints of the project | Project |
29
+ | `reference` | Links to dashboards, tickets, documents | Project; user for your own resources |
30
+
31
+ The index is rebuilt from the memory files after each background run: at most 200 lines and 25,000 characters, listing the 200 newest files. An entry that does not fit is left out whole, and the index ends with a warning that names what was left out.
32
+
33
+ ## How memories are used
34
+
35
+ Each run gets the memory policy and both indexes in its system prompt. The policy tells the model where to save memories when you ask, how to choose the type, what not to save (code structure, git history, fix recipes, anything in AGENTS.md, task state), and to verify what a memory claims before relying on it.
36
+
37
+ Before your prompt, up to two memories that share the most words with it are added, with their age and a warning for memories older than a day. Meanwhile a model picks up to five more from the memories' titles, descriptions, and keywords; they join the run at its next turn, or are dropped when the run already ended. A memory is added at most once per session. The model is the [`fastModel`](settings.md) when set, otherwise the session model.
38
+
39
+ ## How memories are saved
40
+
41
+ When you ask, the agent writes memory files itself. After a run that answered a new message of yours, a background extractor reads the conversation since the last extraction (up to 40 messages) and the existing memories, and saves durable facts you stated: one fact per file, updating instead of duplicating, never inferred facts or one-off requests. It skips a run in which the agent already wrote memory. Its file tools only reach the memory directories, and it cannot edit `MEMORY.md`. It runs on the `fastModel` or the session model, for up to 5 turns and 2 minutes.
42
+
43
+ Once a day has passed and 5 other sessions have run in the project since the last consolidation, a background dream consolidates the memory after a run: it merges duplicates, fixes stale facts, turns relative dates into absolute ones, and lists files to delete in `.dream-operations.json`, which Diffra applies. It runs for up to 8 turns and 5 minutes.
44
+
45
+ ## Commands
46
+
47
+ | Command | Does |
48
+ |---|---|
49
+ | `/memory` | Show whether auto memory and dreaming are on and where memory lives; turn either on or off for this session; show an index |
50
+ | `/remember <text>` | Ask the agent to save `text` to the right memory directory and type |
51
+ | `/forget <text>` | Let a model pick the memories `text` describes and delete them |
52
+ | `/dream` | Consolidate now |
53
+
54
+ ## Settings
55
+
56
+ | Setting | Default | Meaning |
57
+ |---|---|---|
58
+ | `memory.enableManagedAutoMemory` | `true` | Save memories in the background after turns |
59
+ | `memory.enableManagedAutoDream` | `true` | Consolidate in the background |
60
+ | `memory.agentMaxTurns` | 5 (extractor), 8 (dream) | Turn limit of the background agents; `0` for none |
61
+ | `memory.agentTimeoutMinutes` | 2 (extractor), 5 (dream) | Time limit in minutes; `0` for none |
62
+
63
+ The background agents use model tokens on every turn they run. Turn `memory.enableManagedAutoMemory` off to stop that.
64
+
65
+ ## Differences from Qwen Code
66
+
67
+ - Memory lives under the agent directory instead of `~/.qwen`, and the indexes are in the system prompt instead of being added at the end of each request.
68
+ - Only Qwen Code's default protocol is implemented: there are no `search_memory` and `manage_memory` tools (structured recall), no team memory, and no auto-skill review.
69
+ - `/memory` turns auto memory and dreaming on or off for the session only; set the `memory` settings to keep the change.
70
+ - Memory files have no `category` and `usage_scenarios` fields, and the dream does not read old session transcripts.
71
+ - `/dream` runs the background dreamer instead of asking the main agent.