@agimon-ai/po-config 0.0.0-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 (170) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +170 -0
  3. package/dist/agentPluginMcp.cjs +322 -0
  4. package/dist/agentPluginMcp.cjs.map +1 -0
  5. package/dist/agentPluginMcp.d.mts +38 -0
  6. package/dist/agentPluginMcp.d.mts.map +1 -0
  7. package/dist/agentPluginMcp.mjs +318 -0
  8. package/dist/agentPluginMcp.mjs.map +1 -0
  9. package/dist/apiContracts.cjs +203 -0
  10. package/dist/apiContracts.cjs.map +1 -0
  11. package/dist/apiContracts.d.mts +53 -0
  12. package/dist/apiContracts.d.mts.map +1 -0
  13. package/dist/apiContracts.mjs +198 -0
  14. package/dist/apiContracts.mjs.map +1 -0
  15. package/dist/atomicJson-1W0WhuFF.mjs +44 -0
  16. package/dist/atomicJson-1W0WhuFF.mjs.map +1 -0
  17. package/dist/atomicJson-Dt2z_DXl.cjs +52 -0
  18. package/dist/atomicJson-Dt2z_DXl.cjs.map +1 -0
  19. package/dist/atomicJson.cjs +3 -0
  20. package/dist/atomicJson.d.mts +2 -0
  21. package/dist/atomicJson.mjs +2 -0
  22. package/dist/config-BUw5kHsx.cjs +219 -0
  23. package/dist/config-BUw5kHsx.cjs.map +1 -0
  24. package/dist/config-CKA07FxG.mjs +162 -0
  25. package/dist/config-CKA07FxG.mjs.map +1 -0
  26. package/dist/config-Cm3EV1jp.d.mts +320 -0
  27. package/dist/config-Cm3EV1jp.d.mts.map +1 -0
  28. package/dist/config-NSHRd6na.mjs +2 -0
  29. package/dist/config-zZz80Mh5.cjs +1 -0
  30. package/dist/config.cjs +24 -0
  31. package/dist/config.d.mts +3 -0
  32. package/dist/config.mjs +3 -0
  33. package/dist/configPolicy--TNX7feH.mjs +718 -0
  34. package/dist/configPolicy--TNX7feH.mjs.map +1 -0
  35. package/dist/configPolicy-DmsZEp0t.cjs +795 -0
  36. package/dist/configPolicy-DmsZEp0t.cjs.map +1 -0
  37. package/dist/configSchema.cjs +0 -0
  38. package/dist/configSchema.d.mts +2 -0
  39. package/dist/configSchema.mjs +1 -0
  40. package/dist/configWriter-BTuinLjs.cjs +150 -0
  41. package/dist/configWriter-BTuinLjs.cjs.map +1 -0
  42. package/dist/configWriter-BgkGaLrf.mjs +130 -0
  43. package/dist/configWriter-BgkGaLrf.mjs.map +1 -0
  44. package/dist/configWriter.cjs +5 -0
  45. package/dist/configWriter.d.mts +2 -0
  46. package/dist/configWriter.mjs +2 -0
  47. package/dist/domains-CBYkuxs5.cjs +727 -0
  48. package/dist/domains-CBYkuxs5.cjs.map +1 -0
  49. package/dist/domains-DZOu9vYM.mjs +633 -0
  50. package/dist/domains-DZOu9vYM.mjs.map +1 -0
  51. package/dist/domains.cjs +19 -0
  52. package/dist/domains.d.mts +3 -0
  53. package/dist/domains.mjs +3 -0
  54. package/dist/extensions/mcp-ui.mjs +101 -0
  55. package/dist/extensions/mcp-ui.mjs.map +1 -0
  56. package/dist/extensions/mcp.cjs +171 -0
  57. package/dist/extensions/mcp.cjs.map +1 -0
  58. package/dist/extensions/mcp.d.mts +5 -0
  59. package/dist/extensions/mcp.d.mts.map +1 -0
  60. package/dist/extensions/mcp.mjs +166 -0
  61. package/dist/extensions/mcp.mjs.map +1 -0
  62. package/dist/extensions/server.cjs +504 -0
  63. package/dist/extensions/server.cjs.map +1 -0
  64. package/dist/extensions/server.d.mts +5 -0
  65. package/dist/extensions/server.d.mts.map +1 -0
  66. package/dist/extensions/server.mjs +499 -0
  67. package/dist/extensions/server.mjs.map +1 -0
  68. package/dist/harnessState-CCyBeutB.cjs +188 -0
  69. package/dist/harnessState-CCyBeutB.cjs.map +1 -0
  70. package/dist/harnessState-Dn_S7fB9.mjs +163 -0
  71. package/dist/harnessState-Dn_S7fB9.mjs.map +1 -0
  72. package/dist/harnessState.cjs +6 -0
  73. package/dist/harnessState.d.mts +2 -0
  74. package/dist/harnessState.mjs +2 -0
  75. package/dist/harnessStore-CJSxdSkV.cjs +343 -0
  76. package/dist/harnessStore-CJSxdSkV.cjs.map +1 -0
  77. package/dist/harnessStore-CltwLB7M.mjs +262 -0
  78. package/dist/harnessStore-CltwLB7M.mjs.map +1 -0
  79. package/dist/harnessStore.cjs +15 -0
  80. package/dist/harnessStore.d.mts +2 -0
  81. package/dist/harnessStore.mjs +2 -0
  82. package/dist/index-BAaTySaM.d.mts +35 -0
  83. package/dist/index-BAaTySaM.d.mts.map +1 -0
  84. package/dist/index-BT29GZx5.d.mts +142 -0
  85. package/dist/index-BT29GZx5.d.mts.map +1 -0
  86. package/dist/index-B_lp0W3U.d.mts +114 -0
  87. package/dist/index-B_lp0W3U.d.mts.map +1 -0
  88. package/dist/index-C6GaYjq-.d.mts +6 -0
  89. package/dist/index-C6GaYjq-.d.mts.map +1 -0
  90. package/dist/index-CIQrKS1A.d.mts +50 -0
  91. package/dist/index-CIQrKS1A.d.mts.map +1 -0
  92. package/dist/index-CRcoVYXz.d.mts +39 -0
  93. package/dist/index-CRcoVYXz.d.mts.map +1 -0
  94. package/dist/index-CVlciCJF.d.mts +40 -0
  95. package/dist/index-CVlciCJF.d.mts.map +1 -0
  96. package/dist/index-CeOk2kqs.d.mts +118 -0
  97. package/dist/index-CeOk2kqs.d.mts.map +1 -0
  98. package/dist/index-Ch7ptOkW.d.mts +54 -0
  99. package/dist/index-Ch7ptOkW.d.mts.map +1 -0
  100. package/dist/index-Cvdt-Y-i.d.mts +66 -0
  101. package/dist/index-Cvdt-Y-i.d.mts.map +1 -0
  102. package/dist/index-DJpG-I9K.d.mts +122 -0
  103. package/dist/index-DJpG-I9K.d.mts.map +1 -0
  104. package/dist/index-DNk4q0Qm.d.mts +81 -0
  105. package/dist/index-DNk4q0Qm.d.mts.map +1 -0
  106. package/dist/index.cjs +121 -0
  107. package/dist/index.d.mts +15 -0
  108. package/dist/index.mjs +15 -0
  109. package/dist/init-C_9nyp3-.cjs +448 -0
  110. package/dist/init-C_9nyp3-.cjs.map +1 -0
  111. package/dist/init-DJ6wm-dr.mjs +415 -0
  112. package/dist/init-DJ6wm-dr.mjs.map +1 -0
  113. package/dist/init.cjs +7 -0
  114. package/dist/init.d.mts +2 -0
  115. package/dist/init.mjs +2 -0
  116. package/dist/layeredConfig-B922ibgn.mjs +67 -0
  117. package/dist/layeredConfig-B922ibgn.mjs.map +1 -0
  118. package/dist/layeredConfig-DdI5ysUf.cjs +94 -0
  119. package/dist/layeredConfig-DdI5ysUf.cjs.map +1 -0
  120. package/dist/layeredConfig.cjs +6 -0
  121. package/dist/layeredConfig.d.mts +2 -0
  122. package/dist/layeredConfig.mjs +2 -0
  123. package/dist/majorModes-CmPLEpMT.mjs +333 -0
  124. package/dist/majorModes-CmPLEpMT.mjs.map +1 -0
  125. package/dist/majorModes-DPhVMuhT.cjs +383 -0
  126. package/dist/majorModes-DPhVMuhT.cjs.map +1 -0
  127. package/dist/majorModes.cjs +10 -0
  128. package/dist/majorModes.d.mts +2 -0
  129. package/dist/majorModes.mjs +2 -0
  130. package/dist/piConfig-Bx26HMb_.d.mts +33 -0
  131. package/dist/piConfig-Bx26HMb_.d.mts.map +1 -0
  132. package/dist/piConfig-CCBdZXQr.cjs +260 -0
  133. package/dist/piConfig-CCBdZXQr.cjs.map +1 -0
  134. package/dist/piConfig-qGyCbcVj.mjs +197 -0
  135. package/dist/piConfig-qGyCbcVj.mjs.map +1 -0
  136. package/dist/piConfig.cjs +12 -0
  137. package/dist/piConfig.d.mts +2 -0
  138. package/dist/piConfig.mjs +2 -0
  139. package/dist/piContext.cjs +18 -0
  140. package/dist/piContext.d.mts +3 -0
  141. package/dist/piContext.mjs +2 -0
  142. package/dist/profiles-CTrUCmIh.d.mts +27 -0
  143. package/dist/profiles-CTrUCmIh.d.mts.map +1 -0
  144. package/dist/profiles-DnF9DBpd.cjs +552 -0
  145. package/dist/profiles-DnF9DBpd.cjs.map +1 -0
  146. package/dist/profiles-fujQKrS0.mjs +483 -0
  147. package/dist/profiles-fujQKrS0.mjs.map +1 -0
  148. package/dist/profiles.cjs +13 -0
  149. package/dist/profiles.d.mts +25 -0
  150. package/dist/profiles.d.mts.map +1 -0
  151. package/dist/profiles.mjs +2 -0
  152. package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
  153. package/dist/selectionSwitch.cjs +70 -0
  154. package/dist/selectionSwitch.cjs.map +1 -0
  155. package/dist/selectionSwitch.d.mts +30 -0
  156. package/dist/selectionSwitch.d.mts.map +1 -0
  157. package/dist/selectionSwitch.mjs +64 -0
  158. package/dist/selectionSwitch.mjs.map +1 -0
  159. package/dist/sessionConfig-Boh4Fdje.cjs +342 -0
  160. package/dist/sessionConfig-Boh4Fdje.cjs.map +1 -0
  161. package/dist/sessionConfig-CtLoc-lO.mjs +240 -0
  162. package/dist/sessionConfig-CtLoc-lO.mjs.map +1 -0
  163. package/dist/types.cjs +9 -0
  164. package/dist/types.d.mts +2 -0
  165. package/dist/types.mjs +2 -0
  166. package/llms.txt +12 -0
  167. package/package.json +206 -0
  168. package/src/prompts/po-author-config/SKILL.md +26 -0
  169. package/src/prompts/po-author-config/agents/openai.yaml +4 -0
  170. package/src/prompts/po-author-config/references/config-contract.md +201 -0
