Conversation
Addresses the structural visibility gap documented in issue m#3: the flat plan table hides parent-child relationships, making it impossible to see when retiring or merging a category would orphan its children. render_category_tree() in lib/helpers.py takes the exported categories and an actions dict, then renders an annotated ASCII tree with box-drawing characters showing merges, retirements, new categories, and orphan warnings at a glance. 21 new tests covering nesting, annotations, orphan detection, edge cases (circular parents, missing parents, create-only). AGENTS.md updated to reference the tree view before the flat table in the Plan & Descriptions step. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Coerce term_id and parent to int in _build_tree (WordPress APIs may return string IDs, causing false "parent missing" warnings) - Add test for string ID handling - Add test for circular parent detection - Move _detect_orphans import to top-level in tests - Fix test name: test_one_orphan → test_all_children_orphaned - Fix AGENTS.md example to match actual two-space output format Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2fe7377 to
5122311
Compare
The main value of the tree view is orphan detection — the docs example should demonstrate it, not hide it behind a footnote. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jeherve
left a comment
There was a problem hiding this comment.
This is looking good. I only have a minor comment, below.
| if synthetic: | ||
| label = name | ||
| if count: | ||
| label += f' ({count})' | ||
| else: | ||
| label = f'{name} ({count})' |
There was a problem hiding this comment.
Small inconsistency I noticed here: real categories always render as Name (count), even when count is 0, but synthetic ones drop the (0) and just show Name. So a plan that mixes a real empty category with a brand-new one ends up looking like this:
├── 1999 (0)
├── Fresh Pick ★ new
└── The Good Wife (0)
Same numeric count, two different treatments, and as a reviewer I can't really tell whether Fresh Pick has unknown count, zero count, or "doesn't apply." I tested this against a site of mine that happens to have a few count=0 categories and the ambiguity is real.
I'm wondering if we could just always render (count) for both, even when it's 0? It's a one-liner — drop the if synthetic branch and always do f'{name} ({count})'.
There was a problem hiding this comment.
Good catch, and thanks for testing it against a real site. You're right that the two treatments are confusing. A bare name next to names with (0) leaves you guessing whether the count is zero or just not applicable.
Fixed in 9f99b3d. Dropped the special-case branch entirely so both real and synthetic nodes always render as Name (count). Also removed the now-unused synthetic variable and updated the example output in AGENTS.md.
Before:
├── 1999 (0)
├── Fresh Pick ★ new
└── The Good Wife (0)
After:
├── 1999 (0)
├── Fresh Pick (0) ★ new
└── The Good Wife (0)
All 80 tests pass.
Fixes visual inconsistency where real categories rendered as Name (0) but synthetic (create action) nodes dropped the count and showed just Name. This made it unclear whether a new category had zero posts or an unknown count. Now both render uniformly as Name (0). Addresses review feedback from @jeherve. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jeherve
left a comment
There was a problem hiding this comment.
This tests well for me now, it should be good to go!
Addresses the structural visibility gap from #3: the flat plan table hides parent-child relationships, making it impossible to see when retiring a category would orphan its children.
What it does
render_category_tree()inlib/helpers.pytakes the exported categories and an actions dict, renders an annotated ASCII tree:Retire/merge/create actions are annotated inline. Orphan warnings appear when retiring a parent would leave kept children stranded at root level.
Changes
lib/helpers.py: 5 new functions (~280 lines), pure stdlib Pythontests/test_helpers.py: 21 new tests (18 tree rendering + 3 orphan detection)AGENTS.md: new "Hierarchy Tree View" section before the flat table, with usage example and actions schemaagents/analyze.md: note about includingparent_slugfor new category suggestionsEdge cases handled
All 80 existing + new tests pass.