Add --with-wiki flag to 'graphify hook install' (#549)#673
Add --with-wiki flag to 'graphify hook install' (#549)#673azizur100389 wants to merge 1 commit intosafishamsi:v6from
Conversation
The current post-commit hook rebuilds graph.json / graph.html / GRAPH_REPORT.md but skips the wiki, so agents that follow the integration guidance and read graphify-out/wiki/index.md get stale community articles on every code change. Today users either run 'graphify <path> --wiki' manually on a cadence or extend the hook by hand (clobbered on the next 'graphify hook install'). This adds an opt-in --with-wiki flag that injects a wiki rebuild block into the post-commit hook after the AST rebuild. No LLM cost - it reuses the freshly-written graph.json plus the existing .graphify_labels.json (when available) to call wiki.to_wiki(). Default behavior is unchanged: 'graphify hook install' produces the same script as before. The wiki rebuild only runs when the user explicitly opts in via 'graphify hook install --with-wiki'. Implementation: - hooks.py: extract _HOOK_SCRIPT into a _build_hook_script(with_wiki) factory; install() takes a with_wiki kwarg - __main__.py: parse --with-wiki for the 'hook install' subcommand and thread it through; update help text - tests: 4 new tests covering default vs --with-wiki vs uninstall round trip, plus an equivalence check that with_wiki=False matches the previously-shipped _HOOK_SCRIPT byte-for-byte
|
Hi, Severity: action required | Category: correctness How to fix: Rewrite existing marked hook Agent prompt to fix - you can give this to your LLM of choice:
We noticed a couple of other issues in this PR as well - happy to share if helpful. Spotted by Qodo code review - free for open-source projects. |
Summary
Issue #549 reports that the post-commit hook rebuilds
graph.json/graph.html/GRAPH_REPORT.mdbut skips the wiki, so agents following the integration guidance (readinggraphify-out/wiki/index.md) navigate stale community articles after every code change. The reporter's workaround was either runninggraphify <path> --wikimanually or hand-editing the hook (clobbered by the nextgraphify hook install).This adds an opt-in
--with-wikiflag:Implementation matches the design in #549: no LLM cost, reuses the freshly-written
graph.jsonplus.graphify_labels.jsonto callwiki.to_wiki().Diff
graphify/hooks.py— extracted_HOOK_SCRIPTinto a_build_hook_script(with_wiki: bool)factory;install()takes awith_wiki=Falsekwarggraphify/__main__.py— parse--with-wikiforhook install; updated help texttests/test_hooks.py— 4 new testsBackward compatibility
Default behavior unchanged:
graphify hook installproduces the same script as before. A regression test (test_build_hook_script_wiki_block_only_when_requested) asserts byte-for-byte equivalence with the legacy_HOOK_SCRIPTconstant whenwith_wiki=False. Existing installations don't need any action.Closes #549
Test plan
4 new tests:
test_install_default_omits_wiki_rebuild— without flag, hook script doesn't importto_wikitest_install_with_wiki_injects_wiki_rebuild— with flag, hook contains the wiki block + AST rebuild +--with-wikimarkertest_install_with_wiki_then_uninstall_clean— uninstall removes the entire graphify section, no wiki residuetest_build_hook_script_wiki_block_only_when_requested—_build_hook_script(with_wiki=False) == _HOOK_SCRIPTbyte-for-byteAll existing tests pass; no behavior change for non-opt-in users.