@agimon-ai/po-config 0.0.0-alpha.149 → 0.0.0-alpha.150

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.
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_settingsApi = require("../settingsApi-DZ0hKFXA.cjs");
5
+ const require_settingsApi = require("../settingsApi-DW533fcN.cjs");
6
6
  const require_sessionConfig = require("../sessionConfig-Kj6vmVtE.cjs");
7
7
  let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
8
8
  let _agimon_ai_po_core_mcpProjection = require("@agimon-ai/po-core/mcpProjection");
@@ -1,4 +1,4 @@
1
- import { t as createSettingsApi } from "../settingsApi-CSog84S1.mjs";
1
+ import { t as createSettingsApi } from "../settingsApi-C7fWuifs.mjs";
2
2
  import { d as providePoConfigContext, o as createNativePoConfigContext } from "../sessionConfig-0eGoap9R.mjs";
3
3
  import { BACKGROUND_CONTEXT, requirePoFs, withAbortSignal } from "@agimon-ai/po-core/platform";
4
4
  import { PO_MCP_PROJECTION_SERVICE, createDisabledPoMcpProjection, createPoMcpProjectionService, isPoMcpProjection } from "@agimon-ai/po-core/mcpProjection";
package/dist/index.cjs CHANGED
@@ -9,9 +9,9 @@ const require_layeredConfig = require("./layeredConfig-Dz9REO5H.cjs");
9
9
  const require_domains = require("./domains-9ffI7IYd.cjs");
10
10
  const require_harnessState = require("./harnessState-CQBNDL1D.cjs");
11
11
  const require_harnessStore = require("./harnessStore-Dgn3T4sR.cjs");
12
- const require_settingsApi = require("./settingsApi-DZ0hKFXA.cjs");
12
+ const require_settingsApi = require("./settingsApi-DW533fcN.cjs");
13
13
  const require_piConfig = require("./piConfig-cluCie5i.cjs");
14
- const require_majorModes = require("./majorModes-C6xu8OTJ.cjs");
14
+ const require_majorModes = require("./majorModes-B_1SnkQP.cjs");
15
15
  const require_profiles = require("./profiles-DZP_-bFs.cjs");
16
16
  const require_init = require("./init-B9tCCwA3.cjs");
17
17
  require("./config-zZz80Mh5.cjs");
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/services/settingsApi/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;qBAgCa,oBAAiB,IAAQ,eAAa"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/services/settingsApi/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;qBAuCa,oBAAiB,IAAQ,eAAa"}
package/dist/index.mjs CHANGED
@@ -8,9 +8,9 @@ import { r as PO_DIR } from "./layeredConfig-BWcYmZI7.mjs";
8
8
  import { _ as findPluginManifestPathAsync, b as isRemotePluginSource, c as resolvePluginDirectories, g as expandDomainNames, h as domainCompletionPrefix, l as resolvePluginEntries, m as domainCompletionItems, o as listDomainNames, s as loadDomains, u as resolveSharedSkills, v as findPluginManifestPath, x as pluginDirectoryForSource, y as MARKETPLACE_MANIFEST_RELATIVE_PATHS } from "./domains-BmdX_BMx.mjs";
9
9
  import { i as readHarnessState, n as HARNESS_STATE_KEYS, r as projectHarnessEnvironment, t as FILE_ONLY_STATE_FIELDS } from "./harnessState-ufE-npBa.mjs";
10
10
  import { _ as HARNESS_STATE_POINTER, a as requireHarnessPaths, d as getHarnessState, f as getSessionHarnessState, g as updateHarnessState, h as snapshotHarnessState, l as createHarnessSession, m as restoreHarnessStateSnapshot, o as requireHarnessRoot, p as loadHarnessState, r as harnessRoot, u as disposeHarnessState, v as resetHarnessStore } from "./harnessStore-yqKUx-kP.mjs";
11
- import { t as createSettingsApi } from "./settingsApi-CSog84S1.mjs";
11
+ import { t as createSettingsApi } from "./settingsApi-C7fWuifs.mjs";
12
12
  import { a as loadPiConfigAsync, c as piConfigPaths, d as MIN_IMAGE_MAX_DIMENSION, f as clampImageMaxDimension, i as loadPiConfig, l as piImageSettingsPath, o as loadPiImageSettings, p as parsePiImageSettings, s as savePiImageSettings, u as DEFAULT_IMAGE_MAX_DIMENSION } from "./piConfig-Bq36PQFF.mjs";
13
- import { a as loadMajorModesConfigLenient, c as layerEntries, i as loadMajorModesConfig, l as resolveLayers, r as readPackageConfigurations, s as isLocalPackageSpecifier, u as resolvePackageConfigurations } from "./majorModes-BQVTbC7k.mjs";
13
+ import { a as loadMajorModesConfigLenient, c as isLocalPackageSpecifier, d as resolveLayers, f as resolvePackageConfigurations, i as loadMajorModesConfig, l as layerEntries, r as readPackageConfigurations } from "./majorModes-eYzNJPBU.mjs";
14
14
  import { _ as replaceProfileEnvironment, f as loadProfiles, h as applyProfileEnvironment, l as buildPersonaPrompt, m as PERSONA_FILES, p as resolveProfile, u as listProfileNames } from "./profiles-Lf9s1Fb6.mjs";
15
15
  import { a as GLOBAL_PO_SEED_FILES, i as initializeRepositoryPoConfig, o as PO_CONFIG_TEMPLATES, r as initializeGlobalPoConfig, s as REPOSITORY_PO_CONFIG_TEMPLATES } from "./init-lw06fOB4.mjs";
16
16
  import { t as PO_CONFIG_SERVICE } from "./config-BBvn_ZLP.mjs";
@@ -439,6 +439,12 @@ Object.defineProperty(exports, "MODES_FILE", {
439
439
  return MODES_FILE;
440
440
  }
441
441
  });
