{"record":{"id":"b3c27707c06f5364","repo":"Egonex-AI/Understand-Anything","slug":"working-tree-has-relevant-uncommitted-changes-p","errorCode":null,"errorMessage":"Working tree has relevant uncommitted changes: ${preview}${suffix}. Commit or stash them before incremental analysis so the HEAD baseline remains reproducible.","messagePattern":"Working tree has relevant uncommitted changes: (.+?)(.+?)\\. Commit or stash them before incremental analysis so the HEAD baseline remains reproducible\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/prepare-incremental.mjs","lineNumber":489,"sourceCode":"    );\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(', ');\n    const suffix = dirtyPaths.length > 10 ? ` (+${dirtyPaths.length - 10} more)` : '';\n    throw new Error(\n      `Working tree has relevant uncommitted changes: ${preview}${suffix}. ` +\n      `Commit or stash them before incremental analysis so the HEAD baseline remains reproducible.`,\n    );\n  }\n  const changes = parseNameStatusZ(\n    run(\n      'git',\n      ['diff', '--name-status', '-z', '--relative', baseCommit, headCommit, '--', '.'],\n      { cwd: projectRoot },\n    ),\n  );\n  const diffPaths = pathsFromChanges(changes);\n\n  const scanPath = join(intermediateDir, 'scan-result.json');\n  const oldScan = readJson(scanPath, {});\n  const graph = readJson(join(uaDir, 'knowledge-graph.json'), {});\n  const oldFingerprints = normalizeFingerprintStore(\n    readJson(join(uaDir, 'fingerprints.json'), null),","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/07edf82a04371b6f69779b067bdc8a1a8753a9db/understand-anything-plugin/skills/understand/prepare-incremental.mjs#L471-L507","documentation":"main checks for uncommitted changes in the working tree that are relevant to the analysis (after exclude filtering). If any exist, incremental analysis is refused because the HEAD baseline would be irreproducible — the diff against baseCommit would not reflect a clean, committed state, so symbol protection could be computed against the wrong content.","triggerScenarios":"relevantWorktreeChanges returns one or more paths (limited preview of 10 in the message) because the repo has modified, staged, added, or deleted files matching analysis scope at the time prepare-incremental.mjs runs.","commonSituations":"Running incremental preparation mid-development with unsaved/uncommitted edits, CI checking out a branch with local modifications, or generated files appearing in the worktree that are not excluded and not gitignored.","solutions":["Commit the changes: git add -A && git commit -m \"...\" then re-run","Stash them: git stash (or git stash -u for untracked) and re-run","Exclude irrelevant dirty files: --exclude <patterns> if they are generated/local-only files","Add generated paths to .gitignore or the script's exclude patterns so they never count as relevant"],"exampleFix":"// before\nnode prepare-incremental.mjs . HEAD~1   # fails with dirty worktree\n// after\ngit stash -u\nnode prepare-incremental.mjs . HEAD~1\ngit stash pop","handlingStrategy":"validation","validationCode":"const dirty = execSync('git status --porcelain', { cwd: projectRoot }).toString().trim();\nif (dirty) throw new Error('Commit or stash uncommitted changes before incremental analysis');","typeGuard":null,"tryCatchPattern":"try {\n  await prepareIncremental(args);\n} catch (err) {\n  if (String(err.message).startsWith('Working tree has relevant uncommitted changes')) {\n    console.error(err.message);\n    // either instruct user to commit/stash, or auto-stash:\n    execSync('git stash -u');\n    return prepareIncremental(args).finally(() => execSync('git stash pop'));\n  }\n  throw err;\n}","preventionTips":["Run git status --porcelain and ensure it is empty before incremental prep","Exclude generated/local-only paths via --exclude or .gitignore so they do not count as relevant","In CI, always work from a clean checkout"],"tags":["git","worktree","state"],"backgroundTag":"dirty-working-tree","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"}