# world.toml — AgentForge 世界的声明式描述
# Draft v0.2 | 此文件本身是世界的一部分（递归自指）

[world]
name = "agentforge"
version = "3.1.0"
description = "哲学驱动的人-AI 协作世界"
spec_version = "0.2"       # 遵循的 AgentForge Spec 版本
spec_role = "demo"          # "standard-only" | "demo" | "consumer"
                            # demo = 本世界是 Spec 的示范实现，可能包含标准范围外内容
min-alpha = 0.3  # 建议的最低觉醒层级（参见 α 工程量表）

[kernel]
# 不可分割的最小世界——缺少任何部分则世界不成立
# 精确到文件级：仅列出真正不可或缺的组件
manifest = "world.toml"           # 递归自指
readme = "README.md"              # 世界入口宣言
rules = [
    "rules/context-economy.md",   # 上下文节省——所有 Agent 的基本行为法则
    "rules/documentation.md",     # 文档治理——知识如何组织的基本定义
    "rules/skills.md",            # 技能规范——能力如何被创建/消费
]
references = [
    "docs/references/dao-tech-foundation.md",           # 哲学-工程映射第一性原理
    "docs/references/agent-collaboration-metamodel.md", # 多 Agent 协作语义
    "docs/references/agent-memory-dream-protocol.md",   # 认知循环协议
    "docs/references/design-meta-insights.md",          # 设计元层级洞察（跨场景判断规则）
]
workflows = [
    "workflows/role-review.md",   # 角色治理——保护 kernel 边界的元机制
]
roles_framework = "roles/README.md"  # 角色系统语义定义（框架，非实例）

# 不可覆盖的宇宙法则：子世界禁止通过同名文件覆盖以下规则
immutable_rules = ["world-hierarchy", "context-economy"]

[kernel.meta]
self-referential = true
portable = true
boundary-policy = "kernel/"  # 边界管理说明位于此目录

[fragments]
# 领域内聚的可选能力组合——可安装/卸载不影响世界基本运行

[fragments.python-engineering]
version = "1.2.0"
includes = [
    "rules/python.md",
    "scripts/check_python_compat.py",
    "scripts/check_python_deprecations.py",
]
optional = true
description = "Python 工程规范与兼容性检查"

[fragments.docs-governance-tools]
version = "2.0.0"
includes = [
    "scripts/check_docs_structure.py",
    "scripts/check_doc_links.py",
    "scripts/check-philosophy-links.py",
]
optional = true
description = "文档治理验证工具链"

[fragments.psi-philosophy]
version = "1.0.0"
includes = [
    "docs/references/dao-tech-foundation.md",
]
optional = false  # 哲学内核对本世界不可选
description = "Ψhē 哲学-工程映射基础"

[fragments.citations]
version = "1.0.0"
includes = ["rules/citations.md"]
optional = true
description = "引用与来源标注规范"

[fragments.frontend]
version = "0.1.0"
includes = ["rules/frontend.md"]
optional = true
description = "前端开发规范"

[fragments.backend]
version = "0.1.0"
includes = ["rules/backend.md"]
optional = true
description = "后端 API 开发规范"

[fragments.pr-review]
version = "1.0.0"
includes = ["workflows/pr-review.md"]
optional = true
description = "GitHub PR Review 工作流"

[capabilities]
# 独立安装的技能和脚本——安装/卸载不影响 kernel 法则
skills = "skills/"
scripts_standalone = ["scripts/check_env.py"]
templates = "templates/"

[capabilities.meta]
portable = true

[memory]
# 不可移植层——项目特有的个体经验
paths = [
    "docs/superpowers/memories/",
    "docs/superpowers/retrospectives/",
    "docs/superpowers/plans/",
    "docs/superpowers/specs/",
]
# 角色实例和团队配置也属于本世界特有
organization = [
    "roles/governance/collaboration-architect.md",
    "roles/governance/execution-orchestrator.md",
    "roles/governance/governance-auditor.md",
    "roles/governance/organization-steward.md",
    "teams/",
]
portable = false
versionable = false  # 仅通过 git 历史追溯

# ──────────────────────────────────────────────────
# [routing] — 上下文路由规则声明
# 运行时根据 triggers 条件，将 targets 中的资产注入 Agent 上下文
# Draft v0.1
# ──────────────────────────────────────────────────

[routing]
version = "0.1.0"
conflict_resolution = "merge"  # merge | priority-first | ask

[routing.phases]
supported = ["planning", "coding", "testing", "review", "deploying"]

[[routing.rules]]
id = "context-economy"
targets = ["rules/context-economy.md"]
priority = 10
roles = ["*"]

