byterover-cli 2.5.1 → 2.6.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 (85) hide show
  1. package/.env.production +7 -0
  2. package/LICENSE +44 -0
  3. package/bin/dev.js +8 -1
  4. package/bin/run.js +8 -1
  5. package/dist/server/config/environment.d.ts +0 -19
  6. package/dist/server/config/environment.js +29 -38
  7. package/dist/server/constants.d.ts +0 -9
  8. package/dist/server/constants.js +0 -12
  9. package/dist/server/core/domain/errors/auth-error.d.ts +0 -6
  10. package/dist/server/core/domain/errors/auth-error.js +0 -12
  11. package/dist/server/core/domain/errors/task-error.d.ts +0 -3
  12. package/dist/server/core/domain/errors/task-error.js +0 -8
  13. package/dist/server/core/domain/errors/transport-error.d.ts +0 -31
  14. package/dist/server/core/domain/errors/transport-error.js +0 -50
  15. package/dist/server/infra/connectors/rules/rules-connector-config.d.ts +0 -4
  16. package/dist/server/infra/http/models-dev-client.d.ts +0 -4
  17. package/dist/server/infra/http/models-dev-client.js +0 -6
  18. package/dist/server/infra/http/openrouter-api-client.d.ts +0 -8
  19. package/dist/server/infra/http/openrouter-api-client.js +0 -13
  20. package/dist/server/infra/http/provider-model-fetcher-registry.d.ts +0 -5
  21. package/dist/server/infra/http/provider-model-fetcher-registry.js +0 -7
  22. package/dist/server/infra/provider/env-provider-detector.d.ts +0 -20
  23. package/dist/server/infra/provider/env-provider-detector.js +0 -27
  24. package/dist/server/infra/storage/file-provider-config-store.d.ts +0 -4
  25. package/dist/server/infra/storage/file-provider-config-store.js +0 -6
  26. package/dist/server/utils/file-content-reader.d.ts +2 -1
  27. package/dist/server/utils/file-helpers.d.ts +0 -24
  28. package/dist/server/utils/file-helpers.js +0 -81
  29. package/dist/server/utils/process-logger.d.ts +0 -13
  30. package/dist/server/utils/process-logger.js +1 -78
  31. package/node_modules/@campfirein/brv-transport-client/LICENSE +95 -0
  32. package/node_modules/@campfirein/brv-transport-client/README.md +3 -4
  33. package/node_modules/@campfirein/brv-transport-client/package.json +2 -2
  34. package/oclif.manifest.json +1 -1
  35. package/package.json +6 -4
  36. package/dist/server/core/domain/entities/bullet.d.ts +0 -51
  37. package/dist/server/core/domain/entities/bullet.js +0 -94
  38. package/dist/server/core/domain/entities/memory.d.ts +0 -55
  39. package/dist/server/core/domain/entities/memory.js +0 -90
  40. package/dist/server/core/domain/entities/playbook.d.ts +0 -80
  41. package/dist/server/core/domain/entities/playbook.js +0 -214
  42. package/dist/server/core/domain/entities/presigned-url.d.ts +0 -9
  43. package/dist/server/core/domain/entities/presigned-url.js +0 -18
  44. package/dist/server/core/domain/entities/presigned-urls-response.d.ts +0 -10
  45. package/dist/server/core/domain/entities/presigned-urls-response.js +0 -18
  46. package/dist/server/core/domain/entities/retrieve-result.d.ts +0 -35
  47. package/dist/server/core/domain/entities/retrieve-result.js +0 -35
  48. package/dist/server/core/domain/errors/headless-prompt-error.d.ts +0 -11
  49. package/dist/server/core/domain/errors/headless-prompt-error.js +0 -18
  50. package/dist/server/core/interfaces/services/i-legacy-rule-detector.d.ts +0 -56
  51. package/dist/server/core/interfaces/services/i-legacy-rule-detector.js +0 -1
  52. package/dist/server/core/interfaces/services/i-memory-retrieval-service.d.ts +0 -39
  53. package/dist/server/core/interfaces/services/i-memory-retrieval-service.js +0 -1
  54. package/dist/server/core/interfaces/services/i-memory-storage-service.d.ts +0 -53
  55. package/dist/server/core/interfaces/services/i-memory-storage-service.js +0 -1
  56. package/dist/server/core/interfaces/services/i-terminal.d.ts +0 -146
  57. package/dist/server/core/interfaces/services/i-terminal.js +0 -1
  58. package/dist/server/core/interfaces/services/i-workspace-detector-service.d.ts +0 -8
  59. package/dist/server/core/interfaces/services/i-workspace-detector-service.js +0 -1
  60. package/dist/server/core/interfaces/storage/i-onboarding-preference-store.d.ts +0 -20
  61. package/dist/server/core/interfaces/storage/i-onboarding-preference-store.js +0 -1
  62. package/dist/server/infra/connectors/rules/legacy-rule-detector.d.ts +0 -21
  63. package/dist/server/infra/connectors/rules/legacy-rule-detector.js +0 -106
  64. package/dist/server/infra/memory/http-memory-retrieval-service.d.ts +0 -18
  65. package/dist/server/infra/memory/http-memory-retrieval-service.js +0 -64
  66. package/dist/server/infra/memory/http-memory-storage-service.d.ts +0 -18
  67. package/dist/server/infra/memory/http-memory-storage-service.js +0 -72
  68. package/dist/server/infra/memory/memory-to-playbook-mapper.d.ts +0 -33
  69. package/dist/server/infra/memory/memory-to-playbook-mapper.js +0 -51
  70. package/dist/server/infra/storage/file-onboarding-preference-store.d.ts +0 -10
  71. package/dist/server/infra/storage/file-onboarding-preference-store.js +0 -45
  72. package/dist/server/infra/terminal/headless-terminal.d.ts +0 -91
  73. package/dist/server/infra/terminal/headless-terminal.js +0 -211
  74. package/dist/server/infra/workspace/workspace-detector-service.d.ts +0 -57
  75. package/dist/server/infra/workspace/workspace-detector-service.js +0 -165
  76. package/dist/server/utils/crash-log.d.ts +0 -14
  77. package/dist/server/utils/crash-log.js +0 -19
  78. package/dist/server/utils/emoji-helpers.d.ts +0 -38
  79. package/dist/server/utils/emoji-helpers.js +0 -42
  80. package/dist/server/utils/error-handler.d.ts +0 -51
  81. package/dist/server/utils/error-handler.js +0 -169
  82. package/dist/server/utils/oclif-error-helpers.d.ts +0 -40
  83. package/dist/server/utils/oclif-error-helpers.js +0 -46
  84. package/dist/server/utils/tool-display-formatter.d.ts +0 -53
  85. package/dist/server/utils/tool-display-formatter.js +0 -257
