spooling 0.2.17__tar.gz → 0.2.19__tar.gz
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.
- {spooling-0.2.17/spooling.egg-info → spooling-0.2.19}/PKG-INFO +49 -2
- {spooling-0.2.17 → spooling-0.2.19}/README.md +48 -1
- {spooling-0.2.17 → spooling-0.2.19}/pyproject.toml +1 -1
- {spooling-0.2.17 → spooling-0.2.19}/spooling/cli.py +22 -3
- {spooling-0.2.17 → spooling-0.2.19}/spooling/cloud.py +25 -1
- {spooling-0.2.17 → spooling-0.2.19}/spooling/summarize.py +143 -2
- {spooling-0.2.17 → spooling-0.2.19/spooling.egg-info}/PKG-INFO +49 -2
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_cloud_errors.py +23 -1
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_docs.py +1 -1
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_summarize.py +170 -0
- {spooling-0.2.17 → spooling-0.2.19}/LICENSE +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/setup.cfg +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/__init__.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/agent.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/classifiers.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/config.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/__init__.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/base.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/bigquery.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/clickhouse.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/factory.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/mongodb.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/mysql.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/postgresql.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/rest/__init__.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/rest/base.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/rest/shopify_connectors.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/snowflake.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/connectors/types.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/db.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/device_login.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/embeddings.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/evals.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/experiments.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/ingest.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/insights.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/mcp_server.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/optimize.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/parser.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/pricing.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/__init__.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/antigravity.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/base.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/claude_code.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/codex.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/copilot.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/cortex_code.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/cursor.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/gemini.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/github.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/gitlab.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/kiro.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/opencode.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/session_file.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/providers/windsurf.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/redact.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/remote_otel.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/schema.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/sdk.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/search.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/server.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/sessions.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/stats.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/subscription_pricing.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/tracing.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/tunnel.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/tunnel_auth.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling/watcher.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling.egg-info/SOURCES.txt +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling.egg-info/dependency_links.txt +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling.egg-info/entry_points.txt +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling.egg-info/requires.txt +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/spooling.egg-info/top_level.txt +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_agent_spans.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_claude_code_provider.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_cloud_teams.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_device_login.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_insights.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_mcp_auth_middleware.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_session_ids.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_storage_optimizations.py +0 -0
- {spooling-0.2.17 → spooling-0.2.19}/tests/test_tunnel_auth.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spooling
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.19
|
|
4
4
|
Summary: Local session tracker and semantic search for AI coding assistants
|
|
5
5
|
Author: Parsed Analytics, Inc.
|
|
6
6
|
License: MIT
|
|
@@ -240,6 +240,8 @@ Some providers already supply a summary (Claude Code writes `summary` records).
|
|
|
240
240
|
| `openai` (default) | Any OpenAI-compatible endpoint: local [Ollama](https://ollama.com), OpenAI, OpenRouter, vLLM, LiteLLM | none for local; `SPOOLING_SUMMARY_API_KEY` for hosted |
|
|
241
241
|
| `anthropic` | The Anthropic API | `ANTHROPIC_API_KEY` |
|
|
242
242
|
| `bedrock` | AWS Bedrock (Converse API). Uses `boto3`, which Spooling already installs | `AWS_BEARER_TOKEN_BEDROCK` (Bedrock API key; needs a recent `boto3`) or any normal AWS credentials, plus `AWS_REGION` |
|
|
243
|
+
| `claude-code` | Reuse your Claude Code login (runs `claude -p`), here or on another machine with `--ssh` | whatever Claude Code is signed in with |
|
|
244
|
+
| `opencode` | Reuse opencode's providers (runs `opencode run`), here or over `--ssh` | whatever opencode is configured with |
|
|
243
245
|
|
|
244
246
|
The default is a local Ollama daemon, so nothing leaves your machine. Any other backend sends redacted transcripts to a third party, so Spooling asks for confirmation first (skip with `--yes`).
|
|
245
247
|
|
|
@@ -252,17 +254,47 @@ spooling summarize --base-url https://api.openai.com/v1 --model gpt-4o-mini
|
|
|
252
254
|
spooling summarize --backend anthropic # defaults to claude-haiku-4-5
|
|
253
255
|
spooling summarize --backend bedrock --region us-east-2 \
|
|
254
256
|
--model us.anthropic.claude-haiku-4-5-20251001-v1:0
|
|
257
|
+
|
|
258
|
+
spooling summarize --backend claude-code # uses your Claude Code login
|
|
259
|
+
spooling summarize --backend claude-code --ssh my-other-mac
|
|
260
|
+
spooling summarize --backend opencode --model amazon-bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0
|
|
255
261
|
```
|
|
256
262
|
|
|
257
263
|
- `-p, --project`, `--provider`, `-d, --days`, `-n, --limit` - choose which sessions
|
|
258
264
|
- `--min-messages` - skip very short sessions (default 4)
|
|
259
|
-
- `--backend` - `openai`, `anthropic` or `
|
|
265
|
+
- `--backend` - `openai`, `anthropic`, `bedrock`, `claude-code` or `opencode` (or set `SPOOLING_SUMMARY_BACKEND`)
|
|
260
266
|
- `--model` - model name or id (or set `SPOOLING_SUMMARY_MODEL`). Defaults to `qwen2.5:7b` for `openai` and `claude-haiku-4-5` for `anthropic`; `bedrock` requires one, because Bedrock ids differ by region and account (use an inference profile id such as `us.anthropic.claude-haiku-4-5-20251001-v1:0`)
|
|
261
267
|
- `--base-url` - endpoint for the `openai` backend (or `SPOOLING_SUMMARY_BASE_URL`; default `http://localhost:11434/v1`)
|
|
262
268
|
- `--region` - AWS region for `bedrock` (default `AWS_REGION`)
|
|
269
|
+
- `--ssh HOST` - run the `claude-code` or `opencode` backend on another machine over SSH (for example a Mac where Claude Code is signed in). Needs key-based SSH login; the redacted transcript is piped over the connection
|
|
270
|
+
- `--cli-cmd` - the command to run if it isn't on `PATH`, such as `~/.local/bin/claude`. With `--ssh`, this is the path on the remote machine
|
|
263
271
|
- `--force` - regenerate even if a summary exists
|
|
264
272
|
- `-y, --yes` - don't ask before sending text to a non-local endpoint
|
|
265
273
|
|
|
274
|
+
#### Summarize one session
|
|
275
|
+
|
|
276
|
+
Name the session by its id (or any unique prefix) and pick the backend:
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
spooling session list --title login # find the id first
|
|
280
|
+
spooling summarize ses_e6310bd1 --backend claude-code
|
|
281
|
+
spooling summarize ses_e6310bd1 --backend claude-code --ssh my-other-mac
|
|
282
|
+
spooling session show ses_e6310bd1 # read it back
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
- If the session already has a summary, nothing runs. Add `--force` to replace it, including a summary the provider wrote.
|
|
286
|
+
- Naming a session skips the `--min-messages` filter, so short sessions work too. You can name several: `spooling summarize ID1 ID2 --backend claude-code`.
|
|
287
|
+
- `--dry-run` shows what would run without calling a model, and `-y` skips the confirmation prompt.
|
|
288
|
+
- To avoid typing the backend each time, `export SPOOLING_SUMMARY_BACKEND=claude-code`. There is no environment variable for `--ssh`.
|
|
289
|
+
|
|
290
|
+
#### Using Claude Code or opencode
|
|
291
|
+
|
|
292
|
+
The `claude-code` and `opencode` backends run the agent's headless mode and send the prompt on stdin, so there is no API key to set up: they use whatever login the agent already has. Both send the redacted transcript to that agent's provider, so Spooling asks for confirmation first.
|
|
293
|
+
|
|
294
|
+
- Leave `--model` off to use the agent's default model. For opencode, the model is `provider/model`, and your configured default may be an old model id, so pass one explicitly if you see an error.
|
|
295
|
+
- With `--ssh`, the agent runs from `/tmp` on the remote machine, so it doesn't pick up a project's rules. SSH runs non-interactively and often skips your shell profile, so if you get "not found", use `--cli-cmd` with the full path.
|
|
296
|
+
- `claude -p` records each run as a session in that machine's Claude Code history. They are tagged with a `spooling-summary:` prefix, and `spooling summarize` skips them. The opencode backend deletes its run's session automatically.
|
|
297
|
+
|
|
266
298
|
The run stops early on errors that would repeat for every session (bad credentials, an unreachable server, an unknown model). A summary Spooling generated is refreshed on the next run once the session has grown; `session show` tells you when that is the case.
|
|
267
299
|
|
|
268
300
|
### `spooling optimize`
|
|
@@ -455,6 +487,21 @@ spooling push --dry-run # show what would be pushed
|
|
|
455
487
|
|
|
456
488
|
`push` ingests new provider sessions into the local database before uploading, so you don't need to run `spooling sync` first. The server upserts by session id, so re-running is safe.
|
|
457
489
|
|
|
490
|
+
#### When a Free workspace is full
|
|
491
|
+
|
|
492
|
+
The Free plan caps each workspace (500 sessions, 100,000 messages, 5,000 traces). When a push would go past a cap the server answers
|
|
493
|
+
`402`, and `spooling push` stops with a clear message and a non-zero exit code:
|
|
494
|
+
|
|
495
|
+
```
|
|
496
|
+
Free plan limit reached: this workspace can't take more on the Free plan.
|
|
497
|
+
The Free plan allows 500 sessions per workspace. Delete old ones with `spooling cloud delete`, or upgrade at https://app.spooling.ai/settings?tab=billing
|
|
498
|
+
Nothing already pushed was removed; the rest of this push was not sent.
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
Nothing you have already pushed is removed, and sessions already in the workspace can still be updated by a batch that adds no new
|
|
502
|
+
ones. Free space with `spooling cloud delete`, or upgrade from the link. `spooling cloud watch` shows the message once and then a
|
|
503
|
+
short "still at the Free plan limit" line each cycle, and carries on automatically once there is room.
|
|
504
|
+
|
|
458
505
|
### Push only some sessions, or to a specific team
|
|
459
506
|
|
|
460
507
|
**Which team gets the sessions** is decided by the API key you are logged in with. Each key belongs to one workspace (personal or a team), and `spooling push` sends to that workspace. Mint a key for the team in the app, then log in with it:
|
|
@@ -204,6 +204,8 @@ Some providers already supply a summary (Claude Code writes `summary` records).
|
|
|
204
204
|
| `openai` (default) | Any OpenAI-compatible endpoint: local [Ollama](https://ollama.com), OpenAI, OpenRouter, vLLM, LiteLLM | none for local; `SPOOLING_SUMMARY_API_KEY` for hosted |
|
|
205
205
|
| `anthropic` | The Anthropic API | `ANTHROPIC_API_KEY` |
|
|
206
206
|
| `bedrock` | AWS Bedrock (Converse API). Uses `boto3`, which Spooling already installs | `AWS_BEARER_TOKEN_BEDROCK` (Bedrock API key; needs a recent `boto3`) or any normal AWS credentials, plus `AWS_REGION` |
|
|
207
|
+
| `claude-code` | Reuse your Claude Code login (runs `claude -p`), here or on another machine with `--ssh` | whatever Claude Code is signed in with |
|
|
208
|
+
| `opencode` | Reuse opencode's providers (runs `opencode run`), here or over `--ssh` | whatever opencode is configured with |
|
|
207
209
|
|
|
208
210
|
The default is a local Ollama daemon, so nothing leaves your machine. Any other backend sends redacted transcripts to a third party, so Spooling asks for confirmation first (skip with `--yes`).
|
|
209
211
|
|
|
@@ -216,17 +218,47 @@ spooling summarize --base-url https://api.openai.com/v1 --model gpt-4o-mini
|
|
|
216
218
|
spooling summarize --backend anthropic # defaults to claude-haiku-4-5
|
|
217
219
|
spooling summarize --backend bedrock --region us-east-2 \
|
|
218
220
|
--model us.anthropic.claude-haiku-4-5-20251001-v1:0
|
|
221
|
+
|
|
222
|
+
spooling summarize --backend claude-code # uses your Claude Code login
|
|
223
|
+
spooling summarize --backend claude-code --ssh my-other-mac
|
|
224
|
+
spooling summarize --backend opencode --model amazon-bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0
|
|
219
225
|
```
|
|
220
226
|
|
|
221
227
|
- `-p, --project`, `--provider`, `-d, --days`, `-n, --limit` - choose which sessions
|
|
222
228
|
- `--min-messages` - skip very short sessions (default 4)
|
|
223
|
-
- `--backend` - `openai`, `anthropic` or `
|
|
229
|
+
- `--backend` - `openai`, `anthropic`, `bedrock`, `claude-code` or `opencode` (or set `SPOOLING_SUMMARY_BACKEND`)
|
|
224
230
|
- `--model` - model name or id (or set `SPOOLING_SUMMARY_MODEL`). Defaults to `qwen2.5:7b` for `openai` and `claude-haiku-4-5` for `anthropic`; `bedrock` requires one, because Bedrock ids differ by region and account (use an inference profile id such as `us.anthropic.claude-haiku-4-5-20251001-v1:0`)
|
|
225
231
|
- `--base-url` - endpoint for the `openai` backend (or `SPOOLING_SUMMARY_BASE_URL`; default `http://localhost:11434/v1`)
|
|
226
232
|
- `--region` - AWS region for `bedrock` (default `AWS_REGION`)
|
|
233
|
+
- `--ssh HOST` - run the `claude-code` or `opencode` backend on another machine over SSH (for example a Mac where Claude Code is signed in). Needs key-based SSH login; the redacted transcript is piped over the connection
|
|
234
|
+
- `--cli-cmd` - the command to run if it isn't on `PATH`, such as `~/.local/bin/claude`. With `--ssh`, this is the path on the remote machine
|
|
227
235
|
- `--force` - regenerate even if a summary exists
|
|
228
236
|
- `-y, --yes` - don't ask before sending text to a non-local endpoint
|
|
229
237
|
|
|
238
|
+
#### Summarize one session
|
|
239
|
+
|
|
240
|
+
Name the session by its id (or any unique prefix) and pick the backend:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
spooling session list --title login # find the id first
|
|
244
|
+
spooling summarize ses_e6310bd1 --backend claude-code
|
|
245
|
+
spooling summarize ses_e6310bd1 --backend claude-code --ssh my-other-mac
|
|
246
|
+
spooling session show ses_e6310bd1 # read it back
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
- If the session already has a summary, nothing runs. Add `--force` to replace it, including a summary the provider wrote.
|
|
250
|
+
- Naming a session skips the `--min-messages` filter, so short sessions work too. You can name several: `spooling summarize ID1 ID2 --backend claude-code`.
|
|
251
|
+
- `--dry-run` shows what would run without calling a model, and `-y` skips the confirmation prompt.
|
|
252
|
+
- To avoid typing the backend each time, `export SPOOLING_SUMMARY_BACKEND=claude-code`. There is no environment variable for `--ssh`.
|
|
253
|
+
|
|
254
|
+
#### Using Claude Code or opencode
|
|
255
|
+
|
|
256
|
+
The `claude-code` and `opencode` backends run the agent's headless mode and send the prompt on stdin, so there is no API key to set up: they use whatever login the agent already has. Both send the redacted transcript to that agent's provider, so Spooling asks for confirmation first.
|
|
257
|
+
|
|
258
|
+
- Leave `--model` off to use the agent's default model. For opencode, the model is `provider/model`, and your configured default may be an old model id, so pass one explicitly if you see an error.
|
|
259
|
+
- With `--ssh`, the agent runs from `/tmp` on the remote machine, so it doesn't pick up a project's rules. SSH runs non-interactively and often skips your shell profile, so if you get "not found", use `--cli-cmd` with the full path.
|
|
260
|
+
- `claude -p` records each run as a session in that machine's Claude Code history. They are tagged with a `spooling-summary:` prefix, and `spooling summarize` skips them. The opencode backend deletes its run's session automatically.
|
|
261
|
+
|
|
230
262
|
The run stops early on errors that would repeat for every session (bad credentials, an unreachable server, an unknown model). A summary Spooling generated is refreshed on the next run once the session has grown; `session show` tells you when that is the case.
|
|
231
263
|
|
|
232
264
|
### `spooling optimize`
|
|
@@ -419,6 +451,21 @@ spooling push --dry-run # show what would be pushed
|
|
|
419
451
|
|
|
420
452
|
`push` ingests new provider sessions into the local database before uploading, so you don't need to run `spooling sync` first. The server upserts by session id, so re-running is safe.
|
|
421
453
|
|
|
454
|
+
#### When a Free workspace is full
|
|
455
|
+
|
|
456
|
+
The Free plan caps each workspace (500 sessions, 100,000 messages, 5,000 traces). When a push would go past a cap the server answers
|
|
457
|
+
`402`, and `spooling push` stops with a clear message and a non-zero exit code:
|
|
458
|
+
|
|
459
|
+
```
|
|
460
|
+
Free plan limit reached: this workspace can't take more on the Free plan.
|
|
461
|
+
The Free plan allows 500 sessions per workspace. Delete old ones with `spooling cloud delete`, or upgrade at https://app.spooling.ai/settings?tab=billing
|
|
462
|
+
Nothing already pushed was removed; the rest of this push was not sent.
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
Nothing you have already pushed is removed, and sessions already in the workspace can still be updated by a batch that adds no new
|
|
466
|
+
ones. Free space with `spooling cloud delete`, or upgrade from the link. `spooling cloud watch` shows the message once and then a
|
|
467
|
+
short "still at the Free plan limit" line each cycle, and carries on automatically once there is room.
|
|
468
|
+
|
|
422
469
|
### Push only some sessions, or to a specific team
|
|
423
470
|
|
|
424
471
|
**Which team gets the sessions** is decided by the API key you are logged in with. Each key belongs to one workspace (personal or a team), and `spooling push` sends to that workspace. Mint a key for the team in the app, then log in with it:
|
|
@@ -1337,16 +1337,20 @@ def session_show(session_id, messages, max_chars):
|
|
|
1337
1337
|
@click.option("--limit", "-n", default=20, show_default=True, help="Max sessions to summarize")
|
|
1338
1338
|
@click.option("--min-messages", default=4, show_default=True,
|
|
1339
1339
|
help="Skip sessions shorter than this (ignored when ids are given)")
|
|
1340
|
-
@click.option("--backend", type=click.Choice(["openai", "anthropic", "bedrock"]), default=None,
|
|
1340
|
+
@click.option("--backend", type=click.Choice(["openai", "anthropic", "bedrock", "claude-code", "opencode"]), default=None,
|
|
1341
1341
|
help="LLM backend (default: $SPOOLING_SUMMARY_BACKEND or openai = any OpenAI-compatible endpoint, e.g. local Ollama)")
|
|
1342
1342
|
@click.option("--model", default=None, help="Model name or id (default: $SPOOLING_SUMMARY_MODEL, else qwen2.5:7b for openai, claude-haiku-4-5 for anthropic; required for bedrock)")
|
|
1343
1343
|
@click.option("--region", default=None, help="AWS region for --backend bedrock (default: $AWS_REGION)")
|
|
1344
|
+
@click.option("--ssh", default=None, metavar="HOST",
|
|
1345
|
+
help="Run --backend claude-code or opencode on this SSH host (e.g. another Mac where it is signed in)")
|
|
1346
|
+
@click.option("--cli-cmd", default=None,
|
|
1347
|
+
help="Command for claude-code / opencode if it isn't on PATH (e.g. ~/.local/bin/claude); runs on --ssh HOST if set")
|
|
1344
1348
|
@click.option("--base-url", default=None,
|
|
1345
1349
|
help="Endpoint for --backend openai (default: $SPOOLING_SUMMARY_BASE_URL or local Ollama)")
|
|
1346
1350
|
@click.option("--force", is_flag=True, help="Regenerate even if a summary exists (replaces provider summaries too)")
|
|
1347
1351
|
@click.option("--dry-run", is_flag=True, help="List what would be summarized; call no model")
|
|
1348
1352
|
@click.option("--yes", "-y", is_flag=True, help="Don't ask before sending text to a non-local endpoint")
|
|
1349
|
-
def summarize(session_ids, project, provider, days, limit, min_messages, backend, model, region, base_url, force, dry_run, yes):
|
|
1353
|
+
def summarize(session_ids, project, provider, days, limit, min_messages, backend, model, region, ssh, cli_cmd, base_url, force, dry_run, yes):
|
|
1350
1354
|
"""Generate short summaries for sessions that don't have one.
|
|
1351
1355
|
|
|
1352
1356
|
Uses a model you configure; the default is a local Ollama daemon, so
|
|
@@ -1362,6 +1366,9 @@ def summarize(session_ids, project, provider, days, limit, min_messages, backend
|
|
|
1362
1366
|
spooling summarize ses_e6310bd1 --force
|
|
1363
1367
|
spooling summarize --base-url https://api.openai.com/v1 --model gpt-4o-mini
|
|
1364
1368
|
spooling summarize --backend anthropic
|
|
1369
|
+
spooling summarize --backend claude-code # reuse your Claude Code login
|
|
1370
|
+
spooling summarize --backend claude-code --ssh my-other-mac
|
|
1371
|
+
spooling summarize --backend opencode --model amazon-bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0
|
|
1365
1372
|
spooling summarize --backend bedrock --model us.anthropic.claude-haiku-4-5-20251001-v1:0
|
|
1366
1373
|
"""
|
|
1367
1374
|
from spooling.db import get_connection
|
|
@@ -1378,7 +1385,15 @@ def summarize(session_ids, project, provider, days, limit, min_messages, backend
|
|
|
1378
1385
|
except ValueError as e:
|
|
1379
1386
|
console.print(f"[red]{e}[/red]")
|
|
1380
1387
|
raise SystemExit(1)
|
|
1381
|
-
|
|
1388
|
+
if (ssh or cli_cmd) and backend not in sm.CLI_BACKENDS:
|
|
1389
|
+
console.print("[red]--ssh and --cli-cmd only apply to --backend claude-code or opencode.[/red]")
|
|
1390
|
+
raise SystemExit(1)
|
|
1391
|
+
if backend == "openai":
|
|
1392
|
+
where = base_url
|
|
1393
|
+
elif backend in sm.CLI_BACKENDS:
|
|
1394
|
+
where = backend + (f" on {ssh}" if ssh else "")
|
|
1395
|
+
else:
|
|
1396
|
+
where = backend + (f" ({region})" if region else "")
|
|
1382
1397
|
|
|
1383
1398
|
resolved: list[str] = []
|
|
1384
1399
|
for ref in session_ids:
|
|
@@ -1436,9 +1451,13 @@ def summarize(session_ids, project, provider, days, limit, min_messages, backend
|
|
|
1436
1451
|
if not transcript:
|
|
1437
1452
|
console.print(f"[dim]skip[/dim] {label} (no message text)")
|
|
1438
1453
|
continue
|
|
1454
|
+
if transcript.startswith(f"[user] {sm.RUN_MARKER}"):
|
|
1455
|
+
console.print(f"[dim]skip[/dim] {label} (a summarizer run, not real work)")
|
|
1456
|
+
continue
|
|
1439
1457
|
try:
|
|
1440
1458
|
text = sm.generate_summary(
|
|
1441
1459
|
transcript, model=model, base_url=base_url, backend=backend, region=region,
|
|
1460
|
+
ssh=ssh, cli_cmd=cli_cmd,
|
|
1442
1461
|
)
|
|
1443
1462
|
except Exception as e:
|
|
1444
1463
|
failed += 1
|
|
@@ -171,9 +171,23 @@ def _explain_error_impl(e: BaseException, base: str) -> str:
|
|
|
171
171
|
return escape(str(e) or type(e).__name__)
|
|
172
172
|
|
|
173
173
|
|
|
174
|
+
# Stable first words of the 402 explanation, so `watch` can tell "workspace is full" from a real failure.
|
|
175
|
+
PLAN_LIMIT = "Free plan limit reached"
|
|
176
|
+
|
|
177
|
+
|
|
174
178
|
def _explain_http(e: "httpx.HTTPStatusError") -> str:
|
|
175
179
|
code = e.response.status_code
|
|
176
180
|
body = escape(e.response.text[:200])
|
|
181
|
+
if code == 402:
|
|
182
|
+
try:
|
|
183
|
+
detail = e.response.json().get("detail")
|
|
184
|
+
except Exception: # noqa: BLE001 - a proxy's HTML page, an empty body...
|
|
185
|
+
detail = None
|
|
186
|
+
return (
|
|
187
|
+
f"{PLAN_LIMIT}: this workspace can't take more on the Free plan.\n"
|
|
188
|
+
f" {escape(str(detail)) if detail else body}\n"
|
|
189
|
+
f" Nothing already pushed was removed; the rest of this push was not sent."
|
|
190
|
+
)
|
|
177
191
|
if code == 401:
|
|
178
192
|
return (
|
|
179
193
|
f"HTTP 401: the server rejected your API key.\n"
|
|
@@ -927,6 +941,7 @@ def cloud_watch(interval: int, limit: int, batch: int, lookback: int, no_redact:
|
|
|
927
941
|
|
|
928
942
|
console.print(f"[cyan]Watching local sessions → {base}[/cyan]")
|
|
929
943
|
console.print(f" interval: {interval}s · lookback: {lookback}m · starting watermark: {watermark or 'none (full first push)'}")
|
|
944
|
+
limit_warned = False
|
|
930
945
|
|
|
931
946
|
while not stop["flag"]:
|
|
932
947
|
cycle_started = datetime.now(timezone.utc)
|
|
@@ -954,9 +969,18 @@ def cloud_watch(interval: int, limit: int, batch: int, lookback: int, no_redact:
|
|
|
954
969
|
if redaction_count:
|
|
955
970
|
console.print(f" [dim]Redacted {redaction_count} secret(s) before push[/dim]")
|
|
956
971
|
total, rejected, err = _push_batches(sessions, batch, base, headers, console.print)
|
|
957
|
-
if err:
|
|
972
|
+
if err and err.startswith(PLAN_LIMIT):
|
|
973
|
+
# A full workspace will not fix itself, so say it clearly once and then stay quiet instead of repeating it.
|
|
974
|
+
if not limit_warned:
|
|
975
|
+
console.print(f"[red]{err}[/red]")
|
|
976
|
+
console.print(" [dim]Watch keeps running and tries again each cycle, so it resumes as soon as you upgrade or free some space.[/dim]")
|
|
977
|
+
limit_warned = True
|
|
978
|
+
else:
|
|
979
|
+
console.print(f"[dim]{ts}[/dim] [yellow]still at the Free plan limit; nothing was sent[/yellow]")
|
|
980
|
+
elif err:
|
|
958
981
|
console.print(f"[red]{err.splitlines()[0]}[/red] (will retry next cycle)")
|
|
959
982
|
else:
|
|
983
|
+
limit_warned = False
|
|
960
984
|
# Advance watermark to the cycle start; the lookback window catches
|
|
961
985
|
# sessions whose started_at slid backwards or whose messages were
|
|
962
986
|
# appended after the original started_at.
|
|
@@ -26,7 +26,12 @@ Configuration (flags on the CLI override these):
|
|
|
26
26
|
from __future__ import annotations
|
|
27
27
|
|
|
28
28
|
import functools
|
|
29
|
+
import json
|
|
29
30
|
import os
|
|
31
|
+
import re
|
|
32
|
+
import shlex
|
|
33
|
+
import subprocess
|
|
34
|
+
import tempfile
|
|
30
35
|
from urllib.parse import urlparse
|
|
31
36
|
|
|
32
37
|
import httpx
|
|
@@ -127,12 +132,20 @@ def clean_summary(text: str) -> str:
|
|
|
127
132
|
return text
|
|
128
133
|
|
|
129
134
|
|
|
130
|
-
BACKENDS = ("openai", "anthropic", "bedrock")
|
|
135
|
+
BACKENDS = ("openai", "anthropic", "bedrock", "claude-code", "opencode")
|
|
131
136
|
DEFAULT_BACKEND = os.environ.get("SPOOLING_SUMMARY_BACKEND", "openai")
|
|
132
137
|
DEFAULT_ANTHROPIC_MODEL = "claude-haiku-4-5"
|
|
133
138
|
MAX_OUTPUT_TOKENS = 300
|
|
134
139
|
|
|
135
140
|
|
|
141
|
+
_ANSI = re.compile(r"\x1b\[[0-9;?]*[ -/]*[@-~]")
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class FatalBackendError(RuntimeError):
|
|
145
|
+
"""A failure that will repeat for every session (missing model, command not
|
|
146
|
+
found, SSH unreachable), so the run should stop instead of retrying."""
|
|
147
|
+
|
|
148
|
+
|
|
136
149
|
def is_local_backend(backend: str, base_url: str) -> bool:
|
|
137
150
|
"""True if the transcript stays on this machine for this backend."""
|
|
138
151
|
return backend == "openai" and is_local_url(base_url)
|
|
@@ -146,6 +159,9 @@ def resolve_model(backend: str, model: str | None) -> str:
|
|
|
146
159
|
return DEFAULT_MODEL
|
|
147
160
|
if backend == "anthropic":
|
|
148
161
|
return os.environ.get("SPOOLING_SUMMARY_MODEL") or DEFAULT_ANTHROPIC_MODEL
|
|
162
|
+
if backend in CLI_BACKENDS:
|
|
163
|
+
# Empty means "whatever model the agent is configured to use".
|
|
164
|
+
return os.environ.get("SPOOLING_SUMMARY_MODEL") or ""
|
|
149
165
|
# Bedrock ids are region/account specific (inference profiles like
|
|
150
166
|
# "us.anthropic....-v1:0"), so there is no default that is safe everywhere.
|
|
151
167
|
env = os.environ.get("SPOOLING_SUMMARY_MODEL")
|
|
@@ -181,6 +197,11 @@ def _complete_openai(transcript, *, model, base_url, api_key, timeout, client) -
|
|
|
181
197
|
client = client or httpx.Client(timeout=timeout)
|
|
182
198
|
try:
|
|
183
199
|
resp = client.post(url, json=payload, headers=headers)
|
|
200
|
+
if resp.status_code == 404:
|
|
201
|
+
raise FatalBackendError(
|
|
202
|
+
f"404 from {url}: model {model!r} not found, or this is not an OpenAI-compatible "
|
|
203
|
+
f"endpoint. For Ollama, run: ollama pull {model}"
|
|
204
|
+
)
|
|
184
205
|
resp.raise_for_status()
|
|
185
206
|
data = resp.json()
|
|
186
207
|
finally:
|
|
@@ -193,6 +214,119 @@ def _complete_openai(transcript, *, model, base_url, api_key, timeout, client) -
|
|
|
193
214
|
raise ValueError(f"unexpected response from {url}: {str(data)[:200]}") from e
|
|
194
215
|
|
|
195
216
|
|
|
217
|
+
# Backends that shell out to a coding agent's headless mode. The prompt goes in
|
|
218
|
+
# on stdin and the answer comes back on stdout, so this reuses whatever login
|
|
219
|
+
# the agent already has (a Claude Code subscription, opencode's providers).
|
|
220
|
+
# name -> (executable, fixed args, flag that selects a model)
|
|
221
|
+
CLI_BACKENDS = {
|
|
222
|
+
"claude-code": ("claude", ["-p"], "--model"),
|
|
223
|
+
"opencode": ("opencode", ["run", "--format", "json"], "-m"),
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
# Sessions created by these runs show up in the agent's own history (and so in
|
|
227
|
+
# Spooling). Start the prompt with this marker so they are recognizable, and so
|
|
228
|
+
# `spooling summarize` never tries to summarize its own runs.
|
|
229
|
+
RUN_MARKER = "spooling-summary:"
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _parse_opencode_events(stdout: str) -> tuple[str, str | None]:
|
|
233
|
+
"""Pull the answer text and session id out of ``opencode run --format json``."""
|
|
234
|
+
texts: list[str] = []
|
|
235
|
+
session_id = None
|
|
236
|
+
for line in stdout.splitlines():
|
|
237
|
+
try:
|
|
238
|
+
ev = json.loads(line)
|
|
239
|
+
except ValueError:
|
|
240
|
+
continue
|
|
241
|
+
if not isinstance(ev, dict):
|
|
242
|
+
continue
|
|
243
|
+
session_id = session_id or ev.get("sessionID")
|
|
244
|
+
part = ev.get("part") or {}
|
|
245
|
+
if ev.get("type") == "text" and isinstance(part.get("text"), str):
|
|
246
|
+
texts.append(part["text"])
|
|
247
|
+
return "".join(texts), session_id
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _delete_opencode_session(session_id: str, *, ssh, cli_cmd) -> None:
|
|
251
|
+
"""Best effort: remove the run's session so summaries don't pile up in
|
|
252
|
+
opencode's history (and get re-ingested by Spooling)."""
|
|
253
|
+
if not re.fullmatch(r"[A-Za-z0-9_\-]+", session_id):
|
|
254
|
+
return
|
|
255
|
+
base = shlex.split(cli_cmd) if cli_cmd else ["opencode"]
|
|
256
|
+
cmd = base + ["session", "delete", session_id]
|
|
257
|
+
if ssh:
|
|
258
|
+
argv = ["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=10", ssh,
|
|
259
|
+
" ".join(shlex.quote(a) for a in cmd)]
|
|
260
|
+
else:
|
|
261
|
+
argv = cmd
|
|
262
|
+
try:
|
|
263
|
+
subprocess.run(argv, capture_output=True, text=True, timeout=30,
|
|
264
|
+
cwd=None if ssh else tempfile.gettempdir())
|
|
265
|
+
except Exception:
|
|
266
|
+
pass
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def _complete_cli(backend, transcript, *, model, ssh, cli_cmd, timeout) -> str:
|
|
271
|
+
"""Summarize by running a coding agent's headless mode, here or over SSH.
|
|
272
|
+
|
|
273
|
+
With ``ssh`` set the command runs on that host (for example another Mac
|
|
274
|
+
where Claude Code is signed in) and the redacted transcript is piped
|
|
275
|
+
through the SSH connection.
|
|
276
|
+
"""
|
|
277
|
+
exe, fixed, model_flag = CLI_BACKENDS[backend]
|
|
278
|
+
prompt = f"{RUN_MARKER} {SYSTEM_PROMPT}\n\n{_user_prompt(transcript)}"
|
|
279
|
+
cmd = (shlex.split(cli_cmd) if cli_cmd else [exe]) + fixed
|
|
280
|
+
if model:
|
|
281
|
+
cmd += [model_flag, model]
|
|
282
|
+
|
|
283
|
+
if ssh:
|
|
284
|
+
if ssh.startswith("-"):
|
|
285
|
+
raise FatalBackendError(f"invalid ssh host {ssh!r}")
|
|
286
|
+
# Run from /tmp so the agent doesn't load some project's rules or tools
|
|
287
|
+
# into a summarization request.
|
|
288
|
+
remote = "cd /tmp 2>/dev/null; " + " ".join(shlex.quote(a) for a in cmd)
|
|
289
|
+
argv = ["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=10", ssh, remote]
|
|
290
|
+
cwd = None
|
|
291
|
+
else:
|
|
292
|
+
argv, cwd = cmd, tempfile.gettempdir()
|
|
293
|
+
|
|
294
|
+
try:
|
|
295
|
+
proc = subprocess.run(argv, input=prompt, capture_output=True, text=True,
|
|
296
|
+
timeout=timeout, cwd=cwd)
|
|
297
|
+
except FileNotFoundError as e:
|
|
298
|
+
raise FatalBackendError(
|
|
299
|
+
f"could not run {argv[0]!r}: not found. Install it, use --ssh HOST to run it on "
|
|
300
|
+
f"another machine, or pass its full path with --cli-cmd."
|
|
301
|
+
) from e
|
|
302
|
+
except subprocess.TimeoutExpired as e:
|
|
303
|
+
raise RuntimeError(f"{exe} timed out after {timeout:.0f}s") from e
|
|
304
|
+
|
|
305
|
+
err = _ANSI.sub("", proc.stderr or "").strip()[-300:]
|
|
306
|
+
if ssh and proc.returncode == 255:
|
|
307
|
+
raise FatalBackendError(f"ssh to {ssh} failed: {err or 'connection error'}")
|
|
308
|
+
if proc.returncode == 127:
|
|
309
|
+
raise FatalBackendError(
|
|
310
|
+
f"'{exe}' not found{' on ' + ssh if ssh else ''}. Non-interactive shells often skip "
|
|
311
|
+
f"your PATH setup; pass its full path with --cli-cmd. {err}"
|
|
312
|
+
)
|
|
313
|
+
if proc.returncode != 0:
|
|
314
|
+
msg = f"{exe} exited {proc.returncode}: {err or '(no output)'}"
|
|
315
|
+
low = err.lower()
|
|
316
|
+
if "login" in low or "authenticat" in low or "api key" in low:
|
|
317
|
+
raise FatalBackendError(msg + f" (sign in to {exe} on that machine first)")
|
|
318
|
+
raise RuntimeError(msg)
|
|
319
|
+
out = _ANSI.sub("", proc.stdout or "")
|
|
320
|
+
if backend == "opencode":
|
|
321
|
+
out, session_id = _parse_opencode_events(out)
|
|
322
|
+
if session_id:
|
|
323
|
+
_delete_opencode_session(session_id, ssh=ssh, cli_cmd=cli_cmd)
|
|
324
|
+
if not out.strip() and err:
|
|
325
|
+
# opencode prints some failures to stderr but still exits 0.
|
|
326
|
+
raise RuntimeError(f"{exe} returned nothing: {err}")
|
|
327
|
+
return out
|
|
328
|
+
|
|
329
|
+
|
|
196
330
|
@functools.lru_cache(maxsize=4)
|
|
197
331
|
def _anthropic_client(api_key: str | None, timeout: float):
|
|
198
332
|
import anthropic
|
|
@@ -250,6 +384,8 @@ def generate_summary(
|
|
|
250
384
|
api_key: str | None = None,
|
|
251
385
|
backend: str = "openai",
|
|
252
386
|
region: str | None = None,
|
|
387
|
+
ssh: str | None = None,
|
|
388
|
+
cli_cmd: str | None = None,
|
|
253
389
|
timeout: float = 120.0,
|
|
254
390
|
client: httpx.Client | None = None,
|
|
255
391
|
) -> str:
|
|
@@ -263,8 +399,11 @@ def generate_summary(
|
|
|
263
399
|
api_key=api_key, timeout=timeout, client=client)
|
|
264
400
|
elif backend == "anthropic":
|
|
265
401
|
content = _complete_anthropic(transcript, model=model, api_key=api_key, timeout=timeout)
|
|
266
|
-
|
|
402
|
+
elif backend == "bedrock":
|
|
267
403
|
content = _complete_bedrock(transcript, model=model, region=region, timeout=timeout)
|
|
404
|
+
else:
|
|
405
|
+
content = _complete_cli(backend, transcript, model=model, ssh=ssh,
|
|
406
|
+
cli_cmd=cli_cmd, timeout=max(timeout, 180.0))
|
|
268
407
|
|
|
269
408
|
summary = clean_summary(content)
|
|
270
409
|
if not summary:
|
|
@@ -354,6 +493,8 @@ def is_fatal_error(exc: BaseException) -> bool:
|
|
|
354
493
|
"""True for errors that will repeat for every session (bad credentials,
|
|
355
494
|
unreachable server, unknown model), so the run should stop instead of
|
|
356
495
|
failing once per session."""
|
|
496
|
+
if isinstance(exc, FatalBackendError):
|
|
497
|
+
return True
|
|
357
498
|
if isinstance(exc, httpx.ConnectError):
|
|
358
499
|
return True
|
|
359
500
|
if isinstance(exc, httpx.HTTPStatusError) and exc.response.status_code in (401, 403, 404):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spooling
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.19
|
|
4
4
|
Summary: Local session tracker and semantic search for AI coding assistants
|
|
5
5
|
Author: Parsed Analytics, Inc.
|
|
6
6
|
License: MIT
|
|
@@ -240,6 +240,8 @@ Some providers already supply a summary (Claude Code writes `summary` records).
|
|
|
240
240
|
| `openai` (default) | Any OpenAI-compatible endpoint: local [Ollama](https://ollama.com), OpenAI, OpenRouter, vLLM, LiteLLM | none for local; `SPOOLING_SUMMARY_API_KEY` for hosted |
|
|
241
241
|
| `anthropic` | The Anthropic API | `ANTHROPIC_API_KEY` |
|
|
242
242
|
| `bedrock` | AWS Bedrock (Converse API). Uses `boto3`, which Spooling already installs | `AWS_BEARER_TOKEN_BEDROCK` (Bedrock API key; needs a recent `boto3`) or any normal AWS credentials, plus `AWS_REGION` |
|
|
243
|
+
| `claude-code` | Reuse your Claude Code login (runs `claude -p`), here or on another machine with `--ssh` | whatever Claude Code is signed in with |
|
|
244
|
+
| `opencode` | Reuse opencode's providers (runs `opencode run`), here or over `--ssh` | whatever opencode is configured with |
|
|
243
245
|
|
|
244
246
|
The default is a local Ollama daemon, so nothing leaves your machine. Any other backend sends redacted transcripts to a third party, so Spooling asks for confirmation first (skip with `--yes`).
|
|
245
247
|
|
|
@@ -252,17 +254,47 @@ spooling summarize --base-url https://api.openai.com/v1 --model gpt-4o-mini
|
|
|
252
254
|
spooling summarize --backend anthropic # defaults to claude-haiku-4-5
|
|
253
255
|
spooling summarize --backend bedrock --region us-east-2 \
|
|
254
256
|
--model us.anthropic.claude-haiku-4-5-20251001-v1:0
|
|
257
|
+
|
|
258
|
+
spooling summarize --backend claude-code # uses your Claude Code login
|
|
259
|
+
spooling summarize --backend claude-code --ssh my-other-mac
|
|
260
|
+
spooling summarize --backend opencode --model amazon-bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0
|
|
255
261
|
```
|
|
256
262
|
|
|
257
263
|
- `-p, --project`, `--provider`, `-d, --days`, `-n, --limit` - choose which sessions
|
|
258
264
|
- `--min-messages` - skip very short sessions (default 4)
|
|
259
|
-
- `--backend` - `openai`, `anthropic` or `
|
|
265
|
+
- `--backend` - `openai`, `anthropic`, `bedrock`, `claude-code` or `opencode` (or set `SPOOLING_SUMMARY_BACKEND`)
|
|
260
266
|
- `--model` - model name or id (or set `SPOOLING_SUMMARY_MODEL`). Defaults to `qwen2.5:7b` for `openai` and `claude-haiku-4-5` for `anthropic`; `bedrock` requires one, because Bedrock ids differ by region and account (use an inference profile id such as `us.anthropic.claude-haiku-4-5-20251001-v1:0`)
|
|
261
267
|
- `--base-url` - endpoint for the `openai` backend (or `SPOOLING_SUMMARY_BASE_URL`; default `http://localhost:11434/v1`)
|
|
262
268
|
- `--region` - AWS region for `bedrock` (default `AWS_REGION`)
|
|
269
|
+
- `--ssh HOST` - run the `claude-code` or `opencode` backend on another machine over SSH (for example a Mac where Claude Code is signed in). Needs key-based SSH login; the redacted transcript is piped over the connection
|
|
270
|
+
- `--cli-cmd` - the command to run if it isn't on `PATH`, such as `~/.local/bin/claude`. With `--ssh`, this is the path on the remote machine
|
|
263
271
|
- `--force` - regenerate even if a summary exists
|
|
264
272
|
- `-y, --yes` - don't ask before sending text to a non-local endpoint
|
|
265
273
|
|
|
274
|
+
#### Summarize one session
|
|
275
|
+
|
|
276
|
+
Name the session by its id (or any unique prefix) and pick the backend:
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
spooling session list --title login # find the id first
|
|
280
|
+
spooling summarize ses_e6310bd1 --backend claude-code
|
|
281
|
+
spooling summarize ses_e6310bd1 --backend claude-code --ssh my-other-mac
|
|
282
|
+
spooling session show ses_e6310bd1 # read it back
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
- If the session already has a summary, nothing runs. Add `--force` to replace it, including a summary the provider wrote.
|
|
286
|
+
- Naming a session skips the `--min-messages` filter, so short sessions work too. You can name several: `spooling summarize ID1 ID2 --backend claude-code`.
|
|
287
|
+
- `--dry-run` shows what would run without calling a model, and `-y` skips the confirmation prompt.
|
|
288
|
+
- To avoid typing the backend each time, `export SPOOLING_SUMMARY_BACKEND=claude-code`. There is no environment variable for `--ssh`.
|
|
289
|
+
|
|
290
|
+
#### Using Claude Code or opencode
|
|
291
|
+
|
|
292
|
+
The `claude-code` and `opencode` backends run the agent's headless mode and send the prompt on stdin, so there is no API key to set up: they use whatever login the agent already has. Both send the redacted transcript to that agent's provider, so Spooling asks for confirmation first.
|
|
293
|
+
|
|
294
|
+
- Leave `--model` off to use the agent's default model. For opencode, the model is `provider/model`, and your configured default may be an old model id, so pass one explicitly if you see an error.
|
|
295
|
+
- With `--ssh`, the agent runs from `/tmp` on the remote machine, so it doesn't pick up a project's rules. SSH runs non-interactively and often skips your shell profile, so if you get "not found", use `--cli-cmd` with the full path.
|
|
296
|
+
- `claude -p` records each run as a session in that machine's Claude Code history. They are tagged with a `spooling-summary:` prefix, and `spooling summarize` skips them. The opencode backend deletes its run's session automatically.
|
|
297
|
+
|
|
266
298
|
The run stops early on errors that would repeat for every session (bad credentials, an unreachable server, an unknown model). A summary Spooling generated is refreshed on the next run once the session has grown; `session show` tells you when that is the case.
|
|
267
299
|
|
|
268
300
|
### `spooling optimize`
|
|
@@ -455,6 +487,21 @@ spooling push --dry-run # show what would be pushed
|
|
|
455
487
|
|
|
456
488
|
`push` ingests new provider sessions into the local database before uploading, so you don't need to run `spooling sync` first. The server upserts by session id, so re-running is safe.
|
|
457
489
|
|
|
490
|
+
#### When a Free workspace is full
|
|
491
|
+
|
|
492
|
+
The Free plan caps each workspace (500 sessions, 100,000 messages, 5,000 traces). When a push would go past a cap the server answers
|
|
493
|
+
`402`, and `spooling push` stops with a clear message and a non-zero exit code:
|
|
494
|
+
|
|
495
|
+
```
|
|
496
|
+
Free plan limit reached: this workspace can't take more on the Free plan.
|
|
497
|
+
The Free plan allows 500 sessions per workspace. Delete old ones with `spooling cloud delete`, or upgrade at https://app.spooling.ai/settings?tab=billing
|
|
498
|
+
Nothing already pushed was removed; the rest of this push was not sent.
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
Nothing you have already pushed is removed, and sessions already in the workspace can still be updated by a batch that adds no new
|
|
502
|
+
ones. Free space with `spooling cloud delete`, or upgrade from the link. `spooling cloud watch` shows the message once and then a
|
|
503
|
+
short "still at the Free plan limit" line each cycle, and carries on automatically once there is room.
|
|
504
|
+
|
|
458
505
|
### Push only some sessions, or to a specific team
|
|
459
506
|
|
|
460
507
|
**Which team gets the sessions** is decided by the API key you are logged in with. Each key belongs to one workspace (personal or a team), and `spooling push` sends to that workspace. Mint a key for the team in the app, then log in with it:
|
|
@@ -28,7 +28,7 @@ class _Handler(BaseHTTPRequestHandler):
|
|
|
28
28
|
|
|
29
29
|
def _go(self):
|
|
30
30
|
type(self).seen.append(f"{self.command} {self.path}")
|
|
31
|
-
payload = json.dumps(type(self).body if type(self).status == 200 else {"detail": "nope"}).encode()
|
|
31
|
+
payload = json.dumps(type(self).body if type(self).status == 200 else getattr(type(self), "error_body", {"detail": "nope"})).encode()
|
|
32
32
|
self.send_response(type(self).status)
|
|
33
33
|
if type(self).status == 429:
|
|
34
34
|
self.send_header("Retry-After", "42")
|
|
@@ -194,6 +194,28 @@ def test_push_success_exits_zero(logged_in, server, monkeypatch):
|
|
|
194
194
|
assert "POST /v1/sessions/batch" in server.handler.seen
|
|
195
195
|
|
|
196
196
|
|
|
197
|
+
FULL = {"detail": "The Free plan allows 500 sessions per workspace. Delete old ones with `spooling cloud delete`, or upgrade at https://app.spooling.ai/settings?tab=billing"}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def test_a_full_free_workspace_gets_a_clear_message_and_a_nonzero_exit(logged_in, server, monkeypatch):
|
|
201
|
+
server.handler.status, server.handler.error_body = 402, FULL
|
|
202
|
+
logged_in(server.url)
|
|
203
|
+
monkeypatch.setattr(cloud, "_collect_sessions", lambda **k: one_session())
|
|
204
|
+
r = run("push", "--no-sync")
|
|
205
|
+
assert r.exit_code == 1 and "Done." not in r.output
|
|
206
|
+
assert cloud.PLAN_LIMIT in r.output
|
|
207
|
+
assert "settings?tab=billing" in r.output and "spooling cloud delete" in r.output # the server's own words, not raw JSON
|
|
208
|
+
assert "Nothing already pushed was removed" in r.output
|
|
209
|
+
assert '{"detail"' not in r.output
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def test_a_402_without_json_still_explains_itself():
|
|
213
|
+
req = httpx.Request("POST", "http://x/v1/sessions/batch")
|
|
214
|
+
e = httpx.HTTPStatusError("402", request=req, response=httpx.Response(402, text="<html>Payment Required</html>", request=req))
|
|
215
|
+
msg = cloud._explain_http(e)
|
|
216
|
+
assert msg.startswith(cloud.PLAN_LIMIT) and "Payment Required" in msg
|
|
217
|
+
|
|
218
|
+
|
|
197
219
|
@pytest.mark.parametrize("status", [401, 500])
|
|
198
220
|
def test_push_server_error_exits_nonzero(logged_in, server, monkeypatch, status):
|
|
199
221
|
server.handler.status = status
|
|
@@ -44,7 +44,7 @@ def test_summarize_is_documented_and_has_documented_options():
|
|
|
44
44
|
from pathlib import Path
|
|
45
45
|
readme = (Path(__file__).resolve().parent.parent / "README.md").read_text()
|
|
46
46
|
out = _help("summarize")
|
|
47
|
-
for opt in ("--dry-run", "--force", "--backend", "--model", "--base-url", "--region", "--days", "--limit", "--min-messages", "--yes"):
|
|
47
|
+
for opt in ("--dry-run", "--force", "--backend", "--model", "--base-url", "--region", "--ssh", "--cli-cmd", "--days", "--limit", "--min-messages", "--yes"):
|
|
48
48
|
assert opt in out
|
|
49
49
|
assert opt in readme, f"README does not mention {opt}"
|
|
50
50
|
assert "--summaries" in _help("session", "list")
|
|
@@ -468,3 +468,173 @@ def test_bedrock_client_honors_aws_region_env(monkeypatch):
|
|
|
468
468
|
sm._bedrock_client("eu-west-1") # explicit region wins
|
|
469
469
|
assert seen["region_name"] == "eu-west-1"
|
|
470
470
|
sm._bedrock_client.cache_clear()
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
# --- claude-code / opencode (shell out to an agent's headless mode) ----------
|
|
474
|
+
|
|
475
|
+
import os
|
|
476
|
+
import stat
|
|
477
|
+
import subprocess
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
def _fake_exe(tmp_path, name, body):
|
|
481
|
+
p = tmp_path / name
|
|
482
|
+
p.write_text("#!/bin/sh\n" + body)
|
|
483
|
+
p.chmod(p.stat().st_mode | stat.S_IEXEC)
|
|
484
|
+
return str(p)
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def test_claude_code_backend_pipes_prompt_on_stdin(tmp_path):
|
|
488
|
+
exe = _fake_exe(tmp_path, "claude",
|
|
489
|
+
'echo "ARGS: $*" >&2; echo "CWD: $(pwd)" >&2; cat > "$0.stdin"; echo "Claude says hi."')
|
|
490
|
+
out = sm.generate_summary("[user] fix the bug", backend="claude-code", model="haiku", cli_cmd=exe)
|
|
491
|
+
assert out == "Claude says hi."
|
|
492
|
+
stdin = (tmp_path / "claude.stdin").read_text()
|
|
493
|
+
assert stdin.startswith(sm.RUN_MARKER) # marker so the run is recognizable
|
|
494
|
+
assert "[user] fix the bug" in stdin # transcript went via stdin, not argv
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
def test_claude_code_args_and_model_flag(monkeypatch):
|
|
498
|
+
seen = {}
|
|
499
|
+
|
|
500
|
+
def fake_run(argv, **kw):
|
|
501
|
+
seen.update(argv=argv, **kw)
|
|
502
|
+
return subprocess.CompletedProcess(argv, 0, stdout="ok\n", stderr="")
|
|
503
|
+
monkeypatch.setattr(sm.subprocess, "run", fake_run)
|
|
504
|
+
|
|
505
|
+
sm.generate_summary("t", backend="claude-code", model="haiku")
|
|
506
|
+
assert seen["argv"] == ["claude", "-p", "--model", "haiku"]
|
|
507
|
+
assert seen["cwd"] # not the user's project dir
|
|
508
|
+
assert "t" in seen["input"]
|
|
509
|
+
|
|
510
|
+
sm.generate_summary("t", backend="claude-code") # no model -> agent's own default
|
|
511
|
+
assert seen["argv"] == ["claude", "-p"]
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
def test_ssh_wraps_command_and_pipes_stdin(monkeypatch):
|
|
515
|
+
seen = {}
|
|
516
|
+
|
|
517
|
+
def fake_run(argv, **kw):
|
|
518
|
+
seen.update(argv=argv, **kw)
|
|
519
|
+
return subprocess.CompletedProcess(argv, 0, stdout="remote ok", stderr="")
|
|
520
|
+
monkeypatch.setattr(sm.subprocess, "run", fake_run)
|
|
521
|
+
|
|
522
|
+
out = sm.generate_summary("[user] hi", backend="claude-code", ssh="me@other-mac",
|
|
523
|
+
cli_cmd="/opt/homebrew/bin/claude", model="sonnet")
|
|
524
|
+
assert out == "remote ok"
|
|
525
|
+
argv = seen["argv"]
|
|
526
|
+
assert argv[:4] == ["ssh", "-o", "BatchMode=yes", "-o"]
|
|
527
|
+
assert "me@other-mac" in argv
|
|
528
|
+
remote = argv[-1]
|
|
529
|
+
assert remote.startswith("cd /tmp")
|
|
530
|
+
assert "/opt/homebrew/bin/claude -p --model sonnet" in remote
|
|
531
|
+
assert "[user] hi" not in remote and "[user] hi" in seen["input"] # transcript is not in argv
|
|
532
|
+
assert seen["cwd"] is None
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
def test_ssh_rejects_option_injection():
|
|
536
|
+
with pytest.raises(sm.FatalBackendError, match="invalid ssh host"):
|
|
537
|
+
sm.generate_summary("t", backend="claude-code", ssh="-oProxyCommand=evil")
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
def test_missing_executable_is_fatal(tmp_path):
|
|
541
|
+
with pytest.raises(sm.FatalBackendError, match="not found"):
|
|
542
|
+
sm.generate_summary("t", backend="claude-code", cli_cmd=str(tmp_path / "nope"))
|
|
543
|
+
assert sm.is_fatal_error(sm.FatalBackendError("x"))
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
@pytest.mark.parametrize("code,stderr,fatal,match", [
|
|
547
|
+
(255, "ssh: connect to host x port 22: Connection refused", True, "ssh to h failed"),
|
|
548
|
+
(127, "sh: claude: command not found", True, "not found on h"),
|
|
549
|
+
(1, "Please login first", True, "sign in"),
|
|
550
|
+
(1, "something transient", False, "exited 1"),
|
|
551
|
+
])
|
|
552
|
+
def test_cli_backend_failure_modes(monkeypatch, code, stderr, fatal, match):
|
|
553
|
+
monkeypatch.setattr(sm.subprocess, "run",
|
|
554
|
+
lambda argv, **kw: subprocess.CompletedProcess(argv, code, stdout="", stderr=stderr))
|
|
555
|
+
with pytest.raises(Exception, match=match) as ei:
|
|
556
|
+
sm.generate_summary("t", backend="claude-code", ssh="h")
|
|
557
|
+
assert sm.is_fatal_error(ei.value) is fatal
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
def test_cli_output_ansi_is_stripped(tmp_path):
|
|
561
|
+
exe = _fake_exe(tmp_path, "claude", r'printf "\033[1mBold summary.\033[0m\n"')
|
|
562
|
+
assert sm.generate_summary("t", backend="claude-code", cli_cmd=exe) == "Bold summary."
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
def test_opencode_parses_json_events_and_deletes_its_session(monkeypatch):
|
|
566
|
+
events = "\n".join(json.dumps(e) for e in [
|
|
567
|
+
{"type": "step_start", "sessionID": "ses_abc123", "part": {"type": "step-start"}},
|
|
568
|
+
{"type": "text", "sessionID": "ses_abc123", "part": {"type": "text", "text": "It fixed the login."}},
|
|
569
|
+
{"type": "step_finish", "sessionID": "ses_abc123", "part": {"type": "step-finish"}},
|
|
570
|
+
])
|
|
571
|
+
calls = []
|
|
572
|
+
|
|
573
|
+
def fake_run(argv, **kw):
|
|
574
|
+
calls.append(argv)
|
|
575
|
+
return subprocess.CompletedProcess(argv, 0, stdout=events if "run" in argv else "", stderr="")
|
|
576
|
+
monkeypatch.setattr(sm.subprocess, "run", fake_run)
|
|
577
|
+
|
|
578
|
+
out = sm.generate_summary("t", backend="opencode", model="amazon-bedrock/m")
|
|
579
|
+
assert out == "It fixed the login."
|
|
580
|
+
assert calls[0] == ["opencode", "run", "--format", "json", "-m", "amazon-bedrock/m"]
|
|
581
|
+
assert calls[1] == ["opencode", "session", "delete", "ses_abc123"] # no leftover history
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
def test_opencode_cleanup_failure_does_not_lose_the_summary(monkeypatch):
|
|
585
|
+
events = json.dumps({"type": "text", "sessionID": "ses_x", "part": {"type": "text", "text": "Done."}})
|
|
586
|
+
|
|
587
|
+
def fake_run(argv, **kw):
|
|
588
|
+
if "delete" in argv:
|
|
589
|
+
raise OSError("boom")
|
|
590
|
+
return subprocess.CompletedProcess(argv, 0, stdout=events, stderr="")
|
|
591
|
+
monkeypatch.setattr(sm.subprocess, "run", fake_run)
|
|
592
|
+
assert sm.generate_summary("t", backend="opencode") == "Done."
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
def test_opencode_never_runs_delete_on_a_weird_session_id(monkeypatch):
|
|
596
|
+
events = json.dumps({"type": "text", "sessionID": "x; rm -rf ~", "part": {"type": "text", "text": "ok"}})
|
|
597
|
+
calls = []
|
|
598
|
+
monkeypatch.setattr(sm.subprocess, "run",
|
|
599
|
+
lambda argv, **kw: calls.append(argv) or subprocess.CompletedProcess(argv, 0, stdout=events, stderr=""))
|
|
600
|
+
sm.generate_summary("t", backend="opencode")
|
|
601
|
+
assert len(calls) == 1 # only the run, no delete
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
def test_agent_backends_are_not_local():
|
|
605
|
+
assert not sm.is_local_backend("claude-code", "http://localhost:11434/v1")
|
|
606
|
+
assert not sm.is_local_backend("opencode", "http://localhost:11434/v1")
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
def test_ollama_404_explains_how_to_fix_it():
|
|
610
|
+
c = _client(lambda r: httpx.Response(404, json={"error": "model not found"}))
|
|
611
|
+
with pytest.raises(sm.FatalBackendError, match="ollama pull qwen2.5:7b"):
|
|
612
|
+
sm.generate_summary("t", client=c)
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
def test_cli_ssh_requires_an_agent_backend(conn):
|
|
616
|
+
res = CliRunner().invoke(cli, ["summarize", "--ssh", "host", "--dry-run"])
|
|
617
|
+
assert res.exit_code != 0 and "only apply" in res.output
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
def test_cli_passes_ssh_and_cmd_through(conn, monkeypatch):
|
|
621
|
+
add_session(conn, "ses_hhhh000001", n_msgs=6)
|
|
622
|
+
seen = {}
|
|
623
|
+
monkeypatch.setattr(sm, "generate_summary", lambda t, **k: seen.update(k) or "ok")
|
|
624
|
+
res = CliRunner().invoke(cli, ["summarize", "--backend", "claude-code", "--ssh", "my-mac",
|
|
625
|
+
"--cli-cmd", "/x/claude", "-y"])
|
|
626
|
+
assert res.exit_code == 0, res.output
|
|
627
|
+
assert seen["ssh"] == "my-mac" and seen["cli_cmd"] == "/x/claude" and seen["backend"] == "claude-code"
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
def test_cli_skips_its_own_summarizer_runs(conn, monkeypatch):
|
|
631
|
+
# An agent's history contains the summarizer's own runs; don't summarize those.
|
|
632
|
+
sid = "ses_iiii000001"
|
|
633
|
+
add_session(conn, sid, n_msgs=6)
|
|
634
|
+
conn.execute("UPDATE messages SET content = ? WHERE id = ?", (f"{sm.RUN_MARKER} You summarize...", f"{sid}-0"))
|
|
635
|
+
conn.commit()
|
|
636
|
+
called = []
|
|
637
|
+
monkeypatch.setattr(sm, "generate_summary", lambda t, **k: called.append(1) or "x")
|
|
638
|
+
res = CliRunner().invoke(cli, ["summarize", "--backend", "claude-code", "-y"])
|
|
639
|
+
assert res.exit_code == 0, res.output
|
|
640
|
+
assert not called and "summarizer run" in res.output
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|