Skip to content

Commit 10453b1

Browse files
authored
Merge pull request #27 from githubnext/rig-sampler/08-extract-package-scripts-14d1b114445f90b1
2 parents 23d3254 + 1116080 commit 10453b1

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

‎skills/rig/rig.ts‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
* T:LauncherIo type {stdin,stdout,stderr} override for launcher subprocess
2828
* T:JsonSchemaObject type {[key:string]:unknown} plain JSON Schema object
2929
* s.string/number/integer/boolean/null SchemaHelperFactory primitives; call as value or fn(desc)
30-
* s.array(items,desc?) ArraySchema
31-
* s.object(props,desc?) ObjectSchema; s.optional(inner) marks field optional
32-
* s.record(valSchema,desc?) RecordSchema keyed by string
30+
* s.array(items,desc?) ArraySchema; use for homogeneous lists, e.g. s.array(s.string)
31+
* s.object(props,desc?) ObjectSchema; s.optional(inner) marks field optional; use for fixed-key shapes
32+
* s.record(valSchema,desc?) RecordSchema keyed by string; use for open-ended key→value maps
3333
* s.enum(...values|values,desc) EnumSchema
3434
* s.unknown() unconstrained JSON
3535
* p`...` PromptBuilder template tag; interpolates PromptIntent|string|PromptBuilder
@@ -202,15 +202,33 @@ export const s = {
202202
null: createTypedPrimitiveSchema<NullSchema>("null"),
203203
/** Schema for an unconstrained JSON value. Serializes to an empty schema object. */
204204
unknown: createUnknownSchema(),
205-
/** Schema for a homogeneous array. `s.array(s.string)` → `string[]`. */
205+
/**
206+
* Schema for a homogeneous array.
207+
*
208+
* @example
209+
* s.array(s.string) // string[]
210+
* s.array(s.number, "scores") // number[] with description
211+
*/
206212
array<Item extends Schema>(items: Item, description?: string): ArraySchema<Item> {
207213
return description === undefined ? markAsSchema({ type: "array", items }) : markAsSchema({ type: "array", items, description });
208214
},
209-
/** Schema for a fixed-shape object. Fields wrapped with `s.optional` are omitted from `required`. */
215+
/**
216+
* Schema for a fixed-shape object. Fields wrapped with `s.optional` are omitted from `required`.
217+
*
218+
* @example
219+
* s.object({ name: s.string, age: s.optional(s.number) })
220+
*/
210221
object<Fields extends Record<string, Schema>>(properties: Fields, description?: string): ObjectSchema<Fields> {
211222
return description === undefined ? markAsSchema({ type: "object", properties }) : markAsSchema({ type: "object", properties, description });
212223
},
213-
/** Schema for a string-keyed map where every value shares the same schema. */
224+
/**
225+
* Schema for a string-keyed map where every value shares the same schema.
226+
* Use this instead of `s.object` when the keys are not known in advance.
227+
*
228+
* @example
229+
* s.record(s.string) // Record<string, string>
230+
* s.record(s.number, "score by name") // Record<string, number> with description
231+
*/
214232
record<Value extends Schema>(additionalProperties: Value, description?: string): RecordSchema<Value> {
215233
return description === undefined ? markAsSchema({ type: "object", additionalProperties }) : markAsSchema({ type: "object", additionalProperties, description });
216234
},

0 commit comments

Comments
 (0)