{"record":{"id":"72519f5c6b001701","repo":"stablyai/orca","slug":"verify-skills-cli-runtime-args-join-exit","errorCode":null,"errorMessage":"[verify-skills-cli-runtime] ${args.join(' ')} exited ${String(result.status)}\\n${detail}","messagePattern":"\\[verify-skills-cli-runtime\\] (.+?) exited (.+?)\\\\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"config/scripts/verify-skills-cli-runtime.cjs","lineNumber":159,"sourceCode":"  delete env.ORCA_CLI_CWD\n  const result = spawnSync(process.execPath, [entry, ...args], {\n    cwd: dirname(outDir),\n    encoding: 'utf8',\n    env,\n    killSignal: 'SIGKILL',\n    maxBuffer: 16 * 1024 * 1024,\n    timeout: timeoutMs\n  })\n  if (result.error || result.signal || result.status !== 0) {\n    const detail = [\n      result.error?.message,\n      result.signal ? `terminated by ${result.signal}` : null,\n      result.stdout,\n      result.stderr\n    ]\n      .filter(Boolean)\n      .join('\\n')\n    throw new Error(\n      `[verify-skills-cli-runtime] ${args.join(' ')} exited ${String(result.status)}\\n${detail}`\n    )\n  }\n  return result.stdout\n}\n\nfunction parseJson(label, output) {\n  try {\n    return JSON.parse(output)\n  } catch {\n    throw new Error(`[verify-skills-cli-runtime] ${label} emitted invalid JSON:\\n${output}`)\n  }\n}\n\nfunction verifySkillsCliRuntime(outDir, artifactRoot = dirname(outDir), options = {}) {\n  const absoluteOutDir = resolve(outDir)\n  const closure = collectRuntimeClosure(absoluteOutDir, resolve(artifactRoot))\n  if (options.executeCommands === false) {","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/verify-skills-cli-runtime.cjs#L141-L177","documentation":"Thrown by verify-skills-cli-runtime.cjs runCli() when a spawned CLI subprocess fails — non-zero exit, termination by signal, or a spawn-level error (e.g. executable missing, timeout). It aggregates stdout, stderr, signal, and error.message into a single diagnostic string. This is a build/CI verification script that drives the built Orca skills CLI as a black box.","triggerScenarios":"spawnSync(process.execPath, [outDir/cli/index.js, ...args]) returns with result.error set, result.signal set (e.g. SIGKILL from timeout), or result.status !== 0. Triggered by: skills list/get/install/update commands crashing, timing out (>30s), exceeding the 16MB stdout buffer, or the CLI entry file failing to load.","commonSituations":"Running the skills CLI runtime verification on a broken build where the CLI throws on startup; a skills topic that crashes when listed; NODE_PATH cleared (env sets NODE_PATH='') causing a dependency to fail to resolve at runtime; a command hanging past CLI_COMMAND_TIMEOUT_MS (30s); stdout exceeding maxBuffer on a large skills list.","solutions":["Read the embedded detail block (error.message, signal, stdout, stderr) to identify which of the 5 CLI commands failed and why.","If signal is present (e.g. SIGKILL), the command timed out — profile the specific skills subcommand for hangs or infinite loops.","If stdout/stderr show a module resolution error, rebuild the outDir closure or check that all runtime imports are bundled (collectRuntimeClosure verifies this beforehand).","If maxBuffer was exceeded, increase maxBuffer or reduce the output volume of the offending subcommand.","Reproduce locally with the same node binary and env (NODE_PATH='') to get a stack trace: node out/cli/index.js <failing-args>."],"exampleFix":"// before: command times out silently\nconst result = runCli(absoluteOutDir, ['skills', 'list', '--json'])\n\n// after: isolate which command and surface its exit detail\ntry {\n  runCli(absoluteOutDir, ['skills', 'list', '--json'])\n} catch (err) {\n  console.error('skills list failed under NODE_PATH=\"\" env:', err.message)\n  throw err\n}","handlingStrategy":"try-catch","validationCode":"const entry = resolve(outDir, 'cli', 'index.js')\nif (!existsSync(entry)) {\n  throw new Error(`CLI entry missing: ${entry}`)\n}\n// Pre-flight: confirm node can load the entry without running it\nconst probe = spawnSync(process.execPath, ['--check', entry], { encoding: 'utf8' })\nif (probe.status !== 0) {\n  throw new Error(`CLI entry has a syntax/load error: ${probe.stderr}`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  const stdout = runCli(outDir, args)\n} catch (err) {\n  // err.message contains args, exit code, signal, stdout, stderr\n  if (err.message.includes('terminated by SIGKILL')) {\n    // timeout — increase timeoutMs or optimize the command\n  } else if (err.message.includes('maxBuffer')) {\n    // output too large — increase maxBuffer\n  }\n  throw err\n}","preventionTips":["Run collectRuntimeClosure before command execution to catch missing imports early.","Keep CLI_COMMAND_TIMEOUT_MS proportional to the slowest subcommand in CI.","Ensure --json code paths never write to stdout except the JSON payload."],"tags":["ci","subprocess","spawn-sync","skills-cli","verification"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}