@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.
- package/CHANGELOG.md +1176 -0
- package/LICENSE +21 -0
- package/PROMPT.md +4006 -0
- package/README.md +201 -2
- package/assets/README.md +11 -0
- package/assets/hero.svg +44 -0
- package/assets/plan-loop.svg +62 -0
- package/assets/quest-map.svg +80 -0
- package/bin/godplans.js +93 -0
- package/docs/ARCHITECTURE.md +136 -0
- package/docs/RELEASING.md +107 -0
- package/evals/README.md +295 -0
- package/evals/cases/brownfield-cli/EXPECTATIONS +15 -0
- package/evals/cases/brownfield-cli/INPUT/package.json +9 -0
- package/evals/cases/brownfield-cli/INPUT/src/cli.js +4 -0
- package/evals/cases/brownfield-cli/INPUT/src/format.js +3 -0
- package/evals/cases/brownfield-cli/INPUT/test/cli.test.js +7 -0
- package/evals/cases/brownfield-cli/REQUEST.baseline.md +10 -0
- package/evals/cases/brownfield-cli/REQUEST.md +10 -0
- package/evals/cases/compliance-refusal/EXPECTATIONS +4 -0
- package/evals/cases/compliance-refusal/REQUEST.baseline.md +9 -0
- package/evals/cases/compliance-refusal/REQUEST.md +8 -0
- package/evals/cases/greenfield-saas/EXPECTATIONS +21 -0
- package/evals/cases/greenfield-saas/REQUEST.baseline.md +11 -0
- package/evals/cases/greenfield-saas/REQUEST.md +11 -0
- package/evals/cases/nested-pillars/EXPECTATIONS +12 -0
- package/evals/cases/nested-pillars/REQUEST.baseline.md +10 -0
- package/evals/cases/nested-pillars/REQUEST.md +11 -0
- package/evals/cases/observability-evidence/EXPECTATIONS +10 -0
- package/evals/cases/observability-evidence/REQUEST.baseline.md +10 -0
- package/evals/cases/observability-evidence/REQUEST.md +11 -0
- package/evals/cases/product-business/EXPECTATIONS +18 -0
- package/evals/cases/product-business/REQUEST.baseline.md +13 -0
- package/evals/cases/product-business/REQUEST.md +14 -0
- package/evals/cases/product-form-routing/EXPECTATIONS +13 -0
- package/evals/cases/product-form-routing/REQUEST.baseline.md +11 -0
- package/evals/cases/product-form-routing/REQUEST.md +11 -0
- package/evals/cases/prose-integrity/EXPECTATIONS +19 -0
- package/evals/cases/prose-integrity/REQUEST.baseline.md +19 -0
- package/evals/cases/prose-integrity/REQUEST.md +20 -0
- package/evals/cases/replan-preserves-history/EXPECTATIONS +9 -0
- package/evals/cases/replan-preserves-history/INPUT/.godplans/PLAN.mdx +115 -0
- package/evals/cases/replan-preserves-history/INPUT/package.json +5 -0
- package/evals/cases/replan-preserves-history/REQUEST.baseline.md +10 -0
- package/evals/cases/replan-preserves-history/REQUEST.md +10 -0
- package/evals/cases/stale-prepublication/EXPECTATIONS +10 -0
- package/evals/cases/stale-prepublication/REQUEST.baseline.md +12 -0
- package/evals/cases/stale-prepublication/REQUEST.md +13 -0
- package/evals/cases/stale-source-evidence/EXPECTATIONS +10 -0
- package/evals/cases/stale-source-evidence/INPUT/package.json +8 -0
- package/evals/cases/stale-source-evidence/REQUEST.baseline.md +11 -0
- package/evals/cases/stale-source-evidence/REQUEST.md +12 -0
- package/evals/cases/weekend-library/EXPECTATIONS +19 -0
- package/evals/cases/weekend-library/REQUEST.baseline.md +10 -0
- package/evals/cases/weekend-library/REQUEST.md +11 -0
- package/evals/cases-roster.txt +19 -0
- package/evals/external/GRADE.schema.json +39 -0
- package/evals/external/README.md +42 -0
- package/evals/external/RUBRIC.md +32 -0
- package/evals/metrics/context-cost.json +154 -0
- package/evals/outcomes/README.md +65 -0
- package/evals/outcomes/cases/tenant-notes-api/REQUEST.baseline.md +14 -0
- package/evals/outcomes/cases/tenant-notes-api/REQUEST.md +13 -0
- package/evals/outcomes/cases/tenant-notes-api/VERIFY.sh +13 -0
- package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/README.md +93 -0
- package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/treatment/plan/PLAN.json +547 -0
- package/evals/runners/claude-baseline.sh +4 -0
- package/evals/runners/claude-grade.sh +3 -0
- package/evals/runners/claude.sh +4 -0
- package/evals/runners/codex-baseline.sh +181 -0
- package/evals/runners/codex-builder.sh +96 -0
- package/evals/runners/codex-godaudits.sh +84 -0
- package/evals/runners/codex.sh +147 -0
- package/evals/runners/gemini-baseline.sh +4 -0
- package/evals/runners/gemini-grade.sh +3 -0
- package/evals/runners/gemini.sh +4 -0
- package/evals/runners/vendor-cli.sh +257 -0
- package/evals/runners/vendor-grade.sh +82 -0
- package/install.sh +323 -0
- package/package.json +92 -4
- package/requirements/skills-ref.txt +2 -0
- package/scripts/build-catalog.js +114 -0
- package/scripts/build-prompt.sh +257 -0
- package/scripts/context-metrics.js +118 -0
- package/scripts/eval-external.js +226 -0
- package/scripts/eval-matrix.sh +172 -0
- package/scripts/eval-outcome.js +143 -0
- package/scripts/eval.sh +321 -0
- package/scripts/lint-parity.js +331 -0
- package/scripts/lint.sh +743 -0
- package/scripts/outcome-summary.js +126 -0
- package/scripts/release-check.sh +108 -0
- package/scripts/release-prepare.js +41 -0
- package/scripts/summarize-eval.js +91 -0
- package/scripts/summarize-matrix.js +101 -0
- package/scripts/version-sync.js +65 -0
- package/skills/godplans/SKILL.md +192 -0
- package/skills/godplans/references/agent-memory.md +168 -0
- package/skills/godplans/references/architecture.md +189 -0
- package/skills/godplans/references/build.md +130 -0
- package/skills/godplans/references/business.md +252 -0
- package/skills/godplans/references/code-quality.md +165 -0
- package/skills/godplans/references/compliance.md +59 -0
- package/skills/godplans/references/database.md +157 -0
- package/skills/godplans/references/deploy.md +146 -0
- package/skills/godplans/references/discovery.md +297 -0
- package/skills/godplans/references/doc-set.md +243 -0
- package/skills/godplans/references/exemplar.md +228 -0
- package/skills/godplans/references/launch.md +162 -0
- package/skills/godplans/references/llm.md +132 -0
- package/skills/godplans/references/observe.md +178 -0
- package/skills/godplans/references/plan-format.md +340 -0
- package/skills/godplans/references/product.md +130 -0
- package/skills/godplans/references/repo.md +184 -0
- package/skills/godplans/references/roadmap.md +158 -0
- package/skills/godplans/references/security.md +156 -0
- package/skills/godplans/references/seo.md +133 -0
- package/skills/godplans/references/stack.md +133 -0
- package/skills/godplans/references/style-genome.md +198 -0
- package/skills/godplans/references/ui.md +153 -0
- package/skills/godplans/references/ux.md +150 -0
- package/skills/godplans/schemas/PLAN.schema.json +275 -0
- package/skills/godplans/schemas/PLAN.v1.schema.json +258 -0
- package/skills/godplans/scripts/plan-halflife.sh +76 -0
- package/skills/godplans/scripts/style-stats.py +630 -0
- package/skills/godplans/scripts/validate-plan.sh +1709 -0
- package/skills/godplans/templates/PLAN.template.mdx +269 -0
- package/tests/agent-memory-guidance.sh +32 -0
- package/tests/build-catalog.sh +81 -0
- package/tests/codex-runner.sh +139 -0
- package/tests/eval-harness.sh +377 -0
- package/tests/evidence-harnesses.sh +243 -0
- package/tests/fixtures/plan-json-v1-1.13.0.json +472 -0
- package/tests/install-regression.sh +246 -0
- package/tests/lib/plan-schema-check.js +163 -0
- package/tests/lint-selftest.sh +582 -0
- package/tests/package-contents.sh +140 -0
- package/tests/portable-prompt.test.sh +261 -0
- package/tests/release-tooling.sh +204 -0
- package/tests/run.sh +14 -0
- package/tests/script-usage.sh +37 -0
- package/tests/style-stats.sh +170 -0
- package/tests/validate-plan.sh +1970 -0
- package/tests/vendor-runner.sh +291 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
|
|
3
|
+
set -eu
|
|
4
|
+
|
|
5
|
+
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
6
|
+
TMP_ROOT=${TMPDIR:-/tmp}/godplans-install-test.$$
|
|
7
|
+
PASS_COUNT=0
|
|
8
|
+
|
|
9
|
+
cleanup() {
|
|
10
|
+
rm -rf "$TMP_ROOT"
|
|
11
|
+
}
|
|
12
|
+
trap cleanup EXIT HUP INT TERM
|
|
13
|
+
|
|
14
|
+
fail() {
|
|
15
|
+
echo "FAIL: $*" >&2
|
|
16
|
+
exit 1
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pass() {
|
|
20
|
+
PASS_COUNT=$((PASS_COUNT + 1))
|
|
21
|
+
echo "ok $PASS_COUNT - $1"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
new_fixture() {
|
|
25
|
+
fixture=$TMP_ROOT/fixture-$1
|
|
26
|
+
mkdir -p "$fixture/skills"
|
|
27
|
+
cp "$ROOT/install.sh" "$fixture/install.sh"
|
|
28
|
+
cp -R "$ROOT/skills/godplans" "$fixture/skills/godplans"
|
|
29
|
+
printf '%s\n' "$1" > "$fixture/skills/godplans/install-test-payload"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
run_global() {
|
|
33
|
+
fixture=$1
|
|
34
|
+
home=$2
|
|
35
|
+
shift 2
|
|
36
|
+
HOME=$home \
|
|
37
|
+
AGENTS_SKILLS_DIR=$home/.agents/skills \
|
|
38
|
+
CLAUDE_SKILLS_DIR=$home/.claude/skills \
|
|
39
|
+
sh "$fixture/install.sh" "$@"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
run_project() {
|
|
43
|
+
fixture=$1
|
|
44
|
+
home=$2
|
|
45
|
+
project=$3
|
|
46
|
+
shift 3
|
|
47
|
+
HOME=$home sh "$fixture/install.sh" --project "$project" "$@"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
assert_file_contains() {
|
|
51
|
+
grep -F "$2" "$1" >/dev/null 2>&1 || fail "$1 does not contain: $2"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
mkdir -p "$TMP_ROOT"
|
|
55
|
+
|
|
56
|
+
# Documented aliases must resolve to their canonical destination names.
|
|
57
|
+
new_fixture alias
|
|
58
|
+
home=$TMP_ROOT/home-alias
|
|
59
|
+
mkdir -p "$home"
|
|
60
|
+
run_global "$fixture" "$home" --tools claude,codex >/dev/null
|
|
61
|
+
[ -L "$home/.agents/skills/godplans" ] || fail "codex alias did not install the agents target"
|
|
62
|
+
[ -L "$home/.claude/skills/godplans" ] || fail "claude target was not installed"
|
|
63
|
+
for agent_alias in cursor zed vscode copilot gemini gemini-cli opencode amp kilo goose; do
|
|
64
|
+
run_global "$fixture" "$home" --tools "$agent_alias" >/dev/null
|
|
65
|
+
[ -L "$home/.agents/skills/godplans" ] || fail "$agent_alias alias did not install the agents target"
|
|
66
|
+
done
|
|
67
|
+
run_global "$fixture" "$home" --tools claude-code >/dev/null
|
|
68
|
+
[ -L "$home/.claude/skills/godplans" ] || fail "claude-code alias did not install the Claude target"
|
|
69
|
+
run_global "$fixture" "$home" --tools factory-droid --copy >/dev/null
|
|
70
|
+
[ -d "$home/.factory/skills/godplans" ] || fail "factory-droid alias did not install the Factory target"
|
|
71
|
+
pass "documented aliases map to canonical targets"
|
|
72
|
+
|
|
73
|
+
# Unknown names and mode-incompatible selections must fail before writing.
|
|
74
|
+
new_fixture reject
|
|
75
|
+
home=$TMP_ROOT/home-reject
|
|
76
|
+
project=$TMP_ROOT/project-reject
|
|
77
|
+
mkdir -p "$home" "$project"
|
|
78
|
+
if run_global "$fixture" "$home" --tools agents,unknown >"$TMP_ROOT/unknown.out" 2>&1; then
|
|
79
|
+
fail "unknown tool name succeeded"
|
|
80
|
+
fi
|
|
81
|
+
assert_file_contains "$TMP_ROOT/unknown.out" "Unknown tool: unknown"
|
|
82
|
+
[ ! -e "$home/.agents/skills/godplans" ] || fail "validation wrote a target before rejecting an unknown tool"
|
|
83
|
+
if run_global "$fixture" "$home" --tools copilot-cloud >"$TMP_ROOT/global-noop.out" 2>&1; then
|
|
84
|
+
fail "project-only target succeeded in global mode"
|
|
85
|
+
fi
|
|
86
|
+
assert_file_contains "$TMP_ROOT/global-noop.out" "not available in global mode"
|
|
87
|
+
if run_project "$fixture" "$home" "$project" --tools factory >"$TMP_ROOT/project-noop.out" 2>&1; then
|
|
88
|
+
fail "global-only target succeeded in project mode"
|
|
89
|
+
fi
|
|
90
|
+
assert_file_contains "$TMP_ROOT/project-noop.out" "not available in project mode"
|
|
91
|
+
run_global "$fixture" "$home" --tools factory --copy >/dev/null
|
|
92
|
+
[ -d "$home/.factory/skills/godplans" ] || fail "an explicitly selected undetected tool silently did nothing"
|
|
93
|
+
pass "invalid and no-op target selections are rejected atomically"
|
|
94
|
+
|
|
95
|
+
# Both installation forms must work in both scopes.
|
|
96
|
+
new_fixture matrix
|
|
97
|
+
home=$TMP_ROOT/home-matrix
|
|
98
|
+
project=$TMP_ROOT/project-matrix
|
|
99
|
+
mkdir -p "$home" "$project"
|
|
100
|
+
run_global "$fixture" "$home" --tools agents >/dev/null
|
|
101
|
+
[ -L "$home/.agents/skills/godplans" ] || fail "global symlink install did not create a symlink"
|
|
102
|
+
run_global "$fixture" "$home" --tools claude --copy >/dev/null
|
|
103
|
+
[ -d "$home/.claude/skills/godplans" ] || fail "global copy install did not create a directory"
|
|
104
|
+
[ ! -L "$home/.claude/skills/godplans" ] || fail "global copy install created a symlink"
|
|
105
|
+
run_project "$fixture" "$home" "$project" --tools agents >/dev/null
|
|
106
|
+
[ -L "$project/.agents/skills/godplans" ] || fail "project symlink install did not create a symlink"
|
|
107
|
+
run_project "$fixture" "$home" "$project" --tools claude,copilot-cloud --copy >/dev/null
|
|
108
|
+
[ -d "$project/.claude/skills/godplans" ] || fail "project copy install missed Claude"
|
|
109
|
+
[ -d "$project/.github/skills/godplans" ] || fail "project copy install missed Copilot cloud"
|
|
110
|
+
[ ! -L "$project/.github/skills/godplans" ] || fail "project Copilot copy created a symlink"
|
|
111
|
+
pass "copy and symlink installs work globally and per project"
|
|
112
|
+
|
|
113
|
+
# The global agents and claude roots honor their override variables at
|
|
114
|
+
# non-default paths, and --help names them. run_global pins both to the fake
|
|
115
|
+
# HOME, so these runs call the installer directly.
|
|
116
|
+
new_fixture override
|
|
117
|
+
home=$TMP_ROOT/home-override
|
|
118
|
+
mkdir -p "$home"
|
|
119
|
+
HOME=$home AGENTS_SKILLS_DIR=$TMP_ROOT/custom-agents CLAUDE_SKILLS_DIR=$TMP_ROOT/custom-claude \
|
|
120
|
+
sh "$fixture/install.sh" --tools agents,claude >/dev/null
|
|
121
|
+
[ -L "$TMP_ROOT/custom-agents/godplans" ] || fail "AGENTS_SKILLS_DIR was ignored"
|
|
122
|
+
[ -L "$TMP_ROOT/custom-claude/godplans" ] || fail "CLAUDE_SKILLS_DIR was ignored"
|
|
123
|
+
[ ! -e "$home/.agents/skills/godplans" ] || fail "AGENTS_SKILLS_DIR override still wrote under HOME"
|
|
124
|
+
[ ! -e "$home/.claude/skills/godplans" ] || fail "CLAUDE_SKILLS_DIR override still wrote under HOME"
|
|
125
|
+
HOME=$home AGENTS_SKILLS_DIR=$TMP_ROOT/custom-agents CLAUDE_SKILLS_DIR=$TMP_ROOT/custom-claude \
|
|
126
|
+
sh "$fixture/install.sh" --tools agents,claude --uninstall >/dev/null
|
|
127
|
+
[ ! -e "$TMP_ROOT/custom-agents/godplans" ] || fail "uninstall left the AGENTS_SKILLS_DIR install"
|
|
128
|
+
[ ! -e "$TMP_ROOT/custom-claude/godplans" ] || fail "uninstall left the CLAUDE_SKILLS_DIR install"
|
|
129
|
+
sh "$fixture/install.sh" --help > "$TMP_ROOT/help.out"
|
|
130
|
+
assert_file_contains "$TMP_ROOT/help.out" "AGENTS_SKILLS_DIR=DIR CLAUDE_SKILLS_DIR=DIR"
|
|
131
|
+
[ "$(tail -n 1 "$TMP_ROOT/help.out")" = "instructions are printed at the end." ] ||
|
|
132
|
+
fail "--help does not print the whole usage block"
|
|
133
|
+
pass "global root overrides are honored and documented"
|
|
134
|
+
|
|
135
|
+
# An unowned directory must survive install and uninstall attempts.
|
|
136
|
+
new_fixture collision
|
|
137
|
+
home=$TMP_ROOT/home-collision
|
|
138
|
+
mkdir -p "$home/.agents/skills/godplans"
|
|
139
|
+
printf '%s\n' keep > "$home/.agents/skills/godplans/sentinel"
|
|
140
|
+
if run_global "$fixture" "$home" --tools agents >"$TMP_ROOT/collision-install.out" 2>&1; then
|
|
141
|
+
fail "install replaced an unowned destination"
|
|
142
|
+
fi
|
|
143
|
+
assert_file_contains "$TMP_ROOT/collision-install.out" "Refusing to replace unowned destination"
|
|
144
|
+
assert_file_contains "$home/.agents/skills/godplans/sentinel" "keep"
|
|
145
|
+
if run_global "$fixture" "$home" --tools agents --uninstall >"$TMP_ROOT/collision-uninstall.out" 2>&1; then
|
|
146
|
+
fail "uninstall accepted an unowned destination"
|
|
147
|
+
fi
|
|
148
|
+
assert_file_contains "$TMP_ROOT/collision-uninstall.out" "Refusing to remove unowned destination"
|
|
149
|
+
assert_file_contains "$home/.agents/skills/godplans/sentinel" "keep"
|
|
150
|
+
pass "unowned destinations are preserved on install and uninstall"
|
|
151
|
+
|
|
152
|
+
# Installer-owned copies must update and uninstall cleanly.
|
|
153
|
+
new_fixture owned-copy
|
|
154
|
+
home=$TMP_ROOT/home-owned-copy
|
|
155
|
+
mkdir -p "$home"
|
|
156
|
+
run_global "$fixture" "$home" --tools agents --copy >/dev/null
|
|
157
|
+
assert_file_contains "$home/.agents/skills/godplans/install-test-payload" "owned-copy"
|
|
158
|
+
printf '%s\n' updated > "$fixture/skills/godplans/install-test-payload"
|
|
159
|
+
run_global "$fixture" "$home" --tools agents --copy >/dev/null
|
|
160
|
+
assert_file_contains "$home/.agents/skills/godplans/install-test-payload" "updated"
|
|
161
|
+
run_global "$fixture" "$home" --tools agents --uninstall >/dev/null
|
|
162
|
+
[ ! -e "$home/.agents/skills/godplans" ] || fail "owned copy survived uninstall"
|
|
163
|
+
pass "owned copies can be updated and uninstalled"
|
|
164
|
+
|
|
165
|
+
# Installer-owned symlinks must reinstall and uninstall cleanly.
|
|
166
|
+
new_fixture owned-link
|
|
167
|
+
home=$TMP_ROOT/home-owned-link
|
|
168
|
+
mkdir -p "$home"
|
|
169
|
+
run_global "$fixture" "$home" --tools agents >/dev/null
|
|
170
|
+
run_global "$fixture" "$home" --tools agents >/dev/null
|
|
171
|
+
[ -L "$home/.agents/skills/godplans" ] || fail "owned symlink reinstall did not preserve link mode"
|
|
172
|
+
mv "$fixture" "$fixture-moved"
|
|
173
|
+
fixture=$fixture-moved
|
|
174
|
+
run_global "$fixture" "$home" --tools agents >/dev/null
|
|
175
|
+
[ -f "$home/.agents/skills/godplans/install-test-payload" ] || fail "owned symlink was not repaired after its source moved"
|
|
176
|
+
run_global "$fixture" "$home" --tools agents --uninstall >/dev/null
|
|
177
|
+
[ ! -e "$home/.agents/skills/godplans" ] || fail "owned symlink survived uninstall"
|
|
178
|
+
pass "owned symlinks can be repaired, reinstalled, and uninstalled"
|
|
179
|
+
|
|
180
|
+
# A stale ownership record must not authorize deletion of a replacement.
|
|
181
|
+
new_fixture stale
|
|
182
|
+
home=$TMP_ROOT/home-stale
|
|
183
|
+
mkdir -p "$home"
|
|
184
|
+
run_global "$fixture" "$home" --tools agents >/dev/null
|
|
185
|
+
rm "$home/.agents/skills/godplans"
|
|
186
|
+
mkdir -p "$home/.agents/skills/godplans"
|
|
187
|
+
printf '%s\n' replacement > "$home/.agents/skills/godplans/sentinel"
|
|
188
|
+
if run_global "$fixture" "$home" --tools agents --uninstall >"$TMP_ROOT/stale.out" 2>&1; then
|
|
189
|
+
fail "stale ownership record authorized unowned deletion"
|
|
190
|
+
fi
|
|
191
|
+
assert_file_contains "$home/.agents/skills/godplans/sentinel" "replacement"
|
|
192
|
+
rm -rf "$home/.agents/skills/godplans"
|
|
193
|
+
mkdir -p "$TMP_ROOT/unowned-link-target"
|
|
194
|
+
printf '%s\n' other > "$TMP_ROOT/unowned-link-target/sentinel"
|
|
195
|
+
ln -s "$TMP_ROOT/unowned-link-target" "$home/.agents/skills/godplans"
|
|
196
|
+
if run_global "$fixture" "$home" --tools agents --uninstall >"$TMP_ROOT/stale-link.out" 2>&1; then
|
|
197
|
+
fail "stale ownership record authorized deletion of a replacement symlink"
|
|
198
|
+
fi
|
|
199
|
+
assert_file_contains "$home/.agents/skills/godplans/sentinel" "other"
|
|
200
|
+
pass "stale ownership state does not delete directory or symlink replacements"
|
|
201
|
+
|
|
202
|
+
# Force is the explicit escape hatch for unowned install and uninstall.
|
|
203
|
+
new_fixture force
|
|
204
|
+
home=$TMP_ROOT/home-force
|
|
205
|
+
mkdir -p "$home/.agents/skills/godplans"
|
|
206
|
+
printf '%s\n' replace > "$home/.agents/skills/godplans/sentinel"
|
|
207
|
+
run_global "$fixture" "$home" --tools agents --copy --force >/dev/null
|
|
208
|
+
[ ! -e "$home/.agents/skills/godplans/sentinel" ] || fail "forced install preserved the collision"
|
|
209
|
+
assert_file_contains "$home/.agents/skills/godplans/install-test-payload" "force"
|
|
210
|
+
run_global "$fixture" "$home" --tools agents --uninstall >/dev/null
|
|
211
|
+
mkdir -p "$home/.agents/skills/godplans"
|
|
212
|
+
printf '%s\n' remove > "$home/.agents/skills/godplans/sentinel"
|
|
213
|
+
run_global "$fixture" "$home" --tools agents --uninstall --force >/dev/null
|
|
214
|
+
[ ! -e "$home/.agents/skills/godplans" ] || fail "forced uninstall preserved the unowned destination"
|
|
215
|
+
pass "force explicitly permits replacement and removal"
|
|
216
|
+
|
|
217
|
+
# Installing never rewrites the source checkout's tracked PROMPT.md; lint
|
|
218
|
+
# prompt-fresh keeps the committed prompt current instead.
|
|
219
|
+
new_fixture prompt
|
|
220
|
+
mkdir -p "$fixture/scripts"
|
|
221
|
+
cp "$ROOT/scripts/build-prompt.sh" "$fixture/scripts/build-prompt.sh"
|
|
222
|
+
chmod +x "$fixture/scripts/build-prompt.sh"
|
|
223
|
+
printf '%s\n' 'source prompt sentinel' > "$fixture/PROMPT.md"
|
|
224
|
+
home=$TMP_ROOT/home-prompt
|
|
225
|
+
mkdir -p "$home"
|
|
226
|
+
run_global "$fixture" "$home" --tools agents >/dev/null
|
|
227
|
+
assert_file_contains "$fixture/PROMPT.md" "source prompt sentinel"
|
|
228
|
+
pass "install leaves the source PROMPT.md untouched"
|
|
229
|
+
|
|
230
|
+
# A copy install omits Python bytecode found in the source checkout, and never
|
|
231
|
+
# deletes it from the source.
|
|
232
|
+
new_fixture bytecode
|
|
233
|
+
mkdir -p "$fixture/skills/godplans/scripts/__pycache__"
|
|
234
|
+
printf '%s\n' bytecode > "$fixture/skills/godplans/scripts/__pycache__/style-stats.cpython-314.pyc"
|
|
235
|
+
printf '%s\n' bytecode > "$fixture/skills/godplans/scripts/stray.pyc"
|
|
236
|
+
home=$TMP_ROOT/home-bytecode
|
|
237
|
+
mkdir -p "$home"
|
|
238
|
+
run_global "$fixture" "$home" --tools agents --copy >/dev/null
|
|
239
|
+
[ -f "$home/.agents/skills/godplans/install-test-payload" ] || fail "bytecode fixture copy did not install"
|
|
240
|
+
[ ! -e "$home/.agents/skills/godplans/scripts/__pycache__" ] || fail "copy install shipped __pycache__"
|
|
241
|
+
[ ! -e "$home/.agents/skills/godplans/scripts/stray.pyc" ] || fail "copy install shipped a .pyc file"
|
|
242
|
+
[ -f "$fixture/skills/godplans/scripts/__pycache__/style-stats.cpython-314.pyc" ] ||
|
|
243
|
+
fail "copy install deleted bytecode from the source checkout"
|
|
244
|
+
pass "copy install omits Python bytecode"
|
|
245
|
+
|
|
246
|
+
echo "1..$PASS_COUNT"
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Dependency-free JSON Schema subset checker for PLAN.json sidecars.
|
|
3
|
+
//
|
|
4
|
+
// Usage: node tests/lib/plan-schema-check.js SCHEMA.json DOCUMENT.json...
|
|
5
|
+
// Exits 0 when every document conforms, 1 when any does not, and 2 for a usage
|
|
6
|
+
// error or a schema that uses a keyword this checker does not implement.
|
|
7
|
+
//
|
|
8
|
+
// It implements the keywords PLAN.schema.json and PLAN.v1.schema.json use, plus
|
|
9
|
+
// maxLength, and refuses any other keyword anywhere in the schema, whether or
|
|
10
|
+
// not a document reaches it, so a schema edit that relies on something
|
|
11
|
+
// unimplemented fails the suite instead of passing unchecked. Documents are
|
|
12
|
+
// decoded as strict UTF-8 because a sidecar that is not valid UTF-8 is not
|
|
13
|
+
// valid JSON.
|
|
14
|
+
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
const fs = require('node:fs');
|
|
18
|
+
|
|
19
|
+
const ANNOTATIONS = new Set(['$schema', 'title', 'description']);
|
|
20
|
+
const KEYWORDS = new Set([
|
|
21
|
+
'type', 'enum', 'const', 'required', 'properties', 'additionalProperties',
|
|
22
|
+
'items', 'minItems', 'maxItems', 'uniqueItems', 'minLength', 'maxLength',
|
|
23
|
+
'pattern', 'minimum', 'maximum', 'format',
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
function readJson(path) {
|
|
27
|
+
const bytes = fs.readFileSync(path);
|
|
28
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
29
|
+
return JSON.parse(text);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function typeOf(value) {
|
|
33
|
+
if (value === null) return 'null';
|
|
34
|
+
if (Array.isArray(value)) return 'array';
|
|
35
|
+
if (typeof value === 'number') return Number.isInteger(value) ? 'integer' : 'number';
|
|
36
|
+
return typeof value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function matchesType(value, type) {
|
|
40
|
+
const actual = typeOf(value);
|
|
41
|
+
return actual === type || (type === 'number' && actual === 'integer');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function realDate(text) {
|
|
45
|
+
const match = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(text);
|
|
46
|
+
if (!match) return false;
|
|
47
|
+
const [year, month, day] = match.slice(1).map(Number);
|
|
48
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
49
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const FORMATS = {
|
|
53
|
+
date: realDate,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function same(left, right) {
|
|
57
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Walk every subschema up front. Checking keywords only where a document
|
|
61
|
+
// reaches would let one hide under an optional property or the items of an
|
|
62
|
+
// array every fixture leaves empty.
|
|
63
|
+
function assertSupported(schema, path) {
|
|
64
|
+
if (typeOf(schema) !== 'object') throw new Error(`subschema at ${path} is not an object`);
|
|
65
|
+
for (const key of Object.keys(schema)) {
|
|
66
|
+
if (!ANNOTATIONS.has(key) && !KEYWORDS.has(key)) {
|
|
67
|
+
throw new Error(`unsupported schema keyword ${key} at ${path}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if ('format' in schema && !FORMATS[schema.format]) {
|
|
71
|
+
throw new Error(`unsupported format ${schema.format} at ${path}`);
|
|
72
|
+
}
|
|
73
|
+
for (const [key, item] of Object.entries(schema.properties || {})) assertSupported(item, `${path}.${key}`);
|
|
74
|
+
if ('items' in schema) assertSupported(schema.items, `${path}[]`);
|
|
75
|
+
if (typeof schema.additionalProperties === 'object') assertSupported(schema.additionalProperties, `${path}.*`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function check(schema, value, path, errors) {
|
|
79
|
+
const fail = (message) => errors.push(`${path}: ${message}`);
|
|
80
|
+
|
|
81
|
+
if ('type' in schema) {
|
|
82
|
+
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
83
|
+
if (!types.some((type) => matchesType(value, type))) {
|
|
84
|
+
fail(`type ${typeOf(value)} is not ${types.join(' or ')}`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if ('const' in schema && !same(value, schema.const)) fail(`expected ${JSON.stringify(schema.const)}`);
|
|
89
|
+
if ('enum' in schema && !schema.enum.some((option) => same(value, option))) {
|
|
90
|
+
fail(`${JSON.stringify(value)} is not one of ${JSON.stringify(schema.enum)}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (typeof value === 'string') {
|
|
94
|
+
if ('minLength' in schema && value.length < schema.minLength) fail(`shorter than ${schema.minLength}`);
|
|
95
|
+
if ('maxLength' in schema && value.length > schema.maxLength) fail(`longer than ${schema.maxLength}`);
|
|
96
|
+
if ('pattern' in schema && !new RegExp(schema.pattern, 'u').test(value)) {
|
|
97
|
+
fail(`${JSON.stringify(value)} does not match ${schema.pattern}`);
|
|
98
|
+
}
|
|
99
|
+
if ('format' in schema && !FORMATS[schema.format](value)) {
|
|
100
|
+
fail(`${JSON.stringify(value)} is not a valid ${schema.format}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (typeof value === 'number') {
|
|
105
|
+
if ('minimum' in schema && value < schema.minimum) fail(`below ${schema.minimum}`);
|
|
106
|
+
if ('maximum' in schema && value > schema.maximum) fail(`above ${schema.maximum}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (Array.isArray(value)) {
|
|
110
|
+
if ('minItems' in schema && value.length < schema.minItems) fail(`fewer than ${schema.minItems} items`);
|
|
111
|
+
if ('maxItems' in schema && value.length > schema.maxItems) fail(`more than ${schema.maxItems} items`);
|
|
112
|
+
if (schema.uniqueItems) {
|
|
113
|
+
const seen = new Set(value.map((item) => JSON.stringify(item)));
|
|
114
|
+
if (seen.size !== value.length) fail('items are not unique');
|
|
115
|
+
}
|
|
116
|
+
if ('items' in schema) value.forEach((item, index) => check(schema.items, item, `${path}[${index}]`, errors));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (typeOf(value) === 'object') {
|
|
120
|
+
for (const key of schema.required || []) {
|
|
121
|
+
if (!(key in value)) fail(`missing required property ${key}`);
|
|
122
|
+
}
|
|
123
|
+
const properties = schema.properties || {};
|
|
124
|
+
for (const [key, item] of Object.entries(value)) {
|
|
125
|
+
if (key in properties) {
|
|
126
|
+
check(properties[key], item, `${path}.${key}`, errors);
|
|
127
|
+
} else if (schema.additionalProperties === false) {
|
|
128
|
+
fail(`unexpected property ${key}`);
|
|
129
|
+
} else if (typeof schema.additionalProperties === 'object') {
|
|
130
|
+
check(schema.additionalProperties, item, `${path}.${key}`, errors);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function main(argv) {
|
|
137
|
+
if (argv.length < 2) {
|
|
138
|
+
process.stderr.write('usage: plan-schema-check.js SCHEMA.json DOCUMENT.json...\n');
|
|
139
|
+
return 2;
|
|
140
|
+
}
|
|
141
|
+
let schema;
|
|
142
|
+
try {
|
|
143
|
+
schema = readJson(argv[0]);
|
|
144
|
+
assertSupported(schema, '$');
|
|
145
|
+
} catch (error) {
|
|
146
|
+
process.stderr.write(`FAIL ${argv[0]}: ${error.message}\n`);
|
|
147
|
+
return 2;
|
|
148
|
+
}
|
|
149
|
+
let failed = 0;
|
|
150
|
+
for (const path of argv.slice(1)) {
|
|
151
|
+
const errors = [];
|
|
152
|
+
try {
|
|
153
|
+
check(schema, readJson(path), '$', errors);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
errors.push(error.message);
|
|
156
|
+
}
|
|
157
|
+
for (const error of errors) process.stderr.write(`FAIL ${path}: ${error}\n`);
|
|
158
|
+
if (errors.length) failed += 1;
|
|
159
|
+
}
|
|
160
|
+
return failed ? 1 : 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
process.exitCode = main(process.argv.slice(2));
|