@gordon.gan/specflow 1.4.4-beta → 1.5.0-beta
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 +2 -2
- package/dist/cli/commands/approval-assemble.d.ts +21 -0
- package/dist/cli/commands/approval-assemble.js +95 -0
- package/dist/cli/index.js +2 -0
- package/dist/core/approval/assemble.d.ts +10 -0
- package/dist/core/approval/assemble.js +391 -0
- package/dist/core/approval/index-schema.d.ts +473 -0
- package/dist/core/approval/index-schema.js +146 -0
- package/dist/core/approval/index.d.ts +4 -0
- package/dist/core/approval/index.js +3 -0
- package/dist/core/approval/paths.d.ts +8 -0
- package/dist/core/approval/paths.js +28 -0
- package/dist/core/approval/types.d.ts +120 -0
- package/dist/core/approval/types.js +1 -0
- package/package.json +1 -1
- package/prompts/approval/api-guidance.md +179 -0
- package/prompts/approval/generate.md +224 -153
- package/prompts/approval/multi-repo-guidance.md +202 -0
- package/prompts/approval/project-conventions-guidance.md +1 -1
- package/prompts/approval/segmented-generation.md +151 -0
- package/skills/GUIDANCE_PACKS.md +3 -1
- package/skills/specflow-approval/SKILL.md +132 -16
- package/templates/approval-index.yaml +72 -0
- package/templates/approval-part.md +15 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export type ApprovalGenerationMode = 'segmented' | 'monolithic';
|
|
2
|
+
export type ApprovalPartStatus = 'draft' | 'ok' | 'retry';
|
|
3
|
+
export interface ApprovalOptionalChapters {
|
|
4
|
+
readonly s5: boolean;
|
|
5
|
+
readonly s7: boolean;
|
|
6
|
+
readonly s8: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ApprovalBatching {
|
|
9
|
+
readonly tables_per_call: number;
|
|
10
|
+
readonly interfaces_per_call: number;
|
|
11
|
+
readonly pages_per_call: number;
|
|
12
|
+
readonly capabilities_per_call: number;
|
|
13
|
+
}
|
|
14
|
+
export type ApprovalRepoRole = 'platform' | 'web' | 'worker' | 'hub' | 'other';
|
|
15
|
+
export type ApprovalDocumentMode = 'unified' | 'per_repo';
|
|
16
|
+
export interface ApprovalMultiRepoEntry {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly label: string;
|
|
19
|
+
readonly role?: ApprovalRepoRole;
|
|
20
|
+
readonly change: string;
|
|
21
|
+
readonly root_hint?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ApprovalOutputRef {
|
|
24
|
+
readonly repo: string;
|
|
25
|
+
readonly change: string;
|
|
26
|
+
readonly path: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ApprovalMultiRepo {
|
|
29
|
+
readonly enabled: boolean;
|
|
30
|
+
readonly document_mode?: ApprovalDocumentMode;
|
|
31
|
+
readonly primary_repo?: string;
|
|
32
|
+
readonly repos: readonly ApprovalMultiRepoEntry[];
|
|
33
|
+
readonly outputs?: {
|
|
34
|
+
readonly unified?: ApprovalOutputRef;
|
|
35
|
+
readonly per_repo?: readonly ApprovalOutputRef[];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface ApprovalTableRef {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly action: string;
|
|
42
|
+
readonly part: string;
|
|
43
|
+
readonly repo?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ApprovalInterfaceRef {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly short: string;
|
|
48
|
+
readonly change: string;
|
|
49
|
+
readonly part: string;
|
|
50
|
+
readonly repo?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ApprovalPageRef {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly route: string;
|
|
55
|
+
readonly apis: readonly string[];
|
|
56
|
+
readonly part: string;
|
|
57
|
+
readonly repo?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ApprovalCapabilityRef {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly part: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ApprovalConventionsResolved {
|
|
64
|
+
readonly architecture?: readonly string[];
|
|
65
|
+
readonly database?: readonly string[];
|
|
66
|
+
readonly api?: readonly string[];
|
|
67
|
+
readonly frontend?: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
export interface ApprovalIndex {
|
|
70
|
+
readonly schema: 'specflow.approval.index/v1';
|
|
71
|
+
readonly change: string;
|
|
72
|
+
readonly generated_at: string;
|
|
73
|
+
readonly mode: ApprovalGenerationMode;
|
|
74
|
+
readonly ui_in_scope: boolean;
|
|
75
|
+
readonly db_in_scope: boolean;
|
|
76
|
+
readonly api_in_scope: boolean;
|
|
77
|
+
readonly optional: ApprovalOptionalChapters;
|
|
78
|
+
readonly parts_order: readonly string[];
|
|
79
|
+
readonly design_points: readonly string[];
|
|
80
|
+
readonly decisions: readonly string[];
|
|
81
|
+
readonly tables: readonly ApprovalTableRef[];
|
|
82
|
+
readonly interfaces: readonly ApprovalInterfaceRef[];
|
|
83
|
+
readonly pages: readonly ApprovalPageRef[];
|
|
84
|
+
readonly capabilities: readonly ApprovalCapabilityRef[];
|
|
85
|
+
readonly batching: ApprovalBatching;
|
|
86
|
+
readonly conventions: ApprovalConventionsResolved;
|
|
87
|
+
readonly multi_repo?: ApprovalMultiRepo;
|
|
88
|
+
readonly meta?: {
|
|
89
|
+
readonly language?: string;
|
|
90
|
+
readonly tech_stack?: string;
|
|
91
|
+
readonly project_mode?: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export interface ApprovalManifestPart {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly path: string;
|
|
97
|
+
readonly status: ApprovalPartStatus;
|
|
98
|
+
readonly sha256?: string;
|
|
99
|
+
readonly updated_at?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface ApprovalManifest {
|
|
102
|
+
readonly schema: 'specflow.approval.manifest/v1';
|
|
103
|
+
readonly change: string;
|
|
104
|
+
readonly parts: readonly ApprovalManifestPart[];
|
|
105
|
+
readonly assembled_at?: string;
|
|
106
|
+
readonly approval_sha256?: string;
|
|
107
|
+
}
|
|
108
|
+
export type ApprovalDiagnosticSeverity = 'error' | 'warning';
|
|
109
|
+
export interface ApprovalDiagnostic {
|
|
110
|
+
readonly code: string;
|
|
111
|
+
readonly severity: ApprovalDiagnosticSeverity;
|
|
112
|
+
readonly message: string;
|
|
113
|
+
readonly part?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface ApprovalAssembleResult {
|
|
116
|
+
readonly markdown?: string;
|
|
117
|
+
readonly outputPath?: string;
|
|
118
|
+
readonly diagnostics: readonly ApprovalDiagnostic[];
|
|
119
|
+
readonly ok: boolean;
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Approval · API / RPC / OpenAPI Guidance
|
|
2
|
+
|
|
3
|
+
> Used by `/specflow:approval` before drafting **§4.5 接口设计** (after
|
|
4
|
+
> `project-conventions-guidance.md` `topic=api`).
|
|
5
|
+
>
|
|
6
|
+
> **目的**:产出**可生成**的接口契约(非 narrative stub),并避免 **Worker 面 HTTP** 与 **平台内部 RPC**
|
|
7
|
+
> 混写导致某一侧被省略。
|
|
8
|
+
>
|
|
9
|
+
> **优先级**:项目约定 + 现网 proto/OpenAPI **>** 本路由 **>** LLM。
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 0. When to run
|
|
14
|
+
|
|
15
|
+
| 条件 | 必须执行 |
|
|
16
|
+
|------|----------|
|
|
17
|
+
| 本迭代有 **新增** HTTP 路径或 gRPC | 全文 §1–§4 |
|
|
18
|
+
| 本迭代 **修改/行为扩展** 对外或 Worker 契约 | §1 分层 + §2 锁名 + §3 变更 delta |
|
|
19
|
+
| 仅 **不变·本迭代消费** 既有 RPC/HTTP | §1 分层 + §4 完整骨架(字段/示例/错误);禁止一句带过 |
|
|
20
|
+
| 三仓/多仓合订 | §1 **每层每面一个 `In`**,禁止用「内部调用」合并条目 |
|
|
21
|
+
|
|
22
|
+
Announce after Read:
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
API guidance: layering=<n surfaces> | proto=<path|draft in §4.5> | worker_openapi=<path|must draft>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 1. 接口分层 — 禁止混层 (fixes B2)
|
|
31
|
+
|
|
32
|
+
一条业务链路上常有 **多个契约面**,每一面在 §4.5 清单中必须是 **独立 `In`**,各自完整展开:
|
|
33
|
+
|
|
34
|
+
| 层 | 典型调用方 → 被调方 | 协议形态 | 清单命名示例 | 常见错误 |
|
|
35
|
+
|----|---------------------|----------|--------------|----------|
|
|
36
|
+
| L1 控制台/北向 | Web → Gateway | HTTP `/api/v1/...` | I1 调试启动 | 把字段只写在 design,§4.5 无表 |
|
|
37
|
+
| L2 Worker 边车 HTTP | Worker → Gateway | HTTP `/internal/v1/...` + work 鉴权头 | I4 逐步上报 | **只写路径,无 OpenAPI schema** |
|
|
38
|
+
| L3 平台编排 RPC | Gateway/调度 → 本服务 logic | gRPC + `google.api.http` | I4 对应 RPC(与 L2 同编号或 I4a/I4b 成对) | 写「暂定 RPC,HTTP 冻结」—— **禁止** |
|
|
39
|
+
| L4 平台东向 RPC | 调度 → result/testcase/… | gRPC `client/<svc>/` | I6/I7 确保壳/写入逐步 | **用一句「内部调用 I7」代替 I4 的 RPC 详设** |
|
|
40
|
+
|
|
41
|
+
### 1.1 硬规则
|
|
42
|
+
|
|
43
|
+
1. **L2 与 L3 成对**:新增 Worker HTTP 路径时,**必须**同时写清:
|
|
44
|
+
- L2:HTTP method/path、必填头、request/response JSON 字段表、失败示例
|
|
45
|
+
- L3:冻结 RPC 全名、`message` 字段号、`option (google.api.http)`、Gateway 注册点
|
|
46
|
+
2. **L4 不得 stub**:列入清单的东向 RPC(即使 proto 已存在)仍须 **§4.5.2 完整骨架**;
|
|
47
|
+
可标注「与现网 proto 一致」但**必须**贴字段表 + 成功/失败示例 + 错误表。
|
|
48
|
+
3. **禁止**在 L2 小节写满 HTTP,再在 L4 用「经 client/result 调 I7」一行替代 I7 详设。
|
|
49
|
+
4. **调用关系图**须显式画出 L2→L3→L4,例如:
|
|
50
|
+
`Worker --L2 HTTP--> Gateway --L3 RPC--> Scheduler --L4 RPC--> Result`
|
|
51
|
+
|
|
52
|
+
### 1.2 三仓合订
|
|
53
|
+
|
|
54
|
+
| 仓 | 负责的层 | §4.5 须写 |
|
|
55
|
+
|----|----------|-----------|
|
|
56
|
+
| talos | L3/L4 + Gateway 注册 | proto 草案 + 注册文件/函数 |
|
|
57
|
+
| talos-worker | L2 | OpenAPI path + schema + 鉴权头示例 |
|
|
58
|
+
| talos-web | L1 | HTTP 消费 + TS 类型(§4.6 交叉引用 `In`) |
|
|
59
|
+
|
|
60
|
+
合订文档 **禁止**只写 talos 侧 L4 而 Worker OpenAPI 写「apply 时补」。
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 2. RPC / 服务名冻结 (fixes A1)
|
|
65
|
+
|
|
66
|
+
### 2.1 禁止用语 (硬)
|
|
67
|
+
|
|
68
|
+
下列写法 **一律禁止**出现在 §4.5 / §2 决策 / §4.8:
|
|
69
|
+
|
|
70
|
+
- `暂定` / `TBD` / `实现时命名` / `实现时与 OpenAPI 对齐`
|
|
71
|
+
- `如 SubmitXxx` / `例如 scheduler.SubmitXxx`
|
|
72
|
+
- `RPC 名以实现为准`
|
|
73
|
+
|
|
74
|
+
未锁名 → 视为 **BLOCKED**,不得标 READY;须 `[待 refine 澄清: RPC 名]` 或写入锁定名。
|
|
75
|
+
|
|
76
|
+
### 2.2 必须输出
|
|
77
|
+
|
|
78
|
+
| 项 | 格式 |
|
|
79
|
+
|----|------|
|
|
80
|
+
| 服务 | `package` 名,如 `scheduler` |
|
|
81
|
+
| RPC | **冻结**全名,如 `scheduler.SubmitStepResult`(无「如」) |
|
|
82
|
+
| HTTP | method + 完整 path(可含 `{job_id}`) |
|
|
83
|
+
| proto 文件 | 相对路径,如 `proto/scheduler/scheduler.proto` |
|
|
84
|
+
|
|
85
|
+
决策表新增行时使用 **Proposed → Accepted** 仅当 RPC 名已在 §4.5 冻结。
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 3. 可生成契约包 (fixes A2)
|
|
90
|
+
|
|
91
|
+
对 **新增** 或 **修改 HTTP 绑定** 的 RPC,§4.5 **必须**含 **「Proto / OpenAPI 契约包」** 块(可用 `**Proto 草案**` 加粗标签,非标题):
|
|
92
|
+
|
|
93
|
+
### 3.1 Proto 最小集
|
|
94
|
+
|
|
95
|
+
```protobuf
|
|
96
|
+
// 文件: proto/<svc>/<svc>.proto
|
|
97
|
+
rpc SubmitStepResult(SubmitStepResultReq) returns (SubmitStepResultResp) {
|
|
98
|
+
option (google.api.http) = {
|
|
99
|
+
post: "/internal/v1/tasks/{job_id}/step-results"
|
|
100
|
+
body: "*"
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
message SubmitStepResultReq {
|
|
104
|
+
int32 schema_version = 1;
|
|
105
|
+
string request_id = 2;
|
|
106
|
+
// … 每个字段必须有号与类型
|
|
107
|
+
}
|
|
108
|
+
message SubmitStepResultResp {
|
|
109
|
+
int32 schema_version = 1;
|
|
110
|
+
string request_id = 2;
|
|
111
|
+
bool accepted = 3;
|
|
112
|
+
bool replayed = 4;
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
要求:
|
|
117
|
+
|
|
118
|
+
- 每个字段 **字段号 + 类型 + json_name**(若与 snake 不同)
|
|
119
|
+
- `google.api.http` **完整** post/get/path/body
|
|
120
|
+
- enum/status **闭合**,禁止「等」;与现网 ingest 白名单对齐(例:逐步 ingest 仅四终态)
|
|
121
|
+
|
|
122
|
+
### 3.2 Gateway 注册 (硬)
|
|
123
|
+
|
|
124
|
+
必须写明 **其一**:
|
|
125
|
+
|
|
126
|
+
- 「与 `ReportProgress` / `SubmitResult` **同一**注册点:`<文件路径>` 函数 `<Name>`」
|
|
127
|
+
- 或「ProtoSets 清单 `<path>` 新增 `<proto>` 条目」
|
|
128
|
+
|
|
129
|
+
禁止只写「网关 ProtoSet 含新绑定」。
|
|
130
|
+
|
|
131
|
+
### 3.3 Worker OpenAPI 交叉引用
|
|
132
|
+
|
|
133
|
+
- 路径必须在 `talos-worker/contracts/v1/http.openapi.yaml`(或项目约定路径)**给出 schema 草案**
|
|
134
|
+
- 必填头须与现网 progress/result **同构列出**:
|
|
135
|
+
`Idempotency-Key`, `Authorization-date`, `Authorization: TALOS-WORK-1:...`, `Content-Type`, `Accept`
|
|
136
|
+
- HTTP 请求示例 **必须含上述头**,不得只有 JSON body
|
|
137
|
+
|
|
138
|
+
### 3.4 错误映射
|
|
139
|
+
|
|
140
|
+
| 条件 | gRPC `codes.*` | HTTP | 禁止 |
|
|
141
|
+
|------|----------------|------|------|
|
|
142
|
+
| 租约无效 | `FailedPrecondition` 或项目约定 **唯一**值 | **唯一** 403 或 409 | `403/409(与 progress 同类)` |
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 4. §4.5 逐接口最低深度 (含不变)
|
|
147
|
+
|
|
148
|
+
每个 `In` **必须**含 generate.md §4.5.2 全部加粗块;额外:
|
|
149
|
+
|
|
150
|
+
| 变更类型 | 额外要求 |
|
|
151
|
+
|----------|----------|
|
|
152
|
+
| 新增 L2+L3 | §3 契约包 + Gateway 注册 + Worker OpenAPI 指针 |
|
|
153
|
+
| 修改 | 字段号/changelog + 兼容缺省 |
|
|
154
|
+
| 不变·本迭代消费 | 从现网 proto/OpenAPI **摘录**字段表+示例;标注源路径;仍须失败示例 |
|
|
155
|
+
| 不变·协议不变 | 同上;禁止「详见 OpenAPI」无正文 |
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 5. 自检 (生成后必过)
|
|
160
|
+
|
|
161
|
+
- [ ] 清单中每个契约面有独立 `In`,无 L2/L4 混写 stub
|
|
162
|
+
- [ ] 无「暂定/如/实现时」RPC 措辞
|
|
163
|
+
- [ ] 新增 RPC 有 proto 字段号 + http option + 注册点
|
|
164
|
+
- [ ] Worker HTTP 示例含完整 work 鉴权头
|
|
165
|
+
- [ ] status/enum 闭合,与 ingest/现网校验一致
|
|
166
|
+
- [ ] 错误表无「或」「同类映射」模糊语
|
|
167
|
+
- [ ] L4 东向 RPC 非一句话 stub
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 6. 与 database / frontend guidance 对称
|
|
172
|
+
|
|
173
|
+
| 包 | 路由 | 章节 |
|
|
174
|
+
|----|------|------|
|
|
175
|
+
| database | `database-guidance.md` | §4.4 |
|
|
176
|
+
| frontend | `frontend-guidance.md` | §4.6 |
|
|
177
|
+
| **api** | **本文件** | **§4.5** |
|
|
178
|
+
|
|
179
|
+
`project-conventions-guidance.md` `topic=api` 解决「项目禁令与风格」;本文件解决「可生成契约与分层」。
|