@@ -1,49 +1,3 @@
1
- import fs from 'node:fs';
2
- import { readdir, unlink } from 'node:fs/promises';
3
- import { join } from 'node:path';
4
- /**
5
- * Finds the most recent file in a directory by modification time.
6
- * @param directory - Absolute path to directory to search
7
- * @returns Absolute path to the most recent file
8
- * @throws Error if directory is empty or doesn't exist
9
- */
10
- export async function findLatestFile(directory) {
11
- const files = await readdir(directory, { withFileTypes: true });
12
- const fileNames = files.filter((f) => f.isFile()).map((f) => f.name);
13
- if (fileNames.length === 0) {
14
- throw new Error(`No files found in directory: ${directory}`);
15
- }
16
- // Sort files by name (timestamp-based naming ensures latest is last)
17
- // Assuming filenames follow pattern: prefix-{timestamp}.json
18
- fileNames.sort();
19
- const latestFile = fileNames.at(-1);
20
- return join(directory, latestFile);
21
- }
22
- /**
23
- * Removes all files from a directory while preserving the directory itself.
24
- * Returns the number of files removed.
25
- * Silently succeeds if directory doesn't exist.
26
- * @param dirPath - Absolute path to directory to clear
27
- * @returns Number of files removed
28
- */
29
- export async function clearDirectory(dirPath) {
30
- try {
31
- const entries = await readdir(dirPath, { withFileTypes: true });
32
- // Filter to only get files (not subdirectories)
33
- const files = entries.filter((entry) => entry.isFile());
34
- // Remove each file
35
- await Promise.all(files.map((file) => unlink(join(dirPath, file.name))));
36
- return files.length;
37
- }
38
- catch (error) {
39
- // If directory doesn't exist (ENOENT), return 0
40
- if (error.code === 'ENOENT') {
41
- return 0;
42
- }
43
- // Re-throw other errors
44
- throw error;
45
- }
46
- }
47
1
  /**
48
2
  * Sanitizes a folder path by replacing all special characters with a hyphen.
49
3
  * @param folderName - The folder path need to sanitize
@@ -73,38 +27,3 @@ export function toSnakeCase(name) {
73
27
  .replaceAll(/_{2,}/g, '_')
74
28
  .replaceAll(/^_|_$/g, '');
75
29
  }
76
- /**
77
- * Lists all immediate children (files and directories) of the given directory,
78
- * and, for each child folder, shows its own immediate children.
79
- * @param dirPath The directory path whose children to list.
80
- * @returns An object where keys are child names, and values are:
81
- * - for files: undefined
82
- * - for directories: an array of their immediate children
83
- */
84
- export function listDirectoryChildren(dirPath = '.brv/context-tree') {
85
- const result = {};
86
- const children = fs.readdirSync(dirPath);
87
- for (const child of children) {
88
- const childPath = `${dirPath}/${child}`;
89
- let stat;
90
- try {
91
- stat = fs.statSync(childPath);
92
- }
93
- catch {
94
- result[child] = undefined;
95
- continue;
96
- }
97
- if (stat.isDirectory()) {
98
- try {
99
- result[child] = fs.readdirSync(childPath);
100
- }
101
- catch {
102
- result[child] = undefined;
103
- }
104
- }
105
- else {
106
- result[child] = undefined;
107
- }
108
- }
109
- return result;
110
- }
@@ -8,11 +8,6 @@
8
8
  *
