@agimon-ai/doompi-config 0.0.1-alpha.0

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.
Files changed (151) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/decorate.cjs +1 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/decorate.mjs +1 -0
  5. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  6. package/dist/atomicJson.cjs +2 -0
  7. package/dist/atomicJson.cjs.map +1 -0
  8. package/dist/atomicJson.d.cts +6 -0
  9. package/dist/atomicJson.d.cts.map +1 -0
  10. package/dist/atomicJson.d.mts +6 -0
  11. package/dist/atomicJson.d.mts.map +1 -0
  12. package/dist/atomicJson.mjs +2 -0
  13. package/dist/atomicJson.mjs.map +1 -0
  14. package/dist/config/piConfig.cjs +2 -0
  15. package/dist/config/piConfig.cjs.map +1 -0
  16. package/dist/config/piConfig.d.cts +7 -0
  17. package/dist/config/piConfig.d.cts.map +1 -0
  18. package/dist/config/piConfig.d.mts +7 -0
  19. package/dist/config/piConfig.d.mts.map +1 -0
  20. package/dist/config/piConfig.mjs +2 -0
  21. package/dist/config/piConfig.mjs.map +1 -0
  22. package/dist/config/schema.cjs +0 -0
  23. package/dist/config/schema.d.cts +33 -0
  24. package/dist/config/schema.d.cts.map +1 -0
  25. package/dist/config/schema.d.mts +33 -0
  26. package/dist/config/schema.d.mts.map +1 -0
  27. package/dist/config/schema.mjs +1 -0
  28. package/dist/config.cjs +2 -0
  29. package/dist/config.cjs.map +1 -0
  30. package/dist/config.d.cts +24 -0
  31. package/dist/config.d.cts.map +1 -0
  32. package/dist/config.d.mts +24 -0
  33. package/dist/config.d.mts.map +1 -0
  34. package/dist/config.mjs +2 -0
  35. package/dist/config.mjs.map +1 -0
  36. package/dist/configWriter.cjs +2 -0
  37. package/dist/configWriter.cjs.map +1 -0
  38. package/dist/configWriter.d.cts +52 -0
  39. package/dist/configWriter.d.cts.map +1 -0
  40. package/dist/configWriter.d.mts +52 -0
  41. package/dist/configWriter.d.mts.map +1 -0
  42. package/dist/configWriter.mjs +2 -0
  43. package/dist/configWriter.mjs.map +1 -0
  44. package/dist/container.cjs +2 -0
  45. package/dist/container.cjs.map +1 -0
  46. package/dist/container.d.cts +12 -0
  47. package/dist/container.d.cts.map +1 -0
  48. package/dist/container.d.mts +12 -0
  49. package/dist/container.d.mts.map +1 -0
  50. package/dist/container.mjs +2 -0
  51. package/dist/container.mjs.map +1 -0
  52. package/dist/domains.cjs +2 -0
  53. package/dist/domains.cjs.map +1 -0
  54. package/dist/domains.d.cts +75 -0
  55. package/dist/domains.d.cts.map +1 -0
  56. package/dist/domains.d.mts +75 -0
  57. package/dist/domains.d.mts.map +1 -0
  58. package/dist/domains.mjs +2 -0
  59. package/dist/domains.mjs.map +1 -0
  60. package/dist/extensions/doom.cjs +2 -0
  61. package/dist/extensions/doom.cjs.map +1 -0
  62. package/dist/extensions/doom.d.cts +8 -0
  63. package/dist/extensions/doom.d.cts.map +1 -0
  64. package/dist/extensions/doom.d.mts +8 -0
  65. package/dist/extensions/doom.d.mts.map +1 -0
  66. package/dist/extensions/doom.mjs +2 -0
  67. package/dist/extensions/doom.mjs.map +1 -0
  68. package/dist/extensions/pi.cjs +2 -0
  69. package/dist/extensions/pi.cjs.map +1 -0
  70. package/dist/extensions/pi.d.cts +8 -0
  71. package/dist/extensions/pi.d.cts.map +1 -0
  72. package/dist/extensions/pi.d.mts +8 -0
  73. package/dist/extensions/pi.d.mts.map +1 -0
  74. package/dist/extensions/pi.mjs +2 -0
  75. package/dist/extensions/pi.mjs.map +1 -0
  76. package/dist/harnessState.cjs +2 -0
  77. package/dist/harnessState.cjs.map +1 -0
  78. package/dist/harnessState.d.cts +50 -0
  79. package/dist/harnessState.d.cts.map +1 -0
  80. package/dist/harnessState.d.mts +50 -0
  81. package/dist/harnessState.d.mts.map +1 -0
  82. package/dist/harnessState.mjs +2 -0
  83. package/dist/harnessState.mjs.map +1 -0
  84. package/dist/harnessStore.cjs +2 -0
  85. package/dist/harnessStore.cjs.map +1 -0
  86. package/dist/harnessStore.d.cts +102 -0
  87. package/dist/harnessStore.d.cts.map +1 -0
  88. package/dist/harnessStore.d.mts +102 -0
  89. package/dist/harnessStore.d.mts.map +1 -0
  90. package/dist/harnessStore.mjs +2 -0
  91. package/dist/harnessStore.mjs.map +1 -0
  92. package/dist/index.cjs +1 -0
  93. package/dist/index.d.cts +16 -0
  94. package/dist/index.d.mts +16 -0
  95. package/dist/index.mjs +1 -0
  96. package/dist/init.cjs +73 -0
  97. package/dist/init.cjs.map +1 -0
  98. package/dist/init.d.cts +33 -0
  99. package/dist/init.d.cts.map +1 -0
  100. package/dist/init.d.mts +33 -0
  101. package/dist/init.d.mts.map +1 -0
  102. package/dist/init.mjs +73 -0
  103. package/dist/init.mjs.map +1 -0
  104. package/dist/layeredConfig.cjs +2 -0
  105. package/dist/layeredConfig.cjs.map +1 -0
  106. package/dist/layeredConfig.d.cts +49 -0
  107. package/dist/layeredConfig.d.cts.map +1 -0
  108. package/dist/layeredConfig.d.mts +49 -0
  109. package/dist/layeredConfig.d.mts.map +1 -0
  110. package/dist/layeredConfig.mjs +2 -0
  111. package/dist/layeredConfig.mjs.map +1 -0
  112. package/dist/majorModes.cjs +2 -0
  113. package/dist/majorModes.cjs.map +1 -0
  114. package/dist/majorModes.d.cts +73 -0
  115. package/dist/majorModes.d.cts.map +1 -0
  116. package/dist/majorModes.d.mts +73 -0
  117. package/dist/majorModes.d.mts.map +1 -0
  118. package/dist/majorModes.mjs +2 -0
  119. package/dist/majorModes.mjs.map +1 -0
  120. package/dist/pi.cjs +1 -0
  121. package/dist/pi.d.cts +2 -0
  122. package/dist/pi.d.mts +2 -0
  123. package/dist/pi.mjs +1 -0
  124. package/dist/piContext.cjs +2 -0
  125. package/dist/piContext.cjs.map +1 -0
  126. package/dist/piContext.d.cts +19 -0
  127. package/dist/piContext.d.cts.map +1 -0
  128. package/dist/piContext.d.mts +19 -0
  129. package/dist/piContext.d.mts.map +1 -0
  130. package/dist/piContext.mjs +2 -0
  131. package/dist/piContext.mjs.map +1 -0
  132. package/dist/profiles.cjs +4 -0
  133. package/dist/profiles.cjs.map +1 -0
  134. package/dist/profiles.d.cts +35 -0
  135. package/dist/profiles.d.cts.map +1 -0
  136. package/dist/profiles.d.mts +35 -0
  137. package/dist/profiles.d.mts.map +1 -0
  138. package/dist/profiles.mjs +4 -0
  139. package/dist/profiles.mjs.map +1 -0
  140. package/dist/types.cjs +2 -0
  141. package/dist/types.cjs.map +1 -0
  142. package/dist/types.d.cts +132 -0
  143. package/dist/types.d.cts.map +1 -0
  144. package/dist/types.d.mts +132 -0
  145. package/dist/types.d.mts.map +1 -0
  146. package/dist/types.mjs +2 -0
  147. package/dist/types.mjs.map +1 -0
  148. package/package.json +150 -0
  149. package/skills/doom-pi-config/SKILL.md +26 -0
  150. package/skills/doom-pi-config/agents/openai.yaml +4 -0
  151. package/skills/doom-pi-config/references/config-contract.md +43 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.cjs","names":["fs","path","randomUUID","os","globalDoomConfigDirectory"],"sources":["../src/init.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from './config.ts';\n\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst PRIVATE_FILE_MODE = 0o600;\nconst UTF8_ENCODING = 'utf8';\nconst FILE_ALREADY_EXISTS = 'EEXIST';\nconst FILE_NOT_FOUND = 'ENOENT';\n\n/** The global seed files are processed in this fixed order. */\nexport const GLOBAL_DOOM_SEED_FILES = [\n 'config.yaml',\n 'modes.yaml',\n 'domains.yaml',\n 'profiles.yaml',\n 'hooks.yaml',\n] as const;\n\ntype GlobalDoomSeedFile = (typeof GLOBAL_DOOM_SEED_FILES)[number];\n\n/** Portable defaults for a new global Doom configuration directory. */\nexport const DOOM_CONFIG_TEMPLATES: Readonly<Record<GlobalDoomSeedFile, string>> = {\n 'config.yaml': `projectTrust: ask\n\n# Autonomous voice is opt-in and uses an explicitly configured Pi model.\n# voice:\n# autoCapture:\n# model: provider/model-id\n# startPhrases:\n# - hey doom\n# stopPhrases:\n# - stop speaking\n# tts:\n# engine: macos-say\n# voice: Samantha\n# rate: 190\n`,\n 'modes.yaml': `# Seeded defaults. Every layer here resolves from what Doom Pi installs or\n# from a public package, so a fresh install works with no extra setup.\n#\n# Layers and modes defined here apply to every repository. A repository's own\n# .doom/modes.yaml is read after this file and replaces any layer or mode of the\n# same name, so a repository can override one entry without restating the rest.\n#\n# A layer package is an npm specifier, or a path if it was never published:\n# packages: ['./extensions/my-ext']\n# A path is relative to the config that declares it, so it resolves beside this\n# file here (~/.pi/.doom) and against the repository root in a repository copy.\nlayers:\n guardrails:\n # repositoryHooks ships with Doom Pi, so the layer steers the agent toward\n # the governing skill and scaffolding before it writes.\n extensions: [repositoryHooks]\n hookGroups: [guardrails, scaffolding]\n vibe-lint:\n packages:\n - '@agimon-ai/vibe-lint/extensions/pi'\n team:\n packages:\n - '@agimon-ai/doompi-team/extensions/doom'\n plan-mode:\n packages:\n - '@agimon-ai/doompi-plan/extensions/doom'\n runner:\n packages:\n - '@agimon-ai/doompi-runner/extensions/pi'\n style-system:\n extensions: [styleSystem]\n goal:\n packages:\n - '@narumitw/pi-goal/src/index.ts'\n ask-user:\n packages:\n - '@juicesharp/rpiv-ask-user-question'\n# copilot is the default when --major-mode is not passed. Add your own modes\n# here; a mode is just a named set of the layers above.\nmajorMode:\n minimal: [guardrails, team]\n copilot: [guardrails, vibe-lint, team, plan-mode, runner, style-system, goal, ask-user]\n`,\n 'domains.yaml': `# A domain is a named set of plugin directories loaded for a session.\n# Add your own alongside default; aliases map short names onto them.\n#\n# Each plugin path is written in full and is relative to the config that\n# declares it, so it resolves beside this file here (~/.pi/.doom) and against\n# the repository root in a repository copy:\n# plugins: ['plugins/my-plugin']\n# A repository's own .doom/domains.yaml is read after this file and replaces any\n# domain of the same name.\ndomains:\n default:\n plugins: []\naliases: {}\n`,\n 'profiles.yaml': 'profiles: {}\\n',\n 'hooks.yaml': 'groups: {}\\n',\n};\n\n/** Result of filling the global seed directory. File arrays contain names in seed order. */\nexport interface GlobalDoomInitResult {\n directory: string;\n created: string[];\n preserved: string[];\n /** Existing files overwritten from the template. Only ever non-empty under `force`. */\n replaced: string[];\n}\n\nexport interface GlobalDoomInitOptions {\n /**\n * Overwrite existing seed files instead of preserving them.\n *\n * Off by default: init is safe to re-run, and hand-edited config is the\n * normal case rather than the exception.\n */\n force?: boolean;\n}\n\nfunction errorCode(error: unknown): string | undefined {\n if (!(error instanceof Error)) return undefined;\n const code = (error as NodeJS.ErrnoException).code;\n return typeof code === 'string' ? code : undefined;\n}\n\nfunction ensureDirectory(directory: string): void {\n let stats: fs.Stats;\n try {\n stats = fs.lstatSync(directory);\n } catch (error) {\n if (errorCode(error) !== FILE_NOT_FOUND) throw error;\n try {\n fs.mkdirSync(directory, { mode: PRIVATE_DIRECTORY_MODE });\n stats = fs.lstatSync(directory);\n } catch (mkdirError) {\n if (errorCode(mkdirError) !== FILE_ALREADY_EXISTS) throw mkdirError;\n stats = fs.lstatSync(directory);\n }\n }\n\n if (stats.isSymbolicLink()) {\n throw new Error(`Refusing to initialize through symlinked directory: ${directory}`);\n }\n if (!stats.isDirectory()) {\n throw new Error(`Doom config path is not a directory: ${directory}`);\n }\n}\n\nfunction ensureGlobalDoomDirectory(directory: string): void {\n ensureDirectory(path.dirname(directory));\n ensureDirectory(directory);\n}\n\nfunction classifyTarget(targetPath: string): 'missing' | 'file' {\n let stats: fs.Stats;\n try {\n stats = fs.lstatSync(targetPath);\n } catch (error) {\n if (errorCode(error) === FILE_NOT_FOUND) return 'missing';\n throw error;\n }\n\n if (stats.isFile()) return 'file';\n if (stats.isSymbolicLink()) {\n try {\n if (fs.statSync(targetPath).isFile()) return 'file';\n } catch (error) {\n throw new Error(`Doom config seed symlink is not file-like: ${targetPath}`, { cause: error });\n }\n }\n throw new Error(`Doom config seed path is not file-like: ${targetPath}`);\n}\n\nfunction cleanupTemporaryFile(temporaryPath: string): void {\n try {\n fs.unlinkSync(temporaryPath);\n } catch (error) {\n if (errorCode(error) !== FILE_NOT_FOUND) throw error;\n }\n}\n\nfunction publishExclusively(targetPath: string, content: string): boolean {\n const temporaryPath = `${targetPath}.${process.pid}.${randomUUID()}.tmp`;\n let fileDescriptor: number | undefined;\n try {\n fileDescriptor = fs.openSync(temporaryPath, 'wx', PRIVATE_FILE_MODE);\n fs.writeFileSync(fileDescriptor, content, UTF8_ENCODING);\n fs.fchmodSync(fileDescriptor, PRIVATE_FILE_MODE);\n fs.fsyncSync(fileDescriptor);\n const descriptorToClose = fileDescriptor;\n fileDescriptor = undefined;\n fs.closeSync(descriptorToClose);\n\n try {\n fs.linkSync(temporaryPath, targetPath);\n return true;\n } catch (error) {\n if (errorCode(error) === FILE_ALREADY_EXISTS && classifyTarget(targetPath) === 'file') return false;\n throw error;\n }\n } finally {\n if (fileDescriptor !== undefined) {\n const descriptorToClose = fileDescriptor;\n fileDescriptor = undefined;\n fs.closeSync(descriptorToClose);\n }\n cleanupTemporaryFile(temporaryPath);\n }\n}\n\n/**\n * Replaces a seed file with the template, atomically.\n *\n * The rename swaps the directory entry in one step, so a reader either sees the\n * whole old file or the whole new one. Renaming onto a symlinked seed replaces\n * the link rather than writing through it.\n */\nfunction publishForcefully(targetPath: string, content: string): void {\n const temporaryPath = `${targetPath}.${process.pid}.${randomUUID()}.tmp`;\n let fileDescriptor: number | undefined;\n try {\n fileDescriptor = fs.openSync(temporaryPath, 'wx', PRIVATE_FILE_MODE);\n fs.writeFileSync(fileDescriptor, content, UTF8_ENCODING);\n fs.fchmodSync(fileDescriptor, PRIVATE_FILE_MODE);\n fs.fsyncSync(fileDescriptor);\n const descriptorToClose = fileDescriptor;\n fileDescriptor = undefined;\n fs.closeSync(descriptorToClose);\n\n fs.renameSync(temporaryPath, targetPath);\n } finally {\n if (fileDescriptor !== undefined) {\n const descriptorToClose = fileDescriptor;\n fileDescriptor = undefined;\n fs.closeSync(descriptorToClose);\n }\n cleanupTemporaryFile(temporaryPath);\n }\n}\n\n/**\n * Fills missing global seed files.\n *\n * Existing files are left alone so that re-running init never discards\n * hand-edited config; pass `force` to overwrite them from the template.\n */\nexport function initializeGlobalDoomConfig(\n homeDirectory = os.homedir(),\n options: GlobalDoomInitOptions = {},\n): GlobalDoomInitResult {\n const directory = globalDoomConfigDirectory(homeDirectory);\n ensureGlobalDoomDirectory(directory);\n\n const created: string[] = [];\n const preserved: string[] = [];\n const replaced: string[] = [];\n for (const fileName of GLOBAL_DOOM_SEED_FILES) {\n const targetPath = path.join(directory, fileName);\n const existed = classifyTarget(targetPath) === 'file';\n\n if (options.force) {\n publishForcefully(targetPath, DOOM_CONFIG_TEMPLATES[fileName]);\n (existed ? replaced : created).push(fileName);\n continue;\n }\n if (existed) {\n preserved.push(fileName);\n continue;\n }\n if (publishExclusively(targetPath, DOOM_CONFIG_TEMPLATES[fileName])) created.push(fileName);\n else preserved.push(fileName);\n }\n\n return { directory, created, preserved, replaced };\n}\n"],"mappings":"8SAOA,MAEM,EAAgB,OAChB,EAAsB,SACtB,EAAiB,SAGV,EAAyB,CACpC,cACA,aACA,eACA,gBACA,YACF,EAKa,EAAsE,CACjF,cAAe;;;;;;;;;;;;;;EAef,aAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2Cd,eAAgB;;;;;;;;;;;;;EAchB,gBAAiB;EACjB,aAAc;CAChB,EAqBA,SAAS,EAAU,EAAoC,CACrD,GAAI,EAAE,aAAiB,OAAQ,OAC/B,IAAM,EAAQ,EAAgC,KAC9C,OAAO,OAAO,GAAS,SAAW,EAAO,IAAA,EAC3C,CAEA,SAAS,EAAgB,EAAyB,CAChD,IAAI,EACJ,GAAI,CACF,EAAQA,EAAAA,QAAG,U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CAAS,EAEnC,IAAM,EAAoB,CAAC,EACrB,EAAsB,CAAC,EACvB,EAAqB,CAAC,EAC5B,IAAK,IAAM,KAAY,EAAwB,CAC7C,IAAM,EAAaH,EAAAA,QAAK,KAAK,EAAW,CAAQ,EAC1C,EAAU,EAAe,CAAU,IAAM,OAE/C,GAAI,EAAQ,MAAO,CACjB,EAAkB,EAAY,EAAsB,EAAS,GAC5D,EAAU,EAAW,EAAA,CAAS,KAAK,CAAQ,EAC5C,QACF,CACA,GAAI,EAAS,CACX,EAAU,KAAK,CAAQ,EACvB,QACF,CACI,EAAmB,EAAY,EAAsB,EAAS,EAAG,EAAQ,KAAK,CAAQ,EACrF,EAAU,KAAK,CAAQ,CAC9B,CAEA,MAAO,CAAE,YAAW,UAAS,YAAW,UAAS,CACnD"}
