openhorse 0.1.22 → 0.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.
Files changed (143) hide show
  1. package/README.md +76 -427
  2. package/dist/cli.d.ts +1 -3
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +125 -1028
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/index.d.ts.map +1 -1
  7. package/dist/commands/index.js +91 -19
  8. package/dist/commands/index.js.map +1 -1
  9. package/dist/commands/types.d.ts +1 -0
  10. package/dist/commands/types.d.ts.map +1 -1
  11. package/dist/commands/types.js.map +1 -1
  12. package/dist/framework/index.d.ts +2 -2
  13. package/dist/framework/index.d.ts.map +1 -1
  14. package/dist/framework/index.js +6 -1
  15. package/dist/framework/index.js.map +1 -1
  16. package/dist/framework/query.d.ts +2 -0
  17. package/dist/framework/query.d.ts.map +1 -1
  18. package/dist/framework/query.js +5 -2
  19. package/dist/framework/query.js.map +1 -1
  20. package/dist/harness/assembler.d.ts +14 -2
  21. package/dist/harness/assembler.d.ts.map +1 -1
  22. package/dist/harness/assembler.js +167 -32
  23. package/dist/harness/assembler.js.map +1 -1
  24. package/dist/harness/capsule.d.ts +2 -1
  25. package/dist/harness/capsule.d.ts.map +1 -1
  26. package/dist/harness/capsule.js +64 -0
  27. package/dist/harness/capsule.js.map +1 -1
  28. package/dist/harness/context-harness.d.ts +23 -3
  29. package/dist/harness/context-harness.d.ts.map +1 -1
  30. package/dist/harness/context-harness.js +97 -7
  31. package/dist/harness/context-harness.js.map +1 -1
  32. package/dist/harness/contract.d.ts +2 -2
  33. package/dist/harness/contract.d.ts.map +1 -1
  34. package/dist/harness/contract.js +7 -3
  35. package/dist/harness/contract.js.map +1 -1
  36. package/dist/harness/evidence.d.ts +15 -0
  37. package/dist/harness/evidence.d.ts.map +1 -0
  38. package/dist/harness/evidence.js +171 -0
  39. package/dist/harness/evidence.js.map +1 -0
  40. package/dist/harness/index.d.ts +9 -3
  41. package/dist/harness/index.d.ts.map +1 -1
  42. package/dist/harness/index.js +15 -1
  43. package/dist/harness/index.js.map +1 -1
  44. package/dist/harness/intent.d.ts +4 -0
  45. package/dist/harness/intent.d.ts.map +1 -0
  46. package/dist/harness/intent.js +139 -0
  47. package/dist/harness/intent.js.map +1 -0
  48. package/dist/harness/state.d.ts +12 -0
  49. package/dist/harness/state.d.ts.map +1 -0
  50. package/dist/harness/state.js +84 -0
  51. package/dist/harness/state.js.map +1 -0
  52. package/dist/harness/turn-summary.d.ts +25 -0
  53. package/dist/harness/turn-summary.d.ts.map +1 -0
  54. package/dist/harness/turn-summary.js +120 -0
  55. package/dist/harness/turn-summary.js.map +1 -0
  56. package/dist/harness/types.d.ts +103 -0
  57. package/dist/harness/types.d.ts.map +1 -1
  58. package/dist/index.d.ts +2 -2
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +6 -1
  61. package/dist/index.js.map +1 -1
  62. package/dist/ink-ui/App.d.ts +6 -0
  63. package/dist/ink-ui/App.d.ts.map +1 -0
  64. package/dist/ink-ui/App.js +12 -0
  65. package/dist/ink-ui/App.js.map +1 -0
  66. package/dist/ink-ui/components/Markdown.d.ts +9 -0
  67. package/dist/ink-ui/components/Markdown.d.ts.map +1 -0
  68. package/dist/ink-ui/components/Markdown.js +188 -0
  69. package/dist/ink-ui/components/Markdown.js.map +1 -0
  70. package/dist/ink-ui/components/PixelHorseBanner.d.ts +8 -0
  71. package/dist/ink-ui/components/PixelHorseBanner.d.ts.map +1 -0
  72. package/dist/ink-ui/components/PixelHorseBanner.js +97 -0
  73. package/dist/ink-ui/components/PixelHorseBanner.js.map +1 -0
  74. package/dist/ink-ui/components/PromptInput.d.ts +9 -0
  75. package/dist/ink-ui/components/PromptInput.d.ts.map +1 -0
  76. package/dist/ink-ui/components/PromptInput.js +24 -0
  77. package/dist/ink-ui/components/PromptInput.js.map +1 -0
  78. package/dist/ink-ui/components/SelectList.d.ts +15 -0
  79. package/dist/ink-ui/components/SelectList.d.ts.map +1 -0
  80. package/dist/ink-ui/components/SelectList.js +39 -0
  81. package/dist/ink-ui/components/SelectList.js.map +1 -0
  82. package/dist/ink-ui/components/StatusLine.d.ts +9 -0
  83. package/dist/ink-ui/components/StatusLine.d.ts.map +1 -0
  84. package/dist/ink-ui/components/StatusLine.js +71 -0
  85. package/dist/ink-ui/components/StatusLine.js.map +1 -0
  86. package/dist/ink-ui/components/TerminalCursor.d.ts +13 -0
  87. package/dist/ink-ui/components/TerminalCursor.d.ts.map +1 -0
  88. package/dist/ink-ui/components/TerminalCursor.js +74 -0
  89. package/dist/ink-ui/components/TerminalCursor.js.map +1 -0
  90. package/dist/ink-ui/components/Transcript.d.ts +8 -0
  91. package/dist/ink-ui/components/Transcript.d.ts.map +1 -0
  92. package/dist/ink-ui/components/Transcript.js +29 -0
  93. package/dist/ink-ui/components/Transcript.js.map +1 -0
  94. package/dist/ink-ui/controllers/chat-controller.d.ts +15 -0
  95. package/dist/ink-ui/controllers/chat-controller.d.ts.map +1 -0
  96. package/dist/ink-ui/controllers/chat-controller.js +410 -0
  97. package/dist/ink-ui/controllers/chat-controller.js.map +1 -0
  98. package/dist/ink-ui/launch.d.ts +3 -0
  99. package/dist/ink-ui/launch.d.ts.map +1 -0
  100. package/dist/ink-ui/launch.js +14 -0
  101. package/dist/ink-ui/launch.js.map +1 -0
  102. package/dist/ink-ui/runtime/prompt-layout.d.ts +11 -0
  103. package/dist/ink-ui/runtime/prompt-layout.d.ts.map +1 -0
  104. package/dist/ink-ui/runtime/prompt-layout.js +51 -0
  105. package/dist/ink-ui/runtime/prompt-layout.js.map +1 -0
  106. package/dist/ink-ui/screens/ReplScreen.d.ts +14 -0
  107. package/dist/ink-ui/screens/ReplScreen.d.ts.map +1 -0
  108. package/dist/ink-ui/screens/ReplScreen.js +470 -0
  109. package/dist/ink-ui/screens/ReplScreen.js.map +1 -0
  110. package/dist/ink-ui/types.d.ts +43 -0
  111. package/dist/ink-ui/types.d.ts.map +1 -0
  112. package/dist/ink-ui/types.js +3 -0
  113. package/dist/ink-ui/types.js.map +1 -0
  114. package/dist/services/compact/auto-compact.d.ts +3 -1
  115. package/dist/services/compact/auto-compact.d.ts.map +1 -1
  116. package/dist/services/compact/auto-compact.js +10 -0
  117. package/dist/services/compact/auto-compact.js.map +1 -1
  118. package/dist/services/compact/compact.d.ts +5 -1
  119. package/dist/services/compact/compact.d.ts.map +1 -1
  120. package/dist/services/compact/compact.js +11 -1
  121. package/dist/services/compact/compact.js.map +1 -1
  122. package/dist/services/config-dir.d.ts +2 -0
  123. package/dist/services/config-dir.d.ts.map +1 -1
  124. package/dist/services/config-dir.js +5 -0
  125. package/dist/services/config-dir.js.map +1 -1
  126. package/dist/services/config.js +2 -2
  127. package/dist/services/config.js.map +1 -1
  128. package/dist/services/global-config.d.ts +1 -1
  129. package/dist/services/global-config.d.ts.map +1 -1
  130. package/dist/services/session-storage.d.ts +4 -1
  131. package/dist/services/session-storage.d.ts.map +1 -1
  132. package/dist/services/session-storage.js +76 -6
  133. package/dist/services/session-storage.js.map +1 -1
  134. package/dist/tools/mcp.js +1 -1
  135. package/dist/ui-v2/components/session-picker.d.ts +2 -0
  136. package/dist/ui-v2/components/session-picker.d.ts.map +1 -1
  137. package/dist/ui-v2/components/session-picker.js +34 -5
  138. package/dist/ui-v2/components/session-picker.js.map +1 -1
  139. package/dist/ui-v2/state/sessions.d.ts +1 -0
  140. package/dist/ui-v2/state/sessions.d.ts.map +1 -1
  141. package/dist/ui-v2/state/sessions.js +18 -0
  142. package/dist/ui-v2/state/sessions.js.map +1 -1
  143. package/package.json +5 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  ---