9
9
  * Each session creates a new log file with timestamp.
10
10
  */
11
- /**
12
- * Initialize session log - creates a new log file for this session.
13
- * Should be called once when the main process starts.
14
- */
15
- export declare function initSessionLog(): void;
16
11
  /**
17
12
  * Write a log entry to the log file.
18
13
  * Uses synchronous append for reliability in process shutdown scenarios.
@@ -26,18 +21,10 @@ export declare function transportLog(message: string): void;
26
21
  * Log with [Agent] prefix.
27
22
  */
28
23
  export declare function agentLog(message: string): void;
29
- /**
30
- * Log with [ProcessManager] prefix.
31
- */
32
- export declare function processManagerLog(message: string): void;
33
24
  /**
34
25
  * Log a transport event (for TUI monitoring).
35
26
  */
36
27
  export declare function eventLog(eventName: string, data?: unknown): void;
37
- /**
38
- * Log an error with full details.
39
- */
40
- export declare function errorLog(error: Error | string, context?: string): void;
41
28
  /**
42
29
  * Log a crash with full environment details.
43
30
  * Everything goes to the session log file.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Each session creates a new log file with timestamp.
10
10
  */
11
- import { appendFileSync, existsSync, mkdirSync, readdirSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
11
+ import { appendFileSync, existsSync, mkdirSync } from 'node:fs';
12
12
  import { join } from 'node:path';
13
13
  import { getGlobalLogsDir } from './global-logs-path.js';
14
14
  /** Current session's log file path (set on init) */
@@ -35,34 +35,6 @@ function ensureLogDir() {
35
35
  // Logging will fail gracefully later when trying to write
36
36
  }
37
37
  }
38
- /** Max age for log files in milliseconds (30 days) */
39
- const LOG_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;
40
- /**
41
- * Clean up log files older than 30 days.
42
- * Runs silently - errors are ignored to not affect the main process.
43
- */
44
- function cleanupOldLogs() {
45
- try {
46
- const logsDir = getLogsDir();
47
- if (!existsSync(logsDir))
48
- return;
49
- const now = Date.now();
50
- const files = readdirSync(logsDir);
51
- for (const file of files) {
52
- if (!file.endsWith('.log'))
53
- continue;
54
- const filePath = join(logsDir, file);
55
- const stats = statSync(filePath);
56
- const age = now - stats.mtimeMs;
57
- if (age > LOG_MAX_AGE_MS) {
58
- unlinkSync(filePath);
59
- }
60
- }
61
- }
62
- catch {
63
- // Silently ignore - don't crash the process
64
- }
65
- }
66
38
  /**
67
39
  * Format timestamp for log entries.
68
40
  */
