byterover-cli 1.0.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +19 -13
  2. package/dist/commands/hook-prompt-submit.d.ts +27 -0
  3. package/dist/commands/hook-prompt-submit.js +39 -0
  4. package/dist/commands/mcp.d.ts +13 -0
  5. package/dist/commands/mcp.js +61 -0
  6. package/dist/commands/status.js +8 -3
  7. package/dist/constants.d.ts +1 -1
  8. package/dist/constants.js +1 -1
  9. package/dist/core/domain/cipher/agent-events/types.d.ts +44 -1
  10. package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
  11. package/dist/core/domain/cipher/tools/constants.js +1 -0
  12. package/dist/core/domain/entities/agent.d.ts +16 -0
  13. package/dist/core/domain/entities/agent.js +78 -0
  14. package/dist/core/domain/entities/connector-type.d.ts +10 -0
  15. package/dist/core/domain/entities/connector-type.js +9 -0
  16. package/dist/core/domain/entities/event.d.ts +1 -1
  17. package/dist/core/domain/entities/event.js +2 -0
  18. package/dist/core/domain/errors/task-error.d.ts +4 -0
  19. package/dist/core/domain/errors/task-error.js +7 -0
  20. package/dist/core/domain/transport/schemas.d.ts +40 -0
  21. package/dist/core/domain/transport/schemas.js +28 -0
  22. package/dist/core/interfaces/connectors/connector-types.d.ts +70 -0
  23. package/dist/core/interfaces/connectors/i-connector-manager.d.ts +72 -0
  24. package/dist/core/interfaces/connectors/i-connector-manager.js +1 -0
  25. package/dist/core/interfaces/connectors/i-connector.d.ts +54 -0
  26. package/dist/core/interfaces/connectors/i-connector.js +1 -0
  27. package/dist/core/interfaces/i-file-service.d.ts +7 -0
  28. package/dist/core/interfaces/i-mcp-config-writer.d.ts +40 -0
  29. package/dist/core/interfaces/i-mcp-config-writer.js +1 -0
  30. package/dist/core/interfaces/i-rule-template-service.d.ts +4 -2
  31. package/dist/core/interfaces/transport/i-transport-client.d.ts +7 -0
  32. package/dist/core/interfaces/usecase/i-connectors-use-case.d.ts +3 -0
  33. package/dist/core/interfaces/usecase/i-connectors-use-case.js +1 -0
  34. package/dist/hooks/init/update-notifier.d.ts +1 -0
  35. package/dist/hooks/init/update-notifier.js +10 -1
  36. package/dist/infra/cipher/agent/cipher-agent.d.ts +8 -0
  37. package/dist/infra/cipher/agent/cipher-agent.js +16 -0
  38. package/dist/infra/cipher/file-system/binary-utils.d.ts +7 -12
  39. package/dist/infra/cipher/file-system/binary-utils.js +46 -31
  40. package/dist/infra/cipher/llm/context/context-manager.d.ts +10 -2
  41. package/dist/infra/cipher/llm/context/context-manager.js +39 -2
  42. package/dist/infra/cipher/llm/formatters/gemini-formatter.js +48 -9
  43. package/dist/infra/cipher/llm/internal-llm-service.d.ts +4 -0
  44. package/dist/infra/cipher/llm/internal-llm-service.js +40 -12
  45. package/dist/infra/cipher/session/chat-session.d.ts +3 -0
  46. package/dist/infra/cipher/session/chat-session.js +7 -1
  47. package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.d.ts +6 -7
  48. package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.js +57 -18
  49. package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +1 -8
  50. package/dist/infra/cipher/tools/implementations/curate-tool.js +380 -24
  51. package/dist/infra/cipher/tools/implementations/read-file-tool.js +38 -17
  52. package/dist/infra/cipher/tools/implementations/search-knowledge-tool.d.ts +7 -0
  53. package/dist/infra/cipher/tools/implementations/search-knowledge-tool.js +303 -0
  54. package/dist/infra/cipher/tools/index.d.ts +1 -0
  55. package/dist/infra/cipher/tools/index.js +1 -0
  56. package/dist/infra/cipher/tools/tool-manager.js +1 -0
  57. package/dist/infra/cipher/tools/tool-registry.js +7 -0
  58. package/dist/infra/connectors/connector-manager.d.ts +32 -0
  59. package/dist/infra/connectors/connector-manager.js +158 -0
  60. package/dist/infra/connectors/hook/hook-connector-config.d.ts +52 -0
  61. package/dist/infra/connectors/hook/hook-connector-config.js +41 -0
  62. package/dist/infra/connectors/hook/hook-connector.d.ts +46 -0
  63. package/dist/infra/connectors/hook/hook-connector.js +231 -0
  64. package/dist/infra/connectors/mcp/index.d.ts +4 -0
  65. package/dist/infra/connectors/mcp/index.js +4 -0
  66. package/dist/infra/connectors/mcp/json-mcp-config-writer.d.ts +26 -0
  67. package/dist/infra/connectors/mcp/json-mcp-config-writer.js +71 -0
  68. package/dist/infra/connectors/mcp/mcp-connector-config.d.ts +229 -0
  69. package/dist/infra/connectors/mcp/mcp-connector-config.js +173 -0
  70. package/dist/infra/connectors/mcp/mcp-connector.d.ts +80 -0
  71. package/dist/infra/connectors/mcp/mcp-connector.js +324 -0
  72. package/dist/infra/connectors/mcp/toml-mcp-config-writer.d.ts +45 -0
  73. package/dist/infra/connectors/mcp/toml-mcp-config-writer.js +134 -0
  74. package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.d.ts +2 -2
  75. package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.js +1 -1
  76. package/dist/infra/connectors/rules/rules-connector-config.d.ts +95 -0
  77. package/dist/infra/{rule/agent-rule-config.js → connectors/rules/rules-connector-config.js} +10 -10
  78. package/dist/infra/connectors/rules/rules-connector.d.ts +34 -0
  79. package/dist/infra/connectors/rules/rules-connector.js +139 -0
  80. package/dist/infra/connectors/shared/rule-file-manager.d.ts +72 -0
  81. package/dist/infra/connectors/shared/rule-file-manager.js +119 -0
  82. package/dist/infra/connectors/shared/template-service.d.ts +27 -0
  83. package/dist/infra/connectors/shared/template-service.js +125 -0
  84. package/dist/infra/context-tree/file-context-tree-writer-service.d.ts +5 -2
  85. package/dist/infra/context-tree/file-context-tree-writer-service.js +20 -5
  86. package/dist/infra/core/executors/curate-executor.d.ts +2 -2
  87. package/dist/infra/core/executors/curate-executor.js +7 -7
  88. package/dist/infra/core/executors/query-executor.d.ts +12 -0
  89. package/dist/infra/core/executors/query-executor.js +62 -1
  90. package/dist/infra/file/fs-file-service.d.ts +7 -0
  91. package/dist/infra/file/fs-file-service.js +15 -1
  92. package/dist/infra/mcp/index.d.ts +2 -0
  93. package/dist/infra/mcp/index.js +2 -0
  94. package/dist/infra/mcp/mcp-server.d.ts +58 -0
  95. package/dist/infra/mcp/mcp-server.js +178 -0
  96. package/dist/infra/mcp/tools/brv-curate-tool.d.ts +23 -0
  97. package/dist/infra/mcp/tools/brv-curate-tool.js +68 -0
  98. package/dist/infra/mcp/tools/brv-query-tool.d.ts +17 -0
  99. package/dist/infra/mcp/tools/brv-query-tool.js +68 -0
  100. package/dist/infra/mcp/tools/index.d.ts +3 -0
  101. package/dist/infra/mcp/tools/index.js +3 -0
  102. package/dist/infra/mcp/tools/task-result-waiter.d.ts +30 -0
  103. package/dist/infra/mcp/tools/task-result-waiter.js +56 -0
  104. package/dist/infra/process/agent-worker.d.ts +2 -2
  105. package/dist/infra/process/agent-worker.js +663 -142
  106. package/dist/infra/process/constants.d.ts +1 -1
  107. package/dist/infra/process/constants.js +1 -1
  108. package/dist/infra/process/ipc-types.d.ts +17 -4
  109. package/dist/infra/process/ipc-types.js +3 -3
  110. package/dist/infra/process/parent-heartbeat.d.ts +47 -0
  111. package/dist/infra/process/parent-heartbeat.js +118 -0
  112. package/dist/infra/process/process-manager.d.ts +79 -0
  113. package/dist/infra/process/process-manager.js +277 -3
  114. package/dist/infra/process/task-queue-manager.d.ts +13 -0
  115. package/dist/infra/process/task-queue-manager.js +19 -0
  116. package/dist/infra/process/transport-handlers.d.ts +3 -0
  117. package/dist/infra/process/transport-handlers.js +51 -5
  118. package/dist/infra/process/transport-worker.js +9 -69
  119. package/dist/infra/repl/commands/connectors-command.d.ts +8 -0
  120. package/dist/infra/repl/commands/{gen-rules-command.js → connectors-command.js} +21 -10
  121. package/dist/infra/repl/commands/curate-command.js +2 -2
  122. package/dist/infra/repl/commands/index.js +3 -2
  123. package/dist/infra/repl/commands/init-command.js +11 -7
  124. package/dist/infra/repl/commands/query-command.js +22 -2
  125. package/dist/infra/repl/commands/reset-command.js +1 -1
  126. package/dist/infra/transport/socket-io-transport-client.d.ts +75 -0
  127. package/dist/infra/transport/socket-io-transport-client.js +308 -7
  128. package/dist/infra/transport/socket-io-transport-server.js +4 -0
  129. package/dist/infra/usecase/connectors-use-case.d.ts +63 -0
  130. package/dist/infra/usecase/connectors-use-case.js +222 -0
  131. package/dist/infra/usecase/init-use-case.d.ts +8 -43
  132. package/dist/infra/usecase/init-use-case.js +27 -252
  133. package/dist/infra/usecase/logout-use-case.js +1 -1
  134. package/dist/infra/usecase/pull-use-case.js +5 -5
  135. package/dist/infra/usecase/push-use-case.js +4 -4
  136. package/dist/infra/usecase/reset-use-case.js +3 -4
  137. package/dist/infra/usecase/space-list-use-case.js +3 -3
  138. package/dist/infra/usecase/space-switch-use-case.js +3 -3
  139. package/dist/infra/usecase/status-use-case.d.ts +10 -0
  140. package/dist/infra/usecase/status-use-case.js +53 -0
  141. package/dist/resources/prompts/curate.yml +114 -4
  142. package/dist/resources/prompts/explore.yml +34 -0
  143. package/dist/resources/prompts/query-orchestrator.yml +112 -0
  144. package/dist/resources/prompts/system-prompt.yml +12 -2
  145. package/dist/resources/tools/search_knowledge.txt +32 -0
  146. package/dist/templates/mcp-base.md +1 -0
  147. package/dist/templates/sections/brv-instructions.md +98 -0
  148. package/dist/templates/sections/mcp-workflow.md +13 -0
  149. package/dist/tui/app.js +4 -1
  150. package/dist/tui/components/command-details.js +1 -1
  151. package/dist/tui/components/execution/execution-changes.d.ts +2 -0
  152. package/dist/tui/components/execution/execution-changes.js +5 -1
  153. package/dist/tui/components/execution/execution-content.d.ts +2 -0
  154. package/dist/tui/components/execution/execution-content.js +8 -18
  155. package/dist/tui/components/execution/execution-input.d.ts +2 -0
  156. package/dist/tui/components/execution/execution-input.js +6 -4
  157. package/dist/tui/components/execution/execution-progress.d.ts +2 -0
  158. package/dist/tui/components/execution/execution-progress.js +6 -2
  159. package/dist/tui/components/execution/expanded-log-view.d.ts +20 -0
  160. package/dist/tui/components/execution/expanded-log-view.js +75 -0
  161. package/dist/tui/components/execution/expanded-message-view.d.ts +24 -0
  162. package/dist/tui/components/execution/expanded-message-view.js +68 -0
  163. package/dist/tui/components/execution/index.d.ts +2 -0
  164. package/dist/tui/components/execution/index.js +2 -0
  165. package/dist/tui/components/execution/log-item.d.ts +4 -0
  166. package/dist/tui/components/execution/log-item.js +2 -2
  167. package/dist/tui/components/footer.js +1 -1
  168. package/dist/tui/components/index.d.ts +2 -1
  169. package/dist/tui/components/index.js +2 -1
  170. package/dist/tui/components/init.js +2 -9
  171. package/dist/tui/components/logo.js +4 -3
  172. package/dist/tui/components/markdown.d.ts +13 -0
  173. package/dist/tui/components/markdown.js +88 -0
  174. package/dist/tui/components/message-item.js +1 -1
  175. package/dist/tui/components/onboarding/onboarding-flow.js +14 -11
  176. package/dist/tui/components/onboarding/welcome-box.js +1 -1
  177. package/dist/tui/components/suggestions.js +3 -3
  178. package/dist/tui/contexts/mode-context.js +6 -2
  179. package/dist/tui/contexts/onboarding-context.d.ts +4 -0
  180. package/dist/tui/contexts/onboarding-context.js +14 -2
  181. package/dist/tui/hooks/index.d.ts +1 -0
  182. package/dist/tui/hooks/index.js +1 -0
  183. package/dist/tui/hooks/use-is-latest-version.d.ts +6 -0
  184. package/dist/tui/hooks/use-is-latest-version.js +22 -0
  185. package/dist/tui/views/command-view.d.ts +1 -1
  186. package/dist/tui/views/command-view.js +87 -98
  187. package/dist/tui/views/logs-view.d.ts +8 -0
  188. package/dist/tui/views/logs-view.js +55 -27
  189. package/dist/utils/file-validator.d.ts +1 -1
  190. package/dist/utils/file-validator.js +25 -28
  191. package/dist/utils/type-guards.d.ts +5 -0
  192. package/dist/utils/type-guards.js +7 -0
  193. package/oclif.manifest.json +55 -4
  194. package/package.json +12 -1
  195. package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +0 -3
  196. package/dist/infra/repl/commands/gen-rules-command.d.ts +0 -7
  197. package/dist/infra/rule/agent-rule-config.d.ts +0 -19
  198. package/dist/infra/rule/rule-template-service.d.ts +0 -18
  199. package/dist/infra/rule/rule-template-service.js +0 -88
  200. package/dist/infra/usecase/generate-rules-use-case.d.ts +0 -61
  201. package/dist/infra/usecase/generate-rules-use-case.js +0 -285
  202. /package/dist/core/interfaces/{usecase/i-generate-rules-use-case.js → connectors/connector-types.js} +0 -0
  203. /package/dist/infra/{rule → connectors/shared}/constants.d.ts +0 -0
  204. /package/dist/infra/{rule → connectors/shared}/constants.js +0 -0
