@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.
Files changed (146) hide show
  1. package/CHANGELOG.md +1202 -0
  2. package/LICENSE +21 -0
  3. package/PROMPT.md +4006 -0
  4. package/README.md +245 -2
  5. package/bin/godplans.js +93 -0
  6. package/docs/ARCHITECTURE.md +136 -0
  7. package/docs/RELEASING.md +107 -0
  8. package/docs/assets/badge-approved.svg +12 -0
  9. package/docs/assets/badge-done.svg +11 -0
  10. package/docs/assets/badge-graded.svg +12 -0
  11. package/docs/assets/badge-validated.svg +10 -0
  12. package/docs/assets/hero.svg +37 -0
  13. package/docs/assets/quest-map.svg +53 -0
  14. package/evals/README.md +295 -0
  15. package/evals/cases/brownfield-cli/EXPECTATIONS +15 -0
  16. package/evals/cases/brownfield-cli/INPUT/package.json +9 -0
  17. package/evals/cases/brownfield-cli/INPUT/src/cli.js +4 -0
  18. package/evals/cases/brownfield-cli/INPUT/src/format.js +3 -0
  19. package/evals/cases/brownfield-cli/INPUT/test/cli.test.js +7 -0
  20. package/evals/cases/brownfield-cli/REQUEST.baseline.md +10 -0
  21. package/evals/cases/brownfield-cli/REQUEST.md +10 -0
  22. package/evals/cases/compliance-refusal/EXPECTATIONS +4 -0
  23. package/evals/cases/compliance-refusal/REQUEST.baseline.md +9 -0
  24. package/evals/cases/compliance-refusal/REQUEST.md +8 -0
  25. package/evals/cases/greenfield-saas/EXPECTATIONS +21 -0
  26. package/evals/cases/greenfield-saas/REQUEST.baseline.md +11 -0
  27. package/evals/cases/greenfield-saas/REQUEST.md +11 -0
  28. package/evals/cases/nested-pillars/EXPECTATIONS +12 -0
  29. package/evals/cases/nested-pillars/REQUEST.baseline.md +10 -0
  30. package/evals/cases/nested-pillars/REQUEST.md +11 -0
  31. package/evals/cases/observability-evidence/EXPECTATIONS +10 -0
  32. package/evals/cases/observability-evidence/REQUEST.baseline.md +10 -0
  33. package/evals/cases/observability-evidence/REQUEST.md +11 -0
  34. package/evals/cases/product-business/EXPECTATIONS +18 -0
  35. package/evals/cases/product-business/REQUEST.baseline.md +13 -0
  36. package/evals/cases/product-business/REQUEST.md +14 -0
  37. package/evals/cases/product-form-routing/EXPECTATIONS +13 -0
  38. package/evals/cases/product-form-routing/REQUEST.baseline.md +11 -0
  39. package/evals/cases/product-form-routing/REQUEST.md +11 -0
  40. package/evals/cases/prose-integrity/EXPECTATIONS +19 -0
  41. package/evals/cases/prose-integrity/REQUEST.baseline.md +19 -0
  42. package/evals/cases/prose-integrity/REQUEST.md +20 -0
  43. package/evals/cases/replan-preserves-history/EXPECTATIONS +9 -0
  44. package/evals/cases/replan-preserves-history/INPUT/.godplans/PLAN.mdx +115 -0
  45. package/evals/cases/replan-preserves-history/INPUT/package.json +5 -0
  46. package/evals/cases/replan-preserves-history/REQUEST.baseline.md +10 -0
  47. package/evals/cases/replan-preserves-history/REQUEST.md +10 -0
  48. package/evals/cases/stale-prepublication/EXPECTATIONS +10 -0
  49. package/evals/cases/stale-prepublication/REQUEST.baseline.md +12 -0
  50. package/evals/cases/stale-prepublication/REQUEST.md +13 -0
  51. package/evals/cases/stale-source-evidence/EXPECTATIONS +10 -0
  52. package/evals/cases/stale-source-evidence/INPUT/package.json +8 -0
  53. package/evals/cases/stale-source-evidence/REQUEST.baseline.md +11 -0
  54. package/evals/cases/stale-source-evidence/REQUEST.md +12 -0
  55. package/evals/cases/weekend-library/EXPECTATIONS +19 -0
  56. package/evals/cases/weekend-library/REQUEST.baseline.md +10 -0
  57. package/evals/cases/weekend-library/REQUEST.md +11 -0
  58. package/evals/cases-roster.txt +19 -0
  59. package/evals/external/GRADE.schema.json +39 -0
  60. package/evals/external/README.md +42 -0
  61. package/evals/external/RUBRIC.md +32 -0
  62. package/evals/metrics/context-cost.json +154 -0
  63. package/evals/outcomes/README.md +65 -0
  64. package/evals/outcomes/cases/tenant-notes-api/REQUEST.baseline.md +14 -0
  65. package/evals/outcomes/cases/tenant-notes-api/REQUEST.md +13 -0
  66. package/evals/outcomes/cases/tenant-notes-api/VERIFY.sh +13 -0
  67. package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/README.md +93 -0
  68. package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/treatment/plan/PLAN.json +547 -0
  69. package/evals/runners/claude-baseline.sh +4 -0
  70. package/evals/runners/claude-grade.sh +3 -0
  71. package/evals/runners/claude.sh +4 -0
  72. package/evals/runners/codex-baseline.sh +181 -0
  73. package/evals/runners/codex-builder.sh +96 -0
  74. package/evals/runners/codex-godaudits.sh +84 -0
  75. package/evals/runners/codex.sh +147 -0
  76. package/evals/runners/gemini-baseline.sh +4 -0
  77. package/evals/runners/gemini-grade.sh +3 -0
  78. package/evals/runners/gemini.sh +4 -0
  79. package/evals/runners/vendor-cli.sh +257 -0
  80. package/evals/runners/vendor-grade.sh +82 -0
  81. package/install.sh +323 -0
  82. package/package.json +91 -4
  83. package/requirements/skills-ref.txt +2 -0
  84. package/scripts/build-catalog.js +114 -0
  85. package/scripts/build-prompt.sh +257 -0
  86. package/scripts/context-metrics.js +118 -0
  87. package/scripts/eval-external.js +226 -0
  88. package/scripts/eval-matrix.sh +172 -0
  89. package/scripts/eval-outcome.js +143 -0
  90. package/scripts/eval.sh +321 -0
  91. package/scripts/lint-parity.js +331 -0
  92. package/scripts/lint.sh +743 -0
  93. package/scripts/outcome-summary.js +126 -0
  94. package/scripts/release-check.sh +108 -0
  95. package/scripts/release-prepare.js +41 -0
  96. package/scripts/summarize-eval.js +91 -0
  97. package/scripts/summarize-matrix.js +101 -0
  98. package/scripts/version-sync.js +65 -0
  99. package/skills/godplans/SKILL.md +192 -0
  100. package/skills/godplans/references/agent-memory.md +168 -0
  101. package/skills/godplans/references/architecture.md +189 -0
  102. package/skills/godplans/references/build.md +130 -0
  103. package/skills/godplans/references/business.md +252 -0
  104. package/skills/godplans/references/code-quality.md +165 -0
  105. package/skills/godplans/references/compliance.md +59 -0
  106. package/skills/godplans/references/database.md +157 -0
  107. package/skills/godplans/references/deploy.md +146 -0
  108. package/skills/godplans/references/discovery.md +297 -0
  109. package/skills/godplans/references/doc-set.md +243 -0
  110. package/skills/godplans/references/exemplar.md +228 -0
  111. package/skills/godplans/references/launch.md +162 -0
  112. package/skills/godplans/references/llm.md +132 -0
  113. package/skills/godplans/references/observe.md +178 -0
  114. package/skills/godplans/references/plan-format.md +340 -0
  115. package/skills/godplans/references/product.md +130 -0
  116. package/skills/godplans/references/repo.md +184 -0
  117. package/skills/godplans/references/roadmap.md +158 -0
  118. package/skills/godplans/references/security.md +156 -0
  119. package/skills/godplans/references/seo.md +133 -0
  120. package/skills/godplans/references/stack.md +133 -0
  121. package/skills/godplans/references/style-genome.md +198 -0
  122. package/skills/godplans/references/ui.md +153 -0
  123. package/skills/godplans/references/ux.md +150 -0
  124. package/skills/godplans/schemas/PLAN.schema.json +275 -0
  125. package/skills/godplans/schemas/PLAN.v1.schema.json +258 -0
  126. package/skills/godplans/scripts/plan-halflife.sh +76 -0
  127. package/skills/godplans/scripts/style-stats.py +630 -0
  128. package/skills/godplans/scripts/validate-plan.sh +1709 -0
  129. package/skills/godplans/templates/PLAN.template.mdx +269 -0
  130. package/tests/agent-memory-guidance.sh +32 -0
  131. package/tests/build-catalog.sh +81 -0
  132. package/tests/codex-runner.sh +139 -0
  133. package/tests/eval-harness.sh +377 -0
  134. package/tests/evidence-harnesses.sh +243 -0
  135. package/tests/fixtures/plan-json-v1-1.13.0.json +472 -0
  136. package/tests/install-regression.sh +246 -0
  137. package/tests/lib/plan-schema-check.js +163 -0
  138. package/tests/lint-selftest.sh +582 -0
  139. package/tests/package-contents.sh +143 -0
  140. package/tests/portable-prompt.test.sh +261 -0
  141. package/tests/release-tooling.sh +204 -0
  142. package/tests/run.sh +14 -0
  143. package/tests/script-usage.sh +37 -0
  144. package/tests/style-stats.sh +170 -0
  145. package/tests/validate-plan.sh +1970 -0
  146. package/tests/vendor-runner.sh +291 -0
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+
7
+ function readRunnerUsage(file) {
8
+ if (!fs.existsSync(file)) {
9
+ return {
10
+ usage_source: 'unavailable',
11
+ input_tokens: null,
12
+ cached_input_tokens: null,
13
+ output_tokens: null,
14
+ total_tokens: null,
15
+ };
16
+ }
17
+ const metadata = {};
18
+ for (const line of fs.readFileSync(file, 'utf8').split('\n')) {
19
+ const separator = line.indexOf('=');
20
+ if (separator <= 0) continue;
21
+ metadata[line.slice(0, separator)] = line.slice(separator + 1);
22
+ }
23
+ const number = (key) => {
24
+ const value = Number(metadata[key]);
25
+ return Number.isFinite(value) ? value : null;
26
+ };
27
+ return {
28
+ usage_source: metadata.usage_source || 'unavailable',
29
+ input_tokens: number('input_tokens'),
30
+ cached_input_tokens: number('cached_input_tokens'),
31
+ output_tokens: number('output_tokens'),
32
+ total_tokens: number('total_tokens'),
33
+ };
34
+ }
35
+
36
+ function auditSummary(output, arm, verifyPassed) {
37
+ const audit = JSON.parse(fs.readFileSync(path.join(output, arm, 'audit', 'AUDIT.json'), 'utf8'));
38
+ const active = (audit.findings || []).filter((finding) => ['open', 'accepted-risk'].includes(finding.status));
39
+ const critical = active.filter((finding) => finding.severity === 'Critical').length;
40
+ const high = active.filter((finding) => finding.severity === 'High').length;
41
+ const planUsage = readRunnerUsage(path.join(output, arm, 'plan', 'RUNNER.txt'));
42
+ const buildUsage = readRunnerUsage(path.join(output, arm, 'build', 'RUNNER.txt'));
43
+ const totalTokens = planUsage.total_tokens !== null && buildUsage.total_tokens !== null
44
+ ? planUsage.total_tokens + buildUsage.total_tokens
45
+ : null;
46
+ return {
47
+ verify_passed: verifyPassed,
48
+ critical,
49
+ high,
50
+ critical_or_high: critical + high,
51
+ all_active_findings: active.length,
52
+ engine_version: audit.audit?.engine_version || null,
53
+ pack_version: audit.audit?.pack_version || null,
54
+ verdict: audit.computed?.overall?.verdict || audit.computed?.verdict || null,
55
+ usage: {
56
+ plan: planUsage,
57
+ build: buildUsage,
58
+ reported_total_tokens: totalTokens,
59
+ },
60
+ };
61
+ }
62
+
63
+ function formatNumber(value) {
64
+ return value === null ? 'unavailable' : value.toLocaleString('en-US');
65
+ }
66
+
67
+ function writeOutcomeSummary({ output, caseId, treatmentVerified, controlVerified }) {
68
+ const treatment = auditSummary(output, 'treatment', treatmentVerified);
69
+ const control = auditSummary(output, 'control', controlVerified);
70
+ if (treatment.engine_version !== control.engine_version || treatment.pack_version !== control.pack_version) {
71
+ throw new Error('audit engine or pack versions differ between arms');
72
+ }
73
+ const reportedTokenDelta = treatment.usage.reported_total_tokens !== null
74
+ && control.usage.reported_total_tokens !== null
75
+ ? treatment.usage.reported_total_tokens - control.usage.reported_total_tokens
76
+ : null;
77
+ const summary = {
78
+ format: 'godplans/build-outcome@1',
79
+ case: caseId,
80
+ treatment,
81
+ control,
82
+ critical_or_high_delta: treatment.critical_or_high - control.critical_or_high,
83
+ reported_total_token_delta: reportedTokenDelta,
84
+ treatment_better: treatment.verify_passed && treatment.critical_or_high < control.critical_or_high,
85
+ };
86
+ fs.writeFileSync(path.join(output, 'SUMMARY.json'), `${JSON.stringify(summary, null, 2)}\n`);
87
+ const markdown = [
88
+ `# Build-outcome evaluation: ${caseId}`,
89
+ '',
90
+ '| Arm | Verify | Critical | High | Critical plus High | All active findings |',
91
+ '|---|---|---:|---:|---:|---:|',
92
+ `| treatment | ${treatment.verify_passed ? 'pass' : 'fail'} | ${treatment.critical} | ${treatment.high} | ${treatment.critical_or_high} | ${treatment.all_active_findings} |`,
93
+ `| control | ${control.verify_passed ? 'pass' : 'fail'} | ${control.critical} | ${control.high} | ${control.critical_or_high} | ${control.all_active_findings} |`,
94
+ '',
95
+ `Critical plus High delta (treatment minus control): ${summary.critical_or_high_delta}.`,
96
+ '',
97
+ '| Arm | Plan tokens | Build tokens | Reported total tokens |',
98
+ '|---|---:|---:|---:|',
99
+ `| treatment | ${formatNumber(treatment.usage.plan.total_tokens)} | ${formatNumber(treatment.usage.build.total_tokens)} | ${formatNumber(treatment.usage.reported_total_tokens)} |`,
100
+ `| control | ${formatNumber(control.usage.plan.total_tokens)} | ${formatNumber(control.usage.build.total_tokens)} | ${formatNumber(control.usage.reported_total_tokens)} |`,
101
+ '',
102
+ 'Token totals are cumulative CLI-reported input plus output. Cached input is retained separately in SUMMARY.json.',
103
+ '',
104
+ ];
105
+ fs.writeFileSync(path.join(output, 'SUMMARY.md'), `${markdown.join('\n')}\n`);
106
+ return summary;
107
+ }
108
+
109
+ if (require.main === module) {
110
+ const args = process.argv.slice(2);
111
+ if (args.length !== 2 || args[0] !== '--output') {
112
+ process.stderr.write('Usage: node scripts/outcome-summary.js --output DIR\n');
113
+ process.exit(2);
114
+ }
115
+ const output = path.resolve(args[1]);
116
+ const prior = JSON.parse(fs.readFileSync(path.join(output, 'SUMMARY.json'), 'utf8'));
117
+ writeOutcomeSummary({
118
+ output,
119
+ caseId: prior.case,
120
+ treatmentVerified: prior.treatment.verify_passed,
121
+ controlVerified: prior.control.verify_passed,
122
+ });
123
+ process.stdout.write(`ok ${output}\n`);
124
+ }
125
+
126
+ module.exports = { writeOutcomeSummary };
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env bash
2
+ # Release-grade local evidence. Requires the pinned official validator and gh.
3
+
4
+ set -eu
5
+
6
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7
+ REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
8
+
9
+ die() {
10
+ printf '[fail] %s\n' "$*" >&2
11
+ exit 1
12
+ }
13
+
14
+ # Resolution order: an explicit SKILLS_REF_BIN, then the documented repository
15
+ # venv, then PATH. Whichever validator is found, the release gate fails when it
16
+ # cannot run; it never skips the official validation.
17
+ if [ -n "${SKILLS_REF_BIN:-}" ]; then
18
+ VALIDATOR=$SKILLS_REF_BIN
19
+ elif [ -x "$REPO_DIR/.venv-skills-ref/bin/skills-ref" ]; then
20
+ VALIDATOR="$REPO_DIR/.venv-skills-ref/bin/skills-ref"
21
+ elif command -v skills-ref >/dev/null 2>&1; then
22
+ VALIDATOR=$(command -v skills-ref)
23
+ else
24
+ printf '%s\n' "[fail] skills-ref is required for release validation." >&2
25
+ printf '%s\n' "Install the pinned validator in an isolated environment:" >&2
26
+ printf '%s\n' " python3 -m venv .venv-skills-ref" >&2
27
+ printf '%s\n' " .venv-skills-ref/bin/pip install -r requirements/skills-ref.txt" >&2
28
+ printf '%s\n' "Then set SKILLS_REF_BIN=.venv-skills-ref/bin/skills-ref and rerun." >&2
29
+ exit 1
30
+ fi
31
+
32
+ # A validator that cannot execute (a stale shim, a deleted interpreter) is a
33
+ # broken tool, not a verdict on the skill, so it gets its own message.
34
+ probe_status=0
35
+ "$VALIDATOR" --version >/dev/null || probe_status=$?
36
+ [ "$probe_status" -eq 0 ] ||
37
+ die "could not execute $VALIDATOR (exit $probe_status); reinstall it or set SKILLS_REF_BIN"
38
+ validate_status=0
39
+ "$VALIDATOR" validate "$REPO_DIR/skills/godplans" || validate_status=$?
40
+ case "$validate_status" in
41
+ 0) ;;
42
+ 126|127) die "could not execute $VALIDATOR (exit $validate_status)" ;;
43
+ *) die "official skills-ref validator rejected skills/godplans (exit $validate_status)" ;;
44
+ esac
45
+
46
+ # release:prepare stubs the new CHANGELOG section with a placeholder line, and
47
+ # the GitHub release notes are cut from that section verbatim. Match only that
48
+ # exact stub (scripts/release-prepare.js), so a real note that names the word
49
+ # TODO, such as one about R-REPO-6, still passes.
50
+ CHANGELOG_STUB='- TODO: describe this release.'
51
+ top_section=$(awk '/^## \[/ { if (seen) exit; seen = 1 } seen { print }' "$REPO_DIR/CHANGELOG.md")
52
+ [ -n "$top_section" ] || die "CHANGELOG.md has no version section"
53
+ if printf '%s\n' "$top_section" | grep -Fqx -- "$CHANGELOG_STUB"; then
54
+ die "the top CHANGELOG.md section still holds the release:prepare stub ($CHANGELOG_STUB); write the release notes first"
55
+ fi
56
+
57
+ if ! command -v gh >/dev/null 2>&1 || ! gh auth status >/dev/null 2>&1; then
58
+ printf '%s\n' "[fail] authenticated gh CLI is required for tag, release, and About parity." >&2
59
+ exit 1
60
+ fi
61
+
62
+ cd "$REPO_DIR"
63
+ # npm run check already runs scripts/eval.sh --check-cases (lint eval-cases and
64
+ # tests/eval-harness.sh), so the release gate does not repeat it.
65
+ SKILLS_REF_BIN="$VALIDATOR" npm run check
66
+ bash scripts/lint.sh tag-release-parity --verbose
67
+
68
+ # The GitHub About text says what package.json says (docs/RELEASING.md step
69
+ # 4): the repository description equals package.json description, and every
70
+ # keyword is a repository topic. A missing topics list reads as no topics.
71
+ # The About text is live repository state that no branch carries, so pull
72
+ # request CI only warns on drift: a release that changes description or
73
+ # keywords would otherwise fail every open pull request from the moment the
74
+ # About text is edited until it merges. A push to main and a local
75
+ # release:check still fail.
76
+ about=$(gh repo view hannsxpeter/godplans --json description,repositoryTopics) ||
77
+ die "gh could not read the repository description and topics"
78
+ about_drift=$(printf '%s\n' "$about" | node -e '
79
+ const fs = require("node:fs");
80
+ const pkg = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
81
+ const repo = JSON.parse(fs.readFileSync(0, "utf8"));
82
+ const topics = new Set((repo.repositoryTopics || []).map((topic) => topic.name));
83
+ const missing = (pkg.keywords || []).filter((keyword) => !topics.has(keyword));
84
+ const fix = [];
85
+ if (repo.description !== pkg.description) {
86
+ console.log("the repository description differs from package.json description");
87
+ fix.push(`--description ${JSON.stringify(pkg.description)}`);
88
+ }
89
+ if (missing.length) {
90
+ console.log(`the repository topics lack package.json keywords: ${missing.join(", ")}`);
91
+ fix.push(`--add-topic ${missing.join(",")}`);
92
+ }
93
+ if (fix.length) console.log(`fix: gh repo edit hannsxpeter/godplans ${fix.join(" ")}`);
94
+ ' "$REPO_DIR/package.json") || die "could not compare the GitHub About text with package.json"
95
+ if [ -n "$about_drift" ]; then
96
+ if [ "${GITHUB_EVENT_NAME:-}" = "pull_request" ]; then
97
+ printf '%s\n' "[warn] GitHub About drifted from package.json (enforced on main and in a local release:check):" \
98
+ "$about_drift" >&2
99
+ else
100
+ die "GitHub About drifted from package.json:
101
+ $about_drift"
102
+ fi
103
+ fi
104
+
105
+ # npm test accepts untracked, unignored files so work in progress can be
106
+ # tested; a release ships exactly what is committed.
107
+ bash tests/package-contents.sh --tracked-only
108
+ printf '%s\n' "ok [release-check]"
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // One command to start a release: bump the semver in package.json, sync every
5
+ // version surface from it, regenerate the prompt and context metrics, and stub
6
+ // a CHANGELOG entry whose TODO line release:check refuses to ship.
7
+ // Usage: npm run release:prepare -- <patch|minor|major|X.Y.Z>
8
+
9
+ const fs = require('node:fs');
10
+ const path = require('node:path');
11
+ const { execFileSync } = require('node:child_process');
12
+
13
+ const root = path.resolve(__dirname, '..');
14
+ const usage = 'Usage: npm run release:prepare -- <patch|minor|major|X.Y.Z>\n';
15
+ const bump = process.argv[2];
16
+ if (bump === '-h' || bump === '--help') {
17
+ process.stdout.write(usage);
18
+ process.exit(0);
19
+ }
20
+ // A leading dash would reach npm version as a flag, not a bump.
21
+ if (!bump || bump.startsWith('-') || process.argv.length > 3) {
22
+ process.stderr.write(usage);
23
+ process.exit(2);
24
+ }
25
+
26
+ execFileSync('npm', ['version', bump, '--no-git-tag-version', '--allow-same-version'], { cwd: root, stdio: 'inherit' });
27
+ const version = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).version;
28
+
29
+ execFileSync('node', ['scripts/version-sync.js'], { cwd: root, stdio: 'inherit' });
30
+
31
+ const changelogPath = path.join(root, 'CHANGELOG.md');
32
+ let changelog = fs.readFileSync(changelogPath, 'utf8');
33
+ if (!changelog.includes(`## [${version}]`)) {
34
+ const today = new Date().toISOString().slice(0, 10);
35
+ const stub = `## [${version}] - ${today}\n\n### Added\n\n- TODO: describe this release.\n\n`;
36
+ changelog = changelog.replace(/\n(## \[)/, `\n${stub}$1`);
37
+ fs.writeFileSync(changelogPath, changelog);
38
+ process.stdout.write(` stubbed CHANGELOG entry for ${version}\n`);
39
+ }
40
+
41
+ process.stdout.write(`\nPrepared ${version}. Next: write the CHANGELOG body, then commit, open a PR, and tag on merge.\n`);
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+
7
+ const usage = 'Usage: node scripts/summarize-eval.js [OUTPUT_DIR] (default evals/output)\n';
8
+ const arg = process.argv[2];
9
+ if (arg === '-h' || arg === '--help') {
10
+ process.stdout.write(usage);
11
+ process.exit(0);
12
+ }
13
+ if ((arg && arg.startsWith('-')) || process.argv.length > 3) {
14
+ process.stderr.write(usage);
15
+ process.exit(2);
16
+ }
17
+ const output = path.resolve(arg || 'evals/output');
18
+
19
+ function runnerMetadata(file) {
20
+ if (!fs.existsSync(file)) return {};
21
+ const entries = {};
22
+ for (const line of fs.readFileSync(file, 'utf8').split('\n')) {
23
+ const index = line.indexOf('=');
24
+ if (index < 1) continue;
25
+ entries[line.slice(0, index)] = line.slice(index + 1);
26
+ }
27
+ return entries;
28
+ }
29
+
30
+ function armSummary(records) {
31
+ const numeric = ['input_tokens', 'cached_input_tokens', 'output_tokens', 'total_tokens'];
32
+ const totals = Object.fromEntries(numeric.map((key) => [key, 0]));
33
+ let measuredRuns = 0;
34
+ for (const record of records) {
35
+ if (record.usage_source === 'unavailable' || record.total_tokens === undefined) continue;
36
+ measuredRuns++;
37
+ for (const key of numeric) totals[key] += Number(record[key] || 0);
38
+ }
39
+ return {
40
+ runs: records.length,
41
+ measured_runs: measuredRuns,
42
+ plan_runs: records.filter((record) => record.outcome === 'plan').length,
43
+ totals,
44
+ tokens_per_plan: records.filter((record) => record.outcome === 'plan' && record.total_tokens !== undefined).length
45
+ ? Math.round(records
46
+ .filter((record) => record.outcome === 'plan' && record.total_tokens !== undefined)
47
+ .reduce((sum, record) => sum + Number(record.total_tokens || 0), 0)
48
+ / records.filter((record) => record.outcome === 'plan' && record.total_tokens !== undefined).length)
49
+ : null,
50
+ };
51
+ }
52
+
53
+ const skill = [];
54
+ const control = [];
55
+ if (fs.existsSync(output)) {
56
+ for (const entry of fs.readdirSync(output, { withFileTypes: true })) {
57
+ if (!entry.isDirectory()) continue;
58
+ const caseDir = path.join(output, entry.name);
59
+ const outcome = fs.existsSync(path.join(caseDir, 'PLAN.mdx')) ? 'plan' : 'refusal';
60
+ skill.push({
61
+ case: entry.name,
62
+ outcome,
63
+ ...runnerMetadata(path.join(caseDir, 'RUNNER.txt')),
64
+ });
65
+ const baseline = path.join(caseDir, 'baseline');
66
+ if (fs.existsSync(baseline)) {
67
+ control.push({
68
+ case: entry.name,
69
+ outcome,
70
+ ...runnerMetadata(path.join(baseline, 'RUNNER.txt')),
71
+ });
72
+ }
73
+ }
74
+ }
75
+
76
+ const document = {
77
+ format: 'godplans/eval-metrics@1',
78
+ output,
79
+ arms: {
80
+ skill: armSummary(skill),
81
+ control: armSummary(control),
82
+ },
83
+ runs: {
84
+ skill,
85
+ control,
86
+ },
87
+ };
88
+
89
+ fs.mkdirSync(output, { recursive: true });
90
+ fs.writeFileSync(path.join(output, 'METRICS.json'), `${JSON.stringify(document, null, 2)}\n`);
91
+ process.stdout.write(`METRICS\t${path.join(output, 'METRICS.json')}\n`);
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+
7
+ const root = path.resolve(__dirname, '..');
8
+ const usage = 'Usage: node scripts/summarize-matrix.js OUTPUT_DIR PROFILE...\n';
9
+ if (process.argv[2] === '-h' || process.argv[2] === '--help') {
10
+ process.stdout.write(usage);
11
+ process.exit(0);
12
+ }
13
+ if (!process.argv[2] || process.argv[2].startsWith('-')) {
14
+ process.stderr.write(usage);
15
+ process.exit(2);
16
+ }
17
+ const output = path.resolve(process.argv[2]);
18
+ const profiles = process.argv.slice(3);
19
+ // The committed roster, not the directory listing, defines the expected cases,
20
+ // so a case missing from disk fails here rather than shrinking case_count.
21
+ // eval-matrix.sh has already checked that the two agree.
22
+ const expectedCases = [...new Set(fs.readFileSync(path.join(root, 'evals', 'cases-roster.txt'), 'utf8')
23
+ .split('\n')
24
+ .map((line) => line.replace(/#.*/, '').trim())
25
+ .filter(Boolean))]
26
+ .sort();
27
+
28
+ // Only a score counts as an arm. eval.sh also writes marker rows such as
29
+ // `FAIL\trunner`, `FAIL\tartifacts`, and `BASE\trunner-error` for a run that
30
+ // produced nothing to score, and those must read as a missing arm.
31
+ const SCORE = /^[0-9]+\/[0-9]+$/;
32
+
33
+ function parseEval(file) {
34
+ const cases = {};
35
+ let aggregate = null;
36
+ for (const line of fs.readFileSync(file, 'utf8').split('\n')) {
37
+ const fields = line.split('\t');
38
+ if (fields[0] === 'AGGREGATE') {
39
+ aggregate = fields.slice(1);
40
+ continue;
41
+ }
42
+ if (!expectedCases.includes(fields[0])) continue;
43
+ cases[fields[0]] ||= {};
44
+ if (!SCORE.test(fields[2] || '')) continue;
45
+ if (fields[1] === 'PASS' || fields[1] === 'FAIL') {
46
+ cases[fields[0]].skill = fields[2];
47
+ cases[fields[0]].status = fields[1];
48
+ } else if (fields[1] === 'BASE') {
49
+ cases[fields[0]].control = fields[2];
50
+ cases[fields[0]].delta = fields[3];
51
+ }
52
+ }
53
+ return { cases, aggregate };
54
+ }
55
+
56
+ function die(message) {
57
+ process.stderr.write(`summarize-matrix: ${message}\n`);
58
+ process.exit(1);
59
+ }
60
+
61
+ const results = {};
62
+ for (const profile of profiles) {
63
+ const directory = path.join(output, profile);
64
+ const evalFile = path.join(directory, 'EVAL.tsv');
65
+ const metricsFile = path.join(directory, 'METRICS.json');
66
+ if (!fs.existsSync(evalFile) || !fs.existsSync(metricsFile)) {
67
+ die(`profile ${profile} is missing EVAL.tsv or METRICS.json`);
68
+ }
69
+ const parsed = parseEval(evalFile);
70
+ for (const caseName of expectedCases) {
71
+ const missing = ['skill', 'control'].filter((arm) => !parsed.cases[caseName]?.[arm]);
72
+ if (missing.length) die(`profile ${profile} has no scored ${missing.join(' or ')} arm for ${caseName}`);
73
+ }
74
+ results[profile] = {
75
+ ...parsed,
76
+ metrics: JSON.parse(fs.readFileSync(metricsFile, 'utf8')),
77
+ };
78
+ }
79
+
80
+ const document = {
81
+ format: 'godplans/model-family-matrix@1',
82
+ case_count: expectedCases.length,
83
+ profiles,
84
+ results,
85
+ };
86
+ fs.writeFileSync(path.join(output, 'MATRIX.json'), `${JSON.stringify(document, null, 2)}\n`);
87
+
88
+ const lines = [
89
+ '# Full model-family evaluation matrix',
90
+ '',
91
+ `Cases per family: ${expectedCases.length}. Every family includes a godplans arm and a neutral no-skill control arm.`,
92
+ '',
93
+ '| Family | Aggregate | Skill tokens per plan | Control tokens per plan |',
94
+ '|---|---:|---:|---:|',
95
+ ];
96
+ for (const profile of profiles) {
97
+ const result = results[profile];
98
+ lines.push(`| ${profile} | ${result.aggregate?.join('; ') || 'not reported'} | ${result.metrics.arms.skill.tokens_per_plan ?? 'unavailable'} | ${result.metrics.arms.control.tokens_per_plan ?? 'unavailable'} |`);
99
+ }
100
+ lines.push('', 'Raw PLAN.mdx, PLAN.json, validator, control plan, runner metadata, CLI event logs, and per-family score rows are retained below this directory.', '');
101
+ fs.writeFileSync(path.join(output, 'MATRIX.md'), `${lines.join('\n')}\n`);
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Single source of version truth: package.json. Writes that version into every
5
+ // surface listed below, then regenerates the prompt and the context metrics
6
+ // that hash it, so a release never hand-edits version strings in lockstep. The
7
+ // CHANGELOG.md heading is not a surface here: release-prepare.js stubs it.
8
+ // --check only compares and writes nothing. Run: npm run version:sync (or
9
+ // version:check).
10
+
11
+ const fs = require('node:fs');
12
+ const path = require('node:path');
13
+ const { execFileSync } = require('node:child_process');
14
+
15
+ const root = path.resolve(__dirname, '..');
16
+ const usage = 'Usage: node scripts/version-sync.js [--check]\n';
17
+ const args = process.argv.slice(2);
18
+ if (args.includes('-h') || args.includes('--help')) {
19
+ process.stdout.write(usage);
20
+ process.exit(0);
21
+ }
22
+ const unknown = args.find((arg) => arg !== '--check');
23
+ if (unknown !== undefined) {
24
+ process.stderr.write(`Unknown argument: ${unknown}\n${usage}`);
25
+ process.exit(2);
26
+ }
27
+ const check = args.includes('--check');
28
+ const version = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).version;
29
+
30
+ const surfaces = [
31
+ ['skills/godplans/SKILL.md', /^(\s+version:\s*")([0-9]+\.[0-9]+\.[0-9]+)(")/m, () => `${version}`, 1, 3],
32
+ ['skills/godplans/SKILL.md', /^(## Skill version:\s*)([0-9]+\.[0-9]+\.[0-9]+)/m, () => `${version}`, 1, null],
33
+ ['plugins/godplans/.claude-plugin/plugin.json', /^(\s+"version":\s*")([0-9]+\.[0-9]+\.[0-9]+)(")/m, () => `${version}`, 1, 3],
34
+ ['.claude-plugin/marketplace.json', /^(\s+"version":\s*")([0-9]+\.[0-9]+\.[0-9]+)(")/m, () => `${version}`, 1, 3],
35
+ ['README.md', /(version-)([0-9]+\.[0-9]+\.[0-9]+)(-blue)/, () => `${version}`, 1, 3],
36
+ ['skills/godplans/templates/PLAN.template.mdx', /(godplans v)([0-9]+\.[0-9]+\.[0-9]+)/, () => `${version}`, 1, null],
37
+ ];
38
+
39
+ const mismatches = [];
40
+ for (const [rel, regex, target, pre, post] of surfaces) {
41
+ const file = path.join(root, rel);
42
+ const text = fs.readFileSync(file, 'utf8');
43
+ const match = text.match(regex);
44
+ if (!match) { mismatches.push(`${rel}: no version surface matched ${regex}`); continue; }
45
+ const corrected = `${match[pre]}${target()}${post ? match[post] : ''}`;
46
+ if (match[0] === corrected) continue;
47
+ if (check) mismatches.push(`${rel}: "${match[0]}" should be "${corrected}"`);
48
+ else { fs.writeFileSync(file, text.replace(regex, corrected)); process.stdout.write(` synced ${rel}: "${match[0]}" -> "${corrected}"\n`); }
49
+ }
50
+
51
+ if (check) {
52
+ if (mismatches.length) {
53
+ process.stderr.write(`Version surfaces are stale:\n ${mismatches.join('\n ')}\nTo fix: run \`npm run version:sync\`.\n`);
54
+ process.exitCode = 1;
55
+ } else process.stdout.write(`All version surfaces are ${version}.\n`);
56
+ } else if (mismatches.length) {
57
+ process.stderr.write(`Could not sync:\n ${mismatches.join('\n ')}\n`);
58
+ process.exitCode = 1;
59
+ } else {
60
+ // The metrics hash PROMPT.md and SKILL.md, so they go stale on every bump and
61
+ // must be rebuilt after the prompt, never before it.
62
+ execFileSync('bash', ['scripts/build-prompt.sh'], { cwd: root, stdio: 'inherit' });
63
+ execFileSync('node', ['scripts/context-metrics.js'], { cwd: root, stdio: 'inherit' });
64
+ process.stdout.write(`Version surfaces synced to ${version}; prompt and context metrics regenerated.\n`);
65
+ }