toolcraft 0.0.5 → 0.0.7

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 (149) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +77 -59
  4. package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.d.ts +2 -0
  5. package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +15 -0
  6. package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.d.ts +2 -0
  7. package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +13 -0
  8. package/node_modules/@poe-code/agent-defs/dist/agents/codex.d.ts +2 -0
  9. package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +14 -0
  10. package/node_modules/@poe-code/agent-defs/dist/agents/goose.d.ts +2 -0
  11. package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +14 -0
  12. package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +7 -0
  13. package/node_modules/@poe-code/agent-defs/dist/agents/index.js +7 -0
  14. package/node_modules/@poe-code/agent-defs/dist/agents/kimi.d.ts +2 -0
  15. package/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +15 -0
  16. package/node_modules/@poe-code/agent-defs/dist/agents/opencode.d.ts +2 -0
  17. package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +14 -0
  18. package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.d.ts +2 -0
  19. package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +13 -0
  20. package/node_modules/@poe-code/agent-defs/dist/index.d.ts +5 -0
  21. package/node_modules/@poe-code/agent-defs/dist/index.js +3 -0
  22. package/node_modules/@poe-code/agent-defs/dist/registry.d.ts +3 -0
  23. package/node_modules/@poe-code/agent-defs/dist/registry.js +26 -0
  24. package/node_modules/@poe-code/agent-defs/dist/specifier.d.ts +7 -0
  25. package/node_modules/@poe-code/agent-defs/dist/specifier.js +27 -0
  26. package/node_modules/@poe-code/agent-defs/dist/types.d.ts +16 -0
  27. package/node_modules/@poe-code/agent-defs/dist/types.js +1 -0
  28. package/node_modules/@poe-code/agent-defs/package.json +20 -0
  29. package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.d.ts +5 -0
  30. package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +552 -0
  31. package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +17 -0
  32. package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +58 -0
  33. package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.d.ts +7 -0
  34. package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.js +46 -0
  35. package/node_modules/@poe-code/config-mutations/dist/formats/index.d.ts +13 -0
  36. package/node_modules/@poe-code/config-mutations/dist/formats/index.js +49 -0
  37. package/node_modules/@poe-code/config-mutations/dist/formats/json.d.ts +31 -0
  38. package/node_modules/@poe-code/config-mutations/dist/formats/json.js +140 -0
  39. package/node_modules/@poe-code/config-mutations/dist/formats/toml.d.ts +2 -0
  40. package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +72 -0
  41. package/node_modules/@poe-code/config-mutations/dist/formats/yaml.d.ts +2 -0
  42. package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +73 -0
  43. package/node_modules/@poe-code/config-mutations/dist/fs-utils.d.ts +18 -0
  44. package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +45 -0
  45. package/node_modules/@poe-code/config-mutations/dist/index.d.ts +8 -0
  46. package/node_modules/@poe-code/config-mutations/dist/index.js +8 -0
  47. package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
  48. package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.js +34 -0
  49. package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.d.ts +52 -0
  50. package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.js +46 -0
  51. package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
  52. package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.js +32 -0
  53. package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +7 -0
  54. package/node_modules/@poe-code/config-mutations/dist/template/render.js +28 -0
  55. package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.d.ts +7 -0
  56. package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.js +21 -0
  57. package/node_modules/@poe-code/config-mutations/dist/testing/index.d.ts +3 -0
  58. package/node_modules/@poe-code/config-mutations/dist/testing/index.js +2 -0
  59. package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +25 -0
  60. package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +170 -0
  61. package/node_modules/@poe-code/config-mutations/dist/types.d.ts +156 -0
  62. package/node_modules/@poe-code/config-mutations/dist/types.js +6 -0
  63. package/node_modules/@poe-code/config-mutations/package.json +33 -0
  64. package/node_modules/@poe-code/file-lock/README.md +52 -0
  65. package/node_modules/@poe-code/file-lock/dist/index.d.ts +1 -0
  66. package/node_modules/@poe-code/file-lock/dist/index.js +1 -0
  67. package/node_modules/@poe-code/file-lock/dist/lock.d.ts +27 -0
  68. package/node_modules/@poe-code/file-lock/dist/lock.js +203 -0
  69. package/node_modules/@poe-code/file-lock/package.json +23 -0
  70. package/node_modules/auth-store/README.md +47 -0
  71. package/node_modules/auth-store/dist/create-secret-store.d.ts +2 -0
  72. package/node_modules/auth-store/dist/create-secret-store.js +35 -0
  73. package/node_modules/auth-store/dist/encrypted-file-store.d.ts +39 -0
  74. package/node_modules/auth-store/dist/encrypted-file-store.js +156 -0
  75. package/node_modules/auth-store/dist/index.d.ts +7 -0
  76. package/node_modules/auth-store/dist/index.js +4 -0
  77. package/node_modules/auth-store/dist/keychain-store.d.ts +22 -0
  78. package/node_modules/auth-store/dist/keychain-store.js +111 -0
  79. package/node_modules/auth-store/dist/provider-store.d.ts +10 -0
  80. package/node_modules/auth-store/dist/provider-store.js +28 -0
  81. package/node_modules/auth-store/dist/types.d.ts +20 -0
  82. package/node_modules/auth-store/dist/types.js +1 -0
  83. package/node_modules/auth-store/package.json +25 -0
  84. package/node_modules/mcp-oauth/README.md +31 -0
  85. package/node_modules/mcp-oauth/dist/client/auth-store-session-store.d.ts +14 -0
  86. package/node_modules/mcp-oauth/dist/client/auth-store-session-store.js +97 -0
  87. package/node_modules/mcp-oauth/dist/client/authorization-state.d.ts +8 -0
  88. package/node_modules/mcp-oauth/dist/client/authorization-state.js +34 -0
  89. package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.d.ts +3 -0
  90. package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +491 -0
  91. package/node_modules/mcp-oauth/dist/client/loopback-authorization.d.ts +20 -0
  92. package/node_modules/mcp-oauth/dist/client/loopback-authorization.js +169 -0
  93. package/node_modules/mcp-oauth/dist/client/pkce.d.ts +2 -0
  94. package/node_modules/mcp-oauth/dist/client/pkce.js +7 -0
  95. package/node_modules/mcp-oauth/dist/client/token-endpoint.d.ts +40 -0
  96. package/node_modules/mcp-oauth/dist/client/token-endpoint.js +143 -0
  97. package/node_modules/mcp-oauth/dist/client/types.d.ts +113 -0
  98. package/node_modules/mcp-oauth/dist/client/types.js +1 -0
  99. package/node_modules/mcp-oauth/dist/index.d.ts +10 -0
  100. package/node_modules/mcp-oauth/dist/index.js +7 -0
  101. package/node_modules/mcp-oauth/dist/resource-indicator.d.ts +1 -0
  102. package/node_modules/mcp-oauth/dist/resource-indicator.js +11 -0
  103. package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.d.ts +27 -0
  104. package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.js +259 -0
  105. package/node_modules/mcp-oauth/dist/types.compile-check.d.ts +1 -0
  106. package/node_modules/mcp-oauth/dist/types.compile-check.js +22 -0
  107. package/node_modules/mcp-oauth/package.json +31 -0
  108. package/node_modules/tiny-mcp-client/.turbo/turbo-build.log +4 -0
  109. package/node_modules/tiny-mcp-client/dist/index.d.ts +2 -0
  110. package/node_modules/tiny-mcp-client/dist/index.js +1 -0
  111. package/node_modules/tiny-mcp-client/dist/internal.d.ts +547 -0
  112. package/node_modules/tiny-mcp-client/dist/internal.js +2404 -0
  113. package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.d.ts +1 -0
  114. package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.js +37 -0
  115. package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.d.ts +1 -0
  116. package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.js +50 -0
  117. package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.d.ts +1 -0
  118. package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.js +50 -0
  119. package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.d.ts +1 -0
  120. package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.js +51 -0
  121. package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.d.ts +1 -0
  122. package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.js +89 -0
  123. package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.d.ts +1 -0
  124. package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.js +56 -0
  125. package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.d.ts +1 -0
  126. package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.js +145 -0
  127. package/node_modules/tiny-mcp-client/dist/oauth-discovery.d.ts +24 -0
  128. package/node_modules/tiny-mcp-client/dist/oauth-discovery.js +385 -0
  129. package/node_modules/tiny-mcp-client/package.json +22 -0
  130. package/node_modules/tiny-mcp-client/src/http-oauth.integration.test.ts +823 -0
  131. package/node_modules/tiny-mcp-client/src/http-oauth.test.ts +882 -0
  132. package/node_modules/tiny-mcp-client/src/index.ts +94 -0
  133. package/node_modules/tiny-mcp-client/src/internal.ts +3566 -0
  134. package/node_modules/tiny-mcp-client/src/jsonrpc-types.compile-check.ts +66 -0
  135. package/node_modules/tiny-mcp-client/src/mcp-client-http-transport.integration.test.ts +222 -0
  136. package/node_modules/tiny-mcp-client/src/mcp-client-sdk.test.ts +1294 -0
  137. package/node_modules/tiny-mcp-client/src/mcp-client-tiny-stdio-test-server-tools.test.ts +143 -0
  138. package/node_modules/tiny-mcp-client/src/mcp-lifecycle-types.compile-check.ts +65 -0
  139. package/node_modules/tiny-mcp-client/src/mcp-prompt-types.compile-check.ts +66 -0
  140. package/node_modules/tiny-mcp-client/src/mcp-resource-types.compile-check.ts +70 -0
  141. package/node_modules/tiny-mcp-client/src/mcp-tool-types.compile-check.ts +117 -0
  142. package/node_modules/tiny-mcp-client/src/mcp-transport-types.compile-check.ts +75 -0
  143. package/node_modules/tiny-mcp-client/src/mcp-utility-types.compile-check.ts +181 -0
  144. package/node_modules/tiny-mcp-client/src/mock-servers.test.ts +980 -0
  145. package/node_modules/tiny-mcp-client/src/oauth-discovery.ts +583 -0
  146. package/node_modules/tiny-mcp-client/src/transports.test.ts +8139 -0
  147. package/node_modules/tiny-mcp-client/src/utilities.test.ts +372 -0
  148. package/node_modules/tiny-mcp-client/tsconfig.json +11 -0
  149. package/package.json +24 -11
