Skip to content

chore(agents): run the agent tooling tests apart from the package tests - #142

Merged
scottlovegrove merged 3 commits into
mainfrom
scottl/split-agent-tests
Dec 3, 2026
Merged

scottlovegrove merged 3 commits into
mainfrom
scottl/split-agent-tests

Conversation

@scottlovegrove

@scottlovegrove scottlovegrove commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Publishing runs npm test through prepublishOnly, and npm test included 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 what prepublishOnly and the pre-push hook run. The agent tooling's tests move to npm run test:agents (vitest.agents.config.ts). test.yml runs both suites on every pull request, with a new Run agent tooling tests step, and now also on every push to main and next, so a merge is tested without the release depending on it. The tooling tsconfig drops vitest/globals, since the agent config doesn't enable them.

npm run verify gains a tests:agents step through a new onlyWhenChanged field on verify steps. It runs when something those tests read changed since main, 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 a main to 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 one TEST_HELPER_PATHS constant 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.

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.
@scottlovegrove scottlovegrove self-assigned this Dec 3, 2026

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the onlyWhenChanged prefixes, 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.ts asserts .cursor/hooks.json is 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 onlyWhenChanged list duplicate what .agents/scripts/instructions.test.ts builds internally; exporting them (e.g. from tree.ts next to AGENT_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, and release.yml's prepublishOnly → npm test no longer runs the agent tests, so neither suite runs on merges to main. Adding a push: 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.ts from the publish path, so nothing fails at the moment the tarball ships if .agents/, .claude/, .codex/ or .pi/ end up in it. Running npm pack --dry-run in prepublishOnly (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)
  • P3 vitest.agents.config.ts:7: This config doesn't set globals: true, but .agents/scripts/tsconfig.json still lists vitest/globals in types. Previously the tooling tests ran under vitest.config.ts, which does enable globals, so the two agreed. Now a new test under .agents/scripts/ written with global describe/it/expect (as allowed by its tsconfig, so npm run type-check passes) fails at runtime with ReferenceError: describe is not defined under npm run test:agents. Add globals: true to match the tsconfig, or drop vitest/globals from the tooling tsconfig if explicit imports are the convention.
  • P3 package.json:22: CONTRIBUTING.md still lists npm test as "Runs all tests" and has no test:agents entry, which this change makes wrong. Update its command list along with AGENTS.md, CODEBASE.md and docs/agents.md.
  • P3 .agents/scripts/lib/verify.ts:106: With no changes since main (changes is []), runVerify prints "No changes since ; checking the tree anyway" but needed() returns false for every onlyWhenChanged step, so tests:agents is skipped while verify claims it checked the tree. Reproduce on a clean main: every other step runs, tests:agents prints the skip line, and a fingerprint gets recorded. Treat an empty change list as "run everything" (e.g. pass undefined to needed when changes.length === 0) and add a case to the new onlyWhenChanged describe block alongside 'checks the tree when nothing changed'.
  • P3 package.json:22: Before this change npm test covered .agents/scripts/, so lefthook's pre-push npm test ran the tooling tests; now nothing local runs them on push unless the person also ran npm run verify. Scenario: a human pushes a change under .agents/scripts/ and pre-push goes green without those tests, leaving them to CI. Adding npm run test:agents next to npm test in lefthook.yml's pre-push keeps the hook matching what CI runs.

Share Feedback • Review Logs • Trace

Comment thread .agents/scripts/lib/steps.ts Resolved
Comment thread .agents/scripts/lib/steps.ts Resolved
Comment thread .agents/scripts/lib/steps.ts Resolved
Comment thread .github/workflows/test.yml Resolved
Comment thread vitest.config.ts Resolved
…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.
@scottlovegrove
scottlovegrove merged commit 70bb2e2 into main Dec 3, 2026
5 checks passed
@scottlovegrove
scottlovegrove deleted the scottl/split-agent-tests branch December 3, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants