poe-code 3.0.184 → 3.0.186

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 (258) hide show
  1. package/dist/cli/commands/configure-payload.d.ts +2 -1
  2. package/dist/cli/commands/configure-payload.js +4 -2
  3. package/dist/cli/commands/configure-payload.js.map +1 -1
  4. package/dist/cli/commands/configure.d.ts +1 -0
  5. package/dist/cli/commands/configure.js +50 -11
  6. package/dist/cli/commands/configure.js.map +1 -1
  7. package/dist/cli/commands/ensure-isolated-config.js +24 -2
  8. package/dist/cli/commands/ensure-isolated-config.js.map +1 -1
  9. package/dist/cli/commands/experiment.js +15 -2
  10. package/dist/cli/commands/experiment.js.map +1 -1
  11. package/dist/cli/commands/login.js +8 -4
  12. package/dist/cli/commands/login.js.map +1 -1
  13. package/dist/cli/commands/memory.js +16 -7
  14. package/dist/cli/commands/memory.js.map +1 -1
  15. package/dist/cli/commands/pipeline-init.js +32 -48
  16. package/dist/cli/commands/pipeline-init.js.map +1 -1
  17. package/dist/cli/commands/pipeline.js +89 -77
  18. package/dist/cli/commands/pipeline.js.map +1 -1
  19. package/dist/cli/commands/provider.d.ts +6 -0
  20. package/dist/cli/commands/provider.js +100 -0
  21. package/dist/cli/commands/provider.js.map +1 -0
  22. package/dist/cli/commands/shared.d.ts +7 -0
  23. package/dist/cli/commands/shared.js +3 -0
  24. package/dist/cli/commands/shared.js.map +1 -1
  25. package/dist/cli/commands/test.js +1 -1
  26. package/dist/cli/commands/test.js.map +1 -1
  27. package/dist/cli/commands/unconfigure.js +12 -3
  28. package/dist/cli/commands/unconfigure.js.map +1 -1
  29. package/dist/cli/container.d.ts +2 -0
  30. package/dist/cli/container.js +3 -0
  31. package/dist/cli/container.js.map +1 -1
  32. package/dist/cli/isolated-env-runner.js +2 -2
  33. package/dist/cli/isolated-env-runner.js.map +1 -1
  34. package/dist/cli/isolated-env.d.ts +3 -2
  35. package/dist/cli/isolated-env.js +31 -40
  36. package/dist/cli/isolated-env.js.map +1 -1
  37. package/dist/cli/poe-code-command-runner.js +9 -2
  38. package/dist/cli/poe-code-command-runner.js.map +1 -1
  39. package/dist/cli/program.js +5 -0
  40. package/dist/cli/program.js.map +1 -1
  41. package/dist/cli/service-registry.d.ts +7 -7
  42. package/dist/cli/service-registry.js.map +1 -1
  43. package/dist/index.js +2496 -1911
  44. package/dist/index.js.map +4 -4
  45. package/dist/providers/claude-code.d.ts +2 -1
  46. package/dist/providers/claude-code.js +5 -5
  47. package/dist/providers/claude-code.js.map +2 -2
  48. package/dist/providers/codex.d.ts +5 -1
  49. package/dist/providers/codex.js +39 -12
  50. package/dist/providers/codex.js.map +2 -2
  51. package/dist/providers/goose.d.ts +2 -1
  52. package/dist/providers/goose.js +24 -8
  53. package/dist/providers/goose.js.map +3 -3
  54. package/dist/providers/kimi.js +3 -3
  55. package/dist/providers/kimi.js.map +3 -3
  56. package/dist/providers/opencode.js +2 -2
  57. package/dist/providers/opencode.js.map +3 -3
  58. package/dist/providers/poe-agent.js +753 -649
  59. package/dist/providers/poe-agent.js.map +4 -4
  60. package/dist/sdk/container.js +3 -0
  61. package/dist/sdk/container.js.map +1 -1
  62. package/dist/sdk/pipeline.d.ts +1 -2
  63. package/dist/sdk/pipeline.js +51 -119
  64. package/dist/sdk/pipeline.js.map +1 -1
  65. package/dist/services/config.d.ts +1 -0
  66. package/dist/services/config.js +27 -2
  67. package/dist/services/config.js.map +1 -1
  68. package/dist/templates/pipeline/SKILL_plan.md +16 -42
  69. package/package.json +15 -1
  70. package/packages/agent-mcp-config/dist/apply.d.ts +6 -0
  71. package/packages/agent-mcp-config/dist/apply.js +175 -0
  72. package/packages/agent-mcp-config/dist/configs.d.ts +22 -0
  73. package/packages/agent-mcp-config/dist/configs.js +74 -0
  74. package/packages/agent-mcp-config/dist/index.d.ts +3 -0
  75. package/packages/agent-mcp-config/dist/index.js +2 -0
  76. package/packages/agent-mcp-config/dist/shapes.d.ts +31 -0
  77. package/packages/agent-mcp-config/dist/shapes.js +87 -0
  78. package/packages/agent-mcp-config/dist/types.d.ts +25 -0
  79. package/packages/agent-mcp-config/dist/types.js +1 -0
  80. package/packages/agent-skill-config/dist/apply.d.ts +25 -0
  81. package/packages/agent-skill-config/dist/apply.js +109 -0
  82. package/packages/agent-skill-config/dist/configs.d.ts +16 -0
  83. package/packages/agent-skill-config/dist/configs.js +66 -0
  84. package/packages/agent-skill-config/dist/exports.compile-check.d.ts +1 -0
  85. package/packages/agent-skill-config/dist/exports.compile-check.js +1 -0
  86. package/packages/agent-skill-config/dist/index.d.ts +5 -0
  87. package/packages/agent-skill-config/dist/index.js +2 -0
  88. package/packages/agent-skill-config/dist/templates/poe-generate.md +47 -0
  89. package/packages/agent-skill-config/dist/templates/terminal-pilot.md +45 -0
  90. package/packages/agent-skill-config/dist/templates.d.ts +3 -0
  91. package/packages/agent-skill-config/dist/templates.js +63 -0
  92. package/packages/agent-skill-config/dist/types.d.ts +16 -0
  93. package/packages/agent-skill-config/dist/types.js +1 -0
  94. package/packages/cmdkit/dist/cli.js +7 -2
  95. package/packages/cmdkit/dist/cli.js.map +2 -2
  96. package/packages/cmdkit-openapi/dist/api-command.d.ts +7 -0
  97. package/packages/cmdkit-openapi/dist/api-command.js +4 -0
  98. package/packages/cmdkit-openapi/dist/auth/bearer-token-auth.d.ts +8 -0
  99. package/packages/cmdkit-openapi/dist/auth/bearer-token-auth.js +216 -0
  100. package/packages/cmdkit-openapi/dist/auth/types.d.ts +9 -0
  101. package/packages/cmdkit-openapi/dist/auth/types.js +1 -0
  102. package/packages/cmdkit-openapi/dist/bin/generate.d.ts +40 -0
  103. package/packages/cmdkit-openapi/dist/bin/generate.js +248 -0
  104. package/packages/cmdkit-openapi/dist/define-client.d.ts +20 -0
  105. package/packages/cmdkit-openapi/dist/define-client.js +148 -0
  106. package/packages/cmdkit-openapi/dist/generate.d.ts +210 -0
  107. package/packages/cmdkit-openapi/dist/generate.js +1091 -0
  108. package/packages/cmdkit-openapi/dist/group-by-noun.d.ts +6 -0
  109. package/packages/cmdkit-openapi/dist/group-by-noun.js +17 -0
  110. package/packages/cmdkit-openapi/dist/http.d.ts +26 -0
  111. package/packages/cmdkit-openapi/dist/http.js +123 -0
  112. package/packages/cmdkit-openapi/dist/index.d.ts +12 -0
  113. package/packages/cmdkit-openapi/dist/index.js +6 -0
  114. package/packages/cmdkit-openapi/dist/interpreter.d.ts +6 -0
  115. package/packages/cmdkit-openapi/dist/interpreter.js +289 -0
  116. package/packages/cmdkit-openapi/dist/lock.d.ts +14 -0
  117. package/packages/cmdkit-openapi/dist/lock.js +48 -0
  118. package/packages/cmdkit-openapi/dist/naming.d.ts +24 -0
  119. package/packages/cmdkit-openapi/dist/naming.js +218 -0
  120. package/packages/cmdkit-openapi/dist/request-shape.d.ts +15 -0
  121. package/packages/cmdkit-openapi/dist/request-shape.js +5 -0
  122. package/packages/cmdkit-openapi/dist/runtime.d.ts +13 -0
  123. package/packages/cmdkit-openapi/dist/runtime.js +94 -0
  124. package/packages/cmdkit-openapi/dist/spec-source.d.ts +11 -0
  125. package/packages/cmdkit-openapi/dist/spec-source.js +63 -0
  126. package/packages/config-mutations/dist/execution/apply-mutation.d.ts +5 -0
  127. package/packages/config-mutations/dist/execution/apply-mutation.js +552 -0
  128. package/packages/config-mutations/dist/execution/path-utils.d.ts +17 -0
  129. package/packages/config-mutations/dist/execution/path-utils.js +58 -0
  130. package/packages/config-mutations/dist/execution/run-mutations.d.ts +7 -0
  131. package/packages/config-mutations/dist/execution/run-mutations.js +46 -0
  132. package/packages/config-mutations/dist/formats/index.d.ts +13 -0
  133. package/packages/config-mutations/dist/formats/index.js +49 -0
  134. package/packages/config-mutations/dist/formats/json.d.ts +31 -0
  135. package/packages/config-mutations/dist/formats/json.js +140 -0
  136. package/packages/config-mutations/dist/formats/toml.d.ts +2 -0
  137. package/packages/config-mutations/dist/formats/toml.js +72 -0
  138. package/packages/config-mutations/dist/formats/yaml.d.ts +2 -0
  139. package/packages/config-mutations/dist/formats/yaml.js +73 -0
  140. package/packages/config-mutations/dist/fs-utils.d.ts +18 -0
  141. package/packages/config-mutations/dist/fs-utils.js +45 -0
  142. package/packages/config-mutations/dist/index.d.ts +8 -0
  143. package/packages/config-mutations/dist/index.js +8 -0
  144. package/packages/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
  145. package/packages/config-mutations/dist/mutations/config-mutation.js +34 -0
  146. package/packages/config-mutations/dist/mutations/file-mutation.d.ts +52 -0
  147. package/packages/config-mutations/dist/mutations/file-mutation.js +46 -0
  148. package/packages/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
  149. package/packages/config-mutations/dist/mutations/template-mutation.js +32 -0
  150. package/packages/config-mutations/dist/template/render.d.ts +7 -0
  151. package/packages/config-mutations/dist/template/render.js +28 -0
  152. package/packages/config-mutations/dist/testing/format-utils.d.ts +7 -0
  153. package/packages/config-mutations/dist/testing/format-utils.js +21 -0
  154. package/packages/config-mutations/dist/testing/index.d.ts +3 -0
  155. package/packages/config-mutations/dist/testing/index.js +2 -0
  156. package/packages/config-mutations/dist/testing/mock-fs.d.ts +25 -0
  157. package/packages/config-mutations/dist/testing/mock-fs.js +170 -0
  158. package/packages/config-mutations/dist/types.d.ts +156 -0
  159. package/packages/config-mutations/dist/types.js +6 -0
  160. package/packages/memory/dist/audit.d.ts +11 -0
  161. package/packages/memory/dist/audit.js +131 -0
  162. package/packages/memory/dist/cache.cli.d.ts +9 -0
  163. package/packages/memory/dist/cache.cli.js +24 -0
  164. package/packages/memory/dist/cache.d.ts +14 -0
  165. package/packages/memory/dist/cache.js +149 -0
  166. package/packages/memory/dist/confidence.d.ts +4 -0
  167. package/packages/memory/dist/confidence.js +201 -0
  168. package/packages/memory/dist/corpus/001-archaeoastronomy.md +479 -0
  169. package/packages/memory/dist/corpus/002-magnetohydrodynamics.md +475 -0
  170. package/packages/memory/dist/corpus/003-biosemiotics.md +483 -0
  171. package/packages/memory/dist/corpus/004-cryopedology.md +483 -0
  172. package/packages/memory/dist/corpus/005-geomicrobiology.md +479 -0
  173. package/packages/memory/dist/corpus/006-aeronomy.md +487 -0
  174. package/packages/memory/dist/corpus/007-paleoclimatology.md +479 -0
  175. package/packages/memory/dist/corpus/008-hydrogeophysics.md +479 -0
  176. package/packages/memory/dist/corpus/009-magnetostratigraphy.md +475 -0
  177. package/packages/memory/dist/corpus/010-isotope-hydrology.md +481 -0
  178. package/packages/memory/dist/corpus/011-speleothem-geochemistry.md +474 -0
  179. package/packages/memory/dist/corpus/012-astrobiogeochemistry.md +475 -0
  180. package/packages/memory/dist/corpus/013-neuroethology.md +483 -0
  181. package/packages/memory/dist/corpus/014-chronophysiology.md +483 -0
  182. package/packages/memory/dist/corpus/015-limnogeochemistry.md +475 -0
  183. package/packages/memory/dist/corpus/016-palynology.md +483 -0
  184. package/packages/memory/dist/corpus/017-volcanotectonics.md +473 -0
  185. package/packages/memory/dist/corpus/018-seismotectonics.md +473 -0
  186. package/packages/memory/dist/corpus/019-biogeomorphology.md +475 -0
  187. package/packages/memory/dist/corpus/020-geobiophysics.md +479 -0
  188. package/packages/memory/dist/corpus/021-phytolith-analysis.md +481 -0
  189. package/packages/memory/dist/corpus/022-archaeometallurgy.md +479 -0
  190. package/packages/memory/dist/corpus/023-paleomagnetism.md +479 -0
  191. package/packages/memory/dist/corpus/024-biocalorimetry.md +475 -0
  192. package/packages/memory/dist/corpus/025-atmospheric-chemiluminescence.md +473 -0
  193. package/packages/memory/dist/corpus/026-cryoseismology.md +479 -0
  194. package/packages/memory/dist/corpus/027-extremophile-radiobiology.md +475 -0
  195. package/packages/memory/dist/corpus/028-heliophysics.md +479 -0
  196. package/packages/memory/dist/corpus/029-astroparticle-geophysics.md +474 -0
  197. package/packages/memory/dist/corpus/030-glaciohydrology.md +479 -0
  198. package/packages/memory/dist/corpus/031-permafrost-microbiology.md +477 -0
  199. package/packages/memory/dist/corpus/032-ecoacoustics.md +479 -0
  200. package/packages/memory/dist/corpus/033-dendroclimatology.md +473 -0
  201. package/packages/memory/dist/corpus/034-ionospheric-tomography.md +477 -0
  202. package/packages/memory/dist/corpus/035-marine-geodesy.md +481 -0
  203. package/packages/memory/dist/corpus/036-sedimentary-ancient-dna.md +481 -0
  204. package/packages/memory/dist/corpus/037-myrmecochory-dynamics.md +474 -0
  205. package/packages/memory/dist/corpus/038-chemosensory-ecology.md +477 -0
  206. package/packages/memory/dist/corpus/039-spintronics-materials.md +479 -0
  207. package/packages/memory/dist/corpus/040-nanotoxicology.md +483 -0
  208. package/packages/memory/dist/corpus/041-cosmochemistry.md +483 -0
  209. package/packages/memory/dist/corpus/042-quaternary-geochronology.md +471 -0
  210. package/packages/memory/dist/corpus/043-biophotonics.md +479 -0
  211. package/packages/memory/dist/corpus/044-evolutionary-morphometrics.md +481 -0
  212. package/packages/memory/dist/corpus/045-cryovolcanology.md +475 -0
  213. package/packages/memory/dist/corpus/046-exoplanet-atmospheric-dynamics.md +479 -0
  214. package/packages/memory/dist/corpus/047-microbial-electrosynthesis.md +477 -0
  215. package/packages/memory/dist/corpus/048-paleoseismology.md +479 -0
  216. package/packages/memory/dist/corpus/049-actinide-geochemistry.md +477 -0
  217. package/packages/memory/dist/corpus/050-quantum-biology.md +489 -0
  218. package/packages/memory/dist/edit.d.ts +10 -0
  219. package/packages/memory/dist/edit.js +43 -0
  220. package/packages/memory/dist/explain.cli.d.ts +8 -0
  221. package/packages/memory/dist/explain.cli.js +9 -0
  222. package/packages/memory/dist/explain.d.ts +8 -0
  223. package/packages/memory/dist/explain.js +77 -0
  224. package/packages/memory/dist/frontmatter.d.ts +9 -0
  225. package/packages/memory/dist/frontmatter.js +217 -0
  226. package/packages/memory/dist/index.d.ts +21 -0
  227. package/packages/memory/dist/index.js +4807 -0
  228. package/packages/memory/dist/index.js.map +7 -0
  229. package/packages/memory/dist/ingest.d.ts +3 -0
  230. package/packages/memory/dist/ingest.js +118 -0
  231. package/packages/memory/dist/init.d.ts +2 -0
  232. package/packages/memory/dist/init.js +24 -0
  233. package/packages/memory/dist/install.d.ts +18 -0
  234. package/packages/memory/dist/install.js +50 -0
  235. package/packages/memory/dist/lock.d.ts +19 -0
  236. package/packages/memory/dist/lock.js +102 -0
  237. package/packages/memory/dist/mcp.d.ts +7 -0
  238. package/packages/memory/dist/mcp.js +58 -0
  239. package/packages/memory/dist/pages.d.ts +4 -0
  240. package/packages/memory/dist/pages.js +92 -0
  241. package/packages/memory/dist/paths.d.ts +12 -0
  242. package/packages/memory/dist/paths.js +34 -0
  243. package/packages/memory/dist/query.d.ts +10 -0
  244. package/packages/memory/dist/query.js +130 -0
  245. package/packages/memory/dist/reconcile.d.ts +9 -0
  246. package/packages/memory/dist/reconcile.js +138 -0
  247. package/packages/memory/dist/resolve-root.d.ts +11 -0
  248. package/packages/memory/dist/resolve-root.js +22 -0
  249. package/packages/memory/dist/search.d.ts +2 -0
  250. package/packages/memory/dist/search.js +29 -0
  251. package/packages/memory/dist/status.d.ts +7 -0
  252. package/packages/memory/dist/status.js +46 -0
  253. package/packages/memory/dist/tokens.d.ts +2 -0
  254. package/packages/memory/dist/tokens.js +71 -0
  255. package/packages/memory/dist/types.d.ts +155 -0
  256. package/packages/memory/dist/types.js +1 -0
  257. package/packages/memory/dist/write.d.ts +9 -0
  258. package/packages/memory/dist/write.js +76 -0
