Merge pull request #1207 from nucleusjay/fix-merge-chunks-and-manifest-bugs

Fix two latent bugs: merge-chunks output and manifest data loss
This commit is contained in:
Safi
2026-06-12 20:15:23 +01:00
committed by GitHub
2 changed files with 22 additions and 3 deletions
+1 -1
View File
@@ -4611,7 +4611,7 @@ def main() -> None:
out_path.parent.mkdir(parents=True, exist_ok=True)
out_path.write_text(json.dumps(merged, ensure_ascii=False), encoding="utf-8")
print(
f"Merged {len(chunk_files)} chunks: {merged['nodes']} nodes, {len(merged['edges'])} edges, "
f"Merged {len(chunk_files)} chunks: {len(merged['nodes'])} nodes, {len(merged['edges'])} edges, "
f"{merged['input_tokens']:,} in / {merged['output_tokens']:,} out tokens"
)
+21 -2
View File
@@ -16,8 +16,27 @@ def _load_manifest() -> dict:
if _GLOBAL_MANIFEST.exists():
try:
return json.loads(_GLOBAL_MANIFEST.read_text(encoding="utf-8"))
except Exception:
pass
except Exception as exc:
# Don't silently wipe the user's manifest on a parse error: that
# deletes every tracked repo. Back the bad file up and surface the
# error so the user can recover or report it.
backup = _GLOBAL_MANIFEST.with_suffix(
_GLOBAL_MANIFEST.suffix + f".corrupt.{int(datetime.now(timezone.utc).timestamp())}"
)
try:
_GLOBAL_MANIFEST.rename(backup)
print(
f"[graphify global] manifest at {_GLOBAL_MANIFEST} failed to parse ({exc}); "
f"moved to {backup} and starting fresh. Restore from the backup if this was "
f"unexpected.",
file=sys.stderr,
)
except Exception as rename_exc:
print(
f"[graphify global] manifest at {_GLOBAL_MANIFEST} failed to parse ({exc}) "
f"and could not be backed up ({rename_exc}). Starting fresh.",
file=sys.stderr,
)
return {"version": 1, "repos": {}}