byterover-cli 1.0.5 → 1.1.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 (124) hide show
  1. package/README.md +12 -10
  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/status.js +8 -3
  5. package/dist/constants.d.ts +1 -1
  6. package/dist/constants.js +1 -1
  7. package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
  8. package/dist/core/domain/cipher/tools/constants.js +1 -0
  9. package/dist/core/domain/entities/agent.d.ts +16 -0
  10. package/dist/core/domain/entities/agent.js +24 -0
  11. package/dist/core/domain/entities/connector-type.d.ts +9 -0
  12. package/dist/core/domain/entities/connector-type.js +8 -0
  13. package/dist/core/domain/entities/event.d.ts +1 -1
  14. package/dist/core/domain/entities/event.js +2 -0
  15. package/dist/core/domain/errors/task-error.d.ts +4 -0
  16. package/dist/core/domain/errors/task-error.js +7 -0
  17. package/dist/core/domain/transport/schemas.d.ts +40 -0
  18. package/dist/core/domain/transport/schemas.js +28 -0
  19. package/dist/core/interfaces/connectors/connector-types.d.ts +57 -0
  20. package/dist/core/interfaces/connectors/i-connector-manager.d.ts +72 -0
  21. package/dist/core/interfaces/connectors/i-connector-manager.js +1 -0
  22. package/dist/core/interfaces/connectors/i-connector.d.ts +54 -0
  23. package/dist/core/interfaces/connectors/i-connector.js +1 -0
  24. package/dist/core/interfaces/i-file-service.d.ts +7 -0
  25. package/dist/core/interfaces/usecase/i-connectors-use-case.d.ts +3 -0
  26. package/dist/core/interfaces/usecase/i-connectors-use-case.js +1 -0
  27. package/dist/hooks/init/update-notifier.d.ts +1 -0
  28. package/dist/hooks/init/update-notifier.js +10 -1
  29. package/dist/infra/cipher/file-system/binary-utils.d.ts +7 -12
  30. package/dist/infra/cipher/file-system/binary-utils.js +46 -31
  31. package/dist/infra/cipher/llm/context/context-manager.d.ts +2 -2
  32. package/dist/infra/cipher/llm/context/context-manager.js +23 -2
  33. package/dist/infra/cipher/llm/formatters/gemini-formatter.js +48 -9
  34. package/dist/infra/cipher/llm/internal-llm-service.js +2 -2
  35. package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.d.ts +6 -7
  36. package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.js +57 -18
  37. package/dist/infra/cipher/tools/implementations/curate-tool.js +20 -2
  38. package/dist/infra/cipher/tools/implementations/read-file-tool.js +38 -17
  39. package/dist/infra/cipher/tools/implementations/search-knowledge-tool.d.ts +7 -0
  40. package/dist/infra/cipher/tools/implementations/search-knowledge-tool.js +303 -0
  41. package/dist/infra/cipher/tools/index.d.ts +1 -0
  42. package/dist/infra/cipher/tools/index.js +1 -0
  43. package/dist/infra/cipher/tools/tool-manager.js +1 -0
  44. package/dist/infra/cipher/tools/tool-registry.js +7 -0
  45. package/dist/infra/connectors/connector-manager.d.ts +32 -0
  46. package/dist/infra/connectors/connector-manager.js +156 -0
  47. package/dist/infra/connectors/hook/hook-connector-config.d.ts +52 -0
  48. package/dist/infra/connectors/hook/hook-connector-config.js +41 -0
  49. package/dist/infra/connectors/hook/hook-connector.d.ts +46 -0
  50. package/dist/infra/connectors/hook/hook-connector.js +231 -0
  51. package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.d.ts +2 -2
  52. package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.js +1 -1
  53. package/dist/infra/connectors/rules/rules-connector-config.d.ts +95 -0
  54. package/dist/infra/{rule/agent-rule-config.js → connectors/rules/rules-connector-config.js} +10 -10
  55. package/dist/infra/connectors/rules/rules-connector.d.ts +41 -0
  56. package/dist/infra/connectors/rules/rules-connector.js +204 -0
  57. package/dist/infra/{rule/rule-template-service.d.ts → connectors/shared/template-service.d.ts} +3 -3
  58. package/dist/infra/{rule/rule-template-service.js → connectors/shared/template-service.js} +1 -1
  59. package/dist/infra/context-tree/file-context-tree-writer-service.d.ts +5 -2
  60. package/dist/infra/context-tree/file-context-tree-writer-service.js +20 -5
  61. package/dist/infra/core/executors/curate-executor.d.ts +2 -2
  62. package/dist/infra/core/executors/curate-executor.js +7 -7
  63. package/dist/infra/core/executors/query-executor.d.ts +12 -0
  64. package/dist/infra/core/executors/query-executor.js +62 -1
  65. package/dist/infra/file/fs-file-service.d.ts +7 -0
  66. package/dist/infra/file/fs-file-service.js +15 -1
  67. package/dist/infra/process/agent-worker.d.ts +2 -2
  68. package/dist/infra/process/agent-worker.js +626 -142
  69. package/dist/infra/process/constants.d.ts +1 -1
  70. package/dist/infra/process/constants.js +1 -1
  71. package/dist/infra/process/ipc-types.d.ts +17 -4
  72. package/dist/infra/process/ipc-types.js +3 -3
  73. package/dist/infra/process/parent-heartbeat.d.ts +47 -0
  74. package/dist/infra/process/parent-heartbeat.js +118 -0
  75. package/dist/infra/process/process-manager.d.ts +79 -0
  76. package/dist/infra/process/process-manager.js +277 -3
  77. package/dist/infra/process/task-queue-manager.d.ts +13 -0
  78. package/dist/infra/process/task-queue-manager.js +19 -0
  79. package/dist/infra/process/transport-handlers.d.ts +3 -0
  80. package/dist/infra/process/transport-handlers.js +51 -5
  81. package/dist/infra/process/transport-worker.js +9 -69
  82. package/dist/infra/repl/commands/connectors-command.d.ts +8 -0
  83. package/dist/infra/repl/commands/{gen-rules-command.js → connectors-command.js} +21 -10
  84. package/dist/infra/repl/commands/index.js +3 -2
  85. package/dist/infra/repl/commands/init-command.js +11 -7
  86. package/dist/infra/repl/commands/query-command.js +22 -2
  87. package/dist/infra/repl/commands/reset-command.js +1 -1
  88. package/dist/infra/transport/socket-io-transport-client.d.ts +68 -0
  89. package/dist/infra/transport/socket-io-transport-client.js +283 -7
  90. package/dist/infra/usecase/connectors-use-case.d.ts +59 -0
  91. package/dist/infra/usecase/connectors-use-case.js +203 -0
  92. package/dist/infra/usecase/init-use-case.d.ts +8 -43
  93. package/dist/infra/usecase/init-use-case.js +27 -251
  94. package/dist/infra/usecase/logout-use-case.js +1 -1
  95. package/dist/infra/usecase/pull-use-case.js +5 -5
  96. package/dist/infra/usecase/push-use-case.js +4 -4
  97. package/dist/infra/usecase/reset-use-case.js +3 -4
  98. package/dist/infra/usecase/space-list-use-case.js +3 -3
  99. package/dist/infra/usecase/space-switch-use-case.js +3 -3
  100. package/dist/resources/prompts/curate.yml +7 -0
  101. package/dist/resources/prompts/explore.yml +34 -0
  102. package/dist/resources/prompts/query-orchestrator.yml +112 -0
  103. package/dist/resources/prompts/system-prompt.yml +12 -2
  104. package/dist/resources/tools/search_knowledge.txt +32 -0
  105. package/dist/templates/sections/brv-instructions.md +98 -0
  106. package/dist/tui/components/onboarding/onboarding-flow.js +14 -11
  107. package/dist/tui/components/onboarding/welcome-box.js +1 -1
  108. package/dist/tui/contexts/onboarding-context.d.ts +4 -0
  109. package/dist/tui/contexts/onboarding-context.js +14 -2
  110. package/dist/tui/views/command-view.js +4 -0
  111. package/dist/utils/file-validator.d.ts +1 -1
  112. package/dist/utils/file-validator.js +25 -28
  113. package/dist/utils/type-guards.d.ts +5 -0
  114. package/dist/utils/type-guards.js +7 -0
  115. package/oclif.manifest.json +30 -4
  116. package/package.json +4 -1
  117. package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +0 -3
  118. package/dist/infra/repl/commands/gen-rules-command.d.ts +0 -7
  119. package/dist/infra/rule/agent-rule-config.d.ts +0 -19
  120. package/dist/infra/usecase/generate-rules-use-case.d.ts +0 -61
  121. package/dist/infra/usecase/generate-rules-use-case.js +0 -285
  122. /package/dist/core/interfaces/{usecase/i-generate-rules-use-case.js → connectors/connector-types.js} +0 -0
  123. /package/dist/infra/{rule → connectors/shared}/constants.d.ts +0 -0
  124. /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)
