@skaile/workspaces 0.40.2 → 0.41.0

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.
Files changed (123) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/{asset-feeds-NOHUJ4XZ.js → asset-feeds-B3YOVIX6.js} +11 -11
  3. package/dist/{asset-feeds-NOHUJ4XZ.js.map → asset-feeds-B3YOVIX6.js.map} +1 -1
  4. package/dist/asset-manager/index.js +9 -9
  5. package/dist/asset-manager/installer.js +8 -8
  6. package/dist/{chunk-HL66R2P2.js → chunk-2PXSZYKV.js} +17 -8
  7. package/dist/chunk-2PXSZYKV.js.map +1 -0
  8. package/dist/{chunk-XZNPKJXU.js → chunk-4ZDA6Q5A.js} +4 -4
  9. package/dist/{chunk-XZNPKJXU.js.map → chunk-4ZDA6Q5A.js.map} +1 -1
  10. package/dist/{chunk-HAXQAC6D.js → chunk-54PBADZO.js} +3 -3
  11. package/dist/{chunk-HAXQAC6D.js.map → chunk-54PBADZO.js.map} +1 -1
  12. package/dist/{chunk-O66LT7UI.js → chunk-5PGFAYN3.js} +5 -5
  13. package/dist/{chunk-O66LT7UI.js.map → chunk-5PGFAYN3.js.map} +1 -1
  14. package/dist/{chunk-MAPRKFBD.js → chunk-B5PEERRZ.js} +18 -3
  15. package/dist/chunk-B5PEERRZ.js.map +1 -0
  16. package/dist/{chunk-CFCSDZYF.js → chunk-DUAB2AFV.js} +4 -4
  17. package/dist/{chunk-CFCSDZYF.js.map → chunk-DUAB2AFV.js.map} +1 -1
  18. package/dist/{chunk-SAXDHVJZ.js → chunk-DZCK7GRW.js} +3 -3
  19. package/dist/{chunk-SAXDHVJZ.js.map → chunk-DZCK7GRW.js.map} +1 -1
  20. package/dist/{chunk-BM7XANVN.js → chunk-GEEW6SY2.js} +10 -3
  21. package/dist/chunk-GEEW6SY2.js.map +1 -0
  22. package/dist/{chunk-USEFGACS.js → chunk-HUSXT2BN.js} +7 -7
  23. package/dist/{chunk-USEFGACS.js.map → chunk-HUSXT2BN.js.map} +1 -1
  24. package/dist/{chunk-XNMABEHH.js → chunk-IGNSNZPG.js} +5 -5
  25. package/dist/{chunk-XNMABEHH.js.map → chunk-IGNSNZPG.js.map} +1 -1
  26. package/dist/{chunk-2DYJ7BJG.js → chunk-LCJNBABB.js} +9 -9
  27. package/dist/{chunk-2DYJ7BJG.js.map → chunk-LCJNBABB.js.map} +1 -1
  28. package/dist/{chunk-23WP47VA.js → chunk-NXNBX56J.js} +2 -2
  29. package/dist/{chunk-23WP47VA.js.map → chunk-NXNBX56J.js.map} +1 -1
  30. package/dist/{chunk-WLWHOA3S.js → chunk-QGDCLTK2.js} +4 -4
  31. package/dist/{chunk-WLWHOA3S.js.map → chunk-QGDCLTK2.js.map} +1 -1
  32. package/dist/{chunk-CBXZB3G5.js → chunk-RVXP5KN5.js} +3 -3
  33. package/dist/{chunk-CBXZB3G5.js.map → chunk-RVXP5KN5.js.map} +1 -1
  34. package/dist/{chunk-EAWENE2K.js → chunk-SC3YNS4W.js} +4 -4
  35. package/dist/{chunk-EAWENE2K.js.map → chunk-SC3YNS4W.js.map} +1 -1
  36. package/dist/{chunk-C54IAYEU.js → chunk-TRVTY5AF.js} +3 -3
  37. package/dist/{chunk-C54IAYEU.js.map → chunk-TRVTY5AF.js.map} +1 -1
  38. package/dist/{chunk-KYC6JH75.js → chunk-UKJMQZV6.js} +3 -3
  39. package/dist/{chunk-KYC6JH75.js.map → chunk-UKJMQZV6.js.map} +1 -1
  40. package/dist/{chunk-J5DB4KHE.js → chunk-V2OSYOWR.js} +5 -5
  41. package/dist/{chunk-J5DB4KHE.js.map → chunk-V2OSYOWR.js.map} +1 -1
  42. package/dist/{chunk-FBIQ4QPF.js → chunk-VIA64TYP.js} +3 -3
  43. package/dist/{chunk-FBIQ4QPF.js.map → chunk-VIA64TYP.js.map} +1 -1
  44. package/dist/{chunk-4A2LAEX6.js → chunk-VMX4DA65.js} +4 -4
  45. package/dist/{chunk-4A2LAEX6.js.map → chunk-VMX4DA65.js.map} +1 -1
  46. package/dist/cli/index.js +36 -36
  47. package/dist/connectors/config.js +8 -8
  48. package/dist/connectors/index.js +9 -9
  49. package/dist/core/index.js +7 -7
  50. package/dist/core/manifest.js +2 -2
  51. package/dist/core/models.js +1 -1
  52. package/dist/core/publish-manifest.js +2 -2
  53. package/dist/core/ref.d.ts +2 -0
  54. package/dist/core/ref.js +29 -0
  55. package/dist/core/ref.js.map +1 -0
  56. package/dist/core/runtime-assets.js +5 -5
  57. package/dist/core/src/index.d.ts +1 -1
  58. package/dist/core/src/index.d.ts.map +1 -1
  59. package/dist/core/src/manifest.d.ts +0 -14
  60. package/dist/core/src/manifest.d.ts.map +1 -1
  61. package/dist/core/src/models.d.ts +20 -0
  62. package/dist/core/src/models.d.ts.map +1 -1
  63. package/dist/core/src/ref.d.ts +25 -0
  64. package/dist/core/src/ref.d.ts.map +1 -0
  65. package/dist/core/src/walker.d.ts.map +1 -1
  66. package/dist/core/workspace-config.js +4 -4
  67. package/dist/deploy/index.js +7 -7
  68. package/dist/discovery/index.js +4 -4
  69. package/dist/{ensure-sources-XITKRBLU.js → ensure-sources-EEH3DWH5.js} +13 -13
  70. package/dist/{ensure-sources-XITKRBLU.js.map → ensure-sources-EEH3DWH5.js.map} +1 -1
  71. package/dist/factory-assets/connectors/deploy.js +9 -9
  72. package/dist/factory-assets/connectors/devserver.js +9 -9
  73. package/dist/factory-assets/connectors/flow/adapter.js +9 -9
  74. package/dist/factory-assets/connectors/flow/engine.js +7 -7
  75. package/dist/factory-assets/connectors/flow/run-flow.js +10 -10
  76. package/dist/factory-assets/connectors/flow.js +9 -9
  77. package/dist/factory-assets/connectors/git.js +9 -9
  78. package/dist/factory-assets/connectors/gmail.js +9 -9
  79. package/dist/factory-assets/connectors/googledrive.js +9 -9
  80. package/dist/factory-assets/connectors/local.js +9 -9
  81. package/dist/factory-assets/connectors/mattermost.js +9 -9
  82. package/dist/factory-assets/connectors/memory.js +9 -9
  83. package/dist/factory-assets/connectors/minio.js +9 -9
  84. package/dist/factory-assets/connectors/postgres.js +9 -9
  85. package/dist/factory-assets/connectors/s3.js +9 -9
  86. package/dist/factory-assets/connectors/sharepoint.js +9 -9
  87. package/dist/factory-assets/connectors/sqlite.js +9 -9
  88. package/dist/factory-assets/connectors/static-server.js +9 -9
  89. package/dist/factory-assets/connectors/tunnel.js +9 -9
  90. package/dist/factory-assets/connectors/webdav.js +9 -9
  91. package/dist/factory-assets/connectors/xstate-store.js +9 -9
  92. package/dist/factory-assets/connectors/xstate.js +9 -9
  93. package/dist/{flows-BOJMGLRI.js → flows-ZYWYM5HR.js} +4 -4
  94. package/dist/{flows-BOJMGLRI.js.map → flows-ZYWYM5HR.js.map} +1 -1
  95. package/dist/library/index.js +11 -11
  96. package/dist/library/install.js +8 -8
  97. package/dist/open-library-5M67A7BN.js +23 -0
  98. package/dist/{open-library-5KJOZHG7.js.map → open-library-5M67A7BN.js.map} +1 -1
  99. package/dist/paths-RTD4IMYN.js +15 -0
  100. package/dist/{paths-66ZDGXK3.js.map → paths-RTD4IMYN.js.map} +1 -1
  101. package/dist/{plugin-store-BOQXW3XV.js → plugin-store-YEHJFGJS.js} +9 -9
  102. package/dist/{plugin-store-BOQXW3XV.js.map → plugin-store-YEHJFGJS.js.map} +1 -1
  103. package/dist/runner/index.js +11 -11
  104. package/dist/sdk/asset-manager.js +9 -9
  105. package/dist/sdk/core.js +7 -7
  106. package/dist/sdk/flow.js +7 -7
  107. package/dist/sdk/index.js +11 -11
  108. package/dist/sdk/runner.js +11 -11
  109. package/dist/{setup-JIGNL3O4.js → setup-VNS4I3OF.js} +9 -9
  110. package/dist/{setup-JIGNL3O4.js.map → setup-VNS4I3OF.js.map} +1 -1
  111. package/dist/store-client-GBWSRUZR.js +15 -0
  112. package/dist/{store-client-ODJJK5XS.js.map → store-client-GBWSRUZR.js.map} +1 -1
  113. package/dist/tui/index.js +11 -11
  114. package/dist/workspace-plugin/adapters/mcp.js +2 -2
  115. package/dist/workspace-plugin/adapters/omp.js +3 -3
  116. package/dist/workspace-plugin/index.js +1 -1
  117. package/package.json +7 -1
  118. package/dist/chunk-BM7XANVN.js.map +0 -1
  119. package/dist/chunk-HL66R2P2.js.map +0 -1
  120. package/dist/chunk-MAPRKFBD.js.map +0 -1
  121. package/dist/open-library-5KJOZHG7.js +0 -23
  122. package/dist/paths-66ZDGXK3.js +0 -15
  123. package/dist/store-client-ODJJK5XS.js +0 -15
