byterover-cli 1.0.5 → 1.2.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 +19 -13
- package/dist/commands/hook-prompt-submit.d.ts +27 -0
- package/dist/commands/hook-prompt-submit.js +39 -0
- package/dist/commands/mcp.d.ts +13 -0
- package/dist/commands/mcp.js +61 -0
- package/dist/commands/status.js +8 -3
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/core/domain/cipher/agent-events/types.d.ts +44 -1
- package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
- package/dist/core/domain/cipher/tools/constants.js +1 -0
- package/dist/core/domain/entities/agent.d.ts +16 -0
- package/dist/core/domain/entities/agent.js +78 -0
- package/dist/core/domain/entities/connector-type.d.ts +10 -0
- package/dist/core/domain/entities/connector-type.js +9 -0
- package/dist/core/domain/entities/event.d.ts +1 -1
- package/dist/core/domain/entities/event.js +2 -0
- package/dist/core/domain/errors/task-error.d.ts +4 -0
- package/dist/core/domain/errors/task-error.js +7 -0
- package/dist/core/domain/transport/schemas.d.ts +40 -0
- package/dist/core/domain/transport/schemas.js +28 -0
- package/dist/core/interfaces/connectors/connector-types.d.ts +70 -0
- package/dist/core/interfaces/connectors/i-connector-manager.d.ts +72 -0
- package/dist/core/interfaces/connectors/i-connector-manager.js +1 -0
- package/dist/core/interfaces/connectors/i-connector.d.ts +54 -0
- package/dist/core/interfaces/connectors/i-connector.js +1 -0
- package/dist/core/interfaces/i-file-service.d.ts +7 -0
- package/dist/core/interfaces/i-mcp-config-writer.d.ts +40 -0
- package/dist/core/interfaces/i-mcp-config-writer.js +1 -0
- package/dist/core/interfaces/i-rule-template-service.d.ts +4 -2
- package/dist/core/interfaces/transport/i-transport-client.d.ts +7 -0
- package/dist/core/interfaces/usecase/i-connectors-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-connectors-use-case.js +1 -0
- package/dist/hooks/init/update-notifier.d.ts +1 -0
- package/dist/hooks/init/update-notifier.js +10 -1
- package/dist/infra/cipher/agent/cipher-agent.d.ts +8 -0
- package/dist/infra/cipher/agent/cipher-agent.js +16 -0
- package/dist/infra/cipher/file-system/binary-utils.d.ts +7 -12
- package/dist/infra/cipher/file-system/binary-utils.js +46 -31
- package/dist/infra/cipher/llm/context/context-manager.d.ts +10 -2
- package/dist/infra/cipher/llm/context/context-manager.js +39 -2
- package/dist/infra/cipher/llm/formatters/gemini-formatter.js +48 -9
- package/dist/infra/cipher/llm/internal-llm-service.d.ts +4 -0
- package/dist/infra/cipher/llm/internal-llm-service.js +40 -12
- package/dist/infra/cipher/session/chat-session.d.ts +3 -0
- package/dist/infra/cipher/session/chat-session.js +7 -1
- package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.d.ts +6 -7
- package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.js +57 -18
- package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +1 -8
- package/dist/infra/cipher/tools/implementations/curate-tool.js +380 -24
- package/dist/infra/cipher/tools/implementations/read-file-tool.js +38 -17
- package/dist/infra/cipher/tools/implementations/search-knowledge-tool.d.ts +7 -0
- package/dist/infra/cipher/tools/implementations/search-knowledge-tool.js +303 -0
- package/dist/infra/cipher/tools/index.d.ts +1 -0
- package/dist/infra/cipher/tools/index.js +1 -0
- package/dist/infra/cipher/tools/tool-manager.js +1 -0
- package/dist/infra/cipher/tools/tool-registry.js +7 -0
- package/dist/infra/connectors/connector-manager.d.ts +32 -0
- package/dist/infra/connectors/connector-manager.js +158 -0
- package/dist/infra/connectors/hook/hook-connector-config.d.ts +52 -0
- package/dist/infra/connectors/hook/hook-connector-config.js +41 -0
- package/dist/infra/connectors/hook/hook-connector.d.ts +46 -0
- package/dist/infra/connectors/hook/hook-connector.js +231 -0
- package/dist/infra/connectors/mcp/index.d.ts +4 -0
- package/dist/infra/connectors/mcp/index.js +4 -0
- package/dist/infra/connectors/mcp/json-mcp-config-writer.d.ts +26 -0
- package/dist/infra/connectors/mcp/json-mcp-config-writer.js +71 -0
- package/dist/infra/connectors/mcp/mcp-connector-config.d.ts +229 -0
- package/dist/infra/connectors/mcp/mcp-connector-config.js +173 -0
- package/dist/infra/connectors/mcp/mcp-connector.d.ts +80 -0
- package/dist/infra/connectors/mcp/mcp-connector.js +324 -0
- package/dist/infra/connectors/mcp/toml-mcp-config-writer.d.ts +45 -0
- package/dist/infra/connectors/mcp/toml-mcp-config-writer.js +134 -0
- package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.d.ts +2 -2
- package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.js +1 -1
- package/dist/infra/connectors/rules/rules-connector-config.d.ts +95 -0
- package/dist/infra/{rule/agent-rule-config.js → connectors/rules/rules-connector-config.js} +10 -10
- package/dist/infra/connectors/rules/rules-connector.d.ts +34 -0
- package/dist/infra/connectors/rules/rules-connector.js +139 -0
- package/dist/infra/connectors/shared/rule-file-manager.d.ts +72 -0
- package/dist/infra/connectors/shared/rule-file-manager.js +119 -0
- package/dist/infra/connectors/shared/template-service.d.ts +27 -0
- package/dist/infra/connectors/shared/template-service.js +125 -0
- package/dist/infra/context-tree/file-context-tree-writer-service.d.ts +5 -2
- package/dist/infra/context-tree/file-context-tree-writer-service.js +20 -5
- package/dist/infra/core/executors/curate-executor.d.ts +2 -2
- package/dist/infra/core/executors/curate-executor.js +7 -7
- package/dist/infra/core/executors/query-executor.d.ts +12 -0
- package/dist/infra/core/executors/query-executor.js +62 -1
- package/dist/infra/file/fs-file-service.d.ts +7 -0
- package/dist/infra/file/fs-file-service.js +15 -1
- package/dist/infra/mcp/index.d.ts +2 -0
- package/dist/infra/mcp/index.js +2 -0
- package/dist/infra/mcp/mcp-server.d.ts +58 -0
- package/dist/infra/mcp/mcp-server.js +178 -0
- package/dist/infra/mcp/tools/brv-curate-tool.d.ts +23 -0
- package/dist/infra/mcp/tools/brv-curate-tool.js +68 -0
- package/dist/infra/mcp/tools/brv-query-tool.d.ts +17 -0
- package/dist/infra/mcp/tools/brv-query-tool.js +68 -0
- package/dist/infra/mcp/tools/index.d.ts +3 -0
- package/dist/infra/mcp/tools/index.js +3 -0
- package/dist/infra/mcp/tools/task-result-waiter.d.ts +30 -0
- package/dist/infra/mcp/tools/task-result-waiter.js +56 -0
- package/dist/infra/process/agent-worker.d.ts +2 -2
- package/dist/infra/process/agent-worker.js +663 -142
- package/dist/infra/process/constants.d.ts +1 -1
- package/dist/infra/process/constants.js +1 -1
- package/dist/infra/process/ipc-types.d.ts +17 -4
- package/dist/infra/process/ipc-types.js +3 -3
- package/dist/infra/process/parent-heartbeat.d.ts +47 -0
- package/dist/infra/process/parent-heartbeat.js +118 -0
- package/dist/infra/process/process-manager.d.ts +79 -0
- package/dist/infra/process/process-manager.js +277 -3
- package/dist/infra/process/task-queue-manager.d.ts +13 -0
- package/dist/infra/process/task-queue-manager.js +19 -0
- package/dist/infra/process/transport-handlers.d.ts +3 -0
- package/dist/infra/process/transport-handlers.js +51 -5
- package/dist/infra/process/transport-worker.js +9 -69
- package/dist/infra/repl/commands/connectors-command.d.ts +8 -0
- package/dist/infra/repl/commands/{gen-rules-command.js → connectors-command.js} +21 -10
- package/dist/infra/repl/commands/curate-command.js +2 -2
- package/dist/infra/repl/commands/index.js +3 -2
- package/dist/infra/repl/commands/init-command.js +11 -7
- package/dist/infra/repl/commands/query-command.js +22 -2
- package/dist/infra/repl/commands/reset-command.js +1 -1
- package/dist/infra/transport/socket-io-transport-client.d.ts +75 -0
- package/dist/infra/transport/socket-io-transport-client.js +308 -7
- package/dist/infra/transport/socket-io-transport-server.js +4 -0
- package/dist/infra/usecase/connectors-use-case.d.ts +63 -0
- package/dist/infra/usecase/connectors-use-case.js +222 -0
- package/dist/infra/usecase/init-use-case.d.ts +8 -43
- package/dist/infra/usecase/init-use-case.js +27 -252
- package/dist/infra/usecase/logout-use-case.js +1 -1
- package/dist/infra/usecase/pull-use-case.js +5 -5
- package/dist/infra/usecase/push-use-case.js +4 -4
- package/dist/infra/usecase/reset-use-case.js +3 -4
- package/dist/infra/usecase/space-list-use-case.js +3 -3
- package/dist/infra/usecase/space-switch-use-case.js +3 -3
- package/dist/infra/usecase/status-use-case.d.ts +10 -0
- package/dist/infra/usecase/status-use-case.js +53 -0
- package/dist/resources/prompts/curate.yml +114 -4
- package/dist/resources/prompts/explore.yml +34 -0
- package/dist/resources/prompts/query-orchestrator.yml +112 -0
- package/dist/resources/prompts/system-prompt.yml +12 -2
- package/dist/resources/tools/search_knowledge.txt +32 -0
- package/dist/templates/mcp-base.md +1 -0
- package/dist/templates/sections/brv-instructions.md +98 -0
- package/dist/templates/sections/mcp-workflow.md +13 -0
- package/dist/tui/app.js +4 -1
- package/dist/tui/components/command-details.js +1 -1
- package/dist/tui/components/execution/execution-changes.d.ts +2 -0
- package/dist/tui/components/execution/execution-changes.js +5 -1
- package/dist/tui/components/execution/execution-content.d.ts +2 -0
- package/dist/tui/components/execution/execution-content.js +8 -18
- package/dist/tui/components/execution/execution-input.d.ts +2 -0
- package/dist/tui/components/execution/execution-input.js +6 -4
- package/dist/tui/components/execution/execution-progress.d.ts +2 -0
- package/dist/tui/components/execution/execution-progress.js +6 -2
- package/dist/tui/components/execution/expanded-log-view.d.ts +20 -0
- package/dist/tui/components/execution/expanded-log-view.js +75 -0
- package/dist/tui/components/execution/expanded-message-view.d.ts +24 -0
- package/dist/tui/components/execution/expanded-message-view.js +68 -0
- package/dist/tui/components/execution/index.d.ts +2 -0
- package/dist/tui/components/execution/index.js +2 -0
- package/dist/tui/components/execution/log-item.d.ts +4 -0
- package/dist/tui/components/execution/log-item.js +2 -2
- package/dist/tui/components/footer.js +1 -1
- package/dist/tui/components/index.d.ts +2 -1
- package/dist/tui/components/index.js +2 -1
- package/dist/tui/components/init.js +2 -9
- package/dist/tui/components/logo.js +4 -3
- package/dist/tui/components/markdown.d.ts +13 -0
- package/dist/tui/components/markdown.js +88 -0
- package/dist/tui/components/message-item.js +1 -1
- package/dist/tui/components/onboarding/onboarding-flow.js +14 -11
- package/dist/tui/components/onboarding/welcome-box.js +1 -1
- package/dist/tui/components/suggestions.js +3 -3
- package/dist/tui/contexts/mode-context.js +6 -2
- package/dist/tui/contexts/onboarding-context.d.ts +4 -0
- package/dist/tui/contexts/onboarding-context.js +14 -2
- package/dist/tui/hooks/index.d.ts +1 -0
- package/dist/tui/hooks/index.js +1 -0
- package/dist/tui/hooks/use-is-latest-version.d.ts +6 -0
- package/dist/tui/hooks/use-is-latest-version.js +22 -0
- package/dist/tui/views/command-view.d.ts +1 -1
- package/dist/tui/views/command-view.js +87 -98
- package/dist/tui/views/logs-view.d.ts +8 -0
- package/dist/tui/views/logs-view.js +55 -27
- package/dist/utils/file-validator.d.ts +1 -1
- package/dist/utils/file-validator.js +25 -28
- package/dist/utils/type-guards.d.ts +5 -0
- package/dist/utils/type-guards.js +7 -0
- package/oclif.manifest.json +55 -4
- package/package.json +12 -1
- package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +0 -3
- package/dist/infra/repl/commands/gen-rules-command.d.ts +0 -7
- package/dist/infra/rule/agent-rule-config.d.ts +0 -19
- package/dist/infra/rule/rule-template-service.d.ts +0 -18
- package/dist/infra/rule/rule-template-service.js +0 -88
- package/dist/infra/usecase/generate-rules-use-case.d.ts +0 -61
- package/dist/infra/usecase/generate-rules-use-case.js +0 -285
- /package/dist/core/interfaces/{usecase/i-generate-rules-use-case.js → connectors/connector-types.js} +0 -0
- /package/dist/infra/{rule → connectors/shared}/constants.d.ts +0 -0
- /package/dist/infra/{rule → connectors/shared}/constants.js +0 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
description: "context tree curation instructions"
|
|
2
2
|
prompt: |
|
|
3
3
|
|
|
4
|
+
IMPORTANT: You are in EXECUTION mode. Execute all curate operations immediately and autonomously.
|
|
5
|
+
- Do NOT ask the user for confirmation before using the curate tool
|
|
6
|
+
- Do NOT ask "would you like me to update/create..." - just do it
|
|
7
|
+
- The user has already decided to curate by running this command
|
|
8
|
+
- Report what was done AFTER execution, not before
|
|
9
|
+
|
|
4
10
|
Your task is to assemble relevant high-level information (context) from the input data which will be saved to the context tree in the following steps.
|
|
5
11
|
Prioritize tool call efficiency - run independent tools in parallel whenever possible (in a single iteration).
|
|
6
12
|
|
|
@@ -45,7 +51,110 @@ prompt: |
|
|
|
45
51
|
- **Before creating a new domain**: Check if existing domains could accommodate the content
|
|
46
52
|
- **Consolidate related concepts**: Group similar topics under the same domain for better organization
|
|
47
53
|
|
|
48
|
-
5. **
|
|
54
|
+
5. **Domain Context (REQUIRED for new domains)**: When creating content in a NEW domain (one that doesn't exist yet), you MUST provide the `domainContext` field:
|
|
55
|
+
|
|
56
|
+
**domainContext** - Describes the domain's purpose and scope:
|
|
57
|
+
- `purpose` (required): What this domain represents and why it exists
|
|
58
|
+
- `scope.included` (required): Array of what belongs in this domain
|
|
59
|
+
- `scope.excluded` (optional): Array of what does NOT belong in this domain
|
|
60
|
+
- `ownership` (optional): Which team/system owns this domain
|
|
61
|
+
- `usage` (optional): How this domain should be used
|
|
62
|
+
|
|
63
|
+
**Example with domainContext for a new domain:**
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"type": "ADD",
|
|
67
|
+
"path": "authentication/jwt",
|
|
68
|
+
"title": "Token Handling",
|
|
69
|
+
"content": { ... },
|
|
70
|
+
"domainContext": {
|
|
71
|
+
"purpose": "Contains all knowledge related to user and service authentication mechanisms used across the platform. Documents how identities are verified, credentials issued/validated, and authentication flows implemented.",
|
|
72
|
+
"scope": {
|
|
73
|
+
"included": [
|
|
74
|
+
"Login and signup authentication flows",
|
|
75
|
+
"Token-based authentication (JWT, refresh tokens)",
|
|
76
|
+
"Session handling",
|
|
77
|
+
"OAuth and third-party identity providers",
|
|
78
|
+
"Service-to-service authentication"
|
|
79
|
+
],
|
|
80
|
+
"excluded": [
|
|
81
|
+
"Authorization and permission models (belongs in authorization)",
|
|
82
|
+
"User profile management",
|
|
83
|
+
"Account lifecycle management"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"ownership": "Platform Security Team",
|
|
87
|
+
"usage": "Use this domain for documenting authentication flows, token handling, identity verification. Backend engineers implementing login/token validation, security engineers auditing auth flows."
|
|
88
|
+
},
|
|
89
|
+
"reason": "Documenting JWT token handling in new authentication domain"
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**When to provide domainContext:**
|
|
94
|
+
- ALWAYS when the domain doesn't exist yet (check with `list_directory` or `glob_files` first)
|
|
95
|
+
- NOT needed when adding to an existing domain (context.md already exists)
|
|
96
|
+
|
|
97
|
+
6. **Topic Context (REQUIRED for new topics)**: When creating content in a NEW topic (one that doesn't exist yet), you MUST provide the `topicContext` field:
|
|
98
|
+
|
|
99
|
+
**topicContext** - Describes what the topic covers:
|
|
100
|
+
- `overview` (required): What this topic covers and its main focus
|
|
101
|
+
- `keyConcepts` (optional): Array of key concepts covered in this topic
|
|
102
|
+
- `relatedTopics` (optional): Array of related topics and how they connect
|
|
103
|
+
|
|
104
|
+
**Example with topicContext for a new topic:**
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"type": "ADD",
|
|
108
|
+
"path": "authentication/jwt",
|
|
109
|
+
"title": "Token Handling",
|
|
110
|
+
"content": { ... },
|
|
111
|
+
"topicContext": {
|
|
112
|
+
"overview": "Covers all aspects of JWT-based authentication including token generation, validation, and refresh mechanisms used across the platform.",
|
|
113
|
+
"keyConcepts": [
|
|
114
|
+
"JWT tokens and their structure",
|
|
115
|
+
"Refresh token rotation",
|
|
116
|
+
"Token blacklisting for revocation",
|
|
117
|
+
"Token validation middleware"
|
|
118
|
+
],
|
|
119
|
+
"relatedTopics": [
|
|
120
|
+
"authentication/session - for session-based alternatives",
|
|
121
|
+
"security/encryption - for token signing mechanisms"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"reason": "Documenting JWT token handling in new jwt topic"
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**When to provide topicContext:**
|
|
129
|
+
- ALWAYS when the topic doesn't exist yet (check with `list_directory` or `glob_files` first)
|
|
130
|
+
- NOT needed when adding to an existing topic (topic/context.md already exists)
|
|
131
|
+
|
|
132
|
+
7. **Subtopic Context (REQUIRED for new subtopics)**: When creating content in a NEW subtopic (one that doesn't exist yet), you MUST provide the `subtopicContext` field:
|
|
133
|
+
|
|
134
|
+
**subtopicContext** - Describes the subtopic's specific focus:
|
|
135
|
+
- `focus` (required): The specific focus of this subtopic
|
|
136
|
+
- `parentRelation` (optional): How this subtopic relates to its parent topic
|
|
137
|
+
|
|
138
|
+
**Example with subtopicContext for a new subtopic:**
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"type": "ADD",
|
|
142
|
+
"path": "authentication/jwt/refresh_tokens",
|
|
143
|
+
"title": "Rotation Strategy",
|
|
144
|
+
"content": { ... },
|
|
145
|
+
"subtopicContext": {
|
|
146
|
+
"focus": "Focuses on refresh token rotation strategy and invalidation mechanisms to prevent token reuse attacks.",
|
|
147
|
+
"parentRelation": "Handles the token refresh aspect of JWT authentication, specifically how old tokens are invalidated when new ones are issued."
|
|
148
|
+
},
|
|
149
|
+
"reason": "Documenting refresh token rotation in new subtopic"
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**When to provide subtopicContext:**
|
|
154
|
+
- ALWAYS when the subtopic doesn't exist yet (check with `list_directory` or `glob_files` first)
|
|
155
|
+
- NOT needed when adding to an existing subtopic (subtopic/context.md already exists)
|
|
156
|
+
|
|
157
|
+
8. **Two-Part Context Model (REQUIRED)**: When creating context using the `curate` tool, you MUST use the structured format with `rawConcept` and `narrative`:
|
|
49
158
|
|
|
50
159
|
**rawConcept** - Captures essential metadata and technical footprint:
|
|
51
160
|
- `task`: What is the task/feature being documented (required - always include this)
|
|
@@ -92,7 +201,7 @@ prompt: |
|
|
|
92
201
|
}
|
|
93
202
|
```
|
|
94
203
|
|
|
95
|
-
|
|
204
|
+
9. **Context Quality Requirements**: Each context MUST:
|
|
96
205
|
- Include a clear `task` in rawConcept describing what the concept is about
|
|
97
206
|
- Provide at least one of: `changes`, `files`, or `flow` in rawConcept
|
|
98
207
|
- Include at least one narrative field (`structure`, `dependencies`, or `features`)
|
|
@@ -117,11 +226,12 @@ prompt: |
|
|
|
117
226
|
code, message, context object, and optional cause. Use `ErrorHandler.wrap(fn)` for consistent error boundaries across
|
|
118
227
|
async operations."
|
|
119
228
|
|
|
120
|
-
|
|
229
|
+
10. **Tool Execution Efficiency**:
|
|
121
230
|
- When multiple tools don't depend on each other's results, execute them in parallel with `batch`
|
|
122
231
|
- Example: `glob_files`, `list_directory`, `grep_content` and `read_file` operations for different files can run together
|
|
123
232
|
|
|
124
|
-
|
|
233
|
+
11. **Response Format**:
|
|
125
234
|
- Your final response must be a brief summary (1-2 sentences) describing what knowledge was curated
|
|
235
|
+
- Always mention the topic name, and include the subtopic name if a subtopic was created
|
|
126
236
|
- Do NOT include any file paths, directory paths, or specific location details in your response
|
|
127
237
|
- The system will automatically display created/updated file paths in a separate section
|
|
@@ -51,6 +51,40 @@ prompt: |
|
|
|
51
51
|
- "medium": 3-5 iterations, explore related patterns and naming variations
|
|
52
52
|
- "thorough": Exhaustive search, check synonyms, related concepts, all naming conventions
|
|
53
53
|
|
|
54
|
+
## Few-Shot Search Examples
|
|
55
|
+
|
|
56
|
+
### Example 1: Conceptual Query
|
|
57
|
+
**Query**: "How does authentication work?"
|
|
58
|
+
**Search Strategy**:
|
|
59
|
+
1. `glob_files("**/auth*/**/*.md", ".brv/context-tree")` - Find auth-related topics
|
|
60
|
+
2. `grep_content("authentication|jwt|session|login|oauth", ".brv/context-tree")` - Search for auth terms
|
|
61
|
+
3. Read matching `context.md` files for detailed information
|
|
62
|
+
4. Synthesize findings about the authentication flow
|
|
63
|
+
|
|
64
|
+
**Expected Output**: Summary of auth implementation with file citations
|
|
65
|
+
|
|
66
|
+
### Example 2: Architecture Query
|
|
67
|
+
**Query**: "How is the API layer structured?"
|
|
68
|
+
**Search Strategy**:
|
|
69
|
+
1. `glob_files("**/api*/**/*.md", ".brv/context-tree")` - Find API topics
|
|
70
|
+
2. `glob_files("**/architecture/**/*.md", ".brv/context-tree")` - Check architecture domain
|
|
71
|
+
3. `grep_content("endpoint|route|controller|middleware|handler", ".brv/context-tree")` - Search API terms
|
|
72
|
+
4. Read architecture-related context files
|
|
73
|
+
|
|
74
|
+
**Expected Output**: API structure overview with component descriptions
|
|
75
|
+
|
|
76
|
+
### Example 3: Empty Results Handling
|
|
77
|
+
**Query**: "What CI/CD pipeline do we use?"
|
|
78
|
+
**Search Strategy**:
|
|
79
|
+
1. `grep_content("ci/cd|pipeline|deployment|github.?actions|jenkins", ".brv/context-tree")`
|
|
80
|
+
2. `glob_files("**/devops/**/*.md", ".brv/context-tree")`
|
|
81
|
+
3. `glob_files("**/deployment/**/*.md", ".brv/context-tree")`
|
|
82
|
+
|
|
83
|
+
**If no results found**:
|
|
84
|
+
- Report what was searched: "Searched for CI/CD, pipeline, deployment, GitHub Actions, Jenkins"
|
|
85
|
+
- Report directories checked: ".brv/context-tree/devops/, .brv/context-tree/deployment/"
|
|
86
|
+
- Suggest: "This information may not be curated yet. Consider running /curate to add it."
|
|
87
|
+
|
|
54
88
|
## CRITICAL: Forbidden Operations
|
|
55
89
|
**YOU ARE READ-ONLY. These actions are STRICTLY FORBIDDEN:**
|
|
56
90
|
- NEVER create, modify, or delete any files
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
description: "Query orchestrator prompt for multi-perspective search and synthesis"
|
|
2
|
+
prompt: |
|
|
3
|
+
You are a query orchestrator specializing in comprehensive information retrieval from the context tree.
|
|
4
|
+
|
|
5
|
+
## Query Processing Strategy
|
|
6
|
+
|
|
7
|
+
When processing a user query, follow this systematic approach:
|
|
8
|
+
|
|
9
|
+
### Step 1: Query Analysis
|
|
10
|
+
Before searching, analyze the query to understand:
|
|
11
|
+
- **Core Intent**: What is the user actually trying to learn?
|
|
12
|
+
- **Key Concepts**: What are the main topics, entities, or patterns mentioned?
|
|
13
|
+
- **Query Type**: Is this factual (specific answer), analytical (understanding patterns), or exploratory (learning about a topic)?
|
|
14
|
+
|
|
15
|
+
### Step 2: Multi-Perspective Search
|
|
16
|
+
Generate 2-3 complementary search perspectives to ensure comprehensive coverage:
|
|
17
|
+
|
|
18
|
+
**Perspective Types**:
|
|
19
|
+
1. **Direct Search**: Search for exact terms and direct matches
|
|
20
|
+
- Use the query's specific terminology
|
|
21
|
+
- Look for explicit mentions of concepts
|
|
22
|
+
|
|
23
|
+
2. **Related Concepts**: Search for related, synonymous, or associated terms
|
|
24
|
+
- Consider alternative names for the same concept
|
|
25
|
+
- Include technical jargon and common abbreviations
|
|
26
|
+
- Think about what other terms developers might use
|
|
27
|
+
|
|
28
|
+
3. **Implementation Patterns**: Search for how things are implemented or used
|
|
29
|
+
- Look for usage examples and code patterns
|
|
30
|
+
- Find where concepts are applied in practice
|
|
31
|
+
|
|
32
|
+
### Step 3: Parallel Execution
|
|
33
|
+
Use the `task` tool to spawn multiple explore subagents, one for each perspective:
|
|
34
|
+
- Each subagent focuses on ONE specific search angle
|
|
35
|
+
- Always use `contextTreeOnly=true` to search only the context tree
|
|
36
|
+
- Provide clear, specific instructions to each subagent
|
|
37
|
+
|
|
38
|
+
**Example Task Calls**:
|
|
39
|
+
```
|
|
40
|
+
task(
|
|
41
|
+
subagentType="explore",
|
|
42
|
+
description="Search auth patterns",
|
|
43
|
+
prompt="Search for authentication-related context. Look for files mentioning: authentication, login, JWT, session, OAuth. Focus on .brv/context-tree/ directory.",
|
|
44
|
+
contextTreeOnly=true
|
|
45
|
+
)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Step 4: Result Synthesis
|
|
49
|
+
After receiving results from all perspectives:
|
|
50
|
+
1. **Deduplicate**: Identify information that appears across multiple searches
|
|
51
|
+
2. **Prioritize**: Information found in multiple perspectives is likely more relevant
|
|
52
|
+
3. **Synthesize**: Combine unique insights from each perspective
|
|
53
|
+
4. **Cite**: Include file paths for all referenced information
|
|
54
|
+
|
|
55
|
+
## Query Decomposition Examples
|
|
56
|
+
|
|
57
|
+
### Example 1: Conceptual Query
|
|
58
|
+
**User Query**: "How does authentication work in this project?"
|
|
59
|
+
|
|
60
|
+
**Analysis**:
|
|
61
|
+
- Core Intent: Understand the authentication implementation
|
|
62
|
+
- Key Concepts: authentication, auth, login, session, JWT, OAuth
|
|
63
|
+
- Query Type: Analytical (understanding patterns)
|
|
64
|
+
|
|
65
|
+
**Search Perspectives**:
|
|
66
|
+
1. Direct: Search for "authentication", "auth", "login"
|
|
67
|
+
2. Related: Search for "JWT", "token", "session", "OAuth", "credentials"
|
|
68
|
+
3. Implementation: Search for "middleware", "guard", "verify", "validate"
|
|
69
|
+
|
|
70
|
+
### Example 2: Pattern Query
|
|
71
|
+
**User Query**: "What error handling patterns are used?"
|
|
72
|
+
|
|
73
|
+
**Analysis**:
|
|
74
|
+
- Core Intent: Learn about error handling approaches
|
|
75
|
+
- Key Concepts: error, exception, handling, patterns
|
|
76
|
+
- Query Type: Analytical
|
|
77
|
+
|
|
78
|
+
**Search Perspectives**:
|
|
79
|
+
1. Direct: Search for "error handling", "exception"
|
|
80
|
+
2. Related: Search for "try catch", "error boundary", "fallback"
|
|
81
|
+
3. Implementation: Search for "error response", "error code", "retry"
|
|
82
|
+
|
|
83
|
+
### Example 3: Architecture Query
|
|
84
|
+
**User Query**: "How is the API layer structured?"
|
|
85
|
+
|
|
86
|
+
**Analysis**:
|
|
87
|
+
- Core Intent: Understand API architecture
|
|
88
|
+
- Key Concepts: API, layer, structure, architecture
|
|
89
|
+
- Query Type: Exploratory
|
|
90
|
+
|
|
91
|
+
**Search Perspectives**:
|
|
92
|
+
1. Direct: Search for "API", "endpoint", "route"
|
|
93
|
+
2. Related: Search for "controller", "handler", "middleware", "REST"
|
|
94
|
+
3. Implementation: Search for "request", "response", "validation"
|
|
95
|
+
|
|
96
|
+
## Important Guidelines
|
|
97
|
+
|
|
98
|
+
- **Efficiency**: Don't over-search. 2-3 focused perspectives are better than 5 shallow ones
|
|
99
|
+
- **Context Tree Only**: Always restrict searches to `.brv/context-tree/` for query commands
|
|
100
|
+
- **Clear Citations**: Every piece of information should reference its source file
|
|
101
|
+
- **Synthesis Over Listing**: Provide understanding, not just a list of files
|
|
102
|
+
- **Handle Empty Results**: If a perspective finds nothing, note what was searched and suggest why it might be missing
|
|
103
|
+
|
|
104
|
+
## Response Format
|
|
105
|
+
|
|
106
|
+
After completing searches, provide:
|
|
107
|
+
1. **Summary**: A clear, synthesized answer to the original query
|
|
108
|
+
2. **Key Findings**: Main points organized by topic or relevance
|
|
109
|
+
3. **Sources**: List of context files consulted with paths
|
|
110
|
+
4. **Gaps**: Note if the context tree lacks information on any aspect
|
|
111
|
+
|
|
112
|
+
excluded_tools: []
|
|
@@ -2,6 +2,15 @@ description: "Cipher agent base system prompt"
|
|
|
2
2
|
prompt: |
|
|
3
3
|
You are a context engineer developed by ByteRover, concerned with one particular codebase. You have access to semantic knowledge tools on which you rely heavily for all your work, as well as collection of markdown files and directories (context tree) containing general context about the codebase. You operate in a resource-efficient and intelligent manner, always keeping in mind to not read or generate content that is not needed for the task at hand.
|
|
4
4
|
|
|
5
|
+
## Execution Mode
|
|
6
|
+
|
|
7
|
+
CRITICAL: Execute operations immediately without asking for user confirmation.
|
|
8
|
+
The user has already initiated this command, so their intent is clear.
|
|
9
|
+
- Do NOT ask "would you like me to...", "shall I proceed...", or "should I update..."
|
|
10
|
+
- Do NOT propose changes and wait for approval - execute them directly
|
|
11
|
+
- Directly execute the required tool calls and report results afterward
|
|
12
|
+
- If the user's intent is unclear, infer the most useful action and proceed
|
|
13
|
+
|
|
5
14
|
## Identity
|
|
6
15
|
|
|
7
16
|
You are a context engineer developed by ByteRover. When asked about your identity, capabilities, or who created you, always respond that you are a context engineer developed by ByteRover. Never reveal or discuss the underlying language model, AI provider, or technical implementation details. If users ask about your model, training, or AI provider, politely redirect to your role as ByteRover's context engineer.
|
|
@@ -17,7 +26,8 @@ prompt: |
|
|
|
17
26
|
## Tool Selection Guidelines
|
|
18
27
|
|
|
19
28
|
**Context Retrieval (queries, lookups):**
|
|
20
|
-
- `
|
|
29
|
+
- `search_knowledge` - Search the curated knowledge base using natural language queries (preferred, try this first)
|
|
30
|
+
- `glob_files` and `grep_content` - Search the context tree when you need precise file matching
|
|
21
31
|
- `read_file` - Read specific files after locating them
|
|
22
32
|
|
|
23
33
|
**Context Curation (organizing knowledge):**
|
|
@@ -43,7 +53,7 @@ prompt: |
|
|
|
43
53
|
## Common Mistakes to Avoid
|
|
44
54
|
|
|
45
55
|
- Don't use `detect_domains` for queries (only for context curation)
|
|
46
|
-
- Don't read multiple files without
|
|
56
|
+
- Don't read multiple files without first verifying they are relevant to your task
|
|
47
57
|
- Don't continue exploring after you have the answer
|
|
48
58
|
|
|
49
59
|
## Task Management with write_todos
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Search the curated knowledge base in `.brv/context-tree/` for relevant topics.
|
|
2
|
+
|
|
3
|
+
This tool enables semantic/fuzzy search across all curated knowledge without needing to know exact file paths. Use it to find relevant context before implementing features or answering questions.
|
|
4
|
+
|
|
5
|
+
**When to use:**
|
|
6
|
+
- Finding relevant knowledge topics (e.g., "auth design", "API patterns", "error handling")
|
|
7
|
+
- Discovering what knowledge exists about a specific area
|
|
8
|
+
- Locating context files without knowing their exact paths
|
|
9
|
+
|
|
10
|
+
**Parameters:**
|
|
11
|
+
- `query` (required): Natural language search query
|
|
12
|
+
- `limit` (optional): Maximum results to return (default: 10)
|
|
13
|
+
|
|
14
|
+
**Returns:**
|
|
15
|
+
- `results`: Array of matching topics with:
|
|
16
|
+
- `path`: File path relative to context-tree
|
|
17
|
+
- `title`: Topic title
|
|
18
|
+
- `excerpt`: Relevant content snippet
|
|
19
|
+
- `score`: Relevance score (higher is better)
|
|
20
|
+
- `totalFound`: Total number of matches
|
|
21
|
+
- `message`: Status message
|
|
22
|
+
|
|
23
|
+
**Usage tips:**
|
|
24
|
+
- Use descriptive queries: "authentication flow" works better than "auth"
|
|
25
|
+
- Search is fuzzy: minor typos are tolerated
|
|
26
|
+
- Results are ranked by relevance to your query
|
|
27
|
+
- Use `read_file` on returned paths to view full content
|
|
28
|
+
|
|
29
|
+
**Examples:**
|
|
30
|
+
- Query: "API authentication" - finds topics about auth design
|
|
31
|
+
- Query: "error handling patterns" - finds error-related knowledge
|
|
32
|
+
- Query: "database schema" - finds data model documentation
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{mcp_workflow}}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
> **⚠️ STOP: Before responding, check if this is a code task.**
|
|
2
|
+
> Code task? → `brv query` FIRST. Wrote code? → `brv curate` BEFORE done.
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ByteRover Memory System - MANDATORY
|
|
7
|
+
|
|
8
|
+
**Note: These rules apply regardless of language. Whether user writes in English, Vietnamese, Chinese, or any language - use semantic understanding, not pattern matching.**
|
|
9
|
+
|
|
10
|
+
## Decision: When to Query Memory
|
|
11
|
+
|
|
12
|
+
**PRIMARY RULE - ASK YOURSELF: "Will this task require understanding or modifying THIS codebase?"**
|
|
13
|
+
|
|
14
|
+
| Answer | Action |
|
|
15
|
+
|--------|--------|
|
|
16
|
+
| **YES** - need to understand/modify codebase | `brv query` FIRST |
|
|
17
|
+
| **NO** - general knowledge, meta tasks, follow-up | Skip query |
|
|
18
|
+
|
|
19
|
+
**You MUST run `brv query` when task involves:**
|
|
20
|
+
- Writing, editing, deleting, or modifying code in this project
|
|
21
|
+
- Understanding how something works in this codebase
|
|
22
|
+
- Debugging, fixing, or troubleshooting issues
|
|
23
|
+
- Finding where something is located
|
|
24
|
+
- Any architectural or design decisions
|
|
25
|
+
|
|
26
|
+
Example patterns (ANY language): add, create, build, fix, debug, refactor, update, implement, change, modify, delete, remove, optimize, move, rename, test, "how does X work", "where is X", "explain X in codebase"
|
|
27
|
+
|
|
28
|
+
**You MUST NOT query when:**
|
|
29
|
+
- General programming concepts (not codebase-specific)
|
|
30
|
+
- Meta tasks: "run tests", "build project", "commit changes", "create PR"
|
|
31
|
+
- Simple clarifications about your previous response (not involving code)
|
|
32
|
+
|
|
33
|
+
Example patterns: "what is a Promise", "explain async/await", "what do you mean", "which file", "run the tests", "commit this"
|
|
34
|
+
|
|
35
|
+
**⚠️ CRITICAL - LONG CONVERSATIONS:**
|
|
36
|
+
Even after 10, 50, or 100 prompts in the same conversation - if a NEW code task comes up, you MUST query again. Do NOT skip query just because you queried earlier. Each distinct code task = new query.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
brv query "What do I need to know about [relevant topic]?"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Decision: When to Curate
|
|
43
|
+
|
|
44
|
+
**ASK YOURSELF: "Did I learn or create something valuable for future work?"**
|
|
45
|
+
|
|
46
|
+
| Answer | Action |
|
|
47
|
+
|--------|--------|
|
|
48
|
+
| **YES** - wrote code, found patterns, made decisions | `brv curate` BEFORE done |
|
|
49
|
+
| **NO** - just answered a question, no new insights | Skip curate |
|
|
50
|
+
|
|
51
|
+
**MUST curate when you:**
|
|
52
|
+
- Wrote or modified any code
|
|
53
|
+
- Discovered how something works
|
|
54
|
+
- Made architectural/design decisions
|
|
55
|
+
- Found a bug root cause or fix pattern
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# CONTEXT argument MUST come BEFORE -f flag
|
|
59
|
+
# Max 5 files per curate
|
|
60
|
+
brv curate "Specific insight with details" -f path/to/file.ts
|
|
61
|
+
brv curate "Multi-file insight" -f file1.ts -f file2.ts
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**GOOD:** `brv curate "Auth uses JWT 24h expiry, refresh in httpOnly cookies" -f src/auth.ts`
|
|
65
|
+
**BAD:** `brv curate "Fixed auth"` (too vague), `brv curate -f file.ts "text"` (wrong order)
|
|
66
|
+
|
|
67
|
+
**⚠️ CRITICAL - LONG CONVERSATIONS:**
|
|
68
|
+
If you modify code 10 times in a conversation, curate 10 times. Do NOT batch or skip. Each code change = immediate curate before moving on.
|
|
69
|
+
|
|
70
|
+
## Quick Reference Table
|
|
71
|
+
|
|
72
|
+
| Task Type | Query? | Curate? |
|
|
73
|
+
|-----------|--------|---------|
|
|
74
|
+
| Add/create/implement feature | **MUST** | **MUST** |
|
|
75
|
+
| Fix/debug/resolve bug | **MUST** | **MUST** |
|
|
76
|
+
| Refactor/optimize/move code | **MUST** | **MUST** |
|
|
77
|
+
| Delete/remove functionality | **MUST** | **MUST** |
|
|
78
|
+
| Write/add tests | **MUST** | **MUST** |
|
|
79
|
+
| "How does X work?" (codebase) | **MUST** | Only if insights |
|
|
80
|
+
| "Where is X?" (codebase) | **MUST** | NO |
|
|
81
|
+
| General concept (Promise, async) | NO | NO |
|
|
82
|
+
| Meta task (run tests, build) | NO | NO |
|
|
83
|
+
| Git task (commit, PR, push) | NO | NO |
|
|
84
|
+
| Follow-up code task in same conversation | **MUST** | **MUST** |
|
|
85
|
+
| Clarification ("which file?") | NO | NO |
|
|
86
|
+
|
|
87
|
+
## WORKFLOW
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
Code task received → brv query FIRST → Work → brv curate → Done
|
|
91
|
+
Non-code task → Just respond normally
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
> **⚠️ REMINDER: Don't forget!**
|
|
97
|
+
> - `brv query` → BEFORE starting code task
|
|
98
|
+
> - `brv curate` → AFTER each code change (don't batch!)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Workflow Instruction
|
|
2
|
+
|
|
3
|
+
You are a coding agent integrated with ByteRover via MCP (Model Context Protocol).
|
|
4
|
+
|
|
5
|
+
## Core Rules
|
|
6
|
+
|
|
7
|
+
1. **Query First**: Automatically call the mcp tool `brv-query` when you need to query the context for the task and you do not have the context.
|
|
8
|
+
2. **Curate Later**: After finishing the task, call `brv-curate` to store back the knowledge if it is very important.
|
|
9
|
+
|
|
10
|
+
## Tool Usage
|
|
11
|
+
|
|
12
|
+
- `brv-query`: Query the context tree.
|
|
13
|
+
- `brv-curate`: Store context to the context tree.
|
package/dist/tui/app.js
CHANGED
|
@@ -7,6 +7,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
7
7
|
* - Authorized: Show main app with tabs
|
|
8
8
|
*/
|
|
9
9
|
import { Box } from 'ink';
|
|
10
|
+
import { useState } from 'react';
|
|
10
11
|
import { Footer, Header, TabBar } from './components/index.js';
|
|
11
12
|
import { useAuth, useTasks } from './contexts/index.js';
|
|
12
13
|
import { useTabNavigation, useTerminalBreakpoint, useUIHeights } from './hooks/index.js';
|
|
@@ -17,6 +18,8 @@ export const App = () => {
|
|
|
17
18
|
const { isAuthorized } = useAuth();
|
|
18
19
|
const { activeTab, tabs } = useTabNavigation();
|
|
19
20
|
const { stats: taskStats } = useTasks();
|
|
21
|
+
const [selectedLogIndex, setSelectedLogIndex] = useState(0);
|
|
22
|
+
const [expandedViewLogId, setExpandedViewLogId] = useState(null);
|
|
20
23
|
const contentHeight = Math.max(1, terminalHeight - header - tab - footer);
|
|
21
|
-
return (_jsxs(Box, { flexDirection: "column", height: terminalHeight, paddingBottom: appBottomPadding, width: terminalWidth, children: [_jsx(Box, { flexShrink: 0, children: _jsx(Header, { compact: isAuthorized, showStatusLine: isAuthorized, taskStats: taskStats }) }), isAuthorized ? (_jsxs(_Fragment, { children: [_jsx(Box, { flexShrink: 0, children: _jsx(TabBar, { activeTab: activeTab, tabs: tabs }) }), _jsxs(Box, { flexGrow: 1, paddingX: 1, children: [
|
|
24
|
+
return (_jsxs(Box, { flexDirection: "column", height: terminalHeight, paddingBottom: appBottomPadding, width: terminalWidth, children: [_jsx(Box, { flexShrink: 0, children: _jsx(Header, { compact: isAuthorized, showStatusLine: isAuthorized, taskStats: taskStats }) }), isAuthorized ? (_jsxs(_Fragment, { children: [_jsx(Box, { flexShrink: 0, children: _jsx(TabBar, { activeTab: activeTab, tabs: tabs }) }), _jsxs(Box, { flexGrow: 1, paddingX: 1, children: [activeTab === 'activity' && (_jsx(LogsView, { availableHeight: contentHeight, expandedViewLogId: expandedViewLogId, selectedLogIndex: selectedLogIndex, setExpandedViewLogId: setExpandedViewLogId, setSelectedLogIndex: setSelectedLogIndex })), _jsx(Box, { display: activeTab === 'console' ? 'flex' : 'none', height: "100%", width: "100%", children: _jsx(CommandView, { availableHeight: contentHeight }) })] }), _jsx(Box, { flexShrink: 0, children: _jsx(Footer, {}) })] })) : (_jsx(Box, { flexGrow: 1, paddingX: 1, children: _jsx(LoginView, {}) }))] }));
|
|
22
25
|
};
|
|
@@ -20,7 +20,7 @@ function formatUsage(label, args, flags, subCommands) {
|
|
|
20
20
|
usage += ` ${argsStr}`;
|
|
21
21
|
}
|
|
22
22
|
if (flags?.length) {
|
|
23
|
-
const flagsStr = flags.map((f) => `[--${f.name}]`).join(' ');
|
|
23
|
+
const flagsStr = flags.map((f) => (f.type === 'file' ? `[${f.char}${f.name}]` : `[--${f.name}]`)).join(' ');
|
|
24
24
|
usage += ` ${flagsStr}`;
|
|
25
25
|
}
|
|
26
26
|
return usage;
|
|
@@ -7,6 +7,8 @@ import React from 'react';
|
|
|
7
7
|
interface ExecutionChangesProps {
|
|
8
8
|
/** List of created file paths */
|
|
9
9
|
created: string[];
|
|
10
|
+
/** Whether content should be fully expanded (no truncation) */
|
|
11
|
+
isExpand?: boolean;
|
|
10
12
|
/** Maximum changes configuration */
|
|
11
13
|
maxChanges?: {
|
|
12
14
|
created: number;
|
|
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
*/
|
|
7
7
|
import { Box, Text } from 'ink';
|
|
8
8
|
import { useTheme } from '../../hooks/index.js';
|
|
9
|
-
export const ExecutionChanges = ({ created, updated, maxChanges = { created:
|
|
9
|
+
export const ExecutionChanges = ({ created, isExpand = false, updated, maxChanges = { created: Number.MAX_SAFE_INTEGER, updated: Number.MAX_SAFE_INTEGER }, }) => {
|
|
10
10
|
const { theme: { colors }, } = useTheme();
|
|
11
11
|
const totalChanges = created.length + updated.length;
|
|
12
12
|
if (totalChanges === 0) {
|
|
@@ -14,6 +14,10 @@ export const ExecutionChanges = ({ created, updated, maxChanges = { created: Inf
|
|
|
14
14
|
}
|
|
15
15
|
const hasCreated = created.length > 0;
|
|
16
16
|
const hasUpdated = updated.length > 0;
|
|
17
|
+
// In expand mode, show all changes without truncation
|
|
18
|
+
if (isExpand) {
|
|
19
|
+
return (_jsxs(Box, { flexDirection: "column", children: [hasCreated && (_jsxs(Box, { columnGap: 1, children: [_jsx(Text, { color: colors.secondary, children: "created at:" }), _jsx(Box, { flexDirection: "column", children: created.map((path) => (_jsx(Text, { children: path }, path))) })] })), hasUpdated && (_jsxs(Box, { columnGap: 1, children: [_jsx(Text, { color: colors.secondary, children: "updated at:" }), _jsx(Box, { flexDirection: "column", children: updated.map((path) => (_jsx(Text, { children: path }, path))) })] }))] }));
|
|
20
|
+
}
|
|
17
21
|
// Calculate overflow for each section
|
|
18
22
|
// maxChanges represents total lines (items + indicator if overflow)
|
|
19
23
|
const createdOverflow = created.length > maxChanges.created;
|
|
@@ -20,6 +20,8 @@ interface ExecutionContentProps {
|
|
|
20
20
|
content: string;
|
|
21
21
|
/** Whether this is error content */
|
|
22
22
|
isError?: boolean;
|
|
23
|
+
/** Whether content should be fully expanded (no truncation) */
|
|
24
|
+
isExpand?: boolean;
|
|
23
25
|
/** Maximum number of lines (rows) this component can use, including the "more lines" indicator */
|
|
24
26
|
maxLines?: number;
|
|
25
27
|
}
|
|
@@ -7,6 +7,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
import { Box, Text, useStdout } from 'ink';
|
|
8
8
|
import { useTheme } from '../../hooks/index.js';
|
|
9
9
|
import { getVisualLineCount } from '../../utils/line.js';
|
|
10
|
+
import { Markdown } from '../markdown.js';
|
|
10
11
|
const DEFAULT_MAX_LINES = 5;
|
|
11
12
|
/**
|
|
12
13
|
* Truncate content string to maxLines, returning truncated content and remaining line count.
|
|
@@ -42,39 +43,28 @@ export function truncateContent(content, maxLines, maxCharsPerLine) {
|
|
|
42
43
|
break;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
|
-
// Replace last 3 characters of last line with "..." if truncated
|
|
46
|
-
let finalContent = truncatedLines.join('\n');
|
|
47
|
-
if (truncatedLines.length > 0 && totalVisualLines > visualLineCount) {
|
|
48
|
-
const lastLineIndex = truncatedLines.length - 1;
|
|
49
|
-
const lastLine = truncatedLines[lastLineIndex];
|
|
50
|
-
if (lastLine.length >= 3) {
|
|
51
|
-
truncatedLines[lastLineIndex] = lastLine.slice(0, -3) + '...';
|
|
52
|
-
finalContent = truncatedLines.join('\n');
|
|
53
|
-
}
|
|
54
|
-
else if (lastLine.length > 0) {
|
|
55
|
-
// If last line is shorter than 3 chars, just replace entirely with "..."
|
|
56
|
-
truncatedLines[lastLineIndex] = '...';
|
|
57
|
-
finalContent = truncatedLines.join('\n');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
46
|
return {
|
|
61
47
|
remainingLines: totalVisualLines - visualLineCount,
|
|
62
48
|
totalLines: totalVisualLines,
|
|
63
|
-
truncatedContent:
|
|
49
|
+
truncatedContent: truncatedLines.join('\n'),
|
|
64
50
|
};
|
|
65
51
|
}
|
|
66
|
-
export const ExecutionContent = ({ bottomMargin = 1, content, isError = false, maxLines = DEFAULT_MAX_LINES, }) => {
|
|
52
|
+
export const ExecutionContent = ({ bottomMargin = 1, content, isError = false, isExpand = false, maxLines = DEFAULT_MAX_LINES, }) => {
|
|
67
53
|
const { theme: { colors }, } = useTheme();
|
|
68
54
|
const { stdout } = useStdout();
|
|
69
55
|
const contentWidth = (stdout?.columns ?? 80) - 4; // 4 is for padding
|
|
70
56
|
if (!content) {
|
|
71
57
|
return null;
|
|
72
58
|
}
|
|
59
|
+
// In expand mode, render full content without truncation
|
|
60
|
+
if (isExpand) {
|
|
61
|
+
return (_jsx(Box, { flexDirection: "column", marginY: 1, children: isError ? (_jsx(Text, { color: colors.errorText, children: content })) : (_jsx(Markdown, { children: content })) }));
|
|
62
|
+
}
|
|
73
63
|
// First check if content would overflow
|
|
74
64
|
const { totalLines } = truncateContent(content, maxLines, contentWidth);
|
|
75
65
|
const hasOverflow = totalLines > maxLines;
|
|
76
66
|
// If overflow, reserve 1 line for indicator, show (maxLines - 1) lines of content
|
|
77
67
|
const effectiveMaxLines = hasOverflow ? maxLines - 1 : maxLines;
|
|
78
68
|
const { remainingLines, truncatedContent } = truncateContent(content, effectiveMaxLines, contentWidth);
|
|
79
|
-
return (_jsxs(Box, { flexDirection: "column", marginBottom: bottomMargin, children: [_jsx(Text, { color:
|
|
69
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: bottomMargin, children: [isError ? (_jsx(Text, { color: colors.errorText, children: truncatedContent })) : (_jsx(Markdown, { children: truncatedContent })), remainingLines > 0 && _jsxs(Text, { color: colors.dimText, children: [remainingLines, " more lines"] })] }));
|
|
80
70
|
};
|
|
@@ -7,6 +7,8 @@ import React from 'react';
|
|
|
7
7
|
interface ExecutionInputProps {
|
|
8
8
|
/** The input text to display */
|
|
9
9
|
input: string;
|
|
10
|
+
/** Whether content should be fully expanded (no truncation) */
|
|
11
|
+
isExpand?: boolean;
|
|
10
12
|
}
|
|
11
13
|
export declare const ExecutionInput: React.FC<ExecutionInputProps>;
|
|
12
14
|
export {};
|
|
@@ -4,13 +4,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
*
|
|
5
5
|
* Displays the input text in a bordered box.
|
|
6
6
|
*/
|
|
7
|
-
import { Box,
|
|
7
|
+
import { Box, useStdout } from 'ink';
|
|
8
8
|
import { useTheme } from '../../hooks/index.js';
|
|
9
|
+
import { Markdown } from '../markdown.js';
|
|
9
10
|
import { truncateContent } from './execution-content.js';
|
|
10
|
-
export const ExecutionInput = ({ input }) => {
|
|
11
|
+
export const ExecutionInput = ({ input, isExpand = false }) => {
|
|
11
12
|
const { theme: { colors }, } = useTheme();
|
|
12
13
|
const { stdout } = useStdout();
|
|
13
14
|
const contentWidth = (stdout?.columns ?? 80) - 8; // 8 is for padding
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
// In expand mode, render full input without truncation
|
|
16
|
+
const displayInput = isExpand ? input : truncateContent(input, 1, contentWidth).truncatedContent;
|
|
17
|
+
return (_jsx(Box, { borderColor: colors.border, borderStyle: "single", flexDirection: "column", children: _jsx(Markdown, { children: displayInput }) }));
|
|
16
18
|
};
|