{"version":3,"file":"index.mjs","names":[],"sources":["../../src/compiler/index.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport { builtinModules, createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { optionalPackageEntry } from '@agimon-ai/doompi-core/module-resolution';\nimport type { LogLevel, LogOrStringHandler, OutputAsset, OutputChunk, RolldownLog, RolldownOutput } from 'rolldown';\n\nimport {\n  contentSha256,\n  findSharedBuild,\n  materializeSharedBuild,\n  publishSharedBuild,\n  type ResolvedSharedBuild,\n  type SharedBuildAsset,\n  type SharedBuildInput,\n  withSharedBuildLock,\n} from './cache';\nimport { fingerprintInput, inputsAreFresh, type InputFingerprint } from './inputs';\n\n/**\n * Compiles TypeScript extensions into plain ESM ahead of the session.\n *\n * Pi loads extensions through jiti, which transpiles TypeScript at import time.\n * That works, but it costs a transform per module on a cold cache and makes Node\n * complain about type stripping under node_modules on every launch. Resolution\n * already knows the full extension list, so each TypeScript graph is compiled\n * to native ESM here and Pi imports it without a runtime transform. Lazy imports\n * remain separate content-addressed chunks so their evaluation semantics survive\n * compilation.\n *\n * Direct module artifacts bundle ordinary JavaScript dependencies. Node built-ins and Pi's\n * shared runtime stay external; native or resource-bearing dependencies fail explicitly\n * unless their package-owned resources are pinned into the artifact.\n * Those imports are rewritten to absolute paths so a worktree-local artifact never relies\n * on its generated directory having its own `node_modules` tree. Immutable build objects\n * may be shared by linked worktrees, but materialized output stays worktree-local.\n */\n\nconst TYPESCRIPT_SUFFIXES = ['.ts', '.mts', '.cts'] as const;\nconst COMPILED_SUFFIX = '.mjs';\n// v15 records a content digest per input; a v14 manifest cannot be confirmed\n// by content and is discarded rather than trusted on timestamps alone.\nconst SET_CACHE_VERSION = 'v15';\nconst HASH_LENGTH = 16;\nconst SET_DIRECTORY = 'sets';\nconst MANIFEST_SUFFIX = '.json';\nconst VIRTUAL_SET_ENTRY = '\\0doompi-extension-set';\nconst EXTENSION_SOURCE_HELPER = '@agimon-ai/doompi-ui/extensionName';\nconst SHARED_BUILD_VERSION = 'v3-rolldown-1.2.5';\nconst SHARED_PATH_TOKEN_PREFIX = '__DOOMPI_PATH_';\nconst REPOSITORY_INPUT_PREFIX = 'repo/';\nconst EXTERNAL_INPUT_PREFIX = 'external/';\nconst DEFAULT_SET_OUTPUT_NAME = 'doom-set';\n\n/** Serializes data embedded in generated JavaScript without leaving HTML or line-separator code boundaries. */\nfunction javascriptStringLiteral(value: string): string {\n  return JSON.stringify(value)\n    .replaceAll('<', '\\\\u003c')\n    .replaceAll('\\u2028', '\\\\u2028')\n    .replaceAll('\\u2029', '\\\\u2029');\n}\n/** Pi's former npm scope. The packages are the same, published under a new name. */\nconst PI_SCOPE_RENAMES: Readonly<Record<string, string>> = {\n  '@mariozechner/pi-coding-agent': '@earendil-works/pi-coding-agent',\n  '@mariozechner/pi-tui': '@earendil-works/pi-tui',\n  '@mariozechner/pi-ai': '@earendil-works/pi-ai',\n  '@sinclair/typebox': 'typebox',\n};\n\nexport function isTypeScriptEntry(entry: string): boolean {\n  return TYPESCRIPT_SUFFIXES.some((suffix) => entry.endsWith(suffix));\n}\n\nfunction renameScope(specifier: string): string {\n  for (const [before, after] of Object.entries(PI_SCOPE_RENAMES)) {\n    if (specifier === before) return after;\n    if (specifier.startsWith(`${before}/`)) return `${after}${specifier.slice(before.length)}`;\n  }\n  return specifier;\n}\n\n/**\n * Packages that must resolve to the copy this harness runs, never to a second\n * one bundled into an extension. Pi owns the TUI and the session state, so a\n * duplicate renders into a different screen and mutates a different store.\n */\nconst HOSTED_PACKAGES = new Set(['@earendil-works/pi-coding-agent', '@earendil-works/pi-tui', '@earendil-works/pi-ai']);\n\n/**\n * Resolves packages Pi exposes to extensions as compatibility aliases.\n *\n * Extensions do not need to declare TypeBox themselves because Pi's loader\n * provides it as a virtual module. A dist bundle bypasses that loader, so it\n * resolves the same package against Pi's dependency tree and bundles it.\n */\nfunction piExtensionDependencyEntry(specifier: string): string | undefined {\n  const piEntry = optionalPackageEntry('@earendil-works/pi-coding-agent', import.meta.url);\n  if (!piEntry) return undefined;\n  try {\n    return createRequire(piEntry).resolve(specifier);\n  } catch {\n    return undefined;\n  }\n}\n\n/** Packages whose native binaries or runtime discovery cannot be rolled up. */\nconst NATIVE_PACKAGES = new Set([\n  '@parcel/watcher',\n  '@napi-rs/keyring',\n  'better-sqlite3',\n  'canvas',\n  'fsevents',\n  'isolated-vm',\n  'keytar',\n  'node-pty',\n  'onnxruntime-node',\n  'playwright',\n  'playwright-core',\n  'puppeteer',\n  'sharp',\n  // TypeScript 7 exposes version metadata at its top-level entry and keeps its\n  // compiler APIs behind unstable native ESM subpaths. Preserve the installed\n  // package graph so extensions resolve those entrypoints at runtime.\n  'typescript',\n]);\n\nconst TURSO_DATABASE_PACKAGE = '@tursodatabase/database';\nconst TURSO_DATABASE_COMMON_PACKAGE = '@tursodatabase/database-common';\n\n/**\n * Dependency-heavy ESM runtimes that Pi set artifacts should retain in their installed graph.\n *\n * Folding these packages into the aggregate creates dozens of generated chunks\n * that Node must parse and link before any extension factory can register. Node\n * can load the installed graph directly while still sharing its module cache.\n */\nconst STARTUP_EXTERNAL_PACKAGES = new Set([\n  '@agimon-ai/foundation-port-registry',\n  '@agimon-ai/foundation-process-registry',\n  '@agimon-ai/log-sink-mcp',\n  '@modelcontextprotocol/sdk',\n  '@narumitw/pi-tui-kit',\n  '@rmux/sdk',\n  '@tursodatabase/database',\n  '@tursodatabase/database-common',\n  'ajv',\n  'ajv-formats',\n  'gpt-tokenizer',\n  'highlight.js',\n  'hono',\n  'inversify',\n  // open 11 resolves its bundled xdg-open helper relative to import.meta.url.\n  // Bundling changes that module location and can break helper discovery.\n  'open',\n  'reflect-metadata',\n  'zod-to-json-schema',\n  'yaml',\n  'zod',\n]);\nconst NODE_BUILTINS = new Set(builtinModules.flatMap((name) => [name, `node:${name}`]));\n\ntype CompilationKind = 'pi-set' | 'module';\n\n/**\n * Direct modules may bundle ordinary JavaScript, but these packages carry runtime\n * files or native bindings that require explicitly pinned resources.\n */\nconst DIRECT_RESOURCE_PACKAGES = new Set([\n  '@agimon-ai/doompi-runner-rmux-darwin-arm64',\n  '@agimon-ai/doompi-runner-rmux-darwin-x64',\n  '@agimon-ai/doompi-runner-rmux-linux-arm64',\n  '@agimon-ai/doompi-runner-rmux-linux-x64',\n  '@tursodatabase/database',\n  '@tursodatabase/database-common',\n  'onnxruntime-web',\n  'ruvector-onnx-embeddings-wasm',\n  'sherpa-onnx-node',\n  'sqlite-vec',\n  'open',\n]);\n\n/** Published runtimes that intentionally retain their native dependency graph outside direct artifacts. */\nconst DIRECT_EXTERNAL_PACKAGES = new Set(['@agimon-ai/style-system']);\n\n/**\n * @rmux/sdk only looks up the caller-provided `rmux` executable by name and has\n * no package-owned executable or resource lookup. Its JavaScript graph is safe\n * to bundle; the RMUX binary remains an intentional host capability.\n */\nfunction directModuleDependencyIsUnbundlable(root: string): boolean {\n  return (\n    NATIVE_PACKAGES.has(root) ||\n    DIRECT_RESOURCE_PACKAGES.has(root) ||\n    root.startsWith('@tursodatabase/database-') ||\n    root.startsWith('sherpa-onnx-')\n  );\n}\n\nfunction directModuleDependencyError(root: string, importer?: string): Error {\n  return new Error(\n    `Cannot compile direct extension module because dependency \"${root}\" has native bindings or package-owned resources that are not part of the compiled artifact${importer ? ` (imported by ${importer})` : ''}`,\n  );\n}\n\ninterface CompiledExtensionManifest {\n  version: string;\n  output: string;\n  artifacts: string[];\n}\n\ninterface ExtensionSetManifest extends CompiledExtensionManifest {\n  entries: string[];\n  inputs: InputFingerprint[];\n  /**\n   * The produced files, by content.\n   *\n   * Existence alone used to be the whole check, and an artifact corrupted in\n   * place was only ever repaired by accident, when an unrelated timestamp moved\n   * and forced the set to compile again. Judging inputs by content removes that\n   * accident, so the output has to answer for itself.\n   */\n  artifactInputs?: InputFingerprint[];\n}\n\nexport interface CompileExtensionResourcePackage {\n  readonly packageName: string;\n  readonly packageDirectory: string;\n  readonly files: readonly { path: string; mode?: number }[];\n}\n\nexport interface CompileExtensionResourceBinding {\n  readonly ownerPackageName: string;\n  readonly ownerDirectory: string;\n  readonly packages: readonly CompileExtensionResourcePackage[];\n}\n\nexport interface CompileExtensionSetOptions {\n  /** Persistent worktree artifact directory. Compiler manifests remain local. */\n  outputDirectory?: string;\n  /** Human-readable artifact prefix, normally the major-mode name. */\n  outputName?: string;\n  /** Canonical worktree root used to create relocatable logical input paths. */\n  repositoryRoot?: string;\n  /** Repository-level immutable cache shared by linked worktrees. */\n  sharedCacheDirectory?: string;\n  /** Package-owned files that must live beside a retained direct module. */\n  resources?: readonly CompileExtensionResourceBinding[];\n}\n\nfunction safeOutputName(value: string): string {\n  const normalized = value\n    .trim()\n    .replace(/[^a-zA-Z0-9._-]+/g, '-')\n    .replace(/^[-.]+|[-.]+$/g, '');\n  return normalized || DEFAULT_SET_OUTPUT_NAME;\n}\n\nfunction packageRootOf(specifier: string): string | undefined {\n  const slash = specifier.startsWith('@') ? specifier.indexOf('/', specifier.indexOf('/') + 1) : specifier.indexOf('/');\n  return slash === -1 ? specifier : specifier.slice(0, slash);\n}\n\nfunction packageRootFromPath(target: string): string | undefined {\n  let directory = path.dirname(target);\n  while (true) {\n    const manifestPath = path.join(directory, 'package.json');\n    if (fs.existsSync(manifestPath)) {\n      try {\n        const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as unknown;\n        if (isRecord(manifest) && typeof manifest.name === 'string') return manifest.name;\n      } catch {\n        return undefined;\n      }\n    }\n    const parent = path.dirname(directory);\n    if (parent === directory) return undefined;\n    directory = parent;\n  }\n}\n\ninterface LogicalInput {\n  logicalPath: string;\n  target: string;\n  sourcePath?: string;\n}\n\nfunction canonicalPath(target: string): string {\n  const absolute = path.resolve(target);\n  try {\n    return fs.realpathSync.native(absolute);\n  } catch {\n    return absolute;\n  }\n}\n\nfunction isInside(directory: string, target: string): boolean {\n  const relative = path.relative(path.resolve(directory), path.resolve(target));\n  return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));\n}\n\nfunction packageManifestDirectory(target: string): string | undefined {\n  let directory = path.dirname(canonicalPath(target));\n  while (true) {\n    const manifestPath = path.join(directory, 'package.json');\n    try {\n      const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as unknown;\n      if (isRecord(manifest) && typeof manifest.name === 'string') return directory;\n    } catch {\n      // Continue through package roots only when their manifest is readable.\n    }\n    const parent = path.dirname(directory);\n    if (parent === directory) return undefined;\n    directory = parent;\n  }\n}\n\nfunction packageDependencyNames(manifest: Record<string, unknown>): string[] {\n  return ['dependencies', 'optionalDependencies'].flatMap((field) => {\n    const dependencies = manifest[field];\n    return isRecord(dependencies) ? Object.keys(dependencies) : [];\n  });\n}\n\nfunction resolvePackageDirectory(name: string, manifestPath: string): string | undefined {\n  try {\n    return packageManifestDirectory(createRequire(manifestPath).resolve(name));\n  } catch {\n    return undefined;\n  }\n}\n\nfunction nativePackageDirectories(entries: readonly string[]): string[] {\n  const queue = entries.map(packageManifestDirectory).filter((value): value is string => value !== undefined);\n  const visited = new Set<string>();\n  const found: string[] = [];\n  while (queue.length > 0) {\n    const directory = canonicalPath(queue.shift() as string);\n    if (visited.has(directory)) continue;\n    visited.add(directory);\n    const manifestPath = path.join(directory, 'package.json');\n    let manifest: Record<string, unknown>;\n    try {\n      const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as unknown;\n      if (!isRecord(parsed)) continue;\n      manifest = parsed;\n    } catch {\n      continue;\n    }\n    if (manifest.name === '@agimon-ai/log-sink-mcp') found.push(directory);\n    if (\n      manifest.name === TURSO_DATABASE_PACKAGE ||\n      manifest.name === 'sqlite-vec' ||\n      manifest.name === 'ruvector-onnx-embeddings-wasm' ||\n      manifest.name === '@napi-rs/keyring'\n    ) {\n      found.push(directory);\n      continue;\n    }\n    for (const dependency of packageDependencyNames(manifest)) {\n      const resolved = resolvePackageDirectory(dependency, manifestPath);\n      if (resolved) queue.push(resolved);\n    }\n  }\n  return found;\n}\n\nfunction currentTursoPlatformPackage(): string | undefined {\n  let suffix = `${process.platform}-${process.arch}`;\n  if (process.platform === 'linux') {\n    const report: unknown = process.report.getReport();\n    if (!isRecord(report) || !isRecord(report.header) || typeof report.header.glibcVersionRuntime !== 'string') {\n      return undefined;\n    }\n    suffix += '-gnu';\n  } else if (process.platform === 'win32') {\n    suffix += '-msvc';\n  }\n  return `${TURSO_DATABASE_PACKAGE}-${suffix}`;\n}\n\nfunction tursoPlatformResource(packageDirectory: string): CompileExtensionResourcePackage | undefined {\n  const packageName = currentTursoPlatformPackage();\n  if (!packageName) return undefined;\n  const manifest: unknown = JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'), 'utf8'));\n  if (\n    !isRecord(manifest) ||\n    !isRecord(manifest.optionalDependencies) ||\n    typeof manifest.optionalDependencies[packageName] !== 'string'\n  ) {\n    return undefined;\n  }\n  let entry: string;\n  try {\n    entry = createRequire(path.join(packageDirectory, 'package.json')).resolve(packageName);\n  } catch {\n    return undefined;\n  }\n  const nativeDirectory = packageManifestDirectory(entry);\n  if (!nativeDirectory) return undefined;\n  const relative = path.relative(nativeDirectory, canonicalPath(entry)).split(path.sep).join('/');\n  if (!relative || relative.startsWith('../') || path.isAbsolute(relative)) return undefined;\n  return {\n    packageName,\n    packageDirectory: nativeDirectory,\n    files: [{ path: 'package.json' }, { path: relative }],\n  };\n}\n\nfunction currentSqliteVecPlatformPackage(): string | undefined {\n  if (process.platform === 'linux' && currentTursoPlatformPackage() === undefined) return undefined;\n  const platform = process.platform === 'win32' ? 'windows' : process.platform;\n  const target = `${platform}-${process.arch}`;\n  if (!['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'windows-x64'].includes(target)) return undefined;\n  return `sqlite-vec-${target}`;\n}\n\nfunction sqliteVecPlatformResource(packageDirectory: string): CompileExtensionResourcePackage | undefined {\n  const packageName = currentSqliteVecPlatformPackage();\n  if (!packageName) return undefined;\n  const manifest: unknown = JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'), 'utf8'));\n  if (\n    !isRecord(manifest) ||\n    !isRecord(manifest.optionalDependencies) ||\n    typeof manifest.optionalDependencies[packageName] !== 'string'\n  )\n    return undefined;\n  const suffix = process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so';\n  let entry: string;\n  try {\n    entry = createRequire(path.join(packageDirectory, 'package.json')).resolve(`${packageName}/vec0.${suffix}`);\n  } catch {\n    return undefined;\n  }\n  const nativeDirectory = packageManifestDirectory(entry);\n  if (!nativeDirectory) return undefined;\n  const relative = path.relative(nativeDirectory, canonicalPath(entry)).split(path.sep).join('/');\n  if (!relative || relative.startsWith('../') || path.isAbsolute(relative)) return undefined;\n  return { packageName, packageDirectory: nativeDirectory, files: [{ path: 'package.json' }, { path: relative }] };\n}\n\nfunction vectorWasmResource(packageDirectory: string): CompileExtensionResourcePackage {\n  const manifest: unknown = JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'), 'utf8'));\n  if (\n    !isRecord(manifest) ||\n    !Array.isArray(manifest.files) ||\n    !manifest.files.every((file) => typeof file === 'string') ||\n    !manifest.files.includes('ruvector_onnx_embeddings_wasm.js') ||\n    !manifest.files.includes('ruvector_onnx_embeddings_wasm_bg.wasm') ||\n    !manifest.files.includes('loader.js')\n  ) {\n    throw new Error('Unsupported embedding WASM resource manifest');\n  }\n  return {\n    packageName: 'ruvector-onnx-embeddings-wasm',\n    packageDirectory,\n    files: ['package.json', ...manifest.files].map((file) => ({ path: file })),\n  };\n}\n\nfunction keyringResources(packageDirectory: string): CompileExtensionResourcePackage[] {\n  const suffix = currentTursoPlatformPackage()?.slice(TURSO_DATABASE_PACKAGE.length);\n  const packageName = suffix && `@napi-rs/keyring${suffix}`;\n  const manifestPath = path.join(packageDirectory, 'package.json');\n  const manifest: unknown = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));\n  if (\n    !packageName ||\n    !isRecord(manifest) ||\n    !isRecord(manifest.optionalDependencies) ||\n    typeof manifest.optionalDependencies[packageName] !== 'string'\n  ) {\n    throw new Error('Unsupported or missing native keyring binding');\n  }\n  const nativeDirectory = resolvePackageDirectory(packageName, manifestPath);\n  if (!nativeDirectory) throw new Error('Unsupported or missing native keyring binding');\n  const entry = createRequire(manifestPath).resolve(packageName);\n  return [\n    {\n      packageName: '@napi-rs/keyring',\n      packageDirectory,\n      files: ['package.json', 'index.js', 'keytar.js'].map((file) => ({ path: file })),\n    },\n    {\n      packageName,\n      packageDirectory: nativeDirectory,\n      files: [\n        { path: 'package.json' },\n        { path: path.relative(nativeDirectory, canonicalPath(entry)).split(path.sep).join('/') },\n      ],\n    },\n  ];\n}\n\nfunction resourcesWithPinnedNativePlatforms(\n  entries: readonly string[],\n  resources: readonly CompileExtensionResourceBinding[] = [],\n): CompileExtensionResourceBinding[] {\n  const pinned = resources.map((resource) => ({ ...resource, packages: [...resource.packages] }));\n  const packagesByName = new Map(\n    pinned.flatMap((resource) => resource.packages.map((pkg) => [pkg.packageName, pkg] as const)),\n  );\n  for (const directory of nativePackageDirectories(entries)) {\n    const manifest = JSON.parse(fs.readFileSync(path.join(directory, 'package.json'), 'utf8')) as { name: string };\n    if (manifest.name === '@agimon-ai/log-sink-mcp') {\n      // Its createRequire lookup must resolve the pinned embedding package, not the source installation.\n      if (!pinned.some((resource) => canonicalPath(resource.ownerDirectory) === canonicalPath(directory))) {\n        pinned.push({ ownerPackageName: manifest.name, ownerDirectory: directory, packages: [] });\n      }\n      continue;\n    }\n    if (manifest.name === '@napi-rs/keyring') {\n      for (const pkg of keyringResources(directory)) {\n        const existing = packagesByName.get(pkg.packageName);\n        if (existing) {\n          if (canonicalPath(existing.packageDirectory) !== canonicalPath(pkg.packageDirectory)) {\n            throw new Error(`Conflicting native package roots for ${pkg.packageName}`);\n          }\n          continue;\n        }\n        packagesByName.set(pkg.packageName, pkg);\n        pinned.push({ ownerPackageName: pkg.packageName, ownerDirectory: pkg.packageDirectory, packages: [pkg] });\n      }\n      continue;\n    }\n    const sqliteVec = manifest.name === 'sqlite-vec';\n    const platform =\n      manifest.name === 'ruvector-onnx-embeddings-wasm'\n        ? vectorWasmResource(directory)\n        : sqliteVec\n          ? sqliteVecPlatformResource(directory)\n          : tursoPlatformResource(directory);\n    if (!platform) {\n      throw new Error(\n        `Unsupported or missing native ${sqliteVec ? 'sqlite-vec' : 'Turso'} binding for ${process.platform}-${process.arch}`,\n      );\n    }\n    const existing = packagesByName.get(platform.packageName);\n    if (existing) {\n      if (canonicalPath(existing.packageDirectory) !== canonicalPath(platform.packageDirectory)) {\n        throw new Error(`Conflicting native package roots for ${platform.packageName}`);\n      }\n      continue;\n    }\n    packagesByName.set(platform.packageName, platform);\n    pinned.push({\n      ownerPackageName: platform.packageName,\n      ownerDirectory: platform.packageDirectory,\n      packages: [platform],\n    });\n  }\n  return pinned;\n}\n\nfunction tursoPlatformIsPinned(resources: readonly CompileExtensionResourceBinding[]): boolean {\n  const packageName = currentTursoPlatformPackage();\n  return (\n    packageName !== undefined &&\n    resources.some((resource) => resource.packages.some((pkg) => pkg.packageName === packageName))\n  );\n}\n\nfunction directModuleDependencyIsPinned(root: string, resources: readonly CompileExtensionResourceBinding[]): boolean {\n  if (root === 'ruvector-onnx-embeddings-wasm' || root === '@napi-rs/keyring') {\n    return resources.some((resource) => resource.packages.some((pkg) => pkg.packageName === root));\n  }\n  if (root === 'sqlite-vec') {\n    const packageName = currentSqliteVecPlatformPackage();\n    return (\n      packageName !== undefined &&\n      resources.some((resource) => resource.packages.some((pkg) => pkg.packageName === packageName))\n    );\n  }\n  return (\n    (root === TURSO_DATABASE_PACKAGE || root === TURSO_DATABASE_COMMON_PACKAGE) && tursoPlatformIsPinned(resources)\n  );\n}\n\nfunction externalLogicalPath(sourcePath: string): string {\n  const identity = createHash('sha256').update(sourcePath).digest('hex');\n  return `${EXTERNAL_INPUT_PREFIX}${identity}`;\n}\n\nfunction logicalInput(target: string, repositoryRoot: string): LogicalInput {\n  const absolute = canonicalPath(target);\n  if (isInside(repositoryRoot, absolute)) {\n    return {\n      logicalPath: `${REPOSITORY_INPUT_PREFIX}${path.relative(repositoryRoot, absolute).split(path.sep).join('/')}`,\n      target: absolute,\n    };\n  }\n  return {\n    logicalPath: externalLogicalPath(absolute),\n    target: absolute,\n    sourcePath: absolute,\n  };\n}\n\nfunction resolveLogicalInputPath(input: SharedBuildInput, repositoryRoot: string): string | undefined {\n  if (input.logicalPath.startsWith(REPOSITORY_INPUT_PREFIX) && input.sourcePath === undefined) {\n    const target = path.resolve(repositoryRoot, input.logicalPath.slice(REPOSITORY_INPUT_PREFIX.length));\n    return isInside(repositoryRoot, target) ? target : undefined;\n  }\n  if (\n    input.logicalPath.startsWith(EXTERNAL_INPUT_PREFIX) &&\n    input.sourcePath !== undefined &&\n    input.logicalPath === externalLogicalPath(input.sourcePath)\n  ) {\n    return input.sourcePath;\n  }\n  return undefined;\n}\n\nfunction artifactsAreFresh(manifest: CompiledExtensionManifest, version: string, output: string): boolean {\n  return (\n    manifest.version === version &&\n    manifest.output === output &&\n    fs.existsSync(output) &&\n    manifest.artifacts.every((artifact) => fs.existsSync(artifact))\n  );\n}\n\nfunction manifestIsFresh(manifest: ExtensionSetManifest, entries: string[]): boolean {\n  if (!artifactsAreFresh(manifest, SET_CACHE_VERSION, manifest.output)) return false;\n  if (JSON.stringify(manifest.entries) !== JSON.stringify(entries)) {\n    return false;\n  }\n  // A manifest written before outputs were recorded by content cannot vouch for\n  // them, so it is rebuilt once rather than trusted.\n  if (manifest.artifactInputs === undefined || !inputsAreFresh(manifest.artifactInputs)) return false;\n  // Content, not timestamps: a build cache that restored byte-identical inputs\n  // must not force this set to be compiled again.\n  return inputsAreFresh(manifest.inputs);\n}\n\nfunction readCompiledExtensionManifest(manifestPath: string): CompiledExtensionManifest | undefined {\n  try {\n    const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as CompiledExtensionManifest;\n    return parsed && typeof parsed.output === 'string' && Array.isArray(parsed.artifacts) ? parsed : undefined;\n  } catch {\n    return undefined;\n  }\n}\n\nfunction readSetManifest(manifestPath: string): ExtensionSetManifest | undefined {\n  const parsed = readCompiledExtensionManifest(manifestPath) as ExtensionSetManifest | undefined;\n  return parsed && Array.isArray(parsed.entries) && Array.isArray(parsed.inputs) ? parsed : undefined;\n}\n\nfunction writeAtomic(target: string, contents: string | Uint8Array, mode = 0o600): void {\n  fs.mkdirSync(path.dirname(target), { recursive: true });\n  const temporary = `${target}.${process.pid}.${Date.now()}.tmp`;\n  fs.writeFileSync(temporary, contents, { mode });\n  try {\n    fs.renameSync(temporary, target);\n    fs.chmodSync(target, mode);\n  } catch (error) {\n    fs.rmSync(temporary, { force: true });\n    throw error;\n  }\n}\n\ninterface CompiledGraph {\n  entry: string;\n  artifacts: string[];\n}\n\nfunction splitOutputOptions(entryFileNames: string) {\n  return {\n    format: 'esm' as const,\n    sourcemap: false,\n    minify: true,\n    codeSplitting: true,\n    hashCharacters: 'hex' as const,\n    entryFileNames,\n    chunkFileNames: `chunks/[name].[hash:${HASH_LENGTH}]${COMPILED_SUFFIX}`,\n    assetFileNames: `assets/[name].[hash:${HASH_LENGTH}][extname]`,\n  };\n}\n\nfunction artifactTarget(outputDirectory: string, artifact: OutputAsset | OutputChunk): string {\n  const target = path.resolve(outputDirectory, artifact.fileName);\n  const relative = path.relative(outputDirectory, target);\n  if (relative.startsWith('..') || path.isAbsolute(relative)) {\n    throw new Error(`Rolldown emitted an artifact outside the output directory: ${artifact.fileName}`);\n  }\n  return target;\n}\n\nfunction artifactMatches(target: string, contents: string | Uint8Array): boolean {\n  try {\n    const current = fs.readFileSync(target);\n    const generated = typeof contents === 'string' ? Buffer.from(contents) : Buffer.from(contents);\n    return current.equals(generated);\n  } catch {\n    return false;\n  }\n}\n\n/** Writes referenced chunks first so a visible entry always has a complete graph. */\nfunction writeCompiledGraph(generated: RolldownOutput, outputDirectory: string): CompiledGraph {\n  const entry = generated.output.find((artifact) => artifact.type === 'chunk' && artifact.isEntry);\n  if (!entry || entry.type !== 'chunk') throw new Error('Rolldown produced no extension entry');\n  const root = path.resolve(outputDirectory);\n  const remaining = generated.output.filter((artifact) => artifact !== entry);\n  for (const artifact of [...remaining, entry]) {\n    const contents = artifact.type === 'chunk' ? artifact.code : artifact.source;\n    const target = artifactTarget(root, artifact);\n    if (!artifactMatches(target, contents)) writeAtomic(target, contents);\n  }\n  return {\n    entry: artifactTarget(root, entry),\n    artifacts: generated.output.map((artifact) => artifactTarget(root, artifact)).sort(),\n  };\n}\nfunction resourceInputPaths(resources: readonly CompileExtensionResourceBinding[] = []): string[] {\n  return resources.flatMap((resource) =>\n    resource.packages.map((pkg) => pkg.files.map((file) => path.resolve(pkg.packageDirectory, file.path))).flat(),\n  );\n}\n\nfunction validateResourcePackageName(name: string): void {\n  if (!/^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/u.test(name)) {\n    throw new Error(`Invalid resource package name: ${name}`);\n  }\n}\n\nfunction resourceArtifacts(resources: readonly CompileExtensionResourceBinding[] = []): Map<string, SharedBuildAsset> {\n  const artifacts = new Map<string, SharedBuildAsset>();\n  const owners = new Set<string>();\n  for (const resource of resources) {\n    validateResourcePackageName(resource.ownerPackageName);\n    const owner = canonicalPath(resource.ownerDirectory);\n    if (owners.has(owner)) throw new Error(`Duplicate resource owner: ${owner}`);\n    owners.add(owner);\n    for (const pkg of resource.packages) {\n      validateResourcePackageName(pkg.packageName);\n      for (const file of pkg.files) {\n        if (\n          !file.path ||\n          file.path.includes('\\\\') ||\n          path.isAbsolute(file.path) ||\n          file.path.split('/').some((part) => !part || part === './index' || part === '..')\n        ) {\n          throw new Error(`Invalid resource path: ${file.path}`);\n        }\n        if (file.mode !== undefined && (!Number.isInteger(file.mode) || file.mode < 0 || file.mode > 0o777)) {\n          throw new Error(`Invalid resource mode: ${file.mode}`);\n        }\n        const source = canonicalPath(path.resolve(pkg.packageDirectory, file.path));\n        if (!isInside(canonicalPath(pkg.packageDirectory), source))\n          throw new Error(`Resource escapes package: ${file.path}`);\n        const stat = fs.statSync(source);\n        if (!stat.isFile()) throw new Error(`Resource is not a file: ${source}`);\n        const artifact = `node_modules/${pkg.packageName}/${file.path}`;\n        if (artifacts.has(artifact)) throw new Error(`Duplicate resource artifact: ${artifact}`);\n        artifacts.set(artifact, { contents: fs.readFileSync(source), mode: file.mode ?? stat.mode & 0o777 });\n      }\n    }\n  }\n  return artifacts;\n}\n\n/** Bind resource layout and permissions as well as input bytes to the cache identity. */\nfunction resourceCacheKey(\n  resources: readonly CompileExtensionResourceBinding[] = [],\n  artifacts: ReadonlyMap<string, SharedBuildAsset>,\n  repositoryRoot?: string,\n): string {\n  if (resources.length === 0) return '';\n  const identity = (directory: string) =>\n    repositoryRoot ? logicalInput(directory, repositoryRoot).logicalPath : canonicalPath(directory);\n  return createHash('sha256')\n    .update(\n      JSON.stringify({\n        resources: resources.map((resource) => ({\n          ownerPackageName: resource.ownerPackageName,\n          ownerDirectory: identity(resource.ownerDirectory),\n          packages: resource.packages.map((pkg) => ({ ...pkg, packageDirectory: identity(pkg.packageDirectory) })),\n        })),\n        modes: [...artifacts].map(([name, asset]) => [name, asset.mode]),\n      }),\n    )\n    .digest('hex');\n}\n\nfunction validateResourceOutputPaths(outputDirectory: string, artifacts: ReadonlyMap<string, SharedBuildAsset>): void {\n  for (const artifact of artifacts.keys()) {\n    let target = canonicalPath(outputDirectory);\n    for (const segment of artifact.split('/')) {\n      target = path.join(target, segment);\n      try {\n        if (fs.lstatSync(target).isSymbolicLink()) throw new Error(`Resource output contains a symlink: ${artifact}`);\n      } catch (error) {\n        if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n      }\n    }\n  }\n}\n\nfunction resourceArtifactsAreFresh(outputDirectory: string, artifacts: ReadonlyMap<string, SharedBuildAsset>): boolean {\n  for (const [artifact, asset] of artifacts) {\n    const target = path.join(outputDirectory, artifact);\n    try {\n      if (\n        !isInside(canonicalPath(outputDirectory), canonicalPath(target)) ||\n        !artifactMatches(target, asset.contents) ||\n        (fs.statSync(target).mode & 0o777) !== asset.mode\n      )\n        return false;\n    } catch {\n      return false;\n    }\n  }\n  return true;\n}\n\nfunction resourceModuleUrl(\n  id: string,\n  outputDirectory: string,\n  resources: readonly CompileExtensionResourceBinding[] = [],\n): string | undefined {\n  const resource = resources.find((candidate) => isInside(canonicalPath(candidate.ownerDirectory), canonicalPath(id)));\n  if (!resource) return undefined;\n  const relative = path.relative(canonicalPath(resource.ownerDirectory), canonicalPath(id));\n  return pathToFileURL(path.join(outputDirectory, 'node_modules', resource.ownerPackageName, relative)).href;\n}\n\nfunction sharedLookupKey(entries: readonly LogicalInput[], outputName: string): string {\n  return createHash('sha256')\n    .update(SHARED_BUILD_VERSION)\n    .update(process.version)\n    .update(process.platform)\n    .update(process.arch)\n    .update(outputName)\n    .update(JSON.stringify(entries.map((entry) => entry.logicalPath)))\n    .digest('hex');\n}\n\ninterface TokenizedInputs {\n  shared: SharedBuildInput[];\n  byTarget: Map<string, string>;\n}\n\nfunction tokenizedInputs(inputs: ReadonlySet<string>, repositoryRoot: string): TokenizedInputs {\n  const logical: LogicalInput[] = [];\n  for (const target of inputs) logical.push(logicalInput(target, repositoryRoot));\n  logical.sort((left, right) => left.logicalPath.localeCompare(right.logicalPath));\n  const shared: SharedBuildInput[] = [\n    { logicalPath: REPOSITORY_INPUT_PREFIX, sha256: '', token: `${SHARED_PATH_TOKEN_PREFIX}ROOT__` },\n  ];\n  const byTarget = new Map<string, string>([[repositoryRoot, `${SHARED_PATH_TOKEN_PREFIX}ROOT__`]]);\n  const tokenByLogicalPath = new Map<string, string>();\n  logical.forEach((input, index) => {\n    const existing = tokenByLogicalPath.get(input.logicalPath);\n    const token = existing ?? `${SHARED_PATH_TOKEN_PREFIX}${String(index)}__`;\n    if (!existing) {\n      shared.push({\n        logicalPath: input.logicalPath,\n        sha256: contentSha256(fs.readFileSync(input.target)),\n        token,\n        ...(input.sourcePath ? { sourcePath: input.sourcePath } : {}),\n      });\n      tokenByLogicalPath.set(input.logicalPath, token);\n    }\n    byTarget.set(path.resolve(input.target), token);\n  });\n  for (const target of inputs) {\n    const input = logicalInput(target, repositoryRoot);\n    const token = tokenByLogicalPath.get(input.logicalPath);\n    if (token) byTarget.set(path.resolve(target), token);\n  }\n  return { shared, byTarget };\n}\n\nfunction tokenizedArtifactContents(\n  generated: RolldownOutput,\n  tokens: ReadonlyMap<string, string>,\n  outputDirectory: string,\n): Map<string, string | Uint8Array | SharedBuildAsset> {\n  const artifacts = new Map<string, string | Uint8Array | SharedBuildAsset>();\n  const outputToken = `${SHARED_PATH_TOKEN_PREFIX}OUTPUT__`;\n  const replacements = [...tokens.entries()].sort(([left], [right]) => right.length - left.length);\n  for (const artifact of generated.output) {\n    if (artifact.type === 'asset') {\n      artifacts.set(artifact.fileName, typeof artifact.source === 'string' ? artifact.source : artifact.source);\n      continue;\n    }\n    let source = artifact.code\n      .replaceAll(pathToFileURL(outputDirectory).href, `${outputToken}:url`)\n      .replaceAll(outputDirectory, outputToken);\n    for (const [target, token] of replacements) {\n      source = source\n        .replaceAll(pathToFileURL(target).href, `${token}:url`)\n        .replaceAll(pathToImportSpecifier(target), token)\n        .replaceAll(target, token);\n    }\n    artifacts.set(artifact.fileName, source);\n  }\n  return artifacts;\n}\n\nfunction writeLocalSetManifest(\n  manifestPath: string,\n  entries: string[],\n  output: string,\n  artifacts: string[],\n  inputs: ReadonlySet<string>,\n): void {\n  const fingerprintAll = (paths: readonly string[]): InputFingerprint[] =>\n    [...paths]\n      .map((target) => fingerprintInput(target))\n      .filter((value): value is InputFingerprint => value !== undefined)\n      .sort((left, right) => left.path.localeCompare(right.path));\n  const sortedArtifacts = [...artifacts].sort();\n  writeAtomic(\n    manifestPath,\n    `${JSON.stringify(\n      {\n        version: SET_CACHE_VERSION,\n        entries,\n        output,\n        artifacts: sortedArtifacts,\n        inputs: fingerprintAll([...inputs]),\n        artifactInputs: fingerprintAll([output, ...sortedArtifacts]),\n      },\n      null,\n      2,\n    )}\\n`,\n  );\n}\n\nfunction materializeSharedSet(\n  build: ResolvedSharedBuild,\n  outputDirectory: string,\n  manifestPath: string,\n  entries: string[],\n): string {\n  const output = materializeSharedBuild(build, outputDirectory);\n  const inputs = new Set(build.replacements.values());\n  const artifacts = build.manifest.artifacts.map((artifact) => path.join(outputDirectory, artifact.path));\n  writeLocalSetManifest(manifestPath, entries, output, artifacts, inputs);\n  return output;\n}\n\n/** Stable lookup key for one exact Pi load order. */\nexport function extensionSetKey(entries: readonly string[]): string {\n  return createHash('sha256')\n    .update(SET_CACHE_VERSION)\n    .update(JSON.stringify(entries.map((entry) => path.resolve(entry))))\n    .digest('hex')\n    .slice(0, HASH_LENGTH);\n}\n\nfunction extensionSetSource(entries: readonly string[]): string {\n  const helper = optionalPackageEntry(EXTENSION_SOURCE_HELPER, import.meta.url);\n  if (!helper) throw new Error(`Cannot resolve ${EXTENSION_SOURCE_HELPER}`);\n  const loaders = entries.map((entry) => `() => import(${javascriptStringLiteral(pathToImportSpecifier(entry))})`);\n  const names = entries.map((entry) => javascriptStringLiteral(entry));\n  return [\n    `import { withExtensionSource } from ${javascriptStringLiteral(pathToImportSpecifier(helper))};`,\n    `const loaders = [${loaders.join(',')}];`,\n    `const names = [${names.join(',')}];`,\n    'function report(index, phase, startedAt, error) {',\n    '  const elapsed = (performance.now() - startedAt).toFixed(1);',\n    '  const detail = error instanceof Error ? \": \" + error.message : error === undefined ? \"\" : \": \" + String(error);',\n    '  process.stderr.write(\"[doompi:timing] \" + phase + \" \" + elapsed + \"ms \" + names[index] + detail + \"\\\\n\");',\n    '}',\n    'export default async function doompiExtensionSet(pi) {',\n    '  const timings = process.env.DOOMPI_TIMING === \"1\" || process.env.PI_TIMING === \"1\";',\n    '  const loaded = await Promise.all(loaders.map(async (load, index) => {',\n    '    const startedAt = performance.now();',\n    '    try {',\n    '      const extension = await load();',\n    '      if (timings) report(index, \"import\", startedAt);',\n    '      return extension;',\n    '    } catch (error) {',\n    '      report(index, \"import-error\", startedAt, error);',\n    '      return undefined;',\n    '    }',\n    '  }));',\n    '  for (let index = 0; index < loaded.length; index += 1) {',\n    '    const extension = loaded[index];',\n    '    if (!extension) continue;',\n    '    const startedAt = performance.now();',\n    '    try {',\n    '      const factory = extension.default;',\n    \"      if (typeof factory !== 'function') throw new Error('does not export an extension factory');\",\n    '      await factory(withExtensionSource(pi, names[index]));',\n    '      if (timings) report(index, \"factory\", startedAt);',\n    '    } catch (error) {',\n    '      report(index, \"factory-error\", startedAt, error);',\n    '    }',\n    '  }',\n    '}',\n  ].join('\\n');\n}\n\nfunction pathToImportSpecifier(target: string): string {\n  // Rolldown accepts absolute POSIX paths directly. Windows needs a file URL,\n  // but replacing separators is enough for its platform-independent parser.\n  return path.resolve(target).split(path.sep).join('/');\n}\n\nfunction setExternalResolver(\n  inputs: Set<string>,\n  kind: CompilationKind,\n  entry?: string,\n  resources: readonly CompileExtensionResourceBinding[] = [],\n) {\n  return {\n    name: 'doom-set-external',\n    async resolveId(\n      this: { resolve: (id: string, importer?: string, options?: unknown) => Promise<{ id: string } | null> },\n      specifier: string,\n      importer: string | undefined,\n      options: unknown,\n    ): Promise<{ id: string; external: boolean } | null> {\n      if (specifier === VIRTUAL_SET_ENTRY) return null;\n      if (NODE_BUILTINS.has(specifier) || specifier.startsWith('node:')) {\n        return { id: specifier, external: true };\n      }\n\n      if (path.isAbsolute(specifier)) {\n        if (!importer && entry && path.resolve(specifier) === path.resolve(entry)) return null;\n        const root = packageRootFromPath(specifier);\n        if (root && kind === 'module' && DIRECT_EXTERNAL_PACKAGES.has(root)) {\n          inputs.add(specifier);\n          return { id: specifier, external: true };\n        }\n        if (\n          root &&\n          kind === 'module' &&\n          directModuleDependencyIsUnbundlable(root) &&\n          !directModuleDependencyIsPinned(root, resources)\n        ) {\n          throw directModuleDependencyError(root, importer);\n        }\n        if (root === '@napi-rs/keyring' && kind === 'module' && directModuleDependencyIsPinned(root, resources)) {\n          const directory = packageManifestDirectory(specifier);\n          if (!directory) throw directModuleDependencyError(root, importer);\n          return {\n            id: `${root}/${path.relative(directory, canonicalPath(specifier)).split(path.sep).join('/')}`,\n            external: true,\n          };\n        }\n        if (\n          root &&\n          (HOSTED_PACKAGES.has(root) ||\n            NATIVE_PACKAGES.has(root) ||\n            (kind === 'pi-set' && STARTUP_EXTERNAL_PACKAGES.has(root)))\n        ) {\n          inputs.add(specifier);\n          return { id: specifier, external: true };\n        }\n        return null;\n      }\n      if (specifier.startsWith('./index')) return null;\n\n      const renamed = renameScope(specifier);\n      const root = packageRootOf(renamed);\n      if (root && HOSTED_PACKAGES.has(root)) {\n        const hosted = optionalPackageEntry(renamed, import.meta.url);\n        if (hosted) {\n          inputs.add(hosted);\n          return { id: hosted, external: true };\n        }\n      }\n      if (root === 'typebox') {\n        const typebox = piExtensionDependencyEntry(renamed);\n        if (typebox) {\n          inputs.add(typebox);\n          return { id: typebox, external: kind === 'pi-set' };\n        }\n      }\n      if (root && kind === 'module' && DIRECT_EXTERNAL_PACKAGES.has(root)) {\n        const resolved = await this.resolve(renamed, importer, options);\n        if (resolved) {\n          inputs.add(resolved.id);\n          return { id: resolved.id, external: true };\n        }\n      }\n      if (\n        root &&\n        kind === 'module' &&\n        directModuleDependencyIsUnbundlable(root) &&\n        !directModuleDependencyIsPinned(root, resources)\n      ) {\n        throw directModuleDependencyError(root, importer);\n      }\n      if (root === '@napi-rs/keyring' && kind === 'module' && directModuleDependencyIsPinned(root, resources)) {\n        return { id: renamed, external: true };\n      }\n      if (root && kind === 'pi-set' && (NATIVE_PACKAGES.has(root) || STARTUP_EXTERNAL_PACKAGES.has(root))) {\n        const resolved = await this.resolve(renamed, importer, options);\n        if (resolved) {\n          inputs.add(resolved.id);\n          return { id: resolved.id, external: true };\n        }\n      }\n      return null;\n    },\n  };\n}\n\nfunction inputCollector(inputs: Set<string>) {\n  return {\n    name: 'doom-set-inputs',\n    load(id: string): null {\n      if (path.isAbsolute(id) && fs.existsSync(id)) inputs.add(id);\n      return null;\n    },\n  };\n}\n\n/** An unresolved bare import would otherwise become a broken dist external. */\nfunction failUnresolvedImport(_level: LogLevel, log: RolldownLog, handler: LogOrStringHandler): void {\n  if (log.code === 'UNRESOLVED_IMPORT') handler('error', log);\n}\n\ninterface SourceRange {\n  start: number;\n  end: number;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction collectImportMetaUrlRanges(value: unknown, ranges: SourceRange[]): void {\n  if (Array.isArray(value)) {\n    for (const item of value) collectImportMetaUrlRanges(item, ranges);\n    return;\n  }\n  if (!isRecord(value)) return;\n\n  const object = value.object;\n  const property = value.property;\n  if (\n    value.type === 'MemberExpression' &&\n    value.computed === false &&\n    typeof value.start === 'number' &&\n    typeof value.end === 'number' &&\n    isRecord(object) &&\n    object.type === 'MetaProperty' &&\n    isRecord(object.meta) &&\n    object.meta.name === 'import' &&\n    isRecord(object.property) &&\n    object.property.name === 'meta' &&\n    isRecord(property) &&\n    property.name === 'url'\n  ) {\n    ranges.push({ start: value.start, end: value.end });\n    return;\n  }\n\n  for (const child of Object.values(value)) collectImportMetaUrlRanges(child, ranges);\n}\n\n/** Keeps package-owned resource lookup anchored to each original source file. */\nfunction preserveImportMetaUrl(outputDirectory: string, resources: readonly CompileExtensionResourceBinding[] = []) {\n  return {\n    name: 'doom-original-import-meta-url',\n    transform(\n      this: {\n        parse: (source: string, options?: { lang?: 'js' | 'jsx' | 'ts' | 'tsx' }) => unknown;\n      },\n      source: string,\n      id: string,\n    ): string | null {\n      if (!path.isAbsolute(id) || !source.includes('import.meta.url')) return null;\n      const packageRoot = packageRootFromPath(id);\n      if (packageRoot === TURSO_DATABASE_PACKAGE || packageRoot === TURSO_DATABASE_COMMON_PACKAGE) return null;\n      const extension = path.extname(id).toLowerCase();\n      const lang = extension === '.tsx' ? 'tsx' : extension === '.jsx' ? 'jsx' : isTypeScriptEntry(id) ? 'ts' : 'js';\n      const ranges: SourceRange[] = [];\n      collectImportMetaUrlRanges(this.parse(source, { lang }), ranges);\n      if (ranges.length === 0) return null;\n      const replacement = javascriptStringLiteral(\n        resourceModuleUrl(id, outputDirectory, resources) ?? pathToFileURL(id).href,\n      );\n      let transformed = source;\n      for (const range of ranges.sort((left, right) => right.start - left.start)) {\n        transformed = `${transformed.slice(0, range.start)}${replacement}${transformed.slice(range.end)}`;\n      }\n      return transformed;\n    },\n  };\n}\n\n/** Location of the lightweight input-fingerprint record for one extension set. */\nexport function extensionSetManifestPath(\n  entries: readonly string[],\n  cacheDirectory: string,\n  options: CompileExtensionSetOptions = {},\n): string {\n  const normalized = entries.map((entry) => path.resolve(entry));\n  const key = extensionSetKey(normalized);\n  const outputDirectory = path.resolve(options.outputDirectory ?? path.join(cacheDirectory, SET_DIRECTORY));\n  const outputName = safeOutputName(options.outputName ?? DEFAULT_SET_OUTPUT_NAME);\n  // One graph can be emitted under several named mode artifacts. Keep their\n  // cache records separate without changing extensionSetKey, which is the\n  // runtime lookup key for an exact activation order.\n  const outputKey = createHash('sha256').update(outputDirectory).update(outputName).digest('hex').slice(0, HASH_LENGTH);\n  return path.join(cacheDirectory, SET_DIRECTORY, `${key}.${outputKey}${MANIFEST_SUFFIX}`);\n}\n\n/**\n * Compiles an ordered extension set into one native ESM entry.\n *\n * The generated entry starts every module load together, then invokes factories\n * sequentially in activation order. Its manifest records every loaded module,\n * so a dependency edit invalidates the cache without running the compiler.\n */\nexport async function compileExtensionSet(\n  entries: readonly string[],\n  cacheDirectory: string,\n  options: CompileExtensionSetOptions = {},\n): Promise<string> {\n  return compileGraph(entries, cacheDirectory, options, 'pi-set');\n}\n\n/** Exact compiler receipt used by sync to validate a direct module without importing it. */\nexport function extensionModuleManifestPath(\n  entry: string,\n  cacheDirectory: string,\n  options: CompileExtensionSetOptions = {},\n): string {\n  const root = options.repositoryRoot ? canonicalPath(options.repositoryRoot) : undefined;\n  const resources = resourcesWithPinnedNativePlatforms([path.resolve(entry)], options.resources);\n  const resourceKey = resourceCacheKey(resources, resourceArtifacts(resources), root);\n  const base = `${extensionSetManifestPath([entry], cacheDirectory, options)}.module.json`;\n  return resourceKey ? `${base}.${resourceKey}.json` : base;\n}\n\n/** Preserve a module's exports instead of wrapping its default in a Pi factory.\n * External dependency and resource policies remain those of the shared compiler.\n */\nexport async function compileExtensionModule(\n  entry: string,\n  cacheDirectory: string,\n  options: CompileExtensionSetOptions = {},\n): Promise<string> {\n  return compileGraph([entry], cacheDirectory, options, 'module');\n}\n\nasync function compileGraph(\n  entries: readonly string[],\n  cacheDirectory: string,\n  options: CompileExtensionSetOptions,\n  kind: 'pi-set' | 'module',\n): Promise<string> {\n  if (entries.length === 0) throw new Error('Cannot compile an empty extension set');\n  const normalized = entries.map((entry) => path.resolve(entry));\n  const setDirectory = path.join(cacheDirectory, SET_DIRECTORY);\n  fs.mkdirSync(setDirectory, { recursive: true });\n  const outputDirectory = path.resolve(options.outputDirectory ?? setDirectory);\n  const outputName = safeOutputName(options.outputName ?? DEFAULT_SET_OUTPUT_NAME);\n  fs.mkdirSync(outputDirectory, { recursive: true });\n  const repositoryRoot = options.repositoryRoot ? canonicalPath(options.repositoryRoot) : undefined;\n  const effectiveResources =\n    kind === 'module'\n      ? resourcesWithPinnedNativePlatforms(normalized, options.resources)\n      : [...(options.resources ?? [])];\n  const resources = resourceArtifacts(effectiveResources);\n  validateResourceOutputPaths(outputDirectory, resources);\n  const resourceKey = resourceCacheKey(effectiveResources, resources, repositoryRoot);\n  const setManifestPath = extensionSetManifestPath(normalized, cacheDirectory, options);\n  const manifestPath =\n    kind === 'module'\n      ? extensionModuleManifestPath(normalized[0], cacheDirectory, options)\n      : resourceKey\n        ? `${setManifestPath}.${resourceKey}.json`\n        : setManifestPath;\n  const previous = readSetManifest(manifestPath);\n  if (previous && manifestIsFresh(previous, normalized) && resourceArtifactsAreFresh(outputDirectory, resources))\n    return previous.output;\n\n  const resourceInputs = resourceInputPaths(effectiveResources);\n  const generate = async (): Promise<{ generated: RolldownOutput; inputs: Set<string> }> => {\n    const inputs = new Set([...normalized, ...resourceInputs]);\n    const source = extensionSetSource(normalized);\n    const { rolldown } = await import('rolldown');\n    const build = await rolldown({\n      input: kind === 'module' ? normalized[0] : VIRTUAL_SET_ENTRY,\n      platform: 'node',\n      plugins: [\n        {\n          name: 'doom-set-entry',\n          resolveId(id: string): string | null {\n            return id === VIRTUAL_SET_ENTRY ? id : null;\n          },\n          load(id: string): string | null {\n            return id === VIRTUAL_SET_ENTRY ? source : null;\n          },\n        },\n        setExternalResolver(inputs, kind, normalized[0], effectiveResources),\n        preserveImportMetaUrl(outputDirectory, effectiveResources),\n        inputCollector(inputs),\n      ],\n      onLog: failUnresolvedImport,\n    });\n    try {\n      return {\n        generated: await build.generate(splitOutputOptions(`${outputName}.[hash:${HASH_LENGTH}]${COMPILED_SUFFIX}`)),\n        inputs,\n      };\n    } finally {\n      await build.close();\n    }\n  };\n\n  if (repositoryRoot && options.sharedCacheDirectory) {\n    const logicalEntries = [...normalized, ...resourceInputs].map((entry) => logicalInput(entry, repositoryRoot));\n    const setLookupKey = sharedLookupKey(logicalEntries, outputName);\n    const lookupKey =\n      kind === 'module' || resourceKey\n        ? createHash('sha256').update(kind).update(':').update(setLookupKey).update(resourceKey).digest('hex')\n        : setLookupKey;\n    const resolveInput = (input: SharedBuildInput): string | undefined =>\n      resolveLogicalInputPath(input, repositoryRoot);\n    return withSharedBuildLock(options.sharedCacheDirectory, lookupKey, async () => {\n      const cached = findSharedBuild(options.sharedCacheDirectory as string, lookupKey, resolveInput);\n      if (cached) return materializeSharedSet(cached, outputDirectory, manifestPath, normalized);\n\n      const { generated, inputs } = await generate();\n      const tokenized = tokenizedInputs(inputs, repositoryRoot);\n      const artifacts = tokenizedArtifactContents(generated, tokenized.byTarget, outputDirectory);\n      for (const [artifactPath, asset] of resources) {\n        if (artifacts.has(artifactPath)) throw new Error(`Duplicate resource artifact: ${artifactPath}`);\n        artifacts.set(artifactPath, asset);\n      }\n      if (\n        [...artifacts.values()].some((contents) => typeof contents === 'string' && contents.includes(repositoryRoot))\n      ) {\n        throw new Error('Shared build graph still contains an absolute worktree path after tokenization');\n      }\n      const entry = generated.output.find((artifact) => artifact.type === 'chunk' && artifact.isEntry);\n      if (!entry) throw new Error('Rolldown produced no shared extension entry');\n      publishSharedBuild({\n        cacheDirectory: options.sharedCacheDirectory as string,\n        lookupKey,\n        entry: entry.fileName,\n        inputs: tokenized.shared,\n        artifacts,\n      });\n      const published = findSharedBuild(options.sharedCacheDirectory as string, lookupKey, resolveInput);\n      if (!published) throw new Error('Published shared build could not be verified');\n      return materializeSharedSet(published, outputDirectory, manifestPath, normalized);\n    });\n  }\n\n  const { generated, inputs } = await generate();\n  const compiled = writeCompiledGraph(generated, outputDirectory);\n  const resourceFiles: string[] = [];\n  for (const [artifact, asset] of resources) {\n    const target = path.resolve(canonicalPath(outputDirectory), artifact);\n    if (!isInside(canonicalPath(outputDirectory), canonicalPath(target)))\n      throw new Error(`Resource escapes output: ${artifact}`);\n    fs.mkdirSync(path.dirname(target), { recursive: true, mode: 0o700 });\n    writeAtomic(target, asset.contents, asset.mode ?? 0o600);\n    resourceFiles.push(target);\n  }\n  writeLocalSetManifest(manifestPath, normalized, compiled.entry, [...compiled.artifacts, ...resourceFiles], inputs);\n  return compiled.entry;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,sBAAsB;CAAC;CAAO;CAAQ;AAAM;AAClD,MAAM,kBAAkB;AAGxB,MAAM,oBAAoB;AAC1B,MAAM,cAAc;AACpB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAC1B,MAAM,0BAA0B;AAChC,MAAM,uBAAuB;AAC7B,MAAM,2BAA2B;AACjC,MAAM,0BAA0B;AAChC,MAAM,wBAAwB;AAC9B,MAAM,0BAA0B;;AAGhC,SAAS,wBAAwB,OAAuB;CACtD,OAAO,KAAK,UAAU,KAAK,CAAC,CACzB,WAAW,KAAK,SAAS,CAAC,CAC1B,WAAW,UAAU,SAAS,CAAC,CAC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