···408408 "links": {
409409 "https://example.com/post/123": {
410410 "referencing_entries": ["https://blog.user.com/entry/456"],
411411- "is_tracked_post": true,
412411 "target_username": "user2"
413412 },
414413 "https://external-site.com/article": {
415415- "referencing_entries": ["https://blog.user.com/entry/789"],
416416- "is_tracked_post": false
414414+ "referencing_entries": ["https://blog.user.com/entry/789"]
417415 }
418416 },
419417 "reverse_mapping": {
···438436```
439437440438This unified structure eliminates duplication by:
441441-- Storing each URL only once with metadata flags
439439+- Storing each URL only once with minimal metadata
442440- Including all link data, reference data, and mappings in one file
443443-- Using `is_tracked_post` to identify internal vs external links
441441+- Using presence of `target_username` to identify tracked vs external links
444442- Providing bidirectional mappings for efficient queries
445443446444### Unified Structure Benefits
+8-15
src/thicket/cli/commands/links_cmd.py
···320320 reverse_mapping = {}
321321322322 for url, entry_ids in link_dict.items():
323323- is_tracked = url in registered_urls
324324- target_username = None
323323+ unified_links[url] = {
324324+ "referencing_entries": entry_ids
325325+ }
325326326327 # Find target username if this is a tracked post
327327- if is_tracked:
328328+ if url in registered_urls:
328329 for username in users:
329330 user_domains_set = {domain for domain in user_domains.get(username, [])}
330331 if any(domain in url for domain in user_domains_set):
331331- target_username = username
332332+ unified_links[url]["target_username"] = username
332333 break
333334334334- unified_links[url] = {
335335- "referencing_entries": entry_ids,
336336- "is_tracked_post": is_tracked
337337- }
338338-339339- if target_username:
340340- unified_links[url]["target_username"] = target_username
341341-342335 # Build reverse mapping
343336 for entry_id in entry_ids:
344337 if entry_id not in reverse_mapping:
···355348356349 if verbose:
357350 console.print(f"Found {len(registered_urls)} registered post URLs")
358358- console.print(f"Found {len(link_dict)} total links, {sum(1 for link in unified_links.values() if link['is_tracked_post'])} tracked posts")
351351+ console.print(f"Found {len(link_dict)} total links, {sum(1 for link in unified_links.values() if 'target_username' in link)} tracked posts")
359352360353 # Save unified data
361354 with open(output_path, "w") as f:
···373366 print(f"Unknown\t{len(link_categories['unknown'])}\tLinks to external sites")
374367 print(f"Total Extracted\t{len(all_links)}\tAll extracted links")
375368 print(f"Saved to Output\t{len(output_data['links'])}\tLinks saved to output file")
376376- print(f"Cross-references\t{sum(1 for link in unified_links.values() if link['is_tracked_post'])}\tLinks to registered posts only")
369369+ print(f"Cross-references\t{sum(1 for link in unified_links.values() if 'target_username' in link)}\tLinks to registered posts only")
377370 else:
378371 table = Table(title="Links Summary")
379372 table.add_column("Category", style="cyan")
···385378 table.add_row("Unknown", str(len(link_categories["unknown"])), "Links to external sites")
386379 table.add_row("Total Extracted", str(len(all_links)), "All extracted links")
387380 table.add_row("Saved to Output", str(len(output_data['links'])), "Links saved to output file")
388388- table.add_row("Cross-references", str(sum(1 for link in unified_links.values() if link['is_tracked_post'])), "Links to registered posts only")
381381+ table.add_row("Cross-references", str(sum(1 for link in unified_links.values() if 'target_username' in link)), "Links to registered posts only")
389382390383 console.print(table)
391384