{"record":{"id":"87b8bea2d11f1e6a","repo":"Egonex-AI/Understand-Anything","slug":"usage-node-finalize-incremental-mjs-projectroot","errorCode":null,"errorMessage":"Usage: node finalize-incremental.mjs <projectRoot>","messagePattern":"Usage: node finalize-incremental\\.mjs <projectRoot>","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/finalize-incremental.mjs","lineNumber":382,"sourceCode":"\nfunction projectMetadata(previousProject, plan, scan) {\n  const languages = [...new Set(\n    (scan.files ?? [])\n      .map(file => file?.language)\n      .filter(language => typeof language === 'string' && language.length > 0),\n  )].sort();\n  return {\n    ...(previousProject ?? {}),\n    languages,\n    analyzedAt: new Date().toISOString(),\n    gitCommitHash: plan.headCommit,\n  };\n}\n\nasync function main() {\n  const args = process.argv.slice(2);\n  if (args.length !== 1 || args[0].startsWith('--')) {\n    throw new Error('Usage: node finalize-incremental.mjs <projectRoot>');\n  }\n  const projectRoot = realpathSync(args[0]);\n  const uaDir = resolveUaDir(projectRoot);\n  const intermediateDir = join(uaDir, 'intermediate');\n  const plan = readJson(join(intermediateDir, 'incremental-plan.json'));\n  const patch = readJson(join(intermediateDir, 'fingerprint-patch.json'));\n  const scan = readJson(join(intermediateDir, 'scan-result.json'), { totalFiles: 0 });\n  if (!plan || !patch) throw new Error('Incremental plan or fingerprint patch is missing');\n  if (patch.baseCommit !== plan.baseCommit || patch.headCommit !== plan.headCommit) {\n    throw new Error('Fingerprint patch does not match the incremental plan commits');\n  }\n\n  if (plan.action === 'FULL_UPDATE') {\n    throw new Error('FULL_UPDATE must run the full /understand pipeline');\n  }\n  if (plan.action === 'SKIP' && isGeneratedOnly(plan)) {\n    process.stdout.write('Generated artifacts only: analysis baseline unchanged\\n');\n    return;","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/07edf82a04371b6f69779b067bdc8a1a8753a9db/understand-anything-plugin/skills/understand/finalize-incremental.mjs#L364-L400","documentation":"finalize-incremental.mjs is a CLI script that must be invoked with exactly one positional argument, the project root directory, and no options. main() throws this usage error when the argument count is not exactly 1 or when the single argument starts with '--' (i.e. an option flag was passed where the project root is expected).","triggerScenarios":"Running `node finalize-incremental.mjs` with no arguments; with two or more arguments; or passing a flag like `node finalize-incremental.mjs --dry-run /path/to/project` so the first arg starts with '--'.","commonSituations":"Copy-pasting an invocation from docs and dropping the projectRoot argument; assuming the script supports flags like --help or --verbose; running it from a wrapper that forwards extra arguments.","solutions":["Invoke with exactly one argument: `node finalize-incremental.mjs <projectRoot>`.","Remove any flags — the script supports none; place any option handling in the calling tool instead.","Quote the project root path if it contains spaces so it counts as a single argument."],"exampleFix":"// before\nnode finalize-incremental.mjs --verbose ~/myproject\n// after\nnode finalize-incremental.mjs ~/myproject","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2);\nif (args.length !== 1 || args[0].startsWith('--')) {\n  console.error('Usage: node finalize-incremental.mjs <projectRoot>');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await import('./finalize-incremental.mjs');\n} catch (err) {\n  if (String(err.message).startsWith('Usage: node finalize-incremental.mjs')) {\n    console.error('Pass exactly one argument: the project root directory.');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Wrap invocations in a helper that appends exactly one positional projectRoot argument.","Never forward CLI flags to scripts that document positional-only arguments.","Quote paths containing spaces so the root counts as a single argument."],"tags":["cli","usage","missing-argument"],"backgroundTag":"missing-cli-argument","analyzedSha":"07edf82a04371b6f69779b067bdc8a1a8753a9db","analyzedAt":"2026-09-07T23:20:10.829Z","contentChangedAt":"2026-09-07T23:20:10.829Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}