"""Zero-model AST public-signature diff generator for AGENTS.md / CLAUDE.md notes."""
import ast, json

def public_signatures(py_source: str) -> dict[str, list[str]]:
    tree = ast.parse(py_source)
    out: dict[str, list[str]] = {}
    for node in tree.body:
        if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and not node.name.startswith('_'):
            out[node.name] = [a.arg for a in node.args.args]
    return out

def diff_cutoff_vs_pinned(before_src: str, pinned_src: str) -> dict[str, object]:
    old_s, new_s = public_signatures(before_src), public_signatures(pinned_src)
    added = sorted(k for k in new_s if k not in old_s)
    removed = sorted(k for k in old_s if k not in new_s)
    changed = sorted(k for k in new_s if k in old_s and new_s[k] != old_s[k])
    return {'model_calls': 0, 'added': added, 'removed': removed, 'changed_signatures': changed}
