spec-agent 2.0.6 → 2.0.7
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.
Potentially problematic release.
This version of spec-agent might be problematic. Click here for more details.
- package/.cursor/rules/spec-agent-assistant.mdc +6 -1
- package/.cursor/skills/spec-agent-execution-orchestrator/SKILL.md +3 -0
- package/.cursor/skills/spec-agent-onboarding-agent/SKILL.md +7 -0
- package/.cursor/skills/spec-agent-product-dev-agent/SKILL.md +8 -0
- package/{spec-agent-implementation.md → IMPLEMENTATION.md} +814 -814
- package/README.md +3 -2
- package/USAGE.md +75 -0
- package/dist/commands/handoff.d.ts.map +1 -1
- package/dist/commands/handoff.js +28 -3
- package/dist/commands/handoff.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/handoff.ts +32 -3
- package/CURSOR_AGENT_PACK.md +0 -93
- package/USAGE_FROM_NPM.md +0 -286
- package/orchestrator-v2-design.md +0 -193
package/USAGE_FROM_NPM.md
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
# spec-agent 公网安装与使用完整指引
|
|
2
|
-
|
|
3
|
-
本文档用于从零开始指导你:
|
|
4
|
-
|
|
5
|
-
- 从 npm 公网安装 `spec-agent`
|
|
6
|
-
- 配置 LLM 环境
|
|
7
|
-
- 跑通完整流程(scan/analyze/merge/plan/dispatch 或 pipeline)
|
|
8
|
-
- 生成可直接投喂 Cursor/QCoder/CodeBuddy 的 handoff 任务包
|
|
9
|
-
- 处理私有源与公网源切换
|
|
10
|
-
- 查看 `--help` 与常见问题排查
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 1. 前置条件
|
|
15
|
-
|
|
16
|
-
- Node.js >= 18(推荐 20/22)
|
|
17
|
-
- 已有可用 LLM API(例如阿里云百炼兼容 OpenAI 的接口)
|
|
18
|
-
- 准备好输入文档目录(支持 `md/pdf/docx/html/txt`)
|
|
19
|
-
|
|
20
|
-
可选检查:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
node -v
|
|
24
|
-
npm -v
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## 2. 从公网 npm 安装
|
|
30
|
-
|
|
31
|
-
如果你的默认 npm 源是公司私有源,请显式指定公网安装:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm install -g spec-agent@latest --registry=https://registry.npmjs.org/
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
安装完成后检查:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
spec-agent --version
|
|
41
|
-
spec-agent --help
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
短命令别名也可用:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
sa --help
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## 3. 创建工作目录
|
|
53
|
-
|
|
54
|
-
建议每个项目单独一个工作目录:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
mkdir my-spec-work
|
|
58
|
-
cd my-spec-work
|
|
59
|
-
mkdir docs output
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
- 把要分析的文档放进 `docs`
|
|
63
|
-
- 产物默认输出到 `output`
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## 4. 配置 LLM(PowerShell 示例)
|
|
68
|
-
|
|
69
|
-
在当前终端设置(快速验证):
|
|
70
|
-
|
|
71
|
-
```powershell
|
|
72
|
-
$env:LLM_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
|
73
|
-
$env:LLM_API_KEY="你的APIKey"
|
|
74
|
-
$env:LLM_MODEL="qwen-vl-plus"
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
可选控成本参数:
|
|
78
|
-
|
|
79
|
-
```powershell
|
|
80
|
-
$env:MAX_ANALYZE_TOKENS="120000"
|
|
81
|
-
$env:LLM_IMAGE_MAX_PER_DOC="8"
|
|
82
|
-
$env:LLM_IMAGE_MAX_BYTES="4000000"
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## 5. 先做环境自检
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
spec-agent doctor --workspace ./output --check-llm
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
如果这里失败,先修复配置再继续跑 pipeline。
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## 6. 一键执行全流程(推荐)
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
spec-agent pipeline --input ./docs --output ./output
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
常用增强参数:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
spec-agent pipeline --input ./docs --output ./output --strict-llm --analyze-retries 2 --analyze-budget-tokens 120000
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
说明:
|
|
110
|
-
|
|
111
|
-
- `--strict-llm`:LLM 失败时不降级,直接报错,适合质量优先场景
|
|
112
|
-
- `--analyze-retries`:analyze 阶段失败重试次数
|
|
113
|
-
- `--analyze-budget-tokens`:analyze 阶段 token 预算
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## 7. 分步执行(可调试)
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
spec-agent scan --input ./docs --output ./output/manifest.json
|
|
121
|
-
spec-agent analyze --manifest ./output/manifest.json --output ./output/summaries
|
|
122
|
-
spec-agent merge --summaries ./output/summaries --output ./output/spec_summary.json
|
|
123
|
-
spec-agent plan --spec ./output/spec_summary.json --output ./output/task_plan.json
|
|
124
|
-
spec-agent dispatch --plan ./output/task_plan.json --output ./output/dispatch_plan.json
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
## 8. 常用运维命令
|
|
130
|
-
|
|
131
|
-
查看当前工作区状态:
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
spec-agent status --workspace ./output
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
从某阶段恢复继续跑:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
spec-agent pipeline --input ./docs --output ./output --from analyze
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
清理中间产物:
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
spec-agent clean --workspace ./output
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
生成多 Agent 执行交接包(v2 beta 起点):
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
spec-agent handoff --workspace ./output --target cursor --include-summaries
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
执行状态机(v2 beta,先做实验):
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
# 第一次执行:初始化 run_state 并调度首批任务
|
|
159
|
-
spec-agent execute --workspace ./output --max-parallel 4
|
|
160
|
-
|
|
161
|
-
# 回填执行结果:将已完成任务标记为 succeeded
|
|
162
|
-
spec-agent execute --workspace ./output --complete T001,T002
|
|
163
|
-
|
|
164
|
-
# 回填失败并触发重试/最终失败
|
|
165
|
-
spec-agent execute --workspace ./output --fail T003 --error "compile failed"
|
|
166
|
-
|
|
167
|
-
# 生成下一步决策与上下文(orchestrator)
|
|
168
|
-
spec-agent orchestrate --workspace ./output --input ./docs
|
|
169
|
-
|
|
170
|
-
# 一轮自动推进(会自动选择 pipeline / handoff / execute)
|
|
171
|
-
spec-agent round --workspace ./output --input ./docs --target cursor --max-parallel 4
|
|
172
|
-
|
|
173
|
-
# 一条命令完成“回填 + 下一轮推进”
|
|
174
|
-
spec-agent round --workspace ./output --input ./docs --complete T001,T002 --fail T003 --error "compile failed"
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## 9. `--help` 使用方式
|
|
180
|
-
|
|
181
|
-
总帮助:
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
spec-agent --help
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
子命令帮助:
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
spec-agent scan --help
|
|
191
|
-
spec-agent analyze --help
|
|
192
|
-
spec-agent merge --help
|
|
193
|
-
spec-agent plan --help
|
|
194
|
-
spec-agent dispatch --help
|
|
195
|
-
spec-agent pipeline --help
|
|
196
|
-
spec-agent doctor --help
|
|
197
|
-
spec-agent status --help
|
|
198
|
-
spec-agent clean --help
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## 10. 常见问题
|
|
204
|
-
|
|
205
|
-
### Q1: 安装时报 404,找不到包
|
|
206
|
-
|
|
207
|
-
大概率是走了私有源。请显式指定公网:
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
npm install -g spec-agent --registry=https://registry.npmjs.org/
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
并检查当前 registry:
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
npm config get registry
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### Q2: 发布时报 `ENEEDAUTH`
|
|
220
|
-
|
|
221
|
-
说明没登录公网 npm。执行:
|
|
222
|
-
|
|
223
|
-
```bash
|
|
224
|
-
npm login --registry=https://registry.npmjs.org/
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Q3: 发布时报 `E403`,提示 2FA 或 token 权限不足
|
|
228
|
-
|
|
229
|
-
按 npm 安全策略,需要:
|
|
230
|
-
|
|
231
|
-
- 开启账号 2FA(Auth and Writes),或
|
|
232
|
-
- 使用带 publish 权限且允许 bypass 2FA 的 token
|
|
233
|
-
|
|
234
|
-
### Q4: 命令存在但分析失败
|
|
235
|
-
|
|
236
|
-
先跑:
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
spec-agent doctor --workspace ./output --check-llm
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
再确认:
|
|
243
|
-
|
|
244
|
-
- `LLM_BASE_URL` / `LLM_API_KEY` / `LLM_MODEL` 是否正确
|
|
245
|
-
- 网络可访问模型接口
|
|
246
|
-
- 输入文档是否可读
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
## 11. 私有源与公网源切换参考
|
|
251
|
-
|
|
252
|
-
切到公网:
|
|
253
|
-
|
|
254
|
-
```bash
|
|
255
|
-
npm config set registry https://registry.npmjs.org/
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
切回私有源(示例):
|
|
259
|
-
|
|
260
|
-
```bash
|
|
261
|
-
npm config set registry https://nexus.cyberway.com.cn/repository/npmGroup/
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
只想单次使用公网,不改全局配置:
|
|
265
|
-
|
|
266
|
-
```bash
|
|
267
|
-
npm install -g spec-agent --registry=https://registry.npmjs.org/
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## 12. 推荐首次执行顺序
|
|
273
|
-
|
|
274
|
-
```bash
|
|
275
|
-
spec-agent --version
|
|
276
|
-
spec-agent --help
|
|
277
|
-
spec-agent doctor --workspace ./output --check-llm
|
|
278
|
-
spec-agent pipeline --input ./docs --output ./output
|
|
279
|
-
spec-agent status --workspace ./output
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
执行完成后,核心结果通常在:
|
|
283
|
-
|
|
284
|
-
- `output/spec_summary.json`
|
|
285
|
-
- `output/task_plan.json`
|
|
286
|
-
- `output/dispatch_plan.json`
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
# Spec-Agent Orchestrator v2 设计方案
|
|
2
|
-
|
|
3
|
-
## 1. 目标与范围
|
|
4
|
-
|
|
5
|
-
本方案用于将 `spec-agent` 从“产物生成工具”升级为“可持续推进执行的智能体编排器”。
|
|
6
|
-
|
|
7
|
-
核心目标:
|
|
8
|
-
|
|
9
|
-
- 自动调用 `spec-agent` CLI(pipeline/handoff/execute)
|
|
10
|
-
- 基于产物做决策,不依赖人工记忆当前状态
|
|
11
|
-
- 支持失败重试与中断恢复
|
|
12
|
-
- 输出明确下一步动作,降低人工操作成本
|
|
13
|
-
|
|
14
|
-
非目标(v2 不做):
|
|
15
|
-
|
|
16
|
-
- 自动提交 PR / 自动合并代码
|
|
17
|
-
- 跨仓库复杂编排
|
|
18
|
-
- 无约束的自动改代码
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## 2. 总体架构
|
|
23
|
-
|
|
24
|
-
建议采用 4 个职责清晰的 Agent 角色:
|
|
25
|
-
|
|
26
|
-
- **Onboarding Agent**:检查安装与环境,确保首次可运行
|
|
27
|
-
- **Pipeline Agent**:负责 scan -> analyze -> merge -> plan -> dispatch
|
|
28
|
-
- **Execution Orchestrator Agent**:负责 handoff + execute 循环推进
|
|
29
|
-
- **Failure Triage Agent**:负责错误分流、修复建议与重试策略
|
|
30
|
-
|
|
31
|
-
说明:v2 初版可由一个主 Agent 执行上述职责;v2.1 后再拆分为多 Agent 角色。
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## 3. 输入与输出契约
|
|
36
|
-
|
|
37
|
-
### 3.1 关键输入产物
|
|
38
|
-
|
|
39
|
-
- `output/manifest.json`
|
|
40
|
-
- `output/spec_summary.json`
|
|
41
|
-
- `output/task_plan.json`
|
|
42
|
-
- `output/dispatch_plan.json`
|
|
43
|
-
- `output/handoff/handoff_bundle.json`
|
|
44
|
-
- `output/execution/run_state.json`
|
|
45
|
-
- `output/execution/execution_report.json`
|
|
46
|
-
- `output/execution/inbox/*.md`
|
|
47
|
-
|
|
48
|
-
### 3.2 Orchestrator 统一上下文文件
|
|
49
|
-
|
|
50
|
-
新增文件:
|
|
51
|
-
|
|
52
|
-
- `output/orchestrator_context.json`
|
|
53
|
-
|
|
54
|
-
用途:
|
|
55
|
-
|
|
56
|
-
- 记录当前阶段、上次动作、最近错误、下一步建议
|
|
57
|
-
- 为 Agent 提供单一事实源(single source of truth)
|
|
58
|
-
|
|
59
|
-
建议结构:
|
|
60
|
-
|
|
61
|
-
```json
|
|
62
|
-
{
|
|
63
|
-
"version": "2.0.0-beta",
|
|
64
|
-
"updatedAt": "2026-04-02T10:00:00Z",
|
|
65
|
-
"workspace": "./output",
|
|
66
|
-
"state": "EXECUTION_RUNNING",
|
|
67
|
-
"lastAction": "spec-agent execute --workspace ./output --max-parallel 4",
|
|
68
|
-
"lastError": null,
|
|
69
|
-
"nextAction": "等待回填:--complete/--fail",
|
|
70
|
-
"metrics": {
|
|
71
|
-
"pending": 120,
|
|
72
|
-
"running": 4,
|
|
73
|
-
"succeeded": 33,
|
|
74
|
-
"failed": 2,
|
|
75
|
-
"blocked": 1
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## 4. 状态机设计
|
|
83
|
-
|
|
84
|
-
状态定义:
|
|
85
|
-
|
|
86
|
-
- `INIT`
|
|
87
|
-
- `READY`
|
|
88
|
-
- `PIPELINE_RUNNING`
|
|
89
|
-
- `PIPELINE_READY`
|
|
90
|
-
- `EXECUTION_RUNNING`
|
|
91
|
-
- `WAITING_FEEDBACK`
|
|
92
|
-
- `PARTIAL_FAILED`
|
|
93
|
-
- `DONE`
|
|
94
|
-
|
|
95
|
-
状态转移规则(简化):
|
|
96
|
-
|
|
97
|
-
1. `INIT -> READY`:安装与环境检查通过
|
|
98
|
-
2. `READY -> PIPELINE_RUNNING`:触发 pipeline
|
|
99
|
-
3. `PIPELINE_RUNNING -> PIPELINE_READY`:产物齐全(task_plan + dispatch_plan)
|
|
100
|
-
4. `PIPELINE_READY -> EXECUTION_RUNNING`:生成 handoff 并首次 execute
|
|
101
|
-
5. `EXECUTION_RUNNING -> WAITING_FEEDBACK`:存在 running 任务,等待回填
|
|
102
|
-
6. `WAITING_FEEDBACK -> EXECUTION_RUNNING`:回填完成,继续调度
|
|
103
|
-
7. 任意状态 -> `PARTIAL_FAILED`:关键错误出现且不可自动恢复
|
|
104
|
-
8. `EXECUTION_RUNNING -> DONE`:pending/running/blocked 归零
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## 5. 决策规则(执行引擎)
|
|
109
|
-
|
|
110
|
-
按优先级从上到下判断:
|
|
111
|
-
|
|
112
|
-
1. 若 `spec-agent --version` 失败:
|
|
113
|
-
- 提示安装:`npm install -g spec-agent --registry=https://registry.npmjs.org/`
|
|
114
|
-
2. 若 `dispatch_plan.json` 不存在:
|
|
115
|
-
- 执行 `spec-agent pipeline --input ./docs --output ./output`
|
|
116
|
-
3. 若 `handoff_bundle.json` 不存在:
|
|
117
|
-
- 执行 `spec-agent handoff --workspace ./output --target cursor --include-summaries`
|
|
118
|
-
4. 若 `run_state.json` 不存在:
|
|
119
|
-
- 执行 `spec-agent execute --workspace ./output --max-parallel 4`
|
|
120
|
-
5. 若 `run_state` 中有 `running`:
|
|
121
|
-
- 进入等待反馈,不重复调度
|
|
122
|
-
6. 若 `pending > 0` 且 `running = 0`:
|
|
123
|
-
- 再次执行 `execute` 调度
|
|
124
|
-
7. 若 `failed` 增长:
|
|
125
|
-
- 调用故障分流策略,给出重试或人工介入建议
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
## 6. MVP 边界(先做可实验)
|
|
130
|
-
|
|
131
|
-
v2 初版仅包含:
|
|
132
|
-
|
|
133
|
-
- 安装检查与首轮 pipeline 引导
|
|
134
|
-
- handoff + execute 调度闭环
|
|
135
|
-
- `--complete / --fail` 回填推进
|
|
136
|
-
- `orchestrator_context.json` 最小写入
|
|
137
|
-
|
|
138
|
-
v2 初版不包含:
|
|
139
|
-
|
|
140
|
-
- 自动代码生成与自动代码回填
|
|
141
|
-
- 自动 PR 流程
|
|
142
|
-
- 高级冲突自动修复
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## 7. 失败分流策略
|
|
147
|
-
|
|
148
|
-
错误类别与处理:
|
|
149
|
-
|
|
150
|
-
- **安装类**(command not found)
|
|
151
|
-
- 给出安装命令与版本校验命令
|
|
152
|
-
- **认证类**(npm ENEEDAUTH / E403)
|
|
153
|
-
- 给出登录或 2FA/token 指引
|
|
154
|
-
- **配置类**(LLM key/base_url/model 缺失)
|
|
155
|
-
- 给出 `doctor --check-llm` 与变量模板
|
|
156
|
-
- **执行类**(task failed)
|
|
157
|
-
- 记录 error,按 `--retry` 重试,超限标记 failed
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## 8. 实施计划
|
|
162
|
-
|
|
163
|
-
### Milestone A(1-2 天)
|
|
164
|
-
|
|
165
|
-
- 落地 `orchestrator_context.json`
|
|
166
|
-
- 实现决策函数(只读产物 -> 推荐命令)
|
|
167
|
-
|
|
168
|
-
### Milestone B(2-3 天)
|
|
169
|
-
|
|
170
|
-
- 将决策函数接入现有 Skill(onboarding + execution)
|
|
171
|
-
- 支持一键“执行一轮”指令
|
|
172
|
-
|
|
173
|
-
### Milestone C(2-3 天)
|
|
174
|
-
|
|
175
|
-
- 加入失败分流模板(安装、认证、LLM、执行)
|
|
176
|
-
- 增加轮次摘要输出(可复盘)
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
## 9. 验收标准
|
|
181
|
-
|
|
182
|
-
- 新环境可从未安装状态引导至 `pipeline` 完成
|
|
183
|
-
- 可连续推进至少 3 轮 execute,不丢失状态
|
|
184
|
-
- 中断重开后可依据 `run_state` 和 `orchestrator_context` 恢复
|
|
185
|
-
- 每轮输出明确下一步命令,不要求用户自行推断
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## 10. 版本节奏对齐
|
|
190
|
-
|
|
191
|
-
- `v1.x`:拆解 + 规划
|
|
192
|
-
- `v2.x`:多 Agent 执行(Beta)
|
|
193
|
-
- `v3.x`:多 Agent 闭环(执行 + 回填 + 验收)
|