12
12
 
13
- **🌍 Language**: English | [简体中文](README.zh-CN.md)
13
+ **🌍 Language**: [English](README.md) | [简体中文](README.zh-CN.md)
14
14
 
15
15
  ---
16
16
 
@@ -18,68 +18,15 @@
18
18
 
19
19
  **OpenHorse** is a terminal-based coding agent that wraps LLM APIs in a harness of safety checks, tool orchestration, session management, and context awareness.
20
20
 
21
- ### Core Design
22
-
23
21
  | Dimension | Description |
24
22
  |-----------|-------------|
25
23
  | **AI as Horse** | Powerful models need guidance and constraints |
26
24
  | **OpenHorse as Reins** | Precise control to prevent runaway behavior |
27
25
  | **Harness System** | Safety boundaries, task constraints, result validation |
28
26
  | **Tool Calling** | LLM autonomously invokes tools to complete tasks |
29
- | **Memory System** | Layered memory: Working / Short-term / Long-term / Semantic |
27
+ | **Memory System** | Layered memory with semantic search |
30
28
  | **MCP Protocol** | Connect external MCP servers for tool extension |
31
29
 
32
- ---
33
-
34
- ## Features
35
-
36
- | Feature | Description |
37
- |---------|-------------|
38
- | **Tool Orchestration** | 20+ built-in tools: file I/O, search, shell, web, memory, todo, plan |
39
- | **Multi-Model** | OpenAI, Claude, DashScope (GLM/Qwen/Kimi), custom endpoints |
40
- | **Context Awareness** | Per-model context windows, token-based auto-compact at 95% |
41
- | **Dynamic Discovery** | Auto-discovers models via `/models` endpoint at startup |
42
- | **MCP Protocol** | Full MCP server connection with heartbeat + reconnect |
43
- | **Memory System** | User / Project / Session memory with semantic search |
44
- | **Session Management** | Persistent sessions, history restore, summary generation |
45
- | **Safety Boundaries** | Bash safety checks, audit logging, permission modes |
46
- | **Streaming Output** | Real-time LLM responses with Markdown rendering |
47
- | **Status Bar** | Live token usage, cost, model, context % display |
48
- | **Simplified Config** | Only 4 user fields — agent controls internals |
49
-
50
- ---
51
-
52
- ## Architecture
53
-
54
- ```
55
- ┌─────────────────────────────────────────────────────────┐
56
- │ CLI Layer │
57
- │ readline + chalk + streaming Markdown + status bar │
58
- └────────────────────────────┬────────────────────────────┘
59
-
60
- ┌────────────────────────────▼────────────────────────────┐
61
- │ Harness Layer │
62
- │ Goal constraints │ Safety checks │ Result validation │
63
- └────────────────────────────┬────────────────────────────┘
64
-
65
- ┌────────────────────────────▼────────────────────────────┐
66
- │ Query Engine │
67
- │ LLM Stream │ Tool Calling │ Retry/Fallback │ Compact │
68
- └──────────┬─────────────────┬─────────────────┬──────────┘
69
- │ │ │
70
- ┌──────────▼─────┐ ┌─────────▼─────┐ ┌─────────▼──────────┐
71
- │ Tools │ │ MCP Client │ │ Skills │
72
- │ File/Bash/Web │ │ Server conn │ │ Builtin/User/Proj │
73
- └─────────────────┘ └───────────────┘ └───────────────────┘
74
-
75
- ┌────────────────────────────▼────────────────────────────┐
76
- │ Memory Layer │
77
- │ User │ Project │ Session │ Semantic Search │ Embeddings │
78
- └─────────────────────────────────────────────────────────┘
79
- ```
80
-
81
- ---
82
-
83
30
  ## Quick Start
