{"id":"52c7ee42-9df7-4a5a-b928-99a9a64378a7","entityType":"agent","slug":"clawhub-myd2002-kb-query","name":"Kb Query","canonicalUrl":"https://www.xpersona.co/agent/clawhub-myd2002-kb-query","canonicalPath":"/agent/clawhub-myd2002-kb-query","generatedAt":"2026-10-11T07:39:54.930Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-10-11T04:10:06.085Z","emptyReason":null},"description":"Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. Skill: Kb Query Owner: myd2002 Summary: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. Tags: latest:1.0.8 Version history: v1.0.8 | 2026-07-09T14:33:17.833Z | user No functional changes. Documentation improved for implementation details and usage","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 1.2K downloads reported by the source. Last updated 10/11/2026.","installCommand":"clawhub skill install s175zrvz5m28epr76c6rt4dtex8474t6:kb-query","sourceUrl":"https://clawhub.ai/myd2002/kb-query","homepage":"https://clawhub.ai/myd2002/skills/kb-query","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/myd2002/kb-query","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/myd2002/skills/kb-query","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":61,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led e"},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-11T04:10:06.085Z","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-11T04:10:06.085Z","emptyReason":null},"stars":null,"forks":null,"downloads":1164,"packageName":null,"latestVersion":"1.0.8","tractionLabel":"1.2K downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T04:10:05.931Z","emptyReason":null},"lastUpdatedAt":"2026-10-11T04:10:06.085Z","lastCrawledAt":"2026-10-11T04:10:05.931Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-12T04:10:05.931Z","lastVerifiedAt":null,"highlights":[{"version":"1.0.8","createdAt":"2026-07-09T14:33:17.833Z","changelog":"No functional changes. Documentation improved for implementation details and usage clarity. - Clarified that answer.json should usually be written using python3's json.dump/json.dumps; discourages manual construction for complex answers. - Added note that Markdown, tables, and double quotes in answers are acceptable—focus is on using robust JSON output. - No code or behavioral changes in this version.","fileCount":15,"zipByteSize":28494},{"version":"1.0.7","createdAt":"2026-07-08T19:54:19.415Z","changelog":"Version 1.0.7 (no file changes detected) - No code or documentation changes in this version. - Skill behavior, process, and documentation remain identical to the previous release.","fileCount":15,"zipByteSize":26171},{"version":"1.0.6","createdAt":"2026-07-08T19:38:52.332Z","changelog":"- Page selection process changed: now, if no suitable KB pages exist or the KB cannot answer, a valid empty selection is written to proceed, and insufficient evidence is reported at the answer stage rather than stopping early. - Clarified that if evidence is insufficient, the flow reaches fetch/apply with an empty selection instead of halting in selection. - Minor clarifications about not exceeding selection scope and prompt updates to rule explanations. - No code changes; documentation update only.","fileCount":15,"zipByteSize":26105},{"version":"1.0.5","createdAt":"2026-07-08T19:03:07.966Z","changelog":"Version 1.0.5 - Enforces stricter context and evidence file handling: JSON is only fully written to file (not terminal), and OpenClaw must read from file, not paste content into chat. - Adds context budget enforcement: OpenClaw should typically select only 1–4 key KB pages (never above maxSelectedPages), aiming for a minimal sufficient set. - Requires all intermediate JSON files to be strictly valid; do not include Markdown fences, comments, trailing commas, or partial content. - Each execution step (prepare/fetch) now only outputs a summary to the terminal; full details are saved to disk for OpenClaw's use. - Clarifies and reinforces evidence selection, answer composition, and Q&A value assessment standards.","fileCount":15,"zipByteSize":24311},{"version":"1.0.4","createdAt":"2026-07-08T16:57:10.688Z","changelog":"No changes detected in this version. - No file changes were made compared to the previous release. - Functionality, workflows, and documentation remain the same as in the previous version.","fileCount":15,"zipByteSize":23027},{"version":"1.0.3","createdAt":"2026-07-08T10:31:11.034Z","changelog":"Version 1.0.3 - No functional or documentation changes detected; file contents are unchanged. - This version maintains all existing workflows, conventions, and skill boundaries as before.","fileCount":15,"zipByteSize":22549},{"version":"1.0.2","createdAt":"2026-07-07T17:47:42.776Z","changelog":"- Major refactor: Restructured the skill to a multi-stage, OpenClaw-led knowledge base Q&A workflow with enhanced evidence selection and higher-quality answers. - Python scripts now only perform deterministic steps: catalog reading, evidence page retrieval, attachment text preview, and output validation; answer generation and evidence selection are handled by OpenClaw. - Introduced a four-stage query process: prepare catalog/context, OpenClaw reference selection, evidence fetch, and final answer integration—with each stage generating/consuming explicit JSON artifacts. - Answer and citation process is clarified: citations must trace only to actually read stable KB pages; temporary attachments may inform context but not be treated as stable sources. - High-value Q&A persistence (to `qa/`) is now strictly gated by a multi-criteria evaluation; OpenClaw must explicitly justify value before a Q&A is stored for future reuse. - Removed legacy scripts and simplified task handling—no scripted fallback answers if OpenClaw output is missing or evidence is insufficient.","fileCount":15,"zipByteSize":22596},{"version":"1.0.1","createdAt":"2026-06-25T19:27:24.503Z","changelog":"- Clarified skill responsibilities, task boundaries, and valid input constraints. - Detailed step-by-step lookup, evidence extraction, and citation requirements for all Q&A tasks. - Updated output JSON schema and formatting rules for consistent desktop integration. - Added strict evidence insufficiency response and citation structure guidelines. - Emphasized separation of general explanations from knowledge-base sourced answers.","fileCount":19,"zipByteSize":13668}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s175zrvz5m28epr76c6rt4dtex8474t6:kb-query","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 classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.","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-kb-query/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-kb-query/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-kb-query/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-kb-query/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-kb-query/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-kb-query/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-11T07:39:54.929Z"}},"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-kb-query/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-kb-query/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-kb-query/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-myd2002-kb-query/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-11T04:10:06.085Z","emptyReason":null},"readme":"Skill: Kb Query\n\nOwner: myd2002\n\nSummary: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\n\nTags: latest:1.0.8\n\nVersion history:\n\nv1.0.8 | 2026-07-09T14:33:17.833Z | user\n\nNo functional changes. Documentation improved for implementation details and usage clarity.\n\n- Clarified that answer.json should usually be written using python3's json.dump/json.dumps; discourages manual construction for complex answers.\n- Added note that Markdown, tables, and double quotes in answers are acceptable—focus is on using robust JSON output.\n- No code or behavioral changes in this version.\n\nv1.0.7 | 2026-07-08T19:54:19.415Z | user\n\nVersion 1.0.7 (no file changes detected)\n\n- No code or documentation changes in this version.\n- Skill behavior, process, and documentation remain identical to the previous release.\n\nv1.0.6 | 2026-07-08T19:38:52.332Z | user\n\n- Page selection process changed: now, if no suitable KB pages exist or the KB cannot answer, a valid empty selection is written to proceed, and insufficient evidence is reported at the answer stage rather than stopping early.\n- Clarified that if evidence is insufficient, the flow reaches fetch/apply with an empty selection instead of halting in selection.\n- Minor clarifications about not exceeding selection scope and prompt updates to rule explanations.\n- No code changes; documentation update only.\n\nv1.0.5 | 2026-07-08T19:03:07.966Z | user\n\nVersion 1.0.5\n\n- Enforces stricter context and evidence file handling: JSON is only fully written to file (not terminal), and OpenClaw must read from file, not paste content into chat.\n- Adds context budget enforcement: OpenClaw should typically select only 1–4 key KB pages (never above maxSelectedPages), aiming for a minimal sufficient set.\n- Requires all intermediate JSON files to be strictly valid; do not include Markdown fences, comments, trailing commas, or partial content.\n- Each execution step (prepare/fetch) now only outputs a summary to the terminal; full details are saved to disk for OpenClaw's use.\n- Clarifies and reinforces evidence selection, answer composition, and Q&A value assessment standards.\n\nv1.0.4 | 2026-07-08T16:57:10.688Z | user\n\nNo changes detected in this version.\n\n- No file changes were made compared to the previous release.\n- Functionality, workflows, and documentation remain the same as in the previous version.\n\nv1.0.3 | 2026-07-08T10:31:11.034Z | user\n\nVersion 1.0.3\n\n- No functional or documentation changes detected; file contents are unchanged.\n- This version maintains all existing workflows, conventions, and skill boundaries as before.\n\nv1.0.2 | 2026-07-07T17:47:42.776Z | auto\n\n- Major refactor: Restructured the skill to a multi-stage, OpenClaw-led knowledge base Q&A workflow with enhanced evidence selection and higher-quality answers.\n- Python scripts now only perform deterministic steps: catalog reading, evidence page retrieval, attachment text preview, and output validation; answer generation and evidence selection are handled by OpenClaw.\n- Introduced a four-stage query process: prepare catalog/context, OpenClaw reference selection, evidence fetch, and final answer integration—with each stage generating/consuming explicit JSON artifacts.\n- Answer and citation process is clarified: citations must trace only to actually read stable KB pages; temporary attachments may inform context but not be treated as stable sources.\n- High-value Q&A persistence (to `qa/`) is now strictly gated by a multi-criteria evaluation; OpenClaw must explicitly justify value before a Q&A is stored for future reuse.\n- Removed legacy scripts and simplified task handling—no scripted fallback answers if OpenClaw output is missing or evidence is insufficient.\n\nv1.0.1 | 2026-06-25T19:27:24.503Z | auto\n\n- Clarified skill responsibilities, task boundaries, and valid input constraints.\n- Detailed step-by-step lookup, evidence extraction, and citation requirements for all Q&A tasks.\n- Updated output JSON schema and formatting rules for consistent desktop integration.\n- Added strict evidence insufficiency response and citation structure guidelines.\n- Emphasized separation of general explanations from knowledge-base sourced answers.\n\nv1.0.0 | 2026-06-25T12:51:21.528Z | auto\n\n- Initial release of the `kb_query` skill for querying Java-specified research knowledge base repositories.\n- Strictly answers questions using only pages from the specified `kbTargets`, with enforced source grounding and structured citations.\n- Reads relevant repository files (`catalog.json`, `index.md`) to identify candidate pages before reading and citing content.\n- Always returns a single JSON object with answer, citations, and evidence details; errors are reported as needed.\n- Clearly states when insufficient evidence is found, preventing unsupported answers.\n- Output and citation formatting matches desktop system requirements for easy reference and compliance.\n\nArchive index:\n\nArchive v1.0.8: 15 files, 28494 bytes\n\nFiles: _meta.json (127b), env-example.txt (159b), main.js (219b), requirements.txt (96b), scripts/catalog.py (5671b), scripts/gitea_api.py (3458b), scripts/qa_writer.py (15683b), scripts/query_context.py (20280b), scripts/run_task.py (16553b), scripts/task_io.py (5113b), scripts/text_extractors.py (2001b), scripts/utils.py (3138b), setup.sh (119b), skill-card.md (2102b), SKILL.md (11216b)\n\nFile v1.0.8:SKILL.md\n\n---\r\nname: kb_query\r\ndescription: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\r\n---\r\n\r\n# kb_query\r\n\r\n## 职责边界\r\n\r\n`kb_query` 只负责“对话”页面的知识库查询。用户输入可以是纯文字，也可以带附件；附件一律是本轮参考材料，用于辅助理解问题、补充上下文或做临时对比，稳定来源仍以知识库证据页为准。\r\n\r\n本 skill 不负责登录、权限、会话历史、文件上传、任务调度或资料源入库。Java 后端负责这些系统动作。OpenClaw 负责理解用户问题、判断需要参考哪些 KB 页面、综合证据、生成回答、判断证据是否充分，以及判断是否值得沉淀为 `qa/` 页面。Python 脚本只做确定性动作：读取 catalog/index 和探索卡片、按 OpenClaw 选择读取证据页面、抽取附件文本预览、校验 OpenClaw 输出、可选写入 `qa/`、维护 `catalog.json`/`index.md`、写出后端 result JSON。\r\n\r\n不要提供脚本兜底的抽取式简化回答。没有真实 OpenClaw 理解时，任务应失败或返回明确错误，而不是用脚本假装完成问答。\r\n\r\n## 输入约定\r\n\r\n后端 payload 通常包含：\r\n\r\n- `taskId`: 后端生成的查询任务 ID，当前格式为 `query-<conversationId>-<messageId>`，用于共享 payload/result 文件和 OpenClaw session key。\r\n- `skill`: `kb_query`。\r\n- `question`: 用户问题。\r\n- `conversationId`: 当前会话 ID。\r\n- `messageId`: 用户消息 ID。\r\n- `attachments[]`: 本轮参考附件，字段包括 `attachmentId`、`fileName`、`mimeType`、`storagePath`、`sha256`、`size`、`temporary=true`。\r\n- `answerPolicy.scopeSelection`: `auto_by_openclaw`。\r\n- `answerPolicy.knowledgeBaseFirst`: `true`，表示事实性回答必须优先基于团队 KB。`answerPolicy.allowNonKbSupplementWhenInsufficient=true` 时，知识库证据不足可以在明确说明后补充非 KB 或附件分析。\r\n- `answerPolicy.writeHighValueAnswerToQa`: 是否允许高价值问答写入 `qa/`。\r\n- `payloadFile`、`resultFile`、`sharedDir`: 后端共享目录路径。\r\n\r\n环境变量包括 `GITEA_URL`、`GITEA_BOT_TOKEN`、`GITEA_BOT_USERNAME`、`GITEA_ORG`、`TEAM_KB_REPO`、`OPENCLAW_SHARED_DIR`。\r\n\r\n## 执行流程\r\n\r\n必须使用四段式流程，让“选哪些页面作为参考”由 OpenClaw 完成，而不是由脚本用关键词配对决定。\n\n上下文预算必须保守执行。`prepare`/`fetch` 命令会把完整 JSON 写入文件，终端只输出摘要；OpenClaw 应阅读文件路径指向的 JSON，不要把完整 context/evidence 粘贴回聊天。页面选择应坚持“够用即可”：通常选择 1-4 个最关键 KB 页面，最多不得超过 `context.analysisLimits.maxSelectedPages`。如果 OpenClaw 判断问题本身不适合由 KB 回答，或者没有任何相关 KB 页面，可以写出合法的空选择 `{\"selectedPages\":[],\"rationale\":\"...\",\"unresolvedQuestions\":[]}`，继续运行 fetch/apply，并在答案中按证据不足规则说明。不要因为证据不足而停止在 selection 阶段；如果少量证据已经能回答，不要扩大读取范围；如果证据不足，按不足规则回答，而不是继续尝试读取大量页面。\n\n所有中间 JSON 文件必须是严格合法 JSON。写 `page-selection.json` 和 `answer.json` 时不要加入 Markdown 代码围栏、注释、尾随逗号或半截文本；文件写好后再运行下一步脚本。`answer` 正文通常包含 Markdown、双引号和表格，优先用 `python3` 的 `json.dump`/`json.dumps` 写出整个 `answer.json`，不要手写长 JSON 字符串。\n\n1. 运行准备脚本：\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\n准备脚本会读取 `catalog.json`、`index.md`、页面元数据、少量探索卡片和附件文本预览，输出 OpenClaw 可读的查询规划上下文。命令行只返回摘要，完整内容在 `<context.json>` 中。`starterPageCards` 只是帮助 OpenClaw 快速了解可能相关的页面，不是最终证据，也不能直接作为引用依据。脚本不会生成答案，也不会决定最终参考页面。\n\n2. OpenClaw 阅读 `<context.json>`，根据用户问题、目录、索引、页面卡片、预算限制和附件上下文，思考并生成 `<page-selection.json>`。OpenClaw 可以选择任意可见 catalog 页面，不限于 `starterPageCards`，但应选择最小充分集合。\n\r\n`page-selection.json` 示例：\r\n\r\n```json\r\n{\r\n  \"rationale\": \"为什么这些页面需要被读取作为证据\",\r\n  \"selectedPages\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"reason\": \"用于确认项目边界和当前实现\",\r\n      \"expectedUse\": \"回答功能进度和边界\"\r\n    }\r\n  ],\r\n  \"unresolvedQuestions\": []\r\n}\r\n```\r\n\r\n3. 按 OpenClaw 选择读取证据页：\r\n\r\n```bash\r\npython3 scripts/run_task.py fetch --input <payload.json> --context <context.json> --selection <page-selection.json> --evidence-output <evidence.json>\r\n```\r\n\r\n`fetch` 只负责校验路径、读取 OpenClaw 选择的 KB 页面、解析 frontmatter `sources[]`，并输出 `<evidence.json>`。命令行只返回证据页摘要，完整内容在 `<evidence.json>` 中。它不做答案判断，也不替 OpenClaw 增删参考范围。\n\r\n4. OpenClaw 阅读 `<context.json>` 和 `<evidence.json>`，进行知识库问答，生成 `<answer.json>`。`answer.json` 必须符合“OpenClaw 输出格式”。答案中的 `sources[]` 只能引用 `<evidence.json>` 中实际读取到的稳定 KB 页面；临时附件不能作为稳定 KB 来源。\r\n\r\n5. 运行应用脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --evidence <evidence.json> --answer <answer.json>\r\n```\r\n\r\n应用脚本会校验答案、确保结尾有参考来源、必要时写入 `qa/` 并更新 `catalog.json` 和 `index.md`，最后把后端 result JSON 写入 payload 指定的 `resultFile`。\r\n\r\n6. 最终回复后端：\r\n\r\n```json\r\n{\"success\": true, \"resultFile\": \"<result.json>\"}\r\n```\r\n\r\n## 回答规则\r\n\r\nOpenClaw 必须先判断团队 KB 证据是否足以回答问题。证据充分性判断基于 OpenClaw 自己选择并通过 `fetch` 读取到的稳定 KB 页面。\r\n\r\n如果 KB 证据足够：先直接回答结论，再给出必要解释、比较、步骤或建议。回答必须以中文为主，除非用户明确要求其他语言。\r\n\r\n如果 KB 证据不足：回答开头必须明确说明“知识库内容无法回答这个问题”或等价表达，然后说明缺少哪些证据。可以在下方补充一般性回答或基于附件的临时分析，但必须标注“以下为非知识库结论/本轮参考附件推断”。\r\n\r\n附件只能帮助理解问题、补充本轮上下文或做临时对比；不要把临时附件当作长期 KB 来源，不要因为附件出现就写普通知识页。若答案主要依赖附件且缺少稳定 KB 证据，通常不要沉淀为 `qa/`。\r\n\r\n回答正文不强制套固定模板。可以按用户问题自然组织成结论、解释、对比、步骤、表格或建议；但不要为了模板牺牲可读性。\r\n\r\n答案结尾必须包含“参考来源”小节，这是唯一强制模板。稳定来源应优先列出 KB 页面路径和标题；如果证据页带有 `sources[]`，同时列出对应源文件、归档路径、仓库 URL、commit 或其他可追溯线索。若没有可引用 KB 页面，写明“知识库中未找到可支撑本问题的页面”。\r\n\r\n## 高价值问答沉淀\r\n\r\n高价值问答不是“回答得长”或“用户问了一个问题”就沉淀，而是要成为团队以后可复用的知识入口。OpenClaw 必须先做结构化评估，再决定是否把 `highValue` 或 `qa.write` 设为 `true`。\r\n\r\n硬性门槛：\r\n\r\n- `knowledgeSufficient=true`，且答案有稳定 KB 页面支撑。\r\n- 主要依据不是本轮临时附件；附件只能帮助理解问题或补充临时上下文。\r\n- 问题不是一次性操作、临时状态查询、简单事实定位、格式转换、寒暄、泛泛建议或纯外部常识问答。\r\n- 结论足够稳定，后续成员在相同或相近问题下可以直接复用。\r\n\r\n正向信号：\r\n\r\n- 跨多个稳定 KB 页面综合，或者把一个重要单页中的规则/边界整理成可复用的规范答案。\r\n- 回答澄清了项目架构、功能边界、资料源处理规则、实验结论、技术选型、风险判断或工作流程。\r\n- 答案包含明确判断、适用条件、例外情况和后续行动，而不是只摘录原文。\r\n- 该问题预计会反复出现，沉淀后能减少后续检索和解释成本。\r\n\r\n建议采用 0-5 分评估：`reuseValue`、`synthesisDepth`、`evidenceQuality`、`stability`、`actionability` 各 0/1 分。总分至少 4 分，且通过全部硬性门槛时，才允许写入 `qa/`。\r\n\r\nOpenClaw 必须在 `answer.json` 中给出 `qaEvaluation`，说明为什么是或不是高价值问答。apply 脚本只执行确定性拦截：缺少评估、证据不足、无稳定来源、附件驱动、临时/一次性、分数不足时，即使 OpenClaw 请求写入，也不沉淀。\r\n\r\n`qa/` 页面应包含：问题、可复用回答、证据页面、适用场景、更新时间。QA 页面只应引用稳定 KB 页面作为来源；临时附件不能作为唯一长期证据。\r\n\r\n## OpenClaw 输出格式\r\n\r\n`answer.json` 是 OpenClaw 生成、apply 脚本读取的文件：\r\n\r\n```json\r\n{\r\n  \"answer\": \"完整回答。正文不需要固定模板；结尾可以已包含参考来源，apply 会补齐缺失的参考来源。\",\r\n  \"knowledgeSufficient\": true,\r\n  \"sources\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"title\": \"Example\",\r\n      \"type\": \"project\",\r\n      \"snippet\": \"可选引用片段\",\r\n      \"sourceIds\": [],\r\n      \"sourceTraces\": [\r\n        {\r\n          \"sourceId\": 1,\r\n          \"sourceType\": \"local_folder\",\r\n          \"title\": \"原始资料标题\",\r\n          \"fileName\": \"example.pdf\",\r\n          \"archivedPath\": \"source_files/local_folder/example.pdf\",\r\n          \"url\": \"\",\r\n          \"commitHash\": \"\"\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"usedAttachments\": [\r\n    {\r\n      \"attachmentId\": 1,\r\n      \"fileName\": \"context.docx\",\r\n      \"role\": \"query_reference\"\r\n    }\r\n  ],\r\n  \"highValue\": false,\r\n  \"qaEvaluation\": {\r\n    \"reuseValue\": 0,\r\n    \"synthesisDepth\": 0,\r\n    \"evidenceQuality\": 0,\r\n    \"stability\": 0,\r\n    \"actionability\": 0,\r\n    \"attachmentDriven\": false,\r\n    \"ephemeral\": false,\r\n    \"reason\": \"为什么适合或不适合沉淀\"\r\n  },\r\n  \"qa\": {\r\n    \"write\": false,\r\n    \"path\": \"qa/example.md\",\r\n    \"title\": \"可复用问答标题\",\r\n    \"content\": \"可选；不填时 apply 根据 answer 自动生成\"\r\n  },\r\n  \"errors\": []\r\n}\r\n```\r\n\r\n后端最终读取 `resultFile` 中的字段：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"answer\": \"...\",\r\n  \"sources\": [],\r\n  \"createdQaPath\": \"qa/example.md\",\r\n  \"processedSources\": [\"team-kb\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\"\r\n}\r\n```\n\nFile v1.0.8:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.8\",\n  \"publishedAt\": 1783607597833\n}\n\nFile v1.0.8:skill-card.md\n\n## Description:\n\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\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-team KB users use this skill to answer questions against a team Gitea-backed knowledge base, optionally using temporary attachments for context and persisting reusable high-value Q&A entries when policy allows.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: The skill uses a bot token to read and write a Gitea-backed knowledge base.\n\nMitigation: Run it only with trusted backend payloads and a tightly scoped bot account limited to the intended KB repository.\n\nRisk: Payload or environment configuration can select the Gitea host used by the helper scripts.\n\nMitigation: Require an allowlisted HTTPS Gitea host before production use.\n\nRisk: The skill reads attachment paths and writes result paths supplied through backend payloads.\n\nMitigation: Constrain attachment and result paths to trusted directories and reject symlinks or path traversal.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/myd2002/skills/kb-query)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, JSON, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown answer text with JSON result files and cited KB sources]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [May create or update high-value Q&A pages, catalog entries, and index entries when policy and evidence gates allow.]\n\n## Skill Version(s):\n\n1.0.8 (source: server release metadata)\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.8: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\n\nFile v1.0.8:requirements.txt\n\n# kb_query uses only the Python 3 standard library for deterministic prepare/apply helpers.\n\nArchive v1.0.7: 15 files, 26171 bytes\n\nFiles: _meta.json (127b), env-example.txt (159b), main.js (219b), requirements.txt (96b), scripts/catalog.py (5671b), scripts/gitea_api.py (3458b), scripts/qa_writer.py (15683b), scripts/query_context.py (20139b), scripts/run_task.py (8236b), scripts/task_io.py (5113b), scripts/text_extractors.py (2001b), scripts/utils.py (3138b), setup.sh (119b), skill-card.md (2053b), SKILL.md (11045b)\n\nFile v1.0.7:SKILL.md\n\n---\r\nname: kb_query\r\ndescription: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\r\n---\r\n\r\n# kb_query\r\n\r\n## 职责边界\r\n\r\n`kb_query` 只负责“对话”页面的知识库查询。用户输入可以是纯文字，也可以带附件；附件一律是本轮参考材料，用于辅助理解问题、补充上下文或做临时对比，稳定来源仍以知识库证据页为准。\r\n\r\n本 skill 不负责登录、权限、会话历史、文件上传、任务调度或资料源入库。Java 后端负责这些系统动作。OpenClaw 负责理解用户问题、判断需要参考哪些 KB 页面、综合证据、生成回答、判断证据是否充分，以及判断是否值得沉淀为 `qa/` 页面。Python 脚本只做确定性动作：读取 catalog/index 和探索卡片、按 OpenClaw 选择读取证据页面、抽取附件文本预览、校验 OpenClaw 输出、可选写入 `qa/`、维护 `catalog.json`/`index.md`、写出后端 result JSON。\r\n\r\n不要提供脚本兜底的抽取式简化回答。没有真实 OpenClaw 理解时，任务应失败或返回明确错误，而不是用脚本假装完成问答。\r\n\r\n## 输入约定\r\n\r\n后端 payload 通常包含：\r\n\r\n- `taskId`: 后端生成的查询任务 ID，当前格式为 `query-<conversationId>-<messageId>`，用于共享 payload/result 文件和 OpenClaw session key。\r\n- `skill`: `kb_query`。\r\n- `question`: 用户问题。\r\n- `conversationId`: 当前会话 ID。\r\n- `messageId`: 用户消息 ID。\r\n- `attachments[]`: 本轮参考附件，字段包括 `attachmentId`、`fileName`、`mimeType`、`storagePath`、`sha256`、`size`、`temporary=true`。\r\n- `answerPolicy.scopeSelection`: `auto_by_openclaw`。\r\n- `answerPolicy.knowledgeBaseFirst`: `true`，表示事实性回答必须优先基于团队 KB。`answerPolicy.allowNonKbSupplementWhenInsufficient=true` 时，知识库证据不足可以在明确说明后补充非 KB 或附件分析。\r\n- `answerPolicy.writeHighValueAnswerToQa`: 是否允许高价值问答写入 `qa/`。\r\n- `payloadFile`、`resultFile`、`sharedDir`: 后端共享目录路径。\r\n\r\n环境变量包括 `GITEA_URL`、`GITEA_BOT_TOKEN`、`GITEA_BOT_USERNAME`、`GITEA_ORG`、`TEAM_KB_REPO`、`OPENCLAW_SHARED_DIR`。\r\n\r\n## 执行流程\r\n\r\n必须使用四段式流程，让“选哪些页面作为参考”由 OpenClaw 完成，而不是由脚本用关键词配对决定。\n\n上下文预算必须保守执行。`prepare`/`fetch` 命令会把完整 JSON 写入文件，终端只输出摘要；OpenClaw 应阅读文件路径指向的 JSON，不要把完整 context/evidence 粘贴回聊天。页面选择应坚持“够用即可”：通常选择 1-4 个最关键 KB 页面，最多不得超过 `context.analysisLimits.maxSelectedPages`。如果 OpenClaw 判断问题本身不适合由 KB 回答，或者没有任何相关 KB 页面，可以写出合法的空选择 `{\"selectedPages\":[],\"rationale\":\"...\",\"unresolvedQuestions\":[]}`，继续运行 fetch/apply，并在答案中按证据不足规则说明。不要因为证据不足而停止在 selection 阶段；如果少量证据已经能回答，不要扩大读取范围；如果证据不足，按不足规则回答，而不是继续尝试读取大量页面。\n\n所有中间 JSON 文件必须是严格合法 JSON。写 `page-selection.json` 和 `answer.json` 时不要加入 Markdown 代码围栏、注释、尾随逗号或半截文本；文件写好后再运行下一步脚本。\n\n1. 运行准备脚本：\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\n准备脚本会读取 `catalog.json`、`index.md`、页面元数据、少量探索卡片和附件文本预览，输出 OpenClaw 可读的查询规划上下文。命令行只返回摘要，完整内容在 `<context.json>` 中。`starterPageCards` 只是帮助 OpenClaw 快速了解可能相关的页面，不是最终证据，也不能直接作为引用依据。脚本不会生成答案，也不会决定最终参考页面。\n\n2. OpenClaw 阅读 `<context.json>`，根据用户问题、目录、索引、页面卡片、预算限制和附件上下文，思考并生成 `<page-selection.json>`。OpenClaw 可以选择任意可见 catalog 页面，不限于 `starterPageCards`，但应选择最小充分集合。\n\r\n`page-selection.json` 示例：\r\n\r\n```json\r\n{\r\n  \"rationale\": \"为什么这些页面需要被读取作为证据\",\r\n  \"selectedPages\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"reason\": \"用于确认项目边界和当前实现\",\r\n      \"expectedUse\": \"回答功能进度和边界\"\r\n    }\r\n  ],\r\n  \"unresolvedQuestions\": []\r\n}\r\n```\r\n\r\n3. 按 OpenClaw 选择读取证据页：\r\n\r\n```bash\r\npython3 scripts/run_task.py fetch --input <payload.json> --context <context.json> --selection <page-selection.json> --evidence-output <evidence.json>\r\n```\r\n\r\n`fetch` 只负责校验路径、读取 OpenClaw 选择的 KB 页面、解析 frontmatter `sources[]`，并输出 `<evidence.json>`。命令行只返回证据页摘要，完整内容在 `<evidence.json>` 中。它不做答案判断，也不替 OpenClaw 增删参考范围。\n\r\n4. OpenClaw 阅读 `<context.json>` 和 `<evidence.json>`，进行知识库问答，生成 `<answer.json>`。`answer.json` 必须符合“OpenClaw 输出格式”。答案中的 `sources[]` 只能引用 `<evidence.json>` 中实际读取到的稳定 KB 页面；临时附件不能作为稳定 KB 来源。\r\n\r\n5. 运行应用脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --evidence <evidence.json> --answer <answer.json>\r\n```\r\n\r\n应用脚本会校验答案、确保结尾有参考来源、必要时写入 `qa/` 并更新 `catalog.json` 和 `index.md`，最后把后端 result JSON 写入 payload 指定的 `resultFile`。\r\n\r\n6. 最终回复后端：\r\n\r\n```json\r\n{\"success\": true, \"resultFile\": \"<result.json>\"}\r\n```\r\n\r\n## 回答规则\r\n\r\nOpenClaw 必须先判断团队 KB 证据是否足以回答问题。证据充分性判断基于 OpenClaw 自己选择并通过 `fetch` 读取到的稳定 KB 页面。\r\n\r\n如果 KB 证据足够：先直接回答结论，再给出必要解释、比较、步骤或建议。回答必须以中文为主，除非用户明确要求其他语言。\r\n\r\n如果 KB 证据不足：回答开头必须明确说明“知识库内容无法回答这个问题”或等价表达，然后说明缺少哪些证据。可以在下方补充一般性回答或基于附件的临时分析，但必须标注“以下为非知识库结论/本轮参考附件推断”。\r\n\r\n附件只能帮助理解问题、补充本轮上下文或做临时对比；不要把临时附件当作长期 KB 来源，不要因为附件出现就写普通知识页。若答案主要依赖附件且缺少稳定 KB 证据，通常不要沉淀为 `qa/`。\r\n\r\n回答正文不强制套固定模板。可以按用户问题自然组织成结论、解释、对比、步骤、表格或建议；但不要为了模板牺牲可读性。\r\n\r\n答案结尾必须包含“参考来源”小节，这是唯一强制模板。稳定来源应优先列出 KB 页面路径和标题；如果证据页带有 `sources[]`，同时列出对应源文件、归档路径、仓库 URL、commit 或其他可追溯线索。若没有可引用 KB 页面，写明“知识库中未找到可支撑本问题的页面”。\r\n\r\n## 高价值问答沉淀\r\n\r\n高价值问答不是“回答得长”或“用户问了一个问题”就沉淀，而是要成为团队以后可复用的知识入口。OpenClaw 必须先做结构化评估，再决定是否把 `highValue` 或 `qa.write` 设为 `true`。\r\n\r\n硬性门槛：\r\n\r\n- `knowledgeSufficient=true`，且答案有稳定 KB 页面支撑。\r\n- 主要依据不是本轮临时附件；附件只能帮助理解问题或补充临时上下文。\r\n- 问题不是一次性操作、临时状态查询、简单事实定位、格式转换、寒暄、泛泛建议或纯外部常识问答。\r\n- 结论足够稳定，后续成员在相同或相近问题下可以直接复用。\r\n\r\n正向信号：\r\n\r\n- 跨多个稳定 KB 页面综合，或者把一个重要单页中的规则/边界整理成可复用的规范答案。\r\n- 回答澄清了项目架构、功能边界、资料源处理规则、实验结论、技术选型、风险判断或工作流程。\r\n- 答案包含明确判断、适用条件、例外情况和后续行动，而不是只摘录原文。\r\n- 该问题预计会反复出现，沉淀后能减少后续检索和解释成本。\r\n\r\n建议采用 0-5 分评估：`reuseValue`、`synthesisDepth`、`evidenceQuality`、`stability`、`actionability` 各 0/1 分。总分至少 4 分，且通过全部硬性门槛时，才允许写入 `qa/`。\r\n\r\nOpenClaw 必须在 `answer.json` 中给出 `qaEvaluation`，说明为什么是或不是高价值问答。apply 脚本只执行确定性拦截：缺少评估、证据不足、无稳定来源、附件驱动、临时/一次性、分数不足时，即使 OpenClaw 请求写入，也不沉淀。\r\n\r\n`qa/` 页面应包含：问题、可复用回答、证据页面、适用场景、更新时间。QA 页面只应引用稳定 KB 页面作为来源；临时附件不能作为唯一长期证据。\r\n\r\n## OpenClaw 输出格式\r\n\r\n`answer.json` 是 OpenClaw 生成、apply 脚本读取的文件：\r\n\r\n```json\r\n{\r\n  \"answer\": \"完整回答。正文不需要固定模板；结尾可以已包含参考来源，apply 会补齐缺失的参考来源。\",\r\n  \"knowledgeSufficient\": true,\r\n  \"sources\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"title\": \"Example\",\r\n      \"type\": \"project\",\r\n      \"snippet\": \"可选引用片段\",\r\n      \"sourceIds\": [],\r\n      \"sourceTraces\": [\r\n        {\r\n          \"sourceId\": 1,\r\n          \"sourceType\": \"local_folder\",\r\n          \"title\": \"原始资料标题\",\r\n          \"fileName\": \"example.pdf\",\r\n          \"archivedPath\": \"source_files/local_folder/example.pdf\",\r\n          \"url\": \"\",\r\n          \"commitHash\": \"\"\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"usedAttachments\": [\r\n    {\r\n      \"attachmentId\": 1,\r\n      \"fileName\": \"context.docx\",\r\n      \"role\": \"query_reference\"\r\n    }\r\n  ],\r\n  \"highValue\": false,\r\n  \"qaEvaluation\": {\r\n    \"reuseValue\": 0,\r\n    \"synthesisDepth\": 0,\r\n    \"evidenceQuality\": 0,\r\n    \"stability\": 0,\r\n    \"actionability\": 0,\r\n    \"attachmentDriven\": false,\r\n    \"ephemeral\": false,\r\n    \"reason\": \"为什么适合或不适合沉淀\"\r\n  },\r\n  \"qa\": {\r\n    \"write\": false,\r\n    \"path\": \"qa/example.md\",\r\n    \"title\": \"可复用问答标题\",\r\n    \"content\": \"可选；不填时 apply 根据 answer 自动生成\"\r\n  },\r\n  \"errors\": []\r\n}\r\n```\r\n\r\n后端最终读取 `resultFile` 中的字段：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"answer\": \"...\",\r\n  \"sources\": [],\r\n  \"createdQaPath\": \"qa/example.md\",\r\n  \"processedSources\": [\"team-kb\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\"\r\n}\r\n```\n\nFile v1.0.7:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.7\",\n  \"publishedAt\": 1783540459415\n}\n\nFile v1.0.7:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. <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>\nTeam members and developers use Kb Query to answer questions against a Gitea-backed Research KB, cite stable KB pages, and optionally persist reusable Q&A when enabled. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill can read team KB content and reference attachments. <br>\nMitigation: Install it only where the Gitea bot token is limited to the intended KB repository. <br>\nRisk: Optional Q&A persistence can commit reusable answers back to the KB. <br>\nMitigation: Keep Q&A persistence disabled unless the team wants curated answers saved as KB pages. <br>\nRisk: Attachment access depends on storage paths supplied through the surrounding system. <br>\nMitigation: Use backend-generated attachment storage paths rather than user-supplied paths. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, JSON, shell commands, configuration] <br>\n**Output Format:** [Markdown answers with JSON handoff files and shell command steps.] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Can write a backend result JSON and, when enabled, a reusable Q&A Markdown page.] <br>\n\n## Skill Version(s): <br>\n1.0.7 (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.7: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\n\nFile v1.0.7:requirements.txt\n\n# kb_query uses only the Python 3 standard library for deterministic prepare/apply helpers.\n\nArchive v1.0.6: 15 files, 26105 bytes\n\nFiles: _meta.json (127b), env-example.txt (159b), main.js (219b), requirements.txt (96b), scripts/catalog.py (5671b), scripts/gitea_api.py (3458b), scripts/qa_writer.py (15683b), scripts/query_context.py (20139b), scripts/run_task.py (8236b), scripts/task_io.py (3902b), scripts/text_extractors.py (2001b), scripts/utils.py (3138b), setup.sh (119b), skill-card.md (2369b), SKILL.md (11045b)\n\nFile v1.0.6:SKILL.md\n\n---\r\nname: kb_query\r\ndescription: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\r\n---\r\n\r\n# kb_query\r\n\r\n## 职责边界\r\n\r\n`kb_query` 只负责“对话”页面的知识库查询。用户输入可以是纯文字，也可以带附件；附件一律是本轮参考材料，用于辅助理解问题、补充上下文或做临时对比，稳定来源仍以知识库证据页为准。\r\n\r\n本 skill 不负责登录、权限、会话历史、文件上传、任务调度或资料源入库。Java 后端负责这些系统动作。OpenClaw 负责理解用户问题、判断需要参考哪些 KB 页面、综合证据、生成回答、判断证据是否充分，以及判断是否值得沉淀为 `qa/` 页面。Python 脚本只做确定性动作：读取 catalog/index 和探索卡片、按 OpenClaw 选择读取证据页面、抽取附件文本预览、校验 OpenClaw 输出、可选写入 `qa/`、维护 `catalog.json`/`index.md`、写出后端 result JSON。\r\n\r\n不要提供脚本兜底的抽取式简化回答。没有真实 OpenClaw 理解时，任务应失败或返回明确错误，而不是用脚本假装完成问答。\r\n\r\n## 输入约定\r\n\r\n后端 payload 通常包含：\r\n\r\n- `taskId`: 后端生成的查询任务 ID，当前格式为 `query-<conversationId>-<messageId>`，用于共享 payload/result 文件和 OpenClaw session key。\r\n- `skill`: `kb_query`。\r\n- `question`: 用户问题。\r\n- `conversationId`: 当前会话 ID。\r\n- `messageId`: 用户消息 ID。\r\n- `attachments[]`: 本轮参考附件，字段包括 `attachmentId`、`fileName`、`mimeType`、`storagePath`、`sha256`、`size`、`temporary=true`。\r\n- `answerPolicy.scopeSelection`: `auto_by_openclaw`。\r\n- `answerPolicy.knowledgeBaseFirst`: `true`，表示事实性回答必须优先基于团队 KB。`answerPolicy.allowNonKbSupplementWhenInsufficient=true` 时，知识库证据不足可以在明确说明后补充非 KB 或附件分析。\r\n- `answerPolicy.writeHighValueAnswerToQa`: 是否允许高价值问答写入 `qa/`。\r\n- `payloadFile`、`resultFile`、`sharedDir`: 后端共享目录路径。\r\n\r\n环境变量包括 `GITEA_URL`、`GITEA_BOT_TOKEN`、`GITEA_BOT_USERNAME`、`GITEA_ORG`、`TEAM_KB_REPO`、`OPENCLAW_SHARED_DIR`。\r\n\r\n## 执行流程\r\n\r\n必须使用四段式流程，让“选哪些页面作为参考”由 OpenClaw 完成，而不是由脚本用关键词配对决定。\n\n上下文预算必须保守执行。`prepare`/`fetch` 命令会把完整 JSON 写入文件，终端只输出摘要；OpenClaw 应阅读文件路径指向的 JSON，不要把完整 context/evidence 粘贴回聊天。页面选择应坚持“够用即可”：通常选择 1-4 个最关键 KB 页面，最多不得超过 `context.analysisLimits.maxSelectedPages`。如果 OpenClaw 判断问题本身不适合由 KB 回答，或者没有任何相关 KB 页面，可以写出合法的空选择 `{\"selectedPages\":[],\"rationale\":\"...\",\"unresolvedQuestions\":[]}`，继续运行 fetch/apply，并在答案中按证据不足规则说明。不要因为证据不足而停止在 selection 阶段；如果少量证据已经能回答，不要扩大读取范围；如果证据不足，按不足规则回答，而不是继续尝试读取大量页面。\n\n所有中间 JSON 文件必须是严格合法 JSON。写 `page-selection.json` 和 `answer.json` 时不要加入 Markdown 代码围栏、注释、尾随逗号或半截文本；文件写好后再运行下一步脚本。\n\n1. 运行准备脚本：\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\n准备脚本会读取 `catalog.json`、`index.md`、页面元数据、少量探索卡片和附件文本预览，输出 OpenClaw 可读的查询规划上下文。命令行只返回摘要，完整内容在 `<context.json>` 中。`starterPageCards` 只是帮助 OpenClaw 快速了解可能相关的页面，不是最终证据，也不能直接作为引用依据。脚本不会生成答案，也不会决定最终参考页面。\n\n2. OpenClaw 阅读 `<context.json>`，根据用户问题、目录、索引、页面卡片、预算限制和附件上下文，思考并生成 `<page-selection.json>`。OpenClaw 可以选择任意可见 catalog 页面，不限于 `starterPageCards`，但应选择最小充分集合。\n\r\n`page-selection.json` 示例：\r\n\r\n```json\r\n{\r\n  \"rationale\": \"为什么这些页面需要被读取作为证据\",\r\n  \"selectedPages\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"reason\": \"用于确认项目边界和当前实现\",\r\n      \"expectedUse\": \"回答功能进度和边界\"\r\n    }\r\n  ],\r\n  \"unresolvedQuestions\": []\r\n}\r\n```\r\n\r\n3. 按 OpenClaw 选择读取证据页：\r\n\r\n```bash\r\npython3 scripts/run_task.py fetch --input <payload.json> --context <context.json> --selection <page-selection.json> --evidence-output <evidence.json>\r\n```\r\n\r\n`fetch` 只负责校验路径、读取 OpenClaw 选择的 KB 页面、解析 frontmatter `sources[]`，并输出 `<evidence.json>`。命令行只返回证据页摘要，完整内容在 `<evidence.json>` 中。它不做答案判断，也不替 OpenClaw 增删参考范围。\n\r\n4. OpenClaw 阅读 `<context.json>` 和 `<evidence.json>`，进行知识库问答，生成 `<answer.json>`。`answer.json` 必须符合“OpenClaw 输出格式”。答案中的 `sources[]` 只能引用 `<evidence.json>` 中实际读取到的稳定 KB 页面；临时附件不能作为稳定 KB 来源。\r\n\r\n5. 运行应用脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --evidence <evidence.json> --answer <answer.json>\r\n```\r\n\r\n应用脚本会校验答案、确保结尾有参考来源、必要时写入 `qa/` 并更新 `catalog.json` 和 `index.md`，最后把后端 result JSON 写入 payload 指定的 `resultFile`。\r\n\r\n6. 最终回复后端：\r\n\r\n```json\r\n{\"success\": true, \"resultFile\": \"<result.json>\"}\r\n```\r\n\r\n## 回答规则\r\n\r\nOpenClaw 必须先判断团队 KB 证据是否足以回答问题。证据充分性判断基于 OpenClaw 自己选择并通过 `fetch` 读取到的稳定 KB 页面。\r\n\r\n如果 KB 证据足够：先直接回答结论，再给出必要解释、比较、步骤或建议。回答必须以中文为主，除非用户明确要求其他语言。\r\n\r\n如果 KB 证据不足：回答开头必须明确说明“知识库内容无法回答这个问题”或等价表达，然后说明缺少哪些证据。可以在下方补充一般性回答或基于附件的临时分析，但必须标注“以下为非知识库结论/本轮参考附件推断”。\r\n\r\n附件只能帮助理解问题、补充本轮上下文或做临时对比；不要把临时附件当作长期 KB 来源，不要因为附件出现就写普通知识页。若答案主要依赖附件且缺少稳定 KB 证据，通常不要沉淀为 `qa/`。\r\n\r\n回答正文不强制套固定模板。可以按用户问题自然组织成结论、解释、对比、步骤、表格或建议；但不要为了模板牺牲可读性。\r\n\r\n答案结尾必须包含“参考来源”小节，这是唯一强制模板。稳定来源应优先列出 KB 页面路径和标题；如果证据页带有 `sources[]`，同时列出对应源文件、归档路径、仓库 URL、commit 或其他可追溯线索。若没有可引用 KB 页面，写明“知识库中未找到可支撑本问题的页面”。\r\n\r\n## 高价值问答沉淀\r\n\r\n高价值问答不是“回答得长”或“用户问了一个问题”就沉淀，而是要成为团队以后可复用的知识入口。OpenClaw 必须先做结构化评估，再决定是否把 `highValue` 或 `qa.write` 设为 `true`。\r\n\r\n硬性门槛：\r\n\r\n- `knowledgeSufficient=true`，且答案有稳定 KB 页面支撑。\r\n- 主要依据不是本轮临时附件；附件只能帮助理解问题或补充临时上下文。\r\n- 问题不是一次性操作、临时状态查询、简单事实定位、格式转换、寒暄、泛泛建议或纯外部常识问答。\r\n- 结论足够稳定，后续成员在相同或相近问题下可以直接复用。\r\n\r\n正向信号：\r\n\r\n- 跨多个稳定 KB 页面综合，或者把一个重要单页中的规则/边界整理成可复用的规范答案。\r\n- 回答澄清了项目架构、功能边界、资料源处理规则、实验结论、技术选型、风险判断或工作流程。\r\n- 答案包含明确判断、适用条件、例外情况和后续行动，而不是只摘录原文。\r\n- 该问题预计会反复出现，沉淀后能减少后续检索和解释成本。\r\n\r\n建议采用 0-5 分评估：`reuseValue`、`synthesisDepth`、`evidenceQuality`、`stability`、`actionability` 各 0/1 分。总分至少 4 分，且通过全部硬性门槛时，才允许写入 `qa/`。\r\n\r\nOpenClaw 必须在 `answer.json` 中给出 `qaEvaluation`，说明为什么是或不是高价值问答。apply 脚本只执行确定性拦截：缺少评估、证据不足、无稳定来源、附件驱动、临时/一次性、分数不足时，即使 OpenClaw 请求写入，也不沉淀。\r\n\r\n`qa/` 页面应包含：问题、可复用回答、证据页面、适用场景、更新时间。QA 页面只应引用稳定 KB 页面作为来源；临时附件不能作为唯一长期证据。\r\n\r\n## OpenClaw 输出格式\r\n\r\n`answer.json` 是 OpenClaw 生成、apply 脚本读取的文件：\r\n\r\n```json\r\n{\r\n  \"answer\": \"完整回答。正文不需要固定模板；结尾可以已包含参考来源，apply 会补齐缺失的参考来源。\",\r\n  \"knowledgeSufficient\": true,\r\n  \"sources\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"title\": \"Example\",\r\n      \"type\": \"project\",\r\n      \"snippet\": \"可选引用片段\",\r\n      \"sourceIds\": [],\r\n      \"sourceTraces\": [\r\n        {\r\n          \"sourceId\": 1,\r\n          \"sourceType\": \"local_folder\",\r\n          \"title\": \"原始资料标题\",\r\n          \"fileName\": \"example.pdf\",\r\n          \"archivedPath\": \"source_files/local_folder/example.pdf\",\r\n          \"url\": \"\",\r\n          \"commitHash\": \"\"\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"usedAttachments\": [\r\n    {\r\n      \"attachmentId\": 1,\r\n      \"fileName\": \"context.docx\",\r\n      \"role\": \"query_reference\"\r\n    }\r\n  ],\r\n  \"highValue\": false,\r\n  \"qaEvaluation\": {\r\n    \"reuseValue\": 0,\r\n    \"synthesisDepth\": 0,\r\n    \"evidenceQuality\": 0,\r\n    \"stability\": 0,\r\n    \"actionability\": 0,\r\n    \"attachmentDriven\": false,\r\n    \"ephemeral\": false,\r\n    \"reason\": \"为什么适合或不适合沉淀\"\r\n  },\r\n  \"qa\": {\r\n    \"write\": false,\r\n    \"path\": \"qa/example.md\",\r\n    \"title\": \"可复用问答标题\",\r\n    \"content\": \"可选；不填时 apply 根据 answer 自动生成\"\r\n  },\r\n  \"errors\": []\r\n}\r\n```\r\n\r\n后端最终读取 `resultFile` 中的字段：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"answer\": \"...\",\r\n  \"sources\": [],\r\n  \"createdQaPath\": \"qa/example.md\",\r\n  \"processedSources\": [\"team-kb\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\"\r\n}\r\n```\n\nFile v1.0.6:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.6\",\n  \"publishedAt\": 1783539532332\n}\n\nFile v1.0.6:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. <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>\nEmployees and developers use this skill to answer Research KB questions from a Gitea-backed team knowledge base, cite stable KB pages, and optionally preserve high-value reusable Q&A when policy allows. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: A broadly scoped Gitea bot token could allow access or changes outside the intended knowledge-base repository. <br>\nMitigation: Limit GITEA_BOT_TOKEN to the intended team knowledge-base repository and use the least permissions needed for read and optional write operations. <br>\nRisk: Optional high-value Q&A persistence can store model-produced answers in the knowledge base. <br>\nMitigation: Enable writeHighValueAnswerToQa only when automatic KB updates are acceptable, and rely on the skill's evidence sufficiency and QA evaluation gates before persisting answers. <br>\nRisk: Reference attachments depend on backend-provided storage paths. <br>\nMitigation: Ensure backend payloads control attachment storage paths and keep attachments as temporary context rather than stable knowledge-base sources. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [Text, Markdown, JSON, Shell commands, Guidance] <br>\n**Output Format:** [JSON result files and Markdown/text answers with stable source citations] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [May include selected KB sources, optional createdQaPath, page-change lists, errors, and commitId.] <br>\n\n## Skill Version(s): <br>\n1.0.6 (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.6: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\n\nFile v1.0.6:requirements.txt\n\n# kb_query uses only the Python 3 standard library for deterministic prepare/apply helpers.\n\nArchive v1.0.5: 15 files, 24311 bytes\n\nFiles: _meta.json (127b), env-example.txt (159b), main.js (219b), requirements.txt (96b), scripts/catalog.py (5671b), scripts/gitea_api.py (3458b), scripts/qa_writer.py (15683b), scripts/query_context.py (20023b), scripts/run_task.py (5951b), scripts/task_io.py (1217b), scripts/text_extractors.py (2001b), scripts/utils.py (3138b), setup.sh (119b), skill-card.md (2253b), SKILL.md (10722b)\n\nFile v1.0.5:SKILL.md\n\n---\r\nname: kb_query\r\ndescription: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\r\n---\r\n\r\n# kb_query\r\n\r\n## 职责边界\r\n\r\n`kb_query` 只负责“对话”页面的知识库查询。用户输入可以是纯文字，也可以带附件；附件一律是本轮参考材料，用于辅助理解问题、补充上下文或做临时对比，稳定来源仍以知识库证据页为准。\r\n\r\n本 skill 不负责登录、权限、会话历史、文件上传、任务调度或资料源入库。Java 后端负责这些系统动作。OpenClaw 负责理解用户问题、判断需要参考哪些 KB 页面、综合证据、生成回答、判断证据是否充分，以及判断是否值得沉淀为 `qa/` 页面。Python 脚本只做确定性动作：读取 catalog/index 和探索卡片、按 OpenClaw 选择读取证据页面、抽取附件文本预览、校验 OpenClaw 输出、可选写入 `qa/`、维护 `catalog.json`/`index.md`、写出后端 result JSON。\r\n\r\n不要提供脚本兜底的抽取式简化回答。没有真实 OpenClaw 理解时，任务应失败或返回明确错误，而不是用脚本假装完成问答。\r\n\r\n## 输入约定\r\n\r\n后端 payload 通常包含：\r\n\r\n- `taskId`: 后端生成的查询任务 ID，当前格式为 `query-<conversationId>-<messageId>`，用于共享 payload/result 文件和 OpenClaw session key。\r\n- `skill`: `kb_query`。\r\n- `question`: 用户问题。\r\n- `conversationId`: 当前会话 ID。\r\n- `messageId`: 用户消息 ID。\r\n- `attachments[]`: 本轮参考附件，字段包括 `attachmentId`、`fileName`、`mimeType`、`storagePath`、`sha256`、`size`、`temporary=true`。\r\n- `answerPolicy.scopeSelection`: `auto_by_openclaw`。\r\n- `answerPolicy.knowledgeBaseFirst`: `true`，表示事实性回答必须优先基于团队 KB。`answerPolicy.allowNonKbSupplementWhenInsufficient=true` 时，知识库证据不足可以在明确说明后补充非 KB 或附件分析。\r\n- `answerPolicy.writeHighValueAnswerToQa`: 是否允许高价值问答写入 `qa/`。\r\n- `payloadFile`、`resultFile`、`sharedDir`: 后端共享目录路径。\r\n\r\n环境变量包括 `GITEA_URL`、`GITEA_BOT_TOKEN`、`GITEA_BOT_USERNAME`、`GITEA_ORG`、`TEAM_KB_REPO`、`OPENCLAW_SHARED_DIR`。\r\n\r\n## 执行流程\r\n\r\n必须使用四段式流程，让“选哪些页面作为参考”由 OpenClaw 完成，而不是由脚本用关键词配对决定。\n\n上下文预算必须保守执行。`prepare`/`fetch` 命令会把完整 JSON 写入文件，终端只输出摘要；OpenClaw 应阅读文件路径指向的 JSON，不要把完整 context/evidence 粘贴回聊天。页面选择应坚持“够用即可”：通常选择 1-4 个最关键 KB 页面，最多不得超过 `context.analysisLimits.maxSelectedPages`。如果少量证据已经能回答，不要扩大读取范围；如果证据不足，按不足规则回答，而不是继续尝试读取大量页面。\n\n所有中间 JSON 文件必须是严格合法 JSON。写 `page-selection.json` 和 `answer.json` 时不要加入 Markdown 代码围栏、注释、尾随逗号或半截文本；文件写好后再运行下一步脚本。\n\n1. 运行准备脚本：\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\n准备脚本会读取 `catalog.json`、`index.md`、页面元数据、少量探索卡片和附件文本预览，输出 OpenClaw 可读的查询规划上下文。命令行只返回摘要，完整内容在 `<context.json>` 中。`starterPageCards` 只是帮助 OpenClaw 快速了解可能相关的页面，不是最终证据，也不能直接作为引用依据。脚本不会生成答案，也不会决定最终参考页面。\n\n2. OpenClaw 阅读 `<context.json>`，根据用户问题、目录、索引、页面卡片、预算限制和附件上下文，思考并生成 `<page-selection.json>`。OpenClaw 可以选择任意可见 catalog 页面，不限于 `starterPageCards`，但应选择最小充分集合。\n\r\n`page-selection.json` 示例：\r\n\r\n```json\r\n{\r\n  \"rationale\": \"为什么这些页面需要被读取作为证据\",\r\n  \"selectedPages\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"reason\": \"用于确认项目边界和当前实现\",\r\n      \"expectedUse\": \"回答功能进度和边界\"\r\n    }\r\n  ],\r\n  \"unresolvedQuestions\": []\r\n}\r\n```\r\n\r\n3. 按 OpenClaw 选择读取证据页：\r\n\r\n```bash\r\npython3 scripts/run_task.py fetch --input <payload.json> --context <context.json> --selection <page-selection.json> --evidence-output <evidence.json>\r\n```\r\n\r\n`fetch` 只负责校验路径、读取 OpenClaw 选择的 KB 页面、解析 frontmatter `sources[]`，并输出 `<evidence.json>`。命令行只返回证据页摘要，完整内容在 `<evidence.json>` 中。它不做答案判断，也不替 OpenClaw 增删参考范围。\n\r\n4. OpenClaw 阅读 `<context.json>` 和 `<evidence.json>`，进行知识库问答，生成 `<answer.json>`。`answer.json` 必须符合“OpenClaw 输出格式”。答案中的 `sources[]` 只能引用 `<evidence.json>` 中实际读取到的稳定 KB 页面；临时附件不能作为稳定 KB 来源。\r\n\r\n5. 运行应用脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --evidence <evidence.json> --answer <answer.json>\r\n```\r\n\r\n应用脚本会校验答案、确保结尾有参考来源、必要时写入 `qa/` 并更新 `catalog.json` 和 `index.md`，最后把后端 result JSON 写入 payload 指定的 `resultFile`。\r\n\r\n6. 最终回复后端：\r\n\r\n```json\r\n{\"success\": true, \"resultFile\": \"<result.json>\"}\r\n```\r\n\r\n## 回答规则\r\n\r\nOpenClaw 必须先判断团队 KB 证据是否足以回答问题。证据充分性判断基于 OpenClaw 自己选择并通过 `fetch` 读取到的稳定 KB 页面。\r\n\r\n如果 KB 证据足够：先直接回答结论，再给出必要解释、比较、步骤或建议。回答必须以中文为主，除非用户明确要求其他语言。\r\n\r\n如果 KB 证据不足：回答开头必须明确说明“知识库内容无法回答这个问题”或等价表达，然后说明缺少哪些证据。可以在下方补充一般性回答或基于附件的临时分析，但必须标注“以下为非知识库结论/本轮参考附件推断”。\r\n\r\n附件只能帮助理解问题、补充本轮上下文或做临时对比；不要把临时附件当作长期 KB 来源，不要因为附件出现就写普通知识页。若答案主要依赖附件且缺少稳定 KB 证据，通常不要沉淀为 `qa/`。\r\n\r\n回答正文不强制套固定模板。可以按用户问题自然组织成结论、解释、对比、步骤、表格或建议；但不要为了模板牺牲可读性。\r\n\r\n答案结尾必须包含“参考来源”小节，这是唯一强制模板。稳定来源应优先列出 KB 页面路径和标题；如果证据页带有 `sources[]`，同时列出对应源文件、归档路径、仓库 URL、commit 或其他可追溯线索。若没有可引用 KB 页面，写明“知识库中未找到可支撑本问题的页面”。\r\n\r\n## 高价值问答沉淀\r\n\r\n高价值问答不是“回答得长”或“用户问了一个问题”就沉淀，而是要成为团队以后可复用的知识入口。OpenClaw 必须先做结构化评估，再决定是否把 `highValue` 或 `qa.write` 设为 `true`。\r\n\r\n硬性门槛：\r\n\r\n- `knowledgeSufficient=true`，且答案有稳定 KB 页面支撑。\r\n- 主要依据不是本轮临时附件；附件只能帮助理解问题或补充临时上下文。\r\n- 问题不是一次性操作、临时状态查询、简单事实定位、格式转换、寒暄、泛泛建议或纯外部常识问答。\r\n- 结论足够稳定，后续成员在相同或相近问题下可以直接复用。\r\n\r\n正向信号：\r\n\r\n- 跨多个稳定 KB 页面综合，或者把一个重要单页中的规则/边界整理成可复用的规范答案。\r\n- 回答澄清了项目架构、功能边界、资料源处理规则、实验结论、技术选型、风险判断或工作流程。\r\n- 答案包含明确判断、适用条件、例外情况和后续行动，而不是只摘录原文。\r\n- 该问题预计会反复出现，沉淀后能减少后续检索和解释成本。\r\n\r\n建议采用 0-5 分评估：`reuseValue`、`synthesisDepth`、`evidenceQuality`、`stability`、`actionability` 各 0/1 分。总分至少 4 分，且通过全部硬性门槛时，才允许写入 `qa/`。\r\n\r\nOpenClaw 必须在 `answer.json` 中给出 `qaEvaluation`，说明为什么是或不是高价值问答。apply 脚本只执行确定性拦截：缺少评估、证据不足、无稳定来源、附件驱动、临时/一次性、分数不足时，即使 OpenClaw 请求写入，也不沉淀。\r\n\r\n`qa/` 页面应包含：问题、可复用回答、证据页面、适用场景、更新时间。QA 页面只应引用稳定 KB 页面作为来源；临时附件不能作为唯一长期证据。\r\n\r\n## OpenClaw 输出格式\r\n\r\n`answer.json` 是 OpenClaw 生成、apply 脚本读取的文件：\r\n\r\n```json\r\n{\r\n  \"answer\": \"完整回答。正文不需要固定模板；结尾可以已包含参考来源，apply 会补齐缺失的参考来源。\",\r\n  \"knowledgeSufficient\": true,\r\n  \"sources\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"title\": \"Example\",\r\n      \"type\": \"project\",\r\n      \"snippet\": \"可选引用片段\",\r\n      \"sourceIds\": [],\r\n      \"sourceTraces\": [\r\n        {\r\n          \"sourceId\": 1,\r\n          \"sourceType\": \"local_folder\",\r\n          \"title\": \"原始资料标题\",\r\n          \"fileName\": \"example.pdf\",\r\n          \"archivedPath\": \"source_files/local_folder/example.pdf\",\r\n          \"url\": \"\",\r\n          \"commitHash\": \"\"\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"usedAttachments\": [\r\n    {\r\n      \"attachmentId\": 1,\r\n      \"fileName\": \"context.docx\",\r\n      \"role\": \"query_reference\"\r\n    }\r\n  ],\r\n  \"highValue\": false,\r\n  \"qaEvaluation\": {\r\n    \"reuseValue\": 0,\r\n    \"synthesisDepth\": 0,\r\n    \"evidenceQuality\": 0,\r\n    \"stability\": 0,\r\n    \"actionability\": 0,\r\n    \"attachmentDriven\": false,\r\n    \"ephemeral\": false,\r\n    \"reason\": \"为什么适合或不适合沉淀\"\r\n  },\r\n  \"qa\": {\r\n    \"write\": false,\r\n    \"path\": \"qa/example.md\",\r\n    \"title\": \"可复用问答标题\",\r\n    \"content\": \"可选；不填时 apply 根据 answer 自动生成\"\r\n  },\r\n  \"errors\": []\r\n}\r\n```\r\n\r\n后端最终读取 `resultFile` 中的字段：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"answer\": \"...\",\r\n  \"sources\": [],\r\n  \"createdQaPath\": \"qa/example.md\",\r\n  \"processedSources\": [\"team-kb\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\"\r\n}\r\n```\n\nFile v1.0.5:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.5\",\n  \"publishedAt\": 1783537387966\n}\n\nFile v1.0.5:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from a team Gitea-backed knowledge base with OpenClaw-led evidence selection, optional reference attachments, stable citations, and optional high-value Q&A persistence. <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 answer team Research KB questions by preparing bounded context, fetching selected KB evidence, composing cited answers, and optionally saving reusable high-value Q&A pages. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill handles a repository token, network target, local attachment paths, and result paths with weak scoping. <br>\nMitigation: Install only where the backend controls payload generation, validates attachment/result/shared-directory paths, and pins the allowed Gitea host and repository outside user-controlled payload data. <br>\nRisk: Optional Q&A persistence can write generated content back to the knowledge base. <br>\nMitigation: Use a narrowly scoped Gitea bot token and review Q&A persistence policy before enabling repository write access. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n- [Publisher profile](https://clawhub.ai/user/myd2002) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [Text, Markdown, JSON, Shell commands, Configuration, Guidance] <br>\n**Output Format:** [Markdown answers with stable source lists, plus JSON context, evidence, answer, and result files] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [The apply step writes resultFile JSON containing the answer, sources, optional createdQaPath, page changes, errors, and commitId.] <br>\n\n## Skill Version(s): <br>\n1.0.5 (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.5: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\n\nFile v1.0.5:requirements.txt\n\n# kb_query uses only the Python 3 standard library for deterministic prepare/apply helpers.\n\nArchive v1.0.4: 15 files, 23027 bytes\n\nFiles: _meta.json (127b), env-example.txt (159b), main.js (219b), requirements.txt (96b), scripts/catalog.py (5671b), scripts/gitea_api.py (3458b), scripts/qa_writer.py (15683b), scripts/query_context.py (17531b), scripts/run_task.py (4151b), scripts/task_io.py (1217b), scripts/text_extractors.py (2001b), scripts/utils.py (3138b), setup.sh (119b), skill-card.md (2664b), SKILL.md (9804b)\n\nFile v1.0.4:SKILL.md\n\n---\r\nname: kb_query\r\ndescription: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\r\n---\r\n\r\n# kb_query\r\n\r\n## 职责边界\r\n\r\n`kb_query` 只负责“对话”页面的知识库查询。用户输入可以是纯文字，也可以带附件；附件一律是本轮参考材料，用于辅助理解问题、补充上下文或做临时对比，稳定来源仍以知识库证据页为准。\r\n\r\n本 skill 不负责登录、权限、会话历史、文件上传、任务调度或资料源入库。Java 后端负责这些系统动作。OpenClaw 负责理解用户问题、判断需要参考哪些 KB 页面、综合证据、生成回答、判断证据是否充分，以及判断是否值得沉淀为 `qa/` 页面。Python 脚本只做确定性动作：读取 catalog/index 和探索卡片、按 OpenClaw 选择读取证据页面、抽取附件文本预览、校验 OpenClaw 输出、可选写入 `qa/`、维护 `catalog.json`/`index.md`、写出后端 result JSON。\r\n\r\n不要提供脚本兜底的抽取式简化回答。没有真实 OpenClaw 理解时，任务应失败或返回明确错误，而不是用脚本假装完成问答。\r\n\r\n## 输入约定\r\n\r\n后端 payload 通常包含：\r\n\r\n- `taskId`: 后端生成的查询任务 ID，当前格式为 `query-<conversationId>-<messageId>`，用于共享 payload/result 文件和 OpenClaw session key。\r\n- `skill`: `kb_query`。\r\n- `question`: 用户问题。\r\n- `conversationId`: 当前会话 ID。\r\n- `messageId`: 用户消息 ID。\r\n- `attachments[]`: 本轮参考附件，字段包括 `attachmentId`、`fileName`、`mimeType`、`storagePath`、`sha256`、`size`、`temporary=true`。\r\n- `answerPolicy.scopeSelection`: `auto_by_openclaw`。\r\n- `answerPolicy.knowledgeBaseFirst`: `true`，表示事实性回答必须优先基于团队 KB。`answerPolicy.allowNonKbSupplementWhenInsufficient=true` 时，知识库证据不足可以在明确说明后补充非 KB 或附件分析。\r\n- `answerPolicy.writeHighValueAnswerToQa`: 是否允许高价值问答写入 `qa/`。\r\n- `payloadFile`、`resultFile`、`sharedDir`: 后端共享目录路径。\r\n\r\n环境变量包括 `GITEA_URL`、`GITEA_BOT_TOKEN`、`GITEA_BOT_USERNAME`、`GITEA_ORG`、`TEAM_KB_REPO`、`OPENCLAW_SHARED_DIR`。\r\n\r\n## 执行流程\r\n\r\n必须使用四段式流程，让“选哪些页面作为参考”由 OpenClaw 完成，而不是由脚本用关键词配对决定。\r\n\r\n1. 运行准备脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\n准备脚本会读取 `catalog.json`、`index.md`、页面元数据、少量探索卡片和附件文本预览，输出 OpenClaw 可读的查询规划上下文。`starterPageCards` 只是帮助 OpenClaw 快速了解可能相关的页面，不是最终证据，也不能直接作为引用依据。脚本不会生成答案，也不会决定最终参考页面。\r\n\r\n2. OpenClaw 阅读 `<context.json>`，根据用户问题、目录、索引、页面卡片和附件上下文，思考并生成 `<page-selection.json>`。OpenClaw 可以选择任意可见 catalog 页面，不限于 `starterPageCards`。\r\n\r\n`page-selection.json` 示例：\r\n\r\n```json\r\n{\r\n  \"rationale\": \"为什么这些页面需要被读取作为证据\",\r\n  \"selectedPages\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"reason\": \"用于确认项目边界和当前实现\",\r\n      \"expectedUse\": \"回答功能进度和边界\"\r\n    }\r\n  ],\r\n  \"unresolvedQuestions\": []\r\n}\r\n```\r\n\r\n3. 按 OpenClaw 选择读取证据页：\r\n\r\n```bash\r\npython3 scripts/run_task.py fetch --input <payload.json> --context <context.json> --selection <page-selection.json> --evidence-output <evidence.json>\r\n```\r\n\r\n`fetch` 只负责校验路径、读取 OpenClaw 选择的 KB 页面、解析 frontmatter `sources[]`，并输出 `<evidence.json>`。它不做答案判断，也不替 OpenClaw 增删参考范围。\r\n\r\n4. OpenClaw 阅读 `<context.json>` 和 `<evidence.json>`，进行知识库问答，生成 `<answer.json>`。`answer.json` 必须符合“OpenClaw 输出格式”。答案中的 `sources[]` 只能引用 `<evidence.json>` 中实际读取到的稳定 KB 页面；临时附件不能作为稳定 KB 来源。\r\n\r\n5. 运行应用脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --evidence <evidence.json> --answer <answer.json>\r\n```\r\n\r\n应用脚本会校验答案、确保结尾有参考来源、必要时写入 `qa/` 并更新 `catalog.json` 和 `index.md`，最后把后端 result JSON 写入 payload 指定的 `resultFile`。\r\n\r\n6. 最终回复后端：\r\n\r\n```json\r\n{\"success\": true, \"resultFile\": \"<result.json>\"}\r\n```\r\n\r\n## 回答规则\r\n\r\nOpenClaw 必须先判断团队 KB 证据是否足以回答问题。证据充分性判断基于 OpenClaw 自己选择并通过 `fetch` 读取到的稳定 KB 页面。\r\n\r\n如果 KB 证据足够：先直接回答结论，再给出必要解释、比较、步骤或建议。回答必须以中文为主，除非用户明确要求其他语言。\r\n\r\n如果 KB 证据不足：回答开头必须明确说明“知识库内容无法回答这个问题”或等价表达，然后说明缺少哪些证据。可以在下方补充一般性回答或基于附件的临时分析，但必须标注“以下为非知识库结论/本轮参考附件推断”。\r\n\r\n附件只能帮助理解问题、补充本轮上下文或做临时对比；不要把临时附件当作长期 KB 来源，不要因为附件出现就写普通知识页。若答案主要依赖附件且缺少稳定 KB 证据，通常不要沉淀为 `qa/`。\r\n\r\n回答正文不强制套固定模板。可以按用户问题自然组织成结论、解释、对比、步骤、表格或建议；但不要为了模板牺牲可读性。\r\n\r\n答案结尾必须包含“参考来源”小节，这是唯一强制模板。稳定来源应优先列出 KB 页面路径和标题；如果证据页带有 `sources[]`，同时列出对应源文件、归档路径、仓库 URL、commit 或其他可追溯线索。若没有可引用 KB 页面，写明“知识库中未找到可支撑本问题的页面”。\r\n\r\n## 高价值问答沉淀\r\n\r\n高价值问答不是“回答得长”或“用户问了一个问题”就沉淀，而是要成为团队以后可复用的知识入口。OpenClaw 必须先做结构化评估，再决定是否把 `highValue` 或 `qa.write` 设为 `true`。\r\n\r\n硬性门槛：\r\n\r\n- `knowledgeSufficient=true`，且答案有稳定 KB 页面支撑。\r\n- 主要依据不是本轮临时附件；附件只能帮助理解问题或补充临时上下文。\r\n- 问题不是一次性操作、临时状态查询、简单事实定位、格式转换、寒暄、泛泛建议或纯外部常识问答。\r\n- 结论足够稳定，后续成员在相同或相近问题下可以直接复用。\r\n\r\n正向信号：\r\n\r\n- 跨多个稳定 KB 页面综合，或者把一个重要单页中的规则/边界整理成可复用的规范答案。\r\n- 回答澄清了项目架构、功能边界、资料源处理规则、实验结论、技术选型、风险判断或工作流程。\r\n- 答案包含明确判断、适用条件、例外情况和后续行动，而不是只摘录原文。\r\n- 该问题预计会反复出现，沉淀后能减少后续检索和解释成本。\r\n\r\n建议采用 0-5 分评估：`reuseValue`、`synthesisDepth`、`evidenceQuality`、`stability`、`actionability` 各 0/1 分。总分至少 4 分，且通过全部硬性门槛时，才允许写入 `qa/`。\r\n\r\nOpenClaw 必须在 `answer.json` 中给出 `qaEvaluation`，说明为什么是或不是高价值问答。apply 脚本只执行确定性拦截：缺少评估、证据不足、无稳定来源、附件驱动、临时/一次性、分数不足时，即使 OpenClaw 请求写入，也不沉淀。\r\n\r\n`qa/` 页面应包含：问题、可复用回答、证据页面、适用场景、更新时间。QA 页面只应引用稳定 KB 页面作为来源；临时附件不能作为唯一长期证据。\r\n\r\n## OpenClaw 输出格式\r\n\r\n`answer.json` 是 OpenClaw 生成、apply 脚本读取的文件：\r\n\r\n```json\r\n{\r\n  \"answer\": \"完整回答。正文不需要固定模板；结尾可以已包含参考来源，apply 会补齐缺失的参考来源。\",\r\n  \"knowledgeSufficient\": true,\r\n  \"sources\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"title\": \"Example\",\r\n      \"type\": \"project\",\r\n      \"snippet\": \"可选引用片段\",\r\n      \"sourceIds\": [],\r\n      \"sourceTraces\": [\r\n        {\r\n          \"sourceId\": 1,\r\n          \"sourceType\": \"local_folder\",\r\n          \"title\": \"原始资料标题\",\r\n          \"fileName\": \"example.pdf\",\r\n          \"archivedPath\": \"source_files/local_folder/example.pdf\",\r\n          \"url\": \"\",\r\n          \"commitHash\": \"\"\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"usedAttachments\": [\r\n    {\r\n      \"attachmentId\": 1,\r\n      \"fileName\": \"context.docx\",\r\n      \"role\": \"query_reference\"\r\n    }\r\n  ],\r\n  \"highValue\": false,\r\n  \"qaEvaluation\": {\r\n    \"reuseValue\": 0,\r\n    \"synthesisDepth\": 0,\r\n    \"evidenceQuality\": 0,\r\n    \"stability\": 0,\r\n    \"actionability\": 0,\r\n    \"attachmentDriven\": false,\r\n    \"ephemeral\": false,\r\n    \"reason\": \"为什么适合或不适合沉淀\"\r\n  },\r\n  \"qa\": {\r\n    \"write\": false,\r\n    \"path\": \"qa/example.md\",\r\n    \"title\": \"可复用问答标题\",\r\n    \"content\": \"可选；不填时 apply 根据 answer 自动生成\"\r\n  },\r\n  \"errors\": []\r\n}\r\n```\r\n\r\n后端最终读取 `resultFile` 中的字段：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"answer\": \"...\",\r\n  \"sources\": [],\r\n  \"createdQaPath\": \"qa/example.md\",\r\n  \"processedSources\": [\"team-kb\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\"\r\n}\r\n```\n\nFile v1.0.4:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.4\",\n  \"publishedAt\": 1783529830688\n}\n\nFile v1.0.4:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. <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 team knowledge-base users use this skill to answer Research KB questions from a Gitea-backed team knowledge base, with optional temporary attachment context and stable KB citations. It can also persist high-value reusable Q&A pages when policy allows and stable KB evidence supports the answer. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill uses expected Gitea access for reading KB content and optionally writing reusable Q&A pages, catalog.json, and index.md. <br>\nMitigation: Run it with a Gitea bot token limited to the minimum repository permissions needed, and enable Q&A persistence only for teams that want the skill to update the configured KB repo. <br>\nRisk: Temporary attachment previews could be mistaken for stable knowledge-base sources. <br>\nMitigation: Use attachments only as per-query reference context; cite and persist only fetched stable KB pages returned in the evidence bundle. <br>\nRisk: Payload result paths and attachment storage paths can affect which files the helper reads or writes. <br>\nMitigation: Deploy only where the backend constrains attachment storagePath and result paths to the shared workspace. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n- [Publisher profile](https://clawhub.ai/user/myd2002) <br>\n- [Skill definition](artifact/SKILL.md) <br>\n- [Skill metadata](artifact/_meta.json) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [Text, Markdown, JSON, Shell commands, Configuration] <br>\n**Output Format:** [Markdown answers with stable source citations and JSON result files] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [May write QA markdown pages, catalog.json, and index.md when optional high-value Q&A persistence is enabled and evidence gates pass.] <br>\n\n## Skill Version(s): <br>\n1.0.4 (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.4: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\n\nFile v1.0.4:requirements.txt\n\n# kb_query uses only the Python 3 standard library for deterministic prepare/apply helpers.\n\nArchive v1.0.3: 15 files, 22549 bytes\n\nFiles: _meta.json (127b), env-example.txt (159b), main.js (219b), requirements.txt (96b), scripts/catalog.py (4078b), scripts/gitea_api.py (3458b), scripts/qa_writer.py (15683b), scripts/query_context.py (17322b), scripts/run_task.py (4151b), scripts/task_io.py (1217b), scripts/text_extractors.py (2001b), scripts/utils.py (3138b), setup.sh (119b), skill-card.md (2288b), SKILL.md (9804b)\n\nFile v1.0.3:SKILL.md\n\n---\r\nname: kb_query\r\ndescription: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\r\n---\r\n\r\n# kb_query\r\n\r\n## 职责边界\r\n\r\n`kb_query` 只负责“对话”页面的知识库查询。用户输入可以是纯文字，也可以带附件；附件一律是本轮参考材料，用于辅助理解问题、补充上下文或做临时对比，稳定来源仍以知识库证据页为准。\r\n\r\n本 skill 不负责登录、权限、会话历史、文件上传、任务调度或资料源入库。Java 后端负责这些系统动作。OpenClaw 负责理解用户问题、判断需要参考哪些 KB 页面、综合证据、生成回答、判断证据是否充分，以及判断是否值得沉淀为 `qa/` 页面。Python 脚本只做确定性动作：读取 catalog/index 和探索卡片、按 OpenClaw 选择读取证据页面、抽取附件文本预览、校验 OpenClaw 输出、可选写入 `qa/`、维护 `catalog.json`/`index.md`、写出后端 result JSON。\r\n\r\n不要提供脚本兜底的抽取式简化回答。没有真实 OpenClaw 理解时，任务应失败或返回明确错误，而不是用脚本假装完成问答。\r\n\r\n## 输入约定\r\n\r\n后端 payload 通常包含：\r\n\r\n- `taskId`: 后端生成的查询任务 ID，当前格式为 `query-<conversationId>-<messageId>`，用于共享 payload/result 文件和 OpenClaw session key。\r\n- `skill`: `kb_query`。\r\n- `question`: 用户问题。\r\n- `conversationId`: 当前会话 ID。\r\n- `messageId`: 用户消息 ID。\r\n- `attachments[]`: 本轮参考附件，字段包括 `attachmentId`、`fileName`、`mimeType`、`storagePath`、`sha256`、`size`、`temporary=true`。\r\n- `answerPolicy.scopeSelection`: `auto_by_openclaw`。\r\n- `answerPolicy.knowledgeBaseFirst`: `true`，表示事实性回答必须优先基于团队 KB。`answerPolicy.allowNonKbSupplementWhenInsufficient=true` 时，知识库证据不足可以在明确说明后补充非 KB 或附件分析。\r\n- `answerPolicy.writeHighValueAnswerToQa`: 是否允许高价值问答写入 `qa/`。\r\n- `payloadFile`、`resultFile`、`sharedDir`: 后端共享目录路径。\r\n\r\n环境变量包括 `GITEA_URL`、`GITEA_BOT_TOKEN`、`GITEA_BOT_USERNAME`、`GITEA_ORG`、`TEAM_KB_REPO`、`OPENCLAW_SHARED_DIR`。\r\n\r\n## 执行流程\r\n\r\n必须使用四段式流程，让“选哪些页面作为参考”由 OpenClaw 完成，而不是由脚本用关键词配对决定。\r\n\r\n1. 运行准备脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\n准备脚本会读取 `catalog.json`、`index.md`、页面元数据、少量探索卡片和附件文本预览，输出 OpenClaw 可读的查询规划上下文。`starterPageCards` 只是帮助 OpenClaw 快速了解可能相关的页面，不是最终证据，也不能直接作为引用依据。脚本不会生成答案，也不会决定最终参考页面。\r\n\r\n2. OpenClaw 阅读 `<context.json>`，根据用户问题、目录、索引、页面卡片和附件上下文，思考并生成 `<page-selection.json>`。OpenClaw 可以选择任意可见 catalog 页面，不限于 `starterPageCards`。\r\n\r\n`page-selection.json` 示例：\r\n\r\n```json\r\n{\r\n  \"rationale\": \"为什么这些页面需要被读取作为证据\",\r\n  \"selectedPages\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"reason\": \"用于确认项目边界和当前实现\",\r\n      \"expectedUse\": \"回答功能进度和边界\"\r\n    }\r\n  ],\r\n  \"unresolvedQuestions\": []\r\n}\r\n```\r\n\r\n3. 按 OpenClaw 选择读取证据页：\r\n\r\n```bash\r\npython3 scripts/run_task.py fetch --input <payload.json> --context <context.json> --selection <page-selection.json> --evidence-output <evidence.json>\r\n```\r\n\r\n`fetch` 只负责校验路径、读取 OpenClaw 选择的 KB 页面、解析 frontmatter `sources[]`，并输出 `<evidence.json>`。它不做答案判断，也不替 OpenClaw 增删参考范围。\r\n\r\n4. OpenClaw 阅读 `<context.json>` 和 `<evidence.json>`，进行知识库问答，生成 `<answer.json>`。`answer.json` 必须符合“OpenClaw 输出格式”。答案中的 `sources[]` 只能引用 `<evidence.json>` 中实际读取到的稳定 KB 页面；临时附件不能作为稳定 KB 来源。\r\n\r\n5. 运行应用脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --evidence <evidence.json> --answer <answer.json>\r\n```\r\n\r\n应用脚本会校验答案、确保结尾有参考来源、必要时写入 `qa/` 并更新 `catalog.json` 和 `index.md`，最后把后端 result JSON 写入 payload 指定的 `resultFile`。\r\n\r\n6. 最终回复后端：\r\n\r\n```json\r\n{\"success\": true, \"resultFile\": \"<result.json>\"}\r\n```\r\n\r\n## 回答规则\r\n\r\nOpenClaw 必须先判断团队 KB 证据是否足以回答问题。证据充分性判断基于 OpenClaw 自己选择并通过 `fetch` 读取到的稳定 KB 页面。\r\n\r\n如果 KB 证据足够：先直接回答结论，再给出必要解释、比较、步骤或建议。回答必须以中文为主，除非用户明确要求其他语言。\r\n\r\n如果 KB 证据不足：回答开头必须明确说明“知识库内容无法回答这个问题”或等价表达，然后说明缺少哪些证据。可以在下方补充一般性回答或基于附件的临时分析，但必须标注“以下为非知识库结论/本轮参考附件推断”。\r\n\r\n附件只能帮助理解问题、补充本轮上下文或做临时对比；不要把临时附件当作长期 KB 来源，不要因为附件出现就写普通知识页。若答案主要依赖附件且缺少稳定 KB 证据，通常不要沉淀为 `qa/`。\r\n\r\n回答正文不强制套固定模板。可以按用户问题自然组织成结论、解释、对比、步骤、表格或建议；但不要为了模板牺牲可读性。\r\n\r\n答案结尾必须包含“参考来源”小节，这是唯一强制模板。稳定来源应优先列出 KB 页面路径和标题；如果证据页带有 `sources[]`，同时列出对应源文件、归档路径、仓库 URL、commit 或其他可追溯线索。若没有可引用 KB 页面，写明“知识库中未找到可支撑本问题的页面”。\r\n\r\n## 高价值问答沉淀\r\n\r\n高价值问答不是“回答得长”或“用户问了一个问题”就沉淀，而是要成为团队以后可复用的知识入口。OpenClaw 必须先做结构化评估，再决定是否把 `highValue` 或 `qa.write` 设为 `true`。\r\n\r\n硬性门槛：\r\n\r\n- `knowledgeSufficient=true`，且答案有稳定 KB 页面支撑。\r\n- 主要依据不是本轮临时附件；附件只能帮助理解问题或补充临时上下文。\r\n- 问题不是一次性操作、临时状态查询、简单事实定位、格式转换、寒暄、泛泛建议或纯外部常识问答。\r\n- 结论足够稳定，后续成员在相同或相近问题下可以直接复用。\r\n\r\n正向信号：\r\n\r\n- 跨多个稳定 KB 页面综合，或者把一个重要单页中的规则/边界整理成可复用的规范答案。\r\n- 回答澄清了项目架构、功能边界、资料源处理规则、实验结论、技术选型、风险判断或工作流程。\r\n- 答案包含明确判断、适用条件、例外情况和后续行动，而不是只摘录原文。\r\n- 该问题预计会反复出现，沉淀后能减少后续检索和解释成本。\r\n\r\n建议采用 0-5 分评估：`reuseValue`、`synthesisDepth`、`evidenceQuality`、`stability`、`actionability` 各 0/1 分。总分至少 4 分，且通过全部硬性门槛时，才允许写入 `qa/`。\r\n\r\nOpenClaw 必须在 `answer.json` 中给出 `qaEvaluation`，说明为什么是或不是高价值问答。apply 脚本只执行确定性拦截：缺少评估、证据不足、无稳定来源、附件驱动、临时/一次性、分数不足时，即使 OpenClaw 请求写入，也不沉淀。\r\n\r\n`qa/` 页面应包含：问题、可复用回答、证据页面、适用场景、更新时间。QA 页面只应引用稳定 KB 页面作为来源；临时附件不能作为唯一长期证据。\r\n\r\n## OpenClaw 输出格式\r\n\r\n`answer.json` 是 OpenClaw 生成、apply 脚本读取的文件：\r\n\r\n```json\r\n{\r\n  \"answer\": \"完整回答。正文不需要固定模板；结尾可以已包含参考来源，apply 会补齐缺失的参考来源。\",\r\n  \"knowledgeSufficient\": true,\r\n  \"sources\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"title\": \"Example\",\r\n      \"type\": \"project\",\r\n      \"snippet\": \"可选引用片段\",\r\n      \"sourceIds\": [],\r\n      \"sourceTraces\": [\r\n        {\r\n          \"sourceId\": 1,\r\n          \"sourceType\": \"local_folder\",\r\n          \"title\": \"原始资料标题\",\r\n          \"fileName\": \"example.pdf\",\r\n          \"archivedPath\": \"source_files/local_folder/example.pdf\",\r\n          \"url\": \"\",\r\n          \"commitHash\": \"\"\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"usedAttachments\": [\r\n    {\r\n      \"attachmentId\": 1,\r\n      \"fileName\": \"context.docx\",\r\n      \"role\": \"query_reference\"\r\n    }\r\n  ],\r\n  \"highValue\": false,\r\n  \"qaEvaluation\": {\r\n    \"reuseValue\": 0,\r\n    \"synthesisDepth\": 0,\r\n    \"evidenceQuality\": 0,\r\n    \"stability\": 0,\r\n    \"actionability\": 0,\r\n    \"attachmentDriven\": false,\r\n    \"ephemeral\": false,\r\n    \"reason\": \"为什么适合或不适合沉淀\"\r\n  },\r\n  \"qa\": {\r\n    \"write\": false,\r\n    \"path\": \"qa/example.md\",\r\n    \"title\": \"可复用问答标题\",\r\n    \"content\": \"可选；不填时 apply 根据 answer 自动生成\"\r\n  },\r\n  \"errors\": []\r\n}\r\n```\r\n\r\n后端最终读取 `resultFile` 中的字段：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"answer\": \"...\",\r\n  \"sources\": [],\r\n  \"createdQaPath\": \"qa/example.md\",\r\n  \"processedSources\": [\"team-kb\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\"\r\n}\r\n```\n\nFile v1.0.3:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.3\",\n  \"publishedAt\": 1783506671034\n}\n\nFile v1.0.3:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. <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 teams use this skill to answer questions against a Gitea-backed team knowledge base, select supporting KB pages, cite stable evidence, and optionally preserve reusable high-value answers as Q&A pages. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: A broad Gitea bot token could allow the skill to read or update repositories beyond the intended knowledge base. <br>\nMitigation: Scope the bot token to the intended KB repository and use a dedicated bot identity for this workflow. <br>\nRisk: Optional Q&A persistence can change qa/ pages, catalog.json, and index.md. <br>\nMitigation: Enable persistence only for environments that want reusable answer capture, and review resulting page and index changes before relying on them. <br>\nRisk: Reference attachments are temporary context and may not be suitable as stable knowledge-base sources. <br>\nMitigation: Use trusted shared upload paths and keep final citations grounded in fetched KB pages rather than temporary attachments. <br>\n\n\n## Reference(s): <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [Text, Markdown, JSON, Shell commands, Configuration, Guidance] <br>\n**Output Format:** [Markdown-style answer text, JSON context/evidence/result files, and shell commands for prepare, fetch, and apply steps] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Can optionally write reusable Q&A Markdown and update catalog/index files when enabled.] <br>\n\n## Skill Version(s): <br>\n1.0.3 (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.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\n\nFile v1.0.3:requirements.txt\n\n# kb_query uses only the Python 3 standard library for deterministic prepare/apply helpers.\n\nArchive v1.0.2: 15 files, 22596 bytes\n\nFiles: _meta.json (127b), env-example.txt (159b), main.js (219b), requirements.txt (96b), scripts/catalog.py (4078b), scripts/gitea_api.py (3458b), scripts/qa_writer.py (15683b), scripts/query_context.py (17322b), scripts/run_task.py (4151b), scripts/task_io.py (1217b), scripts/text_extractors.py (2001b), scripts/utils.py (3138b), setup.sh (119b), skill-card.md (2478b), SKILL.md (9804b)\n\nFile v1.0.2:SKILL.md\n\n---\r\nname: kb_query\r\ndescription: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\r\n---\r\n\r\n# kb_query\r\n\r\n## 职责边界\r\n\r\n`kb_query` 只负责“对话”页面的知识库查询。用户输入可以是纯文字，也可以带附件；附件一律是本轮参考材料，用于辅助理解问题、补充上下文或做临时对比，稳定来源仍以知识库证据页为准。\r\n\r\n本 skill 不负责登录、权限、会话历史、文件上传、任务调度或资料源入库。Java 后端负责这些系统动作。OpenClaw 负责理解用户问题、判断需要参考哪些 KB 页面、综合证据、生成回答、判断证据是否充分，以及判断是否值得沉淀为 `qa/` 页面。Python 脚本只做确定性动作：读取 catalog/index 和探索卡片、按 OpenClaw 选择读取证据页面、抽取附件文本预览、校验 OpenClaw 输出、可选写入 `qa/`、维护 `catalog.json`/`index.md`、写出后端 result JSON。\r\n\r\n不要提供脚本兜底的抽取式简化回答。没有真实 OpenClaw 理解时，任务应失败或返回明确错误，而不是用脚本假装完成问答。\r\n\r\n## 输入约定\r\n\r\n后端 payload 通常包含：\r\n\r\n- `taskId`: 后端生成的查询任务 ID，当前格式为 `query-<conversationId>-<messageId>`，用于共享 payload/result 文件和 OpenClaw session key。\r\n- `skill`: `kb_query`。\r\n- `question`: 用户问题。\r\n- `conversationId`: 当前会话 ID。\r\n- `messageId`: 用户消息 ID。\r\n- `attachments[]`: 本轮参考附件，字段包括 `attachmentId`、`fileName`、`mimeType`、`storagePath`、`sha256`、`size`、`temporary=true`。\r\n- `answerPolicy.scopeSelection`: `auto_by_openclaw`。\r\n- `answerPolicy.knowledgeBaseFirst`: `true`，表示事实性回答必须优先基于团队 KB。`answerPolicy.allowNonKbSupplementWhenInsufficient=true` 时，知识库证据不足可以在明确说明后补充非 KB 或附件分析。\r\n- `answerPolicy.writeHighValueAnswerToQa`: 是否允许高价值问答写入 `qa/`。\r\n- `payloadFile`、`resultFile`、`sharedDir`: 后端共享目录路径。\r\n\r\n环境变量包括 `GITEA_URL`、`GITEA_BOT_TOKEN`、`GITEA_BOT_USERNAME`、`GITEA_ORG`、`TEAM_KB_REPO`、`OPENCLAW_SHARED_DIR`。\r\n\r\n## 执行流程\r\n\r\n必须使用四段式流程，让“选哪些页面作为参考”由 OpenClaw 完成，而不是由脚本用关键词配对决定。\r\n\r\n1. 运行准备脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\n准备脚本会读取 `catalog.json`、`index.md`、页面元数据、少量探索卡片和附件文本预览，输出 OpenClaw 可读的查询规划上下文。`starterPageCards` 只是帮助 OpenClaw 快速了解可能相关的页面，不是最终证据，也不能直接作为引用依据。脚本不会生成答案，也不会决定最终参考页面。\r\n\r\n2. OpenClaw 阅读 `<context.json>`，根据用户问题、目录、索引、页面卡片和附件上下文，思考并生成 `<page-selection.json>`。OpenClaw 可以选择任意可见 catalog 页面，不限于 `starterPageCards`。\r\n\r\n`page-selection.json` 示例：\r\n\r\n```json\r\n{\r\n  \"rationale\": \"为什么这些页面需要被读取作为证据\",\r\n  \"selectedPages\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"reason\": \"用于确认项目边界和当前实现\",\r\n      \"expectedUse\": \"回答功能进度和边界\"\r\n    }\r\n  ],\r\n  \"unresolvedQuestions\": []\r\n}\r\n```\r\n\r\n3. 按 OpenClaw 选择读取证据页：\r\n\r\n```bash\r\npython3 scripts/run_task.py fetch --input <payload.json> --context <context.json> --selection <page-selection.json> --evidence-output <evidence.json>\r\n```\r\n\r\n`fetch` 只负责校验路径、读取 OpenClaw 选择的 KB 页面、解析 frontmatter `sources[]`，并输出 `<evidence.json>`。它不做答案判断，也不替 OpenClaw 增删参考范围。\r\n\r\n4. OpenClaw 阅读 `<context.json>` 和 `<evidence.json>`，进行知识库问答，生成 `<answer.json>`。`answer.json` 必须符合“OpenClaw 输出格式”。答案中的 `sources[]` 只能引用 `<evidence.json>` 中实际读取到的稳定 KB 页面；临时附件不能作为稳定 KB 来源。\r\n\r\n5. 运行应用脚本：\r\n\r\n```bash\r\npython3 scripts/run_task.py apply --input <payload.json> --context <context.json> --evidence <evidence.json> --answer <answer.json>\r\n```\r\n\r\n应用脚本会校验答案、确保结尾有参考来源、必要时写入 `qa/` 并更新 `catalog.json` 和 `index.md`，最后把后端 result JSON 写入 payload 指定的 `resultFile`。\r\n\r\n6. 最终回复后端：\r\n\r\n```json\r\n{\"success\": true, \"resultFile\": \"<result.json>\"}\r\n```\r\n\r\n## 回答规则\r\n\r\nOpenClaw 必须先判断团队 KB 证据是否足以回答问题。证据充分性判断基于 OpenClaw 自己选择并通过 `fetch` 读取到的稳定 KB 页面。\r\n\r\n如果 KB 证据足够：先直接回答结论，再给出必要解释、比较、步骤或建议。回答必须以中文为主，除非用户明确要求其他语言。\r\n\r\n如果 KB 证据不足：回答开头必须明确说明“知识库内容无法回答这个问题”或等价表达，然后说明缺少哪些证据。可以在下方补充一般性回答或基于附件的临时分析，但必须标注“以下为非知识库结论/本轮参考附件推断”。\r\n\r\n附件只能帮助理解问题、补充本轮上下文或做临时对比；不要把临时附件当作长期 KB 来源，不要因为附件出现就写普通知识页。若答案主要依赖附件且缺少稳定 KB 证据，通常不要沉淀为 `qa/`。\r\n\r\n回答正文不强制套固定模板。可以按用户问题自然组织成结论、解释、对比、步骤、表格或建议；但不要为了模板牺牲可读性。\r\n\r\n答案结尾必须包含“参考来源”小节，这是唯一强制模板。稳定来源应优先列出 KB 页面路径和标题；如果证据页带有 `sources[]`，同时列出对应源文件、归档路径、仓库 URL、commit 或其他可追溯线索。若没有可引用 KB 页面，写明“知识库中未找到可支撑本问题的页面”。\r\n\r\n## 高价值问答沉淀\r\n\r\n高价值问答不是“回答得长”或“用户问了一个问题”就沉淀，而是要成为团队以后可复用的知识入口。OpenClaw 必须先做结构化评估，再决定是否把 `highValue` 或 `qa.write` 设为 `true`。\r\n\r\n硬性门槛：\r\n\r\n- `knowledgeSufficient=true`，且答案有稳定 KB 页面支撑。\r\n- 主要依据不是本轮临时附件；附件只能帮助理解问题或补充临时上下文。\r\n- 问题不是一次性操作、临时状态查询、简单事实定位、格式转换、寒暄、泛泛建议或纯外部常识问答。\r\n- 结论足够稳定，后续成员在相同或相近问题下可以直接复用。\r\n\r\n正向信号：\r\n\r\n- 跨多个稳定 KB 页面综合，或者把一个重要单页中的规则/边界整理成可复用的规范答案。\r\n- 回答澄清了项目架构、功能边界、资料源处理规则、实验结论、技术选型、风险判断或工作流程。\r\n- 答案包含明确判断、适用条件、例外情况和后续行动，而不是只摘录原文。\r\n- 该问题预计会反复出现，沉淀后能减少后续检索和解释成本。\r\n\r\n建议采用 0-5 分评估：`reuseValue`、`synthesisDepth`、`evidenceQuality`、`stability`、`actionability` 各 0/1 分。总分至少 4 分，且通过全部硬性门槛时，才允许写入 `qa/`。\r\n\r\nOpenClaw 必须在 `answer.json` 中给出 `qaEvaluation`，说明为什么是或不是高价值问答。apply 脚本只执行确定性拦截：缺少评估、证据不足、无稳定来源、附件驱动、临时/一次性、分数不足时，即使 OpenClaw 请求写入，也不沉淀。\r\n\r\n`qa/` 页面应包含：问题、可复用回答、证据页面、适用场景、更新时间。QA 页面只应引用稳定 KB 页面作为来源；临时附件不能作为唯一长期证据。\r\n\r\n## OpenClaw 输出格式\r\n\r\n`answer.json` 是 OpenClaw 生成、apply 脚本读取的文件：\r\n\r\n```json\r\n{\r\n  \"answer\": \"完整回答。正文不需要固定模板；结尾可以已包含参考来源，apply 会补齐缺失的参考来源。\",\r\n  \"knowledgeSufficient\": true,\r\n  \"sources\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"title\": \"Example\",\r\n      \"type\": \"project\",\r\n      \"snippet\": \"可选引用片段\",\r\n      \"sourceIds\": [],\r\n      \"sourceTraces\": [\r\n        {\r\n          \"sourceId\": 1,\r\n          \"sourceType\": \"local_folder\",\r\n          \"title\": \"原始资料标题\",\r\n          \"fileName\": \"example.pdf\",\r\n          \"archivedPath\": \"source_files/local_folder/example.pdf\",\r\n          \"url\": \"\",\r\n          \"commitHash\": \"\"\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"usedAttachments\": [\r\n    {\r\n      \"attachmentId\": 1,\r\n      \"fileName\": \"context.docx\",\r\n      \"role\": \"query_reference\"\r\n    }\r\n  ],\r\n  \"highValue\": false,\r\n  \"qaEvaluation\": {\r\n    \"reuseValue\": 0,\r\n    \"synthesisDepth\": 0,\r\n    \"evidenceQuality\": 0,\r\n    \"stability\": 0,\r\n    \"actionability\": 0,\r\n    \"attachmentDriven\": false,\r\n    \"ephemeral\": false,\r\n    \"reason\": \"为什么适合或不适合沉淀\"\r\n  },\r\n  \"qa\": {\r\n    \"write\": false,\r\n    \"path\": \"qa/example.md\",\r\n    \"title\": \"可复用问答标题\",\r\n    \"content\": \"可选；不填时 apply 根据 answer 自动生成\"\r\n  },\r\n  \"errors\": []\r\n}\r\n```\r\n\r\n后端最终读取 `resultFile` 中的字段：\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"answer\": \"...\",\r\n  \"sources\": [],\r\n  \"createdQaPath\": \"qa/example.md\",\r\n  \"processedSources\": [\"team-kb\"],\r\n  \"createdPages\": [],\r\n  \"updatedPages\": [],\r\n  \"errors\": [],\r\n  \"commitId\": \"\"\r\n}\r\n```\n\nFile v1.0.2:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.2\",\n  \"publishedAt\": 1783446462776\n}\n\nFile v1.0.2:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. <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 team knowledge-base users use this skill to answer Research KB questions through an OpenClaw-led workflow that selects KB pages, fetches evidence, generates cited answers, and optionally persists high-value reusable Q&A. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: A Gitea bot token with broad permissions could expose or modify knowledge-base content beyond the intended team repository. <br>\nMitigation: Use a bot token limited to the intended team KB repository and configure the skill only with that repository's owner and name. <br>\nRisk: When high-value Q&A persistence is enabled, the skill can commit generated QA pages and update catalog/index files. <br>\nMitigation: Keep Q&A writing disabled unless persistence is intended, and review generated QA content and stable KB citations before relying on committed changes. <br>\nRisk: Temporary attachments can influence an answer but are not stable knowledge-base sources. <br>\nMitigation: Require stable fetched KB pages for citations and Q&A persistence; label any attachment-based supplement as non-KB or temporary. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, JSON, shell commands, configuration] <br>\n**Output Format:** [Markdown answers and JSON workflow artifacts, with shell commands for prepare, fetch, and apply stages.] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [The apply stage writes a result JSON containing the answer, sources, optional created QA path, page changes, errors, and commit ID.] <br>\n\n## Skill Version(s): <br>\n1.0.2 (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.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\n\nFile v1.0.2:requirements.txt\n\n# kb_query uses only the Python 3 standard library for deterministic prepare/apply helpers.\n\nArchive v1.0.1: 19 files, 13668 bytes\n\nFiles: _meta.json (127b), env-example.txt (106b), main.js (166b), requirements.txt (23b), scripts/catalog.py (357b), scripts/frontmatter.py (743b), scripts/gitea_api.py (1644b), scripts/kb_list.py (659b), scripts/kb_read.py (675b), scripts/kb_schema.py (226b), scripts/result_schema.py (431b), scripts/run_task.py (9812b), scripts/task_schema.py (753b), scripts/validate_answer.py (855b), setup.sh (179b), skill-card.md (2164b), SKILL.md (3945b), tests/sample_query_result.json (713b), tests/sample_query_task.json (882b)\n\nFile v1.0.1:SKILL.md\n\n---\nname: kb_query\ndescription: Answer simple lookup and factual Q&A questions from Java-specified personal/team Research KB repositories with source grounding and structured citations for the desktop source list. Use for ordinary knowledge-base retrieval; do not use for GitHub/open-source project usefulness evaluation or cross-document literature/special-topic reviews.\n---\n\n# Skill: kb_query\n\n## 职责边界\n\n`kb_query` 只负责在 Java 后端指定的 Research KB 仓库中检索资料、读取相关 Markdown 页面，并基于这些已读页面回答问题。它不负责身份识别、权限判断、知识库范围选择、会话存储、查询历史写入或 Gitea 日志记录。\n\n如果用户问题是在评估开源/GitHub 项目是否有用、是否值得复现、环境风险如何，交给对应的开源项目评估 skill。\n如果用户问题是在写专项综述、跨多篇资料做方法对比、研究缺口分析或主题综合，交给对应的专项综述 skill。\n\n只能访问 `kbTargets[]` 中列出的仓库。不要读取或推断任何未列出的仓库。\n\n## 可接受任务\n\n只接受满足以下条件的 JSON：\n\n- `protocol = research_kb_agent_task`\n- `taskType = kb_query`\n- `kbTargets[]` 中有一个或两个目标\n- `payload.question` 非空\n\n## 查询流程\n\n每次回答必须按以下顺序执行：\n\n1. 校验任务协议和输入字段。\n2. 读取每个目标仓库的 `catalog.json` 和 `index.md`。\n3. 从 catalog、index 和仓库 Markdown 树中收集候选页面。\n4. 基于问题进行中文/英文 token 化检索，对标题、路径、标题层级和正文分别评分。\n5. 只读取和使用评分相关的 Markdown 页面。\n6. 回答中的知识库事实必须只来自本次已读页面，不能用常识、模型记忆或外部网页补全知识库事实。\n7. 如果问题是“你是谁”“介绍一下自己”“你能做什么”等身份类问题，优先读取 `README.md`、`AGENTS.md`、`index.md` 等系统页面。\n8. `citations[]` 只能引用本次已读页面，路径必须是仓库相对路径，供桌面端渲染为来源清单并点击打开。\n9. 不要在回答正文末尾生成 Markdown 链接、脚注或“[来源](path)”列表；来源只放入 `citations[]`。\n10. 不要向 Gitea 写入查询日志；查询历史由 Java 后端保存。\n\n## 证据不足规则\n\n如果知识库中没有足够资料回答问题，答案必须先说明：\n\n`知识库中没有足够资料回答这个问题。`\n\n此时可以继续给出一般性说明，但必须用“以下是非知识库结论的一般性说明”这样的文字明确标记。`citations` 必须返回空数组。不要把一般性说明伪装成知识库事实。\n\n## 引用规则\n\n每条 citation 必须包含：\n\n- `kbType`\n- `repoFullName`\n- `path`\n- `title`\n- `snippet`\n- `anchor`\n\n`snippet` 应该是支撑答案的短证据片段。不要引用未读取页面，不要引用 `source_files/` 下的原始归档文件。\n\n桌面端会把 `citations[]` 渲染为“来源 1 / 来源 2 / 来源 3”清单。回答正文要专注于结论，不要重复输出来源清单。\n\n## 输出\n\n必须返回一个合法 JSON 对象，不能包 Markdown 代码块：\n\n```json\n{\n  \"protocol\": \"research_kb_agent_result\",\n  \"protocolVersion\": \"1.0\",\n  \"taskId\": \"...\",\n  \"taskType\": \"kb_query\",\n  \"success\": true,\n  \"result\": {\n    \"answer\": \"...\",\n    \"citations\": [],\n    \"usedScopes\": [\"personal\", \"team\"],\n    \"readPages\": []\n  },\n  \"errors\": []\n}\n```\n\n字段名、层级和类型不能改变。\n\n## 辅助入口\n\n稳定入口是：\n\n```bash\npython3 scripts/run_task.py --stdin\npython3 scripts/run_task.py --task-json <path>\n```\n\n脚本会执行候选页收集、证据检索、引用生成和 JSON schema 输出。Agent 如需生成更自然的中文回答，也必须先读取页面；知识库事实必须限制在已读页面证据内，一般性说明必须清楚标注为非知识库结论。\n\nFile v1.0.1:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.1\",\n  \"publishedAt\": 1782415644503\n}\n\nFile v1.0.1:skill-card.md\n\n## Description: <br>\nAnswers simple lookup and factual Q&A questions from Java-specified personal or team Research KB repositories with source-grounded citations for a desktop source list. <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 users use this skill to answer simple factual questions from one or two Java-selected personal or team Research KB repositories. It reads relevant Markdown pages from the selected repositories and returns answers with structured citations. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill uses a Gitea credential for repository reads without enforcing its own repository allowlist. <br>\nMitigation: Install only when the Java backend tightly controls kbTargets and the Gitea credential is a read-only token scoped to intended KB repositories. <br>\nRisk: Private or business-sensitive knowledge bases could be exposed if transport, repository scope, or dependencies are not controlled. <br>\nMitigation: Confirm repository allowlisting, HTTPS configuration, and pinned dependencies before using the skill with sensitive knowledge bases. <br>\n\n\n## Reference(s): <br>\n- [ClawHub Skill Page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, json, guidance] <br>\n**Output Format:** [JSON object with answer text, citations, used scopes, read pages, and errors] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Citations must reference pages read during the task; insufficient evidence responses return empty citations and label general guidance as non-KB.] <br>\n\n## Skill Version(s): <br>\n1.0.1 (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.1:tests/sample_query_result.json\n\n{\n  \"protocol\": \"research_kb_agent_result\",\n  \"protocolVersion\": \"1.0\",\n  \"taskId\": \"query_sample_001\",\n  \"taskType\": \"kb_query\",\n  \"success\": true,\n  \"result\": {\n    \"answer\": \"知识库中没有足够资料回答这个问题。\\n\\n以下是非知识库结论的一般性说明：\\n\\n可以先补充与问题直接相关的 README、说明文档、会议记录、实验记录或论文摘要，再重新入库后查询。若问题涉及项目或代码，建议优先上传完整项目根目录，让知识库形成代码库总览页；若问题涉及论文或调研，建议上传原文、笔记和关键结论说明。\",\n    \"citations\": [],\n    \"usedScopes\": [\"team\"],\n    \"readPages\": []\n  },\n  \"errors\": []\n}\n\nFile v1.0.1:tests/sample_query_task.json\n\n{\n  \"protocol\": \"research_kb_agent_task\",\n  \"protocolVersion\": \"1.0\",\n  \"taskId\": \"query_sample_001\",\n  \"taskType\": \"kb_query\",\n  \"requestedAt\": \"2026-06-25T12:00:00+08:00\",\n  \"requester\": {\n    \"userId\": 1,\n    \"email\": \"user@example.com\",\n    \"displayName\": \"Sample User\",\n    \"role\": \"member\",\n    \"giteaUsername\": \"sample\"\n  },\n  \"kbTargets\": [\n    {\n      \"kbType\": \"team\",\n      \"repoOwner\": \"AIFusionBot\",\n      \"repoName\": \"aifhku-lab-team-kb\",\n      \"repoFullName\": \"AIFusionBot/aifhku-lab-team-kb\",\n      \"branch\": \"main\"\n    }\n  ],\n  \"payload\": {\n    \"conversationId\": \"conv_001\",\n    \"messageId\": \"msg_001\",\n    \"question\": \"What does the knowledge base say about LLM memory?\",\n    \"answerLanguage\": \"zh-CN\",\n    \"citationRequired\": true,\n    \"maxCitations\": 8\n  },\n  \"responseRequirement\": {\n    \"format\": \"json_only\",\n    \"schema\": \"research_kb_agent_result_v1\"\n  }\n}\n\nFile v1.0.1:env-example.txt\n\nGITEA_URL=http://127.0.0.1:3000\nGITEA_ADMIN_TOKEN=\nGITEA_BOT_USERNAME=AIFusionBot\nPAPERKB_MAX_CHARS=60000\n\nFile v1.0.1:requirements.txt\n\nrequests\npython-dotenv\n\nArchive v1.0.0: 19 files, 10004 bytes\n\nFiles: _meta.json (127b), env-example.txt (106b), main.js (137b), requirements.txt (23b), scripts/catalog.py (357b), scripts/frontmatter.py (743b), scripts/gitea_api.py (1644b), scripts/kb_list.py (659b), scripts/kb_read.py (675b), scripts/kb_schema.py (226b), scripts/result_schema.py (431b), scripts/run_task.py (3807b), scripts/task_schema.py (689b), scripts/validate_answer.py (855b), setup.sh (179b), skill-card.md (1981b), SKILL.md (1811b), tests/sample_query_result.json (323b), tests/sample_query_task.json (882b)\n\nFile v1.0.0:SKILL.md\n\n---\nname: kb_query\ndescription: Answer questions from Java-specified personal/team Research KB repositories with strict source grounding and structured citations.\n---\n\n# Skill: kb_query\n\n## Purpose\n\n`kb_query` is the only query skill used by the desktop system. The Java backend has already handled user identity, permissions, query scope, and conversation storage. This skill must only query the repositories listed in `kbTargets`.\n\n## Accepted Task\n\nOnly accept tasks whose top-level JSON contains:\n\n- `protocol = research_kb_agent_task`\n- `taskType = kb_query`\n- one or two `kbTargets[]` entries\n- `payload.question`\n\nNever access a repository that is not listed in `kbTargets`.\n\n## Required Behavior\n\n1. Read `catalog.json` and `index.md` from every target repository.\n2. List candidate Markdown pages.\n3. Select pages relevant to the question.\n4. Read selected pages with `kb_read.py` or `scripts/run_task.py` helper logic.\n5. Answer only from the pages that were actually read.\n6. Return `citations[]` whose paths are repository-relative and clickable by the desktop reader.\n7. If the knowledge base has no sufficient evidence, explicitly say so and return empty citations.\n8. Do not write query logs to Gitea. The Java backend stores query history.\n\n## Citation Rules\n\nEach citation must include:\n\n- `kbType`\n- `repoFullName`\n- `path`\n- `title`\n- `snippet`\n- `anchor`\n\nDo not cite pages that were not read in this task.\n\n## Output\n\nReturn exactly one valid JSON object:\n\n```json\n{\n  \"protocol\": \"research_kb_agent_result\",\n  \"protocolVersion\": \"1.0\",\n  \"taskId\": \"...\",\n  \"taskType\": \"kb_query\",\n  \"success\": true,\n  \"result\": {\n    \"answer\": \"...\",\n    \"citations\": [],\n    \"usedScopes\": [\"personal\", \"team\"],\n    \"readPages\": []\n  },\n  \"errors\": []\n}\n```\n\nNever return Markdown fences around the JSON.\n\nFile v1.0.0:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.0\",\n  \"publishedAt\": 1782391881528\n}\n\nFile v1.0.0:skill-card.md\n\n## Description: <br>\nAnswer questions from Java-specified personal/team Research KB repositories with strict source grounding and structured citations. <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 desktop application users use this skill to answer questions from specified personal or team Research KB repositories while returning structured JSON citations for the pages read. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill uses a Gitea admin token and does not enforce repository scope itself. <br>\nMitigation: Install only where the Java backend validates kbTargets and user permissions before invoking the skill. <br>\nRisk: A broad Gitea token could allow access beyond the intended knowledge base repositories. <br>\nMitigation: Prefer a read-only token limited to the intended KB repositories before production use. <br>\nRisk: Unpinned Python dependencies can change behavior across installs. <br>\nMitigation: Pin dependency versions before production use. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, JSON, guidance] <br>\n**Output Format:** [JSON object with answer, citations, used scopes, read pages, and errors] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Returns JSON only and does not wrap responses in Markdown fences.] <br>\n\n## Skill Version(s): <br>\n1.0.0 (source: server release evidence and artifact _meta.json) <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:tests/sample_query_result.json\n\n{\n  \"protocol\": \"research_kb_agent_result\",\n  \"protocolVersion\": \"1.0\",\n  \"taskId\": \"query_sample_001\",\n  \"taskType\": \"kb_query\",\n  \"success\": true,\n  \"result\": {\n    \"answer\": \"知识库中没有足够资料回答这个问题。\",\n    \"citations\": [],\n    \"usedScopes\": [\"team\"],\n    \"readPages\": []\n  },\n  \"errors\": []\n}\n\nFile v1.0.0:tests/sample_query_task.json\n\n{\n  \"protocol\": \"research_kb_agent_task\",\n  \"protocolVersion\": \"1.0\",\n  \"taskId\": \"query_sample_001\",\n  \"taskType\": \"kb_query\",\n  \"requestedAt\": \"2026-06-25T12:00:00+08:00\",\n  \"requester\": {\n    \"userId\": 1,\n    \"email\": \"user@example.com\",\n    \"displayName\": \"Sample User\",\n    \"role\": \"member\",\n    \"giteaUsername\": \"sample\"\n  },\n  \"kbTargets\": [\n    {\n      \"kbType\": \"team\",\n      \"repoOwner\": \"AIFusionBot\",\n      \"repoName\": \"aifhku-lab-team-kb\",\n      \"repoFullName\": \"AIFusionBot/aifhku-lab-team-kb\",\n      \"branch\": \"main\"\n    }\n  ],\n  \"payload\": {\n    \"conversationId\": \"conv_001\",\n    \"messageId\": \"msg_001\",\n    \"question\": \"What does the knowledge base say about LLM memory?\",\n    \"answerLanguage\": \"zh-CN\",\n    \"citationRequired\": true,\n    \"maxCitations\": 8\n  },\n  \"responseRequirement\": {\n    \"format\": \"json_only\",\n    \"schema\": \"research_kb_agent_result_v1\"\n  }\n}\n\nFile v1.0.0:env-example.txt\n\nGITEA_URL=http://127.0.0.1:3000\nGITEA_ADMIN_TOKEN=\nGITEA_BOT_USERNAME=AIFusionBot\nPAPERKB_MAX_CHARS=60000\n\nFile v1.0.0:requirements.txt\n\nrequests\npython-dotenv","readmeExcerpt":"Skill: Kb Query Owner: myd2002 Summary: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. Tags: latest:1.0.8 Version history: v1.0.8 | 2026-07-09T14:33:17.833Z | user No functional changes. Documentation improved for implementation details and usage ","codeSnippets":[],"executableExamples":[{"language":"text","snippet":"File v1.0.8:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.8\",\n  \"publishedAt\": 1783607597833\n}\n\nFile v1.0.8:skill-card.md\n\n## Description:\n\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\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-team KB users use this skill to answer questions against a team Gitea-backed knowledge base, optionally using temporary attachments for context and persisting reusable high-value Q&A entries when policy allows.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: The skill uses a bot token to read and write a Gitea-backed knowledge base.\n\nMitigation: Run it only with trusted backend payloads and a tightly scoped bot account limited to the intended KB repository.\n\nRisk: Payload or environment configuration can select the Gitea host used by the helper scripts.\n\nMitigation: Require an allowlisted HTTPS Gitea host before production use.\n\nRisk: The skill reads attachment paths and writes result paths supplied through backend payloads.\n\nMitigation: Constrain attachment and result paths to trusted directories and reject symlinks or path traversal.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/myd2002/skills/kb-query)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, JSON, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown answer text with JSON result files and cited KB sources]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [May create or update high-value Q&A pages, catalog entries, and index entries when policy and evidence gates allow.]\n\n## Skill Version(s):\n\n1.0.8 (source: server rel"},{"language":"text","snippet":"File v1.0.7:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.7\",\n  \"publishedAt\": 1783540459415\n}\n\nFile v1.0.7:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. <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>\nTeam members and developers use Kb Query to answer questions against a Gitea-backed Research KB, cite stable KB pages, and optionally persist reusable Q&A when enabled. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill can read team KB content and reference attachments. <br>\nMitigation: Install it only where the Gitea bot token is limited to the intended KB repository. <br>\nRisk: Optional Q&A persistence can commit reusable answers back to the KB. <br>\nMitigation: Keep Q&A persistence disabled unless the team wants curated answers saved as KB pages. <br>\nRisk: Attachment access depends on storage paths supplied through the surrounding system. <br>\nMitigation: Use backend-generated attachment storage paths rather than user-supplied paths. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, JSON, shell commands, configuration] <br>\n**Output Format:** [Markdown answers with JSON handoff files and shell command steps.] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Can write a backend result JSON and, when enabled, a reusable Q&A Markdown page.] <br>\n\n## Skill Version(s): <br>\n1.0.7 (source: ClawHub release evidence) <br>\n\n## Ethical Considerations: <br>\nUsers shou"},{"language":"text","snippet":"File v1.0.6:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.6\",\n  \"publishedAt\": 1783539532332\n}\n\nFile v1.0.6:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. <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>\nEmployees and developers use this skill to answer Research KB questions from a Gitea-backed team knowledge base, cite stable KB pages, and optionally preserve high-value reusable Q&A when policy allows. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: A broadly scoped Gitea bot token could allow access or changes outside the intended knowledge-base repository. <br>\nMitigation: Limit GITEA_BOT_TOKEN to the intended team knowledge-base repository and use the least permissions needed for read and optional write operations. <br>\nRisk: Optional high-value Q&A persistence can store model-produced answers in the knowledge base. <br>\nMitigation: Enable writeHighValueAnswerToQa only when automatic KB updates are acceptable, and rely on the skill's evidence sufficiency and QA evaluation gates before persisting answers. <br>\nRisk: Reference attachments depend on backend-provided storage paths. <br>\nMitigation: Ensure backend payloads control attachment storage paths and keep attachments as temporary context rather than stable knowledge-base sources. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [Text, Markdown, JSON, Shell commands, Guidance] <br>\n**Output Format:** [JSON result files and Markdown/text answers with stable "},{"language":"text","snippet":"File v1.0.5:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.5\",\n  \"publishedAt\": 1783537387966\n}\n\nFile v1.0.5:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from a team Gitea-backed knowledge base with OpenClaw-led evidence selection, optional reference attachments, stable citations, and optional high-value Q&A persistence. <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 answer team Research KB questions by preparing bounded context, fetching selected KB evidence, composing cited answers, and optionally saving reusable high-value Q&A pages. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill handles a repository token, network target, local attachment paths, and result paths with weak scoping. <br>\nMitigation: Install only where the backend controls payload generation, validates attachment/result/shared-directory paths, and pins the allowed Gitea host and repository outside user-controlled payload data. <br>\nRisk: Optional Q&A persistence can write generated content back to the knowledge base. <br>\nMitigation: Use a narrowly scoped Gitea bot token and review Q&A persistence policy before enabling repository write access. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n- [Publisher profile](https://clawhub.ai/user/myd2002) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [Text, Markdown, JSON, Shell commands, Configuration, Guidance] <br>\n**Output Format:** [Markdown answers with stable source lists, plus JSON context, evidence, answer, and result files] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [The apply step writes resultFile JSON containing th"},{"language":"text","snippet":"File v1.0.4:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.4\",\n  \"publishedAt\": 1783529830688\n}\n\nFile v1.0.4:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. <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 team knowledge-base users use this skill to answer Research KB questions from a Gitea-backed team knowledge base, with optional temporary attachment context and stable KB citations. It can also persist high-value reusable Q&A pages when policy allows and stable KB evidence supports the answer. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill uses expected Gitea access for reading KB content and optionally writing reusable Q&A pages, catalog.json, and index.md. <br>\nMitigation: Run it with a Gitea bot token limited to the minimum repository permissions needed, and enable Q&A persistence only for teams that want the skill to update the configured KB repo. <br>\nRisk: Temporary attachment previews could be mistaken for stable knowledge-base sources. <br>\nMitigation: Use attachments only as per-query reference context; cite and persist only fetched stable KB pages returned in the evidence bundle. <br>\nRisk: Payload result paths and attachment storage paths can affect which files the helper reads or writes. <br>\nMitigation: Deploy only where the backend constrains attachment storagePath and result paths to the shared workspace. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/myd2002/skills/kb-query) <br>\n- [Publisher profile](https://clawhub.ai/user/myd2002) <br>\n- [S"},{"language":"text","snippet":"File v1.0.3:_meta.json\n\n{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.3\",\n  \"publishedAt\": 1783506671034\n}\n\nFile v1.0.3:skill-card.md\n\n## Description: <br>\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. <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 teams use this skill to answer questions against a Gitea-backed team knowledge base, select supporting KB pages, cite stable evidence, and optionally preserve reusable high-value answers as Q&A pages. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: A broad Gitea bot token could allow the skill to read or update repositories beyond the intended knowledge base. <br>\nMitigation: Scope the bot token to the intended KB repository and use a dedicated bot identity for this workflow. <br>\nRisk: Optional Q&A persistence can change qa/ pages, catalog.json, and index.md. <br>\nMitigation: Enable persistence only for environments that want reusable answer capture, and review resulting page and index changes before relying on them. <br>\nRisk: Reference attachments are temporary context and may not be suitable as stable knowledge-base sources. <br>\nMitigation: Use trusted shared upload paths and keep final citations grounded in fetched KB pages rather than temporary attachments. <br>\n\n\n## Reference(s): <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [Text, Markdown, JSON, Shell commands, Configuration, Guidance] <br>\n**Output Format:** [Markdown-style answer text, JSON context/evidence/result files, and shell commands for prepare, fetch, and apply steps] <br>\n**Output Parameters:** [1D] <br>\n**Other Propert"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\r\nname: kb_query\r\ndescription: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\r\n---\r\n\r\n# kb_query\r\n\r\n## 职责边界\r\n\r\n`kb_query` 只负责“对话”页面的知识库查询。用户输入可以是纯文字，也可以带附件；附件一律是本轮参考材料，用于辅助理解问题、补充上下文或做临时对比，稳定来源仍以知识库证据页为准。\r\n\r\n本 skill 不负责登录、权限、会话历史、文件上传、任务调度或资料源入库。Java 后端负责这些系统动作。OpenClaw 负责理解用户问题、判断需要参考哪些 KB 页面、综合证据、生成回答、判断证据是否充分，以及判断是否值得沉淀为 `qa/` 页面。Python 脚本只做确定性动作：读取 catalog/index 和探索卡片、按 OpenClaw 选择读取证据页面、抽取附件文本预览、校验 OpenClaw 输出、可选写入 `qa/`、维护 `catalog.json`/`index.md`、写出后端 result JSON。\r\n\r\n不要提供脚本兜底的抽取式简化回答。没有真实 OpenClaw 理解时，任务应失败或返回明确错误，而不是用脚本假装完成问答。\r\n\r\n## 输入约定\r\n\r\n后端 payload 通常包含：\r\n\r\n- `taskId`: 后端生成的查询任务 ID，当前格式为 `query-<conversationId>-<messageId>`，用于共享 payload/result 文件和 OpenClaw session key。\r\n- `skill`: `kb_query`。\r\n- `question`: 用户问题。\r\n- `conversationId`: 当前会话 ID。\r\n- `messageId`: 用户消息 ID。\r\n- `attachments[]`: 本轮参考附件，字段包括 `attachmentId`、`fileName`、`mimeType`、`storagePath`、`sha256`、`size`、`temporary=true`。\r\n- `answerPolicy.scopeSelection`: `auto_by_openclaw`。\r\n- `answerPolicy.knowledgeBaseFirst`: `true`，表示事实性回答必须优先基于团队 KB。`answerPolicy.allowNonKbSupplementWhenInsufficient=true` 时，知识库证据不足可以在明确说明后补充非 KB 或附件分析。\r\n- `answerPolicy.writeHighValueAnswerToQa`: 是否允许高价值问答写入 `qa/`。\r\n- `payloadFile`、`resultFile`、`sharedDir`: 后端共享目录路径。\r\n\r\n环境变量包括 `GITEA_URL`、`GITEA_BOT_TOKEN`、`GITEA_BOT_USERNAME`、`GITEA_ORG`、`TEAM_KB_REPO`、`OPENCLAW_SHARED_DIR`。\r\n\r\n## 执行流程\r\n\r\n必须使用四段式流程，让“选哪些页面作为参考”由 OpenClaw 完成，而不是由脚本用关键词配对决定。\n\n上下文预算必须保守执行。`prepare`/`fetch` 命令会把完整 JSON 写入文件，终端只输出摘要；OpenClaw 应阅读文件路径指向的 JSON，不要把完整 context/evidence 粘贴回聊天。页面选择应坚持“够用即可”：通常选择 1-4 个最关键 KB 页面，最多不得超过 `context.analysisLimits.maxSelectedPages`。如果 OpenClaw 判断问题本身不适合由 KB 回答，或者没有任何相关 KB 页面，可以写出合法的空选择 `{\"selectedPages\":[],\"rationale\":\"...\",\"unresolvedQuestions\":[]}`，继续运行 fetch/apply，并在答案中按证据不足规则说明。不要因为证据不足而停止在 selection 阶段；如果少量证据已经能回答，不要扩大读取范围；如果证据不足，按不足规则回答，而不是继续尝试读取大量页面。\n\n所有中间 JSON 文件必须是严格合法 JSON。写 `page-selection.json` 和 `answer.json` 时不要加入 Markdown 代码围栏、注释、尾随逗号或半截文本；文件写好后再运行下一步脚本。`answer` 正文通常包含 Markdown、双引号和表格，优先用 `python3` 的 `json.dump`/`json.dumps` 写出整个 `answer.json`，不要手写长 JSON 字符串。\n\n1. 运行准备脚本：\n\r\n```bash\r\npython3 scripts/run_task.py prepare --input <payload.json> --context-output <context.json>\r\n```\r\n\r\n准备脚本会读取 `catalog.json`、`index.md`、页面元数据、少量探索卡片和附件文本预览，输出 OpenClaw 可读的查询规划上下文。命令行只返回摘要，完整内容在 `<context.json>` 中。`starterPageCards` 只是帮助 OpenClaw 快速了解可能相关的页面，不是最终证据，也不能直接作为引用依据。脚本不会生成答案，也不会决定最终参考页面。\n\n2. OpenClaw 阅读 `<context.json>`，根据用户问题、目录、索引、页面卡片、预算限制和附件上下文，思考并生成 `<page-selection.json>`。OpenClaw 可以选择任意可见 catalog 页面，不限于 `starterPageCards`，但应选择最小充分集合。\n\r\n`page-selection.json` 示例：\r\n\r\n```json\r\n{\r\n  \"rationale\": \"为什么这些页面需要被读取作为证据\",\r\n  \"selectedPages\": [\r\n    {\r\n      \"path\": \"projects/example.md\",\r\n      \"reason\": \"用于确认项目边界和当前实现\",\r\n      \"expectedUse\": \"回答功能进度和边界\"\r\n    }\r\n  ],\r\n  \"unresolvedQuestions\": []\r\n}\r\n```\r\n\r\n3. 按 OpenClaw 选择读取证据页：\r\n\r\n```bash"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn7cp7eb6ymqv898hke0ersmc1847fed\",\n  \"slug\": \"kb-query\",\n  \"version\": \"1.0.8\",\n  \"publishedAt\": 1783607597833\n}"},{"path":"skill-card.md","content":"## Description:\n\nAnswer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence.\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-team KB users use this skill to answer questions against a team Gitea-backed knowledge base, optionally using temporary attachments for context and persisting reusable high-value Q&A entries when policy allows.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: The skill uses a bot token to read and write a Gitea-backed knowledge base.\n\nMitigation: Run it only with trusted backend payloads and a tightly scoped bot account limited to the intended KB repository.\n\nRisk: Payload or environment configuration can select the Gitea host used by the helper scripts.\n\nMitigation: Require an allowlisted HTTPS Gitea host before production use.\n\nRisk: The skill reads attachment paths and writes result paths supplied through backend payloads.\n\nMitigation: Constrain attachment and result paths to trusted directories and reject symlinks or path traversal.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/myd2002/skills/kb-query)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, JSON, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown answer text with JSON result files and cited KB sources]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [May create or update high-value Q&A pages, catalog entries, and index entries when policy and evidence gates allow.]\n\n## Skill Version(s):\n\n1.0.8 (source: server release metadata)\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"},{"path":"requirements.txt","content":"# kb_query uses only the Python 3 standard library for deterministic prepare/apply helpers."}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. Skill: Kb Query Owner: myd2002 Summary: Answer Research KB questions from the team Gitea-backed knowledge base with OpenClaw reasoning, optional reference attachments, stable citations, OpenClaw-led evidence selection, and optional high-value Q&A persistence. Tags: latest:1.0.8 Version history: v1.0.8 | 2026-07-09T14:33:17.833Z | user No functional changes. Documentation improved for implementation details and usage","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":1418,"uniquenessScore":47,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-11T04:10:06.085Z","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-11T04:10:06.085Z","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-11T07:39:54.930Z","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"}]}}}