dsh-pstack 0.1.0 → 0.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +92 -117
- package/assets/agents/comment-sicko.md +1 -1
- package/assets/agents/poteto-agent.md +2 -2
- package/assets/docs/guide/01-setup.md +9 -9
- package/assets/docs/guide/02-poteto-mode.md +4 -4
- package/assets/docs/guide/05-build-and-clean.md +3 -3
- package/assets/docs/guide/06-verify-and-ship.md +2 -2
- package/assets/docs/guide/07-overnight.md +10 -12
- package/assets/docs/guide/09-make-it-yours.md +2 -6
- package/assets/docs/guide/10-recipes-and-pitfalls.md +3 -3
- package/assets/docs/guide/README.md +1 -1
- package/assets/docs/guide/images/design.jpg +0 -0
- package/assets/docs/guide/images/overnight.jpg +0 -0
- package/assets/docs/guide/images/recipes.jpg +0 -0
- package/assets/docs/guide/images/router.jpg +0 -0
- package/assets/docs/guide/images/understanding.jpg +0 -0
- package/assets/docs/guide/images/verification.jpg +0 -0
- package/assets/docs/harness/dsh.md +60 -65
- package/assets/docs/pstack-models.example.md +40 -9
- package/assets/skills/architect/SKILL.md +12 -12
- package/assets/skills/arena/SKILL.md +11 -11
- package/assets/skills/automate-me/SKILL.md +15 -14
- package/assets/skills/benchmark-checklist/SKILL.md +0 -2
- package/assets/skills/blast-radius/SKILL.md +5 -5
- package/assets/skills/bro/SKILL.md +0 -2
- package/assets/skills/correct/SKILL.md +0 -2
- package/assets/skills/create-formal-verification-skill/SKILL.md +2 -2
- package/assets/skills/create-verification-skill/SKILL.md +2 -2
- package/assets/skills/figure-it-out/SKILL.md +13 -13
- package/assets/skills/how/SKILL.md +6 -6
- package/assets/skills/how/references/explainer-prompt.md +1 -1
- package/assets/skills/in-your-own-words/SKILL.md +0 -2
- package/assets/skills/interrogate/SKILL.md +9 -7
- package/assets/skills/interrogate/references/rubric.md +1 -1
- package/assets/skills/ketchup/SKILL.md +4 -4
- package/assets/skills/maintain-formal-verification-skill/SKILL.md +2 -2
- package/assets/skills/maintain-verification-skill/SKILL.md +3 -3
- package/assets/skills/no-comments/SKILL.md +7 -7
- package/assets/skills/poteto-help/SKILL.md +32 -31
- package/assets/skills/poteto-help/references/prompting.md +1 -1
- package/assets/skills/poteto-help/references/recipes.md +1 -1
- package/assets/skills/poteto-mode/SKILL.md +17 -19
- package/assets/skills/poteto-mode/playbooks/authoring-a-skill.md +3 -3
- package/assets/skills/poteto-mode/playbooks/autonomous-run.md +6 -4
- package/assets/skills/poteto-mode/playbooks/autopilot-full.md +6 -6
- package/assets/skills/poteto-mode/playbooks/autopilot-stack.md +2 -2
- package/assets/skills/poteto-mode/playbooks/babysit.md +3 -3
- package/assets/skills/poteto-mode/playbooks/bug-fix.md +7 -7
- package/assets/skills/poteto-mode/playbooks/eval.md +3 -3
- package/assets/skills/poteto-mode/playbooks/feature.md +8 -8
- package/assets/skills/poteto-mode/playbooks/hillclimb.md +3 -3
- package/assets/skills/poteto-mode/playbooks/investigation.md +2 -2
- package/assets/skills/poteto-mode/playbooks/multi-phase-plan.md +21 -21
- package/assets/skills/poteto-mode/playbooks/opening-a-pr.md +6 -6
- package/assets/skills/poteto-mode/playbooks/orchestrate.md +13 -13
- package/assets/skills/poteto-mode/playbooks/pause-safely.md +2 -2
- package/assets/skills/poteto-mode/playbooks/perf-issue.md +6 -6
- package/assets/skills/poteto-mode/playbooks/prototype.md +4 -4
- package/assets/skills/poteto-mode/playbooks/refactoring.md +9 -9
- package/assets/skills/poteto-mode/playbooks/runtime-forensics.md +3 -3
- package/assets/skills/poteto-mode/playbooks/session-pickup.md +2 -2
- package/assets/skills/poteto-mode/playbooks/shipping.md +2 -2
- package/assets/skills/poteto-mode/playbooks/trace-forensics.md +2 -2
- package/assets/skills/poteto-mode/playbooks/visual-parity.md +5 -5
- package/assets/skills/poteto-mode/playbooks/worktree-cleanup.md +14 -6
- package/assets/skills/poteto-mode/scripts/check-plan.mjs +85 -70
- package/assets/skills/poteto-mode/scripts/check-plan.test.mjs +343 -0
- package/assets/skills/poteto-mode/scripts/orch/orch.mjs +4282 -0
- package/assets/skills/poteto-mode/scripts/orch/orch.test.mjs +2042 -0
- package/assets/skills/poteto-mode/scripts/watch-pr/cli.test.mjs +5101 -0
- package/assets/skills/poteto-mode/scripts/watch-pr/github.test.mjs +1177 -0
- package/assets/skills/poteto-mode/scripts/watch-pr/policy.test.mjs +1441 -0
- package/assets/skills/poteto-mode/scripts/watch-pr/watch-pr.mjs +4601 -0
- package/assets/skills/poteto-mode/scripts/worktree-audit.mjs +675 -0
- package/assets/skills/principle-attack-the-premise/SKILL.md +0 -2
- package/assets/skills/principle-boundary-discipline/SKILL.md +0 -2
- package/assets/skills/principle-build-the-lever/SKILL.md +0 -3
- package/assets/skills/principle-encode-lessons-in-structure/SKILL.md +0 -2
- package/assets/skills/principle-exhaust-the-design-space/SKILL.md +0 -2
- package/assets/skills/principle-experience-first/SKILL.md +0 -2
- package/assets/skills/principle-explain-the-number/SKILL.md +0 -2
- package/assets/skills/principle-fix-root-causes/SKILL.md +0 -2
- package/assets/skills/principle-foundational-thinking/SKILL.md +0 -2
- package/assets/skills/principle-guard-the-context-window/SKILL.md +0 -2
- package/assets/skills/principle-laziness-protocol/SKILL.md +0 -2
- package/assets/skills/principle-make-operations-idempotent/SKILL.md +0 -2
- package/assets/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +0 -2
- package/assets/skills/principle-minimize-reader-load/SKILL.md +0 -2
- package/assets/skills/principle-model-the-domain/SKILL.md +0 -2
- package/assets/skills/principle-never-block-on-the-human/SKILL.md +0 -2
- package/assets/skills/principle-outcome-oriented-execution/SKILL.md +0 -2
- package/assets/skills/principle-prove-it-works/SKILL.md +2 -2
- package/assets/skills/principle-redesign-from-first-principles/SKILL.md +0 -2
- package/assets/skills/principle-separate-before-serializing-shared-state/SKILL.md +0 -2
- package/assets/skills/principle-sequence-verifiable-units/SKILL.md +0 -2
- package/assets/skills/principle-subtract-before-you-add/SKILL.md +0 -2
- package/assets/skills/principle-test-behavior-not-implementation/SKILL.md +0 -2
- package/assets/skills/principle-type-system-discipline/SKILL.md +0 -2
- package/assets/skills/recall/SKILL.md +9 -9
- package/assets/skills/reflect/SKILL.md +20 -21
- package/assets/skills/reflect/references/divergent-reviewer.md +4 -4
- package/assets/skills/reflect/references/judgment-reviewer.md +2 -2
- package/assets/skills/reflect/references/synthesizer.md +6 -6
- package/assets/skills/reflect/references/tooling-reviewer.md +2 -2
- package/assets/skills/setup-pstack/SKILL.md +28 -37
- package/assets/skills/sharpen/SKILL.md +0 -2
- package/assets/skills/show-me-your-work/SKILL.md +9 -9
- package/assets/skills/show-me-your-work/scripts/log.mjs +108 -0
- package/assets/skills/swarm/SKILL.md +8 -6
- package/assets/skills/tdd/SKILL.md +0 -2
- package/assets/skills/teach/SKILL.md +2 -2
- package/assets/skills/technical-writing/SKILL.md +2 -2
- package/assets/skills/typescript-best-practices/SKILL.md +6 -4
- package/assets/skills/unslop/SKILL.md +0 -2
- package/assets/skills/why/SKILL.md +9 -9
- package/cordis.patch.yml +33 -14
- package/dist/frontmatter-BQX3ekwP.mjs +229 -0
- package/dist/frontmatter-BQX3ekwP.mjs.map +1 -0
- package/dist/history.d.mts +429 -0
- package/dist/history.mjs +1129 -0
- package/dist/history.mjs.map +1 -0
- package/dist/host-contract-o47JH_r8.d.mts +527 -0
- package/dist/index.d.mts +273 -11
- package/dist/index.mjs +248 -148
- package/dist/index.mjs.map +1 -1
- package/dist/paths-D_JlVmBk.mjs +42 -0
- package/dist/paths-D_JlVmBk.mjs.map +1 -0
- package/dist/script.d.mts +193 -0
- package/dist/script.mjs +782 -0
- package/dist/script.mjs.map +1 -0
- package/dist/subagent.d.mts +306 -100
- package/dist/subagent.mjs +1309 -343
- package/dist/subagent.mjs.map +1 -1
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +55 -41
- package/static/icon.png +0 -0
- package/assets/skills/poteto-mode/scripts/bootstrap.ts +0 -62
- package/assets/skills/poteto-mode/scripts/bun.lock +0 -67
- package/assets/skills/poteto-mode/scripts/check-plan.test.ts +0 -96
- package/assets/skills/poteto-mode/scripts/orch/orch.test.ts +0 -761
- package/assets/skills/poteto-mode/scripts/orch/orch.ts +0 -590
- package/assets/skills/poteto-mode/scripts/orch/store.ts +0 -1677
- package/assets/skills/poteto-mode/scripts/package.json +0 -16
- package/assets/skills/poteto-mode/scripts/watch-pr/cli.test.ts +0 -224
- package/assets/skills/poteto-mode/scripts/watch-pr/cli.ts +0 -223
- package/assets/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +0 -129
- package/assets/skills/poteto-mode/scripts/watch-pr/github.test.ts +0 -436
- package/assets/skills/poteto-mode/scripts/watch-pr/github.ts +0 -718
- package/assets/skills/poteto-mode/scripts/watch-pr/policy.test.ts +0 -420
- package/assets/skills/poteto-mode/scripts/watch-pr/policy.ts +0 -836
- package/assets/skills/poteto-mode/scripts/watch-pr/render.ts +0 -169
- package/assets/skills/poteto-mode/scripts/watch-pr/tsconfig.json +0 -13
- package/assets/skills/poteto-mode/scripts/watch-pr/types.compile.ts +0 -93
- package/assets/skills/poteto-mode/scripts/watch-pr/types.ts +0 -413
- package/assets/skills/poteto-mode/scripts/watch-pr/watch-pr +0 -6
- package/assets/skills/poteto-mode/scripts/worktree-audit.sh +0 -127
- package/assets/skills/show-me-your-work/scripts/log.sh +0 -42
- package/dist/LICENSE +0 -22
- package/dist/README.md +0 -159
- package/dist/assets/agents/comment-sicko.md +0 -32
- package/dist/assets/agents/poteto-agent.md +0 -8
- package/dist/assets/docs/guide/01-setup.md +0 -64
- package/dist/assets/docs/guide/02-poteto-mode.md +0 -139
- package/dist/assets/docs/guide/03-understand.md +0 -79
- package/dist/assets/docs/guide/04-design.md +0 -133
- package/dist/assets/docs/guide/05-build-and-clean.md +0 -83
- package/dist/assets/docs/guide/06-verify-and-ship.md +0 -152
- package/dist/assets/docs/guide/07-overnight.md +0 -122
- package/dist/assets/docs/guide/08-principles.md +0 -72
- package/dist/assets/docs/guide/09-make-it-yours.md +0 -100
- package/dist/assets/docs/guide/10-recipes-and-pitfalls.md +0 -180
- package/dist/assets/docs/guide/README.md +0 -38
- package/dist/assets/docs/harness/dsh.md +0 -65
- package/dist/assets/docs/pstack-models.example.md +0 -23
- package/dist/assets/skills/architect/SKILL.md +0 -81
- package/dist/assets/skills/architect/references/design-red-flags.md +0 -57
- package/dist/assets/skills/architect/references/rationale-template.md +0 -35
- package/dist/assets/skills/architect/references/runner-prompt.md +0 -20
- package/dist/assets/skills/arena/SKILL.md +0 -50
- package/dist/assets/skills/automate-me/SKILL.md +0 -105
- package/dist/assets/skills/benchmark-checklist/SKILL.md +0 -41
- package/dist/assets/skills/blast-radius/SKILL.md +0 -52
- package/dist/assets/skills/bro/SKILL.md +0 -9
- package/dist/assets/skills/correct/SKILL.md +0 -34
- package/dist/assets/skills/create-formal-verification-skill/SKILL.md +0 -43
- package/dist/assets/skills/create-verification-skill/SKILL.md +0 -46
- package/dist/assets/skills/create-verification-skill/references/feature-map-example/README.md +0 -47
- package/dist/assets/skills/create-verification-skill/references/feature-map-example/create-note.md +0 -39
- package/dist/assets/skills/create-verification-skill/references/feature-map-example/search.md +0 -45
- package/dist/assets/skills/figure-it-out/SKILL.md +0 -54
- package/dist/assets/skills/how/SKILL.md +0 -38
- package/dist/assets/skills/how/references/explainer-prompt.md +0 -55
- package/dist/assets/skills/how/references/explorer-prompt.md +0 -35
- package/dist/assets/skills/in-your-own-words/SKILL.md +0 -9
- package/dist/assets/skills/interrogate/SKILL.md +0 -69
- package/dist/assets/skills/interrogate/references/code-quality-review.md +0 -47
- package/dist/assets/skills/interrogate/references/lead-judgment.md +0 -39
- package/dist/assets/skills/interrogate/references/reviewer-prompt.md +0 -62
- package/dist/assets/skills/interrogate/references/rubric.md +0 -77
- package/dist/assets/skills/ketchup/SKILL.md +0 -45
- package/dist/assets/skills/maintain-formal-verification-skill/SKILL.md +0 -60
- package/dist/assets/skills/maintain-verification-skill/SKILL.md +0 -41
- package/dist/assets/skills/no-comments/SKILL.md +0 -26
- package/dist/assets/skills/poteto-help/SKILL.md +0 -161
- package/dist/assets/skills/poteto-help/references/prompting.md +0 -51
- package/dist/assets/skills/poteto-help/references/recipes.md +0 -51
- package/dist/assets/skills/poteto-mode/SKILL.md +0 -153
- package/dist/assets/skills/poteto-mode/playbooks/authoring-a-skill.md +0 -12
- package/dist/assets/skills/poteto-mode/playbooks/autonomous-run.md +0 -13
- package/dist/assets/skills/poteto-mode/playbooks/autopilot-full.md +0 -25
- package/dist/assets/skills/poteto-mode/playbooks/autopilot-stack.md +0 -12
- package/dist/assets/skills/poteto-mode/playbooks/babysit.md +0 -23
- package/dist/assets/skills/poteto-mode/playbooks/bug-fix.md +0 -15
- package/dist/assets/skills/poteto-mode/playbooks/eval.md +0 -25
- package/dist/assets/skills/poteto-mode/playbooks/feature.md +0 -21
- package/dist/assets/skills/poteto-mode/playbooks/hillclimb.md +0 -21
- package/dist/assets/skills/poteto-mode/playbooks/investigation.md +0 -14
- package/dist/assets/skills/poteto-mode/playbooks/multi-phase-plan.md +0 -155
- package/dist/assets/skills/poteto-mode/playbooks/opening-a-pr.md +0 -34
- package/dist/assets/skills/poteto-mode/playbooks/orchestrate.md +0 -112
- package/dist/assets/skills/poteto-mode/playbooks/pause-safely.md +0 -10
- package/dist/assets/skills/poteto-mode/playbooks/perf-issue.md +0 -25
- package/dist/assets/skills/poteto-mode/playbooks/prototype.md +0 -14
- package/dist/assets/skills/poteto-mode/playbooks/refactoring.md +0 -16
- package/dist/assets/skills/poteto-mode/playbooks/runtime-forensics.md +0 -11
- package/dist/assets/skills/poteto-mode/playbooks/session-pickup.md +0 -11
- package/dist/assets/skills/poteto-mode/playbooks/shipping.md +0 -12
- package/dist/assets/skills/poteto-mode/playbooks/trace-forensics.md +0 -14
- package/dist/assets/skills/poteto-mode/playbooks/visual-parity.md +0 -11
- package/dist/assets/skills/poteto-mode/playbooks/worktree-cleanup.md +0 -12
- package/dist/assets/skills/poteto-mode/references/bugbot-triage.md +0 -142
- package/dist/assets/skills/poteto-mode/scripts/bootstrap.ts +0 -62
- package/dist/assets/skills/poteto-mode/scripts/bun.lock +0 -67
- package/dist/assets/skills/poteto-mode/scripts/check-plan.mjs +0 -205
- package/dist/assets/skills/poteto-mode/scripts/check-plan.test.ts +0 -96
- package/dist/assets/skills/poteto-mode/scripts/orch/orch.test.ts +0 -761
- package/dist/assets/skills/poteto-mode/scripts/orch/orch.ts +0 -590
- package/dist/assets/skills/poteto-mode/scripts/orch/store.ts +0 -1677
- package/dist/assets/skills/poteto-mode/scripts/package.json +0 -16
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/cli.test.ts +0 -224
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/cli.ts +0 -223
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +0 -129
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/github.test.ts +0 -436
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/github.ts +0 -718
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/policy.test.ts +0 -420
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/policy.ts +0 -836
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/render.ts +0 -169
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/tsconfig.json +0 -13
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/types.compile.ts +0 -93
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/types.ts +0 -413
- package/dist/assets/skills/poteto-mode/scripts/watch-pr/watch-pr +0 -6
- package/dist/assets/skills/poteto-mode/scripts/worktree-audit.sh +0 -127
- package/dist/assets/skills/principle-attack-the-premise/SKILL.md +0 -23
- package/dist/assets/skills/principle-boundary-discipline/SKILL.md +0 -36
- package/dist/assets/skills/principle-build-the-lever/SKILL.md +0 -26
- package/dist/assets/skills/principle-encode-lessons-in-structure/SKILL.md +0 -13
- package/dist/assets/skills/principle-exhaust-the-design-space/SKILL.md +0 -11
- package/dist/assets/skills/principle-experience-first/SKILL.md +0 -21
- package/dist/assets/skills/principle-explain-the-number/SKILL.md +0 -19
- package/dist/assets/skills/principle-fix-root-causes/SKILL.md +0 -23
- package/dist/assets/skills/principle-foundational-thinking/SKILL.md +0 -23
- package/dist/assets/skills/principle-guard-the-context-window/SKILL.md +0 -14
- package/dist/assets/skills/principle-laziness-protocol/SKILL.md +0 -12
- package/dist/assets/skills/principle-make-operations-idempotent/SKILL.md +0 -24
- package/dist/assets/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +0 -16
- package/dist/assets/skills/principle-minimize-reader-load/SKILL.md +0 -20
- package/dist/assets/skills/principle-model-the-domain/SKILL.md +0 -26
- package/dist/assets/skills/principle-never-block-on-the-human/SKILL.md +0 -17
- package/dist/assets/skills/principle-outcome-oriented-execution/SKILL.md +0 -23
- package/dist/assets/skills/principle-prove-it-works/SKILL.md +0 -24
- package/dist/assets/skills/principle-redesign-from-first-principles/SKILL.md +0 -18
- package/dist/assets/skills/principle-separate-before-serializing-shared-state/SKILL.md +0 -18
- package/dist/assets/skills/principle-sequence-verifiable-units/SKILL.md +0 -19
- package/dist/assets/skills/principle-subtract-before-you-add/SKILL.md +0 -20
- package/dist/assets/skills/principle-test-behavior-not-implementation/SKILL.md +0 -22
- package/dist/assets/skills/principle-type-system-discipline/SKILL.md +0 -15
- package/dist/assets/skills/recall/SKILL.md +0 -37
- package/dist/assets/skills/reflect/SKILL.md +0 -70
- package/dist/assets/skills/reflect/references/divergent-reviewer.md +0 -38
- package/dist/assets/skills/reflect/references/judgment-reviewer.md +0 -37
- package/dist/assets/skills/reflect/references/synthesizer.md +0 -56
- package/dist/assets/skills/reflect/references/tooling-reviewer.md +0 -48
- package/dist/assets/skills/setup-pstack/SKILL.md +0 -76
- package/dist/assets/skills/sharpen/SKILL.md +0 -18
- package/dist/assets/skills/show-me-your-work/SKILL.md +0 -84
- package/dist/assets/skills/show-me-your-work/references/decision-log-template.tsv +0 -1
- package/dist/assets/skills/show-me-your-work/scripts/log.sh +0 -42
- package/dist/assets/skills/swarm/SKILL.md +0 -41
- package/dist/assets/skills/tdd/SKILL.md +0 -44
- package/dist/assets/skills/teach/SKILL.md +0 -23
- package/dist/assets/skills/technical-writing/SKILL.md +0 -108
- package/dist/assets/skills/typescript-best-practices/SKILL.md +0 -32
- package/dist/assets/skills/typescript-best-practices/references/patterns.md +0 -328
- package/dist/assets/skills/unslop/SKILL.md +0 -64
- package/dist/assets/skills/why/SKILL.md +0 -100
- package/dist/assets/skills/why/references/epistemics.md +0 -71
- package/dist/assets/skills/why/references/investigator-prompt.md +0 -84
- package/dist/assets/skills/why/references/source-playbook.md +0 -17
- package/dist/assets/skills/why/references/sources/code-archaeology.md +0 -51
- package/dist/assets/skills/why/references/sources/databricks.md +0 -70
- package/dist/assets/skills/why/references/sources/datadog.md +0 -97
- package/dist/assets/skills/why/references/sources/incident-postmortem.md +0 -5
- package/dist/assets/skills/why/references/sources/linear.md +0 -48
- package/dist/assets/skills/why/references/sources/notion.md +0 -55
- package/dist/assets/skills/why/references/sources/sentry.md +0 -66
- package/dist/assets/skills/why/references/sources/slack.md +0 -17
- package/dist/assets/skills/why/references/synthesizer-prompt.md +0 -129
- package/dist/cordis.patch.yml +0 -20
- package/dist/paths-Bbai4CaT.mjs +0 -16
- package/dist/paths-Bbai4CaT.mjs.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import process from "node:process";
|
|
4
|
-
|
|
5
|
-
const RULE =
|
|
6
|
-
"Tests alone are not sufficient verification. A PR is verified only when its unit, live, and perf boxes are all checked.";
|
|
4
|
+
//#region .runtime-sources/skills/poteto-mode/scripts/check-plan.mjs
|
|
5
|
+
const RULE = "Tests alone are not sufficient verification. A PR is verified only when its unit, live, and perf boxes are all checked.";
|
|
7
6
|
const LANES = /Ten lanes on `[^`<>]+` at the PR head/;
|
|
8
7
|
const SUB_BLOCKS = [
|
|
9
8
|
"Depends on.",
|
|
@@ -14,49 +13,57 @@ const SUB_BLOCKS = [
|
|
|
14
13
|
"Verify, live.",
|
|
15
14
|
"Verify, perf.",
|
|
16
15
|
"Review gate.",
|
|
17
|
-
"Merge."
|
|
16
|
+
"Merge."
|
|
17
|
+
];
|
|
18
|
+
const PROGRAM_H3 = [
|
|
19
|
+
"Arm the program",
|
|
20
|
+
"Spawn owners",
|
|
21
|
+
"PR mechanics",
|
|
22
|
+
"Verdict and merge",
|
|
23
|
+
"Boot recipe"
|
|
24
|
+
];
|
|
25
|
+
const PROGRAM_MARKERS = [
|
|
26
|
+
"create_goal",
|
|
27
|
+
"schedule_create",
|
|
28
|
+
"status message"
|
|
18
29
|
];
|
|
19
|
-
const PROGRAM_H3 = ["Arm the program", "Spawn owners", "PR mechanics", "Verdict and merge", "Boot recipe"];
|
|
20
|
-
const PROGRAM_MARKERS = ["git show origin/main:", "schedule_create 1h", "status message"];
|
|
21
30
|
const HOW_TO_READ_MARKERS = [
|
|
22
31
|
"One box is one unit of work",
|
|
23
32
|
"names the evidence",
|
|
24
33
|
"Check a box only when its evidence exists",
|
|
25
34
|
"playbooks/",
|
|
26
|
-
RULE
|
|
35
|
+
RULE
|
|
36
|
+
];
|
|
37
|
+
const PERF_ITEMS = [
|
|
38
|
+
"Metric.",
|
|
39
|
+
"Probe.",
|
|
40
|
+
"Baseline.",
|
|
41
|
+
"Rule."
|
|
27
42
|
];
|
|
28
|
-
const PERF_ITEMS = ["Metric.", "Probe.", "Baseline.", "Rule."];
|
|
29
43
|
const BOX = /^\s*- \[[ x]\] (.*)$/;
|
|
30
|
-
|
|
31
44
|
const file = process.argv[2];
|
|
32
45
|
if (!file) {
|
|
33
46
|
console.error("Usage: node check-plan.mjs <plan.md>");
|
|
34
47
|
process.exit(2);
|
|
35
48
|
}
|
|
36
|
-
|
|
37
49
|
const raw = fs.readFileSync(file, "utf8").split(/\r?\n/);
|
|
38
50
|
const problems = [];
|
|
39
51
|
const fail = (line, message) => problems.push(`${file}:${line}: ${message}`);
|
|
40
|
-
|
|
41
52
|
let start = 0;
|
|
42
|
-
if (raw[0] === "---")
|
|
43
|
-
start = raw.indexOf("---", 1) + 1;
|
|
44
|
-
}
|
|
45
|
-
|
|
53
|
+
if (raw[0] === "---") start = raw.indexOf("---", 1) + 1;
|
|
46
54
|
const lines = [];
|
|
47
55
|
let fence = null;
|
|
48
56
|
const openingFence = (text) => {
|
|
49
57
|
const match = text.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
|
|
50
|
-
if (!match ||
|
|
51
|
-
return {
|
|
58
|
+
if (!match || match[1][0] === "`" && match[2].includes("`")) return null;
|
|
59
|
+
return {
|
|
60
|
+
char: match[1][0],
|
|
61
|
+
length: match[1].length
|
|
62
|
+
};
|
|
52
63
|
};
|
|
53
64
|
const closingFence = (text, opening) => {
|
|
54
65
|
const match = text.match(/^ {0,3}(`+|~+)[ \t]*$/);
|
|
55
|
-
return Boolean(
|
|
56
|
-
match &&
|
|
57
|
-
match[1][0] === opening.char &&
|
|
58
|
-
match[1].length >= opening.length,
|
|
59
|
-
);
|
|
66
|
+
return Boolean(match && match[1][0] === opening.char && match[1].length >= opening.length);
|
|
60
67
|
};
|
|
61
68
|
for (let i = start; i < raw.length; i++) {
|
|
62
69
|
const text = raw[i];
|
|
@@ -69,42 +76,45 @@ for (let i = start; i < raw.length; i++) {
|
|
|
69
76
|
fence = openingFence(text);
|
|
70
77
|
code = Boolean(fence);
|
|
71
78
|
}
|
|
72
|
-
lines.push({
|
|
79
|
+
lines.push({
|
|
80
|
+
n,
|
|
81
|
+
text,
|
|
82
|
+
code
|
|
83
|
+
});
|
|
73
84
|
if (code) continue;
|
|
74
|
-
const prose = text
|
|
75
|
-
.replace(/`[^`]*`/g, "`")
|
|
76
|
-
.replace(/!\[[^\]]*\]\([^)]*\)/g, "")
|
|
77
|
-
.replace(/\]\([^)]*\)/g, "]");
|
|
85
|
+
const prose = text.replace(/`[^`]*`/g, "`").replace(/!\[[^\]]*\]\([^)]*\)/g, "").replace(/\]\([^)]*\)/g, "]");
|
|
78
86
|
if (/[\u2013\u2014]/.test(prose)) fail(n, "long dash");
|
|
79
87
|
if (/[\u2018\u2019\u201c\u201d]/.test(prose)) fail(n, "curly quote");
|
|
80
88
|
if (/: \S/.test(prose)) fail(n, "mid-sentence colon");
|
|
81
89
|
}
|
|
82
|
-
|
|
83
|
-
const h2 = (l) => (!l.code && l.text.startsWith("## ") ? l.text.slice(3).trim() : null);
|
|
90
|
+
const h2 = (l) => !l.code && l.text.startsWith("## ") ? l.text.slice(3).trim() : null;
|
|
84
91
|
const sections = [];
|
|
85
92
|
for (const l of lines) {
|
|
86
93
|
const title = h2(l);
|
|
87
|
-
if (title !== null) sections.push({
|
|
94
|
+
if (title !== null) sections.push({
|
|
95
|
+
title,
|
|
96
|
+
n: l.n,
|
|
97
|
+
body: []
|
|
98
|
+
});
|
|
88
99
|
else if (sections.length) sections.at(-1).body.push(l);
|
|
89
100
|
}
|
|
90
101
|
const find = (title) => sections.find((s) => s.title === title);
|
|
91
102
|
const bodyText = (s) => s.body.map((l) => l.text).join("\n");
|
|
92
|
-
const boxes = (ls) => ls.filter((l) => !l.code && BOX.test(l.text)).map((l) => ({
|
|
93
|
-
|
|
103
|
+
const boxes = (ls) => ls.filter((l) => !l.code && BOX.test(l.text)).map((l) => ({
|
|
104
|
+
n: l.n,
|
|
105
|
+
text: l.text.match(BOX)[1]
|
|
106
|
+
}));
|
|
94
107
|
const h1 = lines.findIndex((l) => !l.code && l.text.startsWith("# "));
|
|
95
108
|
if (h1 === -1) fail(1, "no H1 title");
|
|
96
109
|
const howToRead = find("How to read this");
|
|
97
|
-
if (!howToRead) fail(1,
|
|
110
|
+
if (!howToRead) fail(1, "no \"## How to read this\" section");
|
|
98
111
|
if (h1 !== -1 && howToRead) {
|
|
99
112
|
const intro = lines.slice(h1 + 1).filter((l) => l.n < howToRead.n && l.text.trim() !== "");
|
|
100
113
|
if (intro.length >= 10) fail(lines[h1].n, `intro is ${intro.length} lines, under ten required`);
|
|
101
|
-
for (const marker of HOW_TO_READ_MARKERS) {
|
|
102
|
-
if (!bodyText(howToRead).includes(marker)) fail(howToRead.n, `How to read this lacks "${marker}"`);
|
|
103
|
-
}
|
|
114
|
+
for (const marker of HOW_TO_READ_MARKERS) if (!bodyText(howToRead).includes(marker)) fail(howToRead.n, `How to read this lacks "${marker}"`);
|
|
104
115
|
}
|
|
105
|
-
|
|
106
116
|
const program = find("Program checklist");
|
|
107
|
-
if (!program) fail(1,
|
|
117
|
+
if (!program) fail(1, "no \"## Program checklist\" section");
|
|
108
118
|
else {
|
|
109
119
|
const h3s = program.body.filter((l) => !l.code && l.text.startsWith("### ")).map((l) => l.text.slice(4).trim());
|
|
110
120
|
let cursor = 0;
|
|
@@ -113,65 +123,71 @@ else {
|
|
|
113
123
|
if (at === -1) fail(program.n, `Program checklist lacks "### ${name}" in order`);
|
|
114
124
|
else cursor = at + 1;
|
|
115
125
|
}
|
|
116
|
-
for (const marker of PROGRAM_MARKERS) {
|
|
117
|
-
if (!bodyText(program).includes(marker)) fail(program.n, `Program checklist lacks "${marker}"`);
|
|
118
|
-
}
|
|
126
|
+
for (const marker of PROGRAM_MARKERS) if (!bodyText(program).includes(marker)) fail(program.n, `Program checklist lacks "${marker}"`);
|
|
119
127
|
}
|
|
120
|
-
|
|
121
128
|
const close = find("Close the program");
|
|
122
|
-
if (!close) fail(1,
|
|
129
|
+
if (!close) fail(1, "no \"## Close the program\" section");
|
|
123
130
|
const programIndex = sections.indexOf(program);
|
|
124
131
|
const closeIndex = sections.indexOf(close);
|
|
125
132
|
const prSections = programIndex === -1 || closeIndex === -1 ? [] : sections.slice(programIndex + 1, closeIndex);
|
|
126
133
|
if (prSections.length === 0) fail(1, "no PR sections between Program checklist and Close the program");
|
|
127
|
-
|
|
128
134
|
const report = [];
|
|
129
135
|
for (const pr of prSections) {
|
|
130
136
|
const heads = [];
|
|
131
137
|
for (const l of pr.body) {
|
|
132
138
|
if (l.code) continue;
|
|
133
139
|
const m = l.text.match(/^\*\*([^*]+)\*\*(.*)$/);
|
|
134
|
-
if (m && SUB_BLOCKS.includes(m[1])) heads.push({
|
|
140
|
+
if (m && SUB_BLOCKS.includes(m[1])) heads.push({
|
|
141
|
+
name: m[1],
|
|
142
|
+
n: l.n,
|
|
143
|
+
rest: m[2].trim(),
|
|
144
|
+
lines: []
|
|
145
|
+
});
|
|
135
146
|
else if (heads.length) heads.at(-1).lines.push(l);
|
|
136
147
|
}
|
|
137
148
|
const names = heads.map((h) => h.name);
|
|
138
|
-
if (names.join("|") !== SUB_BLOCKS.join("|")) {
|
|
139
|
-
fail(pr.n, `${pr.title}: sub-blocks are [${names.join(", ")}], expected [${SUB_BLOCKS.join(", ")}]`);
|
|
140
|
-
}
|
|
149
|
+
if (names.join("|") !== SUB_BLOCKS.join("|")) fail(pr.n, `${pr.title}: sub-blocks are [${names.join(", ")}], expected [${SUB_BLOCKS.join(", ")}]`);
|
|
141
150
|
const block = (name) => heads.find((h) => h.name === name);
|
|
142
151
|
const counts = {};
|
|
143
152
|
for (const h of heads) counts[h.name] = boxes(h.lines).length;
|
|
144
|
-
|
|
145
153
|
const depends = block("Depends on.");
|
|
146
154
|
if (depends && depends.rest === "") fail(depends.n, `${pr.title}: Depends on names nothing`);
|
|
147
|
-
for (const name of [
|
|
155
|
+
for (const name of [
|
|
156
|
+
"Files.",
|
|
157
|
+
"Build.",
|
|
158
|
+
"You see.",
|
|
159
|
+
"Verify, unit.",
|
|
160
|
+
"Merge."
|
|
161
|
+
]) {
|
|
148
162
|
const b = block(name);
|
|
149
163
|
if (b && boxes(b.lines).length === 0) fail(b.n, `${pr.title}: ${name} has no box`);
|
|
150
164
|
}
|
|
151
|
-
for (const name of [
|
|
165
|
+
for (const name of [
|
|
166
|
+
"Verify, unit.",
|
|
167
|
+
"Verify, live.",
|
|
168
|
+
"Verify, perf."
|
|
169
|
+
]) {
|
|
152
170
|
const b = block(name);
|
|
153
171
|
if (b && !b.rest.startsWith(RULE)) fail(b.n, `${pr.title}: ${name} does not open with the rule`);
|
|
154
172
|
}
|
|
155
|
-
|
|
156
173
|
const live = block("Verify, live.");
|
|
157
174
|
if (live) {
|
|
158
175
|
if (!LANES.test(live.rest)) fail(live.n, `${pr.title}: Verify, live lacks "Ten lanes on \`<swarm workers model>\` at the PR head" with the model filled in`);
|
|
159
|
-
const lanes = boxes(live.lines).map((b) => ({
|
|
176
|
+
const lanes = boxes(live.lines).map((b) => ({
|
|
177
|
+
...b,
|
|
178
|
+
m: b.text.match(/^Lane (\d+)\. /)
|
|
179
|
+
}));
|
|
160
180
|
const numbers = lanes.filter((b) => b.m).map((b) => Number(b.m[1])).sort((a, b) => a - b);
|
|
161
181
|
if (numbers.join(",") !== "1,2,3,4,5,6,7,8,9,10") fail(live.n, `${pr.title}: lanes are [${numbers.join(",")}], expected 1 to 10`);
|
|
162
|
-
for (const lane of lanes) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
else if (!lane.text.includes("Pass when")) fail(lane.n, `${pr.title}: lane ${lane.m[1]} has no pass predicate`);
|
|
166
|
-
}
|
|
182
|
+
for (const lane of lanes) if (!lane.m) fail(lane.n, `${pr.title}: live box is not a lane`);
|
|
183
|
+
else if (!/Save `[^`]+`/.test(lane.text)) fail(lane.n, `${pr.title}: lane ${lane.m[1]} names no screenshot`);
|
|
184
|
+
else if (!lane.text.includes("Pass when")) fail(lane.n, `${pr.title}: lane ${lane.m[1]} has no pass predicate`);
|
|
167
185
|
}
|
|
168
|
-
|
|
169
186
|
const perf = block("Verify, perf.");
|
|
170
187
|
if (perf) {
|
|
171
188
|
const items = boxes(perf.lines).map((b) => b.text.split(" ")[0]);
|
|
172
189
|
if (items.join("|") !== PERF_ITEMS.join("|")) fail(perf.n, `${pr.title}: perf boxes are [${items.join(", ")}], expected [${PERF_ITEMS.join(", ")}]`);
|
|
173
190
|
}
|
|
174
|
-
|
|
175
191
|
const gate = block("Review gate.");
|
|
176
192
|
if (gate) {
|
|
177
193
|
const gateBoxes = boxes(gate.lines);
|
|
@@ -180,26 +196,25 @@ for (const pr of prSections) {
|
|
|
180
196
|
} else {
|
|
181
197
|
const text = gate.lines.map((l) => l.text).join("\n");
|
|
182
198
|
if (gateBoxes.length === 0) fail(gate.n, `${pr.title}: Review gate has no box`);
|
|
183
|
-
for (const word of [
|
|
184
|
-
|
|
185
|
-
|
|
199
|
+
for (const word of [
|
|
200
|
+
"screenshot",
|
|
201
|
+
"video",
|
|
202
|
+
"operator"
|
|
203
|
+
]) if (!text.includes(word)) fail(gate.n, `${pr.title}: Review gate lacks "${word}"`);
|
|
186
204
|
}
|
|
187
205
|
}
|
|
188
|
-
|
|
189
206
|
const total = boxes(pr.body).length;
|
|
190
207
|
const cells = SUB_BLOCKS.filter((s) => s !== "Depends on.").map((s) => `${s.replace(/[ ,.]+/g, "-").replace(/-$/, "").toLowerCase()}=${counts[s] ?? 0}`);
|
|
191
208
|
report.push(`${pr.title} boxes=${total} ${cells.join(" ")}`);
|
|
192
209
|
}
|
|
193
|
-
|
|
194
210
|
if (closeIndex !== -1) {
|
|
195
211
|
const tail = sections.slice(closeIndex + 1);
|
|
196
|
-
for (const s of tail) {
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
if (!tail.some((s) => s.title.includes("Prototype evidence"))) fail(close.n, 'no "## Appendix ... Prototype evidence" section');
|
|
212
|
+
for (const s of tail) if (!s.title.startsWith("Appendix")) fail(s.n, `"## ${s.title}" after Close the program is not an appendix`);
|
|
213
|
+
if (!tail.some((s) => s.title.includes("Prototype evidence"))) fail(close.n, "no \"## Appendix ... Prototype evidence\" section");
|
|
200
214
|
}
|
|
201
|
-
|
|
202
215
|
for (const line of report) console.log(line);
|
|
203
216
|
console.log(`${prSections.length} PR sections, ${problems.length} problems`);
|
|
204
217
|
for (const p of problems) console.error(p);
|
|
205
218
|
process.exit(problems.length ? 1 : 0);
|
|
219
|
+
//#endregion
|
|
220
|
+
export {};
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { test } from "node:test";
|
|
7
|
+
import { inspect } from "node:util";
|
|
8
|
+
//#region .runtime-sources/skills/poteto-mode/scripts/expect.ts
|
|
9
|
+
/**
|
|
10
|
+
* A small `expect` for `node:test`.
|
|
11
|
+
*
|
|
12
|
+
* The five upstream test files were written against `bun:test`. Their assertions
|
|
13
|
+
* are ordinary value comparisons, so this module supplies exactly the matchers
|
|
14
|
+
* they use rather than a general test framework. It is deliberately not a drop-in
|
|
15
|
+
* replacement: a matcher that is not listed here fails to compile, which keeps the
|
|
16
|
+
* port auditable against the calls that actually exist.
|
|
17
|
+
*
|
|
18
|
+
* Covered: `toBe`, `toEqual`, `toContain`, `toMatch`, `toThrow`, `toBeNull`,
|
|
19
|
+
* `toBeInstanceOf`, `toHaveLength`, `toEndWith`, `toMatchObject`, `.not` on each,
|
|
20
|
+
* and `rejects` / `resolves` for promises.
|
|
21
|
+
*
|
|
22
|
+
* Two differences from `bun:test`, stated so a failure is not misread:
|
|
23
|
+
*
|
|
24
|
+
* - `toEqual` is structural for arrays and plain objects, `Object.is` otherwise.
|
|
25
|
+
* A class instance only equals itself; `toBeInstanceOf` is the matcher for type
|
|
26
|
+
* identity. The ported tests compare plain data, which is why this is enough.
|
|
27
|
+
* - A failure throws `AssertionError` with the two values rendered, not Bun's
|
|
28
|
+
* coloured diff.
|
|
29
|
+
*/
|
|
30
|
+
/** Raised by every failing assertion. */
|
|
31
|
+
var AssertionError = class extends Error {
|
|
32
|
+
constructor(message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = "AssertionError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function display(value) {
|
|
38
|
+
if (typeof value === "function") return `[Function ${value.name || "anonymous"}]`;
|
|
39
|
+
return inspect(value, {
|
|
40
|
+
depth: 3,
|
|
41
|
+
breakLength: 120,
|
|
42
|
+
maxArrayLength: 20
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function messageOf(error) {
|
|
46
|
+
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
47
|
+
return String(error);
|
|
48
|
+
}
|
|
49
|
+
/** Structural equality for the shapes the ported tests compare. */
|
|
50
|
+
function deepEqual(left, right) {
|
|
51
|
+
if (Object.is(left, right)) return true;
|
|
52
|
+
if (left instanceof Date || right instanceof Date) return left instanceof Date && right instanceof Date && left.getTime() === right.getTime();
|
|
53
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
54
|
+
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;
|
|
55
|
+
return left.every((item, index) => deepEqual(item, right[index]));
|
|
56
|
+
}
|
|
57
|
+
if (left === null || right === null || typeof left !== "object" || typeof right !== "object") return false;
|
|
58
|
+
const leftProto = Object.getPrototypeOf(left);
|
|
59
|
+
if (leftProto !== Object.getPrototypeOf(right)) return false;
|
|
60
|
+
if (leftProto !== Object.prototype && leftProto !== null) return false;
|
|
61
|
+
const leftKeys = Object.keys(left);
|
|
62
|
+
const rightKeys = Object.keys(right);
|
|
63
|
+
if (leftKeys.length !== rightKeys.length) return false;
|
|
64
|
+
return leftKeys.every((key) => deepEqual(left[key], right[key]));
|
|
65
|
+
}
|
|
66
|
+
function contains(haystack, needle) {
|
|
67
|
+
if (typeof haystack === "string") return haystack.includes(String(needle));
|
|
68
|
+
if (Array.isArray(haystack)) return haystack.some((item) => deepEqual(item, needle));
|
|
69
|
+
if (haystack instanceof Set) return [...haystack].some((item) => deepEqual(item, needle));
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether `expected` is a partial description of `actual`.
|
|
74
|
+
*
|
|
75
|
+
* `bun:test`'s `toMatchObject` is recursive: every key in `expected` must exist and
|
|
76
|
+
* match, arrays match element by element with the same partial rule, and extra keys
|
|
77
|
+
* in `actual` are allowed. That is what lets an assertion name only the fields it
|
|
78
|
+
* cares about, which several ported cases rely on.
|
|
79
|
+
*/
|
|
80
|
+
function matchesObject(actual, expected) {
|
|
81
|
+
if (Array.isArray(expected)) {
|
|
82
|
+
if (!Array.isArray(actual) || actual.length !== expected.length) return false;
|
|
83
|
+
return expected.every((item, index) => matchesObject(actual[index], item));
|
|
84
|
+
}
|
|
85
|
+
if (expected instanceof Date) return deepEqual(actual, expected);
|
|
86
|
+
if (expected === null || typeof expected !== "object") return deepEqual(actual, expected);
|
|
87
|
+
if (actual === null || typeof actual !== "object") return false;
|
|
88
|
+
return Object.entries(expected).every(([key, value]) => matchesObject(actual[key], value));
|
|
89
|
+
}
|
|
90
|
+
function thrownBy(call) {
|
|
91
|
+
try {
|
|
92
|
+
call();
|
|
93
|
+
return { thrown: false };
|
|
94
|
+
} catch (error) {
|
|
95
|
+
return {
|
|
96
|
+
thrown: true,
|
|
97
|
+
error
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function buildMatchers(actual, negate) {
|
|
102
|
+
/**
|
|
103
|
+
* Fail when `ok` is not what the matcher asked for.
|
|
104
|
+
*
|
|
105
|
+
* `negate` inverts the requirement, so `.not.toContain(x)` passes on a haystack
|
|
106
|
+
* that does not contain `x` and fails when it does.
|
|
107
|
+
*/
|
|
108
|
+
const check = (ok, matcher, expected) => {
|
|
109
|
+
if (ok === !negate) return;
|
|
110
|
+
const relation = negate ? `not to ${matcher}` : matcher;
|
|
111
|
+
throw new AssertionError(`expected ${display(actual)} ${relation} ${display(expected)}`);
|
|
112
|
+
};
|
|
113
|
+
const checkPlain = (ok, matcher) => {
|
|
114
|
+
if (ok === !negate) return;
|
|
115
|
+
throw new AssertionError(`expected ${display(actual)} ${negate ? `not to ${matcher}` : matcher}`);
|
|
116
|
+
};
|
|
117
|
+
const matchers = {
|
|
118
|
+
toBe(expected) {
|
|
119
|
+
check(Object.is(actual, expected), "toBe", expected);
|
|
120
|
+
},
|
|
121
|
+
toEqual(expected) {
|
|
122
|
+
check(deepEqual(actual, expected), "toEqual", expected);
|
|
123
|
+
},
|
|
124
|
+
toContain(expected) {
|
|
125
|
+
check(contains(actual, expected), "toContain", expected);
|
|
126
|
+
},
|
|
127
|
+
toMatch(expected) {
|
|
128
|
+
const text = String(actual);
|
|
129
|
+
check(typeof expected === "string" ? text.includes(expected) : expected.test(text), "toMatch", expected);
|
|
130
|
+
},
|
|
131
|
+
toThrow(expected) {
|
|
132
|
+
if (typeof actual !== "function") throw new AssertionError(`toThrow needs a function, received ${display(actual)}`);
|
|
133
|
+
const result = thrownBy(actual);
|
|
134
|
+
if (!result.thrown) {
|
|
135
|
+
checkPlain(false, "toThrow");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (expected === void 0) {
|
|
139
|
+
checkPlain(true, "toThrow");
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const message = messageOf(result.error);
|
|
143
|
+
const ok = typeof expected === "string" ? message.includes(expected) : expected instanceof RegExp ? expected.test(message) : result.error instanceof expected;
|
|
144
|
+
check(ok, "toThrow", expected);
|
|
145
|
+
},
|
|
146
|
+
toBeNull() {
|
|
147
|
+
checkPlain(actual === null, "toBeNull");
|
|
148
|
+
},
|
|
149
|
+
toBeInstanceOf(expected) {
|
|
150
|
+
check(actual instanceof expected, "toBeInstanceOf", expected);
|
|
151
|
+
},
|
|
152
|
+
toHaveLength(expected) {
|
|
153
|
+
const length = actual?.length;
|
|
154
|
+
check(length === expected, "toHaveLength", expected);
|
|
155
|
+
},
|
|
156
|
+
toEndWith(expected) {
|
|
157
|
+
check(String(actual).endsWith(expected), "toEndWith", expected);
|
|
158
|
+
},
|
|
159
|
+
toMatchObject(expected) {
|
|
160
|
+
check(matchesObject(actual, expected), "toMatchObject", expected);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
Object.defineProperties(matchers, {
|
|
164
|
+
not: {
|
|
165
|
+
get: () => buildMatchers(actual, !negate),
|
|
166
|
+
enumerable: true
|
|
167
|
+
},
|
|
168
|
+
rejects: {
|
|
169
|
+
get: () => buildAsyncMatchers(actual, "rejects", negate),
|
|
170
|
+
enumerable: true
|
|
171
|
+
},
|
|
172
|
+
resolves: {
|
|
173
|
+
get: () => buildAsyncMatchers(actual, "resolves", negate),
|
|
174
|
+
enumerable: true
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return matchers;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Compare against a settled promise.
|
|
181
|
+
*
|
|
182
|
+
* `rejects` reads the rejection reason and fails when the promise resolved;
|
|
183
|
+
* `resolves` is the mirror. Each matcher awaits the settlement, which is what
|
|
184
|
+
* makes `await expect(promise).rejects.toThrow(...)` wait before it compares.
|
|
185
|
+
*/
|
|
186
|
+
function buildAsyncMatchers(actual, mode, negate) {
|
|
187
|
+
if (typeof actual?.then !== "function") throw new AssertionError(`expected a promise, received ${display(actual)}`);
|
|
188
|
+
const wantRejection = mode === "rejects" !== negate;
|
|
189
|
+
const settle = async () => {
|
|
190
|
+
let resolved;
|
|
191
|
+
let rejected;
|
|
192
|
+
await Promise.resolve(actual).then((value) => {
|
|
193
|
+
resolved = { value };
|
|
194
|
+
}, (error) => {
|
|
195
|
+
rejected = { error };
|
|
196
|
+
});
|
|
197
|
+
if (wantRejection) {
|
|
198
|
+
if (resolved !== void 0) throw new AssertionError(`expected the promise to reject, it resolved to ${display(resolved.value)}`);
|
|
199
|
+
return rejected?.error;
|
|
200
|
+
}
|
|
201
|
+
if (rejected !== void 0) throw new AssertionError(`expected the promise to resolve, it rejected with ${messageOf(rejected.error)}`);
|
|
202
|
+
return resolved?.value;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Run one matcher against the settled value.
|
|
206
|
+
*
|
|
207
|
+
* `toThrow` and `toBeInstanceOf` both read the rejection reason, so a thrown
|
|
208
|
+
* reason is turned back into a thunk for `toThrow` rather than special-cased
|
|
209
|
+
* twice. `negate` is already folded into the settlement mode, so the inner
|
|
210
|
+
* matchers run un-negated.
|
|
211
|
+
*/
|
|
212
|
+
const wrap = async (name, expected) => {
|
|
213
|
+
const subject = await settle();
|
|
214
|
+
if (name === "toThrow") {
|
|
215
|
+
buildMatchers(() => {
|
|
216
|
+
throw subject;
|
|
217
|
+
}, false).toThrow(expected);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (name === "toBeNull") {
|
|
221
|
+
buildMatchers(subject, false).toBeNull();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const matchers = buildMatchers(subject, false);
|
|
225
|
+
const matcher = matchers[name];
|
|
226
|
+
if (typeof matcher !== "function") throw new AssertionError(`unknown matcher ${name}`);
|
|
227
|
+
matcher.call(matchers, expected);
|
|
228
|
+
};
|
|
229
|
+
const matchers = {
|
|
230
|
+
toBe: (expected) => wrap("toBe", expected),
|
|
231
|
+
toEqual: (expected) => wrap("toEqual", expected),
|
|
232
|
+
toContain: (expected) => wrap("toContain", expected),
|
|
233
|
+
toMatch: (expected) => wrap("toMatch", expected),
|
|
234
|
+
toThrow: (expected) => wrap("toThrow", expected),
|
|
235
|
+
toBeNull: () => wrap("toBeNull"),
|
|
236
|
+
toBeInstanceOf: (expected) => wrap("toBeInstanceOf", expected),
|
|
237
|
+
toHaveLength: (expected) => wrap("toHaveLength", expected),
|
|
238
|
+
toEndWith: (expected) => wrap("toEndWith", expected),
|
|
239
|
+
toMatchObject: (expected) => wrap("toMatchObject", expected)
|
|
240
|
+
};
|
|
241
|
+
Object.defineProperty(matchers, "not", {
|
|
242
|
+
get: () => buildAsyncMatchers(actual, mode, !negate),
|
|
243
|
+
enumerable: true
|
|
244
|
+
});
|
|
245
|
+
return matchers;
|
|
246
|
+
}
|
|
247
|
+
const expect = Object.assign((actual) => buildMatchers(actual, false), {
|
|
248
|
+
not: (actual) => buildMatchers(actual, true),
|
|
249
|
+
rejects: (actual) => buildAsyncMatchers(actual, "rejects", false),
|
|
250
|
+
resolves: (actual) => buildAsyncMatchers(actual, "resolves", false)
|
|
251
|
+
});
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region .runtime-sources/skills/poteto-mode/scripts/check-plan.test.ts
|
|
254
|
+
const checker = join(import.meta.dirname, "check-plan.mjs");
|
|
255
|
+
const rule = "Tests alone are not sufficient verification. A PR is verified only when its unit, live, and perf boxes are all checked.";
|
|
256
|
+
const validPlan = `# Demo
|
|
257
|
+
|
|
258
|
+
## How to read this
|
|
259
|
+
One box is one unit of work and names the evidence. Check a box only when its evidence exists. See playbooks/.
|
|
260
|
+
${rule}
|
|
261
|
+
|
|
262
|
+
## Program checklist
|
|
263
|
+
### Arm the program
|
|
264
|
+
### Spawn owners
|
|
265
|
+
### PR mechanics
|
|
266
|
+
### Verdict and merge
|
|
267
|
+
### Boot recipe
|
|
268
|
+
\`create_goal\` \`schedule_create\` status message
|
|
269
|
+
|
|
270
|
+
## PR 1
|
|
271
|
+
**Depends on.** None.
|
|
272
|
+
**Files.**
|
|
273
|
+
- [ ] Do the thing.
|
|
274
|
+
**Build.**
|
|
275
|
+
- [ ] Do the thing.
|
|
276
|
+
**You see.**
|
|
277
|
+
- [ ] Do the thing.
|
|
278
|
+
**Verify, unit.** ${rule}
|
|
279
|
+
- [ ] Check the thing.
|
|
280
|
+
**Verify, live.** ${rule} Ten lanes on \`example-model\` at the PR head
|
|
281
|
+
${Array.from({ length: 10 }, (_, i) => `- [ ] Lane ${i + 1}. Save \`lane-${i + 1}.png\`. Pass when evidence exists.`).join("\n")}
|
|
282
|
+
**Verify, perf.** ${rule}
|
|
283
|
+
- [ ] Metric. Recorded.
|
|
284
|
+
- [ ] Probe. Recorded.
|
|
285
|
+
- [ ] Baseline. Recorded.
|
|
286
|
+
- [ ] Rule. Recorded.
|
|
287
|
+
**Review gate.** None.
|
|
288
|
+
**Merge.**
|
|
289
|
+
- [ ] Merge when approved.
|
|
290
|
+
|
|
291
|
+
## Close the program
|
|
292
|
+
Close.
|
|
293
|
+
|
|
294
|
+
## Appendix Prototype evidence
|
|
295
|
+
Recorded.
|
|
296
|
+
`;
|
|
297
|
+
const runPlan = (example, expectedExit) => {
|
|
298
|
+
const directory = mkdtempSync(join(tmpdir(), "check-plan-test-"));
|
|
299
|
+
const file = join(directory, "plan.md");
|
|
300
|
+
writeFileSync(file, validPlan + example);
|
|
301
|
+
try {
|
|
302
|
+
const result = spawnSync("node", [checker, file], { encoding: "utf8" });
|
|
303
|
+
expect(result.status).toBe(expectedExit);
|
|
304
|
+
return result;
|
|
305
|
+
} finally {
|
|
306
|
+
rmSync(directory, {
|
|
307
|
+
recursive: true,
|
|
308
|
+
force: true
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
test("accepts ordinary, indented, and longer closing fences", () => {
|
|
313
|
+
for (const indent of [
|
|
314
|
+
"",
|
|
315
|
+
" ",
|
|
316
|
+
" ",
|
|
317
|
+
" "
|
|
318
|
+
]) runPlan(`${indent}\`\`\`markdown\n## Example only\n${indent}\`\`\`\n`, 0);
|
|
319
|
+
runPlan("```markdown\n## Example only\n````\n", 0);
|
|
320
|
+
});
|
|
321
|
+
test("accepts nested backticks and tilde info strings", () => {
|
|
322
|
+
runPlan("````markdown\n```markdown\n## Example only\n```\n````\n", 0);
|
|
323
|
+
runPlan("~~~markdown `info`\n## Example only\n ~~~\n", 0);
|
|
324
|
+
});
|
|
325
|
+
test("keeps mismatched, shorter, and suffixed closers inside the fence", () => {
|
|
326
|
+
runPlan("````markdown\n~~~\n## Example only\n````\n", 0);
|
|
327
|
+
runPlan("````markdown\n```\n## Example only\n````\n", 0);
|
|
328
|
+
runPlan("````markdown\n``` info\n## Example only\n````\n", 0);
|
|
329
|
+
});
|
|
330
|
+
test("rejects headings and prose outside a proper close", () => {
|
|
331
|
+
for (const suffix of [" ", " "]) {
|
|
332
|
+
const heading = runPlan(`\`\`\`markdown\n## Example only\n\`\`\`${suffix}\n## Example only\n`, 1);
|
|
333
|
+
expect(heading.stderr).toContain("\"## Example only\" after Close the program is not an appendix");
|
|
334
|
+
}
|
|
335
|
+
const prose = runPlan("```markdown\nThis prose has a mid-sentence colon: inside code\n```\nThis prose has a mid-sentence colon: bad.\n", 1);
|
|
336
|
+
expect(prose.stderr).toContain("mid-sentence colon");
|
|
337
|
+
});
|
|
338
|
+
test("rejects backtick info strings containing a backtick", () => {
|
|
339
|
+
const result = runPlan("```markdown `invalid`\n## Example only\n```\n", 1);
|
|
340
|
+
expect(result.stderr).toContain("\"## Example only\" after Close the program is not an appendix");
|
|
341
|
+
});
|
|
342
|
+
//#endregion
|
|
343
|
+
export {};
|