#!/usr/bin/env python3
"""fig-ledger — 公众号文章 §4「组织台账」概念图生成脚本（可复现）

跑法（任意目录）:
    python3 gen_fig_ledger.py
产出（脚本所在目录）: fig-ledger.svg + fig-ledger.png（宽 1400）
依赖: brand-figures skill 的 figlib（qlmanage + PIL，macOS 本机可用）
"""
import os
import sys

FIGLIB_DIR = '/Users/linoyeung/Documents/codexworkspace/.claude/skills/brand-figures/scripts'
sys.path.insert(0, FIGLIB_DIR)
from figlib import O, INK, GRAY, BORDER, LIGHT, head, tail, t, rr, arrow, render

HERE = os.path.dirname(os.path.abspath(__file__))
SVG = os.path.join(HERE, 'fig-ledger.svg')
H = 600  # 语义高度

s = head(1200, H)

# ---- 大标题 ----
s += t(600, 58, '组织台账：项目干到哪，永远记得', 30, INK, 'bold')

# ---- 连线（先画线，端点钉在块边缘，块后画不被线压）----
# 左：GM(右边缘 x=310) → 台账(左边缘 x=470)，y=215
s += arrow(310, 215, 470, 215)
# 右：台账(右边缘 x=730) → 开工简报(左边缘 x=810)，y=190
s += arrow(730, 190, 810, 190)
# 右：开工简报(下边缘 y=230) → 新角色接活(上边缘 y=290)
s += arrow(915, 230, 915, 290)

# ---- 左侧 · 写入侧 ----
# 总经理 GM（人类 → 墨色块）
s += rr(90, 180, 220, 70, INK, 'none', 0, 14)
s += t(200, 223, '总经理 GM', 20, '#FFFFFF', 'bold')
s += t(390, 200, '明明白白地写', 18, O, 'bold')
# 被否掉的路径：AI 自动总结（灰块 + 线画 ✕）
s += rr(90, 330, 220, 70, '#FFFFFF', GRAY, 2, 14)
s += t(200, 372, 'AI 自动总结', 18, GRAY, 'bold')
s += (f'<line x1="102" y1="338" x2="298" y2="392" stroke="{GRAY}" stroke-width="5"/>'
      f'<line x1="298" y1="338" x2="102" y2="392" stroke="{GRAY}" stroke-width="5"/>')
s += t(200, 430, '会失真、不可控', 16, GRAY)

# ---- 中央 · 项目台账卡片 ----
s += rr(470, 130, 260, 290, '#FFFFFF', O, 3, 18)
s += t(600, 172, '项目台账', 22, O, 'bold')
for i, label in enumerate(['当前目标', '待决的问题', '关键的引用']):
    y = 192 + i * 72
    s += rr(492, y, 216, 58, LIGHT, 'none', 0, 10)
    s += t(600, y + 37, label, 17, INK, 'bold')
s += t(600, 450, '只记规定好的几栏', 16, GRAY)

# ---- 右侧 · 读出侧 ----
# 开工简报（打包件：浅橙底 + 橙描边）
s += rr(810, 150, 210, 80, LIGHT, O, 2, 14)
s += t(915, 182, '开工简报', 18, INK, 'bold')
s += t(915, 212, '台账 + 角色职责 打包', 16, GRAY)
# 新角色接活（AI 角色 → 橙块）
s += rr(810, 290, 210, 70, O, 'none', 0, 14)
s += t(915, 333, '新角色接活', 18, '#FFFFFF', 'bold')
s += t(915, 396, '一上来就知道：干到哪了、', 16, GRAY)
s += t(915, 420, '目标是什么、之前定过什么', 16, GRAY)

# ---- 底部结论条 ----
s += rr(90, 500, 1020, 60, LIGHT, 'none', 0, 16)
s += t(600, 537, '每条记录谁写的、为什么写，全部可查。', 18, INK, 'bold')

s += tail()
open(SVG, 'w').write(s)
render(SVG, H)
