@liuyoumi/codex-history 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/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +173 -0
- package/README.zh-CN.md +173 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1244 -0
- package/package.json +56 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 - 2026-05-27
|
|
4
|
+
|
|
5
|
+
Initial release candidate.
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `doctor` command for local Codex data model checks.
|
|
10
|
+
- `list` command for local conversation discovery.
|
|
11
|
+
- `list --grep` filtering for displayed title, id, and cwd matching.
|
|
12
|
+
- `purge <id>` execution by full id or unique short id prefix.
|
|
13
|
+
- Interactive purge confirmation by typing the standard short id.
|
|
14
|
+
- `purge <id> --force` for non-interactive execution.
|
|
15
|
+
- Guarded purge execution with mandatory backups.
|
|
16
|
+
- SQLite cleanup for supported Codex stores.
|
|
17
|
+
- JSON and JSONL state cleanup for supported Codex files.
|
|
18
|
+
- Rollout jsonl and shell snapshot deletion.
|
|
19
|
+
- WAL checkpointing after SQLite mutation.
|
|
20
|
+
- Post-purge verification with non-zero exit on remaining supported references.
|
|
21
|
+
- Fixture-based tests that do not read or modify a real `~/.codex`.
|
|
22
|
+
|
|
23
|
+
### Notes
|
|
24
|
+
|
|
25
|
+
- v0.1.0 is macOS-first.
|
|
26
|
+
- Server-side deletion is not supported or claimed.
|
|
27
|
+
- Physical secure erase from SSDs, APFS snapshots, or Time Machine backups is not supported.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 liuyoumi
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# codex-history
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
A small CLI for finding and removing local Codex conversation history.
|
|
6
|
+
|
|
7
|
+
`codex-history` works on local Codex data files on your machine. It lists conversations using the same short titles shown by Codex when available, lets you narrow the list with `--grep`, and deletes one resolved conversation only after confirmation.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @liuyoumi/codex-history
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or run it without installing:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @liuyoumi/codex-history doctor
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Supported Platforms
|
|
22
|
+
|
|
23
|
+
- macOS: verified for v0.1
|
|
24
|
+
- Windows/Linux: not verified yet
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
codex-history doctor
|
|
30
|
+
codex-history list
|
|
31
|
+
codex-history list --grep "Astro"
|
|
32
|
+
codex-history purge 019e6885
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`purge` prints the resolved conversation and asks you to type the standard short id before it deletes anything:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
About to purge this local Codex conversation:
|
|
39
|
+
|
|
40
|
+
title: Implement Astro blog visual audit
|
|
41
|
+
id: 019e6885-b5ae-7ae0-a50d-ce5f75b0ac08
|
|
42
|
+
cwd: /Users/me/Projects/example
|
|
43
|
+
updated: 2026-05-28T03:16:01.959Z
|
|
44
|
+
|
|
45
|
+
A backup will be created before deletion.
|
|
46
|
+
Type 019e6885 to confirm:
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Commands
|
|
50
|
+
|
|
51
|
+
| Command | Description |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `codex-history doctor` | Check whether the local Codex data layout is supported. |
|
|
54
|
+
| `codex-history list` | List local conversations. |
|
|
55
|
+
| `codex-history list --grep <keyword>` | Filter conversations by title, id, or cwd. |
|
|
56
|
+
| `codex-history purge <id>` | Remove one resolved local conversation after confirmation. |
|
|
57
|
+
|
|
58
|
+
### `doctor`
|
|
59
|
+
|
|
60
|
+
Check whether the local Codex data layout is supported by this version.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
codex-history doctor
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Run this first after installing, or after a Codex update. If the local data layout is not supported, destructive commands fail closed instead of guessing how to delete.
|
|
67
|
+
|
|
68
|
+
### `list`
|
|
69
|
+
|
|
70
|
+
List local Codex conversations.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
codex-history list
|
|
74
|
+
codex-history list --grep "Astro"
|
|
75
|
+
codex-history list --limit 20
|
|
76
|
+
codex-history list --pretty=medium
|
|
77
|
+
codex-history list --pretty=full
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Default output is one line per conversation:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
019e6885 Implement Astro blog visual audit
|
|
84
|
+
019e6874 Review Astro blog visual plan
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`--grep` filters by displayed title, thread id, and cwd. It does not search or print prompt bodies.
|
|
88
|
+
|
|
89
|
+
Use the short id shown by `list`, or paste a full thread id, when running `purge`.
|
|
90
|
+
|
|
91
|
+
By default, `list` shows non-archived conversations. Use `--archived` for archived conversations only, or `--all` for both archived and non-archived conversations.
|
|
92
|
+
|
|
93
|
+
Wrap grep text in quotes when it contains spaces:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
codex-history list --grep "Astro blog"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`--pretty` formats:
|
|
100
|
+
|
|
101
|
+
- `oneline`: short id and title
|
|
102
|
+
- `medium`: full id, updated time, and cwd
|
|
103
|
+
- `full`: `medium` plus created time, archive state, and rollout path
|
|
104
|
+
|
|
105
|
+
When `list` runs in an interactive terminal without `--limit`, output is sent through the system pager. Piped or redirected output skips the pager automatically.
|
|
106
|
+
|
|
107
|
+
### `purge`
|
|
108
|
+
|
|
109
|
+
Remove one local Codex conversation by full id or unique short id prefix.
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
codex-history purge 019e6885
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
For scripts or non-interactive shells, use `--force`:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
codex-history purge 019e6885 --force
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`--force` skips only the interactive short-id confirmation. It still keeps schema validation, mandatory backup, active-thread protection, and post-purge verification.
|
|
122
|
+
|
|
123
|
+
## Options
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
codex-history --codex-home /path/to/.codex list
|
|
127
|
+
codex-history --json list --grep "Astro"
|
|
128
|
+
codex-history --json purge 019e6885 --force
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
- `--codex-home` defaults to `~/.codex`.
|
|
132
|
+
- `--json` prints machine-readable output. For `purge`, JSON output requires `--force` because interactive confirmation is text-only.
|
|
133
|
+
- Color is enabled only in interactive terminals and respects `NO_COLOR`.
|
|
134
|
+
|
|
135
|
+
## Safety
|
|
136
|
+
|
|
137
|
+
Before deleting, `codex-history`:
|
|
138
|
+
|
|
139
|
+
- validates the supported Codex data model
|
|
140
|
+
- resolves the target to exactly one conversation
|
|
141
|
+
- refuses the currently active thread when detectable
|
|
142
|
+
- creates a mandatory backup under `~/.codex-history/backups`
|
|
143
|
+
- removes known references from supported local Codex stores
|
|
144
|
+
- verifies supported stores after mutation
|
|
145
|
+
|
|
146
|
+
This tool only changes local Codex data. It does not delete server-side OpenAI/Codex records, OS backups, terminal scrollback, crash reports, or user-created transcript copies.
|
|
147
|
+
|
|
148
|
+
## Q&A
|
|
149
|
+
|
|
150
|
+
### Does this delete server-side Codex data?
|
|
151
|
+
|
|
152
|
+
No. It only modifies supported local files on your machine.
|
|
153
|
+
|
|
154
|
+
### Where are backups stored?
|
|
155
|
+
|
|
156
|
+
Backups are written under `~/.codex-history/backups`.
|
|
157
|
+
|
|
158
|
+
### Can I recover a purged conversation?
|
|
159
|
+
|
|
160
|
+
The tool creates a backup before deletion, but v0.1 does not include an automatic restore command. Treat `purge` as destructive.
|
|
161
|
+
|
|
162
|
+
## Development
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npm install
|
|
166
|
+
npm run typecheck
|
|
167
|
+
npm test
|
|
168
|
+
npm run build
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# codex-history
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
一个用来查找并删除本地 Codex 对话历史的小型命令行工具。
|
|
6
|
+
|
|
7
|
+
`codex-history` 只处理你机器上的本地 Codex 数据。它会尽量使用 Codex 对话列表里显示的短标题,支持用 `--grep` 缩小范围,并且只会在你确认目标后删除一条明确解析出来的对话。
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @liuyoumi/codex-history
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
也可以不安装直接运行:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @liuyoumi/codex-history doctor
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 支持平台
|
|
22
|
+
|
|
23
|
+
- macOS:v0.1 已验证
|
|
24
|
+
- Windows/Linux:暂未验证
|
|
25
|
+
|
|
26
|
+
## 快速开始
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
codex-history doctor
|
|
30
|
+
codex-history list
|
|
31
|
+
codex-history list --grep "Astro"
|
|
32
|
+
codex-history purge 019e6885
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`purge` 会先展示解析到的对话信息,并要求你输入标准短 id,确认后才会删除:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
About to purge this local Codex conversation:
|
|
39
|
+
|
|
40
|
+
title: 实施 Astro 博客视觉审计工具
|
|
41
|
+
id: 019e6885-b5ae-7ae0-a50d-ce5f75b0ac08
|
|
42
|
+
cwd: /Users/me/Projects/example
|
|
43
|
+
updated: 2026-05-28T03:16:01.959Z
|
|
44
|
+
|
|
45
|
+
A backup will be created before deletion.
|
|
46
|
+
Type 019e6885 to confirm:
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 命令
|
|
50
|
+
|
|
51
|
+
| 命令 | 说明 |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `codex-history doctor` | 检查当前本地 Codex 数据结构是否受支持。 |
|
|
54
|
+
| `codex-history list` | 列出本地对话。 |
|
|
55
|
+
| `codex-history list --grep <keyword>` | 按标题、id 或 cwd 过滤对话。 |
|
|
56
|
+
| `codex-history purge <id>` | 确认后删除一条解析到的本地对话。 |
|
|
57
|
+
|
|
58
|
+
### `doctor`
|
|
59
|
+
|
|
60
|
+
检查当前本地 Codex 数据结构是否被这个版本支持。
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
codex-history doctor
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
建议安装后先跑一次;Codex 更新后也可以再跑一次。如果当前数据结构不受支持,删除命令会拒绝执行,而不是猜测应该怎么删。
|
|
67
|
+
|
|
68
|
+
### `list`
|
|
69
|
+
|
|
70
|
+
列出本地 Codex 对话。
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
codex-history list
|
|
74
|
+
codex-history list --grep "Astro"
|
|
75
|
+
codex-history list --limit 20
|
|
76
|
+
codex-history list --pretty=medium
|
|
77
|
+
codex-history list --pretty=full
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
默认是一行一条:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
019e6885 实施 Astro 博客视觉审计工具
|
|
84
|
+
019e6874 评审 Astro 博客视觉方案
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`--grep` 会按显示标题、线程 id、cwd 过滤。它不会搜索或输出对话正文。
|
|
88
|
+
|
|
89
|
+
执行 `purge` 时,可以使用 `list` 里显示的短 id,也可以粘贴完整 thread id。
|
|
90
|
+
|
|
91
|
+
默认情况下,`list` 只显示未归档对话。使用 `--archived` 只看已归档对话,使用 `--all` 同时查看已归档和未归档对话。
|
|
92
|
+
|
|
93
|
+
如果 grep 关键词里有空格,请加引号:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
codex-history list --grep "Astro 博客"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`--pretty` 支持:
|
|
100
|
+
|
|
101
|
+
- `oneline`:短 id 和标题
|
|
102
|
+
- `medium`:完整 id、更新时间、cwd
|
|
103
|
+
- `full`:在 `medium` 基础上增加创建时间、归档状态、rollout 路径
|
|
104
|
+
|
|
105
|
+
在交互式终端里,如果 `list` 没有加 `--limit`,输出会进入系统分页器。管道或重定向输出会自动跳过分页器。
|
|
106
|
+
|
|
107
|
+
### `purge`
|
|
108
|
+
|
|
109
|
+
通过完整 id 或唯一短 id 前缀删除一条本地 Codex 对话。
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
codex-history purge 019e6885
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
脚本或非交互环境可以使用 `--force`:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
codex-history purge 019e6885 --force
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`--force` 只跳过交互式短 id 确认,不会跳过数据结构校验、强制备份、active thread 保护和删除后的验证。
|
|
122
|
+
|
|
123
|
+
## 选项
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
codex-history --codex-home /path/to/.codex list
|
|
127
|
+
codex-history --json list --grep "Astro"
|
|
128
|
+
codex-history --json purge 019e6885 --force
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
- `--codex-home` 默认是 `~/.codex`。
|
|
132
|
+
- `--json` 输出机器可读的 JSON。`purge` 使用 JSON 输出时必须加 `--force`,因为交互确认只适合文本模式。
|
|
133
|
+
- 颜色只会在交互式终端中启用,并遵守 `NO_COLOR`。
|
|
134
|
+
|
|
135
|
+
## 安全机制
|
|
136
|
+
|
|
137
|
+
删除前,`codex-history` 会:
|
|
138
|
+
|
|
139
|
+
- 校验当前 Codex 本地数据结构是否受支持
|
|
140
|
+
- 将目标解析到唯一一条对话
|
|
141
|
+
- 在可检测时拒绝删除当前 active thread
|
|
142
|
+
- 在 `~/.codex-history/backups` 下创建强制备份
|
|
143
|
+
- 从受支持的本地 Codex 数据中移除已知引用
|
|
144
|
+
- 删除后扫描受支持的数据存储,确认目标引用已经移除
|
|
145
|
+
|
|
146
|
+
这个工具只处理本地 Codex 数据。它不会删除 OpenAI/Codex 服务端记录、系统备份、终端滚动历史、崩溃报告,或你手动保存过的对话副本。
|
|
147
|
+
|
|
148
|
+
## Q&A
|
|
149
|
+
|
|
150
|
+
### 会删除 Codex 服务端数据吗?
|
|
151
|
+
|
|
152
|
+
不会。它只修改你机器上受支持的本地文件。
|
|
153
|
+
|
|
154
|
+
### 备份在哪里?
|
|
155
|
+
|
|
156
|
+
备份会写入 `~/.codex-history/backups`。
|
|
157
|
+
|
|
158
|
+
### 删除后还能恢复吗?
|
|
159
|
+
|
|
160
|
+
工具会在删除前创建备份,但 v0.1 还没有自动恢复命令。请把 `purge` 当作破坏性操作对待。
|
|
161
|
+
|
|
162
|
+
## 开发
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npm install
|
|
166
|
+
npm run typecheck
|
|
167
|
+
npm test
|
|
168
|
+
npm run build
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 许可证
|
|
172
|
+
|
|
173
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|