diff --git a/.changeset/39278-scenarios-skill-evals-cases-from-checkout.md b/.changeset/39278-scenarios-skill-evals-cases-from-checkout.md new file mode 100644 index 00000000000..7147076ff7a --- /dev/null +++ b/.changeset/39278-scenarios-skill-evals-cases-from-checkout.md @@ -0,0 +1,10 @@ +--- +'@objectstack/scenarios': patch +--- + +docs(scenarios): `skill-evals --skills-from VERSION` takes its cases from the checkout + +Clause-②: no +Metadata-protocol: none + +The `@objectstack/skills` package no longer carries each skill's `evals/` directory, so a round over a published version grades that version's bundles against the eval cases (and case files) in the repository checkout's `skills/`. The README's `--skills-from` lines say so, and `round.json` records both trees. A round over the workspace is unchanged. diff --git a/.changeset/39278-skills-package-no-evals.md b/.changeset/39278-skills-package-no-evals.md new file mode 100644 index 00000000000..c3cd3cea9e6 --- /dev/null +++ b/.changeset/39278-skills-package-no-evals.md @@ -0,0 +1,15 @@ +--- +'@objectstack/skills': patch +--- + +fix(skills): the published skills package no longer carries each skill's `evals/` directory + +Clause-②: no +Metadata-protocol: none + +`@objectstack/skills` shipped every skill's `evals/` directory: the cases the maintainers score a skill with, each holding its expected answer and the spellings an answer must not contain. No agent loads them, and the eval runner itself withholds the directory from the skill it grades, so an installed skill held a folder the measured skill never had. From this release `dist/skills/` is the repository's `skills/**` without `skills/SKILL_NAME/evals/**`. + +- **What you see after an upgrade.** Re-running the sync (`npx skills@1.7.2 experimental_sync --agent claude-code --copy -y`) or `os skills` installs skills with no `evals/` directory. Every `SKILL.md`, `references/`, `rules/`, `guides/` and `contracts/` file is unchanged. An `evals/` directory a previous install left in your agent's skills directory is safe to delete. +- **Nothing reads them.** No `SKILL.md` points into `evals/`, and the CLI, the scaffolder and the MCP server read nothing from it. +- **The `next` channel is unchanged.** `npx skills add objectstack-ai/objectstack/skills` copies each skill's directory from the repository's `main`, `evals/` included. +- **The build proves it.** The package's copy step compares `dist/skills/**` to `skills/**` minus those directories, file for file and byte for byte, and refuses a tree that holds a file under a skill's `evals/`; `prepublishOnly` runs the same comparison. diff --git a/content/docs/ai/skills-reference.mdx b/content/docs/ai/skills-reference.mdx index ff1c5cfa8d4..3e0cd07108b 100644 --- a/content/docs/ai/skills-reference.mdx +++ b/content/docs/ai/skills-reference.mdx @@ -262,7 +262,7 @@ skills/objectstack-{domain}/ ├── references/ # generated & optional — present only when the skill maps to Zod sources │ └── _index.md # pointers into @objectstack/spec Zod sources ├── rules/ # optional — detailed implementation rules -└── evals/ # optional — AI comprehension test cases +└── evals/ # optional — the maintainers' eval cases; repository only, not in @objectstack/skills ``` `SKILL.md` is the only required file. The `references/_index.md` index is generated by `packages/spec/scripts/build-skill-references.ts` and points into the published `@objectstack/spec` schemas in `node_modules` — skills never bundle copies of the schemas, so they stay version-aligned automatically. Skills with no mapped Zod sources (such as Formula) ship without a `references/` directory at all. diff --git a/content/docs/ai/skills.mdx b/content/docs/ai/skills.mdx index 73cc4dedb3e..83ac40655e4 100644 --- a/content/docs/ai/skills.mdx +++ b/content/docs/ai/skills.mdx @@ -81,14 +81,14 @@ Traditional AI code assistants generate generic code. They don't understand: ## Skill Architecture -Each skill ships `SKILL.md` plus a generated `references/` index, and richer skills layer optional `rules/` and `evals/` directories on top — up to four distinct parts. Only `SKILL.md` is required: +Each skill ships `SKILL.md` plus a generated `references/` index, and richer skills layer an optional `rules/` directory on top. In the repository a skill also keeps an `evals/` directory, the cases its maintainers score it with; the `@objectstack/skills` package leaves that directory out, so an installed skill holds up to three of these four parts. Only `SKILL.md` is required: | Layer | File | Required | Purpose | | :--- | :--- | :--- | :--- | | **Overview** | `SKILL.md` | Yes | High-level guide with decision trees and quick-start examples | | **References** | `references/_index.md` | Generated | Pointers into the published `@objectstack/spec` Zod sources (present in every skill except Formula) | | **Rules** | `rules/*.md` | Optional | Detailed implementation rules with ✅ correct / ❌ incorrect code examples (today: Data, Platform, Query) | -| **Evaluations** | `evals/*.md` | Optional | Test cases to validate AI assistant understanding (mostly planned — `objectstack-automation` ships the first worked example; other skills' `evals/` directories are still placeholders) | +| **Evaluations** | `evals/` (cases in `*.json`) | Repository only | The cases the maintainers score the skill with: a prompt, the expected answer and the assertions an answer is graded on. Not in the `@objectstack/skills` package | ### SKILL.md — The Entry Point @@ -147,8 +147,8 @@ The same package also carries **`objectui`**, the skill for the `@object-ui/*` R packages rather than for metadata: rendering JSON schemas with `SchemaRenderer`, writing renderer plugins, data-source integration, and testing, i18n and mobile layout in a React host. Its source is [`skills/objectui/`](https://github.com/objectstack-ai/objectstack/tree/main/skills/objectui): -a `SKILL.md` entry point, `rules/` the agent always applies, `guides/` it loads per task, and an -`evals/` prompt per guide that catches regressions in agent behaviour. Its frontmatter defers +a `SKILL.md` entry point, `rules/` the agent always applies, `guides/` it loads per task, and, in +the repository only, an `evals/` file per guide that catches regressions in agent behaviour. Its frontmatter defers data modelling, APIs, automation, formulas and agents to the domain skills above, so the two coexist in one agent. It installs and updates with the rest of `@objectstack/skills`. @@ -249,7 +249,7 @@ Each skill maps directly to an ObjectStack protocol domain. The schema skill tea ### 4. Testable -The `evals/` directory in each skill is reserved for test cases that validate an AI assistant correctly understands the protocol — analogous to test suites for runtime code, but for AI comprehension. Most skills' `evals/` directories are still placeholders; `objectstack-automation` ships the first worked example (`evals/approvals/test-revise-loop.md`). +The `evals/` directory beside each skill in the repository holds test cases that validate an AI assistant correctly understands the protocol — analogous to test suites for runtime code, but for AI comprehension. Like a test suite, it stays in the repository: the `@objectstack/skills` package you install leaves it out, and the maintainers run the cases against each skill with `skill-evals` from a checkout. --- diff --git a/packages/qa/scenarios/README.md b/packages/qa/scenarios/README.md index ffe32e72557..13da6337065 100644 --- a/packages/qa/scenarios/README.md +++ b/packages/qa/scenarios/README.md @@ -1024,7 +1024,7 @@ wrapper, with no change to the runner. ## Running the published skills' eval cases — `skill-evals` -Every published skill bundle carries eval cases (`skills/BUNDLE/evals/*.json`: a `prompt`, an `expected_output` and +Every skill bundle in `skills/` carries eval cases (`skills/BUNDLE/evals/*.json`: a `prompt`, an `expected_output` and `assertions.must_contain` / `must_contain_any` / `must_not_contain`). `skill-evals` sends each case to the local Claude Code login twice, once with the bundle installed and once without, and grades each answer by the case's own tokens. A trigger case asks instead whether the skill was loaded, and runs with the bundle installed beside its competitors only. It runs from this checkout only. It is not part of the published `bin` or `exports`, not a CI job and not a merge gate. The cases are @@ -1037,7 +1037,7 @@ pnpm install && pnpm --filter '@objectstack/scenarios^...' build # the runner pnpm --filter @objectstack/scenarios skill-evals --dry-run # the plan and the argv; no login read, no model call pnpm --filter @objectstack/scenarios skill-evals # every case × 2 arms pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-query --repeats 3 # a touched skill -pnpm --filter @objectstack/scenarios skill-evals --skills-from 18.5.0 # a published @objectstack/skills version's bundles and cases +pnpm --filter @objectstack/scenarios skill-evals --skills-from 18.5.0 # a published @objectstack/skills version's bundles, on this checkout's cases pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-query --triggers-only # its trigger cases alone pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-query,objectstack-ask --triggers-only # both installed in every trigger turn pnpm --filter @objectstack/scenarios skill-evals --case objectstack-ai/skills-tools-knowledge#6 --repeats 10 # one case, both arms @@ -1092,11 +1092,15 @@ pnpm --filter @objectstack/scenarios skill-evals --self-test # the runner's o init line misses an installed bundle is `invalid`. `--trigger-field own` installs the case's bundle alone, as every round recorded before did. `round.json` records `triggerField`, the summary header names it, and `--regrade DIR` keeps it (the flag is refused there). Behaviour cases keep one bundle, so their two arms still differ only in it. +- **`--skills-from VERSION`**: the bundles are the published version's, packed from npm; the cases are always this + checkout's `skills/BUNDLE/evals/`, for the bundles that version holds, because the published package leaves each + skill's `evals/` out. A case's `files` come from the checkout too. `round.json` records both (`skills.source`, + `skills.cases`), and a bundle of this checkout the version does not hold runs no case. - **`--triggers-only`**: the selected bundles' trigger cases alone, on the with-skill arm, for a change that only touches when a skill loads (its `description`). The summary is the trigger section alone, and `round.json` records `scope.triggersOnly`, so `--regrade DIR` keeps that scope. A bundle `--skills` names with no trigger case is - installed as a competitor while another named bundle has one; alone, or under `--trigger-field own`, it is refused - (a published version before trigger cases has none). The flag is refused beside `--regrade` or `--self-test`. + installed as a competitor while another named bundle has one; alone, or under `--trigger-field own`, it is refused. + The flag is refused beside `--regrade` or `--self-test`. `--dry-run` prints the reduced plan, and `--skills-from VERSION` runs it on the published bundles. - **`--case KEY[,KEY]`**: the named cases alone, for an acceptance round on one or two cases. A key is the case's key as the summary and each record print it, `BUNDLE/FILE_STEM#ID` (`objectstack-query/filters-pagination-search#3`): diff --git a/packages/qa/scenarios/src/skill-evals/arms.ts b/packages/qa/scenarios/src/skill-evals/arms.ts index ca126bf7a52..09544e99842 100644 --- a/packages/qa/scenarios/src/skill-evals/arms.ts +++ b/packages/qa/scenarios/src/skill-evals/arms.ts @@ -108,11 +108,13 @@ export function prepareArmWorkdir(arm: Arm, bundles: string | readonly string[], * Place a case's `files` in a turn's project: each entry, a path under the * bundle's `evals/files/` (the reader has refused any other), is copied to the * same path below `evals/files/` inside `cwd`, a directory whole. Called for - * both arms alike, so the arms still differ only in the bundle. + * both arms alike, so the arms still differ only in the bundle. `casesRoot` is + * the tree the cases were read from, which is not the bundles' tree on a round + * over a published version. */ -export function placeCaseFiles(files: readonly string[] | undefined, bundle: string, skillsRoot: string, cwd: string): void { +export function placeCaseFiles(files: readonly string[] | undefined, bundle: string, casesRoot: string, cwd: string): void { for (const f of files ?? []) { const below = f.split('/').slice(2).join('/'); - cpSync(join(skillsRoot, bundle, f), join(cwd, below), { recursive: true, dereference: true }); + cpSync(join(casesRoot, bundle, f), join(cwd, below), { recursive: true, dereference: true }); } } diff --git a/packages/qa/scenarios/src/skill-evals/cases.ts b/packages/qa/scenarios/src/skill-evals/cases.ts index 1551cfbb573..9ac972073b4 100644 --- a/packages/qa/scenarios/src/skill-evals/cases.ts +++ b/packages/qa/scenarios/src/skill-evals/cases.ts @@ -1,10 +1,14 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * The published skills' eval cases, read from a skills root: the workspace's - * `skills/` tree, or the `dist/skills/` of a packed `@objectstack/skills` - * version. Each bundle is one directory holding a `SKILL.md`; its cases are the - * `evals/*.json` files beside it, in the shape every one of them already uses: + * The published skills' eval cases. The bundles come from a skills root: the + * workspace's `skills/` tree, or the `dist/skills/` of a packed + * `@objectstack/skills` version. Each bundle is one directory holding a + * `SKILL.md`. The cases come from a cases root, which is always a checkout's + * `skills/` tree: the published package carries no `evals/`, so a packed + * version's bundles are graded on this checkout's cases for the bundles of the + * same name. A bundle's cases are the `evals/*.json` files under its directory + * in the cases root, in the shape every one of them already uses: * * { "skill_name": BUNDLE, "evals": [ { "id", "prompt", "expected_output", * "files": [], "assertions": { "must_contain": [..], "must_not_contain": [..] } } ] } @@ -74,7 +78,10 @@ export interface SkillEvalRefusal { } export interface SkillEvalCatalog { + /** Where the bundles are read from. */ root: string; + /** Where the cases and their `evals/files/` are read from; `root` itself on a workspace round. */ + casesRoot: string; /** Every bundle directory under the root (a `SKILL.md` beside it), sorted. */ bundles: string[]; /** @@ -253,10 +260,17 @@ export function parseEvalFile(bundle: string, file: string, text: string): { cas return { cases, refusals }; } -/** Every bundle under `root` and every case its `evals/*.json` hold. */ -export function loadSkillEvalCatalog(root: string): SkillEvalCatalog { +/** + * Every bundle under `root`, and every case the `evals/*.json` of the same + * bundle hold under `casesRoot` (absent ⇒ `root`: bundles and cases from one + * tree). A bundle of `casesRoot` that `root` does not hold contributes no case. + */ +export function loadSkillEvalCatalog(root: string, casesRoot: string = root): SkillEvalCatalog { if (!existsSync(root) || !statSync(root).isDirectory()) { - return { root, bundles: [], unlistedBundles: [], cases: [], refusals: [{ path: root, message: 'is not a directory of skill bundles' }] }; + return { root, casesRoot, bundles: [], unlistedBundles: [], cases: [], refusals: [{ path: root, message: 'is not a directory of skill bundles' }] }; + } + if (!existsSync(casesRoot) || !statSync(casesRoot).isDirectory()) { + return { root, casesRoot, bundles: [], unlistedBundles: [], cases: [], refusals: [{ path: casesRoot, message: 'is not a directory of skill bundles to read cases from' }] }; } const bundles = readdirSync(root, { withFileTypes: true }) .filter((d) => d.isDirectory() && existsSync(join(root, d.name, 'SKILL.md'))) @@ -265,7 +279,7 @@ export function loadSkillEvalCatalog(root: string): SkillEvalCatalog { const cases: SkillEvalCase[] = []; const refusals: SkillEvalRefusal[] = []; for (const bundle of bundles) { - const dir = join(root, bundle, 'evals'); + const dir = join(casesRoot, bundle, 'evals'); if (!existsSync(dir)) continue; const files = readdirSync(dir, { withFileTypes: true }) .filter((d) => d.isFile() && d.name.endsWith('.json')) @@ -275,7 +289,7 @@ export function loadSkillEvalCatalog(root: string): SkillEvalCatalog { for (const file of files) { const r = parseEvalFile(bundle, file, readFileSync(join(dir, file), 'utf8')); for (const c of r.cases) { - const missingFile = (c.files ?? []).find((f) => !existsSync(join(root, bundle, f))); + const missingFile = (c.files ?? []).find((f) => !existsSync(join(casesRoot, bundle, f))); if (missingFile) refusals.push({ path: `${bundle}/evals/${file}: ${c.key}`, message: `\`files\` names \`${missingFile}\`, which is not in the bundle` }); else mine.push(c); } @@ -289,7 +303,7 @@ export function loadSkillEvalCatalog(root: string): SkillEvalCatalog { cases.push(...mine); } const unlistedBundles = bundles.filter((b) => notUserInvocable(readFileSync(join(root, b, 'SKILL.md'), 'utf8'))); - return { root, bundles, unlistedBundles, cases, refusals }; + return { root, casesRoot, bundles, unlistedBundles, cases, refusals }; } /** The `SKILL.md` frontmatter sets `user-invocable: false`. Pure over its input. */ diff --git a/packages/qa/scenarios/src/skill-evals/cli.ts b/packages/qa/scenarios/src/skill-evals/cli.ts index 52cf4ad426d..3ec70818007 100644 --- a/packages/qa/scenarios/src/skill-evals/cli.ts +++ b/packages/qa/scenarios/src/skill-evals/cli.ts @@ -15,7 +15,8 @@ * --skills a,b only these bundles (a touched skill); default every bundle with cases * --skills-from SOURCE `workspace` (default: this checkout's skills/) or an * `@objectstack/skills` version (`18.5.0`), packed from npm; - * cases and bundles both come from SOURCE + * the bundles come from SOURCE, the cases always from this + * checkout's skills/BUNDLE/evals/ (the package carries none) * --triggers-only only the selected bundles' trigger cases (`should_trigger`), on * the with-skill arm; refused beside --regrade or --self-test * --case KEY[,KEY] only these cases, by the key the summary and each record print @@ -164,14 +165,24 @@ function repoRoot(): string { } interface SkillsSource { + /** The bundles' tree. */ root: string; + /** The cases' tree: always this checkout's `skills/`. */ + casesRoot: string; label: string; cleanup: () => void; } -/** `workspace` → this checkout's `skills/`; a version → `npm pack @objectstack/skills@VERSION`'s `dist/skills/`. */ +/** What a round over a published version says about its cases; a workspace round says nothing, its one source being both. */ +export const CHECKOUT_CASES_LABEL = 'workspace skills/'; + +/** + * `workspace` → this checkout's `skills/`; a version → `npm pack @objectstack/skills@VERSION`'s `dist/skills/`. + * The cases come from this checkout's `skills/` either way: the published package leaves each skill's `evals/` out. + */ function resolveSkillsSource(from: string, repo: string): SkillsSource { - if (from === 'workspace') return { root: join(repo, 'skills'), label: 'workspace skills/', cleanup: () => {} }; + const casesRoot = join(repo, 'skills'); + if (from === 'workspace') return { root: casesRoot, casesRoot, label: 'workspace skills/', cleanup: () => {} }; if (!/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(from)) throw new Error(`--skills-from takes \`workspace\` or an exact @objectstack/skills version (\`18.5.0\`), not \`${from}\``); const dir = mkdtempSync(join(tmpdir(), 'skill-evals-pack-')); try { @@ -181,7 +192,7 @@ function resolveSkillsSource(from: string, repo: string): SkillsSource { rmSync(dir, { recursive: true, force: true }); throw new Error(`could not pack @objectstack/skills@${from}: ${e instanceof Error ? e.message : String(e)}`); } - return { root: join(dir, 'package', 'dist', 'skills'), label: `published @objectstack/skills@${from}`, cleanup: () => rmSync(dir, { recursive: true, force: true }) }; + return { root: join(dir, 'package', 'dist', 'skills'), casesRoot, label: `published @objectstack/skills@${from}`, cleanup: () => rmSync(dir, { recursive: true, force: true }) }; } function runnerSha(repo: string): string { @@ -198,7 +209,8 @@ export interface RoundRecord { startedAt: string; finishedAt: string; wallMs: number; - skills: { source: string; bundles: string[]; allBundles: boolean }; + /** `cases` is set when the cases came from another tree than the bundles (a round over a published version). */ + skills: { source: string; cases?: string; bundles: string[]; allBundles: boolean }; driver: { driver: 'claude-code-cli'; version: string; @@ -265,7 +277,7 @@ export function writeRoundOutputs(outDir: string, round: RoundRecord): void { title: `Skill evals · ${scope.selectedCases ? `${scope.selectedCases.length} named case(s) of ${round.skills.bundles.join(', ')}` : round.skills.allBundles ? 'all bundles' : round.skills.bundles.join(', ')} × ${scope.triggersOnly ? 'trigger cases × the with-skill arm' : scope.arms.length === 1 ? 'the with-skill arm' : '2 arms'} × ${scope.repeats} rep${scope.repeats === 1 ? '' : 's'}`, lines: [ `runner: ${round.runner.repo} ${round.runner.sha}`, - `skills: ${round.skills.source}`, + `skills: ${round.skills.source}${round.skills.cases ? `; cases: ${round.skills.cases}` : ''}`, ...(scope.selectedCases ? [`cases: the ${scope.selectedCases.length} named by --case, alone: ${scope.selectedCases.map((k) => `\`${k}\``).join(', ')}`] : []), `driver: ${d.driver} ${d.version}, login \`${d.authMethod}\`, no API key; served ${d.servedModels.join(', ') || 'none'}; effort ${d.requestedEffort ?? 'CLI default'}`, `turns: ${scope.ranTurns} of ${scope.plannedTurns} ran (${turnsLine(round.summary.cases.length, round.summary.triggers?.cases.length ?? 0, scope.repeats)}), ${d.concurrency} at once, --max-turns ${d.maxTurns}`, @@ -367,10 +379,11 @@ export async function main(argv: readonly string[]): Promise { const pf = args.dryRun || args.regrade ? undefined : preflight(args.bin, process.env, undefined, args.effort); const source = resolveSkillsSource(args.skillsFrom, repo); try { - const catalog = loadSkillEvalCatalog(source.root); + const catalog = loadSkillEvalCatalog(source.root, source.casesRoot); + const splitSource = source.casesRoot !== source.root; if (catalog.refusals.length) { for (const r of catalog.refusals) console.error(`${r.path}: ${r.message}`); - throw new Error(`${catalog.refusals.length} eval file or case refused under ${source.root}; the runner grades only cases it can read whole`); + throw new Error(`${catalog.refusals.length} eval file or case refused under ${source.casesRoot}; the runner grades only cases it can read whole`); } const catalogView = { bundles: catalog.bundles, unlisted: catalog.unlistedBundles }; if (args.regrade) return regradeRound(resolve(args.regrade), catalog, source.label); @@ -385,6 +398,7 @@ export async function main(argv: readonly string[]): Promise { if (args.dryRun) { console.log(`skills: ${source.label} (${source.root})`); + if (splitSource) console.log(`cases: ${CHECKOUT_CASES_LABEL} (${source.casesRoot}), for the bundles the published version holds`); for (const b of bundles) console.log(` ${b}: ${cases.filter((c) => c.bundle === b).length} case(s)`); const triggers = cases.filter((c) => c.shouldTrigger !== undefined); for (const b of triggers.length ? (triggerField ?? []).filter((n) => !bundles.includes(n)) : []) console.log(` ${b}: no case selected; a competitor in every trigger turn`); @@ -414,6 +428,7 @@ export async function main(argv: readonly string[]): Promise { const exec = await executeRound(jobs, { bin: args.bin, skillsRoot: source.root, + casesRoot: source.casesRoot, catalog: catalogView, outDir, maxTurns: args.maxTurns, @@ -433,7 +448,7 @@ export async function main(argv: readonly string[]): Promise { startedAt: startedAt.toISOString(), finishedAt: finishedAt.toISOString(), wallMs: finishedAt.getTime() - startedAt.getTime(), - skills: { source: source.label, bundles, allBundles: !args.cases && bundles.length === catalog.bundles.length }, + skills: { source: source.label, ...(splitSource ? { cases: CHECKOUT_CASES_LABEL } : {}), bundles, allBundles: !args.cases && bundles.length === catalog.bundles.length }, driver: { driver: 'claude-code-cli', version: pf.version, diff --git a/packages/qa/scenarios/src/skill-evals/run.ts b/packages/qa/scenarios/src/skill-evals/run.ts index fcf624a4a59..455929b5cb7 100644 --- a/packages/qa/scenarios/src/skill-evals/run.ts +++ b/packages/qa/scenarios/src/skill-evals/run.ts @@ -529,7 +529,10 @@ export const runRecordFile = (j: { case: SkillEvalCase; arm: Arm; repeat: number export interface RoundOptions { bin: string; + /** Where each turn's bundle is copied from. */ skillsRoot: string; + /** Where a case's `files` are copied from; absent ⇒ `skillsRoot` (bundles and cases from one tree). */ + casesRoot?: string; catalog: CatalogView; outDir: string; maxTurns: number; @@ -587,7 +590,7 @@ export async function executeRound(jobs: readonly RoundJob[], opts: RoundOptions const dir = prepareArmWorkdir(job.arm, installed, opts.skillsRoot); const startedAt = new Date().toISOString(); try { - placeCaseFiles(job.case.files, job.case.bundle, opts.skillsRoot, dir.cwd); + placeCaseFiles(job.case.files, job.case.bundle, opts.casesRoot ?? opts.skillsRoot, dir.cwd); const run = await runTurn(opts.bin, armArgs(dir.mcpConfigPath, opts), { cwd: dir.cwd, input: job.case.prompt, timeoutMs: opts.caseTimeoutMs, env }); const rec = judgeTurn(job.case, job.arm, job.repeat, run, opts.catalog, startedAt, gradeAnswer, installed); records.push(rec); diff --git a/packages/qa/scenarios/src/skill-evals/self-test.ts b/packages/qa/scenarios/src/skill-evals/self-test.ts index 55b37bafa61..84d637038bb 100644 --- a/packages/qa/scenarios/src/skill-evals/self-test.ts +++ b/packages/qa/scenarios/src/skill-evals/self-test.ts @@ -13,7 +13,7 @@ */ import { createHash } from 'node:crypto'; -import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; @@ -62,6 +62,7 @@ export const SELF_TEST_BATTERIES = Object.freeze({ 'judge: a should-not-trigger case the turn loaded → FAIL; left alone → PASS': 1, 'round: a trigger case runs on the with-skill arm only': 1, 'arms: a case\'s files land in the turn\'s project on both arms': 1, + 'reader: a published tree that carries no evals/ takes its cases and their files from the checkout\'s tree': 1, 'summary: trigger cases are tallied apart from the behaviour pass rates': 1, 'select: --triggers-only keeps the trigger cases on the with-skill arm and drops the behaviour cases': 1, 'flags: --triggers-only beside --regrade or --self-test, or on a bundle with no trigger case → REFUSED': 1, @@ -74,7 +75,7 @@ export const SELF_TEST_BATTERIES = Object.freeze({ }); /** The roster's own size, pinned: a deleted row takes its floor with it otherwise. */ -export const SELF_TEST_BATTERY_FLOOR = 44; +export const SELF_TEST_BATTERY_FLOOR = 45; let selfTestReachedVerdict = false; /** Whether the last {@link runSelfTest} reached its verdict line. */ @@ -141,7 +142,7 @@ export function runSelfTest(deps: SelfTestDeps): SelfTestResult { judgeTurn(c, arm, 1, exited(stdout), { bundles: ['demo-skill', 'other-skill', 'quiet-skill'], unlisted: ['quiet-skill'] }, 'fixture', grade); // Two bundles: `demo-skill` with a behaviour case and a trigger case of each kind; `other-skill` with a behaviour case only. - const selectCatalog = { root: 'fixture', bundles: ['demo-skill', 'other-skill'], unlistedBundles: [], refusals: [], cases: [ + const selectCatalog = { root: 'fixture', casesRoot: 'fixture', bundles: ['demo-skill', 'other-skill'], unlistedBundles: [], refusals: [], cases: [ fixtureCase(), fixtureCase({ id: 2, key: 'demo-skill/demo#2', shouldTrigger: true, mustContain: [] }), fixtureCase({ id: 3, key: 'demo-skill/demo#3', shouldTrigger: false, mustContain: [] }), @@ -471,6 +472,34 @@ export function runSelfTest(deps: SelfTestDeps): SelfTestResult { return ok ? true : 'a case file did not land at its path below evals/files/ on both arms'; }, }, + { + label: 'reader: a published tree that carries no evals/ takes its cases and their files from the checkout\'s tree', + run: () => { + // The published tree: two bundles, no evals/. The checkout: cases for one of them, and for a bundle the version does not hold. + const published = join(scratch, 'published'); + const checkout = join(scratch, 'checkout'); + for (const b of ['demo-skill', 'published-only']) { + mkdirSync(join(published, b), { recursive: true }); + writeFileSync(join(published, b, 'SKILL.md'), `---\nname: ${b}\n---\nthe published text\n`); + } + for (const b of ['demo-skill', 'checkout-only']) { + mkdirSync(join(checkout, b, 'evals', 'files', 'src'), { recursive: true }); + writeFileSync(join(checkout, b, 'SKILL.md'), `---\nname: ${b}\n---\nthe checkout text\n`); + writeFileSync(join(checkout, b, 'evals', 'files', 'src', 'task.object.ts'), 'export {};\n'); + writeFileSync(join(checkout, b, 'evals', 'cases.json'), JSON.stringify({ evals: [{ id: 1, prompt: 'p', files: ['evals/files/src'], assertions: { must_contain: ['x'] } }] })); + } + const alone = loadSkillEvalCatalog(published); + const split = loadSkillEvalCatalog(published, checkout); + const missing = loadSkillEvalCatalog(published, join(scratch, 'no-such-checkout')); + const d = prepareArmWorkdir('with-skill', 'demo-skill', published); + placeCaseFiles(split.cases[0]?.files, 'demo-skill', split.casesRoot, d.cwd); + const bundleText = readFileSync(join(d.cwd, '.claude', 'skills', 'demo-skill', 'SKILL.md'), 'utf8'); + const placed = existsSync(join(d.cwd, 'src', 'task.object.ts')); + rmSync(d.root, { recursive: true, force: true }); + const got = `alone ${alone.cases.length} case(s); split ${split.cases.map((c) => c.key).join() || 'none'} of bundles ${split.bundles.join()}, ${split.refusals.length} refusal(s); missing cases root ${missing.refusals.length} refusal(s), ${missing.cases.length} case(s); bundle ${bundleText.includes('published') ? 'published' : 'checkout'}; file ${placed ? 'placed' : 'absent'}`; + return got === 'alone 0 case(s); split demo-skill/cases#1 of bundles demo-skill,published-only, 0 refusal(s); missing cases root 1 refusal(s), 0 case(s); bundle published; file placed' ? true : got; + }, + }, { label: 'summary: trigger cases are tallied apart from the behaviour pass rates', run: () => { diff --git a/packages/skills/README.md b/packages/skills/README.md index 4778e177e68..5d9ace73101 100644 --- a/packages/skills/README.md +++ b/packages/skills/README.md @@ -4,9 +4,11 @@ This package contains nothing but `dist/skills/`: a byte-for-byte copy of the [`skills/`](https://github.com/objectstack-ai/objectstack/tree/main/skills) tree -of the `objectstack-ai/objectstack` repository — one directory per skill, each -with its `SKILL.md`, `references/`, `rules/` and `evals/` — taken at the commit -that released this version. +of the `objectstack-ai/objectstack` repository, without each skill's `evals/` +directory — one directory per skill, each with its `SKILL.md`, `references/` +and `rules/` — taken at the commit that released this version. The `evals/` +directories hold the cases the maintainers score a skill with; an agent never +loads them, so they stay in the repository. It is published from the Changesets `fixed` group, so its version is always the version of `@objectstack/spec`, `@objectstack/cli` and every other @@ -67,15 +69,19 @@ others — then run steps 1 and 2. The repository's `skills/` tree on `main` is the catalog of the **next** release. `npx skills add objectstack-ai/objectstack/skills --skill '*' --agent claude-code -y` reads it straight from the repository's unreleased `main` — for trying the next -version's skills, not for a released project. +version's skills, not for a released project. It copies each skill's directory +whole, so an install from this channel also holds the `evals/` directories the +package leaves out. ## How the tree is produced `scripts/sync-catalog.mjs`, this package's `build`, wipes `dist/` and copies the -repository's `skills/**` into `dist/skills/**`, reads the copy back and -refuses to finish unless the two trees are equal, file for file and byte for -byte. Its `prepublishOnly` runs the same comparison, so a stale or absent copy is -never published. The copy is gitignored; the repository's `skills/**` is the one source +repository's `skills/**` into `dist/skills/**`, leaving out every file under a +skill's `evals/` directory. It reads the copy back and refuses to finish unless +`dist/skills/**` equals `skills/**` minus those directories, file for file and +byte for byte; a file under a skill's `evals/` found in the copy is refused by +name. Its `prepublishOnly` runs the same comparison, so a stale or absent copy, +or one that carries an eval case, is never published. The copy is gitignored; the repository's `skills/**` is the one source of truth, reviewed and gated there. ## Related diff --git a/packages/skills/scripts/sync-catalog.mjs b/packages/skills/scripts/sync-catalog.mjs index 44ed00a450d..c9028dc36fe 100644 --- a/packages/skills/scripts/sync-catalog.mjs +++ b/packages/skills/scripts/sync-catalog.mjs @@ -3,8 +3,9 @@ /** * sync-catalog — the build step of `@objectstack/skills`: copy the - * repository's published skills catalog (`skills/**` at the repo root) into - * this package's publish tree, byte for byte, and prove it. + * repository's published skills catalog (`skills/**` at the repo root, minus + * each skill's `evals/` directory) into this package's publish tree, byte for + * byte, and prove it. * * node scripts/sync-catalog.mjs # the build: wipe + copy + verify * node scripts/sync-catalog.mjs --check # judge the tree on disk (prepack) @@ -23,6 +24,20 @@ * package commits no second copy and keeps no symlink: the tree under `dist/` * is produced by this script, gitignored, and listed by `files` alone. * + * ## What is left out — each skill's `evals/` + * + * `skills//evals/**` holds the eval fixtures: for each case the expected + * answer and the spellings an answer must not contain. They score the skill for + * its maintainers. Nothing in a consumer install reads them, and the eval + * runner withholds the directory from the bundle it grades, so a tree that + * carried them would not be the tree that was measured. The fixtures stay + * beside each skill in the repository, where the runner and the skill gates + * read them and where the `next` channel still serves them; the publish tree is + * `skills/**` minus `/evals/**`. Membership is the path alone + * (`isEvalFixture`): `evals/` directly under a skill directory, as the skills + * token ratchet's population 1b draws it. A fixture found in the publish tree + * is a red of its own, named as one, never only an "extra" file. + * * ## Layout — `dist/skills//…`, measured against the skills CLI * * `skills@1.7.2`'s `experimental_sync` ("Sync skills from node_modules into @@ -45,8 +60,8 @@ * `/SKILL.md`) is a refusal too: a package that ships nothing must say * so at build time, not at a consumer's `experimental_sync`. * - * After the copy the tree is read back and compared to the source, file set and - * bytes, and `--check` runs that same comparison on demand. The package's + * After the copy the tree is read back and compared to the shipped part of the + * source, file set and bytes, and `--check` runs that same comparison on demand. The package's * `prepublishOnly` runs `--check`, so `pnpm publish` refuses a stale or absent * tree instead of shipping it — the `@objectstack/console` shape. Not `prepack`: * `pnpm pack --json` prints its lifecycle banner (`> PKG@VERSION prepack …`) on @@ -113,24 +128,43 @@ export function walkFiles(root) { return out; } +/** + * Is this catalog-relative path an eval fixture? `evals/` directly under a + * skill directory (`/evals/**`), by the path alone. A file named + * `evals` and an `evals/` directory deeper in a skill or at the catalog root + * are not. + */ +export function isEvalFixture(rel) { + return /^[^/]+\/evals\//.test(rel); +} + +/** The files of `source` the package ships: every regular file but the eval fixtures. */ +export function shippedFiles(source) { + return walkFiles(source).filter((f) => !isEvalFixture(f)); +} + const sha256 = (abs) => createHash('sha256').update(readFileSync(abs)).digest('hex'); /** - * Compare two trees: same file set, same bytes. Pure over the filesystem; - * returns the differences rather than throwing, so a caller can report all of - * them at once. + * Compare the publish tree to the shipped part of the source: same file set, + * same bytes, and no eval fixture in the publish tree. Pure over the + * filesystem; returns the differences rather than throwing, so a caller can + * report all of them at once. */ export function compareTrees(source, target) { const problems = []; if (!existsSync(target)) { return { problems: [`${posix(target)} does not exist`], files: 0 }; } - const src = walkFiles(source); + const src = shippedFiles(source); const dst = walkFiles(target); const srcSet = new Set(src); const dstSet = new Set(dst); for (const f of src) if (!dstSet.has(f)) problems.push(`missing from the publish tree: ${f}`); - for (const f of dst) if (!srcSet.has(f)) problems.push(`extra in the publish tree: ${f}`); + for (const f of dst) { + if (isEvalFixture(f)) problems.push(`eval fixture in the publish tree: ${f}`); + else if (!srcSet.has(f)) problems.push(`extra in the publish tree: ${f}`); + } for (const f of src) { if (!dstSet.has(f)) continue; if (sha256(join(source, f)) !== sha256(join(target, f))) problems.push(`bytes differ: ${f}`); @@ -149,13 +183,13 @@ export function assertCatalogShape(source) { } /** - * The build: wipe `dist`, copy `source` into `target`, read the copy back and - * compare. Returns `{ skills, files }` on success; throws a `SyncRefusal` + * The build: wipe `dist`, copy the shipped files of `source` into `target`, + * read the copy back and compare. Returns `{ skills, files }` on success; throws a `SyncRefusal` * naming every difference otherwise. */ export function syncCatalog({ source = SOURCE, dist = DIST, target = TARGET } = {}) { const skills = assertCatalogShape(source); - const files = walkFiles(source); + const files = shippedFiles(source); rmSync(dist, { recursive: true, force: true }); for (const rel of files) { const dst = join(target, rel); @@ -186,6 +220,9 @@ let selfTestReachedVerdict = false; const SELF_TEST_BATTERIES = Object.freeze({ 'build copies the catalog byte for byte, and --check then passes': 1, + 'build leaves every eval fixture out of the publish tree': 1, + '--check reds on an eval fixture in the publish tree, naming it as one': 1, + 'only evals/ directly under a skill directory is an eval fixture': 1, 'build is idempotent: a second run produces the identical tree': 1, 'a file deleted from the source does not survive a rebuild': 1, '--check reds on a byte change in the publish tree, naming the file': 1, @@ -195,7 +232,7 @@ const SELF_TEST_BATTERIES = Object.freeze({ 'an empty catalog (no /SKILL.md) is refused at build': 1, 'a symlink in the catalog is refused, never followed': 1, }); -const SELF_TEST_BATTERY_FLOOR = 9; +const SELF_TEST_BATTERY_FLOOR = 12; function selfTest() { console.log('sync-catalog self-test\n'); @@ -209,6 +246,10 @@ function selfTest() { writeFileSync(join(source, 'README.md'), '# catalog\n'); writeFileSync(join(source, 'objectstack-data', 'SKILL.md'), '---\nname: objectstack-data\n---\n# data\n'); writeFileSync(join(source, 'objectstack-data', 'references', '_index.md'), '# refs\n'); + // Two eval fixtures, one nested: neither ships, so every count below stays 3. + mkdirSync(join(source, 'objectstack-data', 'evals', 'files', 'src'), { recursive: true }); + writeFileSync(join(source, 'objectstack-data', 'evals', 'cases.json'), '{"evals":[]}\n'); + writeFileSync(join(source, 'objectstack-data', 'evals', 'files', 'src', 'task.object.ts'), 'export {};\n'); const dist = join(root, 'pkg', 'dist'); return { source, dist, target: join(dist, 'skills') }; }; @@ -241,6 +282,33 @@ function selfTest() { if (c.problems.length !== 0) throw new Error(`--check found ${c.problems.join('; ')}`); return `${r.files} files, ${c.files} checked`; }); + run('build leaves every eval fixture out of the publish tree', () => { + const f = fixture('j'); + if (walkFiles(f.source).filter(isEvalFixture).length !== 2) throw new Error('the fixture catalog holds no eval fixture: this case would pass on a copy that skipped nothing'); + syncCatalog(f); + const packed = walkFiles(f.target); + if (existsSync(join(f.target, 'objectstack-data', 'evals'))) throw new Error(`evals/ was copied: ${packed.join(', ')}`); + if (packed.join('|') !== 'README.md|objectstack-data/SKILL.md|objectstack-data/references/_index.md') throw new Error(`got ${packed.join(', ')}`); + return `${packed.length} files packed, 2 fixtures left in the source`; + }); + run('--check reds on an eval fixture in the publish tree, naming it as one', () => { + const f = fixture('k'); + syncCatalog(f); + // The source's own fixture, byte for byte: equal to the source, and still refused. + mkdirSync(join(f.target, 'objectstack-data', 'evals'), { recursive: true }); + writeFileSync(join(f.target, 'objectstack-data', 'evals', 'cases.json'), readFileSync(join(f.source, 'objectstack-data', 'evals', 'cases.json'))); + const c = checkCatalog(f); + if (c.problems.length !== 1 || c.problems[0] !== 'eval fixture in the publish tree: objectstack-data/evals/cases.json') throw new Error(`got ${JSON.stringify(c.problems)}`); + }); + run('only evals/ directly under a skill directory is an eval fixture', () => { + const got = ['a/evals/x.json', 'a/evals/files/src/y.ts', 'evals/x.json', 'README.md', 'a/rules/evals/x.md', 'a/evals', 'a/evals.md'].map(isEvalFixture); + if (got.join() !== 'true,true,false,false,false,false,false') throw new Error(`got ${got.join()}`); + const f = fixture('l'); + mkdirSync(join(f.source, 'objectstack-data', 'rules', 'evals'), { recursive: true }); + writeFileSync(join(f.source, 'objectstack-data', 'rules', 'evals', 'note.md'), '# a rule file\n'); + const r = syncCatalog(f); + if (r.files !== 4 || !existsSync(join(f.target, 'objectstack-data', 'rules', 'evals', 'note.md'))) throw new Error(`a nested evals/ that is no fixture was left out: ${r.files} files`); + }); run('build is idempotent: a second run produces the identical tree', () => { const f = fixture('b'); syncCatalog(f); @@ -341,19 +409,19 @@ function main() { const { problems, files } = checkCatalog(); if (problems.length > 0) { console.error( - `\n✗ @objectstack/skills: the publish tree ${posix(relative(REPO_ROOT, TARGET))} is not the catalog ` + + `\n✗ @objectstack/skills: the publish tree ${posix(relative(REPO_ROOT, TARGET))} is not the catalog (each skill's evals/ left out) ` + `${posix(relative(REPO_ROOT, SOURCE))}:\n ${problems.join('\n ')}\n\n` + ' fix: pnpm --filter @objectstack/skills build\n', ); process.exit(1); } - console.log(`✓ @objectstack/skills: ${files} file(s) under dist/skills are byte-identical to skills/**.`); + console.log(`✓ @objectstack/skills: ${files} file(s) under dist/skills are byte-identical to skills/** minus each skill's evals/.`); return; } const { skills, files } = syncCatalog(); console.log( `✓ @objectstack/skills: ${files} file(s) across ${skills.length} skill(s) copied from skills/** ` + - 'into dist/skills and read back byte-identical.', + "(each skill's evals/ left out) into dist/skills and read back byte-identical.", ); } catch (err) { if (err instanceof SyncRefusal) { diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 6f78aa92aaa..3b6e0988ae0 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -210,16 +210,16 @@ * * 1. PRICED — every hand-authored TEACHING file inside a published skill * directory. A published skill directory is a child of `skills/` carrying - * a SKILL.md; everything under it ships into the customer project - * together, and everything under it that a customer session LOADS is + * a SKILL.md; everything under it but `evals/` ships into the customer + * project together, and everything under it that a customer session LOADS is * priced together. `SKILL.md`, `rules/**`, `guides/**` and hand-authored * `references/**` are all this. * * 1b. EVAL FIXTURES — `skills//evals/**`. Measured and printed in the * bundle total, NOT ratcheted (ruling record 6513306068 on #27847, * letter B). An eval fixture scores the skill for its maintainers and is - * inert in a consumer install (`skills/README.md`, the `evals/` entry of - * the layout; no SKILL.md points at one), so it never enters the customer + * not in the published package (`packages/skills/scripts/sync-catalog.mjs` + * leaves `evals/` out; no SKILL.md points at one), so it never enters the customer * context this gate prices — a ceiling on it priced repo bytes as if they * were customer tokens, and collided with #26369 B (a protocol addition * owes an eval). Their quality gates (`check:skill-eval-tokens`, the eval @@ -3568,7 +3568,7 @@ export function reportLines(rows) { ); out.push(` ${'generator-owned (measured, not ratcheted)'.padEnd(58)} ${String(generatedTokens).padStart(6)} / —`); out.push(` ${'eval fixtures (measured, not ratcheted)'.padEnd(58)} ${String(evalTokens).padStart(6)} / —`); - out.push(` ${'bundle total (whole shipped tree)'.padEnd(58)} ${String(pricedTokens + generatedTokens + evalTokens).padStart(6)}`); + out.push(` ${'bundle total (repository tree; evals/ do not ship)'.padEnd(58)} ${String(pricedTokens + generatedTokens + evalTokens).padStart(6)}`); return out; } @@ -4163,7 +4163,7 @@ function selfTest() { // ── the report line ────────────────────────────────────────────────── ['the report prints a whole-bundle total', - reportLines([{ rel, tokens: 10, ceiling: 20 }]).some((l) => l.includes('bundle total (whole shipped tree)')), true], + reportLines([{ rel, tokens: 10, ceiling: 20 }]).some((l) => l.includes('bundle total (repository tree; evals/ do not ship)')), true], ['the report prints a per-file net delta against the ceiling', reportLines([{ rel, tokens: 30, ceiling: 20 }]).some((l) => l.includes('(+10)')), true], ['the report names the counting convention', @@ -4174,7 +4174,7 @@ function selfTest() { // total even though it moves no ceiling. ['a generator-owned file is counted in the bundle total', reportLines([{ rel: genIndex, tokens: 754, ceiling: undefined, generated: generatorOwning(genIndex) }]) - .some((l) => l.includes('bundle total (whole shipped tree)') && l.includes('754')), true], + .some((l) => l.includes('bundle total (repository tree; evals/ do not ship)') && l.includes('754')), true], ['a generator-owned file is NOT counted into the ratcheted subtotal', reportLines([{ rel: genIndex, tokens: 754, ceiling: undefined, generated: generatorOwning(genIndex) }]) .some((l) => l.includes('ratcheted (authored)') && / 0 \/ +0/.test(l)), true], @@ -4202,7 +4202,7 @@ function selfTest() { ['the walk still finds eval fixtures, so they are measured', walked.includes('skills/demo/evals/deep/deeper/case.md'), true], ['an eval fixture is counted in the bundle total', reportLines([{ rel: evalReal, tokens: 335, ceiling: undefined }]) - .some((l) => l.includes('bundle total (whole shipped tree)') && l.includes('335')), true], + .some((l) => l.includes('bundle total (repository tree; evals/ do not ship)') && l.includes('335')), true], ['an eval fixture is NOT counted into the ratcheted subtotal', reportLines([{ rel: evalReal, tokens: 335, ceiling: undefined }]) .some((l) => l.includes('ratcheted (authored)') && / 0 \/ +0/.test(l)), true], diff --git a/skills/README.md b/skills/README.md index 4e2f52b59a5..23d2a2f1fbd 100644 --- a/skills/README.md +++ b/skills/README.md @@ -75,8 +75,8 @@ skills// │ # (pnpm --filter @objectstack/spec gen:skill-refs — do not hand-edit) ├── rules/ # (optional) detailed per-topic rule files linked from SKILL.md ├── contracts/ # (optional) generated machine-readable contracts (e.g. react-blocks) -└── evals/ # skill eval fixtures — used by maintainers to score the skill, - # inert (but harmless) in consumer installs +└── evals/ # skill eval fixtures — used by maintainers to score the skill; + # not in the @objectstack/skills package (repository only) ``` A `process` skill (`metadata.domain: process`) points at no Zod schema, so it