@joiner-platform/cli 0.1.16 → 0.1.17

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@joiner-platform/cli",
3
- "version": "0.1.16",
4
- "gitHead": "232db36a9e3d77c44fb2d44e40f52f6e82263b1e",
3
+ "version": "0.1.17",
4
+ "gitHead": "960c0d76e00310125672a371eae2d31766a1af8a",
5
5
  "description": "The Joiner CLI: create, test, and publish Joiner tiles, with agent skills for coding agents.",
6
6
  "keywords": [
7
7
  "joiner",
@@ -61,7 +61,7 @@ an older pin, so prefer the live result when upgrading:
61
61
 
62
62
  <!-- begin: sdk-tarball-snippet (auto-generated by packages/poe-tiles-sdk/scripts/publish-tar.ts — do not edit by hand) -->
63
63
  ```json
64
- "joiner-sdk": "https://misc-dev-uploads.quora-913.workers.dev/76306b6900592a9e0611bab2f46560b798c65ed8af6737a05c650acf17d59ac7"
64
+ "joiner-sdk": "https://misc-dev-uploads.quora-913.workers.dev/2ccea219f2bab1a49cd7f7f8bace347f4b248f916bc6db118833ae4ca0096c21"
65
65
  ```
66
66
  <!-- end: sdk-tarball-snippet -->
67
67
 
@@ -485,8 +485,9 @@ table. It exits non-zero when the user is not an active member.
485
485
  and prints CLI commands for checking access and dispatching each mutator and
486
486
  action. Each dispatch command carries an example `--input` built from that
487
487
  function's input schema: required fields only, with `"<fieldName>"` string
488
- placeholders and numbers at the nearest allowed value to `0`. Replace the
489
- placeholders before running it. When the input schema can't be read, or the
488
+ placeholders and numbers at an allowed value near `0`. Replace the
489
+ placeholders before running it. When the input schema can't be read, no number
490
+ fits its bounds, the schema is too large or deeply nested to walk, or the
490
491
  example would be too large for one shell argument (an array of more than 32
491
492
  items, or more than 1 KiB of JSON), the command shows `--input '<json>'` and
492
493
  its `--json` entry has no `inputExample`.
@@ -1,4 +1,4 @@
1
1
  // Auto-generated by poe-tiles-sdk/scripts/publish-tar.ts — do not edit
2
- // publishedAt: 2026-11-30T15:21:52.061Z
2
+ // publishedAt: 2026-11-30T16:31:28.359Z
3
3
  export const SDK_TARBALL_URL =
4
- "https://misc-dev-uploads.quora-913.workers.dev/76306b6900592a9e0611bab2f46560b798c65ed8af6737a05c650acf17d59ac7";
4
+ "https://misc-dev-uploads.quora-913.workers.dev/2ccea219f2bab1a49cd7f7f8bace347f4b248f916bc6db118833ae4ca0096c21";
@@ -13,6 +13,16 @@ const NO_EXAMPLE = Symbol("no-example");
13
13
  const MAX_EXAMPLE_JSON_BYTES = 1024;
14
14
  const MAX_ITEMS = 32;
15
15
 
16
+ /**
17
+ * Store authors can pass raw JSON Schema through `jsonSchema()`, so a schema
18
+ * may repeat subtrees or nest arbitrarily deep. These cap the walk; past
19
+ * either, the command falls back to `'<json>'`.
20
+ */
21
+ const MAX_VISITED_NODES = 10_000;
22
+ const MAX_DEPTH = 64;
23
+
24
+ type Walk = { visited: number };
25
+
16
26
  /**
17
27
  * Builds a minimal input that matches a mutator or action's JSON Schema, for
18
28
  * the copy-paste commands `stores schema` prints. Required object properties
@@ -26,7 +36,7 @@ const MAX_ITEMS = 32;
26
36
  export function exampleInputFromJsonSchema(
27
37
  schema: unknown,
28
38
  ): JSONValue | undefined {
29
- const example = withinLength(exampleFor(schema, "string"));
39
+ const example = withinLength(exampleFor(schema, "string", { visited: 0 }, 0));
30
40
  return example === NO_EXAMPLE ? undefined : example;
31
41
  }
32
42
 
@@ -43,7 +53,11 @@ function withinLength(
43
53
  function exampleFor(
44
54
  schema: unknown,
45
55
  label: string,
56
+ walk: Walk,
57
+ depth: number,
46
58
  ): JSONValue | typeof NO_EXAMPLE {
59
+ walk.visited += 1;
60
+ if (walk.visited > MAX_VISITED_NODES || depth > MAX_DEPTH) return NO_EXAMPLE;
47
61
  if (!isSchema(schema) || "def" in schema || "_zod" in schema) {
48
62
  return NO_EXAMPLE;
49
63
  }
@@ -53,8 +67,8 @@ function exampleFor(
53
67
  return enumValues[0] as JSONValue;
54
68
  }
55
69
  const branch = firstBranch(schema);
56
- if (branch !== undefined) return exampleFor(branch, label);
57
- return typedExample(schema, label);
70
+ if (branch !== undefined) return exampleFor(branch, label, walk, depth + 1);
71
+ return typedExample(schema, label, walk, depth);
58
72
  }
59
73
 
60
74
  function firstBranch(schema: Schema): unknown {
@@ -68,6 +82,8 @@ function firstBranch(schema: Schema): unknown {
68
82
  function typedExample(
69
83
  schema: Schema,
70
84
  label: string,
85
+ walk: Walk,
86
+ depth: number,
71
87
  ): JSONValue | typeof NO_EXAMPLE {
72
88
  const type = Array.isArray(schema["type"])
73
89
  ? schema["type"][0]
@@ -83,16 +99,64 @@ function typedExample(
83
99
  case "null":
84
100
  return null;
85
101
  case "array":
86
- return arrayExample(schema, label);
102
+ return arrayExample(schema, label, walk, depth);
87
103
  case "object":
88
- return objectExample(schema);
104
+ return objectExample(schema, walk, depth);
89
105
  default:
90
106
  return NO_EXAMPLE;
91
107
  }
92
108
  }
93
109
 
94
- /** 0, moved inside `minimum` / `maximum` and their exclusive forms. */
95
- function numberExample(schema: Schema, integer: boolean): number {
110
+ /**
111
+ * 0 moved inside `minimum` / `maximum` and their exclusive forms, else the
112
+ * midpoint of both bounds, each tried as is and snapped to `multipleOf`. No
113
+ * example when none of those satisfies every bound.
114
+ */
115
+ function numberExample(
116
+ schema: Schema,
117
+ integer: boolean,
118
+ ): number | typeof NO_EXAMPLE {
119
+ const multipleOf = numberField(schema, "multipleOf");
120
+ const candidates = [clampedZero(schema, integer), midpoint(schema, integer)]
121
+ .filter((value) => value !== undefined)
122
+ .flatMap((value) =>
123
+ multipleOf === undefined || multipleOf <= 0
124
+ ? [value]
125
+ : [
126
+ value,
127
+ snap(Math.ceil(value / multipleOf), multipleOf),
128
+ snap(Math.floor(value / multipleOf), multipleOf),
129
+ snap(Math.round(value / multipleOf), multipleOf),
130
+ ],
131
+ );
132
+ return (
133
+ candidates.find((value) => satisfiesNumber(schema, integer, value)) ??
134
+ NO_EXAMPLE
135
+ );
136
+ }
137
+
138
+ /** `steps * multipleOf`, without float noise such as 0.30000000000000004. */
139
+ function snap(steps: number, multipleOf: number): number {
140
+ const value = steps * multipleOf;
141
+ return Number.isInteger(value) ? value : Number(value.toPrecision(15));
142
+ }
143
+
144
+ /**
145
+ * Zod's own float-safe check (`floatSafeRemainder`): 0.3 / 0.1 is
146
+ * 2.9999999999999996, and the store accepts 0.3 as a multiple of 0.1.
147
+ * Integers are checked exactly, since that relative tolerance accepts any
148
+ * value once the step count nears 1e15.
149
+ */
150
+ function isMultipleOf(value: number, multipleOf: number): boolean {
151
+ if (Number.isInteger(value) && Number.isInteger(multipleOf)) {
152
+ return value % multipleOf === 0;
153
+ }
154
+ const steps = value / multipleOf;
155
+ const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(steps), 1);
156
+ return Math.abs(steps - Math.round(steps)) < tolerance;
157
+ }
158
+
159
+ function clampedZero(schema: Schema, integer: boolean): number {
96
160
  const round = integer ? Math.ceil : (value: number) => value;
97
161
  const roundDown = integer ? Math.floor : (value: number) => value;
98
162
  const clamps: ReadonlyArray<
@@ -123,6 +187,52 @@ function numberExample(schema: Schema, integer: boolean): number {
123
187
  }, 0);
124
188
  }
