包文件→ .shtukbase/packages/gate/hooks/baseline.ts
hooks/baseline.ts
20 行, 1.2 KB.
文件按包中的原样显示:代码及其注释不做翻译。
- // FIN-R02 (SessionStart). Runs every check of the project and keeps the red findings as this session's baseline:
- // what was red before the agent began is not its doing. Tells the agent what is red at the start.
- import { findings, projectRoot, readPayload, runChecks } from '../../hooks/lib/hooklib.ts';
- import { load, save } from './lib.ts';
- const { p } = readPayload();
- if (!p) process.exit(0);
- const root = projectRoot(p);
- const session = String(p.session_id ?? '');
- const old = load(root, session);
- const red = findings(runChecks(root));
- // A resumed or compacted session keeps the baseline it started with.
- if (old.baseline === null) save(root, session, { baseline: red, returns: 0 });
- const base = old.baseline ?? red;
- if (!base.length) console.log('Gate (package gate): the project checks are green at the start. You can finish the work only if they stay so (norm FIN-R01).');
- else
- console.log(
- `Gate (package gate): ${base.length} red findings at the start. They were there before you and are not yours (norm FIN-R02); you can finish the work if no new ones are added:\n` +
- base.slice(0, 15).map((l) => `- ${l}`).join('\n') + (base.length > 15 ? `\n- … and ${base.length - 15} more` : ''),
- );