@warnyin/agents 0.5.0 → 0.5.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.
Files changed (28) hide show
  1. package/.claude/commands/warnyin/build.md +29 -29
  2. package/.claude/commands/warnyin/design.md +24 -24
  3. package/.claude/commands/warnyin/discovery.md +17 -17
  4. package/.claude/commands/warnyin/init.md +1 -1
  5. package/.claude/commands/warnyin/verify.md +19 -19
  6. package/AGENTS.md +48 -48
  7. package/CLAUDE.md +40 -40
  8. package/package.json +1 -1
  9. package/warnyin/template/stages/[topic]/build.md +58 -58
  10. package/warnyin/template/stages/[topic]/business.md +21 -21
  11. package/warnyin/template/stages/[topic]/design.md +42 -42
  12. package/warnyin/template/stages/[topic]/discovery.md +69 -69
  13. package/warnyin/template/stages/[topic]/proposal.md +43 -43
  14. package/warnyin/template/stages/[topic]/research.md +49 -49
  15. package/warnyin/template/stages/[topic]/tasks/[task-name]/rule.md +13 -13
  16. package/warnyin/template/stages/[topic]/tasks/[task-name]/spec.md +36 -36
  17. package/warnyin/template/stages/[topic]/tasks/[task-name]/standard.md +21 -21
  18. package/warnyin/template/stages/[topic]/tasks/[task-name]/task.md +39 -39
  19. package/warnyin/template/stages/[topic]/test.md +46 -46
  20. package/warnyin/template/stages/[topic]/troubleshooting.md +34 -34
  21. package/warnyin/template/stages/[topic]/verify.md +44 -44
  22. package/warnyin/workflow/README.md +94 -94
  23. package/warnyin/workflow/init.md +68 -4
  24. package/warnyin/workflow/scripts/build-wave.mjs +107 -107
  25. package/warnyin/workflow/stages/build.md +94 -94
  26. package/warnyin/workflow/stages/design.md +116 -116
  27. package/warnyin/workflow/stages/discovery.md +77 -77
  28. package/warnyin/workflow/stages/verify.md +71 -71
