@chenguangyao/devflow-kit 0.1.43
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/CHANGELOG.md +232 -0
- package/LICENSE +21 -0
- package/README.md +539 -0
- package/bin/devflow.js +9 -0
- package/docs/RFC-001-devflow-kit.md +617 -0
- package/docs/RFC-002-workflow-kernel.md +134 -0
- package/docs/enterprise-integration-supplement.md +274 -0
- package/docs/internal-gitlab-setup.md +426 -0
- package/docs/marketplace-skills.md +231 -0
- package/docs/migration-from-arb.md +232 -0
- package/docs/tooling-overview.md +774 -0
- package/docs/workflow-orchestration.md +695 -0
- package/docs/workflow-ui-prototype.html +271 -0
- package/package.json +52 -0
- package/schemas/config.schema.json +51 -0
- package/schemas/delta.schema.json +22 -0
- package/schemas/state.schema.json +130 -0
- package/schemas/status-surface.schema.json +197 -0
- package/schemas/workflow-confirmation-surface.schema.json +70 -0
- package/schemas/workflow-picker.schema.json +94 -0
- package/scripts/postinstall.js +101 -0
- package/scripts/render-workflow-ui-prototype.js +271 -0
- package/skills/apply/SKILL.md +313 -0
- package/skills/apply/references/discipline-checklist.md +145 -0
- package/skills/apply/references/subagent-implementer-prompt.md +113 -0
- package/skills/apply/references/subagent-orchestration.md +150 -0
- package/skills/apply/references/subagent-reviewer-prompt.md +180 -0
- package/skills/apply/references/tdd-loop.md +287 -0
- package/skills/apply/references/when-plan-is-wrong.md +279 -0
- package/skills/apply/references/worktree-swarm.md +292 -0
- package/skills/archive/SKILL.md +229 -0
- package/skills/archive/references/conflict-resolution.md +336 -0
- package/skills/archive/references/knowledge-deposit.md +381 -0
- package/skills/archive/references/spec-merge.md +365 -0
- package/skills/brainstorm/SKILL.md +123 -0
- package/skills/brainstorm/references/proposal-template.md +244 -0
- package/skills/brainstorm/references/question-catalog.md +168 -0
- package/skills/brainstorm/references/session-template.md +184 -0
- package/skills/ci-fix/SKILL.md +63 -0
- package/skills/ci-fix/references/loop.md +25 -0
- package/skills/code-review/SKILL.md +279 -0
- package/skills/code-review/references/escalation-playbook.md +192 -0
- package/skills/code-review/references/language-cheatsheets/go.md +175 -0
- package/skills/code-review/references/language-cheatsheets/java-spring-mybatis.md +246 -0
- package/skills/code-review/references/language-cheatsheets/python.md +170 -0
- package/skills/code-review/references/language-cheatsheets/vue.md +199 -0
- package/skills/code-review/references/output-template.md +275 -0
- package/skills/code-review/references/review-checklist.md +251 -0
- package/skills/complexity-grading/SKILL.md +259 -0
- package/skills/deliver/SKILL.md +271 -0
- package/skills/deliver/references/delivery-modes.md +299 -0
- package/skills/deliver/references/notify.md +359 -0
- package/skills/deliver/references/pr-description.md +319 -0
- package/skills/dependency-upgrade/SKILL.md +57 -0
- package/skills/dependency-upgrade/references/risk-matrix.md +38 -0
- package/skills/df-orchestrator/SKILL.md +407 -0
- package/skills/df-orchestrator/references/complexity-grading.md +177 -0
- package/skills/df-orchestrator/references/escalation-matrix.md +191 -0
- package/skills/df-orchestrator/references/routing-rules.md +290 -0
- package/skills/df-orchestrator/references/workflow-state-machine.md +208 -0
- package/skills/frontend-quality/SKILL.md +61 -0
- package/skills/frontend-quality/references/checklist.md +35 -0
- package/skills/handoff-resume/SKILL.md +59 -0
- package/skills/handoff-resume/references/handoff-template.md +54 -0
- package/skills/plan/SKILL.md +166 -0
- package/skills/plan/references/task-breakdown.md +207 -0
- package/skills/plan/references/task-sequencing.md +143 -0
- package/skills/plan/references/task-template.md +248 -0
- package/skills/requirement-analysis/SKILL.md +499 -0
- package/skills/requirement-analysis/references/acceptance-criteria.md +183 -0
- package/skills/requirement-analysis/references/code-recon.md +151 -0
- package/skills/requirement-analysis/references/edge-case-catalog.md +164 -0
- package/skills/requirement-analysis/references/requirement-template.md +339 -0
- package/skills/requirement-analysis/references/scope-negotiation.md +162 -0
- package/skills/security-hardening/SKILL.md +60 -0
- package/skills/security-hardening/references/checklist.md +42 -0
- package/skills/tech-spec/SKILL.md +388 -0
- package/skills/tech-spec/references/api-contract-design.md +172 -0
- package/skills/tech-spec/references/decision-records.md +110 -0
- package/skills/tech-spec/references/design-template.md +301 -0
- package/skills/tech-spec/references/rollout-and-rollback.md +203 -0
- package/skills/tech-spec/references/spec-delta-conventions.md +250 -0
- package/skills/tech-spec/references/transaction-patterns.md +212 -0
- package/skills/test-spec/SKILL.md +219 -0
- package/skills/test-spec/references/coverage-strategy.md +218 -0
- package/skills/test-spec/references/edge-case-to-test.md +143 -0
- package/skills/test-spec/references/test-case-template.md +276 -0
- package/skills/verify/SKILL.md +232 -0
- package/skills/verify/references/nfr-verification.md +292 -0
- package/skills/verify/references/report-templates.md +510 -0
- package/skills/verify/references/self-test-guide.md +240 -0
- package/skills/verify/references/verify-rollback-map.md +247 -0
- package/src/cli/commands/_helpers.js +108 -0
- package/src/cli/commands/_submit.js +718 -0
- package/src/cli/commands/apply.js +198 -0
- package/src/cli/commands/archive.js +180 -0
- package/src/cli/commands/checkpoint.js +113 -0
- package/src/cli/commands/deliver.js +377 -0
- package/src/cli/commands/deploy.js +504 -0
- package/src/cli/commands/design.js +158 -0
- package/src/cli/commands/disable.js +21 -0
- package/src/cli/commands/doctor.js +178 -0
- package/src/cli/commands/enable.js +21 -0
- package/src/cli/commands/flow.js +645 -0
- package/src/cli/commands/help.js +93 -0
- package/src/cli/commands/ingest.js +602 -0
- package/src/cli/commands/init.js +341 -0
- package/src/cli/commands/knowledge.js +523 -0
- package/src/cli/commands/logs.js +43 -0
- package/src/cli/commands/new.js +202 -0
- package/src/cli/commands/plan.js +49 -0
- package/src/cli/commands/propose.js +27 -0
- package/src/cli/commands/provider.js +698 -0
- package/src/cli/commands/report.js +143 -0
- package/src/cli/commands/requirement.js +227 -0
- package/src/cli/commands/review.js +301 -0
- package/src/cli/commands/skills.js +457 -0
- package/src/cli/commands/status.js +925 -0
- package/src/cli/commands/switch.js +27 -0
- package/src/cli/commands/sync.js +47 -0
- package/src/cli/commands/test.js +366 -0
- package/src/cli/commands/uninstall.js +32 -0
- package/src/cli/commands/update.js +74 -0
- package/src/cli/commands/verify.js +354 -0
- package/src/cli/commands/worktree.js +78 -0
- package/src/cli/index.js +72 -0
- package/src/cli/parse-args.js +102 -0
- package/src/core/autodetect.js +271 -0
- package/src/core/change.js +208 -0
- package/src/core/checkpoint.js +217 -0
- package/src/core/config.js +60 -0
- package/src/core/delta.js +290 -0
- package/src/core/markers.js +59 -0
- package/src/core/paths.js +173 -0
- package/src/core/plan-tasks.js +36 -0
- package/src/core/project-routing.js +285 -0
- package/src/core/projects.js +200 -0
- package/src/core/state.js +200 -0
- package/src/core/workflow-check.js +177 -0
- package/src/core/workflow-init.js +34 -0
- package/src/core/workflow-picker.js +154 -0
- package/src/core/workflow-policy.js +119 -0
- package/src/core/workflow-suggest.js +181 -0
- package/src/core/workflow-verify.js +88 -0
- package/src/core/workflow.js +433 -0
- package/src/core/worktree.js +241 -0
- package/src/knowledge/categories.js +107 -0
- package/src/knowledge/classify.js +125 -0
- package/src/knowledge/deposit.js +414 -0
- package/src/knowledge/migrate.js +149 -0
- package/src/knowledge/mr.js +219 -0
- package/src/knowledge/query.js +131 -0
- package/src/knowledge/registry.js +151 -0
- package/src/knowledge/sync.js +179 -0
- package/src/providers/base.js +74 -0
- package/src/providers/drivers/api-yapi.js +78 -0
- package/src/providers/drivers/ci-jenkins.js +109 -0
- package/src/providers/drivers/intake-confluence.js +544 -0
- package/src/providers/drivers/kb-git.js +549 -0
- package/src/providers/drivers/kb-weknora.js +472 -0
- package/src/providers/drivers/notify-smtp.js +515 -0
- package/src/providers/drivers/observability-oss.js +43 -0
- package/src/providers/drivers/observability-sls.js +50 -0
- package/src/providers/lifecycle.js +135 -0
- package/src/providers/loader.js +132 -0
- package/src/providers/local.js +190 -0
- package/src/providers/userconfig.js +283 -0
- package/src/reports/aggregate.js +185 -0
- package/src/reports/coverage.js +163 -0
- package/src/reports/detect.js +143 -0
- package/src/reports/parse.js +236 -0
- package/src/templates/files/ci/github.yml +38 -0
- package/src/templates/files/ci/gitlab.yml +27 -0
- package/src/templates/files/design.md +63 -0
- package/src/templates/files/ide/devflow-workflow.md +58 -0
- package/src/templates/files/ide/project-overview-reference.md +1 -0
- package/src/templates/files/ide/project-overview.md +27 -0
- package/src/templates/files/knowledge-index.json +17 -0
- package/src/templates/files/knowledge.md +28 -0
- package/src/templates/files/meta.json +8 -0
- package/src/templates/files/plan.md +38 -0
- package/src/templates/files/proposal.md +33 -0
- package/src/templates/files/reports/contract-test.md +40 -0
- package/src/templates/files/reports/e2e-test.md +30 -0
- package/src/templates/files/reports/integration-test.md +36 -0
- package/src/templates/files/reports/joint-test.md +58 -0
- package/src/templates/files/reports/perf.md +24 -0
- package/src/templates/files/reports/regression.md +20 -0
- package/src/templates/files/reports/remote-test.md +55 -0
- package/src/templates/files/reports/self-test.md +43 -0
- package/src/templates/files/reports/smoke-test.md +22 -0
- package/src/templates/files/reports/unit-test.md +36 -0
- package/src/templates/files/requirement.md +51 -0
- package/src/templates/files/review.md +38 -0
- package/src/templates/files/tests.md +36 -0
- package/src/templates/files/verify.md +32 -0
- package/src/templates/index.js +21 -0
- package/src/utils/log.js +37 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# RFC-002: Workflow Kernel 与结构化 Checkpoint
|
|
2
|
+
|
|
3
|
+
- **状态**: Draft / incremental implementation
|
|
4
|
+
- **创建日期**: 2026-05-11
|
|
5
|
+
- **目标版本**: v0.2.x
|
|
6
|
+
|
|
7
|
+
## 摘要
|
|
8
|
+
|
|
9
|
+
devflow-kit 早期主要依靠阶段 skill 约束 agent 行为。这个模式能快速覆盖完整流程,但在真实使用中暴露出几个整体性问题:agent 可能漏展示问题卡或下一步卡,plan 生成后可能越过用户审查直接 apply,多轮 review/apply 后用户不知道下一步,编译/测试失败也容易和历史基线问题混在一起。
|
|
10
|
+
|
|
11
|
+
RFC-002 引入一个轻量 Workflow Kernel:把用户决策点、下一步卡片、风险和证据抽象成结构化 checkpoint。Skill 仍负责判断和解释,CLI/state machine 负责记录、渲染和拒绝越级推进。
|
|
12
|
+
|
|
13
|
+
## 背景问题
|
|
14
|
+
|
|
15
|
+
当前流程的问题不只是"编译测试空转",而是阶段控制太依赖自然语言纪律:
|
|
16
|
+
|
|
17
|
+
- **用户决策点分散**:复杂度分级、涉及项目、Round 问题、plan 审查、review 返工、baseline 风险分别写在不同 skill 中。
|
|
18
|
+
- **卡片输出不稳定**:skill 文档写了要展示,但 agent 漏读或上下文过长时仍可能只输出变更列表。
|
|
19
|
+
- **状态不可产品化**:`state.json.checkpoints` 之前只是简单数组,缺少统一字段,UI/CLI 很难稳定渲染。
|
|
20
|
+
- **证据和风险割裂**:测试报告、部署报告、baseline failure、review finding 都有自己的表达,用户需要自己拼上下文。
|
|
21
|
+
|
|
22
|
+
## 目标
|
|
23
|
+
|
|
24
|
+
1. 把"需要用户确认什么"变成一等状态,而不是对话里的临时句子。
|
|
25
|
+
2. 让 CLI 能统一渲染下一步卡片,减少每个 skill 手写格式的漂移。
|
|
26
|
+
3. 为后续 phase gate 提供可机械检查的字段。
|
|
27
|
+
4. 保留现有 markdown 工作流,不一次性重写所有阶段。
|
|
28
|
+
|
|
29
|
+
## 非目标
|
|
30
|
+
|
|
31
|
+
- 本 RFC 不引入 Web UI。
|
|
32
|
+
- 本 RFC 不要求所有 phase 一次性迁移到 checkpoint。
|
|
33
|
+
- 本 RFC 不替代 `requirement.md` / `design.md` / `plan.md` 等文件优先产物。
|
|
34
|
+
|
|
35
|
+
## 数据模型
|
|
36
|
+
|
|
37
|
+
Checkpoint 存在 `state.json.checkpoints[]`:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"id": "plan_review-3f4a9c12",
|
|
42
|
+
"type": "plan_review",
|
|
43
|
+
"phase": "plan",
|
|
44
|
+
"status": "pending",
|
|
45
|
+
"summary": "plan.md 已生成 3 个 task",
|
|
46
|
+
"question": "是否接受计划并进入 apply?",
|
|
47
|
+
"options": [
|
|
48
|
+
{ "id": "accept", "label": "接受计划", "command": "devflow apply" },
|
|
49
|
+
{ "id": "revise", "label": "修改计划", "command": "devflow plan --edit" }
|
|
50
|
+
],
|
|
51
|
+
"defaultOption": "accept",
|
|
52
|
+
"nextAction": "devflow apply",
|
|
53
|
+
"risks": [],
|
|
54
|
+
"evidence": [],
|
|
55
|
+
"createdAt": "2026-05-11T00:00:00.000Z"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
状态:
|
|
60
|
+
|
|
61
|
+
- `pending`:正在等待用户确认;`devflow status` 应展示下一步卡片。
|
|
62
|
+
- `resolved`:用户已选择,写入 `decision` 和 `resolvedAt`。
|
|
63
|
+
- `cancelled`:该确认点被后续流程替代或废弃。
|
|
64
|
+
|
|
65
|
+
## CLI
|
|
66
|
+
|
|
67
|
+
新增命令:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
devflow checkpoint show --slug=<slug>
|
|
71
|
+
devflow checkpoint add --slug=<slug> \
|
|
72
|
+
--type=plan_review \
|
|
73
|
+
--phase=plan \
|
|
74
|
+
--summary="plan.md 已生成 3 个 task" \
|
|
75
|
+
--question="是否接受计划并进入 apply?" \
|
|
76
|
+
--options="accept=devflow apply;revise=devflow plan --edit"
|
|
77
|
+
devflow checkpoint resolve --slug=<slug> --id=<checkpoint-id> --decision=accept
|
|
78
|
+
devflow checkpoint cancel --slug=<slug> --id=<checkpoint-id> --reason="superseded"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`devflow status` 会显示最新 pending checkpoint 的标准下一步卡片。
|
|
82
|
+
|
|
83
|
+
## 下一步卡片格式
|
|
84
|
+
|
|
85
|
+
CLI 渲染的基础格式:
|
|
86
|
+
|
|
87
|
+
```markdown
|
|
88
|
+
## 下一步
|
|
89
|
+
状态:NEEDS_INPUT
|
|
90
|
+
检查点:plan_review
|
|
91
|
+
阶段:plan
|
|
92
|
+
摘要:plan.md 已生成 3 个 task
|
|
93
|
+
需要你确认:是否接受计划并进入 apply?
|
|
94
|
+
选项:
|
|
95
|
+
- accept — 接受计划 — 命令:`devflow apply`
|
|
96
|
+
- revise — 修改计划 — 命令:`devflow plan --edit`
|
|
97
|
+
命令:`devflow apply`
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 修改原因
|
|
101
|
+
|
|
102
|
+
- **减少 agent 漏步骤**:把"问不问用户"从自由文本变成状态。
|
|
103
|
+
- **减少用户迷路**:每个停顿点都有固定下一步卡片。
|
|
104
|
+
- **方便 UI 渲染**:Codex/Cursor/Claude 等 IDE 可以按同一字段展示卡片。
|
|
105
|
+
- **方便测试**:流程规则可以通过 `state.json` 和 CLI 输出测试,而不是靠人工看对话。
|
|
106
|
+
|
|
107
|
+
## 修改好处
|
|
108
|
+
|
|
109
|
+
- plan 生成后不会只靠 skill 记忆"等用户审查"。
|
|
110
|
+
- requirement 的问题卡、项目确认、复杂度分级可以迁移成统一 checkpoint,其中问题卡和项目确认已接入第一版 CLI gate。
|
|
111
|
+
- apply / review 中的 `DONE_WITH_CONCERNS` 可以把风险和接受选项结构化。
|
|
112
|
+
- verify / deliver 可以读取 unresolved checkpoint,拒绝越级推进。
|
|
113
|
+
- 长期可以把多 agent 并行、baseline failure、review finding 都挂到同一个 evidence/risk 模型上。
|
|
114
|
+
|
|
115
|
+
## 渐进迁移路线
|
|
116
|
+
|
|
117
|
+
1. **v0.2.x**:落地 `src/core/checkpoint.js`、`devflow checkpoint`、`devflow status` 渲染 pending checkpoint。
|
|
118
|
+
2. **plan gate(已接入)**:`devflow plan` 创建 `plan_review`;`devflow apply` 在该 checkpoint pending 时拒绝启动,除非 `--force --reason` 审计绕过。
|
|
119
|
+
3. **intake/requirement gate(已接入)**:`devflow new/ingest` 创建 `problem_card`;`devflow requirement` 在该 checkpoint pending 时拒绝启动,除非 `--force --reason` 审计绕过。
|
|
120
|
+
4. **project gate(已接入)**:`devflow requirement` 自动路由项目后创建 `project_confirmation`;`devflow design` 在该 checkpoint pending 时拒绝启动,除非 `--force --reason` 审计绕过。
|
|
121
|
+
5. **review gate(已接入)**:`devflow review --round` 创建 `review_fix` / `review_blocked`;`devflow apply` 接受返工 checkpoint,review pass / force-pass 解析返工 checkpoint。
|
|
122
|
+
6. **verify/deliver gate(已接入)**:`devflow verify finalize` 缺报告时创建 `verification_evidence`;`devflow deliver` 检查未解决的 review/evidence/risk checkpoint。
|
|
123
|
+
7. **UI 友好(已接入)**:`devflow checkpoint show --json` 输出机器可读 `checkpoint_confirmation_surface`,包含 pending checkpoint、confirmationCard 和 nextAction,供 IDE 直接渲染问题卡/下一步卡。
|
|
124
|
+
8. **证据统一**:review finding、baselineKnownFailures、test reports 逐步接入更细的 `evidence` / `risks` 模型。
|
|
125
|
+
|
|
126
|
+
## 与 skill 的关系
|
|
127
|
+
|
|
128
|
+
Skill 继续保留,但职责调整:
|
|
129
|
+
|
|
130
|
+
- Skill:判断该停在哪里、给出问题/选项、解释原因。
|
|
131
|
+
- CLI:写入 checkpoint、渲染卡片、维护状态和审计日志。
|
|
132
|
+
- State machine:决定 unresolved checkpoint 是否阻止进入下一 phase。
|
|
133
|
+
|
|
134
|
+
这能把 devflow-kit 从"一组流程说明"推进到"有结构化工作流内核的 CLI + Skills 套件"。
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# 企业集成能力补充说明
|
|
2
|
+
|
|
3
|
+
本文补充说明 devflow-kit 新增的企业内网集成能力:YAPI 同步、Jenkins job 智能匹配、SLS/OSS 日志检索、调用链一致性验证。
|
|
4
|
+
|
|
5
|
+
这些能力的共同原则是:核心流程不绑定任何公司内网系统,只定义 provider、命令入口和报告形状;具体地址、token、项目映射都放在 `~/.devflow/providers.json` 或 `~/.devflow/projects.json`。
|
|
6
|
+
|
|
7
|
+
## 一、能力总览
|
|
8
|
+
|
|
9
|
+
| 能力 | 命令 / 配置 | 产物 | 解决的问题 |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| YAPI 同步 | `devflow sync yapi --file=<file>` + `api.yapi` provider | YAPI 接口文档 | 避免代码改了、接口契约文档没同步 |
|
|
12
|
+
| Jenkins job 智能匹配 | `devflow deploy <env> --project=<name>` | `reports/test-report.md#deploy` | 项目多、job 命名不统一时,降低找错 job 的概率 |
|
|
13
|
+
| SLS / OSS 日志检索 | `devflow logs query ...` + `observability.*` provider | 命令输出 / 可贴入测试报告 | 提测、联调、回归时快速拿到 traceId/requestId 证据 |
|
|
14
|
+
| 调用链一致性验证 | `devflow test contract --cmd="..."` | `reports/test-report.md#contract` | 验证接口提供方、调用方、回调、跳转、日志链路是否一致 |
|
|
15
|
+
|
|
16
|
+
## 二、整体流程
|
|
17
|
+
|
|
18
|
+
```mermaid
|
|
19
|
+
flowchart TD
|
|
20
|
+
A["design.md\n接口契约 / 核心流程 / 调用链"] --> B["devflow sync yapi\n同步 YAPI / OpenAPI"]
|
|
21
|
+
A --> C["devflow test contract\n调用链一致性验证"]
|
|
22
|
+
C --> D["reports/test-report.md#contract"]
|
|
23
|
+
E["devflow deploy test\nJenkins job 智能匹配 + 部署"] --> F["reports/test-report.md#deploy"]
|
|
24
|
+
F --> G["devflow test remote / joint / smoke"]
|
|
25
|
+
G --> H["devflow logs query\nSLS / OSS 检索 traceId/requestId"]
|
|
26
|
+
H --> I["补充到 #contract / #remote / #self-test 证据"]
|
|
27
|
+
D --> J["devflow verify finalize"]
|
|
28
|
+
I --> J
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 三、Provider 配置
|
|
32
|
+
|
|
33
|
+
运行交互式配置:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
devflow provider setup
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
当前会提供这些新增项:
|
|
40
|
+
|
|
41
|
+
- `api.yapi`
|
|
42
|
+
- `observability.sls`
|
|
43
|
+
- `observability.oss`
|
|
44
|
+
|
|
45
|
+
也可以手动写入 `~/.devflow/providers.json`。注意 token 必须优先使用 `${env:VAR}`。
|
|
46
|
+
|
|
47
|
+
```jsonc
|
|
48
|
+
{
|
|
49
|
+
"api.yapi": {
|
|
50
|
+
"type": "api",
|
|
51
|
+
"driver": "yapi",
|
|
52
|
+
"config": {
|
|
53
|
+
"baseUrl": "https://yapi.example.com",
|
|
54
|
+
"token": "${env:YAPI_TOKEN}",
|
|
55
|
+
"projectId": "${env:YAPI_PROJECT_ID}",
|
|
56
|
+
"syncPath": "/api/open/import_data"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"observability.sls": {
|
|
60
|
+
"type": "observability",
|
|
61
|
+
"driver": "sls",
|
|
62
|
+
"config": {
|
|
63
|
+
"endpoint": "${env:SLS_ENDPOINT}",
|
|
64
|
+
"project": "${env:SLS_PROJECT}",
|
|
65
|
+
"logstore": "${env:SLS_LOGSTORE}",
|
|
66
|
+
"accessKeyId": "${env:ALIYUN_ACCESS_KEY_ID}",
|
|
67
|
+
"accessKeySecret": "${env:ALIYUN_ACCESS_KEY_SECRET}",
|
|
68
|
+
"queryCommand": "aliyunlog log get_log_all --project=${project} --logstore=${logstore} --query '${query}'"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"observability.oss": {
|
|
72
|
+
"type": "observability",
|
|
73
|
+
"driver": "oss",
|
|
74
|
+
"config": {
|
|
75
|
+
"endpoint": "${env:OSS_ENDPOINT}",
|
|
76
|
+
"bucket": "${env:OSS_BUCKET}",
|
|
77
|
+
"prefix": "logs/",
|
|
78
|
+
"accessKeyId": "${env:ALIYUN_ACCESS_KEY_ID}",
|
|
79
|
+
"accessKeySecret": "${env:ALIYUN_ACCESS_KEY_SECRET}",
|
|
80
|
+
"queryCommand": "ossutil grep oss://${bucket}/${prefix} '${query}'"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## 四、YAPI 同步
|
|
87
|
+
|
|
88
|
+
### 使用方式
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
devflow sync yapi --file=./openapi.json --dry-run
|
|
92
|
+
devflow sync yapi --file=./openapi.json --provider=api.yapi
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
支持输入:
|
|
96
|
+
|
|
97
|
+
- OpenAPI / Swagger JSON
|
|
98
|
+
- 接口说明 markdown
|
|
99
|
+
|
|
100
|
+
### 流程位置
|
|
101
|
+
|
|
102
|
+
YAPI 同步属于 design / verify 之间的契约同步动作:
|
|
103
|
+
|
|
104
|
+
1. `design.md` 写清接口契约。
|
|
105
|
+
2. 产出或整理 `openapi.json` / `api.md`。
|
|
106
|
+
3. 先跑 `--dry-run` 看识别到的接口数量。
|
|
107
|
+
4. 确认后同步到 YAPI。
|
|
108
|
+
5. 在 `test-report.md#contract` 或 `verify.md` 记录同步结果。
|
|
109
|
+
|
|
110
|
+
### 价值
|
|
111
|
+
|
|
112
|
+
- 避免提测后 QA 看到旧接口文档。
|
|
113
|
+
- 让接口契约从 design 进入可复查的外部文档系统。
|
|
114
|
+
- 后续可以继续接 YAPI diff,把“文档是否落后实现”变成 verify 检查。
|
|
115
|
+
|
|
116
|
+
## 五、Jenkins Job 智能匹配
|
|
117
|
+
|
|
118
|
+
### 当前匹配规则
|
|
119
|
+
|
|
120
|
+
devflow 会基于 git remote 的 `group/project`、项目名和环境名生成候选:
|
|
121
|
+
|
|
122
|
+
- `group-project`
|
|
123
|
+
- `group-project-test`
|
|
124
|
+
- `group-test-project`
|
|
125
|
+
- `project-test`
|
|
126
|
+
- `project-test2`
|
|
127
|
+
- `project-deploy-test`
|
|
128
|
+
- `deploy/project`
|
|
129
|
+
- `deploy/project-test`
|
|
130
|
+
- `test/project`
|
|
131
|
+
|
|
132
|
+
并降低 rollback job 的优先级。
|
|
133
|
+
|
|
134
|
+
### 使用方式
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
devflow provider import publish-code --from=./publish-code-config.json
|
|
138
|
+
devflow deploy test --project=member
|
|
139
|
+
devflow deploy test --project=member --merge-to=test --preflight
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 为什么需要
|
|
143
|
+
|
|
144
|
+
很多内部 Jenkins 命名并不统一。智能匹配不能替代人工配置,但可以:
|
|
145
|
+
|
|
146
|
+
- 初始化时给出更靠谱的 job 候选。
|
|
147
|
+
- 导入老配置时兼容多种命名。
|
|
148
|
+
- 降低把 rollback / staging / 其他项目 job 当成测试部署 job 的概率。
|
|
149
|
+
|
|
150
|
+
最终触发哪个 job 仍以 `~/.devflow/projects.json` 中项目 profile 为准。
|
|
151
|
+
|
|
152
|
+
## 六、SLS / OSS 日志检索
|
|
153
|
+
|
|
154
|
+
### 使用方式
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
devflow logs query --provider=observability.sls --trace-id=<traceId>
|
|
158
|
+
devflow logs query --provider=observability.sls --request-id=<requestId>
|
|
159
|
+
devflow logs query --provider=observability.oss --query="orderNo=123"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 建议检索字段
|
|
163
|
+
|
|
164
|
+
| 字段 | 用途 |
|
|
165
|
+
| --- | --- |
|
|
166
|
+
| `traceId` | 串起入口、服务调用、RPC、异步消息 |
|
|
167
|
+
| `requestId` | 定位单次 HTTP 请求或网关请求 |
|
|
168
|
+
| `orderNo` / `contractNo` / `signNo` | 业务链路定位 |
|
|
169
|
+
| `userId` / `memberId` | 用户维度问题定位 |
|
|
170
|
+
| `pay_channel` / `channel` | 渠道分支问题定位 |
|
|
171
|
+
|
|
172
|
+
### 证据放哪里
|
|
173
|
+
|
|
174
|
+
日志检索输出不要直接写进多个散文件。建议整理到:
|
|
175
|
+
|
|
176
|
+
- `reports/test-report.md#contract`:调用链一致性证据
|
|
177
|
+
- `reports/test-report.md#remote`:远程 API 验收证据
|
|
178
|
+
- `reports/test-report.md#self-test`:提测自测补充说明
|
|
179
|
+
|
|
180
|
+
不要把 token、cookie、完整手机号、身份证号等敏感信息写入报告。
|
|
181
|
+
|
|
182
|
+
## 七、调用链一致性验证
|
|
183
|
+
|
|
184
|
+
### 使用方式
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
devflow test contract --cmd="npm run test:contract"
|
|
188
|
+
devflow test contract --cmd="go test ./... -run Contract"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
报告写入:
|
|
192
|
+
|
|
193
|
+
```text
|
|
194
|
+
reports/test-report.md#contract
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### 验证内容
|
|
198
|
+
|
|
199
|
+
调用链一致性验证不是单纯的接口单测。它关注的是“链路中的每个参与者是否对同一个契约有一致理解”。
|
|
200
|
+
|
|
201
|
+
应覆盖:
|
|
202
|
+
|
|
203
|
+
- 提供方接口字段、枚举、状态语义。
|
|
204
|
+
- 调用方解析字段是否一致。
|
|
205
|
+
- `returnUrl` / `redirect` / `callback` / query 参数是否丢失或被误用。
|
|
206
|
+
- 前端轮询 key、后端签约号、订单号、渠道字段来源是否一致。
|
|
207
|
+
- traceId / requestId 是否贯穿入口、下游调用、回调和日志。
|
|
208
|
+
- YAPI / OpenAPI 文档是否与实现一致。
|
|
209
|
+
|
|
210
|
+
### 什么时候需要
|
|
211
|
+
|
|
212
|
+
| Level | 是否需要 |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| L0 | 通常不需要 |
|
|
215
|
+
| L1 | 只有接口契约变化时补 |
|
|
216
|
+
| L2 | 有调用方、回调、跳转、前后端消费者时补 |
|
|
217
|
+
| L3 | 跨服务核心链路默认补 |
|
|
218
|
+
|
|
219
|
+
## 八、Design 模板新增内容
|
|
220
|
+
|
|
221
|
+
`design.md` 现在会提示补充:
|
|
222
|
+
|
|
223
|
+
```markdown
|
|
224
|
+
### YAPI / OpenAPI 同步
|
|
225
|
+
|
|
226
|
+
- 契约文件:
|
|
227
|
+
- 同步命令:`devflow sync yapi --file=<openapi.json|api.md> --dry-run`
|
|
228
|
+
|
|
229
|
+
### 调用链一致性验证
|
|
230
|
+
|
|
231
|
+
- traceId / requestId 传递点:
|
|
232
|
+
- 调用方 / 回调 / redirect / query 参数:
|
|
233
|
+
- 日志检索:`devflow logs query --trace-id=<id>` 或 `--request-id=<id>`
|
|
234
|
+
- 验证命令:`devflow test contract --cmd="<contract/check command>"`
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
这部分的目标不是让每个需求都填满,而是提醒 agent 和开发者:只要涉及接口、回调、跳转、异步链路或跨服务消费者,就不能只写“后端改接口”,必须说明消费者和验证证据。
|
|
238
|
+
|
|
239
|
+
## 九、推荐执行顺序
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# 1. 设计阶段
|
|
243
|
+
devflow design
|
|
244
|
+
|
|
245
|
+
# 2. 接口契约同步
|
|
246
|
+
devflow sync yapi --file=./openapi.json --dry-run
|
|
247
|
+
devflow sync yapi --file=./openapi.json
|
|
248
|
+
|
|
249
|
+
# 3. 实现后验证调用链
|
|
250
|
+
devflow test contract --cmd="npm run test:contract"
|
|
251
|
+
|
|
252
|
+
# 4. 部署测试环境
|
|
253
|
+
devflow deploy test --project=<project> --merge-to=test --preflight
|
|
254
|
+
|
|
255
|
+
# 5. 远程 / 联调 / 冒烟
|
|
256
|
+
devflow test remote --api-base-url=<url> --cmd="..."
|
|
257
|
+
devflow test joint --backend-url=<url> --frontend-url=<url> --cmd="..."
|
|
258
|
+
devflow test smoke --cmd="curl -fsS <url>/health"
|
|
259
|
+
|
|
260
|
+
# 6. 检索日志证据
|
|
261
|
+
devflow logs query --trace-id=<traceId>
|
|
262
|
+
|
|
263
|
+
# 7. 汇总验证
|
|
264
|
+
devflow report self-test
|
|
265
|
+
devflow verify finalize
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## 十、后续可扩展点
|
|
269
|
+
|
|
270
|
+
- YAPI diff:同步前比较 YAPI 现有接口与本次 OpenAPI,把破坏性变更转成 verify warning。
|
|
271
|
+
- Jenkins live discovery:通过 Jenkins API 拉取 job 列表后用 `rankJenkinsJobs()` 排序,让 CLI 交互选择。
|
|
272
|
+
- SLS 原生签名:当前支持 `queryCommand` 模板,后续可内置阿里云 SLS API 签名。
|
|
273
|
+
- OSS 原生检索:当前支持 `queryCommand` 模板,后续可接 OSS SDK 或 `ossutil` 封装。
|
|
274
|
+
- trace report:把一次 traceId 的多服务日志整理为链路表,直接写入 `test-report.md#contract`。
|