feat: append-only version history + bliss CLI ergonomics
Snapshot the code-bearing fields of routes (verb/path/handler), templates (name/content/test_object), and db libraries (name/library) on every content-changing save, so nothing edited is ever lost. Recorded in a new `versions` table via recordVersion() hooked into the create/update functions in db.js (the single write choke point), deduped against the latest snapshot so no-op saves, error-flag-only route writes, and server-restart WS re-bootstraps don't pile up. The live row stays current; old snapshots are the undo trail. Read-only, no revert UI yet. - migrations/004_add_versions.sql: versions table + indexes - db.js: recordVersion/getVersions/getVersion + create/update hooks - plumbing.js: /versions/:id and per-entity .../versions list endpoints - bliss: `versions <type> <sid> <id>` and `version <id>` reads; `update-settings` (edit route_prefix/head_injection, preserving the untouched field); `use <url>` sticky target persisted to ~/.bliss/target so BLISS_URL needn't be re-exported each call - client.js: target-file precedence (BLISS_URL > ~/.bliss/target > localhost) - SKILL.md: document the above Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
03a9d2143d
commit
42f4aacf7c
6 changed files with 211 additions and 7 deletions
|
|
@ -23,6 +23,15 @@ It logs in once and caches the session cookie under `~/.bliss/`, re-logging-in
|
|||
automatically when it expires. Run it as `node bliss-cli/bliss <command>` (or
|
||||
`./bliss-cli/bliss` if on PATH).
|
||||
|
||||
Instead of re-exporting `BLISS_URL` every time, set a **sticky target** once —
|
||||
it persists to `~/.bliss/target` and is used until you change it (a `BLISS_URL`
|
||||
env var still overrides it when set):
|
||||
|
||||
```bash
|
||||
bliss use https://your-instance.example.com # set the target instance
|
||||
bliss use # print the current target
|
||||
```
|
||||
|
||||
## The model (what you're editing)
|
||||
|
||||
A **Structure** is a mini web app. It has **routes** (a VERB + path + a JS
|
||||
|
|
@ -42,14 +51,34 @@ bliss template <sid> <tid> # one template incl. content + test_objec
|
|||
bliss db <sid> <dbid> # one db incl. its library source
|
||||
bliss files <sid> # files attached to a structure
|
||||
bliss logs <sid> <rid> [--since <id>] # route logs (console.log output + errors)
|
||||
|
||||
bliss versions <route|template|db> <sid> <id> # save history (newest first)
|
||||
bliss version <versionId> # one version incl. full snapshot
|
||||
```
|
||||
|
||||
All emit JSON, so: `bliss structure 3 | jq '.routes[].path'`.
|
||||
|
||||
## Version history (undo trail)
|
||||
|
||||
Every content-changing save of a route handler, template, or db library records
|
||||
an append-only snapshot. The live row is always the current version; old ones
|
||||
are kept so nothing edited is ever lost. `versions` lists the summaries (id,
|
||||
`created_at`, `bytes`) newest-first; `version <id>` returns the full snapshot
|
||||
(the versioned fields). No-op re-saves are deduped, so identical content doesn't
|
||||
pile up. There's no revert command yet — to roll back, fetch an old snapshot and
|
||||
re-`update-*` its content:
|
||||
|
||||
```bash
|
||||
bliss versions route 3 12 # what saves exist
|
||||
bliss version 24 | jq -r .snapshot.handler > /tmp/old.js
|
||||
bliss update-route 3 12 --handler-file /tmp/old.js # restore it as a new save
|
||||
```
|
||||
|
||||
## Writes
|
||||
|
||||
```bash
|
||||
bliss create-structure "<name>" # -> {location, id}
|
||||
bliss update-settings <sid> [--route-prefix <p>] [--head-injection <s>|--head-injection-file <f>]
|
||||
bliss clone <sid> --name "<n>" --prefix /p [--clone-dbs]
|
||||
|
||||
bliss create-route <sid> <VERB> <path> # VERB: GET|POST|PUT|DELETE|WS ; -> {id}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue