feat: smart subtree-aware reinit and validate --fix

- project_map_reinit now regenerates only the target subtree + ancestors
  by default, falling back to full reinit when subtree file count exceeds
  reinitFullThresholdPercent (default 10%).
- Add reinitFullThresholdPercent config option.
- Expose fix=true on project_map_validate Pi tool for localized repair.
- Update docs and runtime guidance to prefer patch / validate --fix
  before full reinit.
- Add integration tests for smart reinit and update typebox mock.
This commit is contained in:
Developer
2026-06-16 11:46:48 +00:00
parent 5f1c107667
commit cb581f44b9
11 changed files with 384 additions and 54 deletions
+1 -19
View File
@@ -5,6 +5,7 @@ import {
discoverProject,
generateDirectoryArtifacts,
buildDirectoryContext,
getAncestorEntries,
} from "./init.js";
import type { DirectoryEntry } from "./discover.js";
import type { LLMClient } from "./llm/llm-client.js";
@@ -133,25 +134,6 @@ function countDirectChildren(rootPath: string, relDir: string): number {
}).length;
}
function getAncestorEntries(
entries: DirectoryEntry[],
ctx: ReturnType<typeof buildDirectoryContext>,
entry: DirectoryEntry,
): DirectoryEntry[] {
const result: DirectoryEntry[] = [];
let parent = ctx.parentMap.get(entry.relativePath);
while (parent) {
const ancestor = entries.find(
(candidate) => candidate.relativePath === parent,
);
if (ancestor) {
result.push(ancestor);
}
parent = ctx.parentMap.get(parent);
}
return result;
}
function normalizeRelativePath(relPath: string): string {
if (!relPath || relPath === ".") return ".";
return relPath.replace(/\\/g, "/");