84
31
 
85
32
  ### Requirements
@@ -90,48 +37,38 @@
90
37
  ### Install & Run
91
38
 
92
39
  ```bash
93
- # Clone
94
- git clone https://github.com/Linux2010/openhorse.git
95
- cd openhorse
40
+ # Install globally
41
+ npm install -g openhorse
96
42
 
97
- # Install
98
- npm install
99
-
100
- # Build
101
- npm run build
43
+ # Or from source
44
+ git clone https://github.com/Linux2010/openhorse.git
45
+ cd openhorse && npm install && npm run build
102
46
 
103
- # Configure API Key (choose one)
104
- # Option 1: Environment variable
47
+ # Configure API key
105
48
  export OPENHORSE_API_KEY=your-api-key
49
+ # or create ~/.openhorse/openhorse.json on first run
106
50
 
107
- # Option 2: .env file
108
- cp .env.example .env
109
- # Edit .env and set OPENHORSE_API_KEY
110
-
111
- # Option 3: ~/.openhorse/openhorse.json (recommended)
112
- # Created automatically on first run
113
-
114
- # Start interactive CLI
115
- npm start
116
- # or
117
- node dist/cli.js
118
- ```
119
-
120
- ### Global Install
121
-
122
- ```bash
123
- npm link
124
- # Run from any directory
51
+ # Start
125
52
  openhorse
126
53
  ```
