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.
- package/README.md +19 -13
- package/dist/commands/hook-prompt-submit.d.ts +27 -0
- package/dist/commands/hook-prompt-submit.js +39 -0
- package/dist/commands/mcp.d.ts +13 -0
- package/dist/commands/mcp.js +61 -0
- package/dist/commands/status.js +8 -3
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/core/domain/cipher/agent-events/types.d.ts +44 -1
- package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
- package/dist/core/domain/cipher/tools/constants.js +1 -0
- package/dist/core/domain/entities/agent.d.ts +16 -0
- package/dist/core/domain/entities/agent.js +78 -0
- package/dist/core/domain/entities/connector-type.d.ts +10 -0
- package/dist/core/domain/entities/connector-type.js +9 -0
- package/dist/core/domain/entities/event.d.ts +1 -1
- package/dist/core/domain/entities/event.js +2 -0
- package/dist/core/domain/errors/task-error.d.ts +4 -0
- package/dist/core/domain/errors/task-error.js +7 -0
- package/dist/core/domain/transport/schemas.d.ts +40 -0
- package/dist/core/domain/transport/schemas.js +28 -0
- package/dist/core/interfaces/connectors/connector-types.d.ts +70 -0
- package/dist/core/interfaces/connectors/i-connector-manager.d.ts +72 -0
- package/dist/core/interfaces/connectors/i-connector-manager.js +1 -0
- package/dist/core/interfaces/connectors/i-connector.d.ts +54 -0
- package/dist/core/interfaces/connectors/i-connector.js +1 -0
- package/dist/core/interfaces/i-file-service.d.ts +7 -0
- package/dist/core/interfaces/i-mcp-config-writer.d.ts +40 -0
- package/dist/core/interfaces/i-mcp-config-writer.js +1 -0
- package/dist/core/interfaces/i-rule-template-service.d.ts +4 -2
- package/dist/core/interfaces/transport/i-transport-client.d.ts +7 -0
- package/dist/core/interfaces/usecase/i-connectors-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-connectors-use-case.js +1 -0
- package/dist/hooks/init/update-notifier.d.ts +1 -0
- package/dist/hooks/init/update-notifier.js +10 -1
- package/dist/infra/cipher/agent/cipher-agent.d.ts +8 -0
- package/dist/infra/cipher/agent/cipher-agent.js +16 -0
- package/dist/infra/cipher/file-system/binary-utils.d.ts +7 -12
- package/dist/infra/cipher/file-system/binary-utils.js +46 -31
- package/dist/infra/cipher/llm/context/context-manager.d.ts +10 -2
- package/dist/infra/cipher/llm/context/context-manager.js +39 -2
- package/dist/infra/cipher/llm/formatters/gemini-formatter.js +48 -9
- package/dist/infra/cipher/llm/internal-llm-service.d.ts +4 -0
- package/dist/infra/cipher/llm/internal-llm-service.js +40 -12
- package/dist/infra/cipher/session/chat-session.d.ts +3 -0
- package/dist/infra/cipher/session/chat-session.js +7 -1
- package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.d.ts +6 -7
- package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.js +57 -18
- package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +1 -8
- package/dist/infra/cipher/tools/implementations/curate-tool.js +380 -24
- package/dist/infra/cipher/tools/implementations/read-file-tool.js +38 -17
- package/dist/infra/cipher/tools/implementations/search-knowledge-tool.d.ts +7 -0
- package/dist/infra/cipher/tools/implementations/search-knowledge-tool.js +303 -0
- package/dist/infra/cipher/tools/index.d.ts +1 -0
- package/dist/infra/cipher/tools/index.js +1 -0
- package/dist/infra/cipher/tools/tool-manager.js +1 -0
- package/dist/infra/cipher/tools/tool-registry.js +7 -0
- package/dist/infra/connectors/connector-manager.d.ts +32 -0
- package/dist/infra/connectors/connector-manager.js +158 -0
- package/dist/infra/connectors/hook/hook-connector-config.d.ts +52 -0
- package/dist/infra/connectors/hook/hook-connector-config.js +41 -0
- package/dist/infra/connectors/hook/hook-connector.d.ts +46 -0
- package/dist/infra/connectors/hook/hook-connector.js +231 -0
- package/dist/infra/connectors/mcp/index.d.ts +4 -0
- package/dist/infra/connectors/mcp/index.js +4 -0
- package/dist/infra/connectors/mcp/json-mcp-config-writer.d.ts +26 -0
- package/dist/infra/connectors/mcp/json-mcp-config-writer.js +71 -0
- package/dist/infra/connectors/mcp/mcp-connector-config.d.ts +229 -0
- package/dist/infra/connectors/mcp/mcp-connector-config.js +173 -0
- package/dist/infra/connectors/mcp/mcp-connector.d.ts +80 -0
- package/dist/infra/connectors/mcp/mcp-connector.js +324 -0
- package/dist/infra/connectors/mcp/toml-mcp-config-writer.d.ts +45 -0
- package/dist/infra/connectors/mcp/toml-mcp-config-writer.js +134 -0
- package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.d.ts +2 -2
- package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.js +1 -1
- package/dist/infra/connectors/rules/rules-connector-config.d.ts +95 -0
- package/dist/infra/{rule/agent-rule-config.js → connectors/rules/rules-connector-config.js} +10 -10
- package/dist/infra/connectors/rules/rules-connector.d.ts +34 -0
- package/dist/infra/connectors/rules/rules-connector.js +139 -0
- package/dist/infra/connectors/shared/rule-file-manager.d.ts +72 -0
- package/dist/infra/connectors/shared/rule-file-manager.js +119 -0
- package/dist/infra/connectors/shared/template-service.d.ts +27 -0
- package/dist/infra/connectors/shared/template-service.js +125 -0
- package/dist/infra/context-tree/file-context-tree-writer-service.d.ts +5 -2
- package/dist/infra/context-tree/file-context-tree-writer-service.js +20 -5
- package/dist/infra/core/executors/curate-executor.d.ts +2 -2
- package/dist/infra/core/executors/curate-executor.js +7 -7
- package/dist/infra/core/executors/query-executor.d.ts +12 -0
- package/dist/infra/core/executors/query-executor.js +62 -1
- package/dist/infra/file/fs-file-service.d.ts +7 -0
- package/dist/infra/file/fs-file-service.js +15 -1
- package/dist/infra/mcp/index.d.ts +2 -0
- package/dist/infra/mcp/index.js +2 -0
- package/dist/infra/mcp/mcp-server.d.ts +58 -0
- package/dist/infra/mcp/mcp-server.js +178 -0
- package/dist/infra/mcp/tools/brv-curate-tool.d.ts +23 -0
- package/dist/infra/mcp/tools/brv-curate-tool.js +68 -0
- package/dist/infra/mcp/tools/brv-query-tool.d.ts +17 -0
- package/dist/infra/mcp/tools/brv-query-tool.js +68 -0
- package/dist/infra/mcp/tools/index.d.ts +3 -0
- package/dist/infra/mcp/tools/index.js +3 -0
- package/dist/infra/mcp/tools/task-result-waiter.d.ts +30 -0
- package/dist/infra/mcp/tools/task-result-waiter.js +56 -0
- package/dist/infra/process/agent-worker.d.ts +2 -2
- package/dist/infra/process/agent-worker.js +663 -142
- package/dist/infra/process/constants.d.ts +1 -1
- package/dist/infra/process/constants.js +1 -1
- package/dist/infra/process/ipc-types.d.ts +17 -4
- package/dist/infra/process/ipc-types.js +3 -3
- package/dist/infra/process/parent-heartbeat.d.ts +47 -0
- package/dist/infra/process/parent-heartbeat.js +118 -0
- package/dist/infra/process/process-manager.d.ts +79 -0
- package/dist/infra/process/process-manager.js +277 -3
- package/dist/infra/process/task-queue-manager.d.ts +13 -0
- package/dist/infra/process/task-queue-manager.js +19 -0
- package/dist/infra/process/transport-handlers.d.ts +3 -0
- package/dist/infra/process/transport-handlers.js +51 -5
- package/dist/infra/process/transport-worker.js +9 -69
- package/dist/infra/repl/commands/connectors-command.d.ts +8 -0
- package/dist/infra/repl/commands/{gen-rules-command.js → connectors-command.js} +21 -10
- package/dist/infra/repl/commands/curate-command.js +2 -2
- package/dist/infra/repl/commands/index.js +3 -2
- package/dist/infra/repl/commands/init-command.js +11 -7
- package/dist/infra/repl/commands/query-command.js +22 -2
- package/dist/infra/repl/commands/reset-command.js +1 -1
- package/dist/infra/transport/socket-io-transport-client.d.ts +75 -0
- package/dist/infra/transport/socket-io-transport-client.js +308 -7
- package/dist/infra/transport/socket-io-transport-server.js +4 -0
- package/dist/infra/usecase/connectors-use-case.d.ts +63 -0
- package/dist/infra/usecase/connectors-use-case.js +222 -0
- package/dist/infra/usecase/init-use-case.d.ts +8 -43
- package/dist/infra/usecase/init-use-case.js +27 -252
- package/dist/infra/usecase/logout-use-case.js +1 -1
- package/dist/infra/usecase/pull-use-case.js +5 -5
- package/dist/infra/usecase/push-use-case.js +4 -4
- package/dist/infra/usecase/reset-use-case.js +3 -4
- package/dist/infra/usecase/space-list-use-case.js +3 -3
- package/dist/infra/usecase/space-switch-use-case.js +3 -3
- package/dist/infra/usecase/status-use-case.d.ts +10 -0
- package/dist/infra/usecase/status-use-case.js +53 -0
- package/dist/resources/prompts/curate.yml +114 -4
- package/dist/resources/prompts/explore.yml +34 -0
- package/dist/resources/prompts/query-orchestrator.yml +112 -0
- package/dist/resources/prompts/system-prompt.yml +12 -2
- package/dist/resources/tools/search_knowledge.txt +32 -0
- package/dist/templates/mcp-base.md +1 -0
- package/dist/templates/sections/brv-instructions.md +98 -0
- package/dist/templates/sections/mcp-workflow.md +13 -0
- package/dist/tui/app.js +4 -1
- package/dist/tui/components/command-details.js +1 -1
- package/dist/tui/components/execution/execution-changes.d.ts +2 -0
- package/dist/tui/components/execution/execution-changes.js +5 -1
- package/dist/tui/components/execution/execution-content.d.ts +2 -0
- package/dist/tui/components/execution/execution-content.js +8 -18
- package/dist/tui/components/execution/execution-input.d.ts +2 -0
- package/dist/tui/components/execution/execution-input.js +6 -4
- package/dist/tui/components/execution/execution-progress.d.ts +2 -0
- package/dist/tui/components/execution/execution-progress.js +6 -2
- package/dist/tui/components/execution/expanded-log-view.d.ts +20 -0
- package/dist/tui/components/execution/expanded-log-view.js +75 -0
- package/dist/tui/components/execution/expanded-message-view.d.ts +24 -0
- package/dist/tui/components/execution/expanded-message-view.js +68 -0
- package/dist/tui/components/execution/index.d.ts +2 -0
- package/dist/tui/components/execution/index.js +2 -0
- package/dist/tui/components/execution/log-item.d.ts +4 -0
- package/dist/tui/components/execution/log-item.js +2 -2
- package/dist/tui/components/footer.js +1 -1
- package/dist/tui/components/index.d.ts +2 -1
- package/dist/tui/components/index.js +2 -1
- package/dist/tui/components/init.js +2 -9
- package/dist/tui/components/logo.js +4 -3
- package/dist/tui/components/markdown.d.ts +13 -0
- package/dist/tui/components/markdown.js +88 -0
- package/dist/tui/components/message-item.js +1 -1
- package/dist/tui/components/onboarding/onboarding-flow.js +14 -11
- package/dist/tui/components/onboarding/welcome-box.js +1 -1
- package/dist/tui/components/suggestions.js +3 -3
- package/dist/tui/contexts/mode-context.js +6 -2
- package/dist/tui/contexts/onboarding-context.d.ts +4 -0
- package/dist/tui/contexts/onboarding-context.js +14 -2
- package/dist/tui/hooks/index.d.ts +1 -0
- package/dist/tui/hooks/index.js +1 -0
- package/dist/tui/hooks/use-is-latest-version.d.ts +6 -0
- package/dist/tui/hooks/use-is-latest-version.js +22 -0
- package/dist/tui/views/command-view.d.ts +1 -1
- package/dist/tui/views/command-view.js +87 -98
- package/dist/tui/views/logs-view.d.ts +8 -0
- package/dist/tui/views/logs-view.js +55 -27
- package/dist/utils/file-validator.d.ts +1 -1
- package/dist/utils/file-validator.js +25 -28
- package/dist/utils/type-guards.d.ts +5 -0
- package/dist/utils/type-guards.js +7 -0
- package/oclif.manifest.json +55 -4
- package/package.json +12 -1
- package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +0 -3
- package/dist/infra/repl/commands/gen-rules-command.d.ts +0 -7
- package/dist/infra/rule/agent-rule-config.d.ts +0 -19
- package/dist/infra/rule/rule-template-service.d.ts +0 -18
- package/dist/infra/rule/rule-template-service.js +0 -88
- package/dist/infra/usecase/generate-rules-use-case.d.ts +0 -61
- package/dist/infra/usecase/generate-rules-use-case.js +0 -285
- /package/dist/core/interfaces/{usecase/i-generate-rules-use-case.js → connectors/connector-types.js} +0 -0
- /package/dist/infra/{rule → connectors/shared}/constants.d.ts +0 -0
- /package/dist/infra/{rule → connectors/shared}/constants.js +0 -0
|
@@ -21,3 +21,81 @@ 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: {
|
|
30
|
+
default: 'mcp',
|
|
31
|
+
supported: ['rules', 'mcp'],
|
|
32
|
+
},
|
|
33
|
+
'Augment Code': {
|
|
34
|
+
default: 'mcp',
|
|
35
|
+
supported: ['rules', 'mcp'],
|
|
36
|
+
},
|
|
37
|
+
'Claude Code': {
|
|
38
|
+
default: 'hook',
|
|
39
|
+
supported: ['rules', 'hook', 'mcp'],
|
|
40
|
+
},
|
|
41
|
+
Cline: {
|
|
42
|
+
default: 'mcp',
|
|
43
|
+
supported: ['rules', 'mcp'],
|
|
44
|
+
},
|
|
45
|
+
Codex: {
|
|
46
|
+
default: 'mcp',
|
|
47
|
+
supported: ['rules', 'mcp'],
|
|
48
|
+
},
|
|
49
|
+
Cursor: {
|
|
50
|
+
default: 'mcp',
|
|
51
|
+
supported: ['rules', 'mcp'],
|
|
52
|
+
},
|
|
53
|
+
'Gemini CLI': {
|
|
54
|
+
default: 'mcp',
|
|
55
|
+
supported: ['rules', 'mcp'],
|
|
56
|
+
},
|
|
57
|
+
'Github Copilot': {
|
|
58
|
+
default: 'mcp',
|
|
59
|
+
supported: ['rules', 'mcp'],
|
|
60
|
+
},
|
|
61
|
+
Junie: {
|
|
62
|
+
default: 'mcp',
|
|
63
|
+
supported: ['rules', 'mcp'],
|
|
64
|
+
},
|
|
65
|
+
'Kilo Code': {
|
|
66
|
+
default: 'mcp',
|
|
67
|
+
supported: ['rules', 'mcp'],
|
|
68
|
+
},
|
|
69
|
+
Kiro: {
|
|
70
|
+
default: 'mcp',
|
|
71
|
+
supported: ['rules', 'mcp'],
|
|
72
|
+
},
|
|
73
|
+
Qoder: {
|
|
74
|
+
default: 'mcp',
|
|
75
|
+
supported: ['rules', 'mcp'],
|
|
76
|
+
},
|
|
77
|
+
'Qwen Code': {
|
|
78
|
+
default: 'mcp',
|
|
79
|
+
supported: ['rules', 'mcp'],
|
|
80
|
+
},
|
|
81
|
+
'Roo Code': {
|
|
82
|
+
default: 'mcp',
|
|
83
|
+
supported: ['rules', 'mcp'],
|
|
84
|
+
},
|
|
85
|
+
'Trae.ai': {
|
|
86
|
+
default: 'mcp',
|
|
87
|
+
supported: ['rules', 'mcp'],
|
|
88
|
+
},
|
|
89
|
+
Warp: {
|
|
90
|
+
default: 'mcp',
|
|
91
|
+
supported: ['rules', 'mcp'],
|
|
92
|
+
},
|
|
93
|
+
Windsurf: {
|
|
94
|
+
default: 'mcp',
|
|
95
|
+
supported: ['rules', 'mcp'],
|
|
96
|
+
},
|
|
97
|
+
Zed: {
|
|
98
|
+
default: 'mcp',
|
|
99
|
+
supported: ['rules', 'mcp'],
|
|
100
|
+
},
|
|
101
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
* - 'mcp': Agent uses mcp tools to interact with brv
|
|
8
|
+
*/
|
|
9
|
+
export declare const CONNECTOR_TYPES: readonly ["rules", "hook", "mcp"];
|
|
10
|
+
export type ConnectorType = (typeof CONNECTOR_TYPES)[number];
|
|
@@ -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
|
+
* - 'mcp': Agent uses mcp tools to interact with brv
|
|
8
|
+
*/
|
|
9
|
+
export const CONNECTOR_TYPES = ['rules', 'hook', 'mcp'];
|
|
@@ -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;
|
|
@@ -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,70 @@
|
|
|
1
|
+
import type { ConnectorType } from '../../domain/entities/connector-type.js';
|
|
2
|
+
/**
|
|
3
|
+
* Instructions for manual MCP setup when automatic configuration is not possible.
|
|
4
|
+
*/
|
|
5
|
+
export type ManualInstallInstructions = {
|
|
6
|
+
/** The config content to copy (JSON or TOML formatted) */
|
|
7
|
+
configContent: string;
|
|
8
|
+
/** Guide URL or step-by-step instructions */
|
|
9
|
+
guide: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Result of a connector installation operation.
|
|
13
|
+
*/
|
|
14
|
+
export type ConnectorInstallResult = {
|
|
15
|
+
/** Whether the connector was already installed (no action taken) */
|
|
16
|
+
alreadyInstalled: boolean;
|
|
17
|
+
/** Path to the configuration/rule file */
|
|
18
|
+
configPath: string;
|
|
19
|
+
/** Instructions for manual setup (present when requiresManualSetup is true) */
|
|
20
|
+
manualInstructions?: ManualInstallInstructions;
|
|
21
|
+
/** Human-readable message describing the result */
|
|
22
|
+
message: string;
|
|
23
|
+
/** Whether this requires manual setup by the user */
|
|
24
|
+
requiresManualSetup?: boolean;
|
|
25
|
+
/** Whether the installation was successful */
|
|
26
|
+
success: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Result of a connector uninstallation operation.
|
|
30
|
+
*/
|
|
31
|
+
export type ConnectorUninstallResult = {
|
|
32
|
+
/** Path to the configuration/rule file */
|
|
33
|
+
configPath: string;
|
|
34
|
+
/** Human-readable message describing the result */
|
|
35
|
+
message: string;
|
|
36
|
+
/** Whether the uninstallation was successful */
|
|
37
|
+
success: boolean;
|
|
38
|
+
/** Whether the connector was installed before uninstall */
|
|
39
|
+
wasInstalled: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Status of a connector installation.
|
|
43
|
+
*/
|
|
44
|
+
export type ConnectorStatus = {
|
|
45
|
+
/** Whether the configuration/rule file exists */
|
|
46
|
+
configExists: boolean;
|
|
47
|
+
/** Path to the configuration/rule file */
|
|
48
|
+
configPath: string;
|
|
49
|
+
/** Error message if status check failed */
|
|
50
|
+
error?: string;
|
|
51
|
+
/** Whether the connector is currently installed */
|
|
52
|
+
installed: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Result of switching from one connector type to another.
|
|
56
|
+
*/
|
|
57
|
+
export type ConnectorSwitchResult = {
|
|
58
|
+
/** The connector type that was uninstalled (if any) */
|
|
59
|
+
fromType: ConnectorType | null;
|
|
60
|
+
/** Result of the installation operation */
|
|
61
|
+
installResult: ConnectorInstallResult;
|
|
62
|
+
/** Human-readable message describing the result */
|
|
63
|
+
message: string;
|
|
64
|
+
/** Whether the switch was successful */
|
|
65
|
+
success: boolean;
|
|
66
|
+
/** The connector type that was installed */
|
|
67
|
+
toType: ConnectorType;
|
|
68
|
+
/** Result of the uninstallation operation (if switching) */
|
|
69
|
+
uninstallResult?: ConnectorUninstallResult;
|
|
70
|
+
};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,40 @@
|
|
|
1
|
+
import type { McpServerConfig } from '../../infra/connectors/mcp/mcp-connector-config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Result of checking if MCP config exists.
|
|
4
|
+
*/
|
|
5
|
+
export type McpConfigExistsResult = {
|
|
6
|
+
/** Whether the config file exists */
|
|
7
|
+
fileExists: boolean;
|
|
8
|
+
/** Whether the BRV MCP server entry exists in the config */
|
|
9
|
+
serverExists: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Interface for writing MCP server configurations to agent config files.
|
|
13
|
+
* Different implementations handle different file formats (JSON, TOML, etc.).
|
|
14
|
+
*/
|
|
15
|
+
export interface IMcpConfigWriter {
|
|
16
|
+
/**
|
|
17
|
+
* Check if the config file and BRV server entry exist.
|
|
18
|
+
*
|
|
19
|
+
* @param filePath - Absolute path to the config file
|
|
20
|
+
* @returns Object indicating file and server existence
|
|
21
|
+
*/
|
|
22
|
+
exists(filePath: string): Promise<McpConfigExistsResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Remove the BRV MCP server entry from the config file.
|
|
25
|
+
* Does not delete the file, only removes the server entry.
|
|
26
|
+
*
|
|
27
|
+
* @param filePath - Absolute path to the config file
|
|
28
|
+
* @returns True if the server was removed, false if it didn't exist
|
|
29
|
+
*/
|
|
30
|
+
remove(filePath: string): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Write the MCP server configuration to the config file.
|
|
33
|
+
* Creates the file if it doesn't exist.
|
|
34
|
+
* Preserves existing configuration.
|
|
35
|
+
*
|
|
36
|
+
* @param filePath - Absolute path to the config file
|
|
37
|
+
* @param serverConfig - The MCP server configuration to write
|
|
38
|
+
*/
|
|
39
|
+
write(filePath: string, serverConfig: McpServerConfig): Promise<void>;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Agent } from '../domain/entities/agent.js';
|
|
2
|
+
import { ConnectorType } from '../domain/entities/connector-type.js';
|
|
2
3
|
/**
|
|
3
4
|
* Interface for rule template service operations.
|
|
4
5
|
*/
|
|
5
6
|
export interface IRuleTemplateService {
|
|
6
7
|
/**
|
|
7
|
-
* Generates rule content based on the provided agent.
|
|
8
|
+
* Generates rule content based on the provided agent and connector type.
|
|
8
9
|
*
|
|
9
10
|
* @param agent The agent for which to generate the rule content.
|
|
11
|
+
* @param type The connector type (rules or mcp). Defaults to 'rules'.
|
|
10
12
|
* @returns Promise resolving to the generated rule content.
|
|
11
13
|
*/
|
|
12
|
-
generateRuleContent: (agent: Agent) => Promise<string>;
|
|
14
|
+
generateRuleContent: (agent: Agent, type: ConnectorType) => Promise<string>;
|
|
13
15
|
}
|
|
@@ -54,6 +54,13 @@ export interface ITransportClient {
|
|
|
54
54
|
* Returns the current connection state.
|
|
55
55
|
*/
|
|
56
56
|
getState: () => ConnectionState;
|
|
57
|
+
/**
|
|
58
|
+
* Checks if the socket is actually connected and responsive.
|
|
59
|
+
* Verifies bidirectional communication by sending a ping and waiting for response.
|
|
60
|
+
* @param timeoutMs - Timeout in milliseconds (default: 2000)
|
|
61
|
+
* @returns true if socket is connected and responsive, false otherwise
|
|
62
|
+
*/
|
|
63
|
+
isConnected: (timeoutMs?: number) => Promise<boolean>;
|
|
57
64
|
/**
|
|
58
65
|
* Joins a room for targeted broadcasts.
|
|
59
66
|
* @param room - The room identifier to join
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,11 +9,15 @@ export const UPDATE_CHECK_INTERVAL_MS = 1000 * 60 * 60 * 24;
|
|
|
9
9
|
* Core update notification logic, extracted for testability
|
|
10
10
|
*/
|
|
11
11
|
export async function handleUpdateNotification(deps) {
|
|
12
|
-
const { confirmPrompt, execSyncFn, isTTY, log, notifier } = deps;
|
|
12
|
+
const { confirmPrompt, execSyncFn, exitFn, isTTY, log, notifier } = deps;
|
|
13
13
|
if (!notifier.update || !isTTY) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
const { current, latest } = notifier.update;
|
|
17
|
+
// Skip if already on latest version (handles stale cache after update)
|
|
18
|
+
if (current === latest) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
17
21
|
const shouldUpdate = await confirmPrompt({
|
|
18
22
|
default: true,
|
|
19
23
|
message: `Update available: ${current} → ${latest}. Would you like to update now?`,
|
|
@@ -22,7 +26,11 @@ export async function handleUpdateNotification(deps) {
|
|
|
22
26
|
log('Updating byterover-cli...');
|
|
23
27
|
try {
|
|
24
28
|
execSyncFn('npm update -g byterover-cli', { stdio: 'inherit' });
|
|
29
|
+
log('');
|
|
25
30
|
log(`✓ Successfully updated to ${latest}`);
|
|
31
|
+
log('');
|
|
32
|
+
log(`The update will take effect on next launch. Run 'brv' when ready.`);
|
|
33
|
+
exitFn(0);
|
|
26
34
|
}
|
|
27
35
|
catch {
|
|
28
36
|
log('⚠️ Automatic update failed. Please run manually: npm update -g byterover-cli');
|
|
@@ -35,6 +43,7 @@ const hook = async function () {
|
|
|
35
43
|
await handleUpdateNotification({
|
|
36
44
|
confirmPrompt: confirm,
|
|
37
45
|
execSyncFn: execSync,
|
|
46
|
+
exitFn: process.exit,
|
|
38
47
|
isTTY: process.stdout.isTTY ?? false,
|
|
39
48
|
log: this.log.bind(this),
|
|
40
49
|
notifier,
|
|
@@ -158,6 +158,14 @@ export declare class CipherAgent extends BaseAgent implements ICipherAgent {
|
|
|
158
158
|
* @returns AsyncIterator that yields StreamingEvent objects
|
|
159
159
|
*/
|
|
160
160
|
stream(input: string, options?: StreamOptions): Promise<AsyncIterableIterator<StreamingEvent>>;
|
|
161
|
+
/**
|
|
162
|
+
* Switch the default session to a different session ID.
|
|
163
|
+
* The session must already exist (created via createSession).
|
|
164
|
+
*
|
|
165
|
+
* @param sessionId - The session ID to switch to
|
|
166
|
+
* @throws Error if session does not exist
|
|
167
|
+
*/
|
|
168
|
+
switchDefaultSession(sessionId: string): void;
|
|
161
169
|
private getHistoryStorageInternal;
|
|
162
170
|
private getSessionIdInternal;
|
|
163
171
|
private getSessionManagerInternal;
|
|
@@ -520,6 +520,22 @@ export class CipherAgent extends BaseAgent {
|
|
|
520
520
|
};
|
|
521
521
|
return iterator;
|
|
522
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* Switch the default session to a different session ID.
|
|
525
|
+
* The session must already exist (created via createSession).
|
|
526
|
+
*
|
|
527
|
+
* @param sessionId - The session ID to switch to
|
|
528
|
+
* @throws Error if session does not exist
|
|
529
|
+
*/
|
|
530
|
+
switchDefaultSession(sessionId) {
|
|
531
|
+
this.ensureStarted();
|
|
532
|
+
// Verify the session exists
|
|
533
|
+
const session = this.getSessionManagerInternal().getSession(sessionId);
|
|
534
|
+
if (!session) {
|
|
535
|
+
throw new Error(`Session ${sessionId} does not exist. Create it first with createSession().`);
|
|
536
|
+
}
|
|
537
|
+
this._sessionId = sessionId;
|
|
538
|
+
}
|
|
523
539
|
// === Private Helpers (alphabetical order) ===
|
|
524
540
|
getHistoryStorageInternal() {
|
|
525
541
|
const storage = this.services?.historyStorage;
|