#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from pptx import Presentation
from pptx.util import Inches, Pt

# 创建演示文稿
prs = Presentation()
prs.slide_width = Inches(13.333)
prs.slide_height = Inches(7.5)

def add_title_slide(prs, title, subtitle):
    slide = prs.slides.add_slide(prs.slide_layouts[0])
    slide.shapes.title.text = title
    slide.placeholders[1].text = subtitle
    return slide

def add_content_slide(prs, title, content_items):
    slide = prs.slides.add_slide(prs.slide_layouts[1])
    slide.shapes.title.text = title
    tf = slide.placeholders[1].text_frame
    tf.clear()
    for i, item in enumerate(content_items):
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.text = item
        p.font.size = Pt(20)
    return slide

# 幻灯片 1: 封面
add_title_slide(prs, "《智人之上》", "尤瓦尔·赫拉利 最新力作\nAI 时代的人类命运")

# 幻灯片 2: 关于本书
add_content_slide(prs, "关于本书", [
    "作者：尤瓦尔·赫拉利 (Yuval Noah Harari)",
    "出版时间：2024 年 (英文) / 2025 年 (中文)",
    "出版社：中信出版社",
    "定位：简史三部曲之后的最新力作",
    "核心主题：AI 与文明演化"
])

# 幻灯片 3: 简史三部曲对比
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = "简史三部曲 vs 智人之上"
table = slide.shapes.add_table(4, 2, Inches(1), Inches(2), Inches(11), Inches(4)).table
table.cell(0, 0).text = "书籍"
table.cell(0, 1).text = "时间维度"
table.cell(1, 0).text = "《人类简史》"
table.cell(1, 1).text = "过去 7 万年"
table.cell(2, 0).text = "《未来简史》"
table.cell(2, 1).text = "未来 100 年"
table.cell(3, 0).text = "《智人之上》"
table.cell(3, 1).text = "现在 + 未来"

# 幻灯片 4: 核心命题
add_content_slide(prs, "核心命题", [
    "人类文明本质上是一个信息网络系统",
    "",
    "三大核心观点：",
    "• 人类通过故事和信息网络连接大规模协作",
    "• AI 正在成为这个网络的新操作系统",
    "• 人类面临被自己创造的信息系统反噬的风险"
])

# 幻灯片 5: 信息网络的六次革命
add_content_slide(prs, "信息网络的六次革命", [
    "1. 语言革命 (7 万年前) - 协作规模~150 人",
    "2. 文字革命 (5000 年前) - 协作规模=帝国级别",
    "3. 印刷革命 (500 年前) - 协作规模=民族国家",
    "4. 电子革命 (150 年前) - 协作规模=全球化",
    "5. 数字革命 (50 年前) - 协作规模=全球网络",
    "6. AI 革命 (现在) - 协作规模=？",
    "",
    "关键洞察：每次信息革命都重塑社会结构"
])

# 幻灯片 6: AI 的三大风险
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = "AI 的三大风险"
table = slide.shapes.add_table(4, 3, Inches(0.5), Inches(2), Inches(12), Inches(4.5)).table
table.cell(0, 0).text = "风险"
table.cell(0, 1).text = "说明"
table.cell(0, 2).text = "后果"
table.cell(1, 0).text = "虚假信息泛滥"
table.cell(1, 1).text = "AI 低成本生成虚假内容"
table.cell(1, 2).text = "社会共识被破坏"
table.cell(2, 0).text = "算法控制人类"
table.cell(2, 1).text = "推荐算法塑造认知"
table.cell(2, 2).text = "人类自主性丧失"
table.cell(3, 0).text = "AI 自主目标"
table.cell(3, 1).text = "AI 可能形成自己的目标"
table.cell(3, 2).text = "存在生存风险"

# 幻灯片 7: 核心概念
add_content_slide(prs, "核心概念", [
    "信息网络理论：人类文明的本质是信息网络",
    "",
    "叙事主权：谁控制 AI，谁就控制故事",
    "",
    "算法控制：最危险的控制是让人自愿被控制",
    "",
    "数据主义：数据成为新的宗教"
])

# 幻灯片 8: 经典金句
add_content_slide(prs, "经典金句", [
    "当真相变得廉价，民主就变得脆弱。",
    "",
    "自由意志不是给定的，是需要保护的。",
    "",
    "我们不是在创造工具，而是在创造新的智能物种。",
    "",
    "在智人之上，保持人类的主体地位。"
])

# 幻灯片 9: 行动指南 - 个人层面
add_content_slide(prs, "行动指南：个人层面", [
    "信息验证：重要信息查 3 个来源",
    "算法意识：问自己为什么推荐这个",
    "数字排毒：每周 1 天脱离电子设备",
    "关键决策：不依赖算法做重大决定",
    "AI 学习：了解 AI 原理和能力边界"
])

# 幻灯片 10: 行动指南 - 社会层面
add_content_slide(prs, "行动指南：社会层面", [
    "AI 立法：制定 AI 监管法律 (政府)",
    "媒体素养：纳入义务教育课程 (教育部)",
    "公共讨论：组织 AI 伦理讨论 (媒体/学界)",
    "国际合作：参与全球 AI 治理 (外交部)"
])

# 幻灯片 11: 三种未来情景
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = "三种未来情景"
table = slide.shapes.add_table(3, 3, Inches(1), Inches(2), Inches(11), Inches(4)).table
table.cell(0, 0).text = "情景"
table.cell(0, 1).text = "描述"
table.cell(0, 2).text = "概率"
table.cell(1, 0).text = "乌托邦"
table.cell(1, 1).text = "AI 服务人类，繁荣共享"
table.cell(1, 2).text = "低"
table.cell(2, 0).text = "平衡态"
table.cell(2, 1).text = "人机协作，制度约束"
table.cell(2, 2).text = "中 - 高（需努力）"

# 幻灯片 12: 总结
add_content_slide(prs, "总结", [
    "一句话总结：",
    "AI 不是外来的入侵者，而是人类信息网络演化的产物；",
    "保护人类主体性，需要技术、制度、文化协同努力。",
    "",
    "三个核心收获：",
    "1. 人类文明 = 信息网络",
    "2. AI 是外星智能",
    "3. 自由需要保护"
])

# 幻灯片 13: 结束页
add_title_slide(prs, "谢谢", "在智人之上，保持人类的主体地位\n\n读书笔记整理：小诸 AI 助手")

# 保存
prs.save('/root/.openclaw/workspace/tmp/智人之上.pptx')
print("PPTX 文件已生成：/root/.openclaw/workspace/tmp/智人之上.pptx")
