@hxp-tools/godplans 0.0.0-stage → 2.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 (144) hide show
  1. package/CHANGELOG.md +1176 -0
  2. package/LICENSE +21 -0
  3. package/PROMPT.md +4006 -0
  4. package/README.md +201 -2
  5. package/assets/README.md +11 -0
  6. package/assets/hero.svg +44 -0
  7. package/assets/plan-loop.svg +62 -0
  8. package/assets/quest-map.svg +80 -0
  9. package/bin/godplans.js +93 -0
  10. package/docs/ARCHITECTURE.md +136 -0
  11. package/docs/RELEASING.md +107 -0
  12. package/evals/README.md +295 -0
  13. package/evals/cases/brownfield-cli/EXPECTATIONS +15 -0
  14. package/evals/cases/brownfield-cli/INPUT/package.json +9 -0
  15. package/evals/cases/brownfield-cli/INPUT/src/cli.js +4 -0
  16. package/evals/cases/brownfield-cli/INPUT/src/format.js +3 -0
  17. package/evals/cases/brownfield-cli/INPUT/test/cli.test.js +7 -0
  18. package/evals/cases/brownfield-cli/REQUEST.baseline.md +10 -0
  19. package/evals/cases/brownfield-cli/REQUEST.md +10 -0
  20. package/evals/cases/compliance-refusal/EXPECTATIONS +4 -0
  21. package/evals/cases/compliance-refusal/REQUEST.baseline.md +9 -0
  22. package/evals/cases/compliance-refusal/REQUEST.md +8 -0
  23. package/evals/cases/greenfield-saas/EXPECTATIONS +21 -0
  24. package/evals/cases/greenfield-saas/REQUEST.baseline.md +11 -0
  25. package/evals/cases/greenfield-saas/REQUEST.md +11 -0
  26. package/evals/cases/nested-pillars/EXPECTATIONS +12 -0
  27. package/evals/cases/nested-pillars/REQUEST.baseline.md +10 -0
  28. package/evals/cases/nested-pillars/REQUEST.md +11 -0
  29. package/evals/cases/observability-evidence/EXPECTATIONS +10 -0
  30. package/evals/cases/observability-evidence/REQUEST.baseline.md +10 -0
  31. package/evals/cases/observability-evidence/REQUEST.md +11 -0
  32. package/evals/cases/product-business/EXPECTATIONS +18 -0
  33. package/evals/cases/product-business/REQUEST.baseline.md +13 -0
  34. package/evals/cases/product-business/REQUEST.md +14 -0
  35. package/evals/cases/product-form-routing/EXPECTATIONS +13 -0
  36. package/evals/cases/product-form-routing/REQUEST.baseline.md +11 -0
  37. package/evals/cases/product-form-routing/REQUEST.md +11 -0
  38. package/evals/cases/prose-integrity/EXPECTATIONS +19 -0
  39. package/evals/cases/prose-integrity/REQUEST.baseline.md +19 -0
  40. package/evals/cases/prose-integrity/REQUEST.md +20 -0
  41. package/evals/cases/replan-preserves-history/EXPECTATIONS +9 -0
  42. package/evals/cases/replan-preserves-history/INPUT/.godplans/PLAN.mdx +115 -0
  43. package/evals/cases/replan-preserves-history/INPUT/package.json +5 -0
  44. package/evals/cases/replan-preserves-history/REQUEST.baseline.md +10 -0
  45. package/evals/cases/replan-preserves-history/REQUEST.md +10 -0
  46. package/evals/cases/stale-prepublication/EXPECTATIONS +10 -0
  47. package/evals/cases/stale-prepublication/REQUEST.baseline.md +12 -0
  48. package/evals/cases/stale-prepublication/REQUEST.md +13 -0
  49. package/evals/cases/stale-source-evidence/EXPECTATIONS +10 -0
  50. package/evals/cases/stale-source-evidence/INPUT/package.json +8 -0
  51. package/evals/cases/stale-source-evidence/REQUEST.baseline.md +11 -0
  52. package/evals/cases/stale-source-evidence/REQUEST.md +12 -0
  53. package/evals/cases/weekend-library/EXPECTATIONS +19 -0
  54. package/evals/cases/weekend-library/REQUEST.baseline.md +10 -0
  55. package/evals/cases/weekend-library/REQUEST.md +11 -0
  56. package/evals/cases-roster.txt +19 -0
  57. package/evals/external/GRADE.schema.json +39 -0
  58. package/evals/external/README.md +42 -0
  59. package/evals/external/RUBRIC.md +32 -0
  60. package/evals/metrics/context-cost.json +154 -0
  61. package/evals/outcomes/README.md +65 -0
  62. package/evals/outcomes/cases/tenant-notes-api/REQUEST.baseline.md +14 -0
  63. package/evals/outcomes/cases/tenant-notes-api/REQUEST.md +13 -0
  64. package/evals/outcomes/cases/tenant-notes-api/VERIFY.sh +13 -0
  65. package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/README.md +93 -0
  66. package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/treatment/plan/PLAN.json +547 -0
  67. package/evals/runners/claude-baseline.sh +4 -0
  68. package/evals/runners/claude-grade.sh +3 -0
  69. package/evals/runners/claude.sh +4 -0
  70. package/evals/runners/codex-baseline.sh +181 -0
  71. package/evals/runners/codex-builder.sh +96 -0
  72. package/evals/runners/codex-godaudits.sh +84 -0
  73. package/evals/runners/codex.sh +147 -0
  74. package/evals/runners/gemini-baseline.sh +4 -0
  75. package/evals/runners/gemini-grade.sh +3 -0
  76. package/evals/runners/gemini.sh +4 -0
  77. package/evals/runners/vendor-cli.sh +257 -0
  78. package/evals/runners/vendor-grade.sh +82 -0
  79. package/install.sh +323 -0
  80. package/package.json +92 -4
  81. package/requirements/skills-ref.txt +2 -0
  82. package/scripts/build-catalog.js +114 -0
  83. package/scripts/build-prompt.sh +257 -0
  84. package/scripts/context-metrics.js +118 -0
  85. package/scripts/eval-external.js +226 -0
  86. package/scripts/eval-matrix.sh +172 -0
  87. package/scripts/eval-outcome.js +143 -0
  88. package/scripts/eval.sh +321 -0
  89. package/scripts/lint-parity.js +331 -0
  90. package/scripts/lint.sh +743 -0
  91. package/scripts/outcome-summary.js +126 -0
  92. package/scripts/release-check.sh +108 -0
  93. package/scripts/release-prepare.js +41 -0
  94. package/scripts/summarize-eval.js +91 -0
  95. package/scripts/summarize-matrix.js +101 -0
  96. package/scripts/version-sync.js +65 -0
  97. package/skills/godplans/SKILL.md +192 -0
  98. package/skills/godplans/references/agent-memory.md +168 -0
  99. package/skills/godplans/references/architecture.md +189 -0
  100. package/skills/godplans/references/build.md +130 -0
  101. package/skills/godplans/references/business.md +252 -0
  102. package/skills/godplans/references/code-quality.md +165 -0
  103. package/skills/godplans/references/compliance.md +59 -0
  104. package/skills/godplans/references/database.md +157 -0
  105. package/skills/godplans/references/deploy.md +146 -0
  106. package/skills/godplans/references/discovery.md +297 -0
  107. package/skills/godplans/references/doc-set.md +243 -0
  108. package/skills/godplans/references/exemplar.md +228 -0
  109. package/skills/godplans/references/launch.md +162 -0
  110. package/skills/godplans/references/llm.md +132 -0
  111. package/skills/godplans/references/observe.md +178 -0
  112. package/skills/godplans/references/plan-format.md +340 -0
  113. package/skills/godplans/references/product.md +130 -0
  114. package/skills/godplans/references/repo.md +184 -0
  115. package/skills/godplans/references/roadmap.md +158 -0
  116. package/skills/godplans/references/security.md +156 -0
  117. package/skills/godplans/references/seo.md +133 -0
  118. package/skills/godplans/references/stack.md +133 -0
  119. package/skills/godplans/references/style-genome.md +198 -0
  120. package/skills/godplans/references/ui.md +153 -0
  121. package/skills/godplans/references/ux.md +150 -0
  122. package/skills/godplans/schemas/PLAN.schema.json +275 -0
  123. package/skills/godplans/schemas/PLAN.v1.schema.json +258 -0
  124. package/skills/godplans/scripts/plan-halflife.sh +76 -0
  125. package/skills/godplans/scripts/style-stats.py +630 -0
  126. package/skills/godplans/scripts/validate-plan.sh +1709 -0
  127. package/skills/godplans/templates/PLAN.template.mdx +269 -0
  128. package/tests/agent-memory-guidance.sh +32 -0
  129. package/tests/build-catalog.sh +81 -0
  130. package/tests/codex-runner.sh +139 -0
  131. package/tests/eval-harness.sh +377 -0
  132. package/tests/evidence-harnesses.sh +243 -0
  133. package/tests/fixtures/plan-json-v1-1.13.0.json +472 -0
  134. package/tests/install-regression.sh +246 -0
  135. package/tests/lib/plan-schema-check.js +163 -0
  136. package/tests/lint-selftest.sh +582 -0
  137. package/tests/package-contents.sh +140 -0
  138. package/tests/portable-prompt.test.sh +261 -0
  139. package/tests/release-tooling.sh +204 -0
  140. package/tests/run.sh +14 -0
  141. package/tests/script-usage.sh +37 -0
  142. package/tests/style-stats.sh +170 -0
  143. package/tests/validate-plan.sh +1970 -0
  144. package/tests/vendor-runner.sh +291 -0
