diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3cbaef..72bee5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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" diff --git a/scripts/run-sample.test.ts b/scripts/run-sample.test.ts index 3cb5181..48b6d7b 100644 --- a/scripts/run-sample.test.ts +++ b/scripts/run-sample.test.ts @@ -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"; @@ -282,7 +281,7 @@ 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"); @@ -290,13 +289,24 @@ describe("skill markdown samples typecheck", () => { 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 { diff --git a/skills/rig/samples/03-diagnose-test-failure.md b/skills/rig/samples/03-diagnose-test-failure.md index f14e3b8..d754dfd 100644 --- a/skills/rig/samples/03-diagnose-test-failure.md +++ b/skills/rig/samples/03-diagnose-test-failure.md @@ -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", @@ -21,6 +21,5 @@ const reviewer = agent({ Return only the declared output shape. `, }); - export default reviewer; ``` diff --git a/skills/rig/samples/04-generate-readme.md b/skills/rig/samples/04-generate-readme.md index 6293704..9350dce 100644 --- a/skills/rig/samples/04-generate-readme.md +++ b/skills/rig/samples/04-generate-readme.md @@ -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", @@ -22,6 +16,5 @@ const diagnose = agent({ Do not edit files. `, }); - export default diagnose; ``` diff --git a/skills/rig/samples/05-write-readme-intent.md b/skills/rig/samples/05-write-readme-intent.md index f013425..e358775 100644 --- a/skills/rig/samples/05-write-readme-intent.md +++ b/skills/rig/samples/05-write-readme-intent.md @@ -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", @@ -14,6 +14,5 @@ const readmeWriter = agent({ Include install, usage, and API sections. `, }); - export default readmeWriter; ``` diff --git a/skills/rig/samples/07-summarize-many-files.md b/skills/rig/samples/07-summarize-many-files.md index 56c3388..602163d 100644 --- a/skills/rig/samples/07-summarize-many-files.md +++ b/skills/rig/samples/07-summarize-many-files.md @@ -1,10 +1,8 @@ # 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.", @@ -12,6 +10,5 @@ const summarizeFiles = agent({ summary: s.string, }), }); - export default summarizeFiles; ``` diff --git a/skills/rig/samples/11-release-notes.md b/skills/rig/samples/11-release-notes.md index bd1f6ae..0652c2f 100644 --- a/skills/rig/samples/11-release-notes.md +++ b/skills/rig/samples/11-release-notes.md @@ -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", @@ -13,6 +13,5 @@ const triage = agent({ }), instructions: `Triage the pull request and recommend reviewers.`, }); - export default triage; ``` diff --git a/skills/rig/samples/12-security-scan-review.md b/skills/rig/samples/12-security-scan-review.md index 09673ff..bc82b4e 100644 --- a/skills/rig/samples/12-security-scan-review.md +++ b/skills/rig/samples/12-security-scan-review.md @@ -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", @@ -13,6 +13,5 @@ const releaseNotes = agent({ }), instructions: `Write release notes from commits. Omit empty sections as empty arrays.`, }); - export default releaseNotes; ``` diff --git a/skills/rig/samples/13-test-plan.md b/skills/rig/samples/13-test-plan.md index 656a512..bce219f 100644 --- a/skills/rig/samples/13-test-plan.md +++ b/skills/rig/samples/13-test-plan.md @@ -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", @@ -15,6 +15,5 @@ const securityReview = agent({ }), instructions: `Review dependency security posture from the provided outputs.`, }); - export default securityReview; ``` diff --git a/skills/rig/samples/14-changelog-categorizer.md b/skills/rig/samples/14-changelog-categorizer.md index bf2bbed..5205e45 100644 --- a/skills/rig/samples/14-changelog-categorizer.md +++ b/skills/rig/samples/14-changelog-categorizer.md @@ -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", @@ -12,6 +12,5 @@ const planner = agent({ }), instructions: `Create a focused validation plan for the current changes.`, }); - export default planner; ``` diff --git a/skills/rig/samples/16-docs-gap-analysis.md b/skills/rig/samples/16-docs-gap-analysis.md index c33bb16..fc8ac4b 100644 --- a/skills/rig/samples/16-docs-gap-analysis.md +++ b/skills/rig/samples/16-docs-gap-analysis.md @@ -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", @@ -12,6 +12,5 @@ const apiDiff = agent({ }), instructions: `Compare public API declarations and identify breaking changes.`, }); - export default apiDiff; ``` diff --git a/skills/rig/samples/17-refactor-plan.md b/skills/rig/samples/17-refactor-plan.md index 3a096b4..81d676f 100644 --- a/skills/rig/samples/17-refactor-plan.md +++ b/skills/rig/samples/17-refactor-plan.md @@ -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", @@ -12,6 +12,5 @@ const docsGap = agent({ }), instructions: `Find documentation gaps against the source API.`, }); - export default docsGap; ``` diff --git a/skills/rig/samples/18-patch-writer-output.md b/skills/rig/samples/18-patch-writer-output.md index f7e57e5..04fae12 100644 --- a/skills/rig/samples/18-patch-writer-output.md +++ b/skills/rig/samples/18-patch-writer-output.md @@ -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", @@ -12,6 +12,5 @@ const refactorPlan = agent({ }), instructions: `Plan a minimal, low-risk refactor. Do not edit files.`, }); - export default refactorPlan; ``` diff --git a/skills/rig/samples/19-fix-then-review.md b/skills/rig/samples/19-fix-then-review.md index 2d7606f..7bb4156 100644 --- a/skills/rig/samples/19-fix-then-review.md +++ b/skills/rig/samples/19-fix-then-review.md @@ -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", @@ -12,6 +12,5 @@ const patcher = agent({ }), instructions: `Return a complete replacement for the target file.`, }); - export default patcher; ``` diff --git a/skills/rig/samples/22-config-normalizer.md b/skills/rig/samples/22-config-normalizer.md index 28ef882..82838b2 100644 --- a/skills/rig/samples/22-config-normalizer.md +++ b/skills/rig/samples/22-config-normalizer.md @@ -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", @@ -12,6 +12,5 @@ const ciDiagnosis = agent({ }), instructions: `Diagnose the CI log. Prefer the first real failure over cascading errors.`, }); - export default ciDiagnosis; ``` diff --git a/skills/rig/samples/23-schema-inference.md b/skills/rig/samples/23-schema-inference.md index 32b8639..bb03da6 100644 --- a/skills/rig/samples/23-schema-inference.md +++ b/skills/rig/samples/23-schema-inference.md @@ -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", @@ -11,6 +11,5 @@ const normalize = agent({ }), instructions: `Normalize the config into a JSON-compatible object.`, }); - export default normalize; ``` diff --git a/skills/rig/samples/24-error-message-improver.md b/skills/rig/samples/24-error-message-improver.md index 8da215f..5c4d94c 100644 --- a/skills/rig/samples/24-error-message-improver.md +++ b/skills/rig/samples/24-error-message-improver.md @@ -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", @@ -15,6 +15,5 @@ const inferShape = agent({ }), instructions: `Infer a practical runtime-visible schema from the samples.`, }); - export default inferShape; ``` diff --git a/skills/rig/samples/28-license-check.md b/skills/rig/samples/28-license-check.md index 0e5158b..815c8da 100644 --- a/skills/rig/samples/28-license-check.md +++ b/skills/rig/samples/28-license-check.md @@ -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", @@ -16,6 +16,5 @@ const upgradePlan = agent({ }), instructions: `Plan safe dependency upgrades.`, }); - export default upgradePlan; ``` diff --git a/skills/rig/samples/29-bug-report-draft.md b/skills/rig/samples/29-bug-report-draft.md index 53e088a..7af8e66 100644 --- a/skills/rig/samples/29-bug-report-draft.md +++ b/skills/rig/samples/29-bug-report-draft.md @@ -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", @@ -16,6 +16,5 @@ const licenseCheck = agent({ }), instructions: `Flag unknown or concerning dependency licenses.`, }); - export default licenseCheck; ``` diff --git a/skills/rig/samples/30-github-action-review.md b/skills/rig/samples/30-github-action-review.md index 98ec462..9f750bb 100644 --- a/skills/rig/samples/30-github-action-review.md +++ b/skills/rig/samples/30-github-action-review.md @@ -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", @@ -12,6 +12,5 @@ const bugReport = agent({ }), instructions: `Draft a GitHub bug report from the failure details.`, }); - export default bugReport; ``` diff --git a/skills/rig/samples/31-monorepo-package-map.md b/skills/rig/samples/31-monorepo-package-map.md index bcfcb5f..594b902 100644 --- a/skills/rig/samples/31-monorepo-package-map.md +++ b/skills/rig/samples/31-monorepo-package-map.md @@ -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", @@ -12,6 +12,5 @@ const actionReview = agent({ }), instructions: `Review the workflow for reliability, caching, and least privilege.`, }); - export default actionReview; ``` diff --git a/skills/rig/samples/32-command-planner.md b/skills/rig/samples/32-command-planner.md index 0c752ab..49a318e 100644 --- a/skills/rig/samples/32-command-planner.md +++ b/skills/rig/samples/32-command-planner.md @@ -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", @@ -19,6 +19,5 @@ const packageMap = agent({ }), instructions: `Build a package map for a JavaScript monorepo.`, }); - export default packageMap; ``` diff --git a/skills/rig/samples/34-intent-options.md b/skills/rig/samples/34-intent-options.md index c1bc7d7..4579013 100644 --- a/skills/rig/samples/34-intent-options.md +++ b/skills/rig/samples/34-intent-options.md @@ -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", @@ -11,6 +11,5 @@ const investigator = agent({ }), instructions: `Investigate the project using only readonly evidence.`, }); - export default investigator; ``` diff --git a/skills/rig/samples/35-call-options.md b/skills/rig/samples/35-call-options.md index 782c90d..99c46de 100644 --- a/skills/rig/samples/35-call-options.md +++ b/skills/rig/samples/35-call-options.md @@ -1,7 +1,7 @@ # 35 - Call Options ```rig -import { agent, p, s } from "rig"; +import { agent, s } from "rig"; // Agent role: parse environment outputs. const envReader = agent({ model: "mini", @@ -11,6 +11,5 @@ const envReader = agent({ }), instructions: `Parse environment outputs.`, }); - export default envReader; ``` diff --git a/skills/rig/samples/40-record-output.md b/skills/rig/samples/40-record-output.md index f3ef379..c3eb1b7 100644 --- a/skills/rig/samples/40-record-output.md +++ b/skills/rig/samples/40-record-output.md @@ -1,7 +1,7 @@ # 40 - Record Output ```rig -import { agent, p, s } from "rig"; +import { agent, s } from "rig"; // Agent role: extract any JSON object from input.text into raw. const extractJson = agent({ model: "mini", @@ -11,6 +11,5 @@ const extractJson = agent({ }), instructions: `Extract any JSON object from input.text into raw.`, }); - export default extractJson; ``` diff --git a/skills/rig/samples/41-parse-coverage.md b/skills/rig/samples/41-parse-coverage.md index defc58b..3cd2bf7 100644 --- a/skills/rig/samples/41-parse-coverage.md +++ b/skills/rig/samples/41-parse-coverage.md @@ -1,7 +1,7 @@ # 41 - Parse Coverage ```rig -import { agent, p, s } from "rig"; +import { agent, s } from "rig"; // Agent role: parse coverage by file path. const coverage = agent({ model: "mini", @@ -14,6 +14,5 @@ const coverage = agent({ }), instructions: `Parse coverage by file path.`, }); - export default coverage; ``` diff --git a/skills/rig/samples/44-flaky-test-analysis.md b/skills/rig/samples/44-flaky-test-analysis.md index e4e4e1e..fc8cf05 100644 --- a/skills/rig/samples/44-flaky-test-analysis.md +++ b/skills/rig/samples/44-flaky-test-analysis.md @@ -1,7 +1,7 @@ # 44 - Flaky Test Analysis ```rig -import { agent, p, s } from "rig"; +import { agent, s } from "rig"; // Agent role: decide whether snapshot updates are legitimate. const snapshotReview = agent({ model: "mini", @@ -12,6 +12,5 @@ const snapshotReview = agent({ }), instructions: `Decide whether snapshot updates are legitimate.`, }); - export default snapshotReview; ``` diff --git a/skills/rig/samples/45-code-owner-suggestion.md b/skills/rig/samples/45-code-owner-suggestion.md index 779b790..10fd1b9 100644 --- a/skills/rig/samples/45-code-owner-suggestion.md +++ b/skills/rig/samples/45-code-owner-suggestion.md @@ -1,7 +1,7 @@ # 45 - Code Owner Suggestion ```rig -import { agent, p, s } from "rig"; +import { agent, s } from "rig"; // Agent role: analyze whether the test failure appears flaky. const flaky = agent({ model: "mini", @@ -12,6 +12,5 @@ const flaky = agent({ }), instructions: `Analyze whether the test failure appears flaky.`, }); - export default flaky; ``` diff --git a/skills/rig/samples/46-prompt-intent-inspection.md b/skills/rig/samples/46-prompt-intent-inspection.md index 7217d60..fb052d9 100644 --- a/skills/rig/samples/46-prompt-intent-inspection.md +++ b/skills/rig/samples/46-prompt-intent-inspection.md @@ -1,7 +1,7 @@ # 46 - Prompt Intent Inspection ```rig -import { agent, p, s } from "rig"; +import { agent, s } from "rig"; // Agent role: suggest owners for changed files. const owners = agent({ model: "mini", @@ -11,6 +11,5 @@ const owners = agent({ }), instructions: `Suggest owners for changed files.`, }); - export default owners; ``` diff --git a/skills/rig/samples/47-prompt-intents.md b/skills/rig/samples/47-prompt-intents.md index db2932d..a645754 100644 --- a/skills/rig/samples/47-prompt-intents.md +++ b/skills/rig/samples/47-prompt-intents.md @@ -1,10 +1,8 @@ # 47 - Prompt Intents ```rig -import { agent, p, s } from "rig"; - +import { agent, s } from "rig"; // Agent role: summarize the current git workspace changes. - const promptIntents = agent({ model: "mini", instructions: "Summarize the current git workspace changes.", @@ -13,6 +11,5 @@ const promptIntents = agent({ changedFiles: s.array(s.string), }), }); - export default promptIntents; ``` diff --git a/skills/rig/samples/49-timeout-signal-helper.md b/skills/rig/samples/49-timeout-signal-helper.md index 6eaa2df..32f6c12 100644 --- a/skills/rig/samples/49-timeout-signal-helper.md +++ b/skills/rig/samples/49-timeout-signal-helper.md @@ -1,7 +1,7 @@ # 49 - Timeout Signal Helper ```rig -import { agent, s, timeout } from "rig"; +import { agent, timeout } from "rig"; // Agent role: return a short response before the timeout expires. const worker = agent({ model: "mini", diff --git a/skills/rig/samples/70-multi-file-subagent-summarizer.md b/skills/rig/samples/70-multi-file-subagent-summarizer.md index 0fdeda8..372fb13 100644 --- a/skills/rig/samples/70-multi-file-subagent-summarizer.md +++ b/skills/rig/samples/70-multi-file-subagent-summarizer.md @@ -13,7 +13,6 @@ const fileSummarizer = agent({ // Workflow role: deterministically discover files, run subagent summaries in parallel, and aggregate by file path. const multiFileSummarizer = workflow({ meta: { name: "multiFileSummarizer", description: "Summarize TypeScript files", phases: ["Discover", "Summarize"] }, - output: s.record(s.string), body: async ({ call, phase, pipeline }) => { phase("Discover"); const raw = await call.text(