ARTICLE · INTELLIGENCE

战地情报 · 详情页

来自尧图项目组的一线实战观察与深度解析

graphify 接入 Pi 编码智能体:skill-pi.md 的 /graphify 完整运行手册

graphify 接入 Pi 编码智能体:skill-pi.md 的 /graphify 完整运行手册 graphify 接入 Pi 编码智能体skill-pi.md 的 /graphify 完整运行手册【免费下载链接】graphifyTurn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable knowledge graph. A /graphify skill for Claude Code, Cursor, Codex, and Gemini CLI: local deterministic AST parsing, every edge explained, no vector store.项目地址: https://gitcode.com/GitHub_Trending/graph/graphifygraphify/skill-pi.md是 graphify 为 Pi coding agent 平台定制的 SKILL 文件当用户在 Pi 会话中输入/graphify时Pi 会按这份 700 余行的“运行手册runbook”把任意代码、文档、论文、图片与视频目录转成可查询的知识图谱并给出query/path/explain三种图查询入口。读完本文你既能完整复现该手册规定的九步构建流水线与全部命令行参数也能理解其中每个步骤背后 graphify 仓库源码graphify/build.py、graphify/cache.py、graphify/diagnostics.py 等承担的具体职责。skill-pi.md 在仓库中的定位skill-pi.md与 Claude Code 平台的主技能文件 graphify/skill.md 内容逐字节一致当前仓库版本中两者diff为空它属于 graphify 的“split 桶”平台之一一个技能主体加上一组按需加载的references/参考文档。可以从三处源码确认这一结构安装配置graphify/install.py 中pi平台条目声明了skill_file: skill-pi.md、安装目标~/.pi/agent/skills/graphify/SKILL.md以及skill_refs: pi参考文档目录技能生成tools/skillgen/platforms.toml 中[platform.pi]声明skill_dst graphify/skill-pi.md、refs_dst graphify/skills/pi/references即 skill-pi.md 是由 skillgen 工具从tools/skillgen/fragments/下的片段渲染生成、并以 tests/test_skillgen.py 做回归校验的产物打包分发pyproject.toml 的 package-data 中同时打包了skill-pi.md与skills/*/references/*.md保证pip install后 Pi 仍能拿到完整技能包。随技能主体一同分发的 Pi 参考文档位于 graphify/skills/pi/references/按主题拆分正文中只在对应步骤才要求加载参考文档加载时机extraction-spec.md语义抽取子代理的提示词与 JSON Schemaquery.mdquery/path/explain遍历流程update.md--update增量重建与--cluster-onlyexports.md--wiki、--neo4j、--falkordb、--svg、--graphml、--mcp等导出add-watch.mdadd url语料抓取与--watch自动重建github-and-merge.mdURL 克隆与多仓库合并transcribe.md音视频转写Whisperhooks.mdpost-commit 钩子与 CLAUDE.md 集成安装方式在 README.md 的平台表中给出graphify install --platform pi或等价的graphify pi install。安装后Pi 会话中所有/graphify ...请求都交由skill-pi.md正文驱动用户无需记忆 graphify CLI 的细节。命令参考/graphify 的完整用法文档开头的 Usage 块是/graphify的完整命令面Pi 在执行任何操作前必须严格遵守它的语义/graphify # 对当前目录跑完整流水线HTML 可视化加 --obsidian 生成 vault /graphify path # 对指定路径跑完整流水线 /graphify https://github.com/owner/repo # 克隆仓库后对其跑完整流水线 /graphify https://github.com/owner/repo --branch branch # 克隆指定分支 /graphify url1 url2 ... # 克隆多个仓库各自构建后合并成一张跨仓库图 /graphify path --mode deep # 更彻底的抽取产出更丰富的 INFERRED 边 /graphify path --update # 增量只重新抽取新增/变更的文件 /graphify path --directed # 构建有向图保留边方向 source→target /graphify path --whisper-model medium # 用更大的 Whisper 模型提升转写精度 /graphify path --cluster-only # 在已有图上重跑社区聚类 /graphify path --no-viz # 跳过可视化只出报告 JSON /graphify path --html # HTML 默认就生成此标志是 no-op /graphify path --svg # 额外导出 graph.svg可嵌入 Notion、GitHub /graphify path --graphml # 导出 graph.graphmlGephi、yEd /graphify path --neo4j # 生成 graphify-out/cypher.txt 供 Neo4j 使用 /graphify path --neo4j-push bolt://localhost:7687 # 直接推送到 Neo4j /graphify path --falkordb # 生成 graphify-out/cypher.txt 供 FalkorDB 使用 /graphify path --falkordb-push falkordb://localhost:6379 # 直接推送到 FalkorDB /graphify path --mcp # 启动 MCP stdio server 供其他 agent 访问 /graphify path --watch # 监听目录代码变更后自动重建不需要 LLM /graphify path --wiki # 构建可供 agent 爬取的 wikiindex.md 每个社区一篇 /graphify path --obsidian --obsidian-dir ~/vaults/my-project # 把 vault 写到自定义路径 /graphify add url # 抓取 URL存入 ./raw 并更新图 /graphify add url --author Name # 标注作者 /graphify add url --contributor Name # 标注加入语料的人 /graphify query question # BFS 遍历——宽上下文 /graphify query question --dfs # DFS——追踪一条具体路径 /graphify query question --budget 1500 # 把回答限制在 N 个 token 以内 /graphify path AuthModule Database # 两个概念之间的最短路径 /graphify explain SwinTransformer # 用通俗语言解释某个节点文档同时明确了三条调用语义/graphify --help或-h且无其他参数时原样打印 Usage 块并停止不执行任何命令未给路径时默认使用.当前目录不得反问用户路径以https://github.com/或http://github.com/开头时先执行 Step 0克隆再继续。快速路径已有图时直接走查询手册在“被调用时必须做的事”一节规定了最高优先级规则先检查graphify-out/graph.json是否存在相对当前工作目录。若它存在且用户的请求是自然语言问题“X 怎么工作”“谁调用了 Y”而非显式重建命令--update、--cluster-only或暗示重新抽取的裸路径/URL则完全跳过 Step 1–5直接进入 query 流程——不运行 detect、不检查语料规模、不要求用户缩小范围。这条“快速路径”体现了 graphify 的设计前提图是持久化资产提问时应当“查图而不是重建图”后文 query 小节会展开。Step 0–1解析 Python 解释器并保证安装Pi 这类宿主不保证python3就是装有 graphify 的解释器可能装在 uv tool、pipx 或 venv 里因此 Step 1 的核心是一段解释器探测脚本探测成功后把解释器路径落盘到graphify-out/.graphify_python后续所有 bash 块都必须用$(cat graphify-out/.graphify_python)替代字面量python3# Detect the correct Python interpreter (handles uv tool, pipx, venv, system installs) PYTHON GRAPHIFY_BIN$(which graphify 2/dev/null) # 1. uv tool installs — most reliable on modern Mac/Linux if [ -z $PYTHON ] command -v uv /dev/null 21; then _UV_PY$(uv tool run --from graphifyy python -c import sys; print(sys.executable) 2/dev/null) if [ -n $_UV_PY ]; then PYTHON$_UV_PY; fi fi # 2. Read shebang from graphify binary (pipx and direct pip installs) if [ -z $PYTHON ] [ -n $GRAPHIFY_BIN ]; then _SHEBANG$(head -1 $GRAPHIFY_BIN | tr -d #!) case $_SHEBANG in *[!a-zA-Z0-9/_.-]*) ;; *) $_SHEBANG -c import graphify 2/dev/null PYTHON$_SHEBANG ;; esac fi # 3. Fall back to python3 if [ -z $PYTHON ]; then PYTHONpython3; fi if ! $PYTHON -c import graphify 2/dev/null; then if command -v uv /dev/null 21; then uv tool install --upgrade graphifyy -q 21 | tail -3 _UV_PY$(uv tool run --from graphifyy python -c import sys; print(sys.executable) 2/dev/null) if [ -n $_UV_PY ]; then PYTHON$_UV_PY; fi else $PYTHON -m pip install graphifyy -q 2/dev/null \ || $PYTHON -m pip install graphifyy -q --break-system-packages 21 | tail -3 fi fi # Write interpreter path for all subsequent steps (persists across invocations) mkdir -p graphify-out $PYTHON -c import sys; open(graphify-out/.graphify_python, w, encodingutf-8).write(sys.executable) # Save scan root so graphify update (no args) knows where to look next time echo $(cd INPUT_PATH pwd) graphify-out/.graphify_root三个探测顺序对应 README 中反复强调的安装建议uv tool install/pipx install的隔离环境最可靠裸pip install因环境漂移最容易产生ModuleNotFoundError——这段脚本实际上是把 README 的运维建议固化成了可执行逻辑。若 import 成功则静默进入 Step 2graphify-out/.graphify_root则记录扫描根目录供无参graphify update使用。Step 2文件探测与语料体检Step 2 调用 graphify/detect.py 中的detect()扫描目标路径把分类结果写入graphify-out/.graphify_detect.json注意手册特别要求用 Python 写 sidecar 而不是 shell 重定向避免 PowerShell 宿主上的控制台编码漂移$(cat graphify-out/.graphify_python) -c import json from graphify.detect import detect from pathlib import Path result detect(Path(INPUT_PATH)) Path(graphify-out/.graphify_detect.json).write_text(json.dumps(result, ensure_asciiFalse), encoding\utf-8\) print(fDetected {result[\total_files\]} files) 输出不是原始 JSON而是整理后的摘要0 文件的类别省略Corpus: X files · ~Y words code: N files (.py .ts .go ...) docs: N files (.md .txt ...) papers: N files (.pdf ...) images: N files video: N files (.mp4 .mp3 ...)随后的“体检规则”是手册中防呆逻辑的集中体现total_files为 0以 “No supported files found in [path].” 停止skipped_sensitive非空报告数量并列出被跳过的文件名让被误判的源文件可见、可改名或移动total_words 2,000,000 或total_files 500必须展示警告并计算按文件数排序的 top 5 一级子目录从 detect JSON 读取绝对路径scan_root合并code/document/paper/image/video全部文件列表过滤scan_root /graphify-out/前缀的中间产物取scan_root之后的第一个路径段根目录直属文件记为(root)。若全部文件都在(root)则不问用户、改为建议--no-cluster跳过昂贵的聚类否则展示 top 5 并等待用户选择子目录后再继续。Step 3双通道抽取——AST 结构通道与 LLM 语义通道手册对 Step 3 的关键定性是结构抽取是确定性的、免费的语义抽取才花 token。并且给出了一条强约束——“graphify 不需要 API key永远不要向用户索要也不要因为缺 key 而阻塞”代码文件走 AST完全不需要 LLM 和 key纯代码语料最常见的/graphify .直接跳过语义抽取语义抽取仅针对文档、论文、图片只有在GEMINI_API_KEY/GOOGLE_API_KEY已设置时才使用 Geminipip install graphifyy[gemini]默认模型gemini-3-flash-preview可用GRAPHIFY_GEMINI_MODEL或--model覆盖若两个 key 都未设置向用户打印一次提示后继续——此时“宿主 agent 本身就是 LLM”即由 Pi 会话自己承担语义抽取graphify 明确不读ANTHROPIC_API_KEY、OPENAI_API_KEY或其他厂商的 key。Part AAST与 Part B语义要求在同一轮消息中并行启动AST 启动的同时派发全部语义子代理大语料上可省 5–15 秒。Part A——对代码文件跑 AST 抽取输入来自 detect JSON 的files.code结果落盘为.graphify_ast.json$(cat graphify-out/.graphify_python) -c import sys, json from graphify.extract import collect_files, extract from pathlib import Path code_files [] detect json.loads(Path(graphify-out/.graphify_detect.json).read_text(encoding\utf-8\)) for f in detect.get(files, {}).get(code, []): code_files.extend(collect_files(Path(f)) if Path(f).is_dir() else [Path(f)]) if code_files: result extract(code_files, cache_rootPath(INPUT_PATH)) Path(graphify-out/.graphify_ast.json).write_text(json.dumps(result, indent2, ensure_asciiFalse), encoding\utf-8\) print(fAST: {len(result[\nodes\])} nodes, {len(result[\edges\])} edges) else: Path(graphify-out/.graphify_ast.json).write_text(json.dumps({nodes:[],edges:[],input_tokens:0,output_tokens:0}, ensure_asciiFalse), encoding\utf-8\) print(No code files - skipping AST extraction) 这里调用的graphify.extract.extract即 graphify/extract.py 中的统一抽取入口其下游按语言分派到 graphify/extractors/ 下的 tree-sitter 解析器Python、Go、Rust、C#、Swift、SQL、Terraform 等与 tests/test_extract.py 覆盖的行为一致。Part B——语义抽取并行子代理。先是一条“快速路径”纯代码语料跳过 Part B但必须先写出空的.graphify_semantic.json{nodes:[],edges:[],hyperedges:[],input_tokens:0,output_tokens:0}否则 Part C 的合并会因FileNotFoundError失败——因为 Part C 无条件读取该文件。对确实含文档/论文/图片的语料手册把流程拆成 B0–B3 四步并强制要求使用 Pi 的 Agent 工具“逐个自己读文件慢 5–10 倍”B0 查缓存调用 graphify/cache.py 的check_semantic_cache(all_files, root..., prompt_fileSPEC_PATH)只把document/paper/image三类送检代码已被 AST 覆盖视频在 Step 2.5 先转写为文档。SPEC_PATH是随技能分发的 extraction-spec.md 的绝对路径——缓存条目以提示词文件归属graphify 升级改变了抽取提示词后旧条目会被重新抽取而不是直接回放命中写入.graphify_cached.json未命中列表写入.graphify_uncached.txtB1 分块每块 20–25 个文件图片独占一块视觉需要独立上下文同一目录的文件尽量同块便于抽取跨文件关系B2 派发所有子代理调用必须在同一条消息里发出才能真正并行必须用可写盘的通用型 agentPi 中即具备文件写入权限的子代理类型只读代理会把结果悄悄丢掉。派发给每个子代理的提示词逐字取自 extraction-spec.md替换FILE_LIST、CHUNK_NUM、TOTAL_CHUNKS、DEEP_MODE、CHUNK_PATH绝对路径五个占位符B3 收集与合并以.graphify_chunk_NN.json落盘为成功信号缺失或 JSON 无效只警告不中止超过一半分块失败才停止并要求检查代理类型。合并前要把每个 Agent 调用结果usage字段里的真实 token 数写回 chunk JSONchunk 文件里只有占位 0再把所有 chunk 合并为.graphify_semantic_new.json随后用save_semantic_cache(...)把新结果写回缓存传入与 B0 相同的SPEC_PATH最后把“缓存 新增”合并、按节点 id 去重写入.graphify_semantic.json并清理临时文件。extraction-spec 中规定的抽取规则值得单独强调因为它们直接决定图的质量边界每条边必须带confidence_scoreEXTRACTED恒为 1.0INFERRED只能取 0.95/0.85/0.75/0.65/0.55 之一禁止 0.5 默认值AMBIGUOUS为 0.1–0.3节点 id 必须是小写[a-z0-9_]的{stem}_{entity}确定性格式src/auth/session.pyValidateToken→src_auth_session_validatetoken且必须与 AST 抽取器的 id 规则一致——这是 Part C 能按 id 去重、--update能按source_file精确替换而不产生重复节点的前提。Part C——AST 与语义合并AST 节点优先语义节点按 id 去重后追加边直接拼接hyperedges 只来自语义侧最终写入.graphify_extract.json并打印Merged: N nodes, E edges (x AST y semantic)。Step 4–4.5建图、聚类、分析与完整性体检Step 4 是流水线的核心一次调用链跑完“建图 → 社区检测 → 分析 → 导出”四件事对应仓库中四个模块graphify/build.py 的build_from_json、graphify/cluster.py 的cluster/score_all、graphify/analyze.py 的god_nodes/surprising_connections/suggest_questions、graphify/report.py 的generatemkdir -p graphify-out $(cat graphify-out/.graphify_python) -c import sys, json from graphify.build import build_from_json from graphify.cluster import cluster, score_all from graphify.analyze import god_nodes, surprising_connections, suggest_questions from graphify.report import generate from graphify.export import to_json from pathlib import Path extraction json.loads(Path(graphify-out/.graphify_extract.json).read_text(encoding\utf-8\)) detection json.loads(Path(graphify-out/.graphify_detect.json).read_text(encoding\utf-8\)) G build_from_json(extraction, rootINPUT_PATH, directedIS_DIRECTED) # Guard BEFORE any write: an empty extraction must not clobber a good graph.json if G.number_of_nodes() 0: print(ERROR: Graph is empty - extraction produced no nodes.) raise SystemExit(1) communities cluster(G) cohesion score_all(G, communities) tokens {input: extraction.get(input_tokens, 0), output: extraction.get(output_tokens, 0)} gods god_nodes(G) surprises surprising_connections(G, communities) labels {cid: Community str(cid) for cid in communities} questions suggest_questions(G, communities, labels) wrote to_json(G, communities, graphify-out/graph.json) if not wrote: print(ERROR: refused to shrink graphify-out/graph.json (existing graph has more nodes; #479).) raise SystemExit(1) report generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, INPUT_PATH, suggested_questionsquestions) Path(graphify-out/GRAPH_REPORT.md).write_text(report, encoding\utf-8\) analysis { communities: {str(k): v for k, v in communities.items()}, cohesion: {str(k): v for k, v in cohesion.items()}, gods: gods, surprises: surprises, questions: questions, } Path(graphify-out/.graphify_analysis.json).write_text(json.dumps(analysis, indent2, ensure_asciiFalse), encoding\utf-8\) print(fGraph: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges, {len(communities)} communities) 三个占位符约定IS_DIRECTED在给出--directed时替换为TrueNetworkX 的DiGraph保留 source→target 方向否则False默认无向GraphINPUT_PATH替换为实际路径——root参数让source_file相对化到同一基准保证全量构建与--update增量重抽在节点键上完全一致tests/test_build.py 对build_from_json的合并行为有回归覆盖。这段代码里有两道“写前守卫”是手册的诚实性约束落到代码层的体现空图守卫build_from_json后节点数为 0 立即SystemExit(1)绝不用空抽取覆盖已有的graph.json与GRAPH_REPORT.md收缩守卫#479 shrink-guardgraphify/export.py 的to_json在新图比现有graph.json更小时返回False且不写盘只有图确实被写出才允许写报告与分析 sidecar确保报告永远不描述一个graph.json里不存在的图。若收缩确属故意删除了文件需用--force的全量重建。Step 4.5 是一道只读完整性体检调用 graphify/diagnostics.py 的diagnose_extraction专门暴露增量更新与 AST/LLM id 不匹配时的四种静默损坏模式悬空端点边、缺失端点边、自环、同端点坍缩边有向/无向分别计数$(cat graphify-out/.graphify_python) -c import json from pathlib import Path from graphify.diagnostics import diagnose_extraction, format_diagnostic_report extraction json.loads(Path(graphify-out/.graphify_extract.json).read_text(encoding\utf-8\)) summary diagnose_extraction(extraction, directedIS_DIRECTED, rootINPUT_PATH) print(format_diagnostic_report(summary)) flags [f{summary[k]} {label} for k, label in ( (dangling_endpoint_edges, dangling-endpoint edges), (missing_endpoint_edges, missing-endpoint edges), (self_loop_edges, self-loop edges), (directed_same_endpoint_collapsed_edges, collapsed (directed) edges), (undirected_same_endpoint_collapsed_edges, collapsed (undirected) edges), ) if summary.get(k, 0)] print(GRAPH HEALTH WARNING: ; .join(flags) - graph may be incomplete/corrupt. if flags else Graph health: OK (no dangling/missing/collapsed edges).) 该步骤永不中止流程但若打印了GRAPH HEALTH WARNING最终摘要中必须把它显式呈现出来见文末 Honesty Rules。Step 5–6社区打标与可视化输出Step 5 是流水线中唯一要求 agent 发挥语言能力的环节读.graphify_analysis.json为每个社区依据其节点标签起一个 2–5 词的通俗名如 “Attention Mechanism”“Training Pipeline”然后把LABELS_DICT形如{0: Attention Mechanism, 1: Training Pipeline}代回第二段脚本重生成GRAPH_REPORT.md、保存graphify-out/.graphify_labels.json并带community_labelslabels重新to_json一次让graph.json的节点携带 curated 的community_name。由于用的是同一份 extraction节点数不变收缩守卫自然通过若仍被拒只呈现守卫信息不得强推。Step 6 的输出规则很明确HTML 总是生成除非--no-vizgraphify export html节点超过 5000 时自动聚合到社区视图Obsidian vault 仅在显式给出--obsidian时生成每节点一个文件成本高graphify export obsidian自定义目录用--dir默认graphify-out/obsidian--wiki、--neo4j/--neo4j-push、--falkordb/--falkordb-push、--svg、--graphml、--mcp等导出只在对应标志出现时执行各自细节见 references/exports.md--wiki必须在 Step 9 清理前跑完因为它还要读.graphify_labels.json。Step 9manifest 落盘、成本记账与收尾Step 9 是增量能力的记账环节也是最容易写错的一环手册中每条注释都对应一个具体故障模式$(cat graphify-out/.graphify_python) -c import json from pathlib import Path from datetime import datetime, timezone from graphify.detect import save_manifest detect json.loads(Path(graphify-out/.graphify_detect.json).read_text(encoding\utf-8\)) extract json.loads(Path(graphify-out/.graphify_extract.json).read_text(encoding\utf-8\)) from graphify.cli import _stamped_manifest_files _corpus detect.get(all_files) or detect[files] _manifest_files _stamped_manifest_files(_corpus, extract, Path(INPUT_PATH)) _sem_types (document, paper, image) _dispatched {f for t, fl in detect[files].items() if t in _sem_types for f in fl} _stamped {f for fl in _manifest_files.values() for f in fl} _cleared _dispatched - _stamped _scan {f for fl in _corpus.values() for f in fl} save_manifest(_manifest_files, rootINPUT_PATH, scan_corpus_scan, clear_semantic_cleared or None) input_tok extract.get(input_tokens, 0) output_tok extract.get(output_tokens, 0) cost_path Path(graphify-out/cost.json) cost json.loads(cost_path.read_text(encodingutf-8)) if cost_path.exists() else {runs: [], total_input_tokens: 0, total_output_tokens: 0} cost[runs].append({date: datetime.now(timezone.utc).isoformat(), input_tokens: input_tok, output_tokens: output_tok, files: detect.get(total_files, 0)}) cost[total_input_tokens] input_tok cost[total_output_tokens] output_tok cost_path.write_text(json.dumps(cost, indent2, ensure_asciiFalse), encodingutf-8) rm -f graphify-out/.graphify_detect.json graphify-out/.graphify_extract.json \ graphify-out/.graphify_ast.json graphify-out/.graphify_semantic.json \ graphify-out/.graphify_analysis.json find graphify-out -maxdepth 1 -name .graphify_chunk_*.json -delete 2/dev/null其语义可归纳为四条均与 graphify/manifest.py 及--update流程配套由 tests/test_incremental.py、tests/test_stale_prune.py 回归manifest 相对化save_manifest(..., rootINPUT_PATH)把键相对化到扫描根使 manifest 可跨 clone/机器移植下一次--update能命中缓存文件而不是全部漏判只盖真正产出的章语义类文件doc/paper/image只有实际产出节点/边才盖章某文件所在 chunk 失败或未派发就必须不盖章否则下次--update会把它误判为“已完成”而永久丢失内容。代码文件则总是盖章因为 AST 是确定性的清理陈旧 semantic_hash本次派发但未盖章的文件携带上一轮的陈旧 hashclear_semantic参数让detect_incremental重新排队它们而不是当成未变化成本记账graphify-out/cost.json追加每次运行的日期、输入/输出 token 与文件数并累计历史总量——配合 Honesty Rules 的“报告必须展示 token 成本”。收尾后向用户报告产物清单graph.html、GRAPH_REPORT.md、graph.json、可选obsidian/并只粘贴报告中的三个小节——God Nodes、Surprising Connections、Suggested Questions——而不是整份报告随后从建议问题里挑最“跨界”的一个主动邀请探索“The most interesting question this graph can answer:[question]. Want me to trace it?”用户同意后运行/graphify query [question]并带着用户沿图结构走每个回答以自然的追问收尾。手册用一句原话定义了 agent 的终局角色“The graph is the map. Your job after the pipeline is to be the guide.”查询面query、path、explain 与反馈闭环快速路径之外graphify-out/graph.json已存在时任何语料问题都应通过查询回答。/graphify query的完整流程在 references/query.md 中要点包括先做受控查询扩展graphify queryCLI 用“大小写折叠子串 IDF”匹配节点没有词干还原、同义词或跨语言匹配因此先从不带数字下划线的 label 分词构建词表graphify-out/.vocab.txt长度 3–30 的 token再从词表中选至多 12 个与查询意图语义匹配的 token禁止自造 token选不出任何词表词时如实告知语料无相关词汇并停止两种遍历模式BFS默认适合“X 连着什么”的宽上下文DFS 适合“X 如何到达 Y”的链路追踪CLI 不可用时按手册内置的 NetworkX 内联脚本执行BFS 3 层、DFS 深度上限 6、--budget默认 2000 token 约 4 字符/token 截断只答图里有的东西回答仅使用遍历输出引用具体事实时引用source_location信息不足就明说不虚构边反馈闭环回答后用graphify save-result --question ... --answer ... --type query --nodes ...写回graphify/querylog.py 支撑的 CLI见 graphify/cli.py下一次--update会把这个 QA 抽取为图节点再加--outcome useful|dead_end|corrected配--correction沉淀经验会话开始时运行graphify reflect --if-stale并阅读graphify-out/reflections/LESSONS.mdpreferred sources / known dead ends / corrections构成自改进循环/graphify path A B求两概念最短路径CLI 或 NetworkXshortest_path内联脚本逐跳解释后同样save-result --type path_query/graphify explain X给出单节点的 3–5 句通俗解释来源、类型、度、全部带关系与置信度的邻接边save-result --type explain。子命令守卫与外围能力手册还规定了三个外围约定解释器守卫执行任何子命令--update、--cluster-only、query、path、explain、add前先检查.graphify_python是否存在缺失如用户删了graphify-out/则从which graphify的 shebang 重新解析解释器并落盘再回退python3--update/--cluster-only均为非默认子命令前者只重抽新增/变更文件后者在既有图上重跑聚类两条流程都在 references/update.md 中底层对应 graphify/manifest.py 的增量检测与 build-merge 替换逻辑add url与--watch不属于默认构建前者抓取 URL 存入./raw并增量更新图后者监听目录自动重建纯代码变更不需要 LLM细节见 references/add-watch.md--watch由 graphify/watch.py 实现commit 钩子与 CLAUDE.md 集成用户要求安装 post-commit 自动重建钩子或把 graphify 接入项目 CLAUDE.md 时走 references/hooks.md底层为 graphify/hooks.pyREADME 中提到钩子脚本在安装时内嵌解释器绝对路径因此 GUI git 客户端与 CI 环境同样可靠升级后需重跑graphify hook install刷新路径。Honesty Rules手册的五条诚实约束文档以五条不可协商的规则收尾它们贯穿全文的每一个守卫分支Never invent an edge——不确定就用AMBIGUOUS标记而不是省略或杜撰与 extraction-spec 的置信度量规一一对应Never skip the corpus check warning——Step 2 的大语料警告不可省略Always show token cost in the report——cost.json记账数据必须呈现给用户Never hide cohesion scores behind symbols——社区凝聚度显示原始数值不做符号化包装Never run HTML viz on a graph with more than 5,000 nodes without warning——超过 5000 节点先警告graphify export html此时会自动聚合到社区视图。小结与延伸阅读skill-pi.md本质上是一份“给 agent 看的 SOP”它把 graphify 的九步流水线解释器探测 → 文件体检 → AST/语义双通道抽取 → 建图聚类与双守卫导出 → 社区打标 → 可视化 → 记账清理翻译成可在 Pi 会话中逐条执行的 bash 块并用 references 目录做按需加载的上下文瘦身。对阅读仓库源码的开发者而言理解这份手册最快的路径是按其步骤顺序对照模块graphify/detect.pyStep 2、graphify/extract.py 与 graphify/extractors/Part A、graphify/cache.pyB0/B3、graphify/build.py graphify/cluster.py graphify/analyze.py graphify/export.pyStep 4、graphify/diagnostics.pyStep 4.5、graphify/report.pyStep 5、graphify/manifest.py graphify/cli.pyStep 9 与 save-result/reflect。而 Pi 平台如何拿到这份技能则由 graphify/install.py 的安装表与 tools/skillgen/platforms.toml 的生成配置共同保证。【免费下载链接】graphifyTurn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable knowledge graph. A /graphify skill for Claude Code, Cursor, Codex, and Gemini CLI: local deterministic AST parsing, every edge explained, no vector store.项目地址: https://gitcode.com/GitHub_Trending/graph/graphify创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
RELATED READING

延伸阅读

更多一线实战笔记与深度复盘,助您持续精进