byterover-cli 1.0.4 → 1.0.5

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 (72) hide show
  1. package/README.md +13 -2
  2. package/dist/commands/curate.js +1 -1
  3. package/dist/commands/main.d.ts +13 -0
  4. package/dist/commands/main.js +53 -2
  5. package/dist/commands/query.js +1 -1
  6. package/dist/constants.d.ts +1 -1
  7. package/dist/constants.js +1 -1
  8. package/dist/core/domain/cipher/llm/registry.js +53 -2
  9. package/dist/core/domain/cipher/llm/types.d.ts +2 -0
  10. package/dist/core/domain/cipher/process/types.d.ts +7 -0
  11. package/dist/core/domain/cipher/session/session-metadata.d.ts +178 -0
  12. package/dist/core/domain/cipher/session/session-metadata.js +147 -0
  13. package/dist/core/domain/knowledge/markdown-writer.d.ts +15 -18
  14. package/dist/core/domain/knowledge/markdown-writer.js +232 -34
  15. package/dist/core/domain/knowledge/relation-parser.d.ts +25 -39
  16. package/dist/core/domain/knowledge/relation-parser.js +39 -61
  17. package/dist/core/domain/transport/schemas.d.ts +37 -2
  18. package/dist/core/domain/transport/schemas.js +23 -2
  19. package/dist/core/interfaces/cipher/i-session-persistence.d.ts +133 -0
  20. package/dist/core/interfaces/cipher/i-session-persistence.js +7 -0
  21. package/dist/core/interfaces/cipher/message-types.d.ts +6 -0
  22. package/dist/core/interfaces/executor/i-curate-executor.d.ts +2 -2
  23. package/dist/core/interfaces/i-context-file-reader.d.ts +3 -0
  24. package/dist/core/interfaces/usecase/{i-clear-use-case.d.ts → i-reset-use-case.d.ts} +1 -1
  25. package/dist/infra/cipher/agent/agent-schemas.d.ts +6 -6
  26. package/dist/infra/cipher/agent/service-initializer.js +4 -4
  27. package/dist/infra/cipher/file-system/context-tree-file-system-factory.js +3 -2
  28. package/dist/infra/cipher/file-system/file-system-service.js +1 -0
  29. package/dist/infra/cipher/http/internal-llm-http-service.js +3 -5
  30. package/dist/infra/cipher/interactive-loop.js +3 -1
  31. package/dist/infra/cipher/llm/context/context-manager.js +40 -16
  32. package/dist/infra/cipher/llm/formatters/gemini-formatter.d.ts +13 -0
  33. package/dist/infra/cipher/llm/formatters/gemini-formatter.js +98 -6
  34. package/dist/infra/cipher/llm/generators/byterover-content-generator.js +6 -2
  35. package/dist/infra/cipher/llm/thought-parser.d.ts +21 -0
  36. package/dist/infra/cipher/llm/thought-parser.js +27 -0
  37. package/dist/infra/cipher/llm/tool-output-processor.d.ts +10 -0
  38. package/dist/infra/cipher/llm/tool-output-processor.js +80 -7
  39. package/dist/infra/cipher/process/process-service.js +11 -3
  40. package/dist/infra/cipher/session/chat-session.d.ts +7 -2
  41. package/dist/infra/cipher/session/chat-session.js +90 -52
  42. package/dist/infra/cipher/session/session-metadata-store.d.ts +52 -0
  43. package/dist/infra/cipher/session/session-metadata-store.js +406 -0
  44. package/dist/infra/cipher/tools/implementations/curate-tool.js +113 -35
  45. package/dist/infra/cipher/tools/implementations/task-tool.js +1 -0
  46. package/dist/infra/context-tree/file-context-file-reader.js +4 -0
  47. package/dist/infra/core/task-processor.d.ts +2 -2
  48. package/dist/infra/process/process-manager.d.ts +10 -1
  49. package/dist/infra/process/process-manager.js +16 -6
  50. package/dist/infra/process/transport-handlers.js +31 -0
  51. package/dist/infra/repl/commands/index.js +5 -2
  52. package/dist/infra/repl/commands/new-command.d.ts +14 -0
  53. package/dist/infra/repl/commands/new-command.js +61 -0
  54. package/dist/infra/repl/commands/{clear-command.d.ts → reset-command.d.ts} +2 -2
  55. package/dist/infra/repl/commands/{clear-command.js → reset-command.js} +10 -10
  56. package/dist/infra/usecase/generate-rules-use-case.js +2 -2
  57. package/dist/infra/usecase/init-use-case.js +4 -4
  58. package/dist/infra/usecase/logout-use-case.js +1 -1
  59. package/dist/infra/usecase/push-use-case.js +1 -1
  60. package/dist/infra/usecase/{clear-use-case.d.ts → reset-use-case.d.ts} +5 -5
  61. package/dist/infra/usecase/{clear-use-case.js → reset-use-case.js} +5 -5
  62. package/dist/resources/prompts/curate.yml +68 -13
  63. package/dist/resources/tools/curate.txt +60 -15
  64. package/dist/tui/components/inline-prompts/inline-confirm.js +2 -2
  65. package/dist/tui/components/onboarding/onboarding-flow.js +1 -0
  66. package/dist/tui/views/command-view.js +15 -0
  67. package/dist/utils/file-validator.js +9 -7
  68. package/oclif.manifest.json +3 -3
  69. package/package.json +1 -1
  70. package/dist/config/context-tree-domains.d.ts +0 -29
  71. package/dist/config/context-tree-domains.js +0 -29
  72. /package/dist/core/interfaces/usecase/{i-clear-use-case.js → i-reset-use-case.js} +0 -0
