@peterxiaoyang/superspec 0.1.14 → 0.1.15-alpha

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 (126) hide show
  1. package/dist/cli.d.ts +2 -0
  2. package/dist/cli.js +302 -0
  3. package/dist/format.d.ts +29 -0
  4. package/dist/format.js +141 -0
  5. package/dist/next.d.ts +3 -0
  6. package/dist/next.js +161 -0
  7. package/dist/openspec.d.ts +9 -0
  8. package/dist/openspec.js +41 -0
  9. package/dist/record.d.ts +20 -0
  10. package/dist/record.js +211 -0
  11. package/dist/skill_loop.d.ts +23 -0
  12. package/dist/skill_loop.js +58 -0
  13. package/dist/store.d.ts +31 -0
  14. package/dist/store.js +213 -0
  15. package/dist/sync.d.ts +3 -0
  16. package/dist/sync.js +135 -0
  17. package/dist/task.d.ts +7 -0
  18. package/dist/task.js +44 -0
  19. package/dist/transition.d.ts +34 -0
  20. package/dist/transition.js +400 -0
  21. package/dist/types.d.ts +138 -0
  22. package/dist/types.js +3 -0
  23. package/package.json +8 -53
  24. package/templates/workflow/skills/superspec-apply/SKILL.md +46 -118
  25. package/templates/workflow/skills/superspec-archive/SKILL.md +22 -47
  26. package/templates/workflow/skills/superspec-explore/SKILL.md +38 -69
  27. package/templates/workflow/skills/superspec-propose/SKILL.md +58 -60
  28. package/templates/workflow/skills/superspec-review/SKILL.md +36 -81
  29. package/adapters/codex/agents/architect.toml +0 -13
  30. package/adapters/codex/agents/code-reviewer.toml +0 -13
  31. package/adapters/codex/agents/critic.toml +0 -13
  32. package/adapters/codex/agents/executor.toml +0 -13
  33. package/adapters/codex/agents/explore.toml +0 -13
  34. package/adapters/codex/agents/test-engineer.toml +0 -13
  35. package/adapters/codex/agents/test-runner.toml +0 -13
  36. package/adapters/codex/agents/verifier.toml +0 -13
  37. package/adapters/codex/install-map.json +0 -116
  38. package/bin/launch.js +0 -37
  39. package/bin/superspec-check.js +0 -4
  40. package/bin/superspec-hook.js +0 -4
  41. package/bin/superspec-init.js +0 -4
  42. package/bin/superspec.js +0 -4
  43. package/dist/src/apply_worker_chain.d.ts +0 -60
  44. package/dist/src/apply_worker_chain.js +0 -1283
  45. package/dist/src/apply_worker_chain_lifecycle.d.ts +0 -21
  46. package/dist/src/apply_worker_chain_lifecycle.js +0 -409
  47. package/dist/src/archive.d.ts +0 -23
  48. package/dist/src/archive.js +0 -430
  49. package/dist/src/cli.d.ts +0 -1
  50. package/dist/src/cli.js +0 -33
  51. package/dist/src/cli_args.d.ts +0 -32
  52. package/dist/src/cli_args.js +0 -454
  53. package/dist/src/core.d.ts +0 -20
  54. package/dist/src/core.js +0 -394
  55. package/dist/src/disclosure.d.ts +0 -35
  56. package/dist/src/disclosure.js +0 -671
  57. package/dist/src/doctor.d.ts +0 -44
  58. package/dist/src/doctor.js +0 -230
  59. package/dist/src/evidence.d.ts +0 -29
  60. package/dist/src/evidence.js +0 -1107
  61. package/dist/src/gates.d.ts +0 -19
  62. package/dist/src/gates.js +0 -1631
  63. package/dist/src/git.d.ts +0 -8
  64. package/dist/src/git.js +0 -112
  65. package/dist/src/hooks/adapter.d.ts +0 -5
  66. package/dist/src/hooks/adapter.js +0 -347
  67. package/dist/src/hooks/guard_api.d.ts +0 -12
  68. package/dist/src/hooks/guard_api.js +0 -797
  69. package/dist/src/hooks/health.d.ts +0 -4
  70. package/dist/src/hooks/health.js +0 -86
  71. package/dist/src/hooks/policy_event.d.ts +0 -41
  72. package/dist/src/hooks/policy_event.js +0 -2634
  73. package/dist/src/hooks/types.d.ts +0 -72
  74. package/dist/src/hooks/types.js +0 -1
  75. package/dist/src/hooks/validation.d.ts +0 -3
  76. package/dist/src/hooks/validation.js +0 -70
  77. package/dist/src/i18n.d.ts +0 -21
  78. package/dist/src/i18n.js +0 -720
  79. package/dist/src/init_cli.d.ts +0 -28
  80. package/dist/src/init_cli.js +0 -404
  81. package/dist/src/install_engine.d.ts +0 -71
  82. package/dist/src/install_engine.js +0 -538
  83. package/dist/src/invariants.d.ts +0 -16
  84. package/dist/src/invariants.js +0 -363
  85. package/dist/src/openspec.d.ts +0 -37
  86. package/dist/src/openspec.js +0 -274
  87. package/dist/src/packet_render.d.ts +0 -5
  88. package/dist/src/packet_render.js +0 -1767
  89. package/dist/src/packet_schema.d.ts +0 -59
  90. package/dist/src/packet_schema.js +0 -1
  91. package/dist/src/paths.d.ts +0 -22
  92. package/dist/src/paths.js +0 -203
  93. package/dist/src/project_init.d.ts +0 -33
  94. package/dist/src/project_init.js +0 -191
  95. package/dist/src/self_update.d.ts +0 -14
  96. package/dist/src/self_update.js +0 -56
  97. package/dist/src/state.d.ts +0 -37
  98. package/dist/src/state.js +0 -464
  99. package/dist/src/tasks.d.ts +0 -38
  100. package/dist/src/tasks.js +0 -373
  101. package/dist/src/util.d.ts +0 -163
  102. package/dist/src/util.js +0 -792
  103. package/dist/superspec.d.ts +0 -6
  104. package/dist/superspec.js +0 -97
  105. package/dist/superspec_guard.d.ts +0 -4
  106. package/dist/superspec_guard.js +0 -19
  107. package/dist/superspec_hook.d.ts +0 -4
  108. package/dist/superspec_hook.js +0 -35
  109. package/dist/superspec_init.d.ts +0 -2
  110. package/dist/superspec_init.js +0 -17
  111. package/schemas/hook-event.schema.json +0 -27
  112. package/schemas/install-manifest.schema.json +0 -97
  113. package/templates/hooks/codex-hooks.json +0 -35
  114. package/templates/sidecar/archive-preservation.json +0 -11
  115. package/templates/sidecar/business-invariants.md +0 -38
  116. package/templates/sidecar/config.yaml +0 -13
  117. package/templates/sidecar/discovery.md +0 -33
  118. package/templates/sidecar/test-contract.md +0 -27
  119. package/templates/workflow/prompts/architect.md +0 -27
  120. package/templates/workflow/prompts/code-reviewer.md +0 -34
  121. package/templates/workflow/prompts/critic.md +0 -30
  122. package/templates/workflow/prompts/executor.md +0 -32
  123. package/templates/workflow/prompts/explore.md +0 -27
  124. package/templates/workflow/prompts/test-engineer.md +0 -28
  125. package/templates/workflow/prompts/test-runner.md +0 -35
  126. package/templates/workflow/prompts/verifier.md +0 -35