@@ -0,0 +1,33 @@
1
+ //#region src/init.d.ts
2
+ /** The global seed files are processed in this fixed order. */
3
+ declare const GLOBAL_DOOM_SEED_FILES: readonly ["config.yaml", "modes.yaml", "domains.yaml", "profiles.yaml", "hooks.yaml"];
4
+ type GlobalDoomSeedFile = (typeof GLOBAL_DOOM_SEED_FILES)[number];
5
+ /** Portable defaults for a new global Doom configuration directory. */
6
+ declare const DOOM_CONFIG_TEMPLATES: Readonly<Record<GlobalDoomSeedFile, string>>;
7
+ /** Result of filling the global seed directory. File arrays contain names in seed order. */
8
+ interface GlobalDoomInitResult {
9
+ directory: string;
10
+ created: string[];
11
+ preserved: string[];
12
+ /** Existing files overwritten from the template. Only ever non-empty under `force`. */
13
+ replaced: string[];
14
+ }
15
+ interface GlobalDoomInitOptions {
16
+ /**
17
+ * Overwrite existing seed files instead of preserving them.
18
+ *
19
+ * Off by default: init is safe to re-run, and hand-edited config is the
20
+ * normal case rather than the exception.
21
+ */
22
+ force?: boolean;
23
+ }
24
+ /**
25
+ * Fills missing global seed files.
26
+ *
27
+ * Existing files are left alone so that re-running init never discards
28
+ * hand-edited config; pass `force` to overwrite them from the template.
29
+ */
30
+ declare function initializeGlobalDoomConfig(homeDirectory?: string, options?: GlobalDoomInitOptions): GlobalDoomInitResult;
31
+ //#endregion
32
+ export { DOOM_CONFIG_TEMPLATES, GLOBAL_DOOM_SEED_FILES, GlobalDoomInitOptions, GlobalDoomInitResult, initializeGlobalDoomConfig };
33
+ //# sourceMappingURL=init.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.cts","names":[],"sources":["../src/init.ts"],"mappings":";;cAca;KAQR,6BAA6B;;cAGrB,uBAAuB,SAAS,OAAO;;UA8EnC;EACf;EACA;EACA;;EAEA;;UAGe;;;;;;;EAOf;;;;;;;;iBAkIc,2BACd,wBACA,UAAS,wBACR"}
@@ -0,0 +1,33 @@
1
+ //#region src/init.d.ts
2
+ /** The global seed files are processed in this fixed order. */
3
+ declare const GLOBAL_DOOM_SEED_FILES: readonly ["config.yaml", "modes.yaml", "domains.yaml", "profiles.yaml", "hooks.yaml"];
4
+ type GlobalDoomSeedFile = (typeof GLOBAL_DOOM_SEED_FILES)[number];
5
+ /** Portable defaults for a new global Doom configuration directory. */
6
+ declare const DOOM_CONFIG_TEMPLATES: Readonly<Record<GlobalDoomSeedFile, string>>;
7
+ /** Result of filling the global seed directory. File arrays contain names in seed order. */
8
+ interface GlobalDoomInitResult {
9
+ directory: string;
10
+ created: string[];
11
+ preserved: string[];
12
+ /** Existing files overwritten from the template. Only ever non-empty under `force`. */
13
+ replaced: string[];
14
+ }
15
+ interface GlobalDoomInitOptions {
16
+ /**
17
+ * Overwrite existing seed files instead of preserving them.
18
+ *
19
+ * Off by default: init is safe to re-run, and hand-edited config is the
20
+ * normal case rather than the exception.
21
+ */
22
+ force?: boolean;
23
+ }
24
+ /**
25
+ * Fills missing global seed files.
26
+ *
27
+ * Existing files are left alone so that re-running init never discards
28
+ * hand-edited config; pass `force` to overwrite them from the template.
29
+ */
30
+ declare function initializeGlobalDoomConfig(homeDirectory?: string, options?: GlobalDoomInitOptions): GlobalDoomInitResult;
31
+ //#endregion
32
+ export { DOOM_CONFIG_TEMPLATES, GLOBAL_DOOM_SEED_FILES, GlobalDoomInitOptions, GlobalDoomInitResult, initializeGlobalDoomConfig };
33
+ //# sourceMappingURL=init.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.mts","names":[],"sources":["../src/init.ts"],"mappings":";;cAca;KAQR,6BAA6B;;cAGrB,uBAAuB,SAAS,OAAO;;UA8EnC;EACf;EACA;EACA;;EAEA;;UAGe;;;;;;;EAOf;;;;;;;;iBAkIc,2BACd,wBACA,UAAS,wBACR"}
package/dist/init.mjs ADDED
@@ -0,0 +1,73 @@
1
+ import{globalDoomConfigDirectory as e}from"./config.mjs";import t from"node:fs";import n from"node:os";import r from"node:path";import{randomUUID as i}from"node:crypto";const a=`utf8`,o=`EEXIST`,s=`ENOENT`,c=[`config.yaml`,`modes.yaml`,`domains.yaml`,`profiles.yaml`,`hooks.yaml`],l={"config.yaml":`projectTrust: ask
2
+
3
+ # Autonomous voice is opt-in and uses an explicitly configured Pi model.
4
+ # voice:
5
+ # autoCapture:
6
+ # model: provider/model-id
7
+ # startPhrases:
8
+ # - hey doom
9
+ # stopPhrases:
10
+ # - stop speaking
11
+ # tts:
12
+ # engine: macos-say
13
+ # voice: Samantha
14
+ # rate: 190
15
+ `,"modes.yaml":`# Seeded defaults. Every layer here resolves from what Doom Pi installs or
16
+ # from a public package, so a fresh install works with no extra setup.
17
+ #
18
+ # Layers and modes defined here apply to every repository. A repository's own
19
+ # .doom/modes.yaml is read after this file and replaces any layer or mode of the
20
+ # same name, so a repository can override one entry without restating the rest.
21
+ #
22
+ # A layer package is an npm specifier, or a path if it was never published:
23
+ # packages: ['./extensions/my-ext']
24
+ # A path is relative to the config that declares it, so it resolves beside this
25
+ # file here (~/.pi/.doom) and against the repository root in a repository copy.
26
+ layers:
27
+ guardrails:
28
+ # repositoryHooks ships with Doom Pi, so the layer steers the agent toward
29
+ # the governing skill and scaffolding before it writes.
30
+ extensions: [repositoryHooks]
31
+ hookGroups: [guardrails, scaffolding]
32
+ vibe-lint:
33
+ packages:
34
+ - '@agimon-ai/vibe-lint/extensions/pi'
35
+ team:
36
+ packages:
37
+ - '@agimon-ai/doompi-team/extensions/doom'
38
+ plan-mode:
39
+ packages:
40
+ - '@agimon-ai/doompi-plan/extensions/doom'
41
+ runner:
42
+ packages:
43
+ - '@agimon-ai/doompi-runner/extensions/pi'
44
+ style-system:
45
+ extensions: [styleSystem]
46
+ goal:
47
+ packages:
48
+ - '@narumitw/pi-goal/src/index.ts'
49
+ ask-user:
50
+ packages:
51
+ - '@juicesharp/rpiv-ask-user-question'
52
+ # copilot is the default when --major-mode is not passed. Add your own modes
53
+ # here; a mode is just a named set of the layers above.
54
+ majorMode:
55
+ minimal: [guardrails, team]
56
+ copilot: [guardrails, vibe-lint, team, plan-mode, runner, style-system, goal, ask-user]
57
+ `,"domains.yaml":`# A domain is a named set of plugin directories loaded for a session.
58
+ # Add your own alongside default; aliases map short names onto them.
59
+ #
60
+ # Each plugin path is written in full and is relative to the config that
61
+ # declares it, so it resolves beside this file here (~/.pi/.doom) and against
62
+ # the repository root in a repository copy:
63
+ # plugins: ['plugins/my-plugin']
64
+ # A repository's own .doom/domains.yaml is read after this file and replaces any
65
+ # domain of the same name.
66
+ domains:
67
+ default:
68
+ plugins: []
69
+ aliases: {}
70
+ `,"profiles.yaml":`profiles: {}
71
+ `,"hooks.yaml":`groups: {}
72
+ `};function u(e){if(!(e instanceof Error))return;let t=e.code;return typeof t==`string`?t:void 0}function d(e){let n;try{n=t.lstatSync(e)}catch(r){if(u(r)!==s)throw r;try{t.mkdirSync(e,{mode:448}),n=t.lstatSync(e)}catch(r){if(u(r)!==o)throw r;n=t.lstatSync(e)}}if(n.isSymbolicLink())throw Error(`Refusing to initialize through symlinked directory: ${e}`);if(!n.isDirectory())throw Error(`Doom config path is not a directory: ${e}`)}function f(e){d(r.dirname(e)),d(e)}function p(e){let n;try{n=t.lstatSync(e)}catch(e){if(u(e)===s)return`missing`;throw e}if(n.isFile())return`file`;if(n.isSymbolicLink())try{if(t.statSync(e).isFile())return`file`}catch(t){throw Error(`Doom config seed symlink is not file-like: ${e}`,{cause:t})}throw Error(`Doom config seed path is not file-like: ${e}`)}function m(e){try{t.unlinkSync(e)}catch(e){if(u(e)!==s)throw e}}function h(e,n){let r=`${e}.${process.pid}.${i()}.tmp`,s;try{s=t.openSync(r,`wx`,384),t.writeFileSync(s,n,a),t.fchmodSync(s,384),t.fsyncSync(s);let i=s;s=void 0,t.closeSync(i);try{return t.linkSync(r,e),!0}catch(t){if(u(t)===o&&p(e)===`file`)return!1;throw t}}finally{if(s!==void 0){let e=s;s=void 0,t.closeSync(e)}m(r)}}function g(e,n){let r=`${e}.${process.pid}.${i()}.tmp`,o;try{o=t.openSync(r,`wx`,384),t.writeFileSync(o,n,a),t.fchmodSync(o,384),t.fsyncSync(o);let i=o;o=void 0,t.closeSync(i),t.renameSync(r,e)}finally{if(o!==void 0){let e=o;o=void 0,t.closeSync(e)}m(r)}}function _(t=n.homedir(),i={}){let a=e(t);f(a);let o=[],s=[],u=[];for(let e of c){let t=r.join(a,e),n=p(t)===`file`;if(i.force){g(t,l[e]),(n?u:o).push(e);continue}if(n){s.push(e);continue}h(t,l[e])?o.push(e):s.push(e)}return{directory:a,created:o,preserved:s,replaced:u}}export{l as DOOM_CONFIG_TEMPLATES,c as GLOBAL_DOOM_SEED_FILES,_ as initializeGlobalDoomConfig};
73
+ //# sourceMappingURL=init.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.mjs","names":[],"sources":["../src/init.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from './config.ts';\n\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst PRIVATE_FILE_MODE = 0o600;\nconst UTF8_ENCODING = 'utf8';\nconst FILE_ALREADY_EXISTS = 'EEXIST';\nconst FILE_NOT_FOUND = 'ENOENT';\n\n/** The global seed files are processed in this fixed order. */\nexport const GLOBAL_DOOM_SEED_FILES = [\n 'config.yaml',\n 'modes.yaml',\n 'domains.yaml',\n 'profiles.yaml',\n 'hooks.yaml',\n] as const;\n\ntype GlobalDoomSeedFile = (typeof GLOBAL_DOOM_SEED_FILES)[number];\n\n/** Portable defaults for a new global Doom configuration directory. */\nexport const DOOM_CONFIG_TEMPLATES: Readonly<Record<GlobalDoomSeedFile, string>> = {\n 'config.yaml': `projectTrust: ask\n\n# Autonomous voice is opt-in and uses an explicitly configured Pi model.\n# voice:\n# autoCapture:\n# model: provider/model-id\n# startPhrases:\n# - hey doom\n# stopPhrases:\n# - stop speaking\n# tts:\n# engine: macos-say\n# voice: Samantha\n# rate: 190\n`,\n 'modes.yaml': `# Seeded defaults. Every layer here resolves from what Doom Pi installs or\n# from a public package, so a fresh install works with no extra setup.\n#\n# Layers and modes defined here apply to every repository. A repository's own\n# .doom/modes.yaml is read after this file and replaces any layer or mode of the\n# same name, so a repository can override one entry without restating the rest.\n#\n# A layer package is an npm specifier, or a path if it was never published:\n# packages: ['./extensions/my-ext']\n# A path is relative to the config that declares it, so it resolves beside this\n# file here (~/.pi/.doom) and against the repository root in a repository copy.\nlayers:\n guardrails:\n # repositoryHooks ships with Doom Pi, so the layer steers the agent toward\n # the governing skill and scaffolding before it writes.\n extensions: [repositoryHooks]\n hookGroups: [guardrails, scaffolding]\n vibe-lint:\n packages:\n - '@agimon-ai/vibe-lint/extensions/pi'\n team:\n packages:\n - '@agimon-ai/doompi-team/extensions/doom'\n plan-mode:\n packages:\n - '@agimon-ai/doompi-plan/extensions/doom'\n runner:\n packages:\n - '@agimon-ai/doompi-runner/extensions/pi'\n style-system:\n extensions: [styleSystem]\n goal:\n packages:\n - '@narumitw/pi-goal/src/index.ts'\n ask-user:\n packages:\n - '@juicesharp/rpiv-ask-user-question'\n# copilot is the default when --major-mode is not passed. Add your own modes\n# here; a mode is just a named set of the layers above.\nmajorMode:\n minimal: [guardrails, team]\n copilot: [guardrails, vibe-lint, team, plan-mode, runner, style-system, goal, ask-user]\n`,\n 'domains.yaml': `# A domain is a named set of plugin directories loaded for a session.\n# Add your own alongside default; aliases map short names onto them.\n#\n# Each plugin path is written in full and is relative to the config that\n# declares it, so it resolves beside this file here (~/.pi/.doom) and against\n# the repository root in a repository copy:\n# plugins: ['plugins/my-plugin']\n# A repository's own .doom/domains.yaml is read after this file and replaces any\n# domain of the same name.\ndomains:\n default:\n plugins: []\naliases: {}\n`,\n 'profiles.yaml': 'profiles: {}\\n',\n 'hooks.yaml': 'groups: {}\\n',\n};\n\n/** Result of filling the global seed directory. File arrays contain names in seed order. */\nexport interface GlobalDoomInitResult {\n directory: string;\n created: string[];\n preserved: string[];\n /** Existing files overwritten from the template. Only ever non-empty under `force`. */\n replaced: string[];\n}\n\nexport interface GlobalDoomInitOptions {\n /**\n * Overwrite existing seed files instead of preserving them.\n *\n * Off by default: init is safe to re-run, and hand-edited config is the\n * normal case rather than the exception.\n */\n force?: boolean;\n}\n\nfunction errorCode(error: unknown): string | undefined {\n if (!(error instanceof Error)) return undefined;\n const code = (error as NodeJS.ErrnoException).code;\n return typeof code === 'string' ? code : undefined;\n}\n\nfunction ensureDirectory(directory: string): void {\n let stats: fs.Stats;\n try {\n stats = fs.lstatSync(directory);\n } catch (error) {\n if (errorCode(error) !== FILE_NOT_FOUND) throw error;\n try {\n fs.mkdirSync(directory, { mode: PRIVATE_DIRECTORY_MODE });\n stats = fs.lstatSync(directory);\n } catch (mkdirError) {\n if (errorCode(mkdirError) !== FILE_ALREADY_EXISTS) throw mkdirError;\n stats = fs.lstatSync(directory);\n }\n }\n\n if (stats.isSymbolicLink()) {\n throw new Error(`Refusing to initialize through symlinked directory: ${directory}`);\n }\n if (!stats.isDirectory()) {\n throw new Error(`Doom config path is not a directory: ${directory}`);\n }\n}\n\nfunction ensureGlobalDoomDirectory(directory: string): void {\n ensureDirectory(path.dirname(directory));\n ensureDirectory(directory);\n}\n\nfunction classifyTarget(targetPath: string): 'missing' | 'file' {\n let stats: fs.Stats;\n try {\n stats = fs.lstatSync(targetPath);\n } catch (error) {\n if (errorCode(error) === FILE_NOT_FOUND) return 'missing';\n throw error;\n }\n\n if (stats.isFile()) return 'file';\n if (stats.isSymbolicLink()) {\n try {\n if (fs.statSync(targetPath).isFile()) return 'file';\n } catch (error) {\n throw new Error(`Doom config seed symlink is not file-like: ${targetPath}`, { cause: error });\n }\n }\n throw new Error(`Doom config seed path is not file-like: ${targetPath}`);\n}\n\nfunction cleanupTemporaryFile(temporaryPath: string): void {\n try {\n fs.unlinkSync(temporaryPath);\n } catch (error) {\n if (errorCode(error) !== FILE_NOT_FOUND) throw error;\n }\n}\n\nfunction publishExclusively(targetPath: string, content: string): boolean {\n const temporaryPath = `${targetPath}.${process.pid}.${randomUUID()}.tmp`;\n let fileDescriptor: number | undefined;\n try {\n fileDescriptor = fs.openSync(temporaryPath, 'wx', PRIVATE_FILE_MODE);\n fs.writeFileSync(fileDescriptor, content, UTF8_ENCODING);\n fs.fchmodSync(fileDescriptor, PRIVATE_FILE_MODE);\n fs.fsyncSync(fileDescriptor);\n const descriptorToClose = fileDescriptor;\n fileDescriptor = undefined;\n fs.closeSync(descriptorToClose);\n\n try {\n fs.linkSync(temporaryPath, targetPath);\n return true;\n } catch (error) {\n if (errorCode(error) === FILE_ALREADY_EXISTS && classifyTarget(targetPath) === 'file') return false;\n throw error;\n }\n } finally {\n if (fileDescriptor !== undefined) {\n const descriptorToClose = fileDescriptor;\n fileDescriptor = undefined;\n fs.closeSync(descriptorToClose);\n }\n cleanupTemporaryFile(temporaryPath);\n }\n}\n\n/**\n * Replaces a seed file with the template, atomically.\n *\n * The rename swaps the directory entry in one step, so a reader either sees the\n * whole old file or the whole new one. Renaming onto a symlinked seed replaces\n * the link rather than writing through it.\n */\nfunction publishForcefully(targetPath: string, content: string): void {\n const temporaryPath = `${targetPath}.${process.pid}.${randomUUID()}.tmp`;\n let fileDescriptor: number | undefined;\n try {\n fileDescriptor = fs.openSync(temporaryPath, 'wx', PRIVATE_FILE_MODE);\n fs.writeFileSync(fileDescriptor, content, UTF8_ENCODING);\n fs.fchmodSync(fileDescriptor, PRIVATE_FILE_MODE);\n fs.fsyncSync(fileDescriptor);\n const descriptorToClose = fileDescriptor;\n fileDescriptor = undefined;\n fs.closeSync(descriptorToClose);\n\n fs.renameSync(temporaryPath, targetPath);\n } finally {\n if (fileDescriptor !== undefined) {\n const descriptorToClose = fileDescriptor;\n fileDescriptor = undefined;\n fs.closeSync(descriptorToClose);\n }\n cleanupTemporaryFile(temporaryPath);\n }\n}\n\n/**\n * Fills missing global seed files.\n *\n * Existing files are left alone so that re-running init never discards\n * hand-edited config; pass `force` to overwrite them from the template.\n */\nexport function initializeGlobalDoomConfig(\n homeDirectory = os.homedir(),\n options: GlobalDoomInitOptions = {},\n): GlobalDoomInitResult {\n const directory = globalDoomConfigDirectory(homeDirectory);\n ensureGlobalDoomDirectory(directory);\n\n const created: string[] = [];\n const preserved: string[] = [];\n const replaced: string[] = [];\n for (const fileName of GLOBAL_DOOM_SEED_FILES) {\n const targetPath = path.join(directory, fileName);\n const existed = classifyTarget(targetPath) === 'file';\n\n if (options.force) {\n publishForcefully(targetPath, DOOM_CONFIG_TEMPLATES[fileName]);\n (existed ? replaced : created).push(fileName);\n continue;\n }\n if (existed) {\n preserved.push(fileName);\n continue;\n }\n if (publishExclusively(targetPath, DOOM_CONFIG_TEMPLATES[fileName])) created.push(fileName);\n else preserved.push(fileName);\n }\n\n return { directory, created, preserved, replaced };\n}\n"],"mappings":"yKAOA,MAEM,EAAgB,OAChB,EAAsB,SACtB,EAAiB,SAGV,EAAyB,CACpC,cACA,aACA,eACA,gBACA,YACF,EAKa,EAAsE,CACjF,cAAe;;;;;;;;;;;;;;EAef,aAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2Cd,eAAgB;;;;;;;;;;;;;EAchB,gBAAiB;EACjB,aAAc;CAChB,EAqBA,SAAS,E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EnC,IAAM,EAAoB,CAAC,EACrB,EAAsB,CAAC,EACvB,EAAqB,CAAC,EAC5B,IAAK,IAAM,KAAY,EAAwB,CAC7C,IAAM,EAAa,EAAK,KAAK,EAAW,CAAQ,EAC1C,EAAU,EAAe,CAAU,IAAM,OAE/C,GAAI,EAAQ,MAAO,CACjB,EAAkB,EAAY,EAAsB,EAAS,GAC5D,EAAU,EAAW,EAAA,CAAS,KAAK,CAAQ,EAC5C,QACF,CACA,GAAI,EAAS,CACX,EAAU,KAAK,CAAQ,EACvB,QACF,CACI,EAAmB,EAAY,EAAsB,EAAS,EAAG,EAAQ,KAAK,CAAQ,EACrF,EAAU,KAAK,CAAQ,CAC9B,CAEA,MAAO,CAAE,YAAW,UAAS,YAAW,UAAS,CACnD"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_virtual/_rolldown/runtime.cjs"),t=require("./config.cjs");let n=require("node:fs");n=e.__toESM(n,1);let r=require("node:os");r=e.__toESM(r,1);let i=require("node:path");i=e.__toESM(i,1);let a=require("yaml");const o=`.doom`;function s(e,n,a=r.default.homedir()){let s=t.globalDoomConfigDirectory(a);return[{filePath:i.default.join(s,e),baseDirectory:s},{filePath:i.default.join(n,o,e),baseDirectory:n}]}function c(e,t,i=r.default.homedir()){let o=s(e,t,i),c=[];for(let e of o){if(!n.default.existsSync(e.filePath))continue;let t=n.default.readFileSync(e.filePath,`utf8`),r=(0,a.parse)(t);r!=null&&c.push({...e,text:t,document:r})}return c}function l(e,t){let n={};for(let r of e)for(let[e,i]of Object.entries(t(r.document)??{}))n[e]={...i,baseDirectory:r.baseDirectory};return n}exports.DOOM_DIR=o,exports.doomConfigCandidates=s,exports.mergeNamedSources=l,exports.readDoomConfigSources=c;
2
+ //# sourceMappingURL=layeredConfig.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layeredConfig.cjs","names":["os","globalDoomConfigDirectory","path","fs","parseYaml"],"sources":["../src/layeredConfig.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { parse as parseYaml } from 'yaml';\nimport { globalDoomConfigDirectory } from './config.ts';\n\n/** Repository-local doom-pi configuration directory, committed to git. */\nexport const DOOM_DIR = '.doom';\n\nconst TEXT_ENCODING = 'utf8';\n\n/** One `.doom` document plus the root its relative paths resolve against. */\nexport interface DoomConfigSource<TDocument> {\n /** Absolute path of the file the document was read from. */\n filePath: string;\n /**\n * Where relative paths inside this document point.\n *\n * A repository document resolves against the repository root, so `plugins/x`\n * keeps meaning the same thing it always has. A global document resolves\n * against the global `.doom` directory, so it can name plugins and extensions\n * that live beside it in `~/.pi/.doom` rather than inside whichever\n * repository happens to be open.\n */\n baseDirectory: string;\n /** Raw file contents, for callers that cache parsed results by source text. */\n text: string;\n document: TDocument;\n}\n\n/**\n * Reads one named `.doom` document from the global and repository config\n * directories, lowest precedence first.\n *\n * A missing or empty file contributes nothing, so either location on its own is\n * a complete configuration. Documents are deliberately returned unmerged:\n * merging is by name, and only the caller knows what a name means in its own\n * document, so each one folds the sources itself with the repository last.\n */\nexport function doomConfigCandidates(\n fileName: string,\n repoRoot: string,\n homeDirectory: string = os.homedir(),\n): Array<{ filePath: string; baseDirectory: string }> {\n const globalDirectory = globalDoomConfigDirectory(homeDirectory);\n return [\n { filePath: path.join(globalDirectory, fileName), baseDirectory: globalDirectory },\n { filePath: path.join(repoRoot, DOOM_DIR, fileName), baseDirectory: repoRoot },\n ];\n}\n\nexport function readDoomConfigSources<TDocument>(\n fileName: string,\n repoRoot: string,\n homeDirectory: string = os.homedir(),\n): Array<DoomConfigSource<TDocument>> {\n const candidates = doomConfigCandidates(fileName, repoRoot, homeDirectory);\n\n const sources: Array<DoomConfigSource<TDocument>> = [];\n for (const candidate of candidates) {\n if (!fs.existsSync(candidate.filePath)) continue;\n const text = fs.readFileSync(candidate.filePath, TEXT_ENCODING);\n const document = parseYaml(text) as TDocument | null | undefined;\n // An empty file parses to null and is treated as an absent one, so a seeded\n // placeholder never has to be deleted to get out of the way.\n if (document === null || document === undefined) continue;\n sources.push({ ...candidate, text, document });\n }\n return sources;\n}\n\n/**\n * Merges same-named records across sources, tagging each entry with the base\n * directory of the document that supplied it.\n *\n * Later sources win outright rather than being deep-merged: a repository that\n * redefines a name is replacing it, and a half-inherited definition whose paths\n * straddle two roots would be impossible to resolve.\n */\nexport function mergeNamedSources<TDocument, TEntry>(\n sources: ReadonlyArray<DoomConfigSource<TDocument>>,\n select: (document: TDocument) => Record<string, TEntry> | undefined,\n): Record<string, TEntry & { baseDirectory: string }> {\n const merged: Record<string, TEntry & { baseDirectory: string }> = {};\n for (const source of sources) {\n for (const [name, entry] of Object.entries(select(source.document) ?? {})) {\n merged[name] = { ...entry, baseDirectory: source.baseDirectory };\n }\n }\n return merged;\n}\n"],"mappings":"uSAOA,MAAa,EAAW,QAgCxB,SAAgB,EACd,EACA,EACA,EAAwBA,EAAAA,QAAG,QAAQ,EACiB,CACpD,IAAM,EAAkBC,EAAAA,0BAA0B,CAAa,EAC/D,MAAO,CACL,CAAE,SAAUC,EAAAA,QAAK,KAAK,EAAiB,CAAQ,EAAG,cAAe,CAAgB,EACjF,CAAE,SAAUA,EAAAA,QAAK,KAAK,EAAU,EAAU,CAAQ,EAAG,cAAe,CAAS,CAC/E,CACF,CAEA,SAAgB,EACd,EACA,EACA,EAAwBF,EAAAA,QAAG,QAAQ,EACC,CACpC,IAAM,EAAa,EAAqB,EAAU,EAAU,CAAa,EAEnE,EAA8C,CAAC,EACrD,IAAK,IAAM,KAAa,EAAY,CAClC,GAAI,CAACG,EAAAA,QAAG,WAAW,EAAU,QAAQ,EAAG,SACxC,IAAM,EAAOA,EAAAA,QAAG,aAAa,EAAU,SAAU,MAAa,EACxD,GAAA,EAAWC,EAAAA,MAAAA,CAAU,CAAI,EAG3B,GAAa,MACjB,EAAQ,KAAK,CAAE,GAAG,EAAW,OAAM,UAAS,CAAC,CAC/C,CACA,OAAO,CACT,CAUA,SAAgB,EACd,EACA,EACoD,CACpD,IAAM,EAA6D,CAAC,EACpE,IAAK,IAAM,KAAU,EACnB,IAAK,GAAM,CAAC,EAAM,KAAU,OAAO,QAAQ,EAAO,EAAO,QAAQ,GAAK,CAAC,CAAC,EACtE,EAAO,GAAQ,CAAE,GAAG,EAAO,cAAe,EAAO,aAAc,EAGnE,OAAO,CACT"}
@@ -0,0 +1,49 @@
1
+ //#region src/layeredConfig.d.ts
2
+ /** Repository-local doom-pi configuration directory, committed to git. */
3
+ declare const DOOM_DIR = ".doom";
4
+ /** One `.doom` document plus the root its relative paths resolve against. */
5
+ interface DoomConfigSource<TDocument> {
6
+ /** Absolute path of the file the document was read from. */
7
+ filePath: string;
8
+ /**
9
+ * Where relative paths inside this document point.
10
+ *
11
+ * A repository document resolves against the repository root, so `plugins/x`
12
+ * keeps meaning the same thing it always has. A global document resolves
13
+ * against the global `.doom` directory, so it can name plugins and extensions
14
+ * that live beside it in `~/.pi/.doom` rather than inside whichever
15
+ * repository happens to be open.
16
+ */
17
+ baseDirectory: string;
18
+ /** Raw file contents, for callers that cache parsed results by source text. */
19
+ text: string;
20
+ document: TDocument;
21
+ }
22
+ /**
23
+ * Reads one named `.doom` document from the global and repository config
24
+ * directories, lowest precedence first.
25
+ *
26
+ * A missing or empty file contributes nothing, so either location on its own is
27
+ * a complete configuration. Documents are deliberately returned unmerged:
28
+ * merging is by name, and only the caller knows what a name means in its own
29
+ * document, so each one folds the sources itself with the repository last.
30
+ */
31
+ declare function doomConfigCandidates(fileName: string, repoRoot: string, homeDirectory?: string): Array<{
32
+ filePath: string;
33
+ baseDirectory: string;
34
+ }>;
35
+ declare function readDoomConfigSources<TDocument>(fileName: string, repoRoot: string, homeDirectory?: string): Array<DoomConfigSource<TDocument>>;
36
+ /**
37
+ * Merges same-named records across sources, tagging each entry with the base
38
+ * directory of the document that supplied it.
39
+ *
40
+ * Later sources win outright rather than being deep-merged: a repository that
41
+ * redefines a name is replacing it, and a half-inherited definition whose paths
42
+ * straddle two roots would be impossible to resolve.
43
+ */
44
+ declare function mergeNamedSources<TDocument, TEntry>(sources: ReadonlyArray<DoomConfigSource<TDocument>>, select: (document: TDocument) => Record<string, TEntry> | undefined): Record<string, TEntry & {
45
+ baseDirectory: string;
46
+ }>;
47
+ //#endregion
48
+ export { DOOM_DIR, DoomConfigSource, doomConfigCandidates, mergeNamedSources, readDoomConfigSources };
49
+ //# sourceMappingURL=layeredConfig.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layeredConfig.d.cts","names":[],"sources":["../src/layeredConfig.ts"],"mappings":";;cAOa;;UAKI,iBAAiB;;EAEhC;;;;;;;;;;EAUA;;EAEA;EACA,UAAU;;;;;;;;;;;iBAYI,qBACd,kBACA,kBACA,yBACC;EAAQ;EAAkB;;iBAQb,sBAAsB,WACpC,kBACA,kBACA,yBACC,MAAM,iBAAiB;;;;;;;;;iBAwBV,kBAAkB,WAAW,QAC3C,SAAS,cAAc,iBAAiB,aACxC,SAAS,UAAU,cAAc,eAAe,sBAC/C,eAAe;EAAW"}
@@ -0,0 +1,49 @@
1
+ //#region src/layeredConfig.d.ts
2
+ /** Repository-local doom-pi configuration directory, committed to git. */
3
+ declare const DOOM_DIR = ".doom";
4
+ /** One `.doom` document plus the root its relative paths resolve against. */
5
+ interface DoomConfigSource<TDocument> {
6
+ /** Absolute path of the file the document was read from. */
7
+ filePath: string;
8
+ /**
9
+ * Where relative paths inside this document point.
10
+ *
11
+ * A repository document resolves against the repository root, so `plugins/x`
12
+ * keeps meaning the same thing it always has. A global document resolves
13
+ * against the global `.doom` directory, so it can name plugins and extensions
14
+ * that live beside it in `~/.pi/.doom` rather than inside whichever
15
+ * repository happens to be open.
16
+ */
17
+ baseDirectory: string;
18
+ /** Raw file contents, for callers that cache parsed results by source text. */
19
+ text: string;
20
+ document: TDocument;
21
+ }
22
+ /**
23
+ * Reads one named `.doom` document from the global and repository config
24
+ * directories, lowest precedence first.
25
+ *
26
+ * A missing or empty file contributes nothing, so either location on its own is
27
+ * a complete configuration. Documents are deliberately returned unmerged:
28
+ * merging is by name, and only the caller knows what a name means in its own
29
+ * document, so each one folds the sources itself with the repository last.
30
+ */
31
+ declare function doomConfigCandidates(fileName: string, repoRoot: string, homeDirectory?: string): Array<{
32
+ filePath: string;
33
+ baseDirectory: string;
34
+ }>;
35
+ declare function readDoomConfigSources<TDocument>(fileName: string, repoRoot: string, homeDirectory?: string): Array<DoomConfigSource<TDocument>>;
36
+ /**
37
+ * Merges same-named records across sources, tagging each entry with the base
38
+ * directory of the document that supplied it.
39
+ *
40
+ * Later sources win outright rather than being deep-merged: a repository that
41
+ * redefines a name is replacing it, and a half-inherited definition whose paths
42
+ * straddle two roots would be impossible to resolve.
43
+ */
44
+ declare function mergeNamedSources<TDocument, TEntry>(sources: ReadonlyArray<DoomConfigSource<TDocument>>, select: (document: TDocument) => Record<string, TEntry> | undefined): Record<string, TEntry & {
45
+ baseDirectory: string;
46
+ }>;
47
+ //#endregion
48
+ export { DOOM_DIR, DoomConfigSource, doomConfigCandidates, mergeNamedSources, readDoomConfigSources };
49
+ //# sourceMappingURL=layeredConfig.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layeredConfig.d.mts","names":[],"sources":["../src/layeredConfig.ts"],"mappings":";;cAOa;;UAKI,iBAAiB;;EAEhC;;;;;;;;;;EAUA;;EAEA;EACA,UAAU;;;;;;;;;;;iBAYI,qBACd,kBACA,kBACA,yBACC;EAAQ;EAAkB;;iBAQb,sBAAsB,WACpC,kBACA,kBACA,yBACC,MAAM,iBAAiB;;;;;;;;;iBAwBV,kBAAkB,WAAW,QAC3C,SAAS,cAAc,iBAAiB,aACxC,SAAS,UAAU,cAAc,eAAe,sBAC/C,eAAe;EAAW"}
@@ -0,0 +1,2 @@
1
+ import{globalDoomConfigDirectory as e}from"./config.mjs";import t from"node:fs";import n from"node:os";import r from"node:path";import{parse as i}from"yaml";const a=`.doom`;function o(t,i,o=n.homedir()){let s=e(o);return[{filePath:r.join(s,t),baseDirectory:s},{filePath:r.join(i,a,t),baseDirectory:i}]}function s(e,r,a=n.homedir()){let s=o(e,r,a),c=[];for(let e of s){if(!t.existsSync(e.filePath))continue;let n=t.readFileSync(e.filePath,`utf8`),r=i(n);r!=null&&c.push({...e,text:n,document:r})}return c}function c(e,t){let n={};for(let r of e)for(let[e,i]of Object.entries(t(r.document)??{}))n[e]={...i,baseDirectory:r.baseDirectory};return n}export{a as DOOM_DIR,o as doomConfigCandidates,c as mergeNamedSources,s as readDoomConfigSources};
2
+ //# sourceMappingURL=layeredConfig.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layeredConfig.mjs","names":["parseYaml"],"sources":["../src/layeredConfig.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { parse as parseYaml } from 'yaml';\nimport { globalDoomConfigDirectory } from './config.ts';\n\n/** Repository-local doom-pi configuration directory, committed to git. */\nexport const DOOM_DIR = '.doom';\n\nconst TEXT_ENCODING = 'utf8';\n\n/** One `.doom` document plus the root its relative paths resolve against. */\nexport interface DoomConfigSource<TDocument> {\n /** Absolute path of the file the document was read from. */\n filePath: string;\n /**\n * Where relative paths inside this document point.\n *\n * A repository document resolves against the repository root, so `plugins/x`\n * keeps meaning the same thing it always has. A global document resolves\n * against the global `.doom` directory, so it can name plugins and extensions\n * that live beside it in `~/.pi/.doom` rather than inside whichever\n * repository happens to be open.\n */\n baseDirectory: string;\n /** Raw file contents, for callers that cache parsed results by source text. */\n text: string;\n document: TDocument;\n}\n\n/**\n * Reads one named `.doom` document from the global and repository config\n * directories, lowest precedence first.\n *\n * A missing or empty file contributes nothing, so either location on its own is\n * a complete configuration. Documents are deliberately returned unmerged:\n * merging is by name, and only the caller knows what a name means in its own\n * document, so each one folds the sources itself with the repository last.\n */\nexport function doomConfigCandidates(\n fileName: string,\n repoRoot: string,\n homeDirectory: string = os.homedir(),\n): Array<{ filePath: string; baseDirectory: string }> {\n const globalDirectory = globalDoomConfigDirectory(homeDirectory);\n return [\n { filePath: path.join(globalDirectory, fileName), baseDirectory: globalDirectory },\n { filePath: path.join(repoRoot, DOOM_DIR, fileName), baseDirectory: repoRoot },\n ];\n}\n\nexport function readDoomConfigSources<TDocument>(\n fileName: string,\n repoRoot: string,\n homeDirectory: string = os.homedir(),\n): Array<DoomConfigSource<TDocument>> {\n const candidates = doomConfigCandidates(fileName, repoRoot, homeDirectory);\n\n const sources: Array<DoomConfigSource<TDocument>> = [];\n for (const candidate of candidates) {\n if (!fs.existsSync(candidate.filePath)) continue;\n const text = fs.readFileSync(candidate.filePath, TEXT_ENCODING);\n const document = parseYaml(text) as TDocument | null | undefined;\n // An empty file parses to null and is treated as an absent one, so a seeded\n // placeholder never has to be deleted to get out of the way.\n if (document === null || document === undefined) continue;\n sources.push({ ...candidate, text, document });\n }\n return sources;\n}\n\n/**\n * Merges same-named records across sources, tagging each entry with the base\n * directory of the document that supplied it.\n *\n * Later sources win outright rather than being deep-merged: a repository that\n * redefines a name is replacing it, and a half-inherited definition whose paths\n * straddle two roots would be impossible to resolve.\n */\nexport function mergeNamedSources<TDocument, TEntry>(\n sources: ReadonlyArray<DoomConfigSource<TDocument>>,\n select: (document: TDocument) => Record<string, TEntry> | undefined,\n): Record<string, TEntry & { baseDirectory: string }> {\n const merged: Record<string, TEntry & { baseDirectory: string }> = {};\n for (const source of sources) {\n for (const [name, entry] of Object.entries(select(source.document) ?? {})) {\n merged[name] = { ...entry, baseDirectory: source.baseDirectory };\n }\n }\n return merged;\n}\n"],"mappings":"6JAOA,MAAa,EAAW,QAgCxB,SAAgB,EACd,EACA,EACA,EAAwB,EAAG,QAAQ,EACiB,CACpD,IAAM,EAAkB,EAA0B,CAAa,EAC/D,MAAO,CACL,CAAE,SAAU,EAAK,KAAK,EAAiB,CAAQ,EAAG,cAAe,CAAgB,EACjF,CAAE,SAAU,EAAK,KAAK,EAAU,EAAU,CAAQ,EAAG,cAAe,CAAS,CAC/E,CACF,CAEA,SAAgB,EACd,EACA,EACA,EAAwB,EAAG,QAAQ,EACC,CACpC,IAAM,EAAa,EAAqB,EAAU,EAAU,CAAa,EAEnE,EAA8C,CAAC,EACrD,IAAK,IAAM,KAAa,EAAY,CAClC,GAAI,CAAC,EAAG,WAAW,EAAU,QAAQ,EAAG,SACxC,IAAM,EAAO,EAAG,aAAa,EAAU,SAAU,MAAa,EACxD,EAAWA,EAAU,CAAI,EAG3B,GAAa,MACjB,EAAQ,KAAK,CAAE,GAAG,EAAW,OAAM,UAAS,CAAC,CAC/C,CACA,OAAO,CACT,CAUA,SAAgB,EACd,EACA,EACoD,CACpD,IAAM,EAA6D,CAAC,EACpE,IAAK,IAAM,KAAU,EACnB,IAAK,GAAM,CAAC,EAAM,KAAU,OAAO,QAAQ,EAAO,EAAO,QAAQ,GAAK,CAAC,CAAC,EACtE,EAAO,GAAQ,CAAE,GAAG,EAAO,cAAe,EAAO,aAAc,EAGnE,OAAO,CACT"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_virtual/_rolldown/runtime.cjs"),t=require("./layeredConfig.cjs");let n=require("node:os");n=e.__toESM(n,1);let r=require("node:path");r=e.__toESM(r,1);const i=`modes.yaml`,a=r.default.join(t.DOOM_DIR,i),o=[`./`,`../`];function s(e){return r.default.isAbsolute(e)||o.some(t=>e.startsWith(t))}const c=[`subagents`],l=[`models`,`excludeTools`],u=[`model`,`thinking`],d=new Set([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]);function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e,t,n){let r=Object.keys(e).filter(e=>!t.includes(e));if(r.length>0)throw Error(`${n} has unsupported field(s): ${r.join(`, `)}`)}function m(e,t){if(t===void 0)return;let n=`Layer "${e}" config in ${a}`;if(!f(t))throw Error(`${n} must be a mapping`);if(p(t,c,n),t.subagents===void 0)return{};if(!f(t.subagents))throw Error(`${n}.subagents must be a mapping`);p(t.subagents,l,`${n}.subagents`);let r=Object.hasOwn(t.subagents,`models`),i=Object.hasOwn(t.subagents,`excludeTools`);if(!r&&!i)throw Error(`${n}.subagents must define models or excludeTools`);let o;if(r){if(!Array.isArray(t.subagents.models)||t.subagents.models.length===0)throw Error(`${n}.subagents.models must be a non-empty array`);o=t.subagents.models.map((e,t)=>{let r=`${n}.subagents.models[${t}]`;if(!f(e))throw Error(`${r} must be a mapping`);if(p(e,u,r),typeof e.model!=`string`||!e.model.trim())throw Error(`${r}.model must be a non-empty string`);if(e.thinking!==void 0&&(typeof e.thinking!=`string`||!d.has(e.thinking)))throw Error(`${r}.thinking must be one of: ${[...d].join(`, `)}`);return{model:e.model.trim(),...e.thinking?{thinking:e.thinking}:{}}})}let s;if(i){let e=t.subagents.excludeTools;if(!Array.isArray(e)||e.length===0)throw Error(`${n}.subagents.excludeTools must be a non-empty array`);s=[...new Set(e.map((e,t)=>{let r=`${n}.subagents.excludeTools[${t}]`;if(typeof e!=`string`||!e.trim())throw Error(`${r} must be a non-empty string`);return e.trim()}))]}return{subagents:{...o?{models:o}:{},...s?{excludeTools:s}:{}}}}function h(e,t){if(!f(t))throw Error(`Layer "${e}" in ${a} must be a mapping`);if(`targets`in t)throw Error(`Layer "${e}" in ${a} uses removed field "targets"; select availability through major modes`);let n=m(e,t.config);return n===void 0?t:{...t,config:n}}function g(e,r=n.default.homedir()){let o=t.readDoomConfigSources(i,e,r),s={},c={};for(let e of o){for(let[t,n]of Object.entries(e.document.layers??{}))s[t]={...h(t,n),baseDirectory:e.baseDirectory};Object.assign(c,e.document.majorMode??{})}for(let[e,t]of Object.entries(c))for(let n of t)if(!s[n])throw Error(`Unknown layer "${n}" in majorMode.${e} of ${a}`);return{layers:s,majorMode:c}}function _(e,t){let n,r=new Set,i=!1;for(let a of t){let t=e.layers[a];if(!t)throw Error(`Unknown layer: ${a}`);let o=t.config?.subagents;if(o){if(o.excludeTools!==void 0){i=!0;for(let e of o.excludeTools)r.add(e)}n={...n,...o.models?{models:o.models.map(e=>({...e}))}:{},...i?{excludeTools:[...r]}:{}}}}return n?{subagents:n}:{}}function v(e,t){if(!Object.hasOwn(e.majorMode,t))throw Error(`Unknown major mode: ${t}. Known major modes: ${Object.keys(e.majorMode).sort().join(`, `)}`);return[...e.majorMode[t]]}function y(e,t,n){let r=e.layers[t];if(!r)throw Error(`Unknown layer: ${t}`);let i=[];for(let e of r.extensions??[])i.push(n.ownEntry(e));for(let e of r.packages??[]){let a=typeof e==`string`?e:e.name,o=typeof e!=`string`&&e.optional===!0;if(s(a)){let e=n.localEntry(a,r.baseDirectory);if(e)i.push(e);else if(!o)throw Error(`Layer "${t}" package "${a}" does not resolve under ${r.baseDirectory}. Point it at an extension file, or a directory whose package.json names one.`);continue}if(o){let e=n.optionalPackageEntry(a);e&&i.push(e);continue}i.push(n.packageEntry(a))}return i}function b(e,t){let n=new Set;for(let r of t)for(let t of e.layers[r]?.hookGroups??[])n.add(t);return[...n]}exports.isLocalPackageSpecifier=s,exports.layerEntries=y,exports.layerHookGroups=b,exports.loadMajorModesConfig=g,exports.resolveLayerCustomization=_,exports.resolveLayers=v;
2
+ //# sourceMappingURL=majorModes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"majorModes.cjs","names":["path","DOOM_DIR","os","readDoomConfigSources"],"sources":["../src/majorModes.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport { DOOM_DIR, readDoomConfigSources } from './layeredConfig.ts';\nimport type { PlanningThinkingLevel } from './types.ts';\n\nexport interface LayerPackage {\n name: string;\n optional?: boolean;\n}\n\nexport interface SubagentLayerModelConfig {\n model: string;\n thinking?: PlanningThinkingLevel;\n}\n\nexport interface SubagentLayerConfig {\n models?: SubagentLayerModelConfig[];\n excludeTools?: string[];\n}\n\nexport interface LayerCustomizationConfig {\n subagents?: SubagentLayerConfig;\n}\n\nexport interface LayerDefinition {\n extensions?: string[];\n /**\n * npm specifiers, or paths relative to the config that declares the layer.\n * A path (`./`, `../`, or absolute) is resolved against the repository root\n * for `.doom/modes.yaml` and against the global `.doom` directory for\n * `~/.pi/.doom/modes.yaml`, which is how an extension that was never\n * published to npm gets loaded.\n */\n packages?: Array<string | LayerPackage>;\n hookGroups?: string[];\n config?: LayerCustomizationConfig;\n}\n\n/** A layer plus the root its relative package paths resolve against. */\nexport interface ResolvedLayerDefinition extends LayerDefinition {\n baseDirectory: string;\n}\n\nexport interface MajorModesConfig {\n layers: Record<string, ResolvedLayerDefinition>;\n /** Named major modes, each one a set of layer names. */\n majorMode: Record<string, string[]>;\n}\n\nexport interface LayerResolvers {\n ownEntry: (name: string) => string;\n packageEntry: (name: string) => string;\n optionalPackageEntry: (name: string) => string | undefined;\n /** Resolves a path-style layer package against the config that declared it. */\n localEntry: (specifier: string, baseDirectory: string) => string | undefined;\n}\n\ninterface ModesDocument {\n layers?: Record<string, unknown>;\n majorMode?: Record<string, string[]>;\n}\n\nconst MODES_FILE = 'modes.yaml';\nconst MAJOR_MODES_RELATIVE_PATH = path.join(DOOM_DIR, MODES_FILE);\nconst RELATIVE_PREFIXES = ['./', '../'] as const;\n\n/**\n * Whether a layer package names a path rather than an installed package.\n *\n * The same rule Node applies to import specifiers, so a bare name is always an\n * npm package 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_CONFIG_KEYS = ['subagents'] as const;\nconst SUBAGENT_CONFIG_KEYS = ['models', 'excludeTools'] as const;\nconst SUBAGENT_MODEL_KEYS = ['model', 'thinking'] as const;\nconst THINKING_VALUES = new Set<PlanningThinkingLevel>(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\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) {\n throw new Error(`${location} has unsupported field(s): ${unsupported.join(', ')}`);\n }\n}\n\nfunction parseLayerCustomization(name: string, value: unknown): LayerCustomizationConfig | undefined {\n if (value === undefined) return undefined;\n const location = `Layer \"${name}\" config in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!isRecord(value)) throw new Error(`${location} must be a mapping`);\n assertKnownKeys(value, LAYER_CONFIG_KEYS, location);\n if (value.subagents === undefined) return {};\n if (!isRecord(value.subagents)) throw new Error(`${location}.subagents must be a mapping`);\n assertKnownKeys(value.subagents, SUBAGENT_CONFIG_KEYS, `${location}.subagents`);\n const hasModels = Object.hasOwn(value.subagents, 'models');\n const hasExcludeTools = Object.hasOwn(value.subagents, 'excludeTools');\n if (!hasModels && !hasExcludeTools) {\n throw new Error(`${location}.subagents must define models or excludeTools`);\n }\n\n let models: SubagentLayerModelConfig[] | undefined;\n if (hasModels) {\n if (!Array.isArray(value.subagents.models) || value.subagents.models.length === 0) {\n throw new Error(`${location}.subagents.models must be a non-empty array`);\n }\n models = value.subagents.models.map((entry, index): SubagentLayerModelConfig => {\n const entryLocation = `${location}.subagents.models[${index}]`;\n if (!isRecord(entry)) throw new Error(`${entryLocation} must be a mapping`);\n assertKnownKeys(entry, SUBAGENT_MODEL_KEYS, entryLocation);\n if (typeof entry.model !== 'string' || !entry.model.trim()) {\n throw new Error(`${entryLocation}.model must be a non-empty string`);\n }\n if (\n entry.thinking !== undefined &&\n (typeof entry.thinking !== 'string' || !THINKING_VALUES.has(entry.thinking as PlanningThinkingLevel))\n ) {\n throw new Error(`${entryLocation}.thinking must be one of: ${[...THINKING_VALUES].join(', ')}`);\n }\n return {\n model: entry.model.trim(),\n ...(entry.thinking ? { thinking: entry.thinking as PlanningThinkingLevel } : {}),\n };\n });\n }\n\n let normalizedExcludeTools: string[] | undefined;\n if (hasExcludeTools) {\n const excludeTools = value.subagents.excludeTools;\n if (!Array.isArray(excludeTools) || excludeTools.length === 0) {\n throw new Error(`${location}.subagents.excludeTools must be a non-empty array`);\n }\n normalizedExcludeTools = [\n ...new Set(\n excludeTools.map((entry, index) => {\n const entryLocation = `${location}.subagents.excludeTools[${index}]`;\n if (typeof entry !== 'string' || !entry.trim()) {\n throw new Error(`${entryLocation} must be a non-empty string`);\n }\n return entry.trim();\n }),\n ),\n ];\n }\n\n return {\n subagents: {\n ...(models ? { models } : {}),\n ...(normalizedExcludeTools ? { excludeTools: normalizedExcludeTools } : {}),\n },\n };\n}\n\nfunction 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 const config = parseLayerCustomization(name, definition.config);\n return (config === undefined ? definition : { ...definition, config }) as LayerDefinition;\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 */\nexport function loadMajorModesConfig(repoRoot: string, homeDirectory: string = os.homedir()): MajorModesConfig {\n const sources = readDoomConfigSources<ModesDocument>(MODES_FILE, repoRoot, homeDirectory);\n const layers: Record<string, ResolvedLayerDefinition> = {};\n const majorMode: Record<string, string[]> = {};\n for (const source of sources) {\n for (const [name, definition] of Object.entries(source.document.layers ?? {})) {\n layers[name] = { ...parseLayer(name, definition), baseDirectory: source.baseDirectory };\n }\n Object.assign(majorMode, source.document.majorMode ?? {});\n }\n\n for (const [modeName, names] of Object.entries(majorMode)) {\n for (const name of names) {\n if (!layers[name]) {\n throw new Error(`Unknown layer \"${name}\" in majorMode.${modeName} of ${MAJOR_MODES_RELATIVE_PATH}`);\n }\n }\n }\n return { layers, majorMode };\n}\n\n/** Merges selected layer customization in order, with later models winning and exclusions unioned. */\nexport function resolveLayerCustomization(config: MajorModesConfig, names: string[]): LayerCustomizationConfig {\n let subagents: SubagentLayerConfig | undefined;\n const excludeTools = new Set<string>();\n let hasExcludeTools = false;\n for (const name of names) {\n const layer = config.layers[name];\n if (!layer) throw new Error(`Unknown layer: ${name}`);\n const next = layer.config?.subagents;\n if (!next) continue;\n if (next.excludeTools !== undefined) {\n hasExcludeTools = true;\n for (const tool of next.excludeTools) excludeTools.add(tool);\n }\n subagents = {\n ...subagents,\n ...(next.models ? { models: next.models.map((model) => ({ ...model })) } : {}),\n ...(hasExcludeTools ? { excludeTools: [...excludeTools] } : {}),\n };\n }\n return subagents ? { subagents } : {};\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]!];\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 ?? []) entries.push(resolvers.ownEntry(entry));\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 = resolvers.localEntry(specifier, layer.baseDirectory);\n if (resolved) 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 names one.',\n );\n }\n continue;\n }\n if (optional) {\n const resolved = resolvers.optionalPackageEntry(specifier);\n if (resolved) entries.push(resolved);\n continue;\n }\n entries.push(resolvers.packageEntry(specifier));\n }\n return entries;\n}\n\n/** Hook group ids contributed by the selected layers, deduped. */\nexport function layerHookGroups(config: MajorModesConfig, names: string[]): string[] {\n const groups = new Set<string>();\n for (const name of names) {\n for (const group of config.layers[name]?.hookGroups ?? []) groups.add(group);\n }\n return [...groups];\n}\n"],"mappings":"8OA8DA,MAAM,EAAa,aACb,EAA4BA,EAAAA,QAAK,KAAKC,EAAAA,SAAU,CAAU,EAC1D,EAAoB,CAAC,KAAM,KAAK,EAQtC,SAAgB,EAAwB,EAA4B,CAClE,OAAOD,EAAAA,QAAK,WAAW,CAAS,GAAK,EAAkB,KAAM,GAAW,EAAU,WAAW,CAAM,CAAC,CACtG,CACA,MAAM,EAAoB,CAAC,WAAW,EAChC,EAAuB,CAAC,SAAU,cAAc,EAChD,EAAsB,CAAC,QAAS,UAAU,EAC1C,EAAkB,IAAI,IAA2B,CAAC,MAAO,UAAW,MAAO,SAAU,OAAQ,QAAS,KAAK,CAAC,EAElH,SAAS,EAAS,EAAkD,CAClE,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAEA,SAAS,EAAgB,EAAgC,EAAyB,EAAwB,CACxG,IAAM,EAAc,OAAO,KAAK,CAAK,CAAC,CAAC,OAAQ,GAAQ,CAAC,EAAK,SAAS,CAAG,CAAC,EAC1E,GAAI,EAAY,OAAS,EACvB,MAAU,MAAM,GAAG,EAAS,6BAA6B,EAAY,KAAK,IAAI,GAAG,CAErF,CAEA,SAAS,EAAwB,EAAc,EAAsD,CACnG,GAAI,IAAU,IAAA,GAAW,OACzB,IAAM,EAAW,UAAU,EAAK,cAAc,IAC9C,GAAI,CAAC,EAAS,CAAK,EAAG,MAAU,MAAM,GAAG,EAAS,mBAAmB,EAErE,GADA,EAAgB,EAAO,EAAmB,CAAQ,EAC9C,EAAM,YAAc,IAAA,GAAW,MAAO,CAAC,EAC3C,GAAI,CAAC,EAAS,EAAM,SAAS,EAAG,MAAU,MAAM,GAAG,EAAS,6BAA6B,EACzF,EAAgB,EAAM,UAA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Q,KAAK,CAAQ,OAC9B,GAAI,CAAC,EACR,MAAU,MACR,UAAU,EAAK,aAAa,EAAU,2BAA2B,EAAM,cAAc,8EAEvF,EAEF,QACF,CACA,GAAI,EAAU,CACZ,IAAM,EAAW,EAAU,qBAAqB,CAAS,EACrD,GAAU,EAAQ,KAAK,CAAQ,EACnC,QACF,CACA,EAAQ,KAAK,EAAU,aAAa,CAAS,CAAC,CAChD,CACA,OAAO,CACT,CAGA,SAAgB,EAAgB,EAA0B,EAA2B,CACnF,IAAM,EAAS,IAAI,IACnB,IAAK,IAAM,KAAQ,EACjB,IAAK,IAAM,KAAS,EAAO,OAAO,EAAK,EAAE,YAAc,CAAC,EAAG,EAAO,IAAI,CAAK,EAE7E,MAAO,CAAC,GAAG,CAAM,CACnB"}
@@ -0,0 +1,73 @@
1
+ import { PlanningThinkingLevel } from "./types.cjs";
2
+ //#region src/majorModes.d.ts
3
+ interface LayerPackage {
4
+ name: string;
5
+ optional?: boolean;
6
+ }
7
+ interface SubagentLayerModelConfig {
8
+ model: string;
9
+ thinking?: PlanningThinkingLevel;
10
+ }
11
+ interface SubagentLayerConfig {
12
+ models?: SubagentLayerModelConfig[];
13
+ excludeTools?: string[];
14
+ }
15
+ interface LayerCustomizationConfig {
16
+ subagents?: SubagentLayerConfig;
17
+ }
18
+ interface LayerDefinition {
19
+ extensions?: string[];
20
+ /**
21
+ * npm specifiers, or paths relative to the config that declares the layer.
22
+ * A path (`./`, `../`, or absolute) is resolved against the repository root
23
+ * for `.doom/modes.yaml` and against the global `.doom` directory for
24
+ * `~/.pi/.doom/modes.yaml`, which is how an extension that was never
25
+ * published to npm gets loaded.
26
+ */
27
+ packages?: Array<string | LayerPackage>;
28
+ hookGroups?: string[];
29
+ config?: LayerCustomizationConfig;
30
+ }
31
+ /** A layer plus the root its relative package paths resolve against. */
32
+ interface ResolvedLayerDefinition extends LayerDefinition {
33
+ baseDirectory: string;
34
+ }
35
+ interface MajorModesConfig {
36
+ layers: Record<string, ResolvedLayerDefinition>;
37
+ /** Named major modes, each one a set of layer names. */
38
+ majorMode: Record<string, string[]>;
39
+ }
40
+ interface LayerResolvers {
41
+ ownEntry: (name: string) => string;
42
+ packageEntry: (name: string) => string;
43
+ optionalPackageEntry: (name: string) => string | undefined;
44
+ /** Resolves a path-style layer package against the config that declared it. */
45
+ localEntry: (specifier: string, baseDirectory: string) => string | undefined;
46
+ }
47
+ /**
48
+ * Whether a layer package names a path rather than an installed package.
49
+ *
50
+ * The same rule Node applies to import specifiers, so a bare name is always an
51
+ * npm package and a path always looks like one.
52
+ */
53
+ declare function isLocalPackageSpecifier(specifier: string): boolean;
54
+ /**
55
+ * Reads layers and major modes from the global and repository configs.
56
+ *
57
+ * The repository is read last, so it replaces a global layer or major mode of
58
+ * the same name. Layers keep the root they were declared under so that a
59
+ * global layer naming `./extensions/x` still points beside the global config
60
+ * once it is loaded from inside some other repository.
61
+ */
62
+ declare function loadMajorModesConfig(repoRoot: string, homeDirectory?: string): MajorModesConfig;
63
+ /** Merges selected layer customization in order, with later models winning and exclusions unioned. */
64
+ declare function resolveLayerCustomization(config: MajorModesConfig, names: string[]): LayerCustomizationConfig;
65
+ /** Resolves one named major mode into its configured layer components. */
66
+ declare function resolveLayers(config: MajorModesConfig, majorMode: string): string[];
67
+ /** Resolves one layer's extension and package entries to absolute paths. */
68
+ declare function layerEntries(config: MajorModesConfig, name: string, resolvers: LayerResolvers): string[];
69
+ /** Hook group ids contributed by the selected layers, deduped. */
70
+ declare function layerHookGroups(config: MajorModesConfig, names: string[]): string[];
71
+ //#endregion
72
+ export { LayerCustomizationConfig, LayerDefinition, LayerPackage, LayerResolvers, MajorModesConfig, ResolvedLayerDefinition, SubagentLayerConfig, SubagentLayerModelConfig, isLocalPackageSpecifier, layerEntries, layerHookGroups, loadMajorModesConfig, resolveLayerCustomization, resolveLayers };
73
+ //# sourceMappingURL=majorModes.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"majorModes.d.cts","names":[],"sources":["../src/majorModes.ts"],"mappings":";;UAKiB;EACf;EACA;;UAGe;EACf;EACA,WAAW;;UAGI;EACf,SAAS;EACT;;UAGe;EACf,YAAY;;UAGG;EACf;;;;;;;;EAQA,WAAW,eAAe;EAC1B;EACA,SAAS;;;UAIM,gCAAgC;EAC/C;;UAGe;EACf,QAAQ,eAAe;;EAEvB,WAAW;;UAGI;EACf,WAAW;EACX,eAAe;EACf,uBAAuB;;EAEvB,aAAa,mBAAmB;;;;;;;;iBAkBlB,wBAAwB;;;;;;;;;iBAwGxB,qBAAqB,kBAAkB,yBAAuC;;iBAsB9E,0BAA0B,QAAQ,kBAAkB,kBAAkB;;iBAuBtE,cAAc,QAAQ,kBAAkB;;iBAUxC,aAAa,QAAQ,kBAAkB,cAAc,WAAW;;iBA8BhE,gBAAgB,QAAQ,kBAAkB"}
@@ -0,0 +1,73 @@
1
+ import { PlanningThinkingLevel } from "./types.mjs";
2
+ //#region src/majorModes.d.ts
3
+ interface LayerPackage {
4
+ name: string;
5
+ optional?: boolean;
6
+ }
7
+ interface SubagentLayerModelConfig {
8
+ model: string;
9
+ thinking?: PlanningThinkingLevel;
10
+ }
11
+ interface SubagentLayerConfig {
12
+ models?: SubagentLayerModelConfig[];
13
+ excludeTools?: string[];
14
+ }
15
+ interface LayerCustomizationConfig {
16
+ subagents?: SubagentLayerConfig;
17
+ }
18
+ interface LayerDefinition {
19
+ extensions?: string[];
20
+ /**
21
+ * npm specifiers, or paths relative to the config that declares the layer.
22
+ * A path (`./`, `../`, or absolute) is resolved against the repository root
23
+ * for `.doom/modes.yaml` and against the global `.doom` directory for
24
+ * `~/.pi/.doom/modes.yaml`, which is how an extension that was never
25
+ * published to npm gets loaded.
26
+ */
27
+ packages?: Array<string | LayerPackage>;
28
+ hookGroups?: string[];
29
+ config?: LayerCustomizationConfig;
30
+ }
31
+ /** A layer plus the root its relative package paths resolve against. */
32
+ interface ResolvedLayerDefinition extends LayerDefinition {
33
+ baseDirectory: string;
34
+ }
35
+ interface MajorModesConfig {
36
+ layers: Record<string, ResolvedLayerDefinition>;
37
+ /** Named major modes, each one a set of layer names. */
38
+ majorMode: Record<string, string[]>;
39
+ }
40
+ interface LayerResolvers {
41
+ ownEntry: (name: string) => string;
42
+ packageEntry: (name: string) => string;
43
+ optionalPackageEntry: (name: string) => string | undefined;
44
+ /** Resolves a path-style layer package against the config that declared it. */
45
+ localEntry: (specifier: string, baseDirectory: string) => string | undefined;
46
+ }
47
+ /**
48
+ * Whether a layer package names a path rather than an installed package.
49
+ *
50
+ * The same rule Node applies to import specifiers, so a bare name is always an
51
+ * npm package and a path always looks like one.
52
+ */
53
+ declare function isLocalPackageSpecifier(specifier: string): boolean;
54
+ /**
55
+ * Reads layers and major modes from the global and repository configs.
56
+ *
57
+ * The repository is read last, so it replaces a global layer or major mode of
58
+ * the same name. Layers keep the root they were declared under so that a
59
+ * global layer naming `./extensions/x` still points beside the global config
60
+ * once it is loaded from inside some other repository.
61
+ */
62
+ declare function loadMajorModesConfig(repoRoot: string, homeDirectory?: string): MajorModesConfig;
63
+ /** Merges selected layer customization in order, with later models winning and exclusions unioned. */
64
+ declare function resolveLayerCustomization(config: MajorModesConfig, names: string[]): LayerCustomizationConfig;
65
+ /** Resolves one named major mode into its configured layer components. */
66
+ declare function resolveLayers(config: MajorModesConfig, majorMode: string): string[];
67
+ /** Resolves one layer's extension and package entries to absolute paths. */
68
+ declare function layerEntries(config: MajorModesConfig, name: string, resolvers: LayerResolvers): string[];
69
+ /** Hook group ids contributed by the selected layers, deduped. */
70
+ declare function layerHookGroups(config: MajorModesConfig, names: string[]): string[];
71
+ //#endregion
72
+ export { LayerCustomizationConfig, LayerDefinition, LayerPackage, LayerResolvers, MajorModesConfig, ResolvedLayerDefinition, SubagentLayerConfig, SubagentLayerModelConfig, isLocalPackageSpecifier, layerEntries, layerHookGroups, loadMajorModesConfig, resolveLayerCustomization, resolveLayers };
73
+ //# sourceMappingURL=majorModes.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"majorModes.d.mts","names":[],"sources":["../src/majorModes.ts"],"mappings":";;UAKiB;EACf;EACA;;UAGe;EACf;EACA,WAAW;;UAGI;EACf,SAAS;EACT;;UAGe;EACf,YAAY;;UAGG;EACf;;;;;;;;EAQA,WAAW,eAAe;EAC1B;EACA,SAAS;;;UAIM,gCAAgC;EAC/C;;UAGe;EACf,QAAQ,eAAe;;EAEvB,WAAW;;UAGI;EACf,WAAW;EACX,eAAe;EACf,uBAAuB;;EAEvB,aAAa,mBAAmB;;;;;;;;iBAkBlB,wBAAwB;;;;;;;;;iBAwGxB,qBAAqB,kBAAkB,yBAAuC;;iBAsB9E,0BAA0B,QAAQ,kBAAkB,kBAAkB;;iBAuBtE,cAAc,QAAQ,kBAAkB;;iBAUxC,aAAa,QAAQ,kBAAkB,cAAc,WAAW;;iBA8BhE,gBAAgB,QAAQ,kBAAkB"}
@@ -0,0 +1,2 @@
1
+ import{DOOM_DIR as e,readDoomConfigSources as t}from"./layeredConfig.mjs";import n from"node:os";import r from"node:path";const i=`modes.yaml`,a=r.join(e,i),o=[`./`,`../`];function s(e){return r.isAbsolute(e)||o.some(t=>e.startsWith(t))}const c=[`subagents`],l=[`models`,`excludeTools`],u=[`model`,`thinking`],d=new Set([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]);function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e,t,n){let r=Object.keys(e).filter(e=>!t.includes(e));if(r.length>0)throw Error(`${n} has unsupported field(s): ${r.join(`, `)}`)}function m(e,t){if(t===void 0)return;let n=`Layer "${e}" config in ${a}`;if(!f(t))throw Error(`${n} must be a mapping`);if(p(t,c,n),t.subagents===void 0)return{};if(!f(t.subagents))throw Error(`${n}.subagents must be a mapping`);p(t.subagents,l,`${n}.subagents`);let r=Object.hasOwn(t.subagents,`models`),i=Object.hasOwn(t.subagents,`excludeTools`);if(!r&&!i)throw Error(`${n}.subagents must define models or excludeTools`);let o;if(r){if(!Array.isArray(t.subagents.models)||t.subagents.models.length===0)throw Error(`${n}.subagents.models must be a non-empty array`);o=t.subagents.models.map((e,t)=>{let r=`${n}.subagents.models[${t}]`;if(!f(e))throw Error(`${r} must be a mapping`);if(p(e,u,r),typeof e.model!=`string`||!e.model.trim())throw Error(`${r}.model must be a non-empty string`);if(e.thinking!==void 0&&(typeof e.thinking!=`string`||!d.has(e.thinking)))throw Error(`${r}.thinking must be one of: ${[...d].join(`, `)}`);return{model:e.model.trim(),...e.thinking?{thinking:e.thinking}:{}}})}let s;if(i){let e=t.subagents.excludeTools;if(!Array.isArray(e)||e.length===0)throw Error(`${n}.subagents.excludeTools must be a non-empty array`);s=[...new Set(e.map((e,t)=>{let r=`${n}.subagents.excludeTools[${t}]`;if(typeof e!=`string`||!e.trim())throw Error(`${r} must be a non-empty string`);return e.trim()}))]}return{subagents:{...o?{models:o}:{},...s?{excludeTools:s}:{}}}}function h(e,t){if(!f(t))throw Error(`Layer "${e}" in ${a} must be a mapping`);if(`targets`in t)throw Error(`Layer "${e}" in ${a} uses removed field "targets"; select availability through major modes`);let n=m(e,t.config);return n===void 0?t:{...t,config:n}}function g(e,r=n.homedir()){let o=t(i,e,r),s={},c={};for(let e of o){for(let[t,n]of Object.entries(e.document.layers??{}))s[t]={...h(t,n),baseDirectory:e.baseDirectory};Object.assign(c,e.document.majorMode??{})}for(let[e,t]of Object.entries(c))for(let n of t)if(!s[n])throw Error(`Unknown layer "${n}" in majorMode.${e} of ${a}`);return{layers:s,majorMode:c}}function _(e,t){let n,r=new Set,i=!1;for(let a of t){let t=e.layers[a];if(!t)throw Error(`Unknown layer: ${a}`);let o=t.config?.subagents;if(o){if(o.excludeTools!==void 0){i=!0;for(let e of o.excludeTools)r.add(e)}n={...n,...o.models?{models:o.models.map(e=>({...e}))}:{},...i?{excludeTools:[...r]}:{}}}}return n?{subagents:n}:{}}function v(e,t){if(!Object.hasOwn(e.majorMode,t))throw Error(`Unknown major mode: ${t}. Known major modes: ${Object.keys(e.majorMode).sort().join(`, `)}`);return[...e.majorMode[t]]}function y(e,t,n){let r=e.layers[t];if(!r)throw Error(`Unknown layer: ${t}`);let i=[];for(let e of r.extensions??[])i.push(n.ownEntry(e));for(let e of r.packages??[]){let a=typeof e==`string`?e:e.name,o=typeof e!=`string`&&e.optional===!0;if(s(a)){let e=n.localEntry(a,r.baseDirectory);if(e)i.push(e);else if(!o)throw Error(`Layer "${t}" package "${a}" does not resolve under ${r.baseDirectory}. Point it at an extension file, or a directory whose package.json names one.`);continue}if(o){let e=n.optionalPackageEntry(a);e&&i.push(e);continue}i.push(n.packageEntry(a))}return i}function b(e,t){let n=new Set;for(let r of t)for(let t of e.layers[r]?.hookGroups??[])n.add(t);return[...n]}export{s as isLocalPackageSpecifier,y as layerEntries,b as layerHookGroups,g as loadMajorModesConfig,_ as resolveLayerCustomization,v as resolveLayers};
2
+ //# sourceMappingURL=majorModes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"majorModes.mjs","names":[],"sources":["../src/majorModes.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport { DOOM_DIR, readDoomConfigSources } from './layeredConfig.ts';\nimport type { PlanningThinkingLevel } from './types.ts';\n\nexport interface LayerPackage {\n name: string;\n optional?: boolean;\n}\n\nexport interface SubagentLayerModelConfig {\n model: string;\n thinking?: PlanningThinkingLevel;\n}\n\nexport interface SubagentLayerConfig {\n models?: SubagentLayerModelConfig[];\n excludeTools?: string[];\n}\n\nexport interface LayerCustomizationConfig {\n subagents?: SubagentLayerConfig;\n}\n\nexport interface LayerDefinition {\n extensions?: string[];\n /**\n * npm specifiers, or paths relative to the config that declares the layer.\n * A path (`./`, `../`, or absolute) is resolved against the repository root\n * for `.doom/modes.yaml` and against the global `.doom` directory for\n * `~/.pi/.doom/modes.yaml`, which is how an extension that was never\n * published to npm gets loaded.\n */\n packages?: Array<string | LayerPackage>;\n hookGroups?: string[];\n config?: LayerCustomizationConfig;\n}\n\n/** A layer plus the root its relative package paths resolve against. */\nexport interface ResolvedLayerDefinition extends LayerDefinition {\n baseDirectory: string;\n}\n\nexport interface MajorModesConfig {\n layers: Record<string, ResolvedLayerDefinition>;\n /** Named major modes, each one a set of layer names. */\n majorMode: Record<string, string[]>;\n}\n\nexport interface LayerResolvers {\n ownEntry: (name: string) => string;\n packageEntry: (name: string) => string;\n optionalPackageEntry: (name: string) => string | undefined;\n /** Resolves a path-style layer package against the config that declared it. */\n localEntry: (specifier: string, baseDirectory: string) => string | undefined;\n}\n\ninterface ModesDocument {\n layers?: Record<string, unknown>;\n majorMode?: Record<string, string[]>;\n}\n\nconst MODES_FILE = 'modes.yaml';\nconst MAJOR_MODES_RELATIVE_PATH = path.join(DOOM_DIR, MODES_FILE);\nconst RELATIVE_PREFIXES = ['./', '../'] as const;\n\n/**\n * Whether a layer package names a path rather than an installed package.\n *\n * The same rule Node applies to import specifiers, so a bare name is always an\n * npm package 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_CONFIG_KEYS = ['subagents'] as const;\nconst SUBAGENT_CONFIG_KEYS = ['models', 'excludeTools'] as const;\nconst SUBAGENT_MODEL_KEYS = ['model', 'thinking'] as const;\nconst THINKING_VALUES = new Set<PlanningThinkingLevel>(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\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) {\n throw new Error(`${location} has unsupported field(s): ${unsupported.join(', ')}`);\n }\n}\n\nfunction parseLayerCustomization(name: string, value: unknown): LayerCustomizationConfig | undefined {\n if (value === undefined) return undefined;\n const location = `Layer \"${name}\" config in ${MAJOR_MODES_RELATIVE_PATH}`;\n if (!isRecord(value)) throw new Error(`${location} must be a mapping`);\n assertKnownKeys(value, LAYER_CONFIG_KEYS, location);\n if (value.subagents === undefined) return {};\n if (!isRecord(value.subagents)) throw new Error(`${location}.subagents must be a mapping`);\n assertKnownKeys(value.subagents, SUBAGENT_CONFIG_KEYS, `${location}.subagents`);\n const hasModels = Object.hasOwn(value.subagents, 'models');\n const hasExcludeTools = Object.hasOwn(value.subagents, 'excludeTools');\n if (!hasModels && !hasExcludeTools) {\n throw new Error(`${location}.subagents must define models or excludeTools`);\n }\n\n let models: SubagentLayerModelConfig[] | undefined;\n if (hasModels) {\n if (!Array.isArray(value.subagents.models) || value.subagents.models.length === 0) {\n throw new Error(`${location}.subagents.models must be a non-empty array`);\n }\n models = value.subagents.models.map((entry, index): SubagentLayerModelConfig => {\n const entryLocation = `${location}.subagents.models[${index}]`;\n if (!isRecord(entry)) throw new Error(`${entryLocation} must be a mapping`);\n assertKnownKeys(entry, SUBAGENT_MODEL_KEYS, entryLocation);\n if (typeof entry.model !== 'string' || !entry.model.trim()) {\n throw new Error(`${entryLocation}.model must be a non-empty string`);\n }\n if (\n entry.thinking !== undefined &&\n (typeof entry.thinking !== 'string' || !THINKING_VALUES.has(entry.thinking as PlanningThinkingLevel))\n ) {\n throw new Error(`${entryLocation}.thinking must be one of: ${[...THINKING_VALUES].join(', ')}`);\n }\n return {\n model: entry.model.trim(),\n ...(entry.thinking ? { thinking: entry.thinking as PlanningThinkingLevel } : {}),\n };\n });\n }\n\n let normalizedExcludeTools: string[] | undefined;\n if (hasExcludeTools) {\n const excludeTools = value.subagents.excludeTools;\n if (!Array.isArray(excludeTools) || excludeTools.length === 0) {\n throw new Error(`${location}.subagents.excludeTools must be a non-empty array`);\n }\n normalizedExcludeTools = [\n ...new Set(\n excludeTools.map((entry, index) => {\n const entryLocation = `${location}.subagents.excludeTools[${index}]`;\n if (typeof entry !== 'string' || !entry.trim()) {\n throw new Error(`${entryLocation} must be a non-empty string`);\n }\n return entry.trim();\n }),\n ),\n ];\n }\n\n return {\n subagents: {\n ...(models ? { models } : {}),\n ...(normalizedExcludeTools ? { excludeTools: normalizedExcludeTools } : {}),\n },\n };\n}\n\nfunction 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 const config = parseLayerCustomization(name, definition.config);\n return (config === undefined ? definition : { ...definition, config }) as LayerDefinition;\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 */\nexport function loadMajorModesConfig(repoRoot: string, homeDirectory: string = os.homedir()): MajorModesConfig {\n const sources = readDoomConfigSources<ModesDocument>(MODES_FILE, repoRoot, homeDirectory);\n const layers: Record<string, ResolvedLayerDefinition> = {};\n const majorMode: Record<string, string[]> = {};\n for (const source of sources) {\n for (const [name, definition] of Object.entries(source.document.layers ?? {})) {\n layers[name] = { ...parseLayer(name, definition), baseDirectory: source.baseDirectory };\n }\n Object.assign(majorMode, source.document.majorMode ?? {});\n }\n\n for (const [modeName, names] of Object.entries(majorMode)) {\n for (const name of names) {\n if (!layers[name]) {\n throw new Error(`Unknown layer \"${name}\" in majorMode.${modeName} of ${MAJOR_MODES_RELATIVE_PATH}`);\n }\n }\n }\n return { layers, majorMode };\n}\n\n/** Merges selected layer customization in order, with later models winning and exclusions unioned. */\nexport function resolveLayerCustomization(config: MajorModesConfig, names: string[]): LayerCustomizationConfig {\n let subagents: SubagentLayerConfig | undefined;\n const excludeTools = new Set<string>();\n let hasExcludeTools = false;\n for (const name of names) {\n const layer = config.layers[name];\n if (!layer) throw new Error(`Unknown layer: ${name}`);\n const next = layer.config?.subagents;\n if (!next) continue;\n if (next.excludeTools !== undefined) {\n hasExcludeTools = true;\n for (const tool of next.excludeTools) excludeTools.add(tool);\n }\n subagents = {\n ...subagents,\n ...(next.models ? { models: next.models.map((model) => ({ ...model })) } : {}),\n ...(hasExcludeTools ? { excludeTools: [...excludeTools] } : {}),\n };\n }\n return subagents ? { subagents } : {};\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]!];\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 ?? []) entries.push(resolvers.ownEntry(entry));\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 = resolvers.localEntry(specifier, layer.baseDirectory);\n if (resolved) 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 names one.',\n );\n }\n continue;\n }\n if (optional) {\n const resolved = resolvers.optionalPackageEntry(specifier);\n if (resolved) entries.push(resolved);\n continue;\n }\n entries.push(resolvers.packageEntry(specifier));\n }\n return entries;\n}\n\n/** Hook group ids contributed by the selected layers, deduped. */\nexport function layerHookGroups(config: MajorModesConfig, names: string[]): string[] {\n const groups = new Set<string>();\n for (const name of names) {\n for (const group of config.layers[name]?.hookGroups ?? []) groups.add(group);\n }\n return [...groups];\n}\n"],"mappings":"0HA8DA,MAAM,EAAa,aACb,EAA4B,EAAK,KAAK,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