session-steward 0.10.3 → 0.11.1

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.1] - 2026-09-14
4
+
5
+ ### Added
6
+
7
+ - Added Official MCP Registry metadata and a package-name MCP launch command for registry clients.
8
+
9
+ ## [0.11.0] - 2026-09-14
10
+
11
+ ### Added
12
+
13
+ - Sessions and workspaces can be marked Keep so manual and scheduled Session Steward cleanup skip them without indexing transcripts or changing provider data.
14
+
3
15
  ## [0.10.3] - 2026-09-10
4
16
 
5
17
  ### Fixed
@@ -162,6 +174,8 @@
162
174
  - Support for custom Codex home folders and a saved folder preference.
163
175
  - Streaming and bounded-memory discovery for large session collections and transcripts.
164
176
 
177
+ [0.11.1]: https://github.com/mallikcheripally/session-steward/compare/v0.11.0...v0.11.1
178
+ [0.11.0]: https://github.com/mallikcheripally/session-steward/compare/v0.10.3...v0.11.0
165
179
  [0.10.3]: https://github.com/mallikcheripally/session-steward/compare/v0.10.2...v0.10.3
166
180
  [0.10.2]: https://github.com/mallikcheripally/session-steward/compare/v0.10.1...v0.10.2
167
181
  [0.10.1]: https://github.com/mallikcheripally/session-steward/compare/v0.10.0...v0.10.1