@@ -0,0 +1,138 @@
1
+ export type State = "init" | "explore" | "propose" | "propose_ready" | "apply" | "apply_done" | "review" | "accepted" | "archive" | "abandoned";
2
+ export declare const PHASE1_STATES: ReadonlySet<State>;
3
+ export type Ref = {
4
+ path: string;
5
+ sha: string;
6
+ };
7
+ export type JobState = "requested" | "accepted" | "rejected";
8
+ export type JobRole = "proposal-auditor" | "clarification-review" | "critic-review" | "architect-review" | "test-engineer-review" | "executor" | "test-run" | "final-audit";
9
+ export interface Job {
10
+ job_id: string;
11
+ role: JobRole;
12
+ state: JobState;
13
+ boundFiles: Ref[];
14
+ packet_digest: string;
15
+ created_from_transition: string;
16
+ created_at: string;
17
+ }
18
+ export interface JobPacket {
19
+ job_id: string;
20
+ role: JobRole;
21
+ boundFiles: Ref[];
22
+ packet_digest: string;
23
+ required_output_kind: string;
24
+ stop_conditions: string[];
25
+ created_from_transition: string;
26
+ }
27
+ export type EventType = "transition_prepare" | "transition_commit" | "job_requested" | "job_invalidated" | "reopen" | "abandon" | "task_started" | "task_completed" | "task_abandoned" | "job_accepted" | "job_rejected" | "user_decision_recorded" | "test_run_recorded" | "task_activation_recorded" | "artifact_recorded";
28
+ export interface Event {
29
+ event_id: string;
30
+ event_type: EventType;
31
+ change_id: string;
32
+ transition_id: string | null;
33
+ idempotency_key: string | null;
34
+ created_at: string;
35
+ actor: string;
36
+ prev_snapshot_digest: string | null;
37
+ input_refs: Ref[];
38
+ output_refs: Ref[];
39
+ payload: Record<string, unknown>;
40
+ event_digest: string;
41
+ }
42
+ export interface TransitionCommitPayload {
43
+ transition: string;
44
+ from_state: State;
45
+ to_state: State;
46
+ outcome: "advanced" | "job_created";
47
+ created_job_ids: string[];
48
+ reason: string;
49
+ }
50
+ export interface Snapshot {
51
+ change_id: string;
52
+ state: State;
53
+ openspec_status_digest: string;
54
+ events_digest: string;
55
+ document_digests: Record<string, string>;
56
+ tasks_structure_digest: string | null;
57
+ task_statuses: Record<string, "todo" | "doing" | "done">;
58
+ open_jobs: Job[];
59
+ accepted_jobs: Job[];
60
+ active_task_attempts: TaskAttempt[];
61
+ pending_user_decisions: AskUser[];
62
+ last_transition: string | null;
63
+ computed_at: string;
64
+ }
65
+ export type AttemptState = "active" | "closed" | "abandoned";
66
+ export interface TaskAttempt {
67
+ attempt_id: string;
68
+ task_id: string;
69
+ state: AttemptState;
70
+ task_structure_digest: string;
71
+ declared_write_scope: string[];
72
+ pre_edit_source_fingerprint: string | null;
73
+ pre_edit_red_ref: string | null;
74
+ executor_packet_digest: string | null;
75
+ executor_result_ref: string | null;
76
+ post_edit_green_ref: string | null;
77
+ created_at: string;
78
+ }
79
+ export interface TestRun {
80
+ test_id: string;
81
+ attempt_id?: string | null;
82
+ task_structure_digest: string;
83
+ command: string;
84
+ cwd: string;
85
+ exit_code: number;
86
+ semantic_status: "expected_failure" | "expected_success" | "characterization_pass" | "unknown";
87
+ target_fingerprint: string | null;
88
+ raw_log_ref: string | null;
89
+ created_at: string;
90
+ }
91
+ export interface MissingInput {
92
+ field: string;
93
+ expected: string;
94
+ command_to_fix: string;
95
+ }
96
+ export interface AskUser {
97
+ question: string;
98
+ allowed_answers: string[];
99
+ scope: string;
100
+ }
101
+ export type NextOutput = {
102
+ state: State;
103
+ } & ({
104
+ path: "next_command";
105
+ next_command: string;
106
+ reason: string;
107
+ missing_inputs: MissingInput[];
108
+ } | {
109
+ path: "required_job";
110
+ required_jobs: {
111
+ job_id: string;
112
+ role: JobRole;
113
+ packet_command: string;
114
+ }[];
115
+ reason: string;
116
+ } | {
117
+ path: "ask_user";
118
+ ask_user: AskUser;
119
+ reason: string;
120
+ } | {
121
+ path: "done";
122
+ reason: string;
123
+ });
124
+ export interface TransitionResult {
125
+ transition: string;
126
+ outcome: "advanced" | "job_created";
127
+ from_state: State;
128
+ to_state: State;
129
+ created_jobs: string[];
130
+ message: string;
131
+ events_written: number;
132
+ }
133
+ export interface RecordResult {
134
+ event_type: EventType;
135
+ accepted: boolean;
136
+ message: string;
137
+ job_state?: JobState;
138
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ // SuperSpec 流程引擎 — 核心类型定义
2
+ // Phase 1 只实现前 4 个
3
+ export const PHASE1_STATES = new Set(["init", "explore", "propose", "propose_ready"]);
package/package.json CHANGED
@@ -1,65 +1,20 @@
1
1
  {
2
2
  "name": "@peterxiaoyang/superspec",
3
- "version": "0.1.14",
4
- "description": "SuperSpec workflow package: guard runtime, generic workflow templates, and Codex adapter payload.",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/PeterYaoYang/SuperSpec.git"
8
- },
9
- "bugs": {
10
- "url": "https://github.com/PeterYaoYang/SuperSpec/issues"
11
- },
12
- "homepage": "https://github.com/PeterYaoYang/SuperSpec#readme",
13
- "private": false,
3
+ "version": "0.1.15-alpha",
4
+ "description": "SuperSpec 流程引擎 transition engine with lightweight fact-sync",
14
5
  "type": "module",
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "engines": {
19
- "node": ">=20.19.0"
20
- },
21
- "bin": {
22
- "superspec": "bin/superspec.js",
23
- "superspec-check": "bin/superspec-check.js",
24
- "superspec-hook": "bin/superspec-hook.js",
25
- "superspec-init": "bin/superspec-init.js"
26
- },
6
+ "engines": { "node": ">=20.19.0" },
7
+ "bin": { "superspec": "dist/cli.js" },
27
8
  "exports": {
28
- ".": {
29
- "types": "./dist/superspec.d.ts",
30
- "default": "./dist/superspec.js"
31
- },
32
- "./superspec_guard": {
33
- "types": "./dist/superspec_guard.d.ts",
34
- "default": "./dist/superspec_guard.js"
35
- },
36
- "./superspec_hook": {
37
- "types": "./dist/superspec_hook.d.ts",
38
- "default": "./dist/superspec_hook.js"
39
- },
40
- "./superspec_init": {
41
- "types": "./dist/superspec_init.d.ts",
42
- "default": "./dist/superspec_init.js"
43
- },
44
- "./templates/*": "./templates/*",
45
- "./adapters/*": "./adapters/*",
46
- "./schemas/*": "./schemas/*"
9
+ ".": { "types": "./dist/types.d.ts", "default": "./dist/cli.js" }
47
10
  },
48
- "files": [
49
- "README.md",
50
- "bin",
51
- "dist",
52
- "templates",
53
- "adapters",
54
- "schemas"
55
- ],
11
+ "files": ["README.md", "dist", "templates"],
56
12
  "scripts": {
57
13
  "build": "node build.js",
58
14
  "typecheck": "tsc --noEmit",
59
- "test": "node --test tests/test_install_engine.test.ts tests/test_real_openspec_smoke.test.ts tests/test_superspec_cli.test.ts tests/test_superspec_guard_output.test.ts tests/test_superspec_guard_core.test.ts tests/test_superspec_guard_review.test.ts tests/test_superspec_guard_request_reopen.test.ts tests/test_superspec_guard_archive.test.ts tests/test_superspec_guard_packet.test.ts tests/test_superspec_guard_disclosure.test.ts tests/test_superspec_hooks.test.ts tests/test_superspec_i18n.test.ts tests/test_superspec_skills.test.ts",
15
+ "test": "node --test tests/*.ts",
60
16
  "prepack": "npm run build",
61
- "prepublishOnly": "npm run build",
62
- "pack:dry-run": "npm pack --dry-run"
17
+ "prepublishOnly": "npm run build"
63
18
  },
64
19
  "devDependencies": {
65
20
  "@types/node": "^20.19.0",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: superspec-apply
3
- description: "3.方案通过后用:按 tasks 一项项写代码、跑测试、记录证据;每个任务都要先证明测试会失败,再实现到测试通过。"
3
+ description: " tasks.md 逐任务实现代码,记录 RED/GREEN 证据,推进 task-complete。"
4
4
  metadata:
5
5
  author: SuperSpec
6
6
  source: SuperSpec
@@ -8,136 +8,64 @@ metadata:
8
8
 
9
9
  # SuperSpec Apply
10
10
 
11
- ## 语言规则 / Language
11
+ 你是执行阶段。职责:按 tasks.md 的任务逐个实现——先 RED(测试会失败),再 GREEN(实现到测试通过),然后 task-complete 勾选。
12
12
 
13
- - 默认使用简体中文写人类可读内容;命令、路径、字段名、阶段门名、task/test id、代码标识符保留原文。
14
- - 用户可见文案不得使用“裁决”描述用户动作;统一说“确认”“范围取舍”“处理方式选择”或“用户确认记录”。
15
- - 不把内部证据种类、reason code、JSON 字段大全直接转述给用户;需要诊断时才引用原文。
16
- - 普通 workflow 命令使用 `--format agent`;`--format json` 只用于诊断,不作为默认上下文。
13
+ ## 驱动方式
17
14
 
18
- ## 命令执行 / Shell
15
+ 所有状态由 transition engine 管理。循环:
19
16
 
20
- - Windows PowerShell 中使用 `.cmd` shim:`superspec.cmd ...`、`openspec.cmd ...`;不要运行 `superspec.ps1` 或 `openspec.ps1`。
21
- - 其他 shell 使用文档中的 `superspec ...`、`openspec ...` 命令。
17
+ 1. `superspec transition next --change "<change>"` 获取下一步
18
+ 2. 执行返回的命令
19
+ 3. 登记结果
20
+ 4. 回到 1
22
21
 
23
- ## 阶段职责
22
+ ## 本阶段做什么
24
23
 
25
- Apply OpenSpec tasks 实现,负责 RED/GREEN 证据、任务勾选和 review request-changes 后的 reopen 修复;不扩大范围,不改 proposal package 语义。
24
+ 进入执行前,先用 `openspec instructions apply --change "<change>" --json` 读取 apply 阶段约束,再执行 `superspec transition start-apply --change "<change>"`。
26
25
 
27
- ## 第一条必跑命令
26
+ 每个任务的循环:
28
27
 
29
- ```text
30
- superspec check workflow-packet --change "<change>" --gate apply_ready --format agent
31
- ```
32
-
33
- 遇到任何返回状态为 `block` 就停止;未 allowed 前不要编辑实现。
34
-
35
- ## OpenSpec 边界
36
-
37
- - 直接使用 OpenSpec CLI surface,不读取 repo-local `openspec-*` skill 文本。
38
- - task list、`contextFiles`、progress、dynamic instruction 来自:
39
-
40
- ```text
41
- openspec instructions apply --change "<change>" --json
42
- ```
43
-
44
- 不要发明 task list,也不要跳过 OpenSpec 返回的 context files。
45
-
46
- ## Task Guard 边界
47
-
48
- 实现编辑前读取 `task_edit` 检查结果;勾选 task 前读取 `task_complete` 检查结果:
49
-
50
- ```text
51
- superspec check workflow-packet --change "<change>" --gate task_edit --task-id "<task-id>" --format agent
52
- superspec check workflow-packet --change "<change>" --gate task_complete --task-id "<task-id>" --format agent
53
- ```
54
-
55
- `task_edit` 未 allowed 不得编辑实现;`task_complete` 未 allowed 不得把 checkbox 改成 done。
56
-
57
- ## Reopen 边界
58
-
59
- review 给出 `request_changes_route:"reopen_tasks"` 时,先生成完整 reopen package,再检查:
60
-
61
- ```text
62
- superspec check workflow-packet --change "<change>" --gate task_reopen --task-id "<task-id>" --format agent
63
- ```
64
-
65
- 只有 `task_reopen` allowed 后,才允许把目标 task 从 checked 改回 unchecked 并重新 RED/GREEN。修完写 `task_reopen_resolved`,再进 review。若 route 是 `change_update`,停止 apply 并回 propose/change update。
66
-
67
- ## 用户确认边界
68
-
69
- - apply isolation 和 execution mode 必须等待明确选择。
70
- - 分支状态、dirty worktree、scope expands 或需要改变 task scope 时必须停止并确认。
71
- - 不要使用默认值、历史偏好或沉默作为确认。
72
-
73
- ## 专用代理边界
74
-
75
- 主线程只负责用检查命令生成各角色提示、分派专用代理、审核代理报告、登记证据、推进任务勾选。专用代理来自 `.codex/agents/*.toml` 与 `.codex/prompts/*.md`,不能由主线程自审替代。代理报告只是候选材料,通过检查的才是正式证据。当前 CLI 没有登记证据的命令;代理报告返回后,由主线程按检查命令的 output contract 字段手动写入 `.superspec/evidence/` 对应目录。
76
-
77
- RED/characterization/GREEN 测试必须由 `.codex/agents/test-runner.toml` + `.codex/prompts/test-runner.md` 执行;主线程不得代跑或伪造 formal `test_run` evidence。新增或修改测试文件时用 `test-engineer` 专用代理。
78
-
79
- ```text
80
- superspec check apply-test-packet --change "<change>" --task-id "<task-id>" --test-id "<test-id>" --phase red --format prompt
81
- ```
82
-
83
- 用 test-runner 执行检查命令指定的测试命令;主线程审核报告/原始日志并登记为证据后,才写正式 `test_run` 证据。
84
-
85
- 测试证据语义(框架无关,审核 worker report 时用):只有 `target test identity executed` 才算有效运行;`command exit code alone is not proof`,退出码 0 不证明目标测试真正跑过/通过;命令在到达测试 runner 之前失败属于 `blocked before the target test runner`,不算 RED/GREEN;`do not classify environment/build failures as RED or GREEN`。
86
-
87
- `apply_execution_surface`:缺省有 `write_scope` 为 `implementation`,无 `write_scope` 为 `no_code`;显式允许 `implementation`、`runtime_config`、`docs_generated`、`no_code`。`implementation` / `runtime_config` 必须走 executor-worker chain;`tdd_required:false` 也只能用 closed `apply_worker_chain` 的 `completion_proof_kind:"alternative_verification"` 完成。`docs_generated` / `no_code` 可用 direct alternative/manual verification。
88
-
89
- 编码实现必须由 `.codex/agents/executor.toml` + `.codex/prompts/executor.md` 执行,并通过 active -> closed `apply_worker_chain` 收敛;主线程不得直接改实现代码来完成 task。
90
-
91
- ```text
92
- superspec check apply-executor-packet --change "<change>" --task-id "<task-id>" --apply-worker-chain-ref "<active-chain-ref>" --format prompt
93
- ```
94
-
95
- 使用 `.codex/agents/executor.toml` / `.codex/prompts/executor.md`。先把检查命令给出的激活模板登记为工作链证据;缺激活标记不能启动 executor。TDD 与 no-TDD 的激活标记不同(具体字段以检查命令输出为准)。executor 只能改检查命令声明的实现写范围(implementation/runtime_config write scope),不能写正式 evidence,不能改 task checkbox,不能做 review/verification。
96
-
97
- executor 返回后把报告登记为证据,再生成任务级审查:
28
+ 1. **task-start**:`superspec transition task-start --change "<change>" --task "<TASK-ID>"`
29
+ 2. **拿到 attempt_id**:从 task-start 的返回结果或 `snapshot.json` 中读取当前活跃 attempt `attempt_id`
30
+ 3. **RED**:写测试,跑测试确认失败,`superspec record test-run --change "<change>" --input <red.json>`
31
+ 4. **实现**:写代码让测试通过
32
+ 5. **GREEN**:跑测试确认通过,`superspec record test-run --change "<change>" --input <FILE>`
33
+ 6. **task-complete**:`superspec transition task-complete --change "<change>" --task "<TASK-ID>"`
98
34
 
99
- ```text
100
- superspec check apply-code-review-packet --change "<change>" --task-id "<task-id>" --executor-report-ref "<ref>" --format prompt
101
- ```
102
-
103
- 用 `.codex/agents/code-reviewer.toml` 检查 scope/protected paths、executor report 与 diff、test/invariant mapping 和 suggested GREEN checks。
35
+ no-TDD 任务(tdd_required:false + no_tdd_reason)跳过 RED/GREEN。
104
36
 
105
- code-review 通过后,GREEN 只走同一 executor-worker chain:
37
+ ## test-run 输入格式
106
38
 
107
- ```text
108
- superspec check apply-test-packet --change "<change>" --task-id "<task-id>" --test-id "<test-id>" --phase green --task-code-review-report-ref "<ref>" --format prompt
39
+ ```json
40
+ {
41
+ "test_id": "TEST-XXX",
42
+ "attempt_id": "ATT-TASK-XXX-...",
43
+ "task_structure_digest": "<从 tasks.md 派生的结构指纹>",
44
+ "command": "npm test",
45
+ "cwd": "<工作目录>",
46
+ "exit_code": 1,
47
+ "semantic_status": "expected_failure",
48
+ "target_fingerprint": "<被测文件的 sha256>"
49
+ }
109
50
  ```
110
51
 
111
- GREEN report 审核并登记为 evidence 后,生成 GREEN verification:
52
+ - `attempt_id`:从 task-start 结果获取,确保 RED/GREEN 绑定到正确的执行尝试
53
+ - `semantic_status`:`expected_failure`(RED)/ `expected_success`(GREEN)/ `characterization_pass`
54
+ - `task_structure_digest`:tasks.md 复选框归一化后的 sha256(引擎计算,你不需要手动算)
112
55
 
113
- ```text
114
- superspec check apply-verify-packet --change "<change>" --task-id "<task-id>" --executor-report-ref "<ref>" --task-code-review-report-ref "<ref>" --green-test-run-evidence-ref "<ref>" --red-test-run-evidence-ref "<ref>" --format prompt
115
- ```
56
+ 当前限制:
116
57
 
117
- no-TDD implementation/runtime_config 先登记 live/pass `alternative_verification` 或 `manual_verification`,再生成 alternative verification:
58
+ - 不要同时保留多个 active attempt;同一任务必须先完成或明确失败当前 attempt。
59
+ - 测试证据不按 `task_id` 或 `attempt_id` 绑定时,不要拿来完成任务。
60
+ - RED/GREEN 是流程纪律,不是引擎校验项;引擎只登记你提交的测试记录。
61
+ - 当前 CLI 没有 return-to-propose / reopen surface;不要假装存在回退到 propose 的命令。
118
62
 
119
- ```text
120
- superspec check apply-verify-packet --change "<change>" --task-id "<task-id>" --executor-report-ref "<ref>" --task-code-review-report-ref "<ref>" --alternative-verification-evidence-ref "<ref>" --format prompt
121
- ```
122
-
123
- 用 `.codex/agents/verifier.toml` 检查完成方式分支:GREEN 绑定 RED/characterization、GREEN 和当前工作区;alternative 绑定 no-TDD 激活标记、实际替代/人工验证引用、surface/no-TDD 元数据和当前工作区。审核 verifier 报告后写关闭的工作链证据,再跑 `task_complete`。异常终止只取消旧工作链,不授权完成。
124
-
125
- ## 完成检查
126
-
127
- 每个 task 的证据链(RED/characterization → executor → code-review → GREEN 或替代验证 → verifier)齐全后,运行任务完成检查:
128
-
129
- ```text
130
- superspec check workflow-packet --change "<change>" --gate task_complete --task-id "<task-id>" --format agent
131
- ```
132
-
133
- 只有检查结果显示通过后,才把该 task 的 checkbox 改为 done。所有 task 完成后进入 `superspec-review`。
134
-
135
- ## 异常恢复
136
-
137
- 状态文件损坏时重建:
138
-
139
- ```text
140
- superspec check recompute --change "<change>" --rebuild-corrupt
141
- ```
63
+ ## Guardrails
142
64
 
143
- 状态指纹过期时,重跑对应检查命令即可(检查命令会自动重算并刷新指纹);不要手写状态文件。
65
+ - 只改 tasks.md 里本任务范围相关的文件
66
+ - 不跳过 RED 直接写 GREEN
67
+ - 退出码 0 ≠ 测试通过——semantic_status 才是证据
68
+ - 环境错误 / 构建失败不算 RED 或 GREEN
69
+ - 不手改 tasks.md 复选框——task-complete 会自动补丁
70
+ - 不跳过 transition
71
+ - 不要发明当前分支没有的 `superspec check` / `apply_worker_chain` / `apply_isolation`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: superspec-archive
3
- description: "5.所有审查和验证通过后用:把完成的 change 归档到 specs,并确认关键证据和历史没有丢失;这一步是流程收尾。"
3
+ description: "归档保全:验证文档完整性,提交 archive。"
4
4
  metadata:
5
5
  author: SuperSpec
6
6
  source: SuperSpec
@@ -8,58 +8,33 @@ metadata:
8
8
 
9
9
  # SuperSpec Archive
10
10
 
11
- ## 语言规则 / Language
11
+ 你是归档阶段。职责:确认审查通过后,执行归档——保全清单记录当前文档指纹。
12
12
 
13
- - 默认使用简体中文写人类可读内容;命令、路径、字段名、阶段门名、task/test id、代码标识符保留原文。
14
- - 用户可见文案不得使用“裁决”描述用户动作;统一说“确认”“范围取舍”“处理方式选择”或“用户确认记录”。
15
- - 不把内部证据种类、reason code、JSON 字段大全直接转述给用户;需要诊断时才引用原文。
16
- - 普通 workflow 命令使用 `--format agent`;`--format json` 只用于诊断,不作为默认上下文。
13
+ ## 驱动方式
17
14
 
18
- ## 命令执行 / Shell
15
+ 所有状态由 transition engine 管理。循环:
19
16
 
20
- - Windows PowerShell 中使用 `.cmd` shim:`superspec.cmd ...`、`openspec.cmd ...`;不要运行 `superspec.ps1` 或 `openspec.ps1`。
21
- - 其他 shell 使用文档中的 `superspec ...`、`openspec ...` 命令。
17
+ 1. `superspec transition next --change "<change>"` 获取下一步
18
+ 2. 执行返回的命令
19
+ 3. 回到 1
22
20
 
23
- ## 阶段职责
21
+ ## 本阶段做什么
24
22
 
25
- Archive `review_complete` allowed 后收尾:确认 archive readiness、保全 `.superspec` 证据快照、运行 OpenSpec archive,并验证归档后的 preservation。
23
+ 1. **确认状态为 accepted**:next 会检查
24
+ 2. **archive**:`superspec transition archive --change "<change>"`
25
+ - 引擎记录当前文档指纹(proposal/tasks/design/discovery/bi/test-contract/specs)作为保全清单
26
+ - 归档事件写入 `events.jsonl`,并包含 `artifact_recorded`
27
+ - 缺失 artifact 会以 `sha256:missing` 表达
28
+ - 状态推进到 archive(终态)
26
29
 
27
- ## 第一条必跑命令
30
+ 当前限制:
28
31
 
29
- ```text
30
- superspec check workflow-packet --change "<change>" --gate archive_ready --format agent
31
- ```
32
+ - 这一步没有执行物理 OpenSpec archive;只是记录 SuperSpec 保全事件。
33
+ - 当前 CLI 没有 archive rollback / retry surface。
32
34
 
33
- 遇到 `block` 就停止,不归档。
35
+ ## Guardrails
34
36
 
35
- ## OpenSpec 边界
36
-
37
- - 直接使用 OpenSpec CLI surface,不读取 repo-local `openspec-*` skill 文本。
38
- - 归档动作使用 native OpenSpec CLI;SuperSpec 不重新实现移动、spec sync 或 validation。
39
- - 当前 v1 固定使用 `openspec archive -y "<change>"`,不暴露 `--no-validate` 或 skip-specs 分支。
40
-
41
- ## 用户确认边界
42
-
43
- `archive_ready` 最终确认必须等待明确选择。若 change 不应同步 specs,先回 propose/change update 调整方案,不在 archive 阶段跳过。
44
-
45
- ## 执行步骤
46
-
47
- 确认后运行会写 preservation manifest 的 readiness check:
48
-
49
- ```text
50
- superspec check check-archive-ready --change "<change>" --format agent
51
- ```
52
-
53
- 然后运行 OpenSpec archive:
54
-
55
- ```text
56
- openspec archive -y "<change>"
57
- ```
58
-
59
- 最后验证 archived sidecar preservation:
60
-
61
- ```text
62
- superspec check check-archived --change "<change>" --format agent
63
- ```
64
-
65
- `.superspec/artifacts/business-invariants.md`、`.superspec/artifacts/test-contract.md`、review/verification evidence、RED/GREEN evidence 和 archive evidence 必须能从 preservation manifest 追溯。
37
+ - 不改文档内容(归档前应已定稿)
38
+ - 不跳过 accept 直接 archive
39
+ - archive 后不可逆——确认无误再提交
40
+ - 不跳过 transition
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: superspec-explore
3
- description: "1.新需求刚开始时用:先把目标、范围、风险和现有代码事实弄清楚,产出探索记录(`discovery.md`);这一步只探索,不写正式方案,也不改代码。"
3
+ description: "探索现状、澄清范围、维护 discovery.md;通过 transition/record 把 change 从 init 推进到 propose。"
4
4
  metadata:
5
5
  author: SuperSpec
6
6
  source: SuperSpec
@@ -8,90 +8,59 @@ metadata:
8
8
 
9
9
  # SuperSpec Explore
10
10
 
11
- ## 语言规则 / Language
11
+ 你是探索阶段。职责:调查现状、梳理范围、识别风险,把结果沉淀到 `discovery.md`。不写业务代码,不提前写 proposal/specs/design/tasks。
12
12
 
13
- - 默认使用简体中文写人类可读内容;命令、路径、字段名、阶段门名、task/test id、代码标识符保留原文。
14
- - 用户可见文案不得使用“裁决”描述用户动作;统一说“确认”“范围取舍”“处理方式选择”或“用户确认记录”。
15
- - 不把内部证据种类、reason code、JSON 字段大全直接转述给用户;需要诊断时才引用原文。
16
- - 普通 workflow 命令使用 `--format agent`;`--format json` 只用于诊断,不作为默认上下文。
13
+ ## 驱动方式
17
14
 
18
- ## 命令执行 / Shell
15
+ 所有状态由 transition engine 管理。循环:
19
16
 
20
- - Windows PowerShell 中使用 `.cmd` shim:`superspec.cmd ...`、`openspec.cmd ...`;不要运行 `superspec.ps1` 或 `openspec.ps1`。
21
- - 其他 shell 使用文档中的 `superspec ...`、`openspec ...` 命令。
17
+ 1. `superspec transition next --change "<change>"` 获取下一步
18
+ 2. 执行返回的命令
19
+ 3. 登记结果
20
+ 4. 回到 1
22
21
 
23
- ## 阶段职责
22
+ next 返回 `ask_user` 说明 discovery 不完整或有未确认问题——向用户提问,收到回答后 `superspec record user-decision --change "<change>" --input <FILE>`。
24
23
 
25
- Explore 只做需求澄清、代码事实调查、范围边界和风险记录。产物是 `openspec/changes/<change>/.superspec/artifacts/discovery.md`;不写 `proposal.md`、`specs/**`、`design.md`、`tasks.md`,也不改实现代码。
24
+ 当前 CLI surface:
26
25
 
27
- ## 产物格式
26
+ - 用 `openspec list --json` 和 `openspec status --change "<change>" --json` 建立 OpenSpec 事实基线。
27
+ - 用 `superspec transition explore --change "<change>"` 从 init 进入探索阶段。
28
+ - 用户回答阻塞问题后,写入决策文件并执行 `superspec record user-decision --change "<change>" --input <decision.json>`。
29
+ - 不要把 `superspec status` 的 job 计数当成权威事实;阶段推进以 transition / record 返回值和 OpenSpec 文档为准。
28
30
 
29
- - discovery.md 必须按 SuperSpec discovery 模板的结构填写,保留全部段落:`调查范围` / `现有实现事实` / `隐性合约` / `风险与歧义` / `待确认问题` / `Subagent Evidence`;不得自创或删减段落骨架。
30
- - 第一条必跑命令 `superspec check workflow-packet --change "<change>" --gate explore_complete --format agent` 的返回里带 `discovery_template` 与 `discovery_rules`:按其中的模板骨架和填写规则产出,而不是自由发挥,这样无论哪个模型产物结构都一致。
31
+ ## 本阶段做什么
31
32
 
32
- ## 第一条必跑命令
33
+ 1. **建立事实基线**:读代码、查架构、理解当前系统行为(只读)
34
+ 2. **写 discovery.md**:
35
+ 3. **澄清歧义**:有阻塞歧义时向用户提问
33
36
 
34
- ```text
35
- superspec init --scope project --format agent
36
- ```
37
+ ## discovery.md 格式
37
38
 
38
- 随后用 `openspec list --json` 查找匹配 change;若已有则复用,若没有则直接创建,不要先跑 `openspec --help` / `openspec change --help` / `openspec new --help` 探测语法(命令失败或版本报错时才查 help 诊断)。
39
+ 写入 `openspec/changes/<change>/.superspec/artifacts/discovery.md`:
39
40
 
40
- ```text
41
- openspec list --json
42
- ```
41
+ ```markdown
42
+ # Discovery
43
43
 
44
- 仅当 `openspec list --json` 没有匹配 change 时运行:
44
+ ## 现状
45
+ (当前系统怎么工作)
45
46
 
46
- ```text
47
- openspec new change "<change>" --description "<用户需求摘要>"
48
- ```
47
+ ## 需要改什么
48
+ (要实现的需求)
49
49
 
50
- 然后读取当前上下文:
50
+ ## 风险和边界
51
+ (技术风险、依赖、兼容性)
51
52
 
52
- ```text
53
- openspec status --change "<change>" --json
54
- superspec check check-init --change "<change>" --format agent
55
- superspec check workflow-packet --change "<change>" --gate explore_complete --format agent
53
+ ## 待确认问题
54
+ - [ ] 问题1的描述
55
+ - [ ] 问题2的描述
56
56
  ```
57
57
 
58
- 遇到 `block` 就停止,按检查结果的下一步提示处理;不要绕过检查。
59
-
60
- ## OpenSpec 边界
61
-
62
- - 直接使用 OpenSpec CLI surface,不读取 repo-local `openspec-*` skill 文本。
63
- - 用 `openspec list --json` 和 `openspec status --change "<change>" --json` 确认 change 结构、artifactPaths 和当前状态。
64
- - OpenSpec 负责 change 结构和后续 artifact 语义;本阶段只补 SuperSpec discovery 证据。
65
- - 如果发现需要正式方案、规格、设计或任务,先写入 discovery,再交给 `superspec-propose`。
66
- - 代码事实扫描可由主线程直接完成;若并行创建只读子代理,使用 repo-local `.codex/agents/explore.toml`。该角色只辅助 discovery 覆盖,不能替代 `critic` 审查证据。
67
-
68
- ## 专用代理边界
69
-
70
- 需求审查由本仓库的 `critic` 专用代理完成。生成审查提示时使用检查命令的输出,而不是把披露协议常驻在 skill 正文:
71
-
72
- ```text
73
- superspec check review-packet --change "<change>" --gate explore_complete --role critic --round 1 --format prompt
74
- ```
58
+ **重要**:`- [ ]` 标记的待确认问题必须全部解决。收到用户确认后,把对应未决项从 `- [ ]` 改成 `- [x]` 或删除;只留档、不回写 `discovery.md`,阶段还是过不去。
75
59
 
76
- 主流程整理审查问题时读取主线程提示信息:
77
-
78
- ```text
79
- superspec check review-packet --change "<change>" --gate explore_complete --role main-thread --round 1 --format agent
80
- ```
81
-
82
- 第二轮及以后的审查,必须由检查命令把上一轮的问题注入提示;不要手写历史问题清单。
83
-
84
- ## 用户确认边界
85
-
86
- - 关键范围、非目标、验收标准、业务语义或设计边界问题必须面向用户说明并等待明确确认。
87
- - 探索结论、范围边界和进入 propose 的授权必须等待用户确认后再记录 evidence。
88
- - discovery.md 必须含 `## 待确认问题` 段(标题含「确认」字样即可,如「待确认问题」「需要用户确认的问题」)。每条问题用 `- [ ]`(未决)或 `- [x]`(已确认)标记;也可在已确认项写「已确认:」。**该段只要还有 `- [ ]` 或「仍需确认/待确认」项,`explore_complete` 检查就不会通过**,不得记录人工确认,也不得进入 propose。
89
- - 用户看到的文字要用中文业务语言;内部 JSON 名只写进证据、命令输出或诊断片段。
90
-
91
- ## 完成检查
92
-
93
- ```text
94
- superspec check workflow-packet --change "<change>" --gate explore_complete --format agent
95
- ```
60
+ ## Guardrails
96
61
 
97
- 只有检查结果显示通过后,才进入 `superspec-propose`。
62
+ - 不改业务代码
63
+ - 不写 proposal/specs/design/tasks
64
+ - 不跳过 transition 直接编辑状态文件
65
+ - 用户未确认的决策不自行推断
66
+ - 不要伪造当前分支没有的 `superspec check`