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,340 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# hygiene-check.sh - Code hygiene check script (inspired by VS Code gulpfile.hygiene.ts)
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
usage() {
|
|
6
|
+
cat >&2 <<EOF
|
|
7
|
+
usage: hygiene-check.sh [options] [path...]
|
|
8
|
+
|
|
9
|
+
Options:
|
|
10
|
+
--project-root <dir> Project root directory (default: current dir)
|
|
11
|
+
--fix Attempt to fix issues automatically
|
|
12
|
+
--format-only Only check formatting
|
|
13
|
+
--lint-only Only check linting
|
|
14
|
+
--json Output results in JSON format
|
|
15
|
+
-h, --help Show this help message
|
|
16
|
+
|
|
17
|
+
Checks performed:
|
|
18
|
+
1. Formatting (prettier/editorconfig)
|
|
19
|
+
2. Linting (eslint/stylelint)
|
|
20
|
+
3. Copyright headers
|
|
21
|
+
4. No debug statements (console.log, debugger)
|
|
22
|
+
5. No test.only/describe.only
|
|
23
|
+
6. No TODO without issue reference
|
|
24
|
+
7. Trailing whitespace
|
|
25
|
+
8. File encoding (UTF-8)
|
|
26
|
+
|
|
27
|
+
Exit codes:
|
|
28
|
+
0 - All checks passed
|
|
29
|
+
1 - Hygiene violations detected
|
|
30
|
+
2 - Invalid arguments
|
|
31
|
+
3 - Missing dependencies
|
|
32
|
+
EOF
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
project_root="${DEVBOOKS_PROJECT_ROOT:-$(pwd)}"
|
|
36
|
+
fix_mode=false
|
|
37
|
+
format_only=false
|
|
38
|
+
lint_only=false
|
|
39
|
+
json_output=false
|
|
40
|
+
paths=()
|
|
41
|
+
|
|
42
|
+
while [[ $# -gt 0 ]]; do
|
|
43
|
+
case "$1" in
|
|
44
|
+
-h|--help)
|
|
45
|
+
usage
|
|
46
|
+
exit 0
|
|
47
|
+
;;
|
|
48
|
+
--project-root)
|
|
49
|
+
project_root="${2:-}"
|
|
50
|
+
shift 2
|
|
51
|
+
;;
|
|
52
|
+
--fix)
|
|
53
|
+
fix_mode=true
|
|
54
|
+
shift
|
|
55
|
+
;;
|
|
56
|
+
--format-only)
|
|
57
|
+
format_only=true
|
|
58
|
+
shift
|
|
59
|
+
;;
|
|
60
|
+
--lint-only)
|
|
61
|
+
lint_only=true
|
|
62
|
+
shift
|
|
63
|
+
;;
|
|
64
|
+
--json)
|
|
65
|
+
json_output=true
|
|
66
|
+
shift
|
|
67
|
+
;;
|
|
68
|
+
-*)
|
|
69
|
+
echo "error: unknown option: $1" >&2
|
|
70
|
+
usage
|
|
71
|
+
exit 2
|
|
72
|
+
;;
|
|
73
|
+
*)
|
|
74
|
+
paths+=("$1")
|
|
75
|
+
shift
|
|
76
|
+
;;
|
|
77
|
+
esac
|
|
78
|
+
done
|
|
79
|
+
|
|
80
|
+
cd "$project_root"
|
|
81
|
+
|
|
82
|
+
# Default: check all source files
|
|
83
|
+
if [[ ${#paths[@]} -eq 0 ]]; then
|
|
84
|
+
paths=("src" "tests" "lib")
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
# Result collection
|
|
88
|
+
declare -a violations=()
|
|
89
|
+
exit_code=0
|
|
90
|
+
|
|
91
|
+
log_violation() {
|
|
92
|
+
local type="$1"
|
|
93
|
+
local file="$2"
|
|
94
|
+
local message="$3"
|
|
95
|
+
violations+=("$type|$file|$message")
|
|
96
|
+
exit_code=1
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# =============================================================================
|
|
100
|
+
# Check 1: Formatting (prettier/editorconfig)
|
|
101
|
+
# =============================================================================
|
|
102
|
+
check_formatting() {
|
|
103
|
+
echo "info: checking formatting..."
|
|
104
|
+
|
|
105
|
+
if command -v prettier >/dev/null 2>&1; then
|
|
106
|
+
local prettier_args=("--check")
|
|
107
|
+
[[ "$fix_mode" == "true" ]] && prettier_args=("--write")
|
|
108
|
+
|
|
109
|
+
for path in "${paths[@]}"; do
|
|
110
|
+
[[ -e "$path" ]] || continue
|
|
111
|
+
if ! prettier "${prettier_args[@]}" "$path" 2>/dev/null; then
|
|
112
|
+
log_violation "formatting" "$path" "prettier formatting issues"
|
|
113
|
+
fi
|
|
114
|
+
done
|
|
115
|
+
else
|
|
116
|
+
echo "warn: prettier not found, skipping format check"
|
|
117
|
+
fi
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# =============================================================================
|
|
121
|
+
# Check 2: Linting (eslint)
|
|
122
|
+
# =============================================================================
|
|
123
|
+
check_linting() {
|
|
124
|
+
echo "info: checking linting..."
|
|
125
|
+
|
|
126
|
+
if command -v eslint >/dev/null 2>&1; then
|
|
127
|
+
local eslint_args=()
|
|
128
|
+
[[ "$fix_mode" == "true" ]] && eslint_args+=("--fix")
|
|
129
|
+
|
|
130
|
+
for path in "${paths[@]}"; do
|
|
131
|
+
[[ -e "$path" ]] || continue
|
|
132
|
+
if ! eslint "${eslint_args[@]}" "$path" 2>/dev/null; then
|
|
133
|
+
log_violation "linting" "$path" "eslint violations"
|
|
134
|
+
fi
|
|
135
|
+
done
|
|
136
|
+
elif command -v npm >/dev/null 2>&1 && [[ -f "package.json" ]]; then
|
|
137
|
+
if grep -q '"lint"' package.json 2>/dev/null; then
|
|
138
|
+
if ! npm run lint 2>/dev/null; then
|
|
139
|
+
log_violation "linting" "." "npm run lint failed"
|
|
140
|
+
fi
|
|
141
|
+
fi
|
|
142
|
+
else
|
|
143
|
+
echo "warn: eslint not found, skipping lint check"
|
|
144
|
+
fi
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
# =============================================================================
|
|
148
|
+
# Check 3: Debug statements
|
|
149
|
+
# =============================================================================
|
|
150
|
+
check_debug_statements() {
|
|
151
|
+
echo "info: checking for debug statements..."
|
|
152
|
+
|
|
153
|
+
local patterns=(
|
|
154
|
+
'console\.log\('
|
|
155
|
+
'console\.debug\('
|
|
156
|
+
'console\.warn\('
|
|
157
|
+
'debugger;'
|
|
158
|
+
'DEBUG\s*='
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
for path in "${paths[@]}"; do
|
|
162
|
+
[[ -e "$path" ]] || continue
|
|
163
|
+
|
|
164
|
+
for pattern in "${patterns[@]}"; do
|
|
165
|
+
local matches
|
|
166
|
+
matches=$(rg -l "$pattern" "$path" --type ts --type js 2>/dev/null || true)
|
|
167
|
+
if [[ -n "$matches" ]]; then
|
|
168
|
+
while IFS= read -r file; do
|
|
169
|
+
log_violation "debug" "$file" "contains debug statement: $pattern"
|
|
170
|
+
done <<< "$matches"
|
|
171
|
+
fi
|
|
172
|
+
done
|
|
173
|
+
done
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
# =============================================================================
|
|
177
|
+
# Check 4: test.only / describe.only
|
|
178
|
+
# =============================================================================
|
|
179
|
+
check_test_only() {
|
|
180
|
+
echo "info: checking for test.only/describe.only..."
|
|
181
|
+
|
|
182
|
+
local patterns=(
|
|
183
|
+
'\.only\s*\('
|
|
184
|
+
'it\.only\s*\('
|
|
185
|
+
'test\.only\s*\('
|
|
186
|
+
'describe\.only\s*\('
|
|
187
|
+
'fdescribe\s*\('
|
|
188
|
+
'fit\s*\('
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
for path in "${paths[@]}"; do
|
|
192
|
+
[[ -e "$path" ]] || continue
|
|
193
|
+
|
|
194
|
+
for pattern in "${patterns[@]}"; do
|
|
195
|
+
local matches
|
|
196
|
+
matches=$(rg -l "$pattern" "$path" --type ts --type js 2>/dev/null || true)
|
|
197
|
+
if [[ -n "$matches" ]]; then
|
|
198
|
+
while IFS= read -r file; do
|
|
199
|
+
log_violation "test-only" "$file" "contains .only() or focused test"
|
|
200
|
+
done <<< "$matches"
|
|
201
|
+
fi
|
|
202
|
+
done
|
|
203
|
+
done
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
# =============================================================================
|
|
207
|
+
# Check 5: TODO without issue reference
|
|
208
|
+
# =============================================================================
|
|
209
|
+
check_todo_issues() {
|
|
210
|
+
echo "info: checking TODOs for issue references..."
|
|
211
|
+
|
|
212
|
+
# Find TODOs without issue reference
|
|
213
|
+
local matches
|
|
214
|
+
matches=$(rg -l 'TODO(?!\s*[:#]\s*\d+|.*#\d+|.*issue|.*ISSUE)' "${paths[@]}" --type ts --type js 2>/dev/null || true)
|
|
215
|
+
|
|
216
|
+
if [[ -n "$matches" ]]; then
|
|
217
|
+
while IFS= read -r file; do
|
|
218
|
+
log_violation "todo" "$file" "contains TODO without issue reference (use TODO: #123 or TODO: see issue #123)"
|
|
219
|
+
done <<< "$matches"
|
|
220
|
+
fi
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
# =============================================================================
|
|
224
|
+
# Check 6: Trailing whitespace
|
|
225
|
+
# =============================================================================
|
|
226
|
+
check_trailing_whitespace() {
|
|
227
|
+
echo "info: checking for trailing whitespace..."
|
|
228
|
+
|
|
229
|
+
for path in "${paths[@]}"; do
|
|
230
|
+
[[ -e "$path" ]] || continue
|
|
231
|
+
|
|
232
|
+
local matches
|
|
233
|
+
matches=$(rg -l '\s+$' "$path" --type ts --type js --type md 2>/dev/null || true)
|
|
234
|
+
if [[ -n "$matches" ]]; then
|
|
235
|
+
if [[ "$fix_mode" == "true" ]]; then
|
|
236
|
+
while IFS= read -r file; do
|
|
237
|
+
sed -i '' 's/[[:space:]]*$//' "$file" 2>/dev/null || sed -i 's/[[:space:]]*$//' "$file"
|
|
238
|
+
echo "fixed: $file (trailing whitespace)"
|
|
239
|
+
done <<< "$matches"
|
|
240
|
+
else
|
|
241
|
+
while IFS= read -r file; do
|
|
242
|
+
log_violation "whitespace" "$file" "contains trailing whitespace"
|
|
243
|
+
done <<< "$matches"
|
|
244
|
+
fi
|
|
245
|
+
fi
|
|
246
|
+
done
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
# =============================================================================
|
|
250
|
+
# Check 7: Copyright headers (optional)
|
|
251
|
+
# =============================================================================
|
|
252
|
+
check_copyright() {
|
|
253
|
+
echo "info: checking copyright headers..."
|
|
254
|
+
|
|
255
|
+
# Check if copyright configuration exists
|
|
256
|
+
local copyright_pattern=""
|
|
257
|
+
if [[ -f ".copyrightrc" ]]; then
|
|
258
|
+
copyright_pattern=$(cat .copyrightrc)
|
|
259
|
+
elif [[ -f "LICENSE" ]]; then
|
|
260
|
+
# Try to extract copyright holder from LICENSE file
|
|
261
|
+
local holder
|
|
262
|
+
holder=$(grep -i "copyright" LICENSE 2>/dev/null | head -1 || true)
|
|
263
|
+
if [[ -n "$holder" ]]; then
|
|
264
|
+
# Simplified check: only check if copyright declaration exists
|
|
265
|
+
copyright_pattern="Copyright"
|
|
266
|
+
fi
|
|
267
|
+
fi
|
|
268
|
+
|
|
269
|
+
if [[ -z "$copyright_pattern" ]]; then
|
|
270
|
+
echo "info: no copyright configuration found, skipping"
|
|
271
|
+
return 0
|
|
272
|
+
fi
|
|
273
|
+
|
|
274
|
+
for path in "${paths[@]}"; do
|
|
275
|
+
[[ -e "$path" ]] || continue
|
|
276
|
+
|
|
277
|
+
local files
|
|
278
|
+
files=$(find "$path" -name "*.ts" -o -name "*.js" 2>/dev/null || true)
|
|
279
|
+
|
|
280
|
+
while IFS= read -r file; do
|
|
281
|
+
[[ -z "$file" ]] && continue
|
|
282
|
+
if ! head -20 "$file" | grep -qi "$copyright_pattern" 2>/dev/null; then
|
|
283
|
+
log_violation "copyright" "$file" "missing copyright header"
|
|
284
|
+
fi
|
|
285
|
+
done <<< "$files"
|
|
286
|
+
done
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
# =============================================================================
|
|
290
|
+
# Run checks
|
|
291
|
+
# =============================================================================
|
|
292
|
+
|
|
293
|
+
if [[ "$lint_only" == "true" ]]; then
|
|
294
|
+
check_linting
|
|
295
|
+
elif [[ "$format_only" == "true" ]]; then
|
|
296
|
+
check_formatting
|
|
297
|
+
else
|
|
298
|
+
check_formatting
|
|
299
|
+
check_linting
|
|
300
|
+
check_debug_statements
|
|
301
|
+
check_test_only
|
|
302
|
+
check_todo_issues
|
|
303
|
+
check_trailing_whitespace
|
|
304
|
+
check_copyright
|
|
305
|
+
fi
|
|
306
|
+
|
|
307
|
+
# =============================================================================
|
|
308
|
+
# Output results
|
|
309
|
+
# =============================================================================
|
|
310
|
+
|
|
311
|
+
if [[ "$json_output" == "true" ]]; then
|
|
312
|
+
echo "{"
|
|
313
|
+
echo " \"success\": $([[ $exit_code -eq 0 ]] && echo "true" || echo "false"),"
|
|
314
|
+
echo " \"violations\": ["
|
|
315
|
+
first=true
|
|
316
|
+
for v in "${violations[@]}"; do
|
|
317
|
+
IFS='|' read -r type file message <<< "$v"
|
|
318
|
+
[[ "$first" == "true" ]] || echo ","
|
|
319
|
+
first=false
|
|
320
|
+
echo -n " {\"type\": \"$type\", \"file\": \"$file\", \"message\": \"$message\"}"
|
|
321
|
+
done
|
|
322
|
+
echo
|
|
323
|
+
echo " ]"
|
|
324
|
+
echo "}"
|
|
325
|
+
else
|
|
326
|
+
if [[ ${#violations[@]} -gt 0 ]]; then
|
|
327
|
+
echo ""
|
|
328
|
+
echo "=== Hygiene Violations ===" >&2
|
|
329
|
+
for v in "${violations[@]}"; do
|
|
330
|
+
IFS='|' read -r type file message <<< "$v"
|
|
331
|
+
echo "[$type] $file: $message" >&2
|
|
332
|
+
done
|
|
333
|
+
echo ""
|
|
334
|
+
echo "Total: ${#violations[@]} violation(s)" >&2
|
|
335
|
+
else
|
|
336
|
+
echo "ok: all hygiene checks passed"
|
|
337
|
+
fi
|
|
338
|
+
fi
|
|
339
|
+
|
|
340
|
+
exit $exit_code
|