byterover-cli 1.7.2 → 1.8.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 (66) hide show
  1. package/README.md +17 -3
  2. package/dist/agent/core/domain/tools/constants.d.ts +0 -15
  3. package/dist/agent/core/domain/tools/constants.js +0 -15
  4. package/dist/agent/core/interfaces/i-cipher-agent.d.ts +6 -0
  5. package/dist/agent/core/interfaces/i-curate-service.d.ts +12 -0
  6. package/dist/agent/infra/llm/internal-llm-service.d.ts +13 -0
  7. package/dist/agent/infra/llm/internal-llm-service.js +61 -21
  8. package/dist/agent/infra/tools/implementations/curate-tool.d.ts +133 -0
  9. package/dist/agent/infra/tools/implementations/curate-tool.js +14 -0
  10. package/dist/agent/infra/tools/implementations/search-knowledge-service.js +91 -14
  11. package/dist/agent/infra/tools/index.d.ts +0 -4
  12. package/dist/agent/infra/tools/index.js +0 -4
  13. package/dist/agent/infra/tools/tool-registry.js +0 -113
  14. package/dist/agent/resources/prompts/curate-detail-preservation.yml +73 -0
  15. package/dist/agent/resources/prompts/system-prompt.yml +69 -3
  16. package/dist/server/core/domain/knowledge/markdown-writer.d.ts +13 -0
  17. package/dist/server/core/domain/knowledge/markdown-writer.js +116 -8
  18. package/dist/server/infra/executor/curate-executor.js +1 -1
  19. package/dist/server/infra/executor/direct-search-responder.d.ts +45 -0
  20. package/dist/server/infra/executor/direct-search-responder.js +86 -0
  21. package/dist/server/infra/executor/folder-pack-executor.d.ts +13 -5
  22. package/dist/server/infra/executor/folder-pack-executor.js +739 -39
  23. package/dist/server/infra/executor/query-executor.d.ts +49 -3
  24. package/dist/server/infra/executor/query-executor.js +194 -9
  25. package/dist/server/infra/executor/query-result-cache.d.ts +87 -0
  26. package/dist/server/infra/executor/query-result-cache.js +127 -0
  27. package/dist/server/infra/executor/query-similarity.d.ts +28 -0
  28. package/dist/server/infra/executor/query-similarity.js +41 -0
  29. package/dist/server/infra/process/agent-worker.js +9 -2
  30. package/dist/server/infra/process/inline-agent-executor.js +16 -5
  31. package/dist/server/infra/usecase/curate-use-case.js +6 -1
  32. package/dist/server/infra/usecase/query-use-case.js +10 -0
  33. package/dist/server/utils/file-validator.js +78 -1
  34. package/dist/tui/hooks/use-slash-completion.js +25 -4
  35. package/oclif.manifest.json +1 -1
  36. package/package.json +1 -1
  37. package/dist/agent/infra/tools/implementations/bash-exec-tool.d.ts +0 -13
  38. package/dist/agent/infra/tools/implementations/bash-exec-tool.js +0 -110
  39. package/dist/agent/infra/tools/implementations/bash-output-tool.d.ts +0 -12
  40. package/dist/agent/infra/tools/implementations/bash-output-tool.js +0 -43
  41. package/dist/agent/infra/tools/implementations/batch-tool.d.ts +0 -12
  42. package/dist/agent/infra/tools/implementations/batch-tool.js +0 -142
  43. package/dist/agent/infra/tools/implementations/create-knowledge-topic-tool.d.ts +0 -11
  44. package/dist/agent/infra/tools/implementations/create-knowledge-topic-tool.js +0 -149
  45. package/dist/agent/infra/tools/implementations/delete-memory-tool.d.ts +0 -12
  46. package/dist/agent/infra/tools/implementations/delete-memory-tool.js +0 -37
  47. package/dist/agent/infra/tools/implementations/edit-file-tool.d.ts +0 -13
  48. package/dist/agent/infra/tools/implementations/edit-file-tool.js +0 -50
  49. package/dist/agent/infra/tools/implementations/edit-memory-tool.d.ts +0 -13
  50. package/dist/agent/infra/tools/implementations/edit-memory-tool.js +0 -53
  51. package/dist/agent/infra/tools/implementations/kill-process-tool.d.ts +0 -12
  52. package/dist/agent/infra/tools/implementations/kill-process-tool.js +0 -55
  53. package/dist/agent/infra/tools/implementations/list-memories-tool.d.ts +0 -12
  54. package/dist/agent/infra/tools/implementations/list-memories-tool.js +0 -63
  55. package/dist/agent/infra/tools/implementations/read-memory-tool.d.ts +0 -12
  56. package/dist/agent/infra/tools/implementations/read-memory-tool.js +0 -39
  57. package/dist/agent/infra/tools/implementations/read-todos-tool.d.ts +0 -11
  58. package/dist/agent/infra/tools/implementations/read-todos-tool.js +0 -39
  59. package/dist/agent/infra/tools/implementations/search-history-tool.d.ts +0 -10
  60. package/dist/agent/infra/tools/implementations/search-history-tool.js +0 -36
  61. package/dist/agent/infra/tools/implementations/spec-analyze-tool.d.ts +0 -7
  62. package/dist/agent/infra/tools/implementations/spec-analyze-tool.js +0 -78
  63. package/dist/agent/infra/tools/implementations/write-memory-tool.d.ts +0 -13
  64. package/dist/agent/infra/tools/implementations/write-memory-tool.js +0 -52
  65. package/dist/agent/infra/tools/implementations/write-todos-tool.d.ts +0 -13
  66. package/dist/agent/infra/tools/implementations/write-todos-tool.js +0 -121
