agent-dump 1.0.0__py3-none-win_amd64.whl

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.
@@ -0,0 +1,627 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-dump
3
+ Version: 1.0.0
4
+ Classifier: Environment :: Console
5
+ Classifier: License :: OSI Approved :: MIT License
6
+ Classifier: Programming Language :: Rust
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Topic :: Utilities
14
+ License-File: LICENSE
15
+ Summary: AI Coding Assistant Session Export Tool
16
+ Keywords: ai,chat,export,opencode,cli
17
+ Author-email: XingKaiXin <xingkaixin@gmail.com>
18
+ License-Expression: MIT
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
21
+ Project-URL: Homepage, https://github.com/xingkaixin/agent-dump
22
+ Project-URL: Issues, https://github.com/xingkaixin/agent-dump/issues
23
+ Project-URL: Repository, https://github.com/xingkaixin/agent-dump
24
+
25
+ ![logo](https://raw.githubusercontent.com/xingkaixin/agent-dump/refs/heads/main/assets/logo.png)
26
+
27
+ # Agent Dump
28
+
29
+ AI Coding Assistant Session Export Tool - Exports JSON, Markdown, and raw session data from multiple AI coding tools, with direct URI printing.
30
+
31
+ Step-by-step guide: [Export a Codex session to Markdown](https://agent-dump.xingkaixin.me/guides/export-codex-session/).
32
+
33
+ ## Supported AI Tools
34
+
35
+ - **OpenCode** - Open source AI coding assistant
36
+ - **ZCode** - ZCode coding assistant sessions
37
+ - **Claude Code** - Anthropic's AI coding tool
38
+ - **Codex** - OpenAI's command-line AI coding assistant
39
+ - **Kimi** - Moonshot AI assistant
40
+ - **Cursor** - Cursor composer sessions
41
+ - **Pi** - Earendil's AI coding agent
42
+ - **DeepChat** - Current local sessions from unencrypted databases
43
+ - **Cherry Studio** - Local 2.x chats and agent sessions
44
+ - **MiniMax Code** - Current CLI sessions from local SQLite storage
45
+ - **More Tools** - PRs are welcome to support other AI coding tools
46
+
47
+ ## Features
48
+
49
+ - **Interactive Selection**: Provides a friendly command-line interactive interface using Ratatui
50
+ - **Multi-Agent Support**: Automatically scan session data from multiple AI tools
51
+ - **Batch Export**: Supports exporting all sessions from the last N days
52
+ - **Specific Export**: Export specific sessions by URI
53
+ - **Session List**: Only list sessions without exporting them
54
+ - **Direct Text Dump**: View session content directly in terminal via URI (e.g., `agent-dump opencode://session-id`)
55
+ - **Statistics**: Exports include statistics such as token usage and cost
56
+ - **Message Details**: Fully retains session messages, tool calls, and other details
57
+ - **Smart Title Extraction**: Automatically extract session titles from agent metadata
58
+ - **Session Statistics**: View usage statistics grouped by agent and time (`--stats`)
59
+ - **Full-Text Search**: Local SQLite FTS5 search across session titles, messages, reasoning, and tool state (`--search`); terms are matched literally
60
+ - **Ranked Search Evidence**: Search results include rank, URI, updated time, and highlighted snippets
61
+ - **Actionable Diagnostics**: CLI errors show checked roots, parsed URI fields, capability gaps, and next steps (localized via `--lang en|zh`)
62
+
63
+ ## Path Discovery
64
+
65
+ `agent-dump` resolves most session roots in this order: official environment variable, tool default directory, then local development fallback under `data/<agent>`. ZCode currently uses only its macOS/Windows default database path.
66
+
67
+ - **Codex**: `CODEX_HOME` -> `~/.codex` -> `data/codex`
68
+ - **Claude Code**: `CLAUDE_CONFIG_DIR` -> `~/.claude` -> `data/claudecode`
69
+ - **Kimi**: `KIMI_SHARE_DIR` -> `~/.kimi` -> `data/kimi`
70
+ - **OpenCode**: `OPENCODE_DB` selects one database (relative to `XDG_DATA_HOME/opencode` or `~/.local/share/opencode`). Otherwise use `opencode.db` there, then the legacy Windows `LOCALAPPDATA`/`APPDATA` location, then `data/opencode/opencode.db`.
71
+ - **ZCode**: macOS `~/.zcode/cli/db/db.sqlite`; Windows `%USERPROFILE%\.zcode\cli\db\db.sqlite`; no Linux default path
72
+ - **Cursor**: Cursor's default user `globalStorage/state.vscdb`
73
+ - **Pi**: `PI_HOME` -> `~/.pi` -> `data/pi`
74
+ - **DeepChat**: `DEEPCHAT_USER_DATA_DIR/app_db/agent.db`; defaults to macOS `~/Library/Application Support/DeepChat/app_db/agent.db`, Windows `%APPDATA%\DeepChat\app_db\agent.db`, or Linux `${XDG_CONFIG_HOME:-~/.config}/DeepChat/app_db/agent.db`.
75
+ - **Cherry Studio**: `CHERRY_STUDIO_USER_DATA_DIR/Data/cherrystudio.sqlite`; otherwise the first existing database in the user data directories configured by `~/.cherrystudio/boot-config.json`, then the platform default: macOS `~/Library/Application Support/CherryStudio`, Windows `%APPDATA%\CherryStudio`, or Linux `${XDG_CONFIG_HOME:-~/.config}/CherryStudio` (each with `Data/cherrystudio.sqlite`). The override is provided by agent-dump; use it for portable/dev installations or to select among multiple installations.
76
+ - **MiniMax Code**: `MINIMAX_DATA_DIR` → `MAVIS_DATA_DIR` → `~/.minimax`; the database is `v2/sqlite/runtime-state.sqlite` under the selected root. Only one root is selected; a missing explicit path never falls back to another installation.
77
+
78
+ Notes:
79
+
80
+ - On Windows, prefer configuring the tool's official environment variable when available.
81
+ - The `data/<agent>` fallback is kept for local development and tests.
82
+
83
+ DeepChat reads saved sessions in the current `agent.db`, including migrated history, ACP sessions, and subagent sessions; drafts are excluded. It supports listing, query, search, stats, collect, and print / JSON / Markdown exports. Structured messages take precedence over the `content` fallback. Text, reasoning, and tool records are normalized; compaction markers do not enter collect. JSON also retains attachment references, links, and other message blocks. Attachment files and offloaded tool output are not read. Token totals come from message records; billing cost is unavailable.
84
+
85
+ SQLCipher databases, direct reads of legacy `chat.db`, and raw export are unsupported. The reader does not run DeepChat migrations or Tape recovery. Set `DEEPCHAT_USER_DATA_DIR` to read a custom user data directory.
86
+
87
+ Cherry Studio supports listing, query, search, stats, collect, and print / JSON / Markdown exports from its current 2.x database, including migrated history. Ordinary chats expose only the active root-to-leaf path; other branches and parallel model replies are excluded from exports, search, and counts. Structural roots and empty reserved user leaves are excluded. Agent sessions are read chronologically and use their workspace as the working directory; ordinary chats have no working directory. Deleted sessions and chat messages are excluded.
88
+
89
+ Text, reasoning, tool calls/results, code, and translations are normalized. JSON retains file references and control events; compaction summaries and internal events do not enter collect or search. Token totals come from message stats. Per-currency costs are preserved in JSON without conversion or an aggregate billing total. The reader never opens attachment files, scans SDK logs, or runs application migrations. Direct reads of 1.x IndexedDB/Redux data and raw export are unsupported.
90
+
91
+ MiniMax Code supports listing, query, search, stats, collect, and print / JSON / Markdown exports from the current CLI's migrated display messages. Visible conversations, child tasks, and archived sessions are included; hidden and internal peek/channel/cron sessions are excluded. Messages follow database row order and preserve text, reasoning, tool state/results, and attachment references. Compaction, review, and system events do not enter collect or search. The model comes from session metadata and remains unknown when absent; JSON retains recorded per-message token usage without estimating billing cost.
92
+
93
+ Set `MINIMAX_DATA_DIR` explicitly for custom profiles, earlier source builds using `~/.minimax-code`, or other directories. The reader does not read model-context JSONL or attachment files, run migrations, or recover rewound messages. Raw export, direct legacy storage reads, and desktop data are unsupported. Pending migrations and corrupt sessions produce diagnostics instead of appearing empty. See the [MiniMax Code design and acceptance scope](docs/minimax-provider-design.md).
94
+
95
+ OpenCode supports legacy SQLite and 2.x `session_v2/session_message`. When both schemas coexist, V2 wins for the same session ID; legacy-only sessions remain readable. V2 messages follow `seq` order, and counts include system and status records. Synthetic input, system/skill messages, compaction and shell records are excluded from collect. `OPENCODE_DB` selects a custom or channel database; a missing explicit path never falls back, and `:memory:` is unavailable. Attachments stay in JSON metadata without fetching referenced files. Running and archived records remain readable; pending inbox items are excluded. Raw export remains normalized `.raw.json`, not an OpenCode import file. See the [design and acceptance scope](docs/opencode-v2-design.md).
96
+
97
+ ## Installation
98
+
99
+ Starting with v1.0.0, distribution artifacts use Rust. Version 0.15.9 is the last Python release. Rust wheels provide only the `agent-dump` command: Python imports and `python -m agent_dump` are no longer included. Applications using the old API can pin `agent-dump==0.15.9`.
100
+
101
+ Prebuilt artifacts support macOS x64/arm64, Linux x64 (glibc ≥ 2.17), and Windows x64. Linux musl/Alpine has no prebuilt wheel. Wheel installation needs no Rust compiler; building from Git/sdist requires Rust 1.90.0 and a C toolchain.
102
+
103
+ ```bash
104
+ pip install agent-dump
105
+ ```
106
+
107
+ ### Method 1: Install using uv tool (Recommended)
108
+
109
+ ```bash
110
+ # Install from PyPI (Available after release)
111
+ uv tool install agent-dump
112
+
113
+ # Install directly from GitHub
114
+ uv tool install git+https://github.com/xingkaixin/agent-dump
115
+ ```
116
+
117
+ ### Method 2: Run directly using uvx (No installation required)
118
+
119
+ ```bash
120
+ # Run from PyPI (Available after release)
121
+ uvx agent-dump --help
122
+
123
+ # Run directly from GitHub
124
+ uvx --from git+https://github.com/xingkaixin/agent-dump agent-dump --help
125
+ ```
126
+
127
+ ### Method 3: Run directly using bunx / npx (No Python required)
128
+
129
+ ```bash
130
+ # Run from npm
131
+ bunx @agent-dump/cli --help
132
+ npx @agent-dump/cli --help
133
+ ```
134
+
135
+ The `bunx`, `npx`, and global npm/pnpm/Bun installation paths all require Node.js 22 or newer.
136
+ They execute the same Node.js package wrapper before launching the native binary.
137
+
138
+ `@agent-dump/cli` delegates the platform-package download to npm, preserving scoped registries,
139
+ authentication, proxy, and CA settings, then verifies the published checksum before installation.
140
+
141
+ Supported native targets:
142
+
143
+ <!-- native-targets:start -->
144
+ - `darwin-x64`
145
+ - `darwin-arm64`
146
+ - `linux-x64`
147
+ - `win32-x64`
148
+ <!-- native-targets:end -->
149
+
150
+ If your platform is unsupported, the wrapper prints the detected platform/arch pair and points to the GitHub releases page.
151
+
152
+ ### Method 4: Local Development
153
+
154
+ ```bash
155
+ # Clone the repository
156
+ git clone https://github.com/xingkaixin/agent-dump.git
157
+ cd agent-dump
158
+
159
+ # Build the native CLI
160
+ cargo build --locked --release
161
+
162
+ # Local installation test
163
+ uv tool install . --force
164
+ ```
165
+
166
+ ### Method 5: Install as a Skill
167
+
168
+ ```bash
169
+ npx skills add xingkaixin/agent-dump
170
+ ```
171
+
172
+ ## Usage
173
+
174
+ ### Interactive Export
175
+
176
+ ```bash
177
+ # Enter interactive mode to select and export sessions
178
+ agent-dump --interactive
179
+
180
+ # Or use the source build
181
+ ./target/release/agent-dump --interactive
182
+ ```
183
+
184
+ After running, it will display the list of sessions from the last 7 days grouped by time (Today, Yesterday, This Week, This Month, Earlier). Use the spacebar to select/deselect, and press Enter to confirm the export.
185
+
186
+ > **Note:** Starting from v0.3.0, the default behavior has changed. Running `agent-dump` without arguments now shows the help message. Use `--interactive` to enter interactive mode.
187
+ >
188
+ > If multiple explicit modes are supplied, agent-dump preserves the existing mode priority and prints a warning listing the lower-priority options it ignored.
189
+
190
+ ### URI Mode (Direct Text Dump)
191
+
192
+ Quickly view session content directly in the terminal without exporting to a file:
193
+
194
+ ```bash
195
+ # View a specific session by URI
196
+ agent-dump opencode://session-id-abc123
197
+
198
+ # The URI format is shown in list mode and interactive selector
199
+ # • Session Title (opencode://session-id-abc123)
200
+ ```
201
+
202
+ Supported URI schemes:
203
+ - `opencode://<session_id>` - OpenCode sessions
204
+ - `zcode://<session_id>` - ZCode sessions
205
+ - `codex://<session_id>` - Codex sessions
206
+ - `codex://threads/<session_id>` - Codex sessions
207
+ - `kimi://<session_id>` - Kimi sessions
208
+ - `claude://<session_id>` - Claude Code sessions
209
+ - `cursor://<requestid>` - Cursor sessions (`requestid` is used as URI identifier)
210
+ - `pi://<session_id>` - Pi sessions
211
+ - `deepchat://<session_id>` - DeepChat sessions
212
+ - `cherry://topic-<id>` / `cherry://session-<id>` - Cherry Studio chats / agent sessions
213
+ - `minimax://<session_id>` - MiniMax Code CLI sessions
214
+
215
+ ### Typical Errors
216
+
217
+ `agent-dump` reports actionable diagnostics instead of a single opaque failure line.
218
+ Messages follow the CLI locale (`--lang en|zh`). Common examples:
219
+
220
+ ```text
221
+ Diagnostic
222
+ Summary: No usable local session data found.
223
+ Searched roots:
224
+ - Codex: CODEX_HOME/sessions: /Users/me/.codex/sessions
225
+ - OpenCode: XDG/default opencode.db: /Users/me/.local/share/opencode/opencode.db
226
+ Next steps:
227
+ - Confirm the agent has produced session data on this machine.
228
+ - If you use a custom directory, check that the relevant environment variable points at it.
229
+ ```
230
+
231
+ ```text
232
+ Diagnostic
233
+ Summary: No matching session found.
234
+ Parsed URI: codex://session-123
235
+ - scheme: codex
236
+ - session_id: session-123
237
+ Details:
238
+ - Scanned the currently available providers, but no session id matched.
239
+ Next steps:
240
+ - Run `agent-dump --list` to confirm the session still exists.
241
+ - Check that the session id in the URI is complete and belongs to that provider.
242
+ ```
243
+
244
+ ```text
245
+ Diagnostic
246
+ Summary: The current request uses an export capability Cursor does not support.
247
+ Capability gap: Cursor supports only json, print; requested raw
248
+ Next steps:
249
+ - Remove `raw` and use a supported format.
250
+ - For further processing, export JSON first and convert afterwards.
251
+ ```
252
+
253
+ ### Exit Codes
254
+
255
+ Explicit provider scopes (`provider:`, legacy provider prefixes, or `providers=` in query URIs) are applied before discovery. Unselected providers are not scanned. An empty explicit scope result keeps the mode’s no-match behavior, without probing unrelated providers.
256
+
257
+ | Code | Meaning |
258
+ |------|---------|
259
+ | `0` | The command did what was asked — including when the result set is legitimately empty (no sessions in the `-days` window, a keyword or `--search` that matched nothing), and when interactive export partially succeeds. |
260
+ | `1` | The command could not do what was asked: no provider data exists on this machine, a URI did not resolve to a session, every requested interactive export failed, or an argument combination is invalid. |
261
+ | `2` | Argument usage error, raised by `argparse` (unknown flag, invalid `--format` value). |
262
+
263
+ This makes `agent-dump --list && ...` meaningful: it succeeds when sessions were
264
+ listed and fails when there is nothing to list because no provider has data.
265
+
266
+ ## Command-line Arguments
267
+
268
+ ```bash
269
+ # Display help
270
+ agent-dump # Show help message
271
+ agent-dump --help # Show detailed help
272
+
273
+ # List mode (prints all matches, no pagination)
274
+ agent-dump --list # List sessions from last 7 days
275
+ agent-dump --list -days 3 # List sessions from last 3 days
276
+ agent-dump --list -query error # List sessions matching keyword "error"
277
+ agent-dump --list -query codex,kimi:error # Query only within Codex/Kimi
278
+ agent-dump --list -query 'bug provider:codex path:.' # Structured query: keyword + provider + path
279
+ agent-dump --list -query 'bug path:"/Users/me/My Project"' # Quote structured values containing spaces
280
+ agent-dump --interactive -query 'role:user limit:20 refactor' # Structured query with role and global limit
281
+ agent-dump 'agents://.?q=refactor&providers=codex,claude' # Query recent sessions for current repo
282
+ agent-dump 'agents://.?q=refactor&providers=codex,claude&roles=user&limit=20' # Structured query URI
283
+ agent-dump --list 'agents:///Users/me/work/repo?providers=codex,opencode' # Query by absolute path
284
+ agent-dump --interactive 'agents://~/work/repo?q=bug' # Path-scoped interactive selection
285
+ agent-dump --list -page-size 10 # Accepted for compatibility but currently ignored
286
+
287
+ # Interactive export mode
288
+ agent-dump --interactive # Interactive mode (default 7 days)
289
+ agent-dump --interactive -days 3 # Interactive mode (3 days)
290
+ agent-dump -days 3 # Auto-activates list mode
291
+ agent-dump -query error # Auto-activates list mode
292
+
293
+ # Note: in interactive mode with --query, only agents with keyword matches are shown,
294
+ # and the count shown for each agent is the post-filter matched count.
295
+ #
296
+ # Query ambiguity rules:
297
+ # - `error:timeout` remains a plain keyword query.
298
+ # - `codex,kimi:error` remains the legacy agent-scoped query syntax.
299
+ # - Structured mode is activated only when a known key appears: provider / role / path / cwd / limit.
300
+ # - Quote or escape structured values containing spaces, for example `path:"/Users/me/My Project"`.
301
+ # - `role:...` constrains keyword matching to messages of those roles.
302
+ # - `limit:...` truncates the final global matched result set.
303
+
304
+ # URI mode - Direct text dump
305
+ agent-dump opencode://<session-id> # View OpenCode session content
306
+ agent-dump zcode://<session-id> # View ZCode session content
307
+ agent-dump codex://<session-id> # View Codex session content
308
+ agent-dump kimi://<session-id> # View Kimi session content
309
+ agent-dump claude://<session-id> # View Claude Code session content
310
+ agent-dump cursor://<request-id> # View Cursor session content
311
+ agent-dump pi://<session-id> # View Pi session content
312
+ agent-dump deepchat://<session-id> # View DeepChat session content
313
+ agent-dump minimax://<session-id> # View MiniMax Code session content
314
+ agent-dump codex://<session-id> --head # View lightweight session metadata before exporting
315
+ agent-dump codex://<session-id> --format json --output ./my-sessions # Export JSON file
316
+ agent-dump codex://<session-id> --format markdown --output ./my-sessions # Export Markdown file
317
+ agent-dump codex://<session-id> --format print,json --output ./my-sessions # Print and export JSON
318
+ agent-dump codex://<session-id> --format json,markdown,raw --output ./my-sessions # Export multiple formats
319
+ agent-dump cursor://<request-id> --format json --output ./my-sessions # Cursor supports JSON export
320
+ agent-dump cursor://<request-id> --format print,json --output ./my-sessions # Cursor print + JSON
321
+ agent-dump codex://<session-id> --format json --summary --output ./my-sessions # Export JSON with AI summary
322
+ agent-dump codex://<session-id> --format print,json --summary --output ./my-sessions # Print, export JSON, and include summary
323
+
324
+ # Search mode (full-text)
325
+ agent-dump --search "auth timeout" # Search sessions matching keyword
326
+ agent-dump --search "认证" # CJK keyword search works
327
+ agent-dump --search "auth" --list -days 30 # Combine with list + days
328
+ agent-dump --reindex # Force rebuild search index
329
+
330
+ # Note: search results include provider, updated time, URI, rank, and highlighted snippets.
331
+
332
+ # Statistics mode
333
+ agent-dump --stats # Show session stats for last 7 days
334
+ agent-dump --stats -days 30 # Show session stats for last 30 days
335
+
336
+ # Provider capabilities (read-only; --capabilities is an alias)
337
+ agent-dump --providers
338
+
339
+ # collect mode (time-range summary with AI)
340
+ agent-dump --collect
341
+ agent-dump --collect -days 7
342
+ agent-dump --collect -since 2026-03-01 -until 2026-03-05
343
+ agent-dump --collect -since 20260301 -until 20260305
344
+ agent-dump --collect --collect-mode insight
345
+ agent-dump --collect --save ./reports
346
+ agent-dump --collect --save ./reports/weekly.md
347
+ agent-dump --collect --save /tmp/agent-dump-reports
348
+ agent-dump --collect --save /tmp/agent-dump-reports/weekly.md
349
+ agent-dump --collect 'agents://.?q=refactor&providers=codex,claude'
350
+ agent-dump --collect --dry-run -since 20260301 -until 20260305 --save ./reports
351
+ agent-dump --shortcut ob 20260408
352
+
353
+ # Note: --collect keeps only visible user/assistant text, excluding system/developer/tool messages,
354
+ # reasoning, plans, tool calls, and tool results. Sessions empty after this projection are ignored.
355
+ # PM chunks summarize requests, decisions, and agent-reported outcomes, then merge per session
356
+ # and reduce within each date/project group (or each session in insight mode).
357
+ # Final Markdown input retains these sources; inputs over 64,000 characters require a narrower range/query.
358
+ # Note: collect date precedence is explicit -since/-until, then explicit -days, then today only.
359
+ # Note: --collect --dry-run completes scanning, query filtering, and chunk planning, then
360
+ # prints provider breakdown, session/chunk counts, concurrency, dates, and save path preview.
361
+ # Note: during --collect, stderr shows multi-stage progress such as scan_sessions,
362
+ # plan_chunks, summarize_chunks, merge_sessions, tree_reduction, render_final, and write_output.
363
+ # Note: unreadable sessions are reported on stderr; readable sessions without visible dialogue are silently ignored.
364
+ # Note: collect writes files like agent-dump-collect-20260301-20260305.md.
365
+ # Note: --save accepts either a directory or a .md file path. Missing non-.md paths are treated as directories.
366
+
367
+ # config mode
368
+ agent-dump --config view
369
+ agent-dump --config edit
370
+
371
+ # Other options
372
+ agent-dump --interactive --format json # Interactive export as JSON (default)
373
+ agent-dump --interactive --format markdown # Interactive export as Markdown
374
+ agent-dump --interactive --format json,markdown,raw # Interactive multi-format export
375
+ agent-dump --interactive -output ./my-sessions # Specify output directory
376
+
377
+ # Compatibility note
378
+ # md remains available as an alias for markdown, e.g. --format md,raw
379
+ # --head is a URI discovery mode. It does not replace --format print and cannot be combined with --format/--summary.
380
+ ```
381
+
382
+ ### Summarize with an external agent
383
+
384
+ Generate a self-contained task prompt instead of configuring an AI endpoint. No skill is required:
385
+
386
+ ```bash
387
+ agent-dump --collect --emit-prompt \
388
+ -since 20260824 -until 20260830 \
389
+ --collect-mode pm --save ./reports/weekly.md
390
+
391
+ # Keep an existing collect shortcut and opt in for this invocation
392
+ agent-dump --shortcut ob 20260831 --emit-prompt
393
+ ```
394
+
395
+ These commands print the prompt directly. For agent execution, **save stdout and stderr to separate private files
396
+ on the first invocation** so a command tool's output limit cannot discard candidates. A macOS/Linux shortcut example
397
+ (no additional CLI option is needed):
398
+
399
+ ```bash
400
+ (
401
+ umask 077
402
+ collect_task_dir=$(mktemp -d) || exit 1
403
+ agent-dump --shortcut ob 20260831 --emit-prompt \
404
+ > "$collect_task_dir/prompt.md" 2> "$collect_task_dir/diagnostics.txt"
405
+ collect_exit_code=$?
406
+ printf 'Exit: %s\nPrompt: %s\nDiagnostics: %s\n' \
407
+ "$collect_exit_code" "$collect_task_dir/prompt.md" "$collect_task_dir/diagnostics.txt"
408
+ exit "$collect_exit_code"
409
+ )
410
+ ```
411
+
412
+ Give the agent both file paths. It should read the instructions, validate the full manifest programmatically, and
413
+ process it in batches, without printing the entire file back into tool output. On other platforms, likewise use a
414
+ private temporary directory, capture both streams separately, and check the exit code.
415
+
416
+ Give the prompt to an agent that can run commands and read/write files in the same local environment.
417
+ It includes a fixed candidate manifest, per-session read commands, the working directory and timezone,
418
+ the existing `pm`/`insight` report requirements, and the absolute final report path.
419
+ Commands use the running native executable; they do not require another global install.
420
+ Keep the same provider-path environment variables. If the original runtime is no longer available,
421
+ confirm a replacement entry point before proceeding.
422
+
423
+ - stdout contains the prompt; diagnostics go to stderr. `--save` still names the **final report**, not the prompt file.
424
+ - Generation does not validate AI settings, call a model, plan summary chunks, write collect logs, or create the report.
425
+ Content queries may still read transcripts and update the local search index while selecting candidates.
426
+ - All collect exclusions and query filters still apply. Dates include both endpoints and select sessions by their local
427
+ **creation date**, not individual message timestamps. The manifest is not a content snapshot.
428
+ - Before reading transcripts, validate the manifest end marker, candidate count, unique URIs, JSON lengths, and command
429
+ identities. Parseable JSON alone does not prove completeness. Recover a damaged manifest from the full saved file first;
430
+ otherwise regenerate the prompt at most once with the original selection conditions and capture output directly.
431
+ Regeneration creates a new candidate manifest, not the old snapshot. If the conditions are unknown or recovery fails,
432
+ ask the user before delivering a partial report from a damaged manifest.
433
+ - Save each session's stdout/stderr separately and read the transcript in bounded chunks through EOF; successful export
434
+ does not mean complete reading. Analyze only visible user/assistant text and do not switch to JSON to inspect tool results.
435
+ A complete manifest with individual unreadable sources may produce a report disclosing those gaps.
436
+ - Ignore sessions without substantive visible dialogue. Keep approvals or duplicate transcripts only when they change a
437
+ request, decision, or outcome, and keep the current reporting process out of the work being summarized. Replacing an existing
438
+ report requires explicit user permission; prepare and verify the new content before replacing the old report.
439
+ - `--emit-prompt` requires collect mode and conflicts with `--dry-run`. No matching candidates produces no prompt
440
+ and exits `0`; no available provider or a preparation error exits `1`.
441
+ - To make this permanent for a shortcut, add `"--emit-prompt"` to its `args`; shortcut expansion needs no special handling.
442
+
443
+ Like the built-in collect prompts, the generated model instructions and report headings are Chinese;
444
+ `--lang` controls CLI help and diagnostics. Treat the prompt's titles and paths as private data.
445
+ External processing is subject to the chosen agent's data-transfer policy, not necessarily offline.
446
+ Generating a prompt does not mean that a report has been created, and does not automatically launch an external agent.
447
+
448
+ ### Full Parameter Reference
449
+
450
+ | Parameter | Description | Default |
451
+ |-----------|-------------|---------|
452
+ | `uri` | Agent session URI to dump (e.g., `opencode://session-id`), or a scoped query URI such as `agents://.?q=refactor&providers=codex,claude&roles=user&limit=20` | - |
453
+ | `--interactive` | Run in interactive mode to select and export sessions | - |
454
+ | `-d`, `-days`, `--days` | Query sessions from the last positive N days. Values outside the supported calendar range are rejected. In collect mode, applies when `-since/-until` are omitted. | 7 outside collect; today only in collect |
455
+ | `-q`, `-query` | Query filter. The keyword is one case-insensitive literal phrase after whitespace normalization, matched within a session title or logical transcript. Supports legacy `keyword` or `agent1,agent2:keyword` (e.g. `codex,kimi:error`), and structured terms like `bug provider:codex role:user path:. limit:20`. `cwd:` is an alias of `path:`. Structured values containing spaces support shell-style quoting and escaping. `limit` must be a positive signed 64-bit integer. Unknown structured keys are rejected. Cannot be combined with `agents://...` query URIs. | - |
456
+ | `--head` | URI mode only. Print bounded discovery metadata without rereading the transcript; message count is exact when discovery scanned the complete source and explicitly `unknown` otherwise. Does not export files or print body content. Cannot be combined with `--format` or `--summary`. | - |
457
+ | `--collect` | Collect sessions by date range, optionally constrained by `-query` or an `agents://...` query URI (mutually exclusive). Only visible user/assistant text is summarized; system/developer/tool messages, reasoning, plans, tool calls, and tool results are excluded, and empty projected sessions are ignored. PM mode extracts requests, decisions, and agent-reported outcomes before deterministic session merge and tree reduction. Multi-stage progress is shown on stderr. | - |
458
+ | `--collect-mode` | collect output mode: `pm` for project-management summaries, `insight` for author insight summaries. | `pm` |
459
+ | `--dry-run` | Use with `--collect` to preview provider breakdown, session/chunk counts, concurrency, date range, and save path while skipping AI calls and file writes. | - |
460
+ | `--emit-prompt` | Use with `--collect` to print a self-contained task for an external agent, without AI configuration or report writes. Incompatible with `--dry-run`; `--save` specifies the eventual report path. | - |
461
+ | `--stats` | Show session usage statistics for the last N days, grouped by agent and time. If any message count is unknown, reports the known subtotal and number of unknown Sessions instead of presenting a partial sum as a total. Supports `-days` and `-query`; use it as a standalone mode. | - |
462
+ | `--providers`, `--capabilities` | Show the registered provider capability matrix, including URI schemes, supported and unsupported export formats, and whether local search roots exist. Does not scan sessions. | - |
463
+ | `--search` | Full-text search across provider-normalized session titles, messages, reasoning, and tool state using local SQLite FTS5; raw provider metadata is not searched. Whitespace-delimited terms are matched literally (FTS5 operator syntax such as `AND`/`NEAR`/`*` is not interpreted), all distinct terms are required, and terms may occur in different corpus fields. CJK terms require literal adjacency. FTS5-unavailable and unsupported-tokenizer cases use the same in-process logical-text matcher; unreadable sessions and index errors are reported on stderr. Cached session text not seen for 30 days is removed automatically. Can be combined with `--list`. | - |
464
+ | `--reindex` | Force rebuild of the full-text search index. Use when index is corrupted or after manual session data changes. | - |
465
+ | `--lang` | Force the CLI message locale (`en` or `zh`). Overrides locale detection from `LANG`/`LC_ALL`. | auto-detected |
466
+ | `--no-metadata-summary` | Hide the per-session metadata summary line in list and interactive views. | off |
467
+ | `-v`, `--version` | Print the version and exit. | - |
468
+ | `--shortcut` | Run a configured shortcut preset. Example: `agent-dump --shortcut ob 20260408` | - |
469
+ | `-since`, `--since` | collect start date, supports `YYYY-MM-DD` or `YYYYMMDD` | - |
470
+ | `-until`, `--until` | collect end date, supports `YYYY-MM-DD` or `YYYYMMDD` | - |
471
+ | `--save` | collect report path. Supports absolute/relative directory or `.md` file path. If no filename is provided, the default collect filename is used. With `--emit-prompt`, the path is included as an instruction for the external agent; no report is written. | - |
472
+ | `-config`, `--config` | Config management: `view` or `edit` | - |
473
+ | `--list` | Only list sessions without exporting and print all matched sessions (auto-activated if `-days` or `-query` is specified without `--interactive`) | - |
474
+ | `-format`, `--format` | Output format. Supports comma-separated values: `json \\| markdown \\| raw \\| print`, with `md` kept as an alias. Default: URI mode `print`, non-URI mode `json`. URI mode can mix `print,json`; `--interactive` does not support `print`; `--list` ignores this option with warning; `--head` cannot be combined with this option. Cursor supports only `json` and `print` (no `raw/markdown`). | - |
475
+ | `-summary`, `--summary` | URI mode only. When enabled, summary is generated only if `--format` includes `json` and AI config is complete; otherwise a warning is shown and export continues without summary. During AI requests, a loading hint is shown on stderr. Cannot be combined with `--head`. | - |
476
+ | `-p`, `-page-size`, `--page-size` | Accepted for compatibility; currently ignored | 20 |
477
+ | `-output`, `--output` | Output directory. For `json/raw`, priority is `--output` > `config.toml` `[export].output` > `./sessions`. Relative paths are resolved from the current working directory. Markdown keeps using `./sessions` unless `--output` is explicitly passed. Ignored in `--list` with warning. | `config export.output` or `./sessions` |
478
+ | `-h, --help` | Show help message | - |
479
+
480
+ When URI mode combines `print` with file formats, a print read/render failure is reported without blocking file exports. Raw source copying can still succeed when normalized parsing fails. Exit status remains `0` if any requested output succeeds, otherwise `1`.
481
+
482
+ ### Python API migration
483
+
484
+ Rust releases distribute a CLI only. Call `agent-dump` as a subprocess and use JSON exports for structured data. The frozen Python implementation is retained in Git history and installed separately for differential verification. Existing API consumers should migrate to the CLI or pin `agent-dump==0.15.9`.
485
+
486
+ ### collect configuration file
487
+
488
+ Discovery failures are counted separately because the number of missing sessions is unknown. Reads that fail during query filtering also count as session read failures. These gaps are included in saved reports and completion logs; `--emit-prompt` carries them in its task metadata and fails if failures leave no candidates.
489
+
490
+ File discovery failures include partially unreadable providers. Valid sessions remain usable, but collect reports and handoff metadata mark discovery as incomplete; `--emit-prompt` exits with failure if no candidates remain after discovery failures.
491
+
492
+ When some session reads or summaries fail, collection continues with successful sessions. The saved Markdown includes a fixed incomplete-report notice with failure and included-session counts; an entirely failed run still fails.
493
+
494
+ Collect preserves visible message text within a 12,000-character per-session extraction budget (including event labels). Text beyond that budget is omitted and marked as truncated for the final summary.
495
+
496
+ PM summaries merge sessions only within the same date and known working directory. Sessions without a working directory retain separate attribution.
497
+
498
+ Default config path:
499
+
500
+ - macOS/Linux: `~/.config/agent-dump/config.toml`
501
+ - Windows: `%APPDATA%/agent-dump/config.toml`
502
+
503
+ Example:
504
+
505
+ ```toml
506
+ [ai]
507
+ provider = "openai" # openai | anthropic
508
+ base_url = "https://api.openai.com/v1"
509
+ model = "gpt-4.1-mini"
510
+ api_key = "sk-..."
511
+
512
+ [collect]
513
+ summary_concurrency = 4 # 1-32
514
+
515
+ [export]
516
+ output = "../exports"
517
+
518
+ [shortcut.ob]
519
+ params = ["date"]
520
+ args = [
521
+ "--collect",
522
+ "--save", "~/Dropbox/OBSIDIAN/XingKaiXin/00_Inbox/{year}/{year_month}/agent-dump-collect-{date}.md",
523
+ "--since", "{date}",
524
+ "--until", "{date}",
525
+ ]
526
+
527
+ [agent.claudecode]
528
+ deny = [
529
+ "/Users/Kevin/workspace/projects/work/fin-agent/agent",
530
+ ]
531
+ ```
532
+
533
+ `[agent.<name>].deny` only applies to `--collect`. When a session `cwd` matches one of the configured paths, or is inside that path, the session is ignored during collect.
534
+
535
+ Collect, `--collect --dry-run`, and `--collect --emit-prompt` require valid TOML and exclusion arrays containing only nonempty path strings. Invalid configuration stops the command before session discovery or AI requests; compatibility parsing never disables exclusions for collect.
536
+
537
+ `[export].output` defines the global default output root for `json/raw` exports. It accepts absolute or relative paths. Relative paths are resolved from the directory where `agent-dump` is executed, not from the config file location.
538
+
539
+ `[shortcut.<name>]` defines a reusable shortcut preset. `params` declares positional input names. `args` declares the expanded CLI argv template. When `date` is provided, `{year}` / `{month}` / `{year_month}` are derived automatically.
540
+
541
+ When `agent-dump` writes `config.toml`, it preserves comments, whitespace, and field order, escapes TOML-sensitive characters, and restricts the file to owner-only permissions (`0600`) because it may contain an API key.
542
+ Legacy invalid TOML can still be read for compatibility, but `--config edit` refuses to rewrite it because a safe round trip cannot preserve unknown values. Fix the invalid escaping manually or replace the file before editing.
543
+
544
+ ## Project Structure
545
+
546
+ ```text
547
+ Cargo.toml # Workspace, shared dependencies/lints and CLI release version
548
+ rustfmt.toml # Stable Rustfmt, edition 2024, 80 columns
549
+ src/ # CLI workflows, Collect and terminal interaction
550
+ crates/agent-dump-core/ # Providers, sessions, queries and export engine
551
+ resources/ # Embedded locales and prompts
552
+ tests/cli/ # CLI contracts and external Python reference comparison
553
+ tests/tooling/ # Packaging, benchmark and documentation checks
554
+ scripts/ # Validated CLI benchmarks and paired release eval
555
+ packaging/ # Maturin builds and installation verification
556
+ npm/ # Node launcher and platform packages
557
+ docs/ # Architecture, migration and acceptance evidence
558
+ web/ # Landing page
559
+ ```
560
+
561
+ ## Development
562
+
563
+ Rust is the build and runtime implementation starting with v1.0.0, with Ratatui for terminal interaction. The old Python application has been removed from the working tree. Differential tests install the immutable 0.15.9 wheel in an isolated reference environment. See [P2](docs/rust-p2-completion.md), [P3–P5](docs/rust-p3-p5-completion.md), [P6 acceptance](docs/rust-p6-completion.md), and the [final performance report](docs/benchmarks/rust-p6.md).
564
+
565
+ ```bash
566
+ # Run Cargo directly from the repository root
567
+ cargo build --locked --release
568
+ cargo test --locked --workspace
569
+
570
+ # Run full CI checks, including the isolated historical Python reference
571
+ # (includes npm tests when Node.js is available, and the landing page check when pnpm is)
572
+ just isok
573
+
574
+ # Check Rustfmt, strict Clippy and Ruff
575
+ just lint
576
+
577
+ # Auto-fix linting issues
578
+ just lint-fix
579
+
580
+ # Format code
581
+ just fmt
582
+
583
+ # Type checking
584
+ just check
585
+
586
+ # Testing
587
+ just test
588
+
589
+ # Build a standalone binary for the current platform
590
+ just build-native
591
+
592
+ # Sync npm package metadata
593
+ just build-npm
594
+
595
+ # Run npm wrapper tests and smoke checks
596
+ just test-npm-smoke
597
+ ```
598
+
599
+ Both crates inherit workspace lints: unsafe code is denied, Clippy all/pedantic are denied, and nursery warnings fail the gate through `-D warnings`. Explicit exceptions and their reasons are documented in the [development guide](docs/development-guide.md#rust-格式与-lint). Existing CLI differential and tooling tests remain in `tests/`.
600
+
601
+ ## Release
602
+
603
+ ```bash
604
+ # 1. Update the package version in a single place
605
+ $EDITOR Cargo.toml
606
+
607
+ # 2. Commit and merge to main
608
+
609
+ # 3. Create and push a release tag
610
+ git tag v{version}
611
+ git push origin v{version}
612
+ ```
613
+
614
+ - The tag release workflow is [`release.yml`](./.github/workflows/release.yml)
615
+ - Only tags matching `vX.Y.Z` trigger the unified release pipeline
616
+ - Release publishes PyPI artifacts, GitHub release assets, and npm packages for `@agent-dump/cli`
617
+ - Retrying the same release skips byte-identical registry artifacts and fails if an existing version or asset differs
618
+ - npm publishing waits until each package is downloadable with the expected integrity before proceeding to the next package; native packages precede the CLI wrapper
619
+ - The npm CLI package installs the matching native binary during `npm`/`npx` installation and verifies its checksum
620
+ - PyPI publishing uses `UV_PUBLISH_TOKEN`, stored as an environment secret in the GitHub `release` environment
621
+ - npm publishing uses Trusted Publisher/OIDC for every `@agent-dump/*` package, bound to this repository,
622
+ `release.yml`, and the GitHub `release` environment; it does not use an `NPM_TOKEN` secret
623
+
624
+ ## License
625
+
626
+ MIT
627
+
@@ -0,0 +1,6 @@
1
+ agent_dump-1.0.0.data/scripts/agent-dump.exe,sha256=T0Fiv5WNQhHrVxMK7rtsQMzY9c4OJM7JKVT06HXCP9w,11006464
2
+ agent_dump-1.0.0.dist-info/METADATA,sha256=v7wWTJ4rXzkSpn055SRytyDnV-4s0Qwf9kdNwg2T3mc,40480
3
+ agent_dump-1.0.0.dist-info/WHEEL,sha256=8Aej0W0a6Cz6apA3IzJrTnxLRVLAt-w0Oh8SA3Con_c,94
4
+ agent_dump-1.0.0.dist-info/licenses/LICENSE,sha256=uqc7WhGCax7gUFF_tgg5YCYWdrqHhMm1IDYTk6aOnw0,1102
5
+ agent_dump-1.0.0.dist-info/sboms/agent-dump.cyclonedx.json,sha256=pzfloBlqYddVU7bsFk3n0VVyYdBOPNERBL8uBs8hOgE,274752
6
+ agent_dump-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.15.0)
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-win_amd64