Implement FORGE-F002 context skill and snapshot commands

This commit is contained in:
rob
2026-11-17 14:19:59 +00:00
parent d01b4c0f06
commit 6217b9e8fd
12 changed files with 198 additions and 4 deletions
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
"""Report duplicate task headings and unfinished Git worktrees without changing them."""
import argparse
import re
import subprocess
from pathlib import Path
TASK = re.compile(r"^##\s+((?:[A-Z][A-Z0-9]*-)?[A-Z]*\d{3,})\s+[—-]", re.M)
def ids(paths):
found = {}
for path in paths:
for match in TASK.finditer(Path(path).read_text(encoding="utf-8")):
line = Path(path).read_text(encoding="utf-8")[:match.start()].count("\n") + 1
found.setdefault(match.group(1), []).append(f"{path}:{line}")
return found
def git(*args):
return subprocess.check_output(["git", *args], text=True).strip()
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("task_files", nargs="*", help="task registers to compare")
parser.add_argument("--worktrees", action="store_true", help="report worktree changes and handoffs")
args = parser.parse_args()
collisions = {key: loc for key, loc in ids(args.task_files).items() if len(loc) > 1}
for key, loc in sorted(collisions.items()):
print(f"COLLISION {key}: {', '.join(loc)}")
if args.worktrees:
for block in git("worktree", "list", "--porcelain").split("\n\n"):
if not block:
continue
path = Path(block.splitlines()[0].removeprefix("worktree "))
status = subprocess.check_output(["git", "-C", str(path), "status", "--porcelain"], text=True).strip()
handoff = path / "docs/HANDOFF.md"
print(f"WORKTREE {path}: {'CHANGES' if status else 'clean'}; handoff {'present' if handoff.is_file() and handoff.read_text().strip() else 'MISSING'}")
return 1 if collisions else 0
if __name__ == "__main__":
raise SystemExit(main())
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
"""Archive safe current-worktree source, including non-ignored untracked files."""
import datetime
import subprocess
import sys
import zipfile
from pathlib import Path
root = Path(sys.argv[1]).resolve()
deny_dirs = {".git", ".test-worktrees", "snapshots", "node_modules", ".venv", "venv", "__pycache__", "dist", "build", ".pytest_cache"}
deny_suffixes = (".db", ".sqlite", ".sqlite3", ".pem", ".key", ".p12", ".pfx")
def git(*args):
return subprocess.check_output(["git", "-C", str(root), *args], text=True).strip()
def allowed(path):
parts = Path(path).parts
name = parts[-1]
return not (set(parts) & deny_dirs or any(p.startswith(".env") for p in parts) or name.endswith(deny_suffixes) or "credential" in name.lower() or "secret" in name.lower())
paths = subprocess.check_output(["git", "-C", str(root), "ls-files", "-co", "--exclude-standard", "-z"]).decode().split("\0")
selected = sorted({p for p in paths if p and allowed(p) and (root / p).is_file() and not (root / p).is_symlink()})
out_dir = root / "snapshots"
out_dir.mkdir(exist_ok=True)
stamp = datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%dT%H%M%SZ")
out = out_dir / f"{root.name}-chatgpt-{stamp}-{git('rev-parse', '--short', 'HEAD')}.zip"
with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as archive:
for path in selected:
archive.write(root / path, path)
print(f"{out}\nbranch: {git('branch', '--show-current')}\nuncommitted: {bool(git('status', '--porcelain'))}\nfiles: {len(selected)}")
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
set -eu
repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
exec python3 "$repo/scripts/create-chatgpt-snapshot.py" "$repo"
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
set -eu
if [ "${1:-}" = "--help" ]; then
echo 'Usage: scripts/testtask.sh FORGE-F###'
echo 'Forge currently has no application runtime or manual-test hook.'
exit 0
fi
case "${1:-}" in
FORGE-F[0-9][0-9][0-9]) ;;
*) echo 'Usage: scripts/testtask.sh FORGE-F###' >&2; exit 2 ;;
esac
echo 'testtask is provisioned but blocked: Forge has no application runtime or task-specific manual-test hook.' >&2
exit 3