package/README.md CHANGED
@@ -126,7 +126,8 @@ The terminal UI includes:
126
126
  - **Streaming Output**: Live responses with markdown rendering (headings, lists, blockquotes, code blocks)
127
127
  - **Reasoning Display**: View agent thinking process with streamed reasoning blocks
128
128
  - **File & Folder References**: Type `@` in curate mode to browse and attach files or entire folders
129
- - **PDF Support**: Reference and extract text from PDF files using `@` (100 pages default, 200 max)
129
+ - **PDF & Office Support**: Reference and extract text from PDF, Word (.docx), Excel (.xlsx), and PowerPoint (.pptx) files using `@` (PDF: 100 pages default, 200 max)
130
+ - **Structured Content Preservation**: Curated context retains diagrams (Mermaid, PlantUML, ASCII art), tables, procedures, and code examples in full fidelity
130
131
  - **Dynamic Domains**: Automatically creates new knowledge domains as your context tree grows
131
132
  - **Session Persistence**: Sessions auto-resume after restart
132
133
  - **Expandable Views**: Press `Ctrl+O` to expand messages or logs to full-screen with vim-style navigation
@@ -140,7 +141,7 @@ The terminal UI includes:
140
141
  | `Ctrl+O` | Expand message or log to full-screen |
141
142
  | `j` / `k` | Scroll down/up in expanded view |
142
143
  | `g` / `G` | Jump to top/bottom in expanded view |
143
- | `Esc` | Cancel streaming responses / exit expanded view |
144
+ | `Esc` | Cancel streaming responses and long-running commands / exit expanded view |
144
145
  | `q` | Exit expanded view |
145
146
  | `/` | Show command suggestions |
146
147
  | `@` | Browse files and folders (in curate mode) |
@@ -194,10 +195,18 @@ Get your API key at [app.byterover.dev/settings/keys](https://app.byterover.dev/
194
195
  - `--format <text|json>`: Output format (default: text)
195
196
 
196
197
  **Curate flags:**
197
- - `-f, --files <path>`: Include specific files or folders (max 5, can be repeated)
198
+ - `-f, --files <path>`: Include specific files (max 5, can be repeated)
199
+ - `-d, --folder <path>`: Folder path to pack and analyze (can be repeated)
198
200
  - `--headless`: Run in headless mode
199
201
  - `--format <text|json>`: Output format (default: text)
200
202
 
203
+ **Curate examples:**
204
+ ```bash
205
+ brv curate "Auth uses JWT with 24h expiry" -f src/middleware/auth.ts
206
+ brv curate --folder src/auth/
207
+ brv curate "Analyze auth module" -d src/auth/
208
+ ```
209
+
201
210
  ### Cloud Sync
202
211
 
203
212
  | Command | Description |
@@ -283,6 +292,11 @@ The context tree organizes knowledge into:
283
292
  - **Topics**: Specific subjects within domains (e.g., Authentication, Components)
284
293
  - **Context Files**: Markdown files containing your actual knowledge
285
294
 
295
+ ### Query Intelligence
296
+
297
+ - **Tiered responses**: Queries are answered via a 4-tier system—cached results return instantly, high-confidence matches skip the LLM entirely, and complex queries use an optimized agentic loop
298
+ - **Out-of-domain detection**: When a topic isn't covered in your context tree, ByteRover tells you clearly instead of guessing, and suggests using `/curate` to add the missing knowledge
299
+
286
300
  ## Supported AI Agents
287
301
 
288
302
  ByteRover integrates with 19 AI coding agents:
@@ -3,29 +3,14 @@
3
3
  * These constants ensure type safety and prevent typos.
4
4
  */
5
5
  export declare const ToolName: {
6
- readonly BASH_EXEC: 'bash_exec';
7
- readonly BASH_OUTPUT: 'bash_output';
8
- readonly BATCH: 'batch';
9
6
  readonly CODE_EXEC: 'code_exec';
10
- readonly CREATE_KNOWLEDGE_TOPIC: 'create_knowledge_topic';
11
7
  readonly CURATE: 'curate';
12
- readonly DELETE_MEMORY: 'delete_memory';
13
- readonly EDIT_FILE: 'edit_file';
14
- readonly EDIT_MEMORY: 'edit_memory';
15
8
  readonly GLOB_FILES: 'glob_files';
16
9
  readonly GREP_CONTENT: 'grep_content';
17
- readonly KILL_PROCESS: 'kill_process';
18
10
  readonly LIST_DIRECTORY: 'list_directory';
19
- readonly LIST_MEMORIES: 'list_memories';
20
11
  readonly READ_FILE: 'read_file';
21
- readonly READ_MEMORY: 'read_memory';
22
- readonly READ_TODOS: 'read_todos';
23
- readonly SEARCH_HISTORY: 'search_history';
24
12
  readonly SEARCH_KNOWLEDGE: 'search_knowledge';
25
- readonly SPEC_ANALYZE: 'spec_analyze';
26
13
  readonly WRITE_FILE: 'write_file';
27
- readonly WRITE_MEMORY: 'write_memory';
28
- readonly WRITE_TODOS: 'write_todos';
29
14
  };
30
15
  /**
31
16
  * Union type of all known tool names.
@@ -3,27 +3,12 @@
3
3
  * These constants ensure type safety and prevent typos.
4
4
  */
5
5
  export const ToolName = {
6
- BASH_EXEC: 'bash_exec',
7
- BASH_OUTPUT: 'bash_output',
8
- BATCH: 'batch',
9
6
  CODE_EXEC: 'code_exec',
10
- CREATE_KNOWLEDGE_TOPIC: 'create_knowledge_topic',
11
7
  CURATE: 'curate',
12
- DELETE_MEMORY: 'delete_memory',
13
- EDIT_FILE: 'edit_file',
14
- EDIT_MEMORY: 'edit_memory',
15
8
  GLOB_FILES: 'glob_files',
16
9
  GREP_CONTENT: 'grep_content',
17
- KILL_PROCESS: 'kill_process',
18
10
  LIST_DIRECTORY: 'list_directory',
19
- LIST_MEMORIES: 'list_memories',
20
11
  READ_FILE: 'read_file',
21
- READ_MEMORY: 'read_memory',
22
- READ_TODOS: 'read_todos',
23
- SEARCH_HISTORY: 'search_history',
24
12
  SEARCH_KNOWLEDGE: 'search_knowledge',
25
- SPEC_ANALYZE: 'spec_analyze',
26
13
  WRITE_FILE: 'write_file',
27
- WRITE_MEMORY: 'write_memory',
28
- WRITE_TODOS: 'write_todos',
29
14
  };
@@ -15,6 +15,12 @@ export interface ExecutionContext {
15
15
  fileReferenceInstructions?: string;
16
16
  /** Whether running in JSON input mode (headless with conversation history) */
17
17
  isJsonInputMode?: boolean;
18
+ /** Override maxIterations for this execution (e.g., 2 for queries with pre-fetched context) */
19
+ maxIterations?: number;
20
+ /** Override maxTokens for this execution (e.g., 1024 for queries) */
21
+ maxTokens?: number;
22
+ /** Override temperature for this execution (e.g., 0.3 for factual queries) */
23
+ temperature?: number;
18
24
  }
19
25
  /**
20
26
  * Agent execution state (string union for external consumers).
@@ -6,12 +6,20 @@
6
6
  * Raw concept metadata for a knowledge topic.
7
7
  */
8
8
  export interface CurateRawConcept {
9
+ /** Author or source attribution */
10
+ author?: string;
9
11
  /** What changes in the codebase are induced by this concept */
10
12
  changes?: string[];
11
13
  /** Which files are related to this concept */
12
14
  files?: string[];
13
15
  /** What is the flow included in this concept */
14
16
  flow?: string;
17
+ /** Regex or validation patterns with descriptions */
18
+ patterns?: Array<{
19
+ description: string;
20
+ flags?: string;
21
+ pattern: string;
22
+ }>;
15
23
  /** What is the task related to this concept */
16
24
  task?: string;
17
25
  /** When the concept was created or modified (ISO 8601 format) */
@@ -23,8 +31,12 @@ export interface CurateRawConcept {
23
31
  export interface CurateNarrative {
24
32
  /** Dependency management information */
25
33
  dependencies?: string;
34
+ /** Examples and use cases */
35
+ examples?: string;
26
36
  /** Feature documentation for this concept */
27
37
  features?: string;
38
+ /** Exact rules, constraints, or guidelines - preserved verbatim */
39
+ rules?: string;
28
40
  /** Code structure documentation */
29
41
  structure?: string;
30
42
  }
@@ -62,6 +62,8 @@ export interface LLMServiceConfig {
62
62
  * - Handle retry logic (handled by RetryableContentGenerator decorator)
63
63
  */
64
64
  export declare class ByteRoverLLMService implements ILLMService {
65
+ /** Cached base system prompt (everything built by SystemPromptManager) for reuse across iterations */
66
+ private cachedBasePrompt;
65
67
  private readonly compactionService?;
66
68
  private readonly config;
67
69
  private readonly contextManager;
@@ -70,6 +72,8 @@ export declare class ByteRoverLLMService implements ILLMService {
70
72
  private readonly generator;
71
73
  private readonly logger;
72
74
  private readonly loopDetector;
75
+ /** Flag indicating memory was modified by tools during this task, requiring prompt rebuild */
76
+ private memoryDirtyFlag;
73
77
  private readonly memoryManager?;
74
78
  private readonly metadataHandler;
75
79
  private readonly mutex;
@@ -348,6 +352,15 @@ export declare class ByteRoverLLMService implements ILLMService {
348
352
  * @param taskId - Task ID from usecase for billing tracking (passed to subagents)
349
353
  */
350
354
  private handleToolCalls;
355
+ /**
356
+ * Replace the DateTime section in a cached system prompt with a fresh timestamp.
357
+ * DateTimeContributor wraps its output in <dateTime>...</dateTime> XML tags,
358
+ * enabling reliable regex replacement without rebuilding the entire prompt.
359
+ *
360
+ * @param cachedPrompt - Previously cached system prompt
361
+ * @returns Updated prompt with fresh DateTime
362
+ */
363
+ private refreshDateTime;
351
364
  /**
352
365
  * Validate LLM configuration using Zod schema.
353
366
  *
@@ -36,6 +36,8 @@ const TARGET_MESSAGE_TOKEN_UTILIZATION = 0.7;
36
36
  * - Handle retry logic (handled by RetryableContentGenerator decorator)
37
37
  */
38
38
  export class ByteRoverLLMService {
39
+ /** Cached base system prompt (everything built by SystemPromptManager) for reuse across iterations */
40
+ cachedBasePrompt = null;
39
41
  compactionService;
40
42
  config;
41
43
  contextManager;
@@ -44,6 +46,8 @@ export class ByteRoverLLMService {
44
46
  generator;
45
47
  logger;
46
48
  loopDetector;
49
+ /** Flag indicating memory was modified by tools during this task, requiring prompt rebuild */
50
+ memoryDirtyFlag = false;
47
51
  memoryManager;
48
52
  metadataHandler;
49
53
  mutex = new AsyncMutex();
@@ -148,13 +152,17 @@ export class ByteRoverLLMService {
148
152
  * @returns Final assistant response
149
153
  */
150
154
  async completeTask(textInput, options) {
155
+ // Reset per-task prompt cache (each task gets a fresh prompt on its first iteration)
156
+ this.cachedBasePrompt = null;
157
+ this.memoryDirtyFlag = false;
151
158
  // Extract options with defaults
152
159
  const { executionContext, fileData, imageData, signal, stream, taskId } = options ?? {};
153
160
  // Get filtered tools based on command type (e.g., only read-only tools for 'query')
154
161
  const toolSet = this.toolManager.getToolsForCommand(options?.executionContext?.commandType);
155
- // Create state machine with configured limits
162
+ // Create state machine with configured limits (per-invocation overrides via ExecutionContext)
163
+ const effectiveMaxIterations = executionContext?.maxIterations ?? this.config.maxIterations;
156
164
  const maxTimeMs = this.config.timeout ?? 600_000; // 10 min default
157
- const stateMachine = new AgentStateMachine(this.config.maxIterations, maxTimeMs);
165
+ const stateMachine = new AgentStateMachine(effectiveMaxIterations, maxTimeMs);
158
166
  stateMachine.transition(AgentState.EXECUTING);
159
167
  // Agentic loop with state machine
160
168
  while (!stateMachine.isTerminal()) {
@@ -295,10 +303,13 @@ export class ByteRoverLLMService {
295
303
  buildGenerateContentRequest(options) {
296
304
  // Get internal messages from context manager
297
305
  const messages = this.contextManager.getMessages();
306
+ // Apply per-invocation overrides from ExecutionContext (e.g., query-optimized config)
307
+ const effectiveMaxTokens = options.executionContext?.maxTokens ?? this.config.maxTokens;
308
+ const effectiveTemperature = options.executionContext?.temperature ?? this.config.temperature;
298
309
  return {
299
310
  config: {
300
- maxTokens: this.config.maxTokens,
301
- temperature: this.config.temperature,
311
+ maxTokens: effectiveMaxTokens,
312
+ temperature: effectiveTemperature,
302
313
  },
303
314
  contents: messages,
304
315
  executionContext: options.executionContext,
@@ -560,23 +571,35 @@ export class ByteRoverLLMService {
560
571
  for (const marker of markersSet) {
561
572
  availableMarkers[marker] = marker;
562
573
  }
563
- // Build environment context for system prompt
564
- const environmentContext = await this.environmentBuilder.build({
565
- includeBrvStructure: true,
566
- includeFileTree: true,
567
- maxFileTreeDepth: 3,
568
- maxFileTreeEntries: 100,
569
- workingDirectory: this.workingDirectory,
570
- });
571
- let systemPrompt = await this.systemPromptManager.build({
572
- availableMarkers,
573
- availableTools,
574
- commandType: executionContext?.commandType,
575
- conversationMetadata: executionContext?.conversationMetadata,
576
- environmentContext,
577
- fileReferenceInstructions: executionContext?.fileReferenceInstructions,
578
- memoryManager: this.memoryManager,
579
- });
574
+ // Build base system prompt (cached across iterations within the same task)
575
+ const needsFullRebuild = iterationCount === 0 || this.cachedBasePrompt === null || this.memoryDirtyFlag;
576
+ let basePrompt;
577
+ if (needsFullRebuild) {
578
+ // Full rebuild: first iteration, no cache, or memory was modified by tools
579
+ const environmentContext = await this.environmentBuilder.build({
580
+ includeBrvStructure: true,
581
+ includeFileTree: true,
582
+ maxFileTreeDepth: 3,
583
+ maxFileTreeEntries: 100,
584
+ workingDirectory: this.workingDirectory,
585
+ });
586
+ basePrompt = await this.systemPromptManager.build({
587
+ availableMarkers,
588
+ availableTools,
589
+ commandType: executionContext?.commandType,
590
+ conversationMetadata: executionContext?.conversationMetadata,
591
+ environmentContext,
592
+ fileReferenceInstructions: executionContext?.fileReferenceInstructions,
593
+ memoryManager: this.memoryManager,
594
+ });
595
+ this.cachedBasePrompt = basePrompt;
596
+ this.memoryDirtyFlag = false;
597
+ }
598
+ else {
599
+ // Cache hit: reuse base prompt, only refresh the DateTime section
600
+ basePrompt = this.refreshDateTime(this.cachedBasePrompt);
601
+ }
602
+ let systemPrompt = basePrompt;
580
603
  // Determine which reflection prompt to add (only highest priority is chosen)
581
604
  const reflectionType = this.determineReflectionType(iterationCount, executionContext?.commandType);
582
605
  // Add reflection prompt if eligible (hierarchical: only one reflection per iteration)
@@ -939,6 +962,11 @@ export class ByteRoverLLMService {
939
962
  };
940
963
  this.contextManager.updateToolCallState(toolCall.id, runningState);
941
964
  }
965
+ // Check if any memory-modifying tools are being called (invalidates cached system prompt)
966
+ const memoryModifyingTools = new Set(['delete_memory', 'edit_memory', 'write_memory']);
967
+ if (lastMessage.toolCalls.some((tc) => memoryModifyingTools.has(tc.function.name))) {
968
+ this.memoryDirtyFlag = true;
969
+ }
942
970
  // Step 3: Execute all tool calls in parallel (pass taskId for subagent billing)
943
971
  const parallelResults = await Promise.allSettled(lastMessage.toolCalls.map((toolCall) => this.executeToolCallParallel(toolCall, taskId)));
944
972
  // Step 4: Update tool part states with results (in order)
@@ -1002,6 +1030,18 @@ export class ByteRoverLLMService {
1002
1030
  }
1003
1031
  }
1004
1032
  }
1033
+ /**
1034
+ * Replace the DateTime section in a cached system prompt with a fresh timestamp.
1035
+ * DateTimeContributor wraps its output in <dateTime>...</dateTime> XML tags,
1036
+ * enabling reliable regex replacement without rebuilding the entire prompt.
1037
+ *
1038
+ * @param cachedPrompt - Previously cached system prompt
1039
+ * @returns Updated prompt with fresh DateTime
1040
+ */
1041
+ refreshDateTime(cachedPrompt) {
1042
+ const freshDateTime = `<dateTime>Current date and time: ${new Date().toISOString()}</dateTime>`;
1043
+ return cachedPrompt.replace(/<dateTime>[\S\s]*?<\/dateTime>/, freshDateTime);
1044
+ }
1005
1045
  /**
1006
1046
  * Validate LLM configuration using Zod schema.
1007
1047
  *
@@ -16,21 +16,64 @@ export declare const CurateInputSchema: z.ZodObject<{
16
16
  content: z.ZodOptional<z.ZodObject<{
17
17
  narrative: z.ZodOptional<z.ZodObject<{
18
18
  dependencies: z.ZodOptional<z.ZodString>;
19
+ diagrams: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
+ content: z.ZodString;
21
+ title: z.ZodOptional<z.ZodString>;
22
+ type: z.ZodEnum<["mermaid", "plantuml", "ascii", "other"]>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ type: "ascii" | "mermaid" | "plantuml" | "other";
25
+ content: string;
26
+ title?: string | undefined;
27
+ }, {
28
+ type: "ascii" | "mermaid" | "plantuml" | "other";
29
+ content: string;
30
+ title?: string | undefined;
31
+ }>, "many">>;
32
+ examples: z.ZodOptional<z.ZodString>;
19
33
  features: z.ZodOptional<z.ZodString>;
34
+ rules: z.ZodOptional<z.ZodString>;
20
35
  structure: z.ZodOptional<z.ZodString>;
21
36
  }, "strip", z.ZodTypeAny, {
22
37
  structure?: string | undefined;
23
38
  dependencies?: string | undefined;
24
39
  features?: string | undefined;
40
+ rules?: string | undefined;
41
+ examples?: string | undefined;
42
+ diagrams?: {
43
+ type: "ascii" | "mermaid" | "plantuml" | "other";
44
+ content: string;
45
+ title?: string | undefined;
46
+ }[] | undefined;
25
47
  }, {
26
48
  structure?: string | undefined;
27
49
  dependencies?: string | undefined;
28
50
  features?: string | undefined;
51
+ rules?: string | undefined;
52
+ examples?: string | undefined;
53
+ diagrams?: {
54
+ type: "ascii" | "mermaid" | "plantuml" | "other";
55
+ content: string;
56
+ title?: string | undefined;
57
+ }[] | undefined;
29
58
  }>>;
30
59
  rawConcept: z.ZodOptional<z.ZodObject<{
60
+ author: z.ZodOptional<z.ZodString>;
31
61
  changes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
32
62
  files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
33
63
  flow: z.ZodOptional<z.ZodString>;
64
+ patterns: z.ZodOptional<z.ZodArray<z.ZodObject<{
65
+ description: z.ZodString;
66
+ flags: z.ZodOptional<z.ZodString>;
67
+ pattern: z.ZodString;
68
+ }, "strip", z.ZodTypeAny, {
69
+ description: string;
70
+ pattern: string;
71
+ flags?: string | undefined;
72
+ }, {
73
+ description: string;
74
+ pattern: string;
75
+ flags?: string | undefined;
76
+ }>, "many">>;
34
77
  task: z.ZodOptional<z.ZodString>;
35
78
  timestamp: z.ZodOptional<z.ZodString>;
36
79
  }, "strip", z.ZodTypeAny, {
@@ -39,12 +82,24 @@ export declare const CurateInputSchema: z.ZodObject<{
39
82
  task?: string | undefined;
40
83
  changes?: string[] | undefined;
41
84
  flow?: string | undefined;
85
+ author?: string | undefined;
86
+ patterns?: {
87
+ description: string;
88
+ pattern: string;
89
+ flags?: string | undefined;
90
+ }[] | undefined;
42
91
  }, {
43
92
  timestamp?: string | undefined;
44
93
  files?: string[] | undefined;
45
94
  task?: string | undefined;
46
95
  changes?: string[] | undefined;
47
96
  flow?: string | undefined;
97
+ author?: string | undefined;
98
+ patterns?: {
99
+ description: string;
100
+ pattern: string;
101
+ flags?: string | undefined;
102
+ }[] | undefined;
48
103
  }>>;
49
104
  relations: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
50
105
  snippets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -53,6 +108,13 @@ export declare const CurateInputSchema: z.ZodObject<{
53
108
  structure?: string | undefined;
54
109
  dependencies?: string | undefined;
55
110
  features?: string | undefined;
111
+ rules?: string | undefined;
112
+ examples?: string | undefined;
113
+ diagrams?: {
114
+ type: "ascii" | "mermaid" | "plantuml" | "other";
115
+ content: string;
116
+ title?: string | undefined;
117
+ }[] | undefined;
56
118
  } | undefined;
57
119
  rawConcept?: {
58
120
  timestamp?: string | undefined;
@@ -60,6 +122,12 @@ export declare const CurateInputSchema: z.ZodObject<{
60
122
  task?: string | undefined;
61
123
  changes?: string[] | undefined;
62
124
  flow?: string | undefined;
125
+ author?: string | undefined;
126
+ patterns?: {
127
+ description: string;
128
+ pattern: string;
129
+ flags?: string | undefined;
130
+ }[] | undefined;
63
131
  } | undefined;
64
132
  relations?: string[] | undefined;
65
133
  snippets?: string[] | undefined;
@@ -68,6 +136,13 @@ export declare const CurateInputSchema: z.ZodObject<{
68
136
  structure?: string | undefined;
69
137
  dependencies?: string | undefined;
70
138
  features?: string | undefined;
139
+ rules?: string | undefined;
140
+ examples?: string | undefined;
141
+ diagrams?: {
142
+ type: "ascii" | "mermaid" | "plantuml" | "other";
143
+ content: string;
144
+ title?: string | undefined;
145
+ }[] | undefined;
71
146
  } | undefined;
72
147
  rawConcept?: {
73
148
  timestamp?: string | undefined;
@@ -75,6 +150,12 @@ export declare const CurateInputSchema: z.ZodObject<{
75
150
  task?: string | undefined;
76
151
  changes?: string[] | undefined;
77
152
  flow?: string | undefined;
153
+ author?: string | undefined;
154
+ patterns?: {
155
+ description: string;
156
+ pattern: string;
157
+ flags?: string | undefined;
158
+ }[] | undefined;
78
159
  } | undefined;
79
160
  relations?: string[] | undefined;
80
161
  snippets?: string[] | undefined;
@@ -149,6 +230,13 @@ export declare const CurateInputSchema: z.ZodObject<{
149
230
  structure?: string | undefined;
150
231
  dependencies?: string | undefined;
151
232
  features?: string | undefined;
233
+ rules?: string | undefined;
234
+ examples?: string | undefined;
235
+ diagrams?: {
236
+ type: "ascii" | "mermaid" | "plantuml" | "other";
237
+ content: string;
238
+ title?: string | undefined;
239
+ }[] | undefined;
152
240
  } | undefined;
153
241
  rawConcept?: {
154
242
  timestamp?: string | undefined;
@@ -156,6 +244,12 @@ export declare const CurateInputSchema: z.ZodObject<{
156
244
  task?: string | undefined;
157
245
  changes?: string[] | undefined;
158
246
  flow?: string | undefined;
247
+ author?: string | undefined;
248
+ patterns?: {
249
+ description: string;
250
+ pattern: string;
251
+ flags?: string | undefined;
252
+ }[] | undefined;
159
253
  } | undefined;
160
254
  relations?: string[] | undefined;
161
255
  snippets?: string[] | undefined;
@@ -190,6 +284,13 @@ export declare const CurateInputSchema: z.ZodObject<{
190
284
  structure?: string | undefined;
191
285
  dependencies?: string | undefined;
192
286
  features?: string | undefined;
287
+ rules?: string | undefined;
288
+ examples?: string | undefined;
289
+ diagrams?: {
290
+ type: "ascii" | "mermaid" | "plantuml" | "other";
291
+ content: string;
292
+ title?: string | undefined;
293
+ }[] | undefined;
193
294
  } | undefined;
194
295
  rawConcept?: {
195
296
  timestamp?: string | undefined;
@@ -197,6 +298,12 @@ export declare const CurateInputSchema: z.ZodObject<{
197
298
  task?: string | undefined;
198
299
  changes?: string[] | undefined;
199
300
  flow?: string | undefined;
301
+ author?: string | undefined;
302
+ patterns?: {
303
+ description: string;
304
+ pattern: string;
305
+ flags?: string | undefined;
306
+ }[] | undefined;
200
307
  } | undefined;
201
308
  relations?: string[] | undefined;
202
309
  snippets?: string[] | undefined;
@@ -234,6 +341,13 @@ export declare const CurateInputSchema: z.ZodObject<{
234
341
  structure?: string | undefined;
235
342
  dependencies?: string | undefined;
236
343
  features?: string | undefined;
344
+ rules?: string | undefined;
345
+ examples?: string | undefined;
346
+ diagrams?: {
347
+ type: "ascii" | "mermaid" | "plantuml" | "other";
348
+ content: string;
349
+ title?: string | undefined;
350
+ }[] | undefined;
237
351
  } | undefined;
238
352
  rawConcept?: {
239
353
  timestamp?: string | undefined;
@@ -241,6 +355,12 @@ export declare const CurateInputSchema: z.ZodObject<{
241
355
  task?: string | undefined;
242
356
  changes?: string[] | undefined;
243
357
  flow?: string | undefined;
358
+ author?: string | undefined;
359
+ patterns?: {
360
+ description: string;
361
+ pattern: string;
362
+ flags?: string | undefined;
363
+ }[] | undefined;
244
364
  } | undefined;
245
365
  relations?: string[] | undefined;
246
366
  snippets?: string[] | undefined;
@@ -277,6 +397,13 @@ export declare const CurateInputSchema: z.ZodObject<{
277
397
  structure?: string | undefined;
278
398
  dependencies?: string | undefined;
279
399
  features?: string | undefined;
400
+ rules?: string | undefined;
401
+ examples?: string | undefined;
402
+ diagrams?: {
403
+ type: "ascii" | "mermaid" | "plantuml" | "other";
404
+ content: string;
405
+ title?: string | undefined;
406
+ }[] | undefined;
280
407
  } | undefined;
281
408
  rawConcept?: {
282
409
  timestamp?: string | undefined;
@@ -284,6 +411,12 @@ export declare const CurateInputSchema: z.ZodObject<{
284
411
  task?: string | undefined;
285
412
  changes?: string[] | undefined;
286
413
  flow?: string | undefined;
414
+ author?: string | undefined;
415
+ patterns?: {
416
+ description: string;
417
+ pattern: string;
418
+ flags?: string | undefined;
419
+ }[] | undefined;
287
420
  } | undefined;
288
421
  relations?: string[] | undefined;
289
422
  snippets?: string[] | undefined;
@@ -14,9 +14,15 @@ const OperationType = z.enum(['ADD', 'UPDATE', 'UPSERT', 'MERGE', 'DELETE']);
14
14
  * Raw Concept schema for structured metadata and technical footprint.
15
15
  */
16
16
  const RawConceptSchema = z.object({
17
+ author: z.string().optional().describe('Author or source attribution (e.g., "meowso", "Team Security")'),
17
18
  changes: z.array(z.string()).optional().describe('What changes in the codebase are induced by this concept'),
18
19
  files: z.array(z.string()).optional().describe('Which files are related to this concept'),
19
20
  flow: z.string().optional().describe('What is the flow included in this concept'),
21
+ patterns: z.array(z.object({
22
+ description: z.string().describe('What this pattern matches or validates'),
23
+ flags: z.string().optional().describe('Pattern flags (e.g., "gi" for regex)'),
24
+ pattern: z.string().describe('The exact pattern string (e.g., regex pattern)')
25
+ })).optional().describe('Regex or validation patterns related to this concept'),
20
26
  task: z.string().optional().describe('What is the task related to this concept'),
21
27
  timestamp: z
22
28
  .string()
@@ -31,10 +37,17 @@ const NarrativeSchema = z.object({
31
37
  .string()
32
38
  .optional()
33
39
  .describe('Dependency management information (e.g., "Singleton, init when service starts, hard dependency in smoke test")'),
40
+ diagrams: z.array(z.object({
41
+ content: z.string().describe('The full diagram content (Mermaid code, PlantUML code, or ASCII art) - preserved verbatim'),
42
+ title: z.string().optional().describe('Optional title or label for the diagram'),
43
+ type: z.enum(['mermaid', 'plantuml', 'ascii', 'other']).describe('Diagram type for proper rendering'),
44
+ })).optional().describe('Diagrams found in source content - Mermaid, PlantUML, ASCII art, sequence diagrams. Preserve verbatim.'),
45
+ examples: z.string().optional().describe('Concrete examples and use cases demonstrating the concept'),
34
46
  features: z
35
47
  .string()
36
48
  .optional()
37
49
  .describe('Feature documentation for this concept (e.g., "User permission can be stale for up to 300 seconds due to Redis cache")'),
50
+ rules: z.string().optional().describe('Exact rules, constraints, or guidelines - preserved verbatim from source'),
38
51
  structure: z.string().optional().describe('Code structure documentation (e.g., "clients/redis_client.go")'),
39
52
  });
40
53
  /**
@@ -775,6 +788,7 @@ export function createCurateTool() {
775
788
  - structure: Code structure documentation
776
789
  - dependencies: Dependency management information
777
790
  - features: Feature documentation
791
+ - diagrams: Array of diagrams with {type: "mermaid"|"plantuml"|"ascii"|"other", content: string, title?: string} - preserve verbatim
778
792
  - **snippets**: Code/text snippets (legacy support)
779
793
  - **relations**: Related topics using @domain/topic notation
780
794