| name | notion-chat-export |
| description | Run opencode to export AI conversation to Notion. Use this skill whenever user wants to save, export, or archive an AI conversation to Notion. This skill generates an opencode prompt and executes it via CLI. Trigger phrases include: "export to Notion", "save to Notion", "把这个对话导出", "保存到公众号阅读", "archive conversation to Notion", "把这段AI对话导出到Notion", "run opencode to do X", "用opencode完成这个任务", etc. |
Notion Chat Export via OpenCode
This skill runs opencode with a generated prompt to export AI conversation content to a Notion page.
Workflow
Step 1: Identify the Conversation Content
Locate the AI conversation content that the user wants to export. This could be:
- The entire current session's conversation history
- A specific portion of conversation the user mentioned
- Content that the user just pasted
Step 2: Parse and Format the Conversation
Parse the conversation and format it. Key formatting rules:
- Use
**用户**: prefix for user messages (bold for visibility)
- Use
**AI**: prefix for assistant messages
- Add
--- (horizontal divider) between each exchange
- Preserve all code blocks, lists, and formatting within messages
- Do NOT modify or summarize the content - copy exactly as-is
Step 3: Generate the OpenCode Prompt
Generate a detailed prompt for opencode based on this template:
请完成以下任务:
1. 使用 Notion API(notion_API-post-search)搜索名为"公众号阅读"的页面,获取其 page_id
2. 使用 notion_API-post-page 在"公众号阅读"页面下创建一个新页面
3. 页面标题为:[对话] {日期} - {简短主题}
- 日期格式:YYYY-MM-DD
- 简短主题:根据对话内容总结一个合适的简短标题(20字以内),不要直接截取前20个字符。
4. 使用 notion_API-patch-block-children 添加以下对话内容(不改变内容,只做适当排版):
---
{conversation_content}
---
5. 完成后返回新创建的页面 URL
注意事项:
- 用不同的样式区分用户消息和AI回复(用户消息用粗体前缀"**用户**:", AI回复用"**AI**:")
- 每个问答对之间用分隔线"---"隔开
- 代码块要保留原始格式
- 不要总结或修改内容,原样复制
Step 4: Execute OpenCode
Use the bash tool to run opencode with the generated prompt:
opencode run -m opencode/minimax-m2.5-free "{generated_prompt}"
Important notes:
--agent flag does not work with subagents (plan, build, explore, etc.) - it falls back to default agent
- Must specify model with
-m opencode/minimax-m2.5-free for proper execution
--dir {working_directory}: Optional, specify working directory
Step 5: Return the Result
After opencode completes:
- Report the success/failure status
- If successful, provide the Notion page URL
- If failed, report the error and suggest manual export
Example
User says: "把这个对话导出到公众号阅读"
AI does:
- Extracts the conversation content from the session
- Formats it with proper structure
- Generates an opencode prompt
- Executes:
opencode run -m opencode/minimax-m2.5-free "请完成以下任务:..."
- Reports success with the new Notion page URL
Troubleshooting
- If opencode command fails: Check if opencode is in PATH, try with full path
- If "公众号阅读" page not found: The opencode agent should handle this, but user may need to confirm
- If Notion API fails: Report the error from opencode output
Notes
- Always preserve exact conversation content - do not summarize or edit
- Model is required: Use
-m opencode/minimax-m2.5-free
- The opencode CLI should be in PATH:
C:\Users\h\AppData\Roaming\npm\opencode