session-zoo 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. session_zoo-0.1.0/.github/workflows/ci.yml +28 -0
  2. session_zoo-0.1.0/.github/workflows/publish.yml +30 -0
  3. session_zoo-0.1.0/.gitignore +21 -0
  4. session_zoo-0.1.0/.pre-commit-config.yaml +17 -0
  5. session_zoo-0.1.0/CHANGELOG.md +18 -0
  6. session_zoo-0.1.0/CONTRIBUTING.md +43 -0
  7. session_zoo-0.1.0/LICENSE +21 -0
  8. session_zoo-0.1.0/PKG-INFO +176 -0
  9. session_zoo-0.1.0/README.md +146 -0
  10. session_zoo-0.1.0/README_zh.md +146 -0
  11. session_zoo-0.1.0/docs/demo.gif +0 -0
  12. session_zoo-0.1.0/docs/superpowers/plans/2026-03-11-session-zoon.md +2420 -0
  13. session_zoo-0.1.0/docs/superpowers/plans/2026-03-14-zoo-skills.md +759 -0
  14. session_zoo-0.1.0/docs/superpowers/specs/2026-03-11-session-zoon-design.md +297 -0
  15. session_zoo-0.1.0/docs/superpowers/specs/2026-03-14-zoo-skills-design.md +127 -0
  16. session_zoo-0.1.0/pyproject.toml +49 -0
  17. session_zoo-0.1.0/scripts/generate_demo_gif.py +262 -0
  18. session_zoo-0.1.0/src/session_zoo/__init__.py +1 -0
  19. session_zoo-0.1.0/src/session_zoo/adapters/__init__.py +16 -0
  20. session_zoo-0.1.0/src/session_zoo/adapters/claude_code.py +171 -0
  21. session_zoo-0.1.0/src/session_zoo/cli.py +588 -0
  22. session_zoo-0.1.0/src/session_zoo/config.py +50 -0
  23. session_zoo-0.1.0/src/session_zoo/data/skills/zoo-browse/SKILL.md +30 -0
  24. session_zoo-0.1.0/src/session_zoo/data/skills/zoo-restore/SKILL.md +36 -0
  25. session_zoo-0.1.0/src/session_zoo/data/skills/zoo-summarize/SKILL.md +38 -0
  26. session_zoo-0.1.0/src/session_zoo/data/skills/zoo-sync/SKILL.md +33 -0
  27. session_zoo-0.1.0/src/session_zoo/data/skills/zoo-tag/SKILL.md +36 -0
  28. session_zoo-0.1.0/src/session_zoo/db.py +184 -0
  29. session_zoo-0.1.0/src/session_zoo/installer.py +63 -0
  30. session_zoo-0.1.0/src/session_zoo/models.py +38 -0
  31. session_zoo-0.1.0/src/session_zoo/py.typed +0 -0
  32. session_zoo-0.1.0/src/session_zoo/renderer.py +246 -0
  33. session_zoo-0.1.0/src/session_zoo/summarizer.py +149 -0
  34. session_zoo-0.1.0/src/session_zoo/sync.py +94 -0
  35. session_zoo-0.1.0/tests/conftest.py +90 -0
  36. session_zoo-0.1.0/tests/test_claude_code_adapter.py +63 -0
  37. session_zoo-0.1.0/tests/test_cli.py +685 -0
  38. session_zoo-0.1.0/tests/test_config.py +33 -0
  39. session_zoo-0.1.0/tests/test_db.py +151 -0
  40. session_zoo-0.1.0/tests/test_e2e.py +866 -0
  41. session_zoo-0.1.0/tests/test_import_quiet.py +75 -0
  42. session_zoo-0.1.0/tests/test_installer.py +72 -0
  43. session_zoo-0.1.0/tests/test_integration.py +106 -0
  44. session_zoo-0.1.0/tests/test_models.py +60 -0
  45. session_zoo-0.1.0/tests/test_renderer.py +254 -0
  46. session_zoo-0.1.0/tests/test_summarizer.py +157 -0
  47. session_zoo-0.1.0/tests/test_sync.py +78 -0
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: pip install -e ".[dev]"
26
+
27
+ - name: Run tests
28
+ run: pytest --tb=short -q
@@ -0,0 +1,30 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ environment: pypi
11
+ permissions:
12
+ id-token: write # trusted publishing
13
+ contents: read
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.12"
22
+
23
+ - name: Install build tools
24
+ run: pip install build
25
+
26
+ - name: Build package
27
+ run: python -m build
28
+
29
+ - name: Publish to PyPI
30
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .eggs/
8
+ .pytest_cache/
9
+ .tox/
10
+ .coverage
11
+ htmlcov/
12
+ .venv/
13
+ venv/
14
+ env/
15
+ .vscode/
16
+ .idea/
17
+ .DS_Store
18
+ *.pem
19
+ *.key
20
+ .env
21
+ .superpowers/
@@ -0,0 +1,17 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.6.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: end-of-file-fixer
7
+ - id: check-yaml
8
+ - id: check-toml
9
+ - id: check-added-large-files
10
+ args: ['--maxkb=500']
11
+
12
+ - repo: https://github.com/astral-sh/ruff-pre-commit
13
+ rev: v0.8.0
14
+ hooks:
15
+ - id: ruff
16
+ args: [--fix]
17
+ - id: ruff-format
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.1.0] - 2026-03-12
8
+
9
+ ### Added
10
+
11
+ - CLI tool `zoo` with 14 commands: init, config, import, list, show, search, tag, tags, delete, summarize, sync, clone, reindex, restore
12
+ - Claude Code adapter: discover, parse, and restore sessions from `~/.claude/`
13
+ - Multi-provider AI summarization: Claude Code CLI, Codex CLI, Anthropic API
14
+ - Git-based sync: push raw JSONL + metadata + Markdown summaries to GitHub
15
+ - Cross-device restore: clone repo → reindex → restore sessions to `~/.claude/`
16
+ - SQLite local index with search, filter by project/tool/tag/date
17
+ - Markdown renderer with noise filtering, tool call merging, relative paths
18
+ - Tag management for organizing sessions
@@ -0,0 +1,43 @@
1
+ # Contributing to session-zoo
2
+
3
+ Thanks for your interest in contributing!
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/AndsGo/session-zoo.git
9
+ cd session-zoo
10
+ python3 -m venv .venv
11
+ source .venv/bin/activate
12
+ pip install -e ".[dev]"
13
+ ```
14
+
15
+ ## Running Tests
16
+
17
+ ```bash
18
+ pytest
19
+ ```
20
+
21
+ ## Code Style
22
+
23
+ - Python 3.12+ with type hints
24
+ - Keep functions focused and small
25
+ - Follow existing patterns in the codebase
26
+
27
+ ## Adding a New Adapter
28
+
29
+ To support a new AI tool (e.g., Cursor, Copilot), create a new adapter:
30
+
31
+ 1. Create `src/session_zoo/adapters/your_tool.py`
32
+ 2. Implement the adapter class with `discover()`, `parse()`, `get_restore_path()` methods
33
+ 3. Register it in `src/session_zoo/adapters/__init__.py`
34
+ 4. Add tests in `tests/test_your_tool_adapter.py`
35
+
36
+ See `adapters/claude_code.py` for reference.
37
+
38
+ ## Pull Request Process
39
+
40
+ 1. Fork the repo and create a branch from `main`
41
+ 2. Add tests for any new functionality
42
+ 3. Ensure all tests pass (`pytest`)
43
+ 4. Submit a PR with a clear description of the changes
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AndsGo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: session-zoo
3
+ Version: 0.1.0
4
+ Summary: AI development session recorder — save and sync sessions to GitHub
5
+ Project-URL: Homepage, https://github.com/AndsGo/session-zoo
6
+ Project-URL: Repository, https://github.com/AndsGo/session-zoo
7
+ Project-URL: Issues, https://github.com/AndsGo/session-zoo/issues
8
+ Author-email: AndsGo <18702149475@163.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,claude,codex,developer-tools,recorder,session
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Documentation
20
+ Classifier: Topic :: Software Development :: Version Control :: Git
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.12
23
+ Requires-Dist: anthropic>=0.52.0
24
+ Requires-Dist: rich>=13.0.0
25
+ Requires-Dist: typer>=0.15.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest-tmp-files>=0.0.2; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # session-zoo
32
+
33
+ [English](README.md) | [中文](README_zh.md)
34
+
35
+ Save and sync your AI development sessions to GitHub.
36
+
37
+ `session-zoo` automatically discovers sessions from AI coding tools (Claude Code, Codex, etc.), generates AI summaries, and syncs everything to a GitHub repo — raw data preserved for cross-device migration, plus readable Markdown for review.
38
+
39
+ <p align="center">
40
+ <img src="docs/demo.gif" alt="session-zoo demo" width="700">
41
+ </p>
42
+
43
+ ## Features
44
+
45
+ - **Auto-discover** sessions from `~/.claude/` (Claude Code adapter built-in)
46
+ - **AI Summarize** using existing Claude/Codex CLI (no API key needed) or Anthropic API
47
+ - **Git Sync** raw JSONL + metadata + Markdown summaries to GitHub
48
+ - **Cross-device restore** — clone on a new machine, restore sessions to `~/.claude/` for `/resume`
49
+ - **Tag & Search** sessions by project, tool, date, or custom tags
50
+ - **Extensible** adapter pattern — easy to add support for new AI tools
51
+
52
+ ## Quick Start
53
+
54
+ ### Install
55
+
56
+ ```bash
57
+ pip install session-zoo
58
+ ```
59
+
60
+ Or install from source:
61
+
62
+ ```bash
63
+ git clone https://github.com/AndsGo/session-zoo.git
64
+ cd session-zoo
65
+ pip install -e .
66
+ ```
67
+
68
+ ### Setup
69
+
70
+ ```bash
71
+ # Initialize
72
+ zoo init
73
+
74
+ # Set your GitHub repo for syncing (create an empty repo first)
75
+ zoo config set repo git@github.com:yourname/my-sessions.git
76
+ ```
77
+
78
+ ### Basic Workflow
79
+
80
+ ```bash
81
+ # Import sessions from Claude Code
82
+ zoo import
83
+
84
+ # List all sessions
85
+ zoo list
86
+
87
+ # View session details
88
+ zoo show <session-id>
89
+ zoo show <session-id> --markdown
90
+
91
+ # Generate AI summary (uses installed claude/codex CLI automatically)
92
+ zoo summarize <session-id>
93
+
94
+ # Tag sessions for organization
95
+ zoo tag <session-id> bugfix security
96
+
97
+ # Sync everything to GitHub
98
+ zoo sync
99
+ ```
100
+
101
+ ### Cross-Device Restore
102
+
103
+ On a new machine:
104
+
105
+ ```bash
106
+ zoo init
107
+ zoo config set repo git@github.com:yourname/my-sessions.git
108
+ zoo clone # Clone the session repo
109
+ zoo reindex # Rebuild local index from repo
110
+ zoo restore # Restore .jsonl files to ~/.claude/ for /resume
111
+ ```
112
+
113
+ ## Commands
114
+
115
+ | Command | Description |
116
+ |---------|-------------|
117
+ | `zoo init` | Initialize configuration |
118
+ | `zoo config show/set` | View or set config (repo, ai-key, ai-model) |
119
+ | `zoo import` | Import new sessions from AI tools |
120
+ | `zoo list` | List sessions (filter by --project, --tool, --tag, --since) |
121
+ | `zoo show <id>` | Show session details (--raw, --markdown) |
122
+ | `zoo search <query>` | Search sessions by summary content |
123
+ | `zoo tag <id> [tags...]` | Add/remove tags |
124
+ | `zoo tags` | List all tags with counts |
125
+ | `zoo delete <id>` | Delete a session from index |
126
+ | `zoo summarize [id]` | Generate AI summaries (--provider auto/claude-code/codex/api) |
127
+ | `zoo sync` | Sync sessions to GitHub (--dry-run) |
128
+ | `zoo clone` | Clone session repo to local |
129
+ | `zoo reindex` | Rebuild SQLite index from repo |
130
+ | `zoo restore` | Restore session files to tool directories |
131
+
132
+ ## Summarization Providers
133
+
134
+ `zoo summarize` supports multiple providers, auto-detected by priority:
135
+
136
+ 1. **claude-code** — Uses installed `claude -p` CLI (no API key needed)
137
+ 2. **codex** — Uses installed `codex -q` CLI (no API key needed)
138
+ 3. **api** — Uses Anthropic API directly (requires `zoo config set ai-key <key>`)
139
+
140
+ ```bash
141
+ # Auto-detect (uses whatever is available)
142
+ zoo summarize <id>
143
+
144
+ # Force a specific provider
145
+ zoo summarize --provider claude-code <id>
146
+ zoo summarize --provider api <id>
147
+ ```
148
+
149
+ ## GitHub Repo Structure
150
+
151
+ ```
152
+ your-sessions-repo/
153
+ ├── raw/claude-code/my-project/
154
+ │ ├── <session-id>.jsonl # Raw session data (preserved as-is)
155
+ │ └── <session-id>.meta.json # Metadata (tags, summary, cwd)
156
+ └── sessions/my-project/2026-03-10/claude-code/
157
+ └── <session-id>.md # Readable Markdown summary
158
+ ```
159
+
160
+ ## Adding Adapters
161
+
162
+ session-zoo uses an adapter pattern to support different AI tools. Currently supported:
163
+
164
+ - **Claude Code** (`~/.claude/projects/`)
165
+
166
+ To add a new adapter, implement `discover()`, `parse()`, and `get_restore_path()`. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
167
+
168
+ ## Requirements
169
+
170
+ - Python 3.12+
171
+ - Git
172
+ - (Optional) `claude` or `codex` CLI for summarization without API key
173
+
174
+ ## License
175
+
176
+ [MIT](LICENSE)
@@ -0,0 +1,146 @@
1
+ # session-zoo
2
+
3
+ [English](README.md) | [中文](README_zh.md)
4
+
5
+ Save and sync your AI development sessions to GitHub.
6
+
7
+ `session-zoo` automatically discovers sessions from AI coding tools (Claude Code, Codex, etc.), generates AI summaries, and syncs everything to a GitHub repo — raw data preserved for cross-device migration, plus readable Markdown for review.
8
+
9
+ <p align="center">
10
+ <img src="docs/demo.gif" alt="session-zoo demo" width="700">
11
+ </p>
12
+
13
+ ## Features
14
+
15
+ - **Auto-discover** sessions from `~/.claude/` (Claude Code adapter built-in)
16
+ - **AI Summarize** using existing Claude/Codex CLI (no API key needed) or Anthropic API
17
+ - **Git Sync** raw JSONL + metadata + Markdown summaries to GitHub
18
+ - **Cross-device restore** — clone on a new machine, restore sessions to `~/.claude/` for `/resume`
19
+ - **Tag & Search** sessions by project, tool, date, or custom tags
20
+ - **Extensible** adapter pattern — easy to add support for new AI tools
21
+
22
+ ## Quick Start
23
+
24
+ ### Install
25
+
26
+ ```bash
27
+ pip install session-zoo
28
+ ```
29
+
30
+ Or install from source:
31
+
32
+ ```bash
33
+ git clone https://github.com/AndsGo/session-zoo.git
34
+ cd session-zoo
35
+ pip install -e .
36
+ ```
37
+
38
+ ### Setup
39
+
40
+ ```bash
41
+ # Initialize
42
+ zoo init
43
+
44
+ # Set your GitHub repo for syncing (create an empty repo first)
45
+ zoo config set repo git@github.com:yourname/my-sessions.git
46
+ ```
47
+
48
+ ### Basic Workflow
49
+
50
+ ```bash
51
+ # Import sessions from Claude Code
52
+ zoo import
53
+
54
+ # List all sessions
55
+ zoo list
56
+
57
+ # View session details
58
+ zoo show <session-id>
59
+ zoo show <session-id> --markdown
60
+
61
+ # Generate AI summary (uses installed claude/codex CLI automatically)
62
+ zoo summarize <session-id>
63
+
64
+ # Tag sessions for organization
65
+ zoo tag <session-id> bugfix security
66
+
67
+ # Sync everything to GitHub
68
+ zoo sync
69
+ ```
70
+
71
+ ### Cross-Device Restore
72
+
73
+ On a new machine:
74
+
75
+ ```bash
76
+ zoo init
77
+ zoo config set repo git@github.com:yourname/my-sessions.git
78
+ zoo clone # Clone the session repo
79
+ zoo reindex # Rebuild local index from repo
80
+ zoo restore # Restore .jsonl files to ~/.claude/ for /resume
81
+ ```
82
+
83
+ ## Commands
84
+
85
+ | Command | Description |
86
+ |---------|-------------|
87
+ | `zoo init` | Initialize configuration |
88
+ | `zoo config show/set` | View or set config (repo, ai-key, ai-model) |
89
+ | `zoo import` | Import new sessions from AI tools |
90
+ | `zoo list` | List sessions (filter by --project, --tool, --tag, --since) |
91
+ | `zoo show <id>` | Show session details (--raw, --markdown) |
92
+ | `zoo search <query>` | Search sessions by summary content |
93
+ | `zoo tag <id> [tags...]` | Add/remove tags |
94
+ | `zoo tags` | List all tags with counts |
95
+ | `zoo delete <id>` | Delete a session from index |
96
+ | `zoo summarize [id]` | Generate AI summaries (--provider auto/claude-code/codex/api) |
97
+ | `zoo sync` | Sync sessions to GitHub (--dry-run) |
98
+ | `zoo clone` | Clone session repo to local |
99
+ | `zoo reindex` | Rebuild SQLite index from repo |
100
+ | `zoo restore` | Restore session files to tool directories |
101
+
102
+ ## Summarization Providers
103
+
104
+ `zoo summarize` supports multiple providers, auto-detected by priority:
105
+
106
+ 1. **claude-code** — Uses installed `claude -p` CLI (no API key needed)
107
+ 2. **codex** — Uses installed `codex -q` CLI (no API key needed)
108
+ 3. **api** — Uses Anthropic API directly (requires `zoo config set ai-key <key>`)
109
+
110
+ ```bash
111
+ # Auto-detect (uses whatever is available)
112
+ zoo summarize <id>
113
+
114
+ # Force a specific provider
115
+ zoo summarize --provider claude-code <id>
116
+ zoo summarize --provider api <id>
117
+ ```
118
+
119
+ ## GitHub Repo Structure
120
+
121
+ ```
122
+ your-sessions-repo/
123
+ ├── raw/claude-code/my-project/
124
+ │ ├── <session-id>.jsonl # Raw session data (preserved as-is)
125
+ │ └── <session-id>.meta.json # Metadata (tags, summary, cwd)
126
+ └── sessions/my-project/2026-03-10/claude-code/
127
+ └── <session-id>.md # Readable Markdown summary
128
+ ```
129
+
130
+ ## Adding Adapters
131
+
132
+ session-zoo uses an adapter pattern to support different AI tools. Currently supported:
133
+
134
+ - **Claude Code** (`~/.claude/projects/`)
135
+
136
+ To add a new adapter, implement `discover()`, `parse()`, and `get_restore_path()`. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
137
+
138
+ ## Requirements
139
+
140
+ - Python 3.12+
141
+ - Git
142
+ - (Optional) `claude` or `codex` CLI for summarization without API key
143
+
144
+ ## License
145
+
146
+ [MIT](LICENSE)
@@ -0,0 +1,146 @@
1
+ # session-zoo
2
+
3
+ [English](README.md) | [中文](README_zh.md)
4
+
5
+ 将你的 AI 开发会话保存并同步到 GitHub。
6
+
7
+ `session-zoo` 自动发现 AI 编程工具(Claude Code、Codex 等)的会话记录,生成 AI 摘要,并将所有数据同步到 GitHub 仓库 —— 原始数据完整保留以便跨设备迁移,同时生成可读的 Markdown 方便回顾。
8
+
9
+ <p align="center">
10
+ <img src="docs/demo.gif" alt="session-zoo 演示" width="700">
11
+ </p>
12
+
13
+ ## 特性
14
+
15
+ - **自动发现** `~/.claude/` 下的会话(内置 Claude Code 适配器)
16
+ - **AI 摘要** 直接使用已安装的 Claude/Codex CLI(无需 API key),也支持 Anthropic API
17
+ - **Git 同步** 原始 JSONL + 元数据 + Markdown 摘要同步到 GitHub
18
+ - **跨设备恢复** — 在新设备 clone 后恢复会话到 `~/.claude/`,支持 `/resume`
19
+ - **标签与搜索** 按项目、工具、日期或自定义标签管理会话
20
+ - **可扩展** 适配器模式,轻松添加新工具支持
21
+
22
+ ## 快速开始
23
+
24
+ ### 安装
25
+
26
+ ```bash
27
+ pip install session-zoo
28
+ ```
29
+
30
+ 或从源码安装:
31
+
32
+ ```bash
33
+ git clone https://github.com/AndsGo/session-zoo.git
34
+ cd session-zoo
35
+ pip install -e .
36
+ ```
37
+
38
+ ### 初始化
39
+
40
+ ```bash
41
+ # 初始化配置
42
+ zoo init
43
+
44
+ # 设置 GitHub 仓库(需先创建一个空仓库)
45
+ zoo config set repo git@github.com:yourname/my-sessions.git
46
+ ```
47
+
48
+ ### 基本用法
49
+
50
+ ```bash
51
+ # 导入 Claude Code 会话
52
+ zoo import
53
+
54
+ # 查看所有会话
55
+ zoo list
56
+
57
+ # 查看会话详情
58
+ zoo show <session-id>
59
+ zoo show <session-id> --markdown
60
+
61
+ # 生成 AI 摘要(自动使用已安装的 claude/codex CLI)
62
+ zoo summarize <session-id>
63
+
64
+ # 添加标签
65
+ zoo tag <session-id> bugfix security
66
+
67
+ # 同步到 GitHub
68
+ zoo sync
69
+ ```
70
+
71
+ ### 跨设备恢复
72
+
73
+ 在新设备上:
74
+
75
+ ```bash
76
+ zoo init
77
+ zoo config set repo git@github.com:yourname/my-sessions.git
78
+ zoo clone # 克隆会话仓库
79
+ zoo reindex # 从仓库重建本地索引
80
+ zoo restore # 恢复 .jsonl 文件到 ~/.claude/ 以支持 /resume
81
+ ```
82
+
83
+ ## 命令列表
84
+
85
+ | 命令 | 说明 |
86
+ |------|------|
87
+ | `zoo init` | 初始化配置 |
88
+ | `zoo config show/set` | 查看或设置配置(repo, ai-key, ai-model) |
89
+ | `zoo import` | 从 AI 工具导入新会话 |
90
+ | `zoo list` | 列出会话(支持 --project, --tool, --tag, --since 筛选) |
91
+ | `zoo show <id>` | 查看会话详情(--raw 原始数据, --markdown 渲染) |
92
+ | `zoo search <query>` | 按摘要内容搜索 |
93
+ | `zoo tag <id> [tags...]` | 添加/删除标签 |
94
+ | `zoo tags` | 列出所有标签及数量 |
95
+ | `zoo delete <id>` | 删除会话 |
96
+ | `zoo summarize [id]` | 生成 AI 摘要(--provider auto/claude-code/codex/api) |
97
+ | `zoo sync` | 同步到 GitHub(--dry-run 预览) |
98
+ | `zoo clone` | 克隆会话仓库到本地 |
99
+ | `zoo reindex` | 从仓库重建 SQLite 索引 |
100
+ | `zoo restore` | 恢复会话文件到工具目录 |
101
+
102
+ ## 摘要生成
103
+
104
+ `zoo summarize` 支持多种方式,按优先级自动检测:
105
+
106
+ 1. **claude-code** — 使用已安装的 `claude -p` CLI(无需 API key)
107
+ 2. **codex** — 使用已安装的 `codex -q` CLI(无需 API key)
108
+ 3. **api** — 直接调用 Anthropic API(需 `zoo config set ai-key <key>`)
109
+
110
+ ```bash
111
+ # 自动检测
112
+ zoo summarize <id>
113
+
114
+ # 指定方式
115
+ zoo summarize --provider claude-code <id>
116
+ zoo summarize --provider api <id>
117
+ ```
118
+
119
+ ## GitHub 仓库结构
120
+
121
+ ```
122
+ your-sessions-repo/
123
+ ├── raw/claude-code/my-project/
124
+ │ ├── <session-id>.jsonl # 原始会话数据(完整保留)
125
+ │ └── <session-id>.meta.json # 元数据(标签、摘要、工作目录)
126
+ └── sessions/my-project/2026-03-10/claude-code/
127
+ └── <session-id>.md # 可读的 Markdown 摘要
128
+ ```
129
+
130
+ ## 添加适配器
131
+
132
+ session-zoo 使用适配器模式支持不同的 AI 工具。目前支持:
133
+
134
+ - **Claude Code** (`~/.claude/projects/`)
135
+
136
+ 添加新适配器需实现 `discover()`、`parse()` 和 `get_restore_path()` 方法。详见 [CONTRIBUTING.md](CONTRIBUTING.md)。
137
+
138
+ ## 环境要求
139
+
140
+ - Python 3.12+
141
+ - Git
142
+ - (可选)`claude` 或 `codex` CLI 用于无 API key 的摘要生成
143
+
144
+ ## 许可证
145
+
146
+ [MIT](LICENSE)
Binary file