// Assemble the plugin's skill content: the dsh-specific prelude (committed in // this package at skill/prelude.md) followed VERBATIM by the canonical CLI // skill body (repo-root skill/SKILL.md — the same source crates/bsk-cli's // build.rs mirrors, so the two can never drift apart). The original's YAML // frontmatter is stripped: name/description are supplied by the registration. // Output: src/skill-content.generated.ts (gitignored, built before tsdown and // before vitest) so the markdown ships inlined in the bundle and registration // is a pure in-memory read — never a per-step disk access. import { readFileSync, writeFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; const here = dirname(fileURLToPath(import.meta.url)); const pkg = join(here, ".."); const prelude = readFileSync(join(pkg, "skill", "prelude.md"), "utf8"); const upstream = readFileSync(join(pkg, "..", "..", "skill", "SKILL.md"), "utf8"); function stripFrontmatter(markdown) { if (!markdown.startsWith("---\n")) return markdown; const end = markdown.indexOf("\n---\n", 4); return end === -1 ? markdown : markdown.slice(end + 5).replace(/^\s*\n/, ""); } const NAME = "browser-skill"; const DESCRIPTION = "Browser automation against the user's logged-in Chromium through this plugin's browser_* " + "tools (bsk engine): visit and read pages, fill forms, click through flows, scrape data, " + "smoke-test UI changes. Use when a task needs a real browser; requires the bsk CLI and the " + "browser-skill extension connected."; const content = `${prelude.trim()}\n\n${stripFrontmatter(upstream).trim()}\n`; const banner = "// GENERATED by scripts/build-skill-content.mjs — do not edit.\n" + "// Sources: skill/prelude.md (this package) + ../../../skill/SKILL.md (repo root).\n"; writeFileSync( join(pkg, "src", "skill-content.generated.ts"), `${banner}export const BSK_SKILL_NAME = ${JSON.stringify(NAME)};\n` + `export const BSK_SKILL_DESCRIPTION = ${JSON.stringify(DESCRIPTION)};\n` + `export const BSK_SKILL_MARKDOWN = ${JSON.stringify(content)};\n`, ); console.log(`skill-content.generated.ts written (${content.length} chars)`);