opencli-sitemap-author
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseopencli-sitemap-author
opencli-sitemap-author
You are authoring a task execution graph for agents, not an SEO sitemap. The artifact should help an agent using decide where it is, what path to take next, which OpenCLI adapter to prefer, and how to recover when the page disagrees with memory.
opencli browserKeep the sitemap small and verified. Do not crawl a whole site. Capture only task-relevant paths that you actually observed.
你正在编写一份面向Agent的任务执行图谱,而非SEO站点地图。该成果应帮助使用的Agent判断当前位置、下一步路径、优先选择的OpenCLI Adapter,以及当页面与记忆不符时如何恢复。
opencli browser请保持站点地图精简且经过验证。不要爬取整个站点,仅记录你实际观察到的与任务相关的路径。
Storage Model
存储模型
Two layers:
- Global seed: (top-level)
sitemaps/<site>/ - Local overlay:
~/.opencli/sites/<site>/sitemap/
Local overlay wins by stable id. Write new discoveries to local first. Promote to global only after review.
Recommended layout:
text
sitemap/
SITE.md # site purpose, auth assumptions, stable page ids
pages/<page-id>.md # page state signatures, actions, linked APIs
pages/_<partial>.md # cross-page UI partial (e.g. _tweet_card.md)
workflows/<task-id>.md # best path, fallback path, avoid list
pitfalls.md # durable failure modes and stale areas两层结构:
- 全局种子:(顶层目录)
sitemaps/<site>/ - 本地覆盖层:
~/.opencli/sites/<site>/sitemap/
本地覆盖层通过稳定ID优先级更高。新发现的内容先写入本地,仅在审核后同步到全局。
推荐目录结构:
text
sitemap/
SITE.md # 站点用途、认证假设、稳定页面ID
pages/<page-id>.md # 页面状态签名、操作、关联API
pages/_<partial>.md # 跨页UI片段(例如 _tweet_card.md)
workflows/<task-id>.md # 最优路径、降级路径、避坑列表
pitfalls.md # 常见失败模式及过时区域Size guidance(实测启发式)
篇幅指导(实测启发式)
references/sitemap-schema.mdspec 800 是 lazy-load 优化目标 + Phase 2 audit 阈值;下表是 author 实战决策辅助,不替代 spec hard 限制。超 800 的文件 audit 会 flag,author 解释("5 个 cohesive UI primitive 一起放")或拆。
| 文件 token | 决策 |
|---|---|
| < 1500 | 自然 size,不动 |
| 1500-3000 | 看 cohesion — 5 个 cohesive UI primitive 一起放 OK;mixed 内容拆 |
| > 3000 | 必拆 sub-file 或 partial(agent lazy load budget 真有限制) |
Phase 2 cron audit 按 token count 不按 byte count(CJK 中文 token-per-char 比 English 高 30-50%)。
references/sitemap-schema.md规范中的800 token是懒加载优化目标+第二阶段审核阈值;下表为作者实战决策辅助,不替代规范的硬性限制。超过800 token的文件会在审核中被标记,作者需解释(如“5个关联的UI原语放在一起”)或拆分。
| 文件token数 | 决策 |
|---|---|
| < 1500 | 保持自然篇幅,无需调整 |
| 1500-3000 | 看内容关联性——5个关联的UI原语放在一起没问题;混合内容则拆分 |
| > 3000 | 必须拆分为子文件或片段(Agent的懒加载预算确实有限制) |
第二阶段定时审核按token数而非字节数计算(CJK中文的字符-token比英文高30-50%)。
Authoring Loop
创作循环
- Load existing memory: read local overlay first, then global seed if present.
- Verify reality: use ,
opencli browser <session> state,find, andnetwork; browser state is truth. If you just completed ananalyzesession for this site, start from the retained browse trace underopencli-adapter-authoras seed evidence instead of re-discovering the path from zero.~/.opencli/sites/<site>/traces/ - Record only durable structure: page purpose, stable anchors, state signature, actions, workflows, API references, pitfalls.
- Use stable ids: page/action/workflow ids should survive URL params, locale text drift, and minor layout changes.
- Write local draft: update unless explicitly promoting to repo.
~/.opencli/sites/<site>/sitemap/... - Mark stale on conflict: if existing sitemap disagrees with current browser state, trust browser state and mark the item stale rather than forcing the old path.
- 加载已有记忆:优先读取本地覆盖层,若存在则再读取全局种子。
- 验证实际情况:使用、
opencli browser <session> state、find和network命令;浏览器状态为事实依据。如果你刚完成针对该站点的analyze会话,请从opencli-adapter-author下保留的浏览轨迹作为种子证据,而非从零重新探索路径。~/.opencli/sites/<site>/traces/ - 仅记录持久化结构:页面用途、稳定锚点、状态签名、操作、工作流、API参考、常见陷阱。
- 使用稳定ID:页面/操作/工作流ID应能在URL参数、区域文本变化及微小布局变更后依然有效。
- 写入本地草稿:更新,除非明确要同步到代码仓库。
~/.opencli/sites/<site>/sitemap/... - 冲突时标记为过时:若现有站点地图与当前浏览器状态不符,请信任浏览器状态并将该条目标记为过时,而非强制沿用旧路径。
Required Action Schema
必填操作Schema
Every action edge must include:
yaml
undefined每个操作边必须包含:
yaml
undefinedaction:<stable-id>
action:<stable-id>
pre: <current page / state / auth requirements>
do: <agent action, adapter command, or semantic browser command>
post: <URL / state / output that proves success>
fail: <failure signal 1> | <signal 2>
recover: <fallback instruction>; adapter_health_update: <adapter> -> suspect
evidence: opencli browser <cmd> or trace:<path>
Use this compact form by default. Use the longer Markdown form from `references/sitemap-schema.md` only when an action genuinely needs long explanation. `verified_at` and `source` are inherited from file frontmatter; do not repeat them per action.
Do not promote an action without evidence. If a recovery path marks `adapter_health_update`, the browser-sitemap consumer must write that health update to the local overlay so the next agent does not retry a known-suspect adapter.pre: <当前页面/状态/认证要求>
do: <Agent操作、Adapter命令或语义化浏览器命令>
post: <证明成功的URL/状态/输出>
fail: <失败信号1> | <信号2>
recover: <降级指令>; adapter_health_update: <adapter> -> suspect
evidence: opencli browser <cmd> or trace:<path>
默认使用这种紧凑格式。仅当操作确实需要长篇解释时,才使用`references/sitemap-schema.md`中的长Markdown格式。`verified_at`和`source`从文件前置元数据继承,无需在每个操作中重复。
没有证据的操作请勿同步到全局。如果降级路径标记了`adapter_health_update`,浏览器-站点地图的使用者必须将该健康更新写入本地覆盖层,以便下一个Agent不会重试已知存在问题的Adapter。Partial pages(跨页通用 UI)
页面片段(跨页通用UI)
partial 文件 (,) 装跨页 UI 原语(如 的 like/reply/repost/bookmark)。被多 page 通过 引用。
_<name>.mdurl_patterns: []_tweet_card.mdaction:<id> in pages/_<name>.mdPartial scope rule:partial 内所有 selector(testid / a11y / structural)必须 scoped 到 partial root,不能是 page-level first match。例如 :
_tweet_card.mdyaml
undefined片段文件(,)用于存放跨页UI原语(例如中的点赞/回复/转发/收藏)。可被多个页面通过引用。
_<name>.mdurl_patterns: []_tweet_card.mdaction:<id> in pages/_<name>.md片段范围规则:片段内所有选择器(testid/无障碍标识/结构选择器)必须限定在片段根节点范围内,不能是页面级的首个匹配项。例如:
_tweet_card.mdyaml
undefined❌ 错:page-level first match,会点到 timeline 首条非 target card
❌ 错误:页面级首个匹配项,会点击时间线中第一条非目标卡片
do: click [data-testid="like"]
do: click [data-testid="like"]
✅ 对:scoped 到 article root
✅ 正确:限定在article根节点范围内
do: click [data-testid="like"] in article[role="article"] (card scope)
partial 文件顶部写明 scope root 一行:
```mddo: click [data-testid="like"] in article[role="article"] (card scope)
片段文件顶部需写明一行范围根节点说明:
```mdCard scope rule
卡片范围规则
所有 testid selector 必须 scoped 到 ,不能用 page-level first match。
article[role="article"]
---所有testid选择器必须限定在范围内,不能使用页面级首个匹配项。
article[role="article"]
---Workflow Fields
工作流字段
Each workflow should answer:
- Goal: user-facing task this workflow solves.
- State signature: minimal observable checkpoint for resume after sleep/compaction.
- Best path: prefer existing adapter if it covers the goal.
opencli <site> <command> - Fallback path: browser workflow if the adapter is missing or failing.
- Avoid: tempting paths that waste turns, trigger modals, or rely on unstable selectors.
- Stale markers: last verified date and known layout/API drift signals.
Endpoint/API knowledge should reference ids from when available. Do not duplicate full endpoint schemas inside sitemap files.
endpoints.json每个工作流应包含以下内容:
- 目标:该工作流解决的面向用户的任务。
- 状态签名:休眠/压缩后恢复所需的最小可观察检查点。
- 最优路径:若现有Adapter能覆盖该目标,则优先使用。
opencli <site> <command> - 降级路径:当Adapter缺失或故障时的浏览器工作流。
- 避坑项:诱人但浪费步骤、触发弹窗或依赖不稳定选择器的路径。
- 过时标记:最后验证日期及已知的布局/API变更信号。
端点/API知识应在可用时引用中的ID。请勿在站点地图文件中重复完整的端点Schema。
endpoints.jsonFallback on_adapter_fail:
convention(推荐)
on_adapter_fail:推荐降级on_adapter_fail:
约定
on_adapter_fail:Fallback path 第一行声明触发条件 + adapter_health_update directive,把"为什么走 fallback"和"标 adapter suspect"放一起:
yaml
on_adapter_fail:
- adapter_health_update: opencli twitter post -> suspect
- opencli browser state (verify current page)
- if not on /home: goto /home
- action:open_compose in pages/home.md
- ...比纯 step list 清晰:consumption skill 看到 key 知道这是 adapter-trigger 而非 entry-point fallback,directive 先执行后续才走 steps。schema v1.2 candidate,目前作为 SKILL guideline 推荐。
on_adapter_fail:降级路径第一行需声明触发条件+adapter_health_update指令,将“为何走降级路径”和“标记Adapter为可疑”放在一起:
yaml
on_adapter_fail:
- adapter_health_update: opencli twitter post -> suspect
- opencli browser state (verify current page)
- if not on /home: goto /home
- action:open_compose in pages/home.md
- ...比纯步骤列表更清晰:消费型skill看到关键字就知道这是Adapter触发的降级而非入口级降级,指令会先执行,之后才走步骤流程。这是schema v1.2候选方案,目前作为SKILL指南推荐使用。
on_adapter_fail:SITE.md Top-level routes
— 标 uncovered routes
Top-level routesSITE.md 顶层路由
— 标记未覆盖路由
顶层路由SITE.mdTop-level routesmd
undefinedSITE.md顶层路由md
undefinedTop-level routes
顶层路由
- /home → pages/home.md
- /search → pages/search.md
- /messages → pages/messages.md(DM,本 PoC v1 不覆盖) # ← 显式 uncovered marker
- /settings → 不在 sitemap scope,agent 自探 # ← 同上
不写 = agent 不知该 route 存在;写 + 标 uncovered = agent 知道存在但 sitemap 帮不上忙,自己探。
---- /home → pages/home.md
- /search → pages/search.md
- /messages → pages/messages.md(私信,本PoC v1不覆盖) # ← 显式未覆盖标记
- /settings → 不在站点地图范围内,Agent自行探索 # ← 同上
不写=Agent不知道该路由存在;写+标记未覆盖=Agent知道存在但站点地图无法提供帮助,需自行探索。
---Red Lines
红线规则
- Sitemap is a hint; current browser state is truth.
- Do not write secrets, cookies, user-private ids, private messages, or account-specific values.
- Do not document bypasses for CAPTCHA, WAF, access control, rate limits, or paid gates.
- Do not store brittle snapshot indices like as durable targets. Store semantic anchors and recovery instructions.
[17] - Do not describe unverified paths as facts. Use or
draftlabels.stale - Drafts go inside , not
sitemap/draft-<topic>.mdat the parent level — the latter is invisible to~/.opencli/sites/<site>/sitemap.draft.mdsitemap availability detection.opencli browser
- 站点地图仅为参考;当前浏览器状态才是事实依据。
- 请勿写入密钥、Cookie、用户私有ID、私人消息或账户特定值。
- 请勿记录绕过CAPTCHA、WAF、访问控制、速率限制或付费墙的方法。
- 请勿将这类脆弱的快照索引作为持久化目标。请存储语义锚点和恢复指令。
[17] - 请勿将未验证的路径描述为事实。使用或
draft标签标记。stale - 草稿需放在中,而非父级目录的
sitemap/draft-<topic>.md——后者会被~/.opencli/sites/<site>/sitemap.draft.md的站点地图可用性检测忽略。opencli browser
Detailed schema
详细Schema
See for the full field-level spec — / / / / schemas, action-level state signatures, enum (healthy / suspect / broken), endpoint reference rules, two-layer overlay semantics, draft placement, and Phase 2 validation rules.
references/sitemap-schema.mdSITE.mdpages/<id>.mdworkflows/<id>.mdapis.mdpitfalls.mdadapter_health完整的字段级规范请查看——包含////的Schema、操作级状态签名、枚举(healthy/suspect/broken)、端点引用规则、两层覆盖语义、草稿存放位置及第二阶段验证规则。
references/sitemap-schema.mdSITE.mdpages/<id>.mdworkflows/<id>.mdapis.mdpitfalls.mdadapter_health