wiki-agent

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Wiki Agent — Targeted Cross-Agent History Search + Ingest

Wiki Agent — 跨Agent历史定向搜索与摄入

You are doing a query-driven targeted ingest from one specific AI agent's raw conversation history. The user is typically working in a different agent right now and wants to pull in context from another agent's past sessions.
This is not bulk ingest. You find sessions about a specific topic, extract the relevant blobs, distill them into the wiki, and return a synthesized answer the user can act on immediately.
你将执行基于查询的特定AI Agent原始对话历史定向摄入。用户当前通常在另一个Agent中工作,想要从其他Agent的过往会话中调取上下文信息。
这不是批量摄入。你需要找到与特定主题相关的会话,提取相关内容片段,将其提炼到wiki中,并返回用户可立即使用的合成答案。

Command Routing

命令路由

Parse the invocation to determine the target agent and optional query:
CommandTargetExample
/wiki-claude [query]
Claude Code history
/wiki-claude "how did I set up auth middleware"
/wiki-codex [query]
Codex CLI history
/wiki-codex "rust ownership patterns"
/wiki-hermes [query]
Hermes agent history
/wiki-hermes "memory architecture"
/wiki-openclaw [query]
OpenClaw history
/wiki-openclaw "project planning approach"
/wiki-copilot [query]
Copilot chat history
/wiki-copilot "test strategy for API routes"
If no query is given, default to recent sessions mode: ingest the last 5 unprocessed sessions from that agent and return a summary of what was found. This is equivalent to a focused
wiki-history-ingest
for that agent only.
解析调用指令以确定目标Agent和可选查询:
命令目标示例
/wiki-claude [query]
Claude Code历史记录
/wiki-claude "how did I set up auth middleware"
/wiki-codex [query]
Codex CLI历史记录
/wiki-codex "rust ownership patterns"
/wiki-hermes [query]
Hermes Agent历史记录
/wiki-hermes "memory architecture"
/wiki-openclaw [query]
OpenClaw历史记录
/wiki-openclaw "project planning approach"
/wiki-copilot [query]
Copilot聊天历史记录
/wiki-copilot "test strategy for API routes"
如果未提供查询,默认进入近期会话模式:摄入该Agent的最后5个未处理会话,并返回找到内容的摘要。这相当于针对该Agent的聚焦版
wiki-history-ingest

Before You Start

开始前准备

  1. Read
    ~/.obsidian-wiki/config
    → get
    OBSIDIAN_VAULT_PATH
    .
  2. Read
    $OBSIDIAN_VAULT_PATH/.manifest.json
    → know what's already ingested.
  3. Read
    $OBSIDIAN_VAULT_PATH/hot.md
    if it exists → warm context on recent wiki activity.

  1. 读取
    ~/.obsidian-wiki/config
    → 获取
    OBSIDIAN_VAULT_PATH
  2. 读取
    $OBSIDIAN_VAULT_PATH/.manifest.json
    → 了解已摄入的内容。
  3. 如果存在
    $OBSIDIAN_VAULT_PATH/hot.md
    ,请读取 → 获取wiki近期活动的上下文信息。

Step 1: Locate the Agent's History Root

步骤1:定位Agent的历史记录根目录

AgentDefault pathConfig override
claude
~/.claude
+
~/Library/Application Support/Claude/local-agent-mode-sessions/
CLAUDE_HISTORY_PATH
in
.env
codex
~/.codex
CODEX_HISTORY_PATH
in
.env
hermes
~/.hermes
HERMES_HOME
in env or
.env
openclaw
~/.openclaw
OPENCLAW_HOME
in
.env
copilot
~/.copilot
COPILOT_HISTORY_PATH
in
.env
If the history root doesn't exist, stop and tell the user: "No
<agent>
history found at
<path>
. Have you run
<agent>
on this machine? You can set a custom path with
<CONFIG_VAR>
in
.env
."

