@agimon-ai/doompi 0.0.1-alpha.66 → 0.0.1-alpha.68

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.
@@ -1,2 +1,2 @@
1
- const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("./syncLocation.cjs"),n=require("./modules/moduleResolution.cjs"),r=require("../services/extensionAssembler.cjs"),i=require("./telemetry/logSinkTelemetry.cjs");require("./config/harnessState.cjs");let a=require("node:path");a=e.__toESM(a,1);let o=require("node:fs");o=e.__toESM(o,1);let s=require("node:os");s=e.__toESM(s,1);let c=require("@agimon-ai/doompi-config/config"),l=require("@agimon-ai/doompi-config/domains"),u=require("@agimon-ai/doompi-config/profiles"),d=require("@agimon-ai/doompi-config/majorModes"),f=require("@agimon-ai/doompi-domain/mcp"),p=require("@agimon-ai/doompi-domain/plugins"),m=require("@agimon-ai/doompi-domain/resources"),h=require("@agimon-ai/doompi-ui/theme"),g=require("@agimon-ai/doompi-extension-contracts/cordis-host"),_=require("@agimon-ai/doompi-extension-contracts/mcp-session"),v=require("@agimon-ai/doompi-config/harnessStore");const y=`ollama`,b=`resolve_config`,x=`collect_resources`;function S(e,t){if(e.preset===`kimi`&&(!t.KIMI_API_KEY&&t.KIMI_CODE_API_KEY&&(t.KIMI_API_KEY=t.KIMI_CODE_API_KEY),!t.KIMI_API_KEY))throw Error(`KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset`);if(e.preset===y){if((e.piArgs.find(e=>e.startsWith(`${y}/`))?.endsWith(`:cloud`)??!1)&&!t.OLLAMA_API_KEY)throw Error(`OLLAMA_API_KEY is required for Ollama cloud models`);t.OLLAMA_API_KEY||=y,t.DOOMPI_OLLAMA_BASE_URL=t.OLLAMA_BASE_URL??t.ANTHROPIC_BASE_URL??`http://localhost:11434/v1`}}function C(e){return e.profile?(0,u.resolveProfile)(e.repoRoot,e.profile):void 0}async function w(e,y=i.createHarnessTelemetry()){let w=await y.runInSpan(`doom_pi.${b}`,{"harness.phase":b},async()=>{let t=(0,d.loadMajorModesConfig)(e.repoRoot,e.homeDirectory),n=(0,d.filterHookDisabledLayers)(t,(0,d.resolveLayers)(t,e.majorMode),e.hooks),r=C(e);if(!o.default.existsSync(e.cwd)||!o.default.statSync(e.cwd).isDirectory())throw Error(`Working directory does not exist: ${e.cwd}`);return{majorModesConfig:t,selectedLayers:n,hookGroups:(0,d.layerHookGroups)(t,n),profile:r,plugins:await(0,p.materializePluginEntries)((0,l.resolvePluginEntries)(e.repoRoot,e.domains,e.pluginDirectories)),mcpAllowlist:(0,f.resolveMcpAllowlist)(e.repoRoot,e.domains),sharedSkills:(0,l.resolveSharedSkills)(e.repoRoot,e.domains)}}).catch(async t=>{throw await y.recordError(i.HARNESS_EVENT.configLoadFailed,t,{"harness.phase":b,"harness.major_mode":e.majorMode,"harness.domain_count":e.domains.length}),t}),{majorModesConfig:T,selectedLayers:E,hookGroups:D,profile:O,plugins:k,mcpAllowlist:A}=w,j=O?.persona,M=O?.personaRoot??e.repoRoot,N=await y.runInSpan(`doom_pi.${x}`,{"harness.plugin.count":k.length,"harness.agents":e.agents,"harness.mcp":e.mcp},()=>(0,m.collectResources)(e.repoRoot,k,{agents:e.agents,mcp:e.mcp,temporaryDirectory:e.resourceDirectory,skillCacheDirectory:a.default.join(e.resourceDirectory??t.resolveSyncLocation(e.repoRoot,e.homeDirectory??s.default.homedir()).directory,`cache`,`skills`),mcpAllowlist:A,sharedSkills:w.sharedSkills,pluginDataRoot:a.default.join((0,c.globalDoomConfigDirectory)(e.homeDirectory??s.default.homedir()),`plugin-data`)})).catch(async e=>{throw await y.recordError(i.HARNESS_EVENT.resourceCollectionFailed,e,{"harness.phase":x,"harness.plugin.count":k.length}),e});try{let t=await(0,h.writeDefaultTheme)(N.temporaryDirectory),i={...process.env};delete i[_.DOOM_MCP_SESSION_ENV_VAR];let s=(0,u.applyProfileEnvironment)(i,O?.env??{});S(e,i),i.NX_DAEMON??=`false`,i[g.DOOM_CORDIS_HOST_REQUIRED_ENV]=`1`,i.DOOMPI_THEME||=h.DEFAULT_THEME_NAME,i.CLAUDE_PROJECT_DIR=e.repoRoot,i.CODEX_REPO_ROOT=e.repoRoot,i.ORIGINAL_REPO_PATH||=e.repoRoot,i.MCP_UI_VIEWER=e.automation?`none`:i.MCP_UI_VIEWER??``;let c=n.packageEntry(r.PERSONA_ENTRY),l=j?(0,u.buildPersonaPrompt)(M,j):void 0,d;return l&&(d=a.default.join(N.temporaryDirectory,`persona.md`),await o.default.promises.writeFile(d,`${l}\n`,{mode:384})),(0,v.createHarnessSession)({root:e.repoRoot,majorMode:e.majorMode,temporaryDirectory:N.temporaryDirectory,domains:e.domains,layers:E,profile:O?.name,profileEnvironment:s,personaFile:d,skillDirectories:N.skillDirectories,agentDirectories:N.agentDirectories,additionalDirectories:e.additionalDirectories,childExtensions:[],pluginDirectories:e.pluginDirectories,pluginHooks:N.pluginHooks,hookGroups:D,hooks:e.hooks,agents:e.agents,mcp:e.mcp,mcpConfigPath:N.mcpConfigPath,mcpProjection:N.mcpProjection,allowProtectedWrites:e.allowProtectedWrites},{directory:N.temporaryDirectory,environment:i}),e.agents&&(i.PI_SUBAGENT_EXTRA_AGENT_DIRS=N.agentDirectories.join(a.default.delimiter),i.PI_SUBAGENT_EXTRA_SKILL_DIRS=N.skillDirectories.join(a.default.delimiter),i.PI_SUBAGENT_PI_BINARY=a.default.join(e.repoRoot,`pi.sh`)),{options:e,environment:i,resources:N,plugins:k,profile:O?.name,personaDirectory:j,personaRoot:M,mcpAllowlist:A,majorModesConfig:T,selectedLayers:E,hookGroups:D,personaEntry:c,defaultThemePath:t,cleanup:N.cleanup.bind(N)}}catch(t){throw await y.recordError(i.HARNESS_EVENT.contextBuildFailed,t,{"harness.phase":`build_context`,"harness.major_mode":e.majorMode,...O?.name?{"harness.profile":O.name}:{}}),await N.cleanup(),t}}exports.buildHarnessContext=w,exports.configurePreset=S,exports.resolveHarnessProfile=C;
1
+ const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("./syncLocation.cjs"),n=require("./modules/moduleResolution.cjs"),r=require("../services/extensionAssembler.cjs"),i=require("./telemetry/logSinkTelemetry.cjs");require("./config/harnessState.cjs");let a=require("node:path");a=e.__toESM(a,1);let o=require("node:fs");o=e.__toESM(o,1);let s=require("node:os");s=e.__toESM(s,1);let c=require("@agimon-ai/doompi-config/config"),l=require("@agimon-ai/doompi-config/domains"),u=require("@agimon-ai/doompi-config/profiles"),d=require("@agimon-ai/doompi-config/majorModes"),f=require("@agimon-ai/doompi-domain/mcp"),p=require("@agimon-ai/doompi-domain/plugins"),m=require("@agimon-ai/doompi-domain/resources"),h=require("@agimon-ai/doompi-ui/theme"),g=require("@agimon-ai/doompi-extension-contracts/cordis-host"),_=require("@agimon-ai/doompi-extension-contracts/mcp-session"),v=require("@agimon-ai/doompi-config/harnessStore");const y=`ollama`,b=`resolve_config`,x=`collect_resources`;function S(e,t){if(e.preset===`kimi`&&(!t.KIMI_API_KEY&&t.KIMI_CODE_API_KEY&&(t.KIMI_API_KEY=t.KIMI_CODE_API_KEY),!t.KIMI_API_KEY))throw Error(`KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset`);if(e.preset===y){if((e.piArgs.find(e=>e.startsWith(`${y}/`))?.endsWith(`:cloud`)??!1)&&!t.OLLAMA_API_KEY)throw Error(`OLLAMA_API_KEY is required for Ollama cloud models`);t.OLLAMA_API_KEY||=y,t.DOOMPI_OLLAMA_BASE_URL=t.OLLAMA_BASE_URL??t.ANTHROPIC_BASE_URL??`http://localhost:11434/v1`}}function C(e){return e.profile?(0,u.resolveProfile)(e.repoRoot,e.profile):void 0}async function w(e,y=i.createHarnessTelemetry()){let w=await y.runInSpan(`doom_pi.${b}`,{"harness.phase":b},async()=>{let t=(0,d.loadMajorModesConfig)(e.repoRoot,e.homeDirectory),n=(0,d.filterHookDisabledLayers)(t,(0,d.resolveLayers)(t,e.majorMode),e.hooks),r=C(e);if(!o.default.existsSync(e.cwd)||!o.default.statSync(e.cwd).isDirectory())throw Error(`Working directory does not exist: ${e.cwd}`);return{majorModesConfig:t,selectedLayers:n,hookGroups:(0,d.layerHookGroups)(t,n),profile:r,plugins:await(0,p.materializePluginEntries)((0,l.resolvePluginEntries)(e.repoRoot,e.domains,e.pluginDirectories)),mcpAllowlist:(0,f.resolveMcpAllowlist)(e.repoRoot,e.domains),sharedSkills:(0,l.resolveSharedSkills)(e.repoRoot,e.domains)}}).catch(async t=>{throw await y.recordError(i.HARNESS_EVENT.configLoadFailed,t,{"harness.phase":b,"harness.major_mode":e.majorMode,"harness.domain_count":e.domains.length}),t}),{majorModesConfig:T,selectedLayers:E,hookGroups:D,profile:O,plugins:k,mcpAllowlist:A}=w,j=O?.persona,M=O?.personaRoot??e.repoRoot,N=await y.runInSpan(`doom_pi.${x}`,{"harness.plugin.count":k.length,"harness.agents":e.agents,"harness.mcp":e.mcp},()=>(0,m.collectResources)(e.repoRoot,k,{agents:e.agents,mcp:e.mcp,temporaryDirectory:e.resourceDirectory,skillCacheDirectory:a.default.join(e.resourceDirectory??t.resolveSyncLocation(e.repoRoot,e.homeDirectory??s.default.homedir()).directory,`cache`,`skills`),mcpAllowlist:A,sharedSkills:w.sharedSkills,pluginDataRoot:a.default.join((0,c.globalDoomConfigDirectory)(e.homeDirectory??s.default.homedir()),`plugin-data`)})).catch(async e=>{throw await y.recordError(i.HARNESS_EVENT.resourceCollectionFailed,e,{"harness.phase":x,"harness.plugin.count":k.length}),e});try{let t=await(0,h.writeDefaultTheme)(N.temporaryDirectory),i={...process.env};delete i[_.DOOM_MCP_SESSION_ENV_VAR];let s=(0,u.applyProfileEnvironment)(i,O?.env??{});S(e,i),i.NX_DAEMON??=`false`,i[g.DOOM_CORDIS_HOST_REQUIRED_ENV]=`1`,i.DOOMPI_THEME||=h.DEFAULT_THEME_NAME,i.CLAUDE_PROJECT_DIR=e.repoRoot,i.CODEX_REPO_ROOT=e.repoRoot,i.ORIGINAL_REPO_PATH||=e.repoRoot,i.MCP_UI_VIEWER=e.automation?`none`:i.MCP_UI_VIEWER??``;let c=n.packageEntry(r.PERSONA_ENTRY),l=j?(0,u.buildPersonaPrompt)(M,j):void 0,d;return l&&(d=a.default.join(N.temporaryDirectory,`persona.md`),await o.default.promises.writeFile(d,`${l}\n`,{mode:384})),(0,v.createHarnessSession)({root:e.repoRoot,majorMode:e.majorMode,temporaryDirectory:N.temporaryDirectory,domains:e.domains,layers:E,profile:O?.name,profileIdentity:O?.identity,profileVoice:O?.voice,profileEnvironment:s,personaFile:d,skillDirectories:N.skillDirectories,agentDirectories:N.agentDirectories,additionalDirectories:e.additionalDirectories,childExtensions:[],pluginDirectories:e.pluginDirectories,pluginHooks:N.pluginHooks,hookGroups:D,hooks:e.hooks,agents:e.agents,mcp:e.mcp,mcpConfigPath:N.mcpConfigPath,mcpProjection:N.mcpProjection,allowProtectedWrites:e.allowProtectedWrites},{directory:N.temporaryDirectory,environment:i}),e.agents&&(i.PI_SUBAGENT_EXTRA_AGENT_DIRS=N.agentDirectories.join(a.default.delimiter),i.PI_SUBAGENT_EXTRA_SKILL_DIRS=N.skillDirectories.join(a.default.delimiter),i.PI_SUBAGENT_PI_BINARY=a.default.join(e.repoRoot,`pi.sh`)),{options:e,environment:i,resources:N,plugins:k,profile:O?.name,personaDirectory:j,personaRoot:M,mcpAllowlist:A,majorModesConfig:T,selectedLayers:E,hookGroups:D,personaEntry:c,defaultThemePath:t,cleanup:N.cleanup.bind(N)}}catch(t){throw await y.recordError(i.HARNESS_EVENT.contextBuildFailed,t,{"harness.phase":`build_context`,"harness.major_mode":e.majorMode,...O?.name?{"harness.profile":O.name}:{}}),await N.cleanup(),t}}exports.buildHarnessContext=w,exports.configurePreset=S,exports.resolveHarnessProfile=C;
2
2
  //# sourceMappingURL=harnessContext.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harnessContext.cjs","names":["resolveProfile","createHarnessTelemetry","loadMajorModesConfig","filterHookDisabledLayers","resolveLayers","fs","layerHookGroups","materializePluginEntries","resolvePluginEntries","resolveMcpAllowlist","resolveSharedSkills","HARNESS_EVENT","collectResources","path","resolveSyncLocation","os","globalDoomConfigDirectory","writeDefaultTheme","DOOM_MCP_SESSION_ENV_VAR","applyProfileEnvironment","DOOM_CORDIS_HOST_REQUIRED_ENV","DEFAULT_THEME_NAME","packageEntry","PERSONA_ENTRY","buildPersonaPrompt"],"sources":["../../../src/adapters/harnessContext.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { globalDoomConfigDirectory } from '@agimon-ai/doompi-config/config';\nimport { resolveMcpAllowlist } from '@agimon-ai/doompi-domain/mcp';\nimport { materializePluginEntries } from '@agimon-ai/doompi-domain/plugins';\nimport { collectResources, type HarnessResources } from '@agimon-ai/doompi-domain/resources';\nimport {\n createHarnessTelemetry,\n HARNESS_EVENT,\n type HarnessTelemetry,\n} from '../adapters/telemetry/logSinkTelemetry.ts';\nimport { resolvePluginEntries, resolveSharedSkills } from '@agimon-ai/doompi-config/domains';\nimport type { DomainMcpAllowlist, PluginEntry } from '@agimon-ai/doompi-config/domains';\nimport {\n filterHookDisabledLayers,\n layerHookGroups,\n loadMajorModesConfig,\n resolveLayers,\n} from '@agimon-ai/doompi-config/majorModes';\nimport type { MajorModesConfig } from '@agimon-ai/doompi-config/majorModes';\nimport { applyProfileEnvironment, buildPersonaPrompt, resolveProfile } from '@agimon-ai/doompi-config/profiles';\nimport type { AgentProfile } from '@agimon-ai/doompi-config/profiles';\nimport { DOOM_CORDIS_HOST_REQUIRED_ENV } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_MCP_SESSION_ENV_VAR } from '@agimon-ai/doompi-extension-contracts/mcp-session';\nimport { DEFAULT_THEME_NAME, writeDefaultTheme } from '@agimon-ai/doompi-ui/theme';\nimport { createHarnessSession } from './config/harnessState';\nimport { PERSONA_ENTRY } from '../services/extensionAssembler.ts';\nimport type { HarnessOptions } from '../types/interfaces/harness';\nimport { packageEntry } from './modules/moduleResolution';\nimport { resolveSyncLocation } from './syncLocation.ts';\n\nconst OLLAMA_PRESET = 'ollama';\nconst PRIVATE_FILE_MODE = 0o600;\nconst RESOLVE_CONFIG_PHASE = 'resolve_config';\nconst COLLECT_RESOURCES_PHASE = 'collect_resources';\nconst BUILD_CONTEXT_PHASE = 'build_context';\n\n/**\n * Everything a command needs, resolved once.\n *\n * All three commands need the same expensive preparation (domains resolved,\n * plugins collected into a temp directory, environment assembled), so it is\n * built here and handed to whichever command runs.\n */\nexport interface HarnessContext {\n options: HarnessOptions;\n environment: NodeJS.ProcessEnv;\n resources: HarnessResources;\n plugins: PluginEntry[];\n profile?: string;\n personaDirectory?: string;\n /** Root personaDirectory resolves against, when a profile supplied one. */\n personaRoot?: string;\n mcpAllowlist?: DomainMcpAllowlist;\n majorModesConfig: MajorModesConfig;\n selectedLayers: string[];\n hookGroups: string[];\n personaEntry?: string;\n defaultThemePath: string;\n cleanup(): Promise<void>;\n}\n\n/**\n * Applies the provider environment a preset needs.\n *\n * Exported because the synced Pi path has no launcher to do it: the doom-pi\n * extension applies the same rules in-process before anything reads them.\n * `piArgs` is only consulted to spot a selected cloud model.\n */\nexport function configurePreset(\n options: Pick<HarnessOptions, 'preset' | 'piArgs'>,\n environment: NodeJS.ProcessEnv,\n): void {\n if (options.preset === 'kimi') {\n if (!environment.KIMI_API_KEY && environment.KIMI_CODE_API_KEY) {\n environment.KIMI_API_KEY = environment.KIMI_CODE_API_KEY;\n }\n if (!environment.KIMI_API_KEY) {\n throw new Error('KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset');\n }\n }\n if (options.preset === OLLAMA_PRESET) {\n const selected = options.piArgs.find((argument) => argument.startsWith(`${OLLAMA_PRESET}/`));\n const cloud = selected?.endsWith(':cloud') ?? false;\n if (cloud && !environment.OLLAMA_API_KEY) {\n throw new Error('OLLAMA_API_KEY is required for Ollama cloud models');\n }\n environment.OLLAMA_API_KEY ||= OLLAMA_PRESET;\n environment.DOOMPI_OLLAMA_BASE_URL =\n environment.OLLAMA_BASE_URL ?? environment.ANTHROPIC_BASE_URL ?? 'http://localhost:11434/v1';\n }\n}\n\n/** Resolves the optional persona and environment profile selected for this run. */\nexport function resolveHarnessProfile(options: HarnessOptions): AgentProfile | undefined {\n return options.profile ? resolveProfile(options.repoRoot, options.profile) : undefined;\n}\n\n/**\n * Resolves the full matrix and stages every resource Pi will need.\n *\n * The caller owns the returned cleanup(): the temporary directory holding\n * skills, agents, and the generated MCP config has to outlive this function\n * and be removed once the selected command is done with it.\n */\nexport async function buildHarnessContext(\n options: HarnessOptions,\n telemetry: HarnessTelemetry = createHarnessTelemetry(),\n): Promise<HarnessContext> {\n // Everything up to collectResources reads configuration off disk, so a single\n // malformed modes.yaml or profiles.yaml surfaces here as a failed launch\n // with no other record.\n const configured = await telemetry\n .runInSpan(`doom_pi.${RESOLVE_CONFIG_PHASE}`, { 'harness.phase': RESOLVE_CONFIG_PHASE }, async () => {\n const majorModesConfig = loadMajorModesConfig(options.repoRoot, options.homeDirectory);\n const selectedLayers = filterHookDisabledLayers(\n majorModesConfig,\n resolveLayers(majorModesConfig, options.majorMode),\n options.hooks,\n );\n const profile = resolveHarnessProfile(options);\n if (!fs.existsSync(options.cwd) || !fs.statSync(options.cwd).isDirectory()) {\n throw new Error(`Working directory does not exist: ${options.cwd}`);\n }\n return {\n majorModesConfig,\n selectedLayers,\n hookGroups: layerHookGroups(majorModesConfig, selectedLayers),\n profile,\n plugins: await materializePluginEntries(\n resolvePluginEntries(options.repoRoot, options.domains, options.pluginDirectories),\n ),\n mcpAllowlist: resolveMcpAllowlist(options.repoRoot, options.domains),\n sharedSkills: resolveSharedSkills(options.repoRoot, options.domains),\n };\n })\n .catch(async (error: unknown) => {\n await telemetry.recordError(HARNESS_EVENT.configLoadFailed, error, {\n 'harness.phase': RESOLVE_CONFIG_PHASE,\n 'harness.major_mode': options.majorMode,\n 'harness.domain_count': options.domains.length,\n });\n throw error;\n });\n\n const { majorModesConfig, selectedLayers, hookGroups, profile, plugins, mcpAllowlist } = configured;\n const personaDirectory = profile?.persona;\n // A global profile's persona lives beside the global config, not in the repo.\n const personaRoot = profile?.personaRoot ?? options.repoRoot;\n const resources = await telemetry\n .runInSpan(\n `doom_pi.${COLLECT_RESOURCES_PHASE}`,\n { 'harness.plugin.count': plugins.length, 'harness.agents': options.agents, 'harness.mcp': options.mcp },\n () =>\n collectResources(options.repoRoot, plugins, {\n agents: options.agents,\n mcp: options.mcp,\n // Set by `doom-pi sync`, which stages into a directory that outlives\n // the process rather than a temporary one.\n temporaryDirectory: options.resourceDirectory,\n skillCacheDirectory: path.join(\n options.resourceDirectory ??\n resolveSyncLocation(options.repoRoot, options.homeDirectory ?? os.homedir()).directory,\n 'cache',\n 'skills',\n ),\n mcpAllowlist,\n sharedSkills: configured.sharedSkills,\n pluginDataRoot: path.join(globalDoomConfigDirectory(options.homeDirectory ?? os.homedir()), 'plugin-data'),\n }),\n )\n .catch(async (error: unknown) => {\n // Conflicting skills, agents, or MCP servers all fail here, and the plugin\n // that caused it is only identifiable from the message.\n await telemetry.recordError(HARNESS_EVENT.resourceCollectionFailed, error, {\n 'harness.phase': COLLECT_RESOURCES_PHASE,\n 'harness.plugin.count': plugins.length,\n });\n throw error;\n });\n\n try {\n const defaultThemePath = await writeDefaultTheme(resources.temporaryDirectory);\n const environment = { ...process.env };\n // The file-backed projection published through Cordis is authoritative.\n // Never let a legacy parent-process projection leak into this Doom session.\n delete environment[DOOM_MCP_SESSION_ENV_VAR];\n const profileEnvironment = applyProfileEnvironment(environment, profile?.env ?? {});\n\n configurePreset(options, environment);\n environment.NX_DAEMON ??= 'false';\n environment[DOOM_CORDIS_HOST_REQUIRED_ENV] = '1';\n environment.DOOMPI_THEME ||= DEFAULT_THEME_NAME;\n environment.CLAUDE_PROJECT_DIR = options.repoRoot;\n environment.CODEX_REPO_ROOT = options.repoRoot;\n environment.ORIGINAL_REPO_PATH ||= options.repoRoot;\n environment.MCP_UI_VIEWER = options.automation ? 'none' : (environment.MCP_UI_VIEWER ?? '');\n\n // Always loaded, even with no persona at launch: the extension no-ops\n // without a persona file, and /profile needs it present to load one later.\n // Pi freezes the --extension list at startup, so it cannot be added on demand.\n const personaEntry = packageEntry(PERSONA_ENTRY);\n const personaPrompt = personaDirectory ? buildPersonaPrompt(personaRoot, personaDirectory) : undefined;\n let personaFile: string | undefined;\n if (personaPrompt) {\n personaFile = path.join(resources.temporaryDirectory, 'persona.md');\n await fs.promises.writeFile(personaFile, `${personaPrompt}\\n`, { mode: PRIVATE_FILE_MODE });\n }\n\n // One write, describing the child rather than this process. The state file\n // is the child's authority and the environment is what it projects for the\n // hooks and packages that can only read an environment.\n createHarnessSession(\n {\n root: options.repoRoot,\n majorMode: options.majorMode,\n temporaryDirectory: resources.temporaryDirectory,\n domains: options.domains,\n layers: selectedLayers,\n profile: profile?.name,\n profileEnvironment,\n personaFile,\n skillDirectories: resources.skillDirectories,\n agentDirectories: resources.agentDirectories,\n additionalDirectories: options.additionalDirectories,\n childExtensions: [],\n pluginDirectories: options.pluginDirectories,\n pluginHooks: resources.pluginHooks,\n hookGroups,\n hooks: options.hooks,\n agents: options.agents,\n mcp: options.mcp,\n mcpConfigPath: resources.mcpConfigPath,\n mcpProjection: resources.mcpProjection,\n allowProtectedWrites: options.allowProtectedWrites,\n },\n { directory: resources.temporaryDirectory, environment },\n );\n if (options.agents) {\n environment.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_PI_BINARY = path.join(options.repoRoot, 'pi.sh');\n }\n\n // Core hook groups load regardless; hookGroups selects the rest. The initial\n // state write includes an empty list deliberately: unset means every group.\n\n return {\n options,\n environment,\n resources,\n plugins,\n profile: profile?.name,\n personaDirectory,\n personaRoot,\n mcpAllowlist,\n majorModesConfig,\n selectedLayers,\n hookGroups,\n personaEntry,\n defaultThemePath,\n cleanup: resources.cleanup.bind(resources),\n };\n } catch (error) {\n // Preparation failed after the temp directory existed, so nothing will be\n // handed back to clean it up.\n await telemetry.recordError(HARNESS_EVENT.contextBuildFailed, error, {\n 'harness.phase': BUILD_CONTEXT_PHASE,\n 'harness.major_mode': options.majorMode,\n ...(profile?.name ? { 'harness.profile': profile.name } : {}),\n });\n await resources.cleanup();\n throw error;\n }\n}\n"],"mappings":"u6BAgCA,MAAM,EAAgB,SAEhB,EAAuB,iBACvB,EAA0B,oBAmChC,SAAgB,EACd,EACA,EACM,CACN,GAAI,EAAQ,SAAW,SACjB,CAAC,EAAY,cAAgB,EAAY,oBAC3C,EAAY,aAAe,EAAY,mBAErC,CAAC,EAAY,cACf,MAAU,MAAM,mEAAmE,EAGvF,GAAI,EAAQ,SAAW,EAAe,CAGpC,IAFiB,EAAQ,OAAO,KAAM,GAAa,EAAS,WAAW,GAAG,EAAc,EAAE,CACrE,CAAC,EAAE,SAAS,QAAQ,GAAK,KACjC,CAAC,EAAY,eACxB,MAAU,MAAM,oDAAoD,EAEtE,EAAY,iBAAmB,EAC/B,EAAY,uBACV,EAAY,iBAAmB,EAAY,oBAAsB,2BACrE,CACF,CAGA,SAAgB,EAAsB,EAAmD,CACvF,OAAO,EAAQ,SAAA,EAAUA,EAAAA,eAAAA,CAAe,EAAQ,SAAU,EAAQ,OAAO,EAAI,IAAA,EAC/E,CASA,eAAsB,EACpB,EACA,EAA8BC,EAAAA,uBAAuB,EAC5B,CAIzB,IAAM,EAAa,MAAM,EACtB,UAAU,WAAW,IAAwB,CAAE,gBAAiB,CAAqB,EAAG,SAAY,CACnG,IAAM,GAAA,EAAmBC,EAAAA,qBAAAA,CAAqB,EAAQ,SAAU,EAAQ,aAAa,EAC/E,GAAA,EAAiBC,EAAAA,yBAAAA,CACrB,GAAA,EACAC,EAAAA,cAAAA,CAAc,EAAkB,EAAQ,SAAS,EACjD,EAAQ,KACV,EACM,EAAU,EAAsB,CAAO,EAC7C,GAA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AC/B,gBAAiB,CAAC,EAClB,kBAAmB,EAAQ,kBAC3B,YAAa,EAAU,YACvB,aACA,MAAO,EAAQ,MACf,OAAQ,EAAQ,OAChB,IAAK,EAAQ,IACb,cAAe,EAAU,cACzB,cAAe,EAAU,cACzB,qBAAsB,EAAQ,oBAChC,EACA,CAAE,UAAW,EAAU,mBAAoB,aAAY,CACzD,EACI,EAAQ,SACV,EAAY,6BAA+B,EAAU,iBAAiB,KAAKQ,EAAAA,QAAK,SAAS,EACzF,EAAY,6BAA+B,EAAU,iBAAiB,KAAKA,EAAAA,QAAK,SAAS,EACzF,EAAY,sBAAwBA,EAAAA,QAAK,KAAK,EAAQ,SAAU,OAAO,GAMlE,CACL,UACA,cACA,YACA,UACA,QAAS,GAAS,KAClB,mBACA,cACA,eACA,mBACA,iBACA,aACA,eACA,mBACA,QAAS,EAAU,QAAQ,KAAK,CAAS,CAC3C,CACF,OAAS,EAAO,CASd,MANA,MAAM,EAAU,YAAYF,EAAAA,cAAc,mBAAoB,EAAO,CACnE,gBAAiB,gBACjB,qBAAsB,EAAQ,UAC9B,GAAI,GAAS,KAAO,CAAE,kBAAmB,EAAQ,IAAK,EAAI,CAAC,CAC7D,CAAC,EACD,MAAM,EAAU,QAAQ,EAClB,CACR,CACF"}
