Skip to content

pa-db-prune

by rob

Data

Remove old or low-importance messages from SQLite database. Deletes messages based on age, importance score, or total count criteria. Returns deleted message IDs and count.

# pa-db-prune

Remove old or low-importance messages from SQLite database. Deletes messages based on age, importance score, or total count criteria. Returns deleted message IDs and count.

## Installation

This is a CmdForge tool. It should be installed in your CmdForge tools directory (`~/.cmdforge/pa-db-prune/`) with a wrapper script in `~/.local/bin/`.

## Usage

This tool accepts input via pipe and processes it according to the specified criteria:

```bash
# Dry run to see what would be deleted
echo '{"max_age_days": 30, "min_importance": 0.5}' | pa-db-prune --db-path ~/.pa2/data/pa2.db --dry-run true

# Actually delete old messages
echo '{"max_age_days": 90}' | pa-db-prune --db-path ~/.pa2/data/pa2.db

# Delete low-importance messages
echo '{"min_importance": 0.3, "max_count": 1000}' | pa-db-prune --db-path ~/.pa2/data/pa2.db
```

## Arguments

| Flag | Default | Description |
|------|---------|-------------|
| `--db-path` | _(required)_ | Path to SQLite database file (required) |
| `--dry-run` | `false` | If true, return what would be deleted without deleting |

## How It Works

The tool executes a single-step pipeline:

1. **prune_database** (code) - Connects to the SQLite database and removes messages matching the deletion criteria provided via stdin. Criteria can include maximum age in days, minimum importance score, or maximum total count. Returns a JSON object containing the IDs of deleted messages and the total count.

The tool preserves messages that don't match the deletion criteria and optionally performs a dry run to preview what would be deleted.

## Dependencies

None

No reviews yet.

Issues

No issues reported for this tool.