dw-kit 1.0.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/agents/executor.md +80 -0
- package/.claude/agents/planner.md +100 -0
- package/.claude/agents/quality-checker.md +86 -0
- package/.claude/agents/researcher.md +93 -0
- package/.claude/agents/reviewer.md +126 -0
- package/.claude/hooks/post-write.sh +62 -0
- package/.claude/hooks/pre-commit-gate.sh +90 -0
- package/.claude/hooks/progress-ping.sh +47 -0
- package/.claude/hooks/safety-guard.sh +54 -0
- package/.claude/rules/code-style.md +37 -0
- package/.claude/rules/commit-standards.md +37 -0
- package/.claude/rules/workflow-rules.md +62 -0
- package/.claude/settings.json +71 -0
- package/.claude/settings.local.json +12 -0
- package/.claude/skills/dw-arch-review/SKILL.md +119 -0
- package/.claude/skills/dw-archive/SKILL.md +81 -0
- package/.claude/skills/dw-commit/SKILL.md +81 -0
- package/.claude/skills/dw-config-init/SKILL.md +91 -0
- package/.claude/skills/dw-config-validate/SKILL.md +75 -0
- package/.claude/skills/dw-dashboard/SKILL.md +209 -0
- package/.claude/skills/dw-debug/SKILL.md +97 -0
- package/.claude/skills/dw-docs-update/SKILL.md +125 -0
- package/.claude/skills/dw-estimate/SKILL.md +90 -0
- package/.claude/skills/dw-execute/SKILL.md +98 -0
- package/.claude/skills/dw-flow/SKILL.md +274 -0
- package/.claude/skills/dw-handoff/SKILL.md +81 -0
- package/.claude/skills/dw-log-work/SKILL.md +69 -0
- package/.claude/skills/dw-plan/SKILL.md +125 -0
- package/.claude/skills/dw-plan/template-plan.md +47 -0
- package/.claude/skills/dw-requirements/SKILL.md +98 -0
- package/.claude/skills/dw-research/SKILL.md +98 -0
- package/.claude/skills/dw-research/template-research.md +51 -0
- package/.claude/skills/dw-review/SKILL.md +66 -0
- package/.claude/skills/dw-review/checklist.md +88 -0
- package/.claude/skills/dw-rollback/SKILL.md +90 -0
- package/.claude/skills/dw-sprint-review/SKILL.md +99 -0
- package/.claude/skills/dw-task-init/SKILL.md +59 -0
- package/.claude/skills/dw-test-plan/SKILL.md +113 -0
- package/.claude/skills/dw-thinking/SKILL.md +70 -0
- package/.claude/skills/dw-thinking/THINKING.md +91 -0
- package/.claude/skills/dw-upgrade/SKILL.md +82 -0
- package/.claude/templates/en/task-context.md +73 -0
- package/.claude/templates/en/task-plan.md +79 -0
- package/.claude/templates/en/task-progress.md +65 -0
- package/.claude/templates/pr-template.md +56 -0
- package/.claude/templates/task-context.md +73 -0
- package/.claude/templates/task-plan.md +79 -0
- package/.claude/templates/task-progress.md +65 -0
- package/.dw/adapters/claude-cli/extensions/.gitkeep +0 -0
- package/.dw/adapters/claude-cli/extensions/README.md +36 -0
- package/.dw/adapters/claude-cli/generated/README.md +23 -0
- package/.dw/adapters/claude-cli/generated/agents/.gitkeep +0 -0
- package/.dw/adapters/claude-cli/generated/skills/.gitkeep +0 -0
- package/.dw/adapters/claude-cli/overrides/README.md +35 -0
- package/.dw/adapters/claude-cli/overrides/agents/.gitkeep +0 -0
- package/.dw/adapters/claude-cli/overrides/skills/.gitkeep +0 -0
- package/.dw/adapters/generic/AGENT.md +169 -0
- package/.dw/adapters/generic/README.md +21 -0
- package/.dw/config/config.schema.json +121 -0
- package/.dw/config/dw.config.yml +82 -0
- package/.dw/config/presets/enterprise.yml +52 -0
- package/.dw/config/presets/small-team.yml +39 -0
- package/.dw/config/presets/solo-quick.yml +37 -0
- package/.dw/core/QUALITY.md +220 -0
- package/.dw/core/ROLES.md +257 -0
- package/.dw/core/THINKING.md +126 -0
- package/.dw/core/WORKFLOW.md +450 -0
- package/.dw/core/templates/vi/task-context.md +92 -0
- package/.dw/core/templates/vi/task-plan.md +93 -0
- package/.dw/core/templates/vi/task-progress.md +56 -0
- package/CLAUDE.md +98 -0
- package/LICENSE +21 -0
- package/README.md +183 -0
- package/bin/dw.mjs +28 -0
- package/package.json +52 -0
- package/scripts/e2e-local-check.sh +76 -0
- package/scripts/migrate-v03-to-v1.sh +243 -0
- package/scripts/upgrade.sh +246 -0
- package/setup.sh +382 -0
- package/src/cli.mjs +68 -0
- package/src/commands/doctor.mjs +149 -0
- package/src/commands/init.mjs +332 -0
- package/src/commands/migrate.mjs +215 -0
- package/src/commands/upgrade.mjs +262 -0
- package/src/commands/validate.mjs +102 -0
- package/src/lib/config.mjs +75 -0
- package/src/lib/copy.mjs +110 -0
- package/src/lib/platform.mjs +39 -0
- package/src/lib/ui.mjs +66 -0
- package/src/smoke-test.mjs +315 -0
package/setup.sh
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# dw-kit — Interactive Setup Wizard (LEGACY)
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# ⚠ DEPRECATED: Use `dw init` instead (npm install -g dw-kit)
|
|
6
|
+
#
|
|
7
|
+
# npm install -g dw-kit
|
|
8
|
+
# dw init
|
|
9
|
+
#
|
|
10
|
+
# This script is kept for environments without Node.js.
|
|
11
|
+
# New features will only be added to the `dw` CLI.
|
|
12
|
+
# =============================================================================
|
|
13
|
+
# Chạy từ root của dự án của bạn. Hỏi 4 câu, tự cấu hình mọi thứ.
|
|
14
|
+
# Thời gian: ~1-2 phút
|
|
15
|
+
#
|
|
16
|
+
# Usage:
|
|
17
|
+
# bash .dw-module/setup.sh
|
|
18
|
+
#
|
|
19
|
+
# Silent mode (CI/scripted):
|
|
20
|
+
# DW_NAME="my-app" DW_LEVEL=2 DW_ROLES="dev,techlead" DW_LANG="vi" \
|
|
21
|
+
# bash .dw-module/setup.sh --silent
|
|
22
|
+
# =============================================================================
|
|
23
|
+
|
|
24
|
+
set -e
|
|
25
|
+
|
|
26
|
+
TOOLKIT_DIR=".dw-module"
|
|
27
|
+
SILENT="${1:-}"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
CYAN='\033[0;36m'
|
|
31
|
+
GREEN='\033[0;32m'
|
|
32
|
+
YELLOW='\033[1;33m'
|
|
33
|
+
BOLD='\033[1m'
|
|
34
|
+
NC='\033[0m'
|
|
35
|
+
|
|
36
|
+
# Kiểm tra submodule
|
|
37
|
+
if [ ! -d "$TOOLKIT_DIR/.claude" ]; then
|
|
38
|
+
echo "Toolkit chưa được add. Chạy trước:"
|
|
39
|
+
echo " git submodule add https://github.com/dv-workflow/dv-workflow.git .dw-module"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
clear
|
|
44
|
+
echo -e "${CYAN}${BOLD}"
|
|
45
|
+
echo " ██████╗ ██╗ ██╗ ██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██╗ ██████╗ ██╗ ██╗"
|
|
46
|
+
echo " ██╔══██╗██║ ██║ ██║ ██║██╔═══██╗██╔══██╗██║ ██╔╝██╔════╝██║ ██╔═══██╗██║ ██║"
|
|
47
|
+
echo " ██║ ██║██║ ██║ ██║ █╗ ██║██║ ██║██████╔╝█████╔╝ █████╗ ██║ ██║ ██║██║ █╗ ██║"
|
|
48
|
+
echo " ██║ ██║╚██╗ ██╔╝ ██║███╗██║██║ ██║██╔══██╗██╔═██╗ ██╔══╝ ██║ ██║ ██║██║███╗██║"
|
|
49
|
+
echo " ██████╔╝ ╚████╔╝ ╚███╔███╔╝╚██████╔╝██║ ██║██║ ██╗██║ ███████╗╚██████╔╝╚███╔███╔╝"
|
|
50
|
+
echo " ╚═════╝ ╚═══╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚══╝╚══╝"
|
|
51
|
+
echo -e "${NC}"
|
|
52
|
+
echo -e "${CYAN} Setup Wizard v0.3 — ~1 phút${NC}"
|
|
53
|
+
echo ""
|
|
54
|
+
|
|
55
|
+
# =============================================================================
|
|
56
|
+
# BƯỚC 1: Đọc từ env (silent mode) hoặc hỏi user (interactive mode)
|
|
57
|
+
# =============================================================================
|
|
58
|
+
|
|
59
|
+
if [ -n "$SILENT" ] && [ "$SILENT" = "--silent" ]; then
|
|
60
|
+
# Silent mode: đọc từ environment variables
|
|
61
|
+
PROJECT_NAME="${DW_NAME:-my-project}"
|
|
62
|
+
LEVEL="${DW_LEVEL:-2}"
|
|
63
|
+
ROLES_RAW="${DW_ROLES:-dev,techlead}"
|
|
64
|
+
LANG="${DW_LANG:-vi}"
|
|
65
|
+
else
|
|
66
|
+
# ---- Câu 1: Project name ----
|
|
67
|
+
echo -e "${BOLD}[Project] Tên project?${NC}"
|
|
68
|
+
read -r -p " > " PROJECT_NAME
|
|
69
|
+
PROJECT_NAME="${PROJECT_NAME:-my-project}"
|
|
70
|
+
echo ""
|
|
71
|
+
|
|
72
|
+
# ---- Câu 2: Level ----
|
|
73
|
+
echo -e "${BOLD}[Level] Chọn level workflow:${NC}"
|
|
74
|
+
echo " 1 = Lite — research → execute → commit (solo dev, hotfix nhanh)"
|
|
75
|
+
echo " 2 = Standard — research → plan → execute → review (team, feature mới) [default]"
|
|
76
|
+
echo " 3 = Enterprise — full workflow + living docs + metrics (team lớn, audit trail)"
|
|
77
|
+
read -r -p " Level [1/2/3, Enter = 2]: " LEVEL
|
|
78
|
+
LEVEL="${LEVEL:-2}"
|
|
79
|
+
echo ""
|
|
80
|
+
|
|
81
|
+
# ---- Câu 3: Roles ----
|
|
82
|
+
echo -e "${BOLD}[Role] Team có những roles nào? (Dev luôn được bật)${NC}"
|
|
83
|
+
echo " Nhập số cách nhau bởi dấu phẩy, hoặc Enter để chọn dev+techlead:"
|
|
84
|
+
echo " 1 = Dev (luôn bật)"
|
|
85
|
+
echo " 2 = Tech Lead — architecture review, approve plans"
|
|
86
|
+
echo " 3 = BA — requirements, user stories"
|
|
87
|
+
echo " 4 = QC — test plans, bug reports"
|
|
88
|
+
echo " 5 = PM — dashboard, metrics"
|
|
89
|
+
read -r -p " Roles [1,2,...]: " ROLES_INPUT
|
|
90
|
+
ROLES_INPUT="${ROLES_INPUT:-1,2}"
|
|
91
|
+
echo ""
|
|
92
|
+
|
|
93
|
+
# ---- Câu 4: Language ----
|
|
94
|
+
echo -e "${BOLD}[Lang] Ngôn ngữ docs output?${NC}"
|
|
95
|
+
echo " vi = Tiếng Việt [default]"
|
|
96
|
+
echo " en = English"
|
|
97
|
+
read -r -p " Language [vi/en]: " LANG
|
|
98
|
+
LANG="${LANG:-vi}"
|
|
99
|
+
echo ""
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
# =============================================================================
|
|
103
|
+
# BUILD roles list từ input
|
|
104
|
+
# =============================================================================
|
|
105
|
+
|
|
106
|
+
build_roles() {
|
|
107
|
+
local input="$1"
|
|
108
|
+
local roles=" - dev"
|
|
109
|
+
# Nếu input dạng "dev,techlead" (silent mode)
|
|
110
|
+
if echo "$input" | grep -q "[a-z]"; then
|
|
111
|
+
echo "$input" | tr ',' '\n' | while read -r r; do
|
|
112
|
+
r=$(echo "$r" | tr -d ' ')
|
|
113
|
+
[ "$r" != "dev" ] && echo " - $r"
|
|
114
|
+
done
|
|
115
|
+
return
|
|
116
|
+
fi
|
|
117
|
+
# Nếu input dạng "1,2,3" (interactive mode)
|
|
118
|
+
echo "$input" | tr ',' '\n' | while read -r n; do
|
|
119
|
+
n=$(echo "$n" | tr -d ' ')
|
|
120
|
+
case "$n" in
|
|
121
|
+
2) echo " - techlead" ;;
|
|
122
|
+
3) echo " - ba" ;;
|
|
123
|
+
4) echo " - qc" ;;
|
|
124
|
+
5) echo " - pm" ;;
|
|
125
|
+
esac
|
|
126
|
+
done
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
HAS_TL=false; HAS_BA=false; HAS_QC=false; HAS_PM=false
|
|
130
|
+
|
|
131
|
+
check_role() {
|
|
132
|
+
local input="$1"
|
|
133
|
+
if echo "$input" | grep -q "techlead\|,2\b\|^2\b"; then HAS_TL=true; fi
|
|
134
|
+
if echo "$input" | grep -q "ba\b\|,3\b\|^3\b"; then HAS_BA=true; fi
|
|
135
|
+
if echo "$input" | grep -q "qc\b\|,4\b\|^4\b"; then HAS_QC=true; fi
|
|
136
|
+
if echo "$input" | grep -q "pm\b\|,5\b\|^5\b"; then HAS_PM=true; fi
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
ROLES_RAW="${ROLES_RAW:-$ROLES_INPUT}"
|
|
140
|
+
check_role "$ROLES_RAW"
|
|
141
|
+
|
|
142
|
+
# =============================================================================
|
|
143
|
+
# APPLY: Copy files + Write config
|
|
144
|
+
# =============================================================================
|
|
145
|
+
|
|
146
|
+
echo -e "${CYAN}Đang setup...${NC}"
|
|
147
|
+
|
|
148
|
+
# Copy .claude/
|
|
149
|
+
if [ -d ".claude" ]; then
|
|
150
|
+
cp -rn "$TOOLKIT_DIR/.claude/skills" ".claude/" 2>/dev/null || true
|
|
151
|
+
cp -rn "$TOOLKIT_DIR/.claude/agents" ".claude/" 2>/dev/null || true
|
|
152
|
+
cp -rn "$TOOLKIT_DIR/.claude/rules" ".claude/" 2>/dev/null || true
|
|
153
|
+
cp -rn "$TOOLKIT_DIR/.claude/hooks" ".claude/" 2>/dev/null || true
|
|
154
|
+
cp -rn "$TOOLKIT_DIR/.claude/templates" ".claude/" 2>/dev/null || true
|
|
155
|
+
[ ! -f ".claude/settings.json" ] && cp "$TOOLKIT_DIR/.claude/settings.json" ".claude/"
|
|
156
|
+
else
|
|
157
|
+
cp -r "$TOOLKIT_DIR/.claude" "./"
|
|
158
|
+
fi
|
|
159
|
+
|
|
160
|
+
# Chọn base config theo level
|
|
161
|
+
if [ "$LEVEL" = "3" ]; then
|
|
162
|
+
BASE_CONFIG="$TOOLKIT_DIR/project-templates/enterprise/.dw/config/dw.config.yml"
|
|
163
|
+
elif [ "$LEVEL" = "1" ]; then
|
|
164
|
+
BASE_CONFIG="$TOOLKIT_DIR/project-templates/old-maintenance/.dw/config/dw.config.yml"
|
|
165
|
+
else
|
|
166
|
+
BASE_CONFIG="$TOOLKIT_DIR/project-templates/new-product/.dw/config/dw.config.yml"
|
|
167
|
+
fi
|
|
168
|
+
|
|
169
|
+
# Ghi config với giá trị user đã chọn
|
|
170
|
+
if [ ! -f ".dw/.dw/config/dw.config.yml" ]; then
|
|
171
|
+
ROLES_YAML=" roles:\n - dev"
|
|
172
|
+
$HAS_TL && ROLES_YAML="$ROLES_YAML\n - techlead"
|
|
173
|
+
$HAS_BA && ROLES_YAML="$ROLES_YAML\n - ba"
|
|
174
|
+
$HAS_QC && ROLES_YAML="$ROLES_YAML\n - qc"
|
|
175
|
+
$HAS_PM && ROLES_YAML="$ROLES_YAML\n - pm"
|
|
176
|
+
|
|
177
|
+
sed \
|
|
178
|
+
-e "s|name: \"your.*\"|name: \"$PROJECT_NAME\"|" \
|
|
179
|
+
-e "s|name: \"your-enterprise-project\"|name: \"$PROJECT_NAME\"|" \
|
|
180
|
+
-e "s|language: \"vi\"|language: \"$LANG\"|" \
|
|
181
|
+
"$BASE_CONFIG" > ".dw/.dw/config/dw.config.yml"
|
|
182
|
+
|
|
183
|
+
# Inject roles (replace toàn bộ roles section) — pure awk, no Python needed
|
|
184
|
+
ROLES_LINES=" - dev"
|
|
185
|
+
$HAS_TL && ROLES_LINES="${ROLES_LINES}| - techlead"
|
|
186
|
+
$HAS_BA && ROLES_LINES="${ROLES_LINES}| - ba"
|
|
187
|
+
$HAS_QC && ROLES_LINES="${ROLES_LINES}| - qc"
|
|
188
|
+
$HAS_PM && ROLES_LINES="${ROLES_LINES}| - pm"
|
|
189
|
+
|
|
190
|
+
awk -v roles="$ROLES_LINES" '
|
|
191
|
+
/^ roles:/ {
|
|
192
|
+
print " roles:"
|
|
193
|
+
n = split(roles, a, "|")
|
|
194
|
+
for (i = 1; i <= n; i++) print a[i]
|
|
195
|
+
in_roles = 1; next
|
|
196
|
+
}
|
|
197
|
+
in_roles && /^ -/ { next }
|
|
198
|
+
{ in_roles = 0; print }
|
|
199
|
+
' config/dw.config.yml > config/dw.config.yml.tmp \
|
|
200
|
+
&& mv config/dw.config.yml.tmp config/dw.config.yml
|
|
201
|
+
fi
|
|
202
|
+
|
|
203
|
+
# Tạo CLAUDE.md
|
|
204
|
+
if [ ! -f "CLAUDE.md" ]; then
|
|
205
|
+
cp "$TOOLKIT_DIR/CLAUDE.md" .
|
|
206
|
+
cat >> CLAUDE.md << 'SECTION'
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Tech Stack
|
|
211
|
+
|
|
212
|
+
<!-- Cập nhật phần này với stack thực tế của project -->
|
|
213
|
+
- Framework: [e.g. NestJS / Django / Laravel / Next.js]
|
|
214
|
+
- Database: [e.g. PostgreSQL / MySQL / MongoDB]
|
|
215
|
+
- Testing: [e.g. Jest / Pytest / PHPUnit]
|
|
216
|
+
|
|
217
|
+
## Project-Specific Rules
|
|
218
|
+
|
|
219
|
+
<!-- Thêm rules đặc thù của project -->
|
|
220
|
+
- [Rule 1]
|
|
221
|
+
SECTION
|
|
222
|
+
fi
|
|
223
|
+
|
|
224
|
+
# Tạo runtime directories (gom vào .dw/ để không pollute root)
|
|
225
|
+
mkdir -p .dw/tasks .dw/docs .dw/metrics .dw/reports
|
|
226
|
+
|
|
227
|
+
# =============================================================================
|
|
228
|
+
# V2: Generate config/dw.config.yml và settings.json từ MCP config
|
|
229
|
+
# =============================================================================
|
|
230
|
+
|
|
231
|
+
# Copy config mới nếu chưa có (v1 structure)
|
|
232
|
+
if [ ! -f ".dw/.dw/config/dw.config.yml" ] && [ -f "$TOOLKIT_DIR/.dw/config/dw.config.yml" ]; then
|
|
233
|
+
mkdir -p config/presets
|
|
234
|
+
cp "$TOOLKIT_DIR/.dw/config/dw.config.yml" ".dw/.dw/config/dw.config.yml"
|
|
235
|
+
cp "$TOOLKIT_DIR/config/config.schema.json" ".dw/config/config.schema.json" 2>/dev/null || true
|
|
236
|
+
cp "$TOOLKIT_DIR/config/presets/"* "config/presets/" 2>/dev/null || true
|
|
237
|
+
fi
|
|
238
|
+
|
|
239
|
+
# Generate settings.json từ claude.mcp config (nếu có python3 + có mcp config)
|
|
240
|
+
generate_mcp_settings() {
|
|
241
|
+
local config_file="${1:-config/dw.config.yml}"
|
|
242
|
+
[ ! -f "$config_file" ] && return 0
|
|
243
|
+
[ ! -f ".claude/settings.json" ] && return 0
|
|
244
|
+
command -v python3 &>/dev/null || return 0
|
|
245
|
+
|
|
246
|
+
python3 - "$config_file" ".claude/settings.json" <<'PYEOF' 2>/dev/null || true
|
|
247
|
+
import sys, json, re
|
|
248
|
+
|
|
249
|
+
config_path = sys.argv[1]
|
|
250
|
+
settings_path = sys.argv[2]
|
|
251
|
+
|
|
252
|
+
with open(config_path) as f:
|
|
253
|
+
content = f.read()
|
|
254
|
+
|
|
255
|
+
# Extract MCP servers từ YAML (simple parser — không cần PyYAML)
|
|
256
|
+
mcp_servers = {}
|
|
257
|
+
in_mcp = False
|
|
258
|
+
current_server = None
|
|
259
|
+
|
|
260
|
+
for line in content.split('\n'):
|
|
261
|
+
stripped = line.rstrip()
|
|
262
|
+
# Detect mcp: block
|
|
263
|
+
if re.match(r'\s*mcp:\s*$', stripped):
|
|
264
|
+
in_mcp = True
|
|
265
|
+
continue
|
|
266
|
+
if in_mcp:
|
|
267
|
+
# New top-level key = end of mcp block
|
|
268
|
+
if re.match(r'^[a-z_]', stripped) or re.match(r'^_toolkit', stripped):
|
|
269
|
+
in_mcp = False
|
|
270
|
+
continue
|
|
271
|
+
# Server entry: - name: "..."
|
|
272
|
+
m = re.match(r'\s*-\s*name:\s*["\']?([^"\']+)["\']?', stripped)
|
|
273
|
+
if m:
|
|
274
|
+
current_server = m.group(1).strip()
|
|
275
|
+
mcp_servers[current_server] = {}
|
|
276
|
+
continue
|
|
277
|
+
if current_server:
|
|
278
|
+
# command:
|
|
279
|
+
m = re.match(r'\s+command:\s*["\']?([^"\']+)["\']?', stripped)
|
|
280
|
+
if m:
|
|
281
|
+
mcp_servers[current_server]['command'] = m.group(1).strip()
|
|
282
|
+
# args: (array — simplified)
|
|
283
|
+
m = re.match(r'\s+args:\s*\[([^\]]*)\]', stripped)
|
|
284
|
+
if m:
|
|
285
|
+
args = [a.strip().strip('"').strip("'") for a in m.group(1).split(',') if a.strip()]
|
|
286
|
+
mcp_servers[current_server]['args'] = args
|
|
287
|
+
|
|
288
|
+
if not mcp_servers:
|
|
289
|
+
sys.exit(0)
|
|
290
|
+
|
|
291
|
+
# Update settings.json
|
|
292
|
+
with open(settings_path) as f:
|
|
293
|
+
settings = json.load(f)
|
|
294
|
+
|
|
295
|
+
settings['mcpServers'] = {}
|
|
296
|
+
for name, server in mcp_servers.items():
|
|
297
|
+
settings['mcpServers'][name] = {
|
|
298
|
+
'command': server.get('command', ''),
|
|
299
|
+
'args': server.get('args', [])
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
with open(settings_path, 'w') as f:
|
|
303
|
+
json.dump(settings, f, indent=2, ensure_ascii=False)
|
|
304
|
+
f.write('\n')
|
|
305
|
+
|
|
306
|
+
print(f" MCP servers configured: {', '.join(mcp_servers.keys())}")
|
|
307
|
+
PYEOF
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
generate_mcp_settings ".dw/.dw/config/dw.config.yml"
|
|
311
|
+
|
|
312
|
+
# Validate config nếu có python3 và jsonschema
|
|
313
|
+
if command -v python3 &>/dev/null && [ -f ".dw/.dw/config/dw.config.yml" ] && [ -f ".dw/config/config.schema.json" ]; then
|
|
314
|
+
python3 -c "import jsonschema" 2>/dev/null && \
|
|
315
|
+
python3 - ".dw/.dw/config/dw.config.yml" ".dw/config/config.schema.json" <<'PYEOF' 2>/dev/null || true
|
|
316
|
+
import sys, json
|
|
317
|
+
try:
|
|
318
|
+
import yaml
|
|
319
|
+
with open(sys.argv[1]) as f:
|
|
320
|
+
config = yaml.safe_load(f)
|
|
321
|
+
import jsonschema
|
|
322
|
+
with open(sys.argv[2]) as f:
|
|
323
|
+
schema = json.load(f)
|
|
324
|
+
jsonschema.validate(config, schema)
|
|
325
|
+
print(" config/dw.config.yml: valid")
|
|
326
|
+
except jsonschema.ValidationError as e:
|
|
327
|
+
print(f" ⚠ Config validation warning: {e.message}")
|
|
328
|
+
except Exception:
|
|
329
|
+
pass
|
|
330
|
+
PYEOF
|
|
331
|
+
fi
|
|
332
|
+
|
|
333
|
+
# Gitignore
|
|
334
|
+
if [ -f ".gitignore" ]; then
|
|
335
|
+
if ! grep -q ".dw/metrics" .gitignore; then
|
|
336
|
+
printf "\n# dw-kit\n.dw/metrics/\n.dw/reports/\nCLAUDE.local.md\n" >> .gitignore
|
|
337
|
+
fi
|
|
338
|
+
else
|
|
339
|
+
cp "$TOOLKIT_DIR/.gitignore" .
|
|
340
|
+
fi
|
|
341
|
+
|
|
342
|
+
# =============================================================================
|
|
343
|
+
# SUMMARY
|
|
344
|
+
# =============================================================================
|
|
345
|
+
|
|
346
|
+
clear
|
|
347
|
+
echo -e "${GREEN}${BOLD}"
|
|
348
|
+
echo " ✅ Setup hoàn tất!"
|
|
349
|
+
echo -e "${NC}"
|
|
350
|
+
echo " Project : $PROJECT_NAME"
|
|
351
|
+
echo " Level : $LEVEL $([ "$LEVEL" = "1" ] && echo "(Lite)" || ([ "$LEVEL" = "2" ] && echo "(Standard)" || echo "(Enterprise — Level 3 beta)"))"
|
|
352
|
+
echo " Language: $LANG"
|
|
353
|
+
printf " Roles : dev"
|
|
354
|
+
$HAS_TL && printf ", techlead"
|
|
355
|
+
$HAS_BA && printf ", ba"
|
|
356
|
+
$HAS_QC && printf ", qc"
|
|
357
|
+
$HAS_PM && printf ", pm"
|
|
358
|
+
echo ""
|
|
359
|
+
echo ""
|
|
360
|
+
echo " Files tạo:"
|
|
361
|
+
echo " .claude/ — 22 skills, agents, rules, hooks, templates"
|
|
362
|
+
echo " config/dw.config.yml"
|
|
363
|
+
echo " CLAUDE.md"
|
|
364
|
+
echo " .dw/tasks/ .dw/docs/ .dw/metrics/ .dw/reports/"
|
|
365
|
+
echo ""
|
|
366
|
+
echo -e "${CYAN} Skills đã bật:${NC}"
|
|
367
|
+
echo " /dw-task-init /dw-research /dw-execute /dw-commit /dw-debug /dw-handoff"
|
|
368
|
+
[ "$LEVEL" -ge 2 ] && echo " /dw-plan /dw-review /dw-estimate /dw-log-work"
|
|
369
|
+
[ "$LEVEL" -ge 3 ] && echo " /dw-docs-update /dw-dashboard /dw-sprint-review"
|
|
370
|
+
$HAS_TL && echo " /dw-arch-review (Tech Lead)"
|
|
371
|
+
$HAS_BA && echo " /dw-requirements (BA)"
|
|
372
|
+
$HAS_QC && echo " /dw-test-plan (QC)"
|
|
373
|
+
$HAS_PM && echo " /dw-dashboard (PM)"
|
|
374
|
+
echo ""
|
|
375
|
+
echo -e "${YELLOW} Bước tiếp theo:${NC}"
|
|
376
|
+
echo " 1. Mở Claude Code trong thư mục này"
|
|
377
|
+
echo " 2. Cập nhật Tech Stack trong CLAUDE.md (tuỳ chọn nhưng nên làm)"
|
|
378
|
+
echo " 3. Chạy: /dw-task-init [tên-feature-đầu-tiên]"
|
|
379
|
+
echo ""
|
|
380
|
+
echo " Docs: .dw-module/docs/README.md"
|
|
381
|
+
echo " Cheatsheet: .dw-module/docs/cheatsheet.md"
|
|
382
|
+
echo ""
|
package/src/cli.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
const pkg = require(join(__dirname, '..', 'package.json'));
|
|
10
|
+
|
|
11
|
+
export function run(argv) {
|
|
12
|
+
const program = new Command();
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.name('dw')
|
|
16
|
+
.description('dw-kit — AI development workflow toolkit')
|
|
17
|
+
.version(pkg.version, '-v, --version');
|
|
18
|
+
|
|
19
|
+
program
|
|
20
|
+
.command('init')
|
|
21
|
+
.description('Setup dw-kit in current project (interactive wizard)')
|
|
22
|
+
.option('-p, --preset <name>', 'Use preset: solo-quick | small-team | enterprise')
|
|
23
|
+
.option('-a, --adapter <platform>', 'Target platform: claude-cli | cursor | generic', 'claude-cli')
|
|
24
|
+
.option('-s, --silent', 'Non-interactive mode (reads DW_NAME, DW_DEPTH, DW_ROLES, DW_LANG env vars)')
|
|
25
|
+
.action(async (opts) => {
|
|
26
|
+
const { initCommand } = await import('./commands/init.mjs');
|
|
27
|
+
await initCommand(opts);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
program
|
|
31
|
+
.command('upgrade')
|
|
32
|
+
.description('Update dw-kit files in current project')
|
|
33
|
+
.option('-n, --dry-run', 'Preview changes without applying')
|
|
34
|
+
.option('-c, --check', 'Only check if update is available')
|
|
35
|
+
.option('-l, --layer <name>', 'Update specific layer: core | platform | capability | all', 'all')
|
|
36
|
+
.action(async (opts) => {
|
|
37
|
+
const { upgradeCommand } = await import('./commands/upgrade.mjs');
|
|
38
|
+
await upgradeCommand(opts);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
program
|
|
42
|
+
.command('validate')
|
|
43
|
+
.description('Validate .dw/config/dw.config.yml against schema')
|
|
44
|
+
.option('-f, --file <path>', 'Config file path', '.dw/config/dw.config.yml')
|
|
45
|
+
.action(async (opts) => {
|
|
46
|
+
const { validateCommand } = await import('./commands/validate.mjs');
|
|
47
|
+
await validateCommand(opts);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
program
|
|
51
|
+
.command('doctor')
|
|
52
|
+
.description('Check dw-kit installation health')
|
|
53
|
+
.action(async () => {
|
|
54
|
+
const { doctorCommand } = await import('./commands/doctor.mjs');
|
|
55
|
+
await doctorCommand();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
program
|
|
59
|
+
.command('migrate')
|
|
60
|
+
.description('Migrate project from dw-kit v0.3 to v1')
|
|
61
|
+
.option('-n, --dry-run', 'Preview migration without applying')
|
|
62
|
+
.action(async (opts) => {
|
|
63
|
+
const { migrateCommand } = await import('./commands/migrate.mjs');
|
|
64
|
+
await migrateCommand(opts);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
program.parse(argv);
|
|
68
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { header, ok, warn, err, info, log } from '../lib/ui.mjs';
|
|
5
|
+
import { loadConfig, getToolkitVersions } from '../lib/config.mjs';
|
|
6
|
+
import { detectPlatform, platformLabel } from '../lib/platform.mjs';
|
|
7
|
+
|
|
8
|
+
const TOOLKIT_ROOT = resolve(fileURLToPath(import.meta.url), '..', '..', '..');
|
|
9
|
+
|
|
10
|
+
const CORE_FILES = [
|
|
11
|
+
'.dw/core/WORKFLOW.md',
|
|
12
|
+
'.dw/core/THINKING.md',
|
|
13
|
+
'.dw/core/QUALITY.md',
|
|
14
|
+
'.dw/core/ROLES.md',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const CONFIG_FILES = [
|
|
18
|
+
'.dw/config/dw.config.yml',
|
|
19
|
+
'.dw/config/config.schema.json',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const CLAUDE_ESSENTIAL = [
|
|
23
|
+
'.claude/settings.json',
|
|
24
|
+
'.claude/hooks/pre-commit-gate.sh',
|
|
25
|
+
'.claude/hooks/safety-guard.sh',
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export async function doctorCommand() {
|
|
29
|
+
const projectDir = process.cwd();
|
|
30
|
+
|
|
31
|
+
header('dw-kit Doctor');
|
|
32
|
+
let issues = 0;
|
|
33
|
+
let warnings = 0;
|
|
34
|
+
|
|
35
|
+
info('Environment');
|
|
36
|
+
log(`Node.js : ${process.version}`);
|
|
37
|
+
log(`Platform : ${process.platform} ${process.arch}`);
|
|
38
|
+
log(`Working dir : ${projectDir}`);
|
|
39
|
+
|
|
40
|
+
const pkg = JSON.parse(readFileSync(join(TOOLKIT_ROOT, 'package.json'), 'utf-8'));
|
|
41
|
+
log(`dw-kit CLI : v${pkg.version}`);
|
|
42
|
+
|
|
43
|
+
const platform = detectPlatform(projectDir);
|
|
44
|
+
log(`AI Platform : ${platformLabel(platform)}`);
|
|
45
|
+
|
|
46
|
+
info('Core Files (Layer 0)');
|
|
47
|
+
for (const file of CORE_FILES) {
|
|
48
|
+
const fullPath = join(projectDir, file);
|
|
49
|
+
if (existsSync(fullPath)) {
|
|
50
|
+
ok(file);
|
|
51
|
+
} else {
|
|
52
|
+
err(`${file} — MISSING`);
|
|
53
|
+
issues++;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
info('Config (Layer 2)');
|
|
58
|
+
for (const file of CONFIG_FILES) {
|
|
59
|
+
const fullPath = join(projectDir, file);
|
|
60
|
+
if (existsSync(fullPath)) {
|
|
61
|
+
ok(file);
|
|
62
|
+
} else {
|
|
63
|
+
err(`${file} — MISSING`);
|
|
64
|
+
issues++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const configPath = join(projectDir, '.dw', 'config', 'dw.config.yml');
|
|
69
|
+
if (existsSync(configPath)) {
|
|
70
|
+
const config = loadConfig(configPath);
|
|
71
|
+
if (config) {
|
|
72
|
+
const versions = getToolkitVersions(config);
|
|
73
|
+
log(` Core version : ${versions.core}`);
|
|
74
|
+
log(` Platform version : ${versions.platform}`);
|
|
75
|
+
|
|
76
|
+
const toolkitConfig = loadConfig(join(TOOLKIT_ROOT, '.dw', 'config', 'dw.config.yml'));
|
|
77
|
+
if (toolkitConfig) {
|
|
78
|
+
const toolkitVersions = getToolkitVersions(toolkitConfig);
|
|
79
|
+
if (versions.core !== toolkitVersions.core) {
|
|
80
|
+
warn(`Update available: ${versions.core} → ${toolkitVersions.core} (run \`dw upgrade\`)`);
|
|
81
|
+
warnings++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
err('.dw/config/dw.config.yml — YAML parse error');
|
|
86
|
+
issues++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
info('Claude Files (Layer 1)');
|
|
91
|
+
if (platform === 'claude-cli' || existsSync(join(projectDir, '.claude'))) {
|
|
92
|
+
for (const file of CLAUDE_ESSENTIAL) {
|
|
93
|
+
const fullPath = join(projectDir, file);
|
|
94
|
+
if (existsSync(fullPath)) {
|
|
95
|
+
ok(file);
|
|
96
|
+
} else {
|
|
97
|
+
warn(`${file} — missing (optional for non-Claude platforms)`);
|
|
98
|
+
warnings++;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (existsSync(join(projectDir, 'CLAUDE.md'))) {
|
|
103
|
+
ok('CLAUDE.md');
|
|
104
|
+
} else {
|
|
105
|
+
warn('CLAUDE.md — missing');
|
|
106
|
+
warnings++;
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
log('Skipped — not a Claude CLI project');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
info('Adapter Structure (Layer 3)');
|
|
113
|
+
const adapterDirs = [
|
|
114
|
+
'.dw/adapters/claude-cli/generated',
|
|
115
|
+
'.dw/adapters/claude-cli/overrides',
|
|
116
|
+
'.dw/adapters/claude-cli/extensions',
|
|
117
|
+
];
|
|
118
|
+
for (const dir of adapterDirs) {
|
|
119
|
+
if (existsSync(join(projectDir, dir))) {
|
|
120
|
+
ok(dir);
|
|
121
|
+
} else {
|
|
122
|
+
warn(`${dir} — missing`);
|
|
123
|
+
warnings++;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
info('Runtime Directories');
|
|
128
|
+
for (const dir of ['.dw/tasks', '.dw/docs']) {
|
|
129
|
+
if (existsSync(join(projectDir, dir))) {
|
|
130
|
+
ok(dir);
|
|
131
|
+
} else {
|
|
132
|
+
warn(`${dir} — missing (will be created on first use)`);
|
|
133
|
+
warnings++;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
console.log();
|
|
138
|
+
header('Diagnosis');
|
|
139
|
+
if (issues === 0 && warnings === 0) {
|
|
140
|
+
ok('Everything looks good!');
|
|
141
|
+
} else if (issues === 0) {
|
|
142
|
+
warn(`${warnings} warning(s), 0 errors — mostly fine`);
|
|
143
|
+
} else {
|
|
144
|
+
err(`${issues} error(s), ${warnings} warning(s) — run \`dw init\` to fix`);
|
|
145
|
+
}
|
|
146
|
+
console.log();
|
|
147
|
+
|
|
148
|
+
process.exit(issues > 0 ? 1 : 0);
|
|
149
|
+
}
|