@jakkrichm/create-nexus-devflow 2.2.1 → 2.2.2

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.
@@ -12,6 +12,10 @@ export interface GateReport {
12
12
  warnings: string[];
13
13
  findingsBlockers: number;
14
14
  remainingTasks: number;
15
+ twoStage: {
16
+ stage1SpecFidelity: boolean;
17
+ stage2CodeQuality: boolean;
18
+ };
15
19
  summary: string;
16
20
  }
17
21
  export declare function evaluateGate(projectRoot: string, options?: GateOptions): Promise<GateReport>;
@@ -38,6 +38,8 @@ export async function evaluateGate(projectRoot, options = {}) {
38
38
  }
39
39
  }
40
40
  catch { }
41
+ const stage1SpecFidelity = remaining === 0 && (status.currentWork.state === "idle" || status.completion.state === "ready" || !options.strict);
42
+ const stage2CodeQuality = blockers.length === 0;
41
43
  const passed = violations.length === 0;
42
44
  const exitCode = passed ? 0 : 1;
43
45
  let summary = "";
@@ -45,7 +47,7 @@ export async function evaluateGate(projectRoot, options = {}) {
45
47
  summary =
46
48
  status.currentWork.state === "idle"
47
49
  ? "Quality Gate Passed: Workspace is clean with 0 blockers."
48
- : "Quality Gate Passed: Active run satisfies all gatekeeper criteria.";
50
+ : "Quality Gate Passed: Active run satisfies all gatekeeper criteria (Stage 1 Spec & Stage 2 Quality).";
49
51
  }
50
52
  else {
51
53
  summary = `Quality Gate Failed: ${violations.length} blocker(s) detected.`;
@@ -59,6 +61,10 @@ export async function evaluateGate(projectRoot, options = {}) {
59
61
  warnings,
60
62
  findingsBlockers: blockers.length,
61
63
  remainingTasks: remaining,
64
+ twoStage: {
65
+ stage1SpecFidelity,
66
+ stage2CodeQuality
67
+ },
62
68
  summary
63
69
  };
64
70
  }
