@shareai-lab/kode 1.0.70 → 1.0.71

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 (253) hide show
  1. package/README.md +202 -76
  2. package/README.zh-CN.md +246 -0
  3. package/cli.js +62 -0
  4. package/package.json +45 -25
  5. package/scripts/postinstall.js +56 -0
  6. package/src/ProjectOnboarding.tsx +180 -0
  7. package/src/Tool.ts +53 -0
  8. package/src/commands/approvedTools.ts +53 -0
  9. package/src/commands/bug.tsx +20 -0
  10. package/src/commands/clear.ts +43 -0
  11. package/src/commands/compact.ts +120 -0
  12. package/src/commands/config.tsx +19 -0
  13. package/src/commands/cost.ts +18 -0
  14. package/src/commands/ctx_viz.ts +209 -0
  15. package/src/commands/doctor.ts +24 -0
  16. package/src/commands/help.tsx +19 -0
  17. package/src/commands/init.ts +37 -0
  18. package/src/commands/listen.ts +42 -0
  19. package/src/commands/login.tsx +51 -0
  20. package/src/commands/logout.tsx +40 -0
  21. package/src/commands/mcp.ts +41 -0
  22. package/src/commands/model.tsx +40 -0
  23. package/src/commands/modelstatus.tsx +20 -0
  24. package/src/commands/onboarding.tsx +34 -0
  25. package/src/commands/pr_comments.ts +59 -0
  26. package/src/commands/refreshCommands.ts +54 -0
  27. package/src/commands/release-notes.ts +34 -0
  28. package/src/commands/resume.tsx +30 -0
  29. package/src/commands/review.ts +49 -0
  30. package/src/commands/terminalSetup.ts +221 -0
  31. package/src/commands.ts +136 -0
  32. package/src/components/ApproveApiKey.tsx +93 -0
  33. package/src/components/AsciiLogo.tsx +13 -0
  34. package/src/components/AutoUpdater.tsx +148 -0
  35. package/src/components/Bug.tsx +367 -0
  36. package/src/components/Config.tsx +289 -0
  37. package/src/components/ConsoleOAuthFlow.tsx +326 -0
  38. package/src/components/Cost.tsx +23 -0
  39. package/src/components/CostThresholdDialog.tsx +46 -0
  40. package/src/components/CustomSelect/option-map.ts +42 -0
  41. package/src/components/CustomSelect/select-option.tsx +52 -0
  42. package/src/components/CustomSelect/select.tsx +143 -0
  43. package/src/components/CustomSelect/use-select-state.ts +414 -0
  44. package/src/components/CustomSelect/use-select.ts +35 -0
  45. package/src/components/FallbackToolUseRejectedMessage.tsx +15 -0
  46. package/src/components/FileEditToolUpdatedMessage.tsx +66 -0
  47. package/src/components/Help.tsx +215 -0
  48. package/src/components/HighlightedCode.tsx +33 -0
  49. package/src/components/InvalidConfigDialog.tsx +113 -0
  50. package/src/components/Link.tsx +32 -0
  51. package/src/components/LogSelector.tsx +86 -0
  52. package/src/components/Logo.tsx +145 -0
  53. package/src/components/MCPServerApprovalDialog.tsx +100 -0
  54. package/src/components/MCPServerDialogCopy.tsx +25 -0
  55. package/src/components/MCPServerMultiselectDialog.tsx +109 -0
  56. package/src/components/Message.tsx +219 -0
  57. package/src/components/MessageResponse.tsx +15 -0
  58. package/src/components/MessageSelector.tsx +211 -0
  59. package/src/components/ModeIndicator.tsx +88 -0
  60. package/src/components/ModelConfig.tsx +301 -0
  61. package/src/components/ModelListManager.tsx +223 -0
  62. package/src/components/ModelSelector.tsx +3208 -0
  63. package/src/components/ModelStatusDisplay.tsx +228 -0
  64. package/src/components/Onboarding.tsx +274 -0
  65. package/src/components/PressEnterToContinue.tsx +11 -0
  66. package/src/components/PromptInput.tsx +710 -0
  67. package/src/components/SentryErrorBoundary.ts +33 -0
  68. package/src/components/Spinner.tsx +129 -0
  69. package/src/components/StructuredDiff.tsx +184 -0
  70. package/src/components/TextInput.tsx +246 -0
  71. package/src/components/TokenWarning.tsx +31 -0
  72. package/src/components/ToolUseLoader.tsx +40 -0
  73. package/src/components/TrustDialog.tsx +106 -0
  74. package/src/components/binary-feedback/BinaryFeedback.tsx +63 -0
  75. package/src/components/binary-feedback/BinaryFeedbackOption.tsx +111 -0
  76. package/src/components/binary-feedback/BinaryFeedbackView.tsx +172 -0
  77. package/src/components/binary-feedback/utils.ts +220 -0
  78. package/src/components/messages/AssistantBashOutputMessage.tsx +22 -0
  79. package/src/components/messages/AssistantLocalCommandOutputMessage.tsx +45 -0
  80. package/src/components/messages/AssistantRedactedThinkingMessage.tsx +19 -0
  81. package/src/components/messages/AssistantTextMessage.tsx +144 -0
  82. package/src/components/messages/AssistantThinkingMessage.tsx +40 -0
  83. package/src/components/messages/AssistantToolUseMessage.tsx +123 -0
  84. package/src/components/messages/UserBashInputMessage.tsx +28 -0
  85. package/src/components/messages/UserCommandMessage.tsx +30 -0
  86. package/src/components/messages/UserKodingInputMessage.tsx +28 -0
  87. package/src/components/messages/UserPromptMessage.tsx +35 -0
  88. package/src/components/messages/UserTextMessage.tsx +39 -0
  89. package/src/components/messages/UserToolResultMessage/UserToolCanceledMessage.tsx +12 -0
  90. package/src/components/messages/UserToolResultMessage/UserToolErrorMessage.tsx +36 -0
  91. package/src/components/messages/UserToolResultMessage/UserToolRejectMessage.tsx +31 -0
  92. package/src/components/messages/UserToolResultMessage/UserToolResultMessage.tsx +57 -0
  93. package/src/components/messages/UserToolResultMessage/UserToolSuccessMessage.tsx +35 -0
  94. package/src/components/messages/UserToolResultMessage/utils.tsx +56 -0
  95. package/src/components/permissions/BashPermissionRequest/BashPermissionRequest.tsx +121 -0
  96. package/src/components/permissions/FallbackPermissionRequest.tsx +155 -0
  97. package/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx +182 -0
  98. package/src/components/permissions/FileEditPermissionRequest/FileEditToolDiff.tsx +75 -0
  99. package/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx +164 -0
  100. package/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.tsx +81 -0
  101. package/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.tsx +242 -0
  102. package/src/components/permissions/PermissionRequest.tsx +103 -0
  103. package/src/components/permissions/PermissionRequestTitle.tsx +69 -0
  104. package/src/components/permissions/hooks.ts +44 -0
  105. package/src/components/permissions/toolUseOptions.ts +59 -0
  106. package/src/components/permissions/utils.ts +23 -0
  107. package/src/constants/betas.ts +5 -0
  108. package/src/constants/claude-asterisk-ascii-art.tsx +238 -0
  109. package/src/constants/figures.ts +4 -0
  110. package/src/constants/keys.ts +3 -0
  111. package/src/constants/macros.ts +6 -0
  112. package/src/constants/models.ts +935 -0
  113. package/src/constants/oauth.ts +18 -0
  114. package/src/constants/product.ts +17 -0
  115. package/src/constants/prompts.ts +177 -0
  116. package/src/constants/releaseNotes.ts +7 -0
  117. package/src/context/PermissionContext.tsx +149 -0
  118. package/src/context.ts +278 -0
  119. package/src/cost-tracker.ts +84 -0
  120. package/src/entrypoints/cli.tsx +1498 -0
  121. package/src/entrypoints/mcp.ts +176 -0
  122. package/src/history.ts +25 -0
  123. package/src/hooks/useApiKeyVerification.ts +59 -0
  124. package/src/hooks/useArrowKeyHistory.ts +55 -0
  125. package/src/hooks/useCanUseTool.ts +138 -0
  126. package/src/hooks/useCancelRequest.ts +39 -0
  127. package/src/hooks/useDoublePress.ts +42 -0
  128. package/src/hooks/useExitOnCtrlCD.ts +31 -0
  129. package/src/hooks/useInterval.ts +25 -0
  130. package/src/hooks/useLogMessages.ts +16 -0
  131. package/src/hooks/useLogStartupTime.ts +12 -0
  132. package/src/hooks/useNotifyAfterTimeout.ts +65 -0
  133. package/src/hooks/usePermissionRequestLogging.ts +44 -0
  134. package/src/hooks/useSlashCommandTypeahead.ts +137 -0
  135. package/src/hooks/useTerminalSize.ts +49 -0
  136. package/src/hooks/useTextInput.ts +315 -0
  137. package/src/messages.ts +37 -0
  138. package/src/permissions.ts +268 -0
  139. package/src/query.ts +704 -0
  140. package/src/screens/ConfigureNpmPrefix.tsx +197 -0
  141. package/src/screens/Doctor.tsx +219 -0
  142. package/src/screens/LogList.tsx +68 -0
  143. package/src/screens/REPL.tsx +792 -0
  144. package/src/screens/ResumeConversation.tsx +68 -0
  145. package/src/services/browserMocks.ts +66 -0
  146. package/src/services/claude.ts +1947 -0
  147. package/src/services/customCommands.ts +683 -0
  148. package/src/services/fileFreshness.ts +377 -0
  149. package/src/services/mcpClient.ts +564 -0
  150. package/src/services/mcpServerApproval.tsx +50 -0
  151. package/src/services/notifier.ts +40 -0
  152. package/src/services/oauth.ts +357 -0
  153. package/src/services/openai.ts +796 -0
  154. package/src/services/sentry.ts +3 -0
  155. package/src/services/statsig.ts +171 -0
  156. package/src/services/statsigStorage.ts +86 -0
  157. package/src/services/systemReminder.ts +406 -0
  158. package/src/services/vcr.ts +161 -0
  159. package/src/tools/ArchitectTool/ArchitectTool.tsx +122 -0
  160. package/src/tools/ArchitectTool/prompt.ts +15 -0
  161. package/src/tools/AskExpertModelTool/AskExpertModelTool.tsx +505 -0
  162. package/src/tools/BashTool/BashTool.tsx +270 -0
  163. package/src/tools/BashTool/BashToolResultMessage.tsx +38 -0
  164. package/src/tools/BashTool/OutputLine.tsx +48 -0
  165. package/src/tools/BashTool/prompt.ts +174 -0
  166. package/src/tools/BashTool/utils.ts +56 -0
  167. package/src/tools/FileEditTool/FileEditTool.tsx +316 -0
  168. package/src/tools/FileEditTool/prompt.ts +51 -0
  169. package/src/tools/FileEditTool/utils.ts +58 -0
  170. package/src/tools/FileReadTool/FileReadTool.tsx +371 -0
  171. package/src/tools/FileReadTool/prompt.ts +7 -0
  172. package/src/tools/FileWriteTool/FileWriteTool.tsx +297 -0
  173. package/src/tools/FileWriteTool/prompt.ts +10 -0
  174. package/src/tools/GlobTool/GlobTool.tsx +119 -0
  175. package/src/tools/GlobTool/prompt.ts +8 -0
  176. package/src/tools/GrepTool/GrepTool.tsx +147 -0
  177. package/src/tools/GrepTool/prompt.ts +11 -0
  178. package/src/tools/MCPTool/MCPTool.tsx +106 -0
  179. package/src/tools/MCPTool/prompt.ts +3 -0
  180. package/src/tools/MemoryReadTool/MemoryReadTool.tsx +127 -0
  181. package/src/tools/MemoryReadTool/prompt.ts +3 -0
  182. package/src/tools/MemoryWriteTool/MemoryWriteTool.tsx +89 -0
  183. package/src/tools/MemoryWriteTool/prompt.ts +3 -0
  184. package/src/tools/MultiEditTool/MultiEditTool.tsx +366 -0
  185. package/src/tools/MultiEditTool/prompt.ts +45 -0
  186. package/src/tools/NotebookEditTool/NotebookEditTool.tsx +298 -0
  187. package/src/tools/NotebookEditTool/prompt.ts +3 -0
  188. package/src/tools/NotebookReadTool/NotebookReadTool.tsx +266 -0
  189. package/src/tools/NotebookReadTool/prompt.ts +3 -0
  190. package/src/tools/StickerRequestTool/StickerRequestTool.tsx +93 -0
  191. package/src/tools/StickerRequestTool/prompt.ts +19 -0
  192. package/src/tools/TaskTool/TaskTool.tsx +382 -0
  193. package/src/tools/TaskTool/constants.ts +1 -0
  194. package/src/tools/TaskTool/prompt.ts +56 -0
  195. package/src/tools/ThinkTool/ThinkTool.tsx +56 -0
  196. package/src/tools/ThinkTool/prompt.ts +12 -0
  197. package/src/tools/TodoWriteTool/TodoWriteTool.tsx +289 -0
  198. package/src/tools/TodoWriteTool/prompt.ts +63 -0
  199. package/src/tools/lsTool/lsTool.tsx +269 -0
  200. package/src/tools/lsTool/prompt.ts +2 -0
  201. package/src/tools.ts +63 -0
  202. package/src/types/PermissionMode.ts +120 -0
  203. package/src/types/RequestContext.ts +72 -0
  204. package/src/utils/Cursor.ts +436 -0
  205. package/src/utils/PersistentShell.ts +373 -0
  206. package/src/utils/agentStorage.ts +97 -0
  207. package/src/utils/array.ts +3 -0
  208. package/src/utils/ask.tsx +98 -0
  209. package/src/utils/auth.ts +13 -0
  210. package/src/utils/autoCompactCore.ts +223 -0
  211. package/src/utils/autoUpdater.ts +318 -0
  212. package/src/utils/betas.ts +20 -0
  213. package/src/utils/browser.ts +14 -0
  214. package/src/utils/cleanup.ts +72 -0
  215. package/src/utils/commands.ts +261 -0
  216. package/src/utils/config.ts +771 -0
  217. package/src/utils/conversationRecovery.ts +54 -0
  218. package/src/utils/debugLogger.ts +1123 -0
  219. package/src/utils/diff.ts +42 -0
  220. package/src/utils/env.ts +57 -0
  221. package/src/utils/errors.ts +21 -0
  222. package/src/utils/exampleCommands.ts +108 -0
  223. package/src/utils/execFileNoThrow.ts +51 -0
  224. package/src/utils/expertChatStorage.ts +136 -0
  225. package/src/utils/file.ts +402 -0
  226. package/src/utils/fileRecoveryCore.ts +71 -0
  227. package/src/utils/format.tsx +44 -0
  228. package/src/utils/generators.ts +62 -0
  229. package/src/utils/git.ts +92 -0
  230. package/src/utils/globalLogger.ts +77 -0
  231. package/src/utils/http.ts +10 -0
  232. package/src/utils/imagePaste.ts +38 -0
  233. package/src/utils/json.ts +13 -0
  234. package/src/utils/log.ts +382 -0
  235. package/src/utils/markdown.ts +213 -0
  236. package/src/utils/messageContextManager.ts +289 -0
  237. package/src/utils/messages.tsx +938 -0
  238. package/src/utils/model.ts +836 -0
  239. package/src/utils/permissions/filesystem.ts +118 -0
  240. package/src/utils/ripgrep.ts +167 -0
  241. package/src/utils/sessionState.ts +49 -0
  242. package/src/utils/state.ts +25 -0
  243. package/src/utils/style.ts +29 -0
  244. package/src/utils/terminal.ts +49 -0
  245. package/src/utils/theme.ts +122 -0
  246. package/src/utils/thinking.ts +144 -0
  247. package/src/utils/todoStorage.ts +431 -0
  248. package/src/utils/tokens.ts +43 -0
  249. package/src/utils/toolExecutionController.ts +163 -0
  250. package/src/utils/unaryLogging.ts +26 -0
  251. package/src/utils/user.ts +37 -0
  252. package/src/utils/validate.ts +165 -0
  253. package/cli.mjs +0 -1803
