dw-kit 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,311 @@
1
+ ---
2
+ name: dw-retroactive
3
+ description: "Retroactively document một feature/task đã được implement trước khi dùng dw. Reverse-engineer từ code + git history, tạo đầy đủ context + as-built plan + progress docs. Dùng khi cần AI hiểu sâu một module cũ."
4
+ argument-hint: "[feature-name]"
5
+ allowed-tools:
6
+ - Read
7
+ - Grep
8
+ - Glob
9
+ - Write
10
+ - "Bash(git log *)"
11
+ - "Bash(git diff *)"
12
+ - "Bash(git show *)"
13
+ - "Bash(git blame *)"
14
+ - "Bash(git shortlog *)"
15
+ - "Bash(ls *)"
16
+ ---
17
+
18
+ # dw-retroactive — Retroactive Documentation
19
+
20
+ Feature: **$ARGUMENTS**
21
+
22
+ > Reverse-engineer feature đã tồn tại từ code và git history. Tạo đầy đủ task docs như thể đã đi qua workflow dw — để AI (và team) có context đầy đủ khi làm việc liên quan feature này.
23
+
24
+ ---
25
+
26
+ ## Đọc Config
27
+
28
+ Đọc `.dw/config/dw.config.yml`:
29
+ - `paths.tasks` → output location (mặc định `.dw/tasks`)
30
+ - `project.language` → ngôn ngữ docs
31
+
32
+ ## Kiểm tra đã có docs chưa
33
+
34
+ Kiểm tra `{paths.tasks}/$ARGUMENTS/` đã tồn tại chưa:
35
+ - Nếu rồi → hỏi user: "Đã có task docs cho `$ARGUMENTS`. Overwrite hay skip?"
36
+ - Nếu chưa → tiếp tục
37
+
38
+ ---
39
+
40
+ ## Bước 1: Tìm files liên quan
41
+
42
+ Dùng tên `$ARGUMENTS` như keyword để tìm:
43
+
44
+ ```
45
+ Glob: **/*$ARGUMENTS*
46
+ Grep: "$ARGUMENTS" trong toàn codebase (case-insensitive)
47
+ Grep: tên function/class/route liên quan (nếu có thể suy ra từ tên)
48
+ ```
49
+
50
+ Nếu không tìm được → hỏi user: "Không tìm thấy files liên quan `$ARGUMENTS`. Bạn có thể cung cấp thêm keyword hoặc path không?"
51
+
52
+ ## Bước 2: Đọc và phân tích code
53
+
54
+ Với mỗi file tìm được:
55
+
56
+ 1. **Đọc toàn bộ file** (hoặc phần liên quan)
57
+ 2. Xác định:
58
+ - Vai trò của file trong feature này
59
+ - Logic chính / business rules
60
+ - Input/Output/Side effects
61
+ - Error handling patterns
62
+ 3. **Trace data flow**: đầu vào từ đâu → xử lý gì → kết quả đi đâu
63
+ 4. **Tìm dependencies**: module này gọi gì? Ai gọi module này?
64
+ 5. **Tìm tests**: test files liên quan, coverage hiện tại
65
+
66
+ ## Bước 3: Phân tích git history
67
+
68
+ ```bash
69
+ # Commits liên quan feature
70
+ git log --oneline --follow -- [files-found]
71
+
72
+ # Ai đã implement
73
+ git shortlog -sn -- [files-found]
74
+
75
+ # Thay đổi đáng kể
76
+ git log --oneline --diff-filter=A -- [files-found] # khi files được tạo
77
+
78
+ # Context của lần commit đầu tiên
79
+ git show [first-commit] --stat
80
+ ```
81
+
82
+ Xác định:
83
+ - Feature được tạo khi nào
84
+ - Ai implement (để biết ai có thể được hỏi)
85
+ - Có breaking changes nào đã được fix sau đó không
86
+ - Tech debt nào đang tồn tại (TODO, FIXME trong code)
87
+
88
+ ## Bước 4: Áp dụng tư duy phản biện
89
+
90
+ Từ framework `core/THINKING.md` (hoặc `.claude/skills/dw-thinking/THINKING.md`):
91
+
92
+ - **Giả định**: Code đang giả định gì về input, state, environment?
93
+ - **Failure modes**: Điều gì có thể làm feature này fail? Edge cases nào?
94
+ - **Tech debt**: Có TODO/FIXME? Có antipatterns? Code mùi?
95
+ - **Security**: Có điểm nào đáng lo ngại về auth, validation, data exposure?
96
+
97
+ ## Bước 5: Tạo task docs
98
+
99
+ Tạo thư mục `{paths.tasks}/$ARGUMENTS/` và 3 files:
100
+
101
+ ### 5a. Context doc
102
+
103
+ Tạo `{paths.tasks}/$ARGUMENTS/$ARGUMENTS-context.md`:
104
+
105
+ ```markdown
106
+ # Context: $ARGUMENTS
107
+
108
+ ## Ngày khảo sát: [date]
109
+ ## Loại: Retroactive Documentation
110
+ ## Người thực hiện: agent (dw-retroactive)
111
+
112
+ ---
113
+
114
+ ## Mô Tả Feature
115
+
116
+ [2-3 câu mô tả feature làm gì, phục vụ ai]
117
+
118
+ ## Codebase Analysis
119
+
120
+ ### Files Liên Quan
121
+
122
+ | # | File | Vai trò | Ghi chú |
123
+ |---|------|---------|---------|
124
+ | 1 | [file] | [vai trò] | |
125
+
126
+ ### Kiến Trúc
127
+
128
+ ```
129
+ [ASCII diagram hoặc mô tả luồng]
130
+ Input → [Module] → Output
131
+
132
+ [Dependencies]
133
+ ```
134
+
135
+ ### Data Flow
136
+
137
+ - **Input**: [từ đâu, format gì]
138
+ - **Processing**: [logic chính]
139
+ - **Output**: [đi đâu, format gì]
140
+ - **Side effects**: [DB writes, events, external calls]
141
+
142
+ ## Dependencies
143
+
144
+ ### Upstream (feature phụ thuộc vào)
145
+ - [ ] [Module/Service] — [vai trò]
146
+
147
+ ### Downstream (ai phụ thuộc vào feature này)
148
+ - [ ] [Module/Service] — [ảnh hưởng thế nào]
149
+
150
+ ## Git History
151
+
152
+ - **Tạo lần đầu**: [date] bởi [author]
153
+ - **Commits**: [N commits]
154
+ - **Maintainer chính**: [author]
155
+ - **Thay đổi đáng kể**: [mô tả nếu có]
156
+
157
+ ## Test Coverage
158
+
159
+ - [ ] Có tests: [Có/Không]
160
+ - Test files: [danh sách]
161
+ - Coverage: [mô tả]
162
+ - Gaps: [thiếu test ở đâu]
163
+
164
+ ## Giả Định & Hạn Chế
165
+
166
+ | # | Giả định/Hạn chế | Mức độ rủi ro |
167
+ |---|-----------------|--------------|
168
+ | 1 | [giả định trong code] | Cao/TB/Thấp |
169
+
170
+ ## Tech Debt & Warnings
171
+
172
+ - [ ] [TODO/FIXME đang có]
173
+ - [ ] [Antipatterns phát hiện]
174
+ - [ ] [Security concerns]
175
+
176
+ ## Ghi Chú Cho AI
177
+
178
+ > Context quan trọng khi làm task liên quan feature này:
179
+ - [Gotcha 1]
180
+ - [Gotcha 2]
181
+ ```
182
+
183
+ ### 5b. As-Built Plan doc
184
+
185
+ Tạo `{paths.tasks}/$ARGUMENTS/$ARGUMENTS-plan.md`:
186
+
187
+ ```markdown
188
+ # As-Built Plan: $ARGUMENTS
189
+
190
+ ## Ngày tạo: [date]
191
+ ## Loại: As-Built (Retroactive) — không phải forward plan
192
+ ## Trạng thái: Done (implemented trước khi adopt dw)
193
+ ## Implemented by: [author từ git history]
194
+
195
+ ---
196
+
197
+ > ⚠ Đây là tài liệu retroactive — mô tả những gì ĐÃ được implement,
198
+ > không phải plan cho việc sẽ làm. Dùng để AI và team hiểu context.
199
+
200
+ ## Tóm Tắt Giải Pháp Đã Implement
201
+
202
+ [Mô tả approach được dùng, dựa trên code analysis]
203
+
204
+ ## Những Gì Đã Implement
205
+
206
+ ### Component 1: [Tên]
207
+ - **Mô tả**: [làm gì]
208
+ - **Files**: [danh sách]
209
+ - **Cách hoạt động**: [tóm tắt logic]
210
+
211
+ ### Component 2: [Tên]
212
+ ...
213
+
214
+ ## Quyết Định Kỹ Thuật Đáng Chú Ý
215
+
216
+ | Quyết định | Approach đã dùng | Lý do suy đoán |
217
+ |-----------|-----------------|----------------|
218
+ | [decision] | [approach] | [inferred from code/commits] |
219
+
220
+ ## Rủi Ro & Hạn Chế Đã Biết
221
+
222
+ | # | Mô tả | Mức độ | Trạng thái |
223
+ |---|-------|--------|-----------|
224
+ | 1 | [risk] | Cao/TB/Thấp | Open/Resolved |
225
+
226
+ ## Edge Cases
227
+
228
+ - [ ] [Edge case được xử lý hay chưa?]
229
+
230
+ ## Tác Động Hệ Thống
231
+
232
+ - **Modules ảnh hưởng**: [danh sách]
233
+ - **API**: [endpoints liên quan]
234
+ - **Database**: [schema/tables liên quan]
235
+ ```
236
+
237
+ ### 5c. Progress doc
238
+
239
+ Tạo `{paths.tasks}/$ARGUMENTS/$ARGUMENTS-progress.md`:
240
+
241
+ ```markdown
242
+ # Progress: $ARGUMENTS
243
+
244
+ ## Trạng thái: Done (Pre-dw Implementation)
245
+ ## Loại: Retroactive Documentation
246
+ ## Documented on: [date]
247
+
248
+ ---
249
+
250
+ > Feature này đã được implement trước khi adopt dw-kit.
251
+ > File này được tạo retroactively để AI có context khi làm task liên quan.
252
+
253
+ ## Implementation History (từ git)
254
+
255
+ | Thời điểm | Sự kiện | Author |
256
+ |-----------|---------|--------|
257
+ | [date] | Feature được tạo | [author] |
258
+ | [date] | [notable change] | [author] |
259
+
260
+ ## Known Issues / Open Items
261
+
262
+ - [ ] [Issue đang mở nếu có]
263
+ - [ ] [Tech debt cần xử lý]
264
+
265
+ ## Handoff Notes cho AI
266
+
267
+ Khi làm task liên quan feature này:
268
+ - **Đọc trước**: `$ARGUMENTS-context.md` để hiểu architecture
269
+ - **Cẩn thận**: [warning 1]
270
+ - **Không thay đổi**: [phần nào là stable contract]
271
+ - **Có thể refactor**: [phần nào an toàn để thay đổi]
272
+ ```
273
+
274
+ ---
275
+
276
+ ## Bước 6: Báo cáo kết quả
277
+
278
+ ```
279
+ ╔══════════════════════════════════════════════════════╗
280
+ ║ ✅ dw-retroactive complete: $ARGUMENTS
281
+ ╠══════════════════════════════════════════════════════╣
282
+ ║ Files khảo sát : [N files]
283
+ ║ Git commits : [N commits, từ [date] đến [date]]
284
+ ║ Maintainer chính : [author]
285
+ ╠══════════════════════════════════════════════════════╣
286
+ ║ Docs đã tạo:
287
+ ║ {paths.tasks}/$ARGUMENTS/$ARGUMENTS-context.md
288
+ ║ {paths.tasks}/$ARGUMENTS/$ARGUMENTS-plan.md (as-built)
289
+ ║ {paths.tasks}/$ARGUMENTS/$ARGUMENTS-progress.md
290
+ ╠══════════════════════════════════════════════════════╣
291
+ ║ Key findings:
292
+ ║ • [Finding 1]
293
+ ║ • [Finding 2]
294
+ ║ • [Finding 3]
295
+ ╠══════════════════════════════════════════════════════╣
296
+ ║ Tech debt / warnings:
297
+ ║ • [Warning nếu có]
298
+ ╠══════════════════════════════════════════════════════╣
299
+ ║ Tiếp theo:
300
+ ║ → Khi cần task liên quan: /dw-research $ARGUMENTS
301
+ ║ (AI sẽ đọc context docs vừa tạo làm foundation)
302
+ ╚══════════════════════════════════════════════════════╝
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Lưu ý
308
+
309
+ - **As-built ≠ forward plan**: Docs này mô tả hiện trạng, không phải kế hoạch
310
+ - **Best-effort**: AI chỉ thấy được những gì có trong code và git — context ẩn (verbal decisions, Slack threads) có thể thiếu. Cần human review và bổ sung.
311
+ - **Sau khi tạo**: Khuyến khích dev liên quan review và bổ sung `## Ghi Chú Cho AI` section
@@ -0,0 +1,35 @@
1
+ ---
2
+ date: [ISO timestamp — e.g. 2026-04-02T14:30:00]
3
+ from: [agent-role — researcher | planner | developer | reviewer | debugger]
4
+ to: [agent-role — planner | developer | user]
5
+ task: [task-name]
6
+ status: DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT
7
+ ---
8
+
9
+ ## Summary
10
+
11
+ [1-3 câu tóm tắt kết quả / findings]
12
+
13
+ ## Details
14
+
15
+ [Chi tiết findings, decisions, hoặc implementation notes]
16
+
17
+ ## Concerns (nếu DONE_WITH_CONCERNS)
18
+
19
+ - [Concern 1]
20
+ - [Concern 2]
21
+
22
+ ## Blockers (nếu BLOCKED)
23
+
24
+ - **Blocker**: [Mô tả vấn đề]
25
+ - **Owner**: [Ai cần resolve]
26
+ - **Unblock by**: [Action cần làm]
27
+
28
+ ## Needs (nếu NEEDS_CONTEXT)
29
+
30
+ - [ ] [Thông tin cần thêm]
31
+ - [ ] [Quyết định cần từ user/TL]
32
+
33
+ ## Next Steps
34
+
35
+ - [Bước tiếp theo đề xuất]
@@ -0,0 +1,53 @@
1
+ # Agent Communication Protocol — dw-kit v1.2
2
+
3
+ ## Mục Đích
4
+
5
+ Khi một task lớn cần nhiều "vai" khác nhau (researcher → planner → developer), việc ghi lại kết quả từng bước giúp:
6
+ - Team members (người hoặc agent) biết chính xác task đang ở đâu
7
+ - Audit trail rõ ràng: ai quyết định gì, lúc nào
8
+ - Session tiếp theo có thể tiếp tục mà không cần hỏi lại
9
+
10
+ ## Convention: Reports Directory
11
+
12
+ ```
13
+ .dw/tasks/[task-name]/
14
+ ├── [name]-context.md # Research findings
15
+ ├── [name]-plan.md # Implementation plan
16
+ ├── [name]-progress.md # Progress tracking
17
+ └── reports/ # Agent communication (v1.2+)
18
+ ├── 260402-1430-from-researcher-to-planner-analysis.md
19
+ ├── 260402-1500-from-planner-to-developer-subtask-1.md
20
+ └── 260402-1600-from-developer-to-reviewer-pr-ready.md
21
+ ```
22
+
23
+ **Filename format**: `[YYMMDD-HHMM]-from-[role]-to-[role]-[description].md`
24
+
25
+ ## Status Codes
26
+
27
+ | Status | Nghĩa |
28
+ |--------|-------|
29
+ | `DONE` | Hoàn thành, output sẵn sàng để dùng |
30
+ | `DONE_WITH_CONCERNS` | Xong nhưng có điểm đáng chú ý / cần review |
31
+ | `BLOCKED` | Bị chặn, cần action từ bên ngoài để tiếp tục |
32
+ | `NEEDS_CONTEXT` | Thiếu thông tin, cần human confirm |
33
+
34
+ ## Khi Nào Tạo Report
35
+
36
+ - Sau khi `dw-research` hoàn thành → report `from-researcher-to-planner`
37
+ - Sau khi `dw-plan` approved → report `from-planner-to-developer`
38
+ - Khi phát hiện blocker trong execute → report `from-developer-to-user` với `BLOCKED`
39
+ - Sau khi review xong → report `from-reviewer-to-developer`
40
+
41
+ ## Khi Nào KHÔNG Cần Report
42
+
43
+ - Tasks `quick` depth (≤2 files, hotfix) → không cần overhead này
44
+ - Solo dev, single session → progress.md đã đủ
45
+ - Thông tin đã có trong context.md / plan.md → không duplicate
46
+
47
+ ## Template
48
+
49
+ Dùng `.claude/templates/agent-report.md`
50
+
51
+ ## Lưu Ý Quan Trọng
52
+
53
+ Reports là **cho con người đọc**, không phải protocol cho AI. Claude Code đã communicate qua conversation context. Reports giúp team members theo dõi task cross-session, không phải AI-to-AI messaging.
package/CLAUDE.md CHANGED
@@ -1,99 +1,39 @@
1
- <!-- dw-kit | core: 1.0 | platform: 1.0 -->
2
- # dw-kit
1
+ # dw-kit (repo)
3
2
 
