From 5145971891e15f0294e04e5c98abe1c66ae2290a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Jul 2026 10:49:37 +0000 Subject: [PATCH 1/2] Initial plan From e3340b1d3cac4798ee95d451d08a3d4d5e9ffabc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Jul 2026 10:54:10 +0000 Subject: [PATCH 2/2] fix: make sample 318 stdin-runnable Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../rig/samples/318-ts-barrel-re-exporter.md | 53 +++++-------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/skills/rig/samples/318-ts-barrel-re-exporter.md b/skills/rig/samples/318-ts-barrel-re-exporter.md index 9c15060..059d050 100644 --- a/skills/rig/samples/318-ts-barrel-re-exporter.md +++ b/skills/rig/samples/318-ts-barrel-re-exporter.md @@ -3,50 +3,21 @@ ```rig import { agent, p, s, defineTool, repair } from "rig"; import { readFile } from "node:fs/promises"; - -// Agent role: generate a barrel index.ts that re-exports all exported symbols from TypeScript files in a directory. +// Agent role: generate a barrel file for exported symbols in skills/rig/engines. const tsBarrelReExporter = agent({ model: "small", - input: s.object({ - sourceDir: s.path, - outputFile: s.path, - }), - instructions: p`You are a TypeScript barrel re-exporter. - -Find TypeScript source files to barrel (excluding index files): -${p.bash("find . -name '*.ts' -not -name 'index.ts' -not -name '*.test.ts' -not -name '*.d.ts' -not -path '*/node_modules/*' | head -50")} - -For each TypeScript file in the source directory, call extractExportedSymbols to discover exported names. -Then write the barrel file to ${p.writeInput("outputFile", "barrelContent")}. -Return the declared output.`, - tools: [ - defineTool("extractExportedSymbols", { - description: "Read a TypeScript file and extract all top-level exported symbol names", - parameters: s.object({ filePath: s.path }), - async handler({ filePath }) { - const content = await readFile(filePath, "utf8"); - const symbols: string[] = []; - const exportRegex = /^export\s+(?:(?:default\s+)?(?:function|class|const|let|var|type|interface|enum)\s+(\w+)|(\{[^}]+\}))/gm; - for (const match of content.matchAll(exportRegex)) { - if (match[1]) { - symbols.push(match[1]); - } else if (match[2]) { - const named = match[2].replace(/[{}]/g, "").split(",").map((s: string) => s.trim().split(/\s+as\s+/)[0].trim()).filter(Boolean); - symbols.push(...named); - } - } - return { filePath, symbols }; - }, - }), - ], - output: s.object({ - exports: s.array(s.string), - outputFile: s.path, - totalExports: s.int, - filesScanned: s.int, - }), + instructions: p`Generate a TypeScript barrel for skills/rig/engines from ${p.bash("find skills/rig/engines -name '*.ts' -not -name 'index.ts' -not -name '*.d.ts' | head -20")}. Use extractExportedSymbols for each file, set outputFile to /tmp/rig-barrel.ts, write barrelContent to ${p.writeOutput("barrelContent", "/tmp/rig-barrel.ts")}, and return the declared output.`, + tools: [defineTool("extractExportedSymbols", { + description: "Read a TypeScript file and extract top-level exported symbol names", + parameters: s.object({ filePath: s.path }), + async handler({ filePath }) { + const content = await readFile(filePath, "utf8"); + const symbols = [...content.matchAll(/^export\s+(?:(?:default\s+)?(?:function|class|const|let|var|type|interface|enum)\s+(\w+)|(\{[^}]+\}))/gm)].flatMap((match) => match[1] ? [match[1]] : match[2]!.replace(/[{}]/g, "").split(",").map((name) => name.trim().split(/\s+as\s+/)[0].trim()).filter(Boolean)); + return { filePath, symbols }; + }, + })], + output: s.object({ barrelContent: s.string, exports: s.array(s.string), outputFile: s.path, totalExports: s.int, filesScanned: s.int }), addons: [repair()], }); - export default tsBarrelReExporter; ```