@goodandready/dsh-goal 0.1.8 → 0.1.10
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 +121 -44
- package/{docs/README.ru.md → README.ru.md} +12 -1
- package/README.zh.md +219 -0
- package/docs/design/DESIGN.md +23 -0
- package/lib/client.js +146 -61
- package/lib/command-handler.js +76 -34
- package/lib/goal-engine.js +49 -5
- package/lib/index.js +344 -131
- package/package.json +6 -4
- package/docs/README.zh.md +0 -143
package/README.md
CHANGED
|
@@ -11,78 +11,127 @@
|
|
|
11
11
|
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node-20%2B-f59e0b.svg?style=for-the-badge&labelColor=451a03" alt="Node version"></a>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
|
-
<!--
|
|
14
|
+
<!-- Обязательная кнопка перехода на витрину всех проектов -->
|
|
15
15
|
<p align="center">
|
|
16
|
-
<a href="https://goodandready.app/"><img src="https://img.shields.io/badge
|
|
16
|
+
<a href="https://goodandready.app/"><img src="https://img.shields.io/badge/Все_проекты_автора-goodandready.app-ff4500.svg?style=for-the-badge&logo=rocket&logoColor=white&labelColor=1a1a2e" alt="Все проекты автора"></a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
19
|
<p align="center">
|
|
20
20
|
<a href="README.md"><b>🇬🇧 English</b></a> •
|
|
21
|
-
<a href="
|
|
22
|
-
<a href="
|
|
21
|
+
<a href="README.ru.md"><b>🇷🇺 Русский</b></a> •
|
|
22
|
+
<a href="README.zh.md"><b>🇨🇳 中文说明</b></a>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
|
+
<!-- Обязательный блок поддержки проекта: локализуй текст под язык README -->
|
|
26
|
+
<table align="center">
|
|
27
|
+
<tr>
|
|
28
|
+
<td align="center">
|
|
29
|
+
⭐ <strong>If you like this plugin, please star it on GitHub</strong> — it shows me that the plugin is useful to you and motivates me to keep developing it.
|
|
30
|
+
<br><br>
|
|
31
|
+
🐛 <strong>If you find a bug or would like to request a feature</strong>, open a GitHub issue in any language — I will review your proposal and implement useful suggestions in a future plugin version.
|
|
32
|
+
</td>
|
|
33
|
+
</tr>
|
|
34
|
+
</table>
|
|
35
|
+
|
|
25
36
|
</div>
|
|
26
37
|
|
|
27
38
|
---
|
|
28
39
|
|
|
29
40
|
## ⚡ Overview & The Problem
|
|
30
41
|
|
|
31
|
-
Complex engineering tasks require multi-step autonomy: decomposing high-level objectives into milestones, executing
|
|
42
|
+
Complex engineering tasks require multi-step autonomy: decomposing high-level objectives into sequential milestones, executing iterations without requiring manual user re-prompting, and maintaining clear visibility into task progress.
|
|
43
|
+
|
|
44
|
+
Without an autonomous tracking framework, agents can lose context across turns, stall in passive loops, or fail to notify users when complex workflows stall.
|
|
32
45
|
|
|
33
|
-
**`@goodandready/dsh-goal`**
|
|
34
|
-
* 🎯 **Sticky Top Goal Banner**: Pinned
|
|
35
|
-
* ⏸️ **Play / Pause / Cancel**: Instantly pause the autonomous loop or resume execution on demand.
|
|
36
|
-
* 📋 **Milestone Breakdown
|
|
37
|
-
*
|
|
38
|
-
*
|
|
46
|
+
**`@goodandready/dsh-goal`** introduces Goal Mode to DeepSeek Harness:
|
|
47
|
+
* 🎯 **Sticky Top Goal Banner**: Pinned header over composer dock with live elapsed timer (`• 2s`, `• 1m 45s`), real-time status badge (`RUNNING`, `PAUSED`, `COMPLETED`), active goal title, and control actions.
|
|
48
|
+
* ⏸️ **Play / Pause / Resume / Cancel**: Instantly pause the autonomous loop or resume execution on demand via buttons or `/goal` command.
|
|
49
|
+
* 📋 **Milestone Breakdown & ETA**: Interactive checklist showing sub-tasks, completion status (`pending`, `in_progress`, `completed`, `failed`), progress bar, and dynamic completion ETA.
|
|
50
|
+
* 🌐 **Multi-Language Auto-Detection (*Added in v0.1.9*)**: Prompt injection, autonomous follow-ups, and UI badges automatically follow the user's input language (English by default, Chinese, or Russian when entered in Cyrillic).
|
|
51
|
+
* 🔘 **Quick Launch Button (*Added in v0.1.8*)**: Fast goal launcher docked above the message input with instant objective prompt modal. Toggleable in settings.
|
|
52
|
+
* 📊 **Token Usage Tracking & Markdown Export (*Added in v0.1.7*)**: Accumulated prompt, completion, and total tokens tracked per session with one-click Markdown summary export.
|
|
53
|
+
* 🤖 **Autonomous Agent Contract**: Provides `goal_set_milestones`, `goal_update_progress`, and `goal_finish` tools directly to the agent.
|
|
54
|
+
* 🔄 **Core DSH Goal Tools Interception (*Added in v0.1.10*)**: Seamless drop-in compatibility for models calling built-in DSH goal tools (`update_goal`, `get_goal`, `create_goal`). Intercepts actions (`complete`, `pause`, `resume`, `edit`, `blocked`), bypasses rigid authority restrictions that caused crashes (`complete and blocked require a direct human turn`), and routes all state updates directly to GoalEngine.
|
|
55
|
+
* 🛡️ **Safety Guardrails**: Configurable `maxIterations` safety limit and Smart Progress Guard to catch and pause idle turns without progress.
|
|
56
|
+
* 🔔 **Web Audio Chimes**: Pleasant synthesized audio feedback on goal completion or failure via Web Audio API.
|
|
39
57
|
|
|
40
58
|
---
|
|
41
59
|
|
|
42
60
|
## 🏛️ Architecture
|
|
43
61
|
|
|
44
62
|
```mermaid
|
|
45
|
-
graph
|
|
46
|
-
subgraph
|
|
63
|
+
graph LR
|
|
64
|
+
subgraph UserInterface ["User Interface & Interaction"]
|
|
47
65
|
Cmd["Slash Command: /goal <objective>"]
|
|
48
|
-
|
|
66
|
+
Dock["Sticky Goal Banner (conversation.input.dock)"]
|
|
67
|
+
Modal["Goal Details & Milestone Modal"]
|
|
68
|
+
QuickLaunch["Quick Launch Goal Button"]
|
|
49
69
|
end
|
|
50
70
|
|
|
51
|
-
subgraph
|
|
71
|
+
subgraph GoalEngineCore ["Goal Engine Core (lib/goal-engine.js)"]
|
|
52
72
|
State["State Manager (IDLE, RUNNING, PAUSED, COMPLETED)"]
|
|
53
|
-
Milestones["Milestone Tracker &
|
|
54
|
-
|
|
73
|
+
Milestones["Milestone Tracker & ETA Calculation"]
|
|
74
|
+
DiskStore["Persistence Store (goal-state.json)"]
|
|
75
|
+
LangDetector["detectLanguage (en, zh, ru)"]
|
|
55
76
|
end
|
|
56
77
|
|
|
57
|
-
subgraph
|
|
78
|
+
subgraph AutonomousLoop ["Autonomous Drive & Turn Coordinator (lib/index.js)"]
|
|
79
|
+
TurnHook["ctx.on('turn/end') AutoDrive"]
|
|
80
|
+
Guard["Smart Progress Guard & Iteration Limiter"]
|
|
81
|
+
PromptInject["getStatePromptInjection"]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
subgraph AgentTools ["Cordis Registered Tools"]
|
|
58
85
|
ToolSet["goal_set_milestones"]
|
|
59
86
|
ToolProgress["goal_update_progress"]
|
|
60
87
|
ToolFinish["goal_finish"]
|
|
61
|
-
LimitGuard{"maxIterations Guard"}
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
subgraph UI ["DSH Web Interface"]
|
|
65
|
-
Banner["Sticky Top Goal Banner"]
|
|
66
|
-
Timer["Live Elapsed Timer"]
|
|
67
|
-
Drawer["Milestone Checklist Modal"]
|
|
68
|
-
Settings["Settings Card (Schemastery)"]
|
|
69
88
|
end
|
|
70
89
|
|
|
71
|
-
Cmd -->
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
ToolProgress --> GoalEngine
|
|
81
|
-
ToolFinish --> GoalEngine
|
|
90
|
+
Cmd --> GoalEngineCore
|
|
91
|
+
Dock --> GoalEngineCore
|
|
92
|
+
QuickLaunch --> GoalEngineCore
|
|
93
|
+
GoalEngineCore --> DiskStore
|
|
94
|
+
GoalEngineCore --> AutonomousLoop
|
|
95
|
+
AutonomousLoop --> PromptInject
|
|
96
|
+
GoalEngineCore --> Modal
|
|
97
|
+
AgentTools --> GoalEngineCore
|
|
98
|
+
AutonomousLoop --> Guard
|
|
82
99
|
```
|
|
83
100
|
|
|
84
101
|
---
|
|
85
102
|
|
|
103
|
+
## ✨ Features & Module Breakdown
|
|
104
|
+
|
|
105
|
+
### 1. `lib/goal-engine.js` — State Engine
|
|
106
|
+
Zero external dependency core managing session goals, milestone states, elapsed time calculations, ETA forecasts, token accumulators, and crash recovery hydration.
|
|
107
|
+
* **Auto Language Detection**: Automatically analyzes goal title and parameters (`detectLanguage`) to select English (`en`), Chinese (`zh`), or Russian (`ru`).
|
|
108
|
+
* **ETA Estimator**: Predicts remaining time based on average milestone velocity:
|
|
109
|
+
$$\text{ETA} = \frac{\text{elapsed}}{\text{completedMilestones}} \times \text{remainingMilestones}$$
|
|
110
|
+
* **Low-Latency State Serialization**: Synchronous debounced atomic file persistence to prevent data loss on crashes.
|
|
111
|
+
|
|
112
|
+
### 2. `lib/command-handler.js` — Slash Commands
|
|
113
|
+
Handles `/goal` commands and subcommands:
|
|
114
|
+
* `/goal <objective>`: Starts a new autonomous goal.
|
|
115
|
+
* `/goal pause`: Pauses current goal and halts agent turn.
|
|
116
|
+
* `/goal resume`: Resumes execution and triggers agent continuation.
|
|
117
|
+
* `/goal clear`: Resets session goal to IDLE.
|
|
118
|
+
* `/goal`: Shows status, elapsed time, ETA, iterations, tokens, and active milestones.
|
|
119
|
+
|
|
120
|
+
### 3. `lib/index.js` — DSH Cordis Lifecycle Coordinator
|
|
121
|
+
* Registers REST API endpoints (`GET /dsh-goal/state`, `POST /dsh-goal/action`, `GET /dsh-goal/events` SSE stream).
|
|
122
|
+
* Subscribes to `turn/end` for zero-latency turn-to-turn auto-drive using `setImmediate`.
|
|
123
|
+
* Listens to `approval/asked` to automatically pause goal when operator confirmation is needed.
|
|
124
|
+
* Registers agent tools: `goal_set_milestones`, `goal_update_progress`, `goal_finish`.
|
|
125
|
+
* Seamlessly shadows core DSH goal tools: `update_goal`, `get_goal`, `create_goal` with zero collision and full `GOAL_OUTPUT` schema compliance.
|
|
126
|
+
|
|
127
|
+
### 4. `lib/client.js` — Frontend Web UI
|
|
128
|
+
* **Sticky Top Banner**: Mounts via slot `conversation.input.dock` with live timer, status badge, pause/resume, and details button.
|
|
129
|
+
* **Goal Details Modal**: Full milestone list, progress bar, token statistics, and 📋 Markdown Report Copy.
|
|
130
|
+
* **Quick Launch Button**: Floating launcher for rapid goal formulation without typing slash commands.
|
|
131
|
+
* **Plugin Settings Card**: Schemastery-backed settings UI registered via `settings.plugin.item`.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
86
135
|
## 📦 Installation
|
|
87
136
|
|
|
88
137
|
```bash
|
|
@@ -95,42 +144,70 @@ Restart your DeepSeek Harness instance and refresh the browser.
|
|
|
95
144
|
|
|
96
145
|
## 💬 Usage & Quick Start
|
|
97
146
|
|
|
98
|
-
Start a
|
|
147
|
+
### 1. Start a Goal via Chat
|
|
148
|
+
Simply enter the `/goal` slash command:
|
|
99
149
|
|
|
100
150
|
```text
|
|
101
|
-
/goal Refactor
|
|
151
|
+
/goal Refactor authentication middleware and cover with unit tests
|
|
102
152
|
```
|
|
103
153
|
|
|
104
|
-
|
|
154
|
+
The agent will immediately:
|
|
155
|
+
1. Establish a structured milestone plan via `goal_set_milestones`.
|
|
156
|
+
2. Advance through milestones, marking each `in_progress` and `completed` via `goal_update_progress`.
|
|
157
|
+
3. Conclude with a full summary via `goal_finish`.
|
|
158
|
+
|
|
159
|
+
### 2. Quick Launch Button
|
|
160
|
+
Click the **Start Goal** button directly above the message input box, type your objective, and click **Start Goal**.
|
|
161
|
+
|
|
162
|
+
### 3. REST API Control
|
|
163
|
+
Control goals programmatically via HTTP:
|
|
105
164
|
|
|
106
165
|
```bash
|
|
166
|
+
# Start a goal
|
|
107
167
|
curl -X POST http://localhost:3080/dsh-goal/action \
|
|
108
168
|
-H "Content-Type: application/json" \
|
|
109
|
-
-d '{"action":"start","title":"
|
|
169
|
+
-d '{"action":"start","title":"Implement automated backup pipeline"}'
|
|
170
|
+
|
|
171
|
+
# Pause
|
|
172
|
+
curl -X POST http://localhost:3080/dsh-goal/action \
|
|
173
|
+
-H "Content-Type: application/json" \
|
|
174
|
+
-d '{"action":"pause"}'
|
|
175
|
+
|
|
176
|
+
# Resume
|
|
177
|
+
curl -X POST http://localhost:3080/dsh-goal/action \
|
|
178
|
+
-H "Content-Type: application/json" \
|
|
179
|
+
-d '{"action":"resume"}'
|
|
180
|
+
|
|
181
|
+
# Inspect live state
|
|
182
|
+
curl http://localhost:3080/dsh-goal/state
|
|
110
183
|
```
|
|
111
184
|
|
|
112
185
|
---
|
|
113
186
|
|
|
114
187
|
## ⚙️ Configuration Reference (`settings.yaml`)
|
|
115
188
|
|
|
189
|
+
Configure settings in `settings.yaml` or through the **Settings → Plugins → Goal Mode** UI card:
|
|
190
|
+
|
|
116
191
|
```yaml
|
|
117
192
|
dsh-goal:
|
|
118
193
|
maxIterations: 25
|
|
119
194
|
autoDrive: true
|
|
120
195
|
enableSound: true
|
|
196
|
+
showQuickLaunchButton: true
|
|
121
197
|
```
|
|
122
198
|
|
|
123
199
|
| Parameter | Type | Default | Description |
|
|
124
200
|
|:---|:---|:---|:---|
|
|
125
|
-
| `maxIterations` | `number` | `25` | Safety limit: maximum autonomous
|
|
201
|
+
| `maxIterations` | `number` | `25` | Safety limit: maximum autonomous turns per goal |
|
|
126
202
|
| `autoDrive` | `boolean` | `true` | Keep the autonomous agent loop running between turns |
|
|
127
|
-
| `enableSound` | `boolean` | `true` | Play
|
|
203
|
+
| `enableSound` | `boolean` | `true` | Play audio chime when a goal completes or fails |
|
|
204
|
+
| `showQuickLaunchButton` | `boolean` | `true` | Show the quick launch goal button above the composer dock |
|
|
128
205
|
|
|
129
206
|
---
|
|
130
207
|
|
|
131
208
|
## 🧪 Testing
|
|
132
209
|
|
|
133
|
-
Run
|
|
210
|
+
Run unit and integration tests:
|
|
134
211
|
|
|
135
212
|
```bash
|
|
136
213
|
npm test
|
|
@@ -17,11 +17,21 @@
|
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
19
|
<p align="center">
|
|
20
|
-
<a href="
|
|
20
|
+
<a href="README.md"><b>🇬🇧 English</b></a> •
|
|
21
21
|
<a href="README.ru.md"><b>🇷🇺 Русский</b></a> •
|
|
22
22
|
<a href="README.zh.md"><b>🇨🇳 中文说明</b></a>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
|
+
<table align="center">
|
|
26
|
+
<tr>
|
|
27
|
+
<td align="center">
|
|
28
|
+
⭐ <strong>Если вам нравится этот плагин, поставьте ему звезду на GitHub</strong> — это покажет мне, что плагин вам полезен, и будет мотивировать меня развивать его дальше.
|
|
29
|
+
<br><br>
|
|
30
|
+
🐛 <strong>Если вы нашли баг или хотите предложить новый функционал</strong>, создайте issue на GitHub на любом языке — я рассмотрю ваше предложение и реализую полезные идеи в одной из следующих версий плагина.
|
|
31
|
+
</td>
|
|
32
|
+
</tr>
|
|
33
|
+
</table>
|
|
34
|
+
|
|
25
35
|
</div>
|
|
26
36
|
|
|
27
37
|
---
|
|
@@ -35,6 +45,7 @@
|
|
|
35
45
|
* ⏸️ **Управление циклом (Play / Pause / Cancel)**: мгновенная приостановка автономного цикла агента или его возобновление в любой момент.
|
|
36
46
|
* 📋 **Интерактивная панель майлстоунов**: модальное окно со списком подзадач, прогресс-баром и журналом выполнения.
|
|
37
47
|
* 🤖 **Инструменты агента**: `goal_set_milestones`, `goal_update_progress` и `goal_finish` для самостоятельной работы ИИ.
|
|
48
|
+
* 🔄 **Перехват и замещение инструментов ядра DSH (*Добавлено в v0.1.10*)**: Бесшовная совместимость для моделей, вызывающих стандартные инструменты DSH (`update_goal`, `get_goal`, `create_goal`). Перехватывает действия (`complete`, `pause`, `resume`, `edit`, `blocked`), устраняет падения ядра (`complete and blocked require a direct human turn`) и синхронизирует состояние напрямую с GoalEngine.
|
|
38
49
|
* 🛡️ **Защитные лимиты**: настраиваемое ограничение `maxIterations` для предотвращения бесконечных циклов.
|
|
39
50
|
|
|
40
51
|
---
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# 📦 @goodandready/dsh-goal
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<h3>DeepSeek Harness 自主目标执行与多轮任务跟踪引擎</h3>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@goodandready/dsh-goal"><img src="https://img.shields.io/npm/v/@goodandready/dsh-goal.svg?style=for-the-badge&color=6366f1&labelColor=1e1b4b" alt="npm version"></a>
|
|
9
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/GooDAnDReaDY/dsh-goal.svg?style=for-the-badge&color=10b981&labelColor=064e3b" alt="license"></a>
|
|
10
|
+
<a href="https://github.com/topics/dsh-plugin"><img src="https://img.shields.io/badge/DSH-Plugin-8b5cf6.svg?style=for-the-badge&labelColor=2e1065" alt="DSH Plugin"></a>
|
|
11
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node-20%2B-f59e0b.svg?style=for-the-badge&labelColor=451a03" alt="Node version"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<!-- Обязательная кнопка перехода на витрину всех проектов -->
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://goodandready.app/"><img src="https://img.shields.io/badge/Все_проекты_автора-goodandready.app-ff4500.svg?style=for-the-badge&logo=rocket&logoColor=white&labelColor=1a1a2e" alt="Все проекты автора"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="README.md"><b>🇬🇧 English</b></a> •
|
|
21
|
+
<a href="README.ru.md"><b>🇷🇺 Русский</b></a> •
|
|
22
|
+
<a href="README.zh.md"><b>🇨🇳 中文说明</b></a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<!-- Обязательный блок поддержки проекта: локализуй текст под язык README -->
|
|
26
|
+
<table align="center">
|
|
27
|
+
<tr>
|
|
28
|
+
<td align="center">
|
|
29
|
+
⭐ <strong>如果您喜欢这个插件,请在 GitHub 上为它点亮 Star</strong> — 这能让我知道插件对您有用,并鼓励我继续开发和维护它。
|
|
30
|
+
<br><br>
|
|
31
|
+
🐛 <strong>如果您发现 Bug 或希望增加功能</strong>,请使用任意语言在 GitHub 上提交 Issue — 我会评估您的建议,并在后续版本中实现有价值的改进。
|
|
32
|
+
</td>
|
|
33
|
+
</tr>
|
|
34
|
+
</table>
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## ⚡ 概述与解决的问题
|
|
41
|
+
|
|
42
|
+
复杂的工程开发任务需要多步骤的自主推进:将高层目标分解为有序的里程碑、在各轮交互间无需用户重复提示即可持续执行,并保持清晰直观的进度可视化。
|
|
43
|
+
|
|
44
|
+
如果缺乏目标跟踪框架,智能体容易在多轮对话中丢失上下文、陷入被动等待,或在遇到卡点时无法及时提醒用户。
|
|
45
|
+
|
|
46
|
+
**`@goodandready/dsh-goal`** 为 DeepSeek Harness 带来了完整的目标模式(Goal Mode):
|
|
47
|
+
* 🎯 **输入框上方常驻目标横幅**:顶部常驻状态条,配备实时计时器(`• 2s`、`• 1m 45s`)、状态徽章(`RUNNING`、`PAUSED`、`COMPLETED`)、当前目标名称与控制操作。
|
|
48
|
+
* ⏸️ **播放 / 暂停 / 恢复 / 取消**:可通过按钮或 `/goal` 命令随时暂停自主循环,或在需要时恢复执行。
|
|
49
|
+
* 📋 **里程碑拆解与 ETA 预测**:交互式清单抽屉,展示子任务状态(`pending`、`in_progress`、`completed`、`failed`)、进度百分比与动态预估剩余时间。
|
|
50
|
+
* 🌐 **多语言智能识别(v0.1.9 新增)**:提示词注入、自主轮次追问和 UI 状态徽章自动匹配用户输入语言(默认英语,支持中文和俄语)。
|
|
51
|
+
* 🔘 **快速启动按钮(v0.1.8 新增)**:常驻于输入框上方的启动按钮,支持弹窗一键制定目标,可在设置中自由开关。
|
|
52
|
+
* 📊 **Token 消耗统计与 Markdown 导出(v0.1.7 新增)**:实时累计提示词、生成词及总 Token 消耗,支持一键复制完整 Markdown 报告。
|
|
53
|
+
* 🤖 **智能体自主协作工具**:向智能体直接提供 `goal_set_milestones`、`goal_update_progress` 和 `goal_finish` 工具。
|
|
54
|
+
* 🔄 **DSH 核心目标工具无缝拦截与兼容 (*v0.1.10 新增*)**: 为使用原生 DSH 目标控制指令的模型提供完美向下兼容,透明接管 `update_goal`、`get_goal`、`create_goal`。拦截并处理 `complete`、`pause`、`resume`、`edit`、`blocked` 等操作,彻底解决原生工具抛出的 `complete and blocked require a direct human turn` 权限崩溃错误,所有状态直接同步至 GoalEngine。
|
|
55
|
+
* 🛡️ **安全防护机制**:支持自定义最大迭代次数(`maxIterations`)以及智能卡顿检测(Smart Progress Guard)。
|
|
56
|
+
* 🔔 **Web Audio 提示音**:任务完成或失败时,通过 Web Audio API 播放舒缓的合成音效。
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 🏛️ 架构图
|
|
61
|
+
|
|
62
|
+
```mermaid
|
|
63
|
+
graph LR
|
|
64
|
+
subgraph UserInterface ["用户界面与交互"]
|
|
65
|
+
Cmd["斜杠命令: /goal <目标>"]
|
|
66
|
+
Dock["常驻目标横幅 (conversation.input.dock)"]
|
|
67
|
+
Modal["目标详情与里程碑弹窗"]
|
|
68
|
+
QuickLaunch["快速启动目标按钮"]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
subgraph GoalEngineCore ["目标引擎核心 (lib/goal-engine.js)"]
|
|
72
|
+
State["状态管理 (IDLE, RUNNING, PAUSED, COMPLETED)"]
|
|
73
|
+
Milestones["里程碑跟踪与 ETA 计算"]
|
|
74
|
+
DiskStore["状态持久化存储 (goal-state.json)"]
|
|
75
|
+
LangDetector["语言检测器 (en, zh, ru)"]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
subgraph AutonomousLoop ["自主循环与轮次协调器 (lib/index.js)"]
|
|
79
|
+
TurnHook["ctx.on('turn/end') 自动推进"]
|
|
80
|
+
Guard["卡顿防守与最大迭代限制"]
|
|
81
|
+
PromptInject["getStatePromptInjection 提示词注入"]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
subgraph AgentTools ["Cordis 注册工具"]
|
|
85
|
+
ToolSet["goal_set_milestones"]
|
|
86
|
+
ToolProgress["goal_update_progress"]
|
|
87
|
+
ToolFinish["goal_finish"]
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
Cmd --> GoalEngineCore
|
|
91
|
+
Dock --> GoalEngineCore
|
|
92
|
+
QuickLaunch --> GoalEngineCore
|
|
93
|
+
GoalEngineCore --> DiskStore
|
|
94
|
+
GoalEngineCore --> AutonomousLoop
|
|
95
|
+
AutonomousLoop --> PromptInject
|
|
96
|
+
GoalEngineCore --> Modal
|
|
97
|
+
AgentTools --> GoalEngineCore
|
|
98
|
+
AutonomousLoop --> Guard
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## ✨ 核心模块详解
|
|
104
|
+
|
|
105
|
+
### 1. `lib/goal-engine.js` — 状态引擎
|
|
106
|
+
纯 JavaScript 实现,零外部依赖,完整管理会话目标、里程碑状态、运行计时、ETA 预测、Token 累计与崩溃恢复水合。
|
|
107
|
+
* **语言自动识别**:根据目标文本自动选择英语 (`en`)、中文 (`zh`) 或俄语 (`ru`)。
|
|
108
|
+
* **ETA 预估计算**:基于已完成里程碑的平均耗时进行动态预估:
|
|
109
|
+
$$\text{ETA} = \frac{\text{已运行时间}}{\text{已完成里程碑数}} \times \text{剩余里程碑数}$$
|
|
110
|
+
* **原子防抖持久化**:采用安全的临时文件写入与重命名机制,避免进程中断导致数据损坏。
|
|
111
|
+
|
|
112
|
+
### 2. `lib/command-handler.js` — 命令处理
|
|
113
|
+
处理 `/goal` 斜杠命令及其子命令:
|
|
114
|
+
* `/goal <目标内容>`:启动新目标。
|
|
115
|
+
* `/goal pause`:暂停当前目标并中止智能体当前轮次。
|
|
116
|
+
* `/goal resume`:恢复执行并自动提示智能体继续。
|
|
117
|
+
* `/goal clear`:重置当前目标为 IDLE。
|
|
118
|
+
* `/goal`:展示状态、耗时、预估时间、迭代进度、Token 统计与里程碑列表。
|
|
119
|
+
|
|
120
|
+
### 3. `lib/index.js` — DSH Cordis 生命周期管理
|
|
121
|
+
* 注册 HTTP REST API(`GET /dsh-goal/state`、`POST /dsh-goal/action` 及 `GET /dsh-goal/events` SSE 实时流)。
|
|
122
|
+
* 监听 `turn/end` 事件,通过 `setImmediate` 实现轮次间的极低延迟自动驱动。
|
|
123
|
+
* 监听 `approval/asked` 事件,在需要操作员审批时自动暂停。
|
|
124
|
+
* 为智能体注册专属工具:`goal_set_milestones`、`goal_update_progress`、`goal_finish`。
|
|
125
|
+
|
|
126
|
+
### 4. `lib/client.js` — Web 前端界面
|
|
127
|
+
* **常驻目标横幅**:注入 `conversation.input.dock` 插槽,包含实时计时、状态徽章、暂停/恢复与详情按钮。
|
|
128
|
+
* **目标详情弹窗**:展示完整里程碑清单、进度条、Token 统计,并支持 📋 一键复制 Markdown 报告。
|
|
129
|
+
* **快速启动按钮**:输入框上方的便捷入口,免去手动输入命令的繁琐。
|
|
130
|
+
* **设置卡片**:基于 Schemastery 注册至 `settings.plugin.item` 的可视化设置面板。
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 📦 安装说明
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
dsh plugin --profile web add @goodandready/dsh-goal
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
安装完成后重启 DeepSeek Harness 实例并刷新浏览器即可。
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 💬 使用指南
|
|
145
|
+
|
|
146
|
+
### 1. 通过聊天输入启动目标
|
|
147
|
+
在聊天输入框中直接输入 `/goal` 命令:
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
/goal 重构鉴权中间件并补充完整的单元测试
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
智能体将立即:
|
|
154
|
+
1. 通过 `goal_set_milestones` 制定清晰的步骤规划;
|
|
155
|
+
2. 逐项执行,并通过 `goal_update_progress` 标记 `in_progress` 与 `completed`;
|
|
156
|
+
3. 全部完成后调用 `goal_finish` 输出最终总结。
|
|
157
|
+
|
|
158
|
+
### 2. 快速启动按钮
|
|
159
|
+
点击输入框上方的 **启动目标** 按钮,在弹出的窗口中输入任务描述并点击确认。
|
|
160
|
+
|
|
161
|
+
### 3. 通过 REST API 控制
|
|
162
|
+
也可以通过 HTTP 请求远程控制目标:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# 启动目标
|
|
166
|
+
curl -X POST http://localhost:3080/dsh-goal/action \
|
|
167
|
+
-H "Content-Type: application/json" \
|
|
168
|
+
-d '{"action":"start","title":"实现自动化备份流水线"}'
|
|
169
|
+
|
|
170
|
+
# 暂停目标
|
|
171
|
+
curl -X POST http://localhost:3080/dsh-goal/action \
|
|
172
|
+
-H "Content-Type: application/json" \
|
|
173
|
+
-d '{"action":"pause"}'
|
|
174
|
+
|
|
175
|
+
# 恢复目标
|
|
176
|
+
curl -X POST http://localhost:3080/dsh-goal/action \
|
|
177
|
+
-H "Content-Type: application/json" \
|
|
178
|
+
-d '{"action":"resume"}'
|
|
179
|
+
|
|
180
|
+
# 查看实时状态
|
|
181
|
+
curl http://localhost:3080/dsh-goal/state
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## ⚙️ 配置说明 (`settings.yaml`)
|
|
187
|
+
|
|
188
|
+
可在 `settings.yaml` 中配置,或在 **设置 → 插件 → 目标模式** 界面中调整:
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
dsh-goal:
|
|
192
|
+
maxIterations: 25
|
|
193
|
+
autoDrive: true
|
|
194
|
+
enableSound: true
|
|
195
|
+
showQuickLaunchButton: true
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
| 参数项 | 类型 | 默认值 | 说明 |
|
|
199
|
+
|:---|:---|:---|:---|
|
|
200
|
+
| `maxIterations` | `number` | `25` | 安全限制:每个目标允许执行的最大自主轮次 |
|
|
201
|
+
| `autoDrive` | `boolean` | `true` | 是否在轮次之间自动保持循环执行 |
|
|
202
|
+
| `enableSound` | `boolean` | `true` | 目标完成或失败时是否播放提示音效 |
|
|
203
|
+
| `showQuickLaunchButton` | `boolean` | `true` | 是否在输入框上方常驻快速启动按钮 |
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 🧪 自动化测试
|
|
208
|
+
|
|
209
|
+
运行单元与集成测试套件:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
npm test
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## 📄 开源许可
|
|
218
|
+
|
|
219
|
+
MIT © [GooDAnDReaDY](https://github.com/GooDAnDReaDY)
|
package/docs/design/DESIGN.md
CHANGED
|
@@ -116,3 +116,26 @@
|
|
|
116
116
|
4. **Экспорт отчета в Markdown (One-click Markdown Export):**
|
|
117
117
|
- Для выполненной цели модальное окно предоставляет кнопку «📋 Скопировать отчёт в Markdown».
|
|
118
118
|
- Генерирует отчет с заголовком, статусом, длительностью, итерациями, расходом токенов, резюме результатов и таблицей вех.
|
|
119
|
+
|
|
120
|
+
### Решение 10: Бесшовная совместимость и перехват базовых инструментов целей DSH (update_goal, get_goal, create_goal) (v0.1.10)
|
|
121
|
+
|
|
122
|
+
**Контекст:**
|
|
123
|
+
В GitHub Issue #2 пользователи столкнулись с ошибкой:
|
|
124
|
+
`complete and blocked require a direct human turn or the current goal round`
|
|
125
|
+
при попытке модели завершить или обновить цель вызовом встроенного инструмента `update_goal`.
|
|
126
|
+
Причина: встроенный плагин ядра DSH (`@deepseek-ai/dsh-tool-goal`) накладывает жёсткие проверки происхождения хода (authority checks), которые дают сбой в автономных циклах и при вызовах вне строго размеченного раунда цели.
|
|
127
|
+
|
|
128
|
+
**Принятые решения:**
|
|
129
|
+
1. **Динамическое замещение инструментов ядра в `ToolRuntime`:**
|
|
130
|
+
- При инициализации `ctx.inject(['tools'], (tctx) => { ... })` плагин проверяет наличие `update_goal`, `get_goal`, `create_goal` в глобальном слое (`tctx.tools.layers.global.tools.data`), удаляет конфликтующие строгие определения ядра и регистрирует собственные полнофункциональные версии.
|
|
131
|
+
2. **Маршрутизация действий в `GoalEngine`:**
|
|
132
|
+
- `update_goal` перехватывает все действия модели:
|
|
133
|
+
- `action: 'complete'` — завершает цель в `engine.completeGoal()`, внедряет заключительный контекст `<goal_complete>` и возвращает статус `complete`;
|
|
134
|
+
- `action: 'pause'` — переводит цель в паузу через `engine.pause()`;
|
|
135
|
+
- `action: 'resume'` — возобновляет цель (`engine.resume()`) и перезапускает автодрайв агента;
|
|
136
|
+
- `action: 'edit'` — обновляет цель (`title`) и лимит раундов (`maxIterations`);
|
|
137
|
+
- `action: 'blocked'` — фиксирует блокер в `engine.pause()` с возвратом фазы `blocked` и кода причины.
|
|
138
|
+
3. **Строгое соответствие схеме `GOAL_OUTPUT`:**
|
|
139
|
+
- Все перехваченные инструменты возвращают структуры, валидные по спецификации `GOAL_VALUE_SCHEMA` ядра (`goal: null` при отсутствии активной цели, либо объект цели с `id`, `revision`, `objective`, `phase`, `roundsStarted`, `maxGoalRounds`, `activation`).
|
|
140
|
+
4. **Нейтрализация устаревшего системного промпта ядра:**
|
|
141
|
+
- Удаляется секция `tool:goal` ядра с ошибочными директивами и заменяется актуальной динамической инструкцией `tool:dsh-goal`.
|