@@ -104,32 +76,6 @@ function getLogPath() {
104
76
  }
105
77
  return sessionLogPath;
106
78
  }
107
- /**
108
- * Initialize session log - creates a new log file for this session.
109
- * Should be called once when the main process starts.
110
- */
111
- export function initSessionLog() {
112
- if (sessionLogPath)
113
- return;
114
- try {
115
- ensureLogDir();
116
- cleanupOldLogs();
117
- sessionLogPath = join(getLogsDir(), generateSessionLogFilename());
118
- const timestamp = formatTimestamp();
119
- const header = [
120
- '='.repeat(70),
121
- `BRV Session Log - Started: ${timestamp}`,
122
- `CWD: ${process.cwd()}`,
123
- `Node: ${process.version} | Platform: ${process.platform} | PID: ${process.pid}`,
124
- '='.repeat(70),
125
- '',
126
- ].join('\n');
127
- writeFileSync(sessionLogPath, header);
128
- }
129
- catch {
130
- // Silently ignore - don't crash the process
131
- }
132
- }
133
79
  /**
134
80
  * Write a log entry to the log file.
135
81
  * Uses synchronous append for reliability in process shutdown scenarios.
@@ -157,12 +103,6 @@ export function transportLog(message) {
157
103
  export function agentLog(message) {
158
104
  processLog(`[Agent] ${message}`);
159
105
  }
160
- /**
161
- * Log with [ProcessManager] prefix.
162
- */
163
- export function processManagerLog(message) {
164
- processLog(`[ProcessManager] ${message}`);
165
- }
166
106
  /**
167
107
  * Log a transport event (for TUI monitoring).
168
108
  */
@@ -170,23 +110,6 @@ export function eventLog(eventName, data) {
170
110
  const dataStr = data ? ` ${JSON.stringify(data)}` : '';
171
111
  processLog(`[Event] ${eventName}${dataStr}`);
172
112
  }
