consolidate
Merge near-duplicate or heavily-overlapping pages. Ported from vanillaflava’s wiki-integrate. Propose-first, act-only-on-approval — the graph is load-bearing and silent merges corrupt it.
When to use
- User runs
/consolidate. - User points at specific pages: “merge A and B”.
reconcilereport surfaced merge candidates and user wants to action them.
Workflow
1. Identify candidates
If given specific pages, skip to step 2.
Otherwise, scan for:
- Pages with near-identical titles (edit distance ≤3, case-insensitive).
- Pages with ≥60% body overlap (crude: shared tokens, shared wikilinks, shared headings).
- Pages where one is a clear superset of the other.
Limit to ~5 candidate pairs per run. More than that means a bigger cleanup session is needed.
2. Propose — do NOT merge yet
For each candidate pair, produce a proposal:
### Proposal: [[Page A]] + [[Page B]]
**Recommendation:** Keep [[Page A]] as target, merge [[Page B]] into it.
**Reason:** <why A is the better target — more inbound links, more complete body, newer, clearer title, etc.>
**Content deltas:**
- Sections unique to B that should land in A: <list>
- Conflicting claims (need human resolution): <list>
**Link migration:** N pages currently wikilink to [[Page B]] — would be retargeted to [[Page A]].
**Changes if approved:**
- Append B's unique sections to A.
- Add B's tags to A (deduplicated).
- Redirect all inbound wikilinks from [[Page B]] to [[Page A]].
- Delete B, OR turn B into a redirect stub with `aliases: [Page B]` on A.Present all proposals to the user. Wait for explicit approval per pair before acting.
3. Apply (only on approval)
Per approved pair:
-
Merge unique content from source into target, preserving order and context.
-
Deduplicate tags.
-
grep -rl '\[\[Page B\]\]'across vault, rewrite each occurrence to[[Page A]](or[[Page A|Page B]]if the original display text mattered). -
Add
Page Btoaliases:in target’s frontmatter. -
Delete source file.
-
Append to log:
## [YYYY-MM-DD] consolidate | [[Page A]] ← [[Page B]] - Links retargeted: N - Conflicts resolved: <list>
Rules
- Never silent-merge. Always propose; always wait.
- Target = more connected, more complete, newer — in that order of priority.
- Preserve aliases. The merged title becomes an alias on the target so old links keep working.
- Don’t merge across
_Canon/boundary. If one page is canon and the other isn’t, the non-canon page gets absorbed if the canon page genuinely covers its content; otherwise leave them separate. - One-way. A + B → A (not a new page). Picking a survivor matters.
- Per-pair approval. Don’t batch-approve.
Blocked cases
- Conflicting facts between pages → surface in proposal, user resolves before approval.
- Both pages are canon → do not propose. Log as a structural issue for next reconcile.
- Source page has many unique inbound links from very different topics → probably not a duplicate. Reconsider.
Verification
- After approved merges,
grep -r '\[\[Page B\]\]'returns empty (or onlyaliases:frontmatter). - log has the entry.
git diffshows the merge, link rewrites, and deletion.