1
+ {"version":3,"file":"harnessContext.cjs","names":["resolveProfile","createHarnessTelemetry","loadMajorModesConfig","filterHookDisabledLayers","resolveLayers","fs","layerHookGroups","materializePluginEntries","resolvePluginEntries","resolveMcpAllowlist","resolveSharedSkills","HARNESS_EVENT","collectResources","path","resolveSyncLocation","os","globalDoomConfigDirectory","writeDefaultTheme","DOOM_MCP_SESSION_ENV_VAR","applyProfileEnvironment","DOOM_CORDIS_HOST_REQUIRED_ENV","DEFAULT_THEME_NAME","packageEntry","PERSONA_ENTRY","buildPersonaPrompt"],"sources":["../../../src/adapters/harnessContext.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { globalDoomConfigDirectory } from '@agimon-ai/doompi-config/config';\nimport { resolveMcpAllowlist } from '@agimon-ai/doompi-domain/mcp';\nimport { materializePluginEntries } from '@agimon-ai/doompi-domain/plugins';\nimport { collectResources, type HarnessResources } from '@agimon-ai/doompi-domain/resources';\nimport {\n createHarnessTelemetry,\n HARNESS_EVENT,\n type HarnessTelemetry,\n} from '../adapters/telemetry/logSinkTelemetry.ts';\nimport { resolvePluginEntries, resolveSharedSkills } from '@agimon-ai/doompi-config/domains';\nimport type { DomainMcpAllowlist, PluginEntry } from '@agimon-ai/doompi-config/domains';\nimport {\n filterHookDisabledLayers,\n layerHookGroups,\n loadMajorModesConfig,\n resolveLayers,\n} from '@agimon-ai/doompi-config/majorModes';\nimport type { MajorModesConfig } from '@agimon-ai/doompi-config/majorModes';\nimport { applyProfileEnvironment, buildPersonaPrompt, resolveProfile } from '@agimon-ai/doompi-config/profiles';\nimport type { AgentProfile } from '@agimon-ai/doompi-config/profiles';\nimport { DOOM_CORDIS_HOST_REQUIRED_ENV } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_MCP_SESSION_ENV_VAR } from '@agimon-ai/doompi-extension-contracts/mcp-session';\nimport { DEFAULT_THEME_NAME, writeDefaultTheme } from '@agimon-ai/doompi-ui/theme';\nimport { createHarnessSession } from './config/harnessState';\nimport { PERSONA_ENTRY } from '../services/extensionAssembler.ts';\nimport type { HarnessOptions } from '../types/interfaces/harness';\nimport { packageEntry } from './modules/moduleResolution';\nimport { resolveSyncLocation } from './syncLocation.ts';\n\nconst OLLAMA_PRESET = 'ollama';\nconst PRIVATE_FILE_MODE = 0o600;\nconst RESOLVE_CONFIG_PHASE = 'resolve_config';\nconst COLLECT_RESOURCES_PHASE = 'collect_resources';\nconst BUILD_CONTEXT_PHASE = 'build_context';\n\n/**\n * Everything a command needs, resolved once.\n *\n * All three commands need the same expensive preparation (domains resolved,\n * plugins collected into a temp directory, environment assembled), so it is\n * built here and handed to whichever command runs.\n */\nexport interface HarnessContext {\n options: HarnessOptions;\n environment: NodeJS.ProcessEnv;\n resources: HarnessResources;\n plugins: PluginEntry[];\n profile?: string;\n personaDirectory?: string;\n /** Root personaDirectory resolves against, when a profile supplied one. */\n personaRoot?: string;\n mcpAllowlist?: DomainMcpAllowlist;\n majorModesConfig: MajorModesConfig;\n selectedLayers: string[];\n hookGroups: string[];\n personaEntry?: string;\n defaultThemePath: string;\n cleanup(): Promise<void>;\n}\n\n/**\n * Applies the provider environment a preset needs.\n *\n * Exported because the synced Pi path has no launcher to do it: the doom-pi\n * extension applies the same rules in-process before anything reads them.\n * `piArgs` is only consulted to spot a selected cloud model.\n */\nexport function configurePreset(\n options: Pick<HarnessOptions, 'preset' | 'piArgs'>,\n environment: NodeJS.ProcessEnv,\n): void {\n if (options.preset === 'kimi') {\n if (!environment.KIMI_API_KEY && environment.KIMI_CODE_API_KEY) {\n environment.KIMI_API_KEY = environment.KIMI_CODE_API_KEY;\n }\n if (!environment.KIMI_API_KEY) {\n throw new Error('KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset');\n }\n }\n if (options.preset === OLLAMA_PRESET) {\n const selected = options.piArgs.find((argument) => argument.startsWith(`${OLLAMA_PRESET}/`));\n const cloud = selected?.endsWith(':cloud') ?? false;\n if (cloud && !environment.OLLAMA_API_KEY) {\n throw new Error('OLLAMA_API_KEY is required for Ollama cloud models');\n }\n environment.OLLAMA_API_KEY ||= OLLAMA_PRESET;\n environment.DOOMPI_OLLAMA_BASE_URL =\n environment.OLLAMA_BASE_URL ?? environment.ANTHROPIC_BASE_URL ?? 'http://localhost:11434/v1';\n }\n}\n\n/** Resolves the optional persona and environment profile selected for this run. */\nexport function resolveHarnessProfile(options: HarnessOptions): AgentProfile | undefined {\n return options.profile ? resolveProfile(options.repoRoot, options.profile) : undefined;\n}\n\n/**\n * Resolves the full matrix and stages every resource Pi will need.\n *\n * The caller owns the returned cleanup(): the temporary directory holding\n * skills, agents, and the generated MCP config has to outlive this function\n * and be removed once the selected command is done with it.\n */\nexport async function buildHarnessContext(\n options: HarnessOptions,\n telemetry: HarnessTelemetry = createHarnessTelemetry(),\n): Promise<HarnessContext> {\n // Everything up to collectResources reads configuration off disk, so a single\n // malformed modes.yaml or profiles.yaml surfaces here as a failed launch\n // with no other record.\n const configured = await telemetry\n .runInSpan(`doom_pi.${RESOLVE_CONFIG_PHASE}`, { 'harness.phase': RESOLVE_CONFIG_PHASE }, async () => {\n const majorModesConfig = loadMajorModesConfig(options.repoRoot, options.homeDirectory);\n const selectedLayers = filterHookDisabledLayers(\n majorModesConfig,\n resolveLayers(majorModesConfig, options.majorMode),\n options.hooks,\n );\n const profile = resolveHarnessProfile(options);\n if (!fs.existsSync(options.cwd) || !fs.statSync(options.cwd).isDirectory()) {\n throw new Error(`Working directory does not exist: ${options.cwd}`);\n }\n return {\n majorModesConfig,\n selectedLayers,\n hookGroups: layerHookGroups(majorModesConfig, selectedLayers),\n profile,\n plugins: await materializePluginEntries(\n resolvePluginEntries(options.repoRoot, options.domains, options.pluginDirectories),\n ),\n mcpAllowlist: resolveMcpAllowlist(options.repoRoot, options.domains),\n sharedSkills: resolveSharedSkills(options.repoRoot, options.domains),\n };\n })\n .catch(async (error: unknown) => {\n await telemetry.recordError(HARNESS_EVENT.configLoadFailed, error, {\n 'harness.phase': RESOLVE_CONFIG_PHASE,\n 'harness.major_mode': options.majorMode,\n 'harness.domain_count': options.domains.length,\n });\n throw error;\n });\n\n const { majorModesConfig, selectedLayers, hookGroups, profile, plugins, mcpAllowlist } = configured;\n const personaDirectory = profile?.persona;\n // A global profile's persona lives beside the global config, not in the repo.\n const personaRoot = profile?.personaRoot ?? options.repoRoot;\n const resources = await telemetry\n .runInSpan(\n `doom_pi.${COLLECT_RESOURCES_PHASE}`,\n { 'harness.plugin.count': plugins.length, 'harness.agents': options.agents, 'harness.mcp': options.mcp },\n () =>\n collectResources(options.repoRoot, plugins, {\n agents: options.agents,\n mcp: options.mcp,\n // Set by `doom-pi sync`, which stages into a directory that outlives\n // the process rather than a temporary one.\n temporaryDirectory: options.resourceDirectory,\n skillCacheDirectory: path.join(\n options.resourceDirectory ??\n resolveSyncLocation(options.repoRoot, options.homeDirectory ?? os.homedir()).directory,\n 'cache',\n 'skills',\n ),\n mcpAllowlist,\n sharedSkills: configured.sharedSkills,\n pluginDataRoot: path.join(globalDoomConfigDirectory(options.homeDirectory ?? os.homedir()), 'plugin-data'),\n }),\n )\n .catch(async (error: unknown) => {\n // Conflicting skills, agents, or MCP servers all fail here, and the plugin\n // that caused it is only identifiable from the message.\n await telemetry.recordError(HARNESS_EVENT.resourceCollectionFailed, error, {\n 'harness.phase': COLLECT_RESOURCES_PHASE,\n 'harness.plugin.count': plugins.length,\n });\n throw error;\n });\n\n try {\n const defaultThemePath = await writeDefaultTheme(resources.temporaryDirectory);\n const environment = { ...process.env };\n // The file-backed projection published through Cordis is authoritative.\n // Never let a legacy parent-process projection leak into this Doom session.\n delete environment[DOOM_MCP_SESSION_ENV_VAR];\n const profileEnvironment = applyProfileEnvironment(environment, profile?.env ?? {});\n\n configurePreset(options, environment);\n environment.NX_DAEMON ??= 'false';\n environment[DOOM_CORDIS_HOST_REQUIRED_ENV] = '1';\n environment.DOOMPI_THEME ||= DEFAULT_THEME_NAME;\n environment.CLAUDE_PROJECT_DIR = options.repoRoot;\n environment.CODEX_REPO_ROOT = options.repoRoot;\n environment.ORIGINAL_REPO_PATH ||= options.repoRoot;\n environment.MCP_UI_VIEWER = options.automation ? 'none' : (environment.MCP_UI_VIEWER ?? '');\n\n // Always loaded, even with no persona at launch: the extension no-ops\n // without a persona file, and /profile needs it present to load one later.\n // Pi freezes the --extension list at startup, so it cannot be added on demand.\n const personaEntry = packageEntry(PERSONA_ENTRY);\n const personaPrompt = personaDirectory ? buildPersonaPrompt(personaRoot, personaDirectory) : undefined;\n let personaFile: string | undefined;\n if (personaPrompt) {\n personaFile = path.join(resources.temporaryDirectory, 'persona.md');\n await fs.promises.writeFile(personaFile, `${personaPrompt}\\n`, { mode: PRIVATE_FILE_MODE });\n }\n\n // One write, describing the child rather than this process. The state file\n // is the child's authority and the environment is what it projects for the\n // hooks and packages that can only read an environment.\n createHarnessSession(\n {\n root: options.repoRoot,\n majorMode: options.majorMode,\n temporaryDirectory: resources.temporaryDirectory,\n domains: options.domains,\n layers: selectedLayers,\n profile: profile?.name,\n profileIdentity: profile?.identity,\n profileVoice: profile?.voice,\n profileEnvironment,\n personaFile,\n skillDirectories: resources.skillDirectories,\n agentDirectories: resources.agentDirectories,\n additionalDirectories: options.additionalDirectories,\n childExtensions: [],\n pluginDirectories: options.pluginDirectories,\n pluginHooks: resources.pluginHooks,\n hookGroups,\n hooks: options.hooks,\n agents: options.agents,\n mcp: options.mcp,\n mcpConfigPath: resources.mcpConfigPath,\n mcpProjection: resources.mcpProjection,\n allowProtectedWrites: options.allowProtectedWrites,\n },\n { directory: resources.temporaryDirectory, environment },\n );\n if (options.agents) {\n environment.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_PI_BINARY = path.join(options.repoRoot, 'pi.sh');\n }\n\n // Core hook groups load regardless; hookGroups selects the rest. The initial\n // state write includes an empty list deliberately: unset means every group.\n\n return {\n options,\n environment,\n resources,\n plugins,\n profile: profile?.name,\n personaDirectory,\n personaRoot,\n mcpAllowlist,\n majorModesConfig,\n selectedLayers,\n hookGroups,\n personaEntry,\n defaultThemePath,\n cleanup: resources.cleanup.bind(resources),\n };\n } catch (error) {\n // Preparation failed after the temp directory existed, so nothing will be\n // handed back to clean it up.\n await telemetry.recordError(HARNESS_EVENT.contextBuildFailed, error, {\n 'harness.phase': BUILD_CONTEXT_PHASE,\n 'harness.major_mode': options.majorMode,\n ...(profile?.name ? { 'harness.profile': profile.name } : {}),\n });\n await resources.cleanup();\n throw error;\n }\n}\n"],"mappings":"u6BAgCA,MAAM,EAAgB,SAEhB,EAAuB,i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U,iBAAiB,KAAKQ,EAAAA,QAAK,SAAS,EACzF,EAAY,6BAA+B,EAAU,iBAAiB,KAAKA,EAAAA,QAAK,SAAS,EACzF,EAAY,sBAAwBA,EAAAA,QAAK,KAAK,EAAQ,SAAU,OAAO,GAMlE,CACL,UACA,cACA,YACA,UACA,QAAS,GAAS,KAClB,mBACA,cACA,eACA,mBACA,iBACA,aACA,eACA,mBACA,QAAS,EAAU,QAAQ,KAAK,CAAS,CAC3C,CACF,OAAS,EAAO,CASd,MANA,MAAM,EAAU,YAAYF,EAAAA,cAAc,mBAAoB,EAAO,CACnE,gBAAiB,gBACjB,qBAAsB,EAAQ,UAC9B,GAAI,GAAS,KAAO,CAAE,kBAAmB,EAAQ,IAAK,EAAI,CAAC,CAC7D,CAAC,EACD,MAAM,EAAU,QAAQ,EAClB,CACR,CACF"}
@@ -1,2 +1,2 @@
1
- import{resolveSyncLocation as e}from"./syncLocation.mjs";import{packageEntry as t}from"./modules/moduleResolution.mjs";import{PERSONA_ENTRY as n}from"../services/extensionAssembler.mjs";import{HARNESS_EVENT as r,createHarnessTelemetry as i}from"./telemetry/logSinkTelemetry.mjs";import{createHarnessSession as a}from"./config/harnessState.mjs";import o from"node:path";import s from"node:fs";import c from"node:os";import{globalDoomConfigDirectory as l}from"@agimon-ai/doompi-config/config";import{resolvePluginEntries as u,resolveSharedSkills as d}from"@agimon-ai/doompi-config/domains";import{applyProfileEnvironment as f,buildPersonaPrompt as p,resolveProfile as m}from"@agimon-ai/doompi-config/profiles";import{filterHookDisabledLayers as h,layerHookGroups as g,loadMajorModesConfig as _,resolveLayers as v}from"@agimon-ai/doompi-config/majorModes";import{resolveMcpAllowlist as y}from"@agimon-ai/doompi-domain/mcp";import{materializePluginEntries as b}from"@agimon-ai/doompi-domain/plugins";import{collectResources as x}from"@agimon-ai/doompi-domain/resources";import{DEFAULT_THEME_NAME as S,writeDefaultTheme as C}from"@agimon-ai/doompi-ui/theme";import{DOOM_CORDIS_HOST_REQUIRED_ENV as w}from"@agimon-ai/doompi-extension-contracts/cordis-host";import{DOOM_MCP_SESSION_ENV_VAR as T}from"@agimon-ai/doompi-extension-contracts/mcp-session";const E=`ollama`,D=`resolve_config`,O=`collect_resources`;function k(e,t){if(e.preset===`kimi`&&(!t.KIMI_API_KEY&&t.KIMI_CODE_API_KEY&&(t.KIMI_API_KEY=t.KIMI_CODE_API_KEY),!t.KIMI_API_KEY))throw Error(`KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset`);if(e.preset===E){if((e.piArgs.find(e=>e.startsWith(`${E}/`))?.endsWith(`:cloud`)??!1)&&!t.OLLAMA_API_KEY)throw Error(`OLLAMA_API_KEY is required for Ollama cloud models`);t.OLLAMA_API_KEY||=E,t.DOOMPI_OLLAMA_BASE_URL=t.OLLAMA_BASE_URL??t.ANTHROPIC_BASE_URL??`http://localhost:11434/v1`}}function A(e){return e.profile?m(e.repoRoot,e.profile):void 0}async function j(m,E=i()){let j=await E.runInSpan(`doom_pi.${D}`,{"harness.phase":D},async()=>{let e=_(m.repoRoot,m.homeDirectory),t=h(e,v(e,m.majorMode),m.hooks),n=A(m);if(!s.existsSync(m.cwd)||!s.statSync(m.cwd).isDirectory())throw Error(`Working directory does not exist: ${m.cwd}`);return{majorModesConfig:e,selectedLayers:t,hookGroups:g(e,t),profile:n,plugins:await b(u(m.repoRoot,m.domains,m.pluginDirectories)),mcpAllowlist:y(m.repoRoot,m.domains),sharedSkills:d(m.repoRoot,m.domains)}}).catch(async e=>{throw await E.recordError(r.configLoadFailed,e,{"harness.phase":D,"harness.major_mode":m.majorMode,"harness.domain_count":m.domains.length}),e}),{majorModesConfig:M,selectedLayers:N,hookGroups:P,profile:F,plugins:I,mcpAllowlist:L}=j,R=F?.persona,z=F?.personaRoot??m.repoRoot,B=await E.runInSpan(`doom_pi.${O}`,{"harness.plugin.count":I.length,"harness.agents":m.agents,"harness.mcp":m.mcp},()=>x(m.repoRoot,I,{agents:m.agents,mcp:m.mcp,temporaryDirectory:m.resourceDirectory,skillCacheDirectory:o.join(m.resourceDirectory??e(m.repoRoot,m.homeDirectory??c.homedir()).directory,`cache`,`skills`),mcpAllowlist:L,sharedSkills:j.sharedSkills,pluginDataRoot:o.join(l(m.homeDirectory??c.homedir()),`plugin-data`)})).catch(async e=>{throw await E.recordError(r.resourceCollectionFailed,e,{"harness.phase":O,"harness.plugin.count":I.length}),e});try{let e=await C(B.temporaryDirectory),r={...process.env};delete r[T];let i=f(r,F?.env??{});k(m,r),r.NX_DAEMON??=`false`,r[w]=`1`,r.DOOMPI_THEME||=S,r.CLAUDE_PROJECT_DIR=m.repoRoot,r.CODEX_REPO_ROOT=m.repoRoot,r.ORIGINAL_REPO_PATH||=m.repoRoot,r.MCP_UI_VIEWER=m.automation?`none`:r.MCP_UI_VIEWER??``;let c=t(n),l=R?p(z,R):void 0,u;return l&&(u=o.join(B.temporaryDirectory,`persona.md`),await s.promises.writeFile(u,`${l}\n`,{mode:384})),a({root:m.repoRoot,majorMode:m.majorMode,temporaryDirectory:B.temporaryDirectory,domains:m.domains,layers:N,profile:F?.name,profileEnvironment:i,personaFile:u,skillDirectories:B.skillDirectories,agentDirectories:B.agentDirectories,additionalDirectories:m.additionalDirectories,childExtensions:[],pluginDirectories:m.pluginDirectories,pluginHooks:B.pluginHooks,hookGroups:P,hooks:m.hooks,agents:m.agents,mcp:m.mcp,mcpConfigPath:B.mcpConfigPath,mcpProjection:B.mcpProjection,allowProtectedWrites:m.allowProtectedWrites},{directory:B.temporaryDirectory,environment:r}),m.agents&&(r.PI_SUBAGENT_EXTRA_AGENT_DIRS=B.agentDirectories.join(o.delimiter),r.PI_SUBAGENT_EXTRA_SKILL_DIRS=B.skillDirectories.join(o.delimiter),r.PI_SUBAGENT_PI_BINARY=o.join(m.repoRoot,`pi.sh`)),{options:m,environment:r,resources:B,plugins:I,profile:F?.name,personaDirectory:R,personaRoot:z,mcpAllowlist:L,majorModesConfig:M,selectedLayers:N,hookGroups:P,personaEntry:c,defaultThemePath:e,cleanup:B.cleanup.bind(B)}}catch(e){throw await E.recordError(r.contextBuildFailed,e,{"harness.phase":`build_context`,"harness.major_mode":m.majorMode,...F?.name?{"harness.profile":F.name}:{}}),await B.cleanup(),e}}export{j as buildHarnessContext,k as configurePreset,A as resolveHarnessProfile};
1
+ import{resolveSyncLocation as e}from"./syncLocation.mjs";import{packageEntry as t}from"./modules/moduleResolution.mjs";import{PERSONA_ENTRY as n}from"../services/extensionAssembler.mjs";import{HARNESS_EVENT as r,createHarnessTelemetry as i}from"./telemetry/logSinkTelemetry.mjs";import{createHarnessSession as a}from"./config/harnessState.mjs";import o from"node:path";import s from"node:fs";import c from"node:os";import{globalDoomConfigDirectory as l}from"@agimon-ai/doompi-config/config";import{resolvePluginEntries as u,resolveSharedSkills as d}from"@agimon-ai/doompi-config/domains";import{applyProfileEnvironment as f,buildPersonaPrompt as p,resolveProfile as m}from"@agimon-ai/doompi-config/profiles";import{filterHookDisabledLayers as h,layerHookGroups as g,loadMajorModesConfig as _,resolveLayers as v}from"@agimon-ai/doompi-config/majorModes";import{resolveMcpAllowlist as y}from"@agimon-ai/doompi-domain/mcp";import{materializePluginEntries as b}from"@agimon-ai/doompi-domain/plugins";import{collectResources as x}from"@agimon-ai/doompi-domain/resources";import{DEFAULT_THEME_NAME as S,writeDefaultTheme as C}from"@agimon-ai/doompi-ui/theme";import{DOOM_CORDIS_HOST_REQUIRED_ENV as w}from"@agimon-ai/doompi-extension-contracts/cordis-host";import{DOOM_MCP_SESSION_ENV_VAR as T}from"@agimon-ai/doompi-extension-contracts/mcp-session";const E=`ollama`,D=`resolve_config`,O=`collect_resources`;function k(e,t){if(e.preset===`kimi`&&(!t.KIMI_API_KEY&&t.KIMI_CODE_API_KEY&&(t.KIMI_API_KEY=t.KIMI_CODE_API_KEY),!t.KIMI_API_KEY))throw Error(`KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset`);if(e.preset===E){if((e.piArgs.find(e=>e.startsWith(`${E}/`))?.endsWith(`:cloud`)??!1)&&!t.OLLAMA_API_KEY)throw Error(`OLLAMA_API_KEY is required for Ollama cloud models`);t.OLLAMA_API_KEY||=E,t.DOOMPI_OLLAMA_BASE_URL=t.OLLAMA_BASE_URL??t.ANTHROPIC_BASE_URL??`http://localhost:11434/v1`}}function A(e){return e.profile?m(e.repoRoot,e.profile):void 0}async function j(m,E=i()){let j=await E.runInSpan(`doom_pi.${D}`,{"harness.phase":D},async()=>{let e=_(m.repoRoot,m.homeDirectory),t=h(e,v(e,m.majorMode),m.hooks),n=A(m);if(!s.existsSync(m.cwd)||!s.statSync(m.cwd).isDirectory())throw Error(`Working directory does not exist: ${m.cwd}`);return{majorModesConfig:e,selectedLayers:t,hookGroups:g(e,t),profile:n,plugins:await b(u(m.repoRoot,m.domains,m.pluginDirectories)),mcpAllowlist:y(m.repoRoot,m.domains),sharedSkills:d(m.repoRoot,m.domains)}}).catch(async e=>{throw await E.recordError(r.configLoadFailed,e,{"harness.phase":D,"harness.major_mode":m.majorMode,"harness.domain_count":m.domains.length}),e}),{majorModesConfig:M,selectedLayers:N,hookGroups:P,profile:F,plugins:I,mcpAllowlist:L}=j,R=F?.persona,z=F?.personaRoot??m.repoRoot,B=await E.runInSpan(`doom_pi.${O}`,{"harness.plugin.count":I.length,"harness.agents":m.agents,"harness.mcp":m.mcp},()=>x(m.repoRoot,I,{agents:m.agents,mcp:m.mcp,temporaryDirectory:m.resourceDirectory,skillCacheDirectory:o.join(m.resourceDirectory??e(m.repoRoot,m.homeDirectory??c.homedir()).directory,`cache`,`skills`),mcpAllowlist:L,sharedSkills:j.sharedSkills,pluginDataRoot:o.join(l(m.homeDirectory??c.homedir()),`plugin-data`)})).catch(async e=>{throw await E.recordError(r.resourceCollectionFailed,e,{"harness.phase":O,"harness.plugin.count":I.length}),e});try{let e=await C(B.temporaryDirectory),r={...process.env};delete r[T];let i=f(r,F?.env??{});k(m,r),r.NX_DAEMON??=`false`,r[w]=`1`,r.DOOMPI_THEME||=S,r.CLAUDE_PROJECT_DIR=m.repoRoot,r.CODEX_REPO_ROOT=m.repoRoot,r.ORIGINAL_REPO_PATH||=m.repoRoot,r.MCP_UI_VIEWER=m.automation?`none`:r.MCP_UI_VIEWER??``;let c=t(n),l=R?p(z,R):void 0,u;return l&&(u=o.join(B.temporaryDirectory,`persona.md`),await s.promises.writeFile(u,`${l}\n`,{mode:384})),a({root:m.repoRoot,majorMode:m.majorMode,temporaryDirectory:B.temporaryDirectory,domains:m.domains,layers:N,profile:F?.name,profileIdentity:F?.identity,profileVoice:F?.voice,profileEnvironment:i,personaFile:u,skillDirectories:B.skillDirectories,agentDirectories:B.agentDirectories,additionalDirectories:m.additionalDirectories,childExtensions:[],pluginDirectories:m.pluginDirectories,pluginHooks:B.pluginHooks,hookGroups:P,hooks:m.hooks,agents:m.agents,mcp:m.mcp,mcpConfigPath:B.mcpConfigPath,mcpProjection:B.mcpProjection,allowProtectedWrites:m.allowProtectedWrites},{directory:B.temporaryDirectory,environment:r}),m.agents&&(r.PI_SUBAGENT_EXTRA_AGENT_DIRS=B.agentDirectories.join(o.delimiter),r.PI_SUBAGENT_EXTRA_SKILL_DIRS=B.skillDirectories.join(o.delimiter),r.PI_SUBAGENT_PI_BINARY=o.join(m.repoRoot,`pi.sh`)),{options:m,environment:r,resources:B,plugins:I,profile:F?.name,personaDirectory:R,personaRoot:z,mcpAllowlist:L,majorModesConfig:M,selectedLayers:N,hookGroups:P,personaEntry:c,defaultThemePath:e,cleanup:B.cleanup.bind(B)}}catch(e){throw await E.recordError(r.contextBuildFailed,e,{"harness.phase":`build_context`,"harness.major_mode":m.majorMode,...F?.name?{"harness.profile":F.name}:{}}),await B.cleanup(),e}}export{j as buildHarnessContext,k as configurePreset,A as resolveHarnessProfile};
2
2
  //# sourceMappingURL=harnessContext.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harnessContext.mjs","names":[],"sources":["../../../src/adapters/harnessContext.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { globalDoomConfigDirectory } from '@agimon-ai/doompi-config/config';\nimport { resolveMcpAllowlist } from '@agimon-ai/doompi-domain/mcp';\nimport { materializePluginEntries } from '@agimon-ai/doompi-domain/plugins';\nimport { collectResources, type HarnessResources } from '@agimon-ai/doompi-domain/resources';\nimport {\n createHarnessTelemetry,\n HARNESS_EVENT,\n type HarnessTelemetry,\n} from '../adapters/telemetry/logSinkTelemetry.ts';\nimport { resolvePluginEntries, resolveSharedSkills } from '@agimon-ai/doompi-config/domains';\nimport type { DomainMcpAllowlist, PluginEntry } from '@agimon-ai/doompi-config/domains';\nimport {\n filterHookDisabledLayers,\n layerHookGroups,\n loadMajorModesConfig,\n resolveLayers,\n} from '@agimon-ai/doompi-config/majorModes';\nimport type { MajorModesConfig } from '@agimon-ai/doompi-config/majorModes';\nimport { applyProfileEnvironment, buildPersonaPrompt, resolveProfile } from '@agimon-ai/doompi-config/profiles';\nimport type { AgentProfile } from '@agimon-ai/doompi-config/profiles';\nimport { DOOM_CORDIS_HOST_REQUIRED_ENV } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_MCP_SESSION_ENV_VAR } from '@agimon-ai/doompi-extension-contracts/mcp-session';\nimport { DEFAULT_THEME_NAME, writeDefaultTheme } from '@agimon-ai/doompi-ui/theme';\nimport { createHarnessSession } from './config/harnessState';\nimport { PERSONA_ENTRY } from '../services/extensionAssembler.ts';\nimport type { HarnessOptions } from '../types/interfaces/harness';\nimport { packageEntry } from './modules/moduleResolution';\nimport { resolveSyncLocation } from './syncLocation.ts';\n\nconst OLLAMA_PRESET = 'ollama';\nconst PRIVATE_FILE_MODE = 0o600;\nconst RESOLVE_CONFIG_PHASE = 'resolve_config';\nconst COLLECT_RESOURCES_PHASE = 'collect_resources';\nconst BUILD_CONTEXT_PHASE = 'build_context';\n\n/**\n * Everything a command needs, resolved once.\n *\n * All three commands need the same expensive preparation (domains resolved,\n * plugins collected into a temp directory, environment assembled), so it is\n * built here and handed to whichever command runs.\n */\nexport interface HarnessContext {\n options: HarnessOptions;\n environment: NodeJS.ProcessEnv;\n resources: HarnessResources;\n plugins: PluginEntry[];\n profile?: string;\n personaDirectory?: string;\n /** Root personaDirectory resolves against, when a profile supplied one. */\n personaRoot?: string;\n mcpAllowlist?: DomainMcpAllowlist;\n majorModesConfig: MajorModesConfig;\n selectedLayers: string[];\n hookGroups: string[];\n personaEntry?: string;\n defaultThemePath: string;\n cleanup(): Promise<void>;\n}\n\n/**\n * Applies the provider environment a preset needs.\n *\n * Exported because the synced Pi path has no launcher to do it: the doom-pi\n * extension applies the same rules in-process before anything reads them.\n * `piArgs` is only consulted to spot a selected cloud model.\n */\nexport function configurePreset(\n options: Pick<HarnessOptions, 'preset' | 'piArgs'>,\n environment: NodeJS.ProcessEnv,\n): void {\n if (options.preset === 'kimi') {\n if (!environment.KIMI_API_KEY && environment.KIMI_CODE_API_KEY) {\n environment.KIMI_API_KEY = environment.KIMI_CODE_API_KEY;\n }\n if (!environment.KIMI_API_KEY) {\n throw new Error('KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset');\n }\n }\n if (options.preset === OLLAMA_PRESET) {\n const selected = options.piArgs.find((argument) => argument.startsWith(`${OLLAMA_PRESET}/`));\n const cloud = selected?.endsWith(':cloud') ?? false;\n if (cloud && !environment.OLLAMA_API_KEY) {\n throw new Error('OLLAMA_API_KEY is required for Ollama cloud models');\n }\n environment.OLLAMA_API_KEY ||= OLLAMA_PRESET;\n environment.DOOMPI_OLLAMA_BASE_URL =\n environment.OLLAMA_BASE_URL ?? environment.ANTHROPIC_BASE_URL ?? 'http://localhost:11434/v1';\n }\n}\n\n/** Resolves the optional persona and environment profile selected for this run. */\nexport function resolveHarnessProfile(options: HarnessOptions): AgentProfile | undefined {\n return options.profile ? resolveProfile(options.repoRoot, options.profile) : undefined;\n}\n\n/**\n * Resolves the full matrix and stages every resource Pi will need.\n *\n * The caller owns the returned cleanup(): the temporary directory holding\n * skills, agents, and the generated MCP config has to outlive this function\n * and be removed once the selected command is done with it.\n */\nexport async function buildHarnessContext(\n options: HarnessOptions,\n telemetry: HarnessTelemetry = createHarnessTelemetry(),\n): Promise<HarnessContext> {\n // Everything up to collectResources reads configuration off disk, so a single\n // malformed modes.yaml or profiles.yaml surfaces here as a failed launch\n // with no other record.\n const configured = await telemetry\n .runInSpan(`doom_pi.${RESOLVE_CONFIG_PHASE}`, { 'harness.phase': RESOLVE_CONFIG_PHASE }, async () => {\n const majorModesConfig = loadMajorModesConfig(options.repoRoot, options.homeDirectory);\n const selectedLayers = filterHookDisabledLayers(\n majorModesConfig,\n resolveLayers(majorModesConfig, options.majorMode),\n options.hooks,\n );\n const profile = resolveHarnessProfile(options);\n if (!fs.existsSync(options.cwd) || !fs.statSync(options.cwd).isDirectory()) {\n throw new Error(`Working directory does not exist: ${options.cwd}`);\n }\n return {\n majorModesConfig,\n selectedLayers,\n hookGroups: layerHookGroups(majorModesConfig, selectedLayers),\n profile,\n plugins: await materializePluginEntries(\n resolvePluginEntries(options.repoRoot, options.domains, options.pluginDirectories),\n ),\n mcpAllowlist: resolveMcpAllowlist(options.repoRoot, options.domains),\n sharedSkills: resolveSharedSkills(options.repoRoot, options.domains),\n };\n })\n .catch(async (error: unknown) => {\n await telemetry.recordError(HARNESS_EVENT.configLoadFailed, error, {\n 'harness.phase': RESOLVE_CONFIG_PHASE,\n 'harness.major_mode': options.majorMode,\n 'harness.domain_count': options.domains.length,\n });\n throw error;\n });\n\n const { majorModesConfig, selectedLayers, hookGroups, profile, plugins, mcpAllowlist } = configured;\n const personaDirectory = profile?.persona;\n // A global profile's persona lives beside the global config, not in the repo.\n const personaRoot = profile?.personaRoot ?? options.repoRoot;\n const resources = await telemetry\n .runInSpan(\n `doom_pi.${COLLECT_RESOURCES_PHASE}`,\n { 'harness.plugin.count': plugins.length, 'harness.agents': options.agents, 'harness.mcp': options.mcp },\n () =>\n collectResources(options.repoRoot, plugins, {\n agents: options.agents,\n mcp: options.mcp,\n // Set by `doom-pi sync`, which stages into a directory that outlives\n // the process rather than a temporary one.\n temporaryDirectory: options.resourceDirectory,\n skillCacheDirectory: path.join(\n options.resourceDirectory ??\n resolveSyncLocation(options.repoRoot, options.homeDirectory ?? os.homedir()).directory,\n 'cache',\n 'skills',\n ),\n mcpAllowlist,\n sharedSkills: configured.sharedSkills,\n pluginDataRoot: path.join(globalDoomConfigDirectory(options.homeDirectory ?? os.homedir()), 'plugin-data'),\n }),\n )\n .catch(async (error: unknown) => {\n // Conflicting skills, agents, or MCP servers all fail here, and the plugin\n // that caused it is only identifiable from the message.\n await telemetry.recordError(HARNESS_EVENT.resourceCollectionFailed, error, {\n 'harness.phase': COLLECT_RESOURCES_PHASE,\n 'harness.plugin.count': plugins.length,\n });\n throw error;\n });\n\n try {\n const defaultThemePath = await writeDefaultTheme(resources.temporaryDirectory);\n const environment = { ...process.env };\n // The file-backed projection published through Cordis is authoritative.\n // Never let a legacy parent-process projection leak into this Doom session.\n delete environment[DOOM_MCP_SESSION_ENV_VAR];\n const profileEnvironment = applyProfileEnvironment(environment, profile?.env ?? {});\n\n configurePreset(options, environment);\n environment.NX_DAEMON ??= 'false';\n environment[DOOM_CORDIS_HOST_REQUIRED_ENV] = '1';\n environment.DOOMPI_THEME ||= DEFAULT_THEME_NAME;\n environment.CLAUDE_PROJECT_DIR = options.repoRoot;\n environment.CODEX_REPO_ROOT = options.repoRoot;\n environment.ORIGINAL_REPO_PATH ||= options.repoRoot;\n environment.MCP_UI_VIEWER = options.automation ? 'none' : (environment.MCP_UI_VIEWER ?? '');\n\n // Always loaded, even with no persona at launch: the extension no-ops\n // without a persona file, and /profile needs it present to load one later.\n // Pi freezes the --extension list at startup, so it cannot be added on demand.\n const personaEntry = packageEntry(PERSONA_ENTRY);\n const personaPrompt = personaDirectory ? buildPersonaPrompt(personaRoot, personaDirectory) : undefined;\n let personaFile: string | undefined;\n if (personaPrompt) {\n personaFile = path.join(resources.temporaryDirectory, 'persona.md');\n await fs.promises.writeFile(personaFile, `${personaPrompt}\\n`, { mode: PRIVATE_FILE_MODE });\n }\n\n // One write, describing the child rather than this process. The state file\n // is the child's authority and the environment is what it projects for the\n // hooks and packages that can only read an environment.\n createHarnessSession(\n {\n root: options.repoRoot,\n majorMode: options.majorMode,\n temporaryDirectory: resources.temporaryDirectory,\n domains: options.domains,\n layers: selectedLayers,\n profile: profile?.name,\n profileEnvironment,\n personaFile,\n skillDirectories: resources.skillDirectories,\n agentDirectories: resources.agentDirectories,\n additionalDirectories: options.additionalDirectories,\n childExtensions: [],\n pluginDirectories: options.pluginDirectories,\n pluginHooks: resources.pluginHooks,\n hookGroups,\n hooks: options.hooks,\n agents: options.agents,\n mcp: options.mcp,\n mcpConfigPath: resources.mcpConfigPath,\n mcpProjection: resources.mcpProjection,\n allowProtectedWrites: options.allowProtectedWrites,\n },\n { directory: resources.temporaryDirectory, environment },\n );\n if (options.agents) {\n environment.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_PI_BINARY = path.join(options.repoRoot, 'pi.sh');\n }\n\n // Core hook groups load regardless; hookGroups selects the rest. The initial\n // state write includes an empty list deliberately: unset means every group.\n\n return {\n options,\n environment,\n resources,\n plugins,\n profile: profile?.name,\n personaDirectory,\n personaRoot,\n mcpAllowlist,\n majorModesConfig,\n selectedLayers,\n hookGroups,\n personaEntry,\n defaultThemePath,\n cleanup: resources.cleanup.bind(resources),\n };\n } catch (error) {\n // Preparation failed after the temp directory existed, so nothing will be\n // handed back to clean it up.\n await telemetry.recordError(HARNESS_EVENT.contextBuildFailed, error, {\n 'harness.phase': BUILD_CONTEXT_PHASE,\n 'harness.major_mode': options.majorMode,\n ...(profile?.name ? { 'harness.profile': profile.name } : {}),\n });\n await resources.cleanup();\n throw error;\n }\n}\n"],"mappings":"g0CAgCA,MAAM,EAAgB,SAEhB,EAAuB,iBACvB,EAA0B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harnessContext.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { globalDoomConfigDirectory } from '@agimon-ai/doompi-config/config';\nimport { resolveMcpAllowlist } from '@agimon-ai/doompi-domain/mcp';\nimport { materializePluginEntries } from '@agimon-ai/doompi-domain/plugins';\nimport { collectResources, type HarnessResources } from '@agimon-ai/doompi-domain/resources';\nimport {\n createHarnessTelemetry,\n HARNESS_EVENT,\n type HarnessTelemetry,\n} from '../adapters/telemetry/logSinkTelemetry.ts';\nimport { resolvePluginEntries, resolveSharedSkills } from '@agimon-ai/doompi-config/domains';\nimport type { DomainMcpAllowlist, PluginEntry } from '@agimon-ai/doompi-config/domains';\nimport {\n filterHookDisabledLayers,\n layerHookGroups,\n loadMajorModesConfig,\n resolveLayers,\n} from '@agimon-ai/doompi-config/majorModes';\nimport type { MajorModesConfig } from '@agimon-ai/doompi-config/majorModes';\nimport { applyProfileEnvironment, buildPersonaPrompt, resolveProfile } from '@agimon-ai/doompi-config/profiles';\nimport type { AgentProfile } from '@agimon-ai/doompi-config/profiles';\nimport { DOOM_CORDIS_HOST_REQUIRED_ENV } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_MCP_SESSION_ENV_VAR } from '@agimon-ai/doompi-extension-contracts/mcp-session';\nimport { DEFAULT_THEME_NAME, writeDefaultTheme } from '@agimon-ai/doompi-ui/theme';\nimport { createHarnessSession } from './config/harnessState';\nimport { PERSONA_ENTRY } from '../services/extensionAssembler.ts';\nimport type { HarnessOptions } from '../types/interfaces/harness';\nimport { packageEntry } from './modules/moduleResolution';\nimport { resolveSyncLocation } from './syncLocation.ts';\n\nconst OLLAMA_PRESET = 'ollama';\nconst PRIVATE_FILE_MODE = 0o600;\nconst RESOLVE_CONFIG_PHASE = 'resolve_config';\nconst COLLECT_RESOURCES_PHASE = 'collect_resources';\nconst BUILD_CONTEXT_PHASE = 'build_context';\n\n/**\n * Everything a command needs, resolved once.\n *\n * All three commands need the same expensive preparation (domains resolved,\n * plugins collected into a temp directory, environment assembled), so it is\n * built here and handed to whichever command runs.\n */\nexport interface HarnessContext {\n options: HarnessOptions;\n environment: NodeJS.ProcessEnv;\n resources: HarnessResources;\n plugins: PluginEntry[];\n profile?: string;\n personaDirectory?: string;\n /** Root personaDirectory resolves against, when a profile supplied one. */\n personaRoot?: string;\n mcpAllowlist?: DomainMcpAllowlist;\n majorModesConfig: MajorModesConfig;\n selectedLayers: string[];\n hookGroups: string[];\n personaEntry?: string;\n defaultThemePath: string;\n cleanup(): Promise<void>;\n}\n\n/**\n * Applies the provider environment a preset needs.\n *\n * Exported because the synced Pi path has no launcher to do it: the doom-pi\n * extension applies the same rules in-process before anything reads them.\n * `piArgs` is only consulted to spot a selected cloud model.\n */\nexport function configurePreset(\n options: Pick<HarnessOptions, 'preset' | 'piArgs'>,\n environment: NodeJS.ProcessEnv,\n): void {\n if (options.preset === 'kimi') {\n if (!environment.KIMI_API_KEY && environment.KIMI_CODE_API_KEY) {\n environment.KIMI_API_KEY = environment.KIMI_CODE_API_KEY;\n }\n if (!environment.KIMI_API_KEY) {\n throw new Error('KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset');\n }\n }\n if (options.preset === OLLAMA_PRESET) {\n const selected = options.piArgs.find((argument) => argument.startsWith(`${OLLAMA_PRESET}/`));\n const cloud = selected?.endsWith(':cloud') ?? false;\n if (cloud && !environment.OLLAMA_API_KEY) {\n throw new Error('OLLAMA_API_KEY is required for Ollama cloud models');\n }\n environment.OLLAMA_API_KEY ||= OLLAMA_PRESET;\n environment.DOOMPI_OLLAMA_BASE_URL =\n environment.OLLAMA_BASE_URL ?? environment.ANTHROPIC_BASE_URL ?? 'http://localhost:11434/v1';\n }\n}\n\n/** Resolves the optional persona and environment profile selected for this run. */\nexport function resolveHarnessProfile(options: HarnessOptions): AgentProfile | undefined {\n return options.profile ? resolveProfile(options.repoRoot, options.profile) : undefined;\n}\n\n/**\n * Resolves the full matrix and stages every resource Pi will need.\n *\n * The caller owns the returned cleanup(): the temporary directory holding\n * skills, agents, and the generated MCP config has to outlive this function\n * and be removed once the selected command is done with it.\n */\nexport async function buildHarnessContext(\n options: HarnessOptions,\n telemetry: HarnessTelemetry = createHarnessTelemetry(),\n): Promise<HarnessContext> {\n // Everything up to collectResources reads configuration off disk, so a single\n // malformed modes.yaml or profiles.yaml surfaces here as a failed launch\n // with no other record.\n const configured = await telemetry\n .runInSpan(`doom_pi.${RESOLVE_CONFIG_PHASE}`, { 'harness.phase': RESOLVE_CONFIG_PHASE }, async () => {\n const majorModesConfig = loadMajorModesConfig(options.repoRoot, options.homeDirectory);\n const selectedLayers = filterHookDisabledLayers(\n majorModesConfig,\n resolveLayers(majorModesConfig, options.majorMode),\n options.hooks,\n );\n const profile = resolveHarnessProfile(options);\n if (!fs.existsSync(options.cwd) || !fs.statSync(options.cwd).isDirectory()) {\n throw new Error(`Working directory does not exist: ${options.cwd}`);\n }\n return {\n majorModesConfig,\n selectedLayers,\n hookGroups: layerHookGroups(majorModesConfig, selectedLayers),\n profile,\n plugins: await materializePluginEntries(\n resolvePluginEntries(options.repoRoot, options.domains, options.pluginDirectories),\n ),\n mcpAllowlist: resolveMcpAllowlist(options.repoRoot, options.domains),\n sharedSkills: resolveSharedSkills(options.repoRoot, options.domains),\n };\n })\n .catch(async (error: unknown) => {\n await telemetry.recordError(HARNESS_EVENT.configLoadFailed, error, {\n 'harness.phase': RESOLVE_CONFIG_PHASE,\n 'harness.major_mode': options.majorMode,\n 'harness.domain_count': options.domains.length,\n });\n throw error;\n });\n\n const { majorModesConfig, selectedLayers, hookGroups, profile, plugins, mcpAllowlist } = configured;\n const personaDirectory = profile?.persona;\n // A global profile's persona lives beside the global config, not in the repo.\n const personaRoot = profile?.personaRoot ?? options.repoRoot;\n const resources = await telemetry\n .runInSpan(\n `doom_pi.${COLLECT_RESOURCES_PHASE}`,\n { 'harness.plugin.count': plugins.length, 'harness.agents': options.agents, 'harness.mcp': options.mcp },\n () =>\n collectResources(options.repoRoot, plugins, {\n agents: options.agents,\n mcp: options.mcp,\n // Set by `doom-pi sync`, which stages into a directory that outlives\n // the process rather than a temporary one.\n temporaryDirectory: options.resourceDirectory,\n skillCacheDirectory: path.join(\n options.resourceDirectory ??\n resolveSyncLocation(options.repoRoot, options.homeDirectory ?? os.homedir()).directory,\n 'cache',\n 'skills',\n ),\n mcpAllowlist,\n sharedSkills: configured.sharedSkills,\n pluginDataRoot: path.join(globalDoomConfigDirectory(options.homeDirectory ?? os.homedir()), 'plugin-data'),\n }),\n )\n .catch(async (error: unknown) => {\n // Conflicting skills, agents, or MCP servers all fail here, and the plugin\n // that caused it is only identifiable from the message.\n await telemetry.recordError(HARNESS_EVENT.resourceCollectionFailed, error, {\n 'harness.phase': COLLECT_RESOURCES_PHASE,\n 'harness.plugin.count': plugins.length,\n });\n throw error;\n });\n\n try {\n const defaultThemePath = await writeDefaultTheme(resources.temporaryDirectory);\n const environment = { ...process.env };\n // The file-backed projection published through Cordis is authoritative.\n // Never let a legacy parent-process projection leak into this Doom session.\n delete environment[DOOM_MCP_SESSION_ENV_VAR];\n const profileEnvironment = applyProfileEnvironment(environment, profile?.env ?? {});\n\n configurePreset(options, environment);\n environment.NX_DAEMON ??= 'false';\n environment[DOOM_CORDIS_HOST_REQUIRED_ENV] = '1';\n environment.DOOMPI_THEME ||= DEFAULT_THEME_NAME;\n environment.CLAUDE_PROJECT_DIR = options.repoRoot;\n environment.CODEX_REPO_ROOT = options.repoRoot;\n environment.ORIGINAL_REPO_PATH ||= options.repoRoot;\n environment.MCP_UI_VIEWER = options.automation ? 'none' : (environment.MCP_UI_VIEWER ?? '');\n\n // Always loaded, even with no persona at launch: the extension no-ops\n // without a persona file, and /profile needs it present to load one later.\n // Pi freezes the --extension list at startup, so it cannot be added on demand.\n const personaEntry = packageEntry(PERSONA_ENTRY);\n const personaPrompt = personaDirectory ? buildPersonaPrompt(personaRoot, personaDirectory) : undefined;\n let personaFile: string | undefined;\n if (personaPrompt) {\n personaFile = path.join(resources.temporaryDirectory, 'persona.md');\n await fs.promises.writeFile(personaFile, `${personaPrompt}\\n`, { mode: PRIVATE_FILE_MODE });\n }\n\n // One write, describing the child rather than this process. The state file\n // is the child's authority and the environment is what it projects for the\n // hooks and packages that can only read an environment.\n createHarnessSession(\n {\n root: options.repoRoot,\n majorMode: options.majorMode,\n temporaryDirectory: resources.temporaryDirectory,\n domains: options.domains,\n layers: selectedLayers,\n profile: profile?.name,\n profileIdentity: profile?.identity,\n profileVoice: profile?.voice,\n profileEnvironment,\n personaFile,\n skillDirectories: resources.skillDirectories,\n agentDirectories: resources.agentDirectories,\n additionalDirectories: options.additionalDirectories,\n childExtensions: [],\n pluginDirectories: options.pluginDirectories,\n pluginHooks: resources.pluginHooks,\n hookGroups,\n hooks: options.hooks,\n agents: options.agents,\n mcp: options.mcp,\n mcpConfigPath: resources.mcpConfigPath,\n mcpProjection: resources.mcpProjection,\n allowProtectedWrites: options.allowProtectedWrites,\n },\n { directory: resources.temporaryDirectory, environment },\n );\n if (options.agents) {\n environment.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_PI_BINARY = path.join(options.repoRoot, 'pi.sh');\n }\n\n // Core hook groups load regardless; hookGroups selects the rest. The initial\n // state write includes an empty list deliberately: unset means every group.\n\n return {\n options,\n environment,\n resources,\n plugins,\n profile: profile?.name,\n personaDirectory,\n personaRoot,\n mcpAllowlist,\n majorModesConfig,\n selectedLayers,\n hookGroups,\n personaEntry,\n defaultThemePath,\n cleanup: resources.cleanup.bind(resources),\n };\n } catch (error) {\n // Preparation failed after the temp directory existed, so nothing will be\n // handed back to clean it up.\n await telemetry.recordError(HARNESS_EVENT.contextBuildFailed, error, {\n 'harness.phase': BUILD_CONTEXT_PHASE,\n 'harness.major_mode': options.majorMode,\n ...(profile?.name ? { 'harness.profile': profile.name } : {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AmB,EAAQ,IAAK,EAAI,CAAC,CAC7D,CAAC,EACD,MAAM,EAAU,QAAQ,EAClB,CACR,CACF"}
@@ -1,2 +1,2 @@
1
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../adapters/repository/repository.cjs"),n=require("./options.cjs"),r=require("../../adapters/config/harnessState.cjs");let i=require("node:path");i=e.__toESM(i,1);let a=require("@agimon-ai/doompi-config/domains"),o=require("@agimon-ai/doompi-config/majorModes");function s(e){try{return t.findRepositoryRoot(e)}catch{return i.default.resolve(e)}}function c(e){let t=e.environment??process.env,c=e.cwd??process.cwd(),l=[...e.args],u=n.parseHarnessArgs(l),d=r.readHarnessState(t,e.report).root,f=d?i.default.resolve(d):s(u.options.cwd);return{repoRoot:f,...n.parseHarnessArgs(l,t,c,(0,o.loadMajorModesConfig)(f).defaultMajorMode,(0,a.loadDomains)(f).defaultDomains).options}}exports.resolveHarnessOptions=c;
1
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../adapters/repository/repository.cjs"),n=require("./options.cjs"),r=require("../../adapters/config/harnessState.cjs");let i=require("node:path");i=e.__toESM(i,1);let a=require("@agimon-ai/doompi-config/domains"),o=require("@agimon-ai/doompi-config/profiles"),s=require("@agimon-ai/doompi-config/majorModes");function c(e){try{return t.findRepositoryRoot(e)}catch{return i.default.resolve(e)}}function l(e){let t=e.environment??process.env,l=e.cwd??process.cwd(),u=[...e.args],d=n.parseHarnessArgs(u),f=r.readHarnessState(t,e.report).root,p=f?i.default.resolve(f):c(d.options.cwd);return{repoRoot:p,...n.parseHarnessArgs(u,t,l,(0,s.loadMajorModesConfig)(p).defaultMajorMode,(0,a.loadDomains)(p).defaultDomains,(0,o.loadProfileCatalog)(p).defaultProfile).options}}exports.resolveHarnessOptions=l;
2
2
  //# sourceMappingURL=harnessOptions.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harnessOptions.cjs","names":["findRepositoryRoot","path","parseHarnessArgs","readHarnessState","loadMajorModesConfig","loadDomains"],"sources":["../../../../src/commands/cli/harnessOptions.ts"],"sourcesContent":["import path from 'node:path';\nimport { loadDomains } from '@agimon-ai/doompi-config/domains';\nimport { loadMajorModesConfig } from '@agimon-ai/doompi-config/majorModes';\nimport { parseHarnessArgs } from './options.ts';\nimport { readHarnessState } from '../../adapters/config/harnessState.ts';\nimport { findRepositoryRoot } from '../../adapters/repository/repository.ts';\nimport type { HarnessFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport type { HarnessOptions } from '../../types/interfaces/harness';\n\nexport interface ResolveHarnessOptionsInput {\n /** Raw launcher arguments, as the binary received them. */\n args: readonly string[];\n environment?: NodeJS.ProcessEnv;\n cwd?: string;\n /** Reports a malformed inherited harness state without failing the run. */\n report?: HarnessFailureReporter;\n}\n\n/** Uses the nearest configured repository, or the selected directory for an unconfigured workspace. */\nfunction resolveConfigurationRoot(cwd: string): string {\n try {\n return findRepositoryRoot(cwd);\n } catch {\n return path.resolve(cwd);\n }\n}\n\n/**\n * Settles the configuration root and the full option matrix for one run.\n *\n * Two passes are required: the first reads --cwd without touching repository\n * configuration, which keeps a run resolvable even when modes.yaml is\n * malformed, and the second applies the defaults that root supplies. An\n * inherited root wins, which is how a nested run stays pinned to the outer\n * repository rather than re-deriving one from its own cwd. When no configured\n * repository exists, the selected working directory is the configuration root.\n */\nexport function resolveHarnessOptions(input: ResolveHarnessOptionsInput): HarnessOptions {\n const environment = input.environment ?? process.env;\n const cwd = input.cwd ?? process.cwd();\n const args = [...input.args];\n\n const initial = parseHarnessArgs(args);\n const inheritedRoot = readHarnessState(environment, input.report).root;\n const repoRoot = inheritedRoot ? path.resolve(inheritedRoot) : resolveConfigurationRoot(initial.options.cwd);\n const parsed = parseHarnessArgs(\n args,\n environment,\n cwd,\n loadMajorModesConfig(repoRoot).defaultMajorMode,\n loadDomains(repoRoot).defaultDomains,\n );\n return { repoRoot, ...parsed.options };\n}\n"],"mappings":"+UAmBA,SAAS,EAAyB,EAAqB,CACrD,GAAI,CACF,OAAOA,EAAAA,mBAAmB,CAAG,CAC/B,MAAQ,CACN,OAAOC,EAAAA,QAAK,QAAQ,CAAG,CACzB,CACF,CAYA,SAAgB,EAAsB,EAAmD,CACvF,IAAM,EAAc,EAAM,aAAe,QAAQ,IAC3C,EAAM,EAAM,KAAO,QAAQ,IAAI,EAC/B,EAAO,CAAC,GAAG,EAAM,IAAI,EAErB,EAAUC,EAAAA,iBAAiB,CAAI,EAC/B,EAAgBC,EAAAA,iBAAiB,EAAa,EAAM,MAAM,CAAC,CAAC,KAC5D,EAAW,EAAgBF,EAAAA,QAAK,QAAQ,CAAa,EAAI,EAAyB,EAAQ,QAAQ,GAAG,EAQ3G,MAAO,CAAE,WAAU,GAPJC,EAAAA,iBACb,EACA,EACA,GAAA,EACAE,EAAAA,qBAAAA,CAAqB,CAAQ,CAAC,CAAC,kBAAA,EAC/BC,EAAAA,YAAAA,CAAY,CAAQ,CAAC,CAAC,cAEG,CAAC,CAAC,OAAQ,CACvC"}
