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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ jobs:

- name: Test
run: npm test

- name: Typecheck extracted markdown rig samples
run: npm run sample -- --testNamePattern="skill markdown samples typecheck"
18 changes: 14 additions & 4 deletions scripts/run-sample.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { describe, it, expect, beforeEach, vi } from "vitest";
import { readFileSync, readdirSync } from "fs";
import { mkdtemp, rm, writeFile } from "fs/promises";
import { tmpdir } from "os";
import { resolve } from "path";
import { Readable, Writable } from "stream";
import { execFile } from "child_process";
Expand Down Expand Up @@ -282,21 +281,32 @@ describe("skill markdown samples", () => {

describe("skill markdown samples typecheck", () => {
it("typechecks extracted rig programs with npx tsc", async () => {
const typecheckDir = await mkdtemp(resolve(tmpdir(), "rig-sample-typecheck-"));
const typecheckDir = await mkdtemp(resolve(__dirname, ".tmp-rig-sample-typecheck-"));
try {
for (const file of markdownTargets) {
const markdown = readFileSync(resolve(markdownDir, file), "utf8");
const code = withTypecheckModel(extractRigCode(markdown));
const tsFile = resolve(typecheckDir, file.replace(/\.md$/, ".ts"));
await writeFile(tsFile, `${code}\n`, "utf8");
}
const tsconfigPath = resolve(typecheckDir, "tsconfig.json");
await writeFile(
tsconfigPath,
JSON.stringify(
{
extends: "../../tsconfig.json",
include: ["./*.ts"],
},
null,
2,
),
);

await execFileAsync(
"npx",
["--yes", "--package", "typescript@5.9.3", "--", "tsc", "--noEmit", "--pretty", "false"],
["tsc", "--project", tsconfigPath, "--pretty", "false"],
{
cwd: resolve(__dirname, ".."),
env: { ...process.env, npm_config_ignore_scripts: "true" },
},
);
} finally {
Expand Down
3 changes: 1 addition & 2 deletions skills/rig/samples/03-diagnose-test-failure.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 03 - Diagnose Test Failure

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: review input.diff for correctness and regression risks. Return only the declared output shape.
const reviewer = agent({
model: "mini",
Expand All @@ -21,6 +21,5 @@ const reviewer = agent({
Return only the declared output shape.
`,
});

export default reviewer;
```
9 changes: 1 addition & 8 deletions skills/rig/samples/04-generate-readme.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# 04 - Generate Readme

```rig
import { agent, p, s } from "rig";
const ShResult = s.object({
ok: s.boolean,
stdout: s.string,
stderr: s.string,
exitCode: s.number
});
import { agent, s } from "rig";
// Agent role: diagnose the failing test result. Do not edit files.
const diagnose = agent({
model: "mini",
Expand All @@ -22,6 +16,5 @@ const diagnose = agent({
Do not edit files.
`,
});

export default diagnose;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/05-write-readme-intent.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 05 - Write Readme Intent

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: generate a concise README for the package. Include install, usage, and API sections.
const readmeWriter = agent({
model: "mini",
Expand All @@ -14,6 +14,5 @@ const readmeWriter = agent({
Include install, usage, and API sections.
`,
});

export default readmeWriter;
```
5 changes: 1 addition & 4 deletions skills/rig/samples/07-summarize-many-files.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# 07 - Summarize Many Files

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

import { agent, s } from "rig";
// Agent role: summarize the repository file list in one sentence.

const summarizeFiles = agent({
model: "mini",
instructions: "Summarize the repository file list in one sentence.",
output: s.object({
summary: s.string,
}),
});

export default summarizeFiles;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/11-release-notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 11 - Release Notes

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: triage the pull request and recommend reviewers.
const triage = agent({
model: "mini",
Expand All @@ -13,6 +13,5 @@ const triage = agent({
}),
instructions: `Triage the pull request and recommend reviewers.`,
});

export default triage;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/12-security-scan-review.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 12 - Security Scan Review

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: write release notes from commits. Omit empty sections as empty arrays.
const releaseNotes = agent({
model: "mini",
Expand All @@ -13,6 +13,5 @@ const releaseNotes = agent({
}),
instructions: `Write release notes from commits. Omit empty sections as empty arrays.`,
});

export default releaseNotes;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/13-test-plan.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 13 - Test Plan

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: review dependency security posture from the provided outputs.
const securityReview = agent({
model: "mini",
Expand All @@ -15,6 +15,5 @@ const securityReview = agent({
}),
instructions: `Review dependency security posture from the provided outputs.`,
});

export default securityReview;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/14-changelog-categorizer.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 14 - Changelog Categorizer

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: create a focused validation plan for the current changes.
const planner = agent({
model: "mini",
Expand All @@ -12,6 +12,5 @@ const planner = agent({
}),
instructions: `Create a focused validation plan for the current changes.`,
});

export default planner;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/16-docs-gap-analysis.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 16 - Docs Gap Analysis

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: compare public API declarations and identify breaking changes.
const apiDiff = agent({
model: "mini",
Expand All @@ -12,6 +12,5 @@ const apiDiff = agent({
}),
instructions: `Compare public API declarations and identify breaking changes.`,
});

export default apiDiff;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/17-refactor-plan.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 17 - Refactor Plan

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: find documentation gaps against the source API.
const docsGap = agent({
model: "mini",
Expand All @@ -12,6 +12,5 @@ const docsGap = agent({
}),
instructions: `Find documentation gaps against the source API.`,
});

export default docsGap;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/18-patch-writer-output.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 18 - Patch Writer Output

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: plan a minimal, low-risk refactor. Do not edit files.
const refactorPlan = agent({
model: "mini",
Expand All @@ -12,6 +12,5 @@ const refactorPlan = agent({
}),
instructions: `Plan a minimal, low-risk refactor. Do not edit files.`,
});
export default refactorPlan;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/19-fix-then-review.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 19 - Fix Then Review

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: return a complete replacement for the target file.
const patcher = agent({
model: "mini",
Expand All @@ -12,6 +12,5 @@ const patcher = agent({
}),
instructions: `Return a complete replacement for the target file.`,
});

export default patcher;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/22-config-normalizer.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 22 - Config Normalizer

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: diagnose the CI log. Prefer the first real failure over cascading errors.
const ciDiagnosis = agent({
model: "mini",
Expand All @@ -12,6 +12,5 @@ const ciDiagnosis = agent({
}),
instructions: `Diagnose the CI log. Prefer the first real failure over cascading errors.`,
});

export default ciDiagnosis;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/23-schema-inference.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 23 - Schema Inference

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: normalize the config into a JSON-compatible object.
const normalize = agent({
model: "mini",
Expand All @@ -11,6 +11,5 @@ const normalize = agent({
}),
instructions: `Normalize the config into a JSON-compatible object.`,
});

export default normalize;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/24-error-message-improver.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 24 - Error Message Improver

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: infer a practical runtime-visible schema from the samples.
const inferShape = agent({
model: "mini",
Expand All @@ -15,6 +15,5 @@ const inferShape = agent({
}),
instructions: `Infer a practical runtime-visible schema from the samples.`,
});

export default inferShape;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/28-license-check.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 28 - License Check

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: plan safe dependency upgrades.
const upgradePlan = agent({
model: "mini",
Expand All @@ -16,6 +16,5 @@ const upgradePlan = agent({
}),
instructions: `Plan safe dependency upgrades.`,
});

export default upgradePlan;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/29-bug-report-draft.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 29 - Bug Report Draft

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: flag unknown or concerning dependency licenses.
const licenseCheck = agent({
model: "mini",
Expand All @@ -16,6 +16,5 @@ const licenseCheck = agent({
}),
instructions: `Flag unknown or concerning dependency licenses.`,
});

export default licenseCheck;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/30-github-action-review.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 30 - Github Action Review

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: draft a GitHub bug report from the failure details.
const bugReport = agent({
model: "mini",
Expand All @@ -12,6 +12,5 @@ const bugReport = agent({
}),
instructions: `Draft a GitHub bug report from the failure details.`,
});

export default bugReport;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/31-monorepo-package-map.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 31 - Monorepo Package Map

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: review the workflow for reliability, caching, and least privilege.
const actionReview = agent({
model: "mini",
Expand All @@ -12,6 +12,5 @@ const actionReview = agent({
}),
instructions: `Review the workflow for reliability, caching, and least privilege.`,
});

export default actionReview;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/32-command-planner.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 32 - Command Planner

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: build a package map for a JavaScript monorepo.
const packageMap = agent({
model: "mini",
Expand All @@ -19,6 +19,5 @@ const packageMap = agent({
}),
instructions: `Build a package map for a JavaScript monorepo.`,
});

export default packageMap;
```
3 changes: 1 addition & 2 deletions skills/rig/samples/34-intent-options.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 34 - Intent Options

```rig
import { agent, p, s } from "rig";
import { agent, s } from "rig";
// Agent role: investigate the project using only readonly evidence.
const investigator = agent({
model: "mini",
Expand All @@ -11,6 +11,5 @@ const investigator = agent({
}),
instructions: `Investigate the project using only readonly evidence.`,
});

export default investigator;
```
Loading