sessiongraph 1.0.14 → 1.0.16
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/PRIVACY.md +15 -61
- package/README.md +35 -55
- package/bin/sessiongraph.mjs +14 -8
- package/dist/assets/index-C0jATzD9.css +1 -0
- package/dist/assets/{index-D4P4hbvc.js → index-CFlNwG9H.js} +1 -1
- package/dist/assets/index-D24Hz9MJ.js +180 -0
- package/dist/assets/{index-Kotmn42s.js → index-D7udGrT1.js} +1 -1
- package/dist/assets/{index-BLM-0yG6.js → index-U9QGDl1t.js} +1 -1
- package/dist/assets/katagami-sans-DMv8PCo8.woff2 +0 -0
- package/dist/assets/licenses/hugeicons.txt +21 -0
- package/dist/assets/licenses/katagami.txt +93 -0
- package/dist/assets/public-viewer-CyDoUT6s.css +1 -0
- package/dist/assets/public-viewer-iQBchlbq.js +24 -0
- package/dist/assets/scene-DmT4K5Nj.js +248 -0
- package/dist/assets/share-DrezE0sG.js +7 -0
- package/dist/assets/{three-D_1Qt16u.js → three-DDiuFd7k.js} +21 -21
- package/dist/assets/{worker-C10U_apJ.js → worker-B9mWJfQ6.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/cli.mjs +50326 -17640
- package/dist-server/install-cli.mjs +204 -0
- package/dist-server/server.mjs +1089 -379
- package/docs/cli.md +293 -190
- package/docs/guide.md +16 -9
- package/docs/import-coverage.md +73 -5
- package/docs/performance.md +164 -0
- package/docs/releases.md +6 -0
- package/package.json +18 -10
- package/dist/assets/external-links-BmBkCsrt.js +0 -1
- package/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/assets/index-B1kyvo41.js +0 -175
- package/dist/assets/index-Du0_nVjH.css +0 -1
- package/dist/assets/publishing-CEvQPkO1.css +0 -1
- package/dist/assets/publishing-D9CqkbeB.js +0 -23
- package/dist/assets/scene-CTHyYtma.js +0 -139
- package/dist/assets/share-Cw1E-ED9.js +0 -7
- package/docs/importer-comparison.md +0 -48
- package/docs/session-artifacts-audit.md +0 -176
package/docs/cli.md
CHANGED
|
@@ -1,61 +1,173 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CLI reference
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Use `sessiongraph` or `ssg` to read your local session library.
|
|
4
|
+
Use `sync` to import updates.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
With Node.js 24+:
|
|
5
9
|
|
|
6
10
|
```sh
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
node bin/sessiongraph.mjs commands --json
|
|
11
|
+
npm install --global sessiongraph
|
|
12
|
+
ssg --help
|
|
10
13
|
```
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
Global npm installs register both commands in npm's global executable directory.
|
|
16
|
+
With a custom npm prefix, include that directory in PATH (`<prefix>/bin` on
|
|
17
|
+
macOS/Linux, `<prefix>` on Windows).
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
Desktop releases install both commands on first launch using their bundled
|
|
20
|
+
runtime. Restart your terminal after opening the app.
|
|
21
|
+
|
|
22
|
+
| Platform | CLI directory |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| macOS | `~/Library/Application Support/SessionGraph/cli/bin` |
|
|
25
|
+
| Windows | `%LOCALAPPDATA%\SessionGraph\cli\bin` |
|
|
26
|
+
| Linux | `$XDG_DATA_HOME/sessiongraph/cli/bin`, defaulting to `~/.local/share/sessiongraph/cli/bin` |
|
|
27
|
+
|
|
28
|
+
Desktop setup adds this directory to the current user's PATH: zsh, bash, and sh
|
|
29
|
+
profiles; fish's `conf.d`; or Windows' user environment. Existing PATH entries and
|
|
30
|
+
profile content are preserved. Other shells need the directory added manually.
|
|
31
|
+
Versioned CLI files stay outside the app bundle so AppImage commands work after
|
|
32
|
+
the app closes. Development builds leave PATH unchanged.
|
|
33
|
+
To remove the desktop CLI, delete its `cli` directory and its marked shell PATH
|
|
34
|
+
block or Windows user PATH entry.
|
|
35
|
+
|
|
36
|
+
## Start
|
|
17
37
|
|
|
18
38
|
```sh
|
|
19
|
-
sessiongraph
|
|
20
|
-
sessiongraph
|
|
21
|
-
sessiongraph
|
|
22
|
-
sessiongraph docs # Full generated Markdown reference
|
|
23
|
-
sessiongraph docs sources setup # Reference for one command
|
|
24
|
-
sessiongraph --version
|
|
39
|
+
sessiongraph sources setup --detected
|
|
40
|
+
sessiongraph sync
|
|
41
|
+
sessiongraph sessions --directory .
|
|
25
42
|
```
|
|
26
43
|
|
|
27
|
-
`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
Use `npx sessiongraph <command>` for a one-off run. In a source checkout,
|
|
45
|
+
run `pnpm build`, then `node bin/sessiongraph.mjs <command>`.
|
|
46
|
+
Running `sessiongraph` alone opens the desktop app; `--browser` opens the web app.
|
|
47
|
+
|
|
48
|
+
## Commands
|
|
49
|
+
|
|
50
|
+
### Query from an agent
|
|
31
51
|
|
|
32
|
-
|
|
52
|
+
`ssg mcp` serves saved sessions over stdio. In OpenCode, register it once:
|
|
33
53
|
|
|
34
54
|
```sh
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
opencode mcp add sessiongraph --global -- ssg mcp
|
|
56
|
+
opencode mcp list
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
For clients with an `mcpServers` configuration:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{ "mcpServers": { "sessiongraph": { "command": "ssg", "args": ["mcp"] } } }
|
|
37
63
|
```
|
|
38
64
|
|
|
39
|
-
`
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
history. See the [coverage matrix](import-coverage.md#imported-data-by-harness).
|
|
65
|
+
Use the full `ssg` executable path if a GUI client cannot find it. The client
|
|
66
|
+
launches the process as your OS user and owns the connection. Start with
|
|
67
|
+
`search_sessions` or `list_sessions`, then pass a returned `id` to `list_messages`,
|
|
68
|
+
`list_events`, `list_commits`, `list_files`, `get_timeline`, `list_relationships`,
|
|
69
|
+
or `get_session`. `get_stats` returns aggregate usage.
|
|
70
|
+
|
|
71
|
+
### Local REST API
|
|
47
72
|
|
|
48
|
-
|
|
73
|
+
Set `SESSIONGRAPH_SERVER_PASSWORD` in the server and client environments. The
|
|
74
|
+
default username is `sessiongraph`; override it with `SESSIONGRAPH_SERVER_USERNAME`.
|
|
75
|
+
Start the API in the foreground:
|
|
49
76
|
|
|
50
77
|
```sh
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
sessiongraph sources sync
|
|
54
|
-
sessiongraph sources sync codex # Only this enabled source; keeps the full selection
|
|
55
|
-
sessiongraph sync # Alias for sources sync
|
|
56
|
-
sessiongraph import # Alias for sources sync
|
|
78
|
+
ssg serve # http://127.0.0.1:4783
|
|
79
|
+
```
|
|
57
80
|
|
|
58
|
-
|
|
81
|
+
From another terminal with the same credentials:
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
ssg api /api/info
|
|
85
|
+
ssg api '/v1/sessions?source=codex&limit=10'
|
|
86
|
+
ssg api '/v1/search?query=invoice'
|
|
87
|
+
ssg api /openapi.json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
All HTTP endpoints require Basic authentication, including discovery. Use
|
|
91
|
+
`curl --user sessiongraph http://127.0.0.1:4783/v1/sessions` to enter the
|
|
92
|
+
password interactively. `--port` selects another port; `ssg serve --port 0 --json`
|
|
93
|
+
prints the OS-assigned URL. Ctrl+C stops the server.
|
|
94
|
+
|
|
95
|
+
Both transports query the same local library. Pass `--data-dir` to `serve` or
|
|
96
|
+
`mcp` to select another. Use `ssg sync` separately to refresh saved history.
|
|
97
|
+
Filters and limits are listed by `/openapi.json` and MCP `tools/list`.
|
|
98
|
+
`since` and `until` are inclusive: pass Unix milliseconds, ISO timestamps with a
|
|
99
|
+
timezone, or `YYYY-MM-DD` (whole UTC days). URL-encode session IDs as one path segment.
|
|
100
|
+
Use `nextCursor` with the original filters for the next page; restart on
|
|
101
|
+
`STALE_CURSOR`. Search reuses the index between queries on the same selection.
|
|
102
|
+
|
|
103
|
+
For “How many sessions did I start on May 13?”, call `get_stats` with
|
|
104
|
+
`{"dateField":"created","since":"2026-05-13","until":"2026-05-13"}`.
|
|
105
|
+
`totals.sessions` counts all matching saved sessions, regardless of page size.
|
|
106
|
+
Use `lastActivity` for the latest saved message (creation fallback), `message`
|
|
107
|
+
for any timed saved message in the window, or `overlap` (default) for
|
|
108
|
+
lifetimes intersecting the window, including idle gaps. Usage is lifetime.
|
|
109
|
+
|
|
110
|
+
`list_sessions` returns compact rows with IDs for `get_session`. For a breakdown,
|
|
111
|
+
use `groupBy: "project"` for labeled source-specific IDs, or `"repository"` to
|
|
112
|
+
combine verified local checkouts across tools and worktrees. Unverified
|
|
113
|
+
checkouts share an **unknown** bucket, not a verified repository.
|
|
114
|
+
`relationship` (root/child/fork) and `origin` (human/automated/unknown) can be
|
|
115
|
+
filtered or grouped independently. Root means no recorded parent/fork.
|
|
116
|
+
Origins require explicit evidence; titles, user messages and interactive tools
|
|
117
|
+
do not prove personal initiation. Sync after updating to pick up native provenance.
|
|
118
|
+
|
|
119
|
+
### Reference
|
|
120
|
+
|
|
121
|
+
| Command | Description |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| `sources` | List session sources and their status |
|
|
124
|
+
| `sources setup [source...]` | Configure sources |
|
|
125
|
+
| `sources remove [source...]` | Disable sources; keep saved history |
|
|
126
|
+
| `sync [source...]` | Refresh sessions from configured sources |
|
|
127
|
+
| `sessions` | List sessions, newest activity first |
|
|
128
|
+
| `search <query>` | Search titles, messages, files, and tools |
|
|
129
|
+
| `show <session-id>` | Show session details |
|
|
130
|
+
| `messages <session-id>` | Show messages, newest first |
|
|
131
|
+
| `timeline <session-id>` | Show user-message times and coverage |
|
|
132
|
+
| `events <session-id>` | Inspect messages, tool calls, results, and events |
|
|
133
|
+
| `files <session-id>` | Show verified file changes and tool counts |
|
|
134
|
+
| `commits <session-id>` | Show recorded Git commit actions and evidence |
|
|
135
|
+
| `relationships <session-id>` | Show recorded parents, children, forks, and provider links |
|
|
136
|
+
| `stats` | Summarize session counts and lifetime usage |
|
|
137
|
+
| `graph` | Export a session graph |
|
|
138
|
+
| `doctor` | Check library health and source availability |
|
|
139
|
+
|
|
140
|
+
Use full session IDs from `sessions` or `search`, such as `codex:SESSION_ID`.
|
|
141
|
+
Add `--json` for structured output.
|
|
142
|
+
|
|
143
|
+
```sh
|
|
144
|
+
sessiongraph sessions --directory . --since 7d
|
|
145
|
+
sessiongraph search '"OAuth callback" in:messages' --source codex
|
|
146
|
+
sessiongraph search 'in:files invoice' --directory .
|
|
147
|
+
sessiongraph show codex:SESSION_ID
|
|
148
|
+
sessiongraph messages codex:SESSION_ID --limit 20
|
|
149
|
+
sessiongraph events codex:SESSION_ID --filter tools
|
|
150
|
+
sessiongraph events codex:SESSION_ID --item EVENT_ID --revision REVISION
|
|
151
|
+
sessiongraph stats --since 7d --group-by source
|
|
152
|
+
sessiongraph graph --directory . --json
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
For help and command schemas:
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
sessiongraph sources setup --help
|
|
159
|
+
sessiongraph commands --json # Command and result schemas
|
|
160
|
+
sessiongraph help search --json # Schema for one command
|
|
161
|
+
sessiongraph docs # Generated Markdown reference
|
|
162
|
+
sessiongraph docs sources setup # Reference for one command
|
|
163
|
+
sessiongraph --version
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Sources
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
sessiongraph sources setup claude-code codex
|
|
170
|
+
sessiongraph sync codex
|
|
59
171
|
sessiongraph sources setup codex --path /archives/codex-home
|
|
60
172
|
sessiongraph sources setup codex --default-path
|
|
61
173
|
sessiongraph sources setup --auto-import off
|
|
@@ -63,169 +175,160 @@ sessiongraph sources remove codex
|
|
|
63
175
|
sessiongraph sources remove --all
|
|
64
176
|
```
|
|
65
177
|
|
|
66
|
-
- `sources`
|
|
67
|
-
|
|
68
|
-
- `
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
##
|
|
98
|
-
|
|
99
|
-
|
|
178
|
+
- `sources setup` enables sources. Run `sync` to import them.
|
|
179
|
+
`--detected` enables all detected sources, including metadata-only sources.
|
|
180
|
+
- `sync`, `sources sync`, and `import` are aliases. Sync waits for completion and
|
|
181
|
+
reports discovered, imported, unchanged, and failed counts. A discovery error
|
|
182
|
+
counts as one failure per affected source; coverage warnings do not affect
|
|
183
|
+
`doctor` or the exit status. `--json` reports these separately in `errors` and
|
|
184
|
+
`warnings`. Source IDs select an enabled subset without changing the selection.
|
|
185
|
+
- `sources remove` disables imports and clears custom paths. Saved sessions,
|
|
186
|
+
messages, and search history remain available. Re-enable a source to import again.
|
|
187
|
+
- `--auto-import` controls automatic refresh while the app is running.
|
|
188
|
+
- Source changes and imports share the app's import lock. Retry `IMPORT_BUSY` after
|
|
189
|
+
the other import finishes. Failed imports preserve saved history.
|
|
190
|
+
|
|
191
|
+
### Custom paths
|
|
192
|
+
|
|
193
|
+
`--path` saves an absolute path for one filesystem source, overriding its
|
|
194
|
+
environment/default path. `--default-path` restores automatic detection.
|
|
195
|
+
Paths can be configured before they become available.
|
|
196
|
+
|
|
197
|
+
| Source | Path |
|
|
198
|
+
| --- | --- |
|
|
199
|
+
| Codex | Home containing `sessions/` |
|
|
200
|
+
| Claude Code | Home containing `projects/` |
|
|
201
|
+
| Pi | The `sessions/` directory |
|
|
202
|
+
| Cursor | CLI home; IDE data uses `SESSIONGRAPH_CURSOR_USER_DATA_DIR` |
|
|
203
|
+
| OpenCode | Authenticated local service discovery; open OpenCode before syncing |
|
|
204
|
+
|
|
205
|
+
Other sources describe their paths in `sources --json` under `pathHint`.
|
|
206
|
+
Custom-path sessions use a saved-context handoff when opened from the app.
|
|
207
|
+
See the [source guide](guide.md#source-coverage) for format coverage.
|
|
208
|
+
|
|
209
|
+
## Filters
|
|
210
|
+
|
|
211
|
+
`sessions`, `search`, `stats`, and `graph` accept:
|
|
212
|
+
|
|
213
|
+
| Option | Match |
|
|
100
214
|
| --- | --- |
|
|
101
|
-
|
|
|
102
|
-
|
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
215
|
+
| `--source <id>` | Source ID; repeat for multiple sources |
|
|
216
|
+
| `--directory <path>` | Directory and descendants at path boundaries; relative paths use the current directory |
|
|
217
|
+
| `--project <id>` | Exact project ID |
|
|
218
|
+
| `--model <name>` | Exact model name |
|
|
219
|
+
| `--since <date>` | Sessions overlapping this window start |
|
|
220
|
+
| `--until <date>` | Sessions overlapping this inclusive window end |
|
|
221
|
+
| `--archived include\|exclude\|only` | Archived history; default `include` |
|
|
222
|
+
| `--raw` | Include linked provider sessions separately; may double-count usage |
|
|
223
|
+
|
|
224
|
+
Dates accept durations (`30m`, `24h`, `7d`, `2w`), `today`, `yesterday`,
|
|
225
|
+
`YYYY-MM-DD` (UTC), or ISO timestamps with a timezone. Date-only `--until` values
|
|
226
|
+
include the full UTC day. Session lifetimes end at the latest saved message time,
|
|
227
|
+
falling back to creation time. Relative windows stay fixed across cursor pages.
|
|
228
|
+
|
|
229
|
+
Search supports quoted phrases, `source:`, `project:`, `dir:`, `model:`,
|
|
230
|
+
`is:fork|child|root|archived`, `in:title|messages|files|tools`, and
|
|
231
|
+
`after:YYYY-MM-DD` / `before:YYYY-MM-DD`. Quote the query as one shell argument.
|
|
232
|
+
Search `after:` / `before:` filter creation dates in local time; `--since` /
|
|
233
|
+
`--until` select overlapping lifetimes in UTC.
|
|
234
|
+
|
|
235
|
+
### Usage totals
|
|
236
|
+
|
|
237
|
+
Stats report **lifetime usage for matched sessions**, including activity outside
|
|
238
|
+
the date window. Group by primary source, model, project, or directory.
|
|
239
|
+
Each measure includes `knownTotal`, `knownSessions`, and `unknownSessions`.
|
|
240
|
+
An entirely unknown measure is `null`; known zero stays zero. Empty selections
|
|
241
|
+
return zero totals. Results also report complete, partial, and pending history counts.
|
|
242
|
+
|
|
243
|
+
## Pagination and coverage
|
|
244
|
+
|
|
245
|
+
Use `nextCursor` with the same command, session, query, and filters. Cursors depend
|
|
246
|
+
on the saved snapshot; restart on `STALE_CURSOR`. Session lists sort by latest
|
|
247
|
+
saved message time, falling back to creation time, then ID.
|
|
248
|
+
|
|
249
|
+
| Command | Limits |
|
|
250
|
+
| --- | --- |
|
|
251
|
+
| `sessions`, `search`, `messages`, `commits`, `relationships` | 50 items by default; `--limit` accepts 1–200 |
|
|
252
|
+
| `stats` | Paginated groups; totals cover all matched sessions |
|
|
253
|
+
| `messages` | 64,000 text characters per page; 200 fragments, file entries, and tool entries per message |
|
|
254
|
+
| `search` | 8 content pages and 48,000 characters per session, sharing a 24-million-character budget |
|
|
255
|
+
| `timeline` | 2,000 timed user-message markers, plus untimed and missing-history counts |
|
|
256
|
+
| `events` | 60 summaries per page; payloads have size limits |
|
|
257
|
+
| `files` | Evidence from 120 saved messages per page |
|
|
258
|
+
| `graph` | 5,000 sessions |
|
|
259
|
+
|
|
260
|
+
`partial` and `coverage` describe missing or truncated history. With partial search
|
|
261
|
+
coverage, unmatched text may exist outside the index. Narrow filters for more
|
|
262
|
+
coverage, or inspect `messages` and `events --item`.
|
|
263
|
+
|
|
264
|
+
`files` returns paths and evidence sources. `snapshotSteps: 0` means the page
|
|
265
|
+
contains no snapshot evidence.
|
|
266
|
+
Its numeric cursor is an offset: compare `revision` across pages and restart if it
|
|
267
|
+
changes. Graph exports include local session metadata; review them before sharing.
|
|
268
|
+
The default view folds linked provider sessions into complete T3 threads.
|
|
269
|
+
|
|
270
|
+
## Recorded commits
|
|
115
271
|
|
|
116
272
|
```sh
|
|
117
|
-
sessiongraph
|
|
118
|
-
sessiongraph
|
|
119
|
-
sessiongraph search 'in:files invoice' --directory . --json
|
|
120
|
-
sessiongraph show codex:SESSION_ID --json
|
|
121
|
-
sessiongraph messages codex:SESSION_ID --limit 20 --json
|
|
122
|
-
sessiongraph events codex:SESSION_ID --filter tools --json
|
|
123
|
-
sessiongraph events codex:SESSION_ID --item EVENT_ID --revision REVISION --json
|
|
124
|
-
sessiongraph relationships codex:SESSION_ID --json
|
|
125
|
-
sessiongraph stats --since 7d --group-by source --json
|
|
126
|
-
sessiongraph graph --directory . --json
|
|
127
|
-
sessiongraph doctor --json
|
|
273
|
+
sessiongraph commits opencode:SESSION_ID --limit 50 --json
|
|
274
|
+
sessiongraph events opencode:SESSION_ID --item EVIDENCE_EVENT_ID --json
|
|
128
275
|
```
|
|
129
276
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
Stats report **recorded lifetime usage of those sessions**, not tokens or spend
|
|
146
|
-
within the selected window. Each usage field returns `knownTotal`, `knownSessions`,
|
|
147
|
-
and `unknownSessions`. An entirely unknown measure is `null`; known zero stays zero.
|
|
148
|
-
No matches gives zero sessions and zero totals. Partial/pending history counts are
|
|
149
|
-
included. Grouping uses the primary source, model, project, or directory.
|
|
150
|
-
|
|
151
|
-
The default matches the app's explicit T3/provider-link deduplication. `--raw`
|
|
152
|
-
includes the underlying provider sessions too and can double-count their usage.
|
|
153
|
-
|
|
154
|
-
Search also supports the app query syntax: quoted phrases, `source:`, `project:`,
|
|
155
|
-
`dir:`, `model:`, `is:fork|child|root|archived`, `in:title|messages|files|tools`, and
|
|
156
|
-
`after:YYYY-MM-DD` / `before:YYYY-MM-DD`. The last two are the existing search
|
|
157
|
-
engine's creation-date filters in the machine's local timezone, distinct from the
|
|
158
|
-
CLI's UTC overlap-window flags. Quote the whole query as one shell argument.
|
|
159
|
-
|
|
160
|
-
### Bounds and coverage
|
|
161
|
-
|
|
162
|
-
- List/search/message/relationship pages default to 50 items; `--limit` accepts
|
|
163
|
-
1–200. Stats paginates groups, while its totals cover the full filtered selection.
|
|
164
|
-
- Follow `nextCursor` with the same command and filters. Cursors are opaque and
|
|
165
|
-
tied to the saved snapshot; changes produce `STALE_CURSOR`. Restart the query.
|
|
166
|
-
- Messages contain at most 64,000 text characters per page, and at most 200
|
|
167
|
-
fragments, file entries, and tool entries per message. Truncation is explicit.
|
|
168
|
-
Use smaller pages and `events --item` to inspect structured evidence.
|
|
169
|
-
- Search uses the same sampling policy as the app: at most 8 content pages and
|
|
170
|
-
48,000 characters per session, with a fair share of a 24-million-character budget.
|
|
171
|
-
`coverage.limited` reports incomplete search coverage. A lack of matches in a
|
|
172
|
-
partial index does not establish that the full conversation lacks the text.
|
|
173
|
-
- Timeline returns up to 2,000 timed user-turn markers and reports untimed and
|
|
174
|
-
missing history. No timestamps or ancestry are invented.
|
|
175
|
-
- Events reuse the app's 60-item pages, revision checks, and bounded payloads.
|
|
176
|
-
`--filter` accepts `all`, `messages`, `tools`, `events`, or `untimed`.
|
|
177
|
-
- Files returns evidence from 120 saved messages per page. Its existing numeric
|
|
178
|
-
cursor is an offset, so compare `revision` between pages and restart if changed.
|
|
179
|
-
It returns paths and evidence sources, not complete file contents or diffs.
|
|
180
|
-
- Graph output is limited to 5,000 sessions; narrow the filters for larger libraries.
|
|
181
|
-
It contains local metadata and is not a public, anonymized snapshot.
|
|
182
|
-
|
|
183
|
-
## Automation contract
|
|
184
|
-
|
|
185
|
-
All data commands support `--json`. Stdout is exactly one JSON object:
|
|
277
|
+
`commits` reads the saved SQLite index. Each action includes a SHA (possibly
|
|
278
|
+
abbreviated), execution directory, operation (`created`, `amended`, `cherry-picked`),
|
|
279
|
+
nullable time, and evidence event ID.
|
|
280
|
+
|
|
281
|
+
Check `coverage`: pending, indexed, partial, or unavailable. Zero recorded actions
|
|
282
|
+
can reflect missing evidence. Run `sync` to index older imports. See the
|
|
283
|
+
[coverage matrix](import-coverage.md#imported-data-by-harness).
|
|
284
|
+
|
|
285
|
+
## Agent interface
|
|
286
|
+
|
|
287
|
+
`commands --json` and `help <command> --json` describe arguments, options, defaults,
|
|
288
|
+
aliases, effects, examples, and result shapes. Help, docs, and command discovery
|
|
289
|
+
work independently of the library. Commands are noninteractive.
|
|
290
|
+
|
|
291
|
+
With `--json`, stdout contains one versioned object:
|
|
186
292
|
|
|
187
293
|
```json
|
|
188
294
|
{ "schemaVersion": 1, "command": "sessions", "data": { "items": [], "total": 0, "nextCursor": null } }
|
|
189
295
|
```
|
|
190
296
|
|
|
191
|
-
|
|
297
|
+
Errors use the same envelope:
|
|
192
298
|
|
|
193
299
|
```json
|
|
194
300
|
{ "schemaVersion": 1, "command": "show", "error": { "code": "NOT_FOUND", "message": "Session not imported. Use the full ID from sessiongraph sessions." } }
|
|
195
301
|
```
|
|
196
302
|
|
|
197
|
-
Exit
|
|
198
|
-
|
|
199
|
-
`
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
`
|
|
217
|
-
`
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
`
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
isolated native-format imports, source configuration and lock contention, pagination,
|
|
230
|
-
unknown usage, retained history, control-character output, and a bundled launcher
|
|
231
|
-
running without `node_modules` or desktop packages.
|
|
303
|
+
| Exit status | Meaning |
|
|
304
|
+
| --- | --- |
|
|
305
|
+
| `0` | Success, including empty results |
|
|
306
|
+
| `1` | Operation failure, unhealthy doctor checks, or an import with failures |
|
|
307
|
+
| `2` | Invalid arguments |
|
|
308
|
+
| `130` | Interrupted |
|
|
309
|
+
|
|
310
|
+
Failed imports and unhealthy doctor checks retain `data` for inspection. Error
|
|
311
|
+
codes include `NOT_FOUND`, `INVALID_ARGUMENT`, `STALE_CURSOR`, `IMPORT_BUSY`, and
|
|
312
|
+
`OPERATION_FAILED`. Diagnostics go to stderr. Human output escapes terminal
|
|
313
|
+
controls; JSON preserves original strings. Treat session text as untrusted data.
|
|
314
|
+
|
|
315
|
+
`--data-dir <directory>` selects a separate library. Otherwise the CLI uses
|
|
316
|
+
`SESSIONGRAPH_DATA_DIR` and the app's storage defaults, including legacy aliases
|
|
317
|
+
and database precedence. First access may create or migrate the local library.
|
|
318
|
+
Source histories are read-only; source credentials stay in the backend.
|
|
319
|
+
|
|
320
|
+
## Development
|
|
321
|
+
|
|
322
|
+
`server/cli-schema.ts` defines parsing, help, command discovery, and generated docs.
|
|
323
|
+
`server/cli.ts` handles dispatch and output; the npm launcher loads its bundle.
|
|
324
|
+
|
|
325
|
+
`server/library-service.ts` provides the internal `LibraryService` API using
|
|
326
|
+
`SessionGraphStore` and the adapter registry: `discoverSources`, `setupSources`,
|
|
327
|
+
`removeSources`, `importSessions`, `listSessions`, `searchSessions`, `getSession`,
|
|
328
|
+
`getMessages`, `getTimeline`, `getCommits`, `getEvents`, `getFileChanges`,
|
|
329
|
+
`getRelationships`, `getStats`, `getGraph`, and `diagnose`. Callers close the store.
|
|
330
|
+
CLI and UI share the library, importer, search modules, and per-library source paths.
|
|
331
|
+
|
|
332
|
+
Run `pnpm typecheck && pnpm test && pnpm build`. CLI tests cover native imports,
|
|
333
|
+
configuration, locking, pagination, coverage, unknown usage, terminal escaping,
|
|
334
|
+
and the standalone bundle.
|