@vibesdotdev/localdb 0.0.1
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.
- package/README.md +121 -0
- package/SPEC.md +119 -0
- package/dist/cli/commands/_shared.consumer.d.ts +5 -0
- package/dist/cli/commands/_shared.consumer.d.ts.map +1 -0
- package/dist/cli/commands/_shared.consumer.js +17 -0
- package/dist/cli/commands/_shared.consumer.js.map +1 -0
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.d.ts +19 -0
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.js +19 -0
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.d.ts +5 -0
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.js +80 -0
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.js.map +1 -0
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.d.ts +19 -0
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.js +16 -0
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.d.ts +5 -0
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.js +33 -0
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.js.map +1 -0
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.d.ts +15 -0
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.js +15 -0
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.d.ts +5 -0
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.js +28 -0
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.js.map +1 -0
- package/dist/cli/commands/query/dev.localdb.query.cli-command.descriptor.d.ts +24 -0
- package/dist/cli/commands/query/dev.localdb.query.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/query/dev.localdb.query.cli-command.descriptor.js +20 -0
- package/dist/cli/commands/query/dev.localdb.query.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.d.ts +5 -0
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.js +63 -0
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.js.map +1 -0
- package/dist/cli/commands/status/dev.localdb.status.cli-command.descriptor.d.ts +19 -0
- package/dist/cli/commands/status/dev.localdb.status.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/status/dev.localdb.status.cli-command.descriptor.js +19 -0
- package/dist/cli/commands/status/dev.localdb.status.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.d.ts +5 -0
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.js +73 -0
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.js.map +1 -0
- package/dist/core/connection-pool.d.ts +84 -0
- package/dist/core/connection-pool.d.ts.map +1 -0
- package/dist/core/connection-pool.js +191 -0
- package/dist/core/connection-pool.js.map +1 -0
- package/dist/core/database.d.ts +137 -0
- package/dist/core/database.d.ts.map +1 -0
- package/dist/core/database.js +347 -0
- package/dist/core/database.js.map +1 -0
- package/dist/core/error-context.d.ts +2 -0
- package/dist/core/error-context.d.ts.map +1 -0
- package/dist/core/error-context.js +17 -0
- package/dist/core/error-context.js.map +1 -0
- package/dist/core/migration-registry.d.ts +89 -0
- package/dist/core/migration-registry.d.ts.map +1 -0
- package/dist/core/migration-registry.js +226 -0
- package/dist/core/migration-registry.js.map +1 -0
- package/dist/core/runtime.d.ts +3 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +17 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/dev.localdb.cli-group.descriptor.d.ts +9 -0
- package/dist/dev.localdb.cli-group.descriptor.d.ts.map +1 -0
- package/dist/dev.localdb.cli-group.descriptor.js +17 -0
- package/dist/dev.localdb.cli-group.descriptor.js.map +1 -0
- package/dist/dev.localdb.context.descriptor.d.ts +21 -0
- package/dist/dev.localdb.context.descriptor.d.ts.map +1 -0
- package/dist/dev.localdb.context.descriptor.js +12 -0
- package/dist/dev.localdb.context.descriptor.js.map +1 -0
- package/dist/dev.localdb.context.impl.consumer.d.ts +9 -0
- package/dist/dev.localdb.context.impl.consumer.d.ts.map +1 -0
- package/dist/dev.localdb.context.impl.consumer.js +10 -0
- package/dist/dev.localdb.context.impl.consumer.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/localdb.cloud.plugin.d.ts +17 -0
- package/dist/localdb.cloud.plugin.d.ts.map +1 -0
- package/dist/localdb.cloud.plugin.js +23 -0
- package/dist/localdb.cloud.plugin.js.map +1 -0
- package/dist/localdb.plugin.d.ts +8 -0
- package/dist/localdb.plugin.d.ts.map +1 -0
- package/dist/localdb.plugin.js +38 -0
- package/dist/localdb.plugin.js.map +1 -0
- package/dist/migrations/load-sql.d.ts +45 -0
- package/dist/migrations/load-sql.d.ts.map +1 -0
- package/dist/migrations/load-sql.js +117 -0
- package/dist/migrations/load-sql.js.map +1 -0
- package/dist/schemas/api.d.ts +82 -0
- package/dist/schemas/api.d.ts.map +1 -0
- package/dist/schemas/api.js +2 -0
- package/dist/schemas/api.js.map +1 -0
- package/package.json +146 -0
- package/src/cli/commands/_shared.consumer.ts +20 -0
- package/src/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.ts +20 -0
- package/src/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.ts +97 -0
- package/src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.ts +17 -0
- package/src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.ts +46 -0
- package/src/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.ts +16 -0
- package/src/cli/commands/pools/dev.localdb.pools.cli-command.impl.ts +37 -0
- package/src/cli/commands/query/dev.localdb.query.cli-command.descriptor.ts +21 -0
- package/src/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.ts +69 -0
- package/src/cli/commands/status/dev.localdb.status.cli-command.descriptor.ts +20 -0
- package/src/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.ts +93 -0
- package/src/core/connection-pool.ts +240 -0
- package/src/core/database.ts +419 -0
- package/src/core/error-context.ts +19 -0
- package/src/core/migration-registry.ts +321 -0
- package/src/core/runtime.ts +17 -0
- package/src/dev.localdb.cli-group.descriptor.ts +20 -0
- package/src/dev.localdb.context.descriptor.ts +13 -0
- package/src/dev.localdb.context.impl.consumer.ts +12 -0
- package/src/index.ts +28 -0
- package/src/localdb.cloud.plugin.ts +24 -0
- package/src/localdb.plugin.ts +43 -0
- package/src/migrations/atlas/001-initial-schema.sql +173 -0
- package/src/migrations/atlas/002-lang-server-fields.sql +12 -0
- package/src/migrations/atlas/003-config-id-dedup.sql +31 -0
- package/src/migrations/atlas/004-fix-on-conflict-constraints.sql +25 -0
- package/src/migrations/atlas/005-diagnostics.sql +66 -0
- package/src/migrations/atlas/006-diagnostic-summaries.sql +65 -0
- package/src/migrations/atlas/007-diagnostic-slice.sql +83 -0
- package/src/migrations/load-sql.ts +133 -0
- package/src/schemas/api.ts +92 -0
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @vibesdotdev/localdb
|
|
2
|
+
|
|
3
|
+
Local SQLite primitive for the vibes consumer-hardware toolkit. Owns the
|
|
4
|
+
connection pool, namespace migration registry, recovery/trapdoor flow, and the
|
|
5
|
+
`vibes dev localdb` CLI surface. Backed by `bun:sqlite`; server-runtime only.
|
|
6
|
+
|
|
7
|
+
The contract lives in [`SPEC.md`](./SPEC.md). Operational status lives in
|
|
8
|
+
[`PROD-CHECKLIST.md`](./PROD-CHECKLIST.md). This README is the developer
|
|
9
|
+
quick-start.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Workspace-only:
|
|
14
|
+
|
|
15
|
+
```jsonc
|
|
16
|
+
// package.json
|
|
17
|
+
{
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@vibesdotdev/localdb": "workspace:*",
|
|
20
|
+
"@vibesdotdev/runtime": "workspace:*"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Register migrations and open a database
|
|
26
|
+
|
|
27
|
+
A domain module declares its migrations once and asks for its database by
|
|
28
|
+
namespace + path. Migrations run on first `getDatabase()` for that
|
|
29
|
+
`namespace:path`.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { localdb, type Migration } from '@vibesdotdev/localdb';
|
|
33
|
+
import type { Database } from 'bun:sqlite';
|
|
34
|
+
|
|
35
|
+
const MY_MIGRATIONS: Migration[] = [
|
|
36
|
+
{
|
|
37
|
+
version: 1,
|
|
38
|
+
name: 'Create things table',
|
|
39
|
+
up: (db: Database) => {
|
|
40
|
+
db.exec(`
|
|
41
|
+
CREATE TABLE IF NOT EXISTS things (
|
|
42
|
+
id TEXT PRIMARY KEY,
|
|
43
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
44
|
+
)
|
|
45
|
+
`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
localdb.registerMigrations('my-module', MY_MIGRATIONS);
|
|
51
|
+
|
|
52
|
+
const handle = await localdb.getDatabase(
|
|
53
|
+
'my-module',
|
|
54
|
+
'.vibes/my-module/state.db',
|
|
55
|
+
'my-module-storage'
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const db = handle.getDatabase();
|
|
59
|
+
db.query('INSERT INTO things (id) VALUES (?)').run('hello');
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Migration versions must be `1..N` consecutive — registering out of order
|
|
63
|
+
throws. Asking for an unregistered namespace throws. Migration failure
|
|
64
|
+
triggers automatic recovery: the corrupted file is backed up
|
|
65
|
+
(`*.bak-{ts}`, last 12 retained) and a fresh database is migrated from
|
|
66
|
+
version 0.
|
|
67
|
+
|
|
68
|
+
## Get a raw connection (no migrations)
|
|
69
|
+
|
|
70
|
+
For quick read-only tools or one-off scripts that don't need version
|
|
71
|
+
management, `getRawDatabase` returns a pooled `bun:sqlite.Database` directly:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { localdb } from '@vibesdotdev/localdb';
|
|
75
|
+
|
|
76
|
+
const raw = localdb.getRawDatabase('.vibes/scratch/log.db', 'log-reader');
|
|
77
|
+
const rows = raw.query('SELECT * FROM events ORDER BY ts DESC LIMIT 100').all();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This bypasses the migration registry. Prefer `getDatabase()` for any
|
|
81
|
+
schema-owning code.
|
|
82
|
+
|
|
83
|
+
## CLI
|
|
84
|
+
|
|
85
|
+
The package registers `vibes dev localdb` for inspecting state from a
|
|
86
|
+
terminal:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
vibes dev localdb status # connection + migration status across namespaces
|
|
90
|
+
vibes dev localdb namespaces # registered migration namespaces
|
|
91
|
+
vibes dev localdb pools # connection pool statistics
|
|
92
|
+
vibes dev localdb migrate <ns> # run pending migrations for a namespace
|
|
93
|
+
vibes dev localdb query <ns> # raw SQL against a namespace database
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Commands run on consumer hardware only.
|
|
97
|
+
|
|
98
|
+
## What lives where
|
|
99
|
+
|
|
100
|
+
- The `storage/adapter` impl `storage.localdb.core` →
|
|
101
|
+
[`@vibesdotdev/storage-adapter-localdb`](../storage-adapter-localdb/) (the
|
|
102
|
+
thin storage wrapper that consumes this package).
|
|
103
|
+
- App and feature schemas / migration SQL → the owning package or app.
|
|
104
|
+
This package owns the SQLite *primitive*; it does not carry domain SQL.
|
|
105
|
+
- Cloud / multi-tenant SQLite → use
|
|
106
|
+
[`@vibesdotdev/storage-adapter-drizzle`](../storage-adapter-drizzle/)
|
|
107
|
+
with libsql/Turso or D1.
|
|
108
|
+
|
|
109
|
+
## Verification
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
bun test packages/localdb
|
|
113
|
+
bun --bun tsc -p packages/localdb/tsconfig.json --noEmit
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Links
|
|
117
|
+
|
|
118
|
+
- [SPEC.md](./SPEC.md) — package contract.
|
|
119
|
+
- [storage](../storage/SPEC.md),
|
|
120
|
+
[storage-adapter-localdb](../storage-adapter-localdb/),
|
|
121
|
+
[storage-adapter-drizzle](../storage-adapter-drizzle/SPEC.md).
|
package/SPEC.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @vibesdotdev/localdb
|
|
2
|
+
|
|
3
|
+
Local SQLite primitive for the vibes consumer-hardware toolkit. Owns the
|
|
4
|
+
connection pool (one `bun:sqlite` `Database` per file path, WAL mode, busy
|
|
5
|
+
timeout, ref-counted, idle-cleanup), the namespace migration registry
|
|
6
|
+
(sequential-version enforcement, legacy `PRAGMA user_version` bootstrap,
|
|
7
|
+
`vibes_schema_versions` tracking table), the recovery/trapdoor flow (backup →
|
|
8
|
+
delete → recreate → re-migrate on migration failure or version mismatch), and
|
|
9
|
+
the `vibes dev localdb` CLI surface. Consumer hardware only — `bun:sqlite` is
|
|
10
|
+
server-runtime only. The storage adapter that wraps localdb lives in a sibling
|
|
11
|
+
adapter package, not here.
|
|
12
|
+
|
|
13
|
+
## Owns
|
|
14
|
+
|
|
15
|
+
- **Plugin descriptors registered by the plugin** (`./plugin`):
|
|
16
|
+
- `runtime/context` `dev/localdb` — server-side `LocaldbApi` access for
|
|
17
|
+
runtime callers.
|
|
18
|
+
- `cli/group` `dev.localdb` parented under `dev` — `vibes dev localdb`.
|
|
19
|
+
- `cli/command` `dev.localdb.{status,migrate,namespaces,pools,query}`.
|
|
20
|
+
- **Connection pool** (`./core/connection-pool`): per-path pooled `bun:sqlite`
|
|
21
|
+
`Database`, ref-counting, idle stale-cleanup (30 min), uniform PRAGMAs
|
|
22
|
+
(`journal_mode=WAL`, `busy_timeout=5000`, `foreign_keys=ON`,
|
|
23
|
+
`synchronous=NORMAL`, `temp_store=MEMORY`).
|
|
24
|
+
- **Migration registry** (`./core/migration-registry`): namespace-keyed
|
|
25
|
+
`Migration[]`, sequential `1..N` version enforcement,
|
|
26
|
+
`vibes_schema_versions` tracking, legacy `PRAGMA user_version` one-time
|
|
27
|
+
bootstrap, incompatible-database (version-too-high) detection.
|
|
28
|
+
- **`LocalDatabase` + `localdb` singleton manager** (`./core/database`):
|
|
29
|
+
per-`namespace:path` entry caching with per-`dbPath` async lock,
|
|
30
|
+
recovery/trapdoor on migration failure with retained backups (last 12),
|
|
31
|
+
`getRawDatabase()` for migration-free pooled access, `closeAll()` /
|
|
32
|
+
process-exit cleanup.
|
|
33
|
+
- **Public API types** (`./schemas`): `LocaldbApi`, `LocaldbRawDatabase`,
|
|
34
|
+
`LocaldbStatement`, `Migration`, `MigrationFunction`, `ConnectionStats`,
|
|
35
|
+
`ConnectionPoolApi`, `MigrationRegistryApi`.
|
|
36
|
+
|
|
37
|
+
## Does not own
|
|
38
|
+
|
|
39
|
+
- The `storage/adapter` impl `storage.localdb.core` →
|
|
40
|
+
[`storage-adapter-localdb`](../storage-adapter-localdb/SPEC.md). Per pattern
|
|
41
|
+
1, environment-specific storage adapters live in sibling packages; the
|
|
42
|
+
adapter is a thin `storage` consumer of `localdb`.
|
|
43
|
+
- Domain migration SQL → owning module:
|
|
44
|
+
- `atlas` schema → [`workspace`](../workspace/SPEC.md) (the only registrar,
|
|
45
|
+
via `packages/workspace/src/codegraph/storage/register-migrations.ts`).
|
|
46
|
+
- `pm-state` schema → [`pm`](../pm/SPEC.md) (already lives there; PM passes
|
|
47
|
+
its own dir as an absolute path to `loadMigrationSQLSync`).
|
|
48
|
+
- `external` `file_accesses` → [`external`](../external/SPEC.md) (already
|
|
49
|
+
inline-defined in `packages/external/src/register-migrations.ts`).
|
|
50
|
+
- `config` schema → [`cli`](../cli/SPEC.md) (its app-config storage
|
|
51
|
+
subsystem already declares the namespace).
|
|
52
|
+
- Cross-process / multi-tenant locking, replication, observability of pool
|
|
53
|
+
stats. Out of scope for the consumer-hardware floor; cloud storage uses
|
|
54
|
+
[`storage-adapter-drizzle`](../storage-adapter-drizzle/SPEC.md).
|
|
55
|
+
- A `runtime/client` descriptor or `getVibesLocaldbClient()`. LocalDB is a
|
|
56
|
+
runtime substrate consumed via the `localdb` singleton or the `dev/localdb`
|
|
57
|
+
context, not a domain module.
|
|
58
|
+
|
|
59
|
+
## Hard rules
|
|
60
|
+
|
|
61
|
+
- **`bun:sqlite`, server-runtime only.** All filesystem/SQLite imports are
|
|
62
|
+
dynamic and gated on `isLocaldbServerRuntime()`. `LocalDatabase.initialize()`
|
|
63
|
+
throws in browser bundles.
|
|
64
|
+
- **Sequential migration versions.** Registered migrations form `1..N` with
|
|
65
|
+
no gaps; out-of-sequence registration throws at `register()` time.
|
|
66
|
+
- **Unknown namespace = throw.** `needsMigration` / `runMigrations` /
|
|
67
|
+
`getDatabase` against an unregistered namespace is a hard failure (per
|
|
68
|
+
pattern 4); domain modules call
|
|
69
|
+
`localdb.registerMigrations(namespace, migrations)` before opening their
|
|
70
|
+
database.
|
|
71
|
+
- **Recovery is automatic and lossy.** Migration failure or
|
|
72
|
+
version-higher-than-registered triggers backup (`*.bak-{ts}`, last 12
|
|
73
|
+
retained) → delete file + WAL/SHM artifacts → fresh DB → re-run migrations
|
|
74
|
+
from version 0. Domain code must not rely on data surviving migration
|
|
75
|
+
failure.
|
|
76
|
+
- **One Database per file path.** All access goes through the pool; the
|
|
77
|
+
`usePool: false` direct-connection path stays for special cases but new
|
|
78
|
+
code uses the pool.
|
|
79
|
+
- **No domain SQL in this package.** Migration SQL files for a feature live
|
|
80
|
+
with that feature's package.
|
|
81
|
+
|
|
82
|
+
## Migration debt
|
|
83
|
+
|
|
84
|
+
All items completed in t11-mig-localdb-final-and-seal. See git history for original debt items.
|
|
85
|
+
|
|
86
|
+
## Public entrypoints
|
|
87
|
+
|
|
88
|
+
`.` — root exports (`localdb`, `LocalDatabase`, `Migration`, etc.)
|
|
89
|
+
`./plugin` — LocalDB plugin registration
|
|
90
|
+
`./schemas` — TypeScript type definitions (`LocaldbApi`, `Migration`, etc.)
|
|
91
|
+
|
|
92
|
+
Migration-era subpaths (`./core/*`, `./migrations/*`, `./localdb.plugin`) have been removed.
|
|
93
|
+
|
|
94
|
+
## Verification
|
|
95
|
+
|
|
96
|
+
`bun test` from `packages/localdb`. Covers `MigrationRegistry` (version
|
|
97
|
+
tracking, sequence validation, legacy-bootstrap, incompatible-version
|
|
98
|
+
detection), `ConnectionPool` (pooling, ref-count, stats), `LocalDatabase`
|
|
99
|
+
(init / idempotence / recovery / backup pruning), `localdb` manager
|
|
100
|
+
(namespace caching + per-path lock), and `loadMigrationSQL` file resolution.
|
|
101
|
+
Today (per `PROD-CHECKLIST.md` 2026-04-18): 79 pass / 0 fail.
|
|
102
|
+
|
|
103
|
+
## Links
|
|
104
|
+
|
|
105
|
+
- [storage/SPEC.md](../storage/SPEC.md),
|
|
106
|
+
[storage-adapter-localdb/SPEC.md](../storage-adapter-localdb/SPEC.md),
|
|
107
|
+
[storage-adapter-drizzle/SPEC.md](../storage-adapter-drizzle/SPEC.md),
|
|
108
|
+
[runtime/SPEC.md](../runtime/SPEC.md),
|
|
109
|
+
[cli/SPEC.md](../cli/SPEC.md),
|
|
110
|
+
[logging/SPEC.md](../logging/SPEC.md)
|
|
111
|
+
- Active consumers: [pm](../pm/SPEC.md), [workspace](../workspace/SPEC.md),
|
|
112
|
+
[external](../external/SPEC.md), [cli](../cli/SPEC.md),
|
|
113
|
+
[presence](../presence/SPEC.md), [prompts](../prompts/SPEC.md),
|
|
114
|
+
[experiments](../experiments/SPEC.md), [desktop](../desktop/SPEC.md),
|
|
115
|
+
[browser-automation](../browser-automation/SPEC.md),
|
|
116
|
+
[knowledge](../knowledge/SPEC.md), [setup](../setup/SPEC.md)
|
|
117
|
+
- Doctrine:
|
|
118
|
+
[RUNTIME-FIRST-MODULES.md](../../docs/architecture/RUNTIME-FIRST-MODULES.md),
|
|
119
|
+
[RUNTIME-SCOPE-TOPOLOGY.md](../../docs/architecture/RUNTIME-SCOPE-TOPOLOGY.md)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const databasePathsByNamespace: Record<string, string>;
|
|
2
|
+
export declare function resolveDatabasePathForNamespace(namespace: string): string | undefined;
|
|
3
|
+
export declare function resolveFromCwd(p: string): string;
|
|
4
|
+
export declare function formatAgeMs(ageMs: number): string;
|
|
5
|
+
//# sourceMappingURL=_shared.consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.consumer.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/_shared.consumer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAG3D,CAAC;AAEF,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErF;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIjD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
export const databasePathsByNamespace = {
|
|
3
|
+
atlas: '.vibes/atlas/vibes.db',
|
|
4
|
+
session: '.vibes/session/sessions.db'
|
|
5
|
+
};
|
|
6
|
+
export function resolveDatabasePathForNamespace(namespace) {
|
|
7
|
+
return databasePathsByNamespace[namespace];
|
|
8
|
+
}
|
|
9
|
+
export function resolveFromCwd(p) {
|
|
10
|
+
return resolve(process.cwd(), p);
|
|
11
|
+
}
|
|
12
|
+
export function formatAgeMs(ageMs) {
|
|
13
|
+
const ageMin = Math.floor(ageMs / 60000);
|
|
14
|
+
const ageSec = Math.floor((ageMs % 60000) / 1000);
|
|
15
|
+
return ageMin > 0 ? `${ageMin}m ${ageSec}s` : `${ageSec}s`;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=_shared.consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.consumer.js","sourceRoot":"","sources":["../../../src/cli/commands/_shared.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,MAAM,wBAAwB,GAA2B;IAC/D,KAAK,EAAE,uBAAuB;IAC9B,OAAO,EAAE,4BAA4B;CACrC,CAAC;AAEF,MAAM,UAAU,+BAA+B,CAAC,SAAiB;IAChE,OAAO,wBAAwB,CAAC,SAAS,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAS;IACvC,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAa;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IAClD,OAAO,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev LocalDB Migrate CLI Command Descriptor
|
|
3
|
+
*/
|
|
4
|
+
declare const _default: {
|
|
5
|
+
id: string;
|
|
6
|
+
kind: "cli/command";
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
group: string;
|
|
10
|
+
surfaces: string[];
|
|
11
|
+
hardware: string[];
|
|
12
|
+
enabled: true;
|
|
13
|
+
options: {
|
|
14
|
+
flags: string;
|
|
15
|
+
description: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=dev.localdb.migrate.cli-command.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.migrate.cli-command.descriptor.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;AAIH,wBAaG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev LocalDB Migrate CLI Command Descriptor
|
|
3
|
+
*/
|
|
4
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
5
|
+
export default createRuntimeAsset({
|
|
6
|
+
id: 'dev.localdb.migrate',
|
|
7
|
+
kind: 'cli/command',
|
|
8
|
+
name: 'migrate',
|
|
9
|
+
description: 'Run pending migrations',
|
|
10
|
+
group: 'dev.localdb',
|
|
11
|
+
surfaces: ['cli'],
|
|
12
|
+
hardware: ['consumer'],
|
|
13
|
+
enabled: true,
|
|
14
|
+
options: [
|
|
15
|
+
{ flags: '--namespace <name>', description: 'Run migrations for a specific namespace' },
|
|
16
|
+
{ flags: '--dry-run', description: 'Show pending migrations without applying them' }
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=dev.localdb.migrate.cli-command.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.migrate.cli-command.descriptor.js","sourceRoot":"","sources":["../../../../src/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAe,kBAAkB,CAAC;IACjC,EAAE,EAAE,qBAAqB;IACzB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,wBAAwB;IACrC,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,OAAO,EAAE,IAAI;IACb,OAAO,EAAE;QACR,EAAE,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,yCAAyC,EAAE;QACvF,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,+CAA+C,EAAE;KACpF;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.migrate.cli-command.impl.consumer.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.ts"],"names":[],"mappings":";mBAOsB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;;AAD5F,wBA0FE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
3
|
+
import { requestCLIExit } from '@vibesdotdev/cli/providers';
|
|
4
|
+
import { resolveDatabasePathForNamespace, resolveFromCwd } from '../_shared.consumer';
|
|
5
|
+
export default {
|
|
6
|
+
async execute(_args, opts) {
|
|
7
|
+
const runtime = getVibesRuntime();
|
|
8
|
+
const ui = (await runtime.context('cli/ui'));
|
|
9
|
+
const localdb = (await runtime.context('dev/localdb'));
|
|
10
|
+
const namespaceOpt = typeof opts.namespace === 'string' ? opts.namespace : undefined;
|
|
11
|
+
const dryRun = Boolean(opts.dryRun);
|
|
12
|
+
ui.log(`\n=== LocalDB Migrate${dryRun ? ' (Dry Run)' : ''} ===\n`);
|
|
13
|
+
const namespaces = localdb.listNamespaces();
|
|
14
|
+
if (namespaces.length === 0) {
|
|
15
|
+
ui.info('No migration namespaces registered.');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const namespacesToMigrate = namespaceOpt
|
|
19
|
+
? namespaces.filter((ns) => ns === namespaceOpt)
|
|
20
|
+
: namespaces;
|
|
21
|
+
if (namespacesToMigrate.length === 0) {
|
|
22
|
+
ui.error(`Namespace '${namespaceOpt}' not found.`);
|
|
23
|
+
ui.info(`Available namespaces: ${namespaces.join(', ')}`);
|
|
24
|
+
requestCLIExit(1);
|
|
25
|
+
}
|
|
26
|
+
const { migrationRegistry } = (await import('../../../core/migration-registry'));
|
|
27
|
+
let migratedCount = 0;
|
|
28
|
+
let errorCount = 0;
|
|
29
|
+
for (const ns of namespacesToMigrate) {
|
|
30
|
+
const dbPath = resolveDatabasePathForNamespace(ns);
|
|
31
|
+
if (!dbPath) {
|
|
32
|
+
ui.warn(`Skipping '${ns}': no known database path`);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const fullPath = resolveFromCwd(dbPath);
|
|
36
|
+
if (!existsSync(fullPath)) {
|
|
37
|
+
ui.warn(`Skipping '${ns}': database not found (${dbPath})`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
ui.log(`\nNamespace: ${ns}`);
|
|
41
|
+
ui.log(`Database: ${dbPath}`);
|
|
42
|
+
try {
|
|
43
|
+
const db = localdb.getRawDatabase(fullPath, 'localdb-migrate');
|
|
44
|
+
const needsMigration = migrationRegistry.needsMigration(db, ns);
|
|
45
|
+
if (!needsMigration) {
|
|
46
|
+
ui.success('Already up to date');
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const status = migrationRegistry.getDatabaseStatus(db, ns);
|
|
50
|
+
ui.log(`Pending: ${status.pendingMigrations} migration(s) (v${status.currentVersion} → v${status.targetVersion})`);
|
|
51
|
+
if (dryRun) {
|
|
52
|
+
ui.log('Would apply:');
|
|
53
|
+
for (const m of status.migrations) {
|
|
54
|
+
if (!m.applied)
|
|
55
|
+
ui.log(` • v${m.version}: ${m.name}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
await migrationRegistry.runMigrations(db, ns);
|
|
60
|
+
ui.success('Migrations completed');
|
|
61
|
+
migratedCount++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
ui.error(`Error: ${String(error)}`);
|
|
66
|
+
errorCount++;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
ui.log('\n' + '─'.repeat(50));
|
|
70
|
+
if (dryRun) {
|
|
71
|
+
ui.info(`Dry run complete. Checked ${namespacesToMigrate.length} namespace(s).`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
ui.info(`Migration complete: ${migratedCount} migrated, ${errorCount} errors`);
|
|
75
|
+
}
|
|
76
|
+
if (errorCount > 0)
|
|
77
|
+
requestCLIExit(1);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=dev.localdb.migrate.cli-command.impl.consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.migrate.cli-command.impl.consumer.js","sourceRoot":"","sources":["../../../../src/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAkB,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAE,+BAA+B,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEtF,eAAe;IACd,KAAK,CAAC,OAAO,CAAC,KAA8B,EAAE,IAA6B;QAC1E,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAc,CAAC;QAC1D,MAAM,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAe,CAAC;QAErE,MAAM,YAAY,GAAG,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEpC,EAAE,CAAC,GAAG,CAAC,wBAAwB,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAEnE,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;QAC5C,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,EAAE,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;YAC/C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AC,6BAA6B,mBAAmB,CAAC,MAAM,gBAAgB,CAAC,CAAC;QAClF,CAAC;aAAM,CAAC;YACP,EAAE,CAAC,IAAI,CAAC,uBAAuB,aAAa,cAAc,UAAU,SAAS,CAAC,CAAC;QAChF,CAAC;QAED,IAAI,UAAU,GAAG,CAAC;YAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev LocalDB Namespaces CLI Command Descriptor
|
|
3
|
+
*/
|
|
4
|
+
declare const _default: {
|
|
5
|
+
id: string;
|
|
6
|
+
kind: "cli/command";
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
group: string;
|
|
10
|
+
surfaces: string[];
|
|
11
|
+
hardware: string[];
|
|
12
|
+
enabled: true;
|
|
13
|
+
options: {
|
|
14
|
+
flags: string;
|
|
15
|
+
description: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=dev.localdb.namespaces.cli-command.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.namespaces.cli-command.descriptor.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;AAIH,wBAUG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev LocalDB Namespaces CLI Command Descriptor
|
|
3
|
+
*/
|
|
4
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
5
|
+
export default createRuntimeAsset({
|
|
6
|
+
id: 'dev.localdb.namespaces',
|
|
7
|
+
kind: 'cli/command',
|
|
8
|
+
name: 'namespaces',
|
|
9
|
+
description: 'List registered migration namespaces',
|
|
10
|
+
group: 'dev.localdb',
|
|
11
|
+
surfaces: ['cli'],
|
|
12
|
+
hardware: ['consumer'],
|
|
13
|
+
enabled: true,
|
|
14
|
+
options: [{ flags: '--verbose', description: 'Show migration details for each namespace' }]
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=dev.localdb.namespaces.cli-command.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.namespaces.cli-command.descriptor.js","sourceRoot":"","sources":["../../../../src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAe,kBAAkB,CAAC;IACjC,EAAE,EAAE,wBAAwB;IAC5B,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;CAC3F,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.namespaces.cli-command.impl.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.ts"],"names":[],"mappings":";mBAKsB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;;AAD5F,wBAyCE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
2
|
+
export default {
|
|
3
|
+
async execute(_args, opts) {
|
|
4
|
+
const runtime = getVibesRuntime();
|
|
5
|
+
const ui = (await runtime.context('cli/ui'));
|
|
6
|
+
const localdb = (await runtime.context('dev/localdb'));
|
|
7
|
+
const verbose = Boolean(opts.verbose);
|
|
8
|
+
ui.log('\n=== Registered Migration Namespaces ===\n');
|
|
9
|
+
const namespaces = localdb.listNamespaces();
|
|
10
|
+
if (namespaces.length === 0) {
|
|
11
|
+
ui.info('No migration namespaces registered.');
|
|
12
|
+
ui.info('Namespaces are registered when their modules are loaded.');
|
|
13
|
+
ui.info('Try running a command that uses the database first.');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!verbose) {
|
|
17
|
+
ui.table(namespaces.map((ns) => ({ namespace: ns })));
|
|
18
|
+
ui.info('\nUse --verbose to see migration details\n');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const { migrationRegistry } = (await import('../../../core/migration-registry.js'));
|
|
22
|
+
for (const ns of namespaces) {
|
|
23
|
+
ui.log(`\nNamespace: ${ns}`);
|
|
24
|
+
const migrations = migrationRegistry.getMigrations(ns);
|
|
25
|
+
ui.log(`Migrations: ${migrations.length}`);
|
|
26
|
+
for (const m of migrations) {
|
|
27
|
+
ui.log(` • v${m.version}: ${m.name}${m.down ? ' (reversible)' : ''}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
ui.log('\n');
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=dev.localdb.namespaces.cli-command.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.namespaces.cli-command.impl.js","sourceRoot":"","sources":["../../../../src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,eAAe;IACd,KAAK,CAAC,OAAO,CAAC,KAA8B,EAAE,IAA6B;QAC1E,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,O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AAK,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACxE,CAAC;QACF,CAAC;QAED,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev LocalDB Pools CLI Command Descriptor
|
|
3
|
+
*/
|
|
4
|
+
declare const _default: {
|
|
5
|
+
id: string;
|
|
6
|
+
kind: "cli/command";
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
group: string;
|
|
10
|
+
surfaces: string[];
|
|
11
|
+
hardware: string[];
|
|
12
|
+
enabled: true;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=dev.localdb.pools.cli-command.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.pools.cli-command.descriptor.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;AAIH,wBASG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev LocalDB Pools CLI Command Descriptor
|
|
3
|
+
*/
|
|
4
|
+
import { createRuntimeAsset } from '@vibesdotdev/runtime';
|
|
5
|
+
export default createRuntimeAsset({
|
|
6
|
+
id: 'dev.localdb.pools',
|
|
7
|
+
kind: 'cli/command',
|
|
8
|
+
name: 'pools',
|
|
9
|
+
description: 'Show connection pool statistics',
|
|
10
|
+
group: 'dev.localdb',
|
|
11
|
+
surfaces: ['cli'],
|
|
12
|
+
hardware: ['consumer'],
|
|
13
|
+
enabled: true
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=dev.localdb.pools.cli-command.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.pools.cli-command.descriptor.js","sourceRoot":"","sources":["../../../../src/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAe,kBAAkB,CAAC;IACjC,EAAE,EAAE,mBAAmB;IACvB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,iCAAiC;IAC9C,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,OAAO,EAAE,IAAI;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.pools.cli-command.impl.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/pools/dev.localdb.pools.cli-command.impl.ts"],"names":[],"mappings":";mBAMsB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;;AAD7F,wBA+BE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
2
|
+
import { formatAgeMs } from '../_shared.consumer.js';
|
|
3
|
+
export default {
|
|
4
|
+
async execute(_args, _opts) {
|
|
5
|
+
const runtime = getVibesRuntime();
|
|
6
|
+
const ui = (await runtime.context('cli/ui'));
|
|
7
|
+
const localdb = (await runtime.context('dev/localdb'));
|
|
8
|
+
ui.log('\n=== Connection Pool Statistics ===\n');
|
|
9
|
+
const stats = localdb.getPoolStats();
|
|
10
|
+
ui.log(`Total Connections: ${stats.total}`);
|
|
11
|
+
ui.log(`Active (in use): ${stats.active}`);
|
|
12
|
+
ui.log(`Idle (pooled): ${stats.idle}`);
|
|
13
|
+
if (stats.connections.length === 0) {
|
|
14
|
+
ui.info('\nNo active connections.\n');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
ui.log('\nConnections:\n' + '─'.repeat(80));
|
|
18
|
+
ui.table(stats.connections.map((c) => ({
|
|
19
|
+
path: c.path,
|
|
20
|
+
status: c.refCount > 0 ? 'ACTIVE' : 'IDLE',
|
|
21
|
+
refs: c.refCount,
|
|
22
|
+
age: formatAgeMs(c.ageMs),
|
|
23
|
+
consumer: c.consumer
|
|
24
|
+
})));
|
|
25
|
+
ui.log('');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=dev.localdb.pools.cli-command.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.pools.cli-command.impl.js","sourceRoot":"","sources":["../../../../src/cli/commands/pools/dev.localdb.pools.cli-command.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,eAAe;IACd,KAAK,CAAC,OAAO,CAAC,KAA8B,EAAE,KAA8B;QAC3E,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAc,CAAC;QAC1D,MAAM,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAe,CAAC;QAErE,EAAE,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QAEjD,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;QAErC,EAAE,CAAC,GAAG,CAAC,sBAAsB,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5C,EAAE,CAAC,GAAG,CAAC,sBAAsB,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7C,EAAE,CAAC,GAAG,CAAC,sBAAsB,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAE3C,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,EAAE,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;YACtC,OAAO;QACR,CAAC;QAED,EAAE,CAAC,GAAG,CAAC,kBAAkB,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5C,EAAE,CAAC,KAAK,CACP,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,MAAM,EAAE,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM;YAC1C,IAAI,EAAE,CAAC,CAAC,QAAQ;YAChB,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;YACzB,QAAQ,EAAE,CAAC,CAAC,QAAQ;SACpB,CAAC,CAAC,CACH,CAAC;QACF,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev LocalDB Query CLI Command Descriptor
|
|
3
|
+
*/
|
|
4
|
+
declare const _default: {
|
|
5
|
+
id: string;
|
|
6
|
+
kind: "cli/command";
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
group: string;
|
|
10
|
+
surfaces: string[];
|
|
11
|
+
hardware: string[];
|
|
12
|
+
enabled: true;
|
|
13
|
+
arguments: {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
required: boolean;
|
|
17
|
+
}[];
|
|
18
|
+
options: {
|
|
19
|
+
flags: string;
|
|
20
|
+
description: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
24
|
+
//# sourceMappingURL=dev.localdb.query.cli-command.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.localdb.query.cli-command.descriptor.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/query/dev.localdb.query.cli-command.descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;AAIH,wBAcG"}
|