1
+ {"version":3,"file":"harnessOptions.cjs","names":["findRepositoryRoot","path","parseHarnessArgs","readHarnessState","loadMajorModesConfig","loadDomains","loadProfileCatalog"],"sources":["../../../../src/commands/cli/harnessOptions.ts"],"sourcesContent":["import path from 'node:path';\nimport { loadDomains } from '@agimon-ai/doompi-config/domains';\nimport { loadMajorModesConfig } from '@agimon-ai/doompi-config/majorModes';\nimport { loadProfileCatalog } from '@agimon-ai/doompi-config/profiles';\nimport { parseHarnessArgs } from './options.ts';\nimport { readHarnessState } from '../../adapters/config/harnessState.ts';\nimport { findRepositoryRoot } from '../../adapters/repository/repository.ts';\nimport type { HarnessFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport type { HarnessOptions } from '../../types/interfaces/harness';\n\nexport interface ResolveHarnessOptionsInput {\n /** Raw launcher arguments, as the binary received them. */\n args: readonly string[];\n environment?: NodeJS.ProcessEnv;\n cwd?: string;\n /** Reports a malformed inherited harness state without failing the run. */\n report?: HarnessFailureReporter;\n}\n\n/** Uses the nearest configured repository, or the selected directory for an unconfigured workspace. */\nfunction resolveConfigurationRoot(cwd: string): string {\n try {\n return findRepositoryRoot(cwd);\n } catch {\n return path.resolve(cwd);\n }\n}\n\n/**\n * Settles the configuration root and the full option matrix for one run.\n *\n * Two passes are required: the first reads --cwd without touching repository\n * configuration, which keeps a run resolvable even when modes.yaml is\n * malformed, and the second applies the defaults that root supplies. An\n * inherited root wins, which is how a nested run stays pinned to the outer\n * repository rather than re-deriving one from its own cwd. When no configured\n * repository exists, the selected working directory is the configuration root.\n */\nexport function resolveHarnessOptions(input: ResolveHarnessOptionsInput): HarnessOptions {\n const environment = input.environment ?? process.env;\n const cwd = input.cwd ?? process.cwd();\n const args = [...input.args];\n\n const initial = parseHarnessArgs(args);\n const inheritedRoot = readHarnessState(environment, input.report).root;\n const repoRoot = inheritedRoot ? path.resolve(inheritedRoot) : resolveConfigurationRoot(initial.options.cwd);\n const parsed = parseHarnessArgs(\n args,\n environment,\n cwd,\n loadMajorModesConfig(repoRoot).defaultMajorMode,\n loadDomains(repoRoot).defaultDomains,\n loadProfileCatalog(repoRoot).defaultProfile,\n );\n return { repoRoot, ...parsed.options };\n}\n"],"mappings":"8XAoBA,SAAS,EAAyB,EAAqB,CACrD,GAAI,CACF,OAAOA,EAAAA,mBAAmB,CAAG,CAC/B,MAAQ,CACN,OAAOC,EAAAA,QAAK,QAAQ,CAAG,CACzB,CACF,CAYA,SAAgB,EAAsB,EAAmD,CACvF,IAAM,EAAc,EAAM,aAAe,QAAQ,IAC3C,EAAM,EAAM,KAAO,QAAQ,IAAI,EAC/B,EAAO,CAAC,GAAG,EAAM,IAAI,EAErB,EAAUC,EAAAA,iBAAiB,CAAI,EAC/B,EAAgBC,EAAAA,iBAAiB,EAAa,EAAM,MAAM,CAAC,CAAC,KAC5D,EAAW,EAAgBF,EAAAA,QAAK,QAAQ,CAAa,EAAI,EAAyB,EAAQ,QAAQ,GAAG,EAS3G,MAAO,CAAE,WAAU,GARJC,EAAAA,iBACb,EACA,EACA,GAAA,EACAE,EAAAA,qBAAAA,CAAqB,CAAQ,CAAC,CAAC,kBAAA,EAC/BC,EAAAA,YAAAA,CAAY,CAAQ,CAAC,CAAC,gBAAA,EACtBC,EAAAA,mBAAAA,CAAmB,CAAQ,CAAC,CAAC,cAEJ,CAAC,CAAC,OAAQ,CACvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"harnessOptions.d.cts","names":[],"sources":["../../../../src/commands/cli/harnessOptions.ts"],"mappings":";;;iBASiB;;EAEf;EACA,cAAc,OAAO;EACrB;;EAEA,SAAS;;;;;;;;;;;;wBAsBK,sBAAsB,OAAO,6BAA6B"}
1
+ {"version":3,"file":"harnessOptions.d.cts","names":[],"sources":["../../../../src/commands/cli/harnessOptions.ts"],"mappings":";;;iBAUiB;;EAEf;EACA,cAAc,OAAO;EACrB;;EAEA,SAAS;;;;;;;;;;;;wBAsBK,sBAAsB,OAAO,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"harnessOptions.d.mts","names":[],"sources":["../../../../src/commands/cli/harnessOptions.ts"],"mappings":";;;iBASiB;;EAEf;EACA,cAAc,OAAO;EACrB;;EAEA,SAAS;;;;;;;;;;;;wBAsBK,sBAAsB,OAAO,6BAA6B"}
1
+ {"version":3,"file":"harnessOptions.d.mts","names":[],"sources":["../../../../src/commands/cli/harnessOptions.ts"],"mappings":";;;iBAUiB;;EAEf;EACA,cAAc,OAAO;EACrB;;EAEA,SAAS;;;;;;;;;;;;wBAsBK,sBAAsB,OAAO,6BAA6B"}
@@ -1,2 +1,2 @@
1
- import{findRepositoryRoot as e}from"../../adapters/repository/repository.mjs";import{parseHarnessArgs as t}from"./options.mjs";import{readHarnessState as n}from"../../adapters/config/harnessState.mjs";import r from"node:path";import{loadDomains as i}from"@agimon-ai/doompi-config/domains";import{loadMajorModesConfig as a}from"@agimon-ai/doompi-config/majorModes";function o(t){try{return e(t)}catch{return r.resolve(t)}}function s(e){let s=e.environment??process.env,c=e.cwd??process.cwd(),l=[...e.args],u=t(l),d=n(s,e.report).root,f=d?r.resolve(d):o(u.options.cwd);return{repoRoot:f,...t(l,s,c,a(f).defaultMajorMode,i(f).defaultDomains).options}}export{s as resolveHarnessOptions};
1
+ import{findRepositoryRoot as e}from"../../adapters/repository/repository.mjs";import{parseHarnessArgs as t}from"./options.mjs";import{readHarnessState as n}from"../../adapters/config/harnessState.mjs";import r from"node:path";import{loadDomains as i}from"@agimon-ai/doompi-config/domains";import{loadProfileCatalog as a}from"@agimon-ai/doompi-config/profiles";import{loadMajorModesConfig as o}from"@agimon-ai/doompi-config/majorModes";function s(t){try{return e(t)}catch{return r.resolve(t)}}function c(e){let c=e.environment??process.env,l=e.cwd??process.cwd(),u=[...e.args],d=t(u),f=n(c,e.report).root,p=f?r.resolve(f):s(d.options.cwd);return{repoRoot:p,...t(u,c,l,o(p).defaultMajorMode,i(p).defaultDomains,a(p).defaultProfile).options}}export{c as resolveHarnessOptions};
2
2
  //# sourceMappingURL=harnessOptions.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harnessOptions.mjs","names":[],"sources":["../../../../src/commands/cli/harnessOptions.ts"],"sourcesContent":["import path from 'node:path';\nimport { loadDomains } from '@agimon-ai/doompi-config/domains';\nimport { loadMajorModesConfig } from '@agimon-ai/doompi-config/majorModes';\nimport { parseHarnessArgs } from './options.ts';\nimport { readHarnessState } from '../../adapters/config/harnessState.ts';\nimport { findRepositoryRoot } from '../../adapters/repository/repository.ts';\nimport type { HarnessFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport type { HarnessOptions } from '../../types/interfaces/harness';\n\nexport interface ResolveHarnessOptionsInput {\n /** Raw launcher arguments, as the binary received them. */\n args: readonly string[];\n environment?: NodeJS.ProcessEnv;\n cwd?: string;\n /** Reports a malformed inherited harness state without failing the run. */\n report?: HarnessFailureReporter;\n}\n\n/** Uses the nearest configured repository, or the selected directory for an unconfigured workspace. */\nfunction resolveConfigurationRoot(cwd: string): string {\n try {\n return findRepositoryRoot(cwd);\n } catch {\n return path.resolve(cwd);\n }\n}\n\n/**\n * Settles the configuration root and the full option matrix for one run.\n *\n * Two passes are required: the first reads --cwd without touching repository\n * configuration, which keeps a run resolvable even when modes.yaml is\n * malformed, and the second applies the defaults that root supplies. An\n * inherited root wins, which is how a nested run stays pinned to the outer\n * repository rather than re-deriving one from its own cwd. When no configured\n * repository exists, the selected working directory is the configuration root.\n */\nexport function resolveHarnessOptions(input: ResolveHarnessOptionsInput): HarnessOptions {\n const environment = input.environment ?? process.env;\n const cwd = input.cwd ?? process.cwd();\n const args = [...input.args];\n\n const initial = parseHarnessArgs(args);\n const inheritedRoot = readHarnessState(environment, input.report).root;\n const repoRoot = inheritedRoot ? path.resolve(inheritedRoot) : resolveConfigurationRoot(initial.options.cwd);\n const parsed = parseHarnessArgs(\n args,\n environment,\n cwd,\n loadMajorModesConfig(repoRoot).defaultMajorMode,\n loadDomains(repoRoot).defaultDomains,\n );\n return { repoRoot, ...parsed.options };\n}\n"],"mappings":"4WAmBA,SAAS,EAAyB,EAAqB,CACrD,GAAI,CACF,OAAO,EAAmB,CAAG,CAC/B,MAAQ,CACN,OAAO,EAAK,QAAQ,CAAG,CACzB,CACF,CAYA,SAAgB,EAAsB,EAAmD,CACvF,IAAM,EAAc,EAAM,aAAe,QAAQ,IAC3C,EAAM,EAAM,KAAO,QAAQ,IAAI,EAC/B,EAAO,CAAC,GAAG,EAAM,IAAI,EAErB,EAAU,EAAiB,CAAI,EAC/B,EAAgB,EAAiB,EAAa,EAAM,MAAM,CAAC,CAAC,KAC5D,EAAW,EAAgB,EAAK,QAAQ,CAAa,EAAI,EAAyB,EAAQ,QAAQ,GAAG,EAQ3G,MAAO,CAAE,WAAU,GAPJ,EACb,EACA,EACA,EACA,EAAqB,CAAQ,CAAC,CAAC,iBAC/B,EAAY,CAAQ,CAAC,CAAC,cAEG,CAAC,CAAC,OAAQ,CACvC"}
1
+ {"version":3,"file":"harnessOptions.mjs","names":[],"sources":["../../../../src/commands/cli/harnessOptions.ts"],"sourcesContent":["import path from 'node:path';\nimport { loadDomains } from '@agimon-ai/doompi-config/domains';\nimport { loadMajorModesConfig } from '@agimon-ai/doompi-config/majorModes';\nimport { loadProfileCatalog } from '@agimon-ai/doompi-config/profiles';\nimport { parseHarnessArgs } from './options.ts';\nimport { readHarnessState } from '../../adapters/config/harnessState.ts';\nimport { findRepositoryRoot } from '../../adapters/repository/repository.ts';\nimport type { HarnessFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport type { HarnessOptions } from '../../types/interfaces/harness';\n\nexport interface ResolveHarnessOptionsInput {\n /** Raw launcher arguments, as the binary received them. */\n args: readonly string[];\n environment?: NodeJS.ProcessEnv;\n cwd?: string;\n /** Reports a malformed inherited harness state without failing the run. */\n report?: HarnessFailureReporter;\n}\n\n/** Uses the nearest configured repository, or the selected directory for an unconfigured workspace. */\nfunction resolveConfigurationRoot(cwd: string): string {\n try {\n return findRepositoryRoot(cwd);\n } catch {\n return path.resolve(cwd);\n }\n}\n\n/**\n * Settles the configuration root and the full option matrix for one run.\n *\n * Two passes are required: the first reads --cwd without touching repository\n * configuration, which keeps a run resolvable even when modes.yaml is\n * malformed, and the second applies the defaults that root supplies. An\n * inherited root wins, which is how a nested run stays pinned to the outer\n * repository rather than re-deriving one from its own cwd. When no configured\n * repository exists, the selected working directory is the configuration root.\n */\nexport function resolveHarnessOptions(input: ResolveHarnessOptionsInput): HarnessOptions {\n const environment = input.environment ?? process.env;\n const cwd = input.cwd ?? process.cwd();\n const args = [...input.args];\n\n const initial = parseHarnessArgs(args);\n const inheritedRoot = readHarnessState(environment, input.report).root;\n const repoRoot = inheritedRoot ? path.resolve(inheritedRoot) : resolveConfigurationRoot(initial.options.cwd);\n const parsed = parseHarnessArgs(\n args,\n environment,\n cwd,\n loadMajorModesConfig(repoRoot).defaultMajorMode,\n loadDomains(repoRoot).defaultDomains,\n loadProfileCatalog(repoRoot).defaultProfile,\n );\n return { repoRoot, ...parsed.options };\n}\n"],"mappings":"mbAoBA,SAAS,EAAyB,EAAqB,CACrD,GAAI,CACF,OAAO,EAAmB,CAAG,CAC/B,MAAQ,CACN,OAAO,EAAK,QAAQ,CAAG,CACzB,CACF,CAYA,SAAgB,EAAsB,EAAmD,CACvF,IAAM,EAAc,EAAM,aAAe,QAAQ,IAC3C,EAAM,EAAM,KAAO,QAAQ,IAAI,EAC/B,EAAO,CAAC,GAAG,EAAM,IAAI,EAErB,EAAU,EAAiB,CAAI,EAC/B,EAAgB,EAAiB,EAAa,EAAM,MAAM,CAAC,CAAC,KAC5D,EAAW,EAAgB,EAAK,QAAQ,CAAa,EAAI,EAAyB,EAAQ,QAAQ,GAAG,EAS3G,MAAO,CAAE,WAAU,GARJ,EACb,EACA,EACA,EACA,EAAqB,CAAQ,CAAC,CAAC,iBAC/B,EAAY,CAAQ,CAAC,CAAC,eACtB,EAAmB,CAAQ,CAAC,CAAC,cAEJ,CAAC,CAAC,OAAQ,CACvC"}
@@ -1,2 +1,2 @@
1
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./matrixOptions.cjs");let n=require("node:path");n=e.__toESM(n,1);let r=require("@agimon-ai/doompi-config/domains");const i=`kimi-for-coding`,a=`kimi-for-coding-highspeed`,o=`kimi-k2.6`,s=`default`,c=`kimi`,l=`ollama`,u=`ollama/`,d=`native`,f=`--model`,p=`--mode`,m=`--thinking`,h=`--print`,g=`--approve`,_=`--profiles`,v=`--no-domains`,y=`vibe-lint`,b=`json`,x=`--auto-stop`,S=`--help`,C=`--version`,w=new Map([[`k2p5`,i],[`k2p6`,i],[`k2p7`,i],[`kimi-k2.5`,i],[o,i],[`kimi-k2.7-code`,i],[i,i],[a,a]]);function T(e){if(e===s||e===c||e===l)return e;throw Error(`Unsupported preset: ${e}`)}function E(e,...t){return e.some(e=>t.includes(e)||t.some(t=>e.startsWith(`${t}=`)))}function D(e){for(let t=0;t<e.length;t+=1){if(e[t]===f||e[t]===`-m`){let n=e[t+1];if(n)return{index:t,value:n,inline:!1}}if(e[t]?.startsWith(`${f}=`))return{index:t,value:e[t].slice(`${f}=`.length),inline:!0}}}function O(e,t){let n=D(e);n?n.inline?e[n.index]=`${f}=${t}`:e[n.index+1]=t:e.unshift(f,t)}function k(e,t,n){let r=D(t);if(e===c){let e=r?.value??n.KIMI_CODE_MODEL??i,a=e.includes(`/`)?e.slice(e.indexOf(`/`)+1):e;O(t,`kimi-coding/${w.get(a)??a}`)}if(e===l){let e=r?.value??n.OLLAMA_CLAUDE_MODEL??o,i=e.startsWith(u)?e.slice(7):e;O(t,`${u}${i.includes(`:`)?i:`${i}:cloud`}`)}}function A(e,n){let r=e.some(e=>e===S||e===`-h`),i=e.some(e=>e===C||e===`-v`);if(r||i)return{options:{cwd:n,profile:void 0,domains:[],majorMode:t.DEFAULT_MAJOR_MODE,explain:!1,emitMcp:void 0,pluginDirectories:[],additionalDirectories:[],preset:s,outputFormat:d,mute:!1,automation:!1,autoStop:!1,sandbox:!1,allowProtectedWrites:!1,hooks:!0,mcp:!0,agents:!0,piArgs:[]},help:r,version:i}}function j(e,i=process.env,a=process.cwd(),o=t.DEFAULT_MAJOR_MODE,c){let l=A(e,a);if(l)return l;let u=t.resolveInheritedProfile(i),f=!1,w=t.resolveInheritedMajorMode(i,o),D=!1,O=[],j=[],M=[],N=[],P=a,F=T(i.DOOMPI_PRESET??s),I=d,L=!1,R=!1,z=!1,B=!1,V=!1,H=!1,U=!0,W=!0,G=!0,K=!1,q=!1,J=!1,Y;for(let r=0;r<e.length;r+=1){let i=e[r];if(t.matchesOption(i,`--target`))throw Error(`${t.REMOVED_TARGET_OPTION} was replaced by ${t.MAJOR_MODE_OPTION}`);if(t.matchesOption(i,`--layer`))throw Error(`${t.REMOVED_LAYER_OPTION} was replaced by ${t.MAJOR_MODE_OPTION}`);if(t.matchesOption(i,`--layers`))throw Error(`${t.REMOVED_LAYERS_OPTION} was removed; select one major mode with ${t.MAJOR_MODE_OPTION}`);if(t.matchesOption(i,_))throw Error(`${_} was replaced by ${t.DOMAINS_OPTION}`);let o=t.readOption(e,r,t.MAJOR_MODE_OPTION);if(o){if(D)throw Error(`${t.MAJOR_MODE_OPTION} can only be provided once`);w=t.parseMajorMode(o.value,t.MAJOR_MODE_OPTION),D=!0,r=o.nextIndex;continue}let s=t.readOption(e,r,t.PROFILE_OPTION);if(s){if(f)throw Error(`${t.PROFILE_OPTION} can only be provided once`);u=t.parseProfileValue(s.value,t.PROFILE_OPTION),f=!0,r=s.nextIndex;continue}let c=t.readOption(e,r,`--domains`)??t.readOption(e,r,`--domain`);if(c){O.push(...t.parseCsv(c.value)),r=c.nextIndex;continue}let l=t.readOption(e,r,`--emit-mcp`);if(l){Y=n.default.resolve(a,l.value),r=l.nextIndex;continue}let d=t.readOption(e,r,`--plugin-dir`);if(d){j.push(d.value),r=d.nextIndex;continue}let h=t.readOption(e,r,t.ADD_DIRECTORY_OPTION);if(h){M.push(h.value),r=h.nextIndex;continue}let g=t.readOption(e,r,`--preset`);if(g){F=T(g.value),r=g.nextIndex;continue}let E=t.readOption(e,r,`--cwd`)??t.readOption(e,r,`--cd`);if(E){P=n.default.resolve(a,E.value),r=E.nextIndex;continue}let k=t.readOption(e,r,`--effort`);if(k){k.inline?N.push(`${m}=${k.value}`):N.push(m,k.value),r=k.nextIndex;continue}let A=t.readOption(e,r,`--output-format`);if(A){let e=A.value;if(e===y)I=y;else{let t=e===`stream-json`?b:e;A.inline?N.push(`${p}=${t}`):N.push(p,t)}r=A.nextIndex;continue}i===v?L=!0:i===`--explain`?J=!0:i===`--automation`?z=!0:i===`--mute`?R=!0:i===x?B=!0:i===`--sandbox`?V=!0:i===`--allow-protected-writes`?H=!0:i===`--hooks`?U=!0:i===`--mcp`?W=!0:i===`--agents`?G=!0:i===`--no-hooks`?U=!1:i===`--no-mcp`?W=!1:i===`--no-agents`?G=!1:i===S||i===`-h`?K=!0:i===C||i===`-v`?q=!0:i!==`--verbose`&&i!==`--dangerously-skip-permissions`&&N.push(i)}if(L&&O.length>0)throw Error(`${v} cannot be combined with ${t.DOMAINS_OPTION}`);if(!L&&O.length===0&&j.length===0&&O.push(...(0,r.defaultDomainsForMajorMode)(w,i,c)),z&&(E(N,h,`-p`)||N.unshift(h),E(N,p)||N.unshift(p,b),E(N,g,`-a`)||N.unshift(g)),B&&(z||I===y||E(N,h,`-p`,p)))throw Error(`${x} only supports interactive Pi mode`);return k(F,N,i),{options:{cwd:P,profile:u,domains:O,majorMode:w,explain:J,emitMcp:Y,pluginDirectories:j.map(e=>n.default.resolve(a,e)),additionalDirectories:[...new Set([...t.resolveAdditionalDirectories(i,a),...M.map(e=>n.default.resolve(a,e))])],preset:F,outputFormat:I,mute:R,automation:z,autoStop:B,sandbox:V,allowProtectedWrites:H,hooks:U,mcp:W,agents:G,piArgs:N},help:K,version:q}}exports.parseHarnessArgs=j;
1
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./matrixOptions.cjs");let n=require("node:path");n=e.__toESM(n,1);let r=require("@agimon-ai/doompi-config/domains");const i=`kimi-for-coding`,a=`kimi-for-coding-highspeed`,o=`kimi-k2.6`,s=`default`,c=`kimi`,l=`ollama`,u=`ollama/`,d=`native`,f=`--model`,p=`--mode`,m=`--thinking`,h=`--print`,g=`--approve`,_=`--profiles`,v=`--no-domains`,y=`vibe-lint`,b=`json`,x=`--auto-stop`,S=`--help`,C=`--version`,w=new Map([[`k2p5`,i],[`k2p6`,i],[`k2p7`,i],[`kimi-k2.5`,i],[o,i],[`kimi-k2.7-code`,i],[i,i],[a,a]]);function T(e){if(e===s||e===c||e===l)return e;throw Error(`Unsupported preset: ${e}`)}function E(e,...t){return e.some(e=>t.includes(e)||t.some(t=>e.startsWith(`${t}=`)))}function D(e){for(let t=0;t<e.length;t+=1){if(e[t]===f||e[t]===`-m`){let n=e[t+1];if(n)return{index:t,value:n,inline:!1}}if(e[t]?.startsWith(`${f}=`))return{index:t,value:e[t].slice(`${f}=`.length),inline:!0}}}function O(e,t){let n=D(e);n?n.inline?e[n.index]=`${f}=${t}`:e[n.index+1]=t:e.unshift(f,t)}function k(e,t,n){let r=D(t);if(e===c){let e=r?.value??n.KIMI_CODE_MODEL??i,a=e.includes(`/`)?e.slice(e.indexOf(`/`)+1):e;O(t,`kimi-coding/${w.get(a)??a}`)}if(e===l){let e=r?.value??n.OLLAMA_CLAUDE_MODEL??o,i=e.startsWith(u)?e.slice(7):e;O(t,`${u}${i.includes(`:`)?i:`${i}:cloud`}`)}}function A(e,n){let r=e.some(e=>e===S||e===`-h`),i=e.some(e=>e===C||e===`-v`);if(r||i)return{options:{cwd:n,profile:void 0,domains:[],majorMode:t.DEFAULT_MAJOR_MODE,explain:!1,emitMcp:void 0,pluginDirectories:[],additionalDirectories:[],preset:s,outputFormat:d,mute:!1,automation:!1,autoStop:!1,sandbox:!1,allowProtectedWrites:!1,hooks:!0,mcp:!0,agents:!0,piArgs:[]},help:r,version:i}}function j(e,i=process.env,a=process.cwd(),o=t.DEFAULT_MAJOR_MODE,c,l){let u=A(e,a);if(u)return u;let f=t.resolveInheritedProfile(i)??l,w=!1,D=t.resolveInheritedMajorMode(i,o),O=!1,j=[],M=[],N=[],P=[],F=a,I=T(i.DOOMPI_PRESET??s),L=d,R=!1,z=!1,B=!1,V=!1,H=!1,U=!1,W=!0,G=!0,K=!0,q=!1,J=!1,Y=!1,X;for(let r=0;r<e.length;r+=1){let i=e[r];if(t.matchesOption(i,`--target`))throw Error(`${t.REMOVED_TARGET_OPTION} was replaced by ${t.MAJOR_MODE_OPTION}`);if(t.matchesOption(i,`--layer`))throw Error(`${t.REMOVED_LAYER_OPTION} was replaced by ${t.MAJOR_MODE_OPTION}`);if(t.matchesOption(i,`--layers`))throw Error(`${t.REMOVED_LAYERS_OPTION} was removed; select one major mode with ${t.MAJOR_MODE_OPTION}`);if(t.matchesOption(i,_))throw Error(`${_} was replaced by ${t.DOMAINS_OPTION}`);let o=t.readOption(e,r,t.MAJOR_MODE_OPTION);if(o){if(O)throw Error(`${t.MAJOR_MODE_OPTION} can only be provided once`);D=t.parseMajorMode(o.value,t.MAJOR_MODE_OPTION),O=!0,r=o.nextIndex;continue}let s=t.readOption(e,r,t.PROFILE_OPTION);if(s){if(w)throw Error(`${t.PROFILE_OPTION} can only be provided once`);f=t.parseProfileValue(s.value,t.PROFILE_OPTION),w=!0,r=s.nextIndex;continue}let c=t.readOption(e,r,`--domains`)??t.readOption(e,r,`--domain`);if(c){j.push(...t.parseCsv(c.value)),r=c.nextIndex;continue}let l=t.readOption(e,r,`--emit-mcp`);if(l){X=n.default.resolve(a,l.value),r=l.nextIndex;continue}let u=t.readOption(e,r,`--plugin-dir`);if(u){M.push(u.value),r=u.nextIndex;continue}let d=t.readOption(e,r,t.ADD_DIRECTORY_OPTION);if(d){N.push(d.value),r=d.nextIndex;continue}let h=t.readOption(e,r,`--preset`);if(h){I=T(h.value),r=h.nextIndex;continue}let g=t.readOption(e,r,`--cwd`)??t.readOption(e,r,`--cd`);if(g){F=n.default.resolve(a,g.value),r=g.nextIndex;continue}let E=t.readOption(e,r,`--effort`);if(E){E.inline?P.push(`${m}=${E.value}`):P.push(m,E.value),r=E.nextIndex;continue}let k=t.readOption(e,r,`--output-format`);if(k){let e=k.value;if(e===y)L=y;else{let t=e===`stream-json`?b:e;k.inline?P.push(`${p}=${t}`):P.push(p,t)}r=k.nextIndex;continue}i===v?R=!0:i===`--explain`?Y=!0:i===`--automation`?B=!0:i===`--mute`?z=!0:i===x?V=!0:i===`--sandbox`?H=!0:i===`--allow-protected-writes`?U=!0:i===`--hooks`?W=!0:i===`--mcp`?G=!0:i===`--agents`?K=!0:i===`--no-hooks`?W=!1:i===`--no-mcp`?G=!1:i===`--no-agents`?K=!1:i===S||i===`-h`?q=!0:i===C||i===`-v`?J=!0:i!==`--verbose`&&i!==`--dangerously-skip-permissions`&&P.push(i)}if(R&&j.length>0)throw Error(`${v} cannot be combined with ${t.DOMAINS_OPTION}`);if(!R&&j.length===0&&M.length===0&&j.push(...(0,r.defaultDomainsForMajorMode)(D,i,c)),B&&(E(P,h,`-p`)||P.unshift(h),E(P,p)||P.unshift(p,b),E(P,g,`-a`)||P.unshift(g)),V&&(B||L===y||E(P,h,`-p`,p)))throw Error(`${x} only supports interactive Pi mode`);return k(I,P,i),{options:{cwd:F,profile:f,domains:j,majorMode:D,explain:Y,emitMcp:X,pluginDirectories:M.map(e=>n.default.resolve(a,e)),additionalDirectories:[...new Set([...t.resolveAdditionalDirectories(i,a),...N.map(e=>n.default.resolve(a,e))])],preset:I,outputFormat:L,mute:z,automation:B,autoStop:V,sandbox:H,allowProtectedWrites:U,hooks:W,mcp:G,agents:K,piArgs:P},help:q,version:J}}exports.parseHarnessArgs=j;
2
2
  //# sourceMappingURL=options.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.cjs","names":["DEFAULT_MAJOR_MODE","resolveInheritedProfile","resolveInheritedMajorMode","matchesOption","REMOVED_TARGET_OPTION","MAJOR_MODE_OPTION","REMOVED_LAYER_OPTION","REMOVED_LAYERS_OPTION","DOMAINS_OPTION","readOption","parseMajorMode","PROFILE_OPTION","parseProfileValue","parseCsv","path","ADD_DIRECTORY_OPTION","defaultDomainsForMajorMode","resolveAdditionalDirectories"],"sources":["../../../../src/commands/cli/options.ts"],"sourcesContent":["import path from 'node:path';\nimport type { HarnessOutputFormat, HarnessPreset, ParsedHarnessArgs } from '../../types/interfaces/harness';\nimport { defaultDomainsForMajorMode } from '@agimon-ai/doompi-config/domains';\nimport {\n ADD_DIRECTORY_OPTION,\n DEFAULT_MAJOR_MODE,\n DOMAIN_OPTION,\n DOMAINS_OPTION,\n DOOMPI_PRESET_ENV,\n MAJOR_MODE_OPTION,\n matchesOption,\n PROFILE_OPTION,\n parseCsv,\n parseMajorMode,\n parseProfileValue,\n REMOVED_LAYER_OPTION,\n REMOVED_LAYERS_OPTION,\n REMOVED_TARGET_OPTION,\n readOption,\n resolveAdditionalDirectories,\n resolveInheritedMajorMode,\n resolveInheritedProfile,\n} from './matrixOptions.ts';\n\nconst KIMI_FOR_CODING = 'kimi-for-coding';\nconst KIMI_FOR_CODING_HIGHSPEED = 'kimi-for-coding-highspeed';\nconst KIMI_K2_6 = 'kimi-k2.6';\nconst DEFAULT_PRESET = 'default';\nconst KIMI_PRESET = 'kimi';\nconst OLLAMA_PRESET = 'ollama';\nconst OLLAMA_PREFIX = 'ollama/';\nconst KIMI_CODING_PREFIX = 'kimi-coding/';\nconst CLOUD_SUFFIX = ':cloud';\nconst NATIVE_FORMAT = 'native';\nconst KIMI_CODE_MODEL_ENV = 'KIMI_CODE_MODEL';\nconst OLLAMA_CLAUDE_MODEL_ENV = 'OLLAMA_CLAUDE_MODEL';\nconst MODEL_OPTION = '--model';\nconst MODEL_SHORT_OPTION = '-m';\nconst MODE_OPTION = '--mode';\nconst THINKING_OPTION = '--thinking';\nconst PRINT_OPTION = '--print';\nconst PRINT_SHORT_OPTION = '-p';\nconst APPROVE_OPTION = '--approve';\nconst APPROVE_SHORT_OPTION = '-a';\nconst PROFILES_OPTION = '--profiles';\nconst NO_DOMAINS_OPTION = '--no-domains';\nconst PRESET_OPTION = '--preset';\nconst EFFORT_OPTION = '--effort';\nconst OUTPUT_FORMAT_OPTION = '--output-format';\nconst MUTE_OPTION = '--mute';\nconst VIBE_LINT_FORMAT = 'vibe-lint';\nconst STREAM_JSON_FORMAT = 'stream-json';\nconst JSON_FORMAT = 'json';\nconst EXPLAIN_OPTION = '--explain';\nconst EMIT_MCP_OPTION = '--emit-mcp';\nconst PLUGIN_DIRECTORY_OPTION = '--plugin-dir';\nconst CWD_OPTION = '--cwd';\nconst CD_OPTION = '--cd';\nconst AUTOMATION_OPTION = '--automation';\nconst AUTO_STOP_OPTION = '--auto-stop';\nconst SANDBOX_OPTION = '--sandbox';\nconst ALLOW_PROTECTED_WRITES_OPTION = '--allow-protected-writes';\nconst HOOKS_OPTION = '--hooks';\nconst MCP_OPTION = '--mcp';\nconst AGENTS_OPTION = '--agents';\nconst NO_HOOKS_OPTION = '--no-hooks';\nconst NO_MCP_OPTION = '--no-mcp';\nconst NO_AGENTS_OPTION = '--no-agents';\nconst VERBOSE_OPTION = '--verbose';\nconst DANGEROUSLY_SKIP_PERMISSIONS_OPTION = '--dangerously-skip-permissions';\nconst HELP_OPTION = '--help';\nconst HELP_SHORT_OPTION = '-h';\nconst VERSION_OPTION = '--version';\nconst VERSION_SHORT_OPTION = '-v';\n\nconst KIMI_ALIASES = new Map([\n ['k2p5', KIMI_FOR_CODING],\n ['k2p6', KIMI_FOR_CODING],\n ['k2p7', KIMI_FOR_CODING],\n ['kimi-k2.5', KIMI_FOR_CODING],\n [KIMI_K2_6, KIMI_FOR_CODING],\n ['kimi-k2.7-code', KIMI_FOR_CODING],\n [KIMI_FOR_CODING, KIMI_FOR_CODING],\n [KIMI_FOR_CODING_HIGHSPEED, KIMI_FOR_CODING_HIGHSPEED],\n]);\n\nfunction parsePreset(value: string): HarnessPreset {\n if (value === DEFAULT_PRESET || value === KIMI_PRESET || value === OLLAMA_PRESET) return value;\n throw new Error(`Unsupported preset: ${value}`);\n}\n\nfunction hasOption(args: string[], ...names: string[]): boolean {\n return args.some((arg) => names.includes(arg) || names.some((name) => arg.startsWith(`${name}=`)));\n}\n\nfunction modelValue(args: string[]): { index: number; value: string; inline: boolean } | undefined {\n for (let index = 0; index < args.length; index += 1) {\n if (args[index] === MODEL_OPTION || args[index] === MODEL_SHORT_OPTION) {\n const value = args[index + 1];\n if (value) return { index, value, inline: false };\n }\n if (args[index]?.startsWith(`${MODEL_OPTION}=`)) {\n return { index, value: args[index].slice(`${MODEL_OPTION}=`.length), inline: true };\n }\n }\n return undefined;\n}\n\nfunction replaceModel(args: string[], value: string): void {\n const selected = modelValue(args);\n if (!selected) {\n args.unshift(MODEL_OPTION, value);\n } else if (selected.inline) {\n args[selected.index] = `${MODEL_OPTION}=${value}`;\n } else {\n args[selected.index + 1] = value;\n }\n}\n\nfunction normalizeProviderArgs(preset: HarnessPreset, piArgs: string[], environment: NodeJS.ProcessEnv): void {\n const selected = modelValue(piArgs);\n if (preset === KIMI_PRESET) {\n const value = selected?.value ?? environment[KIMI_CODE_MODEL_ENV] ?? KIMI_FOR_CODING;\n const unqualified = value.includes('/') ? value.slice(value.indexOf('/') + 1) : value;\n replaceModel(piArgs, `${KIMI_CODING_PREFIX}${KIMI_ALIASES.get(unqualified) ?? unqualified}`);\n }\n if (preset === OLLAMA_PRESET) {\n const value = selected?.value ?? environment[OLLAMA_CLAUDE_MODEL_ENV] ?? KIMI_K2_6;\n const unqualified = value.startsWith(OLLAMA_PREFIX) ? value.slice(OLLAMA_PREFIX.length) : value;\n replaceModel(\n piArgs,\n `${OLLAMA_PREFIX}${unqualified.includes(':') ? unqualified : `${unqualified}${CLOUD_SUFFIX}`}`,\n );\n }\n}\n\n/**\n * Answers `--help` and `--version` without reading the environment.\n *\n * The caller only looks at `help` and `version` for these, and never launches,\n * so the options carry defaults rather than a resolved matrix. This exists so a\n * stale export cannot break the one command that explains how to fix it.\n */\nfunction parseInformationalArgs(args: string[], currentDirectory: string): ParsedHarnessArgs | undefined {\n const help = args.some((arg) => arg === HELP_OPTION || arg === HELP_SHORT_OPTION);\n const version = args.some((arg) => arg === VERSION_OPTION || arg === VERSION_SHORT_OPTION);\n if (!help && !version) return undefined;\n return {\n options: {\n cwd: currentDirectory,\n profile: undefined,\n domains: [],\n majorMode: DEFAULT_MAJOR_MODE,\n explain: false,\n emitMcp: undefined,\n pluginDirectories: [],\n additionalDirectories: [],\n preset: DEFAULT_PRESET,\n outputFormat: NATIVE_FORMAT,\n mute: false,\n automation: false,\n autoStop: false,\n sandbox: false,\n allowProtectedWrites: false,\n hooks: true,\n mcp: true,\n agents: true,\n piArgs: [],\n },\n help,\n version,\n };\n}\n\nexport function parseHarnessArgs(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n defaultMajorMode: string = DEFAULT_MAJOR_MODE,\n defaultDomains?: readonly string[],\n): ParsedHarnessArgs {\n const informational = parseInformationalArgs(args, currentDirectory);\n if (informational) return informational;\n\n let profile = resolveInheritedProfile(environment);\n let profileProvided = false;\n let majorMode = resolveInheritedMajorMode(environment, defaultMajorMode);\n let majorModeProvided = false;\n const domains: string[] = [];\n // Directory options are collected verbatim and resolved once after the loop,\n // so a relative path means the same thing regardless of where --cwd appears\n // in the argument list.\n const pluginDirectoryValues: string[] = [];\n const additionalDirectoryValues: string[] = [];\n const piArgs: string[] = [];\n let cwd = currentDirectory;\n let preset = parsePreset(environment[DOOMPI_PRESET_ENV] ?? DEFAULT_PRESET);\n let outputFormat: HarnessOutputFormat = NATIVE_FORMAT;\n let domainsDisabled = false;\n let mute = false;\n let automation = false;\n let autoStop = false;\n let sandbox = false;\n let allowProtectedWrites = false;\n let hooks = true;\n let mcp = true;\n let agents = true;\n let help = false;\n let version = false;\n let explain = false;\n let emitMcp: string | undefined;\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!;\n\n if (matchesOption(arg, REMOVED_TARGET_OPTION)) {\n throw new Error(`${REMOVED_TARGET_OPTION} was replaced by ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, REMOVED_LAYER_OPTION)) {\n throw new Error(`${REMOVED_LAYER_OPTION} was replaced by ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, REMOVED_LAYERS_OPTION)) {\n throw new Error(`${REMOVED_LAYERS_OPTION} was removed; select one major mode with ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, PROFILES_OPTION)) {\n throw new Error(`${PROFILES_OPTION} was replaced by ${DOMAINS_OPTION}`);\n }\n\n const majorModeMatch = readOption(args, index, MAJOR_MODE_OPTION);\n if (majorModeMatch) {\n if (majorModeProvided) throw new Error(`${MAJOR_MODE_OPTION} can only be provided once`);\n majorMode = parseMajorMode(majorModeMatch.value, MAJOR_MODE_OPTION);\n majorModeProvided = true;\n index = majorModeMatch.nextIndex;\n continue;\n }\n\n const profileMatch = readOption(args, index, PROFILE_OPTION);\n if (profileMatch) {\n if (profileProvided) throw new Error(`${PROFILE_OPTION} can only be provided once`);\n profile = parseProfileValue(profileMatch.value, PROFILE_OPTION);\n profileProvided = true;\n index = profileMatch.nextIndex;\n continue;\n }\n\n const domainMatch = readOption(args, index, DOMAINS_OPTION) ?? readOption(args, index, DOMAIN_OPTION);\n if (domainMatch) {\n domains.push(...parseCsv(domainMatch.value));\n index = domainMatch.nextIndex;\n continue;\n }\n\n const emitMcpMatch = readOption(args, index, EMIT_MCP_OPTION);\n if (emitMcpMatch) {\n emitMcp = path.resolve(currentDirectory, emitMcpMatch.value);\n index = emitMcpMatch.nextIndex;\n continue;\n }\n\n const pluginDirectoryMatch = readOption(args, index, PLUGIN_DIRECTORY_OPTION);\n if (pluginDirectoryMatch) {\n pluginDirectoryValues.push(pluginDirectoryMatch.value);\n index = pluginDirectoryMatch.nextIndex;\n continue;\n }\n\n const addDirectoryMatch = readOption(args, index, ADD_DIRECTORY_OPTION);\n if (addDirectoryMatch) {\n additionalDirectoryValues.push(addDirectoryMatch.value);\n index = addDirectoryMatch.nextIndex;\n continue;\n }\n\n const presetMatch = readOption(args, index, PRESET_OPTION);\n if (presetMatch) {\n preset = parsePreset(presetMatch.value);\n index = presetMatch.nextIndex;\n continue;\n }\n\n const cwdMatch = readOption(args, index, CWD_OPTION) ?? readOption(args, index, CD_OPTION);\n if (cwdMatch) {\n cwd = path.resolve(currentDirectory, cwdMatch.value);\n index = cwdMatch.nextIndex;\n continue;\n }\n\n const effortMatch = readOption(args, index, EFFORT_OPTION);\n if (effortMatch) {\n if (effortMatch.inline) piArgs.push(`${THINKING_OPTION}=${effortMatch.value}`);\n else piArgs.push(THINKING_OPTION, effortMatch.value);\n index = effortMatch.nextIndex;\n continue;\n }\n\n const outputFormatMatch = readOption(args, index, OUTPUT_FORMAT_OPTION);\n if (outputFormatMatch) {\n const requested = outputFormatMatch.value;\n if (requested === VIBE_LINT_FORMAT) {\n outputFormat = VIBE_LINT_FORMAT;\n } else {\n const mode = requested === STREAM_JSON_FORMAT ? JSON_FORMAT : requested;\n if (outputFormatMatch.inline) piArgs.push(`${MODE_OPTION}=${mode}`);\n else piArgs.push(MODE_OPTION, mode);\n }\n index = outputFormatMatch.nextIndex;\n continue;\n }\n\n if (arg === NO_DOMAINS_OPTION) domainsDisabled = true;\n else if (arg === EXPLAIN_OPTION) explain = true;\n else if (arg === AUTOMATION_OPTION) automation = true;\n else if (arg === MUTE_OPTION) mute = true;\n else if (arg === AUTO_STOP_OPTION) autoStop = true;\n else if (arg === SANDBOX_OPTION) sandbox = true;\n else if (arg === ALLOW_PROTECTED_WRITES_OPTION) allowProtectedWrites = true;\n else if (arg === HOOKS_OPTION) hooks = true;\n else if (arg === MCP_OPTION) mcp = true;\n else if (arg === AGENTS_OPTION) agents = true;\n else if (arg === NO_HOOKS_OPTION) hooks = false;\n else if (arg === NO_MCP_OPTION) mcp = false;\n else if (arg === NO_AGENTS_OPTION) agents = false;\n else if (arg === HELP_OPTION || arg === HELP_SHORT_OPTION) help = true;\n else if (arg === VERSION_OPTION || arg === VERSION_SHORT_OPTION) version = true;\n // Accepted for Claude Code compatibility and deliberately not forwarded.\n else if (arg !== VERBOSE_OPTION && arg !== DANGEROUSLY_SKIP_PERMISSIONS_OPTION) piArgs.push(arg);\n }\n\n if (domainsDisabled && domains.length > 0) {\n throw new Error(`${NO_DOMAINS_OPTION} cannot be combined with ${DOMAINS_OPTION}`);\n }\n if (!domainsDisabled && domains.length === 0 && pluginDirectoryValues.length === 0) {\n domains.push(...defaultDomainsForMajorMode(majorMode, environment, defaultDomains));\n }\n if (automation) {\n if (!hasOption(piArgs, PRINT_OPTION, PRINT_SHORT_OPTION)) piArgs.unshift(PRINT_OPTION);\n if (!hasOption(piArgs, MODE_OPTION)) piArgs.unshift(MODE_OPTION, JSON_FORMAT);\n if (!hasOption(piArgs, APPROVE_OPTION, APPROVE_SHORT_OPTION)) piArgs.unshift(APPROVE_OPTION);\n }\n if (\n autoStop &&\n (automation ||\n outputFormat === VIBE_LINT_FORMAT ||\n hasOption(piArgs, PRINT_OPTION, PRINT_SHORT_OPTION, MODE_OPTION))\n ) {\n throw new Error(`${AUTO_STOP_OPTION} only supports interactive Pi mode`);\n }\n normalizeProviderArgs(preset, piArgs, environment);\n\n return {\n options: {\n cwd,\n profile,\n domains,\n majorMode,\n explain,\n emitMcp,\n pluginDirectories: pluginDirectoryValues.map((value) => path.resolve(currentDirectory, value)),\n additionalDirectories: [\n ...new Set([\n ...resolveAdditionalDirectories(environment, currentDirectory),\n ...additionalDirectoryValues.map((value) => path.resolve(currentDirectory, value)),\n ]),\n ],\n preset,\n outputFormat,\n mute,\n automation,\n autoStop,\n sandbox,\n allowProtectedWrites,\n hooks,\n mcp,\n agents,\n piArgs,\n },\n help,\n version,\n };\n}\n"],"mappings":"0LAwBA,MAAM,EAAkB,kBAClB,EAA4B,4BAC5B,EAAY,YACZ,EAAiB,UACjB,EAAc,OACd,EAAgB,SAChB,EAAgB,UAGhB,EAAgB,SAGhB,EAAe,UAEf,EAAc,SACd,EAAkB,aAClB,EAAe,UAEf,EAAiB,YAEjB,EAAkB,aAClB,EAAoB,eAKpB,EAAmB,YAEnB,EAAc,OAOd,EAAmB,cAWnB,EAAc,SAEd,EAAiB,YAGjB,EAAe,IAAI,IAAI,CAC3B,CAAC,OAAQ,CAAe,EACxB,CAAC,OAAQ,CAAe,EACxB,CAAC,OAAQ,CAAe,EACxB,CAAC,YAAa,CAAe,EAC7B,CAAC,EAAW,CAAe,EAC3B,CAAC,iBAAkB,CAAe,EAClC,CAAC,EAAiB,CAAe,EACjC,CAAC,EAA2B,CAAyB,CACvD,CAAC,EAED,SAAS,EAAY,EAA8B,CACjD,GAAI,IAAU,GAAkB,IAAU,GAAe,IAAU,EAAe,OAAO,EACzF,MAAU,MAAM,uBAAuB,GAAO,CAChD,CAEA,SAAS,EAAU,EAAgB,GAAG,EAA0B,CAC9D,OAAO,EAAK,KAAM,GAAQ,EAAM,SAAS,CAAG,GAAK,EAAM,KAAM,GAAS,E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JOR_MODE_OPTION","REMOVED_LAYER_OPTION","REMOVED_LAYERS_OPTION","DOMAINS_OPTION","readOption","parseMajorMode","PROFILE_OPTION","parseProfileValue","parseCsv","path","ADD_DIRECTORY_OPTION","defaultDomainsForMajorMode","resolveAdditionalDirectories"],"sources":["../../../../src/commands/cli/options.ts"],"sourcesContent":["import path from 'node:path';\nimport type { HarnessOutputFormat, HarnessPreset, ParsedHarnessArgs } from '../../types/interfaces/harness';\nimport { defaultDomainsForMajorMode } from '@agimon-ai/doompi-config/domains';\nimport {\n ADD_DIRECTORY_OPTION,\n DEFAULT_MAJOR_MODE,\n DOMAIN_OPTION,\n DOMAINS_OPTION,\n DOOMPI_PRESET_ENV,\n MAJOR_MODE_OPTION,\n matchesOption,\n PROFILE_OPTION,\n parseCsv,\n parseMajorMode,\n parseProfileValue,\n REMOVED_LAYER_OPTION,\n REMOVED_LAYERS_OPTION,\n REMOVED_TARGET_OPTION,\n readOption,\n resolveAdditionalDirectories,\n resolveInheritedMajorMode,\n resolveInheritedProfile,\n} from './matrixOptions.ts';\n\nconst KIMI_FOR_CODING = 'kimi-for-coding';\nconst KIMI_FOR_CODING_HIGHSPEED = 'kimi-for-coding-highspeed';\nconst KIMI_K2_6 = 'kimi-k2.6';\nconst DEFAULT_PRESET = 'default';\nconst KIMI_PRESET = 'kimi';\nconst OLLAMA_PRESET = 'ollama';\nconst OLLAMA_PREFIX = 'ollama/';\nconst KIMI_CODING_PREFIX = 'kimi-coding/';\nconst CLOUD_SUFFIX = ':cloud';\nconst NATIVE_FORMAT = 'native';\nconst KIMI_CODE_MODEL_ENV = 'KIMI_CODE_MODEL';\nconst OLLAMA_CLAUDE_MODEL_ENV = 'OLLAMA_CLAUDE_MODEL';\nconst MODEL_OPTION = '--model';\nconst MODEL_SHORT_OPTION = '-m';\nconst MODE_OPTION = '--mode';\nconst THINKING_OPTION = '--thinking';\nconst PRINT_OPTION = '--print';\nconst PRINT_SHORT_OPTION = '-p';\nconst APPROVE_OPTION = '--approve';\nconst APPROVE_SHORT_OPTION = '-a';\nconst PROFILES_OPTION = '--profiles';\nconst NO_DOMAINS_OPTION = '--no-domains';\nconst PRESET_OPTION = '--preset';\nconst EFFORT_OPTION = '--effort';\nconst OUTPUT_FORMAT_OPTION = '--output-format';\nconst MUTE_OPTION = '--mute';\nconst VIBE_LINT_FORMAT = 'vibe-lint';\nconst STREAM_JSON_FORMAT = 'stream-json';\nconst JSON_FORMAT = 'json';\nconst EXPLAIN_OPTION = '--explain';\nconst EMIT_MCP_OPTION = '--emit-mcp';\nconst PLUGIN_DIRECTORY_OPTION = '--plugin-dir';\nconst CWD_OPTION = '--cwd';\nconst CD_OPTION = '--cd';\nconst AUTOMATION_OPTION = '--automation';\nconst AUTO_STOP_OPTION = '--auto-stop';\nconst SANDBOX_OPTION = '--sandbox';\nconst ALLOW_PROTECTED_WRITES_OPTION = '--allow-protected-writes';\nconst HOOKS_OPTION = '--hooks';\nconst MCP_OPTION = '--mcp';\nconst AGENTS_OPTION = '--agents';\nconst NO_HOOKS_OPTION = '--no-hooks';\nconst NO_MCP_OPTION = '--no-mcp';\nconst NO_AGENTS_OPTION = '--no-agents';\nconst VERBOSE_OPTION = '--verbose';\nconst DANGEROUSLY_SKIP_PERMISSIONS_OPTION = '--dangerously-skip-permissions';\nconst HELP_OPTION = '--help';\nconst HELP_SHORT_OPTION = '-h';\nconst VERSION_OPTION = '--version';\nconst VERSION_SHORT_OPTION = '-v';\n\nconst KIMI_ALIASES = new Map([\n ['k2p5', KIMI_FOR_CODING],\n ['k2p6', KIMI_FOR_CODING],\n ['k2p7', KIMI_FOR_CODING],\n ['kimi-k2.5', KIMI_FOR_CODING],\n [KIMI_K2_6, KIMI_FOR_CODING],\n ['kimi-k2.7-code', KIMI_FOR_CODING],\n [KIMI_FOR_CODING, KIMI_FOR_CODING],\n [KIMI_FOR_CODING_HIGHSPEED, KIMI_FOR_CODING_HIGHSPEED],\n]);\n\nfunction parsePreset(value: string): HarnessPreset {\n if (value === DEFAULT_PRESET || value === KIMI_PRESET || value === OLLAMA_PRESET) return value;\n throw new Error(`Unsupported preset: ${value}`);\n}\n\nfunction hasOption(args: string[], ...names: string[]): boolean {\n return args.some((arg) => names.includes(arg) || names.some((name) => arg.startsWith(`${name}=`)));\n}\n\nfunction modelValue(args: string[]): { index: number; value: string; inline: boolean } | undefined {\n for (let index = 0; index < args.length; index += 1) {\n if (args[index] === MODEL_OPTION || args[index] === MODEL_SHORT_OPTION) {\n const value = args[index + 1];\n if (value) return { index, value, inline: false };\n }\n if (args[index]?.startsWith(`${MODEL_OPTION}=`)) {\n return { index, value: args[index].slice(`${MODEL_OPTION}=`.length), inline: true };\n }\n }\n return undefined;\n}\n\nfunction replaceModel(args: string[], value: string): void {\n const selected = modelValue(args);\n if (!selected) {\n args.unshift(MODEL_OPTION, value);\n } else if (selected.inline) {\n args[selected.index] = `${MODEL_OPTION}=${value}`;\n } else {\n args[selected.index + 1] = value;\n }\n}\n\nfunction normalizeProviderArgs(preset: HarnessPreset, piArgs: string[], environment: NodeJS.ProcessEnv): void {\n const selected = modelValue(piArgs);\n if (preset === KIMI_PRESET) {\n const value = selected?.value ?? environment[KIMI_CODE_MODEL_ENV] ?? KIMI_FOR_CODING;\n const unqualified = value.includes('/') ? value.slice(value.indexOf('/') + 1) : value;\n replaceModel(piArgs, `${KIMI_CODING_PREFIX}${KIMI_ALIASES.get(unqualified) ?? unqualified}`);\n }\n if (preset === OLLAMA_PRESET) {\n const value = selected?.value ?? environment[OLLAMA_CLAUDE_MODEL_ENV] ?? KIMI_K2_6;\n const unqualified = value.startsWith(OLLAMA_PREFIX) ? value.slice(OLLAMA_PREFIX.length) : value;\n replaceModel(\n piArgs,\n `${OLLAMA_PREFIX}${unqualified.includes(':') ? unqualified : `${unqualified}${CLOUD_SUFFIX}`}`,\n );\n }\n}\n\n/**\n * Answers `--help` and `--version` without reading the environment.\n *\n * The caller only looks at `help` and `version` for these, and never launches,\n * so the options carry defaults rather than a resolved matrix. This exists so a\n * stale export cannot break the one command that explains how to fix it.\n */\nfunction parseInformationalArgs(args: string[], currentDirectory: string): ParsedHarnessArgs | undefined {\n const help = args.some((arg) => arg === HELP_OPTION || arg === HELP_SHORT_OPTION);\n const version = args.some((arg) => arg === VERSION_OPTION || arg === VERSION_SHORT_OPTION);\n if (!help && !version) return undefined;\n return {\n options: {\n cwd: currentDirectory,\n profile: undefined,\n domains: [],\n majorMode: DEFAULT_MAJOR_MODE,\n explain: false,\n emitMcp: undefined,\n pluginDirectories: [],\n additionalDirectories: [],\n preset: DEFAULT_PRESET,\n outputFormat: NATIVE_FORMAT,\n mute: false,\n automation: false,\n autoStop: false,\n sandbox: false,\n allowProtectedWrites: false,\n hooks: true,\n mcp: true,\n agents: true,\n piArgs: [],\n },\n help,\n version,\n };\n}\n\nexport function parseHarnessArgs(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n defaultMajorMode: string = DEFAULT_MAJOR_MODE,\n defaultDomains?: readonly string[],\n defaultProfile?: string,\n): ParsedHarnessArgs {\n const informational = parseInformationalArgs(args, currentDirectory);\n if (informational) return informational;\n\n // An inherited profile wins: a nested run stays on the persona its parent\n // chose rather than snapping back to the repository default.\n let profile = resolveInheritedProfile(environment) ?? defaultProfile;\n let profileProvided = false;\n let majorMode = resolveInheritedMajorMode(environment, defaultMajorMode);\n let majorModeProvided = false;\n const domains: string[] = [];\n // Directory options are collected verbatim and resolved once after the loop,\n // so a relative path means the same thing regardless of where --cwd appears\n // in the argument list.\n const pluginDirectoryValues: string[] = [];\n const additionalDirectoryValues: string[] = [];\n const piArgs: string[] = [];\n let cwd = currentDirectory;\n let preset = parsePreset(environment[DOOMPI_PRESET_ENV] ?? DEFAULT_PRESET);\n let outputFormat: HarnessOutputFormat = NATIVE_FORMAT;\n let domainsDisabled = false;\n let mute = false;\n let automation = false;\n let autoStop = false;\n let sandbox = false;\n let allowProtectedWrites = false;\n let hooks = true;\n let mcp = true;\n let agents = true;\n let help = false;\n let version = false;\n let explain = false;\n let emitMcp: string | undefined;\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!;\n\n if (matchesOption(arg, REMOVED_TARGET_OPTION)) {\n throw new Error(`${REMOVED_TARGET_OPTION} was replaced by ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, REMOVED_LAYER_OPTION)) {\n throw new Error(`${REMOVED_LAYER_OPTION} was replaced by ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, REMOVED_LAYERS_OPTION)) {\n throw new Error(`${REMOVED_LAYERS_OPTION} was removed; select one major mode with ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, PROFILES_OPTION)) {\n throw new Error(`${PROFILES_OPTION} was replaced by ${DOMAINS_OPTION}`);\n }\n\n const majorModeMatch = readOption(args, index, MAJOR_MODE_OPTION);\n if (majorModeMatch) {\n if (majorModeProvided) throw new Error(`${MAJOR_MODE_OPTION} can only be provided once`);\n majorMode = parseMajorMode(majorModeMatch.value, MAJOR_MODE_OPTION);\n majorModeProvided = true;\n index = majorModeMatch.nextIndex;\n continue;\n }\n\n const profileMatch = readOption(args, index, PROFILE_OPTION);\n if (profileMatch) {\n if (profileProvided) throw new Error(`${PROFILE_OPTION} can only be provided once`);\n profile = parseProfileValue(profileMatch.value, PROFILE_OPTION);\n profileProvided = true;\n index = profileMatch.nextIndex;\n continue;\n }\n\n const domainMatch = readOption(args, index, DOMAINS_OPTION) ?? readOption(args, index, DOMAIN_OPTION);\n if (domainMatch) {\n domains.push(...parseCsv(domainMatch.value));\n index = domainMatch.nextIndex;\n continue;\n }\n\n const emitMcpMatch = readOption(args, index, EMIT_MCP_OPTION);\n if (emitMcpMatch) {\n emitMcp = path.resolve(currentDirectory, emitMcpMatch.value);\n index = emitMcpMatch.nextIndex;\n continue;\n }\n\n const pluginDirectoryMatch = readOption(args, index, PLUGIN_DIRECTORY_OPTION);\n if (pluginDirectoryMatch) {\n pluginDirectoryValues.push(pluginDirectoryMatch.value);\n index = pluginDirectoryMatch.nextIndex;\n continue;\n }\n\n const addDirectoryMatch = readOption(args, index, ADD_DIRECTORY_OPTION);\n if (addDirectoryMatch) {\n additionalDirectoryValues.push(addDirectoryMatch.value);\n index = addDirectoryMatch.nextIndex;\n continue;\n }\n\n const presetMatch = readOption(args, index, PRESET_OPTION);\n if (presetMatch) {\n preset = parsePreset(presetMatch.value);\n index = presetMatch.nextIndex;\n continue;\n }\n\n const cwdMatch = readOption(args, index, CWD_OPTION) ?? readOption(args, index, CD_OPTION);\n if (cwdMatch) {\n cwd = path.resolve(currentDirectory, cwdMatch.value);\n index = cwdMatch.nextIndex;\n continue;\n }\n\n const effortMatch = readOption(args, index, EFFORT_OPTION);\n if (effortMatch) {\n if (effortMatch.inline) piArgs.push(`${THINKING_OPTION}=${effortMatch.value}`);\n else piArgs.push(THINKING_OPTION, effortMatch.value);\n index = effortMatch.nextIndex;\n continue;\n }\n\n const outputFormatMatch = readOption(args, index, OUTPUT_FORMAT_OPTION);\n if (outputFormatMatch) {\n const requested = outputFormatMatch.value;\n if (requested === VIBE_LINT_FORMAT) {\n outputFormat = VIBE_LINT_FORMAT;\n } else {\n const mode = requested === STREAM_JSON_FORMAT ? JSON_FORMAT : requested;\n if (outputFormatMatch.inline) piArgs.push(`${MODE_OPTION}=${mode}`);\n else piArgs.push(MODE_OPTION, mode);\n }\n index = outputFormatMatch.nextIndex;\n continue;\n }\n\n if (arg === NO_DOMAINS_OPTION) domainsDisabled = true;\n else if (arg === EXPLAIN_OPTION) explain = true;\n else if (arg === AUTOMATION_OPTION) automation = true;\n else if (arg === MUTE_OPTION) mute = true;\n else if (arg === AUTO_STOP_OPTION) autoStop = true;\n else if (arg === SANDBOX_OPTION) sandbox = true;\n else if (arg === ALLOW_PROTECTED_WRITES_OPTION) allowProtectedWrites = true;\n else if (arg === HOOKS_OPTION) hooks = true;\n else if (arg === MCP_OPTION) mcp = true;\n else if (arg === AGENTS_OPTION) agents = true;\n else if (arg === NO_HOOKS_OPTION) hooks = false;\n else if (arg === NO_MCP_OPTION) mcp = false;\n else if (arg === NO_AGENTS_OPTION) agents = false;\n else if (arg === HELP_OPTION || arg === HELP_SHORT_OPTION) help = true;\n else if (arg === VERSION_OPTION || arg === VERSION_SHORT_OPTION) version = true;\n // Accepted for Claude Code compatibility and deliberately not forwarded.\n else if (arg !== VERBOSE_OPTION && arg !== DANGEROUSLY_SKIP_PERMISSIONS_OPTION) piArgs.push(arg);\n }\n\n if (domainsDisabled && domains.length > 0) {\n throw new Error(`${NO_DOMAINS_OPTION} cannot be combined with ${DOMAINS_OPTION}`);\n }\n if (!domainsDisabled && domains.length === 0 && pluginDirectoryValues.length === 0) {\n domains.push(...defaultDomainsForMajorMode(majorMode, environment, defaultDomains));\n }\n if (automation) {\n if (!hasOption(piArgs, PRINT_OPTION, PRINT_SHORT_OPTION)) piArgs.unshift(PRINT_OPTION);\n if (!hasOption(piArgs, MODE_OPTION)) piArgs.unshift(MODE_OPTION, JSON_FORMAT);\n if (!hasOption(piArgs, APPROVE_OPTION, APPROVE_SHORT_OPTION)) piArgs.unshift(APPROVE_OPTION);\n }\n if (\n autoStop &&\n (automation ||\n outputFormat === VIBE_LINT_FORMAT ||\n hasOption(piArgs, PRINT_OPTION, PRINT_SHORT_OPTION, MODE_OPTION))\n ) {\n throw new Error(`${AUTO_STOP_OPTION} only supports interactive Pi mode`);\n }\n normalizeProviderArgs(preset, piArgs, environment);\n\n return {\n options: {\n cwd,\n profile,\n domains,\n majorMode,\n explain,\n emitMcp,\n pluginDirectories: pluginDirectoryValues.map((value) => path.resolve(currentDirectory, value)),\n additionalDirectories: [\n ...new Set([\n ...resolveAdditionalDirectories(environment, currentDirectory),\n ...additionalDirectoryValues.map((value) => path.resolve(currentDirectory, value)),\n ]),\n ],\n preset,\n outputFormat,\n mute,\n automation,\n autoStop,\n sandbox,\n allowProtectedWrites,\n hooks,\n mcp,\n agents,\n piArgs,\n },\n help,\n version,\n };\n}\n"],"mappings":"0LAwBA,MAAM,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CAAY,EAChF,EAAU,EAAQ,CAAW,GAAG,EAAO,QAAQ,EAAa,CAAW,EACvE,EAAU,EAAQ,EAAgB,IAAoB,GAAG,EAAO,QAAQ,CAAc,GAG3F,IACC,GACC,IAAiB,GACjB,EAAU,EAAQ,EAAc,KAAoB,CAAW,GAEjE,MAAU,MAAM,GAAG,EAAiB,mCAAmC,EAIzE,OAFA,EAAsB,EAAQ,EAAQ,CAAW,EAE1C,CACL,QAAS,CACP,MACA,UACA,UACA,YACA,UACA,UACA,kBAAmB,EAAsB,IAAK,GAAUF,EAAAA,QAAK,QAAQ,EAAkB,CAAK,CAAC,EAC7F,sBAAuB,CACrB,GAAG,IAAI,IAAI,CACT,GAAGG,EAAAA,6BAA6B,EAAa,CAAgB,EAC7D,GAAG,EAA0B,IAAK,GAAUH,EAAAA,QAAK,QAAQ,EAAkB,CAAK,CAAC,CACnF,CAAC,CACH,EACA,SACA,eACA,OACA,aACA,WACA,UACA,uBACA,QACA,MACA,SACA,QACF,EACA,OACA,SACF,CACF"}
@@ -1,5 +1,5 @@
1
1
  import { ParsedHarnessArgs } from "../../types/interfaces/harness.cjs";
2
2
  //#region src/commands/cli/options.d.ts
3
- export declare function parseHarnessArgs(args: string[], environment?: NodeJS.ProcessEnv, currentDirectory?: string, defaultMajorMode?: string, defaultDomains?: readonly string[]): ParsedHarnessArgs;
3
+ export declare function parseHarnessArgs(args: string[], environment?: NodeJS.ProcessEnv, currentDirectory?: string, defaultMajorMode?: string, defaultDomains?: readonly string[], defaultProfile?: string): ParsedHarnessArgs;
4
4
  //#endregion
5
5
  //# sourceMappingURL=options.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.cts","names":[],"sources":["../../../../src/commands/cli/options.ts"],"mappings":";;wBA8KgB,iBACd,gBACA,cAAa,OAAO,YACpB,2BACA,2BACA,qCACC"}
1
+ {"version":3,"file":"options.d.cts","names":[],"sources":["../../../../src/commands/cli/options.ts"],"mappings":";;wBA8KgB,iBACd,gBACA,cAAa,OAAO,YACpB,2BACA,2BACA,oCACA,0BACC"}
@@ -1,5 +1,5 @@
1
1
  import { ParsedHarnessArgs } from "../../types/interfaces/harness.mjs";
2
2
  //#region src/commands/cli/options.d.ts
3
- export declare function parseHarnessArgs(args: string[], environment?: NodeJS.ProcessEnv, currentDirectory?: string, defaultMajorMode?: string, defaultDomains?: readonly string[]): ParsedHarnessArgs;
3
+ export declare function parseHarnessArgs(args: string[], environment?: NodeJS.ProcessEnv, currentDirectory?: string, defaultMajorMode?: string, defaultDomains?: readonly string[], defaultProfile?: string): ParsedHarnessArgs;
4
4
  //#endregion
5
5
  //# sourceMappingURL=options.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.mts","names":[],"sources":["../../../../src/commands/cli/options.ts"],"mappings":";;wBA8KgB,iBACd,gBACA,cAAa,OAAO,YACpB,2BACA,2BACA,qCACC"}
1
+ {"version":3,"file":"options.d.mts","names":[],"sources":["../../../../src/commands/cli/options.ts"],"mappings":";;wBA8KgB,iBACd,gBACA,cAAa,OAAO,YACpB,2BACA,2BACA,oCACA,0BACC"}
@@ -1,2 +1,2 @@
1
- import{ADD_DIRECTORY_OPTION as e,DEFAULT_MAJOR_MODE as t,DOMAINS_OPTION as n,MAJOR_MODE_OPTION as r,PROFILE_OPTION as i,REMOVED_LAYERS_OPTION as ee,REMOVED_LAYER_OPTION as te,REMOVED_TARGET_OPTION as ne,matchesOption as a,parseCsv as re,parseMajorMode as ie,parseProfileValue as ae,readOption as o,resolveAdditionalDirectories as s,resolveInheritedMajorMode as c,resolveInheritedProfile as l}from"./matrixOptions.mjs";import u from"node:path";import{defaultDomainsForMajorMode as d}from"@agimon-ai/doompi-config/domains";const f=`kimi-for-coding`,p=`kimi-for-coding-highspeed`,m=`kimi-k2.6`,h=`default`,g=`kimi`,_=`ollama`,v=`ollama/`,y=`native`,b=`--model`,x=`--mode`,S=`--thinking`,C=`--print`,w=`--approve`,T=`--profiles`,E=`--no-domains`,D=`vibe-lint`,O=`json`,k=`--auto-stop`,A=`--help`,j=`--version`,M=new Map([[`k2p5`,f],[`k2p6`,f],[`k2p7`,f],[`kimi-k2.5`,f],[m,f],[`kimi-k2.7-code`,f],[f,f],[p,p]]);function oe(e){if(e===h||e===g||e===_)return e;throw Error(`Unsupported preset: ${e}`)}function N(e,...t){return e.some(e=>t.includes(e)||t.some(t=>e.startsWith(`${t}=`)))}function P(e){for(let t=0;t<e.length;t+=1){if(e[t]===b||e[t]===`-m`){let n=e[t+1];if(n)return{index:t,value:n,inline:!1}}if(e[t]?.startsWith(`${b}=`))return{index:t,value:e[t].slice(`${b}=`.length),inline:!0}}}function F(e,t){let n=P(e);n?n.inline?e[n.index]=`${b}=${t}`:e[n.index+1]=t:e.unshift(b,t)}function se(e,t,n){let r=P(t);if(e===g){let e=r?.value??n.KIMI_CODE_MODEL??f,i=e.includes(`/`)?e.slice(e.indexOf(`/`)+1):e;F(t,`kimi-coding/${M.get(i)??i}`)}if(e===_){let e=r?.value??n.OLLAMA_CLAUDE_MODEL??m,i=e.startsWith(v)?e.slice(7):e;F(t,`${v}${i.includes(`:`)?i:`${i}:cloud`}`)}}function ce(e,n){let r=e.some(e=>e===A||e===`-h`),i=e.some(e=>e===j||e===`-v`);if(r||i)return{options:{cwd:n,profile:void 0,domains:[],majorMode:t,explain:!1,emitMcp:void 0,pluginDirectories:[],additionalDirectories:[],preset:h,outputFormat:y,mute:!1,automation:!1,autoStop:!1,sandbox:!1,allowProtectedWrites:!1,hooks:!0,mcp:!0,agents:!0,piArgs:[]},help:r,version:i}}function I(f,p=process.env,m=process.cwd(),g=t,_){let v=ce(f,m);if(v)return v;let b=l(p),M=!1,P=c(p,g),F=!1,I=[],L=[],R=[],z=[],B=m,V=oe(p.DOOMPI_PRESET??h),H=y,U=!1,W=!1,G=!1,K=!1,q=!1,J=!1,Y=!0,X=!0,Z=!0,Q=!1,le=!1,$=!1,ue;for(let t=0;t<f.length;t+=1){let s=f[t];if(a(s,`--target`))throw Error(`${ne} was replaced by ${r}`);if(a(s,`--layer`))throw Error(`${te} was replaced by ${r}`);if(a(s,`--layers`))throw Error(`${ee} was removed; select one major mode with ${r}`);if(a(s,T))throw Error(`${T} was replaced by ${n}`);let c=o(f,t,r);if(c){if(F)throw Error(`${r} can only be provided once`);P=ie(c.value,r),F=!0,t=c.nextIndex;continue}let l=o(f,t,i);if(l){if(M)throw Error(`${i} can only be provided once`);b=ae(l.value,i),M=!0,t=l.nextIndex;continue}let d=o(f,t,`--domains`)??o(f,t,`--domain`);if(d){I.push(...re(d.value)),t=d.nextIndex;continue}let p=o(f,t,`--emit-mcp`);if(p){ue=u.resolve(m,p.value),t=p.nextIndex;continue}let h=o(f,t,`--plugin-dir`);if(h){L.push(h.value),t=h.nextIndex;continue}let g=o(f,t,e);if(g){R.push(g.value),t=g.nextIndex;continue}let _=o(f,t,`--preset`);if(_){V=oe(_.value),t=_.nextIndex;continue}let v=o(f,t,`--cwd`)??o(f,t,`--cd`);if(v){B=u.resolve(m,v.value),t=v.nextIndex;continue}let y=o(f,t,`--effort`);if(y){y.inline?z.push(`${S}=${y.value}`):z.push(S,y.value),t=y.nextIndex;continue}let C=o(f,t,`--output-format`);if(C){let e=C.value;if(e===D)H=D;else{let t=e===`stream-json`?O:e;C.inline?z.push(`${x}=${t}`):z.push(x,t)}t=C.nextIndex;continue}s===E?U=!0:s===`--explain`?$=!0:s===`--automation`?G=!0:s===`--mute`?W=!0:s===k?K=!0:s===`--sandbox`?q=!0:s===`--allow-protected-writes`?J=!0:s===`--hooks`?Y=!0:s===`--mcp`?X=!0:s===`--agents`?Z=!0:s===`--no-hooks`?Y=!1:s===`--no-mcp`?X=!1:s===`--no-agents`?Z=!1:s===A||s===`-h`?Q=!0:s===j||s===`-v`?le=!0:s!==`--verbose`&&s!==`--dangerously-skip-permissions`&&z.push(s)}if(U&&I.length>0)throw Error(`${E} cannot be combined with ${n}`);if(!U&&I.length===0&&L.length===0&&I.push(...d(P,p,_)),G&&(N(z,C,`-p`)||z.unshift(C),N(z,x)||z.unshift(x,O),N(z,w,`-a`)||z.unshift(w)),K&&(G||H===D||N(z,C,`-p`,x)))throw Error(`${k} only supports interactive Pi mode`);return se(V,z,p),{options:{cwd:B,profile:b,domains:I,majorMode:P,explain:$,emitMcp:ue,pluginDirectories:L.map(e=>u.resolve(m,e)),additionalDirectories:[...new Set([...s(p,m),...R.map(e=>u.resolve(m,e))])],preset:V,outputFormat:H,mute:W,automation:G,autoStop:K,sandbox:q,allowProtectedWrites:J,hooks:Y,mcp:X,agents:Z,piArgs:z},help:Q,version:le}}export{I as parseHarnessArgs};
1
+ import{ADD_DIRECTORY_OPTION as e,DEFAULT_MAJOR_MODE as t,DOMAINS_OPTION as n,MAJOR_MODE_OPTION as r,PROFILE_OPTION as i,REMOVED_LAYERS_OPTION as ee,REMOVED_LAYER_OPTION as te,REMOVED_TARGET_OPTION as ne,matchesOption as a,parseCsv as re,parseMajorMode as ie,parseProfileValue as ae,readOption as o,resolveAdditionalDirectories as s,resolveInheritedMajorMode as c,resolveInheritedProfile as l}from"./matrixOptions.mjs";import u from"node:path";import{defaultDomainsForMajorMode as d}from"@agimon-ai/doompi-config/domains";const f=`kimi-for-coding`,p=`kimi-for-coding-highspeed`,m=`kimi-k2.6`,h=`default`,g=`kimi`,_=`ollama`,v=`ollama/`,y=`native`,b=`--model`,x=`--mode`,S=`--thinking`,C=`--print`,w=`--approve`,T=`--profiles`,E=`--no-domains`,D=`vibe-lint`,O=`json`,k=`--auto-stop`,A=`--help`,j=`--version`,M=new Map([[`k2p5`,f],[`k2p6`,f],[`k2p7`,f],[`kimi-k2.5`,f],[m,f],[`kimi-k2.7-code`,f],[f,f],[p,p]]);function N(e){if(e===h||e===g||e===_)return e;throw Error(`Unsupported preset: ${e}`)}function P(e,...t){return e.some(e=>t.includes(e)||t.some(t=>e.startsWith(`${t}=`)))}function F(e){for(let t=0;t<e.length;t+=1){if(e[t]===b||e[t]===`-m`){let n=e[t+1];if(n)return{index:t,value:n,inline:!1}}if(e[t]?.startsWith(`${b}=`))return{index:t,value:e[t].slice(`${b}=`.length),inline:!0}}}function I(e,t){let n=F(e);n?n.inline?e[n.index]=`${b}=${t}`:e[n.index+1]=t:e.unshift(b,t)}function oe(e,t,n){let r=F(t);if(e===g){let e=r?.value??n.KIMI_CODE_MODEL??f,i=e.includes(`/`)?e.slice(e.indexOf(`/`)+1):e;I(t,`kimi-coding/${M.get(i)??i}`)}if(e===_){let e=r?.value??n.OLLAMA_CLAUDE_MODEL??m,i=e.startsWith(v)?e.slice(7):e;I(t,`${v}${i.includes(`:`)?i:`${i}:cloud`}`)}}function se(e,n){let r=e.some(e=>e===A||e===`-h`),i=e.some(e=>e===j||e===`-v`);if(r||i)return{options:{cwd:n,profile:void 0,domains:[],majorMode:t,explain:!1,emitMcp:void 0,pluginDirectories:[],additionalDirectories:[],preset:h,outputFormat:y,mute:!1,automation:!1,autoStop:!1,sandbox:!1,allowProtectedWrites:!1,hooks:!0,mcp:!0,agents:!0,piArgs:[]},help:r,version:i}}function L(f,p=process.env,m=process.cwd(),g=t,_,v){let b=se(f,m);if(b)return b;let M=l(p)??v,F=!1,I=c(p,g),L=!1,R=[],z=[],B=[],V=[],H=m,U=N(p.DOOMPI_PRESET??h),W=y,G=!1,K=!1,q=!1,J=!1,Y=!1,X=!1,Z=!0,Q=!0,$=!0,ce=!1,le=!1,ue=!1,de;for(let t=0;t<f.length;t+=1){let s=f[t];if(a(s,`--target`))throw Error(`${ne} was replaced by ${r}`);if(a(s,`--layer`))throw Error(`${te} was replaced by ${r}`);if(a(s,`--layers`))throw Error(`${ee} was removed; select one major mode with ${r}`);if(a(s,T))throw Error(`${T} was replaced by ${n}`);let c=o(f,t,r);if(c){if(L)throw Error(`${r} can only be provided once`);I=ie(c.value,r),L=!0,t=c.nextIndex;continue}let l=o(f,t,i);if(l){if(F)throw Error(`${i} can only be provided once`);M=ae(l.value,i),F=!0,t=l.nextIndex;continue}let d=o(f,t,`--domains`)??o(f,t,`--domain`);if(d){R.push(...re(d.value)),t=d.nextIndex;continue}let p=o(f,t,`--emit-mcp`);if(p){de=u.resolve(m,p.value),t=p.nextIndex;continue}let h=o(f,t,`--plugin-dir`);if(h){z.push(h.value),t=h.nextIndex;continue}let g=o(f,t,e);if(g){B.push(g.value),t=g.nextIndex;continue}let _=o(f,t,`--preset`);if(_){U=N(_.value),t=_.nextIndex;continue}let v=o(f,t,`--cwd`)??o(f,t,`--cd`);if(v){H=u.resolve(m,v.value),t=v.nextIndex;continue}let y=o(f,t,`--effort`);if(y){y.inline?V.push(`${S}=${y.value}`):V.push(S,y.value),t=y.nextIndex;continue}let b=o(f,t,`--output-format`);if(b){let e=b.value;if(e===D)W=D;else{let t=e===`stream-json`?O:e;b.inline?V.push(`${x}=${t}`):V.push(x,t)}t=b.nextIndex;continue}s===E?G=!0:s===`--explain`?ue=!0:s===`--automation`?q=!0:s===`--mute`?K=!0:s===k?J=!0:s===`--sandbox`?Y=!0:s===`--allow-protected-writes`?X=!0:s===`--hooks`?Z=!0:s===`--mcp`?Q=!0:s===`--agents`?$=!0:s===`--no-hooks`?Z=!1:s===`--no-mcp`?Q=!1:s===`--no-agents`?$=!1:s===A||s===`-h`?ce=!0:s===j||s===`-v`?le=!0:s!==`--verbose`&&s!==`--dangerously-skip-permissions`&&V.push(s)}if(G&&R.length>0)throw Error(`${E} cannot be combined with ${n}`);if(!G&&R.length===0&&z.length===0&&R.push(...d(I,p,_)),q&&(P(V,C,`-p`)||V.unshift(C),P(V,x)||V.unshift(x,O),P(V,w,`-a`)||V.unshift(w)),J&&(q||W===D||P(V,C,`-p`,x)))throw Error(`${k} only supports interactive Pi mode`);return oe(U,V,p),{options:{cwd:H,profile:M,domains:R,majorMode:I,explain:ue,emitMcp:de,pluginDirectories:z.map(e=>u.resolve(m,e)),additionalDirectories:[...new Set([...s(p,m),...B.map(e=>u.resolve(m,e))])],preset:U,outputFormat:W,mute:K,automation:q,autoStop:J,sandbox:Y,allowProtectedWrites:X,hooks:Z,mcp:Q,agents:$,piArgs:V},help:ce,version:le}}export{L as parseHarnessArgs};
2
2
  //# sourceMappingURL=options.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.mjs","names":[],"sources":["../../../../src/commands/cli/options.ts"],"sourcesContent":["import path from 'node:path';\nimport type { HarnessOutputFormat, HarnessPreset, ParsedHarnessArgs } from '../../types/interfaces/harness';\nimport { defaultDomainsForMajorMode } from '@agimon-ai/doompi-config/domains';\nimport {\n ADD_DIRECTORY_OPTION,\n DEFAULT_MAJOR_MODE,\n DOMAIN_OPTION,\n DOMAINS_OPTION,\n DOOMPI_PRESET_ENV,\n MAJOR_MODE_OPTION,\n matchesOption,\n PROFILE_OPTION,\n parseCsv,\n parseMajorMode,\n parseProfileValue,\n REMOVED_LAYER_OPTION,\n REMOVED_LAYERS_OPTION,\n REMOVED_TARGET_OPTION,\n readOption,\n resolveAdditionalDirectories,\n resolveInheritedMajorMode,\n resolveInheritedProfile,\n} from './matrixOptions.ts';\n\nconst KIMI_FOR_CODING = 'kimi-for-coding';\nconst KIMI_FOR_CODING_HIGHSPEED = 'kimi-for-coding-highspeed';\nconst KIMI_K2_6 = 'kimi-k2.6';\nconst DEFAULT_PRESET = 'default';\nconst KIMI_PRESET = 'kimi';\nconst OLLAMA_PRESET = 'ollama';\nconst OLLAMA_PREFIX = 'ollama/';\nconst KIMI_CODING_PREFIX = 'kimi-coding/';\nconst CLOUD_SUFFIX = ':cloud';\nconst NATIVE_FORMAT = 'native';\nconst KIMI_CODE_MODEL_ENV = 'KIMI_CODE_MODEL';\nconst OLLAMA_CLAUDE_MODEL_ENV = 'OLLAMA_CLAUDE_MODEL';\nconst MODEL_OPTION = '--model';\nconst MODEL_SHORT_OPTION = '-m';\nconst MODE_OPTION = '--mode';\nconst THINKING_OPTION = '--thinking';\nconst PRINT_OPTION = '--print';\nconst PRINT_SHORT_OPTION = '-p';\nconst APPROVE_OPTION = '--approve';\nconst APPROVE_SHORT_OPTION = '-a';\nconst PROFILES_OPTION = '--profiles';\nconst NO_DOMAINS_OPTION = '--no-domains';\nconst PRESET_OPTION = '--preset';\nconst EFFORT_OPTION = '--effort';\nconst OUTPUT_FORMAT_OPTION = '--output-format';\nconst MUTE_OPTION = '--mute';\nconst VIBE_LINT_FORMAT = 'vibe-lint';\nconst STREAM_JSON_FORMAT = 'stream-json';\nconst JSON_FORMAT = 'json';\nconst EXPLAIN_OPTION = '--explain';\nconst EMIT_MCP_OPTION = '--emit-mcp';\nconst PLUGIN_DIRECTORY_OPTION = '--plugin-dir';\nconst CWD_OPTION = '--cwd';\nconst CD_OPTION = '--cd';\nconst AUTOMATION_OPTION = '--automation';\nconst AUTO_STOP_OPTION = '--auto-stop';\nconst SANDBOX_OPTION = '--sandbox';\nconst ALLOW_PROTECTED_WRITES_OPTION = '--allow-protected-writes';\nconst HOOKS_OPTION = '--hooks';\nconst MCP_OPTION = '--mcp';\nconst AGENTS_OPTION = '--agents';\nconst NO_HOOKS_OPTION = '--no-hooks';\nconst NO_MCP_OPTION = '--no-mcp';\nconst NO_AGENTS_OPTION = '--no-agents';\nconst VERBOSE_OPTION = '--verbose';\nconst DANGEROUSLY_SKIP_PERMISSIONS_OPTION = '--dangerously-skip-permissions';\nconst HELP_OPTION = '--help';\nconst HELP_SHORT_OPTION = '-h';\nconst VERSION_OPTION = '--version';\nconst VERSION_SHORT_OPTION = '-v';\n\nconst KIMI_ALIASES = new Map([\n ['k2p5', KIMI_FOR_CODING],\n ['k2p6', KIMI_FOR_CODING],\n ['k2p7', KIMI_FOR_CODING],\n ['kimi-k2.5', KIMI_FOR_CODING],\n [KIMI_K2_6, KIMI_FOR_CODING],\n ['kimi-k2.7-code', KIMI_FOR_CODING],\n [KIMI_FOR_CODING, KIMI_FOR_CODING],\n [KIMI_FOR_CODING_HIGHSPEED, KIMI_FOR_CODING_HIGHSPEED],\n]);\n\nfunction parsePreset(value: string): HarnessPreset {\n if (value === DEFAULT_PRESET || value === KIMI_PRESET || value === OLLAMA_PRESET) return value;\n throw new Error(`Unsupported preset: ${value}`);\n}\n\nfunction hasOption(args: string[], ...names: string[]): boolean {\n return args.some((arg) => names.includes(arg) || names.some((name) => arg.startsWith(`${name}=`)));\n}\n\nfunction modelValue(args: string[]): { index: number; value: string; inline: boolean } | undefined {\n for (let index = 0; index < args.length; index += 1) {\n if (args[index] === MODEL_OPTION || args[index] === MODEL_SHORT_OPTION) {\n const value = args[index + 1];\n if (value) return { index, value, inline: false };\n }\n if (args[index]?.startsWith(`${MODEL_OPTION}=`)) {\n return { index, value: args[index].slice(`${MODEL_OPTION}=`.length), inline: true };\n }\n }\n return undefined;\n}\n\nfunction replaceModel(args: string[], value: string): void {\n const selected = modelValue(args);\n if (!selected) {\n args.unshift(MODEL_OPTION, value);\n } else if (selected.inline) {\n args[selected.index] = `${MODEL_OPTION}=${value}`;\n } else {\n args[selected.index + 1] = value;\n }\n}\n\nfunction normalizeProviderArgs(preset: HarnessPreset, piArgs: string[], environment: NodeJS.ProcessEnv): void {\n const selected = modelValue(piArgs);\n if (preset === KIMI_PRESET) {\n const value = selected?.value ?? environment[KIMI_CODE_MODEL_ENV] ?? KIMI_FOR_CODING;\n const unqualified = value.includes('/') ? value.slice(value.indexOf('/') + 1) : value;\n replaceModel(piArgs, `${KIMI_CODING_PREFIX}${KIMI_ALIASES.get(unqualified) ?? unqualified}`);\n }\n if (preset === OLLAMA_PRESET) {\n const value = selected?.value ?? environment[OLLAMA_CLAUDE_MODEL_ENV] ?? KIMI_K2_6;\n const unqualified = value.startsWith(OLLAMA_PREFIX) ? value.slice(OLLAMA_PREFIX.length) : value;\n replaceModel(\n piArgs,\n `${OLLAMA_PREFIX}${unqualified.includes(':') ? unqualified : `${unqualified}${CLOUD_SUFFIX}`}`,\n );\n }\n}\n\n/**\n * Answers `--help` and `--version` without reading the environment.\n *\n * The caller only looks at `help` and `version` for these, and never launches,\n * so the options carry defaults rather than a resolved matrix. This exists so a\n * stale export cannot break the one command that explains how to fix it.\n */\nfunction parseInformationalArgs(args: string[], currentDirectory: string): ParsedHarnessArgs | undefined {\n const help = args.some((arg) => arg === HELP_OPTION || arg === HELP_SHORT_OPTION);\n const version = args.some((arg) => arg === VERSION_OPTION || arg === VERSION_SHORT_OPTION);\n if (!help && !version) return undefined;\n return {\n options: {\n cwd: currentDirectory,\n profile: undefined,\n domains: [],\n majorMode: DEFAULT_MAJOR_MODE,\n explain: false,\n emitMcp: undefined,\n pluginDirectories: [],\n additionalDirectories: [],\n preset: DEFAULT_PRESET,\n outputFormat: NATIVE_FORMAT,\n mute: false,\n automation: false,\n autoStop: false,\n sandbox: false,\n allowProtectedWrites: false,\n hooks: true,\n mcp: true,\n agents: true,\n piArgs: [],\n },\n help,\n version,\n };\n}\n\nexport function parseHarnessArgs(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n defaultMajorMode: string = DEFAULT_MAJOR_MODE,\n defaultDomains?: readonly string[],\n): ParsedHarnessArgs {\n const informational = parseInformationalArgs(args, currentDirectory);\n if (informational) return informational;\n\n let profile = resolveInheritedProfile(environment);\n let profileProvided = false;\n let majorMode = resolveInheritedMajorMode(environment, defaultMajorMode);\n let majorModeProvided = false;\n const domains: string[] = [];\n // Directory options are collected verbatim and resolved once after the loop,\n // so a relative path means the same thing regardless of where --cwd appears\n // in the argument list.\n const pluginDirectoryValues: string[] = [];\n const additionalDirectoryValues: string[] = [];\n const piArgs: string[] = [];\n let cwd = currentDirectory;\n let preset = parsePreset(environment[DOOMPI_PRESET_ENV] ?? DEFAULT_PRESET);\n let outputFormat: HarnessOutputFormat = NATIVE_FORMAT;\n let domainsDisabled = false;\n let mute = false;\n let automation = false;\n let autoStop = false;\n let sandbox = false;\n let allowProtectedWrites = false;\n let hooks = true;\n let mcp = true;\n let agents = true;\n let help = false;\n let version = false;\n let explain = false;\n let emitMcp: string | undefined;\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!;\n\n if (matchesOption(arg, REMOVED_TARGET_OPTION)) {\n throw new Error(`${REMOVED_TARGET_OPTION} was replaced by ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, REMOVED_LAYER_OPTION)) {\n throw new Error(`${REMOVED_LAYER_OPTION} was replaced by ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, REMOVED_LAYERS_OPTION)) {\n throw new Error(`${REMOVED_LAYERS_OPTION} was removed; select one major mode with ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, PROFILES_OPTION)) {\n throw new Error(`${PROFILES_OPTION} was replaced by ${DOMAINS_OPTION}`);\n }\n\n const majorModeMatch = readOption(args, index, MAJOR_MODE_OPTION);\n if (majorModeMatch) {\n if (majorModeProvided) throw new Error(`${MAJOR_MODE_OPTION} can only be provided once`);\n majorMode = parseMajorMode(majorModeMatch.value, MAJOR_MODE_OPTION);\n majorModeProvided = true;\n index = majorModeMatch.nextIndex;\n continue;\n }\n\n const profileMatch = readOption(args, index, PROFILE_OPTION);\n if (profileMatch) {\n if (profileProvided) throw new Error(`${PROFILE_OPTION} can only be provided once`);\n profile = parseProfileValue(profileMatch.value, PROFILE_OPTION);\n profileProvided = true;\n index = profileMatch.nextIndex;\n continue;\n }\n\n const domainMatch = readOption(args, index, DOMAINS_OPTION) ?? readOption(args, index, DOMAIN_OPTION);\n if (domainMatch) {\n domains.push(...parseCsv(domainMatch.value));\n index = domainMatch.nextIndex;\n continue;\n }\n\n const emitMcpMatch = readOption(args, index, EMIT_MCP_OPTION);\n if (emitMcpMatch) {\n emitMcp = path.resolve(currentDirectory, emitMcpMatch.value);\n index = emitMcpMatch.nextIndex;\n continue;\n }\n\n const pluginDirectoryMatch = readOption(args, index, PLUGIN_DIRECTORY_OPTION);\n if (pluginDirectoryMatch) {\n pluginDirectoryValues.push(pluginDirectoryMatch.value);\n index = pluginDirectoryMatch.nextIndex;\n continue;\n }\n\n const addDirectoryMatch = readOption(args, index, ADD_DIRECTORY_OPTION);\n if (addDirectoryMatch) {\n additionalDirectoryValues.push(addDirectoryMatch.value);\n index = addDirectoryMatch.nextIndex;\n continue;\n }\n\n const presetMatch = readOption(args, index, PRESET_OPTION);\n if (presetMatch) {\n preset = parsePreset(presetMatch.value);\n index = presetMatch.nextIndex;\n continue;\n }\n\n const cwdMatch = readOption(args, index, CWD_OPTION) ?? readOption(args, index, CD_OPTION);\n if (cwdMatch) {\n cwd = path.resolve(currentDirectory, cwdMatch.value);\n index = cwdMatch.nextIndex;\n continue;\n }\n\n const effortMatch = readOption(args, index, EFFORT_OPTION);\n if (effortMatch) {\n if (effortMatch.inline) piArgs.push(`${THINKING_OPTION}=${effortMatch.value}`);\n else piArgs.push(THINKING_OPTION, effortMatch.value);\n index = effortMatch.nextIndex;\n continue;\n }\n\n const outputFormatMatch = readOption(args, index, OUTPUT_FORMAT_OPTION);\n if (outputFormatMatch) {\n const requested = outputFormatMatch.value;\n if (requested === VIBE_LINT_FORMAT) {\n outputFormat = VIBE_LINT_FORMAT;\n } else {\n const mode = requested === STREAM_JSON_FORMAT ? JSON_FORMAT : requested;\n if (outputFormatMatch.inline) piArgs.push(`${MODE_OPTION}=${mode}`);\n else piArgs.push(MODE_OPTION, mode);\n }\n index = outputFormatMatch.nextIndex;\n continue;\n }\n\n if (arg === NO_DOMAINS_OPTION) domainsDisabled = true;\n else if (arg === EXPLAIN_OPTION) explain = true;\n else if (arg === AUTOMATION_OPTION) automation = true;\n else if (arg === MUTE_OPTION) mute = true;\n else if (arg === AUTO_STOP_OPTION) autoStop = true;\n else if (arg === SANDBOX_OPTION) sandbox = true;\n else if (arg === ALLOW_PROTECTED_WRITES_OPTION) allowProtectedWrites = true;\n else if (arg === HOOKS_OPTION) hooks = true;\n else if (arg === MCP_OPTION) mcp = true;\n else if (arg === AGENTS_OPTION) agents = true;\n else if (arg === NO_HOOKS_OPTION) hooks = false;\n else if (arg === NO_MCP_OPTION) mcp = false;\n else if (arg === NO_AGENTS_OPTION) agents = false;\n else if (arg === HELP_OPTION || arg === HELP_SHORT_OPTION) help = true;\n else if (arg === VERSION_OPTION || arg === VERSION_SHORT_OPTION) version = true;\n // Accepted for Claude Code compatibility and deliberately not forwarded.\n else if (arg !== VERBOSE_OPTION && arg !== DANGEROUSLY_SKIP_PERMISSIONS_OPTION) piArgs.push(arg);\n }\n\n if (domainsDisabled && domains.length > 0) {\n throw new Error(`${NO_DOMAINS_OPTION} cannot be combined with ${DOMAINS_OPTION}`);\n }\n if (!domainsDisabled && domains.length === 0 && pluginDirectoryValues.length === 0) {\n domains.push(...defaultDomainsForMajorMode(majorMode, environment, defaultDomains));\n }\n if (automation) {\n if (!hasOption(piArgs, PRINT_OPTION, PRINT_SHORT_OPTION)) piArgs.unshift(PRINT_OPTION);\n if (!hasOption(piArgs, MODE_OPTION)) piArgs.unshift(MODE_OPTION, JSON_FORMAT);\n if (!hasOption(piArgs, APPROVE_OPTION, APPROVE_SHORT_OPTION)) piArgs.unshift(APPROVE_OPTION);\n }\n if (\n autoStop &&\n (automation ||\n outputFormat === VIBE_LINT_FORMAT ||\n hasOption(piArgs, PRINT_OPTION, PRINT_SHORT_OPTION, MODE_OPTION))\n ) {\n throw new Error(`${AUTO_STOP_OPTION} only supports interactive Pi mode`);\n }\n normalizeProviderArgs(preset, piArgs, environment);\n\n return {\n options: {\n cwd,\n profile,\n domains,\n majorMode,\n explain,\n emitMcp,\n pluginDirectories: pluginDirectoryValues.map((value) => path.resolve(currentDirectory, value)),\n additionalDirectories: [\n ...new Set([\n ...resolveAdditionalDirectories(environment, currentDirectory),\n ...additionalDirectoryValues.map((value) => path.resolve(currentDirectory, value)),\n ]),\n ],\n preset,\n outputFormat,\n mute,\n automation,\n autoStop,\n sandbox,\n allowProtectedWrites,\n hooks,\n mcp,\n agents,\n piArgs,\n },\n help,\n version,\n };\n}\n"],"mappings":"ygBAwBA,MAAM,EAAkB,kBAClB,EAA4B,4BAC5B,EAAY,YACZ,EAAiB,UACjB,EAAc,OACd,EAAgB,SAChB,EAAgB,UAGhB,EAAgB,SAGhB,EAAe,UAEf,EAAc,SACd,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,CACH,EACA,SACA,eACA,OACA,aACA,WACA,UACA,uBACA,QACA,MACA,SACA,QACF,EACA,OACA,UACF,CACF"}
1
+ {"version":3,"file":"options.mjs","names":[],"sources":["../../../../src/commands/cli/options.ts"],"sourcesContent":["import path from 'node:path';\nimport type { HarnessOutputFormat, HarnessPreset, ParsedHarnessArgs } from '../../types/interfaces/harness';\nimport { defaultDomainsForMajorMode } from '@agimon-ai/doompi-config/domains';\nimport {\n ADD_DIRECTORY_OPTION,\n DEFAULT_MAJOR_MODE,\n DOMAIN_OPTION,\n DOMAINS_OPTION,\n DOOMPI_PRESET_ENV,\n MAJOR_MODE_OPTION,\n matchesOption,\n PROFILE_OPTION,\n parseCsv,\n parseMajorMode,\n parseProfileValue,\n REMOVED_LAYER_OPTION,\n REMOVED_LAYERS_OPTION,\n REMOVED_TARGET_OPTION,\n readOption,\n resolveAdditionalDirectories,\n resolveInheritedMajorMode,\n resolveInheritedProfile,\n} from './matrixOptions.ts';\n\nconst KIMI_FOR_CODING = 'kimi-for-coding';\nconst KIMI_FOR_CODING_HIGHSPEED = 'kimi-for-coding-highspeed';\nconst KIMI_K2_6 = 'kimi-k2.6';\nconst DEFAULT_PRESET = 'default';\nconst KIMI_PRESET = 'kimi';\nconst OLLAMA_PRESET = 'ollama';\nconst OLLAMA_PREFIX = 'ollama/';\nconst KIMI_CODING_PREFIX = 'kimi-coding/';\nconst CLOUD_SUFFIX = ':cloud';\nconst NATIVE_FORMAT = 'native';\nconst KIMI_CODE_MODEL_ENV = 'KIMI_CODE_MODEL';\nconst OLLAMA_CLAUDE_MODEL_ENV = 'OLLAMA_CLAUDE_MODEL';\nconst MODEL_OPTION = '--model';\nconst MODEL_SHORT_OPTION = '-m';\nconst MODE_OPTION = '--mode';\nconst THINKING_OPTION = '--thinking';\nconst PRINT_OPTION = '--print';\nconst PRINT_SHORT_OPTION = '-p';\nconst APPROVE_OPTION = '--approve';\nconst APPROVE_SHORT_OPTION = '-a';\nconst PROFILES_OPTION = '--profiles';\nconst NO_DOMAINS_OPTION = '--no-domains';\nconst PRESET_OPTION = '--preset';\nconst EFFORT_OPTION = '--effort';\nconst OUTPUT_FORMAT_OPTION = '--output-format';\nconst MUTE_OPTION = '--mute';\nconst VIBE_LINT_FORMAT = 'vibe-lint';\nconst STREAM_JSON_FORMAT = 'stream-json';\nconst JSON_FORMAT = 'json';\nconst EXPLAIN_OPTION = '--explain';\nconst EMIT_MCP_OPTION = '--emit-mcp';\nconst PLUGIN_DIRECTORY_OPTION = '--plugin-dir';\nconst CWD_OPTION = '--cwd';\nconst CD_OPTION = '--cd';\nconst AUTOMATION_OPTION = '--automation';\nconst AUTO_STOP_OPTION = '--auto-stop';\nconst SANDBOX_OPTION = '--sandbox';\nconst ALLOW_PROTECTED_WRITES_OPTION = '--allow-protected-writes';\nconst HOOKS_OPTION = '--hooks';\nconst MCP_OPTION = '--mcp';\nconst AGENTS_OPTION = '--agents';\nconst NO_HOOKS_OPTION = '--no-hooks';\nconst NO_MCP_OPTION = '--no-mcp';\nconst NO_AGENTS_OPTION = '--no-agents';\nconst VERBOSE_OPTION = '--verbose';\nconst DANGEROUSLY_SKIP_PERMISSIONS_OPTION = '--dangerously-skip-permissions';\nconst HELP_OPTION = '--help';\nconst HELP_SHORT_OPTION = '-h';\nconst VERSION_OPTION = '--version';\nconst VERSION_SHORT_OPTION = '-v';\n\nconst KIMI_ALIASES = new Map([\n ['k2p5', KIMI_FOR_CODING],\n ['k2p6', KIMI_FOR_CODING],\n ['k2p7', KIMI_FOR_CODING],\n ['kimi-k2.5', KIMI_FOR_CODING],\n [KIMI_K2_6, KIMI_FOR_CODING],\n ['kimi-k2.7-code', KIMI_FOR_CODING],\n [KIMI_FOR_CODING, KIMI_FOR_CODING],\n [KIMI_FOR_CODING_HIGHSPEED, KIMI_FOR_CODING_HIGHSPEED],\n]);\n\nfunction parsePreset(value: string): HarnessPreset {\n if (value === DEFAULT_PRESET || value === KIMI_PRESET || value === OLLAMA_PRESET) return value;\n throw new Error(`Unsupported preset: ${value}`);\n}\n\nfunction hasOption(args: string[], ...names: string[]): boolean {\n return args.some((arg) => names.includes(arg) || names.some((name) => arg.startsWith(`${name}=`)));\n}\n\nfunction modelValue(args: string[]): { index: number; value: string; inline: boolean } | undefined {\n for (let index = 0; index < args.length; index += 1) {\n if (args[index] === MODEL_OPTION || args[index] === MODEL_SHORT_OPTION) {\n const value = args[index + 1];\n if (value) return { index, value, inline: false };\n }\n if (args[index]?.startsWith(`${MODEL_OPTION}=`)) {\n return { index, value: args[index].slice(`${MODEL_OPTION}=`.length), inline: true };\n }\n }\n return undefined;\n}\n\nfunction replaceModel(args: string[], value: string): void {\n const selected = modelValue(args);\n if (!selected) {\n args.unshift(MODEL_OPTION, value);\n } else if (selected.inline) {\n args[selected.index] = `${MODEL_OPTION}=${value}`;\n } else {\n args[selected.index + 1] = value;\n }\n}\n\nfunction normalizeProviderArgs(preset: HarnessPreset, piArgs: string[], environment: NodeJS.ProcessEnv): void {\n const selected = modelValue(piArgs);\n if (preset === KIMI_PRESET) {\n const value = selected?.value ?? environment[KIMI_CODE_MODEL_ENV] ?? KIMI_FOR_CODING;\n const unqualified = value.includes('/') ? value.slice(value.indexOf('/') + 1) : value;\n replaceModel(piArgs, `${KIMI_CODING_PREFIX}${KIMI_ALIASES.get(unqualified) ?? unqualified}`);\n }\n if (preset === OLLAMA_PRESET) {\n const value = selected?.value ?? environment[OLLAMA_CLAUDE_MODEL_ENV] ?? KIMI_K2_6;\n const unqualified = value.startsWith(OLLAMA_PREFIX) ? value.slice(OLLAMA_PREFIX.length) : value;\n replaceModel(\n piArgs,\n `${OLLAMA_PREFIX}${unqualified.includes(':') ? unqualified : `${unqualified}${CLOUD_SUFFIX}`}`,\n );\n }\n}\n\n/**\n * Answers `--help` and `--version` without reading the environment.\n *\n * The caller only looks at `help` and `version` for these, and never launches,\n * so the options carry defaults rather than a resolved matrix. This exists so a\n * stale export cannot break the one command that explains how to fix it.\n */\nfunction parseInformationalArgs(args: string[], currentDirectory: string): ParsedHarnessArgs | undefined {\n const help = args.some((arg) => arg === HELP_OPTION || arg === HELP_SHORT_OPTION);\n const version = args.some((arg) => arg === VERSION_OPTION || arg === VERSION_SHORT_OPTION);\n if (!help && !version) return undefined;\n return {\n options: {\n cwd: currentDirectory,\n profile: undefined,\n domains: [],\n majorMode: DEFAULT_MAJOR_MODE,\n explain: false,\n emitMcp: undefined,\n pluginDirectories: [],\n additionalDirectories: [],\n preset: DEFAULT_PRESET,\n outputFormat: NATIVE_FORMAT,\n mute: false,\n automation: false,\n autoStop: false,\n sandbox: false,\n allowProtectedWrites: false,\n hooks: true,\n mcp: true,\n agents: true,\n piArgs: [],\n },\n help,\n version,\n };\n}\n\nexport function parseHarnessArgs(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n defaultMajorMode: string = DEFAULT_MAJOR_MODE,\n defaultDomains?: readonly string[],\n defaultProfile?: string,\n): ParsedHarnessArgs {\n const informational = parseInformationalArgs(args, currentDirectory);\n if (informational) return informational;\n\n // An inherited profile wins: a nested run stays on the persona its parent\n // chose rather than snapping back to the repository default.\n let profile = resolveInheritedProfile(environment) ?? defaultProfile;\n let profileProvided = false;\n let majorMode = resolveInheritedMajorMode(environment, defaultMajorMode);\n let majorModeProvided = false;\n const domains: string[] = [];\n // Directory options are collected verbatim and resolved once after the loop,\n // so a relative path means the same thing regardless of where --cwd appears\n // in the argument list.\n const pluginDirectoryValues: string[] = [];\n const additionalDirectoryValues: string[] = [];\n const piArgs: string[] = [];\n let cwd = currentDirectory;\n let preset = parsePreset(environment[DOOMPI_PRESET_ENV] ?? DEFAULT_PRESET);\n let outputFormat: HarnessOutputFormat = NATIVE_FORMAT;\n let domainsDisabled = false;\n let mute = false;\n let automation = false;\n let autoStop = false;\n let sandbox = false;\n let allowProtectedWrites = false;\n let hooks = true;\n let mcp = true;\n let agents = true;\n let help = false;\n let version = false;\n let explain = false;\n let emitMcp: string | undefined;\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!;\n\n if (matchesOption(arg, REMOVED_TARGET_OPTION)) {\n throw new Error(`${REMOVED_TARGET_OPTION} was replaced by ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, REMOVED_LAYER_OPTION)) {\n throw new Error(`${REMOVED_LAYER_OPTION} was replaced by ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, REMOVED_LAYERS_OPTION)) {\n throw new Error(`${REMOVED_LAYERS_OPTION} was removed; select one major mode with ${MAJOR_MODE_OPTION}`);\n }\n if (matchesOption(arg, PROFILES_OPTION)) {\n throw new Error(`${PROFILES_OPTION} was replaced by ${DOMAINS_OPTION}`);\n }\n\n const majorModeMatch = readOption(args, index, MAJOR_MODE_OPTION);\n if (majorModeMatch) {\n if (majorModeProvided) throw new Error(`${MAJOR_MODE_OPTION} can only be provided once`);\n majorMode = parseMajorMode(majorModeMatch.value, MAJOR_MODE_OPTION);\n majorModeProvided = true;\n index = majorModeMatch.nextIndex;\n continue;\n }\n\n const profileMatch = readOption(args, index, PROFILE_OPTION);\n if (profileMatch) {\n if (profileProvided) throw new Error(`${PROFILE_OPTION} can only be provided once`);\n profile = parseProfileValue(profileMatch.value, PROFILE_OPTION);\n profileProvided = true;\n index = profileMatch.nextIndex;\n continue;\n }\n\n const domainMatch = readOption(args, index, DOMAINS_OPTION) ?? readOption(args, index, DOMAIN_OPTION);\n if (domainMatch) {\n domains.push(...parseCsv(domainMatch.value));\n index = domainMatch.nextIndex;\n continue;\n }\n\n const emitMcpMatch = readOption(args, index, EMIT_MCP_OPTION);\n if (emitMcpMatch) {\n emitMcp = path.resolve(currentDirectory, emitMcpMatch.value);\n index = emitMcpMatch.nextIndex;\n continue;\n }\n\n const pluginDirectoryMatch = readOption(args, index, PLUGIN_DIRECTORY_OPTION);\n if (pluginDirectoryMatch) {\n pluginDirectoryValues.push(pluginDirectoryMatch.value);\n index = pluginDirectoryMatch.nextIndex;\n continue;\n }\n\n const addDirectoryMatch = readOption(args, index, ADD_DIRECTORY_OPTION);\n if (addDirectoryMatch) {\n additionalDirectoryValues.push(addDirectoryMatch.value);\n index = addDirectoryMatch.nextIndex;\n continue;\n }\n\n const presetMatch = readOption(args, index, PRESET_OPTION);\n if (presetMatch) {\n preset = parsePreset(presetMatch.value);\n index = presetMatch.nextIndex;\n continue;\n }\n\n const cwdMatch = readOption(args, index, CWD_OPTION) ?? readOption(args, index, CD_OPTION);\n if (cwdMatch) {\n cwd = path.resolve(currentDirectory, cwdMatch.value);\n index = cwdMatch.nextIndex;\n continue;\n }\n\n const effortMatch = readOption(args, index, EFFORT_OPTION);\n if (effortMatch) {\n if (effortMatch.inline) piArgs.push(`${THINKING_OPTION}=${effortMatch.value}`);\n else piArgs.push(THINKING_OPTION, effortMatch.value);\n index = effortMatch.nextIndex;\n continue;\n }\n\n const outputFormatMatch = readOption(args, index, OUTPUT_FORMAT_OPTION);\n if (outputFormatMatch) {\n const requested = outputFormatMatch.value;\n if (requested === VIBE_LINT_FORMAT) {\n outputFormat = VIBE_LINT_FORMAT;\n } else {\n const mode = requested === STREAM_JSON_FORMAT ? JSON_FORMAT : requested;\n if (outputFormatMatch.inline) piArgs.push(`${MODE_OPTION}=${mode}`);\n else piArgs.push(MODE_OPTION, mode);\n }\n index = outputFormatMatch.nextIndex;\n continue;\n }\n\n if (arg === NO_DOMAINS_OPTION) domainsDisabled = true;\n else if (arg === EXPLAIN_OPTION) explain = true;\n else if (arg === AUTOMATION_OPTION) automation = true;\n else if (arg === MUTE_OPTION) mute = true;\n else if (arg === AUTO_STOP_OPTION) autoStop = true;\n else if (arg === SANDBOX_OPTION) sandbox = true;\n else if (arg === ALLOW_PROTECTED_WRITES_OPTION) allowProtectedWrites = true;\n else if (arg === HOOKS_OPTION) hooks = true;\n else if (arg === MCP_OPTION) mcp = true;\n else if (arg === AGENTS_OPTION) agents = true;\n else if (arg === NO_HOOKS_OPTION) hooks = false;\n else if (arg === NO_MCP_OPTION) mcp = false;\n else if (arg === NO_AGENTS_OPTION) agents = false;\n else if (arg === HELP_OPTION || arg === HELP_SHORT_OPTION) help = true;\n else if (arg === VERSION_OPTION || arg === VERSION_SHORT_OPTION) version = true;\n // Accepted for Claude Code compatibility and deliberately not forwarded.\n else if (arg !== VERBOSE_OPTION && arg !== DANGEROUSLY_SKIP_PERMISSIONS_OPTION) piArgs.push(arg);\n }\n\n if (domainsDisabled && domains.length > 0) {\n throw new Error(`${NO_DOMAINS_OPTION} cannot be combined with ${DOMAINS_OPTION}`);\n }\n if (!domainsDisabled && domains.length === 0 && pluginDirectoryValues.length === 0) {\n domains.push(...defaultDomainsForMajorMode(majorMode, environment, defaultDomains));\n }\n if (automation) {\n if (!hasOption(piArgs, PRINT_OPTION, PRINT_SHORT_OPTION)) piArgs.unshift(PRINT_OPTION);\n if (!hasOption(piArgs, MODE_OPTION)) piArgs.unshift(MODE_OPTION, JSON_FORMAT);\n if (!hasOption(piArgs, APPROVE_OPTION, APPROVE_SHORT_OPTION)) piArgs.unshift(APPROVE_OPTION);\n }\n if (\n autoStop &&\n (automation ||\n outputFormat === VIBE_LINT_FORMAT ||\n hasOption(piArgs, PRINT_OPTION, PRINT_SHORT_OPTION, MODE_OPTION))\n ) {\n throw new Error(`${AUTO_STOP_OPTION} only supports interactive Pi mode`);\n }\n normalizeProviderArgs(preset, piArgs, environment);\n\n return {\n options: {\n cwd,\n profile,\n domains,\n majorMode,\n explain,\n emitMcp,\n pluginDirectories: pluginDirectoryValues.map((value) => path.resolve(currentDirectory, value)),\n additionalDirectories: [\n ...new Set([\n ...resolveAdditionalDirectories(environment, currentDirectory),\n ...additionalDirectoryValues.map((value) => path.resolve(currentDirectory, value)),\n ]),\n ],\n preset,\n outputFormat,\n mute,\n automation,\n autoStop,\n sandbox,\n allowProtectedWrites,\n hooks,\n mcp,\n agents,\n piArgs,\n },\n help,\n version,\n };\n}\n"],"mappings":"ygBAwBA,MAAM,EAAkB,kBAClB,EAA4B,4BAC5B,EAAY,YACZ,EAAiB,UACjB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Aa,CAAgB,EAC7D,GAAG,EAA0B,IAAK,GAAU,EAAK,QAAQ,EAAkB,CAAK,CAAC,CACnF,CAAC,CACH,EACA,SACA,eACA,OACA,aACA,WACA,UACA,uBACA,QACA,MACA,SACA,QACF,EACA,QACA,UACF,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/doompi",
3
- "version": "0.0.1-alpha.66",
3
+ "version": "0.0.1-alpha.68",
4
4
  "description": "Opinionated, composable Pi distribution for scoped agent tools, skills, MCP servers, and developer workflows.",
5
5
  "keywords": [
6
6
  "ai",
@@ -325,17 +325,17 @@
325
325
  "rolldown": "1.2.7",
326
326
  "typebox": "1.3.25",
327
327
  "yaml": "2.9.0",
328
- "@agimon-ai/doompi-autostop": "0.0.1-alpha.42",
329
- "@agimon-ai/doompi-cache": "0.0.1-alpha.31",
330
- "@agimon-ai/doompi-config": "0.0.1-alpha.64",
331
- "@agimon-ai/doompi-domain": "0.0.1-alpha.43",
332
- "@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.64",
333
- "@agimon-ai/doompi-major-mode": "0.0.1-alpha.43",
334
- "@agimon-ai/doompi-notification": "0.0.1-alpha.42",
335
- "@agimon-ai/doompi-skill": "0.0.1-alpha.43",
336
- "@agimon-ai/doompi-telemetry": "0.0.1-alpha.63",
337
- "@agimon-ai/doompi-ui": "0.0.1-alpha.65",
338
- "@agimon-ai/doompi-profile": "0.0.1-alpha.43"
328
+ "@agimon-ai/doompi-autostop": "0.0.1-alpha.44",
329
+ "@agimon-ai/doompi-cache": "0.0.1-alpha.33",
330
+ "@agimon-ai/doompi-config": "0.0.1-alpha.66",
331
+ "@agimon-ai/doompi-domain": "0.0.1-alpha.45",
332
+ "@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.66",
333
+ "@agimon-ai/doompi-major-mode": "0.0.1-alpha.45",
334
+ "@agimon-ai/doompi-notification": "0.0.1-alpha.44",
335
+ "@agimon-ai/doompi-profile": "0.0.1-alpha.45",
336
+ "@agimon-ai/doompi-skill": "0.0.1-alpha.45",
337
+ "@agimon-ai/doompi-telemetry": "0.0.1-alpha.65",
338
+ "@agimon-ai/doompi-ui": "0.0.1-alpha.67"
339
339
  },
340
340
  "devDependencies": {
341
341
  "@earendil-works/pi-ai": "0.85.1",
@@ -345,7 +345,7 @@
345
345
  "@vitest/coverage-v8": "4.1.11",
346
346
  "typescript": "7.0.2",
347
347
  "vitest": "4.1.11",
348
- "@agimon-ai/doompi-runner": "0.0.1-alpha.65"
348
+ "@agimon-ai/doompi-runner": "0.0.1-alpha.67"
349
349
  },
350
350
  "peerDependencies": {
351
351
  "@earendil-works/pi-tui": "0.85.1"