{"record":{"id":"bd68c76f6b689dc7","repo":"Egonex-AI/Understand-Anything","slug":"usage-node-prepare-incremental-mjs-projectroot","errorCode":null,"errorMessage":"Usage: node prepare-incremental.mjs <projectRoot> <baseCommit> [--exclude <patterns>]","messagePattern":"Usage: node prepare-incremental\\.mjs <projectRoot> <baseCommit> \\[--exclude <patterns>\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/prepare-incremental.mjs","lineNumber":469,"sourceCode":"}\n\nfunction parseArgs(argv) {\n  const positionals = [];\n  const excludePatterns = [];\n  for (let i = 0; i < argv.length; i++) {\n    const arg = argv[i];\n    if (arg === '--exclude') {\n      const value = argv[++i];\n      if (!value || value.startsWith('--')) throw new Error('--exclude requires patterns');\n      excludePatterns.push(...value.split(',').map(item => item.trim()).filter(Boolean));\n    } else if (arg.startsWith('--')) {\n      throw new Error(`Unknown option: ${arg}`);\n    } else {\n      positionals.push(arg);\n    }\n  }\n  if (positionals.length !== 2) {\n    throw new Error(\n      'Usage: node prepare-incremental.mjs <projectRoot> <baseCommit> [--exclude <patterns>]',\n    );\n  }\n  return { projectRoot: positionals[0], baseCommit: positionals[1], excludePatterns };\n}\n\nasync function main() {\n  const args = parseArgs(process.argv.slice(2));\n  const projectRoot = realpathSync(args.projectRoot);\n  const uaDir = resolveUaDir(projectRoot);\n  const intermediateDir = join(uaDir, 'intermediate');\n  mkdirSync(intermediateDir, { recursive: true });\n\n  const baseCommit = resolveCommit(projectRoot, args.baseCommit);\n  const headCommit = resolveCommit(projectRoot, 'HEAD');\n  const dirtyPaths = relevantWorktreeChanges(projectRoot, args.excludePatterns);\n  if (dirtyPaths.length > 0) {\n    const preview = dirtyPaths.slice(0, 10).join(', ');","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/07edf82a04371b6f69779b067bdc8a1a8753a9db/understand-anything-plugin/skills/understand/prepare-incremental.mjs#L451-L487","documentation":"parseArgs requires exactly two positional arguments: the project root and the base commit. Any other count (too few or too many) triggers this usage error, which documents the full accepted command line.","triggerScenarios":"Running the script with zero or one positional argument, or with extra stray positional arguments (e.g. unquoted paths with spaces adding a third positional).","commonSituations":"Forgetting the baseCommit argument, running the script from a README example with placeholders, or shell word-splitting an unquoted project path containing spaces into multiple positionals.","solutions":["Supply exactly two positionals: node prepare-incremental.mjs <projectRoot> <baseCommit>","Quote the project root if it contains spaces: node prepare-incremental.mjs \"/path/with spaces\" HEAD","Use a valid base commit (SHA, branch, or tag) as the second argument","Confirm the working directory/CI step invokes the script with the intended arguments"],"exampleFix":"// before\nnode prepare-incremental.mjs .\n// after\nnode prepare-incremental.mjs . HEAD~1","handlingStrategy":"validation","validationCode":"const positionals = process.argv.slice(2).filter(a => !a.startsWith('--'));\nif (positionals.length !== 2) {\n  console.error('Usage: node prepare-incremental.mjs <projectRoot> <baseCommit> [--exclude <patterns>]');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const parsed = parseArgs(argv);\n} catch (err) {\n  if (err.message.startsWith('Usage:')) {\n    console.error(err.message);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Always pass both projectRoot and baseCommit positionals","Quote project paths containing spaces so the shell yields one positional","Resolve the base commit (SHA/branch/tag) before invoking the script"],"tags":["cli","arguments","usage"],"backgroundTag":"missing-required-argument","analyzedSha":"07edf82a04371b6f69779b067bdc8a1a8753a9db","analyzedAt":"2026-09-07T23:20:10.829Z","contentChangedAt":"2026-09-07T23:20:10.829Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}