Skip to main content

AI Coding Assistant Session Export Tool

Project description

logo

Agent Dump

AI 编码助手会话导出工具 - 支持从多种 AI 编码工具的会话数据导出会话为 JSON 格式。

支持的 AI 工具

  • OpenCode - 开源 AI 编程助手
  • Claude Code - Anthropic 的 AI 编码工具 (计划中)
  • Code X - GitHub Copilot Chat (计划中)
  • 更多工具 - 欢迎提交 PR 支持其他 AI 编码工具

功能特性

  • 交互式选择: 使用 questionary 提供友好的命令行交互界面
  • 批量导出: 支持导出最近 N 天的所有会话
  • 指定导出: 通过会话 ID 导出特定会话
  • 会话列表: 仅列出会话而不导出
  • 统计数据: 导出包含 tokens 使用量、成本等统计信息
  • 消息详情: 完整保留会话消息、工具调用等详细信息

安装

方式一:使用 uv tool 安装(推荐)

# 从 PyPI 安装(发布后可使用)
uv tool install agent-dump

# 从 GitHub 直接安装
uv tool install git+https://github.com/xingkaixin/agent-dump

方式二:使用 uvx 直接运行(无需安装)

# 从 PyPI 运行(发布后可使用)
uvx agent-dump --help

# 从 GitHub 直接运行
uvx --from git+https://github.com/xingkaixin/agent-dump agent-dump --help

方式三:本地开发

# 克隆仓库
git clone https://github.com/xingkaixin/agent-dump.git
cd agent-dump

# 使用 uv 安装依赖
uv sync

# 本地安装测试
uv tool install . --force

使用方法

交互式导出(默认)

# 方式一:使用命令行入口
uv run agent-dump

# 方式二:使用模块运行
uv run python -m agent_dump

运行后会显示最近 7 天的会话列表,使用空格选择/取消,回车确认导出。

命令行参数

uv run agent-dump --days 3                    # 导出最近 3 天的会话
uv run agent-dump --agent claude              # 指定 Agent 工具名称
uv run agent-dump --output ./my-sessions      # 指定输出目录
uv run agent-dump --list                      # 仅列出会话
uv run agent-dump --export ses_abc,ses_xyz    # 导出指定 ID 的会话

完整参数说明

参数 说明 默认值
--days 查询最近 N 天的会话 7
--agent Agent 工具名称 opencode
--output 输出目录 ./sessions
--export 导出指定会话 ID(逗号分隔) -
--list 仅列出会话,不导出 -

项目结构

.
├── src/
│   └── agent_dump/      # 主包目录
│       ├── __init__.py  # 包初始化
│       ├── __main__.py  # python -m agent_dump 入口
│       ├── cli.py       # 命令行接口
│       ├── db.py        # 数据库操作
│       ├── exporter.py  # 导出逻辑
│       └── selector.py  # 交互式选择
├── tests/               # 测试目录
├── pyproject.toml       # 项目配置
├── Makefile            # 自动化命令
├── ruff.toml           # 代码风格配置
├── data/               # 数据库目录
│   └── opencode/
│       └── opencode.db
└── sessions/           # 导出目录
    └── {agent-name}/   # 按工具分类的导出文件
        └── ses_xxx.json

开发

# 代码检查
make lint

# 自动修复
make lint.fix

# 代码格式化
make lint.fmt

# 类型检查
make check

依赖

  • Python >= 3.14
  • prompt-toolkit >= 3.0.0
  • questionary >= 2.1.1
  • ruff >= 0.15.2 (开发)
  • ty >= 0.0.18 (开发)

许可证

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_dump-0.1.1.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_dump-0.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file agent_dump-0.1.1.tar.gz.

File metadata

  • Download URL: agent_dump-0.1.1.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agent_dump-0.1.1.tar.gz
Algorithm Hash digest
SHA256 283b07ac951044a118f06de6c38f587b6a70b1c25b26d0cd6016e7ef90f637da
MD5 556f469bca538b66eb9eaae268aa1ef7
BLAKE2b-256 37a7c8e175288772cf9c81fb5dbacc9358bcc9c31ce1009233eea351b7bbdb15

See more details on using hashes here.

File details

Details for the file agent_dump-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: agent_dump-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agent_dump-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c77bcc356ca94a61fbf06705114515def478f4645ca2aa73daa0a6b2239d5b8
MD5 db7eab585df41bfe1f893a7e4fc03c3a
BLAKE2b-256 49b4ef88d3ac8f29fc6c4144f5ce4aa8f2f5fea97dd19d3d903014a3e6e021f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page