goke 6.6.0 → 6.6.1

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/dist/coerce.d.ts CHANGED
@@ -78,13 +78,35 @@ export declare namespace StandardJSONSchemaV1 {
78
78
  /**
79
79
  * Wraps a plain JSON Schema object into a StandardJSONSchemaV1-compatible object.
80
80
  *
81
- * @internal This is an internal helper used by @goke/mcp to wrap MCP tool schemas.
82
- * Users should pass Zod or other StandardSchema-compatible schemas to `.option()`.
81
+ * Originally built for @goke/mcp to wrap MCP tool schemas, but also useful for
82
+ * any consumer that has a hand-written JSON Schema (e.g. an array of strings
83
+ * or a tagged union) and wants goke's `.action()` callback to infer the right
84
+ * option type without reaching for Zod. Pass an explicit `Output` type
85
+ * parameter to tell TypeScript what the coerced value will look like at
86
+ * runtime — goke does not validate the output shape, it just propagates it
87
+ * into the inferred options type for `.action()` callbacks.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * cli
92
+ * .command('diff', 'Show diff')
93
+ * .option(
94
+ * '--filter <glob>',
95
+ * wrapJsonSchema<string[]>({
96
+ * type: 'array',
97
+ * items: { type: 'string' },
98
+ * description: 'Glob pattern (repeatable)',
99
+ * }),
100
+ * )
101
+ * .action((options) => {
102
+ * // options.filter: string[] | undefined
103
+ * })
104
+ * ```
83
105
  *
84
106
  * @param jsonSchema - A plain JSON Schema object (e.g. `{ type: "number" }`)
85
107
  * @returns A StandardJSONSchemaV1-compatible object that Goke can use for coercion
86
108
  */
87
- export declare function wrapJsonSchema(jsonSchema: Record<string, unknown>): StandardJSONSchemaV1;
109
+ export declare function wrapJsonSchema<Output = unknown>(jsonSchema: Record<string, unknown>): StandardJSONSchemaV1<unknown, Output>;
88
110
  /** Minimal JSON Schema interface — only what we need for CLI coercion. */
89
111
  export interface JsonSchema {
90
112
  type?: string | string[];
@@ -1 +1 @@
1
- {"version":3,"file":"coerce.d.ts","sourceRoot":"","sources":["../src/coerce.ts"],"names":[],"mappings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OAAO,CAAA;CAAE,CAcrI"}
package/dist/coerce.js CHANGED
@@ -50,8 +50,30 @@ export class GokeError extends Error {
50
50
  /**
51
51
  * Wraps a plain JSON Schema object into a StandardJSONSchemaV1-compatible object.
52
52
  *
53
- * @internal This is an internal helper used by @goke/mcp to wrap MCP tool schemas.
54
- * Users should pass Zod or other StandardSchema-compatible schemas to `.option()`.
53
+ * Originally built for @goke/mcp to wrap MCP tool schemas, but also useful for
54
+ * any consumer that has a hand-written JSON Schema (e.g. an array of strings
55
+ * or a tagged union) and wants goke's `.action()` callback to infer the right
56
+ * option type without reaching for Zod. Pass an explicit `Output` type
57
+ * parameter to tell TypeScript what the coerced value will look like at
58
+ * runtime — goke does not validate the output shape, it just propagates it
59
+ * into the inferred options type for `.action()` callbacks.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * cli
64
+ * .command('diff', 'Show diff')
65
+ * .option(
66
+ * '--filter <glob>',
67
+ * wrapJsonSchema<string[]>({
68
+ * type: 'array',
69
+ * items: { type: 'string' },
70
+ * description: 'Glob pattern (repeatable)',
71
+ * }),
72
+ * )
73
+ * .action((options) => {
74
+ * // options.filter: string[] | undefined
75
+ * })
76
+ * ```
55
77
  *
56
78
  * @param jsonSchema - A plain JSON Schema object (e.g. `{ type: "number" }`)
57
79
  * @returns A StandardJSONSchemaV1-compatible object that Goke can use for coercion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goke",
3
- "version": "6.6.0",
3
+ "version": "6.6.1",
4
4
  "type": "module",
5
5
  "description": "Simple yet powerful framework for building command-line apps. Inspired by cac.",
6
6
  "repository": {
package/src/coerce.ts CHANGED
@@ -127,13 +127,37 @@ export declare namespace StandardJSONSchemaV1 {
127
127
  /**
128
128
  * Wraps a plain JSON Schema object into a StandardJSONSchemaV1-compatible object.
129
129
  *
130
- * @internal This is an internal helper used by @goke/mcp to wrap MCP tool schemas.
131
- * Users should pass Zod or other StandardSchema-compatible schemas to `.option()`.
130
+ * Originally built for @goke/mcp to wrap MCP tool schemas, but also useful for
131
+ * any consumer that has a hand-written JSON Schema (e.g. an array of strings
132
+ * or a tagged union) and wants goke's `.action()` callback to infer the right
133
+ * option type without reaching for Zod. Pass an explicit `Output` type
134
+ * parameter to tell TypeScript what the coerced value will look like at
135
+ * runtime — goke does not validate the output shape, it just propagates it
136
+ * into the inferred options type for `.action()` callbacks.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * cli
141
+ * .command('diff', 'Show diff')
142
+ * .option(
143
+ * '--filter <glob>',
144
+ * wrapJsonSchema<string[]>({
145
+ * type: 'array',
146
+ * items: { type: 'string' },
147
+ * description: 'Glob pattern (repeatable)',
148
+ * }),
149
+ * )
150
+ * .action((options) => {
151
+ * // options.filter: string[] | undefined
152
+ * })
153
+ * ```
132
154
  *
133
155
  * @param jsonSchema - A plain JSON Schema object (e.g. `{ type: "number" }`)
134
156
  * @returns A StandardJSONSchemaV1-compatible object that Goke can use for coercion
135
157
  */
136
- export function wrapJsonSchema(jsonSchema: Record<string, unknown>): StandardJSONSchemaV1 {
158
+ export function wrapJsonSchema<Output = unknown>(
159
+ jsonSchema: Record<string, unknown>,
160
+ ): StandardJSONSchemaV1<unknown, Output> {
137
161
  return {
138
162
  "~standard": {
139
163
  version: 1,