@skaile/workspaces 0.40.2 → 0.41.1
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/CHANGELOG.md +50 -0
- package/dist/{asset-feeds-NOHUJ4XZ.js → asset-feeds-5AL623RN.js} +11 -11
- package/dist/{asset-feeds-NOHUJ4XZ.js.map → asset-feeds-5AL623RN.js.map} +1 -1
- package/dist/asset-manager/index.js +9 -9
- package/dist/asset-manager/installer.js +8 -8
- package/dist/{chunk-HL66R2P2.js → chunk-2PXSZYKV.js} +17 -8
- package/dist/chunk-2PXSZYKV.js.map +1 -0
- package/dist/{chunk-O66LT7UI.js → chunk-5PGFAYN3.js} +5 -5
- package/dist/{chunk-O66LT7UI.js.map → chunk-5PGFAYN3.js.map} +1 -1
- package/dist/{chunk-MAPRKFBD.js → chunk-B5PEERRZ.js} +18 -3
- package/dist/chunk-B5PEERRZ.js.map +1 -0
- package/dist/{chunk-CFCSDZYF.js → chunk-DUAB2AFV.js} +4 -4
- package/dist/{chunk-CFCSDZYF.js.map → chunk-DUAB2AFV.js.map} +1 -1
- package/dist/{chunk-SAXDHVJZ.js → chunk-DZCK7GRW.js} +3 -3
- package/dist/{chunk-SAXDHVJZ.js.map → chunk-DZCK7GRW.js.map} +1 -1
- package/dist/{chunk-4A2LAEX6.js → chunk-FIMEPG6J.js} +4 -4
- package/dist/{chunk-4A2LAEX6.js.map → chunk-FIMEPG6J.js.map} +1 -1
- package/dist/{chunk-BM7XANVN.js → chunk-GEEW6SY2.js} +10 -3
- package/dist/chunk-GEEW6SY2.js.map +1 -0
- package/dist/{chunk-XNMABEHH.js → chunk-IGNSNZPG.js} +5 -5
- package/dist/{chunk-XNMABEHH.js.map → chunk-IGNSNZPG.js.map} +1 -1
- package/dist/{chunk-USEFGACS.js → chunk-KZPMBTQL.js} +7 -7
- package/dist/{chunk-USEFGACS.js.map → chunk-KZPMBTQL.js.map} +1 -1
- package/dist/{chunk-FBIQ4QPF.js → chunk-MWEB2TZ7.js} +15 -15
- package/dist/chunk-MWEB2TZ7.js.map +1 -0
- package/dist/{chunk-XZNPKJXU.js → chunk-OL2BXZZV.js} +4 -4
- package/dist/{chunk-XZNPKJXU.js.map → chunk-OL2BXZZV.js.map} +1 -1
- package/dist/{chunk-23WP47VA.js → chunk-OZVZA64O.js} +2 -2
- package/dist/{chunk-23WP47VA.js.map → chunk-OZVZA64O.js.map} +1 -1
- package/dist/{chunk-J5DB4KHE.js → chunk-PIAWSWLQ.js} +5 -5
- package/dist/{chunk-J5DB4KHE.js.map → chunk-PIAWSWLQ.js.map} +1 -1
- package/dist/{chunk-WLWHOA3S.js → chunk-QGDCLTK2.js} +4 -4
- package/dist/{chunk-WLWHOA3S.js.map → chunk-QGDCLTK2.js.map} +1 -1
- package/dist/{chunk-CBXZB3G5.js → chunk-RVXP5KN5.js} +3 -3
- package/dist/{chunk-CBXZB3G5.js.map → chunk-RVXP5KN5.js.map} +1 -1
- package/dist/{chunk-KYC6JH75.js → chunk-UKJMQZV6.js} +3 -3
- package/dist/{chunk-KYC6JH75.js.map → chunk-UKJMQZV6.js.map} +1 -1
- package/dist/{chunk-2DYJ7BJG.js → chunk-WCFB2EPJ.js} +42 -11
- package/dist/chunk-WCFB2EPJ.js.map +1 -0
- package/dist/{chunk-HAXQAC6D.js → chunk-XPHQSIFZ.js} +3 -3
- package/dist/{chunk-HAXQAC6D.js.map → chunk-XPHQSIFZ.js.map} +1 -1
- package/dist/{chunk-C54IAYEU.js → chunk-Y2OCHNEH.js} +3 -3
- package/dist/{chunk-C54IAYEU.js.map → chunk-Y2OCHNEH.js.map} +1 -1
- package/dist/{chunk-EAWENE2K.js → chunk-ZFZ2BFQQ.js} +4 -4
- package/dist/{chunk-EAWENE2K.js.map → chunk-ZFZ2BFQQ.js.map} +1 -1
- package/dist/cli/index.js +95 -74
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/src/commands/source.d.ts.map +1 -1
- package/dist/connectors/config.js +8 -8
- package/dist/connectors/index.js +9 -9
- package/dist/core/index.js +7 -7
- package/dist/core/manifest.js +2 -2
- package/dist/core/models.js +1 -1
- package/dist/core/publish-manifest.js +2 -2
- package/dist/core/ref.d.ts +2 -0
- package/dist/core/ref.js +29 -0
- package/dist/core/ref.js.map +1 -0
- package/dist/core/runtime-assets.js +5 -5
- package/dist/core/src/index.d.ts +1 -1
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/manifest.d.ts +0 -14
- package/dist/core/src/manifest.d.ts.map +1 -1
- package/dist/core/src/models.d.ts +20 -0
- package/dist/core/src/models.d.ts.map +1 -1
- package/dist/core/src/ref.d.ts +25 -0
- package/dist/core/src/ref.d.ts.map +1 -0
- package/dist/core/src/walker.d.ts.map +1 -1
- package/dist/core/workspace-config.js +4 -4
- package/dist/deploy/index.js +7 -7
- package/dist/discovery/index.js +4 -4
- package/dist/{ensure-sources-XITKRBLU.js → ensure-sources-P2O7ATDO.js} +13 -13
- package/dist/{ensure-sources-XITKRBLU.js.map → ensure-sources-P2O7ATDO.js.map} +1 -1
- package/dist/factory-assets/connectors/deploy.js +9 -9
- package/dist/factory-assets/connectors/devserver.js +9 -9
- package/dist/factory-assets/connectors/flow/adapter.js +9 -9
- package/dist/factory-assets/connectors/flow/engine.js +7 -7
- package/dist/factory-assets/connectors/flow/run-flow.js +10 -10
- package/dist/factory-assets/connectors/flow.js +9 -9
- package/dist/factory-assets/connectors/git.js +9 -9
- package/dist/factory-assets/connectors/gmail.js +9 -9
- package/dist/factory-assets/connectors/googledrive.js +9 -9
- package/dist/factory-assets/connectors/local.js +9 -9
- package/dist/factory-assets/connectors/mattermost.js +9 -9
- package/dist/factory-assets/connectors/memory.js +9 -9
- package/dist/factory-assets/connectors/minio.js +9 -9
- package/dist/factory-assets/connectors/postgres.js +9 -9
- package/dist/factory-assets/connectors/s3.js +9 -9
- package/dist/factory-assets/connectors/sharepoint.js +9 -9
- package/dist/factory-assets/connectors/sqlite.js +9 -9
- package/dist/factory-assets/connectors/static-server.js +9 -9
- package/dist/factory-assets/connectors/tunnel.js +9 -9
- package/dist/factory-assets/connectors/webdav.js +9 -9
- package/dist/factory-assets/connectors/xstate-store.js +9 -9
- package/dist/factory-assets/connectors/xstate.js +9 -9
- package/dist/{flows-BOJMGLRI.js → flows-2HE7KTMA.js} +4 -4
- package/dist/{flows-BOJMGLRI.js.map → flows-2HE7KTMA.js.map} +1 -1
- package/dist/library/index.js +11 -11
- package/dist/library/install.js +8 -8
- package/dist/open-library-XBZTS6OM.js +23 -0
- package/dist/{open-library-5KJOZHG7.js.map → open-library-XBZTS6OM.js.map} +1 -1
- package/dist/paths-FUTWU7TP.js +15 -0
- package/dist/{paths-66ZDGXK3.js.map → paths-FUTWU7TP.js.map} +1 -1
- package/dist/{plugin-store-BOQXW3XV.js → plugin-store-ULRBL4YO.js} +9 -9
- package/dist/{plugin-store-BOQXW3XV.js.map → plugin-store-ULRBL4YO.js.map} +1 -1
- package/dist/runner/index.js +11 -11
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +9 -9
- package/dist/sdk/core.js +7 -7
- package/dist/sdk/flow.js +7 -7
- package/dist/sdk/index.js +11 -11
- package/dist/sdk/runner.js +11 -11
- package/dist/{setup-JIGNL3O4.js → setup-VIECJRD7.js} +9 -9
- package/dist/{setup-JIGNL3O4.js.map → setup-VIECJRD7.js.map} +1 -1
- package/dist/store-client-UG2GRPXB.js +15 -0
- package/dist/{store-client-ODJJK5XS.js.map → store-client-UG2GRPXB.js.map} +1 -1
- package/dist/tui/index.js +11 -11
- package/dist/workspace-plugin/adapters/mcp.js +2 -2
- package/dist/workspace-plugin/adapters/omp.js +3 -3
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +7 -1
- package/dist/chunk-2DYJ7BJG.js.map +0 -1
- package/dist/chunk-BM7XANVN.js.map +0 -1
- package/dist/chunk-FBIQ4QPF.js.map +0 -1
- package/dist/chunk-HL66R2P2.js.map +0 -1
- package/dist/chunk-MAPRKFBD.js.map +0 -1
- package/dist/open-library-5KJOZHG7.js +0 -23
- package/dist/paths-66ZDGXK3.js +0 -15
- package/dist/store-client-ODJJK5XS.js +0 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseDep } from './chunk-
|
|
1
|
+
import { parseDep, isValidAssetName, slugifyAssetName } from './chunk-GEEW6SY2.js';
|
|
2
2
|
import { readFileSync, readdirSync, statSync } from 'fs';
|
|
3
3
|
import { basename, dirname, join } from 'path';
|
|
4
4
|
import { parse } from 'yaml';
|
|
@@ -291,9 +291,24 @@ function* walkDir(dir) {
|
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
+
function normalizeEntryName(e) {
|
|
295
|
+
if (isValidAssetName(e.name)) return;
|
|
296
|
+
let slug;
|
|
297
|
+
try {
|
|
298
|
+
slug = slugifyAssetName(e.name);
|
|
299
|
+
} catch {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const original = e.name;
|
|
303
|
+
e.name = slug;
|
|
304
|
+
if (e.metadata?.displayName === void 0) {
|
|
305
|
+
e.metadata = { ...e.metadata, displayName: original };
|
|
306
|
+
}
|
|
307
|
+
}
|
|
294
308
|
function scanDirectory(root, repoName) {
|
|
295
309
|
const entries = /* @__PURE__ */ new Map();
|
|
296
310
|
function add(e) {
|
|
311
|
+
normalizeEntryName(e);
|
|
297
312
|
const key = `${e.kind}:${e.name}`;
|
|
298
313
|
const existing = entries.get(key);
|
|
299
314
|
if (!existing) {
|
|
@@ -322,5 +337,5 @@ function scanDirectory(root, repoName) {
|
|
|
322
337
|
}
|
|
323
338
|
|
|
324
339
|
export { bundleDepRefs, fromAgentMd, fromAgentYaml, fromBundleYaml, fromConnectorMd, fromContractMd, fromFlowYaml, fromKnowledgeYaml, fromMcpServerMd, fromPromptMd, fromSkillMd, parseFrontmatter, parseRequires, scanDirectory, walkDir };
|
|
325
|
-
//# sourceMappingURL=chunk-
|
|
326
|
-
//# sourceMappingURL=chunk-
|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CAAK,SAAS,YAAY,CAAA;AAChE,QAAA,GAAA,CAAI,YAAA,CAAa,QAAA,EAAU,QAAQ,CAAC,CAAA;AAAA,IACxC,CAAA,CAAA,MAAQ;AAAA,IAAC;AAAA,EACX;AAEA,EAAA,OAAO,CAAC,GAAG,OAAA,CAAQ,MAAA,EAAQ,CAAA;AAC7B","file":"chunk-B5PEERRZ.js","sourcesContent":["/**\n * Manifest parsing — reads SKILL.md, AGENT.md, agent.yaml, CONTRACT.md,\n * CONNECTOR.md, *.prompt.md, *.flow.yaml, *.bundle.yaml files and\n * produces CatalogEntry objects.\n * Used by @skaile/asset-manager for on-demand repo scanning.\n */\n\nimport { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\nimport { parse } from \"yaml\";\nimport type { AssetKind, CatalogEntry, Dependency } from \"./models.js\";\nimport { isValidAssetName, parseDep, slugifyAssetName } from \"./models.js\";\n\n// ── Frontmatter helpers ───────────────────────────────────────────────────────\n\n/**\n * Result of parsing YAML frontmatter from a markdown file.\n * @docLink packages/core/concepts#frontmatter-result\n */\nexport interface FrontmatterResult {\n /** Parsed YAML data. Empty object if no frontmatter block is present. */\n data: Record<string, unknown>;\n /** Markdown body below the frontmatter block (trimmed). */\n body: string;\n}\n\n/**\n * Parse YAML frontmatter from a markdown file (`---` delimited).\n * Returns `{ data: {}, body: text }` when no frontmatter block is present.\n *\n * @param text - Raw file contents\n * @returns Parsed frontmatter data and the remaining body text\n * @docLink packages/core/concepts#parse-frontmatter\n */\nexport function parseFrontmatter(text: string): FrontmatterResult {\n const m = text.match(/^---\\s*\\n([\\s\\S]*?)\\n---/);\n if (!m) return { data: {}, body: text.trim() };\n try {\n const data = (parse(m[1]!) as Record<string, unknown>) ?? {};\n const body = text.slice(m[0].length).trim();\n return { data, body };\n } catch {\n return { data: {}, body: text.trim() };\n }\n}\n\n/** Extract version from frontmatter, checking both top-level and metadata.version. */\nfunction extractVersion(meta: Record<string, unknown>): string {\n return String(\n meta.version ?? (meta.metadata as Record<string, unknown> | undefined)?.version ?? \"\",\n );\n}\n\n/**\n * Parse the `requires:` field from manifest frontmatter into typed `Dependency` objects.\n * Accepts a comma-separated string or an array of `\"kind:name\"` strings. Reads from either\n * the root or `metadata.requires` (matching `extractVersion`'s dual-location behavior) so\n * skill authors can follow the agentskills.io convention of placing skaile extensions under\n * `metadata:` while remaining backward-compatible with root-level declarations.\n *\n * @param meta - Parsed frontmatter data object\n * @returns Array of `Dependency` objects (empty when `requires` is absent)\n * @docLink packages/core/concepts#parse-requires\n */\nexport function parseRequires(meta: Record<string, unknown>): Dependency[] {\n const raw = meta.requires ?? (meta.metadata as Record<string, unknown> | undefined)?.requires;\n if (!raw) return [];\n const list =\n typeof raw === \"string\"\n ? raw.split(\",\").map((s) => s.trim())\n : Array.isArray(raw)\n ? (raw as string[])\n : [];\n return list.filter(Boolean).map(parseDep);\n}\n\n// ── agent.yaml dependency collectors ───────────────────────────────────────────\n\n/**\n * Collect named sub-agent dependencies from an `agent.yaml` array field.\n * Each `{name, ...}` object entry becomes an `{kind: \"agent\", name}` dependency.\n * Covers both the new `requires[]` and legacy `dependencies[]` formats.\n */\nfunction collectAgentDeps(raw: unknown, out: Dependency[]): void {\n if (!Array.isArray(raw)) return;\n for (const d of raw) {\n if (typeof d === \"object\" && d !== null && \"name\" in d) {\n out.push({ kind: \"agent\", name: String((d as Record<string, unknown>).name) });\n }\n }\n}\n\n/**\n * Collect string refs from an `agent.yaml` array field (`abilities[]`,\n * `contracts[]`) as `{kind, name}` dependencies, skipping empty entries.\n */\nfunction collectStringRefs(raw: unknown, kind: Dependency[\"kind\"], out: Dependency[]): void {\n if (!Array.isArray(raw)) return;\n for (const r of raw) {\n if (typeof r === \"string\" && r) out.push({ kind, name: r });\n }\n}\n\n/**\n * Collect catalog refs from an `agent.yaml` mixin field (`persona`, `rules`,\n * `knowledge`) as requires so `skaile install` pulls them automatically. Local\n * paths (`.`/`/`) are skipped — not catalog assets. Refs without a `kind:`\n * prefix get `defaultKind` injected; the publisher scope and `#pin` are stripped\n * so only `kind:name` is tracked.\n */\nfunction collectMixinRefs(raw: unknown, defaultKind: string, out: Dependency[]): void {\n if (!Array.isArray(raw)) return;\n for (const r of raw) {\n if (typeof r !== \"string\" || !r) continue;\n if (r.startsWith(\".\") || r.startsWith(\"/\")) continue; // local path — skip\n // Normalize: if no kind: prefix, inject the default kind\n const normalized = r.includes(\":\") ? r : `${defaultKind}:${r}`;\n // Only kind:name matters for requires — strip the publisher scope and #pin.\n const colonIdx = normalized.indexOf(\":\");\n const kind = normalized.slice(0, colonIdx).trim();\n let rest = normalized.slice(colonIdx + 1).trim();\n const hashIdx = rest.indexOf(\"#\");\n if (hashIdx !== -1) rest = rest.slice(0, hashIdx).trim();\n let name: string;\n if (rest.startsWith(\"@\")) {\n // Scoped form @publisher/name → name is the segment after the slash.\n const slashIdx = rest.indexOf(\"/\");\n name = slashIdx !== -1 ? rest.slice(slashIdx + 1).trim() : \"\";\n } else {\n // Legacy name@publisher (deprecated) or a bare name.\n const atIdx = rest.indexOf(\"@\");\n name = atIdx !== -1 ? rest.slice(0, atIdx).trim() : rest;\n }\n if (name) out.push({ kind, name });\n }\n}\n\n// ── Manifest parsers ──────────────────────────────────────────────────────────\n\n/**\n * Parse a `SKILL.md` file into a `CatalogEntry`.\n * The `kind` field defaults to `\"skill\"` but can be overridden to `\"agent\"` or `\"prompt\"`\n * via the `type:` frontmatter key. Falls back to the parent directory name when `name:` is absent.\n *\n * @param filePath - Absolute path to the `SKILL.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind, name, description, version, and requires\n * @docLink packages/core/concepts#from-skill-md\n */\nexport function fromSkillMd(filePath: string, repoName: string): CatalogEntry {\n const { data: meta } = parseFrontmatter(readFileSync(filePath, \"utf8\"));\n let kind = String(meta.type ?? \"skill\") as AssetKind;\n if (![\"skill\", \"agent\", \"prompt\", \"persona\", \"ruleset\", \"knowledge\"].includes(kind))\n kind = \"skill\";\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind,\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse an `AGENT.md` file into a `CatalogEntry` with `kind: \"agent\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * @param filePath - Absolute path to the `AGENT.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"agent\"`\n * @docLink packages/core/concepts#from-agent-md\n */\nexport function fromAgentMd(filePath: string, repoName: string): CatalogEntry {\n const { data: meta } = parseFrontmatter(readFileSync(filePath, \"utf8\"));\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"agent\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse an `agent.yaml` file into a `CatalogEntry` with `kind: \"agent\"`.\n * Collects sub-agent dependencies from `requires[]` (new format) and `dependencies[]`\n * (legacy format), skill abilities from `abilities[]`, and contracts from `contracts[]`.\n *\n * @param filePath - Absolute path to the `agent.yaml` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"agent\"` and full dependency graph\n * @docLink packages/core/concepts#from-agent-yaml\n */\nexport function fromAgentYaml(filePath: string, repoName: string): CatalogEntry {\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(readFileSync(filePath, \"utf8\")) as Record<string, unknown>) ?? {};\n } catch {}\n\n const requires: Dependency[] = [];\n\n // Sub-agent dependencies from requires[] (new format: {name, source, ...})\n collectAgentDeps(meta.requires, requires);\n // Legacy sub-agent dependencies from dependencies[] (old format: {name, ...})\n collectAgentDeps(meta.dependencies, requires);\n // Skill abilities referenced in the system prompt\n collectStringRefs(meta.abilities, \"skill\", requires);\n // Contracts referenced in the system prompt (co-located in skills dir)\n collectStringRefs(meta.contracts, \"contract\", requires);\n\n // Mixin composition fields — track catalog refs as requires so `skaile install`\n // automatically pulls them. Local paths (. or /) are skipped — not catalog assets.\n for (const [field, defaultKind] of [\n [\"persona\", \"persona\"],\n [\"rules\", \"ruleset\"],\n [\"knowledge\", \"knowledge\"],\n ] as const) {\n collectMixinRefs(meta[field], defaultKind, requires);\n }\n\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"agent\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: String(meta.version ?? \"\"),\n requires,\n dependencies: [],\n };\n}\n\n/**\n * Parse a `*.prompt.md` file into a `CatalogEntry` with `kind: \"prompt\"`.\n * The name defaults to the filename stem (without the `.prompt.md` suffix)\n * when no `name:` frontmatter key is present.\n *\n * @param filePath - Absolute path to the `.prompt.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"prompt\"`\n * @docLink packages/core/concepts#from-prompt-md\n */\nexport function fromPromptMd(filePath: string, repoName: string): CatalogEntry {\n const { data: meta } = parseFrontmatter(readFileSync(filePath, \"utf8\"));\n const name = String(meta.name ?? basename(filePath).replace(/\\.prompt\\.md$/, \"\"));\n return {\n name,\n kind: \"prompt\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse a `*.flow.yaml` or `*.flow.json` file into a `CatalogEntry` with `kind: \"flow\"`.\n * The name resolves from `name:` or `id:` frontmatter, falling back to the filename stem.\n *\n * @param filePath - Absolute path to the flow definition file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"flow\"`\n * @docLink packages/core/concepts#from-flow-yaml\n */\nexport function fromFlowYaml(filePath: string, repoName: string): CatalogEntry {\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(readFileSync(filePath, \"utf8\")) as Record<string, unknown>) ?? {};\n } catch {}\n\n const stem = basename(filePath)\n .replace(/\\.flow\\.yaml$/, \"\")\n .replace(/\\.flow\\.json$/, \"\");\n return {\n name: String(meta.name ?? meta.id ?? stem),\n kind: \"flow\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: String(meta.version ?? \"\"),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse a `*.bundle.yaml` file into a `CatalogEntry` with `kind: \"bundle\"`.\n * Bundles declare a flat list of string `dependencies` (asset refs) rather than\n * typed `Dependency` objects; both `requires` and `dependencies` are populated.\n *\n * @param filePath - Absolute path to the bundle YAML file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"bundle\"`\n * @docLink packages/core/concepts#from-bundle-yaml\n */\nexport function fromBundleYaml(filePath: string, repoName: string): CatalogEntry {\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(readFileSync(filePath, \"utf8\")) as Record<string, unknown>) ?? {};\n } catch {}\n\n const name = String(meta.name ?? basename(filePath).replace(/\\.bundle\\.yaml$/, \"\"));\n\n const deps = meta.dependencies;\n const dependencies = Array.isArray(deps) ? (deps as string[]).filter(Boolean) : [];\n\n return {\n name,\n kind: \"bundle\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: String(meta.version ?? \"\"),\n requires: parseRequires(meta),\n dependencies,\n };\n}\n\n/**\n * Extract a bundle's raw transitive dependency ref strings from its manifest\n * file — the union of its `requires` and `dependencies` lists, kept verbatim\n * (publisher/pin qualifiers preserved, comments dropped by the parser).\n *\n * Supports both `*.bundle.yaml` (top-level `requires`/`dependencies`) and the\n * `BUNDLE.md` frontmatter layout (`requires`/`dependencies`, incl. nested under\n * `metadata`). Unlike {@link parseRequires}, refs are returned as-is — the\n * resolver needs the full `kind:name@<publisher>[#pin]` form, not a\n * publisher-stripped {@link Dependency}.\n *\n * @param filePath - Absolute path to the bundle's `.bundle.yaml` or `BUNDLE.md`.\n * @returns Deduped list of ref strings; `[]` on parse failure or no deps.\n * @docLink packages/core/concepts#bundle-dep-refs\n */\nexport function bundleDepRefs(filePath: string): string[] {\n let meta: Record<string, unknown> = {};\n try {\n meta = filePath.endsWith(\".bundle.yaml\")\n ? ((parse(readFileSync(filePath, \"utf8\")) as Record<string, unknown>) ?? {})\n : parseFrontmatter(readFileSync(filePath, \"utf8\")).data;\n } catch {\n return [];\n }\n const out: string[] = [];\n const collect = (v: unknown) => {\n if (Array.isArray(v))\n for (const x of v) if (typeof x === \"string\" && x.trim()) out.push(x.trim());\n };\n collect(meta.requires);\n collect((meta.metadata as Record<string, unknown> | undefined)?.requires);\n collect(meta.dependencies);\n return [...new Set(out)];\n}\n\n/**\n * Parse a `CONTRACT.md` file into a `CatalogEntry` with `kind: \"contract\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * @param filePath - Absolute path to the `CONTRACT.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"contract\"`\n * @docLink packages/core/concepts#from-contract-md\n */\nexport function fromContractMd(filePath: string, repoName: string): CatalogEntry {\n const { data: meta } = parseFrontmatter(readFileSync(filePath, \"utf8\"));\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"contract\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse an `MCP.md` file into a `CatalogEntry` with `kind: \"mcp-server\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * Frontmatter fields (catalog identity):\n * - `name` — server name (default: parent dir name)\n * - `description` — short description\n * - `version` — semver\n * - `keywords` — array of discovery tags\n *\n * Frontmatter fields (runtime defaults, stored in `metadata`):\n * - `transport` — \"stdio\" | \"sse\" | \"http\" (default: \"stdio\")\n * - `command` — command to execute (stdio)\n * - `args` — command arguments (stdio)\n * - `env` — environment variables (stdio)\n * - `url` — server URL (sse/http)\n * - `headers` — HTTP headers (sse/http)\n *\n * When `mcp:name` appears in `skaile.yaml` `dependencies`, the runner reads\n * these defaults from `metadata` to build a `McpServerDeclaration` without\n * requiring verbose inline config.\n *\n * @param filePath - Absolute path to the `MCP.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"mcp-server\"`\n * @docLink packages/core/concepts#from-mcp-server-md\n */\nexport function fromMcpServerMd(filePath: string, repoName: string): CatalogEntry {\n const { data: meta } = parseFrontmatter(readFileSync(filePath, \"utf8\"));\n\n // Extract runtime defaults into metadata\n const metadata: Record<string, unknown> = {};\n if (meta.transport) metadata.transport = String(meta.transport);\n if (meta.command) metadata.command = String(meta.command);\n if (Array.isArray(meta.args)) metadata.args = meta.args.map(String);\n if (meta.env && typeof meta.env === \"object\" && !Array.isArray(meta.env)) {\n metadata.env = meta.env as Record<string, string>;\n }\n if (meta.url) metadata.url = String(meta.url);\n if (meta.headers && typeof meta.headers === \"object\" && !Array.isArray(meta.headers)) {\n metadata.headers = meta.headers as Record<string, string>;\n }\n if (meta.recipe && typeof meta.recipe === \"object\" && !Array.isArray(meta.recipe)) {\n metadata.recipe = meta.recipe;\n }\n\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"mcp-server\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n metadata: Object.keys(metadata).length > 0 ? metadata : undefined,\n };\n}\n\n/**\n * Parse a `knowledge.yaml` file into a `CatalogEntry` with `kind: \"knowledge\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * @param filePath - Absolute path to the `knowledge.yaml` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"knowledge\"`\n * @docLink packages/core/concepts#from-knowledge-yaml\n */\nexport function fromKnowledgeYaml(filePath: string, repoName: string): CatalogEntry {\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(readFileSync(filePath, \"utf8\")) as Record<string, unknown>) ?? {};\n } catch {}\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"knowledge\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: String(meta.version ?? \"\"),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse a `CONNECTOR.md` file into a `CatalogEntry` with `kind: \"connector\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * Frontmatter fields (catalog identity):\n * - `name` — connector name (default: parent dir name)\n * - `description` — short description\n * - `version` — semver\n *\n * Frontmatter fields (runtime defaults, stored in `metadata`):\n * - `entry` — adapter entry point (default: \"./adapter.ts\")\n * - `npm_deps` — npm dependencies required by the adapter\n * - `fields` — configuration fields the adapter expects\n * - `health_check` — whether to run a health check on connect\n *\n * The markdown body (below the frontmatter) is stored in `metadata.body`\n * so the runner can inject the connector's skill description into the\n * system prompt when `expose_as_skill` is enabled.\n *\n * @param filePath - Absolute path to the `CONNECTOR.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"connector\"`\n * @docLink packages/core/concepts#from-connector-md\n */\nexport function fromConnectorMd(filePath: string, repoName: string): CatalogEntry {\n const text = readFileSync(filePath, \"utf-8\");\n const { data: meta, body } = parseFrontmatter(text);\n const name = String(meta.name ?? basename(dirname(filePath)));\n return {\n name,\n kind: \"connector\" as AssetKind,\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n metadata: {\n entry: meta.entry ?? \"./adapter.ts\",\n npm_deps: meta.npm_deps ?? {},\n fields: meta.fields ?? [],\n health_check: meta.health_check ?? null,\n body,\n },\n };\n}\n\n// ── Recursive walker ──────────────────────────────────────────────────────────\n\ninterface WalkEntry {\n path: string;\n name: string;\n}\n\n/**\n * Recursively yield every file entry under `dir`, sorted alphabetically at each level.\n * Skips `.git` and `node_modules` directories and follows symlinks (resolving to\n * the stat target). `node_modules` is excluded because Bun's `node_modules/.bun/...`\n * layout contains symlink farms that form cycles when packages reference each other\n * transitively — entering them causes unbounded recursion in this walker.\n *\n * @param dir - Absolute path to the directory to walk\n * @docLink packages/core/concepts#walk-dir\n */\nexport function* walkDir(dir: string): Generator<WalkEntry> {\n let dirEntries: import(\"node:fs\").Dirent<string>[];\n try {\n dirEntries = readdirSync(dir, { withFileTypes: true, encoding: \"utf8\" });\n } catch {\n return;\n }\n for (const e of dirEntries.sort((a, b) => (a.name < b.name ? -1 : 1))) {\n const full = join(dir, e.name);\n if (e.isSymbolicLink()) {\n try {\n if (statSync(full).isDirectory()) yield* walkDir(full);\n else yield { path: full, name: e.name };\n } catch {}\n } else if (e.isDirectory()) {\n if (e.name !== \".git\" && e.name !== \"node_modules\") yield* walkDir(full);\n } else if (e.isFile()) {\n yield { path: full, name: e.name };\n }\n }\n}\n\n// ── Public scanner ────────────────────────────────────────────────────────────\n\n/**\n * Walk `root` recursively and return a `CatalogEntry` for every recognized asset manifest found.\n *\n * Recognized filenames: `SKILL.md`, `AGENT.md`, `agent.yaml`, `CONTRACT.md`, `MCP.md`,\n * `CONNECTOR.md`, `*.prompt.md`, `*.bundle.yaml`, `*.flow.yaml`, `*.flow.json`.\n *\n * When two entries share the same `kind:name` key, the one with the alphabetically\n * later source path wins (consistent with catalog precedence rules).\n *\n * @param root - Absolute path to the directory tree to scan\n * @param repoName - Repository name attached to every produced entry\n * @returns Array of deduplicated `CatalogEntry` objects, one per manifest file\n * @docLink packages/core/concepts#scan-directory\n */\n/**\n * Coerce a scanned entry's `name` to a canonical asset name in place. When the\n * raw name is already canonical this is a no-op; otherwise the original is stashed\n * on `metadata.displayName` (only when not already set) so callers keep the pretty\n * label for display while identity uses the slug. A name that slugifies to empty\n * is left untouched — `parseAssetRef` will reject it downstream with its full hint.\n */\nfunction normalizeEntryName(e: CatalogEntry): void {\n if (isValidAssetName(e.name)) return;\n let slug: string;\n try {\n slug = slugifyAssetName(e.name);\n } catch {\n return;\n }\n const original = e.name;\n e.name = slug;\n if (e.metadata?.displayName === undefined) {\n e.metadata = { ...e.metadata, displayName: original };\n }\n}\n\nexport function scanDirectory(root: string, repoName: string): CatalogEntry[] {\n const entries = new Map<string, CatalogEntry>();\n\n function add(e: CatalogEntry): void {\n // Boundary normalization: a third-party source we don't control may name an\n // asset with a human-styled identity (\"Complex App\"). Slugify it to a\n // canonical name so the ref it produces parses, preserving the original on\n // `metadata.displayName` for display. No-op for already-canonical names.\n normalizeEntryName(e);\n const key = `${e.kind}:${e.name}`;\n const existing = entries.get(key);\n if (!existing) {\n entries.set(key, e);\n return;\n }\n // Among duplicates, alphabetically later source path wins\n if (e.source > existing.source) entries.set(key, e);\n }\n\n for (const { path: filePath, name } of walkDir(root)) {\n try {\n if (name === \"SKILL.md\") add(fromSkillMd(filePath, repoName));\n else if (name === \"AGENT.md\") add(fromAgentMd(filePath, repoName));\n else if (name === \"agent.yaml\") add(fromAgentYaml(filePath, repoName));\n else if (name === \"CONTRACT.md\") add(fromContractMd(filePath, repoName));\n else if (name === \"MCP.md\") add(fromMcpServerMd(filePath, repoName));\n else if (name === \"CONNECTOR.md\") add(fromConnectorMd(filePath, repoName));\n else if (name === \"knowledge.yaml\") add(fromKnowledgeYaml(filePath, repoName));\n else if (name.endsWith(\".prompt.md\")) add(fromPromptMd(filePath, repoName));\n else if (name.endsWith(\".bundle.yaml\")) add(fromBundleYaml(filePath, repoName));\n else if (name.endsWith(\".flow.yaml\") || name.endsWith(\".flow.json\"))\n add(fromFlowYaml(filePath, repoName));\n } catch {}\n }\n\n return [...entries.values()];\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveSkWorkspaceConfig, readLinks } from './chunk-
|
|
2
|
-
import { scanDirectory } from './chunk-
|
|
1
|
+
import { resolveSkWorkspaceConfig, readLinks } from './chunk-2PXSZYKV.js';
|
|
2
|
+
import { scanDirectory } from './chunk-B5PEERRZ.js';
|
|
3
3
|
import { existsSync, readFileSync, lstatSync } from 'fs';
|
|
4
4
|
import { createRequire } from 'module';
|
|
5
5
|
import { homedir } from 'os';
|
|
@@ -209,5 +209,5 @@ function findCatalogEntry(entries, query) {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
export { FACTORY_ASSETS_REPO_NAME, factoryAssetRoots, resolveFactoryAssetsRoot, resolveFactoryAssetsRootOrNull, resolvePackagedAssetsDir, resolveRuntimeAssets, resolveWorkspacesPackageRoot };
|
|
212
|
-
//# sourceMappingURL=chunk-
|
|
213
|
-
//# sourceMappingURL=chunk-
|
|
212
|
+
//# sourceMappingURL=chunk-DUAB2AFV.js.map
|
|
213
|
+
//# sourceMappingURL=chunk-DUAB2AFV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../core/src/runtime-assets.ts"],"names":["resolvePath","require"],"mappings":";;;;;;;;AAoDA,SAAS,sBACP,OAAA,EACmC;AACnC,EAAA,MAAM,OAAO,OAAA,CAAQ,GAAA,CAAI,eAAe,IAAA,CAAK,OAAA,IAAW,SAAS,CAAA;AACjE,EAAA,MAAM,UAAA,GAAa,IAAA,CAAK,IAAA,EAAM,SAAS,CAAA;AACvC,EAAA,MAAM,MAAyC,EAAC;AAChD,EAAA,KAAA,MAAW,CAAA,IAAK,OAAA,IAAW,EAAC,EAAG;AAC7B,IAAA,MAAM,IAAA,GACJ,CAAA,CAAE,GAAA,CACC,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAA,CACpB,KAAA,CAAM,MAAM,CAAA,CACZ,GAAA,EAAI,IAAK,QAAA;AACd,IAAA,IAAI,GAAA,CAAI,IAAI,CAAA,EAAG;AACf,IAAA,GAAA,CAAI,IAAI,CAAA,GAAI,EAAE,IAAA,EAAM,IAAA,CAAK,UAAA,EAAY,IAAI,CAAA,EAAG,GAAA,EAAK,CAAA,CAAE,GAAA,EAAK,MAAA,EAAQ,EAAE,GAAA,EAAI;AAAA,EACxE;AACA,EAAA,OAAO,GAAA;AACT;AAqDO,IA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AAA,MAAQ;AACN,QAAA,OAAO,IAAA;AAAA,MACT;AAAA,IACF;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,sBAAA,CAAuB,MAAc,IAAA,EAAiC;AAC7E,EAAA,IAAI,SAAS,wBAAA,IAA4B,CAAC,KAAK,IAAA,IAAQ,CAAC,KAAK,GAAA,EAAK;AAChE,IAAA,OACE,CAAA,oHAAA,CAAA;AAAA,EAGJ;AACA,EAAA,IAAI,KAAK,GAAA,EAAK;AACZ,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,IAAA,CAAK,GAAG,CAAA,8EAAA,CAAA;AAAA,EAC1C;AACA,EAAA,IAAI,KAAK,IAAA,EAAM;AACb,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,kBAAA,EAAqB,IAAA,CAAK,IAAI,CAAA,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,eAAe,IAAI,CAAA,2BAAA,CAAA;AAC5B;AAEA,SAAS,gBAAA,CACP,SACA,KAAA,EACiC;AACjC,EAAA,IAAI,MAAM,IAAA,EAAM;AACd,IAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAA,IAAQ,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAI,CAAA;AAAA,EAC3E;AACA,EAAA,MAAM,OAAA,GAAU,QAAQ,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,IAAA,KAAS,MAAM,IAAI,CAAA;AAC3D,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG,OAAO,QAAQ,CAAC,CAAA;AAE1C,EAAA,OAAO,MAAA;AACT","file":"chunk-CFCSDZYF.js","sourcesContent":["/**\n * Runtime asset resolution — read `skaile.yaml`, scan all declared repositories\n * (including the built-in `factory-assets/` directory as an implicit default),\n * and produce a unified view of connector catalog entries plus the implicit refs\n * that the `skaile.yaml` `connectors:` section adds to the dependency graph.\n *\n * This module is the single source of truth for \"which connectors does this\n * project see at runtime, and where do their implementations live on disk\".\n * Both the runner (serve, REPL, flow) and the platform's mid-session\n * `add_resource` flow consume `RuntimeAssetsResult.catalogEntries` and pass\n * it into `ConnectorManager` for catalog-based resolution.\n *\n * `factory-assets/` is the single first-party content tree (built-in connectors\n * + first-party skills + bundles) shipped inside the `@skaile/workspaces`\n * package — not a standalone package.\n *\n * It resolves to an **ordered list of roots** ({@link factoryAssetRoots}), not a\n * single dir. The bundled tree is always the baseline; an optional\n * `SKAILE_FACTORY_ASSETS_DIR` (legacy: `SKAILE_BASE_ASSETS_DIR`) is layered\n * **in front** as an additive override source — the agent container points it at\n * `/app/factory-assets/` (or a bind-mounted host dir) to ship updated skills /\n * flows / bundles / connector manifests without rebuilding the image. The two\n * roots resolve uniformly across every consumer (connector catalog scan, skill /\n * flow / completion discovery, the asset-manager factory source):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir, when set and existing (override layer).\n * 2. the bundled tree via {@link resolvePackagedAssetsDir} — the in-repo source\n * `packages/workspaces/factory-assets/` during dev, else the published\n * `dist/factory-assets/` after install (always-present baseline).\n *\n * Override semantics are **env-first**: on a name conflict the env root wins and\n * the bundled root fills the rest. Connector *code* still loads via the package's\n * static `exports` map, so the env root can override/add skills, flows, bundles,\n * and connector **manifests/metadata**, but cannot ship a new executable\n * connector — its `.js` is not on the package's import graph.\n */\n\nimport { existsSync, lstatSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, resolve as resolvePath } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { scanDirectory } from \"./manifest.js\";\nimport type { CatalogEntry } from \"./models.js\";\nimport { readLinks } from \"./repo-manager.js\";\nimport type { SourceDeclaration, SourceEntry } from \"./workspace-config.js\";\nimport { resolveSkWorkspaceConfig } from \"./workspace-config.js\";\n\n/**\n * Map declared `sources[]` to internal `SourceDeclaration`s keyed by the\n * URL-derived cache slug, pointing at the machine-cache clone path\n * (`~/.skaile/sources/<slug>/`).\n */\nfunction sourcesToDeclarations(\n sources: SourceEntry[] | undefined,\n): Record<string, SourceDeclaration> {\n const home = process.env.SKAILE_HOME ?? join(homedir(), \".skaile\");\n const sourcesDir = join(home, \"sources\");\n const out: Record<string, SourceDeclaration> = {};\n for (const s of sources ?? []) {\n const slug =\n s.url\n .replace(/\\.git$/, \"\")\n .split(/[/:]/)\n .pop() ?? \"source\";\n if (out[slug]) continue;\n out[slug] = { path: join(sourcesDir, slug), url: s.url, branch: s.pin };\n }\n return out;\n}\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Catalog entry filtered to mount/connector kinds. Same shape as `CatalogEntry`.\n * @docLink packages/core/concepts#runtime-catalog-entry\n */\nexport type RuntimeCatalogEntry = CatalogEntry;\n\n/**\n * Implicit catalog reference derived from a `connectors:` declaration in `skaile.yaml`.\n * Each connector driver becomes an implicit ref that must be resolved in the catalog.\n * @docLink packages/core/concepts#runtime-asset-ref\n */\nexport interface RuntimeAssetRef {\n kind: \"connector\";\n /** Driver name — matches `RuntimeCatalogEntry.name`. */\n name: string;\n /** Source declaration id from `skaile.yaml`. */\n declarationId: string;\n}\n\n/**\n * Aggregated npm packages required by all resolved mount/connector adapters.\n * Populated from `metadata.npm_deps` in each matched catalog entry.\n * @docLink packages/core/concepts#runtime-npm-deps\n */\nexport interface RuntimeNpmDeps {\n required: string[];\n optional: string[];\n}\n\n/**\n * Non-fatal warning emitted during `resolveRuntimeAssets` when a repo is unavailable\n * or a driver is not found in any catalog.\n * @docLink packages/core/concepts#runtime-asset-warning\n */\nexport interface RuntimeAssetWarning {\n /** Stable code for filtering / structured logging. */\n code: \"missing_driver\" | \"repo_unavailable\" | \"invalid_repo_decl\";\n message: string;\n /** Declaration id when applicable. */\n declarationId?: string;\n /** Driver / repository name when applicable. */\n name?: string;\n}\n\n/**\n * Repository name used for the implicit built-in `factory-assets` catalog entry\n * (the in-package connector tree).\n * @docLink packages/core/concepts#factory-assets-repo-name\n */\nexport const FACTORY_ASSETS_REPO_NAME = \"factory-assets\";\n\n/**\n * Repository name for the optional `SKAILE_FACTORY_ASSETS_DIR` override layer,\n * scanned ahead of (and overriding) the bundled {@link FACTORY_ASSETS_REPO_NAME}.\n */\nconst FACTORY_ASSETS_OVERRIDE_REPO_NAME = \"factory-assets:override\";\n\n/**\n * Result of `resolveRuntimeAssets`.\n * The same object is mutated in place by `refresh()`, allowing callers to hold\n * a stable reference and observe updates after a new repository is cloned or\n * a driver is installed mid-session.\n * @docLink packages/core/concepts#runtime-assets-result\n */\nexport interface RuntimeAssetsResult {\n catalogEntries: RuntimeCatalogEntry[];\n implicitRefs: RuntimeAssetRef[];\n requiredNpmDeps: RuntimeNpmDeps;\n warnings: RuntimeAssetWarning[];\n /** Re-scan repositories and re-derive implicit refs. Mutates in place. */\n refresh(): Promise<void>;\n /**\n * Catalog lookup. When `kind` is omitted and multiple entries share the\n * `name`, returns `undefined` (caller must disambiguate).\n */\n findEntry(query: { kind?: \"connector\"; name: string }): RuntimeCatalogEntry | undefined;\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/**\n * Resolve all runtime assets visible to a project by scanning declared repositories.\n *\n * Reads `skaile.yaml`, scans every declared repository (plus the implicit\n * built-in `factory-assets` repo), and derives implicit refs from `mounts:` /\n * `connectors:` declarations. Does not clone or install anything — purely a\n * read-only scan of what is already on disk. URL-only repositories that have\n * not been cloned yet are reported as `repo_unavailable` warnings.\n *\n * @param projectDir - Absolute path to the project workspace root\n * @returns `RuntimeAssetsResult` with catalog entries, implicit refs, npm deps, and warnings\n * @docLink packages/core/concepts#resolve-runtime-assets\n */\nexport async function resolveRuntimeAssets(projectDir: string): Promise<RuntimeAssetsResult> {\n const result: RuntimeAssetsResult = {\n catalogEntries: [],\n implicitRefs: [],\n requiredNpmDeps: { required: [], optional: [] },\n warnings: [],\n refresh: async () => {\n await populate(projectDir, result);\n },\n findEntry: (query) => findCatalogEntry(result.catalogEntries, query),\n };\n\n await populate(projectDir, result);\n return result;\n}\n\n/**\n * Resolve the ordered list of on-disk roots for the built-in `factory-assets`\n * tree (built-in connectors + first-party skills + bundles). This is the single\n * shared resolver every consumer goes through, so the env override and the\n * bundled baseline are honoured uniformly.\n *\n * Order (env-first = override-wins):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir (legacy: `SKAILE_BASE_ASSETS_DIR`),\n * when set and existing — an additive override layer.\n * 2. {@link resolvePackagedAssetsDir} — the bundled tree (in-repo source in dev,\n * `dist/factory-assets/` after install). Always-present baseline.\n *\n * Returns `[]` only when the package cannot be located at all. De-duplicated, so\n * pointing the env var at the bundled dir collapses to one root.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function factoryAssetRoots(): string[] {\n const roots: string[] = [];\n const envDir = process.env.SKAILE_FACTORY_ASSETS_DIR ?? process.env.SKAILE_BASE_ASSETS_DIR;\n if (envDir && existsSync(envDir)) roots.push(resolvePath(envDir));\n const bundled = resolvePackagedAssetsDir(\"factory-assets\");\n if (bundled) roots.push(bundled);\n return [...new Set(roots)];\n}\n\n/**\n * Resolve the primary on-disk root of the `factory-assets` tree — the first of\n * {@link factoryAssetRoots} (the env override when set, else the bundled tree).\n * Prefer {@link factoryAssetRoots} when you need to scan every layer; this\n * single-dir form is for callers that want one canonical path.\n *\n * @returns Absolute path to the highest-precedence `factory-assets` directory\n * @throws When no root can be located\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolveFactoryAssetsRoot(): string {\n const hit = resolveFactoryAssetsRootOrNull();\n if (hit) return hit;\n\n throw new Error(\n `Cannot resolve the factory-assets directory. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR to the on-disk path, ` +\n `ensure @skaile/workspaces is installed, ` +\n `or run from within the @skaile/workspaces package tree.`,\n );\n}\n\n/**\n * Non-throwing variant of {@link resolveFactoryAssetsRoot}: the same\n * env-then-packaged resolution tiers, returning `null` instead of throwing when\n * none locate the directory. Callers that treat a missing factory tree as a\n * soft \"not present\" (e.g. the asset-manager's implicit-source injection) MUST\n * use this so they honour the `SKAILE_FACTORY_ASSETS_DIR` container override\n * identically to the runtime path.\n */\nexport function resolveFactoryAssetsRootOrNull(): string | null {\n return factoryAssetRoots()[0] ?? null;\n}\n\n/**\n * Resolve the `@skaile/workspaces` package root — the directory containing its\n * `package.json`. Tries `require.resolve` first (works when installed as a\n * dependency *and* in-repo via the self-reference), then walks upward from this\n * module looking for a `package.json` whose `name` is `@skaile/workspaces`\n * (bounded to 8 levels). Returns `null` when neither locates it.\n *\n * The single source of truth for finding content shipped inside the package —\n * the unified `factory-assets/` tree (built-in connectors + first-party skills\n * + bundles) resolves through {@link resolvePackagedAssetsDir} on top of this.\n *\n * Memoized: the package location is immutable for the process lifetime, but\n * this sits on the CLI hot path (every `findSkills` / flow / completion call\n * funnels through here), so the `require.resolve` + upward `package.json` walk\n * runs once. `undefined` = not yet computed.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nlet workspacesPackageRootCache: string | null | undefined;\n\nexport function resolveWorkspacesPackageRoot(): string | null {\n if (workspacesPackageRootCache !== undefined) return workspacesPackageRootCache;\n workspacesPackageRootCache = computeWorkspacesPackageRoot();\n return workspacesPackageRootCache;\n}\n\nfunction computeWorkspacesPackageRoot(): string | null {\n try {\n const require = createRequire(import.meta.url);\n return dirname(require.resolve(\"@skaile/workspaces/package.json\"));\n } catch {\n // Fall through to the workspace walk.\n }\n let dir: string;\n try {\n dir = dirname(fileURLToPath(import.meta.url));\n } catch {\n return null;\n }\n for (let i = 0; i < 8; i++) {\n const pkgPath = join(dir, \"package.json\");\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as { name?: string };\n if (pkg.name === \"@skaile/workspaces\") return dir;\n } catch {\n // Ignore malformed package.json and keep walking.\n }\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Locate a content-asset directory inside the package. Prefers the in-repo\n * **source** dir `<pkgRoot>/<subdir>` when present — in a dev checkout it is the\n * full tree (e.g. `factory-assets/` keeps the connector `.ts` entry files that\n * `dist/` does not) — then the published `dist/<subdir>` copy (what\n * `files: [\"dist\"]` ships, the only one present after `npm i`). Returns `null`\n * when neither exists.\n *\n * `factory-assets/` resolves to the source tree in dev (code + skills + bundles)\n * and to `dist/factory-assets` post-install (compiled connectors + copied\n * manifests/skills/bundles).\n *\n * @param subdir - `\"factory-assets\"` | …\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolvePackagedAssetsDir(subdir: string): string | null {\n const root = resolveWorkspacesPackageRoot();\n if (!root) return null;\n for (const cand of [join(root, subdir), join(root, \"dist\", subdir)]) {\n if (existsSync(cand)) return cand;\n }\n return null;\n}\n\n// ─── Internals ────────────────────────────────────────────────────────────────\n\nasync function populate(projectDir: string, target: RuntimeAssetsResult): Promise<void> {\n target.catalogEntries = [];\n target.implicitRefs = [];\n target.requiredNpmDeps = { required: [], optional: [] };\n target.warnings = [];\n\n const config = resolveSkWorkspaceConfig(projectDir);\n // Connector catalog scan runs over the project's declared sources[] (resolved\n // to their machine-cache clone paths) plus the implicit factory-assets repo.\n const repositories = buildEffectiveRepositories(sourcesToDeclarations(config.sources));\n const links = readLinks(projectDir);\n\n // Scan each repository for connector entries.\n for (const [name, decl] of Object.entries(repositories)) {\n const repoDir = resolveRepoDir(name, decl, projectDir, links);\n if (!repoDir) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: repoUnavailableMessage(name, decl),\n });\n continue;\n }\n try {\n // Both factory layers carry the same `factory-assets` provenance — the\n // override repo is an internal scan-order device, not a distinct source.\n const repoName = name === FACTORY_ASSETS_OVERRIDE_REPO_NAME ? FACTORY_ASSETS_REPO_NAME : name;\n const entries = scanDirectory(repoDir, repoName).filter((e) => e.kind === \"connector\");\n target.catalogEntries.push(...entries);\n } catch (err) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: `Failed to scan repository \"${name}\" at ${repoDir}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n });\n }\n }\n\n // De-duplicate by (kind, name), keeping the first occurrence. Scan order is\n // declared sources → env override → bundled baseline, so an env-supplied\n // connector manifest overrides the bundled one and the bundled one fills the\n // rest (the override layer can refresh built-in manifests in place).\n const seen = new Set<string>();\n target.catalogEntries = target.catalogEntries.filter((e) => {\n const key = `${e.kind}:${e.name}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n\n // Derive implicit refs from skaile.yaml connectors.\n for (const c of config.connectors ?? []) {\n target.implicitRefs.push({ kind: \"connector\", name: c.driver, declarationId: c.id });\n }\n\n // Validate refs and aggregate npm deps.\n const requiredSet = new Set<string>();\n const optionalSet = new Set<string>();\n for (const ref of target.implicitRefs) {\n const entry = findCatalogEntry(target.catalogEntries, ref);\n if (!entry) {\n target.warnings.push({\n code: \"missing_driver\",\n declarationId: ref.declarationId,\n name: ref.name,\n message:\n `Unknown ${ref.kind} driver \"${ref.name}\" referenced by ${ref.kind} \"${ref.declarationId}\". ` +\n `Run \\`skaile ${ref.kind} catalog\\` to see available drivers, ` +\n `or declare a repository in skaile.yaml that provides this driver.`,\n });\n continue;\n }\n const npm = (entry.metadata?.npm_deps ?? {}) as { required?: string[]; optional?: string[] };\n for (const p of npm.required ?? []) requiredSet.add(p);\n for (const p of npm.optional ?? []) optionalSet.add(p);\n }\n target.requiredNpmDeps.required = [...requiredSet];\n target.requiredNpmDeps.optional = [...optionalSet];\n}\n\n/**\n * Build the effective `repositories` map: caller's declarations first, then the\n * implicit built-in `factory-assets` repos. Each {@link factoryAssetRoots} layer\n * becomes its own repo, the env override inserted **before** the bundled\n * baseline so its connector entries win on the first-match dedup downstream.\n * When the package cannot be located at all, a path-less sentinel under\n * {@link FACTORY_ASSETS_REPO_NAME} drives the `repo_unavailable` warning.\n */\nfunction buildEffectiveRepositories(\n declared: Record<string, SourceDeclaration> | undefined,\n): Record<string, SourceDeclaration> {\n const result: Record<string, SourceDeclaration> = { ...(declared ?? {}) };\n const roots = factoryAssetRoots();\n if (roots.length === 0) {\n // Surface as a warning during scan rather than throwing here — let the\n // caller decide whether factory-assets is required. resolveRepoDir() /\n // repoUnavailableMessage re-discover the failure and emit it.\n if (!result[FACTORY_ASSETS_REPO_NAME]) result[FACTORY_ASSETS_REPO_NAME] = { path: \"\" };\n return result;\n }\n // override-first when both layers exist, so the env root's entries are scanned\n // (and matched) ahead of the bundled baseline.\n const keys =\n roots.length > 1\n ? [FACTORY_ASSETS_OVERRIDE_REPO_NAME, FACTORY_ASSETS_REPO_NAME]\n : [FACTORY_ASSETS_REPO_NAME];\n roots.forEach((dir, i) => {\n const key = keys[i] ?? `${FACTORY_ASSETS_REPO_NAME}:${i}`;\n if (!result[key]) result[key] = { path: dir };\n });\n return result;\n}\n\n/**\n * Resolve a repository declaration to an on-disk directory. Order:\n * 1. Linked override (`.skaile/links.yaml`).\n * 2. Local `path` — relative to `projectDir`.\n * 3. Cloned URL repo at `.skaile/repos/<name>/` (must already exist).\n *\n * Returns `null` when none of these resolve. Does not clone.\n */\nfunction resolveRepoDir(\n name: string,\n decl: SourceDeclaration,\n projectDir: string,\n links: Record<string, string>,\n): string | null {\n // 1. Linked override\n const linked = links[name];\n if (linked && existsSync(linked)) return linked;\n\n // 2. Local path\n if (decl.path) {\n const resolved = resolvePath(projectDir, decl.path);\n return existsSync(resolved) ? resolved : null;\n }\n\n // 3. URL repo cloned to project's .skaile/repos/<name>\n if (decl.url) {\n const projectDest = join(projectDir, \".skaile\", \"repos\", name);\n if (existsSync(projectDest)) {\n // Either a real directory or a symlink to the global cache.\n try {\n lstatSync(projectDest);\n return projectDest;\n } catch {\n return null;\n }\n }\n return null;\n }\n\n return null;\n}\n\nfunction repoUnavailableMessage(name: string, decl: SourceDeclaration): string {\n if (name === FACTORY_ASSETS_REPO_NAME && !decl.path && !decl.url) {\n return (\n `Cannot resolve the built-in factory-assets. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR or ensure @skaile/workspaces is installed.`\n );\n }\n if (decl.url) {\n return `Repository \"${name}\" (${decl.url}) is not available. Register it as a Library Source via \\`skaile source add\\`.`;\n }\n if (decl.path) {\n return `Repository \"${name}\" path not found: ${decl.path}`;\n }\n return `Repository \"${name}\" has neither url nor path.`;\n}\n\nfunction findCatalogEntry(\n entries: RuntimeCatalogEntry[],\n query: { kind?: \"connector\"; name: string },\n): RuntimeCatalogEntry | undefined {\n if (query.kind) {\n return entries.find((e) => e.kind === query.kind && e.name === query.name);\n }\n const matches = entries.filter((e) => e.name === query.name);\n if (matches.length === 1) return matches[0];\n // 0 or >1 with no kind — caller must disambiguate.\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../core/src/runtime-assets.ts"],"names":["resolvePath","require"],"mappings":";;;;;;;;AAoDA,SAAS,sBACP,OAAA,EACmC;AACnC,EAAA,MAAM,OAAO,OAAA,CAAQ,GAAA,CAAI,eAAe,IAAA,CAAK,OAAA,IAAW,SAAS,CAAA;AACjE,EAAA,MAAM,UAAA,GAAa,IAAA,CAAK,IAAA,EAAM,SAAS,CAAA;AACvC,EAAA,MAAM,MAAyC,EAAC;AAChD,EAAA,KAAA,MAAW,CAAA,IAAK,OAAA,IAAW,EAAC,EAAG;AAC7B,IAAA,MAAM,IAAA,GACJ,CAAA,CAAE,GAAA,CACC,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAA,CACpB,KAAA,CAAM,MAAM,CAAA,CACZ,GAAA,EAAI,IAAK,QAAA;AACd,IAAA,IAAI,GAAA,CAAI,IAAI,CAAA,EAAG;AACf,IAAA,GAAA,CAAI,IAAI,CAAA,GAAI,EAAE,IAAA,EAAM,IAAA,CAAK,UAAA,EAAY,IAAI,CAAA,EAAG,GAAA,EAAK,CAAA,CAAE,GAAA,EAAK,MAAA,EAAQ,EAAE,GAAA,EAAI;AAAA,EACxE;AACA,EAAA,OAAO,GAA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AAA,MACT,CAAA,CAAA,MAAQ;AACN,QAAA,OAAO,IAAA;AAAA,MACT;AAAA,IACF;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,sBAAA,CAAuB,MAAc,IAAA,EAAiC;AAC7E,EAAA,IAAI,SAAS,wBAAA,IAA4B,CAAC,KAAK,IAAA,IAAQ,CAAC,KAAK,GAAA,EAAK;AAChE,IAAA,OACE,CAAA,oHAAA,CAAA;AAAA,EAGJ;AACA,EAAA,IAAI,KAAK,GAAA,EAAK;AACZ,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,IAAA,CAAK,GAAG,CAAA,8EAAA,CAAA;AAAA,EAC1C;AACA,EAAA,IAAI,KAAK,IAAA,EAAM;AACb,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,kBAAA,EAAqB,IAAA,CAAK,IAAI,CAAA,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,eAAe,IAAI,CAAA,2BAAA,CAAA;AAC5B;AAEA,SAAS,gBAAA,CACP,SACA,KAAA,EACiC;AACjC,EAAA,IAAI,MAAM,IAAA,EAAM;AACd,IAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAA,IAAQ,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAI,CAAA;AAAA,EAC3E;AACA,EAAA,MAAM,OAAA,GAAU,QAAQ,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,IAAA,KAAS,MAAM,IAAI,CAAA;AAC3D,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG,OAAO,QAAQ,CAAC,CAAA;AAE1C,EAAA,OAAO,MAAA;AACT","file":"chunk-DUAB2AFV.js","sourcesContent":["/**\n * Runtime asset resolution — read `skaile.yaml`, scan all declared repositories\n * (including the built-in `factory-assets/` directory as an implicit default),\n * and produce a unified view of connector catalog entries plus the implicit refs\n * that the `skaile.yaml` `connectors:` section adds to the dependency graph.\n *\n * This module is the single source of truth for \"which connectors does this\n * project see at runtime, and where do their implementations live on disk\".\n * Both the runner (serve, REPL, flow) and the platform's mid-session\n * `add_resource` flow consume `RuntimeAssetsResult.catalogEntries` and pass\n * it into `ConnectorManager` for catalog-based resolution.\n *\n * `factory-assets/` is the single first-party content tree (built-in connectors\n * + first-party skills + bundles) shipped inside the `@skaile/workspaces`\n * package — not a standalone package.\n *\n * It resolves to an **ordered list of roots** ({@link factoryAssetRoots}), not a\n * single dir. The bundled tree is always the baseline; an optional\n * `SKAILE_FACTORY_ASSETS_DIR` (legacy: `SKAILE_BASE_ASSETS_DIR`) is layered\n * **in front** as an additive override source — the agent container points it at\n * `/app/factory-assets/` (or a bind-mounted host dir) to ship updated skills /\n * flows / bundles / connector manifests without rebuilding the image. The two\n * roots resolve uniformly across every consumer (connector catalog scan, skill /\n * flow / completion discovery, the asset-manager factory source):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir, when set and existing (override layer).\n * 2. the bundled tree via {@link resolvePackagedAssetsDir} — the in-repo source\n * `packages/workspaces/factory-assets/` during dev, else the published\n * `dist/factory-assets/` after install (always-present baseline).\n *\n * Override semantics are **env-first**: on a name conflict the env root wins and\n * the bundled root fills the rest. Connector *code* still loads via the package's\n * static `exports` map, so the env root can override/add skills, flows, bundles,\n * and connector **manifests/metadata**, but cannot ship a new executable\n * connector — its `.js` is not on the package's import graph.\n */\n\nimport { existsSync, lstatSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, resolve as resolvePath } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { scanDirectory } from \"./manifest.js\";\nimport type { CatalogEntry } from \"./models.js\";\nimport { readLinks } from \"./repo-manager.js\";\nimport type { SourceDeclaration, SourceEntry } from \"./workspace-config.js\";\nimport { resolveSkWorkspaceConfig } from \"./workspace-config.js\";\n\n/**\n * Map declared `sources[]` to internal `SourceDeclaration`s keyed by the\n * URL-derived cache slug, pointing at the machine-cache clone path\n * (`~/.skaile/sources/<slug>/`).\n */\nfunction sourcesToDeclarations(\n sources: SourceEntry[] | undefined,\n): Record<string, SourceDeclaration> {\n const home = process.env.SKAILE_HOME ?? join(homedir(), \".skaile\");\n const sourcesDir = join(home, \"sources\");\n const out: Record<string, SourceDeclaration> = {};\n for (const s of sources ?? []) {\n const slug =\n s.url\n .replace(/\\.git$/, \"\")\n .split(/[/:]/)\n .pop() ?? \"source\";\n if (out[slug]) continue;\n out[slug] = { path: join(sourcesDir, slug), url: s.url, branch: s.pin };\n }\n return out;\n}\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Catalog entry filtered to mount/connector kinds. Same shape as `CatalogEntry`.\n * @docLink packages/core/concepts#runtime-catalog-entry\n */\nexport type RuntimeCatalogEntry = CatalogEntry;\n\n/**\n * Implicit catalog reference derived from a `connectors:` declaration in `skaile.yaml`.\n * Each connector driver becomes an implicit ref that must be resolved in the catalog.\n * @docLink packages/core/concepts#runtime-asset-ref\n */\nexport interface RuntimeAssetRef {\n kind: \"connector\";\n /** Driver name — matches `RuntimeCatalogEntry.name`. */\n name: string;\n /** Source declaration id from `skaile.yaml`. */\n declarationId: string;\n}\n\n/**\n * Aggregated npm packages required by all resolved mount/connector adapters.\n * Populated from `metadata.npm_deps` in each matched catalog entry.\n * @docLink packages/core/concepts#runtime-npm-deps\n */\nexport interface RuntimeNpmDeps {\n required: string[];\n optional: string[];\n}\n\n/**\n * Non-fatal warning emitted during `resolveRuntimeAssets` when a repo is unavailable\n * or a driver is not found in any catalog.\n * @docLink packages/core/concepts#runtime-asset-warning\n */\nexport interface RuntimeAssetWarning {\n /** Stable code for filtering / structured logging. */\n code: \"missing_driver\" | \"repo_unavailable\" | \"invalid_repo_decl\";\n message: string;\n /** Declaration id when applicable. */\n declarationId?: string;\n /** Driver / repository name when applicable. */\n name?: string;\n}\n\n/**\n * Repository name used for the implicit built-in `factory-assets` catalog entry\n * (the in-package connector tree).\n * @docLink packages/core/concepts#factory-assets-repo-name\n */\nexport const FACTORY_ASSETS_REPO_NAME = \"factory-assets\";\n\n/**\n * Repository name for the optional `SKAILE_FACTORY_ASSETS_DIR` override layer,\n * scanned ahead of (and overriding) the bundled {@link FACTORY_ASSETS_REPO_NAME}.\n */\nconst FACTORY_ASSETS_OVERRIDE_REPO_NAME = \"factory-assets:override\";\n\n/**\n * Result of `resolveRuntimeAssets`.\n * The same object is mutated in place by `refresh()`, allowing callers to hold\n * a stable reference and observe updates after a new repository is cloned or\n * a driver is installed mid-session.\n * @docLink packages/core/concepts#runtime-assets-result\n */\nexport interface RuntimeAssetsResult {\n catalogEntries: RuntimeCatalogEntry[];\n implicitRefs: RuntimeAssetRef[];\n requiredNpmDeps: RuntimeNpmDeps;\n warnings: RuntimeAssetWarning[];\n /** Re-scan repositories and re-derive implicit refs. Mutates in place. */\n refresh(): Promise<void>;\n /**\n * Catalog lookup. When `kind` is omitted and multiple entries share the\n * `name`, returns `undefined` (caller must disambiguate).\n */\n findEntry(query: { kind?: \"connector\"; name: string }): RuntimeCatalogEntry | undefined;\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/**\n * Resolve all runtime assets visible to a project by scanning declared repositories.\n *\n * Reads `skaile.yaml`, scans every declared repository (plus the implicit\n * built-in `factory-assets` repo), and derives implicit refs from `mounts:` /\n * `connectors:` declarations. Does not clone or install anything — purely a\n * read-only scan of what is already on disk. URL-only repositories that have\n * not been cloned yet are reported as `repo_unavailable` warnings.\n *\n * @param projectDir - Absolute path to the project workspace root\n * @returns `RuntimeAssetsResult` with catalog entries, implicit refs, npm deps, and warnings\n * @docLink packages/core/concepts#resolve-runtime-assets\n */\nexport async function resolveRuntimeAssets(projectDir: string): Promise<RuntimeAssetsResult> {\n const result: RuntimeAssetsResult = {\n catalogEntries: [],\n implicitRefs: [],\n requiredNpmDeps: { required: [], optional: [] },\n warnings: [],\n refresh: async () => {\n await populate(projectDir, result);\n },\n findEntry: (query) => findCatalogEntry(result.catalogEntries, query),\n };\n\n await populate(projectDir, result);\n return result;\n}\n\n/**\n * Resolve the ordered list of on-disk roots for the built-in `factory-assets`\n * tree (built-in connectors + first-party skills + bundles). This is the single\n * shared resolver every consumer goes through, so the env override and the\n * bundled baseline are honoured uniformly.\n *\n * Order (env-first = override-wins):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir (legacy: `SKAILE_BASE_ASSETS_DIR`),\n * when set and existing — an additive override layer.\n * 2. {@link resolvePackagedAssetsDir} — the bundled tree (in-repo source in dev,\n * `dist/factory-assets/` after install). Always-present baseline.\n *\n * Returns `[]` only when the package cannot be located at all. De-duplicated, so\n * pointing the env var at the bundled dir collapses to one root.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function factoryAssetRoots(): string[] {\n const roots: string[] = [];\n const envDir = process.env.SKAILE_FACTORY_ASSETS_DIR ?? process.env.SKAILE_BASE_ASSETS_DIR;\n if (envDir && existsSync(envDir)) roots.push(resolvePath(envDir));\n const bundled = resolvePackagedAssetsDir(\"factory-assets\");\n if (bundled) roots.push(bundled);\n return [...new Set(roots)];\n}\n\n/**\n * Resolve the primary on-disk root of the `factory-assets` tree — the first of\n * {@link factoryAssetRoots} (the env override when set, else the bundled tree).\n * Prefer {@link factoryAssetRoots} when you need to scan every layer; this\n * single-dir form is for callers that want one canonical path.\n *\n * @returns Absolute path to the highest-precedence `factory-assets` directory\n * @throws When no root can be located\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolveFactoryAssetsRoot(): string {\n const hit = resolveFactoryAssetsRootOrNull();\n if (hit) return hit;\n\n throw new Error(\n `Cannot resolve the factory-assets directory. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR to the on-disk path, ` +\n `ensure @skaile/workspaces is installed, ` +\n `or run from within the @skaile/workspaces package tree.`,\n );\n}\n\n/**\n * Non-throwing variant of {@link resolveFactoryAssetsRoot}: the same\n * env-then-packaged resolution tiers, returning `null` instead of throwing when\n * none locate the directory. Callers that treat a missing factory tree as a\n * soft \"not present\" (e.g. the asset-manager's implicit-source injection) MUST\n * use this so they honour the `SKAILE_FACTORY_ASSETS_DIR` container override\n * identically to the runtime path.\n */\nexport function resolveFactoryAssetsRootOrNull(): string | null {\n return factoryAssetRoots()[0] ?? null;\n}\n\n/**\n * Resolve the `@skaile/workspaces` package root — the directory containing its\n * `package.json`. Tries `require.resolve` first (works when installed as a\n * dependency *and* in-repo via the self-reference), then walks upward from this\n * module looking for a `package.json` whose `name` is `@skaile/workspaces`\n * (bounded to 8 levels). Returns `null` when neither locates it.\n *\n * The single source of truth for finding content shipped inside the package —\n * the unified `factory-assets/` tree (built-in connectors + first-party skills\n * + bundles) resolves through {@link resolvePackagedAssetsDir} on top of this.\n *\n * Memoized: the package location is immutable for the process lifetime, but\n * this sits on the CLI hot path (every `findSkills` / flow / completion call\n * funnels through here), so the `require.resolve` + upward `package.json` walk\n * runs once. `undefined` = not yet computed.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nlet workspacesPackageRootCache: string | null | undefined;\n\nexport function resolveWorkspacesPackageRoot(): string | null {\n if (workspacesPackageRootCache !== undefined) return workspacesPackageRootCache;\n workspacesPackageRootCache = computeWorkspacesPackageRoot();\n return workspacesPackageRootCache;\n}\n\nfunction computeWorkspacesPackageRoot(): string | null {\n try {\n const require = createRequire(import.meta.url);\n return dirname(require.resolve(\"@skaile/workspaces/package.json\"));\n } catch {\n // Fall through to the workspace walk.\n }\n let dir: string;\n try {\n dir = dirname(fileURLToPath(import.meta.url));\n } catch {\n return null;\n }\n for (let i = 0; i < 8; i++) {\n const pkgPath = join(dir, \"package.json\");\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as { name?: string };\n if (pkg.name === \"@skaile/workspaces\") return dir;\n } catch {\n // Ignore malformed package.json and keep walking.\n }\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Locate a content-asset directory inside the package. Prefers the in-repo\n * **source** dir `<pkgRoot>/<subdir>` when present — in a dev checkout it is the\n * full tree (e.g. `factory-assets/` keeps the connector `.ts` entry files that\n * `dist/` does not) — then the published `dist/<subdir>` copy (what\n * `files: [\"dist\"]` ships, the only one present after `npm i`). Returns `null`\n * when neither exists.\n *\n * `factory-assets/` resolves to the source tree in dev (code + skills + bundles)\n * and to `dist/factory-assets` post-install (compiled connectors + copied\n * manifests/skills/bundles).\n *\n * @param subdir - `\"factory-assets\"` | …\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolvePackagedAssetsDir(subdir: string): string | null {\n const root = resolveWorkspacesPackageRoot();\n if (!root) return null;\n for (const cand of [join(root, subdir), join(root, \"dist\", subdir)]) {\n if (existsSync(cand)) return cand;\n }\n return null;\n}\n\n// ─── Internals ────────────────────────────────────────────────────────────────\n\nasync function populate(projectDir: string, target: RuntimeAssetsResult): Promise<void> {\n target.catalogEntries = [];\n target.implicitRefs = [];\n target.requiredNpmDeps = { required: [], optional: [] };\n target.warnings = [];\n\n const config = resolveSkWorkspaceConfig(projectDir);\n // Connector catalog scan runs over the project's declared sources[] (resolved\n // to their machine-cache clone paths) plus the implicit factory-assets repo.\n const repositories = buildEffectiveRepositories(sourcesToDeclarations(config.sources));\n const links = readLinks(projectDir);\n\n // Scan each repository for connector entries.\n for (const [name, decl] of Object.entries(repositories)) {\n const repoDir = resolveRepoDir(name, decl, projectDir, links);\n if (!repoDir) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: repoUnavailableMessage(name, decl),\n });\n continue;\n }\n try {\n // Both factory layers carry the same `factory-assets` provenance — the\n // override repo is an internal scan-order device, not a distinct source.\n const repoName = name === FACTORY_ASSETS_OVERRIDE_REPO_NAME ? FACTORY_ASSETS_REPO_NAME : name;\n const entries = scanDirectory(repoDir, repoName).filter((e) => e.kind === \"connector\");\n target.catalogEntries.push(...entries);\n } catch (err) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: `Failed to scan repository \"${name}\" at ${repoDir}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n });\n }\n }\n\n // De-duplicate by (kind, name), keeping the first occurrence. Scan order is\n // declared sources → env override → bundled baseline, so an env-supplied\n // connector manifest overrides the bundled one and the bundled one fills the\n // rest (the override layer can refresh built-in manifests in place).\n const seen = new Set<string>();\n target.catalogEntries = target.catalogEntries.filter((e) => {\n const key = `${e.kind}:${e.name}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n\n // Derive implicit refs from skaile.yaml connectors.\n for (const c of config.connectors ?? []) {\n target.implicitRefs.push({ kind: \"connector\", name: c.driver, declarationId: c.id });\n }\n\n // Validate refs and aggregate npm deps.\n const requiredSet = new Set<string>();\n const optionalSet = new Set<string>();\n for (const ref of target.implicitRefs) {\n const entry = findCatalogEntry(target.catalogEntries, ref);\n if (!entry) {\n target.warnings.push({\n code: \"missing_driver\",\n declarationId: ref.declarationId,\n name: ref.name,\n message:\n `Unknown ${ref.kind} driver \"${ref.name}\" referenced by ${ref.kind} \"${ref.declarationId}\". ` +\n `Run \\`skaile ${ref.kind} catalog\\` to see available drivers, ` +\n `or declare a repository in skaile.yaml that provides this driver.`,\n });\n continue;\n }\n const npm = (entry.metadata?.npm_deps ?? {}) as { required?: string[]; optional?: string[] };\n for (const p of npm.required ?? []) requiredSet.add(p);\n for (const p of npm.optional ?? []) optionalSet.add(p);\n }\n target.requiredNpmDeps.required = [...requiredSet];\n target.requiredNpmDeps.optional = [...optionalSet];\n}\n\n/**\n * Build the effective `repositories` map: caller's declarations first, then the\n * implicit built-in `factory-assets` repos. Each {@link factoryAssetRoots} layer\n * becomes its own repo, the env override inserted **before** the bundled\n * baseline so its connector entries win on the first-match dedup downstream.\n * When the package cannot be located at all, a path-less sentinel under\n * {@link FACTORY_ASSETS_REPO_NAME} drives the `repo_unavailable` warning.\n */\nfunction buildEffectiveRepositories(\n declared: Record<string, SourceDeclaration> | undefined,\n): Record<string, SourceDeclaration> {\n const result: Record<string, SourceDeclaration> = { ...(declared ?? {}) };\n const roots = factoryAssetRoots();\n if (roots.length === 0) {\n // Surface as a warning during scan rather than throwing here — let the\n // caller decide whether factory-assets is required. resolveRepoDir() /\n // repoUnavailableMessage re-discover the failure and emit it.\n if (!result[FACTORY_ASSETS_REPO_NAME]) result[FACTORY_ASSETS_REPO_NAME] = { path: \"\" };\n return result;\n }\n // override-first when both layers exist, so the env root's entries are scanned\n // (and matched) ahead of the bundled baseline.\n const keys =\n roots.length > 1\n ? [FACTORY_ASSETS_OVERRIDE_REPO_NAME, FACTORY_ASSETS_REPO_NAME]\n : [FACTORY_ASSETS_REPO_NAME];\n roots.forEach((dir, i) => {\n const key = keys[i] ?? `${FACTORY_ASSETS_REPO_NAME}:${i}`;\n if (!result[key]) result[key] = { path: dir };\n });\n return result;\n}\n\n/**\n * Resolve a repository declaration to an on-disk directory. Order:\n * 1. Linked override (`.skaile/links.yaml`).\n * 2. Local `path` — relative to `projectDir`.\n * 3. Cloned URL repo at `.skaile/repos/<name>/` (must already exist).\n *\n * Returns `null` when none of these resolve. Does not clone.\n */\nfunction resolveRepoDir(\n name: string,\n decl: SourceDeclaration,\n projectDir: string,\n links: Record<string, string>,\n): string | null {\n // 1. Linked override\n const linked = links[name];\n if (linked && existsSync(linked)) return linked;\n\n // 2. Local path\n if (decl.path) {\n const resolved = resolvePath(projectDir, decl.path);\n return existsSync(resolved) ? resolved : null;\n }\n\n // 3. URL repo cloned to project's .skaile/repos/<name>\n if (decl.url) {\n const projectDest = join(projectDir, \".skaile\", \"repos\", name);\n if (existsSync(projectDest)) {\n // Either a real directory or a symlink to the global cache.\n try {\n lstatSync(projectDest);\n return projectDest;\n } catch {\n return null;\n }\n }\n return null;\n }\n\n return null;\n}\n\nfunction repoUnavailableMessage(name: string, decl: SourceDeclaration): string {\n if (name === FACTORY_ASSETS_REPO_NAME && !decl.path && !decl.url) {\n return (\n `Cannot resolve the built-in factory-assets. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR or ensure @skaile/workspaces is installed.`\n );\n }\n if (decl.url) {\n return `Repository \"${name}\" (${decl.url}) is not available. Register it as a Library Source via \\`skaile source add\\`.`;\n }\n if (decl.path) {\n return `Repository \"${name}\" path not found: ${decl.path}`;\n }\n return `Repository \"${name}\" has neither url nor path.`;\n}\n\nfunction findCatalogEntry(\n entries: RuntimeCatalogEntry[],\n query: { kind?: \"connector\"; name: string },\n): RuntimeCatalogEntry | undefined {\n if (query.kind) {\n return entries.find((e) => e.kind === query.kind && e.name === query.name);\n }\n const matches = entries.filter((e) => e.name === query.name);\n if (matches.length === 1) return matches[0];\n // 0 or >1 with no kind — caller must disambiguate.\n return undefined;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseAssetRef } from './chunk-
|
|
1
|
+
import { parseAssetRef } from './chunk-GEEW6SY2.js';
|
|
2
2
|
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
|
|
3
3
|
import { join, resolve } from 'path';
|
|
4
4
|
import { stringify, parse } from 'yaml';
|
|
@@ -225,5 +225,5 @@ function saveSkPublishManifest(dir, manifest) {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
export { SKAILE_MANIFEST_FILENAME, decodeSkaileManifest, encodeSkaileManifest, loadSkPublishManifest, saveSkPublishManifest };
|
|
228
|
-
//# sourceMappingURL=chunk-
|
|
229
|
-
//# sourceMappingURL=chunk-
|
|
228
|
+
//# sourceMappingURL=chunk-DZCK7GRW.js.map
|
|
229
|
+
//# sourceMappingURL=chunk-DZCK7GRW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../core/src/publish-manifest.ts"],"names":[],"mappings":";;;;;AAmJO,IAAM,wBAAA,GAA2B;AAIxC,SAAS,YAAY,GAAA,EAA0C;AAC7D,EAAA,IAAI,CAAC,OAAO,OAAO,GAAA,KAAQ,Y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HVJZ.js","sourcesContent":["/**\n * Publish manifest — `skaile.manifest.yaml`\n *\n * What a repo PUBLISHES: the `publisher` / `version` / `assets[]` that used to\n * live in the publication half of `skaile.yaml`, plus a per-asset dependency\n * graph, store-listing metadata, and an optional curator `source:` pointer.\n *\n * ── Two files, two codecs ──────────────────────────────────────────────────\n *\n * skaile.yaml → SkWorkspaceConfig (workspace + consumption)\n * skaile.manifest.yaml → SkPublishManifest (publication) ← this module\n *\n * A repo can have either file, both, or neither: a pure workspace has only\n * `skaile.yaml`; a pure asset repo (e.g. `ai-assets`) has only\n * `skaile.manifest.yaml`; a repo that is both has both.\n *\n * ── One format, three roles ────────────────────────────────────────────────\n *\n * First-party `source:` absent → bytes live in this repo (`root`/`files`).\n * Curator/sidecar `source:` present → bytes come from the referenced upstream,\n * verified by `sha256`.\n *\n * `decodeSkaileManifest` mirrors `decodeSkaileYaml`: total (never throws),\n * returns {@link Diagnostic}s. Dep-ref strings are validated with `parseAssetRef`.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { parse, stringify } from \"yaml\";\nimport { parseAssetRef } from \"./models.js\";\nimport type { Diagnostic } from \"./workspace-config.js\";\n\n// ── Types ───────────────────────────────────────────────────────────────────\n\n/** One file inside a curated asset, pinned to an exact upstream blob hash. */\nexport interface ManifestFileEntry {\n path: string;\n /** 64-hex sha256 of the upstream blob. */\n sha256: string;\n}\n\n/**\n * One entry in a manifest's `assets:` list. Either `root:` (recursive walk) or\n * `files:` (explicit list, supports globs for first-party; the granular\n * `{path, sha256}` form for curated upstream verification) declares which paths\n * constitute the asset. `version:` overrides the manifest-level version.\n *\n * @docLink packages/core/publish-manifest#asset-entry\n */\nexport interface AssetEntry {\n kind: string;\n name: string;\n root?: string;\n /**\n * Explicit file listing. First-party manifests use bare `string[]` (globs,\n * fast-glob). Curated entries may use the granular `{path, sha256}` form so\n * the resolver fetches + verifies exact upstream blobs without a full clone.\n */\n files?: string[] | ManifestFileEntry[];\n version?: string;\n /** Per-asset publisher override (e.g. for curator/mirror repos). */\n publisher?: string;\n\n /**\n * Canonical dep refs (`kind:@<publisher>/name[#version]`) — same grammar as\n * `SkWorkspaceConfig.dependencies`. Authoritative for this asset's resolved\n * deps. (Was `requires` in `.skaile-source.yaml`.)\n */\n dependencies?: string[];\n\n /**\n * Author-pinned composite sha256 over the asset's `files`/`root` (same\n * deterministic algorithm as the walker + discovery). Optional locally;\n * REQUIRED on store publish. (Was `.skaile-source.yaml` `assets[].sha256`.)\n */\n sha256?: string;\n\n /**\n * Curator override: this single asset's bytes come from a different upstream\n * than the manifest-level `source`. Absent → inherit manifest `source` (or\n * first-party when that is also absent).\n */\n source?: ManifestSource;\n\n // ── Store-listing metadata (all optional; fall back to content frontmatter) ──\n description?: string;\n keywords?: string[];\n category?: string;\n license?: string;\n homepage?: string;\n}\n\n/**\n * Upstream the bytes come from when a manifest curates a repo it does not own.\n * Absent → first-party (bytes live in the manifest's own repo).\n *\n * @docLink packages/core/publish-manifest#manifest-source\n */\nexport interface ManifestSource {\n url: string;\n /** 40-char commit the curated bytes are pinned to. */\n commit?: string;\n}\n\n/**\n * Signing/attribution recorded when a manifest is published on behalf of others.\n *\n * @docLink packages/core/publish-manifest#manifest-provenance\n */\nexport interface ManifestProvenance {\n curator: string;\n signed_by?: string;\n}\n\n/**\n * Parsed `skaile.manifest.yaml` — what a repo publishes.\n *\n * @docLink packages/core/publish-manifest#sk-publish-manifest\n */\nexport interface SkPublishManifest {\n publisher?: string;\n version?: string;\n /** Repo-level store defaults inherited by assets unless overridden per-entry. */\n license?: string;\n homepage?: string;\n /**\n * Repo-relative path prefixes holding dev-only assets — excluded from\n * discovery/publish unless `--dev`. (Was `.skaile-source.yaml` `dev_paths`.)\n */\n dev_paths?: string[];\n /**\n * Curator mode: the single upstream all assets in this file come from. A\n * per-asset `source` overrides it. Absent → first-party (own repo).\n */\n source?: ManifestSource;\n /** Present when this manifest is curated/published on behalf of another author. */\n provenance?: ManifestProvenance;\n assets?: AssetEntry[];\n}\n\n/** Result of {@link decodeSkaileManifest}: the manifest plus any notes. */\nexport interface ManifestDecodeResult {\n manifest: SkPublishManifest;\n diagnostics: Diagnostic[];\n}\n\n/** The single fixed filename for a publish manifest. */\nexport const SKAILE_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\n\n// ── Decode ──────────────────────────────────────────────────────────────────\n\nfunction parseSource(raw: unknown): ManifestSource | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const s = raw as Record<string, unknown>;\n if (typeof s.url !== \"string\" || s.url.length === 0) return undefined;\n const out: ManifestSource = { url: s.url };\n if (typeof s.commit === \"string\" && s.commit.length > 0) out.commit = s.commit;\n return out;\n}\n\nfunction parseProvenance(raw: unknown): ManifestProvenance | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const p = raw as Record<string, unknown>;\n if (typeof p.curator !== \"string\" || p.curator.length === 0) return undefined;\n const out: ManifestProvenance = { curator: p.curator };\n if (typeof p.signed_by === \"string\" && p.signed_by.length > 0) out.signed_by = p.signed_by;\n return out;\n}\n\n/** Parse `files:` as either `string[]` (globs) or `{path, sha256}[]` (granular). */\nfunction parseFiles(raw: unknown): string[] | ManifestFileEntry[] | undefined {\n if (!Array.isArray(raw)) return undefined;\n const strings: string[] = [];\n const granular: ManifestFileEntry[] = [];\n for (const item of raw) {\n if (typeof item === \"string\") {\n strings.push(item);\n } else if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const f = item as Record<string, unknown>;\n if (typeof f.path === \"string\" && typeof f.sha256 === \"string\") {\n granular.push({ path: f.path, sha256: f.sha256 });\n }\n }\n }\n // A manifest uses one form per entry; if both somehow appear, granular wins\n // (it is the verifiable form). Empty → undefined.\n if (granular.length > 0) return granular;\n if (strings.length > 0) return strings;\n return undefined;\n}\n\n/** Parse the YAML root, returning either the mapping or an error diagnostic. */\nfunction parseManifestRoot(\n text: string,\n): { ok: true; raw: Record<string, unknown> } | { ok: false; diagnostic: Diagnostic } {\n let parsed: unknown;\n try {\n parsed = parse(text) ?? {};\n } catch (err) {\n return {\n ok: false,\n diagnostic: {\n code: \"yaml_syntax\",\n severity: \"error\",\n message: `Invalid YAML: ${err instanceof Error ? err.message : String(err)}`,\n },\n };\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return {\n ok: false,\n diagnostic: {\n code: \"non_object_root\",\n severity: \"error\",\n message: \"skaile.manifest.yaml must be a mapping at the top level.\",\n },\n };\n }\n return { ok: true, raw: parsed as Record<string, unknown> };\n}\n\n/** Decode the manifest-level scalar/array/object fields onto `manifest`. */\nfunction decodeManifestFields(raw: Record<string, unknown>, manifest: SkPublishManifest): void {\n if (typeof raw.publisher === \"string\" && raw.publisher.length > 0) {\n manifest.publisher = raw.publisher;\n }\n if (typeof raw.version === \"string\" && raw.version.length > 0) {\n manifest.version = raw.version;\n }\n if (typeof raw.license === \"string\" && raw.license.length > 0) {\n manifest.license = raw.license;\n }\n if (typeof raw.homepage === \"string\" && raw.homepage.length > 0) {\n manifest.homepage = raw.homepage;\n }\n if (Array.isArray(raw.dev_paths)) {\n const paths = raw.dev_paths.filter((p): p is string => typeof p === \"string\" && p.length > 0);\n if (paths.length > 0) manifest.dev_paths = paths;\n }\n const source = parseSource(raw.source);\n if (source) manifest.source = source;\n const provenance = parseProvenance(raw.provenance);\n if (provenance) manifest.provenance = provenance;\n}\n\n/**\n * Validate an asset's `dependencies` via `parseAssetRef`, pushing a `warning`\n * for each malformed ref. Returns the kept (valid) refs.\n */\nfunction decodeAssetDependencies(\n raw: unknown,\n kind: string,\n name: string,\n diagnostics: Diagnostic[],\n): string[] {\n const deps: string[] = [];\n if (!Array.isArray(raw)) return deps;\n for (const dep of raw) {\n if (typeof dep !== \"string\") continue;\n try {\n parseAssetRef(dep);\n deps.push(dep);\n } catch (err) {\n diagnostics.push({\n code: \"malformed_dependency\",\n severity: \"warning\",\n message: `assets[${kind}:${name}].dependencies: ${\n err instanceof Error ? err.message : String(err)\n }`,\n path: `assets.${kind}:${name}.dependencies`,\n });\n }\n }\n return deps;\n}\n\n/**\n * Decode one `assets[]` item into an {@link AssetEntry}, or `undefined` when the\n * item is not a mapping or lacks both `kind` and `name`. Pushes dependency\n * warnings to `diagnostics`.\n */\nfunction decodeAssetEntry(item: unknown, diagnostics: Diagnostic[]): AssetEntry | undefined {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return undefined;\n const a = item as Record<string, unknown>;\n const kind = typeof a.kind === \"string\" ? a.kind : \"\";\n const name = typeof a.name === \"string\" ? a.name : \"\";\n if (!kind || !name) return undefined;\n const entry: AssetEntry = { kind, name };\n if (typeof a.root === \"string\") entry.root = a.root;\n const files = parseFiles(a.files);\n if (files) entry.files = files;\n if (typeof a.version === \"string\") entry.version = a.version;\n if (typeof a.publisher === \"string\") entry.publisher = a.publisher;\n if (typeof a.sha256 === \"string\") entry.sha256 = a.sha256;\n const assetSource = parseSource(a.source);\n if (assetSource) entry.source = assetSource;\n\n const deps = decodeAssetDependencies(a.dependencies, kind, name, diagnostics);\n if (deps.length > 0) entry.dependencies = deps;\n\n if (typeof a.description === \"string\") entry.description = a.description;\n if (Array.isArray(a.keywords)) {\n const kw = a.keywords.filter((k): k is string => typeof k === \"string\");\n if (kw.length > 0) entry.keywords = kw;\n }\n if (typeof a.category === \"string\") entry.category = a.category;\n if (typeof a.license === \"string\") entry.license = a.license;\n if (typeof a.homepage === \"string\") entry.homepage = a.homepage;\n\n return entry;\n}\n\n/** Decode the `assets[]` list onto `manifest`, collecting dependency warnings. */\nfunction decodeManifestAssets(\n raw: Record<string, unknown>,\n manifest: SkPublishManifest,\n diagnostics: Diagnostic[],\n): void {\n if (!Array.isArray(raw.assets)) return;\n const entries: AssetEntry[] = [];\n for (const item of raw.assets) {\n const entry = decodeAssetEntry(item, diagnostics);\n if (entry) entries.push(entry);\n }\n if (entries.length > 0) manifest.assets = entries;\n}\n\n/**\n * Decode `skaile.manifest.yaml` text into a {@link SkPublishManifest} plus\n * {@link Diagnostic}s. Total — never throws: a YAML syntax error or non-object\n * root is reported as an `error`-severity diagnostic with an empty manifest.\n * Malformed `assets[].dependencies` refs are reported as `warning`s (validated\n * via `parseAssetRef`) rather than silently dropped.\n *\n * Pair with {@link encodeSkaileManifest} for round-tripping.\n * @docLink packages/core/publish-manifest#decode-skaile-manifest\n */\nexport function decodeSkaileManifest(text: string): ManifestDecodeResult {\n const root = parseManifestRoot(text);\n if (!root.ok) {\n return { manifest: {}, diagnostics: [root.diagnostic] };\n }\n\n const manifest: SkPublishManifest = {};\n const diagnostics: Diagnostic[] = [];\n decodeManifestFields(root.raw, manifest);\n decodeManifestAssets(root.raw, manifest, diagnostics);\n\n return { manifest, diagnostics };\n}\n\n// ── Encode ──────────────────────────────────────────────────────────────────\n\n/** Fixed top-level key order for {@link encodeSkaileManifest}. */\nconst MANIFEST_KEY_ORDER: (keyof SkPublishManifest)[] = [\n \"publisher\",\n \"version\",\n \"license\",\n \"homepage\",\n \"dev_paths\",\n \"source\",\n \"provenance\",\n \"assets\",\n];\n\n/** Fixed per-asset key order for {@link encodeSkaileManifest}. */\nconst ASSET_KEY_ORDER: (keyof AssetEntry)[] = [\n \"kind\",\n \"name\",\n \"source\",\n \"root\",\n \"files\",\n \"version\",\n \"publisher\",\n \"sha256\",\n \"dependencies\",\n \"description\",\n \"keywords\",\n \"category\",\n \"license\",\n \"homepage\",\n];\n\nfunction orderedAsset(a: AssetEntry): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const key of ASSET_KEY_ORDER) {\n const value = a[key];\n if (value !== undefined) out[key] = value;\n }\n return out;\n}\n\n/**\n * Encode a {@link SkPublishManifest} to canonical `skaile.manifest.yaml` text:\n * deterministic key order, only defined fields, `lineWidth: 120` (mirrors\n * `encodeSkaileYaml`).\n * @docLink packages/core/publish-manifest#encode-skaile-manifest\n */\nexport function encodeSkaileManifest(manifest: SkPublishManifest): string {\n const out: Record<string, unknown> = {};\n for (const key of MANIFEST_KEY_ORDER) {\n const value = manifest[key];\n if (value === undefined) continue;\n if (key === \"assets\" && Array.isArray(value)) {\n out.assets = (value as AssetEntry[]).map(orderedAsset);\n } else {\n out[key] = value;\n }\n }\n return stringify(out, { lineWidth: 120 });\n}\n\n// ── File I/O ──────────────────────────────────────────────────────────────────\n\n/**\n * Load and decode `<dir>/skaile.manifest.yaml`. Returns `null` when the file is\n * absent or unparseable (mirrors `loadSkWorkspaceConfig`'s tolerant contract).\n * @docLink packages/core/publish-manifest#load-sk-publish-manifest\n */\nexport function loadSkPublishManifest(dir: string): SkPublishManifest | null {\n const filePath = join(resolve(dir), SKAILE_MANIFEST_FILENAME);\n if (!existsSync(filePath)) return null;\n let raw: string;\n try {\n raw = readFileSync(filePath, \"utf-8\");\n } catch {\n return null;\n }\n const { manifest, diagnostics } = decodeSkaileManifest(raw);\n if (diagnostics.some((d) => d.code === \"yaml_syntax\" || d.code === \"non_object_root\")) {\n return null;\n }\n return manifest;\n}\n\n/**\n * Encode and write a manifest to `<dir>/skaile.manifest.yaml`, creating the\n * directory if needed. Returns the absolute path written.\n * @docLink packages/core/publish-manifest#save-sk-publish-manifest\n */\nexport function saveSkPublishManifest(dir: string, manifest: SkPublishManifest): string {\n const resolvedDir = resolve(dir);\n const filePath = join(resolvedDir, SKAILE_MANIFEST_FILENAME);\n if (!existsSync(resolvedDir)) {\n mkdirSync(resolvedDir, { recursive: true });\n }\n writeFileSync(filePath, encodeSkaileManifest(manifest));\n return filePath;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../core/src/publish-manifest.ts"],"names":[],"mappings":";;;;;AAmJO,IAAM,wBAAA,GAA2B;AAIxC,SAAS,YAAY,GAAA,EAA0C;AAC7D,EAAA,IAAI,CAAC,OAAO,OAAO,GAAA,KAAQ,YAAY,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA,EAAG,OAAO,MAAA;AAClE,EAAA,MAAM,CAAA,GAAI,GAAA;AACV,EAAA,IA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AAA,EACF;AACA,EAAA,OAAO,SAAA,CAAU,GAAA,EAAK,EAAE,SAAA,EAAW,KAAK,CAAA;AAC1C;AASO,SAAS,sBAAsB,GAAA,EAAuC;AAC3E,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,OAAA,CAAQ,GAAG,GAAG,wBAAwB,CAAA;AAC5D,EAAA,IAAI,CAAC,UAAA,CAAW,QAAQ,CAAA,EAAG,OAAO,IAAA;AAClC,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAM,YAAA,CAAa,UAAU,OAAO,CAAA;AAAA,EACtC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,EAAE,QAAA,EAAU,WAAA,EAAY,GAAI,qBAAqB,GAAG,CAAA;AAC1D,EAAA,IAAI,WAAA,CAAY,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,aAAA,IAAiB,CAAA,CAAE,IAAA,KAAS,iBAAiB,CAAA,EAAG;AACrF,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,QAAA;AACT;AAOO,SAAS,qBAAA,CAAsB,KAAa,QAAA,EAAqC;AACtF,EAAA,MAAM,WAAA,GAAc,QAAQ,GAAG,CAAA;AAC/B,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,WAAA,EAAa,wBAAwB,CAAA;AAC3D,EAAA,IAAI,CAAC,UAAA,CAAW,WAAW,CAAA,EAAG;AAC5B,IAAA,SAAA,CAAU,WAAA,EAAa,EAAE,SAAA,EAAW,IAAA,EAAM,CAAA;AAAA,EAC5C;AACA,EAAA,aAAA,CAAc,QAAA,EAAU,oBAAA,CAAqB,QAAQ,CAAC,CAAA;AACtD,EAAA,OAAO,QAAA;AACT","file":"chunk-DZCK7GRW.js","sourcesContent":["/**\n * Publish manifest — `skaile.manifest.yaml`\n *\n * What a repo PUBLISHES: the `publisher` / `version` / `assets[]` that used to\n * live in the publication half of `skaile.yaml`, plus a per-asset dependency\n * graph, store-listing metadata, and an optional curator `source:` pointer.\n *\n * ── Two files, two codecs ──────────────────────────────────────────────────\n *\n * skaile.yaml → SkWorkspaceConfig (workspace + consumption)\n * skaile.manifest.yaml → SkPublishManifest (publication) ← this module\n *\n * A repo can have either file, both, or neither: a pure workspace has only\n * `skaile.yaml`; a pure asset repo (e.g. `ai-assets`) has only\n * `skaile.manifest.yaml`; a repo that is both has both.\n *\n * ── One format, three roles ────────────────────────────────────────────────\n *\n * First-party `source:` absent → bytes live in this repo (`root`/`files`).\n * Curator/sidecar `source:` present → bytes come from the referenced upstream,\n * verified by `sha256`.\n *\n * `decodeSkaileManifest` mirrors `decodeSkaileYaml`: total (never throws),\n * returns {@link Diagnostic}s. Dep-ref strings are validated with `parseAssetRef`.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { parse, stringify } from \"yaml\";\nimport { parseAssetRef } from \"./models.js\";\nimport type { Diagnostic } from \"./workspace-config.js\";\n\n// ── Types ───────────────────────────────────────────────────────────────────\n\n/** One file inside a curated asset, pinned to an exact upstream blob hash. */\nexport interface ManifestFileEntry {\n path: string;\n /** 64-hex sha256 of the upstream blob. */\n sha256: string;\n}\n\n/**\n * One entry in a manifest's `assets:` list. Either `root:` (recursive walk) or\n * `files:` (explicit list, supports globs for first-party; the granular\n * `{path, sha256}` form for curated upstream verification) declares which paths\n * constitute the asset. `version:` overrides the manifest-level version.\n *\n * @docLink packages/core/publish-manifest#asset-entry\n */\nexport interface AssetEntry {\n kind: string;\n name: string;\n root?: string;\n /**\n * Explicit file listing. First-party manifests use bare `string[]` (globs,\n * fast-glob). Curated entries may use the granular `{path, sha256}` form so\n * the resolver fetches + verifies exact upstream blobs without a full clone.\n */\n files?: string[] | ManifestFileEntry[];\n version?: string;\n /** Per-asset publisher override (e.g. for curator/mirror repos). */\n publisher?: string;\n\n /**\n * Canonical dep refs (`kind:@<publisher>/name[#version]`) — same grammar as\n * `SkWorkspaceConfig.dependencies`. Authoritative for this asset's resolved\n * deps. (Was `requires` in `.skaile-source.yaml`.)\n */\n dependencies?: string[];\n\n /**\n * Author-pinned composite sha256 over the asset's `files`/`root` (same\n * deterministic algorithm as the walker + discovery). Optional locally;\n * REQUIRED on store publish. (Was `.skaile-source.yaml` `assets[].sha256`.)\n */\n sha256?: string;\n\n /**\n * Curator override: this single asset's bytes come from a different upstream\n * than the manifest-level `source`. Absent → inherit manifest `source` (or\n * first-party when that is also absent).\n */\n source?: ManifestSource;\n\n // ── Store-listing metadata (all optional; fall back to content frontmatter) ──\n description?: string;\n keywords?: string[];\n category?: string;\n license?: string;\n homepage?: string;\n}\n\n/**\n * Upstream the bytes come from when a manifest curates a repo it does not own.\n * Absent → first-party (bytes live in the manifest's own repo).\n *\n * @docLink packages/core/publish-manifest#manifest-source\n */\nexport interface ManifestSource {\n url: string;\n /** 40-char commit the curated bytes are pinned to. */\n commit?: string;\n}\n\n/**\n * Signing/attribution recorded when a manifest is published on behalf of others.\n *\n * @docLink packages/core/publish-manifest#manifest-provenance\n */\nexport interface ManifestProvenance {\n curator: string;\n signed_by?: string;\n}\n\n/**\n * Parsed `skaile.manifest.yaml` — what a repo publishes.\n *\n * @docLink packages/core/publish-manifest#sk-publish-manifest\n */\nexport interface SkPublishManifest {\n publisher?: string;\n version?: string;\n /** Repo-level store defaults inherited by assets unless overridden per-entry. */\n license?: string;\n homepage?: string;\n /**\n * Repo-relative path prefixes holding dev-only assets — excluded from\n * discovery/publish unless `--dev`. (Was `.skaile-source.yaml` `dev_paths`.)\n */\n dev_paths?: string[];\n /**\n * Curator mode: the single upstream all assets in this file come from. A\n * per-asset `source` overrides it. Absent → first-party (own repo).\n */\n source?: ManifestSource;\n /** Present when this manifest is curated/published on behalf of another author. */\n provenance?: ManifestProvenance;\n assets?: AssetEntry[];\n}\n\n/** Result of {@link decodeSkaileManifest}: the manifest plus any notes. */\nexport interface ManifestDecodeResult {\n manifest: SkPublishManifest;\n diagnostics: Diagnostic[];\n}\n\n/** The single fixed filename for a publish manifest. */\nexport const SKAILE_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\n\n// ── Decode ──────────────────────────────────────────────────────────────────\n\nfunction parseSource(raw: unknown): ManifestSource | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const s = raw as Record<string, unknown>;\n if (typeof s.url !== \"string\" || s.url.length === 0) return undefined;\n const out: ManifestSource = { url: s.url };\n if (typeof s.commit === \"string\" && s.commit.length > 0) out.commit = s.commit;\n return out;\n}\n\nfunction parseProvenance(raw: unknown): ManifestProvenance | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const p = raw as Record<string, unknown>;\n if (typeof p.curator !== \"string\" || p.curator.length === 0) return undefined;\n const out: ManifestProvenance = { curator: p.curator };\n if (typeof p.signed_by === \"string\" && p.signed_by.length > 0) out.signed_by = p.signed_by;\n return out;\n}\n\n/** Parse `files:` as either `string[]` (globs) or `{path, sha256}[]` (granular). */\nfunction parseFiles(raw: unknown): string[] | ManifestFileEntry[] | undefined {\n if (!Array.isArray(raw)) return undefined;\n const strings: string[] = [];\n const granular: ManifestFileEntry[] = [];\n for (const item of raw) {\n if (typeof item === \"string\") {\n strings.push(item);\n } else if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const f = item as Record<string, unknown>;\n if (typeof f.path === \"string\" && typeof f.sha256 === \"string\") {\n granular.push({ path: f.path, sha256: f.sha256 });\n }\n }\n }\n // A manifest uses one form per entry; if both somehow appear, granular wins\n // (it is the verifiable form). Empty → undefined.\n if (granular.length > 0) return granular;\n if (strings.length > 0) return strings;\n return undefined;\n}\n\n/** Parse the YAML root, returning either the mapping or an error diagnostic. */\nfunction parseManifestRoot(\n text: string,\n): { ok: true; raw: Record<string, unknown> } | { ok: false; diagnostic: Diagnostic } {\n let parsed: unknown;\n try {\n parsed = parse(text) ?? {};\n } catch (err) {\n return {\n ok: false,\n diagnostic: {\n code: \"yaml_syntax\",\n severity: \"error\",\n message: `Invalid YAML: ${err instanceof Error ? err.message : String(err)}`,\n },\n };\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return {\n ok: false,\n diagnostic: {\n code: \"non_object_root\",\n severity: \"error\",\n message: \"skaile.manifest.yaml must be a mapping at the top level.\",\n },\n };\n }\n return { ok: true, raw: parsed as Record<string, unknown> };\n}\n\n/** Decode the manifest-level scalar/array/object fields onto `manifest`. */\nfunction decodeManifestFields(raw: Record<string, unknown>, manifest: SkPublishManifest): void {\n if (typeof raw.publisher === \"string\" && raw.publisher.length > 0) {\n manifest.publisher = raw.publisher;\n }\n if (typeof raw.version === \"string\" && raw.version.length > 0) {\n manifest.version = raw.version;\n }\n if (typeof raw.license === \"string\" && raw.license.length > 0) {\n manifest.license = raw.license;\n }\n if (typeof raw.homepage === \"string\" && raw.homepage.length > 0) {\n manifest.homepage = raw.homepage;\n }\n if (Array.isArray(raw.dev_paths)) {\n const paths = raw.dev_paths.filter((p): p is string => typeof p === \"string\" && p.length > 0);\n if (paths.length > 0) manifest.dev_paths = paths;\n }\n const source = parseSource(raw.source);\n if (source) manifest.source = source;\n const provenance = parseProvenance(raw.provenance);\n if (provenance) manifest.provenance = provenance;\n}\n\n/**\n * Validate an asset's `dependencies` via `parseAssetRef`, pushing a `warning`\n * for each malformed ref. Returns the kept (valid) refs.\n */\nfunction decodeAssetDependencies(\n raw: unknown,\n kind: string,\n name: string,\n diagnostics: Diagnostic[],\n): string[] {\n const deps: string[] = [];\n if (!Array.isArray(raw)) return deps;\n for (const dep of raw) {\n if (typeof dep !== \"string\") continue;\n try {\n parseAssetRef(dep);\n deps.push(dep);\n } catch (err) {\n diagnostics.push({\n code: \"malformed_dependency\",\n severity: \"warning\",\n message: `assets[${kind}:${name}].dependencies: ${\n err instanceof Error ? err.message : String(err)\n }`,\n path: `assets.${kind}:${name}.dependencies`,\n });\n }\n }\n return deps;\n}\n\n/**\n * Decode one `assets[]` item into an {@link AssetEntry}, or `undefined` when the\n * item is not a mapping or lacks both `kind` and `name`. Pushes dependency\n * warnings to `diagnostics`.\n */\nfunction decodeAssetEntry(item: unknown, diagnostics: Diagnostic[]): AssetEntry | undefined {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return undefined;\n const a = item as Record<string, unknown>;\n const kind = typeof a.kind === \"string\" ? a.kind : \"\";\n const name = typeof a.name === \"string\" ? a.name : \"\";\n if (!kind || !name) return undefined;\n const entry: AssetEntry = { kind, name };\n if (typeof a.root === \"string\") entry.root = a.root;\n const files = parseFiles(a.files);\n if (files) entry.files = files;\n if (typeof a.version === \"string\") entry.version = a.version;\n if (typeof a.publisher === \"string\") entry.publisher = a.publisher;\n if (typeof a.sha256 === \"string\") entry.sha256 = a.sha256;\n const assetSource = parseSource(a.source);\n if (assetSource) entry.source = assetSource;\n\n const deps = decodeAssetDependencies(a.dependencies, kind, name, diagnostics);\n if (deps.length > 0) entry.dependencies = deps;\n\n if (typeof a.description === \"string\") entry.description = a.description;\n if (Array.isArray(a.keywords)) {\n const kw = a.keywords.filter((k): k is string => typeof k === \"string\");\n if (kw.length > 0) entry.keywords = kw;\n }\n if (typeof a.category === \"string\") entry.category = a.category;\n if (typeof a.license === \"string\") entry.license = a.license;\n if (typeof a.homepage === \"string\") entry.homepage = a.homepage;\n\n return entry;\n}\n\n/** Decode the `assets[]` list onto `manifest`, collecting dependency warnings. */\nfunction decodeManifestAssets(\n raw: Record<string, unknown>,\n manifest: SkPublishManifest,\n diagnostics: Diagnostic[],\n): void {\n if (!Array.isArray(raw.assets)) return;\n const entries: AssetEntry[] = [];\n for (const item of raw.assets) {\n const entry = decodeAssetEntry(item, diagnostics);\n if (entry) entries.push(entry);\n }\n if (entries.length > 0) manifest.assets = entries;\n}\n\n/**\n * Decode `skaile.manifest.yaml` text into a {@link SkPublishManifest} plus\n * {@link Diagnostic}s. Total — never throws: a YAML syntax error or non-object\n * root is reported as an `error`-severity diagnostic with an empty manifest.\n * Malformed `assets[].dependencies` refs are reported as `warning`s (validated\n * via `parseAssetRef`) rather than silently dropped.\n *\n * Pair with {@link encodeSkaileManifest} for round-tripping.\n * @docLink packages/core/publish-manifest#decode-skaile-manifest\n */\nexport function decodeSkaileManifest(text: string): ManifestDecodeResult {\n const root = parseManifestRoot(text);\n if (!root.ok) {\n return { manifest: {}, diagnostics: [root.diagnostic] };\n }\n\n const manifest: SkPublishManifest = {};\n const diagnostics: Diagnostic[] = [];\n decodeManifestFields(root.raw, manifest);\n decodeManifestAssets(root.raw, manifest, diagnostics);\n\n return { manifest, diagnostics };\n}\n\n// ── Encode ──────────────────────────────────────────────────────────────────\n\n/** Fixed top-level key order for {@link encodeSkaileManifest}. */\nconst MANIFEST_KEY_ORDER: (keyof SkPublishManifest)[] = [\n \"publisher\",\n \"version\",\n \"license\",\n \"homepage\",\n \"dev_paths\",\n \"source\",\n \"provenance\",\n \"assets\",\n];\n\n/** Fixed per-asset key order for {@link encodeSkaileManifest}. */\nconst ASSET_KEY_ORDER: (keyof AssetEntry)[] = [\n \"kind\",\n \"name\",\n \"source\",\n \"root\",\n \"files\",\n \"version\",\n \"publisher\",\n \"sha256\",\n \"dependencies\",\n \"description\",\n \"keywords\",\n \"category\",\n \"license\",\n \"homepage\",\n];\n\nfunction orderedAsset(a: AssetEntry): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const key of ASSET_KEY_ORDER) {\n const value = a[key];\n if (value !== undefined) out[key] = value;\n }\n return out;\n}\n\n/**\n * Encode a {@link SkPublishManifest} to canonical `skaile.manifest.yaml` text:\n * deterministic key order, only defined fields, `lineWidth: 120` (mirrors\n * `encodeSkaileYaml`).\n * @docLink packages/core/publish-manifest#encode-skaile-manifest\n */\nexport function encodeSkaileManifest(manifest: SkPublishManifest): string {\n const out: Record<string, unknown> = {};\n for (const key of MANIFEST_KEY_ORDER) {\n const value = manifest[key];\n if (value === undefined) continue;\n if (key === \"assets\" && Array.isArray(value)) {\n out.assets = (value as AssetEntry[]).map(orderedAsset);\n } else {\n out[key] = value;\n }\n }\n return stringify(out, { lineWidth: 120 });\n}\n\n// ── File I/O ──────────────────────────────────────────────────────────────────\n\n/**\n * Load and decode `<dir>/skaile.manifest.yaml`. Returns `null` when the file is\n * absent or unparseable (mirrors `loadSkWorkspaceConfig`'s tolerant contract).\n * @docLink packages/core/publish-manifest#load-sk-publish-manifest\n */\nexport function loadSkPublishManifest(dir: string): SkPublishManifest | null {\n const filePath = join(resolve(dir), SKAILE_MANIFEST_FILENAME);\n if (!existsSync(filePath)) return null;\n let raw: string;\n try {\n raw = readFileSync(filePath, \"utf-8\");\n } catch {\n return null;\n }\n const { manifest, diagnostics } = decodeSkaileManifest(raw);\n if (diagnostics.some((d) => d.code === \"yaml_syntax\" || d.code === \"non_object_root\")) {\n return null;\n }\n return manifest;\n}\n\n/**\n * Encode and write a manifest to `<dir>/skaile.manifest.yaml`, creating the\n * directory if needed. Returns the absolute path written.\n * @docLink packages/core/publish-manifest#save-sk-publish-manifest\n */\nexport function saveSkPublishManifest(dir: string, manifest: SkPublishManifest): string {\n const resolvedDir = resolve(dir);\n const filePath = join(resolvedDir, SKAILE_MANIFEST_FILENAME);\n if (!existsSync(resolvedDir)) {\n mkdirSync(resolvedDir, { recursive: true });\n }\n writeFileSync(filePath, encodeSkaileManifest(manifest));\n return filePath;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { computeHash, applyPatch } from './chunk-
|
|
2
|
-
import { resolveSkWorkspaceConfig } from './chunk-
|
|
1
|
+
import { computeHash, applyPatch } from './chunk-MWEB2TZ7.js';
|
|
2
|
+
import { resolveSkWorkspaceConfig } from './chunk-2PXSZYKV.js';
|
|
3
3
|
import { deployedBase, deployedDir, isDeployed } from './chunk-XGCXFX7X.js';
|
|
4
4
|
import { DRIVER_TARGETS } from './chunk-O4JH3KUE.js';
|
|
5
5
|
import { renderAgentToFramework } from './chunk-67MFR5LS.js';
|
|
@@ -400,5 +400,5 @@ function createScaffold(name, kind, destDir) {
|
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
export { createScaffold, deployAll, deployAsset, installAgent, removeAsset };
|
|
403
|
-
//# sourceMappingURL=chunk-
|
|
404
|
-
//# sourceMappingURL=chunk-
|
|
403
|
+
//# sourceMappingURL=chunk-FIMEPG6J.js.map
|
|
404
|
+
//# sourceMappingURL=chunk-FIMEPG6J.js.map
|