@@ -1,22 +1,67 @@
1
- Curate knowledge topics with atomic operations. This tool manages the knowledge structure using four operation types:
1
+ Curate knowledge topics with atomic operations. This tool manages the knowledge structure using four operation types and supports a two-part context model: Raw Concept + Narrative.
2
+
3
+ **Content Structure (Two-Part Model):**
4
+ - **rawConcept**: Captures essential metadata and technical footprint
5
+ - task: What is the task related to this concept
6
+ - changes: Array of changes induced in the codebase
7
+ - files: Array of related files
8
+ - flow: The execution flow of this concept
9
+ - timestamp: When created/modified (ISO 8601 format, e.g., 2025-03-18)
10
+ - **narrative**: Captures descriptive and structural context
11
+ - structure: Code structure documentation (e.g., "clients/redis_client.go")
12
+ - dependencies: Dependency management information (e.g., "Singleton, init when service starts")
13
+ - features: Feature documentation (e.g., "User permission can be stale for up to 300 seconds")
14
+ - **snippets**: Code/text snippets (legacy support, optional)
15
+ - **relations**: Related topics using @domain/topic notation
2
16
 
3
17
  **Operations:**
4
- 1. **ADD** - Create new domain/topic/subtopic with context.md
5
- - Requires: path, content (snippets and/or relations), reason
6
- - Example: { type: "ADD", path: "code_style/error-handling", content: { snippets: ["..."], relations: ["logging/basics"] }, reason: "New pattern identified" }
18
+ 1. **ADD** - Create new titled context file in domain/topic/subtopic
19
+ - Requires: path, title, content, reason
20
+ - Example with Raw Concept + Narrative:
21
+ {
22
+ type: "ADD",
23
+ path: "structure/caching",
24
+ title: "Redis User Permissions",
25
+ content: {
26
+ rawConcept: {
27
+ task: "Introduce Redis cache for getUserPermissions(userId)",
28
+ changes: ["Cached result using remote Redis", "Redis client: singleton"],
29
+ files: ["services/permission_service.go", "clients/redis_client.go"],
30
+ flow: "getUserPermissions -> check Redis -> on miss query DB -> store result -> return",
31
+ timestamp: "2025-03-18"
32
+ },
33
+ narrative: {
34
+ structure: "# Redis client\n- clients/redis_client.go",
35
+ dependencies: "# Redis client\n- Singleton, init when service starts",
36
+ features: "# Authorization\n- User permission can be stale for up to 300 seconds"
37
+ },
38
+ relations: ["@structure/database"]
39
+ },
40
+ reason: "New caching pattern"
41
+ }
42
+ - Creates: structure/caching/redis_user_permissions.md
43
+
44
+ 2. **UPDATE** - Modify existing titled context file (full replacement)
45
+ - Requires: path, title, content, reason
46
+ - Supports same content structure as ADD
47
+
48
+ 3. **MERGE** - Combine source file into target file, delete source
49
+ - Requires: path (source), title (source file), mergeTarget (destination path), mergeTargetTitle (destination file), reason
50
+ - Example: { type: "MERGE", path: "code_style/old_topic", title: "Old Guide", mergeTarget: "code_style/new_topic", mergeTargetTitle: "New Guide", reason: "Consolidating" }
51
+ - Raw concepts and narratives are intelligently merged
7
52
 
