openhorse 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,219 +1,314 @@
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 a small set of fields are user-configurable. The agent controls internal generation 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
+ "toolConfirmation": "allow"
143
+ }
133
144
  ```
134
145
 
135
- ### Claude 系列
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. |
136
153
 
137
- ```bash
138
- /model opus # Claude Opus 4.7
139
- /model sonnet # Claude Sonnet 4.6
140
- /model haiku # Claude Haiku 4.5
141
- ```
154
+ ### Agent-Controlled Internals
142
155
 
143
- ### 阿里百炼系列(coding.dashscope.aliyuncs.com)
156
+ These parameters are managed by the agent, not exposed to users:
157
+
158
+ | Parameter | Default | Description |
159
+ |-----------|---------|-------------|
160
+ | `maxTokens` | 8192 | Maximum output tokens |
161
+ | `temperature` | 0.1 | Sampling temperature |
162
+ | `maxRetries` | 3 | Retry attempts on failure |
163
+ | `retryBaseDelay` | 1000ms | Base delay between retries |
164
+
165
+ ### Configuration Priority
144
166
 
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
167
  ```
168
+ CLI flags > ~/.openhorse/openhorse.json > env vars > internal defaults
169
+ ```
170
+
171
+ ### Environment Variables
172
+
173
+ | Variable | Default | Description |
174
+ |----------|---------|-------------|
175
+ | `OPENHORSE_API_KEY` | - | LLM API key |
176
+ | `OPENHORSE_API_BASE_URL` | - | API base URL |
177
+ | `OPENHORSE_MODEL` | `glm-5` | Default model |
178
+ | `OPENHORSE_MODE` | `development` | Run mode |
179
+ | `OPENHORSE_LOG_LEVEL` | `info` | Log level |
180
+ | `OPENHORSE_TOOL_CONFIRMATION` | `allow` | Tool confirmation fallback: `allow`, `deny`, or `ask` |
181
+ | `OPENHORSE_EMBEDDING_PROVIDER` | - | Embedding service (ollama/openai) |
182
+
183
+ See [docs/config.md](docs/config.md) for full details.
184
+
185
+ ---
186
+
187
+ ## Models
188
+
189
+ ### Supported Model Families
190
+
191
+ | Provider | Models | Endpoint |
192
+ |----------|--------|----------|
193
+ | **GLM (智谱)** | `glm-5`, `glm-4` | DashScope coding |
194
+ | **Qwen (通义)** | `qwen-turbo`, `qwen-plus`, `qwen-max`, `qwen-long` | DashScope coding |
195
+ | **OpenAI** | `gpt-4o`, `gpt-4o-mini`, `gpt-4` | OpenAI API |
196
+ | **Claude** | `claude-sonnet-4-6`, `claude-opus-4-8` | Anthropic API |
197
+ | **DeepSeek** | `deepseek-chat`, `deepseek-reasoner` | DeepSeek API |
153
198
 
154
- ### 模型命令
199
+ ### Context Windows
200
+
201
+ OpenHorse tracks each model's context window and auto-compacts at **95% usage**:
202
+
203
+ | Model | Context | Max Output |
204
+ |-------|---------|------------|
205
+ | `glm-5` | 202,752 | 8,192 |
206
+ | `qwen-long` | 1,000,000 | 8,192 |
207
+ | `qwen-plus` | 131,072 | 8,192 |
208
+ | `gpt-4o` | 128,000 | 16,384 |
209
+ | `claude-sonnet-4-6` | 200,000 | 16,000 |
210
+ | `claude-opus-4-8` | 200,000 | 32,000 |
211
+
212
+ Unknown models default to **128,000** context.
213
+
214
+ ### Dynamic Discovery
215
+
216
+ 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.
217
+
218
+ ### Model Commands
155
219
 
156
220
  ```bash
