byterover-cli 1.0.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +19 -13
  2. package/dist/commands/hook-prompt-submit.d.ts +27 -0
  3. package/dist/commands/hook-prompt-submit.js +39 -0
  4. package/dist/commands/mcp.d.ts +13 -0
  5. package/dist/commands/mcp.js +61 -0
  6. package/dist/commands/status.js +8 -3
  7. package/dist/constants.d.ts +1 -1
  8. package/dist/constants.js +1 -1
  9. package/dist/core/domain/cipher/agent-events/types.d.ts +44 -1
  10. package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
  11. package/dist/core/domain/cipher/tools/constants.js +1 -0
  12. package/dist/core/domain/entities/agent.d.ts +16 -0
  13. package/dist/core/domain/entities/agent.js +78 -0
  14. package/dist/core/domain/entities/connector-type.d.ts +10 -0
  15. package/dist/core/domain/entities/connector-type.js +9 -0
  16. package/dist/core/domain/entities/event.d.ts +1 -1
  17. package/dist/core/domain/entities/event.js +2 -0
  18. package/dist/core/domain/errors/task-error.d.ts +4 -0
  19. package/dist/core/domain/errors/task-error.js +7 -0
  20. package/dist/core/domain/transport/schemas.d.ts +40 -0
  21. package/dist/core/domain/transport/schemas.js +28 -0
  22. package/dist/core/interfaces/connectors/connector-types.d.ts +70 -0
  23. package/dist/core/interfaces/connectors/i-connector-manager.d.ts +72 -0
  24. package/dist/core/interfaces/connectors/i-connector-manager.js +1 -0
  25. package/dist/core/interfaces/connectors/i-connector.d.ts +54 -0
  26. package/dist/core/interfaces/connectors/i-connector.js +1 -0
  27. package/dist/core/interfaces/i-file-service.d.ts +7 -0
  28. package/dist/core/interfaces/i-mcp-config-writer.d.ts +40 -0
  29. package/dist/core/interfaces/i-mcp-config-writer.js +1 -0
  30. package/dist/core/interfaces/i-rule-template-service.d.ts +4 -2
  31. package/dist/core/interfaces/transport/i-transport-client.d.ts +7 -0
  32. package/dist/core/interfaces/usecase/i-connectors-use-case.d.ts +3 -0
  33. package/dist/core/interfaces/usecase/i-connectors-use-case.js +1 -0
  34. package/dist/hooks/init/update-notifier.d.ts +1 -0
  35. package/dist/hooks/init/update-notifier.js +10 -1
  36. package/dist/infra/cipher/agent/cipher-agent.d.ts +8 -0
  37. package/dist/infra/cipher/agent/cipher-agent.js +16 -0
  38. package/dist/infra/cipher/file-system/binary-utils.d.ts +7 -12
  39. package/dist/infra/cipher/file-system/binary-utils.js +46 -31
  40. package/dist/infra/cipher/llm/context/context-manager.d.ts +10 -2
  41. package/dist/infra/cipher/llm/context/context-manager.js +39 -2
  42. package/dist/infra/cipher/llm/formatters/gemini-formatter.js +48 -9
  43. package/dist/infra/cipher/llm/internal-llm-service.d.ts +4 -0
  44. package/dist/infra/cipher/llm/internal-llm-service.js +40 -12
  45. package/dist/infra/cipher/session/chat-session.d.ts +3 -0
  46. package/dist/infra/cipher/session/chat-session.js +7 -1
  47. package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.d.ts +6 -7
  48. package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.js +57 -18
  49. package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +1 -8
  50. package/dist/infra/cipher/tools/implementations/curate-tool.js +380 -24
  51. package/dist/infra/cipher/tools/implementations/read-file-tool.js +38 -17
  52. package/dist/infra/cipher/tools/implementations/search-knowledge-tool.d.ts +7 -0
  53. package/dist/infra/cipher/tools/implementations/search-knowledge-tool.js +303 -0
  54. package/dist/infra/cipher/tools/index.d.ts +1 -0
  55. package/dist/infra/cipher/tools/index.js +1 -0
  56. package/dist/infra/cipher/tools/tool-manager.js +1 -0
  57. package/dist/infra/cipher/tools/tool-registry.js +7 -0
  58. package/dist/infra/connectors/connector-manager.d.ts +32 -0
  59. package/dist/infra/connectors/connector-manager.js +158 -0
  60. package/dist/infra/connectors/hook/hook-connector-config.d.ts +52 -0
  61. package/dist/infra/connectors/hook/hook-connector-config.js +41 -0
  62. package/dist/infra/connectors/hook/hook-connector.d.ts +46 -0
  63. package/dist/infra/connectors/hook/hook-connector.js +231 -0
  64. package/dist/infra/connectors/mcp/index.d.ts +4 -0
  65. package/dist/infra/connectors/mcp/index.js +4 -0
  66. package/dist/infra/connectors/mcp/json-mcp-config-writer.d.ts +26 -0
  67. package/dist/infra/connectors/mcp/json-mcp-config-writer.js +71 -0
  68. package/dist/infra/connectors/mcp/mcp-connector-config.d.ts +229 -0
  69. package/dist/infra/connectors/mcp/mcp-connector-config.js +173 -0
  70. package/dist/infra/connectors/mcp/mcp-connector.d.ts +80 -0
  71. package/dist/infra/connectors/mcp/mcp-connector.js +324 -0
  72. package/dist/infra/connectors/mcp/toml-mcp-config-writer.d.ts +45 -0
  73. package/dist/infra/connectors/mcp/toml-mcp-config-writer.js +134 -0
  74. package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.d.ts +2 -2
  75. package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.js +1 -1
  76. package/dist/infra/connectors/rules/rules-connector-config.d.ts +95 -0
  77. package/dist/infra/{rule/agent-rule-config.js → connectors/rules/rules-connector-config.js} +10 -10
  78. package/dist/infra/connectors/rules/rules-connector.d.ts +34 -0
  79. package/dist/infra/connectors/rules/rules-connector.js +139 -0
  80. package/dist/infra/connectors/shared/rule-file-manager.d.ts +72 -0
  81. package/dist/infra/connectors/shared/rule-file-manager.js +119 -0
  82. package/dist/infra/connectors/shared/template-service.d.ts +27 -0
  83. package/dist/infra/connectors/shared/template-service.js +125 -0
  84. package/dist/infra/context-tree/file-context-tree-writer-service.d.ts +5 -2
  85. package/dist/infra/context-tree/file-context-tree-writer-service.js +20 -5
  86. package/dist/infra/core/executors/curate-executor.d.ts +2 -2
  87. package/dist/infra/core/executors/curate-executor.js +7 -7
  88. package/dist/infra/core/executors/query-executor.d.ts +12 -0
  89. package/dist/infra/core/executors/query-executor.js +62 -1
  90. package/dist/infra/file/fs-file-service.d.ts +7 -0
  91. package/dist/infra/file/fs-file-service.js +15 -1
  92. package/dist/infra/mcp/index.d.ts +2 -0
  93. package/dist/infra/mcp/index.js +2 -0
  94. package/dist/infra/mcp/mcp-server.d.ts +58 -0
  95. package/dist/infra/mcp/mcp-server.js +178 -0
  96. package/dist/infra/mcp/tools/brv-curate-tool.d.ts +23 -0
  97. package/dist/infra/mcp/tools/brv-curate-tool.js +68 -0
  98. package/dist/infra/mcp/tools/brv-query-tool.d.ts +17 -0
  99. package/dist/infra/mcp/tools/brv-query-tool.js +68 -0
  100. package/dist/infra/mcp/tools/index.d.ts +3 -0
  101. package/dist/infra/mcp/tools/index.js +3 -0
  102. package/dist/infra/mcp/tools/task-result-waiter.d.ts +30 -0
  103. package/dist/infra/mcp/tools/task-result-waiter.js +56 -0
  104. package/dist/infra/process/agent-worker.d.ts +2 -2
  105. package/dist/infra/process/agent-worker.js +663 -142
  106. package/dist/infra/process/constants.d.ts +1 -1
  107. package/dist/infra/process/constants.js +1 -1
  108. package/dist/infra/process/ipc-types.d.ts +17 -4
  109. package/dist/infra/process/ipc-types.js +3 -3
  110. package/dist/infra/process/parent-heartbeat.d.ts +47 -0
  111. package/dist/infra/process/parent-heartbeat.js +118 -0
  112. package/dist/infra/process/process-manager.d.ts +79 -0
  113. package/dist/infra/process/process-manager.js +277 -3
  114. package/dist/infra/process/task-queue-manager.d.ts +13 -0
  115. package/dist/infra/process/task-queue-manager.js +19 -0
  116. package/dist/infra/process/transport-handlers.d.ts +3 -0
  117. package/dist/infra/process/transport-handlers.js +51 -5
  118. package/dist/infra/process/transport-worker.js +9 -69
  119. package/dist/infra/repl/commands/connectors-command.d.ts +8 -0
  120. package/dist/infra/repl/commands/{gen-rules-command.js → connectors-command.js} +21 -10
  121. package/dist/infra/repl/commands/curate-command.js +2 -2
  122. package/dist/infra/repl/commands/index.js +3 -2
  123. package/dist/infra/repl/commands/init-command.js +11 -7
  124. package/dist/infra/repl/commands/query-command.js +22 -2
  125. package/dist/infra/repl/commands/reset-command.js +1 -1
  126. package/dist/infra/transport/socket-io-transport-client.d.ts +75 -0
  127. package/dist/infra/transport/socket-io-transport-client.js +308 -7
  128. package/dist/infra/transport/socket-io-transport-server.js +4 -0
  129. package/dist/infra/usecase/connectors-use-case.d.ts +63 -0
  130. package/dist/infra/usecase/connectors-use-case.js +222 -0
  131. package/dist/infra/usecase/init-use-case.d.ts +8 -43
  132. package/dist/infra/usecase/init-use-case.js +27 -252
  133. package/dist/infra/usecase/logout-use-case.js +1 -1
  134. package/dist/infra/usecase/pull-use-case.js +5 -5
  135. package/dist/infra/usecase/push-use-case.js +4 -4
  136. package/dist/infra/usecase/reset-use-case.js +3 -4
  137. package/dist/infra/usecase/space-list-use-case.js +3 -3
  138. package/dist/infra/usecase/space-switch-use-case.js +3 -3
  139. package/dist/infra/usecase/status-use-case.d.ts +10 -0
  140. package/dist/infra/usecase/status-use-case.js +53 -0
  141. package/dist/resources/prompts/curate.yml +114 -4
  142. package/dist/resources/prompts/explore.yml +34 -0
  143. package/dist/resources/prompts/query-orchestrator.yml +112 -0
  144. package/dist/resources/prompts/system-prompt.yml +12 -2
  145. package/dist/resources/tools/search_knowledge.txt +32 -0
  146. package/dist/templates/mcp-base.md +1 -0
  147. package/dist/templates/sections/brv-instructions.md +98 -0
  148. package/dist/templates/sections/mcp-workflow.md +13 -0
  149. package/dist/tui/app.js +4 -1
  150. package/dist/tui/components/command-details.js +1 -1
  151. package/dist/tui/components/execution/execution-changes.d.ts +2 -0
  152. package/dist/tui/components/execution/execution-changes.js +5 -1
  153. package/dist/tui/components/execution/execution-content.d.ts +2 -0
  154. package/dist/tui/components/execution/execution-content.js +8 -18
  155. package/dist/tui/components/execution/execution-input.d.ts +2 -0
  156. package/dist/tui/components/execution/execution-input.js +6 -4
  157. package/dist/tui/components/execution/execution-progress.d.ts +2 -0
  158. package/dist/tui/components/execution/execution-progress.js +6 -2
  159. package/dist/tui/components/execution/expanded-log-view.d.ts +20 -0
  160. package/dist/tui/components/execution/expanded-log-view.js +75 -0
  161. package/dist/tui/components/execution/expanded-message-view.d.ts +24 -0
  162. package/dist/tui/components/execution/expanded-message-view.js +68 -0
  163. package/dist/tui/components/execution/index.d.ts +2 -0
  164. package/dist/tui/components/execution/index.js +2 -0
  165. package/dist/tui/components/execution/log-item.d.ts +4 -0
  166. package/dist/tui/components/execution/log-item.js +2 -2
  167. package/dist/tui/components/footer.js +1 -1
  168. package/dist/tui/components/index.d.ts +2 -1
  169. package/dist/tui/components/index.js +2 -1
  170. package/dist/tui/components/init.js +2 -9
  171. package/dist/tui/components/logo.js +4 -3
  172. package/dist/tui/components/markdown.d.ts +13 -0
  173. package/dist/tui/components/markdown.js +88 -0
  174. package/dist/tui/components/message-item.js +1 -1
  175. package/dist/tui/components/onboarding/onboarding-flow.js +14 -11
  176. package/dist/tui/components/onboarding/welcome-box.js +1 -1
  177. package/dist/tui/components/suggestions.js +3 -3
  178. package/dist/tui/contexts/mode-context.js +6 -2
  179. package/dist/tui/contexts/onboarding-context.d.ts +4 -0
  180. package/dist/tui/contexts/onboarding-context.js +14 -2
  181. package/dist/tui/hooks/index.d.ts +1 -0
  182. package/dist/tui/hooks/index.js +1 -0
  183. package/dist/tui/hooks/use-is-latest-version.d.ts +6 -0
  184. package/dist/tui/hooks/use-is-latest-version.js +22 -0
  185. package/dist/tui/views/command-view.d.ts +1 -1
  186. package/dist/tui/views/command-view.js +87 -98
  187. package/dist/tui/views/logs-view.d.ts +8 -0
  188. package/dist/tui/views/logs-view.js +55 -27
  189. package/dist/utils/file-validator.d.ts +1 -1
  190. package/dist/utils/file-validator.js +25 -28
  191. package/dist/utils/type-guards.d.ts +5 -0
  192. package/dist/utils/type-guards.js +7 -0
  193. package/oclif.manifest.json +55 -4
  194. package/package.json +12 -1
  195. package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +0 -3
  196. package/dist/infra/repl/commands/gen-rules-command.d.ts +0 -7
  197. package/dist/infra/rule/agent-rule-config.d.ts +0 -19
  198. package/dist/infra/rule/rule-template-service.d.ts +0 -18
  199. package/dist/infra/rule/rule-template-service.js +0 -88
  200. package/dist/infra/usecase/generate-rules-use-case.d.ts +0 -61
  201. package/dist/infra/usecase/generate-rules-use-case.js +0 -285
  202. /package/dist/core/interfaces/{usecase/i-generate-rules-use-case.js → connectors/connector-types.js} +0 -0
  203. /package/dist/infra/{rule → connectors/shared}/constants.d.ts +0 -0
  204. /package/dist/infra/{rule → connectors/shared}/constants.js +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ByteRover CLI
