byterover-cli 2.5.2 → 3.0.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 (389) hide show
  1. package/.env.production +8 -0
  2. package/LICENSE +44 -0
  3. package/README.md +240 -14
  4. package/bin/dev.js +8 -1
  5. package/bin/run.js +8 -1
  6. package/dist/agent/core/domain/knowledge/conflict-detector.d.ts +38 -0
  7. package/dist/agent/core/domain/knowledge/conflict-detector.js +71 -0
  8. package/dist/agent/core/domain/knowledge/conflict-resolver.d.ts +17 -0
  9. package/dist/agent/core/domain/knowledge/conflict-resolver.js +118 -0
  10. package/dist/agent/core/domain/knowledge/utils.d.ts +4 -0
  11. package/dist/agent/core/domain/knowledge/utils.js +6 -0
  12. package/dist/agent/core/interfaces/i-curate-service.d.ts +6 -0
  13. package/dist/agent/infra/tools/implementations/curate-tool.d.ts +67 -34
  14. package/dist/agent/infra/tools/implementations/curate-tool.js +294 -47
  15. package/dist/agent/resources/prompts/system-prompt.yml +15 -8
  16. package/dist/agent/resources/tools/code_exec.txt +3 -0
  17. package/dist/agent/resources/tools/curate.txt +12 -3
  18. package/dist/oclif/commands/connectors/install.d.ts +2 -1
  19. package/dist/oclif/commands/connectors/install.js +38 -3
  20. package/dist/oclif/commands/curate/index.d.ts +18 -0
  21. package/dist/oclif/commands/curate/index.js +78 -1
  22. package/dist/oclif/commands/init.d.ts +12 -0
  23. package/dist/oclif/commands/init.js +75 -0
  24. package/dist/oclif/commands/locations.js +1 -1
  25. package/dist/oclif/commands/providers/connect.d.ts +31 -1
  26. package/dist/oclif/commands/providers/connect.js +307 -27
  27. package/dist/oclif/commands/pull.d.ts +1 -0
  28. package/dist/oclif/commands/pull.js +7 -0
  29. package/dist/oclif/commands/push.d.ts +1 -0
  30. package/dist/oclif/commands/push.js +8 -0
  31. package/dist/oclif/commands/review/approve.d.ts +17 -0
  32. package/dist/oclif/commands/review/approve.js +37 -0
  33. package/dist/oclif/commands/review/base-review-decision.d.ts +18 -0
  34. package/dist/oclif/commands/review/base-review-decision.js +71 -0
  35. package/dist/oclif/commands/review/pending.d.ts +13 -0
  36. package/dist/oclif/commands/review/pending.js +94 -0
  37. package/dist/oclif/commands/review/reject.d.ts +17 -0
  38. package/dist/oclif/commands/review/reject.js +38 -0
  39. package/dist/oclif/commands/space/list.d.ts +2 -2
  40. package/dist/oclif/commands/space/list.js +13 -35
  41. package/dist/oclif/commands/space/switch.d.ts +2 -7
  42. package/dist/oclif/commands/space/switch.js +13 -56
  43. package/dist/oclif/commands/status.d.ts +1 -0
  44. package/dist/oclif/commands/status.js +11 -1
  45. package/dist/oclif/commands/vc/add.d.ts +7 -0
  46. package/dist/oclif/commands/vc/add.js +29 -0
  47. package/dist/oclif/commands/vc/branch.d.ts +15 -0
  48. package/dist/oclif/commands/vc/branch.js +70 -0
  49. package/dist/oclif/commands/vc/checkout.d.ts +14 -0
  50. package/dist/oclif/commands/vc/checkout.js +47 -0
  51. package/dist/oclif/commands/vc/clone.d.ts +9 -0
  52. package/dist/oclif/commands/vc/clone.js +61 -0
  53. package/dist/oclif/commands/vc/commit.d.ts +10 -0
  54. package/dist/oclif/commands/vc/commit.js +32 -0
  55. package/dist/oclif/commands/vc/config.d.ts +10 -0
  56. package/dist/oclif/commands/vc/config.js +30 -0
  57. package/dist/oclif/commands/vc/fetch.d.ts +10 -0
  58. package/dist/oclif/commands/vc/fetch.js +42 -0
  59. package/dist/oclif/commands/vc/index.d.ts +6 -0
  60. package/dist/oclif/commands/vc/index.js +8 -0
  61. package/dist/oclif/commands/vc/init.d.ts +6 -0
  62. package/dist/oclif/commands/vc/init.js +25 -0
  63. package/dist/oclif/commands/vc/log.d.ts +13 -0
  64. package/dist/oclif/commands/vc/log.js +48 -0
  65. package/dist/oclif/commands/vc/merge.d.ts +19 -0
  66. package/dist/oclif/commands/vc/merge.js +130 -0
  67. package/dist/oclif/commands/vc/pull.d.ts +13 -0
  68. package/dist/oclif/commands/vc/pull.js +60 -0
  69. package/dist/oclif/commands/vc/push.d.ts +13 -0
  70. package/dist/oclif/commands/vc/push.js +60 -0
  71. package/dist/oclif/commands/vc/remote/add.d.ts +10 -0
  72. package/dist/oclif/commands/vc/remote/add.js +30 -0
  73. package/dist/oclif/commands/vc/remote/index.d.ts +6 -0
  74. package/dist/oclif/commands/vc/remote/index.js +16 -0
  75. package/dist/oclif/commands/vc/remote/set-url.d.ts +10 -0
  76. package/dist/oclif/commands/vc/remote/set-url.js +30 -0
  77. package/dist/oclif/commands/vc/reset.d.ts +13 -0
  78. package/dist/oclif/commands/vc/reset.js +62 -0
  79. package/dist/oclif/commands/vc/status.d.ts +8 -0
  80. package/dist/oclif/commands/vc/status.js +106 -0
  81. package/dist/oclif/hooks/init/validate-brv-config.d.ts +26 -0
  82. package/dist/oclif/hooks/init/validate-brv-config.js +62 -0
  83. package/dist/oclif/lib/daemon-client.d.ts +2 -0
  84. package/dist/oclif/lib/daemon-client.js +36 -10
  85. package/dist/oclif/lib/prompt-utils.d.ts +43 -0
  86. package/dist/oclif/lib/prompt-utils.js +84 -0
  87. package/dist/oclif/lib/spinner.d.ts +8 -0
  88. package/dist/oclif/lib/spinner.js +23 -0
  89. package/dist/oclif/lib/task-client.d.ts +5 -0
  90. package/dist/oclif/lib/task-client.js +15 -2
  91. package/dist/server/config/environment.d.ts +2 -19
  92. package/dist/server/config/environment.js +31 -38
  93. package/dist/server/constants.d.ts +3 -9
  94. package/dist/server/constants.js +9 -12
  95. package/dist/server/core/domain/entities/auth-token.d.ts +2 -0
  96. package/dist/server/core/domain/entities/auth-token.js +7 -1
  97. package/dist/server/core/domain/entities/curate-log-entry.d.ts +11 -0
  98. package/dist/server/core/domain/entities/space.d.ts +4 -0
  99. package/dist/server/core/domain/entities/space.js +8 -0
  100. package/dist/server/core/domain/entities/team.d.ts +2 -0
  101. package/dist/server/core/domain/entities/team.js +4 -0
  102. package/dist/server/core/domain/errors/auth-error.d.ts +0 -6
  103. package/dist/server/core/domain/errors/auth-error.js +0 -12
  104. package/dist/server/core/domain/errors/git-error.d.ts +6 -0
  105. package/dist/server/core/domain/errors/git-error.js +12 -0
  106. package/dist/server/core/domain/errors/task-error.d.ts +4 -3
  107. package/dist/server/core/domain/errors/task-error.js +8 -8
  108. package/dist/server/core/domain/errors/transport-error.d.ts +0 -31
  109. package/dist/server/core/domain/errors/transport-error.js +0 -50
  110. package/dist/server/core/domain/errors/vc-error.d.ts +5 -0
  111. package/dist/server/core/domain/errors/vc-error.js +8 -0
  112. package/dist/server/core/domain/knowledge/markdown-writer.d.ts +4 -1
  113. package/dist/server/core/domain/knowledge/markdown-writer.js +37 -7
  114. package/dist/server/core/domain/transport/schemas.d.ts +6 -6
  115. package/dist/server/core/interfaces/context-tree/i-context-tree-service.d.ts +11 -0
  116. package/dist/server/core/interfaces/process/i-task-lifecycle-hook.d.ts +6 -0
  117. package/dist/server/core/interfaces/services/i-git-service.d.ts +234 -0
  118. package/dist/server/core/interfaces/storage/i-curate-log-store.d.ts +5 -0
  119. package/dist/server/core/interfaces/storage/i-review-backup-store.d.ts +19 -0
  120. package/dist/server/core/interfaces/vc/i-vc-git-config-store.d.ts +8 -0
  121. package/dist/server/infra/config/auto-init.d.ts +0 -2
  122. package/dist/server/infra/config/auto-init.js +0 -1
  123. package/dist/server/infra/connectors/rules/rules-connector-config.d.ts +0 -4
  124. package/dist/server/infra/context-tree/file-context-tree-service.d.ts +2 -0
  125. package/dist/server/infra/context-tree/file-context-tree-service.js +13 -0
  126. package/dist/server/infra/daemon/brv-server.js +23 -3
  127. package/dist/server/infra/git/cogit-url.d.ts +17 -0
  128. package/dist/server/infra/git/cogit-url.js +39 -0
  129. package/dist/server/infra/git/git-http-wrapper.d.ts +20 -0
  130. package/dist/server/infra/git/git-http-wrapper.js +334 -0
  131. package/dist/server/infra/git/isomorphic-git-service.d.ts +78 -0
  132. package/dist/server/infra/git/isomorphic-git-service.js +983 -0
  133. package/dist/server/infra/http/models-dev-client.d.ts +0 -4
  134. package/dist/server/infra/http/models-dev-client.js +0 -6
  135. package/dist/server/infra/http/openrouter-api-client.d.ts +0 -8
  136. package/dist/server/infra/http/openrouter-api-client.js +0 -13
  137. package/dist/server/infra/http/provider-model-fetcher-registry.d.ts +0 -5
  138. package/dist/server/infra/http/provider-model-fetcher-registry.js +0 -7
  139. package/dist/server/infra/http/review-api-handler.d.ts +13 -0
  140. package/dist/server/infra/http/review-api-handler.js +286 -0
  141. package/dist/server/infra/http/review-ui.d.ts +7 -0
  142. package/dist/server/infra/http/review-ui.js +606 -0
  143. package/dist/server/infra/mcp/tools/brv-curate-tool.d.ts +2 -2
  144. package/dist/server/infra/process/curate-log-handler.d.ts +18 -2
  145. package/dist/server/infra/process/curate-log-handler.js +50 -13
  146. package/dist/server/infra/process/feature-handlers.js +41 -1
  147. package/dist/server/infra/process/task-router.js +16 -0
  148. package/dist/server/infra/provider/env-provider-detector.d.ts +0 -20
  149. package/dist/server/infra/provider/env-provider-detector.js +0 -27
  150. package/dist/server/infra/space/http-space-service.js +2 -0
  151. package/dist/server/infra/storage/file-curate-log-store.d.ts +10 -0
  152. package/dist/server/infra/storage/file-curate-log-store.js +35 -0
  153. package/dist/server/infra/storage/file-provider-config-store.d.ts +0 -4
  154. package/dist/server/infra/storage/file-provider-config-store.js +0 -6
  155. package/dist/server/infra/storage/file-review-backup-store.d.ts +29 -0
  156. package/dist/server/infra/storage/file-review-backup-store.js +121 -0
  157. package/dist/server/infra/transport/handlers/auth-handler.js +9 -5
  158. package/dist/server/infra/transport/handlers/handler-types.d.ts +9 -0
  159. package/dist/server/infra/transport/handlers/handler-types.js +11 -0
  160. package/dist/server/infra/transport/handlers/index.d.ts +4 -0
  161. package/dist/server/infra/transport/handlers/index.js +2 -0
  162. package/dist/server/infra/transport/handlers/init-handler.d.ts +1 -0
  163. package/dist/server/infra/transport/handlers/init-handler.js +13 -1
  164. package/dist/server/infra/transport/handlers/pull-handler.d.ts +3 -0
  165. package/dist/server/infra/transport/handlers/pull-handler.js +5 -1
  166. package/dist/server/infra/transport/handlers/push-handler.d.ts +20 -0
  167. package/dist/server/infra/transport/handlers/push-handler.js +116 -14
  168. package/dist/server/infra/transport/handlers/reset-handler.d.ts +11 -0
  169. package/dist/server/infra/transport/handlers/reset-handler.js +37 -1
  170. package/dist/server/infra/transport/handlers/review-handler.d.ts +35 -0
  171. package/dist/server/infra/transport/handlers/review-handler.js +162 -0
  172. package/dist/server/infra/transport/handlers/space-handler.d.ts +3 -0
  173. package/dist/server/infra/transport/handlers/space-handler.js +4 -1
  174. package/dist/server/infra/transport/handlers/status-handler.d.ts +5 -0
  175. package/dist/server/infra/transport/handlers/status-handler.js +51 -16
  176. package/dist/server/infra/transport/handlers/vc-handler.d.ts +100 -0
  177. package/dist/server/infra/transport/handlers/vc-handler.js +1050 -0
  178. package/dist/server/infra/transport/socket-io-transport-server.d.ts +7 -0
  179. package/dist/server/infra/transport/socket-io-transport-server.js +12 -1
  180. package/dist/server/infra/transport/transport-connector.d.ts +1 -1
  181. package/dist/server/infra/transport/transport-connector.js +2 -1
  182. package/dist/server/infra/vc/file-vc-git-config-store.d.ts +11 -0
  183. package/dist/server/infra/vc/file-vc-git-config-store.js +43 -0
  184. package/dist/server/templates/skill/SKILL.md +167 -33
  185. package/dist/server/utils/curate-result-parser.d.ts +64 -0
  186. package/dist/server/utils/curate-result-parser.js +8 -0
  187. package/dist/server/utils/file-content-reader.d.ts +2 -1
  188. package/dist/server/utils/file-helpers.d.ts +0 -24
  189. package/dist/server/utils/file-helpers.js +0 -81
  190. package/dist/server/utils/gitignore.d.ts +9 -0
  191. package/dist/server/utils/gitignore.js +47 -0
  192. package/dist/server/utils/process-logger.d.ts +0 -13
  193. package/dist/server/utils/process-logger.js +1 -78
  194. package/dist/shared/transport/events/index.d.ts +6 -0
  195. package/dist/shared/transport/events/index.js +3 -0
  196. package/dist/shared/transport/events/init-events.d.ts +8 -0
  197. package/dist/shared/transport/events/init-events.js +1 -0
  198. package/dist/shared/transport/events/push-events.d.ts +6 -0
  199. package/dist/shared/transport/events/review-events.d.ts +41 -0
  200. package/dist/shared/transport/events/review-events.js +5 -0
  201. package/dist/shared/transport/events/vc-events.d.ts +257 -0
  202. package/dist/shared/transport/events/vc-events.js +67 -0
  203. package/dist/shared/transport/types/dto.d.ts +6 -1
  204. package/dist/tui/app/pages/init-project-page.d.ts +9 -0
  205. package/dist/tui/app/pages/init-project-page.js +54 -0
  206. package/dist/tui/app/pages/protected-routes.js +14 -6
  207. package/dist/tui/components/index.d.ts +0 -2
  208. package/dist/tui/components/index.js +0 -1
  209. package/dist/tui/features/activity/hooks/use-activity-logs.js +7 -1
  210. package/dist/tui/features/commands/definitions/index.js +3 -0
  211. package/dist/tui/features/commands/definitions/space-list.js +9 -18
  212. package/dist/tui/features/commands/definitions/space-switch.js +10 -6
  213. package/dist/tui/features/commands/definitions/vc-add.d.ts +2 -0
  214. package/dist/tui/features/commands/definitions/vc-add.js +15 -0
  215. package/dist/tui/features/commands/definitions/vc-branch.d.ts +2 -0
  216. package/dist/tui/features/commands/definitions/vc-branch.js +33 -0
  217. package/dist/tui/features/commands/definitions/vc-checkout.d.ts +2 -0
  218. package/dist/tui/features/commands/definitions/vc-checkout.js +32 -0
  219. package/dist/tui/features/commands/definitions/vc-clone.d.ts +2 -0
  220. package/dist/tui/features/commands/definitions/vc-clone.js +18 -0
  221. package/dist/tui/features/commands/definitions/vc-commit.d.ts +2 -0
  222. package/dist/tui/features/commands/definitions/vc-commit.js +32 -0
  223. package/dist/tui/features/commands/definitions/vc-config.d.ts +2 -0
  224. package/dist/tui/features/commands/definitions/vc-config.js +40 -0
  225. package/dist/tui/features/commands/definitions/vc-fetch.d.ts +2 -0
  226. package/dist/tui/features/commands/definitions/vc-fetch.js +37 -0
  227. package/dist/tui/features/commands/definitions/vc-init.d.ts +2 -0
  228. package/dist/tui/features/commands/definitions/vc-init.js +11 -0
  229. package/dist/tui/features/commands/definitions/vc-log.d.ts +2 -0
  230. package/dist/tui/features/commands/definitions/vc-log.js +25 -0
  231. package/dist/tui/features/commands/definitions/vc-merge.d.ts +2 -0
  232. package/dist/tui/features/commands/definitions/vc-merge.js +48 -0
  233. package/dist/tui/features/commands/definitions/vc-pull.d.ts +2 -0
  234. package/dist/tui/features/commands/definitions/vc-pull.js +42 -0
  235. package/dist/tui/features/commands/definitions/vc-push.d.ts +2 -0
  236. package/dist/tui/features/commands/definitions/vc-push.js +38 -0
  237. package/dist/tui/features/commands/definitions/vc-remote.d.ts +2 -0
  238. package/dist/tui/features/commands/definitions/vc-remote.js +57 -0
  239. package/dist/tui/features/commands/definitions/vc-reset.d.ts +2 -0
  240. package/dist/tui/features/commands/definitions/vc-reset.js +35 -0
  241. package/dist/tui/features/commands/definitions/vc-status.d.ts +2 -0
  242. package/dist/tui/features/commands/definitions/vc-status.js +11 -0
  243. package/dist/tui/features/commands/definitions/vc.d.ts +2 -0
  244. package/dist/tui/features/commands/definitions/vc.js +36 -0
  245. package/dist/tui/features/commands/hooks/use-slash-command-processor.js +5 -5
  246. package/dist/tui/features/log/api/execute-log.d.ts +8 -0
  247. package/dist/tui/features/log/api/execute-log.js +13 -0
  248. package/dist/tui/features/log/components/log-flow.d.ts +14 -0
  249. package/dist/tui/features/log/components/log-flow.js +29 -0
  250. package/dist/tui/features/log/utils/format-log.d.ts +3 -0
  251. package/dist/tui/features/log/utils/format-log.js +42 -0
  252. package/dist/tui/features/onboarding/hooks/use-app-view-mode.d.ts +9 -5
  253. package/dist/tui/features/onboarding/hooks/use-app-view-mode.js +12 -5
  254. package/dist/tui/features/push/components/push-flow.js +9 -2
  255. package/dist/tui/features/reset/components/reset-flow.js +2 -1
  256. package/dist/tui/features/status/components/status-view.js +2 -1
  257. package/dist/tui/features/status/utils/format-status.js +9 -0
  258. package/dist/tui/features/tasks/hooks/use-task-subscriptions.js +11 -0
  259. package/dist/tui/features/tasks/stores/tasks-store.d.ts +10 -0
  260. package/dist/tui/features/tasks/stores/tasks-store.js +16 -0
  261. package/dist/tui/features/vc/add/api/execute-vc-add.d.ts +8 -0
  262. package/dist/tui/features/vc/add/api/execute-vc-add.js +13 -0
  263. package/dist/tui/features/vc/add/components/vc-add-flow.d.ts +7 -0
  264. package/dist/tui/features/vc/add/components/vc-add-flow.js +35 -0
  265. package/dist/tui/features/vc/branch/api/execute-vc-branch.d.ts +8 -0
  266. package/dist/tui/features/vc/branch/api/execute-vc-branch.js +13 -0
  267. package/dist/tui/features/vc/branch/components/vc-branch-flow.d.ts +8 -0
  268. package/dist/tui/features/vc/branch/components/vc-branch-flow.js +53 -0
  269. package/dist/tui/features/vc/branch/utils/format-branch.d.ts +4 -0
  270. package/dist/tui/features/vc/branch/utils/format-branch.js +12 -0
  271. package/dist/tui/features/vc/checkout/api/execute-vc-checkout.d.ts +8 -0
  272. package/dist/tui/features/vc/checkout/api/execute-vc-checkout.js +13 -0
  273. package/dist/tui/features/vc/checkout/components/vc-checkout-flow.d.ts +8 -0
  274. package/dist/tui/features/vc/checkout/components/vc-checkout-flow.js +33 -0
  275. package/dist/tui/features/vc/clone/api/execute-vc-clone.d.ts +8 -0
  276. package/dist/tui/features/vc/clone/api/execute-vc-clone.js +13 -0
  277. package/dist/tui/features/vc/clone/components/vc-clone-flow.d.ts +7 -0
  278. package/dist/tui/features/vc/clone/components/vc-clone-flow.js +79 -0
  279. package/dist/tui/features/vc/commit/api/execute-vc-commit.d.ts +8 -0
  280. package/dist/tui/features/vc/commit/api/execute-vc-commit.js +13 -0
  281. package/dist/tui/features/vc/commit/components/vc-commit-flow.d.ts +7 -0
  282. package/dist/tui/features/vc/commit/components/vc-commit-flow.js +29 -0
  283. package/dist/tui/features/vc/config/api/execute-vc-config.d.ts +8 -0
  284. package/dist/tui/features/vc/config/api/execute-vc-config.js +13 -0
  285. package/dist/tui/features/vc/config/components/vc-config-flow.d.ts +9 -0
  286. package/dist/tui/features/vc/config/components/vc-config-flow.js +30 -0
  287. package/dist/tui/features/vc/fetch/api/execute-vc-fetch.d.ts +8 -0
  288. package/dist/tui/features/vc/fetch/api/execute-vc-fetch.js +13 -0
  289. package/dist/tui/features/vc/fetch/components/vc-fetch-flow.d.ts +8 -0
  290. package/dist/tui/features/vc/fetch/components/vc-fetch-flow.js +75 -0
  291. package/dist/tui/features/vc/init/api/execute-vc-init.d.ts +8 -0
  292. package/dist/tui/features/vc/init/api/execute-vc-init.js +13 -0
  293. package/dist/tui/features/vc/init/components/vc-init-flow.d.ts +10 -0
  294. package/dist/tui/features/vc/init/components/vc-init-flow.js +37 -0
  295. package/dist/tui/features/vc/merge/api/execute-vc-merge.d.ts +8 -0
  296. package/dist/tui/features/vc/merge/api/execute-vc-merge.js +13 -0
  297. package/dist/tui/features/vc/merge/components/vc-merge-flow.d.ts +11 -0
  298. package/dist/tui/features/vc/merge/components/vc-merge-flow.js +72 -0
  299. package/dist/tui/features/vc/pull/api/execute-vc-pull.d.ts +8 -0
  300. package/dist/tui/features/vc/pull/api/execute-vc-pull.js +13 -0
  301. package/dist/tui/features/vc/pull/components/vc-pull-flow.d.ts +9 -0
  302. package/dist/tui/features/vc/pull/components/vc-pull-flow.js +83 -0
  303. package/dist/tui/features/vc/push/api/execute-vc-push.d.ts +8 -0
  304. package/dist/tui/features/vc/push/api/execute-vc-push.js +13 -0
  305. package/dist/tui/features/vc/push/components/vc-push-flow.d.ts +8 -0
  306. package/dist/tui/features/vc/push/components/vc-push-flow.js +83 -0
  307. package/dist/tui/features/vc/remote/api/execute-vc-remote.d.ts +8 -0
  308. package/dist/tui/features/vc/remote/api/execute-vc-remote.js +13 -0
  309. package/dist/tui/features/vc/remote/components/vc-remote-flow.d.ts +9 -0
  310. package/dist/tui/features/vc/remote/components/vc-remote-flow.js +42 -0
  311. package/dist/tui/features/vc/reset/api/execute-vc-reset.d.ts +8 -0
  312. package/dist/tui/features/vc/reset/api/execute-vc-reset.js +13 -0
  313. package/dist/tui/features/vc/reset/components/vc-reset-flow.d.ts +10 -0
  314. package/dist/tui/features/vc/reset/components/vc-reset-flow.js +63 -0
  315. package/dist/tui/features/vc/status/api/execute-vc-status.d.ts +8 -0
  316. package/dist/tui/features/vc/status/api/execute-vc-status.js +13 -0
  317. package/dist/tui/features/vc/status/components/vc-status-flow.d.ts +10 -0
  318. package/dist/tui/features/vc/status/components/vc-status-flow.js +133 -0
  319. package/dist/tui/lib/environment.d.ts +8 -0
  320. package/dist/tui/lib/environment.js +8 -0
  321. package/dist/tui/utils/error-messages.d.ts +5 -1
  322. package/dist/tui/utils/error-messages.js +32 -3
  323. package/node_modules/@campfirein/brv-transport-client/LICENSE +95 -0
  324. package/node_modules/@campfirein/brv-transport-client/README.md +3 -4
  325. package/node_modules/@campfirein/brv-transport-client/package.json +2 -2
  326. package/oclif.manifest.json +985 -65
  327. package/package.json +13 -5
  328. package/dist/oclif/hooks/prerun/validate-brv-config-version.d.ts +0 -33
  329. package/dist/oclif/hooks/prerun/validate-brv-config-version.js +0 -86
  330. package/dist/server/core/domain/entities/bullet.d.ts +0 -51
  331. package/dist/server/core/domain/entities/bullet.js +0 -94
  332. package/dist/server/core/domain/entities/memory.d.ts +0 -55
  333. package/dist/server/core/domain/entities/memory.js +0 -90
  334. package/dist/server/core/domain/entities/playbook.d.ts +0 -80
  335. package/dist/server/core/domain/entities/playbook.js +0 -214
  336. package/dist/server/core/domain/entities/presigned-url.d.ts +0 -9
  337. package/dist/server/core/domain/entities/presigned-url.js +0 -18
  338. package/dist/server/core/domain/entities/presigned-urls-response.d.ts +0 -10
  339. package/dist/server/core/domain/entities/presigned-urls-response.js +0 -18
  340. package/dist/server/core/domain/entities/retrieve-result.d.ts +0 -35
  341. package/dist/server/core/domain/entities/retrieve-result.js +0 -35
  342. package/dist/server/core/domain/errors/headless-prompt-error.d.ts +0 -11
  343. package/dist/server/core/domain/errors/headless-prompt-error.js +0 -18
  344. package/dist/server/core/interfaces/services/i-legacy-rule-detector.d.ts +0 -56
  345. package/dist/server/core/interfaces/services/i-memory-retrieval-service.d.ts +0 -39
  346. package/dist/server/core/interfaces/services/i-memory-storage-service.d.ts +0 -53
  347. package/dist/server/core/interfaces/services/i-terminal.d.ts +0 -146
  348. package/dist/server/core/interfaces/services/i-terminal.js +0 -1
  349. package/dist/server/core/interfaces/services/i-workspace-detector-service.d.ts +0 -8
  350. package/dist/server/core/interfaces/services/i-workspace-detector-service.js +0 -1
  351. package/dist/server/core/interfaces/storage/i-onboarding-preference-store.d.ts +0 -20
  352. package/dist/server/core/interfaces/storage/i-onboarding-preference-store.js +0 -1
  353. package/dist/server/infra/connectors/rules/legacy-rule-detector.d.ts +0 -21
  354. package/dist/server/infra/connectors/rules/legacy-rule-detector.js +0 -106
  355. package/dist/server/infra/memory/http-memory-retrieval-service.d.ts +0 -18
  356. package/dist/server/infra/memory/http-memory-retrieval-service.js +0 -64
  357. package/dist/server/infra/memory/http-memory-storage-service.d.ts +0 -18
  358. package/dist/server/infra/memory/http-memory-storage-service.js +0 -72
  359. package/dist/server/infra/memory/memory-to-playbook-mapper.d.ts +0 -33
  360. package/dist/server/infra/memory/memory-to-playbook-mapper.js +0 -51
  361. package/dist/server/infra/storage/file-onboarding-preference-store.d.ts +0 -10
  362. package/dist/server/infra/storage/file-onboarding-preference-store.js +0 -45
  363. package/dist/server/infra/terminal/headless-terminal.d.ts +0 -91
  364. package/dist/server/infra/terminal/headless-terminal.js +0 -211
  365. package/dist/server/infra/workspace/workspace-detector-service.d.ts +0 -57
  366. package/dist/server/infra/workspace/workspace-detector-service.js +0 -165
  367. package/dist/server/utils/crash-log.d.ts +0 -14
  368. package/dist/server/utils/crash-log.js +0 -19
  369. package/dist/server/utils/emoji-helpers.d.ts +0 -38
  370. package/dist/server/utils/emoji-helpers.js +0 -42
  371. package/dist/server/utils/error-handler.d.ts +0 -51
  372. package/dist/server/utils/error-handler.js +0 -169
  373. package/dist/server/utils/oclif-error-helpers.d.ts +0 -40
  374. package/dist/server/utils/oclif-error-helpers.js +0 -46
  375. package/dist/server/utils/tool-display-formatter.d.ts +0 -53
  376. package/dist/server/utils/tool-display-formatter.js +0 -257
  377. package/dist/tui/components/init.d.ts +0 -33
  378. package/dist/tui/components/init.js +0 -234
  379. package/dist/tui/features/space/api/get-spaces.d.ts +0 -16
  380. package/dist/tui/features/space/api/get-spaces.js +0 -17
  381. package/dist/tui/features/space/api/switch-space.d.ts +0 -11
  382. package/dist/tui/features/space/api/switch-space.js +0 -24
  383. package/dist/tui/features/space/components/space-list-view.d.ts +0 -12
  384. package/dist/tui/features/space/components/space-list-view.js +0 -56
  385. package/dist/tui/features/space/components/space-switch-flow.d.ts +0 -13
  386. package/dist/tui/features/space/components/space-switch-flow.js +0 -97
  387. /package/dist/server/core/interfaces/services/{i-legacy-rule-detector.js → i-git-service.js} +0 -0
  388. /package/dist/server/core/interfaces/{services/i-memory-retrieval-service.js → storage/i-review-backup-store.js} +0 -0
  389. /package/dist/server/core/interfaces/{services/i-memory-storage-service.js → vc/i-vc-git-config-store.js} +0 -0
