Timeline Cleanup
Delete low-value timeline messages by pattern, with attachment protection by default.
Default chat scope:
- if
chatJid is omitted, the cleanup targets web:default
- for
web:* chats, the helper resolves the full web session scope (root chat plus branches)
Usage
Cleanup is available both as an import and as a CLI.
Import
import { cleanupTimeline } from "/workspace/.pi/skills/timeline-cleanup/cleanup.ts";
const result = await cleanupTimeline({
patterns: ["reload", "compaction"],
// dryRun: true,
// includeMedia: false,
// vacuum: false,
// beforeRowid: 99999,
// chatJid: "web:default",
// maxLength: 300,
// senderFilter: "web-agent",
// throttleMs: 1100,
// retryOn429: true,
// maxRetries: 2,
});
CLI
bun run /workspace/.pi/skills/timeline-cleanup/cleanup.ts \
--patterns "reload,compaction,compacting" \
--before 5000 \
--dry-run
Result shape
cleanupTimeline() returns a CleanupResult shaped like:
{
matched: number,
skipped: number,
deleted: number,
failed: number,
dbSizeBefore: string,
dbSizeAfter: string
}
cleanupAll() returns a record of those per built-in pattern group.
Built-in pattern groups
Use cleanupAll() for a full housekeeping pass:
import { cleanupAll } from "/workspace/.pi/skills/timeline-cleanup/cleanup.ts";
const results = await cleanupAll({ beforeRowid: 5000, dryRun: true });
| Group |
Patterns |
Sender |
Max length |
| Reloads |
reload, supervisorctl restart, restart-piclaw, local-install, bun pm pack |
any |
500 |
| Compaction |
compaction, compacting, auto-compact |
any |
500 |
| Greetings (user) |
exact: hey, hello, hi, Hello?, hey there, etc. |
user |
30 |
| Agent intros |
Hey! ..., Hello! ..., good to see you, ready to help |
agent |
300 |
| Slash commands |
lines starting with / |
any |
50 |
| Slash responses |
Unknown command:, Current model:, Switched...model, Switching...model, Model switched, Cycle model, Cycle thinking, Thinking level, Thinking set, Supports thinking |
agent |
300 |
| One-word acks |
exact: yes, ok, go, done, well?, so?, etc. |
any |
30 |
| Transition filler |
let me check, let me look, now let me, etc. |
agent |
200 |
| Version bumps |
bumped version, tagged v0., bump patch |
any |
300 |
| Build/lint/test |
make lint, make test, bun run build, pass...0 fail |
any |
300 |
| Git operations |
git add, git commit -m, git push, git status |
any |
200 |
| Package installs |
bun install, bun add, bun update, packages installed |
any |
300 |
Behaviour
- delete operations are throttled by default (
1100ms) with optional retry on HTTP 429 responses
- media-bearing messages are skipped unless
--include-media is set
- vacuuming is optional and only makes sense after actual deletions
Vacuum
Vacuuming requires exclusive DB access. The helper can copy the DB to /tmp, vacuum the copy, swap it in, and restart piclaw briefly.
Environment
PICLAW_STORE — message DB parent directory (default /workspace/.piclaw/store)
PICLAW_WEB_PORT — web server port (default 8080)
PICLAW_INTERNAL_SECRET / PICLAW_WEB_INTERNAL_SECRET — internal API auth
Related
close-of-day uses the same cleanup strategy as part of end-of-day maintenance.
1---2name: timeline-cleanup3description: Delete low-value messages from the web timeline by keyword patterns. Protects messages with user-uploaded images. Optionally vacuums the DB afterward.4---56# Timeline Cleanup78Delete low-value timeline messages by pattern, with attachment protection by default.910Default chat scope:1112- if `chatJid` is omitted, the cleanup targets `web:default`13- for `web:*` chats, the helper resolves the **full web session scope** (root chat plus branches)1415## Usage1617Cleanup is available both as an import and as a CLI.1819### Import2021```typescript22import { cleanupTimeline } from "/workspace/.pi/skills/timeline-cleanup/cleanup.ts";2324const result = await cleanupTimeline({25 patterns: ["reload", "compaction"],26 // dryRun: true,27 // includeMedia: false,28 // vacuum: false,29 // beforeRowid: 99999,30 // chatJid: "web:default",31 // maxLength: 300,32 // senderFilter: "web-agent",33 // throttleMs: 1100,34 // retryOn429: true,35 // maxRetries: 2,36});37```3839### CLI4041```bash42bun run /workspace/.pi/skills/timeline-cleanup/cleanup.ts \43 --patterns "reload,compaction,compacting" \44 --before 5000 \45 --dry-run46```4748## Result shape4950`cleanupTimeline()` returns a `CleanupResult` shaped like:5152```ts53{54 matched: number,55 skipped: number,56 deleted: number,57 failed: number,58 dbSizeBefore: string,59 dbSizeAfter: string60}61```6263`cleanupAll()` returns a record of those per built-in pattern group.6465## Built-in pattern groups6667Use `cleanupAll()` for a full housekeeping pass:6869```typescript70import { cleanupAll } from "/workspace/.pi/skills/timeline-cleanup/cleanup.ts";71const results = await cleanupAll({ beforeRowid: 5000, dryRun: true });72```7374| Group | Patterns | Sender | Max length |75|---|---|---|---|76| **Reloads** | `reload`, `supervisorctl restart`, `restart-piclaw`, `local-install`, `bun pm pack` | any | 500 |77| **Compaction** | `compaction`, `compacting`, `auto-compact` | any | 500 |78| **Greetings (user)** | exact: `hey`, `hello`, `hi`, `Hello?`, `hey there`, etc. | user | 30 |79| **Agent intros** | `Hey! ...`, `Hello! ...`, `good to see you`, `ready to help` | agent | 300 |80| **Slash commands** | lines starting with `/` | any | 50 |81| **Slash responses** | `Unknown command:`, `Current model:`, `Switched...model`, `Switching...model`, `Model switched`, `Cycle model`, `Cycle thinking`, `Thinking level`, `Thinking set`, `Supports thinking` | agent | 300 |82| **One-word acks** | exact: `yes`, `ok`, `go`, `done`, `well?`, `so?`, etc. | any | 30 |83| **Transition filler** | `let me check`, `let me look`, `now let me`, etc. | agent | 200 |84| **Version bumps** | `bumped version`, `tagged v0.`, `bump patch` | any | 300 |85| **Build/lint/test** | `make lint`, `make test`, `bun run build`, `pass...0 fail` | any | 300 |86| **Git operations** | `git add`, `git commit -m`, `git push`, `git status` | any | 200 |87| **Package installs** | `bun install`, `bun add`, `bun update`, `packages installed` | any | 300 |8889## Behaviour9091- delete operations are throttled by default (`1100ms`) with optional retry on HTTP 429 responses92- media-bearing messages are skipped unless `--include-media` is set93- vacuuming is optional and only makes sense after actual deletions9495## Vacuum9697Vacuuming requires exclusive DB access. The helper can copy the DB to `/tmp`, vacuum the copy, swap it in, and restart piclaw briefly.9899## Environment100101- `PICLAW_STORE` — message DB parent directory (default `/workspace/.piclaw/store`)102- `PICLAW_WEB_PORT` — web server port (default `8080`)103- `PICLAW_INTERNAL_SECRET` / `PICLAW_WEB_INTERNAL_SECRET` — internal API auth104105## Related106107- `close-of-day` uses the same cleanup strategy as part of end-of-day maintenance.