feat(wiki): preserve hand-authored custom pages across export#2159
Open
TomaszWu14 wants to merge 1 commit into
Open
feat(wiki): preserve hand-authored custom pages across export#2159TomaszWu14 wants to merge 1 commit into
TomaszWu14 wants to merge 1 commit into
Conversation
`graphify export wiki` deleted every `wiki/*.md` at the start of each run (to clear orphaned community articles, since LLM labels are non-deterministic). That also deleted any page a user added by hand — custom analysis, notes — with no way to keep them. Instead, track generated files in a `.graphify_wiki_files.json` manifest and on re-export delete only our own prior output (files generated last run but not this run, e.g. renamed communities). Any file graphify never wrote is preserved. Preserved pages are auto-listed in a "Custom Pages" section of index.md, titled by their first markdown H1, so they stay reachable from the entry point. First run after upgrade has no manifest and deletes nothing, so existing custom pages survive the migration; orphans self-heal on the next run. Adds 5 tests covering preservation, index linking, own-orphan cleanup, the manifest, and the no-H1 title fallback.
Author
|
Friendly heads-up: this PR is a first-time contribution, so the CI workflows are sitting in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
graphify export wikideletes everywiki/*.mdat the start of each run:This exists to clear orphaned community articles (LLM-generated labels are non-deterministic, so a renamed community would otherwise leave its old file behind). But it also deletes any page a user added by hand — custom analysis, notes, topology deep-dives — with no way to keep them. Re-running the export silently wipes them, and there's no opt-out.
Fix
to_wikinow tracks the files it generates in a.graphify_wiki_files.jsonmanifest and, on re-export, deletes only its own prior output (files it generated last run but not this run — e.g. renamed communities). Any file graphify never wrote is left untouched.Preserved pages are also auto-listed in a Custom Pages section of
index.md, titled by their first markdown# H1(falling back to a de-slugged filename), so they stay reachable from the agent entry point instead of becoming orphans.Migration safety: the first run after upgrade has no manifest, so it deletes nothing — existing custom pages survive. Self-generated orphans are cleaned up from the next run onward.
Behavior
my-analysis.mdnow survives re-export and appears under## Custom Pagesin the index.Tests
Adds 5 tests to
tests/test_wiki.py:test_to_wiki_preserves_custom_pagestest_index_lists_custom_pages_by_h1test_to_wiki_removes_only_its_own_orphanstest_to_wiki_writes_manifesttest_custom_page_without_h1_falls_back_to_filenamepytest tests/test_wiki.py→ 35 passed (30 existing + 5 new).Notes
import jsonmoved to module level (was needed by the new manifest read/write).to_wiki's signature is unchanged._index_mdgains an optionalcustom_pagesargument.