125
189
 
190
+ function midpoint(schema: Schema, integer: boolean): number | undefined {
191
+ const lower = boundOf(schema, "minimum", "exclusiveMinimum", Math.max);
192
+ const upper = boundOf(schema, "maximum", "exclusiveMaximum", Math.min);
193
+ if (lower === undefined || upper === undefined) return undefined;
194
+ const middle = Number((lower + (upper - lower) / 2).toPrecision(15));
195
+ return integer ? Math.ceil(middle) : middle;
196
+ }
197
+
198
+ function boundOf(
199
+ schema: Schema,
200
+ inclusive: string,
201
+ exclusive: string,
202
+ tighter: (a: number, b: number) => number,
203
+ ): number | undefined {
204
+ const bounds = [
205
+ numberField(schema, inclusive),
206
+ numberField(schema, exclusive),
207
+ ].filter((bound) => bound !== undefined);
208
+ return bounds.length === 0 ? undefined : bounds.reduce(tighter);
209
+ }
210
+
211
+ function satisfiesNumber(
212
+ schema: Schema,
213
+ integer: boolean,
214
+ value: number,
215
+ ): boolean {
216
+ const check = (key: string, ok: (bound: number) => boolean) => {
217
+ const bound = numberField(schema, key);
218
+ return bound === undefined || ok(bound);
219
+ };
220
+ return (
221
+ Number.isFinite(value) &&
222
+ (!integer || Number.isInteger(value)) &&
223
+ check("minimum", (bound) => value >= bound) &&
224
+ check("exclusiveMinimum", (bound) => value > bound) &&
225
+ check("maximum", (bound) => value <= bound) &&
226
+ check("exclusiveMaximum", (bound) => value < bound) &&
227
+ check("multipleOf", (bound) => bound > 0 && isMultipleOf(value, bound))
228
+ );
229
+ }
230
+
231
+ function numberField(schema: Schema, key: string): number | undefined {
232
+ const value = schema[key];
233
+ return typeof value === "number" ? value : undefined;
234
+ }
235
+
126
236
  /**
127
237
  * One example per tuple position (`prefixItems`, or a draft-07 `items`
128
238
  * array with `additionalItems` as the rest), then `items` examples up to `minItems`, or one when nothing else
@@ -131,9 +241,11 @@ function numberExample(schema: Schema, integer: boolean): number {
131
241
  function arrayExample(
132
242
  schema: Schema,
133
243
  label: string,
244
+ walk: Walk,
245
+ depth: number,
134
246
  ): JSONValue | typeof NO_EXAMPLE {
135
247
  const { prefix, rest } = arrayParts(schema);
136
- const result = examplesFor(prefix, label);
248
+ const result = examplesFor(prefix, label, walk, depth);
137
249
  if (result === NO_EXAMPLE) return NO_EXAMPLE;
138
250
  const minItems =
139
251
  typeof schema["minItems"] === "number" ? schema["minItems"] : 0;
@@ -146,7 +258,12 @@ function arrayExample(
146
258
  return prefix.length === 0 && minItems === 0 ? [] : NO_EXAMPLE;
147
259
  }
148
260
  if (result.length + restCount > MAX_ITEMS) return NO_EXAMPLE;
149
- const restExamples = examplesFor(Array(restCount).fill(rest), label);
261
+ const restExamples = examplesFor(
262
+ Array(restCount).fill(rest),
263
+ label,
264
+ walk,
265
+ depth,
266
+ );
150
267
  return restExamples === NO_EXAMPLE
151
268
  ? NO_EXAMPLE
152
269
  : withinLength([...result, ...restExamples]);
@@ -166,25 +283,36 @@ function arrayParts(schema: Schema): { prefix: unknown[]; rest: unknown } {
166
283
  function examplesFor(
167
284
  schemas: readonly unknown[],
168
285
  label: string,
286
+ walk: Walk,
287
+ depth: number,
169
288
  ): JSONValue[] | typeof NO_EXAMPLE {
170
289
  if (schemas.length > MAX_ITEMS) return NO_EXAMPLE;
171
290
  const result: JSONValue[] = [];
172
291
  for (const itemSchema of schemas) {
173
- const value = exampleFor(itemSchema, label);
292
+ const value = exampleFor(itemSchema, label, walk, depth + 1);
174
293
  if (value === NO_EXAMPLE) return NO_EXAMPLE;
175
294
  result.push(value);
176
295
  }
177
296
  return result;
178
297
  }
179
298
 
180
- function objectExample(schema: Schema): JSONValue | typeof NO_EXAMPLE {
299
+ function objectExample(
300
+ schema: Schema,
301
+ walk: Walk,
302
+ depth: number,
303
+ ): JSONValue | typeof NO_EXAMPLE {
181
304
  const properties = isSchema(schema["properties"]) ? schema["properties"] : {};
182
- const required = Array.isArray(schema["required"])
183
- ? schema["required"].filter((key) => typeof key === "string")
305
+ const rawRequired = Array.isArray(schema["required"])
306
+ ? schema["required"]
184
307
  : [];
308
+ walk.visited += rawRequired.length;
309
+ if (walk.visited > MAX_VISITED_NODES) return NO_EXAMPLE;
310
+ const required = new Set(
311
+ rawRequired.filter((key) => typeof key === "string"),
312
+ );
185
313
  const result: { [key: string]: JSONValue } = {};
186
314
  for (const key of required) {
187
- const value = exampleFor(properties[key], key);
315
+ const value = exampleFor(properties[key], key, walk, depth + 1);
188
316
  if (value === NO_EXAMPLE) return NO_EXAMPLE;
189
317
  result[key] = value;
190
318
  }