Repository navigation
Description
Feature request: post-commit hook should optionally rebuild the wiki
Today graphify hook install produces a hook that rebuilds
graph.json / graph.html / GRAPH_REPORT.md after each commit but
skips the wiki. Wiki drift is silent: agents read stale community
articles after every code change.
Proposed
graphify hook install --with-wiki flag adds a wiki rebuild step to
the post-commit hook. Implementation is a small addition that calls
graphify.wiki.to_wiki(G, communities, output_dir, ...) from the
existing graph.json after the AST rebuild — no LLM cost, ~1-2 seconds
for a 1000-node graph.
Workaround today
Users either run graphify <path> --wiki manually on a cadence, or
extend the hook by hand (which the next graphify hook install may
clobber). Both work, but staleness is silent and the manual rebuild
is easy to forget.
Why it matters
Agents that follow the integration guidance (e.g. the ## graphify
section that graphify claude install writes into CLAUDE.md) prefer
graphify-out/wiki/index.md over raw file reads. If the wiki is
stale relative to the AST graph, the agent navigates outdated
community structure for current code state.
Suggested shape
graphify hook install # existing behavior, code-only
graphify hook install --with-wiki # adds wiki rebuild
graphify hook install --without-wiki # explicit opt-out (default)
Or a config knob in a .graphify.toml so projects can opt in once
without re-running hook install.
Implementation sketch
The post-commit hook currently calls (roughly) graphify update ..
Adding a wiki step would be:
from pathlib import Path
import json
from graphify.build import build_from_json
from graphify.cluster import score_all
from graphify.wiki import to_wiki
from graphify.analyze import god_nodes
from networkx.readwrite import json_graph
data = json.loads(Path('graphify-out/graph.json').read_text())
G = json_graph.node_link_graph(data, edges='links')
communities = {}
for nid, d in G.nodes(data=True):
cid = d.get('community')
if cid is not None:
communities.setdefault(int(cid), []).append(nid)
to_wiki(G, communities, 'graphify-out/wiki',
cohesion=score_all(G, communities), god_nodes_data=god_nodes(G))Adds ~1-2s to commit time on a 1000-node graph; opt-in via flag keeps
default behavior unchanged.
Happy to PR if direction is acceptable.
Activity