byterover-cli 0.3.4 → 0.4.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 (346) hide show
  1. package/README.md +119 -63
  2. package/bin/dev.js +8 -1
  3. package/bin/run.js +7 -0
  4. package/dist/commands/cipher-agent/run.d.ts +30 -0
  5. package/dist/commands/cipher-agent/run.js +123 -61
  6. package/dist/commands/cipher-agent/set-prompt.d.ts +2 -0
  7. package/dist/commands/cipher-agent/set-prompt.js +13 -8
  8. package/dist/commands/cipher-agent/show-prompt.d.ts +2 -0
  9. package/dist/commands/cipher-agent/show-prompt.js +17 -12
  10. package/dist/commands/curate.d.ts +3 -60
  11. package/dist/commands/curate.js +45 -341
  12. package/dist/commands/foo.d.ts +4 -2
  13. package/dist/commands/foo.js +21 -16
  14. package/dist/commands/main.d.ts +9 -0
  15. package/dist/commands/main.js +34 -0
  16. package/dist/commands/query.d.ts +2 -48
  17. package/dist/commands/query.js +19 -287
  18. package/dist/commands/status.d.ts +2 -13
  19. package/dist/commands/status.js +12 -91
  20. package/dist/commands/watch.d.ts +2 -0
  21. package/dist/commands/watch.js +23 -19
  22. package/dist/config/environment.d.ts +1 -1
  23. package/dist/config/environment.js +2 -2
  24. package/dist/constants.d.ts +4 -5
  25. package/dist/constants.js +5 -5
  26. package/dist/core/domain/cipher/errors/storage-error.d.ts +89 -0
  27. package/dist/core/domain/cipher/errors/storage-error.js +130 -0
  28. package/dist/core/domain/cipher/queue/types.d.ts +71 -0
  29. package/dist/core/domain/cipher/queue/types.js +9 -0
  30. package/dist/core/domain/cipher/storage/message-storage-types.d.ts +218 -0
  31. package/dist/core/domain/cipher/storage/message-storage-types.js +18 -0
  32. package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
  33. package/dist/core/domain/cipher/tools/constants.js +1 -0
  34. package/dist/core/domain/entities/event.d.ts +1 -1
  35. package/dist/core/domain/entities/event.js +5 -0
  36. package/dist/core/domain/entities/global-config.d.ts +36 -0
  37. package/dist/core/domain/entities/global-config.js +66 -0
  38. package/dist/core/domain/knowledge/directory-manager.d.ts +10 -0
  39. package/dist/core/domain/knowledge/directory-manager.js +18 -0
  40. package/dist/core/domain/knowledge/markdown-writer.d.ts +9 -0
  41. package/dist/core/domain/knowledge/markdown-writer.js +51 -1
  42. package/dist/core/interfaces/cipher/i-agent-storage.d.ts +152 -0
  43. package/dist/core/interfaces/cipher/i-agent-storage.js +1 -0
  44. package/dist/core/interfaces/cipher/i-cipher-agent.d.ts +2 -0
  45. package/dist/core/interfaces/cipher/i-key-storage.d.ts +91 -0
  46. package/dist/core/interfaces/cipher/i-key-storage.js +1 -0
  47. package/dist/core/interfaces/i-global-config-store.d.ts +34 -0
  48. package/dist/core/interfaces/i-global-config-store.js +1 -0
  49. package/dist/core/interfaces/i-onboarding-preference-store.d.ts +20 -0
  50. package/dist/core/interfaces/i-onboarding-preference-store.js +1 -0
  51. package/dist/core/interfaces/i-terminal.d.ts +146 -0
  52. package/dist/core/interfaces/i-terminal.js +1 -0
  53. package/dist/core/interfaces/i-workspace-detector-service.d.ts +8 -0
  54. package/dist/core/interfaces/i-workspace-detector-service.js +1 -0
  55. package/dist/core/interfaces/usecase/i-clear-use-case.d.ts +6 -0
  56. package/dist/core/interfaces/usecase/i-clear-use-case.js +1 -0
  57. package/dist/core/interfaces/usecase/i-curate-use-case.d.ts +10 -0
  58. package/dist/core/interfaces/usecase/i-curate-use-case.js +1 -0
  59. package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +3 -0
  60. package/dist/core/interfaces/usecase/i-generate-rules-use-case.js +1 -0
  61. package/dist/core/interfaces/usecase/i-init-use-case.d.ts +5 -0
  62. package/dist/core/interfaces/usecase/i-init-use-case.js +1 -0
  63. package/dist/core/interfaces/usecase/i-login-use-case.d.ts +3 -0
  64. package/dist/core/interfaces/usecase/i-login-use-case.js +1 -0
  65. package/dist/core/interfaces/usecase/i-logout-use-case.d.ts +5 -0
  66. package/dist/core/interfaces/usecase/i-logout-use-case.js +1 -0
  67. package/dist/core/interfaces/usecase/i-pull-use-case.d.ts +5 -0
  68. package/dist/core/interfaces/usecase/i-pull-use-case.js +1 -0
  69. package/dist/core/interfaces/usecase/i-push-use-case.d.ts +6 -0
  70. package/dist/core/interfaces/usecase/i-push-use-case.js +1 -0
  71. package/dist/core/interfaces/usecase/i-query-use-case.d.ts +9 -0
  72. package/dist/core/interfaces/usecase/i-query-use-case.js +1 -0
  73. package/dist/core/interfaces/usecase/i-space-list-use-case.d.ts +3 -0
  74. package/dist/core/interfaces/usecase/i-space-list-use-case.js +1 -0
  75. package/dist/core/interfaces/usecase/i-space-switch-use-case.d.ts +3 -0
  76. package/dist/core/interfaces/usecase/i-space-switch-use-case.js +1 -0
  77. package/dist/core/interfaces/usecase/i-status-use-case.d.ts +5 -0
  78. package/dist/core/interfaces/usecase/i-status-use-case.js +1 -0
  79. package/dist/hooks/init/update-notifier.js +1 -5
  80. package/dist/hooks/init/welcome.js +1 -2
  81. package/dist/infra/cipher/agent-service-factory.d.ts +13 -6
  82. package/dist/infra/cipher/agent-service-factory.js +40 -16
  83. package/dist/infra/cipher/cipher-agent.js +4 -4
  84. package/dist/infra/cipher/consumer/consumer-lock.d.ts +20 -0
  85. package/dist/infra/cipher/consumer/consumer-lock.js +40 -0
  86. package/dist/infra/cipher/consumer/consumer-service.d.ts +99 -0
  87. package/dist/infra/cipher/consumer/consumer-service.js +165 -0
  88. package/dist/infra/cipher/consumer/execution-consumer.d.ts +121 -0
  89. package/dist/infra/cipher/consumer/execution-consumer.js +523 -0
  90. package/dist/infra/cipher/consumer/index.d.ts +33 -0
  91. package/dist/infra/cipher/consumer/index.js +33 -0
  92. package/dist/infra/cipher/consumer/queue-polling-service.d.ts +120 -0
  93. package/dist/infra/cipher/consumer/queue-polling-service.js +248 -0
  94. package/dist/infra/cipher/http/internal-llm-http-service.d.ts +94 -0
  95. package/dist/infra/cipher/http/internal-llm-http-service.js +118 -0
  96. package/dist/infra/cipher/llm/context/compaction/compaction-service.d.ts +106 -0
  97. package/dist/infra/cipher/llm/context/compaction/compaction-service.js +132 -0
  98. package/dist/infra/cipher/llm/context/compaction/index.d.ts +9 -0
  99. package/dist/infra/cipher/llm/context/compaction/index.js +9 -0
  100. package/dist/infra/cipher/llm/context/context-manager.d.ts +46 -2
  101. package/dist/infra/cipher/llm/context/context-manager.js +68 -4
  102. package/dist/infra/cipher/llm/context/rw-lock.d.ts +72 -0
  103. package/dist/infra/cipher/llm/context/rw-lock.js +145 -0
  104. package/dist/infra/cipher/llm/generators/byterover-content-generator.d.ts +7 -7
  105. package/dist/infra/cipher/llm/generators/byterover-content-generator.js +8 -8
  106. package/dist/infra/cipher/llm/internal-llm-service.js +2 -0
  107. package/dist/infra/cipher/session/session-manager.d.ts +4 -4
  108. package/dist/infra/cipher/session/session-manager.js +5 -5
  109. package/dist/infra/cipher/storage/agent-storage.d.ts +246 -0
  110. package/dist/infra/cipher/storage/agent-storage.js +956 -0
  111. package/dist/infra/cipher/storage/dual-format-history-storage.d.ts +77 -0
  112. package/dist/infra/cipher/storage/dual-format-history-storage.js +149 -0
  113. package/dist/infra/cipher/storage/granular-history-storage.d.ts +65 -0
  114. package/dist/infra/cipher/storage/granular-history-storage.js +118 -0
  115. package/dist/infra/cipher/storage/message-storage-service.d.ts +108 -0
  116. package/dist/infra/cipher/storage/message-storage-service.js +529 -0
  117. package/dist/infra/cipher/storage/process-utils.d.ts +16 -0
  118. package/dist/infra/cipher/storage/process-utils.js +43 -0
  119. package/dist/infra/cipher/storage/sqlite-key-storage.d.ts +105 -0
  120. package/dist/infra/cipher/storage/sqlite-key-storage.js +404 -0
  121. package/dist/infra/cipher/system-prompt/simple-prompt-factory.d.ts +1 -0
  122. package/dist/infra/cipher/system-prompt/simple-prompt-factory.js +7 -0
  123. package/dist/infra/cipher/tools/default-policy-rules.js +1 -1
  124. package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +10 -0
  125. package/dist/infra/cipher/tools/implementations/curate-tool.js +371 -0
  126. package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.js +11 -8
  127. package/dist/infra/cipher/tools/tool-manager.d.ts +8 -2
  128. package/dist/infra/cipher/tools/tool-manager.js +29 -2
  129. package/dist/infra/cipher/tools/tool-registry.js +7 -0
  130. package/dist/infra/http/authenticated-http-client.d.ts +21 -0
  131. package/dist/infra/http/authenticated-http-client.js +38 -0
  132. package/dist/infra/repl/commands/arg-parser.d.ts +97 -0
  133. package/dist/infra/repl/commands/arg-parser.js +129 -0
  134. package/dist/infra/repl/commands/clear-command.d.ts +5 -0
  135. package/dist/infra/repl/commands/clear-command.js +61 -0
  136. package/dist/infra/repl/commands/curate-command.d.ts +9 -0
  137. package/dist/infra/repl/commands/curate-command.js +88 -0
  138. package/dist/infra/repl/commands/gen-rules-command.d.ts +7 -0
  139. package/dist/infra/repl/commands/gen-rules-command.js +38 -0
  140. package/dist/infra/repl/commands/index.d.ts +8 -0
  141. package/dist/infra/repl/commands/index.js +36 -0
  142. package/dist/infra/repl/commands/init-command.d.ts +7 -0
  143. package/dist/infra/repl/commands/init-command.js +83 -0
  144. package/dist/infra/repl/commands/login-command.d.ts +7 -0
  145. package/dist/infra/repl/commands/login-command.js +50 -0
  146. package/dist/infra/repl/commands/logout-command.d.ts +5 -0
  147. package/dist/infra/repl/commands/logout-command.js +48 -0
  148. package/dist/infra/repl/commands/pull-command.d.ts +5 -0
  149. package/dist/infra/repl/commands/pull-command.js +61 -0
  150. package/dist/infra/repl/commands/push-command.d.ts +5 -0
  151. package/dist/infra/repl/commands/push-command.js +66 -0
  152. package/dist/infra/repl/commands/query-command.d.ts +5 -0
  153. package/dist/infra/repl/commands/query-command.js +66 -0
  154. package/dist/infra/repl/commands/space/index.d.ts +5 -0
  155. package/dist/infra/repl/commands/space/index.js +14 -0
  156. package/dist/infra/repl/commands/space/list-command.d.ts +5 -0
  157. package/dist/infra/repl/commands/space/list-command.js +70 -0
  158. package/dist/infra/repl/commands/space/switch-command.d.ts +5 -0
  159. package/dist/infra/repl/commands/space/switch-command.js +37 -0
  160. package/dist/infra/repl/commands/status-command.d.ts +5 -0
  161. package/dist/infra/repl/commands/status-command.js +39 -0
  162. package/dist/infra/repl/repl-startup.d.ts +18 -0
  163. package/dist/infra/repl/repl-startup.js +26 -0
  164. package/dist/infra/storage/file-global-config-store.d.ts +22 -0
  165. package/dist/infra/storage/file-global-config-store.js +65 -0
  166. package/dist/infra/storage/file-onboarding-preference-store.d.ts +10 -0
  167. package/dist/infra/storage/file-onboarding-preference-store.js +46 -0
  168. package/dist/infra/terminal/oclif-terminal.d.ts +19 -0
  169. package/dist/infra/terminal/oclif-terminal.js +60 -0
  170. package/dist/infra/terminal/repl-terminal.d.ts +31 -0
  171. package/dist/infra/terminal/repl-terminal.js +116 -0
  172. package/dist/infra/tracking/mixpanel-tracking-service.d.ts +11 -1
  173. package/dist/infra/tracking/mixpanel-tracking-service.js +18 -13
  174. package/dist/infra/usecase/clear-use-case.d.ts +20 -0
  175. package/dist/infra/usecase/clear-use-case.js +58 -0
  176. package/dist/infra/usecase/curate-use-case.d.ts +66 -0
  177. package/dist/infra/usecase/curate-use-case.js +283 -0
  178. package/dist/{commands/gen-rules.d.ts → infra/usecase/generate-rules-use-case.d.ts} +14 -20
  179. package/dist/{commands/gen-rules.js → infra/usecase/generate-rules-use-case.js} +59 -78
  180. package/dist/infra/usecase/init-use-case.d.ts +139 -0
  181. package/dist/{commands/init.js → infra/usecase/init-use-case.js} +184 -230
  182. package/dist/infra/usecase/login-use-case.d.ts +28 -0
  183. package/dist/infra/usecase/login-use-case.js +88 -0
  184. package/dist/infra/usecase/logout-use-case.d.ts +22 -0
  185. package/dist/infra/usecase/logout-use-case.js +51 -0
  186. package/dist/infra/usecase/pull-use-case.d.ts +35 -0
  187. package/dist/infra/usecase/pull-use-case.js +89 -0
  188. package/dist/infra/usecase/push-use-case.d.ts +37 -0
  189. package/dist/infra/usecase/push-use-case.js +124 -0
  190. package/dist/infra/usecase/query-use-case.d.ts +78 -0
  191. package/dist/infra/usecase/query-use-case.js +401 -0
  192. package/dist/infra/usecase/space-list-use-case.d.ts +27 -0
  193. package/dist/infra/usecase/space-list-use-case.js +64 -0
  194. package/dist/infra/usecase/space-switch-use-case.d.ts +36 -0
  195. package/dist/infra/usecase/space-switch-use-case.js +140 -0
  196. package/dist/infra/usecase/status-use-case.d.ts +27 -0
  197. package/dist/infra/usecase/status-use-case.js +97 -0
  198. package/dist/infra/workspace/workspace-detector-service.d.ts +3 -6
  199. package/dist/resources/prompts/curate-context-tree-curation.yml +23 -11
  200. package/dist/resources/prompts/query-context-tree-retrieval.yml +3 -4
  201. package/dist/resources/prompts/system-prompt.yml +1 -1
  202. package/dist/resources/prompts/tool-outputs.yml +4 -3
  203. package/dist/templates/sections/command-reference.md +12 -0
  204. package/dist/templates/sections/workflow.md +10 -1
  205. package/dist/tui/app.d.ts +9 -0
  206. package/dist/tui/app.js +26 -0
  207. package/dist/tui/components/enter-prompt.d.ts +13 -0
  208. package/dist/tui/components/enter-prompt.js +15 -0
  209. package/dist/tui/components/execution/execution-changes.d.ts +14 -0
  210. package/dist/tui/components/execution/execution-changes.js +15 -0
  211. package/dist/tui/components/execution/execution-content.d.ts +25 -0
  212. package/dist/tui/components/execution/execution-content.js +67 -0
  213. package/dist/tui/components/execution/execution-input.d.ts +12 -0
  214. package/dist/tui/components/execution/execution-input.js +16 -0
  215. package/dist/tui/components/execution/execution-progress.d.ts +21 -0
  216. package/dist/tui/components/execution/execution-progress.js +21 -0
  217. package/dist/tui/components/execution/execution-status.d.ts +13 -0
  218. package/dist/tui/components/execution/execution-status.js +19 -0
  219. package/dist/tui/components/execution/index.d.ts +11 -0
  220. package/dist/tui/components/execution/index.js +11 -0
  221. package/dist/tui/components/execution/log-item.d.ts +17 -0
  222. package/dist/tui/components/execution/log-item.js +25 -0
  223. package/dist/tui/components/footer.d.ts +5 -0
  224. package/dist/tui/components/footer.js +12 -0
  225. package/dist/tui/components/header.d.ts +18 -0
  226. package/dist/tui/components/header.js +18 -0
  227. package/dist/tui/components/index.d.ts +17 -0
  228. package/dist/tui/components/index.js +14 -0
  229. package/dist/tui/components/inline-prompts/index.d.ts +15 -0
  230. package/dist/tui/components/inline-prompts/index.js +10 -0
  231. package/dist/tui/components/inline-prompts/inline-confirm.d.ts +17 -0
  232. package/dist/tui/components/inline-prompts/inline-confirm.js +32 -0
  233. package/dist/tui/components/inline-prompts/inline-file-selector.d.ts +43 -0
  234. package/dist/tui/components/inline-prompts/inline-file-selector.js +185 -0
  235. package/dist/tui/components/inline-prompts/inline-input.d.ts +19 -0
  236. package/dist/tui/components/inline-prompts/inline-input.js +32 -0
  237. package/dist/tui/components/inline-prompts/inline-search.d.ts +20 -0
  238. package/dist/tui/components/inline-prompts/inline-search.js +50 -0
  239. package/dist/tui/components/inline-prompts/inline-select.d.ts +20 -0
  240. package/dist/tui/components/inline-prompts/inline-select.js +34 -0
  241. package/dist/tui/components/logo.d.ts +43 -0
  242. package/dist/tui/components/logo.js +103 -0
  243. package/dist/tui/components/message-item.d.ts +12 -0
  244. package/dist/tui/components/message-item.js +12 -0
  245. package/dist/tui/components/onboarding/copyable-prompt.d.ts +15 -0
  246. package/dist/tui/components/onboarding/copyable-prompt.js +65 -0
  247. package/dist/tui/components/onboarding/index.d.ts +7 -0
  248. package/dist/tui/components/onboarding/index.js +6 -0
  249. package/dist/tui/components/onboarding/onboarding-flow.d.ts +13 -0
  250. package/dist/tui/components/onboarding/onboarding-flow.js +304 -0
  251. package/dist/tui/components/onboarding/onboarding-step.d.ts +23 -0
  252. package/dist/tui/components/onboarding/onboarding-step.js +12 -0
  253. package/dist/tui/components/output-log.d.ts +14 -0
  254. package/dist/tui/components/output-log.js +13 -0
  255. package/dist/tui/components/scrollable-list.d.ts +30 -0
  256. package/dist/tui/components/scrollable-list.js +121 -0
  257. package/dist/tui/components/suggestions.d.ts +16 -0
  258. package/dist/tui/components/suggestions.js +162 -0
  259. package/dist/tui/components/tab-bar.d.ts +10 -0
  260. package/dist/tui/components/tab-bar.js +12 -0
  261. package/dist/tui/constants.d.ts +11 -0
  262. package/dist/tui/constants.js +13 -0
  263. package/dist/tui/contexts/auth-context.d.ts +30 -0
  264. package/dist/tui/contexts/auth-context.js +153 -0
  265. package/dist/tui/contexts/consumer.d.ts +31 -0
  266. package/dist/tui/contexts/consumer.js +56 -0
  267. package/dist/tui/contexts/index.d.ts +6 -0
  268. package/dist/tui/contexts/index.js +6 -0
  269. package/dist/tui/contexts/onboarding-context.d.ts +43 -0
  270. package/dist/tui/contexts/onboarding-context.js +181 -0
  271. package/dist/tui/contexts/services-context.d.ts +29 -0
  272. package/dist/tui/contexts/services-context.js +20 -0
  273. package/dist/tui/contexts/use-commands.d.ts +29 -0
  274. package/dist/tui/contexts/use-commands.js +53 -0
  275. package/dist/tui/contexts/use-mode.d.ts +43 -0
  276. package/dist/tui/contexts/use-mode.js +76 -0
  277. package/dist/tui/contexts/use-theme.d.ts +53 -0
  278. package/dist/tui/contexts/use-theme.js +60 -0
  279. package/dist/tui/hooks/index.d.ts +17 -0
  280. package/dist/tui/hooks/index.js +14 -0
  281. package/dist/tui/hooks/use-activity-logs.d.ts +26 -0
  282. package/dist/tui/hooks/use-activity-logs.js +90 -0
  283. package/dist/tui/hooks/use-consumer.d.ts +12 -0
  284. package/dist/tui/hooks/use-consumer.js +50 -0
  285. package/dist/tui/hooks/use-onboarding.d.ts +7 -0
  286. package/dist/tui/hooks/use-onboarding.js +6 -0
  287. package/dist/tui/hooks/use-queue-polling.d.ts +31 -0
  288. package/dist/tui/hooks/use-queue-polling.js +90 -0
  289. package/dist/tui/hooks/use-slash-command-processor.d.ts +16 -0
  290. package/dist/tui/hooks/use-slash-command-processor.js +132 -0
  291. package/dist/tui/hooks/use-slash-completion.d.ts +30 -0
  292. package/dist/tui/hooks/use-slash-completion.js +230 -0
  293. package/dist/tui/hooks/use-tab-navigation.d.ts +10 -0
  294. package/dist/tui/hooks/use-tab-navigation.js +35 -0
  295. package/dist/tui/hooks/use-visible-window.d.ts +22 -0
  296. package/dist/tui/hooks/use-visible-window.js +37 -0
  297. package/dist/tui/index.d.ts +1 -0
  298. package/dist/tui/index.js +1 -0
  299. package/dist/tui/providers/app-providers.d.ts +25 -0
  300. package/dist/tui/providers/app-providers.js +9 -0
  301. package/dist/tui/types/commands.d.ts +252 -0
  302. package/dist/tui/types/commands.js +16 -0
  303. package/dist/tui/types/dialogs.d.ts +37 -0
  304. package/dist/tui/types/dialogs.js +4 -0
  305. package/dist/tui/types/index.d.ts +11 -0
  306. package/dist/tui/types/index.js +7 -0
  307. package/dist/tui/types/messages.d.ts +55 -0
  308. package/dist/tui/types/messages.js +4 -0
  309. package/dist/tui/types/prompts.d.ts +100 -0
  310. package/dist/tui/types/prompts.js +4 -0
  311. package/dist/tui/types/ui.d.ts +14 -0
  312. package/dist/tui/types/ui.js +4 -0
  313. package/dist/tui/types.d.ts +1 -0
  314. package/dist/tui/types.js +1 -0
  315. package/dist/tui/views/command-view.d.ts +12 -0
  316. package/dist/tui/views/command-view.js +451 -0
  317. package/dist/tui/views/index.d.ts +6 -0
  318. package/dist/tui/views/index.js +6 -0
  319. package/dist/tui/views/login-view.d.ts +10 -0
  320. package/dist/tui/views/login-view.js +30 -0
  321. package/dist/tui/views/logs-view.d.ts +11 -0
  322. package/dist/tui/views/logs-view.js +73 -0
  323. package/dist/utils/file-validator.d.ts +16 -0
  324. package/dist/utils/file-validator.js +81 -0
  325. package/dist/utils/global-config-path.d.ts +15 -0
  326. package/dist/utils/global-config-path.js +38 -0
  327. package/oclif.manifest.json +29 -315
  328. package/package.json +11 -4
  329. package/dist/commands/clear.d.ts +0 -19
  330. package/dist/commands/clear.js +0 -78
  331. package/dist/commands/init.d.ts +0 -130
  332. package/dist/commands/login.d.ts +0 -22
  333. package/dist/commands/login.js +0 -108
  334. package/dist/commands/logout.d.ts +0 -16
  335. package/dist/commands/logout.js +0 -61
  336. package/dist/commands/pull.d.ts +0 -33
  337. package/dist/commands/pull.js +0 -115
  338. package/dist/commands/push.d.ts +0 -35
  339. package/dist/commands/push.js +0 -160
  340. package/dist/commands/space/list.d.ts +0 -25
  341. package/dist/commands/space/list.js +0 -114
  342. package/dist/commands/space/switch.d.ts +0 -36
  343. package/dist/commands/space/switch.js +0 -160
  344. package/dist/infra/cipher/grpc/internal-llm-grpc-service.d.ts +0 -149
  345. package/dist/infra/cipher/grpc/internal-llm-grpc-service.js +0 -364
  346. package/dist/infra/cipher/grpc/internal-llm-grpc.proto +0 -94
