Skip to content

Commit 5225ab5

Browse files
Slokhjxom
andauthored
feat: add pluggable friction stores (#75)
* Add pluggable friction stores * Expose stored occurrence counts * Respect PostgreSQL search paths * Configure CLI friction stores * Simplify Postgres store setup * Format CLI store configuration * Resolve pnpm toolchain friction * Harden pluggable store boundaries * refactor: align pluggable stores * test: use postgres testcontainers * refactor: group postgres options * test: namespace postgres fixture * fix: resolve store review feedback * feat: accept postgres connection strings * feat: use postgres.js for stores * fix: preserve store edge cases * feat: migrate stores through frog * docs: describe database store roadmap * docs: add d1 store roadmap * docs: reorder database store guide * fix: guard store parsing boundaries * docs: simplify database setup * docs: trim database usage * docs: reorder database storage --------- Co-authored-by: jxom <7336481+jxom@users.noreply.github.com>
1 parent 94ed2a8 commit 5225ab5

36 files changed

Lines changed: 2815 additions & 72 deletions

.changeset/calm-frogs-store.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'frog': minor
3+
---
4+
5+
Added pluggable friction stores, a Postgres.js-backed `Store.postgres({ connectionString })` factory, and the `Frog.create` logging API.
6+
7+
```ts
8+
import { Frog, Store } from 'frog'
9+
10+
const store = Store.postgres({ connectionString: process.env.DATABASE_URL! })
11+
const frog = Frog.create({ store })
12+
await frog.log({
13+
body: 'The workaround used.',
14+
severity: 'minor',
15+
title: 'Tool required a workaround',
16+
})
17+
const logs = await frog.logs()
18+
await store.close()
19+
```

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,26 @@ Accept friction reported by other repositories with `.agents/friction-log/config
213213
`frog init` enables inbound reports by default. Run `frog init --no-inbound` to initialize without
214214
accepting inbound reports.
215215

216+
### Store Logs in a Database
217+
218+
Frog separates friction logging from persistence, so agents and applications can record and inspect
219+
logs through one API while choosing where they live. Repository files are the default, PostgreSQL is
220+
supported today, and SQLite and Cloudflare D1 are planned.
221+
222+
```sh
223+
export FROG_DATABASE_URL=postgres://...
224+
frog migrate
225+
frog list
226+
```
227+
228+
#### Database Support
229+
230+
| Database | Status | Factory |
231+
| ------------- | ----------- | -------------------------------------- |
232+
| PostgreSQL | Available | `Store.postgres({ connectionString })` |
233+
| SQLite | Coming soon ||
234+
| Cloudflare D1 | Coming soon ||
235+
216236
## CLI Reference
217237

218238
```
@@ -224,7 +244,9 @@ Commands:
224244
init Create the friction log, config, and issue form.
225245
list List entries with their state.
226246
log Write a friction entry.
247+
migrate Create or upgrade the selected store.
227248
publish Report pending entries as GitHub issues.
249+
resolve Remove one resolved friction entry.
228250
sync Reconcile entries against issue state.
229251
targets List dependencies that accept friction reports.
230252

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"devDependencies": {
1515
"@changesets/cli": "catalog:",
16+
"@testcontainers/postgresql": "catalog:",
1617
"@types/node": "catalog:",
1718
"@vitest/coverage-v8": "catalog:",
1819
"tsx": "catalog:",
@@ -62,6 +63,7 @@
6263
"@clack/prompts": "catalog:",
6364
"@octokit/rest": "catalog:",
6465
"incur": "catalog:",
66+
"postgres": "catalog:",
6567
"yaml": "catalog:"
6668
},
6769
"engines": {

0 commit comments

Comments
 (0)