@warnyin/agents 0.17.0 → 0.18.1

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 (86) hide show
  1. package/CHANGELOG.md +168 -153
  2. package/README.md +160 -160
  3. package/package.json +38 -38
  4. package/src/.claude/agents/warnyin-infra.md +13 -13
  5. package/src/.claude/agents/warnyin-qa.md +13 -13
  6. package/src/.claude/agents/warnyin-sa.md +13 -13
  7. package/src/.claude/agents/warnyin-security.md +13 -13
  8. package/src/.claude/agents/warnyin-tech-lead.md +13 -13
  9. package/src/.claude/agents/warnyin-ux.md +14 -0
  10. package/src/.claude/commands/warnyin/build.md +31 -31
  11. package/src/.claude/commands/warnyin/design.md +27 -27
  12. package/src/.claude/commands/warnyin/discovery.md +22 -22
  13. package/src/.claude/commands/warnyin/explore.md +14 -14
  14. package/src/.claude/commands/warnyin/feedback/issue.md +14 -14
  15. package/src/.claude/commands/warnyin/init.md +12 -12
  16. package/src/.claude/commands/warnyin/install-skill.md +19 -14
  17. package/src/.claude/commands/warnyin/next.md +17 -17
  18. package/src/.claude/commands/warnyin/ship.md +28 -28
  19. package/src/.claude/commands/warnyin/triage.md +14 -14
  20. package/src/.claude/commands/warnyin/update-codemaps.md +12 -12
  21. package/src/.claude/commands/warnyin/verify.md +20 -20
  22. package/src/.claude/skills/explore/SKILL.md +8 -8
  23. package/src/.claude/skills/next/SKILL.md +8 -8
  24. package/src/.claude/skills/update-codemaps/SKILL.md +8 -8
  25. package/src/.warnyin/installer/templates/CLAUDE.global.md +5 -5
  26. package/src/.warnyin/installer/templates/CLAUDE.md +35 -35
  27. package/src/.warnyin/template/docs/codemap/index.md +18 -18
  28. package/src/.warnyin/template/docs/features/[feature-name]/business.md +5 -5
  29. package/src/.warnyin/template/docs/features/[feature-name]/feature.md +5 -5
  30. package/src/.warnyin/template/docs/features/[feature-name]/spec.md +16 -16
  31. package/src/.warnyin/template/docs/infra.md +16 -16
  32. package/src/.warnyin/template/docs/project.md +18 -18
  33. package/src/.warnyin/template/docs/rule.md +7 -7
  34. package/src/.warnyin/template/docs/techstack/[component]/about.md +6 -6
  35. package/src/.warnyin/template/docs/techstack/[component]/rule.md +6 -6
  36. package/src/.warnyin/template/docs/techstack/[component]/standard.md +6 -6
  37. package/src/.warnyin/template/docs/techstack/[component]/structure.md +7 -7
  38. package/src/.warnyin/template/docs/techstack/[component]/test.md +7 -7
  39. package/src/.warnyin/template/docs/troubleshooting.md +32 -32
  40. package/src/.warnyin/template/stages/[topic]/build.md +58 -58
  41. package/src/.warnyin/template/stages/[topic]/business.md +21 -21
  42. package/src/.warnyin/template/stages/[topic]/design.md +63 -63
  43. package/src/.warnyin/template/stages/[topic]/discovery.md +69 -69
  44. package/src/.warnyin/template/stages/[topic]/proposal.md +43 -43
  45. package/src/.warnyin/template/stages/[topic]/research.md +49 -49
  46. package/src/.warnyin/template/stages/[topic]/ship.md +32 -32
  47. package/src/.warnyin/template/stages/[topic]/tasks/[task-name]/issue.md +19 -19
  48. package/src/.warnyin/template/stages/[topic]/tasks/[task-name]/rule.md +13 -13
  49. package/src/.warnyin/template/stages/[topic]/tasks/[task-name]/spec.md +36 -36
  50. package/src/.warnyin/template/stages/[topic]/tasks/[task-name]/standard.md +21 -21
  51. package/src/.warnyin/template/stages/[topic]/tasks/[task-name]/task.md +40 -40
  52. package/src/.warnyin/template/stages/[topic]/test.md +46 -46
  53. package/src/.warnyin/template/stages/[topic]/troubleshooting.md +34 -34
  54. package/src/.warnyin/template/stages/[topic]/verify.md +44 -44
  55. package/src/.warnyin/template/stages/[topic]/wireframe.md +104 -0
  56. package/src/.warnyin/workflow/README.md +106 -106
  57. package/src/.warnyin/workflow/api-doc.md +93 -93
  58. package/src/.warnyin/workflow/codemap.md +91 -91
  59. package/src/.warnyin/workflow/contexts/README.md +51 -51
  60. package/src/.warnyin/workflow/contexts/build.md +25 -25
  61. package/src/.warnyin/workflow/contexts/research.md +25 -25
  62. package/src/.warnyin/workflow/contexts/review.md +25 -25
  63. package/src/.warnyin/workflow/explore.md +32 -32
  64. package/src/.warnyin/workflow/feedback.md +212 -212
  65. package/src/.warnyin/workflow/init.md +136 -136
  66. package/src/.warnyin/workflow/next.md +48 -48
  67. package/src/.warnyin/workflow/roles/README.md +52 -47
  68. package/src/.warnyin/workflow/roles/ba.md +25 -25
  69. package/src/.warnyin/workflow/roles/developer.md +31 -31
  70. package/src/.warnyin/workflow/roles/infra.md +24 -24
  71. package/src/.warnyin/workflow/roles/po.md +28 -28
  72. package/src/.warnyin/workflow/roles/qa.md +36 -35
  73. package/src/.warnyin/workflow/roles/sa.md +28 -28
  74. package/src/.warnyin/workflow/roles/security.md +39 -39
  75. package/src/.warnyin/workflow/roles/tech-lead.md +28 -28
  76. package/src/.warnyin/workflow/roles/ux.md +76 -0
  77. package/src/.warnyin/workflow/scripts/build-wave.mjs +145 -145
  78. package/src/.warnyin/workflow/scripts/validate-topic.mjs +378 -378
  79. package/src/.warnyin/workflow/stages/build.md +98 -98
  80. package/src/.warnyin/workflow/stages/design.md +174 -154
  81. package/src/.warnyin/workflow/stages/discovery.md +256 -256
  82. package/src/.warnyin/workflow/stages/ship.md +94 -94
  83. package/src/.warnyin/workflow/stages/verify.md +82 -82
  84. package/src/.warnyin/workflow/triage.md +74 -74
  85. package/src/AGENTS.md +54 -54
  86. package/src/bin/cli.mjs +357 -333