package/README.md CHANGED
@@ -4,339 +4,210 @@
4
4
  [![Build status](https://img.shields.io/github/actions/workflow/status/mallikcheripally/session-steward/validate.yml?branch=main&style=flat-square&label=build)](https://github.com/mallikcheripally/session-steward/actions/workflows/validate.yml)
5
5
  [![License: MIT](https://img.shields.io/npm/l/session-steward?style=flat-square)](https://github.com/mallikcheripally/session-steward/blob/main/LICENSE)
6
6
 
7
- A local Codex and Claude Code session manager for safely reviewing, backing up, and deleting old sessions from a browser UI or terminal CLI, or through MCP with ChatGPT or Claude.
7
+ Session Steward is a local session manager for Codex and Claude Code. It helps you find old or large sessions across workspaces, decide what is worth keeping, and clean up the related records it recognizes. You can use it with browser UI or terminal CLI, or through MCP with ChatGPT or Claude.
8
8
 
9
- AI coding tools can accumulate hundreds or thousands of local sessions. A session may leave behind transcripts, history, logs, checkpoints, and linked artifacts, so manual cleanup can easily miss related data.
9
+ Codex can delete a session, and Claude Code can purge a project. Built-in deletion works when you already know what should go. Session Steward helps when the hard part is reviewing many sessions across both tools.
10
10
 
11
- Session Steward makes session cleanup safer by finding those records, showing what cleanup will affect, creating a local backup, removing supported data, and verifying the result afterward. Session Steward runs locally.
11
+ - Find inactive or large sessions across workspaces. Switch between Codex and Claude Code, then filter by archive status, name, or session ID.
12
+ - Open a session before deciding. See a distilled timeline of recent messages, file changes, commands, and command results, plus recognized storage and token use.
13
+ - Clean selected sessions using a plan you review first, with a local backup, verification afterward, and recovery when cleanup needs attention.
12
14
 
13
- ![Session Steward cleanup demo](https://raw.githubusercontent.com/mallikcheripally/session-steward/main/docs/session-steward-demo.gif)
14
-
15
- ## Manage local Codex and Claude Code sessions
16
-
17
- - Review and clean up sessions from the browser, terminal, ChatGPT, or Claude through MCP.
18
- - Switch between Codex and Claude Code without installing another package.
19
- - See session counts and the storage used by recognized session files.
20
- - Find sessions inactive for 30, 60, or 90 days.
21
- - Filter active or archived sessions by workspace, name, or session ID.
22
- - Inspect session details and affected records before deletion.
23
- - Read a session timeline of what you asked, what changed, and which commands ran.
24
- - See how many tokens a session used, split into fresh input, cached input, cache writes, and output.
25
- - Choose standard or thorough cleanup.
26
- - Use custom Codex or Claude home folders across browser and terminal sessions.
27
-
28
- ## Safe by default
29
-
30
- - Cleanup happens entirely on your computer.
31
- - Only records included in the reviewed cleanup plan are removed.
32
- - A local recovery backup is created before anything changes.
33
- - Cleanup is verified before the backup is removed.
34
- - Unrecognized storage is reported and left untouched.
35
- - Thorough cleanup is unavailable when the detected storage format is not supported.
36
- - Cleanup stays local and does not upload session contents.
37
-
38
- At startup, Session Steward may contact the public npm registry to check for a newer version.
39
-
40
- ### Session Steward does not remove
41
-
42
- - Sign-in data or saved API credentials
43
- - Configuration, plugins, caches, or custom prompt files
44
- - Project files, Git repositories, or worktrees
45
- - Sessions outside the reviewed cleanup plan
46
- - Conversations stored in your ChatGPT or Claude account
47
- - Claude Code worktrees, branches, repositories, remote sessions, SSH sessions, or Cowork data
48
-
49
- ## Install and get started
15
+ ## Try Session Steward locally
50
16
 
51
- Session Steward supports macOS, Linux, and Windows and requires Node.js 24.15 or newer.
17
+ Try the browser app for one run without installing it globally:
52
18
 
53
- Install it globally:
19
+ Session Steward requires Node.js 24.15 or newer.
54
20
 
55
21
  ```bash
56
- npm install --global session-steward
22
+ npx session-steward@latest
57
23
  ```
58
24
 
59
- Then launch it:
25
+ The browser app listens only on `127.0.0.1` and does not upload session contents.
60
26
 
61
- ```bash
62
- session-steward
63
- ```
27
+ ![Session Steward cleanup demo](https://raw.githubusercontent.com/mallikcheripally/session-steward/main/docs/session-steward-demo.gif)
64
28
 
65
- Or try it without installing:
29
+ For ongoing use, install it globally:
66
30
 
67
31
  ```bash
68
- npx session-steward@latest
32
+ npm install --global session-steward
69
33
  ```
70
34
 
71
- Session Steward opens in your browser, listens only on `127.0.0.1`, and detects `~/.codex` and `~/.claude` by default. Claude Code CLI and local Claude Desktop sessions are detected on macOS and Windows; the Claude Code CLI is also supported on Linux. On Windows, these resolve to `%USERPROFILE%\.codex` and `%USERPROFILE%\.claude`.
72
-
73
- When run inside WSL, Session Steward uses the Linux home folder and manages sessions stored there. Run it from Windows to manage sessions in your Windows profile.
74
-
75
- To clean up sessions:
76
-
77
- 1. Review the detected sessions.
78
- 2. Select one or more sessions.
79
- 3. Choose a cleanup option.
80
- 4. Review exactly what will be removed.
81
- 5. Close any selected sessions that may still be active.
82
- 6. Confirm the cleanup.
35
+ The global install provides four commands:
83
36
 
84
- Keep the terminal open while using Session Steward. Press `Ctrl+C` to stop it.
37
+ | Command | Use it for |
38
+ | --- | --- |
39
+ | `session-steward` | Browser interface |
40
+ | `session-steward-cli` | Interactive terminal and JSON output |
41
+ | `session-steward-mcp` | MCP session management |
42
+ | `session-steward-scheduler` | Automatic session cleanup |
85
43
 
86
- ## Cleanup and recovery
44
+ Session Steward supports macOS, Linux, and Windows. Run `session-steward` to open the browser interface. Leave its terminal open while you use it; press `Ctrl+C` to stop it.
87
45
 
88
- ### Standard cleanup
46
+ ## Find old and large Codex and Claude Code sessions
89
47
 
90
- Recommended for routine removal. It removes supported transcripts, history, registry entries, logs, and linked session artifacts belonging to the selected sessions.
48
+ Session Steward reads the local session folders already used by Codex and Claude Code. It looks for `~/.codex` and `~/.claude` by default and lets you switch providers from the same interface.
91
49
 
92
- ### Thorough cleanup
50
+ You can:
93
51
 
94
- Includes standard cleanup and removes additional recognized session-owned data. For Codex this can include supported Desktop references, memory outputs, and goal records. For Claude Code this includes recognized file checkpoints.
52
+ - filter by inactivity, exact workspace, active or archived status, name, or session ID;
53
+ - see recognized session-owned storage by session and workspace, then sort by size;
54
+ - browse session timeline of recent messages, file changes, commands, and command results;
55
+ - inspect fresh input, cached input, cache writes, output, and recorded reasoning tokens;
56
+ - mark a session or workspace **Keep** so manual and scheduled cleanup skip it.
95
57
 
96
- Thorough cleanup is unavailable when Session Steward finds storage it does not recognize. Standard cleanup remains available for supported records that can be identified safely.
58
+ A workspace Keep covers that folder, its descendants, and future sessions there. Keep affects Session Steward cleanup only. Codex or Claude Code can still remove their own data.
97
59
 
98
- ### Recovery backups
60
+ ## Why not just delete sessions one at a time?
99
61
 
100
- A temporary backup is created inside the active provider folder under `session-steward-backups/`.
62
+ The native delete commands are useful when you already know what should go. They do not cover the same cross-workspace review and cleanup job.
101
63
 
102
- After cleanup is successfully verified, the backup is removed automatically. If cleanup fails, Session Steward keeps the backup and lets you restore the sessions, keep the backup, or delete it.
64
+ A session can have more than its transcript. Depending on the provider and storage version, it may also have history or registry entries, logs, checkpoints, and other linked records. Removing a JSONL file by hand can leave those records behind.
103
65
 
104
- Before restoring, the current versions of affected files are saved separately to provide another recovery point.
66
+ Session Steward starts from the session instead of a file path. It finds supported related records, shows them in one cleanup plan, and leaves storage it does not recognize alone. You can review several candidates together without treating every old session as safe to delete.
105
67
 
106
- ## Terminal CLI
68
+ ## Use the browser, CLI, or MCP
107
69
 
108
- Start the interactive terminal interface:
70
+ ### Browser
109
71
 
110
- ```bash
111
- session-steward-cli
112
- ```
113
-
114
- Use Claude Code instead of Codex:
72
+ Run:
115
73
 
116
74
  ```bash
117
- session-steward-cli --provider claude-code
75
+ session-steward
118
76
  ```
119
77
 
120
- List sessions as JSON:
78
+ Choose Codex or Claude Code, filter or search the list, and open sessions you are unsure about. When you select sessions for cleanup, the browser shows the affected records before asking for confirmation.
121
79
 
122
- ```bash
123
- session-steward-cli --json --limit 10
124
- ```
80
+ Use `session-steward --no-open` to start without opening a browser automatically. Open the local address printed in the terminal.
125
81
 
126
- <details>
127
- <summary>More terminal options</summary>
82
+ ### Terminal CLI
128
83
 
129
- Show session and workspace storage totals:
84
+ Start the interactive terminal:
130
85
 
131
86
  ```bash
132
- session-steward-cli --overview
87
+ session-steward-cli
133
88
  ```
134
89
 
135
- Add `--json` when the output will be read by another tool.
136
-
137
- Find sessions inactive for at least 60 days:
90
+ Use Claude Code instead of Codex, or return a limited JSON result for another tool:
138
91
 
139
92
  ```bash
140
- session-steward-cli --inactive-days 60
93
+ session-steward-cli --provider claude-code
94
+ session-steward-cli --json --limit 10
141
95
  ```
142
96
 
143
- Show only archived sessions:
97
+ Filter with options such as `--inactive-days 60`, `--archive-status archived`, or `--workspace /path/to/project`. Use `--events` for the timeline, `--tokens` for token use, and `--sort size` for the largest sessions first. Run `session-steward-cli --help` for every option.
144
98
 
145
- ```bash
146
- session-steward-cli --archive-status archived
147
- ```
99
+ ### MCP with ChatGPT, Codex, or Claude Code
148
100
 
149
- Show sessions from one exact workspace:
101
+ Connect the local MCP server once:
150
102
 
151
103
  ```bash
152
- session-steward-cli --workspace /path/to/project
104
+ codex mcp add session-steward -- session-steward-mcp
153
105
  ```
154
106
 
155
- Use `--include-internals` to include subagents and `--include-supporting` to include supporting sessions. Session sizes are shown in the interactive list, and `--sort size` places the largest sessions first.
156
-
157
- Start with `--events` to read what happened inside a session — what you asked, what the assistant concluded, which files changed, and which commands ran or failed. In the interactive list, `inspect <number>` then shows that session's timeline:
107
+ Or connect it to Claude Code:
158
108
 
159
109
  ```bash
160
- session-steward-cli --events --events-limit 50
110
+ claude mcp add --scope user session-steward -- session-steward-mcp
161
111
  ```
162
112
 
163
- With `--json`, each session carries its own `events`, plus a `coverage` summary of how much of the transcript was recognized:
164
-
165
- ```bash
166
- session-steward-cli --json --limit 5 --events
167
- ```
113
+ Registry installers can start the same server without a global install using `npx session-steward@latest mcp`.
168
114
 
169
- Use `--tokens` to count what a session spent. The total is split into fresh input, cached input, cache writes, and output, with reasoning reported as a share of output where the provider records it:
115
+ You can then ask your client to find inactive sessions, compare recognized session storage between Codex and Claude Code, inspect a session, keep a workspace, clean exact sessions, restore a backup, or manage a cleanup schedule.
170
116
 
171
- ```bash
172
- session-steward-cli --tokens
173
- ```
117
+ Session Steward marks cleanup, restore, and schedule management as destructive MCP actions so the client can apply its configured approval policy.
174
118
 
175
- In the interactive list, `tokens` toggles the same breakdown into `inspect`. With `--json`, each session carries a `tokens` object:
119
+ Scheduled cleanup continues in the background after you close the client. You can ask to pause, resume, run, change, or remove a schedule. Before uninstalling Session Steward, stop scheduled cleanup:
176
120
 
177
121
  ```bash
178
- session-steward-cli --json --limit 5 --tokens
179
- ```
180
-
181
- Cached input usually dominates, because the whole conversation is re-sent on every turn. A forked session reports its own work separately from the tokens it inherited from the session it branched from, so the two are never added together.
182
-
183
- The interactive terminal accepts the same filters:
184
-
185
- ```text
186
- inactive 30
187
- inactive 60
188
- inactive 90
189
- archive active
190
- archive archived
191
- workspace /path/to/project
192
- internals
193
- supporting
194
- tokens
195
- cleanup standard
196
- cleanup thorough
197
- overview
198
- backups
122
+ session-steward-scheduler --stop
199
123
  ```
200
124
 
201
- Run `inactive`, `archive`, or `workspace` without a value to clear that filter.
202
-
203
- `backups` lists recovery backups retained after an interrupted or unsuccessful cleanup. Use `restore <number>` to restore one, or `delete-backup <number>` to remove it permanently. Both actions require an explicit confirmation.
204
-
205
- </details>
206
-
207
- Use `session-steward-cli --help` to see all available options.
208
-
209
- ## Clean up sessions with ChatGPT or Claude
210
-
211
- Connect Session Steward once, then ask ChatGPT or Claude to find old or large
212
- sessions, delete them safely, restore a backup, or clean sessions automatically
213
- on a schedule.
125
+ For another MCP client, configure a local stdio server named `session-steward` with the command `session-steward-mcp`.
214
126
 
215
- Connect it to ChatGPT and Codex:
127
+ The MCP process uses Session Steward's saved provider folders or the defaults when none are saved. Its server command can set startup folders with `--codex-home` or `--claude-home`, and its `manage_settings` tool can change the saved folders. A one-time browser or CLI override does not carry into a later MCP process.
216
128
 
217
- ```bash
218
- codex mcp add session-steward -- session-steward-mcp
219
- ```
129
+ The MCP server runs locally, but session details can contain messages, commands, file names, and workspace paths. Your MCP client may send that information to its AI provider.
220
130
 
221
- Connect it to Claude Code:
131
+ ## Review what will be deleted first
222
132
 
223
- ```bash
224
- claude mcp add --scope user session-steward -- session-steward-mcp
225
- ```
133
+ For a manual cleanup:
226
134
 
227
- You can then ask things like:
135
+ 1. Select the sessions.
136
+ 2. Close any selected sessions that may still be active.
137
+ 3. Review the cleanup plan Session Steward builds.
138
+ 4. Confirm the plan.
139
+ 5. Session Steward creates a local recovery backup.
140
+ 6. It removes only supported records in the reviewed plan.
141
+ 7. It checks whether those records are gone.
228
142
 
229
- - “Find sessions I have not used in 60 days.”
230
- - “Show sessions from this workspace, largest first.”
231
- - “Delete those sessions.”
232
- - “Every 12 days, delete sessions I have not used in 45 days.”
233
- - “Restore my latest backup.”
143
+ Every interface revalidates the selected sessions before changing data. If Session Steward can detect that a selected session is active, preflight or cleanup stops. When detection is unavailable, it warns you to confirm that the selected sessions are closed.
234
144
 
235
- Cleanup uses the same local backup and verification checks as the browser and
236
- terminal. Codex or Claude Code asks for approval before cleanup, restore, or
237
- schedule changes.
145
+ ### Standard and thorough cleanup
238
146
 
239
- Scheduled cleanup continues in the background after you close Codex or Claude
240
- Code. You can ask to pause, resume, run, change, or remove a schedule. Before
241
- uninstalling Session Steward, stop scheduled cleanup:
147
+ **Standard cleanup** removes supported transcripts, history, registry entries, logs, and linked artifacts belonging to the selected sessions. It is the routine option.
242
148
 
243
- ```bash
244
- session-steward-scheduler --stop
245
- ```
149
+ **Thorough cleanup** also removes additional recognized session-owned data. For Codex, that can include supported Desktop references, memory outputs, and goal records. For Claude Code, it includes recognized file checkpoints.
246
150
 
247
- Check or remove the MCP connection at any time:
151
+ Thorough cleanup is unavailable when the detected storage layout is not supported. Standard cleanup can still remove records that Session Steward can identify safely.
248
152
 
249
- ```bash
250
- codex mcp list
251
- codex mcp remove session-steward
153
+ <details>
154
+ <summary>Backup and restore behavior</summary>
252
155
 
253
- claude mcp list
254
- claude mcp remove --scope user session-steward
255
- ```
156
+ Recovery backups are stored under `session-steward-backups/` inside the active provider folder.
256
157
 
257
- For another MCP client, add a local server named `session-steward`:
158
+ If cleanup from the browser or interactive terminal needs attention, the backup is kept until you decide whether to restore it. The browser offers **Restore**, and the terminal reports the backup for the `restore` command. MCP and scheduled cleanup try to restore automatically.
258
159
 
259
- ```json
260
- {
261
- "mcpServers": {
262
- "session-steward": {
263
- "command": "session-steward-mcp"
264
- }
265
- }
266
- }
267
- ```
160
+ After successful cleanup, Session Steward removes the recovery backup when it can. A restore first creates a temporary safety backup of the current files, then tries to remove both backups if the restore succeeds. If a restore or backup removal cannot complete, recovery data remains and Session Steward reports it.
268
161
 
269
- The MCP server uses the same provider folders selected in the browser or
270
- terminal.
162
+ </details>
271
163
 
272
- ### Privacy
164
+ ### What cleanup leaves alone
273
165
 
274
- The MCP server runs locally. Session details can include messages, commands,
275
- file names, and workspace paths, and your MCP client may send that information
276
- to its AI provider.
166
+ - Sign-in data and saved API credentials
167
+ - Configuration, plugins, caches, and custom prompt files
168
+ - Project files, Git repositories, and worktrees
169
+ - Sessions outside the reviewed cleanup plan
170
+ - Conversations stored in your ChatGPT or Claude account
171
+ - Claude Code worktrees, branches, repositories, remote sessions, SSH sessions, and Cowork data
277
172
 
278
- ## Use a custom provider folder
173
+ ## Provider folders and platform support
279
174
 
280
- The browser interface displays the active provider folder. Select **Change** to choose another existing folder and remember it for later browser and terminal sessions.
175
+ The browser shows the active provider folder. Select **Change** to choose another existing folder and save it for later browser, terminal, and MCP sessions.
281
176
 
282
- For a one-time override:
177
+ For a one-time browser override:
283
178
 
284
179
  ```bash
285
180
  session-steward --codex-home /path/to/.codex
286
- ```
287
-
288
- For Claude Code:
289
-
290
- ```bash
291
181
  session-steward --claude-home /path/to/.claude
292
182
  ```
293
183
 
294
- The command-line override applies only to that run and does not replace your saved folder.
184
+ The CLI and MCP commands accept the same flags. An override applies only to that process and does not replace the saved folder.
295
185
 
296
- ## Other commands
186
+ Codex and Claude Code CLI sessions are supported on macOS, Linux, and Windows. Local Claude Desktop sessions are also supported on macOS and Windows. On Windows, the default provider folders are `%USERPROFILE%\.codex` and `%USERPROFILE%\.claude`; both standalone and Microsoft Store Claude Desktop data locations are detected.
297
187
 
298
- Start without automatically opening the browser:
188
+ Inside WSL, Session Steward uses the Linux home folder. Run it from Windows to manage sessions in your Windows profile.
299
189
 
300
- ```bash
301
- session-steward --no-open
302
- ```
190
+ Archiving a Claude Desktop session does not delete it. It remains available until it is explicitly included in cleanup. Session Steward does not remove Claude worktrees.
303
191
 
304
- Update Session Steward:
192
+ ## Update or uninstall
305
193
 
306
194
  ```bash
307
195
  npm install --global session-steward@latest
308
- ```
309
-
310
- Uninstall it:
311
-
312
- ```bash
313
196
  npm uninstall --global session-steward
314
197
  ```
315
198
 
316
- Uninstalling Session Steward does not remove provider sessions, recovery backups, or saved folder preferences.
199
+ Uninstalling does not remove provider sessions, recovery backups, or saved folder preferences.
317
200
 
318
201
  ## Troubleshooting
319
202
 
320
- - **The browser did not open:** Run `session-steward --no-open`, then open the local address shown in the terminal.
203
+ - **The browser did not open:** Run `session-steward --no-open`, then open the local address printed in the terminal.
321
204
  - **No sessions were found:** Check the selected provider and displayed home folder. Use **Change** or pass a one-time home-folder override.
322
- - **Thorough cleanup is unavailable:** Review the compatibility details. Unrecognized storage is left untouched, but standard cleanup may still be available.
205
+ - **Thorough cleanup is unavailable:** Unrecognized storage stays unchanged, while standard cleanup may still be available.
323
206
  - **Your Node.js version is too old:** Install Node.js 24.15 or newer and run Session Steward again.
324
207
 
325
- ## Development
208
+ ## Benchmarks
326
209
 
327
- ```bash
328
- git clone https://github.com/mallikcheripally/session-steward.git
329
- cd session-steward
330
- npm install
331
- npm test
332
- npm run build
333
- ```
334
-
335
- ## Performance and scale
336
-
337
- Session Steward uses paginated listings, incremental transcript reads, and bounded caches to remain responsive with large session libraries.
338
-
339
- Current synthetic benchmarks on an arm64 Mac with Node.js 24.15.0:
210
+ Current benchmarks on an arm64 Mac with Node.js 24.15.0:
340
211
 
341
212
  | Scenario | Scale | Time | Measured memory growth |
342
213
  | --- | ---: | ---: | ---: |
@@ -358,11 +229,7 @@ Results vary with hardware, disk speed, and session layout. Tests and benchmarks
358
229
 
359
230
  ## Support
360
231
 
361
- Codex, Claude Code CLI, and local Claude Code Desktop sessions are supported. Claude Desktop archive is not treated as deletion, and Session Steward never removes its worktrees. On Windows, both the standalone and Microsoft Store Claude Desktop data locations are detected.
362
-
363
- Use [GitHub Issues](https://github.com/mallikcheripally/session-steward/issues) to report a bug, request a provider, or share a storage format that Session Steward does not recognize.
364
-
365
- See the [changelog](https://github.com/mallikcheripally/session-steward/blob/main/CHANGELOG.md) for published release history.
232
+ Use [GitHub Issues](https://github.com/mallikcheripally/session-steward/issues) to report a bug, request a provider, or share a storage format that Session Steward does not recognize. See the [changelog](https://github.com/mallikcheripally/session-steward/blob/main/CHANGELOG.md) for release history.
366
233
 
367
234
  Session Steward is an independent project and is not affiliated with or endorsed by OpenAI or Anthropic.
368
235
 
@@ -106,6 +106,7 @@ async function main() {
106
106
  archiveStatus: values["archive-status"],
107
107
  backups: values.backups ?? false,
108
108
  cleanup: values.cleanup,
109
+ configDirectory: settings.getConfigDirectory(),
109
110
  events: values.events ?? false,
110
111
  eventsLimit,
111
112
  help,
@@ -37,13 +37,17 @@ Options:
37
37
  "../lib/cleanup-schedules.mjs"
38
38
  );
39
39
  const { createProviderSettings } = await import("../lib/settings.mjs");
40
+ const { createSessionProtectionStore } = await import("../lib/session-protections.mjs");
40
41
  const settings = await createProviderSettings({
41
42
  configDirectory: values["config-directory"],
42
43
  });
43
44
  const scheduleStore = createCleanupScheduleStore({
44
45
  configDirectory: settings.getConfigDirectory(),
45
46
  });
46
- const results = await runDueCleanupSchedules({ scheduleStore, settings });
47
+ const protectionStore = createSessionProtectionStore({
48
+ configDirectory: settings.getConfigDirectory(),
49
+ });
50
+ const results = await runDueCleanupSchedules({ protectionStore, scheduleStore, settings });
47
51
  if (results.some((result) => ["failed", "recovery-failed"].includes(result.status))) {
48
52
  process.exitCode = 1;
49
53
  }
@@ -10,20 +10,32 @@ import { findAvailableUpdate, formatUpdateNotice } from "../lib/update-check.mjs
10
10
 
11
11
  assertSupportedNode();
12
12
 
13
- const { values } = parseArgs({
14
- allowPositionals: false,
15
- options: {
16
- "codex-home": { type: "string" },
17
- "claude-home": { type: "string" },
18
- help: { short: "h", type: "boolean" },
19
- "no-open": { type: "boolean", default: false },
20
- port: { type: "string" },
21
- version: { short: "v", type: "boolean" },
22
- },
23
- });
24
-
25
- if (values.help) {
26
- process.stdout.write(`Usage: session-steward [options]
13
+ if (process.argv[2] === "mcp") {
14
+ process.argv.splice(2, 1);
15
+ await import("./session-steward-mcp.mjs");
16
+ } else {
17
+ await startBrowser();
18
+ }
19
+
20
+ async function startBrowser() {
21
+ const { values } = parseArgs({
22
+ allowPositionals: false,
23
+ options: {
24
+ "codex-home": { type: "string" },
25
+ "claude-home": { type: "string" },
26
+ help: { short: "h", type: "boolean" },
27
+ "no-open": { type: "boolean", default: false },
28
+ port: { type: "string" },
29
+ version: { short: "v", type: "boolean" },
30
+ },
31
+ });
32
+
33
+ if (values.help) {
34
+ process.stdout.write(`Usage: session-steward [options]
35
+ session-steward mcp [options]
36
+
37
+ Commands:
38
+ mcp Run the MCP server over stdio
27
39
 
28
40
  Options:
29
41
  --codex-home <path> Use a custom Codex session folder
@@ -33,44 +45,45 @@ Options:
33
45
  -h, --help Show this help
34
46
  -v, --version Show the installed version
35
47
  `);
36
- process.exit(0);
37
- }
48
+ return;
49
+ }
38
50
 
39
- if (values.version) {
40
- process.stdout.write(`${packageMetadata.version}\n`);
41
- process.exit(0);
42
- }
51
+ if (values.version) {
52
+ process.stdout.write(`${packageMetadata.version}\n`);
53
+ return;
54
+ }
43
55
 
44
- const { startLocalServer } = await import("../lib/server.mjs");
45
- const port = values.port === undefined ? 0 : Number.parseInt(values.port, 10);
46
- const availableUpdate = await findAvailableUpdate({ packageMetadata });
56
+ const { startLocalServer } = await import("../lib/server.mjs");
57
+ const port = values.port === undefined ? 0 : Number.parseInt(values.port, 10);
58
+ const availableUpdate = await findAvailableUpdate({ packageMetadata });
47
59
 
48
- if (availableUpdate) {
49
- process.stdout.write(`${formatUpdateNotice(availableUpdate)}\n`);
50
- }
60
+ if (availableUpdate) {
61
+ process.stdout.write(`${formatUpdateNotice(availableUpdate)}\n`);
62
+ }
63
+
64
+ const server = await startLocalServer({
65
+ claudeHome: values["claude-home"],
66
+ codexHome: values["codex-home"],
67
+ port,
68
+ });
69
+
70
+ process.stdout.write(`Session Steward is running at http://127.0.0.1:${server.port}\n`);
51
71
 
52
- const server = await startLocalServer({
53
- claudeHome: values["claude-home"],
54
- codexHome: values["codex-home"],
55
- port,
56
- });
57
-
58
- process.stdout.write(`Session Steward is running at http://127.0.0.1:${server.port}\n`);
59
-
60
- if (!values["no-open"]) {
61
- const url = `http://127.0.0.1:${server.port}`;
62
- const invocation = getBrowserOpenInvocation(url);
63
-
64
- if (invocation) {
65
- const opener = spawn(invocation.command, invocation.args, {
66
- detached: true,
67
- stdio: "ignore",
68
- windowsHide: invocation.windowsHide,
69
- });
70
- opener.unref();
71
- } else {
72
- process.stdout.write(`Open ${url} in a browser.\n`);
72
+ if (!values["no-open"]) {
73
+ const url = `http://127.0.0.1:${server.port}`;
74
+ const invocation = getBrowserOpenInvocation(url);
75
+
76
+ if (invocation) {
77
+ const opener = spawn(invocation.command, invocation.args, {
78
+ detached: true,
79
+ stdio: "ignore",
80
+ windowsHide: invocation.windowsHide,
81
+ });
82
+ opener.unref();
83
+ } else {
84
+ process.stdout.write(`Open ${url} in a browser.\n`);
85
+ }
73
86
  }
74
- }
75
87
 
76
- process.stdout.write("Press Ctrl+C to stop.\n");
88
+ process.stdout.write("Press Ctrl+C to stop.\n");
89
+ }