import json, re # Load real OpenAPI paths with open("scripts/openapi.json", encoding="utf-8") as f: spec = json.load(f) real_paths = set() for p, methods in spec.get("paths", {}).items(): for m in methods: real_paths.add((m.upper(), p)) # Load api.ts with open("src/api/api.ts", encoding="utf-8") as f: lines = f.readlines() # Extract per-function guessed request path + 待确认 flag func_re = re.compile(r"^\s*(?:export\s+)?(?:async\s+)?function\s+(\w+)\s*\(") req_re = re.compile(r"request(?:<[^>]*>)?\(\s*['\"]([^'\"]+)['\"]") dai_re = re.compile(r"【待确认】") cur = None funcs = {} # name -> {path, dai, lineno} for i, ln in enumerate(lines): m = func_re.match(ln) if m: cur = m.group(1) funcs[cur] = {"path": None, "dai": False, "lineno": i+1} if cur: rm = req_re.search(ln) if rm and funcs[cur]["path"] is None: funcs[cur]["path"] = rm.group(1) if dai_re.search(ln): funcs[cur]["dai"] = True # Real paths set for existence check (ignore method for domain check) all_real_path_strings = set(p for _, p in real_paths) print("=== FUNCTIONS WITH 【待确认】 GUESSED PATH ===") phantom = [] exists = [] no_real_branch = [] for name, info in funcs.items(): if not info["dai"]: continue path = info["path"] if path is None: no_real_branch.append(name) print(f" [NO-REAL-BRANCH] {name} (line {info['lineno']})") continue if path in all_real_path_strings: exists.append((name, path)) print(f" [REAL?] {name:42} -> {path} (line {info['lineno']})") else: phantom.append((name, path)) print(f" [PHANTOM] {name:42} -> {path} (line {info['lineno']})") print() print(f"REAL-DOMAIN (path string exists somewhere): {len(exists)}") print(f"PHANTOM (path NOT in OpenAPI at all): {len(phantom)}") print(f"【待确认】 but NO request path found: {len(no_real_branch)}")