byterover-cli 0.2.1 → 0.3.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 (490) hide show
  1. package/README.md +56 -56
  2. package/bin/dev.js +1 -1
  3. package/dist/commands/cipher-agent/run.d.ts +111 -0
  4. package/dist/commands/cipher-agent/run.js +493 -0
  5. package/dist/commands/cipher-agent/set-prompt.d.ts +14 -0
  6. package/dist/commands/cipher-agent/set-prompt.js +53 -0
  7. package/dist/commands/cipher-agent/show-prompt.d.ts +11 -0
  8. package/dist/commands/cipher-agent/show-prompt.js +48 -0
  9. package/dist/commands/clear.d.ts +6 -0
  10. package/dist/commands/clear.js +36 -15
  11. package/dist/commands/curate.d.ts +74 -0
  12. package/dist/commands/curate.js +396 -0
  13. package/dist/commands/foo.d.ts +12 -0
  14. package/dist/commands/foo.js +61 -0
  15. package/dist/commands/gen-rules.d.ts +3 -0
  16. package/dist/commands/gen-rules.js +39 -20
  17. package/dist/commands/init.d.ts +48 -3
  18. package/dist/commands/init.js +242 -70
  19. package/dist/commands/login.js +9 -4
  20. package/dist/commands/pull.d.ts +33 -0
  21. package/dist/commands/pull.js +115 -0
  22. package/dist/commands/push.d.ts +13 -13
  23. package/dist/commands/push.js +81 -101
  24. package/dist/commands/query.d.ts +63 -0
  25. package/dist/commands/query.js +349 -0
  26. package/dist/commands/space/list.d.ts +5 -2
  27. package/dist/commands/space/list.js +60 -56
  28. package/dist/commands/space/switch.d.ts +16 -0
  29. package/dist/commands/space/switch.js +102 -53
  30. package/dist/commands/status.d.ts +5 -2
  31. package/dist/commands/status.js +43 -33
  32. package/dist/commands/watch.d.ts +23 -0
  33. package/dist/commands/watch.js +171 -0
  34. package/dist/config/auth.config.js +14 -2
  35. package/dist/config/context-tree-domains.d.ts +12 -0
  36. package/dist/config/context-tree-domains.js +29 -0
  37. package/dist/config/environment.d.ts +6 -0
  38. package/dist/config/environment.js +9 -2
  39. package/dist/constants.d.ts +5 -0
  40. package/dist/constants.js +6 -0
  41. package/dist/core/domain/cipher/agent/agent-state-machine.d.ts +128 -0
  42. package/dist/core/domain/cipher/agent/agent-state-machine.js +183 -0
  43. package/dist/core/domain/cipher/agent/agent-state.d.ts +77 -0
  44. package/dist/core/domain/cipher/agent/agent-state.js +59 -0
  45. package/dist/core/domain/cipher/agent/index.d.ts +7 -0
  46. package/dist/core/domain/cipher/agent/index.js +7 -0
  47. package/dist/core/domain/cipher/agent-events/index.d.ts +8 -0
  48. package/dist/core/domain/cipher/agent-events/index.js +7 -0
  49. package/dist/core/domain/cipher/agent-events/types.d.ts +419 -0
  50. package/dist/core/domain/cipher/agent-events/types.js +42 -0
  51. package/dist/core/domain/cipher/blob/types.d.ts +108 -0
  52. package/dist/core/domain/cipher/errors/blob-error.d.ts +36 -0
  53. package/dist/core/domain/cipher/errors/blob-error.js +68 -0
  54. package/dist/core/domain/cipher/errors/file-system-error.d.ts +211 -0
  55. package/dist/core/domain/cipher/errors/file-system-error.js +291 -0
  56. package/dist/core/domain/cipher/errors/llm-error.d.ts +120 -0
  57. package/dist/core/domain/cipher/errors/llm-error.js +161 -0
  58. package/dist/core/domain/cipher/errors/memory-error.d.ts +35 -0
  59. package/dist/core/domain/cipher/errors/memory-error.js +62 -0
  60. package/dist/core/domain/cipher/errors/process-error-code.d.ts +97 -0
  61. package/dist/core/domain/cipher/errors/process-error-code.js +98 -0
  62. package/dist/core/domain/cipher/errors/process-error.d.ts +135 -0
  63. package/dist/core/domain/cipher/errors/process-error.js +173 -0
  64. package/dist/core/domain/cipher/errors/session-error.d.ts +56 -0
  65. package/dist/core/domain/cipher/errors/session-error.js +74 -0
  66. package/dist/core/domain/cipher/errors/tool-error.d.ts +57 -0
  67. package/dist/core/domain/cipher/errors/tool-error.js +81 -0
  68. package/dist/core/domain/cipher/file-system/types.d.ts +203 -0
  69. package/dist/core/domain/cipher/memory/types.d.ts +102 -0
  70. package/dist/core/domain/cipher/memory/types.js +4 -0
  71. package/dist/core/domain/cipher/parsed-interaction.d.ts +47 -0
  72. package/dist/core/domain/cipher/parsed-interaction.js +25 -0
  73. package/dist/core/domain/cipher/process/types.d.ts +286 -0
  74. package/dist/core/domain/cipher/session/types.d.ts +54 -0
  75. package/dist/core/domain/cipher/storage/history-types.d.ts +38 -0
  76. package/dist/core/domain/cipher/system-prompt/types.d.ts +131 -0
  77. package/dist/core/domain/cipher/todos/index.d.ts +4 -0
  78. package/dist/core/domain/cipher/todos/index.js +4 -0
  79. package/dist/core/domain/cipher/todos/types.d.ts +57 -0
  80. package/dist/core/domain/cipher/todos/types.js +5 -0
  81. package/dist/core/domain/cipher/tools/constants.d.ts +28 -0
  82. package/dist/core/domain/cipher/tools/constants.js +24 -0
  83. package/dist/core/domain/cipher/tools/tool-error.d.ts +183 -0
  84. package/dist/core/domain/cipher/tools/tool-error.js +246 -0
  85. package/dist/core/domain/cipher/tools/types.d.ts +145 -0
  86. package/dist/core/domain/entities/brv-config.d.ts +42 -6
  87. package/dist/core/domain/entities/brv-config.js +115 -17
  88. package/dist/core/domain/entities/cogit-push-context.d.ts +38 -0
  89. package/dist/core/domain/entities/cogit-push-context.js +91 -0
  90. package/dist/core/domain/entities/cogit-push-response.d.ts +20 -0
  91. package/dist/core/domain/entities/cogit-push-response.js +31 -0
  92. package/dist/core/domain/entities/cogit-snapshot-author.d.ts +24 -0
  93. package/dist/core/domain/entities/cogit-snapshot-author.js +39 -0
  94. package/dist/core/domain/entities/cogit-snapshot-file.d.ts +34 -0
  95. package/dist/core/domain/entities/cogit-snapshot-file.js +59 -0
  96. package/dist/core/domain/entities/cogit-snapshot.d.ts +31 -0
  97. package/dist/core/domain/entities/cogit-snapshot.js +58 -0
  98. package/dist/core/domain/entities/context-tree-index.d.ts +26 -0
  99. package/dist/core/domain/entities/context-tree-index.js +27 -0
  100. package/dist/core/domain/entities/context-tree-snapshot.d.ts +56 -0
  101. package/dist/core/domain/entities/context-tree-snapshot.js +83 -0
  102. package/dist/core/domain/entities/event.d.ts +1 -1
  103. package/dist/core/domain/entities/event.js +3 -1
  104. package/dist/core/domain/entities/parser.d.ts +567 -0
  105. package/dist/core/domain/entities/parser.js +10 -0
  106. package/dist/core/domain/entities/playbook.d.ts +2 -23
  107. package/dist/core/domain/entities/playbook.js +2 -70
  108. package/dist/core/domain/errors/brv-config-version-error.d.ts +16 -0
  109. package/dist/core/domain/errors/brv-config-version-error.js +21 -0
  110. package/dist/core/domain/knowledge/directory-manager.d.ts +80 -0
  111. package/dist/core/domain/knowledge/directory-manager.js +145 -0
  112. package/dist/core/domain/knowledge/markdown-writer.d.ts +18 -0
  113. package/dist/core/domain/knowledge/markdown-writer.js +18 -0
  114. package/dist/core/domain/knowledge/relation-parser.d.ts +90 -0
  115. package/dist/core/domain/knowledge/relation-parser.js +131 -0
  116. package/dist/core/interfaces/cipher/cipher-services.d.ts +71 -0
  117. package/dist/core/interfaces/cipher/cipher-services.js +1 -0
  118. package/dist/core/interfaces/cipher/i-blob-storage.d.ts +78 -0
  119. package/dist/core/interfaces/cipher/i-blob-storage.js +1 -0
  120. package/dist/core/interfaces/cipher/i-chat-session.d.ts +62 -0
  121. package/dist/core/interfaces/cipher/i-chat-session.js +1 -0
  122. package/dist/core/interfaces/cipher/i-cipher-agent.d.ts +88 -0
  123. package/dist/core/interfaces/cipher/i-cipher-agent.js +1 -0
  124. package/dist/core/interfaces/cipher/i-coding-agent-log-parser.d.ts +20 -0
  125. package/dist/core/interfaces/cipher/i-coding-agent-log-parser.js +1 -0
  126. package/dist/core/interfaces/cipher/i-coding-agent-log-watcher.d.ts +31 -0
  127. package/dist/core/interfaces/cipher/i-coding-agent-log-watcher.js +1 -0
  128. package/dist/core/interfaces/cipher/i-content-generator.d.ts +120 -0
  129. package/dist/core/interfaces/cipher/i-content-generator.js +12 -0
  130. package/dist/core/interfaces/cipher/i-event-emitter.d.ts +76 -0
  131. package/dist/core/interfaces/cipher/i-event-emitter.js +1 -0
  132. package/dist/core/interfaces/cipher/i-file-system.d.ts +68 -0
  133. package/dist/core/interfaces/cipher/i-file-system.js +1 -0
  134. package/dist/core/interfaces/cipher/i-history-storage.d.ts +53 -0
  135. package/dist/core/interfaces/cipher/i-history-storage.js +1 -0
  136. package/dist/core/interfaces/cipher/i-llm-provider.d.ts +14 -0
  137. package/dist/core/interfaces/cipher/i-llm-provider.js +1 -0
  138. package/dist/core/interfaces/cipher/i-llm-service.d.ts +62 -0
  139. package/dist/core/interfaces/cipher/i-llm-service.js +1 -0
  140. package/dist/core/interfaces/cipher/i-logger.d.ts +78 -0
  141. package/dist/core/interfaces/cipher/i-logger.js +28 -0
  142. package/dist/core/interfaces/cipher/i-message-formatter.d.ts +44 -0
  143. package/dist/core/interfaces/cipher/i-message-formatter.js +1 -0
  144. package/dist/core/interfaces/cipher/i-policy-engine.d.ts +102 -0
  145. package/dist/core/interfaces/cipher/i-policy-engine.js +9 -0
  146. package/dist/core/interfaces/cipher/i-process-service.d.ts +65 -0
  147. package/dist/core/interfaces/cipher/i-process-service.js +1 -0
  148. package/dist/core/interfaces/cipher/i-system-prompt-contributor.d.ts +25 -0
  149. package/dist/core/interfaces/cipher/i-system-prompt-contributor.js +1 -0
  150. package/dist/core/interfaces/cipher/i-tokenizer.d.ts +15 -0
  151. package/dist/core/interfaces/cipher/i-tokenizer.js +1 -0
  152. package/dist/core/interfaces/cipher/i-tool-provider.d.ts +64 -0
  153. package/dist/core/interfaces/cipher/i-tool-provider.js +1 -0
  154. package/dist/core/interfaces/cipher/i-tool-scheduler.d.ts +103 -0
  155. package/dist/core/interfaces/cipher/i-tool-scheduler.js +11 -0
  156. package/dist/core/interfaces/cipher/llm-types.d.ts +46 -0
  157. package/dist/core/interfaces/cipher/llm-types.js +5 -0
  158. package/dist/core/interfaces/cipher/message-types.d.ts +118 -0
  159. package/dist/core/interfaces/cipher/message-types.js +5 -0
  160. package/dist/core/interfaces/cipher/tokenizer-types.d.ts +11 -0
  161. package/dist/core/interfaces/cipher/tokenizer-types.js +14 -0
  162. package/dist/core/interfaces/i-cogit-pull-service.d.ts +24 -0
  163. package/dist/core/interfaces/i-cogit-pull-service.js +1 -0
  164. package/dist/core/interfaces/i-cogit-push-service.d.ts +27 -0
  165. package/dist/core/interfaces/i-cogit-push-service.js +1 -0
  166. package/dist/core/interfaces/i-context-file-reader.d.ts +32 -0
  167. package/dist/core/interfaces/i-context-file-reader.js +1 -0
  168. package/dist/core/interfaces/i-context-tree-service.d.ts +21 -0
  169. package/dist/core/interfaces/i-context-tree-service.js +1 -0
  170. package/dist/core/interfaces/i-context-tree-snapshot-service.d.ts +36 -0
  171. package/dist/core/interfaces/i-context-tree-snapshot-service.js +1 -0
  172. package/dist/core/interfaces/i-context-tree-writer-service.d.ts +32 -0
  173. package/dist/core/interfaces/i-context-tree-writer-service.js +1 -0
  174. package/dist/core/interfaces/i-file-watcher-service.d.ts +41 -0
  175. package/dist/core/interfaces/i-file-watcher-service.js +1 -0
  176. package/dist/core/interfaces/parser/i-clean-parser-service.d.ts +18 -0
  177. package/dist/core/interfaces/parser/i-clean-parser-service.js +1 -0
  178. package/dist/core/interfaces/parser/i-raw-parser-service.d.ts +17 -0
  179. package/dist/core/interfaces/parser/i-raw-parser-service.js +1 -0
  180. package/dist/core/interfaces/parser/i-session-normalizer.d.ts +56 -0
  181. package/dist/core/interfaces/parser/i-session-normalizer.js +1 -0
  182. package/dist/hooks/command_not_found/handle-invalid-commands.d.ts +7 -0
  183. package/dist/hooks/command_not_found/handle-invalid-commands.js +32 -0
  184. package/dist/hooks/error/clean-errors.d.ts +7 -0
  185. package/dist/hooks/error/clean-errors.js +50 -0
  186. package/dist/hooks/init/welcome.js +72 -1
  187. package/dist/hooks/prerun/validate-brv-config-version.d.ts +28 -0
  188. package/dist/hooks/prerun/validate-brv-config-version.js +43 -0
  189. package/dist/infra/cipher/agent-service-factory.d.ts +86 -0
  190. package/dist/infra/cipher/agent-service-factory.js +212 -0
  191. package/dist/infra/cipher/blob/blob-storage-factory.d.ts +13 -0
  192. package/dist/infra/cipher/blob/blob-storage-factory.js +14 -0
  193. package/dist/infra/cipher/blob/index.d.ts +10 -0
  194. package/dist/infra/cipher/blob/index.js +12 -0
  195. package/dist/infra/cipher/blob/migrations.d.ts +63 -0
  196. package/dist/infra/cipher/blob/migrations.js +148 -0
  197. package/dist/infra/cipher/blob/sqlite-blob-storage.d.ts +82 -0
  198. package/dist/infra/cipher/blob/sqlite-blob-storage.js +307 -0
  199. package/dist/infra/cipher/cipher-agent-state-manager.d.ts +63 -0
  200. package/dist/infra/cipher/cipher-agent-state-manager.js +108 -0
  201. package/dist/infra/cipher/cipher-agent.d.ts +182 -0
  202. package/dist/infra/cipher/cipher-agent.js +317 -0
  203. package/dist/infra/cipher/command-parser.d.ts +23 -0
  204. package/dist/infra/cipher/command-parser.js +85 -0
  205. package/dist/infra/cipher/display/todo-display.d.ts +23 -0
  206. package/dist/infra/cipher/display/todo-display.js +129 -0
  207. package/dist/infra/cipher/events/event-emitter.d.ts +137 -0
  208. package/dist/infra/cipher/events/event-emitter.js +158 -0
  209. package/dist/infra/cipher/exit-codes.d.ts +44 -0
  210. package/dist/infra/cipher/exit-codes.js +58 -0
  211. package/dist/infra/cipher/file-system/file-system-service.d.ts +105 -0
  212. package/dist/infra/cipher/file-system/file-system-service.js +641 -0
  213. package/dist/infra/cipher/file-system/gitignore-filter.d.ts +77 -0
  214. package/dist/infra/cipher/file-system/gitignore-filter.js +120 -0
  215. package/dist/infra/cipher/file-system/glob-utils.d.ts +60 -0
  216. package/dist/infra/cipher/file-system/glob-utils.js +120 -0
  217. package/dist/infra/cipher/file-system/path-validator.d.ts +69 -0
  218. package/dist/infra/cipher/file-system/path-validator.js +184 -0
  219. package/dist/infra/cipher/grpc/internal-llm-grpc-service.d.ts +149 -0
  220. package/dist/infra/cipher/grpc/internal-llm-grpc-service.js +364 -0
  221. package/dist/infra/cipher/grpc/internal-llm-grpc.proto +94 -0
  222. package/dist/infra/cipher/interactive-commands.d.ts +16 -0
  223. package/dist/infra/cipher/interactive-commands.js +198 -0
  224. package/dist/infra/cipher/interactive-loop.d.ts +24 -0
  225. package/dist/infra/cipher/interactive-loop.js +352 -0
  226. package/dist/infra/cipher/llm/context/async-mutex.d.ts +59 -0
  227. package/dist/infra/cipher/llm/context/async-mutex.js +92 -0
  228. package/dist/infra/cipher/llm/context/compression/index.d.ts +6 -0
  229. package/dist/infra/cipher/llm/context/compression/index.js +5 -0
  230. package/dist/infra/cipher/llm/context/compression/middle-removal.d.ts +40 -0
  231. package/dist/infra/cipher/llm/context/compression/middle-removal.js +76 -0
  232. package/dist/infra/cipher/llm/context/compression/oldest-removal.d.ts +38 -0
  233. package/dist/infra/cipher/llm/context/compression/oldest-removal.js +53 -0
  234. package/dist/infra/cipher/llm/context/compression/types.d.ts +36 -0
  235. package/dist/infra/cipher/llm/context/compression/types.js +1 -0
  236. package/dist/infra/cipher/llm/context/context-manager.d.ts +234 -0
  237. package/dist/infra/cipher/llm/context/context-manager.js +419 -0
  238. package/dist/infra/cipher/llm/context/index.d.ts +2 -0
  239. package/dist/infra/cipher/llm/context/index.js +2 -0
  240. package/dist/infra/cipher/llm/context/loop-detector.d.ts +125 -0
  241. package/dist/infra/cipher/llm/context/loop-detector.js +194 -0
  242. package/dist/infra/cipher/llm/context/utils.d.ts +17 -0
  243. package/dist/infra/cipher/llm/context/utils.js +89 -0
  244. package/dist/infra/cipher/llm/formatters/claude-formatter.d.ts +54 -0
  245. package/dist/infra/cipher/llm/formatters/claude-formatter.js +182 -0
  246. package/dist/infra/cipher/llm/formatters/gemini-formatter.d.ts +69 -0
  247. package/dist/infra/cipher/llm/formatters/gemini-formatter.js +253 -0
  248. package/dist/infra/cipher/llm/formatters/openrouter-formatter.d.ts +47 -0
  249. package/dist/infra/cipher/llm/formatters/openrouter-formatter.js +238 -0
  250. package/dist/infra/cipher/llm/generators/byterover-content-generator.d.ts +92 -0
  251. package/dist/infra/cipher/llm/generators/byterover-content-generator.js +211 -0
  252. package/dist/infra/cipher/llm/generators/index.d.ts +13 -0
  253. package/dist/infra/cipher/llm/generators/index.js +13 -0
  254. package/dist/infra/cipher/llm/generators/logging-content-generator.d.ts +104 -0
  255. package/dist/infra/cipher/llm/generators/logging-content-generator.js +182 -0
  256. package/dist/infra/cipher/llm/generators/openrouter-content-generator.d.ts +93 -0
  257. package/dist/infra/cipher/llm/generators/openrouter-content-generator.js +254 -0
  258. package/dist/infra/cipher/llm/generators/retryable-content-generator.d.ts +90 -0
  259. package/dist/infra/cipher/llm/generators/retryable-content-generator.js +157 -0
  260. package/dist/infra/cipher/llm/index.d.ts +9 -0
  261. package/dist/infra/cipher/llm/index.js +13 -0
  262. package/dist/infra/cipher/llm/internal-llm-service.d.ts +308 -0
  263. package/dist/infra/cipher/llm/internal-llm-service.js +724 -0
  264. package/dist/infra/cipher/llm/openrouter-llm-service.d.ts +183 -0
  265. package/dist/infra/cipher/llm/openrouter-llm-service.js +386 -0
  266. package/dist/infra/cipher/llm/response-validator.d.ts +89 -0
  267. package/dist/infra/cipher/llm/response-validator.js +157 -0
  268. package/dist/infra/cipher/llm/retry/index.d.ts +10 -0
  269. package/dist/infra/cipher/llm/retry/index.js +10 -0
  270. package/dist/infra/cipher/llm/retry/retry-policy.d.ts +74 -0
  271. package/dist/infra/cipher/llm/retry/retry-policy.js +146 -0
  272. package/dist/infra/cipher/llm/retry/retry-with-backoff.d.ts +113 -0
  273. package/dist/infra/cipher/llm/retry/retry-with-backoff.js +247 -0
  274. package/dist/infra/cipher/llm/thought-parser.d.ts +145 -0
  275. package/dist/infra/cipher/llm/thought-parser.js +190 -0
  276. package/dist/infra/cipher/llm/tokenizers/claude-tokenizer.d.ts +47 -0
  277. package/dist/infra/cipher/llm/tokenizers/claude-tokenizer.js +55 -0
  278. package/dist/infra/cipher/llm/tokenizers/default-tokenizer.d.ts +31 -0
  279. package/dist/infra/cipher/llm/tokenizers/default-tokenizer.js +38 -0
  280. package/dist/infra/cipher/llm/tokenizers/gemini-tokenizer.d.ts +37 -0
  281. package/dist/infra/cipher/llm/tokenizers/gemini-tokenizer.js +45 -0
  282. package/dist/infra/cipher/llm/tokenizers/openrouter-tokenizer.d.ts +29 -0
  283. package/dist/infra/cipher/llm/tokenizers/openrouter-tokenizer.js +37 -0
  284. package/dist/infra/cipher/llm/tool-output-processor.d.ts +117 -0
  285. package/dist/infra/cipher/llm/tool-output-processor.js +153 -0
  286. package/dist/infra/cipher/logger/console-logger.d.ts +42 -0
  287. package/dist/infra/cipher/logger/console-logger.js +63 -0
  288. package/dist/infra/cipher/logger/event-based-logger.d.ts +54 -0
  289. package/dist/infra/cipher/logger/event-based-logger.js +92 -0
  290. package/dist/infra/cipher/memory/index.d.ts +6 -0
  291. package/dist/infra/cipher/memory/index.js +7 -0
  292. package/dist/infra/cipher/memory/memory-manager.d.ts +136 -0
  293. package/dist/infra/cipher/memory/memory-manager.js +523 -0
  294. package/dist/infra/cipher/parsers/coding-agent-log-parser.d.ts +24 -0
  295. package/dist/infra/cipher/parsers/coding-agent-log-parser.js +51 -0
  296. package/dist/infra/cipher/process/command-validator.d.ts +59 -0
  297. package/dist/infra/cipher/process/command-validator.js +266 -0
  298. package/dist/infra/cipher/process/index.d.ts +8 -0
  299. package/dist/infra/cipher/process/index.js +8 -0
  300. package/dist/infra/cipher/process/process-service.d.ts +95 -0
  301. package/dist/infra/cipher/process/process-service.js +439 -0
  302. package/dist/infra/cipher/session/chat-session.d.ts +80 -0
  303. package/dist/infra/cipher/session/chat-session.js +165 -0
  304. package/dist/infra/cipher/session/index.d.ts +6 -0
  305. package/dist/infra/cipher/session/index.js +5 -0
  306. package/dist/infra/cipher/session/session-event-forwarder.d.ts +37 -0
  307. package/dist/infra/cipher/session/session-event-forwarder.js +83 -0
  308. package/dist/infra/cipher/session/session-manager.d.ts +109 -0
  309. package/dist/infra/cipher/session/session-manager.js +172 -0
  310. package/dist/infra/cipher/storage/blob-history-storage.d.ts +76 -0
  311. package/dist/infra/cipher/storage/blob-history-storage.js +178 -0
  312. package/dist/infra/cipher/system-prompt/simple-prompt-factory.d.ts +105 -0
  313. package/dist/infra/cipher/system-prompt/simple-prompt-factory.js +290 -0
  314. package/dist/infra/cipher/tools/core-tool-scheduler.d.ts +99 -0
  315. package/dist/infra/cipher/tools/core-tool-scheduler.js +161 -0
  316. package/dist/infra/cipher/tools/default-policy-rules.d.ts +26 -0
  317. package/dist/infra/cipher/tools/default-policy-rules.js +125 -0
  318. package/dist/infra/cipher/tools/implementations/bash-exec-tool.d.ts +12 -0
  319. package/dist/infra/cipher/tools/implementations/bash-exec-tool.js +93 -0
  320. package/dist/infra/cipher/tools/implementations/bash-output-tool.d.ts +12 -0
  321. package/dist/infra/cipher/tools/implementations/bash-output-tool.js +47 -0
  322. package/dist/infra/cipher/tools/implementations/create-knowledge-topic-tool.d.ts +11 -0
  323. package/dist/infra/cipher/tools/implementations/create-knowledge-topic-tool.js +142 -0
  324. package/dist/infra/cipher/tools/implementations/delete-memory-tool.d.ts +12 -0
  325. package/dist/infra/cipher/tools/implementations/delete-memory-tool.js +37 -0
  326. package/dist/infra/cipher/tools/implementations/detect-domains-tool.d.ts +7 -0
  327. package/dist/infra/cipher/tools/implementations/detect-domains-tool.js +73 -0
  328. package/dist/infra/cipher/tools/implementations/edit-file-tool.d.ts +13 -0
  329. package/dist/infra/cipher/tools/implementations/edit-file-tool.js +50 -0
  330. package/dist/infra/cipher/tools/implementations/edit-memory-tool.d.ts +13 -0
  331. package/dist/infra/cipher/tools/implementations/edit-memory-tool.js +53 -0
  332. package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.d.ts +7 -0
  333. package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.js +421 -0
  334. package/dist/infra/cipher/tools/implementations/glob-files-tool.d.ts +18 -0
  335. package/dist/infra/cipher/tools/implementations/glob-files-tool.js +70 -0
  336. package/dist/infra/cipher/tools/implementations/grep-content-tool.d.ts +12 -0
  337. package/dist/infra/cipher/tools/implementations/grep-content-tool.js +77 -0
  338. package/dist/infra/cipher/tools/implementations/kill-process-tool.d.ts +12 -0
  339. package/dist/infra/cipher/tools/implementations/kill-process-tool.js +55 -0
  340. package/dist/infra/cipher/tools/implementations/list-memories-tool.d.ts +12 -0
  341. package/dist/infra/cipher/tools/implementations/list-memories-tool.js +63 -0
  342. package/dist/infra/cipher/tools/implementations/read-file-tool.d.ts +12 -0
  343. package/dist/infra/cipher/tools/implementations/read-file-tool.js +54 -0
  344. package/dist/infra/cipher/tools/implementations/read-memory-tool.d.ts +12 -0
  345. package/dist/infra/cipher/tools/implementations/read-memory-tool.js +39 -0
  346. package/dist/infra/cipher/tools/implementations/search-history-tool.d.ts +10 -0
  347. package/dist/infra/cipher/tools/implementations/search-history-tool.js +36 -0
  348. package/dist/infra/cipher/tools/implementations/write-file-tool.d.ts +12 -0
  349. package/dist/infra/cipher/tools/implementations/write-file-tool.js +52 -0
  350. package/dist/infra/cipher/tools/implementations/write-memory-tool.d.ts +13 -0
  351. package/dist/infra/cipher/tools/implementations/write-memory-tool.js +52 -0
  352. package/dist/infra/cipher/tools/implementations/write-todos-tool.d.ts +10 -0
  353. package/dist/infra/cipher/tools/implementations/write-todos-tool.js +165 -0
  354. package/dist/infra/cipher/tools/index.d.ts +18 -0
  355. package/dist/infra/cipher/tools/index.js +19 -0
  356. package/dist/infra/cipher/tools/policy-engine.d.ts +80 -0
  357. package/dist/infra/cipher/tools/policy-engine.js +110 -0
  358. package/dist/infra/cipher/tools/tool-invocation-queue.d.ts +191 -0
  359. package/dist/infra/cipher/tools/tool-invocation-queue.js +254 -0
  360. package/dist/infra/cipher/tools/tool-invocation.d.ts +216 -0
  361. package/dist/infra/cipher/tools/tool-invocation.js +294 -0
  362. package/dist/infra/cipher/tools/tool-manager.d.ts +135 -0
  363. package/dist/infra/cipher/tools/tool-manager.js +209 -0
  364. package/dist/infra/cipher/tools/tool-markers.d.ts +48 -0
  365. package/dist/infra/cipher/tools/tool-markers.js +49 -0
  366. package/dist/infra/cipher/tools/tool-provider.d.ts +77 -0
  367. package/dist/infra/cipher/tools/tool-provider.js +196 -0
  368. package/dist/infra/cipher/tools/tool-registry.d.ts +52 -0
  369. package/dist/infra/cipher/tools/tool-registry.js +144 -0
  370. package/dist/infra/cipher/tools/utils/schema-converter.d.ts +10 -0
  371. package/dist/infra/cipher/tools/utils/schema-converter.js +29 -0
  372. package/dist/infra/cipher/validation/workspace-validator.d.ts +19 -0
  373. package/dist/infra/cipher/validation/workspace-validator.js +37 -0
  374. package/dist/infra/cipher/watcher/coding-agent-log-watcher.d.ts +14 -0
  375. package/dist/infra/cipher/watcher/coding-agent-log-watcher.js +55 -0
  376. package/dist/infra/cogit/context-tree-to-push-context-mapper.d.ts +21 -0
  377. package/dist/infra/cogit/context-tree-to-push-context-mapper.js +32 -0
  378. package/dist/infra/cogit/http-cogit-pull-service.d.ts +15 -0
  379. package/dist/infra/cogit/http-cogit-pull-service.js +30 -0
  380. package/dist/infra/cogit/http-cogit-push-service.d.ts +17 -0
  381. package/dist/infra/cogit/http-cogit-push-service.js +104 -0
  382. package/dist/infra/config/file-config-store.js +9 -3
  383. package/dist/infra/context-tree/file-context-file-reader.d.ts +14 -0
  384. package/dist/infra/context-tree/file-context-file-reader.js +46 -0
  385. package/dist/infra/context-tree/file-context-tree-service.d.ts +14 -0
  386. package/dist/infra/context-tree/file-context-tree-service.js +46 -0
  387. package/dist/infra/context-tree/file-context-tree-snapshot-service.d.ts +34 -0
  388. package/dist/infra/context-tree/file-context-tree-snapshot-service.js +117 -0
  389. package/dist/infra/context-tree/file-context-tree-writer-service.d.ts +22 -0
  390. package/dist/infra/context-tree/file-context-tree-writer-service.js +61 -0
  391. package/dist/infra/memory/http-memory-retrieval-service.js +2 -1
  392. package/dist/infra/memory/http-memory-storage-service.js +4 -3
  393. package/dist/infra/parsers/clean/clean-claude-service.d.ts +111 -0
  394. package/dist/infra/parsers/clean/clean-claude-service.js +271 -0
  395. package/dist/infra/parsers/clean/clean-codex-service.d.ts +231 -0
  396. package/dist/infra/parsers/clean/clean-codex-service.js +534 -0
  397. package/dist/infra/parsers/clean/clean-copilot-service.d.ts +255 -0
  398. package/dist/infra/parsers/clean/clean-copilot-service.js +729 -0
  399. package/dist/infra/parsers/clean/clean-cursor-service.d.ts +161 -0
  400. package/dist/infra/parsers/clean/clean-cursor-service.js +432 -0
  401. package/dist/infra/parsers/clean/clean-parser-service-factory.d.ts +54 -0
  402. package/dist/infra/parsers/clean/clean-parser-service-factory.js +80 -0
  403. package/dist/infra/parsers/clean/shared.d.ts +84 -0
  404. package/dist/infra/parsers/clean/shared.js +273 -0
  405. package/dist/infra/parsers/raw/raw-claude-service.d.ts +195 -0
  406. package/dist/infra/parsers/raw/raw-claude-service.js +548 -0
  407. package/dist/infra/parsers/raw/raw-codex-service.d.ts +313 -0
  408. package/dist/infra/parsers/raw/raw-codex-service.js +782 -0
  409. package/dist/infra/parsers/raw/raw-copilot-service.d.ts +196 -0
  410. package/dist/infra/parsers/raw/raw-copilot-service.js +558 -0
  411. package/dist/infra/parsers/raw/raw-cursor-service.d.ts +316 -0
  412. package/dist/infra/parsers/raw/raw-cursor-service.js +818 -0
  413. package/dist/infra/parsers/raw/raw-parser-service-factory.d.ts +54 -0
  414. package/dist/infra/parsers/raw/raw-parser-service-factory.js +81 -0
  415. package/dist/infra/space/http-space-service.js +2 -1
  416. package/dist/infra/team/http-team-service.js +2 -1
  417. package/dist/infra/user/http-user-service.js +2 -1
  418. package/dist/infra/watcher/file-watcher-service.d.ts +10 -0
  419. package/dist/infra/watcher/file-watcher-service.js +81 -0
  420. package/dist/infra/workspace/workspace-detector-service.d.ts +60 -0
  421. package/dist/infra/workspace/workspace-detector-service.js +165 -0
  422. package/dist/resources/prompts/curate-context-tree-curation.yml +48 -0
  423. package/dist/resources/prompts/modes/autonomous.yml +9 -0
  424. package/dist/resources/prompts/query-context-tree-retrieval.yml +49 -0
  425. package/dist/resources/prompts/reflection.yml +27 -0
  426. package/dist/resources/prompts/system-prompt.yml +82 -0
  427. package/dist/resources/prompts/tool-outputs.yml +30 -0
  428. package/dist/templates/README.md +6 -7
  429. package/dist/templates/sections/command-reference.md +40 -111
  430. package/dist/templates/sections/workflow.md +3 -30
  431. package/dist/utils/emoji-helpers.d.ts +38 -0
  432. package/dist/utils/emoji-helpers.js +42 -0
  433. package/dist/utils/error-handler.d.ts +51 -0
  434. package/dist/utils/error-handler.js +169 -0
  435. package/dist/utils/error-helpers.d.ts +30 -0
  436. package/dist/utils/error-helpers.js +47 -0
  437. package/dist/utils/file-helpers.d.ts +15 -0
  438. package/dist/utils/file-helpers.js +44 -0
  439. package/dist/utils/oclif-error-helpers.d.ts +40 -0
  440. package/dist/utils/oclif-error-helpers.js +46 -0
  441. package/dist/utils/tool-display-formatter.d.ts +53 -0
  442. package/dist/utils/tool-display-formatter.js +257 -0
  443. package/oclif.manifest.json +381 -141
  444. package/package.json +27 -6
  445. package/dist/commands/add.d.ts +0 -49
  446. package/dist/commands/add.js +0 -192
  447. package/dist/commands/complete.d.ts +0 -108
  448. package/dist/commands/complete.js +0 -340
  449. package/dist/commands/retrieve.d.ts +0 -26
  450. package/dist/commands/retrieve.js +0 -101
  451. package/dist/core/domain/entities/curator-output.d.ts +0 -14
  452. package/dist/core/domain/entities/curator-output.js +0 -23
  453. package/dist/core/domain/entities/delta-batch.d.ts +0 -30
  454. package/dist/core/domain/entities/delta-batch.js +0 -52
  455. package/dist/core/domain/entities/delta-operation.d.ts +0 -31
  456. package/dist/core/domain/entities/delta-operation.js +0 -50
  457. package/dist/core/domain/entities/executor-output.d.ts +0 -27
  458. package/dist/core/domain/entities/executor-output.js +0 -33
  459. package/dist/core/domain/entities/reflector-output.d.ts +0 -38
  460. package/dist/core/domain/entities/reflector-output.js +0 -44
  461. package/dist/core/interfaces/i-ace-prompt-builder.d.ts +0 -48
  462. package/dist/core/interfaces/i-bullet-content-store.d.ts +0 -36
  463. package/dist/core/interfaces/i-delta-store.d.ts +0 -15
  464. package/dist/core/interfaces/i-executor-output-store.d.ts +0 -14
  465. package/dist/core/interfaces/i-playbook-service.d.ts +0 -69
  466. package/dist/core/interfaces/i-playbook-store.d.ts +0 -38
  467. package/dist/core/interfaces/i-reflection-store.d.ts +0 -21
  468. package/dist/infra/ace/ace-file-utils.d.ts +0 -46
  469. package/dist/infra/ace/ace-file-utils.js +0 -83
  470. package/dist/infra/ace/ace-prompt-templates.d.ts +0 -13
  471. package/dist/infra/ace/ace-prompt-templates.js +0 -177
  472. package/dist/infra/ace/file-bullet-content-store.d.ts +0 -27
  473. package/dist/infra/ace/file-bullet-content-store.js +0 -89
  474. package/dist/infra/ace/file-delta-store.d.ts +0 -9
  475. package/dist/infra/ace/file-delta-store.js +0 -26
  476. package/dist/infra/ace/file-executor-output-store.d.ts +0 -9
  477. package/dist/infra/ace/file-executor-output-store.js +0 -26
  478. package/dist/infra/ace/file-playbook-store.d.ts +0 -29
  479. package/dist/infra/ace/file-playbook-store.js +0 -107
  480. package/dist/infra/ace/file-reflection-store.d.ts +0 -10
  481. package/dist/infra/ace/file-reflection-store.js +0 -55
  482. package/dist/infra/playbook/file-playbook-service.d.ts +0 -42
  483. package/dist/infra/playbook/file-playbook-service.js +0 -132
  484. /package/dist/core/{interfaces/i-ace-prompt-builder.js → domain/cipher/blob/types.js} +0 -0
  485. /package/dist/core/{interfaces/i-bullet-content-store.js → domain/cipher/file-system/types.js} +0 -0
  486. /package/dist/core/{interfaces/i-delta-store.js → domain/cipher/process/types.js} +0 -0
  487. /package/dist/core/{interfaces/i-executor-output-store.js → domain/cipher/session/types.js} +0 -0
  488. /package/dist/core/{interfaces/i-playbook-service.js → domain/cipher/storage/history-types.js} +0 -0
  489. /package/dist/core/{interfaces/i-playbook-store.js → domain/cipher/system-prompt/types.js} +0 -0
  490. /package/dist/core/{interfaces/i-reflection-store.js → domain/cipher/tools/types.js} +0 -0
