Add ChatGPT handover snapshot script and project context

This commit is contained in:
rob
2026-11-04 13:18:42 +00:00
parent 1ccba36a4e
commit 03e15dd531
9 changed files with 265 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
# ChatGPT handover snapshot
From the repository root, run:
```bash
python3 scripts/create_snapshot.py
```
The script writes a timestamped ZIP into `snapshots/`. It includes the application source, `AGENTS.md`, `docs/`, and `scripts/`, including safe untracked files. It omits Git metadata, task worktrees, dependency directories, local environment files, local databases, shared files, caches, generated builds, prior snapshots, symlinks, and common key/credential files. The root `.gitignore` ignores `snapshots/`.
Inspect the ZIP contents before uploading it if you have added new local data or sensitive file types to the project.
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env python3
"""Create a source-and-context ZIP for a ChatGPT project handover."""
from datetime import datetime
import os
from pathlib import Path
from zipfile import ZIP_DEFLATED, ZipFile
ROOT = Path(__file__).resolve().parent.parent
OUTPUT = ROOT / "snapshots"
ROOT_ENTRIES = ("AGENTS.md", ".gitignore", "README.md", "api", "react", "docs", "scripts")
EXCLUDED_DIRS = {
".git", ".worktrees", ".venv", "venv", "node_modules", "share",
"instance", "__pycache__", ".pytest_cache", ".mypy_cache", ".ruff_cache",
"dist", "dist-ssr", "build", "coverage", "snapshots", "logs",
}
EXCLUDED_NAMES = {".env", ".flaskenv", ".DS_Store"}
EXCLUDED_SUFFIXES = (".pyc", ".pyo", ".log", ".zip", ".db", ".sqlite", ".sqlite3", ".pem", ".key", ".p12", ".pfx")
def safe_file(path: Path) -> bool:
name = path.name.lower()
if path.is_symlink() or not path.is_file():
return False
if name.startswith(".") and name != ".gitignore":
return False
if name in EXCLUDED_NAMES or name.startswith(".env."):
return False
if name.startswith(("credentials", "id_rsa", "id_ed25519")):
return False
return not name.endswith(EXCLUDED_SUFFIXES)
def source_files():
for root_name in ROOT_ENTRIES:
entry = ROOT / root_name
if entry.is_file():
if safe_file(entry):
yield entry
continue
if not entry.is_dir() or entry.is_symlink():
continue
for directory, dirs, files in os.walk(entry, followlinks=False):
dirs[:] = sorted(
name for name in dirs
if name not in EXCLUDED_DIRS
and not name.startswith(".")
and not (Path(directory) / name).is_symlink()
)
for name in sorted(files):
path = Path(directory) / name
if safe_file(path):
yield path
def main():
OUTPUT.mkdir(exist_ok=True)
stamp = datetime.now().strftime("%Y%m%d-%H%M%S-%f")
archive = OUTPUT / f"foldershare-{stamp}.zip"
temporary = OUTPUT / f".foldershare-{stamp}.tmp"
count = 0
try:
with ZipFile(temporary, "w", compression=ZIP_DEFLATED) as zip_file:
for path in source_files():
zip_file.write(path, path.relative_to(ROOT).as_posix())
count += 1
temporary.replace(archive)
finally:
temporary.unlink(missing_ok=True)
print(f"Created {archive} ({count} files)")
if __name__ == "__main__":
main()