Files
callstack__agent-device/scripts/__tests__/agent-setup-startup-contract.test.ts
Michał Pierzchała b0d4b40467 chore: stop publishing skills to npm (#1730)
* chore: stop publishing skills to npm

* fix: align simulator skill startup

* docs: align agent setup with open-first workflow
2026-08-11 11:46:33 +02:00

49 lines
1.7 KiB
TypeScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { test } from 'vitest';
const ROOT = join(import.meta.dirname, '..', '..');
const AGENT_SETUP = join(ROOT, 'website', 'docs', 'docs', 'agent-setup.md');
const OPEN_FIRST = 'For a normal app-driving task, start immediately.';
const MANDATORY_STARTUP_PROBES = [
{
pattern: /Before planning commands, run `agent-device --version`/,
example: 'Before planning commands, run `agent-device --version`',
},
{
pattern: /Before planning device work, run `agent-device --version`/,
example: 'Before planning device work, run `agent-device --version`',
},
{
pattern: /run `agent-device help workflow` before planning/,
example: 'run `agent-device help workflow` before planning',
},
] as const;
function assertOpenFirstSetup(content: string): void {
const openFirstRules = content.split(OPEN_FIRST).length - 1;
assert.equal(openFirstRules, 3, 'recommended, Cursor, and Claude rules must start with open');
for (const probe of MANDATORY_STARTUP_PROBES) {
assert.doesNotMatch(
content,
probe.pattern,
`agent setup contains mandatory startup probe: ${probe.pattern}`,
);
}
}
test('agent setup rules start normal work with open and avoid mandatory probes', async () => {
assertOpenFirstSetup(await readFile(AGENT_SETUP, 'utf8'));
});
for (const probe of MANDATORY_STARTUP_PROBES) {
test(`agent setup contract rejects ${probe.pattern}`, async () => {
const content = await readFile(AGENT_SETUP, 'utf8');
assert.throws(
() => assertOpenFirstSetup(`${content}\n${probe.example}\n`),
/agent setup contains mandatory startup probe/,
);
});
}