@phuetz/code-buddy 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/README.fr.md +56 -0
  2. package/README.md +74 -16
  3. package/codebuddy-runtime.json +5 -5
  4. package/dist/agent/codebuddy-agent.d.ts +18 -0
  5. package/dist/agent/codebuddy-agent.js +45 -8
  6. package/dist/agent/execution/agent-executor.d.ts +0 -9
  7. package/dist/agent/execution/agent-executor.js +176 -12
  8. package/dist/agent/execution/context-pipeline.d.ts +9 -0
  9. package/dist/agent/execution/context-pipeline.js +64 -2
  10. package/dist/agent/execution/tool-loop-guard.d.ts +76 -0
  11. package/dist/agent/execution/tool-loop-guard.js +165 -0
  12. package/dist/agent/execution/tool-selection-strategy.d.ts +7 -0
  13. package/dist/agent/execution/tool-selection-strategy.js +32 -2
  14. package/dist/agent/facades/session-facade.d.ts +0 -6
  15. package/dist/agent/facades/session-facade.js +0 -45
  16. package/dist/agent/hermes-claw-migrate.d.ts +0 -21
  17. package/dist/agent/hermes-claw-migrate.js +9 -4
  18. package/dist/agent/hermes-protocol-gateways.js +8 -1
  19. package/dist/agent/repo-profiler.js +17 -4
  20. package/dist/agent/self-improvement/authored-tool-runtime.js +10 -2
  21. package/dist/agent/self-improvement/evolution/ast-novelty.d.ts +5 -0
  22. package/dist/agent/self-improvement/evolution/ast-novelty.js +58 -23
  23. package/dist/agent/self-improvement/evolution/code-variant-store.d.ts +3 -0
  24. package/dist/agent/self-improvement/evolution/evolution-engine.js +2 -0
  25. package/dist/agent/self-improvement/evolution/protected-paths.js +6 -0
  26. package/dist/agent/self-improvement/evolution/variant-fitness.d.ts +13 -2
  27. package/dist/agent/self-improvement/evolution/variant-fitness.js +184 -58
  28. package/dist/agent/self-improvement/evolution/worktree-scorer.d.ts +2 -0
  29. package/dist/agent/self-improvement/evolution/worktree-scorer.js +15 -0
  30. package/dist/agent/self-improvement/evolutionary-archive.d.ts +2 -1
  31. package/dist/agent/self-improvement/evolutionary-archive.js +34 -5
  32. package/dist/agent/self-improvement/proposal-store.d.ts +1 -0
  33. package/dist/agent/self-improvement/proposal-store.js +79 -17
  34. package/dist/agent/self-improvement/skill-apply-journal.d.ts +44 -0
  35. package/dist/agent/self-improvement/skill-apply-journal.js +178 -0
  36. package/dist/agent/self-improvement/skill-behavior-benchmark.d.ts +3 -0
  37. package/dist/agent/self-improvement/skill-behavior-benchmark.js +19 -0
  38. package/dist/agent/self-improvement/skill-behavior-gate.d.ts +34 -0
  39. package/dist/agent/self-improvement/skill-behavior-gate.js +96 -0
  40. package/dist/agent/self-improvement/skill-engine.d.ts +22 -0
  41. package/dist/agent/self-improvement/skill-engine.js +385 -13
  42. package/dist/agent/self-improvement/skill-gate.d.ts +2 -0
  43. package/dist/agent/self-improvement/skill-gate.js +17 -2
  44. package/dist/agent/self-improvement/skill-mutator.d.ts +6 -1
  45. package/dist/agent/self-improvement/skill-mutator.js +51 -15
  46. package/dist/agent/self-improvement/skill-types.d.ts +2 -1
  47. package/dist/agent/self-improvement/types.d.ts +11 -0
  48. package/dist/agent/tool-handler.d.ts +1 -1
  49. package/dist/agent/tool-handler.js +28 -9
  50. package/dist/auth/profile-manager.js +1 -1
  51. package/dist/channels/companion-channel-turn.d.ts +53 -4
  52. package/dist/channels/companion-channel-turn.js +218 -16
  53. package/dist/channels/slash-parity.d.ts +4 -6
  54. package/dist/channels/slash-parity.js +9 -44
  55. package/dist/cli/session-commands.d.ts +9 -0
  56. package/dist/cli/session-commands.js +45 -5
  57. package/dist/cli/session-picker.d.ts +43 -0
  58. package/dist/cli/session-picker.js +128 -0
  59. package/dist/codebuddy/a2a-call-tool-defs.d.ts +26 -0
  60. package/dist/codebuddy/a2a-call-tool-defs.js +12 -0
  61. package/dist/codebuddy/fleet-tool-defs.d.ts +2 -0
  62. package/dist/codebuddy/fleet-tool-defs.js +55 -0
  63. package/dist/codebuddy/providers/chatgpt-headers.d.ts +18 -0
  64. package/dist/codebuddy/providers/chatgpt-headers.js +37 -0
  65. package/dist/codebuddy/providers/provider-chatgpt-responses.d.ts +2 -1
  66. package/dist/codebuddy/providers/provider-chatgpt-responses.js +10 -23
  67. package/dist/codebuddy/providers/provider-openai-compat.d.ts +7 -0
  68. package/dist/codebuddy/providers/provider-openai-compat.js +29 -1
  69. package/dist/codebuddy/ragchat-tool-defs.d.ts +31 -0
  70. package/dist/codebuddy/ragchat-tool-defs.js +19 -0
  71. package/dist/codebuddy/resource-catalog-tool-defs.d.ts +28 -0
  72. package/dist/codebuddy/resource-catalog-tool-defs.js +18 -0
  73. package/dist/codebuddy/tool-definitions/agent-tools.js +2 -2
  74. package/dist/codebuddy/tool-definitions/code-exec-tools.js +5 -1
  75. package/dist/codebuddy/tool-definitions/cron-tools.js +6 -0
  76. package/dist/codebuddy/tool-definitions/self-describe-tools.js +6 -1
  77. package/dist/codebuddy/tools.d.ts +0 -6
  78. package/dist/codebuddy/tools.js +25 -3
  79. package/dist/commands/cli/daemon-commands.js +3 -1
  80. package/dist/commands/cli/evolve-command.js +21 -5
  81. package/dist/commands/cli/fleet-collaboration-commands.d.ts +2 -0
  82. package/dist/commands/cli/fleet-collaboration-commands.js +57 -0
  83. package/dist/commands/cli/fleet-commands.js +29 -0
  84. package/dist/commands/cli/fleet-mission-commands.d.ts +3 -0
  85. package/dist/commands/cli/fleet-mission-commands.js +72 -0
  86. package/dist/commands/cli/fleet-rooms-commands.d.ts +10 -0
  87. package/dist/commands/cli/fleet-rooms-commands.js +289 -0
  88. package/dist/commands/cli/tools-commands.js +2 -1
  89. package/dist/commands/cli/triage-command.d.ts +8 -0
  90. package/dist/commands/cli/triage-command.js +72 -0
  91. package/dist/commands/cli/utility-commands.js +25 -1
  92. package/dist/commands/client-dispatcher.d.ts +7 -0
  93. package/dist/commands/client-dispatcher.js +73 -21
  94. package/dist/commands/cron-cli/index.d.ts +3 -1
  95. package/dist/commands/cron-cli/index.js +25 -0
  96. package/dist/commands/device-auth.d.ts +10 -0
  97. package/dist/commands/device-auth.js +91 -0
  98. package/dist/commands/enhanced-command-handler.d.ts +9 -0
  99. package/dist/commands/enhanced-command-handler.js +28 -6
  100. package/dist/commands/handlers/agent-handlers.d.ts +1 -1
  101. package/dist/commands/handlers/agent-handlers.js +4 -4
  102. package/dist/commands/handlers/channel-handlers.js +53 -2
  103. package/dist/commands/handlers/export-handlers.d.ts +3 -2
  104. package/dist/commands/handlers/export-handlers.js +55 -28
  105. package/dist/commands/handlers/extra-handlers.js +5 -1
  106. package/dist/commands/handlers/grill-me-handler.js +26 -18
  107. package/dist/commands/handlers/memory-handlers.d.ts +6 -2
  108. package/dist/commands/handlers/memory-handlers.js +35 -15
  109. package/dist/commands/handlers/missing-handlers.d.ts +2 -2
  110. package/dist/commands/handlers/missing-handlers.js +12 -4
  111. package/dist/commands/handlers/resources-handler.d.ts +12 -0
  112. package/dist/commands/handlers/resources-handler.js +52 -0
  113. package/dist/commands/handlers/starter-handlers.d.ts +1 -1
  114. package/dist/commands/handlers/starter-handlers.js +32 -2
  115. package/dist/commands/handlers/switch-handler.d.ts +1 -1
  116. package/dist/commands/handlers/switch-handler.js +15 -0
  117. package/dist/commands/handlers/test-handlers.js +4 -86
  118. package/dist/commands/handlers/ui-handlers.js +11 -5
  119. package/dist/commands/login-chatgpt.d.ts +8 -0
  120. package/dist/commands/login-chatgpt.js +17 -0
  121. package/dist/commands/mcp-import.d.ts +11 -0
  122. package/dist/commands/mcp-import.js +67 -0
  123. package/dist/commands/mcp-invoke.d.ts +2 -0
  124. package/dist/commands/mcp-invoke.js +68 -0
  125. package/dist/commands/mcp.d.ts +13 -0
  126. package/dist/commands/mcp.js +66 -21
  127. package/dist/commands/pipeline.d.ts +7 -1
  128. package/dist/commands/pipeline.js +104 -7
  129. package/dist/commands/resources.d.ts +2 -0
  130. package/dist/commands/resources.js +64 -0
  131. package/dist/commands/skills-cli/index.js +35 -12
  132. package/dist/commands/slash/builtin-commands.js +16 -3
  133. package/dist/commands/slash/index.d.ts +3 -1
  134. package/dist/commands/slash/index.js +2 -0
  135. package/dist/commands/slash/surfaces.d.ts +53 -0
  136. package/dist/commands/slash/surfaces.js +177 -0
  137. package/dist/commands/slash/types.d.ts +17 -0
  138. package/dist/commands/try.d.ts +1 -1
  139. package/dist/commands/try.js +1 -1
  140. package/dist/companion/companion-identity.d.ts +43 -0
  141. package/dist/companion/companion-identity.js +136 -0
  142. package/dist/companion/companion-toolset.d.ts +66 -0
  143. package/dist/companion/companion-toolset.js +368 -0
  144. package/dist/companion/companion-turn.d.ts +10 -2
  145. package/dist/companion/companion-turn.js +38 -1
  146. package/dist/config/code-exec-policy.d.ts +25 -0
  147. package/dist/config/code-exec-policy.js +39 -0
  148. package/dist/config/model-tools.d.ts +9 -0
  149. package/dist/config/model-tools.js +103 -0
  150. package/dist/context/context-manager-v2.js +2 -2
  151. package/dist/context/lm-resizer-compressor.js +3 -2
  152. package/dist/context/lm-resizer-diagnostics.d.ts +9 -0
  153. package/dist/context/lm-resizer-diagnostics.js +30 -0
  154. package/dist/context/tool-output-masking.js +3 -4
  155. package/dist/curator/curator.d.ts +6 -0
  156. package/dist/curator/curator.js +53 -3
  157. package/dist/daemon/cron-agent-bridge.d.ts +6 -0
  158. package/dist/daemon/cron-agent-bridge.js +31 -4
  159. package/dist/doctor/index.d.ts +11 -2
  160. package/dist/doctor/index.js +84 -21
  161. package/dist/doctor/integrations.d.ts +197 -0
  162. package/dist/doctor/integrations.js +241 -0
  163. package/dist/doctor/triage.d.ts +108 -0
  164. package/dist/doctor/triage.js +304 -0
  165. package/dist/errors/crash-handler.js +2 -0
  166. package/dist/fleet/collaboration.d.ts +44 -0
  167. package/dist/fleet/collaboration.js +170 -0
  168. package/dist/fleet/fleet-listener.d.ts +1 -0
  169. package/dist/fleet/fleet-listener.js +87 -46
  170. package/dist/fleet/fleet-registry.d.ts +2 -0
  171. package/dist/fleet/resource-catalog.d.ts +245 -0
  172. package/dist/fleet/resource-catalog.js +211 -0
  173. package/dist/fleet/rooms/room-access.d.ts +138 -0
  174. package/dist/fleet/rooms/room-access.js +196 -0
  175. package/dist/fleet/rooms/room-client.d.ts +158 -0
  176. package/dist/fleet/rooms/room-client.js +685 -0
  177. package/dist/fleet/rooms/room-event.d.ts +139 -0
  178. package/dist/fleet/rooms/room-event.js +330 -0
  179. package/dist/fleet/rooms/room-filter.d.ts +48 -0
  180. package/dist/fleet/rooms/room-filter.js +152 -0
  181. package/dist/fleet/rooms/room-hub.d.ts +154 -0
  182. package/dist/fleet/rooms/room-hub.js +363 -0
  183. package/dist/fleet/rooms/room-identity.d.ts +26 -0
  184. package/dist/fleet/rooms/room-identity.js +82 -0
  185. package/dist/fleet/rooms/room-lock.d.ts +34 -0
  186. package/dist/fleet/rooms/room-lock.js +180 -0
  187. package/dist/fleet/rooms/room-observations.d.ts +7 -0
  188. package/dist/fleet/rooms/room-observations.js +61 -0
  189. package/dist/fleet/rooms/room-server.d.ts +28 -0
  190. package/dist/fleet/rooms/room-server.js +75 -0
  191. package/dist/fleet/rooms/room-store.d.ts +119 -0
  192. package/dist/fleet/rooms/room-store.js +448 -0
  193. package/dist/fleet/rooms/room-ws-bridge.d.ts +27 -0
  194. package/dist/fleet/rooms/room-ws-bridge.js +137 -0
  195. package/dist/fleet/sensory-mission-bridge.d.ts +42 -0
  196. package/dist/fleet/sensory-mission-bridge.js +136 -0
  197. package/dist/git/worktree-sessions.js +1 -0
  198. package/dist/harness/contract.d.ts +4 -4
  199. package/dist/harness/fleet-supervisor.d.ts +16 -0
  200. package/dist/harness/fleet-supervisor.js +64 -0
  201. package/dist/harness/index.d.ts +4 -0
  202. package/dist/harness/index.js +4 -0
  203. package/dist/harness/mission-runner.d.ts +3 -0
  204. package/dist/harness/mission-runner.js +53 -0
  205. package/dist/harness/mission-store.d.ts +93 -0
  206. package/dist/harness/mission-store.js +297 -0
  207. package/dist/harness/tool-harness.d.ts +56 -0
  208. package/dist/harness/tool-harness.js +153 -0
  209. package/dist/hooks/use-enhanced-input.js +48 -4
  210. package/dist/hooks/use-input-handler.d.ts +1 -0
  211. package/dist/hooks/use-input-handler.js +82 -22
  212. package/dist/hooks/use-input-history.js +1 -0
  213. package/dist/identity/lisa-introspection.js +5 -2
  214. package/dist/identity/operational-self-model.d.ts +2 -0
  215. package/dist/identity/operational-self-model.js +4 -0
  216. package/dist/index.js +52 -6
  217. package/dist/mcp/client.d.ts +11 -0
  218. package/dist/mcp/client.js +68 -3
  219. package/dist/mcp/config.d.ts +20 -0
  220. package/dist/mcp/config.js +121 -8
  221. package/dist/mcp/import-normalize.d.ts +12 -0
  222. package/dist/mcp/import-normalize.js +114 -0
  223. package/dist/mcp/mcp-oauth-constants.d.ts +8 -0
  224. package/dist/mcp/mcp-oauth-constants.js +9 -0
  225. package/dist/mcp/mcp-oauth-provider.d.ts +80 -0
  226. package/dist/mcp/mcp-oauth-provider.js +241 -0
  227. package/dist/mcp/mcp-oauth.d.ts +60 -1
  228. package/dist/mcp/mcp-oauth.js +241 -65
  229. package/dist/mcp/transports.d.ts +14 -5
  230. package/dist/mcp/transports.js +112 -101
  231. package/dist/mcp/types.d.ts +5 -0
  232. package/dist/media/comfyui-recipe-contract.d.ts +7 -7
  233. package/dist/memory/facts-memory.d.ts +11 -1
  234. package/dist/memory/facts-memory.js +47 -8
  235. package/dist/memory/memory-candidate-queue.d.ts +2 -2
  236. package/dist/memory/memory-candidate-queue.js +6 -6
  237. package/dist/memory/persistent-memory.d.ts +13 -8
  238. package/dist/memory/persistent-memory.js +77 -30
  239. package/dist/nodes/device-node.js +5 -9
  240. package/dist/observability/mobile-supervision-gateway-contract.js +20 -7
  241. package/dist/observability/run-event-writer.d.ts +21 -0
  242. package/dist/observability/run-event-writer.js +81 -0
  243. package/dist/observability/run-store.d.ts +5 -0
  244. package/dist/observability/run-store.js +18 -13
  245. package/dist/observability/run-trajectory.js +1 -1
  246. package/dist/optimization/prompt-cache.d.ts +19 -2
  247. package/dist/optimization/prompt-cache.js +41 -6
  248. package/dist/orchestration/orchestrator.d.ts +21 -0
  249. package/dist/orchestration/orchestrator.js +122 -15
  250. package/dist/persistence/session-content.d.ts +8 -0
  251. package/dist/persistence/session-content.js +76 -0
  252. package/dist/persistence/session-handoff.d.ts +64 -0
  253. package/dist/persistence/session-handoff.js +80 -0
  254. package/dist/persistence/session-history.d.ts +4 -0
  255. package/dist/persistence/session-history.js +38 -0
  256. package/dist/persistence/session-store.d.ts +9 -0
  257. package/dist/persistence/session-store.js +48 -20
  258. package/dist/personas/persona-manager.js +17 -1
  259. package/dist/plugins/code-explorer/CodeExplorerManager.d.ts +10 -4
  260. package/dist/plugins/code-explorer/CodeExplorerManager.js +69 -16
  261. package/dist/plugins/plugin-manager.js +10 -1
  262. package/dist/prompts/prompt-manager.js +11 -4
  263. package/dist/prompts/system-base.js +6 -2
  264. package/dist/protocols/a2a/codebuddy-executor.d.ts +11 -2
  265. package/dist/protocols/a2a/codebuddy-executor.js +9 -8
  266. package/dist/protocols/a2a/index.d.ts +1 -1
  267. package/dist/protocols/a2a/jsonrpc-v1.d.ts +41 -0
  268. package/dist/protocols/a2a/jsonrpc-v1.js +145 -0
  269. package/dist/protocols/a2a/peer-config.d.ts +20 -0
  270. package/dist/protocols/a2a/peer-config.js +55 -0
  271. package/dist/providers/codex-oauth.js +30 -6
  272. package/dist/providers/model-provider-compat.js +2 -1
  273. package/dist/sandbox/os-sandbox.d.ts +1 -1
  274. package/dist/scheduler/cron-scheduler.d.ts +15 -2
  275. package/dist/scheduler/cron-scheduler.js +35 -4
  276. package/dist/scheduler/job-notepad.d.ts +69 -0
  277. package/dist/scheduler/job-notepad.js +339 -0
  278. package/dist/security/audit-logger.d.ts +1 -1
  279. package/dist/security/compute-confinement.d.ts +4 -0
  280. package/dist/security/compute-confinement.js +89 -0
  281. package/dist/security/session-encryption.d.ts +4 -0
  282. package/dist/security/session-encryption.js +31 -0
  283. package/dist/sensory/voice-loop.d.ts +17 -0
  284. package/dist/sensory/voice-loop.js +72 -15
  285. package/dist/server/auth/device-session-context.d.ts +9 -0
  286. package/dist/server/auth/device-session-context.js +13 -0
  287. package/dist/server/auth/device-store.d.ts +89 -0
  288. package/dist/server/auth/device-store.js +261 -0
  289. package/dist/server/auth/device-token.d.ts +3 -0
  290. package/dist/server/auth/device-token.js +6 -0
  291. package/dist/server/auth/jwt.js +4 -0
  292. package/dist/server/index.d.ts +0 -10
  293. package/dist/server/index.js +28 -0
  294. package/dist/server/middleware/auth.js +3 -2
  295. package/dist/server/routes/a2a-jsonrpc.d.ts +9 -0
  296. package/dist/server/routes/a2a-jsonrpc.js +66 -0
  297. package/dist/server/routes/a2a-protocol.d.ts +12 -0
  298. package/dist/server/routes/a2a-protocol.js +1 -1
  299. package/dist/server/routes/device-auth.d.ts +4 -0
  300. package/dist/server/routes/device-auth.js +40 -0
  301. package/dist/server/types.d.ts +4 -0
  302. package/dist/server/websocket/handler.d.ts +13 -0
  303. package/dist/server/websocket/handler.js +102 -17
  304. package/dist/services/prompt-builder.d.ts +2 -0
  305. package/dist/services/prompt-builder.js +16 -6
  306. package/dist/services/runtime-settings-context.d.ts +81 -0
  307. package/dist/services/runtime-settings-context.js +79 -0
  308. package/dist/skills/executor.js +2 -0
  309. package/dist/skills/hub.js +16 -14
  310. package/dist/skills/local-inventory.d.ts +21 -0
  311. package/dist/skills/local-inventory.js +72 -0
  312. package/dist/skills/skill-loader.js +2 -2
  313. package/dist/skills/skill-usage-store.d.ts +49 -0
  314. package/dist/skills/skill-usage-store.js +121 -0
  315. package/dist/testing/ai-integration-tests.js +8 -5
  316. package/dist/themes/theme-manager.d.ts +12 -0
  317. package/dist/themes/theme-manager.js +29 -0
  318. package/dist/themes/theme-schema.d.ts +24 -24
  319. package/dist/tools/a2a-call-tool.d.ts +34 -0
  320. package/dist/tools/a2a-call-tool.js +75 -0
  321. package/dist/tools/bash/streaming-executor.d.ts +1 -0
  322. package/dist/tools/bash/streaming-executor.js +78 -90
  323. package/dist/tools/code-exec-preflight-runner.d.ts +41 -0
  324. package/dist/tools/code-exec-preflight-runner.js +254 -0
  325. package/dist/tools/code-exec-preflight.d.ts +44 -0
  326. package/dist/tools/code-exec-preflight.js +501 -0
  327. package/dist/tools/code-exec-tool.d.ts +48 -1
  328. package/dist/tools/code-exec-tool.js +191 -47
  329. package/dist/tools/comment-watcher.js +29 -12
  330. package/dist/tools/core-code-inspection.d.ts +56 -0
  331. package/dist/tools/core-code-inspection.js +86 -0
  332. package/dist/tools/create-skill-tool.d.ts +2 -3
  333. package/dist/tools/create-skill-tool.js +16 -75
  334. package/dist/tools/cronjob-tool.d.ts +1 -0
  335. package/dist/tools/cronjob-tool.js +1 -0
  336. package/dist/tools/env-doctor-tool.d.ts +2 -0
  337. package/dist/tools/env-doctor-tool.js +4 -3
  338. package/dist/tools/execute-code-rpc-invoker.d.ts +1 -1
  339. package/dist/tools/execute-code-rpc-invoker.js +35 -19
  340. package/dist/tools/execute-code-runner.d.ts +2 -0
  341. package/dist/tools/execute-code-runner.js +52 -17
  342. package/dist/tools/fleet-room-tool.d.ts +104 -0
  343. package/dist/tools/fleet-room-tool.js +124 -0
  344. package/dist/tools/integration-tool-hints.d.ts +4 -0
  345. package/dist/tools/integration-tool-hints.js +19 -0
  346. package/dist/tools/list-peers-tool.d.ts +3 -0
  347. package/dist/tools/list-peers-tool.js +11 -4
  348. package/dist/tools/media-generation-tool.d.ts +16 -1
  349. package/dist/tools/media-generation-tool.js +341 -9
  350. package/dist/tools/merge-conflict-tool.js +53 -25
  351. package/dist/tools/metadata.d.ts +1 -5
  352. package/dist/tools/metadata.js +30 -28
  353. package/dist/tools/peer-tool-invoke-tool.d.ts +61 -0
  354. package/dist/tools/peer-tool-invoke-tool.js +396 -0
  355. package/dist/tools/ragchat-tool.d.ts +39 -0
  356. package/dist/tools/ragchat-tool.js +105 -0
  357. package/dist/tools/registry/fleet-tools.d.ts +21 -3
  358. package/dist/tools/registry/fleet-tools.js +137 -4
  359. package/dist/tools/registry/index.d.ts +1 -1
  360. package/dist/tools/registry/index.js +2 -2
  361. package/dist/tools/registry/knowledge-tools.d.ts +2 -2
  362. package/dist/tools/registry/knowledge-tools.js +2 -2
  363. package/dist/tools/registry/lessons-tools.d.ts +7 -0
  364. package/dist/tools/registry/lessons-tools.js +43 -3
  365. package/dist/tools/registry/memory-tools.d.ts +1 -1
  366. package/dist/tools/registry/memory-tools.js +8 -8
  367. package/dist/tools/registry/research-tools.d.ts +1 -0
  368. package/dist/tools/registry/research-tools.js +4 -13
  369. package/dist/tools/registry/self-describe-tools.d.ts +1 -1
  370. package/dist/tools/registry/self-describe-tools.js +43 -30
  371. package/dist/tools/resource-catalog-tool.d.ts +38 -0
  372. package/dist/tools/resource-catalog-tool.js +46 -0
  373. package/dist/tools/skills-inspection-tool.js +30 -1
  374. package/dist/tools/stream-tool-output.d.ts +3 -0
  375. package/dist/tools/stream-tool-output.js +33 -0
  376. package/dist/tools/tool-call-scheduler.d.ts +10 -0
  377. package/dist/tools/tool-call-scheduler.js +58 -0
  378. package/dist/tools/tool-effect.d.ts +5 -0
  379. package/dist/tools/tool-effect.js +26 -0
  380. package/dist/tools/tool-search.d.ts +12 -11
  381. package/dist/tools/tool-search.js +67 -26
  382. package/dist/tools/types.d.ts +6 -0
  383. package/dist/ui/components/ChatHistory.d.ts +1 -1
  384. package/dist/ui/components/ChatHistory.js +2 -2
  385. package/dist/ui/components/ChatInput.d.ts +2 -1
  386. package/dist/ui/components/ChatInput.js +42 -88
  387. package/dist/ui/components/ChatInterface.d.ts +4 -2
  388. package/dist/ui/components/ChatInterface.js +27 -63
  389. package/dist/ui/components/CommandSuggestions.d.ts +0 -1
  390. package/dist/ui/components/CommandSuggestions.js +4 -6
  391. package/dist/ui/components/FileAutocomplete.js +1 -1
  392. package/dist/ui/components/KeyboardHelp.js +8 -6
  393. package/dist/ui/components/ModelSelection.js +6 -5
  394. package/dist/ui/components/StatusBar.d.ts +2 -1
  395. package/dist/ui/components/StatusBar.js +8 -7
  396. package/dist/ui/context/theme-context.js +3 -2
  397. package/dist/ui/index.d.ts +1 -1
  398. package/dist/ui/index.js +1 -1
  399. package/dist/ui/utils/markdown-renderer.js +4 -13
  400. package/dist/utils/atomic-write.d.ts +22 -0
  401. package/dist/utils/atomic-write.js +29 -0
  402. package/dist/utils/bounded-output.d.ts +16 -0
  403. package/dist/utils/bounded-output.js +63 -0
  404. package/dist/utils/config-validation/schema.d.ts +2 -2
  405. package/dist/utils/device-store-file.d.ts +4 -0
  406. package/dist/utils/device-store-file.js +40 -0
  407. package/dist/utils/export-manager.d.ts +9 -0
  408. package/dist/utils/export-manager.js +19 -0
  409. package/dist/utils/first-use-hints.d.ts +25 -0
  410. package/dist/utils/first-use-hints.js +58 -0
  411. package/dist/utils/graceful-shutdown.d.ts +8 -0
  412. package/dist/utils/graceful-shutdown.js +23 -7
  413. package/dist/utils/history-manager.js +1 -1
  414. package/dist/utils/update-notifier.js +16 -18
  415. package/dist/wizard/environment-detection.d.ts +5 -1
  416. package/dist/wizard/environment-detection.js +49 -7
  417. package/dist/wizard/onboarding.d.ts +5 -1
  418. package/dist/wizard/onboarding.js +90 -30
  419. package/dist/wizard/provider-onboarding.d.ts +2 -0
  420. package/dist/wizard/provider-onboarding.js +55 -17
  421. package/package.json +7 -3
