opencode-conversation-analysis

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Conversation Analysis

对话分析

Analyze user messages from OpenCode sessions to identify recurring themes, communication patterns, and steering behaviours.
分析OpenCode会话中的用户消息,识别重复出现的主题、沟通模式以及引导行为。

Critical Rules

核心规则

  1. NEVER cat or read chunk files directly - they're huge and will explode your context
  2. Pass file paths to subagents - let them read and analyze independently
  3. Use parallel subagents - one per chunk, they run concurrently
  4. Subagents return structured JSON - you synthesize at the end
  1. 绝对不要直接查看或读取分块文件 - 这些文件体积庞大,会超出上下文限制
  2. 将文件路径传递给子Agent - 让它们独立读取和分析
  3. 使用并行子Agent - 每个分块对应一个子Agent,并行运行
  4. 子Agent返回结构化JSON - 最后由你进行合成

Workflow

工作流程

Step 1: Run Extraction

步骤1:运行提取脚本

bash
~/.agents/skills/opencode-conversation-analysis/scripts/extract.sh
This script:
  • Finds all main sessions (excludes subagent child sessions)
  • Extracts user messages with metadata (session_id, title, timestamp, text)
  • Filters out messages < 10 characters
  • Chunks into ~320k char files (~80k tokens each)
  • Outputs to
    /tmp/opencode-analysis/chunk_*.jsonl
Review the output summary to see how many chunks were created.
bash
~/.agents/skills/opencode-conversation-analysis/scripts/extract.sh
该脚本的功能:
  • 查找所有主会话(排除子Agent的子会话)
  • 提取带有元数据的用户消息(session_id、title、timestamp、text)
  • 过滤掉长度小于10个字符的消息
  • 将内容分块为约320000字符的文件(每个约80000 tokens)
  • 输出到
    /tmp/opencode-analysis/chunk_*.jsonl
查看输出摘要,了解创建的分块数量。

Step 2: Launch Parallel Subagents

步骤2:启动并行子Agent

For each chunk file, spawn a
general
subagent with this prompt template:
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"]
    }
  ]
}
Launch ALL chunk subagents in parallel (single message, multiple Task tool calls).
对于每个分块文件,启动一个
general
子Agent,并使用以下提示模板:
读取文件/tmp/opencode-analysis/chunk_N.jsonl,其中包含来自编码会话的用户消息(JSONL格式,字段包括:session_id、session_title、timestamp、text)。

分析这些消息,识别用户在引导AI编码助手时重复出现的主题。寻找以下模式:
- 他们如何给出反馈
- 他们如何纠正错误
- 他们如何界定/细化需求
- 偏好的沟通风格
- 他们强调的技术方法

对于识别出的每个主题,请提供:
1. 主题名称(简短、描述性)
2. 描述(1-2句话)
3. 2-3条来自消息的直接引用示例

仅返回符合以下格式的有效JSON:
{
  "themes": [
    {
      "name": "Theme Name",
      "description": "Description of the pattern",
      "examples": ["quote 1", "quote 2"]
    }
  ]
}
并行启动所有分块对应的子Agent(单条消息,调用多个Task工具)。

Step 3: Synthesize Results

步骤3:合成结果

Once all subagents return:
  1. Collect all theme objects from all chunks
  2. Group similar themes (same name or overlapping descriptions)
  3. Merge examples from duplicate themes
  4. Rank themes by how many chunks they appeared in
  5. Pick the best 2-3 examples per theme
当所有子Agent返回结果后:
  1. 收集所有分块中的所有主题对象
  2. 对相似主题进行分组(名称相同或描述重叠)
  3. 合并重复主题的示例
  4. 根据主题出现的分块数量进行排序
  5. 为每个主题挑选最佳的2-3个示例

Step 4: Output Format

步骤4:输出格式

Present the final analysis as markdown with this structure:
markdown
undefined
将最终分析结果以markdown格式呈现,结构如下:
markdown
undefined

Themes in How You Steer AI Coding Assistants

你引导AI编码助手的主题分析

Analysis of N messages across M sessions (date range)

对M个会话中的N条消息的分析(日期范围)

1. Theme Name

1. 主题名称

Description of the pattern.
Examples:
  • "direct quote 1"
  • "direct quote 2"
  • "direct quote 3"

模式描述。
示例:
  • "直接引用1"
  • "直接引用2"
  • "直接引用3"

2. Next Theme

2. 下一个主题

...

Output directly to the user - don't write to a file unless asked.
...

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

Customisation Options

自定义选项

The user may request:
  • Different chunk sizes: Edit
    CHUNK_SIZE
    in extract.sh (default 320000 chars)
  • Different message filter: Edit the
    ${#text} -ge 10
    check in extract.sh
  • Include subagent sessions: Remove the
    parentID == null
    filter in extract.sh
  • Time period filtering: Add timestamp filtering in extract.sh
用户可能会要求:
  • 不同的分块大小:编辑extract.sh中的
    CHUNK_SIZE
    (默认320000字符)
  • 不同的消息过滤规则:编辑extract.sh中的
    ${#text} -ge 10
    检查条件
  • 包含子Agent会话:移除extract.sh中的
    parentID == null
    过滤条件
  • 时间范围过滤:在extract.sh中添加时间戳过滤

Storage Format Reference

存储格式参考

See references/storage-format.md for details on OpenCode's conversation storage structure.
查看references/storage-format.md了解OpenCode对话存储结构的详细信息。