@chenmk/superflow 0.2.5 → 0.3.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 (55) hide show
  1. package/README.md +4 -1
  2. package/README.zh-CN.md +1 -0
  3. package/assets/manifest.json +3 -1
  4. package/assets/prompts/superflow-clarify.md +6 -0
  5. package/assets/prompts/superflow-pipeline.md +8 -0
  6. package/assets/scripts/superflow-archive-command-hook.sh +80 -0
  7. package/assets/scripts/superflow-delivery-check.sh +23 -4
  8. package/assets/skills/superflow-archive/SKILL.md +5 -0
  9. package/assets/skills/superflow-clarify/SKILL.md +26 -7
  10. package/assets/skills/superflow-design/SKILL.md +28 -6
  11. package/assets/skills/superflow-docs/SKILL.md +11 -0
  12. package/assets/skills/superflow-pipeline/SKILL.md +29 -0
  13. package/assets/skills/superflow-pipeline/references/api-design-template.md +11 -0
  14. package/assets/skills/superflow-pipeline/references/batch-prompt-template.md +27 -0
  15. package/assets/skills/superflow-pipeline/references/implementation-prompt-template.md +29 -1
  16. package/assets/skills/superflow-pipeline/references/quality-gate.md +2 -0
  17. package/assets/skills/superflow-pipeline/references/superpower-technical-design-template.md +41 -0
  18. package/assets/skills/superflow-pipeline/references/test-execution-template.md +10 -0
  19. package/assets/skills/superflow-pipeline/scripts/superflow-guard.sh +143 -0
  20. package/assets/skills/superflow-verify/SKILL.md +7 -0
  21. package/assets/skills-en/superflow-archive/SKILL.md +6 -0
  22. package/assets/skills-en/superflow-clarify/SKILL.md +26 -7
  23. package/assets/skills-en/superflow-design/SKILL.md +27 -5
  24. package/assets/skills-en/superflow-docs/SKILL.md +11 -0
  25. package/assets/skills-en/superflow-pipeline/SKILL.md +28 -0
  26. package/assets/skills-en/superflow-pipeline/references/api-design-template.md +13 -0
  27. package/assets/skills-en/superflow-pipeline/references/batch-prompt-template.md +16 -0
  28. package/assets/skills-en/superflow-pipeline/references/implementation-prompt-template.md +17 -0
  29. package/assets/skills-en/superflow-pipeline/references/quality-gate.md +17 -0
  30. package/assets/skills-en/superflow-pipeline/references/superpower-technical-design-template.md +46 -0
  31. package/assets/skills-en/superflow-pipeline/references/test-execution-template.md +12 -0
  32. package/assets/skills-en/superflow-pipeline/scripts/superflow-guard.sh +143 -0
  33. package/assets/skills-en/superflow-verify/SKILL.md +8 -0
  34. package/dist/app/commands/archive.js +7 -3
  35. package/dist/app/commands/archive.js.map +1 -1
  36. package/dist/app/commands/change-guard.js +27 -0
  37. package/dist/app/commands/change-guard.js.map +1 -0
  38. package/dist/app/commands/design.js +2 -20
  39. package/dist/app/commands/design.js.map +1 -1
  40. package/dist/app/commands/init.js +1 -5
  41. package/dist/app/commands/init.js.map +1 -1
  42. package/dist/app/commands/update.js +2 -5
  43. package/dist/app/commands/update.js.map +1 -1
  44. package/dist/app/commands/verify.js +7 -3
  45. package/dist/app/commands/verify.js.map +1 -1
  46. package/dist/domains/config/context.js +1 -5
  47. package/dist/domains/config/context.js.map +1 -1
  48. package/dist/domains/deps.js +1 -5
  49. package/dist/domains/deps.js.map +1 -1
  50. package/dist/domains/hook.js +1 -0
  51. package/dist/domains/hook.js.map +1 -1
  52. package/dist/platform/assets.js +9 -0
  53. package/dist/platform/assets.js.map +1 -0
  54. package/package.json +3 -2
  55. package/scripts/release-notes-check.js +102 -0
package/README.md CHANGED
@@ -206,7 +206,10 @@ hook registration is not enabled for OpenCode yet; use `/superflow-*` commands
206
206
  to run workflow gates explicitly.
207
207
 
208
208
  For large requirements, ask the agent to read one section or one feature at a
209
- time. SuperBridge Flow will route through clarification, OpenSpec docs,
209
+ time. The total router automatically uses embedded deep clarification when a
210
+ feature needs an owner decision; it investigates available facts first and asks
211
+ one decision at a time with a recommendation. Clear, bounded work continues
212
+ without an interview. SuperBridge Flow then routes through OpenSpec docs,
210
213
  Superpowers technical design, implementation prompts, verification, and archive.
211
214
 
212
215
  ## Automatic Update Checks
package/README.zh-CN.md CHANGED
@@ -121,6 +121,7 @@ superflow init
121
121
  - Superpowers 负责 HOW:源码级技术详设、TDD/RED 顺序、团队分工、worktree/端口并行、review/tester 编排和验证闭环。
122
122
  - 完整流程是 `docs -> design -> implement -> verify -> archive`。Superpowers 技术详设落到 `docs/superpowers/specs/*-technical-design.md`,并记录到 `.sdd/state.yaml` 的 `technical_design`,避免长会话压缩后漂移。
