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