@@ -0,0 +1,8 @@
1
+ BRV_API_BASE_URL=https://iam.byterover.dev/api/v1
2
+ BRV_AUTHORIZATION_URL=https://iam.byterover.dev/api/v1/oidc/authorize
3
+ BRV_COGIT_API_BASE_URL=https://v3-cgit.byterover.dev/api/v1
4
+ BRV_GIT_REMOTE_BASE_URL=https://byterover.dev
5
+ BRV_ISSUER_URL=https://iam.byterover.dev/api/v1/oidc
6
+ BRV_LLM_API_BASE_URL=https://llm.byterover.dev
7
+ BRV_TOKEN_URL=https://iam.byterover.dev/api/v1/oidc/token
8
+ BRV_WEB_APP_URL=https://app.byterover.dev
package/LICENSE ADDED
@@ -0,0 +1,44 @@
1
+ Elastic License 2.0 (ELv2)
2
+
3
+ Acceptance
4
+ By using the software, you agree to all of the terms and conditions below.
5
+
6
+ Copyright License
7
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below.
8
+
9
+ Limitations
10
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
11
+
12
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
13
+
14
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor's trademarks is subject to applicable law.
15
+
16
+ Patents
17
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
18
+
19
+ Notices
20
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
21
+
22
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
23
+
24
+ No Other Rights
25
+ These terms do not imply any licenses other than those expressly granted in these terms.
26
+
27
+ Termination
28
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
29
+
30
+ No Liability
31
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
32
+
33
+ Definitions
34
+ The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
35
+
36
+ _you_ refers to the individual or entity agreeing to these terms.
37
+
38
+ _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
39
+
40
+ _your licenses_ are all the licenses granted to you for the software under these terms.
41
+
42
+ _use_ means anything you do with the software requiring one of your licenses.
43
+
44
+ _trademark_ means trademarks, service marks, and similar rights.
package/README.md CHANGED
@@ -1,15 +1,71 @@
1
1
  # ByteRover CLI