8
- 2. **UPDATE** - Modify existing context.md (full replacement)
9
- - Requires: path, content, reason
10
- - Example: { type: "UPDATE", path: "code_style/error-handling", content: { snippets: ["Updated content"] }, reason: "Improved guidance" }
53
+ 4. **DELETE** - Remove specific file or entire folder
54
+ - Requires: path, title (optional), reason
55
+ - With title: deletes specific file; without title: deletes entire folder
11
56
 
12
- 3. **MERGE** - Combine source topic into target, delete source
13
- - Requires: path (source), mergeTarget (destination), reason
14
- - Example: { type: "MERGE", path: "code_style/old-topic", mergeTarget: "code_style/new-topic", reason: "Consolidating duplicates" }
57
+ **Path format:** domain/topic or domain/topic/subtopic (uses snake_case automatically)
58
+ **File naming:** Titles are converted to snake_case (e.g., "Best Practices" -> "best_practices.md")
15
59
 
16
- 4. **DELETE** - Remove topic/subtopic folder recursively
17
- - Requires: path, reason
18
- - Example: { type: "DELETE", path: "code_style/deprecated-topic", reason: "No longer relevant" }
60
+ **Domain constraints:**
61
+ - Predefined domains: code_style, design, structure, compliance, testing, bug_fixes
62
+ - Up to 3 additional custom domains are allowed
63
+ - Always prefer predefined domains when possible
19
64
 
20
- **Path format:** domain/topic or domain/topic/subtopic
65
+ **Backward Compatibility:** Existing context entries using only snippets and relations continue to work.
21
66
 
22
- **Output:** Returns applied operations with status (success/failed) and a summary of counts.
67
+ **Output:** Returns applied operations with status (success/failed), filePath (for created/modified files), and a summary of counts.
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  /**
3
3
  * InlineConfirm Component
4
4
  *
@@ -28,5 +28,5 @@ export function InlineConfirm({ default: defaultValue = true, message, onConfirm
28
28
  onConfirm(defaultValue);
29
29
  }
30
30
  };
31
- return (_jsxs(Box, { children: [_jsx(Text, { color: colors.secondary, children: "? " }), _jsxs(Text, { color: colors.text, children: [message, " "] }), _jsxs(Text, { color: colors.secondary, children: [hint, " "] }), _jsx(TextInput, { onChange: setInput, onSubmit: handleSubmit, value: input })] }));
31
+ return (_jsx(Box, { children: _jsxs(Text, { color: colors.text, children: [message, "?", ' ', _jsxs(Text, { color: colors.secondary, children: [hint, " "] }), _jsx(TextInput, { onChange: setInput, onSubmit: handleSubmit, value: input })] }) }));
32
32
  }
@@ -37,6 +37,7 @@ function getStepNumber(step) {
37
37
  }
38
38
  }
39
39
  }
40
+ // eslint-disable-next-line complexity -- React component renders multiple onboarding steps with conditional logic
40
41
  export const OnboardingFlow = ({ availableHeight, onInitComplete }) => {
41
42
  const { theme: { colors } } = useTheme();
42
43
  const { mode } = useMode();
@@ -301,6 +301,21 @@ export const CommandView = ({ availableHeight }) => {
301
301
  setActivePrompt(null);
302
302
  const needReloadAuth = trimmed.startsWith('/login') || trimmed.startsWith('/logout');
303
303
  const needReloadBrvConfig = trimmed.startsWith('/space switch') || trimmed.startsWith('/init');
304
+ const needNewSession = trimmed.startsWith('/new');
305
+ // Handle /new command - create new session and clear messages
306
+ if (needNewSession && client) {
307
+ try {
308
+ const response = await client.request('agent:newSession', { reason: 'User requested new session' });
309
+ if (response.success) {
310
+ // Clear the messages to start fresh
311
+ setMessages([]);
312
+ clearTasks();
313
+ }
314
+ }
315
+ catch {
316
+ // Error handling - the command already showed feedback
317
+ }
318
+ }
304
319
  // Refresh state after commands that change auth or project state
305
320
  if (needReloadAuth || needReloadBrvConfig) {
306
321
  clearTasks();
@@ -7,11 +7,11 @@ import path from 'node:path';
7
7
  * @param filePath - The file path to normalize
8
8
  * @returns Normalized absolute path
9
9
  */
