ShtukbaseStandard
archivo del paquete→ .shtukbase/packages/blueprint-skilled-agent/actions/build.ts

actions/build.ts

28 líneas, 1.3 KB.

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

  1. // Builds what agents get from the skills: /agents/prompts/<agent>.md for every agent page with `skills:`, and the
  2. // mirror .claude/skills/<id>/SKILL.md of the active skills. Removes a mirrored skill that is no longer active.
  3. // Run from the project root: bun .shtukbase/packages/blueprint-skilled-agent/actions/build.ts [--dry-run]
  4. import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
  5. import { dirname, join } from 'node:path';
  6. import { plan } from '../lib/skills.ts';
  7. const root = process.cwd();
  8. const dry = process.argv.includes('--dry-run');
  9. const p = plan(root);
  10. let n = 0;
  11. for (const [rel, text] of p.files) {
  12. const f = join(root, rel);
  13. if (existsSync(f) && readFileSync(f, 'utf8') === text) continue;
  14. n++;
  15. console.log(`${dry ? 'would write' : 'wrote'} ${rel}`);
  16. if (!dry) {
  17. mkdirSync(dirname(f), { recursive: true });
  18. writeFileSync(f, text);
  19. }
  20. }
  21. for (const id of p.mirrors) {
  22. console.log(`${dry ? 'would remove' : 'removed'} .claude/skills/${id} (the skill is gone or switched off)`);
  23. if (!dry) rmSync(join(root, '.claude', 'skills', id), { recursive: true, force: true });
  24. }
  25. console.log(n || p.mirrors.length ? `skills: files built — ${n}` : 'skills: everything is already built');
  26. for (const x of p.problems) console.log(` ${x.at}: ${x.what} → ${x.fix}`);
  27. process.exit(p.problems.length ? 1 : 0);