@chenmk/superflow 0.2.5 → 0.4.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.
Files changed (116) hide show
  1. package/README.md +24 -2
  2. package/README.zh-CN.md +17 -1
  3. package/assets/manifest.json +7 -4
  4. package/assets/prompts/superflow-clarify.md +6 -0
  5. package/assets/prompts/superflow-design.md +3 -0
  6. package/assets/prompts/superflow-docs.md +4 -1
  7. package/assets/prompts/superflow-pipeline.md +8 -0
  8. package/assets/scripts/superflow-archive-command-hook.sh +80 -0
  9. package/assets/scripts/superflow-delivery-check.sh +23 -4
  10. package/assets/scripts/superflow-dependency-update-hook.sh +1 -1
  11. package/assets/scripts/superflow-managed-work-check.mjs +194 -0
  12. package/assets/scripts/superflow-managed-work-guard.sh +103 -0
  13. package/assets/skills/openspec-propose/SKILL.md +11 -0
  14. package/assets/skills/superflow-archive/SKILL.md +5 -0
  15. package/assets/skills/superflow-clarify/SKILL.md +26 -7
  16. package/assets/skills/superflow-design/SKILL.md +38 -7
  17. package/assets/skills/superflow-docs/SKILL.md +27 -0
  18. package/assets/skills/superflow-pipeline/SKILL.md +75 -0
  19. package/assets/skills/superflow-pipeline/references/api-design-template.md +11 -0
  20. package/assets/skills/superflow-pipeline/references/batch-prompt-template.md +27 -0
  21. package/assets/skills/superflow-pipeline/references/document-templates.md +8 -0
  22. package/assets/skills/superflow-pipeline/references/implementation-prompt-template.md +29 -1
  23. package/assets/skills/superflow-pipeline/references/managed-work.md +58 -0
  24. package/assets/skills/superflow-pipeline/references/quality-gate.md +3 -0
  25. package/assets/skills/superflow-pipeline/references/superpower-technical-design-template.md +51 -0
  26. package/assets/skills/superflow-pipeline/references/test-execution-template.md +10 -0
  27. package/assets/skills/superflow-pipeline/scripts/superflow-archive.sh +1 -1
  28. package/assets/skills/superflow-pipeline/scripts/superflow-guard.sh +215 -2
  29. package/assets/skills/superflow-verify/SKILL.md +7 -0
  30. package/assets/skills-en/openspec-propose/SKILL.md +14 -0
  31. package/assets/skills-en/superflow-archive/SKILL.md +6 -0
  32. package/assets/skills-en/superflow-clarify/SKILL.md +26 -7
  33. package/assets/skills-en/superflow-design/SKILL.md +38 -6
  34. package/assets/skills-en/superflow-docs/SKILL.md +27 -0
  35. package/assets/skills-en/superflow-pipeline/SKILL.md +76 -0
  36. package/assets/skills-en/superflow-pipeline/references/api-design-template.md +13 -0
  37. package/assets/skills-en/superflow-pipeline/references/batch-prompt-template.md +16 -0
  38. package/assets/skills-en/superflow-pipeline/references/document-templates.md +5 -0
  39. package/assets/skills-en/superflow-pipeline/references/implementation-prompt-template.md +17 -0
  40. package/assets/skills-en/superflow-pipeline/references/managed-work.md +34 -0
  41. package/assets/skills-en/superflow-pipeline/references/quality-gate.md +25 -0
  42. package/assets/skills-en/superflow-pipeline/references/superpower-technical-design-template.md +57 -0
  43. package/assets/skills-en/superflow-pipeline/references/test-execution-template.md +12 -0
  44. package/assets/skills-en/superflow-pipeline/scripts/superflow-archive.sh +1 -1
  45. package/assets/skills-en/superflow-pipeline/scripts/superflow-guard.sh +214 -2
  46. package/assets/skills-en/superflow-verify/SKILL.md +8 -0
  47. package/dist/app/cli.js +120 -102
  48. package/dist/app/cli.js.map +1 -1
  49. package/dist/app/commands/archive.js +7 -3
  50. package/dist/app/commands/archive.js.map +1 -1
  51. package/dist/app/commands/change-guard.js +27 -0
  52. package/dist/app/commands/change-guard.js.map +1 -0
  53. package/dist/app/commands/design.js +2 -20
  54. package/dist/app/commands/design.js.map +1 -1
  55. package/dist/app/commands/init.js +7 -7
  56. package/dist/app/commands/init.js.map +1 -1
  57. package/dist/app/commands/managed-service.js +5 -0
  58. package/dist/app/commands/managed-service.js.map +1 -0
  59. package/dist/app/commands/pipeline.js +123 -3
  60. package/dist/app/commands/pipeline.js.map +1 -1
  61. package/dist/app/commands/status.js +199 -77
  62. package/dist/app/commands/status.js.map +1 -1
  63. package/dist/app/commands/uninstall.js +5 -2
  64. package/dist/app/commands/uninstall.js.map +1 -1
  65. package/dist/app/commands/update.js +33 -11
  66. package/dist/app/commands/update.js.map +1 -1
  67. package/dist/app/commands/verify.js +7 -3
  68. package/dist/app/commands/verify.js.map +1 -1
  69. package/dist/domains/config/cli-help.js +103 -73
  70. package/dist/domains/config/cli-help.js.map +1 -1
  71. package/dist/domains/config/context.js +1 -5
  72. package/dist/domains/config/context.js.map +1 -1
  73. package/dist/domains/deps.js +3 -6
  74. package/dist/domains/deps.js.map +1 -1
  75. package/dist/domains/hook.js +71 -37
  76. package/dist/domains/hook.js.map +1 -1
  77. package/dist/domains/managed-work/contract.js +218 -0
  78. package/dist/domains/managed-work/contract.js.map +1 -0
  79. package/dist/domains/managed-work/i18n.js +12 -0
  80. package/dist/domains/managed-work/i18n.js.map +1 -0
  81. package/dist/domains/managed-work/input.js +111 -0
  82. package/dist/domains/managed-work/input.js.map +1 -0
  83. package/dist/domains/managed-work/journal.js +122 -0
  84. package/dist/domains/managed-work/journal.js.map +1 -0
  85. package/dist/domains/managed-work/lock.js +40 -0
  86. package/dist/domains/managed-work/lock.js.map +1 -0
  87. package/dist/domains/managed-work/notifications.js +53 -0
  88. package/dist/domains/managed-work/notifications.js.map +1 -0
  89. package/dist/domains/managed-work/paths.js +18 -0
  90. package/dist/domains/managed-work/paths.js.map +1 -0
  91. package/dist/domains/managed-work/prompts.js +218 -0
  92. package/dist/domains/managed-work/prompts.js.map +1 -0
  93. package/dist/domains/managed-work/runner.js +626 -0
  94. package/dist/domains/managed-work/runner.js.map +1 -0
  95. package/dist/domains/managed-work/schemas.js +85 -0
  96. package/dist/domains/managed-work/schemas.js.map +1 -0
  97. package/dist/domains/managed-work/service.js +121 -0
  98. package/dist/domains/managed-work/service.js.map +1 -0
  99. package/dist/domains/managed-work/state.js +90 -0
  100. package/dist/domains/managed-work/state.js.map +1 -0
  101. package/dist/domains/managed-work/storage.js +181 -0
  102. package/dist/domains/managed-work/storage.js.map +1 -0
  103. package/dist/domains/managed-work/types.js +16 -0
  104. package/dist/domains/managed-work/types.js.map +1 -0
  105. package/dist/domains/managed-work/wait.js +40 -0
  106. package/dist/domains/managed-work/wait.js.map +1 -0
  107. package/dist/platform/agent-process.js +308 -0
  108. package/dist/platform/agent-process.js.map +1 -0
  109. package/dist/platform/assets.js +9 -0
  110. package/dist/platform/assets.js.map +1 -0
  111. package/dist/platform/process-liveness.js +10 -0
  112. package/dist/platform/process-liveness.js.map +1 -0
  113. package/dist/platform/version-check.js +30 -9
  114. package/dist/platform/version-check.js.map +1 -1
  115. package/package.json +3 -2
  116. package/scripts/release-notes-check.js +102 -0
