dw-kit 1.0.1 → 1.1.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
package/CLAUDE.md CHANGED
@@ -6,6 +6,16 @@ Methodology: `core/WORKFLOW.md` (load on demand — không phải always-loaded)
6
6
 
7
7
  ---
8
8
 
9
+ ## Override
10
+
11
+ Nếu prompt của user chứa `--no-dw`:
12
+ - Bỏ qua **toàn bộ** dw workflow instructions (Quy Tắc Vàng, Routing, Session Start)
13
+ - KHÔNG đọc config, KHÔNG check tasks, KHÔNG apply thinking framework
14
+ - Làm việc như Claude thông thường — trả lời trực tiếp, không theo process nào
15
+ - Áp dụng cho request đó; request tiếp theo vẫn dùng dw bình thường
16
+
17
+ ---
18
+
9
19
  ## Quy Tắc Vàng
10
20
 
11
21
  1. **Config-driven**: Đọc `.dw/config/dw.config.yml` trước mọi action
@@ -42,6 +52,7 @@ Không chắc scope → dùng `standard`. Assess dựa trên facts (file count,
42
52
 
43
53
  | Skill | Mô tả | Depth |
44
54
  |-------|--------|-------|
55
+ | `/dw-prompt [desc]` | Build structured prompt (autocomplete + wizard) | all |
45
56
  | `/dw-task-init [name]` | Khởi tạo task docs | all |
46
57
  | `/dw-research [name]` | Khảo sát codebase | all |
47
58
  | `/dw-plan [name]` | Lập kế hoạch (DỪNG chờ approve) | standard+ |
@@ -59,6 +70,8 @@ Không chắc scope → dùng `standard`. Assess dựa trên facts (file count,
59
70
  | `/dw-dashboard` | PM: metrics report | if pm role |
60
71
  | `/dw-sprint-review` | Team retrospective | all |
61
72
  | `/dw-docs-update` | Cập nhật living docs | thorough |
73
+ | `/dw-onboard` | Onboard dw vào existing project (breadth-first scan) | always |
74
+ | `/dw-retroactive [name]` | Retroactive doc 1 feature đã có (depth-first) | always |
62
75
  | `/dw-config-init` | Khởi tạo config mới | always |
63
76
  | `/dw-config-validate` | Validate config file | always |
64
77
  | `/dw-upgrade` | Upgrade toolkit | always |
package/README.md CHANGED
@@ -14,27 +14,13 @@ dw-kit helps your team run AI-assisted development with a **repeatable workflow*
14
14
  Initialize → Understand → Plan → Execute (TDD) → Verify → Close
15
15
  ```
16
16
 
17
- ```mermaid
18
- %%{init: {'flowchart': {'nodeSpacing': 10, 'rankSpacing': 18}}}%%
19
- flowchart LR
20
- classDef extra fill:#f3f4f6,stroke:#9ca3af,stroke-width:1px,color:#111;
21
-
22
- D[Init + Understand] --> P[Plan (approve)]
23
- P -->|approved| E[Execute (TDD)]
24
- P -->|revise| P
25
-
26
- E --> V[Verify (gates)]
27
- V -->|sign-off| C[Close (handoff + archive)]
28
- V -->|revise (fix)| E
29
-
30
- subgraph Extra[Depth=thorough]
31
- R[Req] --> Est[Est] --> AR[Arch] --> P
32
- P -.-> TP[Test] -.-> E
33
- E -.-> DU[Docs] --> LW[Log] -.-> C
34
- end
35
-
36
- class R,Est,AR,TP,DU,LW extra
37
- ```
17
+ <img src="docs/workflow-diagram.svg" alt="dw-kit workflow diagram" />
18
+
19
+ ## Workflow overview
20
+
21
+ `dw` runs a 6-phase process (all phases for `standard` and `thorough`):
22
+
23
+ Initialize Understand → Plan (stops for approval) → Execute (TDD; 1 commit per subtask) → Verify (quality gates + review sign-off) → Close (handoff + archive when done).
38
24
 
39
25
  ### 6 phases (full workflow)
40
26
  - **Initialize**: clarify task scope and set up the workspace + task docs.
@@ -58,24 +44,28 @@ npm install -g dw-kit
58
44
 
59
45
  ## Quick start
60
46
 
61
- From your project directory:
47
+ Setup dw in project directory:
62
48
 
63
49
  ```bash
64
50
  dw init
65
51
  ```
66
52
 
67
- Then in **Claude Code** (Update for Cursor/Antigravity/... in the next version):
53
+ Then in **Claude Code CLI**, run the full workflow:
68
54
 
69
55
  ```
70
- /dw-flow new-feature
56
+ /dw-flow your-task-or-anythings
71
57
  ```
72
58
 
73
- ## Workflow overview
59
+ ---
74
60
 
75
- `dw` runs a 6-phase process (all phases for `standard` and `thorough`):
61
+ Discover other skills:
76
62
 
77
- Initialize → Understand → Plan (stops for approval) → Execute (TDD; 1 commit per subtask) → Verify (quality gates + review sign-off) → Close (handoff + archive when done).
63
+ ```
64
+ /dw-prompt
65
+ /dw-thinking
66
+ ...
78
67
 
68
+ ```
79
69
 
80
70
  ---
81
71
 
@@ -88,8 +78,13 @@ dw doctor # installation health check
88
78
  dw upgrade # update toolkit files (override-aware)
89
79
  dw upgrade --check # check for updates only
90
80
  dw upgrade --dry-run # preview changes
81
+ dw prompt # build a well-structured task prompt (autocomplete + wizard)
82
+ dw prompt --text "..." # non-interactive: structure a description directly
83
+ dw claude-vn-fix # patch Claude CLI to fix Vietnamese IME (backup/restore)
91
84
  ```
92
85
 
86
+ `dw claude-vn-fix` patches the local Claude CLI bundle to fix Vietnamese IME input (DEL char `\x7f` issue). Includes auto-backup and rollback.
87
+
93
88
  ---
94
89
 
95
90
  ## Depth system
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dw-kit",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "AI development workflow toolkit — structured, quality-assured, team-ready. From requirements to dashboard.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,7 +13,12 @@
13
13
  ".dw/config/",
14
14
  ".dw/adapters/",
15
15
  "scripts/",
16
- ".claude/",
16
+ ".claude/agents/",
17
+ ".claude/hooks/",
18
+ ".claude/rules/",
19
+ ".claude/skills/",
20
+ ".claude/templates/",
21
+ ".claude/settings.json",
17
22
  "CLAUDE.md"
18
23
  ],
19
24
  "engines": {
@@ -46,6 +51,7 @@
46
51
  "ajv": "^8.18.0",
47
52
  "chalk": "^5.6.2",
48
53
  "commander": "^14.0.3",
54
+ "enquirer": "^2.4.1",
49
55
  "js-yaml": "^4.1.1"
50
56
  }
51
57
  }
