包文件→ .shtukbase/packages/harness/checks/h01_agent.ts
checks/h01_agent.ts
30 行, 1.5 KB.
文件按包中的原样显示:代码及其注释不做翻译。
- // HRN-R01. An agent on a harness can be run unattended: its harness package is installed, the model and the rights
- // (access) are written, the working folder and the instruction file are inside the project. Agents whose runtime
- // is not a harness the packages know (a person, the node itself) are not checked.
- import { main } from '../../collections/checks/lib/runner.ts';
- import { type Project, type Result, addr, recordsOf } from '../../agents/lib/factlib.ts';
- import { KNOWN, agentProblems, harnessOf, harnessPkg } from '../lib/harness.ts';
- export const RULE = {
- id: 'HRN-R01', title: 'An agent on a harness can be run without a person',
- scope: 'agents whose runtime is a harness: claude, codex, opencode, dsh, hermes',
- };
- export function check(p: Project, res: Result): void {
- const recs = recordsOf(p, 'AGENT').filter((r) => {
- const h = harnessOf(r.fm);
- return KNOWN.includes(h) || harnessPkg(p.root, h).installed;
- });
- res.scope = recs.map((r) => addr(r.id));
- res.scopeText = `agents on harnesses (${recs.length})`;
- if (!res.part('agents', p.coll('AGENT') ? null : 'no agents collection')) return;
- for (const r of recs) {
- const at = addr(r.id);
- const h = harnessOf(r.fm);
- const hp = harnessPkg(p.root, h);
- if (!hp.installed) res.hole(at, `harness "${h}", but the package ${hp.pkg} is not in the project`, `shtuk install …/${hp.pkg}`, 'no-harness');
- for (const x of agentProblems(p.root, r.fm)) res.hole(at, x.what, x.fix, x.code);
- }
- }
- if (import.meta.main) main({ RULE, check });