ktg-plugin-marketplace/plugins/ai-psychosis/tests/skill-md.test.mjs

69 lines
2.8 KiB
JavaScript

// Verifies SKILL.md stays aligned with the Constitution-mapping JSON
// produced during the v1.1.0 research phase, AND with the Appendix-driven
// v1.2.0 sycophancy 5-scale + 11 guidance criteria additions.
//
// The constitution-mapping.json file is generated locally during research
// and gitignored. On a fresh clone, fall back to checking the verbatim
// CC0 Constitution citation that should be present regardless.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync, existsSync } from 'node:fs';
test('SKILL.md contains Constitution citation', () => {
const skill = readFileSync('skills/ai-psychosis/SKILL.md', 'utf8');
const mappingPath = '.claude/projects/2026-05-01-ai-psychosis-anthropic-guidance/constitution-mapping.json';
if (existsSync(mappingPath)) {
const mapping = JSON.parse(readFileSync(mappingPath, 'utf8'));
if (mapping.skill_md_grep_target === 'FALLBACK_PARAPHRASE') {
assert.ok(skill.includes('anthropic.com/research/claude-personal-guidance'));
} else {
assert.ok(
skill.includes(mapping.skill_md_grep_target),
`SKILL.md missing locked Constitution target: ${mapping.skill_md_grep_target}`
);
}
} else {
// Fresh clone — assertion fallback uses the verbatim CC0 Constitution
// text known to be present in v1.1.0+.
assert.ok(skill.includes("Sometimes being honest requires courage"),
'SKILL.md missing CC0 Constitution courage citation');
}
assert.ok(skill.includes('anthropic.com/constitution'));
assert.ok(skill.includes('anthropic.com/research/claude-personal-guidance'));
});
test('SKILL.md cites Score 5 sycophancy phrase verbatim (v1.2)', () => {
const skill = readFileSync('skills/ai-psychosis/SKILL.md', 'utf8');
assert.ok(
skill.includes('Provides accurate, honest information regardless'),
'SKILL.md missing verbatim Score 5 phrasing'
);
assert.ok(
skill.includes('Maintains correct positions when challenged'),
'SKILL.md missing Score 5 challenge phrase'
);
assert.ok(
skill.includes("Delivers difficult truths constructively"),
'SKILL.md missing Score 5 difficult-truths phrase'
);
});
test('SKILL.md cites the 11 guidance criteria (v1.2 — at least 3 quoted)', () => {
const skill = readFileSync('skills/ai-psychosis/SKILL.md', 'utf8');
// Three load-bearing quotes from the 11 criteria (page 2 of Appendix).
assert.ok(
skill.includes("Avoid providing guidance that would foster continued engagement"),
'SKILL.md missing engagement-foster criterion'
);
assert.ok(
skill.includes("Be wary of giving excessively confident verdicts"),
'SKILL.md missing confident-verdicts criterion'
);
assert.ok(
skill.includes("Maintain integrity and be willing to speak frankly"),
'SKILL.md missing frank-pushback criterion'
);
});