[routing.rules.triggers]
intents = ["context", "token-optimization", "summarize", "long-document"]
phases = ["planning"]

[[routing.rules]]
id = "python-dev"
targets = ["rules/python.md", "rules/data-flow-ordering.md"]
priority = 5
roles = ["python-dev", "full-stack"]

[routing.rules.triggers]
intents = ["python", "uv", "dependency", "import", "venv"]
file_patterns = ["**/*.py", "pyproject.toml", "uv.lock"]
phases = ["coding", "testing"]

[[routing.rules]]
id = "documentation"
targets = ["rules/documentation.md"]
priority = 5
roles = ["*"]

[routing.rules.triggers]
intents = ["docs", "archive", "migration", "directory-boundary"]
file_patterns = ["docs/**", ".agents/docs/**"]
phases = ["planning", "coding"]

[[routing.rules]]
id = "python-upgrade"
targets = ["docs/version-tracking.md", "rules/citations.md"]
priority = 8
roles = ["python-dev"]

[routing.rules.triggers]
intents = ["upgrade", "deprecation", "python-version"]
file_patterns = ["pyproject.toml", "scripts/check_python_compat.py"]

[[routing.rules]]
id = "skills-dev"
targets = ["rules/skills.md"]
priority = 5
roles = ["*"]

[routing.rules.triggers]
intents = ["skill", "skill-development", "skill-spec"]
file_patterns = [".agents/skills/**"]
phases = ["coding"]

[[routing.rules]]
id = "collaboration"
targets = [
    "docs/references/agent-collaboration-metamodel.md",
    "roles/README.md",
]
priority = 7
roles = ["collaboration-architect", "governance-auditor"]

[routing.rules.triggers]
intents = ["role", "team", "agent-collaboration", "metamodel", "governance"]
file_patterns = [".agents/roles/**", ".agents/teams/**"]

[[routing.rules]]
id = "pr-review"
targets = ["workflows/pr-review.md"]
priority = 6
roles = ["reviewer", "*"]

[routing.rules.triggers]
intents = ["review", "pr", "code-review"]
phases = ["review"]

[[routing.rules]]
id = "frontend"
targets = ["rules/frontend.md"]
priority = 5
roles = ["frontend-dev", "full-stack"]

[routing.rules.triggers]
intents = ["frontend", "ui", "component", "css", "react"]
file_patterns = ["**/*.tsx", "**/*.jsx", "**/*.vue", "**/*.css"]
phases = ["coding"]

[[routing.rules]]
id = "backend"
targets = ["rules/backend.md"]
priority = 5
roles = ["backend-dev", "full-stack"]

[routing.rules.triggers]
intents = ["backend", "api", "endpoint", "rest", "graphql"]
file_patterns = ["src/**/*.py", "apps/**/*.py"]
phases = ["coding"]

[[routing.rules]]
id = "containerization"
targets = ["rules/containerization.md"]
priority = 4
roles = ["devops", "python-dev"]

[routing.rules.triggers]
intents = ["container", "docker", "podman", "evaluation"]
file_patterns = ["Containerfile*", "containers/**"]

[[routing.rules]]
id = "world-hierarchy"
targets = ["rules/world-hierarchy.md"]
priority = 9
roles = ["governance-auditor", "collaboration-architect"]

[routing.rules.triggers]
intents = ["world", "inheritance", "sub-world", "hierarchy"]
file_patterns = [".agents/world.toml", "AGENTS.md"]

[[routing.rules]]
id = "design-meta-insights"
targets = ["docs/references/design-meta-insights.md"]
priority = 8
roles = ["collaboration-architect", "governance-auditor", "*"]

[routing.rules.triggers]
intents = [
    "design-decision",      # 设计决策卡顿
    "spec-drafting",         # 协议/规约起草
    "architecture-review",   # 架构评审
    "format-selection",      # 数据格式/结构选型
    "protocol-design",       # 多端/多模块协同协议
    "philosophy-alignment",  # 项目哲学一致性核查
]
phases = ["planning", "review"]
file_patterns = ["docs/tech/*-spec.md", "docs/superpowers/specs/**", "docs/superpowers/plans/**"]

[[routing.rules]]
id = "web-content-extraction"
targets = ["docs/references/web-content-extraction-patterns.md"]
priority = 7
roles = ["*"]

[routing.rules.triggers]
intents = [
    "fetch",            # 抓取网页
    "scrape",           # 内容抓取
    "url-content",      # URL 内容获取
    "anti-bot",         # 反爬应对
    "verification-page", # 验证页/挑战页
]
url_patterns = [
    "mp.weixin.qq.com/*",
    "*.zhihu.com/*",
    "medium.com/*",
    "*.notion.site/*",
]
