universal-dev-standards 5.15.1 → 5.17.0
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/bundled/ai/standards/acceptance-criteria-traceability.ai.yaml +31 -0
- package/bundled/ai/standards/forward-derivation-standards.ai.yaml +23 -0
- package/bundled/ai/standards/knowledge-graph-memory.ai.yaml +1 -1
- package/bundled/core/acceptance-criteria-traceability.md +46 -0
- package/bundled/core/forward-derivation-standards.md +19 -0
- package/bundled/core/knowledge-graph-memory.md +2 -2
- package/bundled/core/spec-driven-development.md +21 -3
- package/bundled/locales/zh-CN/CHANGELOG.md +23 -3
- package/bundled/locales/zh-CN/README.md +1 -1
- package/bundled/locales/zh-CN/core/acceptance-criteria-traceability.md +46 -0
- package/bundled/locales/zh-CN/core/forward-derivation-standards.md +19 -0
- package/bundled/locales/zh-CN/core/spec-driven-development.md +16 -2
- package/bundled/locales/zh-CN/skills/ac-coverage/SKILL.md +194 -0
- package/bundled/locales/zh-CN/skills/adr-assistant/SKILL.md +135 -40
- package/bundled/locales/zh-CN/skills/brainstorm-assistant/SKILL.md +217 -63
- package/bundled/locales/zh-CN/skills/brainstorm-assistant/guide.md +599 -0
- package/bundled/locales/zh-CN/skills/commands/brainstorm.md +92 -25
- package/bundled/locales/zh-CN/skills/commit-standards/SKILL.md +78 -16
- package/bundled/locales/zh-CN/skills/contract-test-assistant/SKILL.md +85 -26
- package/bundled/locales/zh-CN/skills/deploy-assistant/SKILL.md +189 -0
- package/bundled/locales/zh-CN/skills/dev-methodology/SKILL.md +110 -0
- package/bundled/locales/zh-CN/skills/dev-methodology/guide.md +255 -0
- package/bundled/locales/zh-CN/skills/dev-workflow-guide/SKILL.md +70 -11
- package/bundled/locales/zh-CN/skills/journey-test-assistant/SKILL.md +209 -0
- package/bundled/locales/zh-CN/skills/knowledge-graph/SKILL.md +58 -0
- package/bundled/locales/zh-CN/skills/knowledge-graph/guide.md +74 -0
- package/bundled/locales/zh-CN/skills/migration-assistant/SKILL.md +125 -8
- package/bundled/locales/zh-CN/skills/observability-assistant/guide.md +188 -0
- package/bundled/locales/zh-CN/skills/orchestrate/SKILL.md +173 -0
- package/bundled/locales/zh-CN/skills/plan/SKILL.md +240 -0
- package/bundled/locales/zh-CN/skills/push/SKILL.md +242 -0
- package/bundled/locales/zh-CN/skills/retrospective-assistant/SKILL.md +104 -36
- package/bundled/locales/zh-CN/skills/reverse-engineer/SKILL.md +88 -32
- package/bundled/locales/zh-CN/skills/runbook-assistant/guide.md +216 -0
- package/bundled/locales/zh-CN/skills/skill-builder/SKILL.md +149 -0
- package/bundled/locales/zh-CN/skills/slo-assistant/guide.md +188 -0
- package/bundled/locales/zh-CN/skills/spec-derivation/SKILL.md +86 -0
- package/bundled/locales/zh-CN/skills/spec-derivation/guide.md +476 -0
- package/bundled/locales/zh-CN/skills/spec-driven-dev/SKILL.md +155 -81
- package/bundled/locales/zh-CN/skills/sweep/SKILL.md +151 -0
- package/bundled/locales/zh-CN/skills/testing-guide/SKILL.md +207 -110
- package/bundled/locales/zh-TW/CHANGELOG.md +23 -3
- package/bundled/locales/zh-TW/README.md +1 -1
- package/bundled/locales/zh-TW/core/acceptance-criteria-traceability.md +46 -0
- package/bundled/locales/zh-TW/core/browser-compatibility-standards.md +222 -5
- package/bundled/locales/zh-TW/core/contract-testing-standards.md +184 -5
- package/bundled/locales/zh-TW/core/cross-flow-regression.md +192 -5
- package/bundled/locales/zh-TW/core/forward-derivation-standards.md +19 -0
- package/bundled/locales/zh-TW/core/knowledge-graph-memory.md +2 -2
- package/bundled/locales/zh-TW/core/release-readiness-gate.md +186 -5
- package/bundled/locales/zh-TW/core/spec-driven-development.md +20 -2
- package/bundled/locales/zh-TW/skills/adr-assistant/SKILL.md +21 -42
- package/bundled/locales/zh-TW/skills/brainstorm-assistant/SKILL.md +212 -59
- package/bundled/locales/zh-TW/skills/brainstorm-assistant/guide.md +266 -579
- package/bundled/locales/zh-TW/skills/commands/brainstorm.md +91 -26
- package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +77 -15
- package/bundled/locales/zh-TW/skills/contract-test-assistant/SKILL.md +75 -16
- package/bundled/locales/zh-TW/skills/dev-methodology/guide.md +255 -0
- package/bundled/locales/zh-TW/skills/dev-workflow-guide/SKILL.md +125 -64
- package/bundled/locales/zh-TW/skills/knowledge-graph/SKILL.md +5 -5
- package/bundled/locales/zh-TW/skills/knowledge-graph/guide.md +74 -0
- package/bundled/locales/zh-TW/skills/migration-assistant/SKILL.md +128 -11
- package/bundled/locales/zh-TW/skills/observability-assistant/guide.md +188 -0
- package/bundled/locales/zh-TW/skills/orchestrate/SKILL.md +3 -2
- package/bundled/locales/zh-TW/skills/plan/SKILL.md +3 -2
- package/bundled/locales/zh-TW/skills/push/SKILL.md +3 -2
- package/bundled/locales/zh-TW/skills/retrospective-assistant/SKILL.md +94 -28
- package/bundled/locales/zh-TW/skills/reverse-engineer/SKILL.md +84 -28
- package/bundled/locales/zh-TW/skills/runbook-assistant/guide.md +216 -0
- package/bundled/locales/zh-TW/skills/slo-assistant/guide.md +188 -0
- package/bundled/locales/zh-TW/skills/spec-derivation/guide.md +476 -0
- package/bundled/locales/zh-TW/skills/spec-driven-dev/SKILL.md +148 -77
- package/bundled/locales/zh-TW/skills/testing-guide/SKILL.md +141 -44
- package/bundled/skills/brainstorm-assistant/SKILL.md +142 -106
- package/bundled/skills/brainstorm-assistant/guide.md +256 -661
- package/bundled/skills/commands/brainstorm.md +51 -30
- package/bundled/skills/knowledge-graph/SKILL.md +5 -5
- package/bundled/skills/knowledge-graph/guide.md +4 -4
- package/bundled/skills/spec-driven-dev/SKILL.md +27 -0
- package/package.json +2 -2
- package/src/commands/check.js +11 -2
- package/src/lint/i18n.js +109 -23
- package/standards-registry.json +4 -4
- package/bundled/locales/zh-TW/docs/SKILL-FALLBACK-GUIDE.md +0 -407
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: journey-test-assistant
|
|
3
|
+
source: ../../../../skills/journey-test-assistant/SKILL.md
|
|
4
|
+
source_version: 1.0.0
|
|
5
|
+
translation_version: 1.0.0
|
|
6
|
+
last_synced: 2026-06-02
|
|
7
|
+
source_hash: 439f49327b75
|
|
8
|
+
status: current
|
|
9
|
+
scope: partial
|
|
10
|
+
description: |
|
|
11
|
+
[UDS] 从项目描述生成连贯的用户旅程测试计划(TESTPLAN)与 E2E 骨架。
|
|
12
|
+
allowed-tools: Read, Write, Grep, Glob
|
|
13
|
+
argument-hint: "[项目描述 | --analyze | --archetype A1|A2|A3]"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Journey Test Assistant | 旅程测试助手
|
|
17
|
+
|
|
18
|
+
从项目描述生成连贯的用户旅程测试计划(TESTPLAN-NNN.md)与对应的 E2E 骨架,让每个新项目从第一天起就拥有完整的测试旅程。
|
|
19
|
+
|
|
20
|
+
## 与 /e2e 的区别
|
|
21
|
+
|
|
22
|
+
| 维度 | /e2e | /journey-test |
|
|
23
|
+
|------|------|--------------|
|
|
24
|
+
| 组织单位 | 单一 XSPEC/AC | 跨 Story 的用户旅程 |
|
|
25
|
+
| 测试结构 | 隔离、独立 | 连贯、状态共享 |
|
|
26
|
+
| 产物 | `*.spec.ts` 骨架 | `TESTPLAN.md` + `*.journey.spec.ts` |
|
|
27
|
+
| 触发时机 | 功能完成后 | 项目创建时(Journey-First) |
|
|
28
|
+
| 检测目标 | 单一 AC 是否正确 | 跨步骤状态传递是否连贯 |
|
|
29
|
+
|
|
30
|
+
## 工作流程
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
输入:项目描述 / 现有 TESTPLAN / --analyze
|
|
34
|
+
↓
|
|
35
|
+
Phase 1:定义 Persona
|
|
36
|
+
分析项目描述 → 识别所有用户角色 → 定义 Actor/Role/Key Permissions
|
|
37
|
+
↓
|
|
38
|
+
Phase 2:设计旅程地图
|
|
39
|
+
列出主要业务目标 → 拆解为 T-NNN 分组 → 声明依赖链
|
|
40
|
+
↓
|
|
41
|
+
Phase 3:生成 TESTPLAN
|
|
42
|
+
按格式输出 test-plans/TESTPLAN-001.md(含 Personas、步骤、依赖图)
|
|
43
|
+
↓
|
|
44
|
+
Phase 4:生成 E2E 骨架
|
|
45
|
+
从 TESTPLAN T-NNN 生成 *.journey.spec.ts(含 skipIf + 共享 state)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 模式
|
|
49
|
+
|
|
50
|
+
### 1. 生成模式(默认)
|
|
51
|
+
|
|
52
|
+
从项目描述生成完整的 TESTPLAN + E2E 骨架。
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
/journey-test "电商平台,需要 buyer/seller/admin 三个角色"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
产物:
|
|
59
|
+
- `test-plans/TESTPLAN-001.md`:含 Personas、T-000 环境重置、T-001~T-NNN 步骤分组、执行顺序依赖图
|
|
60
|
+
- `src/e2e/journey/main-flow.journey.spec.ts`:含 `describe.skipIf` + 共享 state + T-NNN 对应的完整骨架
|
|
61
|
+
|
|
62
|
+
### 2. 分析模式(--analyze)
|
|
63
|
+
|
|
64
|
+
扫描现有测试,找出旅程覆盖缺口。
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
/journey-test --analyze
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
执行步骤:
|
|
71
|
+
1. 读取 `test-plans/TESTPLAN-NNN.md`(若存在)
|
|
72
|
+
2. 扫描 `src/e2e/` 下所有 `*.journey.spec.ts` 和 `*.journey.e2e.test.ts`
|
|
73
|
+
3. 比对 TESTPLAN T-NNN 与自动化测试中的 T-NNN 引用
|
|
74
|
+
4. 输出 Coverage gap 报告:列出 TESTPLAN 中缺乏自动化对应的 T-NNN 步骤
|
|
75
|
+
|
|
76
|
+
### 3. Archetype 模式(--archetype)
|
|
77
|
+
|
|
78
|
+
使用预设旅程模板,适合已知类型的项目快速启动。
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
/journey-test --archetype A1 # Spec-driven 旅程
|
|
82
|
+
/journey-test --archetype A2 # UI-driven 旅程
|
|
83
|
+
/journey-test --archetype A3 # Brownfield 旅程
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| Archetype | 模板 | 适用场景 |
|
|
87
|
+
|-----------|------|---------|
|
|
88
|
+
| A1 | Spec-driven | 需求 → Spec → Code → Test,适合 API/Backend 项目 |
|
|
89
|
+
| A2 | UI-driven | 设计稿 → UI → 视觉回归,适合前端/全栈项目 |
|
|
90
|
+
| A3 | Brownfield | 现有代码 → 分析 → 重构验证,适合既有项目补测试 |
|
|
91
|
+
|
|
92
|
+
## TESTPLAN 格式(T-NNN)
|
|
93
|
+
|
|
94
|
+
以下为完整的 TESTPLAN 模板,展示所有必要区段:
|
|
95
|
+
|
|
96
|
+
```markdown
|
|
97
|
+
# TESTPLAN-001 <ProjectName> 主线旅程
|
|
98
|
+
|
|
99
|
+
## Personas
|
|
100
|
+
|
|
101
|
+
| Actor | Role | Key Permissions |
|
|
102
|
+
|---------------|---------------|------------------------------|
|
|
103
|
+
| platform_admin | Platform Admin | 创建 Org、管理用户、查看所有资源 |
|
|
104
|
+
| org_member | Org Member | 读取项目、执行 Pipeline |
|
|
105
|
+
|
|
106
|
+
## Environment
|
|
107
|
+
|
|
108
|
+
- BASE_URL:`http://localhost:3000`(本机)/ `$JOURNEY_BASE_URL`(CI)
|
|
109
|
+
- 验证命令:`curl $BASE_URL/health`
|
|
110
|
+
- 必要账号:`ADMIN_EMAIL`、`ADMIN_PASSWORD` 环境变量
|
|
111
|
+
|
|
112
|
+
## T-000 环境重置(optional)
|
|
113
|
+
|
|
114
|
+
前置条件:无
|
|
115
|
+
depends_on:无
|
|
116
|
+
|
|
117
|
+
| 步骤 | 操作 | 预期结果 |
|
|
118
|
+
|---------|-----------------------------------|-----------------|
|
|
119
|
+
| T-000-1 | [API] GET /health | 返回 200 OK |
|
|
120
|
+
| T-000-2 | [CHECK] 数据库连接正常 | 无错误日志 |
|
|
121
|
+
|
|
122
|
+
## T-001 Platform Admin 登录
|
|
123
|
+
|
|
124
|
+
前置条件:环境正常运行(T-000 通过)
|
|
125
|
+
depends_on:T-000
|
|
126
|
+
|
|
127
|
+
| 步骤 | 操作 | 预期结果 |
|
|
128
|
+
|---------|---------------------------------------------|--------------------------|
|
|
129
|
+
| T-001-1 | [API] POST /api/auth/login(admin 账号) | 返回 200 + authToken |
|
|
130
|
+
| T-001-2 | [CHECK] authToken 存入共享 state | let authToken 有值 |
|
|
131
|
+
|
|
132
|
+
## T-010 主要功能操作
|
|
133
|
+
|
|
134
|
+
前置条件:authToken 已取得(T-001 通过)
|
|
135
|
+
depends_on:T-001
|
|
136
|
+
|
|
137
|
+
| 步骤 | 操作 | 预期结果 |
|
|
138
|
+
|---------|---------------------------------------------|--------------------------|
|
|
139
|
+
| T-010-1 | [API] POST /api/resources(带 authToken) | 返回 201 + resourceId ★ |
|
|
140
|
+
| T-010-2 | [CHECK] resourceId 存入共享 state | let resourceId 有值 |
|
|
141
|
+
|
|
142
|
+
## 执行顺序依赖图
|
|
143
|
+
|
|
144
|
+
T-000 → T-001 → T-010
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## E2E 骨架格式(.journey.spec.ts)
|
|
148
|
+
|
|
149
|
+
生成的骨架展示三个核心模式:`describe.skipIf` 环境保护、共享 `let` 状态、T-NNN 标识符对应。
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { describe, it, expect } from "vitest"
|
|
153
|
+
|
|
154
|
+
// Journey E2E:需要真实后端,不设置 JOURNEY_BASE_URL 则全部 skip
|
|
155
|
+
const BASE_URL = process.env.JOURNEY_BASE_URL || ""
|
|
156
|
+
|
|
157
|
+
describe.skipIf(!BASE_URL)("Platform Admin Journey — T-001 → T-010", () => {
|
|
158
|
+
// 共享 state:每个步骤从前一步骤的结果取值
|
|
159
|
+
let authToken: string
|
|
160
|
+
let resourceId: string
|
|
161
|
+
|
|
162
|
+
it("T-001: Platform Admin 登录并取得 authToken", async () => {
|
|
163
|
+
const res = await fetch(`${BASE_URL}/api/auth/login`, {
|
|
164
|
+
method: "POST",
|
|
165
|
+
headers: { "Content-Type": "application/json" },
|
|
166
|
+
body: JSON.stringify({
|
|
167
|
+
email: process.env.ADMIN_EMAIL,
|
|
168
|
+
password: process.env.ADMIN_PASSWORD,
|
|
169
|
+
}),
|
|
170
|
+
})
|
|
171
|
+
expect(res.status, "T-001 failed: login should return 200").toBe(200)
|
|
172
|
+
const data = await res.json()
|
|
173
|
+
expect(data.token, "T-001 failed: token should be present").toBeTruthy()
|
|
174
|
+
authToken = data.token // ← 传递给后续步骤
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it("T-010: 执行主要操作(depends on T-001)", async () => {
|
|
178
|
+
// 如果 T-001 失败,authToken 为 undefined,此步骤的错误信息会清楚说明
|
|
179
|
+
expect(authToken, "T-010 precondition failed: authToken from T-001 is missing").toBeTruthy()
|
|
180
|
+
|
|
181
|
+
const res = await fetch(`${BASE_URL}/api/resources`, {
|
|
182
|
+
method: "POST",
|
|
183
|
+
headers: {
|
|
184
|
+
"Content-Type": "application/json",
|
|
185
|
+
Authorization: `Bearer ${authToken}`,
|
|
186
|
+
},
|
|
187
|
+
body: JSON.stringify({ name: "journey-test-resource" }),
|
|
188
|
+
})
|
|
189
|
+
expect(res.status, `T-010 failed: expected 201, got ${res.status}`).toBe(201)
|
|
190
|
+
const data = await res.json()
|
|
191
|
+
resourceId = data.id // ← 传递给后续步骤
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## 后续步骤
|
|
197
|
+
|
|
198
|
+
完成后建议:
|
|
199
|
+
|
|
200
|
+
> **TESTPLAN 与 Journey E2E 骨架已生成。建议下一步:**
|
|
201
|
+
> - 执行 `/e2e` 生成各功能的 AC 层测试(补充旅程测试的细节覆盖)
|
|
202
|
+
> - 执行 `/atdd` 定义各 T-NNN 步骤对应的验收条件
|
|
203
|
+
> - 执行 `/journey-test --analyze` 定期检查自动化覆盖缺口
|
|
204
|
+
|
|
205
|
+
## 参考
|
|
206
|
+
|
|
207
|
+
- 标准:[user-journey-testing.ai.yaml](../../.standards/user-journey-testing.ai.yaml)
|
|
208
|
+
- 相关 XSPEC:XSPEC-128(UDS 标准定义)
|
|
209
|
+
- 相关 Skill:`/e2e`(AC 层测试)、`/atdd`(验收条件定义)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: knowledge-graph
|
|
3
|
+
source: ../../../../skills/knowledge-graph/SKILL.md
|
|
4
|
+
source_version: 1.0.0
|
|
5
|
+
translation_version: 1.0.0
|
|
6
|
+
last_synced: 2026-06-02
|
|
7
|
+
source_hash: 68a0b2a9e02f
|
|
8
|
+
status: current
|
|
9
|
+
description: |
|
|
10
|
+
[UDS] 通过知识图追踪规格/决策/代码的影响链(引擎或 Markdown 后备)
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# 知识图
|
|
14
|
+
|
|
15
|
+
> **语言**: [English](../../../../skills/knowledge-graph/SKILL.md) | 简体中文
|
|
16
|
+
|
|
17
|
+
依据[知识图记忆标准](../../../../core/knowledge-graph-memory.md)的关系 schema,回答横跨规格、决策与代码的结构性问题——*「XSPEC-205 的完整影响链是什么?」*。有无图引擎皆可运作。
|
|
18
|
+
|
|
19
|
+
> **Implements**: XSPEC-237 Phase 5 — knowledge-graph skill(EngramGraph opt-in)
|
|
20
|
+
|
|
21
|
+
## 模式选择
|
|
22
|
+
|
|
23
|
+
回答**前**先判断使用哪种模式:
|
|
24
|
+
|
|
25
|
+
| 条件 | 模式 |
|
|
26
|
+
|------|------|
|
|
27
|
+
| 设定了 `ENGRAM_URL`,或本机图引擎 `/health` 有响应 | 服务模式(引擎)|
|
|
28
|
+
| 否则 | 降级模式(Markdown)|
|
|
29
|
+
|
|
30
|
+
## 工作流程
|
|
31
|
+
|
|
32
|
+
1. **解析目标**——将参数规范化为标准 id(`XSPEC-205`、`DEC-062`、函数名)。
|
|
33
|
+
2. **选择模式**——探测图引擎(服务)否则后备(降级)。
|
|
34
|
+
3. **服务模式(AC-5b)**——发出单一多跳查询,呈现返回的链(含跨域链接 code → spec → decision):
|
|
35
|
+
```bash
|
|
36
|
+
curl -s -X POST "$ENGRAM_URL/graph/impact-analysis" \
|
|
37
|
+
-H 'content-type: application/json' \
|
|
38
|
+
-d '{"nodeId":"XSPEC-205","maxHops":3}'
|
|
39
|
+
```
|
|
40
|
+
4. **降级模式(AC-5a)**——无引擎时,读取目标文件,沿其 `impacts`/`impacted_by`/`supersedes`/`related` front-matter 与正文 `[[ref]]` 链接读取被链接文件,手动组出链(受读取深度限制)。
|
|
41
|
+
5. **呈现链**——列出相连的 Spec 与 Decision、每跳的边类型、以及(若有)各节点的 `confidence`,高者在前。
|
|
42
|
+
6. **说明使用的模式**——务必告知答案来自引擎或 Markdown 后备,以明确完整度。
|
|
43
|
+
|
|
44
|
+
## 关系 schema
|
|
45
|
+
|
|
46
|
+
见[知识图记忆标准](../../../../core/knowledge-graph-memory.md)。front-matter 字段:`related`、`impacts`、`impacted_by`、`supersedes`、`implements`。边推导:Decision `impacts` Spec → IMPACTS;Decision `supersedes` Decision → SUPERSEDES。
|
|
47
|
+
|
|
48
|
+
## 下一步引导
|
|
49
|
+
|
|
50
|
+
- 降级模式若触及读取深度上限,告知用户图引擎(如 EngramGraph)可给出完整链,以及如何设定 `ENGRAM_URL`。
|
|
51
|
+
- 若引用的 id 找不到,标示为待修的悬空引用。
|
|
52
|
+
- 主动提议为遍历过的文件补上缺漏的 `impacts`/`impacted_by` front-matter。
|
|
53
|
+
|
|
54
|
+
## 参考
|
|
55
|
+
|
|
56
|
+
- 标准:[core/knowledge-graph-memory.md](../../../../core/knowledge-graph-memory.md)
|
|
57
|
+
- 引擎(opt-in):[EngramGraph](https://github.com/AsiaOstrich/EngramGraph) — `engramgraph`
|
|
58
|
+
- 详细指南:[guide.md](guide.md)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../../skills/knowledge-graph/guide.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-02
|
|
6
|
+
source_hash: 9c86b5a2a71d
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Knowledge Graph — 详细指南
|
|
11
|
+
|
|
12
|
+
[SKILL.md](SKILL.md) 的配套说明。两种运行模式的范例以及引擎 API。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. 服务模式(graph 引擎)
|
|
17
|
+
|
|
18
|
+
当存在可访问的 EngramGraph 兼容引擎时,单次查询即可返回完整的影响链。
|
|
19
|
+
|
|
20
|
+
### 影响分析
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
curl -s -X POST "$ENGRAM_URL/graph/impact-analysis" \
|
|
24
|
+
-H 'content-type: application/json' \
|
|
25
|
+
-d '{"nodeId":"XSPEC-205","maxHops":3}'
|
|
26
|
+
# => { "nodeId": "XSPEC-205",
|
|
27
|
+
# "decisions": [ {"id":"DEC-062","title":"...","via":"direct"},
|
|
28
|
+
# {"id":"DEC-069","title":"...","via":"supersedes"} ] }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`via: "direct"` 表示该决策直接 IMPACTS(影响)此规格;`via: "supersedes"` 表示它通过 SUPERSEDES 链(≤ `maxHops`)触达此规格。
|
|
32
|
+
|
|
33
|
+
### 信心反馈(SAGE)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
curl -s -X POST "$ENGRAM_URL/graph/ingest" \
|
|
37
|
+
-H 'content-type: application/json' \
|
|
38
|
+
-d '{"type":"test_fail","functionId":"src/a.ts#execute"}'
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
降低该节点的信心值;后续读取时会优先呈现信心更高的节点。
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 2. 降级模式(仅 Markdown)
|
|
46
|
+
|
|
47
|
+
无需引擎。通过读取文件来重建影响链:
|
|
48
|
+
|
|
49
|
+
1. 读取目标文档(例如 `XSPEC-205`)。
|
|
50
|
+
2. 从其 front-matter(`impacts`、`impacted_by`、`supersedes`、`related`)以及行内 `[[ref]]` 链接中收集 id。
|
|
51
|
+
3. 对每个 id,读取对应文档并重复此过程,直到达到所需的跳数深度。
|
|
52
|
+
4. 按前缀对每个 id 分类(`XSPEC-*`/`SPEC-*` → 规格;`DEC-*`/`ADR-*` → 决策)并报告边(edges)。
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# find the documents
|
|
56
|
+
grep -rl "id: XSPEC-205" --include='*.md' .
|
|
57
|
+
# discover outbound references
|
|
58
|
+
grep -nE "(impacts|impacted_by|supersedes|related):|\[\[(XSPEC|DEC|ADR)-" path/to/XSPEC-205.md
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
降级模式始终是正确的,但受限于你读取的文件数量;跨域的代码链接(function → spec)通常只在服务模式下才可获得。
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 3. 等价性
|
|
66
|
+
|
|
67
|
+
两种模式产生**相同形状的答案**(一组带边类型、互相关联的规格/决策列表)。服务模式更快也更完整(它可以包含 code→spec→decision 的跳转);降级模式是通用的后备方案。务必告知用户答案来自哪种模式。
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 参考
|
|
72
|
+
|
|
73
|
+
- [core/knowledge-graph-memory.md](../../core/knowledge-graph-memory.md)
|
|
74
|
+
- [EngramGraph](https://github.com/AsiaOstrich/EngramGraph)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
source: ../../../../skills/migration-assistant/SKILL.md
|
|
3
3
|
source_version: 1.0.0
|
|
4
|
+
source_hash: 67b6f33f825e
|
|
4
5
|
translation_version: 1.0.0
|
|
5
|
-
last_synced: 2026-
|
|
6
|
+
last_synced: 2026-06-01
|
|
6
7
|
status: current
|
|
7
8
|
description: |
|
|
8
9
|
引导代码迁移、框架升级与技术现代化。
|
|
@@ -30,12 +31,12 @@ description: |
|
|
|
30
31
|
|
|
31
32
|
| 类型 | 范例 | 风险 |
|
|
32
33
|
|------|------|------|
|
|
33
|
-
| **框架升级** | React 17→18, Vue 2→3 | 中高 |
|
|
34
|
-
| **语言迁移** | JS→TS, Python 2→3 | 高 |
|
|
35
|
-
| **API 版本** | REST v1→v2, GraphQL 更新 | 中 |
|
|
36
|
-
| **数据库迁移** | MySQL→PostgreSQL | 极高 |
|
|
37
|
-
| **构建工具** | Webpack→Vite | 低中 |
|
|
38
|
-
| **包管理器** | npm→pnpm | 低 |
|
|
34
|
+
| **框架升级** | React 17→18, Vue 2→3, Angular 15→17 | 中高 |
|
|
35
|
+
| **语言迁移** | JS→TS, Python 2→3, Java 8→17 | 高 |
|
|
36
|
+
| **API 版本** | REST v1→v2, GraphQL schema 更新 | 中 |
|
|
37
|
+
| **数据库迁移** | MySQL→PostgreSQL, SQL→NoSQL | 极高 |
|
|
38
|
+
| **构建工具** | Webpack→Vite, Grunt→ESBuild | 低中 |
|
|
39
|
+
| **包管理器** | npm→pnpm, pip→poetry | 低 |
|
|
39
40
|
|
|
40
41
|
## 风险评估矩阵
|
|
41
42
|
|
|
@@ -54,6 +55,92 @@ description: |
|
|
|
54
55
|
5. **验证** - 执行完整测试套件、检查回归
|
|
55
56
|
6. **清理** - 移除兼容层、旧依赖
|
|
56
57
|
|
|
58
|
+
## API 迁移契约测试
|
|
59
|
+
|
|
60
|
+
当 API endpoint 从一个技术栈迁至另一个(PHP → .NET、Express → Spring、Python → Go),对**新**实现的单元测试只验证**新 DTO**——无法捕捉「旧版有但新版漏掉的字段」。字段缺漏、字段 rename、类型漂移,以及顶层 vs nested 层级漂移等问题会静默流入生产,导致仍预期旧版 shape 的既有前端失灵。
|
|
61
|
+
|
|
62
|
+
**仅靠单元测试、集成测试或 code review 无法防止**。2026-05-24 真实 PROD 事故:67/67 测试全绿流入正式环境,由客户发现缺漏。
|
|
63
|
+
|
|
64
|
+
### 强制规则
|
|
65
|
+
|
|
66
|
+
每个被迁移的 API endpoint **必须**至少有一份 contract test,比对新实现的 response 与从 legacy 实现捕获的 fixture。验证的是结构性等价(keys、type、层级位置),而非值等价。
|
|
67
|
+
|
|
68
|
+
### Fixture 捕获协议
|
|
69
|
+
|
|
70
|
+
**Legacy 仍运行(典型迁移窗口):**
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# 1. Capture ≥3 representative inputs (happy path, edge case, empty result)
|
|
74
|
+
curl -X POST $LEGACY_BASE/endpoint -d @input1.json \
|
|
75
|
+
> tests/fixtures/migration/endpoint/scenario1.json
|
|
76
|
+
curl -X POST $LEGACY_BASE/endpoint -d @input2_empty.json \
|
|
77
|
+
> tests/fixtures/migration/endpoint/scenario2_empty.json
|
|
78
|
+
curl -X POST $LEGACY_BASE/endpoint -d @input3_edge.json \
|
|
79
|
+
> tests/fixtures/migration/endpoint/scenario3_edge.json
|
|
80
|
+
|
|
81
|
+
# 2. Scrub PII and volatile values (timestamps, generated IDs)
|
|
82
|
+
jq 'walk(if type == "string" and test("@") then "redacted@example.com" else . end)' \
|
|
83
|
+
tests/fixtures/migration/endpoint/scenario1.json > tmp && mv tmp ...
|
|
84
|
+
|
|
85
|
+
# 3. Commit fixtures
|
|
86
|
+
git add tests/fixtures/migration/endpoint/
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Legacy 已退役但 source 可读:**
|
|
90
|
+
|
|
91
|
+
- 追踪 legacy source code,手动构建预期的 response shape
|
|
92
|
+
- 将每个字段的来源(SQL 列、计算式、hardcoded)记录于同位置的 `.notes.md` 文件
|
|
93
|
+
|
|
94
|
+
### Contract test 模板
|
|
95
|
+
|
|
96
|
+
**C# / xUnit:**
|
|
97
|
+
|
|
98
|
+
```csharp
|
|
99
|
+
[Theory]
|
|
100
|
+
[InlineData("scenario1")]
|
|
101
|
+
[InlineData("scenario2_empty")]
|
|
102
|
+
[InlineData("scenario3_edge")]
|
|
103
|
+
public async Task Endpoint_ResponseShape_MatchesLegacyFixture(string scenario)
|
|
104
|
+
{
|
|
105
|
+
var fixture = LoadFixture($"migration/endpoint/{scenario}");
|
|
106
|
+
var response = await CallNewImpl(fixture.Input);
|
|
107
|
+
// StructuralEquivalence checks keys + types + placement, ignores values
|
|
108
|
+
StructuralEquivalence.Assert(response, fixture.ExpectedShape);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**TypeScript / Jest:**
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { structuralEquivalence } from "./test-utils/structural-equivalence";
|
|
116
|
+
|
|
117
|
+
describe.each([
|
|
118
|
+
["scenario1"],
|
|
119
|
+
["scenario2_empty"],
|
|
120
|
+
["scenario3_edge"],
|
|
121
|
+
])("Endpoint response shape vs legacy fixture (%s)", (scenario) => {
|
|
122
|
+
test("matches", async () => {
|
|
123
|
+
const fixture = loadFixture(`migration/endpoint/${scenario}.json`);
|
|
124
|
+
const response = await callNewImpl(fixture.input);
|
|
125
|
+
structuralEquivalence(response, fixture.expectedShape);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`structuralEquivalence` / `StructuralEquivalence.Assert` 规则:每一层具备相同的 key 集合(不可缺漏、不可多出,除非明确 opt in)、每个 key 具相同的基本类型、相同的层级位置(顶层 vs nested)。值可以不同(timestamps、IDs);类型与结构不可不同。
|
|
131
|
+
|
|
132
|
+
### 逐字段迁移审计清单
|
|
133
|
+
|
|
134
|
+
合并任何被迁移的 endpoint 前:
|
|
135
|
+
|
|
136
|
+
- [ ] 所有 legacy response 字段皆 mapping 至新 DTO(无 silent drop)
|
|
137
|
+
- [ ] 尽量保留命名(避免将 `TotalX` rename 而丢失「per-member」语意)
|
|
138
|
+
- [ ] 保留顶层 vs nested 层级位置
|
|
139
|
+
- [ ] 已验证类型兼容性(string→int 转换为明确而非巧合)
|
|
140
|
+
- [ ] Error path return code 与 legacy 一致(`509` 而非 `506`;`404` 而非 `400`)
|
|
141
|
+
- [ ] Contract test fixture 已 commit 至 `tests/fixtures/migration/`
|
|
142
|
+
- [ ] Cross-link 至 [contract-test-assistant](../contract-test-assistant/SKILL.md) 做持续的消费端验证
|
|
143
|
+
|
|
57
144
|
## 回滚策略
|
|
58
145
|
|
|
59
146
|
| 方式 | 使用时机 |
|
|
@@ -63,15 +150,45 @@ description: |
|
|
|
63
150
|
| **双运行** | 关键系统、零停机 |
|
|
64
151
|
| **分支冻结** | 一次性完整迁移 |
|
|
65
152
|
|
|
153
|
+
## 使用范例
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
User: /migrate "Vue 2 to 3"
|
|
157
|
+
AI: Migration Assessment: Vue 2 → Vue 3
|
|
158
|
+
Breaking changes found: 12
|
|
159
|
+
- Options API → Composition API (47 components)
|
|
160
|
+
- Filters removed (8 usages)
|
|
161
|
+
- Event bus removed (3 usages)
|
|
162
|
+
Risk: Medium-High
|
|
163
|
+
Estimated effort: 2-3 weeks
|
|
164
|
+
Recommended: Staged migration with @vue/compat
|
|
165
|
+
```
|
|
166
|
+
|
|
66
167
|
## 下一步引导
|
|
67
168
|
|
|
68
169
|
`/migrate` 完成后,AI 助手应建议:
|
|
69
170
|
|
|
70
171
|
> **迁移分析完成。建议下一步:**
|
|
71
172
|
> - 执行 `/reverse` 深入理解现有代码
|
|
72
|
-
> - 执行 `/testing` 确保迁移后测试通过
|
|
173
|
+
> - 执行 `/testing` 确保迁移后测试通过 ⭐ **推荐**
|
|
73
174
|
> - 执行 `/commit` 提交迁移变更
|
|
74
175
|
|
|
75
176
|
## 参考
|
|
76
177
|
|
|
77
178
|
- 核心规范:[refactoring-standards.md](../../../../core/refactoring-standards.md)
|
|
179
|
+
- 相关:[contract-test-assistant](../contract-test-assistant/SKILL.md) — 迁移后持续契约验证的策略
|
|
180
|
+
|
|
181
|
+
## 版本历史
|
|
182
|
+
|
|
183
|
+
| 版本 | 日期 | 变更 |
|
|
184
|
+
|------|------|------|
|
|
185
|
+
| 1.1.0 | 2026-05-26 | 新增:API 迁移契约测试章节——强制 fixture 捕获协议、C#/TS 模板、逐字段审计清单(XSPEC-233 / closes #112) |
|
|
186
|
+
| 1.0.0 | 2026-03-24 | 初始版本 |
|
|
187
|
+
|
|
188
|
+
## AI 代理行为
|
|
189
|
+
|
|
190
|
+
> 完整的 AI 行为定义请参阅对应的命令文件:[`/migrate`](../commands/migrate.md#ai-agent-behavior--ai-代理行为)
|
|
191
|
+
|
|
192
|
+
## 授权
|
|
193
|
+
|
|
194
|
+
CC BY 4.0
|