Repository navigation
chore(agents): run the agent tooling tests apart from the package tests - #142
Conversation
Publishing runs npm test through prepublishOnly, and npm test also ran the agent tooling's tests in .agents/scripts. A slow agent-tooling test timing out there broke outline-cli's 3.2.0 publish, and the same setup is here. npm test now covers only the package's tests. The tooling's tests run with npm run test:agents (vitest.agents.config.ts), which CI runs on every pull request and verify runs when something those tests read changed since main.
doistbot
left a comment
There was a problem hiding this comment.
This PR cleanly splits the agent tooling's tests out of npm test into their own test:agents config, with a conditional tests:agents step in verify and a new CI workflow running both suites on every PR.
Few things worth tightening:
-
Verify skip gaps: deleting or renaming documentation that AGENTS.md links to (e.g.
docs/icon.md) matches none of theonlyWhenChangedprefixes, so the instructions test gets skipped locally despite the broken link. Relatedly,.cursor/is missing from the list even though agent tests read it (e.g.hook-wiring.test.tsasserts.cursor/hooks.jsonis absent) — and since the directory doesn't exist yet, the new existence test would need to tolerate that. -
Shared source of truth: the helper-source entries in the
onlyWhenChangedlist duplicate what.agents/scripts/instructions.test.tsbuilds internally; exporting them (e.g. fromtree.tsnext toAGENT_DOCS) would keep the two from drifting, since the existence test can't catch a missing path it doesn't know about. -
Merge-to-main coverage: the new workflow only triggers on
pull_request, andrelease.yml'sprepublishOnly→npm testno longer runs the agent tests, so neither suite runs on merges tomain. Adding apush: branches: [main]trigger would satisfy the standard without gating the release. -
Publish-time artifact guard: dropping the agent test glob also drops
package-contents.test.tsfrom the publish path, so nothing fails at the moment the tarball ships if.agents/,.claude/,.codex/or.pi/end up in it. Runningnpm pack --dry-runinprepublishOnly(or keeping just that test) would preserve the guard without the slow tooling tests.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (4)
vitest.agents.config.ts:7: This config doesn't set
globals: true, but.agents/scripts/tsconfig.jsonstill listsvitest/globalsintypes. Previously the tooling tests ran undervitest.config.ts, which does enable globals, so the two agreed. Now a new test under.agents/scripts/written with globaldescribe/it/expect(as allowed by its tsconfig, sonpm run type-checkpasses) fails at runtime withReferenceError: describe is not definedundernpm run test:agents. Addglobals: trueto match the tsconfig, or dropvitest/globalsfrom the tooling tsconfig if explicit imports are the convention.package.json:22:
CONTRIBUTING.mdstill listsnpm testas "Runs all tests" and has notest:agentsentry, which this change makes wrong. Update its command list along with AGENTS.md, CODEBASE.md and docs/agents.md..agents/scripts/lib/verify.ts:106: With no changes since
main(changesis[]),runVerifyprints "No changes since ; checking the tree anyway" butneeded()returns false for everyonlyWhenChangedstep, sotests:agentsis skipped while verify claims it checked the tree. Reproduce on a cleanmain: every other step runs,tests:agentsprints the skip line, and a fingerprint gets recorded. Treat an empty change list as "run everything" (e.g. passundefinedtoneededwhenchanges.length === 0) and add a case to the newonlyWhenChangeddescribe block alongside 'checks the tree when nothing changed'.package.json:22: Before this change
npm testcovered.agents/scripts/, so lefthook's pre-pushnpm testran the tooling tests; now nothing local runs them on push unless the person also rannpm run verify. Scenario: a human pushes a change under.agents/scripts/and pre-push goes green without those tests, leaving them to CI. Addingnpm run test:agentsnext tonpm testinlefthook.yml's pre-push keeps the hook matching what CI runs.
…ppears hook-wiring.test.ts checks that .cursor/hooks.json stays absent, so adding one is a change the agent tooling tests read.
…n unchanged tree verify now runs a step with onlyWhenChanged when nothing changed since the base, as it runs every other step then, and when a changed file was deleted or renamed, since the agent docs may name it. test.yml also runs on pushes to main and next, so both suites run on every merge without the release depending on them. In verify the agent tooling tests wait for the package tests, so two vitest pools don't slow each other into timeouts. The helper sources instructions.test.ts reads come from one constant in tree.ts, shared with the step. The tooling tsconfig drops vitest/globals, since vitest.agents.config.ts doesn't enable them. The docs say pre-push runs only the package's tests.
Publishing runs
npm testthroughprepublishOnly, andnpm testincluded the agent tooling's tests in.agents/scripts/. outline-cli has the same setup, and its 3.2.0 publish failed when one of those tests (patches.test.ts, which drives real git) timed out on the slower release runner. Those tests check the tooling in.agents/, not the package, so they have no business deciding whether a release ships.npm test(vitest.config.ts) now covers only the package's tests, and is still whatprepublishOnlyand the pre-push hook run. The agent tooling's tests move tonpm run test:agents(vitest.agents.config.ts).test.ymlruns both suites on every pull request, with a newRun agent tooling testsstep, and now also on every push tomainandnext, so a merge is tested without the release depending on it. The tooling tsconfig dropsvitest/globals, since the agent config doesn't enable them.npm run verifygains atests:agentsstep through a newonlyWhenChangedfield on verify steps. It runs when something those tests read changed sincemain, when a file was deleted or renamed (the agent docs may name it), and when nothing changed, since verify then checks the whole tree. Otherwise it prints that it skipped the step and why, and counts it as passed, so steps after it still run. Without amainto compare with, it runs. It starts after the package tests, so two vitest pools don't slow each other into timeouts.The list covers
.agents/, the new config,package.json, the lockfile, the workflows,lefthook.yml,.claude/,.codex/,.pi/,.cursor/(a test forbids a Cursor hooks file), the agent docs and the test-helper sources the instructions test reads, which now come from oneTEST_HELPER_PATHSconstant shared by the test and the step. A steps test fails if any listed path stops existing (.cursor/aside), so a rename can't quietly stop the step running.