openhorse 0.1.15 → 0.1.17

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 (98) hide show
  1. package/README.md +339 -274
  2. package/README.zh-CN.md +487 -0
  3. package/dist/cli.js +36 -39
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/index.d.ts.map +1 -1
  6. package/dist/commands/index.js +257 -105
  7. package/dist/commands/index.js.map +1 -1
  8. package/dist/commands/types.d.ts +7 -0
  9. package/dist/commands/types.d.ts.map +1 -1
  10. package/dist/commands/types.js.map +1 -1
  11. package/dist/framework/index.d.ts +2 -0
  12. package/dist/framework/index.d.ts.map +1 -1
  13. package/dist/framework/index.js +8 -1
  14. package/dist/framework/index.js.map +1 -1
  15. package/dist/framework/prompt.d.ts.map +1 -1
  16. package/dist/framework/prompt.js +1 -0
  17. package/dist/framework/prompt.js.map +1 -1
  18. package/dist/framework/query.d.ts +7 -0
  19. package/dist/framework/query.d.ts.map +1 -1
  20. package/dist/framework/query.js +44 -17
  21. package/dist/framework/query.js.map +1 -1
  22. package/dist/framework/store.d.ts +3 -0
  23. package/dist/framework/store.d.ts.map +1 -1
  24. package/dist/framework/store.js.map +1 -1
  25. package/dist/harness/assembler.d.ts +5 -0
  26. package/dist/harness/assembler.d.ts.map +1 -0
  27. package/dist/harness/assembler.js +71 -0
  28. package/dist/harness/assembler.js.map +1 -0
  29. package/dist/harness/capsule.d.ts +4 -0
  30. package/dist/harness/capsule.d.ts.map +1 -0
  31. package/dist/harness/capsule.js +99 -0
  32. package/dist/harness/capsule.js.map +1 -0
  33. package/dist/harness/context-harness.d.ts +41 -0
  34. package/dist/harness/context-harness.d.ts.map +1 -0
  35. package/dist/harness/context-harness.js +139 -0
  36. package/dist/harness/context-harness.js.map +1 -0
  37. package/dist/harness/contract.d.ts +4 -0
  38. package/dist/harness/contract.d.ts.map +1 -0
  39. package/dist/harness/contract.js +62 -0
  40. package/dist/harness/contract.js.map +1 -0
  41. package/dist/harness/drift-guard.d.ts +12 -0
  42. package/dist/harness/drift-guard.d.ts.map +1 -0
  43. package/dist/harness/drift-guard.js +50 -0
  44. package/dist/harness/drift-guard.js.map +1 -0
  45. package/dist/harness/index.d.ts +10 -0
  46. package/dist/harness/index.d.ts.map +1 -0
  47. package/dist/harness/index.js +21 -0
  48. package/dist/harness/index.js.map +1 -0
  49. package/dist/harness/ledger.d.ts +29 -0
  50. package/dist/harness/ledger.d.ts.map +1 -0
  51. package/dist/harness/ledger.js +122 -0
  52. package/dist/harness/ledger.js.map +1 -0
  53. package/dist/harness/types.d.ts +81 -0
  54. package/dist/harness/types.d.ts.map +1 -0
  55. package/dist/harness/types.js +3 -0
  56. package/dist/harness/types.js.map +1 -0
  57. package/dist/index.d.ts +2 -2
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +7 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/sdk/sessions.js +6 -6
  62. package/dist/sdk/sessions.js.map +1 -1
  63. package/dist/services/compact/auto-compact.d.ts +37 -8
  64. package/dist/services/compact/auto-compact.d.ts.map +1 -1
  65. package/dist/services/compact/auto-compact.js +80 -17
  66. package/dist/services/compact/auto-compact.js.map +1 -1
  67. package/dist/services/compact/compact.d.ts +3 -0
  68. package/dist/services/compact/compact.d.ts.map +1 -1
  69. package/dist/services/compact/compact.js +13 -1
  70. package/dist/services/compact/compact.js.map +1 -1
  71. package/dist/services/config-dir.d.ts +12 -0
  72. package/dist/services/config-dir.d.ts.map +1 -1
  73. package/dist/services/config-dir.js +42 -0
  74. package/dist/services/config-dir.js.map +1 -1
  75. package/dist/services/model-context.d.ts +44 -0
  76. package/dist/services/model-context.d.ts.map +1 -0
  77. package/dist/services/model-context.js +134 -0
  78. package/dist/services/model-context.js.map +1 -0
  79. package/dist/services/session-storage.d.ts +76 -1
  80. package/dist/services/session-storage.d.ts.map +1 -1
  81. package/dist/services/session-storage.js +343 -73
  82. package/dist/services/session-storage.js.map +1 -1
  83. package/dist/tools/bash_security.d.ts +10 -0
  84. package/dist/tools/bash_security.d.ts.map +1 -1
  85. package/dist/tools/bash_security.js +30 -1
  86. package/dist/tools/bash_security.js.map +1 -1
  87. package/dist/ui/command-panel.d.ts.map +1 -1
  88. package/dist/ui/command-panel.js +12 -12
  89. package/dist/ui/command-panel.js.map +1 -1
  90. package/dist/ui/stream-markdown.d.ts +1 -8
  91. package/dist/ui/stream-markdown.d.ts.map +1 -1
  92. package/dist/ui/stream-markdown.js +4 -129
  93. package/dist/ui/stream-markdown.js.map +1 -1
  94. package/dist/ui/user-input.d.ts +10 -0
  95. package/dist/ui/user-input.d.ts.map +1 -0
  96. package/dist/ui/user-input.js +66 -0
  97. package/dist/ui/user-input.js.map +1 -0
  98. package/package.json +1 -1
