@agent-native/core 0.49.14 → 0.49.16

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/index.js CHANGED
@@ -60,6 +60,9 @@ function buildRedactedCommandTag(argv) {
60
60
  Sentry.init({
61
61
  dsn: "https://0d384e9eff2f6542af468b92769f2f5b@o117565.ingest.us.sentry.io/4511270386466816",
62
62
  release: `agent-native-cli@${_version}`,
63
+ // Sentry's Http integration wraps outgoing fetch in a way that breaks the
64
+ // hosted Plan MCP route negotiation used by recap CI smoke checks.
65
+ integrations: (integrations) => integrations.filter((integration) => integration.name !== "Http"),
63
66
  // sendDefaultPii MUST stay false — the CLI runs in third-party developer
64
67
  // environments and we never want to ship request headers, IPs, cookies,
65
68
  // or process env contents to Sentry without explicit consent.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AAEvC,2EAA2E;AAC3E,IAAI,QAAQ,GAAG,SAAS,CAAC;AACzB,IAAI,CAAC;IACH,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,yCAAyC;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,oBAAoB,CAAC,EAAE,OAAO,CAAC,CACxE,CAAC;IACF,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC;AACzB,CAAC;AAAC,MAAM,CAAC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AC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;qBAC1C,KAAK,CAAC,yBAAyB,CAAC,CAAC;gBACpC,MAAM;YACR,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;YAC7C,OAAO,CAAC,KAAK,CACX,sEAAsE;gBACpE,uBAAuB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI;gBAClD,qCAAqC;gBACrC,wCAAwC,CAC3C,CAAC;YACF,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACtD,OAAO,CAAC,KAAK,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC;YACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;QAC7C,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACtD,OAAO,CAAC,KAAK,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { execSync, spawn } from \"child_process\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { fileURLToPath } from \"url\";\nimport * as Sentry from \"@sentry/node\";\n\n// Resolve version once at module scope — used by both --version and --help\nlet _version = \"unknown\";\ntry {\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n // dist/cli/index.js → ../../package.json\n const pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, \"../../package.json\"), \"utf-8\"),\n );\n _version = pkg.version;\n} catch {}\n\n// Fail fast on unsupported Node versions. `engines.node: \">=22\"` is only\n// advisory — npx/pnpm merely warn — so without this an older Node (18/20)\n// first fails deep inside a scaffold dynamic import with a cryptic\n// ERR_MODULE / syntax error that `handleScaffoldImportError` misreports as a\n// corrupt npx cache. A clear up-front message saves that whole detour.\nconst REQUIRED_NODE_MAJOR = 22;\nconst _nodeMajor = Number(process.versions.node.split(\".\")[0]);\nif (Number.isFinite(_nodeMajor) && _nodeMajor < REQUIRED_NODE_MAJOR) {\n console.error(\n `agent-native requires Node.js ${REQUIRED_NODE_MAJOR} or newer, but you're on Node ${process.versions.node}.\\n` +\n `Upgrade Node (https://nodejs.org) and re-run. With nvm: \\`nvm install ${REQUIRED_NODE_MAJOR}\\`.`,\n );\n process.exit(1);\n}\n\n/**\n * Build a redacted \"command\" tag from process.argv. Strips the value that\n * follows any --token / --key / --secret / --password / --api-key flag so\n * we don't ship developer secrets to Sentry alongside the crash.\n *\n * Supports both `--token foo` (separate argv item) and `--token=foo`\n * (combined argv item) forms.\n */\nconst SECRET_FLAG_RE = /^--?(token|key|secret|password|api[_-]?key)$/i;\nconst SECRET_FLAG_EQ_RE =\n /^(--?(token|key|secret|password|api[_-]?key))=(.*)$/i;\nfunction buildRedactedCommandTag(argv: string[]): string {\n const out: string[] = [];\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i];\n if (SECRET_FLAG_RE.test(a)) {\n out.push(a);\n // Consume the next argv item as the secret value\n if (i + 1 < argv.length) {\n out.push(\"<redacted>\");\n i++;\n }\n continue;\n }\n const m = a.match(SECRET_FLAG_EQ_RE);\n if (m) {\n out.push(`${m[1]}=<redacted>`);\n continue;\n }\n out.push(a);\n }\n return out.join(\" \");\n}\n\nSentry.init({\n dsn: \"https://0d384e9eff2f6542af468b92769f2f5b@o117565.ingest.us.sentry.io/4511270386466816\",\n release: `agent-native-cli@${_version}`,\n // sendDefaultPii MUST stay false — the CLI runs in third-party developer\n // environments and we never want to ship request headers, IPs, cookies,\n // or process env contents to Sentry without explicit consent.\n sendDefaultPii: false,\n beforeSend(event) {\n // Drop expected user-input rejections (validateRepoName, etc.) so they\n // don't pollute Sentry with non-bug noise.\n const exceptionType = event.exception?.values?.[0]?.type;\n if (\n exceptionType === \"ValidationError\" ||\n event.tags?.handled === \"validation\"\n ) {\n return null;\n }\n\n // Defense in depth: strip any sensitive fields that may have been\n // attached to the event despite sendDefaultPii: false (e.g. integrations\n // that capture request metadata).\n if (event.request) {\n if (event.request.headers) {\n const headers = event.request.headers as Record<string, string>;\n for (const k of Object.keys(headers)) {\n const lk = k.toLowerCase();\n if (\n lk === \"cookie\" ||\n lk === \"authorization\" ||\n lk === \"set-cookie\" ||\n lk === \"proxy-authorization\"\n ) {\n delete headers[k];\n }\n }\n }\n // Cookies are also exposed via event.request.cookies as a separate field\n delete (event.request as Record<string, unknown>).cookies;\n }\n // Keep user info that was explicitly set via Sentry.setUser (id/email)\n // so we can attribute crashes back to the operator. Always strip\n // ip_address — the CLI runs on third-party machines and the IP is auto-\n // collected without consent. If only auto-collected fields remain,\n // drop the user object entirely.\n if (event.user) {\n const user = event.user as Record<string, unknown>;\n delete user.ip_address;\n const hasIdentity =\n typeof user.id === \"string\" ||\n typeof user.email === \"string\" ||\n typeof user.username === \"string\";\n if (!hasIdentity) {\n delete event.user;\n }\n }\n // Sentry's contexts can carry process.env snapshots — strip env-shaped\n // contexts so we don't leak deployment secrets.\n if (event.contexts && typeof event.contexts === \"object\") {\n delete (event.contexts as Record<string, unknown>).runtime_env;\n }\n\n event.tags = {\n ...event.tags,\n // Build the command tag from process.argv with secrets redacted so\n // `agent-native ... --token foo` doesn't leak `foo` to Sentry.\n command: buildRedactedCommandTag(process.argv.slice(2)),\n subcommand: process.argv[2] ?? \"none\",\n nodeVersion: process.version,\n platform: process.platform,\n };\n return event;\n },\n});\n\n// Identify the operator so future CLI errors carry spaceId / builderUserId\n// that we can map back to a real Builder user. The CLI doesn't have a real\n// email today — only the env-managed identifiers from the workspace's .env.\n{\n const builderUserId = process.env.BUILDER_USER_ID;\n const builderPublicKey = process.env.BUILDER_PUBLIC_KEY;\n if (builderUserId) {\n Sentry.setUser({ id: builderUserId });\n Sentry.setTag(\"builderUserId\", builderUserId);\n }\n if (builderPublicKey) {\n Sentry.setTag(\"spaceId\", builderPublicKey);\n }\n}\n\nconst FEEDBACK_URL =\n \"https://forms.agent-native.com/f/agent-native-feedback/_16ewV?source=cli\";\nconst BUGS_URL = \"https://github.com/BuilderIO/agent-native/issues\";\n\nconst command = process.argv[2];\n// Filter out bare \"--\" separators that pnpm inserts between its args and script args\nconst args = process.argv.slice(3).filter((a) => a !== \"--\");\n\nfunction parseScaffoldArgs(argv: string[]): {\n name?: string;\n template?: string;\n standalone: boolean;\n} {\n let name: string | undefined;\n let template: string | undefined;\n let standalone = false;\n\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--template\" && argv[i + 1]) {\n template = argv[++i];\n } else if (arg.startsWith(\"--template=\")) {\n template = arg.slice(\"--template=\".length);\n } else if (arg === \"--standalone\") {\n standalone = true;\n } else if (!arg.startsWith(\"-\") && !name) {\n name = arg;\n }\n }\n\n return { name, template, standalone };\n}\n\n// Track CLI usage (best-effort, non-blocking)\nfunction trackCli(event: string, props?: Record<string, unknown>): void {\n try {\n import(\"../tracking/registry.js\").then((m) => {\n m.track(event, { command, ...props });\n });\n import(\"../tracking/providers.js\").then((m) =>\n m.registerBuiltinProviders(),\n );\n } catch {}\n}\n\n// Global error handler — show feedback link on unhandled crashes\nprocess.on(\"uncaughtException\", (err) => {\n console.error(`\\n Unexpected error: ${err.message}\\n`);\n console.error(` Report this bug: ${BUGS_URL}`);\n console.error(` Send feedback: ${FEEDBACK_URL}\\n`);\n trackCli(\"cli.crash\", { error: err.message });\n Sentry.captureException(err);\n Sentry.flush(2000).finally(() => process.exit(1));\n});\n\nprocess.on(\"unhandledRejection\", (reason: any) => {\n console.error(`\\n Unhandled error: ${reason?.message ?? reason}\\n`);\n console.error(` Report this bug: ${BUGS_URL}`);\n console.error(` Send feedback: ${FEEDBACK_URL}\\n`);\n trackCli(\"cli.crash\", { error: reason?.message ?? String(reason) });\n Sentry.captureException(reason);\n Sentry.flush(2000).finally(() => process.exit(1));\n});\n\n// Surface a self-heal hint when an interrupted `npx @agent-native/core@latest ...`\n// leaves a half-extracted package in the npx cache and a follow-up run fails\n// to load one of our own sub-modules.\nfunction handleScaffoldImportError(err: any): never {\n const msg = err?.message ?? String(err);\n const looksLikeCorruptCache =\n err?.code === \"ERR_MODULE_NOT_FOUND\" ||\n err?.code === \"MODULE_NOT_FOUND\" ||\n err?.code === \"ENOENT\" ||\n /Cannot find module|tarball|integrity|EINTEGRITY|corrupt|truncated/i.test(\n msg,\n );\n if (looksLikeCorruptCache) {\n console.error(\n `\\n Failed to load the scaffolder. This usually means an earlier\\n \\`npx\\` run was interrupted and left a corrupt cache.\\n\\n Clear the npx cache and try again:\\n rm -rf ~/.npm/_npx\\n npx @agent-native/core@latest create\\n\\n Original error: ${msg}\\n`,\n );\n } else {\n console.error(`\\n Failed to load the scaffolder: ${msg}\\n`);\n }\n trackCli(\"cli.scaffold.import_error\", { error: msg });\n Sentry.captureException(err);\n Sentry.flush(2000).finally(() => process.exit(1));\n throw err;\n}\n\nfunction findViteBin(): string {\n // Look for vite in node_modules/.bin\n const localVite = path.resolve(\"node_modules/.bin/vite\");\n if (fs.existsSync(localVite)) return localVite;\n return \"vite\"; // fallback to PATH\n}\n\nfunction findTsxBin(): string {\n const localTsx = path.resolve(\"node_modules/.bin/tsx\");\n if (fs.existsSync(localTsx)) return localTsx;\n return \"tsx\";\n}\n\nfunction findReactRouterBin(): string {\n const localBin = path.resolve(\"node_modules/.bin/react-router\");\n if (fs.existsSync(localBin)) return localBin;\n return \"react-router\";\n}\n\n/** Check if the project uses React Router framework mode (has react-router.config.ts) */\nfunction isReactRouterFramework(): boolean {\n return (\n fs.existsSync(path.resolve(\"react-router.config.ts\")) ||\n fs.existsSync(path.resolve(\"react-router.config.js\"))\n );\n}\n\nfunction isWorkspaceRoot(): boolean {\n const pkgPath = path.resolve(\"package.json\");\n if (!fs.existsSync(pkgPath)) return false;\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n return (\n typeof pkg?.[\"agent-native\"]?.workspaceCore === \"string\" &&\n fs.existsSync(path.resolve(\"apps\"))\n );\n } catch {\n return false;\n }\n}\n\nfunction run(\n cmd: string,\n cmdArgs: string[],\n opts?: { stdio?: \"inherit\" | \"pipe\" },\n) {\n const child = spawn(cmd, cmdArgs, {\n stdio: opts?.stdio ?? \"inherit\",\n shell: process.platform === \"win32\",\n env: process.env,\n });\n child.on(\"exit\", (code) => process.exit(code ?? 0));\n // Forward signals to child so Cmd+C doesn't leave zombie processes holding ports\n for (const sig of [\"SIGINT\", \"SIGTERM\", \"SIGHUP\"] as const) {\n process.on(sig, () => {\n child.kill(sig);\n setTimeout(() => {\n try {\n child.kill(\"SIGKILL\");\n } catch {}\n process.exit(1);\n }, 5000).unref();\n });\n }\n return child;\n}\n\n/**\n * Walk up from `cwd` and try to figure out which template / app this build\n * is running for. We look for two patterns:\n *\n * - `templates/<name>/...` — building inside the framework monorepo\n * - `apps/<name>/...` — building inside a scaffolded workspace\n *\n * Both, neither, or one may match. Used purely as Sentry tags so we can\n * filter the noisy \"Command failed: react-router build\" issues by template.\n */\nfunction inferBuildContext(cwd: string): {\n template?: string;\n app?: string;\n} {\n const segs = cwd.split(path.sep);\n let template: string | undefined;\n let app: string | undefined;\n for (let i = 0; i < segs.length - 1; i++) {\n if (segs[i] === \"templates\" && segs[i + 1] && !segs[i + 1].startsWith(\".\"))\n template = segs[i + 1];\n if (segs[i] === \"apps\" && segs[i + 1] && !segs[i + 1].startsWith(\".\"))\n app = segs[i + 1];\n }\n return { template, app };\n}\n\n/**\n * Run a build subcommand, streaming its stdout/stderr to the user's terminal\n * in real time while also capturing bounded tails for Sentry. On non-zero\n * exit we report a structured event (template, app, exit code, stderr/stdout\n * tails) and exit with the child's code. We deliberately do NOT throw — the\n * global uncaughtException handler would re-capture with a generic\n * \"Error: Command failed\" title, collapsing every template's failure into\n * one issue (which is exactly what we're trying to fix here).\n */\nfunction runBuildStep(\n cmd: string,\n cmdArgs: string[],\n opts: { label: string; env?: NodeJS.ProcessEnv },\n): Promise<void> {\n return new Promise<void>((resolve) => {\n const STDERR_TAIL_BYTES = 8000;\n const STDOUT_TAIL_BYTES = 4000;\n let stderrBuf = \"\";\n let stdoutBuf = \"\";\n\n const child = spawn(cmd, cmdArgs, {\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n shell: process.platform === \"win32\",\n env: opts.env ?? process.env,\n });\n\n child.stdout?.on(\"data\", (chunk: Buffer) => {\n process.stdout.write(chunk);\n const next = stdoutBuf + chunk.toString(\"utf-8\");\n stdoutBuf =\n next.length > STDOUT_TAIL_BYTES ? next.slice(-STDOUT_TAIL_BYTES) : next;\n });\n child.stderr?.on(\"data\", (chunk: Buffer) => {\n process.stderr.write(chunk);\n const next = stderrBuf + chunk.toString(\"utf-8\");\n stderrBuf =\n next.length > STDERR_TAIL_BYTES ? next.slice(-STDERR_TAIL_BYTES) : next;\n });\n\n child.on(\"error\", (err) => {\n // Failure to spawn (ENOENT, etc.).\n const cwd = process.cwd();\n const { template, app } = inferBuildContext(cwd);\n Sentry.captureException(err, {\n tags: {\n buildStep: opts.label,\n ...(template ? { template } : {}),\n ...(app ? { app } : {}),\n },\n extra: {\n command: `${cmd} ${cmdArgs.join(\" \")}`,\n cwd,\n stage: \"spawn\",\n },\n });\n Sentry.flush(2000).finally(() => process.exit(1));\n });\n\n child.on(\"exit\", (code, signal) => {\n const exitCode = code ?? (signal ? 1 : 0);\n if (exitCode === 0) {\n resolve();\n return;\n }\n const cwd = process.cwd();\n const { template, app } = inferBuildContext(cwd);\n const childCommand = `${cmd} ${cmdArgs.join(\" \")}`;\n const err = new Error(\n `Build step \"${opts.label}\" failed with exit code ${exitCode}` +\n (template ? ` (template=${template})` : \"\") +\n (app ? ` (app=${app})` : \"\"),\n );\n Sentry.captureException(err, {\n tags: {\n buildStep: opts.label,\n ...(template ? { template } : {}),\n ...(app ? { app } : {}),\n },\n extra: {\n command: childCommand,\n cwd,\n exitCode,\n signal: signal ?? null,\n stderrTail: stderrBuf,\n stdoutTail: stdoutBuf,\n },\n });\n // Don't throw — see comment on runBuildStep above.\n Sentry.flush(2000).finally(() => process.exit(exitCode));\n });\n });\n}\n\ntrackCli(\"cli.run\");\n\nswitch (command) {\n case \"dev\": {\n if (isWorkspaceRoot()) {\n import(\"./workspace-dev.js\")\n .then((m) => m.runWorkspaceDev({ args }))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n const vite = findViteBin();\n run(vite, args);\n break;\n }\n\n case \"workspace-dev\": {\n import(\"./workspace-dev.js\")\n .then((m) => m.runWorkspaceDev({ args }))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"build\": {\n // React Router framework mode uses `react-router build` which\n // internally runs `vite build` with proper environment orchestration.\n // Legacy SPA mode uses `vite build` directly.\n //\n // Each step uses runBuildStep so that on failure we get a Sentry event\n // tagged with template/app and including stderr/stdout tails. If the\n // child exits non-zero, runBuildStep calls process.exit itself; the\n // continuation only runs on success.\n (async () => {\n if (isReactRouterFramework()) {\n const rr = findReactRouterBin();\n console.log(\"Building (React Router framework mode)...\");\n await runBuildStep(rr, [\"build\"], { label: \"react-router-build\" });\n } else {\n const vite = findViteBin();\n console.log(\"Building...\");\n await runBuildStep(vite, [\"build\"], { label: \"vite-build\" });\n }\n\n // Post-build: framework-mode apps also need a Nitro server bundle for\n // `agent-native start` and for serverless presets.\n if (isReactRouterFramework()) {\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n const deployBuild = path.resolve(__dirname, \"../deploy/build.js\");\n if (fs.existsSync(deployBuild)) {\n await runBuildStep(\"node\", [deployBuild], {\n label: \"deploy-build\",\n env: process.env,\n });\n } else {\n console.warn(\n `[build] Deploy build script not found at ${deployBuild}. Skipping post-build step.`,\n );\n }\n }\n\n console.log(\"\\nBuild complete.\");\n })().catch((err) => {\n // runBuildStep handles its own failures and exits, so reaching here\n // implies a programming error in the orchestration above. Capture\n // and exit so the global unhandledRejection handler doesn't double-\n // report with a generic title.\n Sentry.captureException(err);\n Sentry.flush(2000).finally(() => process.exit(1));\n });\n break;\n }\n\n case \"start\": {\n // Like `next start` — runs Nitro production server\n const serverEntry = path.resolve(\".output/server/index.mjs\");\n if (!fs.existsSync(serverEntry)) {\n console.error(\n 'No production build found. Run \"agent-native build\" first.',\n );\n process.exit(1);\n }\n run(\"node\", [serverEntry, ...args]);\n break;\n }\n\n case \"action\": {\n // Run an action from actions/ (or scripts/ for backwards compat)\n const actionName = args[0];\n if (!actionName) {\n console.error(\"Usage: agent-native action <name> [--args]\");\n process.exit(1);\n }\n const tsxAction = findTsxBin();\n // Try actions/run.ts first, fall back to scripts/run.ts\n const actionsRun = path.resolve(\"actions/run.ts\");\n const scriptsRun = path.resolve(\"scripts/run.ts\");\n const runFile = fs.existsSync(actionsRun) ? actionsRun : scriptsRun;\n run(tsxAction, [runFile, ...args]);\n break;\n }\n\n case \"script\": {\n // @deprecated — use `agent-native action` instead\n const scriptName = args[0];\n if (!scriptName) {\n console.error(\"Usage: agent-native script <name> [--args]\");\n process.exit(1);\n }\n const tsx = findTsxBin();\n // Try actions/run.ts first, fall back to scripts/run.ts\n const actionsRunScript = path.resolve(\"actions/run.ts\");\n const scriptsRunScript = path.resolve(\"scripts/run.ts\");\n const runFileScript = fs.existsSync(actionsRunScript)\n ? actionsRunScript\n : scriptsRunScript;\n run(tsx, [runFileScript, ...args]);\n break;\n }\n\n case \"typecheck\": {\n // Run TypeScript type checking\n // React Router framework mode generates route types first\n if (isReactRouterFramework()) {\n const rr = findReactRouterBin();\n try {\n execSync(`${rr} typegen`, { stdio: \"inherit\" });\n } catch {\n // typegen may fail if routes aren't set up yet — continue to tsc\n }\n }\n const tsc = path.resolve(\"node_modules/.bin/tsc\");\n const tscBin = fs.existsSync(tsc) ? tsc : \"tsc\";\n run(tscBin, [\"--noEmit\", ...args]);\n break;\n }\n\n case \"create\": {\n // Defaults to creating a workspace with a multi-select template picker.\n // Use --standalone for the old single-app flow.\n // --template foo,bar Pre-select multiple templates in the picker\n // --standalone Scaffold a single standalone app\n const parsed = parseScaffoldArgs(args);\n import(\"./create.js\")\n .then((m) =>\n m.createApp(parsed.name, {\n template: parsed.template,\n standalone: parsed.standalone,\n }),\n )\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"migrate\": {\n import(\"./migrate.js\")\n .then((m) => m.runMigrate(args))\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"code\": {\n import(\"./code.js\")\n .then((m) => m.runCode(args))\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"mcp\": {\n // Connect external coding agents (Claude Code, Cowork, Codex) over MCP.\n // `mcp serve` runs the stdio transport; install/uninstall/status/token\n // manage client configs + the local token.\n import(\"./mcp.js\")\n .then((m) => m.runMcp(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"connect\": {\n // Wire your local coding agent to a DEPLOYED agent-native app via a\n // browser device-code flow (no token copying). `--all` connects every\n // first-party hosted app; `--token` is the no-browser fallback.\n import(\"./connect.js\")\n .then((m) => m.runConnect(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"reconnect\":\n case \"reauth\": {\n // Refresh an existing remote MCP auth/config entry without reinstalling\n // app skills or running the broader connector setup path.\n import(\"./connect.js\")\n .then((m) => m.runConnect([\"reconnect\", ...args]))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"app-skill\": {\n // Package or install an agent-native app as a skill-backed MCP/app bundle.\n import(\"./app-skill.js\")\n .then((m) => m.runAppSkill(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"skills\": {\n // Friendly skill install surface. Wraps open skills installation plus MCP.\n import(\"./skills.js\")\n .then((m) => m.runSkills(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"recap\": {\n // PR visual recap helpers used by the GitHub Action. Promoted to the CLI\n // so an installed repo's workflow can call `agent-native recap …` instead\n // of copying helper scripts. Run `agent-native recap help` for the full\n // subcommand list.\n import(\"./recap.js\")\n .then((m) => m.runRecap(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"plan\": {\n // DB-free local plan helpers. These never call the Plan app action surface;\n // they only read/write MDX folders and static preview HTML.\n import(\"./plan-local.js\")\n .then((m) => m.runPlan(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"create-workspace\": {\n // Deprecated alias for `create` (since workspace is now the default).\n const parsed = parseScaffoldArgs(args);\n import(\"./create-workspace.js\")\n .then((m) =>\n m.createWorkspace({ name: parsed.name, template: parsed.template }),\n )\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"add-app\": {\n // Add one or more apps to the current workspace.\n const parsed = parseScaffoldArgs(args);\n import(\"./create.js\")\n .then((m) =>\n m.addAppToWorkspace(parsed.name, { template: parsed.template }),\n )\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"deploy\": {\n // Build and deploy the entire workspace as one unit. Each app is served\n // at /<app>/* under the same origin.\n import(\"../deploy/workspace-deploy.js\")\n .then((m) => m.runWorkspaceDeploy({ args }))\n .catch((err) => {\n console.error(\"Deploy failed:\", err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"setup-agents\": {\n import(\"./setup-agents.js\").then((m) => m.runSetupAgents());\n break;\n }\n\n case \"info\": {\n // Print read-only info about an installable package (e.g. @agent-native/scheduling).\n // Lists subpath exports, source paths in node_modules, and docs pointers.\n import(\"./info.js\").then((m) => m.runInfo(args[0]));\n break;\n }\n\n case \"audit-agent-web\": {\n import(\"./audit-agent-web.js\")\n .then((m) => m.runAuditAgentWeb(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"--version\":\n case \"-v\": {\n console.log(_version);\n break;\n }\n\n case undefined:\n import(\"./code.js\")\n .then((m) => m.runCode([]))\n .catch(handleScaffoldImportError);\n break;\n\n case \"--help\":\n case \"-h\":\n console.log(`agent-native v${_version}\n\nUsage:\n agent-native Launch Agent-Native Code workspace\n agent-native \"fix tests\" Start an Agent-Native Code coding session\n agent-native dev Start development server\n (or the workspace gateway at a workspace root)\n agent-native build Build for production (client + server)\n agent-native start Start production server\n agent-native action <name> Run an action from actions/\n agent-native script <name> Run an action (deprecated alias for 'action')\n agent-native typecheck Run TypeScript type checking\n agent-native create [name] Scaffold a new agent-native workspace with a\n multi-select template picker. Use --standalone\n for a single-app scaffold.\n agent-native code Launch Agent-Native Code workspace. Type a task or\n use goals like /migrate and /audit.\n agent-native code serve Run the Agent-Native Code remote connector.\n agent-native mcp <cmd> Connect external coding agents over MCP.\n cmds: serve | install | uninstall | status |\n token (--client claude-code|claude-code-cli|\n codex|cowork)\n agent-native connect <url> Authenticate your coding agent to a DEPLOYED app.\n OAuth-capable clients (Claude Code) get a /mcp\n authenticate prompt; Codex / Cowork use the\n browser device-code flow. --all connects every\n first-party app; --token is the no-browser\n fallback. Usually run for you by 'skills add'.\n agent-native reconnect [url] Re-authenticate an existing MCP entry without\n reinstalling app skills/connectors.\n agent-native app-skill <cmd> Install, launch, or package app-backed skills.\n cmds: ensure | launch | pack\n agent-native skills add assets|design-exploration|visual-plan|visual-recap|context-xray\n Install the skill instructions, register the MCP\n connector, AND authenticate it in one step.\n --no-connect skips auth (run 'connect' later);\n non-interactive shells print the connect command.\n --with-github-action also writes the PR Visual\n Recap workflow into .github/workflows/.\n agent-native recap <cmd> PR visual recap setup and GitHub Action helpers.\n Run 'agent-native recap help' for subcommands.\n agent-native plan local <cmd> DB-free local plan helpers.\n cmds: init | check | preview\n agent-native migrate <source> Create an Agent-Native Code /migrate session, or use\n --emit for a portable own-agent dossier.\n agent-native add-app [name] Add one or more apps to the current workspace\n agent-native workspace-dev Start the multi-app workspace gateway\n agent-native deploy Build & deploy every app in the workspace to\n a single origin (your-agents.com/<app>/*)\n agent-native setup-agents Create symlinks for all agent tools\n agent-native info <pkg> Print info about an installed package:\n exports, source paths, and docs links.\n agent-native audit-agent-web Audit a public URL for agent-readable surfaces\n\nOptions:\n -h, --help Show this help message\n -v, --version Show version number\n --template <names> Comma-separated templates to pre-select\n (mail,calendar,analytics,...) — or\n github:user/repo for community templates\n --standalone Scaffold a single standalone app (no workspace)\n --emit [dir] With migrate, emit an own-agent dossier\n --describe <text> With migrate, describe URL/prose-only sources\n --preset <name> Workspace deploy preset:\n cloudflare_pages (default), netlify, or vercel\n --build-only Build workspace deploy artifacts without publishing\n --eager With workspace dev, start every app immediately\n --url <url> URL to audit with audit-agent-web\n\nFeedback: ${FEEDBACK_URL}\nBugs: ${BUGS_URL}`);\n break;\n\n default:\n if (command && !command.startsWith(\"-\")) {\n // A bare, single command-like token with no further args is almost\n // always a mistyped subcommand (e.g. `agent-native destory`). Silently\n // forwarding it to the coding agent would run an LLM with file-write\n // powers on a typo — a real footgun on a code-modifying tool. Refuse it\n // and point at the explicit forms. Intentional natural-language tasks\n // are still dispatched: a quoted phrase (`agent-native \"fix tests\"`,\n // which arrives as one argv token containing a space) or multi-word\n // input (`agent-native fix the tests`, which has trailing args).\n const looksLikeMistypedSubcommand =\n args.length === 0 && /^[a-z][a-z0-9-]*$/i.test(command);\n if (!looksLikeMistypedSubcommand) {\n import(\"./code.js\")\n .then((m) => m.runCode([command, ...args]))\n .catch(handleScaffoldImportError);\n break;\n }\n console.error(`Unknown command: ${command}`);\n console.error(\n `If you meant to start a coding session with this as the task, run:\\n` +\n ` agent-native code ${JSON.stringify(command)}\\n` +\n `or quote a natural-language task:\\n` +\n ` agent-native \"fix the failing tests\"`,\n );\n console.error('Run \"agent-native --help\" for usage.');\n console.error(`Bugs: ${BUGS_URL}`);\n process.exit(1);\n }\n console.error(`Unknown command: ${command}`);\n console.error('Run \"agent-native --help\" for usage.');\n console.error(`Bugs: ${BUGS_URL}`);\n process.exit(1);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/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AAQ,EAAE,CAAC,CAAC;YACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;QAC7C,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACtD,OAAO,CAAC,KAAK,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { execSync, spawn } from \"child_process\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { fileURLToPath } from \"url\";\nimport * as Sentry from \"@sentry/node\";\n\n// Resolve version once at module scope — used by both --version and --help\nlet _version = \"unknown\";\ntry {\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n // dist/cli/index.js → ../../package.json\n const pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, \"../../package.json\"), \"utf-8\"),\n );\n _version = pkg.version;\n} catch {}\n\n// Fail fast on unsupported Node versions. `engines.node: \">=22\"` is only\n// advisory — npx/pnpm merely warn — so without this an older Node (18/20)\n// first fails deep inside a scaffold dynamic import with a cryptic\n// ERR_MODULE / syntax error that `handleScaffoldImportError` misreports as a\n// corrupt npx cache. A clear up-front message saves that whole detour.\nconst REQUIRED_NODE_MAJOR = 22;\nconst _nodeMajor = Number(process.versions.node.split(\".\")[0]);\nif (Number.isFinite(_nodeMajor) && _nodeMajor < REQUIRED_NODE_MAJOR) {\n console.error(\n `agent-native requires Node.js ${REQUIRED_NODE_MAJOR} or newer, but you're on Node ${process.versions.node}.\\n` +\n `Upgrade Node (https://nodejs.org) and re-run. With nvm: \\`nvm install ${REQUIRED_NODE_MAJOR}\\`.`,\n );\n process.exit(1);\n}\n\n/**\n * Build a redacted \"command\" tag from process.argv. Strips the value that\n * follows any --token / --key / --secret / --password / --api-key flag so\n * we don't ship developer secrets to Sentry alongside the crash.\n *\n * Supports both `--token foo` (separate argv item) and `--token=foo`\n * (combined argv item) forms.\n */\nconst SECRET_FLAG_RE = /^--?(token|key|secret|password|api[_-]?key)$/i;\nconst SECRET_FLAG_EQ_RE =\n /^(--?(token|key|secret|password|api[_-]?key))=(.*)$/i;\nfunction buildRedactedCommandTag(argv: string[]): string {\n const out: string[] = [];\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i];\n if (SECRET_FLAG_RE.test(a)) {\n out.push(a);\n // Consume the next argv item as the secret value\n if (i + 1 < argv.length) {\n out.push(\"<redacted>\");\n i++;\n }\n continue;\n }\n const m = a.match(SECRET_FLAG_EQ_RE);\n if (m) {\n out.push(`${m[1]}=<redacted>`);\n continue;\n }\n out.push(a);\n }\n return out.join(\" \");\n}\n\nSentry.init({\n dsn: \"https://0d384e9eff2f6542af468b92769f2f5b@o117565.ingest.us.sentry.io/4511270386466816\",\n release: `agent-native-cli@${_version}`,\n // Sentry's Http integration wraps outgoing fetch in a way that breaks the\n // hosted Plan MCP route negotiation used by recap CI smoke checks.\n integrations: (integrations) =>\n integrations.filter((integration) => integration.name !== \"Http\"),\n // sendDefaultPii MUST stay false — the CLI runs in third-party developer\n // environments and we never want to ship request headers, IPs, cookies,\n // or process env contents to Sentry without explicit consent.\n sendDefaultPii: false,\n beforeSend(event) {\n // Drop expected user-input rejections (validateRepoName, etc.) so they\n // don't pollute Sentry with non-bug noise.\n const exceptionType = event.exception?.values?.[0]?.type;\n if (\n exceptionType === \"ValidationError\" ||\n event.tags?.handled === \"validation\"\n ) {\n return null;\n }\n\n // Defense in depth: strip any sensitive fields that may have been\n // attached to the event despite sendDefaultPii: false (e.g. integrations\n // that capture request metadata).\n if (event.request) {\n if (event.request.headers) {\n const headers = event.request.headers as Record<string, string>;\n for (const k of Object.keys(headers)) {\n const lk = k.toLowerCase();\n if (\n lk === \"cookie\" ||\n lk === \"authorization\" ||\n lk === \"set-cookie\" ||\n lk === \"proxy-authorization\"\n ) {\n delete headers[k];\n }\n }\n }\n // Cookies are also exposed via event.request.cookies as a separate field\n delete (event.request as Record<string, unknown>).cookies;\n }\n // Keep user info that was explicitly set via Sentry.setUser (id/email)\n // so we can attribute crashes back to the operator. Always strip\n // ip_address — the CLI runs on third-party machines and the IP is auto-\n // collected without consent. If only auto-collected fields remain,\n // drop the user object entirely.\n if (event.user) {\n const user = event.user as Record<string, unknown>;\n delete user.ip_address;\n const hasIdentity =\n typeof user.id === \"string\" ||\n typeof user.email === \"string\" ||\n typeof user.username === \"string\";\n if (!hasIdentity) {\n delete event.user;\n }\n }\n // Sentry's contexts can carry process.env snapshots — strip env-shaped\n // contexts so we don't leak deployment secrets.\n if (event.contexts && typeof event.contexts === \"object\") {\n delete (event.contexts as Record<string, unknown>).runtime_env;\n }\n\n event.tags = {\n ...event.tags,\n // Build the command tag from process.argv with secrets redacted so\n // `agent-native ... --token foo` doesn't leak `foo` to Sentry.\n command: buildRedactedCommandTag(process.argv.slice(2)),\n subcommand: process.argv[2] ?? \"none\",\n nodeVersion: process.version,\n platform: process.platform,\n };\n return event;\n },\n});\n\n// Identify the operator so future CLI errors carry spaceId / builderUserId\n// that we can map back to a real Builder user. The CLI doesn't have a real\n// email today — only the env-managed identifiers from the workspace's .env.\n{\n const builderUserId = process.env.BUILDER_USER_ID;\n const builderPublicKey = process.env.BUILDER_PUBLIC_KEY;\n if (builderUserId) {\n Sentry.setUser({ id: builderUserId });\n Sentry.setTag(\"builderUserId\", builderUserId);\n }\n if (builderPublicKey) {\n Sentry.setTag(\"spaceId\", builderPublicKey);\n }\n}\n\nconst FEEDBACK_URL =\n \"https://forms.agent-native.com/f/agent-native-feedback/_16ewV?source=cli\";\nconst BUGS_URL = \"https://github.com/BuilderIO/agent-native/issues\";\n\nconst command = process.argv[2];\n// Filter out bare \"--\" separators that pnpm inserts between its args and script args\nconst args = process.argv.slice(3).filter((a) => a !== \"--\");\n\nfunction parseScaffoldArgs(argv: string[]): {\n name?: string;\n template?: string;\n standalone: boolean;\n} {\n let name: string | undefined;\n let template: string | undefined;\n let standalone = false;\n\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--template\" && argv[i + 1]) {\n template = argv[++i];\n } else if (arg.startsWith(\"--template=\")) {\n template = arg.slice(\"--template=\".length);\n } else if (arg === \"--standalone\") {\n standalone = true;\n } else if (!arg.startsWith(\"-\") && !name) {\n name = arg;\n }\n }\n\n return { name, template, standalone };\n}\n\n// Track CLI usage (best-effort, non-blocking)\nfunction trackCli(event: string, props?: Record<string, unknown>): void {\n try {\n import(\"../tracking/registry.js\").then((m) => {\n m.track(event, { command, ...props });\n });\n import(\"../tracking/providers.js\").then((m) =>\n m.registerBuiltinProviders(),\n );\n } catch {}\n}\n\n// Global error handler — show feedback link on unhandled crashes\nprocess.on(\"uncaughtException\", (err) => {\n console.error(`\\n Unexpected error: ${err.message}\\n`);\n console.error(` Report this bug: ${BUGS_URL}`);\n console.error(` Send feedback: ${FEEDBACK_URL}\\n`);\n trackCli(\"cli.crash\", { error: err.message });\n Sentry.captureException(err);\n Sentry.flush(2000).finally(() => process.exit(1));\n});\n\nprocess.on(\"unhandledRejection\", (reason: any) => {\n console.error(`\\n Unhandled error: ${reason?.message ?? reason}\\n`);\n console.error(` Report this bug: ${BUGS_URL}`);\n console.error(` Send feedback: ${FEEDBACK_URL}\\n`);\n trackCli(\"cli.crash\", { error: reason?.message ?? String(reason) });\n Sentry.captureException(reason);\n Sentry.flush(2000).finally(() => process.exit(1));\n});\n\n// Surface a self-heal hint when an interrupted `npx @agent-native/core@latest ...`\n// leaves a half-extracted package in the npx cache and a follow-up run fails\n// to load one of our own sub-modules.\nfunction handleScaffoldImportError(err: any): never {\n const msg = err?.message ?? String(err);\n const looksLikeCorruptCache =\n err?.code === \"ERR_MODULE_NOT_FOUND\" ||\n err?.code === \"MODULE_NOT_FOUND\" ||\n err?.code === \"ENOENT\" ||\n /Cannot find module|tarball|integrity|EINTEGRITY|corrupt|truncated/i.test(\n msg,\n );\n if (looksLikeCorruptCache) {\n console.error(\n `\\n Failed to load the scaffolder. This usually means an earlier\\n \\`npx\\` run was interrupted and left a corrupt cache.\\n\\n Clear the npx cache and try again:\\n rm -rf ~/.npm/_npx\\n npx @agent-native/core@latest create\\n\\n Original error: ${msg}\\n`,\n );\n } else {\n console.error(`\\n Failed to load the scaffolder: ${msg}\\n`);\n }\n trackCli(\"cli.scaffold.import_error\", { error: msg });\n Sentry.captureException(err);\n Sentry.flush(2000).finally(() => process.exit(1));\n throw err;\n}\n\nfunction findViteBin(): string {\n // Look for vite in node_modules/.bin\n const localVite = path.resolve(\"node_modules/.bin/vite\");\n if (fs.existsSync(localVite)) return localVite;\n return \"vite\"; // fallback to PATH\n}\n\nfunction findTsxBin(): string {\n const localTsx = path.resolve(\"node_modules/.bin/tsx\");\n if (fs.existsSync(localTsx)) return localTsx;\n return \"tsx\";\n}\n\nfunction findReactRouterBin(): string {\n const localBin = path.resolve(\"node_modules/.bin/react-router\");\n if (fs.existsSync(localBin)) return localBin;\n return \"react-router\";\n}\n\n/** Check if the project uses React Router framework mode (has react-router.config.ts) */\nfunction isReactRouterFramework(): boolean {\n return (\n fs.existsSync(path.resolve(\"react-router.config.ts\")) ||\n fs.existsSync(path.resolve(\"react-router.config.js\"))\n );\n}\n\nfunction isWorkspaceRoot(): boolean {\n const pkgPath = path.resolve(\"package.json\");\n if (!fs.existsSync(pkgPath)) return false;\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n return (\n typeof pkg?.[\"agent-native\"]?.workspaceCore === \"string\" &&\n fs.existsSync(path.resolve(\"apps\"))\n );\n } catch {\n return false;\n }\n}\n\nfunction run(\n cmd: string,\n cmdArgs: string[],\n opts?: { stdio?: \"inherit\" | \"pipe\" },\n) {\n const child = spawn(cmd, cmdArgs, {\n stdio: opts?.stdio ?? \"inherit\",\n shell: process.platform === \"win32\",\n env: process.env,\n });\n child.on(\"exit\", (code) => process.exit(code ?? 0));\n // Forward signals to child so Cmd+C doesn't leave zombie processes holding ports\n for (const sig of [\"SIGINT\", \"SIGTERM\", \"SIGHUP\"] as const) {\n process.on(sig, () => {\n child.kill(sig);\n setTimeout(() => {\n try {\n child.kill(\"SIGKILL\");\n } catch {}\n process.exit(1);\n }, 5000).unref();\n });\n }\n return child;\n}\n\n/**\n * Walk up from `cwd` and try to figure out which template / app this build\n * is running for. We look for two patterns:\n *\n * - `templates/<name>/...` — building inside the framework monorepo\n * - `apps/<name>/...` — building inside a scaffolded workspace\n *\n * Both, neither, or one may match. Used purely as Sentry tags so we can\n * filter the noisy \"Command failed: react-router build\" issues by template.\n */\nfunction inferBuildContext(cwd: string): {\n template?: string;\n app?: string;\n} {\n const segs = cwd.split(path.sep);\n let template: string | undefined;\n let app: string | undefined;\n for (let i = 0; i < segs.length - 1; i++) {\n if (segs[i] === \"templates\" && segs[i + 1] && !segs[i + 1].startsWith(\".\"))\n template = segs[i + 1];\n if (segs[i] === \"apps\" && segs[i + 1] && !segs[i + 1].startsWith(\".\"))\n app = segs[i + 1];\n }\n return { template, app };\n}\n\n/**\n * Run a build subcommand, streaming its stdout/stderr to the user's terminal\n * in real time while also capturing bounded tails for Sentry. On non-zero\n * exit we report a structured event (template, app, exit code, stderr/stdout\n * tails) and exit with the child's code. We deliberately do NOT throw — the\n * global uncaughtException handler would re-capture with a generic\n * \"Error: Command failed\" title, collapsing every template's failure into\n * one issue (which is exactly what we're trying to fix here).\n */\nfunction runBuildStep(\n cmd: string,\n cmdArgs: string[],\n opts: { label: string; env?: NodeJS.ProcessEnv },\n): Promise<void> {\n return new Promise<void>((resolve) => {\n const STDERR_TAIL_BYTES = 8000;\n const STDOUT_TAIL_BYTES = 4000;\n let stderrBuf = \"\";\n let stdoutBuf = \"\";\n\n const child = spawn(cmd, cmdArgs, {\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n shell: process.platform === \"win32\",\n env: opts.env ?? process.env,\n });\n\n child.stdout?.on(\"data\", (chunk: Buffer) => {\n process.stdout.write(chunk);\n const next = stdoutBuf + chunk.toString(\"utf-8\");\n stdoutBuf =\n next.length > STDOUT_TAIL_BYTES ? next.slice(-STDOUT_TAIL_BYTES) : next;\n });\n child.stderr?.on(\"data\", (chunk: Buffer) => {\n process.stderr.write(chunk);\n const next = stderrBuf + chunk.toString(\"utf-8\");\n stderrBuf =\n next.length > STDERR_TAIL_BYTES ? next.slice(-STDERR_TAIL_BYTES) : next;\n });\n\n child.on(\"error\", (err) => {\n // Failure to spawn (ENOENT, etc.).\n const cwd = process.cwd();\n const { template, app } = inferBuildContext(cwd);\n Sentry.captureException(err, {\n tags: {\n buildStep: opts.label,\n ...(template ? { template } : {}),\n ...(app ? { app } : {}),\n },\n extra: {\n command: `${cmd} ${cmdArgs.join(\" \")}`,\n cwd,\n stage: \"spawn\",\n },\n });\n Sentry.flush(2000).finally(() => process.exit(1));\n });\n\n child.on(\"exit\", (code, signal) => {\n const exitCode = code ?? (signal ? 1 : 0);\n if (exitCode === 0) {\n resolve();\n return;\n }\n const cwd = process.cwd();\n const { template, app } = inferBuildContext(cwd);\n const childCommand = `${cmd} ${cmdArgs.join(\" \")}`;\n const err = new Error(\n `Build step \"${opts.label}\" failed with exit code ${exitCode}` +\n (template ? ` (template=${template})` : \"\") +\n (app ? ` (app=${app})` : \"\"),\n );\n Sentry.captureException(err, {\n tags: {\n buildStep: opts.label,\n ...(template ? { template } : {}),\n ...(app ? { app } : {}),\n },\n extra: {\n command: childCommand,\n cwd,\n exitCode,\n signal: signal ?? null,\n stderrTail: stderrBuf,\n stdoutTail: stdoutBuf,\n },\n });\n // Don't throw — see comment on runBuildStep above.\n Sentry.flush(2000).finally(() => process.exit(exitCode));\n });\n });\n}\n\ntrackCli(\"cli.run\");\n\nswitch (command) {\n case \"dev\": {\n if (isWorkspaceRoot()) {\n import(\"./workspace-dev.js\")\n .then((m) => m.runWorkspaceDev({ args }))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n const vite = findViteBin();\n run(vite, args);\n break;\n }\n\n case \"workspace-dev\": {\n import(\"./workspace-dev.js\")\n .then((m) => m.runWorkspaceDev({ args }))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"build\": {\n // React Router framework mode uses `react-router build` which\n // internally runs `vite build` with proper environment orchestration.\n // Legacy SPA mode uses `vite build` directly.\n //\n // Each step uses runBuildStep so that on failure we get a Sentry event\n // tagged with template/app and including stderr/stdout tails. If the\n // child exits non-zero, runBuildStep calls process.exit itself; the\n // continuation only runs on success.\n (async () => {\n if (isReactRouterFramework()) {\n const rr = findReactRouterBin();\n console.log(\"Building (React Router framework mode)...\");\n await runBuildStep(rr, [\"build\"], { label: \"react-router-build\" });\n } else {\n const vite = findViteBin();\n console.log(\"Building...\");\n await runBuildStep(vite, [\"build\"], { label: \"vite-build\" });\n }\n\n // Post-build: framework-mode apps also need a Nitro server bundle for\n // `agent-native start` and for serverless presets.\n if (isReactRouterFramework()) {\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n const deployBuild = path.resolve(__dirname, \"../deploy/build.js\");\n if (fs.existsSync(deployBuild)) {\n await runBuildStep(\"node\", [deployBuild], {\n label: \"deploy-build\",\n env: process.env,\n });\n } else {\n console.warn(\n `[build] Deploy build script not found at ${deployBuild}. Skipping post-build step.`,\n );\n }\n }\n\n console.log(\"\\nBuild complete.\");\n })().catch((err) => {\n // runBuildStep handles its own failures and exits, so reaching here\n // implies a programming error in the orchestration above. Capture\n // and exit so the global unhandledRejection handler doesn't double-\n // report with a generic title.\n Sentry.captureException(err);\n Sentry.flush(2000).finally(() => process.exit(1));\n });\n break;\n }\n\n case \"start\": {\n // Like `next start` — runs Nitro production server\n const serverEntry = path.resolve(\".output/server/index.mjs\");\n if (!fs.existsSync(serverEntry)) {\n console.error(\n 'No production build found. Run \"agent-native build\" first.',\n );\n process.exit(1);\n }\n run(\"node\", [serverEntry, ...args]);\n break;\n }\n\n case \"action\": {\n // Run an action from actions/ (or scripts/ for backwards compat)\n const actionName = args[0];\n if (!actionName) {\n console.error(\"Usage: agent-native action <name> [--args]\");\n process.exit(1);\n }\n const tsxAction = findTsxBin();\n // Try actions/run.ts first, fall back to scripts/run.ts\n const actionsRun = path.resolve(\"actions/run.ts\");\n const scriptsRun = path.resolve(\"scripts/run.ts\");\n const runFile = fs.existsSync(actionsRun) ? actionsRun : scriptsRun;\n run(tsxAction, [runFile, ...args]);\n break;\n }\n\n case \"script\": {\n // @deprecated — use `agent-native action` instead\n const scriptName = args[0];\n if (!scriptName) {\n console.error(\"Usage: agent-native script <name> [--args]\");\n process.exit(1);\n }\n const tsx = findTsxBin();\n // Try actions/run.ts first, fall back to scripts/run.ts\n const actionsRunScript = path.resolve(\"actions/run.ts\");\n const scriptsRunScript = path.resolve(\"scripts/run.ts\");\n const runFileScript = fs.existsSync(actionsRunScript)\n ? actionsRunScript\n : scriptsRunScript;\n run(tsx, [runFileScript, ...args]);\n break;\n }\n\n case \"typecheck\": {\n // Run TypeScript type checking\n // React Router framework mode generates route types first\n if (isReactRouterFramework()) {\n const rr = findReactRouterBin();\n try {\n execSync(`${rr} typegen`, { stdio: \"inherit\" });\n } catch {\n // typegen may fail if routes aren't set up yet — continue to tsc\n }\n }\n const tsc = path.resolve(\"node_modules/.bin/tsc\");\n const tscBin = fs.existsSync(tsc) ? tsc : \"tsc\";\n run(tscBin, [\"--noEmit\", ...args]);\n break;\n }\n\n case \"create\": {\n // Defaults to creating a workspace with a multi-select template picker.\n // Use --standalone for the old single-app flow.\n // --template foo,bar Pre-select multiple templates in the picker\n // --standalone Scaffold a single standalone app\n const parsed = parseScaffoldArgs(args);\n import(\"./create.js\")\n .then((m) =>\n m.createApp(parsed.name, {\n template: parsed.template,\n standalone: parsed.standalone,\n }),\n )\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"migrate\": {\n import(\"./migrate.js\")\n .then((m) => m.runMigrate(args))\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"code\": {\n import(\"./code.js\")\n .then((m) => m.runCode(args))\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"mcp\": {\n // Connect external coding agents (Claude Code, Cowork, Codex) over MCP.\n // `mcp serve` runs the stdio transport; install/uninstall/status/token\n // manage client configs + the local token.\n import(\"./mcp.js\")\n .then((m) => m.runMcp(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"connect\": {\n // Wire your local coding agent to a DEPLOYED agent-native app via a\n // browser device-code flow (no token copying). `--all` connects every\n // first-party hosted app; `--token` is the no-browser fallback.\n import(\"./connect.js\")\n .then((m) => m.runConnect(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"reconnect\":\n case \"reauth\": {\n // Refresh an existing remote MCP auth/config entry without reinstalling\n // app skills or running the broader connector setup path.\n import(\"./connect.js\")\n .then((m) => m.runConnect([\"reconnect\", ...args]))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"app-skill\": {\n // Package or install an agent-native app as a skill-backed MCP/app bundle.\n import(\"./app-skill.js\")\n .then((m) => m.runAppSkill(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"skills\": {\n // Friendly skill install surface. Wraps open skills installation plus MCP.\n import(\"./skills.js\")\n .then((m) => m.runSkills(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"recap\": {\n // PR visual recap helpers used by the GitHub Action. Promoted to the CLI\n // so an installed repo's workflow can call `agent-native recap …` instead\n // of copying helper scripts. Run `agent-native recap help` for the full\n // subcommand list.\n import(\"./recap.js\")\n .then((m) => m.runRecap(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"plan\": {\n // DB-free local plan helpers. These never call the Plan app action surface;\n // they only read/write MDX folders and static preview HTML.\n import(\"./plan-local.js\")\n .then((m) => m.runPlan(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"create-workspace\": {\n // Deprecated alias for `create` (since workspace is now the default).\n const parsed = parseScaffoldArgs(args);\n import(\"./create-workspace.js\")\n .then((m) =>\n m.createWorkspace({ name: parsed.name, template: parsed.template }),\n )\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"add-app\": {\n // Add one or more apps to the current workspace.\n const parsed = parseScaffoldArgs(args);\n import(\"./create.js\")\n .then((m) =>\n m.addAppToWorkspace(parsed.name, { template: parsed.template }),\n )\n .catch(handleScaffoldImportError);\n break;\n }\n\n case \"deploy\": {\n // Build and deploy the entire workspace as one unit. Each app is served\n // at /<app>/* under the same origin.\n import(\"../deploy/workspace-deploy.js\")\n .then((m) => m.runWorkspaceDeploy({ args }))\n .catch((err) => {\n console.error(\"Deploy failed:\", err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"setup-agents\": {\n import(\"./setup-agents.js\").then((m) => m.runSetupAgents());\n break;\n }\n\n case \"info\": {\n // Print read-only info about an installable package (e.g. @agent-native/scheduling).\n // Lists subpath exports, source paths in node_modules, and docs pointers.\n import(\"./info.js\").then((m) => m.runInfo(args[0]));\n break;\n }\n\n case \"audit-agent-web\": {\n import(\"./audit-agent-web.js\")\n .then((m) => m.runAuditAgentWeb(args))\n .catch((err) => {\n console.error(err?.message ?? err);\n process.exit(1);\n });\n break;\n }\n\n case \"--version\":\n case \"-v\": {\n console.log(_version);\n break;\n }\n\n case undefined:\n import(\"./code.js\")\n .then((m) => m.runCode([]))\n .catch(handleScaffoldImportError);\n break;\n\n case \"--help\":\n case \"-h\":\n console.log(`agent-native v${_version}\n\nUsage:\n agent-native Launch Agent-Native Code workspace\n agent-native \"fix tests\" Start an Agent-Native Code coding session\n agent-native dev Start development server\n (or the workspace gateway at a workspace root)\n agent-native build Build for production (client + server)\n agent-native start Start production server\n agent-native action <name> Run an action from actions/\n agent-native script <name> Run an action (deprecated alias for 'action')\n agent-native typecheck Run TypeScript type checking\n agent-native create [name] Scaffold a new agent-native workspace with a\n multi-select template picker. Use --standalone\n for a single-app scaffold.\n agent-native code Launch Agent-Native Code workspace. Type a task or\n use goals like /migrate and /audit.\n agent-native code serve Run the Agent-Native Code remote connector.\n agent-native mcp <cmd> Connect external coding agents over MCP.\n cmds: serve | install | uninstall | status |\n token (--client claude-code|claude-code-cli|\n codex|cowork)\n agent-native connect <url> Authenticate your coding agent to a DEPLOYED app.\n OAuth-capable clients (Claude Code) get a /mcp\n authenticate prompt; Codex / Cowork use the\n browser device-code flow. --all connects every\n first-party app; --token is the no-browser\n fallback. Usually run for you by 'skills add'.\n agent-native reconnect [url] Re-authenticate an existing MCP entry without\n reinstalling app skills/connectors.\n agent-native app-skill <cmd> Install, launch, or package app-backed skills.\n cmds: ensure | launch | pack\n agent-native skills add assets|design-exploration|visual-plan|visual-recap|context-xray\n Install the skill instructions, register the MCP\n connector, AND authenticate it in one step.\n --no-connect skips auth (run 'connect' later);\n non-interactive shells print the connect command.\n --with-github-action also writes the PR Visual\n Recap workflow into .github/workflows/.\n agent-native recap <cmd> PR visual recap setup and GitHub Action helpers.\n Run 'agent-native recap help' for subcommands.\n agent-native plan local <cmd> DB-free local plan helpers.\n cmds: init | check | preview\n agent-native migrate <source> Create an Agent-Native Code /migrate session, or use\n --emit for a portable own-agent dossier.\n agent-native add-app [name] Add one or more apps to the current workspace\n agent-native workspace-dev Start the multi-app workspace gateway\n agent-native deploy Build & deploy every app in the workspace to\n a single origin (your-agents.com/<app>/*)\n agent-native setup-agents Create symlinks for all agent tools\n agent-native info <pkg> Print info about an installed package:\n exports, source paths, and docs links.\n agent-native audit-agent-web Audit a public URL for agent-readable surfaces\n\nOptions:\n -h, --help Show this help message\n -v, --version Show version number\n --template <names> Comma-separated templates to pre-select\n (mail,calendar,analytics,...) — or\n github:user/repo for community templates\n --standalone Scaffold a single standalone app (no workspace)\n --emit [dir] With migrate, emit an own-agent dossier\n --describe <text> With migrate, describe URL/prose-only sources\n --preset <name> Workspace deploy preset:\n cloudflare_pages (default), netlify, or vercel\n --build-only Build workspace deploy artifacts without publishing\n --eager With workspace dev, start every app immediately\n --url <url> URL to audit with audit-agent-web\n\nFeedback: ${FEEDBACK_URL}\nBugs: ${BUGS_URL}`);\n break;\n\n default:\n if (command && !command.startsWith(\"-\")) {\n // A bare, single command-like token with no further args is almost\n // always a mistyped subcommand (e.g. `agent-native destory`). Silently\n // forwarding it to the coding agent would run an LLM with file-write\n // powers on a typo — a real footgun on a code-modifying tool. Refuse it\n // and point at the explicit forms. Intentional natural-language tasks\n // are still dispatched: a quoted phrase (`agent-native \"fix tests\"`,\n // which arrives as one argv token containing a space) or multi-word\n // input (`agent-native fix the tests`, which has trailing args).\n const looksLikeMistypedSubcommand =\n args.length === 0 && /^[a-z][a-z0-9-]*$/i.test(command);\n if (!looksLikeMistypedSubcommand) {\n import(\"./code.js\")\n .then((m) => m.runCode([command, ...args]))\n .catch(handleScaffoldImportError);\n break;\n }\n console.error(`Unknown command: ${command}`);\n console.error(\n `If you meant to start a coding session with this as the task, run:\\n` +\n ` agent-native code ${JSON.stringify(command)}\\n` +\n `or quote a natural-language task:\\n` +\n ` agent-native \"fix the failing tests\"`,\n );\n console.error('Run \"agent-native --help\" for usage.');\n console.error(`Bugs: ${BUGS_URL}`);\n process.exit(1);\n }\n console.error(`Unknown command: ${command}`);\n console.error('Run \"agent-native --help\" for usage.');\n console.error(`Bugs: ${BUGS_URL}`);\n process.exit(1);\n}\n"]}
@@ -7,5 +7,5 @@
7
7
  * recap.spec.ts fails if these drift. Regenerate from the YAML with the snippet
8
8
  * in recap.spec.ts.
9
9
  */
10
- export declare const PR_VISUAL_RECAP_WORKFLOW_YML = "name: PR Visual Recap\n\n# Visual code review: a coding agent runs the repo's visual-recap skill over the\n# PR diff, publishes a plan, and upserts one sticky comment with a screenshot.\n# Plain `pull_request` (NOT `pull_request_target`) so fork code never sees secrets.\n\non:\n pull_request:\n types: [opened, synchronize, reopened, ready_for_review]\n\npermissions:\n contents: read\n\nconcurrency:\n group: pr-visual-recap-${{ github.event.pull_request.number }}\n cancel-in-progress: true\n\nenv:\n VISUAL_RECAP_AGENT: ${{ vars.VISUAL_RECAP_AGENT || 'claude' }}\n VISUAL_RECAP_SKILL_SOURCE: ${{ vars.VISUAL_RECAP_SKILL_SOURCE || 'auto' }}\n\njobs:\n gate:\n name: Gate\n runs-on: ubuntu-latest\n timeout-minutes: 10\n permissions:\n contents: read\n issues: write\n pull-requests: write\n outputs:\n run: ${{ steps.decide.outputs.run }}\n agent: ${{ steps.decide.outputs.agent }}\n steps:\n - id: decide\n uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0\n env:\n # Presence-only signals \u2014 never expose secret VALUES to the gate.\n HAS_PLAN: ${{ secrets.PLAN_RECAP_TOKEN != '' }}\n HAS_ANTHROPIC: ${{ secrets.ANTHROPIC_API_KEY != '' }}\n HAS_OPENAI: ${{ secrets.OPENAI_API_KEY != '' }}\n AGENT: ${{ env.VISUAL_RECAP_AGENT }}\n VISUAL_RECAP_MODEL: ${{ vars.VISUAL_RECAP_MODEL }}\n HEAD_SHA: ${{ github.event.pull_request.head.sha }}\n with:\n script: |\n const pr = context.payload.pull_request;\n const reasons = [];\n\n if (!pr) reasons.push('no pull_request payload');\n if (pr && pr.draft) reasons.push('draft PR');\n\n // Fork PRs run with no secrets, so publishing would fail anyway \u2014 skip.\n const headRepo = pr && pr.head && pr.head.repo && pr.head.repo.full_name;\n if (pr && headRepo && headRepo !== process.env.GITHUB_REPOSITORY) {\n reasons.push(`fork PR (${headRepo})`);\n }\n\n const login = (pr && pr.user && pr.user.login || '').toLowerCase();\n const botAuthors = ['dependabot[bot]', 'dependabot', 'renovate[bot]', 'renovate'];\n if (botAuthors.includes(login)) reasons.push(`bot author (${login})`);\n if (pr && pr.user && pr.user.type === 'Bot') reasons.push('bot author (type=Bot)');\n\n if (process.env.HAS_PLAN !== 'true') reasons.push('PLAN_RECAP_TOKEN not configured');\n\n // Normalize + validate the agent so a mis-cased value can't pass the\n // gate and then match neither agent step below.\n const agent = (process.env.AGENT || 'claude').toLowerCase();\n if (agent !== 'claude' && agent !== 'codex') {\n reasons.push(`unsupported VISUAL_RECAP_AGENT \"${process.env.AGENT}\" (expected \"claude\" or \"codex\")`);\n } else if (agent === 'codex') {\n if (process.env.HAS_OPENAI !== 'true') reasons.push('OPENAI_API_KEY not configured (codex backend)');\n } else {\n if (process.env.HAS_ANTHROPIC !== 'true') reasons.push('ANTHROPIC_API_KEY not configured (claude backend)');\n }\n\n // Validate the model before it reaches the agent CLI.\n const model = process.env.VISUAL_RECAP_MODEL || '';\n if (model && !/^[a-zA-Z0-9._-]{1,80}$/.test(model)) {\n reasons.push(`invalid VISUAL_RECAP_MODEL value (must match [a-zA-Z0-9._-]{1,80})`);\n }\n\n // Self-modifying guard, evaluated in the trusted gate (runs NO\n // PR-checked-out code): skip the ENTIRE job if the PR touches the\n // workflow, skill, or any agent config the runner loads, so a PR\n // can't rewrite what runs and exfiltrate secrets.\n if (pr) {\n try {\n const files = await github.paginate(github.rest.pulls.listFiles, {\n owner: context.repo.owner,\n repo: context.repo.repo,\n pull_number: pr.number,\n per_page: 100,\n });\n const isSensitive = (p) =>\n p === '.github/workflows/pr-visual-recap.yml' ||\n /(^|\\/)skills\\/visual-(recap|plan|plans)\\//.test(p) ||\n /(^|\\/)\\.claude\\//.test(p) ||\n /(^|\\/)CLAUDE\\.md$/.test(p) ||\n /(^|\\/)AGENTS\\.md$/.test(p) ||\n /(^|\\/)\\.mcp\\.json$/.test(p);\n const hits = files.map((f) => f.filename).filter(isSensitive);\n if (hits.length) {\n reasons.push(`PR modifies recap-control files (${hits.slice(0, 3).join(', ')}${hits.length > 3 ? ', \u2026' : ''}) \u2014 skipping so untrusted PR code never runs with secrets`);\n }\n } catch (e) {\n // Fail closed: if the file list can't be read, skip.\n reasons.push(`could not list PR files for the self-modifying guard (${e.message}); skipping to be safe`);\n }\n }\n\n const run = reasons.length === 0;\n core.setOutput('run', run ? 'true' : 'false');\n core.setOutput('agent', agent);\n core.info(run ? `Visual recap will run (${agent}).` : `Visual recap skipped: ${reasons.join('; ')}`);\n\n // When skipping, refresh an EXISTING sticky recap comment with a\n // short skip line so it does not silently go stale. Never create a\n // new comment (no spam for repos where the recap has never run).\n if (!run && pr) {\n try {\n const MARKER = '<!-- pr-visual-recap -->';\n const { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: pr.number,\n per_page: 100,\n });\n const existing = comments.find(\n (c) => c.user && c.user.type === 'Bot' && c.body && c.body.includes(MARKER)\n );\n if (existing) {\n const headShort = (process.env.HEAD_SHA || '').slice(0, 7);\n const shaRef = headShort ? `\\`${headShort}\\`` : 'latest push';\n const primaryReason = reasons.filter(\n (r) => !r.startsWith('could not list PR files for the self-modifying guard')\n )[0] || reasons[0] || 'skipped';\n const skipLine = `_Recap skipped for ${shaRef}: ${primaryReason}._`;\n const withoutPrev = (existing.body || '')\n .split('\\n')\n .filter((l) => !/_Recap skipped for .+_$/.test(l.trim()))\n .join('\\n')\n .trimEnd();\n const updatedBody = `${withoutPrev}\\n\\n${skipLine}`;\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: existing.id,\n body: updatedBody,\n });\n }\n } catch (e) {\n core.warning(`Could not update recap skip comment: ${e.message}`);\n }\n }\n\n recap:\n name: Generate visual recap\n needs: gate\n if: needs.gate.outputs.run == 'true'\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n actions: write\n checks: write\n contents: read\n issues: write\n pull-requests: write\n env:\n PLAN_RECAP_APP_URL: ${{ secrets.PLAN_RECAP_APP_URL || 'https://plan.agent-native.com' }}\n PLAN_RECAP_TOKEN: ${{ secrets.PLAN_RECAP_TOKEN }}\n GH_TOKEN: ${{ github.token }}\n PR_NUMBER: ${{ github.event.pull_request.number }}\n HEAD_SHA: ${{ github.event.pull_request.head.sha }}\n VISUAL_RECAP_MODEL: ${{ vars.VISUAL_RECAP_MODEL }}\n VISUAL_RECAP_REASONING: ${{ vars.VISUAL_RECAP_REASONING }}\n VISUAL_RECAP_SKILL_SOURCE: ${{ vars.VISUAL_RECAP_SKILL_SOURCE || 'auto' }}\n steps:\n - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n with:\n fetch-depth: 0\n # This job runs an agent over untrusted PR diff; don't leave the token\n # in .git/config (it uses GH_TOKEN for gh API calls, never git push).\n persist-credentials: false\n\n # Dogfood trusted base-branch source inside this monorepo, else install the\n # published package once. Never execute PR-head recap CLI code.\n - name: Resolve recap CLI\n id: cli\n env:\n # Optional: pin the consumer CLI version (e.g. \"1.2.3\"). Defaults to\n # \"latest\" when unset. Set via repository variable RECAP_CLI_VERSION.\n RECAP_CLI_VERSION: ${{ vars.RECAP_CLI_VERSION || 'latest' }}\n run: |\n if [ \"$GITHUB_REPOSITORY\" = \"BuilderIO/agent-native\" ] && [ -f packages/core/src/cli/index.ts ]; then\n echo \"local=true\" >> \"$GITHUB_OUTPUT\"\n else\n echo \"local=false\" >> \"$GITHUB_OUTPUT\"\n fi\n\n - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n if: steps.cli.outputs.local == 'true'\n with:\n ref: ${{ github.event.pull_request.base.sha }}\n path: .recap-cli-source\n fetch-depth: 1\n persist-credentials: false\n\n - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8\n if: steps.cli.outputs.local == 'true'\n\n - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0\n with:\n node-version: \"22\"\n cache: ${{ steps.cli.outputs.local == 'true' && 'pnpm' || '' }}\n\n - name: Install trusted workspace recap CLI\n if: steps.cli.outputs.local == 'true'\n working-directory: .recap-cli-source\n run: |\n set -euo pipefail\n pnpm install --frozen-lockfile --ignore-scripts\n echo \"RECAP_CLI=$PWD/node_modules/.bin/tsx $PWD/packages/core/src/cli/index.ts\" >> \"$GITHUB_ENV\"\n\n - name: Install published recap CLI\n if: steps.cli.outputs.local != 'true'\n env:\n RECAP_CLI_VERSION: ${{ vars.RECAP_CLI_VERSION || 'latest' }}\n run: |\n set -euo pipefail\n VERSION=\"$RECAP_CLI_VERSION\"\n if [ \"$VERSION\" = \"latest\" ]; then\n VERSION=\"$(npm view @agent-native/core@latest version)\"\n fi\n for attempt in 1 2 3; do\n if npm install --prefix \"$RUNNER_TEMP/recap-cli\" --no-audit --no-fund \"@agent-native/core@$VERSION\"; then\n break\n fi\n if [ \"$attempt\" = \"3\" ]; then exit 1; fi\n sleep $((attempt * 10))\n done\n echo \"RECAP_CLI=$RUNNER_TEMP/recap-cli/node_modules/.bin/agent-native\" >> \"$GITHUB_ENV\"\n\n - name: Start visual recap check\n id: recap_check\n continue-on-error: true\n run: |\n set -uo pipefail\n $RECAP_CLI recap check start --sha \"$HEAD_SHA\" --workflow-url \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"\n\n - name: Collect bounded diff\n id: diff\n env:\n BASE_SHA: ${{ github.event.pull_request.base.sha }}\n run: |\n set -euo pipefail\n $RECAP_CLI recap collect-diff --base \"$BASE_SHA\" --head \"$HEAD_SHA\" --out recap.diff --stat recap.stat\n\n - name: Probe plan-app auth\n id: auth_probe\n if: steps.diff.outputs.tiny != 'true'\n continue-on-error: true\n run: |\n set -uo pipefail\n # Hit the plan app's action surface with the publish token. A 401 means\n # the token is expired/revoked; surface it in the sticky comment so the\n # repo owner knows to re-mint it instead of seeing a generic failure.\n HTTP_STATUS=$(node -e '\n const https = require(\"https\");\n const url = new URL(\"/_agent-native/actions/record-recap-usage\", process.env.PLAN_RECAP_APP_URL || \"https://plan.agent-native.com\");\n const req = https.request(url, { method: \"POST\", headers: { \"authorization\": \"Bearer \" + process.env.PLAN_RECAP_TOKEN, \"content-type\": \"application/json\" }, timeout: 8000 }, (res) => { process.stdout.write(String(res.statusCode)); req.destroy(); });\n req.on(\"error\", () => process.stdout.write(\"0\"));\n req.end(JSON.stringify({ planId: \"__probe__\" }));\n ' 2>/dev/null || echo \"0\")\n if [ \"$HTTP_STATUS\" = \"401\" ]; then\n echo \"auth_failed=true\" >> \"$GITHUB_OUTPUT\"\n else\n echo \"auth_failed=false\" >> \"$GITHUB_OUTPUT\"\n fi\n\n - name: Secret scan\n id: scan\n if: steps.diff.outputs.tiny != 'true'\n run: |\n set -uo pipefail\n # Fail CLOSED: a scanner error or invalid JSON suppresses the diff so a\n # credential-bearing diff is never handed to the agent / plan service.\n if ! SCAN_JSON=\"$($RECAP_CLI recap scan --diff recap.diff)\"; then\n SCAN_JSON='{\"suppressed\":true,\"reason\":\"secret scan failed to run; failing closed\"}'\n fi\n {\n echo 'json<<__RECAP_SCAN_EOF__'\n echo \"$SCAN_JSON\"\n echo '__RECAP_SCAN_EOF__'\n } >> \"$GITHUB_OUTPUT\"\n SUPPRESSED=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).suppressed?\"true\":\"false\")}catch{process.stdout.write(\"true\")}' \"$SCAN_JSON\")\n echo \"suppressed=$SUPPRESSED\" >> \"$GITHUB_OUTPUT\"\n\n - name: Read previous plan id\n id: prev\n continue-on-error: true\n run: |\n set -euo pipefail\n PLAN_ID=\"$($RECAP_CLI recap comment find-plan-id --repo \"$GITHUB_REPOSITORY\" --issue \"$PR_NUMBER\" --token \"$GH_TOKEN\")\"\n echo \"plan_id=$PLAN_ID\" >> \"$GITHUB_OUTPUT\"\n\n - name: Smoke-test Plan MCP tools\n id: mcp_smoke\n if: steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true'\n continue-on-error: true\n run: |\n set -uo pipefail\n $RECAP_CLI recap mcp-smoke --app-url \"$PLAN_RECAP_APP_URL\"\n\n - name: Build recap prompt\n id: prompt\n if: steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true' && steps.mcp_smoke.outputs.ok == 'true'\n env:\n # Pass step outputs via env, NOT ${{ }} interpolation into the run body:\n # the prev plan id is parsed from a PR comment and could inject shell.\n PREV_PLAN_ID: ${{ steps.prev.outputs.plan_id }}\n DIFF_HUGE: ${{ steps.diff.outputs.huge }}\n run: |\n set -euo pipefail\n ARGS=(--diff recap.diff --stat recap.stat --pr \"$PR_NUMBER\" --repo \"$GITHUB_REPOSITORY\" --head \"$HEAD_SHA\" --app-url \"$PLAN_RECAP_APP_URL\" --skill-source \"$VISUAL_RECAP_SKILL_SOURCE\" --out recap-prompt.md)\n if [ \"${DIFF_HUGE:-}\" = \"true\" ]; then ARGS+=(--huge); fi\n if [ -n \"${PREV_PLAN_ID:-}\" ]; then ARGS+=(--prev-plan-id \"$PREV_PLAN_ID\"); fi\n $RECAP_CLI recap build-prompt \"${ARGS[@]}\"\n\n - name: Run agent (Claude Code)\n id: claude\n if: needs.gate.outputs.agent == 'claude' && steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true' && steps.mcp_smoke.outputs.ok == 'true'\n continue-on-error: true\n env:\n ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}\n run: |\n set -uo pipefail\n MCP_CONFIG=\"$RUNNER_TEMP/plan-mcp.json\"\n $RECAP_CLI recap mcp-config --agent claude --app-url \"$PLAN_RECAP_APP_URL\" --out \"$MCP_CONFIG\"\n CLAUDE_ARGS=(-p \"$(cat recap-prompt.md)\" --mcp-config \"$MCP_CONFIG\" --allowedTools \"Read,Write,Bash(git diff:*),mcp__plan__get-plan-blocks,mcp__plan__create-visual-recap,mcp__plan__set-resource-visibility\" --permission-mode dontAsk --output-format json)\n if [ -n \"${VISUAL_RECAP_MODEL:-}\" ]; then CLAUDE_ARGS+=(--model \"$VISUAL_RECAP_MODEL\"); fi\n rm -f recap-url.txt claude-result.json claude-stderr.log\n run_claude() {\n set +e\n npx -y @anthropic-ai/claude-code@2 \"${CLAUDE_ARGS[@]}\" > claude-result.json 2> claude-stderr.log\n CLAUDE_STATUS=\"$?\"\n set -e\n echo \"$CLAUDE_STATUS\" > claude-exit-code.txt\n }\n run_claude\n if [ ! -s recap-url.txt ] && grep -Eiq 'schedule(d)? (a )?(wakeup|retry)|will retry|backoff|connector.*register|mcp.*(register|unreachable|not usable|zero tools|not callable)' claude-result.json claude-stderr.log 2>/dev/null; then\n echo \"Plan MCP registration appears delayed; retrying Claude once after 20s.\"\n sleep 20\n run_claude\n fi\n rm -f \"$MCP_CONFIG\" || true\n\n - name: Run agent (Codex)\n id: codex\n if: needs.gate.outputs.agent == 'codex' && steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true' && steps.mcp_smoke.outputs.ok == 'true'\n continue-on-error: true\n env:\n OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n run: |\n set -uo pipefail\n $RECAP_CLI recap mcp-config --agent codex --app-url \"$PLAN_RECAP_APP_URL\" --force\n # `codex login` writes ~/.codex/auth.json (the bare env var is dropped on\n # the gpt-5.5 wss transport); stdin keeps the key out of process args.\n printenv OPENAI_API_KEY | npx -y @openai/codex@0 login --with-api-key || true\n # The runner is itself an ephemeral sandbox; bypass Codex's own sandbox\n # (bubblewrap can't init here) and approval gate (cancels the MCP write).\n CODEX_ARGS=(exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check)\n if [ -n \"${VISUAL_RECAP_MODEL:-}\" ]; then CODEX_ARGS+=(--model \"$VISUAL_RECAP_MODEL\"); fi\n # Validate reasoning against the enum before embedding it in the TOML override.\n case \"${VISUAL_RECAP_REASONING:-}\" in\n none|minimal|low|medium|high|xhigh)\n CODEX_ARGS+=(-c \"model_reasoning_effort=\\\"$VISUAL_RECAP_REASONING\\\"\") ;;\n \"\") ;;\n *) echo \"Ignoring invalid VISUAL_RECAP_REASONING: $VISUAL_RECAP_REASONING\" ;;\n esac\n rm -f recap-url.txt codex-events.jsonl codex-stderr.log\n run_codex() {\n set +e\n npx -y @openai/codex@0 \"${CODEX_ARGS[@]}\" --json \"$(cat recap-prompt.md)\" 2> codex-stderr.log | tee codex-events.jsonl\n CODEX_STATUS=\"${PIPESTATUS[0]}\"\n set -e\n echo \"$CODEX_STATUS\" > codex-exit-code.txt\n }\n run_codex\n if [ ! -s recap-url.txt ] && grep -Eiq 'schedule(d)? (a )?(wakeup|retry)|will retry|backoff|connector.*register|mcp.*(register|unreachable|not usable|zero tools|not callable)' codex-events.jsonl codex-stderr.log 2>/dev/null; then\n echo \"Plan MCP registration appears delayed; retrying Codex once after 20s.\"\n sleep 20\n run_codex\n fi\n\n - name: Read plan URL\n id: url\n if: steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true'\n run: |\n set -uo pipefail\n PLAN_URL=\"\"\n URL_REASON=\"\"\n if [ -f recap-url.txt ]; then\n PLAN_URL=\"$(tr -d '\\r\\n' < recap-url.txt | tr -d ' ')\"\n else\n URL_REASON=\"recap-url.txt was not created by the agent\"\n fi\n # recap-url.txt is agent-written -> untrusted. Rebuild a canonical\n # recap URL from the trusted app base and a strictly validated plan id,\n # preserving path-prefixed self-hosted mounts.\n if [ -z \"$URL_REASON\" ]; then\n URL_RESULT=$(PLAN_URL=\"$PLAN_URL\" node <<'NODE'\n const emit = (value) => process.stdout.write(JSON.stringify(value));\n try {\n const raw = process.env.PLAN_URL || \"\";\n if (!raw) {\n emit({ url: \"\", reason: \"recap-url.txt was empty\" });\n process.exit(0);\n }\n const trusted = new URL(process.env.PLAN_RECAP_APP_URL || \"https://plan.agent-native.com\");\n const parsed = /^https?:\\/\\//i.test(raw)\n ? new URL(raw)\n : new URL(raw, trusted);\n if (parsed.origin !== trusted.origin) {\n emit({ url: \"\", reason: `recap-url.txt points at ${parsed.origin}, expected ${trusted.origin}` });\n process.exit(0);\n }\n\n const base = trusted.pathname.replace(/\\/$/, \"\");\n const paths = [parsed.pathname];\n if (base && parsed.pathname.startsWith(`${base}/`)) {\n paths.push(parsed.pathname.slice(base.length) || \"/\");\n }\n\n for (const path of paths) {\n const match = path.match(/^\\/(?:plans|recaps)\\/([A-Za-z0-9_-]+)\\/?$/);\n if (match) {\n emit({ url: `${trusted.origin}${base}/recaps/${match[1]}`, reason: \"\" });\n process.exit(0);\n }\n }\n emit({ url: \"\", reason: \"recap-url.txt did not contain a valid /plans/<id> or /recaps/<id> URL for the configured plan app\" });\n } catch {\n emit({ url: \"\", reason: \"recap-url.txt was not a valid URL or recap path\" });\n }\n NODE\n )\n CANONICAL_URL=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).url||\"\")}catch{process.stdout.write(\"\")}' \"$URL_RESULT\")\n URL_REASON=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).reason||\"\")}catch{process.stdout.write(\"recap-url.txt URL validation failed\")}' \"$URL_RESULT\")\n else\n CANONICAL_URL=\"\"\n fi\n if [ -n \"$CANONICAL_URL\" ]; then\n echo \"plan_url=$CANONICAL_URL\" >> \"$GITHUB_OUTPUT\"; echo \"ok=true\" >> \"$GITHUB_OUTPUT\"\n else\n echo \"plan_url=\" >> \"$GITHUB_OUTPUT\"; echo \"ok=false\" >> \"$GITHUB_OUTPUT\"\n fi\n {\n echo 'reason<<__RECAP_URL_REASON_EOF__'\n echo \"$URL_REASON\"\n echo '__RECAP_URL_REASON_EOF__'\n } >> \"$GITHUB_OUTPUT\"\n\n - name: Summarize agent failure\n id: agent_summary\n if: steps.url.outputs.ok != 'true' && steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true'\n continue-on-error: true\n env:\n RECAP_AGENT: ${{ needs.gate.outputs.agent }}\n RECAP_MCP_SMOKE_OK: ${{ steps.mcp_smoke.outputs.ok }}\n RECAP_MCP_SMOKE_SUMMARY: ${{ steps.mcp_smoke.outputs.summary }}\n run: |\n set -uo pipefail\n if [ -n \"${RECAP_MCP_SMOKE_SUMMARY:-}\" ] && [ \"${RECAP_MCP_SMOKE_OK:-}\" != \"true\" ]; then\n {\n echo 'summary<<__RECAP_MCP_SMOKE_SUMMARY_EOF__'\n echo \"$RECAP_MCP_SMOKE_SUMMARY\"\n echo '__RECAP_MCP_SMOKE_SUMMARY_EOF__'\n } >> \"$GITHUB_OUTPUT\"\n node -e 'process.stdout.write(JSON.stringify({ ok: true, summary: process.env.RECAP_MCP_SMOKE_SUMMARY || \"\" }) + \"\\n\")'\n exit 0\n fi\n RESULT=claude-result.json\n STDERR=claude-stderr.log\n EXIT_CODE=claude-exit-code.txt\n if [ \"$RECAP_AGENT\" = \"codex\" ]; then\n RESULT=codex-events.jsonl\n STDERR=codex-stderr.log\n EXIT_CODE=codex-exit-code.txt\n fi\n $RECAP_CLI recap agent-summary --agent \"$RECAP_AGENT\" --result-file \"$RESULT\" --stderr-file \"$STDERR\" --exit-code-file \"$EXIT_CODE\" || true\n\n - name: Attach usage\n if: steps.url.outputs.ok == 'true'\n continue-on-error: true\n env:\n PLAN_URL: ${{ steps.url.outputs.plan_url }}\n # Use the gate-normalized agent so \"Codex\" still selects the right file.\n RECAP_AGENT: ${{ needs.gate.outputs.agent }}\n run: |\n set -uo pipefail\n RESULT=claude-result.json\n if [ \"$RECAP_AGENT\" = \"codex\" ]; then RESULT=codex-events.jsonl; fi\n if [ -f \"$RESULT\" ]; then $RECAP_CLI recap usage --plan-url \"$PLAN_URL\" --agent \"$RECAP_AGENT\" --result-file \"$RESULT\" --model \"${VISUAL_RECAP_MODEL:-}\" --app-url \"$PLAN_RECAP_APP_URL\" --token \"$PLAN_RECAP_TOKEN\" || true; fi\n\n - name: Cache Playwright browsers\n if: steps.url.outputs.ok == 'true'\n uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3\n with:\n path: ~/.cache/ms-playwright\n key: playwright-1-${{ runner.os }}\n\n - name: Screenshot + upload\n id: shot\n if: steps.url.outputs.ok == 'true'\n continue-on-error: true\n env:\n # recap-url.txt is untrusted agent output; pass via env, never ${{ }}.\n PLAN_URL: ${{ steps.url.outputs.plan_url }}\n run: |\n set -uo pipefail\n pnpm exec playwright install --with-deps chromium 2>/dev/null || npx -y playwright@1 install --with-deps chromium || true\n LIGHT_SHOT_JSON=\"$($RECAP_CLI recap shot --url \"$PLAN_URL\" --token \"$PLAN_RECAP_TOKEN\" --app-url \"$PLAN_RECAP_APP_URL\" --out recap.png --theme light || echo '{}')\"\n DARK_SHOT_JSON=\"$($RECAP_CLI recap shot --url \"$PLAN_URL\" --token \"$PLAN_RECAP_TOKEN\" --app-url \"$PLAN_RECAP_APP_URL\" --out recap-dark.png --theme dark || echo '{}')\"\n IMAGE_URL=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).imageUrl||\"\")}catch{process.stdout.write(\"\")}' \"$LIGHT_SHOT_JSON\")\n DARK_IMAGE_URL=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).imageUrl||\"\")}catch{process.stdout.write(\"\")}' \"$DARK_SHOT_JSON\")\n echo \"image_url=$IMAGE_URL\" >> \"$GITHUB_OUTPUT\"\n echo \"light_image_url=$IMAGE_URL\" >> \"$GITHUB_OUTPUT\"\n echo \"dark_image_url=$DARK_IMAGE_URL\" >> \"$GITHUB_OUTPUT\"\n if [ -f recap.png ] || [ -f recap-dark.png ]; then echo \"captured=true\" >> \"$GITHUB_OUTPUT\"; else echo \"captured=false\" >> \"$GITHUB_OUTPUT\"; fi\n\n - name: Upload recap screenshot artifact\n if: steps.shot.outputs.captured == 'true'\n uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1\n with:\n name: pr-visual-recap-${{ github.event.pull_request.number }}\n path: |\n recap.png\n recap-dark.png\n if-no-files-found: ignore\n retention-days: 14\n\n - name: Upsert sticky comment\n if: always()\n continue-on-error: true\n env:\n PLAN_URL: ${{ steps.url.outputs.plan_url }}\n RECAP_IMAGE_URL: ${{ steps.shot.outputs.image_url }}\n RECAP_LIGHT_IMAGE_URL: ${{ steps.shot.outputs.light_image_url }}\n RECAP_DARK_IMAGE_URL: ${{ steps.shot.outputs.dark_image_url }}\n SUPPRESSED: ${{ steps.scan.outputs.suppressed }}\n SUPPRESSED_JSON: ${{ steps.scan.outputs.json }}\n DIFF_HUGE: ${{ steps.diff.outputs.huge }}\n DIFF_TINY: ${{ steps.diff.outputs.tiny }}\n PREV_PLAN_ID: ${{ steps.prev.outputs.plan_id }}\n RECAP_AUTH_FAILED: ${{ steps.auth_probe.outputs.auth_failed }}\n RECAP_AGENT_SUMMARY: ${{ steps.agent_summary.outputs.summary }}\n RECAP_URL_REASON: ${{ steps.url.outputs.reason }}\n run: |\n set -euo pipefail\n ARGS=(recap comment upsert --repo \"$GITHUB_REPOSITORY\" --issue \"$PR_NUMBER\" --token \"$GH_TOKEN\")\n # On a tiny diff, only REFRESH an existing comment, never create one.\n if [ \"${DIFF_TINY:-}\" = \"true\" ]; then ARGS+=(--update-only); fi\n $RECAP_CLI \"${ARGS[@]}\"\n\n - name: Complete visual recap check\n if: always() && steps.recap_check.outputs.check_run_id != ''\n continue-on-error: true\n env:\n # Untrusted/step values via env (NOT ${{ }}-interpolated into the run\n # body): the agent-written plan URL and the scan JSON could inject shell.\n CHECK_RUN_ID: ${{ steps.recap_check.outputs.check_run_id }}\n PLAN_OK: ${{ steps.url.outputs.ok }}\n PLAN_URL: ${{ steps.url.outputs.plan_url }}\n SUPPRESSED: ${{ steps.scan.outputs.suppressed }}\n SUPPRESSED_JSON: ${{ steps.scan.outputs.json }}\n DIFF_HUGE: ${{ steps.diff.outputs.huge }}\n DIFF_TINY: ${{ steps.diff.outputs.tiny }}\n RECAP_AGENT_SUMMARY: ${{ steps.agent_summary.outputs.summary }}\n RECAP_URL_REASON: ${{ steps.url.outputs.reason }}\n run: |\n set -uo pipefail\n $RECAP_CLI recap check complete \\\n --check-run-id \"$CHECK_RUN_ID\" \\\n --plan-ok \"$PLAN_OK\" \\\n --plan-url \"$PLAN_URL\" \\\n --suppressed \"$SUPPRESSED\" \\\n --suppressed-json \"$SUPPRESSED_JSON\" \\\n --huge \"$DIFF_HUGE\" \\\n --tiny \"$DIFF_TINY\" \\\n --failure-summary \"$RECAP_AGENT_SUMMARY\" \\\n --url-reason \"$RECAP_URL_REASON\" \\\n --workflow-url \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"\n";
10
+ export declare const PR_VISUAL_RECAP_WORKFLOW_YML = "name: PR Visual Recap\n\n# Visual code review: a coding agent runs the repo's visual-recap skill over the\n# PR diff, publishes a plan, and upserts one sticky comment with a screenshot.\n# Plain `pull_request` (NOT `pull_request_target`) so fork code never sees secrets.\n\non:\n pull_request:\n types: [opened, synchronize, reopened, ready_for_review]\n\npermissions:\n contents: read\n\nconcurrency:\n group: pr-visual-recap-${{ github.event.pull_request.number }}\n cancel-in-progress: true\n\nenv:\n VISUAL_RECAP_AGENT: ${{ vars.VISUAL_RECAP_AGENT || 'claude' }}\n VISUAL_RECAP_SKILL_SOURCE: ${{ vars.VISUAL_RECAP_SKILL_SOURCE || 'auto' }}\n\njobs:\n gate:\n name: Gate\n runs-on: ubuntu-latest\n timeout-minutes: 10\n permissions:\n contents: read\n issues: write\n pull-requests: write\n outputs:\n run: ${{ steps.decide.outputs.run }}\n agent: ${{ steps.decide.outputs.agent }}\n steps:\n - id: decide\n uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0\n env:\n # Presence-only signals \u2014 never expose secret VALUES to the gate.\n HAS_PLAN: ${{ secrets.PLAN_RECAP_TOKEN != '' }}\n HAS_ANTHROPIC: ${{ secrets.ANTHROPIC_API_KEY != '' }}\n HAS_OPENAI: ${{ secrets.OPENAI_API_KEY != '' }}\n AGENT: ${{ env.VISUAL_RECAP_AGENT }}\n VISUAL_RECAP_MODEL: ${{ vars.VISUAL_RECAP_MODEL }}\n HEAD_SHA: ${{ github.event.pull_request.head.sha }}\n with:\n script: |\n const pr = context.payload.pull_request;\n const reasons = [];\n\n if (!pr) reasons.push('no pull_request payload');\n if (pr && pr.draft) reasons.push('draft PR');\n\n // Fork PRs run with no secrets, so publishing would fail anyway \u2014 skip.\n const headRepo = pr && pr.head && pr.head.repo && pr.head.repo.full_name;\n if (pr && headRepo && headRepo !== process.env.GITHUB_REPOSITORY) {\n reasons.push(`fork PR (${headRepo})`);\n }\n\n const login = (pr && pr.user && pr.user.login || '').toLowerCase();\n const botAuthors = ['dependabot[bot]', 'dependabot', 'renovate[bot]', 'renovate'];\n if (botAuthors.includes(login)) reasons.push(`bot author (${login})`);\n if (pr && pr.user && pr.user.type === 'Bot') reasons.push('bot author (type=Bot)');\n\n if (process.env.HAS_PLAN !== 'true') reasons.push('PLAN_RECAP_TOKEN not configured');\n\n // Normalize + validate the agent so a mis-cased value can't pass the\n // gate and then match neither agent step below.\n const agent = (process.env.AGENT || 'claude').toLowerCase();\n if (agent !== 'claude' && agent !== 'codex') {\n reasons.push(`unsupported VISUAL_RECAP_AGENT \"${process.env.AGENT}\" (expected \"claude\" or \"codex\")`);\n } else if (agent === 'codex') {\n if (process.env.HAS_OPENAI !== 'true') reasons.push('OPENAI_API_KEY not configured (codex backend)');\n } else {\n if (process.env.HAS_ANTHROPIC !== 'true') reasons.push('ANTHROPIC_API_KEY not configured (claude backend)');\n }\n\n // Validate the model before it reaches the agent CLI.\n const model = process.env.VISUAL_RECAP_MODEL || '';\n if (model && !/^[a-zA-Z0-9._-]{1,80}$/.test(model)) {\n reasons.push(`invalid VISUAL_RECAP_MODEL value (must match [a-zA-Z0-9._-]{1,80})`);\n }\n\n // Self-modifying guard, evaluated in the trusted gate (runs NO\n // PR-checked-out code): skip the ENTIRE job if the PR touches the\n // workflow, skill, or any agent config the runner loads, so a PR\n // can't rewrite what runs and exfiltrate secrets.\n if (pr) {\n try {\n const files = await github.paginate(github.rest.pulls.listFiles, {\n owner: context.repo.owner,\n repo: context.repo.repo,\n pull_number: pr.number,\n per_page: 100,\n });\n const isSensitive = (p) =>\n p === '.github/workflows/pr-visual-recap.yml' ||\n /(^|\\/)skills\\/visual-(recap|plan|plans)\\//.test(p) ||\n /(^|\\/)\\.claude\\//.test(p) ||\n /(^|\\/)CLAUDE\\.md$/.test(p) ||\n /(^|\\/)AGENTS\\.md$/.test(p) ||\n /(^|\\/)\\.mcp\\.json$/.test(p);\n const hits = files.map((f) => f.filename).filter(isSensitive);\n if (hits.length) {\n reasons.push(`PR modifies recap-control files (${hits.slice(0, 3).join(', ')}${hits.length > 3 ? ', \u2026' : ''}) \u2014 skipping so untrusted PR code never runs with secrets`);\n }\n } catch (e) {\n // Fail closed: if the file list can't be read, skip.\n reasons.push(`could not list PR files for the self-modifying guard (${e.message}); skipping to be safe`);\n }\n }\n\n const run = reasons.length === 0;\n core.setOutput('run', run ? 'true' : 'false');\n core.setOutput('agent', agent);\n core.info(run ? `Visual recap will run (${agent}).` : `Visual recap skipped: ${reasons.join('; ')}`);\n\n // When skipping, refresh an EXISTING sticky recap comment with a\n // short skip line so it does not silently go stale. Never create a\n // new comment (no spam for repos where the recap has never run).\n if (!run && pr) {\n try {\n const MARKER = '<!-- pr-visual-recap -->';\n const { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: pr.number,\n per_page: 100,\n });\n const existing = comments.find(\n (c) => c.user && c.user.type === 'Bot' && c.body && c.body.includes(MARKER)\n );\n if (existing) {\n const headShort = (process.env.HEAD_SHA || '').slice(0, 7);\n const shaRef = headShort ? `\\`${headShort}\\`` : 'latest push';\n const primaryReason = reasons.filter(\n (r) => !r.startsWith('could not list PR files for the self-modifying guard')\n )[0] || reasons[0] || 'skipped';\n const skipLine = `_Recap skipped for ${shaRef}: ${primaryReason}._`;\n const withoutPrev = (existing.body || '')\n .split('\\n')\n .filter((l) => !/_Recap skipped for .+_$/.test(l.trim()))\n .join('\\n')\n .trimEnd();\n const updatedBody = `${withoutPrev}\\n\\n${skipLine}`;\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: existing.id,\n body: updatedBody,\n });\n }\n } catch (e) {\n core.warning(`Could not update recap skip comment: ${e.message}`);\n }\n }\n\n recap:\n name: Generate visual recap\n needs: gate\n if: needs.gate.outputs.run == 'true'\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n actions: write\n checks: write\n contents: read\n issues: write\n pull-requests: write\n env:\n PLAN_RECAP_APP_URL: ${{ secrets.PLAN_RECAP_APP_URL || 'https://plan.agent-native.com' }}\n PLAN_RECAP_TOKEN: ${{ secrets.PLAN_RECAP_TOKEN }}\n GH_TOKEN: ${{ github.token }}\n PR_NUMBER: ${{ github.event.pull_request.number }}\n HEAD_SHA: ${{ github.event.pull_request.head.sha }}\n VISUAL_RECAP_MODEL: ${{ vars.VISUAL_RECAP_MODEL }}\n VISUAL_RECAP_REASONING: ${{ vars.VISUAL_RECAP_REASONING }}\n VISUAL_RECAP_SKILL_SOURCE: ${{ vars.VISUAL_RECAP_SKILL_SOURCE || 'auto' }}\n steps:\n - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n with:\n fetch-depth: 0\n # This job runs an agent over untrusted PR diff; don't leave the token\n # in .git/config (it uses GH_TOKEN for gh API calls, never git push).\n persist-credentials: false\n\n # Dogfood trusted base-branch source inside this monorepo, else install the\n # published package once. Never execute PR-head recap CLI code.\n - name: Resolve recap CLI\n id: cli\n env:\n # Optional: pin the consumer CLI version (e.g. \"1.2.3\"). Defaults to\n # \"latest\" when unset. Set via repository variable RECAP_CLI_VERSION.\n RECAP_CLI_VERSION: ${{ vars.RECAP_CLI_VERSION || 'latest' }}\n run: |\n if [ \"$GITHUB_REPOSITORY\" = \"BuilderIO/agent-native\" ] && [ -f packages/core/src/cli/index.ts ]; then\n echo \"local=true\" >> \"$GITHUB_OUTPUT\"\n else\n echo \"local=false\" >> \"$GITHUB_OUTPUT\"\n fi\n\n - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n if: steps.cli.outputs.local == 'true'\n with:\n ref: ${{ github.event.pull_request.base.sha }}\n path: .recap-cli-source\n fetch-depth: 1\n persist-credentials: false\n\n - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8\n if: steps.cli.outputs.local == 'true'\n\n - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0\n with:\n node-version: \"22\"\n cache: ${{ steps.cli.outputs.local == 'true' && 'pnpm' || '' }}\n\n - name: Install trusted workspace recap CLI\n if: steps.cli.outputs.local == 'true'\n working-directory: .recap-cli-source\n run: |\n set -euo pipefail\n pnpm install --frozen-lockfile --ignore-scripts\n echo \"RECAP_CLI=$PWD/node_modules/.bin/tsx $PWD/packages/core/src/cli/index.ts\" >> \"$GITHUB_ENV\"\n\n - name: Install published recap CLI\n if: steps.cli.outputs.local != 'true'\n env:\n RECAP_CLI_VERSION: ${{ vars.RECAP_CLI_VERSION || 'latest' }}\n run: |\n set -euo pipefail\n VERSION=\"$RECAP_CLI_VERSION\"\n if [ \"$VERSION\" = \"latest\" ]; then\n VERSION=\"$(npm view @agent-native/core@latest version)\"\n fi\n for attempt in 1 2 3; do\n if npm install --prefix \"$RUNNER_TEMP/recap-cli\" --no-audit --no-fund \"@agent-native/core@$VERSION\"; then\n break\n fi\n if [ \"$attempt\" = \"3\" ]; then exit 1; fi\n sleep $((attempt * 10))\n done\n echo \"RECAP_CLI=$RUNNER_TEMP/recap-cli/node_modules/.bin/agent-native\" >> \"$GITHUB_ENV\"\n\n - name: Start visual recap check\n id: recap_check\n continue-on-error: true\n run: |\n set -uo pipefail\n $RECAP_CLI recap check start --sha \"$HEAD_SHA\" --workflow-url \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"\n\n - name: Collect bounded diff\n id: diff\n env:\n BASE_SHA: ${{ github.event.pull_request.base.sha }}\n run: |\n set -euo pipefail\n $RECAP_CLI recap collect-diff --base \"$BASE_SHA\" --head \"$HEAD_SHA\" --out recap.diff --stat recap.stat\n\n - name: Probe plan-app auth\n id: auth_probe\n if: steps.diff.outputs.tiny != 'true'\n continue-on-error: true\n run: |\n set -uo pipefail\n # Hit the plan app's action surface with the publish token. A 401 means\n # the token is expired/revoked; surface it in the sticky comment so the\n # repo owner knows to re-mint it instead of seeing a generic failure.\n HTTP_STATUS=$(node -e '\n const https = require(\"https\");\n const url = new URL(\"/_agent-native/actions/record-recap-usage\", process.env.PLAN_RECAP_APP_URL || \"https://plan.agent-native.com\");\n const req = https.request(url, { method: \"POST\", headers: { \"authorization\": \"Bearer \" + process.env.PLAN_RECAP_TOKEN, \"content-type\": \"application/json\" }, timeout: 8000 }, (res) => { process.stdout.write(String(res.statusCode)); req.destroy(); });\n req.on(\"error\", () => process.stdout.write(\"0\"));\n req.end(JSON.stringify({ planId: \"__probe__\" }));\n ' 2>/dev/null || echo \"0\")\n if [ \"$HTTP_STATUS\" = \"401\" ]; then\n echo \"auth_failed=true\" >> \"$GITHUB_OUTPUT\"\n else\n echo \"auth_failed=false\" >> \"$GITHUB_OUTPUT\"\n fi\n\n - name: Secret scan\n id: scan\n if: steps.diff.outputs.tiny != 'true'\n run: |\n set -uo pipefail\n # Fail CLOSED: a scanner error or invalid JSON suppresses the diff so a\n # credential-bearing diff is never handed to the agent / plan service.\n if ! SCAN_JSON=\"$($RECAP_CLI recap scan --diff recap.diff)\"; then\n SCAN_JSON='{\"suppressed\":true,\"reason\":\"secret scan failed to run; failing closed\"}'\n fi\n {\n echo 'json<<__RECAP_SCAN_EOF__'\n echo \"$SCAN_JSON\"\n echo '__RECAP_SCAN_EOF__'\n } >> \"$GITHUB_OUTPUT\"\n SUPPRESSED=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).suppressed?\"true\":\"false\")}catch{process.stdout.write(\"true\")}' \"$SCAN_JSON\")\n echo \"suppressed=$SUPPRESSED\" >> \"$GITHUB_OUTPUT\"\n\n - name: Read previous plan id\n id: prev\n continue-on-error: true\n run: |\n set -euo pipefail\n PLAN_ID=\"$($RECAP_CLI recap comment find-plan-id --repo \"$GITHUB_REPOSITORY\" --issue \"$PR_NUMBER\" --token \"$GH_TOKEN\")\"\n echo \"plan_id=$PLAN_ID\" >> \"$GITHUB_OUTPUT\"\n\n - name: Smoke-test Plan MCP tools\n id: mcp_smoke\n if: steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true'\n continue-on-error: true\n run: |\n set -uo pipefail\n $RECAP_CLI recap mcp-smoke --app-url \"$PLAN_RECAP_APP_URL\"\n\n - name: Build recap prompt\n id: prompt\n if: steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true' && steps.mcp_smoke.outputs.ok == 'true'\n env:\n # Pass step outputs via env, NOT ${{ }} interpolation into the run body:\n # the prev plan id is parsed from a PR comment and could inject shell.\n PREV_PLAN_ID: ${{ steps.prev.outputs.plan_id }}\n DIFF_HUGE: ${{ steps.diff.outputs.huge }}\n run: |\n set -euo pipefail\n ARGS=(--diff recap.diff --stat recap.stat --pr \"$PR_NUMBER\" --repo \"$GITHUB_REPOSITORY\" --head \"$HEAD_SHA\" --app-url \"$PLAN_RECAP_APP_URL\" --skill-source \"$VISUAL_RECAP_SKILL_SOURCE\" --out recap-prompt.md)\n if [ \"${DIFF_HUGE:-}\" = \"true\" ]; then ARGS+=(--huge); fi\n if [ -n \"${PREV_PLAN_ID:-}\" ]; then ARGS+=(--prev-plan-id \"$PREV_PLAN_ID\"); fi\n $RECAP_CLI recap build-prompt \"${ARGS[@]}\"\n\n - name: Run agent (Claude Code)\n id: claude\n if: needs.gate.outputs.agent == 'claude' && steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true' && steps.mcp_smoke.outputs.ok == 'true'\n continue-on-error: true\n env:\n ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}\n run: |\n set -uo pipefail\n MCP_CONFIG=\"$RUNNER_TEMP/plan-mcp.json\"\n $RECAP_CLI recap mcp-config --agent claude --app-url \"$PLAN_RECAP_APP_URL\" --out \"$MCP_CONFIG\"\n CLAUDE_ALLOWED_TOOLS=\"Read,Write,Bash(git diff:*),mcp__plan__get-plan-blocks,mcp__plan__create-visual-recap,mcp__plan__set-resource-visibility,mcp__agent-native-plans__get-plan-blocks,mcp__agent-native-plans__create-visual-recap,mcp__agent-native-plans__set-resource-visibility\"\n CLAUDE_ARGS=(-p \"$(cat recap-prompt.md)\" --mcp-config \"$MCP_CONFIG\" --allowedTools \"$CLAUDE_ALLOWED_TOOLS\" --permission-mode dontAsk --output-format json)\n if [ -n \"${VISUAL_RECAP_MODEL:-}\" ]; then CLAUDE_ARGS+=(--model \"$VISUAL_RECAP_MODEL\"); fi\n rm -f recap-url.txt claude-result.json claude-stderr.log\n run_claude() {\n set +e\n npx -y @anthropic-ai/claude-code@2 \"${CLAUDE_ARGS[@]}\" > claude-result.json 2> claude-stderr.log\n CLAUDE_STATUS=\"$?\"\n set -e\n echo \"$CLAUDE_STATUS\" > claude-exit-code.txt\n }\n run_claude\n if [ ! -s recap-url.txt ] && grep -Eiq 'schedule(d)? (a )?(wakeup|retry)|will retry|backoff|connector.*register|mcp.*(register|unreachable|not usable|zero tools|not callable)' claude-result.json claude-stderr.log 2>/dev/null; then\n echo \"Plan MCP registration appears delayed; retrying Claude once after 20s.\"\n sleep 20\n run_claude\n fi\n rm -f \"$MCP_CONFIG\" || true\n\n - name: Run agent (Codex)\n id: codex\n if: needs.gate.outputs.agent == 'codex' && steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true' && steps.mcp_smoke.outputs.ok == 'true'\n continue-on-error: true\n env:\n OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n run: |\n set -uo pipefail\n $RECAP_CLI recap mcp-config --agent codex --app-url \"$PLAN_RECAP_APP_URL\" --force\n # `codex login` writes ~/.codex/auth.json (the bare env var is dropped on\n # the gpt-5.5 wss transport); stdin keeps the key out of process args.\n printenv OPENAI_API_KEY | npx -y @openai/codex@0 login --with-api-key || true\n # The runner is itself an ephemeral sandbox; bypass Codex's own sandbox\n # (bubblewrap can't init here) and approval gate (cancels the MCP write).\n CODEX_ARGS=(exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check)\n if [ -n \"${VISUAL_RECAP_MODEL:-}\" ]; then CODEX_ARGS+=(--model \"$VISUAL_RECAP_MODEL\"); fi\n # Validate reasoning against the enum before embedding it in the TOML override.\n case \"${VISUAL_RECAP_REASONING:-}\" in\n none|minimal|low|medium|high|xhigh)\n CODEX_ARGS+=(-c \"model_reasoning_effort=\\\"$VISUAL_RECAP_REASONING\\\"\") ;;\n \"\") ;;\n *) echo \"Ignoring invalid VISUAL_RECAP_REASONING: $VISUAL_RECAP_REASONING\" ;;\n esac\n rm -f recap-url.txt codex-events.jsonl codex-stderr.log\n run_codex() {\n set +e\n npx -y @openai/codex@0 \"${CODEX_ARGS[@]}\" --json \"$(cat recap-prompt.md)\" 2> codex-stderr.log | tee codex-events.jsonl\n CODEX_STATUS=\"${PIPESTATUS[0]}\"\n set -e\n echo \"$CODEX_STATUS\" > codex-exit-code.txt\n }\n run_codex\n if [ ! -s recap-url.txt ] && grep -Eiq 'schedule(d)? (a )?(wakeup|retry)|will retry|backoff|connector.*register|mcp.*(register|unreachable|not usable|zero tools|not callable)' codex-events.jsonl codex-stderr.log 2>/dev/null; then\n echo \"Plan MCP registration appears delayed; retrying Codex once after 20s.\"\n sleep 20\n run_codex\n fi\n\n - name: Read plan URL\n id: url\n if: steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true'\n run: |\n set -uo pipefail\n PLAN_URL=\"\"\n URL_REASON=\"\"\n if [ -f recap-url.txt ]; then\n PLAN_URL=\"$(tr -d '\\r\\n' < recap-url.txt | tr -d ' ')\"\n else\n URL_REASON=\"recap-url.txt was not created by the agent\"\n fi\n # recap-url.txt is agent-written -> untrusted. Rebuild a canonical\n # recap URL from the trusted app base and a strictly validated plan id,\n # preserving path-prefixed self-hosted mounts.\n if [ -z \"$URL_REASON\" ]; then\n URL_RESULT=$(PLAN_URL=\"$PLAN_URL\" node <<'NODE'\n const emit = (value) => process.stdout.write(JSON.stringify(value));\n try {\n const raw = process.env.PLAN_URL || \"\";\n if (!raw) {\n emit({ url: \"\", reason: \"recap-url.txt was empty\" });\n process.exit(0);\n }\n const trusted = new URL(process.env.PLAN_RECAP_APP_URL || \"https://plan.agent-native.com\");\n const parsed = /^https?:\\/\\//i.test(raw)\n ? new URL(raw)\n : new URL(raw, trusted);\n if (parsed.origin !== trusted.origin) {\n emit({ url: \"\", reason: `recap-url.txt points at ${parsed.origin}, expected ${trusted.origin}` });\n process.exit(0);\n }\n\n const base = trusted.pathname.replace(/\\/$/, \"\");\n const paths = [parsed.pathname];\n if (base && parsed.pathname.startsWith(`${base}/`)) {\n paths.push(parsed.pathname.slice(base.length) || \"/\");\n }\n\n for (const path of paths) {\n const match = path.match(/^\\/(?:plans|recaps)\\/([A-Za-z0-9_-]+)\\/?$/);\n if (match) {\n emit({ url: `${trusted.origin}${base}/recaps/${match[1]}`, reason: \"\" });\n process.exit(0);\n }\n }\n emit({ url: \"\", reason: \"recap-url.txt did not contain a valid /plans/<id> or /recaps/<id> URL for the configured plan app\" });\n } catch {\n emit({ url: \"\", reason: \"recap-url.txt was not a valid URL or recap path\" });\n }\n NODE\n )\n CANONICAL_URL=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).url||\"\")}catch{process.stdout.write(\"\")}' \"$URL_RESULT\")\n URL_REASON=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).reason||\"\")}catch{process.stdout.write(\"recap-url.txt URL validation failed\")}' \"$URL_RESULT\")\n else\n CANONICAL_URL=\"\"\n fi\n if [ -n \"$CANONICAL_URL\" ]; then\n echo \"plan_url=$CANONICAL_URL\" >> \"$GITHUB_OUTPUT\"; echo \"ok=true\" >> \"$GITHUB_OUTPUT\"\n else\n echo \"plan_url=\" >> \"$GITHUB_OUTPUT\"; echo \"ok=false\" >> \"$GITHUB_OUTPUT\"\n fi\n {\n echo 'reason<<__RECAP_URL_REASON_EOF__'\n echo \"$URL_REASON\"\n echo '__RECAP_URL_REASON_EOF__'\n } >> \"$GITHUB_OUTPUT\"\n\n - name: Summarize agent failure\n id: agent_summary\n if: steps.url.outputs.ok != 'true' && steps.diff.outputs.tiny != 'true' && steps.scan.outputs.suppressed != 'true'\n continue-on-error: true\n env:\n RECAP_AGENT: ${{ needs.gate.outputs.agent }}\n RECAP_MCP_SMOKE_OK: ${{ steps.mcp_smoke.outputs.ok }}\n RECAP_MCP_SMOKE_SUMMARY: ${{ steps.mcp_smoke.outputs.summary }}\n run: |\n set -uo pipefail\n if [ -n \"${RECAP_MCP_SMOKE_SUMMARY:-}\" ] && [ \"${RECAP_MCP_SMOKE_OK:-}\" != \"true\" ]; then\n {\n echo 'summary<<__RECAP_MCP_SMOKE_SUMMARY_EOF__'\n echo \"$RECAP_MCP_SMOKE_SUMMARY\"\n echo '__RECAP_MCP_SMOKE_SUMMARY_EOF__'\n } >> \"$GITHUB_OUTPUT\"\n node -e 'process.stdout.write(JSON.stringify({ ok: true, summary: process.env.RECAP_MCP_SMOKE_SUMMARY || \"\" }) + \"\\n\")'\n exit 0\n fi\n RESULT=claude-result.json\n STDERR=claude-stderr.log\n EXIT_CODE=claude-exit-code.txt\n if [ \"$RECAP_AGENT\" = \"codex\" ]; then\n RESULT=codex-events.jsonl\n STDERR=codex-stderr.log\n EXIT_CODE=codex-exit-code.txt\n fi\n $RECAP_CLI recap agent-summary --agent \"$RECAP_AGENT\" --result-file \"$RESULT\" --stderr-file \"$STDERR\" --exit-code-file \"$EXIT_CODE\" || true\n\n - name: Attach usage\n if: steps.url.outputs.ok == 'true'\n continue-on-error: true\n env:\n PLAN_URL: ${{ steps.url.outputs.plan_url }}\n # Use the gate-normalized agent so \"Codex\" still selects the right file.\n RECAP_AGENT: ${{ needs.gate.outputs.agent }}\n run: |\n set -uo pipefail\n RESULT=claude-result.json\n if [ \"$RECAP_AGENT\" = \"codex\" ]; then RESULT=codex-events.jsonl; fi\n if [ -f \"$RESULT\" ]; then $RECAP_CLI recap usage --plan-url \"$PLAN_URL\" --agent \"$RECAP_AGENT\" --result-file \"$RESULT\" --model \"${VISUAL_RECAP_MODEL:-}\" --app-url \"$PLAN_RECAP_APP_URL\" --token \"$PLAN_RECAP_TOKEN\" || true; fi\n\n - name: Cache Playwright browsers\n if: steps.url.outputs.ok == 'true'\n uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3\n with:\n path: ~/.cache/ms-playwright\n key: playwright-1-${{ runner.os }}\n\n - name: Screenshot + upload\n id: shot\n if: steps.url.outputs.ok == 'true'\n continue-on-error: true\n env:\n # recap-url.txt is untrusted agent output; pass via env, never ${{ }}.\n PLAN_URL: ${{ steps.url.outputs.plan_url }}\n run: |\n set -uo pipefail\n pnpm exec playwright install --with-deps chromium 2>/dev/null || npx -y playwright@1 install --with-deps chromium || true\n LIGHT_SHOT_JSON=\"$($RECAP_CLI recap shot --url \"$PLAN_URL\" --token \"$PLAN_RECAP_TOKEN\" --app-url \"$PLAN_RECAP_APP_URL\" --out recap.png --theme light || echo '{}')\"\n DARK_SHOT_JSON=\"$($RECAP_CLI recap shot --url \"$PLAN_URL\" --token \"$PLAN_RECAP_TOKEN\" --app-url \"$PLAN_RECAP_APP_URL\" --out recap-dark.png --theme dark || echo '{}')\"\n IMAGE_URL=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).imageUrl||\"\")}catch{process.stdout.write(\"\")}' \"$LIGHT_SHOT_JSON\")\n DARK_IMAGE_URL=$(node -e 'try{process.stdout.write(JSON.parse(process.argv[1]).imageUrl||\"\")}catch{process.stdout.write(\"\")}' \"$DARK_SHOT_JSON\")\n echo \"image_url=$IMAGE_URL\" >> \"$GITHUB_OUTPUT\"\n echo \"light_image_url=$IMAGE_URL\" >> \"$GITHUB_OUTPUT\"\n echo \"dark_image_url=$DARK_IMAGE_URL\" >> \"$GITHUB_OUTPUT\"\n if [ -f recap.png ] || [ -f recap-dark.png ]; then echo \"captured=true\" >> \"$GITHUB_OUTPUT\"; else echo \"captured=false\" >> \"$GITHUB_OUTPUT\"; fi\n\n - name: Upload recap screenshot artifact\n if: steps.shot.outputs.captured == 'true'\n uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1\n with:\n name: pr-visual-recap-${{ github.event.pull_request.number }}\n path: |\n recap.png\n recap-dark.png\n if-no-files-found: ignore\n retention-days: 14\n\n - name: Upsert sticky comment\n if: always()\n continue-on-error: true\n env:\n PLAN_URL: ${{ steps.url.outputs.plan_url }}\n RECAP_IMAGE_URL: ${{ steps.shot.outputs.image_url }}\n RECAP_LIGHT_IMAGE_URL: ${{ steps.shot.outputs.light_image_url }}\n RECAP_DARK_IMAGE_URL: ${{ steps.shot.outputs.dark_image_url }}\n SUPPRESSED: ${{ steps.scan.outputs.suppressed }}\n SUPPRESSED_JSON: ${{ steps.scan.outputs.json }}\n DIFF_HUGE: ${{ steps.diff.outputs.huge }}\n DIFF_TINY: ${{ steps.diff.outputs.tiny }}\n PREV_PLAN_ID: ${{ steps.prev.outputs.plan_id }}\n RECAP_AUTH_FAILED: ${{ steps.auth_probe.outputs.auth_failed }}\n RECAP_AGENT_SUMMARY: ${{ steps.agent_summary.outputs.summary }}\n RECAP_URL_REASON: ${{ steps.url.outputs.reason }}\n run: |\n set -euo pipefail\n ARGS=(recap comment upsert --repo \"$GITHUB_REPOSITORY\" --issue \"$PR_NUMBER\" --token \"$GH_TOKEN\")\n # On a tiny diff, only REFRESH an existing comment, never create one.\n if [ \"${DIFF_TINY:-}\" = \"true\" ]; then ARGS+=(--update-only); fi\n $RECAP_CLI \"${ARGS[@]}\"\n\n - name: Complete visual recap check\n if: always() && steps.recap_check.outputs.check_run_id != ''\n continue-on-error: true\n env:\n # Untrusted/step values via env (NOT ${{ }}-interpolated into the run\n # body): the agent-written plan URL and the scan JSON could inject shell.\n CHECK_RUN_ID: ${{ steps.recap_check.outputs.check_run_id }}\n PLAN_OK: ${{ steps.url.outputs.ok }}\n PLAN_URL: ${{ steps.url.outputs.plan_url }}\n SUPPRESSED: ${{ steps.scan.outputs.suppressed }}\n SUPPRESSED_JSON: ${{ steps.scan.outputs.json }}\n DIFF_HUGE: ${{ steps.diff.outputs.huge }}\n DIFF_TINY: ${{ steps.diff.outputs.tiny }}\n RECAP_AGENT_SUMMARY: ${{ steps.agent_summary.outputs.summary }}\n RECAP_URL_REASON: ${{ steps.url.outputs.reason }}\n run: |\n set -uo pipefail\n $RECAP_CLI recap check complete \\\n --check-run-id \"$CHECK_RUN_ID\" \\\n --plan-ok \"$PLAN_OK\" \\\n --plan-url \"$PLAN_URL\" \\\n --suppressed \"$SUPPRESSED\" \\\n --suppressed-json \"$SUPPRESSED_JSON\" \\\n --huge \"$DIFF_HUGE\" \\\n --tiny \"$DIFF_TINY\" \\\n --failure-summary \"$RECAP_AGENT_SUMMARY\" \\\n --url-reason \"$RECAP_URL_REASON\" \\\n --workflow-url \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"\n";
11
11
  //# sourceMappingURL=pr-visual-recap-workflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pr-visual-recap-workflow.d.ts","sourceRoot":"","sources":["../../src/cli/pr-visual-recap-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,4BAA4B,kx6BACsh6B,CAAC"}
1
+ {"version":3,"file":"pr-visual-recap-workflow.d.ts","sourceRoot":"","sources":["../../src/cli/pr-visual-recap-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,4BAA4B,m96BACqt6B,CAAC"}