127
54
 
128
- ---
55
+ ## Key Features
129
56
 
130
- ## Configuration
57
+ | Feature | Description |
58
+ |---------|-------------|
59
+ | **Tool Orchestration** | 20+ built-in tools: file I/O, shell, web, memory, git, LSP |
60
+ | **Multi-Model** | OpenAI, Claude, GLM, Qwen, DeepSeek, custom endpoints |
61
+ | **Context Awareness** | Per-model context windows, token-based auto-compact at 95% |
62
+ | **MCP Protocol** | stdio MCP servers with heartbeat + reconnect |
63
+ | **Memory System** | User / Project / Session memory with semantic search |
64
+ | **Session Management** | Persistent sessions with history restore |
65
+ | **Safety Boundaries** | Bash safety checks, audit logging, permission modes |
66
+ | **Streaming Output** | Real-time LLM responses with Markdown rendering |
67
+ | **Skills System** | Builtin, user, and project-level skill extensions |
131
68
 
132
- ### User Config (`~/.openhorse/openhorse.json`)
69
+ ## Configuration
133
70
 
134
- Only a small set of fields are user-configurable. The agent controls internal generation parameters.
71
+ Minimal user config the agent controls internal parameters.
135
72
 
136
73
  ```json
137
74
  {
@@ -143,84 +80,32 @@ Only a small set of fields are user-configurable. The agent controls internal ge
143
80
  }
144
81
  ```
145
82
 
146
- | Field | Required | Description |
147
- |-------|----------|-------------|
148
- | `apiKey` | Yes | LLM API key |
149
- | `apiBaseUrl` | No | API endpoint URL |
150
- | `defaultModel` | No | Default model (`glm-5`) |
151
- | `fallbackModel` | No | Fallback model on failure |
152
- | `toolConfirmation` | No | How to handle tools that ask for confirmation: `allow`, `deny`, or `ask`. Defaults to `allow` until the Ink UI can prompt interactively. |
153
- | `webSearch` | No | Optional WebSearch mode/provider overrides. `auto` uses provider MCP first, then adapter fallback (`tavily`, `brave`, `custom`, `ddg`). |
154
-
155
- ### Agent-Controlled Internals
156
-
157
- These parameters are managed by the agent, not exposed to users:
158
-
159
- | Parameter | Default | Description |
160
- |-----------|---------|-------------|
161
- | `maxTokens` | 8192 | Maximum output tokens |
162
- | `temperature` | 0.1 | Sampling temperature |
163
- | `maxRetries` | 3 | Retry attempts on failure |
164
- | `retryBaseDelay` | 1000ms | Base delay between retries |
83
+ | Field | Description |
84
+ |-------|-------------|
85
+ | `apiKey` | LLM API key |
86
+ | `apiBaseUrl` | API endpoint URL |
87
+ | `defaultModel` | Default model |
88
+ | `fallbackModel` | Fallback model on failure |
89
+ | `toolConfirmation` | Tool confirmation mode: `allow`, `deny`, or `ask` |
90
+ | `webSearch` | WebSearch mode/provider: `auto`, `tavily`, `brave`, `ddg` |
165
91
 
