openhorse 0.1.16 → 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.
- package/README.md +339 -274
- package/README.zh-CN.md +487 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +207 -108
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/types.d.ts +7 -0
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js.map +1 -1
- package/dist/framework/query.d.ts +4 -0
- package/dist/framework/query.d.ts.map +1 -1
- package/dist/framework/query.js +9 -1
- package/dist/framework/query.js.map +1 -1
- package/dist/sdk/sessions.js +6 -6
- package/dist/sdk/sessions.js.map +1 -1
- package/dist/services/config-dir.d.ts +12 -0
- package/dist/services/config-dir.d.ts.map +1 -1
- package/dist/services/config-dir.js +42 -0
- package/dist/services/config-dir.js.map +1 -1
- package/dist/services/session-storage.d.ts +67 -1
- package/dist/services/session-storage.d.ts.map +1 -1
- package/dist/services/session-storage.js +331 -73
- package/dist/services/session-storage.js.map +1 -1
- 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
|
-
>
|
|
4
|
+
> A CLI-driven coding agent with safety boundaries, tool orchestration, memory, and context management.
|
|
5
5
|
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://nodejs.org)
|
|
8
8
|
[](https://www.typescriptlang.org)
|
|
9
|
+
[](https://www.npmjs.com/package/openhorse)
|
|
9
10
|
|
|
10
11
|
---
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
**🌍 Language**: English | [简体中文](README.zh-CN.md)
|
|
13
14
|
|
|
14
|
-
|
|
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
|
-
|
|
|
34
|
-
|
|
35
|
-
| **
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
| **
|
|
40
|
-
|
|
|
41
|
-
|
|
|
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 +
|
|
56
|
+
│ CLI Layer │
|
|
57
|
+
│ readline + chalk + streaming Markdown + status bar │
|
|
51
58
|
└────────────────────────────┬────────────────────────────┘
|
|
52
59
|
│
|
|
53
60
|
┌────────────────────────────▼────────────────────────────┐
|
|
54
|
-
│ Harness
|
|
55
|
-
│
|
|
61
|
+
│ Harness Layer │
|
|
62
|
+
│ Goal constraints │ Safety checks │ Result validation │
|
|
56
63
|
└────────────────────────────┬────────────────────────────┘
|
|
57
64
|
│
|
|
58
65
|
┌────────────────────────────▼────────────────────────────┐
|
|
59
|
-
│ Query
|
|
60
|
-
│ LLM Stream │ Tool Calling │ Retry/Fallback │
|
|
66
|
+
│ Query Engine │
|
|
67
|
+
│ LLM Stream │ Tool Calling │ Retry/Fallback │ Compact │
|
|
61
68
|
└──────────┬─────────────────┬─────────────────┬──────────┘
|
|
62
69
|
│ │ │
|
|
63
70
|
┌──────────▼─────┐ ┌─────────▼─────┐ ┌─────────▼──────────┐
|
|
64
|
-
│ Tools
|
|
65
|
-
│ File/Bash/Web │ │ Server
|
|
71
|
+
│ Tools │ │ MCP Client │ │ Skills │
|
|
72
|
+
│ File/Bash/Web │ │ Server conn │ │ Builtin/User/Proj │
|
|
66
73
|
└─────────────────┘ └───────────────┘ └───────────────────┘
|
|
67
74
|
│
|
|
68
75
|
┌────────────────────────────▼────────────────────────────┐
|
|
69
|
-
│ Memory
|
|
70
|
-
│ User
|
|
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
|
-
#
|
|
97
|
-
#
|
|
103
|
+
# Configure API Key (choose one)
|
|
104
|
+
# Option 1: Environment variable
|
|
98
105
|
export OPENHORSE_API_KEY=your-api-key
|
|
99
106
|
|
|
100
|
-
#
|
|
107
|
+
# Option 2: .env file
|
|
101
108
|
cp .env.example .env
|
|
102
|
-
#
|
|
109
|
+
# Edit .env and set OPENHORSE_API_KEY
|
|
103
110
|
|
|
104
|
-
#
|
|
105
|
-
#
|
|
111
|
+
# Option 3: ~/.openhorse/openhorse.json (recommended)
|
|
112
|
+
# Created automatically on first run
|
|
106
113
|
|
|
107
|
-
#
|
|
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
|
-
###
|
|
132
|
+
### User Config (`~/.openhorse/openhorse.json`)
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
| `
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
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
|
-
###
|
|
261
|
+
### Task Management
|
|
180
262
|
|
|
181
|
-
|
|
|
182
|
-
|
|
183
|
-
| `
|
|
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
|
-
##
|
|
302
|
+
## MCP Protocol
|
|
211
303
|
|
|
212
|
-
|
|
304
|
+
Full support for MCP (Model Context Protocol) servers:
|
|
213
305
|
|
|
214
|
-
###
|
|
306
|
+
### Configure MCP Servers
|
|
215
307
|
|
|
216
|
-
|
|
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", "/
|
|
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 #
|
|
329
|
+
/mcp # Show MCP server connection status
|
|
238
330
|
```
|
|
239
331
|
|
|
240
|
-
|
|
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` | - |
|
|
253
|
-
| `/
|
|
254
|
-
| `/sessions` | - |
|
|
255
|
-
| `/resume` | - |
|
|
256
|
-
| `/memory` | - |
|
|
257
|
-
| `/memory reindex` | - |
|
|
258
|
-
| `/skills` | - |
|
|
259
|
-
| `/mcp` | - | MCP
|
|
260
|
-
| `/agents` | - |
|
|
261
|
-
| `/safety` | - |
|
|
262
|
-
| `/
|
|
263
|
-
| `/
|
|
264
|
-
| `/
|
|
265
|
-
| `/clear` |
|
|
266
|
-
| `/
|
|
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
|
|
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
|
|
285
|
-
│ │ ├── brain.ts
|
|
286
|
-
│ │ └── strategy-tracker.ts
|
|
287
|
-
│ ├── agents/
|
|
288
|
-
│ │ ├── leader.ts
|
|
289
|
-
│ │ ├── coder.ts
|
|
290
|
-
│ │ └── router.ts
|
|
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
|
|
298
|
-
│
|
|
299
|
-
│ ├──
|
|
300
|
-
│ │ ├──
|
|
301
|
-
│ │ ├──
|
|
302
|
-
│ │
|
|
303
|
-
│
|
|
304
|
-
│ ├──
|
|
305
|
-
│ │
|
|
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
|
|
309
|
-
│ │ ├── config.ts
|
|
310
|
-
│ │ ├── global-config.ts
|
|
311
|
-
│ │ ├──
|
|
312
|
-
│ │ ├──
|
|
313
|
-
│ │ ├──
|
|
314
|
-
│ │
|
|
315
|
-
│ │ ├──
|
|
316
|
-
│ │
|
|
317
|
-
│ ├──
|
|
318
|
-
│ │ ├──
|
|
319
|
-
│ │ ├──
|
|
320
|
-
│ │
|
|
321
|
-
│
|
|
322
|
-
│ │
|
|
323
|
-
│ │
|
|
324
|
-
│ ├──
|
|
325
|
-
│ │ ├──
|
|
326
|
-
│ │ ├──
|
|
327
|
-
│ │
|
|
328
|
-
│
|
|
329
|
-
│
|
|
330
|
-
│
|
|
331
|
-
│
|
|
332
|
-
├──
|
|
333
|
-
│
|
|
334
|
-
│
|
|
335
|
-
|
|
336
|
-
├── docs/
|
|
337
|
-
│ ├──
|
|
338
|
-
│
|
|
339
|
-
│
|
|
340
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
379
|
-
- 流式 Markdown 渲染:代码块缓冲防断裂
|
|
380
|
-
- 工具预览卡片:工具执行结果可视化
|
|
381
|
-
- UI 组件测试
|
|
457
|
+
### v0.1.14
|
|
382
458
|
|
|
383
|
-
|
|
459
|
+
- LSP crash fix, compact UI, concise agent output
|
|
384
460
|
|
|
385
|
-
|
|
386
|
-
- 状态管理:Todo/Plan 状态持久化
|
|
387
|
-
- 语义搜索:Embedding + Vector Store
|
|
388
|
-
- Skills 系统:技能加载与注入
|
|
389
|
-
- 原子写入:防止数据损坏
|
|
390
|
-
- 模型别名:Bailian 模型支持
|
|
461
|
+
### v0.1.10 — v0.1.13
|
|
391
462
|
|
|
392
|
-
|
|
463
|
+
- MCP client with heartbeat/reconnect, semantic search, skills system, atomic writes, model aliases (Bailian), storage fixes
|
|
393
464
|
|
|
394
|
-
|
|
395
|
-
- MCP 协议支持
|
|
396
|
-
- 多模型支持
|
|
465
|
+
### v0.1.1 — v0.1.9
|
|
397
466
|
|
|
398
|
-
|
|
467
|
+
- CLI framework, harness system, memory system, session management, tool orchestration
|
|
399
468
|
|
|
400
|
-
|
|
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
|
-
##
|
|
497
|
+
## Roadmap
|
|
432
498
|
|
|
433
|
-
|
|
|
434
|
-
|
|
435
|
-
| v0.1.
|
|
436
|
-
| v0.1.
|
|
437
|
-
| v0.1.
|
|
438
|
-
| v0.1.
|
|
439
|
-
| v0.1.
|
|
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
|
-
|
|
507
|
+
See `docs/roadmap/` for details.
|
|
443
508
|
|
|
444
509
|
---
|
|
445
510
|
|
|
446
|
-
##
|
|
511
|
+
## Contributing
|
|
447
512
|
|
|
448
|
-
|
|
513
|
+
Issues and Pull Requests are welcome!
|
|
449
514
|
|
|
450
515
|
---
|
|
451
516
|
|
|
452
|
-
##
|
|
517
|
+
## License
|
|
453
518
|
|
|
454
|
-
MIT License
|
|
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
|
|
525
|
+
*"AI as a horse, OpenHorse as the reins."*
|