Agent默认路径配置覆盖项
claude
~/.claude
+
~/Library/Application Support/Claude/local-agent-mode-sessions/
.env
中的
CLAUDE_HISTORY_PATH
codex
~/.codex
.env
中的
CODEX_HISTORY_PATH
hermes
~/.hermes
环境变量或
.env
中的
HERMES_HOME
openclaw
~/.openclaw
.env
中的
OPENCLAW_HOME
copilot
~/.copilot
.env
中的
COPILOT_HISTORY_PATH
如果历史记录根目录不存在,请停止操作并告知用户:"在
<path>
未找到
<agent>
历史记录。你是否在此机器上运行过
<agent>
?你可以在
.env
中通过
<CONFIG_VAR>
设置自定义路径。"

Step 2: Build Session Inventory

步骤2:构建会话清单

Use the cheapest index source for each agent — don't open session files until you know which ones are relevant.
为每个Agent使用成本最低的索引源——在确定哪些会话相关之前,不要打开会话文件。

Claude

Claude

Primary index:   ~/.claude/projects/  (directories = projects, files = sessions)
Session files:   ~/.claude/projects/*/*.jsonl
Desktop index:   find ~/Library/Application Support/Claude/local-agent-mode-sessions -name "local_*.json"
Signal fields:   sessionId, cwd, startedAt, title (in local_*.json)
Build a list of sessions:
{path, project_dir, modified_at, already_ingested}
.
Primary index:   ~/.claude/projects/  (directories = projects, files = sessions)
Session files:   ~/.claude/projects/*/*.jsonl
Desktop index:   find ~/Library/Application Support/Claude/local-agent-mode-sessions -name "local_*.json"
Signal fields:   sessionId, cwd, startedAt, title (in local_*.json)
构建会话列表:
{path, project_dir, modified_at, already_ingested}

Codex

Codex

Primary index:   ~/.codex/session_index.jsonl
Session files:   ~/.codex/sessions/**/rollout-*.jsonl
Signal fields:   thread_id, name/title, updated_at (in session_index.jsonl)
Read
session_index.jsonl
as the inventory. Each line:
{thread_id, name, updated_at}
. Map thread IDs to rollout files by matching directory names.
Primary index:   ~/.codex/session_index.jsonl
Session files:   ~/.codex/sessions/**/rollout-*.jsonl
Signal fields:   thread_id, name/title, updated_at (in session_index.jsonl)
读取
session_index.jsonl
作为清单。每一行:
{thread_id, name, updated_at}
。通过匹配目录名将线程ID映射到rollout文件。

Hermes

Hermes