@@ -0,0 +1,8 @@
1
+ import { SlashCommand } from '../../../tui/types.js';
2
+ /**
3
+ * Connectors command
4
+ *
5
+ * Manages connectors (rules, hook) for integrating BRV with coding agents.
6
+ * Lists connected agents and allows managing or adding new connections.
7
+ */
8
+ export declare const connectorsCommand: SlashCommand;
@@ -1,19 +1,20 @@
1
1
  import { CommandKind } from '../../../tui/types.js';
2
+ import { ConnectorManager } from '../../connectors/connector-manager.js';
3
+ import { RuleTemplateService } from '../../connectors/shared/template-service.js';
2
4
  import { FsFileService } from '../../file/fs-file-service.js';
3
- import { LegacyRuleDetector } from '../../rule/legacy-rule-detector.js';
4
- import { RuleTemplateService } from '../../rule/rule-template-service.js';
5
- import { FileGlobalConfigStore } from "../../storage/file-global-config-store.js";
5
+ import { FileGlobalConfigStore } from '../../storage/file-global-config-store.js';
6
6
  import { createTokenStore } from '../../storage/token-store.js';
7
7
  import { FsTemplateLoader } from '../../template/fs-template-loader.js';
8
8
  import { ReplTerminal } from '../../terminal/repl-terminal.js';
