@hxp-tools/godplans 0.0.0-stage → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1202 -0
- package/LICENSE +21 -0
- package/PROMPT.md +4006 -0
- package/README.md +245 -2
- package/bin/godplans.js +93 -0
- package/docs/ARCHITECTURE.md +136 -0
- package/docs/RELEASING.md +107 -0
- package/docs/assets/badge-approved.svg +12 -0
- package/docs/assets/badge-done.svg +11 -0
- package/docs/assets/badge-graded.svg +12 -0
- package/docs/assets/badge-validated.svg +10 -0
- package/docs/assets/hero.svg +37 -0
- package/docs/assets/quest-map.svg +53 -0
- package/evals/README.md +295 -0
- package/evals/cases/brownfield-cli/EXPECTATIONS +15 -0
- package/evals/cases/brownfield-cli/INPUT/package.json +9 -0
- package/evals/cases/brownfield-cli/INPUT/src/cli.js +4 -0
- package/evals/cases/brownfield-cli/INPUT/src/format.js +3 -0
- package/evals/cases/brownfield-cli/INPUT/test/cli.test.js +7 -0
- package/evals/cases/brownfield-cli/REQUEST.baseline.md +10 -0
- package/evals/cases/brownfield-cli/REQUEST.md +10 -0
- package/evals/cases/compliance-refusal/EXPECTATIONS +4 -0
- package/evals/cases/compliance-refusal/REQUEST.baseline.md +9 -0
- package/evals/cases/compliance-refusal/REQUEST.md +8 -0
- package/evals/cases/greenfield-saas/EXPECTATIONS +21 -0
- package/evals/cases/greenfield-saas/REQUEST.baseline.md +11 -0
- package/evals/cases/greenfield-saas/REQUEST.md +11 -0
- package/evals/cases/nested-pillars/EXPECTATIONS +12 -0
- package/evals/cases/nested-pillars/REQUEST.baseline.md +10 -0
- package/evals/cases/nested-pillars/REQUEST.md +11 -0
- package/evals/cases/observability-evidence/EXPECTATIONS +10 -0
- package/evals/cases/observability-evidence/REQUEST.baseline.md +10 -0
- package/evals/cases/observability-evidence/REQUEST.md +11 -0
- package/evals/cases/product-business/EXPECTATIONS +18 -0
- package/evals/cases/product-business/REQUEST.baseline.md +13 -0
- package/evals/cases/product-business/REQUEST.md +14 -0
- package/evals/cases/product-form-routing/EXPECTATIONS +13 -0
- package/evals/cases/product-form-routing/REQUEST.baseline.md +11 -0
- package/evals/cases/product-form-routing/REQUEST.md +11 -0
- package/evals/cases/prose-integrity/EXPECTATIONS +19 -0
- package/evals/cases/prose-integrity/REQUEST.baseline.md +19 -0
- package/evals/cases/prose-integrity/REQUEST.md +20 -0
- package/evals/cases/replan-preserves-history/EXPECTATIONS +9 -0
- package/evals/cases/replan-preserves-history/INPUT/.godplans/PLAN.mdx +115 -0
- package/evals/cases/replan-preserves-history/INPUT/package.json +5 -0
- package/evals/cases/replan-preserves-history/REQUEST.baseline.md +10 -0
- package/evals/cases/replan-preserves-history/REQUEST.md +10 -0
- package/evals/cases/stale-prepublication/EXPECTATIONS +10 -0
- package/evals/cases/stale-prepublication/REQUEST.baseline.md +12 -0
- package/evals/cases/stale-prepublication/REQUEST.md +13 -0
- package/evals/cases/stale-source-evidence/EXPECTATIONS +10 -0
- package/evals/cases/stale-source-evidence/INPUT/package.json +8 -0
- package/evals/cases/stale-source-evidence/REQUEST.baseline.md +11 -0
- package/evals/cases/stale-source-evidence/REQUEST.md +12 -0
- package/evals/cases/weekend-library/EXPECTATIONS +19 -0
- package/evals/cases/weekend-library/REQUEST.baseline.md +10 -0
- package/evals/cases/weekend-library/REQUEST.md +11 -0
- package/evals/cases-roster.txt +19 -0
- package/evals/external/GRADE.schema.json +39 -0
- package/evals/external/README.md +42 -0
- package/evals/external/RUBRIC.md +32 -0
- package/evals/metrics/context-cost.json +154 -0
- package/evals/outcomes/README.md +65 -0
- package/evals/outcomes/cases/tenant-notes-api/REQUEST.baseline.md +14 -0
- package/evals/outcomes/cases/tenant-notes-api/REQUEST.md +13 -0
- package/evals/outcomes/cases/tenant-notes-api/VERIFY.sh +13 -0
- package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/README.md +93 -0
- package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/treatment/plan/PLAN.json +547 -0
- package/evals/runners/claude-baseline.sh +4 -0
- package/evals/runners/claude-grade.sh +3 -0
- package/evals/runners/claude.sh +4 -0
- package/evals/runners/codex-baseline.sh +181 -0
- package/evals/runners/codex-builder.sh +96 -0
- package/evals/runners/codex-godaudits.sh +84 -0
- package/evals/runners/codex.sh +147 -0
- package/evals/runners/gemini-baseline.sh +4 -0
- package/evals/runners/gemini-grade.sh +3 -0
- package/evals/runners/gemini.sh +4 -0
- package/evals/runners/vendor-cli.sh +257 -0
- package/evals/runners/vendor-grade.sh +82 -0
- package/install.sh +323 -0
- package/package.json +91 -4
- package/requirements/skills-ref.txt +2 -0
- package/scripts/build-catalog.js +114 -0
- package/scripts/build-prompt.sh +257 -0
- package/scripts/context-metrics.js +118 -0
- package/scripts/eval-external.js +226 -0
- package/scripts/eval-matrix.sh +172 -0
- package/scripts/eval-outcome.js +143 -0
- package/scripts/eval.sh +321 -0
- package/scripts/lint-parity.js +331 -0
- package/scripts/lint.sh +743 -0
- package/scripts/outcome-summary.js +126 -0
- package/scripts/release-check.sh +108 -0
- package/scripts/release-prepare.js +41 -0
- package/scripts/summarize-eval.js +91 -0
- package/scripts/summarize-matrix.js +101 -0
- package/scripts/version-sync.js +65 -0
- package/skills/godplans/SKILL.md +192 -0
- package/skills/godplans/references/agent-memory.md +168 -0
- package/skills/godplans/references/architecture.md +189 -0
- package/skills/godplans/references/build.md +130 -0
- package/skills/godplans/references/business.md +252 -0
- package/skills/godplans/references/code-quality.md +165 -0
- package/skills/godplans/references/compliance.md +59 -0
- package/skills/godplans/references/database.md +157 -0
- package/skills/godplans/references/deploy.md +146 -0
- package/skills/godplans/references/discovery.md +297 -0
- package/skills/godplans/references/doc-set.md +243 -0
- package/skills/godplans/references/exemplar.md +228 -0
- package/skills/godplans/references/launch.md +162 -0
- package/skills/godplans/references/llm.md +132 -0
- package/skills/godplans/references/observe.md +178 -0
- package/skills/godplans/references/plan-format.md +340 -0
- package/skills/godplans/references/product.md +130 -0
- package/skills/godplans/references/repo.md +184 -0
- package/skills/godplans/references/roadmap.md +158 -0
- package/skills/godplans/references/security.md +156 -0
- package/skills/godplans/references/seo.md +133 -0
- package/skills/godplans/references/stack.md +133 -0
- package/skills/godplans/references/style-genome.md +198 -0
- package/skills/godplans/references/ui.md +153 -0
- package/skills/godplans/references/ux.md +150 -0
- package/skills/godplans/schemas/PLAN.schema.json +275 -0
- package/skills/godplans/schemas/PLAN.v1.schema.json +258 -0
- package/skills/godplans/scripts/plan-halflife.sh +76 -0
- package/skills/godplans/scripts/style-stats.py +630 -0
- package/skills/godplans/scripts/validate-plan.sh +1709 -0
- package/skills/godplans/templates/PLAN.template.mdx +269 -0
- package/tests/agent-memory-guidance.sh +32 -0
- package/tests/build-catalog.sh +81 -0
- package/tests/codex-runner.sh +139 -0
- package/tests/eval-harness.sh +377 -0
- package/tests/evidence-harnesses.sh +243 -0
- package/tests/fixtures/plan-json-v1-1.13.0.json +472 -0
- package/tests/install-regression.sh +246 -0
- package/tests/lib/plan-schema-check.js +163 -0
- package/tests/lint-selftest.sh +582 -0
- package/tests/package-contents.sh +143 -0
- package/tests/portable-prompt.test.sh +261 -0
- package/tests/release-tooling.sh +204 -0
- package/tests/run.sh +14 -0
- package/tests/script-usage.sh +37 -0
- package/tests/style-stats.sh +170 -0
- package/tests/validate-plan.sh +1970 -0
- package/tests/vendor-runner.sh +291 -0
package/scripts/eval.sh
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Run godplans behavioral cases through any compatible agent runner.
|
|
3
|
+
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
7
|
+
CASES="${GODPLANS_EVAL_CASES:-$ROOT/evals/cases}"
|
|
8
|
+
RUNNER="${GODPLANS_EVAL_RUNNER:-}"
|
|
9
|
+
BASELINE_RUNNER="${GODPLANS_EVAL_BASELINE_RUNNER:-}"
|
|
10
|
+
VALIDATOR="${GODPLANS_VALIDATOR:-$ROOT/skills/godplans/scripts/validate-plan.sh}"
|
|
11
|
+
OUTPUT="$ROOT/evals/output"
|
|
12
|
+
CHECK_ONLY=0
|
|
13
|
+
SCORE_ONLY=0
|
|
14
|
+
BASELINE=0
|
|
15
|
+
SELECTED=""
|
|
16
|
+
|
|
17
|
+
usage() {
|
|
18
|
+
cat <<'USAGE'
|
|
19
|
+
Usage: bash scripts/eval.sh [options] [case ...]
|
|
20
|
+
|
|
21
|
+
Run behavioral cases through GODPLANS_EVAL_RUNNER and score the artifacts.
|
|
22
|
+
|
|
23
|
+
Options:
|
|
24
|
+
--check-cases Validate case manifests without running an agent.
|
|
25
|
+
--score-only Rescore artifacts already present under --output.
|
|
26
|
+
--baseline Also run each case through GODPLANS_EVAL_BASELINE_RUNNER
|
|
27
|
+
(the same agent and model with no godplans skill loaded)
|
|
28
|
+
and score it against the same expectations. Reports the
|
|
29
|
+
per-case and aggregate delta. The baseline arm is a
|
|
30
|
+
measurement, never a gate: it cannot fail the run.
|
|
31
|
+
--output DIRECTORY Read or write evaluation artifacts in DIRECTORY.
|
|
32
|
+
-h, --help Show this help.
|
|
33
|
+
|
|
34
|
+
Without --baseline the harness proves conformance to godplans' own
|
|
35
|
+
expectations. It cannot show that a godplans plan beats what the same agent
|
|
36
|
+
produces unaided. That claim requires the control arm.
|
|
37
|
+
USAGE
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
die() {
|
|
41
|
+
echo "eval: $*" >&2
|
|
42
|
+
exit 2
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
append_selected() {
|
|
46
|
+
if [ -z "$SELECTED" ]; then
|
|
47
|
+
SELECTED=$1
|
|
48
|
+
else
|
|
49
|
+
SELECTED="$SELECTED $1"
|
|
50
|
+
fi
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
while [ $# -gt 0 ]; do
|
|
54
|
+
case "$1" in
|
|
55
|
+
--check-cases) CHECK_ONLY=1 ;;
|
|
56
|
+
--score-only) SCORE_ONLY=1 ;;
|
|
57
|
+
--baseline) BASELINE=1 ;;
|
|
58
|
+
--output)
|
|
59
|
+
[ $# -gt 1 ] || die "--output needs a directory"
|
|
60
|
+
OUTPUT=$2
|
|
61
|
+
shift
|
|
62
|
+
;;
|
|
63
|
+
-h|--help) usage; exit 0 ;;
|
|
64
|
+
--*) die "unknown option: $1" ;;
|
|
65
|
+
*) append_selected "$1" ;;
|
|
66
|
+
esac
|
|
67
|
+
shift
|
|
68
|
+
done
|
|
69
|
+
|
|
70
|
+
[ -d "$CASES" ] || die "case directory not found: $CASES"
|
|
71
|
+
|
|
72
|
+
case_dirs() {
|
|
73
|
+
if [ -n "$SELECTED" ]; then
|
|
74
|
+
for id in $SELECTED; do
|
|
75
|
+
[ -d "$CASES/$id" ] || die "unknown case: $id"
|
|
76
|
+
printf '%s\n' "$CASES/$id"
|
|
77
|
+
done
|
|
78
|
+
else
|
|
79
|
+
find "$CASES" -mindepth 1 -maxdepth 1 -type d -print | LC_ALL=C sort
|
|
80
|
+
fi
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
validate_expectations() {
|
|
84
|
+
file=$1
|
|
85
|
+
outcome_count=0
|
|
86
|
+
# read fails on a final line with no newline; the second test keeps it.
|
|
87
|
+
while IFS='|' read -r op arg value || [ -n "$op$arg$value" ]; do
|
|
88
|
+
case "$op" in
|
|
89
|
+
''|'#'*) continue ;;
|
|
90
|
+
outcome)
|
|
91
|
+
case "$arg" in plan|refusal) ;; *) return 1 ;; esac
|
|
92
|
+
outcome_count=$((outcome_count + 1))
|
|
93
|
+
;;
|
|
94
|
+
frontmatter|domain)
|
|
95
|
+
[ -n "$arg" ] && [ -n "$value" ] || return 1
|
|
96
|
+
;;
|
|
97
|
+
gate)
|
|
98
|
+
[ -n "$arg" ] && [ -n "$value" ] || return 1
|
|
99
|
+
;;
|
|
100
|
+
contains|contains-ci|not-contains)
|
|
101
|
+
[ -n "$arg" ] || return 1
|
|
102
|
+
;;
|
|
103
|
+
max-count)
|
|
104
|
+
[ -n "$arg" ] || return 1
|
|
105
|
+
case "$value" in ''|*[!0-9]*) return 1 ;; esac
|
|
106
|
+
;;
|
|
107
|
+
*) return 1 ;;
|
|
108
|
+
esac
|
|
109
|
+
done < "$file"
|
|
110
|
+
[ "$outcome_count" -eq 1 ]
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# Score one artifact against one EXPECTATIONS file. Sets SCORE_PASSED and
|
|
114
|
+
# SCORE_TOTAL. Emits MISS lines on stderr only when a report label is given,
|
|
115
|
+
# so the baseline arm stays quiet: its misses are the measurement, not a fault.
|
|
116
|
+
score_artifact() {
|
|
117
|
+
score_artifact_path=$1
|
|
118
|
+
score_expectations=$2
|
|
119
|
+
score_report_label=${3:-}
|
|
120
|
+
SCORE_PASSED=0
|
|
121
|
+
SCORE_TOTAL=0
|
|
122
|
+
|
|
123
|
+
while IFS='|' read -r op arg value || [ -n "$op$arg$value" ]; do
|
|
124
|
+
case "$op" in ''|'#'*) continue ;; esac
|
|
125
|
+
SCORE_TOTAL=$((SCORE_TOTAL + 1))
|
|
126
|
+
ok=0
|
|
127
|
+
if [ -s "$score_artifact_path" ]; then
|
|
128
|
+
case "$op" in
|
|
129
|
+
outcome)
|
|
130
|
+
if [ "$arg" = "plan" ]; then
|
|
131
|
+
"$VALIDATOR" --allow-planning "$score_artifact_path" >/dev/null 2>&1 && ok=1
|
|
132
|
+
else
|
|
133
|
+
ok=1
|
|
134
|
+
fi
|
|
135
|
+
;;
|
|
136
|
+
frontmatter)
|
|
137
|
+
grep -Eq "^${arg}:[[:space:]]*${value}[[:space:]]*$" "$score_artifact_path" && ok=1
|
|
138
|
+
;;
|
|
139
|
+
domain)
|
|
140
|
+
grep -Eq "^[|][[:space:]]*${arg}[[:space:]]*[|][[:space:]]*${value}[[:space:]]*[|]" "$score_artifact_path" && ok=1
|
|
141
|
+
;;
|
|
142
|
+
contains)
|
|
143
|
+
grep -Fq -- "$arg" "$score_artifact_path" && ok=1
|
|
144
|
+
;;
|
|
145
|
+
contains-ci)
|
|
146
|
+
grep -Fiq -- "$arg" "$score_artifact_path" && ok=1
|
|
147
|
+
;;
|
|
148
|
+
not-contains)
|
|
149
|
+
if ! grep -Fq -- "$arg" "$score_artifact_path"; then ok=1; fi
|
|
150
|
+
;;
|
|
151
|
+
max-count)
|
|
152
|
+
count=$(grep -Fc -- "$arg" "$score_artifact_path" || true)
|
|
153
|
+
[ "$count" -le "$value" ] && ok=1
|
|
154
|
+
;;
|
|
155
|
+
gate)
|
|
156
|
+
grep -Fq -- "$value" "$score_artifact_path" && ok=1
|
|
157
|
+
;;
|
|
158
|
+
esac
|
|
159
|
+
elif [ "$op" = "not-contains" ]; then
|
|
160
|
+
# A missing artifact trivially lacks the string, so this line is credited.
|
|
161
|
+
# Every other operator scores 0 on it, so an empty artifact earns only its
|
|
162
|
+
# not-contains points (evals/README.md, Expectation grammar).
|
|
163
|
+
ok=1
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
if [ "$ok" -eq 1 ]; then
|
|
167
|
+
SCORE_PASSED=$((SCORE_PASSED + 1))
|
|
168
|
+
elif [ -n "$score_report_label" ]; then
|
|
169
|
+
printf '%s\tMISS\t%s|%s|%s\n' "$score_report_label" "$op" "$arg" "$value" >&2
|
|
170
|
+
fi
|
|
171
|
+
done < "$score_expectations"
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
# Skill minus control, with an explicit sign so a loss never reads as "+-N".
|
|
175
|
+
signed_delta() {
|
|
176
|
+
if [ "$1" -ge 0 ]; then
|
|
177
|
+
printf '+%s' "$1"
|
|
178
|
+
else
|
|
179
|
+
printf '%s' "$1"
|
|
180
|
+
fi
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
CASE_LIST=$(mktemp)
|
|
184
|
+
trap 'rm -f "$CASE_LIST"' EXIT
|
|
185
|
+
case_dirs > "$CASE_LIST"
|
|
186
|
+
|
|
187
|
+
while IFS= read -r dir; do
|
|
188
|
+
[ -f "$dir/REQUEST.md" ] || die "missing REQUEST.md in $dir"
|
|
189
|
+
[ -f "$dir/EXPECTATIONS" ] || die "missing EXPECTATIONS in $dir"
|
|
190
|
+
validate_expectations "$dir/EXPECTATIONS" || die "invalid EXPECTATIONS in $dir"
|
|
191
|
+
expected_outcome=$(awk -F'|' '$1 == "outcome" { print $2; exit }' "$dir/EXPECTATIONS")
|
|
192
|
+
if [ "$expected_outcome" = "plan" ] && grep -Eiq 'PLAN[.]mdx[^[:alnum:]]+only' "$dir/REQUEST.md"; then
|
|
193
|
+
die "plan case contradicts the required validator companion: $dir"
|
|
194
|
+
fi
|
|
195
|
+
# The neutral control request must not leak the skill it is meant to omit.
|
|
196
|
+
# A REQUEST.baseline.md that names godplans, the .godplans path, or the
|
|
197
|
+
# validator companion would hand the control the very format the delta is
|
|
198
|
+
# supposed to measure, so reject it here rather than at run time.
|
|
199
|
+
if [ -f "$dir/REQUEST.baseline.md" ] &&
|
|
200
|
+
grep -Eiq 'godplans|\.godplans|SKILL\.md|validator companion|PLAN\.mdx' "$dir/REQUEST.baseline.md"; then
|
|
201
|
+
die "REQUEST.baseline.md leaks the skill (godplans/.godplans/PLAN.mdx/validator): $dir"
|
|
202
|
+
fi
|
|
203
|
+
done < "$CASE_LIST"
|
|
204
|
+
|
|
205
|
+
if [ "$CHECK_ONLY" -eq 1 ]; then
|
|
206
|
+
echo "ok [eval-cases]"
|
|
207
|
+
exit 0
|
|
208
|
+
fi
|
|
209
|
+
|
|
210
|
+
[ -x "$VALIDATOR" ] || die "validator is not executable: $VALIDATOR"
|
|
211
|
+
if [ "$SCORE_ONLY" -eq 0 ]; then
|
|
212
|
+
[ -n "$RUNNER" ] || die "set GODPLANS_EVAL_RUNNER to an executable runner"
|
|
213
|
+
[ -x "$RUNNER" ] || die "runner is not executable: $RUNNER"
|
|
214
|
+
if [ "$BASELINE" -eq 1 ]; then
|
|
215
|
+
[ -n "$BASELINE_RUNNER" ] || die "--baseline needs GODPLANS_EVAL_BASELINE_RUNNER"
|
|
216
|
+
[ -x "$BASELINE_RUNNER" ] || die "baseline runner is not executable: $BASELINE_RUNNER"
|
|
217
|
+
[ "$BASELINE_RUNNER" != "$RUNNER" ] || die "baseline runner must not be the skill runner"
|
|
218
|
+
fi
|
|
219
|
+
fi
|
|
220
|
+
|
|
221
|
+
mkdir -p "$OUTPUT"
|
|
222
|
+
failed=0
|
|
223
|
+
skill_points=0
|
|
224
|
+
base_points=0
|
|
225
|
+
arm_total=0
|
|
226
|
+
|
|
227
|
+
while IFS= read -r dir; do
|
|
228
|
+
id=$(basename "$dir")
|
|
229
|
+
expected_outcome=$(awk -F'|' '$1 == "outcome" { print $2; exit }' "$dir/EXPECTATIONS")
|
|
230
|
+
out_dir="$OUTPUT/$id"
|
|
231
|
+
if [ "$SCORE_ONLY" -eq 0 ]; then
|
|
232
|
+
rm -rf "$out_dir"
|
|
233
|
+
mkdir -p "$out_dir"
|
|
234
|
+
fi
|
|
235
|
+
|
|
236
|
+
if [ "$expected_outcome" = "plan" ]; then
|
|
237
|
+
artifact="$out_dir/PLAN.mdx"
|
|
238
|
+
else
|
|
239
|
+
artifact="$out_dir/RESPONSE.md"
|
|
240
|
+
fi
|
|
241
|
+
|
|
242
|
+
if [ "$SCORE_ONLY" -eq 0 ]; then
|
|
243
|
+
if ! "$RUNNER" "$dir/REQUEST.md" "$artifact"; then
|
|
244
|
+
printf '%s\tFAIL\trunner\n' "$id"
|
|
245
|
+
failed=1
|
|
246
|
+
continue
|
|
247
|
+
fi
|
|
248
|
+
fi
|
|
249
|
+
|
|
250
|
+
artifact_set_ok=1
|
|
251
|
+
if [ "$expected_outcome" = "plan" ]; then
|
|
252
|
+
companion="$out_dir/validate-plan.sh"
|
|
253
|
+
sidecar="$out_dir/PLAN.json"
|
|
254
|
+
[ -s "$artifact" ] || artifact_set_ok=0
|
|
255
|
+
[ -x "$companion" ] || artifact_set_ok=0
|
|
256
|
+
[ -s "$sidecar" ] || artifact_set_ok=0
|
|
257
|
+
cmp -s "$VALIDATOR" "$companion" || artifact_set_ok=0
|
|
258
|
+
if [ "$artifact_set_ok" -eq 1 ]; then
|
|
259
|
+
node -e '
|
|
260
|
+
const fs = require("node:fs");
|
|
261
|
+
const crypto = require("node:crypto");
|
|
262
|
+
const plan = fs.readFileSync(process.argv[1]);
|
|
263
|
+
const sidecar = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
|
264
|
+
const digest = "sha256:" + crypto.createHash("sha256").update(plan).digest("hex");
|
|
265
|
+
if (sidecar.plan_digest !== digest) process.exit(1);
|
|
266
|
+
' "$artifact" "$sidecar" || artifact_set_ok=0
|
|
267
|
+
fi
|
|
268
|
+
else
|
|
269
|
+
[ -s "$artifact" ] || artifact_set_ok=0
|
|
270
|
+
[ ! -e "$out_dir/PLAN.mdx" ] || artifact_set_ok=0
|
|
271
|
+
fi
|
|
272
|
+
if [ "$artifact_set_ok" -eq 0 ]; then
|
|
273
|
+
printf '%s\tFAIL\tartifacts\n' "$id"
|
|
274
|
+
failed=1
|
|
275
|
+
continue
|
|
276
|
+
fi
|
|
277
|
+
|
|
278
|
+
score_artifact "$artifact" "$dir/EXPECTATIONS" "$id"
|
|
279
|
+
passed=$SCORE_PASSED
|
|
280
|
+
total=$SCORE_TOTAL
|
|
281
|
+
|
|
282
|
+
if [ "$passed" -eq "$total" ]; then
|
|
283
|
+
printf '%s\tPASS\t%s/%s\n' "$id" "$passed" "$total"
|
|
284
|
+
else
|
|
285
|
+
printf '%s\tFAIL\t%s/%s\n' "$id" "$passed" "$total"
|
|
286
|
+
failed=1
|
|
287
|
+
fi
|
|
288
|
+
|
|
289
|
+
if [ "$BASELINE" -eq 1 ]; then
|
|
290
|
+
base_dir="$out_dir/baseline"
|
|
291
|
+
if [ "$expected_outcome" = "plan" ]; then
|
|
292
|
+
base_artifact="$base_dir/PLAN.mdx"
|
|
293
|
+
else
|
|
294
|
+
base_artifact="$base_dir/RESPONSE.md"
|
|
295
|
+
fi
|
|
296
|
+
|
|
297
|
+
if [ "$SCORE_ONLY" -eq 0 ]; then
|
|
298
|
+
rm -rf "$base_dir"
|
|
299
|
+
mkdir -p "$base_dir"
|
|
300
|
+
if ! "$BASELINE_RUNNER" "$dir/REQUEST.md" "$base_artifact"; then
|
|
301
|
+
printf '%s\tBASE\trunner-error\n' "$id"
|
|
302
|
+
continue
|
|
303
|
+
fi
|
|
304
|
+
fi
|
|
305
|
+
|
|
306
|
+
score_artifact "$base_artifact" "$dir/EXPECTATIONS" ""
|
|
307
|
+
printf '%s\tBASE\t%s/%s\tdelta %s\n' "$id" "$SCORE_PASSED" "$SCORE_TOTAL" "$(signed_delta "$((passed - SCORE_PASSED))")"
|
|
308
|
+
skill_points=$((skill_points + passed))
|
|
309
|
+
base_points=$((base_points + SCORE_PASSED))
|
|
310
|
+
arm_total=$((arm_total + total))
|
|
311
|
+
fi
|
|
312
|
+
done < "$CASE_LIST"
|
|
313
|
+
|
|
314
|
+
if [ "$BASELINE" -eq 1 ] && [ "$arm_total" -gt 0 ]; then
|
|
315
|
+
printf 'AGGREGATE\tskill %s/%s\tbaseline %s/%s\tdelta %s\n' \
|
|
316
|
+
"$skill_points" "$arm_total" "$base_points" "$arm_total" "$(signed_delta "$((skill_points - base_points))")"
|
|
317
|
+
fi
|
|
318
|
+
|
|
319
|
+
node "$ROOT/scripts/summarize-eval.js" "$OUTPUT"
|
|
320
|
+
|
|
321
|
+
exit "$failed"
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Parity checks for scripts/lint.sh, kept in a file so js-syntax and node
|
|
5
|
+
// --check cover them. lint.sh owns the reporting; this prints data only.
|
|
6
|
+
//
|
|
7
|
+
// node scripts/lint-parity.js description-length
|
|
8
|
+
// prints the SKILL.md description length in characters.
|
|
9
|
+
// node scripts/lint-parity.js description-parity
|
|
10
|
+
// prints one line per plugin manifest whose description differs from
|
|
11
|
+
// SKILL.md, and one when the marketplace metadata.description differs
|
|
12
|
+
// from package.json.
|
|
13
|
+
// node scripts/lint-parity.js domain-parity "CONTRACT MODULES"
|
|
14
|
+
// prints "domains N M" (N domain modules, M lists compared), then one
|
|
15
|
+
// "problem TEXT" line per disagreement.
|
|
16
|
+
//
|
|
17
|
+
// A read or parse error exits 2 with the reason on stderr.
|
|
18
|
+
|
|
19
|
+
const fs = require('node:fs');
|
|
20
|
+
const path = require('node:path');
|
|
21
|
+
|
|
22
|
+
const root = path.resolve(__dirname, '..');
|
|
23
|
+
const skillRel = 'skills/godplans/SKILL.md';
|
|
24
|
+
const refsRel = 'skills/godplans/references';
|
|
25
|
+
const validatorRel = 'skills/godplans/scripts/validate-plan.sh';
|
|
26
|
+
const buildRel = 'scripts/build-prompt.sh';
|
|
27
|
+
const metricsRel = 'scripts/context-metrics.js';
|
|
28
|
+
const portableRel = 'tests/portable-prompt.test.sh';
|
|
29
|
+
const templateRel = 'skills/godplans/templates/PLAN.template.mdx';
|
|
30
|
+
const discoveryRel = 'skills/godplans/references/discovery.md';
|
|
31
|
+
const schemaRel = 'skills/godplans/schemas/PLAN.schema.json';
|
|
32
|
+
|
|
33
|
+
function die(message) {
|
|
34
|
+
process.stderr.write(`${message}\n`);
|
|
35
|
+
process.exit(2);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function read(rel) {
|
|
39
|
+
const file = path.join(root, rel);
|
|
40
|
+
if (!fs.existsSync(file)) throw new Error(`${rel} does not exist`);
|
|
41
|
+
return fs.readFileSync(file, 'utf8');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function readJson(rel) {
|
|
45
|
+
const text = read(rel);
|
|
46
|
+
try {
|
|
47
|
+
return JSON.parse(text);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
die(`${rel} is not valid JSON: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// The description must be one double-quoted line, which is also a JSON
|
|
55
|
+
// string, so JSON.parse reads it exactly. Folded, literal, plain, and
|
|
56
|
+
// multi-line forms are refused rather than parsed: YAML folding rules are
|
|
57
|
+
// easy to get subtly wrong, and one form is enough.
|
|
58
|
+
function description() {
|
|
59
|
+
const lines = read(skillRel).split(/\r?\n/);
|
|
60
|
+
if (lines[0] !== '---') die(`${skillRel} does not start with a --- frontmatter line`);
|
|
61
|
+
const close = lines.indexOf('---', 1);
|
|
62
|
+
if (close < 0) die(`${skillRel} frontmatter has no closing --- line`);
|
|
63
|
+
const line = lines.slice(1, close).find((text) => /^description:/.test(text));
|
|
64
|
+
if (line === undefined) die(`${skillRel} frontmatter has no description`);
|
|
65
|
+
const quoted = line.match(/^description:[ \t]*("(?:[^"\\]|\\.)*")[ \t]*$/);
|
|
66
|
+
if (!quoted) die(`${skillRel} description must be one double-quoted line (no >, |, plain, or continued form)`);
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(quoted[1]);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
die(`${skillRel} description uses an escape JSON cannot read: ${error.message}`);
|
|
71
|
+
}
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Two sources, each copied by hand: the SKILL.md description goes into both
|
|
76
|
+
// plugin manifests, and the package.json description into the marketplace
|
|
77
|
+
// tagline (metadata.description), which the GitHub About text also carries.
|
|
78
|
+
function descriptionParity(value) {
|
|
79
|
+
const problems = [];
|
|
80
|
+
const compare = (label, actual, expected, source, short) => {
|
|
81
|
+
if (typeof actual !== 'string') {
|
|
82
|
+
problems.push(`${label} has no description string`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (actual === expected) return;
|
|
86
|
+
let at = 0;
|
|
87
|
+
while (at < actual.length && at < expected.length && actual[at] === expected[at]) at += 1;
|
|
88
|
+
problems.push(`${label} description differs from the ${source} description at character ${at + 1} (${actual.length} vs ${expected.length} characters); copy the ${short} description into it verbatim`);
|
|
89
|
+
};
|
|
90
|
+
const fromSkill = (label, actual) => compare(label, actual, value, 'SKILL.md frontmatter', 'SKILL.md');
|
|
91
|
+
const pluginRel = 'plugins/godplans/.claude-plugin/plugin.json';
|
|
92
|
+
fromSkill(pluginRel, readJson(pluginRel).description);
|
|
93
|
+
const marketRel = '.claude-plugin/marketplace.json';
|
|
94
|
+
const market = readJson(marketRel);
|
|
95
|
+
const entries = Array.isArray(market.plugins) ? market.plugins.filter((entry) => entry && entry.name === 'godplans') : [];
|
|
96
|
+
if (entries.length !== 1) {
|
|
97
|
+
problems.push(`${marketRel} has ${entries.length} plugin entries named godplans; want exactly 1`);
|
|
98
|
+
} else {
|
|
99
|
+
fromSkill(`${marketRel} godplans plugin entry`, entries[0].description);
|
|
100
|
+
}
|
|
101
|
+
const pkgDescription = readJson('package.json').description;
|
|
102
|
+
if (typeof pkgDescription !== 'string') {
|
|
103
|
+
problems.push('package.json has no description string');
|
|
104
|
+
} else {
|
|
105
|
+
const metadata = market.metadata && typeof market.metadata === 'object' ? market.metadata : {};
|
|
106
|
+
compare(`${marketRel} metadata`, metadata.description, pkgDescription, 'package.json', 'package.json');
|
|
107
|
+
}
|
|
108
|
+
return problems;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function words(text) {
|
|
112
|
+
return text.split(/\s+/).filter(Boolean);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function quotedStrings(text) {
|
|
116
|
+
return Array.from(text.matchAll(/(['"])([^'"]+)\1/g), (match) => match[2]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function need(match, what) {
|
|
120
|
+
if (!match) throw new Error(`cannot find ${what}`);
|
|
121
|
+
return match;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Perl hash pairs: 'key' => 'value' or KEY => 'value'.
|
|
125
|
+
function perlPairs(text) {
|
|
126
|
+
return Array.from(text.matchAll(/(['"]?)([A-Za-z0-9_-]+)\1\s*=>\s*(['"])([^'"]+)\3/g), (pair) => [pair[2], pair[4]]);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// The R-<PREFIX>-N ids a module defines: those that start a line (after an
|
|
130
|
+
// optional list marker) inside its ## Plan requirements section. Ids cited
|
|
131
|
+
// mid-sentence are cross-references to other modules and are not counted.
|
|
132
|
+
function definedPrefixes(text) {
|
|
133
|
+
const prefixes = new Set();
|
|
134
|
+
let inside = false;
|
|
135
|
+
for (const line of text.split(/\r?\n/)) {
|
|
136
|
+
if (/^## Plan requirements\s*$/.test(line)) {
|
|
137
|
+
inside = true;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (inside && /^## /.test(line)) inside = false;
|
|
141
|
+
if (!inside) continue;
|
|
142
|
+
const id = line.match(/^\s*(?:(?:[0-9]+\.|[-*])\s+)?(?:\*\*)?R-([A-Z][A-Z0-9-]*)-[0-9]+/);
|
|
143
|
+
if (id) prefixes.add(id[1]);
|
|
144
|
+
}
|
|
145
|
+
return prefixes;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function domainParity(contractText) {
|
|
149
|
+
const contract = new Set(words(contractText || ''));
|
|
150
|
+
const problems = [];
|
|
151
|
+
const domains = fs.readdirSync(path.join(root, refsRel))
|
|
152
|
+
.filter((name) => name.endsWith('.md'))
|
|
153
|
+
.map((name) => name.slice(0, -3))
|
|
154
|
+
.filter((name) => !contract.has(name))
|
|
155
|
+
.sort();
|
|
156
|
+
if (domains.length === 0) problems.push(`${refsRel} has no domain modules`);
|
|
157
|
+
const isDomain = (name) => !contract.has(name);
|
|
158
|
+
|
|
159
|
+
// compare: NAMES must hold each EXPECTED name exactly once and nothing else.
|
|
160
|
+
const compare = (label, names, expected, lacks, extra) => {
|
|
161
|
+
const counts = new Map();
|
|
162
|
+
for (const name of names) counts.set(name, (counts.get(name) || 0) + 1);
|
|
163
|
+
for (const name of expected) {
|
|
164
|
+
if (!counts.has(name)) problems.push(lacks(name));
|
|
165
|
+
}
|
|
166
|
+
for (const [name, count] of counts) {
|
|
167
|
+
if (!expected.includes(name)) problems.push(extra(name));
|
|
168
|
+
if (count > 1) problems.push(`${label} names ${name} ${count} times`);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const compareToDomains = (label, names) => compare(label, names, domains,
|
|
172
|
+
(name) => `${label} lacks domain module ${name}`,
|
|
173
|
+
(name) => `${label} names ${name}, but ${refsRel}/${name}.md does not exist`);
|
|
174
|
+
|
|
175
|
+
// Read every source once. A source whose shape cannot be found is one
|
|
176
|
+
// problem, and the checks that need it are skipped.
|
|
177
|
+
const texts = {};
|
|
178
|
+
for (const rel of [skillRel, validatorRel, buildRel, metricsRel, portableRel, templateRel, discoveryRel, schemaRel]) {
|
|
179
|
+
try {
|
|
180
|
+
texts[rel] = read(rel);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
problems.push(error.message);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const extract = (label, rel, fn) => {
|
|
186
|
+
if (texts[rel] === undefined) return null;
|
|
187
|
+
try {
|
|
188
|
+
return fn(texts[rel]);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
problems.push(`${label}: ${error.message}`);
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const phase4 = extract(`${skillRel} Phase 4 table`, skillRel, (text) => {
|
|
196
|
+
const lines = text.split(/\r?\n/);
|
|
197
|
+
const start = lines.findIndex((line) => /^### Phase 4\b/.test(line));
|
|
198
|
+
if (start < 0) throw new Error('cannot find the "### Phase 4" heading');
|
|
199
|
+
const names = [];
|
|
200
|
+
for (let i = start + 1; i < lines.length && !/^#{1,3} /.test(lines[i]); i += 1) {
|
|
201
|
+
if (!lines[i].startsWith('|')) continue;
|
|
202
|
+
for (const match of lines[i].matchAll(/references\/([a-z0-9-]+)\.md/g)) names.push(match[1]);
|
|
203
|
+
}
|
|
204
|
+
if (names.length === 0) throw new Error('the Phase 4 table names no references/<module>.md');
|
|
205
|
+
return names;
|
|
206
|
+
});
|
|
207
|
+
const knownDomain = extract(`${validatorRel} %known_domain`, validatorRel, (text) =>
|
|
208
|
+
words(need(text.match(/%known_domain\s*=\s*map\s*\{[^}]*\}\s*qw\(([^)]*)\)/), 'the %known_domain qw() list')[1]));
|
|
209
|
+
const modulePrefix = extract(`${validatorRel} %module_prefix`, validatorRel, (text) =>
|
|
210
|
+
perlPairs(need(text.match(/%module_prefix\s*=\s*\(([\s\S]*?)\);/), 'the %module_prefix table')[1]));
|
|
211
|
+
// The validator derives the prefix-to-module map with reverse, so it is the
|
|
212
|
+
// exact inverse of %module_prefix by construction; require that line.
|
|
213
|
+
extract(`${validatorRel} prefix-to-module map`, validatorRel, (text) =>
|
|
214
|
+
need(text.match(/%prefix_module\s*=\s*reverse\s+%module_prefix\s*;/), '%prefix_module = reverse %module_prefix'));
|
|
215
|
+
const orders = extract(`${buildRel} REFERENCE_ORDER`, buildRel, (text) => {
|
|
216
|
+
const match = need(text.match(/if \[ "\$MODE" = "full" \]; then\s*\n\s*REFERENCE_ORDER="([^"]*)"\s*\nelse\s*\n\s*REFERENCE_ORDER="([^"]*)"/), 'the full and core REFERENCE_ORDER assignments');
|
|
217
|
+
return { full: words(match[1]), core: words(match[2]) };
|
|
218
|
+
});
|
|
219
|
+
const fullCount = extract(`${buildRel} full-mode header`, buildRel, (text) =>
|
|
220
|
+
Number(need(text.match(/\ball ([0-9]+) domain modules\b/), '"all N domain modules"')[1]));
|
|
221
|
+
const lazySentence = extract(`${buildRel} core-mode lazy module sentence`, buildRel, (text) => {
|
|
222
|
+
const match = need(text.replace(/\s+/g, ' ').match(/The lazy modules are ([^.]*)\./), '"The lazy modules are ..."');
|
|
223
|
+
return match[1].split(/\s*,\s*(?:and\s+)?|\s+and\s+/).filter(Boolean);
|
|
224
|
+
});
|
|
225
|
+
const metrics = extract(`${metricsRel} module lists`, metricsRel, (text) => ({
|
|
226
|
+
core: quotedStrings(need(text.match(/const coreModules = \[([\s\S]*?)\];/), 'const coreModules = [...]')[1]),
|
|
227
|
+
lazy: quotedStrings(need(text.match(/const lazyModules = \[([\s\S]*?)\];/), 'const lazyModules = [...]')[1]),
|
|
228
|
+
}));
|
|
229
|
+
// A plan copies the template's matrix and the discovery module shows a worked
|
|
230
|
+
// one; the validator fails any plan whose matrix lacks a known domain, so a
|
|
231
|
+
// row missing here reaches every plan an agent writes from these examples.
|
|
232
|
+
const matrixRows = (text) => {
|
|
233
|
+
const lines = text.split(/\r?\n/);
|
|
234
|
+
const start = lines.findIndex((line) => line === '## Applicability matrix');
|
|
235
|
+
if (start < 0) throw new Error('cannot find the "## Applicability matrix" heading');
|
|
236
|
+
const names = [];
|
|
237
|
+
for (let i = start + 1; i < lines.length && !/^#{1,3} /.test(lines[i]) && !lines[i].startsWith('```'); i += 1) {
|
|
238
|
+
const row = lines[i].match(/^\|\s*([a-z][a-z0-9-]*)\s*\|/);
|
|
239
|
+
if (row) names.push(row[1]);
|
|
240
|
+
}
|
|
241
|
+
if (names.length === 0) throw new Error('the applicability matrix has no domain rows');
|
|
242
|
+
return names;
|
|
243
|
+
};
|
|
244
|
+
const templateMatrix = extract(`${templateRel} applicability matrix`, templateRel, matrixRows);
|
|
245
|
+
const discoveryMatrix = extract(`${discoveryRel} worked applicability matrix`, discoveryRel, matrixRows);
|
|
246
|
+
const schemaCount = extract(`${schemaRel} applicability count`, schemaRel, (text) => {
|
|
247
|
+
const applicability = need(JSON.parse(text).properties || null, 'top-level properties').applicability;
|
|
248
|
+
need(applicability, 'properties.applicability');
|
|
249
|
+
return { min: applicability.minItems, max: applicability.maxItems };
|
|
250
|
+
});
|
|
251
|
+
const portable = extract(`${portableRel} module lists`, portableRel, (text) => ({
|
|
252
|
+
core: words(need(text.match(/^expected_refs="([^"]*)"/m), 'expected_refs="..."')[1]),
|
|
253
|
+
lazy: words(need(text.match(/^lazy_refs="([^"]*)"/m), 'lazy_refs="..."')[1]),
|
|
254
|
+
}));
|
|
255
|
+
|
|
256
|
+
// Every list names every domain module exactly once.
|
|
257
|
+
const lists = [];
|
|
258
|
+
if (phase4) lists.push([`${skillRel} Phase 4 table`, phase4]);
|
|
259
|
+
if (knownDomain) lists.push([`${validatorRel} %known_domain`, knownDomain]);
|
|
260
|
+
if (modulePrefix) lists.push([`${validatorRel} %module_prefix keys`, modulePrefix.map((pair) => pair[0])]);
|
|
261
|
+
if (orders) lists.push([`${buildRel} full REFERENCE_ORDER`, orders.full]);
|
|
262
|
+
if (metrics) lists.push([`${metricsRel} coreModules + lazyModules`, metrics.core.concat(metrics.lazy)]);
|
|
263
|
+
if (portable) lists.push([`${portableRel} expected_refs + lazy_refs`, portable.core.concat(portable.lazy)]);
|
|
264
|
+
if (templateMatrix) lists.push([`${templateRel} applicability matrix`, templateMatrix]);
|
|
265
|
+
if (discoveryMatrix) lists.push([`${discoveryRel} worked applicability matrix`, discoveryMatrix]);
|
|
266
|
+
for (const [label, names] of lists) compareToDomains(label, names.filter(isDomain));
|
|
267
|
+
if (schemaCount && (schemaCount.min !== domains.length || schemaCount.max !== domains.length)) {
|
|
268
|
+
problems.push(`${schemaRel} applicability minItems ${schemaCount.min} and maxItems ${schemaCount.max} must both equal the ${domains.length} domain modules`);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// The core and lazy split agrees with context-metrics.js.
|
|
272
|
+
if (metrics) {
|
|
273
|
+
const core = metrics.core.filter(isDomain);
|
|
274
|
+
const lazy = metrics.lazy.filter(isDomain);
|
|
275
|
+
const split = [];
|
|
276
|
+
if (orders) split.push([`${buildRel} core REFERENCE_ORDER`, orders.core, core, `${metricsRel} coreModules`]);
|
|
277
|
+
if (lazySentence) split.push([`${buildRel} core-mode lazy module sentence`, lazySentence, lazy, `${metricsRel} lazyModules`]);
|
|
278
|
+
if (portable) {
|
|
279
|
+
split.push([`${portableRel} expected_refs`, portable.core, core, `${metricsRel} coreModules`]);
|
|
280
|
+
split.push([`${portableRel} lazy_refs`, portable.lazy, lazy, `${metricsRel} lazyModules`]);
|
|
281
|
+
}
|
|
282
|
+
for (const [label, names, expected, expectedLabel] of split) {
|
|
283
|
+
compare(label, names.filter(isDomain), expected,
|
|
284
|
+
(name) => `${label} lacks ${name}, which ${expectedLabel} names`,
|
|
285
|
+
(name) => `${label} names ${name}, which ${expectedLabel} does not`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (fullCount !== null && fullCount !== domains.length) {
|
|
290
|
+
problems.push(`${buildRel} full-mode header says all ${fullCount} domain modules, but ${refsRel} has ${domains.length}`);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Prefixes: one per module, and each module defines its requirements under
|
|
294
|
+
// its own prefix.
|
|
295
|
+
if (modulePrefix) {
|
|
296
|
+
const prefixOf = new Map(modulePrefix);
|
|
297
|
+
const owners = new Map();
|
|
298
|
+
for (const [module, prefix] of modulePrefix) owners.set(prefix, (owners.get(prefix) || []).concat(module));
|
|
299
|
+
for (const [prefix, modules] of owners) {
|
|
300
|
+
if (modules.length > 1) problems.push(`${validatorRel} %module_prefix gives the prefix ${prefix} to ${modules.join(' and ')}`);
|
|
301
|
+
}
|
|
302
|
+
for (const domain of domains) {
|
|
303
|
+
const own = prefixOf.get(domain);
|
|
304
|
+
if (!own) continue;
|
|
305
|
+
const defined = definedPrefixes(read(`${refsRel}/${domain}.md`));
|
|
306
|
+
if (!defined.has(own)) problems.push(`${refsRel}/${domain}.md defines no R-${own}-N requirement, but %module_prefix gives ${domain} the prefix ${own}`);
|
|
307
|
+
for (const prefix of defined) {
|
|
308
|
+
if (prefix !== own) problems.push(`${refsRel}/${domain}.md defines R-${prefix}-N requirements, but %module_prefix gives ${domain} the prefix ${own}`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return { domains: domains.length, lists: lists.length, problems };
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const mode = process.argv[2];
|
|
317
|
+
try {
|
|
318
|
+
if (mode === 'description-length') {
|
|
319
|
+
process.stdout.write(`${Array.from(description()).length}\n`);
|
|
320
|
+
} else if (mode === 'description-parity') {
|
|
321
|
+
process.stdout.write(descriptionParity(description()).map((line) => `${line}\n`).join(''));
|
|
322
|
+
} else if (mode === 'domain-parity') {
|
|
323
|
+
const result = domainParity(process.argv[3]);
|
|
324
|
+
process.stdout.write(`domains ${result.domains} ${result.lists}\n`);
|
|
325
|
+
process.stdout.write(result.problems.map((line) => `problem ${line}\n`).join(''));
|
|
326
|
+
} else {
|
|
327
|
+
die('usage: node scripts/lint-parity.js description-length | description-parity | domain-parity "CONTRACT MODULES"');
|
|
328
|
+
}
|
|
329
|
+
} catch (error) {
|
|
330
|
+
die(error.message);
|
|
331
|
+
}
|