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.
- package/.claude/rules/code-style.md +37 -37
- package/.claude/rules/commit-standards.md +37 -37
- package/.claude/rules/workflow-rules.md +15 -0
- package/.claude/settings.json +1 -1
- package/.claude/skills/dw-onboard/SKILL.md +201 -0
- package/.claude/skills/dw-prompt/SKILL.md +62 -0
- package/.claude/skills/dw-retroactive/SKILL.md +311 -0
- package/CLAUDE.md +13 -0
- package/README.md +22 -27
- package/package.json +8 -2
- package/src/__fixtures__/claude-cli-bug-snippet.js +15 -0
- package/src/cli.mjs +33 -0
- package/src/commands/claude-vn-fix.mjs +267 -0
- package/src/commands/init.mjs +1 -1
- package/src/commands/prompt.mjs +112 -0
- package/src/lib/clipboard.mjs +24 -0
- package/src/lib/prompt-suggest.mjs +84 -0
- package/src/lib/update-checker.mjs +73 -0
- package/src/smoke-test.mjs +47 -1
- package/.claude/settings.local.json +0 -12
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
# Code Style & Conventions
|
|
2
|
-
|
|
3
|
-
## Nguyên tắc chung
|
|
4
|
-
- Đặt tên biến/hàm rõ ràng, tự giải thích (self-documenting)
|
|
5
|
-
- Ưu tiên đơn giản, dễ đọc hơn clever code
|
|
6
|
-
- Mỗi function làm MỘT việc
|
|
7
|
-
- Comments giải thích WHY, không phải WHAT
|
|
8
|
-
- Xử lý errors ở đầu function (guard clauses / early return)
|
|
9
|
-
|
|
10
|
-
## Naming Conventions
|
|
11
|
-
- Variables/Functions: camelCase
|
|
12
|
-
- Classes/Components: PascalCase
|
|
13
|
-
- Constants: UPPER_SNAKE_CASE
|
|
14
|
-
- Files: kebab-case hoặc theo convention của framework
|
|
15
|
-
- Directories: kebab-case
|
|
16
|
-
|
|
17
|
-
## File Organization
|
|
18
|
-
- 1 component/class per file (trừ khi strongly related)
|
|
19
|
-
- Group imports: external → internal → relative
|
|
20
|
-
- Export ở cuối file hoặc inline (nhất quán trong project)
|
|
21
|
-
|
|
22
|
-
## Error Handling
|
|
23
|
-
- KHÔNG swallow errors (catch rỗng)
|
|
24
|
-
- Log đủ context để debug (error message, input data, stack)
|
|
25
|
-
- Dùng custom error types cho domain errors
|
|
26
|
-
- Validate input ở boundary (API, form, external data)
|
|
27
|
-
|
|
28
|
-
## Testing
|
|
29
|
-
- Test file cùng tên với source: `foo.ts` → `foo.test.ts` hoặc `foo.spec.ts`
|
|
30
|
-
- Mỗi test case kiểm tra MỘT behavior
|
|
31
|
-
- Test name mô tả expected behavior: "should return error when input is empty"
|
|
32
|
-
- Arrange → Act → Assert pattern
|
|
33
|
-
- KHÔNG mock internal implementation details
|
|
34
|
-
|
|
35
|
-
## NOTE
|
|
36
|
-
Đây là quy tắc mặc định. Team tùy chỉnh theo stack cụ thể của dự án.
|
|
37
|
-
Thêm framework-specific rules vào file này hoặc tạo file riêng trong `.claude/rules/`.
|
|
1
|
+
# Code Style & Conventions
|
|
2
|
+
|
|
3
|
+
## Nguyên tắc chung
|
|
4
|
+
- Đặt tên biến/hàm rõ ràng, tự giải thích (self-documenting)
|
|
5
|
+
- Ưu tiên đơn giản, dễ đọc hơn clever code
|
|
6
|
+
- Mỗi function làm MỘT việc
|
|
7
|
+
- Comments giải thích WHY, không phải WHAT
|
|
8
|
+
- Xử lý errors ở đầu function (guard clauses / early return)
|
|
9
|
+
|
|
10
|
+
## Naming Conventions
|
|
11
|
+
- Variables/Functions: camelCase
|
|
12
|
+
- Classes/Components: PascalCase
|
|
13
|
+
- Constants: UPPER_SNAKE_CASE
|
|
14
|
+
- Files: kebab-case hoặc theo convention của framework
|
|
15
|
+
- Directories: kebab-case
|
|
16
|
+
|
|
17
|
+
## File Organization
|
|
18
|
+
- 1 component/class per file (trừ khi strongly related)
|
|
19
|
+
- Group imports: external → internal → relative
|
|
20
|
+
- Export ở cuối file hoặc inline (nhất quán trong project)
|
|
21
|
+
|
|
22
|
+
## Error Handling
|
|
23
|
+
- KHÔNG swallow errors (catch rỗng)
|
|
24
|
+
- Log đủ context để debug (error message, input data, stack)
|
|
25
|
+
- Dùng custom error types cho domain errors
|
|
26
|
+
- Validate input ở boundary (API, form, external data)
|
|
27
|
+
|
|
28
|
+
## Testing
|
|
29
|
+
- Test file cùng tên với source: `foo.ts` → `foo.test.ts` hoặc `foo.spec.ts`
|
|
30
|
+
- Mỗi test case kiểm tra MỘT behavior
|
|
31
|
+
- Test name mô tả expected behavior: "should return error when input is empty"
|
|
32
|
+
- Arrange → Act → Assert pattern
|
|
33
|
+
- KHÔNG mock internal implementation details
|
|
34
|
+
|
|
35
|
+
## NOTE
|
|
36
|
+
Đây là quy tắc mặc định. Team tùy chỉnh theo stack cụ thể của dự án.
|
|
37
|
+
Thêm framework-specific rules vào file này hoặc tạo file riêng trong `.claude/rules/`.
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
# Commit Standards
|
|
2
|
-
|
|
3
|
-
## Format
|
|
4
|
-
```
|
|
5
|
-
<type>(<scope>): <mô tả tiếng Việt hoặc tiếng Anh>
|
|
6
|
-
|
|
7
|
-
[Body - chi tiết thay đổi, lý do]
|
|
8
|
-
[Blank line]
|
|
9
|
-
[Footer - breaking changes, references]
|
|
10
|
-
|
|
11
|
-
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Types
|
|
15
|
-
| Type | Khi nào dùng |
|
|
16
|
-
|------|-------------|
|
|
17
|
-
| `feat` | Tính năng mới |
|
|
18
|
-
| `fix` | Sửa lỗi |
|
|
19
|
-
| `refactor` | Tái cấu trúc, không thay đổi behavior |
|
|
20
|
-
| `test` | Thêm/sửa tests |
|
|
21
|
-
| `docs` | Tài liệu, comments |
|
|
22
|
-
| `chore` | Build, config, dependencies |
|
|
23
|
-
| `style` | Format, whitespace (không thay đổi logic) |
|
|
24
|
-
| `perf` | Cải thiện performance |
|
|
25
|
-
|
|
26
|
-
## Quy tắc
|
|
27
|
-
- Mỗi commit = 1 subtask hoặc 1 đơn vị logic hoàn chỉnh
|
|
28
|
-
- Mô tả ngắn <= 72 ký tự
|
|
29
|
-
- Dùng thì hiện tại: "thêm", "sửa", "cập nhật" (không phải "đã thêm")
|
|
30
|
-
- KHÔNG commit files chứa secrets (.env, credentials, tokens)
|
|
31
|
-
- KHÔNG commit console.log/debugger còn sót
|
|
32
|
-
|
|
33
|
-
## Branch Naming
|
|
34
|
-
```
|
|
35
|
-
<type>/<task-name>
|
|
36
|
-
```
|
|
37
|
-
Ví dụ: `feat/user-auth`, `fix/login-redirect`, `refactor/api-structure`
|
|
1
|
+
# Commit Standards
|
|
2
|
+
|
|
3
|
+
## Format
|
|
4
|
+
```
|
|
5
|
+
<type>(<scope>): <mô tả tiếng Việt hoặc tiếng Anh>
|
|
6
|
+
|
|
7
|
+
[Body - chi tiết thay đổi, lý do]
|
|
8
|
+
[Blank line]
|
|
9
|
+
[Footer - breaking changes, references]
|
|
10
|
+
|
|
11
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Types
|
|
15
|
+
| Type | Khi nào dùng |
|
|
16
|
+
|------|-------------|
|
|
17
|
+
| `feat` | Tính năng mới |
|
|
18
|
+
| `fix` | Sửa lỗi |
|
|
19
|
+
| `refactor` | Tái cấu trúc, không thay đổi behavior |
|
|
20
|
+
| `test` | Thêm/sửa tests |
|
|
21
|
+
| `docs` | Tài liệu, comments |
|
|
22
|
+
| `chore` | Build, config, dependencies |
|
|
23
|
+
| `style` | Format, whitespace (không thay đổi logic) |
|
|
24
|
+
| `perf` | Cải thiện performance |
|
|
25
|
+
|
|
26
|
+
## Quy tắc
|
|
27
|
+
- Mỗi commit = 1 subtask hoặc 1 đơn vị logic hoàn chỉnh
|
|
28
|
+
- Mô tả ngắn <= 72 ký tự
|
|
29
|
+
- Dùng thì hiện tại: "thêm", "sửa", "cập nhật" (không phải "đã thêm")
|
|
30
|
+
- KHÔNG commit files chứa secrets (.env, credentials, tokens)
|
|
31
|
+
- KHÔNG commit console.log/debugger còn sót
|
|
32
|
+
|
|
33
|
+
## Branch Naming
|
|
34
|
+
```
|
|
35
|
+
<type>/<task-name>
|
|
36
|
+
```
|
|
37
|
+
Ví dụ: `feat/user-auth`, `fix/login-redirect`, `refactor/api-structure`
|
|
@@ -12,6 +12,8 @@ Trước khi thực hiện bất kỳ skill nào, PHẢI đọc `.dw/config/dw.c
|
|
|
12
12
|
|
|
13
13
|
| Skill | Level 1 | Level 2 | Level 3 |
|
|
14
14
|
|-------|---------|---------|---------|
|
|
15
|
+
| onboard | yes | yes | yes |
|
|
16
|
+
| retroactive | yes | yes | yes |
|
|
15
17
|
| task-init | yes | yes | yes |
|
|
16
18
|
| research | yes | yes | yes |
|
|
17
19
|
| plan | skip | yes | yes |
|
|
@@ -43,6 +45,19 @@ Trước khi thực hiện bất kỳ skill nào, PHẢI đọc `.dw/config/dw.c
|
|
|
43
45
|
- Ghi rõ: đang ở subtask nào, blockers, context quan trọng
|
|
44
46
|
- Commit work-in-progress nếu có thay đổi đáng kể
|
|
45
47
|
|
|
48
|
+
## Adoption Workflow (Existing Project)
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Lần đầu dùng dw trên project đang chạy:
|
|
52
|
+
/dw-onboard → .dw/context/project-map.md + module docs (breadth-first)
|
|
53
|
+
↓
|
|
54
|
+
Khi cần AI hiểu sâu module cụ thể:
|
|
55
|
+
/dw-retroactive [module] → .dw/tasks/[module]/ as-built docs (depth-first)
|
|
56
|
+
↓
|
|
57
|
+
Task mới liên quan module đã documented:
|
|
58
|
+
/dw-research [task] → AI đọc context có sẵn làm foundation
|
|
59
|
+
```
|
|
60
|
+
|
|
46
61
|
## Multi-Role Workflow
|
|
47
62
|
|
|
48
63
|
```
|
package/.claude/settings.json
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"hooks": [
|
|
53
53
|
{
|
|
54
54
|
"type": "prompt",
|
|
55
|
-
"prompt": "
|
|
55
|
+
"prompt": "Session context: $ARGUMENTS\n\nIf stop_hook_active is true in the context above, reply ONLY: {\"decision\":\"allow\"} to prevent infinite loops.\n\nOtherwise check: any uncommitted important changes? any in-progress task with outdated progress file? any unrecorded blockers?\n\nReply with ONLY valid JSON, no other text:\n- {\"decision\":\"block\",\"reason\":\"<describe what needs attention>\"} if action needed\n- {\"decision\":\"allow\"} if all clear"
|
|
56
56
|
}
|
|
57
57
|
]
|
|
58
58
|
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dw-onboard
|
|
3
|
+
description: "Onboard dw-kit vào project đang chạy. Scan codebase, tạo project map và context docs cho các modules hiện có. Chạy một lần khi adopt dw vào existing project."
|
|
4
|
+
argument-hint: ""
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Grep
|
|
8
|
+
- Glob
|
|
9
|
+
- Write
|
|
10
|
+
- "Bash(git log *)"
|
|
11
|
+
- "Bash(git shortlog *)"
|
|
12
|
+
- "Bash(ls *)"
|
|
13
|
+
- "Bash(wc *)"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# dw-onboard — Onboard Existing Project vào dw-kit
|
|
17
|
+
|
|
18
|
+
> Dùng khi adopt dw-kit vào project đã chạy. Chạy **một lần**. Output là project map và context docs cho các modules hiện có — làm nền tảng cho AI trong các sessions sau.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Đọc Config
|
|
23
|
+
|
|
24
|
+
Đọc `.dw/config/dw.config.yml`:
|
|
25
|
+
- `paths.tasks` → base tasks path
|
|
26
|
+
- `project.language` → ngôn ngữ output
|
|
27
|
+
- `project.name` → tên project
|
|
28
|
+
|
|
29
|
+
## Bước 1: Khám phá cấu trúc project
|
|
30
|
+
|
|
31
|
+
Scan top-level structure của codebase:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
Glob: src/**, app/**, lib/**, packages/**, services/**, modules/**
|
|
35
|
+
Bash: ls -la (top level)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Xác định:
|
|
39
|
+
- **Project type**: monorepo / single app / microservices / library
|
|
40
|
+
- **Tech stack**: ngôn ngữ, framework chính (từ package.json, go.mod, requirements.txt, Cargo.toml, v.v.)
|
|
41
|
+
- **Entry points**: main files, index files, routers
|
|
42
|
+
- **Major directories**: mỗi dir là 1 potential module
|
|
43
|
+
|
|
44
|
+
## Bước 2: Phân loại modules
|
|
45
|
+
|
|
46
|
+
Với mỗi major directory/module, xác định:
|
|
47
|
+
|
|
48
|
+
| Module | Type | Vai trò | Files | Phức tạp? |
|
|
49
|
+
|--------|------|---------|-------|-----------|
|
|
50
|
+
| [dir] | feature/service/util/infra | [mô tả 1 dòng] | [số files] | Cao/TB/Thấp |
|
|
51
|
+
|
|
52
|
+
**Phức tạp = Cao** nếu: nhiều files (>10), có DB/API, business logic phức tạp.
|
|
53
|
+
→ Modules phức tạp Cao: recommend `/dw-retroactive [module]` sau.
|
|
54
|
+
|
|
55
|
+
## Bước 3: Phân tích nhanh từng module
|
|
56
|
+
|
|
57
|
+
Với mỗi module (không cần đọc toàn bộ — chỉ đọc đủ để hiểu):
|
|
58
|
+
|
|
59
|
+
1. **Entry file**: đọc file chính (index, main, router, controller)
|
|
60
|
+
2. **Exports/Public API**: function/class/endpoint nào được expose?
|
|
61
|
+
3. **Dependencies**: module này gọi đến module nào khác?
|
|
62
|
+
4. **Git activity**: `git shortlog --since="6 months ago" -- [path]` → ai đang maintain?
|
|
63
|
+
|
|
64
|
+
Ghi tóm tắt ngắn gọn (3-5 dòng) per module.
|
|
65
|
+
|
|
66
|
+
## Bước 4: Check git history toàn project
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git log --oneline --since="3 months ago" | head -30
|
|
70
|
+
git shortlog -sn --since="3 months ago" | head -10
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Xác định:
|
|
74
|
+
- Modules nào đang active development
|
|
75
|
+
- Modules nào stable / ít thay đổi
|
|
76
|
+
- Contributors chính
|
|
77
|
+
|
|
78
|
+
## Bước 5: Tạo output
|
|
79
|
+
|
|
80
|
+
### 5a. Project Map
|
|
81
|
+
|
|
82
|
+
Tạo `.dw/context/project-map.md`:
|
|
83
|
+
|
|
84
|
+
```markdown
|
|
85
|
+
# Project Map: [project.name]
|
|
86
|
+
|
|
87
|
+
## Ngày tạo: [date]
|
|
88
|
+
## Tạo bởi: dw-onboard
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Tech Stack
|
|
93
|
+
|
|
94
|
+
- **Ngôn ngữ**: [language]
|
|
95
|
+
- **Framework**: [framework]
|
|
96
|
+
- **Database**: [db nếu có]
|
|
97
|
+
- **Infrastructure**: [docker, k8s, cloud nếu có]
|
|
98
|
+
|
|
99
|
+
## Cấu Trúc Tổng Quan
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
[ASCII tree của top-level structure]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Modules
|
|
106
|
+
|
|
107
|
+
| Module | Type | Vai trò | Phức tạp | Active? | Deep-dive? |
|
|
108
|
+
|--------|------|---------|----------|---------|------------|
|
|
109
|
+
| [name] | [type] | [mô tả ngắn] | Cao/TB/Thấp | Có/Không | `/dw-retroactive [name]` |
|
|
110
|
+
|
|
111
|
+
## Dependencies giữa Modules
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
[Module A] → [Module B] → [Module C]
|
|
115
|
+
↓
|
|
116
|
+
[Module D]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Entry Points chính
|
|
120
|
+
|
|
121
|
+
- [file/endpoint]: [mô tả]
|
|
122
|
+
|
|
123
|
+
## Conventions phát hiện
|
|
124
|
+
|
|
125
|
+
- [Convention 1]: [mô tả]
|
|
126
|
+
- [Convention 2]
|
|
127
|
+
|
|
128
|
+
## Git Activity (3 tháng gần nhất)
|
|
129
|
+
|
|
130
|
+
- **Active modules**: [danh sách]
|
|
131
|
+
- **Stable modules**: [danh sách]
|
|
132
|
+
- **Top contributors**: [tên]
|
|
133
|
+
|
|
134
|
+
## Gợi ý Deep-dive
|
|
135
|
+
|
|
136
|
+
Các modules phức tạp nên chạy `/dw-retroactive` để AI có context đầy đủ:
|
|
137
|
+
- [ ] `/dw-retroactive [module-a]` — [lý do: nhiều files, core business logic]
|
|
138
|
+
- [ ] `/dw-retroactive [module-b]`
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 5b. Module context docs
|
|
142
|
+
|
|
143
|
+
Với mỗi module **phức tạp Cao**: tạo `.dw/context/modules/[module-name].md`:
|
|
144
|
+
|
|
145
|
+
```markdown
|
|
146
|
+
# Module: [module-name]
|
|
147
|
+
|
|
148
|
+
## Vai trò
|
|
149
|
+
[1-2 câu mô tả]
|
|
150
|
+
|
|
151
|
+
## Files chính
|
|
152
|
+
| File | Vai trò |
|
|
153
|
+
|------|---------|
|
|
154
|
+
| [file] | [vai trò] |
|
|
155
|
+
|
|
156
|
+
## Public API / Exports
|
|
157
|
+
- [function/endpoint]: [mô tả]
|
|
158
|
+
|
|
159
|
+
## Dependencies
|
|
160
|
+
- Upstream: [modules gọi đến đây]
|
|
161
|
+
- Downstream: [modules được đây gọi]
|
|
162
|
+
|
|
163
|
+
## Conventions riêng
|
|
164
|
+
- [Convention đặc thù của module này]
|
|
165
|
+
|
|
166
|
+
## Lưu ý cho AI
|
|
167
|
+
- [Gotchas, tech debt, context quan trọng]
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Với modules **phức tạp TB/Thấp**: chỉ ghi entry trong project-map.md, không tạo file riêng.
|
|
171
|
+
|
|
172
|
+
## Bước 6: Báo cáo kết quả
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
╔══════════════════════════════════════════════════════╗
|
|
176
|
+
║ ✅ dw-onboard complete: [project.name]
|
|
177
|
+
╠══════════════════════════════════════════════════════╣
|
|
178
|
+
║ Modules discovered : [N]
|
|
179
|
+
║ Docs tạo :
|
|
180
|
+
║ .dw/context/project-map.md
|
|
181
|
+
║ .dw/context/modules/[X files]
|
|
182
|
+
║ Tech stack : [summary]
|
|
183
|
+
╠══════════════════════════════════════════════════════╣
|
|
184
|
+
║ Gợi ý tiếp theo:
|
|
185
|
+
║ Modules phức tạp cần deep-dive:
|
|
186
|
+
║ → /dw-retroactive [module-a]
|
|
187
|
+
║ → /dw-retroactive [module-b]
|
|
188
|
+
║
|
|
189
|
+
║ Khi bắt đầu task mới liên quan module đã có:
|
|
190
|
+
║ → AI sẽ tự đọc .dw/context/ để có context
|
|
191
|
+
╚══════════════════════════════════════════════════════╝
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Lưu ý
|
|
197
|
+
|
|
198
|
+
- **Không tạo `.dw/tasks/`** — onboard output vào `.dw/context/`, tách khỏi task docs
|
|
199
|
+
- **Không đọc toàn bộ code** — chỉ cần đủ để hiểu vai trò và interface của module
|
|
200
|
+
- **Không analyze chi tiết logic** — đó là việc của `/dw-retroactive` khi cần deep-dive
|
|
201
|
+
- Nếu project đã có `.dw/context/project-map.md` → hỏi user: "Đã có project map. Update hay skip?"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dw-prompt
|
|
3
|
+
description: "Improve a vague task description into a clear, actionable prompt. Uses git log + recent dw tasks for project context. Output is concise — human dev will refine further."
|
|
4
|
+
argument-hint: "[task description] [--vi]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Prompt Builder
|
|
8
|
+
|
|
9
|
+
Input: **$ARGUMENTS**
|
|
10
|
+
|
|
11
|
+
## Bước 0 — Parse options
|
|
12
|
+
|
|
13
|
+
- Nếu `$ARGUMENTS` chứa `--vi`: output bằng **tiếng Việt**, bỏ flag `--vi` ra khỏi description
|
|
14
|
+
- Mặc định: output bằng **tiếng Anh**
|
|
15
|
+
|
|
16
|
+
## Bước 1 — Lấy context từ git log
|
|
17
|
+
|
|
18
|
+
Extract 1–2 keywords chính từ description (bỏ qua stop words: fix, add, feat, the, a, in, of).
|
|
19
|
+
|
|
20
|
+
Chạy **cả hai** để có context tốt nhất:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Tìm commits liên quan theo keyword
|
|
24
|
+
git log --oneline --no-merges --all --grep="<keyword1>" -15
|
|
25
|
+
git log --oneline --no-merges --all --grep="<keyword2>" -15
|
|
26
|
+
|
|
27
|
+
# Fallback: 30 commits gần nhất
|
|
28
|
+
git log --oneline --no-merges -30
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Dùng kết quả để nhận ra: module names, naming conventions, commit style của project.
|
|
32
|
+
|
|
33
|
+
## Bước 2 — Lấy context từ dw tasks gần đây
|
|
34
|
+
|
|
35
|
+
Đọc danh sách task đang/đã làm:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
ls .dw/tasks/
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Nếu có task liên quan đến keyword → đọc file `*-progress.md` để hiểu thêm context (scope, decisions, findings).
|
|
42
|
+
|
|
43
|
+
## Bước 3 — Improve prompt
|
|
44
|
+
|
|
45
|
+
**Nếu $ARGUMENTS rỗng (sau khi bỏ flags):** hỏi ngắn "Describe your task:" trước.
|
|
46
|
+
|
|
47
|
+
**Rules:**
|
|
48
|
+
- **1–2 dòng tối đa** — human dev sẽ tự sửa thêm
|
|
49
|
+
- Giữ: **what** + **scope** (nếu rõ từ context) + **outcome** (nếu rõ)
|
|
50
|
+
- Active voice, present tense: "Fix...", "Add...", "Refactor..."
|
|
51
|
+
- Không bullet points, không markdown headers trong output
|
|
52
|
+
- Match naming conventions từ git log nếu nhận ra được
|
|
53
|
+
|
|
54
|
+
## Output format
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
─── Improved prompt ──────────────────────
|
|
58
|
+
<1–2 line improved prompt>
|
|
59
|
+
──────────────────────────────────────────
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Không thêm gì khác ngoài block trên.
|