Skip to content

Commit 40f3626

Browse files
Copilotpelikhan
andauthored
Enforce CI typechecking for extracted Rig markdown samples (#275)
* Add CI coverage for extracted markdown sample typechecks Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> * Enforce unused checks for extracted markdown sample typecheck Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent b630e04 commit 40f3626

32 files changed

Lines changed: 46 additions & 72 deletions

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ jobs:
2828

2929
- name: Test
3030
run: npm test
31+
32+
- name: Typecheck extracted markdown rig samples
33+
run: npm run sample -- --testNamePattern="skill markdown samples typecheck"

‎scripts/run-sample.test.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { describe, it, expect, beforeEach, vi } from "vitest";
77
import { readFileSync, readdirSync } from "fs";
88
import { mkdtemp, rm, writeFile } from "fs/promises";
9-
import { tmpdir } from "os";
109
import { resolve } from "path";
1110
import { Readable, Writable } from "stream";
1211
import { execFile } from "child_process";
@@ -282,21 +281,32 @@ describe("skill markdown samples", () => {
282281

283282
describe("skill markdown samples typecheck", () => {
284283
it("typechecks extracted rig programs with npx tsc", async () => {
285-
const typecheckDir = await mkdtemp(resolve(tmpdir(), "rig-sample-typecheck-"));
284+
const typecheckDir = await mkdtemp(resolve(__dirname, ".tmp-rig-sample-typecheck-"));
286285
try {
287286
for (const file of markdownTargets) {
288287
const markdown = readFileSync(resolve(markdownDir, file), "utf8");
289288
const code = withTypecheckModel(extractRigCode(markdown));
290289
const tsFile = resolve(typecheckDir, file.replace(/\.md$/, ".ts"));
291290
await writeFile(tsFile, `${code}\n`, "utf8");
292291
}
292+
const tsconfigPath = resolve(typecheckDir, "tsconfig.json");
293+
await writeFile(
294+
tsconfigPath,
295+
JSON.stringify(
296+
{
297+
extends: "../../tsconfig.json",
298+
include: ["./*.ts"],
299+
},
300+
null,
301+
2,
302+
),
303+
);
293304

294305
await execFileAsync(
295306
"npx",
296-
["--yes", "--package", "typescript@5.9.3", "--", "tsc", "--noEmit", "--pretty", "false"],
307+
["tsc", "--project", tsconfigPath, "--pretty", "false"],
297308
{
298309
cwd: resolve(__dirname, ".."),
299-
env: { ...process.env, npm_config_ignore_scripts: "true" },
300310
},
301311
);
302312
} finally {

‎skills/rig/samples/03-diagnose-test-failure.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 03 - Diagnose Test Failure
22

33
```rig
4-
import { agent, p, s } from "rig";
4+
import { agent, s } from "rig";
55
// Agent role: review input.diff for correctness and regression risks. Return only the declared output shape.
66
const reviewer = agent({
77
model: "mini",
@@ -21,6 +21,5 @@ const reviewer = agent({
2121
Return only the declared output shape.
2222
`,
2323
});
24-
2524
export default reviewer;
2625
```
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
# 04 - Generate Readme
22

33
```rig
4-
import { agent, p, s } from "rig";
5-
const ShResult = s.object({
6-
ok: s.boolean,
7-
stdout: s.string,
8-
stderr: s.string,
9-
exitCode: s.number
10-
});
4+
import { agent, s } from "rig";
115
// Agent role: diagnose the failing test result. Do not edit files.
126
const diagnose = agent({
137
model: "mini",
@@ -22,6 +16,5 @@ const diagnose = agent({
2216
Do not edit files.
2317
`,
2418
});
25-
2619
export default diagnose;
2720
```

‎skills/rig/samples/05-write-readme-intent.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 05 - Write Readme Intent
22

33
```rig
4-
import { agent, p, s } from "rig";
4+
import { agent, s } from "rig";
55
// Agent role: generate a concise README for the package. Include install, usage, and API sections.
66
const readmeWriter = agent({
77
model: "mini",
@@ -14,6 +14,5 @@ const readmeWriter = agent({
1414
Include install, usage, and API sections.
1515
`,
1616
});
17-
1817
export default readmeWriter;
1918
```
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
# 07 - Summarize Many Files
22

33
```rig
4-
import { agent, p, s } from "rig";
5-
4+
import { agent, s } from "rig";
65
// Agent role: summarize the repository file list in one sentence.
7-
86
const summarizeFiles = agent({
97
model: "mini",
108
instructions: "Summarize the repository file list in one sentence.",
119
output: s.object({
1210
summary: s.string,
1311
}),
1412
});
15-
1613
export default summarizeFiles;
1714
```

‎skills/rig/samples/11-release-notes.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 11 - Release Notes
22

33
```rig
4-
import { agent, p, s } from "rig";
4+
import { agent, s } from "rig";
55
// Agent role: triage the pull request and recommend reviewers.
66
const triage = agent({
77
model: "mini",
@@ -13,6 +13,5 @@ const triage = agent({
1313
}),
1414
instructions: `Triage the pull request and recommend reviewers.`,
1515
});
16-
1716
export default triage;
1817
```

‎skills/rig/samples/12-security-scan-review.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 12 - Security Scan Review
22

33
```rig
4-
import { agent, p, s } from "rig";
4+
import { agent, s } from "rig";
55
// Agent role: write release notes from commits. Omit empty sections as empty arrays.
66
const releaseNotes = agent({
77
model: "mini",
@@ -13,6 +13,5 @@ const releaseNotes = agent({
1313
}),
1414
instructions: `Write release notes from commits. Omit empty sections as empty arrays.`,
1515
});
16-
1716
export default releaseNotes;
1817
```

‎skills/rig/samples/13-test-plan.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 13 - Test Plan
22

33
```rig
4-
import { agent, p, s } from "rig";
4+
import { agent, s } from "rig";
55
// Agent role: review dependency security posture from the provided outputs.
66
const securityReview = agent({
77
model: "mini",
@@ -15,6 +15,5 @@ const securityReview = agent({
1515
}),
1616
instructions: `Review dependency security posture from the provided outputs.`,
1717
});
18-
1918
export default securityReview;
2019
```

‎skills/rig/samples/14-changelog-categorizer.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 14 - Changelog Categorizer
22

33
```rig
4-
import { agent, p, s } from "rig";
4+
import { agent, s } from "rig";
55
// Agent role: create a focused validation plan for the current changes.
66
const planner = agent({
77
model: "mini",
@@ -12,6 +12,5 @@ const planner = agent({
1212
}),
1313
instructions: `Create a focused validation plan for the current changes.`,
1414
});
15-
1615
export default planner;
1716
```

0 commit comments

Comments
 (0)