@@ -46,7 +46,7 @@ brv --version
46
46
 
47
47
  ## Quick Start
48
48
 
49
- Visit [**ByteRover's Beta Docs**](https://docs.byterover.dev/beta) for more information.
49
+ Visit [**ByteRover Docs**](https://docs.byterover.dev) for more information.
50
50
 
51
51
  Get started with ByteRover CLI in three simple steps:
52
52
 
@@ -122,7 +122,7 @@ The **Context Tree** is ByteRover's structured knowledge system that helps you a
122
122
  - **Organized Knowledge**: Structure your project knowledge by domain and topic
123
123
  - **Easy Retrieval**: Find relevant context quickly when you need it
124
124
  - **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
125
+ - **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
126
  - **Cloud Sync**: Push and sync your context tree to ByteRover's cloud storage for backup and team collaboration
127
127
  - **Dynamic Domains**: Automatically creates new domains as your knowledge grows
128
128
 
@@ -135,13 +135,15 @@ The context tree organizes knowledge into:
135
135
 
136
136
  ### Integrating with Coding Agents
137
137
 
138
- Use `/gen-rules` to generate rule instruction files that help your AI coding agents understand and work with ByteRover:
138
+ Use `/connectors` to manage integrations with your AI coding agents:
139
139
 
140
140
  ```
141
- /gen-rules
141
+ /connectors
142
142
  ```
143
143
 
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.
144
+ ByteRover supports two connector types:
145
+ - **Hook integration** (Claude Code): Direct injection via IDE settings for seamless integration
146
+ - **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
145
147
 
146
148
  ## Slash Commands Reference
147
149
 
@@ -198,12 +200,12 @@ This creates agent-specific rule files (e.g., `CLAUDE.md`, `.cursorrules`) that
198
200
  - `-l, --limit <n>`: Maximum spaces to fetch (default: 50)
199
201
  - `-o, --offset <n>`: Number of spaces to skip
200
202
 
201
- ### Context Tree Management
203
+ ### Connectors & Context Tree Management
202
204
 
203
205
  | Command | Description |
204
206
  |---------|-------------|
205
- | `/gen-rules` | Generate rule files for AI coding agents (Claude Code, Cursor, etc.) |
206
- | `/reset [-y] [directory]` | Reset context tree to default domains |
207
+ | `/connectors` | Manage agent connectors (rules-based or hook integration) |
208
+ | `/reset [-y] [directory]` | Reset context tree to empty state |
207
209
 
208
210
  **Reset options:**
209
211
  - `-y, --yes`: Skip confirmation prompt
@@ -339,7 +341,7 @@ If you encounter issues or have questions:
339
341
 
340
342
  1. Check the command help in the REPL
341
343
  2. Run `/status` to review your project state
342
- 3. Visit [ByteRover Docs](https://docs.byterover.dev)
344
+ 3. Visit the [ByteRover Docs](https://docs.byterover.dev)
343
345
  4. Contact ByteRover support
344
346
 
345
347
  ---
@@ -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
+ }
@@ -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
@@ -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 {};
@@ -21,3 +21,27 @@ export const AGENT_VALUES = [
21
21
  'Windsurf',
22
22
  'Zed',
23
23
  ];
24
+ /**
25
+ * Single source of truth for agent connector configuration.
26
+ * Defines which connectors each agent supports and which is the default.
27
+ */
28
+ export const AGENT_CONNECTOR_CONFIG = {
29
+ Amp: { default: 'rules', supported: ['rules'] },
30
+ 'Augment Code': { default: 'rules', supported: ['rules'] },
31
+ 'Claude Code': { default: 'hook', supported: ['rules', 'hook'] },
32
+ Cline: { default: 'rules', supported: ['rules'] },
33
+ Codex: { default: 'rules', supported: ['rules'] },
34
+ Cursor: { default: 'rules', supported: ['rules'] },
35
+ 'Gemini CLI': { default: 'rules', supported: ['rules'] },
36
+ 'Github Copilot': { default: 'rules', supported: ['rules'] },
37
+ Junie: { default: 'rules', supported: ['rules'] },
38
+ 'Kilo Code': { default: 'rules', supported: ['rules'] },
39
+ Kiro: { default: 'rules', supported: ['rules'] },
40
+ Qoder: { default: 'rules', supported: ['rules'] },
41
+ 'Qwen Code': { default: 'rules', supported: ['rules'] },
42
+ 'Roo Code': { default: 'rules', supported: ['rules'] },
43
+ 'Trae.ai': { default: 'rules', supported: ['rules'] },
44
+ Warp: { default: 'rules', supported: ['rules'] },
45
+ Windsurf: { default: 'rules', supported: ['rules'] },
46
+ Zed: { default: 'rules', supported: ['rules'] },
47
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Array of all supported connector types.
3
+ * Each connector type represents a different method for integrating BRV with coding agents.
4
+ *
5
+ * - 'rules': Agent reads instructions from a rule file (e.g., CLAUDE.md)
6
+ * - 'hook': Instructions are injected on each prompt via agent hooks
7
+ */
8
+ export declare const CONNECTOR_TYPES: readonly ["rules", "hook"];
9
+ export type ConnectorType = (typeof CONNECTOR_TYPES)[number];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Array of all supported connector types.
3
+ * Each connector type represents a different method for integrating BRV with coding agents.
4
+ *
5
+ * - 'rules': Agent reads instructions from a rule file (e.g., CLAUDE.md)
6
+ * - 'hook': Instructions are injected on each prompt via agent hooks
7
+ */
8
+ export const CONNECTOR_TYPES = ['rules', 'hook'];
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Array of all supported Events.
3
3
  */
4
- export declare const EVENT_VALUES: readonly ["repl", "auth:sign_in", "auth:signed_out", "auth:token_invalid", "space:init", "space:changed", "rule:generate", "mem:status", "mem:curate", "mem:pull", "mem:push", "mem:query", "onboarding:init_completed", "onboarding:curate_completed", "onboarding:query_completed", "onboarding:skipped", "onboarding:completed", "init"];
4
+ export declare const EVENT_VALUES: readonly ["repl", "auth:sign_in", "auth:signed_out", "auth:token_invalid", "space:init", "space:changed", "rule:generate", "connectors:configure", "connector:install", "mem:status", "mem:curate", "mem:pull", "mem:push", "mem:query", "onboarding:init_completed", "onboarding:curate_completed", "onboarding:query_completed", "onboarding:skipped", "onboarding:completed", "init"];
5
5
  export type EventName = (typeof EVENT_VALUES)[number];
6
6
  export interface PropertyDict {
7
7
  [key: string]: any;
@@ -9,6 +9,8 @@ export const EVENT_VALUES = [
9
9
  'space:init',
10
10
  'space:changed',
11
11
  'rule:generate',
12
+ 'connectors:configure',
13
+ 'connector:install',
12
14
  'mem:status',
13
15
  'mem:curate',
14
16
  'mem:pull',
@@ -5,6 +5,7 @@
5
5
  export declare const TaskErrorCode: {
6
6
  readonly AGENT_DISCONNECTED: "ERR_AGENT_DISCONNECTED";
7
7
  readonly AGENT_NOT_AVAILABLE: "ERR_AGENT_NOT_AVAILABLE";
8
+ readonly AGENT_NOT_INITIALIZED: "ERR_AGENT_NOT_INITIALIZED";
8
9
  readonly LLM_ERROR: "ERR_LLM_ERROR";
9
10
  readonly LLM_RATE_LIMIT: "ERR_LLM_RATE_LIMIT";
10
11
  readonly NOT_AUTHENTICATED: "ERR_NOT_AUTHENTICATED";
@@ -50,6 +51,9 @@ export declare class AgentNotAvailableError extends TaskError {
50
51
  export declare class AgentDisconnectedError extends TaskError {
51
52
  constructor();
52
53
  }
54
+ export declare class AgentNotInitializedError extends TaskError {
55
+ constructor(reason?: string);
56
+ }
53
57
  export declare class ProcessorNotInitError extends TaskError {
54
58
  constructor();
55
59
  }
@@ -6,6 +6,7 @@ export const TaskErrorCode = {
6
6
  // Agent errors
7
7
  AGENT_DISCONNECTED: 'ERR_AGENT_DISCONNECTED',
8
8
  AGENT_NOT_AVAILABLE: 'ERR_AGENT_NOT_AVAILABLE',
9
+ AGENT_NOT_INITIALIZED: 'ERR_AGENT_NOT_INITIALIZED',
9
10
  // LLM errors
10
11
  LLM_ERROR: 'ERR_LLM_ERROR',
11
12
  LLM_RATE_LIMIT: 'ERR_LLM_RATE_LIMIT',
@@ -90,6 +91,12 @@ export class AgentDisconnectedError extends TaskError {
90
91
  this.name = 'AgentDisconnectedError';
91
92
  }
92
93
  }
94
+ export class AgentNotInitializedError extends TaskError {
95
+ constructor(reason) {
96
+ super(reason ? `Agent not initialized: ${reason}` : 'Agent not initialized. Please complete login and setup first.', TaskErrorCode.AGENT_NOT_INITIALIZED);
97
+ this.name = 'AgentNotInitializedError';
98
+ }
99
+ }
93
100
  export class ProcessorNotInitError extends TaskError {
94
101
  constructor() {
95
102
  super('TaskProcessor not initialized', TaskErrorCode.PROCESSOR_NOT_INIT);
@@ -1170,6 +1170,46 @@ export declare const AgentNewSessionResponseSchema: z.ZodObject<{
1170
1170
  error?: string | undefined;
1171
1171
  sessionId?: string | undefined;
1172
1172
  }>;
1173
+ /**
1174
+ * Agent status event names.
1175
+ */
1176
+ export declare const AgentStatusEventNames: {
1177
+ /** Status changed broadcast */
1178
+ readonly STATUS_CHANGED: "agent:status:changed";
1179
+ };
1180
+ /**
1181
+ * Agent health status for monitoring.
1182
+ * Used by Transport to check if CipherAgent is ready before forwarding tasks.
1183
+ */
1184
+ export declare const AgentStatusSchema: z.ZodObject<{
1185
+ /** Number of tasks currently processing */
1186
+ activeTasks: z.ZodNumber;
1187
+ /** Whether auth token is loaded and valid */
1188
+ hasAuth: z.ZodBoolean;
1189
+ /** Whether BrvConfig is loaded */
1190
+ hasConfig: z.ZodBoolean;
1191
+ /** Whether CipherAgent is initialized and ready */
1192
+ isInitialized: z.ZodBoolean;
1193
+ /** Last initialization error message */
1194
+ lastError: z.ZodOptional<z.ZodString>;
1195
+ /** Number of tasks waiting in queue */
1196
+ queuedTasks: z.ZodNumber;
1197
+ }, "strip", z.ZodTypeAny, {
1198
+ activeTasks: number;
1199
+ hasAuth: boolean;
1200
+ hasConfig: boolean;
1201
+ isInitialized: boolean;
1202
+ queuedTasks: number;
1203
+ lastError?: string | undefined;
1204
+ }, {
1205
+ activeTasks: number;
1206
+ hasAuth: boolean;
1207
+ hasConfig: boolean;
1208
+ isInitialized: boolean;
1209
+ queuedTasks: number;
1210
+ lastError?: string | undefined;
1211
+ }>;
1212
+ export type AgentStatus = z.infer<typeof AgentStatusSchema>;
1173
1213
  export type TodoItem = z.infer<typeof TodoItemSchema>;
1174
1214
  export type ChunkPayload = z.infer<typeof ChunkPayloadSchema>;
1175
1215
  export type ResponsePayload = z.infer<typeof ResponsePayloadSchema>;
@@ -581,3 +581,31 @@ export const AgentNewSessionResponseSchema = z.object({
581
581
  /** Whether the new session was created successfully */
582
582
  success: z.boolean(),
583
583
  });
584
+ // ============================================================================
585
+ // Agent Status (health check)
586
+ // ============================================================================
587
+ /**
588
+ * Agent status event names.
589
+ */
590
+ export const AgentStatusEventNames = {
591
+ /** Status changed broadcast */
592
+ STATUS_CHANGED: 'agent:status:changed',
593
+ };
594
+ /**
595
+ * Agent health status for monitoring.
596
+ * Used by Transport to check if CipherAgent is ready before forwarding tasks.
597
+ */
598
+ export const AgentStatusSchema = z.object({
599
+ /** Number of tasks currently processing */
600
+ activeTasks: z.number().int().nonnegative(),
601
+ /** Whether auth token is loaded and valid */
602
+ hasAuth: z.boolean(),
603
+ /** Whether BrvConfig is loaded */
604
+ hasConfig: z.boolean(),
605
+ /** Whether CipherAgent is initialized and ready */
606
+ isInitialized: z.boolean(),
607
+ /** Last initialization error message */
608
+ lastError: z.string().optional(),
609
+ /** Number of tasks waiting in queue */
610
+ queuedTasks: z.number().int().nonnegative(),
611
+ });
@@ -0,0 +1,57 @@
1
+ import type { ConnectorType } from '../../domain/entities/connector-type.js';
2
+ /**
3
+ * Result of a connector installation operation.
4
+ */
5
+ export type ConnectorInstallResult = {
6
+ /** Whether the connector was already installed (no action taken) */
7
+ alreadyInstalled: boolean;
8
+ /** Path to the configuration/rule file */
9
+ configPath: string;
10
+ /** Human-readable message describing the result */
11
+ message: string;
12
+ /** Whether the installation was successful */
13
+ success: boolean;
14
+ };
15
+ /**
16
+ * Result of a connector uninstallation operation.
17
+ */
18
+ export type ConnectorUninstallResult = {
19
+ /** Path to the configuration/rule file */
20
+ configPath: string;
21
+ /** Human-readable message describing the result */
22
+ message: string;
23
+ /** Whether the uninstallation was successful */
24
+ success: boolean;
25
+ /** Whether the connector was installed before uninstall */
26
+ wasInstalled: boolean;
27
+ };
28
+ /**
29
+ * Status of a connector installation.
30
+ */
31
+ export type ConnectorStatus = {
32
+ /** Whether the configuration/rule file exists */
33
+ configExists: boolean;
34
+ /** Path to the configuration/rule file */
35
+ configPath: string;
36
+ /** Error message if status check failed */
37
+ error?: string;
38
+ /** Whether the connector is currently installed */
39
+ installed: boolean;
40
+ };
41
+ /**
42
+ * Result of switching from one connector type to another.
43
+ */
44
+ export type ConnectorSwitchResult = {
45
+ /** The connector type that was uninstalled (if any) */
46
+ fromType: ConnectorType | null;
47
+ /** Result of the installation operation */
48
+ installResult: ConnectorInstallResult;
49
+ /** Human-readable message describing the result */
50
+ message: string;
51
+ /** Whether the switch was successful */
52
+ success: boolean;
53
+ /** The connector type that was installed */
54
+ toType: ConnectorType;
55
+ /** Result of the uninstallation operation (if switching) */
56
+ uninstallResult?: ConnectorUninstallResult;
57
+ };
@@ -0,0 +1,72 @@
1
+ import type { Agent } from '../../domain/entities/agent.js';
2
+ import type { ConnectorType } from '../../domain/entities/connector-type.js';
3
+ import type { ConnectorInstallResult, ConnectorStatus, ConnectorSwitchResult } from './connector-types.js';
4
+ import type { IConnector } from './i-connector.js';
5
+ /**
6
+ * Interface for managing connectors.
7
+ * Acts as a factory for creating connectors and orchestrates connector operations.
8
+ */
9
+ export interface IConnectorManager {
10
+ /**
11
+ * Get all installed connectors across all agents.
12
+ * Iterates over all agents and checks which have connectors installed.
13
+ *
14
+ * @returns Map of agent to installed connector type (only includes agents with connectors)
15
+ */
16
+ getAllInstalledConnectors(): Promise<Map<Agent, ConnectorType>>;
17
+ /**
18
+ * Get a connector instance for the specified type.
19
+ *
20
+ * @param type - The connector type
21
+ * @returns The connector instance
22
+ * @throws Error if the connector type is not supported
23
+ */
24
+ getConnector(type: ConnectorType): IConnector;
25
+ /**
26
+ * Get the default connector type for the specified agent.
27
+ *
28
+ * @param agent - The agent to get the default connector for
29
+ * @returns The default connector type
30
+ */
31
+ getDefaultConnectorType(agent: Agent): ConnectorType;
32
+ /**
33
+ * Get the currently installed connector type for the specified agent.
34
+ * Checks all connector types and returns the first one that is installed.
35
+ *
36
+ * @param agent - The agent to check
37
+ * @returns The installed connector type, or null if none installed
38
+ */
39
+ getInstalledConnectorType(agent: Agent): Promise<ConnectorType | null>;
40
+ /**
41
+ * Get list of connector types that support the specified agent.
42
+ *
43
+ * @param agent - The agent to check
44
+ * @returns Array of supported connector types
45
+ */
46
+ getSupportedConnectorTypes(agent: Agent): ConnectorType[];
47
+ /**
48
+ * Install the default connector for the specified agent.
49
+ *
50
+ * @param agent - The agent to install for
51
+ * @returns Installation result
52
+ */
53
+ installDefault(agent: Agent): Promise<ConnectorInstallResult>;
54
+ /**
55
+ * Get the status of a specific connector type for an agent.
56
+ *
57
+ * @param type - The connector type
58
+ * @param agent - The agent to check
59
+ * @returns Connector status
60
+ */
61
+ status(type: ConnectorType, agent: Agent): Promise<ConnectorStatus>;
62
+ /**
63
+ * Switch from one connector type to another for the specified agent.
64
+ * Uninstalls the current connector (if any) and installs the new one.
65
+ * This ensures only one connector is active per agent.
66
+ *
67
+ * @param agent - The agent to switch connectors for
68
+ * @param toType - The connector type to switch to
69
+ * @returns Switch result with details of uninstall and install operations
70
+ */
71
+ switchConnector(agent: Agent, toType: ConnectorType): Promise<ConnectorSwitchResult>;
72
+ }
@@ -0,0 +1,54 @@
1
+ import type { Agent } from '../../domain/entities/agent.js';
2
+ import type { ConnectorType } from '../../domain/entities/connector-type.js';
3
+ import type { ConnectorInstallResult, ConnectorStatus, ConnectorUninstallResult } from './connector-types.js';
4
+ /**
5
+ * Interface for a connector that integrates BRV with a coding agent.
6
+ * Each connector type (rules, hook, mcp) has its own implementation.
7
+ */
8
+ export interface IConnector {
9
+ /**
10
+ * Get the path to the configuration/rule file for a specific agent.
11
+ *
12
+ * @param agent - The agent to get the config path for
13
+ * @returns The path relative to project root
14
+ */
15
+ getConfigPath(agent: Agent): string;
16
+ /**
17
+ * Get list of agents supported by this connector type.
18
+ *
19
+ * @returns Array of supported agent names
20
+ */
21
+ getSupportedAgents(): Agent[];
22
+ /**
23
+ * Install the connector for the specified agent.
24
+ * If already installed, returns alreadyInstalled: true.
25
+ *
26
+ * @param agent - The coding agent to install for
27
+ * @returns Installation result with success status and message
28
+ */
29
+ install(agent: Agent): Promise<ConnectorInstallResult>;
30
+ /**
31
+ * Check if this connector supports the specified agent.
32
+ *
33
+ * @param agent - The agent to check
34
+ * @returns True if the agent is supported
35
+ */
36
+ isSupported(agent: Agent): boolean;
37
+ /**
38
+ * Check the installation status for the specified agent.
39
+ *
40
+ * @param agent - The coding agent to check status for
41
+ * @returns Status including installed state and config file existence
42
+ */
43
+ status(agent: Agent): Promise<ConnectorStatus>;
44
+ /** The type of this connector */
45
+ readonly type: ConnectorType;
46
+ /**
47
+ * Uninstall the connector for the specified agent.
48
+ * Only removes BRV content, preserves user's other configurations.
49
+ *
50
+ * @param agent - The coding agent to uninstall from
51
+ * @returns Uninstallation result with success status and message
52
+ */
53
+ uninstall(agent: Agent): Promise<ConnectorUninstallResult>;
54
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -15,6 +15,13 @@ export interface IFileService {
15
15
  * @returns A promise that resolves with the path to the backup file.
16
16
  */
17
17
  createBackup: (filePath: string) => Promise<string>;
18
+ /**
19
+ * Deletes a file at the specified path.
20
+ *
21
+ * @param filePath The path to the file to delete.
22
+ * @returns A promise that resolves when the file has been deleted.
23
+ */
24
+ delete: (filePath: string) => Promise<void>;
18
25
  /**
19
26
  * Checks if a file exists at the specified path.
20
27
  *
@@ -0,0 +1,3 @@
1
+ export interface IConnectorsUseCase {
2
+ run(): Promise<void>;
3
+ }
@@ -27,6 +27,7 @@ export type UpdateNotifierDeps = {
27
27
  execSyncFn: (command: string, options: {
28
28
  stdio: 'inherit';
29
29
  }) => void;
30
+ exitFn: (code: number) => never;
30
31
  isTTY: boolean;
31
32
  log: (message: string) => void;
32
33
  notifier: NarrowedUpdateNotifier;