166
- ### Configuration Priority
167
-
168
- ```
169
- CLI flags > ~/.openhorse/openhorse.json > env vars > internal defaults
170
- ```
171
-
172
- ### Environment Variables
173
-
174
- | Variable | Default | Description |
175
- |----------|---------|-------------|
176
- | `OPENHORSE_API_KEY` | - | LLM API key |
177
- | `OPENHORSE_API_BASE_URL` | - | API base URL |
178
- | `OPENHORSE_MODEL` | `glm-5` | Default model |
179
- | `OPENHORSE_MODE` | `development` | Run mode |
180
- | `OPENHORSE_LOG_LEVEL` | `info` | Log level |
181
- | `OPENHORSE_TOOL_CONFIRMATION` | `allow` | Tool confirmation fallback: `allow`, `deny`, or `ask` |
182
- | `OPENHORSE_WEBSEARCH_PROVIDER` | `auto` | WebSearch mode/provider: `auto`, `native`, `bailian`, `zhipu`, `tavily-mcp`, `tavily`, `brave`, `custom`, `ddg` |
183
- | `OPENHORSE_WEBSEARCH_API_KEY` | configured API key | Provider-specific API key for MCP or adapters |
184
- | `OPENHORSE_WEBSEARCH_MCP_ENDPOINT` | provider default | WebSearch MCP endpoint override |
185
- | `OPENHORSE_WEBSEARCH_AUTH_TYPE` | `bearer` | MCP API key auth style: `bearer`, `header`, `query`, or `none` |
186
- | `OPENHORSE_EMBEDDING_PROVIDER` | - | Embedding service (ollama/openai) |
92
+ Configuration priority: `CLI flags > ~/.openhorse/openhorse.json > env vars > defaults`
187
93
 
188
94
  See [docs/config.md](docs/config.md) for full details.
189
95
 
190
- ---
191
-
192
96
  ## Models
193
97
 
194
- ### Supported Model Families
195
-
196
- | Provider | Models | Endpoint |
197
- |----------|--------|----------|
198
- | **GLM (智谱)** | `glm-5`, `glm-4` | DashScope coding |
199
- | **Qwen (通义)** | `qwen-turbo`, `qwen-plus`, `qwen-max`, `qwen-long` | DashScope coding |
200
- | **OpenAI** | `gpt-4o`, `gpt-4o-mini`, `gpt-4` | OpenAI API |
201
- | **Claude** | `claude-sonnet-4-6`, `claude-opus-4-8` | Anthropic API |
202
- | **DeepSeek** | `deepseek-chat`, `deepseek-reasoner` | DeepSeek API |
203
-
204
- ### Context Windows
98
+ OpenHorse supports OpenAI-compatible providers and auto-discovers model context windows at startup via the `/models` endpoint.
205
99
 
206
- OpenHorse tracks each model's context window and auto-compacts at **95% usage**:
100
+ | Provider | Example Models |
101
+ |----------|---------------|
102
+ | **GLM (智谱)** | `glm-5`, `glm-4` |
103
+ | **Qwen (通义)** | `qwen-turbo`, `qwen-plus`, `qwen-max`, `qwen-long` |
104
+ | **OpenAI** | `gpt-4o`, `gpt-4o-mini`, `gpt-4` |
105
+ | **Claude** | `claude-sonnet-4-6`, `claude-opus-4-8` |
106
+ | **DeepSeek** | `deepseek-chat`, `deepseek-reasoner` |
207
107
 
208
- | Model | Context | Max Output |
209
- |-------|---------|------------|
210
- | `glm-5` | 202,752 | 8,192 |
211
- | `qwen-long` | 1,000,000 | 8,192 |
212
- | `qwen-plus` | 131,072 | 8,192 |
213
- | `gpt-4o` | 128,000 | 16,384 |
214
- | `claude-sonnet-4-6` | 200,000 | 16,000 |
215
- | `claude-opus-4-8` | 200,000 | 32,000 |
216
-
217
- Unknown models default to **128,000** context.
218
-
219
- ### Dynamic Discovery
220
-
221
- At startup, OpenHorse queries the `/models` endpoint for context window data. If unsupported (e.g., DashScope coding returns 404), it falls back to the builtin database silently.
222
-
223
- ### Model Commands
108
+ Context usage is tracked in real tokens. When usage reaches **95%**, auto-compact generates a summary of early messages to free up space.
224
109
 
225
110
  ```bash
226
111
  /model # Show current model
@@ -228,309 +113,73 @@ At startup, OpenHorse queries the `/models` endpoint for context window data. If
228
113
  /model glm-5 # Switch to GLM-5
229
114
  ```
230
115
 
231
- ---
232
-
233
116
  ## Tools
234
117
 