9
9
  import { MixpanelTrackingService } from '../../tracking/mixpanel-tracking-service.js';
10
- import { GenerateRulesUseCase } from '../../usecase/generate-rules-use-case.js';
10
+ import { ConnectorsUseCase } from '../../usecase/connectors-use-case.js';
11
11
  /**
12
- * Generate rules command
12
+ * Connectors command
13
13
  *
14
- * Creates and runs GenerateRulesUseCase with ReplTerminal for TUI integration.
14
+ * Manages connectors (rules, hook) for integrating BRV with coding agents.
15
+ * Lists connected agents and allows managing or adding new connections.
15
16
  */
16
- export const genRulesCommand = {
17
+ export const connectorsCommand = {
17
18
  action: () => ({
18
19
  async execute(onMessage, onPrompt) {
19
20
  // Create ReplTerminal with callbacks
@@ -24,15 +25,25 @@ export const genRulesCommand = {
24
25
  const templateService = new RuleTemplateService(templateLoader);
25
26
  const globalConfigStore = new FileGlobalConfigStore();
26
27
  const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore: createTokenStore() });
28
+ // Create ConnectorManager
29
+ const connectorManager = new ConnectorManager({
30
+ fileService,
31
+ projectRoot: process.cwd(),
32
+ templateService,
33
+ });
27
34
  // Create and run UseCase
28
- const useCase = new GenerateRulesUseCase(fileService, new LegacyRuleDetector(), templateService, terminal, trackingService);
35
+ const useCase = new ConnectorsUseCase({
36
+ connectorManager,
37
+ terminal,
38
+ trackingService,
39
+ });
29
40
  await useCase.run();
30
41
  },
31
42
  type: 'streaming',
32
43
  }),
33
44
  aliases: [],
34
45
  autoExecute: true,
35
- description: 'Generate rule instructions for coding agents to work with ByteRover correctly',
46
+ description: 'Manage agent connectors (rules, hooks)',
36
47
  kind: CommandKind.BUILT_IN,
37
- name: 'gen-rules',
48
+ name: 'connectors',
38
49
  };
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { isDevelopment } from '../../../config/environment.js';
3
3
  import { CommandKind } from '../../../tui/types.js';
