@skaile/workspaces 0.15.1 → 0.16.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 (89) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/asset-feeds-L4ROBIAZ.js +90 -0
  3. package/dist/asset-feeds-L4ROBIAZ.js.map +1 -0
  4. package/dist/asset-manager/index.js +5 -5
  5. package/dist/asset-manager/installer.js +4 -4
  6. package/dist/asset-manager/src/index.d.ts.map +1 -1
  7. package/dist/base-assets/connectors/deploy.js +5 -5
  8. package/dist/base-assets/connectors/devserver.js +5 -5
  9. package/dist/base-assets/connectors/flow/adapter.js +5 -5
  10. package/dist/base-assets/connectors/flow/run-flow.js +6 -6
  11. package/dist/base-assets/connectors/flow.js +5 -5
  12. package/dist/base-assets/connectors/git.js +5 -5
  13. package/dist/base-assets/connectors/gmail.js +5 -5
  14. package/dist/base-assets/connectors/googledrive.js +5 -5
  15. package/dist/base-assets/connectors/local.js +5 -5
  16. package/dist/base-assets/connectors/mattermost.js +5 -5
  17. package/dist/base-assets/connectors/memory.js +5 -5
  18. package/dist/base-assets/connectors/minio.js +5 -5
  19. package/dist/base-assets/connectors/postgres.js +5 -5
  20. package/dist/base-assets/connectors/redis.js +5 -5
  21. package/dist/base-assets/connectors/s3.js +5 -5
  22. package/dist/base-assets/connectors/sharepoint.js +5 -5
  23. package/dist/base-assets/connectors/sqlite.js +5 -5
  24. package/dist/base-assets/connectors/static-server.js +5 -5
  25. package/dist/base-assets/connectors/tunnel.js +5 -5
  26. package/dist/base-assets/connectors/webdav.js +5 -5
  27. package/dist/base-assets/connectors/xstate-store.js +5 -5
  28. package/dist/base-assets/connectors/xstate.js +5 -5
  29. package/dist/base-assets/connectors/yjs.js +5 -5
  30. package/dist/{chunk-SVNFQSU3.js → chunk-3DS5VIQP.js} +3 -3
  31. package/dist/{chunk-SVNFQSU3.js.map → chunk-3DS5VIQP.js.map} +1 -1
  32. package/dist/{chunk-ERCOCLW5.js → chunk-42YLNYFK.js} +4 -4
  33. package/dist/{chunk-ERCOCLW5.js.map → chunk-42YLNYFK.js.map} +1 -1
  34. package/dist/{chunk-4RUVG5GX.js → chunk-4BRSVK7Q.js} +46 -3
  35. package/dist/chunk-4BRSVK7Q.js.map +1 -0
  36. package/dist/{chunk-HJV7MHG5.js → chunk-75M5W7FX.js} +8 -8
  37. package/dist/{chunk-HJV7MHG5.js.map → chunk-75M5W7FX.js.map} +1 -1
  38. package/dist/{chunk-67TJEQJE.js → chunk-ALJM24WL.js} +5 -5
  39. package/dist/{chunk-67TJEQJE.js.map → chunk-ALJM24WL.js.map} +1 -1
  40. package/dist/{chunk-W75ASXH4.js → chunk-KJ2LLWRF.js} +3 -3
  41. package/dist/{chunk-W75ASXH4.js.map → chunk-KJ2LLWRF.js.map} +1 -1
  42. package/dist/{chunk-6DEGWPAR.js → chunk-SMFZFFIZ.js} +3 -3
  43. package/dist/{chunk-6DEGWPAR.js.map → chunk-SMFZFFIZ.js.map} +1 -1
  44. package/dist/{chunk-GAZINYCS.js → chunk-SOQMVRQL.js} +19 -3
  45. package/dist/chunk-SOQMVRQL.js.map +1 -0
  46. package/dist/{chunk-DEZVZSBN.js → chunk-YMMWP3YL.js} +21 -6
  47. package/dist/chunk-YMMWP3YL.js.map +1 -0
  48. package/dist/{chunk-HSOEX3TA.js → chunk-YW36VEVN.js} +4 -4
  49. package/dist/{chunk-HSOEX3TA.js.map → chunk-YW36VEVN.js.map} +1 -1
  50. package/dist/{chunk-G7O7WDXX.js → chunk-ZUQXHBEH.js} +2 -2
  51. package/dist/{chunk-G7O7WDXX.js.map → chunk-ZUQXHBEH.js.map} +1 -1
  52. package/dist/cli/index.js +238 -117
  53. package/dist/cli/index.js.map +1 -1
  54. package/dist/cli/src/asset-feeds.d.ts +42 -0
  55. package/dist/cli/src/asset-feeds.d.ts.map +1 -0
  56. package/dist/cli/src/commands/manage.d.ts.map +1 -1
  57. package/dist/cli/src/commands/project.d.ts.map +1 -1
  58. package/dist/cli/src/commands/source.d.ts +6 -4
  59. package/dist/cli/src/commands/source.d.ts.map +1 -1
  60. package/dist/cli/src/ensure-sources.d.ts +25 -0
  61. package/dist/cli/src/ensure-sources.d.ts.map +1 -0
  62. package/dist/connectors/config.js +4 -4
  63. package/dist/connectors/index.js +5 -5
  64. package/dist/core/index.js +3 -3
  65. package/dist/core/runtime-assets.js +2 -2
  66. package/dist/core/src/index.d.ts +1 -1
  67. package/dist/core/src/index.d.ts.map +1 -1
  68. package/dist/core/src/workspace-config.d.ts +27 -0
  69. package/dist/core/src/workspace-config.d.ts.map +1 -1
  70. package/dist/core/src/workspace-yaml-editor.d.ts +10 -1
  71. package/dist/core/src/workspace-yaml-editor.d.ts.map +1 -1
  72. package/dist/core/workspace-config.js +1 -1
  73. package/dist/ensure-sources-V26CZNJF.js +68 -0
  74. package/dist/ensure-sources-V26CZNJF.js.map +1 -0
  75. package/dist/runner/index.js +7 -7
  76. package/dist/sdk/asset-manager.js +5 -5
  77. package/dist/sdk/core.js +3 -3
  78. package/dist/sdk/index.js +7 -7
  79. package/dist/sdk/runner.js +7 -7
  80. package/dist/{setup-WZFCLQ2J.js → setup-R6VWIPLL.js} +5 -5
  81. package/dist/{setup-WZFCLQ2J.js.map → setup-R6VWIPLL.js.map} +1 -1
  82. package/dist/{store-client-BM3IBDPT.js → store-client-FLD3XUY7.js} +6 -6
  83. package/dist/{store-client-BM3IBDPT.js.map → store-client-FLD3XUY7.js.map} +1 -1
  84. package/dist/tui/index.js +7 -7
  85. package/dist/workspace-plugin/index.js +1 -1
  86. package/package.json +1 -1
  87. package/dist/chunk-4RUVG5GX.js.map +0 -1
  88. package/dist/chunk-DEZVZSBN.js.map +0 -1
  89. package/dist/chunk-GAZINYCS.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../asset-manager/src/index.ts"],"names":["parseYaml","stringifyYaml"],"mappings":";;;;;;;;;;;;;AA8RO,IAAM,eAAN,MAAmB;AAAA;AA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AACrC,IAAA,IAAI,UAAA,CAAW,IAAI,CAAA,EAAG,OAAO,IAAA;AAE7B,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,iBAAA,EAAkB,EAAG,IAAI,CAAA;AACjD,IAAA,IAAI,WAAW,IAAA,CAAK,UAAA,EAAY,MAAM,CAAC,GAAG,OAAO,UAAA;AAEjD,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"chunk-DEZVZSBN.js","sourcesContent":["/**\n * @skaile/asset-manager — programmatic AI asset management API.\n *\n * Manages project-local repositories, dependency resolution, deployment,\n * lock files, patches, and contribution workflows.\n *\n * Usage:\n * import { AssetManager } from \"@skaile/workspaces/asset-manager\"\n * const am = new AssetManager({ projectDir: \"/path/to/project\" })\n * await am.install()\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport {\n existsSync,\n lstatSync,\n readFileSync,\n readdirSync,\n rmSync,\n unlinkSync,\n writeFileSync,\n} from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { parse as parseYaml, stringify as stringifyYaml } from \"yaml\";\nimport type {\n AiComponent,\n AssetCollision,\n CatalogEntry,\n LockFile,\n RepositoryDeclaration,\n} from \"@skaile/workspaces/core\";\nimport type { DriverTarget } from \"@skaile/workspaces/core\";\nimport {\n deployedBase,\n deployedDir,\n isDeployed,\n parseAssetRef,\n resolveRuntimeAssets,\n resolveSkWorkspaceConfig,\n} from \"@skaile/workspaces/core\";\nimport { buildLockFile, readLock, verifyLock, writeLock } from \"@skaile/workspaces/core\";\nimport {\n checkRepoStatus,\n ensureRepo,\n getGlobalCacheDir,\n readLinks,\n resolveAll,\n resolveAsset,\n scanRepo,\n} from \"@skaile/workspaces/core\";\nimport {\n extractForPatch,\n generatePatch,\n savePatch,\n applyPatch as coreApplyPatch,\n} from \"@skaile/workspaces/core\";\nimport type { DeployOptions } from \"./installer.js\";\nimport { createScaffold, deployAll, removeAsset } from \"./installer.js\";\nimport type { HistoryEntry } from \"./history.js\";\nimport { appendHistory, clearHistory, getRecentHistory } from \"./history.js\";\nimport { commitChanges } from \"./contrib.js\";\n\n// Re-export sub-modules\nexport type { DeployOptions } from \"./installer.js\";\nexport type { Log } from \"./renderers.js\";\nexport type { HistoryEntry } from \"./history.js\";\nexport { createScaffold, deployAll, removeAsset } from \"./installer.js\";\nexport { renderAgentToFramework } from \"./renderers.js\";\nexport {\n appendHistory,\n clearHistory,\n getRecentHistory,\n loadHistory,\n} from \"./history.js\";\n// Contrib helpers (commitChanges et al.) are still used internally by the\n// patch-submit flow but are no longer part of the public API surface — the\n// `skaile repo contrib *` command tree was removed on 2026-05-12.\n\n// ── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Metadata about a repository declared in `skaile.yaml`.\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport interface RepoInfo {\n /** Repository name as declared in `skaile.yaml`. */\n name: string;\n /** How the repo is sourced: cloned from a URL, mounted from a local path, or symlinked via `skaile repo link`. */\n kind: \"local\" | \"remote\" | \"linked\";\n /** Remote URL (present when `kind === \"remote\"`). */\n url?: string;\n /** Filesystem path (present when `kind === \"local\"` or `kind === \"linked\"`). */\n path?: string;\n /** Git branch configured for this repository. */\n branch: string;\n /** Whether the repository has been cloned/resolved locally. */\n cloned: boolean;\n}\n\n/**\n * Live sync status for a repository.\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport interface RepoStatusInfo {\n /** Repository name as declared in `skaile.yaml`. */\n name: string;\n /** How the repo is sourced. */\n kind: \"local\" | \"remote\" | \"linked\";\n /** Number of commits the local clone is behind the remote. */\n behind: number;\n /** `true` when the local clone matches the remote HEAD. */\n upToDate: boolean;\n /** Error message when status check failed. */\n error?: string;\n}\n\n/**\n * Result of a full `skaile install` or `skaile add` run.\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport interface InstallResult {\n /** Asset refs (`kind:name`) successfully deployed in this run. */\n deployed: string[];\n /** Asset refs (`kind:name`) removed because they are no longer in the resolved set. */\n removed: string[];\n /** Asset refs that could not be resolved in any configured repository. */\n missing: string[];\n /** Whether `skaile.lock.yaml` was written or updated. */\n lockWritten: boolean;\n /** Assets that exist in multiple repos — the resolved entry shadows others. */\n collisions: AssetCollision[];\n /**\n * npm packages installed as a side effect of resolving runtime asset peer\n * deps (connectors / mounts declared in skaile.yaml). Empty when nothing\n * needed installing or when the runtime-deps step was skipped.\n */\n npmInstalled?: string[];\n /**\n * npm packages that the runtime-deps step tried but failed to install.\n * Non-fatal — listed for telemetry and CLI reporting.\n */\n npmFailed?: string[];\n}\n\n/**\n * An installed asset whose source repository is behind the remote.\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport interface OutdatedEntry {\n /** Asset kind (`skill`, `agent`, `prompt`, `flow`, `contract`). */\n kind: string;\n /** Asset name as registered in the catalog. */\n name: string;\n /** Repository that provides this asset. */\n repository: string;\n /** Version string recorded in the lock file at install time. */\n currentVersion: string;\n /** Number of commits the local repository is behind the remote. */\n behind: number;\n}\n\n/**\n * A node in the resolved dependency tree (returned by `AssetManager.tree()`).\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport interface DependencyNode {\n /** Asset ref (`kind:name`) or `\"project\"` for the root node. */\n ref: string;\n /** Transitive dependencies resolved by this node. */\n children: DependencyNode[];\n}\n\n/**\n * A missing dependency detected by `AssetManager.doctor()`.\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport interface DepIssue {\n /** Kind of the asset that has the unsatisfied requirement. */\n assetKind: string;\n /** Name of the asset that has the unsatisfied requirement. */\n assetName: string;\n /** Kind of the missing dependency. */\n depKind: string;\n /** Name of the missing dependency. */\n depName: string;\n /** `true` when the missing dependency exists in a configured repository but has not been installed. */\n inRepos: boolean;\n}\n\n/**\n * A single deployed asset shown in the workspace overview.\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport interface OverviewEntry {\n /** Asset kind (`skill`, `agent`, `prompt`, `flow`, `contract`). */\n kind: string;\n /** Asset name. */\n name: string;\n /** Domain the asset belongs to (from the lock file; `\"unknown\"` when unresolvable). */\n domain: string;\n /** Repository that provides this asset. */\n repository: string;\n /** Version string from the lock file. */\n version: string;\n /**\n * Sync status relative to the source repository.\n * - `\"synced\"` — local clone matches remote HEAD\n * - `\"outdated\"` — local clone is behind the remote\n * - `\"local\"` — sourced from a local path, no remote to compare\n * - `\"error\"` — status check failed\n * - `\"unknown\"` — repository not found or lock entry missing\n */\n syncStatus: string;\n}\n\n/**\n * Aggregated workspace overview returned by `AssetManager.overview()`.\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport interface OverviewResult {\n /** Entries grouped by domain, sorted alphabetically. Each group is sorted by kind then name. */\n byDomain: Map<string, OverviewEntry[]>;\n /** Total number of deployed assets. */\n total: number;\n /** Sync status for each configured repository. */\n repos: RepoStatusInfo[];\n}\n\n// ── AssetManager ─────────────────────────────────────────────────────────────\n\n/**\n * Options for constructing an {@link AssetManager}.\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport interface AssetManagerOptions {\n /** Absolute or relative path to the workspace root (must contain `skaile.yaml`). */\n projectDir: string;\n /**\n * Agent framework to target for asset deployment.\n * Determines which framework directories (``.claude/``, ``.omp/``, etc.) are used.\n * Defaults to `\"claude-code\"`.\n */\n driverTarget?: DriverTarget;\n /**\n * When `true`, assets are installed into the global Skaile cache rather than the\n * project workspace. Skips `skaile.yaml` dependency updates.\n */\n global?: boolean;\n}\n\n/**\n * Programmatic API for managing AI assets in a Skaile workspace.\n *\n * `AssetManager` wraps repository management, catalog search, asset installation,\n * lock-file tracking, patch workflows, and workspace diagnostics. The CLI delegates\n * all `skaile catalog`, `skaile repo`, `skaile install`, `skaile add`, and\n * `skaile init` commands to this class.\n *\n * @example\n * ```typescript\n * import { AssetManager } from \"@skaile/workspaces/asset-manager\";\n *\n * const am = new AssetManager({ projectDir: \"/my-project\" });\n *\n * // Install all dependencies declared in skaile.yaml\n * const result = await am.install();\n * console.log(`Deployed: ${result.deployed.join(\", \")}`);\n *\n * // Add a single skill (resolves transitive deps, updates skaile.yaml)\n * const deployed = am.add(\"skill:my-skill\");\n *\n * // Search the catalog\n * const skills = am.search(\"code review\", \"skill\");\n * ```\n *\n * @docLink packages/asset-manager/concepts#asset-manager\n */\nexport class AssetManager {\n /** Resolved absolute path to the workspace root. */\n readonly projectDir: string;\n /** Agent framework driver target used for all deploy operations. */\n readonly driverTarget: DriverTarget;\n /** Whether this instance operates in global-install mode. */\n readonly global: boolean;\n\n constructor(opts: AssetManagerOptions) {\n this.projectDir = resolve(opts.projectDir);\n this.driverTarget = opts.driverTarget ?? (\"claude-code\" as DriverTarget);\n this.global = opts.global ?? false;\n }\n\n private get reposDir(): string {\n return join(this.projectDir, \".skaile\", \"repos\");\n }\n\n private get lockPath(): string {\n return join(this.projectDir, \"skaile.lock.yaml\");\n }\n\n private get patchDir(): string {\n return join(this.projectDir, \".skaile\", \"patches\");\n }\n\n private get deployOpts(): DeployOptions {\n return { driverTarget: this.driverTarget, global: this.global, cwd: this.projectDir };\n }\n\n private loadConfig() {\n // Read raw YAML directly to get fields (dependencies, patches) that\n // resolveSkWorkspaceConfig doesn't pass through.\n const configPath = join(this.projectDir, \"skaile.yaml\");\n let raw: Record<string, any> = {};\n if (existsSync(configPath)) {\n try {\n raw = parseYaml(readFileSync(configPath, \"utf8\")) ?? {};\n } catch {}\n }\n\n const config = resolveSkWorkspaceConfig(this.projectDir);\n\n const repositories: Record<string, RepositoryDeclaration> = {};\n let dependencies: string[] = raw.dependencies ?? [];\n const patches: Record<string, string> = raw.patches ?? {};\n\n // ai_resources entries are converted into per-call RepositoryDeclaration\n // map for the install pipeline. New sources are registered with\n // @skaile/library directly via `skaile source add`.\n const aiResources = raw.ai_resources ?? config.ai_resources;\n if (aiResources?.length) {\n for (const entry of aiResources) {\n if (repositories[entry.name]) continue;\n const isUrl = /^(https?:|git@|git:)/.test(entry.path);\n repositories[entry.name] = isUrl\n ? { url: entry.path, branch: entry.branch }\n : { path: entry.path, branch: entry.branch };\n if (entry.dependencies) {\n dependencies = [...dependencies, ...entry.dependencies];\n }\n }\n }\n\n return { repositories, dependencies, patches, config };\n }\n\n // ── Install / resolve ──────────────────────────────────────────────────\n\n /**\n * Install all dependencies declared in `skaile.yaml`.\n *\n * Steps: clone/pull repositories → resolve transitive dependencies → reconcile\n * (remove stale assets) → deploy new assets → write `skaile.lock.yaml` → record history.\n *\n * @param opts - Optional installation options.\n * @param opts.locked - When `true`, restore the exact versions recorded in the existing\n * lock file instead of resolving from source. Throws if no lock file is found.\n * @returns {@link InstallResult} summarising what was deployed, what was missing, and any collisions.\n */\n async install(opts?: { locked?: boolean }): Promise<InstallResult> {\n const { repositories, dependencies, patches } = this.loadConfig();\n\n if (opts?.locked) {\n return this.installLocked(repositories, patches);\n }\n\n // 1. Ensure all repos are cloned/pulled\n for (const [name, decl] of Object.entries(repositories)) {\n try {\n ensureRepo(decl, name, this.reposDir, { projectDir: this.projectDir });\n } catch (err) {\n return {\n deployed: [],\n removed: [],\n missing: [`repo:${name}`],\n lockWritten: false,\n collisions: [],\n };\n }\n }\n\n // 2. Resolve all dependencies (transitive)\n const { resolved, missing, resolvedBy, collisions } = resolveAll(\n dependencies,\n repositories,\n this.reposDir,\n { projectDir: this.projectDir },\n );\n\n // 3. Reconcile: remove stale assets (in old lock but not in new resolved set)\n const oldLock = readLock(this.lockPath);\n const resolvedRefs = new Set(resolved.map((e) => `${e.kind}:${e.name}`));\n const removed: string[] = [];\n if (oldLock) {\n for (const ref of Object.keys(oldLock.assets)) {\n if (!resolvedRefs.has(ref)) {\n const [kind, name] = ref.split(\":\") as [string, string];\n removeAsset(kind, name, this.deployOpts);\n removed.push(ref);\n }\n }\n }\n\n // 4. Deploy new assets\n const deployed = deployAll(resolved, repositories, patches, this.deployOpts);\n\n // 5. Write lock file\n const lockData = buildLockFile(\n repositories,\n resolved,\n resolvedBy,\n this.reposDir,\n this.projectDir,\n );\n writeLock(this.lockPath, lockData);\n\n // 6. Record history\n for (const ref of deployed) {\n appendHistory(this.projectDir, {\n ref,\n action: \"add\",\n timestamp: new Date().toISOString(),\n context: this.global ? \"global\" : \"project\",\n });\n }\n for (const ref of removed) {\n appendHistory(this.projectDir, {\n ref,\n action: \"remove\",\n timestamp: new Date().toISOString(),\n context: this.global ? \"global\" : \"project\",\n });\n }\n\n // 7. Install npm peer deps for any mount/connector declared in skaile.yaml.\n // Runtime drivers/adapters need their npm deps available at the moment\n // a session starts — installing them at install-time avoids cryptic\n // \"Cannot find module 'pg'\" errors at first connect.\n const { npmInstalled, npmFailed } = await this.installRuntimeAssetDeps();\n\n return {\n deployed,\n removed,\n missing,\n lockWritten: true,\n collisions,\n npmInstalled,\n npmFailed,\n };\n }\n\n /**\n * Resolve runtime assets and install any missing npm peer deps.\n *\n * - Required deps: installed via `bun add --optional`. Failure is recorded\n * in `npmFailed` but does not throw — install() proceeds so users get a\n * useful error message rather than a hung command.\n * - Optional deps: not installed automatically (would force every consumer\n * to pull every connector's deps). Future: add a flag to opt in.\n */\n private async installRuntimeAssetDeps(): Promise<{\n npmInstalled: string[];\n npmFailed: string[];\n }> {\n const npmInstalled: string[] = [];\n const npmFailed: string[] = [];\n let runtimeAssets: Awaited<ReturnType<typeof resolveRuntimeAssets>> | null = null;\n try {\n runtimeAssets = await resolveRuntimeAssets(this.projectDir);\n } catch {\n // Non-fatal — projects with no skaile.yaml or unresolvable base-assets\n // simply have no runtime deps to install.\n return { npmInstalled, npmFailed };\n }\n\n const required = runtimeAssets.requiredNpmDeps.required;\n if (required.length === 0) return { npmInstalled, npmFailed };\n\n const { findMissingPackages, installNpmPackages } = await import(\n \"@skaile/workspaces/connectors\"\n );\n const missing = findMissingPackages(required, this.projectDir);\n if (missing.length === 0) return { npmInstalled, npmFailed };\n\n const result = await installNpmPackages(missing, this.projectDir);\n if (result.success) {\n npmInstalled.push(...missing);\n } else {\n npmFailed.push(...missing);\n }\n return { npmInstalled, npmFailed };\n }\n\n private installLocked(\n repositories: Record<string, RepositoryDeclaration>,\n patches: Record<string, string>,\n ): InstallResult {\n const lock = readLock(this.lockPath);\n if (!lock) {\n throw new Error(\"No lock file found. Run `skaile install` first.\");\n }\n\n // Ensure repos at pinned commits\n for (const [name, lockRepo] of Object.entries(lock.repositories)) {\n const decl = repositories[name] ?? {\n url: lockRepo.url,\n path: lockRepo.path,\n branch: lockRepo.branch,\n };\n ensureRepo(decl, name, this.reposDir, { projectDir: this.projectDir });\n }\n\n // Verify integrity\n const verification = verifyLock(lock, this.reposDir);\n if (!verification.ok) {\n const issues = [\n ...verification.drifted.map((r) => `drifted: ${r}`),\n ...verification.missing.map((r) => `missing: ${r}`),\n ];\n throw new Error(`Lock file verification failed:\\n ${issues.join(\"\\n \")}`);\n }\n\n // Rebuild catalog entries from lock + deploy\n const resolved: CatalogEntry[] = [];\n for (const [ref, entry] of Object.entries(lock.assets)) {\n const [kind, name] = ref.split(\":\") as [string, string];\n const repoDecl = repositories[entry.repository];\n let repoDir: string;\n if (repoDecl?.path) {\n repoDir = resolve(this.projectDir, repoDecl.path);\n } else {\n repoDir = join(this.reposDir, entry.repository);\n }\n resolved.push({\n name,\n kind: kind as any,\n description: \"\",\n source: join(repoDir, entry.source),\n repository: entry.repository,\n version: entry.version,\n requires: [],\n dependencies: [],\n });\n }\n\n const deployed = deployAll(resolved, repositories, patches, this.deployOpts);\n return { deployed, removed: [], missing: [], lockWritten: false, collisions: [] };\n }\n\n /**\n * Add a single asset (and its transitive dependencies) to the workspace.\n *\n * Resolves `ref`, deploys the asset and all requirements, then records the ref\n * in `skaile.yaml` `dependencies` so subsequent `skaile install` runs re-deploy it.\n *\n * @param ref - Asset ref in `kind:name` or `repo/kind:name` form (e.g. `skill:my-skill`).\n * @returns Array of asset refs that were deployed in this call.\n * @throws When the asset cannot be found in any configured repository.\n */\n add(ref: string): string[] {\n const { repositories, patches } = this.loadConfig();\n const parsed = parseAssetRef(ref);\n\n // Ensure repos\n for (const [name, decl] of Object.entries(repositories)) {\n try {\n ensureRepo(decl, name, this.reposDir, { projectDir: this.projectDir });\n } catch {}\n }\n\n const entry = resolveAsset(parsed, repositories, this.reposDir);\n if (!entry) throw new Error(`Asset not found: ${ref}`);\n\n // Resolve with transitive deps\n const { resolved, missing } = resolveAll([ref], repositories, this.reposDir);\n const deployed = deployAll(resolved, repositories, patches, this.deployOpts);\n\n // Add to skaile.yaml dependencies\n const depRef = `${parsed.kind}:${parsed.name}`;\n this.addDependencyToConfig(depRef);\n\n for (const d of deployed) {\n appendHistory(this.projectDir, {\n ref: d,\n action: \"add\",\n timestamp: new Date().toISOString(),\n context: this.global ? \"global\" : \"project\",\n });\n }\n\n return deployed;\n }\n\n /**\n * Remove a deployed asset and unregister it from `skaile.yaml`.\n *\n * @param ref - Asset ref in `kind:name` form (e.g. `skill:my-skill`).\n * @returns `true` if the asset was found and removed, `false` if it was not deployed.\n */\n remove(ref: string): boolean {\n const parsed = parseAssetRef(ref);\n const ok = removeAsset(parsed.kind, parsed.name, this.deployOpts);\n if (ok) {\n const depRef = `${parsed.kind}:${parsed.name}`;\n this.removeDependencyFromConfig(depRef);\n\n appendHistory(this.projectDir, {\n ref: depRef,\n action: \"remove\",\n timestamp: new Date().toISOString(),\n context: this.global ? \"global\" : \"project\",\n });\n }\n return ok;\n }\n\n // ── Query ──────────────────────────────────────────────────────────────\n\n /**\n * Search the catalog across all configured repositories.\n *\n * @param query - Substring to match against entry names and descriptions (case-insensitive).\n * Omit to return all entries.\n * @param kind - Filter by asset kind (`\"skill\"`, `\"agent\"`, `\"prompt\"`, `\"flow\"`, `\"contract\"`).\n * Omit to return all kinds.\n * @returns Array of matching {@link CatalogEntry} objects from all accessible repositories.\n */\n search(query?: string, kind?: string): CatalogEntry[] {\n const { repositories } = this.loadConfig();\n let all: CatalogEntry[] = [];\n\n for (const [name, decl] of Object.entries(repositories)) {\n const repoDir = this.resolveRepoDir(decl, name);\n if (!repoDir) continue;\n all = [...all, ...scanRepo(repoDir, name)];\n }\n\n if (kind) all = all.filter((e) => e.kind === kind);\n if (query) {\n const q = query.toLowerCase();\n all = all.filter(\n (e) => e.name.toLowerCase().includes(q) || e.description.toLowerCase().includes(q),\n );\n }\n return all;\n }\n\n /**\n * Look up a single asset's full catalog entry.\n *\n * @param ref - Asset ref in `kind:name` or `repo/kind:name` form.\n * @returns The matching {@link CatalogEntry}, or `null` when not found.\n */\n info(ref: string): CatalogEntry | null {\n const { repositories } = this.loadConfig();\n const parsed = parseAssetRef(ref);\n\n for (const [name, decl] of Object.entries(repositories)) {\n const repoDir = this.resolveRepoDir(decl, name);\n if (!repoDir) continue;\n if (parsed.repository && parsed.repository !== name) continue;\n const entries = scanRepo(repoDir, name);\n const match = entries.find((e) => e.kind === parsed.kind && e.name === parsed.name);\n if (match) return match;\n }\n return null;\n }\n\n /**\n * List all assets currently deployed in the workspace (or global cache).\n *\n * Scans the framework deploy directories rather than the lock file, so it\n * also returns assets that were installed manually or outside of `skaile install`.\n *\n * @param kind - Filter by asset kind. Omit to return all kinds.\n * @returns Shallow {@link CatalogEntry} objects (description and version will be empty).\n */\n listDeployed(kind?: string): CatalogEntry[] {\n // Bundles are dependency groups, not deployed as files — exclude from scan\n const kinds = (\n kind ? [kind] : [\"skill\", \"agent\", \"prompt\", \"flow\", \"contract\"]\n ) as AiComponent[];\n const result: CatalogEntry[] = [];\n const seen = new Set<string>();\n for (const k of kinds) {\n try {\n const base = deployedBase(k, this.driverTarget, this.global, this.projectDir);\n if (!existsSync(base)) continue;\n for (const item of readdirSync(base, { withFileTypes: true })) {\n // Directories and symlinks use the directory name directly (skills, omp agents, etc.)\n // Files use the stem without extension (claude-code agents → .md, codex agents → .toml,\n // prompts → .prompt.md, flows → .flow.yaml/.flow.json)\n let name: string;\n if (item.isDirectory() || item.isSymbolicLink()) {\n name = item.name;\n } else if (item.isFile()) {\n name = item.name\n .replace(/\\.prompt\\.md$/, \"\")\n .replace(/\\.flow\\.(yaml|json)$/, \"\")\n .replace(/\\.bundle\\.yaml$/, \"\")\n .replace(/\\.(md|toml|yaml|json)$/, \"\");\n } else {\n continue;\n }\n const key = `${k}:${name}`;\n if (seen.has(key)) continue;\n seen.add(key);\n result.push({\n name,\n kind: k as any,\n description: \"\",\n source: join(base, item.name),\n version: \"\",\n requires: [],\n dependencies: [],\n });\n }\n } catch {}\n }\n return result;\n }\n\n /**\n * Build an aggregated workspace overview with domain grouping and sync status.\n *\n * Combines deployed assets, lock file metadata, and live repository status\n * into a single structured result. Used by `skaile status`.\n *\n * @returns {@link OverviewResult} with entries grouped by domain and per-repo sync status.\n */\n overview(): OverviewResult {\n const { repositories } = this.loadConfig();\n const lock = readLock(this.lockPath);\n const deployed = this.listDeployed();\n\n // Get repo sync status\n const repoStatuses = new Map<string, RepoStatusInfo>();\n for (const [name, decl] of Object.entries(repositories)) {\n const status = checkRepoStatus(decl, name, this.reposDir);\n repoStatuses.set(name, {\n name,\n kind: status.kind,\n behind: status.behind,\n upToDate: status.upToDate,\n error: status.error,\n });\n }\n\n // Build entries with domain + sync info\n const entries: OverviewEntry[] = [];\n for (const d of deployed) {\n // Try to find full info from lock or repos\n const lockKey = `${d.kind}:${d.name}`;\n const lockEntry = lock?.assets[lockKey];\n\n const domain = lockEntry?.domain ?? \"unknown\";\n const repository = lockEntry?.repository ?? \"\";\n const version = lockEntry?.version ?? \"\";\n let syncStatus = \"unknown\";\n\n // Determine sync status\n if (repository) {\n const repoStatus = repoStatuses.get(repository);\n if (!repoStatus) syncStatus = \"unknown\";\n else if (repoStatus.kind === \"local\") syncStatus = \"local\";\n else if (repoStatus.error) syncStatus = \"error\";\n else if (repoStatus.upToDate) syncStatus = \"synced\";\n else syncStatus = \"outdated\";\n }\n\n entries.push({ kind: d.kind, name: d.name, domain, repository, version, syncStatus });\n }\n\n // Group by domain\n const byDomain = new Map<string, OverviewEntry[]>();\n for (const e of entries) {\n if (!byDomain.has(e.domain)) byDomain.set(e.domain, []);\n byDomain.get(e.domain)!.push(e);\n }\n\n // Sort domains alphabetically, entries within domain by kind then name\n const sorted = new Map<string, OverviewEntry[]>();\n for (const key of [...byDomain.keys()].sort()) {\n sorted.set(\n key,\n byDomain\n .get(key)!\n .sort((a, b) =>\n a.kind !== b.kind ? a.kind.localeCompare(b.kind) : a.name.localeCompare(b.name),\n ),\n );\n }\n\n return {\n byDomain: sorted,\n total: entries.length,\n repos: [...repoStatuses.values()],\n };\n }\n\n /**\n * Build the resolved dependency tree from the lock file.\n *\n * @returns Root {@link DependencyNode} with `ref === \"project\"` whose children\n * are the directly-declared dependencies, each with their own transitive subtrees.\n * Returns a single node with `ref === \"(no lock file)\"` when no lock exists.\n */\n tree(): DependencyNode {\n const lock = readLock(this.lockPath);\n if (!lock) return { ref: \"(no lock file)\", children: [] };\n\n const byParent = new Map<string, string[]>();\n for (const [ref, entry] of Object.entries(lock.assets)) {\n const parent = entry.resolved_by;\n if (!byParent.has(parent)) byParent.set(parent, []);\n byParent.get(parent)!.push(ref);\n }\n\n function buildNode(ref: string): DependencyNode {\n const children = (byParent.get(ref) ?? []).map(buildNode);\n return { ref, children };\n }\n\n const directChildren = byParent.get(\"direct\") ?? [];\n return {\n ref: \"project\",\n children: directChildren.map(buildNode),\n };\n }\n\n /**\n * Explain why an asset is installed by tracing its dependency chain in the lock file.\n *\n * @param ref - Asset ref in `kind:name` form.\n * @returns Chain of refs from the asset back to `\"direct (skaile.yaml)\"`, or `[]` when\n * the asset is not in the lock file.\n */\n why(ref: string): string[] {\n const lock = readLock(this.lockPath);\n if (!lock) return [];\n if (!lock.assets[ref]) return []; // not in lock file\n\n const chain: string[] = [];\n let current = ref;\n const seen = new Set<string>();\n while (current && current !== \"direct\") {\n if (seen.has(current)) break;\n seen.add(current);\n chain.push(current);\n const entry = lock.assets[current];\n if (!entry) break;\n current = entry.resolved_by;\n }\n if (current === \"direct\") chain.push(\"direct (skaile.yaml)\");\n return chain;\n }\n\n /**\n * List installed assets whose source repository is behind the remote.\n *\n * Only remote repositories (not local paths) are checked for staleness.\n *\n * @returns Array of {@link OutdatedEntry} objects, one per asset in a repository\n * that has commits not yet pulled locally.\n */\n outdated(): OutdatedEntry[] {\n const { repositories } = this.loadConfig();\n const lock = readLock(this.lockPath);\n if (!lock) return [];\n\n const result: OutdatedEntry[] = [];\n for (const [name, lockRepo] of Object.entries(lock.repositories)) {\n if (!lockRepo.commit || lockRepo.path) continue;\n const decl = repositories[name];\n if (!decl) continue;\n const status = checkRepoStatus(decl, name, this.reposDir);\n if (status.behind > 0) {\n for (const [ref, entry] of Object.entries(lock.assets)) {\n if (entry.repository === name) {\n const [kind, assetName] = ref.split(\":\") as [string, string];\n result.push({\n kind,\n name: assetName,\n repository: name,\n currentVersion: entry.version,\n behind: status.behind,\n });\n }\n }\n }\n }\n return result;\n }\n\n /**\n * Produce a unified diff between the deployed asset and its catalog source.\n *\n * Useful for detecting manual edits to deployed files or verifying that a patch\n * was applied correctly.\n *\n * @param ref - Asset ref in `kind:name` form.\n * @returns Unified diff string, or `null` when there are no differences or the\n * asset is not deployed/resolvable.\n */\n diff(ref: string): string | null {\n const parsed = parseAssetRef(ref);\n const entry = this.info(ref);\n if (!entry) return null;\n\n const deployedPath = join(\n deployedBase(parsed.kind as AiComponent, this.driverTarget, this.global, this.projectDir),\n parsed.name,\n );\n if (!existsSync(deployedPath) || !existsSync(entry.source)) return null;\n\n const r = spawnSync(\"diff\", [\"-ruN\", entry.source, deployedPath], { encoding: \"utf8\" });\n return r.status === 1 ? r.stdout : null;\n }\n\n // ── Lock ───────────────────────────────────────────────────────────────\n\n /**\n * Resolve all declared dependencies and write (or overwrite) `skaile.lock.yaml`.\n *\n * Performs repository sync and full dependency resolution without deploying assets.\n * Use this to regenerate the lock file after manually editing `skaile.yaml`.\n *\n * @returns The written {@link LockFile} data.\n */\n lock(): LockFile {\n const { repositories, dependencies } = this.loadConfig();\n\n for (const [name, decl] of Object.entries(repositories)) {\n try {\n ensureRepo(decl, name, this.reposDir, { projectDir: this.projectDir });\n } catch {}\n }\n\n const { resolved, resolvedBy } = resolveAll(dependencies, repositories, this.reposDir);\n const lockData = buildLockFile(\n repositories,\n resolved,\n resolvedBy,\n this.reposDir,\n this.projectDir,\n );\n writeLock(this.lockPath, lockData);\n return lockData;\n }\n\n // ── Patch workflow ─────────────────────────────────────────────────────\n\n /**\n * Extract a deployed asset into a patch working directory for editing.\n *\n * Copies the deployed asset to `.skaile/patches/<kind>-<name>/` so changes\n * can be made there and then committed as a patch file via `patchCommit`.\n *\n * @param ref - Asset ref in `kind:name` form.\n * @returns Absolute path to the patch working directory.\n * @throws When the asset cannot be found in the catalog.\n */\n patch(ref: string): string {\n const entry = this.info(ref);\n if (!entry) throw new Error(`Asset not found: ${ref}`);\n return extractForPatch(entry, this.patchDir);\n }\n\n /**\n * Generate a `.patch` file from changes made in the patch working directory.\n *\n * Diffs the patch working directory against the original catalog source and\n * writes the result to `.skaile/patches/<kind>-<name>.patch`.\n *\n * @param ref - Asset ref in `kind:name` form.\n * @returns Absolute path to the generated `.patch` file.\n * @throws When the patch working directory does not exist or no differences are found.\n */\n patchCommit(ref: string): string {\n const parsed = parseAssetRef(ref);\n const entry = this.info(ref);\n if (!entry) throw new Error(`Asset not found: ${ref}`);\n\n const patchedDir = join(this.patchDir, `${parsed.kind}-${parsed.name}`);\n if (!existsSync(patchedDir)) {\n throw new Error(`No patch working dir found. Run \\`skaile patch ${ref}\\` first.`);\n }\n\n const originalDir = dirname(entry.source);\n const content = generatePatch(originalDir, patchedDir);\n if (!content) throw new Error(\"No differences found.\");\n\n const patchFile = join(this.patchDir, `${parsed.kind}-${parsed.name}.patch`);\n savePatch(patchFile, content);\n return patchFile;\n }\n\n /**\n * Apply the committed patch file to the repository clone and open a contribution branch.\n *\n * Applies `.skaile/patches/<kind>-<name>.patch` to the repository clone, creates a\n * `patch/<kind>-<name>` branch, and stages a commit — ready to push via `contribPush`.\n *\n * @param ref - Asset ref in `kind:name` form.\n * @throws When the asset is not found, has no repository, or the patch file is missing.\n */\n patchSubmit(ref: string): void {\n const parsed = parseAssetRef(ref);\n const entry = this.info(ref);\n if (!entry?.repository) throw new Error(`Asset not found or no repository: ${ref}`);\n\n const { repositories } = this.loadConfig();\n const decl = repositories[entry.repository];\n if (!decl?.url) throw new Error(\"Can only submit patches for remote repositories.\");\n\n const repoDir = join(this.reposDir, entry.repository);\n const branchName = `patch/${parsed.kind}-${parsed.name}`;\n\n // Apply patch to repo clone\n const patchFile = join(this.patchDir, `${parsed.kind}-${parsed.name}.patch`);\n if (!existsSync(patchFile)) throw new Error(\"No patch file. Run `skaile patch-commit` first.\");\n\n coreApplyPatch(repoDir, patchFile);\n commitChanges(repoDir, `fix: improve ${parsed.kind} ${parsed.name}`, branchName);\n }\n\n /**\n * Delete the patch working directory and patch file for an asset.\n *\n * @param ref - Asset ref in `kind:name` form.\n */\n patchRemove(ref: string): void {\n const parsed = parseAssetRef(ref);\n const patchFile = join(this.patchDir, `${parsed.kind}-${parsed.name}.patch`);\n const patchedDir = join(this.patchDir, `${parsed.kind}-${parsed.name}`);\n try {\n rmSync(patchFile);\n } catch {}\n try {\n rmSync(patchedDir, { recursive: true });\n } catch {}\n }\n\n // ── Doctor ─────────────────────────────────────────────────────────────\n\n /**\n * Scan deployed assets for unsatisfied transitive dependencies.\n *\n * For each deployed asset, checks that all entries in its `requires` list are\n * also deployed. Returns a list of issues with a flag indicating whether the\n * missing dependency can be resolved from a configured repository.\n *\n * @returns Array of {@link DepIssue} objects. An empty array means the workspace is healthy.\n */\n doctor(): DepIssue[] {\n const { repositories } = this.loadConfig();\n const deployed = this.listDeployed();\n const issues: DepIssue[] = [];\n\n for (const entry of deployed) {\n const full = this.info(`${entry.kind}:${entry.name}`);\n if (!full) continue;\n for (const req of full.requires) {\n if (\n !isDeployed(\n req.kind as AiComponent,\n req.name,\n this.driverTarget,\n this.global,\n this.projectDir,\n )\n ) {\n const inRepos =\n resolveAsset({ kind: req.kind, name: req.name }, repositories, this.reposDir) !== null;\n issues.push({\n assetKind: entry.kind,\n assetName: entry.name,\n depKind: req.kind,\n depName: req.name,\n inRepos,\n });\n }\n }\n }\n return issues;\n }\n\n // ── Scaffold ───────────────────────────────────────────────────────────\n\n /**\n * Create a minimal asset scaffold directory (delegates to {@link createScaffold}).\n *\n * @param name - Asset name (also used as the directory name).\n * @param kind - Asset kind: `skill` | `agent` | `bundle` | `flow` | `prompt` | `contract`.\n * @param destDir - Parent directory to create the asset in.\n * @returns `{ ok: true, path }` on success, `{ ok: false, path: errorMessage }` if the\n * directory already exists.\n */\n create(name: string, kind: string, destDir: string): { ok: boolean; path: string } {\n return createScaffold(name, kind, destDir);\n }\n\n // ── Contrib (REMOVED 2026-05-12) ───────────────────────────────────────\n //\n // The `contribChanges / contribDiff / contribCommit / contribPush /\n // contribCompare` methods were retired alongside `skaile repo contrib *`.\n // The refinement push-back workflow is being re-introduced in Phase 4 as\n // `skaile publish` + `skaile preset push` against the Library Source model.\n\n // ── History ────────────────────────────────────────────────────────────\n\n /**\n * Return recent asset action history entries, newest first.\n *\n * @param limit - Maximum number of entries to return. Defaults to `20`.\n * @returns Array of {@link HistoryEntry} objects in reverse-chronological order.\n */\n history(limit = 20): HistoryEntry[] {\n return getRecentHistory(this.projectDir, limit);\n }\n\n /**\n * Erase all asset action history for this workspace.\n */\n clearHistory(): void {\n clearHistory(this.projectDir);\n }\n\n // ── Clean ───────────────────────────────────────────────────────────────\n\n /**\n * Remove deployed assets tracked by the lock file and report unmanaged ones.\n *\n * With `opts.all`, also deletes `.skaile/history.yaml`, `.skaile/patches/`,\n * `.skaile/repos/`, and `skaile.lock.yaml` — effectively resetting the workspace\n * to a pre-install state.\n *\n * @param opts - Optional cleanup options.\n * @param opts.all - When `true`, remove all Skaile-managed state in addition to deployed assets.\n * @returns Object with `removed` (successfully cleaned refs), `skipped` (with reasons),\n * and `unmanaged` (deployed assets not in the lock file).\n */\n clean(opts?: { all?: boolean }): {\n removed: string[];\n skipped: Array<{ ref: string; reason: string }>;\n unmanaged: string[];\n } {\n const lock = readLock(this.lockPath);\n const removed: string[] = [];\n const skipped: Array<{ ref: string; reason: string }> = [];\n\n if (lock) {\n for (const ref of Object.keys(lock.assets)) {\n const [kind, name] = ref.split(\":\") as [string, string];\n const dest = deployedDir(\n kind as AiComponent,\n name,\n this.driverTarget,\n this.global,\n this.projectDir,\n );\n\n try {\n const stat = lstatSync(dest);\n if (stat.isSymbolicLink()) unlinkSync(dest);\n else rmSync(dest, { recursive: true, force: true });\n removed.push(ref);\n } catch {\n // Already gone — count as removed\n removed.push(ref);\n }\n }\n }\n\n // Collect unmanaged assets for reporting\n const lockRefs = lock ? new Set(Object.keys(lock.assets)) : new Set<string>();\n const unmanaged: string[] = [];\n const allDeployed = this.listDeployed();\n for (const d of allDeployed) {\n const ref = `${d.kind}:${d.name}`;\n if (!lockRefs.has(ref)) {\n unmanaged.push(ref);\n }\n }\n\n if (opts?.all) {\n // Delete history file\n const historyFile = join(this.projectDir, \".skaile\", \"history.yaml\");\n try {\n unlinkSync(historyFile);\n } catch {}\n\n // Remove patches dir\n try {\n rmSync(this.patchDir, { recursive: true, force: true });\n } catch {}\n\n // Remove repos dir\n try {\n rmSync(this.reposDir, { recursive: true, force: true });\n } catch {}\n\n // Remove lock file\n try {\n unlinkSync(this.lockPath);\n } catch {}\n }\n\n return { removed, skipped, unmanaged };\n }\n\n // ── Helpers ────────────────────────────────────────────────────────────\n\n /** Add a dependency ref to skaile.yaml if not already present. */\n private addDependencyToConfig(ref: string): void {\n if (this.global) return; // global installs don't modify skaile.yaml\n const configPath = join(this.projectDir, \"skaile.yaml\");\n if (!existsSync(configPath)) return;\n const raw = parseYaml(readFileSync(configPath, \"utf8\")) ?? {};\n if (!raw.dependencies) raw.dependencies = [];\n if (!raw.dependencies.includes(ref)) {\n raw.dependencies.push(ref);\n writeFileSync(configPath, stringifyYaml(raw, { lineWidth: 120 }));\n }\n }\n\n /** Remove a dependency ref from skaile.yaml. */\n private removeDependencyFromConfig(ref: string): void {\n if (this.global) return;\n const configPath = join(this.projectDir, \"skaile.yaml\");\n if (!existsSync(configPath)) return;\n const raw = parseYaml(readFileSync(configPath, \"utf8\")) ?? {};\n if (!raw.dependencies) return;\n const idx = raw.dependencies.indexOf(ref);\n if (idx !== -1) {\n raw.dependencies.splice(idx, 1);\n writeFileSync(configPath, stringifyYaml(raw, { lineWidth: 120 }));\n }\n }\n\n private resolveRepoDir(decl: RepositoryDeclaration, name: string): string | null {\n // Check links first\n const links = readLinks(this.projectDir);\n if (links[name]) {\n return existsSync(links[name]) ? links[name] : null;\n }\n\n if (decl.path) {\n const resolved = resolve(this.projectDir, decl.path);\n return existsSync(resolved) ? resolved : null;\n }\n\n // Check project-local symlink, then global cache\n const dest = join(this.reposDir, name);\n if (existsSync(dest)) return dest;\n\n const globalDest = join(getGlobalCacheDir(), name);\n if (existsSync(join(globalDest, \".git\"))) return globalDest;\n\n return null;\n }\n}\n\n// ── Agent install (renders GitAgent packages to framework-native files) ──\n\nexport { installAgent } from \"./install-agent.js\";\n\n// ── Renderers ─────────────────────────────────────────────────────────────\n\nexport {\n AGENT_RENDERERS,\n claudeCodeRenderer,\n codexRenderer,\n driverTargetSupportsAgents,\n ompRenderer,\n} from \"./renderers.js\";\nexport type { AgentRenderer, AgentRenderInput, AgentRenderResult } from \"./renderers.js\";\n\n// ── Fragments ─────────────────────────────────────────────────────────────\n\nexport type {\n AbilityRef,\n ConnectorRef,\n ContractRef,\n FragmentContext,\n FragmentId,\n} from \"./fragments.js\";\nexport { BUILT_IN_FRAGMENTS, resolveFragments, loadPromptExtensions } from \"./fragments.js\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../core/src/repo-manager.ts","../core/src/workspace-config.ts"],"names":["resolve","join","existsSync","mkdirSync","writeFileSync","stringify","homedir","parsePath","readFileSync","parse"],"mappings":";;;;;;;;AAmCO,SAAS,iBAAA,GAA4B;AAC1C,EAAA,OAAO,QAAQ,GAAA,CAAI,gBAAA,IAAoB,KAAK,OAAA,EAAQ,EAAG,WAAW,OAAO,CAAA;AAC3E;AAWA,IAAM,UAAU,EAAE,GAAG,OAAA,CAAQ,GAAA,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AA,CAAe,MAAM,CAAA;AACtD,IAAA,MAAM,WAAA,GAAc,gBAAgB,UAAU,CAAA;AAC9C,IAAA,IAAI,CAAC,aAAa,OAAO,MAAA;AACzB,IAAA,OAAOC,IAAAA,CAAK,aAAa,OAAO,CAAA;AAAA,EAClC;AAGA,EAAA,IAAI,UAAA,CAAW,UAAA,CAAW,QAAQ,CAAA,EAAG;AACnC,IAAA,MAAM,GAAA,GAAM,cAAc,UAAU,CAAA;AACpC,IAAA,MAAM,YAAA,GAAe,MAAA,CAAO,YAAA,IAAgB,EAAC;AAC7C,IAAA,MAAM,WAAW,iBAAA,EAAkB;AACnC,IAAA,MAAM,QAAQ,YAAA,CAAa,GAAA,EAAK,cAAc,QAAA,EAAU,EAAE,YAAY,CAAA;AACtE,IAAA,IAAI,CAAC,OAAO,OAAO,MAAA;AACnB,IAAA,OAAO,OAAA,CAAQ,MAAM,MAAM,CAAA;AAAA,EAC7B;AAGA,EAAA,OAAOD,OAAAA,CAAQ,YAAY,UAAU,CAAA;AACvC","file":"chunk-GAZINYCS.js","sourcesContent":["/**\n * Repository operations — clone, pull, scan, resolve, link.\n *\n * Remote repos are cloned to a shared global cache (~/.skaile/repos/<name>/).\n * Projects reference the cache via symlinks at .skaile/repos/<name>/.\n * Local repos (path:) are used directly. Linked repos override remote URLs.\n *\n * Supports partial clone + sparse checkout for large repos.\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport {\n existsSync,\n mkdirSync,\n readFileSync,\n rmSync,\n symlinkSync,\n lstatSync,\n writeFileSync,\n} from \"node:fs\";\nimport { resolve, join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { parse, stringify } from \"yaml\";\nimport type { AssetRef, CatalogEntry } from \"./models.js\";\nimport { parseAssetRef } from \"./models.js\";\nimport type { RepositoryDeclaration } from \"./workspace-config.js\";\nimport { scanDirectory } from \"./manifest.js\";\n\n// ── Global cache ─────────────────────────────────────────────────────────────\n\n/**\n * Return the global shared repo cache directory (`~/.skaile/repos` by default).\n * Override with the `SKAILE_CACHE_DIR` environment variable.\n * @docLink packages/core/api-reference#get-global-cache-dir\n */\nexport function getGlobalCacheDir(): string {\n return process.env.SKAILE_CACHE_DIR ?? join(homedir(), \".skaile\", \"repos\");\n}\n\n// ── Git operations ───────────────────────────────────────────────────────────\n\n/**\n * Shared env for all git subprocess spawns.\n * GIT_TERMINAL_PROMPT=0 prevents git from opening /dev/tty to ask for\n * credentials when running inside a CLI spinner (which holds the terminal in\n * raw mode). Without this, git bypasses stdio: \"pipe\" and the process hangs\n * indefinitely waiting for input that can never arrive.\n */\nconst GIT_ENV = { ...process.env, GIT_TERMINAL_PROMPT: \"0\" };\n\n/**\n * Clone a remote git repository using partial clone (treeless) with sparse checkout.\n * Falls back to a regular shallow clone if the server does not support partial clones.\n *\n * @param url - Remote git URL\n * @param branch - Branch to clone\n * @param dest - Local destination directory\n * @returns `true` on success, `false` on failure\n * @docLink packages/core/api-reference#clone-repo\n */\nexport function cloneRepo(url: string, branch: string, dest: string): boolean {\n mkdirSync(dest, { recursive: true });\n // Try partial clone first (requires git 2.25+ and server support)\n const r = spawnSync(\n \"git\",\n [\"clone\", \"--depth=1\", \"--filter=blob:none\", \"--sparse\", \"--branch\", branch, url, dest],\n { stdio: \"pipe\", env: GIT_ENV },\n );\n if (r.status === 0) {\n // Enable cone mode for sparse checkout\n spawnSync(\"git\", [\"-C\", dest, \"sparse-checkout\", \"init\", \"--cone\"], {\n stdio: \"pipe\",\n env: GIT_ENV,\n });\n // Check out everything initially (for discovery)\n spawnSync(\"git\", [\"-C\", dest, \"sparse-checkout\", \"disable\"], { stdio: \"pipe\", env: GIT_ENV });\n return true;\n }\n // Fallback: regular shallow clone\n const fallback = spawnSync(\"git\", [\"clone\", \"--depth=1\", \"--branch\", branch, url, dest], {\n stdio: \"pipe\",\n env: GIT_ENV,\n });\n return fallback.status === 0;\n}\n\n/**\n * Pull the latest commits for a cloned repository.\n * On shallow clone divergence, falls back to `git fetch --depth=1` + `git reset --hard`.\n *\n * @param dest - Local repo directory\n * @param branch - Branch to pull\n * @returns `true` on success, `false` on failure\n * @docLink packages/core/api-reference#pull-repo\n */\nexport function pullRepo(dest: string, branch: string): boolean {\n const r = spawnSync(\"git\", [\"-C\", dest, \"pull\", \"--depth=1\", \"--ff-only\"], {\n stdio: \"pipe\",\n env: GIT_ENV,\n });\n if (r.status === 0) return true;\n // Shallow clones can diverge — force-sync via fetch + reset\n const fetch = spawnSync(\"git\", [\"-C\", dest, \"fetch\", \"--depth=1\", \"origin\", branch], {\n stdio: \"pipe\",\n env: GIT_ENV,\n });\n if (fetch.status !== 0) return false;\n const reset = spawnSync(\"git\", [\"-C\", dest, \"reset\", \"--hard\", `origin/${branch}`], {\n stdio: \"pipe\",\n env: GIT_ENV,\n });\n return reset.status === 0;\n}\n\n/**\n * Return the current HEAD commit SHA for a local repository.\n *\n * @param repoDir - Absolute path to the cloned repository\n * @returns Full commit SHA string, or `null` on failure\n * @docLink packages/core/api-reference#get-repo-commit\n */\nexport function getRepoCommit(repoDir: string): string | null {\n const r = spawnSync(\"git\", [\"-C\", repoDir, \"rev-parse\", \"HEAD\"], {\n encoding: \"utf8\",\n stdio: \"pipe\",\n });\n return r.status === 0 ? r.stdout.trim() : null;\n}\n\n/**\n * Check out a specific tag, branch, or commit SHA in a local repository.\n * Fetches the ref from `origin` first, then attempts `FETCH_HEAD` checkout.\n *\n * @param repoDir - Absolute path to the cloned repository\n * @param pin - Tag, branch name, or commit SHA\n * @returns `true` on success, `false` on failure\n * @docLink packages/core/api-reference#checkout-pin\n */\nexport function checkoutPin(repoDir: string, pin: string): boolean {\n // Fetch the ref first (works for tags, branches, and commits)\n spawnSync(\"git\", [\"-C\", repoDir, \"fetch\", \"--depth=1\", \"origin\", pin], {\n stdio: \"pipe\",\n env: GIT_ENV,\n });\n const r = spawnSync(\"git\", [\"-C\", repoDir, \"checkout\", \"FETCH_HEAD\"], {\n stdio: \"pipe\",\n env: GIT_ENV,\n });\n if (r.status === 0) return true;\n // Fallback: try direct checkout (for branches already fetched)\n const r2 = spawnSync(\"git\", [\"-C\", repoDir, \"checkout\", pin], { stdio: \"pipe\", env: GIT_ENV });\n return r2.status === 0;\n}\n\n// ── Link management ──────────────────────────────────────────────────────────\n\n/**\n * Map of repo name → local filesystem path for development overrides.\n * Stored in `.skaile/links.yaml`; used to redirect a named repo to a local clone.\n * @docLink packages/core/api-reference#link-config\n */\nexport interface LinkConfig {\n [repoName: string]: string; // repo name → local path\n}\n\n/** Path to the project-local links file. */\nfunction linksFile(projectDir: string): string {\n return join(projectDir, \".skaile\", \"links.yaml\");\n}\n\n/**\n * Read the dev-link map from `.skaile/links.yaml` in the project directory.\n * Returns an empty object when no links file exists.\n *\n * @param projectDir - Absolute path to the project root\n * @returns `LinkConfig` map (may be empty)\n * @docLink packages/core/api-reference#read-links\n */\nexport function readLinks(projectDir: string): LinkConfig {\n const file = linksFile(projectDir);\n if (!existsSync(file)) return {};\n try {\n return (parse(readFileSync(file, \"utf8\")) as LinkConfig) ?? {};\n } catch {\n return {};\n }\n}\n\n/**\n * Persist the dev-link map to `.skaile/links.yaml` in the project directory.\n *\n * @param projectDir - Absolute path to the project root\n * @param links - Updated `LinkConfig` to write\n * @docLink packages/core/api-reference#write-links\n */\nexport function writeLinks(projectDir: string, links: LinkConfig): void {\n const dir = join(projectDir, \".skaile\");\n mkdirSync(dir, { recursive: true });\n writeFileSync(linksFile(projectDir), stringify(links));\n}\n\n/**\n * Register a local filesystem path as a dev override for a named repository.\n * The path is stored in `.skaile/links.yaml` and takes priority over the remote URL at runtime.\n *\n * @param projectDir - Absolute path to the project root\n * @param repoName - Name of the repository to override\n * @param localPath - Local path (absolute or relative to `projectDir`) to use instead\n * @throws When the resolved path does not exist\n * @docLink packages/core/api-reference#link-repo\n */\nexport function linkRepo(projectDir: string, repoName: string, localPath: string): void {\n const resolved = resolve(projectDir, localPath);\n if (!existsSync(resolved)) {\n throw new Error(`Path not found: ${localPath} (resolved: ${resolved})`);\n }\n const links = readLinks(projectDir);\n links[repoName] = resolved;\n writeLinks(projectDir, links);\n}\n\n/**\n * Remove the dev-link override for a named repository, reverting it to the remote URL.\n *\n * @param projectDir - Absolute path to the project root\n * @param repoName - Name of the repository to unlink\n * @returns `true` if the link existed and was removed, `false` if no link was found\n * @docLink packages/core/api-reference#unlink-repo\n */\nexport function unlinkRepo(projectDir: string, repoName: string): boolean {\n const links = readLinks(projectDir);\n if (!links[repoName]) return false;\n delete links[repoName];\n writeLinks(projectDir, links);\n return true;\n}\n\n// ── Repo lifecycle ───────────────────────────────────────────────────────────\n\n/**\n * Ensure a repository is available locally, cloning or symlinking as needed.\n *\n * Resolution order:\n * 1. Linked override (`.skaile/links.yaml`) — highest priority\n * 2. Local path (`decl.path`) — direct filesystem reference\n * 3. Remote URL (`decl.url`) — cloned to the shared global cache, symlinked into `.skaile/repos/`\n *\n * Pin support: when `opts.pin` is provided, the tag/commit is checked out after clone.\n *\n * @param decl - Repository declaration from `skaile.yaml`\n * @param name - Logical repository name (cache key)\n * @param reposDir - Project-local repos directory (`.skaile/repos/`)\n * @param opts - Optional: `pin` for a specific commit/tag, `projectDir` for link lookup\n * @returns Absolute path to the local repository directory\n * @throws When the repository cannot be resolved or cloned\n * @docLink packages/core/api-reference#ensure-repo\n */\nexport function ensureRepo(\n decl: RepositoryDeclaration,\n name: string,\n reposDir: string,\n opts?: { pin?: string; projectDir?: string },\n): string {\n // 1. Check for linked override\n if (opts?.projectDir) {\n const links = readLinks(opts.projectDir);\n if (links[name]) {\n const linked = links[name];\n if (!existsSync(linked)) {\n throw new Error(\n `Linked path not found: ${linked}. Remove the .skaile/links.yaml entry to clear it.`,\n );\n }\n return linked;\n }\n }\n\n // 2. Local path\n if (decl.path) {\n const projectDir = opts?.projectDir ?? resolve(reposDir, \"..\");\n const resolved = resolve(projectDir, decl.path);\n if (!existsSync(resolved)) {\n throw new Error(`Local repository path not found: ${decl.path} (resolved: ${resolved})`);\n }\n return resolved;\n }\n\n // 3. Remote URL — clone to shared global cache\n if (decl.url) {\n const branch = decl.branch ?? \"main\";\n const globalCache = getGlobalCacheDir();\n const cacheDest = join(globalCache, name);\n\n // Clone or pull in global cache\n if (existsSync(join(cacheDest, \".git\"))) {\n if (!opts?.pin) pullRepo(cacheDest, branch);\n } else {\n if (!cloneRepo(decl.url, branch, cacheDest)) {\n throw new Error(`Failed to clone ${decl.url} (branch: ${branch})`);\n }\n }\n\n // Checkout pin if specified\n if (opts?.pin) {\n checkoutPin(cacheDest, opts.pin);\n }\n\n // Create symlink in project-local .skaile/repos/ → global cache\n const projectDest = join(reposDir, name);\n const projectExists = existsSync(projectDest);\n const isSymlink = projectExists && lstatSync(projectDest).isSymbolicLink();\n\n if (!projectExists) {\n mkdirSync(reposDir, { recursive: true });\n try {\n symlinkSync(cacheDest, projectDest);\n } catch {\n // Symlink failed (Windows?), just use cache dir directly\n return cacheDest;\n }\n } else if (!isSymlink) {\n // Stale real directory (legacy clone) — replace with symlink to global cache\n rmSync(projectDest, { recursive: true });\n try {\n symlinkSync(cacheDest, projectDest);\n } catch {\n // Symlink failed, fall through to return cacheDest\n }\n }\n\n return cacheDest;\n }\n\n throw new Error(`Repository \"${name}\" has neither url nor path`);\n}\n\n// ── Scanning ─────────────────────────────────────────────────────────────────\n\n/**\n * Scan a repository directory and return all discovered asset catalog entries.\n * Delegates to `scanDirectory` from `manifest.ts`.\n *\n * @param repoDir - Absolute path to the repository root\n * @param repoName - Repository name attached to each produced entry\n * @returns Array of `CatalogEntry` objects found in the repository\n * @docLink packages/core/api-reference#scan-repo\n */\nexport function scanRepo(repoDir: string, repoName: string): CatalogEntry[] {\n return scanDirectory(repoDir, repoName);\n}\n\n// ── Resolution ───────────────────────────────────────────────────────────────\n\n/**\n * Resolve a single asset reference to its `CatalogEntry` by scanning declared repositories.\n *\n * Search order:\n * 1. Explicit `@repository` qualifier on the ref — only that repo is searched.\n * 2. `opts.preferRepo` — searched first when set (repo affinity for transitive deps).\n * 3. All declared repos in declaration order.\n *\n * @param ref - Parsed asset reference to resolve\n * @param repositories - Repository declarations from `skaile.yaml`\n * @param reposDir - Project-local repos directory (`.skaile/repos/`)\n * @param opts - Optional: `projectDir` for link lookup, `preferRepo` for affinity\n * @returns Matching `CatalogEntry`, or `null` if not found in any repository\n * @docLink packages/core/api-reference#resolve-asset\n */\nexport function resolveAsset(\n ref: AssetRef,\n repositories: Record<string, RepositoryDeclaration>,\n reposDir: string,\n opts?: { projectDir?: string; preferRepo?: string },\n): CatalogEntry | null {\n let repoNames: string[];\n if (ref.repository) {\n // Explicit @repo qualifier — only search that repo\n repoNames = [ref.repository];\n } else if (opts?.preferRepo && opts.preferRepo in repositories) {\n // Repo affinity from parent — search preferred repo first, then others\n const rest = Object.keys(repositories).filter((n) => n !== opts.preferRepo);\n repoNames = [opts.preferRepo, ...rest];\n } else {\n repoNames = Object.keys(repositories);\n }\n\n for (const repoName of repoNames) {\n const decl = repositories[repoName];\n if (!decl) continue;\n\n const repoDir = resolveRepoDir(decl, repoName, reposDir, opts?.projectDir);\n if (!repoDir || !existsSync(repoDir)) continue;\n\n const entries = scanRepo(repoDir, repoName);\n const match = entries.find((e) => e.kind === ref.kind && e.name === ref.name);\n if (match) return match;\n }\n\n return null;\n}\n\n/** Resolve repo dir without cloning (for lookups). Checks links first. */\nfunction resolveRepoDir(\n decl: RepositoryDeclaration,\n name: string,\n reposDir: string,\n projectDir?: string,\n): string | null {\n // Check links\n if (projectDir) {\n const links = readLinks(projectDir);\n if (links[name]) {\n return existsSync(links[name]) ? links[name] : null;\n }\n }\n\n if (decl.path) {\n const base = projectDir ?? resolve(reposDir, \"..\");\n const resolved = resolve(base, decl.path);\n return existsSync(resolved) ? resolved : null;\n }\n\n // Check project-local symlink or global cache\n const projectDest = join(reposDir, name);\n if (existsSync(projectDest)) return projectDest;\n\n const globalDest = join(getGlobalCacheDir(), name);\n if (existsSync(join(globalDest, \".git\"))) return globalDest;\n\n return null;\n}\n\n/**\n * Collision record: the same `kind:name` was found in more than one repository.\n * Produced by `resolveAll` when multiple repos contain the same asset.\n * @docLink packages/core/api-reference#asset-collision\n */\nexport interface AssetCollision {\n /** \"kind:name\" key. */\n key: string;\n /** Repository the asset was resolved from. */\n resolvedFrom: string;\n /** Other repositories that also contain this asset. */\n shadowedIn: string[];\n}\n\n/**\n * Result of a full transitive dependency resolution via `resolveAll`.\n * @docLink packages/core/api-reference#resolve-result\n */\nexport interface ResolveResult {\n /** All resolved assets in leaf-first (dependency) order. */\n resolved: CatalogEntry[];\n /** Refs that could not be found in any repo. */\n missing: string[];\n /** Maps \"kind:name\" → resolved_by (\"direct\" or \"kind:name\" of parent). */\n resolvedBy: Map<string, string>;\n /** Assets that exist in multiple repos (resolved entry shadows others). */\n collisions: AssetCollision[];\n}\n\n/**\n * Resolve all dependencies (including transitive) from a list of asset ref strings.\n * Returns resolved assets in leaf-first order (dependencies before dependents).\n *\n * Repo affinity: transitive deps inherit the parent entry's repository as a\n * search preference, so bundled assets are found in their own repo first.\n * Explicit `@repo` qualifiers always take precedence over affinity.\n *\n * @param deps - Top-level asset ref strings to resolve (e.g. `[\"skill:use-exa\", \"agent:pi\"]`)\n * @param repositories - Repository declarations from `skaile.yaml`\n * @param reposDir - Project-local repos directory\n * @param opts - Optional: `projectDir` for link lookup\n * @returns `ResolveResult` with resolved entries, missing refs, provenance map, and collisions\n * @docLink packages/core/api-reference#resolve-all\n */\nexport function resolveAll(\n deps: string[],\n repositories: Record<string, RepositoryDeclaration>,\n reposDir: string,\n opts?: { projectDir?: string },\n): ResolveResult {\n const resolved: CatalogEntry[] = [];\n const seen = new Set<string>();\n const missing: string[] = [];\n const resolvedBy = new Map<string, string>();\n\n function visit(refStr: string, parent: string, parentRepo?: string): void {\n const ref = parseAssetRef(refStr);\n const key = `${ref.kind}:${ref.name}`;\n if (seen.has(key)) return;\n seen.add(key);\n\n // Pass repo affinity: explicit @repo on the ref wins, then parent's repo\n const preferRepo = ref.repository ?? parentRepo;\n const entry = resolveAsset(ref, repositories, reposDir, {\n ...opts,\n preferRepo,\n });\n if (!entry) {\n missing.push(refStr);\n return;\n }\n\n resolvedBy.set(key, parent);\n\n // Propagate entry's repository to transitive deps\n const entryRepo = entry.repository;\n\n // Resolve transitive deps (from requires field)\n for (const req of entry.requires) {\n visit(`${req.kind}:${req.name}`, key, entryRepo);\n }\n\n // Resolve bundle dependencies\n for (const dep of entry.dependencies) {\n visit(dep, key, entryRepo);\n }\n\n resolved.push(entry);\n }\n\n for (const dep of deps) {\n visit(dep, \"direct\");\n }\n\n // Detect collisions: check each resolved asset against other repos\n const collisions = detectCollisions(resolved, repositories, reposDir, opts?.projectDir);\n\n return { resolved, missing, resolvedBy, collisions };\n}\n\n/**\n * For each resolved asset, check whether other repos also contain the same\n * kind:name pair. Returns only actual collisions (2+ repos).\n */\nfunction detectCollisions(\n resolved: CatalogEntry[],\n repositories: Record<string, RepositoryDeclaration>,\n reposDir: string,\n projectDir?: string,\n): AssetCollision[] {\n const repoNames = Object.keys(repositories);\n if (repoNames.length < 2) return [];\n\n // Build per-repo catalog caches (avoids re-scanning)\n const repoEntries = new Map<string, CatalogEntry[]>();\n for (const repoName of repoNames) {\n const decl = repositories[repoName];\n if (!decl) continue;\n const repoDir = resolveRepoDir(decl, repoName, reposDir, projectDir);\n if (!repoDir || !existsSync(repoDir)) continue;\n repoEntries.set(repoName, scanRepo(repoDir, repoName));\n }\n\n const collisions: AssetCollision[] = [];\n for (const entry of resolved) {\n const key = `${entry.kind}:${entry.name}`;\n const shadowedIn: string[] = [];\n for (const [repoName, entries] of repoEntries) {\n if (repoName === entry.repository) continue;\n if (entries.some((e) => e.kind === entry.kind && e.name === entry.name)) {\n shadowedIn.push(repoName);\n }\n }\n if (shadowedIn.length > 0 && entry.repository) {\n collisions.push({ key, resolvedFrom: entry.repository, shadowedIn });\n }\n }\n return collisions;\n}\n\n// ── Status ───────────────────────────────────────────────────────────────────\n\n/**\n * Status summary for a repository — local HEAD, remote HEAD, and how far behind.\n * @docLink packages/core/api-reference#repo-status\n */\nexport interface RepoStatus {\n /** Logical name of the repository. */\n name: string;\n /** Whether the repo is local, remote (cloned), or linked (dev override). */\n kind: \"local\" | \"remote\" | \"linked\";\n /** Current local HEAD commit SHA. */\n localHead: string;\n /** Remote HEAD commit SHA (fetched during status check). */\n remoteHead: string;\n /** Number of commits the local clone is behind the remote. */\n behind: number;\n /** `true` when `behind === 0`. */\n upToDate: boolean;\n /** Absolute path the link points to (linked repos only). */\n linkedTo?: string;\n /** Human-readable error string when the status check failed. */\n error?: string;\n}\n\n/**\n * Check whether a repository clone is up to date with its remote.\n * Fetches the last 50 commits to compare local HEAD with `origin/<branch>`.\n *\n * @param decl - Repository declaration from `skaile.yaml`\n * @param name - Logical repository name\n * @param reposDir - Project-local repos directory\n * @param projectDir - Optional project root for link lookup\n * @returns `RepoStatus` describing the current state\n * @docLink packages/core/api-reference#check-repo-status\n */\nexport function checkRepoStatus(\n decl: RepositoryDeclaration,\n name: string,\n reposDir: string,\n projectDir?: string,\n): RepoStatus {\n // Check for linked override\n if (projectDir) {\n const links = readLinks(projectDir);\n if (links[name]) {\n return {\n name,\n kind: \"linked\",\n localHead: \"\",\n remoteHead: \"\",\n behind: 0,\n upToDate: true,\n linkedTo: links[name],\n };\n }\n }\n\n const base: RepoStatus = {\n name,\n kind: decl.path ? \"local\" : \"remote\",\n localHead: \"\",\n remoteHead: \"\",\n behind: 0,\n upToDate: true,\n };\n\n if (decl.path) return base;\n\n // Check global cache first, then project-local\n let dest = join(getGlobalCacheDir(), name);\n if (!existsSync(join(dest, \".git\"))) {\n dest = join(reposDir, name);\n }\n if (!existsSync(join(dest, \".git\"))) {\n return { ...base, error: \"Not cloned yet\" };\n }\n\n const branch = decl.branch ?? \"main\";\n\n const localHead = getRepoCommit(dest);\n if (!localHead) return { ...base, error: \"Failed to read local HEAD\" };\n base.localHead = localHead;\n\n const fetchR = spawnSync(\"git\", [\"-C\", dest, \"fetch\", \"--depth=50\", \"origin\", branch], {\n encoding: \"utf8\",\n stdio: \"pipe\",\n env: GIT_ENV,\n });\n if (fetchR.status !== 0) return { ...base, error: \"Fetch failed\" };\n\n const remoteR = spawnSync(\"git\", [\"-C\", dest, \"rev-parse\", `origin/${branch}`], {\n encoding: \"utf8\",\n stdio: \"pipe\",\n });\n if (remoteR.status !== 0) return { ...base, error: \"Failed to read remote HEAD\" };\n base.remoteHead = remoteR.stdout.trim();\n\n const countR = spawnSync(\n \"git\",\n [\"-C\", dest, \"rev-list\", \"--left-right\", \"--count\", `HEAD...origin/${branch}`],\n { encoding: \"utf8\", stdio: \"pipe\" },\n );\n if (countR.status === 0) {\n const parts = countR.stdout.trim().split(/\\s+/);\n base.behind = parseInt(parts[1] ?? \"0\", 10);\n }\n\n base.upToDate = base.behind === 0;\n return base;\n}\n","/**\n * Unified workspace configuration — `skaile.yaml` / `<name>.skaile.yaml`\n *\n * Single file combining AI resources, data connectors, agent behavior,\n * runtime defaults, and workspace layout.\n *\n * ── File naming ──────────────────────────────────────────────────────────\n *\n * skaile.yaml → canonical default workspace config\n * staging.skaile.yaml → alternative workspace config\n * *.skaile.yaml → glob pattern for named configs\n *\n * ── Stacking ─────────────────────────────────────────────────────────────\n *\n * Files stack across scope levels (same name must match):\n * ~/.skaile/skaile.yaml priority 10 (user)\n * /app/skaile.yaml priority 20 (app)\n * /project/skaile.yaml priority 30 (project)\n *\n * ── Relationship to other files ──────────────────────────────────────────\n *\n * .skaile/settings.json User-specific overrides (API keys, personal\n * model preferences). Gitignored. Overrides\n * workspace config defaults at runtime.\n *\n * workspace.yaml Scaffold template. Generates skaile.yaml\n * at `skaile init` time. Never read at runtime.\n *\n * agent.yaml Agent definition (identity). Referenced from\n * skaile.yaml via `agent.definition`.\n */\n\nimport { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, parse as parsePath, resolve } from \"node:path\";\nimport { parse, stringify } from \"yaml\";\nimport { type CatalogEntry, parseAssetRef } from \"./models.js\";\nimport { getGlobalCacheDir, resolveAsset } from \"./repo-manager.js\";\n\n// ── Agent config ──────────────────────────────────────────────────────────────\n\n/**\n * Named agent configuration profile. The \"default\" profile is the active one.\n * Personal overrides (apiKeys, model preference) live in .skaile/settings.json.\n * @docLink packages/core/workspace-config#agent-config-profile\n */\nexport interface AgentConfigProfile {\n /** Bridge driver to use: \"claude-sdk\", \"codex\", or \"omp\". */\n driver?: string;\n /** Default LLM provider: \"anthropic\", \"openai\", \"google\", etc. */\n provider?: string;\n /** Default model identifier. */\n model?: string;\n /** Thinking mode for Claude models. */\n thinking?: \"adaptive\" | \"enabled\" | \"disabled\";\n /** Reasoning effort level. */\n effort?: \"low\" | \"medium\" | \"high\" | string;\n /** Override framework install paths (rarely needed). */\n skills_dir?: string;\n agents_dir?: string;\n prompts_dir?: string;\n}\n\n// ── Startup ───────────────────────────────────────────────────────────────────\n\n/**\n * A startup directive — run on workspace launch.\n *\n * String form: \"agent:research-assistant\" — start the named agent\n * Object form: { \"system-prompt-override\": \"...\" } — replace system prompt\n * { \"system-prompt-append\": \"...\" } — append to system prompt\n * @docLink packages/core/workspace-config#startup-directive\n */\nexport type StartupDirective = string | Record<string, string>;\n\n// ── AI Resources ──────────────────────────────────────────────────────────────\n\n/**\n * An AI resource source with its own dependency list.\n * All declared dependencies are installed from this source's catalog.\n * @docLink packages/core/workspace-config#ai-resource-entry\n */\nexport interface AiResourceEntry {\n /** Source name (used as cache key and in CLI output). */\n name: string;\n /** Path to local directory or GitHub repo URL. */\n path: string;\n /** Git branch (default: main). */\n branch?: string;\n /** Skill/agent/package/flow refs to install from this source. Syntax: \"kind:name\". */\n dependencies?: string[];\n /** Auto-deploy to framework dirs on install. */\n auto_deploy?: boolean;\n}\n\n// ── Repository Declaration ────────────────────────────────────────────────────\n\n/**\n * Internal-only data shape used by the legacy asset install pipeline\n * (`repo-manager`, `lock`, `runtime-assets`). Carries the resolved URL or\n * path for an `ai_resources[]` entry. Not surfaced via the workspace config\n * schema — new sources are registered through `@skaile/library`.\n *\n * @docLink packages/core/workspace-config#repository-declaration\n */\nexport interface RepositoryDeclaration {\n /** GitHub or git URL (for remote repos). */\n url?: string;\n /** Local filesystem path (for local repos). */\n path?: string;\n /** Git branch (default: main). */\n branch?: string;\n /** Upstream URL for fork workflows. */\n upstream?: string;\n}\n\n// ── Mounts ──────────────────────────────────────────────────────────────────\n\n/**\n * A filesystem mount — projected storage backend.\n * @docLink packages/core/workspace-config#mount-declaration\n */\ninterface MountDeclaration {\n /** Unique identifier. Used as mount dir name. */\n id: string;\n /** Mount driver: \"local\", \"git\", \"s3\", \"webdav\", \"sharepoint\". */\n driver: string;\n /** What to mount: URL, bucket path, host filesystem path. */\n source: string;\n /** Workspace-relative mount point (default: .mounts/<id>). */\n target?: string;\n /** Access level enforced by the mount driver. */\n access?: \"read-only\" | \"read-write\";\n /** Credential reference: \"env:VAR_NAME\" or inline value. */\n auth?: string;\n /**\n * Whether to watch this mount for filesystem changes.\n * true = always watch, false = never watch, undefined = auto (watch if read-write).\n */\n watch?: boolean;\n /**\n * **Expert-only.** When `true`, the mount manager wires the resolved\n * credential into the workspace so the agent's interactive `git`/`curl`\n * tools can authenticate directly against the mount's host. Defaults to\n * `false` — agents have no credential exposure and rely on driver-managed\n * pulls/pushes. See `_devlog/specs/2026-05-05-git-credential-tiers.md`.\n */\n exposeAccessToken?: boolean;\n /**\n * Optional override for the access token TTL (seconds). When omitted, the\n * provider's natural TTL is used. Values above the provider's documented\n * maximum are silently capped.\n */\n accessTokenTTL?: number;\n /** Driver-specific configuration (branch, region, etc.). */\n options?: Record<string, unknown>;\n}\n\n// ── Connectors ────────────────────────────────────────────────────────────────\n\n/**\n * A data connector — tool-accessed backend the agent interacts with.\n * @docLink packages/core/workspace-config#connector-declaration\n */\nexport interface ConnectorDeclaration {\n /** Unique identifier. Used as tool namespace. */\n id: string;\n /** Connector adapter: \"postgres\", \"redis\", \"sqlite\", \"memory\", \"xstate\", \"xstate-store\", \"yjs\". */\n driver: string;\n /**\n * Access level enforced by ConnectorManager.\n * Optional in config — ConnectorManager defaults to \"read-only\" when absent.\n */\n access?: \"read-only\" | \"read-write\";\n /** Credential reference: \"env:VAR_NAME\" or inline value. */\n auth?: string;\n /** Adapter-specific configuration (dsn, host, etc.). */\n options?: Record<string, unknown>;\n\n // ── Extended fields (Plan A: first-level asset support) ──────────────────\n /** Semver range for future catalog versioning, e.g. \"^1.0.0\". */\n version?: string;\n /**\n * Run a health check (ping) when the connector is first connected.\n * Default: false. Set to true to surface connection errors early.\n */\n health_check?: boolean;\n /**\n * Inject this connector's skill description into the agent's system prompt.\n * Default: false.\n */\n expose_as_skill?: boolean;\n /** Tags for catalog browsing and skill routing. */\n tags?: string[];\n\n /**\n * Optional filesystem face — makes the connector \"mountable\".\n * When present, ConnectorManager allocates a mount directory and passes it\n * to the connector via `ConnectContext.mountTarget`.\n *\n * YAML key: `mount` (sub-block under a `connectors:` entry).\n * Replaces the legacy top-level `mounts:` key (hard cut — see Task 11).\n */\n mount?: {\n /** Source URL or path (repo URL, bucket name, host path). */\n source: string;\n /** Override mount target directory (default: `.mounts/<id>/`). */\n target?: string;\n /** Watch flag: omitted → watch read-write, skip read-only. */\n watch?: boolean;\n /** Expert-only: expose the resolved credential to the agent CLI. */\n exposeAccessToken?: boolean;\n /** Optional access-token TTL override (seconds). */\n accessTokenTTL?: number;\n };\n}\n\n// ── MCP Servers ──────────────────────────────────────────────────────────────\n\n/**\n * Reference to a Nix-built asset recipe.\n *\n * The `attr` field selects an attribute path in the platform's flake\n * (`/etc/skaile/flake/`), e.g. `mcps.excel`, `mcps.ppt`, `stacks.baseline`.\n * Resolution happens at session start (cold) and on `reconfigure_mcps`\n * (hot-add) via `nix path-info --offline`.\n *\n * @docLink packages/core/concepts#asset-recipe\n */\nexport interface AssetRecipe {\n /** Flake attribute path, e.g. `mcps.excel`. */\n attr: string;\n}\n\n/**\n * Validates an `AssetRecipe.attr` value against nix attribute path syntax.\n *\n * Nix attribute paths are dot-separated segments. Each segment must start with\n * a letter and contain only letters, digits, underscores, hyphens, and dots.\n * Characters like `#`, spaces, and nix expression fragments are explicitly\n * rejected — even though `spawnSync` array args prevent shell injection, nix\n * parses the combined `flakeRef#attr` string and invalid chars trigger\n * unintended evaluation paths.\n *\n * Deliberate restriction: leading digits per segment are not allowed even\n * though some nix attrs permit them, because they are rare in practice and\n * the restriction makes the validation straightforward to audit.\n *\n * @throws Error when `attr` is invalid\n */\nexport function validateAssetRecipeAttr(attr: string): void {\n if (typeof attr !== \"string\" || attr.length === 0) {\n throw new Error(\"AssetRecipe.attr must be a non-empty string\");\n }\n if (attr.length > 200) {\n throw new Error(`AssetRecipe.attr too long (${attr.length} chars, max 200)`);\n }\n const VALID_ATTR = /^[a-z][a-z0-9._-]*(?:\\.[a-z][a-z0-9._-]*)*$/i;\n if (!VALID_ATTR.test(attr)) {\n throw new Error(\n `AssetRecipe.attr \"${attr}\" contains invalid characters. ` +\n `Allowed: letters, digits, underscore, hyphen, dot. ` +\n `Each dot-segment must start with a letter.`,\n );\n }\n}\n\n/**\n * A declarative external MCP server — spawned or connected at session startup\n * and injected into the Claude SDK driver as a named `mcpServers` entry.\n *\n * Maps directly to the Claude Agent SDK's `McpServerConfig` union:\n * - `transport: \"stdio\"` (default) → `McpStdioServerConfig` — subprocess spawn\n * - `transport: \"sse\"` → `McpSSEServerConfig` — HTTP Server-Sent Events\n * - `transport: \"http\"` → `McpHttpServerConfig` — HTTP streaming\n *\n * The `id` becomes the key in the SDK's `mcpServers` record and also the MCP\n * tool prefix (e.g., `mcp__my-server__<tool-name>`).\n * @docLink packages/core/workspace-config#mcp-server-declaration\n */\nexport interface McpServerDeclaration {\n /** Unique identifier — used as the `mcpServers` record key and tool prefix. */\n id: string;\n /**\n * Transport type.\n * Default: `\"stdio\"` (subprocess).\n */\n transport?: \"stdio\" | \"sse\" | \"http\";\n /** For `\"stdio\"`: the command to execute (e.g. `\"npx\"`, `\"node\"`, `\"python\"`). */\n command?: string;\n /** For `\"stdio\"`: arguments passed to the command. */\n args?: string[];\n /** For `\"stdio\"`: environment variables injected into the subprocess. */\n env?: Record<string, string>;\n /** For `\"sse\"` and `\"http\"`: the server URL. */\n url?: string;\n /** For `\"sse\"` and `\"http\"`: HTTP headers (e.g. `Authorization`). */\n headers?: Record<string, string>;\n /** Short description of what this server provides (used in catalog). */\n description?: string;\n /** Tags for catalog browsing and discovery. */\n tags?: string[];\n /**\n * Optional Nix recipe binding. When present, the runner resolves the\n * recipe's `/nix/store` out-path before subprocess spawn and substitutes\n * `${recipe:<id>}` / `${recipe:<id>:<sub>}` / `${recipe:<id>:bin}` /\n * `${recipe:<id>:lib}` markers in `command`, `args`, and `env` values.\n * `<id>` matches this declaration's `id` field.\n */\n recipe?: AssetRecipe;\n}\n\n// ── Agent Configuration ──────────────────────────────────────────────────────\n\n/**\n * Platform-level context describing the environment the agent operates in.\n * Rendered by the runner into a \"## Platform\" section of the system prompt.\n */\nexport interface AgentContextConfig {\n /** Platform identifier (e.g. \"skaile\"). Controls the rendered header sentence. */\n platform?: string;\n /** Whether multiple users may interact in the same session. */\n multi_user?: boolean;\n /** Session persistence model. */\n session_model?: \"persistent\" | \"ephemeral\";\n}\n\nexport interface AgentConfig {\n /**\n * Agent definition reference. Resolved in order:\n * - Local path: \".skaile/agent\" or \"./my-agent\"\n * - Catalog reference: \"agent:<name>\" (resolved via asset manager catalog)\n * - Resource path: \"ai-assets://<domain>/agents/<name>\"\n */\n definition?: string;\n\n /**\n * Platform-level context (platform identifier, multi-user flag, session model).\n * Consumed by the runner to build the \"## Platform\" section of the system prompt.\n */\n context?: AgentContextConfig;\n\n /** Agent runtime constraints. */\n permissions?: AgentPermissions;\n\n /** Lifecycle hooks — shell commands run at specific points. */\n hooks?: AgentHooks;\n\n /** Named subagent definitions available for delegation. */\n subagents?: Record<string, SubagentConfig>;\n\n /**\n * Control which framework fragments are included in the rendered system prompt.\n * true (default) — include built-in fragment\n * false — omit this fragment\n * string — path to a custom markdown file (relative to project root)\n *\n * Fragment IDs: \"agent-mode\" | \"skill-discovery\" | \"connector-usage\" | \"handoff\"\n */\n fragments?: Record<string, boolean | string>;\n\n /**\n * Additional markdown files appended at the end of every rendered agent system\n * prompt in this workspace. Paths relative to the project root (skaile.yaml).\n *\n * YAML key: `prompt-extensions`\n */\n \"prompt-extensions\"?: string[];\n\n /**\n * Free-form user-authored agent prompt. Plain text or markdown — no length\n * cap, no template substitution. Prepended immediately after the platform\n * context section and before the environment section in the assembled\n * system prompt (see runner's {@link assembleSystemPrompt}).\n *\n * Written by the platform's wake-time yaml serializer from the combined\n * project-level + session-level prompts stored on `SkaileConfigData.agent.prompt`.\n * Standalone CLI / forge sessions may set this directly in `skaile.yaml`.\n *\n * Spec: `docs/superpowers/specs/2026-05-13-platform-agent-prompt-design.md`\n * @since 2026-05\n */\n prompt?: string;\n}\n\nexport interface AgentPermissions {\n /** Maximum agentic turns per query (default: 15). */\n max_turns?: number;\n /**\n * Permission mode for Claude SDK driver.\n * 'auto' = bypassPermissions (default for automated flows).\n * 'interactive' = prompt for each tool use.\n */\n permission_mode?: \"auto\" | \"interactive\";\n /** Glob patterns the agent may NOT write to. Stacking: union across scopes. */\n deny_write?: string[];\n /** Glob patterns the agent may NOT read. Stacking: union across scopes. */\n deny_read?: string[];\n}\n\nexport interface AgentHooks {\n /** Run before a flow starts (after resources are connected). */\n pre_flow?: HookEntry[];\n /** Run after a flow completes (before resources disconnect). */\n post_flow?: HookEntry[];\n /** Run before each flow node executes. */\n pre_node?: HookEntry[];\n /** Run after each flow node completes successfully. */\n post_node?: HookEntry[];\n}\n\nexport interface HookEntry {\n /** Human-readable hook name. */\n name: string;\n /** Shell command to execute. */\n run: string;\n /** Working directory relative to workspace root (default: workspace root). */\n cwd?: string;\n /** Timeout in seconds (default: 60). */\n timeout?: number;\n /** Continue flow if hook fails (default: false). */\n continue_on_error?: boolean;\n}\n\nexport interface SubagentConfig {\n /** What this subagent does. */\n description: string;\n /** System prompt for the subagent. */\n prompt: string;\n /** Tools this subagent may use (default: all). */\n tools?: string[];\n /** Tools this subagent may NOT use. */\n disallowed_tools?: string[];\n /** Model override. */\n model?: string;\n}\n\n// ── Workspace Layout ─────────────────────────────────────────────────────────\n\nexport interface WorkspaceLayoutConfig {\n /** Directories to ensure exist (created at scaffold time, verified at run time). */\n directories?: string[];\n\n /** Git configuration. */\n git?: GitConfig;\n\n /** Post-scaffold setup commands (run once after `skaile init`). */\n setup?: SetupEntry[];\n\n /** Container configuration (Docker). */\n container?: ContainerConfig;\n}\n\nexport interface GitConfig {\n /** Initialize a git repo at scaffold time (default: true). */\n init?: boolean;\n /** .gitignore entries. Stacking: concatenate + deduplicate. */\n ignore?: string[];\n}\n\nexport interface SetupEntry {\n /** Human-readable name. */\n name: string;\n /** Shell command to execute. */\n run: string;\n /** Working directory relative to workspace root. */\n cwd?: string;\n /** Continue if command fails (default: false). */\n continue_on_error?: boolean;\n}\n\nexport interface NixContainerConfig {\n /**\n * Nixpkgs package attribute names to include in the environment.\n * Example: [\"nodejs_22\", \"bun\", \"git\", \"python3\"]\n */\n packages?: string[];\n /**\n * Nixpkgs registry name used as a package prefix for `nix shell`.\n * MUST be a bare registry name like \"nixpkgs\" — not a channel path like\n * \"nixpkgs/nixos-24.11\" (which is not valid as a flake ref prefix).\n * Defaults to \"nixpkgs\".\n */\n channel?: string;\n /**\n * Path to a Nix file (shell.nix / flake.nix) relative to the project root.\n * When set, `packages` and `channel` are ignored — the file is the source of truth.\n */\n flake?: string;\n /**\n * Predefined named stack to resolve from the system stack registry (SKAILE_NIX_STACK_REGISTRY).\n * Overridden by `packages` if present.\n * Takes precedence over the parent `ContainerConfig.stack` field when nix mode is active.\n */\n stack?: string;\n}\n\nexport interface ContainerConfig {\n /** Enable Docker container generation. */\n enabled?: boolean;\n /** Base Docker image. */\n image?: string;\n /** System packages to install. */\n packages?: string[];\n /** Agent CLIs to install globally in the container. */\n agent_clis?: string[];\n /** Ports to expose. */\n ports?: string[];\n /** Environment variables to pass through. */\n env?: string[];\n /** Docker volume/bind mounts. */\n mounts?: Array<{ type: \"bind\" | \"volume\"; source: string; target: string }>;\n /** WebSocket port for IPC. */\n ws_port?: number;\n /**\n * Named system stack.\n * - Docker mode: resolved to an image tag via `dockerImageMap` (SKAILE_DOCKER_IMAGE_MAP).\n * - Nix mode: resolved to a package list via `nixStackRegistry` (SKAILE_NIX_STACK_REGISTRY).\n * Overridden by `nix.stack` if both are present.\n */\n stack?: string;\n /** Nix-specific environment configuration (nix session mode only). */\n nix?: NixContainerConfig;\n}\n\n// ── Top-level config ──────────────────────────────────────────────────────────\n\nexport interface SkWorkspaceConfig {\n /** Project name (defaults to directory basename). */\n name?: string;\n /** Project description. */\n description?: string;\n\n /**\n * Agent configuration profiles. The \"default\" profile provides runtime\n * defaults (framework, model, provider). Personal overrides live in\n * .skaile/settings.json and always take priority.\n *\n * YAML key: `agent-config` or `agent_config`\n */\n agent_config?: Record<string, AgentConfigProfile>;\n\n /**\n * Startup directives — executed when the workspace is launched.\n * Each item is either a string (\"agent:name\") or a map\n * ({ \"system-prompt-override\": \"...\" }).\n */\n startup?: StartupDirective[];\n\n /**\n * Internal-only — always `{}` on the merged config. Kept on the shape so\n * `repo-manager`, `lock`, and `runtime-assets` keep type-checking; their\n * `Record<string, RepositoryDeclaration>` arguments are built from\n * `ai_resources[]` entries inside the install pipeline.\n */\n repositories?: Record<string, RepositoryDeclaration>;\n\n /**\n * Asset dependencies using kind:name[@repo][#pin] syntax (new format).\n * Top-level flat list — repos and deps are separate concerns.\n *\n * YAML key: `dependencies`\n */\n dependencies?: string[];\n\n /**\n * Local patches applied during install (new format).\n * Maps \"kind:name\" → patch file path relative to project root.\n *\n * YAML key: `patches`\n */\n patches?: Record<string, string>;\n\n /**\n * AI resource sources, each with its own dependency list.\n * @deprecated Use `repositories` + `dependencies` instead.\n */\n ai_resources?: AiResourceEntry[];\n\n /**\n * @deprecated The top-level `mounts:` key is no longer supported as of Task 11.\n *\n * Move filesystem-projected storage backends under `connectors:` with a\n * `mount:` sub-block. See `docs/migration-mounts-to-connectors.md`.\n *\n * This field is kept on the type **only** so `config.ts` can detect a\n * present `mounts:` block and throw a migration error. It is never merged,\n * applied, or forwarded to any manager. `normalizeConfig` still populates it\n * when `mounts:` is present in the YAML so the detection check works.\n *\n * YAML key: `mounts` (rejected at runtime — do not use)\n */\n mounts?: MountDeclaration[];\n\n /**\n * Data connectors — tool-accessed backends.\n *\n * Each declaration's `driver` field is an *implicit* catalog ref\n * (`connector:<driver>`). The runtime resolves it through\n * `resolveRuntimeAssets()`, which scans every declared `repositories` entry\n * plus the implicit `@skaile/base-assets` repo for matching `CONNECTOR.md`\n * manifests. Drivers that do not match any catalog entry produce a\n * `missing_driver` warning at session startup.\n *\n * YAML key: `connectors`\n */\n connectors?: ConnectorDeclaration[];\n\n /**\n * External MCP servers — injected into the Claude SDK driver at session startup.\n * Supports stdio subprocess, SSE, and HTTP transports.\n *\n * YAML key: `mcp_servers`\n */\n mcp_servers?: McpServerDeclaration[];\n\n /** Agent behavior — definition reference, permissions, hooks, subagents. */\n agent?: AgentConfig;\n\n /** Workspace layout — directories, git, setup scripts, container. */\n workspace?: WorkspaceLayoutConfig;\n\n /**\n * Secret provisioning configuration.\n * Controls how connector credentials are resolved at runtime.\n *\n * YAML key: `secrets`\n */\n secrets?: SecretsConfig;\n\n /**\n * Telemetry configuration — passed through raw to the telemetry package.\n * Parsed by `resolveTelemetryConfig` in `@skaile/workspaces/telemetry`.\n *\n * YAML key: `telemetry`\n */\n telemetry?: Record<string, unknown>;\n\n /**\n * Session compaction settings -- controls when and how conversation\n * snapshots are created.\n *\n * YAML key: `compaction`\n */\n compaction?: CompactionConfig;\n}\n\nexport interface SecretsConfig {\n /**\n * How secrets are provided to the container.\n * \"env\" — read from process.env (default, for CLI/standalone)\n * \"provisioned\" — wait for secrets over transport bridge (platform containers)\n */\n provider?: \"env\" | \"provisioned\";\n /** Timeout in ms for waiting for provisioned secrets (default: 30000). */\n timeoutMs?: number;\n}\n\n// ── Compaction config ────────────────────────────────────────────────────────\n\nexport interface CompactionConfig {\n /** Enable managed compaction (default: true). */\n enabled?: boolean;\n /** Context fill percentage that triggers compaction (default: 80). */\n thresholdPercent?: number;\n /** Compact before hibernation for cheap restores (default: true). */\n compactOnHibernate?: boolean;\n /** Minimum ms between compactions to prevent thrashing (default: 120000). */\n minCooldownMs?: number;\n /** Enable manual compact command in expert mode (default: false). */\n manualCompactEnabled?: boolean;\n}\n\nexport const COMPACTION_DEFAULTS: Required<CompactionConfig> = {\n enabled: true,\n thresholdPercent: 80,\n compactOnHibernate: true,\n minCooldownMs: 120_000,\n manualCompactEnabled: false,\n};\n\n// ── Deprecated type aliases ───────────────────────────────────────────────────\n\n/** @deprecated Use AgentConfigProfile */\nexport interface RuntimeDefaults {\n framework?: string;\n driver?: string;\n provider?: string;\n model?: string;\n skills_dir?: string;\n agents_dir?: string;\n prompts_dir?: string;\n}\n\n/** @deprecated Use AiResourceEntry[] */\nexport interface AiResourcesConfig {\n sources?: AiResourceSource[];\n requires?: string[];\n auto_deploy?: boolean;\n}\n\n/** @deprecated Use AiResourceEntry */\nexport interface AiResourceSource {\n name: string;\n path: string;\n branch?: string;\n}\n\n// ── Config file info ──────────────────────────────────────────────────────────\n\nexport interface SkWorkspaceConfigFile {\n /** Absolute path to the config file. */\n path: string;\n /** Workspace name (extracted from filename). */\n name: string;\n /** Parsed config. */\n config: SkWorkspaceConfig;\n}\n\n// ── Constants ─────────────────────────────────────────────────────────────────\n\n/** Suffix for named workspace configs: `<name>.skaile.yaml` */\nexport const SKAILE_YAML_SUFFIX = \".skaile.yaml\";\n/** Filename for the default workspace config when no name is given. */\nexport const SKAILE_YAML_DEFAULT = \"skaile.yaml\";\n\n/** @deprecated Use SKAILE_YAML_SUFFIX */\nexport const SK_WORKSPACE_SUFFIX = SKAILE_YAML_SUFFIX;\n/** @deprecated Use SKAILE_YAML_DEFAULT */\nexport const SK_WORKSPACE_DEFAULT_NAME = \"default\";\n\n// ── Config I/O ────────────────────────────────────────────────────────────────\n\n/**\n * Return the canonical filename for a workspace config.\n * The default workspace resolves to `\"skaile.yaml\"`; named workspaces resolve to\n * `\"<name>.skaile.yaml\"`.\n *\n * @param name - Optional workspace name (omit or pass `\"default\"` for the primary config)\n * @returns Filename string (not a full path)\n * @docLink packages/core/workspace-config#workspace-config-filename\n */\nexport function workspaceConfigFilename(name?: string): string {\n if (!name || name === \"default\") return SKAILE_YAML_DEFAULT;\n return `${name}${SKAILE_YAML_SUFFIX}`;\n}\n\n/**\n * Return `true` if `filename` matches the workspace config naming convention\n * (`\"skaile.yaml\"` or any `\"*.skaile.yaml\"`).\n *\n * @param filename - Bare filename (no directory component)\n * @docLink packages/core/workspace-config#is-workspace-config-filename\n */\nexport function isWorkspaceConfigFilename(filename: string): boolean {\n return filename === SKAILE_YAML_DEFAULT || filename.endsWith(SKAILE_YAML_SUFFIX);\n}\n\n/**\n * Extract the workspace name from a config filename.\n * `\"skaile.yaml\"` → `\"default\"`, `\"staging.skaile.yaml\"` → `\"staging\"`.\n *\n * @param filename - Bare filename produced by `workspaceConfigFilename`\n * @returns Workspace name string\n * @docLink packages/core/workspace-config#workspace-name-from-filename\n */\nexport function workspaceNameFromFilename(filename: string): string {\n if (filename === SKAILE_YAML_DEFAULT) return \"default\";\n return filename.slice(0, -SKAILE_YAML_SUFFIX.length);\n}\n\n/**\n * Load a single workspace config file from `dir`.\n * When `name` is omitted and no `skaile.yaml` exists, falls back to the sole\n * `*.skaile.yaml` file in the directory if exactly one is present.\n *\n * @param dir - Directory to search for the config file\n * @param name - Optional workspace name (omit for the default `skaile.yaml`)\n * @returns Parsed config file info, or `null` if no matching file was found\n * @docLink packages/core/workspace-config#load-sk-workspace-config\n */\nexport function loadSkWorkspaceConfig(dir: string, name?: string): SkWorkspaceConfigFile | null {\n const resolvedDir = resolve(dir);\n const canonicalName = name && name !== \"default\" ? name : undefined;\n\n const filename = workspaceConfigFilename(canonicalName);\n const filePath = join(resolvedDir, filename);\n if (existsSync(filePath)) {\n return parseConfigFile(filePath, canonicalName ?? \"default\");\n }\n\n if (!canonicalName) {\n const found = listSkWorkspaceConfigs(resolvedDir);\n if (found.length === 1) return found[0]!;\n }\n\n return null;\n}\n\n/**\n * Serialize and write a workspace config to `dir`, creating the directory if needed.\n *\n * @param dir - Target directory (created recursively if absent)\n * @param config - Config object to serialize as YAML\n * @param name - Optional workspace name (omit for the default `skaile.yaml`)\n * @returns Absolute path of the written file\n * @docLink packages/core/workspace-config#save-sk-workspace-config\n */\nexport function saveSkWorkspaceConfig(\n dir: string,\n config: SkWorkspaceConfig,\n name?: string,\n): string {\n const resolvedDir = resolve(dir);\n const filename = workspaceConfigFilename(name);\n const filePath = join(resolvedDir, filename);\n\n if (!existsSync(resolvedDir)) {\n mkdirSync(resolvedDir, { recursive: true });\n }\n\n writeFileSync(filePath, stringify(config, { lineWidth: 120 }));\n return filePath;\n}\n\n/**\n * List all workspace config files present in `dir`, sorted alphabetically by name.\n * Returns an empty array when `dir` does not exist or is unreadable.\n *\n * @param dir - Directory to scan for `skaile.yaml` and `*.skaile.yaml` files\n * @returns Array of parsed config file descriptors\n * @docLink packages/core/workspace-config#list-sk-workspace-configs\n */\nexport function listSkWorkspaceConfigs(dir: string): SkWorkspaceConfigFile[] {\n const resolvedDir = resolve(dir);\n if (!existsSync(resolvedDir)) return [];\n\n const configs: SkWorkspaceConfigFile[] = [];\n try {\n for (const entry of readdirSync(resolvedDir)) {\n if (isWorkspaceConfigFilename(entry)) {\n const wsName = workspaceNameFromFilename(entry);\n const parsed = parseConfigFile(join(resolvedDir, entry), wsName);\n if (parsed) configs.push(parsed);\n }\n }\n } catch {\n /* unreadable dir */\n }\n\n return configs.sort((a, b) => a.name.localeCompare(b.name));\n}\n\n/**\n * Resolve the effective workspace config by stacking configs across three scope levels:\n * user (`~/.skaile/`) < app (`opts.appDir`) < project (`projectDir`).\n *\n * Each level's config is merged with `mergeSkWorkspaceConfigs`, with higher-priority\n * scopes winning for scalars and unions applied for arrays (deny lists, directories, etc.).\n * Returns an empty object `{}` when no config files are found.\n *\n * @param projectDir - Root directory of the current project\n * @param opts - Optional overrides: `name` selects a named workspace (default: `\"default\"`),\n * `appDir` inserts an app-level config between user and project scopes\n * @returns Merged effective `SkWorkspaceConfig`\n * @docLink packages/core/workspace-config#resolve-sk-workspace-config\n */\nexport function resolveSkWorkspaceConfig(\n projectDir: string,\n opts?: { name?: string; appDir?: string },\n): SkWorkspaceConfig {\n const name = opts?.name ?? SK_WORKSPACE_DEFAULT_NAME;\n const configs: SkWorkspaceConfig[] = [];\n\n const userConfig = loadSkWorkspaceConfig(join(homedir(), \".skaile\"), name);\n if (userConfig) configs.push(userConfig.config);\n\n if (opts?.appDir) {\n const appConfig = loadSkWorkspaceConfig(opts.appDir, name);\n if (appConfig) configs.push(appConfig.config);\n }\n\n const projectConfig = loadSkWorkspaceConfig(projectDir, name);\n if (projectConfig) configs.push(projectConfig.config);\n\n if (configs.length > 0) return configs.reduce(mergeSkWorkspaceConfigs);\n\n return {};\n}\n\n/**\n * Walk upward from `startDir` looking for a `skaile.yaml` (or `*.skaile.yaml`).\n * Returns the directory containing the first match, or `undefined` if none found.\n *\n * Stops after 20 levels to avoid scanning all the way to `/`.\n *\n * @param startDir - Directory to start searching from (usually `process.cwd()`)\n * @returns Absolute path to the workspace root, or `undefined`\n * @docLink packages/core/workspace-config#find-workspace-root\n */\nexport function findWorkspaceRoot(startDir: string): string | undefined {\n let dir = resolve(startDir);\n const root = parsePath(dir).root; // filesystem root (e.g. \"/\" or \"C:\\\\\")\n let depth = 0;\n\n while (depth < 20) {\n if (existsSync(join(dir, SKAILE_YAML_DEFAULT))) return dir;\n // Check for named workspace configs (*.skaile.yaml)\n try {\n for (const entry of readdirSync(dir)) {\n if (entry.endsWith(SKAILE_YAML_SUFFIX)) return dir;\n }\n } catch {\n /* unreadable */\n }\n\n if (dir === root) break;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n depth++;\n }\n return undefined;\n}\n\n// ── Merge logic ───────────────────────────────────────────────────────────────\n\n/**\n * Deep-merge two workspace configs according to stacking rules.\n * `overlay` takes priority over `base` for scalar fields.\n * Arrays use concatenation + deduplication; deny lists always union.\n * Mounts and connectors are merged by `id` (overlay entry wins for same id).\n * Hooks are concatenated in order (base first, overlay appended).\n *\n * @param base - Lower-priority config (e.g. user or app scope)\n * @param overlay - Higher-priority config (e.g. project scope)\n * @returns Merged `SkWorkspaceConfig`\n * @docLink packages/core/workspace-config#merge-sk-workspace-configs\n */\nexport function mergeSkWorkspaceConfigs(\n base: SkWorkspaceConfig,\n overlay: SkWorkspaceConfig,\n): SkWorkspaceConfig {\n return {\n name: overlay.name ?? base.name,\n description: overlay.description ?? base.description,\n\n // agent_config: per-profile key, overlay profile wins\n agent_config: {\n ...(base.agent_config ?? {}),\n ...(overlay.agent_config ?? {}),\n },\n\n // startup: overlay wins (project-level only)\n startup: overlay.startup ?? base.startup,\n\n // ai_resources: dedupe by source name — overlay entry wins for same name\n ai_resources: dedupeByKey(\n [...(base.ai_resources ?? []), ...(overlay.ai_resources ?? [])],\n \"name\",\n ),\n\n // mounts: by id — overlay wins\n mounts: mergeById(base.mounts ?? [], overlay.mounts ?? []),\n\n // connectors: by id — overlay wins\n connectors: mergeById(base.connectors ?? [], overlay.connectors ?? []),\n\n // mcp_servers: by id — overlay wins\n mcp_servers: mergeById(base.mcp_servers ?? [], overlay.mcp_servers ?? []),\n\n agent: {\n definition: overlay.agent?.definition ?? base.agent?.definition,\n context: overlay.agent?.context ?? base.agent?.context,\n permissions: {\n ...base.agent?.permissions,\n ...stripUndefined(overlay.agent?.permissions),\n deny_write: dedupe([\n ...(base.agent?.permissions?.deny_write ?? []),\n ...(overlay.agent?.permissions?.deny_write ?? []),\n ]),\n deny_read: dedupe([\n ...(base.agent?.permissions?.deny_read ?? []),\n ...(overlay.agent?.permissions?.deny_read ?? []),\n ]),\n },\n subagents: {\n ...(base.agent?.subagents ?? {}),\n ...(overlay.agent?.subagents ?? {}),\n },\n hooks: {\n pre_flow: [\n ...(base.agent?.hooks?.pre_flow ?? []),\n ...(overlay.agent?.hooks?.pre_flow ?? []),\n ],\n post_flow: [\n ...(base.agent?.hooks?.post_flow ?? []),\n ...(overlay.agent?.hooks?.post_flow ?? []),\n ],\n pre_node: [\n ...(base.agent?.hooks?.pre_node ?? []),\n ...(overlay.agent?.hooks?.pre_node ?? []),\n ],\n post_node: [\n ...(base.agent?.hooks?.post_node ?? []),\n ...(overlay.agent?.hooks?.post_node ?? []),\n ],\n },\n },\n\n workspace: {\n directories: dedupe([\n ...(base.workspace?.directories ?? []),\n ...(overlay.workspace?.directories ?? []),\n ]),\n git: {\n init: overlay.workspace?.git?.init ?? base.workspace?.git?.init,\n ignore: dedupe([\n ...(base.workspace?.git?.ignore ?? []),\n ...(overlay.workspace?.git?.ignore ?? []),\n ]),\n },\n setup: overlay.workspace?.setup ?? base.workspace?.setup,\n container: overlay.workspace?.container ?? base.workspace?.container,\n },\n\n // secrets: overlay wins entirely\n secrets: overlay.secrets ?? base.secrets,\n\n // telemetry: overlay wins entirely (raw pass-through)\n telemetry: overlay.telemetry ?? base.telemetry,\n\n // repositories: always empty in merged output; the schema no longer\n // accepts this key. The internal install pipeline builds its own map\n // from `ai_resources[]` entries.\n repositories: {},\n\n // dependencies: concatenate and dedupe\n dependencies: dedupe([...(base.dependencies ?? []), ...(overlay.dependencies ?? [])]),\n };\n}\n\n// ── Raw → canonical normalization ─────────────────────────────────────────────\n\n/**\n * Normalize a raw parsed YAML object into the canonical SkWorkspaceConfig shape.\n * Handles backward-compatible fields:\n * - `agent-config` (hyphen) → `agent_config`\n * - `ai_resources` as object (old {sources, requires}) → AiResourceEntry[]\n * - `data_resources` → `connectors`\n * @docLink packages/core/workspace-config#normalize-config\n */\nexport function normalizeConfig(raw: Record<string, unknown>): SkWorkspaceConfig {\n const config: SkWorkspaceConfig = {};\n\n if (raw.name) config.name = String(raw.name);\n if (raw.description) config.description = String(raw.description);\n\n // agent_config: accept 'agent-config' (hyphen) or 'agent_config' (underscore)\n const agentConfigRaw = raw[\"agent-config\"] ?? raw.agent_config;\n if (agentConfigRaw && typeof agentConfigRaw === \"object\" && !Array.isArray(agentConfigRaw)) {\n config.agent_config = agentConfigRaw as Record<string, AgentConfigProfile>;\n }\n\n // startup\n if (Array.isArray(raw.startup)) {\n config.startup = raw.startup as StartupDirective[];\n }\n\n // ai_resources: support both old object {sources, requires} and new array [{name, path, dependencies}]\n const aiResRaw = raw.ai_resources;\n if (Array.isArray(aiResRaw)) {\n config.ai_resources = aiResRaw as AiResourceEntry[];\n } else if (aiResRaw && typeof aiResRaw === \"object\") {\n const old = aiResRaw as Record<string, unknown>;\n const sources = Array.isArray(old.sources) ? (old.sources as Record<string, unknown>[]) : [];\n const requires = Array.isArray(old.requires) ? (old.requires as string[]).filter(Boolean) : [];\n const autoDeploy = Boolean(old.auto_deploy ?? false);\n\n config.ai_resources = sources.map((s, i) => {\n const entry: AiResourceEntry = {\n name: String(s.name ?? \"\"),\n path: String(s.path ?? s.url ?? \"\"),\n };\n if (s.branch) entry.branch = String(s.branch);\n if (autoDeploy) entry.auto_deploy = true;\n // Attach global requires to first source\n if (i === 0 && requires.length > 0) entry.dependencies = requires;\n return entry;\n });\n }\n\n // mounts\n if (Array.isArray(raw.mounts)) {\n config.mounts = raw.mounts as MountDeclaration[];\n }\n\n // connectors (no data_resources fallback — clean break)\n if (Array.isArray(raw.connectors)) {\n config.connectors = raw.connectors as ConnectorDeclaration[];\n }\n\n // mcp_servers\n if (Array.isArray(raw.mcp_servers)) {\n config.mcp_servers = raw.mcp_servers as McpServerDeclaration[];\n }\n\n if (raw.agent) config.agent = raw.agent as AgentConfig;\n if (raw.workspace) config.workspace = raw.workspace as WorkspaceLayoutConfig;\n\n // secrets\n if (raw.secrets && typeof raw.secrets === \"object\") {\n config.secrets = raw.secrets as SecretsConfig;\n }\n\n // dependencies\n if (Array.isArray(raw.dependencies)) {\n config.dependencies = raw.dependencies.filter((d): d is string => typeof d === \"string\");\n }\n\n // telemetry: pass through raw object — parsed by @skaile/workspaces/telemetry\n if (raw.telemetry && typeof raw.telemetry === \"object\" && !Array.isArray(raw.telemetry)) {\n config.telemetry = raw.telemetry as Record<string, unknown>;\n }\n\n return config;\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────────────\n\nfunction parseConfigFile(filePath: string, name: string): SkWorkspaceConfigFile | null {\n let raw: string;\n try {\n raw = readFileSync(filePath, \"utf-8\");\n } catch {\n return null;\n }\n let parsed: Record<string, unknown>;\n try {\n parsed = (parse(raw) as Record<string, unknown>) ?? {};\n } catch {\n return null;\n }\n const config = normalizeConfig(parsed);\n return { path: filePath, name, config };\n}\n\nfunction dedupe(arr: string[]): string[] {\n return [...new Set(arr)];\n}\n\nfunction dedupeByKey<T extends object>(arr: T[], key: string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (let i = arr.length - 1; i >= 0; i--) {\n const val = String((arr[i] as any)[key] ?? \"\");\n if (!seen.has(val)) {\n seen.add(val);\n result.unshift(arr[i]!);\n }\n }\n return result;\n}\n\nfunction mergeById<T extends { id: string }>(base: T[], overlay: T[]): T[] {\n const map = new Map<string, T>();\n for (const r of base) map.set(r.id, r);\n for (const r of overlay) map.set(r.id, r);\n return [...map.values()];\n}\n\nfunction stripUndefined<T extends object>(obj?: T): Partial<T> {\n if (!obj) return {};\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n if (v !== undefined) result[k] = v;\n }\n return result as Partial<T>;\n}\n\n// ── MCP server loader ─────────────────────────────────────────────────────────\n\n/**\n * Build a `McpServerDeclaration` from a resolved `CatalogEntry` with `kind: \"mcp-server\"`.\n * Maps `metadata` fields (transport, command, args, env, url, headers) to declaration fields.\n * Returns `null` when the entry has no usable metadata (no command and no url).\n */\nfunction mcpDeclFromCatalogEntry(entry: CatalogEntry): McpServerDeclaration | null {\n const m = entry.metadata;\n if (!m) return null;\n\n const decl: McpServerDeclaration = { id: entry.name };\n if (m.transport) decl.transport = String(m.transport) as \"stdio\" | \"sse\" | \"http\";\n if (m.command) decl.command = String(m.command);\n if (Array.isArray(m.args)) decl.args = m.args.map(String);\n if (m.env && typeof m.env === \"object\") decl.env = m.env as Record<string, string>;\n if (m.url) decl.url = String(m.url);\n if (m.headers && typeof m.headers === \"object\") {\n decl.headers = m.headers as Record<string, string>;\n }\n if (entry.description) decl.description = entry.description;\n if (m.recipe && typeof m.recipe === \"object\" && !Array.isArray(m.recipe)) {\n const r = m.recipe as Record<string, unknown>;\n if (typeof r.attr === \"string\") {\n try {\n validateAssetRecipeAttr(r.attr);\n decl.recipe = { attr: r.attr };\n } catch (err) {\n // Invalid attr — skip the recipe field entirely (treat as if recipe was absent).\n // The MCP server may still be usable via a command/url without recipe substitution.\n console.warn(\n `[workspace-config] mcpDeclFromCatalogEntry: invalid recipe.attr for entry \"${entry.name}\": ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n }\n\n // Must have at least a command (stdio) or url (sse/http) to be useful\n if (!decl.command && !decl.url) return null;\n return decl;\n}\n\n/**\n * Merge two `McpServerDeclaration` objects field-by-field.\n * `overlay` values win for every non-undefined field; `base` provides defaults.\n */\nfunction mergeMcpDeclarations(\n base: McpServerDeclaration,\n overlay: McpServerDeclaration,\n): McpServerDeclaration {\n return {\n id: overlay.id,\n transport: overlay.transport ?? base.transport,\n command: overlay.command ?? base.command,\n args: overlay.args ?? base.args,\n env: overlay.env ? (base.env ? { ...base.env, ...overlay.env } : overlay.env) : base.env,\n url: overlay.url ?? base.url,\n headers: overlay.headers\n ? base.headers\n ? { ...base.headers, ...overlay.headers }\n : overlay.headers\n : base.headers,\n description: overlay.description ?? base.description,\n tags: overlay.tags ?? base.tags,\n recipe: overlay.recipe ?? base.recipe,\n };\n}\n\n/**\n * Load MCP server declarations by merging two sources:\n *\n * 1. **Catalog defaults** — `mcp-server:*` refs in the `dependencies` array\n * (or legacy `ai_resources[].dependencies`). Each ref is resolved from the\n * repository catalog; the `MCP.md` frontmatter provides default config\n * (transport, command, args, env, url, headers).\n *\n * 2. **Explicit declarations** — entries in the `mcp_servers` section of\n * `skaile.yaml`. These override catalog defaults field-by-field when the\n * `id` matches a catalog-resolved server name.\n *\n * This allows users to write `dependencies: [mcp:excel]` and get a working\n * server from catalog defaults, or add an `mcp_servers:` override to customize\n * specific fields (e.g. env vars, mount paths).\n *\n * @param projectDir - Workspace root where `skaile.yaml` lives\n * @returns Unified array of `McpServerDeclaration` objects ready for the runner\n * @docLink packages/core/workspace-config#load-mcp-server-declarations\n */\nexport function loadMcpServerDeclarations(projectDir: string): McpServerDeclaration[] {\n const config = resolveSkWorkspaceConfig(projectDir);\n const explicit = config.mcp_servers ?? [];\n\n // Collect all mcp-server refs from both dependency formats\n const mcpRefStrings: string[] = [];\n\n // New format: top-level dependencies\n for (const dep of config.dependencies ?? []) {\n const ref = parseAssetRef(dep);\n if (ref.kind === \"mcp-server\") mcpRefStrings.push(dep);\n }\n\n // Legacy format: ai_resources[].dependencies\n for (const res of config.ai_resources ?? []) {\n for (const dep of res.dependencies ?? []) {\n const ref = parseAssetRef(dep);\n if (ref.kind === \"mcp-server\") mcpRefStrings.push(dep);\n }\n }\n\n // No catalog refs — return explicit declarations as-is\n if (mcpRefStrings.length === 0) return explicit;\n\n // Resolve catalog entries\n const repositories = config.repositories ?? {};\n\n // Also build repositories from legacy ai_resources for backward compat\n const allRepos = { ...repositories };\n for (const res of config.ai_resources ?? []) {\n if (res.name && res.path && !(res.name in allRepos)) {\n allRepos[res.name] = {\n url: res.path.startsWith(\"/\") ? undefined : res.path,\n path: res.path.startsWith(\"/\") ? res.path : undefined,\n branch: res.branch,\n };\n }\n }\n\n const reposDir = getGlobalCacheDir();\n const explicitById = new Map(explicit.map((d) => [d.id, d]));\n const result: McpServerDeclaration[] = [];\n const seen = new Set<string>();\n\n for (const refStr of mcpRefStrings) {\n const ref = parseAssetRef(refStr);\n if (seen.has(ref.name)) continue;\n seen.add(ref.name);\n\n const entry = resolveAsset(ref, allRepos, reposDir, { projectDir });\n if (!entry) continue;\n\n const catalogDecl = mcpDeclFromCatalogEntry(entry);\n if (!catalogDecl) continue;\n\n // Merge with explicit override if present (explicit fields win)\n const override = explicitById.get(entry.name);\n if (override) {\n explicitById.delete(entry.name);\n result.push(mergeMcpDeclarations(catalogDecl, override));\n } else {\n result.push(catalogDecl);\n }\n }\n\n // Append remaining explicit-only declarations (no catalog match)\n for (const decl of explicitById.values()) {\n result.push(decl);\n }\n\n return result;\n}\n\n// ── Agent definition resolver ──────────────────────────────────────────────────\n\n/**\n * Walk upward from `from` (max 8 levels) until a directory containing\n * `ai-assets/` is found. Returns the absolute path to that `ai-assets/`\n * directory, or undefined if none found.\n */\nfunction findAiAssetsDir(from: string): string | undefined {\n let dir = resolve(from);\n for (let i = 0; i < 8; i++) {\n const candidate = join(dir, \"ai-assets\");\n if (existsSync(candidate)) return candidate;\n const resolved = resolve(dir, \"..\");\n if (resolved === dir) break;\n dir = resolved;\n }\n return undefined;\n}\n\n/**\n * Resolve the `agent.definition` field from `skaile.yaml` in `projectDir`\n * to an absolute filesystem path.\n *\n * Resolution rules:\n * - Absent or empty → undefined\n * - Relative/absolute local path → resolve(projectDir, definition)\n * - `ai-assets://<rest>` → walk up for ai-assets/, join with <rest>\n * - `agent:<name>` catalog refs → resolved via repository scanning\n *\n * Used by the runner to determine agentDir without requiring --agent-dir.\n * @docLink packages/core/workspace-config#resolve-agent-dir\n */\nexport function resolveAgentDir(projectDir: string): string | undefined {\n const config = resolveSkWorkspaceConfig(projectDir);\n const definition = config.agent?.definition;\n if (!definition) return undefined;\n\n // ai-assets:// URI\n if (definition.startsWith(\"ai-assets://\")) {\n const relPath = definition.slice(\"ai-assets://\".length);\n const aiAssetsDir = findAiAssetsDir(projectDir);\n if (!aiAssetsDir) return undefined;\n return join(aiAssetsDir, relPath);\n }\n\n // Catalog reference — resolve via repository scanning\n if (definition.startsWith(\"agent:\")) {\n const ref = parseAssetRef(definition);\n const repositories = config.repositories ?? {};\n const reposDir = getGlobalCacheDir();\n const entry = resolveAsset(ref, repositories, reposDir, { projectDir });\n if (!entry) return undefined;\n return dirname(entry.source);\n }\n\n // Local path (relative or absolute)\n return resolve(projectDir, definition);\n}\n"]}