dev-playbooks-cn 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/LICENSE +21 -0
- package/README.md +466 -0
- package/bin/devbooks.js +987 -0
- package/package.json +43 -0
- package/skills/Skills/344/275/277/347/224/250/350/257/264/346/230/216.md +446 -0
- package/skills/Skill/345/274/200/345/217/221/346/214/207/345/215/227.md +248 -0
- package/skills/_shared/context-detection-template.md +315 -0
- package/skills/_shared/mcp-enhancement-template.md +144 -0
- package/skills/_shared/references//351/200/232/347/224/250/345/256/210/351/227/250/345/215/217/350/256/256.md +114 -0
- package/skills/_template/config-discovery-template.md +126 -0
- package/skills/devbooks-brownfield-bootstrap/SKILL.md +167 -0
- package/skills/devbooks-brownfield-bootstrap/references//344/273/243/347/240/201/345/257/274/350/210/252/347/255/226/347/225/245.md +203 -0
- package/skills/devbooks-brownfield-bootstrap/references//345/255/230/351/207/217/351/241/271/347/233/256/345/210/235/345/247/213/345/214/226.md +96 -0
- package/skills/devbooks-brownfield-bootstrap/references//345/255/230/351/207/217/351/241/271/347/233/256/345/210/235/345/247/213/345/214/226/346/217/220/347/244/272/350/257/215.md +115 -0
- package/skills/devbooks-brownfield-bootstrap/references//346/234/257/350/257/255/350/241/250/346/250/241/346/235/277.md +42 -0
- package/skills/devbooks-brownfield-bootstrap/scripts/cod-update.sh +357 -0
- package/skills/devbooks-brownfield-bootstrap/templates/project-profile-template.md +172 -0
- package/skills/devbooks-c4-map/SKILL.md +151 -0
- package/skills/devbooks-c4-map/references/C4/346/236/266/346/236/204/345/234/260/345/233/276/346/217/220/347/244/272/350/257/215.md +33 -0
- package/skills/devbooks-c4-map/references//345/210/206/345/261/202/347/272/246/346/235/237/346/243/200/346/237/245/346/270/205/345/215/225.md +185 -0
- package/skills/devbooks-code-review/SKILL.md +175 -0
- package/skills/devbooks-code-review/references/PR/346/250/241/346/235/277/344/270/216/346/214/207/345/215/227.md +321 -0
- package/skills/devbooks-code-review/references//344/273/243/347/240/201/350/257/204/345/256/241/346/217/220/347/244/272/350/257/215.md +100 -0
- package/skills/devbooks-code-review/references//345/235/217/345/221/263/351/201/223/351/200/237/346/237/245/350/241/250.md +495 -0
- package/skills/devbooks-code-review/references//350/265/204/346/272/220/347/256/241/347/220/206/345/256/241/346/237/245/346/270/205/345/215/225.md +311 -0
- package/skills/devbooks-coder/SKILL.md +219 -0
- package/skills/devbooks-coder/references//344/273/243/347/240/201/345/256/236/347/216/260/346/217/220/347/244/272/350/257/215.md +70 -0
- package/skills/devbooks-coder/references//344/275/216/351/243/216/351/231/251/346/224/271/345/212/250/346/212/200/346/234/257.md +275 -0
- package/skills/devbooks-coder/references//346/227/245/345/277/227/350/247/204/350/214/203.md +329 -0
- package/skills/devbooks-coder/references//347/274/226/347/240/201/351/243/216/346/240/274/347/273/206/345/210/231.md +351 -0
- package/skills/devbooks-coder/references//351/224/231/350/257/257/347/240/201/350/247/204/350/214/203.md +463 -0
- package/skills/devbooks-delivery-workflow/SKILL.md +217 -0
- package/skills/devbooks-delivery-workflow/references//344/272/244/344/273/230/351/252/214/346/224/266/345/267/245/344/275/234/346/265/201.md +256 -0
- package/skills/devbooks-delivery-workflow/references//345/216/237/345/236/213-/347/224/237/344/272/247/345/217/214/350/275/250/346/250/241/345/274/217.md +168 -0
- package/skills/devbooks-delivery-workflow/references//345/217/230/346/233/264/351/252/214/350/257/201/344/270/216/350/277/275/346/272/257/346/250/241/346/235/277.md +133 -0
- package/skills/devbooks-delivery-workflow/scripts/ac-trace-check.sh +330 -0
- package/skills/devbooks-delivery-workflow/scripts/audit-scope.sh +262 -0
- package/skills/devbooks-delivery-workflow/scripts/change-check.sh +1040 -0
- package/skills/devbooks-delivery-workflow/scripts/change-codemod-scaffold.sh +135 -0
- package/skills/devbooks-delivery-workflow/scripts/change-evidence.sh +152 -0
- package/skills/devbooks-delivery-workflow/scripts/change-scaffold.sh +442 -0
- package/skills/devbooks-delivery-workflow/scripts/change-spec-delta-scaffold.sh +136 -0
- package/skills/devbooks-delivery-workflow/scripts/constitution-check.sh +237 -0
- package/skills/devbooks-delivery-workflow/scripts/env-match-check.sh +128 -0
- package/skills/devbooks-delivery-workflow/scripts/fitness-check.sh +387 -0
- package/skills/devbooks-delivery-workflow/scripts/guardrail-check.sh +519 -0
- package/skills/devbooks-delivery-workflow/scripts/handoff-check.sh +141 -0
- package/skills/devbooks-delivery-workflow/scripts/hygiene-check.sh +340 -0
- package/skills/devbooks-delivery-workflow/scripts/migrate-from-openspec.sh +385 -0
- package/skills/devbooks-delivery-workflow/scripts/migrate-to-v2-gates.sh +202 -0
- package/skills/devbooks-delivery-workflow/scripts/progress-dashboard.sh +319 -0
- package/skills/devbooks-delivery-workflow/scripts/prototype-promote.sh +341 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-preview.sh +203 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-promote.sh +118 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-rollback.sh +124 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-stage.sh +117 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-all.sh +78 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-npm-package.sh +123 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-openspec-free.sh +81 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-slash-commands.sh +146 -0
- package/skills/devbooks-delivery-workflow/templates/handoff.md +50 -0
- package/skills/devbooks-design-backport/SKILL.md +73 -0
- package/skills/devbooks-design-backport/references//345/233/236/345/206/231/350/256/276/350/256/241/346/226/207/346/241/243/346/217/220/347/244/272/350/257/215.md +196 -0
- package/skills/devbooks-design-doc/SKILL.md +121 -0
- package/skills/devbooks-design-doc/references//345/276/256/346/234/215/345/212/241/350/256/276/350/256/241/346/270/205/345/215/225.md +149 -0
- package/skills/devbooks-design-doc/references//350/256/276/350/256/241/346/226/207/346/241/243/346/217/220/347/244/272/350/257/215.md +189 -0
- package/skills/devbooks-design-doc/references//351/232/220/347/247/201/345/220/210/350/247/204/346/243/200/346/237/245/346/270/205/345/215/225.md +240 -0
- package/skills/devbooks-entropy-monitor/SKILL.md +188 -0
- package/skills/devbooks-entropy-monitor/references//347/206/265/345/272/246/351/207/217/346/226/271/346/263/225/350/256/272.md +223 -0
- package/skills/devbooks-entropy-monitor/scripts/entropy-measure.sh +449 -0
- package/skills/devbooks-entropy-monitor/scripts/entropy-report.sh +303 -0
- package/skills/devbooks-entropy-monitor/templates/thresholds.json +99 -0
- package/skills/devbooks-federation/SKILL.md +264 -0
- package/skills/devbooks-federation/scripts/federation-check.sh +144 -0
- package/skills/devbooks-federation/templates/federation.yaml +89 -0
- package/skills/devbooks-impact-analysis/SKILL.md +135 -0
- package/skills/devbooks-impact-analysis/references//345/275/261/345/223/215/345/210/206/346/236/220/346/217/220/347/244/272/350/257/215.md +82 -0
- package/skills/devbooks-impact-analysis/scripts/graph-cache.sh +214 -0
- package/skills/devbooks-implementation-plan/SKILL.md +83 -0
- package/skills/devbooks-implementation-plan/references//347/274/226/347/240/201/350/256/241/345/210/222/346/217/220/347/244/272/350/257/215.md +99 -0
- package/skills/devbooks-index-bootstrap/SKILL.md +240 -0
- package/skills/devbooks-proposal-author/SKILL.md +83 -0
- package/skills/devbooks-proposal-author/references//346/217/220/346/241/210/346/222/260/345/206/231/346/217/220/347/244/272/350/257/215.md +66 -0
- package/skills/devbooks-proposal-challenger/SKILL.md +86 -0
- package/skills/devbooks-proposal-challenger/references//344/274/246/347/220/206/344/270/216/345/220/210/350/247/204/346/243/200/346/237/245/346/270/205/345/215/225.md +176 -0
- package/skills/devbooks-proposal-challenger/references//346/217/220/346/241/210/350/264/250/347/226/221/346/217/220/347/244/272/350/257/215.md +57 -0
- package/skills/devbooks-proposal-debate-workflow/SKILL.md +78 -0
- package/skills/devbooks-proposal-debate-workflow/references//346/217/220/346/241/210/345/257/271/350/276/251/345/267/245/344/275/234/346/265/201.md +24 -0
- package/skills/devbooks-proposal-debate-workflow/references//346/217/220/346/241/210/345/257/271/350/276/251/346/250/241/346/235/277.md +35 -0
- package/skills/devbooks-proposal-debate-workflow/scripts/proposal-debate-check.sh +102 -0
- package/skills/devbooks-proposal-judge/SKILL.md +78 -0
- package/skills/devbooks-proposal-judge/references//346/217/220/346/241/210/350/243/201/345/206/263/346/217/220/347/244/272/350/257/215.md +37 -0
- package/skills/devbooks-router/SKILL.md +346 -0
- package/skills/devbooks-spec-contract/SKILL.md +191 -0
- package/skills/devbooks-spec-contract/references/API/350/256/276/350/256/241/346/214/207/345/215/227.md +349 -0
- package/skills/devbooks-spec-contract/references//345/245/221/347/272/246/344/270/216/346/225/260/346/215/256/345/256/232/344/271/211/346/217/220/347/244/272/350/257/215.md +85 -0
- package/skills/devbooks-spec-contract/references//350/247/204/346/240/274/345/217/230/346/233/264/346/217/220/347/244/272/350/257/215.md +63 -0
- package/skills/devbooks-spec-contract/references//351/232/220/345/274/217/345/217/230/346/233/264/346/243/200/346/265/213/346/217/220/347/244/272/350/257/215.md +183 -0
- package/skills/devbooks-spec-contract/scripts/implicit-change-detect.sh +378 -0
- package/skills/devbooks-spec-gardener/SKILL.md +72 -0
- package/skills/devbooks-spec-gardener/references//350/247/204/346/240/274/345/233/255/344/270/201/346/217/220/347/244/272/350/257/215.md +41 -0
- package/skills/devbooks-test-owner/SKILL.md +172 -0
- package/skills/devbooks-test-owner/references//345/217/230/346/233/264/351/252/214/350/257/201/344/270/216/350/277/275/346/272/257/346/250/241/346/235/277.md +228 -0
- package/skills/devbooks-test-owner/references//345/274/202/346/255/245/347/263/273/347/273/237/346/265/213/350/257/225/347/255/226/347/225/245.md +316 -0
- package/skills/devbooks-test-owner/references//346/265/213/350/257/225/344/273/243/347/240/201/346/217/220/347/244/272/350/257/215.md +208 -0
- package/skills/devbooks-test-owner/references//346/265/213/350/257/225/345/210/206/345/261/202/347/255/226/347/225/245.md +281 -0
- package/skills/devbooks-test-owner/references//346/265/213/350/257/225/351/251/261/345/212/250.md +394 -0
- package/skills/devbooks-test-owner/references//350/247/243/344/276/235/350/265/226/346/212/200/346/234/257/351/200/237/346/237/245/350/241/250.md +432 -0
- package/skills/devbooks-test-reviewer/SKILL.md +189 -0
- package/templates/.devbooks/config.yaml +88 -0
- package/templates/claude-commands/devbooks/apply.md +38 -0
- package/templates/claude-commands/devbooks/archive.md +33 -0
- package/templates/claude-commands/devbooks/backport.md +19 -0
- package/templates/claude-commands/devbooks/bootstrap.md +19 -0
- package/templates/claude-commands/devbooks/c4.md +19 -0
- package/templates/claude-commands/devbooks/challenger.md +19 -0
- package/templates/claude-commands/devbooks/code.md +19 -0
- package/templates/claude-commands/devbooks/debate.md +19 -0
- package/templates/claude-commands/devbooks/delivery.md +19 -0
- package/templates/claude-commands/devbooks/design.md +19 -0
- package/templates/claude-commands/devbooks/entropy.md +19 -0
- package/templates/claude-commands/devbooks/federation.md +19 -0
- package/templates/claude-commands/devbooks/gardener.md +19 -0
- package/templates/claude-commands/devbooks/impact.md +19 -0
- package/templates/claude-commands/devbooks/index.md +19 -0
- package/templates/claude-commands/devbooks/judge.md +19 -0
- package/templates/claude-commands/devbooks/plan.md +19 -0
- package/templates/claude-commands/devbooks/proposal.md +19 -0
- package/templates/claude-commands/devbooks/quick.md +42 -0
- package/templates/claude-commands/devbooks/review.md +19 -0
- package/templates/claude-commands/devbooks/router.md +19 -0
- package/templates/claude-commands/devbooks/spec.md +19 -0
- package/templates/claude-commands/devbooks/test-review.md +19 -0
- package/templates/claude-commands/devbooks/test.md +19 -0
- package/templates/dev-playbooks/README.md +458 -0
- package/templates/dev-playbooks/changes/.gitkeep +1 -0
- package/templates/dev-playbooks/constitution.md +116 -0
- package/templates/dev-playbooks/project.md +96 -0
- package/templates/dev-playbooks/scripts/.gitkeep +1 -0
- package/templates/dev-playbooks/specs/_meta/anti-patterns/.gitkeep +2 -0
- package/templates/dev-playbooks/specs/_meta/glossary.md +47 -0
- package/templates/dev-playbooks/specs/_meta/project-profile.md +79 -0
- package/templates/dev-playbooks/specs/architecture/fitness-rules.md +95 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# skills/devbooks-delivery-workflow/scripts/migrate-to-devbooks-2.sh
|
|
3
|
+
# OpenSpec -> DevBooks 2.0 Migration Script
|
|
4
|
+
#
|
|
5
|
+
# Migrate dev-playbooks/ directory structure to dev-playbooks/.
|
|
6
|
+
# Supports idempotent execution, state checkpoints, and reference updates.
|
|
7
|
+
#
|
|
8
|
+
# Usage:
|
|
9
|
+
# ./migrate-to-devbooks-2.sh [options]
|
|
10
|
+
# ./migrate-to-devbooks-2.sh --help
|
|
11
|
+
#
|
|
12
|
+
# Exit codes:
|
|
13
|
+
# 0 - Migration successful
|
|
14
|
+
# 1 - Migration failed
|
|
15
|
+
# 2 - Usage error
|
|
16
|
+
|
|
17
|
+
set -euo pipefail
|
|
18
|
+
|
|
19
|
+
VERSION="1.0.0"
|
|
20
|
+
|
|
21
|
+
# Default configuration
|
|
22
|
+
project_root="."
|
|
23
|
+
dry_run=false
|
|
24
|
+
keep_old=false
|
|
25
|
+
force=false
|
|
26
|
+
checkpoint_file=""
|
|
27
|
+
|
|
28
|
+
# Color definitions
|
|
29
|
+
RED='\033[0;31m'
|
|
30
|
+
GREEN='\033[0;32m'
|
|
31
|
+
YELLOW='\033[0;33m'
|
|
32
|
+
BLUE='\033[0;34m'
|
|
33
|
+
NC='\033[0m'
|
|
34
|
+
|
|
35
|
+
show_help() {
|
|
36
|
+
cat << 'EOF'
|
|
37
|
+
OpenSpec -> DevBooks 2.0 Migration Script (migrate-to-devbooks-2.sh)
|
|
38
|
+
|
|
39
|
+
Usage:
|
|
40
|
+
./migrate-to-devbooks-2.sh [options]
|
|
41
|
+
|
|
42
|
+
Options:
|
|
43
|
+
--project-root DIR Project root directory (default: current directory)
|
|
44
|
+
--dry-run Simulate run, do not actually modify files
|
|
45
|
+
--keep-old Keep dev-playbooks/ directory after migration
|
|
46
|
+
--force Force re-execute all steps (ignore checkpoints)
|
|
47
|
+
--help, -h Show help
|
|
48
|
+
|
|
49
|
+
Migration Steps:
|
|
50
|
+
1. [STRUCTURE] Create dev-playbooks/ directory structure
|
|
51
|
+
2. [CONTENT] Migrate specs/ and changes/ content
|
|
52
|
+
3. [CONFIG] Create/update .devbooks/config.yaml
|
|
53
|
+
4. [REFS] Update path references in all documents
|
|
54
|
+
5. [CLEANUP] Cleanup (optionally keep old directory)
|
|
55
|
+
|
|
56
|
+
Features:
|
|
57
|
+
- Idempotent execution: safe to run repeatedly
|
|
58
|
+
- State checkpoints: supports resume from breakpoint
|
|
59
|
+
- Reference updates: automatic batch path replacement
|
|
60
|
+
- Rollback support: use with migrate-from-openspec.sh
|
|
61
|
+
|
|
62
|
+
EOF
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
log_info() { echo -e "${BLUE}[INFO]${NC} $*"; }
|
|
66
|
+
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*" >&2; }
|
|
67
|
+
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
|
|
68
|
+
log_pass() { echo -e "${GREEN}[PASS]${NC} $*"; }
|
|
69
|
+
log_step() { echo -e "${BLUE}[STEP]${NC} $*"; }
|
|
70
|
+
|
|
71
|
+
# Checkpoint management
|
|
72
|
+
init_checkpoint() {
|
|
73
|
+
checkpoint_file="${project_root}/.devbooks/.migrate-checkpoint"
|
|
74
|
+
if [[ "$force" == true ]]; then
|
|
75
|
+
rm -f "$checkpoint_file" 2>/dev/null || true
|
|
76
|
+
fi
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
save_checkpoint() {
|
|
80
|
+
local step="$1"
|
|
81
|
+
if [[ "$dry_run" == false ]]; then
|
|
82
|
+
mkdir -p "$(dirname "$checkpoint_file")"
|
|
83
|
+
echo "$step" >> "$checkpoint_file"
|
|
84
|
+
fi
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
is_step_done() {
|
|
88
|
+
local step="$1"
|
|
89
|
+
if [[ -f "$checkpoint_file" ]]; then
|
|
90
|
+
grep -qx "$step" "$checkpoint_file" 2>/dev/null
|
|
91
|
+
return $?
|
|
92
|
+
fi
|
|
93
|
+
return 1
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# Step 1: Create directory structure
|
|
97
|
+
step_structure() {
|
|
98
|
+
log_step "1. Creating directory structure"
|
|
99
|
+
|
|
100
|
+
if is_step_done "STRUCTURE" && [[ "$force" == false ]]; then
|
|
101
|
+
log_info "Directory structure already created (skipping)"
|
|
102
|
+
return 0
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
local dirs=(
|
|
106
|
+
"dev-playbooks"
|
|
107
|
+
"dev-playbooks/specs"
|
|
108
|
+
"dev-playbooks/specs/_meta"
|
|
109
|
+
"dev-playbooks/specs/_meta/anti-patterns"
|
|
110
|
+
"dev-playbooks/specs/_staged"
|
|
111
|
+
"dev-playbooks/specs/architecture"
|
|
112
|
+
"dev-playbooks/changes"
|
|
113
|
+
"dev-playbooks/changes/archive"
|
|
114
|
+
"dev-playbooks/scripts"
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
for dir in "${dirs[@]}"; do
|
|
118
|
+
local full_path="${project_root}/${dir}"
|
|
119
|
+
if [[ ! -d "$full_path" ]]; then
|
|
120
|
+
if [[ "$dry_run" == true ]]; then
|
|
121
|
+
log_info "[DRY-RUN] mkdir -p $full_path"
|
|
122
|
+
else
|
|
123
|
+
mkdir -p "$full_path"
|
|
124
|
+
fi
|
|
125
|
+
fi
|
|
126
|
+
done
|
|
127
|
+
|
|
128
|
+
save_checkpoint "STRUCTURE"
|
|
129
|
+
log_pass "Directory structure creation complete"
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# Step 2: Migrate content
|
|
133
|
+
step_content() {
|
|
134
|
+
log_step "2. Migrating content"
|
|
135
|
+
|
|
136
|
+
if is_step_done "CONTENT" && [[ "$force" == false ]]; then
|
|
137
|
+
log_info "Content already migrated (skipping)"
|
|
138
|
+
return 0
|
|
139
|
+
fi
|
|
140
|
+
|
|
141
|
+
local openspec_dir="${project_root}/openspec"
|
|
142
|
+
|
|
143
|
+
if [[ ! -d "$openspec_dir" ]]; then
|
|
144
|
+
log_warn "dev-playbooks/ directory does not exist, skipping content migration"
|
|
145
|
+
save_checkpoint "CONTENT"
|
|
146
|
+
return 0
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
# Migrate specs/
|
|
150
|
+
if [[ -d "${openspec_dir}/specs" ]]; then
|
|
151
|
+
log_info "Migrating specs/ ..."
|
|
152
|
+
if [[ "$dry_run" == true ]]; then
|
|
153
|
+
log_info "[DRY-RUN] cp -r ${openspec_dir}/specs/* ${project_root}/dev-playbooks/specs/"
|
|
154
|
+
else
|
|
155
|
+
cp -r "${openspec_dir}/specs/"* "${project_root}/dev-playbooks/specs/" 2>/dev/null || true
|
|
156
|
+
fi
|
|
157
|
+
fi
|
|
158
|
+
|
|
159
|
+
# Migrate changes/
|
|
160
|
+
if [[ -d "${openspec_dir}/changes" ]]; then
|
|
161
|
+
log_info "Migrating changes/ ..."
|
|
162
|
+
if [[ "$dry_run" == true ]]; then
|
|
163
|
+
log_info "[DRY-RUN] cp -r ${openspec_dir}/changes/* ${project_root}/dev-playbooks/changes/"
|
|
164
|
+
else
|
|
165
|
+
cp -r "${openspec_dir}/changes/"* "${project_root}/dev-playbooks/changes/" 2>/dev/null || true
|
|
166
|
+
fi
|
|
167
|
+
fi
|
|
168
|
+
|
|
169
|
+
# Migrate project.md
|
|
170
|
+
if [[ -f "${openspec_dir}/project.md" ]]; then
|
|
171
|
+
log_info "Migrating project.md ..."
|
|
172
|
+
if [[ "$dry_run" == true ]]; then
|
|
173
|
+
log_info "[DRY-RUN] cp ${openspec_dir}/project.md ${project_root}/dev-playbooks/project.md"
|
|
174
|
+
else
|
|
175
|
+
cp "${openspec_dir}/project.md" "${project_root}/dev-playbooks/project.md" 2>/dev/null || true
|
|
176
|
+
fi
|
|
177
|
+
fi
|
|
178
|
+
|
|
179
|
+
save_checkpoint "CONTENT"
|
|
180
|
+
log_pass "Content migration complete"
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
# Step 3: Create/update configuration
|
|
184
|
+
step_config() {
|
|
185
|
+
log_step "3. Creating/updating configuration"
|
|
186
|
+
|
|
187
|
+
if is_step_done "CONFIG" && [[ "$force" == false ]]; then
|
|
188
|
+
log_info "Configuration already updated (skipping)"
|
|
189
|
+
return 0
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
local config_dir="${project_root}/.devbooks"
|
|
193
|
+
local config_file="${config_dir}/config.yaml"
|
|
194
|
+
|
|
195
|
+
if [[ "$dry_run" == true ]]; then
|
|
196
|
+
log_info "[DRY-RUN] Creating/updating ${config_file}"
|
|
197
|
+
else
|
|
198
|
+
mkdir -p "$config_dir"
|
|
199
|
+
|
|
200
|
+
# If configuration file does not exist or needs updating
|
|
201
|
+
if [[ ! -f "$config_file" ]] || grep -q "root: dev-playbooks/" "$config_file" 2>/dev/null; then
|
|
202
|
+
cat > "$config_file" << 'YAML'
|
|
203
|
+
# DevBooks 2.0 Configuration
|
|
204
|
+
# Generated by migrate-to-devbooks-2.sh
|
|
205
|
+
|
|
206
|
+
root: dev-playbooks/
|
|
207
|
+
constitution: constitution.md
|
|
208
|
+
project: project.md
|
|
209
|
+
|
|
210
|
+
paths:
|
|
211
|
+
specs: specs/
|
|
212
|
+
changes: changes/
|
|
213
|
+
staged: specs/_staged/
|
|
214
|
+
archive: changes/archive/
|
|
215
|
+
|
|
216
|
+
constraints:
|
|
217
|
+
require_constitution: true
|
|
218
|
+
allow_legacy_protocol: false
|
|
219
|
+
|
|
220
|
+
fitness:
|
|
221
|
+
mode: warn
|
|
222
|
+
rules_file: specs/architecture/fitness-rules.md
|
|
223
|
+
|
|
224
|
+
tracing:
|
|
225
|
+
coverage_threshold: 80
|
|
226
|
+
evidence_dir: evidence/
|
|
227
|
+
YAML
|
|
228
|
+
fi
|
|
229
|
+
fi
|
|
230
|
+
|
|
231
|
+
save_checkpoint "CONFIG"
|
|
232
|
+
log_pass "Configuration update complete"
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
# Step 4: Update references
|
|
236
|
+
step_refs() {
|
|
237
|
+
log_step "4. Updating path references"
|
|
238
|
+
|
|
239
|
+
if is_step_done "REFS" && [[ "$force" == false ]]; then
|
|
240
|
+
log_info "References already updated (skipping)"
|
|
241
|
+
return 0
|
|
242
|
+
fi
|
|
243
|
+
|
|
244
|
+
local files_updated=0
|
|
245
|
+
|
|
246
|
+
# Find files that need updating
|
|
247
|
+
while IFS= read -r file; do
|
|
248
|
+
[[ -z "$file" ]] && continue
|
|
249
|
+
[[ ! -f "$file" ]] && continue
|
|
250
|
+
|
|
251
|
+
# Skip binary files and .git directory
|
|
252
|
+
[[ "$file" == *".git"* ]] && continue
|
|
253
|
+
[[ "$file" == *".png" ]] && continue
|
|
254
|
+
[[ "$file" == *".jpg" ]] && continue
|
|
255
|
+
[[ "$file" == *".ico" ]] && continue
|
|
256
|
+
|
|
257
|
+
# Check if contains dev-playbooks/ references
|
|
258
|
+
if grep -q "dev-playbooks/" "$file" 2>/dev/null; then
|
|
259
|
+
if [[ "$dry_run" == true ]]; then
|
|
260
|
+
log_info "[DRY-RUN] Updating references: $file"
|
|
261
|
+
else
|
|
262
|
+
# macOS compatible sed
|
|
263
|
+
if [[ "$(uname)" == "Darwin" ]]; then
|
|
264
|
+
sed -i '' 's|dev-playbooks/|dev-playbooks/|g' "$file"
|
|
265
|
+
else
|
|
266
|
+
sed -i 's|dev-playbooks/|dev-playbooks/|g' "$file"
|
|
267
|
+
fi
|
|
268
|
+
fi
|
|
269
|
+
files_updated=$((files_updated + 1))
|
|
270
|
+
fi
|
|
271
|
+
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)
|
|
272
|
+
|
|
273
|
+
save_checkpoint "REFS"
|
|
274
|
+
log_pass "Updated references in ${files_updated} files"
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
# Step 5: Cleanup
|
|
278
|
+
step_cleanup() {
|
|
279
|
+
log_step "5. Cleanup"
|
|
280
|
+
|
|
281
|
+
if is_step_done "CLEANUP" && [[ "$force" == false ]]; then
|
|
282
|
+
log_info "Cleanup already complete (skipping)"
|
|
283
|
+
return 0
|
|
284
|
+
fi
|
|
285
|
+
|
|
286
|
+
local openspec_dir="${project_root}/openspec"
|
|
287
|
+
|
|
288
|
+
if [[ "$keep_old" == true ]]; then
|
|
289
|
+
log_info "Keeping dev-playbooks/ directory (--keep-old)"
|
|
290
|
+
elif [[ -d "$openspec_dir" ]]; then
|
|
291
|
+
if [[ "$dry_run" == true ]]; then
|
|
292
|
+
log_info "[DRY-RUN] rm -rf $openspec_dir"
|
|
293
|
+
else
|
|
294
|
+
# Create backup
|
|
295
|
+
local backup_dir="${project_root}/.devbooks/backup/openspec-$(date +%Y%m%d%H%M%S)"
|
|
296
|
+
mkdir -p "$(dirname "$backup_dir")"
|
|
297
|
+
mv "$openspec_dir" "$backup_dir"
|
|
298
|
+
log_info "Backed up dev-playbooks/ to ${backup_dir}"
|
|
299
|
+
fi
|
|
300
|
+
fi
|
|
301
|
+
|
|
302
|
+
save_checkpoint "CLEANUP"
|
|
303
|
+
log_pass "Cleanup complete"
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
# Verify migration result
|
|
307
|
+
verify_migration() {
|
|
308
|
+
log_step "Verifying migration result"
|
|
309
|
+
|
|
310
|
+
local errors=0
|
|
311
|
+
|
|
312
|
+
# Check directory structure
|
|
313
|
+
local required_dirs=(
|
|
314
|
+
"dev-playbooks"
|
|
315
|
+
"dev-playbooks/specs"
|
|
316
|
+
"dev-playbooks/changes"
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
for dir in "${required_dirs[@]}"; do
|
|
320
|
+
if [[ ! -d "${project_root}/${dir}" ]]; then
|
|
321
|
+
log_error "Missing directory: $dir"
|
|
322
|
+
errors=$((errors + 1))
|
|
323
|
+
fi
|
|
324
|
+
done
|
|
325
|
+
|
|
326
|
+
# Check configuration file
|
|
327
|
+
if [[ ! -f "${project_root}/.devbooks/config.yaml" ]]; then
|
|
328
|
+
log_error "Missing configuration file: .devbooks/config.yaml"
|
|
329
|
+
errors=$((errors + 1))
|
|
330
|
+
fi
|
|
331
|
+
|
|
332
|
+
# Check remaining references (warning only)
|
|
333
|
+
local remaining_refs
|
|
334
|
+
remaining_refs=$(grep -r "dev-playbooks/" "${project_root}" --include="*.md" --include="*.yaml" --include="*.sh" 2>/dev/null | grep -v ".devbooks/backup" | wc -l || echo "0")
|
|
335
|
+
if [[ "$remaining_refs" -gt 0 ]]; then
|
|
336
|
+
log_warn "Still ${remaining_refs} dev-playbooks/ references remaining"
|
|
337
|
+
fi
|
|
338
|
+
|
|
339
|
+
if [[ "$errors" -eq 0 ]]; then
|
|
340
|
+
log_pass "Migration verification passed"
|
|
341
|
+
return 0
|
|
342
|
+
else
|
|
343
|
+
log_error "Migration verification failed, ${errors} errors"
|
|
344
|
+
return 1
|
|
345
|
+
fi
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
main() {
|
|
349
|
+
while [[ $# -gt 0 ]]; do
|
|
350
|
+
case "$1" in
|
|
351
|
+
--help|-h) show_help; exit 0 ;;
|
|
352
|
+
--version|-v) echo "migrate-to-devbooks-2.sh v${VERSION}"; exit 0 ;;
|
|
353
|
+
--project-root) project_root="${2:-.}"; shift 2 ;;
|
|
354
|
+
--dry-run) dry_run=true; shift ;;
|
|
355
|
+
--keep-old) keep_old=true; shift ;;
|
|
356
|
+
--force) force=true; shift ;;
|
|
357
|
+
-*) log_error "Unknown option: $1"; exit 2 ;;
|
|
358
|
+
*) log_error "Unknown argument: $1"; exit 2 ;;
|
|
359
|
+
esac
|
|
360
|
+
done
|
|
361
|
+
|
|
362
|
+
log_info "OpenSpec -> DevBooks 2.0 Migration"
|
|
363
|
+
log_info "Project root: ${project_root}"
|
|
364
|
+
[[ "$dry_run" == true ]] && log_info "Mode: DRY-RUN"
|
|
365
|
+
[[ "$force" == true ]] && log_info "Mode: FORCE"
|
|
366
|
+
|
|
367
|
+
init_checkpoint
|
|
368
|
+
|
|
369
|
+
# Execute migration steps
|
|
370
|
+
step_structure
|
|
371
|
+
step_content
|
|
372
|
+
step_config
|
|
373
|
+
step_refs
|
|
374
|
+
step_cleanup
|
|
375
|
+
|
|
376
|
+
# Verify
|
|
377
|
+
if [[ "$dry_run" == false ]]; then
|
|
378
|
+
verify_migration
|
|
379
|
+
fi
|
|
380
|
+
|
|
381
|
+
log_pass "Migration complete!"
|
|
382
|
+
exit 0
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
main "$@"
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# migrate-to-v2-gates.sh - Help existing change packages comply with v2 quality gates
|
|
3
|
+
#
|
|
4
|
+
# This script creates missing evidence directories and adds required sections
|
|
5
|
+
# to verification.md to help existing change packages pass the new quality gates.
|
|
6
|
+
#
|
|
7
|
+
# Reference: harden-devbooks-quality-gates design.md AC-001, AC-002, AC-006
|
|
8
|
+
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
usage() {
|
|
12
|
+
cat <<'EOF' >&2
|
|
13
|
+
usage: migrate-to-v2-gates.sh <change-id> [options]
|
|
14
|
+
|
|
15
|
+
Migrate a change package to comply with v2 quality gates:
|
|
16
|
+
1. Creates evidence/red-baseline/ and evidence/green-final/ directories if missing
|
|
17
|
+
2. Adds "Test Environment Declaration" section to verification.md if missing
|
|
18
|
+
3. Reports migration status
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
--project-root <dir> Project root directory (default: pwd)
|
|
22
|
+
--change-root <dir> Change packages root (default: changes)
|
|
23
|
+
--dry-run Show what would be done without making changes
|
|
24
|
+
-h, --help Show this help message
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
migrate-to-v2-gates.sh my-change-001
|
|
28
|
+
migrate-to-v2-gates.sh my-change-001 --dry-run
|
|
29
|
+
migrate-to-v2-gates.sh my-change-001 --change-root dev-playbooks/changes
|
|
30
|
+
EOF
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if [[ $# -eq 0 ]]; then
|
|
34
|
+
usage
|
|
35
|
+
exit 2
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
|
39
|
+
usage
|
|
40
|
+
exit 0
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
change_id="$1"
|
|
44
|
+
shift
|
|
45
|
+
|
|
46
|
+
project_root="${DEVBOOKS_PROJECT_ROOT:-$(pwd)}"
|
|
47
|
+
change_root="${DEVBOOKS_CHANGE_ROOT:-changes}"
|
|
48
|
+
dry_run=false
|
|
49
|
+
|
|
50
|
+
while [[ $# -gt 0 ]]; do
|
|
51
|
+
case "$1" in
|
|
52
|
+
-h|--help)
|
|
53
|
+
usage
|
|
54
|
+
exit 0
|
|
55
|
+
;;
|
|
56
|
+
--project-root)
|
|
57
|
+
project_root="${2:-}"
|
|
58
|
+
shift 2
|
|
59
|
+
;;
|
|
60
|
+
--change-root)
|
|
61
|
+
change_root="${2:-}"
|
|
62
|
+
shift 2
|
|
63
|
+
;;
|
|
64
|
+
--dry-run)
|
|
65
|
+
dry_run=true
|
|
66
|
+
shift
|
|
67
|
+
;;
|
|
68
|
+
*)
|
|
69
|
+
echo "error: unknown option: $1" >&2
|
|
70
|
+
usage
|
|
71
|
+
exit 2
|
|
72
|
+
;;
|
|
73
|
+
esac
|
|
74
|
+
done
|
|
75
|
+
|
|
76
|
+
# Validate change-id
|
|
77
|
+
if [[ -z "$change_id" || "$change_id" == "-"* || "$change_id" =~ [[:space:]] ]]; then
|
|
78
|
+
echo "error: invalid change-id: '$change_id'" >&2
|
|
79
|
+
exit 2
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# Build paths
|
|
83
|
+
project_root="${project_root%/}"
|
|
84
|
+
change_root="${change_root%/}"
|
|
85
|
+
|
|
86
|
+
if [[ "$change_root" = /* ]]; then
|
|
87
|
+
change_dir="${change_root}/${change_id}"
|
|
88
|
+
else
|
|
89
|
+
change_dir="${project_root}/${change_root}/${change_id}"
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
verification_file="${change_dir}/verification.md"
|
|
93
|
+
evidence_dir="${change_dir}/evidence"
|
|
94
|
+
red_baseline="${evidence_dir}/red-baseline"
|
|
95
|
+
green_final="${evidence_dir}/green-final"
|
|
96
|
+
|
|
97
|
+
# Check change directory exists
|
|
98
|
+
if [[ ! -d "$change_dir" ]]; then
|
|
99
|
+
echo "error: change directory not found: ${change_dir}" >&2
|
|
100
|
+
exit 1
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
echo "migrate-to-v2-gates: migrating '${change_id}'"
|
|
104
|
+
echo " change-dir: ${change_dir}"
|
|
105
|
+
echo " dry-run: ${dry_run}"
|
|
106
|
+
echo ""
|
|
107
|
+
|
|
108
|
+
changes_made=0
|
|
109
|
+
issues_found=0
|
|
110
|
+
|
|
111
|
+
# 1. Create evidence directories
|
|
112
|
+
echo "=== Checking evidence directories ==="
|
|
113
|
+
|
|
114
|
+
if [[ ! -d "$red_baseline" ]]; then
|
|
115
|
+
echo " [MISSING] evidence/red-baseline/"
|
|
116
|
+
if [[ "$dry_run" == false ]]; then
|
|
117
|
+
mkdir -p "$red_baseline"
|
|
118
|
+
echo "README.md" > "${red_baseline}/.gitkeep"
|
|
119
|
+
echo " [CREATED] evidence/red-baseline/"
|
|
120
|
+
changes_made=$((changes_made + 1))
|
|
121
|
+
else
|
|
122
|
+
echo " [DRY-RUN] Would create evidence/red-baseline/"
|
|
123
|
+
fi
|
|
124
|
+
else
|
|
125
|
+
echo " [OK] evidence/red-baseline/"
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
if [[ ! -d "$green_final" ]]; then
|
|
129
|
+
echo " [MISSING] evidence/green-final/"
|
|
130
|
+
if [[ "$dry_run" == false ]]; then
|
|
131
|
+
mkdir -p "$green_final"
|
|
132
|
+
echo "# Green Final Evidence" > "${green_final}/.gitkeep"
|
|
133
|
+
echo " [CREATED] evidence/green-final/"
|
|
134
|
+
changes_made=$((changes_made + 1))
|
|
135
|
+
else
|
|
136
|
+
echo " [DRY-RUN] Would create evidence/green-final/"
|
|
137
|
+
fi
|
|
138
|
+
else
|
|
139
|
+
echo " [OK] evidence/green-final/"
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
|
+
# 2. Check verification.md for test environment declaration
|
|
143
|
+
echo ""
|
|
144
|
+
echo "=== Checking verification.md ==="
|
|
145
|
+
|
|
146
|
+
if [[ ! -f "$verification_file" ]]; then
|
|
147
|
+
echo " [MISSING] verification.md - cannot add sections"
|
|
148
|
+
issues_found=$((issues_found + 1))
|
|
149
|
+
else
|
|
150
|
+
# Check for test environment declaration section
|
|
151
|
+
if ! grep -q "Test Environment Declaration" "$verification_file" 2>/dev/null; then
|
|
152
|
+
echo " [MISSING] Test Environment Declaration section"
|
|
153
|
+
if [[ "$dry_run" == false ]]; then
|
|
154
|
+
# Add section before last heading or at end
|
|
155
|
+
cat >> "$verification_file" << 'EOF'
|
|
156
|
+
|
|
157
|
+
## Test Environment Declaration
|
|
158
|
+
|
|
159
|
+
> Automatically added by migrate-to-v2-gates.sh, please fill in actual environment info
|
|
160
|
+
|
|
161
|
+
- Runtime: <macOS / Linux / Windows / CI>
|
|
162
|
+
- Database: <N/A / MySQL / PostgreSQL / ...>
|
|
163
|
+
- External Dependencies: <None / specific service names>
|
|
164
|
+
- Special Configuration: <None / specific configuration>
|
|
165
|
+
EOF
|
|
166
|
+
echo " [ADDED] Test Environment Declaration section to verification.md"
|
|
167
|
+
changes_made=$((changes_made + 1))
|
|
168
|
+
else
|
|
169
|
+
echo " [DRY-RUN] Would add Test Environment Declaration section"
|
|
170
|
+
fi
|
|
171
|
+
else
|
|
172
|
+
echo " [OK] Test Environment Declaration section exists"
|
|
173
|
+
fi
|
|
174
|
+
fi
|
|
175
|
+
|
|
176
|
+
# 3. Summary
|
|
177
|
+
echo ""
|
|
178
|
+
echo "=== Migration Summary ==="
|
|
179
|
+
if [[ "$dry_run" == true ]]; then
|
|
180
|
+
echo " Mode: dry-run (no changes made)"
|
|
181
|
+
else
|
|
182
|
+
echo " Changes made: ${changes_made}"
|
|
183
|
+
fi
|
|
184
|
+
echo " Issues found: ${issues_found}"
|
|
185
|
+
|
|
186
|
+
if [[ $issues_found -gt 0 ]]; then
|
|
187
|
+
echo ""
|
|
188
|
+
echo "warn: some issues require manual attention"
|
|
189
|
+
exit 1
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
if [[ $changes_made -gt 0 || "$dry_run" == true ]]; then
|
|
193
|
+
echo ""
|
|
194
|
+
echo "Next steps:"
|
|
195
|
+
echo " 1. Add actual Red baseline evidence to evidence/red-baseline/"
|
|
196
|
+
echo " 2. After tests pass, add Green evidence to evidence/green-final/"
|
|
197
|
+
echo " 3. Update Test Environment Declaration section in verification.md with actual environment"
|
|
198
|
+
echo " 4. Run 'change-check.sh ${change_id} --mode archive' to verify compliance"
|
|
199
|
+
fi
|
|
200
|
+
|
|
201
|
+
echo ""
|
|
202
|
+
echo "ok: migration complete"
|