@patchbay-nebius/agent 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +47 -7
- package/dist/cli.js.map +1 -1
- package/dist/scanner-IPBNTPNM.js +247 -0
- package/dist/scanner-IPBNTPNM.js.map +1 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -104,6 +104,7 @@ Usage:
|
|
|
104
104
|
patchbay build [--record] "<one-sentence integration>"
|
|
105
105
|
patchbay research "<one-sentence integration>"
|
|
106
106
|
patchbay verify [--watch] <directory>
|
|
107
|
+
patchbay scan <directory> [--build-top=<n>] [--json]
|
|
107
108
|
patchbay add <run-dir> [--target=<dir>]
|
|
108
109
|
patchbay push <run-dir> --repo=owner/name [--path=connectors/<name>] [--branch=<branch>] [--dry-run]
|
|
109
110
|
patchbay help
|
|
@@ -112,18 +113,21 @@ Commands:
|
|
|
112
113
|
build Full pipeline: plan \u2192 research \u2192 generate \u2192 verify (with repair). Default if you pass a prompt.
|
|
113
114
|
research Plan + API research only. Prints the spec, no code.
|
|
114
115
|
verify Type-check and vitest an existing connector folder (needs src/connector.ts + tests).
|
|
116
|
+
scan Walk a repo and report integration opportunities patchbay could build.
|
|
115
117
|
add Drop a recorded run's connector files into another project.
|
|
116
118
|
push Open a pull request on a GitHub repo with the generated files.
|
|
117
119
|
help Show this message.
|
|
118
120
|
|
|
119
121
|
Flags:
|
|
120
|
-
--record
|
|
121
|
-
--watch
|
|
122
|
-
--
|
|
123
|
-
--
|
|
124
|
-
--
|
|
125
|
-
--
|
|
126
|
-
--
|
|
122
|
+
--record build only. Writes runs/<timestamp>/ with generated files and the event log.
|
|
123
|
+
--watch verify only. Re-runs the sandbox verify whenever a .ts file in <directory> changes.
|
|
124
|
+
--build-top scan only. After reporting, build the top-N opportunities (full pipeline each).
|
|
125
|
+
--json scan only. Emit the raw opportunity list as JSON instead of the formatted report.
|
|
126
|
+
--target add only. Where to drop the files, defaults to ./connectors/<run-name>.
|
|
127
|
+
--repo push only. owner/name of the target GitHub repo.
|
|
128
|
+
--path push only. Where to drop the files inside the repo, defaults to connectors/<run-name>.
|
|
129
|
+
--branch push only. Branch name to create, defaults to patchbay/<run-name>.
|
|
130
|
+
--dry-run push only. Print the plan without hitting the GitHub API.
|
|
127
131
|
|
|
128
132
|
Environment:
|
|
129
133
|
NEBIUS_API_KEY, NEBIUS_AI_PROJECT, TAVILY_API_KEY \u2013 required for live runs.
|
|
@@ -143,6 +147,7 @@ async function main() {
|
|
|
143
147
|
const rest = known.has(first) ? argv.slice(1) : argv;
|
|
144
148
|
if (first === "add") return add(argv.slice(1));
|
|
145
149
|
if (first === "push") return push(argv.slice(1));
|
|
150
|
+
if (first === "scan") return scan(argv.slice(1));
|
|
146
151
|
switch (cmd) {
|
|
147
152
|
case "build":
|
|
148
153
|
return build(rest);
|
|
@@ -152,6 +157,41 @@ async function main() {
|
|
|
152
157
|
return verify(rest);
|
|
153
158
|
}
|
|
154
159
|
}
|
|
160
|
+
async function scan(args) {
|
|
161
|
+
const positional = args.filter((a) => !a.startsWith("--"));
|
|
162
|
+
let dir = positional[0] ? resolve(positional[0]) : process.cwd();
|
|
163
|
+
const first = positional[0] ?? "";
|
|
164
|
+
if (/^https?:\/\/github\.com\//i.test(first) || /^git@github\.com:/i.test(first)) {
|
|
165
|
+
const { tmpdir } = await import("os");
|
|
166
|
+
const { execSync } = await import("child_process");
|
|
167
|
+
const target = join2(tmpdir(), `patchbay-scan-${Date.now()}`);
|
|
168
|
+
console.log(`cloning ${first} \u2192 ${target} (shallow)\u2026`);
|
|
169
|
+
execSync(`git clone --depth=1 "${first}" "${target}"`, { stdio: "inherit" });
|
|
170
|
+
dir = target;
|
|
171
|
+
}
|
|
172
|
+
if (!existsSync(dir)) return usageError(`No such directory: ${dir}`);
|
|
173
|
+
const asJson = args.includes("--json");
|
|
174
|
+
const buildTopArg = args.find((a) => a.startsWith("--build-top="));
|
|
175
|
+
const buildTop = buildTopArg ? Math.max(0, Number(buildTopArg.slice("--build-top=".length))) : 0;
|
|
176
|
+
const { scanRepo, formatReport } = await import("./scanner-IPBNTPNM.js");
|
|
177
|
+
const opportunities = scanRepo(dir);
|
|
178
|
+
if (asJson) {
|
|
179
|
+
console.log(JSON.stringify(opportunities, null, 2));
|
|
180
|
+
} else {
|
|
181
|
+
console.log(formatReport(opportunities, dir));
|
|
182
|
+
}
|
|
183
|
+
if (buildTop > 0 && opportunities.length) {
|
|
184
|
+
const top = opportunities.slice(0, buildTop);
|
|
185
|
+
console.log(`
|
|
186
|
+
Building top ${top.length} opportunit${top.length === 1 ? "y" : "ies"}\u2026
|
|
187
|
+
`);
|
|
188
|
+
for (const [i, op] of top.entries()) {
|
|
189
|
+
console.log(`
|
|
190
|
+
\u2500\u2500\u2500\u2500 (${i + 1}/${top.length}) ${op.file}:${op.line} \u2500\u2500\u2500\u2500`);
|
|
191
|
+
await build(["--record", op.prompt]);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
155
195
|
async function add(args) {
|
|
156
196
|
const positional = args.filter((a) => !a.startsWith("--"));
|
|
157
197
|
const flag = args.find((a) => a.startsWith("--target="));
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/github-push.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, watch, writeFileSync } from 'node:fs'\nimport { basename, dirname, join, relative, resolve } from 'node:path'\nimport { loadConfig, missingLiveKeys } from './config'\nimport { pushToGitHub } from './github-push'\nimport { startResearch, startRun, startVerify } from './index'\nimport type { GeneratedFile, RunEvent } from './types'\n\nconst HELP = `patchbay – describe an integration, get a tested TypeScript connector.\n\nUsage:\n patchbay build [--record] \"<one-sentence integration>\"\n patchbay research \"<one-sentence integration>\"\n patchbay verify [--watch] <directory>\n patchbay add <run-dir> [--target=<dir>]\n patchbay push <run-dir> --repo=owner/name [--path=connectors/<name>] [--branch=<branch>] [--dry-run]\n patchbay help\n\nCommands:\n build Full pipeline: plan → research → generate → verify (with repair). Default if you pass a prompt.\n research Plan + API research only. Prints the spec, no code.\n verify Type-check and vitest an existing connector folder (needs src/connector.ts + tests).\n add Drop a recorded run's connector files into another project.\n push Open a pull request on a GitHub repo with the generated files.\n help Show this message.\n\nFlags:\n --record build only. Writes runs/<timestamp>/ with generated files and the event log.\n --watch verify only. Re-runs the sandbox verify whenever a .ts file in <directory> changes.\n --target add only. Where to drop the files, defaults to ./connectors/<run-name>.\n --repo push only. owner/name of the target GitHub repo.\n --path push only. Where to drop the files inside the repo, defaults to connectors/<run-name>.\n --branch push only. Branch name to create, defaults to patchbay/<run-name>.\n --dry-run push only. Print the plan without hitting the GitHub API.\n\nEnvironment:\n NEBIUS_API_KEY, NEBIUS_AI_PROJECT, TAVILY_API_KEY – required for live runs.\n PATCHBAY_MOCK=false – enable live mode (default is replay).\n PATCHBAY_RUNNER=local|nebius – default nebius (isolated sandbox).\n PATCHBAY_MAX_ATTEMPTS=<n> – repair attempts, default 3.\n`\n\nasync function main() {\n const argv = process.argv.slice(2)\n const first = argv[0]\n\n if (!first || first === 'help' || first === '--help' || first === '-h') {\n console.log(HELP)\n return\n }\n\n // Backwards-compat: bare prompt = build\n const known = new Set(['build', 'research', 'verify'])\n const cmd = known.has(first) ? first : 'build'\n const rest = known.has(first) ? argv.slice(1) : argv\n\n if (first === 'add') return add(argv.slice(1))\n if (first === 'push') return push(argv.slice(1))\n\n switch (cmd) {\n case 'build':\n return build(rest)\n case 'research':\n return research(rest)\n case 'verify':\n return verify(rest)\n }\n}\n\n/**\n * Copy the files from a recorded run (`runs/<timestamp>/`) into a target\n * project. Default target is ./connectors/<run-basename>, so repeated adds\n * don't overwrite each other.\n */\nasync function add(args: string[]) {\n const positional = args.filter((a) => !a.startsWith('--'))\n const flag = args.find((a) => a.startsWith('--target='))\n const runDir = positional[0] ? resolve(positional[0]) : ''\n if (!runDir) return usageError('add needs a run directory (e.g. runs/<timestamp>)')\n if (!existsSync(runDir)) return usageError(`No such directory: ${runDir}`)\n const srcDir = join(runDir, 'src')\n if (!existsSync(join(srcDir, 'connector.ts'))) {\n return usageError(`${runDir} does not look like a patchbay run (no src/connector.ts)`)\n }\n const target = flag ? resolve(flag.slice('--target='.length)) : resolve(process.cwd(), 'connectors', basename(runDir))\n if (existsSync(target)) {\n console.error(`Refusing to overwrite ${target}. Pass --target=<fresh-dir> or move the existing folder out of the way.`)\n process.exit(1)\n }\n mkdirSync(target, { recursive: true })\n // src/ is self-contained (connector.ts + connector.test.ts + fixtures.ts).\n cpSync(srcDir, join(target, 'src'), { recursive: true })\n const readme = join(runDir, 'README.md')\n if (existsSync(readme)) cpSync(readme, join(target, 'README.md'))\n const copied = readdirSync(join(target, 'src'))\n console.log(`✔ Copied ${copied.length + (existsSync(readme) ? 1 : 0)} files to ${target}`)\n console.log(' src/' + copied.join('\\n src/'))\n if (existsSync(readme)) console.log(' README.md')\n console.log(`\\nTests should already pass unchanged — the connector is self-contained and uses an injected fetch.`)\n console.log(`Add vitest and typescript as dev deps where you'll run them, or wire this into your existing suite.`)\n}\n\nasync function build(args: string[]) {\n const record = args.includes('--record')\n const prompt = args.filter((a) => a !== '--record').join(' ').trim()\n if (!prompt) return usageError('build needs a prompt')\n\n const config = loadConfig()\n const missing = missingLiveKeys(config)\n if (config.mock || missing.length) {\n console.log(`Replay mode (${config.mock ? 'PATCHBAY_MOCK is not \"false\"' : `missing ${missing.join(', ')}`})`)\n }\n\n const events: RunEvent[] = []\n for await (const event of startRun(prompt, config)) {\n events.push(event)\n printEvent(event)\n }\n\n if (record) {\n const dir = join(process.cwd(), 'runs', new Date().toISOString().replace(/[:.]/g, '-'))\n const result = events.find((e) => e.type === 'result')\n for (const file of result?.type === 'result' ? result.files : []) {\n mkdirSync(dirname(join(dir, file.path)), { recursive: true })\n writeFileSync(join(dir, file.path), file.content)\n }\n mkdirSync(dir, { recursive: true })\n writeFileSync(join(dir, 'run.json'), JSON.stringify({ prompt, origin: 'live', events }, null, 2))\n console.log(`\\nRecorded to ${dir}`)\n }\n}\n\nasync function research(args: string[]) {\n const prompt = args.join(' ').trim()\n if (!prompt) return usageError('research needs a prompt')\n const config = loadConfig()\n const missing = missingLiveKeys(config)\n if (config.mock || missing.length) {\n console.log(`Replay mode (${config.mock ? 'PATCHBAY_MOCK is not \"false\"' : `missing ${missing.join(', ')}`}) – returning cached research`)\n }\n for await (const event of startResearch(prompt, config)) {\n printEvent(event)\n if (event.type === 'spec') {\n console.log('\\nSpec:')\n console.log(JSON.stringify(event.spec, null, 2))\n }\n }\n}\n\nasync function verify(args: string[]) {\n const watchMode = args.includes('--watch')\n const positional = args.filter((a) => !a.startsWith('--'))\n const dir = positional[0] ? resolve(positional[0]) : ''\n if (!dir) return usageError('verify needs a directory')\n if (!collectFiles(dir).some((f) => f.path === 'src/connector.ts')) {\n return usageError(`No src/connector.ts under ${dir}`)\n }\n const config = loadConfig()\n const missing = missingLiveKeys(config)\n if (config.mock || missing.length) {\n console.error(`verify needs live keys. Set PATCHBAY_MOCK=false and provide ${missing.join(', ') || 'the missing env vars'}.`)\n process.exit(1)\n }\n\n const runOnce = async () => {\n const files = collectFiles(dir)\n console.log(`\\nVerifying ${files.length} files from ${dir}`)\n for await (const event of startVerify(files, config)) printEvent(event)\n }\n\n await runOnce()\n if (!watchMode) return\n\n console.log(`\\nWatching ${dir} for .ts changes. Ctrl+C to exit.`)\n let running = false\n let rerun = false\n // Native fs.watch is good enough: debounced to avoid thrashing when an editor\n // saves multiple files in quick succession.\n let pending: NodeJS.Timeout | null = null\n const trigger = () => {\n if (pending) clearTimeout(pending)\n pending = setTimeout(async () => {\n pending = null\n if (running) { rerun = true; return }\n running = true\n try { await runOnce() } finally {\n running = false\n if (rerun) { rerun = false; trigger() }\n }\n }, 400)\n }\n watch(dir, { recursive: true }, (_, filename) => {\n if (filename && (filename.endsWith('.ts') || filename.endsWith('.json'))) trigger()\n })\n await new Promise(() => {}) // keep the process alive\n}\n\nasync function push(args: string[]) {\n const positional = args.filter((a) => !a.startsWith('--'))\n const runDir = positional[0] ? resolve(positional[0]) : ''\n if (!runDir) return usageError('push needs a run directory')\n const repo = flagValue(args, '--repo')\n if (!repo) return usageError('push needs --repo=owner/name')\n const target = flagValue(args, '--path') ?? `connectors/${basename(runDir)}`\n const branch = flagValue(args, '--branch')\n const dryRun = args.includes('--dry-run')\n const token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN\n if (!token && !dryRun) {\n return usageError('push needs GH_TOKEN (or GITHUB_TOKEN) in the environment, with repo scope on the target.')\n }\n try {\n const result = await pushToGitHub({\n runDir, repo, token: token ?? '', targetPath: target,\n ...(branch ? { branch } : {}),\n dryRun,\n })\n console.log(dryRun ? '✔ Dry run:' : '✔ Opened pull request:')\n console.log(` URL: ${result.prUrl}`)\n console.log(` branch: ${result.branch} (base: ${result.base})`)\n console.log(` files: ${result.files.length} under ${target}/`)\n for (const path of result.files) console.log(` ${path}`)\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error))\n process.exit(1)\n }\n}\n\nfunction flagValue(args: string[], flag: string): string | undefined {\n const match = args.find((a) => a.startsWith(`${flag}=`))\n return match?.slice(flag.length + 1)\n}\n\nfunction collectFiles(root: string): GeneratedFile[] {\n const out: GeneratedFile[] = []\n const walk = (dir: string) => {\n for (const entry of readdirSync(dir)) {\n if (entry === 'node_modules' || entry.startsWith('.')) continue\n const abs = join(dir, entry)\n const st = statSync(abs)\n if (st.isDirectory()) walk(abs)\n else if (entry.endsWith('.ts') || entry === 'README.md') {\n out.push({ path: relative(root, abs).replace(/\\\\/g, '/'), content: readFileSync(abs, 'utf8') })\n }\n }\n }\n walk(root)\n return out\n}\n\nfunction usageError(message: string): void {\n console.error(`Error: ${message}\\n`)\n console.error(HELP)\n process.exit(1)\n}\n\nfunction printEvent(event: RunEvent) {\n switch (event.type) {\n case 'step':\n console.log(`${event.status === 'start' ? '▶' : event.status === 'done' ? '✔' : '✖'} ${event.step}${event.detail ? ` — ${event.detail}` : ''}`)\n break\n case 'log':\n console.log(` ${event.message}`)\n break\n case 'tests':\n console.log(` attempt ${event.attempt}: ${event.report.passed}/${event.report.total} passed, typecheck ${event.report.typecheckOk ? 'ok' : 'failed'}`)\n for (const f of event.report.failures) console.log(` ✖ ${f.name}`)\n break\n case 'usage':\n for (const u of event.usage) console.log(` ${u.model}: ${u.promptTokens} in / ${u.completionTokens} out, $${u.costUsd.toFixed(4)}`)\n break\n case 'error':\n console.error(`Error: ${event.message}`)\n break\n }\n}\n\nmain().catch((error) => {\n console.error(error)\n process.exit(1)\n})\n","import { readdirSync, readFileSync, statSync } from 'node:fs'\nimport { join, relative } from 'node:path'\n\nexport interface PushOptions {\n runDir: string\n repo: string // \"owner/name\"\n token: string\n /** Where inside the target repo the connector files land. */\n targetPath: string // e.g. \"connectors/typeform-pipedrive\"\n /** Branch to create. Defaults to patchbay/<basename(runDir)>. */\n branch?: string\n /** Base branch to branch from. GitHub defaults it to the repo's default. */\n base?: string\n /** PR title + body overrides. */\n title?: string\n body?: string\n /** Set true to log what would happen without hitting the API. */\n dryRun?: boolean\n}\n\nexport interface PushResult {\n prUrl: string\n branch: string\n base: string\n files: string[]\n}\n\nconst API = 'https://api.github.com'\n\n/**\n * Takes a recorded patchbay run (runs/<timestamp>/ with src/* + README.md) and lands it in a\n * target GitHub repo as a pull request: new branch, commits every file under `targetPath`,\n * opens a PR against the repo's default branch.\n *\n * Uses the GitHub REST API directly (fetch + token). The token needs `repo` scope on the\n * target. Dry-run prints the plan without calling the API.\n */\nexport async function pushToGitHub(opts: PushOptions): Promise<PushResult> {\n const files = collectRunFiles(opts.runDir)\n if (files.length === 0) throw new Error(`${opts.runDir} has no files to push (expected src/* and README.md).`)\n\n const [owner, name] = opts.repo.split('/')\n if (!owner || !name) throw new Error(`Expected --repo=owner/name, got \"${opts.repo}\"`)\n\n const branch = opts.branch ?? `patchbay/${basenameNoSlash(opts.runDir)}`\n const title = opts.title ?? `patchbay: ${opts.targetPath}`\n const body =\n opts.body ??\n `Generated by [patchbay](https://github.com/GodSmasher/patchbay) from \\`${basenameNoSlash(opts.runDir)}\\`.\\n\\n` +\n `Includes ${files.length} files under \\`${opts.targetPath}/\\`. Tests pass against the documented example in a hermetic sandbox.`\n\n if (opts.dryRun) {\n return { prUrl: `(dry-run) would open PR on ${opts.repo}`, branch, base: opts.base ?? '(default)', files: files.map((f) => f.path) }\n }\n\n const api = createApi(opts.token)\n const repo = (await api(`/repos/${owner}/${name}`)) as { default_branch: string }\n const base = opts.base ?? repo.default_branch\n const baseRef = (await api(`/repos/${owner}/${name}/git/ref/heads/${base}`)) as { object: { sha: string } }\n const baseSha = baseRef.object.sha\n\n // Create the branch (409 if it already exists, we tolerate that).\n try {\n await api(`/repos/${owner}/${name}/git/refs`, {\n method: 'POST',\n body: { ref: `refs/heads/${branch}`, sha: baseSha },\n })\n } catch (error) {\n if (!/already exists/i.test(String(error))) throw error\n }\n\n // One commit per file keeps the diff readable; could be batched into a tree later if it matters.\n for (const file of files) {\n const path = `${opts.targetPath}/${file.path}`.replace(/\\\\/g, '/')\n const existing = (await api(`/repos/${owner}/${name}/contents/${encodeURIComponent(path)}?ref=${branch}`).catch(() => null)) as { sha?: string } | null\n await api(`/repos/${owner}/${name}/contents/${encodeURIComponent(path)}`, {\n method: 'PUT',\n body: {\n message: `patchbay: ${path}`,\n content: Buffer.from(file.content, 'utf8').toString('base64'),\n branch,\n ...(existing?.sha ? { sha: existing.sha } : {}),\n },\n })\n }\n\n const pr = (await api(`/repos/${owner}/${name}/pulls`, {\n method: 'POST',\n body: { title, head: branch, base, body, draft: false },\n })) as { html_url: string }\n\n return { prUrl: pr.html_url, branch, base, files: files.map((f) => f.path) }\n}\n\ninterface RunFile {\n path: string\n content: string\n}\n\nfunction collectRunFiles(root: string): RunFile[] {\n const out: RunFile[] = []\n const walk = (dir: string) => {\n for (const entry of readdirSync(dir)) {\n if (entry === 'run.json' || entry.startsWith('.')) continue\n const abs = join(dir, entry)\n const st = statSync(abs)\n if (st.isDirectory()) walk(abs)\n else out.push({ path: relative(root, abs).replace(/\\\\/g, '/'), content: readFileSync(abs, 'utf8') })\n }\n }\n walk(root)\n return out\n}\n\nfunction basenameNoSlash(path: string): string {\n return path.replace(/[\\\\/]+$/, '').split(/[\\\\/]/).pop() ?? 'run'\n}\n\nfunction createApi(token: string) {\n return async <T = unknown>(path: string, init: { method?: string; body?: unknown } = {}): Promise<T> => {\n const res = await fetch(`${API}${path}`, {\n method: init.method ?? 'GET',\n headers: {\n Authorization: `Bearer ${token}`,\n Accept: 'application/vnd.github+json',\n 'X-GitHub-Api-Version': '2022-11-28',\n 'User-Agent': 'patchbay-cli',\n ...(init.body ? { 'Content-Type': 'application/json' } : {}),\n },\n body: init.body ? JSON.stringify(init.body) : undefined,\n })\n const text = await res.text()\n const data = text ? JSON.parse(text) : {}\n if (!res.ok) throw new Error(`GitHub ${init.method ?? 'GET'} ${path}: HTTP ${res.status} ${(data as { message?: string }).message ?? text.slice(0, 200)}`)\n return data as T\n }\n}\n"],"mappings":";;;;;;;;;;AACA,SAAS,QAAQ,YAAY,WAAW,eAAAA,cAAa,gBAAAC,eAAc,YAAAC,WAAU,OAAO,qBAAqB;AACzG,SAAS,UAAU,SAAS,QAAAC,OAAM,YAAAC,WAAU,eAAe;;;ACF3D,SAAS,aAAa,cAAc,gBAAgB;AACpD,SAAS,MAAM,gBAAgB;AA0B/B,IAAM,MAAM;AAUZ,eAAsB,aAAa,MAAwC;AACzE,QAAM,QAAQ,gBAAgB,KAAK,MAAM;AACzC,MAAI,MAAM,WAAW,EAAG,OAAM,IAAI,MAAM,GAAG,KAAK,MAAM,uDAAuD;AAE7G,QAAM,CAAC,OAAO,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG;AACzC,MAAI,CAAC,SAAS,CAAC,KAAM,OAAM,IAAI,MAAM,oCAAoC,KAAK,IAAI,GAAG;AAErF,QAAM,SAAS,KAA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,MAAM,GAAG,EAAE,QAAQ,OAAO,GAAG,GAAG,SAASC,cAAa,KAAK,MAAM,EAAE,CAAC;AAAA,MAChG;AAAA,IACF;AAAA,EACF;AACA,OAAK,IAAI;AACT,SAAO;AACT;AAEA,SAAS,WAAW,SAAuB;AACzC,UAAQ,MAAM,UAAU,OAAO;AAAA,CAAI;AACnC,UAAQ,MAAM,IAAI;AAClB,UAAQ,KAAK,CAAC;AAChB;AAEA,SAAS,WAAW,OAAiB;AACnC,UAAQ,MAAM,MAAM;AAAA,IAClB,KAAK;AACH,cAAQ,IAAI,GAAG,MAAM,WAAW,UAAU,WAAM,MAAM,WAAW,SAAS,WAAM,QAAG,IAAI,MAAM,IAAI,GAAG,MAAM,SAAS,WAAM,MAAM,MAAM,KAAK,EAAE,EAAE;AAC9I;AAAA,IACF,KAAK;AACH,cAAQ,IAAI,OAAO,MAAM,OAAO,EAAE;AAClC;AAAA,IACF,KAAK;AACH,cAAQ,IAAI,eAAe,MAAM,OAAO,KAAK,MAAM,OAAO,MAAM,IAAI,MAAM,OAAO,KAAK,sBAAsB,MAAM,OAAO,cAAc,OAAO,QAAQ,EAAE;AACxJ,iBAAW,KAAK,MAAM,OAAO,SAAU,SAAQ,IAAI,gBAAW,EAAE,IAAI,EAAE;AACtE;AAAA,IACF,KAAK;AACH,iBAAW,KAAK,MAAM,MAAO,SAAQ,IAAI,OAAO,EAAE,KAAK,KAAK,EAAE,YAAY,SAAS,EAAE,gBAAgB,UAAU,EAAE,QAAQ,QAAQ,CAAC,CAAC,EAAE;AACrI;AAAA,IACF,KAAK;AACH,cAAQ,MAAM,UAAU,MAAM,OAAO,EAAE;AACvC;AAAA,EACJ;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["readdirSync","readFileSync","statSync","join","relative","join","readdirSync","statSync","relative","readFileSync"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/github-push.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, watch, writeFileSync } from 'node:fs'\nimport { basename, dirname, join, relative, resolve } from 'node:path'\nimport { loadConfig, missingLiveKeys } from './config'\nimport { pushToGitHub } from './github-push'\nimport { startResearch, startRun, startVerify } from './index'\nimport type { GeneratedFile, RunEvent } from './types'\n\nconst HELP = `patchbay – describe an integration, get a tested TypeScript connector.\n\nUsage:\n patchbay build [--record] \"<one-sentence integration>\"\n patchbay research \"<one-sentence integration>\"\n patchbay verify [--watch] <directory>\n patchbay scan <directory> [--build-top=<n>] [--json]\n patchbay add <run-dir> [--target=<dir>]\n patchbay push <run-dir> --repo=owner/name [--path=connectors/<name>] [--branch=<branch>] [--dry-run]\n patchbay help\n\nCommands:\n build Full pipeline: plan → research → generate → verify (with repair). Default if you pass a prompt.\n research Plan + API research only. Prints the spec, no code.\n verify Type-check and vitest an existing connector folder (needs src/connector.ts + tests).\n scan Walk a repo and report integration opportunities patchbay could build.\n add Drop a recorded run's connector files into another project.\n push Open a pull request on a GitHub repo with the generated files.\n help Show this message.\n\nFlags:\n --record build only. Writes runs/<timestamp>/ with generated files and the event log.\n --watch verify only. Re-runs the sandbox verify whenever a .ts file in <directory> changes.\n --build-top scan only. After reporting, build the top-N opportunities (full pipeline each).\n --json scan only. Emit the raw opportunity list as JSON instead of the formatted report.\n --target add only. Where to drop the files, defaults to ./connectors/<run-name>.\n --repo push only. owner/name of the target GitHub repo.\n --path push only. Where to drop the files inside the repo, defaults to connectors/<run-name>.\n --branch push only. Branch name to create, defaults to patchbay/<run-name>.\n --dry-run push only. Print the plan without hitting the GitHub API.\n\nEnvironment:\n NEBIUS_API_KEY, NEBIUS_AI_PROJECT, TAVILY_API_KEY – required for live runs.\n PATCHBAY_MOCK=false – enable live mode (default is replay).\n PATCHBAY_RUNNER=local|nebius – default nebius (isolated sandbox).\n PATCHBAY_MAX_ATTEMPTS=<n> – repair attempts, default 3.\n`\n\nasync function main() {\n const argv = process.argv.slice(2)\n const first = argv[0]\n\n if (!first || first === 'help' || first === '--help' || first === '-h') {\n console.log(HELP)\n return\n }\n\n // Backwards-compat: bare prompt = build\n const known = new Set(['build', 'research', 'verify'])\n const cmd = known.has(first) ? first : 'build'\n const rest = known.has(first) ? argv.slice(1) : argv\n\n if (first === 'add') return add(argv.slice(1))\n if (first === 'push') return push(argv.slice(1))\n if (first === 'scan') return scan(argv.slice(1))\n\n switch (cmd) {\n case 'build':\n return build(rest)\n case 'research':\n return research(rest)\n case 'verify':\n return verify(rest)\n }\n}\n\nasync function scan(args: string[]) {\n const positional = args.filter((a) => !a.startsWith('--'))\n let dir = positional[0] ? resolve(positional[0]) : process.cwd()\n // Accept GitHub URLs: shallow-clone into a tmp dir so judges can scan a\n // random repo without cloning it themselves.\n const first = positional[0] ?? ''\n if (/^https?:\\/\\/github\\.com\\//i.test(first) || /^git@github\\.com:/i.test(first)) {\n const { tmpdir } = await import('node:os')\n const { execSync } = await import('node:child_process')\n const target = join(tmpdir(), `patchbay-scan-${Date.now()}`)\n console.log(`cloning ${first} → ${target} (shallow)…`)\n execSync(`git clone --depth=1 \"${first}\" \"${target}\"`, { stdio: 'inherit' })\n dir = target\n }\n if (!existsSync(dir)) return usageError(`No such directory: ${dir}`)\n const asJson = args.includes('--json')\n const buildTopArg = args.find((a) => a.startsWith('--build-top='))\n const buildTop = buildTopArg ? Math.max(0, Number(buildTopArg.slice('--build-top='.length))) : 0\n\n const { scanRepo, formatReport } = await import('./scanner')\n const opportunities = scanRepo(dir)\n if (asJson) {\n console.log(JSON.stringify(opportunities, null, 2))\n } else {\n console.log(formatReport(opportunities, dir))\n }\n\n if (buildTop > 0 && opportunities.length) {\n const top = opportunities.slice(0, buildTop)\n console.log(`\\nBuilding top ${top.length} opportunit${top.length === 1 ? 'y' : 'ies'}…\\n`)\n for (const [i, op] of top.entries()) {\n console.log(`\\n──── (${i + 1}/${top.length}) ${op.file}:${op.line} ────`)\n await build(['--record', op.prompt])\n }\n }\n}\n\n/**\n * Copy the files from a recorded run (`runs/<timestamp>/`) into a target\n * project. Default target is ./connectors/<run-basename>, so repeated adds\n * don't overwrite each other.\n */\nasync function add(args: string[]) {\n const positional = args.filter((a) => !a.startsWith('--'))\n const flag = args.find((a) => a.startsWith('--target='))\n const runDir = positional[0] ? resolve(positional[0]) : ''\n if (!runDir) return usageError('add needs a run directory (e.g. runs/<timestamp>)')\n if (!existsSync(runDir)) return usageError(`No such directory: ${runDir}`)\n const srcDir = join(runDir, 'src')\n if (!existsSync(join(srcDir, 'connector.ts'))) {\n return usageError(`${runDir} does not look like a patchbay run (no src/connector.ts)`)\n }\n const target = flag ? resolve(flag.slice('--target='.length)) : resolve(process.cwd(), 'connectors', basename(runDir))\n if (existsSync(target)) {\n console.error(`Refusing to overwrite ${target}. Pass --target=<fresh-dir> or move the existing folder out of the way.`)\n process.exit(1)\n }\n mkdirSync(target, { recursive: true })\n // src/ is self-contained (connector.ts + connector.test.ts + fixtures.ts).\n cpSync(srcDir, join(target, 'src'), { recursive: true })\n const readme = join(runDir, 'README.md')\n if (existsSync(readme)) cpSync(readme, join(target, 'README.md'))\n const copied = readdirSync(join(target, 'src'))\n console.log(`✔ Copied ${copied.length + (existsSync(readme) ? 1 : 0)} files to ${target}`)\n console.log(' src/' + copied.join('\\n src/'))\n if (existsSync(readme)) console.log(' README.md')\n console.log(`\\nTests should already pass unchanged — the connector is self-contained and uses an injected fetch.`)\n console.log(`Add vitest and typescript as dev deps where you'll run them, or wire this into your existing suite.`)\n}\n\nasync function build(args: string[]) {\n const record = args.includes('--record')\n const prompt = args.filter((a) => a !== '--record').join(' ').trim()\n if (!prompt) return usageError('build needs a prompt')\n\n const config = loadConfig()\n const missing = missingLiveKeys(config)\n if (config.mock || missing.length) {\n console.log(`Replay mode (${config.mock ? 'PATCHBAY_MOCK is not \"false\"' : `missing ${missing.join(', ')}`})`)\n }\n\n const events: RunEvent[] = []\n for await (const event of startRun(prompt, config)) {\n events.push(event)\n printEvent(event)\n }\n\n if (record) {\n const dir = join(process.cwd(), 'runs', new Date().toISOString().replace(/[:.]/g, '-'))\n const result = events.find((e) => e.type === 'result')\n for (const file of result?.type === 'result' ? result.files : []) {\n mkdirSync(dirname(join(dir, file.path)), { recursive: true })\n writeFileSync(join(dir, file.path), file.content)\n }\n mkdirSync(dir, { recursive: true })\n writeFileSync(join(dir, 'run.json'), JSON.stringify({ prompt, origin: 'live', events }, null, 2))\n console.log(`\\nRecorded to ${dir}`)\n }\n}\n\nasync function research(args: string[]) {\n const prompt = args.join(' ').trim()\n if (!prompt) return usageError('research needs a prompt')\n const config = loadConfig()\n const missing = missingLiveKeys(config)\n if (config.mock || missing.length) {\n console.log(`Replay mode (${config.mock ? 'PATCHBAY_MOCK is not \"false\"' : `missing ${missing.join(', ')}`}) – returning cached research`)\n }\n for await (const event of startResearch(prompt, config)) {\n printEvent(event)\n if (event.type === 'spec') {\n console.log('\\nSpec:')\n console.log(JSON.stringify(event.spec, null, 2))\n }\n }\n}\n\nasync function verify(args: string[]) {\n const watchMode = args.includes('--watch')\n const positional = args.filter((a) => !a.startsWith('--'))\n const dir = positional[0] ? resolve(positional[0]) : ''\n if (!dir) return usageError('verify needs a directory')\n if (!collectFiles(dir).some((f) => f.path === 'src/connector.ts')) {\n return usageError(`No src/connector.ts under ${dir}`)\n }\n const config = loadConfig()\n const missing = missingLiveKeys(config)\n if (config.mock || missing.length) {\n console.error(`verify needs live keys. Set PATCHBAY_MOCK=false and provide ${missing.join(', ') || 'the missing env vars'}.`)\n process.exit(1)\n }\n\n const runOnce = async () => {\n const files = collectFiles(dir)\n console.log(`\\nVerifying ${files.length} files from ${dir}`)\n for await (const event of startVerify(files, config)) printEvent(event)\n }\n\n await runOnce()\n if (!watchMode) return\n\n console.log(`\\nWatching ${dir} for .ts changes. Ctrl+C to exit.`)\n let running = false\n let rerun = false\n // Native fs.watch is good enough: debounced to avoid thrashing when an editor\n // saves multiple files in quick succession.\n let pending: NodeJS.Timeout | null = null\n const trigger = () => {\n if (pending) clearTimeout(pending)\n pending = setTimeout(async () => {\n pending = null\n if (running) { rerun = true; return }\n running = true\n try { await runOnce() } finally {\n running = false\n if (rerun) { rerun = false; trigger() }\n }\n }, 400)\n }\n watch(dir, { recursive: true }, (_, filename) => {\n if (filename && (filename.endsWith('.ts') || filename.endsWith('.json'))) trigger()\n })\n await new Promise(() => {}) // keep the process alive\n}\n\nasync function push(args: string[]) {\n const positional = args.filter((a) => !a.startsWith('--'))\n const runDir = positional[0] ? resolve(positional[0]) : ''\n if (!runDir) return usageError('push needs a run directory')\n const repo = flagValue(args, '--repo')\n if (!repo) return usageError('push needs --repo=owner/name')\n const target = flagValue(args, '--path') ?? `connectors/${basename(runDir)}`\n const branch = flagValue(args, '--branch')\n const dryRun = args.includes('--dry-run')\n const token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN\n if (!token && !dryRun) {\n return usageError('push needs GH_TOKEN (or GITHUB_TOKEN) in the environment, with repo scope on the target.')\n }\n try {\n const result = await pushToGitHub({\n runDir, repo, token: token ?? '', targetPath: target,\n ...(branch ? { branch } : {}),\n dryRun,\n })\n console.log(dryRun ? '✔ Dry run:' : '✔ Opened pull request:')\n console.log(` URL: ${result.prUrl}`)\n console.log(` branch: ${result.branch} (base: ${result.base})`)\n console.log(` files: ${result.files.length} under ${target}/`)\n for (const path of result.files) console.log(` ${path}`)\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error))\n process.exit(1)\n }\n}\n\nfunction flagValue(args: string[], flag: string): string | undefined {\n const match = args.find((a) => a.startsWith(`${flag}=`))\n return match?.slice(flag.length + 1)\n}\n\nfunction collectFiles(root: string): GeneratedFile[] {\n const out: GeneratedFile[] = []\n const walk = (dir: string) => {\n for (const entry of readdirSync(dir)) {\n if (entry === 'node_modules' || entry.startsWith('.')) continue\n const abs = join(dir, entry)\n const st = statSync(abs)\n if (st.isDirectory()) walk(abs)\n else if (entry.endsWith('.ts') || entry === 'README.md') {\n out.push({ path: relative(root, abs).replace(/\\\\/g, '/'), content: readFileSync(abs, 'utf8') })\n }\n }\n }\n walk(root)\n return out\n}\n\nfunction usageError(message: string): void {\n console.error(`Error: ${message}\\n`)\n console.error(HELP)\n process.exit(1)\n}\n\nfunction printEvent(event: RunEvent) {\n switch (event.type) {\n case 'step':\n console.log(`${event.status === 'start' ? '▶' : event.status === 'done' ? '✔' : '✖'} ${event.step}${event.detail ? ` — ${event.detail}` : ''}`)\n break\n case 'log':\n console.log(` ${event.message}`)\n break\n case 'tests':\n console.log(` attempt ${event.attempt}: ${event.report.passed}/${event.report.total} passed, typecheck ${event.report.typecheckOk ? 'ok' : 'failed'}`)\n for (const f of event.report.failures) console.log(` ✖ ${f.name}`)\n break\n case 'usage':\n for (const u of event.usage) console.log(` ${u.model}: ${u.promptTokens} in / ${u.completionTokens} out, $${u.costUsd.toFixed(4)}`)\n break\n case 'error':\n console.error(`Error: ${event.message}`)\n break\n }\n}\n\nmain().catch((error) => {\n console.error(error)\n process.exit(1)\n})\n","import { readdirSync, readFileSync, statSync } from 'node:fs'\nimport { join, relative } from 'node:path'\n\nexport interface PushOptions {\n runDir: string\n repo: string // \"owner/name\"\n token: string\n /** Where inside the target repo the connector files land. */\n targetPath: string // e.g. \"connectors/typeform-pipedrive\"\n /** Branch to create. Defaults to patchbay/<basename(runDir)>. */\n branch?: string\n /** Base branch to branch from. GitHub defaults it to the repo's default. */\n base?: string\n /** PR title + body overrides. */\n title?: string\n body?: string\n /** Set true to log what would happen without hitting the API. */\n dryRun?: boolean\n}\n\nexport interface PushResult {\n prUrl: string\n branch: string\n base: string\n files: string[]\n}\n\nconst API = 'https://api.github.com'\n\n/**\n * Takes a recorded patchbay run (runs/<timestamp>/ with src/* + README.md) and lands it in a\n * target GitHub repo as a pull request: new branch, commits every file under `targetPath`,\n * opens a PR against the repo's default branch.\n *\n * Uses the GitHub REST API directly (fetch + token). The token needs `repo` scope on the\n * target. Dry-run prints the plan without calling the API.\n */\nexport async function pushToGitHub(opts: PushOptions): Promise<PushResult> {\n const files = collectRunFiles(opts.runDir)\n if (files.length === 0) throw new Error(`${opts.runDir} has no files to push (expected src/* and README.md).`)\n\n const [owner, name] = opts.repo.split('/')\n if (!owner || !name) throw new Error(`Expected --repo=owner/name, got \"${opts.repo}\"`)\n\n const branch = opts.branch ?? `patchbay/${basenameNoSlash(opts.runDir)}`\n const title = opts.title ?? `patchbay: ${opts.targetPath}`\n const body =\n opts.body ??\n `Generated by [patchbay](https://github.com/GodSmasher/patchbay) from \\`${basenameNoSlash(opts.runDir)}\\`.\\n\\n` +\n `Includes ${files.length} files under \\`${opts.targetPath}/\\`. Tests pass against the documented example in a hermetic sandbox.`\n\n if (opts.dryRun) {\n return { prUrl: `(dry-run) would open PR on ${opts.repo}`, branch, base: opts.base ?? '(default)', files: files.map((f) => f.path) }\n }\n\n const api = createApi(opts.token)\n const repo = (await api(`/repos/${owner}/${name}`)) as { default_branch: string }\n const base = opts.base ?? repo.default_branch\n const baseRef = (await api(`/repos/${owner}/${name}/git/ref/heads/${base}`)) as { object: { sha: string } }\n const baseSha = baseRef.object.sha\n\n // Create the branch (409 if it already exists, we tolerate that).\n try {\n await api(`/repos/${owner}/${name}/git/refs`, {\n method: 'POST',\n body: { ref: `refs/heads/${branch}`, sha: baseSha },\n })\n } catch (error) {\n if (!/already exists/i.test(String(error))) throw error\n }\n\n // One commit per file keeps the diff readable; could be batched into a tree later if it matters.\n for (const file of files) {\n const path = `${opts.targetPath}/${file.path}`.replace(/\\\\/g, '/')\n const existing = (await api(`/repos/${owner}/${name}/contents/${encodeURIComponent(path)}?ref=${branch}`).catch(() => null)) as { sha?: string } | null\n await api(`/repos/${owner}/${name}/contents/${encodeURIComponent(path)}`, {\n method: 'PUT',\n body: {\n message: `patchbay: ${path}`,\n content: Buffer.from(file.content, 'utf8').toString('base64'),\n branch,\n ...(existing?.sha ? { sha: existing.sha } : {}),\n },\n })\n }\n\n const pr = (await api(`/repos/${owner}/${name}/pulls`, {\n method: 'POST',\n body: { title, head: branch, base, body, draft: false },\n })) as { html_url: string }\n\n return { prUrl: pr.html_url, branch, base, files: files.map((f) => f.path) }\n}\n\ninterface RunFile {\n path: string\n content: string\n}\n\nfunction collectRunFiles(root: string): RunFile[] {\n const out: RunFile[] = []\n const walk = (dir: string) => {\n for (const entry of readdirSync(dir)) {\n if (entry === 'run.json' || entry.startsWith('.')) continue\n const abs = join(dir, entry)\n const st = statSync(abs)\n if (st.isDirectory()) walk(abs)\n else out.push({ path: relative(root, abs).replace(/\\\\/g, '/'), content: readFileSync(abs, 'utf8') })\n }\n }\n walk(root)\n return out\n}\n\nfunction basenameNoSlash(path: string): string {\n return path.replace(/[\\\\/]+$/, '').split(/[\\\\/]/).pop() ?? 'run'\n}\n\nfunction createApi(token: string) {\n return async <T = unknown>(path: string, init: { method?: string; body?: unknown } = {}): Promise<T> => {\n const res = await fetch(`${API}${path}`, {\n method: init.method ?? 'GET',\n headers: {\n Authorization: `Bearer ${token}`,\n Accept: 'application/vnd.github+json',\n 'X-GitHub-Api-Version': '2022-11-28',\n 'User-Agent': 'patchbay-cli',\n ...(init.body ? { 'Content-Type': 'application/json' } : {}),\n },\n body: init.body ? JSON.stringify(init.body) : undefined,\n })\n const text = await res.text()\n const data = text ? JSON.parse(text) : {}\n if (!res.ok) throw new Error(`GitHub ${init.method ?? 'GET'} ${path}: HTTP ${res.status} ${(data as { message?: string }).message ?? text.slice(0, 200)}`)\n return data as T\n }\n}\n"],"mappings":";;;;;;;;;;AACA,SAAS,QAAQ,YAAY,WAAW,eAAAA,cAAa,gBAAAC,eAAc,YAAAC,WAAU,OAAO,qBAAqB;AACzG,SAAS,UAAU,SAAS,QAAAC,OAAM,YAAAC,WAAU,eAAe;;;ACF3D,SAAS,aAAa,cAAc,gBAAgB;AACpD,SAAS,MAAM,gBAAgB;AA0B/B,IAAM,MAAM;AAUZ,eAAsB,aAAa,MAAwC;AACzE,QAAM,QAAQ,gBAAgB,KAAK,MAAM;AACzC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AAI,MAAM,OAAO,KAAK,sBAAsB,MAAM,OAAO,cAAc,OAAO,QAAQ,EAAE;AACxJ,iBAAW,KAAK,MAAM,OAAO,SAAU,SAAQ,IAAI,gBAAW,EAAE,IAAI,EAAE;AACtE;AAAA,IACF,KAAK;AACH,iBAAW,KAAK,MAAM,MAAO,SAAQ,IAAI,OAAO,EAAE,KAAK,KAAK,EAAE,YAAY,SAAS,EAAE,gBAAgB,UAAU,EAAE,QAAQ,QAAQ,CAAC,CAAC,EAAE;AACrI;AAAA,IACF,KAAK;AACH,cAAQ,MAAM,UAAU,MAAM,OAAO,EAAE;AACvC;AAAA,EACJ;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["readdirSync","readFileSync","statSync","join","relative","join","readdirSync","statSync","relative","readFileSync"]}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// src/scanner.ts
|
|
2
|
+
import { readFileSync, readdirSync, statSync } from "fs";
|
|
3
|
+
import { join, relative, extname, basename } from "path";
|
|
4
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", ".next", "out", "build", ".turbo", ".vercel", "coverage"]);
|
|
5
|
+
var SCAN_EXTS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py", ".go", ".rb", ".env", ".example"]);
|
|
6
|
+
var SCAN_MAX_BYTES = 5e5;
|
|
7
|
+
var INTEGRATION_KEYWORDS = /\b(webhook|sync|notify|integrate|forward|post\s+to|send\s+to|push\s+to|pull\s+from|fetch\s+from|subscribe|publish|route\s+to|hook\s+into)\b/i;
|
|
8
|
+
var VENDOR_HINTS = {
|
|
9
|
+
stripe: "Stripe",
|
|
10
|
+
shopify: "Shopify",
|
|
11
|
+
mailchimp: "Mailchimp",
|
|
12
|
+
typeform: "Typeform",
|
|
13
|
+
pipedrive: "Pipedrive",
|
|
14
|
+
hubspot: "HubSpot",
|
|
15
|
+
salesforce: "Salesforce",
|
|
16
|
+
slack: "Slack",
|
|
17
|
+
discord: "Discord",
|
|
18
|
+
notion: "Notion",
|
|
19
|
+
airtable: "Airtable",
|
|
20
|
+
asana: "Asana",
|
|
21
|
+
jira: "Jira",
|
|
22
|
+
linear: "Linear",
|
|
23
|
+
github: "GitHub",
|
|
24
|
+
gitlab: "GitLab",
|
|
25
|
+
zendesk: "Zendesk",
|
|
26
|
+
intercom: "Intercom",
|
|
27
|
+
twilio: "Twilio",
|
|
28
|
+
sendgrid: "SendGrid",
|
|
29
|
+
brevo: "Brevo",
|
|
30
|
+
resend: "Resend",
|
|
31
|
+
postmark: "Postmark",
|
|
32
|
+
mailgun: "Mailgun",
|
|
33
|
+
calendly: "Calendly",
|
|
34
|
+
jotform: "Jotform",
|
|
35
|
+
pusher: "Pusher",
|
|
36
|
+
zoom: "Zoom",
|
|
37
|
+
trello: "Trello",
|
|
38
|
+
freshdesk: "Freshdesk",
|
|
39
|
+
monday: "Monday",
|
|
40
|
+
pipeline: "Pipedrive",
|
|
41
|
+
quickbooks: "QuickBooks",
|
|
42
|
+
xero: "Xero",
|
|
43
|
+
paypal: "PayPal",
|
|
44
|
+
square: "Square"
|
|
45
|
+
};
|
|
46
|
+
var VENDOR_PATTERN = new RegExp(`\\b(${Object.keys(VENDOR_HINTS).join("|")})\\b`, "gi");
|
|
47
|
+
function scanRepo(root) {
|
|
48
|
+
const files = walk(root);
|
|
49
|
+
const opportunities = [];
|
|
50
|
+
for (const file of files) {
|
|
51
|
+
let content;
|
|
52
|
+
try {
|
|
53
|
+
const size = statSync(file).size;
|
|
54
|
+
if (size > SCAN_MAX_BYTES) continue;
|
|
55
|
+
content = readFileSync(file, "utf8");
|
|
56
|
+
} catch {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const rel = relative(root, file).replace(/\\/g, "/");
|
|
60
|
+
const name = basename(file).toLowerCase();
|
|
61
|
+
const lines = content.split("\n");
|
|
62
|
+
if (name.endsWith(".env") || name.endsWith(".env.example") || name === ".env.example" || name === ".env.sample") {
|
|
63
|
+
opportunities.push(...scanEnvFile(rel, lines));
|
|
64
|
+
}
|
|
65
|
+
opportunities.push(...scanTodos(rel, lines));
|
|
66
|
+
opportunities.push(...scanWebhookHandlers(rel, lines, content));
|
|
67
|
+
opportunities.push(...scanVendorImports(rel, lines));
|
|
68
|
+
}
|
|
69
|
+
return rankAndDedupe(opportunities);
|
|
70
|
+
}
|
|
71
|
+
function walk(dir, out = []) {
|
|
72
|
+
let entries;
|
|
73
|
+
try {
|
|
74
|
+
entries = readdirSync(dir);
|
|
75
|
+
} catch {
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
for (const entry of entries) {
|
|
79
|
+
if (entry.startsWith(".") && !entry.startsWith(".env")) continue;
|
|
80
|
+
if (SKIP_DIRS.has(entry)) continue;
|
|
81
|
+
const full = join(dir, entry);
|
|
82
|
+
let st;
|
|
83
|
+
try {
|
|
84
|
+
st = statSync(full);
|
|
85
|
+
} catch {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (st.isDirectory()) walk(full, out);
|
|
89
|
+
else if (SCAN_EXTS.has(extname(entry).toLowerCase()) || entry.startsWith(".env")) out.push(full);
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
function scanEnvFile(file, lines) {
|
|
94
|
+
const found = [];
|
|
95
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
96
|
+
for (let i = 0; i < lines.length; i++) {
|
|
97
|
+
const line = lines[i];
|
|
98
|
+
const match = line.match(/^([A-Z][A-Z0-9_]+)=/);
|
|
99
|
+
if (!match) continue;
|
|
100
|
+
const key = match[1];
|
|
101
|
+
const vendor = detectVendor(key.toLowerCase());
|
|
102
|
+
if (!vendor) continue;
|
|
103
|
+
const bucket = grouped.get(vendor) ?? { line: i + 1, vars: [] };
|
|
104
|
+
bucket.vars.push(key);
|
|
105
|
+
grouped.set(vendor, bucket);
|
|
106
|
+
}
|
|
107
|
+
for (const [vendor, info] of grouped) {
|
|
108
|
+
const title = VENDOR_HINTS[vendor];
|
|
109
|
+
found.push({
|
|
110
|
+
score: 60 + info.vars.length * 5,
|
|
111
|
+
kind: "env-var",
|
|
112
|
+
file,
|
|
113
|
+
line: info.line,
|
|
114
|
+
evidence: info.vars.join(", "),
|
|
115
|
+
vendors: [title],
|
|
116
|
+
prompt: `When something happens that needs ${title}, call ${title}'s API with the fields configured via ${info.vars.join(" / ")}.`
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return found;
|
|
120
|
+
}
|
|
121
|
+
function scanTodos(file, lines) {
|
|
122
|
+
const found = [];
|
|
123
|
+
for (let i = 0; i < lines.length; i++) {
|
|
124
|
+
const line = lines[i];
|
|
125
|
+
const match = line.match(/(?:\/\/|\/\*|#|<!--|\*)\s*(?:TODO|FIXME|XXX|HACK)\b[: ]*(.*)/i);
|
|
126
|
+
if (!match) continue;
|
|
127
|
+
const text = match[1].replace(/\*\/\s*$/, "").trim();
|
|
128
|
+
if (text.length < 15) continue;
|
|
129
|
+
if (!INTEGRATION_KEYWORDS.test(text) && !VENDOR_PATTERN.test(text)) continue;
|
|
130
|
+
const vendors = detectVendors(text);
|
|
131
|
+
found.push({
|
|
132
|
+
score: 50 + vendors.length * 10 + (INTEGRATION_KEYWORDS.test(text) ? 10 : 0),
|
|
133
|
+
kind: "todo",
|
|
134
|
+
file,
|
|
135
|
+
line: i + 1,
|
|
136
|
+
evidence: text.slice(0, 160),
|
|
137
|
+
vendors,
|
|
138
|
+
prompt: text.length < 180 && /^when|^on\b/i.test(text) ? text : promptFromTodo(text, vendors)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return found;
|
|
142
|
+
}
|
|
143
|
+
function scanWebhookHandlers(file, lines, content) {
|
|
144
|
+
const found = [];
|
|
145
|
+
const routeRe = /(?:router|app)\.(?:post|put|patch)\s*\(\s*['"`]([^'"`]*(?:webhook|hook|callback|notify|event)[^'"`]*)['"`]/gi;
|
|
146
|
+
let m;
|
|
147
|
+
while (m = routeRe.exec(content)) {
|
|
148
|
+
const path = m[1];
|
|
149
|
+
const upto = content.slice(0, m.index);
|
|
150
|
+
const lineNo = upto.split("\n").length;
|
|
151
|
+
const windowStart = Math.max(0, lineNo - 1);
|
|
152
|
+
const window = lines.slice(windowStart, Math.min(lines.length, windowStart + 20)).join("\n");
|
|
153
|
+
const stubby = /(TODO|FIXME|not\s+implemented|throw\s+new\s+Error)/i.test(window) || window.replace(/[^{}]/g, "").length < 4;
|
|
154
|
+
if (!stubby) continue;
|
|
155
|
+
const vendors = detectVendors(path + " " + window);
|
|
156
|
+
found.push({
|
|
157
|
+
score: 70 + vendors.length * 10,
|
|
158
|
+
kind: "webhook-handler",
|
|
159
|
+
file,
|
|
160
|
+
line: lineNo,
|
|
161
|
+
evidence: `${path} \u2014 route body is empty / TODO / not-implemented`,
|
|
162
|
+
vendors,
|
|
163
|
+
prompt: vendors.length ? `When a ${vendors[0]} webhook hits ${path}, handle the payload and ${inferAction(vendors)}.` : `When an incoming webhook hits ${path}, verify the signature, parse the payload and forward the result to the configured target.`
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return found;
|
|
167
|
+
}
|
|
168
|
+
function scanVendorImports(file, lines) {
|
|
169
|
+
const found = [];
|
|
170
|
+
for (let i = 0; i < lines.length; i++) {
|
|
171
|
+
const line = lines[i];
|
|
172
|
+
const match = line.match(/(?:from\s+|require\(\s*)['"]([^'"\n]+)['"]/);
|
|
173
|
+
if (!match) continue;
|
|
174
|
+
const spec = match[1];
|
|
175
|
+
if (spec.startsWith(".") || spec.startsWith("/") || spec.startsWith("node:")) continue;
|
|
176
|
+
const vendor = detectVendor(spec.replace(/^@/, "").toLowerCase());
|
|
177
|
+
if (!vendor) continue;
|
|
178
|
+
const vendorUses = (readSafe(file).match(new RegExp(`\\b${vendor}`, "gi")) || []).length;
|
|
179
|
+
if (vendorUses > 6) continue;
|
|
180
|
+
const title = VENDOR_HINTS[vendor];
|
|
181
|
+
found.push({
|
|
182
|
+
score: 40 + (vendorUses < 3 ? 15 : 0),
|
|
183
|
+
kind: "vendor-sdk-import",
|
|
184
|
+
file,
|
|
185
|
+
line: i + 1,
|
|
186
|
+
evidence: `imports '${spec}' but only uses "${vendor}" ${vendorUses}\xD7 in this file`,
|
|
187
|
+
vendors: [title],
|
|
188
|
+
prompt: `Write a ${title} integration \u2014 the ${title} SDK is already a dependency but there's no handler wired up.`
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return found;
|
|
192
|
+
}
|
|
193
|
+
function readSafe(file) {
|
|
194
|
+
try {
|
|
195
|
+
return readFileSync(file, "utf8");
|
|
196
|
+
} catch {
|
|
197
|
+
return "";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function detectVendor(text) {
|
|
201
|
+
for (const key of Object.keys(VENDOR_HINTS)) if (text.includes(key)) return key;
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
function detectVendors(text) {
|
|
205
|
+
const set = /* @__PURE__ */ new Set();
|
|
206
|
+
const lower = text.toLowerCase();
|
|
207
|
+
for (const key of Object.keys(VENDOR_HINTS)) if (lower.includes(key)) set.add(VENDOR_HINTS[key]);
|
|
208
|
+
return [...set];
|
|
209
|
+
}
|
|
210
|
+
function promptFromTodo(text, vendors) {
|
|
211
|
+
if (vendors.length >= 2) return `When something happens in ${vendors[0]}, do the matching thing in ${vendors[1]}. (From TODO: "${text.slice(0, 100)}")`;
|
|
212
|
+
if (vendors.length === 1) return `Build the ${vendors[0]} integration this TODO describes: "${text.slice(0, 160)}"`;
|
|
213
|
+
return `Build the integration this TODO describes: "${text.slice(0, 180)}"`;
|
|
214
|
+
}
|
|
215
|
+
function inferAction(vendors) {
|
|
216
|
+
if (vendors.length >= 2) return `forward the result to ${vendors[1]}`;
|
|
217
|
+
return "persist the result and reply 200";
|
|
218
|
+
}
|
|
219
|
+
function rankAndDedupe(opportunities) {
|
|
220
|
+
const map = /* @__PURE__ */ new Map();
|
|
221
|
+
for (const op of opportunities) {
|
|
222
|
+
const key = `${op.file}::${op.kind}::${op.vendors.join(",")}`;
|
|
223
|
+
const existing = map.get(key);
|
|
224
|
+
if (!existing || op.score > existing.score) map.set(key, op);
|
|
225
|
+
}
|
|
226
|
+
return [...map.values()].sort((a, b) => b.score - a.score);
|
|
227
|
+
}
|
|
228
|
+
function formatReport(opportunities, root) {
|
|
229
|
+
if (!opportunities.length) return `No integration opportunities found under ${root}.`;
|
|
230
|
+
const header = `patchbay scan found ${opportunities.length} integration opportunit${opportunities.length === 1 ? "y" : "ies"} under ${root}
|
|
231
|
+
`;
|
|
232
|
+
const body = opportunities.map((op, i) => `#${i + 1} score ${op.score} ${op.kind} ${op.file}:${op.line}
|
|
233
|
+
${op.evidence}
|
|
234
|
+
build: patchbay build "${op.prompt}"`).join("\n\n");
|
|
235
|
+
const footer = `
|
|
236
|
+
|
|
237
|
+
Run one directly:
|
|
238
|
+
patchbay build "${opportunities[0].prompt}"
|
|
239
|
+
Or let patchbay build the top N for you:
|
|
240
|
+
patchbay scan ${root} --build-top=1`;
|
|
241
|
+
return header + "\n" + body + footer;
|
|
242
|
+
}
|
|
243
|
+
export {
|
|
244
|
+
formatReport,
|
|
245
|
+
scanRepo
|
|
246
|
+
};
|
|
247
|
+
//# sourceMappingURL=scanner-IPBNTPNM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/scanner.ts"],"sourcesContent":["import { readFileSync, readdirSync, statSync } from 'node:fs'\nimport { join, relative, extname, basename } from 'node:path'\n\n/**\n * `patchbay scan <dir>` walks a repository looking for integration opportunities\n * patchbay could build. It reports a prioritised list with a concrete one-sentence\n * prompt per opportunity so the user can go straight to `patchbay build \"...\"`\n * (or `patchbay scan <dir> --build-top=N` for the hands-off path).\n *\n * The scanner is deliberately heuristic — regex + file-structure only, no LLM —\n * so it's instant, free, and the user can audit every signal we flagged.\n */\n\nexport interface Opportunity {\n score: number\n kind: 'todo' | 'env-var' | 'webhook-handler' | 'vendor-sdk-import'\n file: string\n line: number\n evidence: string\n prompt: string\n vendors: string[]\n}\n\nconst SKIP_DIRS = new Set(['node_modules', '.git', 'dist', '.next', 'out', 'build', '.turbo', '.vercel', 'coverage'])\nconst SCAN_EXTS = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.py', '.go', '.rb', '.env', '.example'])\nconst SCAN_MAX_BYTES = 500_000\n\nconst INTEGRATION_KEYWORDS = /\\b(webhook|sync|notify|integrate|forward|post\\s+to|send\\s+to|push\\s+to|pull\\s+from|fetch\\s+from|subscribe|publish|route\\s+to|hook\\s+into)\\b/i\n\n/** Vendor name → canonical title case for the prompt. */\nconst VENDOR_HINTS: Record<string, string> = {\n stripe: 'Stripe', shopify: 'Shopify', mailchimp: 'Mailchimp', typeform: 'Typeform', pipedrive: 'Pipedrive',\n hubspot: 'HubSpot', salesforce: 'Salesforce', slack: 'Slack', discord: 'Discord', notion: 'Notion',\n airtable: 'Airtable', asana: 'Asana', jira: 'Jira', linear: 'Linear', github: 'GitHub', gitlab: 'GitLab',\n zendesk: 'Zendesk', intercom: 'Intercom', twilio: 'Twilio', sendgrid: 'SendGrid', brevo: 'Brevo',\n resend: 'Resend', postmark: 'Postmark', mailgun: 'Mailgun', calendly: 'Calendly', jotform: 'Jotform',\n pusher: 'Pusher', zoom: 'Zoom', trello: 'Trello', freshdesk: 'Freshdesk', monday: 'Monday',\n pipeline: 'Pipedrive', quickbooks: 'QuickBooks', xero: 'Xero', paypal: 'PayPal', square: 'Square',\n}\n\nconst VENDOR_PATTERN = new RegExp(`\\\\b(${Object.keys(VENDOR_HINTS).join('|')})\\\\b`, 'gi')\n\nexport function scanRepo(root: string): Opportunity[] {\n const files = walk(root)\n const opportunities: Opportunity[] = []\n for (const file of files) {\n let content: string\n try {\n const size = statSync(file).size\n if (size > SCAN_MAX_BYTES) continue\n content = readFileSync(file, 'utf8')\n } catch { continue }\n\n const rel = relative(root, file).replace(/\\\\/g, '/')\n const name = basename(file).toLowerCase()\n const lines = content.split('\\n')\n\n if (name.endsWith('.env') || name.endsWith('.env.example') || name === '.env.example' || name === '.env.sample') {\n opportunities.push(...scanEnvFile(rel, lines))\n }\n opportunities.push(...scanTodos(rel, lines))\n opportunities.push(...scanWebhookHandlers(rel, lines, content))\n opportunities.push(...scanVendorImports(rel, lines))\n }\n return rankAndDedupe(opportunities)\n}\n\nfunction walk(dir: string, out: string[] = []): string[] {\n let entries: string[]\n try { entries = readdirSync(dir) } catch { return out }\n for (const entry of entries) {\n if (entry.startsWith('.') && !entry.startsWith('.env')) continue\n if (SKIP_DIRS.has(entry)) continue\n const full = join(dir, entry)\n let st\n try { st = statSync(full) } catch { continue }\n if (st.isDirectory()) walk(full, out)\n else if (SCAN_EXTS.has(extname(entry).toLowerCase()) || entry.startsWith('.env')) out.push(full)\n }\n return out\n}\n\nfunction scanEnvFile(file: string, lines: string[]): Opportunity[] {\n const found: Opportunity[] = []\n const grouped = new Map<string, { line: number; vars: string[] }>()\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n const match = line.match(/^([A-Z][A-Z0-9_]+)=/)\n if (!match) continue\n const key = match[1]!\n const vendor = detectVendor(key.toLowerCase())\n if (!vendor) continue\n const bucket = grouped.get(vendor) ?? { line: i + 1, vars: [] }\n bucket.vars.push(key)\n grouped.set(vendor, bucket)\n }\n for (const [vendor, info] of grouped) {\n const title = VENDOR_HINTS[vendor]!\n found.push({\n score: 60 + info.vars.length * 5,\n kind: 'env-var',\n file,\n line: info.line,\n evidence: info.vars.join(', '),\n vendors: [title],\n prompt: `When something happens that needs ${title}, call ${title}'s API with the fields configured via ${info.vars.join(' / ')}.`,\n })\n }\n return found\n}\n\nfunction scanTodos(file: string, lines: string[]): Opportunity[] {\n const found: Opportunity[] = []\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n // Only inline / block comments, not strings or type literals.\n const match = line.match(/(?:\\/\\/|\\/\\*|#|<!--|\\*)\\s*(?:TODO|FIXME|XXX|HACK)\\b[: ]*(.*)/i)\n if (!match) continue\n const text = match[1]!.replace(/\\*\\/\\s*$/, '').trim()\n if (text.length < 15) continue\n if (!INTEGRATION_KEYWORDS.test(text) && !VENDOR_PATTERN.test(text)) continue\n const vendors = detectVendors(text)\n found.push({\n score: 50 + vendors.length * 10 + (INTEGRATION_KEYWORDS.test(text) ? 10 : 0),\n kind: 'todo',\n file,\n line: i + 1,\n evidence: text.slice(0, 160),\n vendors,\n prompt: text.length < 180 && /^when|^on\\b/i.test(text) ? text : promptFromTodo(text, vendors),\n })\n }\n return found\n}\n\nfunction scanWebhookHandlers(file: string, lines: string[], content: string): Opportunity[] {\n const found: Opportunity[] = []\n // Node/TS: look for Express/Next route handlers that are near-empty or throw.\n const routeRe = /(?:router|app)\\.(?:post|put|patch)\\s*\\(\\s*['\"`]([^'\"`]*(?:webhook|hook|callback|notify|event)[^'\"`]*)['\"`]/gi\n let m: RegExpExecArray | null\n while ((m = routeRe.exec(content))) {\n const path = m[1]!\n const upto = content.slice(0, m.index)\n const lineNo = upto.split('\\n').length\n const windowStart = Math.max(0, lineNo - 1)\n const window = lines.slice(windowStart, Math.min(lines.length, windowStart + 20)).join('\\n')\n const stubby = /(TODO|FIXME|not\\s+implemented|throw\\s+new\\s+Error)/i.test(window) || window.replace(/[^{}]/g, '').length < 4\n if (!stubby) continue\n const vendors = detectVendors(path + ' ' + window)\n found.push({\n score: 70 + vendors.length * 10,\n kind: 'webhook-handler',\n file,\n line: lineNo,\n evidence: `${path} — route body is empty / TODO / not-implemented`,\n vendors,\n prompt: vendors.length\n ? `When a ${vendors[0]} webhook hits ${path}, handle the payload and ${inferAction(vendors)}.`\n : `When an incoming webhook hits ${path}, verify the signature, parse the payload and forward the result to the configured target.`,\n })\n }\n return found\n}\n\nfunction scanVendorImports(file: string, lines: string[]): Opportunity[] {\n const found: Opportunity[] = []\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n const match = line.match(/(?:from\\s+|require\\(\\s*)['\"]([^'\"\\n]+)['\"]/)\n if (!match) continue\n const spec = match[1]!\n // Only real npm packages: skip relative imports (./x, ../x) and node builtins (node:x).\n if (spec.startsWith('.') || spec.startsWith('/') || spec.startsWith('node:')) continue\n const vendor = detectVendor(spec.replace(/^@/, '').toLowerCase())\n if (!vendor) continue\n // Count how many times the vendor name shows up in the file to tell \"imported-and-used\" from \"imported-but-stubbed\".\n const vendorUses = (readSafe(file).match(new RegExp(`\\\\b${vendor}`, 'gi')) || []).length\n if (vendorUses > 6) continue // actively used; probably not an opportunity\n const title = VENDOR_HINTS[vendor]!\n found.push({\n score: 40 + (vendorUses < 3 ? 15 : 0),\n kind: 'vendor-sdk-import',\n file,\n line: i + 1,\n evidence: `imports '${spec}' but only uses \"${vendor}\" ${vendorUses}× in this file`,\n vendors: [title],\n prompt: `Write a ${title} integration — the ${title} SDK is already a dependency but there's no handler wired up.`,\n })\n }\n return found\n}\n\nfunction readSafe(file: string): string {\n try { return readFileSync(file, 'utf8') } catch { return '' }\n}\n\nfunction detectVendor(text: string): string | null {\n for (const key of Object.keys(VENDOR_HINTS)) if (text.includes(key)) return key\n return null\n}\n\nfunction detectVendors(text: string): string[] {\n const set = new Set<string>()\n const lower = text.toLowerCase()\n for (const key of Object.keys(VENDOR_HINTS)) if (lower.includes(key)) set.add(VENDOR_HINTS[key]!)\n return [...set]\n}\n\nfunction promptFromTodo(text: string, vendors: string[]): string {\n if (vendors.length >= 2) return `When something happens in ${vendors[0]}, do the matching thing in ${vendors[1]}. (From TODO: \"${text.slice(0, 100)}\")`\n if (vendors.length === 1) return `Build the ${vendors[0]} integration this TODO describes: \"${text.slice(0, 160)}\"`\n return `Build the integration this TODO describes: \"${text.slice(0, 180)}\"`\n}\n\nfunction inferAction(vendors: string[]): string {\n if (vendors.length >= 2) return `forward the result to ${vendors[1]}`\n return 'persist the result and reply 200'\n}\n\nfunction rankAndDedupe(opportunities: Opportunity[]): Opportunity[] {\n // Collapse duplicates (same file + same first vendor + same kind) to the highest-scoring.\n const map = new Map<string, Opportunity>()\n for (const op of opportunities) {\n const key = `${op.file}::${op.kind}::${op.vendors.join(',')}`\n const existing = map.get(key)\n if (!existing || op.score > existing.score) map.set(key, op)\n }\n return [...map.values()].sort((a, b) => b.score - a.score)\n}\n\nexport function formatReport(opportunities: Opportunity[], root: string): string {\n if (!opportunities.length) return `No integration opportunities found under ${root}.`\n const header = `patchbay scan found ${opportunities.length} integration opportunit${opportunities.length === 1 ? 'y' : 'ies'} under ${root}\\n`\n const body = opportunities\n .map((op, i) => `#${i + 1} score ${op.score} ${op.kind} ${op.file}:${op.line}\\n ${op.evidence}\\n build: patchbay build \"${op.prompt}\"`)\n .join('\\n\\n')\n const footer = `\\n\\nRun one directly:\\n patchbay build \"${opportunities[0]!.prompt}\"\\nOr let patchbay build the top N for you:\\n patchbay scan ${root} --build-top=1`\n return header + '\\n' + body + footer\n}\n"],"mappings":";AAAA,SAAS,cAAc,aAAa,gBAAgB;AACpD,SAAS,MAAM,UAAU,SAAS,gBAAgB;AAsBlD,IAAM,YAAY,oBAAI,IAAI,CAAC,gBAAgB,QAAQ,QAAQ,SAAS,OAAO,SAAS,UAAU,WAAW,UAAU,CAAC;AACpH,IAAM,YAAY,oBAAI,IAAI,CAAC,OAAO,QAAQ,OAAO,QAAQ,QAAQ,QAAQ,OAAO,OAAO,OAAO,QAAQ,UAAU,CAAC;AACjH,IAAM,iBAAiB;AAEvB,IAAM,uBAAuB;AAG7B,IAAM,eAAuC;AAAA,EAC3C,QAAQ;AAAA,EAAU,SAAS;AAAA,EAAW,WAAW;AAAA,EAAa,UAAU;AAAA,EAAY,WAAW;AAAA,EAC/F,SAAS;AAAA,EAAW,YAAY;AAAA,EAAc,OAAO;AAAA,EAAS,SAAS;AAAA,EAAW,QAAQ;AAAA,EAC1F,UAAU;AAAA,EAAY,OAAO;AAAA,EAAS,MAAM;AAAA,EAAQ,QAAQ;AAAA,EAAU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