@@ -3,11 +3,14 @@ import { isDevelopment } from '../config/environment.js';
3
3
  import { CodingAgentLogParser } from '../infra/cipher/parsers/coding-agent-log-parser.js';
4
4
  import { CodingAgentLogWatcher } from '../infra/cipher/watcher/coding-agent-log-watcher.js';
5
5
  import { ProjectConfigStore } from '../infra/config/file-config-store.js';
6
+ import { OclifTerminal } from '../infra/terminal/oclif-terminal.js';
6
7
  import { FileWatcherService } from '../infra/watcher/file-watcher-service.js';
7
8
  export default class Foo extends Command {
8
9
  static description = 'Purely for testing CodingAgentLogWatcher [Development only]';
9
10
  static hidden = !isDevelopment();
11
+ terminal = {};
10
12
  async createServices() {
13
+ this.terminal = new OclifTerminal(this);
11
14
  const projectConfigStore = new ProjectConfigStore();
12
15
  const fileWatcherService = new FileWatcherService();
13
16
  const codingAgentLogParser = new CodingAgentLogParser();
@@ -18,43 +21,45 @@ export default class Foo extends Command {
18
21
  };
19
22
  }
20
23
  async run() {
24
+ const { codingAgentLogWatcher, projectConfigStore } = await this.createServices();
21
25
  if (!isDevelopment()) {
22
- this.error('This command is only available in development environment');
26
+ this.terminal.error('This command is only available in development environment');
27
+ return;
23
28
  }
24
- const { codingAgentLogWatcher, projectConfigStore } = await this.createServices();
25
29
  const projectConfig = await projectConfigStore.read();
26
30
  if (projectConfig === undefined) {
27
- this.error('No project config found. Run "brv init" first.');
31
+ this.terminal.error('No project config found. Run "brv init" first.');
32
+ return;
28
33
  }
29
34
  // Defensive checking nill
30
35
  if (projectConfig.chatLogPath === undefined) {
31
- this.error('No chat log path configured in project config. Run "brv init" first.');
36
+ this.terminal.error('No chat log path configured in project config. Run "brv init" first.');
32
37
  }
33
38
  if (projectConfig.ide === undefined) {
34
- this.error('No coding agent selected. Run "brv init" first.');
39
+ this.terminal.error('No coding agent selected. Run "brv init" first.');
35
40
  }
36
- this.log(`Watching ${projectConfig.ide} log files...`);
41
+ this.terminal.log(`Watching ${projectConfig.ide} log files...`);
37
42
  await codingAgentLogWatcher.start({
38
43
  codingAgentInfo: {
39
44
  chatLogPath: projectConfig.chatLogPath,
40
45
  name: projectConfig.ide,
41
46
  },
42
47
  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:');
48
+ this.terminal.log(`New Clean Session from ${cleanSession.type}:`);
49
+ this.terminal.log(`Clean Session title: ${cleanSession.title}`);
50
+ this.terminal.log('Clean Session messages:');
46
51
  for (const message of cleanSession.messages) {
47
- this.log(`${JSON.stringify(message, undefined, 2)}]\n`);
52
+ this.terminal.log(`${JSON.stringify(message, undefined, 2)}]\n`);
48
53
  }
49
- this.log(`Clean Session ID: ${cleanSession.id}`);
50
- this.log(`Clean Session Metadata: ${JSON.stringify(cleanSession.metadata, undefined, 2)}`);
54
+ this.terminal.log(`Clean Session ID: ${cleanSession.id}`);
55
+ this.terminal.log(`Clean Session Metadata: ${JSON.stringify(cleanSession.metadata, undefined, 2)}`);
51
56
  resolve();
52
- this.log(`Clean Session timestamp: ${cleanSession.timestamp}`);
53
- this.log(`Clean Session workspace paths:`);
57
+ this.terminal.log(`Clean Session timestamp: ${cleanSession.timestamp}`);
58
+ this.terminal.log(`Clean Session workspace paths:`);
54
59
  for (const workspacePath of cleanSession.workspacePaths) {
55
- this.log(`${workspacePath}`);
60
+ this.terminal.log(`${workspacePath}`);
56
61
  }
57
- this.log('\n\n');
62
+ this.terminal.log('\n\n');
58
63
  }),
59
64
  });
