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.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +466 -0
  3. package/bin/devbooks.js +987 -0
  4. package/package.json +43 -0
  5. package/skills/Skills/344/275/277/347/224/250/350/257/264/346/230/216.md +446 -0
  6. package/skills/Skill/345/274/200/345/217/221/346/214/207/345/215/227.md +248 -0
  7. package/skills/_shared/context-detection-template.md +315 -0
  8. package/skills/_shared/mcp-enhancement-template.md +144 -0
  9. 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
  10. package/skills/_template/config-discovery-template.md +126 -0
  11. package/skills/devbooks-brownfield-bootstrap/SKILL.md +167 -0
  12. 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
  13. 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
  14. 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
  15. package/skills/devbooks-brownfield-bootstrap/references//346/234/257/350/257/255/350/241/250/346/250/241/346/235/277.md +42 -0
  16. package/skills/devbooks-brownfield-bootstrap/scripts/cod-update.sh +357 -0
  17. package/skills/devbooks-brownfield-bootstrap/templates/project-profile-template.md +172 -0
  18. package/skills/devbooks-c4-map/SKILL.md +151 -0
  19. 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
  20. 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
  21. package/skills/devbooks-code-review/SKILL.md +175 -0
  22. 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
  23. 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
  24. 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
  25. 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
  26. package/skills/devbooks-coder/SKILL.md +219 -0
  27. 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
  28. 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
  29. package/skills/devbooks-coder/references//346/227/245/345/277/227/350/247/204/350/214/203.md +329 -0
  30. 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
  31. package/skills/devbooks-coder/references//351/224/231/350/257/257/347/240/201/350/247/204/350/214/203.md +463 -0
  32. package/skills/devbooks-delivery-workflow/SKILL.md +217 -0
  33. 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
  34. 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
  35. 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
  36. package/skills/devbooks-delivery-workflow/scripts/ac-trace-check.sh +330 -0
  37. package/skills/devbooks-delivery-workflow/scripts/audit-scope.sh +262 -0
  38. package/skills/devbooks-delivery-workflow/scripts/change-check.sh +1040 -0
  39. package/skills/devbooks-delivery-workflow/scripts/change-codemod-scaffold.sh +135 -0
  40. package/skills/devbooks-delivery-workflow/scripts/change-evidence.sh +152 -0
  41. package/skills/devbooks-delivery-workflow/scripts/change-scaffold.sh +442 -0
  42. package/skills/devbooks-delivery-workflow/scripts/change-spec-delta-scaffold.sh +136 -0
  43. package/skills/devbooks-delivery-workflow/scripts/constitution-check.sh +237 -0
  44. package/skills/devbooks-delivery-workflow/scripts/env-match-check.sh +128 -0
  45. package/skills/devbooks-delivery-workflow/scripts/fitness-check.sh +387 -0
  46. package/skills/devbooks-delivery-workflow/scripts/guardrail-check.sh +519 -0
  47. package/skills/devbooks-delivery-workflow/scripts/handoff-check.sh +141 -0
  48. package/skills/devbooks-delivery-workflow/scripts/hygiene-check.sh +340 -0
  49. package/skills/devbooks-delivery-workflow/scripts/migrate-from-openspec.sh +385 -0
  50. package/skills/devbooks-delivery-workflow/scripts/migrate-to-v2-gates.sh +202 -0
  51. package/skills/devbooks-delivery-workflow/scripts/progress-dashboard.sh +319 -0
  52. package/skills/devbooks-delivery-workflow/scripts/prototype-promote.sh +341 -0
  53. package/skills/devbooks-delivery-workflow/scripts/spec-preview.sh +203 -0
  54. package/skills/devbooks-delivery-workflow/scripts/spec-promote.sh +118 -0
  55. package/skills/devbooks-delivery-workflow/scripts/spec-rollback.sh +124 -0
  56. package/skills/devbooks-delivery-workflow/scripts/spec-stage.sh +117 -0
  57. package/skills/devbooks-delivery-workflow/scripts/verify-all.sh +78 -0
  58. package/skills/devbooks-delivery-workflow/scripts/verify-npm-package.sh +123 -0
  59. package/skills/devbooks-delivery-workflow/scripts/verify-openspec-free.sh +81 -0
  60. package/skills/devbooks-delivery-workflow/scripts/verify-slash-commands.sh +146 -0
  61. package/skills/devbooks-delivery-workflow/templates/handoff.md +50 -0
  62. package/skills/devbooks-design-backport/SKILL.md +73 -0
  63. 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
  64. package/skills/devbooks-design-doc/SKILL.md +121 -0
  65. 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
  66. 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
  67. 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
  68. package/skills/devbooks-entropy-monitor/SKILL.md +188 -0
  69. 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
  70. package/skills/devbooks-entropy-monitor/scripts/entropy-measure.sh +449 -0
  71. package/skills/devbooks-entropy-monitor/scripts/entropy-report.sh +303 -0
  72. package/skills/devbooks-entropy-monitor/templates/thresholds.json +99 -0
  73. package/skills/devbooks-federation/SKILL.md +264 -0
  74. package/skills/devbooks-federation/scripts/federation-check.sh +144 -0
  75. package/skills/devbooks-federation/templates/federation.yaml +89 -0
  76. package/skills/devbooks-impact-analysis/SKILL.md +135 -0
  77. 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
  78. package/skills/devbooks-impact-analysis/scripts/graph-cache.sh +214 -0
  79. package/skills/devbooks-implementation-plan/SKILL.md +83 -0
  80. 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
  81. package/skills/devbooks-index-bootstrap/SKILL.md +240 -0
  82. package/skills/devbooks-proposal-author/SKILL.md +83 -0
  83. 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
  84. package/skills/devbooks-proposal-challenger/SKILL.md +86 -0
  85. 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
  86. 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
  87. package/skills/devbooks-proposal-debate-workflow/SKILL.md +78 -0
  88. 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
  89. 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
  90. package/skills/devbooks-proposal-debate-workflow/scripts/proposal-debate-check.sh +102 -0
  91. package/skills/devbooks-proposal-judge/SKILL.md +78 -0
  92. 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
  93. package/skills/devbooks-router/SKILL.md +346 -0
  94. package/skills/devbooks-spec-contract/SKILL.md +191 -0
  95. package/skills/devbooks-spec-contract/references/API/350/256/276/350/256/241/346/214/207/345/215/227.md +349 -0
  96. 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
  97. 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
  98. 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
  99. package/skills/devbooks-spec-contract/scripts/implicit-change-detect.sh +378 -0
  100. package/skills/devbooks-spec-gardener/SKILL.md +72 -0
  101. 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
  102. package/skills/devbooks-test-owner/SKILL.md +172 -0
  103. 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
  104. 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
  105. 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
  106. 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
  107. package/skills/devbooks-test-owner/references//346/265/213/350/257/225/351/251/261/345/212/250.md +394 -0
  108. 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
  109. package/skills/devbooks-test-reviewer/SKILL.md +189 -0
  110. package/templates/.devbooks/config.yaml +88 -0
  111. package/templates/claude-commands/devbooks/apply.md +38 -0
  112. package/templates/claude-commands/devbooks/archive.md +33 -0
  113. package/templates/claude-commands/devbooks/backport.md +19 -0
  114. package/templates/claude-commands/devbooks/bootstrap.md +19 -0
  115. package/templates/claude-commands/devbooks/c4.md +19 -0
  116. package/templates/claude-commands/devbooks/challenger.md +19 -0
  117. package/templates/claude-commands/devbooks/code.md +19 -0
  118. package/templates/claude-commands/devbooks/debate.md +19 -0
  119. package/templates/claude-commands/devbooks/delivery.md +19 -0
  120. package/templates/claude-commands/devbooks/design.md +19 -0
  121. package/templates/claude-commands/devbooks/entropy.md +19 -0
  122. package/templates/claude-commands/devbooks/federation.md +19 -0
  123. package/templates/claude-commands/devbooks/gardener.md +19 -0
  124. package/templates/claude-commands/devbooks/impact.md +19 -0
  125. package/templates/claude-commands/devbooks/index.md +19 -0
  126. package/templates/claude-commands/devbooks/judge.md +19 -0
  127. package/templates/claude-commands/devbooks/plan.md +19 -0
  128. package/templates/claude-commands/devbooks/proposal.md +19 -0
  129. package/templates/claude-commands/devbooks/quick.md +42 -0
  130. package/templates/claude-commands/devbooks/review.md +19 -0
  131. package/templates/claude-commands/devbooks/router.md +19 -0
  132. package/templates/claude-commands/devbooks/spec.md +19 -0
  133. package/templates/claude-commands/devbooks/test-review.md +19 -0
  134. package/templates/claude-commands/devbooks/test.md +19 -0
  135. package/templates/dev-playbooks/README.md +458 -0
  136. package/templates/dev-playbooks/changes/.gitkeep +1 -0
  137. package/templates/dev-playbooks/constitution.md +116 -0
  138. package/templates/dev-playbooks/project.md +96 -0
  139. package/templates/dev-playbooks/scripts/.gitkeep +1 -0
  140. package/templates/dev-playbooks/specs/_meta/anti-patterns/.gitkeep +2 -0
  141. package/templates/dev-playbooks/specs/_meta/glossary.md +47 -0
  142. package/templates/dev-playbooks/specs/_meta/project-profile.md +79 -0
  143. package/templates/dev-playbooks/specs/architecture/fitness-rules.md +95 -0