@@ -1,107 +1,107 @@
1
- // build-wave — fan-out หนึ่ง sub-agent ต่อหนึ่ง task ใน "หนึ่ง wave" (task ที่ independent กัน)
2
- // main loop (BUILD command) เรียก script นี้ทีละ wave ตาม dependency แล้ว integrate ระหว่าง wave
3
- //
4
- // args = {
5
- // slug: string, // ชื่อ topic เช่น "billing-redesign"
6
- // tasks: string[], // ชื่อ task ใน wave นี้ (โฟลเดอร์ warnyin/stages/<slug>/tasks/<task>)
7
- // isolate?: boolean, // true = worktree ต่อ task (ดีฟอลต์), false = shared tree (sequential)
8
- // }
9
-
10
- export const meta = {
11
- name: 'build-wave',
12
- description: 'BUILD: fan-out sub-agent ต่อ task ใน wave เดียว — implement + test/lint + commit แล้วรายงานผล',
13
- phases: [{ title: 'Build wave', detail: 'parallel agent, หนึ่งตัวต่อหนึ่ง task (worktree isolation)' }],
14
- }
15
-
16
- const slug = args && args.slug
17
- const tasks = (args && args.tasks) || []
18
- const isolate = !(args && args.isolate === false)
19
-
20
- if (!slug || tasks.length === 0) {
21
- log('ไม่มี slug หรือ tasks — ไม่มีอะไรให้ build')
22
- return { slug: slug || null, results: [], failed: [] }
23
- }
24
-
25
- phase('Build wave')
26
- log(`Build ${tasks.length} task ของ "${slug}"${isolate ? ' · worktree isolation' : ' · shared tree'}`)
27
-
28
- const RESULT_SCHEMA = {
29
- type: 'object',
30
- additionalProperties: false,
31
- required: ['task', 'status', 'summary'],
32
- properties: {
33
- task: { type: 'string', description: 'ชื่อ task' },
34
- status: { enum: ['passed', 'failed'], description: 'passed ก็ต่อเมื่อ test/lint เขียวจริง' },
35
- summary: { type: 'string', description: 'สรุปสั้นๆ ว่าทำอะไร' },
36
- branch: { type: 'string', description: 'ชื่อ git branch ของ worktree (ถ้า isolate) ให้ main loop merge' },
37
- filesChanged: { type: 'array', items: { type: 'string' } },
38
- testResult: { type: 'string', description: 'ผล test-flow + build/lint' },
39
- notes: { type: 'string', description: 'conflict/ข้อควรระวัง/ rule ใหม่ที่ note ไว้' },
40
- troubleshooting: {
41
- type: 'array',
42
- description: 'ปัญหายาก/เจอซ้ำที่แก้สำเร็จ — main loop จะเขียนรวมลง topic troubleshooting.md',
43
- items: {
44
- type: 'object',
45
- additionalProperties: false,
46
- required: ['title', 'rootCause', 'solution'],
47
- properties: {
48
- title: { type: 'string' },
49
- symptom: { type: 'string', description: 'อาการ/error message' },
50
- rootCause: { type: 'string' },
51
- solution: { type: 'string' },
52
- prevention: { type: 'string', description: 'วิธีป้องกันไม่ให้เกิดซ้ำ' },
53
- },
54
- },
55
- },
56
- },
57
- }
58
-
59
- function prompt(task) {
60
- const dir = `warnyin/stages/${slug}/tasks/${task}`
61
- const lines = [
62
- `คุณคือ build sub-agent ของ task "${task}" (vertical slice) ทำตาม playbook warnyin/workflow/stages/build.md`,
63
- ``,
64
- `1. อ่านให้ครบก่อนเขียนโค้ด:`,
65
- ` - warnyin/workflow/roles/developer.md (role card: lens + checklist ก่อนส่งงาน — ทำตามทุกข้อ)`,
66
- ` - ${dir}/task.md (เป้าหมาย + sub-tasks + dependency + acceptance)`,
67
- ` - ${dir}/spec.md (API/UXUI/data-flow/user-flow/persona/test-flow)`,
68
- ` - ${dir}/standard.md (pattern โค้ด, shared component — reuse ห้ามเขียนซ้ำ)`,
69
- ` - ${dir}/rule.md (กฎที่ต้อง follow)`,
70
- ` - ภาพรวม: warnyin/stages/${slug}/design.md, proposal.md`,
71
- ` - rule/standard กลางที่อ้างถึงใน docs/techstack/<component>/`,
72
- `2. Implement ให้ครบทุก sub-task แบบ vertical slice (end-to-end) ทำตาม standard.md + rule.md เคร่งครัด`,
73
- `3. รัน test-flow ใน spec.md + build/lint ของ component นั้น`,
74
- `4. ถ้าเจอ error/ติดปัญหา → อ่าน docs/troubleshooting.md ก่อน เผื่อเคยแก้แล้ว`,
75
- `5. รายงาน status=passed เฉพาะเมื่อ test/build เขียวจริง; ถ้าแก้ไม่ได้ → status=failed พร้อมเหตุผล`,
76
- ` ห้ามรายงานผ่านทั้งที่ยังแดง`,
77
- `6. ห้ามแก้ไฟล์ rule/standard กลางใน docs/ (rule ใหม่ note ไว้ใน ${dir}/rule.md อยู่แล้ว รอ SHIP)`,
78
- `7. อัปเดตสถานะ + acceptance ที่ผ่านใน ${dir}/task.md`,
79
- `8. ปัญหาที่ "ยาก/เจอซ้ำ" และแก้สำเร็จ → ใส่ในฟิลด์ troubleshooting (main loop จะรวมลง topic troubleshooting.md)`,
80
- ]
81
- if (isolate) {
82
- lines.push(
83
- `9. คุณอยู่ใน git worktree แยก: เมื่อเสร็จและเขียวแล้ว ให้ commit งาน (git add -A && git commit -m "build(${task}): ...")`,
84
- ` แล้วรายงานชื่อ branch (git rev-parse --abbrev-ref HEAD) ในฟิลด์ branch เพื่อให้ main loop merge`,
85
- )
86
- } else {
87
- lines.push(`9. (shared tree) อย่า commit เอง — main loop จะ commit ให้หลังตรวจ`)
88
- }
89
- lines.push(``, `คืนผลตาม schema.`)
90
- return lines.join('\n')
91
- }
92
-
93
- const results = await parallel(
94
- tasks.map((task) => () =>
95
- agent(prompt(task), isolate
96
- ? { label: `build:${task}`, schema: RESULT_SCHEMA, isolation: 'worktree' }
97
- : { label: `build:${task}`, schema: RESULT_SCHEMA })
98
- )
99
- )
100
-
101
- const clean = results.filter(Boolean)
102
- const failed = clean.filter((r) => r.status === 'failed').map((r) => r.task)
103
- const skipped = tasks.filter((t) => !clean.some((r) => r.task === t))
104
-
105
- log(`เสร็จ ${clean.length}/${tasks.length} · ผ่าน ${clean.length - failed.length} · ล้ม ${failed.length}${skipped.length ? ` · ข้าม ${skipped.length}` : ''}`)
106
-
107
- return { slug, results: clean, failed, skipped }
1
+ // build-wave — fan-out หนึ่ง sub-agent ต่อหนึ่ง task ใน "หนึ่ง wave" (task ที่ independent กัน)
2
+ // main loop (BUILD command) เรียก script นี้ทีละ wave ตาม dependency แล้ว integrate ระหว่าง wave
3
+ //
4
+ // args = {
5
+ // slug: string, // ชื่อ topic เช่น "billing-redesign"
6
+ // tasks: string[], // ชื่อ task ใน wave นี้ (โฟลเดอร์ warnyin/stages/<slug>/tasks/<task>)
7
+ // isolate?: boolean, // true = worktree ต่อ task (ดีฟอลต์), false = shared tree (sequential)
8
+ // }
9
+
10
+ export const meta = {
11
+ name: 'build-wave',
12
+ description: 'BUILD: fan-out sub-agent ต่อ task ใน wave เดียว — implement + test/lint + commit แล้วรายงานผล',
13
+ phases: [{ title: 'Build wave', detail: 'parallel agent, หนึ่งตัวต่อหนึ่ง task (worktree isolation)' }],
14
+ }
15
+
16
+ const slug = args && args.slug
17
+ const tasks = (args && args.tasks) || []
18
+ const isolate = !(args && args.isolate === false)
19
+
20
+ if (!slug || tasks.length === 0) {
21
+ log('ไม่มี slug หรือ tasks — ไม่มีอะไรให้ build')
22
+ return { slug: slug || null, results: [], failed: [] }
23
+ }
24
+
25
+ phase('Build wave')
26
+ log(`Build ${tasks.length} task ของ "${slug}"${isolate ? ' · worktree isolation' : ' · shared tree'}`)
27
+
28
+ const RESULT_SCHEMA = {
29
+ type: 'object',
30
+ additionalProperties: false,
31
+ required: ['task', 'status', 'summary'],
32
+ properties: {
33
+ task: { type: 'string', description: 'ชื่อ task' },
34
+ status: { enum: ['passed', 'failed'], description: 'passed ก็ต่อเมื่อ test/lint เขียวจริง' },
35
+ summary: { type: 'string', description: 'สรุปสั้นๆ ว่าทำอะไร' },
36
+ branch: { type: 'string', description: 'ชื่อ git branch ของ worktree (ถ้า isolate) ให้ main loop merge' },
37
+ filesChanged: { type: 'array', items: { type: 'string' } },
38
+ testResult: { type: 'string', description: 'ผล test-flow + build/lint' },
39
+ notes: { type: 'string', description: 'conflict/ข้อควรระวัง/ rule ใหม่ที่ note ไว้' },
40
+ troubleshooting: {
41
+ type: 'array',
42
+ description: 'ปัญหายาก/เจอซ้ำที่แก้สำเร็จ — main loop จะเขียนรวมลง topic troubleshooting.md',
43
+ items: {
44
+ type: 'object',
45
+ additionalProperties: false,
46
+ required: ['title', 'rootCause', 'solution'],
47
+ properties: {
48
+ title: { type: 'string' },
49
+ symptom: { type: 'string', description: 'อาการ/error message' },
50
+ rootCause: { type: 'string' },
51
+ solution: { type: 'string' },
52
+ prevention: { type: 'string', description: 'วิธีป้องกันไม่ให้เกิดซ้ำ' },
53
+ },
54
+ },
55
+ },
56
+ },
57
+ }
58
+
59
+ function prompt(task) {
60
+ const dir = `warnyin/stages/${slug}/tasks/${task}`
61
+ const lines = [
62
+ `คุณคือ build sub-agent ของ task "${task}" (vertical slice) ทำตาม playbook warnyin/workflow/stages/build.md`,
63
+ ``,
64
+ `1. อ่านให้ครบก่อนเขียนโค้ด:`,
65
+ ` - warnyin/workflow/roles/developer.md (role card: lens + checklist ก่อนส่งงาน — ทำตามทุกข้อ)`,
66
+ ` - ${dir}/task.md (เป้าหมาย + sub-tasks + dependency + acceptance)`,
67
+ ` - ${dir}/spec.md (API/UXUI/data-flow/user-flow/persona/test-flow)`,
68
+ ` - ${dir}/standard.md (pattern โค้ด, shared component — reuse ห้ามเขียนซ้ำ)`,
69
+ ` - ${dir}/rule.md (กฎที่ต้อง follow)`,
70
+ ` - ภาพรวม: warnyin/stages/${slug}/design.md, proposal.md`,
71
+ ` - rule/standard กลางที่อ้างถึงใน docs/techstack/<component>/`,
72
+ `2. Implement ให้ครบทุก sub-task แบบ vertical slice (end-to-end) ทำตาม standard.md + rule.md เคร่งครัด`,
73
+ `3. รัน test-flow ใน spec.md + build/lint ของ component นั้น`,
74
+ `4. ถ้าเจอ error/ติดปัญหา → อ่าน docs/troubleshooting.md ก่อน เผื่อเคยแก้แล้ว`,
75
+ `5. รายงาน status=passed เฉพาะเมื่อ test/build เขียวจริง; ถ้าแก้ไม่ได้ → status=failed พร้อมเหตุผล`,
76
+ ` ห้ามรายงานผ่านทั้งที่ยังแดง`,
77
+ `6. ห้ามแก้ไฟล์ rule/standard กลางใน docs/ (rule ใหม่ note ไว้ใน ${dir}/rule.md อยู่แล้ว รอ SHIP)`,
78
+ `7. อัปเดตสถานะ + acceptance ที่ผ่านใน ${dir}/task.md`,
79
+ `8. ปัญหาที่ "ยาก/เจอซ้ำ" และแก้สำเร็จ → ใส่ในฟิลด์ troubleshooting (main loop จะรวมลง topic troubleshooting.md)`,
80
+ ]
81
+ if (isolate) {
82
+ lines.push(
83
+ `9. คุณอยู่ใน git worktree แยก: เมื่อเสร็จและเขียวแล้ว ให้ commit งาน (git add -A && git commit -m "build(${task}): ...")`,
84
+ ` แล้วรายงานชื่อ branch (git rev-parse --abbrev-ref HEAD) ในฟิลด์ branch เพื่อให้ main loop merge`,
85
+ )
86
+ } else {
87
+ lines.push(`9. (shared tree) อย่า commit เอง — main loop จะ commit ให้หลังตรวจ`)
88
+ }
89
+ lines.push(``, `คืนผลตาม schema.`)
90
+ return lines.join('\n')
91
+ }
92
+
93
+ const results = await parallel(
94
+ tasks.map((task) => () =>
95
+ agent(prompt(task), isolate
96
+ ? { label: `build:${task}`, schema: RESULT_SCHEMA, isolation: 'worktree' }
97
+ : { label: `build:${task}`, schema: RESULT_SCHEMA })
98
+ )
99
+ )
100
+
101
+ const clean = results.filter(Boolean)
102
+ const failed = clean.filter((r) => r.status === 'failed').map((r) => r.task)
103
+ const skipped = tasks.filter((t) => !clean.some((r) => r.task === t))
104
+
105
+ log(`เสร็จ ${clean.length}/${tasks.length} · ผ่าน ${clean.length - failed.length} · ล้ม ${failed.length}${skipped.length ? ` · ข้าม ${skipped.length}` : ''}`)
106
+
107
+ return { slug, results: clean, failed, skipped }
@@ -1,94 +1,94 @@
1
- # Stage: BUILD
2
-
3
- > **Playbook กลาง — AI ทุกเจ้าทำตามไฟล์นี้ชุดเดียวกัน** (Claude Code / Codex / Antigravity / อื่นๆ)
4
- > เป้าหมาย: ลงมือทำ task ที่ DESIGN เตรียมไว้ โดย **fan-out sub-agent อัตโนมัติต่อ task ตาม dependency**
5
-
6
- ---
7
-
8
- ## 1. BUILD คืออะไร / ใช้เมื่อไหร่
9
-
10
- ใช้เมื่อ DESIGN ผ่าน Gate แล้ว มี `tasks/<task>/` ครบ (task.md + spec.md + standard.md + rule.md)
11
- BUILD จะ **orchestrate การ implement** โดยกระจายงานเป็น sub-agent หนึ่งตัวต่อหนึ่ง task/slice และเดินตาม dependency graph
12
-
13
- ---
14
-
15
- ## 2. Input ที่ต้องอ่านก่อนเริ่ม
16
-
17
- 1. `warnyin/stages/<slug>/design.md` — dependency graph ระหว่าง task/slice (section 7)
18
- 2. `warnyin/stages/<slug>/proposal.md` — scope ของ change
19
- 3. `warnyin/stages/<slug>/tasks/<task>/task.md` ทุกใบ — dependency ของแต่ละ task + sub-tasks
20
- 4. `docs/techstack/<component>/rule.md` + `standard.md` — กฎ/มาตรฐานที่ต้อง follow
21
-
22
- ---
23
-
24
- ## 3. หลักการทำงาน (operating principles)
25
-
26
- 1. **ถาม user ยืนยัน "ครั้งเดียวก่อนเริ่ม"** — แสดง execution plan (DAG + wave ไหนรัน parallel + isolation) ให้ user อนุมัติ แล้วจึง fan-out อัตโนมัติ ไม่ถามซ้ำระหว่างทาง
27
- 2. **Fan-out ตาม dependency (wave-based)** — จัด task เป็น "wave" ตาม topological order ของ dependency:
28
- - task ใน wave เดียวกัน = independent → รัน **parallel**
29
- - ข้าม wave = มี dependency → wave ถัดไปเริ่มหลัง wave ก่อนหน้ารวมผลเสร็จ
30
- 3. **Worktree isolation ต่อ task** — แต่ละ parallel task ทำใน git worktree ของตัวเอง ไม่แก้ไฟล์ชนกัน แล้ว **integrate (merge) เข้า build branch หลังจบแต่ละ wave**
31
- - ถ้า target ไม่ใช่ git repo → fallback เป็น **sequential shared-tree** (ทีละ task ตาม dependency)
32
- 4. **แต่ละ build agent ต้อง self-verify** — implement → รัน test-flow ใน `spec.md` + build/lint → **ต้องผ่านก่อนถึง mark passed**; ถ้าแก้ไม่ได้ให้รายงาน `failed` พร้อมเหตุผล **ห้ามรายงานผ่านทั้งที่ยังแดง**
33
- 5. **เคารพ standard/rule ของ task** — ทำตาม `standard.md` (pattern โค้ด, reuse shared component) และ `rule.md` (กฎ) อย่างเคร่งครัด
34
- 6. **ห้ามแตะ rule/standard กลางใน `docs/`** — rule ใหม่ที่เสนอถูก note ไว้ใน `tasks/<task>/rule.md` แล้ว รอ SHIP ค่อยอัปเดตไฟล์กลาง
35
- 7. **fail = หยุดที่ wave นั้น** — ถ้า task ใน wave ล้ม ให้รายงาน user ก่อนไป wave ถัดไป (เพราะ wave ถัดไปอาจ depend อยู่)
36
- 8. **★ ปิดท้ายด้วย full build + full test เสมอ** — หลัง merge ทุก wave แล้ว ต้องรัน build ทั้งหมด + test suite ทั้งหมด (รวม unit test) บน build branch ที่ integrate; **แก้วนจนเขียวหมด** ก่อนปิด BUILD (กันกรณี task รายเดี่ยวเขียวแต่พอรวมกันแล้วพัง)
37
- 9. **ทุก build agent สวม role Developer** — ทำตาม role card `warnyin/workflow/roles/developer.md` (lens + checklist ก่อนส่งงาน) — build-wave.mjs ใส่ให้ใน prompt แล้ว
38
- 10. **★ ใช้ Troubleshooting KB** — เจอปัญหา/error ระหว่าง build ให้ **อ่าน `docs/troubleshooting.md` ก่อนเสมอ** เผื่อเคยแก้แล้ว; เมื่อแก้ปัญหาที่ **ยาก/เจอซ้ำ** สำเร็จ ให้บันทึก entry ลง `warnyin/stages/<slug>/troubleshooting.md` (ปัญหา/อาการ/root cause/วิธีแก้/ป้องกันซ้ำ) — ตอน SHIP จะยกขึ้น KB กลาง
39
-
40
- ---
41
-
42
- ## 4. ลำดับขั้นการทำงาน (orchestration)
43
-
44
- > ผู้ orchestrate คือ AI ตัวหลัก (main loop) — sub-agent คือคนลงมือ implement
45
-
46
- 0. **★ เช็ค context window ก่อนเริ่ม:** ประเมินว่า context ของ session ปัจจุบันถูกใช้ไปมากน้อยแค่ไหน — ถ้าใช้ไปเยอะหรือ **เกินครึ่ง** → **เสนอ user ให้ `/compact` หรือ `/clear` ก่อนเสมอ** แล้วค่อยเริ่ม BUILD ใน context ที่โล่ง (สถานะงานอยู่ในไฟล์ `warnyin/stages/<slug>/` ครบ ไม่หายไปกับ context) — BUILD เป็นงานยาว ต้องมี context เหลือมากพอ; เครื่องอื่นที่ไม่มีคำสั่งนี้ → แนะนำเริ่ม session ใหม่
47
- 1. **อ่าน task ทั้งหมด** → ดึง dependency ของแต่ละ task จาก `task.md` (section 2) + `design.md` (section 7)
48
- 2. **สร้าง DAG + จัด wave** (topological sort): wave 1 = task ที่ไม่มี dependency, wave 2 = task ที่ depend เฉพาะ wave 1, ...
49
- 3. **Pre-check:** target เป็น git repo ไหม (สำหรับ worktree) — ถ้าไม่ใช่ → fallback sequential shared-tree และแจ้ง user
50
- 4. **เสนอ execution plan + ขออนุมัติ (ครั้งเดียว):** แสดง wave / task ในแต่ละ wave / อันไหน parallel / isolation mode → ถาม user go/no-go
51
- 5. **เดินทีละ wave:**
52
- - fan-out sub-agent ของ task ใน wave นั้น (parallel, worktree isolation) ผ่าน **Workflow** (`warnyin/workflow/scripts/build-wave.mjs`)
53
- - แต่ละ agent: implement → test/lint → commit (ถ้า worktree) → รายงานผลแบบ structured (status, files, branch, test result)
54
- - **integrate:** main loop merge worktree branch ของ wave นั้นเข้า build branch (ทีละอันเพื่อเลี่ยง conflict); ถ้า conflict → แก้/รายงาน
55
- - ถ้ามี task `failed` → หยุด รายงาน user
56
- 6. **★ Full build & test gate (หลังทุก wave merge เสร็จ):** บน build branch ที่ integrate แล้ว รัน **build ทั้งหมด + test suite ทั้งหมด (รวม unit test)** ของทุก component ที่กระทบ
57
- - มี error / test แดง → **แก้จนเขียวหมด (loop)** อาจ delegate fix ให้ sub-agent ทีละจุด แล้ว rerun ใหม่
58
- - **ห้ามปิด BUILD ถ้ายังมี build error หรือ test ตัวใดแดง**
59
- - ถ้าวนแก้หลายรอบยังไม่ผ่าน → หยุด รายงาน user พร้อม log error
60
- 7. **ปิดงาน:** อัปเดต `build.md` (รายงานผลต่อ task + ผล full build/test) + สถานะใน `task.md` แต่ละใบ → เสนอเข้า VERIFY ด้วย `/warnyin:verify`
61
-
62
- ---
63
-
64
- ## 5. Output
65
-
66
- | ไฟล์ | เนื้อหา |
67
- |---|---|
68
- | โค้ดจริงใน target repo | การ implement ของแต่ละ task (merge เข้า build branch) |
69
- | `warnyin/stages/<slug>/build.md` | รายงานผล build: สถานะ/ผล test/ไฟล์ที่แก้ ต่อ task + integration notes |
70
- | `warnyin/stages/<slug>/troubleshooting.md` | ปัญหายาก/ซ้ำที่แก้สำเร็จ (SHIP ยกขึ้น `docs/troubleshooting.md`) |
71
- | `tasks/<task>/task.md` (อัปเดต) | สถานะ task → เสร็จ + acceptance ที่ผ่าน |
72
-
73
- ---
74
-
75
- ## 6. Workflow script (Claude Code)
76
-
77
- ใช้ `warnyin/workflow/scripts/build-wave.mjs` — fan-out หนึ่ง agent ต่อหนึ่ง task ใน **หนึ่ง wave** (parallel, worktree isolation), คืนผลแบบ structured
78
- main loop เรียก script นี้ **ทีละ wave** แล้ว integrate ระหว่าง wave (ดูรายละเอียดใน `.claude/commands/warnyin/build.md`)
79
-
80
- > เครื่องอื่น (Codex/Antigravity) ที่ไม่มี Workflow tool: ทำตามหลักการข้อ 3-4 โดย implement task ตามลำดับ wave เอง (parallel เท่าที่เครื่องรองรับ)
81
-
82
- ---
83
-
84
- ## 7. Gate → เข้า VERIFY ได้เมื่อ
85
-
86
- - [ ] ทุก task ใน DAG ถูก implement และ merge เข้า build branch แล้ว
87
- - [ ] ทุก task รายงาน `passed` (test-flow + build/lint เขียว) — ไม่มี `failed` ค้าง
88
- - [ ] ไม่มี merge conflict ค้าง
89
- - [ ] **★ Full build ของทุก component ผ่าน — ไม่มี build error**
90
- - [ ] **★ test suite ทั้งหมด (รวม unit test) เขียวทั้งหมดบน build branch**
91
- - [ ] `build.md` สรุปผลครบทุก task + ผล full build/test
92
- - [ ] ไม่มีการแตะ rule/standard กลางใน `docs/` (rule ใหม่ยัง note รอ SHIP)
93
-
94
- ยังไม่ครบ → อยู่ BUILD ต่อ ห้ามข้ามไป VERIFY
1
+ # Stage: BUILD
2
+
3
+ > **Playbook กลาง — AI ทุกเจ้าทำตามไฟล์นี้ชุดเดียวกัน** (Claude Code / Codex / Antigravity / อื่นๆ)
4
+ > เป้าหมาย: ลงมือทำ task ที่ DESIGN เตรียมไว้ โดย **fan-out sub-agent อัตโนมัติต่อ task ตาม dependency**
5
+
6
+ ---
7
+
8
+ ## 1. BUILD คืออะไร / ใช้เมื่อไหร่
9
+
10
+ ใช้เมื่อ DESIGN ผ่าน Gate แล้ว มี `tasks/<task>/` ครบ (task.md + spec.md + standard.md + rule.md)
11
+ BUILD จะ **orchestrate การ implement** โดยกระจายงานเป็น sub-agent หนึ่งตัวต่อหนึ่ง task/slice และเดินตาม dependency graph
12
+
13
+ ---
14
+
15
+ ## 2. Input ที่ต้องอ่านก่อนเริ่ม
16
+
17
+ 1. `warnyin/stages/<slug>/design.md` — dependency graph ระหว่าง task/slice (section 7)
18
+ 2. `warnyin/stages/<slug>/proposal.md` — scope ของ change
19
+ 3. `warnyin/stages/<slug>/tasks/<task>/task.md` ทุกใบ — dependency ของแต่ละ task + sub-tasks
20
+ 4. `docs/techstack/<component>/rule.md` + `standard.md` — กฎ/มาตรฐานที่ต้อง follow
21
+
22
+ ---
23
+
24
+ ## 3. หลักการทำงาน (operating principles)
25
+
26
+ 1. **ถาม user ยืนยัน "ครั้งเดียวก่อนเริ่ม"** — แสดง execution plan (DAG + wave ไหนรัน parallel + isolation) ให้ user อนุมัติ แล้วจึง fan-out อัตโนมัติ ไม่ถามซ้ำระหว่างทาง
27
+ 2. **Fan-out ตาม dependency (wave-based)** — จัด task เป็น "wave" ตาม topological order ของ dependency:
28
+ - task ใน wave เดียวกัน = independent → รัน **parallel**
29
+ - ข้าม wave = มี dependency → wave ถัดไปเริ่มหลัง wave ก่อนหน้ารวมผลเสร็จ
30
+ 3. **Worktree isolation ต่อ task** — แต่ละ parallel task ทำใน git worktree ของตัวเอง ไม่แก้ไฟล์ชนกัน แล้ว **integrate (merge) เข้า build branch หลังจบแต่ละ wave**
31
+ - ถ้า target ไม่ใช่ git repo → fallback เป็น **sequential shared-tree** (ทีละ task ตาม dependency)
32
+ 4. **แต่ละ build agent ต้อง self-verify** — implement → รัน test-flow ใน `spec.md` + build/lint → **ต้องผ่านก่อนถึง mark passed**; ถ้าแก้ไม่ได้ให้รายงาน `failed` พร้อมเหตุผล **ห้ามรายงานผ่านทั้งที่ยังแดง**
33
+ 5. **เคารพ standard/rule ของ task** — ทำตาม `standard.md` (pattern โค้ด, reuse shared component) และ `rule.md` (กฎ) อย่างเคร่งครัด
34
+ 6. **ห้ามแตะ rule/standard กลางใน `docs/`** — rule ใหม่ที่เสนอถูก note ไว้ใน `tasks/<task>/rule.md` แล้ว รอ SHIP ค่อยอัปเดตไฟล์กลาง
35
+ 7. **fail = หยุดที่ wave นั้น** — ถ้า task ใน wave ล้ม ให้รายงาน user ก่อนไป wave ถัดไป (เพราะ wave ถัดไปอาจ depend อยู่)
36
+ 8. **★ ปิดท้ายด้วย full build + full test เสมอ** — หลัง merge ทุก wave แล้ว ต้องรัน build ทั้งหมด + test suite ทั้งหมด (รวม unit test) บน build branch ที่ integrate; **แก้วนจนเขียวหมด** ก่อนปิด BUILD (กันกรณี task รายเดี่ยวเขียวแต่พอรวมกันแล้วพัง)
37
+ 9. **ทุก build agent สวม role Developer** — ทำตาม role card `warnyin/workflow/roles/developer.md` (lens + checklist ก่อนส่งงาน) — build-wave.mjs ใส่ให้ใน prompt แล้ว
38
+ 10. **★ ใช้ Troubleshooting KB** — เจอปัญหา/error ระหว่าง build ให้ **อ่าน `docs/troubleshooting.md` ก่อนเสมอ** เผื่อเคยแก้แล้ว; เมื่อแก้ปัญหาที่ **ยาก/เจอซ้ำ** สำเร็จ ให้บันทึก entry ลง `warnyin/stages/<slug>/troubleshooting.md` (ปัญหา/อาการ/root cause/วิธีแก้/ป้องกันซ้ำ) — ตอน SHIP จะยกขึ้น KB กลาง
39
+
40
+ ---
41
+
42
+ ## 4. ลำดับขั้นการทำงาน (orchestration)
43
+
44
+ > ผู้ orchestrate คือ AI ตัวหลัก (main loop) — sub-agent คือคนลงมือ implement
45
+
46
+ 0. **★ เช็ค context window ก่อนเริ่ม:** ประเมินว่า context ของ session ปัจจุบันถูกใช้ไปมากน้อยแค่ไหน — ถ้าใช้ไปเยอะหรือ **เกินครึ่ง** → **เสนอ user ให้ `/compact` หรือ `/clear` ก่อนเสมอ** แล้วค่อยเริ่ม BUILD ใน context ที่โล่ง (สถานะงานอยู่ในไฟล์ `warnyin/stages/<slug>/` ครบ ไม่หายไปกับ context) — BUILD เป็นงานยาว ต้องมี context เหลือมากพอ; เครื่องอื่นที่ไม่มีคำสั่งนี้ → แนะนำเริ่ม session ใหม่
47
+ 1. **อ่าน task ทั้งหมด** → ดึง dependency ของแต่ละ task จาก `task.md` (section 2) + `design.md` (section 7)
48
+ 2. **สร้าง DAG + จัด wave** (topological sort): wave 1 = task ที่ไม่มี dependency, wave 2 = task ที่ depend เฉพาะ wave 1, ...
49
+ 3. **Pre-check:** target เป็น git repo ไหม (สำหรับ worktree) — ถ้าไม่ใช่ → fallback sequential shared-tree และแจ้ง user
50
+ 4. **เสนอ execution plan + ขออนุมัติ (ครั้งเดียว):** แสดง wave / task ในแต่ละ wave / อันไหน parallel / isolation mode → ถาม user go/no-go
51
+ 5. **เดินทีละ wave:**
52
+ - fan-out sub-agent ของ task ใน wave นั้น (parallel, worktree isolation) ผ่าน **Workflow** (`warnyin/workflow/scripts/build-wave.mjs`)
53
+ - แต่ละ agent: implement → test/lint → commit (ถ้า worktree) → รายงานผลแบบ structured (status, files, branch, test result)
54
+ - **integrate:** main loop merge worktree branch ของ wave นั้นเข้า build branch (ทีละอันเพื่อเลี่ยง conflict); ถ้า conflict → แก้/รายงาน
55
+ - ถ้ามี task `failed` → หยุด รายงาน user
56
+ 6. **★ Full build & test gate (หลังทุก wave merge เสร็จ):** บน build branch ที่ integrate แล้ว รัน **build ทั้งหมด + test suite ทั้งหมด (รวม unit test)** ของทุก component ที่กระทบ
57
+ - มี error / test แดง → **แก้จนเขียวหมด (loop)** อาจ delegate fix ให้ sub-agent ทีละจุด แล้ว rerun ใหม่
58
+ - **ห้ามปิด BUILD ถ้ายังมี build error หรือ test ตัวใดแดง**
59
+ - ถ้าวนแก้หลายรอบยังไม่ผ่าน → หยุด รายงาน user พร้อม log error
60
+ 7. **ปิดงาน:** อัปเดต `build.md` (รายงานผลต่อ task + ผล full build/test) + สถานะใน `task.md` แต่ละใบ → เสนอเข้า VERIFY ด้วย `/warnyin:verify`
61
+
62
+ ---
63
+
64
+ ## 5. Output
65
+
66
+ | ไฟล์ | เนื้อหา |
67
+ |---|---|
68
+ | โค้ดจริงใน target repo | การ implement ของแต่ละ task (merge เข้า build branch) |
69
+ | `warnyin/stages/<slug>/build.md` | รายงานผล build: สถานะ/ผล test/ไฟล์ที่แก้ ต่อ task + integration notes |
70
+ | `warnyin/stages/<slug>/troubleshooting.md` | ปัญหายาก/ซ้ำที่แก้สำเร็จ (SHIP ยกขึ้น `docs/troubleshooting.md`) |
71
+ | `tasks/<task>/task.md` (อัปเดต) | สถานะ task → เสร็จ + acceptance ที่ผ่าน |
72
+
73
+ ---
74
+
75
+ ## 6. Workflow script (Claude Code)
76
+
77
+ ใช้ `warnyin/workflow/scripts/build-wave.mjs` — fan-out หนึ่ง agent ต่อหนึ่ง task ใน **หนึ่ง wave** (parallel, worktree isolation), คืนผลแบบ structured
78
+ main loop เรียก script นี้ **ทีละ wave** แล้ว integrate ระหว่าง wave (ดูรายละเอียดใน `.claude/commands/warnyin/build.md`)
79
+
80
+ > เครื่องอื่น (Codex/Antigravity) ที่ไม่มี Workflow tool: ทำตามหลักการข้อ 3-4 โดย implement task ตามลำดับ wave เอง (parallel เท่าที่เครื่องรองรับ)
81
+
82
+ ---
83
+
84
+ ## 7. Gate → เข้า VERIFY ได้เมื่อ
85
+
86
+ - [ ] ทุก task ใน DAG ถูก implement และ merge เข้า build branch แล้ว
87
+ - [ ] ทุก task รายงาน `passed` (test-flow + build/lint เขียว) — ไม่มี `failed` ค้าง
88
+ - [ ] ไม่มี merge conflict ค้าง
89
+ - [ ] **★ Full build ของทุก component ผ่าน — ไม่มี build error**
90
+ - [ ] **★ test suite ทั้งหมด (รวม unit test) เขียวทั้งหมดบน build branch**
91
+ - [ ] `build.md` สรุปผลครบทุก task + ผล full build/test
92
+ - [ ] ไม่มีการแตะ rule/standard กลางใน `docs/` (rule ใหม่ยัง note รอ SHIP)
93
+
94
+ ยังไม่ครบ → อยู่ BUILD ต่อ ห้ามข้ามไป VERIFY