{"id":"ebe89d16-eab4-4caa-a30b-d25c25f6a231","entityType":"agent","slug":"clawhub-myd2002-feishu-ingest","name":"Feishu Ingest","canonicalUrl":"https://www.xpersona.co/agent/clawhub-myd2002-feishu-ingest","canonicalPath":"/agent/clawhub-myd2002-feishu-ingest","generatedAt":"2026-10-12T17:16:11.948Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-10-12T01:04:29.041Z","emptyReason":null},"description":"Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow. Skill: Feishu Ingest Owner: myd2002 Summary: Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow. Tags: latest:1.0.3 Version history: v1.0.3 | 2026-07-09T14:34:38.782Z | user feishu-ingest 1.0.3 - No cod","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 963 downloads reported by the source. Last updated 10/12/2026.","installCommand":"clawhub skill install s175zrvz5m28epr76c6rt4dtex8474t6:feishu-ingest","sourceUrl":"https://clawhub.ai/myd2002/feishu-ingest","homepage":"https://clawhub.ai/myd2002/skills/feishu-ingest","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/myd2002/feishu-ingest","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/myd2002/skills/feishu-ingest","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":60,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segmen"},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-12T01:04:29.041Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-12T01:04:29.041Z","emptyReason":null},"stars":null,"forks":null,"downloads":963,"likes":null,"task":null,"library":null,"packageName":null,"latestVersion":"1.0.3","tractionLabel":"963 downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-12T01:04:28.961Z","emptyReason":null},"lastUpdatedAt":"2026-10-12T01:04:29.041Z","lastCrawledAt":"2026-10-12T01:04:28.961Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-13T01:04:28.961Z","lastVerifiedAt":null,"highlights":[{"version":"1.0.3","createdAt":"2026-07-09T14:34:38.782Z","changelog":"feishu-ingest 1.0.3 - No code changes in this release. - Documentation (SKILL.md) updated for improved clarity and structure. - No changes to core logic, features, or configuration. - Safe to upgrade; behavior is unchanged.","fileCount":16,"zipByteSize":38319},{"version":"1.0.2","createdAt":"2026-07-08T16:59:29.781Z","changelog":"- Clarified that Feishu content is often fragmented and requires explicit mapping into the knowledge graph before archiving. - Added guidance: OpenClaw should first determine which items deserve entity pages and which existing pages need to be updated, instead of blindly archiving low-value chat content. - Expanded required linking: when updating/creating pages, also maintain relatedPages for general Wiki entities (besides relatedConcepts, Resources, CodePages). - Introduced overview/ page type for team-level navigation, project maps, or research directions; advised not to create overview pages without clear value. - Improved documentation on content curation criteria and navigation/overview page creation.","fileCount":16,"zipByteSize":38288},{"version":"1.0.1","createdAt":"2026-07-08T11:04:08.722Z","changelog":"- Clarified that \"group files\" are only handled if they appear as message resources (file/image), not by crawling the group files directory; folders are now returned as unsupported. - Updated documentation to specify that file/folder messages are recognized distinctly, with unsupported types explicitly marked. - Enhanced skipResult/prepare apply phase documentation for error feedback and diagnosis. - Minor improvements to output result description, including how source item status statistics are handled for frontend cards. - Refined some phrasing and removed redundancy for improved clarity.","fileCount":16,"zipByteSize":36626},{"version":"1.0.0","createdAt":"2026-07-07T17:44:14.448Z","changelog":"Initial release of feishu_ingest – a skill for structured ingestion of Feishu group messages and files into a Research KB. - Polls Feishu groups for new messages, files, and cloud docs; compiles into Markdown sources with metadata. - Provides a two-phase \"prepare/apply\" workflow: gather/prepare source materials, then validate and ingest into Gitea-backed knowledge base. - Robust error handling for permissions, unsupported types, and large files; clear status reporting. - Integrates with OpenClaw for context analysis and page generation. - Modular script structure for extensibility and maintainability; unified Feishu and Gitea API clients. - Granular configuration for source scanning, grouping, filtering, and file/document handling.","fileCount":16,"zipByteSize":36380}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s175zrvz5m28epr76c6rt4dtex8474t6:feishu-ingest","setupComplexity":"medium","setupSteps":["Python environment detected. Create a strict virtual environment (`python -m venv .venv`) before installing dependencies to prevent system-level package conflicts.","Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.","Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-12T17:16:11.947Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-feishu-ingest/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"high","updatedAt":"2026-10-12T01:04:29.041Z","emptyReason":null},"readme":"Skill: Feishu Ingest\n\nOwner: myd2002\n\nSummary: Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow.\n\nTags: latest:1.0.3\n\nVersion history:\n\nv1.0.3 | 2026-07-09T14:34:38.782Z | user\n\nfeishu-ingest 1.0.3\n\n- No code changes in this release.\n- Documentation (SKILL.md) updated for improved clarity and structure.\n- No changes to core logic, features, or configuration.\n- Safe to upgrade; behavior is unchanged.\n\nv1.0.2 | 2026-07-08T16:59:29.781Z | user\n\n- Clarified that Feishu content is often fragmented and requires explicit mapping into the knowledge graph before archiving.\n- Added guidance: OpenClaw should first determine which items deserve entity pages and which existing pages need to be updated, instead of blindly archiving low-value chat content.\n- Expanded required linking: when updating/creating pages, also maintain relatedPages for general Wiki entities (besides relatedConcepts, Resources, CodePages).\n- Introduced overview/ page type for team-level navigation, project maps, or research directions; advised not to create overview pages without clear value.\n- Improved documentation on content curation criteria and navigation/overview page creation.\n\nv1.0.1 | 2026-07-08T11:04:08.722Z | user\n\n- Clarified that \"group files\" are only handled if they appear as message resources (file/image), not by crawling the group files directory; folders are now returned as unsupported.\n- Updated documentation to specify that file/folder messages are recognized distinctly, with unsupported types explicitly marked.\n- Enhanced skipResult/prepare apply phase documentation for error feedback and diagnosis.\n- Minor improvements to output result description, including how source item status statistics are handled for frontend cards.\n- Refined some phrasing and removed redundancy for improved clarity.\n\nv1.0.0 | 2026-07-07T17:44:14.448Z | auto\n\nInitial release of feishu_ingest – a skill for structured ingestion of Feishu group messages and files into a Research KB.\n\n- Polls Feishu groups for new messages, files, and cloud docs; compiles into Markdown sources with metadata.\n- Provides a two-phase \"prepare/apply\" workflow: gather/prepare source materials, then validate and ingest into Gitea-backed knowledge base.\n- Robust error handling for permissions, unsupported types, and large files; clear status reporting.\n- Integrates with OpenClaw for context analysis and page generation.\n- Modular script structure for extensibility and maintainability; unified Feishu and Gitea API clients.\n- Granular configuration for source scanning, grouping, filtering, and file/document handling.\n\nArchive index:\n\nArchive v1.0.3: 16 files, 38319 bytes\n\nFiles: _meta.json (132b), env-example.txt (193b), main.js (156b), requirements.txt (106b), scripts/catalog.py (6950b), scripts/feishu_platform.py (14615b), scripts/feishu_reader.py (40331b), scripts/gitea_api.py (4392b), scripts/kb_writer.py (22530b), scripts/run_task.py (3478b), scripts/task_io.py (1604b), scripts/text_extractors.py (6772b), scripts/utils.py (3860b), setup.sh (184b), skill-card.md (2259b), SKILL.md (10694b)\n\nFile v1.0.3:SKILL.md\n\n---\r\nname: feishu_ingest\r\ndescription: Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow.\r\n---\r\n\r\n# feishu_ingest\r\n\r\n## 职责\r\n\r\n把飞书群作为可定时扫描资料源处理。`prepare` 拉取增量群消息、下载消息资源、读取飞书云文档、把普通群消息编译成可定位的 Markdown 源文件，并输出供 OpenClaw 分析的 `inputItems[]`。`apply` 校验 OpenClaw 生成的页面、归档源文件、写入 Gitea 知识库、更新 `catalog.json` / `index.md`，并返回 `sourceItems[]` 给后端持久化。当前“群文件”来自群消息历史里的 file/image 等 message resource；不单独爬取群文件目录，飞书文件夹消息记录为 `unsupported`。\r\n\r\n不要伪造飞书内容。缺少凭据、机器人不在群、无权限读取消息/文件/文档时，返回 `need_authorization` 或明确错误。飞书文件夹和超大文件记录为 `unsupported`。\n\n飞书内容往往是碎片化线索，入库前必须先判断它在知识库图谱里的位置。写 `pages.json` 前，OpenClaw 应私下做一次知识图谱规划：哪些文件/文档/消息片段值得成为实体页，哪些已有 `overview/`、`projects/`、`concepts/`、`resources/` 或其他页面需要补充新证据和跳转。不要把低价值聊天硬写成页面，也不要把稳定概念、具体资源或团队导航更新遗漏掉。\n\r\n## 脚本结构\r\n\r\n当前 `scripts/` 只保留真实入口和依赖：\r\n\r\n- `run_task.py`：唯一命令入口，提供 `prepare` 和 `apply` 子命令。\r\n- `feishu_reader.py`：prepare 主逻辑，拉消息、处理附件/云文档/消息片段、生成分析上下文。\r\n- `kb_writer.py`：apply 主逻辑，校验 `sourceItemKeys`、归档源文件、写页面/catalog/index、生成 `sourceItems[]`。\r\n- `feishu_platform.py`：飞书开放平台客户端，负责 token、消息历史、消息资源、Doc/Wiki/Sheet/Bitable 读取。\r\n- `text_extractors.py`：本地文件文本预览，支持文本、CSV/JSON/YAML/代码、DOCX、PPTX、XLSX、PDF 可选解析、ZIP 清单。\r\n- `gitea_api.py`：Gitea 内容读写客户端，支持 dry-run。\r\n- `catalog.py`：catalog 合并、索引渲染、图关系归一。\r\n- `task_io.py`：payload/result JSON 读写。\r\n- `utils.py`：hash、slug、frontmatter 清理、关键词、路径安全等通用函数。\r\n\r\n旧探索脚本已删除；飞书读取统一走 `feishu_platform.py`，知识库写入统一走 `kb_writer.py`。\r\n\r\n## 必需配置\r\n\r\n环境变量：\r\n\r\n- `FEISHU_APP_ID`\r\n- `FEISHU_APP_SECRET`\r\n- `GITEA_URL`\r\n- `GITEA_BOT_TOKEN`\r\n- `GITEA_BOT_USERNAME` 或 `GITEA_ORG`\r\n- `TEAM_KB_REPO`\r\n\r\n可选：\r\n\r\n- `OPENCLAW_SHARED_DIR`：token 缓存、prepare 临时文件和中间上下文目录。\r\n\r\n飞书应用需要机器人能力、机器人已进群、读取群消息历史权限、读取群消息资源权限。读取云文档还需要对应 Doc/Wiki/Sheet/Bitable 权限和文档授权。\r\n\r\n## 输入配置\r\n\r\n后端资料源会传入：\r\n\r\n- `source.config.chatId` / `openChatId` / `open_chat_id`：飞书群 ID。\r\n- `scanIntervalMinutes`：后端定时扫描间隔。\r\n- `initialLookbackHours`：首次扫描回扫窗口，默认 168 小时。\r\n- `maxMessages`：每轮最多拉取消息数，默认 200。\r\n- `messageSegmentWindowMinutes`：把相邻群消息编译成一个消息源文件的时间窗口，默认 10 分钟。\r\n- `maxMessagesPerSegment`：每个消息源文件最多包含的消息数，默认 12。\r\n- `maxFileSizeMb`：单个群文件进入分析的最大体积，上限 100MB。\r\n- `includeFiles` / `includeMessages` / `includeDocuments`：是否处理群文件、普通群消息、飞书云文档。\r\n- `fetchRecentMessages=false`：只处理后端传入的 `source.items[]`，不主动拉群消息。\r\n- `urls` / `docUrls` / `wikiUrls` / `tokens` / `documents` / `links`：额外飞书文档、Wiki、表格、多维表格 URL 或 token。\r\n- `source.lastSnapshot.lastMessageCreateTime`：上一轮处理到的消息创建时间，prepare 用它做增量游标。\r\n\r\n## Prepare\r\n\r\n运行：\r\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\nprepare 输出：\r\n\r\n- `inputItems[]`：OpenClaw 需要分析的候选资料。\r\n- `sourceItems[]`：prepare 阶段已经确定为跳过、无权限、失败、暂不支持的资料项。\r\n- `instructions.analysisTemplates`：每种资料类型的分析模板。\r\n- `skipResult`：没有新候选资料时直接写给后端的成功结果；如果没有写入任何页面且 `sourceItems[]` 中存在 `need_authorization` 或 `fetch_failed`，后端会把任务标记为 `failed` 并保留 result/sourceItems 作为诊断。\r\n\r\n`inputItems[]` 类型：\r\n\r\n- `sourceKind=feishu_file`：群消息里的文件/图片等下载资源，`required=true`。后续按本地文件同样思路分析，并归档原始文件。\r\n- `sourceKind=feishu_document`：飞书云文档/Wiki/Sheet/Bitable 编译出的 Markdown 源，`required=true`。\r\n- `sourceKind=feishu_message_segment`：按时间窗口整理后的群消息片段，`required=false`。源文件包含发送时间、message_id、sender、消息原文和机器可读定位。\r\n\r\n## OpenClaw 生成 pages.json\r\n\r\n强制规则：\r\n\r\n- 文件和云文档：每个 `required=true` 的 input item 必须出现在至少一个页面的 `sourceItemKeys` 中。\r\n- 群消息：不要逐条入库。只在消息片段包含长期研究价值时写入 `notes/`。\r\n- 高价值消息包括：项目决策、需求澄清、可复用解释、实验结果、会议结论、资源链接加上下文、后续行动项。\r\n- 低价值消息包括：收到/好的/谢谢、纯排期、重复通知、无上下文链接、临时协调、表情或闲聊。\r\n- 生成页面时必须保留 `sourceItemKeys`。不要写 `source_files/`，源文件归档由 apply 完成。\r\n- 不写 `qa/` 页面。\r\n- 根据证据生成/更新 `overview/`、`concepts/`、`resources/`、`projects/` 等相关页面时，要在正文里写 Markdown 链接，并维护 `relatedConcepts` / `relatedResources` / `relatedCodePages` / `relatedPages`。`relatedPages` 用于 overview、项目、论文、综述、会议、实验、技术文档、笔记等普通 Wiki 页面之间的关联。\n\r\n## Apply\r\n\r\n运行：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --pages <pages.json>\r\n```\r\n\r\napply 会：\r\n\r\n1. 校验所有页面路径和 `sourceItemKeys`。\r\n2. 确认所有 required 文件/云文档已被页面覆盖。\r\n3. 把被使用的群文件归档到 `source_files/feishu/<sourceId>/files/`。\r\n4. 把被使用的群消息源 Markdown 归档到 `source_files/feishu/<sourceId>/messages/`。\r\n5. 把被使用的飞书云文档源 Markdown 归档到 `source_files/feishu/<sourceId>/documents/`。\r\n6. 写入页面、`catalog.json`、`index.md`。\r\n7. 返回 `sourceItems[]`，标记每个资料项为 `ingested`、`skipped`、`need_authorization`、`fetch_failed` 或 `unsupported`。\r\n\r\n## 页面路由与模板\r\n\r\n### `papers/` 论文/技术报告\r\n\r\n适用：论文 PDF、arXiv、会议论文、技术报告。覆盖：摘要、研究问题、方法、数据/实验、主要结论、局限、可复用点、相关概念与资源。\r\n\r\n### `surveys/` 综述/调研\r\n\r\n适用：行业调研、文献综述、方案对比、landscape。覆盖：范围、分类框架、对比表、趋势、空白/争议、推荐阅读、相关概念与资源。优先做结构化比较。\r\n\r\n### `projects/` 项目/需求/方案\r\n\r\n适用：需求文档、项目计划、路线图、方案评审。覆盖：背景、目标、范围、里程碑、关键决策、风险、下一步、相关页面。\r\n\r\n### `code/` 代码/仓库/接口\r\n\r\n适用：代码文件、仓库说明、API 文档、SDK、脚本。覆盖：仓库/模块、架构、入口、关键 API、运行/部署、风险与 TODO、相关概念。\r\n\r\n### `meetings/` 会议/讨论\r\n\r\n适用：会议纪要、长讨论、同步会摘要。覆盖：背景、讨论要点、决策、行动项、开放问题、相关页面。不要逐字转写。\r\n\r\n### `experiments/` 实验/评测\r\n\r\n适用：实验记录、benchmark、ablation、结果表、失败复盘。覆盖：假设、设置、指标、结果、分析、复现信息、后续实验。\r\n\r\n### `tech-notes/` 技术笔记/排障\r\n\r\n适用：部署手册、配置说明、排障过程、命令记录。覆盖：问题、环境、步骤、配置、排错、参考、相关页面。\r\n\r\n### `notes/` 群消息沉淀\r\n\r\n适用：经过价值判断的普通群消息片段。覆盖：背景、要点、结论/价值、后续动作、消息定位。消息定位至少包含时间范围和 message_id。\r\n\r\n### `concepts/` 概念页\r\n\r\n适用：从资料中抽出的稳定概念、方法、术语。覆盖：定义、使用场景、相关方法、常见误区、相关资源。概念页要链接回支撑资料页。\r\n\r\n### `resources/` 资源页\n\n适用：工具、链接、数据集、附件、图片、暂不能深度解析但值得登记的资料。覆盖：资源是什么、内容摘要、使用方法、适用场景、限制、相关页面。\n\n### `overview/` 总览/导航页\n\n适用：飞书消息或文档显著改变团队级主题导航、项目资料地图、阶段性资料包、研究方向入口或跨资料综合时。覆盖：主题边界、相关实体页、关键概念/资源、当前状态、待补证据。没有明确导航或综合价值时不要硬建 overview。\n\r\n## 输出结果\r\n\r\n成功结果必须包含：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"processedSources\": [\"source-item-key\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"archivedFiles\": [],\r\n  \"skippedSources\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\",\r\n  \"snapshot\": { \"lastMessageCreateTime\": 0 },\r\n  \"sourceItems\": []\r\n}\r\n```\r\n\r\n`sourceItems[]` 每项尽量包含：`itemKey`、`sourceKind/kind`、`status`、`title`、`sha256`、`relativePath/originalPath`、`archivedPath`、`url`、`externalId`、`messageTime`、`size`、`lastError`、`metadata`。前端飞书资料源卡片中的资料项状态统计来自后端持久化后的 `source_items` 累计数据；最新游标/消息/候选数来自本轮 snapshot。\r\n\r\n如果没有新增消息、文件或文档，prepare 可以直接写入成功的 skip result。若只有普通群消息且 OpenClaw 判断都不值得入库，apply 允许 `pages: []` 并更新快照，避免下轮重复处理。\n\nFile v1.0.3:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"feishu-ingest\",\n  \"version\": \"1.0.3\",\n  \"publishedAt\": 1783607678782\n}\n\nFile v1.0.3:skill-card.md\n\n## Description:\n\nPoll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[myd2002](https://clawhub.ai/user/myd2002)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers and research knowledge-base maintainers use this skill to ingest Feishu group messages, attachments, and cloud documents into a Research KB while preserving source-item status and provenance for backend persistence.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Task-controlled inputs can redirect credentials or repository writes.\n\nMitigation: Run only with trusted payloads, bind GITEA_BOT_TOKEN to an administrator-configured Gitea origin, and reject payload-selected repository URLs.\n\nRisk: Local files may be archived too broadly during apply.\n\nMitigation: Restrict archived source paths to the prepare workspace and review apply contexts before execution.\n\nRisk: Feishu and Gitea credentials can expose sensitive workspace or repository data.\n\nMitigation: Use least-privilege Feishu and Gitea credentials and protect Feishu token cache permissions.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/myd2002/skills/feishu-ingest)\n- [Feishu Open Platform API](https://open.feishu.cn/open-apis)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown guidance and JSON task envelopes for prepare/apply workflows]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Produces inputItems and sourceItems status records; apply can create or update Research KB Markdown pages, catalog entries, indexes, and archived source files.]\n\n## Skill Version(s):\n\n1.0.3 (source: server release evidence)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nFile v1.0.3:env-example.txt\n\nGITEA_URL=http://127.0.0.1:3000\nGITEA_BOT_TOKEN=\nGITEA_BOT_USERNAME=research-kb-bot\nGITEA_ORG=\nTEAM_KB_REPO=team-kb\nOPENCLAW_SHARED_DIR=/srv/research-kb/shared\nFEISHU_APP_ID=\nFEISHU_APP_SECRET=\n\nFile v1.0.3:requirements.txt\n\n# No mandatory third-party dependencies.\n# Optional: install pypdf or PyPDF2 to improve PDF text previews.\n\nArchive v1.0.2: 16 files, 38288 bytes\n\nFiles: _meta.json (132b), env-example.txt (193b), main.js (156b), requirements.txt (106b), scripts/catalog.py (6950b), scripts/feishu_platform.py (14615b), scripts/feishu_reader.py (40331b), scripts/gitea_api.py (4392b), scripts/kb_writer.py (22530b), scripts/run_task.py (3478b), scripts/task_io.py (1604b), scripts/text_extractors.py (6772b), scripts/utils.py (3860b), setup.sh (184b), skill-card.md (2244b), SKILL.md (10694b)\n\nFile v1.0.2:SKILL.md\n\n---\r\nname: feishu_ingest\r\ndescription: Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow.\r\n---\r\n\r\n# feishu_ingest\r\n\r\n## 职责\r\n\r\n把飞书群作为可定时扫描资料源处理。`prepare` 拉取增量群消息、下载消息资源、读取飞书云文档、把普通群消息编译成可定位的 Markdown 源文件，并输出供 OpenClaw 分析的 `inputItems[]`。`apply` 校验 OpenClaw 生成的页面、归档源文件、写入 Gitea 知识库、更新 `catalog.json` / `index.md`，并返回 `sourceItems[]` 给后端持久化。当前“群文件”来自群消息历史里的 file/image 等 message resource；不单独爬取群文件目录，飞书文件夹消息记录为 `unsupported`。\r\n\r\n不要伪造飞书内容。缺少凭据、机器人不在群、无权限读取消息/文件/文档时，返回 `need_authorization` 或明确错误。飞书文件夹和超大文件记录为 `unsupported`。\n\n飞书内容往往是碎片化线索，入库前必须先判断它在知识库图谱里的位置。写 `pages.json` 前，OpenClaw 应私下做一次知识图谱规划：哪些文件/文档/消息片段值得成为实体页，哪些已有 `overview/`、`projects/`、`concepts/`、`resources/` 或其他页面需要补充新证据和跳转。不要把低价值聊天硬写成页面，也不要把稳定概念、具体资源或团队导航更新遗漏掉。\n\r\n## 脚本结构\r\n\r\n当前 `scripts/` 只保留真实入口和依赖：\r\n\r\n- `run_task.py`：唯一命令入口，提供 `prepare` 和 `apply` 子命令。\r\n- `feishu_reader.py`：prepare 主逻辑，拉消息、处理附件/云文档/消息片段、生成分析上下文。\r\n- `kb_writer.py`：apply 主逻辑，校验 `sourceItemKeys`、归档源文件、写页面/catalog/index、生成 `sourceItems[]`。\r\n- `feishu_platform.py`：飞书开放平台客户端，负责 token、消息历史、消息资源、Doc/Wiki/Sheet/Bitable 读取。\r\n- `text_extractors.py`：本地文件文本预览，支持文本、CSV/JSON/YAML/代码、DOCX、PPTX、XLSX、PDF 可选解析、ZIP 清单。\r\n- `gitea_api.py`：Gitea 内容读写客户端，支持 dry-run。\r\n- `catalog.py`：catalog 合并、索引渲染、图关系归一。\r\n- `task_io.py`：payload/result JSON 读写。\r\n- `utils.py`：hash、slug、frontmatter 清理、关键词、路径安全等通用函数。\r\n\r\n旧探索脚本已删除；飞书读取统一走 `feishu_platform.py`，知识库写入统一走 `kb_writer.py`。\r\n\r\n## 必需配置\r\n\r\n环境变量：\r\n\r\n- `FEISHU_APP_ID`\r\n- `FEISHU_APP_SECRET`\r\n- `GITEA_URL`\r\n- `GITEA_BOT_TOKEN`\r\n- `GITEA_BOT_USERNAME` 或 `GITEA_ORG`\r\n- `TEAM_KB_REPO`\r\n\r\n可选：\r\n\r\n- `OPENCLAW_SHARED_DIR`：token 缓存、prepare 临时文件和中间上下文目录。\r\n\r\n飞书应用需要机器人能力、机器人已进群、读取群消息历史权限、读取群消息资源权限。读取云文档还需要对应 Doc/Wiki/Sheet/Bitable 权限和文档授权。\r\n\r\n## 输入配置\r\n\r\n后端资料源会传入：\r\n\r\n- `source.config.chatId` / `openChatId` / `open_chat_id`：飞书群 ID。\r\n- `scanIntervalMinutes`：后端定时扫描间隔。\r\n- `initialLookbackHours`：首次扫描回扫窗口，默认 168 小时。\r\n- `maxMessages`：每轮最多拉取消息数，默认 200。\r\n- `messageSegmentWindowMinutes`：把相邻群消息编译成一个消息源文件的时间窗口，默认 10 分钟。\r\n- `maxMessagesPerSegment`：每个消息源文件最多包含的消息数，默认 12。\r\n- `maxFileSizeMb`：单个群文件进入分析的最大体积，上限 100MB。\r\n- `includeFiles` / `includeMessages` / `includeDocuments`：是否处理群文件、普通群消息、飞书云文档。\r\n- `fetchRecentMessages=false`：只处理后端传入的 `source.items[]`，不主动拉群消息。\r\n- `urls` / `docUrls` / `wikiUrls` / `tokens` / `documents` / `links`：额外飞书文档、Wiki、表格、多维表格 URL 或 token。\r\n- `source.lastSnapshot.lastMessageCreateTime`：上一轮处理到的消息创建时间，prepare 用它做增量游标。\r\n\r\n## Prepare\r\n\r\n运行：\r\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\nprepare 输出：\r\n\r\n- `inputItems[]`：OpenClaw 需要分析的候选资料。\r\n- `sourceItems[]`：prepare 阶段已经确定为跳过、无权限、失败、暂不支持的资料项。\r\n- `instructions.analysisTemplates`：每种资料类型的分析模板。\r\n- `skipResult`：没有新候选资料时直接写给后端的成功结果；如果没有写入任何页面且 `sourceItems[]` 中存在 `need_authorization` 或 `fetch_failed`，后端会把任务标记为 `failed` 并保留 result/sourceItems 作为诊断。\r\n\r\n`inputItems[]` 类型：\r\n\r\n- `sourceKind=feishu_file`：群消息里的文件/图片等下载资源，`required=true`。后续按本地文件同样思路分析，并归档原始文件。\r\n- `sourceKind=feishu_document`：飞书云文档/Wiki/Sheet/Bitable 编译出的 Markdown 源，`required=true`。\r\n- `sourceKind=feishu_message_segment`：按时间窗口整理后的群消息片段，`required=false`。源文件包含发送时间、message_id、sender、消息原文和机器可读定位。\r\n\r\n## OpenClaw 生成 pages.json\r\n\r\n强制规则：\r\n\r\n- 文件和云文档：每个 `required=true` 的 input item 必须出现在至少一个页面的 `sourceItemKeys` 中。\r\n- 群消息：不要逐条入库。只在消息片段包含长期研究价值时写入 `notes/`。\r\n- 高价值消息包括：项目决策、需求澄清、可复用解释、实验结果、会议结论、资源链接加上下文、后续行动项。\r\n- 低价值消息包括：收到/好的/谢谢、纯排期、重复通知、无上下文链接、临时协调、表情或闲聊。\r\n- 生成页面时必须保留 `sourceItemKeys`。不要写 `source_files/`，源文件归档由 apply 完成。\r\n- 不写 `qa/` 页面。\r\n- 根据证据生成/更新 `overview/`、`concepts/`、`resources/`、`projects/` 等相关页面时，要在正文里写 Markdown 链接，并维护 `relatedConcepts` / `relatedResources` / `relatedCodePages` / `relatedPages`。`relatedPages` 用于 overview、项目、论文、综述、会议、实验、技术文档、笔记等普通 Wiki 页面之间的关联。\n\r\n## Apply\r\n\r\n运行：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --pages <pages.json>\r\n```\r\n\r\napply 会：\r\n\r\n1. 校验所有页面路径和 `sourceItemKeys`。\r\n2. 确认所有 required 文件/云文档已被页面覆盖。\r\n3. 把被使用的群文件归档到 `source_files/feishu/<sourceId>/files/`。\r\n4. 把被使用的群消息源 Markdown 归档到 `source_files/feishu/<sourceId>/messages/`。\r\n5. 把被使用的飞书云文档源 Markdown 归档到 `source_files/feishu/<sourceId>/documents/`。\r\n6. 写入页面、`catalog.json`、`index.md`。\r\n7. 返回 `sourceItems[]`，标记每个资料项为 `ingested`、`skipped`、`need_authorization`、`fetch_failed` 或 `unsupported`。\r\n\r\n## 页面路由与模板\r\n\r\n### `papers/` 论文/技术报告\r\n\r\n适用：论文 PDF、arXiv、会议论文、技术报告。覆盖：摘要、研究问题、方法、数据/实验、主要结论、局限、可复用点、相关概念与资源。\r\n\r\n### `surveys/` 综述/调研\r\n\r\n适用：行业调研、文献综述、方案对比、landscape。覆盖：范围、分类框架、对比表、趋势、空白/争议、推荐阅读、相关概念与资源。优先做结构化比较。\r\n\r\n### `projects/` 项目/需求/方案\r\n\r\n适用：需求文档、项目计划、路线图、方案评审。覆盖：背景、目标、范围、里程碑、关键决策、风险、下一步、相关页面。\r\n\r\n### `code/` 代码/仓库/接口\r\n\r\n适用：代码文件、仓库说明、API 文档、SDK、脚本。覆盖：仓库/模块、架构、入口、关键 API、运行/部署、风险与 TODO、相关概念。\r\n\r\n### `meetings/` 会议/讨论\r\n\r\n适用：会议纪要、长讨论、同步会摘要。覆盖：背景、讨论要点、决策、行动项、开放问题、相关页面。不要逐字转写。\r\n\r\n### `experiments/` 实验/评测\r\n\r\n适用：实验记录、benchmark、ablation、结果表、失败复盘。覆盖：假设、设置、指标、结果、分析、复现信息、后续实验。\r\n\r\n### `tech-notes/` 技术笔记/排障\r\n\r\n适用：部署手册、配置说明、排障过程、命令记录。覆盖：问题、环境、步骤、配置、排错、参考、相关页面。\r\n\r\n### `notes/` 群消息沉淀\r\n\r\n适用：经过价值判断的普通群消息片段。覆盖：背景、要点、结论/价值、后续动作、消息定位。消息定位至少包含时间范围和 message_id。\r\n\r\n### `concepts/` 概念页\r\n\r\n适用：从资料中抽出的稳定概念、方法、术语。覆盖：定义、使用场景、相关方法、常见误区、相关资源。概念页要链接回支撑资料页。\r\n\r\n### `resources/` 资源页\n\n适用：工具、链接、数据集、附件、图片、暂不能深度解析但值得登记的资料。覆盖：资源是什么、内容摘要、使用方法、适用场景、限制、相关页面。\n\n### `overview/` 总览/导航页\n\n适用：飞书消息或文档显著改变团队级主题导航、项目资料地图、阶段性资料包、研究方向入口或跨资料综合时。覆盖：主题边界、相关实体页、关键概念/资源、当前状态、待补证据。没有明确导航或综合价值时不要硬建 overview。\n\r\n## 输出结果\r\n\r\n成功结果必须包含：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"processedSources\": [\"source-item-key\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"archivedFiles\": [],\r\n  \"skippedSources\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\",\r\n  \"snapshot\": { \"lastMessageCreateTime\": 0 },\r\n  \"sourceItems\": []\r\n}\r\n```\r\n\r\n`sourceItems[]` 每项尽量包含：`itemKey`、`sourceKind/kind`、`status`、`title`、`sha256`、`relativePath/originalPath`、`archivedPath`、`url`、`externalId`、`messageTime`、`size`、`lastError`、`metadata`。前端飞书资料源卡片中的资料项状态统计来自后端持久化后的 `source_items` 累计数据；最新游标/消息/候选数来自本轮 snapshot。\r\n\r\n如果没有新增消息、文件或文档，prepare 可以直接写入成功的 skip result。若只有普通群消息且 OpenClaw 判断都不值得入库，apply 允许 `pages: []` 并更新快照，避免下轮重复处理。\n\nFile v1.0.2:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"feishu-ingest\",\n  \"version\": \"1.0.2\",\n  \"publishedAt\": 1783529969781\n}\n\nFile v1.0.2:skill-card.md\n\n## Description: <br>\nPoll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[myd2002](https://clawhub.ai/user/myd2002) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers and knowledge-base operators use this skill to ingest Feishu group messages, message attachments, and Feishu cloud documents into a curated Research KB. It helps decide which chat segments or documents merit durable pages, then writes Markdown pages, catalog metadata, archive links, and source item status records. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The apply step can upload local files named in task metadata without confining them to the Feishu staging directory. <br>\nMitigation: Install only when the Feishu source, generated context, pages.json, and Gitea token are controlled by a trusted backend; use a least-privilege Gitea bot token scoped to the KB repo; isolate OPENCLAW_SHARED_DIR; add path confinement before broader deployment. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/feishu-ingest) <br>\n- [Feishu Open Platform APIs](https://open.feishu.cn/open-apis) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [JSON, Markdown, Shell commands, Configuration] <br>\n**Output Format:** [JSON prepare/apply envelopes plus Markdown KB pages and catalog/index updates] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Uses a prepare/apply workflow; requires Feishu app credentials and a least-privilege Gitea bot token for the target KB repository.] <br>\n\n## Skill Version(s): <br>\n1.0.2 (source: server release evidence) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v1.0.2:env-example.txt\n\nGITEA_URL=http://127.0.0.1:3000\nGITEA_BOT_TOKEN=\nGITEA_BOT_USERNAME=research-kb-bot\nGITEA_ORG=\nTEAM_KB_REPO=team-kb\nOPENCLAW_SHARED_DIR=/srv/research-kb/shared\nFEISHU_APP_ID=\nFEISHU_APP_SECRET=\n\nFile v1.0.2:requirements.txt\n\n# No mandatory third-party dependencies.\n# Optional: install pypdf or PyPDF2 to improve PDF text previews.\n\nArchive v1.0.1: 16 files, 36626 bytes\n\nFiles: _meta.json (132b), env-example.txt (193b), main.js (156b), requirements.txt (106b), scripts/catalog.py (5288b), scripts/feishu_platform.py (14615b), scripts/feishu_reader.py (39263b), scripts/gitea_api.py (4392b), scripts/kb_writer.py (19818b), scripts/run_task.py (3478b), scripts/task_io.py (1604b), scripts/text_extractors.py (6772b), scripts/utils.py (3860b), setup.sh (184b), skill-card.md (2666b), SKILL.md (9731b)\n\nFile v1.0.1:SKILL.md\n\n---\r\nname: feishu_ingest\r\ndescription: Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow.\r\n---\r\n\r\n# feishu_ingest\r\n\r\n## 职责\r\n\r\n把飞书群作为可定时扫描资料源处理。`prepare` 拉取增量群消息、下载消息资源、读取飞书云文档、把普通群消息编译成可定位的 Markdown 源文件，并输出供 OpenClaw 分析的 `inputItems[]`。`apply` 校验 OpenClaw 生成的页面、归档源文件、写入 Gitea 知识库、更新 `catalog.json` / `index.md`，并返回 `sourceItems[]` 给后端持久化。当前“群文件”来自群消息历史里的 file/image 等 message resource；不单独爬取群文件目录，飞书文件夹消息记录为 `unsupported`。\r\n\r\n不要伪造飞书内容。缺少凭据、机器人不在群、无权限读取消息/文件/文档时，返回 `need_authorization` 或明确错误。飞书文件夹和超大文件记录为 `unsupported`。\r\n\r\n## 脚本结构\r\n\r\n当前 `scripts/` 只保留真实入口和依赖：\r\n\r\n- `run_task.py`：唯一命令入口，提供 `prepare` 和 `apply` 子命令。\r\n- `feishu_reader.py`：prepare 主逻辑，拉消息、处理附件/云文档/消息片段、生成分析上下文。\r\n- `kb_writer.py`：apply 主逻辑，校验 `sourceItemKeys`、归档源文件、写页面/catalog/index、生成 `sourceItems[]`。\r\n- `feishu_platform.py`：飞书开放平台客户端，负责 token、消息历史、消息资源、Doc/Wiki/Sheet/Bitable 读取。\r\n- `text_extractors.py`：本地文件文本预览，支持文本、CSV/JSON/YAML/代码、DOCX、PPTX、XLSX、PDF 可选解析、ZIP 清单。\r\n- `gitea_api.py`：Gitea 内容读写客户端，支持 dry-run。\r\n- `catalog.py`：catalog 合并、索引渲染、图关系归一。\r\n- `task_io.py`：payload/result JSON 读写。\r\n- `utils.py`：hash、slug、frontmatter 清理、关键词、路径安全等通用函数。\r\n\r\n旧探索脚本已删除；飞书读取统一走 `feishu_platform.py`，知识库写入统一走 `kb_writer.py`。\r\n\r\n## 必需配置\r\n\r\n环境变量：\r\n\r\n- `FEISHU_APP_ID`\r\n- `FEISHU_APP_SECRET`\r\n- `GITEA_URL`\r\n- `GITEA_BOT_TOKEN`\r\n- `GITEA_BOT_USERNAME` 或 `GITEA_ORG`\r\n- `TEAM_KB_REPO`\r\n\r\n可选：\r\n\r\n- `OPENCLAW_SHARED_DIR`：token 缓存、prepare 临时文件和中间上下文目录。\r\n\r\n飞书应用需要机器人能力、机器人已进群、读取群消息历史权限、读取群消息资源权限。读取云文档还需要对应 Doc/Wiki/Sheet/Bitable 权限和文档授权。\r\n\r\n## 输入配置\r\n\r\n后端资料源会传入：\r\n\r\n- `source.config.chatId` / `openChatId` / `open_chat_id`：飞书群 ID。\r\n- `scanIntervalMinutes`：后端定时扫描间隔。\r\n- `initialLookbackHours`：首次扫描回扫窗口，默认 168 小时。\r\n- `maxMessages`：每轮最多拉取消息数，默认 200。\r\n- `messageSegmentWindowMinutes`：把相邻群消息编译成一个消息源文件的时间窗口，默认 10 分钟。\r\n- `maxMessagesPerSegment`：每个消息源文件最多包含的消息数，默认 12。\r\n- `maxFileSizeMb`：单个群文件进入分析的最大体积，上限 100MB。\r\n- `includeFiles` / `includeMessages` / `includeDocuments`：是否处理群文件、普通群消息、飞书云文档。\r\n- `fetchRecentMessages=false`：只处理后端传入的 `source.items[]`，不主动拉群消息。\r\n- `urls` / `docUrls` / `wikiUrls` / `tokens` / `documents` / `links`：额外飞书文档、Wiki、表格、多维表格 URL 或 token。\r\n- `source.lastSnapshot.lastMessageCreateTime`：上一轮处理到的消息创建时间，prepare 用它做增量游标。\r\n\r\n## Prepare\r\n\r\n运行：\r\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\nprepare 输出：\r\n\r\n- `inputItems[]`：OpenClaw 需要分析的候选资料。\r\n- `sourceItems[]`：prepare 阶段已经确定为跳过、无权限、失败、暂不支持的资料项。\r\n- `instructions.analysisTemplates`：每种资料类型的分析模板。\r\n- `skipResult`：没有新候选资料时直接写给后端的成功结果；如果没有写入任何页面且 `sourceItems[]` 中存在 `need_authorization` 或 `fetch_failed`，后端会把任务标记为 `failed` 并保留 result/sourceItems 作为诊断。\r\n\r\n`inputItems[]` 类型：\r\n\r\n- `sourceKind=feishu_file`：群消息里的文件/图片等下载资源，`required=true`。后续按本地文件同样思路分析，并归档原始文件。\r\n- `sourceKind=feishu_document`：飞书云文档/Wiki/Sheet/Bitable 编译出的 Markdown 源，`required=true`。\r\n- `sourceKind=feishu_message_segment`：按时间窗口整理后的群消息片段，`required=false`。源文件包含发送时间、message_id、sender、消息原文和机器可读定位。\r\n\r\n## OpenClaw 生成 pages.json\r\n\r\n强制规则：\r\n\r\n- 文件和云文档：每个 `required=true` 的 input item 必须出现在至少一个页面的 `sourceItemKeys` 中。\r\n- 群消息：不要逐条入库。只在消息片段包含长期研究价值时写入 `notes/`。\r\n- 高价值消息包括：项目决策、需求澄清、可复用解释、实验结果、会议结论、资源链接加上下文、后续行动项。\r\n- 低价值消息包括：收到/好的/谢谢、纯排期、重复通知、无上下文链接、临时协调、表情或闲聊。\r\n- 生成页面时必须保留 `sourceItemKeys`。不要写 `source_files/`，源文件归档由 apply 完成。\r\n- 不写 `qa/` 页面。\r\n- 根据证据生成/更新 `concepts/`、`resources/`、`projects/` 等相关页面时，要在正文里写 Markdown 链接，并维护 `relatedConcepts` / `relatedResources` / `relatedCodePages`。\r\n\r\n## Apply\r\n\r\n运行：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --pages <pages.json>\r\n```\r\n\r\napply 会：\r\n\r\n1. 校验所有页面路径和 `sourceItemKeys`。\r\n2. 确认所有 required 文件/云文档已被页面覆盖。\r\n3. 把被使用的群文件归档到 `source_files/feishu/<sourceId>/files/`。\r\n4. 把被使用的群消息源 Markdown 归档到 `source_files/feishu/<sourceId>/messages/`。\r\n5. 把被使用的飞书云文档源 Markdown 归档到 `source_files/feishu/<sourceId>/documents/`。\r\n6. 写入页面、`catalog.json`、`index.md`。\r\n7. 返回 `sourceItems[]`，标记每个资料项为 `ingested`、`skipped`、`need_authorization`、`fetch_failed` 或 `unsupported`。\r\n\r\n## 页面路由与模板\r\n\r\n### `papers/` 论文/技术报告\r\n\r\n适用：论文 PDF、arXiv、会议论文、技术报告。覆盖：摘要、研究问题、方法、数据/实验、主要结论、局限、可复用点、相关概念与资源。\r\n\r\n### `surveys/` 综述/调研\r\n\r\n适用：行业调研、文献综述、方案对比、landscape。覆盖：范围、分类框架、对比表、趋势、空白/争议、推荐阅读、相关概念与资源。优先做结构化比较。\r\n\r\n### `projects/` 项目/需求/方案\r\n\r\n适用：需求文档、项目计划、路线图、方案评审。覆盖：背景、目标、范围、里程碑、关键决策、风险、下一步、相关页面。\r\n\r\n### `code/` 代码/仓库/接口\r\n\r\n适用：代码文件、仓库说明、API 文档、SDK、脚本。覆盖：仓库/模块、架构、入口、关键 API、运行/部署、风险与 TODO、相关概念。\r\n\r\n### `meetings/` 会议/讨论\r\n\r\n适用：会议纪要、长讨论、同步会摘要。覆盖：背景、讨论要点、决策、行动项、开放问题、相关页面。不要逐字转写。\r\n\r\n### `experiments/` 实验/评测\r\n\r\n适用：实验记录、benchmark、ablation、结果表、失败复盘。覆盖：假设、设置、指标、结果、分析、复现信息、后续实验。\r\n\r\n### `tech-notes/` 技术笔记/排障\r\n\r\n适用：部署手册、配置说明、排障过程、命令记录。覆盖：问题、环境、步骤、配置、排错、参考、相关页面。\r\n\r\n### `notes/` 群消息沉淀\r\n\r\n适用：经过价值判断的普通群消息片段。覆盖：背景、要点、结论/价值、后续动作、消息定位。消息定位至少包含时间范围和 message_id。\r\n\r\n### `concepts/` 概念页\r\n\r\n适用：从资料中抽出的稳定概念、方法、术语。覆盖：定义、使用场景、相关方法、常见误区、相关资源。概念页要链接回支撑资料页。\r\n\r\n### `resources/` 资源页\r\n\r\n适用：工具、链接、数据集、附件、图片、暂不能深度解析但值得登记的资料。覆盖：资源是什么、内容摘要、使用方法、适用场景、限制、相关页面。\r\n\r\n## 输出结果\r\n\r\n成功结果必须包含：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"processedSources\": [\"source-item-key\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"archivedFiles\": [],\r\n  \"skippedSources\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\",\r\n  \"snapshot\": { \"lastMessageCreateTime\": 0 },\r\n  \"sourceItems\": []\r\n}\r\n```\r\n\r\n`sourceItems[]` 每项尽量包含：`itemKey`、`sourceKind/kind`、`status`、`title`、`sha256`、`relativePath/originalPath`、`archivedPath`、`url`、`externalId`、`messageTime`、`size`、`lastError`、`metadata`。前端飞书资料源卡片中的资料项状态统计来自后端持久化后的 `source_items` 累计数据；最新游标/消息/候选数来自本轮 snapshot。\r\n\r\n如果没有新增消息、文件或文档，prepare 可以直接写入成功的 skip result。若只有普通群消息且 OpenClaw 判断都不值得入库，apply 允许 `pages: []` 并更新快照，避免下轮重复处理。\n\nFile v1.0.1:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"feishu-ingest\",\n  \"version\": \"1.0.1\",\n  \"publishedAt\": 1783508648722\n}\n\nFile v1.0.1:skill-card.md\n\n## Description: <br>\nPoll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[myd2002](https://clawhub.ai/user/myd2002) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers and knowledge-management teams use this skill to ingest Feishu chat messages, message resources, and Feishu cloud documents into a Research KB backed by Gitea. It prepares candidate source items for analysis, then applies accepted pages and source-item status records back to the knowledge base. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill stores a sensitive Feishu access token on disk. <br>\nMitigation: Run it with a private, access-controlled OPENCLAW_SHARED_DIR and restrict filesystem permissions for the token cache. <br>\nRisk: The skill can archive local file paths as part of ingestion. <br>\nMitigation: Limit who can influence source items, context files, and pages.json, and review repository visibility before applying changes to sensitive materials. <br>\nRisk: Feishu app permissions and Gitea write access determine what the skill can read and publish. <br>\nMitigation: Use least-privilege Feishu app scopes and Gitea credentials, and deploy only where group, document, and repository access are tightly controlled. <br>\n\n\n## Reference(s): <br>\n- [ClawHub Feishu Ingest Skill Page](https://clawhub.ai/myd2002/skills/feishu-ingest) <br>\n- [Feishu Open Platform API](https://open.feishu.cn/open-apis) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [JSON, Markdown, Files, API Calls, Shell commands, Configuration instructions] <br>\n**Output Format:** [JSON envelopes with Markdown knowledge-base pages, archived source files, and source-item status records] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Prepare emits inputItems, sourceItems, analysis templates, and skip results; apply emits processed sources, created or updated pages, archived files, errors, commit id, snapshot, and sourceItems.] <br>\n\n## Skill Version(s): <br>\n1.0.1 (source: server release metadata) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v1.0.1:env-example.txt\n\nGITEA_URL=http://127.0.0.1:3000\nGITEA_BOT_TOKEN=\nGITEA_BOT_USERNAME=research-kb-bot\nGITEA_ORG=\nTEAM_KB_REPO=team-kb\nOPENCLAW_SHARED_DIR=/srv/research-kb/shared\nFEISHU_APP_ID=\nFEISHU_APP_SECRET=\n\nFile v1.0.1:requirements.txt\n\n# No mandatory third-party dependencies.\n# Optional: install pypdf or PyPDF2 to improve PDF text previews.\n\nArchive v1.0.0: 16 files, 36380 bytes\n\nFiles: _meta.json (132b), env-example.txt (193b), main.js (156b), requirements.txt (106b), scripts/catalog.py (5288b), scripts/feishu_platform.py (14615b), scripts/feishu_reader.py (39263b), scripts/gitea_api.py (4392b), scripts/kb_writer.py (19818b), scripts/run_task.py (3478b), scripts/task_io.py (1604b), scripts/text_extractors.py (6772b), scripts/utils.py (3860b), setup.sh (184b), skill-card.md (2671b), SKILL.md (9060b)\n\nFile v1.0.0:SKILL.md\n\n---\nname: feishu_ingest\ndescription: Poll Feishu groups for new messages and message resources, download group files, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow.\n---\n\n# feishu_ingest\n\n## 职责\n\n把飞书群作为可定时扫描资料源处理。`prepare` 拉取增量群消息、下载消息资源、读取飞书云文档、把普通群消息编译成可定位的 Markdown 源文件，并输出供 OpenClaw 分析的 `inputItems[]`。`apply` 校验 OpenClaw 生成的页面、归档源文件、写入 Gitea 知识库、更新 `catalog.json` / `index.md`，并返回 `sourceItems[]` 给后端持久化。\n\n不要伪造飞书内容。缺少凭据、机器人不在群、无权限读取消息/文件/文档时，返回 `need_authorization` 或明确错误。飞书文件夹和超大文件记录为 `unsupported`。\n\n## 脚本结构\n\n当前 `scripts/` 只保留真实入口和依赖：\n\n- `run_task.py`：唯一命令入口，提供 `prepare` 和 `apply` 子命令。\n- `feishu_reader.py`：prepare 主逻辑，拉消息、处理附件/云文档/消息片段、生成分析上下文。\n- `kb_writer.py`：apply 主逻辑，校验 `sourceItemKeys`、归档源文件、写页面/catalog/index、生成 `sourceItems[]`。\n- `feishu_platform.py`：飞书开放平台客户端，负责 token、消息历史、消息资源、Doc/Wiki/Sheet/Bitable 读取。\n- `text_extractors.py`：本地文件文本预览，支持文本、CSV/JSON/YAML/代码、DOCX、PPTX、XLSX、PDF 可选解析、ZIP 清单。\n- `gitea_api.py`：Gitea 内容读写客户端，支持 dry-run。\n- `catalog.py`：catalog 合并、索引渲染、图关系归一。\n- `task_io.py`：payload/result JSON 读写。\n- `utils.py`：hash、slug、frontmatter 清理、关键词、路径安全等通用函数。\n\n旧探索脚本已删除；飞书读取统一走 `feishu_platform.py`，知识库写入统一走 `kb_writer.py`。\n\n## 必需配置\n\n环境变量：\n\n- `FEISHU_APP_ID`\n- `FEISHU_APP_SECRET`\n- `GITEA_URL`\n- `GITEA_BOT_TOKEN`\n- `GITEA_BOT_USERNAME` 或 `GITEA_ORG`\n- `TEAM_KB_REPO`\n\n可选：\n\n- `OPENCLAW_SHARED_DIR`：token 缓存、prepare 临时文件和中间上下文目录。\n\n飞书应用需要机器人能力、机器人已进群、读取群消息历史权限、读取群消息资源权限。读取云文档还需要对应 Doc/Wiki/Sheet/Bitable 权限和文档授权。\n\n## 输入配置\n\n后端资料源会传入：\n\n- `source.config.chatId` / `openChatId` / `open_chat_id`：飞书群 ID。\n- `scanIntervalMinutes`：后端定时扫描间隔。\n- `initialLookbackHours`：首次扫描回扫窗口，默认 168 小时。\n- `maxMessages`：每轮最多拉取消息数，默认 200。\n- `messageSegmentWindowMinutes`：把相邻群消息编译成一个消息源文件的时间窗口，默认 10 分钟。\n- `maxMessagesPerSegment`：每个消息源文件最多包含的消息数，默认 12。\n- `maxFileSizeMb`：单个群文件进入分析的最大体积，上限 100MB。\n- `includeFiles` / `includeMessages` / `includeDocuments`：是否处理群文件、普通群消息、飞书云文档。\n- `fetchRecentMessages=false`：只处理后端传入的 `source.items[]`，不主动拉群消息。\n- `urls` / `docUrls` / `wikiUrls` / `tokens` / `documents` / `links`：额外飞书文档、Wiki、表格、多维表格 URL 或 token。\n- `source.lastSnapshot.lastMessageCreateTime`：上一轮处理到的消息创建时间，prepare 用它做增量游标。\n\n## Prepare\n\n运行：\n\n```bash\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\n```\n\nprepare 输出：\n\n- `inputItems[]`：OpenClaw 需要分析的候选资料。\n- `sourceItems[]`：prepare 阶段已经确定为跳过、无权限、失败、暂不支持的资料项。\n- `instructions.analysisTemplates`：每种资料类型的分析模板。\n- `skipResult`：没有新候选资料时直接写给后端的成功结果。\n\n`inputItems[]` 类型：\n\n- `sourceKind=feishu_file`：群消息里的文件/图片等下载资源，`required=true`。后续按本地文件同样思路分析，并归档原始文件。\n- `sourceKind=feishu_document`：飞书云文档/Wiki/Sheet/Bitable 编译出的 Markdown 源，`required=true`。\n- `sourceKind=feishu_message_segment`：按时间窗口整理后的群消息片段，`required=false`。源文件包含发送时间、message_id、sender、消息原文和机器可读定位。\n\n## OpenClaw 生成 pages.json\n\n强制规则：\n\n- 文件和云文档：每个 `required=true` 的 input item 必须出现在至少一个页面的 `sourceItemKeys` 中。\n- 群消息：不要逐条入库。只在消息片段包含长期研究价值时写入 `notes/`。\n- 高价值消息包括：项目决策、需求澄清、可复用解释、实验结果、会议结论、资源链接加上下文、后续行动项。\n- 低价值消息包括：收到/好的/谢谢、纯排期、重复通知、无上下文链接、临时协调、表情或闲聊。\n- 生成页面时必须保留 `sourceItemKeys`。不要写 `source_files/`，源文件归档由 apply 完成。\n- 不写 `qa/` 页面。\n- 根据证据生成/更新 `concepts/`、`resources/`、`projects/` 等相关页面时，要在正文里写 Markdown 链接，并维护 `relatedConcepts` / `relatedResources` / `relatedCodePages`。\n\n## Apply\n\n运行：\n\n```bash\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --pages <pages.json>\n```\n\napply 会：\n\n1. 校验所有页面路径和 `sourceItemKeys`。\n2. 确认所有 required 文件/云文档已被页面覆盖。\n3. 把被使用的群文件归档到 `source_files/feishu/<sourceId>/files/`。\n4. 把被使用的群消息源 Markdown 归档到 `source_files/feishu/<sourceId>/messages/`。\n5. 把被使用的飞书云文档源 Markdown 归档到 `source_files/feishu/<sourceId>/documents/`。\n6. 写入页面、`catalog.json`、`index.md`。\n7. 返回 `sourceItems[]`，标记每个资料项为 `ingested`、`skipped`、`need_authorization`、`fetch_failed` 或 `unsupported`。\n\n## 页面路由与模板\n\n### `papers/` 论文/技术报告\n\n适用：论文 PDF、arXiv、会议论文、技术报告。覆盖：摘要、研究问题、方法、数据/实验、主要结论、局限、可复用点、相关概念与资源。\n\n### `surveys/` 综述/调研\n\n适用：行业调研、文献综述、方案对比、landscape。覆盖：范围、分类框架、对比表、趋势、空白/争议、推荐阅读、相关概念与资源。优先做结构化比较。\n\n### `projects/` 项目/需求/方案\n\n适用：需求文档、项目计划、路线图、方案评审。覆盖：背景、目标、范围、里程碑、关键决策、风险、下一步、相关页面。\n\n### `code/` 代码/仓库/接口\n\n适用：代码文件、仓库说明、API 文档、SDK、脚本。覆盖：仓库/模块、架构、入口、关键 API、运行/部署、风险与 TODO、相关概念。\n\n### `meetings/` 会议/讨论\n\n适用：会议纪要、长讨论、同步会摘要。覆盖：背景、讨论要点、决策、行动项、开放问题、相关页面。不要逐字转写。\n\n### `experiments/` 实验/评测\n\n适用：实验记录、benchmark、ablation、结果表、失败复盘。覆盖：假设、设置、指标、结果、分析、复现信息、后续实验。\n\n### `tech-notes/` 技术笔记/排障\n\n适用：部署手册、配置说明、排障过程、命令记录。覆盖：问题、环境、步骤、配置、排错、参考、相关页面。\n\n### `notes/` 群消息沉淀\n\n适用：经过价值判断的普通群消息片段。覆盖：背景、要点、结论/价值、后续动作、消息定位。消息定位至少包含时间范围和 message_id。\n\n### `concepts/` 概念页\n\n适用：从资料中抽出的稳定概念、方法、术语。覆盖：定义、使用场景、相关方法、常见误区、相关资源。概念页要链接回支撑资料页。\n\n### `resources/` 资源页\n\n适用：工具、链接、数据集、附件、图片、暂不能深度解析但值得登记的资料。覆盖：资源是什么、内容摘要、使用方法、适用场景、限制、相关页面。\n\n## 输出结果\n\n成功结果必须包含：\n\n```json\n{\n  \"success\": true,\n  \"processedSources\": [\"source-item-key\"],\n  \"createdPages\": [],\n  \"updatedPages\": [],\n  \"archivedFiles\": [],\n  \"skippedSources\": [],\n  \"errors\": [],\n  \"commitId\": \"\",\n  \"snapshot\": { \"lastMessageCreateTime\": 0 },\n  \"sourceItems\": []\n}\n```\n\n`sourceItems[]` 每项尽量包含：`itemKey`、`sourceKind/kind`、`status`、`title`、`sha256`、`relativePath/originalPath`、`archivedPath`、`url`、`externalId`、`messageTime`、`size`、`lastError`、`metadata`。\n\n如果没有新增消息、文件或文档，prepare 可以直接写入成功的 skip result。若只有普通群消息且 OpenClaw 判断都不值得入库，apply 允许 `pages: []` 并更新快照，避免下轮重复处理。\n\nFile v1.0.0:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"feishu-ingest\",\n  \"version\": \"1.0.0\",\n  \"publishedAt\": 1783446254448\n}\n\nFile v1.0.0:skill-card.md\n\n## Description: <br>\nPoll Feishu groups for new messages and message resources, download group files, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[myd2002](https://clawhub.ai/user/myd2002) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers and knowledge-base operators use this skill to ingest Feishu group messages, files, and cloud documents into a Gitea-backed Research KB. It supports a prepare/apply workflow that gathers source material, lets an agent select durable knowledge, and records ingestion status. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill can copy sensitive Feishu messages, attachments, and linked documents into a Gitea Research KB. <br>\nMitigation: Install only for intended Feishu-to-KB ingestion, use least-privileged Feishu and Gitea credentials, and restrict allowed groups, documents, and repositories. <br>\nRisk: Prepared materials and generated pages may persist sensitive or incorrect content. <br>\nMitigation: Keep OPENCLAW_SHARED_DIR private and review generated pages before running apply. <br>\nRisk: Apply should not be run with untrusted payload or context metadata while storagePath validation is still a concern. <br>\nMitigation: Run apply only on trusted backend payloads and context files until storagePath validation is tightened. <br>\n\n\n## Reference(s): <br>\n- [ClawHub Skill Listing](https://clawhub.ai/myd2002/skills/feishu-ingest) <br>\n- [Publisher Profile](https://clawhub.ai/user/myd2002) <br>\n- [Feishu Open Platform APIs](https://open.feishu.cn/open-apis) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, code, shell commands, configuration, guidance] <br>\n**Output Format:** [JSON envelopes plus Markdown source and knowledge-base page content] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Prepare returns candidate inputItems and sourceItems status records; apply validates sourceItemKeys, archives selected Feishu materials, writes KB pages, and returns ingestion status.] <br>\n\n## Skill Version(s): <br>\n1.0.0 (source: ClawHub release evidence) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v1.0.0:env-example.txt\n\nGITEA_URL=http://127.0.0.1:3000\nGITEA_BOT_TOKEN=\nGITEA_BOT_USERNAME=research-kb-bot\nGITEA_ORG=\nTEAM_KB_REPO=team-kb\nOPENCLAW_SHARED_DIR=/srv/research-kb/shared\nFEISHU_APP_ID=\nFEISHU_APP_SECRET=\n\nFile v1.0.0:requirements.txt\n\n# No mandatory third-party dependencies.\n# Optional: install pypdf or PyPDF2 to improve PDF text previews.","readmeExcerpt":"Skill: Feishu Ingest Owner: myd2002 Summary: Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow. Tags: latest:1.0.3 Version history: v1.0.3 | 2026-07-09T14:34:38.782Z | user feishu-ingest 1.0.3 - No cod","codeSnippets":[],"executableExamples":[{"language":"bash","snippet":"python3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>"},{"language":"bash","snippet":"python3 scripts/run_task.py apply --input <payload.json> --context <context.json> --pages <pages.json>"},{"language":"json","snippet":"{\n  \"success\": true,\n  \"processedSources\": [\"source-item-key\"],\n  \"createdPages\": [],\n  \"updatedPages\": [],\n  \"archivedFiles\": [],\n  \"skippedSources\": [],\n  \"errors\": [],\n  \"commitId\": \"\",\n  \"snapshot\": { \"lastMessageCreateTime\": 0 },\n  \"sourceItems\": []\n}"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\r\nname: feishu_ingest\r\ndescription: Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow.\r\n---\r\n\r\n# feishu_ingest\r\n\r\n## 职责\r\n\r\n把飞书群作为可定时扫描资料源处理。`prepare` 拉取增量群消息、下载消息资源、读取飞书云文档、把普通群消息编译成可定位的 Markdown 源文件，并输出供 OpenClaw 分析的 `inputItems[]`。`apply` 校验 OpenClaw 生成的页面、归档源文件、写入 Gitea 知识库、更新 `catalog.json` / `index.md`，并返回 `sourceItems[]` 给后端持久化。当前“群文件”来自群消息历史里的 file/image 等 message resource；不单独爬取群文件目录，飞书文件夹消息记录为 `unsupported`。\r\n\r\n不要伪造飞书内容。缺少凭据、机器人不在群、无权限读取消息/文件/文档时，返回 `need_authorization` 或明确错误。飞书文件夹和超大文件记录为 `unsupported`。\n\n飞书内容往往是碎片化线索，入库前必须先判断它在知识库图谱里的位置。写 `pages.json` 前，OpenClaw 应私下做一次知识图谱规划：哪些文件/文档/消息片段值得成为实体页，哪些已有 `overview/`、`projects/`、`concepts/`、`resources/` 或其他页面需要补充新证据和跳转。不要把低价值聊天硬写成页面，也不要把稳定概念、具体资源或团队导航更新遗漏掉。\n\r\n## 脚本结构\r\n\r\n当前 `scripts/` 只保留真实入口和依赖：\r\n\r\n- `run_task.py`：唯一命令入口，提供 `prepare` 和 `apply` 子命令。\r\n- `feishu_reader.py`：prepare 主逻辑，拉消息、处理附件/云文档/消息片段、生成分析上下文。\r\n- `kb_writer.py`：apply 主逻辑，校验 `sourceItemKeys`、归档源文件、写页面/catalog/index、生成 `sourceItems[]`。\r\n- `feishu_platform.py`：飞书开放平台客户端，负责 token、消息历史、消息资源、Doc/Wiki/Sheet/Bitable 读取。\r\n- `text_extractors.py`：本地文件文本预览，支持文本、CSV/JSON/YAML/代码、DOCX、PPTX、XLSX、PDF 可选解析、ZIP 清单。\r\n- `gitea_api.py`：Gitea 内容读写客户端，支持 dry-run。\r\n- `catalog.py`：catalog 合并、索引渲染、图关系归一。\r\n- `task_io.py`：payload/result JSON 读写。\r\n- `utils.py`：hash、slug、frontmatter 清理、关键词、路径安全等通用函数。\r\n\r\n旧探索脚本已删除；飞书读取统一走 `feishu_platform.py`，知识库写入统一走 `kb_writer.py`。\r\n\r\n## 必需配置\r\n\r\n环境变量：\r\n\r\n- `FEISHU_APP_ID`\r\n- `FEISHU_APP_SECRET`\r\n- `GITEA_URL`\r\n- `GITEA_BOT_TOKEN`\r\n- `GITEA_BOT_USERNAME` 或 `GITEA_ORG`\r\n- `TEAM_KB_REPO`\r\n\r\n可选：\r\n\r\n- `OPENCLAW_SHARED_DIR`：token 缓存、prepare 临时文件和中间上下文目录。\r\n\r\n飞书应用需要机器人能力、机器人已进群、读取群消息历史权限、读取群消息资源权限。读取云文档还需要对应 Doc/Wiki/Sheet/Bitable 权限和文档授权。\r\n\r\n## 输入配置\r\n\r\n后端资料源会传入：\r\n\r\n- `source.config.chatId` / `openChatId` / `open_chat_id`：飞书群 ID。\r\n- `scanIntervalMinutes`：后端定时扫描间隔。\r\n- `initialLookbackHours`：首次扫描回扫窗口，默认 168 小时。\r\n- `maxMessages`：每轮最多拉取消息数，默认 200。\r\n- `messageSegmentWindowMinutes`：把相邻群消息编译成一个消息源文件的时间窗口，默认 10 分钟。\r\n- `maxMessagesPerSegment`：每个消息源文件最多包含的消息数，默认 12。\r\n- `maxFileSizeMb`：单个群文件进入分析的最大体积，上限 100MB。\r\n- `includeFiles` / `includeMessages` / `includeDocuments`：是否处理群文件、普通群消息、飞书云文档。\r\n- `fetchRecentMessages=false`：只处理后端传入的 `source.items[]`，不主动拉群消息。\r\n- `urls` / `docUrls` / `wikiUrls` / `tokens` / `documents` / `links`：额外飞书文档、Wiki、表格、多维表格 URL 或 token。\r\n- `source.lastSnapshot.lastMessageCreateTime`：上一轮处理到的消息创建时间，prepare 用它做增量游标。\r\n\r\n## Prepare\r\n\r\n运行：\r\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\nprepare 输出：\r\n\r\n- `inputItems[]`：OpenClaw 需要分析的候选资料。\r\n- `sourceItems[]`：prepare 阶段已经确定为跳过、无权限、失败、暂不支持的资料项。\r\n- `instructions.analysisTemplates`：每种资料类型的分析模板。\r\n- `skipResult`：没有新候选资料时直接写给后端的成功结果；如果没有写入任何页面且 `sourceItems[]` 中存在 `need_authorization` 或 `fetch_failed`，后端会把任务标记为"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"feishu-ingest\",\n  \"version\": \"1.0.3\",\n  \"publishedAt\": 1783607678782\n}"},{"path":"skill-card.md","content":"## Description:\n\nPoll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[myd2002](https://clawhub.ai/user/myd2002)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers and research knowledge-base maintainers use this skill to ingest Feishu group messages, attachments, and cloud documents into a Research KB while preserving source-item status and provenance for backend persistence.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Task-controlled inputs can redirect credentials or repository writes.\n\nMitigation: Run only with trusted payloads, bind GITEA_BOT_TOKEN to an administrator-configured Gitea origin, and reject payload-selected repository URLs.\n\nRisk: Local files may be archived too broadly during apply.\n\nMitigation: Restrict archived source paths to the prepare workspace and review apply contexts before execution.\n\nRisk: Feishu and Gitea credentials can expose sensitive workspace or repository data.\n\nMitigation: Use least-privilege Feishu and Gitea credentials and protect Feishu token cache permissions.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/myd2002/skills/feishu-ingest)\n- [Feishu Open Platform API](https://open.feishu.cn/open-apis)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown guidance and JSON task envelopes for prepare/apply workflows]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Produces inputItems and sourceItems status records; apply can create or update Research KB Markdown pages, catalog entries, indexes, and archived source files.]\n\n## Skill Version(s):\n\n1.0.3 (source: server release evidence)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment."},{"path":"env-example.txt","content":"GITEA_URL=http://127.0.0.1:3000\nGITEA_BOT_TOKEN=\nGITEA_BOT_USERNAME=research-kb-bot\nGITEA_ORG=\nTEAM_KB_REPO=team-kb\nOPENCLAW_SHARED_DIR=/srv/research-kb/shared\nFEISHU_APP_ID=\nFEISHU_APP_SECRET="},{"path":"requirements.txt","content":"# No mandatory third-party dependencies.\n# Optional: install pypdf or PyPDF2 to improve PDF text previews."}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow. Skill: Feishu Ingest Owner: myd2002 Summary: Poll Feishu groups for new messages, download message resources, read Feishu docs/wiki/sheets/bitables, compile message-source markdown, judge which chat segments are worth preserving, and ingest valuable materials into the Research KB through a prepare/apply workflow. Tags: latest:1.0.3 Version history: v1.0.3 | 2026-07-09T14:34:38.782Z | user feishu-ingest 1.0.3 - No cod","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":1279,"uniquenessScore":52,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-12T01:04:29.041Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-12T01:04:29.041Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-12T17:16:11.948Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}