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
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { AGENT_VALUES } from '../../core/domain/entities/agent.js';
|
|
2
|
+
/** Sentinel value for "Connect a new agent" option */
|
|
3
|
+
const CONNECT_NEW_AGENT = '__connect_new__';
|
|
4
|
+
/**
|
|
5
|
+
* Array of all agents with name and value properties.
|
|
6
|
+
* Useful for UI components like select dropdowns.
|
|
7
|
+
*/
|
|
8
|
+
const AGENTS = AGENT_VALUES.map((agent) => ({
|
|
9
|
+
name: agent,
|
|
10
|
+
value: agent,
|
|
11
|
+
}));
|
|
12
|
+
/**
|
|
13
|
+
* Use case for managing connectors.
|
|
14
|
+
* Shows list of connected agents and allows managing or adding new connections.
|
|
15
|
+
*/
|
|
16
|
+
export class ConnectorsUseCase {
|
|
17
|
+
connectorManager;
|
|
18
|
+
terminal;
|
|
19
|
+
trackingService;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.connectorManager = options.connectorManager;
|
|
22
|
+
this.terminal = options.terminal;
|
|
23
|
+
this.trackingService = options.trackingService;
|
|
24
|
+
}
|
|
25
|
+
async run() {
|
|
26
|
+
await this.trackingService.track('connectors:configure');
|
|
27
|
+
// Step 1: Get all installed connectors
|
|
28
|
+
const installedConnectors = await this.connectorManager.getAllInstalledConnectors();
|
|
29
|
+
// Step 2: Show list or prompt for new agent
|
|
30
|
+
const selectedAgent = installedConnectors.size === 0
|
|
31
|
+
? await this.handleNoConnectorsInstalled()
|
|
32
|
+
: await this.handleExistingConnectors(installedConnectors);
|
|
33
|
+
// Step 3: Get current status and supported types for selected agent
|
|
34
|
+
const currentType = await this.connectorManager.getInstalledConnectorType(selectedAgent);
|
|
35
|
+
const supportedTypes = this.connectorManager.getSupportedConnectorTypes(selectedAgent);
|
|
36
|
+
// Step 4: Select connector type
|
|
37
|
+
const selectedType = await this.promptForConnectorType(selectedAgent, supportedTypes, currentType);
|
|
38
|
+
// Step 5: Handle switching with confirmation if needed
|
|
39
|
+
if (currentType && currentType !== selectedType) {
|
|
40
|
+
const shouldSwitch = await this.promptForSwitchConfirmation(selectedAgent, currentType, selectedType);
|
|
41
|
+
if (!shouldSwitch) {
|
|
42
|
+
this.terminal.log(`Kept ${selectedAgent} connected via ${currentType}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Step 6: Install the selected connector
|
|
47
|
+
await this.installConnector(selectedAgent, selectedType);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Display manual setup instructions for MCP configuration.
|
|
51
|
+
*/
|
|
52
|
+
displayManualInstructions(agent, instructions) {
|
|
53
|
+
this.terminal.log(`\nManual setup required for ${agent}`);
|
|
54
|
+
this.terminal.log('');
|
|
55
|
+
this.terminal.log('Add this configuration to your MCP settings:');
|
|
56
|
+
this.terminal.log('');
|
|
57
|
+
this.terminal.log(instructions.configContent);
|
|
58
|
+
this.terminal.log('');
|
|
59
|
+
if (instructions.guide) {
|
|
60
|
+
this.terminal.log(`\nFor detailed instructions, see: ${instructions.guide}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets a description for a connector type.
|
|
65
|
+
*/
|
|
66
|
+
getConnectorDescription(type, configPath) {
|
|
67
|
+
switch (type) {
|
|
68
|
+
case 'hook': {
|
|
69
|
+
return `Instructions injected on each prompt (${configPath})`;
|
|
70
|
+
}
|
|
71
|
+
case 'mcp': {
|
|
72
|
+
return `Agent connects via MCP protocol ${configPath ? `(${configPath})` : ''}`;
|
|
73
|
+
}
|
|
74
|
+
case 'rules': {
|
|
75
|
+
return `Agent reads instructions from rule file (${configPath})`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Gets a human-readable label for a connector type.
|
|
81
|
+
*/
|
|
82
|
+
getConnectorLabel(type) {
|
|
83
|
+
switch (type) {
|
|
84
|
+
case 'hook': {
|
|
85
|
+
return 'Hook';
|
|
86
|
+
}
|
|
87
|
+
case 'mcp': {
|
|
88
|
+
return 'MCP';
|
|
89
|
+
}
|
|
90
|
+
case 'rules': {
|
|
91
|
+
return 'Rules';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Handles the case when connectors are already installed.
|
|
97
|
+
*/
|
|
98
|
+
async handleExistingConnectors(installedConnectors) {
|
|
99
|
+
const selection = await this.promptForAgentToManage(installedConnectors);
|
|
100
|
+
if (selection === CONNECT_NEW_AGENT) {
|
|
101
|
+
return this.promptForNewAgentSelection(installedConnectors);
|
|
102
|
+
}
|
|
103
|
+
return selection;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Handles the case when no connectors are installed.
|
|
107
|
+
*/
|
|
108
|
+
async handleNoConnectorsInstalled() {
|
|
109
|
+
this.terminal.log('No agents connected yet.\n');
|
|
110
|
+
return this.promptForNewAgentSelection();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Installs the selected connector and displays result.
|
|
114
|
+
*/
|
|
115
|
+
async installConnector(agent, connectorType) {
|
|
116
|
+
const result = await this.connectorManager.switchConnector(agent, connectorType);
|
|
117
|
+
if (result.success) {
|
|
118
|
+
// Handle manual setup instructions
|
|
119
|
+
if (result.installResult.requiresManualSetup && result.installResult.manualInstructions) {
|
|
120
|
+
this.displayManualInstructions(agent, result.installResult.manualInstructions);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (result.fromType && result.fromType !== result.toType) {
|
|
124
|
+
this.terminal.log(`${agent} switched from ${this.getConnectorLabel(result.fromType)} to ${this.getConnectorLabel(result.toType)}`);
|
|
125
|
+
if (result.uninstallResult?.wasInstalled) {
|
|
126
|
+
this.terminal.log(` Uninstalled: ${result.uninstallResult.configPath}`);
|
|
127
|
+
}
|
|
128
|
+
this.terminal.log(` Installed: ${result.installResult.configPath}`);
|
|
129
|
+
}
|
|
130
|
+
else if (result.installResult.alreadyInstalled) {
|
|
131
|
+
this.terminal.log(`${agent} is already connected via ${result.toType}`);
|
|
132
|
+
this.terminal.log(` Config: ${result.installResult.configPath}`);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.terminal.log(`${agent} connected via ${result.toType}`);
|
|
136
|
+
this.terminal.log(` Installed: ${result.installResult.configPath}`);
|
|
137
|
+
}
|
|
138
|
+
// Show restart message for hook connector
|
|
139
|
+
if ((result.toType === 'hook' || result.toType === 'mcp') && !result.installResult.alreadyInstalled) {
|
|
140
|
+
this.terminal.warn(`\nPlease restart ${agent} to apply the new ${result.toType}.`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
this.terminal.error(`Failed to configure ${agent}: ${result.message}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Prompts user to select from connected agents or add new.
|
|
149
|
+
*/
|
|
150
|
+
async promptForAgentToManage(installedConnectors) {
|
|
151
|
+
const choices = [];
|
|
152
|
+
// Add installed agents as choices
|
|
153
|
+
for (const [agent, connectorType] of installedConnectors) {
|
|
154
|
+
const connector = this.connectorManager.getConnector(connectorType);
|
|
155
|
+
const configPath = connector.getConfigPath(agent);
|
|
156
|
+
choices.push({
|
|
157
|
+
description: configPath,
|
|
158
|
+
name: `${agent} (${this.getConnectorLabel(connectorType)})`,
|
|
159
|
+
value: agent,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
// Add separator and "Connect new" option
|
|
163
|
+
choices.push({
|
|
164
|
+
name: '+ Connect a new agent',
|
|
165
|
+
value: CONNECT_NEW_AGENT,
|
|
166
|
+
});
|
|
167
|
+
return this.terminal.select({
|
|
168
|
+
choices,
|
|
169
|
+
message: 'Manage agent connectors:',
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Prompts the user to select a connector type.
|
|
174
|
+
*/
|
|
175
|
+
async promptForConnectorType(agent, supportedTypes, currentType) {
|
|
176
|
+
const choices = supportedTypes.map((type) => {
|
|
177
|
+
const connector = this.connectorManager.getConnector(type);
|
|
178
|
+
const configPath = connector.getConfigPath(agent);
|
|
179
|
+
const isCurrent = type === currentType;
|
|
180
|
+
const label = this.getConnectorLabel(type);
|
|
181
|
+
const description = this.getConnectorDescription(type, configPath);
|
|
182
|
+
return {
|
|
183
|
+
description,
|
|
184
|
+
name: isCurrent ? `${label} (current)` : label,
|
|
185
|
+
value: type,
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
return this.terminal.select({
|
|
189
|
+
choices,
|
|
190
|
+
message: 'Select connector type:',
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Prompts user to select a new agent (excludes already connected agents).
|
|
195
|
+
*/
|
|
196
|
+
async promptForNewAgentSelection(installedConnectors) {
|
|
197
|
+
const connectedAgents = installedConnectors ? new Set(installedConnectors.keys()) : new Set();
|
|
198
|
+
// Filter out already connected agents
|
|
199
|
+
const availableAgents = AGENTS.filter((agent) => !connectedAgents.has(agent.value));
|
|
200
|
+
return this.terminal.search({
|
|
201
|
+
message: 'Which agent are you using (type to search):',
|
|
202
|
+
source(input) {
|
|
203
|
+
if (!input)
|
|
204
|
+
return availableAgents;
|
|
205
|
+
return availableAgents.filter((agent) => agent.name.toLowerCase().includes(input.toLowerCase()) ||
|
|
206
|
+
agent.value.toLowerCase().includes(input.toLowerCase()));
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Prompts the user to confirm switching connectors.
|
|
212
|
+
*/
|
|
213
|
+
async promptForSwitchConfirmation(agent, fromType, toType) {
|
|
214
|
+
const fromConnector = this.connectorManager.getConnector(fromType);
|
|
215
|
+
const fromPath = fromConnector.getConfigPath(agent);
|
|
216
|
+
this.terminal.warn(`${agent} is currently connected via ${this.getConnectorLabel(fromType)} ${fromPath ? `(${fromPath})` : ''}`);
|
|
217
|
+
return this.terminal.confirm({
|
|
218
|
+
default: true,
|
|
219
|
+
message: `Switch to ${toType}? This will uninstall the current connector.`,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { AuthToken } from '../../core/domain/entities/auth-token.js';
|
|
2
2
|
import type { Space } from '../../core/domain/entities/space.js';
|
|
3
3
|
import type { Team } from '../../core/domain/entities/team.js';
|
|
4
|
+
import type { IConnectorManager } from '../../core/interfaces/connectors/i-connector-manager.js';
|
|
4
5
|
import type { ICogitPullService } from '../../core/interfaces/i-cogit-pull-service.js';
|
|
5
6
|
import type { IContextTreeService } from '../../core/interfaces/i-context-tree-service.js';
|
|
6
7
|
import type { IContextTreeSnapshotService } from '../../core/interfaces/i-context-tree-snapshot-service.js';
|
|
7
8
|
import type { IContextTreeWriterService } from '../../core/interfaces/i-context-tree-writer-service.js';
|
|
8
9
|
import type { IFileService } from '../../core/interfaces/i-file-service.js';
|
|
9
|
-
import type { ILegacyRuleDetector } from '../../core/interfaces/i-legacy-rule-detector.js';
|
|
10
10
|
import type { IProjectConfigStore } from '../../core/interfaces/i-project-config-store.js';
|
|
11
|
-
import type { IRuleTemplateService } from '../../core/interfaces/i-rule-template-service.js';
|
|
12
11
|
import type { ISpaceService } from '../../core/interfaces/i-space-service.js';
|
|
13
12
|
import type { ITeamService } from '../../core/interfaces/i-team-service.js';
|
|
14
13
|
import type { ITerminal } from '../../core/interfaces/i-terminal.js';
|
|
@@ -17,7 +16,6 @@ import type { ITrackingService } from '../../core/interfaces/i-tracking-service.
|
|
|
17
16
|
import type { IInitUseCase } from '../../core/interfaces/usecase/i-init-use-case.js';
|
|
18
17
|
import { type Agent } from '../../core/domain/entities/agent.js';
|
|
19
18
|
import { BrvConfig } from '../../core/domain/entities/brv-config.js';
|
|
20
|
-
type CleanupStrategy = 'automatic' | 'manual';
|
|
21
19
|
/**
|
|
22
20
|
* Represents a legacy config that exists but has version issues.
|
|
23
21
|
* Used to display config info during re-initialization prompt.
|
|
@@ -33,30 +31,28 @@ export type LegacyProjectConfigInfo = {
|
|
|
33
31
|
};
|
|
34
32
|
export interface InitUseCaseOptions {
|
|
35
33
|
cogitPullService: ICogitPullService;
|
|
34
|
+
connectorManager: IConnectorManager;
|
|
36
35
|
contextTreeService: IContextTreeService;
|
|
37
36
|
contextTreeSnapshotService: IContextTreeSnapshotService;
|
|
38
37
|
contextTreeWriterService: IContextTreeWriterService;
|
|
39
38
|
fileService: IFileService;
|
|
40
|
-
legacyRuleDetector: ILegacyRuleDetector;
|
|
41
39
|
projectConfigStore: IProjectConfigStore;
|
|
42
40
|
spaceService: ISpaceService;
|
|
43
41
|
teamService: ITeamService;
|
|
44
|
-
templateService: IRuleTemplateService;
|
|
45
42
|
terminal: ITerminal;
|
|
46
43
|
tokenStore: ITokenStore;
|
|
47
44
|
trackingService: ITrackingService;
|
|
48
45
|
}
|
|
49
46
|
export declare class InitUseCase implements IInitUseCase {
|
|
50
47
|
protected readonly cogitPullService: ICogitPullService;
|
|
48
|
+
protected readonly connectorManager: IConnectorManager;
|
|
51
49
|
protected readonly contextTreeService: IContextTreeService;
|
|
52
50
|
protected readonly contextTreeSnapshotService: IContextTreeSnapshotService;
|
|
53
51
|
protected readonly contextTreeWriterService: IContextTreeWriterService;
|
|
54
52
|
protected readonly fileService: IFileService;
|
|
55
|
-
protected readonly legacyRuleDetector: ILegacyRuleDetector;
|
|
56
53
|
protected readonly projectConfigStore: IProjectConfigStore;
|
|
57
54
|
protected readonly spaceService: ISpaceService;
|
|
58
55
|
protected readonly teamService: ITeamService;
|
|
59
|
-
protected readonly templateService: IRuleTemplateService;
|
|
60
56
|
protected readonly terminal: ITerminal;
|
|
61
57
|
protected readonly tokenStore: ITokenStore;
|
|
62
58
|
protected readonly trackingService: ITrackingService;
|
|
@@ -71,9 +67,13 @@ export declare class InitUseCase implements IInitUseCase {
|
|
|
71
67
|
protected ensureAuthenticated(): Promise<AuthToken | undefined>;
|
|
72
68
|
protected fetchAndSelectSpace(token: AuthToken, team: Team): Promise<Space | undefined>;
|
|
73
69
|
protected fetchAndSelectTeam(token: AuthToken): Promise<Team | undefined>;
|
|
74
|
-
protected generateRulesForAgent(selectedAgent: Agent): Promise<void>;
|
|
75
70
|
protected getExistingConfig(): Promise<BrvConfig | LegacyProjectConfigInfo | undefined>;
|
|
76
71
|
protected initializeMemoryContextDir(name: string, initFn: () => Promise<string>): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Installs the default connector for the selected agent.
|
|
74
|
+
* Uses ConnectorManager to handle the installation.
|
|
75
|
+
*/
|
|
76
|
+
protected installConnectorForAgent(selectedAgent: Agent): Promise<void>;
|
|
77
77
|
protected isLegacyProjectConfig(config: BrvConfig | LegacyProjectConfigInfo): config is LegacyProjectConfigInfo;
|
|
78
78
|
/**
|
|
79
79
|
* Checks if the given path represents a README.md placeholder file.
|
|
@@ -87,25 +87,6 @@ export declare class InitUseCase implements IInitUseCase {
|
|
|
87
87
|
* @returns The selected agent
|
|
88
88
|
*/
|
|
89
89
|
protected promptForAgentSelection(): Promise<Agent>;
|
|
90
|
-
/**
|
|
91
|
-
* Prompts the user to choose cleanup strategy for legacy rules.
|
|
92
|
-
* This method is protected to allow test overrides.
|
|
93
|
-
* @returns The chosen cleanup strategy
|
|
94
|
-
*/
|
|
95
|
-
protected promptForCleanupStrategy(): Promise<CleanupStrategy>;
|
|
96
|
-
/**
|
|
97
|
-
* Prompts the user to create a new rule file.
|
|
98
|
-
* This method is protected to allow test overrides.
|
|
99
|
-
* @param agent The agent for which the rule file doesn't exist
|
|
100
|
-
* @param filePath The path where the file would be created
|
|
101
|
-
* @returns True if the user wants to create the file, false otherwise
|
|
102
|
-
*/
|
|
103
|
-
protected promptForFileCreation(agent: Agent, filePath: string): Promise<boolean>;
|
|
104
|
-
/**
|
|
105
|
-
* Prompts the user to confirm overwriting an existing rule file.
|
|
106
|
-
* This method is protected to allow test overrides.
|
|
107
|
-
*/
|
|
108
|
-
protected promptForOverwriteConfirmation(agent: Agent): Promise<boolean>;
|
|
109
90
|
protected promptForSpaceSelection(spaces: Space[]): Promise<Space | undefined>;
|
|
110
91
|
protected promptForTeamSelection(teams: Team[]): Promise<Team | undefined>;
|
|
111
92
|
protected removeAceDirectory(baseDir?: string): Promise<void>;
|
|
@@ -119,21 +100,5 @@ export declare class InitUseCase implements IInitUseCase {
|
|
|
119
100
|
};
|
|
120
101
|
token: AuthToken;
|
|
121
102
|
}): Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* Appends ByteRover rules to a file that has no ByteRover content.
|
|
124
|
-
*/
|
|
125
|
-
private appendRulesToFile;
|
|
126
|
-
/**
|
|
127
|
-
* Creates a new rule file with ByteRover rules.
|
|
128
|
-
*/
|
|
129
|
-
private createNewRuleFile;
|
|
130
|
-
private handleLegacyRulesCleanup;
|
|
131
103
|
private logSuccess;
|
|
132
|
-
private performAutomaticCleanup;
|
|
133
|
-
private performManualCleanup;
|
|
134
|
-
/**
|
|
135
|
-
* Replaces existing ByteRover rules (with boundary markers) with new rules.
|
|
136
|
-
*/
|
|
137
|
-
private replaceExistingRules;
|
|
138
104
|
}
|
|
139
|
-
export {};
|