157
- /model # 显示当前模型
158
- /model list # 显示所有可用模型
159
- /model sonnet # 切换到 Sonnet
221
+ /model # Show current model
222
+ /model list # List all available models
223
+ /model glm-5 # Switch to GLM-5
160
224
  ```
161
225
 
162
226
  ---
163
227
 
164
- ## 🛠️ 工具列表
228
+ ## Tools
229
+
230
+ 20+ built-in tools available for LLM invocation:
231
+
232
+ ### File Operations
233
+
234
+ | Tool | Description |
235
+ |------|-------------|
236
+ | `read_file` | Read file contents |
237
+ | `write_file` | Write to a file |
238
+ | `edit_file` | Edit file (line replacement) |
239
+ | `list_files` | List directory contents |
240
+ | `glob` | Glob pattern file search |
241
+ | `grep` | Regex search file contents |
242
+
243
+ ### Shell
244
+
245
+ | Tool | Description |
246
+ |------|-------------|
247
+ | `exec_command` | Execute shell command (with safety checks) |
248
+
249
+ ### Network
165
250
 
166
- OpenHorse 内置 20+ 工具,LLM 可自动调用:
251
+ | Tool | Description |
252
+ |------|-------------|
253
+ | `web_fetch` | Fetch web page content |
254
+ | `web_search` | Web search |
167
255
 
168
- ### 文件操作
256
+ ### Memory
169
257
 
170
- | 工具 | 功能 |
171
- |------|------|
172
- | `read_file` | 读取文件内容 |
173
- | `write_file` | 写入文件 |
174
- | `edit_file` | 编辑文件(行替换) |
175
- | `list_files` | 列出目录内容 |
176
- | `glob` | Glob 模式搜索文件 |
177
- | `grep` | 正则搜索文件内容 |
258
+ | Tool | Description |
259
+ |------|-------------|
260
+ | `memory_save` | Save a memory entry |
261
+ | `memory_recall` | Search memories |
262
+ | `memory_forget` | Delete a memory entry |
178
263
 
179
- ### Shell 执行
264
+ ### Task Management
180
265
 
181
- | 工具 | 功能 |
182
- |------|------|
183
- | `exec_command` | 执行 shell 命令(带安全检查) |
266
+ | Tool | Description |
267
+ |------|-------------|
268
+ | `todo_write` | Create/update todo list |
269
+ | `enter_plan_mode` | Enter plan mode |
270
+ | `exit_plan_mode` | Exit plan mode |
184
271
 
185
- ### 网络工具
272
+ ---
273
+
274
+ ## Context Management
275
+
276
+ ### Auto-Compact
277
+
278
+ When context usage reaches **95%**, OpenHorse automatically compacts the conversation history:
279
+
280
+ 1. **Generates a summary** of early messages via the LLM
281
+ 2. **Replaces** old messages with a `[Context Summary]` block
282
+ 3. **Preserves** the system message and recent messages
283
+ 4. **Displays** compact notification in the status bar
284
+
285
+ ```
286
+ Compact: 30 → 8 messages | Context: 45% → 12%
287
+ ```
288
+
289
+ ### Token-Based Threshold
186
290
 
187
- | 工具 | 功能 |
188
- |------|------|
189
- | `web_fetch` | 抓取网页内容 |
190
- | `web_search` | 网络搜索 |
291
+ Unlike message-count-based approaches, OpenHorse uses **actual token counts** from the API response for precise context awareness:
191
292
 
192
- ### 记忆系统
293
+ ```
294
+ ctxPercent = (promptTokens / modelContextWindow) × 100
295
+ ```
193
296
 
194
- | 工具 | 功能 |
195
- |------|------|
196
- | `memory_save` | 保存记忆 |
197
- | `memory_recall` | 搜索记忆 |
198
- | `memory_forget` | 删除记忆 |
297
+ Compact triggers only when `ctxPercent >= 95%`, not based on message count.
199
298
 
200
- ### 任务管理
299
+ ### 30-Second Interval
201
300
 
202
- | 工具 | 功能 |
203
- |------|------|
204
- | `todo_write` | 创建/更新任务列表 |
205
- | `enter_plan_mode` | 进入计划模式 |
206
- | `exit_plan_mode` | 退出计划模式 |
301
+ To avoid over-compact, auto-compact runs at most once per 30 seconds. Manual `/compact` command bypasses this interval.
207
302
 
208
303
  ---
209
304
 
210
- ## 🔌 MCP 协议支持
305
+ ## MCP Protocol
211
306
 
212
- OpenHorse 完整支持 MCPModel Context Protocol)协议:
307
+ Full support for MCP (Model Context Protocol) servers:
213
308
 
214
- ### 配置 MCP Server
309
+ ### Configure MCP Servers
215
310
 
216
- 创建 `~/.openhorse/mcp.json`:
311
+ Create `~/.openhorse/mcp.json`:
217
312
 
218
313
  ```json
