@joiner-platform/cli 0.1.7 → 0.1.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,7 +1,7 @@
1
1
  {
2
2
  "name": "@joiner-platform/cli",
3
- "version": "0.1.7",
4
- "gitHead": "5e75f23384e78b483c8dd23441c400a1b712be1e",
3
+ "version": "0.1.9",
4
+ "gitHead": "de911036c9e9177a71a0a55881c4a595e11360b7",
5
5
  "description": "The Joiner CLI: create, test, and publish Joiner tiles, with agent skills for coding agents.",
6
6
  "keywords": [
7
7
  "joiner",
@@ -124,7 +124,7 @@ When the creator asks whether tiles can do something ("can it take pictures?"),
124
124
  | Music made while building | Yes, with `generate_music` | Yes | `audio-generation` skill |
125
125
  | Sound effects made while building | Yes, with `generate_sound_effect` | Yes | `audio-generation` skill |
126
126
  | Art made while building | Yes, with `generate_image` | Yes | `image-generation` skill |
127
- | AI agents as room members | No | Yes | [agents](../tile-creator/references/client-api.md#poe-agents-create-agentid-name-model-tools-room) |
127
+ | AI agents as room members | No | Yes | [agents](../tile-creator/references/client-api.md#poe-agents-create-agentid-name-model-room) |
128
128
  | Open a web link | No | Yes, the player confirms | [links](../tile-creator/references/client-api.md#poe-openexternalurl-url) |
129
129
  | Open or embed another tile | No | Yes | [open](../tile-creator/references/client-api.md#poe-open-typeid-instanceid-openprops-anchorsortkey-placement-viewwidth), [embed](../tile-creator/references/client-api.md#poe-tile-custom-element) |
130
130
  | Scheduled server work (timers, cron, events while nobody plays) | No | No; server code runs when a player acts | [limits](../synced-store/references/limitations.md) |
@@ -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/109546a2cd2a27cc26c46272a5337e159555465b3930d0ef9a03afa1d09e9309"
64
+ "joiner-sdk": "https://misc-dev-uploads.quora-913.workers.dev/a389a1a66884dcffd74adc2e3f829ce6c098d99c89311b4c5ec3cc35280ee278"
65
65
  ```
66
66
  <!-- end: sdk-tarball-snippet -->
67
67
 
@@ -482,8 +482,14 @@ the current user's id is present as an active row in the store's `$users`
482
482
  table. It exits non-zero when the user is not an active member.
483
483
 
484
484
  `stores schema` fetches the store schema, including all available mutators,
485
- and prints ready-to-run CLI commands for checking access and dispatching each
486
- mutator.
485
+ and prints CLI commands for checking access and dispatching each mutator and
486
+ action. Each dispatch command carries an example `--input` built from that
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
490
+ example would be too large for one shell argument (an array of more than 32
491
+ items, or more than 1 KiB of JSON), the command shows `--input '<json>'` and
492
+ its `--json` entry has no `inputExample`.
487
493
 
488
494
  `stores mutate` fetches the store schema version, then sends a single mutation
489
495
  push. It exits non-zero when the server reports a failed mutation.
@@ -45,7 +45,7 @@ below for custom behavior.
45
45
  - [`Poe.room.tileEnd()`](#poe-room-tileend-input) — Show the host end-of-tile UI and optionally replay
46
46
  - [`Poe.room.setShareLeaderboardId()`](#poe-room-setshareleaderboardid-leaderboardid) — Make current-page share links point at a tile-owned leaderboard
47
47
  - [`Poe.room.dismissTileEnd()`](#poe-room-dismisstileend-opts) — Programmatically dismiss this client's tile-end overlay (shared-instance team games)
48
- - [`Poe.agents.create()`](#poe-agents-create-agentid-name-model-tools-room) — Create an agent owned by the calling user, optionally adding it to a room
48
+ - [`Poe.agents.create()`](#poe-agents-create-agentid-name-model-room) — Create an agent owned by the calling user, optionally adding it to a room
49
49
  - [`Poe.agents.delete()`](#poe-agents-delete-agentid) — Delete one of your agents outright (irreversible)
50
50
  - [`Poe.agents.addToRoom()` / `Poe.agents.removeFromRoom()`](#poe-agents-addtoroom-agentid-typeid-instanceid-poe-agents-removefromroom-agentid-typeid-instanceid) — Add/remove an existing agent as a room member
51
51
  - [`Poe.agents.listTools()`](#poe-agents-listtools) — List the first-party agent system-tool catalog
@@ -775,9 +775,9 @@ try {
775
775
 
776
776
  Make the restart **generation-guarded / idempotent** (restart only if the just-finished round is still current) — when several players tap Play Again at once, the platform does not serialize the restarts.
777
777
 
778
- ### `Poe.agents.create({ agentId, name, model, tools?, room? })`
778
+ ### `Poe.agents.create({ agentId, name, model, room? })`
779
779
 
780
- Create a new agent owned by the calling user. You mint the agent's `agentId` (an `agent_<uuid>`) and pass it as the **idempotency key**; the trusted host runs the whole creation server-side in one round-trip: it claims the per-creator-unique `name` in the caller's agents registry, initializes the agent's store with the given `model` and `tools`, and — when you pass a `room` — adds the new agent to that room in the same call.
780
+ Create a new agent owned by the calling user. You mint the agent's `agentId` (an `agent_<uuid>`) and pass it as the **idempotency key**; the trusted host runs the whole creation server-side in one round-trip: it claims the per-creator-unique `name` in the caller's agents registry, initializes the agent's identity with the given `model`, and — when you pass a `room` — adds the new agent to that room in the same call.
781
781
 
782
782
  ```typescript
783
783
  // Use the portable `generateUUID()` helper, not `crypto.randomUUID()` — the
@@ -788,16 +788,15 @@ const result = await Poe.agents.create({
788
788
  agentId, // client-minted idempotency key — reuse it across retries
789
789
  name: "Code Reviewer",
790
790
  model: "anthropic/claude-sonnet-4-6",
791
- tools: ["read_file"], // restricts the agent to these system tools (order ignored)
792
791
  room: { typeId: "chat", instanceId: roomId }, // optional: create + add in one call
793
792
  });
794
793
  ```
795
794
 
796
- `agentId`, `name`, and `model` are required (`name`/`model` are trimmed by the host); `name` is unique among the calling user's agents (case-insensitive). `tools` is the system-tool allow-list — an **explicit grant list** (deny-by-default): the agent may use exactly the tools named, and omitting it (or passing `[]`) gives the agent **no system tools** (the default for auto-created agents; grant tools later via a config edit). Tool order doesn't matter — it's treated as a set. `room` is optional; when supplied you must be a live member of that room (direct-message rooms are refused), and the room is validated before the agent is created so a bad room never leaves an orphaned agent.
795
+ `agentId`, `name`, and `model` are required (`name`/`model` are trimmed by the host); `name` is unique among the calling user's agents (case-insensitive). All agents use the shared Poe execution definition in code. Creation requests containing retired policy fields such as `tools`, `modelParams`, or context settings are rejected. Select an inference model independently of that shared policy.
797
796
 
798
- `modelParams` is optional: the agent's **default model params** for `model` as `paramId → value` (for example `{ output_effort: "high" }` or `{ thinking_visibility: true }`), stored on the agent and applied to every run on that model over the catalog defaults (a stored value overrides its default), so a default that later moves in the catalog still moves for any param the agent never touched. Only ids the platform honors are accepted (`web_search` is not storable), and a stored value that later stops matching the model's options falls back to the catalog default instead of failing the run. The params belong to the agent's model: changing the model through the edit flow clears them unless the same edit supplies new ones. Omitted or `{}` means catalog defaults.
797
+ `room` is optional; when supplied you must be a live member of that room (direct-message rooms are refused), and the room is validated before the agent is created so a bad room never leaves an orphaned agent.
799
798
 
800
- **The `agentId` is the idempotency key.** Mint it once per logical create intent and **reuse it across retries** (don't generate a fresh id on retry, or you lose idempotency). Calling `create` again with the same `agentId` returns your existing agent and **ignores the rest of the payload** — `reused` is `true` when the existing agent was returned and `false` when a fresh one was minted; the optional `room` add still applies on reuse. So a retry (or a double-submit) safely resolves to the same agent. Config changes go through the edit flow, never `create`. The promise rejects only on a *real* conflict — a **new** `agentId` whose `name` is already taken by a different agent — or when `modelParams` carries an id the platform does not honor or a value out of range, or when the room is invalid or initialization fails.
799
+ **The `agentId` is the idempotency key.** Mint it once per logical create intent and **reuse it across retries** (don't generate a fresh id on retry, or you lose idempotency). Calling `create` again with the same `agentId` returns your existing agent and **ignores the rest of the payload** — `reused` is `true` when the existing agent was returned and `false` when a fresh one was minted; the optional `room` add still applies on reuse. So a retry (or a double-submit) safely resolves to the same agent. Creation retries do not update an existing agent. The promise rejects only on a *real* conflict — a **new** `agentId` whose `name` is already taken by a different agent — or when retired policy fields are supplied, or when the room is invalid or initialization fails.
801
800
 
802
801
  The returned `agentId` echoes the id you minted (an `agent_…` id usable as a room member id), and `addedToRoom` reports whether the optional `room` add succeeded. Agents join rooms through the membership APIs (below); apps never mount or read the agent's own store.
803
802
 
@@ -839,49 +838,32 @@ await Poe.agents.removeFromRoom({ agentId, typeId: "chat", instanceId: roomId })
839
838
 
840
839
  ### `Poe.agents.listTools()`
841
840
 
842
- List the first-party agent system-tool catalog — the `{ id, displayName, description }` metadata for every built-in system tool an agent can be granted. Use it to render tool ids and display names in your own agent-building UI without hardcoding the list.
841
+ List the first-party system-tool metadata (`{ id, displayName, description }`). Use it to display tool names. This catalog is not a grant list: the shared Poe definition determines which tools agents can use.
843
842
 
844
843
  ```typescript
845
844
  const tools = await Poe.agents.listTools();
846
- // e.g. [{ id: "calculator", displayName: "Calculator", description: "Evaluates arithmetic expressions." }]
847
-
848
- // The ids are exactly what `Poe.agents.create({ tools })` accepts:
849
- await Poe.agents.create({
850
- name: "Mathbot",
851
- model: "anthropic/claude-sonnet-4-6",
852
- tools: tools.map((tool) => tool.id),
853
- });
854
845
  ```
855
846
 
856
847
  Read-only public metadata — it takes no arguments, requires no permissions, and returns the same catalog for everyone.
857
848
 
858
849
  ### `Poe.agents.listTemplates()`
859
850
 
860
- List the first-party agent-template catalog — the preset agent configurations (name, model, and tool grant) that pre-fill the agent-create form. Use it to render a template picker in your own agent-building UI without hardcoding the presets.
851
+ Return the single Poe creation entry in the existing template shape. Its model is the default inference choice, and its tools describe the shared execution policy. `suggestedName` is empty: ask the creator to name the new instance, rather than creating another default Poe label. The separate `Poe.listModels()` catalog supplies alternative inference models.
861
852
 
862
853
  ```typescript
863
854
  const templates = await Poe.agents.listTemplates();
864
- // e.g. [{
865
- // id: "math-helper",
866
- // displayName: "Math Helper",
867
- // description: "Works through arithmetic step by step using a calculator tool.",
868
- // iconEmoji: "🧮",
869
- // config: { suggestedName: "Math Helper", model: "anthropic/claude-sonnet-4-6", tools: ["calculator"] },
870
- // }]
871
-
872
- // A template's `config` is exactly what `Poe.agents.create` accepts — instantiation is a copy:
873
- const template = templates.find((t) => t.id === "math-helper");
855
+ const template = templates.find((entry) => entry.id === "poe");
874
856
  if (template) {
857
+ const agentId = `agent_${generateUUID()}`; // keep this id for retries
875
858
  await Poe.agents.create({
876
- name: template.config.suggestedName,
859
+ agentId,
860
+ name: "Researcher", // the creator's chosen name
877
861
  model: template.config.model,
878
- // `config.tools` is `readonly string[]`; spread into a mutable copy for the create input.
879
- tools: [...template.config.tools],
880
862
  });
881
863
  }
882
864
  ```
883
865
 
884
- Read-only public metadata — it takes no arguments, requires no permissions, and returns the same catalog for everyone. Picking a template only pre-fills the create form; there is no live template↔agent link after creation.
866
+ Read-only public metadata, the same for everyone. Copy only identity fields into creation requests; tools and other execution settings come from the shared code definition on every run, including for existing agents.
885
867
 
886
868
  ### `Poe.agents.listMine()`
887
869
 
@@ -1924,7 +1906,7 @@ rounds up to the next width. Use `loadImage` with a `size`.
1924
1906
 
1925
1907
  If your app triggers agents (`Poe.agents.*`) and stores their replies, you can record the configuration each run actually executed on — the model, the tools it was allowed, the tool→model bindings, and which of those a per-trigger override replaced.
1926
1908
 
1927
- This is worth storing rather than looking up later, for two reasons: an agent's configuration is **overwritten in place with no history**, so editing it retroactively changes what every past reply appears to have been generated with; and a per-trigger override (`modelOverride` / `enabledTools` / `toolModels`) is **never persisted anywhere**, so it is unrecoverable once the run ends.
1909
+ Record the effective configuration with each reply because the shared policy can change on deployment and per-trigger overrides can differ between runs. Looking up today's instance metadata cannot reconstruct an earlier run's configuration.
1928
1910
 
1929
1911
  ```typescript
1930
1912
  import {
@@ -1,4 +1,4 @@
1
1
  // Auto-generated by poe-tiles-sdk/scripts/publish-tar.ts — do not edit
2
- // publishedAt: 2026-11-25T02:33:43.775Z
2
+ // publishedAt: 2026-11-25T14:50:14.982Z
3
3
  export const SDK_TARBALL_URL =
4
- "https://misc-dev-uploads.quora-913.workers.dev/109546a2cd2a27cc26c46272a5337e159555465b3930d0ef9a03afa1d09e9309";
4
+ "https://misc-dev-uploads.quora-913.workers.dev/a389a1a66884dcffd74adc2e3f829ce6c098d99c89311b4c5ec3cc35280ee278";
@@ -0,0 +1,196 @@
1
+ // owner: jyoung-q
2
+ import type { JSONValue } from "../client.js";
3
+
4
+ type Schema = { readonly [key: string]: unknown };
5
+
6
+ const NO_EXAMPLE = Symbol("no-example");
7
+
8
+ /**
9
+ * Examples are printed as one shell argument, so a schema that needs a long
10
+ * input (a fixed 256x256 grid, say) gets the `'<json>'` placeholder instead.
11
+ * `MAX_ITEMS` bounds the work per array before the size check runs.
12
+ */
13
+ const MAX_EXAMPLE_JSON_BYTES = 1024;
14
+ const MAX_ITEMS = 32;
15
+
16
+ /**
17
+ * Builds a minimal input that matches a mutator or action's JSON Schema, for
18
+ * the copy-paste commands `stores schema` prints. Required object properties
19
+ * only; strings become `"<propertyName>"` placeholders.
20
+ *
21
+ * Returns `undefined` when the schema is not JSON Schema this can read (for
22
+ * example a serialized Zod instance) or the example would be longer than
23
+ * `MAX_EXAMPLE_JSON_BYTES` (UTF-8), so callers fall back to `'<json>'` rather than
24
+ * print an example the store would reject or the shell could not take.
25
+ */
26
+ export function exampleInputFromJsonSchema(
27
+ schema: unknown,
28
+ ): JSONValue | undefined {
29
+ const example = withinLength(exampleFor(schema, "string"));
30
+ return example === NO_EXAMPLE ? undefined : example;
31
+ }
32
+
33
+ function withinLength(
34
+ example: JSONValue | typeof NO_EXAMPLE,
35
+ ): JSONValue | typeof NO_EXAMPLE {
36
+ return example !== NO_EXAMPLE &&
37
+ new TextEncoder().encode(JSON.stringify(example)).length <=
38
+ MAX_EXAMPLE_JSON_BYTES
39
+ ? example
40
+ : NO_EXAMPLE;
41
+ }
42
+
43
+ function exampleFor(
44
+ schema: unknown,
45
+ label: string,
46
+ ): JSONValue | typeof NO_EXAMPLE {
47
+ if (!isSchema(schema) || "def" in schema || "_zod" in schema) {
48
+ return NO_EXAMPLE;
49
+ }
50
+ if ("const" in schema) return schema["const"] as JSONValue;
51
+ const enumValues = schema["enum"];
52
+ if (Array.isArray(enumValues) && enumValues.length > 0) {
53
+ return enumValues[0] as JSONValue;
54
+ }
55
+ const branch = firstBranch(schema);
56
+ if (branch !== undefined) return exampleFor(branch, label);
57
+ return typedExample(schema, label);
58
+ }
59
+
60
+ function firstBranch(schema: Schema): unknown {
61
+ for (const key of ["anyOf", "oneOf"] as const) {
62
+ const branches = schema[key];
63
+ if (Array.isArray(branches) && branches.length > 0) return branches[0];
64
+ }
65
+ return undefined;
66
+ }
67
+
68
+ function typedExample(
69
+ schema: Schema,
70
+ label: string,
71
+ ): JSONValue | typeof NO_EXAMPLE {
72
+ const type = Array.isArray(schema["type"])
73
+ ? schema["type"][0]
74
+ : schema["type"];
75
+ switch (type) {
76
+ case "string":
77
+ return `<${label}>`;
78
+ case "number":
79
+ case "integer":
80
+ return numberExample(schema, type === "integer");
81
+ case "boolean":
82
+ return false;
83
+ case "null":
84
+ return null;
85
+ case "array":
86
+ return arrayExample(schema, label);
87
+ case "object":
88
+ return objectExample(schema);
89
+ default:
90
+ return NO_EXAMPLE;
91
+ }
92
+ }
93
+
94
+ /** 0, moved inside `minimum` / `maximum` and their exclusive forms. */
95
+ function numberExample(schema: Schema, integer: boolean): number {
96
+ const round = integer ? Math.ceil : (value: number) => value;
97
+ const roundDown = integer ? Math.floor : (value: number) => value;
98
+ const clamps: ReadonlyArray<
99
+ readonly [
100
+ string,
101
+ (value: number, bound: number) => boolean,
102
+ (bound: number) => number,
103
+ ]
104
+ > = [
105
+ ["minimum", (value, bound) => value < bound, round],
106
+ [
107
+ "exclusiveMinimum",
108
+ (value, bound) => value <= bound,
109
+ (bound) => roundDown(bound) + 1,
110
+ ],
111
+ ["maximum", (value, bound) => value > bound, roundDown],
112
+ [
113
+ "exclusiveMaximum",
114
+ (value, bound) => value >= bound,
115
+ (bound) => round(bound) - 1,
116
+ ],
117
+ ];
118
+ return clamps.reduce((value, [key, outside, inside]) => {
119
+ const bound = schema[key];
120
+ return typeof bound === "number" && outside(value, bound)
121
+ ? inside(bound)
122
+ : value;
123
+ }, 0);
124
+ }
125
+
126
+ /**
127
+ * One example per tuple position (`prefixItems`, or a draft-07 `items`
128
+ * array with `additionalItems` as the rest), then `items` examples up to `minItems`, or one when nothing else
129
+ * sets the length.
130
+ */
131
+ function arrayExample(
132
+ schema: Schema,
133
+ label: string,
134
+ ): JSONValue | typeof NO_EXAMPLE {
135
+ const { prefix, rest } = arrayParts(schema);
136
+ const result = examplesFor(prefix, label);
137
+ if (result === NO_EXAMPLE) return NO_EXAMPLE;
138
+ const minItems =
139
+ typeof schema["minItems"] === "number" ? schema["minItems"] : 0;
140
+ const restCount = Math.max(
141
+ minItems - result.length,
142
+ prefix.length === 0 ? 1 : 0,
143
+ );
144
+ if (restCount === 0) return withinLength(result);
145
+ if (!isSchema(rest)) {
146
+ return prefix.length === 0 && minItems === 0 ? [] : NO_EXAMPLE;
147
+ }
148
+ if (result.length + restCount > MAX_ITEMS) return NO_EXAMPLE;
149
+ const restExamples = examplesFor(Array(restCount).fill(rest), label);
150
+ return restExamples === NO_EXAMPLE
151
+ ? NO_EXAMPLE
152
+ : withinLength([...result, ...restExamples]);
153
+ }
154
+
155
+ function arrayParts(schema: Schema): { prefix: unknown[]; rest: unknown } {
156
+ const items = schema["items"];
157
+ if (Array.isArray(schema["prefixItems"])) {
158
+ return { prefix: schema["prefixItems"], rest: items };
159
+ }
160
+ if (Array.isArray(items)) {
161
+ return { prefix: items, rest: schema["additionalItems"] };
162
+ }
163
+ return { prefix: [], rest: items };
164
+ }
165
+
166
+ function examplesFor(
167
+ schemas: readonly unknown[],
168
+ label: string,
169
+ ): JSONValue[] | typeof NO_EXAMPLE {
170
+ if (schemas.length > MAX_ITEMS) return NO_EXAMPLE;
171
+ const result: JSONValue[] = [];
172
+ for (const itemSchema of schemas) {
173
+ const value = exampleFor(itemSchema, label);
174
+ if (value === NO_EXAMPLE) return NO_EXAMPLE;
175
+ result.push(value);
176
+ }
177
+ return result;
178
+ }
179
+
180
+ function objectExample(schema: Schema): JSONValue | typeof NO_EXAMPLE {
181
+ const properties = isSchema(schema["properties"]) ? schema["properties"] : {};
182
+ const required = Array.isArray(schema["required"])
183
+ ? schema["required"].filter((key) => typeof key === "string")
184
+ : [];
185
+ const result: { [key: string]: JSONValue } = {};
186
+ for (const key of required) {
187
+ const value = exampleFor(properties[key], key);
188
+ if (value === NO_EXAMPLE) return NO_EXAMPLE;
189
+ result[key] = value;
190
+ }
191
+ return result;
192
+ }
193
+
194
+ function isSchema(value: unknown): value is Schema {
195
+ return typeof value === "object" && value !== null && !Array.isArray(value);
196
+ }
@@ -29,6 +29,7 @@ import {
29
29
  parseNonNegativeIntegerOption,
30
30
  parsePositiveIntegerOption,
31
31
  } from "./parse-options.js";
32
+ import { exampleInputFromJsonSchema } from "./schema-input-example.js";
32
33
  import { createStoreFilesCommands } from "./store-files.js";
33
34
 
34
35
  const DEFAULT_MUTATE_TIMEOUT_MS = 15_000;
@@ -571,16 +572,16 @@ interface StoreSchemaCommands {
571
572
  pull: string;
572
573
  get: string;
573
574
  scan: string;
574
- mutators: Array<{
575
- name: string;
576
- description?: string;
577
- command: string;
578
- }>;
579
- actions: Array<{
580
- name: string;
581
- description?: string;
582
- command: string;
583
- }>;
575
+ mutators: SchemaFunctionCommand[];
576
+ actions: SchemaFunctionCommand[];
577
+ }
578
+
579
+ interface SchemaFunctionCommand {
580
+ name: string;
581
+ description?: string;
582
+ /** A minimal input matching the function's JSON Schema, when one is readable. */
583
+ inputExample?: JSONValue;
584
+ command: string;
584
585
  }
585
586
 
586
587
  function buildSchemaCommands(result: StoreSchemaResult): StoreSchemaCommands {
@@ -589,53 +590,40 @@ function buildSchemaCommands(result: StoreSchemaResult): StoreSchemaCommands {
589
590
  pull: `${cliName()} stores pull ${shellQuote(result.storeTypeId)} ${shellQuote(result.instanceId)} --after-version 0`,
590
591
  get: `${cliName()} stores get ${shellQuote(result.storeTypeId)} ${shellQuote(result.instanceId)} '<tableName>' '<itemKey>'`,
591
592
  scan: `${cliName()} stores scan ${shellQuote(result.storeTypeId)} ${shellQuote(result.instanceId)} '<tableName>' --limit 50`,
592
- mutators: result.schema.mutators.map((mutator) => ({
593
- name: mutator.name,
594
- ...(mutator.description !== undefined
595
- ? { description: mutator.description }
596
- : undefined),
597
- command: mutateCommandForSchema(result, mutator),
598
- })),
599
- actions: result.schema.actions.map((action) => ({
600
- name: action.name,
601
- ...(action.description !== undefined
602
- ? { description: action.description }
603
- : undefined),
604
- command: actionCommandForSchema(result, action),
605
- })),
593
+ mutators: result.schema.mutators.map((mutator) =>
594
+ schemaFunctionCommand(result, "mutate", mutator),
595
+ ),
596
+ actions: result.schema.actions.map((action) =>
597
+ schemaFunctionCommand(result, "action", action),
598
+ ),
606
599
  };
607
600
  }
608
601
 
609
- function mutateCommandForSchema(
602
+ function schemaFunctionCommand(
610
603
  result: StoreSchemaResult,
611
- mutator: StoreMutatorSchemaInfo,
612
- ): string {
613
- return [
614
- cliName(),
615
- "stores",
616
- "mutate",
617
- shellQuote(result.storeTypeId),
618
- shellQuote(result.instanceId),
619
- shellQuote(mutator.name),
620
- "--input",
621
- "'<json>'",
622
- ].join(" ");
623
- }
624
-
625
- function actionCommandForSchema(
626
- result: StoreSchemaResult,
627
- action: StoreActionSchemaInfo,
628
- ): string {
629
- return [
630
- cliName(),
631
- "stores",
632
- "action",
633
- shellQuote(result.storeTypeId),
634
- shellQuote(result.instanceId),
635
- shellQuote(action.name),
636
- "--input",
637
- "'<json>'",
638
- ].join(" ");
604
+ verb: "mutate" | "action",
605
+ fn: StoreMutatorSchemaInfo | StoreActionSchemaInfo,
606
+ ): SchemaFunctionCommand {
607
+ const inputExample = exampleInputFromJsonSchema(fn.inputSchema);
608
+ const input =
609
+ inputExample === undefined
610
+ ? "'<json>'"
611
+ : shellQuote(JSON.stringify(inputExample));
612
+ return {
613
+ name: fn.name,
614
+ ...(fn.description !== undefined ? { description: fn.description } : {}),
615
+ ...(inputExample !== undefined ? { inputExample } : {}),
616
+ command: [
617
+ cliName(),
618
+ "stores",
619
+ verb,
620
+ shellQuote(result.storeTypeId),
621
+ shellQuote(result.instanceId),
622
+ shellQuote(fn.name),
623
+ "--input",
624
+ input,
625
+ ].join(" "),
626
+ };
639
627
  }
640
628
 
641
629
  function printSchemaResult(