@@ -1,4 +1,4 @@
1
- import { parseDep } from './chunk-BM7XANVN.js';
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-MAPRKFBD.js.map
326
- //# sourceMappingURL=chunk-MAPRKFBD.js.map
340
+ //# sourceMappingURL=chunk-B5PEERR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a,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-HL66R2P2.js';
2
- import { scanDirectory } from './chunk-MAPRKFBD.js';
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-CFCSDZYF.js.map
213
- //# sourceMappingURL=chunk-CFCSDZYF.js.map
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,IAAM,wBAAA,GAA2B;AAMxC,IAAM,iCAAA,GAAoC,yBAAA;AAsC1C,eAAsB,qBAAqB,UAAA,EAAkD;AAC3F,EAAA,MAAM,MAAA,GAA8B;AAAA,IA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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,GAAA;AACT;AAqDO,IAAM,wBAAA,GAA2B;AAMxC,IAAM,iCAAA,GAAoC,yBAAA;AAsC1C,eAAsB,qBAAqB,UAAA,EAAkD;AAC3F,EAAA,MAAM,MAAA,GAA8B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EA,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-BM7XANVN.js';
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-SAXDHVJZ.js.map
229
- //# sourceMappingURL=chunk-SAXDHVJZ.js.map
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,YAAY,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA,EAAG,OAAO,MAAA;AAClE,EAAA,MAAM,CAAA,GAAI,GAAA;AACV,EAAA,IAAI,OAAO,EAAE,GAAA,KAAQ,QAAA,IAAY,EAAE,GAAA,CAAI,MAAA,KAAW,GAAG,OAAO,MAAA;AAC5D,E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,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-SAXDHVJZ.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,IAAI,OAAO,EAAE,GAAA,KAAQ,QAAA,IAAY,EAAE,GAAA,CAAI,MAAA,KAAW,GAAG,OAAO,MAAA;AAC5D,EAAA,MAAM,GAAA,GAAsB,EAAE,GAAA,EAAK,CAAA,CAAE,GAAA,EAAI;AACzC,EAAA,IAAI,OAAO,CAAA,CAAE,MAAA,KAAW,QA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A,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"]}
@@ -91,6 +91,13 @@ var ASSET_NAME_HINT = 'names must be lowercase kebab-case (a-z, 0-9, single hyph
91
91
  function isValidAssetName(name) {
92
92
  return ASSET_NAME_RE.test(name);
93
93
  }