219
314
  {
@@ -225,236 +320,209 @@ OpenHorse 完整支持 MCP(Model Context Protocol)协议:
225
320
  },
226
321
  "filesystem": {
227
322
  "command": "npx",
228
- "args": ["-y", "@anthropic/mcp-server-filesystem", "/path/to/allowed/dir"]
323
+ "args": ["-y", "@anthropic/mcp-server-filesystem", "/allowed/dir"]
229
324
  }
230
325
  }
231
326
  }
232
327
  ```
233
328
 
234
- ### MCP 命令
329
+ ### MCP Commands
235
330
 
236
331
  ```bash
237
- /mcp # 显示 MCP Server 连接状态
332
+ /mcp # Show MCP server connection status
238
333
  ```
239
334
 
240
- 启动时自动连接所有配置的 MCP Server。
335
+ Servers connect automatically at startup with heartbeat monitoring and exponential backoff reconnect.
241
336
 
242
337
  ---
243
338
 
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` | 退出 |
339
+ ## Interactive Commands
340
+
341
+ | Command | Alias | Description |
342
+ |---------|-------|-------------|
343
+ | `/help` | `/h` | Show help information |
344
+ | `/status` | `/s` | System status overview |
345
+ | `/model` | - | View or switch models |
346
+ | `/config` | - | Show current configuration |
347
+ | `/cost` | - | Show session token usage and cost |
348
+ | `/compact` | - | Manually trigger context compact |
349
+ | `/sessions` | - | List recent sessions |
350
+ | `/resume` | - | Resume last session |
351
+ | `/memory` | - | Memory system status |
352
+ | `/memory reindex` | - | Rebuild semantic search index |
353
+ | `/skills` | - | List loaded skills |
354
+ | `/mcp` | - | MCP server status |
355
+ | `/agents` | - | List available agents |
356
+ | `/safety` | - | Safety check configuration |
357
+ | `/task` | - | Task management |
358
+ | `/run` | - | Execute task via agent |
359
+ | `/clear` | - | Clear screen |
360
+ | `/clear-history` | `/reset` | Clear conversation history |
361
+ | `/exit` | `/q` | Exit |
268
362
 
269
363
  ---
270
364
 
271
- ## 📁 项目结构
365
+ ## Project Structure
272
366
 