@@ -0,0 +1,727 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
2
+ const require_config = require("./config-BUw5kHsx.cjs");
3
+ const require_layeredConfig = require("./layeredConfig-DdI5ysUf.cjs");
4
+ let node_crypto = require("node:crypto");
5
+ node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
6
+ let node_fs = require("node:fs");
7
+ node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
8
+ let node_path = require("node:path");
9
+ node_path = require_rolldown_runtime.__toESM(node_path, 1);
10
+ let node_os = require("node:os");
11
+ node_os = require_rolldown_runtime.__toESM(node_os, 1);
12
+ //#region src/services/pluginCatalog/index.ts
13
+ const AGENT_PLUGIN_SCHEMA_PREFIX = "https://agent-plugins.org/schemas/";
14
+ const CACHE_DIRECTORY = "plugin-cache";
15
+ const PLUGIN_ID_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
16
+ const NPM_PACKAGE_NAME = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
17
+ const LEGACY_PLUGIN_MANIFEST_PATHS = [
18
+ ".codex-plugin/plugin.json",
19
+ ".claude-plugin/plugin.json",
20
+ ".cursor-plugin/plugin.json"
21
+ ];
22
+ const MARKETPLACE_MANIFEST_RELATIVE_PATHS = [
23
+ ".agents/plugins/marketplace.json",
24
+ ".agents/plugins/api_marketplace.json",
25
+ ".claude-plugin/marketplace.json",
26
+ ".cursor-plugin/marketplace.json"
27
+ ];
28
+ function isRecord$1(value) {
29
+ return typeof value === "object" && value !== null && !Array.isArray(value);
30
+ }
31
+ function requireRecord$1(value, label) {
32
+ if (!isRecord$1(value)) throw new Error(`${label} must be an object`);
33
+ return value;
34
+ }
35
+ function optionalString$1(value, label) {
36
+ if (value === void 0) return void 0;
37
+ if (typeof value !== "string" || !value.trim()) throw new Error(`${label} must be a non-empty string`);
38
+ return value.trim();
39
+ }
40
+ function requireString$1(value, label) {
41
+ const result = optionalString$1(value, label);
42
+ if (!result) throw new Error(`${label} must be a non-empty string`);
43
+ return result;
44
+ }
45
+ function assertOnlyKeys$1(record, allowed, label) {
46
+ const unexpected = Object.keys(record).filter((key) => !allowed.includes(key));
47
+ if (unexpected.length > 0) throw new Error(`${label} contains unsupported field "${unexpected[0]}"`);
48
+ }
49
+ function validatePluginIdSegment(value, label) {
50
+ if (!PLUGIN_ID_SEGMENT.test(value)) throw new Error(`${label} must start with an alphanumeric character and contain only alphanumerics, ., _, or -`);
51
+ }
52
+ function validatePluginId(value, label) {
53
+ const segments = value.split("@");
54
+ if (segments.length > 2 || segments.some((segment) => !PLUGIN_ID_SEGMENT.test(segment))) throw new Error(`${label} must be a plugin name or plugin@marketplace identifier`);
55
+ }
56
+ function normalizeRemoteSubdirectory(value, label) {
57
+ const raw = optionalString$1(value, label);
58
+ if (!raw) return void 0;
59
+ const normalized = raw.replaceAll("\\", "/").replace(/^\.\//, "");
60
+ if (normalized.startsWith("/") || normalized.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) throw new Error(`${label} must stay within the remote repository root`);
61
+ return normalized;
62
+ }
63
+ function normalizeGitUrl(value, baseDirectory, label) {
64
+ const url = requireString$1(value, label);
65
+ if (/^(?:https?|ssh|file):\/\//.test(url) || /^git@[^:]+:.+/.test(url) || node_path.default.isAbsolute(url)) return url;
66
+ if (url.startsWith("./") || url.startsWith(".\\")) {
67
+ const relative = url.replaceAll("\\", "/").slice(2);
68
+ if (!relative || relative.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) throw new Error(`${label} must stay within its declaring root`);
69
+ return node_path.default.resolve(baseDirectory, relative);
70
+ }
71
+ if (/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:\.git)?$/.test(url)) return `https://github.com/${url.endsWith(".git") ? url : `${url}.git`}`;
72
+ throw new Error(`${label} is not a supported Git URL`);
73
+ }
74
+ function resolveMarketplaceLocalPath(rawPath, marketplace, label) {
75
+ if (rawPath === "." || rawPath === "./") return marketplace.root;
76
+ const cursorMarketplace = marketplace.manifestPath.endsWith(".cursor-plugin/marketplace.json");
77
+ const relative = rawPath.startsWith("./") ? rawPath.slice(2) : cursorMarketplace ? rawPath : void 0;
78
+ if (!relative) throw new Error(`${label} must start with ./`);
79
+ const normalized = relative.replaceAll("\\", "/");
80
+ if (normalized.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) throw new Error(`${label} must stay within the marketplace root`);
81
+ return node_path.default.resolve(marketplace.root, normalized);
82
+ }
83
+ function parseSourceObject(value, baseDirectory, label, marketplace) {
84
+ const sourceType = requireString$1(value.source, `${label}.source`);
85
+ if (sourceType === "local") {
86
+ assertOnlyKeys$1(value, [
87
+ "source",
88
+ "path",
89
+ "description"
90
+ ], label);
91
+ const rawPath = requireString$1(value.path, `${label}.path`);
92
+ return {
93
+ type: "local",
94
+ path: marketplace ? resolveMarketplaceLocalPath(rawPath, marketplace, `${label}.path`) : node_path.default.resolve(baseDirectory, rawPath)
95
+ };
96
+ }
97
+ if (sourceType === "url" || sourceType === "git-subdir") {
98
+ assertOnlyKeys$1(value, [
99
+ "source",
100
+ "url",
101
+ "path",
102
+ "ref",
103
+ "sha",
104
+ "description"
105
+ ], label);
106
+ const remotePath = normalizeRemoteSubdirectory(value.path, `${label}.path`);
107
+ if (sourceType === "git-subdir" && !remotePath) throw new Error(`${label}.path must be a non-empty string for git-subdir sources`);
108
+ const ref = optionalString$1(value.ref, `${label}.ref`);
109
+ const sha = optionalString$1(value.sha, `${label}.sha`);
110
+ return {
111
+ type: "git",
112
+ url: normalizeGitUrl(value.url, marketplace?.root ?? baseDirectory, `${label}.url`),
113
+ ...remotePath ? { path: remotePath } : {},
114
+ ...ref ? { ref } : {},
115
+ ...sha ? { sha } : {}
116
+ };
117
+ }
118
+ if (sourceType === "npm") {
119
+ assertOnlyKeys$1(value, [
120
+ "source",
121
+ "package",
122
+ "version",
123
+ "registry",
124
+ "description"
125
+ ], label);
126
+ const packageName = requireString$1(value.package, `${label}.package`);
127
+ if (!NPM_PACKAGE_NAME.test(packageName)) throw new Error(`${label}.package must be a valid npm package name`);
128
+ const version = optionalString$1(value.version, `${label}.version`);
129
+ const registry = optionalString$1(value.registry, `${label}.registry`);
130
+ return {
131
+ type: "npm",
132
+ package: packageName,
133
+ ...version ? { version } : {},
134
+ ...registry ? { registry } : {}
135
+ };
136
+ }
137
+ throw new Error(`${label}.source must be local, url, git-subdir, or npm`);
138
+ }
139
+ function parsePluginSource(value, baseDirectory, label, marketplace) {
140
+ if (typeof value === "string") {
141
+ const rawPath = requireString$1(value, label);
142
+ return {
143
+ type: "local",
144
+ path: marketplace ? resolveMarketplaceLocalPath(rawPath, marketplace, label) : node_path.default.resolve(baseDirectory, rawPath)
145
+ };
146
+ }
147
+ return parseSourceObject(requireRecord$1(value, label), baseDirectory, label, marketplace);
148
+ }
149
+ function parseConfiguredEntry(value, baseDirectory, label) {
150
+ if (typeof value === "string") return { source: parsePluginSource(value, baseDirectory, label) };
151
+ const record = requireRecord$1(value, label);
152
+ const description = optionalString$1(record.description, `${label}.description`);
153
+ if (record.source === void 0 && typeof record.path === "string") {
154
+ assertOnlyKeys$1(record, ["path", "description"], label);
155
+ return {
156
+ source: {
157
+ type: "local",
158
+ path: node_path.default.resolve(baseDirectory, requireString$1(record.path, `${label}.path`))
159
+ },
160
+ ...description ? { description } : {}
161
+ };
162
+ }
163
+ if (typeof record.source === "string" && ![
164
+ "local",
165
+ "url",
166
+ "git-subdir",
167
+ "npm"
168
+ ].includes(record.source)) {
169
+ assertOnlyKeys$1(record, ["source", "description"], label);
170
+ return {
171
+ source: parsePluginSource(record.source, baseDirectory, `${label}.source`),
172
+ ...description ? { description } : {}
173
+ };
174
+ }
175
+ if (isRecord$1(record.source)) {
176
+ assertOnlyKeys$1(record, ["source", "description"], label);
177
+ return {
178
+ source: parsePluginSource(record.source, baseDirectory, `${label}.source`),
179
+ ...description ? { description } : {}
180
+ };
181
+ }
182
+ return {
183
+ source: parseSourceObject(record, baseDirectory, label),
184
+ ...description ? { description } : {}
185
+ };
186
+ }
187
+ function marketplaceRootFromManifest(manifestPath) {
188
+ const normalized = node_path.default.resolve(manifestPath);
189
+ for (const relativePath of MARKETPLACE_MANIFEST_RELATIVE_PATHS) {
190
+ const suffix = node_path.default.normalize(relativePath);
191
+ if (!normalized.endsWith(suffix)) continue;
192
+ let root = normalized;
193
+ for (const _segment of relativePath.split("/")) root = node_path.default.dirname(root);
194
+ return root;
195
+ }
196
+ }
197
+ function findMarketplace(rootOrManifest) {
198
+ if (node_fs.default.existsSync(rootOrManifest) && node_fs.default.statSync(rootOrManifest).isFile()) {
199
+ const root = marketplaceRootFromManifest(rootOrManifest);
200
+ return root ? {
201
+ manifestPath: node_path.default.resolve(rootOrManifest),
202
+ root
203
+ } : void 0;
204
+ }
205
+ for (const relativePath of MARKETPLACE_MANIFEST_RELATIVE_PATHS) {
206
+ const manifestPath = node_path.default.join(rootOrManifest, relativePath);
207
+ if (node_fs.default.existsSync(manifestPath) && node_fs.default.statSync(manifestPath).isFile()) return {
208
+ manifestPath: node_path.default.resolve(manifestPath),
209
+ root: node_path.default.resolve(rootOrManifest)
210
+ };
211
+ }
212
+ }
213
+ function readJsonRecord(filePath, label) {
214
+ let parsed;
215
+ try {
216
+ parsed = JSON.parse(node_fs.default.readFileSync(filePath, "utf8"));
217
+ } catch (error) {
218
+ throw new Error(`${label} at ${filePath} is invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
219
+ }
220
+ return requireRecord$1(parsed, `${label} at ${filePath}`);
221
+ }
222
+ /** Matches Codex manifest precedence, including schema-gated root plugin.json. */
223
+ function findPluginManifestPath(pluginRoot) {
224
+ const rootManifest = node_path.default.join(pluginRoot, "plugin.json");
225
+ try {
226
+ const metadata = node_fs.default.lstatSync(rootManifest);
227
+ if (metadata.isSymbolicLink() || !metadata.isFile()) return void 0;
228
+ const parsed = JSON.parse(node_fs.default.readFileSync(rootManifest, "utf8"));
229
+ if ((isRecord$1(parsed) && typeof parsed.$schema === "string" ? parsed.$schema : void 0)?.startsWith(AGENT_PLUGIN_SCHEMA_PREFIX)) return rootManifest;
230
+ } catch {}
231
+ return LEGACY_PLUGIN_MANIFEST_PATHS.map((relativePath) => node_path.default.join(pluginRoot, relativePath)).find((manifestPath) => node_fs.default.existsSync(manifestPath) && node_fs.default.statSync(manifestPath).isFile());
232
+ }
233
+ function readPluginManifestMetadata(pluginRoot, diagnostics) {
234
+ const manifestPath = findPluginManifestPath(pluginRoot);
235
+ if (!manifestPath) return void 0;
236
+ try {
237
+ const manifest = readJsonRecord(manifestPath, "Plugin manifest");
238
+ const schema = optionalString$1(manifest.$schema, `${manifestPath}.$schema`);
239
+ const name = optionalString$1(manifest.name, `${manifestPath}.name`);
240
+ const version = optionalString$1(manifest.version, `${manifestPath}.version`);
241
+ const description = optionalString$1(manifest.description, `${manifestPath}.description`);
242
+ return {
243
+ path: manifestPath,
244
+ ...name ? { name } : {},
245
+ ...version ? { version } : {},
246
+ ...description ? { description } : {},
247
+ ...schema?.startsWith(AGENT_PLUGIN_SCHEMA_PREFIX) ? { agentPluginSchema: schema } : {}
248
+ };
249
+ } catch (error) {
250
+ diagnostics.push(error instanceof Error ? error.message : String(error));
251
+ return { path: manifestPath };
252
+ }
253
+ }
254
+ function discoverPluginRoot(pluginRoot, entries, diagnostics) {
255
+ const diagnosticCount = diagnostics.length;
256
+ const manifest = readPluginManifestMetadata(pluginRoot, diagnostics);
257
+ if (!manifest || diagnostics.length !== diagnosticCount) return false;
258
+ const name = manifest.name ?? node_path.default.basename(pluginRoot);
259
+ try {
260
+ validatePluginIdSegment(name, `Plugin name in ${manifest.path}`);
261
+ } catch (error) {
262
+ diagnostics.push(error instanceof Error ? error.message : String(error));
263
+ return false;
264
+ }
265
+ entries[name] = {
266
+ source: {
267
+ type: "local",
268
+ path: pluginRoot
269
+ },
270
+ ...manifest.description ? { description: manifest.description } : {},
271
+ manifest
272
+ };
273
+ return true;
274
+ }
275
+ function discoverPluginFolder(root, entries, diagnostics) {
276
+ if (!node_fs.default.existsSync(root) || !node_fs.default.statSync(root).isDirectory()) return 0;
277
+ if (findPluginManifestPath(root)) return discoverPluginRoot(root, entries, diagnostics) ? 1 : 0;
278
+ let discovered = 0;
279
+ const children = node_fs.default.readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((left, right) => left.name.localeCompare(right.name));
280
+ for (const child of children) if (discoverPluginRoot(node_path.default.join(root, child.name), entries, diagnostics)) discovered += 1;
281
+ return discovered;
282
+ }
283
+ function parseMarketplace(marketplace, entries, diagnostics) {
284
+ const document = readJsonRecord(marketplace.manifestPath, "Marketplace manifest");
285
+ const marketplaceName = requireString$1(document.name, `${marketplace.manifestPath}.name`);
286
+ validatePluginIdSegment(marketplaceName, `${marketplace.manifestPath}.name`);
287
+ if (!Array.isArray(document.plugins)) throw new Error(`${marketplace.manifestPath}.plugins must be an array`);
288
+ for (let index = 0; index < document.plugins.length; index += 1) {
289
+ const label = `${marketplace.manifestPath}.plugins[${index}]`;
290
+ try {
291
+ const plugin = requireRecord$1(document.plugins[index], label);
292
+ const pluginName = requireString$1(plugin.name, `${label}.name`);
293
+ validatePluginIdSegment(pluginName, `${label}.name`);
294
+ const id = `${pluginName}@${marketplaceName}`;
295
+ if (Object.hasOwn(entries, id)) continue;
296
+ const source = parsePluginSource(plugin.source, marketplace.root, `${label}.source`, marketplace);
297
+ const description = optionalString$1(plugin.description, `${label}.description`);
298
+ const manifest = source.type === "local" ? readPluginManifestMetadata(source.path, diagnostics) : void 0;
299
+ const resolvedDescription = description ?? manifest?.description;
300
+ entries[id] = {
301
+ source,
302
+ marketplace: marketplaceName,
303
+ ...resolvedDescription ? { description: resolvedDescription } : {},
304
+ ...manifest ? { manifest } : {}
305
+ };
306
+ } catch (error) {
307
+ diagnostics.push(error instanceof Error ? error.message : String(error));
308
+ }
309
+ }
310
+ }
311
+ function parseConfiguredRoots(source) {
312
+ if (source.value === void 0) return [];
313
+ const document = requireRecord$1(source.value, `plugins in ${source.filePath}`);
314
+ assertOnlyKeys$1(document, ["roots", "entries"], `plugins in ${source.filePath}`);
315
+ if (document.roots === void 0) return [];
316
+ if (!Array.isArray(document.roots)) throw new Error(`plugins.roots in ${source.filePath} must be an array`);
317
+ return document.roots.map((root, index) => node_path.default.resolve(source.baseDirectory, requireString$1(root, `plugins.roots[${index}] in ${source.filePath}`)));
318
+ }
319
+ function applyConfiguredEntries(source, entries, diagnostics) {
320
+ if (source.value === void 0) return;
321
+ const document = requireRecord$1(source.value, `plugins in ${source.filePath}`);
322
+ if (document.entries === void 0) return;
323
+ const configuredEntries = requireRecord$1(document.entries, `plugins.entries in ${source.filePath}`);
324
+ for (const [name, value] of Object.entries(configuredEntries)) {
325
+ validatePluginId(name, `Plugin entry "${name}" in ${source.filePath}`);
326
+ const parsed = parseConfiguredEntry(value, source.baseDirectory, `plugins.entries.${name} in ${source.filePath}`);
327
+ const manifest = parsed.source.type === "local" ? readPluginManifestMetadata(parsed.source.path, diagnostics) : void 0;
328
+ const description = parsed.description ?? manifest?.description;
329
+ entries[name] = {
330
+ source: parsed.source,
331
+ ...description ? { description } : {},
332
+ ...manifest ? { manifest } : {}
333
+ };
334
+ }
335
+ }
336
+ function pluginDirectoryForSource(source, homeDoomDirectory) {
337
+ if (source.type === "local") return source.path;
338
+ const identity = source.type === "git" ? [
339
+ "git",
340
+ source.url,
341
+ source.path ?? "",
342
+ source.ref ?? "",
343
+ source.sha ?? ""
344
+ ] : [
345
+ "npm",
346
+ source.package,
347
+ source.version ?? "",
348
+ source.registry ?? ""
349
+ ];
350
+ const digest = node_crypto.default.createHash("sha256").update(JSON.stringify(identity)).digest("hex");
351
+ return node_path.default.join(homeDoomDirectory, CACHE_DIRECTORY, digest);
352
+ }
353
+ function loadPluginCatalog(sources, repoRoot, homeDirectory) {
354
+ const diagnostics = [];
355
+ const entries = {};
356
+ const roots = [...new Set(sources.flatMap(parseConfiguredRoots))];
357
+ const candidates = [
358
+ homeDirectory,
359
+ repoRoot,
360
+ ...roots
361
+ ];
362
+ const marketplaces = [];
363
+ const seenMarketplaces = /* @__PURE__ */ new Set();
364
+ for (const candidate of candidates) {
365
+ const marketplace = findMarketplace(candidate);
366
+ if (!marketplace) continue;
367
+ if (seenMarketplaces.has(marketplace.manifestPath)) continue;
368
+ seenMarketplaces.add(marketplace.manifestPath);
369
+ marketplaces.push(marketplace.manifestPath);
370
+ try {
371
+ parseMarketplace(marketplace, entries, diagnostics);
372
+ } catch (error) {
373
+ diagnostics.push(error instanceof Error ? error.message : String(error));
374
+ }
375
+ }
376
+ for (const root of roots) {
377
+ if (findMarketplace(root)) continue;
378
+ if (discoverPluginFolder(root, entries, diagnostics) === 0) diagnostics.push(`Plugin root contains neither a supported marketplace nor discoverable plugins: ${root}`);
379
+ }
380
+ for (const source of sources) applyConfiguredEntries(source, entries, diagnostics);
381
+ return {
382
+ roots,
383
+ marketplaces,
384
+ entries,
385
+ diagnostics
386
+ };
387
+ }
388
+ function isRemotePluginSource(source) {
389
+ return source.type !== "local";
390
+ }
391
+ //#endregion
392
+ //#region src/services/domains/completion.ts
393
+ const NAME_DELIMITER = ",";
394
+ /** Splits comma-joined selections and expands aliases into concrete domain names. */
395
+ function expandDomainNames(manifest, domainNames) {
396
+ return domainNames.flatMap((raw) => raw.split(NAME_DELIMITER).map((name) => name.trim()).filter(Boolean)).flatMap((name) => manifest.aliases[name] ?? [name]);
397
+ }
398
+ function domainCompletionPrefix(textBeforeCursor) {
399
+ return textBeforeCursor.match(/^\/domains\s+(?:[^\s,]+,)*([^\s,]*)$/)?.[1];
400
+ }
401
+ function domainCompletionItems(domainNames, query) {
402
+ const normalizedQuery = query.toLowerCase();
403
+ return domainNames.filter((name) => name.toLowerCase().startsWith(normalizedQuery)).map((name) => ({
404
+ value: name,
405
+ label: name
406
+ }));
407
+ }
408
+ //#endregion
409
+ //#region src/services/domains/index.ts
410
+ const DOMAINS_FILE = "domains.yaml";
411
+ const UNKNOWN_DOMAIN_ERROR = "Unknown domain";
412
+ const UNKNOWN_PLUGIN_ERROR = "Unknown plugin";
413
+ const MISSING_PLUGIN_DIRECTORY_ERROR = "Plugin directory does not exist";
414
+ const DEFAULT_DOMAINS_PATH = ".po/domains.yaml";
415
+ const SUPPORTED_AGENT_PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
416
+ function isRecord(value) {
417
+ return typeof value === "object" && value !== null && !Array.isArray(value);
418
+ }
419
+ function requireRecord(value, label) {
420
+ if (!isRecord(value)) throw new Error(`${label} must be an object`);
421
+ return value;
422
+ }
423
+ function assertOnlyKeys(record, allowed, label) {
424
+ const unexpected = Object.keys(record).filter((key) => !allowed.includes(key));
425
+ if (unexpected.length > 0) throw new Error(`${label} contains unsupported field "${unexpected[0]}"`);
426
+ }
427
+ function requireString(value, label) {
428
+ if (typeof value !== "string" || !value.trim()) throw new Error(`${label} must be a non-empty string`);
429
+ return value.trim();
430
+ }
431
+ function optionalString(value, label) {
432
+ if (value === void 0) return void 0;
433
+ return requireString(value, label);
434
+ }
435
+ function parseStringArray(value, label) {
436
+ if (!Array.isArray(value)) throw new Error(`${label} must be an array of non-empty strings`);
437
+ return [...new Set(value.map((entry, index) => requireString(entry, `${label}[${index}]`)))];
438
+ }
439
+ function parseOptionalBoolean(value, label) {
440
+ if (value === void 0) return void 0;
441
+ if (typeof value !== "boolean") throw new Error(`${label} must be a boolean`);
442
+ return value;
443
+ }
444
+ function parseDefaultDomains(value) {
445
+ return parseStringArray(value, `defaultDomains in ${DEFAULT_DOMAINS_PATH}`);
446
+ }
447
+ function parseDomainPlugin(value, label) {
448
+ if (typeof value === "string") return requireString(value, label);
449
+ const plugin = requireRecord(value, label);
450
+ assertOnlyKeys(plugin, [
451
+ "name",
452
+ "skills",
453
+ "agents",
454
+ "hooks",
455
+ "mcp"
456
+ ], label);
457
+ const skills = plugin.skills === void 0 ? void 0 : parseStringArray(plugin.skills, `${label}.skills`);
458
+ const agents = plugin.agents === void 0 ? void 0 : parseStringArray(plugin.agents, `${label}.agents`);
459
+ const hooks = parseOptionalBoolean(plugin.hooks, `${label}.hooks`);
460
+ const mcp = parseOptionalBoolean(plugin.mcp, `${label}.mcp`);
461
+ return {
462
+ name: requireString(plugin.name, `${label}.name`),
463
+ ...skills ? { skills } : {},
464
+ ...agents ? { agents } : {},
465
+ ...hooks === void 0 ? {} : { hooks },
466
+ ...mcp === void 0 ? {} : { mcp }
467
+ };
468
+ }
469
+ function parseMcpAllowlist(value, label) {
470
+ const mcp = requireRecord(value, label);
471
+ assertOnlyKeys(mcp, ["servers", "proxy"], label);
472
+ return {
473
+ ...mcp.servers === void 0 ? {} : { servers: parseStringArray(mcp.servers, `${label}.servers`) },
474
+ ...mcp.proxy === void 0 ? {} : { proxy: parseStringArray(mcp.proxy, `${label}.proxy`) }
475
+ };
476
+ }
477
+ function parseDomain(value, label) {
478
+ const domain = requireRecord(value, label);
479
+ assertOnlyKeys(domain, [
480
+ "description",
481
+ "plugins",
482
+ "mcp",
483
+ "sharedSkills"
484
+ ], label);
485
+ const description = optionalString(domain.description, `${label}.description`);
486
+ if (domain.plugins !== void 0 && !Array.isArray(domain.plugins)) throw new Error(`${label}.plugins must be an array`);
487
+ const sharedSkills = parseOptionalBoolean(domain.sharedSkills, `${label}.sharedSkills`);
488
+ return {
489
+ ...description ? { description } : {},
490
+ ...Array.isArray(domain.plugins) ? { plugins: domain.plugins.map((plugin, index) => parseDomainPlugin(plugin, `${label}.plugins[${index}]`)) } : {},
491
+ ...domain.mcp === void 0 ? {} : { mcp: parseMcpAllowlist(domain.mcp, `${label}.mcp`) },
492
+ ...sharedSkills === void 0 ? {} : { sharedSkills }
493
+ };
494
+ }
495
+ function parseAliases(value, label) {
496
+ if (value === void 0) return {};
497
+ const aliases = requireRecord(value, label);
498
+ return Object.fromEntries(Object.entries(aliases).map(([name, domains]) => [name, parseStringArray(domains, `${label}.${name}`)]));
499
+ }
500
+ /**
501
+ * Reads domains and plugin catalogs from global and repository configs.
502
+ *
503
+ * Named domains and explicit plugin entries are replaced by later repository
504
+ * definitions. Configured roots accumulate, with exact marketplace manifests
505
+ * deduplicated in discovery order. Explicit entries override discovered IDs.
506
+ */
507
+ function loadDomains(repoRoot, homeDirectory = node_os.default.homedir()) {
508
+ const sources = require_layeredConfig.readDoomConfigSources(DOMAINS_FILE, repoRoot, homeDirectory);
509
+ const aliases = {};
510
+ const domains = {};
511
+ let defaultDomains;
512
+ for (const source of sources) {
513
+ const document = requireRecord(source.document, source.filePath);
514
+ assertOnlyKeys(document, [
515
+ "plugins",
516
+ "domains",
517
+ "aliases",
518
+ "defaultDomains"
519
+ ], source.filePath);
520
+ Object.assign(aliases, parseAliases(document.aliases, `aliases in ${source.filePath}`));
521
+ if (document.domains !== void 0) {
522
+ const sourceDomains = requireRecord(document.domains, `domains in ${source.filePath}`);
523
+ for (const [name, definition] of Object.entries(sourceDomains)) domains[name] = {
524
+ ...parseDomain(definition, `domains.${name} in ${source.filePath}`),
525
+ baseDirectory: source.baseDirectory
526
+ };
527
+ }
528
+ if (Object.hasOwn(document, "defaultDomains")) defaultDomains = parseDefaultDomains(document.defaultDomains);
529
+ }
530
+ const plugins = loadPluginCatalog(sources.map((source) => ({
531
+ filePath: source.filePath,
532
+ baseDirectory: source.baseDirectory,
533
+ value: requireRecord(source.document, source.filePath).plugins
534
+ })), repoRoot, homeDirectory);
535
+ if (defaultDomains) {
536
+ for (const name of expandDomainNames({
537
+ plugins,
538
+ domains,
539
+ aliases
540
+ }, defaultDomains)) if (!Object.hasOwn(domains, name)) throw new Error(`Unknown default domain "${name}" in ${DEFAULT_DOMAINS_PATH}`);
541
+ }
542
+ return {
543
+ plugins,
544
+ domains,
545
+ aliases,
546
+ ...defaultDomains ? { defaultDomains } : {}
547
+ };
548
+ }
549
+ function listDomainNames(repoRoot, homeDirectory) {
550
+ const manifest = loadDomains(repoRoot, homeDirectory);
551
+ return [.../* @__PURE__ */ new Set([...Object.keys(manifest.domains), ...Object.keys(manifest.aliases)])].sort();
552
+ }
553
+ /**
554
+ * Whether to include .claude/skills as shared fallbacks.
555
+ *
556
+ * Shared skills are included unless every selected domain opts out, so mixing a
557
+ * trimmed domain with an untrimmed one cannot strip the untrimmed one's skills.
558
+ */
559
+ function resolveSharedSkills(repoRoot, domainNames, homeDirectory) {
560
+ const manifest = loadDomains(repoRoot, homeDirectory);
561
+ const expanded = expandDomainNames(manifest, domainNames);
562
+ if (expanded.length === 0) return true;
563
+ return expanded.some((name) => manifest.domains[name]?.sharedSkills !== false);
564
+ }
565
+ /** Resolves named domain plugins while preserving each subset filter. */
566
+ function resolvePluginEntries(repoRoot, domainNames, explicitDirectories, homeDirectory = node_os.default.homedir()) {
567
+ const manifest = loadDomains(repoRoot, homeDirectory);
568
+ const entries = [];
569
+ const seen = /* @__PURE__ */ new Set();
570
+ const homeDoomDirectory = require_config.globalDoomConfigDirectory(homeDirectory);
571
+ for (const domainName of expandDomainNames(manifest, domainNames)) {
572
+ const domain = manifest.domains[domainName];
573
+ if (!domain) throw new Error(`${UNKNOWN_DOMAIN_ERROR}: ${domainName}`);
574
+ for (const selection of domain.plugins ?? []) {
575
+ const isSubset = typeof selection !== "string";
576
+ const pluginName = isSubset ? selection.name : selection;
577
+ const plugin = manifest.plugins.entries[pluginName];
578
+ if (!plugin) throw new Error(`${UNKNOWN_PLUGIN_ERROR} "${pluginName}" referenced by domain "${domainName}"`);
579
+ const directory = pluginDirectoryForSource(plugin.source, homeDoomDirectory);
580
+ if (plugin.source.type === "local" && (!node_fs.default.existsSync(directory) || !node_fs.default.statSync(directory).isDirectory())) throw new Error(`${MISSING_PLUGIN_DIRECTORY_ERROR}: ${directory}`);
581
+ if (seen.has(directory)) continue;
582
+ seen.add(directory);
583
+ entries.push({
584
+ name: pluginName,
585
+ directory,
586
+ domain: domainName,
587
+ source: plugin.source,
588
+ ...plugin.manifest ? { manifest: plugin.manifest } : {},
589
+ ...plugin.manifest?.agentPluginSchema === SUPPORTED_AGENT_PLUGIN_SCHEMA ? { skillDiscovery: "direct-children" } : {},
590
+ ...isSubset && selection.skills ? { skills: selection.skills } : {},
591
+ ...isSubset && selection.agents ? { agents: selection.agents } : {},
592
+ ...isSubset && selection.hooks !== void 0 ? { hooks: selection.hooks } : {},
593
+ ...isSubset && selection.mcp !== void 0 ? { mcp: selection.mcp } : {}
594
+ });
595
+ }
596
+ }
597
+ for (const configuredDirectory of explicitDirectories) {
598
+ const directory = node_path.default.resolve(configuredDirectory);
599
+ if (!node_fs.default.existsSync(directory) || !node_fs.default.statSync(directory).isDirectory()) throw new Error(`${MISSING_PLUGIN_DIRECTORY_ERROR}: ${directory}`);
600
+ if (seen.has(directory)) continue;
601
+ seen.add(directory);
602
+ entries.push({
603
+ name: node_path.default.basename(directory),
604
+ directory,
605
+ source: {
606
+ type: "local",
607
+ path: directory
608
+ }
609
+ });
610
+ }
611
+ return entries;
612
+ }
613
+ function resolvePluginDirectories(repoRoot, domainNames, explicitDirectories, homeDirectory) {
614
+ return resolvePluginEntries(repoRoot, domainNames, explicitDirectories, homeDirectory).map((entry) => entry.directory);
615
+ }
616
+ const PO_DOMAINS_ENV = "PO_DOMAINS";
617
+ const DEFAULT_DOMAIN = "default";
618
+ const MARKETING_MAJOR_MODE = "marketing";
619
+ function parseDomainList(value) {
620
+ return value.split(",").map((entry) => entry.trim()).filter(Boolean);
621
+ }
622
+ /**
623
+ * Domains selected when the caller names none.
624
+ *
625
+ * Configuration keeps this axis independent of the major mode. The
626
+ * major-mode-derived choice is retained only as the compatibility fallback for
627
+ * domains files that declare no defaultDomains.
628
+ */
629
+ function defaultDomainsForMajorMode(majorMode, environment, defaultDomains) {
630
+ const inherited = environment[PO_DOMAINS_ENV];
631
+ if (inherited !== void 0) return parseDomainList(inherited);
632
+ if (defaultDomains !== void 0) return [...defaultDomains];
633
+ return parseDomainList(majorMode === MARKETING_MAJOR_MODE ? MARKETING_MAJOR_MODE : DEFAULT_DOMAIN);
634
+ }
635
+ //#endregion
636
+ Object.defineProperty(exports, "DEFAULT_DOMAIN", {
637
+ enumerable: true,
638
+ get: function() {
639
+ return DEFAULT_DOMAIN;
640
+ }
641
+ });
642
+ Object.defineProperty(exports, "MARKETPLACE_MANIFEST_RELATIVE_PATHS", {
643
+ enumerable: true,
644
+ get: function() {
645
+ return MARKETPLACE_MANIFEST_RELATIVE_PATHS;
646
+ }
647
+ });
648
+ Object.defineProperty(exports, "PO_DOMAINS_ENV", {
649
+ enumerable: true,
650
+ get: function() {
651
+ return PO_DOMAINS_ENV;
652
+ }
653
+ });
654
+ Object.defineProperty(exports, "defaultDomainsForMajorMode", {
655
+ enumerable: true,
656
+ get: function() {
657
+ return defaultDomainsForMajorMode;
658
+ }
659
+ });
660
+ Object.defineProperty(exports, "domainCompletionItems", {
661
+ enumerable: true,
662
+ get: function() {
663
+ return domainCompletionItems;
664
+ }
665
+ });
666
+ Object.defineProperty(exports, "domainCompletionPrefix", {
667
+ enumerable: true,
668
+ get: function() {
669
+ return domainCompletionPrefix;
670
+ }
671
+ });
672
+ Object.defineProperty(exports, "expandDomainNames", {
673
+ enumerable: true,
674
+ get: function() {
675
+ return expandDomainNames;
676
+ }
677
+ });
678
+ Object.defineProperty(exports, "findPluginManifestPath", {
679
+ enumerable: true,
680
+ get: function() {
681
+ return findPluginManifestPath;
682
+ }
683
+ });
684
+ Object.defineProperty(exports, "isRemotePluginSource", {
685
+ enumerable: true,
686
+ get: function() {
687
+ return isRemotePluginSource;
688
+ }
689
+ });
690
+ Object.defineProperty(exports, "listDomainNames", {
691
+ enumerable: true,
692
+ get: function() {
693
+ return listDomainNames;
694
+ }
695
+ });
696
+ Object.defineProperty(exports, "loadDomains", {
697
+ enumerable: true,
698
+ get: function() {
699
+ return loadDomains;
700
+ }
701
+ });
702
+ Object.defineProperty(exports, "pluginDirectoryForSource", {
703
+ enumerable: true,
704
+ get: function() {
705
+ return pluginDirectoryForSource;
706
+ }
707
+ });
708
+ Object.defineProperty(exports, "resolvePluginDirectories", {
709
+ enumerable: true,
710
+ get: function() {
711
+ return resolvePluginDirectories;
712
+ }
713
+ });
714
+ Object.defineProperty(exports, "resolvePluginEntries", {
715
+ enumerable: true,
716
+ get: function() {
717
+ return resolvePluginEntries;
718
+ }
719
+ });
720
+ Object.defineProperty(exports, "resolveSharedSkills", {
721
+ enumerable: true,
722
+ get: function() {
723
+ return resolveSharedSkills;
724
+ }
725
+ });
726
+
727
+ //# sourceMappingURL=domains-CBYkuxs5.cjs.map