mcpField
O
opencode-conversation-analysis

opencode-conversation-analysis

github.com/connoradsAgent 工作流1892 次安装2 天前更新
代码仓库

关于 opencode-conversation-analysis

opencode-conversation-analysis 是一项分析 OpenCode 会话用户消息的技能,用于发现指导编码助手时的反复主题和模式。它提取并分块消息,再由并行子 Agent 分析,最终汇总为 Markdown 报告。

主要功能

  1. 01提取 OpenCode 会话消息
  2. 02将数据分块供分析
  3. 03并行运行子 Agent 分析
  4. 04汇总反复主题与示例
  5. 05输出 Markdown 报告

适用场景

  1. 01回顾编码会话中的常见反馈
  2. 02识别请求如何细化或界定范围
  3. 03分析沟通偏好与纠错方式

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/connorads/dotfiles --skill opencode-conversation-analysis

安装后在 Claude Code 中输入/opencode-conversation-analysis确认已加载。

附带文件references/storage-format.mdscripts/extract.sh

详细介绍

对话分析

分析 OpenCode 会话中的用户消息,识别反复出现的主题、沟通模式和引导行为。

重要规则

  1. 绝不要直接读取或使用 cat 查看分块文件——这些文件很大,会占用过多上下文
  2. 将文件路径传给子 Agent——让它们独立读取并分析
  3. 使用并行子 Agent——每个分块对应一个子 Agent,并发运行
  4. 子 Agent 返回结构化 JSON——最后由你综合结果

工作流

步骤 1:运行提取
~/.agents/skills/opencode-conversation-analysis/scripts/extract.sh

此脚本会:

  • 在可用时从 ~/.local/share/opencode/opencode.db(SQLite)读取数据
  • 对较旧的 OpenCode 安装,回退到 ~/.local/share/opencode/storage/
  • 从主会话中提取用户消息及元数据(session_id、title、timestamp、text)
  • 过滤掉少于 10 个字符的消息
  • 将内容分割为约 32 万字符的文件(每个约 8 万个 token)
  • 输出到 /tmp/opencode-analysis/chunk_*.jsonl

查看输出摘要,了解生成了多少个分块。

步骤 2:启动并行子 Agent

针对每个分块文件,使用以下提示词模板启动一个 general 子 Agent:

Read the file /tmp/opencode-analysis/chunk_N.jsonl which contains user messages from coding sessions (JSONL format with fields: session_id, session_title, timestamp, text).

Analyze these messages to identify recurring themes in how the user steers/guides AI coding assistants. Look for patterns like:
- How they give feedback
- How they correct mistakes
- How they scope/refine requests
- Communication style preferences
- Technical approaches they emphasize

For each theme you identify, provide:
1. Theme name (short, descriptive)
2. Description (1-2 sentences)
3. 2-3 direct quote examples from the messages

Return ONLY valid JSON in this format:
{
  "themes": [
    {
      "name": "Theme Name",
      "description": "Description of the pattern",
      "examples": ["quote 1", "quote 2"]
    }
  ]
}

通过一条消息同时启动所有分块子 Agent(调用多个 Task 工具)。

步骤 3:综合结果

所有子 Agent 返回结果后:

  1. 收集所有分块中的主题对象
  2. 将相似主题分组(名称相同或描述重叠)
  3. 合并重复主题中的示例
  4. 按主题出现于多少个分块中进行排序
  5. 为每个主题挑选 2-3 个最佳示例
步骤 4:输出格式

按以下结构以 Markdown 呈现最终分析:

# Themes in How You Steer AI Coding Assistants

Analysis of N messages across M sessions (date range)

---

## 1. Theme Name

Description of the pattern.

**Examples:**
- "direct quote 1"
- "direct quote 2"
- "direct quote 3"

---

## 2. Next Theme
...

直接向用户输出——除非用户要求,否则不要写入文件。

自定义选项

用户可能会要求:

  • 更改分块大小:在 extract.sh 中编辑 CHUNK_SIZE(默认值为 320000 个字符)
  • 更改消息筛选条件:在 extract.sh 中编辑 MIN_TEXT_LEN(默认值为 10 个字符)
  • 包含子 Agent 会话:在 extract.sh 中移除 parent_id IS NULL(SQLite)和 parentID(旧版)的筛选条件
  • 按时间段筛选:在 extract.sh 中添加时间戳筛选

存储格式参考

详情请参阅 references/storage-format.md,了解 OpenCode 的对话存储结构。

评论

支持 Markdown