60
65
  }
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Main extends Command {
3
+ static description: string;
4
+ /**
5
+ * Hide from help listing since this is the default command (only 'brv')
6
+ */
7
+ static hidden: boolean;
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,34 @@
1
+ import { Command } from '@oclif/core';
2
+ import { ProjectConfigStore } from '../infra/config/file-config-store.js';
3
+ import { startRepl } from '../infra/repl/repl-startup.js';
4
+ import { FileGlobalConfigStore } from "../infra/storage/file-global-config-store.js";
5
+ import { FileOnboardingPreferenceStore } from '../infra/storage/file-onboarding-preference-store.js';
6
+ import { KeychainTokenStore } from '../infra/storage/keychain-token-store.js';
7
+ import { MixpanelTrackingService } from '../infra/tracking/mixpanel-tracking-service.js';
8
+ export default class Main extends Command {
9
+ static description = 'ByteRover CLI - Interactive REPL';
10
+ /**
11
+ * Hide from help listing since this is the default command (only 'brv')
12
+ */
13
+ static hidden = true;
14
+ async run() {
15
+ // Check if running in an interactive terminal
16
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
17
+ this.log('ByteRover REPL requires an interactive terminal.');
18
+ this.log("Run 'brv --help' for available commands.");
19
+ return;
20
+ }
21
+ const tokenStore = new KeychainTokenStore();
22
+ const globalConfigStore = new FileGlobalConfigStore();
23
+ const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
24
+ const onboardingPreferenceStore = new FileOnboardingPreferenceStore();
25
+ // Start the interactive REPL
26
+ await startRepl({
27
+ onboardingPreferenceStore,
28
+ projectConfigStore: new ProjectConfigStore(),
29
+ tokenStore,
30
+ trackingService,
31
+ version: this.config.version,
32
+ });
33
+ }
34
+ }
@@ -1,6 +1,5 @@
1
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';
2
+ import type { IQueryUseCase } from '../core/interfaces/usecase/i-query-use-case.js';
4
3
  export default class Query extends Command {
5
4
  static args: {
6
5
  query: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
@@ -13,51 +12,6 @@ export default class Query extends Command {
13
12
  verbose?: import("@oclif/core/interfaces").BooleanFlag<boolean> | undefined;
14
13
  };
15
14
  static strict: boolean;
16
- catch(error: Error & {
17
- oclif?: {
18
- exit: number;
19
- };
20
- }): Promise<void>;
21
- protected createServices(): {
22
- projectConfigStore: IProjectConfigStore;
23
- trackingService: ITrackingService;
24
- };
25
- /**
26
- * Generate a unique session ID for the query agent.
27
- * Uses crypto.randomUUID() for guaranteed uniqueness (122 bits of entropy).
28
- */
29
- protected generateSessionId(): string;
15
+ protected createUseCase(): IQueryUseCase;
30
16
  run(): Promise<void>;
31
- /**
32
- * Format items count from list_directory result
33
- */
34
- private formatItemsCount;
35
- /**
36
- * Format matches count from grep_content result
37
- */
38
- private formatMatchesCount;
39
- /**
40
- * Format tool result summary for display
41
- */
42
- private formatToolResultSummary;
43
- /**
44
- * Format topics count from find_knowledge_topics result
45
- */
46
- private formatTopicsCount;
47
- /**
48
- * Get user-friendly description for a tool
49
- *
50
- * @param toolName - Name of the tool
51
- * @param args - Tool arguments
52
- * @returns User-friendly description
53
- */
54
- private getToolDescription;
55
- /**
56
- * Handle workspace not initialized error
57
- */
58
- private handleWorkspaceError;
59
- /**
60
- * Setup event listeners for CipherAgent
61
- */
62
- private setupEventListeners;
63
17
  }
@@ -1,15 +1,11 @@
1
1
  import { Args, Command, Flags } from '@oclif/core';
2
- import { randomUUID } from 'node:crypto';
3
- import { getCurrentConfig, isDevelopment } from '../config/environment.js';
4
- import { PROJECT } from '../constants.js';
5
- import { CipherAgent } from '../infra/cipher/cipher-agent.js';
6
- import { ExitCode, ExitError, exitWithCode } from '../infra/cipher/exit-codes.js';
7
- import { WorkspaceNotInitializedError } from '../infra/cipher/validation/workspace-validator.js';
2
+ import { isDevelopment } from '../config/environment.js';
8
3
  import { ProjectConfigStore } from '../infra/config/file-config-store.js';
4
+ import { FileGlobalConfigStore } from '../infra/storage/file-global-config-store.js';
9
5
  import { KeychainTokenStore } from '../infra/storage/keychain-token-store.js';
6
+ import { OclifTerminal } from '../infra/terminal/oclif-terminal.js';
10
7
  import { MixpanelTrackingService } from '../infra/tracking/mixpanel-tracking-service.js';
11
- import { formatError } from '../utils/error-handler.js';
12
- import { formatToolCall, formatToolResult } from '../utils/tool-display-formatter.js';
8
+ import { QueryUseCase } from '../infra/usecase/query-use-case.js';
13
9
  export default class Query extends Command {
14
10
  static args = {
15
11
  query: Args.string({
@@ -63,288 +59,24 @@ Bad:
63
59
  : {}),
64
60
  };
65
61
  static strict = false;
66
- // Override catch to prevent oclif from logging errors that were already displayed
67
- async catch(error) {
68
- // Check if error is ExitError (message already displayed by exitWithCode)
69
- if (error instanceof ExitError) {
70
- return;
71
- }
72
- // Backwards compatibility: also check oclif.exit property
73
- if (error.oclif?.exit !== undefined) {
74
- // Error already displayed by exitWithCode, silently exit
75
- return;
76
- }
77
- // For other errors, re-throw to let oclif handle them
78
- throw error;
79
- }
80
- createServices() {
81
- return {
62
+ createUseCase() {
63
+ const tokenStore = new KeychainTokenStore();
64
+ const globalConfigStore = new FileGlobalConfigStore();
65
+ return new QueryUseCase({
82
66
  projectConfigStore: new ProjectConfigStore(),
83
- trackingService: new MixpanelTrackingService(new KeychainTokenStore()),
84
- };
85
- }
86
- /**
87
- * Generate a unique session ID for the query agent.
88
- * Uses crypto.randomUUID() for guaranteed uniqueness (122 bits of entropy).
89
- */
90
- generateSessionId() {
91
- return randomUUID();
67
+ terminal: new OclifTerminal(this),
68
+ tokenStore,
69
+ trackingService: new MixpanelTrackingService({ globalConfigStore, tokenStore }),
70
+ });
92
71
  }
93
72
  async run() {
94
73
  const { argv, flags } = await this.parse(Query);
95
- const { projectConfigStore, trackingService } = this.createServices();
96
- try {
97
- // Get authentication token
98
- const tokenStore = new KeychainTokenStore();
99
- const token = await tokenStore.load();
100
- if (!token) {
101
- exitWithCode(ExitCode.CONFIG_ERROR, 'Authentication required. Please run "brv login" first.');
102
- }
103
- // Load project config
104
- const brvConfig = await projectConfigStore.read();
105
- // Validate workspace is initialized
106
- if (!brvConfig) {
107
- throw new WorkspaceNotInitializedError('Project not initialized. Please run "brv init" to select your team and workspace.', '.brv');
108
- }
109
- // Create LLM config
110
- const model = flags.model ?? (flags.apiKey ? 'google/gemini-2.5-pro' : 'gemini-2.5-pro');
111
- const envConfig = getCurrentConfig();
112
- const llmConfig = {
113
- accessToken: token.accessToken,
114
- fileSystemConfig: { workingDirectory: process.cwd() },
115
- grpcEndpoint: envConfig.llmGrpcEndpoint,
116
- maxIterations: 5,
117
- maxTokens: 2048,
118
- model,
119
- openRouterApiKey: flags.apiKey,
120
- projectId: PROJECT,
121
- sessionKey: token.sessionKey,
122
- temperature: 0.7,
123
- topK: 10,
124
- topP: 0.95,
125
- verbose: flags.verbose ?? false,
126
- };
127
- // Create and start CipherAgent
128
- const agent = new CipherAgent(llmConfig, brvConfig);
129
- this.log('Querying context tree...');
130
- await agent.start();
131
- try {
132
- const sessionId = this.generateSessionId();
133
- // Setup event listeners
134
- this.setupEventListeners(agent, flags.verbose ?? false);
135
- // Combine all query terms from argv (everything after flags)
136
- const queryTerms = argv.join(' ');
137
- // Execute with autonomous mode and query commandType
138
- const prompt = `Search the context tree for: ${queryTerms}`;
139
- const response = await agent.execute(prompt, sessionId, {
140
- executionContext: { commandType: 'query' },
141
- mode: 'autonomous',
142
- });
143
- this.log('\nQuery Results:');
144
- this.log(response);
145
- // Track query
146
- await trackingService.track('mem:query');
147
- }
148
- finally {
149
- // console.log('Logic for agent stopping and resource cleanup may go here!')
150
- }
151
- }
152
- catch (error) {
153
- if (error instanceof WorkspaceNotInitializedError) {
154
- this.handleWorkspaceError(error);
155
- return;
156
- }
157
- // Display context on one line, error on separate line
158
- process.stderr.write('Failed to query context tree:\n');
159
- exitWithCode(ExitCode.RUNTIME_ERROR, formatError(error));
160
- }
161
- }
162
- /**
163
- * Format items count from list_directory result
164
- */
165
- formatItemsCount(result) {
166
- if (typeof result === 'string') {
167
- const lines = result.split('\n').filter((line) => line.trim());
168
- return `${lines.length} items`;
169
- }
170
- if (Array.isArray(result)) {
171
- return `${result.length} items`;
172
- }
173
- return '';
174
- }
175
- /**
176
- * Format matches count from grep_content result
177
- */
178
- formatMatchesCount(result) {
179
- if (typeof result === 'string') {
180
- const lines = result.split('\n').filter((line) => line.trim());
181
- return `${lines.length} matches found`;
182
- }
183
- if (Array.isArray(result)) {
184
- return `${result.length} matches found`;
185
- }
186
- return '';
187
- }
188
- /**
189
- * Format tool result summary for display
190
- */
191
- formatToolResultSummary(toolName, result) {
192
- try {
193
- switch (toolName) {
194
- case 'bash_exec':
195
- case 'create_knowledge_topic':
196
- case 'delete_knowledge_topic':
197
- case 'detect_domains':
198
- case 'read_file':
199
- case 'update_knowledge_topic':
200
- case 'write_file': {
201
- return '';
202
- }
203
- case 'find_knowledge_topics': {
204
- return this.formatTopicsCount(result);
205
- }
206
- case 'grep_content': {
207
- return this.formatMatchesCount(result);
208
- }
209
- case 'list_directory': {
210
- return this.formatItemsCount(result);
211
- }
212
- default: {
213
- return '';
214
- }
215
- }
216
- }
217
- catch {
218
- return '';
219
- }
220
- }
221
- /**
222
- * Format topics count from find_knowledge_topics result
223
- */
224
- formatTopicsCount(result) {
225
- if (typeof result === 'string') {
226
- try {
227
- const parsed = JSON.parse(result);
228
- const count = Array.isArray(parsed) ? parsed.length : Object.keys(parsed).length;
229
- return `${count} topics retrieved`;
230
- }
231
- catch {
232
- return '';
233
- }
234
- }
235
- if (typeof result === 'object' && result !== null) {
236
- const resultObj = result;
237
- if (Array.isArray(resultObj.results)) {
238
- return `${resultObj.results.length} topics retrieved`;
239
- }
240
- if (typeof resultObj.total === 'number') {
241
- return `${resultObj.total} topics retrieved`;
242
- }
243
- if (Array.isArray(result)) {
244
- return `${result.length} topics retrieved`;
245
- }
246
- }
247
- return '';
248
- }
249
- /**
250
- * Get user-friendly description for a tool
251
- *
252
- * @param toolName - Name of the tool
253
- * @param args - Tool arguments
254
- * @returns User-friendly description
255
- */
256
- getToolDescription(toolName, args) {
257
- switch (toolName) {
258
- case 'bash_exec': {
259
- const cmd = String(args.command ?? '');
260
- return cmd.length > 60 ? `Running command...` : `Running: ${cmd}`;
261
- }
262
- case 'create_knowledge_topic': {
263
- return 'Creating knowledge topic...';
264
- }
265
- case 'find_knowledge_topics': {
266
- return 'Querying knowledge base...';
267
- }
268
- case 'grep_content': {
269
- return 'Searching context tree...';
270
- }
271
- case 'list_directory': {
272
- return 'Listing directory...';
273
- }
274
- case 'read_file': {
275
- return `Reading file...`;
276
- }
277
- case 'update_knowledge_topic': {
278
- return 'Updating knowledge topic...';
279
- }
280
- case 'write_file': {
281
- return 'Writing file...';
282
- }
283
- default: {
284
- return 'Processing...';
285
- }
286
- }
287
- }
288
- /**
289
- * Handle workspace not initialized error
290
- */
291
- handleWorkspaceError(_error) {
292
- const message = 'Project not initialized. Please run "brv init" to select your team and workspace.';
293
- exitWithCode(ExitCode.VALIDATION_ERROR, message);
294
- }
295
- /**
296
- * Setup event listeners for CipherAgent
297
- */
298
- setupEventListeners(agent, verbose) {
299
- if (!agent.agentEventBus) {
300
- throw new Error('Agent event bus not initialized');
301
- }
302
- const eventBus = agent.agentEventBus;
303
- if (verbose) {
304
- // Verbose mode: show detailed events
305
- eventBus.on('llmservice:thinking', () => {
306
- this.log('🤔 [Event] LLM is thinking...');
307
- });
308
- eventBus.on('llmservice:response', (payload) => {
309
- this.log(`✅ [Event] LLM Response (${payload.provider}/${payload.model})`);
310
- });
311
- eventBus.on('llmservice:toolCall', (payload) => {
312
- // Clear any spinner on current line before printing (use spaces instead of ANSI codes)
313
- const formattedCall = formatToolCall(payload.toolName, payload.args);
314
- this.log(`🔧 [Event] Tool Call: ${formattedCall}`);
315
- });
316
- eventBus.on('llmservice:toolResult', (payload) => {
317
- const resultSummary = formatToolResult(payload.toolName, payload.success, payload.result, payload.error);
318
- if (payload.success) {
319
- this.log(`✓ [Event] Tool Success: ${payload.toolName} → ${resultSummary}`);
320
- }
321
- else {
322
- this.log(`✗ [Event] Tool Error: ${payload.toolName} → ${resultSummary}`);
323
- }
324
- });
325
- // NOTE: llmservice:error is handled by catch block in the run method
326
- // which displays error via this.error(). DO NOT display here to avoid duplicate.
327
- }
328
- else {
329
- // Non-verbose mode: show concise tool progress with descriptions
330
- eventBus.on('llmservice:toolCall', (payload) => {
331
- // Clear any spinner on current line before printing (use spaces instead of ANSI codes)
332
- const description = this.getToolDescription(payload.toolName, payload.args);
333
- this.log(`🔧 ${payload.toolName} → ${description}`);
334
- });
335
- eventBus.on('llmservice:toolResult', (payload) => {
336
- if (payload.success) {
337
- // Show brief success summary for tool completion
338
- const summary = this.formatToolResultSummary(payload.toolName, payload.result);
339
- const completionText = summary ? `Complete (${summary})` : 'Complete';
340
- this.log(`✅ ${payload.toolName} → ${completionText}`);
341
- }
342
- else {
343
- this.log(`✗ ${payload.toolName} → Failed: ${payload.error}`);
344
- }
345
- });
346
- // NOTE: llmservice:error is handled by catch block in the run method
347
- // which displays error via this.error(). DO NOT display here to avoid duplicate.
348
- }
74
+ const queryTerms = argv.join(' ');
75
+ await this.createUseCase().run({
76
+ apiKey: flags.apiKey,
77
+ model: flags.model,
78
+ query: queryTerms,
79
+ verbose: flags.verbose ?? false,
80
+ });
349
81
  }
350
82
  }
@@ -1,9 +1,5 @@
1
1
  import { Command } from '@oclif/core';
2
- import type { IContextTreeService } from '../core/interfaces/i-context-tree-service.js';
3
- import type { IContextTreeSnapshotService } from '../core/interfaces/i-context-tree-snapshot-service.js';
4
- import type { IProjectConfigStore } from '../core/interfaces/i-project-config-store.js';
5
- import type { ITokenStore } from '../core/interfaces/i-token-store.js';
6
- import { ITrackingService } from '../core/interfaces/i-tracking-service.js';
2
+ import type { IStatusUseCase } from '../core/interfaces/usecase/i-status-use-case.js';
7
3
  export default class Status extends Command {
8
4
  static args: {
9
5
  directory: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
@@ -13,13 +9,6 @@ export default class Status extends Command {
13
9
  static flags: {
14
10
  format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
11
  };
16
- catch(error: Error): Promise<void>;
17
- protected createServices(): {
18
- contextTreeService: IContextTreeService;
19
- contextTreeSnapshotService: IContextTreeSnapshotService;
20
- projectConfigStore: IProjectConfigStore;
21
- tokenStore: ITokenStore;
22
- trackingService: ITrackingService;
23
- };
12
+ protected createUseCase(): IStatusUseCase;
24
13
  run(): Promise<void>;
25
14
  }
@@ -1,13 +1,12 @@
1
1
  import { Args, Command, Flags } from '@oclif/core';
2
- import chalk from 'chalk';
3
- import { join } from 'node:path';
4
- import { BRV_DIR, CONTEXT_TREE_DIR } from '../constants.js';
5
2
  import { ProjectConfigStore } from '../infra/config/file-config-store.js';
6
3
  import { FileContextTreeService } from '../infra/context-tree/file-context-tree-service.js';
7
4
  import { FileContextTreeSnapshotService } from '../infra/context-tree/file-context-tree-snapshot-service.js';
5
+ import { FileGlobalConfigStore } from '../infra/storage/file-global-config-store.js';
8
6
  import { KeychainTokenStore } from '../infra/storage/keychain-token-store.js';
7
+ import { OclifTerminal } from '../infra/terminal/oclif-terminal.js';
9
8
  import { MixpanelTrackingService } from '../infra/tracking/mixpanel-tracking-service.js';
10
- import { getErrorMessage } from '../utils/error-helpers.js';
9
+ import { StatusUseCase } from '../infra/usecase/status-use-case.js';
11
10
  export default class Status extends Command {
12
11
  static args = {
13
12
  directory: Args.string({ description: 'Project directory (defaults to current directory)', required: false }),
@@ -29,99 +28,21 @@ export default class Status extends Command {
29
28
  options: ['table', 'json'],
30
29
  }),
31
30
  };
32
- // Override catch to prevent oclif from displaying errors again
33
- async catch(error) {
34
- // Status command should always succeed and just show status
35
- // Any errors are already handled and logged in run()
36
- throw error;
37
- }
38
- createServices() {
31
+ createUseCase() {
39
32
  const tokenStore = new KeychainTokenStore();
40
- const trackingService = new MixpanelTrackingService(tokenStore);
41
- return {
33
+ const globalConfigStore = new FileGlobalConfigStore();
34
+ const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
35
+ const contextTreeSnapshotService = new FileContextTreeSnapshotService();
36
+ return new StatusUseCase({
42
37
  contextTreeService: new FileContextTreeService(),
43
- contextTreeSnapshotService: new FileContextTreeSnapshotService(),
38
+ contextTreeSnapshotService,
44
39
  projectConfigStore: new ProjectConfigStore(),
40
+ terminal: new OclifTerminal(this),
45
41
  tokenStore,
46
42
  trackingService,
47
- };
43
+ });
48
44
  }
49
45
  async run() {
50
- const { contextTreeService, contextTreeSnapshotService, projectConfigStore, tokenStore, trackingService } = this.createServices();
51
- this.log(`CLI Version: ${this.config.version}`);
52
- try {
53
- const token = await tokenStore.load();
54
- if (token !== undefined && token.isValid()) {
55
- this.log(`Status: Logged in as ${token.userEmail}`);
56
- }
57
- else if (token === undefined) {
58
- this.log('Status: Not logged in');
59
- }
60
- else {
61
- this.log('Status: Session expired (login required)');
62
- }
63
- }
64
- catch (error) {
65
- this.log('Status: Unable to check authentication status');
66
- this.warn(`Warning: ${getErrorMessage(error)}`);
67
- }
68
- const cwd = process.cwd();
69
- this.log(`Current Directory: ${cwd}`);
70
- try {
71
- const isInitialized = await projectConfigStore.exists();
72
- if (isInitialized) {
73
- const config = await projectConfigStore.read();
74
- if (config) {
75
- this.log(`Project Status: Connected to ${config.teamName}/${config.spaceName}`);
76
- }
77
- else {
78
- this.log('Project Status: Configuration file exists but is invalid');
79
- }
80
- }
81
- else {
82
- this.log('Project Status: Not initialized');
83
- }
84
- }
85
- catch (error) {
86
- this.log('Project Status: Unable to read project configuration');
87
- this.warn(`Warning: ${getErrorMessage(error)}`);
88
- }
89
- // Context tree status
90
- try {
91
- const contextTreeExists = await contextTreeService.exists();
92
- if (!contextTreeExists) {
93
- this.log('Context Tree: Not initialized');
94
- return;
95
- }
96
- const hasSnapshot = await contextTreeSnapshotService.hasSnapshot();
97
- // Auto-create empty snapshot if none exists (all files will show as "added")
98
- if (!hasSnapshot) {
99
- await contextTreeSnapshotService.initEmptySnapshot();
100
- }
101
- const changes = await contextTreeSnapshotService.getChanges();
102
- const hasChanges = changes.added.length > 0 || changes.modified.length > 0 || changes.deleted.length > 0;
103
- if (!hasChanges) {
104
- this.log('Context Tree: No changes');
105
- return;
106
- }
107
- const contextTreeRelPath = join(BRV_DIR, CONTEXT_TREE_DIR);
108
- const formatPath = (file) => join(contextTreeRelPath, file);
109
- // Build unified list with status, sort by path ascending
110
- const allChanges = [
111
- ...changes.modified.map((f) => ({ color: chalk.red, path: f, status: 'modified:' })),
112
- ...changes.added.map((f) => ({ color: chalk.red, path: f, status: 'new file:' })),
113
- ...changes.deleted.map((f) => ({ color: chalk.red, path: f, status: 'deleted:' })),
114
- ].sort((a, b) => a.path.localeCompare(b.path));
115
- this.log('Context Tree Changes:');
116
- for (const change of allChanges) {
117
- this.log(`\t${change.color(`${change.status.padEnd(10)} ${formatPath(change.path)}`)}`);
118
- }
119
- // Track status
120
- await trackingService.track('mem:status');
121
- }
122
- catch (error) {
123
- this.log('Context Tree: Unable to check status');
124
- this.warn(`Warning: ${error instanceof Error ? error.message : 'Context Tree unable to check status'}`);
125
- }
46
+ await this.createUseCase().run({ cliVersion: this.config.version });
126
47
  }
127
48
  }