open-knowledge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenKnowledge — agent guidance
OpenKnowledge — Agent操作指南
OpenKnowledge (OK) is a markdown-CRDT collaboration platform exposed via MCP. This skill is the single source of OK agent guidance. Every rule below is a MUST unless marked otherwise. Depth lives in — one level deep; load a reference when its task comes up.
references/*.mdSkill version tracks.@inkeep/open-knowledge-servershows what's installed.cat ~/.ok/skill-state.ymlneedsok seed>= 0.4.0; if it errors@inkeep/open-knowledge,unknown command.npm install -g @inkeep/open-knowledge
Setup (not connected yet?). If thetools aren't available in your client, this project isn't wired up on this machine — seemcp__open-knowledge__*for the rung ladder (approvereferences/setup.md→.mcp.jsonCLI → optional desktop app) and the canonical quickstart.ok start
OpenKnowledge(简称OK)是一个通过MCP暴露的Markdown-CRDT协作平台。本Skill是OK Agent操作指南的唯一来源。除非另有标记,以下所有规则均为强制要求。详细内容位于目录下(仅一级深度);当涉及对应任务时,请加载参考文档。
references/*.mdSkill版本与保持同步。执行@inkeep/open-knowledge-server可查看已安装版本。cat ~/.ok/skill-state.yml要求ok seed版本≥0.4.0;若提示@inkeep/open-knowledge错误,请执行unknown command。npm install -g @inkeep/open-knowledge
初始化设置(尚未连接?) 如果你的客户端中没有工具,则说明此项目未在本机配置——请查看mcp__open-knowledge__*中的步骤(批准references/setup.md→ 运行.mcp.jsonCLI → 可选桌面应用)以及标准快速入门指南。ok start
TL;DR — the 90% case
核心要点——90%场景适用
- Reads: for one doc,
exec("cat …")for a directory (folder defaults + template menu),exec("ls -A …")for literal,exec("grep …")for ranked retrieval. Nativesearch/Readonly on source code (Grep/.ts/ …), never on in-scope.py/.md..mdx - Writes: for a new or full-replace doc;
write({ document: { path, content } })for a body find/replace;edit({ document: { path, find, replace } })for a frontmatter merge-patch (edit({ document: { path, frontmatter } })deletes a key).nullremoves,delete({ document })moves/renames. Body find/replace is body-only. Pass a one-linemove({ from, to })(≤80 chars, user-facing outcome) on every content write.summary - Preview / open a doc — determine your ONE surface FIRST (once per session). Stop at first match: or
OK_DESKTOP_TERMINALset → you're inside OpenKnowledge (desktop terminal / in-app agent panel) →OK_HOSTED_AGENT(switches the window the user is already looking at); never paste aok open <name>URL into your reply here · in-app browser (Claude Code Desktop's Browser pane, Cursor, Codex) →localhost, then open/navigate it to the doc · else plain CLI →preview_url.ok open <name>opens a doc or folder (auto-detected);ok open <name>for a skill. The--skill <name>field is a route id, not your open mechanism. Don'tpreviewUrlto confirm edits. Full Step-0 procedure + per-surface how-to:preview_screenshot.references/preview.md - Knowledge layers: capturing a source (ingest), synthesizing findings (research), promoting a decision (consolidate) — procedures, not tool calls; there is no tool. Ingest ships here (
ingest); research + consolidate come with thereferences/ingest-and-sources.mdpack. Layer model + packs:knowledge-base.references/starter-packs.md - Direct questions: a plain business question ("which customers…", "what did we decide about…") routes to /
search+ a cited chat answer — no "research" keyword needed. Persist only when durable + multi-doc + not already covered, and offer first. Seeexec.references/corpus-qa.md - Authoring or improving a skill ("write/make a skill", "improve this skill", "turn this into a skill"): STOP and invoke the skill — it owns scope choice (project vs global), the SKILL.md contract, evaluation, and install; don't improvise here. Author through the
open-knowledge-write-skilltarget (skill), never a raw path document. Skills are REAL folders under the editor dirs'write({ skill })(skills/·.claude·.cursor·.codex·.opencode·.pi): ONE is the source, the rest are managed copies/symlinks. Read and edit via the tools (.agents,skills) — they route to the source. Never hand-edit a non-source copy: unedited copies refresh from the source, and editing one forks it into its own skill that stops refreshing.edit({ skill })
- 读取操作:读取单个文档使用,列出目录内容使用
exec("cat …")(含默认文件夹模板菜单),精确匹配搜索使用exec("ls -A …"),排序检索使用exec("grep …")。仅在处理源代码(search/.ts/…)时使用原生.py/Read工具,绝对禁止用于范围内的Grep/.md文件。.mdx - 写入操作:创建或完全替换文档使用;正文内容替换使用
write({ document: { path, content } });更新前置元数据使用edit({ document: { path, find, replace } })(传入edit({ document: { path, frontmatter } })可删除对应字段)。删除文档使用null,移动/重命名文档使用delete({ document })。正文替换仅作用于正文内容。每次写入内容时必须传入一行move({ from, to })(≤80字符,面向用户的结果说明)。summary - 预览/打开文档——先确定唯一操作入口(每会话一次):按以下优先级选择第一个匹配项:已设置或
OK_DESKTOP_TERMINAL→ 处于OpenKnowledge环境(桌面终端/应用内Agent面板)→ 使用OK_HOSTED_AGENT(切换用户当前查看的窗口);在此场景下绝对不要在回复中粘贴ok open <name>链接 · 应用内浏览器(Claude Code Desktop的Browser面板、Cursor、Codex)→ 使用localhost,然后打开/导航到目标文档 · 纯CLI环境 → 使用preview_url。ok open <name>可自动检测并打开文档或文件夹;添加ok open <name>参数可打开指定Skill。--skill <name>字段是路由ID,不是打开文档的操作方式。不要使用previewUrl确认编辑结果。完整的初始步骤及各场景操作指南:preview_screenshot。references/preview.md - 知识分层:捕获来源(摄入)、整合发现(研究)、固化决策(合并)——这些是流程步骤,不是工具调用;不存在工具。摄入流程详见此处(
ingest);研究与合并流程随references/ingest-and-sources.md包提供。分层模型及包说明:knowledge-base。references/starter-packs.md - 直接问题处理:对于普通业务问题(如“哪些客户…“、“关于…我们的决策是什么…”),直接使用/
search工具并给出带引用的聊天回复——无需使用“research”关键词。仅当内容具备持久性、跨文档性且未被现有内容覆盖时才进行持久化,并且先向用户确认。详见exec。references/corpus-qa.md - 编写或改进Skill(如“编写/制作Skill”、“改进此Skill”、“将此内容转为Skill”):立即停止当前操作并调用**** Skill——它负责管理范围选择(项目级 vs 全局级)、SKILL.md契约、评估及安装;请勿自行操作。通过
open-knowledge-write-skill目标进行编写(skill),绝对不要直接操作路径文档。Skill是编辑器目录下write({ skill })(skills/·.claude·.cursor·.codex·.opencode·.pi)中的真实文件夹:其中一个是源文件夹,其余为管理副本/符号链接。必须通过工具(.agents、skills)进行读写操作——它们会自动路由到源文件夹。绝对不要手动编辑非源文件夹的副本:未编辑的副本会从源文件夹同步更新,编辑副本会将其分叉为独立Skill并停止同步。edit({ skill })
Tool index — 21 tools (router; the MCP tool descriptions carry each tool's full contract)
工具索引——21个工具(路由;MCP工具描述包含各工具的完整契约)
- Reads — (primary; read-only
exec/cat/ls/… plus frontmatter/backlink/history enrichment; one command or one pipe, not a shell),grep(ranked BM25 + recency),search(doc versions),history(links, or an array for one call),kind: backlinks|forward|dead|orphans|hubs|suggest(search + read:skills→ skills.sh; omitqueryto LIST managed (Project + Global);nameREADs one — byname+name, never path),scope(resolved config),config(authoring forms +palettestarters + theme tokens;html previewfor JSX schemas),palette({ components })(browser preview URL on demand),preview_url(GitHub-substrate share URL; read-only, errors without a GitHub remote),share_link(markdown-lint violations:lintfor one doc, omit for the project;documentwithfix: trueauto-fixes fixable rules in place — attributed, live in the preview; the rest needdocument/edit),write(every lint violation + broken internal link in one read-only report, by source file with lines;auditscopes; for link VALIDATION use this, notpath).links - Writes — four native CRUD verbs, polymorphic over /
document/folder/template/skill(pass EXACTLY ONE target, nested under its address key):asset(create/overwrite;writeauthors a skill as a REAL folder at the project's default skill home — live immediately for that folder's agent),write({ skill: {…} })(body find/replace/frontmatter merge-patch; no asset),edit(remove),delete(move/rename, rewrites referrers; a skill also takesmove/scopefor Project↔Global — history resets, re-toScope). Output mirrors the input key; the preview envelope (install,previewUrl) stays top-level. Pluswarning(WHERE ainstalllives:skill/addlocations additively — editor ids,remove, or custom roots;agents+modere-form ONLY the locations named;convertmoves the real folder. The source folder IS the skill — no "uninstall everywhere"; a skill dies only viasource),delete(acquire a skill-dir intoimport's locations; scripts never run),add(named version), andcheckpoint(roll back). A folder's frontmatter is open-shape and self-only (does NOT cascade); templates are what new docs start with.restore_version - Conflicts — (
conflicts),kind: list|content(write a resolution + commit; destructive). Seeresolve_conflict.references/conflict-resolution.md
Self-correcting on misuse: constraints JSON Schema can't express ("exactly one target", " needs a ", body-XOR-frontmatter) return with a one-line corrective shape. Read it and retry with that shape; don't guess.
findreplaceisError: trueTools NOT in OK MCP (your host's): , , , , native / / / . The STOP rule governs which you may use on in-scope markdown.
preview_startpreview_screenshotWebFetchWebSearchReadGrepGlobEdit- 读取类工具 — (主要工具;支持只读的
exec/cat/ls/…操作,以及前置元数据/反向链接/历史记录增强;仅支持单个命令或单管道,不支持完整shell)、grep(基于BM25算法排序+时效性)、search(文档版本记录)、history(支持links,或传入数组一次性查询多种类型)、kind: backlinks|forward|dead|orphans|hubs|suggest(搜索+读取:传入skills调用skills.sh;省略query参数列出所有已管理的Skill(项目级+全局级);传入name参数读取单个Skill——通过name+name定位,绝对不要通过路径)、scope(已解析的配置)、config(创作表单+palette模板+主题令牌;传入html preview获取JSX模式)、palette({ components })(按需生成浏览器预览URL)、preview_url(基于GitHub的共享URL;只读,无GitHub远程仓库时会报错)、share_link(Markdown检查违规:传入lint检查单个文档,省略则检查整个项目;传入document并指定fix: true可自动修复可修复的规则——修复结果会实时显示在预览中;其余问题需使用document/edit手动修复)、write(生成包含所有检查违规及无效内部链接的只读报告,按源文件及行号展示;传入audit指定检查范围;链接验证请使用此工具,不要使用path)。links - 写入类工具 — 四个原生CRUD动词,可作用于/
document/folder/template/skill(必须传入且仅传入一个目标,嵌套在对应键下):asset(创建/覆盖;write在项目默认Skill目录下创建真实文件夹形式的Skill——对该文件夹的Agent立即生效)、write({ skill: {…} })(正文内容替换/前置元数据合并更新;不支持asset)、edit(删除)、delete(移动/重命名,自动更新引用;Skill还支持move/scope参数实现项目级↔全局级迁移——历史记录会重置,需重新toScope)。输出结构与输入键对应;预览信封(install、previewUrl)保持在顶层。此外还有warning(指定Skill的安装位置:install/add参数可增量添加/移除位置——编辑器ID、remove或自定义根目录;agents+mode参数仅修改指定位置的格式;convert参数移动源文件夹。源文件夹即为Skill本身——不存在“全局卸载”;仅通过source可删除Skill)、delete(将Skill目录导入import指定的位置;不会运行脚本)、add(创建命名版本)、checkpoint(回滚版本)。文件夹的前置元数据为开放结构且仅作用于自身(不会向下级联到子文档);模板是新文档的初始内容。restore_version - 冲突处理工具 — (支持
conflicts)、kind: list|content(写入解决方案并提交;具有破坏性)。详见resolve_conflict。references/conflict-resolution.md
误用自动纠正:JSON Schema无法表达的约束(如“必须且仅传入一个目标”、“必须搭配”、正文与前置元数据二选一)会返回及一行纠正说明。请根据说明重新尝试,不要自行猜测。
findreplaceisError: true不属于OK MCP的工具(宿主工具):、、、、原生///。STOP规则管控着哪些工具可用于范围内的Markdown文件。
preview_startpreview_screenshotWebFetchWebSearchReadGrepGlobEditSTOP — native tools on in-scope .md
/ .mdx
.md.mdxSTOP规则——禁止对范围内的.md
/.mdx
使用原生工具
.md.mdxRoute every in-scope markdown read and write through OK's MCP tools — never your host's native file tools. Native / / direct on in-scope markdown bypasses the CRDT and loses agent attribution in the shadow repo; native reads skip frontmatter, backlinks, shadow-repo activity, and project git history that OK returns for every matched file. When this workspace has OpenKnowledge MCP configured, do not use native file tools on markdown paths inside the content directory. The ban covers every common rationalization:
EditsedWrite- Native /
Read/Grepon in-scopeGlob/.md— the original case..mdx - /
Bash ls/Bash findon dirs containing in-scope markdown — useBash cat/exec("ls -A …")/exec("find … -name '*.md'"). Native returns bare names;exec("cat …")returns frontmatter, backlink counts, and recent activity.execshows hidden entries (-A,.ok/) without the.okignore/.noise... - Glob patterns that target markdown (,
**/*.md,specs/**,reports/**) — usedocs/**withexecorfind.exec("ls -A <dir>") - Dispatching the Explore / general-purpose subagent for markdown-heavy exploration — subagents use native tools internally and bypass OK. Do markdown exploration yourself via /
exec. Subagents remain appropriate for source-code exploration.search - Native /
Readon in-scope markdown insideGrep—.ok/is in-scope; treat its.ok//.mdlike any other KB file..mdx - /
ls/caton skill folders to discover or read a skill — skills are addressed byfind+name, not by path (a skill can live in any editor dir, thescopehub, or a custom root, with copies elsewhere). Use the.agents/skills/tool.skills
Not seeing is NOT the escape hatch. Wiring, labels, and tool visibility vary by client; some (notably Codex) defer MCP tools behind lazy discovery. Registration is the test, not top-level-symbol visibility — run tool discovery for first. Detail: .
execopen-knowledgereferences/setup.mdEscape hatch. Native / / on / is allowed only when, after running tool discovery (above), no OpenKnowledge MCP server is registered for this project, or immediately after you actually invoked an MCP call and it failed — then begin a user-visible sentence with . "Not registered" is a conclusion you may only reach after tool discovery turned it up empty — never from the initial tool list alone. Never use the hatch because you skipped your client's MCP path, didn't see as a top-level tool, didn't run tool discovery, or rationalized the skill wasn't necessary.
ReadGrepGlob.md.mdxOpenKnowledge MCP unavailable:execSource code and non-markdown files (, , , …): native / / always.
.ts.pypackage.jsonReadGrepGlob所有范围内Markdown文件的读写操作必须通过OK的MCP工具完成——绝对禁止使用宿主的原生文件工具。对范围内Markdown文件使用原生//直接会绕过CRDT,并在影子仓库中丢失Agent操作记录;原生读取工具会忽略前置元数据、反向链接、影子仓库活动及项目Git历史,而这些信息OK会为每个匹配文件返回。当工作区已配置OpenKnowledge MCP时,绝对不要对内容目录内的Markdown路径使用原生文件工具。此禁令涵盖所有常见的合理化借口:
EditsedWrite- 对范围内/
.md使用原生.mdx/Read/Grep——最基础的禁止场景。Glob - 对包含范围内Markdown文件的目录使用/
Bash ls/Bash find——请使用Bash cat/exec("ls -A …")/exec("find … -name '*.md'")。原生工具仅返回名称;exec("cat …")会返回前置元数据、反向链接计数及最近活动。exec参数会显示隐藏条目(-A、.ok/)且不包含.okignore/.冗余内容。.. - 目标为Markdown的Glob模式(、
**/*.md、specs/**、reports/**)——请搭配docs/**使用find或exec。exec("ls -A <dir>") - 调用Explore/通用子Agent进行Markdown内容探索——子Agent内部使用原生工具,会绕过OK。请自行通过/
exec进行Markdown内容探索。子Agent仍适用于源代码探索。search - 对目录内的范围内Markdown文件使用原生
.ok//Read——Grep属于范围之内;其.ok//.md文件需按普通知识库文件处理。.mdx - 对Skill文件夹使用/
ls/cat来发现或读取Skill——Skill通过find+name定位,而非路径(Skill可位于任何编辑器目录、scope中心或自定义根目录,并在其他位置存在副本)。请使用.agents/skills/工具。skills
未看到工具并非免责理由。不同客户端的配置、标签及工具可见性有所不同;部分客户端(尤其是Codex)会延迟加载MCP工具。请先运行工具发现,再判断是否可用,不要仅通过初始工具列表判断。详细说明:。
execopen-knowledgereferences/setup.md例外情况:仅当运行工具发现后(如上所述),发现此项目未注册OpenKnowledge MCP服务器,或实际调用MCP工具后失败时,才允许对/使用原生//工具——此时需在面向用户的回复开头加上。“未注册”结论仅能在工具发现无结果后得出——绝对不要仅通过初始工具列表判断。绝对不要因跳过客户端MCP路径、未在顶层工具中看到、未运行工具发现或认为本Skill不必要而使用例外情况。
.md.mdxReadGrepGlobOpenKnowledge MCP unavailable:exec源代码及非Markdown文件(、、等):始终允许使用原生//工具。
.ts.pypackage.jsonReadGrepGlobReads — examples
读取操作示例
- Read a file: — contents + full enrichment.
exec("cat <path>.md") - List a directory: — per-child frontmatter, recursive markdown counts, most-recently-updated doc per subdir, the folder's own
exec("ls -A <dir>")/title/description+tags. Prefertemplates_availableover plain-A.ls - Literal search: — matches + enrichment on matched files.
exec("grep -rn <term> <dir> | head -5") - Ranked search: — title boost + body BM25 + recency; use when picking the best doc, not when listing every occurrence.
search({ query })
- 读取文件:——返回内容+完整增强信息。
exec("cat <path>.md") - 列出目录:——返回每个子项的前置元数据、递归Markdown文件计数、每个子目录中最近更新的文档、文件夹自身的
exec("ls -A <dir>")/title/description+tags。优先使用templates_available而非普通-A。ls - 精确匹配搜索:——返回匹配结果+匹配文件的增强信息。
exec("grep -rn <term> <dir> | head -5") - 排序检索:——标题权重+正文BM25算法+时效性;用于筛选最佳文档,而非列出所有匹配项。
search({ query })
Writing
写入操作
Call / as soon as you have content (route through MCP per the STOP rule).
writeeditPersist incrementally — the knowledge base IS your checkpoint (MUST). On any multi-step or long-running task — a research sweep, a multi-source synthesis, a batch of docs — write completed work to the KB as you finish each unit: per section, per source, per doc. Never hold finished findings only in your context waiting for one final write at the end. A rate limit, crash, or context compaction mid-task discards everything still unwritten; work already persisted survives, and you resume by reading the doc back. Create the target doc early (skeleton + frontmatter), then each section in as it firms up.
editPass a on every content write (SHOULD) — a one-line (≤80 char) user-facing note; it becomes the timeline entry. Reach for visual structure (Callout, , table, ) where it carries the point better than prose; call as you draft. Advisory write-warnings, MDX authoring, delete/move mechanics, and visual authoring: + + .
summarymermaidhtml previewpalettereferences/writing.mdreferences/components-and-visuals.mdreferences/media-and-assets.md一旦准备好内容,请立即调用/(遵循STOP规则通过MCP路由)。
writeedit增量持久化——知识库即为你的检查点(强制要求)。对于任何多步骤或长时间运行的任务——研究扫描、多源整合、批量文档处理——完成每个单元后立即将工作内容写入知识库:按章节、按来源、按文档分别写入。绝对不要将已完成的结果仅保存在上下文中等候最终一次性写入。任务中途的速率限制、崩溃或上下文压缩会丢失所有未写入的内容;已持久化的工作会保留,你可通过读取文档恢复任务。尽早创建目标文档(框架+前置元数据),然后在每个章节确定后使用添加内容。
edit每次写入内容时建议传入——一行(≤80字符)面向用户的说明;它会成为时间线条目。优先使用可视化结构(提示框、、表格、),当它们比 prose 更能清晰表达观点时;编写时可调用工具。写入警告、MDX创作、删除/移动机制及可视化创作说明:++。
summarymermaidhtml previewpalettereferences/writing.mdreferences/components-and-visuals.mdreferences/media-and-assets.mdGrounding — every factual claim needs a source (MUST)
溯源——每个事实性声明必须有来源(强制要求)
KB docs are factual artifacts: every claim traceable, and the source lives inside the knowledge base, not on the public web.
Ingest is a procedure, not a tool — binary-vs-text classification, SSRF-safe fetch flags, size + executable gates, wrapper frontmatter — in . Read it before your first capture; a naive fetch-and-paste skips every gate.
references/ingest-and-sources.md- Closed loop. External sources are pulled in by the ingest procedure, then cited locally. A bare inside a KB doc is not a citation — it is a TODO meaning "still needs ingesting". The chain only works if every leaf is a local doc.
[source](https://...) - Every factual claim MUST cite its source at the point of claim. No unsourced speculation.
- Web sources → fetch the page (host /
WebFetch), ingest it, then cite the path:WebSearch(the local doc carries[source name](./path/to/source.md)). Inlinesource_url:is a chat affordance, not a KB one.[source](URL) - Self-fetched counts. A URL YOU fetched to ground a claim gets the same ingest — no inline-URL downgrade.
- Internal cross-refs → link the OK doc holding the authoritative claim; that doc cites its own sources (chains terminate in preserved local docs).
- No evidence? Search and ingest the result, OR mark , OR don't write the claim. Do NOT fabricate — unsourced speculation rots into untraceable tribal lore.
(TODO: needs source)
知识库文档是事实性产物:每个声明必须可追溯,且来源必须位于知识库内部,而非公共网络。
摄入是流程,不是工具——包含二进制与文本分类、SSRF安全的获取标志、大小与可执行文件限制、包装前置元数据——详见。首次捕获来源前请阅读此文档;直接获取并粘贴会跳过所有限制。
references/ingest-and-sources.md- 闭环原则:外部来源需通过摄入流程导入,然后在本地引用。知识库文档中的裸链接不是有效引用——它是一个待办事项,意为“仍需摄入”。只有当每个叶子节点都是本地文档时,溯源链才有效。
[source](https://...) - 每个事实性声明必须在声明处引用来源。禁止无来源的推测。
- 网络来源 → 获取页面(使用宿主/
WebFetch)、摄入、然后引用路径:WebSearch(本地文档需包含[source name](./path/to/source.md)字段)。聊天中可使用内联source_url:,但知识库中禁止使用。[source](URL) - 自行获取的来源同样适用。你为验证声明而获取的URL需按相同流程摄入——不能降级为内联URL。
- 内部交叉引用 → 链接持有权威声明的OK文档;该文档会引用自身的来源(溯源链终止于已保存的本地文档)。
- 无证据? 搜索并摄入结果,OR标记,OR不写入该声明。绝对不要编造内容——无来源的推测会演变为无法追溯的隐性知识。
(TODO: needs source)
Linking — standard markdown links (MUST)
链接——使用标准Markdown链接(强制要求)
Link every noun-phrase that names another document — — and link liberally. Every link must resolve to a doc that exists by the time you're done (a same-pass forward-reference you create later in the pass is fine; for one that genuinely won't exist, leave the mention as plain prose + a tracked task). Never backtick a link ( is a bug) and never use HTML . Read on every / response: means all links resolve; a populated list names each broken + ( / / ) — fix them in a follow-up . is the authoritative end-state link check (the editor's red-underline is slug-tolerant and lies, so trust the tool). External web sources are NOT inline body links (see Grounding). Full rule set + the legacy note: .
[text](./relative/path.md)`[text](./foo.md)`<a>brokenLinkswriteedit[]hrefreasonno-such-docno-such-fileunresolvableeditaudit[[Page]]references/linking.md为每个指代其他文档的名词短语添加链接————并尽量多添加链接。所有链接必须在你完成操作时可解析(同一流程中后续创建的前置引用是允许的;对于确实不会存在的引用,请保留为普通文本+跟踪任务)。绝对不要为链接添加反引号(是错误),也不要使用HTML 标签。每次/响应时请查看字段:表示所有链接均可解析;非空列表会列出每个无效及原因(//)——请通过后续修复。是权威的最终状态链接检查工具(编辑器的红色下划线对路径容错且不准确,请信任工具结果)。外部网络来源不允许作为正文中的内联链接(详见溯源部分)。完整规则集+历史说明:。
[text](./relative/path.md)`[text](./foo.md)`<a>writeeditbrokenLinks[]hrefno-such-docno-such-fileunresolvableeditaudit[[Page]]references/linking.mdFolders, frontmatter, templates
文件夹、前置元数据与模板
Every / needs YAML frontmatter — + required, recommended. Two opt-in, nested folder mechanisms: folder frontmatter ( — the folder's own open-shape properties; self-only, does NOT cascade into child docs) and templates ( — what new docs start with). Most folders have NO . A doc's frontmatter is exactly its own on-disk YAML. Structural model + the full pre-write checklist: . Template authoring + folder editing: . Frontmatter-vs-body edit rules: .
.md.mdxtitledescriptiontags<folder>/.ok/frontmatter.yml<folder>/.ok/templates/.ok/references/folder-model.mdreferences/template-authoring.mdreferences/doc-editing.md- Read the folder before writing (MUST). Before creating/editing docs in a folder, call once per folder per session — it returns the folder's
exec("ls -A <folder>")/title/description+tags. Skipping it lands docs that violate folder discipline. (If a folder has no frontmatter AND no templates AND the repo has substantial content elsewhere, it isn't onboarded — runtemplates_availablefirst.)references/onboard-existing-repo.md - Use a template when one fits (MUST). Instantiate via ; inherited templates count. Skip only when none match or the user asked for free-form (note why in chat). Create templates proactively when a shape recurs.
write({ document: { path, template } }) - When recurring per-doc properties emerge (MUST). Writing the same frontmatter on multiple siblings → bake those starting values into a template (). Folder frontmatter does not cascade values into docs.
write({ template })
每个/文件必须包含YAML前置元数据——+为必填项,为推荐项。两种可选的嵌套文件夹机制:文件夹前置元数据(——文件夹自身的开放结构属性;仅作用于自身,不会向下级联到子文档)和模板(——新文档的初始内容)。大多数文件夹没有目录。文档的前置元数据完全等同于其磁盘上的YAML内容。结构模型+完整写入前检查清单:。模板创作+文件夹编辑说明:。前置元数据与正文编辑规则:。
.md.mdxtitledescriptiontags<folder>/.ok/frontmatter.yml<folder>/.ok/templates/.ok/references/folder-model.mdreferences/template-authoring.mdreferences/doc-editing.md- 写入前先读取文件夹信息(强制要求)。在文件夹中创建/编辑文档前,每个会话每个文件夹需调用一次——它会返回文件夹的
exec("ls -A <folder>")/title/description+tags。跳过此步骤会导致文档违反文件夹规范。(如果文件夹没有前置元数据且没有模板,同时仓库其他位置有大量内容,则说明该文件夹未纳入管理——请先运行templates_available。)references/onboard-existing-repo.md - 合适时使用模板(强制要求)。通过实例化;继承的模板同样有效。仅当没有匹配模板或用户要求自由格式时才跳过(请在聊天中说明原因)。当某种结构重复出现时,请主动创建模板。
write({ document: { path, template } }) - 当出现重复的文档属性时(强制要求)。如果多个同级文档使用相同的前置元数据,请将这些初始值整合到模板中()。文件夹前置元数据不会向下级联到文档。
write({ template })
Conflict-aware writes
冲突感知写入
Projects with GitHub sync may carry docs in merge-conflict state; mutating calls against them return RFC 9457 (409). Detect proactively — returns ; on switch to the + flow. Full flow: .
urn:ok:error:doc-in-conflictexec("cat <path>.md")lifecycle: {status, reason} | nullstatus === 'conflict'conflictsresolve_conflictreferences/conflict-resolution.md开启GitHub同步的项目可能存在处于合并冲突状态的文档;对这些文档进行修改会返回RFC 9457 (409)错误。请主动检测——会返回;当时,请切换到+流程。完整流程:。
urn:ok:error:doc-in-conflictexec("cat <path>.md")lifecycle: {status, reason} | nullstatus === 'conflict'conflictsresolve_conflictreferences/conflict-resolution.mdAnti-patterns — the top offenders
反模式——常见错误
| Task | Don't | Do |
|---|---|---|
| List / find / read markdown | | |
| Explore a markdown-heavy dir | | |
| Reference another doc | | |
| Embed an image | | save locally + |
| Factual claim in a KB doc | prose with no citation, OR inline | ingest the source ( |
| Confirm an edit landed | | trust the CRDT tool response |
| Delete a markdown doc | | |
| Write in an unfamiliar folder | straight to | |
Full table: .
references/anti-patterns.md| 任务 | 禁止操作 | 正确操作 |
|---|---|---|
| 列出/查找/读取Markdown | | |
| 探索Markdown内容较多的目录 | | 自行使用 |
| 引用其他文档 | | |
| 嵌入图片 | | 保存到本地 + |
| 知识库文档中的事实性声明 | 无引用的 prose,OR内联 | 摄入来源( |
| 确认编辑已生效 | | 信任CRDT工具的响应 |
| 删除Markdown文档 | | |
| 在不熟悉的文件夹中写入 | 直接调用 | 先调用 |
完整表格:。
references/anti-patterns.mdKnowledge layers — the shape most KB work takes
知识分层——知识库工作的典型模式
Three recurring practices, not tool calls — each a full procedure that ships as skill guidance.
| Layer | When | Procedure |
|---|---|---|
| ingest | Preserve a shared URL/PDF/file verbatim, or you fetched a URL to ground a claim (binary sources preserved, not scraped). | |
| research | Investigate / compare / synthesize sources → | |
| consolidate | A decision was made → canonical source-of-truth with a | |
Research and consolidate arrive with . Without that pack you do not have those procedures — don't improvise one; do the work as an ordinary grounded , or offer to seed it ( shows what it would add).
ok seed --pack knowledge-basewriteok seed --pack knowledge-base --dry-runDon't chain silently: let the user drive ingest → research → consolidate, and a procedure's STOP gates override session-level "don't stop to ask" hints. After any turn that changes KB content, check for a and follow its contract (). Interleave a multi-doc batch so the preview shows narrative progress.
log.mdreferences/cadence-and-logs.mdOnboarding a repo that already has content: . Layer model + packs: .
references/onboard-existing-repo.mdreferences/starter-packs.md三种重复出现的实践,不是工具调用——每种都是完整流程,作为Skill指南提供。
| 分层 | 适用场景 | 流程说明 |
|---|---|---|
| 摄入 | 需完整保存共享URL/PDF/文件,或你为验证声明而获取了URL(二进制来源需完整保存,而非抓取)。 | |
| 研究 | 调查/比较/整合来源 → 生成 | |
| 合并 | 已做出决策 → 生成带 | |
研究与合并流程随提供。未安装此包则无法使用这些流程——请勿自行创造;请作为普通的带溯源操作完成工作,或向用户提议安装此包(可展示会添加的内容)。
ok seed --pack knowledge-basewriteok seed --pack knowledge-base --dry-run请勿静默执行流程链:请让用户驱动摄入→研究→合并流程,且流程的STOP规则会覆盖会话级“无需询问”提示。任何修改知识库内容的操作后,请检查是否存在并遵循其契约()。多文档批量操作时请交替进行,以便预览展示进度。
log.mdreferences/cadence-and-logs.md已有内容的仓库纳入管理:。分层模型及包说明:。
references/onboard-existing-repo.mdreferences/starter-packs.mdServer lifecycle
服务器生命周期
If / returns , run (via Bash) and retry. Never fall back to native / for in-scope markdown.
writeedit"Hocuspocus server is not running"ok startEditWrite如果/返回,请通过Bash运行并重试。绝对不要 fallback 到原生/工具处理范围内的Markdown文件。
writeedit"Hocuspocus server is not running"ok startEditWriteScope recap
范围回顾
OK looks for documents under the resolved (runtime: ); and (at root or any folder depth) define exclusions. Every / under not excluded is an OpenKnowledge document — including under , , . Folder metadata + templates live in nested , not in . Working in a git worktree? Pass the worktree's absolute path as on your OK tool calls once — it sticks for the session, so reads, writes, and the preview all target that worktree.
content.dirconfig({ key: 'content.dir' }).gitignore.okignore.md.mdxcontent.dirspecs/reports/docs/<folder>/.ok/.ok/config.ymlcwdOK会在已解析的下查找文档(运行时可通过查看);和(根目录或任何文件夹深度)定义排除规则。下未被排除的所有/文件均为OpenKnowledge文档——包括、、下的文件。文件夹元数据+模板存储在嵌套的目录中,而非。在Git工作树中工作? 请在OK工具调用中传入工作树的绝对路径作为——会话中会保持此设置,因此读取、写入及预览都会指向该工作树。
content.dirconfig({ key: 'content.dir' }).gitignore.okignorecontent.dir.md.mdxspecs/reports/docs/<folder>/.ok/.ok/config.ymlcwd