10
- function normalizeFilePath(filePath) {
10
+ function normalizeFilePath(filePath, baseDir) {
11
11
  // Expand tilde to home directory
12
12
  const expanded = filePath.startsWith('~') ? filePath.replace(/^~/, os.homedir()) : filePath;
13
- // Resolve to absolute path
14
- const absolute = path.resolve(expanded);
13
+ // Resolve to absolute path using baseDir for relative paths
14
+ const absolute = path.isAbsolute(expanded) ? expanded : path.resolve(baseDir ?? process.cwd(), expanded);
15
15
  // Resolve symlinks (only if file exists)
16
16
  try {
17
17
  return fs.realpathSync(absolute);
@@ -57,8 +57,11 @@ function isTextFile(filePath) {
57
57
  * @returns Validation result with normalized path or error message
58
58
  */
59
59
  export function validateFileForCurate(filePath, projectRoot) {
60
- // Normalize path
61
- const normalized = normalizeFilePath(filePath);
60
+ // Normalize projectRoot first to ensure consistent behavior
61
+ // This handles cases where projectRoot might be relative
62
+ const normalizedProjectRoot = normalizeFilePath(projectRoot);
63
+ // Normalize file path using normalizedProjectRoot as base for relative paths
64
+ const normalized = normalizeFilePath(filePath, normalizedProjectRoot);
62
65
  // Check existence
63
66
  if (!fs.existsSync(normalized)) {
64
67
  return { error: `File does not exist: ${filePath}`, valid: false };
@@ -68,8 +71,7 @@ export function validateFileForCurate(filePath, projectRoot) {
68
71
  if (!stats.isFile()) {
69
72
  return { error: `Path is not a file: ${filePath}`, valid: false };
70
73
  }
71
- // Check within project (normalized paths for reliable comparison)
72
- const normalizedProjectRoot = normalizeFilePath(projectRoot);
74
+ // Check within project (both paths are already normalized)
73
75
  if (!normalized.startsWith(normalizedProjectRoot + path.sep) && normalized !== normalizedProjectRoot) {
74
76
  return { error: `File is outside project directory: ${filePath}`, valid: false };
75
77
  }
@@ -9,7 +9,7 @@
9
9
  "required": false
10
10
  }
11
11
  },
12
- "description": "Curate context to the context tree (connects to running brv instance)\n\nRequires a running brv instance. Start one with: brv start\n\nGood examples:\n- \"Auth uses JWT with 24h expiry. Tokens stored in httpOnly cookies via authMiddleware.ts\"\n- \"API rate limit is 100 req/min per user. Implemented using Redis with sliding window in rateLimiter.ts\"\nBad examples:\n- \"Authentication\" or \"JWT tokens\" (too vague, lacks context)\n- \"Rate limiting\" (no implementation details or file references)",
12
+ "description": "Curate context to the context tree (connects to running brv instance)\n\nRequires a running brv instance. Start one with: brv\n\nGood examples:\n- \"Auth uses JWT with 24h expiry. Tokens stored in httpOnly cookies via authMiddleware.ts\"\n- \"API rate limit is 100 req/min per user. Implemented using Redis with sliding window in rateLimiter.ts\"\nBad examples:\n- \"Authentication\" or \"JWT tokens\" (too vague, lacks context)\n- \"Rate limiting\" (no implementation details or file references)",
13
13
  "examples": [
14
14
  "# Curate context - queues task for background processing",
15
15
  "<%= config.bin %> <%= command.id %> \"Auth uses JWT with 24h expiry. Tokens stored in httpOnly cookies via authMiddleware.ts\"",
@@ -75,7 +75,7 @@
75
75
  "required": true
76
76
  }
77
77
  },
78
- "description": "Query and retrieve information from the context tree (connects to running brv instance)\n\nRequires a running brv instance. Start one with: brv start\n\nGood:\n- \"How is user authentication implemented?\"\n- \"What are the API rate limits and where are they enforced?\"\nBad:\n- \"auth\" or \"authentication\" (too vague, not a question)\n- \"show me code\" (not specific about what information is needed)",
78
+ "description": "Query and retrieve information from the context tree (connects to running brv instance)\n\nRequires a running brv instance. Start one with: brv\n\nGood:\n- \"How is user authentication implemented?\"\n- \"What are the API rate limits and where are they enforced?\"\nBad:\n- \"auth\" or \"authentication\" (too vague, not a question)\n- \"show me code\" (not specific about what information is needed)",
79
79
  "examples": [
80
80
  "# Ask questions about patterns, decisions, or implementation details",
81
81
  "<%= config.bin %> <%= command.id %> What are the coding standards?",
@@ -198,5 +198,5 @@
198
198
  ]
199
199
  }
200
200
  },
201
- "version": "1.0.4"
201
+ "version": "1.0.5"
202
202
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "byterover-cli",
3
3
  "description": "ByteRover's CLI",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "author": "ByteRover",
6
6
  "bin": {
7
7
  "brv": "./bin/run.js"
@@ -1,29 +0,0 @@
1
- /**
2
- * Domain configurations for the context tree structure.
3
- * Each domain represents a specific area of knowledge in the project.
4
- *
5
- * @deprecated Domains are now created dynamically based on content semantics.
6
- * This file is kept for backward compatibility only.
7
- */
8
- export interface DomainConfig {
9
- description: string;
10
- name: string;
11
- }
12
- /**
13
- * Example domain names for reference only.
14
- * Domains are now created dynamically by the agent based on content.
15
- *
16
- * @deprecated Domains are created dynamically. These are kept as examples only.
17
- */
18
- export declare const EXAMPLE_DOMAIN_NAMES: readonly ["authentication", "api_design", "data_models", "error_handling", "ui_components", "testing_patterns", "configuration", "logging", "security", "performance"];
19
- /**
20
- * @deprecated Domains are now created dynamically based on content semantics.
21
- * The agent will create domain names that are semantically meaningful for the curated content.
22
- * This constant is kept for backward compatibility but is no longer used.
23
- */
24
- export declare const DEFAULT_CONTEXT_TREE_DOMAINS: DomainConfig[];
25
- /**
26
- * Alias for backward compatibility.
27
- * @deprecated Domains are created dynamically. This constant is no longer used.
28
- */
29
- export declare const CONTEXT_TREE_DOMAINS: DomainConfig[];
@@ -1,29 +0,0 @@
1
- /**
2
- * Example domain names for reference only.
3
- * Domains are now created dynamically by the agent based on content.
4
- *
5
- * @deprecated Domains are created dynamically. These are kept as examples only.
6
- */
7
- export const EXAMPLE_DOMAIN_NAMES = [
8
- 'authentication',
9
- 'api_design',
10
- 'data_models',
11
- 'error_handling',
12
- 'ui_components',
13
- 'testing_patterns',
14
- 'configuration',
15
- 'logging',
16
- 'security',
17
- 'performance',
18
- ];
19
- /**
20
- * @deprecated Domains are now created dynamically based on content semantics.
21
- * The agent will create domain names that are semantically meaningful for the curated content.
22
- * This constant is kept for backward compatibility but is no longer used.
23
- */
24
- export const DEFAULT_CONTEXT_TREE_DOMAINS = [];
25
- /**
26
- * Alias for backward compatibility.
27
- * @deprecated Domains are created dynamically. This constant is no longer used.
28
- */
29
- export const CONTEXT_TREE_DOMAINS = DEFAULT_CONTEXT_TREE_DOMAINS;