Stage 1 flags the living documents a pull request makes stale (no model, nothing sent). Stage 2, on repositories that opt in with drafter: claude, has Claude Code draft the edits in a sandboxed copy of the tree and opens them as a pull request into the feature branch. A monthly pass re-reads the top-level documents against the whole repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
ade847ba5b
38 files changed
+4286
No files matched your search
@@ -0,0 +1,22 @@
|
||||
"""Reading repository files without following a symlink out of the tree."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def inside(root: Path, path: Path) -> bool:
|
||||
"""True when path's real location is root's real location or below it."""
|
||||
real_root = os.path.realpath(root)
|
||||
real = os.path.realpath(path)
|
||||
return os.path.commonpath([real_root, real]) == real_root
|
||||
|
||||
|
||||
def read_in_tree(root: Path, rel: str) -> str | None:
|
||||
"""The text of root/rel, or None when it is a symlink, not a regular file, or
|
||||
resolves outside root (a symlinked parent directory included)."""
|
||||
path = root / rel
|
||||
if path.is_symlink() or not path.is_file() or not inside(root, path):
|
||||
return None
|
||||
return path.read_text(encoding="utf-8", errors="replace")
|
||||
Reference in new issue
Block a user