273
367
  ```
274
368
  openhorse/
275
369
  ├── bin/
276
- │ └── openhorse # CLI 入口
370
+ │ └── openhorse # CLI entry point
277
371
  ├── 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 路由
372
+ │ ├── cli.ts # CLI interactive entry
373
+ │ ├── commands/ # Slash commands
374
+ │ │ ├── index.ts # Command registry
375
+ │ │ ├── parser.ts # Input parser
376
+ │ │ └── types.ts # Command types
377
+ │ ├── core/ # Core logic
378
+ │ │ ├── agent.ts # Agent base class
379
+ │ │ ├── brain.ts # Decision engine
380
+ │ │ └── strategy-tracker.ts # Strategy tracking
381
+ │ ├── agents/ # Agent implementations
382
+ │ │ ├── leader.ts # Coordinator agent
383
+ │ │ ├── coder.ts # Coding agent
384
+ │ │ └── router.ts # Agent router
291
385
  │ ├── 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 # 技能注册表
386
+ │ │ ├── store.ts # State management
387
+ │ │ ├── query.ts # Query engine (async generator)
388
+ │ │ └── tool-state.ts # Tool state
389
+ │ ├── harness/ # Safety & constraints
390
+ │ │ ├── safety.ts # Safety boundary checks
391
+ │ │ └── bash-safety.ts # Bash command safety
392
+ ├── memory/ # Memory system
393
+ ├── storage.ts # Memory storage
394
+ │ │ ├── semantic-search.ts # Semantic search
395
+ │ │ ├── embeddings.ts # Embedding generation
396
+ │ │ └── vector-store.ts # Vector store (SQLite vec0)
397
+ ├── skills/ # Skill system
398
+ ├── loader.ts # Skill loader
399
+ │ │ └── registry.ts # Skill registry
307
400
  │ ├── 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 # 环境变量模板
401
+ │ │ ├── llm.ts # LLM service (retry/fallback)
402
+ │ │ ├── config.ts # Config loading
403
+ │ │ ├── global-config.ts # Global config
404
+ │ │ ├── model-context.ts # Model context window DB + discovery
405
+ │ │ ├── session-storage.ts # Session persistence
406
+ │ │ ├── atomic-write.ts # Atomic file writes
407
+ │ │ ├── agent-runner.ts # Agent runner
408
+ │ │ ├── task-manager.ts # Task manager
409
+ │ │ └── file-glob.ts # File matching
410
+ │ ├── services/compact/ # Context compaction
411
+ │ │ ├── auto-compact.ts # Token-based auto-compact
412
+ │ │ ├── compact.ts # Compact implementation
413
+ │ │ └── summary-generator.ts # Summary generation
414
+ │ ├── tools/ # Tool implementations
415
+ │ │ ├── index.ts # Tool registry
416
+ │ │ ├── mcp.ts # MCP client
417
+ ├── todo.ts # Todo tool
418
+ │ │ ├── plan.ts # Plan tool
419
+ │ │ ├── web.ts # Web tools
420
+ │ │ └── memory.ts # Memory tools
421
+ └── ui/ # UI components
422
+ ├── box.ts # UI boxes
423
+ ├── markdown.ts # Markdown rendering
424
+ ├── status-bar.ts # Status bar
425
+ ├── stream-markdown.ts # Streaming Markdown
426
+ ├── tool-preview.ts # Tool preview cards
427
+ └── suggestions.ts # Command suggestions
428
+ ├── tests/ # Test suite
429
+ ├── docs/ # Documentation
430
+ │ ├── version/ # Version release notes
431
+ │ ├── roadmap/ # Version roadmaps
432
+ └── config.md # Configuration guide
433
+ ├── .env.example # Environment template
350
434
  ├── package.json
351
- tsconfig.json
352
- └ LICENSE
353
- └ README.md
435
+ └── tsconfig.json
354
436
  ```
355
437
 
356
438
  ---
357
439
 
358
- ## 📝 环境变量
440
+ ## Version History
359
441
 
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) |
442
+ ### v0.1.16 (Current in development)
371
443
 
372
- ---
444
+ - **Token-based auto-compact** at 95% context usage (replaces message-count threshold)
445
+ - **Model context awareness** — per-model context windows (15+ known models)
446
+ - **Dynamic model discovery** — queries `/models` endpoint at startup
447
+ - **Simplified user config** — core fields: `apiKey`, `apiBaseUrl`, `defaultModel`, `fallbackModel`, `toolConfirmation`
448
+ - **Agent-controlled internals** — `maxTokens`, `temperature`, `retries` managed internally
449
+ - **Fallback model** configurable by user
450
+ - **Streamlined command panel** rendering
451
+ - **Context harness workflow** for multi-agent context orchestration
373
452
 
374
- ## 📚 版本历史
453
+ ### v0.1.15
375
454
 