@@ -24,6 +24,7 @@ VALIDATE="$SCRIPT_DIR/superflow-yaml-validate.sh"
24
24
  CHANGE_DIR="${1:-}"
25
25
  PHASE="${2:-}"
26
26
  MODE="${3:-}"
27
+ CHANGE_DIR_INPUT="${CHANGE_DIR%/}"
27
28
 
28
29
  [[ -n "$CHANGE_DIR" && -n "$PHASE" ]] || {
29
30
  usage
@@ -35,6 +36,25 @@ MODE="${3:-}"
35
36
  CHANGE_DIR="$(cd "$CHANGE_DIR" && pwd)"
36
37
  issues=()
37
38
 
39
+ require_canonical_change_layout() {
40
+ local suffix
41
+
42
+ if [[ -L "$CHANGE_DIR_INPUT" ]]; then
43
+ issues+=("symlinked OpenSpec change directory is forbidden; keep one physical openspec/changes/<change-name> directory")
44
+ fi
45
+
46
+ [[ "$CHANGE_DIR" == */openspec/changes/* ]] || return 0
47
+ suffix="${CHANGE_DIR#*/openspec/changes/}"
48
+ case "$suffix" in
49
+ archive/*|*/embedded-changes/*) return 0 ;;
50
+ esac
51
+ if [[ "$suffix" == */* ]]; then
52
+ issues+=("non-canonical OpenSpec change directory: encode the version in <change-name> and use openspec/changes/<change-name>")
53
+ fi
54
+ }
55
+
56
+ require_canonical_change_layout
57
+
38
58
  require_file() {
39
59
  local path="$1"
40
60
  [[ -f "$CHANGE_DIR/$path" ]] || issues+=("missing file: $path")
@@ -178,6 +198,60 @@ require_state_file() {
178
198
  require_file .sdd/state.yaml
179
199
  }
180
200
 
201
+ require_tasks_complete() {
202
+ local task_count unchecked_count
203
+ require_file tasks.md
204
+ [[ -f "$CHANGE_DIR/tasks.md" ]] || return 0
205
+ task_count="$(grep -Ec '^[[:space:]]*-[[:space:]]+\[[ xX]\]' "$CHANGE_DIR/tasks.md" || true)"
206
+ unchecked_count="$(grep -Ec '^[[:space:]]*-[[:space:]]+\[[[:space:]]\]' "$CHANGE_DIR/tasks.md" || true)"
207
+ [[ "$task_count" -gt 0 ]] || issues+=("tasks.md has no checkbox tasks")
208
+ [[ "$unchecked_count" -eq 0 ]] || issues+=("$unchecked_count unchecked task(s) remain in tasks.md")
209
+ }
210
+
211
+ verification_report_path() {
212
+ local value
213
+ value="$(state_get verification_report)"
214
+ [[ -n "$value" && "$value" != "null" ]] || return 1
215
+ if [[ -f "$CHANGE_DIR/$value" ]]; then
216
+ printf '%s\n' "$CHANGE_DIR/$value"
217
+ return 0
218
+ fi
219
+ if [[ -f "$value" ]]; then
220
+ printf '%s\n' "$value"
221
+ return 0
222
+ fi
223
+ return 1
224
+ }
225
+
226
+ require_closeout_markers() {
227
+ local report="${1:-$CHANGE_DIR/test-report.md}"
228
+ if [[ ! -f "$report" ]]; then
229
+ issues+=("verification report path does not exist: $report")
230
+ return 0
231
+ fi
232
+ if ! grep -Eiq '(Verification Result|验证结果|验证结论)[[:space:]::|*-]*(PASS|通过)' "$report"; then
233
+ issues+=("verification result PASS marker not found in verification report")
234
+ fi
235
+ if ! grep -Eiq '(Archive Readiness|归档就绪)[[:space:]::|*-]*(PASS|READY|通过|就绪)' "$report"; then
236
+ issues+=("archive readiness PASS marker not found in verification report")
237
+ fi
238
+ }
239
+
240
+ require_branch_handled() {
241
+ local branch_status
242
+ branch_status="$(state_get branch_status)"
243
+ [[ "$branch_status" == "handled" ]] || issues+=("branch_status must be handled before verification closeout")
244
+ }
245
+
246
+ require_full_verification_fingerprint() {
247
+ local report="$CHANGE_DIR/test-report.md"
248
+ [[ "$(state_get verify_mode)" == "full" ]] || return 0
249
+ require_grep '测试环境|test environment|staging|sandbox' "$report" "full verification test environment"
250
+ require_grep '分支|提交|版本|构建号|镜像|branch|commit|tag|build|image' "$report" "full verification deployment fingerprint"
251
+ require_grep 'https?://|Base URL|基础地址' "$report" "full verification base URL"
252
+ require_grep '验证时间|执行时间|timestamp|verified[_ -]?at|20[0-9]{2}-[0-9]{2}-[0-9]{2}' "$report" "full verification timestamp"
253
+ }
254
+
181
255
  require_spec_doc() {
182
256
  if [[ -f "$CHANGE_DIR/spec.md" ]]; then
183
257
  return
@@ -259,6 +333,43 @@ change_has_external_enum_risk() {
259
333
  "$CHANGE_DIR"/specs/*/spec.md 2>/dev/null
260
334
  }
261
335
 
336
+ change_contract_docs_without_complexity_budget() {
337
+ local path
338
+ for path in proposal.md api.md design.md tests.md spec.md; do
339
+ [[ -f "$CHANGE_DIR/$path" ]] || continue
340
+ sed -E '/新增项统计|复杂度预算|New-item counts|Complexity budget/d' \
341
+ "$CHANGE_DIR/$path"
342
+ done
343
+ if [[ -d "$CHANGE_DIR/specs" ]]; then
344
+ find "$CHANGE_DIR/specs" -path '*/spec.md' -type f \
345
+ -exec sed -E '/新增项统计|复杂度预算|New-item counts|Complexity budget/d' {} +
346
+ fi
347
+ }
348
+
349
+ change_all_docs_without_complexity_budget() {
350
+ find "$CHANGE_DIR" -maxdepth 2 -name '*.md' -type f \
351
+ -exec sed -E '/新增项统计|复杂度预算|New-item counts|Complexity budget/d' {} +
352
+ }
353
+
354
+ change_has_external_config_risk() {
355
+ local content
356
+ content="$(change_contract_docs_without_complexity_budget)"
357
+ grep -Eiq \
358
+ '第三方|外部平台|外部工具|外部集成|third[- ]party|external (platform|tool|integration|system)|SDK|MQ|Kafka|RocketMQ|TDMQ|callback|回调|webhook|支付渠道|payment gateway|cloud service|云服务' \
359
+ <<< "$content"
360
+ }
361
+
362
+ change_has_concurrency_idempotency_risk() {
363
+ grep -RIEiq \
364
+ '并发|批量下发|批量开通|批量续费|重复提交|重复回调|重复消费|重复下发|幂等|竞态|原子占用|concurren|idempoten|race condition|duplicate (request|callback|consumption|delivery)|atomic claim' \
365
+ "$CHANGE_DIR/proposal.md" \
366
+ "$CHANGE_DIR/api.md" \
367
+ "$CHANGE_DIR/design.md" \
368
+ "$CHANGE_DIR/tests.md" \
369
+ "$CHANGE_DIR/spec.md" \
370
+ "$CHANGE_DIR"/specs/*/spec.md 2>/dev/null
371
+ }
372
+
262
373
  change_has_money_precision_risk() {
263
374
  grep -RIEiq \
264
375
  '金额|费用|价格|优惠|折扣|抵扣|退款|分账|支付|发票|余额|电费|服务费|套餐结算|比例分摊|明细分配|尾差|精度|舍入|(^|[^[:alnum:]_])(amount|fee|fees|price|discount|deduction|refund|payment|invoice|balance|proration|allocation|reconciliation|rounding)([^[:alnum:]_]|$)|revenue sharing|profit sharing|split payment|serviceFee|chargeFee|totalAmount|actualAmount|payAmount|refundAmount|discountAmount|invoiceAmount|balanceAmount' \
@@ -282,9 +393,11 @@ change_has_fx_precision_risk() {
282
393
  }
283
394
 
284
395
  change_has_architecture_boundary_risk() {
285
- grep -RIEiq \
396
+ local content
397
+ content="$(change_all_docs_without_complexity_budget)"
398
+ grep -Eiq \
286
399
  '跨仓|跨服务|sibling|SDK|MQ|topic|consumer|scheduler|定时|device|设备|callback|回调|third[- ]party|第三方|mini[- ]program|小程序|gateway|网关|adapter|适配|protocol|协议|interconnect|互联互通|调用链|入口|出口' \
287
- "$CHANGE_DIR"/*.md "$CHANGE_DIR"/**/*.md 2>/dev/null
400
+ <<< "$content"
288
401
  }
289
402
 
290
403
  first_prompt_rel() {
@@ -325,6 +438,33 @@ require_external_enum_contract() {
325
438
  require_grep '不确定|阻塞|blocker|unknown|待确认' "$path" "$label unresolved/blocker column"
326
439
  }
327
440
 
441
+ require_external_config_contract() {
442
+ local path="$1"
443
+ local label="$2"
444
+ require_grep 'External Integration Configuration And Deployment Contract|外部集成配置与部署合同|外部配置.*部署合同' "$path" "$label"
445
+ require_grep '本地.*测试.*生产|local.*test.*production|local.*staging.*production' "$path" "$label environment matrix"
446
+ require_grep '注入|创建方式|provision|injection|IaC|Secret|控制台|console' "$path" "$label injection/provisioning"
447
+ require_grep '运行 owner|创建 owner|provisioning owner|runtime owner|owner.*时点|owner.*time' "$path" "$label owner and timing"
448
+ require_grep '就绪|readiness|消息轨迹|trace|health' "$path" "$label readiness evidence"
449
+ require_grep '回滚|rollback|禁用|disable' "$path" "$label rollback"
450
+ require_grep '密钥|凭据|secret|credential' "$path" "$label secret handling"
451
+ require_grep '不得.*硬编码|禁止.*硬编码|not.*hard.?cod|must not.*hard.?cod|do not hard.?code' "$path" "$label no hard-coded external config"
452
+ require_grep '测试.*生产|test.*production|staging.*production' "$path" "$label test-production distinction"
453
+ }
454
+
455
+ require_concurrency_idempotency_contract() {
456
+ local path="$1"
457
+ local label="$2"
458
+ require_grep 'Concurrency And Idempotency Ownership|并发与幂等归属|应用层原子占用' "$path" "$label"
459
+ require_grep '业务幂等键|business idempotency key|business key' "$path" "$label business idempotency key"
460
+ require_grep '应用层原子占用|application.layer atomic claim|atomic claim' "$path" "$label application-layer atomic claim"
461
+ require_grep '短事务|short transaction|事务边界|transaction boundary' "$path" "$label short transaction boundary"
462
+ require_grep '待处理|pending|成功|success|失败|failed|状态流转|state machine' "$path" "$label state machine"
463
+ require_grep '重试|retry' "$path" "$label retry contract"
464
+ require_grep '外部调用|external call|third.party call' "$path" "$label external-call boundary"
465
+ require_grep '唯一索引.*(不是|不得|不作为).*默认|unique index.*not.*default|do not.*default.*unique index' "$path" "$label unique index is not the default"
466
+ }
467
+
328
468
  require_money_precision_contract() {
329
469
  local path="$1"
330
470
  local label="$2"
@@ -379,6 +519,29 @@ require_money_precision_evidence() {
379
519
  fi
380
520
  }
381
521
 
522
+ require_minimal_design_review() {
523
+ local path="$1"
524
+ local label="$2"
525
+ require_grep '复杂度减法评审|反过度设计评审|Minimal Design Review|Complexity Reduction Review' "$path" "$label"
526
+ require_grep '复用|reuse|existing capability|existing module' "$path" "$label reuse evidence"
527
+ require_grep '最简|最小实现|simplest|minimum design|minimal implementation' "$path" "$label simplest implementation"
528
+ require_grep '删除|拒绝|不新增|移出范围|removed|rejected|do not add|out of scope' "$path" "$label removed or rejected complexity"
529
+ require_grep '新增项统计|复杂度预算|New-item counts|Complexity budget' "$path" "$label complexity budget"
530
+ require_grep '表|table' "$path" "$label table count"
531
+ require_grep '字段|field' "$path" "$label field count"
532
+ require_grep 'API' "$path" "$label API count"
533
+ require_grep 'Service|服务|组件|service|component' "$path" "$label service/component count"
534
+ require_grep '缓存|cache' "$path" "$label cache count"
535
+ require_grep 'MQ|事件|异步|event|async' "$path" "$label async/event count"
536
+ require_grep '定时任务|scheduled job|scheduler' "$path" "$label scheduled-job count"
537
+ require_grep '兼容层|compatibility layer' "$path" "$label compatibility-layer count"
538
+ }
539
+
540
+ require_minimal_design_pass() {
541
+ local path="$1"
542
+ require_grep '(复杂度减法评审|反过度设计评审|Minimal Design Review|Complexity Reduction Review).*(PASS|通过)|(PASS|通过).*(复杂度减法评审|反过度设计评审|Minimal Design Review|Complexity Reduction Review)' "$path" "complexity reduction review PASS verdict"
543
+ }
544
+
382
545
  transition_event=""
383
546
 
384
547
  if [[ -x "$VALIDATE" && -f "$CHANGE_DIR/.sdd/state.yaml" ]]; then
@@ -408,10 +571,23 @@ case "$PHASE" in
408
571
  require_grep 'RED|红绿|GREEN' tests.md "RED/GREEN test contract"
409
572
  require_grep 'curl|Postman|Newman|pytest|RestAssured|自动化命令' tests.md "interface automation command"
410
573
  require_grep 'handoff_hash|sdd-context|上下文包|防漂移' sdd-quality-gate.md "handoff/context-drift gate"
574
+ workflow="$(state_get workflow)"
575
+ if [[ "$workflow" == "full" ]]; then
576
+ require_minimal_design_review design.md "complexity reduction review"
577
+ require_grep '复杂度减法评审|反过度设计评审|Minimal Design Review|Complexity Reduction Review' sdd-quality-gate.md "complexity reduction quality gate"
578
+ require_minimal_design_pass sdd-quality-gate.md
579
+ fi
411
580
  if change_has_external_enum_risk; then
412
581
  require_external_enum_contract api.md "external enum binding contract"
413
582
  require_external_enum_contract sdd-quality-gate.md "external enum binding quality gate"
414
583
  fi
584
+ if change_has_external_config_risk; then
585
+ require_external_config_contract api.md "external integration configuration contract"
586
+ require_external_config_contract sdd-quality-gate.md "external integration deployment gate"
587
+ fi
588
+ if change_has_concurrency_idempotency_risk; then
589
+ require_concurrency_idempotency_contract sdd-quality-gate.md "concurrency and idempotency ownership quality gate"
590
+ fi
415
591
  if change_has_money_precision_risk; then
416
592
  require_grep 'Money Precision Boundary|金额精度边界' sdd-quality-gate.md "money precision quality gate"
417
593
  fi
@@ -436,6 +612,9 @@ case "$PHASE" in
436
612
  require_hash_recorded
437
613
  workflow="$(state_get workflow)"
438
614
  if [[ "$workflow" == "full" ]]; then
615
+ require_minimal_design_review design.md "complexity reduction review"
616
+ require_grep '复杂度减法评审|反过度设计评审|Minimal Design Review|Complexity Reduction Review' sdd-quality-gate.md "complexity reduction quality gate"
617
+ require_minimal_design_pass sdd-quality-gate.md
439
618
  require_optional_state_path technical_design "technical_design"
440
619
  technical_design_rel="$(state_get technical_design)"
441
620
  if [[ -n "${technical_design_rel:-}" && "$technical_design_rel" != "null" ]]; then
@@ -450,9 +629,16 @@ case "$PHASE" in
450
629
  if change_has_external_enum_risk; then
451
630
  require_external_enum_contract "$technical_design_rel" "external enum binding matrix"
452
631
  fi
632
+ if change_has_external_config_risk; then
633
+ require_external_config_contract "$technical_design_rel" "external integration configuration and deployment contract"
634
+ fi
635
+ if change_has_concurrency_idempotency_risk; then
636
+ require_concurrency_idempotency_contract "$technical_design_rel" "concurrency and idempotency ownership contract"
637
+ fi
453
638
  if change_has_money_precision_risk; then
454
639
  require_money_precision_contract "$technical_design_rel" "money precision boundary"
455
640
  fi
641
+ require_minimal_design_review "$technical_design_rel" "technical design minimal design review"
456
642
  fi
457
643
  fi
458
644
  require_grep 'Superpowers Technical Design Handoff|Superpower 技术详设|technical_design|源码级 HOW' design.md "Superpowers technical design handoff"
@@ -481,6 +667,12 @@ case "$PHASE" in
481
667
  if change_has_external_enum_risk; then
482
668
  require_external_enum_contract "$prompt_rel" "prompt external enum binding inheritance"
483
669
  fi
670
+ if change_has_external_config_risk; then
671
+ require_external_config_contract "$prompt_rel" "prompt external integration configuration inheritance"
672
+ fi
673
+ if change_has_concurrency_idempotency_risk; then
674
+ require_concurrency_idempotency_contract "$prompt_rel" "prompt concurrency and idempotency ownership inheritance"
675
+ fi
484
676
  if change_has_money_precision_risk; then
485
677
  require_money_precision_contract "$prompt_rel" "prompt money precision inheritance"
486
678
  fi
@@ -503,6 +695,7 @@ case "$PHASE" in
503
695
  ;;
504
696
  verify)
505
697
  require_state_file
698
+ require_tasks_complete
506
699
  require_file test-report.md
507
700
  require_grep 'RED|失败证据' test-report.md "RED evidence"
508
701
  require_grep 'GREEN|通过证据' test-report.md "GREEN evidence"
@@ -512,10 +705,21 @@ case "$PHASE" in
512
705
  if change_has_external_enum_risk; then
513
706
  require_grep 'External Enum Binding|外部枚举绑定|第三方字段语义绑定|外部展示|展示文案|业务语义|财务语义|BEM|真实入口' test-report.md "external enum binding runtime evidence"
514
707
  fi
708
+ if change_has_external_config_risk; then
709
+ require_grep 'External Integration Configuration And Deployment Contract|外部集成配置与部署合同' test-report.md "external integration configuration runtime evidence"
710
+ require_grep '生产.*就绪|production.*ready|provision.*verified|资源.*存在|resource.*exists' test-report.md "external production readiness evidence"
711
+ fi
712
+ if change_has_concurrency_idempotency_risk; then
713
+ require_grep 'Concurrency And Idempotency Ownership|并发与幂等归属|应用层原子占用' test-report.md "concurrency and idempotency runtime evidence"
714
+ require_grep '并发|concurren|重复|duplicate|重试|retry' test-report.md "concurrency duplicate and retry cases"
715
+ fi
515
716
  if change_has_money_precision_risk; then
516
717
  require_money_precision_evidence test-report.md "money precision runtime evidence"
517
718
  fi
518
719
  require_test_report_lint
720
+ require_closeout_markers "$CHANGE_DIR/test-report.md"
721
+ require_branch_handled
722
+ require_full_verification_fingerprint
519
723
  require_markdown_links_valid
520
724
  if [[ "$(state_get verification_report)" == "" || "$(state_get verification_report)" == "null" ]]; then
521
725
  "$STATE" set "$CHANGE_DIR" verification_report test-report.md
@@ -524,11 +728,20 @@ case "$PHASE" in
524
728
  ;;
525
729
  archive)
526
730
  require_state_file
731
+ require_tasks_complete
527
732
  verify_result="$(state_get verify_result)"
528
733
  [[ "$verify_result" == "pass" ]] || issues+=("verify_result must be pass before archive")
529
734
  archived="$(state_get archived)"
530
735
  [[ "$archived" != "true" ]] || issues+=("archived is already true")
531
736
  require_state_value verification_report "verification_report"
737
+ report_path="$(verification_report_path || true)"
738
+ if [[ -z "$report_path" ]]; then
739
+ issues+=("verification_report path does not exist")
740
+ else
741
+ require_closeout_markers "$report_path"
742
+ fi
743
+ require_branch_handled
744
+ require_state_value verified_at "verified_at"
532
745
  transition_event="archived"
533
746
  ;;
534
747
  *)
@@ -111,6 +111,13 @@ Before pass:
111
111
  complement.
112
112
  7. Branch/worktree status is handled and `.sdd/state.yaml` has:
113
113
  `branch_status: handled`.
114
+ 8. Every checkbox in `tasks.md` is checked. A completed implementation with
115
+ stale task documentation is a verification failure, not an archive-time
116
+ cleanup item.
117
+ 9. `test-report.md` ends with the machine-checkable closeout markers
118
+ `验证结果: PASS` and `归档就绪: PASS`. For `verify_mode: full`, it also
119
+ records the test environment, branch/commit/build or image fingerprint,
120
+ Base URL, and verification timestamp.
114
121
 
115
122
  Only then run:
116
123
 
@@ -22,6 +22,20 @@ When ready to implement, run /opsx:apply
22
22
 
23
23
  **Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
24
24
 
25
+ ### Canonical OpenSpec Change Directory (Blocking)
26
+
27
+ - A change must have exactly one physical directory:
28
+ `openspec/changes/<name>/`.
29
+ - Encode the release version in `<name>`. For example, an account-permission
30
+ change for `v1.1.1` must use `v1-1-1-account-permission-optimization`.
31
+ - Do not create nested version directories such as
32
+ `openspec/changes/v1.1.1/<feature>/`.
33
+ - Do not create a flat symlink, copied directory, or second canonical document
34
+ tree to work around OpenSpec CLI discovery.
35
+ - Creation, status, validation, and apply must use the same `<name>` in
36
+ `openspec new change`, `openspec status --change`, and
37
+ `openspec validate <name> --strict`.
38
+
25
39
  **Steps**
26
40
 
27
41
  1. **If no clear input provided, ask what they want to build**
@@ -14,6 +14,10 @@ do not mark archived until the user confirms final closeout.
14
14
  - `phase: archive`.
15
15
  - `verify_result: pass`.
16
16
  - `verification_report` points to an existing report.
17
+ - Every checkbox in `tasks.md` is checked.
18
+ - The verification report contains `Verification Result: PASS` and
19
+ `Archive Readiness: PASS`.
20
+ - `branch_status: handled` and `verified_at` are recorded.
17
21
  - `superflow-state.sh recover <change-dir>` gives a coherent archive recovery action.
18
22
 
19
23
  ## Procedure
@@ -42,6 +46,8 @@ do not mark archived until the user confirms final closeout.
42
46
  the user explicitly accepts the boundary.
43
47
  - Do not use archive to hide missing API, DB, hook, SQL, test-report, or real
44
48
  integration evidence.
49
+ - Never call `openspec archive` directly to bypass the lifecycle gate. The
50
+ installed archive-command hook blocks that path when native hooks are active.
45
51
  - In a standard `openspec/changes/<name>` layout, archive must use OpenSpec
46
52
  archive semantics so delta specs are merged and the change is moved to
47
53
  `openspec/changes/archive/`. State-only archive is only a fallback for
@@ -50,6 +50,15 @@ any full SDD document or implementation prompt is generated.
50
50
  external input. If semantics are unclear, mark the feature blocked instead of
51
51
  inventing a fallback.
52
52
  - Process one feature at a time, in product-document order.
53
+ - When the pipeline selected embedded deep-clarification mode, investigate facts
54
+ from the repository, source documents, configuration, tests, logs, and tools
55
+ before asking. Ask the user only about an unresolved decision that needs owner
56
+ intent; do not ask for facts that can be found locally.
57
+ - In embedded deep-clarification mode, ask exactly one decision question at a
58
+ time. Include the recommended answer and its important consequence, wait for
59
+ the answer, then record the result before asking the next question. Do not
60
+ create SDD artifacts or implementation prompts while a current-feature
61
+ decision remains pending.
53
62
  - For long PRDs, Lark/Feishu exports, screenshots, or mixed product docs, do
54
63
  not read the whole document and generate all tasks in one pass. First create
55
64
  a source index, then process one bounded section or feature at a time. Each
@@ -85,6 +94,10 @@ Create or update these files in the active OpenSpec change directory:
85
94
  - Business semantic evidence when status/enum/sync/default behavior is involved:
86
95
  source-of-truth field, enum mapping, consumer interpretation, business basis,
87
96
  explicitly rejected fallback/default choices, and unresolved owner questions.
97
+ - Deep-clarification decision evidence when this mode is active: each question,
98
+ recommendation, user decision, consequence, and the resulting
99
+ `confirmed`/`candidate`/`pending`/`rejected` entry in
100
+ `.sdd/handoff/brainstorm-summary.md`.
88
101
 
89
102
  Use the detailed workflow in:
90
103
 
@@ -127,14 +140,20 @@ Use the detailed workflow in:
127
140
  If a proposed default, fallback, old-value retention, or null conversion is
128
141
  not explicitly approved by the requirement or owner, mark it rejected and do
129
142
  not include it in the design.
130
- 11. Ask only current-feature clarification questions.
131
- 12. Wait for programmer confirmation.
132
- 13. Draft a rough API contract: path, action, core request, core response. Field types can be approximate.
133
- 14. Wait for programmer confirmation of the rough API.
134
- 15. Produce a precise API section with field names, types, requiredness, defaults, enums, errors, examples, and curl.
135
- 16. Mark the feature as `frozen` only when understanding, rough API, precise API,
143
+ 11. If embedded deep-clarification mode is active, resolve one decision at a
144
+ time. For each question, state the recommended answer and consequence, wait
145
+ for the programmer response, then update
146
+ `.sdd/handoff/brainstorm-summary.md` under `confirmed`, `candidate`,
147
+ `pending`, or `rejected`. Stop asking once only repository-verifiable facts
148
+ remain.
149
+ 12. Ask only any remaining current-feature clarification questions.
150
+ 13. Wait for programmer confirmation.
151
+ 14. Draft a rough API contract: path, action, core request, core response. Field types can be approximate.
152
+ 15. Wait for programmer confirmation of the rough API.
153
+ 16. Produce a precise API section with field names, types, requiredness, defaults, enums, errors, examples, and curl.
154
+ 17. Mark the feature as `frozen` only when understanding, rough API, precise API,
136
155
  and validation data needs are confirmed or explicitly blocked.
137
- 17. Only after the current feature is frozen or blocked, move to the next
156
+ 18. Only after the current feature is frozen or blocked, move to the next
138
157
  indexed feature. Do not batch-confirm multiple features from memory or a
139
158
  compressed chat summary.
140
159
 
@@ -46,7 +46,17 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
46
46
  4. Write:
47
47
  `docs/superpowers/specs/YYYY-MM-DD-<change-id>-technical-design.md`
48
48
  using `../superflow-pipeline/references/superpower-technical-design-template.md`.
49
- 5. For cross-repository, service-to-service, SDK, MQ, scheduler, device,
49
+ 5. Complete `Minimal Design Review` before expanding source-level HOW. For
50
+ every new table, field, API, service/component, abstraction, cache,
51
+ async/MQ/event flow, scheduled job, or compatibility layer, prove existing
52
+ reuse options, necessity, and why the simplest direct implementation is
53
+ insufficient. Prefer one owner, one write path, one transaction, and
54
+ set-based operations when they satisfy the contract. Remove speculative
55
+ extension points, duplicate DTO/API layers, derivable persistence,
56
+ premature caches, and async compensation without measured need. Record
57
+ retained and removed counts; unresolved simpler alternatives keep the
58
+ design blocked.
59
+ 6. For cross-repository, service-to-service, SDK, MQ, scheduler, device,
50
60
  callback, third-party, mini-program, gateway, or adapter changes, include
51
61
  `Architecture Boundary And Call Direction`. Prove owner module, call
52
62
  direction, existing entry/exit points, proposed entry/exit points, evidence
@@ -54,10 +64,32 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
54
64
  adapter/protocol translator/device gateway into a business-entry
55
65
  orchestrator, stop and return to `$superflow-docs` unless the OpenSpec/SDD
56
66
  contract explicitly grants that ownership with approval evidence.
57
- 6. For field/status/enum/sync changes, include `Field And Status Reverse
67
+ 7. For third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment
68
+ gateways, cloud services, or other external integrations, include
69
+ `External Integration Configuration And Deployment Contract`. Inventory
70
+ every endpoint, app/tenant/project ID, Topic, Tag, Consumer Group,
71
+ namespace, webhook, ACL/role, feature switch, timeout, and credential
72
+ reference. Prove the source and injection/provisioning method for local,
73
+ test, and production environments, plus owner, creation timing, readiness
74
+ check, rollback, and unresolved blockers. Runtime values and server-side
75
+ resources must not exist only as hard-coded annotations/constants. Test
76
+ auto-creation or pre-existing resources must not be treated as proof that
77
+ production will provision them. Missing production provisioning evidence
78
+ blocks design completion.
79
+ 8. For concurrent requests, batch issue/activation/renewal, duplicate callbacks,
80
+ duplicate consumption, or repeated external delivery, include
81
+ `Concurrency And Idempotency Ownership`. Use a stable business idempotency
82
+ key and an application-layer atomic claim in a short transaction; persist
83
+ `PENDING` before the external call, release database locks before calling
84
+ externally, model success/failure/uncertain states, and reuse the original
85
+ business code on retry. A unique index is not the default and may only be an
86
+ optional fallback with proven natural uniqueness, historical cleanup,
87
+ NULL/soft-delete semantics, and a conflict contract. Check-then-insert,
88
+ process-local locks, and random IDs alone are blocked.
89
+ 9. For field/status/enum/sync changes, include `Field And Status Reverse
58
90
  Impact` and prove writers, readers, filters, derived sync paths, consumers,
59
91
  and tests. Direct setter-only design is blocked.
60
- 7. For amount, fee, discount, deduction, refund, sharing, payment, invoice,
92
+ 10. For amount, fee, discount, deduction, refund, sharing, payment, invoice,
61
93
  balance, electricity fee, service fee, package settlement, proration,
62
94
  allocation, reconciliation, or financial display changes,
63
95
  include `Money Precision Boundary`. Prove calculation-state fields,
@@ -76,12 +108,12 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
76
108
  level and policy source, deterministic residual strategy with stable
77
109
  tie-breaker, and positive/zero/negative evidence. For FX changes, freeze the
78
110
  directional rate metadata and one canonical conversion path.
79
- 8. Record state:
111
+ 11. Record state:
80
112
  ```bash
81
113
  ../superflow-pipeline/scripts/superflow-state.sh set <change-dir> technical_design docs/superpowers/specs/YYYY-MM-DD-<change-id>-technical-design.md
82
114
  ../superflow-pipeline/scripts/superflow-state.sh set <change-dir> design_doc design.md
83
115
  ```
84
- 9. Update `design.md` with `Superpowers Technical Design Handoff`, update
116
+ 12. Update `design.md` with `Superpowers Technical Design Handoff`, update
85
117
  `sdd-quality-gate.md` with the technical design path and hash, then run
86
118
  `../superflow-pipeline/scripts/superflow-handoff.sh <change-dir> --refresh`.
87
119
  If the guard reports a stale or missing hash, record the printed hash in
@@ -89,7 +121,7 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
89
121
  `--refresh` again. Do not set `design_doc` to the Superpowers document;
90
122
  `design_doc` is the OpenSpec/SDD contract design, while `technical_design`
91
123
  is the Superpowers HOW document.
92
- 10. Run:
124
+ 13. Run:
93
125
  ```bash
94
126
  ../superflow-pipeline/scripts/superflow-yaml-validate.sh <change-dir>
95
127
  ../superflow-pipeline/scripts/superflow-guard.sh <change-dir> design --apply
@@ -76,6 +76,17 @@ For complex requirements, verify these before writing docs:
76
76
  If the docs only prove that a value exists, is non-null, or lets the request
77
77
  succeed, stop and return to `$superflow-clarify`. If fallback/default/keep-old-value
78
78
  behavior is proposed without explicit requirement or owner approval, stop.
79
+ - For third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment gateways,
80
+ cloud services, or other external integrations, `api.md` and
81
+ `sdd-quality-gate.md` must include `External Integration Configuration And
82
+ Deployment Contract`. Inventory endpoints, app/tenant/project IDs,
83
+ Topic/Tag/Consumer Group, namespace, webhook, ACL/role, feature switches,
84
+ timeout, and credential references across local, test, and production
85
+ environments. Record injection/provisioning method, runtime owner,
86
+ provisioning owner/time, readiness evidence, rollback, secret handling, and
87
+ blockers. Environment-dependent values must not be hard-coded; test
88
+ auto-creation or existing test resources do not prove production readiness.
89
+ Missing production provisioning evidence blocks document freeze.
79
90
  - For amount, fee, discount, deduction, refund, sharing, payment, invoice,
80
91
  balance, electricity/service fee, package settlement, proration, allocation,
81
92
  reconciliation, or financial display changes, `sdd-quality-gate.md` must
@@ -92,6 +103,17 @@ For complex requirements, verify these before writing docs:
92
103
  chain, no-fallback/no-guessing boundary, and pre-coding agent self-check. If
93
104
  any gate is missing from `design.md`, `tests.md`, or quality gate, stop and
94
105
  complete the docs first.
106
+ - For full workflow changes, `design.md` must include a `Minimal Design Review`
107
+ before docs freeze. Inventory every proposed table, field, API,
108
+ service/component, cache, async/MQ/event flow, scheduled job, compatibility
109
+ layer, and abstraction. Record existing reuse evidence, necessity, the
110
+ simplest implementation, removed/rejected complexity, and blockers.
111
+ Prefer extending current modules and synchronous transactions. Do not keep a
112
+ layer only for hypothetical future flexibility; remove it without evidence.
113
+ - `sdd-quality-gate.md` must record the minimal-design verdict as `PASS` or
114
+ `BLOCKED`; only `PASS` may leave docs/design. Missing reuse evidence, parallel APIs/models, redundant persisted
115
+ fields, speculative cache/async/compensation, or an unresolved simpler option
116
+ blocks docs completion.
95
117
  - `design.md` stays the OpenSpec/SDD design contract: requirement mapping,
96
118
  API/DB/field semantics, source facts, real-entry call chain, no-fallback
97
119
  boundary, risks, and acceptance hooks. It must not try to own all source-level
@@ -240,6 +262,11 @@ Use references only as needed:
240
262
  the relationship judgment as `confirmed/partially confirmed/unknown` when a bug fix hinges on
241
263
  existing data or call-chain behavior.
242
264
  - `design.md` must reference the frozen `api.md` fields and errors.
265
+ - `design.md` must include `Minimal Design Review` with:
266
+ `Design item | Existing capability/reuse evidence | Necessary? | Simplest implementation | Removed/rejected complexity | Evidence/blocker`.
267
+ Count new tables, fields, APIs, services/components, caches, async flows,
268
+ jobs, and compatibility layers. A zero count is valid and preferred when
269
+ existing capabilities close the contract.
243
270
  - `design.md` must include a "Field Semantic Contract" table for every risky field:
244
271
  `Field | Source table/DTO/event | Real semantics | Target field | Target semantics | Equivalent? |
245
272
  Evidence anchor | Forbidden usage | Unknowns/owner`.