4
- Workflow toolkit cho dev team. Config: `.dw/config/dw.config.yml`
5
- Methodology: `core/WORKFLOW.md` (load on demand — không phải always-loaded)
3
+ Workflow toolkit codebase. dw rules live in `.claude/rules/` — auto-loaded by Claude Code.
6
4
 
7
- ---
8
-
9
- ## Quy Tắc Vàng
10
-
11
- 1. **Config-driven**: Đọc `.dw/config/dw.config.yml` trước mọi action
12
- 2. **Research trước, code sau**: Task ≥3 files BẮT BUỘC qua research → plan → execute
13
- 3. **Thinking framework**: Áp dụng `core/THINKING.md` khi planning
14
- 4. **TDD**: Viết test trước khi code
15
- 5. **Commit nhỏ**: Mỗi subtask = 1 commit
5
+ Config: `.dw/config/dw.config.yml`
16
6
 
17
7
  ---
18
8
 
19
- ## Routing
20
-
21
- Đọc `workflow.default_depth` từ config. AI assess per-task:
9
+ ## Tech Stack
22
10
 
23
- | Scope | Depth | Workflow |
24
- |-------|-------|---------|
25
- | ≤2 files, hotfix, familiar module | quick | Understand → Execute → Close |
26
- | 3-5 files, module mới | standard | Tất cả 6 phases |
27
- | 6+ files, API/DB/security changes | thorough | Full + arch-review + test-plan |
28
-
29
- Không chắc scope → dùng `standard`. Assess dựa trên facts (file count, API changes, git blame).
30
-
31
- ---
11
+ - Runtime: Node.js ≥18, ESM (`.mjs`)
12
+ - CLI: `commander` · UI: `enquirer`, `chalk` · Config: `js-yaml`, `ajv`
13
+ - Tests: `node src/smoke-test.mjs`
32
14
 
