Blame view

tools/recover/scan.py 1.31 KB
55f68655   王彪总   新项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  #!/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)}")