{
  "$comment": "mdFlow v1 标准空模板。所有以 $comment 命名的字段仅供填写说明，消费者必须忽略。复制后填写个人实例；不要把 Token、密码、私钥或实际 Cookie 写入任何 Manifest。",
  "schema": "mdFlow-manifest-v1",
  "kind": "template",
  "name": "mdFlow",
  "channel": "v1",
  "version": "1.0.0",
  "status": "draft",
  "updated_at": "2026-08-03T08:55:11.933Z",
  "documentation_url": "https://my-work-flow.pages.dev/mdFlow/",
  "consumers": [
    {
      "name": "WebMark",
      "role": "raw_capture"
    },
    {
      "name": "CleanMark",
      "role": "deep_cleaning"
    },
    {
      "name": "PublishMark",
      "role": "clean_site_instance"
    },
    {
      "name": "WorkBuddy",
      "role": "agent_orchestrator"
    }
  ],
  "loading_policy": {
    "read_remote_on": [
      "first_install",
      "local_cache_missing_or_corrupt",
      "explicit_upgrade"
    ],
    "check_remote_during_daily_runs": false,
    "atomic_update": true,
    "keep_previous_valid_version": true,
    "ignore_keys_starting_with": "$"
  },
  "data_model": {
    "layers": {
      "raw": {
        "mutable_by": [
          "WebMark"
        ],
        "read_only_for": [
          "CleanMark"
        ],
        "purpose": "original_evidence"
      },
      "clean": {
        "mutable_by": [
          "CleanMark"
        ],
        "published_by": [
          "PublishMark"
        ],
        "purpose": "curated_content"
      }
    },
    "front_matter": {
      "$comment": "所有消费者必须保留未知字段，以便向后兼容。Raw 与 Clean 使用独立文件，CleanMark 不得原地修改 Raw。",
      "raw": {
        "required": [
          "id",
          "title",
          "url",
          "saved",
          "collection",
          "cleanup"
        ],
        "fields": {
          "id": {
            "type": "string",
            "description": "稳定内容标识；默认长度由 runtime.webmark.storage.id_length 决定。"
          },
          "title": {
            "type": "string",
            "description": "页面或内容标题。"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "原始来源 URL。"
          },
          "author": {
            "type": [
              "string",
              "null"
            ],
            "description": "原作者；无法确认时为 null。"
          },
          "published": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-or-date-time",
            "description": "原始发布时间。"
          },
          "saved": {
            "type": "string",
            "format": "date-time",
            "description": "采集保存时间。"
          },
          "collection": {
            "type": "string",
            "description": "taxonomy.collections 中定义的一级分类 code。"
          },
          "categories": {
            "type": "array",
            "items": "string",
            "default": [],
            "description": "可多选的辅助分类。"
          },
          "topics": {
            "type": "array",
            "items": "string",
            "default": [],
            "description": "主题词。"
          },
          "tags": {
            "type": "array",
            "items": "string",
            "default": [],
            "description": "自由标签。"
          },
          "summary": {
            "type": [
              "string",
              "null"
            ],
            "description": "可选的简短摘要。"
          },
          "cleanup": {
            "type": "integer",
            "const": 0,
            "description": "Raw 内容固定为 0，表示尚未经过 CleanMark 深度整理。"
          }
        }
      },
      "clean": {
        "required": [
          "id",
          "title",
          "slug",
          "collection",
          "sources",
          "cleanup",
          "status",
          "updated"
        ],
        "fields": {
          "id": {
            "type": "string",
            "description": "Clean 内容的永久稳定标识。"
          },
          "title": {
            "type": "string",
            "description": "整理后的正式标题。"
          },
          "slug": {
            "type": "string",
            "description": "稳定、URL 安全的英文路径标识。"
          },
          "collection": {
            "type": "string",
            "description": "校正后的一级分类 code。"
          },
          "categories": {
            "type": "array",
            "items": "string",
            "default": []
          },
          "topics": {
            "type": "array",
            "items": "string",
            "default": []
          },
          "tags": {
            "type": "array",
            "items": "string",
            "default": []
          },
          "summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "sources": {
            "type": "array",
            "min_items": 1,
            "description": "一个或多个 Raw 来源；通过永久 ID 和原始 URL 关联，不使用跨项目相对路径。",
            "item_fields": [
              "id",
              "url"
            ]
          },
          "cleanup": {
            "type": "integer",
            "const": 1,
            "description": "完成 CleanMark 深度整理后固定为 1。"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "review",
              "published",
              "archived"
            ],
            "default": "draft"
          },
          "updated": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "taxonomy": {
    "$comment": "collection 是唯一一级分类；categories/topics/tags 为辅助维度。code 同时作为目录名和乐享路由键。",
    "collections": [
      {
        "code": "collect",
        "name": "待整理",
        "description": "无法可靠归类或尚待人工整理的内容；也是默认回退分类。"
      },
      {
        "code": "environment",
        "name": "环境与工程",
        "description": "环境工程、工艺技术、工程案例与行业资料。"
      },
      {
        "code": "ai-tools",
        "name": "AI 与工具",
        "description": "人工智能产品、Agent、模型及效率工具。"
      },
      {
        "code": "software-development",
        "name": "软件开发",
        "description": "编程、系统设计、部署与软件工程。"
      },
      {
        "code": "literature",
        "name": "文学与阅读",
        "description": "文学作品、阅读资料与人文内容。"
      },
      {
        "code": "reference",
        "name": "资料与参考",
        "description": "通用参考资料、说明文档与暂不归入其他领域的正式资料。"
      }
    ],
    "fallback_collection": "collect"
  },
  "runtime": {
    "workbuddy": {
      "$comment": "填写桌面 Agent 和入口能力。当前优先支持 Tencent WorkBuddy；其他 Agent 可按相同接口适配。",
      "enabled": null,
      "agent": "Tencent WorkBuddy",
      "entry_channels": {
        "app": null,
        "wechat": null,
        "qq": null,
        "feishu": null
      }
    },
    "webmark": {
      "$comment": "WebMark 只负责采集阶段的必要清洗、初步分类和 Raw 落地，不做深度改写。",
      "enabled": null,
      "trigger": {
        "auto_on_bare_url": true,
        "auto_on_save_intent": true,
        "save_intents": [
          "保存",
          "收藏",
          "存一下",
          "记录",
          "归档"
        ],
        "multiple_urls": "separate"
      },
      "fetch": {
        "primary_tool": "WebFetch",
        "fallback_skills": [
          "web-scraper"
        ],
        "allow_script_fallback": true,
        "script_path": "scripts/fetch_page.py",
        "domain_rules": [
          {
            "host": "mp.weixin.qq.com",
            "primary_tool": "WebFetch"
          }
        ],
        "prompt": "Extract the full article content of this page. Return: title, author (if available), publication date (if available), and the complete main body text. Ignore navigation, ads, sidebars, comments, and recommended articles. If the page has no article body, return a brief description of the site/tool, its main features, and intended use case."
      },
      "classification": {
        "article_min_paragraphs": 3,
        "article_min_characters": 500,
        "fallback_collection": "collect"
      },
      "storage": {
        "$comment": "raw_root 为必填的个人本地路径；模板中必须保持 null。",
        "raw_root": null,
        "file_naming_pattern": "{saved_date}-{title}-{id}.md",
        "filename_max_title_length": 50,
        "filename_safe_replacement": "_",
        "id_length": 10,
        "encoding": "utf-8"
      },
      "error_handling": {
        "local_write_retries": 1,
        "continue_on_integration_failure": true,
        "expose_error_detail": false
      }
    },
    "cleanmark": {
      "$comment": "CleanMark 只读 Raw，生成独立 Clean；删除、正文合并和覆盖人工内容不得自动执行。",
      "enabled": null,
      "input": {
        "layer": "raw",
        "read_only": true
      },
      "output": {
        "layer": "clean",
        "content_root": null
      },
      "operations": {
        "safe": "auto_execute",
        "reversible": "execute_and_log",
        "high_risk": "suggest_only"
      },
      "source_linking": {
        "by": [
          "id",
          "url"
        ],
        "allow_multiple_raw_sources": true
      },
      "git": {
        "auto_commit": false,
        "auto_push": false
      }
    },
    "publishmark": {
      "$comment": "PublishMark 是具体 FolderMark Clean 站点实例；FolderMark 本身不读取 mdFlow。",
      "enabled": null,
      "repository": null,
      "branch": "main",
      "content_root": "content",
      "provider": "cloudflare_pages",
      "site_url": null,
      "git_credential_ref": null
    }
  },
  "integrations": {
    "lexiang": {
      "$comment": "个人实例应填写团队、空间和分类路由。space_id/root_entry_id 不是密钥，但会暴露个人知识库拓扑；实际凭据只能使用 credential_ref 引用。",
      "enabled": null,
      "connection_status": "not_configured",
      "mcp_server": "lexiang",
      "import_tool": "knowledge_import_content",
      "team_name": null,
      "team_id": null,
      "credential_ref": null,
      "public_page_base_url": "https://lexiangla.com/pages",
      "fallback_space_key": "collect",
      "on_unconfigured_route": "fallback",
      "spaces": {
        "collect": {
          "enabled": null,
          "space_name": null,
          "space_id": null,
          "root_entry_id": null
        },
        "environment": {
          "enabled": null,
          "space_name": null,
          "space_id": null,
          "root_entry_id": null
        },
        "ai-tools": {
          "enabled": null,
          "space_name": null,
          "space_id": null,
          "root_entry_id": null
        },
        "software-development": {
          "enabled": null,
          "space_name": null,
          "space_id": null,
          "root_entry_id": null
        },
        "literature": {
          "enabled": null,
          "space_name": null,
          "space_id": null,
          "root_entry_id": null
        },
        "reference": {
          "enabled": null,
          "space_name": null,
          "space_id": null,
          "root_entry_id": null
        }
      },
      "route_by_collection": {
        "collect": "collect",
        "environment": "environment",
        "ai-tools": "ai-tools",
        "software-development": "software-development",
        "literature": "literature",
        "reference": "reference"
      }
    },
    "raw_site": {
      "$comment": "Raw 内容从本地单向同步到服务器，不进入 PublishMark Git 仓库。",
      "enabled": null,
      "site_base_url": null,
      "sync": {
        "enabled": null,
        "adapter": "scp",
        "profile": null,
        "target_root": "markdown",
        "verify": true,
        "credential_ref": null
      }
    }
  },
  "response": {
    "$comment": "默认回执只返回可点击地址，不暴露本地路径和错误细节。",
    "success_fields": [
      "lexiang_url",
      "raw_site_url"
    ],
    "include_summary": false,
    "include_local_path": false,
    "batch_format": "table",
    "labels": {
      "lexiang_url": "乐享",
      "raw_site_url": "Raw",
      "local_path": "本地"
    }
  },
  "security": {
    "allow_non_secret_personal_settings": true,
    "allowed_examples": [
      "local_paths",
      "site_urls",
      "team_and_space_ids",
      "credential_references"
    ],
    "forbidden_values": [
      "api_tokens",
      "passwords",
      "private_keys",
      "session_cookies",
      "actual_credentials"
    ]
  }
}
