dw-kit 1.2.1 → 1.3.4
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/hooks/post-write.sh +64 -58
- package/.claude/hooks/pre-commit-gate.sh +96 -90
- package/.claude/hooks/privacy-block.sh +99 -94
- package/.claude/hooks/progress-ping.sh +53 -47
- package/.claude/hooks/safety-guard.sh +60 -54
- package/.claude/hooks/scout-block.sh +88 -82
- package/.claude/hooks/session-init.sh +6 -0
- package/.claude/hooks/stop-check.sh +88 -36
- package/.claude/hooks/telemetry-log.sh +34 -0
- package/.claude/rules/dw.md +138 -0
- package/.claude/settings.json +28 -1
- package/.claude/skills/dw-arch-review/SKILL.md +119 -119
- package/.claude/skills/dw-archive/SKILL.md +81 -81
- package/.claude/skills/dw-commit/SKILL.md +81 -81
- package/.claude/skills/dw-config-init/SKILL.md +91 -91
- package/.claude/skills/dw-config-validate/SKILL.md +75 -75
- package/.claude/skills/dw-dashboard/SKILL.md +209 -209
- package/.claude/skills/dw-debug/SKILL.md +97 -97
- package/.claude/skills/dw-decision/SKILL.md +116 -0
- package/.claude/skills/dw-docs-update/SKILL.md +125 -125
- package/.claude/skills/dw-estimate/SKILL.md +90 -90
- package/.claude/skills/dw-execute/SKILL.md +121 -98
- package/.claude/skills/dw-flow/SKILL.md +274 -274
- package/.claude/skills/dw-handoff/SKILL.md +92 -81
- package/.claude/skills/dw-kit-report/SKILL.md +152 -152
- package/.claude/skills/dw-log-work/SKILL.md +69 -69
- package/.claude/skills/dw-onboard/SKILL.md +201 -201
- package/.claude/skills/dw-plan/SKILL.md +222 -125
- package/.claude/skills/dw-prompt/SKILL.md +62 -62
- package/.claude/skills/dw-requirements/SKILL.md +98 -98
- package/.claude/skills/dw-research/SKILL.md +128 -114
- package/.claude/skills/dw-retroactive/SKILL.md +195 -311
- package/.claude/skills/dw-review/SKILL.md +66 -66
- package/.claude/skills/dw-rollback/SKILL.md +90 -90
- package/.claude/skills/dw-sprint-review/SKILL.md +99 -99
- package/.claude/skills/dw-task-init/SKILL.md +71 -59
- package/.claude/skills/dw-test-plan/SKILL.md +113 -113
- package/.claude/skills/dw-thinking/SKILL.md +70 -70
- package/.claude/skills/dw-upgrade/SKILL.md +72 -72
- package/.dw/core/PILLARS.md +122 -0
- package/.dw/core/ROLES.md +257 -257
- package/.dw/core/templates/v2/spec.md +68 -0
- package/.dw/core/templates/v2/tracking.md +62 -0
- package/.dw/core/v14-evaluation-protocol.md +118 -0
- package/CLAUDE.md +42 -39
- package/MIGRATION-v1.3.md +202 -0
- package/README.md +35 -6
- package/package.json +4 -2
- package/src/cli.mjs +29 -1
- package/src/commands/dashboard.mjs +116 -0
- package/src/commands/doctor.mjs +165 -149
- package/src/commands/init.mjs +339 -332
- package/src/commands/metrics.mjs +185 -0
- package/src/lib/active-index.mjs +87 -0
- package/src/lib/cut-analysis.mjs +240 -0
- package/src/lib/telemetry.mjs +80 -0
- package/.claude/rules/dw-core.md +0 -100
- package/.claude/rules/dw-skills.md +0 -53
- package/.claude/rules/workflow-rules.md +0 -77
|
@@ -1,125 +1,222 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dw
|
|
3
|
-
description: "Lập kế hoạch implementation chi tiết sau khi đã research. Thiết kế giải pháp, phân chia subtasks, xác định rủi ro. DỪNG để chờ approval trước khi execute."
|
|
4
|
-
argument-hint: "[task-name]"
|
|
5
|
-
allowed-tools:
|
|
6
|
-
- Read
|
|
7
|
-
- Grep
|
|
8
|
-
- Glob
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- `
|
|
20
|
-
- `tracking.
|
|
21
|
-
- `
|
|
22
|
-
- `
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- KHÔNG
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
##
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
---
|
|
2
|
+
name: dw:plan
|
|
3
|
+
description: "Lập kế hoạch implementation chi tiết sau khi đã research. Thiết kế giải pháp, phân chia subtasks, xác định rủi ro. Tích hợp Quick Debate (red/blue team) tùy depth. DỪNG để chờ approval trước khi execute."
|
|
4
|
+
argument-hint: "[task-name] [--debate | --no-debate]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Grep
|
|
8
|
+
- Glob
|
|
9
|
+
- Agent
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Lập Kế Hoạch Implementation
|
|
13
|
+
|
|
14
|
+
Task: **$ARGUMENTS**
|
|
15
|
+
|
|
16
|
+
## Đọc Config
|
|
17
|
+
|
|
18
|
+
Đọc `.dw/config/dw.config.yml` → lấy:
|
|
19
|
+
- `paths.tasks` → location task docs
|
|
20
|
+
- `tracking.estimation` → có include estimation trong plan không
|
|
21
|
+
- `tracking.estimation_unit` → đơn vị (hours / story-points / t-shirt)
|
|
22
|
+
- `team.roles` → ai cần approve (có `techlead` → plan cần TL review)
|
|
23
|
+
- `workflow.default_depth` → `thorough` = cần arch-review trước execute
|
|
24
|
+
|
|
25
|
+
## QUAN TRỌNG
|
|
26
|
+
- KHÔNG implement bất cứ gì
|
|
27
|
+
- KHÔNG sửa code
|
|
28
|
+
- CHỈ đọc, phân tích, và viết plan
|
|
29
|
+
- DỪNG LẠI cuối cùng để chờ user/TL approve
|
|
30
|
+
|
|
31
|
+
## Detect Task Format (v1 vs v2)
|
|
32
|
+
|
|
33
|
+
Kiểm tra `{paths.tasks}/$ARGUMENTS/`:
|
|
34
|
+
- **v2**: có `spec.md` + `tracking.md` → plan output update trực tiếp vào `spec.md` (sections Scope/Subtasks/Risks/Success Criteria).
|
|
35
|
+
- **v1** (legacy): có `-context.md`/`-plan.md`/`-progress.md` → plan output ghi vào `$ARGUMENTS-plan.md`.
|
|
36
|
+
- Chưa có gì → gợi ý `/dw:task-init $ARGUMENTS` trước.
|
|
37
|
+
|
|
38
|
+
## Bước 1: Đọc Context
|
|
39
|
+
|
|
40
|
+
- **v2**: Đọc `{paths.tasks}/$ARGUMENTS/spec.md` (bao gồm section `## Research Findings` nếu đã chạy `/dw:research`).
|
|
41
|
+
- **v1**: Đọc `{paths.tasks}/$ARGUMENTS/$ARGUMENTS-context.md` — file research đã tạo.
|
|
42
|
+
- Nếu chưa có research findings → thông báo: "Cần chạy `/dw:research $ARGUMENTS` trước."
|
|
43
|
+
|
|
44
|
+
## Bước 2: Thiết kế giải pháp
|
|
45
|
+
|
|
46
|
+
### Xem xét phương án
|
|
47
|
+
- Liệt kê ÍT NHẤT 2 phương án khả thi
|
|
48
|
+
- So sánh trade-offs: complexity, performance, maintainability, timeline
|
|
49
|
+
- Chọn phương án tối ưu và giải thích lý do
|
|
50
|
+
|
|
51
|
+
### Áp dụng THINKING.md
|
|
52
|
+
1. **Critical Thinking**: Giả định nào? Rủi ro gì? Edge cases?
|
|
53
|
+
2. **Systems Thinking**: Tác động lên modules khác? Data flow thay đổi?
|
|
54
|
+
3. **Multiple Perspectives**: User? Developer? Security? Ops?
|
|
55
|
+
|
|
56
|
+
## Bước 3: Phân chia subtasks
|
|
57
|
+
|
|
58
|
+
Mỗi subtask PHẢI có:
|
|
59
|
+
- **Mô tả**: Cụ thể, actionable
|
|
60
|
+
- **Files**: Danh sách files cần thay đổi
|
|
61
|
+
- **Acceptance criteria**: Điều kiện hoàn thành rõ ràng
|
|
62
|
+
- **Dependencies**: Subtask nào phải xong trước
|
|
63
|
+
- **Estimate** (nếu `tracking.estimation = true`): Effort dự kiến theo `tracking.estimation_unit`
|
|
64
|
+
|
|
65
|
+
Thứ tự subtasks theo dependency graph:
|
|
66
|
+
1. Schema/data changes trước
|
|
67
|
+
2. Service/business logic tiếp
|
|
68
|
+
3. API/routes sau
|
|
69
|
+
4. Tests song song hoặc trước (TDD)
|
|
70
|
+
5. Docs cuối
|
|
71
|
+
|
|
72
|
+
## Bước 4: Viết plan
|
|
73
|
+
|
|
74
|
+
**v2**: Update `spec.md` trực tiếp — điền vào các section có sẵn:
|
|
75
|
+
- `## Scope → In Scope`: thêm ST-1, ST-2, ... với mô tả + acceptance + effort
|
|
76
|
+
- `## Scope → Out of Scope`: các điểm loại trừ rõ ràng
|
|
77
|
+
- `## Risks & Mitigations`: bảng risks
|
|
78
|
+
- `## Success Criteria`: tiêu chí measurable
|
|
79
|
+
- `## Dependencies`: blockers upstream / external
|
|
80
|
+
Frontmatter: đổi `status: Draft` → `status: Approved` chỉ SAU khi user approve.
|
|
81
|
+
|
|
82
|
+
**v1**: Ghi vào `{paths.tasks}/$ARGUMENTS/$ARGUMENTS-plan.md` theo template:
|
|
83
|
+
|
|
84
|
+
```markdown
|
|
85
|
+
# Plan: [Task Name]
|
|
86
|
+
|
|
87
|
+
## Ngày tạo: [date]
|
|
88
|
+
## Trạng thái: Draft → cần approve
|
|
89
|
+
|
|
90
|
+
## Tóm Tắt Giải Pháp
|
|
91
|
+
[1-2 đoạn mô tả approach đã chọn]
|
|
92
|
+
|
|
93
|
+
## Phương Án Đã Xem Xét
|
|
94
|
+
| # | Phương án | Ưu điểm | Nhược điểm | Chọn? |
|
|
95
|
+
|---|-----------|---------|------------|-------|
|
|
96
|
+
|
|
97
|
+
## Subtasks
|
|
98
|
+
### ST-1: [Tên subtask]
|
|
99
|
+
- **Mô tả**: ...
|
|
100
|
+
- **Files**: ...
|
|
101
|
+
- **Criteria**: ...
|
|
102
|
+
- **Dependencies**: none
|
|
103
|
+
- **Estimate**: [nếu có]
|
|
104
|
+
|
|
105
|
+
### ST-2: [Tên subtask]
|
|
106
|
+
...
|
|
107
|
+
|
|
108
|
+
## Rủi Ro & Giả Định
|
|
109
|
+
| # | Loại | Mô tả | Xác suất | Tác động | Giảm thiểu |
|
|
110
|
+
|---|------|--------|----------|----------|------------|
|
|
111
|
+
|
|
112
|
+
## Edge Cases
|
|
113
|
+
- [ ] ...
|
|
114
|
+
|
|
115
|
+
## Tác Động Hệ Thống
|
|
116
|
+
- Modules ảnh hưởng: ...
|
|
117
|
+
- API changes: ...
|
|
118
|
+
- Migration: ...
|
|
119
|
+
- Backward compatibility: ...
|
|
120
|
+
|
|
121
|
+
## Góc Nhìn & Trade-offs
|
|
122
|
+
| Quyết định | User | Dev | Security |
|
|
123
|
+
|-----------|------|-----|----------|
|
|
124
|
+
|
|
125
|
+
## Estimation Tổng (nếu enabled)
|
|
126
|
+
- Research: [done]
|
|
127
|
+
- Planning: [done]
|
|
128
|
+
- Coding: [estimate]
|
|
129
|
+
- Testing: [estimate]
|
|
130
|
+
- Review: [estimate]
|
|
131
|
+
- Total: [sum]
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Bước 4.5: Quick Debate (depth-driven, pre-approval gate)
|
|
135
|
+
|
|
136
|
+
Trước khi trình bày cho user, chạy red/blue quick debate để tự phản biện plan. Tránh ceremony overhead:
|
|
137
|
+
|
|
138
|
+
### Khi nào chạy
|
|
139
|
+
|
|
140
|
+
| Depth | Behavior | Override |
|
|
141
|
+
|-------|----------|----------|
|
|
142
|
+
| `quick` | **SKIP** debate | `--debate` bật thủ công |
|
|
143
|
+
| `standard` | **SKIP** mặc định — CHẠY nếu detect signal high-stakes | `--debate` bật / `--no-debate` tắt |
|
|
144
|
+
| `thorough` | **DEFAULT ON** | `--no-debate` tắt |
|
|
145
|
+
|
|
146
|
+
**Auto-detect signal (standard depth)** — chạy nếu plan đụng:
|
|
147
|
+
- API contract changes (new endpoints, breaking signatures)
|
|
148
|
+
- Database schema migrations
|
|
149
|
+
- Auth / security / permissions
|
|
150
|
+
- Cross-module refactoring ≥3 modules
|
|
151
|
+
- Third-party integration mới
|
|
152
|
+
- Performance-critical path
|
|
153
|
+
|
|
154
|
+
Nếu nghi ngờ → chạy. Chi phí debate < chi phí rollback.
|
|
155
|
+
|
|
156
|
+
### Mode A — Lightweight (single-agent, 2-pass) — DEFAULT
|
|
157
|
+
|
|
158
|
+
Tự thực hiện 2 pass liên tiếp trong cùng session:
|
|
159
|
+
|
|
160
|
+
**Pass 1 — Red Team (attack)**: Đọc lại plan vừa viết, trả lời cụ thể:
|
|
161
|
+
1. Top 3 giả định đáng nghi nhất — cái nào chưa verify?
|
|
162
|
+
2. Top 3 failure modes — plan fail thế nào trong edge cases?
|
|
163
|
+
3. Subtask nào over-scoped (làm nhiều hơn cần) hoặc under-scoped (thiếu)?
|
|
164
|
+
4. Dependency nào bị missing / fragile?
|
|
165
|
+
|
|
166
|
+
**Pass 2 — Blue Team (strengthen)**: Respond từng red concern:
|
|
167
|
+
1. Concern đó valid? Nếu valid → đề xuất mitigation cụ thể.
|
|
168
|
+
2. Top 2 strengthenings để plan resilient hơn (thêm test, fallback, kiểm tra assumption).
|
|
169
|
+
|
|
170
|
+
### Mode B — Deep (parallel subagents) — opt-in `--debate-deep`
|
|
171
|
+
|
|
172
|
+
Chỉ khi stakes cực cao (breaking change, regulatory, production incident). Spawn 2 subagents parallel:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
Agent[red-bot]: critique plan như tấn công — tìm failure modes, hidden assumptions, timing issues
|
|
176
|
+
Agent[blue-bot]: defend + strengthen — propose concrete improvements
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Dùng `Agent` tool với `subagent_type: general-purpose` (hoặc `Plan` cho review sâu). Prompt phải self-contained (subagent không thấy conversation).
|
|
180
|
+
|
|
181
|
+
### Output debate
|
|
182
|
+
|
|
183
|
+
**v2 format** — Append vào `tracking.md` section `## Agent Debate Log`:
|
|
184
|
+
|
|
185
|
+
```markdown
|
|
186
|
+
### {date} — Plan debate
|
|
187
|
+
|
|
188
|
+
**Mode:** lightweight / deep
|
|
189
|
+
**Red-bot findings:**
|
|
190
|
+
- [Concern 1] — severity: H/M/L
|
|
191
|
+
- [Concern 2] — ...
|
|
192
|
+
- [Concern 3] — ...
|
|
193
|
+
|
|
194
|
+
**Blue-bot response:**
|
|
195
|
+
- [Mitigation or counter-argument]
|
|
196
|
+
- [Strengthening proposal]
|
|
197
|
+
|
|
198
|
+
**Incorporated into plan:**
|
|
199
|
+
- [Specific change made to spec.md — e.g., "Added ST-X: validate schema migration on staging before prod"]
|
|
200
|
+
|
|
201
|
+
**Deferred (noted but not blocking):**
|
|
202
|
+
- [Lower-priority items for post-execute review]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**v1 format** — Append "## Debate Log" vào `$ARGUMENTS-plan.md` với cùng cấu trúc.
|
|
206
|
+
|
|
207
|
+
### Nguyên tắc
|
|
208
|
+
|
|
209
|
+
- **Không ceremony**: nếu debate không catch gì mới sau 2 pass → ghi "No new concerns" rồi tiếp tục. Đừng tạo finding giả để fill template.
|
|
210
|
+
- **Incorporate hoặc defer rõ ràng**: mỗi red concern phải có quyết định (fix now / defer / won't fix + reason).
|
|
211
|
+
- **Thời gian cap**: Mode A ≤3 phút agent time. Mode B ≤10 phút.
|
|
212
|
+
|
|
213
|
+
## Bước 5: DỪNG & Trình bày
|
|
214
|
+
|
|
215
|
+
Trình bày plan cho user với:
|
|
216
|
+
1. Tóm tắt approach (3-5 câu)
|
|
217
|
+
2. Số subtasks và estimate tổng (nếu có)
|
|
218
|
+
3. Top 2 risks
|
|
219
|
+
4. **Nếu chạy debate**: Top 2 debate findings + incorporated changes (1-2 dòng)
|
|
220
|
+
5. Yêu cầu: "Approve plan này để tiếp tục `/dw:execute $ARGUMENTS`"
|
|
221
|
+
|
|
222
|
+
Nếu team có TL: "Plan cần TL review trước khi execute."
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dw
|
|
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.
|
|
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.
|