byterover-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/README.md +781 -0
  2. package/bin/dev.cmd +4 -0
  3. package/bin/dev.js +7 -0
  4. package/bin/run.cmd +4 -0
  5. package/bin/run.js +7 -0
  6. package/dist/commands/add.d.ts +60 -0
  7. package/dist/commands/add.js +230 -0
  8. package/dist/commands/clear.d.ts +13 -0
  9. package/dist/commands/clear.js +57 -0
  10. package/dist/commands/complete.d.ts +108 -0
  11. package/dist/commands/complete.js +340 -0
  12. package/dist/commands/gen-rules.d.ts +26 -0
  13. package/dist/commands/gen-rules.js +89 -0
  14. package/dist/commands/init.d.ts +24 -0
  15. package/dist/commands/init.js +135 -0
  16. package/dist/commands/login.d.ts +22 -0
  17. package/dist/commands/login.js +103 -0
  18. package/dist/commands/push.d.ts +33 -0
  19. package/dist/commands/push.js +150 -0
  20. package/dist/commands/retrieve.d.ts +26 -0
  21. package/dist/commands/retrieve.js +101 -0
  22. package/dist/commands/space/list.d.ts +22 -0
  23. package/dist/commands/space/list.js +105 -0
  24. package/dist/commands/space/switch.d.ts +20 -0
  25. package/dist/commands/space/switch.js +110 -0
  26. package/dist/commands/status.d.ts +22 -0
  27. package/dist/commands/status.js +116 -0
  28. package/dist/config/auth.config.d.ts +32 -0
  29. package/dist/config/auth.config.js +35 -0
  30. package/dist/config/environment.d.ts +35 -0
  31. package/dist/config/environment.js +39 -0
  32. package/dist/constants.d.ts +11 -0
  33. package/dist/constants.js +12 -0
  34. package/dist/core/domain/entities/agent.d.ts +5 -0
  35. package/dist/core/domain/entities/agent.js +23 -0
  36. package/dist/core/domain/entities/auth-token.d.ts +43 -0
  37. package/dist/core/domain/entities/auth-token.js +70 -0
  38. package/dist/core/domain/entities/br-config.d.ts +25 -0
  39. package/dist/core/domain/entities/br-config.js +58 -0
  40. package/dist/core/domain/entities/bullet.d.ts +51 -0
  41. package/dist/core/domain/entities/bullet.js +94 -0
  42. package/dist/core/domain/entities/curator-output.d.ts +14 -0
  43. package/dist/core/domain/entities/curator-output.js +23 -0
  44. package/dist/core/domain/entities/delta-batch.d.ts +30 -0
  45. package/dist/core/domain/entities/delta-batch.js +52 -0
  46. package/dist/core/domain/entities/delta-operation.d.ts +31 -0
  47. package/dist/core/domain/entities/delta-operation.js +50 -0
  48. package/dist/core/domain/entities/event.d.ts +8 -0
  49. package/dist/core/domain/entities/event.js +15 -0
  50. package/dist/core/domain/entities/executor-output.d.ts +27 -0
  51. package/dist/core/domain/entities/executor-output.js +33 -0
  52. package/dist/core/domain/entities/memory.d.ts +55 -0
  53. package/dist/core/domain/entities/memory.js +90 -0
  54. package/dist/core/domain/entities/oauth-token-data.d.ts +13 -0
  55. package/dist/core/domain/entities/oauth-token-data.js +20 -0
  56. package/dist/core/domain/entities/playbook.d.ts +97 -0
  57. package/dist/core/domain/entities/playbook.js +275 -0
  58. package/dist/core/domain/entities/presigned-url.d.ts +9 -0
  59. package/dist/core/domain/entities/presigned-url.js +18 -0
  60. package/dist/core/domain/entities/presigned-urls-response.d.ts +10 -0
  61. package/dist/core/domain/entities/presigned-urls-response.js +18 -0
  62. package/dist/core/domain/entities/reflector-output.d.ts +38 -0
  63. package/dist/core/domain/entities/reflector-output.js +44 -0
  64. package/dist/core/domain/entities/retrieve-result.d.ts +35 -0
  65. package/dist/core/domain/entities/retrieve-result.js +35 -0
  66. package/dist/core/domain/entities/space.d.ts +24 -0
  67. package/dist/core/domain/entities/space.js +52 -0
  68. package/dist/core/domain/entities/team.d.ts +42 -0
  69. package/dist/core/domain/entities/team.js +89 -0
  70. package/dist/core/domain/entities/user.d.ts +20 -0
  71. package/dist/core/domain/entities/user.js +32 -0
  72. package/dist/core/domain/errors/ace-error.d.ts +34 -0
  73. package/dist/core/domain/errors/ace-error.js +53 -0
  74. package/dist/core/domain/errors/auth-error.d.ts +10 -0
  75. package/dist/core/domain/errors/auth-error.js +20 -0
  76. package/dist/core/domain/errors/discovery-error.d.ts +21 -0
  77. package/dist/core/domain/errors/discovery-error.js +33 -0
  78. package/dist/core/domain/errors/rule-error.d.ts +6 -0
  79. package/dist/core/domain/errors/rule-error.js +12 -0
  80. package/dist/core/interfaces/i-ace-prompt-builder.d.ts +48 -0
  81. package/dist/core/interfaces/i-ace-prompt-builder.js +1 -0
  82. package/dist/core/interfaces/i-auth-service.d.ts +35 -0
  83. package/dist/core/interfaces/i-auth-service.js +1 -0
  84. package/dist/core/interfaces/i-browser-launcher.d.ts +11 -0
  85. package/dist/core/interfaces/i-browser-launcher.js +1 -0
  86. package/dist/core/interfaces/i-bullet-content-store.d.ts +36 -0
  87. package/dist/core/interfaces/i-bullet-content-store.js +1 -0
  88. package/dist/core/interfaces/i-callback-handler.d.ts +35 -0
  89. package/dist/core/interfaces/i-callback-handler.js +1 -0
  90. package/dist/core/interfaces/i-delta-store.d.ts +15 -0
  91. package/dist/core/interfaces/i-delta-store.js +1 -0
  92. package/dist/core/interfaces/i-executor-output-store.d.ts +14 -0
  93. package/dist/core/interfaces/i-executor-output-store.js +1 -0
  94. package/dist/core/interfaces/i-file-service.d.ts +34 -0
  95. package/dist/core/interfaces/i-file-service.js +1 -0
  96. package/dist/core/interfaces/i-http-client.d.ts +33 -0
  97. package/dist/core/interfaces/i-http-client.js +1 -0
  98. package/dist/core/interfaces/i-memory-retrieval-service.d.ts +40 -0
  99. package/dist/core/interfaces/i-memory-retrieval-service.js +1 -0
  100. package/dist/core/interfaces/i-memory-storage-service.d.ts +55 -0
  101. package/dist/core/interfaces/i-memory-storage-service.js +1 -0
  102. package/dist/core/interfaces/i-oidc-discovery-service.d.ts +20 -0
  103. package/dist/core/interfaces/i-oidc-discovery-service.js +1 -0
  104. package/dist/core/interfaces/i-playbook-service.d.ts +69 -0
  105. package/dist/core/interfaces/i-playbook-service.js +1 -0
  106. package/dist/core/interfaces/i-playbook-store.d.ts +38 -0
  107. package/dist/core/interfaces/i-playbook-store.js +1 -0
  108. package/dist/core/interfaces/i-project-config-store.d.ts +26 -0
  109. package/dist/core/interfaces/i-project-config-store.js +1 -0
  110. package/dist/core/interfaces/i-reflection-store.d.ts +21 -0
  111. package/dist/core/interfaces/i-reflection-store.js +1 -0
  112. package/dist/core/interfaces/i-rule-template-service.d.ts +17 -0
  113. package/dist/core/interfaces/i-rule-template-service.js +4 -0
  114. package/dist/core/interfaces/i-rule-writer-service.d.ts +13 -0
  115. package/dist/core/interfaces/i-rule-writer-service.js +1 -0
  116. package/dist/core/interfaces/i-space-service.d.ts +28 -0
  117. package/dist/core/interfaces/i-space-service.js +1 -0
  118. package/dist/core/interfaces/i-team-service.d.ts +29 -0
  119. package/dist/core/interfaces/i-team-service.js +1 -0
  120. package/dist/core/interfaces/i-template-loader.d.ts +29 -0
  121. package/dist/core/interfaces/i-template-loader.js +1 -0
  122. package/dist/core/interfaces/i-token-store.d.ts +22 -0
  123. package/dist/core/interfaces/i-token-store.js +1 -0
  124. package/dist/core/interfaces/i-tracking-service.d.ts +21 -0
  125. package/dist/core/interfaces/i-tracking-service.js +1 -0
  126. package/dist/core/interfaces/i-user-service.d.ts +14 -0
  127. package/dist/core/interfaces/i-user-service.js +1 -0
  128. package/dist/index.d.ts +1 -0
  129. package/dist/index.js +1 -0
  130. package/dist/infra/ace/ace-file-utils.d.ts +46 -0
  131. package/dist/infra/ace/ace-file-utils.js +83 -0
  132. package/dist/infra/ace/ace-prompt-templates.d.ts +13 -0
  133. package/dist/infra/ace/ace-prompt-templates.js +177 -0
  134. package/dist/infra/ace/file-bullet-content-store.d.ts +27 -0
  135. package/dist/infra/ace/file-bullet-content-store.js +89 -0
  136. package/dist/infra/ace/file-delta-store.d.ts +9 -0
  137. package/dist/infra/ace/file-delta-store.js +26 -0
  138. package/dist/infra/ace/file-executor-output-store.d.ts +9 -0
  139. package/dist/infra/ace/file-executor-output-store.js +26 -0
  140. package/dist/infra/ace/file-playbook-store.d.ts +29 -0
  141. package/dist/infra/ace/file-playbook-store.js +107 -0
  142. package/dist/infra/ace/file-reflection-store.d.ts +10 -0
  143. package/dist/infra/ace/file-reflection-store.js +55 -0
  144. package/dist/infra/auth/oauth-service.d.ts +49 -0
  145. package/dist/infra/auth/oauth-service.js +126 -0
  146. package/dist/infra/auth/oidc-discovery-service.d.ts +51 -0
  147. package/dist/infra/auth/oidc-discovery-service.js +145 -0
  148. package/dist/infra/browser/system-browser-launcher.d.ts +10 -0
  149. package/dist/infra/browser/system-browser-launcher.js +18 -0
  150. package/dist/infra/config/file-config-store.d.ts +21 -0
  151. package/dist/infra/config/file-config-store.js +57 -0
  152. package/dist/infra/file/fs-file-service.d.ts +28 -0
  153. package/dist/infra/file/fs-file-service.js +57 -0
  154. package/dist/infra/http/authenticated-http-client.d.ts +46 -0
  155. package/dist/infra/http/authenticated-http-client.js +99 -0
  156. package/dist/infra/http/callback-handler.d.ts +13 -0
  157. package/dist/infra/http/callback-handler.js +24 -0
  158. package/dist/infra/http/callback-server.d.ts +18 -0
  159. package/dist/infra/http/callback-server.js +93 -0
  160. package/dist/infra/memory/http-memory-retrieval-service.d.ts +18 -0
  161. package/dist/infra/memory/http-memory-retrieval-service.js +63 -0
  162. package/dist/infra/memory/http-memory-storage-service.d.ts +18 -0
  163. package/dist/infra/memory/http-memory-storage-service.js +67 -0
  164. package/dist/infra/memory/memory-to-playbook-mapper.d.ts +33 -0
  165. package/dist/infra/memory/memory-to-playbook-mapper.js +51 -0
  166. package/dist/infra/playbook/file-playbook-service.d.ts +43 -0
  167. package/dist/infra/playbook/file-playbook-service.js +133 -0
  168. package/dist/infra/rule/agent-rule-config.d.ts +19 -0
  169. package/dist/infra/rule/agent-rule-config.js +77 -0
  170. package/dist/infra/rule/rule-template-service.d.ts +18 -0
  171. package/dist/infra/rule/rule-template-service.js +80 -0
  172. package/dist/infra/rule/rule-writer-service.d.ts +19 -0
  173. package/dist/infra/rule/rule-writer-service.js +43 -0
  174. package/dist/infra/space/http-space-service.d.ts +20 -0
  175. package/dist/infra/space/http-space-service.js +67 -0
  176. package/dist/infra/storage/keychain-token-store.d.ts +10 -0
  177. package/dist/infra/storage/keychain-token-store.js +40 -0
  178. package/dist/infra/team/http-team-service.d.ts +21 -0
  179. package/dist/infra/team/http-team-service.js +71 -0
  180. package/dist/infra/template/fs-template-loader.d.ts +33 -0
  181. package/dist/infra/template/fs-template-loader.js +62 -0
  182. package/dist/infra/tracking/mixpanel-tracking-service.d.ts +14 -0
  183. package/dist/infra/tracking/mixpanel-tracking-service.js +44 -0
  184. package/dist/infra/user/http-user-service.d.ts +12 -0
  185. package/dist/infra/user/http-user-service.js +26 -0
  186. package/dist/templates/README.md +103 -0
  187. package/dist/templates/base.md +3 -0
  188. package/dist/templates/sections/command-reference.md +141 -0
  189. package/dist/templates/sections/workflow.md +46 -0
  190. package/dist/utils/file-helpers.d.ts +15 -0
  191. package/dist/utils/file-helpers.js +45 -0
  192. package/oclif.manifest.json +476 -0
  193. package/package.json +82 -0
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Configuration options for HTTP requests.
3
+ */
4
+ export type HttpRequestConfig = {
5
+ headers?: Record<string, string>;
6
+ timeout?: number;
7
+ };
8
+ /**
9
+ * Interface for HTTP client operations.
10
+ * Provides abstraction over HTTP libraries (axios, fetch, etc.) following Clean Architecture principles.
11
+ *
12
+ * Implementations should handle:
13
+ * - Request configuration (headers, timeout)
14
+ * - Error handling and transformation
15
+ * - Response parsing
16
+ */
17
+ export interface IHttpClient {
18
+ /**
19
+ * Performs an HTTP GET request.
20
+ * @param url The URL to request
21
+ * @param config Optional request configuration (headers, timeout)
22
+ * @returns A promise that resolves to the response data
23
+ */
24
+ get: <T>(url: string, config?: HttpRequestConfig) => Promise<T>;
25
+ /**
26
+ * Performs an HTTP POST request.
27
+ * @param url The URL to request
28
+ * @param data The data to send in the request body
29
+ * @param config Optional request configuration (headers, timeout)
30
+ * @returns A promise that resolves to the response data
31
+ */
32
+ post: <TResponse, TData = unknown>(url: string, data?: TData, config?: HttpRequestConfig) => Promise<TResponse>;
33
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { RetrieveResult } from '../domain/entities/retrieve-result.js';
2
+ export type RetrieveParams = {
3
+ accessToken: string;
4
+ nodeKeys?: string[];
5
+ query: string;
6
+ sessionKey: string;
7
+ spaceId: string;
8
+ };
9
+ /**
10
+ * Interface for memory retrieval operations from ByteRover Memora service.
11
+ * This service is responsible for fetching memories based on search queries.
12
+ */
13
+ export interface IMemoryRetrievalService {
14
+ /**
15
+ * Retrieves memories from the ByteRover Memora service based on a search query.
16
+ *
17
+ * @param params The retrieve operation parameters
18
+ * @returns A promise that resolves to the RetrieveResult containing memories and related memories
19
+ *
20
+ * @example
21
+ * // Broad search across entire space
22
+ * const result = await memoryService.retrieve({
23
+ * query: "authentication best practices",
24
+ * spaceId: "a0000000-b001-0000-0000-000000000000",
25
+ * accessToken: token.accessToken,
26
+ * sessionKey: token.sessionKey,
27
+ * });
28
+ *
29
+ * @example
30
+ * // Scoped search to specific files
31
+ * const result = await memoryService.retrieve({
32
+ * query: "error handling",
33
+ * spaceId: "a0000000-b001-0000-0000-000000000000",
34
+ * accessToken: token.accessToken,
35
+ * sessionKey: token.sessionKey,
36
+ * nodeKeys: ["src/auth/login.ts", "src/auth/oauth.ts"],
37
+ * });
38
+ */
39
+ retrieve: (params: RetrieveParams) => Promise<RetrieveResult>;
40
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { PresignedUrlsResponse } from '../domain/entities/presigned-urls-response.js';
2
+ /**
3
+ * Parameters for requesting presigned URLs.
4
+ */
5
+ export type GetPresignedUrlsParams = {
6
+ accessToken: string;
7
+ branch: string;
8
+ fileNames: string[];
9
+ sessionKey: string;
10
+ spaceId: string;
11
+ teamId: string;
12
+ };
13
+ /**
14
+ * Parameters for confirming upload completion.
15
+ */
16
+ export type ConfirmUploadParams = {
17
+ accessToken: string;
18
+ requestId: string;
19
+ sessionKey: string;
20
+ spaceId: string;
21
+ teamId: string;
22
+ };
23
+ /**
24
+ * Interface for memory storage operations to ByteRover CoGit service.
25
+ * This service is responsible for uploading playbooks to blob storage.
26
+ */
27
+ export interface IMemoryStorageService {
28
+ /**
29
+ * Confirms that file upload is complete.
30
+ * Notifies the server that all files have been successfully uploaded to blob storage.
31
+ *
32
+ * @param params Confirmation parameters including request ID from presigned URLs response
33
+ * @returns Promise that resolves when confirmation succeeds
34
+ * @throws Error if confirmation fails
35
+ */
36
+ confirmUpload: (params: ConfirmUploadParams) => Promise<void>;
37
+ /**
38
+ * Generates presigned URLs for uploading files to memory storage.
39
+ *
40
+ * @param params Request parameters including authentication, identifiers, and file list
41
+ * @returns Response object containing presigned URLs and request ID for confirmation
42
+ * @throws Error if the request fails
43
+ */
44
+ getPresignedUrls: (params: GetPresignedUrlsParams) => Promise<PresignedUrlsResponse>;
45
+ /**
46
+ * Uploads file content to a presigned URL.
47
+ * Uses HTTP PUT with the file content in the request body.
48
+ *
49
+ * @param uploadUrl The presigned URL from Google Cloud Storage
50
+ * @param content File content as string (typically JSON)
51
+ * @returns Promise that resolves when upload completes
52
+ * @throws Error if upload fails (network error, expired URL, etc.)
53
+ */
54
+ uploadFile: (uploadUrl: string, content: string) => Promise<void>;
55
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * OIDC metadata returned from the discovery endpoint.
3
+ */
4
+ export type OidcMetadata = {
5
+ authorizationEndpoint: string;
6
+ issuer: string;
7
+ scopesSupported?: string[];
8
+ tokenEndpoint: string;
9
+ };
10
+ /**
11
+ * Interface for OIDC discovery services.
12
+ */
13
+ export interface IOidcDiscoveryService {
14
+ /**
15
+ * Discovers OIDC configuration from the issuer's well-known endpoint.
16
+ * @param issuerUrl The base URL of the OIDC issuer.
17
+ * @returns The OIDC metadata.
18
+ */
19
+ discover: (issuerUrl: string) => Promise<OidcMetadata>;
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,69 @@
1
+ import type { Bullet, BulletMetadata } from '../domain/entities/bullet.js';
2
+ import type { DeltaBatch } from '../domain/entities/delta-batch.js';
3
+ import type { Playbook } from '../domain/entities/playbook.js';
4
+ import type { ReflectorOutput } from '../domain/entities/reflector-output.js';
5
+ /**
6
+ * Interface for playbook operations service.
7
+ * Provides high-level operations for managing ACE playbooks including
8
+ * initialization, bullet management, delta application, and reflection tag processing.
9
+ */
10
+ export interface IPlaybookService {
11
+ /**
12
+ * Adds a new bullet or updates an existing bullet in the playbook.
13
+ * @param params - Bullet parameters
14
+ * @param params.section - Section name for the bullet
15
+ * @param params.content - Content of the bullet
16
+ * @param params.bulletId - Optional bullet ID for update operation
17
+ * @param params.metadata - Optional metadata (tags, related files, timestamp)
18
+ * @param params.directory - Optional base directory (defaults to current working directory)
19
+ * @returns The created or updated bullet
20
+ * @throws Error if validation fails or bulletId not found for updates
21
+ */
22
+ addOrUpdateBullet(params: {
23
+ bulletId?: string;
24
+ content: string;
25
+ directory?: string;
26
+ metadata?: BulletMetadata;
27
+ section: string;
28
+ }): Promise<Bullet>;
29
+ /**
30
+ * Applies delta operations (ADD/UPDATE/REMOVE) to the playbook.
31
+ * Creates a new playbook if it doesn't exist.
32
+ * @param params - Delta application parameters
33
+ * @param params.delta - Delta batch containing operations to apply
34
+ * @param params.directory - Optional base directory (defaults to current working directory)
35
+ * @returns Result containing operations applied count and updated playbook
36
+ * @throws Error if delta application fails
37
+ */
38
+ applyDelta(params: {
39
+ delta: DeltaBatch;
40
+ directory?: string;
41
+ }): Promise<{
42
+ operationsApplied: number;
43
+ playbook: Playbook;
44
+ }>;
45
+ /**
46
+ * Applies reflection bullet tags to existing bullets in the playbook.
47
+ * Skips bullets that don't exist in the playbook.
48
+ * @param params - Reflection tag parameters
49
+ * @param params.reflection - Reflection output containing bullet tags
50
+ * @param params.directory - Optional base directory (defaults to current working directory)
51
+ * @returns Result containing tags applied count and updated playbook
52
+ * @throws Error if playbook not found or tag application fails
53
+ */
54
+ applyReflectionTags(params: {
55
+ directory?: string;
56
+ reflection: ReflectorOutput;
57
+ }): Promise<{
58
+ playbook: Playbook;
59
+ tagsApplied: number;
60
+ }>;
61
+ /**
62
+ * Initializes the ACE playbook directory structure and creates an empty playbook.
63
+ * Creates .br/ace/ directory with subdirectories: reflections/, executor-outputs/, deltas/
64
+ * @param directory - Optional base directory (defaults to current working directory)
65
+ * @returns The absolute path to the created playbook file
66
+ * @throws Error if playbook already exists or initialization fails
67
+ */
68
+ initialize(directory?: string): Promise<string>;
69
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { Playbook } from '../domain/entities/playbook.js';
2
+ /**
3
+ * Port for playbook persistence operations.
4
+ * Implementations can use file system, database, or remote storage.
5
+ */
6
+ export interface IPlaybookStore {
7
+ /**
8
+ * Clears the playbook content by replacing it with an empty playbook.
9
+ * Does nothing if the playbook doesn't exist.
10
+ * @param directory The project directory (defaults to current working directory)
11
+ */
12
+ clear: (directory?: string) => Promise<void>;
13
+ /**
14
+ * Deletes a playbook from storage.
15
+ * Does nothing if the playbook doesn't exist.
16
+ * @param directory The project directory (defaults to current working directory)
17
+ */
18
+ delete: (directory?: string) => Promise<void>;
19
+ /**
20
+ * Checks if a playbook exists in the specified directory.
21
+ * @param directory The project directory (defaults to current working directory)
22
+ * @returns True if playbook exists, false otherwise
23
+ */
24
+ exists: (directory?: string) => Promise<boolean>;
25
+ /**
26
+ * Loads a playbook from storage.
27
+ * @param directory The project directory (defaults to current working directory)
28
+ * @returns The playbook, or undefined if not found
29
+ */
30
+ load: (directory?: string) => Promise<Playbook | undefined>;
31
+ /**
32
+ * Saves a playbook to storage.
33
+ * Creates the directory structure if it doesn't exist.
34
+ * @param playbook The playbook to save
35
+ * @param directory The project directory (defaults to current working directory)
36
+ */
37
+ save: (playbook: Playbook, directory?: string) => Promise<void>;
38
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { BrConfig } from '../domain/entities/br-config.js';
2
+ /**
3
+ * Interface for storing and retrieving ByteRover CLI configuration.
4
+ * Implementations handle persistence of .br/config.json files.
5
+ */
6
+ export interface IProjectConfigStore {
7
+ /**
8
+ * Checks if a configuration file exists in the .br directory.
9
+ * @param directory The project directory to check (defaults to current working directory).
10
+ * @returns True if .br/config.json exists, false otherwise.
11
+ */
12
+ exists: (directory?: string) => Promise<boolean>;
13
+ /**
14
+ * Reads the configuration from the .br directory.
15
+ * @param directory The project directory containing .br folder (defaults to current working directory)
16
+ * @returns The configuration if found, undefined otherwise
17
+ */
18
+ read: (directory?: string) => Promise<BrConfig | undefined>;
19
+ /**
20
+ * Writes the configuration to the .br directory.
21
+ * @param config The configuration to write.
22
+ * @param directory The project directory to create .br folder in (defaults to current working directory)
23
+ * @returns
24
+ */
25
+ write: (config: BrConfig, directory?: string) => Promise<void>;
26
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { ReflectorOutput } from '../domain/entities/reflector-output.js';
2
+ /**
3
+ * Interface for reflection output storage operations.
4
+ * Implementations can be file-based (for production) or in-memory (for testing).
5
+ */
6
+ export interface IReflectionStore {
7
+ /**
8
+ * Loads the most recent reflections from storage.
9
+ * @param directory - Optional base directory (defaults to current working directory)
10
+ * @param count - Maximum number of recent reflections to load (default: 3)
11
+ * @returns Array of recent reflections, ordered from most recent to oldest
12
+ */
13
+ loadRecent(directory?: string, count?: number): Promise<ReflectorOutput[]>;
14
+ /**
15
+ * Saves a reflection output to storage.
16
+ * @param reflection - The reflection output to save
17
+ * @param directory - Optional base directory (defaults to current working directory)
18
+ * @returns The absolute path where the reflection was saved
19
+ */
20
+ save(reflection: ReflectorOutput, directory?: string): Promise<string>;
21
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { Agent } from '../domain/entities/agent.js';
2
+ /**
3
+ * ByteRover CLI generated rule template tag.
4
+ */
5
+ export declare const BR_RULE_TAG = "Generated by ByteRover CLI for";
6
+ /**
7
+ * Interface for rule template service operations.
8
+ */
9
+ export interface IRuleTemplateService {
10
+ /**
11
+ * Generates rule content based on the provided agent.
12
+ *
13
+ * @param agent The agent for which to generate the rule content.
14
+ * @returns Promise resolving to the generated rule content.
15
+ */
16
+ generateRuleContent: (agent: Agent) => Promise<string>;
17
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * ByteRover CLI generated rule template tag.
3
+ */
4
+ export const BR_RULE_TAG = 'Generated by ByteRover CLI for';
@@ -0,0 +1,13 @@
1
+ import { Agent } from '../domain/entities/agent.js';
2
+ /**
3
+ * Interface for rule writer service operations.
4
+ */
5
+ export interface IRuleWriterService {
6
+ /**
7
+ * Writes a rule for the given agent.
8
+ * @param agent The agent for which to write the rule.
9
+ * @param force Whether to force the rule to be written even if it already exists.
10
+ * @returns A promise that resolves when the rule has been written.
11
+ */
12
+ writeRule: (agent: Agent, force: boolean) => Promise<void>;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { Space } from '../domain/entities/space.js';
2
+ /**
3
+ * Interface for space-related operations.
4
+ * Implementations can be HTTP-based (for production) or mock (for testing/development).
5
+ */
6
+ export interface ISpaceService {
7
+ /**
8
+ * Fetches spaces accessible to the authenticated user within a specific team.
9
+ * @param accessToken The OAuth access token for authentication
10
+ * @param sessionKey The session key for tracking the user session
11
+ * @param teamId The team ID to filter spaces by
12
+ * @param option Optional pagination options
13
+ * @param option.limit Maximum number of spaces to fetch in a single request
14
+ * @param option.offset Number of spaces to skip (for pagination)
15
+ * @param option.fetchAll If true, automatically paginate to fetch all spaces
16
+ * @returns A promise that resolves to an object containing:
17
+ * - spaces: Array of Space entities
18
+ * - total: Total number of spaces available (across all pages)
19
+ */
20
+ getSpaces: (accessToken: string, sessionKey: string, teamId: string, option?: {
21
+ fetchAll?: boolean;
22
+ limit?: number;
23
+ offset?: number;
24
+ }) => Promise<{
25
+ spaces: Space[];
26
+ total: number;
27
+ }>;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ import type { Team } from '../domain/entities/team.js';
2
+ /**
3
+ * Interface for team-related operations.
4
+ * Implementations can be HTTP-based (for production) or mock (for testing/development).
5
+ */
6
+ export interface ITeamService {
7
+ /**
8
+ * Fetches teams where the authenticated user is a member.
9
+ * @param accessToken The OAuth access token for authentication
10
+ * @param sessionKey The session key for tracking the user session
11
+ * @param option Optional filtering and pagination options
12
+ * @param option.limit Maximum number of teams to fetch in a single request
13
+ * @param option.offset Number of teams to skip (for pagination)
14
+ * @param option.isActive Filter teams by active status
15
+ * @param option.fetchAll If true, automatically paginate to fetch all teams
16
+ * @returns A promise that resolves to an object containing:
17
+ * - teams: Array of Team entities
18
+ * - total: Total number of teams available (across all pages)
19
+ */
20
+ getTeams: (accessToken: string, sessionKey: string, option?: {
21
+ fetchAll?: boolean;
22
+ isActive?: boolean;
23
+ limit?: number;
24
+ offset?: number;
25
+ }) => Promise<{
26
+ teams: Team[];
27
+ total: number;
28
+ }>;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Interface for loading and processing template files.
3
+ * Supports loading templates from various sources and performing variable substitution.
4
+ */
5
+ export interface ITemplateLoader {
6
+ /**
7
+ * Loads a section template by name.
8
+ * Convenience method that loads from the sections/ directory.
9
+ * @param sectionName - Name of the section (e.g., 'workflow', 'command-reference')
10
+ * @returns Promise resolving to the section content as a string
11
+ * @throws Error if the section file cannot be found or read
12
+ */
13
+ loadSection(sectionName: string): Promise<string>;
14
+ /**
15
+ * Loads a template file from the specified path.
16
+ * @param templatePath - Relative path to the template file (e.g., 'base.md', 'sections/workflow.md')
17
+ * @returns Promise resolving to the template content as a string
18
+ * @throws Error if the template file cannot be found or read
19
+ */
20
+ loadTemplate(templatePath: string): Promise<string>;
21
+ /**
22
+ * Substitutes variables in a template string.
23
+ * Replaces {{variable_name}} with corresponding values from the context.
24
+ * @param template - Template string containing variables to substitute
25
+ * @param context - Object containing variable values (e.g., {agent_name: 'Claude Code'})
26
+ * @returns Template string with variables replaced by their values
27
+ */
28
+ substituteVariables(template: string, context: Record<string, string>): string;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { AuthToken } from '../domain/entities/auth-token.js';
2
+ /**
3
+ * Interface for token storage mechanisms.
4
+ */
5
+ export interface ITokenStore {
6
+ /**
7
+ * Clears the stored token.
8
+ * @returns A promise that resolves when the token is cleared.
9
+ */
10
+ clear: () => Promise<void>;
11
+ /**
12
+ * Loads the stored token.
13
+ * @returns A promise that resolves with the loaded token or undefined if not found.
14
+ */
15
+ load: () => Promise<AuthToken | undefined>;
16
+ /**
17
+ * Saves the token to storage.
18
+ * @param token The token to save.
19
+ * @returns A promise that resolves when the token is saved.
20
+ */
21
+ save: (token: AuthToken) => Promise<void>;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import { EventName, PropertyDict } from '../domain/entities/event.js';
2
+ /**
3
+ * Service interface for tracking user actions and system events.
4
+ *
5
+ * Provides a unified contract for event tracking and analytics throughout the application.
6
+ * Implementations should be non-blocking and handle failures gracefully to avoid impacting
7
+ * user operations.
8
+ */
9
+ export interface ITrackingService {
10
+ /**
11
+ * Tracks a named event with optional metadata.
12
+ *
13
+ * This method should be asynchronous and non-blocking. Implementations should log
14
+ * errors internally rather than throwing, to prevent tracking failures from disrupting
15
+ * user operations.
16
+ *
17
+ * @param eventName - The name of the event to track. Must be one of the predefined EventName values.
18
+ * @param properties - Optional metadata to attach to the event as key-value pairs. All values must be strings.
19
+ */
20
+ track(eventName: EventName, properties?: PropertyDict): Promise<void>;
21
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { User } from '../domain/entities/user.js';
2
+ /**
3
+ * Interface for user-related operations.
4
+ * Implementations can be HTTP-based (for production) or mock (for testing/development).
5
+ */
6
+ export interface IUserService {
7
+ /**
8
+ * Fetches the current authenticated user's information.
9
+ * @param accessToken The OAuth access token for authentication
10
+ * @param sessionKey The session key for tracking the user session
11
+ * @returns A promise that resolves to the User entity
12
+ */
13
+ getCurrentUser: (accessToken: string, sessionKey: string) => Promise<User>;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { run } from '@oclif/core';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { run } from '@oclif/core';
@@ -0,0 +1,46 @@
1
+ import { DeltaBatch } from '../../core/domain/entities/delta-batch.js';
2
+ import { ExecutorOutput } from '../../core/domain/entities/executor-output.js';
3
+ import { ReflectorOutput } from '../../core/domain/entities/reflector-output.js';
4
+ /**
5
+ * Sanitize hint for use in filename.
6
+ * Converts to lowercase, replaces spaces/underscores with hyphens,
7
+ * removes all non-alphanumeric characters except hyphens.
8
+ * @param hint - The hint string to sanitize
9
+ * @returns Sanitized hint suitable for filename
10
+ */
11
+ export declare function sanitizeHint(hint: string): string;
12
+ /**
13
+ * Generates a timestamped filename for ACE output files.
14
+ * @param type - The file type prefix (e.g., 'delta', 'reflection', 'executor-output')
15
+ * @param hint - Optional hint to include in filename
16
+ * @returns Filename in format: {type}-{hint}-{timestamp}.json or {type}-{timestamp}.json
17
+ */
18
+ export declare function generateTimestampedFilename(type: string, hint?: string): string;
19
+ /**
20
+ * Ensures that an ACE subdirectory exists, creating it if necessary.
21
+ * @param baseDir - The base project directory (defaults to current working directory)
22
+ * @param subdir - The ACE subdirectory name (e.g., 'deltas', 'reflections', 'executor-outputs')
23
+ * @returns The absolute path to the subdirectory
24
+ */
25
+ export declare function ensureAceDirectory(baseDir: string | undefined, subdir: string): Promise<string>;
26
+ /**
27
+ * Loads and parses an executor output file.
28
+ * @param filePath - Absolute path to executor output JSON file
29
+ * @returns ExecutorOutput entity
30
+ * @throws Error if file doesn't exist or JSON is invalid
31
+ */
32
+ export declare function loadExecutorOutput(filePath: string): Promise<ExecutorOutput>;
33
+ /**
34
+ * Loads and parses a reflection output file.
35
+ * @param filePath - Absolute path to reflection output JSON file
36
+ * @returns ReflectorOutput entity
37
+ * @throws Error if file doesn't exist or JSON is invalid
38
+ */
39
+ export declare function loadReflectionOutput(filePath: string): Promise<ReflectorOutput>;
40
+ /**
41
+ * Loads and parses a delta batch file.
42
+ * @param filePath - Absolute path to delta batch JSON file
43
+ * @returns DeltaBatch entity
44
+ * @throws Error if file doesn't exist or JSON is invalid
45
+ */
46
+ export declare function loadDeltaBatch(filePath: string): Promise<DeltaBatch>;