376
- ### v0.1.5 - CLI 交互体验增强
455
+ - **Full Markdown streaming** rendering with syntax highlighting
456
+ - **CJK text width** calculation fix for terminal display
457
+ - **Command panel** input clearing improvements
458
+ - Table rendering removed (raw passthrough)
377
459
 
378
- - 状态栏:实时显示 token/cost/MCP 状态
379
- - 流式 Markdown 渲染:代码块缓冲防断裂
380
- - 工具预览卡片:工具执行结果可视化
381
- - UI 组件测试
460
+ ### v0.1.14
382
461
 
383
- ### v0.1.4-plus - 集成与健壮性
462
+ - LSP crash fix, compact UI, concise agent output
384
463
 
385
- - MCP 客户端:心跳、断线重连、自动启动
386
- - 状态管理:Todo/Plan 状态持久化
387
- - 语义搜索:Embedding + Vector Store
388
- - Skills 系统:技能加载与注入
389
- - 原子写入:防止数据损坏
390
- - 模型别名:Bailian 模型支持
464
+ ### v0.1.10 — v0.1.13
391
465
 
392
- ### v0.1.4 - 工具扩展与 MCP
466
+ - MCP client with heartbeat/reconnect, semantic search, skills system, atomic writes, model aliases (Bailian), storage fixes
393
467
 
394
- - 20+ 工具:File/Bash/Web/Memory/Todo/Plan
395
- - MCP 协议支持
396
- - 多模型支持
468
+ ### v0.1.1 — v0.1.9
397
469
 
398
- ### v0.1.1 - v0.1.3 - 基础架构
470
+ - CLI framework, harness system, memory system, session management, tool orchestration
399
471
 
400
- - CLI 交互框架
401
- - Harness 驾驭系统
402
- - 记忆系统
403
- - 会话管理
472
+ See `docs/version/` for detailed release notes.
404
473
 
405
474
  ---
406
475
 
407
- ## 🔧 开发
476
+ ## Development
408
477
 
409
478
  ```bash
410
- # 安装依赖
479
+ # Install dependencies
411
480
  npm install
412
481
 
413
- # 开发模式(热重载)
482
+ # Development mode (hot reload)
414
483
  npm run dev
415
484
 
416
- # 构建
485
+ # Build
417
486
  npm run build
418
487
 
419
- # 运行测试
488
+ # Run tests
420
489
  npm test
421
490
 
422
- # 代码检查
491
+ # Lint
423
492
  npm run lint
424
493
 
425
- # 格式化
494
+ # Format
426
495
  npm run format
427
496
  ```
428
497
 
429
498
  ---
430
499
 
431
- ## 📖 Roadmap
500
+ ## Roadmap
432
501
 
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 |
502
+ | Version | Target |
503
+ |---------|--------|
504
+ | v0.1.16 | Context awareness, auto-compact, config simplification |
505
+ | v0.1.17 | Agent lifecycle improvements, enhanced tool orchestration |
506
+ | v0.1.18 | Plugin/hook system for extensibility |
507
+ | v0.1.19 | VS Code extension |
508
+ | v0.1.20 | Web UI dashboard |
441
509
 
442
- 详见 `docs/roadmap/` 目录。
510
+ See `docs/roadmap/` for details.
443
511
 
444
512
  ---
445
513
 
446
- ## 🤝 贡献
514
+ ## Contributing
447
515
 
448
- 欢迎提交 Issue Pull Request!
516
+ Issues and Pull Requests are welcome!
449
517
 
450
518
  ---
451
519
 
452
- ## 📝 许可
520
+ ## License
453
521
 
454
- MIT License - See [LICENSE](LICENSE) for details
522
+ MIT License see [LICENSE](LICENSE) for details.
455
523
 
456
524
  ---
457
525
 
458
526
  **OpenHorse — Universal Agent Harness Framework.**
459
527
 
460
- *"AI 如马,OpenHorse 如缰。"*
528
+ *"AI as a horse, OpenHorse as the reins."*