@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
package/package.json CHANGED
@@ -1,6 +1,93 @@
1
1
  {
2
2
  "name": "@hxp-tools/godplans",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.1",
4
+ "description": "Plan everything before anything. Ask, decide, grade, clear the gate. A planning skill for AI coding tools.",
5
+ "keywords": [
6
+ "agent-skills",
7
+ "ai-agents",
8
+ "claude-code",
9
+ "codex",
10
+ "cursor",
11
+ "gemini-cli",
12
+ "opencode",
13
+ "windsurf",
14
+ "planning",
15
+ "project-planning",
16
+ "master-plan",
17
+ "plan-first",
18
+ "spec-driven-development",
19
+ "prd",
20
+ "product-management",
21
+ "architecture",
22
+ "roadmap",
23
+ "audit-aware",
24
+ "security-by-design",
25
+ "developer-tools"
26
+ ],
27
+ "homepage": "https://github.com/hannsxpeter/godplans#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/hannsxpeter/godplans/issues"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/hannsxpeter/godplans.git"
34
+ },
35
+ "license": "MIT",
36
+ "author": "hannsxpeter",
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "bin": {
41
+ "godplans": "bin/godplans.js"
42
+ },
43
+ "files": [
44
+ "bin",
45
+ "skills",
46
+ "install.sh",
47
+ "scripts",
48
+ "requirements",
49
+ "evals/cases",
50
+ "evals/cases-roster.txt",
51
+ "evals/external/GRADE.schema.json",
52
+ "evals/external/README.md",
53
+ "evals/external/RUBRIC.md",
54
+ "evals/metrics",
55
+ "evals/outcomes/README.md",
56
+ "evals/outcomes/cases",
57
+ "evals/outcomes/results/2026-07-23-tenant-notes-api-codex/treatment/plan/PLAN.json",
58
+ "evals/runners",
59
+ "evals/README.md",
60
+ "tests",
61
+ "docs",
62
+ "PROMPT.md",
63
+ "README.md",
64
+ "LICENSE",
65
+ "CHANGELOG.md",
66
+ "!**/__pycache__",
67
+ "!**/*.pyc"
68
+ ],
69
+ "scripts": {
70
+ "test": "bash tests/run.sh",
71
+ "catalog": "node scripts/build-catalog.js",
72
+ "catalog:check": "node scripts/build-catalog.js --check",
73
+ "generate": "npm run catalog && npm run build:prompt && npm run metrics:context",
74
+ "version:sync": "node scripts/version-sync.js",
75
+ "version:check": "node scripts/version-sync.js --check",
76
+ "release:prepare": "node scripts/release-prepare.js",
77
+ "lint": "bash scripts/lint.sh --all --verbose",
78
+ "check": "npm run version:check && npm run catalog:check && npm run metrics:check && npm run lint && npm test",
79
+ "eval": "bash scripts/eval.sh",
80
+ "eval:check": "bash scripts/eval.sh --check-cases",
81
+ "eval:matrix": "bash scripts/eval-matrix.sh",
82
+ "eval:external": "node scripts/eval-external.js",
83
+ "eval:outcome": "node scripts/eval-outcome.js",
84
+ "metrics:context": "node scripts/context-metrics.js",
85
+ "metrics:check": "node scripts/context-metrics.js --check",
86
+ "build:prompt": "bash scripts/build-prompt.sh",
87
+ "release:check": "bash scripts/release-check.sh",
88
+ "prepack": "npm run check"
89
+ },
90
+ "engines": {
91
+ "node": ">=18.0.0"
92
+ }
93
+ }
@@ -0,0 +1,2 @@
1
+ # Official Agent Skills reference validator pinned to the reviewed upstream commit.
2
+ git+https://github.com/agentskills/agentskills.git@38a2ff82958afee88dadf4831509e6f7e9d8ef4e#subdirectory=skills-ref
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // The validator embeds `my %catalog_max = (...)` and `my %doc_catalog = (...)`
5
+ // so it stays a single portable file. Both blocks are DERIVED from the
6
+ // reference modules (the second from doc-set.md), not hand-maintained: this
7
+ // regenerates them (or verifies them with --check) using the same extraction
8
+ // the regression suite uses. Adding a requirement or a catalog row never
9
+ // desyncs the validator.
10
+ // Maintainer tooling: it lives outside the shipped skill, which never runs it.
11
+ // Run: node scripts/build-catalog.js [--check] (npm run catalog, catalog:check)
12
+
13
+ const fs = require('node:fs');
14
+ const path = require('node:path');
15
+
16
+ const skillRoot = path.resolve(__dirname, '..', 'skills', 'godplans');
17
+ const referencesDir = path.join(skillRoot, 'references');
18
+ const validatorPath = path.join(skillRoot, 'scripts/validate-plan.sh');
19
+ const usage = 'Usage: node scripts/build-catalog.js [--check]\n';
20
+ const args = process.argv.slice(2);
21
+ if (args.includes('-h') || args.includes('--help')) {
22
+ process.stdout.write(usage);
23
+ process.exit(0);
24
+ }
25
+ const unknown = args.find((arg) => arg !== '--check');
26
+ if (unknown !== undefined) {
27
+ process.stderr.write(`Unknown argument: ${unknown}\n${usage}`);
28
+ process.exit(2);
29
+ }
30
+ const check = args.includes('--check');
31
+
32
+ // Extraction mirrors tests/validate-plan.sh and the definedPrefixes scan in
33
+ // scripts/lint-parity.js: within a `## Plan requirements` section, collect each
34
+ // R-<PREFIX>-<N> that starts a line (after an optional list marker and an
35
+ // optional **). Ids cited mid-sentence are cross-references to other modules
36
+ // and define nothing. Every prefix must be contiguous 1..max.
37
+ const seen = {};
38
+ for (const file of fs.readdirSync(referencesDir).filter((name) => name.endsWith('.md'))) {
39
+ const lines = fs.readFileSync(path.join(referencesDir, file), 'utf8').split(/\r?\n/);
40
+ let inside = false;
41
+ for (const line of lines) {
42
+ if (/^## Plan requirements\s*$/.test(line)) { inside = true; continue; }
43
+ if (inside && /^## /.test(line)) { inside = false; }
44
+ if (!inside) continue;
45
+ const m = line.match(/^\s*(?:(?:[0-9]+\.|[-*])\s+)?(?:\*\*)?R-([A-Z][A-Z0-9-]*)-([0-9]+)/);
46
+ if (m) (seen[m[1]] ||= new Set()).add(Number(m[2]));
47
+ }
48
+ }
49
+
50
+ const errors = [];
51
+ const maxima = {};
52
+ for (const prefix of Object.keys(seen)) {
53
+ const numbers = [...seen[prefix]].sort((a, b) => a - b);
54
+ const max = numbers[numbers.length - 1];
55
+ if (numbers.length !== max) errors.push(`${prefix}: gap in requirement ids (have ${numbers.length}, max ${max})`);
56
+ maxima[prefix] = max;
57
+ }
58
+ if (errors.length) {
59
+ process.stderr.write(`Requirement id gaps:\n ${errors.join('\n ')}\n`);
60
+ process.exit(1);
61
+ }
62
+
63
+ // The documentation catalog is the same problem in a second table: the
64
+ // validator has to know every catalog id and its owning module, and a
65
+ // hand-maintained copy desyncs the first time doc-set.md gains a row.
66
+ const docSetPath = path.join(referencesDir, 'doc-set.md');
67
+ const documents = {};
68
+ const docErrors = [];
69
+ for (const line of fs.readFileSync(docSetPath, 'utf8').split(/\r?\n/)) {
70
+ const row = line.match(/^\|\s*`([a-z]+\.[a-z0-9-]+)`\s*\|\s*(durable|evidence|transient)\s*\|\s*([a-z-]+)\s*\|/);
71
+ if (!row) continue;
72
+ const [, id, durability, owner] = row;
73
+ if (documents[id]) docErrors.push(`${id}: duplicate catalog row`);
74
+ documents[id] = `${owner}|${durability}`;
75
+ }
76
+ if (!Object.keys(documents).length) docErrors.push('doc-set.md: no catalog rows matched');
77
+ // The row regex already guarantees a stage and an owner. What it cannot know is
78
+ // whether the owner is a domain the validator plans, so read that list from the
79
+ // validator itself instead of keeping a second copy here.
80
+ const validator = fs.readFileSync(validatorPath, 'utf8');
81
+ const domainTable = validator.match(/^my %known_domain\s*=\s*map\s*\{\s*\$_\s*=>\s*1\s*\}\s*qw\(([^)]*)\)\s*;/m);
82
+ if (!domainTable) {
83
+ docErrors.push('validate-plan.sh: could not read the %known_domain table');
84
+ } else {
85
+ const knownDomains = new Set(domainTable[1].split(/\s+/).filter(Boolean));
86
+ for (const [id, value] of Object.entries(documents)) {
87
+ const owner = value.split('|')[0];
88
+ if (!knownDomains.has(owner)) docErrors.push(`${id}: owner '${owner}' is not a validator domain`);
89
+ }
90
+ }
91
+ if (docErrors.length) {
92
+ process.stderr.write(`Document catalog problems:\n ${docErrors.join('\n ')}\n`);
93
+ process.exit(1);
94
+ }
95
+
96
+ const block = `my %catalog_max = (\n${Object.keys(maxima).sort().map((p) => ` ${p} => ${maxima[p]},`).join('\n')}\n);`;
97
+ const docBlock = `my %doc_catalog = (\n${Object.keys(documents).sort().map((id) => ` '${id}' => '${documents[id]}',`).join('\n')}\n);`;
98
+ const rebuilt = validator
99
+ .replace(/my %catalog_max = \([^)]*\);/, block)
100
+ .replace(/my %doc_catalog = \([^)]*\);/, docBlock);
101
+
102
+ if (check) {
103
+ if (validator === rebuilt) {
104
+ process.stdout.write('Validator catalog is fresh.\n');
105
+ } else {
106
+ process.stderr.write('Validator catalog is stale. To fix: run `npm run catalog`.\n');
107
+ process.exitCode = 1;
108
+ }
109
+ } else if (validator === rebuilt) {
110
+ process.stdout.write('Validator catalog already fresh.\n');
111
+ } else {
112
+ fs.writeFileSync(validatorPath, rebuilt);
113
+ process.stdout.write(`Rewrote %catalog_max (${Object.keys(maxima).length} prefixes) and %doc_catalog (${Object.keys(documents).length} documents) in validate-plan.sh.\n`);
114
+ }
@@ -0,0 +1,257 @@
1
+ #!/usr/bin/env bash
2
+ # Generate the slim portable prompt for tools with no Agent Skills support.
3
+ # The default core carries compliance, discovery, five load-bearing modules,
4
+ # the quality exemplar, plan format, the template, and portable scripts. The
5
+ # remaining domain modules and the doc-set contract stay as individually
6
+ # attachable files under skills/godplans/references/.
7
+ #
8
+ # Pass --full to generate the historical all-in-one prompt for a one-off use.
9
+ # The repository publishes the core because inlining every module charges the
10
+ # full context cost before applicability is known.
11
+
12
+ set -euo pipefail
13
+
14
+ REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
15
+ SKILL="$REPO_DIR/skills/godplans/SKILL.md"
16
+ REFS="$REPO_DIR/skills/godplans/references"
17
+ # --output, then GODPLANS_PROMPT_OUT, then the mode's default, resolved after
18
+ # parsing so the flags work in any order.
19
+ OUT="${GODPLANS_PROMPT_OUT:-}"
20
+ MODE=core
21
+
22
+ while [ "$#" -gt 0 ]; do
23
+ case "$1" in
24
+ --core)
25
+ MODE=core
26
+ ;;
27
+ --full)
28
+ MODE=full
29
+ ;;
30
+ --output)
31
+ shift
32
+ [ "$#" -gt 0 ] || {
33
+ echo "--output needs a path" >&2
34
+ exit 2
35
+ }
36
+ OUT=$1
37
+ ;;
38
+ -h|--help)
39
+ echo "Usage: bash scripts/build-prompt.sh [--core|--full] [--output PATH]"
40
+ exit 0
41
+ ;;
42
+ *)
43
+ echo "Unknown option: $1" >&2
44
+ exit 2
45
+ ;;
46
+ esac
47
+ shift
48
+ done
49
+ if [ -z "$OUT" ]; then
50
+ if [ "$MODE" = "full" ]; then
51
+ OUT="$REPO_DIR/PROMPT.full.md"
52
+ else
53
+ OUT="$REPO_DIR/PROMPT.md"
54
+ fi
55
+ fi
56
+
57
+ strip_frontmatter() {
58
+ awk 'BEGIN{fm=0} /^---$/{fm++; next} fm!=1{print}' "$1"
59
+ }
60
+
61
+ # The file map points at references/*.md, unreachable from a chat surface;
62
+ # drop that section (from its heading to the next H2).
63
+ strip_file_map() {
64
+ awk 'BEGIN{skip=0} /^## File map/{skip=1; next} skip && /^## /{skip=0} !skip{print}'
65
+ }
66
+
67
+ # Council mode (Phase 6d) needs delegation to three model providers, which a
68
+ # pasted prompt cannot do, and it would spend portable-core budget on an
69
+ # unreachable path. Replace the block, from its `**6d. Council (opt-in).**`
70
+ # heading line up to, but not including, the following "Print the scorecard"
71
+ # paragraph, with one note, as strip_file_map does for the File map. Both
72
+ # boundaries must match exactly once; otherwise the build fails, because a
73
+ # missed opening leaves the council block in the prompt and a missed closing
74
+ # would drop every later section.
75
+ strip_council() {
76
+ awk '
77
+ /^\*\*6d\. Council \(opt-in\)\.\*\*/ {
78
+ opens++
79
+ skip = 1
80
+ print "**6d. Council (opt-in)** is available in the installed skill only; with this prompt, Phase 6 runs with one critic."
81
+ print ""
82
+ next
83
+ }
84
+ skip && /^Print the scorecard/ { closes++; skip = 0 }
85
+ !skip { print }
86
+ END {
87
+ if (opens != 1 || closes != 1 || skip) {
88
+ printf "build-prompt: strip_council boundaries not found exactly once (6d heading: %d, scorecard paragraph: %d%s)\n", opens, closes, skip ? ", unterminated" : "" > "/dev/stderr"
89
+ exit 1
90
+ }
91
+ }'
92
+ }
93
+
94
+ # Neither prompt inlines style-stats.py: it is larger than the core's budget
95
+ # headroom, and the full prompt gives the same instruction as the core. So the
96
+ # SKILL.md and discovery.md sentences that run or copy it get one expression
97
+ # per phrase, shared by both modes: the measured baseline is recorded as not
98
+ # run, and the Phase 7 copy is made only when a native install is reachable.
99
+ # tests/portable-prompt.test.sh fails on any phrasing left unrewritten.
100
+ STYLE_STATS_REWRITES=(
101
+ -e 's|run `[^`]*scripts/style-stats\.py[^`]*`[^,;]* for the measured style baseline|record the measured style baseline as not run (only a native install has the style-stats script)|g'
102
+ -e 's|measured [^`;]*`[^`]*scripts/style-stats\.py[^`]*`[^,;]* and then close-read|with its measured baseline recorded as not run (only a native install has the style-stats script) and then close-read|g'
103
+ -e 's|copy `[^`]*scripts/style-stats\.py`[^,.]*|copy the style-stats script there if a native install is reachable, else record it as not copied|g'
104
+ )
105
+
106
+ # Portable surfaces cannot resolve repository-relative paths. Rewrite only
107
+ # the paths that point at content inlined below; project paths such as
108
+ # .godplans/PLAN.mdx remain literal because the planning agent can access them.
109
+ # A command span that runs the half-life script points at the copy the header
110
+ # tells the reader to save beside the validator companion, because a portable
111
+ # reader can only run a script it wrote to disk.
112
+ portable_text_full() {
113
+ sed \
114
+ -e 's|Each domain has a reference module under `references/`\.|Each domain has an inlined reference module below.|g' \
115
+ -e 's|`references/\([a-z-]*\)\.md`|the inlined \1 reference|g' \
116
+ -e 's|references/\([a-z-]*\)\.md|the inlined \1 reference|g' \
117
+ -e 's|`templates/PLAN\.template\.mdx`|the inlined PLAN template|g' \
118
+ -e 's|templates/PLAN\.template\.mdx|the inlined PLAN template|g' \
119
+ -e 's|`scripts/validate-plan\.sh`|the inlined validator|g' \
120
+ -e 's|scripts/validate-plan\.sh|the inlined validator|g' \
121
+ "${STYLE_STATS_REWRITES[@]}" \
122
+ -e 's|`scripts/plan-halflife\.sh`|the inlined plan half-life script|g' \
123
+ -e 's|`scripts/plan-halflife\.sh |`bash .godplans/plan-halflife.sh |g' \
124
+ -e 's|scripts/plan-halflife\.sh|the inlined plan half-life script|g' \
125
+ -e 's|`plan-format\.md`|the inlined plan-format reference|g' \
126
+ -e 's|plan-format\.md|the inlined plan-format reference|g'
127
+ }
128
+
129
+ # The core rewrites each inlined path in its backticked form, then its bare
130
+ # form, one module per expression because BSD sed BRE has no alternation.
131
+ portable_text_core() {
132
+ sed \
133
+ -e 's|`references/compliance\.md`|the inlined compliance reference|g' \
134
+ -e 's|`references/discovery\.md`|the inlined discovery reference|g' \
135
+ -e 's|`references/product\.md`|the inlined product reference|g' \
136
+ -e 's|`references/architecture\.md`|the inlined architecture reference|g' \
137
+ -e 's|`references/stack\.md`|the inlined stack reference|g' \
138
+ -e 's|`references/database\.md`|the inlined database reference|g' \
139
+ -e 's|`references/security\.md`|the inlined security reference|g' \
140
+ -e 's|`references/exemplar\.md`|the inlined exemplar reference|g' \
141
+ -e 's|`references/plan-format\.md`|the inlined plan-format reference|g' \
142
+ -e 's|`templates/PLAN\.template\.mdx`|the inlined PLAN template|g' \
143
+ -e 's|`scripts/validate-plan\.sh`|the inlined validator|g' \
144
+ -e 's|references/compliance\.md|the inlined compliance reference|g' \
145
+ -e 's|references/discovery\.md|the inlined discovery reference|g' \
146
+ -e 's|references/product\.md|the inlined product reference|g' \
147
+ -e 's|references/architecture\.md|the inlined architecture reference|g' \
148
+ -e 's|references/stack\.md|the inlined stack reference|g' \
149
+ -e 's|references/database\.md|the inlined database reference|g' \
150
+ -e 's|references/security\.md|the inlined security reference|g' \
151
+ -e 's|references/exemplar\.md|the inlined exemplar reference|g' \
152
+ -e 's|templates/PLAN\.template\.mdx|the inlined PLAN template|g' \
153
+ -e 's|scripts/validate-plan\.sh|the inlined validator|g' \
154
+ "${STYLE_STATS_REWRITES[@]}" \
155
+ -e 's|`scripts/plan-halflife\.sh`|the inlined plan half-life script|g' \
156
+ -e 's|`scripts/plan-halflife\.sh |`bash .godplans/plan-halflife.sh |g' \
157
+ -e 's|scripts/plan-halflife\.sh|the inlined plan half-life script|g' \
158
+ -e 's|`plan-format\.md`|the inlined plan-format reference|g' \
159
+ -e 's|plan-format\.md|the inlined plan-format reference|g'
160
+ }
161
+
162
+ portable_text() {
163
+ if [ "$MODE" = "full" ]; then
164
+ portable_text_full
165
+ else
166
+ portable_text_core
167
+ fi
168
+ }
169
+
170
+ if [ "$MODE" = "full" ]; then
171
+ REFERENCE_ORDER="
172
+ compliance discovery
173
+ product business architecture stack database security llm ux ui seo code-quality
174
+ style-genome agent-memory repo build roadmap deploy observe launch
175
+ doc-set exemplar plan-format
176
+ "
177
+ else
178
+ REFERENCE_ORDER="
179
+ compliance discovery
180
+ product architecture stack database security
181
+ exemplar plan-format
182
+ "
183
+ fi
184
+
185
+ {
186
+ if [ "$MODE" = "full" ]; then
187
+ cat <<'EOF'
188
+ # godplans (portable prompt)
189
+
190
+ You are operating under the godplans skill: a planning superskill that
191
+ produces a comprehensive, audit-aware master plan (PLAN.mdx) for a software
192
+ project before any code is written. This file is the flattened, single-file
193
+ form of the skill for surfaces without Agent Skills support. It includes the
194
+ orchestrator, compliance and discovery guidance, all 19 domain modules, the
195
+ quality exemplar, the documentation-set and plan-format contracts, the PLAN
196
+ template, the self-contained validator, and the plan half-life script in
197
+ workflow order. No repository-local skill files are required. When filesystem
198
+ tools are available, write the inlined validator byte-for-byte to
199
+ `.godplans/validate-plan.sh` before validation. Before a replan, save the
200
+ inlined plan half-life script as `.godplans/plan-halflife.sh`, beside the
201
+ validator companion it runs. The canonical source lives at
202
+ https://github.com/hannsxpeter/godplans.
203
+
204
+ Generated by scripts/build-prompt.sh. Do not edit by hand.
205
+
206
+ ---
207
+ EOF
208
+ else
209
+ cat <<'EOF'
210
+ # godplans (portable core)
211
+
212
+ You are operating under the godplans skill. This slim core includes compliance,
213
+ discovery, the plan contract, the five load-bearing modules (product,
214
+ architecture, stack, database, and security), the quality exemplar, the PLAN
215
+ template, and the portable scripts. It does not preload reversible or
216
+ specialized domains. When filesystem tools are available, write the inlined
217
+ validator byte-for-byte to `.godplans/validate-plan.sh` before validation; with
218
+ no installed skill, that inlined copy is the resolved source the `cmp -s` checks
219
+ name. Before a replan, save the inlined plan half-life script as
220
+ `.godplans/plan-halflife.sh`, beside the validator companion it runs.
221
+
222
+ Before each non-core domain pass, load that module from
223
+ `skills/godplans/references/` only when the applicability matrix marks it
224
+ applicable. The lazy modules are business, llm, ux, ui, seo, code-quality,
225
+ style-genome, agent-memory, repo, build, roadmap, deploy, observe, and launch.
226
+ Do not author a domain from memory and do not claim a complete plan if an
227
+ applicable module was not loaded.
228
+
229
+ `references/doc-set.md` is a contract rather than a domain, and the repo pass
230
+ needs it: it carries the document catalog, the lifecycle stages, and the
231
+ selection and exclusion rules behind `## Documentation set`. Load it with the
232
+ repo module. Without it, do not guess catalog ids.
233
+
234
+ Generated by scripts/build-prompt.sh. Do not edit by hand.
235
+
236
+ ---
237
+ EOF
238
+ fi
239
+ strip_frontmatter "$SKILL" | strip_file_map | strip_council | portable_text
240
+ for ref in $REFERENCE_ORDER
241
+ do
242
+ printf '\n\n---\n\n# INLINED REFERENCE: references/%s.md\n\n' "$ref"
243
+ portable_text < "$REFS/$ref.md"
244
+ done
245
+ printf '\n\n---\n\n# INLINED TEMPLATE: templates/PLAN.template.mdx\n\n'
246
+ portable_text < "$REPO_DIR/skills/godplans/templates/PLAN.template.mdx"
247
+ printf '\n\n---\n\n# INLINED VALIDATOR: scripts/validate-plan.sh\n\n```bash\n'
248
+ cat "$REPO_DIR/skills/godplans/scripts/validate-plan.sh"
249
+ printf '\n```\n'
250
+ printf '\n\n---\n\n# INLINED SCRIPT: scripts/plan-halflife.sh\n\n```bash\n'
251
+ cat "$REPO_DIR/skills/godplans/scripts/plan-halflife.sh"
252
+ printf '\n```\n'
253
+ } > "$OUT"
254
+
255
+ lines=$(wc -l < "$OUT" | tr -d ' ')
256
+ bytes=$(wc -c < "$OUT" | tr -d ' ')
257
+ echo "Wrote $OUT ($MODE, $lines lines, $bytes bytes)"
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const crypto = require('node:crypto');
5
+ const fs = require('node:fs');
6
+ const os = require('node:os');
7
+ const path = require('node:path');
8
+ const { execFileSync } = require('node:child_process');
9
+
10
+ const root = path.resolve(__dirname, '..');
11
+ const output = path.join(root, 'evals', 'metrics', 'context-cost.json');
12
+ const usage = 'Usage: node scripts/context-metrics.js [--check]\n';
13
+ const args = process.argv.slice(2);
14
+ if (args.includes('-h') || args.includes('--help')) {
15
+ process.stdout.write(usage);
16
+ process.exit(0);
17
+ }
18
+ const unknown = args.find((arg) => arg !== '--check');
19
+ if (unknown !== undefined) {
20
+ process.stderr.write(`Unknown argument: ${unknown}\n${usage}`);
21
+ process.exit(2);
22
+ }
23
+ const check = args.includes('--check');
24
+ const references = path.join(root, 'skills', 'godplans', 'references');
25
+
26
+ const coreModules = [
27
+ 'compliance',
28
+ 'discovery',
29
+ 'product',
30
+ 'architecture',
31
+ 'stack',
32
+ 'database',
33
+ 'security',
34
+ 'exemplar',
35
+ 'plan-format',
36
+ ];
37
+ const lazyModules = [
38
+ 'doc-set',
39
+ 'business',
40
+ 'llm',
41
+ 'ux',
42
+ 'ui',
43
+ 'seo',
44
+ 'code-quality',
45
+ 'style-genome',
46
+ 'agent-memory',
47
+ 'repo',
48
+ 'build',
49
+ 'roadmap',
50
+ 'deploy',
51
+ 'observe',
52
+ 'launch',
53
+ ];
54
+
55
+ function measure(file) {
56
+ const bytes = fs.readFileSync(file);
57
+ return {
58
+ bytes: bytes.length,
59
+ estimated_tokens: Math.ceil(bytes.length / 4),
60
+ sha256: crypto.createHash('sha256').update(bytes).digest('hex'),
61
+ };
62
+ }
63
+
64
+ function moduleMeasurements(names) {
65
+ return Object.fromEntries(names.map((name) => [
66
+ name,
67
+ measure(path.join(references, `${name}.md`)),
68
+ ]));
69
+ }
70
+
71
+ function sum(measurements) {
72
+ return Object.values(measurements).reduce((total, value) => ({
73
+ bytes: total.bytes + value.bytes,
74
+ estimated_tokens: total.estimated_tokens + value.estimated_tokens,
75
+ }), { bytes: 0, estimated_tokens: 0 });
76
+ }
77
+
78
+ const temporary = fs.mkdtempSync(path.join(os.tmpdir(), 'godplans-context-'));
79
+ const fullPrompt = path.join(temporary, 'PROMPT.full.md');
80
+ try {
81
+ execFileSync('bash', ['scripts/build-prompt.sh', '--full', '--output', fullPrompt], {
82
+ cwd: root,
83
+ stdio: 'ignore',
84
+ });
85
+
86
+ const core = moduleMeasurements(coreModules);
87
+ const lazy = moduleMeasurements(lazyModules);
88
+ const document = {
89
+ format: 'godplans/context-cost@1',
90
+ estimate: {
91
+ method: 'ceil(raw_utf8_bytes / 4)',
92
+ limitation: 'Provider tokenizers differ. Published model runs record actual input and output token usage in RUNNER.txt and METRICS.json.',
93
+ },
94
+ portable_core: measure(path.join(root, 'PROMPT.md')),
95
+ portable_full_generated: measure(fullPrompt),
96
+ native_skill_entry: measure(path.join(root, 'skills', 'godplans', 'SKILL.md')),
97
+ core_modules: core,
98
+ core_modules_total: sum(core),
99
+ lazy_modules: lazy,
100
+ lazy_modules_total: sum(lazy),
101
+ };
102
+ const serialized = `${JSON.stringify(document, null, 2)}\n`;
103
+
104
+ if (check) {
105
+ if (!fs.existsSync(output) || fs.readFileSync(output, 'utf8') !== serialized) {
106
+ process.stderr.write('Context metrics are stale. Run `npm run metrics:context`.\n');
107
+ process.exitCode = 1;
108
+ } else {
109
+ process.stdout.write('Context metrics are current.\n');
110
+ }
111
+ } else {
112
+ fs.mkdirSync(path.dirname(output), { recursive: true });
113
+ fs.writeFileSync(output, serialized);
114
+ process.stdout.write(`Wrote ${path.relative(root, output)}.\n`);
115
+ }
116
+ } finally {
117
+ fs.rmSync(temporary, { recursive: true, force: true });
118
+ }