graceful-handoff/tests/plugin-manifest.test.mjs
Kjell Tore Guttormsen 96a22474bd feat(graceful-handoff): sync the ritual with the global session-end mechanism (v3.2.0)
SKILL.md had drifted from the global CLAUDE.md on two counts, both verified by
grep before the rewrite: the STATE.md template predated the mandatory `board:`
line and the `route:`/`route-last:` lines, and the closing line still demanded
three fields where six are now required (Innboks, Modell neste okt,
Oppstartskommando were missing).

- New step 3 routes the next session via `repo-mailbox:route` BEFORE the Write.
  It cannot run after the commit: the emitted lines live inside STATE.md, so
  routing afterwards would dirty a file that was just committed. One invocation
  feeds both the three comment lines and the closing line's model fields.
- `repo-mailbox` stays a soft dependency — documented fallback if it is absent
  or the cross-plugin Skill invocation is blocked. `route.sh`'s path is
  deliberately not hardcoded (plugin cache, versioned, drifts).
- The single-line constraint on the three comments is now in prose: `board.sh`
  reads the first non-blank, non-heading, non-`<!--` line under the heading as
  the repo's next step, so a wrapped `rationale=` corrupts the board.
- Closing line 3 -> 6 fields. The Innboks field reports what the session did
  rather than re-querying the mailbox — inbox handling belongs first in a
  session, and "no inbox injected" must never be reported as "empty".
- STATE format consolidated to ONE copy. Repo CLAUDE.md restated it with the
  same defect; it now points at SKILL.md step 4 as the authority, following the
  model-rubric precedent (two copies drift, prose cannot be tested).
- allowed-tools gains `Skill`. `plugin.json` description left unchanged on
  purpose — editing it would require the manual marketplace.json edit that
  release-plugin.mjs does not perform.

Tests 30 -> 42, all green. They are prose greps: drift guards, not proof the
ritual runs. Verifying that means a manual /graceful-handoff against a scratch
repo.

Release (tag + catalog ref bump) is operator-gated and NOT done here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013V59bNbWa5x2oTH2NMBJy4
2026-08-09 21:23:39 +02:00

54 lines
2.1 KiB
JavaScript

// plugin-manifest.test.mjs — verify plugin.json schema + CHANGELOG for v3.0.
import { test } from 'node:test';
import { strict as assert } from 'node:assert';
import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const MANIFEST = join(__dirname, '..', '.claude-plugin', 'plugin.json');
const CHANGELOG = join(__dirname, '..', 'CHANGELOG.md');
test('plugin.json version is 3.2.0', () => {
const m = JSON.parse(readFileSync(MANIFEST, 'utf-8'));
assert.equal(m.version, '3.2.0');
});
test('CHANGELOG has a [3.2.0] entry describing the ritual sync', () => {
const c = readFileSync(CHANGELOG, 'utf-8');
const match = c.match(/## \[3\.2\.0\][\s\S]*?(?=## \[3\.1\.0\]|$)/);
assert.ok(match, '[3.2.0] section missing');
assert.match(match[0], /route/);
});
test('plugin.json description mentions STATE.md', () => {
const m = JSON.parse(readFileSync(MANIFEST, 'utf-8'));
assert.match(m.description, /STATE\.md/);
});
test('plugin.json does NOT include auto_discover (not in documented schema)', () => {
const m = JSON.parse(readFileSync(MANIFEST, 'utf-8'));
assert.ok(!('auto_discover' in m), 'auto_discover field should be removed');
});
test('CHANGELOG has [3.0.0] entry with BREAKING section mentioning STATE.md', () => {
const c = readFileSync(CHANGELOG, 'utf-8');
const match = c.match(/## \[3\.0\.0\][\s\S]*?(?=## \[2\.1\.0\]|$)/);
assert.ok(match, '[3.0.0] section missing');
assert.match(match[0], /### BREAKING/);
assert.match(match[0], /STATE\.md/);
});
test('CHANGELOG preserves [2.1.0] and [2.0.0] history', () => {
const c = readFileSync(CHANGELOG, 'utf-8');
assert.match(c, /## \[2\.1\.0\]/);
assert.match(c, /## \[2\.0\.0\]/);
const v20 = c.match(/## \[2\.0\.0\][\s\S]*?(?=## \[1\.0\.0\]|$)/);
assert.ok(v20 && /### BREAKING/.test(v20[0]), '[2.0.0] BREAKING section should remain');
});
test('No source files reference version 1.0.0 / 2.x as current', () => {
const raw = readFileSync(MANIFEST, 'utf-8');
assert.doesNotMatch(raw, /"version":\s*"[12]\./);
});