4
- import { FileGlobalConfigStore } from "../../storage/file-global-config-store.js";
4
+ import { FileGlobalConfigStore } from '../../storage/file-global-config-store.js';
5
5
  import { createTokenStore } from '../../storage/token-store.js';
6
6
  import { ReplTerminal } from '../../terminal/repl-terminal.js';
7
7
  import { MixpanelTrackingService } from '../../tracking/mixpanel-tracking-service.js';
@@ -73,7 +73,7 @@ export const curateCommand = {
73
73
  {
74
74
  char: '@',
75
75
  description: 'Include files (type @ to browse, max 5)',
76
- name: 'files',
76
+ name: 'file',
77
77
  type: 'file',
78
78
  },
79
79
  ...(isDevelopment() ? toCommandFlags(devFlags) : []),
@@ -1,5 +1,5 @@
1
+ import { connectorsCommand } from './connectors-command.js';
1
2
  import { curateCommand } from './curate-command.js';
2
- import { genRulesCommand } from './gen-rules-command.js';
3
3
  import { initCommand } from './init-command.js';
4
4
  import { loginCommand } from './login-command.js';
5
5
  import { logoutCommand } from './logout-command.js';
@@ -21,13 +21,14 @@ export const load = () => [
21
21
  statusCommand, // Quick check current state
22
22
  curateCommand, // Add context (primary action)
23
23
  queryCommand, // Query context tree
24
+ // Connectors management
25
+ connectorsCommand, // Manage agent connectors (rules/hook)
24
26
  // Sync operations
25
27
  pushCommand, // Push to cloud
26
28
  pullCommand, // Pull from cloud
27
29
  // Space management
28
30
  spaceCommand, // Switch/list spaces
29
31
  // Context tree management
30
- genRulesCommand, // Generate rule files
31
32
  resetCommand, // Reset context tree (destructive)
32
33
  // Session management
33
34
  newCommand, // Start fresh session (ends current, clears conversation)
@@ -2,14 +2,14 @@ import { getCurrentConfig } from '../../../config/environment.js';
2
2
  import { CommandKind } from '../../../tui/types.js';
3
3
  import { HttpCogitPullService } from '../../cogit/http-cogit-pull-service.js';
4
4
  import { ProjectConfigStore } from '../../config/file-config-store.js';
5
+ import { ConnectorManager } from '../../connectors/connector-manager.js';
6
+ import { RuleTemplateService } from '../../connectors/shared/template-service.js';
5
7
  import { FileContextTreeService } from '../../context-tree/file-context-tree-service.js';
6
8
  import { FileContextTreeSnapshotService } from '../../context-tree/file-context-tree-snapshot-service.js';
7
9
  import { FileContextTreeWriterService } from '../../context-tree/file-context-tree-writer-service.js';
8
10
  import { FsFileService } from '../../file/fs-file-service.js';
9
- import { LegacyRuleDetector } from '../../rule/legacy-rule-detector.js';
10
- import { RuleTemplateService } from '../../rule/rule-template-service.js';
11
11
  import { HttpSpaceService } from '../../space/http-space-service.js';
12
- import { FileGlobalConfigStore } from "../../storage/file-global-config-store.js";
12
+ import { FileGlobalConfigStore } from '../../storage/file-global-config-store.js';
13
13
  import { createTokenStore } from '../../storage/token-store.js';
14
14
  import { HttpTeamService } from '../../team/http-team-service.js';
15
15
  import { FsTemplateLoader } from '../../template/fs-template-loader.js';
@@ -42,21 +42,26 @@ export const initCommand = {
42
42
  const trackingService = new MixpanelTrackingService({ globalConfigStore, tokenStore });
43
43
  const fileService = new FsFileService();
44
44
  const templateLoader = new FsTemplateLoader(fileService);
45
- const ruleTemplateService = new RuleTemplateService(templateLoader);
46
- const legacyRuleDetector = new LegacyRuleDetector();
45
+ const templateService = new RuleTemplateService(templateLoader);
47
46
  const contextTreeSnapshotService = new FileContextTreeSnapshotService();
47
+ // Create ConnectorManager
48
+ const connectorManager = new ConnectorManager({
49
+ fileService,
50
+ projectRoot: process.cwd(),
51
+ templateService,
52
+ });
48
53
  // Create and run use case
49
54
  const useCase = new InitUseCase({
50
55
  cogitPullService: new HttpCogitPullService({
51
56
  apiBaseUrl: envConfig.cogitApiBaseUrl,
52
57
  }),
58
+ connectorManager,
53
59
  contextTreeService: new FileContextTreeService(),
54
60
  contextTreeSnapshotService,
55
61
  contextTreeWriterService: new FileContextTreeWriterService({
56
62
  snapshotService: contextTreeSnapshotService,
57
63
  }),
58
64
  fileService,
59
- legacyRuleDetector,
60
65
  projectConfigStore: new ProjectConfigStore(),
61
66
  spaceService: new HttpSpaceService({
62
67
  apiBaseUrl: envConfig.apiBaseUrl,
@@ -64,7 +69,6 @@ export const initCommand = {
64
69
  teamService: new HttpTeamService({
65
70
  apiBaseUrl: envConfig.apiBaseUrl,
66
71
  }),
67
- templateService: ruleTemplateService,
68
72
  terminal,
69
73
  tokenStore,
70
74
  trackingService,
@@ -50,13 +50,33 @@ export const queryCommand = {
50
50
  aliases: ['q'],
51
51
  args: [
52
52
  {
53
- description: 'Natural language question about your codebase',
53
+ description: `Natural language question about your codebase or project knowledge.
54
+
55
+ Ask specific questions for better results. The query system will:
56
+ - Search your curated context tree for relevant information
57
+ - Analyze the query from multiple perspectives for comprehensive results
58
+ - Synthesize findings into a clear, cited answer
59
+
60
+ EXAMPLES:
61
+ /query How is authentication implemented?
62
+ /query What are the API error handling patterns?
63
+ /query Explain the database schema design decisions
64
+ /query What testing strategies are used in this project?
65
+
66
+ TIPS:
67
+ - Be specific: "How does JWT refresh work?" vs "authentication"
68
+ - Add context: "in the API layer" or "for user management"
69
+ - Ask about patterns, decisions, or implementations`,
54
70
  name: 'query',
55
71
  required: true,
56
72
  },
57
73
  ],
58
74
  autoExecute: false,
59
- description: 'Query and retrieve information from the context tree',
75
+ description: `Query and retrieve information from the context tree.
76
+
77
+ Searches your curated knowledge base using natural language. Complex queries
78
+ are automatically analyzed from multiple perspectives to find comprehensive
79
+ answers with file citations.`,
60
80
  flags: isDevelopment() ? toCommandFlags(devFlags) : [],
61
81
  kind: CommandKind.BUILT_IN,
62
82
  name: 'query',
@@ -54,7 +54,7 @@ export const resetCommand = {
54
54
  },
55
55
  ],
56
56
  autoExecute: true,
57
- description: 'Reset the current context tree and start with 6 default domains',
57
+ description: 'Reset the current context tree to an empty state',
58
58
  flags: toCommandFlags(resetFlags),
59
59
  kind: CommandKind.BUILT_IN,
60
60
  name: 'reset',
@@ -7,26 +7,76 @@ import type { ConnectionState, ConnectionStateHandler, EventHandler, ITransportC
7
7
  * - Auto-reconnects with exponential backoff
8
8
  * - Request/response uses Socket.IO acknowledgements (callbacks)
9
9
  * - Connection state is tracked and exposed via onStateChange
10
+ * - Force reconnect after all built-in attempts fail (sleep/wake recovery)
11
+ * - Auto-rejoins rooms after reconnect
10
12
  */
11
13
  export declare class SocketIOTransportClient implements ITransportClient {
12
14
  private readonly config;
13
15
  private eventHandlers;
16
+ /** Track force reconnect attempt count for backoff calculation */
17
+ private forceReconnectAttempt;
18
+ /** Timer for scheduled force reconnect */
19
+ private forceReconnectTimer?;
20
+ /** Track joined rooms for auto-rejoin after reconnect */
21
+ private joinedRooms;
22
+ /** Last time we checked for wake (for detecting time jumps) */
23
+ private lastWakeCheckTime;
14
24
  /** Track which events have socket listeners registered (prevents duplicates on reconnect) */
15
25
  private registeredSocketEvents;
26
+ /** Store server URL for force reconnect */
27
+ private serverUrl?;
16
28
  private socket;
17
29
  private state;
18
30
  private stateHandlers;
31
+ /** Timer for wake detection */
32
+ private wakeDetectionTimer?;
19
33
  constructor(config?: TransportClientConfig);
20
34
  connect(url: string): Promise<void>;
21
35
  disconnect(): Promise<void>;
22
36
  getClientId(): string | undefined;
23
37
  getState(): ConnectionState;
38
+ /**
39
+ * Checks if the socket is actually connected and responsive.
40
+ * Uses Socket.IO's built-in volatile emit with acknowledgement to verify bidirectional communication.
41
+ * @param timeoutMs - Timeout in milliseconds (default: 2000)
42
+ * @returns true if socket is connected and responsive, false otherwise
43
+ */
44
+ isConnected(timeoutMs?: number): Promise<boolean>;
24
45
  joinRoom(room: string): Promise<void>;
25
46
  leaveRoom(room: string): Promise<void>;
26
47
  on<T = unknown>(event: string, handler: EventHandler<T>): () => void;
27
48
  once<T = unknown>(event: string, handler: EventHandler<T>): void;
49
+ /**
50
+ * Subscribe to connection state changes.
51
+ *
52
+ * Important: Subscriptions persist across disconnect/connect cycles. Call the returned
53
+ * function to unsubscribe when no longer needed to prevent memory leaks.
54
+ *
55
+ * @returns Unsubscribe function - call to remove the handler
56
+ */
28
57
  onStateChange(handler: ConnectionStateHandler): () => void;
29
58
  request<TResponse = unknown, TRequest = unknown>(event: string, data?: TRequest, options?: RequestOptions): Promise<TResponse>;
59
+ /**
60
+ * Attempt force reconnect after Socket.IO gives up.
61
+ * Creates a new socket and connects.
62
+ * Gives up after MAX_FORCE_RECONNECT_ATTEMPTS (ProcessManager will detect via periodic health check).
63
+ */
64
+ private attemptForceReconnect;
65
+ /**
66
+ * Cancel force reconnect completely (clears timer AND resets counter).
67
+ * Used when connection is stable or on disconnect().
68
+ */
69
+ private cancelForceReconnect;
70
+ /**
71
+ * Clear force reconnect timer only (does NOT reset counter).
72
+ * Used when initiating new connection attempt - counter preserved for backoff continuity.
73
+ */
74
+ private clearForceReconnectTimer;
75
+ /**
76
+ * Handle system wake from sleep/hibernate.
77
+ * Re-triggers reconnection if not connected and force reconnect has given up.
78
+ */
79
+ private handleWakeFromSleep;
30
80
  /**
31
81
  * Register all pending event handlers on the socket.
32
82
  * Called after successful connection to handle handlers added before connect().
@@ -37,9 +87,34 @@ export declare class SocketIOTransportClient implements ITransportClient {
37
87
  * Uses registeredSocketEvents set to prevent duplicates.
38
88
  */
39
89
  private registerSocketEventIfNeeded;
90
+ /**
91
+ * Re-join all tracked rooms after reconnect.
92
+ * Retries failed room joins with exponential backoff.
93
+ */
94
+ private rejoinRooms;
95
+ /**
96
+ * Rejoin a single room with retry logic.
97
+ * Uses exponential backoff: 50ms, 100ms, 200ms, 400ms, 800ms (max 5 attempts).
98
+ * Retries BOTH when socket not connected AND when room:join fails.
99
+ */
100
+ private rejoinRoomWithRetry;
40
101
  /**
41
102
  * Remove socket listener for an event and clear tracking.
42
103
  */
43
104
  private removeSocketEventListener;
105
+ /**
106
+ * Schedule force reconnect with exponential backoff.
107
+ * Called after Socket.IO's built-in reconnection gives up.
108
+ */
109
+ private scheduleForceReconnect;
44
110
  private setState;
111
+ /**
112
+ * Start wake detection timer.
113
+ * Periodically checks for time jumps that indicate system woke from sleep.
114
+ */
115
+ private startWakeDetection;
116
+ /**
117
+ * Stop wake detection timer.
118
+ */
119
+ private stopWakeDetection;
45
120
  }