dev-playbooks-cn 1.6.2 → 1.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dev-playbooks-cn",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "AI-driven spec-based development workflow",
5
5
  "keywords": [
6
6
  "devbooks",
@@ -135,6 +135,17 @@ install_into() {
135
135
  mkdir -p "$dest_root"
136
136
  fi
137
137
 
138
+ # Install _shared directory (used by all skills for common references)
139
+ local shared_src="${src_root}/_shared"
140
+ if [[ -d "$shared_src" ]]; then
141
+ local shared_dest="${dest_root}/_shared"
142
+ if [[ "$dry_run" == true ]]; then
143
+ echo "[dry-run] install: $shared_src -> $shared_dest"
144
+ else
145
+ copy_dir "$shared_src" "$shared_dest"
146
+ fi
147
+ fi
148
+
138
149
  for src in "${skill_dirs[@]}"; do
139
150
  local name
140
151
  name="$(basename "$src")"
@@ -16,7 +16,7 @@
16
16
 
17
17
  set -euo pipefail
18
18
 
19
- VERSION="1.1.0"
19
+ VERSION="1.2.0"
20
20
 
21
21
  # Default configuration
22
22
  project_root="."
@@ -42,7 +42,7 @@ Usage:
42
42
  Options:
43
43
  --project-root DIR Project root directory (default: current directory)
44
44
  --dry-run Simulate run, do not actually modify files
45
- --keep-old Keep openspec/ directory after migration
45
+ --keep-old Keep openspec/ directory after migration (don't archive)
46
46
  --force Force re-execute all steps (ignore checkpoints)
47
47
  --help, -h Show help
48
48
 
@@ -52,22 +52,19 @@ Migration Steps:
52
52
  3. [CONFIG] Create/update .devbooks/config.yaml
53
53
  4. [REFS] Update path references in all documents
54
54
  5. [COMMANDS] Remove OpenSpec AI tool commands
55
- 6. [CLEANUP] Cleanup (optionally keep old directory)
55
+ 6. [ARCHIVE] Archive original openspec/ to .devbooks/archive/
56
56
 
57
- Cleanup includes:
58
- - openspec/ directory (backed up)
59
- - .claude/commands/openspec/ (Claude Code commands)
60
- - .codex/commands/openspec/ (Codex CLI commands)
61
- - .cursor/commands/openspec/ (Cursor commands)
62
- - .windsurf/workflows/openspec/ (Windsurf workflows)
63
- - .continue/prompts/openspec/ (Continue prompts)
64
- - OpenSpec references in CLAUDE.md, AGENTS.md, etc.
57
+ Archive includes:
58
+ - openspec/ directory -> .devbooks/archive/openspec-{timestamp}/
59
+ - .claude/commands/openspec/ -> .devbooks/archive/commands-openspec-{timestamp}/
60
+ - Other AI tool command directories
65
61
 
66
62
  Features:
67
63
  - Idempotent execution: safe to run repeatedly
68
64
  - State checkpoints: supports resume from breakpoint
69
- - Reference updates: automatic batch path replacement
70
- - Rollback support: backup created before cleanup
65
+ - Reference updates: automatic batch path replacement (optimized)
66
+ - Archive support: original files preserved in .devbooks/archive/
67
+ - dev-playbooks/ only contains necessary migrated structure
71
68
 
72
69
  EOF
73
70
  }
@@ -253,32 +250,42 @@ step_refs() {
253
250
 
254
251
  local files_updated=0
255
252
 
256
- # Find files that need updating
253
+ # Use grep -rl to find files containing openspec/ (much faster than find + grep per file)
254
+ # Exclude common large directories for performance
255
+ local exclude_dirs="--exclude-dir=node_modules --exclude-dir=.git --exclude-dir=vendor --exclude-dir=dist --exclude-dir=build --exclude-dir=.devbooks/backup --exclude-dir=.devbooks/archive"
256
+
257
+ # Find all files with openspec/ references
258
+ local files_to_update
259
+ files_to_update=$(grep -rl $exclude_dirs "openspec/" "${project_root}" 2>/dev/null || true)
260
+
261
+ if [[ -z "$files_to_update" ]]; then
262
+ log_info "No files contain openspec/ references"
263
+ save_checkpoint "REFS"
264
+ log_pass "Updated references in 0 files"
265
+ return 0
266
+ fi
267
+
257
268
  while IFS= read -r file; do
258
269
  [[ -z "$file" ]] && continue
259
270
  [[ ! -f "$file" ]] && continue
260
271
 
261
- # Skip binary files and .git directory
262
- [[ "$file" == *".git"* ]] && continue
263
- [[ "$file" == *".png" ]] && continue
264
- [[ "$file" == *".jpg" ]] && continue
265
- [[ "$file" == *".ico" ]] && continue
272
+ # Skip binary files
273
+ case "$file" in
274
+ *.png|*.jpg|*.jpeg|*.gif|*.ico|*.pdf|*.zip|*.tar|*.gz) continue ;;
275
+ esac
266
276
 
267
- # Check if contains openspec/ references
268
- if grep -q "openspec/" "$file" 2>/dev/null; then
269
- if [[ "$dry_run" == true ]]; then
270
- log_info "[DRY-RUN] Updating references: $file"
277
+ if [[ "$dry_run" == true ]]; then
278
+ log_info "[DRY-RUN] Updating references: $file"
279
+ else
280
+ # macOS compatible sed
281
+ if [[ "$(uname)" == "Darwin" ]]; then
282
+ sed -i '' 's|openspec/|dev-playbooks/|g' "$file"
271
283
  else
272
- # macOS compatible sed
273
- if [[ "$(uname)" == "Darwin" ]]; then
274
- sed -i '' 's|openspec/|dev-playbooks/|g' "$file"
275
- else
276
- sed -i 's|openspec/|dev-playbooks/|g' "$file"
277
- fi
284
+ sed -i 's|openspec/|dev-playbooks/|g' "$file"
278
285
  fi
279
- files_updated=$((files_updated + 1))
280
286
  fi
281
- done < <(find "${project_root}" -type f \( -name "*.md" -o -name "*.yaml" -o -name "*.yml" -o -name "*.sh" -o -name "*.ts" -o -name "*.js" -o -name "*.json" \) 2>/dev/null)
287
+ files_updated=$((files_updated + 1))
288
+ done <<< "$files_to_update"
282
289
 
283
290
  save_checkpoint "REFS"
284
291
  log_pass "Updated references in ${files_updated} files"
@@ -310,12 +317,12 @@ step_commands() {
310
317
  local full_path="${project_root}/${cmd_dir}"
311
318
  if [[ -d "$full_path" ]]; then
312
319
  if [[ "$dry_run" == true ]]; then
313
- log_info "[DRY-RUN] rm -rf $full_path"
320
+ log_info "[DRY-RUN] Archive $full_path"
314
321
  else
315
- local backup_dir="${project_root}/.devbooks/backup/commands-$(basename "$cmd_dir")-$(date +%Y%m%d%H%M%S)"
316
- mkdir -p "$(dirname "$backup_dir")"
317
- mv "$full_path" "$backup_dir"
318
- log_info "Backed up ${cmd_dir} to ${backup_dir}"
322
+ local archive_dir="${project_root}/.devbooks/archive/commands-$(basename "$cmd_dir")-$(date +%Y%m%d%H%M%S)"
323
+ mkdir -p "$(dirname "$archive_dir")"
324
+ mv "$full_path" "$archive_dir"
325
+ log_info "Archived ${cmd_dir} to ${archive_dir}"
319
326
  fi
320
327
  removed_count=$((removed_count + 1))
321
328
  fi
@@ -359,9 +366,9 @@ step_commands() {
359
366
  log_pass "Removed ${removed_count} OpenSpec command directories"
360
367
  }
361
368
 
362
- # Step 6: Cleanup
369
+ # Step 6: Cleanup and archive original directory
363
370
  step_cleanup() {
364
- log_step "6. Cleanup"
371
+ log_step "6. Archive and cleanup"
365
372
 
366
373
  if is_step_done "CLEANUP" && [[ "$force" == false ]]; then
367
374
  log_info "Cleanup already complete (skipping)"
@@ -369,18 +376,20 @@ step_cleanup() {
369
376
  fi
370
377
 
371
378
  local openspec_dir="${project_root}/openspec"
379
+ local archive_base="${project_root}/.devbooks/archive"
372
380
 
373
381
  if [[ "$keep_old" == true ]]; then
374
382
  log_info "Keeping openspec/ directory (--keep-old)"
375
383
  elif [[ -d "$openspec_dir" ]]; then
376
384
  if [[ "$dry_run" == true ]]; then
377
- log_info "[DRY-RUN] rm -rf $openspec_dir"
385
+ log_info "[DRY-RUN] Archive openspec/ to ${archive_base}/"
378
386
  else
379
- # Create backup
380
- local backup_dir="${project_root}/.devbooks/backup/openspec-$(date +%Y%m%d%H%M%S)"
381
- mkdir -p "$(dirname "$backup_dir")"
382
- mv "$openspec_dir" "$backup_dir"
383
- log_info "Backed up openspec/ to ${backup_dir}"
387
+ # Archive original directory to .devbooks/archive/
388
+ local archive_dir="${archive_base}/openspec-$(date +%Y%m%d%H%M%S)"
389
+ mkdir -p "$archive_base"
390
+ mv "$openspec_dir" "$archive_dir"
391
+ log_info "Archived openspec/ to ${archive_dir}"
392
+ log_info "Original files preserved in archive, dev-playbooks/ contains migrated structure"
384
393
  fi
385
394
  fi
386
395
 
@@ -414,11 +423,12 @@ verify_migration() {
414
423
  errors=$((errors + 1))
415
424
  fi
416
425
 
417
- # Check remaining references (warning only)
426
+ # Check remaining references (warning only, exclude archive directory)
418
427
  local remaining_refs
419
- remaining_refs=$(grep -r "openspec/" "${project_root}" --include="*.md" --include="*.yaml" --include="*.sh" 2>/dev/null | grep -v ".devbooks/backup" | wc -l || echo "0")
428
+ remaining_refs=$(grep -r "openspec/" "${project_root}" --include="*.md" --include="*.yaml" --include="*.sh" 2>/dev/null | grep -v ".devbooks/archive" | grep -v ".devbooks/backup" | wc -l || echo "0")
429
+ remaining_refs=$(echo "$remaining_refs" | tr -d ' ')
420
430
  if [[ "$remaining_refs" -gt 0 ]]; then
421
- log_warn "Still ${remaining_refs} openspec/ references remaining"
431
+ log_warn "Still ${remaining_refs} openspec/ references remaining (excluding archive)"
422
432
  fi
423
433
 
424
434
  if [[ "$errors" -eq 0 ]]; then
@@ -16,7 +16,7 @@
16
16
 
17
17
  set -euo pipefail
18
18
 
19
- VERSION="1.1.0"
19
+ VERSION="1.2.0"
20
20
 
21
21
  # Default configuration
22
22
  project_root="."
@@ -42,7 +42,7 @@ Usage:
42
42
  Options:
43
43
  --project-root DIR Project root directory (default: current directory)
44
44
  --dry-run Simulate run, do not actually modify files
45
- --keep-old Keep specs/ directory after migration
45
+ --keep-old Keep specs/memory directories after migration (don't archive)
46
46
  --force Force re-execute all steps (ignore checkpoints)
47
47
  --help, -h Show help
48
48
 
@@ -53,15 +53,14 @@ Migration Steps:
53
53
  4. [CONFIG] Create/update .devbooks/config.yaml
54
54
  5. [REFS] Update path references in all documents
55
55
  6. [COMMANDS] Remove spec-kit AI tool commands
56
- 7. [CLEANUP] Cleanup (optionally keep old directories)
56
+ 7. [ARCHIVE] Archive original directories to .devbooks/archive/
57
57
 
58
- Cleanup includes:
59
- - specs/ directory (backed up)
60
- - memory/ directory (backed up)
61
- - templates/ directory (spec-kit templates, backed up)
58
+ Archive includes:
59
+ - specs/ directory -> .devbooks/archive/speckit-specs-{timestamp}/
60
+ - memory/ directory -> .devbooks/archive/speckit-memory-{timestamp}/
61
+ - templates/ directory (if spec-kit style)
62
62
  - scripts/bash/ and scripts/powershell/ (spec-kit scripts)
63
- - .claude/commands/speckit/ and similar AI tool directories
64
- - spec-kit references in CLAUDE.md, AGENTS.md, etc.
63
+ - AI tool command directories
65
64
 
66
65
  Mapping Rules:
67
66
  Spec-Kit DevBooks
@@ -78,8 +77,9 @@ Mapping Rules:
78
77
  Features:
79
78
  - Idempotent execution: safe to run repeatedly
80
79
  - State checkpoints: supports resume from breakpoint
81
- - Reference updates: automatic batch path replacement
82
- - Rollback support: backup created before cleanup
80
+ - Reference updates: automatic batch path replacement (optimized)
81
+ - Archive support: original files preserved in .devbooks/archive/
82
+ - dev-playbooks/ only contains necessary migrated structure
83
83
 
84
84
  EOF
85
85
  }
@@ -429,45 +429,44 @@ step_refs() {
429
429
 
430
430
  local files_updated=0
431
431
 
432
- # Reference patterns to update
433
- declare -a patterns=(
434
- "specs/[^/]*/spec.md:changes/*/design.md"
435
- "specs/[^/]*/plan.md:changes/*/proposal.md"
436
- "specs/[^/]*/tasks.md:changes/*/tasks.md"
437
- "memory/constitution.md:dev-playbooks/specs/_meta/constitution.md"
438
- )
432
+ # Use grep -rl to find files containing spec-kit style references (much faster)
433
+ # Exclude common large directories for performance
434
+ local exclude_dirs="--exclude-dir=node_modules --exclude-dir=.git --exclude-dir=vendor --exclude-dir=dist --exclude-dir=build --exclude-dir=.devbooks/backup --exclude-dir=.devbooks/archive"
435
+
436
+ # Find all files with spec-kit style references
437
+ local files_to_update
438
+ files_to_update=$(grep -rlE $exclude_dirs "(specs/[^/]+/|memory/constitution)" "${project_root}" 2>/dev/null || true)
439
+
440
+ if [[ -z "$files_to_update" ]]; then
441
+ log_info "No files contain spec-kit style references"
442
+ save_checkpoint "REFS"
443
+ log_pass "Updated references in 0 files"
444
+ return 0
445
+ fi
439
446
 
440
- # Find files that need updating
441
447
  while IFS= read -r file; do
442
448
  [[ -z "$file" ]] && continue
443
449
  [[ ! -f "$file" ]] && continue
444
450
 
445
- # Skip binary files and .git directory
446
- [[ "$file" == *".git"* ]] && continue
447
- [[ "$file" == *".png" ]] && continue
448
- [[ "$file" == *".jpg" ]] && continue
449
- [[ "$file" == *".ico" ]] && continue
450
-
451
- local modified=false
451
+ # Skip binary files
452
+ case "$file" in
453
+ *.png|*.jpg|*.jpeg|*.gif|*.ico|*.pdf|*.zip|*.tar|*.gz) continue ;;
454
+ esac
452
455
 
453
- # Check if contains spec-kit style references
454
- if grep -qE "(specs/[^/]+/|memory/constitution)" "$file" 2>/dev/null; then
455
- if [[ "$dry_run" == true ]]; then
456
- log_info "[DRY-RUN] Updating references: $file"
456
+ if [[ "$dry_run" == true ]]; then
457
+ log_info "[DRY-RUN] Updating references: $file"
458
+ else
459
+ # Update common patterns (macOS compatible)
460
+ if [[ "$(uname)" == "Darwin" ]]; then
461
+ sed -i '' 's|memory/constitution\.md|dev-playbooks/specs/_meta/constitution.md|g' "$file"
462
+ sed -i '' 's|spec-driven\.md|dev-playbooks/specs/_meta/spec-driven.md|g' "$file"
457
463
  else
458
- # Update common patterns (macOS compatible)
459
- if [[ "$(uname)" == "Darwin" ]]; then
460
- sed -i '' 's|memory/constitution\.md|dev-playbooks/specs/_meta/constitution.md|g' "$file"
461
- sed -i '' 's|spec-driven\.md|dev-playbooks/specs/_meta/spec-driven.md|g' "$file"
462
- else
463
- sed -i 's|memory/constitution\.md|dev-playbooks/specs/_meta/constitution.md|g' "$file"
464
- sed -i 's|spec-driven\.md|dev-playbooks/specs/_meta/spec-driven.md|g' "$file"
465
- fi
466
- modified=true
464
+ sed -i 's|memory/constitution\.md|dev-playbooks/specs/_meta/constitution.md|g' "$file"
465
+ sed -i 's|spec-driven\.md|dev-playbooks/specs/_meta/spec-driven.md|g' "$file"
467
466
  fi
468
- files_updated=$((files_updated + 1))
469
467
  fi
470
- done < <(find "${project_root}" -type f \( -name "*.md" -o -name "*.yaml" -o -name "*.yml" -o -name "*.sh" -o -name "*.ts" -o -name "*.js" -o -name "*.json" \) 2>/dev/null)
468
+ files_updated=$((files_updated + 1))
469
+ done <<< "$files_to_update"
471
470
 
472
471
  save_checkpoint "REFS"
473
472
  log_pass "Updated references in ${files_updated} files"
@@ -510,12 +509,12 @@ step_commands() {
510
509
  local full_path="${project_root}/${cmd_dir}"
511
510
  if [[ -d "$full_path" ]]; then
512
511
  if [[ "$dry_run" == true ]]; then
513
- log_info "[DRY-RUN] rm -rf $full_path"
512
+ log_info "[DRY-RUN] Archive $full_path"
514
513
  else
515
- local backup_dir="${project_root}/.devbooks/backup/commands-$(basename "$cmd_dir")-$(date +%Y%m%d%H%M%S)"
516
- mkdir -p "$(dirname "$backup_dir")"
517
- mv "$full_path" "$backup_dir"
518
- log_info "Backed up ${cmd_dir} to ${backup_dir}"
514
+ local archive_dir="${project_root}/.devbooks/archive/commands-$(basename "$cmd_dir")-$(date +%Y%m%d%H%M%S)"
515
+ mkdir -p "$(dirname "$archive_dir")"
516
+ mv "$full_path" "$archive_dir"
517
+ log_info "Archived ${cmd_dir} to ${archive_dir}"
519
518
  fi
520
519
  removed_count=$((removed_count + 1))
521
520
  fi
@@ -533,12 +532,12 @@ step_commands() {
533
532
  # Check if it contains spec-kit scripts (by looking for spec-kit patterns)
534
533
  if ls "${full_path}"/*.sh 2>/dev/null | xargs grep -l "spec-kit\|speckit\|SPEC_FILE\|create-new-feature" 2>/dev/null | head -1 > /dev/null; then
535
534
  if [[ "$dry_run" == true ]]; then
536
- log_info "[DRY-RUN] backup and remove $full_path (spec-kit scripts)"
535
+ log_info "[DRY-RUN] archive $full_path (spec-kit scripts)"
537
536
  else
538
- local backup_dir="${project_root}/.devbooks/backup/speckit-scripts-$(date +%Y%m%d%H%M%S)"
539
- mkdir -p "$(dirname "$backup_dir")"
540
- mv "$full_path" "$backup_dir"
541
- log_info "Backed up ${sk_dir}/ to ${backup_dir}"
537
+ local archive_dir="${project_root}/.devbooks/archive/speckit-scripts-$(date +%Y%m%d%H%M%S)"
538
+ mkdir -p "$(dirname "$archive_dir")"
539
+ mv "$full_path" "$archive_dir"
540
+ log_info "Archived ${sk_dir}/ to ${archive_dir}"
542
541
  fi
543
542
  removed_count=$((removed_count + 1))
544
543
  fi
@@ -551,12 +550,12 @@ step_commands() {
551
550
  # Check if it's spec-kit templates (look for spec-template.md or commands/)
552
551
  if [[ -f "${templates_dir}/spec-template.md" ]] || [[ -d "${templates_dir}/commands" ]]; then
553
552
  if [[ "$dry_run" == true ]]; then
554
- log_info "[DRY-RUN] backup and remove $templates_dir (spec-kit templates)"
553
+ log_info "[DRY-RUN] archive $templates_dir (spec-kit templates)"
555
554
  else
556
- local backup_dir="${project_root}/.devbooks/backup/speckit-templates-$(date +%Y%m%d%H%M%S)"
557
- mkdir -p "$(dirname "$backup_dir")"
558
- mv "$templates_dir" "$backup_dir"
559
- log_info "Backed up templates/ to ${backup_dir}"
555
+ local archive_dir="${project_root}/.devbooks/archive/speckit-templates-$(date +%Y%m%d%H%M%S)"
556
+ mkdir -p "$(dirname "$archive_dir")"
557
+ mv "$templates_dir" "$archive_dir"
558
+ log_info "Archived templates/ to ${archive_dir}"
560
559
  fi
561
560
  removed_count=$((removed_count + 1))
562
561
  fi
@@ -602,37 +601,39 @@ step_commands() {
602
601
  log_pass "Removed ${removed_count} spec-kit directories/commands"
603
602
  }
604
603
 
605
- # Step 7: Cleanup
604
+ # Step 7: Archive and cleanup
606
605
  step_cleanup() {
607
- log_step "7. Cleanup"
606
+ log_step "7. Archive and cleanup"
608
607
 
609
608
  if is_step_done "CLEANUP" && [[ "$force" == false ]]; then
610
609
  log_info "Cleanup already complete (skipping)"
611
610
  return 0
612
611
  fi
613
612
 
614
- local dirs_to_backup=(
613
+ local dirs_to_archive=(
615
614
  "specs"
616
615
  "memory"
617
616
  )
617
+ local archive_base="${project_root}/.devbooks/archive"
618
618
 
619
619
  if [[ "$keep_old" == true ]]; then
620
620
  log_info "Keeping original directories (--keep-old)"
621
621
  else
622
- for dir in "${dirs_to_backup[@]}"; do
622
+ for dir in "${dirs_to_archive[@]}"; do
623
623
  local src_dir="${project_root}/${dir}"
624
624
  if [[ -d "$src_dir" ]]; then
625
625
  if [[ "$dry_run" == true ]]; then
626
- log_info "[DRY-RUN] backup and remove $src_dir"
626
+ log_info "[DRY-RUN] archive $src_dir"
627
627
  else
628
- # Create backup
629
- local backup_dir="${project_root}/.devbooks/backup/speckit-${dir}-$(date +%Y%m%d%H%M%S)"
630
- mkdir -p "$(dirname "$backup_dir")"
631
- mv "$src_dir" "$backup_dir"
632
- log_info "Backed up ${dir}/ to ${backup_dir}"
628
+ # Archive to .devbooks/archive/
629
+ local archive_dir="${archive_base}/speckit-${dir}-$(date +%Y%m%d%H%M%S)"
630
+ mkdir -p "$archive_base"
631
+ mv "$src_dir" "$archive_dir"
632
+ log_info "Archived ${dir}/ to ${archive_dir}"
633
633
  fi
634
634
  fi
635
635
  done
636
+ log_info "Original files preserved in .devbooks/archive/, dev-playbooks/ contains migrated structure"
636
637
  fi
637
638
 
638
639
  save_checkpoint "CLEANUP"