173
- /**
174
- * Log an error with full details.
175
- */
176
- export function errorLog(error, context) {
177
- const errorMessage = error instanceof Error ? error.message : error;
178
- const errorStack = error instanceof Error ? error.stack : undefined;
179
- const contextStr = context ? ` (${context})` : '';
180
- processLog(`[ERROR]${contextStr} ${errorMessage}`);
181
- if (errorStack) {
182
- const indentedStack = errorStack
183
- .split('\n')
184
- .slice(1)
185
- .map((line) => ` ${line}`)
186
- .join('\n');
187
- processLog(indentedStack);
188
- }
189
- }
190
113
  /**
191
114
  * Log a crash with full environment details.
192
115
  * Everything goes to the session log file.
@@ -0,0 +1,95 @@
1
+ Copyright (c) 2026 ByteRover
2
+
3
+ Elastic License 2.0
4
+
5
+ URL: https://www.elastic.co/licensing/elastic-license
6
+
7
+ ## Acceptance
8
+
9
+ By using the software, you agree to all of the terms and conditions below.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
14
+ non-sublicensable, non-transferable license to use, copy, distribute, make
15
+ available, and prepare derivative works of the software, in each case subject to
16
+ the limitations and conditions below.
17
+
18
+ ## Limitations
19
+
20
+ You may not provide the software to third parties as a hosted or managed
21
+ service, where the service provides users with access to any substantial set of
22
+ the features or functionality of the software.
23
+
24
+ You may not move, change, disable, or circumvent the license key functionality
25
+ in the software, and you may not remove or obscure any functionality in the
26
+ software that is protected by the license key.
27
+
28
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
29
+ of the licensor in the software. Any use of the licensor's trademarks is subject
30
+ to applicable law.
31
+
32
+ ## Patents
33
+
34
+ The licensor grants you a license, under any patent claims the licensor can
35
+ license, or becomes able to license, to make, have made, use, sell, offer for
36
+ sale, import and have imported the software, in each case subject to the
37
+ limitations and conditions in this license. This license does not cover any
38
+ patent claims that you cause to be infringed by modifications or additions to
39
+ the software. If you or your company make any written claim that the software
40
+ infringes or contributes to infringement of any patent, your patent license for
41
+ the software granted under these terms ends immediately. If your company makes
42
+ such a claim, your patent license ends immediately for work on behalf of your
43
+ company.
44
+
45
+ ## Notices
46
+
47
+ You must ensure that anyone who gets a copy of any part of the software from you
48
+ also gets a copy of these terms.
49
+
50
+ If you modify the software, you must include in any modified copies of the
51
+ software prominent notices stating that you have modified the software.
52
+
53
+ ## No Other Rights
54
+
55
+ These terms do not imply any licenses other than those expressly granted in
56
+ these terms.
57
+
58
+ ## Termination
59
+
60
+ If you use the software in violation of these terms, such use is not licensed,
61
+ and your licenses will automatically terminate. If the licensor provides you
62
+ with a notice of your violation, and you cease all violation of this license no
63
+ later than 30 days after you receive that notice, your licenses will be
64
+ reinstated retroactively. However, if you violate these terms after such
65
+ reinstatement, any additional violation of these terms will cause your licenses
66
+ to terminate automatically and permanently.
67
+
68
+ ## No Liability
69
+
70
+ *As far as the law allows, the software comes as is, without any warranty or
71
+ condition, and the licensor will not be liable to you for any damages arising
72
+ out of these terms or the use or nature of the software, under any kind of
73
+ legal claim.*
74
+
75
+ ## Definitions
76
+
77
+ The **licensor** is the entity offering these terms, and the **software** is the
78
+ software the licensor makes available under these terms, including any portion
79
+ of it.
80
+
81
+ **you** refers to the individual or entity agreeing to these terms.
82
+
83
+ **your company** is any legal entity, sole proprietorship, or other kind of
84
+ organization that you work for, plus all organizations that have control over,
85
+ are under the control of, or are under common control with that
86
+ organization. **control** means ownership of substantially all the assets of an
87
+ entity, or the power to direct its management and policies by vote, contract, or
88
+ otherwise. Control can be direct or indirect.
89
+
90
+ **your licenses** are all the licenses granted to you for the software under
91
+ these terms.
92
+
93
+ **use** means anything you do with the software requiring one of your licenses.
94
+
95
+ **trademark** means trademarks, service marks, and similar rights.
@@ -5,11 +5,9 @@ Real-time transport client for ByteRover. Connects CLI/TUI/REPL clients to the B
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @campfirein/brv-transport-client
8
+ npm install github:campfirein/brv-transport-client#<tag>
9
9
  ```
10
10
 
11
- Requires `.npmrc` configured for GitHub Packages.
12
-
13
11
  ## Quick Start
14
12
 
15
13
  ```typescript
@@ -147,4 +145,5 @@ import {
147
145
 
148
146
  ## License
149
147
 
150
- UNLICENSED - Private package for ByteRover ecosystem
148
+ This project is licensed under the Elastic License 2.0.
149
+ See [LICENSE](./LICENSE)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campfirein/brv-transport-client",
3
- "version": "1.0.1",
3
+ "version": "1.0.0",
4
4
  "description": "Transport client for ByteRover CLI - server discovery, connection, and real-time communication",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -49,5 +49,5 @@
49
49
  "type": "git",
50
50
  "url": "https://github.com/campfirein/brv-transport-client.git"
51
51
  },
52
- "license": "UNLICENSED"
52
+ "license": "Elastic-2.0"
53
53
  }
@@ -1636,5 +1636,5 @@
1636
1636
  ]
1637
1637
  }
1638
1638
  },
1639
- "version": "2.5.1"
1639
+ "version": "2.6.0"
1640
1640
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "byterover-cli",
3
3
  "description": "ByteRover's CLI",
4
- "version": "2.5.1",
4
+ "version": "2.6.0",
5
5
  "author": "ByteRover",
6
6
  "bin": {
7
7
  "brv": "./bin/run.js"
@@ -22,7 +22,7 @@
22
22
  "@ai-sdk/vercel": "^1.0.33",
23
23
  "@ai-sdk/xai": "^2.0.57",
24
24
  "@anthropic-ai/sdk": "^0.70.1",
25
- "@campfirein/brv-transport-client": "github:campfirein/brv-transport-client#release/0.8.4",
25
+ "@campfirein/brv-transport-client": "github:campfirein/brv-transport-client#1.0.0",
26
26
  "@google/genai": "^1.29.0",
27
27
  "@inkjs/ui": "^2.0.0",
28
28
  "@inquirer/prompts": "^7.9.0",
@@ -34,8 +34,9 @@
34
34
  "@socket.io/admin-ui": "^0.5.1",
35
35
  "@tanstack/react-query": "^5.90.20",
36
36
  "ai": "^5.0.129",
37
- "axios": "^1.12.2",
37
+ "axios": "1.14.0",
38
38
  "chalk": "^5.6.2",
39
+ "dotenv": "^17.3.1",
39
40
  "esbuild": "^0.27.2",
40
41
  "express": "^5.1.0",
41
42
  "fullscreen-ink": "^0.1.0",
@@ -110,12 +111,13 @@
110
111
  "node": ">=20.0.0"
111
112
  },
112
113
  "files": [
114
+ "./.env.production",
113
115
  "./bin",
114
116
  "./dist",
115
117
  "./oclif.manifest.json"
116
118
  ],
117
119
  "homepage": "https://www.byterover.dev/",
118
- "license": "UNLICENSED",
120
+ "license": "Elastic-2.0",
119
121
  "main": "dist/index.js",
120
122
  "type": "module",
121
123
  "oclif": {
@@ -1,51 +0,0 @@
1
- /**
2
- * Represents metadata associated with a bullet point
3
- */
4
- export interface BulletMetadata {
5
- relatedFiles: string[];
6
- tags: string[];
7
- timestamp: string;
8
- }
9
- export interface BulletJson {
10
- content?: string;
11
- id: string;
12
- memoryId?: string;
13
- metadata: {
14
- relatedFiles: string[];
15
- tags: string[];
16
- timestamp: string;
17
- };
18
- section: string;
19
- }
20
- /**
21
- * Represents a single knowledge entry in the playbook.
22
- * Bullets contain reusable insights, strategies, or lessons learned.
23
- */
24
- export declare class Bullet {
25
- readonly content: string;
26
- readonly id: string;
27
- readonly memoryId?: string;
28
- readonly metadata: BulletMetadata;
29
- readonly section: string;
30
- constructor(id: string, section: string, content: string, metadata: BulletMetadata, memoryId?: string);
31
- /**
32
- * Creates a Bullet instance from a JSON object.
33
- * The content parameter must be provided separately when content is stored in files.
34
- * @param json The JSON object containing bullet metadata
35
- * @param content Optional content string (required if json.content is undefined)
36
- */
37
- static fromJson(json: BulletJson, content?: string): Bullet;
38
- /**
39
- * Formats the bullet for display in a playbook
40
- */
41
- toDisplayString(): string;
42
- /**
43
- * Converts the bullet to a JSON object
44
- * @param includeContent If false, content field is omitted (for file-based storage)
45
- */
46
- toJson(includeContent?: boolean): BulletJson;
47
- /**
48
- * Creates a new bullet with updated content
49
- */
50
- withUpdatedContent(content: string): Bullet;
51
- }
@@ -1,94 +0,0 @@
1
- /**
2
- * Represents a single knowledge entry in the playbook.
3
- * Bullets contain reusable insights, strategies, or lessons learned.
4
- */
5
- export class Bullet {
6
- content;
7
- id;
8
- memoryId;
9
- metadata;
10
- section;
11
- // eslint-disable-next-line max-params
12
- constructor(id, section, content, metadata, memoryId) {
13
- if (id.trim().length === 0) {
14
- throw new Error('Bullet ID cannot be empty');
15
- }
16
- if (section.trim().length === 0) {
17
- throw new Error('Bullet section cannot be empty');
18
- }
19
- if (content.trim().length === 0) {
20
- throw new Error('Bullet content cannot be empty');
21
- }
22
- if (!metadata.timestamp || metadata.timestamp.trim().length === 0) {
23
- throw new Error('Bullet metadata timestamp cannot be empty');
24
- }
25
- if (!metadata.relatedFiles || !Array.isArray(metadata.relatedFiles)) {
26
- throw new Error('Bullet metadata relatedFiles must be an array');
27
- }
28
- if (!metadata.tags || metadata.tags.length === 0) {
29
- throw new Error('Bullet metadata tags cannot be empty');
30
- }
31
- this.id = id;
32
- this.section = section;
33
- this.content = content;
34
- this.metadata = metadata;
35
- this.memoryId = memoryId;
36
- }
37
- /**
38
- * Creates a Bullet instance from a JSON object.
39
- * The content parameter must be provided separately when content is stored in files.
40
- * @param json The JSON object containing bullet metadata
41
- * @param content Optional content string (required if json.content is undefined)
42
- */
43
- static fromJson(json, content) {
44
- const bulletContent = json.content ?? content;
45
- if (!bulletContent) {
46
- throw new Error(`Bullet content is required for bullet ${json.id}`);
47
- }
48
- return new Bullet(json.id, json.section, bulletContent, {
49
- relatedFiles: json.metadata.relatedFiles,
50
- tags: json.metadata.tags,
51
- timestamp: json.metadata.timestamp,
52
- }, json.memoryId);
53
- }
54
- /**
55
- * Formats the bullet for display in a playbook
56
- */
57
- toDisplayString() {
58
- const tags = this.metadata.tags.join(', ');
59
- const tagDisplay = `[Tags: ${tags}]`;
60
- const filesDisplay = this.metadata.relatedFiles.length > 0 ? `[Files: ${this.metadata.relatedFiles.join(', ')}]` : '[Files: none]';
61
- const timestampDisplay = `[Updated: ${this.metadata.timestamp}]`;
62
- const metadataDisplay = [tagDisplay, filesDisplay, timestampDisplay].join(' ');
63
- return `- [${this.id}] ${this.content}\n ${this.section}\n ${metadataDisplay}`;
64
- }
65
- /**
66
- * Converts the bullet to a JSON object
67
- * @param includeContent If false, content field is omitted (for file-based storage)
68
- */
69
- toJson(includeContent = true) {
70
- const json = {
71
- id: this.id,
72
- memoryId: this.memoryId,
73
- metadata: {
74
- relatedFiles: this.metadata.relatedFiles,
75
- tags: this.metadata.tags,
76
- timestamp: this.metadata.timestamp,
77
- },
78
- section: this.section,
79
- };
80
- if (includeContent) {
81
- json.content = this.content;
82
- }
83
- return json;
84
- }
85
- /**
86
- * Creates a new bullet with updated content
87
- */
88
- withUpdatedContent(content) {
89
- return new Bullet(this.id, this.section, content, {
90
- ...this.metadata,
91
- timestamp: new Date().toISOString(),
92
- }, this.memoryId);
93
- }
94
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * Parameters for creating a Memory instance.
3
- *
4
- * Note: score, parentIds, and childrenIds are optional.
5
- * These fields are present in primary memories (from the `memories` array)
6
- * but absent in related memories (from the `related_memories` array).
7
- */
8
- export type MemoryParams = {
9
- bulletId: string;
10
- childrenIds?: string[];
11
- content: string;
12
- id: string;
13
- metadataType: string;
14
- nodeKeys: string[];
15
- parentIds?: string[];
16
- score?: number;
17
- section: string;
18
- tags: string[];
19
- timestamp: string;
20
- title: string;
21
- };
22
- /**
23
- * Represents a memory retrieved from the ByteRover Memora service.
24
- * Memories are hierarchical knowledge fragments that can have parent and child relationships.
25
- *
26
- * Note: score, parentIds, and childrenIds are optional fields.
27
- * - Primary memories (from API `memories` array) have these fields
28
- * - Related memories (from API `related_memories` array) don't have these fields
29
- */
30
- export declare class Memory {
31
- readonly bulletId: string;
32
- readonly childrenIds?: readonly string[];
33
- readonly content: string;
34
- readonly id: string;
35
- readonly metadataType: string;
36
- readonly nodeKeys: readonly string[];
37
- readonly parentIds?: readonly string[];
38
- readonly score?: number;
39
- readonly section: string;
40
- readonly tags: readonly string[];
41
- readonly timestamp: string;
42
- readonly title: string;
43
- constructor(params: MemoryParams);
44
- /**
45
- * Creates a Memory instance from a JSON object.
46
- * @param json JSON object representing the Memory
47
- * @returns An instance of Memory
48
- */
49
- static fromJson(json: MemoryParams): Memory;
50
- /**
51
- * Converts the Memory instance to a JSON object.
52
- * @returns A JSON object representing the Memory
53
- */
54
- toJson(): MemoryParams;
55
- }