235
- 20+ built-in tools available for LLM invocation:
236
-
237
- ### File Operations
238
-
239
- | Tool | Description |
240
- |------|-------------|
241
- | `read_file` | Read file contents |
242
- | `write_file` | Write to a file |
243
- | `edit_file` | Edit file (line replacement) |
244
- | `list_files` | List directory contents |
245
- | `glob` | Glob pattern file search |
246
- | `grep` | Regex search file contents |
247
-
248
- ### Shell
249
-
250
- | Tool | Description |
251
- |------|-------------|
252
- | `exec_command` | Execute shell command (with safety checks) |
253
-
254
- ### Network
255
-
256
- | Tool | Description |
257
- |------|-------------|
258
- | `web_fetch` | Fetch web page content |
259
- | `web_search` | Web search through configured provider MCP service |
260
-
261
- ### Memory
262
-
263
- | Tool | Description |
264
- |------|-------------|
265
- | `memory_save` | Save a memory entry |
266
- | `memory_recall` | Search memories |
267
- | `memory_forget` | Delete a memory entry |
268
-
269
- ### Task Management
118
+ 20+ built-in tools the LLM can invoke:
270
119
 
271
- | Tool | Description |
272
- |------|-------------|
273
- | `todo_write` | Create/update todo list |
274
- | `enter_plan_mode` | Enter plan mode |
275
- | `exit_plan_mode` | Exit plan mode |
276
-
277
- ---
278
-
279
- ## Context Management
280
-
281
- ### Auto-Compact
282
-
283
- When context usage reaches **95%**, OpenHorse automatically compacts the conversation history:
284
-
285
- 1. **Generates a summary** of early messages via the LLM
286
- 2. **Replaces** old messages with a `[Context Summary]` block
287
- 3. **Preserves** the system message and recent messages
288
- 4. **Displays** compact notification in the status bar
289
-
290
- ```
291
- Compact: 30 → 8 messages | Context: 45% → 12%
292
- ```
293
-
294
- ### Token-Based Threshold
295
-
296
- Unlike message-count-based approaches, OpenHorse uses **actual token counts** from the API response for precise context awareness:
297
-
298
- ```
299
- ctxPercent = (promptTokens / modelContextWindow) × 100
300
- ```
301
-
302
- Compact triggers only when `ctxPercent >= 95%`, not based on message count.
303
-
304
- ### 30-Second Interval
305
-
306
- To avoid over-compact, auto-compact runs at most once per 30 seconds. Manual `/compact` command bypasses this interval.
307
-
308
- ---
120
+ | Category | Tools |
121
+ |----------|-------|
122
+ | **File** | `read_file`, `write_file`, `edit_file`, `list_files`, `glob`, `grep` |
123
+ | **Shell** | `exec_command` (with safety checks) |
124
+ | **Network** | `web_fetch`, `web_search` |
125
+ | **Memory** | `memory_save`, `memory_recall`, `memory_forget` |
126
+ | **Task** | `todo_write`, `enter_plan_mode`, `exit_plan_mode` |
127
+ | **Git** | `git_command` |
128
+ | **MCP** | Connected MCP server tools (e.g. `mcp__filesystem__read_file`) |
309
129
 
310
130
  ## MCP Protocol
311
131
 
312
- OpenHorse supports stdio MCP (Model Context Protocol) servers and exposes connected
313
- server tools directly to the agent as first-class tools.
314
-
315
- ### Configure MCP Servers
316
-
317
- Create `~/.openhorse/mcp.json`:
132
+ OpenHorse connects stdio MCP servers and exposes their tools to the agent.
318
133
 
319
134
  ```json
135
+ // ~/.openhorse/mcp.json
320
136
  {
321
137
  "mcpServers": {
322
138
  "telegram": {
323
139
  "command": "node",
324
- "args": ["path/to/plugin-telegram/dist/index.js"],
325
- "env": {}
326
- },
327
- "filesystem": {
328
- "command": "npx",
329
- "args": ["-y", "@anthropic/mcp-server-filesystem", "/allowed/dir"]
140
+ "args": ["path/to/plugin-telegram/dist/index.js"]
330
141
  }
331
142
  }
332
143
  }
333
144
  ```
334
145
 
335
- The legacy top-level `servers` key is still accepted for compatibility. MCP tool
336
- names follow the `mcp__<server>__<tool>` convention used by Claude Code, Codex,
337
- and OpenClaude, for example `mcp__filesystem__read_file`.
338
-
339
- ### MCP Commands
340
-
341
146
  ```bash
342
147
  /mcp # Show MCP server connection status
343
- /chat use filesystem MCP to list files
344
148
  ```
345
149
 