package/README.md CHANGED
@@ -441,6 +441,7 @@ If you have an existing MCP server you want to keep running, use the MCP proxy:
441
441
  - `casing?: "kebab" | "snake"` — generated CLI flag style.
442
442
  - `services?: TServices` — merged into every handler context.
443
443
  - `version?: string` — surfaced via `--version`.
444
+ - `presets?: boolean` — enables `--preset <path>` for loading parameter defaults from JSON files.
444
445
  - `apiVersion?: string` — for `requires.apiVersion`.
445
446
  - `humanInLoop?: HumanInLoopRuntimeOptions`
446
447
 
package/dist/cli.d.ts CHANGED
@@ -9,6 +9,7 @@ export interface RunCLIOptions<TServices extends object = Record<string, unknown
9
9
  rootUsageName?: string;
10
10
  services?: TServices;
11
11
  version?: string;
12
+ presets?: boolean;
12
13
  }
13
14
  export declare function runCLI<TServices extends object = Record<string, unknown>>(roots: Group<TServices> | Group<TServices>[], options?: RunCLIOptions<TServices>): Promise<void>;
14
15
  export {};
package/dist/cli.js CHANGED
@@ -126,7 +126,7 @@ function getRequiredBranchFingerprint(branch, casing) {
126
126
  .sort();
127
127
  return requiredKeys.join("+");
128
128
  }