123
123
  - Codex 侧通常用自然语言或 `$superflow-pipeline` 触发;Claude Code 侧可以直接用 `/superflow-pipeline`、`/superflow-docs`、`/superflow-design` 等 slash command。
124
+ - 只说一句话触发总路由时,遇到需要业务负责人选择的关键分歧,SuperFlow 会在 clarify 阶段自动进入深度澄清:先查代码和已有资料能确认的事实,再一次只问一个决策问题,并给出推荐方案与影响。明确、范围小的改动不会被强行拉进问答流程。
124
125
  - 飞书、语雀等在线文档读取工具不内置在 SuperBridge Flow CLI 中;可自行用 `lark-cli` 等外部工具读取,再通过 `/superflow-pipeline` 或 `$superflow-pipeline` 分段分析指定小节。
125
126
 
126
127
  ## 命令
@@ -29,6 +29,7 @@
29
29
  "superflow-hook-guard.sh",
30
30
  "superflow-dependency-update-hook.sh",
31
31
  "superflow-integration-evidence-hook.sh",
32
+ "superflow-archive-command-hook.sh",
32
33
  "superflow-test-report-lint.py",
33
34
  "install-sql-pre-commit.sh",
34
35
  "sync-settings-json.py"
@@ -45,7 +46,8 @@
45
46
  "superflow-dependency-update-hook.sh",
46
47
  "superflow-sql-sync-hook.py",
47
48
  "superflow-delivery-check.sh",
48
- "superflow-integration-evidence-hook.sh"
49
+ "superflow-integration-evidence-hook.sh",
50
+ "superflow-archive-command-hook.sh"
49
51
  ],
