byterover-cli 3.1.0 → 3.3.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 +17 -0
- package/dist/agent/infra/agent/agent-schemas.d.ts +8 -0
- package/dist/agent/infra/agent/agent-schemas.js +1 -0
- package/dist/agent/infra/sandbox/curate-service.js +14 -0
- package/dist/agent/infra/sandbox/sandbox-service.js +1 -0
- package/dist/agent/infra/sandbox/tools-sdk.d.ts +10 -0
- package/dist/agent/infra/sandbox/tools-sdk.js +9 -1
- package/dist/agent/infra/tools/implementations/search-knowledge-service.js +226 -103
- package/dist/agent/infra/tools/implementations/write-file-tool.d.ts +2 -1
- package/dist/agent/infra/tools/implementations/write-file-tool.js +16 -2
- package/dist/agent/infra/tools/tool-registry.js +1 -1
- package/dist/agent/infra/tools/write-guard.d.ts +11 -0
- package/dist/agent/infra/tools/write-guard.js +48 -0
- package/dist/agent/resources/prompts/system-prompt.yml +9 -0
- package/dist/agent/resources/tools/expand_knowledge.txt +4 -0
- package/dist/agent/resources/tools/search_knowledge.txt +11 -1
- package/dist/oclif/commands/curate/index.d.ts +1 -0
- package/dist/oclif/commands/curate/index.js +19 -4
- package/dist/oclif/commands/curate/view.js +2 -2
- package/dist/oclif/commands/main.js +13 -0
- package/dist/oclif/commands/query.d.ts +1 -0
- package/dist/oclif/commands/query.js +19 -4
- package/dist/oclif/commands/search.d.ts +20 -0
- package/dist/oclif/commands/search.js +186 -0
- package/dist/oclif/commands/source/add.d.ts +12 -0
- package/dist/oclif/commands/source/add.js +42 -0
- package/dist/oclif/commands/source/index.d.ts +6 -0
- package/dist/oclif/commands/source/index.js +8 -0
- package/dist/oclif/commands/source/list.d.ts +6 -0
- package/dist/oclif/commands/source/list.js +32 -0
- package/dist/oclif/commands/source/remove.d.ts +9 -0
- package/dist/oclif/commands/source/remove.js +33 -0
- package/dist/oclif/commands/status.d.ts +5 -1
- package/dist/oclif/commands/status.js +45 -6
- package/dist/oclif/commands/worktree/add.d.ts +12 -0
- package/dist/oclif/commands/worktree/add.js +44 -0
- package/dist/oclif/commands/worktree/index.d.ts +6 -0
- package/dist/oclif/commands/worktree/index.js +8 -0
- package/dist/oclif/commands/worktree/list.d.ts +6 -0
- package/dist/oclif/commands/worktree/list.js +28 -0
- package/dist/oclif/commands/worktree/remove.d.ts +9 -0
- package/dist/oclif/commands/worktree/remove.js +35 -0
- package/dist/oclif/hooks/init/validate-brv-config.js +4 -0
- package/dist/oclif/lib/daemon-client.d.ts +4 -2
- package/dist/oclif/lib/daemon-client.js +19 -4
- package/dist/oclif/lib/search-format.d.ts +10 -0
- package/dist/oclif/lib/search-format.js +25 -0
- package/dist/oclif/lib/task-client.d.ts +6 -0
- package/dist/oclif/lib/task-client.js +10 -3
- package/dist/server/constants.d.ts +7 -1
- package/dist/server/constants.js +10 -0
- package/dist/server/core/domain/client/client-info.d.ts +7 -0
- package/dist/server/core/domain/client/client-info.js +11 -0
- package/dist/server/core/domain/errors/task-error.d.ts +2 -2
- package/dist/server/core/domain/errors/task-error.js +5 -4
- package/dist/server/core/domain/project/worktrees-schema.d.ts +29 -0
- package/dist/server/core/domain/project/worktrees-schema.js +17 -0
- package/dist/server/core/domain/source/source-operations.d.ts +31 -0
- package/dist/server/core/domain/source/source-operations.js +201 -0
- package/dist/server/core/domain/source/source-schema.d.ts +94 -0
- package/dist/server/core/domain/source/source-schema.js +121 -0
- package/dist/server/core/domain/transport/schemas.d.ts +18 -10
- package/dist/server/core/domain/transport/schemas.js +7 -3
- package/dist/server/core/domain/transport/task-info.d.ts +2 -0
- package/dist/server/core/interfaces/client/i-client-manager.d.ts +13 -0
- package/dist/server/core/interfaces/executor/i-curate-executor.d.ts +4 -0
- package/dist/server/core/interfaces/executor/i-folder-pack-executor.d.ts +7 -3
- package/dist/server/core/interfaces/executor/i-query-executor.d.ts +2 -0
- package/dist/server/core/interfaces/executor/i-search-executor.d.ts +34 -0
- package/dist/server/core/interfaces/executor/i-search-executor.js +1 -0
- package/dist/server/core/interfaces/executor/index.d.ts +1 -0
- package/dist/server/core/interfaces/executor/index.js +1 -0
- package/dist/server/infra/client/client-manager.d.ts +1 -0
- package/dist/server/infra/client/client-manager.js +16 -0
- package/dist/server/infra/daemon/agent-process.js +35 -12
- package/dist/server/infra/executor/curate-executor.js +4 -2
- package/dist/server/infra/executor/direct-search-responder.js +5 -1
- package/dist/server/infra/executor/folder-pack-executor.js +23 -12
- package/dist/server/infra/executor/query-executor.d.ts +23 -0
- package/dist/server/infra/executor/query-executor.js +115 -21
- package/dist/server/infra/executor/search-executor.d.ts +17 -0
- package/dist/server/infra/executor/search-executor.js +30 -0
- package/dist/server/infra/mcp/mcp-mode-detector.d.ts +7 -5
- package/dist/server/infra/mcp/mcp-mode-detector.js +11 -18
- package/dist/server/infra/mcp/mcp-server.d.ts +1 -0
- package/dist/server/infra/mcp/mcp-server.js +11 -6
- package/dist/server/infra/mcp/tools/brv-curate-tool.d.ts +2 -1
- package/dist/server/infra/mcp/tools/brv-curate-tool.js +9 -16
- package/dist/server/infra/mcp/tools/brv-query-tool.d.ts +2 -1
- package/dist/server/infra/mcp/tools/brv-query-tool.js +9 -16
- package/dist/server/infra/mcp/tools/mcp-project-context.d.ts +11 -0
- package/dist/server/infra/mcp/tools/mcp-project-context.js +54 -0
- package/dist/server/infra/process/connection-coordinator.js +11 -0
- package/dist/server/infra/process/feature-handlers.js +4 -1
- package/dist/server/infra/process/task-router.d.ts +1 -0
- package/dist/server/infra/process/task-router.js +60 -5
- package/dist/server/infra/project/resolve-project.d.ts +106 -0
- package/dist/server/infra/project/resolve-project.js +473 -0
- package/dist/server/infra/transport/handlers/index.d.ts +4 -0
- package/dist/server/infra/transport/handlers/index.js +2 -0
- package/dist/server/infra/transport/handlers/pull-handler.js +3 -3
- package/dist/server/infra/transport/handlers/push-handler.js +3 -3
- package/dist/server/infra/transport/handlers/source-handler.d.ts +12 -0
- package/dist/server/infra/transport/handlers/source-handler.js +37 -0
- package/dist/server/infra/transport/handlers/status-handler.js +76 -27
- package/dist/server/infra/transport/handlers/worktree-handler.d.ts +12 -0
- package/dist/server/infra/transport/handlers/worktree-handler.js +67 -0
- package/dist/server/infra/transport/transport-connector.d.ts +10 -4
- package/dist/server/infra/transport/transport-connector.js +2 -2
- package/dist/server/templates/skill/SKILL.md +25 -5
- package/dist/server/utils/path-utils.d.ts +5 -0
- package/dist/server/utils/path-utils.js +11 -1
- package/dist/shared/transport/events/client-events.d.ts +3 -0
- package/dist/shared/transport/events/client-events.js +3 -0
- package/dist/shared/transport/events/index.d.ts +13 -0
- package/dist/shared/transport/events/index.js +9 -0
- package/dist/shared/transport/events/source-events.d.ts +30 -0
- package/dist/shared/transport/events/source-events.js +5 -0
- package/dist/shared/transport/events/status-events.d.ts +5 -0
- package/dist/shared/transport/events/task-events.d.ts +4 -1
- package/dist/shared/transport/events/worktree-events.d.ts +31 -0
- package/dist/shared/transport/events/worktree-events.js +5 -0
- package/dist/shared/transport/search-content.d.ts +28 -0
- package/dist/shared/transport/search-content.js +38 -0
- package/dist/shared/transport/types/dto.d.ts +20 -1
- package/dist/tui/features/commands/definitions/index.js +6 -0
- package/dist/tui/features/commands/definitions/source-add.d.ts +2 -0
- package/dist/tui/features/commands/definitions/source-add.js +48 -0
- package/dist/tui/features/commands/definitions/source-list.d.ts +2 -0
- package/dist/tui/features/commands/definitions/source-list.js +47 -0
- package/dist/tui/features/commands/definitions/source-remove.d.ts +2 -0
- package/dist/tui/features/commands/definitions/source-remove.js +38 -0
- package/dist/tui/features/commands/definitions/source.d.ts +2 -0
- package/dist/tui/features/commands/definitions/source.js +8 -0
- package/dist/tui/features/commands/definitions/worktree-add.d.ts +2 -0
- package/dist/tui/features/commands/definitions/worktree-add.js +35 -0
- package/dist/tui/features/commands/definitions/worktree-list.d.ts +2 -0
- package/dist/tui/features/commands/definitions/worktree-list.js +36 -0
- package/dist/tui/features/commands/definitions/worktree-remove.d.ts +2 -0
- package/dist/tui/features/commands/definitions/worktree-remove.js +33 -0
- package/dist/tui/features/commands/definitions/worktree.d.ts +2 -0
- package/dist/tui/features/commands/definitions/worktree.js +8 -0
- package/dist/tui/features/curate/api/create-curate-task.js +3 -1
- package/dist/tui/features/query/api/create-query-task.js +3 -1
- package/dist/tui/features/source/api/source-api.d.ts +4 -0
- package/dist/tui/features/source/api/source-api.js +22 -0
- package/dist/tui/features/status/api/get-status.js +2 -1
- package/dist/tui/features/status/utils/format-status.js +28 -1
- package/dist/tui/features/transport/components/transport-initializer.js +36 -1
- package/dist/tui/features/worktree/api/worktree-api.d.ts +4 -0
- package/dist/tui/features/worktree/api/worktree-api.js +22 -0
- package/dist/tui/repl-startup.d.ts +2 -0
- package/dist/tui/repl-startup.js +5 -3
- package/dist/tui/stores/transport-store.d.ts +6 -0
- package/dist/tui/stores/transport-store.js +6 -0
- package/dist/tui/utils/error-messages.js +2 -2
- package/oclif.manifest.json +380 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -241,6 +241,23 @@ ByteRover CLI supports 18 LLM providers out of the box. Use `brv providers conne
|
|
|
241
241
|
|
|
242
242
|
</details>
|
|
243
243
|
|
|
244
|
+
## Worktrees and Knowledge Sources
|
|
245
|
+
|
|
246
|
+
> **Vocabulary**
|
|
247
|
+
> - **Worktree link** — a subdirectory pointer to a parent project (`brv worktree`)
|
|
248
|
+
> - **Source** — a read-only reference to another project's knowledge (`brv source`)
|
|
249
|
+
> - **Origin** — where an indexed search result came from (`local` vs `shared`)
|
|
250
|
+
|
|
251
|
+
ByteRover can run from a linked subdirectory without creating a nested `.brv/`.
|
|
252
|
+
|
|
253
|
+
- `projectRoot`: the directory that owns `.brv/config.json`
|
|
254
|
+
- `worktreeRoot`: the linked worktree directory, or `projectRoot` when unlinked
|
|
255
|
+
- `clientCwd`: the shell cwd where you ran `brv`
|
|
256
|
+
|
|
257
|
+
When you run `brv query` or `brv curate` from a linked worktree, implicit defaults use `worktreeRoot` so scope stays stable even if `clientCwd` drifts deeper into the package. Explicit relative paths that you pass yourself, such as `brv curate -f ./src/auth.ts`, still resolve from `clientCwd` to match normal shell behavior.
|
|
258
|
+
|
|
259
|
+
Use `brv worktree add` from the project root to register a subdirectory (or sibling) as a worktree. This creates a `.brv` pointer file in the target directory that redirects to the parent project — the same pattern git uses for `git worktree`. Use `brv worktree remove` to unregister, and `brv worktree list` to inspect. To search another project's knowledge from here, use `brv source add <path>` (with `brv source list` / `brv source remove` to inspect or detach).
|
|
260
|
+
|
|
244
261
|
## Documentation
|
|
245
262
|
|
|
246
263
|
Visit [**docs.byterover.dev**](https://docs.byterover.dev) for full guides on setup, integrations, and advanced usage.
|
|
@@ -46,13 +46,16 @@ export type ValidatedSessionConfig = z.output<typeof SessionConfigSchema>;
|
|
|
46
46
|
*/
|
|
47
47
|
export declare const FileSystemConfigSchema: z.ZodObject<{
|
|
48
48
|
allowedExtensions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
49
|
+
allowedPaths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
49
50
|
maxFileSize: z.ZodOptional<z.ZodNumber>;
|
|
50
51
|
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
51
52
|
}, "strict", z.ZodTypeAny, {
|
|
53
|
+
allowedPaths?: string[] | undefined;
|
|
52
54
|
allowedExtensions?: string[] | undefined;
|
|
53
55
|
workingDirectory?: string | undefined;
|
|
54
56
|
maxFileSize?: number | undefined;
|
|
55
57
|
}, {
|
|
58
|
+
allowedPaths?: string[] | undefined;
|
|
56
59
|
allowedExtensions?: string[] | undefined;
|
|
57
60
|
workingDirectory?: string | undefined;
|
|
58
61
|
maxFileSize?: number | undefined;
|
|
@@ -101,13 +104,16 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
101
104
|
}>>;
|
|
102
105
|
fileSystem: z.ZodOptional<z.ZodObject<{
|
|
103
106
|
allowedExtensions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
107
|
+
allowedPaths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
104
108
|
maxFileSize: z.ZodOptional<z.ZodNumber>;
|
|
105
109
|
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
106
110
|
}, "strict", z.ZodTypeAny, {
|
|
111
|
+
allowedPaths?: string[] | undefined;
|
|
107
112
|
allowedExtensions?: string[] | undefined;
|
|
108
113
|
workingDirectory?: string | undefined;
|
|
109
114
|
maxFileSize?: number | undefined;
|
|
110
115
|
}, {
|
|
116
|
+
allowedPaths?: string[] | undefined;
|
|
111
117
|
allowedExtensions?: string[] | undefined;
|
|
112
118
|
workingDirectory?: string | undefined;
|
|
113
119
|
maxFileSize?: number | undefined;
|
|
@@ -185,6 +191,7 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
185
191
|
storageDir: string;
|
|
186
192
|
} | undefined;
|
|
187
193
|
fileSystem?: {
|
|
194
|
+
allowedPaths?: string[] | undefined;
|
|
188
195
|
allowedExtensions?: string[] | undefined;
|
|
189
196
|
workingDirectory?: string | undefined;
|
|
190
197
|
maxFileSize?: number | undefined;
|
|
@@ -223,6 +230,7 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
223
230
|
maxBlobSize?: number | undefined;
|
|
224
231
|
} | undefined;
|
|
225
232
|
fileSystem?: {
|
|
233
|
+
allowedPaths?: string[] | undefined;
|
|
226
234
|
allowedExtensions?: string[] | undefined;
|
|
227
235
|
workingDirectory?: string | undefined;
|
|
228
236
|
maxFileSize?: number | undefined;
|
|
@@ -27,6 +27,7 @@ export const SessionConfigSchema = z
|
|
|
27
27
|
export const FileSystemConfigSchema = z
|
|
28
28
|
.object({
|
|
29
29
|
allowedExtensions: z.array(z.string()).optional().describe('Allowed file extensions'),
|
|
30
|
+
allowedPaths: z.array(z.string()).optional().describe('Allowed paths for file operations (default: ["."])'),
|
|
30
31
|
maxFileSize: z.number().positive().optional().describe('Maximum file size in bytes'),
|
|
31
32
|
workingDirectory: z.string().optional().describe('Working directory for file operations'),
|
|
32
33
|
})
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { resolve } from 'node:path';
|
|
6
6
|
import { executeCurate } from '../tools/implementations/curate-tool.js';
|
|
7
|
+
import { validateWriteTarget } from '../tools/write-guard.js';
|
|
7
8
|
/**
|
|
8
9
|
* Default base path for knowledge storage.
|
|
9
10
|
*/
|
|
@@ -90,6 +91,19 @@ export class CurateService {
|
|
|
90
91
|
// Resolve relative basePath against the working directory to ensure
|
|
91
92
|
// files are written to the correct project directory, not process.cwd()
|
|
92
93
|
const basePath = resolve(this.workingDirectory, rawBasePath);
|
|
94
|
+
// Source write guard: block curate to shared source context trees
|
|
95
|
+
const writeError = validateWriteTarget(basePath, this.workingDirectory);
|
|
96
|
+
if (writeError) {
|
|
97
|
+
return {
|
|
98
|
+
applied: [{
|
|
99
|
+
message: writeError,
|
|
100
|
+
path: rawBasePath,
|
|
101
|
+
status: 'failed',
|
|
102
|
+
type: 'ADD',
|
|
103
|
+
}],
|
|
104
|
+
summary: { added: 0, deleted: 0, failed: 1, merged: 0, updated: 0 },
|
|
105
|
+
};
|
|
106
|
+
}
|
|
93
107
|
// Pre-validate operations to catch common mistakes early
|
|
94
108
|
const validationFailures = validateOperations(operations);
|
|
95
109
|
if (validationFailures.length > 0) {
|
|
@@ -215,6 +215,7 @@ export class SandboxService {
|
|
|
215
215
|
curateService: this.curateService,
|
|
216
216
|
fileSystem: this.fileSystem,
|
|
217
217
|
parentSessionId: sessionId,
|
|
218
|
+
projectRoot: this.environmentContext?.workingDirectory,
|
|
218
219
|
sandboxService: this,
|
|
219
220
|
searchKnowledgeService: this.searchKnowledgeService,
|
|
220
221
|
sessionManager: this.sessionManager,
|
|
@@ -62,6 +62,8 @@ export interface ListDirectoryOptions {
|
|
|
62
62
|
export interface SearchKnowledgeOptions {
|
|
63
63
|
/** Maximum number of results to return (default: 10) */
|
|
64
64
|
limit?: number;
|
|
65
|
+
/** Path prefix to scope search within (e.g. "auth" or "packages/api") */
|
|
66
|
+
scope?: string;
|
|
65
67
|
}
|
|
66
68
|
/**
|
|
67
69
|
* Result type for searchKnowledge operation.
|
|
@@ -74,6 +76,12 @@ export interface SearchKnowledgeResult {
|
|
|
74
76
|
/** Number of other memories that reference this one */
|
|
75
77
|
backlinkCount?: number;
|
|
76
78
|
excerpt: string;
|
|
79
|
+
/** Origin: 'local' for this project, 'shared' for results from knowledge source */
|
|
80
|
+
origin?: 'local' | 'shared';
|
|
81
|
+
/** Alias of the shared source (undefined for local results) */
|
|
82
|
+
originAlias?: string;
|
|
83
|
+
/** Absolute path to the context tree root this result belongs to. Use join(originContextTreeRoot, path) to read. */
|
|
84
|
+
originContextTreeRoot?: string;
|
|
77
85
|
/** Path to .overview.md for this entry; present when L1 overview exists */
|
|
78
86
|
overviewPath?: string;
|
|
79
87
|
path: string;
|
|
@@ -225,6 +233,8 @@ export interface CreateToolsSDKOptions {
|
|
|
225
233
|
fileSystem: IFileSystem;
|
|
226
234
|
/** Parent session ID for creating child sessions (required for agentQuery) */
|
|
227
235
|
parentSessionId?: string;
|
|
236
|
+
/** Project root for write guard validation (blocks writes to shared source context trees) */
|
|
237
|
+
projectRoot?: string;
|
|
228
238
|
/** Sandbox service for variable injection into child sessions (optional, enables contextData in agentQuery) */
|
|
229
239
|
sandboxService?: ISandboxService;
|
|
230
240
|
/** Search knowledge service */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContextTreeStore } from '../map/context-tree-store.js';
|
|
2
2
|
import { executeLlmMapMemory } from '../map/llm-map-memory.js';
|
|
3
|
+
import { validateWriteTarget } from '../tools/write-guard.js';
|
|
3
4
|
import { chunk, dedup, detectMessageBoundaries, groupBySubject, recon, recordProgress, } from './curation-helpers.js';
|
|
4
5
|
/**
|
|
5
6
|
* Creates a Tools SDK instance for sandbox code execution.
|
|
@@ -11,7 +12,7 @@ import { chunk, dedup, detectMessageBoundaries, groupBySubject, recon, recordPro
|
|
|
11
12
|
* @returns ToolsSDK instance ready to be injected into sandbox context
|
|
12
13
|
*/
|
|
13
14
|
export function createToolsSDK(options) {
|
|
14
|
-
const { commandType, contentGenerator, curateService, fileSystem, parentSessionId, sandboxService, searchKnowledgeService, sessionManager } = options;
|
|
15
|
+
const { commandType, contentGenerator, curateService, fileSystem, parentSessionId, projectRoot, sandboxService, searchKnowledgeService, sessionManager } = options;
|
|
15
16
|
const isReadOnly = commandType === 'query';
|
|
16
17
|
return {
|
|
17
18
|
async agentQuery(prompt, options) {
|
|
@@ -156,6 +157,13 @@ export function createToolsSDK(options) {
|
|
|
156
157
|
if (isReadOnly) {
|
|
157
158
|
throw new Error('writeFile() is disabled in read-only (query) mode');
|
|
158
159
|
}
|
|
160
|
+
// Write guard: block writes to shared source context trees
|
|
161
|
+
if (projectRoot) {
|
|
162
|
+
const writeError = validateWriteTarget(filePath, projectRoot);
|
|
163
|
+
if (writeError) {
|
|
164
|
+
throw new Error(writeError);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
159
167
|
return fileSystem.writeFile(filePath, content, {
|
|
160
168
|
createDirs: options?.createDirs ?? false,
|
|
161
169
|
});
|