mattrguerra/meridian-skillsmainPrivate on GitHub, published here in full

builder-api.md

Language Markdown6.9 KB163 lines

skills/sop-author/references/builder-api.md

  1. # build_sop.py: API reference
  2. The helper script `scripts/build_sop.py` takes a Python dict and produces a styled Meridian SOP .docx. Use it as the default path; only drop down to raw python-docx when the content needs layout the builder doesn't cover.
  3. ## Top-level dict
  4. ```python
  5. {
  6. "title": "Mockup File Naming Convention", # required, str
  7. "owner": "Matt Guerra", # required, str: full name
  8. "initials": "MG", # required, str: 2 or 3 letters
  9. "category": "Operations", # required, str
  10. "effective_date": "04/2026", # required, str: MM/YYYY with slash
  11. "folder_context": "07 - Mockup Artwork Files", # optional, str: appears on line 2 of title bar
  12. "draft": False, # optional, bool: prepends DRAFT_
  13. "template": False, # optional, bool: inserts _TEMPLATE before date
  14. "output_path": "/path/to/output_dir", # optional, str: directory or full path
  15. "sections": [ ... ], # required, list[dict]: see below
  16. }
  17. ```
  18. If `output_path` is a directory, the file is saved inside it using the canonical filename. If it's a full path with a different filename, the builder overrides with the canonical filename (`force_filename: False` to disable).
  19. ## Section types
  20. Each section in `sections` is a dict with a `type` and content fields.
  21. ### Required content sections
  22. ```python
  23. {"type": "purpose", "text": "This SOP defines ..."}
  24. # Renders Heading 1 "Purpose" + body paragraph
  25. {"type": "scope", "text": "This SOP applies to all team members who ..."}
  26. # Renders Heading 1 "Scope & Responsibility" + body paragraph
  27. ```
  28. ### Heading sections
  29. ```python
  30. {"type": "h1", "text": "Folder Structure"}
  31. {"type": "h2", "text": "1.1 Folder Creation & Numbering"}
  32. {"type": "h3", "text": "Components"}
  33. ```
  34. ### Body content
  35. ```python
  36. {"type": "body", "text": "All mockup design files must follow this format..."}
  37. # Arial 11pt black, normal paragraph
  38. {"type": "accent_subhead", "text": "Versioning"}
  39. # Arial Bold 12pt Meridian navy, for in-section topic labels
  40. {"type": "bullet", "text": "Start at v1 for every new job."}
  41. # Bulleted list item, Arial 11pt
  42. {"type": "numbered", "text": "Open the Shared Drive in your browser."}
  43. # Numbered list item, Arial 11pt
  44. {"type": "code", "text": "07 - Mockup Artwork Files\n├── [COMPANY-ID]_[COMPANY NAME]\n└── ..."}
  45. # Multi-line monospace blue code/path block
  46. {"type": "warning", "text": "Do not use 00 for functional folders; it's for SOPs & How-To's only."}
  47. # Bold red callout
  48. {"type": "blank"}
  49. # Inserts a blank paragraph for spacing
  50. ```
  51. ### Tables
  52. ```python
  53. {"type": "format_spec", "text": "Mockup_v[#]_[MM/YYYY]_[Initials]"}
  54. # 1-cell light-blue table with the format pattern in monospace blue bold
  55. {"type": "components_table", "rows": [
  56. ["Component", "Value", "Description"],
  57. ["Mockup", "Always \"Mockup\"", "Fixed document type prefix."],
  58. ["v[#]", "v1, v2, v3...", "Version number."],
  59. ["[MM/YYYY]", "04/2026", "Month and year of creation."],
  60. ["[Initials]", "MG, MI, RM, etc.", "Initials of the team member."],
  61. ]}
  62. # 3-col table. First row is the header. Second column rendered in code style.
  63. {"type": "examples_table", "rows": [
  64. ["Folder", "Sub DIR", "File Name(s)"],
  65. ["NORTHWIND ACADEMY", "H4A", "Mockup_v1_04/2026_RG"],
  66. ["NORTHWIND ACADEMY", "", "Mockup_v2_04/2026_RG"],
  67. ]}
  68. # 3-col table. First row is the header. Last column rendered in code style.
  69. {"type": "note", "text": "Note: This naming convention applies to files inside the 07 - Mockup Artwork Files folder only."}
  70. # 1-cell light-yellow note box, italic gray text
  71. {"type": "quick_ref", "text": "Mockup Format:\nMockup_v[#]_[MM/YYYY]_[Initials]\nFirst version: Mockup_v1_04/2026_RG\nRevision: Mockup_v2_04/2026_RG\nApproved final: Mockup_v3_FINAL_04/2026_RG"}
  72. # 1-cell light-blue reference card, multi-line monospace blue
  73. ```
  74. ## Driver example
  75. A complete driver script the model would write to use the builder:
  76. ```python
  77. import sys
  78. sys.path.insert(0, "/path/to/sop-author/scripts")
  79. from build_sop import build_sop
  80. spec = {
  81. "title": "Mockup Handoff",
  82. "owner": "Matt Guerra",
  83. "initials": "MG",
  84. "category": "Operations",
  85. "effective_date": "05/2026",
  86. "folder_context": "02 - Operations Client Facing > Mockup Handoffs",
  87. "output_path": "/path/to/output_dir",
  88. "sections": [
  89. {"type": "purpose", "text": "This SOP defines the procedure for handing off approved client mockups from the Design team to Client Success."},
  90. {"type": "scope", "text": "Applies to all Display Consultants and CS Associates handling client mockup approvals."},
  91. {"type": "h1", "text": "Process"},
  92. {"type": "h2", "text": "1. Mockup Finalization (Design)"},
  93. {"type": "numbered", "text": "Move the approved mockup file to the client's order folder under 03 - Orders Artwork Files."},
  94. {"type": "numbered", "text": "Rename the file to include _FINAL before the date."},
  95. {"type": "numbered", "text": "Add a comment in the client's CRM record noting the file is ready."},
  96. {"type": "h2", "text": "2. Handoff Notification (Design → CS)"},
  97. {"type": "numbered", "text": "Post in #handoffs with the order number, client name, and the file path."},
  98. {"type": "numbered", "text": "Tag the CS Associate assigned to the order."},
  99. {"type": "h2", "text": "3. CS Confirmation"},
  100. {"type": "numbered", "text": "CS opens the file, spot-checks against the approval thread."},
  101. {"type": "numbered", "text": "If clean: send to the client via the standard delivery email."},
  102. {"type": "numbered", "text": "If issues: return to Design with specifics. Do not edit Design's file."},
  103. {"type": "h1", "text": "Best Practices"},
  104. {"type": "accent_subhead", "text": "Speed vs. Accuracy"},
  105. {"type": "bullet", "text": "Same-day handoff is the goal, but CS confirmation can take up to 24h on high-volume days."},
  106. {"type": "bullet", "text": "Never skip the CS spot-check. The CS Associate is the last set of eyes before the client."},
  107. {"type": "h1", "text": "Quick Reference Card"},
  108. {"type": "quick_ref", "text": "1. Design finalizes file → renames _FINAL → moves to order folder.\n2. Design posts in #handoffs, tags CS.\n3. CS spot-checks.\n4. CS sends to client (or returns to Design)."},
  109. ],
  110. }
  111. out = build_sop(spec)
  112. print(f"Saved: {out}")
  113. ```
  114. ## Validating an existing SOP
  115. ```bash
  116. python3 scripts/build_sop.py --validate /path/to/some_sop.docx
  117. ```
  118. Prints a PASS/FAIL/WARN for each check. Exits 0 if no FAILs.
  119. ## Things the builder does NOT do
  120. - It does not infer SOP type from the content; you must pick the type and pass the right section list.
  121. - It does not edit an existing SOP in place; it always builds from scratch (using the template asset for style inheritance).
  122. - It does not check that the user's content is good. Garbage in → formatted garbage out.
  123. - It does not upload to Drive.