ShtukbaseStandard
archivo del paquete→ .shtukbase/packages/harness/checks/h01_agent.ts

checks/h01_agent.ts

30 líneas, 1.5 KB.

El archivo tal como está en el paquete: el código y sus comentarios no se traducen.

  1. // HRN-R01. An agent on a harness can be run unattended: its harness package is installed, the model and the rights
  2. // (access) are written, the working folder and the instruction file are inside the project. Agents whose runtime
  3. // is not a harness the packages know (a person, the node itself) are not checked.
  4. import { main } from '../../collections/checks/lib/runner.ts';
  5. import { type Project, type Result, addr, recordsOf } from '../../agents/lib/factlib.ts';
  6. import { KNOWN, agentProblems, harnessOf, harnessPkg } from '../lib/harness.ts';
  7. export const RULE = {
  8. id: 'HRN-R01', title: 'An agent on a harness can be run without a person',
  9. scope: 'agents whose runtime is a harness: claude, codex, opencode, dsh, hermes',
  10. };
  11. export function check(p: Project, res: Result): void {
  12. const recs = recordsOf(p, 'AGENT').filter((r) => {
  13. const h = harnessOf(r.fm);
  14. return KNOWN.includes(h) || harnessPkg(p.root, h).installed;
  15. });
  16. res.scope = recs.map((r) => addr(r.id));
  17. res.scopeText = `agents on harnesses (${recs.length})`;
  18. if (!res.part('agents', p.coll('AGENT') ? null : 'no agents collection')) return;
  19. for (const r of recs) {
  20. const at = addr(r.id);
  21. const h = harnessOf(r.fm);
  22. const hp = harnessPkg(p.root, h);
  23. if (!hp.installed) res.hole(at, `harness "${h}", but the package ${hp.pkg} is not in the project`, `shtuk install …/${hp.pkg}`, 'no-harness');
  24. for (const x of agentProblems(p.root, r.fm)) res.hole(at, x.what, x.fix, x.code);
  25. }
  26. }
  27. if (import.meta.main) main({ RULE, check });