33
- ## Session Start
34
-
35
- 1. Đọc `.dw/config/dw.config.yml` → depth, roles, quality commands
36
- 2. Kiểm tra `.dw/tasks/` → active tasks
37
- 3. Đọc `[task]-progress.md` của task đang dở → tiếp tục từ subtask cuối
38
-
39
- ---
40
-
41
- ## Skills
42
-
43
- | Skill | Mô tả | Depth |
44
- |-------|--------|-------|
45
- | `/dw-prompt [desc]` | Build structured prompt (autocomplete + wizard) | all |
46
- | `/dw-task-init [name]` | Khởi tạo task docs | all |
47
- | `/dw-research [name]` | Khảo sát codebase | all |
48
- | `/dw-plan [name]` | Lập kế hoạch (DỪNG chờ approve) | standard+ |
49
- | `/dw-execute [name]` | Implement theo plan (TDD) | all |
50
- | `/dw-commit [msg]` | Smart commit + quality gates | all |
51
- | `/dw-review` | Code review với checklist | standard+ |
52
- | `/dw-debug [issue]` | Debug: investigate → diagnose → fix | all |
53
- | `/dw-thinking [question]` | Apply thinking framework | all |
54
- | `/dw-estimate [name]` | Ước lượng effort | if enabled |
55
- | `/dw-log-work [name]` | Ghi effort thực tế | if enabled |
56
- | `/dw-handoff` | Bàn giao session | all |
57
- | `/dw-requirements` | BA: requirements + user stories | if ba role |
58
- | `/dw-test-plan` | QC: test plan + regression | if qc role |
59
- | `/dw-arch-review` | TL: architecture review | if techlead |
60
- | `/dw-dashboard` | PM: metrics report | if pm role |
61
- | `/dw-sprint-review` | Team retrospective | all |
62
- | `/dw-docs-update` | Cập nhật living docs | thorough |
63
- | `/dw-config-init` | Khởi tạo config mới | always |
64
- | `/dw-config-validate` | Validate config file | always |
65
- | `/dw-upgrade` | Upgrade toolkit | always |
66
- | `/dw-rollback [name]` | Rollback task docs | always |
67
- | `/dw-archive [name]` | Archive completed task | always |
68
-
69
- ---
70
-
71
- ## Task Documentation
72
-
73
- ```
74
- .dw/tasks/[task-name]/
75
- ├── [name]-context.md # Research findings
76
- ├── [name]-plan.md # Implementation plan
77
- └── [name]-progress.md # Progress + handoff notes
78
- ```
79
-
80
- ---
81
-
82
- ## Commit Format
15
+ ## Repo Structure
83
16
 
