dw-kit 1.0.0 → 1.0.1

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/setup.sh DELETED
@@ -1,382 +0,0 @@
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 ""
@@ -1,215 +0,0 @@
1
- import { existsSync, readFileSync, readdirSync, mkdirSync, copyFileSync } from 'node:fs';
2
- import { join, resolve } from 'node:path';
3
- import { execSync } from 'node:child_process';
4
- import { header, ok, warn, err, info, log, dry, ask } from '../lib/ui.mjs';
5
- import { loadConfig, buildConfig, writeConfig } from '../lib/config.mjs';
6
-
7
- const DEPTH_MAP = { '1': 'quick', '2': 'standard', '3': 'thorough' };
8
- const VALID_ROLES = ['dev', 'techlead', 'ba', 'qc', 'pm'];
9
-
10
- export async function migrateCommand(opts) {
11
- const projectDir = process.cwd();
12
- const dryRun = opts.dryRun || false;
13
-
14
- header('dw-kit v0.3 → v1 Migration');
15
- if (dryRun) log('Mode: DRY RUN');
16
-
17
- const oldConfigPath = findOldConfig(projectDir);
18
- if (!oldConfigPath) {
19
- ok('No v0.3 config found (dv-workflow.config.yml). Already on v1 or fresh install.');
20
- log('If migrating manually, run `dw init` instead.');
21
- return;
22
- }
23
-
24
- info(`Step 1: Parse old config (${oldConfigPath})`);
25
- const oldConfig = loadConfig(oldConfigPath);
26
- if (!oldConfig) {
27
- err('Failed to parse old config. Manual migration needed.');
28
- process.exit(1);
29
- }
30
- ok('Old config parsed');
31
-
32
- const extracted = extractOldValues(oldConfig);
33
- log(` Project: ${extracted.name}`);
34
- log(` Level: ${extracted.level} → depth: ${extracted.depth}`);
35
- log(` Roles: ${extracted.roles.join(', ')}`);
36
- log(` Language: ${extracted.language}`);
37
-
38
- info('Step 2: Detect customized skills');
39
- const customized = detectCustomizedSkills(projectDir);
40
- if (customized.length > 0) {
41
- for (const skill of customized) {
42
- if (dryRun) {
43
- dry(`preserve ${skill} → .dw/adapters/claude-cli/overrides/skills/${skill}/`);
44
- } else {
45
- preserveSkillOverride(projectDir, skill);
46
- ok(`Preserved: ${skill} → overrides/`);
47
- }
48
- }
49
- } else {
50
- ok('No customized skills detected');
51
- }
52
-
53
- info('Step 3: Create v1 config');
54
- const newConfigDir = join(projectDir, '.dw', 'config');
55
- const newConfigPath = join(newConfigDir, 'dw.config.yml');
56
-
57
- if (existsSync(newConfigPath)) {
58
- warn('.dw/config/dw.config.yml already exists — skipping config generation');
59
- warn('Review and update manually if needed.');
60
- } else {
61
- const newConfig = buildConfig({
62
- projectName: extracted.name,
63
- language: extracted.language,
64
- depth: extracted.depth,
65
- roles: extracted.roles,
66
- });
67
-
68
- if (extracted.testCommand) newConfig.quality.test_command = extracted.testCommand;
69
- if (extracted.lintCommand) newConfig.quality.lint_command = extracted.lintCommand;
70
- newConfig._toolkit.migrated_from = 'v0.3';
71
-
72
- if (dryRun) {
73
- dry('Would create .dw/config/dw.config.yml');
74
- } else {
75
- mkdirSync(newConfigDir, { recursive: true });
76
- writeConfig(newConfigPath, newConfig);
77
- ok(`.dw/config/dw.config.yml created (depth: ${extracted.depth})`);
78
- }
79
- }
80
-
81
- info('Step 4: Backup old config');
82
- if (dryRun) {
83
- dry(`Would backup ${oldConfigPath} → ${oldConfigPath}.bak`);
84
- } else {
85
- const bakPath = `${oldConfigPath}.bak`;
86
- if (!existsSync(bakPath)) {
87
- copyFileSync(oldConfigPath, bakPath);
88
- ok(`Backed up: ${oldConfigPath} → ${bakPath}`);
89
- } else {
90
- warn('Backup already exists — skipping');
91
- }
92
- }
93
-
94
- info('Step 5: Check CI/CD references');
95
- const ciFiles = checkCIReferences(projectDir);
96
- if (ciFiles.length > 0) {
97
- for (const file of ciFiles) {
98
- warn(`Found reference in: ${file} — update to .dw/config/dw.config.yml`);
99
- }
100
- } else {
101
- ok('No CI/CD references found');
102
- }
103
-
104
- console.log();
105
- header(dryRun ? 'DRY RUN complete — no changes made' : 'Migration complete!');
106
-
107
- if (!dryRun) {
108
- console.log();
109
- log('Next steps:');
110
- log(' 1. Review .dw/config/dw.config.yml');
111
- log(' 2. Run: dw init --adapter claude-cli (to regenerate .claude/)');
112
- log(' 3. Check .dw/adapters/claude-cli/overrides/ for preserved customizations');
113
- if (ciFiles.length > 0) {
114
- log(' 4. Update CI/CD files (see warnings above)');
115
- }
116
- } else {
117
- log('Run without --dry-run to apply migration.');
118
- }
119
- console.log();
120
- }
121
-
122
- function findOldConfig(projectDir) {
123
- const candidates = [
124
- join(projectDir, 'dv-workflow.config.yml'),
125
- join(projectDir, 'dw.config.yml'),
126
- ];
127
- return candidates.find(p => existsSync(p)) || null;
128
- }
129
-
130
- function extractOldValues(config) {
131
- const name = config.project?.name || config.name || 'my-project';
132
- const language = config.project?.language || config.language || 'vi';
133
- const level = String(config.level || config.workflow?.level || '2');
134
- const depth = DEPTH_MAP[level] || 'standard';
135
-
136
- let roles = config.team?.roles || [];
137
- if (!Array.isArray(roles)) roles = ['dev'];
138
- roles = roles.filter(r => VALID_ROLES.includes(r));
139
- if (!roles.includes('dev')) roles.unshift('dev');
140
-
141
- const testCommand = config.quality?.test_command || config.test_command || '';
142
- const lintCommand = config.quality?.lint_command || config.lint_command || '';
143
-
144
- return { name, language, level, depth, roles, testCommand, lintCommand };
145
- }
146
-
147
- function detectCustomizedSkills(projectDir) {
148
- const skillsDir = join(projectDir, '.claude', 'skills');
149
- if (!existsSync(skillsDir)) return [];
150
-
151
- const customized = [];
152
- try {
153
- const isGitRepo = existsSync(join(projectDir, '.git'));
154
- if (!isGitRepo) return [];
155
-
156
- const skills = readdirSync(skillsDir, { withFileTypes: true })
157
- .filter(d => d.isDirectory())
158
- .map(d => d.name);
159
-
160
- for (const skill of skills) {
161
- const skillFile = join('.claude', 'skills', skill, 'SKILL.md');
162
- try {
163
- execSync(`git diff --quiet HEAD -- "${skillFile}"`, {
164
- cwd: projectDir,
165
- stdio: 'pipe',
166
- });
167
- } catch {
168
- customized.push(skill);
169
- }
170
- }
171
- } catch { /* not a git repo or other issue */ }
172
-
173
- return customized;
174
- }
175
-
176
- function preserveSkillOverride(projectDir, skillName) {
177
- const srcFile = join(projectDir, '.claude', 'skills', skillName, 'SKILL.md');
178
- const dstDir = join(projectDir, '.dw', 'adapters', 'claude-cli', 'overrides', 'skills', skillName);
179
- const dstFile = join(dstDir, 'SKILL.md');
180
-
181
- if (!existsSync(srcFile)) return;
182
- mkdirSync(dstDir, { recursive: true });
183
- copyFileSync(srcFile, dstFile);
184
- }
185
-
186
- function checkCIReferences(projectDir) {
187
- const found = [];
188
-
189
- const directChecks = ['.gitlab-ci.yml', 'Makefile', '.circleci/config.yml'];
190
- for (const file of directChecks) {
191
- const fullPath = join(projectDir, file);
192
- if (existsSync(fullPath)) {
193
- const content = readFileSync(fullPath, 'utf-8');
194
- if (/dv-workflow\.config\.yml|dv-workflow-kit/.test(content)) {
195
- found.push(file);
196
- }
197
- }
198
- }
199
-
200
- const workflowsDir = join(projectDir, '.github', 'workflows');
201
- if (existsSync(workflowsDir)) {
202
- try {
203
- const files = readdirSync(workflowsDir).filter(f => f.endsWith('.yml') || f.endsWith('.yaml'));
204
- for (const file of files) {
205
- const fullPath = join(workflowsDir, file);
206
- const content = readFileSync(fullPath, 'utf-8');
207
- if (/dv-workflow\.config\.yml|dv-workflow-kit/.test(content)) {
208
- found.push(join('.github', 'workflows', file));
209
- }
210
- }
211
- } catch { /* dir read failed */ }
212
- }
213
-
214
- return found;
215
- }