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
24 changes: 17 additions & 7 deletions skills/rig/samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Generated by `npm run sample:catalog`; do not edit the inventory by hand.

680 samples: 622 Markdown programs and 58 TypeScript fixtures.
690 samples: 632 Markdown programs and 58 TypeScript fixtures.
Every sample has one primary **pattern bucket**, a **topic cluster**, and a normalized task **family**.
Buckets come from program syntax, not filenames. A workflow with tools stays in workflows; a coordinator with tools stays in delegation.
Markdown and TypeScript versions are kept separately because they exercise different launcher contracts; provider integration fixtures are also intentional.
Expand All @@ -12,12 +12,12 @@ Legacy filenames are stable identifiers, not an authoritative description of the

| Bucket | Samples | Read when |
|--------|---------|-----------|
| [Schema-first agents](#schemas) | 59 | Typed caller inputs and constrained outputs without workspace intents. |
| [Prompt context and side effects](#context) | 68 | Reading or discovering workspace context and declaring output side effects. |
| [Runtime and addons](#runtime) | 41 | Invocation options, engines, timeouts, repair, steering, and addon hooks. |
| [Custom tools](#tools) | 417 | Model-callable deterministic operations, parsing, and Node.js APIs. |
| [Model-driven delegation](#delegation) | 55 | Named specialists coordinated by a model-driven root agent. |
| [Deterministic workflows](#workflows) | 40 | Explicit sequencing, bounded fan-out, pipelines, budgets, and nested workflows. |
| [Schema-first agents](#schemas) | 61 | Typed caller inputs and constrained outputs without workspace intents. |
| [Prompt context and side effects](#context) | 70 | Reading or discovering workspace context and declaring output side effects. |
| [Runtime and addons](#runtime) | 43 | Invocation options, engines, timeouts, repair, steering, and addon hooks. |
| [Custom tools](#tools) | 419 | Model-callable deterministic operations, parsing, and Node.js APIs. |
| [Model-driven delegation](#delegation) | 56 | Named specialists coordinated by a model-driven root agent. |
| [Deterministic workflows](#workflows) | 41 | Explicit sequencing, bounded fan-out, pipelines, budgets, and nested workflows. |

Use `node scripts/sample-catalog.ts --json` for the complete inventory with role comments, task families, and exercised APIs.
For a focused search, append `--family <slug>` or `--bucket <key>`; bucket keys are `schemas`, `context`, `runtime`, `tools`, `delegation`, and `workflows`.
Expand Down Expand Up @@ -81,6 +81,8 @@ For a focused search, append `--family <slug>` or `--bucket <key>`; bucket keys
| optional-event-metadata | [38-exact-literal-output.md](samples/38-exact-literal-output.md), [38-exact-literal-output.ts](../../src/samples/38-exact-literal-output.ts) |
| prompt-intents | [47-prompt-intents.md](samples/47-prompt-intents.md) |
| readonly-investigator | [34-intent-options.md](samples/34-intent-options.md) |
| recipe-conversion-delta | [545-recipe-conversion-delta.md](samples/545-recipe-conversion-delta.md) |
| shift-schedule-localizer | [542-shift-schedule-localizer.md](samples/542-shift-schedule-localizer.md) |
| single-agent-haiku | [01-single-agent-haiku.ts](../../src/samples/01-single-agent-haiku.ts) |
| single-agent-sonnet | [56-single-agent-sonnet.ts](../../src/samples/56-single-agent-sonnet.ts) |
| summarize-many-files | [07-summarize-many-files.md](samples/07-summarize-many-files.md) |
Expand Down Expand Up @@ -116,6 +118,7 @@ For a focused search, append `--family <slug>` or `--bucket <key>`; bucket keys
| review-git-diff | [02-review-git-diff.md](samples/02-review-git-diff.md), [02-review-git-diff.ts](../../src/samples/02-review-git-diff.ts), [03-diagnose-test-failure.ts](../../src/samples/03-diagnose-test-failure.ts) |
| review-readiness-report | [527-review-readiness-report.md](samples/527-review-readiness-report.md) |
| triage-pr | [11-release-notes.ts](../../src/samples/11-release-notes.ts) |
| venue-booking-diff-writer | [550-venue-booking-diff-writer.md](samples/550-venue-booking-diff-writer.md) |

### Configuration and dependencies

Expand Down Expand Up @@ -166,6 +169,7 @@ For a focused search, append `--family <slug>` or `--bucket <key>`; bucket keys
| line-count-report-writer | [537-line-count-report-writer.md](samples/537-line-count-report-writer.md) |
| prompt-intents | [47-prompt-intents.ts](../../src/samples/47-prompt-intents.ts) |
| readonly-investigator | [34-intent-options.ts](../../src/samples/34-intent-options.ts) |
| species-observation-digest | [544-species-observation-digest.md](samples/544-species-observation-digest.md) |
| summarize-many-files | [07-summarize-many-files.ts](../../src/samples/07-summarize-many-files.ts) |
| todo-comment-tracker | [69-todo-comment-tracker.md](samples/69-todo-comment-tracker.md), [175-todo-comment-tracker.md](samples/175-todo-comment-tracker.md) |
| todo-fixme-tracker | [184-todo-fixme-tracker.md](samples/184-todo-fixme-tracker.md) |
Expand Down Expand Up @@ -234,9 +238,11 @@ For a focused search, append `--family <slug>` or `--bucket <key>`; bucket keys
| build-log-analyzer | [78-build-log-analyzer.md](samples/78-build-log-analyzer.md) |
| dotfile-inventory | [149-dotfile-inventory.md](samples/149-dotfile-inventory.md) |
| healthcheck-timeout | [524-healthcheck-timeout.md](samples/524-healthcheck-timeout.md), [534-healthcheck-timeout-status.md](samples/534-healthcheck-timeout-status.md) |
| lab-result-steered-translation | [547-lab-result-steered-translation.md](samples/547-lab-result-steered-translation.md) |
| repair-addon-demo | [523-repair-addon-demo.md](samples/523-repair-addon-demo.md) |
| repair-addon-strict-output | [533-repair-addon-strict-output.md](samples/533-repair-addon-strict-output.md) |
| service-health-probe | [172-service-health-probe.md](samples/172-service-health-probe.md), [181-service-health-probe.md](samples/181-service-health-probe.md), [191-service-health-probe.md](samples/191-service-health-probe.md) |
| station-report-budget | [541-station-report-budget.md](samples/541-station-report-budget.md) |
| timeout-signal-helper | [49-timeout-signal-helper.md](samples/49-timeout-signal-helper.md), [49-timeout-signal-helper.ts](../../src/samples/49-timeout-signal-helper.ts) |

### Tests and CI
Expand Down Expand Up @@ -443,8 +449,10 @@ For a focused search, append `--family <slug>` or `--bucket <key>`; bucket keys
| shell-script-validator | [199-shell-script-validator.md](samples/199-shell-script-validator.md), [322-shell-script-validator.md](samples/322-shell-script-validator.md), [332-shell-script-validator.md](samples/332-shell-script-validator.md) |
| shell-shebang-glob-validator | [441-shell-shebang-glob-validator.md](samples/441-shell-shebang-glob-validator.md), [451-shell-shebang-glob-validator.md](samples/451-shell-shebang-glob-validator.md) |
| shell-shebang-validator | [387-shell-shebang-validator.md](samples/387-shell-shebang-validator.md) |
| shot-log-gap-reconciler | [549-shot-log-gap-reconciler.md](samples/549-shot-log-gap-reconciler.md) |
| stale-dep-detector | [170-stale-dep-detector.md](samples/170-stale-dep-detector.md) |
| todo-fixme-tracker | [194-todo-fixme-tracker.md](samples/194-todo-fixme-tracker.md) |
| transit-stop-translation-joiner | [543-transit-stop-translation-joiner.md](samples/543-transit-stop-translation-joiner.md) |
| workflow-step-duration-estimator | [319-workflow-step-duration-estimator.md](samples/319-workflow-step-duration-estimator.md) |
| zlib-compression-analyzer | [397-zlib-compression-analyzer.md](samples/397-zlib-compression-analyzer.md), [445-zlib-compression-analyzer.md](samples/445-zlib-compression-analyzer.md), [455-zlib-compression-analyzer.md](samples/455-zlib-compression-analyzer.md) |

Expand Down Expand Up @@ -581,6 +589,7 @@ For a focused search, append `--family <slug>` or `--bucket <key>`; bucket keys
| subagent-task-harness | [51-subagent-task-harness.md](samples/51-subagent-task-harness.md) |
| threat-detection | [330-threat-detection.md](samples/330-threat-detection.md) |
| three-way-project-health | [479-three-way-project-health.md](samples/479-three-way-project-health.md) |
| warehouse-slot-allocator | [548-warehouse-slot-allocator.md](samples/548-warehouse-slot-allocator.md) |

### Tests and CI

Expand Down Expand Up @@ -634,6 +643,7 @@ For a focused search, append `--family <slug>` or `--bucket <key>`; bucket keys
|--------|---------|
| budget-aware-crawler | [320-budget-aware-crawler.md](samples/320-budget-aware-crawler.md) |
| flat-workflow-port | [340-flat-workflow-port.md](samples/340-flat-workflow-port.md) |
| itinerary-budget-pipeline | [546-itinerary-budget-pipeline.md](samples/546-itinerary-budget-pipeline.md) |
| merge-strategy-selector | [410-merge-strategy-selector.md](samples/410-merge-strategy-selector.md), [466-merge-strategy-selector.md](samples/466-merge-strategy-selector.md) |
| multi-file-subagent-summarizer | [70-multi-file-subagent-summarizer.md](samples/70-multi-file-subagent-summarizer.md) |
| multi-stage-artifact-pipeline | [510-multi-stage-artifact-pipeline.md](samples/510-multi-stage-artifact-pipeline.md) |
Expand Down
25 changes: 25 additions & 0 deletions skills/rig/samples/541-station-report-budget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 541 - Station Report Budget

```rig
import { agent, p, s, timeout } from "rig";

// Agent role: summarize as many weather stations as possible from the log within the timeout budget.
const stationSummarizer = agent({
model: "small",
addons: timeout({ timeout: 8_000 }),
instructions: p`Read the multi-station weather log below:
${p.bash("printf '%s\\n' \"STATION: ALPHA-01 | DATE: 2024-05-01 | TEMP: 18C | WIND: 12km/h NE | SKY: clear\" \"STATION: ALPHA-01 | DATE: 2024-05-02 | TEMP: 20C | WIND: 15km/h NE | SKY: partly cloudy\" \"STATION: ALPHA-01 | DATE: 2024-05-03 | TEMP: 17C | WIND: 22km/h N | SKY: rain showers\" \"STATION: BRAVO-02 | DATE: 2024-05-01 | TEMP: 9C | WIND: 30km/h W | SKY: overcast\" \"STATION: BRAVO-02 | DATE: 2024-05-02 | TEMP: 7C | WIND: 35km/h W | SKY: snow flurries\" \"STATION: BRAVO-02 | DATE: 2024-05-03 | TEMP: 10C | WIND: 18km/h SW | SKY: clear\" \"STATION: CHARLIE-03 | DATE: 2024-05-01 | TEMP: 29C | WIND: 8km/h S | SKY: hot and humid\" \"STATION: CHARLIE-03 | DATE: 2024-05-02 | TEMP: 31C | WIND: 6km/h S | SKY: heat advisory\" \"STATION: CHARLIE-03 | DATE: 2024-05-03 | TEMP: 28C | WIND: 10km/h SE | SKY: thunderstorms\" \"STATION: DELTA-04 | DATE: 2024-05-01 | TEMP: 2C | WIND: 40km/h N | SKY: blizzard warning\" \"STATION: DELTA-04 | DATE: 2024-05-02 | TEMP: -1C | WIND: 45km/h N | SKY: heavy snow\" \"STATION: DELTA-04 | DATE: 2024-05-03 | TEMP: 1C | WIND: 25km/h NW | SKY: clearing\" \"STATION: ECHO-05 | DATE: 2024-05-01 | TEMP: 24C | WIND: 14km/h E | SKY: sunny\" \"STATION: ECHO-05 | DATE: 2024-05-02 | TEMP: 25C | WIND: 12km/h E | SKY: sunny\" \"STATION: ECHO-05 | DATE: 2024-05-03 | TEMP: 23C | WIND: 16km/h SE | SKY: scattered clouds\"")}

Process the stations strictly in the order they first appear (ALPHA-01, BRAVO-02, CHARLIE-03, DELTA-04, ECHO-05). For each station you have time to finish before the timeout budget expires, produce one summary entry with the station name and a one-sentence description of its conditions trend across the logged days. Stop immediately once the budget is tight rather than rushing an incomplete entry. Report how many stations you fully summarized, the list of completed summaries in order, and whether you had to stop early due to the timeout budget (truncatedDueToBudget).`,
output: s.object({
stationsSummarized: s.int,
summaries: s.array(s.object({
station: s.string,
conditions: s.string,
})),
truncatedDueToBudget: s.boolean,
}),
});

export default stationSummarizer;
```
42 changes: 42 additions & 0 deletions skills/rig/samples/542-shift-schedule-localizer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 542 - Shift Schedule Localizer

```rig
import { agent, p, s } from "rig";

// Agent role: translate each worker's assigned shift into a human-readable
// label for every supported locale, keeping the roster rows identical across
// locales while varying only the shift label text.
const localizer = agent({
model: "large",
instructions: p`Here is the factory shift roster (worker, shift code, station):

1. Alice Nguyen, MORNING, Station A
2. Ben Osei, MORNING, Station B
3. Carla Ruiz, AFTERNOON, Station A
4. Dmitri Volkov, AFTERNOON, Station C
5. Emeka Obi, NIGHT, Station B
6. Fatima Al-Sayed, NIGHT, Station C
7. Grace Lin, MORNING, Station C
8. Hassan Malik, AFTERNOON, Station B

Shift codes map to these English names: MORNING -> "Morning Shift",
AFTERNOON -> "Afternoon Shift", NIGHT -> "Night Shift".

Return a record keyed by exactly the four locale codes 'en', 'es', 'fr', 'de'.
Each locale's value must be an array with one entry per worker above, in the
same order, containing that worker's name and the shift name translated into
that locale (e.g. "Night Shift" in French is "Équipe de nuit"). Do not drop,
reorder, or partition workers across locales: every locale array must list all
8 workers, differing only in the translated shiftLabel text.`,
output: s.record(
s.array(
s.object({
worker: s.string,
shiftLabel: s.string,
}),
),
),
});

export default localizer;
```
50 changes: 50 additions & 0 deletions skills/rig/samples/543-transit-stop-translation-joiner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 543 - Transit Stop Translation Joiner

```rig
import { agent, defineTool, p, s } from "rig";

// Tool: look up a translated label for a stop in a given locale from an embedded table.
const lookupTranslation = defineTool("lookup_translation", {
description: "Look up the translated label for a transit stop in a given locale.",
parameters: s.object({
stopId: s.string,
locale: s.string,
}),
handler: async ({ stopId, locale }: { stopId: string; locale: string }) => {
const table: Record<string, Record<string, string>> = {
"stop-1": { en: "Central Station", fr: "Gare Centrale" },
"stop-2": { en: "Market Square" },
"stop-3": { en: "Riverside", fr: "Bord de Riviere" },
"stop-4": { en: "Harbor View" },
};
const label = table[stopId]?.[locale];
return { label: label === undefined ? undefined : label };
},
});

// Agent role: join embedded transit stops against French translations, mapping missing lookups to null.
const transitStopTranslationJoiner = agent({
model: "small",
tools: [lookupTranslation],
instructions: p`Here are the transit stops with their route IDs:
- stop-1: routes ["R1", "R2"]
- stop-2: routes ["R3"]
- stop-3: routes ["R2", "R4"]
- stop-4: routes ["R5"]

For each stop, call lookup_translation with its stopId and locale "fr" to
find its French label. If the tool returns no label (the label field is
absent/undefined), set the output label to null for that stop rather than
omitting it. Return one entry per stop joining its stopId, routeIds, and
resolved label (string or null).`,
output: s.array(
s.object({
stopId: s.string,
routeIds: s.array(s.string),
label: s.nullable(s.string),
}),
),
});

export default transitStopTranslationJoiner;
```
50 changes: 50 additions & 0 deletions skills/rig/samples/544-species-observation-digest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 544 - Species Observation Digest

```rig
import { agent, p, s } from "rig";

// Agent role: parse a synthetic field-survey log, write a species digest
// report, and summarize the most common local name per species.
const speciesObservationDigest = agent({
model: "small",
instructions: p`Read the field-survey log below, produced by
${p.bash(`printf '%s\\n' \
"english,local_fr,local_sw" \
"Grey Heron,Heron cendre,Korongo" \
"African Fish Eagle,Pygargue vocifere,Furukombe" \
"Grey Heron,Heron cendre,Nyange" \
"Lesser Flamingo,Flamant nain,Heroe mdogo" \
"African Fish Eagle,Pygargue vocifere,Furukombe" \
"Grey Heron,Aigrette grise,Korongo" \
"Lesser Flamingo,Flamant nain,Heroe mdogo" \
"African Fish Eagle,Pygargue vocifere,Tai" \
"Grey Heron,Heron cendre,Korongo" \
"Lesser Flamingo,Flamant rose nain,Heroe mdogo" \
"African Fish Eagle,Aigle pecheur,Furukombe" \
"Grey Heron,Heron cendre,Korongo"`)}

Each data row (after the header) lists: english common name, a French
local label, and a Swahili local label for one observation. Group rows by
the canonical English species name. For each species, count total
observations and tally how often each distinct local-language label
(French or Swahili column value) appears across its observations.

Compose a markdown digest with a heading, a table of species and their
observation counts, and for each species a short line noting its most
frequently used local label. Then write that digest via
${p.write("species-digest-report.md", "# Species Observation Digest\n")}.

Return reportPath ("species-digest-report.md"), speciesCount (the number
of distinct species), and mostCommonLocalName: a record mapping each
canonical English species name to the single local-language label (French
or Swahili) that occurred most often among that species' observations,
breaking ties by picking the label that appears first in the log.`,
output: s.object({
reportPath: s.path,
speciesCount: s.int,
mostCommonLocalName: s.record(s.string),
}),
});

export default speciesObservationDigest;
```
42 changes: 42 additions & 0 deletions skills/rig/samples/545-recipe-conversion-delta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 545 - Recipe Conversion Delta

```rig
import { agent, p, s } from "rig";

// Agent role: merge a baseline recipe with a sparse list of changed ingredients
// into one row per ingredient, carrying forward unchanged amounts.
const recipeConversionDelta = agent({
model: "small",
instructions: p`Baseline recipe (ingredient, amount, unit):
1. Flour, 500, g
2. Sugar, 200, g
3. Butter, 150, g
4. Eggs, 3, count
5. Milk, 250, ml
6. Baking powder, 10, g

Partial update list (only ingredients that changed, with new amounts):
- Flour: 750 g
- Milk: 300 ml
- Eggs: 4 count

For every ingredient in the baseline recipe, produce one row in the output array:
- If the ingredient name appears in the update list, set previousAmount to the
original baseline amount, newAmount to the updated amount, unit to the unit,
and changed to true.
- If the ingredient does not appear in the update list, omit previousAmount
entirely (do not set it to null or 0), set newAmount to the original baseline
amount, unit to the baseline unit, and changed to false.
Preserve the original baseline order and include every one of the 6 ingredients
exactly once. Return only the declared output.`,
output: s.array(s.object({
ingredient: s.string,
previousAmount: s.optional(s.number),
newAmount: s.number,
unit: s.string,
changed: s.boolean,
})),
});

export default recipeConversionDelta;
```
Loading
Loading