@@ -72,6 +78,12 @@ export function formatGateReport(report, options = {}) {
72
78
  lines.push(header);
73
79
  lines.push(` ${style.dim(report.summary)}`);
74
80
  lines.push("");
81
+ const s1Badge = report.twoStage.stage1SpecFidelity ? style.green("✔ PASS") : style.red("✖ FAIL");
82
+ const s2Badge = report.twoStage.stage2CodeQuality ? style.green("✔ PASS") : style.red("✖ FAIL");
83
+ lines.push(style.bold("Two-Stage Review Status:"));
84
+ lines.push(` - Stage 1 (Spec Fidelity & Tasks) : ${s1Badge}`);
85
+ lines.push(` - Stage 2 (Code Quality & Security): ${s2Badge}`);
86
+ lines.push("");
75
87
  if (report.violations.length > 0) {
76
88
  lines.push(style.bold(style.red("Violations:")));
77
89
  for (const v of report.violations) {
@@ -1 +1 @@
1
- {"version":3,"file":"gatekeeper.js","sourceRoot":"","sources":["../../lib/gatekeeper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAoBtC,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,WAAmB,EACnB,UAAuB,EAAE;IAEzB,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,sEAAsE;IACtE,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;IAChD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,UAAU,CAAC,IAAI,CACb,WAAW,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,QAAQ,MAAM,OAAO,CAAC,MAAM,MAAM,OAAO,CAAC,KAAK,EAAE,CACpF,CAAC;IACJ,CAAC;IAED,oEAAoE;IACpE,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,CACvD,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC,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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakkrichm/create-nexus-devflow",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "Installer package for Nexus-DevFlow agentic workflow layer.",
5
5
  "license": "MIT",
6
6
  "author": "Jakkrich",
@@ -83,12 +83,12 @@ Record important findings in `30-plan.md`. Use legacy context updates only when
83
83
 
84
84
  ### 4. Build The Plan
85
85
 
86
- Use the old planner discipline, but keep `30-plan.md` as the main contract:
86
+ Use strict planning discipline, keeping `30-plan.md` as the main contract:
87
87
 
88
+ - **Atomic Micro-Task Sizing (2–5 Minutes)**: Every subtask must be a small, verifiable unit that can be implemented and reviewed cleanly without context sprawl.
88
89
  - record the planning loop evidence: context read, observations, adjustments made, stop condition, and handoff notes
89
90
  - add phases in dependency order
90
- - add subtasks that are small, verifiable units
91
- - include explicit files to modify or create
91
+ - include explicit files to modify or create (exact file paths)
92
92
  - include patterns to follow
93
93
  - include verification command or manual check
94
94
  - include a test decision for every subtask
@@ -97,18 +97,24 @@ Use the old planner discipline, but keep `30-plan.md` as the main contract:
97
97
  Each subtask should answer:
98
98
 
99
99
  - what to change
100
- - where to change it
100
+ - where to change it (exact path)
101
101
  - which pattern to follow
102
102
  - how to verify it
103
103
  - whether automated tests are required, manual, or not required
104
104
 
105
- ### 4.1 Test Decision Gate
105
+ ### 4.1 Strict TDD Task Breakdown & Test Decision Gate
106
106
 
107
- **STRICT MANDATE (กฎเหล็ก Unit Test)**: สำหรับทุก subtask ที่มีการเพิ่ม แก้ไข หรือเปลี่ยนแปลงการทำงานของโค้ด (Behavior Change) **ต้องระบุเป็น `Required` เสมอ** ห้ามละเว้นเด็ดขาด ยกเว้นงานประเภทเอกสารหรือแก้ไข Configuration เท่านั้น
107
+ **STRICT MANDATE (กฎเหล็ก Unit Test & TDD)**: สำหรับทุก subtask ที่มีการเพิ่ม แก้ไข หรือเปลี่ยนแปลงการทำงานของโค้ด (Behavior Change) **ต้องระบุเป็น `Required` เสมอ** และต้องย่อยงานเป็น **TDD Triplet Sub-tasks** ดังนี้:
108
+
109
+ ```markdown
110
+ - [ ] Task 1.1 [TDD-Red]: Write failing test for {feature/behavior} in {test_file} and verify failure
111
+ - [ ] Task 1.2 [TDD-Green]: Implement minimal code in {src_file} to satisfy Task 1.1 test
112
+ - [ ] Task 1.3 [TDD-Refactor]: Refactor logic, eliminate duplication, and verify zero regression
113
+ ```
108
114
 
109
115
  For every subtask, decide one of:
110
116
 
111
- - `Required`: automated tests must be created or updated (Mandatory for all behavior changes)
117
+ - `Required`: automated tests must be created or updated (Mandatory for all behavior changes, formatted as TDD Triplet)
112
118
  - `Manual/Command Only`: verification is non-test but still explicit (Only for configuration/infrastructure tasks)
113
119
  - `Not Required`: no new automated test is needed because there is no meaningful behavior surface (Only for documentation/comments)
114
120
 
@@ -59,27 +59,24 @@ Confirm the current Git branch with `git branch --show-current` and use that bra
59
59
 
60
60
  Select one scoped unit of work at a time. Do not implement the whole plan as one blob.
61
61
 
62
- ### 2. Execute One Scoped Unit
62
+ ### 2. Execute One Scoped Unit (Strict TDD Red-Green-Refactor)
63
63
 
64
- Use the original coder discipline, adapted to 2.0:
64
+ Use the strict coder discipline:
65
65
 
66
- - **STRICT MANDATE (กฎเหล็ก Unit Test)**: ต้องสร้าง/แก้ไข Unit Test ควบคู่กับการแก้ไขโค้ดเสมอ โดยห้ามแก้ไขเฉพาะไฟล์โค้ดหลัก (Production Code) โดยไม่แก้ไขหรือสร้างไฟล์เทสต์ควบคู่กัน
66
+ - **STRICT MANDATE (กฎเหล็ก Unit Test & TDD)**: สำหรับทุกงานที่มีการแก้ไข logic การทำงาน ต้องสร้างหรือแก้ไข Unit Test ควบคู่กับการแก้ไขโค้ดเสมอ โดยห้ามเขียนเฉพาะ Production Code โดยไม่มีเทสต์
67
+ - **🔴 RED (Test First)**: ออกแบบและเขียน Test Case ในไฟล์เทสต์ก่อนเสมอ แล้วรันคำสั่งเทสต์เพื่อพิสูจน์ว่า **Test ล้มเหลว (FAIL)** ตามที่คาดหวัง
68
+ - **🟢 GREEN (Minimal Implementation)**: เขียน Production Code เท่าที่จำเป็นเพื่อให้เทสต์ผ่าน แล้วรันคำสั่งเทสต์เพื่อพิสูจน์ว่า **Test ผ่าน 100% (PASS)**
69
+ - **🔵 REFACTOR (Clean Code)**: ปรับปรุงโครงสร้างโค้ดให้อ่านง่าย กำจัดความซ้ำซ้อน (DRY) โดยที่เทสต์ยังคงเขียว 100%
70
+ - **Code Deletion / Reversion Rule**: หากเผลอเขียน Production Code ก่อนมีเทสต์ ให้ Revert หรือลบโค้ดส่วนนั้น แล้วเริ่มวงจร RED ก่อนเสมอ
67
71
  - start each scoped unit by naming its intent, context, expected observation, adjustment route, and stop condition
68
72
  - read referenced pattern files before editing
69
73
  - read the test decision from `30-plan.md`
70
74
  - confirm assumptions, target files, and success criteria before editing
71
- - make the smallest useful code change
72
75
  - preserve project style
73
- - run the planned verification
76
+ - run the planned verification and capture concrete terminal outputs
74
77
  - record observation, adjustment, stop condition status, and the result in `40-execute.md`
75
78
  - update checklist item status, timestamps, and evidence links as work progresses
76
79
 
77
- If tests are `Required`:
78
-
79
- 1. **TDD Cycle (RED)**: ออกแบบและเขียนตัวเทสต์ให้พังก่อน (หรือเขียนโครงสร้างเทสต์ที่คาดหวังผลลัพธ์ที่ถูกต้อง) ตามแนวทางใน [coding-standards.md](file:///devflow/context/coding-standards.md)
80
- 2. **GREEN**: เขียนโค้ดระบบจริงให้สอดคล้องเพื่อให้เทสต์ผ่าน
81
- 3. **REFACTOR**: ปรับปรุงโครงสร้างโค้ดโดยยังคงรันเทสต์ผ่านอย่างต่อเนื่อง
82
-
83
80
  ### 3. Recovery
84
81
 
85
82
  Use the old recovery discipline when blocked:
@@ -18,15 +18,21 @@ Review implementation quality, run multi-lane validation, produce a verification
18
18
  Use `50-verify.md` as the primary verification artifact.
19
19
  Use `50-verify-impact.md` as an optional companion artifact when the run changes behavior, touches core logic, crosses integration boundaries, or needs explicit rollback and client impact analysis.
20
20
 
21
- ## Process & Quality Gates
21
+ ## Process & Quality Gates (Two-Stage Review Pattern)
22
22
 
23
- ### 1. Senior QA Review & Multi-Lane Verification
23
+ ### Stage 1: Spec Fidelity & Acceptance Criteria Gate
24
+ Before evaluating technical code metrics, verify that the implementation faithfully delivers what was specified:
25
+ 1. **Acceptance Criteria Validation**: Cross-check each Acceptance Criterion (AC-1, AC-2, ...) in `20-spec.md` or `current-feature.md` and verify concrete evidence of completion.
26
+ 2. **Done-When Observable Verification**: Check that all observable conditions ("Done when...") are satisfied in the running application or test suite.
27
+ 3. **Scope Discipline**: Ensure zero scope creep (no unrequested features added) and no unfulfilled functional requirements.
28
+ 4. **Boundary & Negative Scenarios**: Verify unhappy paths, empty inputs, and error states defined in the specification.
24
29
 
25
- Execute verification across all essential quality dimensions:
30
+ ### Stage 2: Code Quality, Security & Architecture Gate
31
+ Execute multi-lane technical verification across all essential quality dimensions:
26
32
 
27
33
  1. **Lane 1: Typecheck & Static Code Quality**:
28
34
  - Run typecheck and static analysis (`tsc --noEmit`, `npm run lint`).
29
- 2. **Lane 2: Automated Test Suites (TDD Gate)**:
35
+ 2. **Lane 2: Automated Test Suites (Strict TDD Gate)**:
30
36
  - Run automated unit and integration tests (`npm test`).
31
37
  - Confirm 100% test pass rate with zero disabled or skipped tests.
32
38
  3. **Lane 3: Scrutinize QA & Edge Cases Review**:
@@ -44,12 +50,13 @@ Execute verification across all essential quality dimensions:
44
50
 
45
51
  ### 2. Decision & Route
46
52
 
47
- - **Pass**: Route to `60-report {ID}`.
48
- - **Fail**: Route back to `40-execute {ID}` with exact failure evidence and remediation steps.
53
+ - **Pass**: Both Stage 1 and Stage 2 pass with 0 blockers -> Route to `60-report {ID}`.
54
+ - **Fail**: Either Stage 1 or Stage 2 fails -> Route back to `40-execute {ID}` with exact failure evidence and remediation steps.
49
55
 
50
56
  ## Output
51
57
 
52
58
  Report:
53
- - QA verdict across all verification lanes
59
+ - **Stage 1 Verdict**: Spec Fidelity & Acceptance Criteria status
60
+ - **Stage 2 Verdict**: Technical Multi-lane quality & security matrix
54
61
  - Evidence commands and outputs
55
62
  - Next command: `60-report {ID}` (if pass) or `40-execute {ID}` (if fail)
@@ -66,21 +66,29 @@ Drive the app to each checklist item and capture evidence as you go:
66
66
  - Watch for **console errors and failed network requests**; a clean-looking screen
67
67
  with errors in the console is not a pass.
68
68
 
69
- ## Step 4 - report
69
+ ## Step 4 - report (Two-Stage Review Pattern)
70
70
 
71
- Give a short, honest verdict, one line per checklist item:
71
+ Format the verification report into two explicit review stages:
72
72
 
73
- [pass] Download PDF saves certificate-<slug>.pdf - file downloaded, opened to the cert
74
- [pass] Both buttons show a loading state - screenshot: loading-state.png
75
- [fail] PDF border missing - printBackground not set; screenshot: pdf-no-border.png
76
- [skip] Vercel render - can't verify locally (feature 9)
73
+ ### Stage 1: Spec Fidelity & Acceptance Gate
74
+ Give a line-by-line verdict for each Acceptance Criterion and "done when" item:
77
75
 
78
- Then state the bottom line: are all the feature's done-whens proven, or not yet.
76
+ [pass] AC-1: Download PDF saves certificate-<slug>.pdf - file downloaded, opened to cert
77
+ [pass] AC-2: Both buttons show a loading state - screenshot: loading-state.png
78
+ [fail] AC-3: PDF border missing - printBackground not set; screenshot: pdf-no-border.png
79
+ [skip] AC-4: Vercel deploy smoke test - can't verify locally (pending staging)
79
80
 
80
- - All proven -> say it's ready for `/complete`.
81
- - Anything failed -> hand back to `/implement` to fix; name what to fix. Don't fix
82
- it here.
83
- - Anything unverifiable -> say so plainly and why; never report it as a pass.
81
+ ### Stage 2: Code Quality, Security & Architecture Gate
82
+ Report the multi-lane technical verification results:
83
+ - **Type & Syntax**: `tsc --noEmit` (0 errors)
84
+ - **Automated Tests**: Unit & integration tests (100% pass)
85
+ - **Security & Hygiene**: Zero secrets, sanitized inputs
86
+ - **Findings Ledger**: 0 blockers (P0/P1) in `devflow/context/findings.md`
87
+
88
+ ### Final Verdict & Route
89
+ - **All Passed**: State that the feature is verified and ready for `/complete`.
90
+ - **Any Failure**: Hand back to `/implement` with exact failure evidence and reproduction steps. Never fix issues inside `/check`.
91
+ - **Unverifiable**: Clearly state reasons and residual risk. Never fabricate a pass.
84
92
 
85
93
  ## Rules
86
94
 
@@ -117,14 +117,10 @@ Give a concise debug report:
117
117
 
118
118
  Choose the next action without writing files:
119
119
 
120
- - Active feature or fix caused the failure -> return the diagnosis to
121
- `/implement`.
122
- - No active work item and the bug is confirmed -> recommend
123
- `/fix "<concise bug and confirmed cause>"`.
124
- - Cause is only likely or blocked -> recommend the next diagnostic evidence, not
125
- a speculative repair.
126
- - The issue is planned product work rather than a defect -> point to
127
- `/feature`.
120
+ - Active feature or fix caused the failure -> return the diagnosis to `/implement` with instructions to write a failing reproduction test ([TDD-Red]) first.
121
+ - No active work item and the bug is confirmed -> recommend `/fix "<concise bug and confirmed cause>"` (which will write a failing test first before fixing).
122
+ - Cause is only likely or blocked -> recommend the next diagnostic evidence, not a speculative repair.
123
+ - The issue is planned product work rather than a defect -> point to `/feature`.
128
124
 
129
125
  ## Rules
130
126
 
@@ -113,10 +113,14 @@ build plan starts high-level.
113
113
 
114
114
  For the one (sub-)feature being built now, write a full spec to
115
115
  `devflow/context/current-feature.md` (create `devflow/context/` if needed), following
116
- `reference/feature-spec-template.md`. Fill every section: goal, in/out of scope,
117
- the build loop, small build steps as a checklist (`- [ ]`, each with an observable
118
- "done when" - `/implement` ticks them off and resumes from the first unchecked
119
- one), files/areas, data/contracts, testing, and notes for the AI.
116
+ `reference/feature-spec-template.md`. Fill every section:
117
+ - Goal, Problem Statement, and In/Out of scope
118
+ - Acceptance Criteria (AC-1, AC-2, ...)
119
+ - Small build steps as atomic 2-5 min checklist items (`- [ ]`, supporting `[TDD-Red]`, `[TDD-Green]`, `[TDD-Refactor]` triplets for functional logic)
120
+ - Two-Stage Verification Strategy:
121
+ - **Stage 1**: Spec Fidelity & Acceptance Criteria Gate
122
+ - **Stage 2**: Technical Multi-lane quality, tests, security, and findings ledger
123
+ - Files/areas to modify, data/contracts, and notes for the AI.
120
124
 
121
125
  **Visual or replication features need a reference image.** If the feature is
122
126
  "make it look like X" - recreating an existing design, matching a mockup, or
@@ -88,19 +88,23 @@ broad checkout. Ask whether to resolve only the conflict allowed by the approved
88
88
  spec or abandon the attempt. A cascade into another completed feature needs a
89
89
  new rollback plan.
90
90
 
91
- ## Step 2 - build one step, review, iterate, checkpoint
91
+ ## Step 2 - build one step, review, iterate, checkpoint (Strict TDD)
92
92
 
93
93
  Work through the spec's build steps in order, one at a time. For each step:
94
94
 
95
- 1. Implement just that step: the smallest change that satisfies its "done when."
96
- 2. Show the **diff**, not whole files.
97
- 3. **Explain it, and prove it.** Give a short summary: what the step delivered,
95
+ 1. **Strict TDD Cycle (for logic & behavior changes)**:
96
+ - **🔴 RED**: Write the unit test first in the relevant test file. Execute the test command and show the failing assertion output.
97
+ - **🟢 GREEN**: Implement only the minimal code in the source file necessary to make the test pass. Re-run test and show passing output.
98
+ - **🔵 REFACTOR**: Refactor and format cleanly, verifying that 100% of tests remain green.
99
+ - *Code Reversion Rule*: If production code is written without a prior test for behavior changes, revert it and write the test first.
100
+ 2. Implement just that step: the smallest change that satisfies its "done when."
101
+ 3. Show the **diff**, not whole files.
102
+ 4. **Explain it, and prove it.** Give a short summary: what the step delivered,
98
103
  one line per changed file on what it does and why, then confirm the step's
99
- "done when" is met with evidence (build output, a screenshot, a passing
100
- assertion). This summary is the comprehension gate, so keep it concrete, not
101
- ceremonial. Include a short **How to try it** note when the step has a manual
104
+ "done when" is met with empirical evidence (test pass output, build output, or screenshot). This summary is the comprehension gate, so keep it concrete, not
105
+ vague. Include a short **How to try it** note when the step has a manual
102
106
  path: the command, URL, click, endpoint, or output the user can check.
103
- 4. **Verify the step.** If `AGENTS.md` declares a `Verify` command, run that exact
107
+ 5. **Verify the step.** If `AGENTS.md` declares a `Verify` command, run that exact
104
108
  command as the automated gate. It is only an umbrella for checks the project
105
109
  actually has, so do not invent tests or other checks to satisfy it. If no
106
110
  `Verify` command exists, run the documented build command and the test command
@@ -83,12 +83,12 @@ Record important findings in `30-plan.md`. Use legacy context updates only when
83
83
 
84
84
  ### 4. Build The Plan
85
85
 
86
- Use the old planner discipline, but keep `30-plan.md` as the main contract:
86
+ Use strict planning discipline, keeping `30-plan.md` as the main contract:
87
87
 
88
+ - **Atomic Micro-Task Sizing (2–5 Minutes)**: Every subtask must be a small, verifiable unit that can be implemented and reviewed cleanly without context sprawl.
88
89
  - record the planning loop evidence: context read, observations, adjustments made, stop condition, and handoff notes
89
90
  - add phases in dependency order
90
- - add subtasks that are small, verifiable units
91
- - include explicit files to modify or create
91
+ - include explicit files to modify or create (exact file paths)
92
92
  - include patterns to follow
93
93
  - include verification command or manual check
94
94
  - include a test decision for every subtask
@@ -97,18 +97,24 @@ Use the old planner discipline, but keep `30-plan.md` as the main contract:
97
97
  Each subtask should answer:
98
98
 
99
99
  - what to change
100
- - where to change it
100
+ - where to change it (exact path)
101
101
  - which pattern to follow
102
102
  - how to verify it
103
103
  - whether automated tests are required, manual, or not required
104
104
 
105
- ### 4.1 Test Decision Gate
105
+ ### 4.1 Strict TDD Task Breakdown & Test Decision Gate
106
106
 
107
- **STRICT MANDATE (กฎเหล็ก Unit Test)**: สำหรับทุก subtask ที่มีการเพิ่ม แก้ไข หรือเปลี่ยนแปลงการทำงานของโค้ด (Behavior Change) **ต้องระบุเป็น `Required` เสมอ** ห้ามละเว้นเด็ดขาด ยกเว้นงานประเภทเอกสารหรือแก้ไข Configuration เท่านั้น
107
+ **STRICT MANDATE (กฎเหล็ก Unit Test & TDD)**: สำหรับทุก subtask ที่มีการเพิ่ม แก้ไข หรือเปลี่ยนแปลงการทำงานของโค้ด (Behavior Change) **ต้องระบุเป็น `Required` เสมอ** และต้องย่อยงานเป็น **TDD Triplet Sub-tasks** ดังนี้:
108
+
109
+ ```markdown
110
+ - [ ] Task 1.1 [TDD-Red]: Write failing test for {feature/behavior} in {test_file} and verify failure
111
+ - [ ] Task 1.2 [TDD-Green]: Implement minimal code in {src_file} to satisfy Task 1.1 test
112
+ - [ ] Task 1.3 [TDD-Refactor]: Refactor logic, eliminate duplication, and verify zero regression
113
+ ```
108
114
 
109
115
  For every subtask, decide one of:
110
116
 
111
- - `Required`: automated tests must be created or updated (Mandatory for all behavior changes)
117
+ - `Required`: automated tests must be created or updated (Mandatory for all behavior changes, formatted as TDD Triplet)
112
118
  - `Manual/Command Only`: verification is non-test but still explicit (Only for configuration/infrastructure tasks)
113
119
  - `Not Required`: no new automated test is needed because there is no meaningful behavior surface (Only for documentation/comments)
114
120
 
@@ -59,27 +59,24 @@ Confirm the current Git branch with `git branch --show-current` and use that bra
59
59
 
60
60
  Select one scoped unit of work at a time. Do not implement the whole plan as one blob.
61
61
 
62
- ### 2. Execute One Scoped Unit
62
+ ### 2. Execute One Scoped Unit (Strict TDD Red-Green-Refactor)
63
63
 
64
- Use the original coder discipline, adapted to 2.0:
64
+ Use the strict coder discipline:
65
65
 
66
- - **STRICT MANDATE (กฎเหล็ก Unit Test)**: ต้องสร้าง/แก้ไข Unit Test ควบคู่กับการแก้ไขโค้ดเสมอ โดยห้ามแก้ไขเฉพาะไฟล์โค้ดหลัก (Production Code) โดยไม่แก้ไขหรือสร้างไฟล์เทสต์ควบคู่กัน
66
+ - **STRICT MANDATE (กฎเหล็ก Unit Test & TDD)**: สำหรับทุกงานที่มีการแก้ไข logic การทำงาน ต้องสร้างหรือแก้ไข Unit Test ควบคู่กับการแก้ไขโค้ดเสมอ โดยห้ามเขียนเฉพาะ Production Code โดยไม่มีเทสต์
67
+ - **🔴 RED (Test First)**: ออกแบบและเขียน Test Case ในไฟล์เทสต์ก่อนเสมอ แล้วรันคำสั่งเทสต์เพื่อพิสูจน์ว่า **Test ล้มเหลว (FAIL)** ตามที่คาดหวัง
68
+ - **🟢 GREEN (Minimal Implementation)**: เขียน Production Code เท่าที่จำเป็นเพื่อให้เทสต์ผ่าน แล้วรันคำสั่งเทสต์เพื่อพิสูจน์ว่า **Test ผ่าน 100% (PASS)**
69
+ - **🔵 REFACTOR (Clean Code)**: ปรับปรุงโครงสร้างโค้ดให้อ่านง่าย กำจัดความซ้ำซ้อน (DRY) โดยที่เทสต์ยังคงเขียว 100%
70
+ - **Code Deletion / Reversion Rule**: หากเผลอเขียน Production Code ก่อนมีเทสต์ ให้ Revert หรือลบโค้ดส่วนนั้น แล้วเริ่มวงจร RED ก่อนเสมอ
67
71
  - start each scoped unit by naming its intent, context, expected observation, adjustment route, and stop condition
68
72
  - read referenced pattern files before editing
69
73
  - read the test decision from `30-plan.md`
70
74
  - confirm assumptions, target files, and success criteria before editing
71
- - make the smallest useful code change
72
75
  - preserve project style
73
- - run the planned verification
76
+ - run the planned verification and capture concrete terminal outputs
74
77
  - record observation, adjustment, stop condition status, and the result in `40-execute.md`
75
78
  - update checklist item status, timestamps, and evidence links as work progresses
76
79
 
77
- If tests are `Required`:
78
-
79
- 1. **TDD Cycle (RED)**: ออกแบบและเขียนตัวเทสต์ให้พังก่อน (หรือเขียนโครงสร้างเทสต์ที่คาดหวังผลลัพธ์ที่ถูกต้อง) ตามแนวทางใน [coding-standards.md](file:///devflow/context/coding-standards.md)
80
- 2. **GREEN**: เขียนโค้ดระบบจริงให้สอดคล้องเพื่อให้เทสต์ผ่าน
81
- 3. **REFACTOR**: ปรับปรุงโครงสร้างโค้ดโดยยังคงรันเทสต์ผ่านอย่างต่อเนื่อง
82
-
83
80
  ### 3. Recovery
84
81
 
85
82
  Use the old recovery discipline when blocked:
@@ -18,15 +18,21 @@ Review implementation quality, run multi-lane validation, produce a verification
18
18
  Use `50-verify.md` as the primary verification artifact.
19
19
  Use `50-verify-impact.md` as an optional companion artifact when the run changes behavior, touches core logic, crosses integration boundaries, or needs explicit rollback and client impact analysis.
20
20
 
21
- ## Process & Quality Gates
21
+ ## Process & Quality Gates (Two-Stage Review Pattern)
22
22
 
23
- ### 1. Senior QA Review & Multi-Lane Verification
23
+ ### Stage 1: Spec Fidelity & Acceptance Criteria Gate
24
+ Before evaluating technical code metrics, verify that the implementation faithfully delivers what was specified:
25
+ 1. **Acceptance Criteria Validation**: Cross-check each Acceptance Criterion (AC-1, AC-2, ...) in `20-spec.md` or `current-feature.md` and verify concrete evidence of completion.
26
+ 2. **Done-When Observable Verification**: Check that all observable conditions ("Done when...") are satisfied in the running application or test suite.
27
+ 3. **Scope Discipline**: Ensure zero scope creep (no unrequested features added) and no unfulfilled functional requirements.
28
+ 4. **Boundary & Negative Scenarios**: Verify unhappy paths, empty inputs, and error states defined in the specification.
24
29
 
25
- Execute verification across all essential quality dimensions:
30
+ ### Stage 2: Code Quality, Security & Architecture Gate
31
+ Execute multi-lane technical verification across all essential quality dimensions:
26
32
 
27
33
  1. **Lane 1: Typecheck & Static Code Quality**:
28
34
  - Run typecheck and static analysis (`tsc --noEmit`, `npm run lint`).
29
- 2. **Lane 2: Automated Test Suites (TDD Gate)**:
35
+ 2. **Lane 2: Automated Test Suites (Strict TDD Gate)**:
30
36
  - Run automated unit and integration tests (`npm test`).
31
37
  - Confirm 100% test pass rate with zero disabled or skipped tests.
32
38
  3. **Lane 3: Scrutinize QA & Edge Cases Review**:
@@ -44,12 +50,13 @@ Execute verification across all essential quality dimensions:
44
50
 
45
51
  ### 2. Decision & Route
46
52
 
47
- - **Pass**: Route to `60-report {ID}`.
48
- - **Fail**: Route back to `40-execute {ID}` with exact failure evidence and remediation steps.
53
+ - **Pass**: Both Stage 1 and Stage 2 pass with 0 blockers -> Route to `60-report {ID}`.
54
+ - **Fail**: Either Stage 1 or Stage 2 fails -> Route back to `40-execute {ID}` with exact failure evidence and remediation steps.
49
55
 
50
56
  ## Output
51
57
 
52
58
  Report:
53
- - QA verdict across all verification lanes
59
+ - **Stage 1 Verdict**: Spec Fidelity & Acceptance Criteria status
60
+ - **Stage 2 Verdict**: Technical Multi-lane quality & security matrix
54
61
  - Evidence commands and outputs
55
62
  - Next command: `60-report {ID}` (if pass) or `40-execute {ID}` (if fail)
@@ -66,21 +66,29 @@ Drive the app to each checklist item and capture evidence as you go:
66
66
  - Watch for **console errors and failed network requests**; a clean-looking screen
67
67
  with errors in the console is not a pass.
68
68
 
69
- ## Step 4 - report
69
+ ## Step 4 - report (Two-Stage Review Pattern)
70
70
 
71
- Give a short, honest verdict, one line per checklist item:
71
+ Format the verification report into two explicit review stages:
72
72
 
73
- [pass] Download PDF saves certificate-<slug>.pdf - file downloaded, opened to the cert
74
- [pass] Both buttons show a loading state - screenshot: loading-state.png
75
- [fail] PDF border missing - printBackground not set; screenshot: pdf-no-border.png
76
- [skip] Vercel render - can't verify locally (feature 9)
73
+ ### Stage 1: Spec Fidelity & Acceptance Gate
74
+ Give a line-by-line verdict for each Acceptance Criterion and "done when" item:
77
75
 
78
- Then state the bottom line: are all the feature's done-whens proven, or not yet.
76
+ [pass] AC-1: Download PDF saves certificate-<slug>.pdf - file downloaded, opened to cert
77
+ [pass] AC-2: Both buttons show a loading state - screenshot: loading-state.png
78
+ [fail] AC-3: PDF border missing - printBackground not set; screenshot: pdf-no-border.png
79
+ [skip] AC-4: Vercel deploy smoke test - can't verify locally (pending staging)
79
80
 
80
- - All proven -> say it's ready for `/complete`.
81
- - Anything failed -> hand back to `/implement` to fix; name what to fix. Don't fix
82
- it here.
83
- - Anything unverifiable -> say so plainly and why; never report it as a pass.
81
+ ### Stage 2: Code Quality, Security & Architecture Gate
82
+ Report the multi-lane technical verification results:
83
+ - **Type & Syntax**: `tsc --noEmit` (0 errors)
84
+ - **Automated Tests**: Unit & integration tests (100% pass)
85
+ - **Security & Hygiene**: Zero secrets, sanitized inputs
86
+ - **Findings Ledger**: 0 blockers (P0/P1) in `devflow/context/findings.md`
87
+
88
+ ### Final Verdict & Route
89
+ - **All Passed**: State that the feature is verified and ready for `/complete`.
90
+ - **Any Failure**: Hand back to `/implement` with exact failure evidence and reproduction steps. Never fix issues inside `/check`.
91
+ - **Unverifiable**: Clearly state reasons and residual risk. Never fabricate a pass.
84
92
 
85
93
  ## Rules
86
94
 
@@ -117,14 +117,10 @@ Give a concise debug report:
117
117
 
118
118
  Choose the next action without writing files:
119
119
 
120
- - Active feature or fix caused the failure -> return the diagnosis to
121
- `/implement`.
122
- - No active work item and the bug is confirmed -> recommend
123
- `/fix "<concise bug and confirmed cause>"`.
124
- - Cause is only likely or blocked -> recommend the next diagnostic evidence, not
125
- a speculative repair.
126
- - The issue is planned product work rather than a defect -> point to
127
- `/feature`.
120
+ - Active feature or fix caused the failure -> return the diagnosis to `/implement` with instructions to write a failing reproduction test ([TDD-Red]) first.
121
+ - No active work item and the bug is confirmed -> recommend `/fix "<concise bug and confirmed cause>"` (which will write a failing test first before fixing).
122
+ - Cause is only likely or blocked -> recommend the next diagnostic evidence, not a speculative repair.
123
+ - The issue is planned product work rather than a defect -> point to `/feature`.
128
124
 
129
125
  ## Rules
130
126
 
@@ -113,10 +113,14 @@ build plan starts high-level.
113
113
 
114
114
  For the one (sub-)feature being built now, write a full spec to
115
115
  `devflow/context/current-feature.md` (create `devflow/context/` if needed), following
116
- `reference/feature-spec-template.md`. Fill every section: goal, in/out of scope,
117
- the build loop, small build steps as a checklist (`- [ ]`, each with an observable
118
- "done when" - `/implement` ticks them off and resumes from the first unchecked
119
- one), files/areas, data/contracts, testing, and notes for the AI.
116
+ `reference/feature-spec-template.md`. Fill every section:
117
+ - Goal, Problem Statement, and In/Out of scope
118
+ - Acceptance Criteria (AC-1, AC-2, ...)
119
+ - Small build steps as atomic 2-5 min checklist items (`- [ ]`, supporting `[TDD-Red]`, `[TDD-Green]`, `[TDD-Refactor]` triplets for functional logic)
120
+ - Two-Stage Verification Strategy:
121
+ - **Stage 1**: Spec Fidelity & Acceptance Criteria Gate
122
+ - **Stage 2**: Technical Multi-lane quality, tests, security, and findings ledger
123
+ - Files/areas to modify, data/contracts, and notes for the AI.
120
124
 
121
125
  **Visual or replication features need a reference image.** If the feature is
122
126
  "make it look like X" - recreating an existing design, matching a mockup, or
@@ -88,19 +88,23 @@ broad checkout. Ask whether to resolve only the conflict allowed by the approved
88
88
  spec or abandon the attempt. A cascade into another completed feature needs a
89
89
  new rollback plan.
90
90
 
91
- ## Step 2 - build one step, review, iterate, checkpoint
91
+ ## Step 2 - build one step, review, iterate, checkpoint (Strict TDD)
92
92
 
93
93
  Work through the spec's build steps in order, one at a time. For each step:
94
94
 
95
- 1. Implement just that step: the smallest change that satisfies its "done when."
96
- 2. Show the **diff**, not whole files.
97
- 3. **Explain it, and prove it.** Give a short summary: what the step delivered,
95
+ 1. **Strict TDD Cycle (for logic & behavior changes)**:
96
+ - **🔴 RED**: Write the unit test first in the relevant test file. Execute the test command and show the failing assertion output.
97
+ - **🟢 GREEN**: Implement only the minimal code in the source file necessary to make the test pass. Re-run test and show passing output.
98
+ - **🔵 REFACTOR**: Refactor and format cleanly, verifying that 100% of tests remain green.
99
+ - *Code Reversion Rule*: If production code is written without a prior test for behavior changes, revert it and write the test first.
100
+ 2. Implement just that step: the smallest change that satisfies its "done when."
101
+ 3. Show the **diff**, not whole files.
102
+ 4. **Explain it, and prove it.** Give a short summary: what the step delivered,
98
103
  one line per changed file on what it does and why, then confirm the step's
99
- "done when" is met with evidence (build output, a screenshot, a passing
100
- assertion). This summary is the comprehension gate, so keep it concrete, not
101
- ceremonial. Include a short **How to try it** note when the step has a manual
104
+ "done when" is met with empirical evidence (test pass output, build output, or screenshot). This summary is the comprehension gate, so keep it concrete, not
105
+ vague. Include a short **How to try it** note when the step has a manual
102
106
  path: the command, URL, click, endpoint, or output the user can check.
103
- 4. **Verify the step.** If `AGENTS.md` declares a `Verify` command, run that exact
107
+ 5. **Verify the step.** If `AGENTS.md` declares a `Verify` command, run that exact
104
108
  command as the automated gate. It is only an umbrella for checks the project
105
109
  actually has, so do not invent tests or other checks to satisfy it. If no
106
110
  `Verify` command exists, run the documented build command and the test command
@@ -68,3 +68,13 @@
68
68
  - *Dependencies*: None
69
69
  - *Scope*: ผสานความสามารถ Adopt Workflow Visibility (Commit vs Local-only), การรองรับ OpenCode และ Multi-Adapter Checkbox Prompt ใน CLI พร้อมอัปเดต Doctor checks และซิงก์ Baseline SHA เป็น v0.13.0 (`0b65166`)
70
70
 
71
+ ---
72
+
73
+ ## 🧪 Phase 9: Strict TDD Sub-Tasks & Two-Stage Review Guardrails
74
+
75
+ - [x] **9. Strict TDD Sub-Tasks & Two-Stage Review Guardrails** `[Size: M]`
76
+ - *Dependencies*: None
77
+ - *Scope*: นำ Strict TDD (Red-Green-Refactor) Sub-Tasks และ Two-Stage Review Pattern (Stage 1: Spec Fidelity, Stage 2: Quality & Security Gate) ผสานเข้าสู่ Prompt Rules, Coding Standards, AI Interaction และ Stage Skills (`30-plan`, `40-execute`, `50-verify`, `feature`, `implement`, `check`, `debug`) พร้อมอัปเดต Template และ Unit Tests
78
+
79
+
80
+
@@ -65,21 +65,37 @@ The entire lifecycle is driven by the **Single Living Spec (`devflow/context/cur
65
65
  *Recommended for large architectural epics, database migrations, security audits, and multi-agent coordination.*
66
66
 
67
67
  ```text
68
- 00-explore ➔ 10-define ➔ 20-spec ➔ 30-plan ➔ 40-execute ➔ 50-verify ➔ 60-report ➔ 70-deliver
68
+ discovery ➔ 10-define ➔ 20-spec ➔ 30-plan ➔ 40-execute ➔ 50-verify ➔ 60-report ➔ 70-deliver
69
69
  ```
70
70
 
71
- 1. `00-explore`: Explore request before delivery commitment (`DISC-YYYYMMDD-NNN`).
71
+ 1. `discovery`: Unified pre-delivery discovery & Socratic alignment (`DISC-YYYYMMDD-NNN` or project roadmap).
72
72
  2. `10-define`: Turn approved discovery into bounded delivery run in `devflow/context/current-run/10-define.md`.
73
73
  3. `20-spec`: Formalize markdown delivery contract & acceptance criteria (`20-spec.md`).
74
- 4. `30-plan`: Breakdown spec into executable tasks with test decisions (`30-plan.md` + checklists).
75
- 5. `40-execute`: Incremental task execution behind review gates (`40-execute.md`).
76
- 6. `50-verify`: Senior QA review & multi-lane verification checks (`50-verify.md`).
74
+ 4. `30-plan`: Breakdown spec into atomic 2-5 min tasks with explicit TDD decisions (`30-plan.md` + checklists).
75
+ 5. `40-execute`: Strict Red-Green-Refactor task execution behind review gates (`40-execute.md`).
76
+ 6. `50-verify`: Senior QA Two-Stage Review (Spec Fidelity + Quality/Security Gate) (`50-verify.md`).
77
77
  7. `60-report`: Standardized markdown delivery digest (`60-report.md`).
78
- 8. `70-deliver`: Release packaging, git merge, archives `devflow/context/current-run/` ➔ `devflow/history/{features|fixes|rollbacks}/{xxx-slug}/`, and closes the run.
78
+ 8. `70-deliver`: Release packaging, git merge, archives `devflow/context/current-run/` ➔ `devflow/history/{category}/{xxx-slug}/`, and closes the run.
79
79
 
80
80
  ---
81
81
 
82
- ## 4. Standalone HTML Reporting Policy
82
+ ## 4. Strict TDD & Two-Stage Review Interaction Rules
83
+
84
+ ### 🔴🟢 Strict TDD Execution Discipline
85
+ During implementation in `/implement` and `40-execute`:
86
+ - **Show Red Phase**: First execute tests to demonstrate expected failure *before* adding production code.
87
+ - **Show Green Phase**: Add minimal production code, re-run tests, and report pass rate.
88
+ - **Show Refactor Phase**: Polish and clean up with zero test regression.
89
+ - **Forbidden**: Never present functional code changes without matching test execution evidence.
90
+
91
+ ### 🛡️ Two-Stage Verification Reporting
92
+ During `/check` and `50-verify`:
93
+ - **Stage 1 (Spec Fidelity Gate)**: Report each Acceptance Criterion and "Done When" status.
94
+ - **Stage 2 (Code Quality & Security Gate)**: Report Typecheck, Lint, Test Suites, Security checks, and Findings Ledger (0 blockers).
95
+
96
+ ---
97
+
98
+ ## 5. Standalone HTML Reporting Policy
83
99
 
84
100
  > [!IMPORTANT]
85
101
  > **No Auto-Generated HTML**: Mainline stages (`/complete` and `60-report`) strictly output Markdown only.
@@ -91,22 +91,33 @@ nexus-devflow/
91
91
 
92
92
  ---
93
93
 
94
- ## 7. Testing & Empirical Proof Standards
94
+ ## 7. Testing & Empirical Proof Standards (Strict TDD & Two-Stage Review)
95
95
 
96
96
  Testing is a core quality gate in Nexus-DevFlow, not an afterthought:
97
97
 
98
98
  - **Unit Test Mandate**: Any new feature, modified logic, parser improvement, or bug fix **MUST ship with automated unit tests** in the same diff.
99
+ - **Strict TDD (Red-Green-Refactor) Protocol**:
100
+ 1. **🔴 RED (Test First)**: Always write automated tests *before* writing or modifying functional logic. Run the test command and verify that it fails for the expected reason.
101
+ 2. **🟢 GREEN (Minimal Code)**: Write only the minimal production code necessary to make the failing test pass. Run the test command and verify 100% green pass.
102
+ 3. **🔵 REFACTOR (Clean & Robust)**: Refactor code for readability, performance, and DRY/YAGNI discipline while ensuring all tests stay green.
103
+ - *Code Deletion / Reversion Rule*: If functional code is created without a prior failing test for behavior changes, it must be reverted or immediately backed by tests before continuing.
99
104
  - **Test Framework**: Use Node.js native test runner executed via `tsx --test test/*.test.ts` under `packages/create-nexus-devflow/`.
100
105
  - **Test Design (AAA Pattern)**:
101
106
  - Structure each test case cleanly: **Arrange** (setup fixtures/mock directories), **Act** (execute function), **Assert** (verify invariants).
102
107
  - Use isolated temporary directories (`fs.mkdtemp` in `os.tmpdir()`) and ensure cleanup in `finally` blocks.
103
108
  - **Empirical Proof Contract**:
104
109
  - Never claim a task is "working", "tested", or "verified" without providing concrete empirical proof (exact command executed, terminal output, pass/fail counts, exit code).
105
- - **Multi-Lane Verification Matrix**:
106
- - **Lane 1 (Type & Syntax Safety)**: `tsc --noEmit` (0 type errors).
107
- - **Lane 2 (Automated Test Suites & Evals)**: `npm test` (Unit tests 100% pass) + `npm run test:routing` (Skill routing accuracy).
108
- - **Lane 3 (Scrutinize & Security Audit)**: Edge cases, null-safety, 0 secrets, safe inputs.
109
- - **Lane 4 (Manual / Scenario Proof)**: Concrete walkthrough steps ("Where to go", "What to run", "What to expect").
110
+ - **Two-Stage Review Pattern (Verification Gate)**:
111
+ - **Stage 1: Spec Fidelity & Acceptance Gate**:
112
+ - Verify 100% conformance against the living spec (`current-feature.md` or `20-spec.md`).
113
+ - Validate all Acceptance Criteria (ACs) and "Done When" observables without missing requirements or scope creep.
114
+ - Test edge cases and boundary conditions defined in the specification.
115
+ - **Stage 2: Code Quality, Security & Architecture Gate**:
116
+ - **Lane 1 (Type & Syntax Safety)**: `tsc --noEmit` (0 type errors).
117
+ - **Lane 2 (Automated Test Suites & Evals)**: `npm test` (Unit tests 100% pass) + `npm run test:routing` (Skill routing accuracy).
118
+ - **Lane 3 (Scrutinize & Security Audit)**: Edge cases, null-safety, 0 secrets, safe inputs.
119
+ - **Lane 4 (Manual / Scenario Proof)**: Concrete walkthrough steps ("Where to go", "What to run", "What to expect").
120
+ - **Findings Ledger State**: 0 blockers (P0/P1) in `devflow/context/findings.md`.
110
121
 
111
122
  ---
112
123