{"version":3,"file":"domains-C_NtkCCi.mjs","names":["isRecord","requireRecord","optionalString","requireString","assertOnlyKeys","isFile","findMarketplace","readPluginManifestMetadata","discoverPluginRoot","discoverPluginFolder","parseMarketplace"],"sources":["../src/services/pluginCatalog/parse.ts","../src/services/pluginCatalog/sync.ts","../src/services/pluginCatalog/index.ts","../src/services/domains/completion.ts","../src/services/domains/core.ts","../src/services/domains/sync.ts","../src/services/domains/index.ts"],"sourcesContent":["/** Pure plugin catalog parsing shared by the async API and the deprecated Node-only sync shim. */\nimport crypto from 'node:crypto';\nimport path from 'node:path';\n\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\nimport { exactPackageVersion, marketplaceOrigin, sha512Integrity } from '@agimon-ai/po-core/verifiedArchive';\n\nimport type { GitPluginSource, PluginCatalogEntry, PluginManifestMetadata, PluginSource } from '../../types/domains';\n\nexport const AGENT_PLUGIN_SCHEMA_PREFIX = 'https://agent-plugins.org/schemas/';\nconst CACHE_DIRECTORY = 'plugin-cache';\nconst PLUGIN_ID_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\nconst NPM_PACKAGE_NAME = /^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/;\nexport const LEGACY_PLUGIN_MANIFEST_PATHS = [\n  '.codex-plugin/plugin.json',\n  '.claude-plugin/plugin.json',\n  '.cursor-plugin/plugin.json',\n] as const;\n\nexport const MARKETPLACE_MANIFEST_RELATIVE_PATHS = [\n  '.agents/plugins/marketplace.json',\n  '.agents/plugins/api_marketplace.json',\n  '.claude-plugin/marketplace.json',\n  '.cursor-plugin/marketplace.json',\n] as const;\n\nexport interface PluginCatalogConfigSource {\n  filePath: string;\n  baseDirectory: string;\n  value: unknown;\n}\n\nexport interface MarketplaceLocation {\n  manifestPath: string;\n  root: string;\n}\n\ninterface ParsedConfiguredEntry {\n  source: PluginSource;\n  description?: string;\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function requireRecord(value: unknown, label: string): Record<string, unknown> {\n  if (!isRecord(value)) throw new Error(`${label} must be an object`);\n  return value;\n}\n\nexport function optionalString(value: unknown, label: string): string | undefined {\n  if (value === undefined) return undefined;\n  if (typeof value !== 'string' || !value.trim()) throw new Error(`${label} must be a non-empty string`);\n  return value.trim();\n}\n\nexport function requireString(value: unknown, label: string): string {\n  const result = optionalString(value, label);\n  if (!result) throw new Error(`${label} must be a non-empty string`);\n  return result;\n}\n\nfunction assertOnlyKeys(record: Record<string, unknown>, allowed: readonly string[], label: string): void {\n  const unexpected = Object.keys(record).filter((key) => !allowed.includes(key));\n  if (unexpected.length > 0) throw new Error(`${label} contains unsupported field \"${unexpected[0]}\"`);\n}\n\nexport function validatePluginIdSegment(value: string, label: string): void {\n  if (!PLUGIN_ID_SEGMENT.test(value)) {\n    throw new Error(`${label} must start with an alphanumeric character and contain only alphanumerics, ., _, or -`);\n  }\n}\n\nfunction validatePluginId(value: string, label: string): void {\n  const segments = value.split('@');\n  if (segments.length > 2 || segments.some((segment) => !PLUGIN_ID_SEGMENT.test(segment))) {\n    throw new Error(`${label} must be a plugin name or plugin@marketplace identifier`);\n  }\n}\n\nfunction normalizeRemoteSubdirectory(value: unknown, label: string): string | undefined {\n  const raw = optionalString(value, label);\n  if (!raw) return undefined;\n  const normalized = raw.replaceAll('\\\\', '/').replace(/^\\.\\//, '');\n  if (\n    normalized.startsWith('/') ||\n    normalized.split('/').some((segment) => segment === '' || segment === '.' || segment === '..')\n  ) {\n    throw new Error(`${label} must stay within the remote repository root`);\n  }\n  return normalized;\n}\n\nfunction normalizeGitUrl(value: unknown, baseDirectory: string, label: string): string {\n  const url = requireString(value, label);\n  if (/^(?:https?|ssh|file):\\/\\//.test(url) || /^git@[^:]+:.+/.test(url) || path.isAbsolute(url)) return url;\n  if (url.startsWith('./') || url.startsWith('.\\\\')) {\n    const relative = url.replaceAll('\\\\', '/').slice(2);\n    if (!relative || relative.split('/').some((segment) => segment === '' || segment === '.' || segment === '..')) {\n      throw new Error(`${label} must stay within its declaring root`);\n    }\n    return path.resolve(baseDirectory, relative);\n  }\n  if (/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+(?:\\.git)?$/.test(url)) {\n    return `https://github.com/${url.endsWith('.git') ? url : `${url}.git`}`;\n  }\n  throw new Error(`${label} is not a supported Git URL`);\n}\n\nfunction resolveMarketplaceLocalPath(rawPath: string, marketplace: MarketplaceLocation, label: string): string {\n  if (rawPath === '.' || rawPath === './') return marketplace.root;\n  const cursorMarketplace = marketplace.manifestPath.endsWith('.cursor-plugin/marketplace.json');\n  const relative = rawPath.startsWith('./') ? rawPath.slice(2) : cursorMarketplace ? rawPath : undefined;\n  if (!relative) throw new Error(`${label} must start with ./`);\n  const normalized = relative.replaceAll('\\\\', '/');\n  if (normalized.split('/').some((segment) => segment === '' || segment === '.' || segment === '..')) {\n    throw new Error(`${label} must stay within the marketplace root`);\n  }\n  return path.resolve(marketplace.root, normalized);\n}\n\nfunction parseSourceObject(\n  value: Record<string, unknown>,\n  baseDirectory: string,\n  label: string,\n  marketplace?: MarketplaceLocation,\n): PluginSource {\n  const sourceType = requireString(value.source, `${label}.source`);\n  if (sourceType === 'local') {\n    assertOnlyKeys(value, ['source', 'path', 'description'], label);\n    const rawPath = requireString(value.path, `${label}.path`);\n    return {\n      type: 'local',\n      path: marketplace\n        ? resolveMarketplaceLocalPath(rawPath, marketplace, `${label}.path`)\n        : path.resolve(baseDirectory, rawPath),\n    };\n  }\n  if (sourceType === 'url' || sourceType === 'git-subdir') {\n    assertOnlyKeys(value, ['source', 'url', 'path', 'ref', 'sha', 'description'], label);\n    const remotePath = normalizeRemoteSubdirectory(value.path, `${label}.path`);\n    if (sourceType === 'git-subdir' && !remotePath) {\n      throw new Error(`${label}.path must be a non-empty string for git-subdir sources`);\n    }\n    const ref = optionalString(value.ref, `${label}.ref`);\n    const sha = optionalString(value.sha, `${label}.sha`);\n    return {\n      type: 'git',\n      url: normalizeGitUrl(value.url, marketplace?.root ?? baseDirectory, `${label}.url`),\n      ...(remotePath ? { path: remotePath } : {}),\n      ...(ref ? { ref } : {}),\n      ...(sha ? { sha } : {}),\n    };\n  }\n  if (sourceType === 'npm') {\n    assertOnlyKeys(value, ['source', 'package', 'version', 'registry', 'integrity', 'description'], label);\n    const packageName = requireString(value.package, `${label}.package`);\n    if (!NPM_PACKAGE_NAME.test(packageName)) throw new Error(`${label}.package must be a valid npm package name`);\n    const version = optionalString(value.version, `${label}.version`);\n    const registry = optionalString(value.registry, `${label}.registry`);\n    const integrity = optionalString(value.integrity, `${label}.integrity`);\n    if (integrity && (!sha512Integrity.test(integrity) || !version || !exactPackageVersion.test(version))) {\n      throw new Error(`${label} requires an exact version and valid SHA-512 integrity`);\n    }\n    return {\n      type: 'npm',\n      package: packageName,\n      ...(version ? { version } : {}),\n      ...(registry ? { registry } : {}),\n      ...(integrity ? { integrity } : {}),\n    };\n  }\n  throw new Error(`${label}.source must be local, url, git-subdir, or npm`);\n}\n\nfunction parsePluginSource(\n  value: unknown,\n  baseDirectory: string,\n  label: string,\n  marketplace?: MarketplaceLocation,\n): PluginSource {\n  if (typeof value === 'string') {\n    const rawPath = requireString(value, label);\n    return {\n      type: 'local',\n      path: marketplace\n        ? resolveMarketplaceLocalPath(rawPath, marketplace, label)\n        : path.resolve(baseDirectory, rawPath),\n    };\n  }\n  return parseSourceObject(requireRecord(value, label), baseDirectory, label, marketplace);\n}\n\nfunction parseConfiguredEntry(value: unknown, baseDirectory: string, label: string): ParsedConfiguredEntry {\n  if (typeof value === 'string') return { source: parsePluginSource(value, baseDirectory, label) };\n  const record = requireRecord(value, label);\n  const description = optionalString(record.description, `${label}.description`);\n  if (record.source === undefined && typeof record.path === 'string') {\n    assertOnlyKeys(record, ['path', 'description'], label);\n    return {\n      source: { type: 'local', path: path.resolve(baseDirectory, requireString(record.path, `${label}.path`)) },\n      ...(description ? { description } : {}),\n    };\n  }\n  if (typeof record.source === 'string' && !['local', 'url', 'git-subdir', 'npm'].includes(record.source)) {\n    assertOnlyKeys(record, ['source', 'description'], label);\n    return {\n      source: parsePluginSource(record.source, baseDirectory, `${label}.source`),\n      ...(description ? { description } : {}),\n    };\n  }\n  if (isRecord(record.source)) {\n    assertOnlyKeys(record, ['source', 'description'], label);\n    return {\n      source: parsePluginSource(record.source, baseDirectory, `${label}.source`),\n      ...(description ? { description } : {}),\n    };\n  }\n  return {\n    source: parseSourceObject(record, baseDirectory, label),\n    ...(description ? { description } : {}),\n  };\n}\n\nexport function marketplaceRootFromManifest(manifestPath: string): string | undefined {\n  const normalized = path.resolve(manifestPath);\n  for (const relativePath of MARKETPLACE_MANIFEST_RELATIVE_PATHS) {\n    const suffix = path.normalize(relativePath);\n    if (!normalized.endsWith(suffix)) continue;\n    let root = normalized;\n    for (const _segment of relativePath.split('/')) root = path.dirname(root);\n    return root;\n  }\n  return undefined;\n}\n\nexport function parseJsonRecord(text: string, filePath: string, label: string): Record<string, unknown> {\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(text) as unknown;\n  } catch (error) {\n    throw new Error(\n      `${label} at ${filePath} is invalid JSON: ${error instanceof Error ? error.message : String(error)}`,\n    );\n  }\n  return requireRecord(parsed, `${label} at ${filePath}`);\n}\n\n/** True when a root plugin.json opts into the Agent Plugins schema, which outranks legacy manifests. */\nexport function isAgentPluginRootManifest(text: string): boolean {\n  const parsed = JSON.parse(text) as unknown;\n  const schema = isRecord(parsed) && typeof parsed.$schema === 'string' ? parsed.$schema : undefined;\n  return schema?.startsWith(AGENT_PLUGIN_SCHEMA_PREFIX) ?? false;\n}\n\nexport function manifestMetadataFromRecord(\n  manifestPath: string,\n  manifest: Record<string, unknown>,\n): PluginManifestMetadata {\n  const schema = optionalString(manifest.$schema, `${manifestPath}.$schema`);\n  const name = optionalString(manifest.name, `${manifestPath}.name`);\n  const version = optionalString(manifest.version, `${manifestPath}.version`);\n  const description = optionalString(manifest.description, `${manifestPath}.description`);\n  return {\n    path: manifestPath,\n    ...(name ? { name } : {}),\n    ...(version ? { version } : {}),\n    ...(description ? { description } : {}),\n    ...(schema?.startsWith(AGENT_PLUGIN_SCHEMA_PREFIX) ? { agentPluginSchema: schema } : {}),\n  };\n}\n\n/** Entry for a discovered plugin root, or undefined after recording why its name is invalid. */\nexport function discoveredPluginEntry(\n  pluginRoot: string,\n  manifest: PluginManifestMetadata,\n  diagnostics: string[],\n): { name: string; entry: PluginCatalogEntry } | undefined {\n  const name = manifest.name ?? path.basename(pluginRoot);\n  try {\n    validatePluginIdSegment(name, `Plugin name in ${manifest.path}`);\n  } catch (error) {\n    diagnostics.push(error instanceof Error ? error.message : String(error));\n    return undefined;\n  }\n  return {\n    name,\n    entry: {\n      source: { type: 'local', path: pluginRoot },\n      ...(manifest.description ? { description: manifest.description } : {}),\n      manifest,\n    },\n  };\n}\n\nexport interface MarketplaceDocument {\n  name: string;\n  plugins: unknown[];\n}\n\nexport function parseMarketplaceDocument(\n  marketplace: MarketplaceLocation,\n  document: Record<string, unknown>,\n): MarketplaceDocument {\n  const name = requireString(document.name, `${marketplace.manifestPath}.name`);\n  validatePluginIdSegment(name, `${marketplace.manifestPath}.name`);\n  if (!Array.isArray(document.plugins)) throw new Error(`${marketplace.manifestPath}.plugins must be an array`);\n  return { name, plugins: document.plugins };\n}\n\nexport interface ParsedMarketplacePlugin {\n  id: string;\n  source: PluginSource;\n  description?: string;\n}\n\n/** One marketplace plugin, or undefined when an earlier entry already claimed its id. Throws on invalid input. */\nexport function parseMarketplacePlugin(\n  marketplace: MarketplaceLocation,\n  document: MarketplaceDocument,\n  index: number,\n  entries: Record<string, PluginCatalogEntry>,\n): ParsedMarketplacePlugin | undefined {\n  const label = `${marketplace.manifestPath}.plugins[${index}]`;\n  const plugin = requireRecord(document.plugins[index], label);\n  const pluginName = requireString(plugin.name, `${label}.name`);\n  validatePluginIdSegment(pluginName, `${label}.name`);\n  const id = `${pluginName}@${document.name}`;\n  if (Object.hasOwn(entries, id)) return undefined;\n  const source = parsePluginSource(plugin.source, marketplace.root, `${label}.source`, marketplace);\n  const description = optionalString(plugin.description, `${label}.description`);\n  return { id, source, ...(description ? { description } : {}) };\n}\n\nexport function catalogEntry(\n  source: PluginSource,\n  description: string | undefined,\n  manifest: PluginManifestMetadata | undefined,\n  marketplace?: string,\n): PluginCatalogEntry {\n  const resolvedDescription = description ?? manifest?.description;\n  return {\n    source,\n    ...(marketplace ? { marketplace } : {}),\n    ...(resolvedDescription ? { description: resolvedDescription } : {}),\n    ...(manifest ? { manifest } : {}),\n  };\n}\n\nexport function parseConfiguredRoots(source: PluginCatalogConfigSource): string[] {\n  if (source.value === undefined) return [];\n  const document = requireRecord(source.value, `plugins in ${source.filePath}`);\n  assertOnlyKeys(document, ['roots', 'entries', 'standalone', 'disabled'], `plugins in ${source.filePath}`);\n  if (document.roots === undefined) return [];\n  if (!Array.isArray(document.roots)) throw new Error(`plugins.roots in ${source.filePath} must be an array`);\n  return document.roots.map((root, index) =>\n    path.resolve(source.baseDirectory, requireString(root, `plugins.roots[${index}] in ${source.filePath}`)),\n  );\n}\n\n/**\n * The plugin IDs one source lists under `plugins.standalone` (load in every session) or\n * `plugins.disabled` (never load). Throws on the first invalid value.\n */\nexport function parseConfiguredPluginList(source: PluginCatalogConfigSource, key: 'standalone' | 'disabled'): string[] {\n  if (source.value === undefined) return [];\n  const document = requireRecord(source.value, `plugins in ${source.filePath}`);\n  const value = document[key];\n  if (value === undefined) return [];\n  if (!Array.isArray(value)) throw new Error(`plugins.${key} in ${source.filePath} must be an array`);\n  return value.map((name, index) => requireString(name, `plugins.${key}[${index}] in ${source.filePath}`));\n}\n\n/** Validates the configured `plugins.entries` of one source. Throws on the first invalid entry. */\nexport function parseConfiguredEntries(\n  source: PluginCatalogConfigSource,\n): Array<{ name: string; source: PluginSource; description?: string }> {\n  if (source.value === undefined) return [];\n  const document = requireRecord(source.value, `plugins in ${source.filePath}`);\n  if (document.entries === undefined) return [];\n  const configuredEntries = requireRecord(document.entries, `plugins.entries in ${source.filePath}`);\n  return Object.entries(configuredEntries).map(([name, value]) => {\n    validatePluginId(name, `Plugin entry \"${name}\" in ${source.filePath}`);\n    const parsed = parseConfiguredEntry(value, source.baseDirectory, `plugins.entries.${name} in ${source.filePath}`);\n    return { name, ...parsed };\n  });\n}\n\nexport function pluginDirectoryForSource(source: PluginSource, homePoDirectory: string): string {\n  if (source.type === 'local') return source.path;\n  const identity =\n    source.type === 'git'\n      ? ['git', source.url, source.path ?? '', source.ref ?? '', source.sha ?? '']\n      : [\n          'npm',\n          source.package,\n          source.version ?? '',\n          source.registry ?? '',\n          ...(source.integrity ? [source.integrity] : []),\n        ];\n  const digest = crypto.createHash('sha256').update(JSON.stringify(identity)).digest('hex');\n  return path.join(homePoDirectory, CACHE_DIRECTORY, digest);\n}\n\n/** Private generated snapshot, never a user-owned marketplace manifest. */\nexport function marketplaceSnapshotPath(\n  homeDirectory: string,\n  environment: Readonly<Record<string, string | undefined>>,\n  origin: string,\n): string {\n  const authority = marketplaceOrigin(origin);\n  const digest = crypto.createHash('sha256').update(authority).digest('hex');\n  return path.join(poHomeDirectory(homeDirectory, environment), 'marketplace', digest, 'catalog.json');\n}\n\n/** Validate the entire snapshot before admitting any remote entry. Local explicit entries still win. */\nexport function marketplaceSnapshotEntries(text: string, origin: string): Record<string, PluginCatalogEntry> {\n  if (text.length > 2 * 1024 * 1024) throw new Error('Marketplace snapshot exceeds the size limit');\n  const authority = marketplaceOrigin(origin);\n  const snapshot = requireRecord(JSON.parse(text), 'Marketplace snapshot');\n  if (snapshot.origin !== authority) throw new Error('Marketplace snapshot authority mismatch');\n  const document = requireRecord(snapshot.document, 'Marketplace snapshot document');\n  if (document.version !== 1) throw new Error('Unsupported marketplace snapshot version');\n  const location = { root: '/', manifestPath: `${authority}/marketplace/v1/catalog.json` };\n  const remote = parseMarketplaceDocument(location, requireRecord(document.marketplace, 'Marketplace document'));\n  const entries: Record<string, PluginCatalogEntry> = {};\n  for (let index = 0; index < remote.plugins.length; index += 1) {\n    const plugin = parseMarketplacePlugin(location, remote, index, entries);\n    if (!plugin) throw new Error('Duplicate marketplace plugin id');\n    if (\n      plugin.source.type !== 'npm' ||\n      !plugin.source.integrity ||\n      !plugin.source.version ||\n      !exactPackageVersion.test(plugin.source.version) ||\n      !sha512Integrity.test(plugin.source.integrity)\n    ) {\n      throw new Error('Marketplace plugins require pinned npm sources');\n    }\n    entries[plugin.id] = {\n      ...catalogEntry(\n        { ...plugin.source, registry: `${authority}/registry` },\n        plugin.description,\n        undefined,\n        remote.name,\n      ),\n      available: {\n        origin: authority,\n        package: plugin.source.package,\n        version: plugin.source.version,\n        integrity: plugin.source.integrity,\n      },\n    };\n  }\n  return entries;\n}\n\nexport function isRemotePluginSource(\n  source: PluginSource,\n): source is GitPluginSource | Extract<PluginSource, { type: 'npm' }> {\n  return source.type !== 'local';\n}\n\n/** Host-owned receipt lookup is scope-bound, not origin-bound: changing authority must never hide an accepted pin. */\nexport function marketplaceInstalledPath(\n  homeDirectory: string,\n  environment: Readonly<Record<string, string | undefined>>,\n  origin: string,\n  workspaceRoot?: string,\n): string {\n  const scope =\n    workspaceRoot && path.resolve(workspaceRoot) !== path.resolve(homeDirectory)\n      ? crypto.createHash('sha256').update(path.resolve(workspaceRoot)).digest('hex')\n      : 'host';\n  return path.join(\n    path.dirname(path.dirname(marketplaceSnapshotPath(homeDirectory, environment, origin))),\n    `installed-${scope}.json`,\n  );\n}\n\n/** Read only from marketplaceInstalledPath, never from plugins fields or repository-authored receipts. */\nexport function marketplaceInstalledEntries(text: string, origin: string): Record<string, PluginCatalogEntry | null> {\n  if (text.length > 2 * 1024 * 1024) throw new Error('Installed marketplace receipts exceed the size limit');\n  const authority = marketplaceOrigin(origin);\n  const receipt = requireRecord(JSON.parse(text), 'Installed marketplace receipt');\n  if (receipt.version !== 1) throw new Error('Unsupported installed marketplace receipt version');\n  const entries: Record<string, PluginCatalogEntry | null> = {};\n  for (const [id, value] of Object.entries(requireRecord(receipt.entries, 'Installed marketplace entries'))) {\n    // An explicit release in a workspace also masks an inherited host receipt, without approving a replacement.\n    if (value === null) {\n      entries[id] = null;\n      continue;\n    }\n    const record = requireRecord(value, `Installed marketplace plugin ${id}`);\n    const marketplace = requireString(record.marketplace, `Installed marketplace plugin ${id}.marketplace`);\n    const plugin = id.slice(0, -(marketplace.length + 1));\n    const approvedOrigin = marketplaceOrigin(requireString(record.origin, `Installed marketplace plugin ${id}.origin`));\n    if (!id.endsWith(`@${marketplace}`) || record.origin !== approvedOrigin)\n      throw new Error('Installed marketplace plugin identity mismatch');\n    const normalized = marketplaceSnapshotEntries(\n      JSON.stringify({\n        origin: approvedOrigin,\n        document: {\n          version: 1,\n          marketplace: {\n            name: marketplace,\n            plugins: [\n              {\n                name: plugin,\n                description: record.description,\n                source: {\n                  source: 'npm',\n                  package: record.package,\n                  version: record.version,\n                  integrity: record.integrity,\n                },\n              },\n            ],\n          },\n        },\n      }),\n      approvedOrigin,\n    )[id];\n    if (!normalized?.available) throw new Error('Invalid installed marketplace plugin');\n    const { available, ...entry } = normalized;\n    entries[id] = {\n      ...entry,\n      installed: available,\n      ...(approvedOrigin !== authority ? { authorityMismatch: true } : {}),\n    };\n  }\n  return entries;\n}\n","// sync: These helpers implement exported Node-only synchronous plugin catalog APIs.\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { marketplaceOrigin } from '@agimon-ai/po-core/verifiedArchive';\n\nimport type { PluginCatalog, PluginCatalogEntry, PluginManifestMetadata } from '../../types/domains';\nimport { configFromText, globalPoConfigPath } from '../config/core';\nimport {\n  LEGACY_PLUGIN_MANIFEST_PATHS,\n  MARKETPLACE_MANIFEST_RELATIVE_PATHS,\n  type MarketplaceLocation,\n  type PluginCatalogConfigSource,\n  catalogEntry,\n  discoveredPluginEntry,\n  isAgentPluginRootManifest,\n  manifestMetadataFromRecord,\n  marketplaceSnapshotPath,\n  marketplaceSnapshotEntries,\n  marketplaceInstalledPath,\n  marketplaceInstalledEntries,\n  marketplaceRootFromManifest,\n  parseConfiguredEntries,\n  parseConfiguredRoots,\n  parseJsonRecord,\n  parseMarketplaceDocument,\n  parseMarketplacePlugin,\n} from './parse';\n\nfunction isFile(filePath: string): boolean {\n  return fs.existsSync(filePath) && fs.statSync(filePath).isFile();\n}\n\nfunction findMarketplace(rootOrManifest: string): MarketplaceLocation | undefined {\n  if (isFile(rootOrManifest)) {\n    const root = marketplaceRootFromManifest(rootOrManifest);\n    return root ? { manifestPath: path.resolve(rootOrManifest), root } : undefined;\n  }\n  for (const relativePath of MARKETPLACE_MANIFEST_RELATIVE_PATHS) {\n    const manifestPath = path.join(rootOrManifest, relativePath);\n    if (isFile(manifestPath)) return { manifestPath: path.resolve(manifestPath), root: path.resolve(rootOrManifest) };\n  }\n  return undefined;\n}\n\n/**\n * Matches Codex manifest precedence, including schema-gated root plugin.json.\n * @deprecated Node-only sync shim; use findPluginManifestPathAsync. Removed in M2.\n */\nexport function findPluginManifestPath(pluginRoot: string): string | undefined {\n  const rootManifest = path.join(pluginRoot, 'plugin.json');\n  try {\n    const metadata = fs.lstatSync(rootManifest);\n    if (metadata.isSymbolicLink() || !metadata.isFile()) return undefined;\n    if (isAgentPluginRootManifest(fs.readFileSync(rootManifest, 'utf8'))) return rootManifest;\n  } catch {\n    // A missing, unreadable, or unrelated root manifest does not outrank legacy manifests.\n  }\n  return LEGACY_PLUGIN_MANIFEST_PATHS.map((relativePath) => path.join(pluginRoot, relativePath)).find(isFile);\n}\n\nfunction readPluginManifestMetadata(pluginRoot: string, diagnostics: string[]): PluginManifestMetadata | undefined {\n  const manifestPath = findPluginManifestPath(pluginRoot);\n  if (!manifestPath) return undefined;\n  try {\n    const manifest = parseJsonRecord(fs.readFileSync(manifestPath, 'utf8'), manifestPath, 'Plugin manifest');\n    return manifestMetadataFromRecord(manifestPath, manifest);\n  } catch (error) {\n    diagnostics.push(error instanceof Error ? error.message : String(error));\n    return { path: manifestPath };\n  }\n}\n\nfunction discoverPluginRoot(\n  pluginRoot: string,\n  entries: Record<string, PluginCatalogEntry>,\n  diagnostics: string[],\n): boolean {\n  const diagnosticCount = diagnostics.length;\n  const manifest = readPluginManifestMetadata(pluginRoot, diagnostics);\n  if (!manifest || diagnostics.length !== diagnosticCount) return false;\n  const discovered = discoveredPluginEntry(pluginRoot, manifest, diagnostics);\n  if (!discovered) return false;\n  entries[discovered.name] = discovered.entry;\n  return true;\n}\n\nfunction discoverPluginFolder(\n  root: string,\n  entries: Record<string, PluginCatalogEntry>,\n  diagnostics: string[],\n): number {\n  if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) return 0;\n  if (findPluginManifestPath(root)) return discoverPluginRoot(root, entries, diagnostics) ? 1 : 0;\n\n  let discovered = 0;\n  const children = fs\n    .readdirSync(root, { withFileTypes: true })\n    .filter((entry) => entry.isDirectory())\n    .sort((left, right) => left.name.localeCompare(right.name));\n  for (const child of children) {\n    if (discoverPluginRoot(path.join(root, child.name), entries, diagnostics)) discovered += 1;\n  }\n  return discovered;\n}\n\nfunction parseMarketplace(\n  marketplace: MarketplaceLocation,\n  entries: Record<string, PluginCatalogEntry>,\n  diagnostics: string[],\n): void {\n  const record = parseJsonRecord(\n    fs.readFileSync(marketplace.manifestPath, 'utf8'),\n    marketplace.manifestPath,\n    'Marketplace manifest',\n  );\n  const document = parseMarketplaceDocument(marketplace, record);\n  for (let index = 0; index < document.plugins.length; index += 1) {\n    try {\n      const plugin = parseMarketplacePlugin(marketplace, document, index, entries);\n      if (!plugin) continue;\n      const manifest =\n        plugin.source.type === 'local' ? readPluginManifestMetadata(plugin.source.path, diagnostics) : undefined;\n      entries[plugin.id] = catalogEntry(plugin.source, plugin.description, manifest, document.name);\n    } catch (error) {\n      diagnostics.push(error instanceof Error ? error.message : String(error));\n    }\n  }\n}\n\n/** @deprecated Node-only sync shim; use loadPluginCatalogAsync. Removed in M2. */\nexport function loadPluginCatalog(\n  sources: readonly PluginCatalogConfigSource[],\n  repoRoot: string,\n  homeDirectory: string,\n  environment: Readonly<Record<string, string | undefined>> = {},\n): PluginCatalog {\n  const diagnostics: string[] = [];\n  const entries: Record<string, PluginCatalogEntry> = {};\n  const roots = [...new Set(sources.flatMap(parseConfiguredRoots))];\n  const candidates = [homeDirectory, repoRoot, ...roots];\n  const marketplaces: string[] = [];\n  const seenMarketplaces = new Set<string>();\n\n  for (const candidate of candidates) {\n    const marketplace = findMarketplace(candidate);\n    if (!marketplace) continue;\n    if (seenMarketplaces.has(marketplace.manifestPath)) continue;\n    seenMarketplaces.add(marketplace.manifestPath);\n    marketplaces.push(marketplace.manifestPath);\n    try {\n      parseMarketplace(marketplace, entries, diagnostics);\n    } catch (error) {\n      diagnostics.push(error instanceof Error ? error.message : String(error));\n    }\n  }\n\n  for (const root of roots) {\n    if (findMarketplace(root)) continue;\n    if (discoverPluginFolder(root, entries, diagnostics) === 0) {\n      diagnostics.push(`Plugin root contains neither a supported marketplace nor discoverable plugins: ${root}`);\n    }\n  }\n\n  const configPath = globalPoConfigPath(homeDirectory, environment);\n  const config = configFromText(\n    fs.existsSync(configPath) ? fs.readFileSync(configPath, 'utf8') : undefined,\n    configPath,\n  );\n  const origin = marketplaceOrigin(config.marketplace?.url);\n  let remoteEntries: Record<string, PluginCatalogEntry> = {};\n  try {\n    const snapshotPath = marketplaceSnapshotPath(homeDirectory, environment, origin);\n    if (fs.existsSync(snapshotPath)) {\n      remoteEntries = marketplaceSnapshotEntries(fs.readFileSync(snapshotPath, 'utf8'), origin);\n      for (const [id, entry] of Object.entries(remoteEntries)) {\n        if (!Object.hasOwn(entries, id)) entries[id] = entry;\n      }\n    }\n  } catch (error) {\n    diagnostics.push(error instanceof Error ? error.message : String(error));\n  }\n\n  for (const source of sources) {\n    for (const parsed of parseConfiguredEntries(source)) {\n      const manifest =\n        parsed.source.type === 'local' ? readPluginManifestMetadata(parsed.source.path, diagnostics) : undefined;\n      entries[parsed.name] = catalogEntry(parsed.source, parsed.description, manifest);\n    }\n  }\n  const uninstalledEntries = { ...entries };\n  for (const file of new Set([\n    marketplaceInstalledPath(homeDirectory, environment, origin),\n    marketplaceInstalledPath(homeDirectory, environment, origin, repoRoot),\n  ])) {\n    if (!fs.existsSync(file)) continue;\n    for (const [id, installed] of Object.entries(marketplaceInstalledEntries(fs.readFileSync(file, 'utf8'), origin))) {\n      if (installed === null) {\n        if (uninstalledEntries[id]) entries[id] = uninstalledEntries[id];\n        else delete entries[id];\n        continue;\n      }\n      const candidate = remoteEntries[id]?.available;\n      entries[id] = {\n        ...installed,\n        ...(candidate?.package === installed.installed?.package ? { available: candidate } : {}),\n      };\n    }\n  }\n  return { roots, marketplaces, entries, diagnostics };\n}\n","import path from 'node:path';\n\nimport { type FileSystem, getOrThrow, readTextIfExists } from '@agimon-ai/po-core/platform';\n\nimport type { PluginCatalog, PluginCatalogEntry, PluginManifestMetadata } from '../../types/domains';\nimport { readHostMarketplaceOrigin } from '../config';\nimport {\n  LEGACY_PLUGIN_MANIFEST_PATHS,\n  MARKETPLACE_MANIFEST_RELATIVE_PATHS,\n  type MarketplaceLocation,\n  type PluginCatalogConfigSource,\n  catalogEntry,\n  discoveredPluginEntry,\n  isAgentPluginRootManifest,\n  manifestMetadataFromRecord,\n  marketplaceSnapshotEntries,\n  marketplaceSnapshotPath,\n  marketplaceInstalledEntries,\n  marketplaceInstalledPath,\n  marketplaceRootFromManifest,\n  parseConfiguredEntries,\n  parseConfiguredRoots,\n  parseJsonRecord,\n  parseMarketplaceDocument,\n  parseMarketplacePlugin,\n} from './parse';\n\ntype Context = Parameters<FileSystem['readTextFile']>[1];\n\nexport {\n  MARKETPLACE_MANIFEST_RELATIVE_PATHS,\n  isRemotePluginSource,\n  parseConfiguredPluginList,\n  pluginDirectoryForSource,\n  type PluginCatalogConfigSource,\n  marketplaceSnapshotPath,\n  marketplaceSnapshotEntries,\n  marketplaceInstalledEntries,\n  marketplaceInstalledPath,\n} from './parse';\nexport { readHostMarketplaceOrigin } from '../config';\nexport { findPluginManifestPath, loadPluginCatalog } from './sync';\n\n/** Kind of the file a path names after following symbolic links, or undefined when nothing is there. */\nasync function resolvedKind(\n  fs: FileSystem,\n  filePath: string,\n  context: Context,\n): Promise<'file' | 'directory' | 'symlink' | undefined> {\n  const info = await fs.fileInfo(filePath, context);\n  if (!info.ok) {\n    if (info.error.code === 'not_found') return undefined;\n    throw info.error;\n  }\n  if (info.value.kind !== 'symlink') return info.value.kind;\n  const target = await fs.canonicalPath(filePath, context);\n  if (!target.ok && target.error.code === 'not_found') return undefined;\n  const targetInfo = await fs.fileInfo(getOrThrow(target), context);\n  if (!targetInfo.ok && targetInfo.error.code === 'not_found') return undefined;\n  return getOrThrow(targetInfo).kind;\n}\n\nasync function isFile(fs: FileSystem, filePath: string, context: Context): Promise<boolean> {\n  return (await resolvedKind(fs, filePath, context)) === 'file';\n}\n\nasync function findMarketplace(\n  fs: FileSystem,\n  rootOrManifest: string,\n  context: Context,\n): Promise<MarketplaceLocation | undefined> {\n  if (await isFile(fs, rootOrManifest, context)) {\n    const root = marketplaceRootFromManifest(rootOrManifest);\n    return root ? { manifestPath: path.resolve(rootOrManifest), root } : undefined;\n  }\n  for (const relativePath of MARKETPLACE_MANIFEST_RELATIVE_PATHS) {\n    const manifestPath = path.join(rootOrManifest, relativePath);\n    if (await isFile(fs, manifestPath, context)) {\n      return { manifestPath: path.resolve(manifestPath), root: path.resolve(rootOrManifest) };\n    }\n  }\n  return undefined;\n}\n\nasync function readText(fs: FileSystem, filePath: string, context: Context): Promise<string> {\n  return getOrThrow(await fs.readTextFile(filePath, context));\n}\n\n/** Matches Codex manifest precedence, including schema-gated root plugin.json. */\nexport async function findPluginManifestPathAsync(\n  fs: FileSystem,\n  pluginRoot: string,\n  context: Context,\n): Promise<string | undefined> {\n  const rootManifest = path.join(pluginRoot, 'plugin.json');\n  try {\n    const metadata = getOrThrow(await fs.fileInfo(rootManifest, context));\n    if (metadata.kind !== 'file') return undefined;\n    if (isAgentPluginRootManifest(await readText(fs, rootManifest, context))) return rootManifest;\n  } catch {\n    // A missing, unreadable, or unrelated root manifest does not outrank legacy manifests.\n  }\n  for (const relativePath of LEGACY_PLUGIN_MANIFEST_PATHS) {\n    const manifestPath = path.join(pluginRoot, relativePath);\n    if (await isFile(fs, manifestPath, context)) return manifestPath;\n  }\n  return undefined;\n}\n\nasync function readPluginManifestMetadata(\n  fs: FileSystem,\n  pluginRoot: string,\n  diagnostics: string[],\n  context: Context,\n): Promise<PluginManifestMetadata | undefined> {\n  const manifestPath = await findPluginManifestPathAsync(fs, pluginRoot, context);\n  if (!manifestPath) return undefined;\n  try {\n    const manifest = parseJsonRecord(await readText(fs, manifestPath, context), manifestPath, 'Plugin manifest');\n    return manifestMetadataFromRecord(manifestPath, manifest);\n  } catch (error) {\n    diagnostics.push(error instanceof Error ? error.message : String(error));\n    return { path: manifestPath };\n  }\n}\n\nasync function discoverPluginRoot(\n  fs: FileSystem,\n  pluginRoot: string,\n  entries: Record<string, PluginCatalogEntry>,\n  diagnostics: string[],\n  context: Context,\n): Promise<boolean> {\n  const diagnosticCount = diagnostics.length;\n  const manifest = await readPluginManifestMetadata(fs, pluginRoot, diagnostics, context);\n  if (!manifest || diagnostics.length !== diagnosticCount) return false;\n  const discovered = discoveredPluginEntry(pluginRoot, manifest, diagnostics);\n  if (!discovered) return false;\n  entries[discovered.name] = discovered.entry;\n  return true;\n}\n\nasync function discoverPluginFolder(\n  fs: FileSystem,\n  root: string,\n  entries: Record<string, PluginCatalogEntry>,\n  diagnostics: string[],\n  context: Context,\n): Promise<number> {\n  if ((await resolvedKind(fs, root, context)) !== 'directory') return 0;\n  if (await findPluginManifestPathAsync(fs, root, context)) {\n    return (await discoverPluginRoot(fs, root, entries, diagnostics, context)) ? 1 : 0;\n  }\n\n  let discovered = 0;\n  const children = getOrThrow(await fs.listDir(root, context))\n    .filter((entry) => entry.kind === 'directory')\n    .sort((left, right) => left.name.localeCompare(right.name));\n  for (const child of children) {\n    if (await discoverPluginRoot(fs, path.join(root, child.name), entries, diagnostics, context)) discovered += 1;\n  }\n  return discovered;\n}\n\nasync function parseMarketplace(\n  fs: FileSystem,\n  marketplace: MarketplaceLocation,\n  entries: Record<string, PluginCatalogEntry>,\n  diagnostics: string[],\n  context: Context,\n): Promise<void> {\n  const record = parseJsonRecord(\n    await readText(fs, marketplace.manifestPath, context),\n    marketplace.manifestPath,\n    'Marketplace manifest',\n  );\n  const document = parseMarketplaceDocument(marketplace, record);\n  for (let index = 0; index < document.plugins.length; index += 1) {\n    try {\n      const plugin = parseMarketplacePlugin(marketplace, document, index, entries);\n      if (!plugin) continue;\n      const manifest =\n        plugin.source.type === 'local'\n          ? await readPluginManifestMetadata(fs, plugin.source.path, diagnostics, context)\n          : undefined;\n      entries[plugin.id] = catalogEntry(plugin.source, plugin.description, manifest, document.name);\n    } catch (error) {\n      diagnostics.push(error instanceof Error ? error.message : String(error));\n    }\n  }\n}\n\n/** Builds the plugin catalog from home, repo, and configured roots through the injected file system. */\nexport async function loadPluginCatalogAsync(\n  fs: FileSystem,\n  sources: readonly PluginCatalogConfigSource[],\n  repoRoot: string,\n  homeDirectory: string,\n  context: Context,\n  environment: Readonly<Record<string, string | undefined>> = {},\n): Promise<PluginCatalog> {\n  const diagnostics: string[] = [];\n  const entries: Record<string, PluginCatalogEntry> = {};\n  const roots = [...new Set(sources.flatMap(parseConfiguredRoots))];\n  const candidates = [homeDirectory, repoRoot, ...roots];\n  const marketplaces: string[] = [];\n  const seenMarketplaces = new Set<string>();\n\n  for (const candidate of candidates) {\n    const marketplace = await findMarketplace(fs, candidate, context);\n    if (!marketplace) continue;\n    if (seenMarketplaces.has(marketplace.manifestPath)) continue;\n    seenMarketplaces.add(marketplace.manifestPath);\n    marketplaces.push(marketplace.manifestPath);\n    try {\n      await parseMarketplace(fs, marketplace, entries, diagnostics, context);\n    } catch (error) {\n      diagnostics.push(error instanceof Error ? error.message : String(error));\n    }\n  }\n\n  for (const root of roots) {\n    if (await findMarketplace(fs, root, context)) continue;\n    if ((await discoverPluginFolder(fs, root, entries, diagnostics, context)) === 0) {\n      diagnostics.push(`Plugin root contains neither a supported marketplace nor discoverable plugins: ${root}`);\n    }\n  }\n\n  const origin = await readHostMarketplaceOrigin(fs, homeDirectory, environment, context);\n  let remoteEntries: Record<string, PluginCatalogEntry> = {};\n  try {\n    const snapshot = await readTextIfExists(fs, marketplaceSnapshotPath(homeDirectory, environment, origin), context);\n    if (snapshot !== undefined) {\n      remoteEntries = marketplaceSnapshotEntries(snapshot, origin);\n      for (const [id, entry] of Object.entries(remoteEntries)) {\n        if (!Object.hasOwn(entries, id)) entries[id] = entry;\n      }\n    }\n  } catch (error) {\n    diagnostics.push(error instanceof Error ? error.message : String(error));\n  }\n\n  for (const source of sources) {\n    for (const parsed of parseConfiguredEntries(source)) {\n      const manifest =\n        parsed.source.type === 'local'\n          ? await readPluginManifestMetadata(fs, parsed.source.path, diagnostics, context)\n          : undefined;\n      entries[parsed.name] = catalogEntry(parsed.source, parsed.description, manifest);\n    }\n  }\n  const uninstalledEntries = { ...entries };\n  for (const file of new Set([\n    marketplaceInstalledPath(homeDirectory, environment, origin),\n    marketplaceInstalledPath(homeDirectory, environment, origin, repoRoot),\n  ])) {\n    const text = await readTextIfExists(fs, file, context);\n    if (text === undefined) continue;\n    for (const [id, installed] of Object.entries(marketplaceInstalledEntries(text, origin))) {\n      if (installed === null) {\n        if (uninstalledEntries[id]) entries[id] = uninstalledEntries[id];\n        else delete entries[id];\n        continue;\n      }\n      const candidate = remoteEntries[id]?.available;\n      entries[id] = {\n        ...installed,\n        ...(candidate?.package === installed.installed?.package ? { available: candidate } : {}),\n      };\n    }\n  }\n  return { roots, marketplaces, entries, diagnostics };\n}\n","import type { DomainManifest } from '../../types/domains';\n\nconst NAME_DELIMITER = ',';\n\n/** Splits comma-joined selections and expands aliases into concrete domain names. */\nexport function expandDomainNames(manifest: DomainManifest, domainNames: readonly string[]): string[] {\n  return domainNames\n    .flatMap((raw) =>\n      raw\n        .split(NAME_DELIMITER)\n        .map((name) => name.trim())\n        .filter(Boolean),\n    )\n    .flatMap((name) => manifest.aliases[name] ?? [name]);\n}\n\nexport function domainCompletionPrefix(textBeforeCursor: string): string | undefined {\n  const match = textBeforeCursor.match(/^\\/domains\\s+(?:[^\\s,]+,)*([^\\s,]*)$/);\n  return match?.[1];\n}\n\nexport function domainCompletionItems(domainNames: string[], query: string): Array<{ value: string; label: string }> {\n  const normalizedQuery = query.toLowerCase();\n  return domainNames\n    .filter((name) => name.toLowerCase().startsWith(normalizedQuery))\n    .map((name) => ({ value: name, label: name }));\n}\n","import path from 'node:path';\n\nimport type {\n  DomainDefinition,\n  DomainManifest,\n  DomainMcpAllowlist,\n  DomainPlugin,\n  PluginCatalog,\n  PluginEntry,\n  ResolvedDomain,\n} from '../../types/domains';\nimport { globalPoConfigDirectory } from '../config';\nimport type { PoConfigSource } from '../layeredConfig';\nimport { parseConfiguredPluginList, pluginDirectoryForSource, type PluginCatalogConfigSource } from '../pluginCatalog';\nimport { expandDomainNames } from './completion';\n\nexport const DOMAINS_FILE = 'domains.yaml';\nconst UNKNOWN_DOMAIN_ERROR = 'Unknown domain';\nconst UNKNOWN_PLUGIN_ERROR = 'Unknown plugin';\nconst MISSING_PLUGIN_DIRECTORY_ERROR = 'Plugin directory does not exist';\nconst DEFAULT_DOMAINS_PATH = '.po/domains.yaml';\nconst SUPPORTED_AGENT_PLUGIN_SCHEMA = 'https://agent-plugins.org/schemas/1.0.0/plugin.schema.json';\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction requireRecord(value: unknown, label: string): Record<string, unknown> {\n  if (!isRecord(value)) throw new Error(`${label} must be an object`);\n  return value;\n}\n\nfunction assertOnlyKeys(record: Record<string, unknown>, allowed: readonly string[], label: string): void {\n  const unexpected = Object.keys(record).filter((key) => !allowed.includes(key));\n  if (unexpected.length > 0) throw new Error(`${label} contains unsupported field \"${unexpected[0]}\"`);\n}\n\nfunction requireString(value: unknown, label: string): string {\n  if (typeof value !== 'string' || !value.trim()) throw new Error(`${label} must be a non-empty string`);\n  return value.trim();\n}\n\nfunction optionalString(value: unknown, label: string): string | undefined {\n  if (value === undefined) return undefined;\n  return requireString(value, label);\n}\n\nfunction parseStringArray(value: unknown, label: string): string[] {\n  if (!Array.isArray(value)) throw new Error(`${label} must be an array of non-empty strings`);\n  return [...new Set(value.map((entry, index) => requireString(entry, `${label}[${index}]`)))];\n}\n\nfunction parseOptionalBoolean(value: unknown, label: string): boolean | undefined {\n  if (value === undefined) return undefined;\n  if (typeof value !== 'boolean') throw new Error(`${label} must be a boolean`);\n  return value;\n}\n\nfunction parseDefaultDomains(value: unknown): string[] {\n  return parseStringArray(value, `defaultDomains in ${DEFAULT_DOMAINS_PATH}`);\n}\n\nfunction parseDomainPlugin(value: unknown, label: string): DomainPlugin {\n  if (typeof value === 'string') return requireString(value, label);\n  const plugin = requireRecord(value, label);\n  assertOnlyKeys(plugin, ['name', 'skills', 'agents', 'hooks', 'mcp'], label);\n  const skills = plugin.skills === undefined ? undefined : parseStringArray(plugin.skills, `${label}.skills`);\n  const agents = plugin.agents === undefined ? undefined : parseStringArray(plugin.agents, `${label}.agents`);\n  const hooks = parseOptionalBoolean(plugin.hooks, `${label}.hooks`);\n  const mcp = parseOptionalBoolean(plugin.mcp, `${label}.mcp`);\n  return {\n    name: requireString(plugin.name, `${label}.name`),\n    ...(skills ? { skills } : {}),\n    ...(agents ? { agents } : {}),\n    ...(hooks === undefined ? {} : { hooks }),\n    ...(mcp === undefined ? {} : { mcp }),\n  };\n}\n\nfunction parseMcpAllowlist(value: unknown, label: string): DomainMcpAllowlist {\n  const mcp = requireRecord(value, label);\n  assertOnlyKeys(mcp, ['servers', 'proxy'], label);\n  return {\n    ...(mcp.servers === undefined ? {} : { servers: parseStringArray(mcp.servers, `${label}.servers`) }),\n    ...(mcp.proxy === undefined ? {} : { proxy: parseStringArray(mcp.proxy, `${label}.proxy`) }),\n  };\n}\n\nfunction parseDomain(value: unknown, label: string): DomainDefinition {\n  const domain = requireRecord(value, label);\n  assertOnlyKeys(domain, ['description', 'plugins', 'mcp', 'sharedSkills'], label);\n  const description = optionalString(domain.description, `${label}.description`);\n  if (domain.plugins !== undefined && !Array.isArray(domain.plugins)) {\n    throw new Error(`${label}.plugins must be an array`);\n  }\n  const sharedSkills = parseOptionalBoolean(domain.sharedSkills, `${label}.sharedSkills`);\n  return {\n    ...(description ? { description } : {}),\n    ...(Array.isArray(domain.plugins)\n      ? { plugins: domain.plugins.map((plugin, index) => parseDomainPlugin(plugin, `${label}.plugins[${index}]`)) }\n      : {}),\n    ...(domain.mcp === undefined ? {} : { mcp: parseMcpAllowlist(domain.mcp, `${label}.mcp`) }),\n    ...(sharedSkills === undefined ? {} : { sharedSkills }),\n  };\n}\n\nfunction parseAliases(value: unknown, label: string): Record<string, string[]> {\n  if (value === undefined) return {};\n  const aliases = requireRecord(value, label);\n  return Object.fromEntries(\n    Object.entries(aliases).map(([name, domains]) => [name, parseStringArray(domains, `${label}.${name}`)]),\n  );\n}\n\n/** Domains, aliases, and defaults folded from the sources, plus the catalog inputs. */\nexport interface DomainSourceSummary {\n  readonly aliases: Record<string, string[]>;\n  readonly domains: Record<string, ResolvedDomain>;\n  readonly defaultDomains: string[] | undefined;\n  readonly catalogSources: PluginCatalogConfigSource[];\n  /** `plugins.standalone` from every source, in source order. */\n  readonly standalone: string[];\n  /** `plugins.disabled` from every source, in source order. */\n  readonly disabled: string[];\n}\n\n/**\n * Folds domain sources in precedence order.\n *\n * Named domains and explicit plugin entries are replaced by later repository\n * definitions. Configured roots accumulate, with exact marketplace manifests\n * deduplicated in discovery order. Explicit entries override discovered IDs.\n */\nexport function summarizeDomainSources(sources: ReadonlyArray<PoConfigSource<unknown>>): DomainSourceSummary {\n  const aliases: Record<string, string[]> = {};\n  const domains: Record<string, ResolvedDomain> = {};\n  let defaultDomains: string[] | undefined;\n\n  for (const source of sources) {\n    const document = requireRecord(source.document, source.filePath);\n    assertOnlyKeys(document, ['plugins', 'domains', 'aliases', 'defaultDomains'], source.filePath);\n    Object.assign(aliases, parseAliases(document.aliases, `aliases in ${source.filePath}`));\n    if (document.domains !== undefined) {\n      const sourceDomains = requireRecord(document.domains, `domains in ${source.filePath}`);\n      for (const [name, definition] of Object.entries(sourceDomains)) {\n        domains[name] = {\n          ...parseDomain(definition, `domains.${name} in ${source.filePath}`),\n          baseDirectory: source.baseDirectory,\n        };\n      }\n    }\n    if (Object.hasOwn(document, 'defaultDomains')) defaultDomains = parseDefaultDomains(document.defaultDomains);\n  }\n\n  const catalogSources = sources.map((source) => ({\n    filePath: source.filePath,\n    baseDirectory: source.baseDirectory,\n    value: requireRecord(source.document, source.filePath).plugins,\n  }));\n  // Both lists accumulate like roots: a repository can add to them but not undo a personal entry.\n  const collect = (key: 'standalone' | 'disabled') => [\n    ...new Set(catalogSources.flatMap((source) => parseConfiguredPluginList(source, key))),\n  ];\n  return {\n    aliases,\n    domains,\n    defaultDomains,\n    catalogSources,\n    standalone: collect('standalone'),\n    disabled: collect('disabled'),\n  };\n}\n\n/** Joins the summary with its plugin catalog and checks the default domains exist. */\nexport function completeDomainManifest(summary: DomainSourceSummary, plugins: PluginCatalog): DomainManifest {\n  const { aliases, domains, defaultDomains, standalone, disabled } = summary;\n  if (defaultDomains) {\n    for (const name of expandDomainNames({ plugins, domains, aliases }, defaultDomains)) {\n      if (!Object.hasOwn(domains, name)) {\n        throw new Error(`Unknown default domain \"${name}\" in ${DEFAULT_DOMAINS_PATH}`);\n      }\n    }\n  }\n  return {\n    plugins,\n    domains,\n    aliases,\n    ...(defaultDomains ? { defaultDomains } : {}),\n    ...(standalone.length > 0 ? { standalone } : {}),\n    ...(disabled.length > 0 ? { disabled } : {}),\n  };\n}\n\nexport function domainNamesOf(manifest: DomainManifest): string[] {\n  return [...new Set([...Object.keys(manifest.domains), ...Object.keys(manifest.aliases)])].sort();\n}\n\n/**\n * Whether to include .claude/skills as shared fallbacks.\n *\n * Shared skills are included unless every selected domain opts out, so mixing a\n * trimmed domain with an untrimmed one cannot strip the untrimmed one's skills.\n */\nexport function sharedSkillsFor(manifest: DomainManifest, domainNames: string[]): boolean {\n  const expanded = expandDomainNames(manifest, domainNames);\n  if (expanded.length === 0) return true;\n  return expanded.some((name) => manifest.domains[name]?.sharedSkills !== false);\n}\n\n/**\n * One step of plugin entry resolution, in order. A driver throws on `error`,\n * throws when `mustBeDirectory` names a path that is not a directory, then keeps\n * the first entry for each directory.\n */\nexport type PluginEntryStep =\n  | { readonly error: string }\n  | { readonly entry: PluginEntry; readonly mustBeDirectory: boolean };\n\nexport function missingPluginDirectoryMessage(directory: string): string {\n  return `${MISSING_PLUGIN_DIRECTORY_ERROR}: ${directory}`;\n}\n\n/**\n * Plans named domain plugins, preserving each subset filter, then standalone plugins, then\n * explicit directories. A disabled plugin is left out wherever it is named.\n */\nexport function pluginEntrySteps(\n  manifest: DomainManifest,\n  domainNames: string[],\n  explicitDirectories: string[],\n  homeDirectory: string,\n): PluginEntryStep[] {\n  const steps: PluginEntryStep[] = [];\n  const homePoDirectory = globalPoConfigDirectory(homeDirectory);\n  const disabled = new Set(manifest.disabled ?? []);\n  const entryFor = (pluginName: string, plugin: PluginCatalog['entries'][string]): PluginEntry => {\n    if (plugin.authorityMismatch)\n      throw new Error(\n        `Marketplace authority changed for \"${pluginName}\". Restore its approved origin, or explicitly disable and freshly enable it from the new origin.`,\n      );\n    return {\n      name: pluginName,\n      directory: pluginDirectoryForSource(plugin.source, homePoDirectory),\n      source: plugin.source,\n      ...(plugin.manifest ? { manifest: plugin.manifest } : {}),\n      ...(plugin.manifest?.agentPluginSchema === SUPPORTED_AGENT_PLUGIN_SCHEMA\n        ? { skillDiscovery: 'direct-children' as const }\n        : {}),\n    };\n  };\n\n  for (const domainName of expandDomainNames(manifest, domainNames)) {\n    const domain = manifest.domains[domainName];\n    if (!domain) return [...steps, { error: `${UNKNOWN_DOMAIN_ERROR}: ${domainName}` }];\n    for (const selection of domain.plugins ?? []) {\n      const isSubset = typeof selection !== 'string';\n      const pluginName = isSubset ? selection.name : selection;\n      if (disabled.has(pluginName)) continue;\n      const plugin = manifest.plugins.entries[pluginName];\n      if (!plugin) {\n        return [...steps, { error: `${UNKNOWN_PLUGIN_ERROR} \"${pluginName}\" referenced by domain \"${domainName}\"` }];\n      }\n      steps.push({\n        mustBeDirectory: plugin.source.type === 'local',\n        entry: {\n          ...entryFor(pluginName, plugin),\n          // The domain is only in scope here. `resolvePluginDirectories` keeps\n          // just the path, so anything downstream that wants to say which domain\n          // brought a plugin has to be told now or not at all.\n          domain: domainName,\n          ...(isSubset && selection.skills ? { skills: selection.skills } : {}),\n          ...(isSubset && selection.agents ? { agents: selection.agents } : {}),\n          ...(isSubset && selection.hooks !== undefined ? { hooks: selection.hooks } : {}),\n          ...(isSubset && selection.mcp !== undefined ? { mcp: selection.mcp } : {}),\n        },\n      });\n    }\n  }\n\n  for (const pluginName of manifest.standalone ?? []) {\n    const plugin = manifest.plugins.entries[pluginName];\n    // ponytail: a stale standalone name is skipped rather than failing every session; the\n    // settings page drops names it removes, so only a hand edit leaves one behind.\n    if (!plugin || disabled.has(pluginName)) continue;\n    steps.push({ mustBeDirectory: plugin.source.type === 'local', entry: entryFor(pluginName, plugin) });\n  }\n\n  for (const configuredDirectory of explicitDirectories) {\n    const directory = path.resolve(configuredDirectory);\n    steps.push({\n      mustBeDirectory: true,\n      entry: { name: path.basename(directory), directory, source: { type: 'local', path: directory } },\n    });\n  }\n  return steps;\n}\n\nexport const PO_DOMAINS_ENV = 'PO_DOMAINS';\nexport const DEFAULT_DOMAIN = 'default';\nconst MARKETING_PRESET = 'marketing';\n\nfunction parseDomainList(value: string): string[] {\n  return value\n    .split(',')\n    .map((entry) => entry.trim())\n    .filter(Boolean);\n}\n\n/**\n * Domains selected when the caller names none.\n *\n * Configuration keeps this axis independent of the preset. The\n * preset-derived choice is retained only as the compatibility fallback for\n * domains files that declare no defaultDomains.\n */\nexport function defaultDomainsForPreset(\n  preset: string,\n  environment: NodeJS.ProcessEnv,\n  defaultDomains?: readonly string[],\n): string[] {\n  const inherited = environment[PO_DOMAINS_ENV];\n  // An explicitly empty variable means no domains, so this tests for the key\n  // rather than for a truthy value.\n  if (inherited !== undefined) return parseDomainList(inherited);\n  if (defaultDomains !== undefined) return [...defaultDomains];\n  return parseDomainList(preset === MARKETING_PRESET ? MARKETING_PRESET : DEFAULT_DOMAIN);\n}\n","// sync: Preserve the exported Node-only domain resolution signatures until phase 2.\nimport fs from 'node:fs';\n\nimport { nodeHost } from '@agimon-ai/po-core/platform';\n\nimport type { DomainManifest, PluginEntry } from '../../types/domains';\nimport { readPoConfigSources } from '../layeredConfig';\nimport { loadPluginCatalog } from '../pluginCatalog';\nimport {\n  DOMAINS_FILE,\n  completeDomainManifest,\n  domainNamesOf,\n  missingPluginDirectoryMessage,\n  pluginEntrySteps,\n  sharedSkillsFor,\n  summarizeDomainSources,\n} from './core';\n\n/**\n * Reads domains and plugin catalogs from global and repository configs.\n *\n * @deprecated Node-only sync shim; use loadDomainsAsync. Removed in M2.\n */\nexport function loadDomains(repoRoot: string, homeDirectory: string = nodeHost.homeDirectory()): DomainManifest {\n  const summary = summarizeDomainSources(readPoConfigSources<unknown>(DOMAINS_FILE, repoRoot, homeDirectory));\n  return completeDomainManifest(summary, loadPluginCatalog(summary.catalogSources, repoRoot, homeDirectory));\n}\n\n/** @deprecated Node-only sync shim; use listDomainNamesAsync. Removed in M2. */\nexport function listDomainNames(repoRoot: string, homeDirectory?: string): string[] {\n  return domainNamesOf(loadDomains(repoRoot, homeDirectory));\n}\n\n/** @deprecated Node-only sync shim; use resolveSharedSkillsAsync. Removed in M2. */\nexport function resolveSharedSkills(repoRoot: string, domainNames: string[], homeDirectory?: string): boolean {\n  return sharedSkillsFor(loadDomains(repoRoot, homeDirectory), domainNames);\n}\n\n/** @deprecated Node-only sync shim; use resolvePluginEntriesAsync. Removed in M2. */\nexport function resolvePluginEntries(\n  repoRoot: string,\n  domainNames: string[],\n  explicitDirectories: string[],\n  homeDirectory: string = nodeHost.homeDirectory(),\n): PluginEntry[] {\n  const manifest = loadDomains(repoRoot, homeDirectory);\n  const entries: PluginEntry[] = [];\n  const seen = new Set<string>();\n  for (const step of pluginEntrySteps(manifest, domainNames, explicitDirectories, homeDirectory)) {\n    if ('error' in step) throw new Error(step.error);\n    const { directory } = step.entry;\n    if (step.mustBeDirectory && (!fs.existsSync(directory) || !fs.statSync(directory).isDirectory())) {\n      throw new Error(missingPluginDirectoryMessage(directory));\n    }\n    if (seen.has(directory)) continue;\n    seen.add(directory);\n    entries.push(step.entry);\n  }\n  return entries;\n}\n\n/** @deprecated Node-only sync shim; use resolvePluginDirectoriesAsync. Removed in M2. */\nexport function resolvePluginDirectories(\n  repoRoot: string,\n  domainNames: string[],\n  explicitDirectories: string[],\n  homeDirectory?: string,\n): string[] {\n  return resolvePluginEntries(repoRoot, domainNames, explicitDirectories, homeDirectory).map(\n    (entry) => entry.directory,\n  );\n}\n","import { getOrThrow, nodeHost, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport type { DomainManifest, PluginEntry } from '../../types/domains';\nimport { readPoConfigSourcesAsync } from '../layeredConfig';\nimport { loadPluginCatalogAsync } from '../pluginCatalog';\nimport {\n  DOMAINS_FILE,\n  completeDomainManifest,\n  domainNamesOf,\n  missingPluginDirectoryMessage,\n  pluginEntrySteps,\n  sharedSkillsFor,\n  summarizeDomainSources,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport { PO_DIR } from '../layeredConfig';\nexport { DEFAULT_DOMAIN, PO_DOMAINS_ENV, defaultDomainsForPreset } from './core';\nexport {\n  listDomainNames,\n  loadDomains,\n  resolvePluginDirectories,\n  resolvePluginEntries,\n  resolveSharedSkills,\n} from './sync';\n\n/** Whether a path names a directory after following symbolic links. */\nasync function isDirectory(fs: FileSystem, filePath: string, context: IoContext): Promise<boolean> {\n  const info = await fs.fileInfo(filePath, context);\n  if (!info.ok) {\n    if (info.error.code === 'not_found') return false;\n    throw info.error;\n  }\n  if (info.value.kind !== 'symlink') return info.value.kind === 'directory';\n  const target = await fs.canonicalPath(filePath, context);\n  if (!target.ok && target.error.code === 'not_found') return false;\n  const targetInfo = await fs.fileInfo(getOrThrow(target), context);\n  if (!targetInfo.ok && targetInfo.error.code === 'not_found') return false;\n  return getOrThrow(targetInfo).kind === 'directory';\n}\n\n/**\n * Reads domains and plugin catalogs from global and repository configs over a FileSystem.\n *\n * Named domains and explicit plugin entries are replaced by later repository\n * definitions. Configured roots accumulate, with exact marketplace manifests\n * deduplicated in discovery order. Explicit entries override discovered IDs.\n */\nexport async function loadDomainsAsync(\n  fs: FileSystem,\n  repoRoot: string,\n  context: IoContext,\n  homeDirectory: string = nodeHost.homeDirectory(),\n  environment?: Parameters<typeof readPoConfigSourcesAsync>[5],\n): Promise<DomainManifest> {\n  const sources = await readPoConfigSourcesAsync<unknown>(\n    fs,\n    DOMAINS_FILE,\n    repoRoot,\n    context,\n    homeDirectory,\n    environment,\n  );\n  const summary = summarizeDomainSources(sources);\n  const plugins = await loadPluginCatalogAsync(\n    fs,\n    summary.catalogSources,\n    repoRoot,\n    homeDirectory,\n    context,\n    environment,\n  );\n  return completeDomainManifest(summary, plugins);\n}\n\nexport async function listDomainNamesAsync(\n  fs: FileSystem,\n  repoRoot: string,\n  context: IoContext,\n  homeDirectory?: string,\n  environment?: Parameters<typeof readPoConfigSourcesAsync>[5],\n): Promise<string[]> {\n  return domainNamesOf(await loadDomainsAsync(fs, repoRoot, context, homeDirectory, environment));\n}\n\n/**\n * Whether to include .claude/skills as shared fallbacks.\n *\n * Shared skills are included unless every selected domain opts out, so mixing a\n * trimmed domain with an untrimmed one cannot strip the untrimmed one's skills.\n */\nexport async function resolveSharedSkillsAsync(\n  fs: FileSystem,\n  repoRoot: string,\n  domainNames: string[],\n  context: IoContext,\n  homeDirectory?: string,\n  environment?: Parameters<typeof readPoConfigSourcesAsync>[5],\n): Promise<boolean> {\n  return sharedSkillsFor(await loadDomainsAsync(fs, repoRoot, context, homeDirectory, environment), domainNames);\n}\n\n/** Resolves named domain plugins while preserving each subset filter. */\nexport async function resolvePluginEntriesAsync(\n  fs: FileSystem,\n  repoRoot: string,\n  domainNames: string[],\n  explicitDirectories: string[],\n  context: IoContext,\n  homeDirectory: string = nodeHost.homeDirectory(),\n  environment?: Parameters<typeof readPoConfigSourcesAsync>[5],\n): Promise<PluginEntry[]> {\n  const manifest = await loadDomainsAsync(fs, repoRoot, context, homeDirectory, environment);\n  const entries: PluginEntry[] = [];\n  const seen = new Set<string>();\n  for (const step of pluginEntrySteps(manifest, domainNames, explicitDirectories, homeDirectory)) {\n    if ('error' in step) throw new Error(step.error);\n    const { directory } = step.entry;\n    if (step.mustBeDirectory && !(await isDirectory(fs, directory, context))) {\n      throw new Error(missingPluginDirectoryMessage(directory));\n    }\n    if (seen.has(directory)) continue;\n    seen.add(directory);\n    entries.push(step.entry);\n  }\n  return entries;\n}\n\nexport async function resolvePluginDirectoriesAsync(\n  fs: FileSystem,\n  repoRoot: string,\n  domainNames: string[],\n  explicitDirectories: string[],\n  context: IoContext,\n  homeDirectory?: string,\n): Promise<string[]> {\n  const entries = await resolvePluginEntriesAsync(\n    fs,\n    repoRoot,\n    domainNames,\n    explicitDirectories,\n    context,\n    homeDirectory,\n  );\n  return entries.map((entry) => entry.directory);\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAa,+BAA+B;CAC1C;CACA;CACA;AACF;AAEA,MAAa,sCAAsC;CACjD;CACA;CACA;CACA;AACF;AAkBA,SAAgBA,WAAS,OAAkD;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAgBC,gBAAc,OAAgB,OAAwC;CACpF,IAAI,CAACD,WAAS,KAAK,GAAG,MAAM,IAAI,MAAM,GAAG,MAAM,mBAAmB;CAClE,OAAO;AACT;AAEA,SAAgBE,iB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