poe-code 4.0.8 → 4.0.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -199,7 +199,6 @@
199
199
  "mustache": "^4.2.0",
200
200
  "openai": "^6.34.0",
201
201
  "parse-duration": "^2.1.5",
202
- "poe-code": "^3.0.410",
203
202
  "semver": "^7.7.4",
204
203
  "shell-quote": "^1.8.4",
205
204
  "simple-git": "^3.36.0",
@@ -118,6 +118,7 @@ export interface GeneratedSkill {
118
118
  export interface GeneratedCommand {
119
119
  noun: string;
120
120
  verb: string;
121
+ topLevel: boolean;
121
122
  exportName: string;
122
123
  filePath: string;
123
124
  operationId: string;
@@ -154,6 +154,7 @@ function applyConfiguredCommandShape(commands, config) {
154
154
  }
155
155
  command.noun = createSafeGeneratedNoun(match.noun);
156
156
  command.verb = createSafeGeneratedVerb(match.verb);
157
+ command.topLevel = false;
157
158
  command.examples = config?.readme?.examples?.[match.exampleKey];
158
159
  applyConfiguredRawResponse(command);
159
160
  applyConfiguredIdempotency(command, match.method, config);
@@ -223,8 +224,12 @@ function createSafeGeneratedVerb(value) {
223
224
  return verb;
224
225
  }
225
226
  function refreshGeneratedCommandNames(command) {
226
- command.exportName = `${toCamelCase(command.noun)}${toPascalCase(command.verb)}Command`;
227
- command.filePath = `${command.noun}/${command.verb}.ts`;
227
+ command.exportName = command.topLevel
228
+ ? `${toCamelCase(command.verb)}Command`
229
+ : `${toCamelCase(command.noun)}${toPascalCase(command.verb)}Command`;
230
+ command.filePath = command.topLevel
231
+ ? `${command.verb}.ts`
232
+ : `${command.noun}/${command.verb}.ts`;
228
233
  }
229
234
  export function collectGeneratedCommand(document, path, method) {
230
235
  const normalizedDocument = normalizeOpenApiDocument(document);
@@ -264,15 +269,24 @@ function createGeneratedCommand(document, entry) {
264
269
  const auth = getOperationAuthMode(document, operation, operationId);
265
270
  const response = resolveSuccessResponse(document, operation, operationId);
266
271
  const noun = createSafeGeneratedNoun(deriveNoun(operation, entry.path, operationId));
267
- const verb = deriveVerb(entry.method, entry.path, operation, operationId, noun);
272
+ const derivedVerb = deriveVerb(entry.method, entry.path, operation, operationId, noun);
268
273
  const collected = collectParams(document, entry, operation, operationId, auth, response.mode);
269
274
  const positional = collectPathPositionals(entry.path, collected.params, operationId);
275
+ const topLevel = entry.method === "get" &&
276
+ operation.tags?.some((tag) => tag.length > 0) !== true &&
277
+ positional.length === 0 &&
278
+ derivedVerb === METHOD_DEFAULTS.get?.collection &&
279
+ normalizeNoun(operationId) === noun;
280
+ const verb = topLevel ? noun : derivedVerb;
270
281
  const methodDefaults = METHOD_DEFAULTS[entry.method];
271
- const exportName = `${toCamelCase(noun)}${toPascalCase(verb)}Command`;
272
- const filePath = `${noun}/${verb}.ts`;
282
+ const exportName = topLevel
283
+ ? `${toCamelCase(verb)}Command`
284
+ : `${toCamelCase(noun)}${toPascalCase(verb)}Command`;
285
+ const filePath = topLevel ? `${verb}.ts` : `${noun}/${verb}.ts`;
273
286
  return {
274
287
  noun,
275
288
  verb,
289
+ topLevel,
276
290
  exportName,
277
291
  filePath,
278
292
  operationId,
@@ -1859,19 +1873,20 @@ function collectTagDescriptions(document) {
1859
1873
  }
1860
1874
  function createIndexFile(commands, document) {
1861
1875
  const groups = groupByNoun(commands);
1876
+ const topLevelCommands = commands.filter((command) => command.topLevel);
1862
1877
  const tagDescriptions = collectTagDescriptions(document);
1863
- if (groups.length === 0) {
1878
+ if (commands.length === 0) {
1864
1879
  return {
1865
1880
  path: "index.ts",
1866
1881
  contents: createGeneratedTypeScriptFile(["export const generatedCommands = [] as const;", ""])
1867
1882
  };
1868
1883
  }
1869
1884
  const lines = createGeneratedTypeScriptFileLines();
1870
- lines.push('import { defineGroup } from "toolcraft";');
1871
- for (const { commands: nounCommands } of groups) {
1872
- for (const command of nounCommands) {
1873
- lines.push(`import { ${command.exportName} } from ${JSON.stringify(`./${command.filePath.replace(/\.ts$/, ".js")}`)};`);
1874
- }
1885
+ if (groups.length > 0) {
1886
+ lines.push('import { defineGroup } from "toolcraft";');
1887
+ }
1888
+ for (const command of [...topLevelCommands, ...groups.flatMap(({ commands }) => commands)]) {
1889
+ lines.push(`import { ${command.exportName} } from ${JSON.stringify(`./${command.filePath.replace(/\.ts$/, ".js")}`)};`);
1875
1890
  }
1876
1891
  if (lines.length > 1) {
1877
1892
  lines.push("");
@@ -1887,7 +1902,10 @@ function createIndexFile(commands, document) {
1887
1902
  lines.push("});");
1888
1903
  lines.push("");
1889
1904
  }
1890
- lines.push(`export const generatedCommands = [${groups.map(({ noun }) => toCamelCase(noun)).join(", ")}] as const;`);
1905
+ lines.push(`export const generatedCommands = [${[
1906
+ ...topLevelCommands.map((command) => command.exportName),
1907
+ ...groups.map(({ noun }) => toCamelCase(noun))
1908
+ ].join(", ")}] as const;`);
1891
1909
  lines.push("");
1892
1910
  return {
1893
1911
  path: "index.ts",
@@ -2075,8 +2093,7 @@ function renderSkillCommandCatalogLine(commandName, command) {
2075
2093
  function renderSkillCommandLine(commandName, command) {
2076
2094
  const parts = [
2077
2095
  commandName,
2078
- command.noun,
2079
- command.verb,
2096
+ ...(command.topLevel ? [command.verb] : [command.noun, command.verb]),
2080
2097
  ...command.positional.map((paramName) => `<${paramName}>`)
2081
2098
  ];
2082
2099
  const requiredFlags = command.params.filter((param) => !param.optional &&
@@ -1,6 +1,9 @@
1
1
  export function groupByNoun(commands) {
2
2
  const groups = new Map();
3
3
  for (const command of commands) {
4
+ if (command.topLevel) {
5
+ continue;
6
+ }
4
7
  const current = groups.get(command.noun);
5
8
  if (current === undefined) {
6
9
  groups.set(command.noun, [command]);
@@ -68,7 +68,7 @@ function createSupportedOperation(metadata, command) {
68
68
  return {
69
69
  ...metadata,
70
70
  status: "supported",
71
- commandPath: `${command.noun} ${command.verb}`
71
+ commandPath: command.topLevel ? command.verb : `${command.noun} ${command.verb}`
72
72
  };
73
73
  }
74
74
  function readOperationMetadata(path, method, operation) {