How to Build Repository-Level Code Intelligence with Repowise Using Graph Analysis, Dead-Code Detection, Decisions, and AI Context


banner("§12  CLAUDE.md")
sh("repowise generate-claude-md")
md = TARGET / "CLAUDE.md"
if md.exists():
   print(md.read_text()[:4000])
banner("§13  MCP tools via CLI")
base = [
   ("get_dead_code",            "repowise dead-code --safe-only"),
   ("search_codebase",          'repowise search "timestamp expiry validation"'),
]
llm_only = [
   ("get_overview",             'repowise query "Architecture overview please"'),
   ("get_context",              'repowise query "Explain signer and serializer modules"'),
   ("get_risk",                 'repowise query "What is risky about changing signer.py?"'),
   ("get_why",                  'repowise query "Why are signers stateless?"'),
   ("get_dependency_path",      'repowise query "How does URLSafeSerializer reach Signer?"'),
   ("get_architecture_diagram", 'repowise query "Produce a Mermaid diagram of the package"'),
]
for name, cmd in base + (llm_only if HAS_LLM else []):
   print(f"\n────  {name}  ────")
   sh(cmd)
if not HAS_LLM:
   print("\n(7 of 9 tools above need an LLM key — set ANTHROPIC_API_KEY and re-run §13.)")
banner("§14  Graph plot")
if G is not None:
   import matplotlib.pyplot as plt
   top = [n for n, _ in sorted(pr.items(), key=lambda x: -x[1])[:40]]
   H = G.subgraph(top).copy()
   sizes = [4000 * pr[n] / max(pr.values()) + 80 for n in H.nodes]
   plt.figure(figsize=(12, 8))
   pos = nx.spring_layout(H, seed=7, k=0.9)
   nx.draw_networkx_edges(H, pos, alpha=0.25, arrows=False)
   nx.draw_networkx_nodes(H, pos, node_size=sizes, node_color="#F59520", alpha=0.85)
   nx.draw_networkx_labels(H, pos,
       labels={n: Path(n).name if isinstance(n, str) else n for n in H.nodes},
       font_size=8)
   plt.title("itsdangerous — top-40 nodes by PageRank")
   plt.axis("off"); plt.tight_layout(); plt.show()
print("\n✅ done.")



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *