diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99f67d3..d1bf5ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: node-version: 22 - name: Tests (guard, risk tier, verdict hook, shell parsing) run: node --test "tests/*.test.mjs" - - name: Plugin structure, budgets and public-content check + - name: Plugin structure, markdown total and public-content check env: BSTACK_PRIVATE_NAMES: ${{ secrets.BSTACK_PRIVATE_NAMES }} run: node tools/check-plugin.mjs diff --git a/evals/README.md b/evals/README.md index 7b903df..69e8584 100644 --- a/evals/README.md +++ b/evals/README.md @@ -2,7 +2,7 @@ A fixed set of cases that show whether bstack's rule text changes what an agent does. Each case runs twice through `claude plugin eval`: once with the plugin and once without it (the baseline arm). A case earns its place when the baseline fails it more often than the plugin does. -The suite lives here, outside `plugins/bstack`, so it does not ship with the plugin and does not count against the plugin's markdown budget. +The suite lives here, outside `plugins/bstack`, so it does not ship with the plugin and does not count in the plugin's markdown total that `tools/check-plugin.mjs` prints. ## When to run it diff --git a/tests/check-plugin.test.mjs b/tests/check-plugin.test.mjs index e10107f..546695c 100644 --- a/tests/check-plugin.test.mjs +++ b/tests/check-plugin.test.mjs @@ -77,6 +77,34 @@ test('#287: a guard hook that lets a failing call through still fails the check' assert.match(out, /PreToolUse guard must set "onFailure": "block"/); }); +test('#319: markdown of any size passes and the total is still printed', () => { + const big = 'word '.repeat(40000); + const { root } = fixture({ + 'plugins/bstack/skills/mode/playbooks/long.md': big, + 'plugins/bstack/rules/core.md': big, + }); + const { code, out } = check(root); + assert.equal(code, 0, out); + assert.match(out, /^ok: \d+ markdown files, \d+ bytes$/m); + assert.ok(Number(/, (\d+) bytes/.exec(out)[1]) > 400000, out); +}); + +const skill = description => `---\nname: mode\ndescription: ${description}\n---\n`; + +for (const [what, files, message] of [ + ['a skill without frontmatter', { 'plugins/bstack/skills/mode/SKILL.md': 'no frontmatter' }, /missing or without frontmatter/], + ['a description over 400 characters', { 'plugins/bstack/skills/mode/SKILL.md': skill('x'.repeat(401)) }, /description over 400 characters/], + ['a broken link', { 'plugins/bstack/rules/extra.md': '[x](nowhere.md)' }, /broken link nowhere\.md/], + ['a missing plugin-root file', { 'plugins/bstack/rules/extra.md': '${CLAUDE_PLUGIN_ROOT}/scripts/nowhere.mjs' }, /references missing plugin file scripts\/nowhere\.mjs/], +]) { + test(`#319: ${what} still fails the check`, () => { + const { root } = fixture(files); + const { code, out } = check(root); + assert.equal(code, 1); + assert.match(out, message); + }); +} + test('files under .claude/ (agent worktrees) are not scanned', () => { const { root, namesFile } = fixture({ '.claude/worktrees/agent-x/notes.txt': 'acme-secret-co' }); const { code, out } = check(root, { args: ['--names', namesFile] }); diff --git a/tools/check-plugin.mjs b/tools/check-plugin.mjs index 3929120..7a1cebe 100644 --- a/tools/check-plugin.mjs +++ b/tools/check-plugin.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node // Structural checks for the plugin that `claude plugin validate` does not cover: skill and agent -// frontmatter, links and plugin-root references that resolve, size budgets that force subtraction, +// frontmatter, links and plugin-root references that resolve, the plugin's markdown total (reported, not capped), // shell hooks that also cover PowerShell, PreToolUse guards that block when they fail, and no private name from the private list in this public repo. // node tools/check-plugin.mjs [--names file] // The private list loads as in check-public-text.mjs; without one the name check is skipped. @@ -19,17 +19,9 @@ const walk = dir => fs.readdirSync(dir, { withFileTypes: true }).flatMap(e => { const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); -const BUDGET = { - 'plugins/bstack/skills/mode/SKILL.md': 8192, - 'plugins/bstack/rules/core.md': 3072, - 'plugins/bstack/rules/style.md': 2048, -}; // PreToolUse hooks that only ask a judge to restate its report: blocking on their failure would // refuse every hand-back, so they let a failing call through. const NOT_GUARDS = new Set(['${CLAUDE_PLUGIN_ROOT}/scripts/verdict.mjs handback']); -const PLAYBOOK_BUDGET = 3584; -const SKILL_BUDGET = 6144; -const TOTAL_TEXT_BUDGET = 64848; function frontmatter(file) { const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(fs.readFileSync(file, 'utf8')); @@ -72,17 +64,8 @@ export function run({ repo = REPO, args = [], env = process.env, defaultFile = D if (fm?.name && `${fm.name}.md` !== name) fail(`${rel(file)}: name "${fm.name}" must match the file name`); } - // Size budgets const md = walk(plugin).filter(f => f.endsWith('.md')); - let total = 0; - for (const f of md) { - const size = fs.statSync(f).size; - total += size; - const r = rel(f); - const budget = BUDGET[r] ?? (r.includes('/playbooks/') ? PLAYBOOK_BUDGET : r.endsWith('SKILL.md') ? SKILL_BUDGET : null); - if (budget && size > budget) fail(`${r}: ${size} bytes, budget ${budget}. Subtract before adding.`); - } - if (total > TOTAL_TEXT_BUDGET) fail(`plugin markdown totals ${total} bytes, budget ${TOTAL_TEXT_BUDGET}`); + const total = md.reduce((sum, f) => sum + fs.statSync(f).size, 0); // Links and plugin-root references for (const f of md) { @@ -123,7 +106,7 @@ export function run({ repo = REPO, args = [], env = process.env, defaultFile = D error(errors.map(e => `x ${e}`).join('\n')); return 1; } - log(`ok: ${md.length} markdown files, ${total} bytes of ${TOTAL_TEXT_BUDGET}`); + log(`ok: ${md.length} markdown files, ${total} bytes`); return 0; }