346
- Servers connect automatically at startup with heartbeat monitoring and exponential
347
- backoff reconnect. HTTP/SSE MCP transports, resources, and prompts are planned
348
- but not part of the current stdio tool bridge.
349
-
350
- ---
351
-
352
150
  ## Interactive Commands
353
151
 
354
- | Command | Alias | Description |
355
- |---------|-------|-------------|
356
- | `/help` | `/h` | Show help information |
357
- | `/status` | `/s` | System status overview |
358
- | `/model` | - | View or switch models |
359
- | `/config` | - | Show current configuration |
360
- | `/cost` | - | Show session token usage and cost |
361
- | `/compact` | - | Manually trigger context compact |
362
- | `/sessions` | - | List recent sessions |
363
- | `/resume` | - | Resume last session |
364
- | `/memory` | - | Memory system status |
365
- | `/memory reindex` | - | Rebuild semantic search index |
366
- | `/skills` | - | List loaded skills |
367
- | `/mcp` | - | MCP server status |
368
- | `/agents` | - | List available agents |
369
- | `/safety` | - | Safety check configuration |
370
- | `/task` | - | Task management |
371
- | `/run` | - | Execute task via agent |
372
- | `/clear` | - | Clear screen |
373
- | `/clear-history` | `/reset` | Clear conversation history |
374
- | `/exit` | `/q` | Exit |
375
-
376
- ---
377
-
378
- ## Project Structure
379
-
380
- ```
381
- openhorse/
382
- ├── bin/
383
- │ └── openhorse # CLI entry point
384
- ├── src/
385
- │ ├── cli.ts # CLI interactive entry
386
- │ ├── commands/ # Slash commands
387
- │ │ ├── index.ts # Command registry
388
- │ │ ├── parser.ts # Input parser
389
- │ │ └── types.ts # Command types
390
- │ ├── core/ # Core logic
391
- │ │ ├── agent.ts # Agent base class
392
- │ │ ├── brain.ts # Decision engine
393
- │ │ └── strategy-tracker.ts # Strategy tracking
394
- │ ├── agents/ # Agent implementations
395
- │ │ ├── leader.ts # Coordinator agent
396
- │ │ ├── coder.ts # Coding agent
397
- │ │ └── router.ts # Agent router
398
- │ ├── framework/
399
- │ │ ├── store.ts # State management
400
- │ │ ├── query.ts # Query engine (async generator)
401
- │ │ └── tool-state.ts # Tool state
402
- │ ├── harness/ # Safety & constraints
403
- │ │ ├── safety.ts # Safety boundary checks
404
- │ │ └── bash-safety.ts # Bash command safety
405
- │ ├── memory/ # Memory system
406
- │ │ ├── storage.ts # Memory storage
407
- │ │ ├── semantic-search.ts # Semantic search
408
- │ │ ├── embeddings.ts # Embedding generation
409
- │ │ └── vector-store.ts # Vector store (SQLite vec0)
410
- │ ├── skills/ # Skill system
411
- │ │ ├── loader.ts # Skill loader
412
- │ │ └── registry.ts # Skill registry
413
- │ ├── services/
414
- │ │ ├── llm.ts # LLM service (retry/fallback)
415
- │ │ ├── config.ts # Config loading
416
- │ │ ├── global-config.ts # Global config
417
- │ │ ├── model-context.ts # Model context window DB + discovery
418
- │ │ ├── session-storage.ts # Session persistence
419
- │ │ ├── atomic-write.ts # Atomic file writes
420
- │ │ ├── agent-runner.ts # Agent runner
421
- │ │ ├── task-manager.ts # Task manager
422
- │ │ └── file-glob.ts # File matching
423
- │ ├── services/compact/ # Context compaction
424
- │ │ ├── auto-compact.ts # Token-based auto-compact
425
- │ │ ├── compact.ts # Compact implementation
426
- │ │ └── summary-generator.ts # Summary generation
427
- │ ├── tools/ # Tool implementations
428
- │ │ ├── index.ts # Tool registry
429
- │ │ ├── mcp.ts # MCP client
430
- │ │ ├── todo.ts # Todo tool
431
- │ │ ├── plan.ts # Plan tool
432
- │ │ ├── web.ts # Web tools
433
- │ │ └── memory.ts # Memory tools
434
- │ └── ui/ # UI components
435
- │ ├── box.ts # UI boxes
436
- │ ├── markdown.ts # Markdown rendering
437
- │ ├── status-bar.ts # Status bar
438
- │ ├── stream-markdown.ts # Streaming Markdown
439
- │ ├── tool-preview.ts # Tool preview cards
440
- │ └── suggestions.ts # Command suggestions
441
- ├── tests/ # Test suite
442
- ├── docs/ # Documentation
443
- │ ├── version/ # Version release notes
444
- │ ├── roadmap/ # Version roadmaps
445
- │ └── config.md # Configuration guide
446
- ├── .env.example # Environment template
447
- ├── package.json
448
- └── tsconfig.json
449
- ```
450
-
451
- ---
452
-
453
- ## Version History
454
-
455
- ### v0.1.16 (Current — in development)
456
-
457
- - **Token-based auto-compact** at 95% context usage (replaces message-count threshold)
458
- - **Model context awareness** — per-model context windows (15+ known models)
459
- - **Dynamic model discovery** — queries `/models` endpoint at startup
460
- - **Simplified user config** — core fields: `apiKey`, `apiBaseUrl`, `defaultModel`, `fallbackModel`, `toolConfirmation`
461
- - **Provider WebSearch** — `web_search` delegates to WebSearch MCP instead of scraping search engines locally
462
- - **Agent-controlled internals** — `maxTokens`, `temperature`, `retries` managed internally
463
- - **Fallback model** configurable by user
464
- - **Streamlined command panel** rendering
465
- - **Context harness workflow** for multi-agent context orchestration
466
-
467
- ### v0.1.15
468
-
469
- - **Full Markdown streaming** rendering with syntax highlighting
470
- - **CJK text width** calculation fix for terminal display
471
- - **Command panel** input clearing improvements
472
- - Table rendering removed (raw passthrough)
473
-
474
- ### v0.1.14
475
-
476
- - LSP crash fix, compact UI, concise agent output
477
-
478
- ### v0.1.10 — v0.1.13
479
-
480
- - MCP client with heartbeat/reconnect, semantic search, skills system, atomic writes, model aliases (Bailian), storage fixes
481
-
482
- ### v0.1.1 — v0.1.9
483
-
484
- - CLI framework, harness system, memory system, session management, tool orchestration
485
-
486
- See `docs/version/` for detailed release notes.
487
-
488
- ---
152
+ | Command | Description |
153
+ |---------|-------------|
154
+ | `/help` `/h` | Show help |
155
+ | `/status` `/s` | System status |
156
+ | `/model` | View or switch models |
157
+ | `/config` | Show configuration |
158
+ | `/cost` | Token usage and cost |
159
+ | `/compact` | Trigger context compact |
160
+ | `/sessions` | List recent sessions |
161
+ | `/resume` | Resume last session |
162
+ | `/memory` | Memory system status |
163
+ | `/skills` | List loaded skills |
164
+ | `/mcp` | MCP server status |
165
+ | `/clear` | Clear screen |
166
+ | `/exit` `/q` | Exit |
489
167
 
