Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions skills/rig/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { agent, p, s } from "rig";
// Agent role: review the current diff and return prioritized findings.
const reviewDiff = agent({
model: "small",
instructions: p`Review ${p.bash("git diff -- .")} and return only the declared output.`,
instructions: p`Review ${p.bash('git diff -- .')} and return only the declared output.`,
output: s.object({
summary: s.string,
risk: s.enum("low", "medium", "high"),
Expand Down Expand Up @@ -58,11 +58,12 @@ the import syntax and Copilot SDK configuration.
|------|--------|
| Known required/optional file | `p.read(path)` / `p.readOptional(path, fallback?)` (prefer this over `cat ... || echo ...`) |
| Several known files | `p.readAll(["path/a.ts", "path/b.ts"])` (explicit array of literal paths) |
| Static shell command | `p.bash(command)`; use ``p.bashRaw`...` `` for literal backslashes |
| Static shell command | `p.bash('git status --short')`; keep commands on one line and use ``p.bashRaw`...` `` for literal backslashes |
| Caller-supplied path(s) | `p.readInput(field)` / `p.readAllInput(field)` with `s.path` schemas |
| Discover workspace paths | `p.glob(pattern)` returns paths only; then delegate one path at a time to a subagent using `p.readInput("path")` (there is no `p.readAll(globPattern)` overload) |
| Persist generated output | `p.writeOutput(field, path)` or `p.writeInput(pathField, outputField)` |
| String-keyed map | `s.record(value)`; keys are always `string` — do not wrap in `s.object`; use `s.record(s.int)` for count maps |
| Date-only and non-empty values | `s.date`, `s.nonEmptyArray(item)`, `s.nonEmptyObject(value)`; see [Agent API and schemas](./agent-api.md) |
| URL and file-path fields | `s.url` for URIs, `s.path` for paths, and wrappers like `s.array(s.path)` for path lists |
| Numeric schema choice | `s.int` for counts/line numbers; `s.number` for measurements and ratios |
| Optional versus nullable | `s.optional(shape)` for omission; `s.nullable(shape)` for explicit `null` |
Expand Down
16 changes: 15 additions & 1 deletion skills/rig/agent-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ s.string
s.string("description")
s.nonEmptyString
s.nonEmptyString("description")
s.date
s.date("description")
s.url
s.url("description")
s.path
Expand Down Expand Up @@ -80,6 +82,7 @@ s.literal(value, "description")
Helper constraints:

- `s.nonEmptyString` sets `minLength: 1`.
- `s.date` describes and validates a date-only string in `YYYY-MM-DD` form; use it instead of `s.string` when time is not part of the value.
- `s.url` uses format `"uri"`; `s.path` uses format `"path"`.
- `s.int` aliases `s.integer`.
- Prefer `s.int` for counts/line numbers and `s.number` for measurements, scores, and ratios.
Expand Down Expand Up @@ -109,7 +112,7 @@ Description placement:

| Helper family | Description argument |
|---------------|----------------------|
| Scalars (`s.string`, `s.int`, `s.path`, `s.url`, `s.boolean`, `s.unknown`) | First |
| Scalars (`s.string`, `s.int`, `s.date`, `s.path`, `s.url`, `s.boolean`, `s.unknown`) | First |
| Containers (`s.array`, `s.object`, `s.record`, `s.optional`, `s.nullable`, `s.nonEmptyArray`, `s.nonEmptyObject`) | Second, after the shape/value |
| `s.enum`, `s.literal` | Last |

Expand All @@ -125,10 +128,21 @@ s.record(s.object({ name: s.string, age: s.number }))
s.record(s.object({ path: s.path, homepage: s.url }))
s.nullable(s.string)
s.literal("done")
s.date
s.nonEmptyArray(s.path)
s.nonEmptyObject(s.boolean)
```

For example, require a date, at least one observation, and at least one localized label:

```ts
s.object({
observedOn: s.date,
observations: s.nonEmptyArray(s.string),
labelsByLocale: s.nonEmptyObject(s.string),
});
```

Prefer `s.path` for file-system locations, `s.url` for URIs, and `s.int` for counts or line numbers. Omit schemas entirely when free-form strings are sufficient.

## Tools
Expand Down
18 changes: 11 additions & 7 deletions skills/rig/dynamic-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,23 @@ errors never affect the run.
Use `until` instead of an open-ended loop:

```ts
const final = await until(
type CatalogState = {
catalog: Record<string, string>;
conflicts: string[];
};

const final = await until<CatalogState>(
{ max: 8, noProgressRounds: 2 },
async (previous, round) => {
const state = await checkAndFix(previous, round);
return {
state,
done: state.passed,
progressKey: state.failureSummary,
};
const state: CatalogState = await checkAndFix(previous, round);
return { state, done: state.conflicts.length === 0, progressKey: JSON.stringify(state.conflicts) };
},
);
final.catalog; // CatalogState
```

`until<State>(...)` gives the step's `previous` parameter (`State | undefined`) and the returned `final` value the same explicit state type. If the step result is inferred as `unknown`, provide the generic and, when needed, annotate the produced `state`.

The loop stops when `done` is true, after `max` rounds, or after
`noProgressRounds` consecutive equal defined progress keys.

Expand Down