2
2
 
3
- Command-line interface for ByteRover, featuring an interactive REPL with a modern React/Ink terminal UI for managing your project's context tree and knowledge storage. Seamlessly integrate with AI coding agents like Claude Code, Cursor, Windsurf, and GitHub Copilot.
3
+ Command-line interface for ByteRover, featuring an interactive REPL with a modern React/Ink terminal UI for managing your project's context tree and knowledge storage. Seamlessly integrate with 18+ AI coding agents including Claude Code, Cursor, Windsurf, GitHub Copilot, Cline, and more.
4
4
 
5
5
  [![Version](https://img.shields.io/npm/v/byterover-cli.svg)](https://npmjs.org/package/byterover-cli)
6
6
  [![Downloads/week](https://img.shields.io/npm/dw/byterover-cli.svg)](https://npmjs.org/package/byterover-cli)
@@ -31,6 +31,7 @@ Command-line interface for ByteRover, featuring an interactive REPL with a moder
31
31
  - Debian/Ubuntu: `sudo apt-get install libsecret-1-dev`
32
32
  - Red Hat-based: `sudo yum install libsecret-devel`
33
33
  - Arch Linux: `sudo pacman -S libsecret`
34
+ - **WSL (Windows Subsystem for Linux)**: Supported with automatic file-based token storage fallback when keychain is unavailable
34
35
 
35
36
  ### Install globally via npm
36
37
 
@@ -46,7 +47,7 @@ brv --version
46
47
 
47
48
  ## Quick Start
48
49
 
49
- Visit [**ByteRover's Beta Docs**](https://docs.byterover.dev/beta) for more information.
50
+ Visit [**ByteRover Docs**](https://docs.byterover.dev) for more information.
50
51
 
51
52
  Get started with ByteRover CLI in three simple steps:
52
53
 
@@ -99,7 +100,9 @@ The terminal UI includes:
99
100
  - **Command Completion**: Type `/` to see available commands with auto-completion
100
101
  - **Activity Log**: Real-time task status and execution progress
101
102
  - **Streaming Output**: Live responses from AI-powered operations
102
- - **File References**: Type `@` in curate mode to browse and attach files
103
+ - **File References**: Type `@` in curate mode to browse and attach files (supports PDF)
104
+ - **Dynamic Domains**: Automatically creates new knowledge domains as your context tree grows
105
+ - **Session Persistence**: Sessions auto-resume after restart
103
106
 
104
107
  ### Using Commands
105
108
 
@@ -122,7 +125,7 @@ The **Context Tree** is ByteRover's structured knowledge system that helps you a
122
125
  - **Organized Knowledge**: Structure your project knowledge by domain and topic
123
126
  - **Easy Retrieval**: Find relevant context quickly when you need it
124
127
  - **Persistent Memory**: Maintain project-specific knowledge across sessions
125
- - **Agent-Friendly**: Works seamlessly with AI coding agents like Claude Code, Cursor, Windsurf, and GitHub Copilot
128
+ - **Agent-Friendly**: Works seamlessly with 18+ AI coding agents (Claude Code, Cursor, Windsurf, GitHub Copilot, Cline, and more) via rules-based or hook-based integration
126
129
  - **Cloud Sync**: Push and sync your context tree to ByteRover's cloud storage for backup and team collaboration
127
130
  - **Dynamic Domains**: Automatically creates new domains as your knowledge grows
128
131
 
@@ -135,13 +138,16 @@ The context tree organizes knowledge into:
135
138
 
136
139
  ### Integrating with Coding Agents
137
140
 
138
- Use `/gen-rules` to generate rule instruction files that help your AI coding agents understand and work with ByteRover:
141
+ Use `/connectors` to manage integrations with your AI coding agents:
139
142
 
140
143
  ```
141
- /gen-rules
144
+ /connectors
142
145
  ```
143
146
 
144
- This creates agent-specific rule files (e.g., `CLAUDE.md`, `.cursorrules`) that instruct the agent how to read from and contribute to your context tree.
147
+ ByteRover supports three connector types:
148
+ - **Hook integration** (Claude Code): Direct injection via IDE settings for seamless integration
149
+ - **Rules-based** (all agents): Generates agent-specific rule files (e.g., `CLAUDE.md`, `.cursorrules`) that instruct the agent how to read from and contribute to your context tree
150
+ - **MCP integration** (Model Context Protocol): Exposes `brv-query` and `brv-curate` as MCP tools that AI agents can call directly
145
151
 
146
152
  ## Slash Commands Reference
147
153
 
@@ -157,7 +163,7 @@ This creates agent-specific rule files (e.g., `CLAUDE.md`, `.cursorrules`) that
157
163
  ```
158
164
  /curate # Interactive mode
159
165
  /curate "Auth uses JWT tokens" # Autonomous mode with text
160
- /curate "API docs" @src/api.ts @README.md # With file references (max 5)
166
+ /curate "API docs" @src/api.ts @README.md # With file references (max 5, supports PDF)
161
167
  ```
162
168
 
163
169
  **Query example:**
@@ -198,12 +204,12 @@ This creates agent-specific rule files (e.g., `CLAUDE.md`, `.cursorrules`) that
198
204
  - `-l, --limit <n>`: Maximum spaces to fetch (default: 50)
199
205
  - `-o, --offset <n>`: Number of spaces to skip
200
206
 
201
- ### Context Tree Management
207
+ ### Connectors & Context Tree Management
202
208
 
203
209
  | Command | Description |
204
210
  |---------|-------------|
205
- | `/gen-rules` | Generate rule files for AI coding agents (Claude Code, Cursor, etc.) |
206
- | `/reset [-y] [directory]` | Reset context tree to default domains |
211
+ | `/connectors` | Manage agent connectors (rules-based or hook integration) |
212
+ | `/reset [-y] [directory]` | Reset context tree to empty state |
207
213
 
208
214
  **Reset options:**
209
215
  - `-y, --yes`: Skip confirmation prompt
@@ -217,7 +223,7 @@ This creates agent-specific rule files (e.g., `CLAUDE.md`, `.cursorrules`) that
217
223
  **Options:**
218
224
  - `-y, --yes`: Skip confirmation prompt
219
225
 
220
- **Note:** This command does NOT affect the context treeit only clears the conversation history and starts a new session.
226
+ **Note:** Sessions are stateful and auto-resume after restart. Use `/new` to start freshthis clears conversation history but does NOT affect the context tree.
221
227
 
222
228
  ### Project Setup
223
229
 
@@ -339,7 +345,7 @@ If you encounter issues or have questions:
339
345
 
340
346
  1. Check the command help in the REPL
341
347
  2. Run `/status` to review your project state
342
- 3. Visit [ByteRover Docs](https://docs.byterover.dev)
348
+ 3. Visit the [ByteRover Docs](https://docs.byterover.dev)
343
349
  4. Contact ByteRover support
344
350
 
345
351
  ---
@@ -0,0 +1,27 @@
1
+ import { Command } from '@oclif/core';
2
+ import { ITemplateLoader } from '../core/interfaces/i-template-loader.js';
3
+ /**
4
+ * Dependencies required by HookPromptSubmit command.
5
+ * Exported for test mocking.
6
+ */
7
+ export type HookPromptSubmitDependencies = {
8
+ templateLoader: ITemplateLoader;
9
+ };
10
+ /**
11
+ * Hidden command for coding agent pre-prompt hooks.
12
+ * Outputs ByteRover workflow instructions to stdout.
13
+ * The agent wraps the output in system context (e.g., <system-reminder> tags).
14
+ *
15
+ * Supported agents:
16
+ * - Claude Code: .claude/settings.local.json (UserPromptSubmit)
17
+ */
18
+ export default class HookPromptSubmit extends Command {
19
+ static description: string;
20
+ static hidden: boolean;
21
+ /**
22
+ * Factory method for creating dependencies.
23
+ * Override in tests to inject mock dependencies.
24
+ */
25
+ protected createDependencies(): HookPromptSubmitDependencies;
26
+ run(): Promise<void>;
27
+ }
@@ -0,0 +1,39 @@
1
+ import { Command } from '@oclif/core';
2
+ import { isDevelopment } from '../config/environment.js';
3
+ import { FsFileService } from '../infra/file/fs-file-service.js';
4
+ import { FsTemplateLoader } from '../infra/template/fs-template-loader.js';
5
+ /**
6
+ * Hidden command for coding agent pre-prompt hooks.
7
+ * Outputs ByteRover workflow instructions to stdout.
8
+ * The agent wraps the output in system context (e.g., <system-reminder> tags).
9
+ *
10
+ * Supported agents:
11
+ * - Claude Code: .claude/settings.local.json (UserPromptSubmit)
12
+ */
13
+ export default class HookPromptSubmit extends Command {
14
+ static description = 'Internal: Pre-prompt hook for coding agents';
15
+ static hidden = true;
16
+ /**
17
+ * Factory method for creating dependencies.
18
+ * Override in tests to inject mock dependencies.
19
+ */
20
+ createDependencies() {
21
+ const fileService = new FsFileService();
22
+ const templateLoader = new FsTemplateLoader(fileService);
23
+ return { templateLoader };
24
+ }
25
+ async run() {
26
+ try {
27
+ const { templateLoader } = this.createDependencies();
28
+ const instructions = await templateLoader.loadSection('brv-instructions');
29
+ // Output to stdout (agent wraps in system context)
30
+ this.log(instructions);
31
+ }
32
+ catch (error) {
33
+ // Silently fail in production - don't interrupt agent workflow
34
+ if (isDevelopment()) {
35
+ console.error('[hook-prompt-submit] Template load failed:', error);
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,13 @@
1
+ import { Command } from '@oclif/core';
2
+ /**
3
+ * MCP command - starts the MCP server for coding agent integration.
4
+ *
5
+ * This command is spawned by coding agents (Claude Code, Cursor, Windsurf)
6
+ * and connects to a running brv instance via Socket.IO.
7
+ */
8
+ export default class Mcp extends Command {
9
+ static description: string;
10
+ static examples: string[];
11
+ static hidden: boolean;
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,61 @@
1
+ import { Command } from '@oclif/core';
2
+ import { NoInstanceRunningError } from '../core/domain/errors/connection-error.js';
3
+ import { ByteRoverMcpServer } from '../infra/mcp/index.js';
4
+ /**
5
+ * MCP command - starts the MCP server for coding agent integration.
6
+ *
7
+ * This command is spawned by coding agents (Claude Code, Cursor, Windsurf)
8
+ * and connects to a running brv instance via Socket.IO.
9
+ */
10
+ export default class Mcp extends Command {
11
+ static description = `Start MCP server for coding agent integration
12
+
13
+ Connects to a running brv instance via Socket.IO.
14
+ Requires: brv running in another terminal.
15
+
16
+ Exposes tools:
17
+ - brv-query: Query the context tree
18
+ - brv-curate: Curate context to the tree`;
19
+ static examples = [
20
+ '# Start MCP server (typically called by coding agents)',
21
+ '<%= config.bin %> <%= command.id %>',
22
+ ];
23
+ static hidden = true; // Called by agents, not users directly
24
+ async run() {
25
+ try {
26
+ const server = new ByteRoverMcpServer({
27
+ version: this.config.version,
28
+ workingDirectory: process.cwd(),
29
+ });
30
+ // Graceful shutdown
31
+ const cleanup = async () => {
32
+ await server.stop();
33
+ // eslint-disable-next-line n/no-process-exit, unicorn/no-process-exit
34
+ process.exit(0);
35
+ };
36
+ process.on('SIGTERM', cleanup);
37
+ process.on('SIGINT', cleanup);
38
+ await server.start();
39
+ // Keep the process alive - MCP server runs on stdio
40
+ // The process will be terminated by SIGTERM/SIGINT or when the parent process closes stdin
41
+ await new Promise((resolve) => {
42
+ process.stdin.on('close', () => {
43
+ resolve();
44
+ });
45
+ process.stdin.on('end', () => {
46
+ resolve();
47
+ });
48
+ });
49
+ await server.stop();
50
+ }
51
+ catch (error) {
52
+ if (error instanceof NoInstanceRunningError) {
53
+ this.logToStderr('Error: No ByteRover instance running.');
54
+ this.logToStderr('Start one with: brv');
55
+ // eslint-disable-next-line n/no-process-exit, unicorn/no-process-exit
56
+ process.exit(1);
57
+ }
58
+ throw error;
59
+ }
60
+ }
61
+ }
@@ -14,9 +14,14 @@ export default class Status extends Command {
14
14
  static description = 'Show CLI status and project information. Display local context tree managed by ByteRover CLI';
15
15
  static examples = [
16
16
  '<%= config.bin %> <%= command.id %>',
17
- '# Check status after login:\n<%= config.bin %> login\n<%= config.bin %> <%= command.id %>',
18
- '# Verify project initialization:\n<%= config.bin %> init\n<%= config.bin %> <%= command.id %>',
19
- '<%= config.bin %> <%= command.id %>',
17
+ '# Check status after login (in REPL):',
18
+ '/login',
19
+ '/status',
20
+ '',
21
+ '# Verify project initialization (in REPL):',
22
+ '/init',
23
+ '/status',
24
+ '',
20
25
  '<%= config.bin %> <%= command.id %> /path/to/project',
21
26
  '<%= config.bin %> <%= command.id %> --format json',
22
27
  ];
@@ -23,7 +23,7 @@ export declare const DEFAULT_BRANCH = "main";
23
23
  * ByteRover documentation URL.
24
24
  * Used in CLI help output to direct users to online documentation.
25
25
  */
26
- export declare const DOCS_URL = "https://docs.byterover.dev/beta";
26
+ export declare const DOCS_URL = "https://docs.byterover.dev";
27
27
  export declare const TRANSPORT_HOST = "127.0.0.1";
28
28
  export declare const TRANSPORT_REQUEST_TIMEOUT_MS = 10000;
29
29
  export declare const TRANSPORT_ROOM_TIMEOUT_MS = 2000;
package/dist/constants.js CHANGED
@@ -28,7 +28,7 @@ export const DEFAULT_BRANCH = 'main';
28
28
  * ByteRover documentation URL.
29
29
  * Used in CLI help output to direct users to online documentation.
30
30
  */
31
- export const DOCS_URL = 'https://docs.byterover.dev/beta';
31
+ export const DOCS_URL = 'https://docs.byterover.dev';
32
32
  // Transport layer constants (optimized for localhost real-time)
33
33
  export const TRANSPORT_HOST = '127.0.0.1'; // Use hostname for better sandbox compatibility
34
34
  export const TRANSPORT_REQUEST_TIMEOUT_MS = 10_000; // 10s - most operations complete quickly
@@ -497,11 +497,13 @@ export interface SessionEventMap {
497
497
  * Emitted when a chunk of content is received (streaming).
498
498
  * @property {string} content - Content of the chunk
499
499
  * @property {boolean} [isComplete] - Whether this is the final chunk
500
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
500
501
  * @property {'reasoning' | 'text'} type - Type of chunk (text or reasoning)
501
502
  */
502
503
  'llmservice:chunk': {
503
504
  content: string;
504
505
  isComplete?: boolean;
506
+ taskId?: string;
505
507
  type: 'reasoning' | 'text';
506
508
  };
507
509
  /**
@@ -509,32 +511,38 @@ export interface SessionEventMap {
509
511
  * @property {number} compressedTokens - Token count after compression
510
512
  * @property {number} originalTokens - Token count before compression
511
513
  * @property {'middle_removal' | 'oldest_removal' | 'summary'} strategy - Compression strategy used
514
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
512
515
  */
513
516
  'llmservice:contextCompressed': {
514
517
  compressedTokens: number;
515
518
  originalTokens: number;
516
519
  strategy: 'middle_removal' | 'oldest_removal' | 'summary';
520
+ taskId?: string;
517
521
  };
518
522
  /**
519
523
  * Emitted when context is approaching the token limit.
520
524
  * @property {number} currentTokens - Current token count
521
525
  * @property {number} maxTokens - Maximum allowed tokens
526
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
522
527
  * @property {number} utilizationPercent - Percentage of context used (0-100)
523
528
  */
524
529
  'llmservice:contextOverflow': {
525
530
  currentTokens: number;
526
531
  maxTokens: number;
532
+ taskId?: string;
527
533
  utilizationPercent: number;
528
534
  };
529
535
  /**
530
536
  * Emitted when old tool outputs are pruned to save context space.
531
537
  * @property {number} pruneCount - Number of tool outputs pruned
532
538
  * @property {'manual' | 'overflow'} reason - Why pruning was triggered
539
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
533
540
  * @property {number} tokensSaved - Estimated tokens saved
534
541
  */
535
542
  'llmservice:contextPruned': {
536
543
  pruneCount: number;
537
544
  reason: 'manual' | 'overflow';
545
+ taskId?: string;
538
546
  tokensSaved: number;
539
547
  };
540
548
  /**
@@ -543,32 +551,38 @@ export interface SessionEventMap {
543
551
  * @property {Record<string, unknown>} args - Arguments that were repeated
544
552
  * @property {'exact_repeat' | 'oscillation'} loopType - Type of loop detected
545
553
  * @property {number} repeatCount - Number of times the pattern repeated
554
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
546
555
  * @property {string} toolName - Name of the tool involved in the loop
547
556
  */
548
557
  'llmservice:doomLoopDetected': {
549
558
  args: Record<string, unknown>;
550
559
  loopType: 'exact_repeat' | 'oscillation';
551
560
  repeatCount: number;
561
+ taskId?: string;
552
562
  toolName: string;
553
563
  };
554
564
  /**
555
565
  * Emitted when an error occurs during LLM service operation.
556
566
  * @property {string} [code] - Error code (optional)
557
567
  * @property {string} error - Error message
568
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
558
569
  */
559
570
  'llmservice:error': {
560
571
  code?: string;
561
572
  error: string;
573
+ taskId?: string;
562
574
  };
563
575
  /**
564
576
  * Emitted when tool output is truncated due to size.
565
577
  * @property {number} originalLength - Original output length before truncation
566
578
  * @property {string} savedToFile - Path to file where full output was saved
579
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
567
580
  * @property {string} toolName - Name of the tool that produced the output
568
581
  */
569
582
  'llmservice:outputTruncated': {
570
583
  originalLength: number;
571
584
  savedToFile: string;
585
+ taskId?: string;
572
586
  toolName: string;
573
587
  };
574
588
  /**
@@ -578,6 +592,7 @@ export interface SessionEventMap {
578
592
  * @property {boolean} [partial] - Whether this is a partial response (e.g., max iterations reached)
579
593
  * @property {string} [provider] - LLM provider name
580
594
  * @property {string} [reasoning] - Internal reasoning (if available)
595
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
581
596
  * @property {TokenUsage} [tokenUsage] - Token usage statistics
582
597
  */
583
598
  'llmservice:response': {
@@ -586,30 +601,38 @@ export interface SessionEventMap {
586
601
  partial?: boolean;
587
602
  provider?: string;
588
603
  reasoning?: string;
604
+ taskId?: string;
589
605
  tokenUsage?: TokenUsage;
590
606
  };
591
607
  /**
592
608
  * Emitted when LLM service starts thinking/processing.
609
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
593
610
  */
594
- 'llmservice:thinking': void;
611
+ 'llmservice:thinking': void | {
612
+ taskId?: string;
613
+ };
595
614
  /**
596
615
  * Emitted when LLM generates a thought (Gemini models only).
597
616
  * @property {string} description - Detailed thought description
598
617
  * @property {string} subject - Brief thought subject
618
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
599
619
  */
600
620
  'llmservice:thought': {
601
621
  description: string;
602
622
  subject: string;
623
+ taskId?: string;
603
624
  };
604
625
  /**
605
626
  * Emitted when LLM requests a tool call.
606
627
  * @property {Record<string, unknown>} args - Arguments for the tool
607
628
  * @property {string} [callId] - Unique identifier for this tool call
629
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
608
630
  * @property {string} toolName - Name of the tool to execute
609
631
  */
610
632
  'llmservice:toolCall': {
611
633
  args: Record<string, unknown>;
612
634
  callId?: string;
635
+ taskId?: string;
613
636
  toolName: string;
614
637
  };
615
638
  /**
@@ -617,11 +640,13 @@ export interface SessionEventMap {
617
640
  * Allows tools to push real-time updates (e.g., bash output streaming).
618
641
  * @property {string} callId - Tool call identifier
619
642
  * @property {Record<string, unknown>} metadata - The metadata update
643
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
620
644
  * @property {string} toolName - Name of the tool streaming metadata
621
645
  */
622
646
  'llmservice:toolMetadata': {
623
647
  callId: string;
624
648
  metadata: Record<string, unknown>;
649
+ taskId?: string;
625
650
  toolName: string;
626
651
  };
627
652
  /**
@@ -632,6 +657,7 @@ export interface SessionEventMap {
632
657
  * @property {Record<string, unknown>} [metadata] - Execution metadata (duration, tokens, etc.)
633
658
  * @property {unknown} [result] - Tool execution result
634
659
  * @property {boolean} success - Whether execution succeeded
660
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
635
661
  * @property {string} toolName - Name of the executed tool
636
662
  */
637
663
  'llmservice:toolResult': {
@@ -641,32 +667,39 @@ export interface SessionEventMap {
641
667
  metadata?: Record<string, unknown>;
642
668
  result?: unknown;
643
669
  success: boolean;
670
+ taskId?: string;
644
671
  toolName: string;
645
672
  };
646
673
  /**
647
674
  * Emitted when LLM receives unsupported input.
648
675
  * @property {string} reason - Reason why input is unsupported
676
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
649
677
  */
650
678
  'llmservice:unsupportedInput': {
651
679
  reason: string;
680
+ taskId?: string;
652
681
  };
653
682
  /**
654
683
  * Emitted when LLM service encounters a warning (e.g., max iterations reached).
655
684
  * @property {string} message - Warning message
656
685
  * @property {string} [model] - Model identifier
657
686
  * @property {string} [provider] - LLM provider name
687
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
658
688
  */
659
689
  'llmservice:warning': {
660
690
  message: string;
661
691
  model?: string;
662
692
  provider?: string;
693
+ taskId?: string;
663
694
  };
664
695
  /**
665
696
  * Emitted when queued messages are dequeued for processing.
666
697
  * @property {number} count - Number of messages that were dequeued
698
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
667
699
  */
668
700
  'message:dequeued': {
669
701
  count: number;
702
+ taskId?: string;
670
703
  };
671
704
  /**
672
705
  * Emitted when a message is queued because session is busy.
@@ -675,6 +708,7 @@ export interface SessionEventMap {
675
708
  * @property {string} message.content - Message text content
676
709
  * @property {number} message.queuedAt - Timestamp when queued
677
710
  * @property {number} position - Position in the queue (1-based)
711
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
678
712
  */
679
713
  'message:queued': {
680
714
  message: {
@@ -683,6 +717,7 @@ export interface SessionEventMap {
683
717
  queuedAt: number;
684
718
  };
685
719
  position: number;
720
+ taskId?: string;
686
721
  };
687
722
  /**
688
723
  * Emitted when a session run completes (streaming API lifecycle event).
@@ -690,20 +725,24 @@ export interface SessionEventMap {
690
725
  * @property {Error} [error] - Error if terminated due to error
691
726
  * @property {'cancelled' | 'error' | 'max-iterations' | 'stop' | 'timeout'} finishReason - Why execution terminated
692
727
  * @property {number} stepCount - Number of agentic steps completed
728
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
693
729
  */
694
730
  'run:complete': {
695
731
  durationMs: number;
696
732
  error?: Error;
697
733
  finishReason: 'cancelled' | 'error' | 'max-iterations' | 'stop' | 'timeout';
698
734
  stepCount: number;
735
+ taskId?: string;
699
736
  };
700
737
  /**
701
738
  * Emitted when session status changes.
702
739
  * Tracks the lifecycle state of a session (idle, busy, retry, waiting).
703
740
  * @property {SessionStatusType} status - The new session status
741
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
704
742
  */
705
743
  'session:statusChanged': {
706
744
  status: SessionStatusType;
745
+ taskId?: string;
707
746
  };
708
747
  /**
709
748
  * Emitted when an execution step finishes.
@@ -711,20 +750,24 @@ export interface SessionEventMap {
711
750
  * @property {number} cost - Cost in dollars for this step
712
751
  * @property {'max_tokens' | 'stop' | 'tool_calls'} finishReason - Why step finished
713
752
  * @property {number} stepIndex - Step index (0-based)
753
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
714
754
  * @property {StepTokenUsage} tokens - Token usage for this step
715
755
  */
716
756
  'step:finished': {
717
757
  cost: number;
718
758
  finishReason: 'max_tokens' | 'stop' | 'tool_calls';
719
759
  stepIndex: number;
760
+ taskId?: string;
720
761
  tokens: StepTokenUsage;
721
762
  };
722
763
  /**
723
764
  * Emitted when an execution step starts.
724
765
  * @property {number} stepIndex - Step index (0-based)
766
+ * @property {string} [taskId] - Optional task ID for concurrent task isolation
725
767
  */
726
768
  'step:started': {
727
769
  stepIndex: number;
770
+ taskId?: string;
728
771
  };
729
772
  }
730
773
  /**
@@ -20,6 +20,7 @@ export declare const ToolName: {
20
20
  readonly READ_MEMORY: 'read_memory';
21
21
  readonly READ_TODOS: 'read_todos';
22
22
  readonly SEARCH_HISTORY: 'search_history';
23
+ readonly SEARCH_KNOWLEDGE: 'search_knowledge';
23
24
  readonly SPEC_ANALYZE: 'spec_analyze';
24
25
  readonly TASK: 'task';
25
26
  readonly WRITE_FILE: 'write_file';
@@ -20,6 +20,7 @@ export const ToolName = {
20
20
  READ_MEMORY: 'read_memory',
21
21
  READ_TODOS: 'read_todos',
22
22
  SEARCH_HISTORY: 'search_history',
23
+ SEARCH_KNOWLEDGE: 'search_knowledge',
23
24
  SPEC_ANALYZE: 'spec_analyze',
24
25
  TASK: 'task',
25
26
  WRITE_FILE: 'write_file',
@@ -1,5 +1,21 @@
1
+ import type { ConnectorType } from './connector-type.js';
1
2
  /**
2
3
  * Array of all supported Agents.
3
4
  */
4
5
  export declare const AGENT_VALUES: readonly ["Amp", "Augment Code", "Claude Code", "Cline", "Codex", "Cursor", "Gemini CLI", "Github Copilot", "Junie", "Kilo Code", "Kiro", "Qoder", "Qwen Code", "Roo Code", "Trae.ai", "Warp", "Windsurf", "Zed"];
5
6
  export type Agent = (typeof AGENT_VALUES)[number];
7
+ /**
8
+ * Connector availability configuration for an agent.
9
+ */
10
+ type AgentConnectorConfig = {
11
+ /** The default connector type for this agent */
12
+ default: ConnectorType;
13
+ /** Connector types supported by this agent */
14
+ supported: readonly ConnectorType[];
15
+ };
16
+ /**
17
+ * Single source of truth for agent connector configuration.
18
+ * Defines which connectors each agent supports and which is the default.
19
+ */
20
+ export declare const AGENT_CONNECTOR_CONFIG: Record<Agent, AgentConnectorConfig>;
21
+ export {};