@halooojustin/cch 0.1.0
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.
- package/README.md +186 -0
- package/README.zh-CN.md +186 -0
- package/bin/ch.js +2 -0
- package/dist/cli.js +4409 -0
- package/package.json +49 -0
- package/skill/SKILL.md +220 -0
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# cch — Claude Code History
|
|
2
|
+
|
|
3
|
+
AI-powered conversation history management for [Claude Code](https://docs.anthropic.com/en/docs/claude-code).
|
|
4
|
+
|
|
5
|
+
Find any past conversation with natural language, resume it in a Zellij or tmux session — across all your projects.
|
|
6
|
+
|
|
7
|
+
## The Problem
|
|
8
|
+
|
|
9
|
+
Claude Code stores conversation history in `~/.claude/projects/`, scoped per directory. When you work across many repos:
|
|
10
|
+
|
|
11
|
+
- `claude --resume` only shows history for the **current** directory
|
|
12
|
+
- No way to search across all projects for a past conversation
|
|
13
|
+
- Closing a terminal loses the active session
|
|
14
|
+
- No global view of running Claude sessions
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g cch
|
|
20
|
+
ch setup # adds shell aliases (cn, cnf, cls, cps, chs)
|
|
21
|
+
source ~/.zshrc # or open a new terminal
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Claude Code Skill (optional)
|
|
25
|
+
|
|
26
|
+
Install the skill so Claude Code knows how to use `ch` for you:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cp -r $(npm root -g)/cch/skill ~/.claude/skills/cch
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then you can just tell Claude Code things like "find my iOS debugging conversation" and it will use `ch` automatically.
|
|
33
|
+
|
|
34
|
+
**Requirements:**
|
|
35
|
+
- Node.js >= 18
|
|
36
|
+
- [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) installed
|
|
37
|
+
- [Zellij](https://zellij.dev/) or [tmux](https://github.com/tmux/tmux) (at least one)
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
### Natural Language Search (the killer feature)
|
|
42
|
+
|
|
43
|
+
Just describe what you remember. AI finds the session.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
ch 上次帮我调试 iOS 的那个对话
|
|
47
|
+
ch the one where I was deploying shrimp
|
|
48
|
+
ch that donut wallet refactor
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`ch` pipes your query + session list to `claude -p` (tries Haiku first for speed, falls back to default model), which returns the best matches. Pick one and it resumes in your multiplexer.
|
|
52
|
+
|
|
53
|
+
### Commands
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
ch <description> Natural language search (default)
|
|
57
|
+
ch list [-n 20] List recent sessions (interactive selector)
|
|
58
|
+
ch search <keyword> Exact keyword search in conversation content
|
|
59
|
+
ch new [description] New Claude session in current directory
|
|
60
|
+
ch new -f [description] Force new (kill existing same-name session)
|
|
61
|
+
ch ls List active multiplexer sessions (interactive selector)
|
|
62
|
+
ch attach <name> Attach to a live session
|
|
63
|
+
ch kill <name> Kill a session
|
|
64
|
+
ch resume <session-id> Resume by session ID
|
|
65
|
+
ch config Show configuration
|
|
66
|
+
ch config set <key> <value> Set a config value
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Interactive Selection
|
|
70
|
+
|
|
71
|
+
Both `ch list` and `ch ls` feature an interactive selector:
|
|
72
|
+
|
|
73
|
+
- **Up/Down arrows** or **j/k** — navigate the list
|
|
74
|
+
- **Number keys** — type a number (e.g. `12`) then **Enter** to jump directly
|
|
75
|
+
- **Enter** — confirm selection (resume session or attach to live session)
|
|
76
|
+
- **Esc** or **q** — cancel
|
|
77
|
+
|
|
78
|
+
CJK text is properly aligned with display-width-aware column padding.
|
|
79
|
+
|
|
80
|
+
### Two-Level Resume
|
|
81
|
+
|
|
82
|
+
**Level 1 — Live sessions:** Session still running in your multiplexer?
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
ch ls # interactive list — pick one to attach
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Level 2 — History resume:** Session ended, but you want to pick it back up?
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
ch 那个讨论登录bug的对话 # AI finds it
|
|
92
|
+
# or
|
|
93
|
+
ch list # interactive list — pick one to resume
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Both levels open in a Zellij/tmux session, so you can detach and reattach anytime. All sessions launch via login shell (`zsh -lc`) to inherit your full environment and auth.
|
|
97
|
+
|
|
98
|
+
### Session Management
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Start a new Claude session in current project
|
|
102
|
+
ch new
|
|
103
|
+
|
|
104
|
+
# With a description (shows up in ch ls and as Zellij tab name)
|
|
105
|
+
ch new "fix authentication bug"
|
|
106
|
+
ch new 修复登录bug # Chinese descriptions work too
|
|
107
|
+
|
|
108
|
+
# Force restart (kills existing session first)
|
|
109
|
+
ch new -f "start fresh on auth"
|
|
110
|
+
|
|
111
|
+
# See what's running (sorted by newest first)
|
|
112
|
+
ch ls
|
|
113
|
+
|
|
114
|
+
# Clean up
|
|
115
|
+
ch kill ch-myproject-fix-auth
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Session Descriptions
|
|
119
|
+
|
|
120
|
+
Descriptions you pass to `ch new` are used in multiple places:
|
|
121
|
+
|
|
122
|
+
- **Zellij tab name** — visible in the tab bar when inside the session (supports Chinese)
|
|
123
|
+
- **`ch ls` output** — shown next to the session name
|
|
124
|
+
- **Session name** — English descriptions are included in the session name (e.g. `ch-infist-fix-login-bug`), Chinese descriptions use a hash fallback (e.g. `ch-infist-a1b2c3`) since Zellij session names don't support CJK
|
|
125
|
+
|
|
126
|
+
## Configuration
|
|
127
|
+
|
|
128
|
+
Config lives at `~/.config/cch/config.json`:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"backend": "auto",
|
|
133
|
+
"claudeCommand": "claude",
|
|
134
|
+
"claudeArgs": ["--dangerously-skip-permissions"],
|
|
135
|
+
"historyLimit": 100
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| Key | Default | Description |
|
|
140
|
+
|-----|---------|-------------|
|
|
141
|
+
| `backend` | `"auto"` | `"auto"`, `"zellij"`, or `"tmux"` |
|
|
142
|
+
| `claudeCommand` | `"claude"` | Path to Claude CLI |
|
|
143
|
+
| `claudeArgs` | `["--dangerously-skip-permissions"]` | Default args for new sessions and resumed sessions |
|
|
144
|
+
| `historyLimit` | `100` | Max sessions loaded for AI search |
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
ch config set backend tmux
|
|
148
|
+
ch config set historyLimit 200
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Recommended Aliases
|
|
152
|
+
|
|
153
|
+
Add to your `.zshrc` or `.bashrc`:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
alias cn="ch new"
|
|
157
|
+
alias cnf="ch new -f"
|
|
158
|
+
alias cls="ch ls"
|
|
159
|
+
alias chs="ch search"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Then use:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
cn fix login bug # new session with description
|
|
166
|
+
cn 修复登录bug # Chinese descriptions supported
|
|
167
|
+
cnf # force restart current project session
|
|
168
|
+
cls # interactive list of active sessions
|
|
169
|
+
chs 龙虾 # keyword search
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## How It Works
|
|
173
|
+
|
|
174
|
+
1. **History scanning** — Reads `~/.claude/projects/**/*.jsonl`, extracts session metadata and first user messages. Results are cached (`~/.config/cch/cache.json`) by file mtime for fast subsequent lookups.
|
|
175
|
+
|
|
176
|
+
2. **AI search** — Builds a text table of all sessions, sends it to `claude -p` (Haiku model preferred for speed, auto-fallback to default). Parses the response to find matching session numbers.
|
|
177
|
+
|
|
178
|
+
3. **Multiplexer integration** — Creates named sessions in Zellij or tmux. For Zellij, generates temporary KDL layout/config files with `zsh -lc` to ensure full shell environment. For tmux, uses standard `new-session`/`attach` commands. Auto-detects which multiplexer is available (Zellij preferred).
|
|
179
|
+
|
|
180
|
+
4. **Session naming** — Sessions are named `ch-<dirname>[-<description-or-hash>]`. English descriptions are slugified into the name; Chinese descriptions use an MD5 hash prefix. The `ch-` prefix makes them identifiable in `zellij ls` / `tmux ls`.
|
|
181
|
+
|
|
182
|
+
5. **Session metadata** — Descriptions, cwd, and creation time are persisted in `~/.config/cch/sessions.json`, surviving reboots. Used by `ch ls` to display descriptions and sort by creation time.
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# cch — Claude Code History
|
|
2
|
+
|
|
3
|
+
为 [Claude Code](https://docs.anthropic.com/en/docs/claude-code) 打造的 AI 对话历史管理工具。
|
|
4
|
+
|
|
5
|
+
用自然语言找到任何一个过去的对话,在 Zellij 或 tmux 里恢复它——跨所有项目。
|
|
6
|
+
|
|
7
|
+
## 痛点
|
|
8
|
+
|
|
9
|
+
Claude Code 的对话历史存在 `~/.claude/projects/` 下,按项目目录隔离。当你同时在多个 repo 工作时:
|
|
10
|
+
|
|
11
|
+
- `claude --resume` 只能看到**当前目录**的历史
|
|
12
|
+
- 无法跨项目搜索某个对话
|
|
13
|
+
- 关掉终端就丢失活跃会话
|
|
14
|
+
- 没有全局视图查看正在运行的 Claude 会话
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g cch
|
|
20
|
+
ch setup # 自动添加 shell 别名 (cn, cnf, cls, cps, chs)
|
|
21
|
+
source ~/.zshrc # 或新开终端
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Claude Code Skill(可选)
|
|
25
|
+
|
|
26
|
+
安装 skill 后,Claude Code 就能自动帮你用 `ch` 命令:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cp -r $(npm root -g)/cch/skill ~/.claude/skills/cch
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
安装后直接对 Claude Code 说"帮我找之前调试 iOS 的对话",它会自动调用 `ch` 搜索。
|
|
33
|
+
|
|
34
|
+
**前置条件:**
|
|
35
|
+
- Node.js >= 18
|
|
36
|
+
- 已安装 [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code)
|
|
37
|
+
- 已安装 [Zellij](https://zellij.dev/) 或 [tmux](https://github.com/tmux/tmux)(至少一个)
|
|
38
|
+
|
|
39
|
+
## 使用方法
|
|
40
|
+
|
|
41
|
+
### 自然语言搜索(核心功能)
|
|
42
|
+
|
|
43
|
+
随便描述你记得的内容,AI 帮你找到对应的对话。
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
ch 上次帮我调试 iOS 的那个对话
|
|
47
|
+
ch 帮我部署虾的那几个
|
|
48
|
+
ch donut 钱包重构的那个
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`ch` 会把你的描述和会话列表一起发给 `claude -p`(优先使用 Haiku 模型加速,失败自动回退到默认模型),返回最匹配的结果。选中后直接在终端复用器里恢复。
|
|
52
|
+
|
|
53
|
+
### 命令一览
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
ch <描述> 自然语言搜索(默认行为)
|
|
57
|
+
ch list [-n 20] 列出最近的历史会话(交互式选择器)
|
|
58
|
+
ch search <关键词> 精确关键词搜索对话内容
|
|
59
|
+
ch new [描述] 在当前目录新建 Claude 会话
|
|
60
|
+
ch new -f [描述] 强制新建(先关闭同名旧会话)
|
|
61
|
+
ch ls 查看活跃的终端复用器会话(交互式选择器)
|
|
62
|
+
ch attach <会话名> 连接到一个活跃会话
|
|
63
|
+
ch kill <会话名> 关闭一个会话
|
|
64
|
+
ch resume <session-id> 通过 session ID 恢复
|
|
65
|
+
ch config 查看配置
|
|
66
|
+
ch config set <key> <value> 修改配置
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 交互式选择器
|
|
70
|
+
|
|
71
|
+
`ch list` 和 `ch ls` 都支持交互式选择:
|
|
72
|
+
|
|
73
|
+
- **上下箭头** 或 **j/k** — 导航选择
|
|
74
|
+
- **数字键** — 输入数字(如 `12`)然后 **Enter** 直接跳转
|
|
75
|
+
- **Enter** — 确认选择(恢复历史会话或连接活跃会话)
|
|
76
|
+
- **Esc** 或 **q** — 取消退出
|
|
77
|
+
|
|
78
|
+
中文文本使用显示宽度感知的列对齐,不会错位。
|
|
79
|
+
|
|
80
|
+
### 两级恢复
|
|
81
|
+
|
|
82
|
+
**第一级 — 活跃会话:** 会话还在终端复用器里运行?
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
ch ls # 交互式列表 — 选一个直接连接
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**第二级 — 历史恢复:** 会话已结束,想重新捡起来?
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
ch 那个讨论登录bug的对话 # AI 帮你找
|
|
92
|
+
# 或者
|
|
93
|
+
ch list # 交互式列表 — 选一个恢复
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
两种方式都会在 Zellij/tmux 会话里打开,通过登录 shell(`zsh -lc`)启动以继承完整环境和认证信息。随时可以断开和重连。
|
|
97
|
+
|
|
98
|
+
### 会话管理
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# 在当前项目启动新的 Claude 会话
|
|
102
|
+
ch new
|
|
103
|
+
|
|
104
|
+
# 带描述(会显示在 ch ls 和 Zellij tab 名中)
|
|
105
|
+
ch new "fix authentication bug"
|
|
106
|
+
ch new 修复登录bug # 支持中文描述
|
|
107
|
+
|
|
108
|
+
# 强制重启(先关闭旧会话)
|
|
109
|
+
ch new -f "重新开始搞认证"
|
|
110
|
+
|
|
111
|
+
# 查看正在运行的会话(按创建时间倒序,最新的在最上面)
|
|
112
|
+
ch ls
|
|
113
|
+
|
|
114
|
+
# 清理
|
|
115
|
+
ch kill ch-myproject-fix-auth
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 会话描述
|
|
119
|
+
|
|
120
|
+
传给 `ch new` 的描述会用在多个地方:
|
|
121
|
+
|
|
122
|
+
- **Zellij tab 名** — 进入会话后在 tab 栏可见(支持中文)
|
|
123
|
+
- **`ch ls` 输出** — 显示在会话名旁边
|
|
124
|
+
- **会话名** — 英文描述直接拼入会话名(如 `ch-infist-fix-login-bug`),中文描述使用哈希缩写(如 `ch-infist-a1b2c3`),因为 Zellij 会话名不支持 CJK 字符
|
|
125
|
+
|
|
126
|
+
## 配置
|
|
127
|
+
|
|
128
|
+
配置文件位于 `~/.config/cch/config.json`:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"backend": "auto",
|
|
133
|
+
"claudeCommand": "claude",
|
|
134
|
+
"claudeArgs": ["--dangerously-skip-permissions"],
|
|
135
|
+
"historyLimit": 100
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| 配置项 | 默认值 | 说明 |
|
|
140
|
+
|--------|--------|------|
|
|
141
|
+
| `backend` | `"auto"` | `"auto"`、`"zellij"` 或 `"tmux"` |
|
|
142
|
+
| `claudeCommand` | `"claude"` | Claude CLI 路径 |
|
|
143
|
+
| `claudeArgs` | `["--dangerously-skip-permissions"]` | 新建会话和恢复会话时的默认参数 |
|
|
144
|
+
| `historyLimit` | `100` | AI 搜索时加载的最大会话数 |
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
ch config set backend tmux
|
|
148
|
+
ch config set historyLimit 200
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## 推荐别名
|
|
152
|
+
|
|
153
|
+
加到你的 `.zshrc` 或 `.bashrc`:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
alias cn="ch new"
|
|
157
|
+
alias cnf="ch new -f"
|
|
158
|
+
alias cls="ch ls"
|
|
159
|
+
alias chs="ch search"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
然后使用:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
cn fix login bug # 带描述新建会话
|
|
166
|
+
cn 修复登录bug # 支持中文描述
|
|
167
|
+
cnf # 强制重启当前项目会话
|
|
168
|
+
cls # 交互式查看活跃会话
|
|
169
|
+
chs 龙虾 # 关键词搜索
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## 工作原理
|
|
173
|
+
|
|
174
|
+
1. **历史扫描** — 读取 `~/.claude/projects/**/*.jsonl`,提取会话元信息和用户的前几条消息。按文件修改时间缓存到 `~/.config/cch/cache.json`,后续查询秒开。
|
|
175
|
+
|
|
176
|
+
2. **AI 搜索** — 构建所有会话的文本列表,连同你的自然语言描述一起发给 `claude -p`(优先使用 Haiku 模型加速,自动回退到默认模型)。解析返回的编号找到匹配的会话。
|
|
177
|
+
|
|
178
|
+
3. **终端复用器集成** — 在 Zellij 或 tmux 中创建命名会话。Zellij 通过生成临时 KDL 布局/配置文件,使用 `zsh -lc` 启动以确保完整的 shell 环境。tmux 使用标准的 `new-session`/`attach` 命令。自动检测可用的复用器(优先 Zellij)。
|
|
179
|
+
|
|
180
|
+
4. **会话命名** — 格式为 `ch-<目录名>[-<描述或哈希>]`。英文描述会 slug 化拼入名称;中文描述使用 MD5 哈希前缀。`ch-` 前缀方便在 `zellij ls` / `tmux ls` 中识别。
|
|
181
|
+
|
|
182
|
+
5. **会话元数据** — 描述、工作目录和创建时间持久化存储在 `~/.config/cch/sessions.json`,重启不丢失。`ch ls` 用它来显示描述和按创建时间排序。
|
|
183
|
+
|
|
184
|
+
## 许可证
|
|
185
|
+
|
|
186
|
+
MIT
|
package/bin/ch.js
ADDED