490
168
  ## Development
491
169
 
492
170
  ```bash
493
- # Install dependencies
494
- npm install
495
-
496
- # Development mode (hot reload)
497
- npm run dev
498
-
499
- # Build
500
- npm run build
501
-
502
- # Run tests
503
- npm test
504
-
505
- # Lint
506
- npm run lint
507
-
508
- # Format
509
- npm run format
171
+ npm install # Install dependencies
172
+ npm run dev # Development mode (hot reload)
173
+ npm run build # Build
174
+ npm test # Run tests
175
+ npm run lint # Lint
176
+ npm run format # Format
510
177
  ```
511
178
 
512
- ---
513
-
514
- ## Roadmap
515
-
516
- | Version | Target |
517
- |---------|--------|
518
- | v0.1.16 | Context awareness, auto-compact, config simplification |
519
- | v0.1.17 | Agent lifecycle improvements, enhanced tool orchestration |
520
- | v0.1.18 | Plugin/hook system for extensibility |
521
- | v0.1.19 | VS Code extension |
522
- | v0.1.20 | Web UI dashboard |
523
-
524
- See `docs/roadmap/` for details.
525
-
526
- ---
527
-
528
179
  ## Contributing
529
180
 
530
181
  Issues and Pull Requests are welcome!
531
182
 
532
- ---
533
-
534
183
  ## License
535
184
 
536
185
  MIT License — see [LICENSE](LICENSE) for details.
package/dist/cli.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  /**
2
- * openhorse - 命令行交互入口
3
- *
4
- * 简洁版 REPL,使用 readline + keypress 事件处理
2
+ * openhorse - Ink/React CLI entry
5
3
  */
6
4
  import 'dotenv/config';
7
5
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,eAAe,CAAC"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,eAAe,CAAC"}