@agimon-ai/doompi 0.0.1-alpha.113 → 0.0.1-alpha.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/terminalChildSession.cjs +1 -0
- package/dist/extensions/terminalChildSession.cjs.map +1 -1
- package/dist/extensions/terminalChildSession.d.mts.map +1 -1
- package/dist/extensions/terminalChildSession.mjs +2 -1
- package/dist/extensions/terminalChildSession.mjs.map +1 -1
- package/dist/src/builders/hooks/index.cjs +95 -0
- package/dist/src/builders/hooks/index.cjs.map +1 -0
- package/dist/src/builders/hooks/index.mjs +89 -0
- package/dist/src/builders/hooks/index.mjs.map +1 -0
- package/dist/src/builders/server/runtime.cjs +3 -1
- package/dist/src/builders/server/runtime.cjs.map +1 -1
- package/dist/src/builders/server/runtime.mjs +4 -2
- package/dist/src/builders/server/runtime.mjs.map +1 -1
- package/dist/src/cli/commands/sync/index.cjs +13 -4
- package/dist/src/cli/commands/sync/index.cjs.map +1 -1
- package/dist/src/cli/commands/sync/index.d.mts.map +1 -1
- package/dist/src/cli/commands/sync/index.mjs +9 -0
- package/dist/src/cli/commands/sync/index.mjs.map +1 -1
- package/dist/src/cli/commands/sync/inspection.cjs +1 -0
- package/dist/src/cli/commands/sync/inspection.cjs.map +1 -1
- package/dist/src/cli/commands/sync/inspection.d.mts.map +1 -1
- package/dist/src/cli/commands/sync/inspection.mjs +1 -0
- package/dist/src/cli/commands/sync/inspection.mjs.map +1 -1
- package/dist/src/compiler/index.cjs +13 -0
- package/dist/src/compiler/index.cjs.map +1 -1
- package/dist/src/compiler/index.mjs +13 -0
- package/dist/src/compiler/index.mjs.map +1 -1
- package/dist/src/composition/harnessState/index.d.mts.map +1 -1
- package/dist/src/composition/syncDrift/index.cjs +27 -0
- package/dist/src/composition/syncDrift/index.cjs.map +1 -1
- package/dist/src/composition/syncDrift/index.d.mts.map +1 -1
- package/dist/src/composition/syncDrift/index.mjs +27 -1
- package/dist/src/composition/syncDrift/index.mjs.map +1 -1
- package/dist/src/composition/syncState/index.cjs +2 -1
- package/dist/src/composition/syncState/index.cjs.map +1 -1
- package/dist/src/composition/syncState/index.d.mts +1 -1
- package/dist/src/composition/syncState/index.d.mts.map +1 -1
- package/dist/src/composition/syncState/index.mjs +2 -1
- package/dist/src/composition/syncState/index.mjs.map +1 -1
- package/package.json +29 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["path","os","globalDoomConfigDirectory","resolveDoomConfigurationRoot","HARNESS_STATE_POINTER","DOOMPI_MAJOR_MODE_ENV","DOOMPI_DOMAINS_ENV","DOOMPI_PROFILE_ENV","fs","spawnSync","doomPiPackageRoot","DOOMPI_API_VERSION","loadMajorModesConfigLenient","loadDoomConfigLenient","loadDomains","parseHarnessArgs","selectionEnvironment","toSelection","piAgentDirectory","piExtensionDispatcherIsUpgradeable","piIntegrationDrift","missingLayerPackageSpecifiers","createLayerResolvers","readLocatedSyncState","selectionCompositionFingerprint","collectDrift","syncRegistrationNeedsApiMigration","readSyncDrift","SyncProgress","acquireSyncLocationLock","resolveSyncLocation","crypto","syncGenerationDirectory","buildHarnessContext","ensureLayerPackages","recordResolvedEntries","piThemeDirectory","DEFAULT_THEME_NAME","SYNC_STATE_VERSION","computeInputsHash","computeWebSourcesHash","loadHarnessState","buildSyncedRuntime","syncWebBundle","syncServerBundle","syncMcpBundle","DOOM_SERVER_BUNDLE_FILE","DOOM_MCP_BUNDLE_FILE","computeServerSourcesHash","computeMcpSourcesHash","writeSyncState","writeProjectPiSettings","readMcpServerNames","SYNC_REGISTRATION_VERSION","syncStateSha256"],"sources":["../../../../../src/cli/commands/sync/index.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/doompi-config/config';\nimport { loadDomains } from '@agimon-ai/doompi-config/domains';\nimport { loadMajorModesConfigLenient } from '@agimon-ai/doompi-config/majorModes';\nimport type { ConfigDiagnostic } from '@agimon-ai/doompi-config/types';\nimport { DOOM_MCP_BUNDLE_FILE } from '@agimon-ai/doompi-core/mcpFacet';\nimport { piAgentDirectory, piThemeDirectory } from '@agimon-ai/doompi-core/runtimePiSettings';\nimport { DOOM_SERVER_BUNDLE_FILE } from '@agimon-ai/doompi-core/serverFacet';\nimport {\n acquireSyncLocationLock,\n resolveSyncLocation,\n syncGenerationDirectory,\n} from '@agimon-ai/doompi-core/syncLocation';\nimport {\n DOOMPI_API_VERSION,\n publishSyncRegistration,\n SYNC_REGISTRATION_VERSION,\n syncStateSha256,\n type SyncPackageRegistration,\n} from '@agimon-ai/doompi-core/syncRegistration';\nimport { DEFAULT_THEME_NAME } from '@agimon-ai/doompi-ui/theme';\n\nimport { buildSyncedRuntime } from '../../../builders/cli';\nimport { createLayerResolvers, type ExtensionComposition } from '../../../builders/cli/extensionAssembler';\nimport { buildHarnessContext } from '../../../builders/cli/harnessContext';\nimport { doomPiPackageRoot, writePiExtensionAlias } from '../../../builders/cli/piExtensionAlias';\nimport { piExtensionDispatcherIsUpgradeable } from '../../../builders/cli/piExtensionDispatcher';\nimport { writeProjectPiSettings } from '../../../builders/cli/projectSettings';\nimport { syncServerBundle } from '../../../builders/server';\nimport { syncMcpBundle } from '../../../builders/server/mcpBundle';\nimport { syncWebBundle } from '../../../builders/web';\nimport { HARNESS_STATE_POINTER, loadHarnessState } from '../../../composition/harnessState';\nimport { ensureLayerPackages, missingLayerPackageSpecifiers } from '../../../composition/layerPackageInstaller';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { resolveDoomConfigurationRoot } from '../../../composition/repository';\nimport { readSyncDrift } from '../../../composition/syncDrift';\nimport {\n computeInputsHash,\n computeMcpSourcesHash,\n computeServerSourcesHash,\n computeWebSourcesHash,\n readLocatedSyncState,\n readMcpServerNames,\n recordResolvedEntries,\n SYNC_STATE_VERSION,\n type SyncSelection,\n type SyncState,\n writeSyncState,\n} from '../../../composition/syncState';\nimport type { HarnessOptions } from '../../../composition/types/harness';\nimport { DOOMPI_DOMAINS_ENV, DOOMPI_MAJOR_MODE_ENV, DOOMPI_PROFILE_ENV } from '../../matrixOptions';\nimport { parseHarnessArgs } from '../../options';\nimport {\n collectDrift,\n piIntegrationDrift,\n selectionCompositionFingerprint,\n selectionEnvironment,\n syncRegistrationNeedsApiMigration,\n toSelection,\n type SyncSettingsMode,\n} from './inspection';\nimport { SyncProgress, type SyncProgressOutput } from './presenter';\n\nexport {\n collectDrift,\n selectionCompositionFingerprint,\n selectionEnvironment,\n syncRegistrationNeedsApiMigration,\n toSelection,\n type SyncSettingsMode,\n} from './inspection';\n\n/**\n * `doom-pi sync`: resolve the matrix once and write it where plain Pi finds it.\n *\n * The doom-emacs split. Everything that needs a real Node process (module\n * resolution, staging skills and agents, generating the MCP config) happens\n * here, and the doom-pi extension then only reads what this produced. The\n * launcher is untouched and keeps resolving the same matrix per run.\n */\n\nconst SYNC_COMMAND = 'sync';\nconst CHECK_OPTION = '--check';\n/** Republishes even when nothing drifted, for a generation suspected of being damaged. */\nconst FORCE_OPTION = '--force';\nconst GLOBAL_OPTION = '--global';\nconst HARNESS_ROOT_ENV = 'DOOMPI_ROOT';\nconst PERSONA_FILE_ENV = 'DOOMPI_PERSONA_FILE';\nconst HOOK_EMITTER = path.join('tools', 'harness', 'emit-hooks.mjs');\nconst NONE = '(none)';\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst SYNC_LABEL = 'sync';\nconst RUNTIME_LABEL = 'runtime';\nconst WEB_LABEL = 'web';\nconst API_LABEL = 'api';\n\nexport interface SyncRoots {\n globalOnly: boolean;\n globalRoot: string;\n sourceRoot: string;\n targetRoot: string;\n}\n\n/** Resolves the configuration source and publication destination for one sync. */\nexport function resolveSyncRoots(\n args: readonly string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n homeDirectory = environment.HOME ?? os.homedir(),\n): SyncRoots {\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const inheritedRoot = environment[HARNESS_ROOT_ENV];\n const sourceRoot = inheritedRoot\n ? path.resolve(inheritedRoot)\n : resolveDoomConfigurationRoot(currentDirectory, homeDirectory);\n const globalOnly = args.includes(GLOBAL_OPTION);\n return { globalOnly, globalRoot, sourceRoot, targetRoot: globalOnly ? globalRoot : sourceRoot };\n}\n\nconst GLOBAL_SCOPE_INHERITED_KEYS = [\n HARNESS_ROOT_ENV,\n HARNESS_STATE_POINTER,\n DOOMPI_MAJOR_MODE_ENV,\n DOOMPI_DOMAINS_ENV,\n DOOMPI_PROFILE_ENV,\n] as const;\n\n/** Removes workspace-only state before a global runtime is resolved. */\nexport function environmentForSyncScope(environment: NodeJS.ProcessEnv, globalOnly: boolean): NodeJS.ProcessEnv {\n if (!globalOnly) return environment;\n const scoped = { ...environment };\n for (const key of GLOBAL_SCOPE_INHERITED_KEYS) delete scoped[key];\n return scoped;\n}\n\n/**\n * Harness variables worth recording, by prefix or exact name.\n *\n * An allowlist rather than the whole environment: the state file is a snapshot\n * of resolved configuration, and dumping `process.env` into it would write\n * every credential the sync happened to run with onto disk.\n */\nconst RECORDED_PREFIXES = ['DOOMPI_'];\nconst RECORDED_KEYS = ['CLAUDE_PROJECT_DIR', 'CODEX_REPO_ROOT', 'ORIGINAL_REPO_PATH', 'MCP_UI_VIEWER'];\n/**\n * Launcher-only values a synced session must not inherit.\n *\n * The child extension list is recomposed on every load, and the subagent binary\n * points at `pi.sh`, which a session started as plain `pi` should not shell out\n * to: Doom Team resolves Pi's own CLI when the variable is absent.\n */\nconst EXCLUDED_KEYS = new Set([\n 'DOOMPI_DISTRIBUTION',\n 'DOOMPI_CHILD_EXTENSIONS',\n 'DOOMPI_COMPOSED',\n 'DOOMPI_MUTE',\n 'DOOMPI_TEMP_DIR',\n // A pointer to the syncing process's own state file. Recording it would hand\n // every later session a path to a state that died with this one.\n HARNESS_STATE_POINTER,\n 'PI_SUBAGENT_PI_BINARY',\n]);\n\ntype SyncOutput = SyncProgressOutput;\n\nexport interface SyncCommandOptions {\n settingsMode?: SyncSettingsMode;\n /** Test/embedding override; normal CLI execution uses the process home. */\n homeDirectory?: string;\n /** Internal pipeline seam when the caller owns the worktree lock. */\n lockHeld?: boolean;\n}\n\nexport interface SyncResult {\n statePath: string;\n /** Omitted when DPI supplies the integration as a process-local overlay. */\n settingsPath?: string;\n /** Set only when the repository still carried its own DoomPi registration. */\n projectSettingsPath?: string;\n selection: SyncSelection;\n mcpServers: string[];\n skillCount: number;\n agentCount: number;\n}\n\nexport function recordedEnvironment(environment: NodeJS.ProcessEnv): Record<string, string> {\n const recorded: Record<string, string> = {};\n for (const [key, value] of Object.entries(environment)) {\n if (value === undefined || EXCLUDED_KEYS.has(key)) continue;\n if (RECORDED_KEYS.includes(key) || RECORDED_PREFIXES.some((prefix) => key.startsWith(prefix))) {\n recorded[key] = value;\n }\n }\n return recorded;\n}\n\n/**\n * Reports the config keys sync chose to ignore.\n *\n * Never fatal. A key nobody recognises is usually a config written for another\n * version of a layer, and refusing to build over it is worse than proceeding\n * without it. The strict check lives in `doompi doctor`.\n */\nfunction writeConfigDiagnostics(diagnostics: readonly ConfigDiagnostic[], output: SyncOutput): void {\n if (diagnostics.length === 0) return;\n const lines = diagnostics.map((entry) => ` ${entry.filePath}: ${entry.path}`).join('\\n');\n output.write(\n `config: ignored ${String(diagnostics.length)} unsupported key(s); run doompi doctor for the strict check\\n${lines}\\n`,\n );\n}\n\n/** Regenerates the hook files the other frontends read before any harness code runs. */\nfunction emitFrontendHooks(repoRoot: string, output: SyncOutput): void {\n const emitter = path.join(repoRoot, HOOK_EMITTER);\n if (!fs.existsSync(emitter)) return;\n const result = spawnSync(process.execPath, [emitter, '--write'], { cwd: repoRoot, encoding: 'utf8' });\n if (result.status === 0) {\n output.write('hooks: regenerated for Claude Code and Codex\\n');\n return;\n }\n output.write(`hooks: emit-hooks failed (${result.stderr?.trim() || `exit ${String(result.status)}`})\\n`);\n}\n\nexport function formatSyncResult(result: SyncResult, runner = 'pi'): string {\n const { selection } = result;\n return [\n `mode: ${selection.majorMode}`,\n `domains: ${selection.domains.join(', ') || NONE}`,\n `profile: ${selection.profile ?? NONE}`,\n `skills: ${result.skillCount}`,\n `agents: ${result.agentCount}`,\n `mcp: ${result.mcpServers.join(', ') || NONE}`,\n `state: ${result.statePath}`,\n ...(result.settingsPath ? [`settings: ${result.settingsPath}`] : []),\n ...(result.projectSettingsPath\n ? [`project: removed duplicate registration from ${result.projectSettingsPath}`]\n : []),\n '',\n `Run ${runner} from the repository root to use it.`,\n '',\n ].join('\\n');\n}\n\n/**\n * The DoomPi that produced this generation, which is the one that can load it.\n *\n * Always the executing package, never another copy the repository happens to\n * install. A generation is not portable between two installations: the bundles\n * are compiled from the building package's own extension entries, the recorded\n * compiler inputs are its files, and the state names its bootstrap entry. Naming\n * a second copy here publishes a registration whose package disagrees with the\n * state it points at, and Pi's dispatcher then loads a harness that rejects the\n * bootstrap as stale on every session, with no sync able to fix it.\n *\n * A repository that wants its own copy to own its sessions runs sync with that\n * copy's CLI, which makes it the executing package.\n */\nfunction packageRegistrationFor(): SyncPackageRegistration {\n const root = fs.realpathSync(doomPiPackageRoot());\n const manifestPath = path.join(root, 'package.json');\n const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as {\n version?: unknown;\n doompiApiVersion?: unknown;\n pi?: { extensions?: unknown };\n };\n const version = manifest.version;\n const apiVersion = manifest.doompiApiVersion;\n const extensions = manifest.pi?.extensions;\n const extension = Array.isArray(extensions) ? extensions.find((value) => typeof value === 'string') : undefined;\n if (\n typeof version !== 'string' ||\n typeof apiVersion !== 'number' ||\n !Number.isSafeInteger(apiVersion) ||\n apiVersion < 1 ||\n apiVersion !== DOOMPI_API_VERSION ||\n typeof extension !== 'string'\n ) {\n throw new Error(`Installed DoomPi package at ${root} has no supported API-versioned Pi extension entry`);\n }\n return {\n root,\n version,\n apiVersion: apiVersion as number,\n manifestPath,\n entry: fs.realpathSync(path.resolve(root, extension)),\n };\n}\n\n/** Resolves the matrix, stages it into home-scoped worktree storage, and publishes one generation. */\nexport async function synchronize(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n commandOptions: SyncCommandOptions = {},\n): Promise<number> {\n const check = args.includes(CHECK_OPTION);\n const force = args.includes(FORCE_OPTION);\n const rest = args.slice(1).filter((argument) => ![CHECK_OPTION, FORCE_OPTION, GLOBAL_OPTION].includes(argument));\n const homeDirectory = commandOptions.homeDirectory ?? environment.HOME ?? os.homedir();\n const roots = resolveSyncRoots(args, environment, currentDirectory, homeDirectory);\n const { globalOnly, globalRoot, targetRoot: repoRoot } = roots;\n const scopedEnvironment = environmentForSyncScope(environment, globalOnly);\n if (globalOnly && !check) fs.mkdirSync(globalRoot, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // Sync tolerates keys it does not recognise so a config written against a\n // different version cannot break a build. `doompi doctor` reports them.\n const modes = loadMajorModesConfigLenient(repoRoot, homeDirectory, environment);\n const configDiagnostics = [...loadDoomConfigLenient(repoRoot, homeDirectory).diagnostics, ...modes.diagnostics];\n const defaultMajorMode = modes.config.defaultMajorMode;\n const defaultDomains = loadDomains(repoRoot, homeDirectory).defaultDomains;\n const parsed = parseHarnessArgs(\n rest,\n selectionEnvironment(repoRoot, scopedEnvironment, homeDirectory),\n globalOnly ? globalRoot : currentDirectory,\n defaultMajorMode,\n defaultDomains,\n );\n const selection = toSelection(parsed.options);\n const agentDirectory = piAgentDirectory(scopedEnvironment, homeDirectory);\n if ((commandOptions.settingsMode ?? 'persisted') === 'persisted' && !check) {\n if (piExtensionDispatcherIsUpgradeable(agentDirectory)) {\n writePiExtensionAlias(agentDirectory);\n output.write('repair: refreshed Pi user dispatcher\\n');\n }\n const drift = piIntegrationDrift(agentDirectory);\n if (drift.length > 0) {\n throw new Error(`DoomPi Pi integration is not ready:\\n${drift.map((entry) => ` ${entry}`).join('\\n')}`);\n }\n }\n writeConfigDiagnostics(configDiagnostics, output);\n if (check) {\n const majorModesConfig = modes.config;\n const missingPackages = missingLayerPackageSpecifiers(\n majorModesConfig,\n Object.keys(majorModesConfig.layers),\n createLayerResolvers(repoRoot),\n );\n if (missingPackages.length > 0) {\n output.write(\n `doompi sync is out of date:\\n${missingPackages\n .map((specifier) => ` configured package is not installed: ${specifier}`)\n .join('\\n')}\\n`,\n );\n return 1;\n }\n let located: ReturnType<typeof readLocatedSyncState>;\n try {\n located = readLocatedSyncState(repoRoot, homeDirectory);\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n output.write(`doompi sync is out of date:\\n ${detail}\\n`);\n return 1;\n }\n const expectedCompositionFingerprint = selectionCompositionFingerprint(\n repoRoot,\n parsed.options,\n homeDirectory,\n environment,\n );\n const drift = collectDrift(\n repoRoot,\n selection,\n located?.state,\n scopedEnvironment,\n commandOptions.settingsMode ?? 'persisted',\n expectedCompositionFingerprint,\n );\n if (drift.length === 0) {\n output.write('doompi sync is up to date\\n');\n return 0;\n }\n output.write(`doompi sync is out of date:\\n${drift.map((entry) => ` ${entry}`).join('\\n')}\\n`);\n return 1;\n }\n\n // Publishing an identical generation is not a no-op: it moves the\n // registration, so every attached cockpit reloads and the previous\n // generation becomes garbage. Same inputs, same published result.\n const driftOptions = {\n repoRoot,\n environment,\n homeDirectory,\n requireWebBundle: Boolean(environment.DOOMPI_WEB_PACKAGE_ROOT),\n };\n const registrationNeedsMigration = syncRegistrationNeedsApiMigration(repoRoot, homeDirectory);\n if (!force && !registrationNeedsMigration && readSyncDrift(driftOptions).fresh) {\n output.write('doompi sync is already up to date\\n');\n return 0;\n }\n\n const progress = new SyncProgress(output);\n const releaseLock = commandOptions.lockHeld\n ? undefined\n : await acquireSyncLocationLock(resolveSyncLocation(repoRoot, homeDirectory));\n let result: SyncResult;\n try {\n // A concurrent publisher may have resolved the drift while this command\n // waited for the lock. Avoid moving the registration for no change.\n const registrationNeedsMigration = syncRegistrationNeedsApiMigration(repoRoot, homeDirectory);\n if (!force && !registrationNeedsMigration && readSyncDrift(driftOptions).fresh) {\n output.write('doompi sync is already up to date\\n');\n return 0;\n }\n result = await stageSync(repoRoot, parsed.options, scopedEnvironment, homeDirectory, progress, commandOptions);\n } finally {\n await releaseLock?.();\n }\n emitFrontendHooks(repoRoot, output);\n output.write(formatSyncResult(result, (commandOptions.settingsMode ?? 'persisted') === 'embedded' ? 'dpi' : 'pi'));\n return 0;\n}\n\nasync function stageSync(\n repoRoot: string,\n options: Omit<HarnessOptions, 'repoRoot'>,\n environment: NodeJS.ProcessEnv,\n homeDirectory: string,\n progress: SyncProgress,\n commandOptions: SyncCommandOptions = {},\n): Promise<SyncResult> {\n const location = resolveSyncLocation(repoRoot, homeDirectory);\n const generation = `${Date.now().toString(36)}-${crypto.randomUUID()}`;\n const directory = syncGenerationDirectory(location, generation);\n await fs.promises.mkdir(location.generationsDirectory, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // The leaf is created without `recursive`, so an existing path is an error\n // rather than something to adopt: the cockpit signs and serves whatever the\n // published generation holds, and sync must only ever publish bytes it\n // wrote itself into a directory it just created.\n await fs.promises.mkdir(directory, { mode: PRIVATE_DIRECTORY_MODE });\n\n try {\n const staged = progress.start(SYNC_LABEL, 'resolving the matrix and staging resources');\n const context = await buildHarnessContext({\n ...options,\n repoRoot: location.root,\n homeDirectory,\n environment,\n cwd: location.root,\n resourceDirectory: directory,\n });\n await ensureLayerPackages({\n repoRoot: location.root,\n config: context.majorModesConfig,\n layers: Object.keys(context.majorModesConfig.layers),\n environment,\n });\n staged(`${String(context.resources.skillCount)} skills, ${String(context.resources.agentCount)} agents`);\n const selection = toSelection(options);\n const resolvers = createLayerResolvers(location.root);\n const resolved = recordResolvedEntries(context.majorModesConfig, resolvers);\n const compositionFingerprint = selectionCompositionFingerprint(location.root, options, homeDirectory, environment);\n const agentDirectory = piAgentDirectory(environment, homeDirectory);\n const persistedThemePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n const themePath =\n (commandOptions.settingsMode ?? 'persisted') === 'persisted' ? persistedThemePath : context.defaultThemePath;\n const state: SyncState = {\n version: SYNC_STATE_VERSION,\n root: location.root,\n identity: location.identity,\n inputsHash: computeInputsHash(location.root, selection, homeDirectory, context.environment),\n webSourcesHash: computeWebSourcesHash(resolved),\n compositionFingerprint,\n selection,\n env: recordedEnvironment(context.environment),\n fileState: {\n profileEnvironment: loadHarnessState(context.environment).state.profileEnvironment,\n pluginHooks: context.resources.pluginHooks,\n mcpProjection: context.resources.mcpProjection,\n },\n resolved,\n baseline: {\n mcpConfigPath: context.resources.mcpConfigPath,\n personaFile: context.environment[PERSONA_FILE_ENV],\n themePath,\n themeName: DEFAULT_THEME_NAME,\n },\n };\n\n // Runtime compilation writes the package dist files consumed by both the web\n // and server bundlers. Finish it first so a package clean cannot race either\n // consumer, then run the independent web and server builds together.\n let resolveCompositions!: (compositions: readonly ExtensionComposition[]) => void;\n let rejectCompositions!: (reason?: unknown) => void;\n const compositionsReady = new Promise<readonly ExtensionComposition[]>((resolve, reject) => {\n resolveCompositions = resolve;\n rejectCompositions = reject;\n });\n const runtimeProgress = progress.start(RUNTIME_LABEL, 'precompiling the mode bundles');\n const runtimeBuild = buildSyncedRuntime(location.root, environment, homeDirectory, {\n state,\n directory,\n onCompositionsResolved: resolveCompositions,\n }).then((synced) => {\n runtimeProgress(`${String(Object.keys(synced.bundles).length)} mode bundles`);\n return synced;\n });\n void runtimeBuild.catch(rejectCompositions);\n const webBuild = (async () => {\n await runtimeBuild;\n const webProgress = progress.start(WEB_LABEL, 'bundling the web cockpit plugins');\n const web = await syncWebBundle({\n repoRoot: location.root,\n resolvedEntries: state.resolved,\n environment,\n outputDirectory: path.join(directory, 'web-bundle'),\n onNotice: (message) => progress.line(WEB_LABEL, message),\n });\n if (web.status === 'failed') throw new Error(`Cockpit bundle failed: ${web.reason}`);\n webProgress(web.status === 'bundled' ? `cockpit bundled with plugins: ${web.pluginIds.join(', ')}` : web.reason);\n return web;\n })();\n const serverBuild = (async () => {\n const compositions = await compositionsReady;\n await runtimeBuild;\n const apiProgress = progress.start(API_LABEL, 'compiling the server bundle');\n const apiDirectory = path.join(directory, 'api');\n const fingerprint = crypto\n .createHash('sha256')\n .update(JSON.stringify([...new Set(compositions.map((composition) => composition.fingerprint))]))\n .digest('hex');\n const [server, mcp] = await Promise.all([\n syncServerBundle({\n repositoryRoot: location.root,\n generation,\n fingerprint,\n compositions,\n outputDirectory: apiDirectory,\n cacheDirectory: path.join(directory, 'cache'),\n sharedCacheDirectory: location.sharedCacheDirectory,\n }),\n syncMcpBundle({\n repositoryRoot: location.root,\n generation,\n fingerprint,\n compositions,\n outputDirectory: path.join(directory, 'mcp'),\n cacheDirectory: path.join(directory, 'cache'),\n sharedCacheDirectory: location.sharedCacheDirectory,\n }),\n ]);\n apiProgress(\n `${server.descriptor.entries.length} server facet(s), ${mcp.descriptor.entries.length} MCP plugin(s) compiled`,\n );\n for (const gap of server.contractGaps) progress.line(API_LABEL, `API contract incomplete: ${gap}`);\n return { server, mcp, fingerprint, apiDirectory };\n })();\n const [runtimeResult, webResult, serverResult] = await Promise.allSettled([runtimeBuild, webBuild, serverBuild]);\n if (runtimeResult.status === 'rejected') throw runtimeResult.reason;\n if (webResult.status === 'rejected') throw webResult.reason;\n if (serverResult.status === 'rejected') throw serverResult.reason;\n const synced = runtimeResult.value;\n const web = webResult.value;\n const { server, mcp, fingerprint, apiDirectory } = serverResult.value;\n const descriptorPath = path.join(apiDirectory, DOOM_SERVER_BUNDLE_FILE);\n const mcpDescriptorPath = path.join(directory, 'mcp', DOOM_MCP_BUNDLE_FILE);\n const finalState: SyncState = {\n ...synced.state,\n serverBundle: {\n descriptorPath,\n fingerprint,\n compilerManifests: server.compilerManifests,\n sourcesHash: computeServerSourcesHash(synced.state.resolved),\n },\n mcpBundle: {\n descriptorPath: mcpDescriptorPath,\n fingerprint,\n compilerManifests: mcp.compilerManifests,\n sourcesHash: computeMcpSourcesHash(synced.state.resolved),\n },\n };\n const statePath = await writeSyncState(\n location.root,\n finalState,\n homeDirectory,\n path.join(directory, 'state.json'),\n );\n const projectSettingsPath =\n (commandOptions.settingsMode ?? 'persisted') === 'persisted'\n ? writeProjectPiSettings(location.root, homeDirectory)\n : undefined;\n const result: SyncResult = {\n statePath,\n ...(projectSettingsPath ? { projectSettingsPath } : {}),\n selection,\n mcpServers: synced.state.baseline.mcpConfigPath ? readMcpServerNames(synced.state.baseline.mcpConfigPath) : [],\n skillCount: context.resources.skillCount,\n agentCount: context.resources.agentCount,\n };\n publishSyncRegistration(\n location.root,\n {\n version: SYNC_REGISTRATION_VERSION,\n root: location.root,\n identity: location.identity,\n generation,\n generationRoot: directory,\n statePath,\n stateSha256: syncStateSha256(statePath),\n webDirectory: web.status === 'bundled' ? web.assetsDir : null,\n apiDirectory,\n serverBundle: { path: descriptorPath, fingerprint, sha256: syncStateSha256(descriptorPath) },\n mcpBundle: { path: mcpDescriptorPath, fingerprint, sha256: syncStateSha256(mcpDescriptorPath) },\n package: packageRegistrationFor(),\n },\n homeDirectory,\n );\n // ponytail: retain generations until host-owned drain evidence can prove no session uses them.\n // Directory age and an open-file check cannot establish that a lazy import is finished.\n return result;\n } catch (error) {\n await fs.promises.rm(directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\n throw error;\n }\n}\n\n/** Compatibility API. Executables call the command function directly. */\nexport class SyncCommand {\n readonly name = SYNC_COMMAND;\n private readonly settingsMode: SyncSettingsMode;\n private readonly homeDirectory: string | undefined;\n private readonly lockHeld: boolean;\n\n constructor(options: SyncCommandOptions = {}) {\n this.settingsMode = options.settingsMode ?? 'persisted';\n this.homeDirectory = options.homeDirectory;\n this.lockHeld = options.lockHeld ?? false;\n }\n\n matches(args: string[]): boolean {\n return args[0] === this.name;\n }\n\n async execute(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n ): Promise<number> {\n return synchronize(args, environment, currentDirectory, output, {\n settingsMode: this.settingsMode,\n homeDirectory: this.homeDirectory,\n lockHeld: this.lockHeld,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,MAAM,eAAe;AACrB,MAAM,eAAe;;AAErB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,eAAeA,UAAAA,QAAK,KAAK,SAAS,WAAW,gBAAgB;AACnE,MAAM,OAAO;AACb,MAAM,yBAAyB;AAC/B,MAAM,aAAa;AACnB,MAAM,gBAAgB;AACtB,MAAM,YAAY;AAClB,MAAM,YAAY;;AAUlB,SAAgB,iBACd,MACA,cAAiC,QAAQ,KACzC,mBAAmB,QAAQ,IAAI,GAC/B,gBAAgB,YAAY,QAAQC,QAAAA,QAAG,QAAQ,GACpC;CACX,MAAM,cAAA,GAAaC,gCAAAA,0BAAAA,CAA0B,aAAa;CAC1D,MAAM,gBAAgB,YAAY;CAClC,MAAM,aAAa,gBACfF,UAAAA,QAAK,QAAQ,aAAa,IAC1BG,gBAAAA,6BAA6B,kBAAkB,aAAa;CAChE,MAAM,aAAa,KAAK,SAAS,aAAa;CAC9C,OAAO;EAAE;EAAY;EAAY;EAAY,YAAY,aAAa,aAAa;CAAW;AAChG;AAEA,MAAM,8BAA8B;CAClC;CACAC,sCAAAA;CACAC,sBAAAA;CACAC,sBAAAA;CACAC,sBAAAA;AACF;;AAGA,SAAgB,wBAAwB,aAAgC,YAAwC;CAC9G,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,SAAS,EAAE,GAAG,YAAY;CAChC,KAAK,MAAM,OAAO,6BAA6B,OAAO,OAAO;CAC7D,OAAO;AACT;;;;;;;;AASA,MAAM,oBAAoB,CAAC,SAAS;AACpC,MAAM,gBAAgB;CAAC;CAAsB;CAAmB;CAAsB;AAAe;;;;;;;;AAQrG,M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":"index.cjs","names":["path","os","globalDoomConfigDirectory","resolveDoomConfigurationRoot","HARNESS_STATE_POINTER","DOOMPI_MAJOR_MODE_ENV","DOOMPI_DOMAINS_ENV","DOOMPI_PROFILE_ENV","fs","spawnSync","doomPiPackageRoot","DOOMPI_API_VERSION","loadMajorModesConfigLenient","loadDoomConfigLenient","loadDomains","parseHarnessArgs","selectionEnvironment","toSelection","piAgentDirectory","piExtensionDispatcherIsUpgradeable","piIntegrationDrift","missingLayerPackageSpecifiers","createLayerResolvers","readLocatedSyncState","selectionCompositionFingerprint","collectDrift","syncRegistrationNeedsApiMigration","readSyncDrift","SyncProgress","acquireSyncLocationLock","resolveSyncLocation","crypto","syncGenerationDirectory","buildHarnessContext","ensureLayerPackages","recordResolvedEntries","piThemeDirectory","DEFAULT_THEME_NAME","syncHookModules","SYNC_STATE_VERSION","computeInputsHash","computeWebSourcesHash","loadHarnessState","buildSyncedRuntime","syncWebBundle","syncServerBundle","syncMcpBundle","DOOM_SERVER_BUNDLE_FILE","DOOM_MCP_BUNDLE_FILE","computeServerSourcesHash","computeMcpSourcesHash","writeSyncState","writeProjectPiSettings","readMcpServerNames","SYNC_REGISTRATION_VERSION","syncStateSha256"],"sources":["../../../../../src/cli/commands/sync/index.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/doompi-config/config';\nimport { loadDomains } from '@agimon-ai/doompi-config/domains';\nimport { loadMajorModesConfigLenient } from '@agimon-ai/doompi-config/majorModes';\nimport type { ConfigDiagnostic } from '@agimon-ai/doompi-config/types';\nimport { DOOM_MCP_BUNDLE_FILE } from '@agimon-ai/doompi-core/mcpFacet';\nimport { piAgentDirectory, piThemeDirectory } from '@agimon-ai/doompi-core/runtimePiSettings';\nimport { DOOM_SERVER_BUNDLE_FILE } from '@agimon-ai/doompi-core/serverFacet';\nimport {\n acquireSyncLocationLock,\n resolveSyncLocation,\n syncGenerationDirectory,\n} from '@agimon-ai/doompi-core/syncLocation';\nimport {\n DOOMPI_API_VERSION,\n publishSyncRegistration,\n SYNC_REGISTRATION_VERSION,\n syncStateSha256,\n type SyncPackageRegistration,\n} from '@agimon-ai/doompi-core/syncRegistration';\nimport { DEFAULT_THEME_NAME } from '@agimon-ai/doompi-ui/theme';\n\nimport { buildSyncedRuntime } from '../../../builders/cli';\nimport { createLayerResolvers, type ExtensionComposition } from '../../../builders/cli/extensionAssembler';\nimport { buildHarnessContext } from '../../../builders/cli/harnessContext';\nimport { doomPiPackageRoot, writePiExtensionAlias } from '../../../builders/cli/piExtensionAlias';\nimport { piExtensionDispatcherIsUpgradeable } from '../../../builders/cli/piExtensionDispatcher';\nimport { writeProjectPiSettings } from '../../../builders/cli/projectSettings';\nimport { syncHookModules } from '../../../builders/hooks';\nimport { syncServerBundle } from '../../../builders/server';\nimport { syncMcpBundle } from '../../../builders/server/mcpBundle';\nimport { syncWebBundle } from '../../../builders/web';\nimport { HARNESS_STATE_POINTER, loadHarnessState } from '../../../composition/harnessState';\nimport { ensureLayerPackages, missingLayerPackageSpecifiers } from '../../../composition/layerPackageInstaller';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { resolveDoomConfigurationRoot } from '../../../composition/repository';\nimport { readSyncDrift } from '../../../composition/syncDrift';\nimport {\n computeInputsHash,\n computeMcpSourcesHash,\n computeServerSourcesHash,\n computeWebSourcesHash,\n readLocatedSyncState,\n readMcpServerNames,\n recordResolvedEntries,\n SYNC_STATE_VERSION,\n type SyncSelection,\n type SyncState,\n writeSyncState,\n} from '../../../composition/syncState';\nimport type { HarnessOptions } from '../../../composition/types/harness';\nimport { DOOMPI_DOMAINS_ENV, DOOMPI_MAJOR_MODE_ENV, DOOMPI_PROFILE_ENV } from '../../matrixOptions';\nimport { parseHarnessArgs } from '../../options';\nimport {\n collectDrift,\n piIntegrationDrift,\n selectionCompositionFingerprint,\n selectionEnvironment,\n syncRegistrationNeedsApiMigration,\n toSelection,\n type SyncSettingsMode,\n} from './inspection';\nimport { SyncProgress, type SyncProgressOutput } from './presenter';\n\nexport {\n collectDrift,\n selectionCompositionFingerprint,\n selectionEnvironment,\n syncRegistrationNeedsApiMigration,\n toSelection,\n type SyncSettingsMode,\n} from './inspection';\n\n/**\n * `doom-pi sync`: resolve the matrix once and write it where plain Pi finds it.\n *\n * The doom-emacs split. Everything that needs a real Node process (module\n * resolution, staging skills and agents, generating the MCP config) happens\n * here, and the doom-pi extension then only reads what this produced. The\n * launcher is untouched and keeps resolving the same matrix per run.\n */\n\nconst SYNC_COMMAND = 'sync';\nconst CHECK_OPTION = '--check';\n/** Republishes even when nothing drifted, for a generation suspected of being damaged. */\nconst FORCE_OPTION = '--force';\nconst GLOBAL_OPTION = '--global';\nconst HARNESS_ROOT_ENV = 'DOOMPI_ROOT';\nconst PERSONA_FILE_ENV = 'DOOMPI_PERSONA_FILE';\nconst HOOK_EMITTER = path.join('tools', 'harness', 'emit-hooks.mjs');\nconst NONE = '(none)';\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst SYNC_LABEL = 'sync';\nconst RUNTIME_LABEL = 'runtime';\nconst WEB_LABEL = 'web';\nconst API_LABEL = 'api';\n\nexport interface SyncRoots {\n globalOnly: boolean;\n globalRoot: string;\n sourceRoot: string;\n targetRoot: string;\n}\n\n/** Resolves the configuration source and publication destination for one sync. */\nexport function resolveSyncRoots(\n args: readonly string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n homeDirectory = environment.HOME ?? os.homedir(),\n): SyncRoots {\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const inheritedRoot = environment[HARNESS_ROOT_ENV];\n const sourceRoot = inheritedRoot\n ? path.resolve(inheritedRoot)\n : resolveDoomConfigurationRoot(currentDirectory, homeDirectory);\n const globalOnly = args.includes(GLOBAL_OPTION);\n return { globalOnly, globalRoot, sourceRoot, targetRoot: globalOnly ? globalRoot : sourceRoot };\n}\n\nconst GLOBAL_SCOPE_INHERITED_KEYS = [\n HARNESS_ROOT_ENV,\n HARNESS_STATE_POINTER,\n DOOMPI_MAJOR_MODE_ENV,\n DOOMPI_DOMAINS_ENV,\n DOOMPI_PROFILE_ENV,\n] as const;\n\n/** Removes workspace-only state before a global runtime is resolved. */\nexport function environmentForSyncScope(environment: NodeJS.ProcessEnv, globalOnly: boolean): NodeJS.ProcessEnv {\n if (!globalOnly) return environment;\n const scoped = { ...environment };\n for (const key of GLOBAL_SCOPE_INHERITED_KEYS) delete scoped[key];\n return scoped;\n}\n\n/**\n * Harness variables worth recording, by prefix or exact name.\n *\n * An allowlist rather than the whole environment: the state file is a snapshot\n * of resolved configuration, and dumping `process.env` into it would write\n * every credential the sync happened to run with onto disk.\n */\nconst RECORDED_PREFIXES = ['DOOMPI_'];\nconst RECORDED_KEYS = ['CLAUDE_PROJECT_DIR', 'CODEX_REPO_ROOT', 'ORIGINAL_REPO_PATH', 'MCP_UI_VIEWER'];\n/**\n * Launcher-only values a synced session must not inherit.\n *\n * The child extension list is recomposed on every load, and the subagent binary\n * points at `pi.sh`, which a session started as plain `pi` should not shell out\n * to: Doom Team resolves Pi's own CLI when the variable is absent.\n */\nconst EXCLUDED_KEYS = new Set([\n 'DOOMPI_DISTRIBUTION',\n 'DOOMPI_CHILD_EXTENSIONS',\n 'DOOMPI_COMPOSED',\n 'DOOMPI_MUTE',\n 'DOOMPI_TEMP_DIR',\n // A pointer to the syncing process's own state file. Recording it would hand\n // every later session a path to a state that died with this one.\n HARNESS_STATE_POINTER,\n 'PI_SUBAGENT_PI_BINARY',\n]);\n\ntype SyncOutput = SyncProgressOutput;\n\nexport interface SyncCommandOptions {\n settingsMode?: SyncSettingsMode;\n /** Test/embedding override; normal CLI execution uses the process home. */\n homeDirectory?: string;\n /** Internal pipeline seam when the caller owns the worktree lock. */\n lockHeld?: boolean;\n}\n\nexport interface SyncResult {\n statePath: string;\n /** Omitted when DPI supplies the integration as a process-local overlay. */\n settingsPath?: string;\n /** Set only when the repository still carried its own DoomPi registration. */\n projectSettingsPath?: string;\n selection: SyncSelection;\n mcpServers: string[];\n skillCount: number;\n agentCount: number;\n}\n\nexport function recordedEnvironment(environment: NodeJS.ProcessEnv): Record<string, string> {\n const recorded: Record<string, string> = {};\n for (const [key, value] of Object.entries(environment)) {\n if (value === undefined || EXCLUDED_KEYS.has(key)) continue;\n if (RECORDED_KEYS.includes(key) || RECORDED_PREFIXES.some((prefix) => key.startsWith(prefix))) {\n recorded[key] = value;\n }\n }\n return recorded;\n}\n\n/**\n * Reports the config keys sync chose to ignore.\n *\n * Never fatal. A key nobody recognises is usually a config written for another\n * version of a layer, and refusing to build over it is worse than proceeding\n * without it. The strict check lives in `doompi doctor`.\n */\nfunction writeConfigDiagnostics(diagnostics: readonly ConfigDiagnostic[], output: SyncOutput): void {\n if (diagnostics.length === 0) return;\n const lines = diagnostics.map((entry) => ` ${entry.filePath}: ${entry.path}`).join('\\n');\n output.write(\n `config: ignored ${String(diagnostics.length)} unsupported key(s); run doompi doctor for the strict check\\n${lines}\\n`,\n );\n}\n\n/** Regenerates the hook files the other frontends read before any harness code runs. */\nfunction emitFrontendHooks(repoRoot: string, output: SyncOutput): void {\n const emitter = path.join(repoRoot, HOOK_EMITTER);\n if (!fs.existsSync(emitter)) return;\n const result = spawnSync(process.execPath, [emitter, '--write'], { cwd: repoRoot, encoding: 'utf8' });\n if (result.status === 0) {\n output.write('hooks: regenerated for Claude Code and Codex\\n');\n return;\n }\n output.write(`hooks: emit-hooks failed (${result.stderr?.trim() || `exit ${String(result.status)}`})\\n`);\n}\n\nexport function formatSyncResult(result: SyncResult, runner = 'pi'): string {\n const { selection } = result;\n return [\n `mode: ${selection.majorMode}`,\n `domains: ${selection.domains.join(', ') || NONE}`,\n `profile: ${selection.profile ?? NONE}`,\n `skills: ${result.skillCount}`,\n `agents: ${result.agentCount}`,\n `mcp: ${result.mcpServers.join(', ') || NONE}`,\n `state: ${result.statePath}`,\n ...(result.settingsPath ? [`settings: ${result.settingsPath}`] : []),\n ...(result.projectSettingsPath\n ? [`project: removed duplicate registration from ${result.projectSettingsPath}`]\n : []),\n '',\n `Run ${runner} from the repository root to use it.`,\n '',\n ].join('\\n');\n}\n\n/**\n * The DoomPi that produced this generation, which is the one that can load it.\n *\n * Always the executing package, never another copy the repository happens to\n * install. A generation is not portable between two installations: the bundles\n * are compiled from the building package's own extension entries, the recorded\n * compiler inputs are its files, and the state names its bootstrap entry. Naming\n * a second copy here publishes a registration whose package disagrees with the\n * state it points at, and Pi's dispatcher then loads a harness that rejects the\n * bootstrap as stale on every session, with no sync able to fix it.\n *\n * A repository that wants its own copy to own its sessions runs sync with that\n * copy's CLI, which makes it the executing package.\n */\nfunction packageRegistrationFor(): SyncPackageRegistration {\n const root = fs.realpathSync(doomPiPackageRoot());\n const manifestPath = path.join(root, 'package.json');\n const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as {\n version?: unknown;\n doompiApiVersion?: unknown;\n pi?: { extensions?: unknown };\n };\n const version = manifest.version;\n const apiVersion = manifest.doompiApiVersion;\n const extensions = manifest.pi?.extensions;\n const extension = Array.isArray(extensions) ? extensions.find((value) => typeof value === 'string') : undefined;\n if (\n typeof version !== 'string' ||\n typeof apiVersion !== 'number' ||\n !Number.isSafeInteger(apiVersion) ||\n apiVersion < 1 ||\n apiVersion !== DOOMPI_API_VERSION ||\n typeof extension !== 'string'\n ) {\n throw new Error(`Installed DoomPi package at ${root} has no supported API-versioned Pi extension entry`);\n }\n return {\n root,\n version,\n apiVersion: apiVersion as number,\n manifestPath,\n entry: fs.realpathSync(path.resolve(root, extension)),\n };\n}\n\n/** Resolves the matrix, stages it into home-scoped worktree storage, and publishes one generation. */\nexport async function synchronize(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n commandOptions: SyncCommandOptions = {},\n): Promise<number> {\n const check = args.includes(CHECK_OPTION);\n const force = args.includes(FORCE_OPTION);\n const rest = args.slice(1).filter((argument) => ![CHECK_OPTION, FORCE_OPTION, GLOBAL_OPTION].includes(argument));\n const homeDirectory = commandOptions.homeDirectory ?? environment.HOME ?? os.homedir();\n const roots = resolveSyncRoots(args, environment, currentDirectory, homeDirectory);\n const { globalOnly, globalRoot, targetRoot: repoRoot } = roots;\n const scopedEnvironment = environmentForSyncScope(environment, globalOnly);\n if (globalOnly && !check) fs.mkdirSync(globalRoot, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // Sync tolerates keys it does not recognise so a config written against a\n // different version cannot break a build. `doompi doctor` reports them.\n const modes = loadMajorModesConfigLenient(repoRoot, homeDirectory, environment);\n const configDiagnostics = [...loadDoomConfigLenient(repoRoot, homeDirectory).diagnostics, ...modes.diagnostics];\n const defaultMajorMode = modes.config.defaultMajorMode;\n const defaultDomains = loadDomains(repoRoot, homeDirectory).defaultDomains;\n const parsed = parseHarnessArgs(\n rest,\n selectionEnvironment(repoRoot, scopedEnvironment, homeDirectory),\n globalOnly ? globalRoot : currentDirectory,\n defaultMajorMode,\n defaultDomains,\n );\n const selection = toSelection(parsed.options);\n const agentDirectory = piAgentDirectory(scopedEnvironment, homeDirectory);\n if ((commandOptions.settingsMode ?? 'persisted') === 'persisted' && !check) {\n if (piExtensionDispatcherIsUpgradeable(agentDirectory)) {\n writePiExtensionAlias(agentDirectory);\n output.write('repair: refreshed Pi user dispatcher\\n');\n }\n const drift = piIntegrationDrift(agentDirectory);\n if (drift.length > 0) {\n throw new Error(`DoomPi Pi integration is not ready:\\n${drift.map((entry) => ` ${entry}`).join('\\n')}`);\n }\n }\n writeConfigDiagnostics(configDiagnostics, output);\n if (check) {\n const majorModesConfig = modes.config;\n const missingPackages = missingLayerPackageSpecifiers(\n majorModesConfig,\n Object.keys(majorModesConfig.layers),\n createLayerResolvers(repoRoot),\n );\n if (missingPackages.length > 0) {\n output.write(\n `doompi sync is out of date:\\n${missingPackages\n .map((specifier) => ` configured package is not installed: ${specifier}`)\n .join('\\n')}\\n`,\n );\n return 1;\n }\n let located: ReturnType<typeof readLocatedSyncState>;\n try {\n located = readLocatedSyncState(repoRoot, homeDirectory);\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n output.write(`doompi sync is out of date:\\n ${detail}\\n`);\n return 1;\n }\n const expectedCompositionFingerprint = selectionCompositionFingerprint(\n repoRoot,\n parsed.options,\n homeDirectory,\n environment,\n );\n const drift = collectDrift(\n repoRoot,\n selection,\n located?.state,\n scopedEnvironment,\n commandOptions.settingsMode ?? 'persisted',\n expectedCompositionFingerprint,\n );\n if (drift.length === 0) {\n output.write('doompi sync is up to date\\n');\n return 0;\n }\n output.write(`doompi sync is out of date:\\n${drift.map((entry) => ` ${entry}`).join('\\n')}\\n`);\n return 1;\n }\n\n // Publishing an identical generation is not a no-op: it moves the\n // registration, so every attached cockpit reloads and the previous\n // generation becomes garbage. Same inputs, same published result.\n const driftOptions = {\n repoRoot,\n environment,\n homeDirectory,\n requireWebBundle: Boolean(environment.DOOMPI_WEB_PACKAGE_ROOT),\n };\n const registrationNeedsMigration = syncRegistrationNeedsApiMigration(repoRoot, homeDirectory);\n if (!force && !registrationNeedsMigration && readSyncDrift(driftOptions).fresh) {\n output.write('doompi sync is already up to date\\n');\n return 0;\n }\n\n const progress = new SyncProgress(output);\n const releaseLock = commandOptions.lockHeld\n ? undefined\n : await acquireSyncLocationLock(resolveSyncLocation(repoRoot, homeDirectory));\n let result: SyncResult;\n try {\n // A concurrent publisher may have resolved the drift while this command\n // waited for the lock. Avoid moving the registration for no change.\n const registrationNeedsMigration = syncRegistrationNeedsApiMigration(repoRoot, homeDirectory);\n if (!force && !registrationNeedsMigration && readSyncDrift(driftOptions).fresh) {\n output.write('doompi sync is already up to date\\n');\n return 0;\n }\n result = await stageSync(repoRoot, parsed.options, scopedEnvironment, homeDirectory, progress, commandOptions);\n } finally {\n await releaseLock?.();\n }\n emitFrontendHooks(repoRoot, output);\n output.write(formatSyncResult(result, (commandOptions.settingsMode ?? 'persisted') === 'embedded' ? 'dpi' : 'pi'));\n return 0;\n}\n\nasync function stageSync(\n repoRoot: string,\n options: Omit<HarnessOptions, 'repoRoot'>,\n environment: NodeJS.ProcessEnv,\n homeDirectory: string,\n progress: SyncProgress,\n commandOptions: SyncCommandOptions = {},\n): Promise<SyncResult> {\n const location = resolveSyncLocation(repoRoot, homeDirectory);\n const generation = `${Date.now().toString(36)}-${crypto.randomUUID()}`;\n const directory = syncGenerationDirectory(location, generation);\n await fs.promises.mkdir(location.generationsDirectory, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // The leaf is created without `recursive`, so an existing path is an error\n // rather than something to adopt: the cockpit signs and serves whatever the\n // published generation holds, and sync must only ever publish bytes it\n // wrote itself into a directory it just created.\n await fs.promises.mkdir(directory, { mode: PRIVATE_DIRECTORY_MODE });\n\n try {\n const staged = progress.start(SYNC_LABEL, 'resolving the matrix and staging resources');\n const context = await buildHarnessContext({\n ...options,\n repoRoot: location.root,\n homeDirectory,\n environment,\n cwd: location.root,\n resourceDirectory: directory,\n });\n await ensureLayerPackages({\n repoRoot: location.root,\n config: context.majorModesConfig,\n layers: Object.keys(context.majorModesConfig.layers),\n environment,\n });\n staged(`${String(context.resources.skillCount)} skills, ${String(context.resources.agentCount)} agents`);\n const selection = toSelection(options);\n const resolvers = createLayerResolvers(location.root);\n const resolved = recordResolvedEntries(context.majorModesConfig, resolvers);\n const compositionFingerprint = selectionCompositionFingerprint(location.root, options, homeDirectory, environment);\n const agentDirectory = piAgentDirectory(environment, homeDirectory);\n const persistedThemePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n const themePath =\n (commandOptions.settingsMode ?? 'persisted') === 'persisted' ? persistedThemePath : context.defaultThemePath;\n const hookModules = await syncHookModules({\n repoRoot: location.root,\n homeDirectory,\n config: context.majorModesConfig,\n directory,\n sharedCacheDirectory: location.sharedCacheDirectory,\n });\n const state: SyncState = {\n version: SYNC_STATE_VERSION,\n root: location.root,\n identity: location.identity,\n inputsHash: computeInputsHash(location.root, selection, homeDirectory, context.environment),\n webSourcesHash: computeWebSourcesHash(resolved),\n compositionFingerprint,\n selection,\n env: recordedEnvironment(context.environment),\n fileState: {\n profileEnvironment: loadHarnessState(context.environment).state.profileEnvironment,\n pluginHooks: context.resources.pluginHooks,\n hookModules,\n mcpProjection: context.resources.mcpProjection,\n },\n resolved,\n baseline: {\n mcpConfigPath: context.resources.mcpConfigPath,\n personaFile: context.environment[PERSONA_FILE_ENV],\n themePath,\n themeName: DEFAULT_THEME_NAME,\n },\n };\n\n // Runtime compilation writes the package dist files consumed by both the web\n // and server bundlers. Finish it first so a package clean cannot race either\n // consumer, then run the independent web and server builds together.\n let resolveCompositions!: (compositions: readonly ExtensionComposition[]) => void;\n let rejectCompositions!: (reason?: unknown) => void;\n const compositionsReady = new Promise<readonly ExtensionComposition[]>((resolve, reject) => {\n resolveCompositions = resolve;\n rejectCompositions = reject;\n });\n const runtimeProgress = progress.start(RUNTIME_LABEL, 'precompiling the mode bundles');\n const runtimeBuild = buildSyncedRuntime(location.root, environment, homeDirectory, {\n state,\n directory,\n onCompositionsResolved: resolveCompositions,\n }).then((synced) => {\n runtimeProgress(`${String(Object.keys(synced.bundles).length)} mode bundles`);\n return synced;\n });\n void runtimeBuild.catch(rejectCompositions);\n const webBuild = (async () => {\n await runtimeBuild;\n const webProgress = progress.start(WEB_LABEL, 'bundling the web cockpit plugins');\n const web = await syncWebBundle({\n repoRoot: location.root,\n resolvedEntries: state.resolved,\n environment,\n outputDirectory: path.join(directory, 'web-bundle'),\n onNotice: (message) => progress.line(WEB_LABEL, message),\n });\n if (web.status === 'failed') throw new Error(`Cockpit bundle failed: ${web.reason}`);\n webProgress(web.status === 'bundled' ? `cockpit bundled with plugins: ${web.pluginIds.join(', ')}` : web.reason);\n return web;\n })();\n const serverBuild = (async () => {\n const compositions = await compositionsReady;\n await runtimeBuild;\n const apiProgress = progress.start(API_LABEL, 'compiling the server bundle');\n const apiDirectory = path.join(directory, 'api');\n const fingerprint = crypto\n .createHash('sha256')\n .update(JSON.stringify([...new Set(compositions.map((composition) => composition.fingerprint))]))\n .digest('hex');\n const [server, mcp] = await Promise.all([\n syncServerBundle({\n repositoryRoot: location.root,\n generation,\n fingerprint,\n compositions,\n outputDirectory: apiDirectory,\n cacheDirectory: path.join(directory, 'cache'),\n sharedCacheDirectory: location.sharedCacheDirectory,\n }),\n syncMcpBundle({\n repositoryRoot: location.root,\n generation,\n fingerprint,\n compositions,\n outputDirectory: path.join(directory, 'mcp'),\n cacheDirectory: path.join(directory, 'cache'),\n sharedCacheDirectory: location.sharedCacheDirectory,\n }),\n ]);\n apiProgress(\n `${server.descriptor.entries.length} server facet(s), ${mcp.descriptor.entries.length} MCP plugin(s) compiled`,\n );\n for (const gap of server.contractGaps) progress.line(API_LABEL, `API contract incomplete: ${gap}`);\n return { server, mcp, fingerprint, apiDirectory };\n })();\n const [runtimeResult, webResult, serverResult] = await Promise.allSettled([runtimeBuild, webBuild, serverBuild]);\n if (runtimeResult.status === 'rejected') throw runtimeResult.reason;\n if (webResult.status === 'rejected') throw webResult.reason;\n if (serverResult.status === 'rejected') throw serverResult.reason;\n const synced = runtimeResult.value;\n const web = webResult.value;\n const { server, mcp, fingerprint, apiDirectory } = serverResult.value;\n const descriptorPath = path.join(apiDirectory, DOOM_SERVER_BUNDLE_FILE);\n const mcpDescriptorPath = path.join(directory, 'mcp', DOOM_MCP_BUNDLE_FILE);\n const finalState: SyncState = {\n ...synced.state,\n serverBundle: {\n descriptorPath,\n fingerprint,\n compilerManifests: server.compilerManifests,\n sourcesHash: computeServerSourcesHash(synced.state.resolved),\n },\n mcpBundle: {\n descriptorPath: mcpDescriptorPath,\n fingerprint,\n compilerManifests: mcp.compilerManifests,\n sourcesHash: computeMcpSourcesHash(synced.state.resolved),\n },\n };\n const statePath = await writeSyncState(\n location.root,\n finalState,\n homeDirectory,\n path.join(directory, 'state.json'),\n );\n const projectSettingsPath =\n (commandOptions.settingsMode ?? 'persisted') === 'persisted'\n ? writeProjectPiSettings(location.root, homeDirectory)\n : undefined;\n const result: SyncResult = {\n statePath,\n ...(projectSettingsPath ? { projectSettingsPath } : {}),\n selection,\n mcpServers: synced.state.baseline.mcpConfigPath ? readMcpServerNames(synced.state.baseline.mcpConfigPath) : [],\n skillCount: context.resources.skillCount,\n agentCount: context.resources.agentCount,\n };\n publishSyncRegistration(\n location.root,\n {\n version: SYNC_REGISTRATION_VERSION,\n root: location.root,\n identity: location.identity,\n generation,\n generationRoot: directory,\n statePath,\n stateSha256: syncStateSha256(statePath),\n webDirectory: web.status === 'bundled' ? web.assetsDir : null,\n apiDirectory,\n serverBundle: { path: descriptorPath, fingerprint, sha256: syncStateSha256(descriptorPath) },\n mcpBundle: { path: mcpDescriptorPath, fingerprint, sha256: syncStateSha256(mcpDescriptorPath) },\n package: packageRegistrationFor(),\n },\n homeDirectory,\n );\n // ponytail: retain generations until host-owned drain evidence can prove no session uses them.\n // Directory age and an open-file check cannot establish that a lazy import is finished.\n return result;\n } catch (error) {\n await fs.promises.rm(directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\n throw error;\n }\n}\n\n/** Compatibility API. Executables call the command function directly. */\nexport class SyncCommand {\n readonly name = SYNC_COMMAND;\n private readonly settingsMode: SyncSettingsMode;\n private readonly homeDirectory: string | undefined;\n private readonly lockHeld: boolean;\n\n constructor(options: SyncCommandOptions = {}) {\n this.settingsMode = options.settingsMode ?? 'persisted';\n this.homeDirectory = options.homeDirectory;\n this.lockHeld = options.lockHeld ?? false;\n }\n\n matches(args: string[]): boolean {\n return args[0] === this.name;\n }\n\n async execute(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n ): Promise<number> {\n return synchronize(args, environment, currentDirectory, output, {\n settingsMode: this.settingsMode,\n homeDirectory: this.homeDirectory,\n lockHeld: this.lockHeld,\n });\n }\n}\n"],"mappings":";;;;;;;;;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|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../src/cli/commands/sync/index.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../src/cli/commands/sync/index.ts"],"mappings":";;;;iBAsGiB;EACf;EACA;EACA;EACA;;;wBAIc,iBACd,yBACA,cAAa,OAAO,YACpB,2BACA,yBACC;;wBAmBa,wBAAwB,aAAa,OAAO,YAAY,sBAAsB,OAAO;KAmChG,aAAa;iBAED;EACf,eAAe;;EAEf;;EAEA;;iBAGe;EACf;;EAEA;;EAEA;EACA,WAAW;EACX;EACA;EACA;;wBAGc,oBAAoB,aAAa,OAAO,aAAa;wBAsCrD,iBAAiB,QAAQ,YAAY;;wBAkE/B,YACpB,gBACA,cAAa,OAAO,YACpB,2BACA,SAAQ,YACR,iBAAgB,qBACf;;qBAyUU;WACF;mBACQ;mBACA;mBACA;EAEjB,YAAY,UAAS;EAMrB,QAAQ;EAIF,QACJ,gBACA,cAAa,OAAO,YACpB,2BACA,SAAQ,aACP"}
|
|
@@ -13,6 +13,7 @@ import { readSyncDrift } from "../../../composition/syncDrift/index.mjs";
|
|
|
13
13
|
import { collectDrift, piIntegrationDrift, selectionCompositionFingerprint, selectionEnvironment, syncRegistrationNeedsApiMigration, toSelection } from "./inspection.mjs";
|
|
14
14
|
import { buildSyncedRuntime } from "../../../../builders/cli/index.mjs";
|
|
15
15
|
import { buildHarnessContext } from "../../../builders/cli/harnessContext.mjs";
|
|
16
|
+
import { syncHookModules } from "../../../builders/hooks/index.mjs";
|
|
16
17
|
import { syncServerBundle } from "../../../builders/server/index.mjs";
|
|
17
18
|
import { syncMcpBundle } from "../../../builders/server/mcpBundle.mjs";
|
|
18
19
|
import { syncWebBundle } from "../../../builders/web/index.mjs";
|
|
@@ -310,6 +311,13 @@ async function stageSync(repoRoot, options, environment, homeDirectory, progress
|
|
|
310
311
|
const agentDirectory = piAgentDirectory(environment, homeDirectory);
|
|
311
312
|
const persistedThemePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);
|
|
312
313
|
const themePath = (commandOptions.settingsMode ?? "persisted") === "persisted" ? persistedThemePath : context.defaultThemePath;
|
|
314
|
+
const hookModules = await syncHookModules({
|
|
315
|
+
repoRoot: location.root,
|
|
316
|
+
homeDirectory,
|
|
317
|
+
config: context.majorModesConfig,
|
|
318
|
+
directory,
|
|
319
|
+
sharedCacheDirectory: location.sharedCacheDirectory
|
|
320
|
+
});
|
|
313
321
|
const state = {
|
|
314
322
|
version: SYNC_STATE_VERSION,
|
|
315
323
|
root: location.root,
|
|
@@ -322,6 +330,7 @@ async function stageSync(repoRoot, options, environment, homeDirectory, progress
|
|
|
322
330
|
fileState: {
|
|
323
331
|
profileEnvironment: loadHarnessState(context.environment).state.profileEnvironment,
|
|
324
332
|
pluginHooks: context.resources.pluginHooks,
|
|
333
|
+
hookModules,
|
|
325
334
|
mcpProjection: context.resources.mcpProjection
|
|
326
335
|
},
|
|
327
336
|
resolved,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["loadDoomConfigLenient"],"sources":["../../../../../src/cli/commands/sync/index.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/doompi-config/config';\nimport { loadDomains } from '@agimon-ai/doompi-config/domains';\nimport { loadMajorModesConfigLenient } from '@agimon-ai/doompi-config/majorModes';\nimport type { ConfigDiagnostic } from '@agimon-ai/doompi-config/types';\nimport { DOOM_MCP_BUNDLE_FILE } from '@agimon-ai/doompi-core/mcpFacet';\nimport { piAgentDirectory, piThemeDirectory } from '@agimon-ai/doompi-core/runtimePiSettings';\nimport { DOOM_SERVER_BUNDLE_FILE } from '@agimon-ai/doompi-core/serverFacet';\nimport {\n acquireSyncLocationLock,\n resolveSyncLocation,\n syncGenerationDirectory,\n} from '@agimon-ai/doompi-core/syncLocation';\nimport {\n DOOMPI_API_VERSION,\n publishSyncRegistration,\n SYNC_REGISTRATION_VERSION,\n syncStateSha256,\n type SyncPackageRegistration,\n} from '@agimon-ai/doompi-core/syncRegistration';\nimport { DEFAULT_THEME_NAME } from '@agimon-ai/doompi-ui/theme';\n\nimport { buildSyncedRuntime } from '../../../builders/cli';\nimport { createLayerResolvers, type ExtensionComposition } from '../../../builders/cli/extensionAssembler';\nimport { buildHarnessContext } from '../../../builders/cli/harnessContext';\nimport { doomPiPackageRoot, writePiExtensionAlias } from '../../../builders/cli/piExtensionAlias';\nimport { piExtensionDispatcherIsUpgradeable } from '../../../builders/cli/piExtensionDispatcher';\nimport { writeProjectPiSettings } from '../../../builders/cli/projectSettings';\nimport { syncServerBundle } from '../../../builders/server';\nimport { syncMcpBundle } from '../../../builders/server/mcpBundle';\nimport { syncWebBundle } from '../../../builders/web';\nimport { HARNESS_STATE_POINTER, loadHarnessState } from '../../../composition/harnessState';\nimport { ensureLayerPackages, missingLayerPackageSpecifiers } from '../../../composition/layerPackageInstaller';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { resolveDoomConfigurationRoot } from '../../../composition/repository';\nimport { readSyncDrift } from '../../../composition/syncDrift';\nimport {\n computeInputsHash,\n computeMcpSourcesHash,\n computeServerSourcesHash,\n computeWebSourcesHash,\n readLocatedSyncState,\n readMcpServerNames,\n recordResolvedEntries,\n SYNC_STATE_VERSION,\n type SyncSelection,\n type SyncState,\n writeSyncState,\n} from '../../../composition/syncState';\nimport type { HarnessOptions } from '../../../composition/types/harness';\nimport { DOOMPI_DOMAINS_ENV, DOOMPI_MAJOR_MODE_ENV, DOOMPI_PROFILE_ENV } from '../../matrixOptions';\nimport { parseHarnessArgs } from '../../options';\nimport {\n collectDrift,\n piIntegrationDrift,\n selectionCompositionFingerprint,\n selectionEnvironment,\n syncRegistrationNeedsApiMigration,\n toSelection,\n type SyncSettingsMode,\n} from './inspection';\nimport { SyncProgress, type SyncProgressOutput } from './presenter';\n\nexport {\n collectDrift,\n selectionCompositionFingerprint,\n selectionEnvironment,\n syncRegistrationNeedsApiMigration,\n toSelection,\n type SyncSettingsMode,\n} from './inspection';\n\n/**\n * `doom-pi sync`: resolve the matrix once and write it where plain Pi finds it.\n *\n * The doom-emacs split. Everything that needs a real Node process (module\n * resolution, staging skills and agents, generating the MCP config) happens\n * here, and the doom-pi extension then only reads what this produced. The\n * launcher is untouched and keeps resolving the same matrix per run.\n */\n\nconst SYNC_COMMAND = 'sync';\nconst CHECK_OPTION = '--check';\n/** Republishes even when nothing drifted, for a generation suspected of being damaged. */\nconst FORCE_OPTION = '--force';\nconst GLOBAL_OPTION = '--global';\nconst HARNESS_ROOT_ENV = 'DOOMPI_ROOT';\nconst PERSONA_FILE_ENV = 'DOOMPI_PERSONA_FILE';\nconst HOOK_EMITTER = path.join('tools', 'harness', 'emit-hooks.mjs');\nconst NONE = '(none)';\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst SYNC_LABEL = 'sync';\nconst RUNTIME_LABEL = 'runtime';\nconst WEB_LABEL = 'web';\nconst API_LABEL = 'api';\n\nexport interface SyncRoots {\n globalOnly: boolean;\n globalRoot: string;\n sourceRoot: string;\n targetRoot: string;\n}\n\n/** Resolves the configuration source and publication destination for one sync. */\nexport function resolveSyncRoots(\n args: readonly string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n homeDirectory = environment.HOME ?? os.homedir(),\n): SyncRoots {\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const inheritedRoot = environment[HARNESS_ROOT_ENV];\n const sourceRoot = inheritedRoot\n ? path.resolve(inheritedRoot)\n : resolveDoomConfigurationRoot(currentDirectory, homeDirectory);\n const globalOnly = args.includes(GLOBAL_OPTION);\n return { globalOnly, globalRoot, sourceRoot, targetRoot: globalOnly ? globalRoot : sourceRoot };\n}\n\nconst GLOBAL_SCOPE_INHERITED_KEYS = [\n HARNESS_ROOT_ENV,\n HARNESS_STATE_POINTER,\n DOOMPI_MAJOR_MODE_ENV,\n DOOMPI_DOMAINS_ENV,\n DOOMPI_PROFILE_ENV,\n] as const;\n\n/** Removes workspace-only state before a global runtime is resolved. */\nexport function environmentForSyncScope(environment: NodeJS.ProcessEnv, globalOnly: boolean): NodeJS.ProcessEnv {\n if (!globalOnly) return environment;\n const scoped = { ...environment };\n for (const key of GLOBAL_SCOPE_INHERITED_KEYS) delete scoped[key];\n return scoped;\n}\n\n/**\n * Harness variables worth recording, by prefix or exact name.\n *\n * An allowlist rather than the whole environment: the state file is a snapshot\n * of resolved configuration, and dumping `process.env` into it would write\n * every credential the sync happened to run with onto disk.\n */\nconst RECORDED_PREFIXES = ['DOOMPI_'];\nconst RECORDED_KEYS = ['CLAUDE_PROJECT_DIR', 'CODEX_REPO_ROOT', 'ORIGINAL_REPO_PATH', 'MCP_UI_VIEWER'];\n/**\n * Launcher-only values a synced session must not inherit.\n *\n * The child extension list is recomposed on every load, and the subagent binary\n * points at `pi.sh`, which a session started as plain `pi` should not shell out\n * to: Doom Team resolves Pi's own CLI when the variable is absent.\n */\nconst EXCLUDED_KEYS = new Set([\n 'DOOMPI_DISTRIBUTION',\n 'DOOMPI_CHILD_EXTENSIONS',\n 'DOOMPI_COMPOSED',\n 'DOOMPI_MUTE',\n 'DOOMPI_TEMP_DIR',\n // A pointer to the syncing process's own state file. Recording it would hand\n // every later session a path to a state that died with this one.\n HARNESS_STATE_POINTER,\n 'PI_SUBAGENT_PI_BINARY',\n]);\n\ntype SyncOutput = SyncProgressOutput;\n\nexport interface SyncCommandOptions {\n settingsMode?: SyncSettingsMode;\n /** Test/embedding override; normal CLI execution uses the process home. */\n homeDirectory?: string;\n /** Internal pipeline seam when the caller owns the worktree lock. */\n lockHeld?: boolean;\n}\n\nexport interface SyncResult {\n statePath: string;\n /** Omitted when DPI supplies the integration as a process-local overlay. */\n settingsPath?: string;\n /** Set only when the repository still carried its own DoomPi registration. */\n projectSettingsPath?: string;\n selection: SyncSelection;\n mcpServers: string[];\n skillCount: number;\n agentCount: number;\n}\n\nexport function recordedEnvironment(environment: NodeJS.ProcessEnv): Record<string, string> {\n const recorded: Record<string, string> = {};\n for (const [key, value] of Object.entries(environment)) {\n if (value === undefined || EXCLUDED_KEYS.has(key)) continue;\n if (RECORDED_KEYS.includes(key) || RECORDED_PREFIXES.some((prefix) => key.startsWith(prefix))) {\n recorded[key] = value;\n }\n }\n return recorded;\n}\n\n/**\n * Reports the config keys sync chose to ignore.\n *\n * Never fatal. A key nobody recognises is usually a config written for another\n * version of a layer, and refusing to build over it is worse than proceeding\n * without it. The strict check lives in `doompi doctor`.\n */\nfunction writeConfigDiagnostics(diagnostics: readonly ConfigDiagnostic[], output: SyncOutput): void {\n if (diagnostics.length === 0) return;\n const lines = diagnostics.map((entry) => ` ${entry.filePath}: ${entry.path}`).join('\\n');\n output.write(\n `config: ignored ${String(diagnostics.length)} unsupported key(s); run doompi doctor for the strict check\\n${lines}\\n`,\n );\n}\n\n/** Regenerates the hook files the other frontends read before any harness code runs. */\nfunction emitFrontendHooks(repoRoot: string, output: SyncOutput): void {\n const emitter = path.join(repoRoot, HOOK_EMITTER);\n if (!fs.existsSync(emitter)) return;\n const result = spawnSync(process.execPath, [emitter, '--write'], { cwd: repoRoot, encoding: 'utf8' });\n if (result.status === 0) {\n output.write('hooks: regenerated for Claude Code and Codex\\n');\n return;\n }\n output.write(`hooks: emit-hooks failed (${result.stderr?.trim() || `exit ${String(result.status)}`})\\n`);\n}\n\nexport function formatSyncResult(result: SyncResult, runner = 'pi'): string {\n const { selection } = result;\n return [\n `mode: ${selection.majorMode}`,\n `domains: ${selection.domains.join(', ') || NONE}`,\n `profile: ${selection.profile ?? NONE}`,\n `skills: ${result.skillCount}`,\n `agents: ${result.agentCount}`,\n `mcp: ${result.mcpServers.join(', ') || NONE}`,\n `state: ${result.statePath}`,\n ...(result.settingsPath ? [`settings: ${result.settingsPath}`] : []),\n ...(result.projectSettingsPath\n ? [`project: removed duplicate registration from ${result.projectSettingsPath}`]\n : []),\n '',\n `Run ${runner} from the repository root to use it.`,\n '',\n ].join('\\n');\n}\n\n/**\n * The DoomPi that produced this generation, which is the one that can load it.\n *\n * Always the executing package, never another copy the repository happens to\n * install. A generation is not portable between two installations: the bundles\n * are compiled from the building package's own extension entries, the recorded\n * compiler inputs are its files, and the state names its bootstrap entry. Naming\n * a second copy here publishes a registration whose package disagrees with the\n * state it points at, and Pi's dispatcher then loads a harness that rejects the\n * bootstrap as stale on every session, with no sync able to fix it.\n *\n * A repository that wants its own copy to own its sessions runs sync with that\n * copy's CLI, which makes it the executing package.\n */\nfunction packageRegistrationFor(): SyncPackageRegistration {\n const root = fs.realpathSync(doomPiPackageRoot());\n const manifestPath = path.join(root, 'package.json');\n const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as {\n version?: unknown;\n doompiApiVersion?: unknown;\n pi?: { extensions?: unknown };\n };\n const version = manifest.version;\n const apiVersion = manifest.doompiApiVersion;\n const extensions = manifest.pi?.extensions;\n const extension = Array.isArray(extensions) ? extensions.find((value) => typeof value === 'string') : undefined;\n if (\n typeof version !== 'string' ||\n typeof apiVersion !== 'number' ||\n !Number.isSafeInteger(apiVersion) ||\n apiVersion < 1 ||\n apiVersion !== DOOMPI_API_VERSION ||\n typeof extension !== 'string'\n ) {\n throw new Error(`Installed DoomPi package at ${root} has no supported API-versioned Pi extension entry`);\n }\n return {\n root,\n version,\n apiVersion: apiVersion as number,\n manifestPath,\n entry: fs.realpathSync(path.resolve(root, extension)),\n };\n}\n\n/** Resolves the matrix, stages it into home-scoped worktree storage, and publishes one generation. */\nexport async function synchronize(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n commandOptions: SyncCommandOptions = {},\n): Promise<number> {\n const check = args.includes(CHECK_OPTION);\n const force = args.includes(FORCE_OPTION);\n const rest = args.slice(1).filter((argument) => ![CHECK_OPTION, FORCE_OPTION, GLOBAL_OPTION].includes(argument));\n const homeDirectory = commandOptions.homeDirectory ?? environment.HOME ?? os.homedir();\n const roots = resolveSyncRoots(args, environment, currentDirectory, homeDirectory);\n const { globalOnly, globalRoot, targetRoot: repoRoot } = roots;\n const scopedEnvironment = environmentForSyncScope(environment, globalOnly);\n if (globalOnly && !check) fs.mkdirSync(globalRoot, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // Sync tolerates keys it does not recognise so a config written against a\n // different version cannot break a build. `doompi doctor` reports them.\n const modes = loadMajorModesConfigLenient(repoRoot, homeDirectory, environment);\n const configDiagnostics = [...loadDoomConfigLenient(repoRoot, homeDirectory).diagnostics, ...modes.diagnostics];\n const defaultMajorMode = modes.config.defaultMajorMode;\n const defaultDomains = loadDomains(repoRoot, homeDirectory).defaultDomains;\n const parsed = parseHarnessArgs(\n rest,\n selectionEnvironment(repoRoot, scopedEnvironment, homeDirectory),\n globalOnly ? globalRoot : currentDirectory,\n defaultMajorMode,\n defaultDomains,\n );\n const selection = toSelection(parsed.options);\n const agentDirectory = piAgentDirectory(scopedEnvironment, homeDirectory);\n if ((commandOptions.settingsMode ?? 'persisted') === 'persisted' && !check) {\n if (piExtensionDispatcherIsUpgradeable(agentDirectory)) {\n writePiExtensionAlias(agentDirectory);\n output.write('repair: refreshed Pi user dispatcher\\n');\n }\n const drift = piIntegrationDrift(agentDirectory);\n if (drift.length > 0) {\n throw new Error(`DoomPi Pi integration is not ready:\\n${drift.map((entry) => ` ${entry}`).join('\\n')}`);\n }\n }\n writeConfigDiagnostics(configDiagnostics, output);\n if (check) {\n const majorModesConfig = modes.config;\n const missingPackages = missingLayerPackageSpecifiers(\n majorModesConfig,\n Object.keys(majorModesConfig.layers),\n createLayerResolvers(repoRoot),\n );\n if (missingPackages.length > 0) {\n output.write(\n `doompi sync is out of date:\\n${missingPackages\n .map((specifier) => ` configured package is not installed: ${specifier}`)\n .join('\\n')}\\n`,\n );\n return 1;\n }\n let located: ReturnType<typeof readLocatedSyncState>;\n try {\n located = readLocatedSyncState(repoRoot, homeDirectory);\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n output.write(`doompi sync is out of date:\\n ${detail}\\n`);\n return 1;\n }\n const expectedCompositionFingerprint = selectionCompositionFingerprint(\n repoRoot,\n parsed.options,\n homeDirectory,\n environment,\n );\n const drift = collectDrift(\n repoRoot,\n selection,\n located?.state,\n scopedEnvironment,\n commandOptions.settingsMode ?? 'persisted',\n expectedCompositionFingerprint,\n );\n if (drift.length === 0) {\n output.write('doompi sync is up to date\\n');\n return 0;\n }\n output.write(`doompi sync is out of date:\\n${drift.map((entry) => ` ${entry}`).join('\\n')}\\n`);\n return 1;\n }\n\n // Publishing an identical generation is not a no-op: it moves the\n // registration, so every attached cockpit reloads and the previous\n // generation becomes garbage. Same inputs, same published result.\n const driftOptions = {\n repoRoot,\n environment,\n homeDirectory,\n requireWebBundle: Boolean(environment.DOOMPI_WEB_PACKAGE_ROOT),\n };\n const registrationNeedsMigration = syncRegistrationNeedsApiMigration(repoRoot, homeDirectory);\n if (!force && !registrationNeedsMigration && readSyncDrift(driftOptions).fresh) {\n output.write('doompi sync is already up to date\\n');\n return 0;\n }\n\n const progress = new SyncProgress(output);\n const releaseLock = commandOptions.lockHeld\n ? undefined\n : await acquireSyncLocationLock(resolveSyncLocation(repoRoot, homeDirectory));\n let result: SyncResult;\n try {\n // A concurrent publisher may have resolved the drift while this command\n // waited for the lock. Avoid moving the registration for no change.\n const registrationNeedsMigration = syncRegistrationNeedsApiMigration(repoRoot, homeDirectory);\n if (!force && !registrationNeedsMigration && readSyncDrift(driftOptions).fresh) {\n output.write('doompi sync is already up to date\\n');\n return 0;\n }\n result = await stageSync(repoRoot, parsed.options, scopedEnvironment, homeDirectory, progress, commandOptions);\n } finally {\n await releaseLock?.();\n }\n emitFrontendHooks(repoRoot, output);\n output.write(formatSyncResult(result, (commandOptions.settingsMode ?? 'persisted') === 'embedded' ? 'dpi' : 'pi'));\n return 0;\n}\n\nasync function stageSync(\n repoRoot: string,\n options: Omit<HarnessOptions, 'repoRoot'>,\n environment: NodeJS.ProcessEnv,\n homeDirectory: string,\n progress: SyncProgress,\n commandOptions: SyncCommandOptions = {},\n): Promise<SyncResult> {\n const location = resolveSyncLocation(repoRoot, homeDirectory);\n const generation = `${Date.now().toString(36)}-${crypto.randomUUID()}`;\n const directory = syncGenerationDirectory(location, generation);\n await fs.promises.mkdir(location.generationsDirectory, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // The leaf is created without `recursive`, so an existing path is an error\n // rather than something to adopt: the cockpit signs and serves whatever the\n // published generation holds, and sync must only ever publish bytes it\n // wrote itself into a directory it just created.\n await fs.promises.mkdir(directory, { mode: PRIVATE_DIRECTORY_MODE });\n\n try {\n const staged = progress.start(SYNC_LABEL, 'resolving the matrix and staging resources');\n const context = await buildHarnessContext({\n ...options,\n repoRoot: location.root,\n homeDirectory,\n environment,\n cwd: location.root,\n resourceDirectory: directory,\n });\n await ensureLayerPackages({\n repoRoot: location.root,\n config: context.majorModesConfig,\n layers: Object.keys(context.majorModesConfig.layers),\n environment,\n });\n staged(`${String(context.resources.skillCount)} skills, ${String(context.resources.agentCount)} agents`);\n const selection = toSelection(options);\n const resolvers = createLayerResolvers(location.root);\n const resolved = recordResolvedEntries(context.majorModesConfig, resolvers);\n const compositionFingerprint = selectionCompositionFingerprint(location.root, options, homeDirectory, environment);\n const agentDirectory = piAgentDirectory(environment, homeDirectory);\n const persistedThemePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n const themePath =\n (commandOptions.settingsMode ?? 'persisted') === 'persisted' ? persistedThemePath : context.defaultThemePath;\n const state: SyncState = {\n version: SYNC_STATE_VERSION,\n root: location.root,\n identity: location.identity,\n inputsHash: computeInputsHash(location.root, selection, homeDirectory, context.environment),\n webSourcesHash: computeWebSourcesHash(resolved),\n compositionFingerprint,\n selection,\n env: recordedEnvironment(context.environment),\n fileState: {\n profileEnvironment: loadHarnessState(context.environment).state.profileEnvironment,\n pluginHooks: context.resources.pluginHooks,\n mcpProjection: context.resources.mcpProjection,\n },\n resolved,\n baseline: {\n mcpConfigPath: context.resources.mcpConfigPath,\n personaFile: context.environment[PERSONA_FILE_ENV],\n themePath,\n themeName: DEFAULT_THEME_NAME,\n },\n };\n\n // Runtime compilation writes the package dist files consumed by both the web\n // and server bundlers. Finish it first so a package clean cannot race either\n // consumer, then run the independent web and server builds together.\n let resolveCompositions!: (compositions: readonly ExtensionComposition[]) => void;\n let rejectCompositions!: (reason?: unknown) => void;\n const compositionsReady = new Promise<readonly ExtensionComposition[]>((resolve, reject) => {\n resolveCompositions = resolve;\n rejectCompositions = reject;\n });\n const runtimeProgress = progress.start(RUNTIME_LABEL, 'precompiling the mode bundles');\n const runtimeBuild = buildSyncedRuntime(location.root, environment, homeDirectory, {\n state,\n directory,\n onCompositionsResolved: resolveCompositions,\n }).then((synced) => {\n runtimeProgress(`${String(Object.keys(synced.bundles).length)} mode bundles`);\n return synced;\n });\n void runtimeBuild.catch(rejectCompositions);\n const webBuild = (async () => {\n await runtimeBuild;\n const webProgress = progress.start(WEB_LABEL, 'bundling the web cockpit plugins');\n const web = await syncWebBundle({\n repoRoot: location.root,\n resolvedEntries: state.resolved,\n environment,\n outputDirectory: path.join(directory, 'web-bundle'),\n onNotice: (message) => progress.line(WEB_LABEL, message),\n });\n if (web.status === 'failed') throw new Error(`Cockpit bundle failed: ${web.reason}`);\n webProgress(web.status === 'bundled' ? `cockpit bundled with plugins: ${web.pluginIds.join(', ')}` : web.reason);\n return web;\n })();\n const serverBuild = (async () => {\n const compositions = await compositionsReady;\n await runtimeBuild;\n const apiProgress = progress.start(API_LABEL, 'compiling the server bundle');\n const apiDirectory = path.join(directory, 'api');\n const fingerprint = crypto\n .createHash('sha256')\n .update(JSON.stringify([...new Set(compositions.map((composition) => composition.fingerprint))]))\n .digest('hex');\n const [server, mcp] = await Promise.all([\n syncServerBundle({\n repositoryRoot: location.root,\n generation,\n fingerprint,\n compositions,\n outputDirectory: apiDirectory,\n cacheDirectory: path.join(directory, 'cache'),\n sharedCacheDirectory: location.sharedCacheDirectory,\n }),\n syncMcpBundle({\n repositoryRoot: location.root,\n generation,\n fingerprint,\n compositions,\n outputDirectory: path.join(directory, 'mcp'),\n cacheDirectory: path.join(directory, 'cache'),\n sharedCacheDirectory: location.sharedCacheDirectory,\n }),\n ]);\n apiProgress(\n `${server.descriptor.entries.length} server facet(s), ${mcp.descriptor.entries.length} MCP plugin(s) compiled`,\n );\n for (const gap of server.contractGaps) progress.line(API_LABEL, `API contract incomplete: ${gap}`);\n return { server, mcp, fingerprint, apiDirectory };\n })();\n const [runtimeResult, webResult, serverResult] = await Promise.allSettled([runtimeBuild, webBuild, serverBuild]);\n if (runtimeResult.status === 'rejected') throw runtimeResult.reason;\n if (webResult.status === 'rejected') throw webResult.reason;\n if (serverResult.status === 'rejected') throw serverResult.reason;\n const synced = runtimeResult.value;\n const web = webResult.value;\n const { server, mcp, fingerprint, apiDirectory } = serverResult.value;\n const descriptorPath = path.join(apiDirectory, DOOM_SERVER_BUNDLE_FILE);\n const mcpDescriptorPath = path.join(directory, 'mcp', DOOM_MCP_BUNDLE_FILE);\n const finalState: SyncState = {\n ...synced.state,\n serverBundle: {\n descriptorPath,\n fingerprint,\n compilerManifests: server.compilerManifests,\n sourcesHash: computeServerSourcesHash(synced.state.resolved),\n },\n mcpBundle: {\n descriptorPath: mcpDescriptorPath,\n fingerprint,\n compilerManifests: mcp.compilerManifests,\n sourcesHash: computeMcpSourcesHash(synced.state.resolved),\n },\n };\n const statePath = await writeSyncState(\n location.root,\n finalState,\n homeDirectory,\n path.join(directory, 'state.json'),\n );\n const projectSettingsPath =\n (commandOptions.settingsMode ?? 'persisted') === 'persisted'\n ? writeProjectPiSettings(location.root, homeDirectory)\n : undefined;\n const result: SyncResult = {\n statePath,\n ...(projectSettingsPath ? { projectSettingsPath } : {}),\n selection,\n mcpServers: synced.state.baseline.mcpConfigPath ? readMcpServerNames(synced.state.baseline.mcpConfigPath) : [],\n skillCount: context.resources.skillCount,\n agentCount: context.resources.agentCount,\n };\n publishSyncRegistration(\n location.root,\n {\n version: SYNC_REGISTRATION_VERSION,\n root: location.root,\n identity: location.identity,\n generation,\n generationRoot: directory,\n statePath,\n stateSha256: syncStateSha256(statePath),\n webDirectory: web.status === 'bundled' ? web.assetsDir : null,\n apiDirectory,\n serverBundle: { path: descriptorPath, fingerprint, sha256: syncStateSha256(descriptorPath) },\n mcpBundle: { path: mcpDescriptorPath, fingerprint, sha256: syncStateSha256(mcpDescriptorPath) },\n package: packageRegistrationFor(),\n },\n homeDirectory,\n );\n // ponytail: retain generations until host-owned drain evidence can prove no session uses them.\n // Directory age and an open-file check cannot establish that a lazy import is finished.\n return result;\n } catch (error) {\n await fs.promises.rm(directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\n throw error;\n }\n}\n\n/** Compatibility API. Executables call the command function directly. */\nexport class SyncCommand {\n readonly name = SYNC_COMMAND;\n private readonly settingsMode: SyncSettingsMode;\n private readonly homeDirectory: string | undefined;\n private readonly lockHeld: boolean;\n\n constructor(options: SyncCommandOptions = {}) {\n this.settingsMode = options.settingsMode ?? 'persisted';\n this.homeDirectory = options.homeDirectory;\n this.lockHeld = options.lockHeld ?? false;\n }\n\n matches(args: string[]): boolean {\n return args[0] === this.name;\n }\n\n async execute(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n ): Promise<number> {\n return synchronize(args, environment, currentDirectory, output, {\n settingsMode: this.settingsMode,\n homeDirectory: this.homeDirectory,\n lockHeld: this.lockHeld,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,MAAM,eAAe;AACrB,MAAM,eAAe;;AAErB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,eAAe,KAAK,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,MAAM,SAAS,gBAAgB,mBAAmB,OAAO,MAAM,SAAS,aAAa,IAAI,CAAC;GAC7G,YAAY,QAAQ,UAAU;GAC9B,YAAY,QAAQ,UAAU;EAChC;EACA,wBACE,SAAS,MACT;GACE,SAAS;GACT,MAAM,SAAS;GACf,UAAU,SAAS;GACnB;GACA,gBAAgB;GAChB;GACA,aAAa,gBAAgB,SAAS;GACtC,cAAc,IAAI,WAAW,YAAY,IAAI,YAAY;GACzD;GACA,cAAc;IAAE,MAAM;IAAgB;IAAa,QAAQ,gBAAgB,cAAc;GAAE;GAC3F,WAAW;IAAE,MAAM;IAAmB;IAAa,QAAQ,gBAAgB,iBAAiB;GAAE;GAC9F,SAAS,uBAAuB;EAClC,GACA,aACF;EAGA,OAAO;CACT,SAAS,OAAO;EACd,MAAM,GAAG,SAAS,GAAG,WAAW;GAAE,WAAW;GAAM,OAAO;GAAM,YAAY;GAAG,YAAY;EAAI,CAAC;EAChG,MAAM;CACR;AACF;;AAGA,IAAa,cAAb,MAAyB;CACvB,OAAgB;CAChB;CACA;CACA;CAEA,YAAY,UAA8B,CAAC,GAAG;EAC5C,KAAK,eAAe,QAAQ,gBAAgB;EAC5C,KAAK,gBAAgB,QAAQ;EAC7B,KAAK,WAAW,QAAQ,YAAY;CACtC;CAEA,QAAQ,MAAyB;EAC/B,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,MAAM,QACJ,MACA,cAAiC,QAAQ,KACzC,mBAAmB,QAAQ,IAAI,GAC/B,SAAqB,QAAQ,QACZ;EACjB,OAAO,YAAY,MAAM,aAAa,kBAAkB,QAAQ;GAC9D,cAAc,KAAK;GACnB,eAAe,KAAK;GACpB,UAAU,KAAK;EACjB,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["loadDoomConfigLenient"],"sources":["../../../../../src/cli/commands/sync/index.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/doompi-config/config';\nimport { loadDomains } from '@agimon-ai/doompi-config/domains';\nimport { loadMajorModesConfigLenient } from '@agimon-ai/doompi-config/majorModes';\nimport type { ConfigDiagnostic } from '@agimon-ai/doompi-config/types';\nimport { DOOM_MCP_BUNDLE_FILE } from '@agimon-ai/doompi-core/mcpFacet';\nimport { piAgentDirectory, piThemeDirectory } from '@agimon-ai/doompi-core/runtimePiSettings';\nimport { DOOM_SERVER_BUNDLE_FILE } from '@agimon-ai/doompi-core/serverFacet';\nimport {\n acquireSyncLocationLock,\n resolveSyncLocation,\n syncGenerationDirectory,\n} from '@agimon-ai/doompi-core/syncLocation';\nimport {\n DOOMPI_API_VERSION,\n publishSyncRegistration,\n SYNC_REGISTRATION_VERSION,\n syncStateSha256,\n type SyncPackageRegistration,\n} from '@agimon-ai/doompi-core/syncRegistration';\nimport { DEFAULT_THEME_NAME } from '@agimon-ai/doompi-ui/theme';\n\nimport { buildSyncedRuntime } from '../../../builders/cli';\nimport { createLayerResolvers, type ExtensionComposition } from '../../../builders/cli/extensionAssembler';\nimport { buildHarnessContext } from '../../../builders/cli/harnessContext';\nimport { doomPiPackageRoot, writePiExtensionAlias } from '../../../builders/cli/piExtensionAlias';\nimport { piExtensionDispatcherIsUpgradeable } from '../../../builders/cli/piExtensionDispatcher';\nimport { writeProjectPiSettings } from '../../../builders/cli/projectSettings';\nimport { syncHookModules } from '../../../builders/hooks';\nimport { syncServerBundle } from '../../../builders/server';\nimport { syncMcpBundle } from '../../../builders/server/mcpBundle';\nimport { syncWebBundle } from '../../../builders/web';\nimport { HARNESS_STATE_POINTER, loadHarnessState } from '../../../composition/harnessState';\nimport { ensureLayerPackages, missingLayerPackageSpecifiers } from '../../../composition/layerPackageInstaller';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { resolveDoomConfigurationRoot } from '../../../composition/repository';\nimport { readSyncDrift } from '../../../composition/syncDrift';\nimport {\n computeInputsHash,\n computeMcpSourcesHash,\n computeServerSourcesHash,\n computeWebSourcesHash,\n readLocatedSyncState,\n readMcpServerNames,\n recordResolvedEntries,\n SYNC_STATE_VERSION,\n type SyncSelection,\n type SyncState,\n writeSyncState,\n} from '../../../composition/syncState';\nimport type { HarnessOptions } from '../../../composition/types/harness';\nimport { DOOMPI_DOMAINS_ENV, DOOMPI_MAJOR_MODE_ENV, DOOMPI_PROFILE_ENV } from '../../matrixOptions';\nimport { parseHarnessArgs } from '../../options';\nimport {\n collectDrift,\n piIntegrationDrift,\n selectionCompositionFingerprint,\n selectionEnvironment,\n syncRegistrationNeedsApiMigration,\n toSelection,\n type SyncSettingsMode,\n} from './inspection';\nimport { SyncProgress, type SyncProgressOutput } from './presenter';\n\nexport {\n collectDrift,\n selectionCompositionFingerprint,\n selectionEnvironment,\n syncRegistrationNeedsApiMigration,\n toSelection,\n type SyncSettingsMode,\n} from './inspection';\n\n/**\n * `doom-pi sync`: resolve the matrix once and write it where plain Pi finds it.\n *\n * The doom-emacs split. Everything that needs a real Node process (module\n * resolution, staging skills and agents, generating the MCP config) happens\n * here, and the doom-pi extension then only reads what this produced. The\n * launcher is untouched and keeps resolving the same matrix per run.\n */\n\nconst SYNC_COMMAND = 'sync';\nconst CHECK_OPTION = '--check';\n/** Republishes even when nothing drifted, for a generation suspected of being damaged. */\nconst FORCE_OPTION = '--force';\nconst GLOBAL_OPTION = '--global';\nconst HARNESS_ROOT_ENV = 'DOOMPI_ROOT';\nconst PERSONA_FILE_ENV = 'DOOMPI_PERSONA_FILE';\nconst HOOK_EMITTER = path.join('tools', 'harness', 'emit-hooks.mjs');\nconst NONE = '(none)';\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst SYNC_LABEL = 'sync';\nconst RUNTIME_LABEL = 'runtime';\nconst WEB_LABEL = 'web';\nconst API_LABEL = 'api';\n\nexport interface SyncRoots {\n globalOnly: boolean;\n globalRoot: string;\n sourceRoot: string;\n targetRoot: string;\n}\n\n/** Resolves the configuration source and publication destination for one sync. */\nexport function resolveSyncRoots(\n args: readonly string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n homeDirectory = environment.HOME ?? os.homedir(),\n): SyncRoots {\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const inheritedRoot = environment[HARNESS_ROOT_ENV];\n const sourceRoot = inheritedRoot\n ? path.resolve(inheritedRoot)\n : resolveDoomConfigurationRoot(currentDirectory, homeDirectory);\n const globalOnly = args.includes(GLOBAL_OPTION);\n return { globalOnly, globalRoot, sourceRoot, targetRoot: globalOnly ? globalRoot : sourceRoot };\n}\n\nconst GLOBAL_SCOPE_INHERITED_KEYS = [\n HARNESS_ROOT_ENV,\n HARNESS_STATE_POINTER,\n DOOMPI_MAJOR_MODE_ENV,\n DOOMPI_DOMAINS_ENV,\n DOOMPI_PROFILE_ENV,\n] as const;\n\n/** Removes workspace-only state before a global runtime is resolved. */\nexport function environmentForSyncScope(environment: NodeJS.ProcessEnv, globalOnly: boolean): NodeJS.ProcessEnv {\n if (!globalOnly) return environment;\n const scoped = { ...environment };\n for (const key of GLOBAL_SCOPE_INHERITED_KEYS) delete scoped[key];\n return scoped;\n}\n\n/**\n * Harness variables worth recording, by prefix or exact name.\n *\n * An allowlist rather than the whole environment: the state file is a snapshot\n * of resolved configuration, and dumping `process.env` into it would write\n * every credential the sync happened to run with onto disk.\n */\nconst RECORDED_PREFIXES = ['DOOMPI_'];\nconst RECORDED_KEYS = ['CLAUDE_PROJECT_DIR', 'CODEX_REPO_ROOT', 'ORIGINAL_REPO_PATH', 'MCP_UI_VIEWER'];\n/**\n * Launcher-only values a synced session must not inherit.\n *\n * The child extension list is recomposed on every load, and the subagent binary\n * points at `pi.sh`, which a session started as plain `pi` should not shell out\n * to: Doom Team resolves Pi's own CLI when the variable is absent.\n */\nconst EXCLUDED_KEYS = new Set([\n 'DOOMPI_DISTRIBUTION',\n 'DOOMPI_CHILD_EXTENSIONS',\n 'DOOMPI_COMPOSED',\n 'DOOMPI_MUTE',\n 'DOOMPI_TEMP_DIR',\n // A pointer to the syncing process's own state file. Recording it would hand\n // every later session a path to a state that died with this one.\n HARNESS_STATE_POINTER,\n 'PI_SUBAGENT_PI_BINARY',\n]);\n\ntype SyncOutput = SyncProgressOutput;\n\nexport interface SyncCommandOptions {\n settingsMode?: SyncSettingsMode;\n /** Test/embedding override; normal CLI execution uses the process home. */\n homeDirectory?: string;\n /** Internal pipeline seam when the caller owns the worktree lock. */\n lockHeld?: boolean;\n}\n\nexport interface SyncResult {\n statePath: string;\n /** Omitted when DPI supplies the integration as a process-local overlay. */\n settingsPath?: string;\n /** Set only when the repository still carried its own DoomPi registration. */\n projectSettingsPath?: string;\n selection: SyncSelection;\n mcpServers: string[];\n skillCount: number;\n agentCount: number;\n}\n\nexport function recordedEnvironment(environment: NodeJS.ProcessEnv): Record<string, string> {\n const recorded: Record<string, string> = {};\n for (const [key, value] of Object.entries(environment)) {\n if (value === undefined || EXCLUDED_KEYS.has(key)) continue;\n if (RECORDED_KEYS.includes(key) || RECORDED_PREFIXES.some((prefix) => key.startsWith(prefix))) {\n recorded[key] = value;\n }\n }\n return recorded;\n}\n\n/**\n * Reports the config keys sync chose to ignore.\n *\n * Never fatal. A key nobody recognises is usually a config written for another\n * version of a layer, and refusing to build over it is worse than proceeding\n * without it. The strict check lives in `doompi doctor`.\n */\nfunction writeConfigDiagnostics(diagnostics: readonly ConfigDiagnostic[], output: SyncOutput): void {\n if (diagnostics.length === 0) return;\n const lines = diagnostics.map((entry) => ` ${entry.filePath}: ${entry.path}`).join('\\n');\n output.write(\n `config: ignored ${String(diagnostics.length)} unsupported key(s); run doompi doctor for the strict check\\n${lines}\\n`,\n );\n}\n\n/** Regenerates the hook files the other frontends read before any harness code runs. */\nfunction emitFrontendHooks(repoRoot: string, output: SyncOutput): void {\n const emitter = path.join(repoRoot, HOOK_EMITTER);\n if (!fs.existsSync(emitter)) return;\n const result = spawnSync(process.execPath, [emitter, '--write'], { cwd: repoRoot, encoding: 'utf8' });\n if (result.status === 0) {\n output.write('hooks: regenerated for Claude Code and Codex\\n');\n return;\n }\n output.write(`hooks: emit-hooks failed (${result.stderr?.trim() || `exit ${String(result.status)}`})\\n`);\n}\n\nexport function formatSyncResult(result: SyncResult, runner = 'pi'): string {\n const { selection } = result;\n return [\n `mode: ${selection.majorMode}`,\n `domains: ${selection.domains.join(', ') || NONE}`,\n `profile: ${selection.profile ?? NONE}`,\n `skills: ${result.skillCount}`,\n `agents: ${result.agentCount}`,\n `mcp: ${result.mcpServers.join(', ') || NONE}`,\n `state: ${result.statePath}`,\n ...(result.settingsPath ? [`settings: ${result.settingsPath}`] : []),\n ...(result.projectSettingsPath\n ? [`project: removed duplicate registration from ${result.projectSettingsPath}`]\n : []),\n '',\n `Run ${runner} from the repository root to use it.`,\n '',\n ].join('\\n');\n}\n\n/**\n * The DoomPi that produced this generation, which is the one that can load it.\n *\n * Always the executing package, never another copy the repository happens to\n * install. A generation is not portable between two installations: the bundles\n * are compiled from the building package's own extension entries, the recorded\n * compiler inputs are its files, and the state names its bootstrap entry. Naming\n * a second copy here publishes a registration whose package disagrees with the\n * state it points at, and Pi's dispatcher then loads a harness that rejects the\n * bootstrap as stale on every session, with no sync able to fix it.\n *\n * A repository that wants its own copy to own its sessions runs sync with that\n * copy's CLI, which makes it the executing package.\n */\nfunction packageRegistrationFor(): SyncPackageRegistration {\n const root = fs.realpathSync(doomPiPackageRoot());\n const manifestPath = path.join(root, 'package.json');\n const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as {\n version?: unknown;\n doompiApiVersion?: unknown;\n pi?: { extensions?: unknown };\n };\n const version = manifest.version;\n const apiVersion = manifest.doompiApiVersion;\n const extensions = manifest.pi?.extensions;\n const extension = Array.isArray(extensions) ? extensions.find((value) => typeof value === 'string') : undefined;\n if (\n typeof version !== 'string' ||\n typeof apiVersion !== 'number' ||\n !Number.isSafeInteger(apiVersion) ||\n apiVersion < 1 ||\n apiVersion !== DOOMPI_API_VERSION ||\n typeof extension !== 'string'\n ) {\n throw new Error(`Installed DoomPi package at ${root} has no supported API-versioned Pi extension entry`);\n }\n return {\n root,\n version,\n apiVersion: apiVersion as number,\n manifestPath,\n entry: fs.realpathSync(path.resolve(root, extension)),\n };\n}\n\n/** Resolves the matrix, stages it into home-scoped worktree storage, and publishes one generation. */\nexport async function synchronize(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n commandOptions: SyncCommandOptions = {},\n): Promise<number> {\n const check = args.includes(CHECK_OPTION);\n const force = args.includes(FORCE_OPTION);\n const rest = args.slice(1).filter((argument) => ![CHECK_OPTION, FORCE_OPTION, GLOBAL_OPTION].includes(argument));\n const homeDirectory = commandOptions.homeDirectory ?? environment.HOME ?? os.homedir();\n const roots = resolveSyncRoots(args, environment, currentDirectory, homeDirectory);\n const { globalOnly, globalRoot, targetRoot: repoRoot } = roots;\n const scopedEnvironment = environmentForSyncScope(environment, globalOnly);\n if (globalOnly && !check) fs.mkdirSync(globalRoot, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // Sync tolerates keys it does not recognise so a config written against a\n // different version cannot break a build. `doompi doctor` reports them.\n const modes = loadMajorModesConfigLenient(repoRoot, homeDirectory, environment);\n const configDiagnostics = [...loadDoomConfigLenient(repoRoot, homeDirectory).diagnostics, ...modes.diagnostics];\n const defaultMajorMode = modes.config.defaultMajorMode;\n const defaultDomains = loadDomains(repoRoot, homeDirectory).defaultDomains;\n const parsed = parseHarnessArgs(\n rest,\n selectionEnvironment(repoRoot, scopedEnvironment, homeDirectory),\n globalOnly ? globalRoot : currentDirectory,\n defaultMajorMode,\n defaultDomains,\n );\n const selection = toSelection(parsed.options);\n const agentDirectory = piAgentDirectory(scopedEnvironment, homeDirectory);\n if ((commandOptions.settingsMode ?? 'persisted') === 'persisted' && !check) {\n if (piExtensionDispatcherIsUpgradeable(agentDirectory)) {\n writePiExtensionAlias(agentDirectory);\n output.write('repair: refreshed Pi user dispatcher\\n');\n }\n const drift = piIntegrationDrift(agentDirectory);\n if (drift.length > 0) {\n throw new Error(`DoomPi Pi integration is not ready:\\n${drift.map((entry) => ` ${entry}`).join('\\n')}`);\n }\n }\n writeConfigDiagnostics(configDiagnostics, output);\n if (check) {\n const majorModesConfig = modes.config;\n const missingPackages = missingLayerPackageSpecifiers(\n majorModesConfig,\n Object.keys(majorModesConfig.layers),\n createLayerResolvers(repoRoot),\n );\n if (missingPackages.length > 0) {\n output.write(\n `doompi sync is out of date:\\n${missingPackages\n .map((specifier) => ` configured package is not installed: ${specifier}`)\n .join('\\n')}\\n`,\n );\n return 1;\n }\n let located: ReturnType<typeof readLocatedSyncState>;\n try {\n located = readLocatedSyncState(repoRoot, homeDirectory);\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n output.write(`doompi sync is out of date:\\n ${detail}\\n`);\n return 1;\n }\n const expectedCompositionFingerprint = selectionCompositionFingerprint(\n repoRoot,\n parsed.options,\n homeDirectory,\n environment,\n );\n const drift = collectDrift(\n repoRoot,\n selection,\n located?.state,\n scopedEnvironment,\n commandOptions.settingsMode ?? 'persisted',\n expectedCompositionFingerprint,\n );\n if (drift.length === 0) {\n output.write('doompi sync is up to date\\n');\n return 0;\n }\n output.write(`doompi sync is out of date:\\n${drift.map((entry) => ` ${entry}`).join('\\n')}\\n`);\n return 1;\n }\n\n // Publishing an identical generation is not a no-op: it moves the\n // registration, so every attached cockpit reloads and the previous\n // generation becomes garbage. Same inputs, same published result.\n const driftOptions = {\n repoRoot,\n environment,\n homeDirectory,\n requireWebBundle: Boolean(environment.DOOMPI_WEB_PACKAGE_ROOT),\n };\n const registrationNeedsMigration = syncRegistrationNeedsApiMigration(repoRoot, homeDirectory);\n if (!force && !registrationNeedsMigration && readSyncDrift(driftOptions).fresh) {\n output.write('doompi sync is already up to date\\n');\n return 0;\n }\n\n const progress = new SyncProgress(output);\n const releaseLock = commandOptions.lockHeld\n ? undefined\n : await acquireSyncLocationLock(resolveSyncLocation(repoRoot, homeDirectory));\n let result: SyncResult;\n try {\n // A concurrent publisher may have resolved the drift while this command\n // waited for the lock. Avoid moving the registration for no change.\n const registrationNeedsMigration = syncRegistrationNeedsApiMigration(repoRoot, homeDirectory);\n if (!force && !registrationNeedsMigration && readSyncDrift(driftOptions).fresh) {\n output.write('doompi sync is already up to date\\n');\n return 0;\n }\n result = await stageSync(repoRoot, parsed.options, scopedEnvironment, homeDirectory, progress, commandOptions);\n } finally {\n await releaseLock?.();\n }\n emitFrontendHooks(repoRoot, output);\n output.write(formatSyncResult(result, (commandOptions.settingsMode ?? 'persisted') === 'embedded' ? 'dpi' : 'pi'));\n return 0;\n}\n\nasync function stageSync(\n repoRoot: string,\n options: Omit<HarnessOptions, 'repoRoot'>,\n environment: NodeJS.ProcessEnv,\n homeDirectory: string,\n progress: SyncProgress,\n commandOptions: SyncCommandOptions = {},\n): Promise<SyncResult> {\n const location = resolveSyncLocation(repoRoot, homeDirectory);\n const generation = `${Date.now().toString(36)}-${crypto.randomUUID()}`;\n const directory = syncGenerationDirectory(location, generation);\n await fs.promises.mkdir(location.generationsDirectory, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // The leaf is created without `recursive`, so an existing path is an error\n // rather than something to adopt: the cockpit signs and serves whatever the\n // published generation holds, and sync must only ever publish bytes it\n // wrote itself into a directory it just created.\n await fs.promises.mkdir(directory, { mode: PRIVATE_DIRECTORY_MODE });\n\n try {\n const staged = progress.start(SYNC_LABEL, 'resolving the matrix and staging resources');\n const context = await buildHarnessContext({\n ...options,\n repoRoot: location.root,\n homeDirectory,\n environment,\n cwd: location.root,\n resourceDirectory: directory,\n });\n await ensureLayerPackages({\n repoRoot: location.root,\n config: context.majorModesConfig,\n layers: Object.keys(context.majorModesConfig.layers),\n environment,\n });\n staged(`${String(context.resources.skillCount)} skills, ${String(context.resources.agentCount)} agents`);\n const selection = toSelection(options);\n const resolvers = createLayerResolvers(location.root);\n const resolved = recordResolvedEntries(context.majorModesConfig, resolvers);\n const compositionFingerprint = selectionCompositionFingerprint(location.root, options, homeDirectory, environment);\n const agentDirectory = piAgentDirectory(environment, homeDirectory);\n const persistedThemePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n const themePath =\n (commandOptions.settingsMode ?? 'persisted') === 'persisted' ? persistedThemePath : context.defaultThemePath;\n const hookModules = await syncHookModules({\n repoRoot: location.root,\n homeDirectory,\n config: context.majorModesConfig,\n directory,\n sharedCacheDirectory: location.sharedCacheDirectory,\n });\n const state: SyncState = {\n version: SYNC_STATE_VERSION,\n root: location.root,\n identity: location.identity,\n inputsHash: computeInputsHash(location.root, selection, homeDirectory, context.environment),\n webSourcesHash: computeWebSourcesHash(resolved),\n compositionFingerprint,\n selection,\n env: recordedEnvironment(context.environment),\n fileState: {\n profileEnvironment: loadHarnessState(context.environment).state.profileEnvironment,\n pluginHooks: context.resources.pluginHooks,\n hookModules,\n mcpProjection: context.resources.mcpProjection,\n },\n resolved,\n baseline: {\n mcpConfigPath: context.resources.mcpConfigPath,\n personaFile: context.environment[PERSONA_FILE_ENV],\n themePath,\n themeName: DEFAULT_THEME_NAME,\n },\n };\n\n // Runtime compilation writes the package dist files consumed by both the web\n // and server bundlers. Finish it first so a package clean cannot race either\n // consumer, then run the independent web and server builds together.\n let resolveCompositions!: (compositions: readonly ExtensionComposition[]) => void;\n let rejectCompositions!: (reason?: unknown) => void;\n const compositionsReady = new Promise<readonly ExtensionComposition[]>((resolve, reject) => {\n resolveCompositions = resolve;\n rejectCompositions = reject;\n });\n const runtimeProgress = progress.start(RUNTIME_LABEL, 'precompiling the mode bundles');\n const runtimeBuild = buildSyncedRuntime(location.root, environment, homeDirectory, {\n state,\n directory,\n onCompositionsResolved: resolveCompositions,\n }).then((synced) => {\n runtimeProgress(`${String(Object.keys(synced.bundles).length)} mode bundles`);\n return synced;\n });\n void runtimeBuild.catch(rejectCompositions);\n const webBuild = (async () => {\n await runtimeBuild;\n const webProgress = progress.start(WEB_LABEL, 'bundling the web cockpit plugins');\n const web = await syncWebBundle({\n repoRoot: location.root,\n resolvedEntries: state.resolved,\n environment,\n outputDirectory: path.join(directory, 'web-bundle'),\n onNotice: (message) => progress.line(WEB_LABEL, message),\n });\n if (web.status === 'failed') throw new Error(`Cockpit bundle failed: ${web.reason}`);\n webProgress(web.status === 'bundled' ? `cockpit bundled with plugins: ${web.pluginIds.join(', ')}` : web.reason);\n return web;\n })();\n const serverBuild = (async () => {\n const compositions = await compositionsReady;\n await runtimeBuild;\n const apiProgress = progress.start(API_LABEL, 'compiling the server bundle');\n const apiDirectory = path.join(directory, 'api');\n const fingerprint = crypto\n .createHash('sha256')\n .update(JSON.stringify([...new Set(compositions.map((composition) => composition.fingerprint))]))\n .digest('hex');\n const [server, mcp] = await Promise.all([\n syncServerBundle({\n repositoryRoot: location.root,\n generation,\n fingerprint,\n compositions,\n outputDirectory: apiDirectory,\n cacheDirectory: path.join(directory, 'cache'),\n sharedCacheDirectory: location.sharedCacheDirectory,\n }),\n syncMcpBundle({\n repositoryRoot: location.root,\n generation,\n fingerprint,\n compositions,\n outputDirectory: path.join(directory, 'mcp'),\n cacheDirectory: path.join(directory, 'cache'),\n sharedCacheDirectory: location.sharedCacheDirectory,\n }),\n ]);\n apiProgress(\n `${server.descriptor.entries.length} server facet(s), ${mcp.descriptor.entries.length} MCP plugin(s) compiled`,\n );\n for (const gap of server.contractGaps) progress.line(API_LABEL, `API contract incomplete: ${gap}`);\n return { server, mcp, fingerprint, apiDirectory };\n })();\n const [runtimeResult, webResult, serverResult] = await Promise.allSettled([runtimeBuild, webBuild, serverBuild]);\n if (runtimeResult.status === 'rejected') throw runtimeResult.reason;\n if (webResult.status === 'rejected') throw webResult.reason;\n if (serverResult.status === 'rejected') throw serverResult.reason;\n const synced = runtimeResult.value;\n const web = webResult.value;\n const { server, mcp, fingerprint, apiDirectory } = serverResult.value;\n const descriptorPath = path.join(apiDirectory, DOOM_SERVER_BUNDLE_FILE);\n const mcpDescriptorPath = path.join(directory, 'mcp', DOOM_MCP_BUNDLE_FILE);\n const finalState: SyncState = {\n ...synced.state,\n serverBundle: {\n descriptorPath,\n fingerprint,\n compilerManifests: server.compilerManifests,\n sourcesHash: computeServerSourcesHash(synced.state.resolved),\n },\n mcpBundle: {\n descriptorPath: mcpDescriptorPath,\n fingerprint,\n compilerManifests: mcp.compilerManifests,\n sourcesHash: computeMcpSourcesHash(synced.state.resolved),\n },\n };\n const statePath = await writeSyncState(\n location.root,\n finalState,\n homeDirectory,\n path.join(directory, 'state.json'),\n );\n const projectSettingsPath =\n (commandOptions.settingsMode ?? 'persisted') === 'persisted'\n ? writeProjectPiSettings(location.root, homeDirectory)\n : undefined;\n const result: SyncResult = {\n statePath,\n ...(projectSettingsPath ? { projectSettingsPath } : {}),\n selection,\n mcpServers: synced.state.baseline.mcpConfigPath ? readMcpServerNames(synced.state.baseline.mcpConfigPath) : [],\n skillCount: context.resources.skillCount,\n agentCount: context.resources.agentCount,\n };\n publishSyncRegistration(\n location.root,\n {\n version: SYNC_REGISTRATION_VERSION,\n root: location.root,\n identity: location.identity,\n generation,\n generationRoot: directory,\n statePath,\n stateSha256: syncStateSha256(statePath),\n webDirectory: web.status === 'bundled' ? web.assetsDir : null,\n apiDirectory,\n serverBundle: { path: descriptorPath, fingerprint, sha256: syncStateSha256(descriptorPath) },\n mcpBundle: { path: mcpDescriptorPath, fingerprint, sha256: syncStateSha256(mcpDescriptorPath) },\n package: packageRegistrationFor(),\n },\n homeDirectory,\n );\n // ponytail: retain generations until host-owned drain evidence can prove no session uses them.\n // Directory age and an open-file check cannot establish that a lazy import is finished.\n return result;\n } catch (error) {\n await fs.promises.rm(directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\n throw error;\n }\n}\n\n/** Compatibility API. Executables call the command function directly. */\nexport class SyncCommand {\n readonly name = SYNC_COMMAND;\n private readonly settingsMode: SyncSettingsMode;\n private readonly homeDirectory: string | undefined;\n private readonly lockHeld: boolean;\n\n constructor(options: SyncCommandOptions = {}) {\n this.settingsMode = options.settingsMode ?? 'persisted';\n this.homeDirectory = options.homeDirectory;\n this.lockHeld = options.lockHeld ?? false;\n }\n\n matches(args: string[]): boolean {\n return args[0] === this.name;\n }\n\n async execute(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n ): Promise<number> {\n return synchronize(args, environment, currentDirectory, output, {\n settingsMode: this.settingsMode,\n homeDirectory: this.homeDirectory,\n lockHeld: this.lockHeld,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,eAAe;AACrB,MAAM,eAAe;;AAErB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,eAAe,KAAK,KAAK,SAAS,WAAW,gBAAgB;AACnE,MAAM,OAAO;AACb,MAAM,yBAAyB;AAC/B,MAAM,aAAa;AACnB,MAAM,gBAAgB;AACtB,MAAM,YAAY;AAClB,MAAM,YAAY;;AAUlB,SAAgB,iBACd,MACA,cAAiC,QAAQ,KACzC,mBAAmB,QAAQ,IAAI,GAC/B,gBAAgB,YAAY,QAAQ,GAAG,QAAQ,GACpC;CACX,MAAM,aAAa,0BAA0B,aAAa;CAC1D,MAAM,gBAAgB,YAAY;CAClC,MAAM,aAAa,gBACf,KAAK,QAAQ,aAAa,IAC1B,6BAA6B,kBAAkB,aAAa;CAChE,MAAM,aAAa,KAAK,SAAS,aAAa;CAC9C,OAAO;EAAE;EAAY;EAAY;EAAY,YAAY,aAAa,aAAa;CAAW;AAChG;AAEA,MAAM,8BAA8B;CAClC;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,wBAAwB,aAAgC,YAAwC;CAC9G,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,SAAS,EAAE,GAAG,YAAY;CAChC,KAAK,MAAM,OAAO,6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AY;GAAG,YAAY;EAAI,CAAC;EAChG,MAAM;CACR;AACF;;AAGA,IAAa,cAAb,MAAyB;CACvB,OAAgB;CAChB;CACA;CACA;CAEA,YAAY,UAA8B,CAAC,GAAG;EAC5C,KAAK,eAAe,QAAQ,gBAAgB;EAC5C,KAAK,gBAAgB,QAAQ;EAC7B,KAAK,WAAW,QAAQ,YAAY;CACtC;CAEA,QAAQ,MAAyB;EAC/B,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,MAAM,QACJ,MACA,cAAiC,QAAQ,KACzC,mBAAmB,QAAQ,IAAI,GAC/B,SAAqB,QAAQ,QACZ;EACjB,OAAO,YAAY,MAAM,aAAa,kBAAkB,QAAQ;GAC9D,cAAc,KAAK;GACnB,eAAe,KAAK;GACpB,UAAU,KAAK;EACjB,CAAC;CACH;AACF"}
|
|
@@ -97,6 +97,7 @@ function collectDrift(repoRoot, selection, state, environment = process.env, set
|
|
|
97
97
|
});
|
|
98
98
|
const sharedMessages = {
|
|
99
99
|
"never-synced": "sync registration is missing or invalid",
|
|
100
|
+
"runtime-stale": "precompiled runtime or hook modules are missing or stale",
|
|
100
101
|
"code-changed": "cockpit sources changed since the last sync",
|
|
101
102
|
"cockpit-bundle-missing": "cockpit bundle is missing",
|
|
102
103
|
"package-apis-missing": "package API routes are missing",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspection.cjs","names":["loadDoomConfigLenient","DOOMPI_MAJOR_MODE_ENV","DOOMPI_PROFILE_ENV","DOOMPI_DOMAINS_ENV","os","loadMajorModesConfig","createLayerResolvers","resolveExtensionComposition","PERSONA_ENTRY","filterHookDisabledLayers","resolveLayers","path","piThemeDirectory","DEFAULT_THEME_NAME","readPiSettings","mergePiSettings","serializePiSettings","piExtensionAliasIsCurrent","DEFAULT_THEME","fs","syncStateRootMatches","computeInputsHash","recordResolvedEntries","readBootstrapStatus","piAgentDirectory","projectRegistersDoom","DUPLICATE_REGISTRATION_DRIFT","readSyncDrift","readSyncRegistration","SYNC_REGISTRATION_VERSION"],"sources":["../../../../../src/cli/commands/sync/inspection.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { filterHookDisabledLayers, loadMajorModesConfig, resolveLayers } from '@agimon-ai/doompi-config/majorModes';\nimport {\n mergePiSettings,\n piAgentDirectory,\n piThemeDirectory,\n readPiSettings,\n serializePiSettings,\n} from '@agimon-ai/doompi-core/runtimePiSettings';\nimport { readSyncRegistration, SYNC_REGISTRATION_VERSION } from '@agimon-ai/doompi-core/syncRegistration';\nimport { DEFAULT_THEME, DEFAULT_THEME_NAME } from '@agimon-ai/doompi-ui/theme';\n\nimport { readBootstrapStatus } from '../../../builders/cli/bootstrapLocator';\nimport {\n createLayerResolvers,\n PERSONA_ENTRY,\n resolveExtensionComposition,\n} from '../../../builders/cli/extensionAssembler';\nimport { piExtensionAliasIsCurrent } from '../../../builders/cli/piExtensionAlias';\nimport { DUPLICATE_REGISTRATION_DRIFT, projectRegistersDoom } from '../../../builders/cli/projectSettings';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { readSyncDrift, type SyncDriftReason } from '../../../composition/syncDrift';\nimport {\n computeInputsHash,\n recordResolvedEntries,\n syncStateRootMatches,\n type SyncSelection,\n type SyncState,\n} from '../../../composition/syncState';\nimport type { HarnessOptions } from '../../../composition/types/harness';\nimport { DOOMPI_DOMAINS_ENV, DOOMPI_MAJOR_MODE_ENV, DOOMPI_PROFILE_ENV } from '../../matrixOptions';\n\nexport type SyncSettingsMode = 'persisted' | 'embedded';\n\n/** Read-only checks shared by sync, doctor, and the running agent. No build-time imports. */\nexport function selectionEnvironment(\n repoRoot: string,\n environment: NodeJS.ProcessEnv,\n homeDirectory?: string,\n): NodeJS.ProcessEnv {\n const { selection } = loadDoomConfigLenient(repoRoot, homeDirectory).config;\n if (!selection) return environment;\n return {\n ...environment,\n ...(selection.majorMode && !environment[DOOMPI_MAJOR_MODE_ENV]\n ? { [DOOMPI_MAJOR_MODE_ENV]: selection.majorMode }\n : {}),\n ...(selection.profile && !environment[DOOMPI_PROFILE_ENV] ? { [DOOMPI_PROFILE_ENV]: selection.profile } : {}),\n ...(selection.domains && environment[DOOMPI_DOMAINS_ENV] === undefined\n ? { [DOOMPI_DOMAINS_ENV]: selection.domains.join(',') }\n : {}),\n };\n}\n\nexport function toSelection(\n options: Pick<HarnessOptions, 'majorMode' | 'domains' | 'profile' | 'preset'>,\n): SyncSelection {\n return {\n majorMode: options.majorMode,\n domains: options.domains,\n profile: options.profile,\n preset: options.preset,\n };\n}\n\nexport function selectionCompositionFingerprint(\n repoRoot: string,\n options: Pick<HarnessOptions, 'agents' | 'hooks' | 'majorMode' | 'mcp' | 'preset'>,\n homeDirectory: string = os.homedir(),\n environment: NodeJS.ProcessEnv = process.env,\n): string {\n const majorModesConfig = loadMajorModesConfig(repoRoot, homeDirectory, environment);\n const resolvers = createLayerResolvers(repoRoot);\n return resolveExtensionComposition({\n agents: options.agents,\n autoStop: false,\n mute: false,\n preset: options.preset,\n personaEntry: resolvers.packageEntry(PERSONA_ENTRY),\n majorMode: options.majorMode,\n layers: filterHookDisabledLayers(\n majorModesConfig,\n resolveLayers(majorModesConfig, options.majorMode),\n options.hooks,\n ),\n majorModesConfig,\n resolvers,\n }).fingerprint;\n}\n\n/** Settings, dispatcher and theme differences an init would fix, independent of sync state. */\nexport function piIntegrationDrift(agentDirectory: string): string[] {\n const drift: string[] = [];\n const themePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n const settings = readPiSettings(agentDirectory);\n const merged = mergePiSettings(settings, agentDirectory, { themePath, themeName: DEFAULT_THEME_NAME });\n if (serializePiSettings(merged) !== serializePiSettings(settings)) {\n drift.push('Pi user settings are out of date; run doompi init');\n }\n if (!piExtensionAliasIsCurrent(agentDirectory)) drift.push('Pi user dispatcher is out of date; run doompi init');\n const expectedTheme = `${JSON.stringify(DEFAULT_THEME, null, 2)}\\n`;\n if (!fs.existsSync(themePath) || fs.readFileSync(themePath, 'utf8') !== expectedTheme) {\n drift.push('Pi user theme is out of date; run doompi init');\n }\n return drift;\n}\n\n/** Differences between what a sync would produce and what is on disk. */\nexport function collectDrift(\n repoRoot: string,\n selection: SyncSelection,\n state: SyncState | undefined,\n environment: NodeJS.ProcessEnv = process.env,\n settingsMode: SyncSettingsMode = 'persisted',\n expectedCompositionFingerprint?: string,\n): string[] {\n if (!state) return ['no sync state: run doompi sync'];\n const drift: string[] = [];\n if (syncRegistrationNeedsApiMigration(repoRoot, environment.HOME ?? os.homedir())) {\n drift.push('DoomPi registration needs API migration');\n }\n if (!syncStateRootMatches(repoRoot, state.root)) drift.push('sync state belongs to a different repository');\n const recorded = state.selection;\n if (\n recorded.majorMode !== selection.majorMode ||\n recorded.profile !== selection.profile ||\n recorded.preset !== selection.preset ||\n recorded.domains.join(',') !== selection.domains.join(',')\n ) {\n drift.push('selection changed since the last sync');\n }\n // Hash the recorded selection so selection changes are not counted twice.\n if (computeInputsHash(repoRoot, recorded, environment.HOME ?? os.homedir(), environment) !== state.inputsHash) {\n drift.push('.doom configuration changed');\n }\n if (\n JSON.stringify(\n recordResolvedEntries(\n loadMajorModesConfig(repoRoot, environment.HOME ?? os.homedir(), environment),\n createLayerResolvers(repoRoot),\n ),\n ) !== JSON.stringify(state.resolved)\n ) {\n drift.push('resolved extension paths changed');\n }\n if (expectedCompositionFingerprint && state.compositionFingerprint !== expectedCompositionFingerprint) {\n drift.push('extension composition changed');\n }\n try {\n if (!readBootstrapStatus(repoRoot, undefined, environment.HOME ?? os.homedir()).fresh) {\n drift.push('precompiled runtime is missing or stale');\n }\n } catch {\n drift.push('precompiled runtime is missing or stale');\n }\n\n if (settingsMode === 'persisted') {\n const agentDirectory = piAgentDirectory(environment);\n const themePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n drift.push(...piIntegrationDrift(agentDirectory));\n if (projectRegistersDoom(repoRoot)) drift.push(DUPLICATE_REGISTRATION_DRIFT);\n if (state.baseline.themePath !== themePath || state.baseline.themeName !== DEFAULT_THEME_NAME) {\n drift.push('synced theme location is out of date');\n }\n }\n const sharedDrift = readSyncDrift({ repoRoot, environment, homeDirectory: environment.HOME ?? os.homedir() });\n const sharedMessages: Partial<Record<SyncDriftReason, string>> = {\n 'never-synced': 'sync registration is missing or invalid',\n 'code-changed': 'cockpit sources changed since the last sync',\n 'cockpit-bundle-missing': 'cockpit bundle is missing',\n 'package-apis-missing': 'package API routes are missing',\n 'server-bundle-stale': 'server bundle is missing or stale',\n 'mcp-bundle-stale': 'MCP bundle is missing or stale',\n };\n for (const reason of sharedDrift.reasons) {\n const message = sharedMessages[reason];\n if (message) drift.push(message);\n }\n return drift;\n}\n\n/** Returns true when a valid legacy registration must be republished with API metadata. */\nexport function syncRegistrationNeedsApiMigration(repoRoot: string, homeDirectory: string): boolean {\n try {\n const registration = readSyncRegistration(repoRoot, homeDirectory);\n return (\n registration !== undefined &&\n (registration.version !== SYNC_REGISTRATION_VERSION || registration.package.apiVersion === undefined)\n );\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,qBACd,UACA,aACA,eACmB;CACnB,MAAM,EAAE,cAAcA,gBAAAA,sBAAsB,UAAU,aAAa,CAAC,CAAC;CACrE,IAAI,CAAC,WAAW,OAAO;CACvB,OAAO;EACL,GAAG;EACH,GAAI,UAAU,aAAa,CAAC,YAAA,uBACxB,GAAGC,sBAAAA,wBAAwB,UAAU,UAAU,IAC/C,CAAC;EACL,GAAI,UAAU,WAAW,CAAC,YAAA,oBAAkC,GAAGC,sBAAAA,qBAAqB,UAAU,QAAQ,IAAI,CAAC;EAC3G,GAAI,UAAU,WAAW,YAAA,sBAAoC,KAAA,IACzD,GAAGC,sBAAAA,qBAAqB,UAAU,QAAQ,KAAK,GAAG,EAAE,IACpD,CAAC;CACP;AACF;AAEA,SAAgB,YACd,SACe;CACf,OAAO;EACL,WAAW,QAAQ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,GAAiBoB,yCAAAA,iBAAAA,CAAiB,WAAW;EACnD,MAAM,YAAYb,UAAAA,QAAK,MAAA,GAAKC,yCAAAA,iBAAAA,CAAiB,cAAc,GAAG,GAAGC,2BAAAA,mBAAmB,MAAM;EAC1F,MAAM,KAAK,GAAG,mBAAmB,cAAc,CAAC;EAChD,IAAIY,wBAAAA,qBAAqB,QAAQ,GAAG,MAAM,KAAKC,wBAAAA,4BAA4B;EAC3E,IAAI,MAAM,SAAS,cAAc,aAAa,MAAM,SAAS,cAAcb,2BAAAA,oBACzE,MAAM,KAAK,sCAAsC;CAErD;CACA,MAAM,cAAcc,gBAAAA,cAAc;EAAE;EAAU;EAAa,eAAe,YAAY,QAAQvB,QAAAA,QAAG,QAAQ;CAAE,CAAC;CAC5G,MAAM,iBAA2D;EAC/D,gBAAgB;EAChB,gBAAgB;EAChB,0BAA0B;EAC1B,wBAAwB;EACxB,uBAAuB;EACvB,oBAAoB;CACtB;CACA,KAAK,MAAM,UAAU,YAAY,SAAS;EACxC,MAAM,UAAU,eAAe;EAC/B,IAAI,SAAS,MAAM,KAAK,OAAO;CACjC;CACA,OAAO;AACT;;AAGA,SAAgB,kCAAkC,UAAkB,eAAgC;CAClG,IAAI;EACF,MAAM,gBAAA,GAAewB,wCAAAA,qBAAAA,CAAqB,UAAU,aAAa;EACjE,OACE,iBAAiB,KAAA,MAChB,aAAa,YAAYC,wCAAAA,6BAA6B,aAAa,QAAQ,eAAe,KAAA;CAE/F,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"inspection.cjs","names":["loadDoomConfigLenient","DOOMPI_MAJOR_MODE_ENV","DOOMPI_PROFILE_ENV","DOOMPI_DOMAINS_ENV","os","loadMajorModesConfig","createLayerResolvers","resolveExtensionComposition","PERSONA_ENTRY","filterHookDisabledLayers","resolveLayers","path","piThemeDirectory","DEFAULT_THEME_NAME","readPiSettings","mergePiSettings","serializePiSettings","piExtensionAliasIsCurrent","DEFAULT_THEME","fs","syncStateRootMatches","computeInputsHash","recordResolvedEntries","readBootstrapStatus","piAgentDirectory","projectRegistersDoom","DUPLICATE_REGISTRATION_DRIFT","readSyncDrift","readSyncRegistration","SYNC_REGISTRATION_VERSION"],"sources":["../../../../../src/cli/commands/sync/inspection.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { filterHookDisabledLayers, loadMajorModesConfig, resolveLayers } from '@agimon-ai/doompi-config/majorModes';\nimport {\n mergePiSettings,\n piAgentDirectory,\n piThemeDirectory,\n readPiSettings,\n serializePiSettings,\n} from '@agimon-ai/doompi-core/runtimePiSettings';\nimport { readSyncRegistration, SYNC_REGISTRATION_VERSION } from '@agimon-ai/doompi-core/syncRegistration';\nimport { DEFAULT_THEME, DEFAULT_THEME_NAME } from '@agimon-ai/doompi-ui/theme';\n\nimport { readBootstrapStatus } from '../../../builders/cli/bootstrapLocator';\nimport {\n createLayerResolvers,\n PERSONA_ENTRY,\n resolveExtensionComposition,\n} from '../../../builders/cli/extensionAssembler';\nimport { piExtensionAliasIsCurrent } from '../../../builders/cli/piExtensionAlias';\nimport { DUPLICATE_REGISTRATION_DRIFT, projectRegistersDoom } from '../../../builders/cli/projectSettings';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { readSyncDrift, type SyncDriftReason } from '../../../composition/syncDrift';\nimport {\n computeInputsHash,\n recordResolvedEntries,\n syncStateRootMatches,\n type SyncSelection,\n type SyncState,\n} from '../../../composition/syncState';\nimport type { HarnessOptions } from '../../../composition/types/harness';\nimport { DOOMPI_DOMAINS_ENV, DOOMPI_MAJOR_MODE_ENV, DOOMPI_PROFILE_ENV } from '../../matrixOptions';\n\nexport type SyncSettingsMode = 'persisted' | 'embedded';\n\n/** Read-only checks shared by sync, doctor, and the running agent. No build-time imports. */\nexport function selectionEnvironment(\n repoRoot: string,\n environment: NodeJS.ProcessEnv,\n homeDirectory?: string,\n): NodeJS.ProcessEnv {\n const { selection } = loadDoomConfigLenient(repoRoot, homeDirectory).config;\n if (!selection) return environment;\n return {\n ...environment,\n ...(selection.majorMode && !environment[DOOMPI_MAJOR_MODE_ENV]\n ? { [DOOMPI_MAJOR_MODE_ENV]: selection.majorMode }\n : {}),\n ...(selection.profile && !environment[DOOMPI_PROFILE_ENV] ? { [DOOMPI_PROFILE_ENV]: selection.profile } : {}),\n ...(selection.domains && environment[DOOMPI_DOMAINS_ENV] === undefined\n ? { [DOOMPI_DOMAINS_ENV]: selection.domains.join(',') }\n : {}),\n };\n}\n\nexport function toSelection(\n options: Pick<HarnessOptions, 'majorMode' | 'domains' | 'profile' | 'preset'>,\n): SyncSelection {\n return {\n majorMode: options.majorMode,\n domains: options.domains,\n profile: options.profile,\n preset: options.preset,\n };\n}\n\nexport function selectionCompositionFingerprint(\n repoRoot: string,\n options: Pick<HarnessOptions, 'agents' | 'hooks' | 'majorMode' | 'mcp' | 'preset'>,\n homeDirectory: string = os.homedir(),\n environment: NodeJS.ProcessEnv = process.env,\n): string {\n const majorModesConfig = loadMajorModesConfig(repoRoot, homeDirectory, environment);\n const resolvers = createLayerResolvers(repoRoot);\n return resolveExtensionComposition({\n agents: options.agents,\n autoStop: false,\n mute: false,\n preset: options.preset,\n personaEntry: resolvers.packageEntry(PERSONA_ENTRY),\n majorMode: options.majorMode,\n layers: filterHookDisabledLayers(\n majorModesConfig,\n resolveLayers(majorModesConfig, options.majorMode),\n options.hooks,\n ),\n majorModesConfig,\n resolvers,\n }).fingerprint;\n}\n\n/** Settings, dispatcher and theme differences an init would fix, independent of sync state. */\nexport function piIntegrationDrift(agentDirectory: string): string[] {\n const drift: string[] = [];\n const themePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n const settings = readPiSettings(agentDirectory);\n const merged = mergePiSettings(settings, agentDirectory, { themePath, themeName: DEFAULT_THEME_NAME });\n if (serializePiSettings(merged) !== serializePiSettings(settings)) {\n drift.push('Pi user settings are out of date; run doompi init');\n }\n if (!piExtensionAliasIsCurrent(agentDirectory)) drift.push('Pi user dispatcher is out of date; run doompi init');\n const expectedTheme = `${JSON.stringify(DEFAULT_THEME, null, 2)}\\n`;\n if (!fs.existsSync(themePath) || fs.readFileSync(themePath, 'utf8') !== expectedTheme) {\n drift.push('Pi user theme is out of date; run doompi init');\n }\n return drift;\n}\n\n/** Differences between what a sync would produce and what is on disk. */\nexport function collectDrift(\n repoRoot: string,\n selection: SyncSelection,\n state: SyncState | undefined,\n environment: NodeJS.ProcessEnv = process.env,\n settingsMode: SyncSettingsMode = 'persisted',\n expectedCompositionFingerprint?: string,\n): string[] {\n if (!state) return ['no sync state: run doompi sync'];\n const drift: string[] = [];\n if (syncRegistrationNeedsApiMigration(repoRoot, environment.HOME ?? os.homedir())) {\n drift.push('DoomPi registration needs API migration');\n }\n if (!syncStateRootMatches(repoRoot, state.root)) drift.push('sync state belongs to a different repository');\n const recorded = state.selection;\n if (\n recorded.majorMode !== selection.majorMode ||\n recorded.profile !== selection.profile ||\n recorded.preset !== selection.preset ||\n recorded.domains.join(',') !== selection.domains.join(',')\n ) {\n drift.push('selection changed since the last sync');\n }\n // Hash the recorded selection so selection changes are not counted twice.\n if (computeInputsHash(repoRoot, recorded, environment.HOME ?? os.homedir(), environment) !== state.inputsHash) {\n drift.push('.doom configuration changed');\n }\n if (\n JSON.stringify(\n recordResolvedEntries(\n loadMajorModesConfig(repoRoot, environment.HOME ?? os.homedir(), environment),\n createLayerResolvers(repoRoot),\n ),\n ) !== JSON.stringify(state.resolved)\n ) {\n drift.push('resolved extension paths changed');\n }\n if (expectedCompositionFingerprint && state.compositionFingerprint !== expectedCompositionFingerprint) {\n drift.push('extension composition changed');\n }\n try {\n if (!readBootstrapStatus(repoRoot, undefined, environment.HOME ?? os.homedir()).fresh) {\n drift.push('precompiled runtime is missing or stale');\n }\n } catch {\n drift.push('precompiled runtime is missing or stale');\n }\n\n if (settingsMode === 'persisted') {\n const agentDirectory = piAgentDirectory(environment);\n const themePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n drift.push(...piIntegrationDrift(agentDirectory));\n if (projectRegistersDoom(repoRoot)) drift.push(DUPLICATE_REGISTRATION_DRIFT);\n if (state.baseline.themePath !== themePath || state.baseline.themeName !== DEFAULT_THEME_NAME) {\n drift.push('synced theme location is out of date');\n }\n }\n const sharedDrift = readSyncDrift({ repoRoot, environment, homeDirectory: environment.HOME ?? os.homedir() });\n const sharedMessages: Partial<Record<SyncDriftReason, string>> = {\n 'never-synced': 'sync registration is missing or invalid',\n 'runtime-stale': 'precompiled runtime or hook modules are missing or stale',\n 'code-changed': 'cockpit sources changed since the last sync',\n 'cockpit-bundle-missing': 'cockpit bundle is missing',\n 'package-apis-missing': 'package API routes are missing',\n 'server-bundle-stale': 'server bundle is missing or stale',\n 'mcp-bundle-stale': 'MCP bundle is missing or stale',\n };\n for (const reason of sharedDrift.reasons) {\n const message = sharedMessages[reason];\n if (message) drift.push(message);\n }\n return drift;\n}\n\n/** Returns true when a valid legacy registration must be republished with API metadata. */\nexport function syncRegistrationNeedsApiMigration(repoRoot: string, homeDirectory: string): boolean {\n try {\n const registration = readSyncRegistration(repoRoot, homeDirectory);\n return (\n registration !== undefined &&\n (registration.version !== SYNC_REGISTRATION_VERSION || registration.package.apiVersion === undefined)\n );\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,qBACd,UACA,aACA,eACmB;CACnB,MAAM,EAAE,cAAcA,gBAAAA,sBAAsB,UAAU,aAAa,CAAC,CAAC;CACrE,IAAI,CAAC,WAAW,OAAO;CACvB,OAAO;EACL,GAAG;EACH,GAAI,UAAU,aAAa,CAAC,YAAA,uBACxB,GAAGC,sBAAAA,wBAAwB,UAAU,UAAU,IAC/C,CAAC;EACL,GAAI,UAAU,WAAW,CAAC,YAAA,oBAAkC,GAAGC,sBAAAA,qBAAqB,UAAU,QAAQ,IAAI,CAAC;EAC3G,GAAI,UAAU,WAAW,YAAA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,kBACA,aAAa,OAAO,YACpB,yBACC,OAAO;wBAeM,YACd,SAAS,KAAK,kEACb;wBASa,gCACd,kBACA,SAAS,KAAK,sEACd,wBACA,cAAa,OAAO;;wBAuCN,aACd,kBACA,WAAW,eACX,OAAO,uBACP,cAAa,OAAO,YACpB,eAAc,kBACd;;
|
|
1
|
+
{"version":3,"file":"inspection.d.mts","names":[],"sources":["../../../../../src/cli/commands/sync/inspection.ts"],"mappings":";;;YAmCY;;wBAGI,qBACd,kBACA,aAAa,OAAO,YACpB,yBACC,OAAO;wBAeM,YACd,SAAS,KAAK,kEACb;wBASa,gCACd,kBACA,SAAS,KAAK,sEACd,wBACA,cAAa,OAAO;;wBAuCN,aACd,kBACA,WAAW,eACX,OAAO,uBACP,cAAa,OAAO,YACpB,eAAc,kBACd;;wBAqEc,kCAAkC,kBAAkB"}
|
|
@@ -93,6 +93,7 @@ function collectDrift(repoRoot, selection, state, environment = process.env, set
|
|
|
93
93
|
});
|
|
94
94
|
const sharedMessages = {
|
|
95
95
|
"never-synced": "sync registration is missing or invalid",
|
|
96
|
+
"runtime-stale": "precompiled runtime or hook modules are missing or stale",
|
|
96
97
|
"code-changed": "cockpit sources changed since the last sync",
|
|
97
98
|
"cockpit-bundle-missing": "cockpit bundle is missing",
|
|
98
99
|
"package-apis-missing": "package API routes are missing",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspection.mjs","names":[],"sources":["../../../../../src/cli/commands/sync/inspection.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { filterHookDisabledLayers, loadMajorModesConfig, resolveLayers } from '@agimon-ai/doompi-config/majorModes';\nimport {\n mergePiSettings,\n piAgentDirectory,\n piThemeDirectory,\n readPiSettings,\n serializePiSettings,\n} from '@agimon-ai/doompi-core/runtimePiSettings';\nimport { readSyncRegistration, SYNC_REGISTRATION_VERSION } from '@agimon-ai/doompi-core/syncRegistration';\nimport { DEFAULT_THEME, DEFAULT_THEME_NAME } from '@agimon-ai/doompi-ui/theme';\n\nimport { readBootstrapStatus } from '../../../builders/cli/bootstrapLocator';\nimport {\n createLayerResolvers,\n PERSONA_ENTRY,\n resolveExtensionComposition,\n} from '../../../builders/cli/extensionAssembler';\nimport { piExtensionAliasIsCurrent } from '../../../builders/cli/piExtensionAlias';\nimport { DUPLICATE_REGISTRATION_DRIFT, projectRegistersDoom } from '../../../builders/cli/projectSettings';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { readSyncDrift, type SyncDriftReason } from '../../../composition/syncDrift';\nimport {\n computeInputsHash,\n recordResolvedEntries,\n syncStateRootMatches,\n type SyncSelection,\n type SyncState,\n} from '../../../composition/syncState';\nimport type { HarnessOptions } from '../../../composition/types/harness';\nimport { DOOMPI_DOMAINS_ENV, DOOMPI_MAJOR_MODE_ENV, DOOMPI_PROFILE_ENV } from '../../matrixOptions';\n\nexport type SyncSettingsMode = 'persisted' | 'embedded';\n\n/** Read-only checks shared by sync, doctor, and the running agent. No build-time imports. */\nexport function selectionEnvironment(\n repoRoot: string,\n environment: NodeJS.ProcessEnv,\n homeDirectory?: string,\n): NodeJS.ProcessEnv {\n const { selection } = loadDoomConfigLenient(repoRoot, homeDirectory).config;\n if (!selection) return environment;\n return {\n ...environment,\n ...(selection.majorMode && !environment[DOOMPI_MAJOR_MODE_ENV]\n ? { [DOOMPI_MAJOR_MODE_ENV]: selection.majorMode }\n : {}),\n ...(selection.profile && !environment[DOOMPI_PROFILE_ENV] ? { [DOOMPI_PROFILE_ENV]: selection.profile } : {}),\n ...(selection.domains && environment[DOOMPI_DOMAINS_ENV] === undefined\n ? { [DOOMPI_DOMAINS_ENV]: selection.domains.join(',') }\n : {}),\n };\n}\n\nexport function toSelection(\n options: Pick<HarnessOptions, 'majorMode' | 'domains' | 'profile' | 'preset'>,\n): SyncSelection {\n return {\n majorMode: options.majorMode,\n domains: options.domains,\n profile: options.profile,\n preset: options.preset,\n };\n}\n\nexport function selectionCompositionFingerprint(\n repoRoot: string,\n options: Pick<HarnessOptions, 'agents' | 'hooks' | 'majorMode' | 'mcp' | 'preset'>,\n homeDirectory: string = os.homedir(),\n environment: NodeJS.ProcessEnv = process.env,\n): string {\n const majorModesConfig = loadMajorModesConfig(repoRoot, homeDirectory, environment);\n const resolvers = createLayerResolvers(repoRoot);\n return resolveExtensionComposition({\n agents: options.agents,\n autoStop: false,\n mute: false,\n preset: options.preset,\n personaEntry: resolvers.packageEntry(PERSONA_ENTRY),\n majorMode: options.majorMode,\n layers: filterHookDisabledLayers(\n majorModesConfig,\n resolveLayers(majorModesConfig, options.majorMode),\n options.hooks,\n ),\n majorModesConfig,\n resolvers,\n }).fingerprint;\n}\n\n/** Settings, dispatcher and theme differences an init would fix, independent of sync state. */\nexport function piIntegrationDrift(agentDirectory: string): string[] {\n const drift: string[] = [];\n const themePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n const settings = readPiSettings(agentDirectory);\n const merged = mergePiSettings(settings, agentDirectory, { themePath, themeName: DEFAULT_THEME_NAME });\n if (serializePiSettings(merged) !== serializePiSettings(settings)) {\n drift.push('Pi user settings are out of date; run doompi init');\n }\n if (!piExtensionAliasIsCurrent(agentDirectory)) drift.push('Pi user dispatcher is out of date; run doompi init');\n const expectedTheme = `${JSON.stringify(DEFAULT_THEME, null, 2)}\\n`;\n if (!fs.existsSync(themePath) || fs.readFileSync(themePath, 'utf8') !== expectedTheme) {\n drift.push('Pi user theme is out of date; run doompi init');\n }\n return drift;\n}\n\n/** Differences between what a sync would produce and what is on disk. */\nexport function collectDrift(\n repoRoot: string,\n selection: SyncSelection,\n state: SyncState | undefined,\n environment: NodeJS.ProcessEnv = process.env,\n settingsMode: SyncSettingsMode = 'persisted',\n expectedCompositionFingerprint?: string,\n): string[] {\n if (!state) return ['no sync state: run doompi sync'];\n const drift: string[] = [];\n if (syncRegistrationNeedsApiMigration(repoRoot, environment.HOME ?? os.homedir())) {\n drift.push('DoomPi registration needs API migration');\n }\n if (!syncStateRootMatches(repoRoot, state.root)) drift.push('sync state belongs to a different repository');\n const recorded = state.selection;\n if (\n recorded.majorMode !== selection.majorMode ||\n recorded.profile !== selection.profile ||\n recorded.preset !== selection.preset ||\n recorded.domains.join(',') !== selection.domains.join(',')\n ) {\n drift.push('selection changed since the last sync');\n }\n // Hash the recorded selection so selection changes are not counted twice.\n if (computeInputsHash(repoRoot, recorded, environment.HOME ?? os.homedir(), environment) !== state.inputsHash) {\n drift.push('.doom configuration changed');\n }\n if (\n JSON.stringify(\n recordResolvedEntries(\n loadMajorModesConfig(repoRoot, environment.HOME ?? os.homedir(), environment),\n createLayerResolvers(repoRoot),\n ),\n ) !== JSON.stringify(state.resolved)\n ) {\n drift.push('resolved extension paths changed');\n }\n if (expectedCompositionFingerprint && state.compositionFingerprint !== expectedCompositionFingerprint) {\n drift.push('extension composition changed');\n }\n try {\n if (!readBootstrapStatus(repoRoot, undefined, environment.HOME ?? os.homedir()).fresh) {\n drift.push('precompiled runtime is missing or stale');\n }\n } catch {\n drift.push('precompiled runtime is missing or stale');\n }\n\n if (settingsMode === 'persisted') {\n const agentDirectory = piAgentDirectory(environment);\n const themePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n drift.push(...piIntegrationDrift(agentDirectory));\n if (projectRegistersDoom(repoRoot)) drift.push(DUPLICATE_REGISTRATION_DRIFT);\n if (state.baseline.themePath !== themePath || state.baseline.themeName !== DEFAULT_THEME_NAME) {\n drift.push('synced theme location is out of date');\n }\n }\n const sharedDrift = readSyncDrift({ repoRoot, environment, homeDirectory: environment.HOME ?? os.homedir() });\n const sharedMessages: Partial<Record<SyncDriftReason, string>> = {\n 'never-synced': 'sync registration is missing or invalid',\n 'code-changed': 'cockpit sources changed since the last sync',\n 'cockpit-bundle-missing': 'cockpit bundle is missing',\n 'package-apis-missing': 'package API routes are missing',\n 'server-bundle-stale': 'server bundle is missing or stale',\n 'mcp-bundle-stale': 'MCP bundle is missing or stale',\n };\n for (const reason of sharedDrift.reasons) {\n const message = sharedMessages[reason];\n if (message) drift.push(message);\n }\n return drift;\n}\n\n/** Returns true when a valid legacy registration must be republished with API metadata. */\nexport function syncRegistrationNeedsApiMigration(repoRoot: string, homeDirectory: string): boolean {\n try {\n const registration = readSyncRegistration(repoRoot, homeDirectory);\n return (\n registration !== undefined &&\n (registration.version !== SYNC_REGISTRATION_VERSION || registration.package.apiVersion === undefined)\n );\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsCA,SAAgB,qBACd,UACA,aACA,eACmB;CACnB,MAAM,EAAE,cAAc,sBAAsB,UAAU,aAAa,CAAC,CAAC;CACrE,IAAI,CAAC,WAAW,OAAO;CACvB,OAAO;EACL,GAAG;EACH,GAAI,UAAU,aAAa,CAAC,YAAA,uBACxB,GAAG,wBAAwB,UAAU,UAAU,IAC/C,CAAC;EACL,GAAI,UAAU,WAAW,CAAC,YAAA,oBAAkC,GAAG,qBAAqB,UAAU,QAAQ,IAAI,CAAC;EAC3G,GAAI,UAAU,WAAW,YAAA,sBAAoC,KAAA,IACzD,GAAG,qBAAqB,UAAU,QAAQ,KAAK,GAAG,EAAE,IACpD,CAAC;CACP;AACF;AAEA,SAAgB,YACd,SACe;CACf,OAAO;EACL,WAAW,QAAQ;EACnB,SAAS,QAAQ;EACjB,SAAS,QAAQ;EACjB,QAAQ,QAAQ;CAClB;AACF;AAEA,SAAgB,gCACd,UACA,SACA,gBAAwB,GAAG,QAAQ,GACnC,cAAiC,QAAQ,KACjC;CACR,MAAM,mBAAmB,qBAAqB,UAAU,eAAe,WAAW;CAClF,MAAM,YAAY,qBAAqB,QAAQ;CAC/C,OAAO,4BAA4B;EACjC,QAAQ,QAAQ;EAChB,UAAU;EACV,MAAM;EACN,QAAQ,QAAQ;EAChB,cAAc,UAAU,aAAa,aAAa;EAClD,WAAW,QAAQ;EACnB,QAAQ,yBACN,kBACA,cAAc,kBAAkB,QAAQ,SAAS,GACjD,Q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
|
+
{"version":3,"file":"inspection.mjs","names":[],"sources":["../../../../../src/cli/commands/sync/inspection.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { filterHookDisabledLayers, loadMajorModesConfig, resolveLayers } from '@agimon-ai/doompi-config/majorModes';\nimport {\n mergePiSettings,\n piAgentDirectory,\n piThemeDirectory,\n readPiSettings,\n serializePiSettings,\n} from '@agimon-ai/doompi-core/runtimePiSettings';\nimport { readSyncRegistration, SYNC_REGISTRATION_VERSION } from '@agimon-ai/doompi-core/syncRegistration';\nimport { DEFAULT_THEME, DEFAULT_THEME_NAME } from '@agimon-ai/doompi-ui/theme';\n\nimport { readBootstrapStatus } from '../../../builders/cli/bootstrapLocator';\nimport {\n createLayerResolvers,\n PERSONA_ENTRY,\n resolveExtensionComposition,\n} from '../../../builders/cli/extensionAssembler';\nimport { piExtensionAliasIsCurrent } from '../../../builders/cli/piExtensionAlias';\nimport { DUPLICATE_REGISTRATION_DRIFT, projectRegistersDoom } from '../../../builders/cli/projectSettings';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { readSyncDrift, type SyncDriftReason } from '../../../composition/syncDrift';\nimport {\n computeInputsHash,\n recordResolvedEntries,\n syncStateRootMatches,\n type SyncSelection,\n type SyncState,\n} from '../../../composition/syncState';\nimport type { HarnessOptions } from '../../../composition/types/harness';\nimport { DOOMPI_DOMAINS_ENV, DOOMPI_MAJOR_MODE_ENV, DOOMPI_PROFILE_ENV } from '../../matrixOptions';\n\nexport type SyncSettingsMode = 'persisted' | 'embedded';\n\n/** Read-only checks shared by sync, doctor, and the running agent. No build-time imports. */\nexport function selectionEnvironment(\n repoRoot: string,\n environment: NodeJS.ProcessEnv,\n homeDirectory?: string,\n): NodeJS.ProcessEnv {\n const { selection } = loadDoomConfigLenient(repoRoot, homeDirectory).config;\n if (!selection) return environment;\n return {\n ...environment,\n ...(selection.majorMode && !environment[DOOMPI_MAJOR_MODE_ENV]\n ? { [DOOMPI_MAJOR_MODE_ENV]: selection.majorMode }\n : {}),\n ...(selection.profile && !environment[DOOMPI_PROFILE_ENV] ? { [DOOMPI_PROFILE_ENV]: selection.profile } : {}),\n ...(selection.domains && environment[DOOMPI_DOMAINS_ENV] === undefined\n ? { [DOOMPI_DOMAINS_ENV]: selection.domains.join(',') }\n : {}),\n };\n}\n\nexport function toSelection(\n options: Pick<HarnessOptions, 'majorMode' | 'domains' | 'profile' | 'preset'>,\n): SyncSelection {\n return {\n majorMode: options.majorMode,\n domains: options.domains,\n profile: options.profile,\n preset: options.preset,\n };\n}\n\nexport function selectionCompositionFingerprint(\n repoRoot: string,\n options: Pick<HarnessOptions, 'agents' | 'hooks' | 'majorMode' | 'mcp' | 'preset'>,\n homeDirectory: string = os.homedir(),\n environment: NodeJS.ProcessEnv = process.env,\n): string {\n const majorModesConfig = loadMajorModesConfig(repoRoot, homeDirectory, environment);\n const resolvers = createLayerResolvers(repoRoot);\n return resolveExtensionComposition({\n agents: options.agents,\n autoStop: false,\n mute: false,\n preset: options.preset,\n personaEntry: resolvers.packageEntry(PERSONA_ENTRY),\n majorMode: options.majorMode,\n layers: filterHookDisabledLayers(\n majorModesConfig,\n resolveLayers(majorModesConfig, options.majorMode),\n options.hooks,\n ),\n majorModesConfig,\n resolvers,\n }).fingerprint;\n}\n\n/** Settings, dispatcher and theme differences an init would fix, independent of sync state. */\nexport function piIntegrationDrift(agentDirectory: string): string[] {\n const drift: string[] = [];\n const themePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n const settings = readPiSettings(agentDirectory);\n const merged = mergePiSettings(settings, agentDirectory, { themePath, themeName: DEFAULT_THEME_NAME });\n if (serializePiSettings(merged) !== serializePiSettings(settings)) {\n drift.push('Pi user settings are out of date; run doompi init');\n }\n if (!piExtensionAliasIsCurrent(agentDirectory)) drift.push('Pi user dispatcher is out of date; run doompi init');\n const expectedTheme = `${JSON.stringify(DEFAULT_THEME, null, 2)}\\n`;\n if (!fs.existsSync(themePath) || fs.readFileSync(themePath, 'utf8') !== expectedTheme) {\n drift.push('Pi user theme is out of date; run doompi init');\n }\n return drift;\n}\n\n/** Differences between what a sync would produce and what is on disk. */\nexport function collectDrift(\n repoRoot: string,\n selection: SyncSelection,\n state: SyncState | undefined,\n environment: NodeJS.ProcessEnv = process.env,\n settingsMode: SyncSettingsMode = 'persisted',\n expectedCompositionFingerprint?: string,\n): string[] {\n if (!state) return ['no sync state: run doompi sync'];\n const drift: string[] = [];\n if (syncRegistrationNeedsApiMigration(repoRoot, environment.HOME ?? os.homedir())) {\n drift.push('DoomPi registration needs API migration');\n }\n if (!syncStateRootMatches(repoRoot, state.root)) drift.push('sync state belongs to a different repository');\n const recorded = state.selection;\n if (\n recorded.majorMode !== selection.majorMode ||\n recorded.profile !== selection.profile ||\n recorded.preset !== selection.preset ||\n recorded.domains.join(',') !== selection.domains.join(',')\n ) {\n drift.push('selection changed since the last sync');\n }\n // Hash the recorded selection so selection changes are not counted twice.\n if (computeInputsHash(repoRoot, recorded, environment.HOME ?? os.homedir(), environment) !== state.inputsHash) {\n drift.push('.doom configuration changed');\n }\n if (\n JSON.stringify(\n recordResolvedEntries(\n loadMajorModesConfig(repoRoot, environment.HOME ?? os.homedir(), environment),\n createLayerResolvers(repoRoot),\n ),\n ) !== JSON.stringify(state.resolved)\n ) {\n drift.push('resolved extension paths changed');\n }\n if (expectedCompositionFingerprint && state.compositionFingerprint !== expectedCompositionFingerprint) {\n drift.push('extension composition changed');\n }\n try {\n if (!readBootstrapStatus(repoRoot, undefined, environment.HOME ?? os.homedir()).fresh) {\n drift.push('precompiled runtime is missing or stale');\n }\n } catch {\n drift.push('precompiled runtime is missing or stale');\n }\n\n if (settingsMode === 'persisted') {\n const agentDirectory = piAgentDirectory(environment);\n const themePath = path.join(piThemeDirectory(agentDirectory), `${DEFAULT_THEME_NAME}.json`);\n drift.push(...piIntegrationDrift(agentDirectory));\n if (projectRegistersDoom(repoRoot)) drift.push(DUPLICATE_REGISTRATION_DRIFT);\n if (state.baseline.themePath !== themePath || state.baseline.themeName !== DEFAULT_THEME_NAME) {\n drift.push('synced theme location is out of date');\n }\n }\n const sharedDrift = readSyncDrift({ repoRoot, environment, homeDirectory: environment.HOME ?? os.homedir() });\n const sharedMessages: Partial<Record<SyncDriftReason, string>> = {\n 'never-synced': 'sync registration is missing or invalid',\n 'runtime-stale': 'precompiled runtime or hook modules are missing or stale',\n 'code-changed': 'cockpit sources changed since the last sync',\n 'cockpit-bundle-missing': 'cockpit bundle is missing',\n 'package-apis-missing': 'package API routes are missing',\n 'server-bundle-stale': 'server bundle is missing or stale',\n 'mcp-bundle-stale': 'MCP bundle is missing or stale',\n };\n for (const reason of sharedDrift.reasons) {\n const message = sharedMessages[reason];\n if (message) drift.push(message);\n }\n return drift;\n}\n\n/** Returns true when a valid legacy registration must be republished with API metadata. */\nexport function syncRegistrationNeedsApiMigration(repoRoot: string, homeDirectory: string): boolean {\n try {\n const registration = readSyncRegistration(repoRoot, homeDirectory);\n return (\n registration !== undefined &&\n (registration.version !== SYNC_REGISTRATION_VERSION || registration.package.apiVersion === undefined)\n );\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsCA,SAAgB,qBACd,UACA,aACA,eACmB;CACnB,MAAM,EAAE,cAAc,sBAAsB,UAAU,aAAa,CAAC,CAAC;CACrE,IAAI,CAAC,WAAW,OAAO;CACvB,OAAO;EACL,GAAG;EACH,GAAI,UAAU,aAAa,CAAC,YAAA,uBACxB,GAAG,wBAAwB,UAAU,UAAU,IAC/C,CAAC;EACL,GAAI,UAAU,WAAW,CAAC,YAAA,oBAAkC,GAAG,qBAAqB,UAAU,QAAQ,IAAI,CAAC;EAC3G,GAAI,UAAU,WAAW,YAAA,sBAAoC,KAAA,IACzD,GAAG,qBAAqB,UAAU,QAAQ,KAAK,GAAG,EAAE,IACpD,CAAC;CACP;AACF;AAEA,SAAgB,YACd,SACe;CACf,OAAO;EACL,WAAW,QAAQ;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EAC/D,gBAAgB;EAChB,iBAAiB;EACjB,gBAAgB;EAChB,0BAA0B;EAC1B,wBAAwB;EACxB,uBAAuB;EACvB,oBAAoB;CACtB;CACA,KAAK,MAAM,UAAU,YAAY,SAAS;EACxC,MAAM,UAAU,eAAe;EAC/B,IAAI,SAAS,MAAM,KAAK,OAAO;CACjC;CACA,OAAO;AACT;;AAGA,SAAgB,kCAAkC,UAAkB,eAAgC;CAClG,IAAI;EACF,MAAM,eAAe,qBAAqB,UAAU,aAAa;EACjE,OACE,iBAAiB,KAAA,MAChB,aAAa,YAAY,6BAA6B,aAAa,QAAQ,eAAe,KAAA;CAE/F,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -754,6 +754,19 @@ function setExternalResolver(inputs, kind, entry, resources = []) {
|
|
|
754
754
|
return null;
|
|
755
755
|
}
|
|
756
756
|
if (specifier.startsWith("./index")) return null;
|
|
757
|
+
if (specifier === "@agimon-ai/doompi-hook/authoring") {
|
|
758
|
+
const resolved = await this.resolve(specifier, importer, options);
|
|
759
|
+
if (resolved) return {
|
|
760
|
+
id: resolved.id,
|
|
761
|
+
external: false
|
|
762
|
+
};
|
|
763
|
+
const installed = (0, _agimon_ai_doompi_core_moduleResolution.optionalPackageEntry)(specifier, require("url").pathToFileURL(__filename).href);
|
|
764
|
+
if (installed) return {
|
|
765
|
+
id: installed,
|
|
766
|
+
external: false
|
|
767
|
+
};
|
|
768
|
+
return null;
|
|
769
|
+
}
|
|
757
770
|
const renamed = renameScope(specifier);
|
|
758
771
|
const root = packageRootOf(renamed);
|
|
759
772
|
if (root && HOSTED_PACKAGES.has(root)) {
|