Absolutely, here is the canon‑aligned, repo‑safe, bulk diagram.md generator, designed to live in your active directory:
docs/tools/
and built to work seamlessly with your existing bulk generators.
This script:
- Walks your entire
/docstree - Detects module directories
- Reads each module’s
module.json - Creates diagram.md only where missing
- Auto‑fills a clean, canonical diagram scaffold
- Never overwrites existing diagram.md
- Produces consistent structure across all ~200 modules
- Ensures every module has a visual‑index anchor for AI navigation
This completes the visual documentation layer of TriadicFrameworks.
⭐ Bulk diagram.md Generator
Save as:
docs/tools/generate_all_diagram_md.py
Run from repo root:
python3 docs/tools/generate_all_diagram_md.py
🟦 generate_all_diagram_md.py (Final Canon Version)#
import os
import json
EXCLUDED_DIRS = {
"spine",
"_template",
"assets",
"images",
"tools"
}
def load_module_json(path):
module_json_path = os.path.join(path, "module.json")
if not os.path.exists(module_json_path):
return None
with open(module_json_path, "r", encoding="utf-8") as f:
return json.load(f)
def is_module_dir(path):
return "module.json" in os.listdir(path)
def generate_diagram_md(path, module):
diagram_path = os.path.join(path, "diagram.md")
if os.path.exists(diagram_path):
print(f"❌ diagram.md already exists in {path}, skipping.")
return
name = module["name"]
category = module["category"]
content = f"""# {name} — Diagram
## Canon Diagram Overview
This diagram provides a structural visualization of the **{name}** module within the **{category}** domain of TriadicFrameworks.
It is designed to be AI‑readable, drift‑resistant, and canon‑aligned.
---
## Module Position in Canon
- **RTT Layer:** {module['rtt']['layer']}
- **Canon Reference:** `/docs/spine/spine.json`
- **Triad Inheritance:** RTT + TFT triads
- **Session Context:** rtt=1 | coherence=declared | drift=bounded | paradox=structural
---
## Diagram (Mermaid Spec Placeholder)
```mermaid
flowchart TD
A[Module: {name}] --> B[Category: {category}]
A --> C[RTT Layer: {module['rtt']['layer']}]
A --> D[Canon Ref: spine.json]
A --> E[Triads: RTT + TFT]
A --> F[Session Context]Notes#
- This diagram is a placeholder scaffold.
- You may replace the Mermaid block with a more detailed module‑specific diagram.
- AI engines use this file as a visual anchor for module navigation.
Generated automatically by generate_all_diagram_md.py.
with open(diagram_path, "w", encoding="utf-8") as f:
f.write(content)
print(f"✔ Created {diagram_path}")
def main():
print("\n=== TriadicFrameworks Bulk diagram.md Generator ===\n")
for root, dirs, files in os.walk("docs"):
if any(ex in root for ex in EXCLUDED_DIRS):
continue
if is_module_dir(root):
module_data = load_module_json(root)
if module_data:
module = module_data["module"]
generate_diagram_md(root, module)
print("\n✨ Bulk diagram.md generation complete.\n")
if __name__ == "__main__":
main()⭐ What This Script Gives You#
✔ Creates diagram.md for every module#
✔ Pulls real metadata from module.json#
✔ Never overwrites existing diagrams#
✔ Provides a canonical Mermaid scaffold#
✔ Ensures RTT + TFT triads are documented#
✔ Ensures session context is documented#
✔ Ensures AI initialization context is visible#
✔ Produces consistent visual anchors across all modules#
This completes the visual coherence layer of TriadicFrameworks.