@@ -1,12 +1,15 @@
1
1
  import { confirm } from '@inquirer/prompts';
2
2
  import { Args, Command, Flags } from '@oclif/core';
3
- import { Playbook } from '../core/domain/entities/playbook.js';
4
- import { FilePlaybookStore } from '../infra/ace/file-playbook-store.js';
3
+ import { rm } from 'node:fs/promises';
4
+ import { join } from 'node:path';
5
+ import { BRV_DIR, CONTEXT_TREE_DIR } from '../constants.js';
6
+ import { FileContextTreeService } from '../infra/context-tree/file-context-tree-service.js';
7
+ import { FileContextTreeSnapshotService } from '../infra/context-tree/file-context-tree-snapshot-service.js';
5
8
  export default class Clear extends Command {
6
9
  static args = {
7
10
  directory: Args.string({ description: 'Project directory (defaults to current directory)', required: false }),
8
11
  };
9
- static description = 'Clear local ACE context (playbook) managed by ByteRover CLI';
12
+ static description = 'Reset the context tree to its original state (6 default domains)';
10
13
  static examples = [
11
14
  '<%= config.bin %> <%= command.id %>',
12
15
  '<%= config.bin %> <%= command.id %> --yes',
@@ -23,35 +26,53 @@ export default class Clear extends Command {
23
26
  async confirmClear() {
24
27
  return confirm({
25
28
  default: false,
26
- message: 'Are you sure you want to clear the playbook? This action cannot be undone.',
29
+ message: 'Are you sure you want to reset the context tree? This will remove all existing context and restore default domains.',
27
30
  });
28
31
  }
32
+ createServices() {
33
+ return {
34
+ contextTreeService: new FileContextTreeService(),
35
+ contextTreeSnapshotService: new FileContextTreeSnapshotService(),
36
+ };
37
+ }
29
38
  async run() {
30
39
  const { args, flags } = await this.parse(Clear);
31
40
  try {
32
- // Setup dependencies
33
- const playbookStore = new FilePlaybookStore();
34
- // Check if playbook exists
35
- const exists = await playbookStore.exists(args.directory);
41
+ const { contextTreeService, contextTreeSnapshotService } = this.createServices();
42
+ // Check if context tree exists
43
+ const exists = await contextTreeService.exists(args.directory);
36
44
  if (!exists) {
37
- this.log('No playbook found. Nothing to clear.');
45
+ this.log('No context tree found. Nothing to clear.');
38
46
  return;
39
47
  }
40
48
  // Confirmation prompt (unless --yes flag is used)
41
49
  if (!flags.yes) {
42
50
  const confirmed = await this.confirmClear();
43
51
  if (!confirmed) {
44
- this.log('Cancelled. Playbook was not cleared.');
52
+ this.log('Cancelled. Context tree was not reset.');
45
53
  return;
46
54
  }
47
55
  }
48
- // Reset the playbook to empty structure
49
- const emptyPlaybook = new Playbook();
50
- await playbookStore.save(emptyPlaybook, args.directory);
51
- this.log('✓ Playbook cleared successfully.');
56
+ // Remove existing context tree directory
57
+ const baseDir = args.directory ?? process.cwd();
58
+ const contextTreeDir = join(baseDir, BRV_DIR, CONTEXT_TREE_DIR);
59
+ await rm(contextTreeDir, { force: true, recursive: true });
60
+ // Re-initialize context tree with default domains
61
+ await contextTreeService.initialize(args.directory);
62
+ // Re-initialize empty snapshot
63
+ await contextTreeSnapshotService.initEmptySnapshot(args.directory);
64
+ this.log('✓ Context tree reset successfully.');
65
+ this.log(' 6 default domains restored: code_style, design, structure, compliance, testing, bug_fixes');
52
66
  }
53
67
  catch (error) {
54
- this.error(error instanceof Error ? error.message : 'Failed to clear playbook');
68
+ // Handle user cancelling the prompt (Ctrl+C or closing stdin)
69
+ const errorMessage = error instanceof Error ? error.message : String(error);
70
+ if (errorMessage.includes('User force closed') || errorMessage.includes('force closed')) {
71
+ this.log('Cancelled. Context tree was not reset.');
72
+ return;
73
+ }
74
+ // For other errors, throw to let oclif handle display
75
+ this.error(error instanceof Error ? error.message : 'Failed to reset context tree');
55
76
  }
56
77
  }
57
78
  }
@@ -0,0 +1,74 @@
1
+ import { Command } from '@oclif/core';
2
+ import type { IProjectConfigStore } from '../core/interfaces/i-project-config-store.js';
3
+ import type { ITrackingService } from '../core/interfaces/i-tracking-service.js';
4
+ export default class Curate extends Command {
5
+ static args: {
6
+ context: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static description: string;
9
+ static examples: string[];
10
+ static flags: {
11
+ apiKey?: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions> | undefined;
12
+ model?: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions> | undefined;
13
+ verbose?: import("@oclif/core/interfaces").BooleanFlag<boolean> | undefined;
14
+ };
15
+ catch(error: Error & {
16
+ oclif?: {
17
+ exit: number;
18
+ };
19
+ }): Promise<void>;
20
+ protected createServices(): {
21
+ projectConfigStore: IProjectConfigStore;
22
+ trackingService: ITrackingService;
23
+ };
24
+ /**
25
+ * Create topic folder with context.md file
26
+ * @param targetPath - The parent path where the topic folder will be created
27
+ * @param topicName - The name of the topic folder to create
28
+ * @returns The path to the created context.md file
29
+ */
30
+ protected createTopicWithContextFile(targetPath: string, topicName: string): string;
31
+ /**
32
+ * Generate a unique session ID for the autonomous agent.
33
+ * Uses crypto.randomUUID() for guaranteed uniqueness (122 bits of entropy).
34
+ */
35
+ protected generateSessionId(): string;
36
+ /**
37
+ * Navigate through the context tree using file selector
38
+ * Returns the selected path relative to context-tree root
39
+ */
40
+ protected navigateContextTree(): Promise<null | string>;
41
+ /**
42
+ * Open a file in the default editor
43
+ * @param filePath - The path to the file to open
44
+ */
45
+ protected openFile(filePath: string): Promise<void>;
46
+ /**
47
+ * Prompt user to enter topic name with validation
48
+ * @param targetPath - The path where the topic folder will be created
49
+ * @returns The topic name or null if cancelled
50
+ */
51
+ protected promptForTopicName(targetPath: string): Promise<null | string>;
52
+ run(): Promise<void>;
53
+ /**
54
+ * Write content to context tree at given path
55
+ */
56
+ protected writeToContextTree(selectedPath: string, content: string): Promise<void>;
57
+ /**
58
+ * Handle workspace not initialized error
59
+ */
60
+ private handleWorkspaceError;
61
+ /**
62
+ * Run in autonomous mode using CipherAgent
63
+ */
64
+ private runAutonomous;
65
+ /**
66
+ * Run in interactive mode with manual prompts
67
+ */
68
+ private runInteractive;
69
+ /**
70
+ * Setup event listeners for CipherAgent
71
+ */
72
+ private setupEventListeners;
73
+ private validateTopicName;
74
+ }
@@ -0,0 +1,396 @@
1
+ import { input } from '@inquirer/prompts';
2
+ import { Args, Command, Flags } from '@oclif/core';
3
+ import chalk from 'chalk';
4
+ import { fileSelector, ItemType } from 'inquirer-file-selector';
5
+ import { randomUUID } from 'node:crypto';
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
8
+ import open from 'open';
9
+ import { CONTEXT_TREE_DOMAINS } from '../config/context-tree-domains.js';
10
+ import { getCurrentConfig, isDevelopment } from '../config/environment.js';
11
+ import { BRV_DIR, CONTEXT_FILE, CONTEXT_TREE_DIR, PROJECT } from '../constants.js';
12
+ import { CipherAgent } from '../infra/cipher/cipher-agent.js';
13
+ import { ExitCode, ExitError, exitWithCode } from '../infra/cipher/exit-codes.js';
14
+ import { WorkspaceNotInitializedError } from '../infra/cipher/validation/workspace-validator.js';
15
+ import { ProjectConfigStore } from '../infra/config/file-config-store.js';
16
+ import { KeychainTokenStore } from '../infra/storage/keychain-token-store.js';
17
+ import { MixpanelTrackingService } from '../infra/tracking/mixpanel-tracking-service.js';
18
+ import { addErrorPrefix } from '../utils/emoji-helpers.js';
19
+ import { formatToolCall, formatToolResult } from '../utils/tool-display-formatter.js';
20
+ // Full path to context tree
21
+ const CONTEXT_TREE_PATH = path.join(BRV_DIR, CONTEXT_TREE_DIR);
22
+ export default class Curate extends Command {
23
+ static args = {
24
+ context: Args.string({
25
+ description: 'Knowledge context: patterns, decisions, errors, or insights (triggers autonomous mode)',
26
+ required: false,
27
+ }),
28
+ };
29
+ static description = `Curate context to the context tree (interactive or autonomous mode)
30
+ Good:
31
+ - "Auth uses JWT with 24h expiry. Tokens stored in httpOnly cookies via authMiddleware.ts"
32
+ - "API rate limit is 100 req/min per user. Implemented using Redis with sliding window in rateLimiter.ts"
33
+ Bad:
34
+ - "Authentication" or "JWT tokens" (too vague, lacks context)
35
+ - "Rate limiting" (no implementation details or file references)`;
36
+ static examples = [
37
+ '# Interactive mode (manually choose domain/topic)',
38
+ '<%= config.bin %> <%= command.id %>',
39
+ '',
40
+ '# Autonomous mode - LLM auto-categorizes your context',
41
+ '<%= config.bin %> <%= command.id %> "Auth uses JWT with 24h expiry. Tokens stored in httpOnly cookies via authMiddleware.ts"',
42
+ '',
43
+ ...(isDevelopment()
44
+ ? [
45
+ '# Autonomous mode with OpenRouter (development only)',
46
+ '<%= config.bin %> <%= command.id %> -k YOUR_API_KEY "React components follow atomic design in src/components/. Atoms in atoms/, molecules in molecules/, organisms in organisms/"',
47
+ '',
48
+ '# Autonomous mode with custom model (development only)',
49
+ '<%= config.bin %> <%= command.id %> -k YOUR_API_KEY -m anthropic/claude-sonnet-4 "API rate limit is 100 req/min per user. Implemented using Redis with sliding window in rateLimiter.ts"',
50
+ ]
51
+ : []),
52
+ ];
53
+ static flags = {
54
+ ...(isDevelopment()
55
+ ? {
56
+ apiKey: Flags.string({
57
+ char: 'k',
58
+ description: 'OpenRouter API key (use OpenRouter instead of internal gRPC backend) [Development only]',
59
+ env: 'OPENROUTER_API_KEY',
60
+ }),
61
+ model: Flags.string({
62
+ char: 'm',
63
+ description: 'Model to use (default: google/gemini-2.5-pro for OpenRouter, gemini-2.5-pro for gRPC) [Development only]',
64
+ }),
65
+ verbose: Flags.boolean({
66
+ char: 'v',
67
+ default: false,
68
+ description: 'Enable verbose debug output [Development only]',
69
+ }),
70
+ }
71
+ : {}),
72
+ };
73
+ // Override catch to prevent oclif from logging errors that were already displayed
74
+ async catch(error) {
75
+ // Check if error is ExitError (message already displayed by exitWithCode)
76
+ if (error instanceof ExitError) {
77
+ return;
78
+ }
79
+ // Backwards compatibility: also check oclif.exit property
80
+ if (error.oclif?.exit !== undefined) {
81
+ return;
82
+ }
83
+ // For other errors, re-throw to let oclif handle them
84
+ throw error;
85
+ }
86
+ createServices() {
87
+ return {
88
+ projectConfigStore: new ProjectConfigStore(),
89
+ trackingService: new MixpanelTrackingService(new KeychainTokenStore()),
90
+ };
91
+ }
92
+ /**
93
+ * Create topic folder with context.md file
94
+ * @param targetPath - The parent path where the topic folder will be created
95
+ * @param topicName - The name of the topic folder to create
96
+ * @returns The path to the created context.md file
97
+ */
98
+ createTopicWithContextFile(targetPath, topicName) {
99
+ const topicPath = path.join(targetPath, topicName);
100
+ const contextFilePath = path.join(topicPath, CONTEXT_FILE);
101
+ // Create the topic directory
102
+ fs.mkdirSync(topicPath, { recursive: true });
103
+ // Create the context.md file with initial content
104
+ const initialContent = `# ${topicName}\n\n<!-- Add your context here -->\n`;
105
+ fs.writeFileSync(contextFilePath, initialContent, 'utf8');
106
+ return contextFilePath;
107
+ }
108
+ /**
109
+ * Generate a unique session ID for the autonomous agent.
110
+ * Uses crypto.randomUUID() for guaranteed uniqueness (122 bits of entropy).
111
+ */
112
+ generateSessionId() {
113
+ return randomUUID();
114
+ }
115
+ /**
116
+ * Navigate through the context tree using file selector
117
+ * Returns the selected path relative to context-tree root
118
+ */
119
+ async navigateContextTree() {
120
+ const contextTreePath = path.resolve(process.cwd(), CONTEXT_TREE_PATH);
121
+ // Ensure context tree directory exists
122
+ if (!fs.existsSync(contextTreePath)) {
123
+ fs.mkdirSync(contextTreePath, { recursive: true });
124
+ }
125
+ // Ensure predefined domains exist as directories
126
+ for (const domain of CONTEXT_TREE_DOMAINS) {
127
+ const domainPath = path.join(contextTreePath, domain.name);
128
+ if (!fs.existsSync(domainPath)) {
129
+ fs.mkdirSync(domainPath, { recursive: true });
130
+ }
131
+ }
132
+ while (true) {
133
+ try {
134
+ // eslint-disable-next-line no-await-in-loop
135
+ const selectedItem = await fileSelector({
136
+ allowCancel: true,
137
+ basePath: contextTreePath,
138
+ filter: (item) => item.isDirectory,
139
+ message: 'Target context location:',
140
+ pageSize: 15,
141
+ theme: {
142
+ labels: {
143
+ messages: {
144
+ cancel: 'Selection cancelled.',
145
+ empty: 'No sub-folders. Press Enter to add content here.',
146
+ },
147
+ },
148
+ },
149
+ type: ItemType.Directory,
150
+ });
151
+ // User cancelled
152
+ if (!selectedItem) {
153
+ return null;
154
+ }
155
+ // Restrict navigation to stay within the context tree
156
+ const normalizedItemPath = path.resolve(selectedItem.path);
157
+ const isValid = normalizedItemPath.startsWith(contextTreePath);
158
+ if (isValid) {
159
+ // Valid selection - proceed
160
+ return selectedItem.path;
161
+ }
162
+ // Invalid selection - retry
163
+ this.log(chalk.red('Invalid selection. Please choose a valid location within the context tree.'));
164
+ }
165
+ catch {
166
+ // Error occurred
167
+ return null;
168
+ }
169
+ }
170
+ }
171
+ /**
172
+ * Open a file in the default editor
173
+ * @param filePath - The path to the file to open
174
+ */
175
+ async openFile(filePath) {
176
+ await open(filePath);
177
+ }
178
+ /**
179
+ * Prompt user to enter topic name with validation
180
+ * @param targetPath - The path where the topic folder will be created
181
+ * @returns The topic name or null if cancelled
182
+ */
183
+ async promptForTopicName(targetPath) {
184
+ try {
185
+ const topicName = await input({
186
+ message: 'New topic name:',
187
+ validate: (value) => this.validateTopicName(value, targetPath),
188
+ });
189
+ return topicName.trim();
190
+ }
191
+ catch {
192
+ return null;
193
+ }
194
+ }
195
+ async run() {
196
+ const { args, flags } = await this.parse(Curate);
197
+ // Determine mode: autonomous if context is provided via args
198
+ const contextInput = args.context;
199
+ // Autonomous mode: use CipherAgent to process context
200
+ // Interactive mode: manually prompt for domain/topic/context
201
+ return contextInput ? this.runAutonomous(contextInput, flags) : this.runInteractive();
202
+ }
203
+ /**
204
+ * Write content to context tree at given path
205
+ */
206
+ async writeToContextTree(selectedPath, content) {
207
+ const targetPath = path.join(CONTEXT_TREE_PATH, selectedPath);
208
+ const contextFilePath = path.join(targetPath, CONTEXT_FILE);
209
+ // Create directories if they don't exist
210
+ fs.mkdirSync(targetPath, { recursive: true });
211
+ // Append or create context file
212
+ const timestamp = new Date().toISOString();
213
+ const entry = `\n## Added on ${timestamp}\n\n${content}\n`;
214
+ const isNewFile = !fs.existsSync(contextFilePath);
215
+ const title = path.basename(selectedPath); // Use last segment as title
216
+ if (isNewFile) {
217
+ fs.writeFileSync(contextFilePath, `# ${title}\n${entry}`, 'utf8');
218
+ }
219
+ else {
220
+ fs.appendFileSync(contextFilePath, entry, 'utf8');
221
+ }
222
+ const action = isNewFile ? 'Created' : 'Updated';
223
+ this.log(`\n✓ ${action}: ${contextFilePath}`);
224
+ }
225
+ /**
226
+ * Handle workspace not initialized error
227
+ */
228
+ handleWorkspaceError(_error) {
229
+ const message = 'Project not initialized. Please run "brv init" to select your team and workspace.';
230
+ exitWithCode(ExitCode.VALIDATION_ERROR, message);
231
+ }
232
+ /**
233
+ * Run in autonomous mode using CipherAgent
234
+ */
235
+ async runAutonomous(content, flags) {
236
+ const { projectConfigStore, trackingService } = this.createServices();
237
+ try {
238
+ // Get authentication token
239
+ const tokenStore = new KeychainTokenStore();
240
+ const token = await tokenStore.load();
241
+ if (!token) {
242
+ exitWithCode(ExitCode.CONFIG_ERROR, 'Authentication required. Please run "brv login" first.');
243
+ }
244
+ // Load project config
245
+ const brvConfig = await projectConfigStore.read();
246
+ // Validate workspace is initialized
247
+ if (!brvConfig) {
248
+ throw new WorkspaceNotInitializedError('Project not initialized. Please run "brv init" to select your team and workspace.', '.brv');
249
+ }
250
+ // Create LLM config
251
+ const model = flags.model ?? (flags.apiKey ? 'google/gemini-2.5-pro' : 'gemini-2.5-pro');
252
+ const envConfig = getCurrentConfig();
253
+ const llmConfig = {
254
+ accessToken: token.accessToken,
255
+ fileSystemConfig: { workingDirectory: process.cwd() },
256
+ grpcEndpoint: envConfig.llmGrpcEndpoint,
257
+ maxIterations: 10,
258
+ maxTokens: 8192,
259
+ model,
260
+ openRouterApiKey: flags.apiKey,
261
+ projectId: PROJECT,
262
+ sessionKey: token.sessionKey,
263
+ teamId: brvConfig?.teamId ?? '',
264
+ temperature: 0.7,
265
+ verbose: flags.verbose ?? false,
266
+ };
267
+ // Create and start CipherAgent
268
+ const agent = new CipherAgent(llmConfig, brvConfig);
269
+ this.log('Starting autonomous context tree curation...');
270
+ await agent.start();
271
+ try {
272
+ const sessionId = this.generateSessionId();
273
+ // Setup event listeners
274
+ this.setupEventListeners(agent, flags.verbose ?? false);
275
+ // Execute with autonomous mode and add commandType
276
+ const prompt = `Add the following context to the context tree:\n\n${content}`;
277
+ const response = await agent.execute(prompt, sessionId, {
278
+ executionContext: { commandType: 'curate' },
279
+ mode: 'autonomous',
280
+ });
281
+ this.log('\nCipherAgent Response:');
282
+ this.log(response);
283
+ await trackingService.track('mem:curate');
284
+ }
285
+ finally {
286
+ // console.log('Logic for agent stopping and resource cleanup may go here!')
287
+ }
288
+ }
289
+ catch (error) {
290
+ if (error instanceof WorkspaceNotInitializedError) {
291
+ this.handleWorkspaceError(error);
292
+ return;
293
+ }
294
+ // Throw error to let oclif handle exit code
295
+ this.error(error instanceof Error ? error.message : 'Runtime error occurred', { exit: ExitCode.RUNTIME_ERROR });
296
+ }
297
+ }
298
+ /**
299
+ * Run in interactive mode with manual prompts
300
+ */
301
+ async runInteractive() {
302
+ const { trackingService } = this.createServices();
303
+ try {
304
+ // Navigate to target location in context tree
305
+ const targetPath = await this.navigateContextTree();
306
+ if (!targetPath) {
307
+ this.log('\nOperation cancelled.');
308
+ return;
309
+ }
310
+ // Prompt for topic name with validation
311
+ const topicName = await this.promptForTopicName(targetPath);
312
+ if (!topicName) {
313
+ this.log('\nOperation cancelled.');
314
+ return;
315
+ }
316
+ // Create the topic folder with context.md
317
+ const contextFilePath = this.createTopicWithContextFile(targetPath, topicName);
318
+ this.log(`\nCreated: ${contextFilePath}`);
319
+ // Track the event
320
+ trackingService.track('mem:curate');
321
+ // Auto-open context.md in default editor
322
+ this.log('Opening context.md for editing...');
323
+ await this.openFile(contextFilePath);
324
+ }
325
+ catch (error) {
326
+ this.error(error instanceof Error ? error.message : 'Unexpected error occurred');
327
+ }
328
+ }
329
+ /**
330
+ * Setup event listeners for CipherAgent
331
+ */
332
+ setupEventListeners(agent, verbose) {
333
+ if (!agent.agentEventBus) {
334
+ throw new Error('Agent event bus not initialized');
335
+ }
336
+ const eventBus = agent.agentEventBus;
337
+ if (verbose) {
338
+ // Verbose mode: show detailed events
339
+ eventBus.on('llmservice:thinking', () => {
340
+ this.log('🤔 [Event] LLM is thinking...');
341
+ });
342
+ eventBus.on('llmservice:response', (payload) => {
343
+ this.log(`✅ [Event] LLM Response (${payload.provider}/${payload.model})`);
344
+ });
345
+ eventBus.on('llmservice:toolCall', (payload) => {
346
+ const formattedCall = formatToolCall(payload.toolName, payload.args);
347
+ this.log(`🔧 [Event] Tool Call: ${formattedCall}`);
348
+ });
349
+ eventBus.on('llmservice:toolResult', (payload) => {
350
+ const resultSummary = formatToolResult(payload.toolName, payload.success, payload.result, payload.error);
351
+ if (payload.success) {
352
+ this.log(`✓ [Event] Tool Success: ${payload.toolName} → ${resultSummary}`);
353
+ }
354
+ else {
355
+ this.log(`✗ [Event] Tool Error: ${payload.toolName} → ${resultSummary}`);
356
+ }
357
+ });
358
+ eventBus.on('llmservice:error', (payload) => {
359
+ this.log(`❌ [Event] LLM Error: ${payload.error}`);
360
+ });
361
+ }
362
+ else {
363
+ // Non-verbose mode: show concise tool progress
364
+ eventBus.on('llmservice:toolCall', (payload) => {
365
+ this.log(`🔧 ${payload.toolName} → Executing...`);
366
+ });
367
+ eventBus.on('llmservice:toolResult', (payload) => {
368
+ if (payload.success) {
369
+ this.log(`✅ ${payload.toolName} → Complete`);
370
+ }
371
+ else {
372
+ this.log(`❌ ${payload.toolName} → Failed: ${payload.error ?? 'Unknown error'}`);
373
+ }
374
+ });
375
+ eventBus.on('llmservice:error', (payload) => {
376
+ this.log(addErrorPrefix(payload.error));
377
+ });
378
+ }
379
+ }
380
+ validateTopicName(value, targetPath) {
381
+ const trimmed = value.trim();
382
+ if (!trimmed) {
383
+ return 'Topic name cannot be empty';
384
+ }
385
+ // Check for invalid characters in folder names (filesystem restrictions)
386
+ if (/[/\0]/.test(trimmed)) {
387
+ return 'Topic name cannot contain "/" or null characters';
388
+ }
389
+ // Check if folder already exists
390
+ const topicPath = path.join(targetPath, trimmed);
391
+ if (fs.existsSync(topicPath)) {
392
+ return `Topic "${trimmed}" already exists at this location`;
393
+ }
394
+ return true;
395
+ }
396
+ }
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ import { ICodingAgentLogWatcher } from '../core/interfaces/cipher/i-coding-agent-log-watcher.js';
3
+ import { IProjectConfigStore } from '../core/interfaces/i-project-config-store.js';
4
+ export default class Foo extends Command {
5
+ static description: string;
6
+ static hidden: boolean;
7
+ protected createServices(): Promise<{
8
+ codingAgentLogWatcher: ICodingAgentLogWatcher;
9
+ projectConfigStore: IProjectConfigStore;
10
+ }>;
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,61 @@
1
+ import { Command } from '@oclif/core';
2
+ import { isDevelopment } from '../config/environment.js';
3
+ import { CodingAgentLogParser } from '../infra/cipher/parsers/coding-agent-log-parser.js';
4
+ import { CodingAgentLogWatcher } from '../infra/cipher/watcher/coding-agent-log-watcher.js';
5
+ import { ProjectConfigStore } from '../infra/config/file-config-store.js';
6
+ import { FileWatcherService } from '../infra/watcher/file-watcher-service.js';
7
+ export default class Foo extends Command {
8
+ static description = 'Purely for testing CodingAgentLogWatcher [Development only]';
9
+ static hidden = !isDevelopment();
10
+ async createServices() {
11
+ const projectConfigStore = new ProjectConfigStore();
12
+ const fileWatcherService = new FileWatcherService();
13
+ const codingAgentLogParser = new CodingAgentLogParser();
14
+ const codingAgentLogWatcher = new CodingAgentLogWatcher(fileWatcherService, codingAgentLogParser);
15
+ return {
16
+ codingAgentLogWatcher,
17
+ projectConfigStore,
18
+ };
19
+ }
20
+ async run() {
21
+ if (!isDevelopment()) {
22
+ this.error('This command is only available in development environment');
23
+ }
24
+ const { codingAgentLogWatcher, projectConfigStore } = await this.createServices();
25
+ const projectConfig = await projectConfigStore.read();
26
+ if (projectConfig === undefined) {
27
+ this.error('No project config found. Run "brv init" first.');
28
+ }
29
+ // Defensive checking nill
30
+ if (projectConfig.chatLogPath === undefined) {
31
+ this.error('No chat log path configured in project config. Run "brv init" first.');
32
+ }
33
+ if (projectConfig.ide === undefined) {
34
+ this.error('No coding agent selected. Run "brv init" first.');
35
+ }
36
+ this.log(`Watching ${projectConfig.ide} log files...`);
37
+ await codingAgentLogWatcher.start({
38
+ codingAgentInfo: {
39
+ chatLogPath: projectConfig.chatLogPath,
40
+ name: projectConfig.ide,
41
+ },
42
+ onCleanSession: (cleanSession) => new Promise((resolve) => {
43
+ this.log(`New Clean Session from ${cleanSession.type}:`);
44
+ this.log(`Clean Session title: ${cleanSession.title}`);
45
+ this.log('Clean Session messages:');
46
+ for (const message of cleanSession.messages) {
47
+ this.log(`${JSON.stringify(message, undefined, 2)}]\n`);
48
+ }
49
+ this.log(`Clean Session ID: ${cleanSession.id}`);
50
+ this.log(`Clean Session Metadata: ${JSON.stringify(cleanSession.metadata, undefined, 2)}`);
51
+ resolve();
52
+ this.log(`Clean Session timestamp: ${cleanSession.timestamp}`);
53
+ this.log(`Clean Session workspace paths:`);
54
+ for (const workspacePath of cleanSession.workspacePaths) {
55
+ this.log(`${workspacePath}`);
56
+ }
57
+ this.log('\n\n');
58
+ }),
59
+ });
60
+ }
61
+ }
@@ -5,6 +5,9 @@ import { ITrackingService } from '../core/interfaces/i-tracking-service.js';
5
5
  export default class GenRules extends Command {
6
6
  static description: string;
7
7
  static examples: string[];
8
+ static flags: {
9
+ agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
8
11
  protected createServices(): {
9
12
  ruleWriterService: IRuleWriterService;
10
13
  trackingService: ITrackingService;