442
+ Object.defineProperty(exports, "composeMajorModesConfig", {
443
+ enumerable: true,
444
+ get: function() {
445
+ return composeMajorModesConfig;
446
+ }
447
+ });
442
448
  Object.defineProperty(exports, "isLocalPackageSpecifier", {
443
449
  enumerable: true,
444
450
  get: function() {
@@ -463,6 +469,12 @@ Object.defineProperty(exports, "loadMajorModesConfigLenient", {
463
469
  return loadMajorModesConfigLenient;
464
470
  }
465
471
  });
472
+ Object.defineProperty(exports, "parseLayer", {
473
+ enumerable: true,
474
+ get: function() {
475
+ return parseLayer;
476
+ }
477
+ });
466
478
  Object.defineProperty(exports, "readMajorModesConfig", {
467
479
  enumerable: true,
468
480
  get: function() {
@@ -494,4 +506,4 @@ Object.defineProperty(exports, "resolvePackageConfigurations", {
494
506
  }
495
507
  });
496
508
 
497
- //# sourceMappingURL=majorModes-C6xu8OTJ.cjs.map
509
+ //# sourceMappingURL=majorModes-B_1SnkQP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"majorModes-B_1SnkQP.cjs","names":["path","localPackageName","splitPackageSpecifier","os","readPoConfigSources","path","getOrThrow","readTextIfExists","nodeHost","readPoConfigSourcesAsync"],"sources":["../src/services/majorModes/core.ts","../src/services/majorModes/sync.ts","../src/services/majorModes/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport type { ConfigDiagnostic } from '../../types/config';\nimport { PO_DIR, type PoConfigProvenance, type PoConfigSource } from '../layeredConfig';\n\nexport type LayerPackageConfig = Record<string, unknown>;\n\n/** One package selected by a layer, plus configuration owned by that package. */\nexport interface LayerPackage {\n name: string;\n optional?: boolean;\n config?: LayerPackageConfig;\n}\n\n/** One configured package found while walking selected layers in order. */\nexport interface ResolvedPackageConfiguration {\n layer: string;\n specifier: string;\n config: LayerPackageConfig;\n baseDirectory: string;\n filePath?: string;\n}\n\nexport interface LayerDefinition {\n /**\n * Po built-in names, or Pi-compatible local extension paths.\n * Bare names resolve from Po's own extension entries. Paths beginning\n * with `./` or `../`, plus absolute paths, resolve against the config that\n * declares the layer and may name a script file or extension directory.\n */\n extensions?: string[];\n /**\n * npm specifiers, or local package paths retained for compatibility.\n * Relative paths resolve against the repository root for `.po/modes.yaml`\n * and against the global `.po` directory for\n * `~/.po/modes.yaml`.\n */\n packages?: Array<string | LayerPackage>;\n /** Legacy configuration accepted for compatibility, with no runtime effect. */\n hookGroups?: string[];\n}\n\n/** A layer plus the root its relative extension and package paths resolve against. */\nexport interface ResolvedLayerDefinition extends LayerDefinition {\n baseDirectory: string;\n /** Absolute path of the modes file that declared this layer. */\n filePath?: string;\n}\n\nexport interface MajorModeDefinition {\n /** Human-readable purpose used by pickers and agent-facing catalogs. */\n description: string;\n /** Ordered layer names activated by this mode. */\n layers: string[];\n}\n\nexport interface MajorModesConfig {\n /** Unconditional package bundle loaded before packages from selected named layers. */\n default?: ResolvedLayerDefinition;\n layers: Record<string, ResolvedLayerDefinition>;\n /** The mode selected when neither a flag nor the environment names one. */\n defaultMajorMode: string;\n /** Source that last declared the default, absent for the built-in fallback. */\n defaultMajorModeSource?: PoConfigProvenance;\n /** Named major modes, including their purpose and ordered layers. */\n majorMode: Record<string, MajorModeDefinition>;\n /** Declaring source for each surviving named mode. */\n majorModeSources?: Record<string, PoConfigProvenance>;\n}\n\nexport interface LayerResolvers {\n ownEntry: (name: string) => string;\n packageEntry: (name: string) => string;\n optionalPackageEntry: (name: string) => string | undefined;\n /** Resolves every standard package.json pi.extensions entry for a package root. */\n packageEntries?: (name: string) => string[];\n /** Optional counterpart to packageEntries. */\n optionalPackageEntries?: (name: string) => string[] | undefined;\n /** Resolves one path-style layer entry against the config that declared it. */\n localEntry: (specifier: string, baseDirectory: string) => string | undefined;\n /** Resolves every Pi extension entry contributed by a local file or directory. */\n localEntries?: (specifier: string, baseDirectory: string) => string[] | undefined;\n}\n\n/**\n * The npm package name a layer package specifier stands for, or undefined when\n * it names none. Injected because answering it for a local path reads that\n * directory's package.json, which `moduleResolution` does on Node and a\n * precomputed composition answers on the edge.\n */\nexport type PackageNameResolver = (specifier: string, baseDirectory: string) => string | undefined;\n\nexport interface ModesDocument {\n default?: unknown;\n layers?: unknown;\n defaultMajorMode?: unknown;\n majorMode?: unknown;\n}\n\nexport const MODES_FILE = 'modes.yaml';\nconst FALLBACK_MAJOR_MODE = 'copilot';\nconst MAJOR_MODES_RELATIVE_PATH = path.join(PO_DIR, MODES_FILE);\nconst RELATIVE_PREFIXES = ['./', '../'] as const;\nconst DEFAULT_KEYS = ['packages'] as const;\n\n/**\n * Whether a layer value names a path rather than a built-in or installed package.\n *\n * The same rule Node applies to import specifiers, so a bare name is always a\n * logical name and a path always looks like one.\n */\nexport function isLocalPackageSpecifier(specifier: string): boolean {\n return path.isAbsolute(specifier) || RELATIVE_PREFIXES.some((prefix) => specifier.startsWith(prefix));\n}\nconst LAYER_PACKAGE_KEYS = ['name', 'optional', 'config'] as const;\nconst MAJOR_MODE_KEYS = ['description', 'layers'] as const;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Where a lenient load collects unknown keys instead of throwing.\n *\n * Same shape as the sink in configPolicy, for the same reason: `assertKnownKeys`\n * is the only reader and the whole composition is synchronous.\n */\nlet unknownKeySink: ConfigDiagnostic[] | undefined;\n\nfunction assertKnownKeys(value: Record<string, unknown>, keys: readonly string[], location: string): void {\n const unsupported = Object.keys(value).filter((key) => !keys.includes(key));\n if (unsupported.length === 0) return;\n if (unknownKeySink !== undefined) {\n for (const key of unsupported) {\n unknownKeySink.push({\n filePath: MAJOR_MODES_RELATIVE_PATH,\n path: key,\n message: `${location} has unsupported field`,\n });\n }\n return;\n }\n throw new Error(`${location} has unsupported field(s): ${unsupported.join(', ')}`);\n}\n\nconst RETIRED_LOOP_PACKAGE = '@agimon-ai/po-loop';\n\nfunction assertNotRetired(name: string, location: string): void {\n if (name !== RETIRED_LOOP_PACKAGE && !name.startsWith(`${RETIRED_LOOP_PACKAGE}@`)) return;\n throw new Error(\n `${location} uses the retired ${RETIRED_LOOP_PACKAGE}. Replace it with @agimon-ai/po-calendar. ` +\n 'Loops from the old package are not migrated; recreate them as Calendar events.',\n );\n}\n\nfunction parseLayerPackage(layerName: string, value: unknown, index: number): string | LayerPackage {\n const location = `Layer \"${layerName}\" package[${index}] in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (typeof value === 'string') {\n if (!value.trim()) throw new Error(`${location} must be a non-empty string or mapping`);\n assertNotRetired(value.trim(), location);\n return value.trim();\n }\n if (!isRecord(value)) throw new Error(`${location} must be a non-empty string or mapping`);\n assertKnownKeys(value, LAYER_PACKAGE_KEYS, location);\n if (typeof value.name !== 'string' || !value.name.trim()) {\n throw new Error(`${location}.name must be a non-empty string`);\n }\n if (value.optional !== undefined && typeof value.optional !== 'boolean') {\n throw new Error(`${location}.optional must be a boolean`);\n }\n if (value.config !== undefined && !isRecord(value.config)) {\n throw new Error(`${location}.config must be a mapping`);\n }\n assertNotRetired(value.name.trim(), location);\n return {\n name: value.name.trim(),\n ...(value.optional === true ? { optional: true } : {}),\n ...(value.config ? { config: { ...value.config } } : {}),\n };\n}\n\nfunction parseLayerExtensions(layerName: string, value: unknown): string[] | undefined {\n if (value === undefined) return undefined;\n const location = `Layer \"${layerName}\" extensions in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!Array.isArray(value)) throw new Error(`${location} must be an array`);\n return value.map((entry, index) => {\n if (typeof entry !== 'string' || !entry.trim()) {\n throw new Error(`${location}[${index}] must be a non-empty string`);\n }\n return entry.trim();\n });\n}\n\nfunction parseLayerPackages(layerName: string, value: unknown): Array<string | LayerPackage> | undefined {\n if (value === undefined) return undefined;\n if (!Array.isArray(value)) {\n throw new Error(`Layer \"${layerName}\" packages in ${MAJOR_MODES_RELATIVE_PATH} must be an array`);\n }\n return value.map((entry, index) => parseLayerPackage(layerName, entry, index));\n}\n\nfunction parseDefaultMajorMode(value: unknown): string {\n if (typeof value !== 'string' || !value.trim()) {\n throw new Error(`defaultMajorMode in ${MAJOR_MODES_RELATIVE_PATH} must be a non-empty string`);\n }\n return value.trim();\n}\n\nfunction parseMajorModeLayers(modeName: string, value: unknown): string[] {\n const location = `Major mode \"${modeName}\" layers in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!Array.isArray(value)) throw new Error(`${location} must be an array`);\n return value.map((layerName, index) => {\n if (typeof layerName !== 'string' || !layerName.trim()) {\n throw new Error(`${location}[${index}] must be a non-empty string`);\n }\n return layerName.trim();\n });\n}\n\nfunction legacyMajorModeDescription(layers: readonly string[]): string {\n return layers.length > 0 ? `Uses layers: ${layers.join(', ')}.` : 'Uses Po Pi core extensions only.';\n}\n\nfunction parseMajorMode(name: string, value: unknown): MajorModeDefinition {\n if (Array.isArray(value)) {\n const layers = parseMajorModeLayers(name, value);\n return { description: legacyMajorModeDescription(layers), layers };\n }\n\n const location = `Major mode \"${name}\" in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!isRecord(value)) throw new Error(`${location} must be a mapping with description and layers`);\n assertKnownKeys(value, MAJOR_MODE_KEYS, location);\n if (typeof value.description !== 'string' || !value.description.trim()) {\n throw new Error(`${location}.description must be a non-empty string`);\n }\n return {\n description: value.description.trim(),\n layers: parseMajorModeLayers(name, value.layers),\n };\n}\n\nfunction parseMajorModes(value: unknown): Record<string, MajorModeDefinition | null> {\n if (value === undefined) return {};\n if (!isRecord(value)) throw new Error(`majorMode in ${MAJOR_MODES_RELATIVE_PATH} must be a mapping`);\n return Object.fromEntries(\n Object.entries(value).map(([name, definition]) => [\n name,\n definition === null ? null : parseMajorMode(name, definition),\n ]),\n );\n}\n\nexport function parseLayer(name: string, definition: unknown): LayerDefinition {\n if (!isRecord(definition)) throw new Error(`Layer \"${name}\" in ${MAJOR_MODES_RELATIVE_PATH} must be a mapping`);\n if ('targets' in definition) {\n throw new Error(\n `Layer \"${name}\" in ${MAJOR_MODES_RELATIVE_PATH} uses removed field \"targets\"; select availability through major modes`,\n );\n }\n if ('config' in definition) {\n throw new Error(\n `Layer \"${name}\" in ${MAJOR_MODES_RELATIVE_PATH} uses unsupported field \"config\"; move it under the package entry that owns it`,\n );\n }\n const extensions = parseLayerExtensions(name, definition.extensions);\n const packages = parseLayerPackages(name, definition.packages);\n return {\n ...definition,\n ...(extensions === undefined ? {} : { extensions }),\n ...(packages === undefined ? {} : { packages }),\n } as LayerDefinition;\n}\n\nfunction parseLayers(value: unknown): Record<string, LayerDefinition | null> {\n if (value === undefined) return {};\n if (!isRecord(value)) throw new Error(`layers in ${MAJOR_MODES_RELATIVE_PATH} must be a mapping`);\n return Object.fromEntries(\n Object.entries(value).map(([name, definition]) => [\n name,\n definition === null ? null : parseLayer(name, definition),\n ]),\n );\n}\n\nfunction parseDefault(value: unknown): LayerDefinition {\n const location = `default in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!isRecord(value)) throw new Error(`${location} must be a mapping with packages`);\n assertKnownKeys(value, DEFAULT_KEYS, location);\n if (!Object.hasOwn(value, 'packages')) {\n throw new Error(`Layer \"default\" packages in ${MAJOR_MODES_RELATIVE_PATH} must be an array`);\n }\n const packages = parseLayerPackages('default', value.packages);\n return { packages };\n}\n\n/**\n * Folds the global and repository modes documents, lowest precedence first.\n *\n * The repository is read last, so it replaces a global layer or major mode of\n * the same name. Layers keep the root they were declared under so that a\n * global layer naming `./extensions/x` still points beside the global config\n * once it is loaded from inside some other repository.\n */\nexport function composeMajorModesConfig(\n sources: ReadonlyArray<PoConfigSource<ModesDocument>>,\n repoRoot: string,\n environment: NodeJS.ProcessEnv,\n resolvePackageName: PackageNameResolver,\n): MajorModesConfig {\n let defaultDefinition: ResolvedLayerDefinition | undefined;\n const layers: Record<string, ResolvedLayerDefinition> = {};\n const majorMode: Record<string, MajorModeDefinition> = {};\n const majorModeSources: Record<string, PoConfigProvenance> = {};\n let defaultMajorMode = FALLBACK_MAJOR_MODE;\n let defaultMajorModeSource: PoConfigProvenance | undefined;\n let hasConfiguredDefault = false;\n for (const source of sources) {\n if (Object.hasOwn(source.document, 'default')) {\n defaultDefinition = {\n ...parseDefault(source.document.default),\n baseDirectory: source.baseDirectory,\n filePath: source.filePath,\n };\n }\n for (const [name, definition] of Object.entries(parseLayers(source.document.layers))) {\n if (definition === null) {\n delete layers[name];\n continue;\n }\n layers[name] = {\n ...definition,\n baseDirectory: source.baseDirectory,\n filePath: source.filePath,\n };\n }\n if (Object.hasOwn(source.document, 'defaultMajorMode')) {\n defaultMajorMode = parseDefaultMajorMode(source.document.defaultMajorMode);\n defaultMajorModeSource = { filePath: source.filePath, baseDirectory: source.baseDirectory };\n hasConfiguredDefault = true;\n }\n for (const [name, definition] of Object.entries(parseMajorModes(source.document.majorMode))) {\n if (definition === null) {\n delete majorMode[name];\n delete majorModeSources[name];\n continue;\n }\n majorMode[name] = definition;\n majorModeSources[name] = { filePath: source.filePath, baseDirectory: source.baseDirectory };\n }\n }\n\n for (const [modeName, definition] of Object.entries(majorMode)) {\n for (const name of definition.layers) {\n if (!layers[name]) {\n throw new Error(`Unknown layer \"${name}\" in majorMode.${modeName} of ${MAJOR_MODES_RELATIVE_PATH}`);\n }\n }\n }\n if (hasConfiguredDefault && !Object.hasOwn(majorMode, defaultMajorMode)) {\n throw new Error(`Unknown default major mode \"${defaultMajorMode}\" in ${MAJOR_MODES_RELATIVE_PATH}`);\n }\n if (environment.PO_DISTRIBUTION === 'desktop') {\n const computerUsePackage = '@agimon-ai/po-computer-use';\n const packages = defaultDefinition?.packages ?? [];\n const hasComputerUse = packages.some((entry) => {\n const specifier = typeof entry === 'string' ? entry : entry.name;\n return resolvePackageName(specifier, defaultDefinition?.baseDirectory ?? repoRoot) === computerUsePackage;\n });\n if (!hasComputerUse) {\n defaultDefinition = {\n ...(defaultDefinition ?? { baseDirectory: repoRoot }),\n packages: [...packages, computerUsePackage],\n };\n }\n }\n return {\n ...(defaultDefinition ? { default: defaultDefinition } : {}),\n layers,\n defaultMajorMode,\n ...(defaultMajorModeSource ? { defaultMajorModeSource } : {}),\n majorMode,\n majorModeSources,\n };\n}\n\n/**\n * Finds configuration owned by one package while preserving layer and package order.\n * Pass a resolver to match local package paths by name without changing their specifiers.\n */\nexport function resolvePackageConfigurations(\n config: MajorModesConfig,\n names: string[],\n packageName: string,\n resolvePackageName?: PackageNameResolver,\n): ResolvedPackageConfiguration[] {\n const normalizedPackageName = packageName.trim();\n if (!normalizedPackageName) throw new Error('Package name must be a non-empty string');\n const configurations: ResolvedPackageConfiguration[] = [];\n const definitions: Array<{ name: string; definition: ResolvedLayerDefinition }> = [];\n if (config.default) definitions.push({ name: 'default', definition: config.default });\n for (const name of names) {\n const definition = config.layers[name];\n if (!definition) throw new Error(`Unknown layer: ${name}`);\n definitions.push({ name, definition });\n }\n for (const { name, definition } of definitions) {\n for (const entry of definition.packages ?? []) {\n if (typeof entry === 'string' || entry.config === undefined) continue;\n const resolvedName = resolvePackageName?.(entry.name, definition.baseDirectory) ?? entry.name;\n if (resolvedName !== normalizedPackageName && !resolvedName.startsWith(`${normalizedPackageName}/`)) continue;\n configurations.push({\n layer: name,\n specifier: entry.name,\n config: { ...entry.config },\n baseDirectory: definition.baseDirectory,\n ...(definition.filePath ? { filePath: definition.filePath } : {}),\n });\n }\n }\n return configurations;\n}\n\n/** Resolves one named major mode into its configured layer components. */\nexport function resolveLayers(config: MajorModesConfig, majorMode: string): string[] {\n if (!Object.hasOwn(config.majorMode, majorMode)) {\n throw new Error(\n `Unknown major mode: ${majorMode}. Known major modes: ${Object.keys(config.majorMode).sort().join(', ')}`,\n );\n }\n return [...config.majorMode[majorMode]!.layers];\n}\n\nfunction resolveLocalEntries(\n resolvers: LayerResolvers,\n specifier: string,\n baseDirectory: string,\n): string[] | undefined {\n const resolved = resolvers.localEntries?.(specifier, baseDirectory);\n if (resolved !== undefined) return resolved;\n const single = resolvers.localEntry(specifier, baseDirectory);\n return single ? [single] : undefined;\n}\n\n/** Resolves one layer's extension and package entries to absolute paths. */\nexport function layerEntries(config: MajorModesConfig, name: string, resolvers: LayerResolvers): string[] {\n const layer = config.layers[name];\n if (!layer) throw new Error(`Unknown layer: ${name}`);\n const entries: string[] = [];\n for (const entry of layer.extensions ?? []) {\n if (!isLocalPackageSpecifier(entry)) {\n entries.push(resolvers.ownEntry(entry));\n continue;\n }\n const resolved = resolveLocalEntries(resolvers, entry, layer.baseDirectory);\n if (!resolved?.length) {\n throw new Error(\n `Layer \"${name}\" extension \"${entry}\" does not resolve under ${layer.baseDirectory}. ` +\n 'Point it at a Pi extension file or directory.',\n );\n }\n entries.push(...resolved);\n }\n for (const entry of layer.packages ?? []) {\n const specifier = typeof entry === 'string' ? entry : entry.name;\n const optional = typeof entry === 'string' ? false : entry.optional === true;\n if (isLocalPackageSpecifier(specifier)) {\n const resolved = resolveLocalEntries(resolvers, specifier, layer.baseDirectory);\n if (resolved?.length) entries.push(...resolved);\n else if (!optional) {\n throw new Error(\n `Layer \"${name}\" package \"${specifier}\" does not resolve under ${layer.baseDirectory}. ` +\n 'Point it at an extension file, or a directory whose package.json declares pi.extensions.',\n );\n }\n continue;\n }\n if (optional) {\n let resolved = resolvers.optionalPackageEntries?.(specifier);\n if (resolved === undefined) {\n const single = resolvers.optionalPackageEntry(specifier);\n resolved = single ? [single] : undefined;\n }\n if (resolved) entries.push(...resolved);\n continue;\n }\n const resolved = resolvers.packageEntries?.(specifier) ?? [resolvers.packageEntry(specifier)];\n if (resolved.length === 0) {\n throw new Error(`Layer \"${name}\" package \"${specifier}\" declares no Pi extensions.`);\n }\n entries.push(...resolved);\n }\n return entries;\n}\n\n/** As `composeMajorModesConfig`, collecting unknown keys as diagnostics instead of throwing. */\nexport function composeMajorModesConfigLenient(\n sources: ReadonlyArray<PoConfigSource<ModesDocument>>,\n repoRoot: string,\n environment: NodeJS.ProcessEnv,\n resolvePackageName: PackageNameResolver,\n): { config: MajorModesConfig; diagnostics: ConfigDiagnostic[] } {\n const diagnostics: ConfigDiagnostic[] = [];\n const previous = unknownKeySink;\n unknownKeySink = diagnostics;\n try {\n return { config: composeMajorModesConfig(sources, repoRoot, environment, resolvePackageName), diagnostics };\n } finally {\n unknownKeySink = previous;\n }\n}\n","import os from 'node:os';\n\nimport { localPackageName, splitPackageSpecifier } from '@agimon-ai/po-core/moduleResolution';\n\nimport type { ConfigDiagnostic } from '../../types/config';\nimport { readPoConfigSources } from '../layeredConfig';\nimport {\n MODES_FILE,\n composeMajorModesConfig,\n composeMajorModesConfigLenient,\n isLocalPackageSpecifier,\n type MajorModesConfig,\n type ModesDocument,\n} from './core';\n\n/** Node's answer: a local path names the package its package.json declares. */\nfunction nodePackageName(specifier: string, baseDirectory: string): string | undefined {\n return isLocalPackageSpecifier(specifier)\n ? localPackageName(specifier, baseDirectory)\n : splitPackageSpecifier(specifier).name;\n}\n\n/**\n * Reads layers and major modes from the global and repository configs.\n *\n * The repository is read last, so it replaces a global layer or major mode of\n * the same name. Layers keep the root they were declared under so that a\n * global layer naming `./extensions/x` still points beside the global config\n * once it is loaded from inside some other repository.\n *\n * @deprecated Node-only sync shim; use readMajorModesConfig. Removed in M2.\n */\nexport function loadMajorModesConfig(\n repoRoot: string,\n homeDirectory: string = os.homedir(),\n environment: NodeJS.ProcessEnv = process.env,\n): MajorModesConfig {\n const sources = readPoConfigSources<ModesDocument>(MODES_FILE, repoRoot, homeDirectory);\n return composeMajorModesConfig(sources, repoRoot, environment, nodePackageName);\n}\n\n/**\n * Reads layers and major modes, tolerating unknown keys.\n *\n * `po sync` uses this so a modes.yaml written against a different set of\n * layer packages cannot break a build. Every other caller keeps the strict\n * `loadMajorModesConfig`, and `po doctor` still reports what was tolerated.\n *\n * @deprecated Node-only sync shim; use readMajorModesConfigLenient. Removed in M2.\n */\nexport function loadMajorModesConfigLenient(\n repoRoot: string,\n homeDirectory: string = os.homedir(),\n environment: NodeJS.ProcessEnv = process.env,\n): { config: MajorModesConfig; diagnostics: ConfigDiagnostic[] } {\n const sources = readPoConfigSources<ModesDocument>(MODES_FILE, repoRoot, homeDirectory);\n return composeMajorModesConfigLenient(sources, repoRoot, environment, nodePackageName);\n}\n","import path from 'node:path';\n\nimport { getOrThrow, nodeHost, readTextIfExists, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport type { ConfigDiagnostic } from '../../types/config';\nimport { readPoConfigSourcesAsync, type PoConfigSource } from '../layeredConfig';\nimport {\n MODES_FILE,\n composeMajorModesConfig,\n composeMajorModesConfigLenient,\n isLocalPackageSpecifier,\n resolvePackageConfigurations,\n type MajorModesConfig,\n type ModesDocument,\n type PackageNameResolver,\n type ResolvedPackageConfiguration,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nconst PACKAGE_MANIFEST = 'package.json';\nconst SCOPE_PREFIX = '@';\n\nexport interface ReadMajorModesConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Defaults to `process.env`. */\n readonly environment?: NodeJS.ProcessEnv;\n /**\n * Names the package a layer specifier stands for. Pass one built from a\n * precomputed composition on the edge; by default local paths are answered\n * from their package.json over `fs`.\n */\n readonly resolvePackageName?: PackageNameResolver;\n}\n\n/** `@scope/name/sub` to `@scope/name`, `name/sub` to `name`. */\nfunction bareSpecifierName(specifier: string): string {\n const segments = specifier.split('/');\n return segments.slice(0, specifier.startsWith(SCOPE_PREFIX) ? 2 : 1).join('/');\n}\n\nasync function localPackageNameAsync(\n fs: FileSystem,\n specifier: string,\n baseDirectory: string,\n context: IoContext,\n): Promise<string | undefined> {\n const target = path.resolve(baseDirectory, specifier);\n try {\n const real = getOrThrow(await fs.canonicalPath(target, context));\n if (getOrThrow(await fs.fileInfo(real, context)).kind !== 'directory') return undefined;\n const text = await readTextIfExists(fs, path.join(target, PACKAGE_MANIFEST), context);\n if (text === undefined) return undefined;\n const manifest = JSON.parse(text) as { name?: unknown };\n return typeof manifest.name === 'string' && manifest.name.trim() ? manifest.name.trim() : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Only the desktop distribution asks for package names, and only of the\n * `default` packages, so those are the local paths read ahead of the\n * synchronous composition.\n */\nasync function precomputedPackageNames(\n fs: FileSystem,\n sources: ReadonlyArray<PoConfigSource<ModesDocument>>,\n environment: NodeJS.ProcessEnv,\n context: IoContext,\n): Promise<PackageNameResolver> {\n const names = new Map<string, string | undefined>();\n const key = (specifier: string, baseDirectory: string) => `${baseDirectory}\\0${specifier}`;\n if (environment.PO_DISTRIBUTION === 'desktop') {\n for (const source of sources) {\n const packages = (source.document.default as { packages?: unknown } | undefined)?.packages;\n if (!Array.isArray(packages)) continue;\n for (const entry of packages) {\n const raw = typeof entry === 'string' ? entry : (entry as { name?: unknown } | null)?.name;\n if (typeof raw !== 'string' || !isLocalPackageSpecifier(raw.trim())) continue;\n const specifier = raw.trim();\n names.set(\n key(specifier, source.baseDirectory),\n await localPackageNameAsync(fs, specifier, source.baseDirectory, context),\n );\n }\n }\n }\n return (specifier, baseDirectory) =>\n isLocalPackageSpecifier(specifier) ? names.get(key(specifier, baseDirectory)) : bareSpecifierName(specifier);\n}\n\nasync function readModes(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadMajorModesConfigOptions,\n): Promise<{\n sources: Array<PoConfigSource<ModesDocument>>;\n environment: NodeJS.ProcessEnv;\n resolvePackageName: PackageNameResolver;\n}> {\n const homeDirectory = options.homeDirectory ?? nodeHost.homeDirectory();\n const environment = options.environment ?? process.env;\n const sources = await readPoConfigSourcesAsync<ModesDocument>(fs, MODES_FILE, repoRoot, context, homeDirectory);\n const resolvePackageName =\n options.resolvePackageName ?? (await precomputedPackageNames(fs, sources, environment, context));\n return { sources, environment, resolvePackageName };\n}\n\n/** Reads layers and major modes over a FileSystem; the same answer as `loadMajorModesConfig`. */\nexport async function readMajorModesConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadMajorModesConfigOptions = {},\n): Promise<MajorModesConfig> {\n const { sources, environment, resolvePackageName } = await readModes(fs, repoRoot, context, options);\n return composeMajorModesConfig(sources, repoRoot, environment, resolvePackageName);\n}\n\n/** As `readMajorModesConfig`, tolerating unknown keys and reporting them. */\nexport async function readMajorModesConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadMajorModesConfigOptions = {},\n): Promise<{ config: MajorModesConfig; diagnostics: ConfigDiagnostic[] }> {\n const { sources, environment, resolvePackageName } = await readModes(fs, repoRoot, context, options);\n return composeMajorModesConfigLenient(sources, repoRoot, environment, resolvePackageName);\n}\n\n/**\n * Reads local package names over a FileSystem, then finds package-owned config.\n * Keeps the original specifiers, source directories, and default/selected-layer order.\n * Missing or invalid local manifests do not match a package name.\n */\nexport async function readPackageConfigurations(\n fs: FileSystem,\n config: MajorModesConfig,\n names: string[],\n packageName: string,\n context: IoContext,\n): Promise<ResolvedPackageConfiguration[]> {\n const packageNames = new Map<string, string | undefined>();\n const key = (specifier: string, baseDirectory: string) => `${baseDirectory}\\0${specifier}`;\n for (const definition of [config.default, ...names.map((name) => config.layers[name])]) {\n if (!definition) continue;\n for (const entry of definition.packages ?? []) {\n if (typeof entry === 'string' || entry.config === undefined || !isLocalPackageSpecifier(entry.name)) {\n continue;\n }\n const entryKey = key(entry.name, definition.baseDirectory);\n if (!packageNames.has(entryKey)) {\n packageNames.set(entryKey, await localPackageNameAsync(fs, entry.name, definition.baseDirectory, context));\n }\n }\n }\n return resolvePackageConfigurations(config, names, packageName, (specifier, baseDirectory) =>\n packageNames.get(key(specifier, baseDirectory)),\n );\n}\n\nexport { isLocalPackageSpecifier, layerEntries, resolveLayers, resolvePackageConfigurations } from './core';\nexport type {\n LayerDefinition,\n LayerPackage,\n LayerPackageConfig,\n LayerResolvers,\n MajorModeDefinition,\n MajorModesConfig,\n PackageNameResolver,\n ResolvedLayerDefinition,\n ResolvedPackageConfiguration,\n} from './core';\nexport { loadMajorModesConfig, loadMajorModesConfigLenient } from './sync';\n"],"mappings":";;;;;;;;;AAmGA,MAAa,aAAa;AAC1B,MAAM,sBAAsB;AAC5B,MAAM,4BAA4BA,UAAAA,QAAK,KAAA,OAAa,UAAU;AAC9D,MAAM,oBAAoB,CAAC,MAAM,KAAK;AACtC,MAAM,eAAe,CAAC,UAAU;;;;;;;AAQhC,SAAgB,wBAAwB,WAA4B;CAClE,OAAOA,UAAAA,QAAK,WAAW,SAAS,KAAK,kBAAkB,MAAM,WAAW,UAAU,WAAW,MAAM,CAAC;AACtG;AACA,MAAM,qBAAqB;CAAC;CAAQ;CAAY;AAAQ;AACxD,MAAM,kBAAkB,CAAC,eAAe,QAAQ;AAEhD,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;;;;;;AAQA,IAAI;AAEJ,SAAS,gBAAgB,OAAgC,MAAyB,UAAwB;CACxG,MAAM,cAAc,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,QAAQ,CAAC,KAAK,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AM,WAAW,IAAI,MAAM,MAAM,WAAW,aAAa;GACzD,IAAI,CAAC,aAAa,IAAI,QAAQ,GAC5B,aAAa,IAAI,UAAU,MAAM,sBAAsB,IAAI,MAAM,MAAM,WAAW,eAAe,OAAO,CAAC;EAE7G;CACF;CACA,OAAO,6BAA6B,QAAQ,OAAO,cAAc,WAAW,kBAC1E,aAAa,IAAI,IAAI,WAAW,aAAa,CAAC,CAChD;AACF"}
@@ -430,6 +430,6 @@ async function readPackageConfigurations(fs, config, names, packageName, context
430
430
  return resolvePackageConfigurations(config, names, packageName, (specifier, baseDirectory) => packageNames.get(key(specifier, baseDirectory)));
431
431
  }
432
432
  //#endregion
433
- export { loadMajorModesConfigLenient as a, layerEntries as c, loadMajorModesConfig as i, resolveLayers as l, readMajorModesConfigLenient as n, MODES_FILE as o, readPackageConfigurations as r, isLocalPackageSpecifier as s, readMajorModesConfig as t, resolvePackageConfigurations as u };
433
+ export { loadMajorModesConfigLenient as a, isLocalPackageSpecifier as c, resolveLayers as d, resolvePackageConfigurations as f, loadMajorModesConfig as i, layerEntries as l, readMajorModesConfigLenient as n, MODES_FILE as o, readPackageConfigurations as r, composeMajorModesConfig as s, readMajorModesConfig as t, parseLayer as u };
434
434
 
435
- //# sourceMappingURL=majorModes-BQVTbC7k.mjs.map
435
+ //# sourceMappingURL=majorModes-eYzNJPBU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"majorModes-eYzNJPBU.mjs","names":[],"sources":["../src/services/majorModes/core.ts","../src/services/majorModes/sync.ts","../src/services/majorModes/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport type { ConfigDiagnostic } from '../../types/config';\nimport { PO_DIR, type PoConfigProvenance, type PoConfigSource } from '../layeredConfig';\n\nexport type LayerPackageConfig = Record<string, unknown>;\n\n/** One package selected by a layer, plus configuration owned by that package. */\nexport interface LayerPackage {\n name: string;\n optional?: boolean;\n config?: LayerPackageConfig;\n}\n\n/** One configured package found while walking selected layers in order. */\nexport interface ResolvedPackageConfiguration {\n layer: string;\n specifier: string;\n config: LayerPackageConfig;\n baseDirectory: string;\n filePath?: string;\n}\n\nexport interface LayerDefinition {\n /**\n * Po built-in names, or Pi-compatible local extension paths.\n * Bare names resolve from Po's own extension entries. Paths beginning\n * with `./` or `../`, plus absolute paths, resolve against the config that\n * declares the layer and may name a script file or extension directory.\n */\n extensions?: string[];\n /**\n * npm specifiers, or local package paths retained for compatibility.\n * Relative paths resolve against the repository root for `.po/modes.yaml`\n * and against the global `.po` directory for\n * `~/.po/modes.yaml`.\n */\n packages?: Array<string | LayerPackage>;\n /** Legacy configuration accepted for compatibility, with no runtime effect. */\n hookGroups?: string[];\n}\n\n/** A layer plus the root its relative extension and package paths resolve against. */\nexport interface ResolvedLayerDefinition extends LayerDefinition {\n baseDirectory: string;\n /** Absolute path of the modes file that declared this layer. */\n filePath?: string;\n}\n\nexport interface MajorModeDefinition {\n /** Human-readable purpose used by pickers and agent-facing catalogs. */\n description: string;\n /** Ordered layer names activated by this mode. */\n layers: string[];\n}\n\nexport interface MajorModesConfig {\n /** Unconditional package bundle loaded before packages from selected named layers. */\n default?: ResolvedLayerDefinition;\n layers: Record<string, ResolvedLayerDefinition>;\n /** The mode selected when neither a flag nor the environment names one. */\n defaultMajorMode: string;\n /** Source that last declared the default, absent for the built-in fallback. */\n defaultMajorModeSource?: PoConfigProvenance;\n /** Named major modes, including their purpose and ordered layers. */\n majorMode: Record<string, MajorModeDefinition>;\n /** Declaring source for each surviving named mode. */\n majorModeSources?: Record<string, PoConfigProvenance>;\n}\n\nexport interface LayerResolvers {\n ownEntry: (name: string) => string;\n packageEntry: (name: string) => string;\n optionalPackageEntry: (name: string) => string | undefined;\n /** Resolves every standard package.json pi.extensions entry for a package root. */\n packageEntries?: (name: string) => string[];\n /** Optional counterpart to packageEntries. */\n optionalPackageEntries?: (name: string) => string[] | undefined;\n /** Resolves one path-style layer entry against the config that declared it. */\n localEntry: (specifier: string, baseDirectory: string) => string | undefined;\n /** Resolves every Pi extension entry contributed by a local file or directory. */\n localEntries?: (specifier: string, baseDirectory: string) => string[] | undefined;\n}\n\n/**\n * The npm package name a layer package specifier stands for, or undefined when\n * it names none. Injected because answering it for a local path reads that\n * directory's package.json, which `moduleResolution` does on Node and a\n * precomputed composition answers on the edge.\n */\nexport type PackageNameResolver = (specifier: string, baseDirectory: string) => string | undefined;\n\nexport interface ModesDocument {\n default?: unknown;\n layers?: unknown;\n defaultMajorMode?: unknown;\n majorMode?: unknown;\n}\n\nexport const MODES_FILE = 'modes.yaml';\nconst FALLBACK_MAJOR_MODE = 'copilot';\nconst MAJOR_MODES_RELATIVE_PATH = path.join(PO_DIR, MODES_FILE);\nconst RELATIVE_PREFIXES = ['./', '../'] as const;\nconst DEFAULT_KEYS = ['packages'] as const;\n\n/**\n * Whether a layer value names a path rather than a built-in or installed package.\n *\n * The same rule Node applies to import specifiers, so a bare name is always a\n * logical name and a path always looks like one.\n */\nexport function isLocalPackageSpecifier(specifier: string): boolean {\n return path.isAbsolute(specifier) || RELATIVE_PREFIXES.some((prefix) => specifier.startsWith(prefix));\n}\nconst LAYER_PACKAGE_KEYS = ['name', 'optional', 'config'] as const;\nconst MAJOR_MODE_KEYS = ['description', 'layers'] as const;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Where a lenient load collects unknown keys instead of throwing.\n *\n * Same shape as the sink in configPolicy, for the same reason: `assertKnownKeys`\n * is the only reader and the whole composition is synchronous.\n */\nlet unknownKeySink: ConfigDiagnostic[] | undefined;\n\nfunction assertKnownKeys(value: Record<string, unknown>, keys: readonly string[], location: string): void {\n const unsupported = Object.keys(value).filter((key) => !keys.includes(key));\n if (unsupported.length === 0) return;\n if (unknownKeySink !== undefined) {\n for (const key of unsupported) {\n unknownKeySink.push({\n filePath: MAJOR_MODES_RELATIVE_PATH,\n path: key,\n message: `${location} has unsupported field`,\n });\n }\n return;\n }\n throw new Error(`${location} has unsupported field(s): ${unsupported.join(', ')}`);\n}\n\nconst RETIRED_LOOP_PACKAGE = '@agimon-ai/po-loop';\n\nfunction assertNotRetired(name: string, location: string): void {\n if (name !== RETIRED_LOOP_PACKAGE && !name.startsWith(`${RETIRED_LOOP_PACKAGE}@`)) return;\n throw new Error(\n `${location} uses the retired ${RETIRED_LOOP_PACKAGE}. Replace it with @agimon-ai/po-calendar. ` +\n 'Loops from the old package are not migrated; recreate them as Calendar events.',\n );\n}\n\nfunction parseLayerPackage(layerName: string, value: unknown, index: number): string | LayerPackage {\n const location = `Layer \"${layerName}\" package[${index}] in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (typeof value === 'string') {\n if (!value.trim()) throw new Error(`${location} must be a non-empty string or mapping`);\n assertNotRetired(value.trim(), location);\n return value.trim();\n }\n if (!isRecord(value)) throw new Error(`${location} must be a non-empty string or mapping`);\n assertKnownKeys(value, LAYER_PACKAGE_KEYS, location);\n if (typeof value.name !== 'string' || !value.name.trim()) {\n throw new Error(`${location}.name must be a non-empty string`);\n }\n if (value.optional !== undefined && typeof value.optional !== 'boolean') {\n throw new Error(`${location}.optional must be a boolean`);\n }\n if (value.config !== undefined && !isRecord(value.config)) {\n throw new Error(`${location}.config must be a mapping`);\n }\n assertNotRetired(value.name.trim(), location);\n return {\n name: value.name.trim(),\n ...(value.optional === true ? { optional: true } : {}),\n ...(value.config ? { config: { ...value.config } } : {}),\n };\n}\n\nfunction parseLayerExtensions(layerName: string, value: unknown): string[] | undefined {\n if (value === undefined) return undefined;\n const location = `Layer \"${layerName}\" extensions in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!Array.isArray(value)) throw new Error(`${location} must be an array`);\n return value.map((entry, index) => {\n if (typeof entry !== 'string' || !entry.trim()) {\n throw new Error(`${location}[${index}] must be a non-empty string`);\n }\n return entry.trim();\n });\n}\n\nfunction parseLayerPackages(layerName: string, value: unknown): Array<string | LayerPackage> | undefined {\n if (value === undefined) return undefined;\n if (!Array.isArray(value)) {\n throw new Error(`Layer \"${layerName}\" packages in ${MAJOR_MODES_RELATIVE_PATH} must be an array`);\n }\n return value.map((entry, index) => parseLayerPackage(layerName, entry, index));\n}\n\nfunction parseDefaultMajorMode(value: unknown): string {\n if (typeof value !== 'string' || !value.trim()) {\n throw new Error(`defaultMajorMode in ${MAJOR_MODES_RELATIVE_PATH} must be a non-empty string`);\n }\n return value.trim();\n}\n\nfunction parseMajorModeLayers(modeName: string, value: unknown): string[] {\n const location = `Major mode \"${modeName}\" layers in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!Array.isArray(value)) throw new Error(`${location} must be an array`);\n return value.map((layerName, index) => {\n if (typeof layerName !== 'string' || !layerName.trim()) {\n throw new Error(`${location}[${index}] must be a non-empty string`);\n }\n return layerName.trim();\n });\n}\n\nfunction legacyMajorModeDescription(layers: readonly string[]): string {\n return layers.length > 0 ? `Uses layers: ${layers.join(', ')}.` : 'Uses Po Pi core extensions only.';\n}\n\nfunction parseMajorMode(name: string, value: unknown): MajorModeDefinition {\n if (Array.isArray(value)) {\n const layers = parseMajorModeLayers(name, value);\n return { description: legacyMajorModeDescription(layers), layers };\n }\n\n const location = `Major mode \"${name}\" in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!isRecord(value)) throw new Error(`${location} must be a mapping with description and layers`);\n assertKnownKeys(value, MAJOR_MODE_KEYS, location);\n if (typeof value.description !== 'string' || !value.description.trim()) {\n throw new Error(`${location}.description must be a non-empty string`);\n }\n return {\n description: value.description.trim(),\n layers: parseMajorModeLayers(name, value.layers),\n };\n}\n\nfunction parseMajorModes(value: unknown): Record<string, MajorModeDefinition | null> {\n if (value === undefined) return {};\n if (!isRecord(value)) throw new Error(`majorMode in ${MAJOR_MODES_RELATIVE_PATH} must be a mapping`);\n return Object.fromEntries(\n Object.entries(value).map(([name, definition]) => [\n name,\n definition === null ? null : parseMajorMode(name, definition),\n ]),\n );\n}\n\nexport function parseLayer(name: string, definition: unknown): LayerDefinition {\n if (!isRecord(definition)) throw new Error(`Layer \"${name}\" in ${MAJOR_MODES_RELATIVE_PATH} must be a mapping`);\n if ('targets' in definition) {\n throw new Error(\n `Layer \"${name}\" in ${MAJOR_MODES_RELATIVE_PATH} uses removed field \"targets\"; select availability through major modes`,\n );\n }\n if ('config' in definition) {\n throw new Error(\n `Layer \"${name}\" in ${MAJOR_MODES_RELATIVE_PATH} uses unsupported field \"config\"; move it under the package entry that owns it`,\n );\n }\n const extensions = parseLayerExtensions(name, definition.extensions);\n const packages = parseLayerPackages(name, definition.packages);\n return {\n ...definition,\n ...(extensions === undefined ? {} : { extensions }),\n ...(packages === undefined ? {} : { packages }),\n } as LayerDefinition;\n}\n\nfunction parseLayers(value: unknown): Record<string, LayerDefinition | null> {\n if (value === undefined) return {};\n if (!isRecord(value)) throw new Error(`layers in ${MAJOR_MODES_RELATIVE_PATH} must be a mapping`);\n return Object.fromEntries(\n Object.entries(value).map(([name, definition]) => [\n name,\n definition === null ? null : parseLayer(name, definition),\n ]),\n );\n}\n\nfunction parseDefault(value: unknown): LayerDefinition {\n const location = `default in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!isRecord(value)) throw new Error(`${location} must be a mapping with packages`);\n assertKnownKeys(value, DEFAULT_KEYS, location);\n if (!Object.hasOwn(value, 'packages')) {\n throw new Error(`Layer \"default\" packages in ${MAJOR_MODES_RELATIVE_PATH} must be an array`);\n }\n const packages = parseLayerPackages('default', value.packages);\n return { packages };\n}\n\n/**\n * Folds the global and repository modes documents, lowest precedence first.\n *\n * The repository is read last, so it replaces a global layer or major mode of\n * the same name. Layers keep the root they were declared under so that a\n * global layer naming `./extensions/x` still points beside the global config\n * once it is loaded from inside some other repository.\n */\nexport function composeMajorModesConfig(\n sources: ReadonlyArray<PoConfigSource<ModesDocument>>,\n repoRoot: string,\n environment: NodeJS.ProcessEnv,\n resolvePackageName: PackageNameResolver,\n): MajorModesConfig {\n let defaultDefinition: ResolvedLayerDefinition | undefined;\n const layers: Record<string, ResolvedLayerDefinition> = {};\n const majorMode: Record<string, MajorModeDefinition> = {};\n const majorModeSources: Record<string, PoConfigProvenance> = {};\n let defaultMajorMode = FALLBACK_MAJOR_MODE;\n let defaultMajorModeSource: PoConfigProvenance | undefined;\n let hasConfiguredDefault = false;\n for (const source of sources) {\n if (Object.hasOwn(source.document, 'default')) {\n defaultDefinition = {\n ...parseDefault(source.document.default),\n baseDirectory: source.baseDirectory,\n filePath: source.filePath,\n };\n }\n for (const [name, definition] of Object.entries(parseLayers(source.document.layers))) {\n if (definition === null) {\n delete layers[name];\n continue;\n }\n layers[name] = {\n ...definition,\n baseDirectory: source.baseDirectory,\n filePath: source.filePath,\n };\n }\n if (Object.hasOwn(source.document, 'defaultMajorMode')) {\n defaultMajorMode = parseDefaultMajorMode(source.document.defaultMajorMode);\n defaultMajorModeSource = { filePath: source.filePath, baseDirectory: source.baseDirectory };\n hasConfiguredDefault = true;\n }\n for (const [name, definition] of Object.entries(parseMajorModes(source.document.majorMode))) {\n if (definition === null) {\n delete majorMode[name];\n delete majorModeSources[name];\n continue;\n }\n majorMode[name] = definition;\n majorModeSources[name] = { filePath: source.filePath, baseDirectory: source.baseDirectory };\n }\n }\n\n for (const [modeName, definition] of Object.entries(majorMode)) {\n for (const name of definition.layers) {\n if (!layers[name]) {\n throw new Error(`Unknown layer \"${name}\" in majorMode.${modeName} of ${MAJOR_MODES_RELATIVE_PATH}`);\n }\n }\n }\n if (hasConfiguredDefault && !Object.hasOwn(majorMode, defaultMajorMode)) {\n throw new Error(`Unknown default major mode \"${defaultMajorMode}\" in ${MAJOR_MODES_RELATIVE_PATH}`);\n }\n if (environment.PO_DISTRIBUTION === 'desktop') {\n const computerUsePackage = '@agimon-ai/po-computer-use';\n const packages = defaultDefinition?.packages ?? [];\n const hasComputerUse = packages.some((entry) => {\n const specifier = typeof entry === 'string' ? entry : entry.name;\n return resolvePackageName(specifier, defaultDefinition?.baseDirectory ?? repoRoot) === computerUsePackage;\n });\n if (!hasComputerUse) {\n defaultDefinition = {\n ...(defaultDefinition ?? { baseDirectory: repoRoot }),\n packages: [...packages, computerUsePackage],\n };\n }\n }\n return {\n ...(defaultDefinition ? { default: defaultDefinition } : {}),\n layers,\n defaultMajorMode,\n ...(defaultMajorModeSource ? { defaultMajorModeSource } : {}),\n majorMode,\n majorModeSources,\n };\n}\n\n/**\n * Finds configuration owned by one package while preserving layer and package order.\n * Pass a resolver to match local package paths by name without changing their specifiers.\n */\nexport function resolvePackageConfigurations(\n config: MajorModesConfig,\n names: string[],\n packageName: string,\n resolvePackageName?: PackageNameResolver,\n): ResolvedPackageConfiguration[] {\n const normalizedPackageName = packageName.trim();\n if (!normalizedPackageName) throw new Error('Package name must be a non-empty string');\n const configurations: ResolvedPackageConfiguration[] = [];\n const definitions: Array<{ name: string; definition: ResolvedLayerDefinition }> = [];\n if (config.default) definitions.push({ name: 'default', definition: config.default });\n for (const name of names) {\n const definition = config.layers[name];\n if (!definition) throw new Error(`Unknown layer: ${name}`);\n definitions.push({ name, definition });\n }\n for (const { name, definition } of definitions) {\n for (const entry of definition.packages ?? []) {\n if (typeof entry === 'string' || entry.config === undefined) continue;\n const resolvedName = resolvePackageName?.(entry.name, definition.baseDirectory) ?? entry.name;\n if (resolvedName !== normalizedPackageName && !resolvedName.startsWith(`${normalizedPackageName}/`)) continue;\n configurations.push({\n layer: name,\n specifier: entry.name,\n config: { ...entry.config },\n baseDirectory: definition.baseDirectory,\n ...(definition.filePath ? { filePath: definition.filePath } : {}),\n });\n }\n }\n return configurations;\n}\n\n/** Resolves one named major mode into its configured layer components. */\nexport function resolveLayers(config: MajorModesConfig, majorMode: string): string[] {\n if (!Object.hasOwn(config.majorMode, majorMode)) {\n throw new Error(\n `Unknown major mode: ${majorMode}. Known major modes: ${Object.keys(config.majorMode).sort().join(', ')}`,\n );\n }\n return [...config.majorMode[majorMode]!.layers];\n}\n\nfunction resolveLocalEntries(\n resolvers: LayerResolvers,\n specifier: string,\n baseDirectory: string,\n): string[] | undefined {\n const resolved = resolvers.localEntries?.(specifier, baseDirectory);\n if (resolved !== undefined) return resolved;\n const single = resolvers.localEntry(specifier, baseDirectory);\n return single ? [single] : undefined;\n}\n\n/** Resolves one layer's extension and package entries to absolute paths. */\nexport function layerEntries(config: MajorModesConfig, name: string, resolvers: LayerResolvers): string[] {\n const layer = config.layers[name];\n if (!layer) throw new Error(`Unknown layer: ${name}`);\n const entries: string[] = [];\n for (const entry of layer.extensions ?? []) {\n if (!isLocalPackageSpecifier(entry)) {\n entries.push(resolvers.ownEntry(entry));\n continue;\n }\n const resolved = resolveLocalEntries(resolvers, entry, layer.baseDirectory);\n if (!resolved?.length) {\n throw new Error(\n `Layer \"${name}\" extension \"${entry}\" does not resolve under ${layer.baseDirectory}. ` +\n 'Point it at a Pi extension file or directory.',\n );\n }\n entries.push(...resolved);\n }\n for (const entry of layer.packages ?? []) {\n const specifier = typeof entry === 'string' ? entry : entry.name;\n const optional = typeof entry === 'string' ? false : entry.optional === true;\n if (isLocalPackageSpecifier(specifier)) {\n const resolved = resolveLocalEntries(resolvers, specifier, layer.baseDirectory);\n if (resolved?.length) entries.push(...resolved);\n else if (!optional) {\n throw new Error(\n `Layer \"${name}\" package \"${specifier}\" does not resolve under ${layer.baseDirectory}. ` +\n 'Point it at an extension file, or a directory whose package.json declares pi.extensions.',\n );\n }\n continue;\n }\n if (optional) {\n let resolved = resolvers.optionalPackageEntries?.(specifier);\n if (resolved === undefined) {\n const single = resolvers.optionalPackageEntry(specifier);\n resolved = single ? [single] : undefined;\n }\n if (resolved) entries.push(...resolved);\n continue;\n }\n const resolved = resolvers.packageEntries?.(specifier) ?? [resolvers.packageEntry(specifier)];\n if (resolved.length === 0) {\n throw new Error(`Layer \"${name}\" package \"${specifier}\" declares no Pi extensions.`);\n }\n entries.push(...resolved);\n }\n return entries;\n}\n\n/** As `composeMajorModesConfig`, collecting unknown keys as diagnostics instead of throwing. */\nexport function composeMajorModesConfigLenient(\n sources: ReadonlyArray<PoConfigSource<ModesDocument>>,\n repoRoot: string,\n environment: NodeJS.ProcessEnv,\n resolvePackageName: PackageNameResolver,\n): { config: MajorModesConfig; diagnostics: ConfigDiagnostic[] } {\n const diagnostics: ConfigDiagnostic[] = [];\n const previous = unknownKeySink;\n unknownKeySink = diagnostics;\n try {\n return { config: composeMajorModesConfig(sources, repoRoot, environment, resolvePackageName), diagnostics };\n } finally {\n unknownKeySink = previous;\n }\n}\n","import os from 'node:os';\n\nimport { localPackageName, splitPackageSpecifier } from '@agimon-ai/po-core/moduleResolution';\n\nimport type { ConfigDiagnostic } from '../../types/config';\nimport { readPoConfigSources } from '../layeredConfig';\nimport {\n MODES_FILE,\n composeMajorModesConfig,\n composeMajorModesConfigLenient,\n isLocalPackageSpecifier,\n type MajorModesConfig,\n type ModesDocument,\n} from './core';\n\n/** Node's answer: a local path names the package its package.json declares. */\nfunction nodePackageName(specifier: string, baseDirectory: string): string | undefined {\n return isLocalPackageSpecifier(specifier)\n ? localPackageName(specifier, baseDirectory)\n : splitPackageSpecifier(specifier).name;\n}\n\n/**\n * Reads layers and major modes from the global and repository configs.\n *\n * The repository is read last, so it replaces a global layer or major mode of\n * the same name. Layers keep the root they were declared under so that a\n * global layer naming `./extensions/x` still points beside the global config\n * once it is loaded from inside some other repository.\n *\n * @deprecated Node-only sync shim; use readMajorModesConfig. Removed in M2.\n */\nexport function loadMajorModesConfig(\n repoRoot: string,\n homeDirectory: string = os.homedir(),\n environment: NodeJS.ProcessEnv = process.env,\n): MajorModesConfig {\n const sources = readPoConfigSources<ModesDocument>(MODES_FILE, repoRoot, homeDirectory);\n return composeMajorModesConfig(sources, repoRoot, environment, nodePackageName);\n}\n\n/**\n * Reads layers and major modes, tolerating unknown keys.\n *\n * `po sync` uses this so a modes.yaml written against a different set of\n * layer packages cannot break a build. Every other caller keeps the strict\n * `loadMajorModesConfig`, and `po doctor` still reports what was tolerated.\n *\n * @deprecated Node-only sync shim; use readMajorModesConfigLenient. Removed in M2.\n */\nexport function loadMajorModesConfigLenient(\n repoRoot: string,\n homeDirectory: string = os.homedir(),\n environment: NodeJS.ProcessEnv = process.env,\n): { config: MajorModesConfig; diagnostics: ConfigDiagnostic[] } {\n const sources = readPoConfigSources<ModesDocument>(MODES_FILE, repoRoot, homeDirectory);\n return composeMajorModesConfigLenient(sources, repoRoot, environment, nodePackageName);\n}\n","import path from 'node:path';\n\nimport { getOrThrow, nodeHost, readTextIfExists, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport type { ConfigDiagnostic } from '../../types/config';\nimport { readPoConfigSourcesAsync, type PoConfigSource } from '../layeredConfig';\nimport {\n MODES_FILE,\n composeMajorModesConfig,\n composeMajorModesConfigLenient,\n isLocalPackageSpecifier,\n resolvePackageConfigurations,\n type MajorModesConfig,\n type ModesDocument,\n type PackageNameResolver,\n type ResolvedPackageConfiguration,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nconst PACKAGE_MANIFEST = 'package.json';\nconst SCOPE_PREFIX = '@';\n\nexport interface ReadMajorModesConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Defaults to `process.env`. */\n readonly environment?: NodeJS.ProcessEnv;\n /**\n * Names the package a layer specifier stands for. Pass one built from a\n * precomputed composition on the edge; by default local paths are answered\n * from their package.json over `fs`.\n */\n readonly resolvePackageName?: PackageNameResolver;\n}\n\n/** `@scope/name/sub` to `@scope/name`, `name/sub` to `name`. */\nfunction bareSpecifierName(specifier: string): string {\n const segments = specifier.split('/');\n return segments.slice(0, specifier.startsWith(SCOPE_PREFIX) ? 2 : 1).join('/');\n}\n\nasync function localPackageNameAsync(\n fs: FileSystem,\n specifier: string,\n baseDirectory: string,\n context: IoContext,\n): Promise<string | undefined> {\n const target = path.resolve(baseDirectory, specifier);\n try {\n const real = getOrThrow(await fs.canonicalPath(target, context));\n if (getOrThrow(await fs.fileInfo(real, context)).kind !== 'directory') return undefined;\n const text = await readTextIfExists(fs, path.join(target, PACKAGE_MANIFEST), context);\n if (text === undefined) return undefined;\n const manifest = JSON.parse(text) as { name?: unknown };\n return typeof manifest.name === 'string' && manifest.name.trim() ? manifest.name.trim() : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Only the desktop distribution asks for package names, and only of the\n * `default` packages, so those are the local paths read ahead of the\n * synchronous composition.\n */\nasync function precomputedPackageNames(\n fs: FileSystem,\n sources: ReadonlyArray<PoConfigSource<ModesDocument>>,\n environment: NodeJS.ProcessEnv,\n context: IoContext,\n): Promise<PackageNameResolver> {\n const names = new Map<string, string | undefined>();\n const key = (specifier: string, baseDirectory: string) => `${baseDirectory}\\0${specifier}`;\n if (environment.PO_DISTRIBUTION === 'desktop') {\n for (const source of sources) {\n const packages = (source.document.default as { packages?: unknown } | undefined)?.packages;\n if (!Array.isArray(packages)) continue;\n for (const entry of packages) {\n const raw = typeof entry === 'string' ? entry : (entry as { name?: unknown } | null)?.name;\n if (typeof raw !== 'string' || !isLocalPackageSpecifier(raw.trim())) continue;\n const specifier = raw.trim();\n names.set(\n key(specifier, source.baseDirectory),\n await localPackageNameAsync(fs, specifier, source.baseDirectory, context),\n );\n }\n }\n }\n return (specifier, baseDirectory) =>\n isLocalPackageSpecifier(specifier) ? names.get(key(specifier, baseDirectory)) : bareSpecifierName(specifier);\n}\n\nasync function readModes(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadMajorModesConfigOptions,\n): Promise<{\n sources: Array<PoConfigSource<ModesDocument>>;\n environment: NodeJS.ProcessEnv;\n resolvePackageName: PackageNameResolver;\n}> {\n const homeDirectory = options.homeDirectory ?? nodeHost.homeDirectory();\n const environment = options.environment ?? process.env;\n const sources = await readPoConfigSourcesAsync<ModesDocument>(fs, MODES_FILE, repoRoot, context, homeDirectory);\n const resolvePackageName =\n options.resolvePackageName ?? (await precomputedPackageNames(fs, sources, environment, context));\n return { sources, environment, resolvePackageName };\n}\n\n/** Reads layers and major modes over a FileSystem; the same answer as `loadMajorModesConfig`. */\nexport async function readMajorModesConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadMajorModesConfigOptions = {},\n): Promise<MajorModesConfig> {\n const { sources, environment, resolvePackageName } = await readModes(fs, repoRoot, context, options);\n return composeMajorModesConfig(sources, repoRoot, environment, resolvePackageName);\n}\n\n/** As `readMajorModesConfig`, tolerating unknown keys and reporting them. */\nexport async function readMajorModesConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadMajorModesConfigOptions = {},\n): Promise<{ config: MajorModesConfig; diagnostics: ConfigDiagnostic[] }> {\n const { sources, environment, resolvePackageName } = await readModes(fs, repoRoot, context, options);\n return composeMajorModesConfigLenient(sources, repoRoot, environment, resolvePackageName);\n}\n\n/**\n * Reads local package names over a FileSystem, then finds package-owned config.\n * Keeps the original specifiers, source directories, and default/selected-layer order.\n * Missing or invalid local manifests do not match a package name.\n */\nexport async function readPackageConfigurations(\n fs: FileSystem,\n config: MajorModesConfig,\n names: string[],\n packageName: string,\n context: IoContext,\n): Promise<ResolvedPackageConfiguration[]> {\n const packageNames = new Map<string, string | undefined>();\n const key = (specifier: string, baseDirectory: string) => `${baseDirectory}\\0${specifier}`;\n for (const definition of [config.default, ...names.map((name) => config.layers[name])]) {\n if (!definition) continue;\n for (const entry of definition.packages ?? []) {\n if (typeof entry === 'string' || entry.config === undefined || !isLocalPackageSpecifier(entry.name)) {\n continue;\n }\n const entryKey = key(entry.name, definition.baseDirectory);\n if (!packageNames.has(entryKey)) {\n packageNames.set(entryKey, await localPackageNameAsync(fs, entry.name, definition.baseDirectory, context));\n }\n }\n }\n return resolvePackageConfigurations(config, names, packageName, (specifier, baseDirectory) =>\n packageNames.get(key(specifier, baseDirectory)),\n );\n}\n\nexport { isLocalPackageSpecifier, layerEntries, resolveLayers, resolvePackageConfigurations } from './core';\nexport type {\n LayerDefinition,\n LayerPackage,\n LayerPackageConfig,\n LayerResolvers,\n MajorModeDefinition,\n MajorModesConfig,\n PackageNameResolver,\n ResolvedLayerDefinition,\n ResolvedPackageConfiguration,\n} from './core';\n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AI,UAAU,SAAS,OAAO;CACnG,OAAO,+BAA+B,SAAS,UAAU,aAAa,kBAAkB;AAC1F;;;;;;AAOA,eAAsB,0BACpB,IACA,QACA,OACA,aACA,SACyC;CACzC,MAAM,+BAAe,IAAI,IAAgC;CACzD,MAAM,OAAO,WAAmB,kBAA0B,GAAG,cAAc,IAAI;CAC/E,KAAK,MAAM,cAAc,CAAC,OAAO,SAAS,GAAG,MAAM,KAAK,SAAS,OAAO,OAAO,KAAK,CAAC,GAAG;EACtF,IAAI,CAAC,YAAY;EACjB,KAAK,MAAM,SAAS,WAAW,YAAY,CAAC,GAAG;GAC7C,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,KAAA,KAAa,CAAC,wBAAwB,MAAM,IAAI,GAChG;GAEF,MAAM,WAAW,IAAI,MAAM,MAAM,WAAW,aAAa;GACzD,IAAI,CAAC,aAAa,IAAI,QAAQ,GAC5B,aAAa,IAAI,UAAU,MAAM,sBAAsB,IAAI,MAAM,MAAM,WAAW,eAAe,OAAO,CAAC;EAE7G;CACF;CACA,OAAO,6BAA6B,QAAQ,OAAO,cAAc,WAAW,kBAC1E,aAAa,IAAI,IAAI,WAAW,aAAa,CAAC,CAChD;AACF"}
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_majorModes = require("./majorModes-C6xu8OTJ.cjs");
2
+ const require_majorModes = require("./majorModes-B_1SnkQP.cjs");
3
+ const require_presets = require("./presets-01mLK7j9.cjs");
3
4
  exports.isLocalPackageSpecifier = require_majorModes.isLocalPackageSpecifier;
4
5
  exports.layerEntries = require_majorModes.layerEntries;
5
6
  exports.loadMajorModesConfig = require_majorModes.loadMajorModesConfig;
@@ -9,3 +10,5 @@ exports.readMajorModesConfigLenient = require_majorModes.readMajorModesConfigLen
9
10
  exports.readPackageConfigurations = require_majorModes.readPackageConfigurations;
10
11
  exports.resolveLayers = require_majorModes.resolveLayers;
11
12
  exports.resolvePackageConfigurations = require_majorModes.resolvePackageConfigurations;
13
+ exports.withSettingsWrite = require_presets.withSettingsWrite;
14
+ exports.writePreset = require_presets.writePreset;
@@ -1,2 +1,91 @@
1
1
  import { _ as layerEntries, a as loadMajorModesConfig, c as LayerPackage, d as MajorModeDefinition, f as MajorModesConfig, g as isLocalPackageSpecifier, h as ResolvedPackageConfiguration, i as readPackageConfigurations, l as LayerPackageConfig, m as ResolvedLayerDefinition, n as readMajorModesConfig, o as loadMajorModesConfigLenient, p as PackageNameResolver, r as readMajorModesConfigLenient, s as LayerDefinition, t as ReadMajorModesConfigOptions, u as LayerResolvers, v as resolveLayers, y as resolvePackageConfigurations } from "./index-DeP6F4Rv.mjs";
2
- export { type LayerDefinition, type LayerPackage, type LayerPackageConfig, type LayerResolvers, type MajorModeDefinition, type MajorModesConfig, type PackageNameResolver, type ReadMajorModesConfigOptions, type ResolvedLayerDefinition, type ResolvedPackageConfiguration, isLocalPackageSpecifier, layerEntries, loadMajorModesConfig, loadMajorModesConfigLenient, readMajorModesConfig, readMajorModesConfigLenient, readPackageConfigurations, resolveLayers, resolvePackageConfigurations };
2
+ import { FileSystem } from "@agimon-ai/po-core/platform";
3
+ //#region src/types/settings.d.ts
4
+ /** Wire values returned by the host and workspace configuration mounts. */
5
+ interface RepositorySettingsRepository {
6
+ id: string;
7
+ name: string;
8
+ path: string;
9
+ active: boolean;
10
+ }
11
+ /** One layer a preset turns on, with the Po plugins (packages) it bundles. */
12
+ interface SettingsPresetLayer {
13
+ name: string;
14
+ packages: string[];
15
+ }
16
+ /** One effective preset, with its layers in load order. */
17
+ interface SettingsPreset {
18
+ name: string;
19
+ description: string;
20
+ layers: SettingsPresetLayer[];
21
+ /** True when this workspace definition replaces a host preset of the same name. */
22
+ overridesHost?: boolean;
23
+ /** True when a workspace reads this preset from the host file because it has none of its own. */
24
+ inherited?: boolean;
25
+ }
26
+ /** Settings > Presets: your major modes, the default new sessions start with, and what every preset includes. */
27
+ interface SettingsPresetsView {
28
+ defaultPreset: string;
29
+ presets: SettingsPreset[];
30
+ /** `default.packages`: loaded before any preset's layers. */
31
+ alwaysIncluded: string[];
32
+ /** sha256 of the mount's modes file, empty when absent. */
33
+ hash: string;
34
+ /** The host token, used when adding to an inherited host default. */
35
+ hostHash?: string;
36
+ /** The token an add to the default preset (`name: ''`) checks: the host file's when that default is inherited. */
37
+ defaultHash: string;
38
+ file?: string;
39
+ writtenFile?: string;
40
+ }
41
+ /** Preset writes use the admitted workspace mount, never a caller-supplied path. */
42
+ type PresetScope = 'host' | `workspace:${string}`;
43
+ interface PresetWriteRequest {
44
+ scope: PresetScope;
45
+ expectedHash: string;
46
+ name: string;
47
+ }
48
+ interface PresetCreateRequest extends PresetWriteRequest {
49
+ description: string;
50
+ layers?: string[];
51
+ }
52
+ interface PresetRenameRequest extends PresetWriteRequest {
53
+ newName: string;
54
+ }
55
+ /** A caller-supplied curated definition. Existing layers are never modified. */
56
+ interface PresetLayerDefinition {
57
+ packages?: Array<string | {
58
+ name: string;
59
+ optional?: boolean;
60
+ config?: Record<string, unknown>;
61
+ }>;
62
+ extensions?: string[];
63
+ hookGroups?: string[];
64
+ }
65
+ interface PresetLayerRequest extends PresetWriteRequest {
66
+ /** Set name to an empty string to add to the scope's default preset. */
67
+ layer: string;
68
+ definition?: PresetLayerDefinition;
69
+ }
70
+ type PresetOperation = 'create' | 'rename' | 'delete' | 'default' | 'add-layer' | 'remove-layer';
71
+ interface PresetReference {
72
+ file: string;
73
+ key: string;
74
+ }
75
+ /** One repository the picker offers. */
76
+ type SettingsRepository = RepositorySettingsRepository;
77
+ //#endregion
78
+ //#region src/services/presets/index.d.ts
79
+ /** Serialize settings writes and the marketplace's final clash check plus membership commit. */
80
+ export declare function withSettingsWrite<T>(action: () => Promise<T>): Promise<T>;
81
+ /** One comment-preserving atomic edit, validated by the same composer as runtime loads. */
82
+ export declare function writePreset(fs: FileSystem, home: string, environment: NodeJS.ProcessEnv, operation: PresetOperation, input: PresetWriteRequest | PresetCreateRequest | PresetRenameRequest | PresetLayerRequest, root?: string, repositories?: readonly SettingsRepository[]): Promise<SettingsPresetsView | {
83
+ error: string;
84
+ conflict?: {
85
+ hash: string;
86
+ };
87
+ references?: PresetReference[];
88
+ }>;
89
+ //#endregion
90
+ export { type LayerDefinition, type LayerPackage, type LayerPackageConfig, type LayerResolvers, type MajorModeDefinition, type MajorModesConfig, type PackageNameResolver, type ReadMajorModesConfigOptions, type ResolvedLayerDefinition, type ResolvedPackageConfiguration, isLocalPackageSpecifier, layerEntries, loadMajorModesConfig, loadMajorModesConfigLenient, readMajorModesConfig, readMajorModesConfigLenient, readPackageConfigurations, resolveLayers, resolvePackageConfigurations };
91
+ //# sourceMappingURL=majorModes.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"majorModes.d.mts","names":[],"sources":["../src/types/settings.ts","../src/services/presets/index.ts"],"mappings":";;;;UACU;EACR;EACA;EACA;EACA;;;UAiCe;EACf;EACA;;;UAIe;EACf;EACA;EACA,QAAQ;;EAER;;EAEA;;;UAIe;EACf;EACA,SAAS;;EAET;;EAEA;;EAEA;;EAEA;EACA;EACA;;;KASU;UAEK;EACf,OAAO;EACP;EACA;;UAGe,4BAA4B;EAC3C;EACA;;UAGe,4BAA4B;EAC3C;;;UAIe;EACf,WAAW;IAAiB;IAAc;IAAoB,SAAS;;EACvE;EACA;;UAGe,2BAA2B;;EAE1C;EACA,aAAa;;KAGH;UAEK;EACf;EACA;;;KAyBU,qBAAqB;;;;wBChGjB,kBAAkB,GAAG,cAAc,QAAQ,KAAK,QAAQ;;wBAkIlD,YACpB,IAAI,YACJ,cACA,aAAa,OAAO,YACpB,WAAW,iBACX,OAAO,qBAAqB,sBAAsB,sBAAsB,oBACxE,eACA,wBAAuB,uBACtB,QAAQ;EAAwB;EAAe;IAAa;;EAAgB,aAAa"}
@@ -1 +1,3 @@
1
- export { s as isLocalPackageSpecifier, c as layerEntries, i as loadMajorModesConfig, a as loadMajorModesConfigLenient, t as readMajorModesConfig, n as readMajorModesConfigLenient, r as readPackageConfigurations, l as resolveLayers, u as resolvePackageConfigurations } from "./majorModes-BQVTbC7k.mjs";
1
+ import { a as loadMajorModesConfigLenient, c as isLocalPackageSpecifier, d as resolveLayers, f as resolvePackageConfigurations, i as loadMajorModesConfig, l as layerEntries, n as readMajorModesConfigLenient, r as readPackageConfigurations, t as readMajorModesConfig } from "./majorModes-eYzNJPBU.mjs";
2
+ import { n as withSettingsWrite, r as writePreset } from "./presets-CpNPbgC7.mjs";
3
+ export { isLocalPackageSpecifier, layerEntries, loadMajorModesConfig, loadMajorModesConfigLenient, readMajorModesConfig, readMajorModesConfigLenient, readPackageConfigurations, resolveLayers, resolvePackageConfigurations, withSettingsWrite, writePreset };