[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CT49QTZB9B6V0P89RAD8AK":3,"skill-same:01M7CT49QTZB9B6V0P89RAD8AK":168},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7CT49QTZB9B6V0P89RAD8AK","graphify",null,"any input (code, docs, papers, images) - knowledge graph - clustered communities - HTML + JSON + audit report","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill.md",[],[],"2026-11-15 14:19:17",false,"---\nname: graphify\ndescription: \"any input (code, docs, papers, images) - knowledge graph - clustered communities - HTML + JSON + audit report\"\ntrigger: \u002Fgraphify\n---\n\n# \u002Fgraphify\n\nTurn any folder of files into a navigable knowledge graph with community detection, an honest audit trail, and three outputs: interactive HTML, GraphRAG-ready JSON, and a plain-language GRAPH_REPORT.md.\n\n## Usage\n\n```\n\u002Fgraphify                                             # full pipeline on current directory → Obsidian vault\n\u002Fgraphify \u003Cpath>                                      # full pipeline on specific path\n\u002Fgraphify \u003Cpath> --mode deep                          # thorough extraction, richer INFERRED edges\n\u002Fgraphify \u003Cpath> --update                             # incremental - re-extract only new\u002Fchanged files\n\u002Fgraphify \u003Cpath> --directed                            # build directed graph (preserves edge direction: source→target)\n\u002Fgraphify \u003Cpath> --whisper-model medium                # use a larger Whisper model for better transcription accuracy\n\u002Fgraphify \u003Cpath> --cluster-only                       # rerun clustering on existing graph\n\u002Fgraphify \u003Cpath> --no-viz                             # skip visualization, just report + JSON\n\u002Fgraphify \u003Cpath> --html                               # (HTML is generated by default - this flag is a no-op)\n\u002Fgraphify \u003Cpath> --svg                                # also export graph.svg (embeds in Notion, GitHub)\n\u002Fgraphify \u003Cpath> --graphml                            # export graph.graphml (Gephi, yEd)\n\u002Fgraphify \u003Cpath> --neo4j                              # generate graphify-out\u002Fcypher.txt for Neo4j\n\u002Fgraphify \u003Cpath> --neo4j-push bolt:\u002F\u002Flocalhost:7687   # push directly to Neo4j\n\u002Fgraphify \u003Cpath> --mcp                                # start MCP stdio server for agent access\n\u002Fgraphify \u003Cpath> --watch                              # watch folder, auto-rebuild on code changes (no LLM needed)\n\u002Fgraphify \u003Cpath> --wiki                               # build agent-crawlable wiki (index.md + one article per community)\n\u002Fgraphify \u003Cpath> --obsidian --obsidian-dir ~\u002Fvaults\u002Fmy-project  # write vault to custom path (e.g. existing vault)\n\u002Fgraphify add \u003Curl>                                   # fetch URL, save to .\u002Fraw, update graph\n\u002Fgraphify add \u003Curl> --author \"Name\"                   # tag who wrote it\n\u002Fgraphify add \u003Curl> --contributor \"Name\"              # tag who added it to the corpus\n\u002Fgraphify query \"\u003Cquestion>\"                          # BFS traversal - broad context\n\u002Fgraphify query \"\u003Cquestion>\" --dfs                    # DFS - trace a specific path\n\u002Fgraphify query \"\u003Cquestion>\" --budget 1500            # cap answer at N tokens\n\u002Fgraphify path \"AuthModule\" \"Database\"                # shortest path between two concepts\n\u002Fgraphify explain \"SwinTransformer\"                   # plain-language explanation of a node\n```\n\n## What graphify is for\n\ngraphify is built around Andrej Karpathy's \u002Fraw folder workflow: drop anything into a folder - papers, tweets, screenshots, code, notes - and get a structured knowledge graph that shows you what you didn't know was connected.\n\nThree things it does that Claude alone cannot:\n1. **Persistent graph** - relationships are stored in `graphify-out\u002Fgraph.json` and survive across sessions. Ask questions weeks later without re-reading everything.\n2. **Honest audit trail** - every edge is tagged EXTRACTED, INFERRED, or AMBIGUOUS. You know what was found vs invented.\n3. **Cross-document surprise** - community detection finds connections between concepts in different files that you would never think to ask about directly.\n\nUse it for:\n- A codebase you're new to (understand architecture before touching anything)\n- A reading list (papers + tweets + notes → one navigable graph)\n- A research corpus (citation graph + concept graph in one)\n- Your personal \u002Fraw folder (drop everything in, let it grow, query it)\n\n## What You Must Do When Invoked\n\nIf no path was given, use `.` (current directory). Do not ask the user for a path.\n\nFollow these steps in order. Do not skip steps.\n\n### Step 1 - Ensure graphify is installed\n\n```bash\n# Detect the correct Python interpreter (handles pipx, venv, system installs)\nGRAPHIFY_BIN=$(which graphify 2>\u002Fdev\u002Fnull)\nif [ -n \"$GRAPHIFY_BIN\" ]; then\n    PYTHON=$(head -1 \"$GRAPHIFY_BIN\" | tr -d '#!')\n    case \"$PYTHON\" in\n        *[!a-zA-Z0-9\u002F_.-]*) PYTHON=\"python3\" ;;\n    esac\nelse\n    PYTHON=\"python3\"\nfi\n\"$PYTHON\" -c \"import graphify\" 2>\u002Fdev\u002Fnull || \"$PYTHON\" -m pip install graphifyy -q 2>\u002Fdev\u002Fnull || \"$PYTHON\" -m pip install graphifyy -q --break-system-packages 2>&1 | tail -3\n# Write interpreter path for all subsequent steps (persists across invocations)\nmkdir -p graphify-out\n\"$PYTHON\" -c \"import sys; open('graphify-out\u002F.graphify_python', 'w').write(sys.executable)\"\n```\n\nIf the import succeeds, print nothing and move straight to Step 2.\n\n**In every subsequent bash block, replace `python3` with `$(cat graphify-out\u002F.graphify_python)` to use the correct interpreter.**\n\n### Step 2 - Detect files\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.detect import detect\nfrom pathlib import Path\nresult = detect(Path('INPUT_PATH'))\nprint(json.dumps(result))\n\" > graphify-out\u002F.graphify_detect.json\n```\n\nReplace INPUT_PATH with the actual path the user provided. Do NOT cat or print the JSON - read it silently and present a clean summary instead:\n\n```\nCorpus: X files · ~Y words\n  code:     N files (.py .ts .go ...)\n  docs:     N files (.md .txt ...)\n  papers:   N files (.pdf ...)\n  images:   N files\n  video:    N files (.mp4 .mp3 ...)\n```\n\nOmit any category with 0 files from the summary.\n\nThen act on it:\n- If `total_files` is 0: stop with \"No supported files found in [path].\"\n- If `skipped_sensitive` is non-empty: mention file count skipped, not the file names.\n- If `total_words` > 2,000,000 OR `total_files` > 200: show the warning and the top 5 subdirectories by file count, then ask which subfolder to run on. Wait for the user's answer before proceeding.\n- Otherwise: proceed directly to Step 2.5 if video files were detected, or Step 3 if not.\n\n### Step 2.5 - Transcribe video \u002F audio files (only if video files detected)\n\nSkip this step entirely if `detect` returned zero `video` files.\n\nVideo and audio files cannot be read directly. Transcribe them to text first, then treat the transcripts as doc files in Step 3.\n\n**Strategy:** Read the god nodes from `graphify-out\u002F.graphify_detect.json` (or the analysis file if it exists from a previous run). You are already a language model — write a one-sentence domain hint yourself from those labels. Then pass it to Whisper as the initial prompt. No separate API call needed.\n\n**However**, if the corpus has *only* video files and no other docs\u002Fcode, use the generic fallback prompt: `\"Use proper punctuation and paragraph breaks.\"`\n\n**Step 1 - Write the Whisper prompt yourself.**\n\nRead the top god node labels from detect output or analysis, then compose a short domain hint sentence, for example:\n\n- Labels: `transformer, attention, encoder, decoder` → `\"Machine learning research on transformer architectures and attention mechanisms. Use proper punctuation and paragraph breaks.\"`\n- Labels: `kubernetes, deployment, pod, helm` → `\"DevOps discussion about Kubernetes deployments and Helm charts. Use proper punctuation and paragraph breaks.\"`\n\nSet it as `WHISPER_PROMPT` to use in the next command.\n\n**Step 2 - Transcribe:**\n\n```bash\nGRAPHIFY_WHISPER_MODEL=base  # or whatever --whisper-model the user passed\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json, os\nfrom pathlib import Path\nfrom graphify.transcribe import transcribe_all\n\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nvideo_files = detect.get('files', {}).get('video', [])\nprompt = os.environ.get('GRAPHIFY_WHISPER_PROMPT', 'Use proper punctuation and paragraph breaks.')\n\ntranscript_paths = transcribe_all(video_files, initial_prompt=prompt)\nprint(json.dumps(transcript_paths))\n\" > graphify-out\u002F.graphify_transcripts.json\n```\n\nAfter transcription:\n- Read the transcript paths from `graphify-out\u002F.graphify_transcripts.json`\n- Add them to the docs list before dispatching semantic subagents in Step 3B\n- Print how many transcripts were created: `Transcribed N video file(s) -> treating as docs`\n- If transcription fails for a file, print a warning and continue with the rest\n\n**Whisper model:** Default is `base`. If the user passed `--whisper-model \u003Cname>`, set `GRAPHIFY_WHISPER_MODEL=\u003Cname>` in the environment before running the command above.\n\n### Step 3 - Extract entities and relationships\n\n**Before starting:** note whether `--mode deep` was given. You must pass `DEEP_MODE=true` to every subagent in Step B2 if it was. Track this from the original invocation - do not lose it.\n\nThis step has two parts: **structural extraction** (deterministic, free) and **semantic extraction** (Claude, costs tokens).\n\n**Run Part A (AST) and Part B (semantic) in parallel. Dispatch all semantic subagents AND start AST extraction in the same message. Both can run simultaneously since they operate on different file types. Merge results in Part C as before.**\n\nNote: Parallelizing AST + semantic saves 5-15s on large corpora. AST is deterministic and fast; start it while subagents are processing docs\u002Fpapers.\n\n#### Part A - Structural extraction for code files\n\nFor any code files detected, run AST extraction in parallel with Part B subagents:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.extract import collect_files, extract\nfrom pathlib import Path\nimport json\n\ncode_files = []\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nfor f in detect.get('files', {}).get('code', []):\n    code_files.extend(collect_files(Path(f)) if Path(f).is_dir() else [Path(f)])\n\nif code_files:\n    result = extract(code_files, cache_root=Path('.'))\n    Path('graphify-out\u002F.graphify_ast.json').write_text(json.dumps(result, indent=2))\n    print(f'AST: {len(result[\\\"nodes\\\"])} nodes, {len(result[\\\"edges\\\"])} edges')\nelse:\n    Path('graphify-out\u002F.graphify_ast.json').write_text(json.dumps({'nodes':[],'edges':[],'input_tokens':0,'output_tokens':0}))\n    print('No code files - skipping AST extraction')\n\"\n```\n\n#### Part B - Semantic extraction (parallel subagents)\n\n**Fast path:** If detection found zero docs, papers, and images (code-only corpus), skip Part B entirely and go straight to Part C. AST handles code - there is nothing for semantic subagents to do.\n\n**MANDATORY: You MUST use the Agent tool here. Reading files yourself one-by-one is forbidden - it is 5-10x slower. If you do not use the Agent tool you are doing this wrong.**\n\nBefore dispatching subagents, print a timing estimate:\n- Load `total_words` and file counts from `graphify-out\u002F.graphify_detect.json`\n- Estimate agents needed: `ceil(uncached_non_code_files \u002F 22)` (chunk size is 20-25)\n- Estimate time: ~45s per agent batch (they run in parallel, so total ≈ 45s × ceil(agents\u002Fparallel_limit))\n- Print: \"Semantic extraction: ~N files → X agents, estimated ~Ys\"\n\n**Step B0 - Check extraction cache first**\n\nBefore dispatching any subagents, check which files already have cached extraction results:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.cache import check_semantic_cache\nfrom pathlib import Path\n\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nall_files = [f for files in detect['files'].values() for f in files]\n\ncached_nodes, cached_edges, cached_hyperedges, uncached = check_semantic_cache(all_files)\n\nif cached_nodes or cached_edges or cached_hyperedges:\n    Path('graphify-out\u002F.graphify_cached.json').write_text(json.dumps({'nodes': cached_nodes, 'edges': cached_edges, 'hyperedges': cached_hyperedges}))\nPath('graphify-out\u002F.graphify_uncached.txt').write_text('\\n'.join(uncached))\nprint(f'Cache: {len(all_files)-len(uncached)} files hit, {len(uncached)} files need extraction')\n\"\n```\n\nOnly dispatch subagents for files listed in `graphify-out\u002F.graphify_uncached.txt`. If all files are cached, skip to Part C directly.\n\n**Step B1 - Split into chunks**\n\nLoad files from `graphify-out\u002F.graphify_uncached.txt`. Split into chunks of 20-25 files each. Each image gets its own chunk (vision needs separate context). When splitting, group files from the same directory together so related artifacts land in the same chunk and cross-file relationships are more likely to be extracted.\n\n**Step B2 - Dispatch ALL subagents in a single message**\n\nCall the Agent tool multiple times IN THE SAME RESPONSE - one call per chunk. This is the only way they run in parallel. If you make one Agent call, wait, then make another, you are doing it sequentially and defeating the purpose.\n\n**IMPORTANT - subagent type:** Always use `subagent_type=\"general-purpose\"`. Do NOT use `Explore` - it is read-only and cannot write chunk files to disk, which silently drops extraction results. General-purpose has Write and Bash access which the subagent needs.\n\nConcrete example for 3 chunks:\n```\n[Agent tool call 1: files 1-15, subagent_type=\"general-purpose\"]\n[Agent tool call 2: files 16-30, subagent_type=\"general-purpose\"]\n[Agent tool call 3: files 31-45, subagent_type=\"general-purpose\"]\n```\nAll three in one message. Not three separate messages.\n\nEach subagent receives this exact prompt (substitute FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, and DEEP_MODE):\n\n```\nYou are a graphify extraction subagent. Read the files listed and extract a knowledge graph fragment.\nOutput ONLY valid JSON matching the schema below - no explanation, no markdown fences, no preamble.\n\nFiles (chunk CHUNK_NUM of TOTAL_CHUNKS):\nFILE_LIST\n\nRules:\n- EXTRACTED: relationship explicit in source (import, call, citation, \"see §3.2\")\n- INFERRED: reasonable inference (shared data structure, implied dependency)\n- AMBIGUOUS: uncertain - flag for review, do not omit\n\nCode files: focus on semantic edges AST cannot find (call relationships, shared data, arch patterns).\n  Do not re-extract imports - AST already has those.\nDoc\u002Fpaper files: extract named concepts, entities, citations. Also extract rationale — sections that explain WHY a decision was made, trade-offs chosen, or design intent. These become nodes with `rationale_for` edges pointing to the concept they explain.\nImage files: use vision to understand what the image IS - do not just OCR.\n  UI screenshot: layout patterns, design decisions, key elements, purpose.\n  Chart: metric, trend\u002Finsight, data source.\n  Tweet\u002Fpost: claim as node, author, concepts mentioned.\n  Diagram: components and connections.\n  Research figure: what it demonstrates, method, result.\n  Handwritten\u002Fwhiteboard: ideas and arrows, mark uncertain readings AMBIGUOUS.\n\nDEEP_MODE (if --mode deep was given): be aggressive with INFERRED edges - indirect deps,\n  shared assumptions, latent couplings. Mark uncertain ones AMBIGUOUS instead of omitting.\n\nSemantic similarity: if two concepts in this chunk solve the same problem or represent the same idea without any structural link (no import, no call, no citation), add a `semantically_similar_to` edge marked INFERRED with a confidence_score reflecting how similar they are (0.6-0.95). Examples:\n- Two functions that both validate user input but never call each other\n- A class in code and a concept in a paper that describe the same algorithm\n- Two error types that handle the same failure mode differently\nOnly add these when the similarity is genuinely non-obvious and cross-cutting. Do not add them for trivially similar things.\n\nHyperedges: if 3 or more nodes clearly participate together in a shared concept, flow, or pattern that is not captured by pairwise edges alone, add a hyperedge to a top-level `hyperedges` array. Examples:\n- All classes that implement a common protocol or interface\n- All functions in an authentication flow (even if they don't all call each other)\n- All concepts from a paper section that form one coherent idea\nUse sparingly — only when the group relationship adds information beyond the pairwise edges. Maximum 3 hyperedges per chunk.\n\nIf a file has YAML frontmatter (--- ... ---), copy source_url, captured_at, author,\n  contributor onto every node from that file.\n\nconfidence_score is REQUIRED on every edge - never omit it, never use 0.5 as a default:\n- EXTRACTED edges: confidence_score = 1.0 always\n- INFERRED edges: reason about each edge individually.\n  Direct structural evidence (shared data structure, clear dependency): 0.8-0.9.\n  Reasonable inference with some uncertainty: 0.6-0.7.\n  Weak or speculative: 0.4-0.5. Most edges should be 0.6-0.9, not 0.5.\n- AMBIGUOUS edges: 0.1-0.3\n\nNode ID format: lowercase, only `[a-z0-9_]`, no dots or slashes. Format: `{stem}_{entity}` where stem is the filename without extension and entity is the symbol name, both normalized (lowercase, non-alphanumeric chars replaced with `_`). Example: `src\u002Fauth\u002Fsession.py` + `ValidateToken` → `session_validatetoken`. This must match the ID the AST extractor generates so cross-references between code and semantic nodes connect correctly.\n\nOutput exactly this JSON (no other text):\n{\"nodes\":[{\"id\":\"session_validatetoken\",\"label\":\"Human Readable Name\",\"file_type\":\"code|document|paper|image\",\"source_file\":\"relative\u002Fpath\",\"source_location\":null,\"source_url\":null,\"captured_at\":null,\"author\":null,\"contributor\":null}],\"edges\":[{\"source\":\"node_id\",\"target\":\"node_id\",\"relation\":\"calls|implements|references|cites|conceptually_related_to|shares_data_with|semantically_similar_to|rationale_for\",\"confidence\":\"EXTRACTED|INFERRED|AMBIGUOUS\",\"confidence_score\":1.0,\"source_file\":\"relative\u002Fpath\",\"source_location\":null,\"weight\":1.0}],\"hyperedges\":[{\"id\":\"snake_case_id\",\"label\":\"Human Readable Label\",\"nodes\":[\"node_id1\",\"node_id2\",\"node_id3\"],\"relation\":\"participate_in|implement|form\",\"confidence\":\"EXTRACTED|INFERRED\",\"confidence_score\":0.75,\"source_file\":\"relative\u002Fpath\"}],\"input_tokens\":0,\"output_tokens\":0}\n```\n\n**Step B3 - Collect, cache, and merge**\n\nWait for all subagents. For each result:\n- Check that `graphify-out\u002F.graphify_chunk_NN.json` exists on disk — this is the success signal\n- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache\n- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: \"chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent.\" Do not silently skip.\n- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort\n\nIf more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type=\"general-purpose\"` is used.\n\nSave new results to cache:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.cache import save_semantic_cache\nfrom pathlib import Path\n\nnew = json.loads(Path('graphify-out\u002F.graphify_semantic_new.json').read_text()) if Path('graphify-out\u002F.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\nsaved = save_semantic_cache(new.get('nodes', []), new.get('edges', []), new.get('hyperedges', []))\nprint(f'Cached {saved} files')\n\"\n```\n\nMerge cached + new results into `graphify-out\u002F.graphify_semantic.json`:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\n\ncached = json.loads(Path('graphify-out\u002F.graphify_cached.json').read_text()) if Path('graphify-out\u002F.graphify_cached.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\nnew = json.loads(Path('graphify-out\u002F.graphify_semantic_new.json').read_text()) if Path('graphify-out\u002F.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\n\nall_nodes = cached['nodes'] + new.get('nodes', [])\nall_edges = cached['edges'] + new.get('edges', [])\nall_hyperedges = cached.get('hyperedges', []) + new.get('hyperedges', [])\nseen = set()\ndeduped = []\nfor n in all_nodes:\n    if n['id'] not in seen:\n        seen.add(n['id'])\n        deduped.append(n)\n\nmerged = {\n    'nodes': deduped,\n    'edges': all_edges,\n    'hyperedges': all_hyperedges,\n    'input_tokens': new.get('input_tokens', 0),\n    'output_tokens': new.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_semantic.json').write_text(json.dumps(merged, indent=2))\nprint(f'Extraction complete - {len(deduped)} nodes, {len(all_edges)} edges ({len(cached[\\\"nodes\\\"])} from cache, {len(new.get(\\\"nodes\\\",[]))} new)')\n\"\n```\nClean up temp files: `rm -f graphify-out\u002F.graphify_cached.json graphify-out\u002F.graphify_uncached.txt graphify-out\u002F.graphify_semantic_new.json`\n\n#### Part C - Merge AST + semantic into final extraction\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom pathlib import Path\n\nast = json.loads(Path('graphify-out\u002F.graphify_ast.json').read_text())\nsem = json.loads(Path('graphify-out\u002F.graphify_semantic.json').read_text())\n\n# Merge: AST nodes first, semantic nodes deduplicated by id\nseen = {n['id'] for n in ast['nodes']}\nmerged_nodes = list(ast['nodes'])\nfor n in sem['nodes']:\n    if n['id'] not in seen:\n        merged_nodes.append(n)\n        seen.add(n['id'])\n\nmerged_edges = ast['edges'] + sem['edges']\nmerged_hyperedges = sem.get('hyperedges', [])\nmerged = {\n    'nodes': merged_nodes,\n    'edges': merged_edges,\n    'hyperedges': merged_hyperedges,\n    'input_tokens': sem.get('input_tokens', 0),\n    'output_tokens': sem.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_extract.json').write_text(json.dumps(merged, indent=2))\ntotal = len(merged_nodes)\nedges = len(merged_edges)\nprint(f'Merged: {total} nodes, {edges} edges ({len(ast[\\\"nodes\\\"])} AST + {len(sem[\\\"nodes\\\"])} semantic)')\n\"\n```\n\n### Step 4 - Build graph, cluster, analyze, generate outputs\n\n**Before starting:** note whether `--directed` was given. If so, pass `directed=True` to `build_from_json()` in the code block below. This builds a `DiGraph` that preserves edge direction (source→target) instead of the default undirected `Graph`.\n\n```bash\nmkdir -p graphify-out\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import cluster, score_all\nfrom graphify.analyze import god_nodes, surprising_connections, suggest_questions\nfrom graphify.report import generate\nfrom graphify.export import to_json\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\ndetection  = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\n\nG = build_from_json(extraction)\ncommunities = cluster(G)\ncohesion = score_all(G, communities)\ntokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}\ngods = god_nodes(G)\nsurprises = surprising_connections(G, communities)\nlabels = {cid: 'Community ' + str(cid) for cid in communities}\n# Placeholder questions - regenerated with real labels in Step 5\nquestions = suggest_questions(G, communities, labels)\n\nreport = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, 'INPUT_PATH', suggested_questions=questions)\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report)\nto_json(G, communities, 'graphify-out\u002Fgraph.json')\n\nanalysis = {\n    'communities': {str(k): v for k, v in communities.items()},\n    'cohesion': {str(k): v for k, v in cohesion.items()},\n    'gods': gods,\n    'surprises': surprises,\n    'questions': questions,\n}\nPath('graphify-out\u002F.graphify_analysis.json').write_text(json.dumps(analysis, indent=2))\nif G.number_of_nodes() == 0:\n    print('ERROR: Graph is empty - extraction produced no nodes.')\n    print('Possible causes: all files were skipped, binary-only corpus, or extraction failed.')\n    raise SystemExit(1)\nprint(f'Graph: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges, {len(communities)} communities')\n\"\n```\n\nIf this step prints `ERROR: Graph is empty`, stop and tell the user what happened - do not proceed to labeling or visualization.\n\nReplace INPUT_PATH with the actual path.\n\n### Step 5 - Label communities\n\nRead `graphify-out\u002F.graphify_analysis.json`. For each community key, look at its node labels and write a 2-5 word plain-language name (e.g. \"Attention Mechanism\", \"Training Pipeline\", \"Data Loading\").\n\nThen regenerate the report and save the labels for the visualizer:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import score_all\nfrom graphify.analyze import god_nodes, surprising_connections, suggest_questions\nfrom graphify.report import generate\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\ndetection  = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\ncohesion = {int(k): v for k, v in analysis['cohesion'].items()}\ntokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}\n\n# LABELS - replace these with the names you chose above\nlabels = LABELS_DICT\n\n# Regenerate questions with real community labels (labels affect question phrasing)\nquestions = suggest_questions(G, communities, labels)\n\nreport = generate(G, communities, cohesion, labels, analysis['gods'], analysis['surprises'], detection, tokens, 'INPUT_PATH', suggested_questions=questions)\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report)\nPath('graphify-out\u002F.graphify_labels.json').write_text(json.dumps({str(k): v for k, v in labels.items()}))\nprint('Report updated with community labels')\n\"\n```\n\nReplace `LABELS_DICT` with the actual dict you constructed (e.g. `{0: \"Attention Mechanism\", 1: \"Training Pipeline\"}`).\nReplace INPUT_PATH with the actual path.\n\n### Step 6 - Generate Obsidian vault (opt-in) + HTML\n\n**Generate HTML always** (unless `--no-viz`). **Obsidian vault only if `--obsidian` was explicitly given** — skip it otherwise, it generates one file per node.\n\nIf `--obsidian` was given:\n\n- If `--obsidian-dir \u003Cpath>` was also given, use that path as the vault directory. Otherwise default to `graphify-out\u002Fobsidian`.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_obsidian, to_canvas\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nlabels_raw = json.loads(Path('graphify-out\u002F.graphify_labels.json').read_text()) if Path('graphify-out\u002F.graphify_labels.json').exists() else {}\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\ncohesion = {int(k): v for k, v in analysis['cohesion'].items()}\nlabels = {int(k): v for k, v in labels_raw.items()}\n\nobsidian_dir = 'OBSIDIAN_DIR'  # replace with --obsidian-dir value, or 'graphify-out\u002Fobsidian' if not given\n\nn = to_obsidian(G, communities, obsidian_dir, community_labels=labels or None, cohesion=cohesion)\nprint(f'Obsidian vault: {n} notes in {obsidian_dir}\u002F')\n\nto_canvas(G, communities, f'{obsidian_dir}\u002Fgraph.canvas', community_labels=labels or None)\nprint(f'Canvas: {obsidian_dir}\u002Fgraph.canvas - open in Obsidian for structured community layout')\nprint()\nprint(f'Open {obsidian_dir}\u002F as a vault in Obsidian.')\nprint('  Graph view   - nodes colored by community (set automatically)')\nprint('  graph.canvas - structured layout with communities as groups')\nprint('  _COMMUNITY_* - overview notes with cohesion scores and dataview queries')\n\"\n```\n\nGenerate the HTML graph (always, unless `--no-viz`):\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_html\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nlabels_raw = json.loads(Path('graphify-out\u002F.graphify_labels.json').read_text()) if Path('graphify-out\u002F.graphify_labels.json').exists() else {}\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\nlabels = {int(k): v for k, v in labels_raw.items()}\n\nif G.number_of_nodes() > 5000:\n    print(f'Graph has {G.number_of_nodes()} nodes - too large for HTML viz. Use Obsidian vault instead.')\nelse:\n    to_html(G, communities, 'graphify-out\u002Fgraph.html', community_labels=labels or None)\n    print('graph.html written - open in any browser, no server needed')\n\"\n```\n\n### Step 6b - Wiki (only if --wiki flag)\n\n**Only run this step if `--wiki` was explicitly given in the original command.**\n\nRun this before Step 9 (cleanup) so `.graphify_labels.json` is still available.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.build import build_from_json\nfrom graphify.wiki import to_wiki\nfrom graphify.analyze import god_nodes\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nlabels_raw = json.loads(Path('graphify-out\u002F.graphify_labels.json').read_text()) if Path('graphify-out\u002F.graphify_labels.json').exists() else {}\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\ncohesion = {int(k): v for k, v in analysis['cohesion'].items()}\nlabels = {int(k): v for k, v in labels_raw.items()}\ngods = god_nodes(G)\n\nn = to_wiki(G, communities, 'graphify-out\u002Fwiki', community_labels=labels or None, cohesion=cohesion, god_nodes_data=gods)\nprint(f'Wiki: {n} articles written to graphify-out\u002Fwiki\u002F')\nprint('  graphify-out\u002Fwiki\u002Findex.md  ->  agent entry point')\n\"\n```\n\n### Step 7 - Neo4j export (only if --neo4j or --neo4j-push flag)\n\n**If `--neo4j`** - generate a Cypher file for manual import:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_cypher\nfrom pathlib import Path\n\nG = build_from_json(json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text()))\nto_cypher(G, 'graphify-out\u002Fcypher.txt')\nprint('cypher.txt written - import with: cypher-shell \u003C graphify-out\u002Fcypher.txt')\n\"\n```\n\n**If `--neo4j-push \u003Curi>`** - push directly to a running Neo4j instance. Ask the user for credentials if not provided:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import cluster\nfrom graphify.export import push_to_neo4j\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\n\nresult = push_to_neo4j(G, uri='NEO4J_URI', user='NEO4J_USER', password='NEO4J_PASSWORD', communities=communities)\nprint(f'Pushed to Neo4j: {result[\\\"nodes\\\"]} nodes, {result[\\\"edges\\\"]} edges')\n\"\n```\n\nReplace `NEO4J_URI`, `NEO4J_USER`, `NEO4J_PASSWORD` with actual values. Default URI is `bolt:\u002F\u002Flocalhost:7687`, default user is `neo4j`. Uses MERGE - safe to re-run without creating duplicates.\n\n### Step 7b - SVG export (only if --svg flag)\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_svg\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nlabels_raw = json.loads(Path('graphify-out\u002F.graphify_labels.json').read_text()) if Path('graphify-out\u002F.graphify_labels.json').exists() else {}\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\nlabels = {int(k): v for k, v in labels_raw.items()}\n\nto_svg(G, communities, 'graphify-out\u002Fgraph.svg', community_labels=labels or None)\nprint('graph.svg written - embeds in Obsidian, Notion, GitHub READMEs')\n\"\n```\n\n### Step 7c - GraphML export (only if --graphml flag)\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_graphml\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\n\nto_graphml(G, communities, 'graphify-out\u002Fgraph.graphml')\nprint('graph.graphml written - open in Gephi, yEd, or any GraphML tool')\n\"\n```\n\n### Step 7d - MCP server (only if --mcp flag)\n\n```bash\npython3 -m graphify.serve graphify-out\u002Fgraph.json\n```\n\nThis starts a stdio MCP server that exposes tools: `query_graph`, `get_node`, `get_neighbors`, `get_community`, `god_nodes`, `graph_stats`, `shortest_path`. Add to Claude Desktop or any MCP-compatible agent orchestrator so other agents can query the graph live.\n\nTo configure in Claude Desktop, add to `claude_desktop_config.json`:\n```json\n{\n  \"mcpServers\": {\n    \"graphify\": {\n      \"command\": \"python3\",\n      \"args\": [\"-m\", \"graphify.serve\", \"\u002Fabsolute\u002Fpath\u002Fto\u002Fgraphify-out\u002Fgraph.json\"]\n    }\n  }\n}\n```\n\n### Step 8 - Token reduction benchmark (only if total_words > 5000)\n\nIf `total_words` from `graphify-out\u002F.graphify_detect.json` is greater than 5,000, run:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.benchmark import run_benchmark, print_benchmark\nfrom pathlib import Path\n\ndetection = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nresult = run_benchmark('graphify-out\u002Fgraph.json', corpus_words=detection['total_words'])\nprint_benchmark(result)\n\"\n```\n\nPrint the output directly in chat. If `total_words \u003C= 5000`, skip silently - the graph value is structural clarity, not token compression, for small corpora.\n\n---\n\n### Step 9 - Save manifest, update cost tracker, clean up, and report\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\nfrom datetime import datetime, timezone\nfrom graphify.detect import save_manifest\n\n# Save manifest for --update\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nsave_manifest(detect['files'])\n\n# Update cumulative cost tracker\nextract = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\ninput_tok = extract.get('input_tokens', 0)\noutput_tok = extract.get('output_tokens', 0)\n\ncost_path = Path('graphify-out\u002Fcost.json')\nif cost_path.exists():\n    cost = json.loads(cost_path.read_text())\nelse:\n    cost = {'runs': [], 'total_input_tokens': 0, 'total_output_tokens': 0}\n\ncost['runs'].append({\n    'date': datetime.now(timezone.utc).isoformat(),\n    'input_tokens': input_tok,\n    'output_tokens': output_tok,\n    'files': detect.get('total_files', 0),\n})\ncost['total_input_tokens'] += input_tok\ncost['total_output_tokens'] += output_tok\ncost_path.write_text(json.dumps(cost, indent=2))\n\nprint(f'This run: {input_tok:,} input tokens, {output_tok:,} output tokens')\nprint(f'All time: {cost[\\\"total_input_tokens\\\"]:,} input, {cost[\\\"total_output_tokens\\\"]:,} output ({len(cost[\\\"runs\\\"])} runs)')\n\"\nrm -f graphify-out\u002F.graphify_detect.json graphify-out\u002F.graphify_extract.json graphify-out\u002F.graphify_ast.json graphify-out\u002F.graphify_semantic.json graphify-out\u002F.graphify_analysis.json graphify-out\u002F.graphify_labels.json\nrm -f graphify-out\u002F.needs_update 2>\u002Fdev\u002Fnull || true\n```\n\nTell the user (omit the obsidian line unless --obsidian was given):\n```\nGraph complete. Outputs in PATH_TO_DIR\u002Fgraphify-out\u002F\n\n  graph.html            - interactive graph, open in browser\n  GRAPH_REPORT.md       - audit report\n  graph.json            - raw graph data\n  obsidian\u002F             - Obsidian vault (only if --obsidian was given)\n```\n\nIf graphify saved you time, consider supporting it: https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fsafishamsi\n\nReplace PATH_TO_DIR with the actual absolute path of the directory that was processed.\n\nThen paste these sections from GRAPH_REPORT.md directly into the chat:\n- God Nodes\n- Surprising Connections\n- Suggested Questions\n\nDo NOT paste the full report - just those three sections. Keep it concise.\n\nThen immediately offer to explore. Pick the single most interesting suggested question from the report - the one that crosses the most community boundaries or has the most surprising bridge node - and ask:\n\n> \"The most interesting question this graph can answer: **[question]**. Want me to trace it?\"\n\nIf the user says yes, run `\u002Fgraphify query \"[question]\"` on the graph and walk them through the answer using the graph structure - which nodes connect, which community boundaries get crossed, what the path reveals. Keep going as long as they want to explore. Each answer should end with a natural follow-up (\"this connects to X - want to go deeper?\") so the session feels like navigation, not a one-shot report.\n\nThe graph is the map. Your job after the pipeline is to be the guide.\n\n---\n\n## Interpreter guard for subcommands\n\nBefore running any subcommand below (`--update`, `--cluster-only`, `query`, `path`, `explain`, `add`), check that `.graphify_python` exists. If it's missing (e.g. user deleted `graphify-out\u002F`), re-resolve the interpreter first:\n\n```bash\nif [ ! -f graphify-out\u002F.graphify_python ]; then\n    GRAPHIFY_BIN=$(which graphify 2>\u002Fdev\u002Fnull)\n    if [ -n \"$GRAPHIFY_BIN\" ]; then\n        PYTHON=$(head -1 \"$GRAPHIFY_BIN\" | tr -d '#!')\n        case \"$PYTHON\" in *[!a-zA-Z0-9\u002F_.-]*) PYTHON=\"python3\" ;; esac\n    else\n        PYTHON=\"python3\"\n    fi\n    mkdir -p graphify-out\n    \"$PYTHON\" -c \"import sys; open('graphify-out\u002F.graphify_python', 'w').write(sys.executable)\"\nfi\n```\n\n## For --update (incremental re-extraction)\n\nUse when you've added or modified files since the last run. Only re-extracts changed files - saves tokens and time.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.detect import detect_incremental, save_manifest\nfrom pathlib import Path\n\nresult = detect_incremental(Path('INPUT_PATH'))\nnew_total = result.get('new_total', 0)\nprint(json.dumps(result, indent=2))\nPath('graphify-out\u002F.graphify_incremental.json').write_text(json.dumps(result))\nif new_total == 0:\n    print('No files changed since last run. Nothing to update.')\n    raise SystemExit(0)\nprint(f'{new_total} new\u002Fchanged file(s) to re-extract.')\n\"\n```\n\nIf new files exist, first check whether all changed files are code files:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\n\nresult = json.loads(open('graphify-out\u002F.graphify_incremental.json').read()) if Path('graphify-out\u002F.graphify_incremental.json').exists() else {}\ncode_exts = {'.py','.ts','.js','.go','.rs','.java','.cpp','.c','.rb','.swift','.kt','.cs','.scala','.php','.cc','.cxx','.hpp','.h','.kts','.lua','.toc'}\nnew_files = result.get('new_files', {})\nall_changed = [f for files in new_files.values() for f in files]\ncode_only = all(Path(f).suffix.lower() in code_exts for f in all_changed)\nprint('code_only:', code_only)\n\"\n```\n\nIf `code_only` is True: print `[graphify update] Code-only changes detected - skipping semantic extraction (no LLM needed)`, run only Step 3A (AST) on the changed files, skip Step 3B entirely (no subagents), then go straight to merge and Steps 4–8.\n\nIf `code_only` is False (any changed file is a doc\u002Fpaper\u002Fimage): run the full Steps 3A–3C pipeline as normal.\n\nThen:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_json\nfrom networkx.readwrite import json_graph\nimport networkx as nx\nfrom pathlib import Path\n\n# Load existing graph\nexisting_data = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG_existing = json_graph.node_link_graph(existing_data, edges='links')\n\n# Load new extraction\nnew_extraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nG_new = build_from_json(new_extraction)\n\n# Prune nodes from deleted files\nincremental = json.loads(Path('graphify-out\u002F.graphify_incremental.json').read_text())\ndeleted = set(incremental.get('deleted_files', []))\nif deleted:\n    to_remove = [n for n, d in G_existing.nodes(data=True) if d.get('source_file') in deleted]\n    G_existing.remove_nodes_from(to_remove)\n    print(f'Pruned {len(to_remove)} ghost nodes from {len(deleted)} deleted file(s)')\n\n# Merge: new nodes\u002Fedges into existing graph\nG_existing.update(G_new)\nprint(f'Merged: {G_existing.number_of_nodes()} nodes, {G_existing.number_of_edges()} edges')\n\n# Write merged result back to .graphify_extract.json so Step 4 sees the full graph\nmerged_out = {\n    'nodes': [{'id': n, **d} for n, d in G_existing.nodes(data=True)],\n    'edges': [{'source': u, 'target': v, **d} for u, v, d in G_existing.edges(data=True)],\n    'hyperedges': new_extraction.get('hyperedges', []),\n    'input_tokens': new_extraction.get('input_tokens', 0),\n    'output_tokens': new_extraction.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_extract.json').write_text(json.dumps(merged_out))\nprint(f'[graphify update] Merged extraction written ({len(merged_out[\\\"nodes\\\"])} nodes, {len(merged_out[\\\"edges\\\"])} edges)')\n\" \n```\n\nThen run Steps 4–8 on the merged graph as normal.\n\nAfter Step 4, show the graph diff:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.analyze import graph_diff\nfrom graphify.build import build_from_json\nfrom networkx.readwrite import json_graph\nimport networkx as nx\nfrom pathlib import Path\n\n# Load old graph (before update) from backup written before merge\nold_data = json.loads(Path('graphify-out\u002F.graphify_old.json').read_text()) if Path('graphify-out\u002F.graphify_old.json').exists() else None\nnew_extract = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nG_new = build_from_json(new_extract)\n\nif old_data:\n    G_old = json_graph.node_link_graph(old_data, edges='links')\n    diff = graph_diff(G_old, G_new)\n    print(diff['summary'])\n    if diff['new_nodes']:\n        print('New nodes:', ', '.join(n['label'] for n in diff['new_nodes'][:5]))\n    if diff['new_edges']:\n        print('New edges:', len(diff['new_edges']))\n\"\n```\n\nBefore the merge step, save the old graph: `cp graphify-out\u002Fgraph.json graphify-out\u002F.graphify_old.json`\nClean up after: `rm -f graphify-out\u002F.graphify_old.json`\n\n---\n\n## For --cluster-only\n\nSkip Steps 1–3. Load the existing graph from `graphify-out\u002Fgraph.json` and re-run clustering:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.cluster import cluster, score_all\nfrom graphify.analyze import god_nodes, surprising_connections\nfrom graphify.report import generate\nfrom graphify.export import to_json\nfrom networkx.readwrite import json_graph\nimport networkx as nx\nfrom pathlib import Path\n\ndata = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG = json_graph.node_link_graph(data, edges='links')\n\ndetection = {'total_files': 0, 'total_words': 99999, 'needs_graph': True, 'warning': None,\n             'files': {'code': [], 'document': [], 'paper': []}}\ntokens = {'input': 0, 'output': 0}\n\ncommunities = cluster(G)\ncohesion = score_all(G, communities)\ngods = god_nodes(G)\nsurprises = surprising_connections(G, communities)\nlabels = {cid: 'Community ' + str(cid) for cid in communities}\n\nreport = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, '.')\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report)\nto_json(G, communities, 'graphify-out\u002Fgraph.json')\n\nanalysis = {\n    'communities': {str(k): v for k, v in communities.items()},\n    'cohesion': {str(k): v for k, v in cohesion.items()},\n    'gods': gods,\n    'surprises': surprises,\n}\nPath('graphify-out\u002F.graphify_analysis.json').write_text(json.dumps(analysis, indent=2))\nprint(f'Re-clustered: {len(communities)} communities')\n\"\n```\n\nThen run Steps 5–9 as normal (label communities, generate viz, benchmark, clean up, report).\n\n---\n\n## For \u002Fgraphify query\n\nTwo traversal modes - choose based on the question:\n\n| Mode | Flag | Best for |\n|------|------|----------|\n| BFS (default) | _(none)_ | \"What is X connected to?\" - broad context, nearest neighbors first |\n| DFS | `--dfs` | \"How does X reach Y?\" - trace a specific chain or dependency path |\n\nFirst check the graph exists:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nfrom pathlib import Path\nif not Path('graphify-out\u002Fgraph.json').exists():\n    print('ERROR: No graph found. Run \u002Fgraphify \u003Cpath> first to build the graph.')\n    raise SystemExit(1)\n\"\n```\nIf it fails, stop and tell the user to run `\u002Fgraphify \u003Cpath>` first.\n\nLoad `graphify-out\u002Fgraph.json`, then:\n\n1. Find the 1-3 nodes whose label best matches key terms in the question.\n2. Run the appropriate traversal from each starting node.\n3. Read the subgraph - node labels, edge relations, confidence tags, source locations.\n4. Answer using **only** what the graph contains. Quote `source_location` when citing a specific fact.\n5. If the graph lacks enough information, say so - do not hallucinate edges.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom networkx.readwrite import json_graph\nimport networkx as nx\nfrom pathlib import Path\n\ndata = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG = json_graph.node_link_graph(data, edges='links')\n\nquestion = 'QUESTION'\nmode = 'MODE'  # 'bfs' or 'dfs'\nterms = [t.lower() for t in question.split() if len(t) > 3]\n\n# Find best-matching start nodes\nscored = []\nfor nid, ndata in G.nodes(data=True):\n    label = ndata.get('label', '').lower()\n    score = sum(1 for t in terms if t in label)\n    if score > 0:\n        scored.append((score, nid))\nscored.sort(reverse=True)\nstart_nodes = [nid for _, nid in scored[:3]]\n\nif not start_nodes:\n    print('No matching nodes found for query terms:', terms)\n    sys.exit(0)\n\nsubgraph_nodes = set()\nsubgraph_edges = []\n\nif mode == 'dfs':\n    # DFS: follow one path as deep as possible before backtracking.\n    # Depth-limited to 6 to avoid traversing the whole graph.\n    visited = set()\n    stack = [(n, 0) for n in reversed(start_nodes)]\n    while stack:\n        node, depth = stack.pop()\n        if node in visited or depth > 6:\n            continue\n        visited.add(node)\n        subgraph_nodes.add(node)\n        for neighbor in G.neighbors(node):\n            if neighbor not in visited:\n                stack.append((neighbor, depth + 1))\n                subgraph_edges.append((node, neighbor))\nelse:\n    # BFS: explore all neighbors layer by layer up to depth 3.\n    frontier = set(start_nodes)\n    subgraph_nodes = set(start_nodes)\n    for _ in range(3):\n        next_frontier = set()\n        for n in frontier:\n            for neighbor in G.neighbors(n):\n                if neighbor not in subgraph_nodes:\n                    next_frontier.add(neighbor)\n                    subgraph_edges.append((n, neighbor))\n        subgraph_nodes.update(next_frontier)\n        frontier = next_frontier\n\n# Token-budget aware output: rank by relevance, cut at budget (~4 chars\u002Ftoken)\ntoken_budget = BUDGET  # default 2000\nchar_budget = token_budget * 4\n\n# Score each node by term overlap for ranked output\ndef relevance(nid):\n    label = G.nodes[nid].get('label', '').lower()\n    return sum(1 for t in terms if t in label)\n\nranked_nodes = sorted(subgraph_nodes, key=relevance, reverse=True)\n\nlines = [f'Traversal: {mode.upper()} | Start: {[G.nodes[n].get(\\\"label\\\",n) for n in start_nodes]} | {len(subgraph_nodes)} nodes']\nfor nid in ranked_nodes:\n    d = G.nodes[nid]\n    lines.append(f'  NODE {d.get(\\\"label\\\", nid)} [src={d.get(\\\"source_file\\\",\\\"\\\")} loc={d.get(\\\"source_location\\\",\\\"\\\")}]')\nfor u, v in subgraph_edges:\n    if u in subgraph_nodes and v in subgraph_nodes:\n        d = G.edges[u, v]\n        lines.append(f'  EDGE {G.nodes[u].get(\\\"label\\\",u)} --{d.get(\\\"relation\\\",\\\"\\\")} [{d.get(\\\"confidence\\\",\\\"\\\")}]--> {G.nodes[v].get(\\\"label\\\",v)}')\n\noutput = '\\n'.join(lines)\nif len(output) > char_budget:\n    output = output[:char_budget] + f'\\n... (truncated at ~{token_budget} token budget - use --budget N for more)'\nprint(output)\n\"\n```\n\nReplace `QUESTION` with the user's actual question, `MODE` with `bfs` or `dfs`, and `BUDGET` with the token budget (default `2000`, or whatever `--budget N` specifies). Then answer based on the subgraph output above.\n\nAfter writing the answer, save it back into the graph so it improves future queries:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -m graphify save-result --question \"QUESTION\" --answer \"ANSWER\" --type query --nodes NODE1 NODE2\n```\n\nReplace `QUESTION` with the question, `ANSWER` with your full answer text, `SOURCE_NODES` with the list of node labels you cited. This closes the feedback loop: the next `--update` will extract this Q&A as a node in the graph.\n\n---\n\n## For \u002Fgraphify path\n\nFind the shortest path between two named concepts in the graph.\n\nFirst check the graph exists:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nfrom pathlib import Path\nif not Path('graphify-out\u002Fgraph.json').exists():\n    print('ERROR: No graph found. Run \u002Fgraphify \u003Cpath> first to build the graph.')\n    raise SystemExit(1)\n\"\n```\nIf it fails, stop and tell the user to run `\u002Fgraphify \u003Cpath>` first.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json, sys\nimport networkx as nx\nfrom networkx.readwrite import json_graph\nfrom pathlib import Path\n\ndata = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG = json_graph.node_link_graph(data, edges='links')\n\na_term = 'NODE_A'\nb_term = 'NODE_B'\n\ndef find_node(term):\n    term = term.lower()\n    scored = sorted(\n        [(sum(1 for w in term.split() if w in G.nodes[n].get('label','').lower()), n)\n         for n in G.nodes()],\n        reverse=True\n    )\n    return scored[0][1] if scored and scored[0][0] > 0 else None\n\nsrc = find_node(a_term)\ntgt = find_node(b_term)\n\nif not src or not tgt:\n    print(f'Could not find nodes matching: {a_term!r} or {b_term!r}')\n    sys.exit(0)\n\ntry:\n    path = nx.shortest_path(G, src, tgt)\n    print(f'Shortest path ({len(path)-1} hops):')\n    for i, nid in enumerate(path):\n        label = G.nodes[nid].get('label', nid)\n        if i \u003C len(path) - 1:\n            edge = G.edges[nid, path[i+1]]\n            rel = edge.get('relation', '')\n            conf = edge.get('confidence', '')\n            print(f'  {label} --{rel}--> [{conf}]')\n        else:\n            print(f'  {label}')\nexcept nx.NetworkXNoPath:\n    print(f'No path found between {a_term!r} and {b_term!r}')\nexcept nx.NodeNotFound as e:\n    print(f'Node not found: {e}')\n\"\n```\n\nReplace `NODE_A` and `NODE_B` with the actual concept names from the user. Then explain the path in plain language - what each hop means, why it's significant.\n\nAfter writing the explanation, save it back:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -m graphify save-result --question \"Path from NODE_A to NODE_B\" --answer \"ANSWER\" --type path_query --nodes NODE_A NODE_B\n```\n\n---\n\n## For \u002Fgraphify explain\n\nGive a plain-language explanation of a single node - everything connected to it.\n\nFirst check the graph exists:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nfrom pathlib import Path\nif not Path('graphify-out\u002Fgraph.json').exists():\n    print('ERROR: No graph found. Run \u002Fgraphify \u003Cpath> first to build the graph.')\n    raise SystemExit(1)\n\"\n```\nIf it fails, stop and tell the user to run `\u002Fgraphify \u003Cpath>` first.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json, sys\nimport networkx as nx\nfrom networkx.readwrite import json_graph\nfrom pathlib import Path\n\ndata = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG = json_graph.node_link_graph(data, edges='links')\n\nterm = 'NODE_NAME'\nterm_lower = term.lower()\n\n# Find best matching node\nscored = sorted(\n    [(sum(1 for w in term_lower.split() if w in G.nodes[n].get('label','').lower()), n)\n     for n in G.nodes()],\n    reverse=True\n)\nif not scored or scored[0][0] == 0:\n    print(f'No node matching {term!r}')\n    sys.exit(0)\n\nnid = scored[0][1]\ndata_n = G.nodes[nid]\nprint(f'NODE: {data_n.get(\\\"label\\\", nid)}')\nprint(f'  source: {data_n.get(\\\"source_file\\\",\\\"unknown\\\")}')\nprint(f'  type: {data_n.get(\\\"file_type\\\",\\\"unknown\\\")}')\nprint(f'  degree: {G.degree(nid)}')\nprint()\nprint('CONNECTIONS:')\nfor neighbor in G.neighbors(nid):\n    edge = G.edges[nid, neighbor]\n    nlabel = G.nodes[neighbor].get('label', neighbor)\n    rel = edge.get('relation', '')\n    conf = edge.get('confidence', '')\n    src_file = G.nodes[neighbor].get('source_file', '')\n    print(f'  --{rel}--> {nlabel} [{conf}] ({src_file})')\n\"\n```\n\nReplace `NODE_NAME` with the concept the user asked about. Then write a 3-5 sentence explanation of what this node is, what it connects to, and why those connections are significant. Use the source locations as citations.\n\nAfter writing the explanation, save it back:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -m graphify save-result --question \"Explain NODE_NAME\" --answer \"ANSWER\" --type explain --nodes NODE_NAME\n```\n\n---\n\n## For \u002Fgraphify add\n\nFetch a URL and add it to the corpus, then update the graph.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys\nfrom graphify.ingest import ingest\nfrom pathlib import Path\n\ntry:\n    out = ingest('URL', Path('.\u002Fraw'), author='AUTHOR', contributor='CONTRIBUTOR')\n    print(f'Saved to {out}')\nexcept ValueError as e:\n    print(f'error: {e}', file=sys.stderr)\n    sys.exit(1)\nexcept RuntimeError as e:\n    print(f'error: {e}', file=sys.stderr)\n    sys.exit(1)\n\"\n```\n\nReplace `URL` with the actual URL, `AUTHOR` with the user's name if provided, `CONTRIBUTOR` likewise. If the command exits with an error, tell the user what went wrong - do not silently continue. After a successful save, automatically run the `--update` pipeline on `.\u002Fraw` to merge the new file into the existing graph.\n\nSupported URL types (auto-detected):\n- YouTube \u002F any video URL → audio downloaded via yt-dlp, transcribed to `.txt` on next run (requires `pip install 'graphifyy[video]'`)\n- Twitter\u002FX → fetched via oEmbed, saved as `.md` with tweet text and author\n- arXiv → abstract + metadata saved as `.md`\n- PDF → downloaded as `.pdf`\n- Images (.png\u002F.jpg\u002F.webp) → downloaded, Claude vision extracts on next run\n- Any webpage → converted to markdown via html2text\n\n---\n\n## For --watch\n\nStart a background watcher that monitors a folder and auto-updates the graph when files change.\n\n```bash\npython3 -m graphify.watch INPUT_PATH --debounce 3\n```\n\nReplace INPUT_PATH with the folder to watch. Behavior depends on what changed:\n\n- **Code files only (.py, .ts, .go, etc.):** re-runs AST extraction + rebuild + cluster immediately, no LLM needed. `graph.json` and `GRAPH_REPORT.md` are updated automatically.\n- **Docs, papers, or images:** writes a `graphify-out\u002Fneeds_update` flag and prints a notification to run `\u002Fgraphify --update` (LLM semantic re-extraction required).\n\nDebounce (default 3s): waits until file activity stops before triggering, so a wave of parallel agent writes doesn't trigger a rebuild per file.\n\nPress Ctrl+C to stop.\n\nFor agentic workflows: run `--watch` in a background terminal. Code changes from agent waves are picked up automatically between waves. If agents are also writing docs or notes, you'll need a manual `\u002Fgraphify --update` after those waves.\n\n---\n\n## For git commit hook\n\nInstall a post-commit hook that auto-rebuilds the graph after every commit. No background process needed - triggers once per commit, works with any editor.\n\n```bash\ngraphify hook install    # install\ngraphify hook uninstall  # remove\ngraphify hook status     # check\n```\n\nAfter every `git commit`, the hook detects which code files changed (via `git diff HEAD~1`), re-runs AST extraction on those files, and rebuilds `graph.json` and `GRAPH_REPORT.md`. Doc\u002Fimage changes are ignored by the hook - run `\u002Fgraphify --update` manually for those.\n\nIf a post-commit hook already exists, graphify appends to it rather than replacing it.\n\n---\n\n## For native CLAUDE.md integration\n\nRun once per project to make graphify always-on in Claude Code sessions:\n\n```bash\ngraphify claude install\n```\n\nThis writes a `## graphify` section to the local `CLAUDE.md` that instructs Claude to check the graph before answering codebase questions and rebuild it after code changes. No manual `\u002Fgraphify` needed in future sessions.\n\n```bash\ngraphify claude uninstall  # remove the section\n```\n\n---\n\n## Honesty Rules\n\n- Never invent an edge. If unsure, use AMBIGUOUS.\n- Never skip the corpus check warning.\n- Always show token cost in the report.\n- Never hide cohesion scores behind symbols - show the raw number.\n- Never run HTML viz on a graph with more than 5,000 nodes without warning the user.\n","# \u002Fgraphify\n\nTurn any folder of files into a navigable knowledge graph with community detection, an honest audit trail, and three outputs: interactive HTML, GraphRAG-ready JSON, and a plain-language GRAPH_REPORT.md.\n\n## Usage\n\n```\n\u002Fgraphify                                             # full pipeline on current directory → Obsidian vault\n\u002Fgraphify \u003Cpath>                                      # full pipeline on specific path\n\u002Fgraphify \u003Cpath> --mode deep                          # thorough extraction, richer INFERRED edges\n\u002Fgraphify \u003Cpath> --update                             # incremental - re-extract only new\u002Fchanged files\n\u002Fgraphify \u003Cpath> --directed                            # build directed graph (preserves edge direction: source→target)\n\u002Fgraphify \u003Cpath> --whisper-model medium                # use a larger Whisper model for better transcription accuracy\n\u002Fgraphify \u003Cpath> --cluster-only                       # rerun clustering on existing graph\n\u002Fgraphify \u003Cpath> --no-viz                             # skip visualization, just report + JSON\n\u002Fgraphify \u003Cpath> --html                               # (HTML is generated by default - this flag is a no-op)\n\u002Fgraphify \u003Cpath> --svg                                # also export graph.svg (embeds in Notion, GitHub)\n\u002Fgraphify \u003Cpath> --graphml                            # export graph.graphml (Gephi, yEd)\n\u002Fgraphify \u003Cpath> --neo4j                              # generate graphify-out\u002Fcypher.txt for Neo4j\n\u002Fgraphify \u003Cpath> --neo4j-push bolt:\u002F\u002Flocalhost:7687   # push directly to Neo4j\n\u002Fgraphify \u003Cpath> --mcp                                # start MCP stdio server for agent access\n\u002Fgraphify \u003Cpath> --watch                              # watch folder, auto-rebuild on code changes (no LLM needed)\n\u002Fgraphify \u003Cpath> --wiki                               # build agent-crawlable wiki (index.md + one article per community)\n\u002Fgraphify \u003Cpath> --obsidian --obsidian-dir ~\u002Fvaults\u002Fmy-project  # write vault to custom path (e.g. existing vault)\n\u002Fgraphify add \u003Curl>                                   # fetch URL, save to .\u002Fraw, update graph\n\u002Fgraphify add \u003Curl> --author \"Name\"                   # tag who wrote it\n\u002Fgraphify add \u003Curl> --contributor \"Name\"              # tag who added it to the corpus\n\u002Fgraphify query \"\u003Cquestion>\"                          # BFS traversal - broad context\n\u002Fgraphify query \"\u003Cquestion>\" --dfs                    # DFS - trace a specific path\n\u002Fgraphify query \"\u003Cquestion>\" --budget 1500            # cap answer at N tokens\n\u002Fgraphify path \"AuthModule\" \"Database\"                # shortest path between two concepts\n\u002Fgraphify explain \"SwinTransformer\"                   # plain-language explanation of a node\n```\n\n## What graphify is for\n\ngraphify is built around Andrej Karpathy's \u002Fraw folder workflow: drop anything into a folder - papers, tweets, screenshots, code, notes - and get a structured knowledge graph that shows you what you didn't know was connected.\n\nThree things it does that Claude alone cannot:\n1. **Persistent graph** - relationships are stored in `graphify-out\u002Fgraph.json` and survive across sessions. Ask questions weeks later without re-reading everything.\n2. **Honest audit trail** - every edge is tagged EXTRACTED, INFERRED, or AMBIGUOUS. You know what was found vs invented.\n3. **Cross-document surprise** - community detection finds connections between concepts in different files that you would never think to ask about directly.\n\nUse it for:\n- A codebase you're new to (understand architecture before touching anything)\n- A reading list (papers + tweets + notes → one navigable graph)\n- A research corpus (citation graph + concept graph in one)\n- Your personal \u002Fraw folder (drop everything in, let it grow, query it)\n\n## What You Must Do When Invoked\n\nIf no path was given, use `.` (current directory). Do not ask the user for a path.\n\nFollow these steps in order. Do not skip steps.\n\n### Step 1 - Ensure graphify is installed\n\n```bash\n# Detect the correct Python interpreter (handles pipx, venv, system installs)\nGRAPHIFY_BIN=$(which graphify 2>\u002Fdev\u002Fnull)\nif [ -n \"$GRAPHIFY_BIN\" ]; then\n    PYTHON=$(head -1 \"$GRAPHIFY_BIN\" | tr -d '#!')\n    case \"$PYTHON\" in\n        *[!a-zA-Z0-9\u002F_.-]*) PYTHON=\"python3\" ;;\n    esac\nelse\n    PYTHON=\"python3\"\nfi\n\"$PYTHON\" -c \"import graphify\" 2>\u002Fdev\u002Fnull || \"$PYTHON\" -m pip install graphifyy -q 2>\u002Fdev\u002Fnull || \"$PYTHON\" -m pip install graphifyy -q --break-system-packages 2>&1 | tail -3\n# Write interpreter path for all subsequent steps (persists across invocations)\nmkdir -p graphify-out\n\"$PYTHON\" -c \"import sys; open('graphify-out\u002F.graphify_python', 'w').write(sys.executable)\"\n```\n\nIf the import succeeds, print nothing and move straight to Step 2.\n\n**In every subsequent bash block, replace `python3` with `$(cat graphify-out\u002F.graphify_python)` to use the correct interpreter.**\n\n### Step 2 - Detect files\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.detect import detect\nfrom pathlib import Path\nresult = detect(Path('INPUT_PATH'))\nprint(json.dumps(result))\n\" > graphify-out\u002F.graphify_detect.json\n```\n\nReplace INPUT_PATH with the actual path the user provided. Do NOT cat or print the JSON - read it silently and present a clean summary instead:\n\n```\nCorpus: X files · ~Y words\n  code:     N files (.py .ts .go ...)\n  docs:     N files (.md .txt ...)\n  papers:   N files (.pdf ...)\n  images:   N files\n  video:    N files (.mp4 .mp3 ...)\n```\n\nOmit any category with 0 files from the summary.\n\nThen act on it:\n- If `total_files` is 0: stop with \"No supported files found in [path].\"\n- If `skipped_sensitive` is non-empty: mention file count skipped, not the file names.\n- If `total_words` > 2,000,000 OR `total_files` > 200: show the warning and the top 5 subdirectories by file count, then ask which subfolder to run on. Wait for the user's answer before proceeding.\n- Otherwise: proceed directly to Step 2.5 if video files were detected, or Step 3 if not.\n\n### Step 2.5 - Transcribe video \u002F audio files (only if video files detected)\n\nSkip this step entirely if `detect` returned zero `video` files.\n\nVideo and audio files cannot be read directly. Transcribe them to text first, then treat the transcripts as doc files in Step 3.\n\n**Strategy:** Read the god nodes from `graphify-out\u002F.graphify_detect.json` (or the analysis file if it exists from a previous run). You are already a language model — write a one-sentence domain hint yourself from those labels. Then pass it to Whisper as the initial prompt. No separate API call needed.\n\n**However**, if the corpus has *only* video files and no other docs\u002Fcode, use the generic fallback prompt: `\"Use proper punctuation and paragraph breaks.\"`\n\n**Step 1 - Write the Whisper prompt yourself.**\n\nRead the top god node labels from detect output or analysis, then compose a short domain hint sentence, for example:\n\n- Labels: `transformer, attention, encoder, decoder` → `\"Machine learning research on transformer architectures and attention mechanisms. Use proper punctuation and paragraph breaks.\"`\n- Labels: `kubernetes, deployment, pod, helm` → `\"DevOps discussion about Kubernetes deployments and Helm charts. Use proper punctuation and paragraph breaks.\"`\n\nSet it as `WHISPER_PROMPT` to use in the next command.\n\n**Step 2 - Transcribe:**\n\n```bash\nGRAPHIFY_WHISPER_MODEL=base  # or whatever --whisper-model the user passed\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json, os\nfrom pathlib import Path\nfrom graphify.transcribe import transcribe_all\n\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nvideo_files = detect.get('files', {}).get('video', [])\nprompt = os.environ.get('GRAPHIFY_WHISPER_PROMPT', 'Use proper punctuation and paragraph breaks.')\n\ntranscript_paths = transcribe_all(video_files, initial_prompt=prompt)\nprint(json.dumps(transcript_paths))\n\" > graphify-out\u002F.graphify_transcripts.json\n```\n\nAfter transcription:\n- Read the transcript paths from `graphify-out\u002F.graphify_transcripts.json`\n- Add them to the docs list before dispatching semantic subagents in Step 3B\n- Print how many transcripts were created: `Transcribed N video file(s) -> treating as docs`\n- If transcription fails for a file, print a warning and continue with the rest\n\n**Whisper model:** Default is `base`. If the user passed `--whisper-model \u003Cname>`, set `GRAPHIFY_WHISPER_MODEL=\u003Cname>` in the environment before running the command above.\n\n### Step 3 - Extract entities and relationships\n\n**Before starting:** note whether `--mode deep` was given. You must pass `DEEP_MODE=true` to every subagent in Step B2 if it was. Track this from the original invocation - do not lose it.\n\nThis step has two parts: **structural extraction** (deterministic, free) and **semantic extraction** (Claude, costs tokens).\n\n**Run Part A (AST) and Part B (semantic) in parallel. Dispatch all semantic subagents AND start AST extraction in the same message. Both can run simultaneously since they operate on different file types. Merge results in Part C as before.**\n\nNote: Parallelizing AST + semantic saves 5-15s on large corpora. AST is deterministic and fast; start it while subagents are processing docs\u002Fpapers.\n\n#### Part A - Structural extraction for code files\n\nFor any code files detected, run AST extraction in parallel with Part B subagents:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.extract import collect_files, extract\nfrom pathlib import Path\nimport json\n\ncode_files = []\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nfor f in detect.get('files', {}).get('code', []):\n    code_files.extend(collect_files(Path(f)) if Path(f).is_dir() else [Path(f)])\n\nif code_files:\n    result = extract(code_files, cache_root=Path('.'))\n    Path('graphify-out\u002F.graphify_ast.json').write_text(json.dumps(result, indent=2))\n    print(f'AST: {len(result[\\\"nodes\\\"])} nodes, {len(result[\\\"edges\\\"])} edges')\nelse:\n    Path('graphify-out\u002F.graphify_ast.json').write_text(json.dumps({'nodes':[],'edges':[],'input_tokens':0,'output_tokens':0}))\n    print('No code files - skipping AST extraction')\n\"\n```\n\n#### Part B - Semantic extraction (parallel subagents)\n\n**Fast path:** If detection found zero docs, papers, and images (code-only corpus), skip Part B entirely and go straight to Part C. AST handles code - there is nothing for semantic subagents to do.\n\n**MANDATORY: You MUST use the Agent tool here. Reading files yourself one-by-one is forbidden - it is 5-10x slower. If you do not use the Agent tool you are doing this wrong.**\n\nBefore dispatching subagents, print a timing estimate:\n- Load `total_words` and file counts from `graphify-out\u002F.graphify_detect.json`\n- Estimate agents needed: `ceil(uncached_non_code_files \u002F 22)` (chunk size is 20-25)\n- Estimate time: ~45s per agent batch (they run in parallel, so total ≈ 45s × ceil(agents\u002Fparallel_limit))\n- Print: \"Semantic extraction: ~N files → X agents, estimated ~Ys\"\n\n**Step B0 - Check extraction cache first**\n\nBefore dispatching any subagents, check which files already have cached extraction results:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.cache import check_semantic_cache\nfrom pathlib import Path\n\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nall_files = [f for files in detect['files'].values() for f in files]\n\ncached_nodes, cached_edges, cached_hyperedges, uncached = check_semantic_cache(all_files)\n\nif cached_nodes or cached_edges or cached_hyperedges:\n    Path('graphify-out\u002F.graphify_cached.json').write_text(json.dumps({'nodes': cached_nodes, 'edges': cached_edges, 'hyperedges': cached_hyperedges}))\nPath('graphify-out\u002F.graphify_uncached.txt').write_text('\\n'.join(uncached))\nprint(f'Cache: {len(all_files)-len(uncached)} files hit, {len(uncached)} files need extraction')\n\"\n```\n\nOnly dispatch subagents for files listed in `graphify-out\u002F.graphify_uncached.txt`. If all files are cached, skip to Part C directly.\n\n**Step B1 - Split into chunks**\n\nLoad files from `graphify-out\u002F.graphify_uncached.txt`. Split into chunks of 20-25 files each. Each image gets its own chunk (vision needs separate context). When splitting, group files from the same directory together so related artifacts land in the same chunk and cross-file relationships are more likely to be extracted.\n\n**Step B2 - Dispatch ALL subagents in a single message**\n\nCall the Agent tool multiple times IN THE SAME RESPONSE - one call per chunk. This is the only way they run in parallel. If you make one Agent call, wait, then make another, you are doing it sequentially and defeating the purpose.\n\n**IMPORTANT - subagent type:** Always use `subagent_type=\"general-purpose\"`. Do NOT use `Explore` - it is read-only and cannot write chunk files to disk, which silently drops extraction results. General-purpose has Write and Bash access which the subagent needs.\n\nConcrete example for 3 chunks:\n```\n[Agent tool call 1: files 1-15, subagent_type=\"general-purpose\"]\n[Agent tool call 2: files 16-30, subagent_type=\"general-purpose\"]\n[Agent tool call 3: files 31-45, subagent_type=\"general-purpose\"]\n```\nAll three in one message. Not three separate messages.\n\nEach subagent receives this exact prompt (substitute FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, and DEEP_MODE):\n\n```\nYou are a graphify extraction subagent. Read the files listed and extract a knowledge graph fragment.\nOutput ONLY valid JSON matching the schema below - no explanation, no markdown fences, no preamble.\n\nFiles (chunk CHUNK_NUM of TOTAL_CHUNKS):\nFILE_LIST\n\nRules:\n- EXTRACTED: relationship explicit in source (import, call, citation, \"see §3.2\")\n- INFERRED: reasonable inference (shared data structure, implied dependency)\n- AMBIGUOUS: uncertain - flag for review, do not omit\n\nCode files: focus on semantic edges AST cannot find (call relationships, shared data, arch patterns).\n  Do not re-extract imports - AST already has those.\nDoc\u002Fpaper files: extract named concepts, entities, citations. Also extract rationale — sections that explain WHY a decision was made, trade-offs chosen, or design intent. These become nodes with `rationale_for` edges pointing to the concept they explain.\nImage files: use vision to understand what the image IS - do not just OCR.\n  UI screenshot: layout patterns, design decisions, key elements, purpose.\n  Chart: metric, trend\u002Finsight, data source.\n  Tweet\u002Fpost: claim as node, author, concepts mentioned.\n  Diagram: components and connections.\n  Research figure: what it demonstrates, method, result.\n  Handwritten\u002Fwhiteboard: ideas and arrows, mark uncertain readings AMBIGUOUS.\n\nDEEP_MODE (if --mode deep was given): be aggressive with INFERRED edges - indirect deps,\n  shared assumptions, latent couplings. Mark uncertain ones AMBIGUOUS instead of omitting.\n\nSemantic similarity: if two concepts in this chunk solve the same problem or represent the same idea without any structural link (no import, no call, no citation), add a `semantically_similar_to` edge marked INFERRED with a confidence_score reflecting how similar they are (0.6-0.95). Examples:\n- Two functions that both validate user input but never call each other\n- A class in code and a concept in a paper that describe the same algorithm\n- Two error types that handle the same failure mode differently\nOnly add these when the similarity is genuinely non-obvious and cross-cutting. Do not add them for trivially similar things.\n\nHyperedges: if 3 or more nodes clearly participate together in a shared concept, flow, or pattern that is not captured by pairwise edges alone, add a hyperedge to a top-level `hyperedges` array. Examples:\n- All classes that implement a common protocol or interface\n- All functions in an authentication flow (even if they don't all call each other)\n- All concepts from a paper section that form one coherent idea\nUse sparingly — only when the group relationship adds information beyond the pairwise edges. Maximum 3 hyperedges per chunk.\n\nIf a file has YAML frontmatter (--- ... ---), copy source_url, captured_at, author,\n  contributor onto every node from that file.\n\nconfidence_score is REQUIRED on every edge - never omit it, never use 0.5 as a default:\n- EXTRACTED edges: confidence_score = 1.0 always\n- INFERRED edges: reason about each edge individually.\n  Direct structural evidence (shared data structure, clear dependency): 0.8-0.9.\n  Reasonable inference with some uncertainty: 0.6-0.7.\n  Weak or speculative: 0.4-0.5. Most edges should be 0.6-0.9, not 0.5.\n- AMBIGUOUS edges: 0.1-0.3\n\nNode ID format: lowercase, only `[a-z0-9_]`, no dots or slashes. Format: `{stem}_{entity}` where stem is the filename without extension and entity is the symbol name, both normalized (lowercase, non-alphanumeric chars replaced with `_`). Example: `src\u002Fauth\u002Fsession.py` + `ValidateToken` → `session_validatetoken`. This must match the ID the AST extractor generates so cross-references between code and semantic nodes connect correctly.\n\nOutput exactly this JSON (no other text):\n{\"nodes\":[{\"id\":\"session_validatetoken\",\"label\":\"Human Readable Name\",\"file_type\":\"code|document|paper|image\",\"source_file\":\"relative\u002Fpath\",\"source_location\":null,\"source_url\":null,\"captured_at\":null,\"author\":null,\"contributor\":null}],\"edges\":[{\"source\":\"node_id\",\"target\":\"node_id\",\"relation\":\"calls|implements|references|cites|conceptually_related_to|shares_data_with|semantically_similar_to|rationale_for\",\"confidence\":\"EXTRACTED|INFERRED|AMBIGUOUS\",\"confidence_score\":1.0,\"source_file\":\"relative\u002Fpath\",\"source_location\":null,\"weight\":1.0}],\"hyperedges\":[{\"id\":\"snake_case_id\",\"label\":\"Human Readable Label\",\"nodes\":[\"node_id1\",\"node_id2\",\"node_id3\"],\"relation\":\"participate_in|implement|form\",\"confidence\":\"EXTRACTED|INFERRED\",\"confidence_score\":0.75,\"source_file\":\"relative\u002Fpath\"}],\"input_tokens\":0,\"output_tokens\":0}\n```\n\n**Step B3 - Collect, cache, and merge**\n\nWait for all subagents. For each result:\n- Check that `graphify-out\u002F.graphify_chunk_NN.json` exists on disk — this is the success signal\n- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache\n- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: \"chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent.\" Do not silently skip.\n- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort\n\nIf more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type=\"general-purpose\"` is used.\n\nSave new results to cache:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.cache import save_semantic_cache\nfrom pathlib import Path\n\nnew = json.loads(Path('graphify-out\u002F.graphify_semantic_new.json').read_text()) if Path('graphify-out\u002F.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\nsaved = save_semantic_cache(new.get('nodes', []), new.get('edges', []), new.get('hyperedges', []))\nprint(f'Cached {saved} files')\n\"\n```\n\nMerge cached + new results into `graphify-out\u002F.graphify_semantic.json`:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\n\ncached = json.loads(Path('graphify-out\u002F.graphify_cached.json').read_text()) if Path('graphify-out\u002F.graphify_cached.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\nnew = json.loads(Path('graphify-out\u002F.graphify_semantic_new.json').read_text()) if Path('graphify-out\u002F.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\n\nall_nodes = cached['nodes'] + new.get('nodes', [])\nall_edges = cached['edges'] + new.get('edges', [])\nall_hyperedges = cached.get('hyperedges', []) + new.get('hyperedges', [])\nseen = set()\ndeduped = []\nfor n in all_nodes:\n    if n['id'] not in seen:\n        seen.add(n['id'])\n        deduped.append(n)\n\nmerged = {\n    'nodes': deduped,\n    'edges': all_edges,\n    'hyperedges': all_hyperedges,\n    'input_tokens': new.get('input_tokens', 0),\n    'output_tokens': new.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_semantic.json').write_text(json.dumps(merged, indent=2))\nprint(f'Extraction complete - {len(deduped)} nodes, {len(all_edges)} edges ({len(cached[\\\"nodes\\\"])} from cache, {len(new.get(\\\"nodes\\\",[]))} new)')\n\"\n```\nClean up temp files: `rm -f graphify-out\u002F.graphify_cached.json graphify-out\u002F.graphify_uncached.txt graphify-out\u002F.graphify_semantic_new.json`\n\n#### Part C - Merge AST + semantic into final extraction\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom pathlib import Path\n\nast = json.loads(Path('graphify-out\u002F.graphify_ast.json').read_text())\nsem = json.loads(Path('graphify-out\u002F.graphify_semantic.json').read_text())\n\n# Merge: AST nodes first, semantic nodes deduplicated by id\nseen = {n['id'] for n in ast['nodes']}\nmerged_nodes = list(ast['nodes'])\nfor n in sem['nodes']:\n    if n['id'] not in seen:\n        merged_nodes.append(n)\n        seen.add(n['id'])\n\nmerged_edges = ast['edges'] + sem['edges']\nmerged_hyperedges = sem.get('hyperedges', [])\nmerged = {\n    'nodes': merged_nodes,\n    'edges': merged_edges,\n    'hyperedges': merged_hyperedges,\n    'input_tokens': sem.get('input_tokens', 0),\n    'output_tokens': sem.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_extract.json').write_text(json.dumps(merged, indent=2))\ntotal = len(merged_nodes)\nedges = len(merged_edges)\nprint(f'Merged: {total} nodes, {edges} edges ({len(ast[\\\"nodes\\\"])} AST + {len(sem[\\\"nodes\\\"])} semantic)')\n\"\n```\n\n### Step 4 - Build graph, cluster, analyze, generate outputs\n\n**Before starting:** note whether `--directed` was given. If so, pass `directed=True` to `build_from_json()` in the code block below. This builds a `DiGraph` that preserves edge direction (source→target) instead of the default undirected `Graph`.\n\n```bash\nmkdir -p graphify-out\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import cluster, score_all\nfrom graphify.analyze import god_nodes, surprising_connections, suggest_questions\nfrom graphify.report import generate\nfrom graphify.export import to_json\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\ndetection  = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\n\nG = build_from_json(extraction)\ncommunities = cluster(G)\ncohesion = score_all(G, communities)\ntokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}\ngods = god_nodes(G)\nsurprises = surprising_connections(G, communities)\nlabels = {cid: 'Community ' + str(cid) for cid in communities}\n# Placeholder questions - regenerated with real labels in Step 5\nquestions = suggest_questions(G, communities, labels)\n\nreport = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, 'INPUT_PATH', suggested_questions=questions)\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report)\nto_json(G, communities, 'graphify-out\u002Fgraph.json')\n\nanalysis = {\n    'communities': {str(k): v for k, v in communities.items()},\n    'cohesion': {str(k): v for k, v in cohesion.items()},\n    'gods': gods,\n    'surprises': surprises,\n    'questions': questions,\n}\nPath('graphify-out\u002F.graphify_analysis.json').write_text(json.dumps(analysis, indent=2))\nif G.number_of_nodes() == 0:\n    print('ERROR: Graph is empty - extraction produced no nodes.')\n    print('Possible causes: all files were skipped, binary-only corpus, or extraction failed.')\n    raise SystemExit(1)\nprint(f'Graph: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges, {len(communities)} communities')\n\"\n```\n\nIf this step prints `ERROR: Graph is empty`, stop and tell the user what happened - do not proceed to labeling or visualization.\n\nReplace INPUT_PATH with the actual path.\n\n### Step 5 - Label communities\n\nRead `graphify-out\u002F.graphify_analysis.json`. For each community key, look at its node labels and write a 2-5 word plain-language name (e.g. \"Attention Mechanism\", \"Training Pipeline\", \"Data Loading\").\n\nThen regenerate the report and save the labels for the visualizer:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import score_all\nfrom graphify.analyze import god_nodes, surprising_connections, suggest_questions\nfrom graphify.report import generate\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\ndetection  = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\ncohesion = {int(k): v for k, v in analysis['cohesion'].items()}\ntokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}\n\n# LABELS - replace these with the names you chose above\nlabels = LABELS_DICT\n\n# Regenerate questions with real community labels (labels affect question phrasing)\nquestions = suggest_questions(G, communities, labels)\n\nreport = generate(G, communities, cohesion, labels, analysis['gods'], analysis['surprises'], detection, tokens, 'INPUT_PATH', suggested_questions=questions)\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report)\nPath('graphify-out\u002F.graphify_labels.json').write_text(json.dumps({str(k): v for k, v in labels.items()}))\nprint('Report updated with community labels')\n\"\n```\n\nReplace `LABELS_DICT` with the actual dict you constructed (e.g. `{0: \"Attention Mechanism\", 1: \"Training Pipeline\"}`).\nReplace INPUT_PATH with the actual path.\n\n### Step 6 - Generate Obsidian vault (opt-in) + HTML\n\n**Generate HTML always** (unless `--no-viz`). **Obsidian vault only if `--obsidian` was explicitly given** — skip it otherwise, it generates one file per node.\n\nIf `--obsidian` was given:\n\n- If `--obsidian-dir \u003Cpath>` was also given, use that path as the vault directory. Otherwise default to `graphify-out\u002Fobsidian`.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_obsidian, to_canvas\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nlabels_raw = json.loads(Path('graphify-out\u002F.graphify_labels.json').read_text()) if Path('graphify-out\u002F.graphify_labels.json').exists() else {}\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\ncohesion = {int(k): v for k, v in analysis['cohesion'].items()}\nlabels = {int(k): v for k, v in labels_raw.items()}\n\nobsidian_dir = 'OBSIDIAN_DIR'  # replace with --obsidian-dir value, or 'graphify-out\u002Fobsidian' if not given\n\nn = to_obsidian(G, communities, obsidian_dir, community_labels=labels or None, cohesion=cohesion)\nprint(f'Obsidian vault: {n} notes in {obsidian_dir}\u002F')\n\nto_canvas(G, communities, f'{obsidian_dir}\u002Fgraph.canvas', community_labels=labels or None)\nprint(f'Canvas: {obsidian_dir}\u002Fgraph.canvas - open in Obsidian for structured community layout')\nprint()\nprint(f'Open {obsidian_dir}\u002F as a vault in Obsidian.')\nprint('  Graph view   - nodes colored by community (set automatically)')\nprint('  graph.canvas - structured layout with communities as groups')\nprint('  _COMMUNITY_* - overview notes with cohesion scores and dataview queries')\n\"\n```\n\nGenerate the HTML graph (always, unless `--no-viz`):\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_html\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nlabels_raw = json.loads(Path('graphify-out\u002F.graphify_labels.json').read_text()) if Path('graphify-out\u002F.graphify_labels.json').exists() else {}\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\nlabels = {int(k): v for k, v in labels_raw.items()}\n\nif G.number_of_nodes() > 5000:\n    print(f'Graph has {G.number_of_nodes()} nodes - too large for HTML viz. Use Obsidian vault instead.')\nelse:\n    to_html(G, communities, 'graphify-out\u002Fgraph.html', community_labels=labels or None)\n    print('graph.html written - open in any browser, no server needed')\n\"\n```\n\n### Step 6b - Wiki (only if --wiki flag)\n\n**Only run this step if `--wiki` was explicitly given in the original command.**\n\nRun this before Step 9 (cleanup) so `.graphify_labels.json` is still available.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.build import build_from_json\nfrom graphify.wiki import to_wiki\nfrom graphify.analyze import god_nodes\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nlabels_raw = json.loads(Path('graphify-out\u002F.graphify_labels.json').read_text()) if Path('graphify-out\u002F.graphify_labels.json').exists() else {}\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\ncohesion = {int(k): v for k, v in analysis['cohesion'].items()}\nlabels = {int(k): v for k, v in labels_raw.items()}\ngods = god_nodes(G)\n\nn = to_wiki(G, communities, 'graphify-out\u002Fwiki', community_labels=labels or None, cohesion=cohesion, god_nodes_data=gods)\nprint(f'Wiki: {n} articles written to graphify-out\u002Fwiki\u002F')\nprint('  graphify-out\u002Fwiki\u002Findex.md  ->  agent entry point')\n\"\n```\n\n### Step 7 - Neo4j export (only if --neo4j or --neo4j-push flag)\n\n**If `--neo4j`** - generate a Cypher file for manual import:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_cypher\nfrom pathlib import Path\n\nG = build_from_json(json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text()))\nto_cypher(G, 'graphify-out\u002Fcypher.txt')\nprint('cypher.txt written - import with: cypher-shell \u003C graphify-out\u002Fcypher.txt')\n\"\n```\n\n**If `--neo4j-push \u003Curi>`** - push directly to a running Neo4j instance. Ask the user for credentials if not provided:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import cluster\nfrom graphify.export import push_to_neo4j\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\n\nresult = push_to_neo4j(G, uri='NEO4J_URI', user='NEO4J_USER', password='NEO4J_PASSWORD', communities=communities)\nprint(f'Pushed to Neo4j: {result[\\\"nodes\\\"]} nodes, {result[\\\"edges\\\"]} edges')\n\"\n```\n\nReplace `NEO4J_URI`, `NEO4J_USER`, `NEO4J_PASSWORD` with actual values. Default URI is `bolt:\u002F\u002Flocalhost:7687`, default user is `neo4j`. Uses MERGE - safe to re-run without creating duplicates.\n\n### Step 7b - SVG export (only if --svg flag)\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_svg\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\nlabels_raw = json.loads(Path('graphify-out\u002F.graphify_labels.json').read_text()) if Path('graphify-out\u002F.graphify_labels.json').exists() else {}\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\nlabels = {int(k): v for k, v in labels_raw.items()}\n\nto_svg(G, communities, 'graphify-out\u002Fgraph.svg', community_labels=labels or None)\nprint('graph.svg written - embeds in Obsidian, Notion, GitHub READMEs')\n\"\n```\n\n### Step 7c - GraphML export (only if --graphml flag)\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_graphml\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text())\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\n\nto_graphml(G, communities, 'graphify-out\u002Fgraph.graphml')\nprint('graph.graphml written - open in Gephi, yEd, or any GraphML tool')\n\"\n```\n\n### Step 7d - MCP server (only if --mcp flag)\n\n```bash\npython3 -m graphify.serve graphify-out\u002Fgraph.json\n```\n\nThis starts a stdio MCP server that exposes tools: `query_graph`, `get_node`, `get_neighbors`, `get_community`, `god_nodes`, `graph_stats`, `shortest_path`. Add to Claude Desktop or any MCP-compatible agent orchestrator so other agents can query the graph live.\n\nTo configure in Claude Desktop, add to `claude_desktop_config.json`:\n```json\n{\n  \"mcpServers\": {\n    \"graphify\": {\n      \"command\": \"python3\",\n      \"args\": [\"-m\", \"graphify.serve\", \"\u002Fabsolute\u002Fpath\u002Fto\u002Fgraphify-out\u002Fgraph.json\"]\n    }\n  }\n}\n```\n\n### Step 8 - Token reduction benchmark (only if total_words > 5000)\n\nIf `total_words` from `graphify-out\u002F.graphify_detect.json` is greater than 5,000, run:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.benchmark import run_benchmark, print_benchmark\nfrom pathlib import Path\n\ndetection = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nresult = run_benchmark('graphify-out\u002Fgraph.json', corpus_words=detection['total_words'])\nprint_benchmark(result)\n\"\n```\n\nPrint the output directly in chat. If `total_words \u003C= 5000`, skip silently - the graph value is structural clarity, not token compression, for small corpora.\n\n---\n\n### Step 9 - Save manifest, update cost tracker, clean up, and report\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\nfrom datetime import datetime, timezone\nfrom graphify.detect import save_manifest\n\n# Save manifest for --update\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text())\nsave_manifest(detect['files'])\n\n# Update cumulative cost tracker\nextract = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\ninput_tok = extract.get('input_tokens', 0)\noutput_tok = extract.get('output_tokens', 0)\n\ncost_path = Path('graphify-out\u002Fcost.json')\nif cost_path.exists():\n    cost = json.loads(cost_path.read_text())\nelse:\n    cost = {'runs': [], 'total_input_tokens': 0, 'total_output_tokens': 0}\n\ncost['runs'].append({\n    'date': datetime.now(timezone.utc).isoformat(),\n    'input_tokens': input_tok,\n    'output_tokens': output_tok,\n    'files': detect.get('total_files', 0),\n})\ncost['total_input_tokens'] += input_tok\ncost['total_output_tokens'] += output_tok\ncost_path.write_text(json.dumps(cost, indent=2))\n\nprint(f'This run: {input_tok:,} input tokens, {output_tok:,} output tokens')\nprint(f'All time: {cost[\\\"total_input_tokens\\\"]:,} input, {cost[\\\"total_output_tokens\\\"]:,} output ({len(cost[\\\"runs\\\"])} runs)')\n\"\nrm -f graphify-out\u002F.graphify_detect.json graphify-out\u002F.graphify_extract.json graphify-out\u002F.graphify_ast.json graphify-out\u002F.graphify_semantic.json graphify-out\u002F.graphify_analysis.json graphify-out\u002F.graphify_labels.json\nrm -f graphify-out\u002F.needs_update 2>\u002Fdev\u002Fnull || true\n```\n\nTell the user (omit the obsidian line unless --obsidian was given):\n```\nGraph complete. Outputs in PATH_TO_DIR\u002Fgraphify-out\u002F\n\n  graph.html            - interactive graph, open in browser\n  GRAPH_REPORT.md       - audit report\n  graph.json            - raw graph data\n  obsidian\u002F             - Obsidian vault (only if --obsidian was given)\n```\n\nIf graphify saved you time, consider supporting it: https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fsafishamsi\n\nReplace PATH_TO_DIR with the actual absolute path of the directory that was processed.\n\nThen paste these sections from GRAPH_REPORT.md directly into the chat:\n- God Nodes\n- Surprising Connections\n- Suggested Questions\n\nDo NOT paste the full report - just those three sections. Keep it concise.\n\nThen immediately offer to explore. Pick the single most interesting suggested question from the report - the one that crosses the most community boundaries or has the most surprising bridge node - and ask:\n\n> \"The most interesting question this graph can answer: **[question]**. Want me to trace it?\"\n\nIf the user says yes, run `\u002Fgraphify query \"[question]\"` on the graph and walk them through the answer using the graph structure - which nodes connect, which community boundaries get crossed, what the path reveals. Keep going as long as they want to explore. Each answer should end with a natural follow-up (\"this connects to X - want to go deeper?\") so the session feels like navigation, not a one-shot report.\n\nThe graph is the map. Your job after the pipeline is to be the guide.\n\n---\n\n## Interpreter guard for subcommands\n\nBefore running any subcommand below (`--update`, `--cluster-only`, `query`, `path`, `explain`, `add`), check that `.graphify_python` exists. If it's missing (e.g. user deleted `graphify-out\u002F`), re-resolve the interpreter first:\n\n```bash\nif [ ! -f graphify-out\u002F.graphify_python ]; then\n    GRAPHIFY_BIN=$(which graphify 2>\u002Fdev\u002Fnull)\n    if [ -n \"$GRAPHIFY_BIN\" ]; then\n        PYTHON=$(head -1 \"$GRAPHIFY_BIN\" | tr -d '#!')\n        case \"$PYTHON\" in *[!a-zA-Z0-9\u002F_.-]*) PYTHON=\"python3\" ;; esac\n    else\n        PYTHON=\"python3\"\n    fi\n    mkdir -p graphify-out\n    \"$PYTHON\" -c \"import sys; open('graphify-out\u002F.graphify_python', 'w').write(sys.executable)\"\nfi\n```\n\n## For --update (incremental re-extraction)\n\nUse when you've added or modified files since the last run. Only re-extracts changed files - saves tokens and time.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.detect import detect_incremental, save_manifest\nfrom pathlib import Path\n\nresult = detect_incremental(Path('INPUT_PATH'))\nnew_total = result.get('new_total', 0)\nprint(json.dumps(result, indent=2))\nPath('graphify-out\u002F.graphify_incremental.json').write_text(json.dumps(result))\nif new_total == 0:\n    print('No files changed since last run. Nothing to update.')\n    raise SystemExit(0)\nprint(f'{new_total} new\u002Fchanged file(s) to re-extract.')\n\"\n```\n\nIf new files exist, first check whether all changed files are code files:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\n\nresult = json.loads(open('graphify-out\u002F.graphify_incremental.json').read()) if Path('graphify-out\u002F.graphify_incremental.json').exists() else {}\ncode_exts = {'.py','.ts','.js','.go','.rs','.java','.cpp','.c','.rb','.swift','.kt','.cs','.scala','.php','.cc','.cxx','.hpp','.h','.kts','.lua','.toc'}\nnew_files = result.get('new_files', {})\nall_changed = [f for files in new_files.values() for f in files]\ncode_only = all(Path(f).suffix.lower() in code_exts for f in all_changed)\nprint('code_only:', code_only)\n\"\n```\n\nIf `code_only` is True: print `[graphify update] Code-only changes detected - skipping semantic extraction (no LLM needed)`, run only Step 3A (AST) on the changed files, skip Step 3B entirely (no subagents), then go straight to merge and Steps 4–8.\n\nIf `code_only` is False (any changed file is a doc\u002Fpaper\u002Fimage): run the full Steps 3A–3C pipeline as normal.\n\nThen:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.export import to_json\nfrom networkx.readwrite import json_graph\nimport networkx as nx\nfrom pathlib import Path\n\n# Load existing graph\nexisting_data = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG_existing = json_graph.node_link_graph(existing_data, edges='links')\n\n# Load new extraction\nnew_extraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nG_new = build_from_json(new_extraction)\n\n# Prune nodes from deleted files\nincremental = json.loads(Path('graphify-out\u002F.graphify_incremental.json').read_text())\ndeleted = set(incremental.get('deleted_files', []))\nif deleted:\n    to_remove = [n for n, d in G_existing.nodes(data=True) if d.get('source_file') in deleted]\n    G_existing.remove_nodes_from(to_remove)\n    print(f'Pruned {len(to_remove)} ghost nodes from {len(deleted)} deleted file(s)')\n\n# Merge: new nodes\u002Fedges into existing graph\nG_existing.update(G_new)\nprint(f'Merged: {G_existing.number_of_nodes()} nodes, {G_existing.number_of_edges()} edges')\n\n# Write merged result back to .graphify_extract.json so Step 4 sees the full graph\nmerged_out = {\n    'nodes': [{'id': n, **d} for n, d in G_existing.nodes(data=True)],\n    'edges': [{'source': u, 'target': v, **d} for u, v, d in G_existing.edges(data=True)],\n    'hyperedges': new_extraction.get('hyperedges', []),\n    'input_tokens': new_extraction.get('input_tokens', 0),\n    'output_tokens': new_extraction.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_extract.json').write_text(json.dumps(merged_out))\nprint(f'[graphify update] Merged extraction written ({len(merged_out[\\\"nodes\\\"])} nodes, {len(merged_out[\\\"edges\\\"])} edges)')\n\" \n```\n\nThen run Steps 4–8 on the merged graph as normal.\n\nAfter Step 4, show the graph diff:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.analyze import graph_diff\nfrom graphify.build import build_from_json\nfrom networkx.readwrite import json_graph\nimport networkx as nx\nfrom pathlib import Path\n\n# Load old graph (before update) from backup written before merge\nold_data = json.loads(Path('graphify-out\u002F.graphify_old.json').read_text()) if Path('graphify-out\u002F.graphify_old.json').exists() else None\nnew_extract = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text())\nG_new = build_from_json(new_extract)\n\nif old_data:\n    G_old = json_graph.node_link_graph(old_data, edges='links')\n    diff = graph_diff(G_old, G_new)\n    print(diff['summary'])\n    if diff['new_nodes']:\n        print('New nodes:', ', '.join(n['label'] for n in diff['new_nodes'][:5]))\n    if diff['new_edges']:\n        print('New edges:', len(diff['new_edges']))\n\"\n```\n\nBefore the merge step, save the old graph: `cp graphify-out\u002Fgraph.json graphify-out\u002F.graphify_old.json`\nClean up after: `rm -f graphify-out\u002F.graphify_old.json`\n\n---\n\n## For --cluster-only\n\nSkip Steps 1–3. Load the existing graph from `graphify-out\u002Fgraph.json` and re-run clustering:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.cluster import cluster, score_all\nfrom graphify.analyze import god_nodes, surprising_connections\nfrom graphify.report import generate\nfrom graphify.export import to_json\nfrom networkx.readwrite import json_graph\nimport networkx as nx\nfrom pathlib import Path\n\ndata = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG = json_graph.node_link_graph(data, edges='links')\n\ndetection = {'total_files': 0, 'total_words': 99999, 'needs_graph': True, 'warning': None,\n             'files': {'code': [], 'document': [], 'paper': []}}\ntokens = {'input': 0, 'output': 0}\n\ncommunities = cluster(G)\ncohesion = score_all(G, communities)\ngods = god_nodes(G)\nsurprises = surprising_connections(G, communities)\nlabels = {cid: 'Community ' + str(cid) for cid in communities}\n\nreport = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, '.')\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report)\nto_json(G, communities, 'graphify-out\u002Fgraph.json')\n\nanalysis = {\n    'communities': {str(k): v for k, v in communities.items()},\n    'cohesion': {str(k): v for k, v in cohesion.items()},\n    'gods': gods,\n    'surprises': surprises,\n}\nPath('graphify-out\u002F.graphify_analysis.json').write_text(json.dumps(analysis, indent=2))\nprint(f'Re-clustered: {len(communities)} communities')\n\"\n```\n\nThen run Steps 5–9 as normal (label communities, generate viz, benchmark, clean up, report).\n\n---\n\n## For \u002Fgraphify query\n\nTwo traversal modes - choose based on the question:\n\n| Mode | Flag | Best for |\n|------|------|----------|\n| BFS (default) | _(none)_ | \"What is X connected to?\" - broad context, nearest neighbors first |\n| DFS | `--dfs` | \"How does X reach Y?\" - trace a specific chain or dependency path |\n\nFirst check the graph exists:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nfrom pathlib import Path\nif not Path('graphify-out\u002Fgraph.json').exists():\n    print('ERROR: No graph found. Run \u002Fgraphify \u003Cpath> first to build the graph.')\n    raise SystemExit(1)\n\"\n```\nIf it fails, stop and tell the user to run `\u002Fgraphify \u003Cpath>` first.\n\nLoad `graphify-out\u002Fgraph.json`, then:\n\n1. Find the 1-3 nodes whose label best matches key terms in the question.\n2. Run the appropriate traversal from each starting node.\n3. Read the subgraph - node labels, edge relations, confidence tags, source locations.\n4. Answer using **only** what the graph contains. Quote `source_location` when citing a specific fact.\n5. If the graph lacks enough information, say so - do not hallucinate edges.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom networkx.readwrite import json_graph\nimport networkx as nx\nfrom pathlib import Path\n\ndata = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG = json_graph.node_link_graph(data, edges='links')\n\nquestion = 'QUESTION'\nmode = 'MODE'  # 'bfs' or 'dfs'\nterms = [t.lower() for t in question.split() if len(t) > 3]\n\n# Find best-matching start nodes\nscored = []\nfor nid, ndata in G.nodes(data=True):\n    label = ndata.get('label', '').lower()\n    score = sum(1 for t in terms if t in label)\n    if score > 0:\n        scored.append((score, nid))\nscored.sort(reverse=True)\nstart_nodes = [nid for _, nid in scored[:3]]\n\nif not start_nodes:\n    print('No matching nodes found for query terms:', terms)\n    sys.exit(0)\n\nsubgraph_nodes = set()\nsubgraph_edges = []\n\nif mode == 'dfs':\n    # DFS: follow one path as deep as possible before backtracking.\n    # Depth-limited to 6 to avoid traversing the whole graph.\n    visited = set()\n    stack = [(n, 0) for n in reversed(start_nodes)]\n    while stack:\n        node, depth = stack.pop()\n        if node in visited or depth > 6:\n            continue\n        visited.add(node)\n        subgraph_nodes.add(node)\n        for neighbor in G.neighbors(node):\n            if neighbor not in visited:\n                stack.append((neighbor, depth + 1))\n                subgraph_edges.append((node, neighbor))\nelse:\n    # BFS: explore all neighbors layer by layer up to depth 3.\n    frontier = set(start_nodes)\n    subgraph_nodes = set(start_nodes)\n    for _ in range(3):\n        next_frontier = set()\n        for n in frontier:\n            for neighbor in G.neighbors(n):\n                if neighbor not in subgraph_nodes:\n                    next_frontier.add(neighbor)\n                    subgraph_edges.append((n, neighbor))\n        subgraph_nodes.update(next_frontier)\n        frontier = next_frontier\n\n# Token-budget aware output: rank by relevance, cut at budget (~4 chars\u002Ftoken)\ntoken_budget = BUDGET  # default 2000\nchar_budget = token_budget * 4\n\n# Score each node by term overlap for ranked output\ndef relevance(nid):\n    label = G.nodes[nid].get('label', '').lower()\n    return sum(1 for t in terms if t in label)\n\nranked_nodes = sorted(subgraph_nodes, key=relevance, reverse=True)\n\nlines = [f'Traversal: {mode.upper()} | Start: {[G.nodes[n].get(\\\"label\\\",n) for n in start_nodes]} | {len(subgraph_nodes)} nodes']\nfor nid in ranked_nodes:\n    d = G.nodes[nid]\n    lines.append(f'  NODE {d.get(\\\"label\\\", nid)} [src={d.get(\\\"source_file\\\",\\\"\\\")} loc={d.get(\\\"source_location\\\",\\\"\\\")}]')\nfor u, v in subgraph_edges:\n    if u in subgraph_nodes and v in subgraph_nodes:\n        d = G.edges[u, v]\n        lines.append(f'  EDGE {G.nodes[u].get(\\\"label\\\",u)} --{d.get(\\\"relation\\\",\\\"\\\")} [{d.get(\\\"confidence\\\",\\\"\\\")}]--> {G.nodes[v].get(\\\"label\\\",v)}')\n\noutput = '\\n'.join(lines)\nif len(output) > char_budget:\n    output = output[:char_budget] + f'\\n... (truncated at ~{token_budget} token budget - use --budget N for more)'\nprint(output)\n\"\n```\n\nReplace `QUESTION` with the user's actual question, `MODE` with `bfs` or `dfs`, and `BUDGET` with the token budget (default `2000`, or whatever `--budget N` specifies). Then answer based on the subgraph output above.\n\nAfter writing the answer, save it back into the graph so it improves future queries:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -m graphify save-result --question \"QUESTION\" --answer \"ANSWER\" --type query --nodes NODE1 NODE2\n```\n\nReplace `QUESTION` with the question, `ANSWER` with your full answer text, `SOURCE_NODES` with the list of node labels you cited. This closes the feedback loop: the next `--update` will extract this Q&A as a node in the graph.\n\n---\n\n## For \u002Fgraphify path\n\nFind the shortest path between two named concepts in the graph.\n\nFirst check the graph exists:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nfrom pathlib import Path\nif not Path('graphify-out\u002Fgraph.json').exists():\n    print('ERROR: No graph found. Run \u002Fgraphify \u003Cpath> first to build the graph.')\n    raise SystemExit(1)\n\"\n```\nIf it fails, stop and tell the user to run `\u002Fgraphify \u003Cpath>` first.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json, sys\nimport networkx as nx\nfrom networkx.readwrite import json_graph\nfrom pathlib import Path\n\ndata = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG = json_graph.node_link_graph(data, edges='links')\n\na_term = 'NODE_A'\nb_term = 'NODE_B'\n\ndef find_node(term):\n    term = term.lower()\n    scored = sorted(\n        [(sum(1 for w in term.split() if w in G.nodes[n].get('label','').lower()), n)\n         for n in G.nodes()],\n        reverse=True\n    )\n    return scored[0][1] if scored and scored[0][0] > 0 else None\n\nsrc = find_node(a_term)\ntgt = find_node(b_term)\n\nif not src or not tgt:\n    print(f'Could not find nodes matching: {a_term!r} or {b_term!r}')\n    sys.exit(0)\n\ntry:\n    path = nx.shortest_path(G, src, tgt)\n    print(f'Shortest path ({len(path)-1} hops):')\n    for i, nid in enumerate(path):\n        label = G.nodes[nid].get('label', nid)\n        if i \u003C len(path) - 1:\n            edge = G.edges[nid, path[i+1]]\n            rel = edge.get('relation', '')\n            conf = edge.get('confidence', '')\n            print(f'  {label} --{rel}--> [{conf}]')\n        else:\n            print(f'  {label}')\nexcept nx.NetworkXNoPath:\n    print(f'No path found between {a_term!r} and {b_term!r}')\nexcept nx.NodeNotFound as e:\n    print(f'Node not found: {e}')\n\"\n```\n\nReplace `NODE_A` and `NODE_B` with the actual concept names from the user. Then explain the path in plain language - what each hop means, why it's significant.\n\nAfter writing the explanation, save it back:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -m graphify save-result --question \"Path from NODE_A to NODE_B\" --answer \"ANSWER\" --type path_query --nodes NODE_A NODE_B\n```\n\n---\n\n## For \u002Fgraphify explain\n\nGive a plain-language explanation of a single node - everything connected to it.\n\nFirst check the graph exists:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nfrom pathlib import Path\nif not Path('graphify-out\u002Fgraph.json').exists():\n    print('ERROR: No graph found. Run \u002Fgraphify \u003Cpath> first to build the graph.')\n    raise SystemExit(1)\n\"\n```\nIf it fails, stop and tell the user to run `\u002Fgraphify \u003Cpath>` first.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json, sys\nimport networkx as nx\nfrom networkx.readwrite import json_graph\nfrom pathlib import Path\n\ndata = json.loads(Path('graphify-out\u002Fgraph.json').read_text())\nG = json_graph.node_link_graph(data, edges='links')\n\nterm = 'NODE_NAME'\nterm_lower = term.lower()\n\n# Find best matching node\nscored = sorted(\n    [(sum(1 for w in term_lower.split() if w in G.nodes[n].get('label','').lower()), n)\n     for n in G.nodes()],\n    reverse=True\n)\nif not scored or scored[0][0] == 0:\n    print(f'No node matching {term!r}')\n    sys.exit(0)\n\nnid = scored[0][1]\ndata_n = G.nodes[nid]\nprint(f'NODE: {data_n.get(\\\"label\\\", nid)}')\nprint(f'  source: {data_n.get(\\\"source_file\\\",\\\"unknown\\\")}')\nprint(f'  type: {data_n.get(\\\"file_type\\\",\\\"unknown\\\")}')\nprint(f'  degree: {G.degree(nid)}')\nprint()\nprint('CONNECTIONS:')\nfor neighbor in G.neighbors(nid):\n    edge = G.edges[nid, neighbor]\n    nlabel = G.nodes[neighbor].get('label', neighbor)\n    rel = edge.get('relation', '')\n    conf = edge.get('confidence', '')\n    src_file = G.nodes[neighbor].get('source_file', '')\n    print(f'  --{rel}--> {nlabel} [{conf}] ({src_file})')\n\"\n```\n\nReplace `NODE_NAME` with the concept the user asked about. Then write a 3-5 sentence explanation of what this node is, what it connects to, and why those connections are significant. Use the source locations as citations.\n\nAfter writing the explanation, save it back:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -m graphify save-result --question \"Explain NODE_NAME\" --answer \"ANSWER\" --type explain --nodes NODE_NAME\n```\n\n---\n\n## For \u002Fgraphify add\n\nFetch a URL and add it to the corpus, then update the graph.\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys\nfrom graphify.ingest import ingest\nfrom pathlib import Path\n\ntry:\n    out = ingest('URL', Path('.\u002Fraw'), author='AUTHOR', contributor='CONTRIBUTOR')\n    print(f'Saved to {out}')\nexcept ValueError as e:\n    print(f'error: {e}', file=sys.stderr)\n    sys.exit(1)\nexcept RuntimeError as e:\n    print(f'error: {e}', file=sys.stderr)\n    sys.exit(1)\n\"\n```\n\nReplace `URL` with the actual URL, `AUTHOR` with the user's name if provided, `CONTRIBUTOR` likewise. If the command exits with an error, tell the user what went wrong - do not silently continue. After a successful save, automatically run the `--update` pipeline on `.\u002Fraw` to merge the new file into the existing graph.\n\nSupported URL types (auto-detected):\n- YouTube \u002F any video URL → audio downloaded via yt-dlp, transcribed to `.txt` on next run (requires `pip install 'graphifyy[video]'`)\n- Twitter\u002FX → fetched via oEmbed, saved as `.md` with tweet text and author\n- arXiv → abstract + metadata saved as `.md`\n- PDF → downloaded as `.pdf`\n- Images (.png\u002F.jpg\u002F.webp) → downloaded, Claude vision extracts on next run\n- Any webpage → converted to markdown via html2text\n\n---\n\n## For --watch\n\nStart a background watcher that monitors a folder and auto-updates the graph when files change.\n\n```bash\npython3 -m graphify.watch INPUT_PATH --debounce 3\n```\n\nReplace INPUT_PATH with the folder to watch. Behavior depends on what changed:\n\n- **Code files only (.py, .ts, .go, etc.):** re-runs AST extraction + rebuild + cluster immediately, no LLM needed. `graph.json` and `GRAPH_REPORT.md` are updated automatically.\n- **Docs, papers, or images:** writes a `graphify-out\u002Fneeds_update` flag and prints a notification to run `\u002Fgraphify --update` (LLM semantic re-extraction required).\n\nDebounce (default 3s): waits until file activity stops before triggering, so a wave of parallel agent writes doesn't trigger a rebuild per file.\n\nPress Ctrl+C to stop.\n\nFor agentic workflows: run `--watch` in a background terminal. Code changes from agent waves are picked up automatically between waves. If agents are also writing docs or notes, you'll need a manual `\u002Fgraphify --update` after those waves.\n\n---\n\n## For git commit hook\n\nInstall a post-commit hook that auto-rebuilds the graph after every commit. No background process needed - triggers once per commit, works with any editor.\n\n```bash\ngraphify hook install    # install\ngraphify hook uninstall  # remove\ngraphify hook status     # check\n```\n\nAfter every `git commit`, the hook detects which code files changed (via `git diff HEAD~1`), re-runs AST extraction on those files, and rebuilds `graph.json` and `GRAPH_REPORT.md`. Doc\u002Fimage changes are ignored by the hook - run `\u002Fgraphify --update` manually for those.\n\nIf a post-commit hook already exists, graphify appends to it rather than replacing it.\n\n---\n\n## For native CLAUDE.md integration\n\nRun once per project to make graphify always-on in Claude Code sessions:\n\n```bash\ngraphify claude install\n```\n\nThis writes a `## graphify` section to the local `CLAUDE.md` that instructs Claude to check the graph before answering codebase questions and rebuild it after code changes. No manual `\u002Fgraphify` needed in future sessions.\n\n```bash\ngraphify claude uninstall  # remove the section\n```\n\n---\n\n## Honesty Rules\n\n- Never invent an edge. If unsure, use AMBIGUOUS.\n- Never skip the corpus check warning.\n- Always show token cost in the report.\n- Never hide cohesion scores behind symbols - show the raw number.\n- Never run HTML viz on a graph with more than 5,000 nodes without warning the user.\n",{"name":5,"trigger":24,"description":7},"\u002Fgraphify","main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill graphify",{"tool":40,"command":41},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill graphify",{"tool":43,"command":44},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill graphify","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill.md",true,[48,54,58,62,66,70,74,78,82,86,90,94,98,102,106,110,114,120,124,128,132,136,140,144,148,152,156,160,164],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"__init__.py","SCRIPT","脚本",1301,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002F__init__.py",{"path":55,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":56,"sourceHtmlUrl":57},"__main__.py",58451,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002F__main__.py",{"path":59,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":60,"sourceHtmlUrl":61},"analyze.py",20893,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fanalyze.py",{"path":63,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":64,"sourceHtmlUrl":65},"benchmark.py",4721,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fbenchmark.py",{"path":67,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":68,"sourceHtmlUrl":69},"build.py",5327,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fbuild.py",{"path":71,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":72,"sourceHtmlUrl":73},"cache.py",5493,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fcache.py",{"path":75,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":76,"sourceHtmlUrl":77},"cluster.py",5411,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fcluster.py",{"path":79,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":80,"sourceHtmlUrl":81},"detect.py",19333,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fdetect.py",{"path":83,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":84,"sourceHtmlUrl":85},"export.py",39719,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fexport.py",{"path":87,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":88,"sourceHtmlUrl":89},"extract.py",142490,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fextract.py",{"path":91,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":92,"sourceHtmlUrl":93},"hooks.py",7459,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fhooks.py",{"path":95,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":96,"sourceHtmlUrl":97},"ingest.py",10235,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fingest.py",{"path":99,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":100,"sourceHtmlUrl":101},"manifest.py",214,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fmanifest.py",{"path":103,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":104,"sourceHtmlUrl":105},"report.py",7860,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Freport.py",{"path":107,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":108,"sourceHtmlUrl":109},"security.py",7421,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fsecurity.py",{"path":111,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":112,"sourceHtmlUrl":113},"serve.py",16095,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fserve.py",{"path":115,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":118,"sourceHtmlUrl":119},"skill-aider.md","REFERENCE","参考文档",47218,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill-aider.md",{"path":121,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":122,"sourceHtmlUrl":123},"skill-claw.md",47230,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill-claw.md",{"path":125,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":126,"sourceHtmlUrl":127},"skill-codex.md",51297,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill-codex.md",{"path":129,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":130,"sourceHtmlUrl":131},"skill-copilot.md",53603,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill-copilot.md",{"path":133,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":134,"sourceHtmlUrl":135},"skill-droid.md",51085,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill-droid.md",{"path":137,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":138,"sourceHtmlUrl":139},"skill-kiro.md",47443,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill-kiro.md",{"path":141,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":142,"sourceHtmlUrl":143},"skill-opencode.md",50810,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill-opencode.md",{"path":145,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":146,"sourceHtmlUrl":147},"skill-vscode.md",8565,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill-vscode.md",{"path":149,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":150,"sourceHtmlUrl":151},"skill-windows.md",51223,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fskill-windows.md",{"path":153,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":154,"sourceHtmlUrl":155},"transcribe.py",6173,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Ftranscribe.py",{"path":157,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":158,"sourceHtmlUrl":159},"validate.py",3297,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fvalidate.py",{"path":161,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":162,"sourceHtmlUrl":163},"watch.py",8488,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fwatch.py",{"path":165,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":166,"sourceHtmlUrl":167},"wiki.py",7341,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Tool-开发工具链\u002FYYC3-Tool-开发工具链-graphify\u002Fgraphify\u002Fwiki.py",[169,176,183,190,197,204],{"skillNo":170,"name":171,"nameZh":6,"description":172,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":173,"categories":174,"keywords":175,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":177,"name":178,"nameZh":6,"description":179,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":180,"categories":181,"keywords":182,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":184,"name":185,"nameZh":6,"description":186,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":187,"categories":188,"keywords":189,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":191,"name":192,"nameZh":6,"description":193,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":194,"categories":195,"keywords":196,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":198,"name":199,"nameZh":6,"description":200,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":201,"categories":202,"keywords":203,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":205,"name":206,"nameZh":6,"description":207,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":208,"categories":209,"keywords":210,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]