package/README.md CHANGED
@@ -1,120 +1,246 @@
1
- # Kode With Agent
1
+ # Kode - AI Assistant for Your Terminal
2
2
 
3
- You can see this as open-cc for everyone, agent-system design is in [./system-design.md](./system-design.md)
3
+ [![npm version](https://badge.fury.io/js/@shareai-lab%2Fkode.svg)](https://www.npmjs.com/package/@shareai-lab/kode)
4
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
5
+
6
+ [中文文档](README.zh-CN.md) | [Contributing](CONTRIBUTING.md) | [Documentation](docs/)
7
+
8
+ Kode is a powerful AI assistant that lives in your terminal. It can understand your codebase, edit files, run commands, and handle entire workflows for you.
4
9
 
5
10
  ## Features
6
11
 
7
- - 🛠️ **Code Analysis & Fixes** - Analyzes and improves your codebase
8
- - 📖 **Code Explanation** - Explains complex functions and logic
9
- - 🧪 **Test Execution** - Runs tests and shell commands
10
- - 🔧 **Workflow Automation** - Handles entire development workflows
11
- - 🤖 **Multi-Model Support** - Works with any OpenAI-compatible API
12
- - 🎯 **Many Built-in Tools** - File operations, shell execution, notebooks, and more
13
- - 💾 **Smart Checkpoints** - Intelligent project state management and recovery
14
- - 🌿 **Worktree Workflows** - Isolated development environments for features
12
+ - 🤖 **AI-Powered Assistance** - Uses advanced AI models to understand and respond to your requests
13
+ - 🔄 **Multi-Model Collaboration** - Flexibly switch and combine multiple AI models to leverage their unique strengths
14
+ - 📝 **Code Editing** - Directly edit files with intelligent suggestions and improvements
15
+ - 🔍 **Codebase Understanding** - Analyzes your project structure and code relationships
16
+ - 🚀 **Command Execution** - Run shell commands and see results in real-time
17
+ - 🛠️ **Workflow Automation** - Handle complex development tasks with simple prompts
18
+ - 🎨 **Interactive UI** - Beautiful terminal interface with syntax highlighting
19
+ - 🔌 **Tool System** - Extensible architecture with specialized tools for different tasks
20
+ - 💾 **Context Management** - Smart context handling to maintain conversation continuity
15
21
 
16
22
  ## Installation
17
23
 
18
24
  ```bash
19
- # Install with npm
20
25
  npm install -g @shareai-lab/kode
26
+ ```
27
+
28
+ After installation, you can use any of these commands:
29
+ - `kode` - Primary command
30
+ - `kwa` - Kode With Agent (alternative)
31
+ - `kd` - Ultra-short alias
21
32
 
22
- # Install with pnpm
23
- pnpm install -g @shareai-lab/kode
33
+ ## Usage
24
34
 
25
- # Install with yarn
26
- yarn global add @shareai-lab/kode
35
+ ### Interactive Mode
36
+ Start an interactive session:
37
+ ```bash
38
+ kode
39
+ # or
40
+ kwa
41
+ # or
42
+ kd
27
43
  ```
28
44
 
29
- ## Quick Start
45
+ ### Non-Interactive Mode
46
+ Get a quick response:
47
+ ```bash
48
+ kode -p "explain this function" main.js
49
+ # or
50
+ kwa -p "explain this function" main.js
51
+ ```
52
+
53
+ ### Commands
54
+
55
+ - `/help` - Show available commands
56
+ - `/model` - Change AI model settings
57
+ - `/config` - Open configuration panel
58
+ - `/cost` - Show token usage and costs
59
+ - `/clear` - Clear conversation history
60
+ - `/init` - Initialize project context
61
+
62
+ ## Multi-Model Intelligent Collaboration
63
+
64
+ Unlike official Claude which supports only a single model, Kode implements **true multi-model collaboration**, allowing you to fully leverage the unique strengths of different AI models.
65
+
66
+ ### 🏗️ Core Technical Architecture
67
+
68
+ #### 1. **ModelManager Multi-Model Manager**
69
+ We designed a unified `ModelManager` system that supports:
70
+ - **Model Profiles**: Each model has an independent configuration file containing API endpoints, authentication, context window size, cost parameters, etc.
71
+ - **Model Pointers**: Users can configure default models for different purposes in the `/model` command:
72
+ - `main`: Default model for main Agent
73
+ - `task`: Default model for SubAgent
74
+ - `reasoning`: Reserved for future ThinkTool usage
75
+ - `quick`: Fast model for simple NLP tasks (security identification, title generation, etc.)
76
+ - **Dynamic Model Switching**: Support runtime model switching without restarting sessions, maintaining context continuity
77
+
78
+ #### 2. **TaskTool Intelligent Task Distribution**
79
+ Our specially designed `TaskTool` (Architect tool) implements:
80
+ - **Subagent Mechanism**: Can launch multiple sub-agents to process tasks in parallel
81
+ - **Model Parameter Passing**: Users can specify which model SubAgents should use in their requests
82
+ - **Default Model Configuration**: SubAgents use the model configured by the `task` pointer by default
83
+
84
+ #### 3. **AskExpertModel Expert Consultation Tool**
85
+ We specially designed the `AskExpertModel` tool:
86
+ - **Expert Model Invocation**: Allows temporarily calling specific expert models to solve difficult problems during conversations
87
+ - **Model Isolation Execution**: Expert model responses are processed independently without affecting the main conversation flow
88
+ - **Knowledge Integration**: Integrates expert model insights into the current task
89
+
90
+ #### 🎯 Flexible Model Switching
91
+ - **Tab Key Quick Switch**: Press Tab in the input box to quickly switch the model for the current conversation
92
+ - **`/model` Command**: Use `/model` command to configure and manage multiple model profiles, set default models for different purposes
93
+ - **User Control**: Users can specify specific models for task processing at any time
94
+
95
+ #### 🔄 Intelligent Work Allocation Strategy
96
+
97
+ **Architecture Design Phase**
98
+ - Use **o3 model** or **GPT-5 model** to explore system architecture and formulate sharp and clear technical solutions
99
+ - These models excel in abstract thinking and system design
100
+
101
+ **Solution Refinement Phase**
102
+ - Use **gemini model** to deeply explore production environment design details
103
+ - Leverage its deep accumulation in practical engineering and balanced reasoning capabilities
104
+
105
+ **Code Implementation Phase**
106
+ - Use **Qwen Coder model**, **Kimi k2 model**, **GLM-4.5 model**, or **Claude Sonnet 4 model** for specific code writing
107
+ - These models have strong performance in code generation, file editing, and engineering implementation
108
+ - Support parallel processing of multiple coding tasks through subagents
109
+
110
+ **Problem Solving**
111
+ - When encountering complex problems, consult expert models like **o3 model**, **Claude Opus 4.1 model**, or **Grok 4 model**
112
+ - Obtain deep technical insights and innovative solutions
113
+
114
+ #### 💡 Practical Application Scenarios
115
+
116
+ ```bash
117
+ # Example 1: Architecture Design
118
+ "Use o3 model to help me design a high-concurrency message queue system architecture"
119
+
120
+ # Example 2: Multi-Model Collaboration
121
+ "First use GPT-5 model to analyze the root cause of this performance issue, then use Claude Sonnet 4 model to write optimization code"
122
+
123
+ # Example 3: Parallel Task Processing
124
+ "Use Qwen Coder model as subagent to refactor these three modules simultaneously"
30
125
 
31
- 1. **Model Setup**: Use the onboarding flow or `/model` command to configure your AI provider
32
- 2. **Custom Models**: If your model isn't listed, manually configure it via `/config`
33
- 3. **OpenAI-Compatible**: Works with any OpenAI-style endpoint (Ollama, OpenRouter, etc.)
126
+ # Example 4: Expert Consultation
127
+ "This memory leak issue is tricky, ask Claude Opus 4.1 model separately for solutions"
34
128
 
35
- ## MCP Server Integration
129
+ # Example 5: Code Review
130
+ "Have Kimi k2 model review the code quality of this PR"
36
131
 
37
- Use Agent Kode as a Model Context Protocol server with Claude Desktop:
132
+ # Example 6: Complex Reasoning
133
+ "Use Grok 4 model to help me derive the time complexity of this algorithm"
38
134
 
39
- 1. Find the full path: `which kode`
40
- 2. Add to Claude Desktop config:
41
- ```json
135
+ # Example 7: Solution Design
136
+ "Have GLM-4.5 model design a microservice decomposition plan"
137
+ ```
138
+
139
+ ### 🛠️ Key Implementation Mechanisms
140
+
141
+ #### **Configuration System**
142
+ ```typescript
143
+ // Example of multi-model configuration support
42
144
  {
43
- "mcpServers": {
44
- "agent-kode": {
45
- "command": "/path/to/kode",
46
- "args": ["mcp", "serve"]
47
- }
145
+ "modelProfiles": {
146
+ "o3": { "provider": "openai", "model": "o3", "apiKey": "..." },
147
+ "claude4": { "provider": "anthropic", "model": "claude-sonnet-4", "apiKey": "..." },
148
+ "qwen": { "provider": "alibaba", "model": "qwen-coder", "apiKey": "..." }
149
+ },
150
+ "modelPointers": {
151
+ "main": "claude4", // Main conversation model
152
+ "task": "qwen", // Task execution model
153
+ "reasoning": "o3", // Reasoning model
154
+ "quick": "glm-4.5" // Quick response model
48
155
  }
49
156
  }
50
157
  ```
51
158
 
52
- ## Development
159
+ #### **Cost Tracking System**
160
+ - **Usage Statistics**: Use `/cost` command to view token usage and costs for each model
161
+ - **Multi-Model Cost Comparison**: Track usage costs of different models in real-time
162
+ - **History Records**: Save cost data for each session
53
163
 
54
- ```bash
55
- # Install dependencies
56
- pnpm install
164
+ #### **Context Manager**
165
+ - **Context Inheritance**: Maintain conversation continuity when switching models
166
+ - **Context Window Adaptation**: Automatically adjust based on different models' context window sizes
167
+ - **Session State Preservation**: Ensure information consistency during multi-model collaboration
57
168
 
58
- # Run in development mode
59
- pnpm run dev
169
+ ### 🚀 Advantages of Multi-Model Collaboration
60
170
 
61
- # Build for production
62
- pnpm run build
171
+ 1. **Maximized Efficiency**: Each task is handled by the most suitable model
172
+ 2. **Cost Optimization**: Use lightweight models for simple tasks, powerful models for complex tasks
173
+ 3. **Parallel Processing**: Multiple models can work on different subtasks simultaneously
174
+ 4. **Flexible Switching**: Switch models based on task requirements without restarting sessions
175
+ 5. **Leveraging Strengths**: Combine advantages of different models for optimal overall results
63
176
 
64
- # Debug with verbose logging
65
- NODE_ENV=development pnpm run dev --verbose --debug
66
- ```
177
+ ### 📊 Comparison with Official Implementation
67
178
 
68
- ## Architecture
179
+ | Feature | Kode | Official Claude |
180
+ |---------|------|-----------------|
181
+ | Number of Supported Models | Unlimited, configurable for any model | Only supports single Claude model |
182
+ | Model Switching | ✅ Tab key quick switch | ❌ Requires session restart |
183
+ | Parallel Processing | ✅ Multiple SubAgents work in parallel | ❌ Single-threaded processing |
184
+ | Cost Tracking | ✅ Separate statistics for multiple models | ❌ Single model cost |
185
+ | Task Model Configuration | ✅ Different default models for different purposes | ❌ Same model for all tasks |
186
+ | Expert Consultation | ✅ AskExpertModel tool | ❌ Not supported |
69
187
 
70
- - **React/Ink** - Terminal UI framework
71
- - **18 Core Tools** - File operations, shell execution, AI workflows, checkpoints
72
- - **Multi-Provider** - Anthropic Claude, OpenAI, custom endpoints
73
- - **TypeScript** - Full type safety throughout
74
- - **MCP Compatible** - Model Context Protocol integration
75
- - **Smart Workflows** - Checkpoint system and worktree management
188
+ This multi-model collaboration capability makes Kode a true **AI Development Workbench**, not just a single AI assistant.
76
189
 
77
- ## Advanced Workflows
190
+ ## Development
78
191
 
79
- Agent Kode provides sophisticated development workflow management:
192
+ Kode is built with modern tools and requires [Bun](https://bun.sh) for development.
80
193
 
81
- ### 🎯 Checkpoint System
82
- Intelligent project state management with automatic analysis and recovery:
83
- - **`/checkpoint-save`** - Smart analysis and state preservation
84
- - **`/checkpoint-restore`** - Natural language version recovery
194
+ ### Install Bun
85
195
 
86
- ### 🌿 Worktree Development
87
- Isolated development environments for feature work:
88
- - **`/worktree-create`** - Task-driven environment creation
89
- - **`/worktree-review`** - Comprehensive code quality assessment
90
- - **`/worktree-merge`** - Safe integration with quality gates
196
+ ```bash
197
+ # macOS/Linux
198
+ curl -fsSL https://bun.sh/install | bash
91
199
 
92
- 📚 **[Complete Workflow Documentation](docs/commands/README.md)**
200
+ # Windows
201
+ powershell -c "irm bun.sh/install.ps1 | iex"
202
+ ```
93
203
 
94
- ## Bug Reports
204
+ ### Setup Development Environment
95
205
 
96
- Submit bugs directly from the app using `/bug` - it will open GitHub with pre-filled information.
206
+ ```bash
207
+ # Clone the repository
208
+ git clone https://github.com/shareAI-lab/kode.git
209
+ cd kode
97
210
 
98
- ## Privacy & Data
211
+ # Install dependencies
212
+ bun install
99
213
 
100
- - **No telemetry** - No backend servers except your chosen AI providers
101
- - **Local processing** - All data stays on your machine
102
- - **Open source** - Full transparency in code and data handling
214
+ # Run in development mode
215
+ bun run dev
216
+ ```
217
+
218
+ ### Build
103
219
 
104
- ## Repository
220
+ ```bash
221
+ bun run build
222
+ ```
105
223
 
106
- - **Homepage**: [https://github.com/shareAI-lab/agent-kode](https://github.com/shareAI-lab/agent-kode)
107
- - **Issues**: [https://github.com/shareAI-lab/agent-kode/issues](https://github.com/shareAI-lab/agent-kode/issues)
224
+ ### Testing
108
225
 
109
- ## License
226
+ ```bash
227
+ # Run tests
228
+ bun test
229
+
230
+ # Test the CLI
231
+ ./cli.js --help
232
+ ```
110
233
 
111
- See [LICENSE.md](LICENSE.md) for details.
234
+ ## Contributing
235
+
236
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
237
+
238
+ ## License
112
239
 
113
- ---
240
+ ISC License - see [LICENSE](LICENSE) for details.
114
241
 
115
- **⚠️ Use at your own risk** - This tool executes code and commands on your system.
242
+ ## Support
116
243
 
117
- ## Thanks
118
- - some code from @dnakov 's anonkode
119
- - some ui learn from gemini-cli
120
- - some system design learn from claude code
244
+ - 📚 [Documentation](docs/)
245
+ - 🐛 [Report Issues](https://github.com/shareAI-lab/kode/issues)
246
+ - 💬 [Discussions](https://github.com/shareAI-lab/kode/discussions)
@@ -0,0 +1,246 @@
1
+ # Kode - 终端 AI 助手
2
+
3
+ [![npm version](https://badge.fury.io/js/@shareai-lab%2Fkode.svg)](https://www.npmjs.com/package/@shareai-lab/kode)
4
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
5
+
6
+ [English](README.md) | [贡献指南](CONTRIBUTING.md) | [文档](docs/)
7
+
8
+ Kode 是一个强大的 AI 助手,运行在你的终端中。它能理解你的代码库、编辑文件、运行命令,并为你处理整个开发工作流。
9
+
10
+ ## 功能特性
11
+
12
+ - 🤖 **AI 驱动的助手** - 使用先进的 AI 模型理解并响应你的请求
13
+ - 🔄 **多模型协同** - 灵活切换和组合使用多个 AI 模型,发挥各自优势
14
+ - 📝 **代码编辑** - 直接编辑文件,提供智能建议和改进
15
+ - 🔍 **代码库理解** - 分析项目结构和代码关系
16
+ - 🚀 **命令执行** - 实时运行 shell 命令并查看结果
17
+ - 🛠️ **工作流自动化** - 用简单的提示处理复杂的开发任务
18
+ - 🎨 **交互式界面** - 美观的终端界面,支持语法高亮
19
+ - 🔌 **工具系统** - 可扩展的架构,为不同任务提供专门的工具
20
+ - 💾 **上下文管理** - 智能的上下文处理,保持对话连续性
21
+
22
+ ## 安装
23
+
24
+ ```bash
25
+ npm install -g @shareai-lab/kode
26
+ ```
27
+
28
+ 安装后,你可以使用以下任一命令:
29
+ - `kode` - 主命令
30
+ - `kwa` - Kode With Agent(备选)
31
+ - `kd` - 超短别名
32
+
33
+ ## 使用方法
34
+
35
+ ### 交互模式
36
+ 启动交互式会话:
37
+ ```bash
38
+ kode
39
+ # 或
40
+ kwa
41
+ # 或
42
+ kd
43
+ ```
44
+
45
+ ### 非交互模式
46
+ 获取快速响应:
47
+ ```bash
48
+ kode -p "解释这个函数" main.js
49
+ # 或
50
+ kwa -p "解释这个函数" main.js
51
+ ```
52
+
53
+ ### 常用命令
54
+
55
+ - `/help` - 显示可用命令
56
+ - `/model` - 更改 AI 模型设置
57
+ - `/config` - 打开配置面板
58
+ - `/cost` - 显示 token 使用量和成本
59
+ - `/clear` - 清除对话历史
60
+ - `/init` - 初始化项目上下文
61
+
62
+ ## 多模型智能协同
63
+
64
+ 与 CC 仅支持单一模型不同,Kode 实现了**真正的多模型协同工作**,让你能够充分发挥不同 AI 模型的独特优势。
65
+
66
+ ### 🏗️ 核心技术架构
67
+
68
+ #### 1. **ModelManager 多模型管理器**
69
+ 我们设计了统一的 `ModelManager` 系统,支持:
70
+ - **模型配置文件(Model Profiles)**:每个模型都有独立的配置文件,包含 API 端点、认证信息、上下文窗口大小、成本等参数
71
+ - **模型指针(Model Pointers)**:用户可以在 `/model` 命令中配置不同用途的默认模型:
72
+ - `main`:主 Agent 的默认模型
73
+ - `task`:SubAgent 的默认模型
74
+ - `reasoning`:预留给未来 ThinkTool 使用
75
+ - `quick`:用于简单 NLP 任务(如安全性识别、生成标题描述等)的快速模型
76
+ - **动态模型切换**:支持运行时切换模型,无需重启会话,保持上下文连续性
77
+
78
+ #### 2. **TaskTool 智能任务分发工具**
79
+ 专门设计的 `TaskTool`(Architect 工具)实现了:
80
+ - **Subagent 机制**:可以启动多个子代理并行处理任务
81
+ - **模型参数传递**:用户可以在请求中指定 SubAgent 使用的模型
82
+ - **默认模型配置**:SubAgent 默认使用 `task` 指针配置的模型
83
+
84
+ #### 3. **AskExpertModel 专家咨询工具**
85
+ 我们专门设计了 `AskExpertModel` 工具:
86
+ - **专家模型调用**:允许在对话中临时调用特定的专家模型解决疑难问题
87
+ - **模型隔离执行**:专家模型的响应独立处理,不影响主对话流程
88
+ - **知识整合**:将专家模型的见解整合到当前任务中
89
+
90
+ #### 🎯 灵活的模型切换
91
+ - **Tab 键快速切换**:在输入框按 Tab 键即可快速切换当前对话使用的模型
92
+ - **`/model` 命令**:使用 `/model` 命令配置和管理多个模型配置文件,设置不同用途的默认模型
93
+ - **用户控制**:用户可以随时指定使用特定的模型进行任务处理
94
+
95
+ #### 🔄 智能的工作分配策略
96
+
97
+ **架构设计阶段**
98
+ - 使用 **o3 模型** 或 **GPT-5 模型** 探讨系统架构,制定犀利明确的技术方案
99
+ - 这些模型在抽象思维和系统设计方面表现卓越
100
+
101
+ **方案细化阶段**
102
+ - 使用 **gemini 模型** 深入探讨生产环境的设计细节
103
+ - 利用其在实际工程实践中的深厚积累和平衡的推理能力
104
+
105
+ **代码实现阶段**
106
+ - 使用 **Qwen Coder 模型**、**Kimi k2 模型** 、**GLM-4.5 模型** 或 **Claude Sonnet 4 模型** 进行具体的代码编写
107
+ - 这些模型在代码生成、文件编辑和工程实现方面性能强劲
108
+ - 支持通过 subagent 并行处理多个编码任务
109
+
110
+ **疑难问题解决**
111
+ - 遇到复杂问题时,可单独咨询 **o3 模型**、**Claude Opus 4.1 模型** 或 **Grok 4 模型** 等专家模型
112
+ - 获得深度的技术见解和创新的解决方案
113
+
114
+ #### 💡 实际应用场景
115
+
116
+ ```bash
117
+ # 示例 1:架构设计
118
+ "用 o3 模型帮我设计一个高并发的消息队列系统架构"
119
+
120
+ # 示例 2:多模型协作
121
+ "先用 GPT-5 模型分析这个性能问题的根本原因,然后用 Claude Sonnet 4 模型编写优化代码"
122
+
123
+ # 示例 3:并行任务处理
124
+ "用 Qwen Coder 模型作为 subagent 同时重构这三个模块"
125
+
126
+ # 示例 4:专家咨询
127
+ "这个内存泄漏问题很棘手,单独问问 Claude Opus 4.1 模型有什么解决方案"
128
+
129
+ # 示例 5:代码审查
130
+ "让 Kimi k2 模型审查这个 PR 的代码质量"
131
+
132
+ # 示例 6:复杂推理
133
+ "用 Grok 4 模型帮我推导这个算法的时间复杂度"
134
+
135
+ # 示例 7:方案设计
136
+ "让 GLM-4.5 模型设计微服务拆分方案"
137
+ ```
138
+
139
+ ### 🛠️ 关键实现机制
140
+
141
+ #### **配置系统(Configuration System)**
142
+ ```typescript
143
+ // 支持多模型配置的示例
144
+ {
145
+ "modelProfiles": {
146
+ "o3": { "provider": "openai", "model": "o3", "apiKey": "..." },
147
+ "claude4": { "provider": "anthropic", "model": "claude-sonnet-4", "apiKey": "..." },
148
+ "qwen": { "provider": "alibaba", "model": "qwen-coder", "apiKey": "..." }
149
+ },
150
+ "modelPointers": {
151
+ "main": "claude4", // 主对话模型
152
+ "task": "qwen", // 任务执行模型
153
+ "reasoning": "o3", // 推理模型
154
+ "quick": "glm-4.5" // 快速响应模型
155
+ }
156
+ }
157
+ ```
158
+
159
+ #### **成本追踪系统(Cost Tracking)**
160
+ - **使用统计**:`/cost` 命令查看各模型的 token 使用量和花费
161
+ - **多模型成本对比**:实时追踪不同模型的使用成本
162
+ - **历史记录**:保存每个会话的成本数据
163
+
164
+ #### **上下文管理器(Context Manager)**
165
+ - **上下文继承**:切换模型时保持对话连续性
166
+ - **上下文窗口适配**:根据不同模型的上下文窗口大小自动调整
167
+ - **会话状态保持**:确保多模型协作时的信息一致性
168
+
169
+ ### 🚀 多模型协同的优势
170
+
171
+ 1. **效率最大化**:每个任务都由最适合的模型处理
172
+ 2. **成本优化**:简单任务用轻量模型,复杂任务用强大模型
173
+ 3. **并行处理**:多个模型可以同时处理不同的子任务
174
+ 4. **灵活切换**:根据任务需求随时切换模型,无需重启会话
175
+ 5. **取长补短**:结合不同模型的优势,获得最佳的整体效果
176
+
177
+ ### 📊 与官方实现的对比
178
+
179
+ | 特性 | Kode | 官方 CC |
180
+ |------|------|---------|
181
+ | 支持模型数量 | 无限制,可配置任意模型 | 仅支持单一 Claude 模型 |
182
+ | 模型切换 | ✅ Tab 键快速切换 | ❌ 需要重启会话 |
183
+ | 并行处理 | ✅ 多个 SubAgent 并行工作 | ❌ 单线程处理 |
184
+ | 成本追踪 | ✅ 多模型成本分别统计 | ❌ 单一模型成本 |
185
+ | 任务模型配置 | ✅ 不同用途配置不同默认模型 | ❌ 所有任务用同一模型 |
186
+ | 专家咨询 | ✅ AskExpertModel 工具 | ❌ 不支持 |
187
+
188
+ 这种多模型协同能力让 Kode 成为真正的 **AI 开发工作台**,而不仅仅是一个单一的 AI 助手。
189
+
190
+ ## 开发
191
+
192
+ Kode 使用现代化工具构建,开发需要 [Bun](https://bun.sh)。
193
+
194
+ ### 安装 Bun
195
+
196
+ ```bash
197
+ # macOS/Linux
198
+ curl -fsSL https://bun.sh/install | bash
199
+
200
+ # Windows
201
+ powershell -c "irm bun.sh/install.ps1 | iex"
202
+ ```
203
+
204
+ ### 设置开发环境
205
+
206
+ ```bash
207
+ # 克隆仓库
208
+ git clone https://github.com/shareAI-lab/kode.git
209
+ cd kode
210
+
211
+ # 安装依赖
212
+ bun install
213
+
214
+ # 在开发模式下运行
215
+ bun run dev
216
+ ```
217
+
218
+ ### 构建
219
+
220
+ ```bash
221
+ bun run build
222
+ ```
223
+
224
+ ### 测试
225
+
226
+ ```bash
227
+ # 运行测试
228
+ bun test
229
+
230
+ # 测试 CLI
231
+ ./cli.js --help
232
+ ```
233
+
234
+ ## 贡献
235
+
236
+ 我们欢迎贡献!请查看我们的[贡献指南](CONTRIBUTING.md)了解详情。
237
+
238
+ ## 许可证
239
+
240
+ ISC 许可证 - 详见 [LICENSE](LICENSE)。
241
+
242
+ ## 支持
243
+
244
+ - 📚 [文档](docs/)
245
+ - 🐛 [报告问题](https://github.com/shareAI-lab/kode/issues)
246
+ - 💬 [讨论](https://github.com/shareAI-lab/kode/discussions)
package/cli.js ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+
6
+ // Prefer bun if available, otherwise use node with loader
7
+ const args = process.argv.slice(2);
8
+ const cliPath = path.join(__dirname, 'src', 'entrypoints', 'cli.tsx');
9
+
10
+ // Try bun first
11
+ try {
12
+ const { execSync } = require('child_process');
13
+ execSync('bun --version', { stdio: 'ignore' });
14
+
15
+ // Bun is available
16
+ const child = spawn('bun', ['run', cliPath, ...args], {
17
+ stdio: 'inherit',
18
+ env: {
19
+ ...process.env,
20
+ YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm')
21
+ }
22
+ });
23
+
24
+ child.on('exit', (code) => process.exit(code || 0));
25
+ child.on('error', () => {
26
+ // Fallback to node if bun fails
27
+ runWithNode();
28
+ });
29
+ } catch {
30
+ // Bun not available, use node
31
+ runWithNode();
32
+ }
33
+
34
+ function runWithNode() {
35
+ // Use node with tsx loader
36
+ const child = spawn('node', [
37
+ '--loader', 'tsx',
38
+ '--no-warnings',
39
+ cliPath,
40
+ ...args
41
+ ], {
42
+ stdio: 'inherit',
43
+ env: {
44
+ ...process.env,
45
+ NODE_OPTIONS: '--loader tsx --no-warnings',
46
+ YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm')
47
+ }
48
+ });
49
+
50
+ child.on('error', (err) => {
51
+ if (err.code === 'MODULE_NOT_FOUND' || err.message.includes('tsx')) {
52
+ console.error('\nError: tsx is required but not installed.');
53
+ console.error('Please run: npm install');
54
+ process.exit(1);
55
+ } else {
56
+ console.error('Failed to start Kode:', err.message);
57
+ process.exit(1);
58
+ }
59
+ });
60
+
61
+ child.on('exit', (code) => process.exit(code || 0));
62
+ }