397777089e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
28 lines
1.9 KiB
JavaScript
28 lines
1.9 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { isAuthoringWrite, decideMode } from './enforce-supreme-gate.mjs';
|
|
|
|
const newFile = { existsImpl: () => false }; // файла ещё нет на диске
|
|
|
|
describe('M7 Ф8 bootstrap-карвут: авторская запись нового плана/спеки', () => {
|
|
it('Write нового .md в specs/ или plans/ → true', () => {
|
|
expect(isAuthoringWrite({ name: 'Write', input: { file_path: 'docs/superpowers/specs/2026-06-12-x.md' } }, newFile)).toBe(true);
|
|
expect(isAuthoringWrite({ name: 'Write', input: { file_path: 'docs/superpowers/plans/2026-06-12-x.md' } }, newFile)).toBe(true);
|
|
});
|
|
it('перезапись существующего файла → false', () => {
|
|
expect(isAuthoringWrite({ name: 'Write', input: { file_path: 'docs/superpowers/plans/x.md' } }, { existsImpl: () => true })).toBe(false);
|
|
});
|
|
it('код / чужой путь / не-Write → false', () => {
|
|
expect(isAuthoringWrite({ name: 'Write', input: { file_path: 'tools/enforce-supreme-gate.mjs' } }, newFile)).toBe(false);
|
|
expect(isAuthoringWrite({ name: 'Write', input: { file_path: 'app/Foo.php' } }, newFile)).toBe(false);
|
|
expect(isAuthoringWrite({ name: 'Edit', input: { file_path: 'docs/superpowers/plans/x.md' } }, newFile)).toBe(false);
|
|
});
|
|
it('decideMode без плана + авторская запись нового файла → allow', () => {
|
|
const r = decideMode({ toolUse: { name: 'Write', input: { file_path: 'docs/superpowers/plans/__nonexistent_bootstrap_test__.md' } }, frozenPlan: null, key: 'k' });
|
|
expect(r.decision).toBe('allow');
|
|
});
|
|
it('decideMode без плана + запись в код → по-прежнему block (регрессия)', () => {
|
|
const r = decideMode({ toolUse: { name: 'Write', input: { file_path: 'app/Foo.php' } }, frozenPlan: null, key: 'k' });
|
|
expect(r.decision).toBe('block');
|
|
});
|
|
});
|