#!/usr/bin/env python3 # -*- coding: utf-8 -*- """扫描 Claude Code 会话记录,列出被本次 P2 搬迁脚本误删的 P0/P1 源文件。""" import json, sys, collections, os JSONL = sys.argv[1] PREFIXES = ( "parking-module-system/src/main/java/com/zteits/parking", "parking-module-api/src/main/java/com/zteits/parking", ) ops = collections.OrderedDict() # path -> [ (kind, payload) ] with open(JSONL, encoding="utf-8", errors="replace") as f: for line in f: if '"tool_use"' not in line: continue try: rec = json.loads(line) except Exception: continue msg = rec.get("message") or {} for c in (msg.get("content") or []): if not isinstance(c, dict) or c.get("type") != "tool_use": continue name = c.get("name") inp = c.get("input") or {} p = inp.get("file_path") if not p or not isinstance(p, str): continue if not any(pp in p for pp in PREFIXES): continue ops.setdefault(p, []).append((name, inp)) print(f"涉及文件 {len(ops)} 个") for p, o in ops.items(): kinds = collections.Counter(k for k, _ in o) print(f" {p.replace('/Users/wangbiao/IdeaProjects/parking/parking-cloud/','')} {dict(kinds)}")