package/README.md CHANGED
@@ -1,219 +1,311 @@
1
1
  # OpenHorse
2
2
 
3
3
  > **OpenHorse — Universal Agent Harness Framework**
4
- > 一个完整的 Harness Coding CLI Agent
4
+ > A CLI-driven coding agent with safety boundaries, tool orchestration, memory, and context management.
5
5
 
6
6
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
7
  [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0-green.svg)](https://nodejs.org)
8
8
  [![TypeScript](https://img.shields.io/badge/typescript-5.0-blue.svg)](https://www.typescriptlang.org)
9
+ [![npm](https://img.shields.io/npm/v/openhorse.svg)](https://www.npmjs.com/package/openhorse)
9
10
 
10
11
  ---
11
12
 
12
- ## 🎯 项目定位
13
+ **🌍 Language**: English | [简体中文](README.zh-CN.md)
13
14
 
14
- **OpenHorse** — 一个完整的 Agent Harness Coding CLI 工具,提供安全边界、工具调用、记忆系统、MCP 协议支持。
15
+ ---
15
16
 
16
- ### 核心理念
17
+ ## Overview
17
18
 
18
- | 维度 | 说明 |
19
- |------|------|
20
- | **🐴 AI 如马** | 强大的 AI 模型需要引导和约束 |
21
- | **🪢 OpenHorse 如缰** | 精准控制方向,防止跑偏失控 |
22
- | **🎯 Harness 系统** | 安全边界、任务约束、结果验证 |
23
- | **🛠️ 工具调用** | LLM 自动调用工具完成任务 |
24
- | **🧠 记忆系统** | 分层记忆:Working / Short-term / Long-term |
25
- | **🔌 MCP 协议** | 支持 MCP 工具扩展 |
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.
26
20
 
27
- ---
21
+ ### Core Design
28
22
 
29
- ## 核心特性
23
+ | Dimension | Description |
24
+ |-----------|-------------|
25
+ | **AI as Horse** | Powerful models need guidance and constraints |
26
+ | **OpenHorse as Reins** | Precise control to prevent runaway behavior |
27
+ | **Harness System** | Safety boundaries, task constraints, result validation |
28
+ | **Tool Calling** | LLM autonomously invokes tools to complete tasks |
29
+ | **Memory System** | Layered memory: Working / Short-term / Long-term / Semantic |
30
+ | **MCP Protocol** | Connect external MCP servers for tool extension |
31
+
32
+ ---
30
33
 
31
- | 特性 | 说明 |
32
- |------|------|
33
- | **LLM 工具调用** | 支持 20+ 工具:文件读写、搜索、执行命令、网页抓取等 |
34
- | **多模型支持** | OpenAI、Claude、阿里百炼(GLM/Qwen/Kimi)、自定义 endpoint |
35
- | **MCP 协议** | 完整支持 MCP Server 连接和工具调用 |
36
- | **记忆系统** | 用户记忆、项目记忆、会话记忆三层存储 |
37
- | **会话管理** | 会话持久化、历史恢复、摘要生成 |
38
- | **安全边界** | Bash 命令白名单、危险模式检测、审计日志 |
39
- | **Todo/Plan** | 任务列表管理、计划模式切换 |
40
- | **流式输出** | 实时显示 LLM 响应,支持 Markdown 渲染 |
41
- | **状态栏** | Token 使用量、成本、MCP 连接状态实时显示 |
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 |
42
49
 
43
50
  ---
44
51
 
45
- ## 🏗️ 架构设计
52
+ ## Architecture
46
53
 
47
54
  ```
48
55
  ┌─────────────────────────────────────────────────────────┐
49
- │ CLI 交互层
50
- │ readline + chalk + 流式 Markdown + 状态栏
56
+ │ CLI Layer
57
+ │ readline + chalk + streaming Markdown + status bar
51
58
  └────────────────────────────┬────────────────────────────┘
52
59
 
53
60
  ┌────────────────────────────▼────────────────────────────┐
54
- │ Harness 驾驭层
55
- 目标约束边界检查 结果验证 Bash 安全 审计日志 │
61
+ │ Harness Layer
62
+ Goal constraints Safety checksResult validation
56
63
  └────────────────────────────┬────────────────────────────┘
57
64
 
58
65
  ┌────────────────────────────▼────────────────────────────┐
59
- │ Query 查询引擎
60
- │ LLM Stream │ Tool Calling │ Retry/Fallback │ Cost Tracker
66
+ │ Query Engine
67
+ │ LLM Stream │ Tool Calling │ Retry/Fallback │ Compact
61
68
  └──────────┬─────────────────┬─────────────────┬──────────┘
62
69
  │ │ │
63
70
  ┌──────────▼─────┐ ┌─────────▼─────┐ ┌─────────▼──────────┐
64
- │ Tools 工具集 │ │ MCP Client │ │ Skills 技能系统
65
- │ File/Bash/Web │ │ Server 连接 │ │ Builtin/User/Proj │
71
+ │ Tools │ │ MCP Client │ │ Skills
72
+ │ File/Bash/Web │ │ Server conn │ │ Builtin/User/Proj │
66
73
  └─────────────────┘ └───────────────┘ └───────────────────┘
67
74
 
68
75
  ┌────────────────────────────▼────────────────────────────┐
69
- │ Memory 记忆层
70
- │ User Memory │ Project Memory │ Session Memory │ Semantic│
76
+ │ Memory Layer
77
+ │ User │ Project │ Session │ Semantic Search Embeddings │
71
78
  └─────────────────────────────────────────────────────────┘
72
79
  ```
73
80
 
74
81
  ---
75
82
 
76
- ## 🚀 快速开始
83
+ ## Quick Start
77
84
 
78
- ### 环境要求
85
+ ### Requirements
79
86
 
80
87
  - Node.js >= 18.0
81
88
  - npm >= 9.0
82
89
 
83
- ### 安装与运行
90
+ ### Install & Run
84
91
 
85
92
  ```bash
86
- # 克隆项目
93
+ # Clone
87
94
  git clone https://github.com/Linux2010/openhorse.git
88
95
  cd openhorse
89
96
 
90
- # 安装依赖
97
+ # Install
91
98
  npm install
92
99
 
93
- # 构建
100
+ # Build
94
101
  npm run build
95
102
 
96
- # 配置 API Key(任选一种)
97
- # 方式 1: 环境变量
103
+ # Configure API Key (choose one)
104
+ # Option 1: Environment variable
98
105
  export OPENHORSE_API_KEY=your-api-key
99
106
 
100
- # 方式 2: .env 文件
107
+ # Option 2: .env file
101
108
  cp .env.example .env
102
- # 编辑 .env 设置 OPENHORSE_API_KEY
109
+ # Edit .env and set OPENHORSE_API_KEY
103
110
 
104
- # 方式 3: ~/.openhorse/openhorse.json(推荐)
105
- # 运行后会自动创建配置文件
111
+ # Option 3: ~/.openhorse/openhorse.json (recommended)
112
+ # Created automatically on first run
106
113
 
107
- # 启动交互式 CLI
114
+ # Start interactive CLI
108
115
  npm start
109
-
110
- # 或直接运行
116
+ # or
111
117
  node dist/cli.js
112
118
  ```
113
119
 
114
- ### 全局安装
120
+ ### Global Install
115
121
 
116
122
  ```bash
117
- # 本地链接
118
123
  npm link
119
-
120
- # 任意目录运行
124
+ # Run from any directory
121
125
  openhorse
122
126
  ```
123
127
 
124
128
  ---
125
129
 
126
- ## 📦 支持的模型
130
+ ## Configuration
127
131
 
128
- ### OpenAI 系列
132
+ ### User Config (`~/.openhorse/openhorse.json`)
129
133
 
130
- ```bash
131
- /model gpt-4o # GPT-4 Omni
132
- /model gpt-3.5-turbo # GPT-3.5
134
+ Only **4 fields** are user-configurable. The agent controls all internal parameters.
135
+
136
+ ```json
137
+ {
138
+ "apiKey": "sk-xxx",
139
+ "apiBaseUrl": "https://coding.dashscope.aliyuncs.com/v1",
140
+ "defaultModel": "glm-5",
141
+ "fallbackModel": "qwen-plus"
142
+ }
133
143
  ```
134
144
 
135
- ### Claude 系列
145
+ | Field | Required | Description |
146
+ |-------|----------|-------------|
147
+ | `apiKey` | Yes | LLM API key |
148
+ | `apiBaseUrl` | No | API endpoint URL |
149
+ | `defaultModel` | No | Default model (`glm-5`) |
150
+ | `fallbackModel` | No | Fallback model on failure |
136
151
 
137
- ```bash
138
- /model opus # Claude Opus 4.7
139
- /model sonnet # Claude Sonnet 4.6
140
- /model haiku # Claude Haiku 4.5
141
- ```
152
+ ### Agent-Controlled Internals
142
153
 
143
- ### 阿里百炼系列(coding.dashscope.aliyuncs.com)
154
+ These parameters are managed by the agent, not exposed to users:
155
+
156
+ | Parameter | Default | Description |
157
+ |-----------|---------|-------------|
158
+ | `maxTokens` | 8192 | Maximum output tokens |
159
+ | `temperature` | 0.1 | Sampling temperature |
160
+ | `maxRetries` | 3 | Retry attempts on failure |
161
+ | `retryBaseDelay` | 1000ms | Base delay between retries |
162
+
163
+ ### Configuration Priority
144
164
 
145
- ```bash
146
- /model qwen # Qwen 3.5 Plus
147
- /model qwenmax # Qwen 3 Max
148
- /model coder # Qwen 3 Coder Plus
149
- /model glm # GLM-5(智谱)
150
- /model kimi # Kimi K2.5(月之暗面)
151
- /model minimax # MiniMax M2.5
152
165
  ```
166
+ CLI flags > ~/.openhorse/openhorse.json > env vars > internal defaults
167
+ ```
168
+
169
+ ### Environment Variables
170
+
171
+ | Variable | Default | Description |
172
+ |----------|---------|-------------|
173
+ | `OPENHORSE_API_KEY` | - | LLM API key |
174
+ | `OPENHORSE_API_BASE_URL` | - | API base URL |
175
+ | `OPENHORSE_MODEL` | `glm-5` | Default model |
176
+ | `OPENHORSE_MODE` | `development` | Run mode |
177
+ | `OPENHORSE_LOG_LEVEL` | `info` | Log level |
178
+ | `OPENHORSE_EMBEDDING_PROVIDER` | - | Embedding service (ollama/openai) |
179
+
180
+ See [docs/config.md](docs/config.md) for full details.
181
+
182
+ ---
183
+
184
+ ## Models
185
+
186
+ ### Supported Model Families
187
+
188
+ | Provider | Models | Endpoint |
189
+ |----------|--------|----------|
190
+ | **GLM (智谱)** | `glm-5`, `glm-4` | DashScope coding |
191
+ | **Qwen (通义)** | `qwen-turbo`, `qwen-plus`, `qwen-max`, `qwen-long` | DashScope coding |
192
+ | **OpenAI** | `gpt-4o`, `gpt-4o-mini`, `gpt-4` | OpenAI API |
193
+ | **Claude** | `claude-sonnet-4-6`, `claude-opus-4-8` | Anthropic API |
194
+ | **DeepSeek** | `deepseek-chat`, `deepseek-reasoner` | DeepSeek API |
153
195
 
154
- ### 模型命令
196
+ ### Context Windows
197
+
198
+ OpenHorse tracks each model's context window and auto-compacts at **95% usage**:
199
+
200
+ | Model | Context | Max Output |
201
+ |-------|---------|------------|
202
+ | `glm-5` | 202,752 | 8,192 |
203
+ | `qwen-long` | 1,000,000 | 8,192 |
204
+ | `qwen-plus` | 131,072 | 8,192 |
205
+ | `gpt-4o` | 128,000 | 16,384 |
206
+ | `claude-sonnet-4-6` | 200,000 | 16,000 |
207
+ | `claude-opus-4-8` | 200,000 | 32,000 |
208
+
209
+ Unknown models default to **128,000** context.
210
+
211
+ ### Dynamic Discovery
212
+
213
+ 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.
214
+
215
+ ### Model Commands
155
216
 
156
217
  ```bash
157
- /model # 显示当前模型
158
- /model list # 显示所有可用模型
159
- /model sonnet # 切换到 Sonnet
218
+ /model # Show current model
219
+ /model list # List all available models
220
+ /model glm-5 # Switch to GLM-5
160
221
  ```
161
222
 
162
223
  ---
163
224
 
164
- ## 🛠️ 工具列表
225
+ ## Tools
226
+
227
+ 20+ built-in tools available for LLM invocation:
228
+
229
+ ### File Operations
230
+
231
+ | Tool | Description |
232
+ |------|-------------|
233
+ | `read_file` | Read file contents |
234
+ | `write_file` | Write to a file |
235
+ | `edit_file` | Edit file (line replacement) |
236
+ | `list_files` | List directory contents |
237
+ | `glob` | Glob pattern file search |
238
+ | `grep` | Regex search file contents |
239
+
240
+ ### Shell
241
+
242
+ | Tool | Description |
243
+ |------|-------------|
244
+ | `exec_command` | Execute shell command (with safety checks) |
245
+
246
+ ### Network
165
247
 
166
- OpenHorse 内置 20+ 工具,LLM 可自动调用:
248
+ | Tool | Description |
249
+ |------|-------------|
250
+ | `web_fetch` | Fetch web page content |
251
+ | `web_search` | Web search |
167
252
 
168
- ### 文件操作
253
+ ### Memory
169
254
 
170
- | 工具 | 功能 |
171
- |------|------|
172
- | `read_file` | 读取文件内容 |
173
- | `write_file` | 写入文件 |
174
- | `edit_file` | 编辑文件(行替换) |
175
- | `list_files` | 列出目录内容 |
176
- | `glob` | Glob 模式搜索文件 |
177
- | `grep` | 正则搜索文件内容 |
255
+ | Tool | Description |
256
+ |------|-------------|
257
+ | `memory_save` | Save a memory entry |
258
+ | `memory_recall` | Search memories |
259
+ | `memory_forget` | Delete a memory entry |
178
260
 
179
- ### Shell 执行
261
+ ### Task Management
180
262
 
181
- | 工具 | 功能 |
182
- |------|------|
183
- | `exec_command` | 执行 shell 命令(带安全检查) |
263
+ | Tool | Description |
264
+ |------|-------------|
265
+ | `todo_write` | Create/update todo list |
266
+ | `enter_plan_mode` | Enter plan mode |
267
+ | `exit_plan_mode` | Exit plan mode |
184
268
 
185
- ### 网络工具
269
+ ---
270
+
271
+ ## Context Management
272
+
273
+ ### Auto-Compact
274
+
275
+ When context usage reaches **95%**, OpenHorse automatically compacts the conversation history:
276
+
277
+ 1. **Generates a summary** of early messages via the LLM
278
+ 2. **Replaces** old messages with a `[Context Summary]` block
279
+ 3. **Preserves** the system message and recent messages
280
+ 4. **Displays** compact notification in the status bar
281
+
282
+ ```
283
+ Compact: 30 → 8 messages | Context: 45% → 12%
284
+ ```
285
+
286
+ ### Token-Based Threshold
186
287
 
187
- | 工具 | 功能 |
188
- |------|------|
189
- | `web_fetch` | 抓取网页内容 |
190
- | `web_search` | 网络搜索 |
288
+ Unlike message-count-based approaches, OpenHorse uses **actual token counts** from the API response for precise context awareness:
191
289
 
192
- ### 记忆系统
290
+ ```
291
+ ctxPercent = (promptTokens / modelContextWindow) × 100
292
+ ```
193
293
 
194
- | 工具 | 功能 |
195
- |------|------|
196
- | `memory_save` | 保存记忆 |
197
- | `memory_recall` | 搜索记忆 |
198
- | `memory_forget` | 删除记忆 |
294
+ Compact triggers only when `ctxPercent >= 95%`, not based on message count.
199
295
 
200
- ### 任务管理
296
+ ### 30-Second Interval
201
297
 
202
- | 工具 | 功能 |
203
- |------|------|
204
- | `todo_write` | 创建/更新任务列表 |
205
- | `enter_plan_mode` | 进入计划模式 |
206
- | `exit_plan_mode` | 退出计划模式 |
298
+ To avoid over-compact, auto-compact runs at most once per 30 seconds. Manual `/compact` command bypasses this interval.
207
299
 
208
300
  ---
209
301
 
210
- ## 🔌 MCP 协议支持
302
+ ## MCP Protocol
211
303
 
212
- OpenHorse 完整支持 MCPModel Context Protocol)协议:
304
+ Full support for MCP (Model Context Protocol) servers:
213
305
 
214
- ### 配置 MCP Server
306
+ ### Configure MCP Servers
215
307
 
216
- 创建 `~/.openhorse/mcp.json`:
308
+ Create `~/.openhorse/mcp.json`:
217
309
 
218
310
  ```json
219
311
  {
@@ -225,236 +317,209 @@ OpenHorse 完整支持 MCP(Model Context Protocol)协议:
225
317
  },
226
318
  "filesystem": {
227
319
  "command": "npx",
228
- "args": ["-y", "@anthropic/mcp-server-filesystem", "/path/to/allowed/dir"]
320
+ "args": ["-y", "@anthropic/mcp-server-filesystem", "/allowed/dir"]
229
321
  }
230
322
  }
231
323
  }
232
324
  ```
233
325
 
234
- ### MCP 命令
326
+ ### MCP Commands
235
327
 
236
328
  ```bash
237
- /mcp # 显示 MCP Server 连接状态
329
+ /mcp # Show MCP server connection status
238
330
  ```
239
331
 
240
- 启动时自动连接所有配置的 MCP Server。
332
+ Servers connect automatically at startup with heartbeat monitoring and exponential backoff reconnect.
241
333
 
242
334
  ---
243
335
 
244
- ## 💬 交互命令
245
-
246
- | 命令 | 别名 | 说明 |
247
- |------|------|------|
248
- | `/help` | `/h` | 显示帮助信息 |
249
- | `/status` | `/s` | 系统状态总览 |
250
- | `/model` | - | 查看或切换模型 |
251
- | `/config` | - | 显示当前配置 |
252
- | `/cost` | - | 显示会话 token 使用量 |
253
- | `/usage` | `/stats` | 详细使用统计 |
254
- | `/sessions` | - | 列出最近会话 |
255
- | `/resume` | - | 恢复上次会话 |
256
- | `/memory` | - | 记忆系统状态 |
257
- | `/memory reindex` | - | 重建语义搜索索引 |
258
- | `/skills` | - | 列出加载的技能 |
259
- | `/mcp` | - | MCP Server 状态 |
260
- | `/agents` | - | Agent 列表 |
261
- | `/safety` | - | 安全检查配置 |
262
- | `/harness` | - | Harness 配置 |
263
- | `/task` | - | 任务管理 |
264
- | `/run` | - | 通过 Agent 执行任务 |
265
- | `/clear` | - | 清屏 |
266
- | `/clear-history` | `/reset` | 清除对话历史 |
267
- | `/exit` | `/q` | 退出 |
336
+ ## Interactive Commands
337
+
338
+ | Command | Alias | Description |
339
+ |---------|-------|-------------|
340
+ | `/help` | `/h` | Show help information |
341
+ | `/status` | `/s` | System status overview |
342
+ | `/model` | - | View or switch models |
343
+ | `/config` | - | Show current configuration |
344
+ | `/cost` | - | Show session token usage and cost |
345
+ | `/compact` | - | Manually trigger context compact |
346
+ | `/sessions` | - | List recent sessions |
347
+ | `/resume` | - | Resume last session |
348
+ | `/memory` | - | Memory system status |
349
+ | `/memory reindex` | - | Rebuild semantic search index |
350
+ | `/skills` | - | List loaded skills |
351
+ | `/mcp` | - | MCP server status |
352
+ | `/agents` | - | List available agents |
353
+ | `/safety` | - | Safety check configuration |
354
+ | `/task` | - | Task management |
355
+ | `/run` | - | Execute task via agent |
356
+ | `/clear` | - | Clear screen |
357
+ | `/clear-history` | `/reset` | Clear conversation history |
358
+ | `/exit` | `/q` | Exit |
268
359
 
269
360
  ---
270
361
 
271
- ## 📁 项目结构
362
+ ## Project Structure
272
363
 
273
364
  ```
274
365
  openhorse/
275
366
  ├── bin/
276
- │ └── openhorse # CLI 入口
367
+ │ └── openhorse # CLI entry point
277
368
  ├── src/
278
- │ ├── cli.ts # 命令行交互入口
279
- │ ├── commands/
280
- │ │ ├── index.ts # 命令注册表
281
- │ │ ├── parser.ts # 输入解析
282
- │ │ └── types.ts # 命令类型定义
283
- │ ├── core/
284
- │ │ ├── agent.ts # Agent 基类
285
- │ │ ├── brain.ts # 决策引擎
286
- │ │ └── strategy-tracker.ts # 策略追踪
287
- │ ├── agents/
288
- │ │ ├── leader.ts # 协调者 Agent
289
- │ │ ├── coder.ts # 编码 Agent
290
- │ │ └── router.ts # Agent 路由
369
+ │ ├── cli.ts # CLI interactive entry
370
+ │ ├── commands/ # Slash commands
371
+ │ │ ├── index.ts # Command registry
372
+ │ │ ├── parser.ts # Input parser
373
+ │ │ └── types.ts # Command types
374
+ │ ├── core/ # Core logic
375
+ │ │ ├── agent.ts # Agent base class
376
+ │ │ ├── brain.ts # Decision engine
377
+ │ │ └── strategy-tracker.ts # Strategy tracking
378
+ │ ├── agents/ # Agent implementations
379
+ │ │ ├── leader.ts # Coordinator agent
380
+ │ │ ├── coder.ts # Coding agent
381
+ │ │ └── router.ts # Agent router
291
382
  │ ├── framework/
292
- │ │ ├── store.ts # 状态管理
293
- │ │ ├── query.ts # 查询引擎
294
- │ │ └── tool-state.ts # 工具状态管理
295
- │ ├── harness/
296
- │ │ ├── safety.ts # 安全边界检查
297
- │ │ └── bash-safety.ts # Bash 命令安全
298
- │ └── harness.ts # Harness 引擎
299
- │ ├── memory/
300
- │ │ ├── storage.ts # 记忆存储
301
- │ │ ├── semantic-search.ts # 语义搜索
302
- │ │ ├── embeddings.ts # Embedding 生成
303
- │ └── vector-store.ts # 向量存储
304
- │ ├── skills/
305
- │ │ ├── loader.ts # 技能加载器
306
- │ │ └ registry.ts # 技能注册表
383
+ │ │ ├── store.ts # State management
384
+ │ │ ├── query.ts # Query engine (async generator)
385
+ │ │ └── tool-state.ts # Tool state
386
+ │ ├── harness/ # Safety & constraints
387
+ │ │ ├── safety.ts # Safety boundary checks
388
+ │ │ └── bash-safety.ts # Bash command safety
389
+ ├── memory/ # Memory system
390
+ ├── storage.ts # Memory storage
391
+ │ │ ├── semantic-search.ts # Semantic search
392
+ │ │ ├── embeddings.ts # Embedding generation
393
+ │ │ └── vector-store.ts # Vector store (SQLite vec0)
394
+ ├── skills/ # Skill system
395
+ ├── loader.ts # Skill loader
396
+ │ │ └── registry.ts # Skill registry
307
397
  │ ├── services/
308
- │ │ ├── llm.ts # LLM 服务(含 Retry/Fallback)
309
- │ │ ├── config.ts # 配置加载
310
- │ │ ├── global-config.ts # 全局配置管理
311
- │ │ ├── session-storage.ts # 会话持久化
312
- │ │ ├── atomic-write.ts # 原子文件写入
313
- │ │ ├── agent-runner.ts # Agent 执行器
314
- │ │ task-manager.ts # 任务管理器
315
- │ │ ├── file-glob.ts # 文件匹配
316
- │ │ mcp-bootstrap.ts # MCP 启动
317
- │ ├── tools/
318
- │ │ ├── index.ts # 工具集注册
319
- │ │ ├── mcp.ts # MCP 客户端(心跳/重连)
320
- │ │ ├── todo.ts # Todo 工具
321
- ├── plan.ts # Plan 工具
322
- │ │ web.ts # Web 工具
323
- │ │ memory.ts # Memory 工具
324
- │ ├── ui/
325
- │ │ ├── box.ts # UI 组件(Header/Spinner)
326
- │ │ ├── markdown.ts # Markdown 渲染
327
- │ │ ├── status-bar.ts # 状态栏
328
- │ ├── stream-markdown.ts # 流式 Markdown
329
- ├── tool-preview.ts # 工具预览卡片
330
- │ └ suggestions.ts # 命令建议
331
- └── index.ts # 公共 API 导出
332
- ├── tests/
333
- ├── ui.test.ts # UI 组件测试
334
- ├── config.test.ts # 配置测试
335
- │ └ ...
336
- ├── docs/
337
- │ ├── roadmap/ # 版本路线图
338
- ├── v0.1.1.md
339
- │ ├── v0.1.2.md
340
- │ │ ├── v0.1.3.md
341
- │ │ ├── v0.1.4.md
342
- │ │ ├── v0.1.4-plus.md
343
- │ │ └ v0.1.5.md
344
- │ │ └ ...
345
- │ ├── architecture.md # 架构设计
346
- │ ├── harness-design.md # Harness 系统
347
- │ └ memory-system.md # 记忆系统
348
- │ └ agent-lifecycle.md # Agent 生命周期
349
- ├── .env.example # 环境变量模板
398
+ │ │ ├── llm.ts # LLM service (retry/fallback)
399
+ │ │ ├── config.ts # Config loading
400
+ │ │ ├── global-config.ts # Global config
401
+ │ │ ├── model-context.ts # Model context window DB + discovery
402
+ │ │ ├── session-storage.ts # Session persistence
403
+ │ │ ├── atomic-write.ts # Atomic file writes
404
+ │ │ ├── agent-runner.ts # Agent runner
405
+ │ │ ├── task-manager.ts # Task manager
406
+ │ │ └── file-glob.ts # File matching
407
+ │ ├── services/compact/ # Context compaction
408
+ │ │ ├── auto-compact.ts # Token-based auto-compact
409
+ │ │ ├── compact.ts # Compact implementation
410
+ │ │ └── summary-generator.ts # Summary generation
411
+ │ ├── tools/ # Tool implementations
412
+ │ │ ├── index.ts # Tool registry
413
+ │ │ ├── mcp.ts # MCP client
414
+ ├── todo.ts # Todo tool
415
+ │ │ ├── plan.ts # Plan tool
416
+ │ │ ├── web.ts # Web tools
417
+ │ │ └── memory.ts # Memory tools
418
+ └── ui/ # UI components
419
+ ├── box.ts # UI boxes
420
+ ├── markdown.ts # Markdown rendering
421
+ ├── status-bar.ts # Status bar
422
+ ├── stream-markdown.ts # Streaming Markdown
423
+ ├── tool-preview.ts # Tool preview cards
424
+ └── suggestions.ts # Command suggestions
425
+ ├── tests/ # Test suite
426
+ ├── docs/ # Documentation
427
+ │ ├── version/ # Version release notes
428
+ │ ├── roadmap/ # Version roadmaps
429
+ └── config.md # Configuration guide
430
+ ├── .env.example # Environment template
350
431
  ├── package.json
351
- tsconfig.json
352
- └ LICENSE
353
- └ README.md
432
+ └── tsconfig.json
354
433
  ```
355
434
 
356
435
  ---
357
436
 
358
- ## 📝 环境变量
437
+ ## Version History
359
438
 
360
- | 变量 | 默认值 | 说明 |
361
- |------|--------|------|
362
- | `OPENHORSE_API_KEY` | - | LLM API Key |
363
- | `OPENHORSE_API_BASE_URL` | - | LLM API Base URL |
364
- | `OPENHORSE_MODEL` | `gpt-4o` | 默认模型 |
365
- | `OPENHORSE_MAX_TOKENS` | `4096` | 最大输出 token |
366
- | `OPENHORSE_TEMPERATURE` | `0.7` | 温度 |
367
- | `OPENHORSE_MODE` | `development` | 运行模式 |
368
- | `OPENHORSE_LOG_LEVEL` | `info` | 日志级别 |
369
- | `OPENHORSE_EMBEDDING_PROVIDER` | - | Embedding 服务(ollama/openai) |
370
- | `OPENHORSE_BUDGET_LIMIT` | - | 预算限制(USD) |
439
+ ### v0.1.16 (Current in development)
371
440
 
372
- ---
441
+ - **Token-based auto-compact** at 95% context usage (replaces message-count threshold)
442
+ - **Model context awareness** — per-model context windows (15+ known models)
443
+ - **Dynamic model discovery** — queries `/models` endpoint at startup
444
+ - **Simplified user config** — only 4 fields: `apiKey`, `apiBaseUrl`, `defaultModel`, `fallbackModel`
445
+ - **Agent-controlled internals** — `maxTokens`, `temperature`, `retries` managed internally
446
+ - **Fallback model** configurable by user
447
+ - **Streamlined command panel** rendering
448
+ - **Context harness workflow** for multi-agent context orchestration
373
449
 
374
- ## 📚 版本历史
450
+ ### v0.1.15
375
451
 
376
- ### v0.1.5 - CLI 交互体验增强
452
+ - **Full Markdown streaming** rendering with syntax highlighting
453
+ - **CJK text width** calculation fix for terminal display
454
+ - **Command panel** input clearing improvements
455
+ - Table rendering removed (raw passthrough)
377
456
 
378
- - 状态栏:实时显示 token/cost/MCP 状态
379
- - 流式 Markdown 渲染:代码块缓冲防断裂
380
- - 工具预览卡片:工具执行结果可视化
381
- - UI 组件测试
457
+ ### v0.1.14
382
458
 
383
- ### v0.1.4-plus - 集成与健壮性
459
+ - LSP crash fix, compact UI, concise agent output
384
460
 
385
- - MCP 客户端:心跳、断线重连、自动启动
386
- - 状态管理:Todo/Plan 状态持久化
387
- - 语义搜索:Embedding + Vector Store
388
- - Skills 系统:技能加载与注入
389
- - 原子写入:防止数据损坏
390
- - 模型别名:Bailian 模型支持
461
+ ### v0.1.10 — v0.1.13
391
462
 
392
- ### v0.1.4 - 工具扩展与 MCP
463
+ - MCP client with heartbeat/reconnect, semantic search, skills system, atomic writes, model aliases (Bailian), storage fixes
393
464
 
394
- - 20+ 工具:File/Bash/Web/Memory/Todo/Plan
395
- - MCP 协议支持
396
- - 多模型支持
465
+ ### v0.1.1 — v0.1.9
397
466
 
398
- ### v0.1.1 - v0.1.3 - 基础架构
467
+ - CLI framework, harness system, memory system, session management, tool orchestration
399
468
 
400
- - CLI 交互框架
401
- - Harness 驾驭系统
402
- - 记忆系统
403
- - 会话管理
469
+ See `docs/version/` for detailed release notes.
404
470
 
405
471
  ---
406
472
 
407
- ## 🔧 开发
473
+ ## Development
408
474
 
409
475
  ```bash
410
- # 安装依赖
476
+ # Install dependencies
411
477
  npm install
412
478
 
413
- # 开发模式(热重载)
479
+ # Development mode (hot reload)
414
480
  npm run dev
415
481
 
416
- # 构建
482
+ # Build
417
483
  npm run build
418
484
 
419
- # 运行测试
485
+ # Run tests
420
486
  npm test
421
487
 
422
- # 代码检查
488
+ # Lint
423
489
  npm run lint
424
490
 
425
- # 格式化
491
+ # Format
426
492
  npm run format
427
493
  ```
428
494
 
429
495
  ---
430
496
 
431
- ## 📖 Roadmap
497
+ ## Roadmap
432
498
 
433
- | 版本 | 目标 |
434
- |------|------|
435
- | v0.1.5 | CLI UX:状态栏、流式 Markdown、工具卡片 |
436
- | v0.1.6 | Agent 增强:Router、多 Agent 协作 |
437
- | v0.1.7 | Hooks 系统:工具调用前后钩子 |
438
- | v0.1.8 | Cron 定时任务:定时执行、提醒 |
439
- | v0.1.9 | VS Code 扩展 |
440
- | v0.1.10 | Web UI |
499
+ | Version | Target |
500
+ |---------|--------|
501
+ | v0.1.16 | Context awareness, auto-compact, config simplification |
502
+ | v0.1.17 | Agent lifecycle improvements, enhanced tool orchestration |
503
+ | v0.1.18 | Plugin/hook system for extensibility |
504
+ | v0.1.19 | VS Code extension |
505
+ | v0.1.20 | Web UI dashboard |
441
506
 
442
- 详见 `docs/roadmap/` 目录。
507
+ See `docs/roadmap/` for details.
443
508
 
444
509
  ---
445
510
 
446
- ## 🤝 贡献
511
+ ## Contributing
447
512
 
448
- 欢迎提交 Issue Pull Request!
513
+ Issues and Pull Requests are welcome!
449
514
 
450
515
  ---
451
516
 
452
- ## 📝 许可
517
+ ## License
453
518
 
454
- MIT License - See [LICENSE](LICENSE) for details
519
+ MIT License see [LICENSE](LICENSE) for details.
455
520
 
456
521
  ---
457
522
 
458
523
  **OpenHorse — Universal Agent Harness Framework.**
459
524
 
460
- *"AI 如马,OpenHorse 如缰。"*
525
+ *"AI as a horse, OpenHorse as the reins."*