50
52
  "agentHooks": {
51
53
  "claude": ["claude-auto-backup-hook.sh"],
@@ -8,3 +8,9 @@ Use the `superflow-clarify` skill for this request.
8
8
  Read the requested source in bounded sections, freeze one feature or section at
9
9
  a time, and stop for missing product/API/DB facts before OpenSpec artifacts are
10
10
  created.
11
+
12
+ If the total router selected embedded deep clarification, establish facts from
13
+ the repository and supplied sources before asking. Ask one unresolved owner
14
+ decision at a time, include a recommended answer and consequence, wait for the
15
+ response, and record the result in the existing brainstorm handoff before moving
16
+ on. Do not turn clear, bounded work into an interview.
@@ -9,5 +9,13 @@ Route the work through the correct SuperBridge Flow phase. OpenSpec owns WHAT
9
9
  and contracts; Superpowers owns source-level HOW. Preserve handoff state and run
10
10
  the required SuperBridge Flow guards before phase transitions.
11
11
 
12
+ When the request has unresolved decisions that need owner intent, competing
13
+ approaches, unclear source of truth, unclear acceptance behavior, or cross-system
14
+ responsibility, enter the embedded deep-clarification mode of
15
+ `superflow-clarify`. Investigate repository-verifiable facts first, then ask one
16
+ decision question at a time with a recommended answer and consequence. Keep the
17
+ decision record in the existing brainstorm handoff. Do not require the user to
18
+ invoke another command, and do not use this mode for a clear bounded change.
19
+
12
20
  Input: treat the argument after `/superflow-pipeline` as the requirement,
13
21
  document path, or change description.
@@ -0,0 +1,80 @@
1
+ #!/bin/bash
2
+ # Blocks direct OpenSpec/Superflow archive commands that bypass lifecycle gates.
3
+
4
+ set -u
5
+
6
+ INPUT=$(cat)
7
+
8
+ read_json_field() {
9
+ local field="$1"
10
+ printf '%s' "$INPUT" | python3 -c "
11
+ import json, sys
12
+ try:
13
+ data = json.load(sys.stdin)
14
+ except Exception:
15
+ print('')
16
+ raise SystemExit
17
+ tool_input = data.get('tool_input', {})
18
+ print(tool_input.get('$field') or tool_input.get('cmd') or '')
19
+ " 2>/dev/null
20
+ }
21
+
22
+ COMMAND=$(read_json_field command)
23
+ [ -n "$COMMAND" ] || exit 0
24
+
25
+ CHANGE=$(printf '%s' "$COMMAND" | python3 -c '
26
+ import shlex, sys
27
+
28
+ try:
29
+ tokens = shlex.split(sys.stdin.read())
30
+ except ValueError:
31
+ raise SystemExit
32
+
33
+ for index in range(len(tokens) - 1):
34
+ binary = tokens[index].rsplit("/", 1)[-1]
35
+ if binary not in {"openspec", "superflow"} or tokens[index + 1] != "archive":
36
+ continue
37
+ skip_value = False
38
+ for token in tokens[index + 2:]:
39
+ if skip_value:
40
+ skip_value = False
41
+ continue
42
+ if token in {"--store", "--agent"}:
43
+ skip_value = True
44
+ continue
45
+ if token.startswith("-"):
46
+ continue
47
+ print(token)
48
+ raise SystemExit
49
+ ' 2>/dev/null)
50
+
51
+ [ -n "$CHANGE" ] || exit 0
52
+
53
+ CWD=$(read_json_field cwd)
54
+ [ -n "$CWD" ] || CWD=$(pwd)
55
+ REPO_ROOT=$(git -C "$CWD" rev-parse --show-toplevel 2>/dev/null) || exit 0
56
+
57
+ if [ -d "$CWD/$CHANGE" ]; then
58
+ CHANGE_DIR="$CWD/$CHANGE"
59
+ else
60
+ CHANGE_DIR="$REPO_ROOT/openspec/changes/$CHANGE"
61
+ fi
62
+
63
+ [ -d "$CHANGE_DIR" ] || exit 0
64
+
65
+ ARCHIVE_SCRIPT=${SUPERFLOW_ARCHIVE_SCRIPT:-$HOME/.codex/skills/superflow-pipeline/scripts/superflow-archive.sh}
66
+ if [ ! -x "$ARCHIVE_SCRIPT" ]; then
67
+ echo "[Superflow 归档门禁] 归档脚本不存在或不可执行:$ARCHIVE_SCRIPT" >&2
68
+ exit 2
69
+ fi
70
+
71
+ if ! "$ARCHIVE_SCRIPT" "$CHANGE_DIR" --dry-run; then
72
+ cat <<'BLOCK_MSG' >&2
73
+ [Superflow 归档门禁] 归档门禁未通过,已阻止直接归档。
74
+ 请先完成 tasks、test-report、测试环境证据、verify 状态和归档确认;
75
+ 不要用 openspec archive 绕过 Superflow 生命周期。
76
+ BLOCK_MSG
77
+ exit 2
78
+ fi
79
+
80
+ exit 0
@@ -52,27 +52,46 @@ if [ -z "$CHANGED" ]; then
52
52
  exit 0
53
53
  fi
54
54
 
55
+ ACTIVE_SDD_CHANGED=$(printf '%s\n' "$CHANGED" | grep -Ev \
56
+ '(^|/)(doc/)?openspec/changes/archive/' || true)
57
+
55
58
  SDD_ACTIVE=0
56
59
  if [ -f "$REPO_ROOT/.sdd-enforced" ]; then
57
60
  SDD_ACTIVE=1
58
61
  fi
59
62
 
63
+ if [ "$SDD_ACTIVE" -eq 0 ]; then
64
+ ACTIVE_STATE=$(find "$REPO_ROOT/openspec/changes" \
65
+ -path '*/archive/*' -prune -o \
66
+ -path '*/.sdd/state.yaml' -type f -print 2>/dev/null \
67
+ | while IFS= read -r state; do
68
+ phase=$(awk -F':' '$1=="phase"{gsub(/^[ \t]+|[ \t]+$/, "", $2); print $2}' "$state")
69
+ archived=$(awk -F':' '$1=="archived"{gsub(/^[ \t]+|[ \t]+$/, "", $2); print $2}' "$state")
70
+ if [ "$archived" != "true" ] && { [ "$phase" = "implement" ] || [ "$phase" = "verify" ]; }; then
71
+ printf '%s\n' "$state"
72
+ fi
73
+ done | head -n 1)
74
+ if [ -n "$ACTIVE_STATE" ]; then
75
+ SDD_ACTIVE=1
76
+ fi
77
+ fi
78
+
60
79
  RUNTIME_CHANGED=$(printf '%s\n' "$CHANGED" | grep -E \
61
80
  '(^|/)src/main/.*\.(java|xml|yml|yaml|properties)$|(^|/)mapper/.*\.xml$|(^|/)sql/.*\.sql$' || true)
62
81
 
63
82
  CODE_RUNTIME_CHANGED=$(printf '%s\n' "$CHANGED" | grep -E \
64
83
  '(^|/)src/main/.*\.(java|xml|yml|yaml|properties)$|(^|/)mapper/.*\.xml$' || true)
65
84
 
66
- P_DIRS=$(printf '%s\n' "$CHANGED" | sed -nE \
85
+ P_DIRS=$(printf '%s\n' "$ACTIVE_SDD_CHANGED" | sed -nE \
67
86
  's#^(.*embedded-changes/(p[0-9]+[^/]*))/.*$#\1#p' | sort -u)
68
87
 
69
- REPORTS=$(printf '%s\n' "$CHANGED" | grep -E \
88
+ REPORTS=$(printf '%s\n' "$ACTIVE_SDD_CHANGED" | grep -E \
70
89
  '(^|/)embedded-changes/p[0-9][^/]*/test-report\.md$|(^|/)test-report\.md$' || true)
71
90
 
72
- AGGREGATE_DOCS=$(printf '%s\n' "$CHANGED" | grep -E \
91
+ AGGREGATE_DOCS=$(printf '%s\n' "$ACTIVE_SDD_CHANGED" | grep -E \
73
92
  '(^|/)openspec/changes/[^/]+/(tasks|test-report|traceability-matrix|sdd-quality-gate|tests)\.md$|(^|/)doc/openspec/changes/[^/]+/(tasks|test-report|traceability-matrix|sdd-quality-gate|tests)\.md$' || true)
74
93
 
75
- SDD_DOCS_CHANGED=$(printf '%s\n' "$CHANGED" | grep -E \
94
+ SDD_DOCS_CHANGED=$(printf '%s\n' "$ACTIVE_SDD_CHANGED" | grep -E \
76
95
  '(^|/)(doc/)?openspec/changes/|(^|/)embedded-changes/p[0-9]' || true)
77
96
 
78
97
  AGGREGATE_ALLOWED=0
@@ -14,6 +14,9 @@ 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 `验证结果: PASS` and `归档就绪: PASS`.
19
+ - `branch_status: handled` and `verified_at` are recorded.
17
20
  - `superflow-state.sh recover <change-dir>` gives a coherent archive recovery action.
18
21
 
19
22
  ## Procedure
@@ -42,6 +45,8 @@ do not mark archived until the user confirms final closeout.
42
45
  the user explicitly accepts the boundary.
43
46
  - Do not use archive to hide missing API, DB, hook, SQL, test-report, or real
44
47
  integration evidence.
48
+ - Never call `openspec archive` directly to bypass the lifecycle gate. The
49
+ installed archive-command hook blocks that path when native hooks are active.
45
50
  - In a standard `openspec/changes/<name>` layout, archive must use OpenSpec
46
51
  archive semantics so delta specs are merged and the change is moved to
47
52
  `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 `已冻结` 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 `已冻结` 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
 
@@ -54,17 +54,39 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
54
54
  adapter/protocol translator/device gateway into a business-entry
55
55
  orchestrator, stop and return to `$superflow-docs` unless the OpenSpec/SDD
56
56
  contract explicitly grants that ownership with approval evidence.
57
- 6. For field/status/enum/sync changes, include `Field And Status Reverse
57
+ 6. For third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment
58
+ gateways, cloud services, or other external integrations, include
59
+ `External Integration Configuration And Deployment Contract`. Inventory
60
+ every endpoint, app/tenant/project ID, Topic, Tag, Consumer Group,
61
+ namespace, webhook, ACL/role, feature switch, timeout, and credential
62
+ reference. Prove the source and injection/provisioning method for local,
63
+ test, and production environments, plus owner, creation timing, readiness
64
+ check, rollback, and unresolved blockers. Runtime values and server-side
65
+ resources must not exist only as hard-coded annotations/constants. Test
66
+ auto-creation or pre-existing resources must not be treated as proof that
67
+ production will provision them. Missing production provisioning evidence
68
+ blocks design completion.
69
+ 7. For concurrent requests, batch issue/activation/renewal, duplicate callbacks,
70
+ duplicate consumption, or repeated external delivery, include
71
+ `Concurrency And Idempotency Ownership`. Use a stable business idempotency
72
+ key and an application-layer atomic claim in a short transaction; persist
73
+ `PENDING` before the external call, release database locks before calling
74
+ externally, model success/failure/uncertain states, and reuse the original
75
+ business code on retry. A unique index is not the default and may only be an
76
+ optional fallback with proven natural uniqueness, historical cleanup,
77
+ NULL/soft-delete semantics, and a conflict contract. Check-then-insert,
78
+ process-local locks, and random IDs alone are blocked.
79
+ 8. For field/status/enum/sync changes, include `Field And Status Reverse
58
80
  Impact` and prove writers, readers, filters, derived sync paths, consumers,
59
81
  and tests. Direct setter-only design is blocked.
60
- 7. For third-party, SDK, BEM/parking, payment/refund, financial display,
82
+ 9. For third-party, SDK, BEM/parking, payment/refund, financial display,
61
83
  source/origin, status sync, or external dictionary fields, include
62
84
  `External Enum Binding`. Prove local source fields/enums, external fields,
63
85
  external enum values, display/business/financial meaning, source evidence,
64
86
  owner confirmation, unresolved handling, and test evidence. A request
65
87
  succeeding or a field being non-null is not enough; unconfirmed values are
66
88
  blockers and must be returned to `$superflow-docs` or the user.
67
- 8. For amount, fee, discount, deduction, refund, sharing, payment, invoice,
89
+ 10. For amount, fee, discount, deduction, refund, sharing, payment, invoice,
68
90
  balance, electricity fee, service fee, package settlement, proration,
69
91
  allocation, reconciliation, or financial display changes,
70
92
  include `Money Precision Boundary`. Prove calculation-state fields,
@@ -83,12 +105,12 @@ Impact` and prove writers, readers, filters, derived sync paths, consumers,
83
105
  level and policy source, deterministic residual strategy with stable
84
106
  tie-breaker, and positive/zero/negative evidence. For FX changes, freeze the
85
107
  directional rate metadata and one canonical conversion path.
86
- 9. Record state:
108
+ 11. Record state:
87
109
  ```bash
88
110
  ../superflow-pipeline/scripts/superflow-state.sh set <change-dir> technical_design docs/superpowers/specs/YYYY-MM-DD-<change-id>-technical-design.md
89
111
  ../superflow-pipeline/scripts/superflow-state.sh set <change-dir> design_doc design.md
90
112
  ```
91
- 10. Update `design.md` with `Superpowers Technical Design Handoff`, update
113
+ 12. Update `design.md` with `Superpowers Technical Design Handoff`, update
92
114
  `sdd-quality-gate.md` with the technical design path and hash, then run
93
115
  `../superflow-pipeline/scripts/superflow-handoff.sh <change-dir> --refresh`.
94
116
  If the guard reports a stale or missing hash, record the printed hash in
@@ -96,7 +118,7 @@ Impact` and prove writers, readers, filters, derived sync paths, consumers,
96
118
  `--refresh` again. Do not set `design_doc` to the Superpowers document;
97
119
  `design_doc` is the OpenSpec/SDD contract design, while `technical_design`
98
120
  is the Superpowers HOW document.
99
- 11. Run:
121
+ 13. Run:
100
122
 
101
123
  ```bash
102
124
  ../superflow-pipeline/scripts/superflow-yaml-validate.sh <change-dir>
@@ -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
82
+ Integration Configuration And Deployment Contract`. Inventory endpoints,
83
+ app/tenant/project IDs, Topic/Tag/Consumer Group, namespace, webhook,
84
+ ACL/role, feature switches, timeout, and credential references across local,
85
+ test, and production environments. Record injection/provisioning method,
86
+ runtime owner, provisioning owner/time, readiness evidence, rollback, secret
87
+ handling, and blockers. Environment-dependent values must not be hard-coded;
88
+ test auto-creation or existing test resources do not prove production
89
+ readiness. Missing production provisioning evidence blocks document freeze.
79
90
  - For third-party, SDK, BEM/parking, payment/refund, financial display,
80
91
  source/origin, status sync, or external dictionary/enum fields, `api.md` and
81
92
  `sdd-quality-gate.md` must include `外部枚举绑定确认` / `External Enum
@@ -11,6 +11,12 @@ This is the lightweight SDD router. Do not load the whole SDD process when a sma
11
11
 
12
12
  - Use `$openspec-explore` when the user is still thinking through a requirement,
13
13
  wants to compare options, or needs codebase investigation before a change.
14
+ - Route to `$superflow-clarify` in embedded deep-clarification mode when the
15
+ user explicitly asks for rigorous questioning, or when a bounded feature has
16
+ unresolved owner decisions, mutually exclusive approaches, unclear source of
17
+ truth, unclear acceptance behavior, or cross-system responsibility. This is
18
+ a mode inside the normal clarify phase, not a separate command the user must
19
+ remember.
14
20
  - Use `$superflow-clarify` only when product inputs are complex and must be frozen one
15
21
  feature at a time before creating OpenSpec artifacts.
16
22
  - Long PRDs, Lark/Feishu exports, screenshot-heavy requirements, and mixed
@@ -49,6 +55,29 @@ This is the lightweight SDD router. Do not load the whole SDD process when a sma
49
55
  SQL change, status field, Mapper/XML query, or cross-repo shared table affects
50
56
  database-backed behavior.
51
57
 
58
+ ## Embedded Deep Clarification
59
+
60
+ When the router selects embedded deep clarification, follow these rules inside
61
+ `$superflow-clarify`:
62
+
63
+ - Do not activate it for a clear, bounded hotfix or tweak whose intended behavior
64
+ and acceptance result are already evidenced. Do not turn routine work into an
65
+ interview.
66
+ - Explore facts that can be established from the requirement, repository,
67
+ configuration, tests, logs, or available tools before asking the user. Ask only
68
+ for a decision the user or owner must make.
69
+ - Ask exactly one decision question at a time. State the recommended option and
70
+ its important consequence, then wait for the answer before the next question.
71
+ - After each answer, update `.sdd/handoff/brainstorm-summary.md` with
72
+ `confirmed`, `candidate`, `pending`, and `rejected` entries. Do not rely on
73
+ chat memory for a resolved decision.
74
+ - Do not create or change proposal, spec, design, tasks, tests, or implementation
75
+ artifacts until all decisions that affect the current feature are confirmed or
76
+ explicitly marked blocked.
77
+ - Exit deep clarification once only repository-verifiable facts remain and the
78
+ user confirms the current feature understanding. Continue through the existing
79
+ clarify workflow without invoking an external skill dependency.
80
+
52
81
  ## Non-Negotiable Rules
53
82
 
54
83
  ### 上下文防漂移与状态门禁(阻塞级)
@@ -439,6 +439,14 @@ D. 复用某个已有接口的数据权限规则,请指定参考接口
439
439
  | --- | -------- | -------- | -------- | ---------------------------------- | ------------- | ----------------------- | -------------------------------- | -------------------------- |
440
440
  | 1 | XX SDK | Java SDK | 1.2.3 | 页面表单提交 -> DTO -> SDK Request | appId: 应用ID | {"code":0,"data":{...}} | {"code":500,"message":"timeout"} | 记录阻塞证据,标记外部阻塞 |
441
441
 
442
+ ### 外部集成配置与部署合同
443
+
444
+ 涉及第三方平台/工具、SDK、MQ/Kafka、回调、支付渠道或云服务时必须填写。
445
+
446
+ | 外部依赖/资源 | 配置项/资源名 | 本地来源/创建方式 | 测试来源/创建方式 | 生产来源/创建方式 | 注入/创建方式 | 运行 owner | 创建 owner/时点 | 就绪证据 | 回滚方式 | 密钥处理 | 阻塞项 |
447
+ | ------------- | ------------- | ----------------- | ----------------- | ----------------- | ------------- | ---------- | --------------- | -------- | -------- | -------- | ------ |
448
+ | TDMQ | Consumer Group | 自动/手工/IaC | 已存在/自动创建 | 运维发版前预创建 | 配置/Secret/IaC/控制台 | ydt-energy | 运维/发版前 | 控制台/API/消息轨迹 | 禁用消费/版本回滚 | 仅记录 Secret 引用 | 无/Blocked |
449
+
442
450
  ### 外部枚举绑定确认
443
451
 
444
452
  涉及第三方、SDK、BEM/停车系统、支付/退款、财务展示、来源字段、状态同步、
@@ -452,6 +460,9 @@ D. 复用某个已有接口的数据权限规则,请指定参考接口
452
460
  ### 外部依赖红线
453
461
 
454
462
  - SDK 参数来源必须写明,不得凭字段名猜测含义。
463
+ - 环境相关 endpoint、资源名、标识、凭据、ACL 和运行开关不得只硬编码在注解、常量或业务代码中。
464
+ - 测试环境自动创建、历史资源已存在或应用本地启动成功,不得作为生产资源已就绪的证据。
465
+ - Topic、Consumer Group、namespace、webhook、应用/租户 ID 等服务端资源必须明确生产创建 owner、创建时点、就绪检查和回滚方式;缺失时阻塞发布。
455
466
  - SDK 版本变更必须记录原因和影响范围。
456
467
  - 真实环境可用时,不得仅用 mock 代替。必须在 tests.md 记录真实请求/响应。
457
468
  - 外部服务不可用时,只能标记为"外部阻塞"或"Mock 验证",不得宣称真实链路通过。
@@ -181,6 +181,33 @@ Superpowers 技术详设复制 `外部枚举绑定确认` / `External Enum Bindi
181
181
  禁止用请求成功、值非空或字段存在替代外部枚举业务语义确认。未确认的外部枚举、
182
182
  支付来源、财务展示含义或兜底映射,必须停止并报告 `Blocked`。
183
183
 
184
+ ## 外部集成配置与部署合同(强制)
185
+
186
+ 如果本批涉及第三方平台/工具、SDK、MQ/Kafka、回调、支付渠道或云服务,必须从
187
+ api.md / sdd-quality-gate.md / Superpowers 技术详设复制
188
+ `外部集成配置与部署合同` / `External Integration Configuration And Deployment Contract`。
189
+
190
+ | 外部依赖/资源 | 配置项/资源名 | 本地来源/创建方式 | 测试来源/创建方式 | 生产来源/创建方式 | 注入/创建方式 | 运行 owner | 创建 owner/时点 | 就绪证据 | 回滚 | 密钥处理 | 阻塞项 |
191
+ | ------------- | ------------- | ----------------- | ----------------- | ----------------- | ------------- | ---------- | --------------- | -------- | ---- | -------- | ------ |
192
+ | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | 配置/Secret/IaC/控制台 | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | 仅引用 | 无/Blocked |
193
+
194
+ 环境相关配置和服务端资源不得只硬编码在注解、常量或业务代码中。测试自动创建或
195
+ 历史资源存在不能证明生产就绪;缺少生产创建与验证证据时必须停止并报告 `Blocked`。
196
+
197
+ ## 并发与幂等归属(强制)
198
+
199
+ 如果本批涉及并发、批量下发/开通/续费、重复提交/回调/消费或重复外部调用,必须从
200
+ sdd-quality-gate.md / Superpowers 技术详设复制 `Concurrency And Idempotency Ownership`。
201
+
202
+ | 场景 | 业务幂等键 | 原子占用 owner | 应用层原子占用 | 短事务边界 | 状态流转 | 重试复用编码 | 外部调用边界 | 不确定结果处理 | 唯一索引角色 | 测试证据 |
203
+ | ---- | ---------- | -------------- | ---------------- | ---------- | -------- | ------------ | ------------ | -------------- | ------------ | -------- |
204
+ | ____ | ____ | ____ | 锁定 owner 后写 PENDING | 独立提交 | PENDING/SUCCESS/FAILED | 复用原业务单号 | 提交后调用 | 阻止重复并对账 | 非默认/可选兜底 | 并发/重复/重试 |
205
+
206
+ 默认采用应用层原子占用:稳定业务幂等键、短事务占用并落 `PENDING`、提交并释放锁后
207
+ 再调用外部系统。禁止“先查再插”、单进程锁、随机单号和外部调用期间持有长事务。
208
+ 唯一索引不是默认方案,只有自然唯一、历史清理、NULL/软删除和冲突合同明确后才可
209
+ 作为数据库兜底。结果不确定时必须阻止重复调用并进入可追踪对账。
210
+
184
211
  ## 金额精度边界继承(强制)
185
212
 
186
213
  如果本批涉及金额、费用、优惠、抵扣、退款、分账、支付、发票、余额、电费、
@@ -148,7 +148,35 @@ Superpowers 技术详设复制 `外部枚举绑定确认` / `External Enum Bindi
148
148
  禁止用请求成功、值非空或字段存在替代外部枚举业务语义确认。未确认的外部枚举、
149
149
  支付来源、财务展示含义或兜底映射,必须停止并报告 `Blocked`。
150
150
 
151
- ### 1.2 金额精度边界继承
151
+ ### 1.2 外部集成配置与部署合同
152
+
153
+ 如果本批涉及第三方平台/工具、SDK、MQ/Kafka、回调、支付渠道或云服务,必须从
154
+ api.md / sdd-quality-gate.md / Superpowers 技术详设复制 `外部集成配置与部署合同`:
155
+
156
+ | 外部依赖/资源 | 配置项/资源名 | 本地来源/创建方式 | 测试来源/创建方式 | 生产来源/创建方式 | 注入/创建方式 | 运行 owner | 创建 owner/时点 | 就绪证据 | 回滚 | 密钥处理 | 阻塞项 |
157
+ | ------------- | ------------- | ----------------- | ----------------- | ----------------- | ------------- | ---------- | --------------- | -------- | ---- | -------- | ------ |
158
+ | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | 配置/Secret/IaC/控制台 | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | \_\_\_\_ | 仅引用 | 无/Blocked |
159
+
160
+ 环境相关配置和服务端资源不得只硬编码在注解、常量或业务代码中。测试自动创建、
161
+ 测试历史资源存在或应用本地启动成功,不能证明生产已就绪;缺少生产创建 owner、
162
+ 创建时点、就绪证据或回滚方式时,必须停止并报告 `Blocked`。
163
+
164
+ ### 1.2.1 并发与幂等归属
165
+
166
+ 如果本批涉及并发、批量下发/开通/续费、重复提交/回调/消费或重复外部调用,必须
167
+ 从 sdd-quality-gate.md / Superpowers 技术详设复制 `Concurrency And Idempotency
168
+ Ownership` / `并发与幂等归属`:
169
+
170
+ | 场景 | 业务幂等键 | 原子占用 owner | 应用层原子占用 | 短事务边界 | 状态流转 | 重试复用编码 | 外部调用边界 | 不确定结果处理 | 唯一索引角色 | 测试证据 |
171
+ | ---- | ---------- | -------------- | ---------------- | ---------- | -------- | ------------ | ------------ | -------------- | ------------ | -------- |
172
+ | ____ | ____ | ____ | 锁定 owner 后写 PENDING | 独立提交 | PENDING/SUCCESS/FAILED | 复用原业务单号 | 提交后调用 | 阻止重复并对账 | 非默认/可选兜底 | 并发/重复/重试 |
173
+
174
+ 默认使用应用层原子占用和稳定业务幂等键,在短事务内持久化 `PENDING` 后提交,释放
175
+ 数据库锁再调用外部系统;重试复用原业务编码,结果不确定时阻止重复并进入对账。
176
+ 禁止“先查再插”、单进程锁、随机单号或跨外部调用的长事务。唯一索引不是默认方案,
177
+ 只有自然唯一、历史数据清理、NULL/软删除和冲突处理合同明确后才可作为可选兜底。
178
+
179
+ ### 1.3 金额精度边界继承
152
180
 
153
181
  如果本批涉及金额、费用、优惠、抵扣、退款、分账、支付、发票、余额、电费、
154
182
  服务费、套餐结算、比例分摊、明细分配、对账或财务展示,必须从 Superpowers
@@ -63,6 +63,8 @@
63
63
  | 45 | **SDD 状态机字段** | **所有进入实现的任务强制** | `.sdd/state.yaml` 包含 workflow、phase、handoff_hash、build_mode、isolation、tdd_mode、review_mode、verify_mode、implementation_prompt、verification_report、archived;`superflow-state.sh status/next/recover` 输出一致 |
64
64
  | 46 | **外部枚举绑定确认** | **涉及第三方、SDK、BEM/停车、支付退款、财务展示、来源字段、状态同步或外部字典时强制** | api.md、sdd-quality-gate.md 和 Superpowers 技术详设包含 `外部枚举绑定确认` / `External Enum Binding`,列出 `业务字段 | 本系统真源字段/枚举 | 外部系统字段 | 外部枚举/字典值 | 展示文案/业务语义/财务语义 | 取值来源 | owner/确认时间 | 不确定项/阻塞处理 | 测试证据`;不得用请求成功、值非空或字段存在替代业务语义确认;未确认时必须阻塞 |
65
65
  | 47 | **金额精度边界** | **涉及金额、费用、优惠、抵扣、退款、分账、支付、发票、余额、电费、服务费、套餐结算、比例分摊、明细分配、对账或财务展示时强制** | Superpowers 技术详设包含 `Money Precision Boundary` 及金额恒等式、权威总额、独立计算项、差额反推项与公式、计算态来源、中间精度、舍入边界、scale/rounding mode、分配/对账规则、禁止提前舍入点和测试证据;存在加法恒等式且总额是真源时,最后一个组成项必须由权威总额减去其余组成项合计得到,禁止所有组成项分别计算和舍入后重建总额;测试必须覆盖半分、尾差或多明细分配场景 |
66
+ | 48 | **外部集成配置与部署合同** | **涉及第三方平台/工具、SDK、MQ/Kafka、回调、支付渠道、云服务或其他外部集成时强制** | api.md、sdd-quality-gate.md、Superpowers 技术详设和实现 prompt 包含 `外部集成配置与部署合同` / `External Integration Configuration And Deployment Contract`;列出 endpoint、应用/租户/项目 ID、Topic/Tag/Consumer Group、namespace、webhook、ACL/role、开关、超时和凭据引用在本地/测试/生产的来源与创建方式,以及注入方式、运行 owner、创建 owner/时点、就绪证据、回滚、密钥处理和阻塞项;环境相关值不得只硬编码在注解/常量/业务代码;测试自动创建、历史资源或本地启动成功不能证明生产就绪,缺少生产创建证据必须阻塞发布 |
67
+ | 49 | **并发与幂等归属** | **涉及并发、批量下发/开通/续费、重复提交/回调/消费或重复外部调用时强制** | sdd-quality-gate.md、Superpowers 技术详设和实现 prompt 包含 `Concurrency And Idempotency Ownership` / `并发与幂等归属`;明确业务幂等键、应用层原子占用 owner、短事务边界、PENDING/SUCCESS/FAILED 状态流转、重试复用原业务编码、外部调用边界和不确定结果对账;唯一索引不作为默认方案,只能在自然唯一、历史数据、NULL/软删除和冲突处理合同明确后作为可选兜底;测试覆盖并发、重复和重试 |
66
68
 
67
69
  ### 文档完整性强制检查(新增,全部项目必做)
68
70
 
@@ -60,6 +60,47 @@ orchestrator unless the OpenSpec/SDD contract explicitly says that module owns
60
60
  the new entry point and records the owner approval. If the correct owner is
61
61
  unclear, mark the design blocked.
62
62
 
63
+ ## External Integration Configuration And Deployment Contract
64
+
65
+ Use this whenever the change integrates with a third-party platform/tool, SDK,
66
+ MQ/Kafka, callback, payment gateway, cloud service, or other external system.
67
+
68
+ | External dependency/resource | Config/resource item | Local source/provisioning | Test source/provisioning | Production source/provisioning | Injection/creation method | Runtime owner | Provisioning owner/time | Readiness evidence | Rollback | Secret handling | Blocker |
69
+ | ---------------------------- | -------------------- | ------------------------- | ------------------------ | ------------------------------ | ------------------------- | ------------- | ----------------------- | ------------------ | -------- | --------------- | ------- |
70
+ | `<TDMQ>` | `<Consumer Group>` | `<auto/manual/IaC>` | `<existing resource>` | `<pre-created by ops>` | `<config/secret/IaC/console>` | `<service>` | `<owner + before deploy>` | `<console/API/trace>` | `<disable/rollback>` | `<secret reference only>` | `<none/blocker>` |
71
+
72
+ Required checks:
73
+
74
+ ```bash
75
+ rg -ni "https?://|endpoint|base.?url|app.?id|tenant|project.?id|topic|tag|consumer.?group|namespace|webhook|acl|role|secret|token|password|timeout" <source-and-config-paths>
76
+ rg -ni "@.*Listener|new.*Client|builder\(|System\.getenv|ConfigurationProperties|Value\(" <source-and-config-paths>
77
+ ```
78
+
79
+ Do not hard-code environment-dependent endpoints, resource names, identifiers,
80
+ credentials, ACLs, or operational switches in annotations, constants, or
81
+ business code. Stable protocol constants may remain code constants only when
82
+ the design proves they are not environment-specific and no server-side
83
+ resource must be provisioned. Test auto-creation, a successful local startup,
84
+ or an already-existing test resource is not evidence that production is
85
+ ready. Every server-side resource must have an explicit production owner,
86
+ creation timing, readiness check, and rollback path. Missing production
87
+ provisioning evidence is a blocker.
88
+
89
+ ## Concurrency And Idempotency Ownership
90
+
91
+ 批量开通、批量续费、并发请求、重复回调、重复消费或重复外部下发时必须填写。
92
+
93
+ | 场景 | 业务幂等键 | 原子占用 owner/资源 | 应用层原子占用操作 | 短事务边界 | 状态流转 | 重试复用编码 | 外部调用边界 | 结果不确定处理 | 唯一索引角色 | 测试证据 |
94
+ | ---- | ---------- | ------------------- | ------------------ | ---------- | -------- | ------------ | ------------ | -------------- | ------------ | -------- |
95
+ | `<批量下发>` | `<套餐+车辆+周期>` | `<周期记录>` | `<锁定 owner 后写 PENDING>` | `<独立事务提交占用>` | `PENDING/SUCCESS/FAILED` | `<复用原业务单号>` | `<提交后调用>` | `<阻止重复并进入对账>` | `<非默认;必要时兜底>` | `<并发/重复/重试用例>` |
96
+
97
+ 应用层原子占用是默认方案:先用稳定业务幂等键在短事务内锁定明确的 owner 资源,
98
+ 写入 `PENDING` 并提交,再释放数据库锁后执行外部调用。外部调用成功或失败后更新
99
+ 状态;重试必须复用原业务单号。结果不确定时必须阻止重复下发并保留人工对账入口。
100
+ 禁止用“先查再插”、单进程锁或随机单号冒充跨实例幂等,也禁止在外部调用期间持有
101
+ 长事务或数据库锁。唯一索引不是默认方案;仅当自然唯一语义、历史数据清理、NULL/
102
+ 软删除行为和冲突处理合同都已明确时,才可作为数据库兜底。
103
+
63
104
  ## Field And Status Reverse Impact
64
105
 
65
106
  Use this whenever changing field values, enum/status values, derived fields,
@@ -166,6 +166,16 @@ HTTP 200、字段非空、mock-only、DB-only、`BUILD SUCCESS`、`Tests are ski
166
166
  ## 9. 结论
167
167
 
168
168
  [是否达到交付标准,是否可以进入下一阶段]
169
+
170
+ 验证结果: PASS / FAIL / BLOCKED / PARTIALLY_VERIFIED
171
+ 归档就绪: PASS / BLOCKED
172
+
173
+ `verify_mode: full` 时必须填写:
174
+
175
+ - 测试环境:
176
+ - 分支/commit/构建号或镜像:
177
+ - Base URL:
178
+ - 验证时间:
169
179
  ```
170
180
 
171
181
  ## 任务完成 Checklist(全部满足才能标记完成)