dw-kit 1.0.0 → 1.0.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.
@@ -22,9 +22,7 @@ except:
22
22
  [ -z "$FILE_PATH" ] && exit 0
23
23
 
24
24
  # ── Đọc lint command từ config ────────────────────────────────────────────────
25
- CONFIG_FILE="${CLAUDE_PROJECT_DIR:-$PWD}/config/dw.config.yml"
26
- # Fallback sang old config nếu chưa migrate
27
- [ ! -f "$CONFIG_FILE" ] && CONFIG_FILE="${CLAUDE_PROJECT_DIR:-$PWD}/config/dw.config.yml"
25
+ CONFIG_FILE="${CLAUDE_PROJECT_DIR:-$PWD}/.dw/config/dw.config.yml"
28
26
  [ ! -f "$CONFIG_FILE" ] && exit 0
29
27
 
30
28
  LINT_CMD=$(grep -m1 "lint_command:" "$CONFIG_FILE" 2>/dev/null \
@@ -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`
@@ -52,7 +52,7 @@
52
52
  "hooks": [
53
53
  {
54
54
  "type": "prompt",
55
- "prompt": "Trước khi kết thúc, kiểm tra: (1) uncommitted changes quan trọng không? (2) Task đang làm dở chưa cập nhật progress? (3) blocker nào chưa ghi lại? Nếu vấn đề, trả về {\"decision\": \"block\", \"reason\": \"[mô tả]\"}. Nếu OK, trả về {\"decision\": \"allow\"}."
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
  }
@@ -6,7 +6,8 @@
6
6
  "WebFetch(domain:docs.anthropic.com)",
7
7
  "Bash(grep -rL \"^name:\" .claude/skills/dw-*/SKILL.md)",
8
8
  "Bash(grep -c '\\\\$ARGUMENTS\\\\|context: fork\\\\|allowed-tools' .dw/adapters/generic/AGENT.md)",
9
- "Bash(grep [v1.0.0] CHANGELOG.md)"
9
+ "Bash(grep [v1.0.0] CHANGELOG.md)",
10
+ "Bash(node src/smoke-test.mjs)"
10
11
  ]
11
12
  }
12
13
  }
@@ -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.
@@ -6,52 +6,42 @@ argument-hint: ""
6
6
 
7
7
  # Upgrade dv-workflow-kit
8
8
 
9
- ## Điều Kiện Tiên Quyết
9
+ ## Điều Kiện tiên quyết
10
10
 
11
- Skill này yêu cầu toolkit được cài qua git submodule tại `.dw-module/`.
11
+ Toolkit được cài theo luồng chuẩn v1 trong project hiện tại (thường là `npm install -g dw-kit` + `dw init`).
12
+ Các tùy chỉnh của team được đặt tại:
13
+ - overrides: `.dw/adapters/claude-cli/overrides/`
14
+ - extensions (skills mới): `.dw/adapters/claude-cli/extensions/`
12
15
 
13
- ## Bước 1: Kiểm tra setup
16
+ ## Bước 1: Preview upgrade (khuyến nghị)
14
17
 
15
- Kiểm tra `.dw-module/` có tồn tại và là git repo:
16
18
  ```bash
17
- ls .dw-module/.git
19
+ dw upgrade --check
20
+ dw upgrade --dry-run
18
21
  ```
19
22
 
20
- Nếu không có → thông báo: "Toolkit chưa được cài dạng git submodule. Xem `examples/integration-guide/README.md`."
21
-
22
- ## Bước 2: Pull version mới nhất
23
+ ## Bước 2: Backup config (tùy chọn nhưng nên làm)
23
24
 
24
- ```bash
25
- cd .dv-workflow && git fetch origin && git log origin/main --oneline -5
26
- ```
27
-
28
- Hiển thị 5 commits mới nhất của upstream để user biết có gì thay đổi.
29
-
30
- ## Bước 3: Backup config
31
-
32
- Trước khi update, backup config hiện tại:
33
25
  ```bash
34
26
  cp .dw/config/dw.config.yml .dw/config/dw.config.yml.backup-$(date +%Y%m%d)
35
27
  ```
36
28
 
37
- Thông báo: "Config đã backup tại `.dw/config/dw.config.yml.backup-[date]`"
38
-
39
- ## Bước 4: Update submodule
29
+ ## Bước 3: Chạy upgrade
40
30
 
41
31
  ```bash
42
- cd .dv-workflow && git pull origin main
32
+ dw upgrade
43
33
  ```
44
34
 
45
- ## Bước 5: So sánhupdate files
35
+ `dw upgrade` sẽ update toolkit files theo version mới **tôn trọng overrides** của team (không ghi đè override).
36
+
37
+ ## Bước 4: Validate & health check
46
38
 
47
- Chạy setup script với mode update (không overwrite):
48
39
  ```bash
49
- bash .dw-module/examples/integration-guide/setup.sh
40
+ dw validate
41
+ dw doctor
50
42
  ```
51
43
 
52
- Script dùng `cp -n` (no-clobber) chỉ copy files MỚI, không overwrite files đã customize.
53
-
54
- ## Bước 6: Báo cáo kết quả
44
+ ## Bước 5: Báo cáo kết quả
55
45
 
56
46
  ```
57
47
  === Upgrade Report ===
@@ -64,7 +54,7 @@ Files mới (đã copy):
64
54
  + .claude/templates/en/task-context.md
65
55
 
66
56
  Files đã thay đổi trong toolkit (KHÔNG tự động update vì bạn có thể đã customize):
67
- ~ .claude/skills/dw-task-init/SKILL.md — xem diff: git diff .dw-module/.claude/skills/dw-task-init/SKILL.md
57
+ ~ .claude/skills/dw-task-init/SKILL.md — xem diff: git diff .claude/skills/dw-task-init/SKILL.md
68
58
  ~ .claude/agents/planner.md
69
59
 
70
60
  Files của bạn (giữ nguyên):
@@ -72,11 +62,11 @@ Files của bạn (giữ nguyên):
72
62
 
73
63
  Lưu ý:
74
64
  - Review các files "đã thay đổi" và merge thủ công nếu cần
75
- - Xem CHANGELOG tại .dw-module/CHANGELOG.md để biết breaking changes
65
+ - Xem CHANGELOG của release (nếu cần) để biết breaking changes
76
66
  - Chạy /dw-config-validate sau khi upgrade để kiểm tra config
77
67
  ```
78
68
 
79
- ## Bước 7: Cleanup backup (tùy chọn)
69
+ ## Cleanup backup (tùy chọn)
80
70
 
81
71
  Hỏi user: "Bạn có muốn xóa file backup config không? (y/n)"
82
72
  Nếu y: `rm .dw/config/dw.config.yml.backup-*`
@@ -1,4 +1,4 @@
1
- # .dw/adapters/claude-cli/extensions/
1
+ # .dw/adapters/claude-cli/extensions/
2
2
 
3
3
  > **NET-NEW TEAM SKILLS — Không conflict với generated, không bị overwrite.**
4
4
 
@@ -15,7 +15,7 @@ extensions/
15
15
  └── README.md ← optional: mô tả skill
16
16
  ```
17
17
 
18
- `setup.sh` copy tất cả skills trong thư mục này vào `.claude/skills/`.
18
+ `dw upgrade` copy tất cả skills trong thư mục này vào `.claude/skills/` (extensions không ghi đè skills đã customize).
19
19
 
20
20
  ## Ví dụ Skills Phù Hợp
21
21
 
@@ -1,7 +1,7 @@
1
- # .dw/adapters/claude-cli/generated/
1
+ # .dw/adapters/claude-cli/generated/
2
2
 
3
3
  > **AUTO-GENERATED — Không edit tay.**
4
- > Thư mục này được overwrite khi chạy `scripts/upgrade.sh` hoặc `setup.sh`.
4
+ > Thư mục này được overwrite khi nâng cấp toolkit trong quá trình build/generation nội bộ.
5
5
 
6
6
  ## Nội dung
7
7
 
@@ -16,7 +16,7 @@ generated/
16
16
 
17
17
  ## Cách hoạt động
18
18
 
19
- `setup.sh` copy `generated/` → `.claude/`, với overrides từ `overrides/` thắng.
19
+ `dw init`/`dw upgrade` → populate `.claude/`, áp dụng overrides từ `overrides/` (override thắng).
20
20
 
21
21
  ## Nếu muốn customize
22
22
 
@@ -1,4 +1,4 @@
1
- # .dw/adapters/claude-cli/overrides/
1
+ # .dw/adapters/claude-cli/overrides/
2
2
 
3
3
  > **TEAM CUSTOMIZATIONS — KHÔNG BAO GIỜ bị overwrite khi upgrade.**
4
4
 
@@ -19,11 +19,13 @@ overrides/
19
19
  └── reviewer.md ← override generated/agents/reviewer.md
20
20
  ```
21
21
 
22
- Khi upgrade, `scripts/upgrade.sh` sẽ:
22
+ Khi chạy `dw upgrade`, luồng sẽ:
23
23
  1. Update `generated/` từ toolkit mới
24
24
  2. Apply overrides từ thư mục này (overrides thắng generated)
25
25
  3. Copy kết quả vào `.claude/`
26
26
 
27
+ Trong v1, luồng chuẩn là `dw upgrade`: nó tôn trọng overrides khi cập nhật `.claude/`.
28
+
27
29
  ## Khi nào nên override?
28
30
 
29
31
  - Team có domain-specific review rules
package/CLAUDE.md CHANGED
@@ -42,6 +42,7 @@ Không chắc scope → dùng `standard`. Assess dựa trên facts (file count,
42
42
 
43
43
  | Skill | Mô tả | Depth |
44
44
  |-------|--------|-------|
45
+ | `/dw-prompt [desc]` | Build structured prompt (autocomplete + wizard) | all |
45
46
  | `/dw-task-init [name]` | Khởi tạo task docs | all |
46
47
  | `/dw-research [name]` | Khảo sát codebase | all |
47
48
  | `/dw-plan [name]` | Lập kế hoạch (DỪNG chờ approve) | standard+ |