@powerhousedao/clint 6.4.0-next.1 → 6.4.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-skills-XkfkDhWl.mjs → build-skills-Bpbbnin0.mjs} +2 -2
- package/dist/{build-skills-XkfkDhWl.mjs.map → build-skills-Bpbbnin0.mjs.map} +1 -1
- package/dist/{index-C3-HSfKb.d.mts → index-CfHcet4v.d.mts} +2 -2
- package/dist/{index-C3-HSfKb.d.mts.map → index-CfHcet4v.d.mts.map} +1 -1
- package/dist/index.d.mts +33 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/integrations/mastra/index.d.mts +1 -1
- package/dist/integrations/powerhouse/index.d.mts +2 -2
- package/dist/runners/cli-runner.d.mts +5 -1
- package/dist/runners/cli-runner.d.mts.map +1 -1
- package/dist/runners/cli-runner.mjs +23 -9
- package/dist/runners/cli-runner.mjs.map +1 -1
- package/dist/runners/mastra-runner.mjs +1 -1
- package/dist/{src-055YwI8s.mjs → src-BmMd0Wl4.mjs} +159 -21
- package/dist/src-BmMd0Wl4.mjs.map +1 -0
- package/dist/testing/index.d.mts +2 -2
- package/dist/{types-CbHJ-ZnH.d.mts → types-3TnDjQ1w.d.mts} +2 -2
- package/dist/{types-CbHJ-ZnH.d.mts.map → types-3TnDjQ1w.d.mts.map} +1 -1
- package/dist/{types-CF6GuPJd.d.mts → types-DbQKfvWc.d.mts} +20 -1
- package/dist/types-DbQKfvWc.d.mts.map +1 -0
- package/package.json +13 -13
- package/dist/src-055YwI8s.mjs.map +0 -1
- package/dist/types-CF6GuPJd.d.mts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { x as renderSkillTemplate } from "./src-
|
|
1
|
+
import { x as renderSkillTemplate } from "./src-BmMd0Wl4.mjs";
|
|
2
2
|
import { n as slugToTitle } from "./schema-BEKAZGyT.mjs";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -299,4 +299,4 @@ async function buildSkills(options) {
|
|
|
299
299
|
//#endregion
|
|
300
300
|
export { buildSkills };
|
|
301
301
|
|
|
302
|
-
//# sourceMappingURL=build-skills-
|
|
302
|
+
//# sourceMappingURL=build-skills-Bpbbnin0.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-skills-XkfkDhWl.mjs","names":[],"sources":["../src/dev/agent-profiles.ts","../src/dev/skill-builder.ts","../src/dev/skill-copier.ts","../src/dev/build-skills.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { renderSkillTemplate } from \"../index.js\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Find the first existing file across multiple include directories.\n */\nfunction findInIncludes(\n includes: string[],\n subdir: string,\n filename: string,\n): string | undefined {\n for (const dir of includes) {\n const p = path.join(dir, subdir, filename);\n if (fs.existsSync(p)) return p;\n }\n return undefined;\n}\n\n/**\n * Build agent profile instructions by rendering base+specialized template pairs.\n * Writes each profile as a Markdown file in {output}/agents/{ProfileName}.md.\n *\n * @returns Number of profiles built and any warnings.\n */\nexport function buildAgentProfiles(config: ResolvedBuildConfig): {\n count: number;\n warnings: string[];\n} {\n const log = config.logger;\n const profiles = config.agentProfiles;\n if (profiles.length === 0) return { count: 0, warnings: [] };\n\n const profilesSubdir = config.subdirs?.profiles ?? \"agent-profiles\";\n\n log(\"\\n--- Building agent instructions ---\");\n\n const allWarnings: string[] = [];\n let count = 0;\n\n for (const profile of profiles) {\n // Check all section files exist before rendering\n const sectionPaths: string[] = [];\n let missing = false;\n for (const section of profile.sections) {\n const found = findInIncludes(config.include, profilesSubdir, section);\n if (!found) {\n log(` SKIP ${profile.name}: missing section ${section}`);\n missing = true;\n break;\n }\n sectionPaths.push(found);\n }\n if (missing) continue;\n\n const agentContext = { ...config.context, agentName: profile.name };\n const renderOpts = config.customHelpers\n ? { helpers: config.customHelpers }\n : undefined;\n\n const renderedSections: string[] = [];\n for (let i = 0; i < profile.sections.length; i++) {\n const raw = fs.readFileSync(sectionPaths[i], \"utf-8\");\n const result = renderSkillTemplate(raw, agentContext, renderOpts);\n for (const w of result.warnings) {\n const msg = `${profile.name}/${profile.sections[i]}: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n renderedSections.push(result.rendered.trim());\n }\n\n const combined = renderedSections.join(\"\\n\\n\") + \"\\n\";\n for (const out of config.output) {\n const agentsDir = path.join(out, \"agent-profiles\");\n fs.mkdirSync(agentsDir, { recursive: true });\n fs.writeFileSync(\n path.join(agentsDir, `${profile.name}.md`),\n combined,\n \"utf-8\",\n );\n }\n\n log(` OK ${profile.name} → ${profile.name}.md (${combined.length} chars)`);\n count++;\n }\n\n return { count, warnings: allWarnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { renderSkillTemplate, slugToTitle } from \"../index.js\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Find the first existing directory across multiple include paths.\n */\nfunction findSubdir(includes: string[], subdir: string): string | undefined {\n for (const dir of includes) {\n const p = path.join(dir, subdir);\n if (fs.existsSync(p)) return p;\n }\n return undefined;\n}\n\n/**\n * Build SKILL.md files from Handlebars templates in skills-tpl/.\n * Each skill directory produces a SKILL.md + references/ folder.\n *\n * @returns Number of skills built and any warnings.\n */\nexport function buildSkillTemplates(config: ResolvedBuildConfig): {\n count: number;\n warnings: string[];\n} {\n const log = config.logger;\n const skillsTplSubdir = config.subdirs?.skillsTpl ?? \"skills-tpl\";\n const skillsTplDir = findSubdir(config.include, skillsTplSubdir);\n\n log(\"\\n--- Building SKILL.md files (templates) ---\");\n\n if (!skillsTplDir) {\n log(\" No skills-tpl/ directory — skipping.\");\n return { count: 0, warnings: [] };\n }\n\n const skillDirs = fs\n .readdirSync(skillsTplDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n .sort();\n\n const allWarnings: string[] = [];\n const renderOpts = config.customHelpers\n ? { helpers: config.customHelpers }\n : undefined;\n let count = 0;\n\n for (const skillName of skillDirs) {\n const skillDir = path.join(skillsTplDir, skillName);\n\n // Preamble\n const preamblePath = path.join(skillDir, \".preamble.md\");\n const preambleRaw = fs.existsSync(preamblePath)\n ? fs.readFileSync(preamblePath, \"utf-8\").trim()\n : \"\";\n let preamble = \"\";\n if (preambleRaw) {\n const r = renderSkillTemplate(preambleRaw, config.context, renderOpts);\n preamble = r.rendered;\n for (const w of r.warnings) {\n const msg = `${skillName}/.preamble.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n }\n\n // Scenario files (NN.name.md)\n const scenarioFiles = fs\n .readdirSync(skillDir)\n .filter((f) => /^\\d+\\..*\\.md$/.test(f))\n .sort();\n\n // Result file\n const resultPath = path.join(skillDir, \".result.md\");\n const hasResult = fs.existsSync(resultPath);\n\n if (!preamble && scenarioFiles.length === 0 && !hasResult) {\n log(` SKIP ${skillName}: no content files found`);\n continue;\n }\n\n // Render references into memory\n const files: Map<string, string> = new Map();\n const refLinks: string[] = [];\n\n for (const scenarioFile of scenarioFiles) {\n const content = fs\n .readFileSync(path.join(skillDir, scenarioFile), \"utf-8\")\n .trim();\n const r = renderSkillTemplate(content, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/${scenarioFile}: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(path.join(\"references\", scenarioFile), r.rendered + \"\\n\");\n const label = slugToTitle(\n scenarioFile.replace(/^\\d+\\./, \"\").replace(/\\.md$/, \"\"),\n );\n refLinks.push(\n `* **${label}** [references/${scenarioFile}](references/${scenarioFile})`,\n );\n }\n\n if (hasResult) {\n const content = fs.readFileSync(resultPath, \"utf-8\").trim();\n const r = renderSkillTemplate(content, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/.result.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(\n path.join(\"references\", \"expected-outcome.md\"),\n r.rendered + \"\\n\",\n );\n refLinks.push(\n `* **Expected Outcome** [references/expected-outcome.md](references/expected-outcome.md)`,\n );\n }\n\n // Build SKILL.md\n const description =\n config.skillDescriptions[skillName] ?? `${slugToTitle(skillName)} tasks`;\n\n const frontmatter = [\n \"---\",\n `name: ${skillName}`,\n `description: \"${description}\"`,\n \"metadata:\",\n \" author: Powerhouse\",\n ' version: \"1.0.0\"',\n \"---\",\n ].join(\"\\n\");\n\n const sections = [preamble];\n if (refLinks.length > 0) {\n sections.push(\"## Specific tasks\\n\\n\" + refLinks.join(\"\\n\"));\n }\n\n const skillMd =\n frontmatter + \"\\n\\n\" + sections.filter(Boolean).join(\"\\n\\n\") + \"\\n\";\n files.set(\"SKILL.md\", skillMd);\n\n // Copy .cli-docs.md if present (render through Handlebars)\n const cliDocsPath = path.join(skillDir, \".cli-docs.md\");\n if (fs.existsSync(cliDocsPath)) {\n const cliDocsRaw = fs.readFileSync(cliDocsPath, \"utf-8\").trim();\n if (cliDocsRaw) {\n const r = renderSkillTemplate(cliDocsRaw, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/.cli-docs.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(\".cli-docs.md\", r.rendered + \"\\n\");\n }\n }\n\n // Write to all output directories\n for (const out of config.output) {\n const outputDir = path.join(out, \"skills\", skillName);\n for (const [relPath, content] of files) {\n const fullPath = path.join(outputDir, relPath);\n fs.mkdirSync(path.dirname(fullPath), { recursive: true });\n fs.writeFileSync(fullPath, content, \"utf-8\");\n }\n }\n\n log(\n ` OK ${skillName} → SKILL.md + ${scenarioFiles.length + (hasResult ? 1 : 0)} references (${skillMd.length} chars)`,\n );\n count++;\n }\n\n return { count, warnings: allWarnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Copy external skills from skills-ext/ to the output directory without processing.\n *\n * @returns Number of skills copied.\n */\nexport function copyExternalSkills(config: ResolvedBuildConfig): number {\n const log = config.logger;\n const skillsExtSubdir = config.subdirs?.skillsExt ?? \"skills-ext\";\n\n log(\"\\n--- Copying external skills ---\");\n\n // Search all include dirs for skills-ext/\n let found = false;\n let total = 0;\n\n for (const dir of config.include) {\n const skillsExtDir = path.join(dir, skillsExtSubdir);\n if (!fs.existsSync(skillsExtDir)) continue;\n found = true;\n\n const skillDirs = fs\n .readdirSync(skillsExtDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n .sort();\n\n for (const skillName of skillDirs) {\n const srcDir = path.join(skillsExtDir, skillName);\n for (const out of config.output) {\n fs.cpSync(srcDir, path.join(out, \"skills\", skillName), {\n recursive: true,\n });\n }\n log(` OK ${skillName} → copied as-is`);\n }\n\n total += skillDirs.length;\n }\n\n if (!found) {\n log(\" No skills-ext/ directory — skipping.\");\n }\n\n return total;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { buildAgentProfiles } from \"./agent-profiles.js\";\nimport { buildSkillTemplates } from \"./skill-builder.js\";\nimport { copyExternalSkills } from \"./skill-copier.js\";\nimport type { AgentProfile, ResolvedBuildConfig } from \"./types.js\";\nimport type { CliMetadata } from \"../core/types.js\";\n\n/**\n * Path-driven skill/profile compilation (ph-clint-dev's pipeline). The paths\n * drive it; a package's `Cli` is an optional extra source (`cli`): its\n * metadata joins the template context as ph-clint-dev did it, so a template\n * can name `{{commands.<id>.description}}` or `{{services.<id>.name}}`.\n * Conventions:\n *\n * <skillsDir>/ include root (default: prompts/ then agents/)\n * agent-profiles/ profile section templates\n * skills-tpl/<skill>/ Handlebars skill templates → SKILL.md\n * skills-ext/<skill>/ external skills copied as-is\n * profiles.json optional [{ name, sections: [...] }]\n *\n * Output: <outDir> (default: dist/skills).\n */\nexport interface BuildSkillsOptions {\n rootDir: string;\n skillsDir?: string;\n agentsDir?: string;\n outDir?: string;\n context?: Record<string, unknown>;\n /**\n * The package's `Cli` (see `loadCli`). Only `getMetadata()` is read, which\n * starts nothing. Its metadata is spread over `context` (ph-clint-dev's\n * order: the Cli wins), its `prompts.skills` give the skill descriptions\n * and its `prompts.agents` the agent profiles; a `profiles.json` entry of\n * the same name replaces the Cli's.\n */\n cli?: { getMetadata(): CliMetadata };\n logger?: (msg: string) => void;\n}\n\nexport interface BuildSkillsResult {\n skills: number;\n profiles: number;\n copied: number;\n warnings: string[];\n outDir: string;\n}\n\nfunction firstExisting(\n rootDir: string,\n candidates: (string | undefined)[],\n): string[] {\n const dirs: string[] = [];\n for (const candidate of candidates) {\n if (!candidate) continue;\n const abs = path.resolve(rootDir, candidate);\n if (fs.existsSync(abs)) dirs.push(abs);\n }\n return dirs;\n}\n\nfunction readProfilesManifest(include: string[]): AgentProfile[] {\n for (const dir of include) {\n const manifest = path.join(dir, \"profiles.json\");\n if (fs.existsSync(manifest)) {\n try {\n return JSON.parse(fs.readFileSync(manifest, \"utf8\")) as AgentProfile[];\n } catch {\n return [];\n }\n }\n }\n return [];\n}\n\nexport async function buildSkills(\n options: BuildSkillsOptions,\n): Promise<BuildSkillsResult> {\n const log = options.logger ?? console.log;\n const include = firstExisting(options.rootDir, [\n options.skillsDir,\n options.agentsDir,\n \"prompts\",\n \"agents\",\n ]);\n const outDir = path.resolve(options.rootDir, options.outDir ?? \"dist/skills\");\n\n if (include.length === 0) {\n log(\n \"No prompt template directories found (prompts/ or agents/) — nothing to build.\",\n );\n return { skills: 0, profiles: 0, copied: 0, warnings: [], outDir };\n }\n\n const meta = options.cli?.getMetadata();\n const skillDescriptions: Record<string, string> = {};\n for (const [id, skill] of Object.entries(meta?.prompts?.skills ?? {})) {\n skillDescriptions[id] =\n typeof skill === \"string\" ? skill : skill.description;\n }\n const manifestProfiles = readProfilesManifest(include);\n const agentProfiles = [\n ...Object.values(meta?.prompts?.agents ?? {})\n .filter((a) => !manifestProfiles.some((p) => p.name === a.name))\n .map(({ name, sections }) => ({ name, sections })),\n ...manifestProfiles,\n ];\n\n const resolved: ResolvedBuildConfig = {\n include,\n output: [outDir],\n context: { builtAt: new Date().toISOString(), ...options.context, ...meta },\n agentProfiles,\n skillDescriptions,\n clean: true,\n logger: log,\n };\n\n for (const dir of resolved.output) {\n if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true });\n }\n\n const profiles = buildAgentProfiles(resolved);\n const templates = buildSkillTemplates(resolved);\n const copied = copyExternalSkills(resolved);\n\n return {\n skills: templates.count,\n profiles: profiles.count,\n copied,\n warnings: [...profiles.warnings, ...templates.warnings],\n outDir,\n };\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,eACP,UACA,QACA,UACoB;CACpB,KAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,IAAI,KAAK,KAAK,KAAK,QAAQ,QAAQ;EACzC,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO;CAC/B;AAEF;;;;;;;AAQA,SAAgB,mBAAmB,QAGjC;CACA,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,OAAO;CACxB,IAAI,SAAS,WAAW,GAAG,OAAO;EAAE,OAAO;EAAG,UAAU,CAAC;CAAE;CAE3D,MAAM,iBAAiB,OAAO,SAAS,YAAY;CAEnD,IAAI,uCAAuC;CAE3C,MAAM,cAAwB,CAAC;CAC/B,IAAI,QAAQ;CAEZ,KAAK,MAAM,WAAW,UAAU;EAE9B,MAAM,eAAyB,CAAC;EAChC,IAAI,UAAU;EACd,KAAK,MAAM,WAAW,QAAQ,UAAU;GACtC,MAAM,QAAQ,eAAe,OAAO,SAAS,gBAAgB,OAAO;GACpE,IAAI,CAAC,OAAO;IACV,IAAI,UAAU,QAAQ,KAAK,oBAAoB,SAAS;IACxD,UAAU;IACV;GACF;GACA,aAAa,KAAK,KAAK;EACzB;EACA,IAAI,SAAS;EAEb,MAAM,eAAe;GAAE,GAAG,OAAO;GAAS,WAAW,QAAQ;EAAK;EAClE,MAAM,aAAa,OAAO,gBACtB,EAAE,SAAS,OAAO,cAAc,IAChC,KAAA;EAEJ,MAAM,mBAA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B,OAAO;CACrD,MAAM,gBAAgB,CACpB,GAAG,OAAO,OAAO,MAAM,SAAS,UAAU,CAAC,CAAC,CAAC,CAC1C,QAAQ,MAAM,CAAC,iBAAiB,MAAM,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAC/D,KAAK,EAAE,MAAM,gBAAgB;EAAE;EAAM;CAAS,EAAE,GACnD,GAAG,gBACL;CAEA,MAAM,WAAgC;EACpC;EACA,QAAQ,CAAC,MAAM;EACf,SAAS;GAAE,0BAAS,IAAI,KAAK,EAAA,CAAE,YAAY;GAAG,GAAG,QAAQ;GAAS,GAAG;EAAK;EAC1E;EACA;EACA,OAAO;EACP,QAAQ;CACV;CAEA,KAAK,MAAM,OAAO,SAAS,QACzB,IAAI,GAAG,WAAW,GAAG,GAAG,GAAG,OAAO,KAAK,EAAE,WAAW,KAAK,CAAC;CAG5D,MAAM,WAAW,mBAAmB,QAAQ;CAC5C,MAAM,YAAY,oBAAoB,QAAQ;CAC9C,MAAM,SAAS,mBAAmB,QAAQ;CAE1C,OAAO;EACL,QAAQ,UAAU;EAClB,UAAU,SAAS;EACnB;EACA,UAAU,CAAC,GAAG,SAAS,UAAU,GAAG,UAAU,QAAQ;EACtD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"build-skills-Bpbbnin0.mjs","names":[],"sources":["../src/dev/agent-profiles.ts","../src/dev/skill-builder.ts","../src/dev/skill-copier.ts","../src/dev/build-skills.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { renderSkillTemplate } from \"../index.js\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Find the first existing file across multiple include directories.\n */\nfunction findInIncludes(\n includes: string[],\n subdir: string,\n filename: string,\n): string | undefined {\n for (const dir of includes) {\n const p = path.join(dir, subdir, filename);\n if (fs.existsSync(p)) return p;\n }\n return undefined;\n}\n\n/**\n * Build agent profile instructions by rendering base+specialized template pairs.\n * Writes each profile as a Markdown file in {output}/agents/{ProfileName}.md.\n *\n * @returns Number of profiles built and any warnings.\n */\nexport function buildAgentProfiles(config: ResolvedBuildConfig): {\n count: number;\n warnings: string[];\n} {\n const log = config.logger;\n const profiles = config.agentProfiles;\n if (profiles.length === 0) return { count: 0, warnings: [] };\n\n const profilesSubdir = config.subdirs?.profiles ?? \"agent-profiles\";\n\n log(\"\\n--- Building agent instructions ---\");\n\n const allWarnings: string[] = [];\n let count = 0;\n\n for (const profile of profiles) {\n // Check all section files exist before rendering\n const sectionPaths: string[] = [];\n let missing = false;\n for (const section of profile.sections) {\n const found = findInIncludes(config.include, profilesSubdir, section);\n if (!found) {\n log(` SKIP ${profile.name}: missing section ${section}`);\n missing = true;\n break;\n }\n sectionPaths.push(found);\n }\n if (missing) continue;\n\n const agentContext = { ...config.context, agentName: profile.name };\n const renderOpts = config.customHelpers\n ? { helpers: config.customHelpers }\n : undefined;\n\n const renderedSections: string[] = [];\n for (let i = 0; i < profile.sections.length; i++) {\n const raw = fs.readFileSync(sectionPaths[i], \"utf-8\");\n const result = renderSkillTemplate(raw, agentContext, renderOpts);\n for (const w of result.warnings) {\n const msg = `${profile.name}/${profile.sections[i]}: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n renderedSections.push(result.rendered.trim());\n }\n\n const combined = renderedSections.join(\"\\n\\n\") + \"\\n\";\n for (const out of config.output) {\n const agentsDir = path.join(out, \"agent-profiles\");\n fs.mkdirSync(agentsDir, { recursive: true });\n fs.writeFileSync(\n path.join(agentsDir, `${profile.name}.md`),\n combined,\n \"utf-8\",\n );\n }\n\n log(` OK ${profile.name} → ${profile.name}.md (${combined.length} chars)`);\n count++;\n }\n\n return { count, warnings: allWarnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { renderSkillTemplate, slugToTitle } from \"../index.js\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Find the first existing directory across multiple include paths.\n */\nfunction findSubdir(includes: string[], subdir: string): string | undefined {\n for (const dir of includes) {\n const p = path.join(dir, subdir);\n if (fs.existsSync(p)) return p;\n }\n return undefined;\n}\n\n/**\n * Build SKILL.md files from Handlebars templates in skills-tpl/.\n * Each skill directory produces a SKILL.md + references/ folder.\n *\n * @returns Number of skills built and any warnings.\n */\nexport function buildSkillTemplates(config: ResolvedBuildConfig): {\n count: number;\n warnings: string[];\n} {\n const log = config.logger;\n const skillsTplSubdir = config.subdirs?.skillsTpl ?? \"skills-tpl\";\n const skillsTplDir = findSubdir(config.include, skillsTplSubdir);\n\n log(\"\\n--- Building SKILL.md files (templates) ---\");\n\n if (!skillsTplDir) {\n log(\" No skills-tpl/ directory — skipping.\");\n return { count: 0, warnings: [] };\n }\n\n const skillDirs = fs\n .readdirSync(skillsTplDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n .sort();\n\n const allWarnings: string[] = [];\n const renderOpts = config.customHelpers\n ? { helpers: config.customHelpers }\n : undefined;\n let count = 0;\n\n for (const skillName of skillDirs) {\n const skillDir = path.join(skillsTplDir, skillName);\n\n // Preamble\n const preamblePath = path.join(skillDir, \".preamble.md\");\n const preambleRaw = fs.existsSync(preamblePath)\n ? fs.readFileSync(preamblePath, \"utf-8\").trim()\n : \"\";\n let preamble = \"\";\n if (preambleRaw) {\n const r = renderSkillTemplate(preambleRaw, config.context, renderOpts);\n preamble = r.rendered;\n for (const w of r.warnings) {\n const msg = `${skillName}/.preamble.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n }\n\n // Scenario files (NN.name.md)\n const scenarioFiles = fs\n .readdirSync(skillDir)\n .filter((f) => /^\\d+\\..*\\.md$/.test(f))\n .sort();\n\n // Result file\n const resultPath = path.join(skillDir, \".result.md\");\n const hasResult = fs.existsSync(resultPath);\n\n if (!preamble && scenarioFiles.length === 0 && !hasResult) {\n log(` SKIP ${skillName}: no content files found`);\n continue;\n }\n\n // Render references into memory\n const files: Map<string, string> = new Map();\n const refLinks: string[] = [];\n\n for (const scenarioFile of scenarioFiles) {\n const content = fs\n .readFileSync(path.join(skillDir, scenarioFile), \"utf-8\")\n .trim();\n const r = renderSkillTemplate(content, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/${scenarioFile}: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(path.join(\"references\", scenarioFile), r.rendered + \"\\n\");\n const label = slugToTitle(\n scenarioFile.replace(/^\\d+\\./, \"\").replace(/\\.md$/, \"\"),\n );\n refLinks.push(\n `* **${label}** [references/${scenarioFile}](references/${scenarioFile})`,\n );\n }\n\n if (hasResult) {\n const content = fs.readFileSync(resultPath, \"utf-8\").trim();\n const r = renderSkillTemplate(content, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/.result.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(\n path.join(\"references\", \"expected-outcome.md\"),\n r.rendered + \"\\n\",\n );\n refLinks.push(\n `* **Expected Outcome** [references/expected-outcome.md](references/expected-outcome.md)`,\n );\n }\n\n // Build SKILL.md\n const description =\n config.skillDescriptions[skillName] ?? `${slugToTitle(skillName)} tasks`;\n\n const frontmatter = [\n \"---\",\n `name: ${skillName}`,\n `description: \"${description}\"`,\n \"metadata:\",\n \" author: Powerhouse\",\n ' version: \"1.0.0\"',\n \"---\",\n ].join(\"\\n\");\n\n const sections = [preamble];\n if (refLinks.length > 0) {\n sections.push(\"## Specific tasks\\n\\n\" + refLinks.join(\"\\n\"));\n }\n\n const skillMd =\n frontmatter + \"\\n\\n\" + sections.filter(Boolean).join(\"\\n\\n\") + \"\\n\";\n files.set(\"SKILL.md\", skillMd);\n\n // Copy .cli-docs.md if present (render through Handlebars)\n const cliDocsPath = path.join(skillDir, \".cli-docs.md\");\n if (fs.existsSync(cliDocsPath)) {\n const cliDocsRaw = fs.readFileSync(cliDocsPath, \"utf-8\").trim();\n if (cliDocsRaw) {\n const r = renderSkillTemplate(cliDocsRaw, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/.cli-docs.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(\".cli-docs.md\", r.rendered + \"\\n\");\n }\n }\n\n // Write to all output directories\n for (const out of config.output) {\n const outputDir = path.join(out, \"skills\", skillName);\n for (const [relPath, content] of files) {\n const fullPath = path.join(outputDir, relPath);\n fs.mkdirSync(path.dirname(fullPath), { recursive: true });\n fs.writeFileSync(fullPath, content, \"utf-8\");\n }\n }\n\n log(\n ` OK ${skillName} → SKILL.md + ${scenarioFiles.length + (hasResult ? 1 : 0)} references (${skillMd.length} chars)`,\n );\n count++;\n }\n\n return { count, warnings: allWarnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Copy external skills from skills-ext/ to the output directory without processing.\n *\n * @returns Number of skills copied.\n */\nexport function copyExternalSkills(config: ResolvedBuildConfig): number {\n const log = config.logger;\n const skillsExtSubdir = config.subdirs?.skillsExt ?? \"skills-ext\";\n\n log(\"\\n--- Copying external skills ---\");\n\n // Search all include dirs for skills-ext/\n let found = false;\n let total = 0;\n\n for (const dir of config.include) {\n const skillsExtDir = path.join(dir, skillsExtSubdir);\n if (!fs.existsSync(skillsExtDir)) continue;\n found = true;\n\n const skillDirs = fs\n .readdirSync(skillsExtDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n .sort();\n\n for (const skillName of skillDirs) {\n const srcDir = path.join(skillsExtDir, skillName);\n for (const out of config.output) {\n fs.cpSync(srcDir, path.join(out, \"skills\", skillName), {\n recursive: true,\n });\n }\n log(` OK ${skillName} → copied as-is`);\n }\n\n total += skillDirs.length;\n }\n\n if (!found) {\n log(\" No skills-ext/ directory — skipping.\");\n }\n\n return total;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { buildAgentProfiles } from \"./agent-profiles.js\";\nimport { buildSkillTemplates } from \"./skill-builder.js\";\nimport { copyExternalSkills } from \"./skill-copier.js\";\nimport type { AgentProfile, ResolvedBuildConfig } from \"./types.js\";\nimport type { CliMetadata } from \"../core/types.js\";\n\n/**\n * Path-driven skill/profile compilation (ph-clint-dev's pipeline). The paths\n * drive it; a package's `Cli` is an optional extra source (`cli`): its\n * metadata joins the template context as ph-clint-dev did it, so a template\n * can name `{{commands.<id>.description}}` or `{{services.<id>.name}}`.\n * Conventions:\n *\n * <skillsDir>/ include root (default: prompts/ then agents/)\n * agent-profiles/ profile section templates\n * skills-tpl/<skill>/ Handlebars skill templates → SKILL.md\n * skills-ext/<skill>/ external skills copied as-is\n * profiles.json optional [{ name, sections: [...] }]\n *\n * Output: <outDir> (default: dist/skills).\n */\nexport interface BuildSkillsOptions {\n rootDir: string;\n skillsDir?: string;\n agentsDir?: string;\n outDir?: string;\n context?: Record<string, unknown>;\n /**\n * The package's `Cli` (see `loadCli`). Only `getMetadata()` is read, which\n * starts nothing. Its metadata is spread over `context` (ph-clint-dev's\n * order: the Cli wins), its `prompts.skills` give the skill descriptions\n * and its `prompts.agents` the agent profiles; a `profiles.json` entry of\n * the same name replaces the Cli's.\n */\n cli?: { getMetadata(): CliMetadata };\n logger?: (msg: string) => void;\n}\n\nexport interface BuildSkillsResult {\n skills: number;\n profiles: number;\n copied: number;\n warnings: string[];\n outDir: string;\n}\n\nfunction firstExisting(\n rootDir: string,\n candidates: (string | undefined)[],\n): string[] {\n const dirs: string[] = [];\n for (const candidate of candidates) {\n if (!candidate) continue;\n const abs = path.resolve(rootDir, candidate);\n if (fs.existsSync(abs)) dirs.push(abs);\n }\n return dirs;\n}\n\nfunction readProfilesManifest(include: string[]): AgentProfile[] {\n for (const dir of include) {\n const manifest = path.join(dir, \"profiles.json\");\n if (fs.existsSync(manifest)) {\n try {\n return JSON.parse(fs.readFileSync(manifest, \"utf8\")) as AgentProfile[];\n } catch {\n return [];\n }\n }\n }\n return [];\n}\n\nexport async function buildSkills(\n options: BuildSkillsOptions,\n): Promise<BuildSkillsResult> {\n const log = options.logger ?? console.log;\n const include = firstExisting(options.rootDir, [\n options.skillsDir,\n options.agentsDir,\n \"prompts\",\n \"agents\",\n ]);\n const outDir = path.resolve(options.rootDir, options.outDir ?? \"dist/skills\");\n\n if (include.length === 0) {\n log(\n \"No prompt template directories found (prompts/ or agents/) — nothing to build.\",\n );\n return { skills: 0, profiles: 0, copied: 0, warnings: [], outDir };\n }\n\n const meta = options.cli?.getMetadata();\n const skillDescriptions: Record<string, string> = {};\n for (const [id, skill] of Object.entries(meta?.prompts?.skills ?? {})) {\n skillDescriptions[id] =\n typeof skill === \"string\" ? skill : skill.description;\n }\n const manifestProfiles = readProfilesManifest(include);\n const agentProfiles = [\n ...Object.values(meta?.prompts?.agents ?? {})\n .filter((a) => !manifestProfiles.some((p) => p.name === a.name))\n .map(({ name, sections }) => ({ name, sections })),\n ...manifestProfiles,\n ];\n\n const resolved: ResolvedBuildConfig = {\n include,\n output: [outDir],\n context: { builtAt: new Date().toISOString(), ...options.context, ...meta },\n agentProfiles,\n skillDescriptions,\n clean: true,\n logger: log,\n };\n\n for (const dir of resolved.output) {\n if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true });\n }\n\n const profiles = buildAgentProfiles(resolved);\n const templates = buildSkillTemplates(resolved);\n const copied = copyExternalSkills(resolved);\n\n return {\n skills: templates.count,\n profiles: profiles.count,\n copied,\n warnings: [...profiles.warnings, ...templates.warnings],\n outDir,\n };\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,eACP,UACA,QACA,UACoB;CACpB,KAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,IAAI,KAAK,KAAK,KAAK,QAAQ,QAAQ;EACzC,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO;CAC/B;AAEF;;;;;;;AAQA,SAAgB,mBAAmB,QAGjC;CACA,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,OAAO;CACxB,IAAI,SAAS,WAAW,GAAG,OAAO;EAAE,OAAO;EAAG,UAAU,CAAC;CAAE;CAE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AU,SAAS;EACnB;EACA,UAAU,CAAC,GAAG,SAAS,UAAU,GAAG,UAAU,QAAQ;EACtD;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { It as Trigger, Lt as TriggerContext, R as Command, S as IAttachmentService, U as EmitFn, c as FolderOperations, d as ReactorSetupContext, et as Logger, f as ReactorWrites, g as SubscriptionConfig, h as RemoteReactorSource, i as DriveConfig, m as RemoteReactorConfig, n as AttachmentRef$1, o as EnsureDriveClient, p as RegistryEntry, r as DocumentRegistry, t as AnyRegistry, u as ReactorContext, v as TypedReactorClient, z as CommandContext, zt as WorkItem } from "./types-
|
|
1
|
+
import { It as Trigger, Lt as TriggerContext, R as Command, S as IAttachmentService, U as EmitFn, c as FolderOperations, d as ReactorSetupContext, et as Logger, f as ReactorWrites, g as SubscriptionConfig, h as RemoteReactorSource, i as DriveConfig, m as RemoteReactorConfig, n as AttachmentRef$1, o as EnsureDriveClient, p as RegistryEntry, r as DocumentRegistry, t as AnyRegistry, u as ReactorContext, v as TypedReactorClient, z as CommandContext, zt as WorkItem } from "./types-DbQKfvWc.mjs";
|
|
2
2
|
import { ReactorProtocol } from "@powerhousedao/host-core";
|
|
3
3
|
import { IReactorClient } from "@powerhousedao/reactor";
|
|
4
4
|
import { DocumentModelModule, ISigner, SignaturePolicy } from "@powerhousedao/shared/document-model";
|
|
@@ -386,4 +386,4 @@ declare function attachDefaultReactor<R extends DocumentRegistry = AnyRegistry>(
|
|
|
386
386
|
//#endregion
|
|
387
387
|
export { createDocumentChangeTrigger as A, attachRemoteReactor as C, InferRegistry as D, ActionOf as E, defineRegistry as O, RemoteReactorAttachment as S, bridgeSubscriptions as T, SignerNotReadyError as _, fileToBlob as a, signerReady as b, isAttachmentAlreadyExists as c, createFolderOperations as d, isDocType as f, SignaturePolicy as g, createReactorWrites as h, asRef as i, DocumentChangeTriggerOptions as k, createAttachmentCommands as l, ReactorWritesOptions as m, attachDefaultReactor as n, getAttachmentService as o, ReactorWritesHandle as p, resolveRemoteReactorConfig as r, inferMimeType as s, AttachDefaultReactorOptions as t, createFolderCommands as u, createGatedSigner as v, ensureDrive as w, AttachRemoteReactorOptions as x, policyOfHeader as y };
|
|
388
388
|
export {};
|
|
389
|
-
//# sourceMappingURL=index-
|
|
389
|
+
//# sourceMappingURL=index-CfHcet4v.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-CfHcet4v.d.mts","names":[],"sources":["../src/integrations/powerhouse/change-trigger.ts","../src/integrations/powerhouse/registry.ts","../src/integrations/powerhouse/subscriptions.ts","../src/integrations/powerhouse/drive.ts","../src/integrations/powerhouse/remote-reactor.ts","../src/integrations/powerhouse/signing.ts","../src/integrations/powerhouse/writes.ts","../src/integrations/powerhouse/type-guard.ts","../src/integrations/powerhouse/folders.ts","../src/integrations/powerhouse/attachment-commands.ts","../src/integrations/powerhouse/attachment.ts","../src/integrations/powerhouse/index.ts"],"mappings":";;;;;;;UAkBiB,6BACf,UAAU,kBACV,gBAAgB,YAChB,UAAU,yBACV;EAAiB;;EAAsB;;;EAGvC;;EAGA,cAAc,IAAI;;;;;;;;;EAUlB,wBAGM,KAAK,eAAe,QAAQ,SAAS,OAClC;;;;;EAMT;;;;;;EAOA,UACE,KAAK,EAAE,gBACP,KAAK,eAAe,QAAQ,SAAS,iBACxB;;;;;;EAOf,WACE,MAAM,MAAM,EAAE,iBACd,KAAK,eAAe,QAAQ,SAAS,OAClC,QAAQ;;;;;;EAOb;;;;;;EAOA,cAAc;;;;;;;;;;;;;;;;;;;;iBAqBA,4BACd,UAAU,mBAAmB,aAC7B,gBAAgB,mBAAmB,YACnC,UAAU,yBACV;EAAiB;;EAAsB;GAEvC,SAAS,6BAA6B,GAAG,GAAG,SAAS,UACpD,QAAQ,QAAQ,SAAS;;;;;;;;;;;;;;KCnFhB,SAAS,KAAK;EAAY,eAAe;IACjD,gBAAgB,mBAAmB,wBAAwB,KACzD,IACA,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sa,qBAAqB,WAAW,mBAAmB;;;iBCrUnD,4BAA4B;;;;;;;;iBCrBtB,qBACpB,KAAK,KAAK,6DACT,QAAQ;iBAcK,MAAM,cAAc;iBAKpB,0BACd,eACC;EAAS;EAAa;;iBAwBT,cAAc,kBAAkB;iBAO1B,WACpB,kBACA,mBACC,QAAQ;;;;;;;UCmBM,4BACf,UAAU,mBAAmB,qBACrB,oBAAoB;;;EAG5B;;;;;;iBAOoB,2BACpB,UAAU,mBAAmB,aAE7B,QAAQ,oBAAoB,gBAC5B,OAAO,oBAAoB,KAC1B,QAAQ,oBAAoB;;;;;;;;;;;;;iBAiDT,qBACpB,UAAU,mBAAmB,aAE7B,KAAK,oBAAoB,IACzB,SAAS,4BAA4B,KACpC,QAAQ,eAAe"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { $ as LogLevel, A as AgentStreamOptions, At as SkillConfig, B as CommandServiceDefinition, Bt as WorkdirStore, C as ReserveAttachmentOptions, Ct as ServiceDefinition, D as AgentPromptInput, Dt as ServiceManager, E as AgentProfileConfig, Et as ServiceInstanceStatus, F as Cli, Ft as ToolResultChunk, G as ErrorChunk, Gt as scanProjects, H as CoreContext, Ht as SkillInfo, I as CliMetadata, It as Trigger, J as InferConfig, K as EventBus, L as CliOptions, Lt as TriggerContext, M as BootstrapOptions, Mt as TextDeltaChunk, N as BootstrapResult, Nt as ToolCallChunk, O as AgentProvider, Ot as ServiceStartOptions, P as CaptureDefinition, Pt as ToolOutputChunk, Q as LifecycleInitContext, R as Command, Rt as TriggerOptions, S as IAttachmentService, St as ServiceBuildContext, T as AgentLoader, Tt as ServiceHostRun, U as EmitFn, Ut as readSkills, V as ConfigEnvVar, Vt as WrapRegistry, W as EndpointType, Wt as PROJECT_INDICATORS, X as LifecycleHandle, Y as InteractiveConfig, Z as LifecycleHook, _ as TypedDocumentChangeEvent, _t as Routine, a as DriveEntry, at as PreflightResult, b as AttachmentResponse, bt as RunOptions, c as FolderOperations, ct as ProcessRunOptions, d as ReactorSetupContext, dt as PromptConfig, et as Logger, f as ReactorWrites, ft as PromptsConfig, g as SubscriptionConfig, gt as ResolvedInteractiveConfig, h as RemoteReactorSource, ht as Resolvable, i as DriveConfig, it as PreflightContext, j as BootTimings, jt as StreamChunk, k as AgentSetupContext, kt as ServiceStatus, l as ReactorConfiguration, lt as ProjectScanResult, m as RemoteReactorConfig, mt as ReadinessPattern, n as AttachmentRef, nt as PhClintEvents, o as EnsureDriveClient, ot as ProcessHandle, p as RegistryEntry, pt as ReadinessConfig, q as HostServiceDefinition, r as DocumentRegistry, rt as PreflightCheck, s as FolderEntry, st as ProcessManager, t as AnyRegistry, tt as OnFn, u as ReactorContext, ut as ProjectScanner, v as TypedReactorClient, vt as RoutineConfig, w as AgentContentPart, wt as ServiceDefinitionBase, x as AttachmentUploadResult, xt as RunReactor, y as AttachmentHeader, yt as RoutineStatus, z as CommandContext, zt as WorkItem } from "./types-
|
|
2
|
-
import { A as createDocumentChangeTrigger, D as InferRegistry, E as ActionOf, O as defineRegistry, _ as SignerNotReadyError, b as signerReady, f as isDocType, g as SignaturePolicy, k as DocumentChangeTriggerOptions, n as attachDefaultReactor, r as resolveRemoteReactorConfig, t as AttachDefaultReactorOptions, y as policyOfHeader } from "./index-
|
|
3
|
-
import { i as ReplSessionOptions, n as ReplOutput, r as ReplSession, t as HistoryEntry } from "./types-
|
|
1
|
+
import { $ as LogLevel, A as AgentStreamOptions, At as SkillConfig, B as CommandServiceDefinition, Bt as WorkdirStore, C as ReserveAttachmentOptions, Ct as ServiceDefinition, D as AgentPromptInput, Dt as ServiceManager, E as AgentProfileConfig, Et as ServiceInstanceStatus, F as Cli, Ft as ToolResultChunk, G as ErrorChunk, Gt as scanProjects, H as CoreContext, Ht as SkillInfo, I as CliMetadata, It as Trigger, J as InferConfig, K as EventBus, L as CliOptions, Lt as TriggerContext, M as BootstrapOptions, Mt as TextDeltaChunk, N as BootstrapResult, Nt as ToolCallChunk, O as AgentProvider, Ot as ServiceStartOptions, P as CaptureDefinition, Pt as ToolOutputChunk, Q as LifecycleInitContext, R as Command, Rt as TriggerOptions, S as IAttachmentService, St as ServiceBuildContext, T as AgentLoader, Tt as ServiceHostRun, U as EmitFn, Ut as readSkills, V as ConfigEnvVar, Vt as WrapRegistry, W as EndpointType, Wt as PROJECT_INDICATORS, X as LifecycleHandle, Y as InteractiveConfig, Z as LifecycleHook, _ as TypedDocumentChangeEvent, _t as Routine, a as DriveEntry, at as PreflightResult, b as AttachmentResponse, bt as RunOptions, c as FolderOperations, ct as ProcessRunOptions, d as ReactorSetupContext, dt as PromptConfig, et as Logger, f as ReactorWrites, ft as PromptsConfig, g as SubscriptionConfig, gt as ResolvedInteractiveConfig, h as RemoteReactorSource, ht as Resolvable, i as DriveConfig, it as PreflightContext, j as BootTimings, jt as StreamChunk, k as AgentSetupContext, kt as ServiceStatus, l as ReactorConfiguration, lt as ProjectScanResult, m as RemoteReactorConfig, mt as ReadinessPattern, n as AttachmentRef, nt as PhClintEvents, o as EnsureDriveClient, ot as ProcessHandle, p as RegistryEntry, pt as ReadinessConfig, q as HostServiceDefinition, r as DocumentRegistry, rt as PreflightCheck, s as FolderEntry, st as ProcessManager, t as AnyRegistry, tt as OnFn, u as ReactorContext, ut as ProjectScanner, v as TypedReactorClient, vt as RoutineConfig, w as AgentContentPart, wt as ServiceDefinitionBase, x as AttachmentUploadResult, xt as RunReactor, y as AttachmentHeader, yt as RoutineStatus, z as CommandContext, zt as WorkItem } from "./types-DbQKfvWc.mjs";
|
|
2
|
+
import { A as createDocumentChangeTrigger, D as InferRegistry, E as ActionOf, O as defineRegistry, _ as SignerNotReadyError, b as signerReady, f as isDocType, g as SignaturePolicy, k as DocumentChangeTriggerOptions, n as attachDefaultReactor, r as resolveRemoteReactorConfig, t as AttachDefaultReactorOptions, y as policyOfHeader } from "./index-CfHcet4v.mjs";
|
|
3
|
+
import { i as ReplSessionOptions, n as ReplOutput, r as ReplSession, t as HistoryEntry } from "./types-3TnDjQ1w.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
+
import { ControlChannel, ControlRecord } from "@powerhousedao/host-core/control-channel";
|
|
5
6
|
import Handlebars from "handlebars";
|
|
6
7
|
import http from "node:http";
|
|
7
8
|
//#region src/core/pkg.d.ts
|
|
@@ -344,6 +345,35 @@ export declare function formatStatus(s: ServiceInstanceStatus): string;
|
|
|
344
345
|
*/
|
|
345
346
|
export declare function createServiceCommands(def: ServiceDefinition<any>): Command[];
|
|
346
347
|
//#endregion
|
|
348
|
+
//#region src/core/service-control.d.ts
|
|
349
|
+
/**
|
|
350
|
+
* Stops the service's running instance, if any, and starts it again where
|
|
351
|
+
* and as it ran. Resolves with the new instance's id.
|
|
352
|
+
*/
|
|
353
|
+
export declare function restartService(services: ServiceManager, id: string, instanceId: string | undefined, workdir: string): Promise<string>;
|
|
354
|
+
/** Answers service requests on `channel` from `services`. */
|
|
355
|
+
export declare function serveServices(channel: ControlChannel, services: ServiceManager, cli: {
|
|
356
|
+
name: string;
|
|
357
|
+
version: string;
|
|
358
|
+
workdir: string;
|
|
359
|
+
}): void;
|
|
360
|
+
/**
|
|
361
|
+
* A manager whose instances live in the process behind `control`: start,
|
|
362
|
+
* stop and list act there; logs, definitions and scans are read here (the
|
|
363
|
+
* files are the same). Undefined when that process does not answer service
|
|
364
|
+
* requests.
|
|
365
|
+
*/
|
|
366
|
+
export declare function connectRemoteServices(local: ServiceManager, control: ControlRecord): Promise<ServiceManager | undefined>;
|
|
367
|
+
/** Thrown by a start that cannot outlive its command. */
|
|
368
|
+
export declare class ServiceStartRefused extends Error {
|
|
369
|
+
constructor(id: string, serveCommand: string | undefined);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* The manager of a command that ends with nothing running to forward to:
|
|
373
|
+
* everything but `start`, which is refused with where to run instead.
|
|
374
|
+
*/
|
|
375
|
+
export declare function refuseServiceStarts(local: ServiceManager, serveCommand: string | undefined): ServiceManager;
|
|
376
|
+
//#endregion
|
|
347
377
|
//#region src/core/project-mapping.d.ts
|
|
348
378
|
interface ProjectMapping {
|
|
349
379
|
/** Project name. */
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/pkg.ts","../src/core/command.ts","../src/core/errors.ts","../src/core/logger.ts","../src/core/cli.ts","../src/core/trigger.ts","../src/core/types-binding.ts","../src/core/schema.ts","../src/core/store.ts","../src/core/config.ts","../src/core/config-command.ts","../src/core/workdir.ts","../src/core/events.ts","../src/core/processes.ts","../src/core/services.ts","../src/core/service-command.ts","../src/core/project-mapping.ts","../src/core/preflight.ts","../src/core/help-command.ts","../src/core/init.ts","../src/core/skill-commands.ts","../src/core/templates.ts","../src/core/routine.ts","../src/core/routine-service.ts","../src/core/stream.ts","../src/core/proxy-routes.ts","../src/core/proxy.ts","../src/interactive/session.ts","../src/interactive/router.ts","../src/interactive/completions.ts","../src/interactive/markdown.ts","../src/core/wraps.ts","../src/core/lifecycle.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/pkg.ts","../src/core/command.ts","../src/core/errors.ts","../src/core/logger.ts","../src/core/cli.ts","../src/core/trigger.ts","../src/core/types-binding.ts","../src/core/schema.ts","../src/core/store.ts","../src/core/config.ts","../src/core/config-command.ts","../src/core/workdir.ts","../src/core/events.ts","../src/core/processes.ts","../src/core/services.ts","../src/core/service-command.ts","../src/core/service-control.ts","../src/core/project-mapping.ts","../src/core/preflight.ts","../src/core/help-command.ts","../src/core/init.ts","../src/core/skill-commands.ts","../src/core/templates.ts","../src/core/routine.ts","../src/core/routine-service.ts","../src/core/stream.ts","../src/core/proxy-routes.ts","../src/core/proxy.ts","../src/interactive/session.ts","../src/interactive/router.ts","../src/interactive/completions.ts","../src/interactive/markdown.ts","../src/core/wraps.ts","../src/core/lifecycle.ts"],"mappings":";;;;;;;;UAgBiB;;EAEf;;EAEA;;EAEA;;;;;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ACA,QAAQ;;UAGO;WACN;WACA;WACA;EACT,SAAS,OAAO;EAChB,qBAAqB;EACrB,aAAa,cAAc,SAAS;EACpC,QAAQ;;;;;wBAwGY,kBACpB,SAAS,qBACR,QAAQ;;;;;;;;;;wBCAK,kBAAkB,MAAM,qBAAqB;;;;;;;UC/I5C;EACf;EACA;EACA;EACA;;;;;;;;;;wBAWc,eACd,eACA,sBACA,8BACC;;;;;;;;;wBAyCa,aAAa;;;;;;;;;;;;;wBCGb,eAAe,eAAe,UAAU;;;;;;wBA6FxC,oBACd,oBACA,eACA,UAAU;;;;;;;wBA4BI,mBACd,eACA,UAAU;;;;;;;;;;wBAyBI,gBAAgB,eAAe;;;;;;;;;;wBCpK/B,eAAe;;;;;;;;;;qBC9ClB,gBAAgB;;;;;;;;wBAuCb,aAAa,SAAS,oBAAoB;;;UCxCzC;;EAEf,OAAO;;;;;;EAMP,gBAAgB;;EAEhB,SAAS;;;;;;;;;;;wBAYW,cACpB,OAAO,iBACP,KAAK,uBACJ,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as restartService, B as userConfigPath, C as installSkills, D as ServiceStartRefused, E as formatStatus, F as configKeyToEnvVar, H as createLogger, I as getMissingRequiredFields, L as localConfigPath, M as createConfigCommand, N as generateConfigCommandHelp, O as connectRemoteServices, P as resolveWorkdir, R as resolveConfig, S as readSkills, T as createServiceCommands, U as formatZodError, V as userStoreFolder, W as readPackageInfo, _ as createSkillCommands, a as initLifecycle, b as registerDefaultHelpers, c as tokenizeArgs, d as createRoutine, f as IDENTITY_WRAPS, g as DEFAULT_SKILL_INSTRUCTION, h as createEventBus, i as defineCli, j as serveServices, k as refuseServiceStarts, l as createCompositeServiceManager, m as createProcessManager, n as createTypes, o as createReplSession, p as composeWraps, r as defineTrigger, s as parseReplInput, t as getProjectMapping, u as createRoutineServiceAdapter, v as isSkillInvocation, w as createHelpCommand, x as renderSkillTemplate, y as extractTemplateVars, z as toUpperSnake } from "./src-BmMd0Wl4.mjs";
|
|
2
2
|
import { n as slugToTitle, t as getSchemaFields } from "./schema-BEKAZGyT.mjs";
|
|
3
3
|
import { C as isDocType, D as policyOfHeader, M as createDocumentChangeTrigger, N as defineCommand, O as signerReady, T as SignerNotReadyError, j as defineRegistry, n as resolveRemoteReactorConfig, t as attachDefaultReactor } from "./powerhouse-3XZmdY3_.mjs";
|
|
4
4
|
import { S as renderStream, _ as isPortFree, a as getGhostSuggestion, f as PROJECT_INDICATORS, g as checkWorkdir, h as checkPort, i as getCompletions, l as resolveServiceName, m as checkCommand, n as applyCompletion, o as createServiceManager, p as scanProjects, r as getCompletionSuffix, s as defineService, t as renderMarkdown, x as formatStreamChunk } from "./markdown-BUeGwhbR.mjs";
|
|
5
5
|
import { n as createWorkdirStore, t as createMemoryWorkdirStore } from "./store-CxqB-OrX.mjs";
|
|
6
6
|
import { t as createProxyServer } from "./proxy-ji3EHzLn.mjs";
|
|
7
|
-
export { DEFAULT_SKILL_INSTRUCTION, IDENTITY_WRAPS, PROJECT_INDICATORS, SignerNotReadyError, applyCompletion, attachDefaultReactor, checkCommand, checkPort, checkWorkdir, composeWraps, configKeyToEnvVar, createCompositeServiceManager, createConfigCommand, createDocumentChangeTrigger, createEventBus, createHelpCommand, createLogger, createMemoryWorkdirStore, createProcessManager, createProxyServer, createReplSession, createRoutine, createRoutineServiceAdapter, createServiceCommands, createServiceManager, createSkillCommands, createTypes, createWorkdirStore, defineCli, defineCommand, defineRegistry, defineService, defineTrigger, extractTemplateVars, formatStatus, formatStreamChunk, formatZodError, generateConfigCommandHelp, getCompletionSuffix, getCompletions, getGhostSuggestion, getMissingRequiredFields, getProjectMapping, getSchemaFields, initLifecycle, installSkills, isDocType, isPortFree, isSkillInvocation, localConfigPath, parseReplInput, policyOfHeader, readPackageInfo, readSkills, registerDefaultHelpers, renderMarkdown, renderSkillTemplate, renderStream, resolveConfig, resolveRemoteReactorConfig, resolveServiceName, resolveWorkdir, scanProjects, signerReady, slugToTitle, toUpperSnake, tokenizeArgs, userConfigPath, userStoreFolder };
|
|
7
|
+
export { DEFAULT_SKILL_INSTRUCTION, IDENTITY_WRAPS, PROJECT_INDICATORS, ServiceStartRefused, SignerNotReadyError, applyCompletion, attachDefaultReactor, checkCommand, checkPort, checkWorkdir, composeWraps, configKeyToEnvVar, connectRemoteServices, createCompositeServiceManager, createConfigCommand, createDocumentChangeTrigger, createEventBus, createHelpCommand, createLogger, createMemoryWorkdirStore, createProcessManager, createProxyServer, createReplSession, createRoutine, createRoutineServiceAdapter, createServiceCommands, createServiceManager, createSkillCommands, createTypes, createWorkdirStore, defineCli, defineCommand, defineRegistry, defineService, defineTrigger, extractTemplateVars, formatStatus, formatStreamChunk, formatZodError, generateConfigCommandHelp, getCompletionSuffix, getCompletions, getGhostSuggestion, getMissingRequiredFields, getProjectMapping, getSchemaFields, initLifecycle, installSkills, isDocType, isPortFree, isSkillInvocation, localConfigPath, parseReplInput, policyOfHeader, readPackageInfo, readSkills, refuseServiceStarts, registerDefaultHelpers, renderMarkdown, renderSkillTemplate, renderStream, resolveConfig, resolveRemoteReactorConfig, resolveServiceName, resolveWorkdir, restartService, scanProjects, serveServices, signerReady, slugToTitle, toUpperSnake, tokenizeArgs, userConfigPath, userStoreFolder };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bt as WorkdirStore, Dt as ServiceManager, O as AgentProvider, R as Command, et as Logger, jt as StreamChunk, k as AgentSetupContext, z as CommandContext } from "../../types-
|
|
1
|
+
import { Bt as WorkdirStore, Dt as ServiceManager, O as AgentProvider, R as Command, et as Logger, jt as StreamChunk, k as AgentSetupContext, z as CommandContext } from "../../types-DbQKfvWc.mjs";
|
|
2
2
|
//#region src/integrations/mastra/types.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Options for getTools().
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ReserveAttachmentOptions, S as IAttachmentService, _ as TypedDocumentChangeEvent, a as DriveEntry, b as AttachmentResponse, c as FolderOperations, d as ReactorSetupContext, f as ReactorWrites, g as SubscriptionConfig, h as RemoteReactorSource, i as DriveConfig, l as ReactorConfiguration, m as RemoteReactorConfig, n as AttachmentRef, o as EnsureDriveClient, p as RegistryEntry, r as DocumentRegistry, s as FolderEntry, t as AnyRegistry, u as ReactorContext, v as TypedReactorClient, x as AttachmentUploadResult, y as AttachmentHeader } from "../../types-
|
|
2
|
-
import { A as createDocumentChangeTrigger, C as attachRemoteReactor, D as InferRegistry, E as ActionOf, O as defineRegistry, S as RemoteReactorAttachment, T as bridgeSubscriptions, _ as SignerNotReadyError, a as fileToBlob, b as signerReady, c as isAttachmentAlreadyExists, d as createFolderOperations, f as isDocType, g as SignaturePolicy, h as createReactorWrites, i as asRef, k as DocumentChangeTriggerOptions, l as createAttachmentCommands, m as ReactorWritesOptions, n as attachDefaultReactor, o as getAttachmentService, p as ReactorWritesHandle, r as resolveRemoteReactorConfig, s as inferMimeType, t as AttachDefaultReactorOptions, u as createFolderCommands, v as createGatedSigner, w as ensureDrive, x as AttachRemoteReactorOptions, y as policyOfHeader } from "../../index-
|
|
1
|
+
import { C as ReserveAttachmentOptions, S as IAttachmentService, _ as TypedDocumentChangeEvent, a as DriveEntry, b as AttachmentResponse, c as FolderOperations, d as ReactorSetupContext, f as ReactorWrites, g as SubscriptionConfig, h as RemoteReactorSource, i as DriveConfig, l as ReactorConfiguration, m as RemoteReactorConfig, n as AttachmentRef, o as EnsureDriveClient, p as RegistryEntry, r as DocumentRegistry, s as FolderEntry, t as AnyRegistry, u as ReactorContext, v as TypedReactorClient, x as AttachmentUploadResult, y as AttachmentHeader } from "../../types-DbQKfvWc.mjs";
|
|
2
|
+
import { A as createDocumentChangeTrigger, C as attachRemoteReactor, D as InferRegistry, E as ActionOf, O as defineRegistry, S as RemoteReactorAttachment, T as bridgeSubscriptions, _ as SignerNotReadyError, a as fileToBlob, b as signerReady, c as isAttachmentAlreadyExists, d as createFolderOperations, f as isDocType, g as SignaturePolicy, h as createReactorWrites, i as asRef, k as DocumentChangeTriggerOptions, l as createAttachmentCommands, m as ReactorWritesOptions, n as attachDefaultReactor, o as getAttachmentService, p as ReactorWritesHandle, r as resolveRemoteReactorConfig, s as inferMimeType, t as AttachDefaultReactorOptions, u as createFolderCommands, v as createGatedSigner, w as ensureDrive, x as AttachRemoteReactorOptions, y as policyOfHeader } from "../../index-CfHcet4v.mjs";
|
|
3
3
|
export { type ActionOf, type AnyRegistry, AttachDefaultReactorOptions, type AttachRemoteReactorOptions, type AttachmentHeader, type AttachmentRef, type AttachmentResponse, type AttachmentUploadResult, type DocumentChangeTriggerOptions, type DocumentRegistry, type DriveConfig, type DriveEntry, type EnsureDriveClient, type FolderEntry, type FolderOperations, type IAttachmentService, type InferRegistry, type ReactorConfiguration, type ReactorContext, type ReactorSetupContext, type ReactorWrites, type ReactorWritesHandle, type ReactorWritesOptions, type RegistryEntry, type RemoteReactorAttachment, type RemoteReactorConfig, type RemoteReactorSource, type ReserveAttachmentOptions, type SignaturePolicy, SignerNotReadyError, type SubscriptionConfig, type TypedDocumentChangeEvent, type TypedReactorClient, asRef, attachDefaultReactor, attachRemoteReactor, bridgeSubscriptions, createAttachmentCommands, createDocumentChangeTrigger, createFolderCommands, createFolderOperations, createGatedSigner, createReactorWrites, defineRegistry, ensureDrive, fileToBlob, getAttachmentService, inferMimeType, isAttachmentAlreadyExists, isDocType, policyOfHeader, resolveRemoteReactorConfig, signerReady };
|
|
4
4
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as Cli, bt as RunOptions } from "../types-
|
|
1
|
+
import { F as Cli, bt as RunOptions } from "../types-DbQKfvWc.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { RunnerArgsSchema, RunnerContext } from "@powerhousedao/host-core";
|
|
4
4
|
//#region src/runners/cli-runner.d.ts
|
|
@@ -299,6 +299,10 @@ export interface RunCliOptions {
|
|
|
299
299
|
signal?: AbortSignal;
|
|
300
300
|
/** The compound's other members (see `RunOptions.members`). */
|
|
301
301
|
members?: RunOptions["members"];
|
|
302
|
+
/** A running instance's control channel (see `RunOptions.remoteServices`). */
|
|
303
|
+
remoteServices?: RunOptions["remoteServices"];
|
|
304
|
+
/** How the Cli is started to keep running (see `RunOptions.serveCommand`). */
|
|
305
|
+
serveCommand?: string;
|
|
302
306
|
}
|
|
303
307
|
/**
|
|
304
308
|
* Runs `cli` in this process's terminal: its stdin, stdout and stderr, and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-runner.d.mts","names":[],"sources":["../../src/runners/cli-runner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"cli-runner.d.mts","names":[],"sources":["../../src/runners/cli-runner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBA4Ca;;;qBAIA;;;qBAIA;;qBAGA,YAAY;;qBA8BZ,oBAAkB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6B,EAAA,KAAA;;qBAE/C,YAAU,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAqB,EAAA,KAAA;;YAGhC,eAAe,EAAE,aAAa;;YAE9B,UAAU,EAAE,cAAc;QAE9B;YACI;IACR;MACE,MAAM;MACN,SAAS;;;;;;;;;wBAkEO,QACpB,qBACA,uBACC,QAAQ;;;;;;wBAkCW,WACpB,sBACC,QAAQ;iBAuCM;;EAEf;;;;EAIA;;EAEA;;;EAGA,aAAa,OAAO;;;EAGpB;;EAEA,uBAAuB;;EAEvB,SAAS;;EAET,UAAU;;EAEV,iBAAiB;;EAEjB;;;;;;;;;wBAUoB,OACpB,KAAK,KACL,SAAS,gBACR;;iBA+Hc;EACf,SAAS;EACT,OAAO;;EAEP,QAAQ;;;EAGR,YAAY;;;;;;;;wBA6EQ,IACpB,MAAM,SACN,KAAK,gBACJ,QAAQ;;;;;;;;;wBAuDW,MAAM,MAAM,SAAS,KAAK,gBAAgB"}
|
|
@@ -4,7 +4,7 @@ import fs from "node:fs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
import { STOP_ON_STDIN_ENV, STOP_STREAM_LIMIT_MS, clearRunRecord, probeRun, readProjectName, readRunRecord, runRecordKey, stopStreamOf, writeRunRecord } from "@powerhousedao/host-core";
|
|
7
|
+
import { STOP_ON_STDIN_ENV, STOP_STREAM_LIMIT_MS, clearRunRecord, controlRecordOf, ensureProcessControlChannel, probeRun, readProjectName, readRunRecord, runRecordKey, stopStreamOf, writeRunRecord } from "@powerhousedao/host-core";
|
|
8
8
|
import { defineHostSchemas } from "@powerhousedao/host-core/schema";
|
|
9
9
|
//#region src/runners/cli-runner.ts
|
|
10
10
|
/**
|
|
@@ -185,7 +185,9 @@ async function runCli(cli, options) {
|
|
|
185
185
|
...reactor ? { reactor } : {},
|
|
186
186
|
...options.onServe ? { onServe: options.onServe } : {},
|
|
187
187
|
...options.signal ? { signal: options.signal } : {},
|
|
188
|
-
...options.members ? { members: options.members } : {}
|
|
188
|
+
...options.members ? { members: options.members } : {},
|
|
189
|
+
...options.remoteServices ? { remoteServices: options.remoteServices } : {},
|
|
190
|
+
...options.serveCommand ? { serveCommand: options.serveCommand } : {}
|
|
189
191
|
});
|
|
190
192
|
} catch (error) {
|
|
191
193
|
console.error(error instanceof Error ? error.message : String(error));
|
|
@@ -198,14 +200,16 @@ async function runCli(cli, options) {
|
|
|
198
200
|
/**
|
|
199
201
|
* The record of a Cli that keeps running: what `ph run <host> --stop` reads.
|
|
200
202
|
* A one-shot writes none and takes no lock, so it runs beside a serving
|
|
201
|
-
* instance; a second serving instance is refused.
|
|
203
|
+
* instance; a second serving instance is refused. The record names the
|
|
204
|
+
* process's control channel, which the Cli answers service requests on.
|
|
202
205
|
*/
|
|
203
|
-
function recordServing(projectRoot, hostName, verb, hostPackage) {
|
|
206
|
+
async function recordServing(projectRoot, hostName, verb, hostPackage) {
|
|
204
207
|
const projectName = readProjectName(projectRoot);
|
|
205
208
|
const key = runRecordKey(hostName, hostPackage);
|
|
206
209
|
const probe = probeRun(projectRoot, key, projectName);
|
|
207
210
|
if (probe.status === "live" && probe.record.pid !== process.pid) throw new Error(`${key} is already running for this project (pid ${probe.record.pid}). Stop it with \`ph run ${key} --stop\`, or run a command beside it: \`ph run ${key} -- <command>\`.`);
|
|
208
211
|
if (probe.status === "foreign") throw new Error(`.ph/run/${key}.json describes a live "${probe.record.projectName}", but this project is "${projectName}". Refusing to start a second instance.`);
|
|
212
|
+
const control = (await ensureProcessControlChannel())?.record;
|
|
209
213
|
writeRunRecord(projectRoot, {
|
|
210
214
|
version: 2,
|
|
211
215
|
host: hostName,
|
|
@@ -215,7 +219,8 @@ function recordServing(projectRoot, hostName, verb, hostPackage) {
|
|
|
215
219
|
verb,
|
|
216
220
|
pid: process.pid,
|
|
217
221
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
218
|
-
outputs: {}
|
|
222
|
+
outputs: {},
|
|
223
|
+
...control ? { extra: { control } } : {}
|
|
219
224
|
});
|
|
220
225
|
process.on("exit", () => {
|
|
221
226
|
if (readRunRecord(projectRoot, key)?.pid === process.pid) clearRunRecord(projectRoot, key);
|
|
@@ -257,9 +262,13 @@ function inStack(cli, host, ctx, url) {
|
|
|
257
262
|
workdir: ctx.projectRoot,
|
|
258
263
|
signal: stop.signal,
|
|
259
264
|
members: ctx.foreground.members,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
265
|
+
serveCommand: `ph run ${ctx.foreground.stack ?? stack}`,
|
|
266
|
+
...ctx.foreground.beside ? {
|
|
267
|
+
...ctx.foreground.control ? { remoteServices: ctx.foreground.control } : {},
|
|
268
|
+
onServe: () => {
|
|
269
|
+
throw new Error(`${stack} is already running: beside it, \`ph run ${stack} -- <command>\` runs a command that ends. The shell and a serving Cli run in the stack itself.`);
|
|
270
|
+
}
|
|
271
|
+
} : {}
|
|
263
272
|
}).then(async (code) => {
|
|
264
273
|
await Promise.all([drained(process.stdout), drained(process.stderr)]);
|
|
265
274
|
return code;
|
|
@@ -291,11 +300,16 @@ async function run(host, ctx) {
|
|
|
291
300
|
foreground: ctx.foreground
|
|
292
301
|
}, url);
|
|
293
302
|
const stopStream = stopStreamOf(ctx.env, () => process.stdin);
|
|
303
|
+
const key = runRecordKey(host.name, ctx.hostPackage?.name);
|
|
304
|
+
const probe = probeRun(ctx.projectRoot, key, readProjectName(ctx.projectRoot));
|
|
305
|
+
const remoteServices = probe.status === "live" && probe.record.pid !== process.pid ? controlRecordOf(probe.record) : void 0;
|
|
294
306
|
const code = await runCli(cli, {
|
|
295
307
|
argv: ctx.argv ?? [],
|
|
296
308
|
...url ? { url } : {},
|
|
297
309
|
workdir: ctx.projectRoot,
|
|
298
310
|
...stopStream ? { stopStream } : {},
|
|
311
|
+
...remoteServices ? { remoteServices } : {},
|
|
312
|
+
serveCommand: `ph run ${key}`,
|
|
299
313
|
onServe: () => recordServing(ctx.projectRoot, host.name, ctx.verb, ctx.hostPackage?.name)
|
|
300
314
|
});
|
|
301
315
|
await Promise.all([drained(process.stdout), drained(process.stderr)]);
|
|
@@ -311,7 +325,7 @@ async function run(host, ctx) {
|
|
|
311
325
|
*/
|
|
312
326
|
async function build(host, ctx) {
|
|
313
327
|
const cli = await loadCli(ctx.projectRoot, host.config?.package);
|
|
314
|
-
const { buildSkills } = await import("../build-skills-
|
|
328
|
+
const { buildSkills } = await import("../build-skills-Bpbbnin0.mjs");
|
|
315
329
|
const result = await buildSkills({
|
|
316
330
|
rootDir: ctx.projectRoot,
|
|
317
331
|
cli
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-runner.mjs","names":[],"sources":["../../src/runners/cli-runner.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n clearRunRecord,\n probeRun,\n readProjectName,\n readRunRecord,\n runRecordKey,\n STOP_ON_STDIN_ENV,\n STOP_STREAM_LIMIT_MS,\n stopStreamOf,\n writeRunRecord,\n type RunnerArgsSchema,\n type RunnerContext,\n} from \"@powerhousedao/host-core\";\nimport { defineHostSchemas } from \"@powerhousedao/host-core/schema\";\nimport { z } from \"zod\";\nimport type { Cli, RunOptions, RunReactor } from \"../core/types.js\";\nimport {\n attachDefaultReactor,\n resolveRemoteReactorConfig,\n} from \"../integrations/powerhouse/index.js\";\nimport type { ReactorContext } from \"../integrations/powerhouse/types.js\";\n\n/**\n * cli-runner (A5): runs a package's `Cli` — its `./cli` export, the\n * `defineCli` result — in the terminal `ph run` was started from. The host's\n * reactor is a REMOTE attach, as mastra-runner's: a lone `remote` backend\n * whose `remote.url` is a drive address on a running switchboard (typically\n * the output token `switchboard.drives.<slug>.url`). The runner hands that\n * reactor to the Cli for the run (`RunOptions.reactor`), in place of the\n * `create` the Cli configured. Everything after `ph run <host> --` (or `ph run <host> run`, or a first word\n * that is no verb: `ph run <host> hello`) is the Cli's argv: a one-shot\n * command, `-i` for its shell, or nothing.\n *\n * In a compound it is the foreground member (A6): it runs in the compound's\n * process with the terminal, after the members next to it, which it sees as\n * service instances; its end ends the stack with its exit code.\n */\n\nexport const kind = \"reactor\";\n\n/** The Cli owns the terminal: it reads stdin itself, and in a compound it is\n * the foreground member. */\nexport const foreground = true;\n\n/** The verbs this runner exports (`runCli`, `loadCli` and `loadOwnCli` are\n * helpers). */\nexport const verbs = [\"run\", \"build\"] as const;\n\n/** The Cli parses its own arguments: `ph run` hands them over unchecked. */\nexport const argsSchema: RunnerArgsSchema = {\n options: [],\n flags: [],\n passthrough: true,\n};\n\n/** The token a host writes for the switchboard's drive address (error hints). */\nconst REMOTE_URL_HINT =\n 'remote: { url: switchboard.drives.<slug>.url } (from ../switchboard/outputs.js), or literally { url: { $output: { host: \"switchboard\", path: [\"drives\", \"<slug>\", \"url\"] } } }';\n\n/**\n * The cli host, from one definition in two forms: DECLARED (`remote.url` may\n * be an output token; what host.js authors write) and RESOLVED (what the verb\n * receives). `config` names the Cli; the reactor block names its switchboard.\n */\nconst schemas = defineHostSchemas((s) =>\n s.reactorHostSchema.extend({\n runner: s.runnerBaseSchema.strict(),\n config: z\n .strictObject({\n /** The package whose `./cli` export the host runs (`<package>/cli`,\n * resolved from the project). Absent: the project's own `./cli`. In a\n * host an installed package supplies, both resolve from that package:\n * absent is the package's own `./cli`. */\n package: z.string().min(1).optional(),\n })\n .optional(),\n }),\n);\n/** Declared form: what a host file may contain before resolution. */\nexport const declaredHostSchema = schemas.declaredHostSchema;\n/** Resolved form: what the verb receives (and `validateHost` checks). */\nexport const hostSchema = schemas.hostSchema;\n\n/** What a cli host.js author writes. */\nexport type CliHostInput = z.input<typeof declaredHostSchema>;\n/** What the verb receives. */\nexport type CliHost = z.output<typeof hostSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/clint/cli-runner\": {\n host: CliHostInput;\n outputs: Record<string, never>;\n };\n }\n}\n\n/** The drive address the host's reactor attaches to; undefined without a\n * reactor block (the Cli then keeps the reactor it configured, if any). */\nfunction remoteUrlOf(host: CliHost): string | undefined {\n const backends = Object.entries(host.reactor?.backends ?? {});\n if (backends.length === 0) return undefined;\n const local = backends.find(([, backend]) => backend.kind !== \"remote\");\n if (local) {\n throw new Error(\n `hosts/${host.name}: a cli host attaches to a RUNNING switchboard, but backend \"${local[0]}\" is \"${local[1].kind}\". ` +\n `Run the reactor as its own switchboard host and declare one remote backend: ${REMOTE_URL_HINT}.`,\n );\n }\n if (backends.length > 1) {\n throw new Error(\n `hosts/${host.name}: a cli host attaches to one switchboard; declare one remote backend, not ${backends.length}.`,\n );\n }\n const url = backends[0][1].remote?.url;\n if (typeof url !== \"string\") {\n throw new Error(\n `hosts/${host.name}: the remote backend needs a drive address on the switchboard (<switchboard>/d/<slug>): ${REMOTE_URL_HINT}.`,\n );\n }\n return url;\n}\n\nfunction isCli(value: unknown): value is Cli {\n if (typeof value !== \"object\" || value === null) return false;\n const cli = value as Partial<Record<keyof Cli, unknown>>;\n return (\n typeof cli.name === \"string\" &&\n typeof cli.run === \"function\" &&\n typeof cli.listCommands === \"function\"\n );\n}\n\n/** The project's own package name, which its `./cli` is reached by. */\nfunction ownPackageName(projectRoot: string): string {\n let name: unknown;\n try {\n name = (\n JSON.parse(\n fs.readFileSync(path.join(projectRoot, \"package.json\"), \"utf8\"),\n ) as { name?: unknown }\n ).name;\n } catch {\n // reported below\n }\n if (typeof name !== \"string\" || !name) {\n throw new Error(\n `${projectRoot}/package.json has no name, so its ./cli export cannot be resolved; set config.package to the package that exports the Cli.`,\n );\n }\n return name;\n}\n\n/**\n * The `Cli` a package exports as `./cli` (named `cli`, or the default\n * export), resolved from the project's dependency tree. Without `packageName`\n * it is the project's own export, by its package.json name.\n */\nexport async function loadCli(\n projectRoot: string,\n packageName?: string,\n): Promise<Cli> {\n const specifier = `${packageName ?? ownPackageName(projectRoot)}/cli`;\n const projectRequire = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n let file: string;\n try {\n file = projectRequire.resolve(specifier);\n } catch (cause) {\n throw new Error(\n packageName\n ? `Cannot resolve ${specifier} from ${projectRoot}: the package must be a dependency of the project and export ./cli.`\n : `Cannot resolve ${specifier} from ${projectRoot}: its package.json needs the ./cli export, and \\`ph build\\` must have built cli/index.ts.`,\n { cause },\n );\n }\n const module = (await import(pathToFileURL(file).href)) as Record<\n string,\n unknown\n >;\n const cli = module.cli ?? module.default;\n if (!isCli(cli)) {\n throw new Error(\n `${specifier} exports no Cli: export the defineCli result as \\`cli\\` (or as the default export).`,\n );\n }\n return cli;\n}\n\n/**\n * The project's own `./cli` export, or undefined when its package.json has\n * none (a package without a Cli). An export that is declared but cannot be\n * loaded throws, as `loadCli` does.\n */\nexport async function loadOwnCli(\n projectRoot: string,\n): Promise<Cli | undefined> {\n let exported: unknown;\n try {\n exported = (\n JSON.parse(\n fs.readFileSync(path.join(projectRoot, \"package.json\"), \"utf8\"),\n ) as { exports?: Record<string, unknown> }\n ).exports?.[\"./cli\"];\n } catch {\n return undefined;\n }\n return exported ? loadCli(projectRoot) : undefined;\n}\n\n/** Whether `argv` opens the Cli's shell: `-i` before the command name, as the\n * Cli itself reads its framework flags. */\nfunction asksInteractive(cli: Cli, argv: readonly string[]): boolean {\n const commands = new Set([...cli.listCommands().map(({ id }) => id), \"help\"]);\n for (const arg of argv) {\n if (commands.has(arg)) return false;\n if (arg === \"-i\" || arg === \"--interactive\") return true;\n }\n return false;\n}\n\n/** Calls `stop` once, when `stream` delivers anything or ends. */\nfunction whenStreamStops(stream: NodeJS.ReadableStream, stop: () => void) {\n let stopped = false;\n const once = () => {\n if (stopped) return;\n stopped = true;\n stop();\n };\n for (const event of [\"data\", \"end\", \"close\", \"error\"]) {\n stream.once(event, once);\n }\n stream.resume();\n}\n\nexport interface RunCliOptions {\n /** The Cli's arguments, as typed after its name. */\n argv: readonly string[];\n /** A switchboard drive address (`<switchboard>/d/<slug>`) the Cli's\n * reactor attaches to, in place of the one it configured. Absent: the Cli\n * keeps its own. */\n url?: string;\n /** Where the Cli works when no `--workdir` says otherwise. Default: cwd. */\n workdir?: string;\n /** A supervisor's stop request: anything on it, or its end, stops the Cli\n * as SIGTERM would. It is stdin, so the Cli's shell (`-i`) is refused. */\n stopStream?: NodeJS.ReadableStream;\n /** How long a stop may take before the process exits regardless (default\n * {@link STOP_STREAM_LIMIT_MS}). */\n stopStreamLimitMs?: number;\n /** Called when the Cli keeps running (see `RunOptions.onServe`). */\n onServe?: () => void | Promise<void>;\n /** Stops a Cli that keeps running (see `RunOptions.signal`). */\n signal?: AbortSignal;\n /** The compound's other members (see `RunOptions.members`). */\n members?: RunOptions[\"members\"];\n}\n\n/**\n * Runs `cli` in this process's terminal: its stdin, stdout and stderr, and\n * the reactor `url` names. Resolves with the exit code once the Cli is done\n * and its reactor released; it never exits the process itself, except when a\n * stop through `stopStream` outlives its limit. A product bin is this call:\n * `process.exit(await runCli(cli, { url, argv: process.argv.slice(2) }))`.\n */\nexport async function runCli(\n cli: Cli,\n options: RunCliOptions,\n): Promise<number> {\n const { stopStream } = options;\n if (stopStream && asksInteractive(cli, options.argv)) {\n console.error(\n `${cli.name}: -i reads stdin, and the process that started this one holds stdin to ask it to stop (${STOP_ON_STDIN_ENV}=1). ` +\n \"Run the shell from a terminal, or run a command without -i.\",\n );\n return 1;\n }\n\n // Released here as well as by the Cli's teardown, which not every exit\n // path of the Cli runs; it releases once.\n let attached: ReactorContext | undefined;\n const { url } = options;\n const reactor: RunReactor | undefined = url\n ? async (setup, configured) =>\n (attached = await attachDefaultReactor(setup, {\n ...(await resolveRemoteReactorConfig(configured?.remote, setup)),\n url,\n }))\n : undefined;\n\n if (stopStream) {\n whenStreamStops(stopStream, () => {\n // No supervisor may be left to end a stop that hangs.\n const limit = options.stopStreamLimitMs ?? STOP_STREAM_LIMIT_MS;\n setTimeout(() => process.exit(143), limit).unref();\n // As the stop channel does: a serving Cli's handler tears it down. A\n // stop during its start waits for the handler; a command in flight\n // finishes within the limit.\n if (process.emit(\"SIGTERM\", \"SIGTERM\")) return;\n const retry = setInterval(() => {\n if (process.emit(\"SIGTERM\", \"SIGTERM\")) clearInterval(retry);\n }, 100);\n retry.unref();\n });\n // These go when the supervisor does, and with no listener the next line\n // would be a fatal error in the middle of the shutdown it asked for.\n for (const output of [process.stdout, process.stderr]) {\n output.on(\"error\", () => undefined);\n }\n }\n\n let exitCode = 0;\n try {\n await cli.run([\"node\", cli.name, ...options.argv], {\n exit: (code) => {\n exitCode = code;\n },\n ...(options.workdir ? { workdir: options.workdir } : {}),\n ...(reactor ? { reactor } : {}),\n ...(options.onServe ? { onServe: options.onServe } : {}),\n ...(options.signal ? { signal: options.signal } : {}),\n ...(options.members ? { members: options.members } : {}),\n });\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error));\n if (exitCode === 0) exitCode = 1;\n } finally {\n await attached?.shutdown();\n }\n return exitCode;\n}\n\n/**\n * The record of a Cli that keeps running: what `ph run <host> --stop` reads.\n * A one-shot writes none and takes no lock, so it runs beside a serving\n * instance; a second serving instance is refused.\n */\nfunction recordServing(\n projectRoot: string,\n hostName: string,\n verb: string,\n hostPackage?: string,\n): void {\n const projectName = readProjectName(projectRoot);\n // A package's host is filed, and addressed, behind its package.\n const key = runRecordKey(hostName, hostPackage);\n const probe = probeRun(projectRoot, key, projectName);\n if (probe.status === \"live\" && probe.record.pid !== process.pid) {\n throw new Error(\n `${key} is already running for this project (pid ${probe.record.pid}). ` +\n `Stop it with \\`ph run ${key} --stop\\`, or run a command beside it: \\`ph run ${key} -- <command>\\`.`,\n );\n }\n if (probe.status === \"foreign\") {\n throw new Error(\n `.ph/run/${key}.json describes a live \"${probe.record.projectName}\", but this project is \"${projectName}\". Refusing to start a second instance.`,\n );\n }\n writeRunRecord(projectRoot, {\n version: 2,\n host: hostName,\n ...(hostPackage === undefined ? {} : { package: hostPackage }),\n projectName,\n kind: \"reactor\",\n verb,\n pid: process.pid,\n startedAt: new Date().toISOString(),\n outputs: {},\n });\n process.on(\"exit\", () => {\n if (readRunRecord(projectRoot, key)?.pid === process.pid) {\n clearRunRecord(projectRoot, key);\n }\n });\n}\n\n/** Resolves once what was written to `stream` before has been handed on\n * (process.exit drops what a pipe has not taken yet). */\nfunction drained(stream: NodeJS.WriteStream): Promise<void> {\n return new Promise((resolve) => stream.write(\"\", () => resolve()));\n}\n\n/** How long a stop from the compound waits for the Cli before the compound\n * stops the rest: a command in flight or the line-based shell does not\n * listen for it. */\nconst FOREGROUND_STOP_MS = 10_000;\n\n/** The handle the compound gets from its foreground member. */\nexport interface ForegroundHandle {\n outputs: Record<string, never>;\n ready: Promise<void>;\n /** The Cli's end, with its exit code: the stack's. */\n exited: Promise<number>;\n /** Asks the Cli to stop (its `RunOptions.signal`) and waits for it, up to\n * a limit. */\n shutdown(): Promise<void>;\n}\n\n/**\n * The Cli as a compound's foreground member: in the compound's process, on\n * the terminal, after the other members. Returns at once; the compound reads\n * the Cli's end from `exited`. A supervised compound holds stdin (its stop\n * stream), so the Cli neither reads it nor opens its shell then. Beside a\n * running stack it may only run a command that ends.\n */\nfunction inStack(\n cli: Cli,\n host: CliHost,\n ctx: RunnerContext & { foreground: NonNullable<RunnerContext[\"foreground\"]> },\n url: string | undefined,\n): ForegroundHandle {\n const argv = ctx.argv ?? [];\n const stack = ctx.parent?.host ?? host.name;\n const done = (exited: Promise<number>): ForegroundHandle => ({\n outputs: {},\n ready: Promise.resolve(),\n exited,\n shutdown: () => Promise.resolve(),\n });\n if (ctx.env[STOP_ON_STDIN_ENV] === \"1\" && asksInteractive(cli, argv)) {\n console.error(\n `${cli.name}: -i reads stdin, and the process that started \"${stack}\" holds its stdin to ask it to stop (${STOP_ON_STDIN_ENV}=1). ` +\n `Run the shell from a terminal, or run a command without -i.`,\n );\n return done(Promise.resolve(1));\n }\n const stop = new AbortController();\n const exited = runCli(cli, {\n argv,\n ...(url ? { url } : {}),\n workdir: ctx.projectRoot,\n signal: stop.signal,\n members: ctx.foreground.members,\n ...(ctx.foreground.beside\n ? {\n onServe: () => {\n throw new Error(\n `${stack} is already running: beside it, \\`ph run ${stack} -- <command>\\` runs a command that ends. The shell and a serving Cli run in the stack itself.`,\n );\n },\n }\n : {}),\n }).then(async (code) => {\n await Promise.all([drained(process.stdout), drained(process.stderr)]);\n return code;\n });\n return {\n ...done(exited),\n shutdown: async () => {\n stop.abort();\n let timer: NodeJS.Timeout | undefined;\n await Promise.race([\n exited,\n new Promise<void>((resolve) => {\n timer = setTimeout(resolve, FOREGROUND_STOP_MS);\n }),\n ]);\n clearTimeout(timer);\n },\n };\n}\n\n/**\n * `run`: the Cli in the foreground, with the host's reactor. On its own the\n * process ends with the Cli's exit code. As a compound's foreground member\n * it returns a handle whose `exited` the compound ends the stack on; it is\n * never a compound's other, in-process kind of member.\n */\nexport async function run(\n host: CliHost,\n ctx: RunnerContext,\n): Promise<ForegroundHandle | undefined> {\n if (ctx.parent && !ctx.foreground) {\n throw new Error(\n `hosts/${host.name}: compound \"${ctx.parent.host}\" runs the cli runner as an ordinary member, but the Cli owns the terminal and its end is the stack's: it runs on its own (\\`ph run ${host.name}\\`) or as a compound's foreground member.`,\n );\n }\n const url = remoteUrlOf(host);\n // From the package that supplies the host, if one does: its own `./cli`.\n // The Cli still works in the project.\n const cli = await loadCli(\n ctx.hostPackage?.root ?? ctx.projectRoot,\n host.config?.package,\n );\n if (ctx.foreground) {\n return inStack(cli, host, { ...ctx, foreground: ctx.foreground }, url);\n }\n const stopStream = stopStreamOf(ctx.env, () => process.stdin);\n const code = await runCli(cli, {\n argv: ctx.argv ?? [],\n ...(url ? { url } : {}),\n workdir: ctx.projectRoot,\n ...(stopStream ? { stopStream } : {}),\n onServe: () =>\n recordServing(\n ctx.projectRoot,\n host.name,\n ctx.verb,\n ctx.hostPackage?.name,\n ),\n });\n await Promise.all([drained(process.stdout), drained(process.stderr)]);\n process.exit(code);\n}\n\n/**\n * `build`: the package's skill and agent-profile compilation with the Cli's\n * metadata in the template context. Loading the Cli starts nothing (no\n * reactor, no services). Source and output are the conventional paths\n * (`prompts/` or `agents/`, `dist/skills`). Shadows a Cli command named\n * `build` as the first word after the host; `ph run <host> run build` still\n * reaches it.\n */\nexport async function build(host: CliHost, ctx: RunnerContext): Promise<void> {\n const cli = await loadCli(ctx.projectRoot, host.config?.package);\n const { buildSkills } = await import(\"../dev/build-skills.js\");\n const result = await buildSkills({ rootDir: ctx.projectRoot, cli });\n console.log(\n `[${host.name}] compiled ${result.skills} skill(s), ${result.profiles} profile(s) → ${result.outDir}`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,OA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I,UAAU,CAAC,IAAI,YACrB,MAAM,IAAI,MACR,SAAS,KAAK,KAAK,cAAc,IAAI,OAAO,KAAK,sIAAsI,KAAK,KAAK,0CACnM;CAEF,MAAM,MAAM,YAAY,IAAI;CAG5B,MAAM,MAAM,MAAM,QAChB,IAAI,aAAa,QAAQ,IAAI,aAC7B,KAAK,QAAQ,OACf;CACA,IAAI,IAAI,YACN,OAAO,QAAQ,KAAK,MAAM;EAAE,GAAG;EAAK,YAAY,IAAI;CAAW,GAAG,GAAG;CAEvE,MAAM,aAAa,aAAa,IAAI,WAAW,QAAQ,KAAK;CAC5D,MAAM,OAAO,MAAM,OAAO,KAAK;EAC7B,MAAM,IAAI,QAAQ,CAAC;EACnB,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC;EACrB,SAAS,IAAI;EACb,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;EACnC,eACE,cACE,IAAI,aACJ,KAAK,MACL,IAAI,MACJ,IAAI,aAAa,IACnB;CACJ,CAAC;CACD,MAAM,QAAQ,IAAI,CAAC,QAAQ,QAAQ,MAAM,GAAG,QAAQ,QAAQ,MAAM,CAAC,CAAC;CACpE,QAAQ,KAAK,IAAI;AACnB;;;;;;;;;AAUA,eAAsB,MAAM,MAAe,KAAmC;CAC5E,MAAM,MAAM,MAAM,QAAQ,IAAI,aAAa,KAAK,QAAQ,OAAO;CAC/D,MAAM,EAAE,gBAAgB,MAAM,OAAO;CACrC,MAAM,SAAS,MAAM,YAAY;EAAE,SAAS,IAAI;EAAa;CAAI,CAAC;CAClE,QAAQ,IACN,IAAI,KAAK,KAAK,aAAa,OAAO,OAAO,aAAa,OAAO,SAAS,gBAAgB,OAAO,QAC/F;AACF"}
|
|
1
|
+
{"version":3,"file":"cli-runner.mjs","names":[],"sources":["../../src/runners/cli-runner.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n clearRunRecord,\n controlRecordOf,\n ensureProcessControlChannel,\n probeRun,\n readProjectName,\n readRunRecord,\n runRecordKey,\n STOP_ON_STDIN_ENV,\n STOP_STREAM_LIMIT_MS,\n stopStreamOf,\n writeRunRecord,\n type RunnerArgsSchema,\n type RunnerContext,\n} from \"@powerhousedao/host-core\";\nimport { defineHostSchemas } from \"@powerhousedao/host-core/schema\";\nimport { z } from \"zod\";\nimport type { Cli, RunOptions, RunReactor } from \"../core/types.js\";\nimport {\n attachDefaultReactor,\n resolveRemoteReactorConfig,\n} from \"../integrations/powerhouse/index.js\";\nimport type { ReactorContext } from \"../integrations/powerhouse/types.js\";\n\n/**\n * cli-runner (A5): runs a package's `Cli` — its `./cli` export, the\n * `defineCli` result — in the terminal `ph run` was started from. The host's\n * reactor is a REMOTE attach, as mastra-runner's: a lone `remote` backend\n * whose `remote.url` is a drive address on a running switchboard (typically\n * the output token `switchboard.drives.<slug>.url`). The runner hands that\n * reactor to the Cli for the run (`RunOptions.reactor`), in place of the\n * `create` the Cli configured. Everything after `ph run <host> --` (or `ph run <host> run`, or a first word\n * that is no verb: `ph run <host> hello`) is the Cli's argv: a one-shot\n * command, `-i` for its shell, or nothing.\n *\n * In a compound it is the foreground member (A6): it runs in the compound's\n * process with the terminal, after the members next to it, which it sees as\n * service instances; its end ends the stack with its exit code.\n */\n\nexport const kind = \"reactor\";\n\n/** The Cli owns the terminal: it reads stdin itself, and in a compound it is\n * the foreground member. */\nexport const foreground = true;\n\n/** The verbs this runner exports (`runCli`, `loadCli` and `loadOwnCli` are\n * helpers). */\nexport const verbs = [\"run\", \"build\"] as const;\n\n/** The Cli parses its own arguments: `ph run` hands them over unchecked. */\nexport const argsSchema: RunnerArgsSchema = {\n options: [],\n flags: [],\n passthrough: true,\n};\n\n/** The token a host writes for the switchboard's drive address (error hints). */\nconst REMOTE_URL_HINT =\n 'remote: { url: switchboard.drives.<slug>.url } (from ../switchboard/outputs.js), or literally { url: { $output: { host: \"switchboard\", path: [\"drives\", \"<slug>\", \"url\"] } } }';\n\n/**\n * The cli host, from one definition in two forms: DECLARED (`remote.url` may\n * be an output token; what host.js authors write) and RESOLVED (what the verb\n * receives). `config` names the Cli; the reactor block names its switchboard.\n */\nconst schemas = defineHostSchemas((s) =>\n s.reactorHostSchema.extend({\n runner: s.runnerBaseSchema.strict(),\n config: z\n .strictObject({\n /** The package whose `./cli` export the host runs (`<package>/cli`,\n * resolved from the project). Absent: the project's own `./cli`. In a\n * host an installed package supplies, both resolve from that package:\n * absent is the package's own `./cli`. */\n package: z.string().min(1).optional(),\n })\n .optional(),\n }),\n);\n/** Declared form: what a host file may contain before resolution. */\nexport const declaredHostSchema = schemas.declaredHostSchema;\n/** Resolved form: what the verb receives (and `validateHost` checks). */\nexport const hostSchema = schemas.hostSchema;\n\n/** What a cli host.js author writes. */\nexport type CliHostInput = z.input<typeof declaredHostSchema>;\n/** What the verb receives. */\nexport type CliHost = z.output<typeof hostSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/clint/cli-runner\": {\n host: CliHostInput;\n outputs: Record<string, never>;\n };\n }\n}\n\n/** The drive address the host's reactor attaches to; undefined without a\n * reactor block (the Cli then keeps the reactor it configured, if any). */\nfunction remoteUrlOf(host: CliHost): string | undefined {\n const backends = Object.entries(host.reactor?.backends ?? {});\n if (backends.length === 0) return undefined;\n const local = backends.find(([, backend]) => backend.kind !== \"remote\");\n if (local) {\n throw new Error(\n `hosts/${host.name}: a cli host attaches to a RUNNING switchboard, but backend \"${local[0]}\" is \"${local[1].kind}\". ` +\n `Run the reactor as its own switchboard host and declare one remote backend: ${REMOTE_URL_HINT}.`,\n );\n }\n if (backends.length > 1) {\n throw new Error(\n `hosts/${host.name}: a cli host attaches to one switchboard; declare one remote backend, not ${backends.length}.`,\n );\n }\n const url = backends[0][1].remote?.url;\n if (typeof url !== \"string\") {\n throw new Error(\n `hosts/${host.name}: the remote backend needs a drive address on the switchboard (<switchboard>/d/<slug>): ${REMOTE_URL_HINT}.`,\n );\n }\n return url;\n}\n\nfunction isCli(value: unknown): value is Cli {\n if (typeof value !== \"object\" || value === null) return false;\n const cli = value as Partial<Record<keyof Cli, unknown>>;\n return (\n typeof cli.name === \"string\" &&\n typeof cli.run === \"function\" &&\n typeof cli.listCommands === \"function\"\n );\n}\n\n/** The project's own package name, which its `./cli` is reached by. */\nfunction ownPackageName(projectRoot: string): string {\n let name: unknown;\n try {\n name = (\n JSON.parse(\n fs.readFileSync(path.join(projectRoot, \"package.json\"), \"utf8\"),\n ) as { name?: unknown }\n ).name;\n } catch {\n // reported below\n }\n if (typeof name !== \"string\" || !name) {\n throw new Error(\n `${projectRoot}/package.json has no name, so its ./cli export cannot be resolved; set config.package to the package that exports the Cli.`,\n );\n }\n return name;\n}\n\n/**\n * The `Cli` a package exports as `./cli` (named `cli`, or the default\n * export), resolved from the project's dependency tree. Without `packageName`\n * it is the project's own export, by its package.json name.\n */\nexport async function loadCli(\n projectRoot: string,\n packageName?: string,\n): Promise<Cli> {\n const specifier = `${packageName ?? ownPackageName(projectRoot)}/cli`;\n const projectRequire = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n let file: string;\n try {\n file = projectRequire.resolve(specifier);\n } catch (cause) {\n throw new Error(\n packageName\n ? `Cannot resolve ${specifier} from ${projectRoot}: the package must be a dependency of the project and export ./cli.`\n : `Cannot resolve ${specifier} from ${projectRoot}: its package.json needs the ./cli export, and \\`ph build\\` must have built cli/index.ts.`,\n { cause },\n );\n }\n const module = (await import(pathToFileURL(file).href)) as Record<\n string,\n unknown\n >;\n const cli = module.cli ?? module.default;\n if (!isCli(cli)) {\n throw new Error(\n `${specifier} exports no Cli: export the defineCli result as \\`cli\\` (or as the default export).`,\n );\n }\n return cli;\n}\n\n/**\n * The project's own `./cli` export, or undefined when its package.json has\n * none (a package without a Cli). An export that is declared but cannot be\n * loaded throws, as `loadCli` does.\n */\nexport async function loadOwnCli(\n projectRoot: string,\n): Promise<Cli | undefined> {\n let exported: unknown;\n try {\n exported = (\n JSON.parse(\n fs.readFileSync(path.join(projectRoot, \"package.json\"), \"utf8\"),\n ) as { exports?: Record<string, unknown> }\n ).exports?.[\"./cli\"];\n } catch {\n return undefined;\n }\n return exported ? loadCli(projectRoot) : undefined;\n}\n\n/** Whether `argv` opens the Cli's shell: `-i` before the command name, as the\n * Cli itself reads its framework flags. */\nfunction asksInteractive(cli: Cli, argv: readonly string[]): boolean {\n const commands = new Set([...cli.listCommands().map(({ id }) => id), \"help\"]);\n for (const arg of argv) {\n if (commands.has(arg)) return false;\n if (arg === \"-i\" || arg === \"--interactive\") return true;\n }\n return false;\n}\n\n/** Calls `stop` once, when `stream` delivers anything or ends. */\nfunction whenStreamStops(stream: NodeJS.ReadableStream, stop: () => void) {\n let stopped = false;\n const once = () => {\n if (stopped) return;\n stopped = true;\n stop();\n };\n for (const event of [\"data\", \"end\", \"close\", \"error\"]) {\n stream.once(event, once);\n }\n stream.resume();\n}\n\nexport interface RunCliOptions {\n /** The Cli's arguments, as typed after its name. */\n argv: readonly string[];\n /** A switchboard drive address (`<switchboard>/d/<slug>`) the Cli's\n * reactor attaches to, in place of the one it configured. Absent: the Cli\n * keeps its own. */\n url?: string;\n /** Where the Cli works when no `--workdir` says otherwise. Default: cwd. */\n workdir?: string;\n /** A supervisor's stop request: anything on it, or its end, stops the Cli\n * as SIGTERM would. It is stdin, so the Cli's shell (`-i`) is refused. */\n stopStream?: NodeJS.ReadableStream;\n /** How long a stop may take before the process exits regardless (default\n * {@link STOP_STREAM_LIMIT_MS}). */\n stopStreamLimitMs?: number;\n /** Called when the Cli keeps running (see `RunOptions.onServe`). */\n onServe?: () => void | Promise<void>;\n /** Stops a Cli that keeps running (see `RunOptions.signal`). */\n signal?: AbortSignal;\n /** The compound's other members (see `RunOptions.members`). */\n members?: RunOptions[\"members\"];\n /** A running instance's control channel (see `RunOptions.remoteServices`). */\n remoteServices?: RunOptions[\"remoteServices\"];\n /** How the Cli is started to keep running (see `RunOptions.serveCommand`). */\n serveCommand?: string;\n}\n\n/**\n * Runs `cli` in this process's terminal: its stdin, stdout and stderr, and\n * the reactor `url` names. Resolves with the exit code once the Cli is done\n * and its reactor released; it never exits the process itself, except when a\n * stop through `stopStream` outlives its limit. A product bin is this call:\n * `process.exit(await runCli(cli, { url, argv: process.argv.slice(2) }))`.\n */\nexport async function runCli(\n cli: Cli,\n options: RunCliOptions,\n): Promise<number> {\n const { stopStream } = options;\n if (stopStream && asksInteractive(cli, options.argv)) {\n console.error(\n `${cli.name}: -i reads stdin, and the process that started this one holds stdin to ask it to stop (${STOP_ON_STDIN_ENV}=1). ` +\n \"Run the shell from a terminal, or run a command without -i.\",\n );\n return 1;\n }\n\n // Released here as well as by the Cli's teardown, which not every exit\n // path of the Cli runs; it releases once.\n let attached: ReactorContext | undefined;\n const { url } = options;\n const reactor: RunReactor | undefined = url\n ? async (setup, configured) =>\n (attached = await attachDefaultReactor(setup, {\n ...(await resolveRemoteReactorConfig(configured?.remote, setup)),\n url,\n }))\n : undefined;\n\n if (stopStream) {\n whenStreamStops(stopStream, () => {\n // No supervisor may be left to end a stop that hangs.\n const limit = options.stopStreamLimitMs ?? STOP_STREAM_LIMIT_MS;\n setTimeout(() => process.exit(143), limit).unref();\n // As the stop channel does: a serving Cli's handler tears it down. A\n // stop during its start waits for the handler; a command in flight\n // finishes within the limit.\n if (process.emit(\"SIGTERM\", \"SIGTERM\")) return;\n const retry = setInterval(() => {\n if (process.emit(\"SIGTERM\", \"SIGTERM\")) clearInterval(retry);\n }, 100);\n retry.unref();\n });\n // These go when the supervisor does, and with no listener the next line\n // would be a fatal error in the middle of the shutdown it asked for.\n for (const output of [process.stdout, process.stderr]) {\n output.on(\"error\", () => undefined);\n }\n }\n\n let exitCode = 0;\n try {\n await cli.run([\"node\", cli.name, ...options.argv], {\n exit: (code) => {\n exitCode = code;\n },\n ...(options.workdir ? { workdir: options.workdir } : {}),\n ...(reactor ? { reactor } : {}),\n ...(options.onServe ? { onServe: options.onServe } : {}),\n ...(options.signal ? { signal: options.signal } : {}),\n ...(options.members ? { members: options.members } : {}),\n ...(options.remoteServices\n ? { remoteServices: options.remoteServices }\n : {}),\n ...(options.serveCommand ? { serveCommand: options.serveCommand } : {}),\n });\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error));\n if (exitCode === 0) exitCode = 1;\n } finally {\n await attached?.shutdown();\n }\n return exitCode;\n}\n\n/**\n * The record of a Cli that keeps running: what `ph run <host> --stop` reads.\n * A one-shot writes none and takes no lock, so it runs beside a serving\n * instance; a second serving instance is refused. The record names the\n * process's control channel, which the Cli answers service requests on.\n */\nasync function recordServing(\n projectRoot: string,\n hostName: string,\n verb: string,\n hostPackage?: string,\n): Promise<void> {\n const projectName = readProjectName(projectRoot);\n // A package's host is filed, and addressed, behind its package.\n const key = runRecordKey(hostName, hostPackage);\n const probe = probeRun(projectRoot, key, projectName);\n if (probe.status === \"live\" && probe.record.pid !== process.pid) {\n throw new Error(\n `${key} is already running for this project (pid ${probe.record.pid}). ` +\n `Stop it with \\`ph run ${key} --stop\\`, or run a command beside it: \\`ph run ${key} -- <command>\\`.`,\n );\n }\n if (probe.status === \"foreign\") {\n throw new Error(\n `.ph/run/${key}.json describes a live \"${probe.record.projectName}\", but this project is \"${projectName}\". Refusing to start a second instance.`,\n );\n }\n const control = (await ensureProcessControlChannel())?.record;\n writeRunRecord(projectRoot, {\n version: 2,\n host: hostName,\n ...(hostPackage === undefined ? {} : { package: hostPackage }),\n projectName,\n kind: \"reactor\",\n verb,\n pid: process.pid,\n startedAt: new Date().toISOString(),\n outputs: {},\n ...(control ? { extra: { control } } : {}),\n });\n process.on(\"exit\", () => {\n if (readRunRecord(projectRoot, key)?.pid === process.pid) {\n clearRunRecord(projectRoot, key);\n }\n });\n}\n\n/** Resolves once what was written to `stream` before has been handed on\n * (process.exit drops what a pipe has not taken yet). */\nfunction drained(stream: NodeJS.WriteStream): Promise<void> {\n return new Promise((resolve) => stream.write(\"\", () => resolve()));\n}\n\n/** How long a stop from the compound waits for the Cli before the compound\n * stops the rest: a command in flight or the line-based shell does not\n * listen for it. */\nconst FOREGROUND_STOP_MS = 10_000;\n\n/** The handle the compound gets from its foreground member. */\nexport interface ForegroundHandle {\n outputs: Record<string, never>;\n ready: Promise<void>;\n /** The Cli's end, with its exit code: the stack's. */\n exited: Promise<number>;\n /** Asks the Cli to stop (its `RunOptions.signal`) and waits for it, up to\n * a limit. */\n shutdown(): Promise<void>;\n}\n\n/**\n * The Cli as a compound's foreground member: in the compound's process, on\n * the terminal, after the other members. Returns at once; the compound reads\n * the Cli's end from `exited`. A supervised compound holds stdin (its stop\n * stream), so the Cli neither reads it nor opens its shell then. Beside a\n * running stack it may only run a command that ends.\n */\nfunction inStack(\n cli: Cli,\n host: CliHost,\n ctx: RunnerContext & { foreground: NonNullable<RunnerContext[\"foreground\"]> },\n url: string | undefined,\n): ForegroundHandle {\n const argv = ctx.argv ?? [];\n const stack = ctx.parent?.host ?? host.name;\n const done = (exited: Promise<number>): ForegroundHandle => ({\n outputs: {},\n ready: Promise.resolve(),\n exited,\n shutdown: () => Promise.resolve(),\n });\n if (ctx.env[STOP_ON_STDIN_ENV] === \"1\" && asksInteractive(cli, argv)) {\n console.error(\n `${cli.name}: -i reads stdin, and the process that started \"${stack}\" holds its stdin to ask it to stop (${STOP_ON_STDIN_ENV}=1). ` +\n `Run the shell from a terminal, or run a command without -i.`,\n );\n return done(Promise.resolve(1));\n }\n const stop = new AbortController();\n const exited = runCli(cli, {\n argv,\n ...(url ? { url } : {}),\n workdir: ctx.projectRoot,\n signal: stop.signal,\n members: ctx.foreground.members,\n serveCommand: `ph run ${ctx.foreground.stack ?? stack}`,\n ...(ctx.foreground.beside\n ? {\n ...(ctx.foreground.control\n ? { remoteServices: ctx.foreground.control }\n : {}),\n onServe: () => {\n throw new Error(\n `${stack} is already running: beside it, \\`ph run ${stack} -- <command>\\` runs a command that ends. The shell and a serving Cli run in the stack itself.`,\n );\n },\n }\n : {}),\n }).then(async (code) => {\n await Promise.all([drained(process.stdout), drained(process.stderr)]);\n return code;\n });\n return {\n ...done(exited),\n shutdown: async () => {\n stop.abort();\n let timer: NodeJS.Timeout | undefined;\n await Promise.race([\n exited,\n new Promise<void>((resolve) => {\n timer = setTimeout(resolve, FOREGROUND_STOP_MS);\n }),\n ]);\n clearTimeout(timer);\n },\n };\n}\n\n/**\n * `run`: the Cli in the foreground, with the host's reactor. On its own the\n * process ends with the Cli's exit code. As a compound's foreground member\n * it returns a handle whose `exited` the compound ends the stack on; it is\n * never a compound's other, in-process kind of member.\n */\nexport async function run(\n host: CliHost,\n ctx: RunnerContext,\n): Promise<ForegroundHandle | undefined> {\n if (ctx.parent && !ctx.foreground) {\n throw new Error(\n `hosts/${host.name}: compound \"${ctx.parent.host}\" runs the cli runner as an ordinary member, but the Cli owns the terminal and its end is the stack's: it runs on its own (\\`ph run ${host.name}\\`) or as a compound's foreground member.`,\n );\n }\n const url = remoteUrlOf(host);\n // From the package that supplies the host, if one does: its own `./cli`.\n // The Cli still works in the project.\n const cli = await loadCli(\n ctx.hostPackage?.root ?? ctx.projectRoot,\n host.config?.package,\n );\n if (ctx.foreground) {\n return inStack(cli, host, { ...ctx, foreground: ctx.foreground }, url);\n }\n const stopStream = stopStreamOf(ctx.env, () => process.stdin);\n // A command beside a serving instance of this host reaches its services.\n const key = runRecordKey(host.name, ctx.hostPackage?.name);\n const probe = probeRun(\n ctx.projectRoot,\n key,\n readProjectName(ctx.projectRoot),\n );\n const remoteServices =\n probe.status === \"live\" && probe.record.pid !== process.pid\n ? controlRecordOf(probe.record)\n : undefined;\n const code = await runCli(cli, {\n argv: ctx.argv ?? [],\n ...(url ? { url } : {}),\n workdir: ctx.projectRoot,\n ...(stopStream ? { stopStream } : {}),\n ...(remoteServices ? { remoteServices } : {}),\n serveCommand: `ph run ${key}`,\n onServe: () =>\n recordServing(\n ctx.projectRoot,\n host.name,\n ctx.verb,\n ctx.hostPackage?.name,\n ),\n });\n await Promise.all([drained(process.stdout), drained(process.stderr)]);\n process.exit(code);\n}\n\n/**\n * `build`: the package's skill and agent-profile compilation with the Cli's\n * metadata in the template context. Loading the Cli starts nothing (no\n * reactor, no services). Source and output are the conventional paths\n * (`prompts/` or `agents/`, `dist/skills`). Shadows a Cli command named\n * `build` as the first word after the host; `ph run <host> run build` still\n * reaches it.\n */\nexport async function build(host: CliHost, ctx: RunnerContext): Promise<void> {\n const cli = await loadCli(ctx.projectRoot, host.config?.package);\n const { buildSkills } = await import(\"../dev/build-skills.js\");\n const result = await buildSkills({ rootDir: ctx.projectRoot, cli });\n console.log(\n `[${host.name}] compiled ${result.skills} skill(s), ${result.profiles} profile(s) → ${result.outDir}`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,OAAO;;;AAIpB,MAAa,aAAa;;;AAI1B,MAAa,QAAQ,CAAC,OAAO,OAAO;;AAGpC,MAAa,aAA+B;CAC1C,SAAS,CAAC;CACV,OAAO,CAAC;CACR,aAAa;AACf;;AAGA,MAAM,kBACJ;;;;;;AAOF,MAAM,UAAU,mBAAmB,MACjC,EAAE,kBAAkB,OAAO;CACzB,QAAQ,EAAE,iBAAiB,OAAO;CAClC,QAAQ,EACL,aAAa;;;;;AAKZ,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACtC,CAAC,CAAC,CACD,SAAS;AACd,CAAC,CACH;;AAEA,MAAa,qBAAqB,QAAQ;;AAE1C,MAAa,aAAa,QAAQ;;;AAkBlC,SAAS,YAAY,MAAmC;CACtD,MAAM,WAAW,OAAO,QAAQ,KAAK,SAAS,YAAY,CAAC,CAAC;CAC5D,IAAI,SAAS,WAAW,GAAG,OAAO,KAAA;CAClC,MAAM,QAAQ,SAAS,MAAM,GAAG,aAAa,QAAQ,SAAS,QAAQ;CACtE,IAAI,OACF,MAAM,IAAI,MACR,SAAS,KAAK,KAAK,+DAA+D,MAAM,GAAG,QAAQ,MAAM,EAAE,CAAC,KAAK,iFAChC,gBAAgB,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;CACzD,MAAM,QAAQ,SACZ,IAAI,aACJ,KACA,gBAAgB,IAAI,WAAW,CACjC;CACA,MAAM,iBACJ,MAAM,WAAW,UAAU,MAAM,OAAO,QAAQ,QAAQ,MACpD,gBAAgB,MAAM,MAAM,IAC5B,KAAA;CACN,MAAM,OAAO,MAAM,OAAO,KAAK;EAC7B,MAAM,IAAI,QAAQ,CAAC;EACnB,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC;EACrB,SAAS,IAAI;EACb,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;EACnC,GAAI,iBAAiB,EAAE,eAAe,IAAI,CAAC;EAC3C,cAAc,UAAU;EACxB,eACE,cACE,IAAI,aACJ,KAAK,MACL,IAAI,MACJ,IAAI,aAAa,IACnB;CACJ,CAAC;CACD,MAAM,QAAQ,IAAI,CAAC,QAAQ,QAAQ,MAAM,GAAG,QAAQ,QAAQ,MAAM,CAAC,CAAC;CACpE,QAAQ,KAAK,IAAI;AACnB;;;;;;;;;AAUA,eAAsB,MAAM,MAAe,KAAmC;CAC5E,MAAM,MAAM,MAAM,QAAQ,IAAI,aAAa,KAAK,QAAQ,OAAO;CAC/D,MAAM,EAAE,gBAAgB,MAAM,OAAO;CACrC,MAAM,SAAS,MAAM,YAAY;EAAE,SAAS,IAAI;EAAa;CAAI,CAAC;CAClE,QAAQ,IACN,IAAI,KAAK,KAAK,aAAa,OAAO,OAAO,aAAa,OAAO,SAAS,gBAAgB,OAAO,QAC/F;AACF"}
|
|
@@ -449,7 +449,7 @@ const serve = run;
|
|
|
449
449
|
*/
|
|
450
450
|
async function build(host, ctx) {
|
|
451
451
|
const config = host.config ?? {};
|
|
452
|
-
const { buildSkills } = await import("../build-skills-
|
|
452
|
+
const { buildSkills } = await import("../build-skills-Bpbbnin0.mjs");
|
|
453
453
|
const { loadOwnCli } = await import("./cli-runner.mjs");
|
|
454
454
|
const result = await buildSkills({
|
|
455
455
|
rootDir: ctx.projectRoot,
|