@@ -0,0 +1,237 @@
1
+ #!/bin/bash
2
+ # skills/devbooks-delivery-workflow/scripts/constitution-check.sh
3
+ # Constitution Compliance Check Script
4
+ #
5
+ # Checks if the project's constitution.md exists and is correctly formatted.
6
+ #
7
+ # Usage:
8
+ # ./constitution-check.sh [project-root]
9
+ # ./constitution-check.sh --help
10
+ #
11
+ # Exit codes:
12
+ # 0 - Constitution exists and is valid
13
+ # 1 - Constitution missing or invalid
14
+ # 2 - Usage error
15
+
16
+ set -euo pipefail
17
+
18
+ # Color output
19
+ RED='\033[0;31m'
20
+ GREEN='\033[0;32m'
21
+ YELLOW='\033[0;33m'
22
+ NC='\033[0m' # No Color
23
+
24
+ # Version
25
+ VERSION="1.0.0"
26
+
27
+ # Show help
28
+ show_help() {
29
+ cat << 'EOF'
30
+ Constitution Compliance Check Script (constitution-check.sh)
31
+
32
+ Usage:
33
+ ./constitution-check.sh [options] [project-root]
34
+
35
+ Options:
36
+ --help, -h Show this help message
37
+ --version, -v Show version information
38
+ --quiet, -q Quiet mode, only output errors
39
+
40
+ Arguments:
41
+ project-root Project root directory, defaults to current directory
42
+
43
+ Checks:
44
+ 1. constitution.md file exists
45
+ 2. Contains "Part Zero" section
46
+ 3. Contains "GIP-" prefixed rules (at least 1)
47
+ 4. Contains "Escape Hatches" section
48
+
49
+ Exit codes:
50
+ 0 - Constitution exists and is valid
51
+ 1 - Constitution missing or invalid
52
+ 2 - Usage error
53
+
54
+ Examples:
55
+ ./constitution-check.sh # Check current directory
56
+ ./constitution-check.sh /path/to/project # Check specified directory
57
+ ./constitution-check.sh --quiet # Quiet mode
58
+
59
+ EOF
60
+ }
61
+
62
+ # Show version
63
+ show_version() {
64
+ echo "constitution-check.sh v${VERSION}"
65
+ }
66
+
67
+ # Log functions
68
+ log_info() {
69
+ [[ "$QUIET" == "false" ]] && echo -e "${GREEN}[INFO]${NC} $*"
70
+ }
71
+
72
+ log_warn() {
73
+ [[ "$QUIET" == "false" ]] && echo -e "${YELLOW}[WARN]${NC} $*" >&2
74
+ }
75
+
76
+ log_error() {
77
+ echo -e "${RED}[FAIL]${NC} $*" >&2
78
+ }
79
+
80
+ log_pass() {
81
+ [[ "$QUIET" == "false" ]] && echo -e "${GREEN}[PASS]${NC} $*"
82
+ }
83
+
84
+ # Resolve truth root directory
85
+ # Prioritize checking dev-playbooks/, fallback to devbooks/
86
+ resolve_truth_root() {
87
+ local root="$1"
88
+
89
+ # Check root configuration in .devbooks/config.yaml
90
+ if [[ -f "${root}/.devbooks/config.yaml" ]]; then
91
+ local config_root
92
+ config_root=$(grep "^root:" "${root}/.devbooks/config.yaml" 2>/dev/null | sed 's/root: *//' | tr -d "'" | tr -d '"' | tr -d '/' || true)
93
+ if [[ -n "$config_root" && -d "${root}/${config_root}" ]]; then
94
+ echo "${root}/${config_root}"
95
+ return 0
96
+ fi
97
+ fi
98
+
99
+ # Prioritize new path dev-playbooks/
100
+ if [[ -d "${root}/dev-playbooks" ]]; then
101
+ echo "${root}/dev-playbooks"
102
+ return 0
103
+ fi
104
+
105
+ # Fallback to old path devbooks/
106
+ if [[ -d "${root}/devbooks" ]]; then
107
+ echo "${root}/devbooks"
108
+ return 0
109
+ fi
110
+
111
+ # Not found
112
+ echo ""
113
+ return 1
114
+ }
115
+
116
+ # Check constitution
117
+ check_constitution() {
118
+ local root="${1:-.}"
119
+ local errors=0
120
+ local checks_passed=0
121
+ local total_checks=4
122
+
123
+ # Resolve truth root directory
124
+ local config_root
125
+ config_root=$(resolve_truth_root "$root") || {
126
+ log_error "Cannot find configuration root directory (dev-playbooks/ or devbooks/)"
127
+ return 1
128
+ }
129
+
130
+ local constitution="${config_root}/constitution.md"
131
+
132
+ log_info "Checking constitution file: $constitution"
133
+
134
+ # Check 1: File exists
135
+ if [[ -f "$constitution" ]]; then
136
+ log_pass "constitution.md exists"
137
+ ((checks_passed++))
138
+ else
139
+ log_error "constitution.md does not exist: $constitution"
140
+ ((errors++))
141
+ fi
142
+
143
+ # If file does not exist, return immediately
144
+ if [[ ! -f "$constitution" ]]; then
145
+ echo ""
146
+ log_error "Constitution check failed: $errors errors"
147
+ return 1
148
+ fi
149
+
150
+ # Check 2: Part Zero section
151
+ if grep -qE "^#+ *Part Zero" "$constitution" 2>/dev/null; then
152
+ log_pass "Contains 'Part Zero' section"
153
+ ((checks_passed++))
154
+ else
155
+ log_error "Missing 'Part Zero' section"
156
+ ((errors++))
157
+ fi
158
+
159
+ # Check 3: GIP rules
160
+ local gip_count
161
+ gip_count=$(grep -cE "^#+ *GIP-[0-9]+" "$constitution" 2>/dev/null || echo "0")
162
+ if [[ "$gip_count" -gt 0 ]]; then
163
+ log_pass "Contains GIP rules (${gip_count} rules)"
164
+ ((checks_passed++))
165
+ else
166
+ log_error "Missing GIP rules (need at least 1 GIP-xxx)"
167
+ ((errors++))
168
+ fi
169
+
170
+ # Check 4: Escape Hatches section
171
+ if grep -qE "^#+ *(Escape Hatches?)" "$constitution" 2>/dev/null; then
172
+ log_pass "Contains 'Escape Hatches' section"
173
+ ((checks_passed++))
174
+ else
175
+ log_error "Missing 'Escape Hatches' section"
176
+ ((errors++))
177
+ fi
178
+
179
+ # Output summary
180
+ echo ""
181
+ if [[ "$errors" -eq 0 ]]; then
182
+ log_info "Constitution check passed: ${checks_passed}/${total_checks} checks passed"
183
+ return 0
184
+ else
185
+ log_error "Constitution check failed: ${checks_passed}/${total_checks} checks passed, ${errors} errors"
186
+ return 1
187
+ fi
188
+ }
189
+
190
+ # Main function
191
+ main() {
192
+ QUIET="false"
193
+ local project_root="."
194
+
195
+ # Parse arguments
196
+ while [[ $# -gt 0 ]]; do
197
+ case "$1" in
198
+ --help|-h)
199
+ show_help
200
+ exit 0
201
+ ;;
202
+ --version|-v)
203
+ show_version
204
+ exit 0
205
+ ;;
206
+ --quiet|-q)
207
+ QUIET="true"
208
+ shift
209
+ ;;
210
+ -*)
211
+ log_error "Unknown option: $1"
212
+ echo "Use --help to see help" >&2
213
+ exit 2
214
+ ;;
215
+ *)
216
+ project_root="$1"
217
+ shift
218
+ ;;
219
+ esac
220
+ done
221
+
222
+ # Check project root directory
223
+ if [[ ! -d "$project_root" ]]; then
224
+ log_error "Project root directory does not exist: $project_root"
225
+ exit 2
226
+ fi
227
+
228
+ # Execute check
229
+ if check_constitution "$project_root"; then
230
+ exit 0
231
+ else
232
+ exit 1
233
+ fi
234
+ }
235
+
236
+ # Run main function
237
+ main "$@"
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env bash
2
+ # env-match-check.sh - Verify test environment declaration exists in verification.md
3
+ #
4
+ # This script checks that verification.md contains a test environment declaration
5
+ # section, which is required for archive mode to ensure reproducibility.
6
+ #
7
+ # Reference: harden-devbooks-quality-gates design.md AC-006
8
+
9
+ set -euo pipefail
10
+
11
+ usage() {
12
+ cat <<'EOF' >&2
13
+ usage: env-match-check.sh <change-id> [options]
14
+
15
+ Verify test environment declaration exists in verification.md:
16
+ 1. Checks verification.md exists
17
+ 2. Verifies "Test Environment Declaration" or "Test Environment" section exists
18
+ 3. Returns exit code based on verification status
19
+
20
+ Options:
21
+ --project-root <dir> Project root directory (default: pwd)
22
+ --change-root <dir> Change packages root (default: changes)
23
+ -h, --help Show this help message
24
+
25
+ Exit Codes:
26
+ 0 - Environment declaration found
27
+ 1 - Check failed (missing section)
28
+ 2 - Usage error
29
+
30
+ Examples:
31
+ env-match-check.sh my-change-001
32
+ env-match-check.sh my-change-001 --change-root dev-playbooks/changes
33
+ EOF
34
+ }
35
+
36
+ if [[ $# -eq 0 ]]; then
37
+ usage
38
+ exit 2
39
+ fi
40
+
41
+ if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
42
+ usage
43
+ exit 0
44
+ fi
45
+
46
+ change_id="$1"
47
+ shift
48
+
49
+ project_root="${DEVBOOKS_PROJECT_ROOT:-$(pwd)}"
50
+ change_root="${DEVBOOKS_CHANGE_ROOT:-changes}"
51
+
52
+ while [[ $# -gt 0 ]]; do
53
+ case "$1" in
54
+ -h|--help)
55
+ usage
56
+ exit 0
57
+ ;;
58
+ --project-root)
59
+ project_root="${2:-}"
60
+ shift 2
61
+ ;;
62
+ --change-root)
63
+ change_root="${2:-}"
64
+ shift 2
65
+ ;;
66
+ *)
67
+ echo "error: unknown option: $1" >&2
68
+ usage
69
+ exit 2
70
+ ;;
71
+ esac
72
+ done
73
+
74
+ # Validate change-id
75
+ if [[ -z "$change_id" || "$change_id" == "-"* || "$change_id" =~ [[:space:]] ]]; then
76
+ echo "error: invalid change-id: '$change_id'" >&2
77
+ exit 2
78
+ fi
79
+
80
+ # Build paths
81
+ project_root="${project_root%/}"
82
+ change_root="${change_root%/}"
83
+
84
+ if [[ "$change_root" = /* ]]; then
85
+ change_dir="${change_root}/${change_id}"
86
+ else
87
+ change_dir="${project_root}/${change_root}/${change_id}"
88
+ fi
89
+
90
+ verification_file="${change_dir}/verification.md"
91
+
92
+ echo "env-match-check: checking '${change_id}'"
93
+ echo " change-dir: ${change_dir}"
94
+
95
+ # Check change directory exists
96
+ if [[ ! -d "$change_dir" ]]; then
97
+ echo "error: missing change directory: ${change_dir}" >&2
98
+ exit 1
99
+ fi
100
+
101
+ # Check verification.md exists
102
+ if [[ ! -f "$verification_file" ]]; then
103
+ echo "error: missing verification.md: ${verification_file}" >&2
104
+ exit 1
105
+ fi
106
+
107
+ # Check for environment declaration section
108
+ # Accept both Chinese and English section names
109
+ env_section_pattern="Test Environment Declaration|Test Environment|Environment Declaration|Runtime Environment|测试环境声明|测试环境|环境声明|运行环境"
110
+
111
+ if grep -qE "^#+ *(${env_section_pattern})" "$verification_file" 2>/dev/null; then
112
+ echo "ok: environment declaration section found"
113
+ exit 0
114
+ fi
115
+
116
+ # Also check for environment content without explicit heading
117
+ # Pattern: lines starting with "- Runtime:" or "- Environment:" etc.
118
+ env_content_pattern="^- *((Runtime|Environment|Database|External)[::]|(运行环境|环境|数据库|外部依赖)[::])"
119
+
120
+ if grep -qE "${env_content_pattern}" "$verification_file" 2>/dev/null; then
121
+ echo "ok: environment declaration content found"
122
+ exit 0
123
+ fi
124
+
125
+ # No environment declaration found
126
+ echo "error: verification.md missing test environment declaration section" >&2
127
+ echo "hint: add a '## Test Environment Declaration' / '## 测试环境声明' section with runtime, database, and external dependency info" >&2
128
+ exit 1