@specpow/framework 0.5.9 → 0.5.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/.specpow/skills/cli-router/SKILL.md +1 -2
- package/.specpow/skills/planning-apply-change/SKILL.md +1 -1
- package/.specpow/skills/planning-archive-change/SKILL.md +13 -3
- package/.specpow/skills/planning-explore/SKILL.md +4 -8
- package/.specpow/skills/planning-onboard/SKILL.md +0 -1
- package/.specpow/skills/planning-propose/SKILL.md +16 -0
- package/.specpow/skills/planning-verify-change/SKILL.md +15 -1
- package/.specpow/skills/planning-write-specs/SKILL.md +0 -18
- package/dist/commands/archive.d.ts.map +1 -1
- package/dist/commands/archive.js +25 -1
- package/dist/commands/archive.js.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +12 -9
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +12 -17
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/workflow/index.js +5 -2
- package/dist/commands/workflow/index.js.map +1 -1
- package/dist/core/hooks/session-start-hook.d.ts.map +1 -1
- package/dist/core/hooks/session-start-hook.js +26 -0
- package/dist/core/hooks/session-start-hook.js.map +1 -1
- package/dist/core/init/codegraph-step.d.ts +36 -0
- package/dist/core/init/codegraph-step.d.ts.map +1 -0
- package/dist/core/init/codegraph-step.js +109 -0
- package/dist/core/init/codegraph-step.js.map +1 -0
- package/dist/core/init/engine.d.ts +2 -2
- package/dist/core/init/engine.d.ts.map +1 -1
- package/dist/core/init/engine.js +13 -2
- package/dist/core/init/engine.js.map +1 -1
- package/dist/core/task-parser.d.ts +17 -0
- package/dist/core/task-parser.d.ts.map +1 -0
- package/dist/core/task-parser.js +59 -0
- package/dist/core/task-parser.js.map +1 -0
- package/package.json +1 -1
- package/.specpow/agents/controller/sdd-controller.md +0 -55
- package/.specpow/agents/execution/java-codegen-agent.md +0 -39
- package/.specpow/agents/execution/ui-codegen-agent.md +0 -32
- package/.specpow/agents/ops/deploy-agent.md +0 -181
- package/.specpow/agents/planning/db-designer-agent.md +0 -30
- package/.specpow/agents/planning/prd-agent.md +0 -31
- package/.specpow/agents/quality/review-agent.md +0 -36
- package/.specpow/agents/quality/test-agent.md +0 -33
- package/.specpow/hooks/hooks.json +0 -30
- package/.specpow/hooks/run-hook.cmd +0 -19
- package/.specpow/hooks/session-start +0 -62
- package/.specpow/hooks/workflow-state +0 -150
- package/.specpow/schemas/bug-fix/schema.yaml +0 -64
- package/.specpow/schemas/bug-fix/templates/analysis.md +0 -43
- package/.specpow/schemas/bug-fix/templates/fix-plan.md +0 -19
- package/.specpow/schemas/bug-fix/templates/proposal.md +0 -30
- package/.specpow/schemas/crud-module/schema.yaml +0 -65
- package/.specpow/schemas/crud-module/templates/design.md +0 -36
- package/.specpow/schemas/crud-module/templates/proposal.md +0 -30
- package/.specpow/schemas/crud-module/templates/spec.md +0 -38
- package/.specpow/schemas/crud-module/templates/tasks.md +0 -57
- package/.specpow/schemas/spec-driven/schema.yaml +0 -87
- package/.specpow/schemas/spec-driven/templates/design.md +0 -54
- package/.specpow/schemas/spec-driven/templates/proposal.md +0 -31
- package/.specpow/schemas/spec-driven/templates/spec.md +0 -42
- package/.specpow/schemas/spec-driven/templates/tasks.md +0 -98
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
# Deploy Agent
|
|
2
|
-
|
|
3
|
-
部署代理负责将应用安全部署到目标环境。
|
|
4
|
-
|
|
5
|
-
## 职责
|
|
6
|
-
|
|
7
|
-
- 执行部署前检查
|
|
8
|
-
- 管理部署流程
|
|
9
|
-
- 验证部署结果
|
|
10
|
-
- 处理回滚
|
|
11
|
-
|
|
12
|
-
## 部署检查清单
|
|
13
|
-
|
|
14
|
-
### 部署前
|
|
15
|
-
|
|
16
|
-
- [ ] 所有测试通过
|
|
17
|
-
- [ ] 代码审查完成
|
|
18
|
-
- [ ] 安全扫描通过
|
|
19
|
-
- [ ] 性能测试达标
|
|
20
|
-
- [ ] 数据库迁移脚本就绪
|
|
21
|
-
- [ ] 配置文件更新
|
|
22
|
-
- [ ] 回滚方案准备
|
|
23
|
-
|
|
24
|
-
### 部署中
|
|
25
|
-
|
|
26
|
-
- [ ] 备份当前版本
|
|
27
|
-
- [ ] 执行数据库迁移
|
|
28
|
-
- [ ] 部署应用代码
|
|
29
|
-
- [ ] 更新配置
|
|
30
|
-
- [ ] 重启服务
|
|
31
|
-
|
|
32
|
-
### 部署后
|
|
33
|
-
|
|
34
|
-
- [ ] 健康检查通过
|
|
35
|
-
- [ ] 功能验证通过
|
|
36
|
-
- [ ] 性能监控正常
|
|
37
|
-
- [ ] 错误率正常
|
|
38
|
-
- [ ] 日志无异常
|
|
39
|
-
- [ ] 通知相关人员
|
|
40
|
-
|
|
41
|
-
## 部署策略
|
|
42
|
-
|
|
43
|
-
### 滚动更新
|
|
44
|
-
|
|
45
|
-
适用于无状态服务:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
# 逐个节点更新
|
|
49
|
-
for node in ${NODES}; do
|
|
50
|
-
deploy-to-node $node
|
|
51
|
-
health-check $node
|
|
52
|
-
done
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### 蓝绿部署
|
|
56
|
-
|
|
57
|
-
适用于关键服务:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
# 部署到绿色环境
|
|
61
|
-
deploy-to-green
|
|
62
|
-
|
|
63
|
-
# 验证绿色环境
|
|
64
|
-
verify-green
|
|
65
|
-
|
|
66
|
-
# 切换流量
|
|
67
|
-
switch-to-green
|
|
68
|
-
|
|
69
|
-
# 保留蓝色环境作为回滚
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### 金丝雀发布
|
|
73
|
-
|
|
74
|
-
适用于高风险变更:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
# 部署到 5% 的实例
|
|
78
|
-
deploy-canary --percentage 5
|
|
79
|
-
|
|
80
|
-
# 监控指标
|
|
81
|
-
monitor-canary --duration 30m
|
|
82
|
-
|
|
83
|
-
# 逐步扩大
|
|
84
|
-
expand-canary --percentage 25
|
|
85
|
-
expand-canary --percentage 50
|
|
86
|
-
expand-canary --percentage 100
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## 回滚流程
|
|
90
|
-
|
|
91
|
-
### 自动回滚触发条件
|
|
92
|
-
|
|
93
|
-
- 错误率 > 5%
|
|
94
|
-
- P99 延迟 > 2x 基线
|
|
95
|
-
- 健康检查失败
|
|
96
|
-
- 关键功能异常
|
|
97
|
-
|
|
98
|
-
### 回滚步骤
|
|
99
|
-
|
|
100
|
-
1. 停止部署流程
|
|
101
|
-
2. 切换到上一版本
|
|
102
|
-
3. 验证服务恢复
|
|
103
|
-
4. 分析问题原因
|
|
104
|
-
5. 通知相关人员
|
|
105
|
-
|
|
106
|
-
## 环境配置
|
|
107
|
-
|
|
108
|
-
### 开发环境
|
|
109
|
-
|
|
110
|
-
```yaml
|
|
111
|
-
environment: development
|
|
112
|
-
replicas: 1
|
|
113
|
-
resources:
|
|
114
|
-
cpu: 0.5
|
|
115
|
-
memory: 512Mi
|
|
116
|
-
auto_deploy: true
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### 测试环境
|
|
120
|
-
|
|
121
|
-
```yaml
|
|
122
|
-
environment: staging
|
|
123
|
-
replicas: 2
|
|
124
|
-
resources:
|
|
125
|
-
cpu: 1
|
|
126
|
-
memory: 1Gi
|
|
127
|
-
auto_deploy: false
|
|
128
|
-
approval_required: false
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### 生产环境
|
|
132
|
-
|
|
133
|
-
```yaml
|
|
134
|
-
environment: production
|
|
135
|
-
replicas: 3
|
|
136
|
-
resources:
|
|
137
|
-
cpu: 2
|
|
138
|
-
memory: 2Gi
|
|
139
|
-
auto_deploy: false
|
|
140
|
-
approval_required: true
|
|
141
|
-
rollback_strategy: automatic
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## 监控指标
|
|
145
|
-
|
|
146
|
-
### 关键指标
|
|
147
|
-
|
|
148
|
-
- 部署成功率
|
|
149
|
-
- 部署耗时
|
|
150
|
-
- 回滚次数
|
|
151
|
-
- 服务可用性
|
|
152
|
-
- 错误率
|
|
153
|
-
- 响应时间
|
|
154
|
-
|
|
155
|
-
### 告警规则
|
|
156
|
-
|
|
157
|
-
```yaml
|
|
158
|
-
alerts:
|
|
159
|
-
- name: HighErrorRate
|
|
160
|
-
condition: error_rate > 0.05
|
|
161
|
-
duration: 5m
|
|
162
|
-
severity: critical
|
|
163
|
-
|
|
164
|
-
- name: HighLatency
|
|
165
|
-
condition: p99_latency > 2000ms
|
|
166
|
-
duration: 10m
|
|
167
|
-
severity: warning
|
|
168
|
-
|
|
169
|
-
- name: HealthCheckFailed
|
|
170
|
-
condition: health_check == false
|
|
171
|
-
duration: 1m
|
|
172
|
-
severity: critical
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## 最佳实践
|
|
176
|
-
|
|
177
|
-
1. **始终准备回滚方案** - 每次部署前确保可以快速回滚
|
|
178
|
-
2. **渐进式发布** - 使用金丝雀或蓝绿部署降低风险
|
|
179
|
-
3. **自动化验证** - 部署后自动执行健康检查和功能验证
|
|
180
|
-
4. **监控先行** - 部署前确保监控和告警就绪
|
|
181
|
-
5. **文档记录** - 记录每次部署的变更和结果
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# DB Designer Agent
|
|
2
|
-
|
|
3
|
-
## 职责
|
|
4
|
-
根据 PRD 设计表结构(遵循字段分类规范),生成 DDL + 索引建议 + 状态码分配
|
|
5
|
-
|
|
6
|
-
## 输入
|
|
7
|
-
- PRD 文件路径
|
|
8
|
-
- 现有数据库 Schema(可选)
|
|
9
|
-
|
|
10
|
-
## 输出
|
|
11
|
-
- `docs/db/<ticket>-ddl.sql` — DDL 脚本
|
|
12
|
-
- `docs/db/<ticket>-indexes.sql` — 索引建议
|
|
13
|
-
- `docs/db/<ticket>-status-codes.md` — 状态码分配表
|
|
14
|
-
|
|
15
|
-
## 工作流
|
|
16
|
-
1. 读取 PRD
|
|
17
|
-
2. 识别实体和关系
|
|
18
|
-
3. 设计表结构(遵循命名规范)
|
|
19
|
-
4. 设计索引(基于查询模式)
|
|
20
|
-
5. 分配状态码
|
|
21
|
-
6. 生成 DDL 脚本
|
|
22
|
-
7. 自审(检查外键、索引覆盖、命名一致性)
|
|
23
|
-
|
|
24
|
-
## 规范
|
|
25
|
-
- 表名:小写,下划线分隔
|
|
26
|
-
- 字段名:小写,下划线分隔
|
|
27
|
-
- 主键:`id` (BIGINT)
|
|
28
|
-
- 审计字段:`created_by`, `created_time`, `updated_by`, `updated_time`
|
|
29
|
-
- 软删除:`is_deleted` (TINYINT)
|
|
30
|
-
- 状态码:按模块分配范围
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# PRD Agent
|
|
2
|
-
|
|
3
|
-
## 职责
|
|
4
|
-
将用户口述/会议纪要/原型截图转化为结构化 PRD(含用例、字段、流程图 Mermaid)
|
|
5
|
-
|
|
6
|
-
## 输入
|
|
7
|
-
- `docs/prd/input/<ticket-id>.md` — 用户原始需求(手工或 Jira 导入)
|
|
8
|
-
- `docs/prd/references/<related-docs>.md` — 参考文档(可选)
|
|
9
|
-
|
|
10
|
-
## 输出
|
|
11
|
-
- `docs/prd/output/<ticket-id>.md` — 结构化 PRD
|
|
12
|
-
- `docs/prd/output/<ticket-id>.meta.json` — 元数据(影响模块、字段、状态码)
|
|
13
|
-
|
|
14
|
-
## 错误处理
|
|
15
|
-
- 输入缺失 → 返回 `docs/prd/errors/<ticket-id>.missing.md`
|
|
16
|
-
- 无法解析 → 返回结构化错误,不生成输出
|
|
17
|
-
|
|
18
|
-
## 工作流
|
|
19
|
-
1. 读取输入文件
|
|
20
|
-
2. 使用 `explore` 技能进行需求探索
|
|
21
|
-
3. 使用 `propose` 技能创建变更提案
|
|
22
|
-
4. 生成结构化 PRD
|
|
23
|
-
5. 生成元数据 JSON
|
|
24
|
-
6. 自审 PRD 完整性
|
|
25
|
-
|
|
26
|
-
## 质量检查
|
|
27
|
-
- [ ] 所有用户场景已覆盖
|
|
28
|
-
- [ ] 字段定义完整(类型、约束、默认值)
|
|
29
|
-
- [ ] 状态码已分配
|
|
30
|
-
- [ ] 流程图已绘制
|
|
31
|
-
- [ ] 非目标已明确
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Review Agent
|
|
2
|
-
|
|
3
|
-
## 职责
|
|
4
|
-
读取 commit range / MR diff → 按 code-review Skill 生成结构化报告
|
|
5
|
-
|
|
6
|
-
## 输入
|
|
7
|
-
- commit 范围(如 `HEAD~5..HEAD`)
|
|
8
|
-
- 或 MR diff 文件路径
|
|
9
|
-
|
|
10
|
-
## 输出
|
|
11
|
-
- 结构化审查报告(findings 列表)
|
|
12
|
-
- 严重度排序
|
|
13
|
-
|
|
14
|
-
## 工作流
|
|
15
|
-
1. 获取 diff(本地 commit range 或 MR diff)
|
|
16
|
-
2. 使用 `requesting-review` 技能指导审查
|
|
17
|
-
3. 按检查清单审查:
|
|
18
|
-
- 规范合规性(对照 specs/)
|
|
19
|
-
- 代码质量(命名、结构、复杂度)
|
|
20
|
-
- 安全性(注入、XSS、权限)
|
|
21
|
-
- 性能(N+1、大查询、缓存)
|
|
22
|
-
- 测试覆盖
|
|
23
|
-
4. 按严重度排序 findings
|
|
24
|
-
5. 输出结构化报告
|
|
25
|
-
|
|
26
|
-
## 审查维度
|
|
27
|
-
1. **规范合规** — 实现是否满足 specs/ 中定义的行为契约
|
|
28
|
-
2. **代码质量** — 命名、结构、可读性、复杂度
|
|
29
|
-
3. **安全性** — 注入、XSS、CSRF、权限检查
|
|
30
|
-
4. **性能** — N+1 查询、大结果集、缺少缓存
|
|
31
|
-
5. **测试** — 覆盖率、测试质量、断言强度
|
|
32
|
-
|
|
33
|
-
## CI 集成
|
|
34
|
-
- GitLab MR webhook → 自动触发
|
|
35
|
-
- 结果回写 MR comment
|
|
36
|
-
- 标记 "AI Review: Needs Attention"
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# Test Agent
|
|
2
|
-
|
|
3
|
-
## 职责
|
|
4
|
-
根据 Service/Mapper 生成 Mock 测试(遵循 TESTING.md,Mockito + JUnit5)
|
|
5
|
-
|
|
6
|
-
## 输入
|
|
7
|
-
- 目标类路径(如 `UserService.java`)
|
|
8
|
-
|
|
9
|
-
## 输出
|
|
10
|
-
- `XxxServiceMock.java` — Mock 测试类
|
|
11
|
-
- 测试报告
|
|
12
|
-
|
|
13
|
-
## 工作流
|
|
14
|
-
1. 读取源类和依赖
|
|
15
|
-
2. 使用 `tdd` 技能指导测试设计
|
|
16
|
-
3. 生成 Mock 测试类
|
|
17
|
-
4. 本地运行测试
|
|
18
|
-
5. 失败 → 自修(≤3 次)
|
|
19
|
-
6. 输出测试报告
|
|
20
|
-
|
|
21
|
-
## 测试规范
|
|
22
|
-
- 框架:JUnit 5 + Mockito
|
|
23
|
-
- 命名:`should_<expected>_when_<condition>`
|
|
24
|
-
- 覆盖:正常路径 + 异常路径 + 边界条件
|
|
25
|
-
- Mock:所有外部依赖
|
|
26
|
-
- 断言:明确、具体
|
|
27
|
-
|
|
28
|
-
## 质量检查
|
|
29
|
-
- [ ] 正常路径覆盖
|
|
30
|
-
- [ ] 异常路径覆盖
|
|
31
|
-
- [ ] 边界条件覆盖
|
|
32
|
-
- [ ] Mock 正确配置
|
|
33
|
-
- [ ] 断言有意义
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"hooks": {
|
|
3
|
-
"SessionStart": [
|
|
4
|
-
{
|
|
5
|
-
"matcher": "",
|
|
6
|
-
"hooks": [
|
|
7
|
-
{
|
|
8
|
-
"type": "command",
|
|
9
|
-
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start",
|
|
10
|
-
"shell": "bash",
|
|
11
|
-
"async": false
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"UserPromptSubmit": [
|
|
17
|
-
{
|
|
18
|
-
"matcher": "",
|
|
19
|
-
"hooks": [
|
|
20
|
-
{
|
|
21
|
-
"type": "command",
|
|
22
|
-
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" workflow-state",
|
|
23
|
-
"shell": "bash",
|
|
24
|
-
"async": false
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
REM SpecPow Hook Runner for Windows
|
|
3
|
-
REM Usage: run-hook.cmd <hook-name>
|
|
4
|
-
REM
|
|
5
|
-
REM P2-11: 支持 SessionStart 和 WorkflowState 两种 Hook
|
|
6
|
-
|
|
7
|
-
set HOOK_NAME=%1
|
|
8
|
-
set SCRIPT_DIR=%~dp0
|
|
9
|
-
|
|
10
|
-
if "%HOOK_NAME%"=="session-start" (
|
|
11
|
-
bash "%SCRIPT_DIR%session-start"
|
|
12
|
-
) else if "%HOOK_NAME%"=="workflow-state" (
|
|
13
|
-
REM WorkflowState Hook: 注入当前工作流状态
|
|
14
|
-
REM 通过 Node.js 调用 TypeScript Hook 模块
|
|
15
|
-
node -e "import('file:///%SCRIPT_DIR:~0,-1%/../dist/core/hooks/index.js').then(m => m.executeUserPromptSubmit(process.cwd(), '', 'claude').then(c => { if(c) console.log(JSON.stringify({hookSpecificOutput:{hookEventName:'UserPromptSubmit',additionalContext:c}})); else process.exit(0); }))"
|
|
16
|
-
) else (
|
|
17
|
-
echo Unknown hook: %HOOK_NAME%
|
|
18
|
-
exit /b 1
|
|
19
|
-
)
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# SpecPow Session Start Hook
|
|
3
|
-
#
|
|
4
|
-
# 在每次会话开始时注入 using-skills 技能内容到 AI 代理上下文
|
|
5
|
-
# 兼容 Claude Code、Cursor、Copilot CLI 等平台
|
|
6
|
-
|
|
7
|
-
set -euo pipefail
|
|
8
|
-
|
|
9
|
-
# Determine plugin root directory
|
|
10
|
-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
11
|
-
PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
12
|
-
|
|
13
|
-
# Read using-skills content
|
|
14
|
-
using_skills_content=$(cat "${PLUGIN_ROOT}/skills/meta-using-skills/SKILL.md" 2>&1 || echo "Error reading using-skills skill")
|
|
15
|
-
|
|
16
|
-
# Escape string for JSON embedding
|
|
17
|
-
escape_for_json() {
|
|
18
|
-
local s="$1"
|
|
19
|
-
s="${s//\\/\\\\}"
|
|
20
|
-
s="${s//\"/\\\"}"
|
|
21
|
-
s="${s//$'\n'/\\n}"
|
|
22
|
-
s="${s//$'\r'/\\r}"
|
|
23
|
-
s="${s//$'\t'/\\t}"
|
|
24
|
-
printf '%s' "$s"
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
using_skills_escaped=$(escape_for_json "$using_skills_content")
|
|
28
|
-
|
|
29
|
-
# Check for OpenSpec context
|
|
30
|
-
openspec_context=""
|
|
31
|
-
if [ -f "${PLUGIN_ROOT}/../openspec/specs" ] 2>/dev/null || [ -d "${PLUGIN_ROOT}/../openspec/specs" ] 2>/dev/null; then
|
|
32
|
-
# Detect active changes
|
|
33
|
-
active_changes=""
|
|
34
|
-
if [ -d "${PLUGIN_ROOT}/../openspec/changes" ] 2>/dev/null; then
|
|
35
|
-
changes_count=$(find "${PLUGIN_ROOT}/../openspec/changes" -maxdepth 1 -mindepth 1 -type d ! -name 'archive' 2>/dev/null | wc -l | tr -d ' ')
|
|
36
|
-
if [ "$changes_count" -gt 0 ] 2>/dev/null; then
|
|
37
|
-
active_changes_list=$(find "${PLUGIN_ROOT}/../openspec/changes" -maxdepth 1 -mindepth 1 -type d ! -name 'archive' 2>/dev/null | while read d; do basename "$d"; done | tr '\n' ', ' | sed 's/, $//')
|
|
38
|
-
active_changes="\nActive changes (${changes_count}): ${active_changes_list}\nUse 'specpow status' to inspect."
|
|
39
|
-
fi
|
|
40
|
-
fi
|
|
41
|
-
|
|
42
|
-
openspec_context="\nOpenSpec structure detected in this project. Follow the spec-driven workflow:\n1. Explore → planning-explore skill\n2. Propose → planning-propose skill\n3. Write Specs/Design/Tasks → planning-write-* skills\n4. Implement → execution-* skills (SDD engine)\n5. Verify → execution-verification-before-completion\n6. Archive → specpow archive\n${active_changes}\n"
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
session_context="<EXTREMELY_IMPORTANT>\nYou have specpow — a spec-powered AI development framework. It combines OpenSpec's spec-driven planning with Superpowers' subagent-driven execution.\n\n**Below is the full content of your 'specpow:meta-using-skills' skill - your introduction to using skills. For all other skills, use the 'Skill' tool:**\n\n${using_skills_escaped}\n\n${openspec_context}\n\nAvailable skill categories:\n- Planning: planning-explore, planning-propose, planning-write-plans, planning-write-specs, planning-write-design\n- Execution: planning-apply-change, execution-subagent-driven-dev, execution-tdd, execution-systematic-debugging, execution-parallel-agents\n- Quality: execution-requesting-review, execution-receiving-review, execution-verification-before-completion, planning-verify-change\n- Business: business-java-codegen, business-ui-codegen, business-test-gen, business-code-review, business-db-design, business-prd-writer, business-deploy-check\n- CLI Router: cli-router — maps user intent to SpecPow CLI commands\n\nSpecPow CLI quick reference (execute via Bash tool):\n| Command | Purpose |\n|---------|----------|\n| specpow status | View current change status |\n| specpow explore \"<topic>\" | Socratic requirement exploration (interactive, run in terminal) |\n| specpow propose <name> | Create change proposal |\n| specpow apply | Execute implementation |\n| specpow verify | Verify changes |\n| specpow archive | Archive changes |\n| specpow debug \"<desc>\" | Systematic debugging |\n| specpow doctor | Project diagnostics |\n\nUsers can also use slash commands: /specpow-explore, /specpow-propose, /specpow-apply, /specpow-verify, /specpow-archive, /specpow-status\n\nRemember: Check for relevant skills BEFORE any action.\n</EXTREMELY_IMPORTANT>"
|
|
46
|
-
|
|
47
|
-
# Output context injection as JSON
|
|
48
|
-
# Cursor hooks expect additional_context (snake_case)
|
|
49
|
-
# Claude Code hooks expect hookSpecificOutput.additionalContext (nested)
|
|
50
|
-
# Copilot CLI (v1.0.11+) and others expect additionalContext (top-level, SDK standard)
|
|
51
|
-
if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
|
|
52
|
-
# Cursor sets CURSOR_PLUGIN_ROOT (may also set CLAUDE_PLUGIN_ROOT)
|
|
53
|
-
printf '{\n "additional_context": "%s"\n}\n' "$session_context" | cat
|
|
54
|
-
elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -z "${COPILOT_CLI:-}" ]; then
|
|
55
|
-
# Claude Code sets CLAUDE_PLUGIN_ROOT without COPILOT_CLI
|
|
56
|
-
printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context" | cat
|
|
57
|
-
else
|
|
58
|
-
# Copilot CLI (sets COPILOT_CLI=1) or unknown platform — SDK standard format
|
|
59
|
-
printf '{\n "additionalContext": "%s"\n}\n' "$session_context" | cat
|
|
60
|
-
fi
|
|
61
|
-
|
|
62
|
-
exit 0
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# SpecPow Workflow State Hook
|
|
3
|
-
#
|
|
4
|
-
# 在用户提交提示时注入当前工作流状态
|
|
5
|
-
# 兼容 Claude Code、Cursor、Copilot CLI 等平台
|
|
6
|
-
|
|
7
|
-
set -euo pipefail
|
|
8
|
-
|
|
9
|
-
# Determine plugin root directory
|
|
10
|
-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
11
|
-
PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
12
|
-
PROJECT_ROOT="$(cd "${PLUGIN_ROOT}/.." 2>/dev/null && pwd || echo "${PLUGIN_ROOT}")"
|
|
13
|
-
|
|
14
|
-
# Escape string for JSON embedding
|
|
15
|
-
escape_for_json() {
|
|
16
|
-
local s="$1"
|
|
17
|
-
s="${s//\\/\\\\}"
|
|
18
|
-
s="${s//\"/\\\"}"
|
|
19
|
-
s="${s//$'\n'/\\n}"
|
|
20
|
-
s="${s//$'\r'/\\r}"
|
|
21
|
-
s="${s//$'\t'/\\t}"
|
|
22
|
-
printf '%s' "$s"
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
# Detect active change
|
|
26
|
-
detect_active_change() {
|
|
27
|
-
local changes_dir="${PROJECT_ROOT}/openspec/changes"
|
|
28
|
-
if [ ! -d "$changes_dir" ]; then
|
|
29
|
-
echo ""
|
|
30
|
-
return
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
# Find first active change (excluding archive)
|
|
34
|
-
local change_name=""
|
|
35
|
-
for dir in "$changes_dir"/*/; do
|
|
36
|
-
local basename=$(basename "$dir")
|
|
37
|
-
if [ "$basename" != "archive" ] && [ -d "$dir" ]; then
|
|
38
|
-
change_name="$basename"
|
|
39
|
-
break
|
|
40
|
-
fi
|
|
41
|
-
done
|
|
42
|
-
|
|
43
|
-
if [ -z "$change_name" ]; then
|
|
44
|
-
echo ""
|
|
45
|
-
return
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
echo "$change_name"
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
# Infer workflow stage from change directory contents
|
|
52
|
-
infer_stage() {
|
|
53
|
-
local change_name="$1"
|
|
54
|
-
local change_dir="${PROJECT_ROOT}/openspec/changes/${change_name}"
|
|
55
|
-
|
|
56
|
-
if [ ! -d "$change_dir" ]; then
|
|
57
|
-
echo "idle"
|
|
58
|
-
return
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
|
-
# Check for verify/review files
|
|
62
|
-
if ls "$change_dir"/*verify* 2>/dev/null | head -1 > /dev/null || \
|
|
63
|
-
ls "$change_dir"/*review* 2>/dev/null | head -1 > /dev/null; then
|
|
64
|
-
echo "verify"
|
|
65
|
-
return
|
|
66
|
-
fi
|
|
67
|
-
|
|
68
|
-
# Check for tasks files
|
|
69
|
-
if ls "$change_dir"/*tasks* 2>/dev/null | head -1 > /dev/null; then
|
|
70
|
-
echo "apply"
|
|
71
|
-
return
|
|
72
|
-
fi
|
|
73
|
-
|
|
74
|
-
# Check for spec/design files
|
|
75
|
-
if ls "$change_dir"/*spec* 2>/dev/null | head -1 > /dev/null || \
|
|
76
|
-
ls "$change_dir"/*design* 2>/dev/null | head -1 > /dev/null; then
|
|
77
|
-
echo "propose"
|
|
78
|
-
return
|
|
79
|
-
fi
|
|
80
|
-
|
|
81
|
-
echo "explore"
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
# Main logic
|
|
85
|
-
change_name=$(detect_active_change)
|
|
86
|
-
|
|
87
|
-
if [ -z "$change_name" ]; then
|
|
88
|
-
# No active change, no context to inject
|
|
89
|
-
exit 0
|
|
90
|
-
fi
|
|
91
|
-
|
|
92
|
-
stage=$(infer_stage "$change_name")
|
|
93
|
-
|
|
94
|
-
# Build workflow context
|
|
95
|
-
workflow_context="<!-- workflow-state: ${stage} -->\n<!-- active-change: ${change_name} -->"
|
|
96
|
-
|
|
97
|
-
# Add stage hint
|
|
98
|
-
case "$stage" in
|
|
99
|
-
explore)
|
|
100
|
-
workflow_context="${workflow_context}\n🔍 当前阶段: EXPLORE — 使用 planning-explore 技能理解需求"
|
|
101
|
-
;;
|
|
102
|
-
propose)
|
|
103
|
-
workflow_context="${workflow_context}\n📝 当前阶段: PROPOSE — 使用 planning-propose 创建变更提案"
|
|
104
|
-
;;
|
|
105
|
-
apply)
|
|
106
|
-
workflow_context="${workflow_context}\n⚙️ 当前阶段: APPLY — 使用 planning-apply-change 执行实现"
|
|
107
|
-
;;
|
|
108
|
-
verify)
|
|
109
|
-
workflow_context="${workflow_context}\n✅ 当前阶段: VERIFY — 使用 planning-verify-change 验证规范"
|
|
110
|
-
;;
|
|
111
|
-
archive)
|
|
112
|
-
workflow_context="${workflow_context}\n📦 当前阶段: ARCHIVE — 运行 specpow archive 合并到主规范"
|
|
113
|
-
;;
|
|
114
|
-
esac
|
|
115
|
-
|
|
116
|
-
# Check progress
|
|
117
|
-
change_dir="${PROJECT_ROOT}/openspec/changes/${change_name}"
|
|
118
|
-
progress=""
|
|
119
|
-
if ls "$change_dir"/*proposal* 2>/dev/null | head -1 > /dev/null; then
|
|
120
|
-
progress="${progress}✓ proposal"
|
|
121
|
-
fi
|
|
122
|
-
if ls "$change_dir"/*spec* 2>/dev/null | head -1 > /dev/null; then
|
|
123
|
-
[ -n "$progress" ] && progress="${progress}, "
|
|
124
|
-
progress="${progress}✓ specs"
|
|
125
|
-
fi
|
|
126
|
-
if ls "$change_dir"/*tasks* 2>/dev/null | head -1 > /dev/null; then
|
|
127
|
-
[ -n "$progress" ] && progress="${progress}, "
|
|
128
|
-
progress="${progress}✓ tasks"
|
|
129
|
-
fi
|
|
130
|
-
|
|
131
|
-
if [ -n "$progress" ]; then
|
|
132
|
-
workflow_context="${workflow_context}\n进度: ${progress}"
|
|
133
|
-
fi
|
|
134
|
-
|
|
135
|
-
# Escape for JSON
|
|
136
|
-
workflow_context_escaped=$(escape_for_json "$workflow_context")
|
|
137
|
-
|
|
138
|
-
# Output based on platform
|
|
139
|
-
if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
|
|
140
|
-
# Cursor format
|
|
141
|
-
printf '{\n "additional_context": "%s"\n}\n' "$workflow_context_escaped" | cat
|
|
142
|
-
elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -z "${COPILOT_CLI:-}" ]; then
|
|
143
|
-
# Claude Code format
|
|
144
|
-
printf '{\n "hookSpecificOutput": {\n "hookEventName": "UserPromptSubmit",\n "additionalContext": "%s"\n }\n}\n' "$workflow_context_escaped" | cat
|
|
145
|
-
else
|
|
146
|
-
# Copilot CLI or unknown platform
|
|
147
|
-
printf '{\n "additionalContext": "%s"\n}\n' "$workflow_context_escaped" | cat
|
|
148
|
-
fi
|
|
149
|
-
|
|
150
|
-
exit 0
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Bug 修复 Schema
|
|
2
|
-
# 用于快速定位和修复 Bug 的工件流
|
|
3
|
-
|
|
4
|
-
name: bug-fix
|
|
5
|
-
description: 系统化定位和修复 Bug
|
|
6
|
-
|
|
7
|
-
apply:
|
|
8
|
-
requires:
|
|
9
|
-
- tasks
|
|
10
|
-
|
|
11
|
-
artifacts:
|
|
12
|
-
- id: proposal
|
|
13
|
-
name: Bug 描述
|
|
14
|
-
description: 描述 Bug 现象和复现步骤
|
|
15
|
-
requires: []
|
|
16
|
-
template: proposal.md
|
|
17
|
-
instruction: |
|
|
18
|
-
记录 Bug 信息:
|
|
19
|
-
- Bug 标题
|
|
20
|
-
- 复现步骤(Step 1, 2, 3...)
|
|
21
|
-
- 预期行为
|
|
22
|
-
- 实际行为
|
|
23
|
-
- 环境信息
|
|
24
|
-
- 影响范围
|
|
25
|
-
output: proposal.md
|
|
26
|
-
|
|
27
|
-
- id: analysis
|
|
28
|
-
name: 根因分析
|
|
29
|
-
description: 分析 Bug 根因
|
|
30
|
-
requires: [proposal]
|
|
31
|
-
template: analysis.md
|
|
32
|
-
instruction: |
|
|
33
|
-
根因分析(4 阶段):
|
|
34
|
-
1. 调查 — 收集日志、堆栈、复现
|
|
35
|
-
2. 模式分析 — 识别错误模式
|
|
36
|
-
3. 假设 — 提出根因假设
|
|
37
|
-
4. 验证 — 验证假设正确性
|
|
38
|
-
output: analysis.md
|
|
39
|
-
|
|
40
|
-
- id: fix-plan
|
|
41
|
-
name: 修复计划
|
|
42
|
-
description: 制定修复方案
|
|
43
|
-
requires: [analysis]
|
|
44
|
-
template: fix-plan.md
|
|
45
|
-
instruction: |
|
|
46
|
-
修复方案:
|
|
47
|
-
- 修复策略(热修复/正常修复/重构修复)
|
|
48
|
-
- 修改文件列表
|
|
49
|
-
- 回归测试计划
|
|
50
|
-
output: fix-plan.md
|
|
51
|
-
|
|
52
|
-
- id: tasks
|
|
53
|
-
name: 修复任务
|
|
54
|
-
description: 修复步骤拆分
|
|
55
|
-
requires: [fix-plan]
|
|
56
|
-
template: tasks.md
|
|
57
|
-
instruction: |
|
|
58
|
-
修复任务拆分:
|
|
59
|
-
1. 编写失败测试(复现 Bug)
|
|
60
|
-
2. 修复代码
|
|
61
|
-
3. 验证测试通过
|
|
62
|
-
4. 回归测试
|
|
63
|
-
5. 更新文档
|
|
64
|
-
output: tasks.md
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# 根因分析
|
|
2
|
-
|
|
3
|
-
## 1. 调查
|
|
4
|
-
|
|
5
|
-
### 错误日志
|
|
6
|
-
```
|
|
7
|
-
(关键错误日志)
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
### 堆栈跟踪
|
|
11
|
-
```
|
|
12
|
-
(关键堆栈)
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### 复现结果
|
|
16
|
-
- 是否可稳定复现: 是/否
|
|
17
|
-
- 复现频率:
|
|
18
|
-
|
|
19
|
-
## 2. 模式分析
|
|
20
|
-
|
|
21
|
-
### 错误模式
|
|
22
|
-
- 错误类型:
|
|
23
|
-
- 涉及模块:
|
|
24
|
-
- 最近变更:
|
|
25
|
-
|
|
26
|
-
## 3. 假设
|
|
27
|
-
|
|
28
|
-
### 假设 1: [描述]
|
|
29
|
-
- 证据:
|
|
30
|
-
- 验证方法:
|
|
31
|
-
|
|
32
|
-
### 假设 2: [描述]
|
|
33
|
-
- 证据:
|
|
34
|
-
- 验证方法:
|
|
35
|
-
|
|
36
|
-
## 4. 结论
|
|
37
|
-
|
|
38
|
-
### 根因
|
|
39
|
-
[确认的根因描述]
|
|
40
|
-
|
|
41
|
-
### 影响分析
|
|
42
|
-
- 直接影响:
|
|
43
|
-
- 间接影响:
|