@@ -0,0 +1,175 @@
1
+ import path from "node:path";
2
+ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
3
+ import { runMutations, configMutation, fileMutation, readFileIfExists } from "@poe-code/config-mutations";
4
+ import { getAgentConfig, resolveConfigPath, isSupported } from "./configs.js";
5
+ import { getShapeTransformer } from "./shapes.js";
6
+ function getConfigDirectory(configPath) {
7
+ return path.dirname(configPath);
8
+ }
9
+ export class UnsupportedAgentError extends Error {
10
+ constructor(agentId) {
11
+ super(`Unsupported agent: ${agentId}`);
12
+ this.name = "UnsupportedAgentError";
13
+ }
14
+ }
15
+ function isConfigObject(value) {
16
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
17
+ }
18
+ function resolveServerMap(document, configKey) {
19
+ const value = document[configKey];
20
+ return isConfigObject(value) ? value : {};
21
+ }
22
+ function mergeServerMap(document, configKey, servers) {
23
+ return { ...document, [configKey]: servers };
24
+ }
25
+ function expandHomePath(configPath, homeDir) {
26
+ if (!configPath.startsWith("~")) {
27
+ return configPath;
28
+ }
29
+ if (configPath === "~") {
30
+ return homeDir;
31
+ }
32
+ if (configPath.startsWith("~/")) {
33
+ return path.join(homeDir, configPath.slice(2));
34
+ }
35
+ return path.join(homeDir, configPath.slice(1));
36
+ }
37
+ function parseYamlDocument(content) {
38
+ if (content.trim() === "") {
39
+ return {};
40
+ }
41
+ const parsed = parseYaml(content);
42
+ if (parsed === null || parsed === undefined) {
43
+ return {};
44
+ }
45
+ if (!isConfigObject(parsed)) {
46
+ throw new Error("Expected YAML document to be an object.");
47
+ }
48
+ return parsed;
49
+ }
50
+ function serializeYamlDocument(document) {
51
+ const serialized = stringifyYaml(document);
52
+ return serialized.endsWith("\n") ? serialized : `${serialized}\n`;
53
+ }
54
+ async function readYamlConfig(configPath, options) {
55
+ const absolutePath = expandHomePath(configPath, options.homeDir);
56
+ const existingContent = await readFileIfExists(options.fs, absolutePath);
57
+ if (existingContent === null) {
58
+ return {};
59
+ }
60
+ return parseYamlDocument(existingContent);
61
+ }
62
+ async function writeYamlConfig(configPath, document, options) {
63
+ if (options.dryRun) {
64
+ return;
65
+ }
66
+ const absolutePath = expandHomePath(configPath, options.homeDir);
67
+ const configDir = path.dirname(absolutePath);
68
+ await options.fs.mkdir(configDir, { recursive: true });
69
+ await options.fs.writeFile(absolutePath, serializeYamlDocument(document), {
70
+ encoding: "utf8"
71
+ });
72
+ }
73
+ function removeServer(document, configKey, serverName) {
74
+ const servers = resolveServerMap(document, configKey);
75
+ if (!(serverName in servers)) {
76
+ return { changed: false, content: document };
77
+ }
78
+ const nextServers = { ...servers };
79
+ delete nextServers[serverName];
80
+ if (Object.keys(nextServers).length === 0) {
81
+ const nextDocument = { ...document };
82
+ delete nextDocument[configKey];
83
+ return { changed: true, content: nextDocument };
84
+ }
85
+ return {
86
+ changed: true,
87
+ content: mergeServerMap(document, configKey, nextServers)
88
+ };
89
+ }
90
+ export async function configure(agentId, server, options) {
91
+ if (!isSupported(agentId)) {
92
+ throw new UnsupportedAgentError(agentId);
93
+ }
94
+ const config = getAgentConfig(agentId);
95
+ const configPath = resolveConfigPath(config, options.platform);
96
+ const shapeTransformer = getShapeTransformer(config.shape);
97
+ const shaped = shapeTransformer(server);
98
+ if (shaped === undefined) {
99
+ await unconfigure(agentId, server.name, options);
100
+ return;
101
+ }
102
+ if (config.format === "yaml") {
103
+ const document = await readYamlConfig(configPath, options);
104
+ const servers = resolveServerMap(document, config.configKey);
105
+ const nextDocument = mergeServerMap(document, config.configKey, {
106
+ ...servers,
107
+ [server.name]: shaped
108
+ });
109
+ await writeYamlConfig(configPath, nextDocument, options);
110
+ return;
111
+ }
112
+ const configDir = getConfigDirectory(configPath);
113
+ await runMutations([
114
+ fileMutation.ensureDirectory({
115
+ path: configDir,
116
+ label: `Ensure directory ${configDir}`
117
+ }),
118
+ // Use transform to replace the server entry entirely (not deep-merge)
119
+ // This ensures old fields like 'args' are removed when switching to array 'command'
120
+ configMutation.transform({
121
+ target: configPath,
122
+ format: config.format,
123
+ transform: (document) => {
124
+ const servers = resolveServerMap(document, config.configKey);
125
+ const newServers = {
126
+ ...servers,
127
+ [server.name]: shaped
128
+ };
129
+ return {
130
+ changed: true,
131
+ content: mergeServerMap(document, config.configKey, newServers)
132
+ };
133
+ },
134
+ label: `Add ${server.name} to ${configPath}`
135
+ })
136
+ ], {
137
+ fs: options.fs,
138
+ homeDir: options.homeDir,
139
+ dryRun: options.dryRun,
140
+ observers: options.observers
141
+ });
142
+ }
143
+ export async function unconfigure(agentId, serverName, options) {
144
+ if (!isSupported(agentId)) {
145
+ throw new UnsupportedAgentError(agentId);
146
+ }
147
+ const config = getAgentConfig(agentId);
148
+ const configPath = resolveConfigPath(config, options.platform);
149
+ if (config.format === "yaml") {
150
+ const document = await readYamlConfig(configPath, options);
151
+ const { changed, content } = removeServer(document, config.configKey, serverName);
152
+ if (!changed) {
153
+ return;
154
+ }
155
+ await writeYamlConfig(configPath, content, options);
156
+ return;
157
+ }
158
+ await runMutations([
159
+ configMutation.prune({
160
+ target: configPath,
161
+ format: config.format,
162
+ shape: {
163
+ [config.configKey]: {
164
+ [serverName]: {}
165
+ }
166
+ },
167
+ label: `Remove ${serverName} from ${configPath}`
168
+ })
169
+ ], {
170
+ fs: options.fs,
171
+ homeDir: options.homeDir,
172
+ dryRun: options.dryRun,
173
+ observers: options.observers
174
+ });
175
+ }
@@ -0,0 +1,22 @@
1
+ import type { ShapeName } from "./shapes.js";
2
+ export type ConfigFormat = "json" | "toml" | "yaml";
3
+ export type Platform = "darwin" | "linux" | "win32";
4
+ export interface AgentMcpConfig {
5
+ configFile: string | ((platform: Platform) => string);
6
+ configKey: string;
7
+ format: ConfigFormat;
8
+ shape: ShapeName;
9
+ mcpOutputFormat?: string;
10
+ }
11
+ export declare const supportedAgents: readonly string[];
12
+ export type AgentSupportStatus = "supported" | "unsupported" | "unknown";
13
+ export interface AgentSupportResult {
14
+ status: AgentSupportStatus;
15
+ input: string;
16
+ id?: string;
17
+ config?: AgentMcpConfig;
18
+ }
19
+ export declare function resolveAgentSupport(input: string, registry?: Record<string, AgentMcpConfig>): AgentSupportResult;
20
+ export declare function isSupported(agentId: string): boolean;
21
+ export declare function getAgentConfig(agentId: string): AgentMcpConfig | undefined;
22
+ export declare function resolveConfigPath(config: AgentMcpConfig, platform: Platform): string;
@@ -0,0 +1,74 @@
1
+ import { resolveAgentId } from "@poe-code/agent-defs";
2
+ const agentMcpConfigs = {
3
+ "claude-code": {
4
+ configFile: "~/.claude.json",
5
+ configKey: "mcpServers",
6
+ format: "json",
7
+ shape: "standard"
8
+ },
9
+ "claude-desktop": {
10
+ configFile: (platform) => {
11
+ switch (platform) {
12
+ case "darwin":
13
+ return "~/Library/Application Support/Claude/claude_desktop_config.json";
14
+ case "win32":
15
+ return "~/AppData/Roaming/Claude/claude_desktop_config.json";
16
+ default:
17
+ return "~/.config/Claude/claude_desktop_config.json";
18
+ }
19
+ },
20
+ configKey: "mcpServers",
21
+ format: "json",
22
+ shape: "standard",
23
+ mcpOutputFormat: "markdown_instructions"
24
+ },
25
+ codex: {
26
+ configFile: "~/.codex/config.toml",
27
+ configKey: "mcp_servers",
28
+ format: "toml",
29
+ shape: "standard"
30
+ },
31
+ opencode: {
32
+ configFile: "~/.config/opencode/opencode.json",
33
+ configKey: "mcp",
34
+ format: "json",
35
+ shape: "opencode"
36
+ },
37
+ kimi: {
38
+ configFile: "~/.kimi/mcp.json",
39
+ configKey: "mcpServers",
40
+ format: "json",
41
+ shape: "standard"
42
+ },
43
+ goose: {
44
+ configFile: "~/.config/goose/config.yaml",
45
+ configKey: "extensions",
46
+ format: "yaml",
47
+ shape: "goose"
48
+ }
49
+ };
50
+ export const supportedAgents = Object.keys(agentMcpConfigs);
51
+ export function resolveAgentSupport(input, registry = agentMcpConfigs) {
52
+ const resolvedId = resolveAgentId(input);
53
+ if (!resolvedId) {
54
+ return { status: "unknown", input };
55
+ }
56
+ const config = registry[resolvedId];
57
+ if (!config) {
58
+ return { status: "unsupported", input, id: resolvedId };
59
+ }
60
+ return { status: "supported", input, id: resolvedId, config };
61
+ }
62
+ export function isSupported(agentId) {
63
+ return resolveAgentSupport(agentId).status === "supported";
64
+ }
65
+ export function getAgentConfig(agentId) {
66
+ const support = resolveAgentSupport(agentId);
67
+ return support.status === "supported" ? support.config : undefined;
68
+ }
69
+ export function resolveConfigPath(config, platform) {
70
+ if (typeof config.configFile === "function") {
71
+ return config.configFile(platform);
72
+ }
73
+ return config.configFile;
74
+ }
@@ -0,0 +1,3 @@
1
+ export type { McpStdioServer, McpHttpServer, McpServerConfig, McpServerEntry, ApplyOptions } from "./types.js";
2
+ export { supportedAgents, isSupported, resolveAgentSupport } from "./configs.js";
3
+ export { configure, unconfigure, UnsupportedAgentError } from "./apply.js";
@@ -0,0 +1,2 @@
1
+ export { supportedAgents, isSupported, resolveAgentSupport } from "./configs.js";
2
+ export { configure, unconfigure, UnsupportedAgentError } from "./apply.js";
@@ -0,0 +1,31 @@
1
+ import type { McpServerEntry } from "./types.js";
2
+ export type ShapeName = "standard" | "opencode" | "goose";
3
+ export interface StandardShapeOutput {
4
+ command: string;
5
+ args?: string[];
6
+ env?: Record<string, string>;
7
+ }
8
+ export interface OpencodeShapeOutput {
9
+ type: "local";
10
+ command: string[];
11
+ env?: Record<string, string>;
12
+ enabled: boolean;
13
+ }
14
+ export interface GooseStdioShapeOutput {
15
+ type: "stdio";
16
+ cmd: string;
17
+ args?: string[];
18
+ envs?: Record<string, string>;
19
+ }
20
+ export interface GooseHttpShapeOutput {
21
+ type: "http";
22
+ url: string;
23
+ headers?: Record<string, string>;
24
+ }
25
+ export type GooseShapeOutput = GooseStdioShapeOutput | GooseHttpShapeOutput;
26
+ export type ShapeOutput = StandardShapeOutput | OpencodeShapeOutput | GooseShapeOutput;
27
+ export type ShapeTransformer = (entry: McpServerEntry) => ShapeOutput | undefined;
28
+ export declare function standardShape(entry: McpServerEntry): ShapeOutput | undefined;
29
+ export declare function opencodeShape(entry: McpServerEntry): OpencodeShapeOutput;
30
+ export declare function gooseShape(entry: McpServerEntry): GooseShapeOutput | undefined;
31
+ export declare function getShapeTransformer(shape: ShapeName): ShapeTransformer;
@@ -0,0 +1,87 @@
1
+ function transformStdioServer(config, enabled) {
2
+ if (!enabled) {
3
+ return undefined;
4
+ }
5
+ const result = {
6
+ command: config.command
7
+ };
8
+ if (config.args && config.args.length > 0) {
9
+ result.args = config.args;
10
+ }
11
+ if (config.env && Object.keys(config.env).length > 0) {
12
+ result.env = config.env;
13
+ }
14
+ return result;
15
+ }
16
+ export function standardShape(entry) {
17
+ const enabled = entry.enabled !== false;
18
+ if (entry.config.transport === "stdio") {
19
+ return transformStdioServer(entry.config, enabled);
20
+ }
21
+ if (!enabled) {
22
+ return undefined;
23
+ }
24
+ return {
25
+ command: entry.config.url
26
+ };
27
+ }
28
+ function transformStdioServerOpencode(config, enabled) {
29
+ const command = config.args && config.args.length > 0
30
+ ? [config.command, ...config.args]
31
+ : [config.command];
32
+ const result = {
33
+ type: "local",
34
+ command,
35
+ enabled
36
+ };
37
+ if (config.env && Object.keys(config.env).length > 0) {
38
+ result.env = config.env;
39
+ }
40
+ return result;
41
+ }
42
+ export function opencodeShape(entry) {
43
+ const enabled = entry.enabled !== false;
44
+ if (entry.config.transport === "stdio") {
45
+ return transformStdioServerOpencode(entry.config, enabled);
46
+ }
47
+ return {
48
+ type: "local",
49
+ command: [entry.config.url],
50
+ enabled
51
+ };
52
+ }
53
+ export function gooseShape(entry) {
54
+ const enabled = entry.enabled !== false;
55
+ if (!enabled) {
56
+ return undefined;
57
+ }
58
+ if (entry.config.transport === "stdio") {
59
+ const result = {
60
+ type: "stdio",
61
+ cmd: entry.config.command
62
+ };
63
+ if (entry.config.args && entry.config.args.length > 0) {
64
+ result.args = entry.config.args;
65
+ }
66
+ if (entry.config.env && Object.keys(entry.config.env).length > 0) {
67
+ result.envs = entry.config.env;
68
+ }
69
+ return result;
70
+ }
71
+ const result = {
72
+ type: "http",
73
+ url: entry.config.url
74
+ };
75
+ if (entry.config.headers && Object.keys(entry.config.headers).length > 0) {
76
+ result.headers = entry.config.headers;
77
+ }
78
+ return result;
79
+ }
80
+ const shapeTransformers = {
81
+ standard: standardShape,
82
+ opencode: opencodeShape,
83
+ goose: gooseShape
84
+ };
85
+ export function getShapeTransformer(shape) {
86
+ return shapeTransformers[shape];
87
+ }
@@ -0,0 +1,25 @@
1
+ import type { FileSystem, MutationObservers } from "../../config-mutations/dist/index.js";
2
+ export interface McpStdioServer {
3
+ transport: "stdio";
4
+ command: string;
5
+ args?: string[];
6
+ env?: Record<string, string>;
7
+ }
8
+ export interface McpHttpServer {
9
+ transport: "http";
10
+ url: string;
11
+ headers?: Record<string, string>;
12
+ }
13
+ export type McpServerConfig = McpStdioServer | McpHttpServer;
14
+ export interface McpServerEntry {
15
+ name: string;
16
+ config: McpServerConfig;
17
+ enabled?: boolean;
18
+ }
19
+ export interface ApplyOptions {
20
+ fs: FileSystem;
21
+ homeDir: string;
22
+ platform: "darwin" | "linux" | "win32";
23
+ dryRun?: boolean;
24
+ observers?: MutationObservers;
25
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { ApplyOptions, SkillFile } from "./types.js";
2
+ export declare class UnsupportedAgentError extends Error {
3
+ constructor(agentId: string);
4
+ }
5
+ export declare function configure(agentId: string, options: ApplyOptions): Promise<void>;
6
+ export declare function unconfigure(agentId: string, options: ApplyOptions & {
7
+ force?: boolean;
8
+ }): Promise<void>;
9
+ export type InstallSkillOptions = {
10
+ fs: ApplyOptions["fs"];
11
+ cwd: string;
12
+ homeDir: string;
13
+ scope: ApplyOptions["scope"];
14
+ dryRun?: boolean;
15
+ observers?: ApplyOptions["observers"];
16
+ };
17
+ export type InstallSkillResult = {
18
+ skillPath: string;
19
+ displayPath: string;
20
+ };
21
+ /**
22
+ * Install a skill for an agent.
23
+ * Creates folder structure: skillDir/<skill.name>/SKILL.md
24
+ */
25
+ export declare function installSkill(agentId: string, skill: SkillFile, options: InstallSkillOptions): Promise<InstallSkillResult>;
@@ -0,0 +1,109 @@
1
+ import { fileMutation, runMutations, templateMutation } from "@poe-code/config-mutations";
2
+ import { resolveAgentSupport } from "./configs.js";
3
+ import { createTemplateLoader } from "./templates.js";
4
+ export class UnsupportedAgentError extends Error {
5
+ constructor(agentId) {
6
+ super(`Unsupported agent: ${agentId}`);
7
+ this.name = "UnsupportedAgentError";
8
+ }
9
+ }
10
+ function toHomeRelative(localSkillDir) {
11
+ if (localSkillDir.startsWith("~/") || localSkillDir === "~") {
12
+ return localSkillDir;
13
+ }
14
+ const normalized = localSkillDir.startsWith("./")
15
+ ? localSkillDir.slice(2)
16
+ : localSkillDir;
17
+ return `~/${normalized}`;
18
+ }
19
+ const bundledSkillTemplateIds = ["poe-generate.md"];
20
+ export async function configure(agentId, options) {
21
+ const support = resolveAgentSupport(agentId);
22
+ if (support.status !== "supported") {
23
+ throw new UnsupportedAgentError(agentId);
24
+ }
25
+ const scope = options.scope ?? "global";
26
+ const config = support.config;
27
+ const skillDir = scope === "global" ? config.globalSkillDir : toHomeRelative(config.localSkillDir);
28
+ const homeDir = scope === "global" ? options.homeDir : options.cwd;
29
+ await runMutations([
30
+ fileMutation.ensureDirectory({
31
+ path: skillDir,
32
+ label: `Ensure directory ${skillDir}`
33
+ }),
34
+ ...bundledSkillTemplateIds.map((templateId) => templateMutation.write({
35
+ target: `${skillDir}/${templateId}`,
36
+ templateId,
37
+ label: `Write bundled skill ${templateId} to ${skillDir}`
38
+ }))
39
+ ], {
40
+ fs: options.fs,
41
+ homeDir,
42
+ dryRun: options.dryRun,
43
+ observers: options.observers,
44
+ templates: createTemplateLoader()
45
+ });
46
+ }
47
+ export async function unconfigure(agentId, options) {
48
+ const support = resolveAgentSupport(agentId);
49
+ if (support.status !== "supported") {
50
+ throw new UnsupportedAgentError(agentId);
51
+ }
52
+ const scope = options.scope ?? "global";
53
+ const config = support.config;
54
+ const skillDir = scope === "global" ? config.globalSkillDir : toHomeRelative(config.localSkillDir);
55
+ const homeDir = scope === "global" ? options.homeDir : options.cwd;
56
+ await runMutations([
57
+ fileMutation.removeDirectory({
58
+ path: skillDir,
59
+ force: options.force,
60
+ label: `Remove skills directory ${skillDir}`
61
+ })
62
+ ], {
63
+ fs: options.fs,
64
+ homeDir,
65
+ dryRun: options.dryRun,
66
+ observers: options.observers
67
+ });
68
+ }
69
+ const SKILL_TEMPLATE_ID = "__skill_content__";
70
+ /**
71
+ * Install a skill for an agent.
72
+ * Creates folder structure: skillDir/<skill.name>/SKILL.md
73
+ */
74
+ export async function installSkill(agentId, skill, options) {
75
+ const support = resolveAgentSupport(agentId);
76
+ if (support.status !== "supported") {
77
+ throw new UnsupportedAgentError(agentId);
78
+ }
79
+ const scope = options.scope ?? "local";
80
+ const config = support.config;
81
+ // Use home-relative paths for mutations (same pattern as configure/unconfigure)
82
+ const skillDir = scope === "global" ? config.globalSkillDir : toHomeRelative(config.localSkillDir);
83
+ const skillFolderPath = `${skillDir}/${skill.name}`;
84
+ const skillFilePath = `${skillFolderPath}/SKILL.md`;
85
+ const displayPath = `${scope === "global" ? config.globalSkillDir : config.localSkillDir}/${skill.name}/SKILL.md`;
86
+ await runMutations([
87
+ fileMutation.ensureDirectory({
88
+ path: skillFolderPath,
89
+ label: `Ensure skill directory ${skill.name}`
90
+ }),
91
+ templateMutation.write({
92
+ target: skillFilePath,
93
+ templateId: SKILL_TEMPLATE_ID,
94
+ label: `Write skill ${skill.name}`
95
+ })
96
+ ], {
97
+ fs: options.fs,
98
+ homeDir: scope === "global" ? options.homeDir : options.cwd,
99
+ dryRun: options.dryRun,
100
+ observers: options.observers,
101
+ templates: async (templateId) => {
102
+ if (templateId === SKILL_TEMPLATE_ID) {
103
+ return skill.content;
104
+ }
105
+ throw new Error(`Unknown template: ${templateId}`);
106
+ }
107
+ });
108
+ return { skillPath: skillFilePath, displayPath };
109
+ }
@@ -0,0 +1,16 @@
1
+ export interface AgentSkillConfig {
2
+ globalSkillDir: string;
3
+ localSkillDir: string;
4
+ }
5
+ export type SkillScope = "global" | "local";
6
+ export declare const supportedAgents: readonly string[];
7
+ export type AgentSupportStatus = "supported" | "unsupported" | "unknown";
8
+ export interface AgentSupportResult {
9
+ status: AgentSupportStatus;
10
+ input: string;
11
+ id?: string;
12
+ config?: AgentSkillConfig;
13
+ }
14
+ export declare function resolveAgentSupport(input: string, registry?: Record<string, AgentSkillConfig>): AgentSupportResult;
15
+ export declare function getAgentConfig(agentId: string): AgentSkillConfig | undefined;
16
+ export declare function resolveSkillDir(config: AgentSkillConfig, scope: SkillScope, cwd: string): string;
@@ -0,0 +1,66 @@
1
+ import os from "node:os";
2
+ import path from "node:path";
3
+ import { resolveAgentId } from "@poe-code/agent-defs";
4
+ const agentSkillConfigs = {
5
+ "claude-code": {
6
+ globalSkillDir: "~/.claude/skills",
7
+ localSkillDir: ".claude/skills"
8
+ },
9
+ codex: {
10
+ globalSkillDir: "~/.codex/skills",
11
+ localSkillDir: ".codex/skills"
12
+ },
13
+ opencode: {
14
+ globalSkillDir: "~/.config/opencode/skills",
15
+ localSkillDir: ".opencode/skills"
16
+ },
17
+ goose: {
18
+ globalSkillDir: "~/.agents/skills",
19
+ localSkillDir: ".agents/skills"
20
+ }
21
+ };
22
+ export const supportedAgents = Object.keys(agentSkillConfigs);
23
+ export function resolveAgentSupport(input, registry = agentSkillConfigs) {
24
+ const resolvedId = resolveAgentId(input);
25
+ if (!resolvedId) {
26
+ return { status: "unknown", input };
27
+ }
28
+ const config = registry[resolvedId];
29
+ if (!config) {
30
+ return { status: "unsupported", input, id: resolvedId };
31
+ }
32
+ return { status: "supported", input, id: resolvedId, config };
33
+ }
34
+ export function getAgentConfig(agentId) {
35
+ const support = resolveAgentSupport(agentId);
36
+ return support.status === "supported" ? support.config : undefined;
37
+ }
38
+ function expandHome(targetPath) {
39
+ if (!targetPath?.startsWith("~")) {
40
+ return targetPath;
41
+ }
42
+ if (targetPath === "~") {
43
+ return os.homedir();
44
+ }
45
+ // Handle ~./ -> ~/.
46
+ if (targetPath.startsWith("~./")) {
47
+ targetPath = `~/.${targetPath.slice(3)}`;
48
+ }
49
+ let remainder = targetPath.slice(1);
50
+ if (remainder.startsWith("/") || remainder.startsWith("\\")) {
51
+ remainder = remainder.slice(1);
52
+ }
53
+ else if (remainder.startsWith(".")) {
54
+ remainder = remainder.slice(1);
55
+ if (remainder.startsWith("/") || remainder.startsWith("\\")) {
56
+ remainder = remainder.slice(1);
57
+ }
58
+ }
59
+ return remainder.length === 0 ? os.homedir() : path.join(os.homedir(), remainder);
60
+ }
61
+ export function resolveSkillDir(config, scope, cwd) {
62
+ if (scope === "global") {
63
+ return path.resolve(expandHome(config.globalSkillDir));
64
+ }
65
+ return path.resolve(cwd, config.localSkillDir);
66
+ }
@@ -0,0 +1,5 @@
1
+ export type { AgentSkillConfig, AgentSupportResult, AgentSupportStatus, SkillScope } from "./configs.js";
2
+ export type { ApplyOptions, SkillFile } from "./types.js";
3
+ export { supportedAgents, resolveAgentSupport, getAgentConfig, resolveSkillDir } from "./configs.js";
4
+ export { configure, unconfigure, installSkill, UnsupportedAgentError } from "./apply.js";
5
+ export type { InstallSkillOptions, InstallSkillResult } from "./apply.js";
@@ -0,0 +1,2 @@
1
+ export { supportedAgents, resolveAgentSupport, getAgentConfig, resolveSkillDir } from "./configs.js";
2
+ export { configure, unconfigure, installSkill, UnsupportedAgentError } from "./apply.js";