package/README.fr.md ADDED
@@ -0,0 +1,56 @@
1
+ # Code Buddy 2.1 — mémoire, apprentissage et coopération
2
+
3
+ Code Buddy peut conserver des informations utiles, proposer des leçons, réutiliser des skills et évaluer des variantes de code. Ces mécanismes agissent sur le contexte et les artefacts du système ; ils ne réentraînent pas les poids du modèle.
4
+
5
+ Pour l’installation et les autres usages, consulter le [README principal](README.md). Cette présentation thématique en français, qui n’est pas une traduction intégrale du README principal, accompagne le [guide technique et ses preuves de source](docs/learning-mechanisms.md).
6
+
7
+ ## Nouveautés 2.1
8
+
9
+ La version 2.2 ajoute la connexion OAuth à ElevenLabs hébergé via MCP, fiabilise les commandes en script (interruption headless en code 130, `mcp add-json --yes`) et affiche le thème effectif dans `/status` ([notes 2.2.0](docs/RELEASE-NOTES-2.2.0.md)). La version 2.1 ajoutait un catalogue explicite de ressources, la recherche RagChat avec citations de pages, l’import de configurations MCP et un pont A2A JSON-RPC limité aux échanges texte documentés. Elle corrige aussi des problèmes de sessions terminal, de mémoire par fournisseur, de diagnostic de configuration et d’interface Cowork. Les [notes de version](docs/RELEASE-NOTES-2.1.0.md) détaillent les limites : pas de reprise automatique des tâches après panne, pas de compatibilité universelle ni de garantie de qualité OCR.
10
+
11
+ ```sh
12
+ npm install -g @phuetz/code-buddy@2.2.0
13
+ buddy --version
14
+ buddy doctor --offline
15
+ ```
16
+
17
+ La CI impose Linux, macOS et Windows avec Node.js 20 et 22. Cowork reste une installation distincte du paquet npm CLI.
18
+
19
+ ## Ce qui reste d’une session à l’autre
20
+
21
+ La mémoire de projet se trouve notamment dans `.codebuddy/CODEBUDDY_MEMORY.md`, la mémoire utilisateur dans `~/.codebuddy/memory.md`. Leur contenu peut rejoindre le prompt dans les limites et selon la portée du contexte actif. Les leçons constituent une autre couche : une session substantielle peut proposer des candidatures, à examiner avant qu’elles deviennent des leçons actives.
22
+
23
+ ```bash
24
+ buddy lessons candidate list
25
+ buddy lessons list
26
+ buddy lessons search "profil"
27
+ buddy lessons context
28
+ ```
29
+
30
+ Exemple d’usage : conserver une convention de tests du dépôt, puis proposer une leçon après un diagnostic utilisant le mauvais profil. Le rapprochement avec [Manus](https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus) concerne le contexte externalisé et les observations d’erreurs, pas une copie de son système interne.
31
+
32
+ ## Des procédures réutilisables et contrôlables
33
+
34
+ Les skills décrivent comment mener une tâche. Le système sait proposer des skills authored et consolider des procédures qui se recouvrent. Il conserve les skills épinglés et refuse les pertes de couverture détectées. Ces contrôles textuels doivent être complétés par une utilisation réelle de la procédure.
35
+
36
+ `buddy improve skills-list` inspecte les procédures authored. `buddy improve skills-consolidate` prévisualise une consolidation et peut appeler un modèle. Son option `--apply` demande explicitement l’installation et l’archivage ; son contrat diffère de celui des commandes génératives voisines.
37
+
38
+ ## Améliorer les artefacts, puis évaluer les variantes de code
39
+
40
+ `CODEBUDDY_SELF_IMPROVE=true` conserve le mode proposition. La valeur `auto-apply`, ou l’autorisation explicite prévue par la commande concernée, permet de garder les changements validés. La voie `improve` portant sur la couche apprise et la voie `evolve` portant sur le code doivent être distinguées.
41
+
42
+ `buddy evolve list` et `buddy evolve review IDENTIFIANT` permettent d’examiner des variantes. Le moteur travaille dans des worktrees et ne fusionne pas automatiquement. Sa référence [DGM de Sakana](https://sakana.ai/dgm/) exprime une inspiration de méthode ; les performances publiées par Sakana ne sont pas des résultats de Code Buddy. Un score hors ligne reste limité au benchmark utilisé.
43
+
44
+ ## Coopérer et explorer plusieurs pistes
45
+
46
+ Le Council peut répartir des rôles complémentaires, évaluer les réponses et les synthétiser. [Fugu, développé par Sakana AI](https://sakana.ai/fugu-release/) ; son modèle d’orchestration entraîné se distingue du conducteur déterministe actuellement présent dans Code Buddy.
47
+
48
+ Le moteur de raisonnement propose ToT/MCTS avec des budgets de recherche. `/think status` permet d’inspecter le réglage. Une consigne de raisonnement injectée par un middleware ne prouve pas qu’un arbre de recherche a été exécuté. Les références [ToT](https://arxiv.org/abs/2305.10601), [RethinkMCTS](https://arxiv.org/abs/2409.09584) et [MCTSr](https://arxiv.org/abs/2406.07394) sont explicitées dans le guide ; aucune équivalence de benchmark n’est annoncée.
49
+
50
+ Une recette de flotte a déjà relié deux hôtes : revue du Buddy Windows par RPC, correction du Buddy Linux, puis oracle indépendant réussi sur les deux systèmes (5/5 chacun). Le relais était assuré manuellement par le pilote. [Déroulement vérifié](docs/reports/2026-09/fleet-two-hosts-learning-example.md).
51
+
52
+ Le gain se vérifie sur une tâche concrète : référence avant changement, actions capturées, résultat, coût et régressions. La présence du code, son activation et son bénéfice observé sont trois constats différents.
53
+
54
+ ## Portée des preuves
55
+
56
+ Le guide d’apprentissage a initialement été relu sur le candidat `01fc0dbd3` le 14 septembre 2026. Ce contrôle historique ne constitue pas la validation de la version 2.1.0 ; consulter les [notes de version](docs/RELEASE-NOTES-2.1.0.md) et les contrôles du commit publié pour identifier cette livraison.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
 
3
- # Code Buddy 2
3
+ # Code Buddy 2.1
4
4
 
5
5
  **A local-first AI coding agent that can also run as a fleet, a desktop app, and a companion.**
6
6
  It reads your repository, writes code, runs commands, and you can watch it work — on your machine,
@@ -12,7 +12,8 @@ at $0 with [Ollama](https://ollama.com) or a ChatGPT subscription.
12
12
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-BSL_1.1-feca57.svg?style=flat-square" alt="License: Business Source License 1.1"/></a>
13
13
  </p>
14
14
 
15
- [What 2.0 is](#what-20-is) ·
15
+ [Français](README.fr.md) ·
16
+ [What Code Buddy is](#what-code-buddy-is) ·
16
17
  [Install](#install) ·
17
18
  [First run](#first-run) ·
18
19
  [Opt-in](#opt-in) ·
@@ -26,16 +27,34 @@ at $0 with [Ollama](https://ollama.com) or a ChatGPT subscription.
26
27
  <sub>A local model reasons on screen, then uses a tool to create a real file. No cloud API bill.</sub>
27
28
  </p>
28
29
 
30
+ <p>
31
+ <a href="docs/assets/infographic-code-buddy-2.webp"><img src="docs/assets/infographic-code-buddy-2.webp" width="900" alt="Code Buddy 2 architecture: you, multi-channel interfaces (terminal, Cowork, PWA, chat, voice, App Studio), the agentic runtime (council, fleet, memory, shadow workspace, evolve, knowledge graph), 220+ tools, 64 providers, and the autonomous engineering loop"/></a>
32
+ <br/>
33
+ <sub>The big picture: interfaces, the agentic runtime, tools and providers, and the loop that turns an idea into an improvement.</sub>
34
+ </p>
35
+
29
36
  </div>
30
37
 
31
38
  ---
32
39
 
33
- ## What 2.0 is
40
+ ## What Code Buddy is
41
+
42
+ ### One minute with Lisa · French presentation
43
+
44
+ [![Lisa introduces Code Buddy and its installation command](assets/site/lisa/presentation.jpg)](https://youtu.be/2XgFHxBeI8Q)
45
+
46
+ [Watch on YouTube](https://youtu.be/2XgFHxBeI8Q) · [MP4 alternative](https://www.agile-up.com/code-buddy/lisa/presentation.mp4) · [French subtitles](assets/site/lisa/presentation.fr.srt)
34
47
 
35
- 1.x was a terminal coding agent: 64 providers behind one router cloud, gateway and local
36
- runtimes — and 220+ tools selected per query. 2.0 keeps all of that unchanged and adds five
37
- surfaces around it. Every one of them is **opt-in**: with its environment variable unset, behavior
38
- is the same as 1.8.0. There is no `BREAKING CHANGE` in the 2.0 range.
48
+ Lisa introduces the multi-AI hub, installation and optional perception components. Edited on September 13, 2026 from an existing September 10 master, with a synthetic voice and portrait, illustrative footage and French captions. Illustrations are not execution evidence. Voice and robotics require additional components beyond the npm package.
49
+
50
+ Code Buddy combines a terminal coding agent with cloud, gateway and local model routing,
51
+ query-selected tools, and the following interfaces. Optional services require their documented
52
+ configuration; enabling a feature does not replace its permission checks.
53
+
54
+ **New in 2.1:** explicit resource discovery and selection, RagChat search with page citations,
55
+ MCP configuration import, a bounded A2A JSON-RPC bridge, and fixes for terminal sessions,
56
+ configuration diagnostics and Cowork workflows. Read the [release notes](docs/RELEASE-NOTES-2.2.0.md)
57
+ for setup and the limits of each integration.
39
58
 
40
59
  - **A multi-AI fleet hub.** Peers running `buddy server` observe each other's events and call each
41
60
  other's models: one-shot `peer.chat`, multi-turn `peer.chat-session.*`, and `peer.tool.invoke`
@@ -101,6 +120,24 @@ The **Cowork** desktop app is a separate step needing Node.js ≥ 22: `buddy ins
101
120
 
102
121
  ---
103
122
 
123
+ ## Use it from Claude Code (plugin, one command)
124
+
125
+ This repository is also a Claude Code plugin marketplace. It installs a skill
126
+ that teaches Claude Code how to drive `buddy` correctly (headless one-shot,
127
+ provider and model pinning, permission modes, the verify loop) and a read-only
128
+ MCP server exposing Code Buddy's tools:
129
+
130
+ ```bash
131
+ npm i -g @phuetz/code-buddy
132
+ claude plugin marketplace add phuetz/code-buddy
133
+ claude plugin install code-buddy@code-buddy
134
+ # optional, same marketplace: the context filter
135
+ claude plugin install lm-resizer@code-buddy
136
+ ```
137
+
138
+ Codex users: `cp -r .codex/skills/code-buddy ~/.codex/skills/`. Remove with
139
+ `claude plugin uninstall code-buddy@code-buddy`.
140
+
104
141
  ## First run
105
142
 
106
143
  A real task, start to finish. `buddy loop` plans, edits, runs your verification command, and stops
@@ -136,6 +173,14 @@ names it.
136
173
 
137
174
  ---
138
175
 
176
+ ## Memory and learning
177
+
178
+ Code Buddy keeps project/user memory, retrieves relevant lessons and can propose review-gated lesson candidates after substantial sessions. Authored skills can be inspected, improved and consolidated; code evolution evaluates variants in isolated worktrees. These change external state and inference-time behavior, not model weights.
179
+
180
+ Start with `buddy lessons candidate list`, `buddy lessons list`, `buddy improve status` and `buddy evolve list`. Council's role-based cooperation and the ToT/MCTS engine are separate mechanisms with their own execution paths and budgets. Inspiration from Manus, Sakana DGM/ShinkaEvolve/Fugu and reasoning papers is not a reproduction claim or a measured productivity gain.
181
+
182
+ Read [activation conditions, source evidence and limitations](docs/learning-mechanisms.md), or the [French overview](README.fr.md). A [two-host fleet recipe](docs/reports/2026-09/fleet-two-hosts-learning-example.md) has combined a Windows RPC review, a Linux code correction and an independent five-case oracle passing on both hosts. The pilot explicitly relayed messages and files; this was not a Council run.
183
+
139
184
  ## Opt-in
140
185
 
141
186
  Nothing below is needed to chat with a local model. Defaults stay off.
@@ -144,7 +189,7 @@ Nothing below is needed to chat with a local model. Defaults stay off.
144
189
  | --- | --- |
145
190
  | `CODEBUDDY_PROVIDER=ollama` | Force the local Ollama path (no API key). |
146
191
  | `CODEBUDDY_MAX_CONTEXT` | Override the context window for every consumer, including the Ollama server itself. |
147
- | `CODEBUDDY_SELF_IMPROVE=true` | Let the agent author its own tools and skills behind empirical gates. It never edits `src/`. |
192
+ | `CODEBUDDY_SELF_IMPROVE=true` | Enable the learned-layer proposal path. `true` stays propose-only; keeping validated changes needs explicit application authorization. The separate `buddy evolve` path can edit code in isolated worktrees. See [contracts](docs/learning-mechanisms.md). |
148
193
  | `CODEBUDDY_SHADOW_WORKSPACE` | Validate proposed writes in a ghost worktree *before* touching your files. |
149
194
  | `CODEBUDDY_TIMELINE` | Per-turn timeline; `buddy replay` inspects, restores or forks a session. |
150
195
  | `CODEBUDDY_INTENTS` | Falsifiable versioned specs, so "done" stays re-provable later. |
@@ -172,13 +217,12 @@ their own gates, listed in [`docs/cb2/README.md`](docs/cb2/README.md) and
172
217
 
173
218
  Honest limits for a first-time visitor:
174
219
 
175
- - **The npm release can lag this tree.** Check `buddy --version` after installing; the source
176
- checkout above is what this page describes.
177
- - **Only the Linux CI legs are blocking.** macOS and Windows run best-effort their results are
178
- visible but do not gate a green build. Interactive-shell execution on macOS is a known open
179
- issue.
180
- - **The test toolchain needs Node ≥ 20** even though the shipped CLI declares `>= 18`. That
181
- affects contributors, not users.
220
+ - **The npm release can lag this tree.** Releases use GitHub Actions trusted publication.
221
+ Check `buddy --version`, the npm dist-tag and the corresponding Git tag when identifying a build.
222
+ - **CI gates all three operating systems.** Linux, macOS and Windows run Node.js 20 and 22
223
+ jobs. A local pass or an earlier platform recipe does not replace the candidate’s CI results.
224
+ - **Node ≥ 20 is the real floor**, for the CLI and for the test toolchain alike (`engines` says
225
+ so since 2.0.0).
182
226
  - **Cowork** is a separate install (Node.js ≥ 22, `buddy install-gui`), not part of the three
183
227
  commands above.
184
228
  - **Film production** needs `ffmpeg`; without a local voice binary, scenes stay silent rather than
@@ -194,6 +238,18 @@ Honest limits for a first-time visitor:
194
238
 
195
239
  ---
196
240
 
241
+ ## Test suite
242
+
243
+ 38 088 tests in 2 115 files at `788f0ef23` (measured 2026-09-10 with `npm test`; 26 failures on that run were environment-only: a running local server, `dist/` not built, 20 s timeouts under load). `npm test -- tests/path/to/file.test.ts` to run a slice.
244
+
245
+ ## Part of a toolchain
246
+
247
+ <p align="center">
248
+ <a href="docs/assets/infographic-ai-engineering-stack.webp"><img src="docs/assets/infographic-ai-engineering-stack.webp" width="900" alt="The AI engineering stack: Code Explorer understands the repository, lm-resizer protects the context budget, Code Buddy 2 acts with AI agents"/></a>
249
+ </p>
250
+
251
+ Code Buddy is the agent. Two sibling tools carry the context work around it: [lm-resizer](https://github.com/phuetz/lm-resizer) filters noisy command output before it reaches the model (Rust, Apache-2.0, `npm i @phuetz/lm-resizer`), and Code Explorer pre-indexes a repository into a queryable knowledge graph served over MCP (available as a service on private codebases — [agile-up.com](https://agile-up.com)). Understand, compress, act.
252
+
197
253
  ## License
198
254
 
199
255
  Business Source License 1.1 — see [LICENSE](LICENSE). Self-host and personal / non-commercial use
@@ -205,7 +261,9 @@ to Apache 2.0 on 2030-08-31. Bundled Python skills stay MIT (see their `SKILL.md
205
261
  ## Documentation
206
262
 
207
263
  - **[Getting started](docs/getting-started.md)** — first run, headless mode, sessions.
208
- - **[Release notes 2.0.0](docs/RELEASE-NOTES-2.0.0.md)** — what changed since 1.8.0.
264
+ - **[Release notes 2.2.0](docs/RELEASE-NOTES-2.2.0.md)** — current changes and validation limits.
265
+ - **[Release notes 2.1.0](docs/RELEASE-NOTES-2.1.0.md)** — previous release.
266
+ - [Release notes 2.0.0](docs/RELEASE-NOTES-2.0.0.md) — previous major release.
209
267
  - [Install](docs/install.md) — published npm, Docker/VPS, the one-command installer.
210
268
  - [Commands](docs/commands.md) · [Features](docs/features.md) · [Security](docs/security.md)
211
269
  - [Cowork Desktop](docs/cowork.md) · [Fleet](docs/fleet-guide.md) · [Code Buddy 2 features](docs/cb2/README.md)
@@ -2,17 +2,17 @@
2
2
  "schemaVersion": 2,
3
3
  "corePackage": {
4
4
  "name": "@phuetz/code-buddy",
5
- "version": "2.0.0",
6
- "description": "Open-source AI coding agent for the terminal, desktop, and HTTP. 64 LLM providers (Claude, GPT, Grok, Gemini, Ollama, LM Studio, NVIDIA NIM, …), 30 of them free-tier or local $0, with automatic failover. 220+ tools selected per query, a peer-to-peer fleet, opt-in self-improvement, multi-channel messaging, and a skills system."
5
+ "version": "2.2.0",
6
+ "description": "AI coding agent with terminal and HTTP interfaces, optional Cowork desktop integration, multi-provider routing, tools, fleet collaboration and inspectable memory. See release notes for supported integrations and limits."
7
7
  },
8
- "sourceRevision": "92c913a97b1b9d7a03ab266de5615a472a2ac899",
8
+ "sourceRevision": "b5c50c189f69794ef73cbea1ef3b3a86c00b2b9f",
9
9
  "sourceDirty": null,
10
10
  "sourceRevisionOrigin": "env:GITHUB_SHA",
11
11
  "distDigest": {
12
12
  "algorithm": "sha256",
13
13
  "scope": "dist-tree-code-without-maps-v1",
14
- "value": "c015f4b49e66354adecbb87b4a31c7aa4ca7691344a281ea5eb3288e8a9e7519",
15
- "fileCount": 5041
14
+ "value": "4c4f5752b460b3976153f23c1bbf6127f59897c27b3b4fbb4f17136332d6cae3",
15
+ "fileCount": 5197
16
16
  },
17
17
  "runtime": {
18
18
  "kind": "codebuddy-core",
@@ -59,6 +59,8 @@ export declare class CodeBuddyAgent extends BaseAgent {
59
59
  private _budgetAlertListener?;
60
60
  /** Nested host gates currently holding assistant text in a private draft state. */
61
61
  private transcriptSnapshotSuspensions;
62
+ /** Serializes interactive session writes (one per completed TUI turn). */
63
+ private interactivePersistence;
62
64
  /**
63
65
  * Create a new CodeBuddyAgent instance
64
66
  *
@@ -84,11 +86,16 @@ export declare class CodeBuddyAgent extends BaseAgent {
84
86
  * Called by dev workflows to associate tool calls with a RunStore run.
85
87
  */
86
88
  setRunId(runId: string | undefined): void;
89
+ private memoryBotId;
87
90
  /**
88
91
  * Multi-bot channels: scope this agent's per-bot state (persistent memory,
89
92
  * lessons) to a bot id. Tool-execution contexts get tagged with it so
90
93
  * `remember`/`lessons` write under `~/.codebuddy/bots/<botId>/`.
91
94
  */
95
+ getMemoryScope(): {
96
+ cwd: string;
97
+ botId?: string;
98
+ };
92
99
  setChannelBotId(botId: string | undefined): void;
93
100
  /** Scope raw tool-result recovery to an embedding host's conversation. */
94
101
  setRecoverySessionId(sessionId: string | undefined): void;
@@ -196,6 +203,17 @@ export declare class CodeBuddyAgent extends BaseAgent {
196
203
  */
197
204
  getSessionCostExtended(): ExtendedCostInfo;
198
205
  saveCurrentSession(): Promise<void> | void;
206
+ /**
207
+ * Persist the interactive (TUI) conversation after a completed turn.
208
+ *
209
+ * The headless path creates its session up front and saves once; the TUI
210
+ * used to do neither, so interactive turns never reached the session file
211
+ * and `--resume` had nothing to continue. The first turn with a user message
212
+ * creates the session (named from that message); every later turn rewrites
213
+ * the session from the agent's chat history, which is idempotent: no turn is
214
+ * appended twice. Calls are serialized; `--ephemeral` stores nothing.
215
+ */
216
+ persistInteractiveSession(): Promise<void>;
199
217
  getCurrentSessionId(): string | null;
200
218
  getClient(): CodeBuddyClient;
201
219
  setModel(model: string): void;
@@ -22,9 +22,11 @@ import { MessageQueue } from "./message-queue.js";
22
22
  import { CostPredictor } from "../analytics/cost-predictor.js";
23
23
  import { BudgetAlertManager } from "../analytics/budget-alerts.js";
24
24
  import { initializeMemory, getMemoryManager } from "../memory/persistent-memory.js";
25
+ import { restoreSessionHistory } from '../persistence/session-history.js';
25
26
  import { getUserHooksManager } from "../hooks/user-hooks.js";
26
27
  import { isFeatureEnabled } from "../config/feature-flags.js";
27
28
  import { getActiveRunStore } from "../observability/run-store.js";
29
+ import { recordSkillActivity } from "../skills/skill-usage-store.js";
28
30
  import { resetIdentityManager } from "../identity/identity-manager.js";
29
31
  import { resetHotReloadManager } from "../config/hot-reload/index.js";
30
32
  import { resetConfigWatcher } from "../config/hot-reload/watcher.js";
@@ -85,6 +87,8 @@ export class CodeBuddyAgent extends BaseAgent {
85
87
  _budgetAlertListener;
86
88
  /** Nested host gates currently holding assistant text in a private draft state. */
87
89
  transcriptSnapshotSuspensions = 0;
90
+ /** Serializes interactive session writes (one per completed TUI turn). */
91
+ interactivePersistence = Promise.resolve();
88
92
  /**
89
93
  * Create a new CodeBuddyAgent instance
90
94
  *
@@ -158,7 +162,7 @@ export class CodeBuddyAgent extends BaseAgent {
158
162
  this.marketplace = this.infrastructure.marketplace;
159
163
  this.repairCoordinator = this.infrastructure.repairCoordinator;
160
164
  // Initialize Persistent Memory (CLAUDE.md style)
161
- initializeMemory().catch(err => {
165
+ initializeMemory(undefined, initialWorkingDirectory).catch(err => {
162
166
  logger.error('Failed to initialize persistent memory', { error: String(err) });
163
167
  });
164
168
  // Initialize cost prediction and budget alerts
@@ -451,7 +455,7 @@ export class CodeBuddyAgent extends BaseAgent {
451
455
  memoryEnabled: this.memoryEnabled,
452
456
  morphEditorEnabled: !!this.toolHandler.morphEditor,
453
457
  cwd: initialWorkingDirectory,
454
- }, this.promptCacheManager, this.memory, this.infrastructure.moltbotHooksManager, getMemoryManager());
458
+ }, this.promptCacheManager, this.memory, this.infrastructure.moltbotHooksManager, getMemoryManager(undefined, undefined, initialWorkingDirectory));
455
459
  // Set up executors for the repair coordinator
456
460
  this.repairCoordinator.setExecutors({
457
461
  commandExecutor: async (cmd) => {
@@ -596,13 +600,19 @@ Look at the screenshot and find the element matching the user's intent. Output o
596
600
  setRunId(runId) {
597
601
  this.toolHandler.setRunId(runId);
598
602
  }
603
+ memoryBotId;
599
604
  /**
600
605
  * Multi-bot channels: scope this agent's per-bot state (persistent memory,
601
606
  * lessons) to a bot id. Tool-execution contexts get tagged with it so
602
607
  * `remember`/`lessons` write under `~/.codebuddy/bots/<botId>/`.
603
608
  */
609
+ getMemoryScope() {
610
+ return { cwd: this.toolHandler.getWorkingDirectory(), botId: this.memoryBotId };
611
+ }
604
612
  setChannelBotId(botId) {
613
+ this.memoryBotId = botId;
605
614
  this.toolHandler.setBotId(botId);
615
+ this.promptBuilder.setPersistentMemory(getMemoryManager(undefined, botId, this.toolHandler.getWorkingDirectory()));
606
616
  }
607
617
  /** Scope raw tool-result recovery to an embedding host's conversation. */
608
618
  setRecoverySessionId(sessionId) {
@@ -1152,6 +1162,7 @@ Look at the screenshot and find the element matching the user's intent. Output o
1152
1162
  catch {
1153
1163
  // Skill usage telemetry is best-effort and must not block a turn.
1154
1164
  }
1165
+ recordSkillActivity(unifiedSkill.name, 'use', { source: 'match' });
1155
1166
  }
1156
1167
  }
1157
1168
  else {
@@ -1380,6 +1391,7 @@ Look at the screenshot and find the element matching the user's intent. Output o
1380
1391
  this.contextManager.importConversationState(cloned.contextManagerState);
1381
1392
  this.toolHandler.restoreWorkingDirectory(cloned.workingDirectory);
1382
1393
  this.promptBuilder.updateConfig({ cwd: cloned.workingDirectory });
1394
+ this.promptBuilder.setPersistentMemory(getMemoryManager(undefined, this.memoryBotId, cloned.workingDirectory));
1383
1395
  }
1384
1396
  getCurrentDirectory() {
1385
1397
  return this.toolHandler.bash.getCurrentDirectory();
@@ -1394,16 +1406,12 @@ Look at the screenshot and find the element matching the user's intent. Output o
1394
1406
  setWorkingDirectory(dir) {
1395
1407
  this.toolHandler.setWorkingDirectory(dir);
1396
1408
  this.promptBuilder.updateConfig({ cwd: dir || process.cwd() });
1409
+ this.promptBuilder.setPersistentMemory(getMemoryManager(undefined, this.memoryBotId, dir));
1397
1410
  }
1398
1411
  /** Rehydrate chat and LLM history from a persisted session (headless --resume). */
1399
1412
  hydratePersistedSession(session) {
1400
1413
  const entries = this.sessionStore.convertMessagesToChatEntries(session.messages);
1401
- const llmMessages = [];
1402
- for (const entry of entries) {
1403
- if (entry.type === 'user' || entry.type === 'assistant') {
1404
- llmMessages.push({ role: entry.type, content: entry.content });
1405
- }
1406
- }
1414
+ const llmMessages = restoreSessionHistory(entries);
1407
1415
  this.historyManager.setChatHistory(entries);
1408
1416
  this.historyManager.setMessages(llmMessages);
1409
1417
  if (session.workingDirectory) {
@@ -1508,6 +1516,35 @@ Look at the screenshot and find the element matching the user's intent. Output o
1508
1516
  turns,
1509
1517
  });
1510
1518
  }
1519
+ /**
1520
+ * Persist the interactive (TUI) conversation after a completed turn.
1521
+ *
1522
+ * The headless path creates its session up front and saves once; the TUI
1523
+ * used to do neither, so interactive turns never reached the session file
1524
+ * and `--resume` had nothing to continue. The first turn with a user message
1525
+ * creates the session (named from that message); every later turn rewrites
1526
+ * the session from the agent's chat history, which is idempotent: no turn is
1527
+ * appended twice. Calls are serialized; `--ephemeral` stores nothing.
1528
+ */
1529
+ persistInteractiveSession() {
1530
+ this.interactivePersistence = this.interactivePersistence.then(async () => {
1531
+ const store = this.sessionStore;
1532
+ if (store.isEphemeral())
1533
+ return;
1534
+ const history = this.historyManager.getChatHistory();
1535
+ const firstUser = history.find((entry) => entry.type === 'user');
1536
+ if (!firstUser)
1537
+ return;
1538
+ if (!store.getCurrentSessionId()) {
1539
+ const { generateConversationTitle } = await import('../utils/conversation-title.js');
1540
+ await store.createSession(generateConversationTitle(firstUser.content), this.getCurrentModel());
1541
+ }
1542
+ await this.saveCurrentSession();
1543
+ }).catch((error) => {
1544
+ logger.warn('[session] interactive turn not persisted', { error: error instanceof Error ? error.message : String(error) });
1545
+ });
1546
+ return this.interactivePersistence;
1547
+ }
1511
1548
  getCurrentSessionId() {
1512
1549
  return this.sessionStore.getCurrentSessionId();
1513
1550
  }
@@ -1,12 +1,3 @@
1
- /**
2
- * Agent Executor Module
3
- *
4
- * Implements the core agentic loop for processing user messages,
5
- * both sequential and streaming. Handles tool execution rounds,
6
- * token counting, cost tracking, and context management.
7
- *
8
- * @module agent/execution
9
- */
10
1
  import { CodeBuddyClient, CodeBuddyMessage } from "../../codebuddy/client.js";
11
2
  import { ChatEntry, StreamingChunk } from "../types.js";
12
3
  import { ToolHandler } from "../tool-handler.js";