129
- function collectFields(schema, casing, path = [], inheritedOptional = false, variantContext) {
129
+ function collectFields(schema, casing, globalLongOptionFlags, path = [], inheritedOptional = false, variantContext) {
130
130
  const collected = {
131
131
  dynamicFields: [],
132
132
  fields: [],
@@ -138,7 +138,7 @@ function collectFields(schema, casing, path = [], inheritedOptional = false, var
138
138
  const childSchema = unwrapOptional(rawChildSchema);
139
139
  const requiredWhenActive = rawChildSchema.kind !== "optional" && childSchema.default === undefined;
140
140
  if (childSchema.kind === "object") {
141
- const nested = collectFields(childSchema, casing, nextPath, runtimeOptional, variantContext);
141
+ const nested = collectFields(childSchema, casing, globalLongOptionFlags, nextPath, runtimeOptional, variantContext);
142
142
  collected.dynamicFields.push(...nested.dynamicFields);
143
143
  collected.fields.push(...nested.fields);
144
144
  collected.variants.push(...nested.variants);
@@ -152,7 +152,7 @@ function collectFields(schema, casing, path = [], inheritedOptional = false, var
152
152
  path: [...nextPath, childSchema.discriminator],
153
153
  displayPath: toDisplayPath([...nextPath, childSchema.discriminator]),
154
154
  optionAttribute: toOptionAttribute([...nextPath, childSchema.discriminator], casing),
155
- commanderOptionAttribute: toCommanderOptionAttribute([...nextPath, childSchema.discriminator], casing),
155
+ commanderOptionAttribute: toCommanderOptionAttribute([...nextPath, childSchema.discriminator], casing, globalLongOptionFlags),
156
156
  optionFlag: toOptionFlag([...nextPath, childSchema.discriminator], casing),
157
157
  shortFlag: undefined,
158
158
  schema: createSyntheticEnumSchema(branchIds),
@@ -165,7 +165,7 @@ function collectFields(schema, casing, path = [], inheritedOptional = false, var
165
165
  collected.fields.push(controlField);
166
166
  const branches = [];
167
167
  for (const [branchId, branchSchema] of Object.entries(childSchema.branches)) {
168
- const branch = collectFields(branchSchema, casing, nextPath, true, {
168
+ const branch = collectFields(branchSchema, casing, globalLongOptionFlags, nextPath, true, {
169
169
  id: variantId,
170
170
  branchId,
171
171
  });
@@ -203,7 +203,7 @@ function collectFields(schema, casing, path = [], inheritedOptional = false, var
203
203
  path: controlPath,
204
204
  displayPath: controlDisplayPath,
205
205
  optionAttribute: toOptionAttribute(controlPath, casing),
206
- commanderOptionAttribute: toCommanderOptionAttribute(controlPath, casing),
206
+ commanderOptionAttribute: toCommanderOptionAttribute(controlPath, casing, globalLongOptionFlags),
207
207
  optionFlag: toOptionFlag(controlPath, casing),
208
208
  shortFlag: undefined,
209
209
  schema: createSyntheticEnumSchema(branchIds),
@@ -218,7 +218,7 @@ function collectFields(schema, casing, path = [], inheritedOptional = false, var
218
218
  const branches = [];
219
219
  childSchema.branches.forEach((branchSchema, index) => {
220
220
  const branchId = branchIds[index] ?? "";
221
- const branch = collectFields(branchSchema, casing, nextPath, true, {
221
+ const branch = collectFields(branchSchema, casing, globalLongOptionFlags, nextPath, true, {
222
222
  id: variantId,
223
223
  branchId,
224
224
  });
@@ -289,7 +289,7 @@ function collectFields(schema, casing, path = [], inheritedOptional = false, var
289
289
  path: nextPath,
290
290
  displayPath: toDisplayPath(nextPath),
291
291
  optionAttribute: toOptionAttribute(nextPath, casing),
292
- commanderOptionAttribute: toCommanderOptionAttribute(nextPath, casing),
292
+ commanderOptionAttribute: toCommanderOptionAttribute(nextPath, casing, globalLongOptionFlags),
293
293
  optionFlag: toOptionFlag(nextPath, casing),
294
294
  shortFlag: childSchema.short,
295
295
  schema: childSchema,
@@ -304,10 +304,10 @@ function collectFields(schema, casing, path = [], inheritedOptional = false, var
304
304
  }
305
305
  return collected;
306
306
  }
307
- function toCommanderOptionAttribute(path, casing) {
307
+ function toCommanderOptionAttribute(path, casing, globalLongOptionFlags) {
308
308
  const optionAttribute = toOptionAttribute(path, casing);
309
309
  const optionFlag = toOptionFlag(path, casing);
310
- if (!GLOBAL_LONG_OPTION_FLAGS.has(optionFlag)) {
310
+ if (!globalLongOptionFlags.has(optionFlag)) {
311
311
  return optionAttribute;
312
312
  }
313
313
  return `param_${optionAttribute}`;
@@ -337,8 +337,8 @@ function assignPositionals(fields, positional) {
337
337
  });
338
338
  return fields;
339
339
  }
340
- function formatOptionFlags(field) {
341
- const collidesWithGlobalFlag = GLOBAL_LONG_OPTION_FLAGS.has(field.optionFlag);
340
+ function formatOptionFlags(field, globalLongOptionFlags) {
341
+ const collidesWithGlobalFlag = globalLongOptionFlags.has(field.optionFlag);
342
342
  if (collidesWithGlobalFlag) {
343
343
  if (field.shortFlag === undefined) {
344
344
  throw new UserError(`Parameter "${field.displayPath}" uses reserved CLI flag "${field.optionFlag}". Add a short flag or rename the parameter.`);
@@ -449,9 +449,9 @@ function parseArrayValue(value, schema, label) {
449
449
  }
450
450
  return splitArrayInput(value).map((item) => parseScalarValue(item, itemSchema, label));
451
451
  }
452
- function createOption(field) {
453
- const flags = formatOptionFlags(field);
454
- const collidesWithGlobalFlag = GLOBAL_LONG_OPTION_FLAGS.has(field.optionFlag);
452
+ function createOption(field, globalLongOptionFlags) {
453
+ const flags = formatOptionFlags(field, globalLongOptionFlags);
454
+ const collidesWithGlobalFlag = globalLongOptionFlags.has(field.optionFlag);
455
455
  const commanderValue = (value) => (value === null ? NULL_OPTION_VALUE : value);
456
456
  if (field.schema.kind === "boolean") {
457
457
  if (collidesWithGlobalFlag) {
@@ -489,7 +489,10 @@ function createOption(field) {
489
489
  option.argParser((value) => commanderValue(parseScalarValue(value, field.schema, field.displayPath)));
490
490
  return [option];
491
491
  }
492
- const GLOBAL_LONG_OPTION_FLAGS = new Set(["--preset", "--yes", "--output", "--verbose"]);
492
+ const ALWAYS_GLOBAL_LONG_OPTION_FLAGS = ["--yes", "--output", "--verbose"];
493
+ function getGlobalLongOptionFlags(presetsEnabled) {
494
+ return new Set(presetsEnabled ? ["--preset", ...ALWAYS_GLOBAL_LONG_OPTION_FLAGS] : ALWAYS_GLOBAL_LONG_OPTION_FLAGS);
495
+ }
493
496
  function createCommanderOption(flags, description, field) {
494
497
  const option = new Option(flags, description);
495
498
  if (field.commanderOptionAttribute !== field.optionAttribute) {
@@ -580,14 +583,14 @@ function describeSchemaType(schema) {
580
583
  throw new UserError("Unsupported CLI schema kind.");
581
584
  }
582
585
  }
583
- function formatHelpFieldFlags(field) {
586
+ function formatHelpFieldFlags(field, globalLongOptionFlags) {
584
587
  if (field.positionalIndex !== undefined) {
585
588
  return formatPositionalToken(field);
586
589
  }
587
590
  if (field.schema.kind === "boolean") {
588
- return `${formatOptionFlags(field)} [value]`;
591
+ return `${formatOptionFlags(field, globalLongOptionFlags)} [value]`;
589
592
  }
590
- return `${formatOptionFlags(field)} <${describeSchemaType(field.schema)}>`;
593
+ return `${formatOptionFlags(field, globalLongOptionFlags)} <${describeSchemaType(field.schema)}>`;
591
594
  }
592
595
  function appendHelpMetadata(description, metadata) {
593
596
  if (metadata.length === 0) {
@@ -711,31 +714,40 @@ function formatSecretDescription(secret) {
711
714
  }
712
715
  return secret.optional === true ? "Optional secret" : "Required secret";
713
716
  }
714
- function formatCommandRows(group, scope) {
715
- return getVisibleChildren(group, scope).map((child) => ({
716
- name: child.aliases.length === 0 ? child.name : `${child.name} (${child.aliases.join(", ")})`,
717
- description: child.description ?? "",
718
- }));
717
+ function formatCommandRowName(node, depth) {
718
+ const name = node.aliases.length === 0 ? node.name : `${node.name} (${node.aliases.join(", ")})`;
719
+ return `${" ".repeat(depth)}${name}`;
720
+ }
721
+ function formatCommandRows(group, scope, depth = 0) {
722
+ return getVisibleChildren(group, scope).flatMap((child) => {
723
+ const row = {
724
+ name: formatCommandRowName(child, depth),
725
+ description: child.description ?? "",
726
+ };
727
+ if (child.kind === "command") {
728
+ return [row];
729
+ }
730
+ return [row, ...formatCommandRows(child, scope, depth + 1)];
731
+ });
719
732
  }
720
- function formatGlobalOptionRows(showVersion) {
721
- const rows = [
722
- {
733
+ function formatGlobalOptionRows(showVersion, presetsEnabled) {
734
+ const rows = [];
735
+ if (presetsEnabled) {
736
+ rows.push({
723
737
  flags: "--preset <path>",
724
738
  description: "Load parameter defaults from a JSON file",
725
- },
726
- {
727
- flags: "--yes",
728
- description: "Accept defaults, skip prompts",
729
- },
730
- {
731
- flags: "--output <format>",
732
- description: "Output format (rich, md, json)",
733
- },
734
- {
735
- flags: "-h, --help",
736
- description: "Show help",
737
- },
738
- ];
739
+ });
740
+ }
741
+ rows.push({
742
+ flags: "--yes",
743
+ description: "Accept defaults, skip prompts",
744
+ }, {
745
+ flags: "--output <format>",
746
+ description: "Output format (rich, md, json)",
747
+ }, {
748
+ flags: "-h, --help",
749
+ description: "Show help",
750
+ });
739
751
  if (showVersion) {
740
752
  rows.push({
741
753
  flags: "--version",
@@ -754,13 +766,13 @@ function buildUsageLine(breadcrumb, rootUsageName, suffix) {
754
766
  const subPath = breadcrumb.slice(1).join(" ");
755
767
  return subPath ? `${rootUsageName} ${subPath} ${suffix}` : `${rootUsageName} ${suffix}`;
756
768
  }
757
- function renderGroupHelp(group, breadcrumb, scope, showVersion, rootUsageName) {
769
+ function renderGroupHelp(group, breadcrumb, scope, showVersion, presetsEnabled, rootUsageName) {
758
770
  const sections = [];
759
771
  const commandRows = formatCommandRows(group, scope);
760
772
  if (commandRows.length > 0) {
761
773
  sections.push(`${text.section("Commands:")}\n${formatCommandList(commandRows)}`);
762
774
  }
763
- sections.push(`${text.section("Global options:")}\n${formatOptionList(formatGlobalOptionRows(showVersion))}`);
775
+ sections.push(`${text.section("Global options:")}\n${formatOptionList(formatGlobalOptionRows(showVersion, presetsEnabled))}`);
764
776
  return renderHelpDocument({
765
777
  breadcrumb,
766
778
  usageLine: buildUsageLine(breadcrumb, rootUsageName, "[options] [command]"),
@@ -769,18 +781,19 @@ function renderGroupHelp(group, breadcrumb, scope, showVersion, rootUsageName) {
769
781
  sections,
770
782
  });
771
783
  }
772
- function renderLeafHelp(command, breadcrumb, casing, rootUsageName) {
784
+ function renderLeafHelp(command, breadcrumb, casing, presetsEnabled, rootUsageName) {
773
785
  const sections = [];
774
- const collected = collectFields(command.params, casing);
786
+ const globalLongOptionFlags = getGlobalLongOptionFlags(presetsEnabled);
787
+ const collected = collectFields(command.params, casing, globalLongOptionFlags);
775
788
  const fields = assignPositionals(collected.fields, command.positional);
776
789
  const optionRows = fields.map((field) => ({
777
- flags: formatHelpFieldFlags(field),
790
+ flags: formatHelpFieldFlags(field, globalLongOptionFlags),
778
791
  description: formatHelpFieldDescription(field),
779
792
  })).concat(collected.dynamicFields.flatMap((field) => formatDynamicHelpFields(field, casing)));
780
793
  if (optionRows.length > 0) {
781
794
  sections.push(`${text.section("Options:")}\n${formatOptionList(optionRows)}`);
782
795
  }
783
- sections.push(`${text.section("Global options:")}\n${formatOptionList(formatGlobalOptionRows(false))}`);
796
+ sections.push(`${text.section("Global options:")}\n${formatOptionList(formatGlobalOptionRows(false, presetsEnabled))}`);
784
797
  const secretRows = formatSecretRows(command.secrets);
785
798
  if (secretRows.length > 0) {
786
799
  sections.push(`${text.section("Secrets (via environment):")}\n${formatOptionList(secretRows)}`);
@@ -820,26 +833,26 @@ async function renderGeneratedHelp(root, argv, options) {
820
833
  const casing = options.casing ?? "kebab";
821
834
  await withOutputFormat(output, async () => {
822
835
  const rendered = target.node.kind === "group"
823
- ? renderGroupHelp(target.node, target.breadcrumb, "cli", options.version !== undefined, options.rootUsageName)
824
- : renderLeafHelp(target.node, target.breadcrumb, casing, options.rootUsageName);
836
+ ? renderGroupHelp(target.node, target.breadcrumb, "cli", options.version !== undefined, options.presets === true, options.rootUsageName)
837
+ : renderLeafHelp(target.node, target.breadcrumb, casing, options.presets === true, options.rootUsageName);
825
838
  process.stdout.write(rendered);
826
839
  });
827
840
  }
828
- function createNodeCommand(node, casing, execute, pathSegments = []) {
841
+ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presetsEnabled, pathSegments = []) {
829
842
  const nextPathSegments = [...pathSegments, node.name];
830
843
  if (node.kind === "command") {
831
844
  if (!node.scope.includes("cli")) {
832
845
  return null;
833
846
  }
834
847
  const command = new CommanderCommand(node.name);
835
- const collected = collectFields(node.params, casing);
848
+ const collected = collectFields(node.params, casing, globalLongOptionFlags);
836
849
  const fields = assignPositionals(collected.fields, node.positional);
837
850
  if (node.description !== undefined) {
838
851
  command.description(node.description);
839
852
  }
840
853
  node.aliases.forEach((alias) => command.alias(alias));
841
854
  command.addHelpCommand(false);
842
- addGlobalOptions(command);
855
+ addGlobalOptions(command, presetsEnabled);
843
856
  command.allowExcessArguments(true);
844
857
  if (collected.dynamicFields.length > 0) {
845
858
  command.allowUnknownOption(true);
@@ -849,7 +862,7 @@ function createNodeCommand(node, casing, execute, pathSegments = []) {
849
862
  command.argument(formatPositionalToken(field));
850
863
  continue;
851
864
  }
852
- for (const option of createOption(field)) {
865
+ for (const option of createOption(field, globalLongOptionFlags)) {
853
866
  command.addOption(option);
854
867
  }
855
868
  }
@@ -863,6 +876,7 @@ function createNodeCommand(node, casing, execute, pathSegments = []) {
863
876
  dynamicFields: collected.dynamicFields,
864
877
  fields,
865
878
  positionalValues,
879
+ presetsEnabled,
866
880
  rawArgv: actionCommand.args,
867
881
  actionCommand,
868
882
  variants: collected.variants,
@@ -874,7 +888,7 @@ function createNodeCommand(node, casing, execute, pathSegments = []) {
874
888
  return null;
875
889
  }
876
890
  const visibleChildren = node.children
877
- .map((child) => createNodeCommand(child, casing, execute, nextPathSegments))
891
+ .map((child) => createNodeCommand(child, casing, globalLongOptionFlags, execute, presetsEnabled, nextPathSegments))
878
892
  .filter((child) => child !== null);
879
893
  const group = new CommanderCommand(node.name);
880
894
  if (node.description !== undefined) {
@@ -882,7 +896,7 @@ function createNodeCommand(node, casing, execute, pathSegments = []) {
882
896
  }
883
897
  node.aliases.forEach((alias) => group.alias(alias));
884
898
  group.addHelpCommand(false);
885
- addGlobalOptions(group);
899
+ addGlobalOptions(group, presetsEnabled);
886
900
  for (const child of visibleChildren) {
887
901
  const isDefaultChild = node.default !== undefined &&
888
902
  node.default.scope.includes("cli") &&
@@ -891,9 +905,11 @@ function createNodeCommand(node, casing, execute, pathSegments = []) {
891
905
  }
892
906
  return group;
893
907
  }
894
- function addGlobalOptions(command) {
908
+ function addGlobalOptions(command, presetsEnabled) {
909
+ if (presetsEnabled) {
910
+ command.option("--preset <path>", "Load parameter defaults from a JSON file.");
911
+ }
895
912
  command
896
- .option("--preset <path>", "Load parameter defaults from a JSON file.")
897
913
  .option("--yes", "Accept defaults and skip prompts.")
898
914
  .option("--output <format>", "Output format.", (value) => {
899
915
  if (value === "rich" || value === "md" || value === "json") {
@@ -1927,7 +1943,7 @@ async function executeCommand(state, services, requirementOptions, runtimeOption
1927
1943
  };
1928
1944
  await withOutputFormat(output, async () => {
1929
1945
  await assertCommandRequirements(state.command, preflightContext, runtime.requirementOptions);
1930
- const params = await resolveParams(state.fields, state.dynamicFields, state.variants, state.positionalValues, optionValues, state.rawArgv, state.casing, resolvedFlags.preset, shouldPrompt);
1946
+ const params = await resolveParams(state.fields, state.dynamicFields, state.variants, state.positionalValues, optionValues, state.rawArgv, state.casing, state.presetsEnabled ? resolvedFlags.preset : undefined, shouldPrompt);
1931
1947
  const context = {
1932
1948
  ...preflightContext,
1933
1949
  params,
@@ -2010,7 +2026,9 @@ export async function runCLI(roots, options = {}) {
2010
2026
  program.exitOverride();
2011
2027
  program.showHelpAfterError();
2012
2028
  program.addHelpCommand(false);
2013
- addGlobalOptions(program);
2029
+ const presetsEnabled = options.presets === true;
2030
+ const globalLongOptionFlags = getGlobalLongOptionFlags(presetsEnabled);
2031
+ addGlobalOptions(program, presetsEnabled);
2014
2032
  if (version !== undefined) {
2015
2033
  program.version(version, "--version");
2016
2034
  }
@@ -2020,7 +2038,7 @@ export async function runCLI(roots, options = {}) {
2020
2038
  await executeCommand(state, servicesWithBuiltIns, requirementOptions, runtimeOptions);
2021
2039
  };
2022
2040
  for (const child of root.children) {
2023
- const command = createNodeCommand(child, casing, execute);
2041
+ const command = createNodeCommand(child, casing, globalLongOptionFlags, execute, presetsEnabled);
2024
2042
  if (command === null) {
2025
2043
  continue;
2026
2044
  }
@@ -0,0 +1,2 @@
1
+ import type { AgentDefinition } from "../types.js";
2
+ export declare const claudeCodeAgent: AgentDefinition;
@@ -0,0 +1,15 @@
1
+ export const claudeCodeAgent = {
2
+ id: "claude-code",
3
+ name: "claude-code",
4
+ label: "Claude Code",
5
+ summary: "Configure Claude Code to route through Poe.",
6
+ aliases: ["claude"],
7
+ binaryName: "claude",
8
+ configPath: "~/.claude/settings.json",
9
+ branding: {
10
+ colors: {
11
+ dark: "#C15F3C",
12
+ light: "#C15F3C"
13
+ }
14
+ }
15
+ };
@@ -0,0 +1,2 @@
1
+ import type { AgentDefinition } from "../types.js";
2
+ export declare const claudeDesktopAgent: AgentDefinition;
@@ -0,0 +1,13 @@
1
+ export const claudeDesktopAgent = {
2
+ id: "claude-desktop",
3
+ name: "claude-desktop",
4
+ label: "Claude Desktop",
5
+ summary: "Anthropic's official desktop application for Claude",
6
+ configPath: "~/.claude/settings.json",
7
+ branding: {
8
+ colors: {
9
+ dark: "#D97757",
10
+ light: "#D97757"
11
+ }
12
+ }
13
+ };
@@ -0,0 +1,2 @@
1
+ import type { AgentDefinition } from "../types.js";
2
+ export declare const codexAgent: AgentDefinition;
@@ -0,0 +1,14 @@
1
+ export const codexAgent = {
2
+ id: "codex",
3
+ name: "codex",
4
+ label: "Codex",
5
+ summary: "Configure Codex to use Poe as the model provider.",
6
+ binaryName: "codex",
7
+ configPath: "~/.codex/config.toml",
8
+ branding: {
9
+ colors: {
10
+ dark: "#D5D9DF",
11
+ light: "#7A7F86"
12
+ }
13
+ }
14
+ };
@@ -0,0 +1,2 @@
1
+ import type { AgentDefinition } from "../types.js";
2
+ export declare const gooseAgent: AgentDefinition;
@@ -0,0 +1,14 @@
1
+ export const gooseAgent = {
2
+ id: "goose",
3
+ name: "goose",
4
+ label: "Goose",
5
+ summary: "Block's open-source AI agent with ACP support.",
6
+ binaryName: "goose",
7
+ configPath: "~/.config/goose/config.yaml",
8
+ branding: {
9
+ colors: {
10
+ dark: "#FF6B35",
11
+ light: "#E85D26"
12
+ }
13
+ }
14
+ };
@@ -0,0 +1,7 @@
1
+ export { claudeCodeAgent } from "./claude-code.js";
2
+ export { claudeDesktopAgent } from "./claude-desktop.js";
3
+ export { codexAgent } from "./codex.js";
4
+ export { openCodeAgent } from "./opencode.js";
5
+ export { kimiAgent } from "./kimi.js";
6
+ export { gooseAgent } from "./goose.js";
7
+ export { poeAgentAgent } from "./poe-agent.js";
@@ -0,0 +1,7 @@
1
+ export { claudeCodeAgent } from "./claude-code.js";
2
+ export { claudeDesktopAgent } from "./claude-desktop.js";
3
+ export { codexAgent } from "./codex.js";
4
+ export { openCodeAgent } from "./opencode.js";
5
+ export { kimiAgent } from "./kimi.js";
6
+ export { gooseAgent } from "./goose.js";
7
+ export { poeAgentAgent } from "./poe-agent.js";
@@ -0,0 +1,2 @@
1
+ import type { AgentDefinition } from "../types.js";
2
+ export declare const kimiAgent: AgentDefinition;
@@ -0,0 +1,15 @@
1
+ export const kimiAgent = {
2
+ id: "kimi",
3
+ name: "kimi",
4
+ label: "Kimi",
5
+ summary: "Configure Kimi CLI to use Poe API",
6
+ aliases: ["kimi-cli"],
7
+ binaryName: "kimi",
8
+ configPath: "~/.kimi/config.toml",
9
+ branding: {
10
+ colors: {
11
+ dark: "#7B68EE",
12
+ light: "#6A5ACD"
13
+ }
14
+ }
15
+ };
@@ -0,0 +1,2 @@
1
+ import type { AgentDefinition } from "../types.js";
2
+ export declare const openCodeAgent: AgentDefinition;
@@ -0,0 +1,14 @@
1
+ export const openCodeAgent = {
2
+ id: "opencode",
3
+ name: "opencode",
4
+ label: "OpenCode CLI",
5
+ summary: "Configure OpenCode CLI to use the Poe API.",
6
+ binaryName: "opencode",
7
+ configPath: "~/.config/opencode/config.json",
8
+ branding: {
9
+ colors: {
10
+ dark: "#4A4F55",
11
+ light: "#2F3338"
12
+ }
13
+ }
14
+ };
@@ -0,0 +1,2 @@
1
+ import type { AgentDefinition } from "../types.js";
2
+ export declare const poeAgentAgent: AgentDefinition;
@@ -0,0 +1,13 @@
1
+ export const poeAgentAgent = {
2
+ id: "poe-agent",
3
+ name: "poe-agent",
4
+ label: "Poe Agent",
5
+ summary: "Run one-shot prompts with the built-in Poe agent runtime.",
6
+ configPath: "~/.poe-code/config.json",
7
+ branding: {
8
+ colors: {
9
+ dark: "#A465F7",
10
+ light: "#7A3FD3"
11
+ }
12
+ }
13
+ };
@@ -0,0 +1,5 @@
1
+ export type { AgentDefinition } from "./types.js";
2
+ export type { AgentSpecifier } from "./specifier.js";
3
+ export { claudeCodeAgent, claudeDesktopAgent, codexAgent, openCodeAgent, kimiAgent, gooseAgent, poeAgentAgent } from "./agents/index.js";
4
+ export { allAgents, resolveAgentId } from "./registry.js";
5
+ export { parseAgentSpecifier, formatAgentSpecifier, normalizeAgentId } from "./specifier.js";
@@ -0,0 +1,3 @@
1
+ export { claudeCodeAgent, claudeDesktopAgent, codexAgent, openCodeAgent, kimiAgent, gooseAgent, poeAgentAgent } from "./agents/index.js";
2
+ export { allAgents, resolveAgentId } from "./registry.js";
3
+ export { parseAgentSpecifier, formatAgentSpecifier, normalizeAgentId } from "./specifier.js";
@@ -0,0 +1,3 @@
1
+ import type { AgentDefinition } from "./types.js";
2
+ export declare const allAgents: AgentDefinition[];
3
+ export declare function resolveAgentId(input: string): string | undefined;
@@ -0,0 +1,26 @@
1
+ import { claudeCodeAgent, claudeDesktopAgent, codexAgent, openCodeAgent, kimiAgent, gooseAgent, poeAgentAgent } from "./agents/index.js";
2
+ export const allAgents = [
3
+ claudeCodeAgent,
4
+ claudeDesktopAgent,
5
+ codexAgent,
6
+ openCodeAgent,
7
+ kimiAgent,
8
+ gooseAgent,
9
+ poeAgentAgent
10
+ ];
11
+ const lookup = new Map();
12
+ for (const agent of allAgents) {
13
+ const values = [agent.id, agent.name, ...(agent.aliases ?? [])];
14
+ for (const value of values) {
15
+ const normalized = value.toLowerCase();
16
+ if (!lookup.has(normalized)) {
17
+ lookup.set(normalized, agent.id);
18
+ }
19
+ }
20
+ }
21
+ export function resolveAgentId(input) {
22
+ if (!input) {
23
+ return undefined;
24
+ }
25
+ return lookup.get(input.toLowerCase());
26
+ }
@@ -0,0 +1,7 @@
1
+ export interface AgentSpecifier {
2
+ agent: string;
3
+ model?: string;
4
+ }
5
+ export declare function parseAgentSpecifier(input: string): AgentSpecifier;
6
+ export declare function formatAgentSpecifier(specifier: AgentSpecifier): string;
7
+ export declare function normalizeAgentId(input: string): string;
@@ -0,0 +1,27 @@
1
+ import { resolveAgentId } from "./registry.js";
2
+ export function parseAgentSpecifier(input) {
3
+ const colonIndex = input.indexOf(":");
4
+ if (colonIndex === -1) {
5
+ return { agent: input.trim() };
6
+ }
7
+ const agent = input.slice(0, colonIndex).trim();
8
+ const model = input.slice(colonIndex + 1).trim();
9
+ return {
10
+ agent,
11
+ ...(model.length > 0 ? { model } : {}),
12
+ };
13
+ }
14
+ export function formatAgentSpecifier(specifier) {
15
+ if (specifier.model) {
16
+ return `${specifier.agent}:${specifier.model}`;
17
+ }
18
+ return specifier.agent;
19
+ }
20
+ export function normalizeAgentId(input) {
21
+ const specifier = parseAgentSpecifier(input.trim());
22
+ const agent = resolveAgentId(specifier.agent) ?? specifier.agent;
23
+ return formatAgentSpecifier({
24
+ agent,
25
+ model: specifier.model
26
+ });
27
+ }
@@ -0,0 +1,16 @@
1
+ export interface AgentDefinition {
2
+ id: string;
3
+ name: string;
4
+ label: string;
5
+ summary: string;
6
+ aliases?: string[];
7
+ /** Binary name for CLI agents. Optional for GUI-only apps like Claude Desktop. */
8
+ binaryName?: string;
9
+ configPath: string;
10
+ branding: {
11
+ colors: {
12
+ dark: string;
13
+ light: string;
14
+ };
15
+ };
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@poe-code/agent-defs",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "tsc"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ]
20
+ }
@@ -0,0 +1,5 @@
1
+ import type { Mutation, MutationContext, MutationOutcome, MutationDetails, MutationOptions } from "../types.js";
2
+ export declare function applyMutation(mutation: Mutation, context: MutationContext, options: MutationOptions): Promise<{
3
+ outcome: MutationOutcome;
4
+ details: MutationDetails;
5
+ }>;