94
+ function slugifyAssetName(raw) {
95
+ const slug = raw.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
96
+ if (!slug) {
97
+ throw new Error(`cannot derive a canonical asset name from "${raw}" \u2014 ${ASSET_NAME_HINT}.`);
98
+ }
99
+ return slug;
100
+ }
94
101
  function isValidPin(pin) {
95
102
  if (SHA_RE.test(pin)) return true;
96
103
  if (semver.valid(pin)) return true;
@@ -156,6 +163,6 @@ function repositoryToRaw(r) {
156
163
  return d;
157
164
  }
158
165
 
159
- export { ASSET_KINDS, ASSET_NAME_HINT, INDIVIDUAL_KINDS, assetRefToDep, assetRefToStr, depToStr, entryFromRaw, entryToRaw, isValidAssetName, parseAssetRef, parseDep, repositoryFromRaw, repositoryToRaw };
160
- //# sourceMappingURL=chunk-BM7XANVN.js.map
161
- //# sourceMappingURL=chunk-BM7XANVN.js.map
166
+ export { ASSET_KINDS, ASSET_NAME_HINT, INDIVIDUAL_KINDS, assetRefToDep, assetRefToStr, depToStr, entryFromRaw, entryToRaw, isValidAssetName, parseAssetRef, parseDep, repositoryFromRaw, repositoryToRaw, slugifyAssetName };
167
+ //# sourceMappingURL=chunk-GEEW6SY2.js.map
168
+ //# sourceMappingURL=chunk-GEEW6SY2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../core/src/models.ts"],"names":[],"mappings":";;;AA4BO,IAAM,WAAA,GAAoC;AAAA,EAC/C,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;AAQO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF;AAwBO,SAAS,SAAS,CAAA,EAAuB;AAC9C,EAAA,MAAM,CAAA,GAAI,CAAA,CAAE,OAAA,CAAQ,GAAG,CAAA;AACvB,EAAA,IAAI,MAAM,EAAA,EAAI;AACZ,IAAA,MAAM,OAAO,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,CAAC,EAAE,IAAA,EAAK;AAChC,IAAA,MAAM,OAAO,CAAA,CAAE,KAAA,CAAM,CAAA,GAAI,CAAC,EAAE,IAAA,EAAK;AACjC,IAAA,OAAO,EAAE,MAAM,IAAA,EAAK;AAAA,EACtB;AACA,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,CAAA,CAAE,MAAK,EAAE;AACzC;AASO,SAAS,SAAS,CAAA,EAAuB;AAC9C,EAAA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AAM,MAAA,CAAO,CAAA,CAAE,IAAA,IAAQ,EAAE,CAAA;AAAA,IACzB,MAAA,EAAQ,MAAA,CAAO,CAAA,CAAE,MAAA,IAAU,MAAM,CAAA;AAAA,IACjC,UAAU,CAAA,CAAE,QAAA,IAAY,OAAO,MAAA,CAAO,CAAA,CAAE,QAAQ,CAAA,GAAI;AAAA,GACtD;AACF;AAUO,SAAS,gBAAgB,CAAA,EAAwC;AACtE,EAAA,MAAM,CAAA,GAA6B;AAAA,IACjC,MAAM,CAAA,CAAE,IAAA;AAAA,IACR,MAAM,CAAA,CAAE,IAAA;AAAA,IACR,MAAM,CAAA,CAAE;AAAA,GACV;AACA,EAAA,IAAI,CAAA,CAAE,MAAA,KAAW,MAAA,EAAQ,CAAA,CAAE,SAAS,CAAA,CAAE,MAAA;AACtC,EAAA,IAAI,CAAA,CAAE,QAAA,IAAY,IAAA,EAAM,CAAA,CAAE,WAAW,CAAA,CAAE,QAAA;AACvC,EAAA,OAAO,CAAA;AACT","file":"chunk-GEEW6SY2.js","sourcesContent":["/**\n * Pure data models — no I/O, no side effects.\n */\n\nimport semver from \"semver\";\n\n/**\n * Discriminator for catalog entries and asset references.\n * Used in asset ref strings (e.g. `'skill:my-skill'`, `'agent:my-agent'`).\n * @docLink packages/core/concepts#asset-kind\n */\nexport type AssetKind =\n | \"skill\"\n | \"agent\"\n | \"prompt\"\n | \"bundle\"\n | \"flow\"\n | \"contract\"\n | \"mcp-server\"\n | \"persona\" // identity fragment — replaces SOUL.md in composition\n | \"ruleset\" // behavioral constraints — replaces RULES.md in composition\n | \"knowledge\" // knowledge bundle directory\n | \"connector\"; // connector descriptor (CONNECTOR.md)\n\n/**\n * All valid AssetKind values as a readonly array.\n * @docLink packages/core/concepts#asset-kinds\n */\nexport const ASSET_KINDS: readonly AssetKind[] = [\n \"skill\",\n \"agent\",\n \"prompt\",\n \"bundle\",\n \"flow\",\n \"contract\",\n \"mcp-server\",\n \"persona\",\n \"ruleset\",\n \"knowledge\",\n \"connector\",\n];\n/**\n * Asset kinds that represent individually installable assets (excludes \"bundle\").\n * Note: persona, ruleset, and knowledge are valid AssetKind values but are not\n * individually installable — they are resolved at session creation time via the\n * mixin-resolver, not through the install/deploy pipeline.\n * @docLink packages/core/concepts#individual-kinds\n */\nexport const INDIVIDUAL_KINDS = [\n \"skill\",\n \"agent\",\n \"prompt\",\n \"flow\",\n \"contract\",\n \"mcp-server\",\n] as const satisfies AssetKind[];\n\n// ── Dependency ────────────────────────────────────────────────────────────────\n\n/**\n * Declared dependency on another catalog asset.\n * @docLink packages/core/concepts#dependency\n */\nexport interface Dependency {\n /** Asset kind (e.g. \"skill\", \"agent\", \"contract\"). */\n kind: string;\n /** Asset name within that kind. */\n name: string;\n /** Canonical publisher namespace (when known). */\n publisher?: string;\n}\n\n/**\n * Parse a `\"kind:name\"` dependency string, or a bare `\"name\"` (defaults kind to `\"skill\"`).\n *\n * @param s - Dependency string, e.g. `\"skill:use-exa\"` or `\"use-exa\"`\n * @returns Parsed `{ kind, name }` dependency object\n * @docLink packages/core/concepts#parse-dep\n */\nexport function parseDep(s: string): Dependency {\n const i = s.indexOf(\":\");\n if (i !== -1) {\n const kind = s.slice(0, i).trim();\n const name = s.slice(i + 1).trim();\n return { kind, name };\n }\n return { kind: \"skill\", name: s.trim() };\n}\n\n/**\n * Serialize a Dependency back to its `\"kind:name\"` string form.\n *\n * @param d - Dependency to serialize\n * @returns String in `\"kind:name\"` format\n * @docLink packages/core/concepts#dep-to-str\n */\nexport function depToStr(d: Dependency): string {\n return `${d.kind}:${d.name}`;\n}\n\n// ── CatalogEntry ──────────────────────────────────────────────────────────────\n\n/**\n * A resolved catalog entry describing an installable asset.\n * Produced by manifest parsers and stored in the catalog YAML.\n * @docLink packages/core/concepts#catalog-entry\n */\nexport interface CatalogEntry {\n /** Unique asset name within its kind. */\n name: string;\n /** Asset kind discriminator. */\n kind: AssetKind;\n /** Short description of what this asset does. */\n description: string;\n /** Absolute path to manifest file */\n source: string;\n /** Canonical publisher namespace this asset belongs to (formerly `repository`). */\n publisher?: string;\n /**\n * `\"<org>/<repo>\"` coordinate the asset came from. Absent → the asset groups\n * directly under its publisher (local library with no git remote, or a\n * non-GitHub source). Replaces the former derived `domain` axis.\n */\n repo?: string;\n /**\n * Navigational domain slug (from a sidecar `DOMAIN.md`), or absent when no\n * domain claims this asset. Display-only — groups assets under their publisher\n * in the manage TUI; never part of identity or the install layout.\n */\n domainSlug?: string;\n /** Semantic version string (may be empty if not declared in the manifest). */\n version: string;\n /** Skills, agents, or other assets this entry depends on. */\n requires: Dependency[];\n /** Bundle dependencies — asset refs to install (bundles only). */\n dependencies: string[];\n /**\n * Kind-specific metadata extracted from the manifest frontmatter.\n * Used by MCP servers to carry default config (transport, command, args, env, url, headers)\n * so that `mcp:name` dependency refs resolve to a runnable declaration without\n * requiring verbose inline config in `skaile.yaml`.\n */\n metadata?: Record<string, unknown>;\n /** Curated facet, surfaced as a badge in the manage TUI (not a tree axis). */\n category?: string;\n /** Store-listing keywords (manifest `assets[].keywords`, else frontmatter). */\n keywords?: string[];\n /** Store-listing license (manifest `assets[].license`, else repo-level default). */\n license?: string;\n /** Store-listing homepage (manifest `assets[].homepage`, else repo-level default). */\n homepage?: string;\n}\n\n/**\n * How the members of a domain relate — drives display affordances only, never\n * install behaviour. Single canonical spelling shared with the store\n * (`DomainRelation` enum) and forge contract.\n */\nexport type DomainRelation = \"additions\" | \"alternatives\" | \"sequence\";\n\n/**\n * Display-only metadata for a navigational domain (from a sidecar `DOMAIN.md`,\n * surfaced by the store's `catalog.listDomains`). Keyed by {@link CatalogEntry.domainSlug}.\n * A domain groups assets under their publisher for co-discovery; it is never\n * part of asset identity and never bulk-installs.\n */\nexport interface CatalogDomain {\n /** Stable slug — the join key to {@link CatalogEntry.domainSlug}. */\n slug: string;\n /** Human-readable title (may change without breaking the slug join). */\n title: string;\n /** Free-text description from the `DOMAIN.md` body. */\n description?: string;\n /** How members relate — drives sort + per-asset glyph, not installs. */\n relation?: DomainRelation;\n /** Display order among a publisher's domains (ascending). */\n order?: number;\n /** `kind:name` ref of the recommended member (alternatives domains). */\n recommendedRef?: string;\n /** Sidecar provenance — `\"<org>/<repo>\"` the `DOMAIN.md` was authored in. */\n sidecarSource?: string;\n}\n\n/**\n * Construct a CatalogEntry from a raw deserialized record (e.g. from catalog.yaml).\n *\n * @param d - Raw object with loosely typed fields\n * @returns Normalized CatalogEntry\n * @docLink packages/core/concepts#entry-from-raw\n */\nexport function entryFromRaw(d: Record<string, unknown>): CatalogEntry {\n const rawDeps = d.dependencies;\n const deps = Array.isArray(rawDeps) ? (rawDeps as string[]).filter(Boolean) : [];\n const entry: CatalogEntry = {\n name: String(d.name ?? \"\"),\n kind: String(d.kind ?? \"skill\") as AssetKind,\n description: String(d.description ?? \"\"),\n source: String(d.source ?? \"\"),\n publisher: d.publisher != null ? String(d.publisher) : undefined,\n // Read `repo`, falling back to the legacy `domain` key so a stale\n // catalog.yaml cache written before this release still groups sanely.\n // The cache self-heals on next write (entryToRaw stops writing `domain`).\n repo: d.repo != null ? String(d.repo) : d.domain != null ? String(d.domain) : undefined,\n domainSlug: d.domainSlug != null ? String(d.domainSlug) : undefined,\n version: String(d.version ?? \"\"),\n requires: Array.isArray(d.requires)\n ? (d.requires as string[]).filter(Boolean).map(parseDep)\n : [],\n dependencies: deps,\n };\n if (d.metadata != null && typeof d.metadata === \"object\" && !Array.isArray(d.metadata)) {\n entry.metadata = d.metadata as Record<string, unknown>;\n }\n if (d.category != null) entry.category = String(d.category);\n if (Array.isArray(d.keywords)) {\n entry.keywords = (d.keywords as unknown[]).filter((k): k is string => typeof k === \"string\");\n }\n if (d.license != null) entry.license = String(d.license);\n if (d.homepage != null) entry.homepage = String(d.homepage);\n return entry;\n}\n\n/**\n * Serialize a CatalogEntry to a plain record suitable for YAML/JSON persistence.\n *\n * @param e - CatalogEntry to serialize\n * @returns Plain object with string-serialized requires and dependencies\n * @docLink packages/core/concepts#entry-to-raw\n */\nexport function entryToRaw(e: CatalogEntry): Record<string, unknown> {\n const raw: Record<string, unknown> = {\n name: e.name,\n kind: e.kind,\n description: e.description,\n source: e.source,\n publisher: e.publisher,\n repo: e.repo,\n version: e.version,\n ...(e.domainSlug != null ? { domainSlug: e.domainSlug } : {}),\n requires: e.requires.map(depToStr),\n dependencies: e.dependencies,\n };\n if (e.metadata) raw.metadata = e.metadata;\n if (e.category != null) raw.category = e.category;\n if (e.keywords && e.keywords.length > 0) raw.keywords = e.keywords;\n if (e.license != null) raw.license = e.license;\n if (e.homepage != null) raw.homepage = e.homepage;\n return raw;\n}\n\n// ── AssetRef ─────────────────────────────────────────────────────────────────\n\n/**\n * A parsed asset reference: `kind:@<publisher>/name[#pin]`.\n *\n * `publisher` is the canonical, GitHub-shaped publisher namespace (≤39 chars,\n * alphanumeric+hyphen). `pin` is a SemVer constraint, exact SHA, or absent.\n * Floating refs (`main`, `latest`, `HEAD`) are rejected at parse time.\n *\n * Produced by `parseAssetRef`; consumed by `resolveAsset` and `resolveAll`.\n * @docLink packages/core/concepts#asset-ref\n */\nexport interface AssetRef {\n kind: string;\n name: string;\n /** Canonical publisher namespace. Optional only for ambiguity-resolution\n * during migration; new manifests require it. */\n publisher?: string;\n /** SemVer constraint (^1.4.0, ~1.4, 1.x, exact 1.4.0), 40-char SHA, or undefined. */\n pin?: string;\n}\n\nconst SHA_RE = /^[0-9a-f]{40}$/i;\n\n// Scoped grammar: `kind:@publisher/name[#version]`. The publisher sub-pattern is\n// GitHub-shaped (1-39 chars, alphanumeric + single hyphens, no leading/trailing or\n// double hyphen); `@` is the scope sigil and `#` the version sigil. `name` is\n// intentionally permissive (`[^/#\\s]+` — only the structural separators are\n// forbidden); floating-ref rejection stays in `isValidPin`, so `#main`/`#latest`\n// match here and fail there with a clear message.\nconst SCOPED_REF_RE =\n /^(?:([a-z][a-z0-9-]*):)?@([A-Za-z0-9](?:[A-Za-z0-9]|-(?!-)){0,37}[A-Za-z0-9]|[A-Za-z0-9])\\/([^/#\\s]+)(?:#(.+))?$/;\n\n// Canonical asset-name grammar: lowercase kebab-case (npm-style, scope-free) —\n// `a-z` / `0-9` segments joined by single hyphens, no leading/trailing hyphen,\n// no uppercase, spaces, dots, or underscores. Names become directory names,\n// lock keys, and CLI args, so the constraint is intentionally narrow.\nconst ASSET_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n// Diagnostic-only matcher: a ref carrying a `kind:@publisher/` scope prefix,\n// capturing whatever follows (sans `#pin`) as the candidate name. Used solely\n// to tell \"missing publisher\" apart from \"malformed name\" when the strict\n// grammar above fails (e.g. a space in the name).\nconst SCOPE_PREFIX_RE = /^(?:[a-z][a-z0-9-]*:)?@[^/\\s]+\\/([^#]+?)(?:#.*)?$/;\n\n/** Human-readable statement of the canonical asset-name rule. */\nexport const ASSET_NAME_HINT =\n 'names must be lowercase kebab-case (a-z, 0-9, single hyphens; e.g. \"cli-concept\")';\n\n/**\n * True when `name` is a canonical asset name: lowercase kebab-case, scope-free.\n *\n * This is the single source of truth for asset-name validity — `parseAssetRef`\n * enforces it, and `skaile validate` reports violations across a repo tree.\n * @docLink packages/core/concepts#is-valid-asset-name\n */\nexport function isValidAssetName(name: string): boolean {\n return ASSET_NAME_RE.test(name);\n}\n\n/**\n * Coerce an arbitrary string into a canonical asset name (lowercase kebab-case).\n *\n * For **third-party sources we don't control**, an upstream asset may carry a\n * human-styled identity (`\"Complex App\"`, `\"CLI_Concept\"`). The canonical grammar\n * (`isValidAssetName`) rejects those, so the ingestion boundary slugifies them to\n * a valid identity rather than crashing: Unicode is folded to ASCII, the result is\n * lowercased, every run of non-`[a-z0-9]` becomes a single hyphen, and\n * leading/trailing hyphens are trimmed. The transform is idempotent and a no-op on\n * already-canonical names.\n *\n * This is intentionally **lossy** — the pretty original is not part of identity.\n * Callers that want to preserve it for display must stash it themselves (e.g. on\n * `CatalogEntry.metadata.displayName`). Authoring-time validation (`skaile validate`)\n * still uses `isValidAssetName` on raw frontmatter, so first-party typos surface there.\n *\n * @throws When `raw` contains no `[a-z0-9]` character (nothing to slugify).\n * @docLink packages/core/concepts#slugify-asset-name\n */\nexport function slugifyAssetName(raw: string): string {\n const slug = raw\n .normalize(\"NFKD\")\n .replace(/[\\u0300-\\u036f]/g, \"\") // strip combining accents\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n if (!slug) {\n throw new Error(`cannot derive a canonical asset name from \"${raw}\" — ${ASSET_NAME_HINT}.`);\n }\n return slug;\n}\n\n/** True when `pin` is a SemVer constraint, exact SemVer, or 40-char SHA. */\nfunction isValidPin(pin: string): boolean {\n if (SHA_RE.test(pin)) return true;\n if (semver.valid(pin)) return true;\n if (semver.validRange(pin)) return true;\n return false;\n}\n\n/** Throw the canonical non-canonical-pin error for a ref `s` carrying `pin`. */\nfunction rejectFloatingPin(s: string, pin: string): never {\n throw new Error(\n `non-canonical pin \"${pin}\" in \"${s}\" — pin must be a SemVer ` +\n \"constraint (1.4.0, ^1.4, ~1.4, 1.x), a 40-char SHA, or absent. \" +\n \"Floating refs (main/latest/HEAD) are not allowed.\",\n );\n}\n\n/** Throw the canonical malformed-name error for a ref `s` carrying `name`. */\nfunction rejectInvalidName(s: string, name: string): never {\n throw new Error(\n `invalid asset name \"${name}\" in ref \"${s}\" — ${ASSET_NAME_HINT}. ` +\n \"Run the `migrate-skaile-manifest` skill on legacy manifests.\",\n );\n}\n\n/**\n * Parse a canonical asset reference string into an `AssetRef` object.\n *\n * Grammar: `kind:@<publisher>/name[#version]`\n * \"skill:@skaile-ai/audit\" → { kind: \"skill\", name: \"audit\", publisher: \"skaile-ai\" }\n * \"skill:@skaile-ai/audit#^1.4.0\" → { …, pin: \"^1.4.0\" }\n * \"skill:@skaile-ai/audit#<40-sha>\" → { …, pin: \"<40-sha>\" }\n *\n * `@` is the scope sigil and `#` the version sigil. `<publisher>` is GitHub-shaped\n * (≤39 chars, alphanumeric+hyphen, no leading/trailing or double hyphen). `pin`\n * accepts a SemVer constraint (`^`, `~`, `x`, exact), a 40-char SHA, or is absent.\n * Floating refs (`main`/`latest`/`HEAD`/anything non-canonical) are parse-time errors.\n *\n * The shorthand `mcp:` is normalized to `mcp-server:`. `kind` defaults to `\"skill\"`.\n *\n * @param s - Asset reference string\n * @returns Parsed `AssetRef`\n * @throws When the ref matches no grammar, the publisher is malformed, or the pin\n * is a floating ref.\n * @docLink packages/core/concepts#parse-asset-ref\n */\nexport function parseAssetRef(s: string): AssetRef {\n const trimmed = s.trim();\n const m = SCOPED_REF_RE.exec(trimmed);\n if (m) {\n const kindRaw = m[1] ?? \"skill\";\n const kind = kindRaw === \"mcp\" ? \"mcp-server\" : kindRaw;\n const publisher = m[2];\n const name = m[3];\n const pin = m[4]?.trim() || undefined;\n if (!isValidAssetName(name)) rejectInvalidName(s, name);\n if (pin !== undefined && !isValidPin(pin)) rejectFloatingPin(s, pin);\n return { kind, name, publisher, pin };\n }\n\n // The strict grammar failed. If the ref nonetheless carries a `@publisher/`\n // scope and the fault is the name (e.g. an embedded space), surface a\n // name-specific error rather than the misleading \"publisher required\" — the\n // publisher is plainly present. A *valid* captured name means the publisher\n // itself is malformed, so fall through to the publisher error below.\n const scoped = SCOPE_PREFIX_RE.exec(trimmed);\n if (scoped) {\n const candidate = scoped[1].trim();\n if (!isValidAssetName(candidate)) rejectInvalidName(s, candidate);\n }\n\n throw new Error(\n `publisher required in asset ref \"${s}\" — use \\`kind:@<publisher>/name\\`. ` +\n \"Run the `migrate-skaile-manifest` skill on legacy manifests.\",\n );\n}\n\n/**\n * Serialize an AssetRef back to its canonical string form.\n *\n * Emits the scope form `kind:@publisher/name[#pin]` when `publisher` is present,\n * and the bare `kind:name[#pin]` form for transitive refs that inherit it.\n *\n * @param ref - AssetRef to serialize\n * @returns String in `\"kind:@publisher/name[#pin]\"` (or bare `\"kind:name[#pin]\"`) format\n * @docLink packages/core/concepts#asset-ref-to-str\n */\nexport function assetRefToStr(ref: AssetRef): string {\n const scope = ref.publisher ? `@${ref.publisher}/${ref.name}` : ref.name;\n return `${ref.kind}:${scope}${ref.pin ? `#${ref.pin}` : \"\"}`;\n}\n\n/**\n * Convert an AssetRef to a simple Dependency, dropping the repository and pin qualifiers.\n *\n * @param ref - Full asset reference (may include repository and pin)\n * @returns Dependency with only kind and name\n * @docLink packages/core/concepts#asset-ref-to-dep\n */\nexport function assetRefToDep(ref: AssetRef): Dependency {\n // Grammar-agnostic — drops publisher/pin, so the scope-sigil change doesn't touch it.\n return { kind: ref.kind, name: ref.name };\n}\n\n// ── Lock File ────────────────────────────────────────────────────────────────\n\n/** A path/sha256 pair recorded for one file inside a locked asset. */\nexport interface LockFileEntry {\n path: string;\n sha256: string;\n}\n\n/**\n * Per-asset entry in the lock file (v3 schema).\n * Keyed in `LockFile.assets` by canonical ref (`<kind>:@<publisher>/<name>#<version>`).\n * @docLink packages/core/api-reference#lock-entry\n */\nexport interface LockEntry {\n /** Composite sha256 over sorted `<path>:<sha256>\\n` rows. */\n sha256: string;\n /** Resolved upstream source + commit. */\n source: { url: string; commit: string };\n /** Files that constitute the asset. */\n files: LockFileEntry[];\n /** True when an `overrides[]` entry pinned this resolution. */\n override_applied: boolean;\n}\n\n/** Per-source-URL entry in `LockFile.sources`. */\nexport interface LockSourceEntry {\n url: string;\n commit: string;\n}\n\n/**\n * Full skaile.lock.yaml structure (v3 schema).\n * @docLink packages/core/api-reference#lock-file\n */\nexport interface LockFile {\n /** Lock file schema version. v3 is canonical. */\n schema_version: 3;\n /** ISO timestamp of when the lock was generated. */\n locked_at: string;\n /** Resolved assets keyed by canonical ref `<kind>:@<publisher>/<name>#<version>`. */\n assets: Record<string, LockEntry>;\n /** Every source URL that contributed at least one resolved asset. */\n sources: LockSourceEntry[];\n /**\n * Resolved plugin packages (from `skaile.yaml` `plugins:`), keyed by package\n * name. The plugin-store reconciler reads this slice into its reconcile-hash\n * so a lock change reinstalls even when the manifest list is unchanged.\n */\n plugins?: Record<string, LockPluginEntry>;\n}\n\n/** One pinned plugin package in the lock file's `plugins` slice. */\nexport interface LockPluginEntry {\n /** Resolved exact version (e.g. \"0.1.3\"). */\n version: string;\n /** Package integrity hash (e.g. \"sha512-...\"); may be empty until populated from bun's output. */\n integrity: string;\n}\n\n// ── AgentManifest ────────────────────────────────────────────────────────────\n\n/**\n * Agent package manifest — parsed from `agent.yaml` in an agent directory.\n * Defines the agent's identity, model preferences, capability requirements, and composition mixins.\n * @docLink packages/core/concepts#agent-manifest\n */\nexport interface AgentManifest {\n spec_version?: string;\n name?: string;\n version?: string;\n description?: string;\n model?: {\n preferred?: string;\n fallback?: string[];\n constraints?: { temperature?: number; max_tokens?: number };\n };\n tools?: {\n allowed?: string[];\n denied?: string[];\n };\n delegation?: { mode?: string };\n requires?: Array<{ name: string; source: string; version?: string; mount: string }>;\n tags?: string[];\n author?: string;\n metadata?: Record<string, unknown>;\n /**\n * @deprecated Use `persona`, `rules`, and `knowledge` mixin arrays instead.\n * This field is declared but was never resolved at runtime.\n */\n extends?: string;\n abilities?: string[];\n /**\n * Identity fragments to compose into the agent persona.\n * Each entry is a catalog ref (`persona:name@repo#pin`), a bare name\n * (defaults to kind \"persona\"), or a local path (`./my.persona.md`).\n * Resolved in order — concatenated with \\n\\n---\\n\\n separator.\n */\n persona?: string[];\n /**\n * Behavioral rule sets to compose into the agent's constraints.\n * Each entry is a catalog ref (`ruleset:name@repo#pin`), bare name,\n * or local path. All rules apply (union).\n */\n rules?: string[];\n /**\n * Knowledge bundles to compose into the agent's domain knowledge.\n * Each entry is a catalog ref (`knowledge:name@repo#pin`), bare name,\n * or local path to a knowledge directory. Loaded in declaration order.\n */\n knowledge?: string[];\n contracts?: string[];\n /**\n * v2 composition items. Each entry references an asset (skill, connector,\n * soul, ruleset, etc.) with binding semantics (discoverable, inline-live,\n * inline-snapshot). Resolved at session start via the composition module.\n */\n composes?: Array<{\n kind: string;\n ref: string;\n instance?: string;\n binding?: \"discoverable\" | \"inline-live\" | \"inline-snapshot\";\n }>;\n runtime?: {\n max_turns?: number;\n timeout?: number;\n [key: string]: unknown;\n };\n}\n\n// ── Repository ───────────────────────────────────────────────────────────────\n\ntype RepositoryKind = \"local\" | \"github\";\n\n/**\n * A registered asset repository (local path or cloned GitHub repo).\n * Stored in the catalog; consumed by `repo-manager` for cloning and scanning.\n * @docLink packages/core/concepts#repository\n */\nexport interface Repository {\n /** Logical repository name. */\n name: string;\n /** Storage kind: \"local\" for paths, \"github\" for remote URLs. */\n kind: RepositoryKind;\n /** Absolute path (local) or remote URL (github). */\n path: string;\n /** Active branch. */\n branch: string;\n /** Upstream fork URL (for fork-based workflows). */\n upstream?: string;\n}\n\n/**\n * Construct a `Repository` from a raw deserialized record.\n *\n * @param d - Raw object from YAML/JSON\n * @returns Normalized `Repository`\n * @docLink packages/core/concepts#repository-from-raw\n */\nexport function repositoryFromRaw(d: Record<string, unknown>): Repository {\n return {\n name: String(d.name ?? \"\"),\n kind: String(d.kind ?? \"local\") as RepositoryKind,\n path: String(d.path ?? \"\"),\n branch: String(d.branch ?? \"main\"),\n upstream: d.upstream != null ? String(d.upstream) : undefined,\n };\n}\n\n/**\n * Serialize a `Repository` to a plain record for YAML/JSON persistence.\n * Omits the `branch` field when it equals `\"main\"` to keep serialized output clean.\n *\n * @param r - Repository to serialize\n * @returns Plain object suitable for YAML/JSON\n * @docLink packages/core/concepts#repository-to-raw\n */\nexport function repositoryToRaw(r: Repository): Record<string, unknown> {\n const d: Record<string, unknown> = {\n name: r.name,\n kind: r.kind,\n path: r.path,\n };\n if (r.branch !== \"main\") d.branch = r.branch;\n if (r.upstream != null) d.upstream = r.upstream;\n return d;\n}\n"]}
@@ -1,8 +1,8 @@
1
- import { deployAll, removeAsset, createScaffold } from './chunk-4A2LAEX6.js';
2
- import { writeLock, buildLockFile, readLock, verifyLock, extractForPatch, generatePatch, savePatch, applyPatch } from './chunk-FBIQ4QPF.js';
3
- import { resolveRuntimeAssets, factoryAssetRoots } from './chunk-CFCSDZYF.js';
4
- import { resolveSkWorkspaceConfig, getRepoCommit, buildProvenanceIndex, resolveAll, ensureRepo, scanRepo, checkRepoStatus, resolveAsset, readLinks, getGlobalCacheDir } from './chunk-HL66R2P2.js';
5
- import { parseAssetRef } from './chunk-BM7XANVN.js';
1
+ import { deployAll, removeAsset, createScaffold } from './chunk-VMX4DA65.js';
2
+ import { writeLock, buildLockFile, readLock, verifyLock, extractForPatch, generatePatch, savePatch, applyPatch } from './chunk-VIA64TYP.js';
3
+ import { resolveRuntimeAssets, factoryAssetRoots } from './chunk-DUAB2AFV.js';
4
+ import { resolveSkWorkspaceConfig, getRepoCommit, buildProvenanceIndex, resolveAll, ensureRepo, scanRepo, checkRepoStatus, resolveAsset, readLinks, getGlobalCacheDir } from './chunk-2PXSZYKV.js';
5
+ import { parseAssetRef } from './chunk-GEEW6SY2.js';
6
6
  import { deployedBase, isDeployed, deployedDir } from './chunk-XGCXFX7X.js';
7
7
  import { appendHistory, getRecentHistory, clearHistory } from './chunk-KTBKW2FI.js';
8
8
  import { commitChanges } from './chunk-UQ6LFBPZ.js';
@@ -1040,5 +1040,5 @@ var AssetManager = class {
1040
1040
  };
1041
1041
 
1042
1042
  export { AssetManager, parseCanonicalLockKey };
1043
- //# sourceMappingURL=chunk-USEFGACS.js.map
1044
- //# sourceMappingURL=chunk-USEFGACS.js.map
1043
+ //# sourceMappingURL=chunk-HUSXT2BN.js.map
1044
+ //# sourceMappingURL=chunk-HUSXT2BN.js.map