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 +342 -274
- package/README.zh-CN.md +487 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +209 -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 +7 -0
- package/dist/framework/query.d.ts.map +1 -1
- package/dist/framework/query.js +32 -21
- 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/config.d.ts +6 -3
- package/dist/services/config.d.ts.map +1 -1
- package/dist/services/config.js +13 -3
- package/dist/services/config.js.map +1 -1
- package/dist/services/global-config.d.ts +6 -3
- package/dist/services/global-config.d.ts.map +1 -1
- package/dist/services/global-config.js +2 -2
- package/dist/services/global-config.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,314 @@
|
|
|
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 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
| `
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
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
|
-
###
|
|
264
|
+
### Task Management
|
|
180
265
|
|
|
181
|
-
|
|
|
182
|
-
|
|
183
|
-
| `
|
|
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
|
-
##
|
|
305
|
+
## MCP Protocol
|
|
211
306
|
|
|
212
|
-
|
|
307
|
+
Full support for MCP (Model Context Protocol) servers:
|
|
213
308
|
|
|
214
|
-
###
|
|
309
|
+
### Configure MCP Servers
|
|
215
310
|
|
|
216
|
-
|
|
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", "/
|
|
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 #
|
|
332
|
+
/mcp # Show MCP server connection status
|
|
238
333
|
```
|
|
239
334
|
|
|
240
|
-
|
|
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` | - |
|
|
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` | 退出 |
|
|
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
|
|
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
|
|
285
|
-
│ │ ├── brain.ts
|
|
286
|
-
│ │ └── strategy-tracker.ts
|
|
287
|
-
│ ├── agents/
|
|
288
|
-
│ │ ├── leader.ts
|
|
289
|
-
│ │ ├── coder.ts
|
|
290
|
-
│ │ └── router.ts
|
|
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
|
|
298
|
-
│
|
|
299
|
-
│ ├──
|
|
300
|
-
│ │ ├──
|
|
301
|
-
│ │ ├──
|
|
302
|
-
│ │
|
|
303
|
-
│
|
|
304
|
-
│ ├──
|
|
305
|
-
│ │
|
|
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
|
|
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 # 环境变量模板
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
379
|
-
- 流式 Markdown 渲染:代码块缓冲防断裂
|
|
380
|
-
- 工具预览卡片:工具执行结果可视化
|
|
381
|
-
- UI 组件测试
|
|
460
|
+
### v0.1.14
|
|
382
461
|
|
|
383
|
-
|
|
462
|
+
- LSP crash fix, compact UI, concise agent output
|
|
384
463
|
|
|
385
|
-
|
|
386
|
-
- 状态管理:Todo/Plan 状态持久化
|
|
387
|
-
- 语义搜索:Embedding + Vector Store
|
|
388
|
-
- Skills 系统:技能加载与注入
|
|
389
|
-
- 原子写入:防止数据损坏
|
|
390
|
-
- 模型别名:Bailian 模型支持
|
|
464
|
+
### v0.1.10 — v0.1.13
|
|
391
465
|
|
|
392
|
-
|
|
466
|
+
- MCP client with heartbeat/reconnect, semantic search, skills system, atomic writes, model aliases (Bailian), storage fixes
|
|
393
467
|
|
|
394
|
-
|
|
395
|
-
- MCP 协议支持
|
|
396
|
-
- 多模型支持
|
|
468
|
+
### v0.1.1 — v0.1.9
|
|
397
469
|
|
|
398
|
-
|
|
470
|
+
- CLI framework, harness system, memory system, session management, tool orchestration
|
|
399
471
|
|
|
400
|
-
|
|
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
|
-
##
|
|
500
|
+
## Roadmap
|
|
432
501
|
|
|
433
|
-
|
|
|
434
|
-
|
|
435
|
-
| v0.1.
|
|
436
|
-
| v0.1.
|
|
437
|
-
| v0.1.
|
|
438
|
-
| v0.1.
|
|
439
|
-
| v0.1.
|
|
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
|
-
|
|
510
|
+
See `docs/roadmap/` for details.
|
|
443
511
|
|
|
444
512
|
---
|
|
445
513
|
|
|
446
|
-
##
|
|
514
|
+
## Contributing
|
|
447
515
|
|
|
448
|
-
|
|
516
|
+
Issues and Pull Requests are welcome!
|
|
449
517
|
|
|
450
518
|
---
|
|
451
519
|
|
|
452
|
-
##
|
|
520
|
+
## License
|
|
453
521
|
|
|
454
|
-
MIT License
|
|
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
|
|
528
|
+
*"AI as a horse, OpenHorse as the reins."*
|