byterover-cli 1.2.0 → 1.2.1

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 CHANGED
@@ -11,6 +11,7 @@ Command-line interface for ByteRover, featuring an interactive REPL with a moder
11
11
  * [Installation](#installation)
12
12
  * [Quick Start](#quick-start)
13
13
  * [Interactive REPL](#interactive-repl)
14
+ * [Keyboard Shortcuts](#keyboard-shortcuts)
14
15
  * [What is Context Tree?](#what-is-context-tree)
15
16
  * [Slash Commands Reference](#slash-commands-reference)
16
17
  * [Authentication](#authentication)
@@ -99,10 +100,24 @@ The terminal UI includes:
99
100
  - **Tab Navigation**: Switch between Chat and Activity views using `Tab`
100
101
  - **Command Completion**: Type `/` to see available commands with auto-completion
101
102
  - **Activity Log**: Real-time task status and execution progress
102
- - **Streaming Output**: Live responses from AI-powered operations
103
+ - **Streaming Output**: Live responses with markdown rendering (headings, lists, blockquotes, code blocks)
103
104
  - **File References**: Type `@` in curate mode to browse and attach files (supports PDF)
104
105
  - **Dynamic Domains**: Automatically creates new knowledge domains as your context tree grows
105
106
  - **Session Persistence**: Sessions auto-resume after restart
107
+ - **Expandable Views**: Press `Ctrl+O` to expand messages or logs to full-screen with vim-style navigation
108
+ - **Version Indicator**: Shows "(latest)" when running the most current version
109
+
110
+ ### Keyboard Shortcuts
111
+
112
+ | Shortcut | Action |
113
+ |----------|--------|
114
+ | `Tab` | Switch between Chat and Activity views |
115
+ | `Ctrl+O` | Expand message or log to full-screen |
116
+ | `j` / `k` | Scroll down/up in expanded view |
117
+ | `g` / `G` | Jump to top/bottom in expanded view |
118
+ | `Esc` or `q` | Exit expanded view |
119
+ | `/` | Show command suggestions |
120
+ | `@` | Browse files (in curate mode) |
106
121
 
107
122
  ### Using Commands
108
123
 
@@ -56,13 +56,15 @@ export interface IChatSession {
56
56
  * @param input - User message content
57
57
  * @param options - Optional execution options
58
58
  * @param options.executionContext - Optional execution context
59
- * @param options.taskId - Optional task ID for concurrent task isolation (included in all emitted events)
59
+ * @param options.taskId - Optional task ID for billing tracking and event correlation
60
+ * @param options.emitTaskId - Whether to include taskId in emitted events (default: true)
60
61
  * @returns Assistant response
61
62
  * @throws SessionCancelledError if operation is cancelled
62
63
  * @throws MaxIterationsExceededError if tool loop exceeds maximum iterations
63
64
  * @throws LLMError if LLM call fails
64
65
  */
65
66
  run(input: string, options?: {
67
+ emitTaskId?: boolean;
66
68
  executionContext?: ExecutionContext;
67
69
  taskId?: string;
68
70
  }): Promise<string>;
@@ -84,9 +84,11 @@ export declare class ChatSession implements IChatSession {
84
84
  * @param input - User message
85
85
  * @param options - Execution options
86
86
  * @param options.executionContext - Optional execution context
87
- * @param options.taskId - Optional task ID for concurrent task isolation
87
+ * @param options.taskId - Optional task ID for billing tracking
88
+ * @param options.emitTaskId - Whether to include taskId in emitted events (default: true)
88
89
  */
89
90
  run(input: string, options?: {
91
+ emitTaskId?: boolean;
90
92
  executionContext?: ExecutionContext;
91
93
  taskId?: string;
92
94
  }): Promise<string>;
@@ -168,10 +168,12 @@ export class ChatSession {
168
168
  * @param input - User message
169
169
  * @param options - Execution options
170
170
  * @param options.executionContext - Optional execution context
171
- * @param options.taskId - Optional task ID for concurrent task isolation
171
+ * @param options.taskId - Optional task ID for billing tracking
172
+ * @param options.emitTaskId - Whether to include taskId in emitted events (default: true)
172
173
  */
173
174
  async run(input, options) {
174
175
  const taskId = options?.taskId;
176
+ const emitTaskId = options?.emitTaskId !== false;
175
177
  const controller = new AbortController();
176
178
  // Track controller per-task for concurrent execution support
177
179
  if (taskId) {
@@ -180,8 +182,8 @@ export class ChatSession {
180
182
  else {
181
183
  this.currentController = controller;
182
184
  }
183
- // Store taskId for event forwarding (last-write-wins for concurrent tasks)
184
- this.currentTaskId = taskId;
185
+ // Store taskId for event forwarding only if emitTaskId is true
186
+ this.currentTaskId = emitTaskId ? taskId : undefined;
185
187
  this.isExecuting = true;
186
188
  sessionStatusManager.setBusy(this.id, this.eventBus);
187
189
  try {
@@ -95,7 +95,7 @@ export function createTaskTool(dependencies) {
95
95
  const registry = getAgentRegistry();
96
96
  return {
97
97
  description: buildTaskToolDescription(registry),
98
- // eslint-disable-next-line complexity -- Inherent complexity: validates agent, manages sessions, handles errors
98
+ // eslint-disable-next-line complexity
99
99
  async execute(input, context) {
100
100
  const params = input;
101
101
  const { contextTreeOnly, description, prompt, sessionId, subagentType } = params;
@@ -181,8 +181,8 @@ export function createTaskTool(dependencies) {
181
181
  progress: 10,
182
182
  });
183
183
  }
184
- // Execute the subagent session with parent's taskId for billing tracking
185
- const response = await session.run(fullPrompt, { taskId: context?.taskId });
184
+ // Pass taskId for billing but don't emit it in events (ENG-917)
185
+ const response = await session.run(fullPrompt, { emitTaskId: false, taskId: context?.taskId });
186
186
  // Stream completion update
187
187
  if (context?.metadata) {
188
188
  context.metadata({
@@ -72,6 +72,15 @@ export declare class SocketIOTransportClient implements ITransportClient {
72
72
  * Used when initiating new connection attempt - counter preserved for backoff continuity.
73
73
  */
74
74
  private clearForceReconnectTimer;
75
+ /**
76
+ * Remove all registered event listeners from socket.
77
+ * Used before re-registering to prevent listener accumulation across reconnects.
78
+ *
79
+ * Why this is needed: Socket.IO preserves the Socket instance across internal reconnects.
80
+ * If we clear registeredSocketEvents without calling socket.off(), the old listeners
81
+ * remain attached, and registerPendingEventHandlers() adds new ones - causing duplicates.
82
+ */
83
+ private clearSocketEventListeners;
75
84
  /**
76
85
  * Handle system wake from sleep/hibernate.
77
86
  * Re-triggers reconnection if not connected and force reconnect has given up.
@@ -145,8 +145,10 @@ export class SocketIOTransportClient {
145
145
  clientLog(`Socket.IO built-in reconnect succeeded after ${attemptNumber} attempts`);
146
146
  this.setState('connected');
147
147
  // Re-register event handlers after reconnect
148
- // Clear tracking first since socket listeners were reset during reconnect
149
- this.registeredSocketEvents.clear();
148
+ // FIX: Remove existing socket listeners before re-registering to prevent
149
+ // listener accumulation. Socket.IO preserves the Socket instance across
150
+ // internal reconnects, so old listeners remain attached if not removed.
151
+ this.clearSocketEventListeners();
150
152
  this.registerPendingEventHandlers();
151
153
  // Auto-rejoin rooms after reconnect
152
154
  // Use process.nextTick to ensure socket.connected is true
@@ -408,6 +410,23 @@ export class SocketIOTransportClient {
408
410
  this.forceReconnectTimer = undefined;
409
411
  }
410
412
  }
413
+ /**
414
+ * Remove all registered event listeners from socket.
415
+ * Used before re-registering to prevent listener accumulation across reconnects.
416
+ *
417
+ * Why this is needed: Socket.IO preserves the Socket instance across internal reconnects.
418
+ * If we clear registeredSocketEvents without calling socket.off(), the old listeners
419
+ * remain attached, and registerPendingEventHandlers() adds new ones - causing duplicates.
420
+ */
421
+ clearSocketEventListeners() {
422
+ const { socket } = this;
423
+ if (!socket)
424
+ return;
425
+ for (const event of this.registeredSocketEvents) {
426
+ socket.off(event);
427
+ }
428
+ this.registeredSocketEvents.clear();
429
+ }
411
430
  /**
412
431
  * Handle system wake from sleep/hibernate.
413
432
  * Re-triggers reconnection if not connected and force reconnect has given up.
@@ -1,100 +1,9 @@
1
1
  # ByteRover CLI Command Reference
2
2
 
3
- ## Memory Commands
3
+ ## Available Commands
4
4
 
5
- ### `brv curate`
5
+ - `brv curate` - Curate context to the context tree
6
+ - `brv query` - Query and retrieve information from the context tree
7
+ - `brv status` - Show CLI status and project information
6
8
 
7
- **Description:** Curate context to the context tree (interactive or autonomous mode)
8
-
9
- **Arguments:**
10
-
11
- - `CONTEXT`: Knowledge context: patterns, decisions, errors, or insights (triggers autonomous mode, optional)
12
-
13
- **Flags:**
14
-
15
- - `--files`, `-f`: Include file paths for critical context (max 5 files). Only text/code files from the current project directory are allowed. **CONTEXT argument must come BEFORE this flag.**
16
-
17
- **Good examples of context:**
18
-
19
- - "Auth uses JWT with 24h expiry. Tokens stored in httpOnly cookies via authMiddleware.ts"
20
- - "API rate limit is 100 req/min per user. Implemented using Redis with sliding window in rateLimiter.ts"
21
-
22
- **Bad examples:**
23
-
24
- - "Authentication" or "JWT tokens" (too vague, lacks context)
25
- - "Rate limiting" (no implementation details or file references)
26
-
27
- **Examples:**
28
-
29
- ```bash
30
- # Interactive mode (manually choose domain/topic)
31
- brv curate
32
-
33
- # Autonomous mode - LLM auto-categorizes your context
34
- brv curate "Auth uses JWT with 24h expiry. Tokens stored in httpOnly cookies via authMiddleware.ts"
35
-
36
- # Include files (CONTEXT must come before --files)
37
- # Single file
38
- brv curate "Authentication middleware validates JWT tokens" -f src/middleware/auth.ts
39
-
40
- # Multiple files - repeat --files flag for each file
41
- brv curate "JWT authentication implementation with refresh token rotation" --files src/auth/jwt.ts --files docs/auth.md
42
- ```
43
-
44
- **Behavior:**
45
-
46
- - Interactive mode: Navigate context tree, create topic folder, edit context.md
47
- - Autonomous mode: LLM automatically categorizes and places context in appropriate location
48
- - When `--files` is provided, agent reads files in parallel before creating knowledge topics
49
-
50
- **Requirements:** Project must be initialized (`brv init`) and authenticated (`brv login`)
51
-
52
- ---
53
-
54
- ### `brv query`
55
-
56
- **Description:** Query and retrieve information from the context tree
57
-
58
- **Arguments:**
59
-
60
- - `QUERY`: Natural language question about your codebase or project knowledge (required)
61
-
62
- **Good examples of queries:**
63
-
64
- - "How is user authentication implemented?"
65
- - "What are the API rate limits and where are they enforced?"
66
-
67
- **Bad examples:**
68
-
69
- - "auth" or "authentication" (too vague, not a question)
70
- - "show me code" (not specific about what information is needed)
71
-
72
- **Examples:**
73
-
74
- ```bash
75
- # Ask questions about patterns, decisions, or implementation details
76
- brv query What are the coding standards?
77
- brv query How is authentication implemented?
78
- ```
79
-
80
- **Behavior:**
81
-
82
- - Uses AI agent to search and answer questions about the context tree
83
- - Accepts natural language questions (not just keywords)
84
- - Displays tool execution progress in real-time
85
-
86
- **Requirements:** Project must be initialized (`brv init`) and authenticated (`brv login`)
87
-
88
- ---
89
-
90
- ## Best Practices
91
-
92
- ### Efficient Workflow
93
-
94
- 1. **Read only what's needed:** Check context tree with `brv status` to see changes before reading full content with `brv query`
95
- 2. **Update precisely:** Use `brv curate` to add/update specific context in context tree
96
- 3. **Push when appropriate:** Prompt user to run `brv push` after completing significant work
97
-
98
- ### Context tree Management
99
-
100
- - Use `brv curate` to directly add/update context in the context tree
9
+ Run `brv query --help` for query instruction and `brv curate --help` for curation instruction.
@@ -1,27 +1,32 @@
1
1
  # Workflow Instruction
2
2
 
3
3
  You are a coding agent focused on one codebase. Use the brv CLI to manage working context.
4
- Core Rules:
5
4
 
6
- - Start from memory. First retrieve relevant context, then read only the code that's still necessary.
7
- - Keep a local context tree. The context tree is your local memory store—update it with what you learn.
5
+ ## Core Rules
8
6
 
9
- ## Context Tree Guideline
10
-
11
- - Be specific ("Use React Query for data fetching in web modules").
12
- - Be actionable (clear instruction a future agent/dev can apply).
13
- - Be contextual (mention module/service, constraints, links to source).
14
- - Include source (file + lines or commit) when possible.
7
+ - **Start from memory.** First retrieve relevant context with `brv query`, then read only the code that's still necessary.
8
+ - **Keep a local context tree.** The context tree is your local memory store—update it with `brv curate` when you learn something valuable.
15
9
 
16
- ## Using `brv curate` with Files
10
+ ## When to Query
17
11
 
18
- When adding complex implementations, use `--files` to include relevant source files (max 5). Only text/code files from the current project directory are allowed. **CONTEXT argument must come BEFORE --files flag.** For multiple files, repeat the `--files` (or `-f`) flag for each file.
12
+ Use `brv query` **before** starting any code task that requires understanding the codebase:
13
+ - Writing, editing, or modifying code
14
+ - Understanding how something works
15
+ - Debugging or troubleshooting issues
16
+ - Making architectural decisions
19
17
 
20
- Examples:
18
+ ## When to Curate
21
19
 
22
- - Single file: `brv curate "JWT authentication with refresh token rotation" -f src/auth.ts`
23
- - Multiple files: `brv curate "Authentication system" --files src/auth/jwt.ts --files src/auth/middleware.ts --files docs/auth.md`
20
+ Use `brv curate` **after** you learn or create something valuable:
21
+ - Wrote or modified code
22
+ - Discovered how something works
23
+ - Made architectural/design decisions
24
+ - Found a bug root cause or fix pattern
24
25
 
25
- ## CLI Usage Notes
26
+ ## Context Tree Guideline
26
27
 
27
- - Use --help on any command to discover flags. Provide exact arguments for the scenario.
28
+ Good context is:
29
+ - **Specific** ("Use React Query for data fetching in web modules")
30
+ - **Actionable** (clear instruction a future agent/dev can apply)
31
+ - **Contextual** (mention module/service, constraints, links to source)
32
+ - **Sourced** (include file + lines or commit when possible)
@@ -249,5 +249,5 @@
249
249
  ]
250
250
  }
251
251
  },
252
- "version": "1.2.0"
252
+ "version": "1.2.1"
253
253
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "byterover-cli",
3
3
  "description": "ByteRover's CLI",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "author": "ByteRover",
6
6
  "bin": {
7
7
  "brv": "./bin/run.js"