Primary index:   ~/.hermes/memories/*.md  (fast to scan)
Session files:   ~/.hermes/sessions/**/*.jsonl
Signal fields:   file names, memory titles, first 3 lines of each memory
Scan memory filenames first (they're often titled by topic). Fall back to session listing.
Primary index:   ~/.hermes/memories/*.md  (fast to scan)
Session files:   ~/.hermes/sessions/**/*.jsonl
Signal fields:   file names, memory titles, first 3 lines of each memory
首先扫描内存文件名(通常按主题命名)。如果没有匹配项,再回退到会话列表。

OpenClaw

OpenClaw

Primary index:   ~/.openclaw/workspace/memory/MEMORY.md  (structured long-term memory)
Daily notes:     ~/.openclaw/workspace/memory/YYYY-MM-DD.md
Session index:   ~/.openclaw/agents/*/sessions/sessions.json
Session files:   ~/.openclaw/agents/*/sessions/*.jsonl
Read
MEMORY.md
sections first — it's the pre-compiled summary of everything. Daily notes give recency signal.
Primary index:   ~/.openclaw/workspace/memory/MEMORY.md  (structured long-term memory)
Daily notes:     ~/.openclaw/workspace/memory/YYYY-MM-DD.md
Session index:   ~/.openclaw/agents/*/sessions/sessions.json
Session files:   ~/.openclaw/agents/*/sessions/*.jsonl
首先读取
MEMORY.md
的章节——这是所有内容的预编译摘要。每日笔记提供时效性信号。

Copilot

Copilot

Primary index:   session filenames / directory listing
Session files:   varies by client (VS Code: ~/.copilot/sessions/*.jsonl or similar)
Signal fields:   session timestamps, file names

Primary index:   session filenames / directory listing
Session files:   varies by client (VS Code: ~/.copilot/sessions/*.jsonl or similar)
Signal fields:   session timestamps, file names

Step 3: Score Sessions Against the Query

步骤3:根据查询为会话评分

If a query was given, score each session in the inventory without opening full session files:
  1. Name/title match — does the session name or thread title contain the query terms? Score: +3
  2. CWD/project match — does the working directory suggest the right project? Score: +2
  3. Recency — sessions from the last 90 days score higher than older ones. Score: +1 per 30-day recency bracket (max +3)
  4. Already ingested — if this session was previously ingested and the wiki page already covers the query (check
    hot.md
    +
    index.md
    ), flag as "covered" but still show in results
Select the top 3–5 sessions by score. If no query was given, select the 5 most recent unprocessed sessions.

如果提供了查询,在不打开完整会话文件的情况下为清单中的每个会话评分:
  1. 名称/标题匹配——会话名称或线程标题是否包含查询词?评分:+3
  2. 工作目录/项目匹配——工作目录是否指向正确的项目?评分:+2
  3. 时效性——近90天内的会话比旧会话得分更高。评分:每30天时间段+1(最高+3)
  4. 已摄入状态——如果该会话之前已被摄入,且wiki页面已覆盖该查询(检查
    hot.md
    +
    index.md
    ),标记为“已覆盖”但仍显示在结果中
选择得分前3-5的会话。如果未提供查询,选择5个最新的未处理会话。

Step 4: Extract the Relevant Blob

步骤4:提取相关内容片段

Open each selected session file and extract only the content relevant to the query. Do not read the full session if it's large — use targeted extraction.
打开每个选中的会话文件,仅提取与查询相关的内容。如果会话文件较大,不要读取完整内容——使用定向提取。

Per-Agent Extraction Strategy

各Agent提取策略

Claude (JSONL conversation):
  • Each line:
    {role, content, timestamp, ...}
  • Search with:
    grep -i "<query terms>" <session.jsonl>
    to find the relevant lines
  • Extract: the surrounding conversation window (10 lines before + 20 lines after each hit)
  • Special signal: tool calls (Read/Write/Bash/Edit) reveal what was actually done — extract these even without keyword matches if they're in the relevant window
Codex (rollout JSONL):
  • Each line:
    {type: "session_meta|turn_context|event_msg|response_item", ...}
  • Filter to
    type: "event_msg"
    (user turns) and
    type: "response_item"
    (model output)
  • Search with:
    grep -i "<query terms>" <rollout.jsonl>
  • Extract: matching turns + their parent context (the
    turn_context
    preceding the match)
  • Skip:
    session_meta
    events (operational metadata, not knowledge)
Hermes (memory files + session JSONL):
  • For memory files: read the full file (they're short — typically <500 words each)
  • For session JSONL:
    grep -i "<query terms>"
    + surrounding window
  • Memory files with title matches → read fully; others → grep only
OpenClaw (MEMORY.md + daily notes + session JSONL):
  • MEMORY.md
    : grep for section headers containing query terms → extract that section
  • Daily notes: grep most recent 30 days for query terms → extract matching paragraphs
  • Session JSONL: same grep-window approach as Claude
  • Prefer MEMORY.md/daily notes over session JSONL (they're pre-synthesized)
Copilot (session JSONL):
  • Same grep-window approach as Claude
  • Look for checkpoint files if available (pre-summarized)

Claude(JSONL对话):
  • 每一行:
    {role, content, timestamp, ...}
  • 搜索方式:
    grep -i "<query terms>" <session.jsonl>
    查找相关行
  • 提取内容:匹配内容前后的对话窗口(匹配项前10行+后20行)
  • 特殊信号:工具调用(Read/Write/Bash/Edit)显示实际操作内容——即使没有关键词匹配,只要在相关窗口内也要提取这些内容
Codex(rollout JSONL):
  • 每一行:
    {type: "session_meta|turn_context|event_msg|response_item", ...}
  • 筛选
    type: "event_msg"
    (用户轮次)和
    type: "response_item"
    (模型输出)
  • 搜索方式:
    grep -i "<query terms>" <rollout.jsonl>
  • 提取内容:匹配的轮次及其父上下文(匹配项之前的
    turn_context
  • 跳过:
    session_meta
    事件(操作元数据,非知识内容)
Hermes(内存文件+会话JSONL):
  • 对于内存文件:读取完整文件(文件较短,通常<500词)
  • 对于会话JSONL:使用
    grep -i "<query terms>"
    + 上下文窗口
  • 标题匹配的内存文件→完整读取;其他→仅使用grep搜索
OpenClaw(MEMORY.md+每日笔记+会话JSONL):
  • MEMORY.md
    :搜索包含查询词的章节标题→提取该章节
  • 每日笔记:搜索最近30天内的查询词→提取匹配段落
  • 会话JSONL:采用与Claude相同的grep窗口方法
  • 优先使用MEMORY.md/每日笔记而非会话JSONL(它们是预合成的)
Copilot(会话JSONL):
  • 采用与Claude相同的grep窗口方法
  • 如果有 checkpoint 文件(预摘要),优先使用

Step 5: Distill Blobs into Wiki Pages

步骤5:将内容片段提炼到Wiki页面

For each extracted blob, determine where it belongs in the wiki:
  1. Check if a wiki page already covers this — grep
    index.md
    and page frontmatter for the topic. If yes, update the existing page rather than creating a new one.
  2. Determine category using standard rules (from
    llm-wiki/SKILL.md
    ):
    • Technique / how-to →
      skills/
    • Abstract concept / pattern →
      concepts/
    • Tool / library / person →
      entities/
    • Cross-cutting insight →
      synthesis/
  3. Write or update the page with required frontmatter:
    yaml
    ---
    title: <topic>
    category: skill|concept|entity|synthesis
    tags: [tag1, tag2]
    sources: [<agent>://<path/to/session>]
    created: <date>
    updated: <date>
    confidence: high|medium|low
    lifecycle: stable|draft
    ---
    Set
    sources
    with the agent prefix so
    memory-bridge
    can find it later.
  4. Add cross-links to related wiki pages found in
    index.md
    .
Distillation rules (same as all ingest skills):
  • Extract durable knowledge, not operational telemetry
  • One wiki page per concept, not one per session
  • Merge into existing pages rather than duplicating
  • Keep the signal: decisions made, patterns discovered, techniques that worked, bugs explained

对于每个提取的内容片段,确定其在wiki中的归属:
  1. 检查是否已有wiki页面覆盖该主题——在
    index.md
    和页面前置元数据中搜索该主题。如果有,更新现有页面而非创建新页面。
  2. 确定分类使用标准规则(来自
    llm-wiki/SKILL.md
    ):
    • 技术/操作指南 →
      skills/
    • 抽象概念/模式 →
      concepts/
    • 工具/库/人物 →
      entities/
    • 跨领域见解 →
      synthesis/
  3. 编写或更新页面并添加所需前置元数据:
    yaml
    ---
    title: <topic>
    category: skill|concept|entity|synthesis
    tags: [tag1, tag2]
    sources: [<agent>://<path/to/session>]
    created: <date>
    updated: <date>
    confidence: high|medium|low
    lifecycle: stable|draft
    ---
    设置
    sources
    时添加Agent前缀,以便
    memory-bridge
    后续能找到它。
  4. 添加交叉链接
    index.md
    中找到的相关wiki页面。
提炼规则(与所有摄入技能相同):
  • 提取持久知识,而非操作遥测数据
  • 每个概念对应一个wiki页面,而非每个会话对应一个
  • 合并到现有页面而非重复创建
  • 保留关键信息:做出的决策、发现的模式、有效的技术、问题解释

Step 6: Return Synthesized Answer

步骤6:返回合成答案

After ingesting, immediately synthesize and return an answer from the newly ingested + existing wiki content:
undefined
摄入完成后,立即从新摄入的内容+现有wiki内容中合成并返回答案:
undefined

From <agent> history: "<query>"

来自<agent>历史记录:"<query>"

Found in: <N> sessions (<session names/titles>)
Key insights: <Synthesized answer — 3–5 bullet points of the most useful knowledge>
Wiki pages updated/created:
  • [[page-name]] — <what was added>
  • [[page-name]] — <what was added>
Sessions ingested:
SessionDateRelevance
<name><date><one-line why it was selected>
Gaps: <What the sessions didn't cover that might be relevant>

If a query was given but no relevant sessions were found, say so explicitly: "No sessions about '<query>' found in `<agent>` history. The most recent sessions covered: <list topics from last 3 sessions>."

---
找到于: <N>个会话(<会话名称/标题>)
关键见解: <合成答案——3-5个最有用知识的要点>
更新/创建的Wiki页面:
  • [[page-name]] — <添加的内容>
  • [[page-name]] — <添加的内容>
已摄入的会话:
会话日期相关性
<name><date><选中原因的单行说明>
空白点: <会话未涵盖但可能相关的内容>

如果提供了查询但未找到相关会话,请明确告知:"在`<agent>`历史记录中未找到关于'<query>'的会话。最近的会话涵盖:<最近3个会话的主题列表>。"

---

Step 7: Update Tracking Files

步骤7:更新跟踪文件

Update
.manifest.json
for each session file processed:
json
{
  "<path>": {
    "ingested_at": "<now>",
    "source_type": "<agent>_conversation",
    "modified_at": "<file mtime>",
    "pages_created": [...],
    "pages_updated": [...]
  }
}
Append to
log.md
:
- [TIMESTAMP] WIKI-AGENT agent=<agent> query="<query>" sessions_searched=N sessions_ingested=M pages_created=X pages_updated=Y
Update
hot.md
with a one-line summary of what was ingested.

为每个处理的会话文件更新
.manifest.json
json
{
  "<path>": {
    "ingested_at": "<now>",
    "source_type": "<agent>_conversation",
    "modified_at": "<file mtime>",
    "pages_created": [...],
    "pages_updated": [...]
  }
}
log.md
追加内容:
- [TIMESTAMP] WIKI-AGENT agent=<agent> query="<query>" sessions_searched=N sessions_ingested=M pages_created=X pages_updated=Y
用摄入内容的单行摘要更新
hot.md

Cross-Agent Use Patterns

跨Agent使用模式

These are the primary use cases this skill is designed for:
"I'm on Codex. What did I figure out about X in Claude?"
/wiki-claude "X"
— finds Claude sessions about X, ingests them, returns the answer
"I solved a bug in Hermes last week. I need that context now in Claude Code."
/wiki-hermes "bug description"
— surfaces and ingests the Hermes session
"What are all the approaches I've tried for X across all my tools?" → Run
/wiki-claude "X"
,
/wiki-codex "X"
,
/wiki-hermes "X"
in sequence — each ingests its slice, the wiki accumulates the cross-agent picture, then
/memory-bridge diff
shows what each tool uniquely contributed
No query — just "catch me up on recent Codex work"
/wiki-codex
— ingests last 5 Codex sessions and returns a summary
以下是该技能设计的主要使用场景:
"我正在使用Codex。我在Claude中关于X的解决方案是什么?"
/wiki-claude "X"
— 查找Claude中关于X的会话,摄入并返回答案
"我上周在Hermes中解决了一个bug。现在需要在Claude Code中使用该上下文。"
/wiki-hermes "bug description"
— 调取并摄入Hermes会话
"我在所有工具中尝试过哪些解决X的方法?" → 依次运行
/wiki-claude "X"
/wiki-codex "X"
/wiki-hermes "X"
— 每个工具摄入其对应的内容片段,wiki积累跨Agent的完整信息,然后
/memory-bridge diff
展示每个工具的独特贡献
无查询——仅需"了解我最近在Codex中的工作内容"
/wiki-codex
— 摄入最后5个Codex会话并返回摘要