84
17
  ```
85
- <type>(<scope>): <mô tả ≤72 ký tự>
86
-
87
- Co-Authored-By: Claude <noreply@anthropic.com>
18
+ bin/ CLI entrypoint
19
+ src/
20
+ commands/ CLI subcommands (init, upgrade, validate, ...)
21
+ lib/ Shared utilities (config, copy, ui, ...)
22
+ .claude/
23
+ hooks/ Bash hooks — python3-free, node only (Windows compat)
24
+ rules/ dw-core.md + dw-skills.md (auto-loaded by Claude Code)
25
+ skills/ Slash command definitions
26
+ templates/ Agent report template
27
+ .dw/
28
+ core/ WORKFLOW.md, THINKING.md, QUALITY.md, ROLES.md
29
+ config/ dw.config.yml for this repo
30
+ tasks/ Active task docs
88
31
  ```
89
32
 
90
- Types: `feat` `fix` `refactor` `test` `docs` `chore` `style` `perf`
91
-
92
- ---
93
-
94
- ## Methodology Reference
33
+ ## Dev Notes
95
34
 
96
- Full methodology: `core/WORKFLOW.md`
97
- Thinking framework: `core/THINKING.md`
98
- Quality strategy: `core/QUALITY.md`
99
- Role definitions: `core/ROLES.md`
35
+ - All source ESM (`import`/`export`) — no CommonJS
36
+ - `TOOLKIT_ROOT` resolved from `import.meta.url` in each command
37
+ - Hooks use `node` for JSON parsing (not python3 — Windows compat)
38
+ - Skills `dw-kit-evolve` and `dw-kit-audit` are maintainer-only — excluded from npm package
39
+ - Published package files declared explicitly in `package.json#files`