@@ -0,0 +1,15 @@
1
+ // Minimal fixture that contains the known Vietnamese IME bug pattern.
2
+ // This is NOT the real Claude CLI; only used for testing the patcher logic.
3
+ //
4
+ // IMPORTANT: The comment below must contain both '@anthropic-ai' and 'claude-code'
5
+ // to pass the bundle signature guard in patchCliJs(). Do not remove it.
6
+ // @anthropic-ai/claude-code bundle stub
7
+
8
+ function demo(INPUT) {
9
+ if(INPUT.includes("\x7f")){
10
+ let COUNT=(INPUT.match(/\x7f/g)||[]).length,STATE=CURSTATE;
11
+ UPDATETEXT(STATE.text);UPDATEOFFSET(STATE.offset)
12
+ return;
13
+ }
14
+ }
15
+
package/src/cli.mjs CHANGED
@@ -2,6 +2,8 @@ import { Command } from 'commander';
2
2
  import { createRequire } from 'node:module';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { dirname, join } from 'node:path';
5
+ import chalk from 'chalk';
6
+ import { getUpdateNotice, scheduleUpdateCheck } from './lib/update-checker.mjs';
5
7
 
6
8
  const __filename = fileURLToPath(import.meta.url);
7
9
  const __dirname = dirname(__filename);
@@ -9,6 +11,10 @@ const require = createRequire(import.meta.url);
9
11
  const pkg = require(join(__dirname, '..', 'package.json'));
10
12
 
11
13
  export function run(argv) {
14
+ // Show cached update notice (non-blocking), then schedule fresh check in background
15
+ const latestVersion = getUpdateNotice(pkg.version);
16
+ scheduleUpdateCheck(pkg.version);
17
+
12
18
  const program = new Command();
13
19
 
14
20
  program
@@ -55,5 +61,32 @@ export function run(argv) {
55
61
  await doctorCommand();
56
62
  });
57
63
 
64
+ program
65
+ .command('prompt')
66
+ .description('Build a well-structured task prompt with autocomplete + guided wizard')
67
+ .option('-t, --text <text>', 'Non-interactive: provide description directly')
68
+ .action(async (opts) => {
69
+ const { promptCommand } = await import('./commands/prompt.mjs');
70
+ await promptCommand(opts);
71
+ });
72
+
73
+ program
74
+ .command('claude-vn-fix')
75
+ .description('Patch Claude CLI to fix Vietnamese IME (local, with backup/restore)')
76
+ .option('--path <file>', 'Path to @anthropic-ai/claude-code/cli.js (optional; auto-detect if omitted)')
77
+ .option('--restore', 'Restore from latest backup')
78
+ .option('--dry-run', 'Show what would change without writing')
79
+ .action(async (opts) => {
80
+ const { claudeVnFixCommand } = await import('./commands/claude-vn-fix.mjs');
81
+ await claudeVnFixCommand(opts);
82
+ });
83
+
58
84
  program.parse(argv);
85
+
86
+ if (latestVersion) {
87
+ console.log();
88
+ console.log(chalk.yellow(` ↑ Update available`) + ` v${pkg.version} → ` + chalk.green.bold(`v${latestVersion}`));
89
+ console.log(` Run ` + chalk.cyan(`npm install -g dw-kit`) + ` to update`);
90
+ console.log();
91
+ }
59
92
  }