@@ -0,0 +1,743 @@
1
+ #!/usr/bin/env bash
2
+ # scripts/lint.sh: meta-linter for godplans.
3
+ #
4
+ # Mechanically enforces the discipline rules. Replaces "the rule says X"
5
+ # with "CI fails if X is violated."
6
+ #
7
+ # Checks run by --all (the default):
8
+ #
9
+ # unicode-clean no byte above 0x7F (so no em or en dashes, Unicode
10
+ # arrows, box-drawing characters, smart quotes,
11
+ # ellipsis characters, or emojis) in any authored text
12
+ # file: every tracked file and every untracked file git
13
+ # does not ignore, minus binary assets and frozen eval
14
+ # results. Without git, a name allowlist stands in.
15
+ # version-parity the SKILL.md frontmatter and body, the top CHANGELOG.md
16
+ # entry, package.json, the marketplace and plugin
17
+ # manifests, and the PLAN template carry one version; a
18
+ # missing surface fails by name. The README badge is
19
+ # left to version:check (scripts/version-sync.js).
20
+ # description-length the SKILL.md frontmatter description is one
21
+ # double-quoted line of 1-1024 characters (Agent
22
+ # Skills spec bound); a folded, literal, plain, or
23
+ # continued description fails.
24
+ # description-parity plugin.json and the godplans entry in the marketplace
25
+ # carry the SKILL.md frontmatter description exactly,
26
+ # and the marketplace metadata.description carries the
27
+ # package.json description.
28
+ # dir-name-match skill directory name matches frontmatter name.
29
+ # references-exist every references/<file>.md named in SKILL.md exists.
30
+ # modules-complete every domain module has the six contract sections.
31
+ # domain-parity the same domain modules appear in references/ (minus
32
+ # the contract modules), the SKILL.md Phase 4 table,
33
+ # the validator's %known_domain and %module_prefix
34
+ # keys, the full reference order in build-prompt.sh,
35
+ # the module lists in context-metrics.js and
36
+ # tests/portable-prompt.test.sh, the PLAN template's
37
+ # applicability matrix, and discovery's worked matrix;
38
+ # the schema's applicability minItems and maxItems
39
+ # equal the module count. The core and lazy split, the
40
+ # lazy module sentence, and the "all N domain modules"
41
+ # count in build-prompt.sh agree with them; each module
42
+ # has its own requirement prefix, the validator derives
43
+ # the prefix map back to modules with reverse, and each
44
+ # module defines its requirements under its prefix.
45
+ # symlinks-valid .agents/skills/godplans and .claude/skills/godplans
46
+ # are symlinks to skills/godplans, and
47
+ # plugins/godplans/skills is a symlink to skills.
48
+ # json-valid every authored JSON file parses.
49
+ # shell-syntax every authored *.sh parses in its declared shell (sh
50
+ # or bash) and uses no bash 4 or later construct that
51
+ # stock macOS /bin/bash 3.2 cannot run.
52
+ # js-syntax every authored *.js, *.mjs, and *.cjs passes
53
+ # node --check.
54
+ # python-syntax every authored *.py parses with ast.parse, which
55
+ # writes no bytecode; skipped visibly when python3
56
+ # cannot run.
57
+ # eval-cases behavioral case manifests are complete and valid.
58
+ # product-surfaces the shipped validator and half-life script and the
59
+ # evaluation, release, and test entry points exist and
60
+ # are executable.
61
+ # action-pins every third-party GitHub Action (`uses:` or
62
+ # `- uses:`, quoted or not) uses a full commit SHA.
63
+ # official-validator runs skills-ref, found in SKILLS_REF_BIN, then
64
+ # .venv-skills-ref/bin/skills-ref, then PATH. Skips
65
+ # visibly (a "skip" line, not "ok") when none is
66
+ # installed or when one found automatically cannot
67
+ # execute; fails when the validator rejects the skill
68
+ # or an explicit SKILLS_REF_BIN cannot execute.
69
+ # prompt-fresh PROMPT.md matches build-prompt.sh without mutation.
70
+ # context-metrics published prompt and module cost metrics are current.
71
+ #
72
+ # Release-only (never part of --all; scripts/release-check.sh runs it by name
73
+ # because it needs an authenticated gh CLI and the network):
74
+ #
75
+ # tag-release-parity verifies published tags against package versions and
76
+ # releases; skips visibly without an authenticated gh.
77
+ #
78
+ # Usage: bash scripts/lint.sh [--verbose] [--all | check-name ...]
79
+ #
80
+ # Several check names run each named check in the order given. An unknown,
81
+ # empty, or blank name fails before any check runs. --verbose is only a flag
82
+ # and may appear anywhere. Each check runs in a subshell with errexit on, so a
83
+ # command that crashes inside a check counts as a failure, and every later
84
+ # check still runs. The exit status is 1 when any check failed.
85
+ #
86
+ # Bash 3.2 compatible (macOS default). Nested bash runs use the bash running
87
+ # this script ($BASH), so /bin/bash scripts/lint.sh tests 3.2.
88
+
89
+ set -eu
90
+
91
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
92
+ REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
93
+ SKILL_DIR="$REPO_DIR/skills/godplans"
94
+ BASH_BIN="${BASH:-bash}"
95
+ TAB="$(printf '\t')"
96
+ # Reference files that are contracts rather than planning domains. They skip
97
+ # the six-section module contract and are left out of domain-parity.
98
+ CONTRACT_MODULES="plan-format discovery compliance exemplar doc-set"
99
+ ALL_CHECKS="unicode-clean version-parity description-length description-parity dir-name-match references-exist modules-complete domain-parity symlinks-valid json-valid shell-syntax js-syntax python-syntax eval-cases product-surfaces action-pins official-validator prompt-fresh context-metrics"
100
+ RELEASE_CHECKS="tag-release-parity"
101
+ VERBOSE=0
102
+ TARGETS=""
103
+ CHECK=lint
104
+ CHECK_BAD=0
105
+ CHECK_SKIPPED=0
106
+
107
+ usage() {
108
+ cat <<EOF
109
+ Usage: bash scripts/lint.sh [--verbose] [--all | check-name ...]
110
+
111
+ With no check names (or --all), runs every check below. Several names run
112
+ each named check. One failing check never stops the others; a check that
113
+ stops on an error counts as a failure. Exit status 1 when any check failed.
114
+
115
+ Checks: $ALL_CHECKS
116
+ Release-only: $RELEASE_CHECKS
117
+ EOF
118
+ }
119
+
120
+ while [ "$#" -gt 0 ]; do
121
+ case "$1" in
122
+ --verbose) VERBOSE=1 ;;
123
+ --all) TARGETS="$TARGETS $ALL_CHECKS" ;;
124
+ -h|--help) usage; exit 0 ;;
125
+ -*) echo "Unknown option: $1" >&2; usage >&2; exit 1 ;;
126
+ # An empty name (lint.sh "$UNSET") would otherwise run nothing and pass.
127
+ ''|*[[:space:]]*) echo "Empty or blank check name: '$1'" >&2; usage >&2; exit 1 ;;
128
+ *) TARGETS="$TARGETS $1" ;;
129
+ esac
130
+ shift
131
+ done
132
+ [ -n "$TARGETS" ] || TARGETS=$ALL_CHECKS
133
+
134
+ check_function() {
135
+ case "$1" in
136
+ unicode-clean) echo check_unicode_clean ;;
137
+ version-parity) echo check_version_parity ;;
138
+ description-length) echo check_description_length ;;
139
+ description-parity) echo check_description_parity ;;
140
+ dir-name-match) echo check_dir_name_match ;;
141
+ references-exist) echo check_references_exist ;;
142
+ modules-complete) echo check_modules_complete ;;
143
+ domain-parity) echo check_domain_parity ;;
144
+ symlinks-valid) echo check_symlinks_valid ;;
145
+ json-valid) echo check_json_valid ;;
146
+ shell-syntax) echo check_shell_syntax ;;
147
+ js-syntax) echo check_js_syntax ;;
148
+ python-syntax) echo check_python_syntax ;;
149
+ eval-cases) echo check_eval_cases ;;
150
+ product-surfaces) echo check_product_surfaces ;;
151
+ action-pins) echo check_action_pins ;;
152
+ official-validator) echo check_official_validator ;;
153
+ tag-release-parity) echo check_tag_release_parity ;;
154
+ prompt-fresh) echo check_prompt_fresh ;;
155
+ context-metrics) echo check_context_metrics ;;
156
+ *) return 1 ;;
157
+ esac
158
+ }
159
+
160
+ # Reject every unknown name before any check runs.
161
+ unknown=0
162
+ for name in $TARGETS; do
163
+ if ! check_function "$name" >/dev/null; then
164
+ echo "Unknown check: $name" >&2
165
+ unknown=1
166
+ fi
167
+ done
168
+ if [ "$unknown" = "1" ]; then
169
+ usage >&2
170
+ exit 1
171
+ fi
172
+
173
+ # Scratch space for state that must outlive a check's subshell: one line per
174
+ # failure in FAIL_LOG, and the cached authored-file list.
175
+ LINT_TMP="$(mktemp -d "${TMPDIR:-/tmp}/godplans-lint.XXXXXX")"
176
+ trap 'rm -rf "$LINT_TMP"' EXIT
177
+ FAIL_LOG="$LINT_TMP/failures"
178
+ : > "$FAIL_LOG"
179
+
180
+ note() { [ "$VERBOSE" = "1" ] && echo " $*" || true; }
181
+ fail() { echo "FAIL [$CHECK] $*" >&2; CHECK_BAD=1; printf '%s\n' "$CHECK" >> "$FAIL_LOG"; }
182
+ skip() { echo "skip [$CHECK] $*"; CHECK_SKIPPED=1; }
183
+ pass() {
184
+ if [ "$CHECK_BAD" = "0" ] && [ "$CHECK_SKIPPED" = "0" ]; then
185
+ echo "ok [$CHECK]"
186
+ fi
187
+ }
188
+
189
+ # in_git_checkout: true when REPO_DIR is the top level of a git work tree (not
190
+ # merely a directory inside some other repository, such as an unpacked npm
191
+ # tarball under a checkout).
192
+ in_git_checkout() {
193
+ command -v git >/dev/null 2>&1 || return 1
194
+ top=$(git -C "$REPO_DIR" rev-parse --show-toplevel 2>/dev/null) || return 1
195
+ [ -n "$top" ] || return 1
196
+ [ "$(cd "$top" && pwd -P)" = "$(cd "$REPO_DIR" && pwd -P)" ]
197
+ }
198
+
199
+ # authored_files: print every authored text file as a repo-relative path, one
200
+ # per line. In a git checkout that is every tracked file plus every untracked
201
+ # file git does not ignore, so ignored local state (.godplans/, the validator
202
+ # venv, editor settings) is never scanned. Without git it falls back to a name
203
+ # allowlist. Frozen eval results, symlinks, deleted paths, and binary assets are
204
+ # left out. The list is built once per run and cached in LINT_TMP.
205
+ authored_files() {
206
+ cache="$LINT_TMP/authored-files"
207
+ if [ ! -f "$cache" ]; then
208
+ raw="$LINT_TMP/authored-files.raw"
209
+ if in_git_checkout; then
210
+ (cd "$REPO_DIR" && git ls-files -z --cached --others --exclude-standard -- . \
211
+ ':(exclude)evals/output' \
212
+ ':(exclude)evals/results' \
213
+ ':(exclude)evals/external/results' \
214
+ ':(exclude)evals/outcomes/results') > "$raw.z"
215
+ tr '\0' '\n' < "$raw.z" > "$raw"
216
+ else
217
+ (cd "$REPO_DIR" && find . \
218
+ \( -path ./.git -o -path ./node_modules -o -path ./.venv-skills-ref \
219
+ -o -path ./.godplans -o -path ./.claude/worktrees \
220
+ -o -path ./.claude/settings.local.json \
221
+ -o -path ./evals/output -o -path ./evals/results \
222
+ -o -path ./evals/external/results -o -path ./evals/outcomes/results \) -prune -o \
223
+ -type f \( -name '*.md' -o -name '*.mdx' -o -name '*.sh' -o -name '*.js' \
224
+ -o -name '*.mjs' -o -name '*.cjs' -o -name '*.json' -o -name '*.yml' \
225
+ -o -name '*.yaml' -o -name '*.py' -o -name '*.txt' -o -name 'EXPECTATIONS' \
226
+ -o -name '.gitignore' -o -name '.gitattributes' -o -name '.editorconfig' \
227
+ -o -name 'CODEOWNERS' -o -name 'LICENSE' \) -print) > "$raw.find"
228
+ sed 's|^\./||' "$raw.find" > "$raw"
229
+ fi
230
+ : > "$cache.tmp"
231
+ while IFS= read -r f; do
232
+ [ -n "$f" ] || continue
233
+ if [ -L "$REPO_DIR/$f" ] || [ ! -f "$REPO_DIR/$f" ]; then
234
+ continue
235
+ fi
236
+ case "$f" in
237
+ *.jpg|*.jpeg|*.png|*.gif|*.webp|*.ico|*.pdf|*.zip|*.gz|*.tgz|*.woff|*.woff2|*.ttf|*.otf) continue ;;
238
+ esac
239
+ printf '%s\n' "$f" >> "$cache.tmp"
240
+ done < "$raw"
241
+ mv "$cache.tmp" "$cache"
242
+ fi
243
+ cat "$cache"
244
+ }
245
+
246
+ # authored_matching ERE: the authored files whose path matches ERE.
247
+ authored_matching() {
248
+ authored_files > "$LINT_TMP/authored-all"
249
+ grep -E -e "$1" "$LINT_TMP/authored-all" || true
250
+ }
251
+
252
+ # parity MODE [ARG]: run scripts/lint-parity.js, which reads the SKILL.md
253
+ # description and the domain module lists and prints what it finds. A read
254
+ # error exits 2 with the reason on stderr.
255
+ parity() {
256
+ node "$SCRIPT_DIR/lint-parity.js" "$@"
257
+ }
258
+
259
+ check_unicode_clean() {
260
+ CHECK=unicode-clean
261
+ # perl, not grep -P: BSD grep on stock macOS has no -P and would silently
262
+ # skip the scan. The rule is stricter than the ban list: authored files are
263
+ # pure ASCII, so any byte above 0x7F fails.
264
+ command -v perl >/dev/null 2>&1 || { fail "perl not found; cannot scan"; return 0; }
265
+ files="$LINT_TMP/unicode-files"
266
+ authored_files > "$files"
267
+ if [ ! -s "$files" ]; then
268
+ fail "no authored files found to scan"
269
+ return 0
270
+ fi
271
+ note "$(wc -l < "$files" | tr -d ' ') authored files scanned"
272
+ hits="$LINT_TMP/unicode-hits"
273
+ (cd "$REPO_DIR" && perl -e '
274
+ while (my $f = <STDIN>) {
275
+ chomp $f;
276
+ open(my $fh, "<", $f) or die "cannot read $f: $!\n";
277
+ my $n = 0;
278
+ while (my $line = <$fh>) {
279
+ next unless $line =~ /[^\x00-\x7F]/;
280
+ print "FILE $f\n" if $n == 0;
281
+ $line .= "\n" unless $line =~ /\n\z/;
282
+ print "$.:$line";
283
+ last if ++$n == 5;
284
+ }
285
+ close $fh;
286
+ }' < "$files") > "$hits"
287
+ while IFS= read -r line; do
288
+ case "$line" in
289
+ "FILE "*) fail "non-ASCII character in ${line#FILE }:" ;;
290
+ *) printf '%s\n' "$line" >&2 ;;
291
+ esac
292
+ done < "$hits"
293
+ pass
294
+ }
295
+
296
+ check_version_parity() {
297
+ CHECK=version-parity
298
+ missing=0
299
+ for rel in \
300
+ skills/godplans/SKILL.md \
301
+ CHANGELOG.md \
302
+ package.json \
303
+ .claude-plugin/marketplace.json \
304
+ plugins/godplans/.claude-plugin/plugin.json \
305
+ skills/godplans/templates/PLAN.template.mdx
306
+ do
307
+ if [ ! -f "$REPO_DIR/$rel" ]; then
308
+ fail "missing version surface: $rel"
309
+ missing=1
310
+ fi
311
+ done
312
+ [ "$missing" = "0" ] || return 0
313
+ fm=$(awk -F'"' '/^ version:/ { print $2; exit }' "$SKILL_DIR/SKILL.md")
314
+ ch=$(grep -m1 '^## \[' "$REPO_DIR/CHANGELOG.md" | sed 's/^## \[\([^]]*\)\].*/\1/' || true)
315
+ body=$(grep -m1 '^## Skill version:' "$SKILL_DIR/SKILL.md" | sed 's/^## Skill version: //' || true)
316
+ package=$(awk -F'"' '/"version":/ { print $4; exit }' "$REPO_DIR/package.json")
317
+ marketplace=$(awk -F'"' '/"version":/ { print $4; exit }' "$REPO_DIR/.claude-plugin/marketplace.json")
318
+ plugin=$(awk -F'"' '/"version":/ { print $4; exit }' "$REPO_DIR/plugins/godplans/.claude-plugin/plugin.json")
319
+ template=$(grep -m1 'plan created (godplans v' "$SKILL_DIR/templates/PLAN.template.mdx" | sed 's/.*godplans v\([^)]*\).*/\1/' || true)
320
+ if [ -z "$fm" ]; then
321
+ fail "SKILL.md frontmatter has no metadata version"
322
+ return 0
323
+ fi
324
+ for pair in \
325
+ "CHANGELOG:$ch" \
326
+ "SKILL-body:$body" \
327
+ "package:$package" \
328
+ "marketplace:$marketplace" \
329
+ "plugin:$plugin" \
330
+ "template:$template"
331
+ do
332
+ label=${pair%%:*}
333
+ value=${pair#*:}
334
+ if [ "$fm" != "$value" ]; then
335
+ fail "$label version ($value) != SKILL.md version ($fm)"
336
+ fi
337
+ done
338
+ pass
339
+ }
340
+
341
+ check_description_length() {
342
+ CHECK=description-length
343
+ command -v node >/dev/null 2>&1 || { fail "node not found; cannot parse the SKILL.md frontmatter"; return 0; }
344
+ if ! len=$(parity description-length 2>"$LINT_TMP/description.err"); then
345
+ fail "cannot read the SKILL.md description: $(cat "$LINT_TMP/description.err")"
346
+ return 0
347
+ fi
348
+ if [ "$len" -lt 1 ] || [ "$len" -gt 1024 ]; then
349
+ fail "description is $len characters; Agent Skills spec bound is 1-1024"
350
+ else
351
+ note "description length: $len"
352
+ fi
353
+ pass
354
+ }
355
+
356
+ check_description_parity() {
357
+ CHECK=description-parity
358
+ command -v node >/dev/null 2>&1 || { fail "node not found; cannot compare descriptions"; return 0; }
359
+ out="$LINT_TMP/description-parity"
360
+ if ! parity description-parity > "$out" 2>"$LINT_TMP/description.err"; then
361
+ fail "cannot compare descriptions: $(cat "$LINT_TMP/description.err")"
362
+ return 0
363
+ fi
364
+ while IFS= read -r line; do
365
+ if [ -n "$line" ]; then
366
+ fail "$line"
367
+ fi
368
+ done < "$out"
369
+ pass
370
+ }
371
+
372
+ check_dir_name_match() {
373
+ CHECK=dir-name-match
374
+ fm_name=$(awk '/^name:/ {print $2; exit}' "$SKILL_DIR/SKILL.md")
375
+ dir_name=$(basename "$SKILL_DIR")
376
+ if [ "$fm_name" != "$dir_name" ]; then
377
+ fail "frontmatter name ($fm_name) != directory name ($dir_name)"
378
+ fi
379
+ pass
380
+ }
381
+
382
+ check_references_exist() {
383
+ CHECK=references-exist
384
+ for ref in $(grep -o 'references/[a-z-]*\.md' "$SKILL_DIR/SKILL.md" | sort -u); do
385
+ if [ ! -f "$SKILL_DIR/$ref" ]; then
386
+ fail "SKILL.md names $ref but it does not exist"
387
+ else
388
+ note "$ref exists"
389
+ fi
390
+ done
391
+ pass
392
+ }
393
+
394
+ check_modules_complete() {
395
+ CHECK=modules-complete
396
+ for f in "$SKILL_DIR"/references/*.md; do
397
+ base=$(basename "$f" .md)
398
+ case " $CONTRACT_MODULES " in
399
+ *" $base "*) continue ;;
400
+ esac
401
+ for section in "## Lineage" "## Decisions to force" "## Plan requirements" "## Task seeds" "## Self-audit rubric" "## Anti-patterns refused"; do
402
+ if ! grep -q "^$section" "$f"; then
403
+ fail "$base.md missing section: $section"
404
+ fi
405
+ done
406
+ done
407
+ pass
408
+ }
409
+
410
+ check_domain_parity() {
411
+ CHECK=domain-parity
412
+ command -v node >/dev/null 2>&1 || { fail "node not found; cannot compare the domain lists"; return 0; }
413
+ out="$LINT_TMP/domain-parity"
414
+ if ! parity domain-parity "$CONTRACT_MODULES" > "$out" 2>"$LINT_TMP/domain-parity.err"; then
415
+ fail "cannot compare the domain lists: $(cat "$LINT_TMP/domain-parity.err")"
416
+ return 0
417
+ fi
418
+ while IFS= read -r line; do
419
+ case "$line" in
420
+ "domains "*)
421
+ set -- $line
422
+ note "$2 domain modules compared against $3 lists"
423
+ ;;
424
+ "problem "*) fail "${line#problem }" ;;
425
+ esac
426
+ done < "$out"
427
+ pass
428
+ }
429
+
430
+ check_symlinks_valid() {
431
+ CHECK=symlinks-valid
432
+ for pair in \
433
+ ".agents/skills/godplans:skills/godplans" \
434
+ ".claude/skills/godplans:skills/godplans" \
435
+ "plugins/godplans/skills:skills"
436
+ do
437
+ rel=${pair%%:*}
438
+ target=${pair#*:}
439
+ link="$REPO_DIR/$rel"
440
+ if [ ! -L "$link" ]; then
441
+ if [ -e "$link" ]; then
442
+ fail "$rel is not a symlink to $target (a copy or a checked-out link file drifts from the canonical skill)"
443
+ else
444
+ fail "$rel does not exist; it must be a symlink to $target"
445
+ fi
446
+ elif [ ! -d "$link" ]; then
447
+ fail "$rel does not resolve to a directory; it must be a symlink to $target"
448
+ else
449
+ resolved=$(cd "$link" && pwd -P)
450
+ expected=$(cd "$REPO_DIR/$target" && pwd -P)
451
+ if [ "$resolved" != "$expected" ]; then
452
+ fail "$rel resolves to $resolved, not $target"
453
+ else
454
+ note "$rel -> $target"
455
+ fi
456
+ fi
457
+ done
458
+ pass
459
+ }
460
+
461
+ check_json_valid() {
462
+ CHECK=json-valid
463
+ command -v node >/dev/null 2>&1 || { fail "node not found; cannot parse JSON"; return 0; }
464
+ files="$LINT_TMP/json-files"
465
+ authored_matching '\.json$' > "$files"
466
+ bad="$LINT_TMP/json-bad"
467
+ (cd "$REPO_DIR" && node -e '
468
+ const fs = require("fs");
469
+ const files = fs.readFileSync(0, "utf8").split("\n").filter(Boolean);
470
+ for (const f of files) {
471
+ try {
472
+ JSON.parse(fs.readFileSync(f, "utf8"));
473
+ } catch (error) {
474
+ process.stdout.write(f + "\t" + String(error.message).split("\n")[0] + "\n");
475
+ }
476
+ }' < "$files") > "$bad"
477
+ while IFS="$TAB" read -r f message; do
478
+ fail "invalid JSON: $f ($message)"
479
+ done < "$bad"
480
+ note "$(wc -l < "$files" | tr -d ' ') JSON files parsed"
481
+ pass
482
+ }
483
+
484
+ check_shell_syntax() {
485
+ CHECK=shell-syntax
486
+ files="$LINT_TMP/shell-files"
487
+ authored_matching '\.sh$' > "$files"
488
+ if [ ! -s "$files" ]; then
489
+ fail "no shell scripts found"
490
+ return 0
491
+ fi
492
+ # Bash 4 and later constructs that stock macOS /bin/bash 3.2 cannot run.
493
+ # Some pass bash -n even under 3.2 and fail only when the line runs; all of
494
+ # them pass bash -n under Ubuntu's bash 5. Covered: declare, local, or
495
+ # typeset with -A, -n, -g, -l, or -u; mapfile, readarray, and coproc;
496
+ # case-changing expansions (${x,,}) and transformations (${x@Q}); negative
497
+ # array subscripts (${a[-1]}); &>>, |&, ;&, and ;;&; [[ -v ]] and [[ -R ]];
498
+ # any wait option (wait -n); and shopt with a bash 4 option (globstar,
499
+ # lastpipe, inherit_errexit, and the like). Comment lines are skipped. The
500
+ # brackets keep these patterns from matching their own lines.
501
+ b4='(^|[^[:alnum:]_])(declare|local|typeset)[[:space:]]+-[[:alpha:]]*[Angul]'
502
+ b4="$b4"'|(^|[^[:alnum:]_-])(ma[p]file|read[a]rray|co[p]roc)([^[:alnum:]_-]|$)'
503
+ b4="$b4"'|[$][{]([[:alpha:]_][[:alnum:]_]*([[][^]]*[]])?|[0-9@*])[,^]'
504
+ b4="$b4"'|[$][{][^}]*@[QEPAaKkUuL][}]'
505
+ b4="$b4"'|[$][{][[:alpha:]_][[:alnum:]_]*[[][[:space:]]*-[0-9]'
506
+ b4="$b4"'|[&]>>|;[&]([[:space:]]|$)|(^|[^|])[|][&]([[:space:]]|$)'
507
+ b4="$b4"'|[[][[][[:space:]]+-[vR][[:space:]]'
508
+ b4="$b4"'|(^|[^[:alnum:]_-])wa[i]t[[:space:]]+-[[:alpha:]]'
509
+ b4="$b4"'|sh[o]pt[[:space:]].*(glob[s]tar|last[p]ipe|inherit_[e]rrexit|auto[c]d|check[j]obs|dir[s]pell|dir[e]xpand|globascii[r]anges|localvar_[i]nherit)'
510
+ err="$LINT_TMP/shell-err"
511
+ while IFS= read -r rel; do
512
+ f="$REPO_DIR/$rel"
513
+ shebang=$(sed -n '1p' "$f")
514
+ case "$shebang" in
515
+ '#!/bin/sh'|'#!/bin/sh '*|'#!/usr/bin/env sh'|'#!/usr/bin/env sh '*) shell=sh ;;
516
+ *) shell=$BASH_BIN ;;
517
+ esac
518
+ if ! "$shell" -n "$f" 2>"$err"; then
519
+ fail "$rel does not parse as $(basename "$shell"):"
520
+ sed -n '1,5p' "$err" | sed 's/^/ /' >&2
521
+ fi
522
+ hits=$(grep -n -E -e "$b4" "$f" | grep -v -E '^[0-9]+:[[:space:]]*#' | head -3 || true)
523
+ if [ -n "$hits" ]; then
524
+ fail "$rel uses a bash 4 construct that bash 3.2 cannot run:"
525
+ printf '%s\n' "$hits" | sed 's/^/ /' >&2
526
+ fi
527
+ done < "$files"
528
+ note "$(wc -l < "$files" | tr -d ' ') shell scripts parsed"
529
+ pass
530
+ }
531
+
532
+ check_js_syntax() {
533
+ CHECK=js-syntax
534
+ command -v node >/dev/null 2>&1 || { fail "node not found; cannot check JavaScript syntax"; return 0; }
535
+ files="$LINT_TMP/js-files"
536
+ authored_matching '\.(js|mjs|cjs)$' > "$files"
537
+ err="$LINT_TMP/js-err"
538
+ while IFS= read -r rel; do
539
+ if ! node --check "$REPO_DIR/$rel" 2>"$err"; then
540
+ fail "$rel does not parse:"
541
+ sed -n '1,5p' "$err" | sed 's/^/ /' >&2
542
+ fi
543
+ done < "$files"
544
+ note "$(wc -l < "$files" | tr -d ' ') JavaScript files checked"
545
+ pass
546
+ }
547
+
548
+ check_python_syntax() {
549
+ CHECK=python-syntax
550
+ files="$LINT_TMP/python-files"
551
+ authored_matching '\.py$' > "$files"
552
+ if [ ! -s "$files" ]; then
553
+ pass
554
+ return 0
555
+ fi
556
+ count=$(wc -l < "$files" | tr -d ' ')
557
+ if ! command -v python3 >/dev/null 2>&1 || ! python3 -c 'import ast' >/dev/null 2>&1; then
558
+ skip "python3 cannot run; $count Python file(s) not parsed"
559
+ return 0
560
+ fi
561
+ err="$LINT_TMP/python-err"
562
+ # ast.parse compiles nothing to disk, unlike py_compile, so no __pycache__
563
+ # lands in the skill directory that install.sh copies.
564
+ while IFS= read -r rel; do
565
+ if ! PYTHONDONTWRITEBYTECODE=1 python3 -c 'import ast, sys; ast.parse(open(sys.argv[1], "rb").read(), sys.argv[1])' "$REPO_DIR/$rel" 2>"$err"; then
566
+ fail "$rel does not parse:"
567
+ tail -n 4 "$err" | sed 's/^/ /' >&2
568
+ fi
569
+ done < "$files"
570
+ note "$count Python files parsed"
571
+ pass
572
+ }
573
+
574
+ check_eval_cases() {
575
+ CHECK=eval-cases
576
+ if ! "$BASH_BIN" "$REPO_DIR/scripts/eval.sh" --check-cases >/dev/null; then
577
+ fail "behavioral case contract failed"
578
+ fi
579
+ pass
580
+ }
581
+
582
+ check_product_surfaces() {
583
+ CHECK=product-surfaces
584
+ for f in \
585
+ "$SKILL_DIR/scripts/validate-plan.sh" \
586
+ "$SKILL_DIR/scripts/plan-halflife.sh" \
587
+ "$REPO_DIR/scripts/eval.sh" \
588
+ "$REPO_DIR/scripts/eval-matrix.sh" \
589
+ "$REPO_DIR/scripts/eval-external.js" \
590
+ "$REPO_DIR/scripts/eval-outcome.js" \
591
+ "$REPO_DIR/scripts/outcome-summary.js" \
592
+ "$REPO_DIR/scripts/release-check.sh" \
593
+ "$REPO_DIR/evals/runners/codex.sh" \
594
+ "$REPO_DIR/tests/run.sh"
595
+ do
596
+ if [ ! -x "$f" ]; then
597
+ fail "missing executable: ${f#$REPO_DIR/}"
598
+ fi
599
+ done
600
+ pass
601
+ }
602
+
603
+ check_context_metrics() {
604
+ CHECK=context-metrics
605
+ if ! node "$REPO_DIR/scripts/context-metrics.js" --check >/dev/null; then
606
+ fail "evals/metrics/context-cost.json is stale"
607
+ fi
608
+ pass
609
+ }
610
+
611
+ check_action_pins() {
612
+ CHECK=action-pins
613
+ for workflow in "$REPO_DIR"/.github/workflows/*.yml "$REPO_DIR"/.github/workflows/*.yaml; do
614
+ [ -f "$workflow" ] || continue
615
+ while IFS= read -r line; do
616
+ # Accept `uses:` on its own line and the `- uses:` list-item form, and
617
+ # drop the quotes YAML allows around the reference.
618
+ ref=$(printf '%s\n' "$line" | sed -n 's/^[[:space:]]*-\{0,1\}[[:space:]]*uses:[[:space:]]*\([^#[:space:]]*\).*/\1/p' | tr -d '\042\047')
619
+ [ -n "$ref" ] || continue
620
+ case "$ref" in
621
+ ./*) continue ;;
622
+ esac
623
+ if ! printf '%s\n' "$ref" | grep -Eq '@[0-9a-f]{40}$'; then
624
+ fail "floating GitHub Action reference in ${workflow#$REPO_DIR/}: $ref"
625
+ fi
626
+ done < "$workflow"
627
+ done
628
+ pass
629
+ }
630
+
631
+ check_official_validator() {
632
+ CHECK=official-validator
633
+ explicit=0
634
+ if [ -n "${SKILLS_REF_BIN:-}" ]; then
635
+ validator=$SKILLS_REF_BIN
636
+ explicit=1
637
+ elif [ -x "$REPO_DIR/.venv-skills-ref/bin/skills-ref" ]; then
638
+ validator="$REPO_DIR/.venv-skills-ref/bin/skills-ref"
639
+ elif command -v skills-ref >/dev/null 2>&1; then
640
+ validator=$(command -v skills-ref)
641
+ else
642
+ skip "skills-ref not installed; scripts/release-check.sh requires it"
643
+ return 0
644
+ fi
645
+ # A validator that cannot start (a stale pipx shim whose interpreter was
646
+ # deleted, a wrong path) is not a validator that rejected the skill.
647
+ rc=0
648
+ "$validator" --version >/dev/null 2>&1 || rc=$?
649
+ if [ "$rc" = "0" ]; then
650
+ out="$LINT_TMP/skills-ref.out"
651
+ "$validator" validate "$SKILL_DIR" > "$out" 2>&1 || rc=$?
652
+ if [ "$rc" = "0" ]; then
653
+ note "skills-ref accepted skills/godplans ($validator)"
654
+ pass
655
+ return 0
656
+ fi
657
+ if [ "$rc" != "126" ] && [ "$rc" != "127" ]; then
658
+ fail "official skills-ref validator rejected skills/godplans (exit $rc):"
659
+ sed -n '1,20p' "$out" | sed 's/^/ /' >&2
660
+ return 0
661
+ fi
662
+ fi
663
+ if [ "$explicit" = "1" ]; then
664
+ case "$validator" in
665
+ */*) [ -x "$validator" ] || { fail "SKILLS_REF_BIN=$validator is not an executable file"; return 0; } ;;
666
+ esac
667
+ fail "could not execute $validator (exit $rc); fix SKILLS_REF_BIN"
668
+ else
669
+ skip "$validator is installed but cannot run (exit $rc); reinstall it or set SKILLS_REF_BIN"
670
+ fi
671
+ return 0
672
+ }
673
+
674
+ check_tag_release_parity() {
675
+ CHECK=tag-release-parity
676
+ if ! command -v gh >/dev/null 2>&1 || ! gh auth status >/dev/null 2>&1; then
677
+ skip "authenticated gh CLI unavailable; scripts/release-check.sh requires it"
678
+ return 0
679
+ fi
680
+ # A clone made with --no-tags or --depth has nothing to compare, and an empty
681
+ # loop must not read as parity.
682
+ if [ "$(git -C "$REPO_DIR" rev-parse --is-shallow-repository 2>/dev/null)" = "true" ] ||
683
+ [ -z "$(git -C "$REPO_DIR" tag --list 'v*')" ]; then
684
+ fail "no v* tags in a full-history checkout; run git fetch --tags --unshallow (or git fetch --tags) first"
685
+ return 0
686
+ fi
687
+ for tag in $(git -C "$REPO_DIR" tag --list 'v*' --sort=version:refname); do
688
+ version=${tag#v}
689
+ tagged_version=$(git -C "$REPO_DIR" show "$tag:package.json" 2>/dev/null | awk -F'"' '/"version":/ { print $4; exit }' || true)
690
+ if [ "$tagged_version" != "$version" ]; then
691
+ fail "$tag package version ($tagged_version) does not match $version"
692
+ fi
693
+ release_record=$(gh release view "$tag" --repo hannsxpeter/godplans --json tagName,isDraft --jq '[.tagName, (.isDraft | tostring)] | @tsv' 2>/dev/null || true)
694
+ expected_record=$(printf '%s\tfalse' "$tag")
695
+ if [ "$release_record" != "$expected_record" ]; then
696
+ fail "$tag has no matching published GitHub release"
697
+ fi
698
+ done
699
+ pass
700
+ }
701
+
702
+ check_prompt_fresh() {
703
+ CHECK=prompt-fresh
704
+ if [ ! -f "$REPO_DIR/PROMPT.md" ]; then
705
+ fail "PROMPT.md missing; run scripts/build-prompt.sh"
706
+ return 0
707
+ fi
708
+ generated="$LINT_TMP/PROMPT.generated"
709
+ err="$LINT_TMP/prompt-err"
710
+ if ! GODPLANS_PROMPT_OUT="$generated" "$BASH_BIN" "$SCRIPT_DIR/build-prompt.sh" >/dev/null 2>"$err"; then
711
+ fail "scripts/build-prompt.sh failed, so PROMPT.md freshness is unknown:"
712
+ sed -n '1,10p' "$err" | sed 's/^/ /' >&2
713
+ return 0
714
+ fi
715
+ if ! cmp -s "$generated" "$REPO_DIR/PROMPT.md"; then
716
+ fail "PROMPT.md is stale; run scripts/build-prompt.sh and commit the diff"
717
+ fi
718
+ pass
719
+ }
720
+
721
+ # Each check runs in a subshell with errexit on, so a command that crashes
722
+ # inside it (an awk error, an unset variable) stops that check and is counted
723
+ # instead of being ignored. The subshell must not sit in an if, ||, &&, or !
724
+ # list: bash turns errexit off inside those, which would hide the crash. fail()
725
+ # appends to FAIL_LOG, so the failure survives the subshell.
726
+ for name in $TARGETS; do
727
+ fn=$(check_function "$name")
728
+ set +e
729
+ ( set -e; CHECK=$name; CHECK_BAD=0; CHECK_SKIPPED=0; "$fn" )
730
+ rc=$?
731
+ set -e
732
+ if [ "$rc" -ne 0 ]; then
733
+ CHECK=$name
734
+ fail "the check stopped early (exit $rc); a command inside it failed, see the error above"
735
+ fi
736
+ done
737
+
738
+ if [ -s "$FAIL_LOG" ]; then
739
+ failed=$(awk '!seen[$0]++' "$FAIL_LOG" | tr '\n' ' ' | sed 's/ $//')
740
+ echo "FAIL [lint] failing checks: $failed" >&2
741
+ exit 1
742
+ fi
743
+ exit 0