@@ -1,98 +1,98 @@
1
- # Stage: BUILD
2
-
3
- > **Playbook กลาง — AI ทุกเจ้าทำตามไฟล์นี้ชุดเดียวกัน** (Claude Code / Codex / Antigravity / อื่นๆ)
4
- > เป้าหมาย: ลงมือทำ task ที่ DESIGN เตรียมไว้ โดย **fan-out sub-agent อัตโนมัติต่อ task ตาม dependency**
5
- > **Context profile:** สวมโหมด `build` (`.warnyin/workflow/contexts/build.md`) — session-level posture ของ stage นี้
6
-
7
- ---
8
-
9
- ## 1. BUILD คืออะไร / ใช้เมื่อไหร่
10
-
11
- ใช้เมื่อ DESIGN ผ่าน Gate แล้ว มี `tasks/<task>/` ครบ (task.md + spec.md + standard.md + rule.md)
12
- BUILD จะ **orchestrate การ implement** โดยกระจายงานเป็น sub-agent หนึ่งตัวต่อหนึ่ง task/slice และเดินตาม dependency graph
13
-
14
- ---
15
-
16
- ## 2. Input ที่ต้องอ่านก่อนเริ่ม
17
-
18
- 1. `docs/stages/<slug>/design.md` — dependency graph ระหว่าง task/slice (section 7)
19
- 2. `docs/stages/<slug>/proposal.md` — scope ของ change
20
- 3. `docs/stages/<slug>/tasks/<task>/task.md` ทุกใบ — dependency ของแต่ละ task + sub-tasks
21
- 4. `docs/techstack/<component>/rule.md` + `standard.md` — กฎ/มาตรฐานที่ต้อง follow
22
-
23
- ---
24
-
25
- ## 3. หลักการทำงาน (operating principles)
26
-
27
- 1. **ถาม user ยืนยัน "ครั้งเดียวก่อนเริ่ม"** — แสดง execution plan (DAG + wave ไหนรัน parallel + isolation) ให้ user อนุมัติ แล้วจึง fan-out อัตโนมัติ ไม่ถามซ้ำระหว่างทาง
28
- 2. **Fan-out ตาม dependency (wave-based)** — จัด task เป็น "wave" ตาม topological order ของ dependency:
29
- - task ใน wave เดียวกัน = independent → รัน **parallel**
30
- - ข้าม wave = มี dependency → wave ถัดไปเริ่มหลัง wave ก่อนหน้ารวมผลเสร็จ
31
- 3. **Worktree isolation ต่อ task** — แต่ละ parallel task ทำใน git worktree ของตัวเอง ไม่แก้ไฟล์ชนกัน แล้ว **integrate (merge) เข้า build branch หลังจบแต่ละ wave**
32
- - **★ worktree fork จาก main (คุมไม่ได้) → agent ต้อง sync build branch ก่อน** — harness fork worktree จาก main จึงยังไม่เห็น `docs/stages/<slug>/` (topic docs) + output ของ wave ก่อนหน้า; build-wave สั่ง agent `git merge <baseRef>` (= build branch) เป็น step แรกก่อนอ่าน task เพื่อให้เห็น dependency ครบ (กลไกอยู่ใน `build-wave.mjs` — orchestrator ส่ง `baseRef` เข้ามา)
33
- - ถ้า target ไม่ใช่ git repo → fallback เป็น **sequential shared-tree** (ทีละ task ตาม dependency)
34
- 4. **แต่ละ build agent ต้อง self-verify (scope = component ตัวเองเท่านั้น)** — implement → รัน test-flow ใน `spec.md` + build/lint **ของ component ที่ task นั้นแตะ (unit + lint ของ component นั้น) ไม่ใช่ทั้ง repo** → **ต้องผ่านก่อนถึง mark passed**; ถ้าแก้ไม่ได้ให้รายงาน `failed` พร้อมเหตุผล **ห้ามรายงานผ่านทั้งที่ยังแดง** — **cross-component / integration / e2e ไม่ต้องรันต่อ task** (เลื่อนไป full-gate ข้อ 8 / §4 ข้อ 6) กันรันซ้ำเสียเวลา
35
- 5. **เคารพ standard/rule ของ task** — ทำตาม `standard.md` (pattern โค้ด, reuse shared component) และ `rule.md` (กฎ) อย่างเคร่งครัด
36
- 6. **ห้ามแตะ rule/standard กลางใน `docs/`** — rule ใหม่ที่เสนอถูก note ไว้ใน `tasks/<task>/rule.md` แล้ว รอ SHIP ค่อยอัปเดตไฟล์กลาง
37
- 7. **fail = หยุดที่ wave นั้น** — ถ้า task ใน wave ล้ม ให้รายงาน user ก่อนไป wave ถัดไป (เพราะ wave ถัดไปอาจ depend อยู่)
38
- 8. **★ ปิดท้ายด้วย full build + full test เสมอ (blocking gate — ห้ามลด bar)** — หลัง merge ทุก wave แล้ว ต้องรัน build ทั้งหมด + test suite ทั้งหมด (รวม unit test) + cross-component/integration บน build branch ที่ integrate; **แก้วนจนเขียวหมด** ก่อนปิด BUILD (กันกรณี task รายเดี่ยวเขียวแต่พอรวมกันแล้วพัง) — **gate นี้คงเป็น blocking เสมอ** การที่ข้อ 4 ลด self-verify ของ agent เหลือ scope component เดียว **ไม่ได้ลดความเข้มของ full-gate** (integration coverage ย้ายมารวมที่นี่ ไม่ใช่ตัดทิ้ง); ห้ามแปลง gate นี้เป็น optional/informational เพื่อให้ "ดูเร็วขึ้น"
39
- 9. **ทุก build agent สวม role Developer** — ทำตาม role card `.warnyin/workflow/roles/developer.md` (lens + checklist ก่อนส่งงาน) — build-wave.mjs ใส่ให้ใน prompt แล้ว
40
- 10. **★ ใช้ Troubleshooting KB** — เจอปัญหา/error ระหว่าง build ให้ **อ่าน `docs/troubleshooting.md` ก่อนเสมอ** เผื่อเคยแก้แล้ว; เมื่อแก้ปัญหาที่ **ยาก/เจอซ้ำ** สำเร็จ ให้บันทึก entry ลง `docs/stages/<slug>/troubleshooting.md` (ปัญหา/อาการ/root cause/วิธีแก้/ป้องกันซ้ำ) — ตอน SHIP จะยกขึ้น KB กลาง
41
- 11. **★ investigate-before-edit** (enforce ของ "ห้ามเดา") — ก่อนแก้ไฟล์ที่มีอยู่ ต้องเข้าใจก่อน — **ใครใช้/อ่านไฟล์นี้, schema/contract/สัญญาของมัน, เจตนาเดิม**; แก้โดยไม่เข้าใจ = เดา (กรณีไม่ชัด → ถาม user / อ่านโค้ดที่อ้างถึง ก่อนแก้)
42
- 12. **★ config-protection** (enforce ของ "ห้ามเดา") — ห้ามแก้ config (linter/formatter/test threshold) หรือ disable rule **"เพื่อให้ build/test ผ่าน"** แทนการแก้โค้ดจริง — ถ้า config ผิดจริง แก้ได้แต่ต้องมี **เหตุผลชัด + note** (ไม่ใช่เพื่อเลี่ยง finding)
43
-
44
- ---
45
-
46
- ## 4. ลำดับขั้นการทำงาน (orchestration)
47
-
48
- > ผู้ orchestrate คือ AI ตัวหลัก (main loop) — sub-agent คือคนลงมือ implement
49
-
50
- 0. **★ เช็ค context window ก่อนเริ่ม:** ประเมินว่า context ของ session ปัจจุบันถูกใช้ไปมากน้อยแค่ไหน — ถ้าใช้ไปเยอะหรือ **เกินครึ่ง** → **เสนอ user ให้ `/compact` หรือ `/clear` ก่อนเสมอ** แล้วค่อยเริ่ม BUILD ใน context ที่โล่ง (สถานะงานอยู่ในไฟล์ `docs/stages/<slug>/` ครบ ไม่หายไปกับ context) — BUILD เป็นงานยาว ต้องมี context เหลือมากพอ; เครื่องอื่นที่ไม่มีคำสั่งนี้ → แนะนำเริ่ม session ใหม่
51
- 1. **อ่าน task ทั้งหมด** → ดึง dependency ของแต่ละ task จาก `task.md` (section 2) + `design.md` (section 7)
52
- 2. **สร้าง DAG + จัด wave** (topological sort): wave 1 = task ที่ไม่มี dependency, wave 2 = task ที่ depend เฉพาะ wave 1, ...
53
- 3. **Pre-check:** target เป็น git repo ไหม (สำหรับ worktree) — ถ้าไม่ใช่ → fallback sequential shared-tree และแจ้ง user
54
- 4. **เสนอ execution plan + ขออนุมัติ (ครั้งเดียว):** แสดง wave / task ในแต่ละ wave / อันไหน parallel / isolation mode → ถาม user go/no-go
55
- 5. **เดินทีละ wave:**
56
- - fan-out sub-agent ของ task ใน wave นั้น (parallel, worktree isolation) ผ่าน **Workflow** (`.warnyin/workflow/scripts/build-wave.mjs`) — orchestrator **ส่ง `baseRef` (= build branch)** เข้า build-wave เพื่อให้ agent sync build branch เข้า worktree ก่อน (เห็น topic docs + output wave ก่อนหน้า)
57
- - แต่ละ agent: sync build branch (`git merge <baseRef>`) → implement → test/lint → commit (ถ้า worktree) → รายงานผลแบบ structured (status, files, branch, test result)
58
- - **integrate:** main loop checkout **เฉพาะไฟล์ source ที่ scoped** ของ wave นั้นจาก worktree branch (`git checkout <branch> -- <files>` — เลี่ยง topic-docs copy ที่ agent merge เข้า worktree + ปลอด KB#11); ถ้า conflict → แก้/รายงาน
59
- - ถ้ามี task `failed` → หยุด รายงาน user
60
- 6. **★ Full build & test gate (หลังทุก wave merge เสร็จ — blocking, ห้ามลด bar):** บน build branch ที่ integrate แล้ว รัน **build ทั้งหมด + test suite ทั้งหมด (รวม unit test) + cross-component/integration** ของทุก component ที่กระทบ — นี่คือจุดที่ครอบ integration ที่ self-verify ต่อ task (§3 ข้อ 4) ไม่ได้รัน จึง **ต้องคงเป็น blocking gate เต็มเสมอ**
61
- - มี error / test แดง → **แก้จนเขียวหมด (loop)** อาจ delegate fix ให้ sub-agent ทีละจุด แล้ว rerun ใหม่
62
- - **ห้ามปิด BUILD ถ้ายังมี build error หรือ test ตัวใดแดง**
63
- - ถ้าวนแก้หลายรอบยังไม่ผ่าน → หยุด รายงาน user พร้อม log error
64
- 7. **ปิดงาน:** อัปเดต `build.md` (รายงานผลต่อ task + ผล full build/test) + สถานะใน `task.md` แต่ละใบ → เสนอเข้า VERIFY ด้วย `/warnyin:verify`
65
-
66
- ---
67
-
68
- ## 5. Output
69
-
70
- | ไฟล์ | เนื้อหา |
71
- |---|---|
72
- | โค้ดจริงใน target repo | การ implement ของแต่ละ task (merge เข้า build branch) |
73
- | `docs/stages/<slug>/build.md` | รายงานผล build: สถานะ/ผล test/ไฟล์ที่แก้ ต่อ task + integration notes |
74
- | `docs/stages/<slug>/troubleshooting.md` | ปัญหายาก/ซ้ำที่แก้สำเร็จ (SHIP ยกขึ้น `docs/troubleshooting.md`) |
75
- | `tasks/<task>/task.md` (อัปเดต) | สถานะ task → เสร็จ + acceptance ที่ผ่าน |
76
-
77
- ---
78
-
79
- ## 6. Workflow script (Claude Code)
80
-
81
- ใช้ `.warnyin/workflow/scripts/build-wave.mjs` — fan-out หนึ่ง agent ต่อหนึ่ง task ใน **หนึ่ง wave** (parallel, worktree isolation), คืนผลแบบ structured
82
- main loop เรียก script นี้ **ทีละ wave** แล้ว integrate ระหว่าง wave (ดูรายละเอียดใน `.claude/commands/warnyin/build.md`)
83
-
84
- > เครื่องอื่น (Codex/Antigravity) ที่ไม่มี Workflow tool: ทำตามหลักการข้อ 3-4 โดย implement task ตามลำดับ wave เอง (parallel เท่าที่เครื่องรองรับ)
85
-
86
- ---
87
-
88
- ## 7. Gate → เข้า VERIFY ได้เมื่อ
89
-
90
- - [ ] ทุก task ใน DAG ถูก implement และ merge เข้า build branch แล้ว
91
- - [ ] ทุก task รายงาน `passed` (test-flow + build/lint เขียว) — ไม่มี `failed` ค้าง
92
- - [ ] ไม่มี merge conflict ค้าง
93
- - [ ] **★ Full build ของทุก component ผ่าน — ไม่มี build error**
94
- - [ ] **★ test suite ทั้งหมด (รวม unit test) เขียวทั้งหมดบน build branch**
95
- - [ ] `build.md` สรุปผลครบทุก task + ผล full build/test
96
- - [ ] ไม่มีการแตะ rule/standard กลางใน `docs/` (rule ใหม่ยัง note รอ SHIP)
97
-
98
- ยังไม่ครบ → อยู่ BUILD ต่อ ห้ามข้ามไป VERIFY
1
+ # Stage: BUILD
2
+
3
+ > **Playbook กลาง — AI ทุกเจ้าทำตามไฟล์นี้ชุดเดียวกัน** (Claude Code / Codex / Antigravity / อื่นๆ)
4
+ > เป้าหมาย: ลงมือทำ task ที่ DESIGN เตรียมไว้ โดย **fan-out sub-agent อัตโนมัติต่อ task ตาม dependency**
5
+ > **Context profile:** สวมโหมด `build` (`.warnyin/workflow/contexts/build.md`) — session-level posture ของ stage นี้
6
+
7
+ ---
8
+
9
+ ## 1. BUILD คืออะไร / ใช้เมื่อไหร่
10
+
11
+ ใช้เมื่อ DESIGN ผ่าน Gate แล้ว มี `tasks/<task>/` ครบ (task.md + spec.md + standard.md + rule.md)
12
+ BUILD จะ **orchestrate การ implement** โดยกระจายงานเป็น sub-agent หนึ่งตัวต่อหนึ่ง task/slice และเดินตาม dependency graph
13
+
14
+ ---
15
+
16
+ ## 2. Input ที่ต้องอ่านก่อนเริ่ม
17
+
18
+ 1. `docs/stages/<slug>/design.md` — dependency graph ระหว่าง task/slice (section 7)
19
+ 2. `docs/stages/<slug>/proposal.md` — scope ของ change
20
+ 3. `docs/stages/<slug>/tasks/<task>/task.md` ทุกใบ — dependency ของแต่ละ task + sub-tasks
21
+ 4. `docs/techstack/<component>/rule.md` + `standard.md` — กฎ/มาตรฐานที่ต้อง follow
22
+
23
+ ---
24
+
25
+ ## 3. หลักการทำงาน (operating principles)
26
+
27
+ 1. **ถาม user ยืนยัน "ครั้งเดียวก่อนเริ่ม"** — แสดง execution plan (DAG + wave ไหนรัน parallel + isolation) ให้ user อนุมัติ แล้วจึง fan-out อัตโนมัติ ไม่ถามซ้ำระหว่างทาง
28
+ 2. **Fan-out ตาม dependency (wave-based)** — จัด task เป็น "wave" ตาม topological order ของ dependency:
29
+ - task ใน wave เดียวกัน = independent → รัน **parallel**
30
+ - ข้าม wave = มี dependency → wave ถัดไปเริ่มหลัง wave ก่อนหน้ารวมผลเสร็จ
31
+ 3. **Worktree isolation ต่อ task** — แต่ละ parallel task ทำใน git worktree ของตัวเอง ไม่แก้ไฟล์ชนกัน แล้ว **integrate (merge) เข้า build branch หลังจบแต่ละ wave**
32
+ - **★ worktree fork จาก main (คุมไม่ได้) → agent ต้อง sync build branch ก่อน** — harness fork worktree จาก main จึงยังไม่เห็น `docs/stages/<slug>/` (topic docs) + output ของ wave ก่อนหน้า; build-wave สั่ง agent `git merge <baseRef>` (= build branch) เป็น step แรกก่อนอ่าน task เพื่อให้เห็น dependency ครบ (กลไกอยู่ใน `build-wave.mjs` — orchestrator ส่ง `baseRef` เข้ามา)
33
+ - ถ้า target ไม่ใช่ git repo → fallback เป็น **sequential shared-tree** (ทีละ task ตาม dependency)
34
+ 4. **แต่ละ build agent ต้อง self-verify (scope = component ตัวเองเท่านั้น)** — implement → รัน test-flow ใน `spec.md` + build/lint **ของ component ที่ task นั้นแตะ (unit + lint ของ component นั้น) ไม่ใช่ทั้ง repo** → **ต้องผ่านก่อนถึง mark passed**; ถ้าแก้ไม่ได้ให้รายงาน `failed` พร้อมเหตุผล **ห้ามรายงานผ่านทั้งที่ยังแดง** — **cross-component / integration / e2e ไม่ต้องรันต่อ task** (เลื่อนไป full-gate ข้อ 8 / §4 ข้อ 6) กันรันซ้ำเสียเวลา
35
+ 5. **เคารพ standard/rule ของ task** — ทำตาม `standard.md` (pattern โค้ด, reuse shared component) และ `rule.md` (กฎ) อย่างเคร่งครัด
36
+ 6. **ห้ามแตะ rule/standard กลางใน `docs/`** — rule ใหม่ที่เสนอถูก note ไว้ใน `tasks/<task>/rule.md` แล้ว รอ SHIP ค่อยอัปเดตไฟล์กลาง
37
+ 7. **fail = หยุดที่ wave นั้น** — ถ้า task ใน wave ล้ม ให้รายงาน user ก่อนไป wave ถัดไป (เพราะ wave ถัดไปอาจ depend อยู่)
38
+ 8. **★ ปิดท้ายด้วย full build + full test เสมอ (blocking gate — ห้ามลด bar)** — หลัง merge ทุก wave แล้ว ต้องรัน build ทั้งหมด + test suite ทั้งหมด (รวม unit test) + cross-component/integration บน build branch ที่ integrate; **แก้วนจนเขียวหมด** ก่อนปิด BUILD (กันกรณี task รายเดี่ยวเขียวแต่พอรวมกันแล้วพัง) — **gate นี้คงเป็น blocking เสมอ** การที่ข้อ 4 ลด self-verify ของ agent เหลือ scope component เดียว **ไม่ได้ลดความเข้มของ full-gate** (integration coverage ย้ายมารวมที่นี่ ไม่ใช่ตัดทิ้ง); ห้ามแปลง gate นี้เป็น optional/informational เพื่อให้ "ดูเร็วขึ้น"
39
+ 9. **ทุก build agent สวม role Developer** — ทำตาม role card `.warnyin/workflow/roles/developer.md` (lens + checklist ก่อนส่งงาน) — build-wave.mjs ใส่ให้ใน prompt แล้ว
40
+ 10. **★ ใช้ Troubleshooting KB** — เจอปัญหา/error ระหว่าง build ให้ **อ่าน `docs/troubleshooting.md` ก่อนเสมอ** เผื่อเคยแก้แล้ว; เมื่อแก้ปัญหาที่ **ยาก/เจอซ้ำ** สำเร็จ ให้บันทึก entry ลง `docs/stages/<slug>/troubleshooting.md` (ปัญหา/อาการ/root cause/วิธีแก้/ป้องกันซ้ำ) — ตอน SHIP จะยกขึ้น KB กลาง
41
+ 11. **★ investigate-before-edit** (enforce ของ "ห้ามเดา") — ก่อนแก้ไฟล์ที่มีอยู่ ต้องเข้าใจก่อน — **ใครใช้/อ่านไฟล์นี้, schema/contract/สัญญาของมัน, เจตนาเดิม**; แก้โดยไม่เข้าใจ = เดา (กรณีไม่ชัด → ถาม user / อ่านโค้ดที่อ้างถึง ก่อนแก้)
42
+ 12. **★ config-protection** (enforce ของ "ห้ามเดา") — ห้ามแก้ config (linter/formatter/test threshold) หรือ disable rule **"เพื่อให้ build/test ผ่าน"** แทนการแก้โค้ดจริง — ถ้า config ผิดจริง แก้ได้แต่ต้องมี **เหตุผลชัด + note** (ไม่ใช่เพื่อเลี่ยง finding)
43
+
44
+ ---
45
+
46
+ ## 4. ลำดับขั้นการทำงาน (orchestration)
47
+
48
+ > ผู้ orchestrate คือ AI ตัวหลัก (main loop) — sub-agent คือคนลงมือ implement
49
+
50
+ 0. **★ เช็ค context window ก่อนเริ่ม:** ประเมินว่า context ของ session ปัจจุบันถูกใช้ไปมากน้อยแค่ไหน — ถ้าใช้ไปเยอะหรือ **เกินครึ่ง** → **เสนอ user ให้ `/compact` หรือ `/clear` ก่อนเสมอ** แล้วค่อยเริ่ม BUILD ใน context ที่โล่ง (สถานะงานอยู่ในไฟล์ `docs/stages/<slug>/` ครบ ไม่หายไปกับ context) — BUILD เป็นงานยาว ต้องมี context เหลือมากพอ; เครื่องอื่นที่ไม่มีคำสั่งนี้ → แนะนำเริ่ม session ใหม่
51
+ 1. **อ่าน task ทั้งหมด** → ดึง dependency ของแต่ละ task จาก `task.md` (section 2) + `design.md` (section 7)
52
+ 2. **สร้าง DAG + จัด wave** (topological sort): wave 1 = task ที่ไม่มี dependency, wave 2 = task ที่ depend เฉพาะ wave 1, ...
53
+ 3. **Pre-check:** target เป็น git repo ไหม (สำหรับ worktree) — ถ้าไม่ใช่ → fallback sequential shared-tree และแจ้ง user
54
+ 4. **เสนอ execution plan + ขออนุมัติ (ครั้งเดียว):** แสดง wave / task ในแต่ละ wave / อันไหน parallel / isolation mode → ถาม user go/no-go
55
+ 5. **เดินทีละ wave:**
56
+ - fan-out sub-agent ของ task ใน wave นั้น (parallel, worktree isolation) ผ่าน **Workflow** (`.warnyin/workflow/scripts/build-wave.mjs`) — orchestrator **ส่ง `baseRef` (= build branch)** เข้า build-wave เพื่อให้ agent sync build branch เข้า worktree ก่อน (เห็น topic docs + output wave ก่อนหน้า)
57
+ - แต่ละ agent: sync build branch (`git merge <baseRef>`) → implement → test/lint → commit (ถ้า worktree) → รายงานผลแบบ structured (status, files, branch, test result)
58
+ - **integrate:** main loop checkout **เฉพาะไฟล์ source ที่ scoped** ของ wave นั้นจาก worktree branch (`git checkout <branch> -- <files>` — เลี่ยง topic-docs copy ที่ agent merge เข้า worktree + ปลอด KB#11); ถ้า conflict → แก้/รายงาน
59
+ - ถ้ามี task `failed` → หยุด รายงาน user
60
+ 6. **★ Full build & test gate (หลังทุก wave merge เสร็จ — blocking, ห้ามลด bar):** บน build branch ที่ integrate แล้ว รัน **build ทั้งหมด + test suite ทั้งหมด (รวม unit test) + cross-component/integration** ของทุก component ที่กระทบ — นี่คือจุดที่ครอบ integration ที่ self-verify ต่อ task (§3 ข้อ 4) ไม่ได้รัน จึง **ต้องคงเป็น blocking gate เต็มเสมอ**
61
+ - มี error / test แดง → **แก้จนเขียวหมด (loop)** อาจ delegate fix ให้ sub-agent ทีละจุด แล้ว rerun ใหม่
62
+ - **ห้ามปิด BUILD ถ้ายังมี build error หรือ test ตัวใดแดง**
63
+ - ถ้าวนแก้หลายรอบยังไม่ผ่าน → หยุด รายงาน user พร้อม log error
64
+ 7. **ปิดงาน:** อัปเดต `build.md` (รายงานผลต่อ task + ผล full build/test) + สถานะใน `task.md` แต่ละใบ → เสนอเข้า VERIFY ด้วย `/warnyin:verify`
65
+
66
+ ---
67
+
68
+ ## 5. Output
69
+
70
+ | ไฟล์ | เนื้อหา |
71
+ |---|---|
72
+ | โค้ดจริงใน target repo | การ implement ของแต่ละ task (merge เข้า build branch) |
73
+ | `docs/stages/<slug>/build.md` | รายงานผล build: สถานะ/ผล test/ไฟล์ที่แก้ ต่อ task + integration notes |
74
+ | `docs/stages/<slug>/troubleshooting.md` | ปัญหายาก/ซ้ำที่แก้สำเร็จ (SHIP ยกขึ้น `docs/troubleshooting.md`) |
75
+ | `tasks/<task>/task.md` (อัปเดต) | สถานะ task → เสร็จ + acceptance ที่ผ่าน |
76
+
77
+ ---
78
+
79
+ ## 6. Workflow script (Claude Code)
80
+
81
+ ใช้ `.warnyin/workflow/scripts/build-wave.mjs` — fan-out หนึ่ง agent ต่อหนึ่ง task ใน **หนึ่ง wave** (parallel, worktree isolation), คืนผลแบบ structured
82
+ main loop เรียก script นี้ **ทีละ wave** แล้ว integrate ระหว่าง wave (ดูรายละเอียดใน `.claude/commands/warnyin/build.md`)
83
+
84
+ > เครื่องอื่น (Codex/Antigravity) ที่ไม่มี Workflow tool: ทำตามหลักการข้อ 3-4 โดย implement task ตามลำดับ wave เอง (parallel เท่าที่เครื่องรองรับ)
85
+
86
+ ---
87
+
88
+ ## 7. Gate → เข้า VERIFY ได้เมื่อ
89
+
90
+ - [ ] ทุก task ใน DAG ถูก implement และ merge เข้า build branch แล้ว
91
+ - [ ] ทุก task รายงาน `passed` (test-flow + build/lint เขียว) — ไม่มี `failed` ค้าง
92
+ - [ ] ไม่มี merge conflict ค้าง
93
+ - [ ] **★ Full build ของทุก component ผ่าน — ไม่มี build error**
94
+ - [ ] **★ test suite ทั้งหมด (รวม unit test) เขียวทั้งหมดบน build branch**
95
+ - [ ] `build.md` สรุปผลครบทุก task + ผล full build/test
96
+ - [ ] ไม่มีการแตะ rule/standard กลางใน `docs/` (rule ใหม่ยัง note รอ SHIP)
97
+
98
+ ยังไม่ครบ → อยู่ BUILD ต่อ ห้ามข้ามไป VERIFY