2
2
 
3
- Command-line interface for ByteRover — an interactive REPL for managing your project's context tree and knowledge storage. Integrates with 22+ AI coding agents.
3
+ <div align="center">
4
4
 
5
- [![Version](https://img.shields.io/npm/v/byterover-cli.svg)](https://npmjs.org/package/byterover-cli)
6
- [![Downloads/week](https://img.shields.io/npm/dw/byterover-cli.svg)](https://npmjs.org/package/byterover-cli)
5
+ <img src="./assets/images/logo/byterover-logo.svg" alt="ByteRover Logo" width="280" />
7
6
 
8
- ## Installation
7
+ <p align="center">
8
+ <em>Interactive REPL CLI for AI-powered context memory</em>
9
+ </p>
9
10
 
10
- ### macOS & Linux (Recommended)
11
+ <p align="center">
12
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-Elastic%202.0-blue.svg" alt="License" /></a>
13
+ <a href="https://npmjs.org/package/byterover-cli"><img src="https://img.shields.io/npm/v/byterover-cli.svg" alt="Version" /></a>
14
+ <a href="https://npmjs.org/package/byterover-cli"><img src="https://img.shields.io/npm/dw/byterover-cli.svg" alt="Downloads" /></a>
15
+ <a href="https://docs.byterover.dev"><img src="https://img.shields.io/badge/Docs-Documentation-green.svg" alt="Documentation" /></a>
16
+ <a href="https://discord.com/invite/UMRrpNjh5W"><img src="https://img.shields.io/badge/Discord-Join%20Community-7289da" alt="Discord" /></a>
17
+ </p>
11
18
 
12
- No Node.js required — everything is bundled.
19
+ </div>
20
+
21
+ ## Overview
22
+
23
+ ByteRover CLI (`brv`) gives AI coding agents persistent, structured memory. It lets developers curate project knowledge into a context tree, sync it to the cloud, and share it across tools and teammates.
24
+
25
+ Run `brv` in any project directory to start an interactive REPL powered by your choice of LLM. The agent understands your codebase through an agentic map, can read and write files, execute code, and store knowledge for future sessions.
26
+
27
+ 📄 Read the [paper](https://arxiv.org/abs/2604.01599) for the full technical details.
28
+
29
+ Or download our self-hosted PDF version of the paper [here](https://byterover.dev/paper).
30
+
31
+ **Key Features:**
32
+
33
+ - 🖥️ Interactive TUI with REPL interface (React/Ink)
34
+ - 🧠 Context tree and knowledge storage management
35
+ - 🔀 Git-like version control for the context tree (branch, commit, merge, push/pull)
36
+ - 🤖 18 LLM providers (Anthropic, OpenAI, Google, Groq, Mistral, xAI, and more)
37
+ - 🛠️ 24 built-in agent tools (code exec, file ops, knowledge search, memory management)
38
+ - 🔄 Cloud sync with push/pull
39
+ - 👀 Review workflow for curate operations (approve/reject pending changes)
40
+ - 🔌 MCP (Model Context Protocol) integration
41
+ - 📦 Hub and connectors ecosystem for skills and bundles
42
+ - 🤝 Works with 22+ AI coding agents (Cursor, Claude Code, Windsurf, Cline, and more)
43
+ - 🏢 Enterprise proxy support
44
+
45
+ ## Benchmark Results
46
+
47
+ All benchmarks are run using the production `byterover-cli` codebase in this repository - no separate research prototype.
48
+
49
+ We evaluate on two long-term conversational memory benchmarks:
50
+
51
+ - **LoCoMo** - ultra-long conversations (~20K tokens, 35 sessions) testing single-hop, multi-hop, temporal, and open-domain retrieval.
52
+ - **LongMemEval-S** - large-scale benchmark (23,867 docs, ~48 sessions per question) testing 6 memory abilities including knowledge update, temporal reasoning, and multi-session synthesis.
53
+
54
+ **LoCoMo** - 96.1% overall accuracy (1,982 questions, 272 docs).
55
+
56
+ **LongMemEval-S** - 92.8% overall accuracy (500 questions, 23,867 docs).
57
+
58
+ <p align="center">
59
+ <img src="assets/images/benchmarks/longmemeval-s-by-category.png" alt="LongMemEval-S Benchmark by Category" width="700" />
60
+ </p>
61
+
62
+ All metrics are LLM-as-Judge accuracy (%). See the [paper](https://arxiv.org/abs/2604.01599), or self-hosted [PDF](https://byterover.dev/paper) for full details.
63
+
64
+ ## Quick Start
65
+
66
+ ### Shell Script (macOS & Linux)
67
+
68
+ No Node.js required - everything is bundled.
13
69
 
14
70
  ```bash
15
71
  curl -fsSL https://byterover.dev/install.sh | sh
@@ -17,7 +73,7 @@ curl -fsSL https://byterover.dev/install.sh | sh
17
73
 
18
74
  Supported platforms: macOS ARM64, Linux x64, Linux ARM64.
19
75
 
20
- ### All platforms (via npm)
76
+ ### npm (All Platforms)
21
77
 
22
78
  Requires Node.js >= 20.
23
79
 
@@ -31,28 +87,198 @@ npm install -g byterover-cli
31
87
  brv --version
32
88
  ```
33
89
 
34
- ## Quick Start
90
+ ### First Run
35
91
 
36
92
  ```bash
37
93
  cd your/project
38
94
  brv
39
95
  ```
40
96
 
41
- The REPL auto-configures on first run no setup needed. Use `/curate` to add knowledge and `/query` to retrieve it:
97
+ The REPL auto-configures on first run - no setup needed. Type `/` to discover all available commands:
42
98
 
43
99
  ```
44
100
  /curate "Auth uses JWT with 24h expiry" @src/middleware/auth.ts
45
101
  /query How is authentication implemented?
46
102
  ```
47
103
 
48
- Type `/` in the REPL to discover all available commands.
104
+ ## ByteRover Cloud
105
+
106
+ ByteRover Cloud is a hosted platform for teams to sync, share, and manage context knowledge across projects and machines.
107
+ Everything works locally by default - Cloud adds collaboration and persistence without changing your workflow.
108
+
109
+ <p>
110
+ <a href="https://app.byterover.dev"><img src="https://img.shields.io/badge/Try%20ByteRover%20Cloud-Free-blue?style=for-the-badge" alt="Try ByteRover Cloud" /></a>
111
+ </p>
112
+
113
+ Sign in with your ByteRover account via `/login` (TUI) or
114
+ an [API key](https://app.byterover.dev/settings/keys) (`brv login`) to get started.
115
+
116
+ - 🔄 **Team context sync** — push and pull shared knowledge across teammates
117
+ - 📂 **Shared spaces** — organize context across multiple projects and teams
118
+ - 💻 **Multi-machine access** — sync your context tree across devices with cloud backup
119
+ - 🧠 **Built-in hosted LLM** — start immediately with limited free usage
120
+ - 👥 **Team management** — manage members, spaces, and permissions via the web app
121
+ - 📊 **Usage analytics** — track seat allocation and monthly credit consumption
122
+ - 🔒 **SOC 2 Type II** certified infrastructure with privacy mode
123
+
124
+ <details>
125
+ <summary><h2>CLI Usage</h2></summary>
126
+
127
+ ### Core Workflow
128
+
129
+ ```bash
130
+ brv # Start interactive REPL
131
+ brv status # Show project and daemon status
132
+ brv curate # Add context to knowledge storage
133
+ brv curate view # View curate history
134
+ brv query # Query context tree and knowledge
135
+ brv review pending # List pending review operations
136
+ brv review approve # Approve curate operations
137
+ brv review reject # Reject curate operations
138
+ ```
139
+
140
+ ### Sync (Legacy)
141
+
142
+ ```bash
143
+ brv push # Legacy — migrate or snapshot context to cloud
144
+ brv pull # Legacy — restore context from cloud snapshot
145
+ ```
146
+
147
+ > Use `brv vc push` / `brv vc pull` for version-controlled sync going forward.
148
+
149
+ ### Version Control
150
+
151
+ ```bash
152
+ brv vc init # Initialize version control for context tree
153
+ brv vc status # Show version control status
154
+ brv vc add # Stage files for the next commit
155
+ brv vc commit # Save staged changes as a commit
156
+ brv vc log # Show commit history
157
+ brv vc branch # List, create, or delete branches
158
+ brv vc checkout # Switch branches
159
+ brv vc merge # Merge a branch into the current branch
160
+ brv vc clone # Clone a ByteRover space repository
161
+ brv vc push # Push commits to ByteRover cloud
162
+ brv vc pull # Pull commits from ByteRover cloud
163
+ brv vc fetch # Fetch refs from ByteRover cloud
164
+ brv vc remote # Show current remote origin
165
+ brv vc remote add # Add a named remote
166
+ brv vc remote set-url # Update a remote URL
167
+ brv vc config # Get or set commit author
168
+ brv vc reset # Unstage files or undo commits
169
+ ```
170
+
171
+ ### Providers & Models
172
+
173
+ ```bash
174
+ brv providers list # List available LLM providers
175
+ brv providers connect # Connect to an LLM provider
176
+ brv providers switch # Switch active provider
177
+ brv providers disconnect # Disconnect a provider
178
+ brv model list # List available models
179
+ brv model switch # Switch active model
180
+ ```
181
+
182
+ ### Hub & Connectors
183
+
184
+ ```bash
185
+ brv hub list # List available hub packages
186
+ brv hub install # Install a hub package
187
+ brv hub registry add # Add a custom registry
188
+ brv hub registry list # List registries
189
+ brv hub registry remove # Remove a registry
190
+ brv connectors list # List connectors
191
+ brv connectors install # Install a connector
192
+ ```
193
+
194
+ ### Spaces (Deprecated)
195
+
196
+ ```bash
197
+ brv space list # Deprecated — use web dashboard
198
+ brv space switch # Deprecated — use brv vc clone
199
+ ```
200
+
201
+ ### Other
202
+
203
+ ```bash
204
+ brv mcp # Start MCP server
205
+ brv login # Authenticate to ByteRover
206
+ brv logout # Disconnect and clear credentials
207
+ brv locations # List registered projects
208
+ brv restart # Restart daemon
209
+ brv debug # Debug mode
210
+ ```
211
+
212
+ Run `brv --help` for the full command reference.
213
+
214
+ </details>
215
+
216
+ <details>
217
+ <summary><h2>Supported LLM Providers</h2></summary>
218
+
219
+ ByteRover CLI supports 18 LLM providers out of the box. Use `brv providers connect` to set up a provider and `brv providers switch` to change the active one.
220
+
221
+ | Provider | Description |
222
+ |----------|-------------|
223
+ | Anthropic | Claude models |
224
+ | OpenAI | GPT models |
225
+ | Google | Gemini models |
226
+ | Groq | Fast inference |
227
+ | Mistral | Mistral models |
228
+ | xAI | Grok models |
229
+ | Cerebras | Fast inference |
230
+ | Cohere | Command models |
231
+ | DeepInfra | Open-source model hosting |
232
+ | OpenRouter | Multi-provider gateway |
233
+ | Perplexity | Search-augmented models |
234
+ | TogetherAI | Open-source model hosting |
235
+ | Vercel | AI SDK provider |
236
+ | Minimax | Minimax models |
237
+ | Moonshot | Kimi models |
238
+ | GLM | GLM models |
239
+ | OpenAI-Compatible | Any OpenAI-compatible API |
240
+ | ByteRover | ByteRover's hosted models |
241
+
242
+ </details>
49
243
 
50
244
  ## Documentation
51
245
 
52
- Visit [**docs.byterover.dev**](https://docs.byterover.dev) for full guides on cloud sync, AI agent integrations, LLM providers, and more.
246
+ Visit [**docs.byterover.dev**](https://docs.byterover.dev) for full guides on setup, integrations, and advanced usage.
247
+
248
+ | Topic | Description |
249
+ |-------|-------------|
250
+ | [Getting Started](https://docs.byterover.dev) | Installation, first run, and basic usage |
251
+ | [Cloud Sync](https://docs.byterover.dev) | Push/pull workflows and team sharing |
252
+ | [Version Control](https://docs.byterover.dev) | Context tree branching, commits, and collaboration |
253
+ | [LLM Providers](https://docs.byterover.dev) | Provider setup and model configuration |
254
+ | [AI Agent Integrations](https://docs.byterover.dev) | Using ByteRover with Cursor, Claude Code, Windsurf, etc. |
255
+ | [Hub & Connectors](https://docs.byterover.dev) | Skills, bundles, and the connector ecosystem |
256
+ | CLI Reference | Run `brv --help` |
257
+
258
+ ## Contributing
259
+
260
+ We welcome contributions! See our [Contributing Guide](CONTRIBUTING.md) for development setup, coding standards, and the PR workflow.
261
+
262
+ ## Community & Support
263
+
264
+ ByteRover CLI is built and maintained by the [ByteRover team](https://byterover.dev/).
265
+
266
+ - Join our [Discord](https://discord.com/invite/UMRrpNjh5W) to share projects, ask questions, or just say hi
267
+ - [Report issues](https://github.com/campfirein/byterover-cli/issues) <!-- TODO: ENG-1575 --> on GitHub
268
+ - If you enjoy ByteRover CLI, please give us a star on GitHub — it helps a lot!
269
+ - Follow [@kevinnguyendn](https://x.com/kevinnguyendn) on X
270
+
271
+ ## Contributors
272
+
273
+ <!-- TODO: ENG-1575 -->
274
+ [![Contributors](https://contrib.rocks/image?repo=campfirein/byterover-cli&max=40&columns=10)](https://github.com/campfirein/byterover-cli/graphs/contributors)
275
+
276
+ ## Star History
53
277
 
54
- Run `brv --help` for CLI usage.
278
+ <a href="https://star-history.com/#campfirein/byterover-cli&Date">
279
+ <img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=campfirein/byterover-cli&type=Date&v=2">
280
+ </a>
55
281
 
56
- ---
282
+ ## License
57
283
 
58
- **Copyright (c) ByteRover**
284
+ Elastic License 2.0. See [LICENSE](LICENSE) for full terms.
package/bin/dev.js CHANGED
@@ -1,8 +1,15 @@
1
1
  #!/usr/bin/env -S node --import tsx --no-warnings
2
2
 
3
+ import {execute} from '@oclif/core'
4
+ import {config as loadEnv} from 'dotenv'
5
+ import {resolve} from 'node:path'
6
+
3
7
  process.env.BRV_ENV = 'development'
4
8
 
5
- import {execute} from '@oclif/core'
9
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
10
+ const root = resolve(import.meta.dirname, '..')
11
+ loadEnv({path: resolve(root, '.env.development')})
12
+
6
13
 
7
14
  // Inject default command 'main' (represents logic of a single 'brv' run) when no args provided
8
15
  // process.argv = ['node', 'bin/dev.js', ...userArgs]
package/bin/run.js CHANGED
@@ -1,8 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import {execute} from '@oclif/core'
4
+ import {config as loadEnv} from 'dotenv'
5
+ import {resolve} from 'node:path'
6
+
3
7
  process.env.BRV_ENV = 'production'
4
8
 
5
- import { execute } from '@oclif/core'
9
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
10
+ const root = resolve(import.meta.dirname, '..')
11
+ loadEnv({path: resolve(root, '.env.production'), quiet: true})
12
+
6
13
 
7
14
  // Inject default command 'main' (represents logic of a single 'brv' run) when no args provided
8
15
  // process.argv = ['node', 'brv', ...userArgs]
@@ -0,0 +1,38 @@
1
+ import type { ContextData } from '../../../../server/core/domain/knowledge/markdown-writer.js';
2
+ /**
3
+ * Summary of detected structural loss when comparing existing vs proposed content.
4
+ */
5
+ export type StructuralLoss = {
6
+ hasLoss: boolean;
7
+ /** Number of rawConcept array items (changes, files) that would be lost */
8
+ lostArrayItems: number;
9
+ /** Number of narrative fields that would be lost */
10
+ lostNarrativeFields: number;
11
+ /** Number of rawConcept scalar fields that would be lost */
12
+ lostRawConceptFields: number;
13
+ /** Number of relations that would be lost */
14
+ lostRelations: number;
15
+ /** Number of snippets that would be lost */
16
+ lostSnippets: number;
17
+ };
18
+ /**
19
+ * Detect structural loss between existing content and proposed content.
20
+ *
21
+ * Only flags when existing content would be LOST, not when new content is added.
22
+ * This prevents false positives when the LLM is enriching content.
23
+ *
24
+ * @param existing - Parsed content from the existing file
25
+ * @param proposed - Proposed new content from the curate operation
26
+ * @returns StructuralLoss summary
27
+ */
28
+ export declare function detectStructuralLoss(existing: ContextData, proposed: ContextData): StructuralLoss;
29
+ /**
30
+ * Derive the structural impact level from detected loss.
31
+ *
32
+ * - Any structural loss → 'high'
33
+ * - No loss → 'low'
34
+ *
35
+ * @param loss - Structural loss summary from detectStructuralLoss
36
+ * @returns Impact level derived from structural evidence
37
+ */
38
+ export declare function deriveImpactFromLoss(loss: StructuralLoss): 'high' | 'low';
@@ -0,0 +1,71 @@
1
+ import { normalize } from './utils.js';
2
+ /**
3
+ * Find items in `existing` that are not in `proposed` (case-insensitive).
4
+ */
5
+ function countLostItems(existing, proposed) {
6
+ const proposedSet = new Set(proposed.map((s) => normalize(s)));
7
+ return existing.filter((item) => !proposedSet.has(normalize(item))).length;
8
+ }
9
+ /**
10
+ * Count narrative fields that exist in `existing` but are absent in `proposed`.
11
+ */
12
+ function countLostNarrativeFields(existing, proposed) {
13
+ if (!existing)
14
+ return 0;
15
+ const fields = ['dependencies', 'examples', 'highlights', 'rules', 'structure'];
16
+ return fields.filter((field) => existing[field] && !proposed?.[field]).length;
17
+ }
18
+ /**
19
+ * Count rawConcept scalar fields and array items that would be lost.
20
+ */
21
+ function countLostRawConceptFields(existing, proposed) {
22
+ if (!existing)
23
+ return { arrayItems: 0, scalars: 0 };
24
+ const scalarFields = ['author', 'flow', 'task', 'timestamp'];
25
+ const scalars = scalarFields.filter((field) => existing[field] && !proposed?.[field]).length;
26
+ const existingChanges = existing.changes ?? [];
27
+ const existingFiles = existing.files ?? [];
28
+ const proposedChanges = proposed?.changes ?? [];
29
+ const proposedFiles = proposed?.files ?? [];
30
+ const arrayItems = countLostItems(existingChanges, proposedChanges) + countLostItems(existingFiles, proposedFiles);
31
+ return { arrayItems, scalars };
32
+ }
33
+ /**
34
+ * Detect structural loss between existing content and proposed content.
35
+ *
36
+ * Only flags when existing content would be LOST, not when new content is added.
37
+ * This prevents false positives when the LLM is enriching content.
38
+ *
39
+ * @param existing - Parsed content from the existing file
40
+ * @param proposed - Proposed new content from the curate operation
41
+ * @returns StructuralLoss summary
42
+ */
43
+ export function detectStructuralLoss(existing, proposed) {
44
+ const lostSnippets = countLostItems(existing.snippets ?? [], proposed.snippets ?? []);
45
+ const lostRelations = countLostItems(existing.relations ?? [], proposed.relations ?? []);
46
+ const lostNarrativeFields = countLostNarrativeFields(existing.narrative, proposed.narrative);
47
+ const { arrayItems: lostArrayItems, scalars: lostRawConceptFields } = countLostRawConceptFields(existing.rawConcept, proposed.rawConcept);
48
+ const hasLoss = lostSnippets > 0 || lostRelations > 0 || lostNarrativeFields > 0 || lostRawConceptFields > 0 || lostArrayItems > 0;
49
+ return {
50
+ hasLoss,
51
+ lostArrayItems,
52
+ lostNarrativeFields,
53
+ lostRawConceptFields,
54
+ lostRelations,
55
+ lostSnippets,
56
+ };
57
+ }
58
+ /**
59
+ * Derive the structural impact level from detected loss.
60
+ *
61
+ * - Any structural loss → 'high'
62
+ * - No loss → 'low'
63
+ *
64
+ * @param loss - Structural loss summary from detectStructuralLoss
65
+ * @returns Impact level derived from structural evidence
66
+ */
67
+ export function deriveImpactFromLoss(loss) {
68
+ if (!loss.hasLoss)
69
+ return 'low';
70
+ return 'high';
71
+ }
@@ -0,0 +1,17 @@
1
+ import type { ContextData } from '../../../../server/core/domain/knowledge/markdown-writer.js';
2
+ import type { StructuralLoss } from './conflict-detector.js';
3
+ /**
4
+ * Auto-resolve structural loss by merging existing content into proposed content.
5
+ *
6
+ * Resolution strategy:
7
+ * - Arrays (snippets, relations, changes, files): Union merge with deduplication
8
+ * - Scalars (narrative fields, rawConcept scalars): Proposed wins; preserve existing if proposed empty
9
+ *
10
+ * Only runs when `loss.hasLoss` is true. When no loss is detected, returns proposed as-is.
11
+ *
12
+ * @param existing - Parsed content from the existing file (before update)
13
+ * @param proposed - Proposed new content from the curate operation
14
+ * @param loss - Structural loss summary from detectStructuralLoss
15
+ * @returns Resolved content with lost items merged back in
16
+ */
17
+ export declare function resolveStructuralLoss(existing: ContextData, proposed: ContextData, loss: StructuralLoss): ContextData;
@@ -0,0 +1,118 @@
1
+ import { normalize } from './utils.js';
2
+ /**
3
+ * Merge two arrays with case-insensitive deduplication.
4
+ * Existing items come first (preserves original order), then new items from proposed.
5
+ */
6
+ function mergeArraysWithDedup(existing, proposed) {
7
+ const seen = new Set();
8
+ const result = [];
9
+ for (const item of existing) {
10
+ const key = normalize(item);
11
+ if (!seen.has(key)) {
12
+ seen.add(key);
13
+ result.push(item);
14
+ }
15
+ }
16
+ for (const item of proposed) {
17
+ const key = normalize(item);
18
+ if (!seen.has(key)) {
19
+ seen.add(key);
20
+ result.push(item);
21
+ }
22
+ }
23
+ return result;
24
+ }
25
+ /**
26
+ * Merge narrative fields.
27
+ * Use proposed if provided, otherwise preserve existing (prevents data loss).
28
+ */
29
+ function mergeNarrative(existing, proposed) {
30
+ if (!existing && !proposed)
31
+ return undefined;
32
+ if (!existing)
33
+ return proposed;
34
+ if (!proposed)
35
+ return existing;
36
+ const merged = {};
37
+ const fields = ['dependencies', 'examples', 'highlights', 'rules', 'structure'];
38
+ for (const field of fields) {
39
+ const value = proposed[field] ?? existing[field];
40
+ if (value !== undefined) {
41
+ // Type assertion needed due to heterogeneous union (string | Array)
42
+ ;
43
+ merged[field] = value;
44
+ }
45
+ }
46
+ // Diagrams: union merge by content
47
+ const existingDiagrams = existing.diagrams ?? [];
48
+ const proposedDiagrams = proposed.diagrams ?? [];
49
+ if (existingDiagrams.length > 0 || proposedDiagrams.length > 0) {
50
+ const seen = new Set(existingDiagrams.map((d) => normalize(d.content)));
51
+ const mergedDiagrams = [...existingDiagrams];
52
+ for (const diagram of proposedDiagrams) {
53
+ if (!seen.has(normalize(diagram.content))) {
54
+ mergedDiagrams.push(diagram);
55
+ }
56
+ }
57
+ merged.diagrams = mergedDiagrams;
58
+ }
59
+ return Object.keys(merged).length > 0 ? merged : undefined;
60
+ }
61
+ /**
62
+ * Merge rawConcept fields.
63
+ * Scalars: use proposed if provided, otherwise preserve existing.
64
+ * Arrays (changes, files): union merge with deduplication.
65
+ */
66
+ function mergeRawConcept(existing, proposed) {
67
+ if (!existing && !proposed)
68
+ return undefined;
69
+ if (!existing)
70
+ return proposed;
71
+ if (!proposed)
72
+ return existing;
73
+ const merged = {};
74
+ // Scalar fields: proposed wins, fall back to existing
75
+ const scalarFields = ['author', 'flow', 'task', 'timestamp'];
76
+ for (const field of scalarFields) {
77
+ const value = proposed[field] ?? existing[field];
78
+ if (value !== undefined) {
79
+ ;
80
+ merged[field] = value;
81
+ }
82
+ }
83
+ // patterns: proposed wins, fall back to existing
84
+ merged.patterns = proposed.patterns ?? existing.patterns;
85
+ // Array fields: union merge
86
+ const mergedChanges = mergeArraysWithDedup(existing.changes ?? [], proposed.changes ?? []);
87
+ if (mergedChanges.length > 0)
88
+ merged.changes = mergedChanges;
89
+ const mergedFiles = mergeArraysWithDedup(existing.files ?? [], proposed.files ?? []);
90
+ if (mergedFiles.length > 0)
91
+ merged.files = mergedFiles;
92
+ return Object.keys(merged).length > 0 ? merged : undefined;
93
+ }
94
+ /**
95
+ * Auto-resolve structural loss by merging existing content into proposed content.
96
+ *
97
+ * Resolution strategy:
98
+ * - Arrays (snippets, relations, changes, files): Union merge with deduplication
99
+ * - Scalars (narrative fields, rawConcept scalars): Proposed wins; preserve existing if proposed empty
100
+ *
101
+ * Only runs when `loss.hasLoss` is true. When no loss is detected, returns proposed as-is.
102
+ *
103
+ * @param existing - Parsed content from the existing file (before update)
104
+ * @param proposed - Proposed new content from the curate operation
105
+ * @param loss - Structural loss summary from detectStructuralLoss
106
+ * @returns Resolved content with lost items merged back in
107
+ */
108
+ export function resolveStructuralLoss(existing, proposed, loss) {
109
+ if (!loss.hasLoss)
110
+ return proposed;
111
+ return {
112
+ ...proposed,
113
+ narrative: mergeNarrative(existing.narrative, proposed.narrative),
114
+ rawConcept: mergeRawConcept(existing.rawConcept, proposed.rawConcept),
115
+ relations: mergeArraysWithDedup(existing.relations ?? [], proposed.relations ?? []),
116
+ snippets: mergeArraysWithDedup(existing.snippets ?? [], proposed.snippets ?? []),
117
+ };
118
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Normalize a string for comparison (trim and lowercase).
3
+ */
4
+ export declare function normalize(s: string): string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Normalize a string for comparison (trim and lowercase).
3
+ */
4
+ export function normalize(s) {
5
+ return s.trim().toLowerCase();
6
+ }
@@ -114,10 +114,14 @@ export type CurateOperationType = 'ADD' | 'DELETE' | 'MERGE' | 'UPDATE' | 'UPSER
114
114
  * Single curate operation.
115
115
  */
116
116
  export interface CurateOperation {
117
+ /** LLM-assessed confidence in the accuracy and completeness of this operation */
118
+ confidence?: 'high' | 'low';
117
119
  /** Content for ADD/UPDATE operations */
118
120
  content?: CurateContent;
119
121
  /** Domain-level context for new domains */
120
122
  domainContext?: CurateDomainContext;
123
+ /** Estimated scope of impact of this knowledge change */
124
+ impact?: 'high' | 'low';
121
125
  /** Target path for MERGE operation */
122
126
  mergeTarget?: string;
123
127
  /** Title of the target file for MERGE operation */
@@ -128,6 +132,8 @@ export interface CurateOperation {
128
132
  reason: string;
129
133
  /** Subtopic-level context for new subtopics */
130
134
  subtopicContext?: CurateSubtopicContext;
135
+ /** One-line semantic summary of what the knowledge file contains after this operation */
136
+ summary?: string;
131
137
  /** Title for the context file (becomes {title}.md) */
132
138
  title?: string;
133
139
  /** Topic-level context for new topics */