/** * Rewrites the root-level `skills/pr-lens/` from this package, which is the * only copy the skills.sh installer hands a user, and the manual the CLI * prints. A drift test fails until this has been run, so they never disagree. * * pnpm skill:sync */ import { dirname, join } from "node:path"; import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises"; import { filesPresent, SKILL_FILES, SKILL_MIRROR_DIR, SKILL_SOURCE_DIR } from "./mirror.js"; await rm(SKILL_MIRROR_DIR, { recursive: true, force: true }); for (const file of SKILL_FILES) { const destination = join(SKILL_MIRROR_DIR, file); await mkdir(dirname(destination), { recursive: true }); await cp(join(SKILL_SOURCE_DIR, file), destination); } const embeddedSkillPath = join(SKILL_SOURCE_DIR, "..", "cli", "src", "skill-content.generated.ts"); const [manual, config, graphDocument, exampleDocument, graphDocumentJsonSchema] = await Promise.all([ readFile(join(SKILL_SOURCE_DIR, "manual.md"), "utf8"), readFile(join(SKILL_SOURCE_DIR, "references", "config.md"), "utf8"), readFile(join(SKILL_SOURCE_DIR, "references", "graph-document.md"), "utf8"), readFile(join(SKILL_SOURCE_DIR, "references", "example.graph.json"), "utf8"), readFile(join(SKILL_SOURCE_DIR, "..", "schema", "json-schema", "graph-doc.schema.json"), "utf8"), ]); await writeFile( embeddedSkillPath, [ "// Generated by `pnpm skill:sync`; edit packages/agent-skill instead.", `export const SKILL_MANUAL = ${JSON.stringify(manual)};`, `export const CONFIG_REFERENCE = ${JSON.stringify(config)};`, `export const GRAPH_DOCUMENT_REFERENCE = ${JSON.stringify(graphDocument)};`, `export const EXAMPLE_GRAPH_DOCUMENT = ${JSON.stringify(exampleDocument)};`, `export const GRAPH_DOCUMENT_JSON_SCHEMA = ${JSON.stringify(graphDocumentJsonSchema)};`, "", ].join("\n"), "utf8", ); console.log((await filesPresent(SKILL_MIRROR_DIR)).map((file) => ` ${file}`).join("\n"));