poe-code 3.0.380 → 3.0.381

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": "3.0.380",
3
+ "version": "3.0.381",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -130,7 +130,9 @@ export function generate(document, options) {
130
130
  })
131
131
  })),
132
132
  createIndexFile(commands),
133
- createCliFile({ brand, label })
133
+ createClientFile(),
134
+ createCliFile({ brand, label }),
135
+ createMcpFile()
134
136
  ];
135
137
  }
136
138
  export function collectGeneratedCommands(document, config) {
@@ -1849,18 +1851,73 @@ function createIndexFile(commands) {
1849
1851
  contents: lines.join("\n")
1850
1852
  };
1851
1853
  }
1854
+ function createClientFile() {
1855
+ return {
1856
+ path: "client.ts",
1857
+ contents: createGeneratedTypeScriptFile([
1858
+ 'import { defineClient, type DefineClientOptions } from "toolcraft-openapi";',
1859
+ 'import { generatedCommands } from "./index.js";',
1860
+ "",
1861
+ 'export type GeneratedClientOptions = Omit<DefineClientOptions<object>, "commands">;',
1862
+ "",
1863
+ "export function defineGeneratedClient(options: GeneratedClientOptions) {",
1864
+ " return defineClient<object>({",
1865
+ " ...options,",
1866
+ " commands: [...generatedCommands],",
1867
+ " });",
1868
+ "}",
1869
+ ""
1870
+ ])
1871
+ };
1872
+ }
1852
1873
  function createCliFile(theme) {
1853
1874
  return {
1854
1875
  path: "cli.ts",
1855
1876
  contents: [
1856
1877
  "#!/usr/bin/env node",
1857
1878
  ...createGeneratedTypeScriptFileLines(),
1858
- 'import { configureTheme, runCLI } from "toolcraft/cli";',
1859
- 'import { generatedCommands } from "./index.js";',
1879
+ 'import { configureTheme, runCLI, type RunCLIOptions } from "toolcraft/cli";',
1880
+ 'import type { OpenApiClientServices } from "toolcraft-openapi";',
1881
+ 'import { defineGeneratedClient, type GeneratedClientOptions } from "./client.js";',
1882
+ "",
1883
+ "export type GeneratedCLIOptions = GeneratedClientOptions &",
1884
+ ' Omit<RunCLIOptions<OpenApiClientServices>, "services">;',
1885
+ "",
1886
+ "export async function runGeneratedCLI(options: GeneratedCLIOptions) {",
1887
+ " const client = defineGeneratedClient(options);",
1888
+ ` configureTheme({ brand: ${JSON.stringify(theme.brand)}, label: ${JSON.stringify(theme.label)} });`,
1889
+ "",
1890
+ " await runCLI(client.root, {",
1891
+ " ...options,",
1892
+ " services: client.services,",
1893
+ " });",
1894
+ "}",
1895
+ ""
1896
+ ].join("\n")
1897
+ };
1898
+ }
1899
+ function createMcpFile() {
1900
+ return {
1901
+ path: "mcp.ts",
1902
+ contents: [
1903
+ "#!/usr/bin/env node",
1904
+ ...createGeneratedTypeScriptFileLines(),
1905
+ 'import { runMCP, type RunMCPOptions } from "toolcraft/mcp";',
1906
+ 'import type { OpenApiClientServices } from "toolcraft-openapi";',
1907
+ 'import { defineGeneratedClient, type GeneratedClientOptions } from "./client.js";',
1908
+ "",
1909
+ "export type GeneratedMCPOptions = GeneratedClientOptions &",
1910
+ ' Omit<RunMCPOptions<OpenApiClientServices>, "name" | "services">;',
1860
1911
  "",
1861
- `configureTheme({ brand: ${JSON.stringify(theme.brand)}, label: ${JSON.stringify(theme.label)} });`,
1912
+ "export async function runGeneratedMCP(options: GeneratedMCPOptions) {",
1913
+ " const client = defineGeneratedClient(options);",
1862
1914
  "",
1863
- "await runCLI([...generatedCommands]);",
1915
+ " await runMCP(client.root, {",
1916
+ " ...options,",
1917
+ " name: client.name,",
1918
+ " services: client.services,",
1919
+ " });",
1920
+ "}",
1864
1921
  ""
1865
1922
  ].join("\n")
1866
1923
  };
@@ -0,0 +1,40 @@
1
+ import { S, defineGroup } from "toolcraft";
2
+ import { runCLI } from "toolcraft/cli";
3
+ import { runMCP } from "toolcraft/mcp";
4
+ import { defineApiCommand, defineClient } from "./index.js";
5
+ const generatedCommands = [
6
+ defineGroup({
7
+ name: "widgets",
8
+ children: [
9
+ defineApiCommand({
10
+ name: "list",
11
+ scope: ["cli", "mcp", "sdk"],
12
+ params: S.Object({}),
13
+ handler: async () => ({ ok: true })
14
+ })
15
+ ]
16
+ })
17
+ ];
18
+ function defineGeneratedClient(options) {
19
+ return defineClient({
20
+ ...options,
21
+ commands: [...generatedCommands]
22
+ });
23
+ }
24
+ async function runGeneratedCLI(options) {
25
+ const client = defineGeneratedClient(options);
26
+ await runCLI(client.root, {
27
+ ...options,
28
+ services: client.services
29
+ });
30
+ }
31
+ async function runGeneratedMCP(options) {
32
+ const client = defineGeneratedClient(options);
33
+ await runMCP(client.root, {
34
+ ...options,
35
+ name: client.name,
36
+ services: client.services
37
+ });
38
+ }
39
+ void runGeneratedCLI;
40
+ void runGeneratedMCP;
@@ -0,0 +1,4 @@
1
+ export declare const generatedWidgetListCommand: import("../../toolcraft/dist/index.js").Command<import("./define-client.js").OpenApiClientServices, import("../../toolcraft/dist/index.js").ObjectSchema<{}>, undefined, unknown>;
2
+ export declare const widgets: import("../../toolcraft/dist/index.js").Group<import("./define-client.js").OpenApiClientServices> & {
3
+ readonly __agentKitGroupTypeInfo: import("../../toolcraft/dist/index.js").GroupTypeInfo<import("./define-client.js").OpenApiClientServices, "widgets", import("../../toolcraft/dist/index.js").Command<import("./define-client.js").OpenApiClientServices, import("../../toolcraft/dist/index.js").ObjectSchema<{}>, undefined, unknown>[], undefined, undefined>;
4
+ };
@@ -0,0 +1,32 @@
1
+ import { S, defineGroup } from "toolcraft";
2
+ import { bearerTokenAuth, defineApiCommand, defineClient } from "./index.js";
3
+ export const generatedWidgetListCommand = defineApiCommand({
4
+ name: "list",
5
+ scope: ["cli", "mcp", "sdk"],
6
+ params: S.Object({}),
7
+ handler: async () => ({ ok: true })
8
+ });
9
+ export const widgets = defineGroup({
10
+ name: "widgets",
11
+ children: [generatedWidgetListCommand]
12
+ });
13
+ const clientWithGeneratedGroup = defineClient({
14
+ name: "manual-group-client",
15
+ baseUrl: "https://api.example.com",
16
+ auth: bearerTokenAuth({
17
+ serviceName: "manual-group-client",
18
+ envVar: "MANUAL_GROUP_CLIENT_TOKEN"
19
+ }),
20
+ commands: [widgets]
21
+ });
22
+ const clientWithGeneratedLeaf = defineClient({
23
+ name: "manual-leaf-client",
24
+ baseUrl: "https://api.example.com",
25
+ auth: bearerTokenAuth({
26
+ serviceName: "manual-leaf-client",
27
+ envVar: "MANUAL_LEAF_CLIENT_TOKEN"
28
+ }),
29
+ commands: [generatedWidgetListCommand]
30
+ });
31
+ void clientWithGeneratedGroup;
32
+ void clientWithGeneratedLeaf;