latticesql 3.1.0 → 3.2.0
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 +4 -0
- package/dist/cli.js +1996 -878
- package/dist/index.cjs +352 -187
- package/dist/index.d.cts +15 -20
- package/dist/index.d.ts +15 -20
- package/dist/index.js +352 -187
- package/docs/api-reference.md +1370 -0
- package/docs/architecture.md +331 -0
- package/docs/assistant.md +138 -0
- package/docs/cli.md +515 -0
- package/docs/cloud.md +675 -0
- package/docs/collaboration.md +85 -0
- package/docs/configuration.md +416 -0
- package/docs/entity-context.md +510 -0
- package/docs/examples/agent-system.md +313 -0
- package/docs/examples/cms.md +366 -0
- package/docs/examples/ticket-tracker.md +313 -0
- package/docs/migrations.md +272 -0
- package/docs/templates.md +338 -0
- package/docs/workspaces.md +81 -0
- package/package.json +3 -2
package/docs/cli.md
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
# CLI Reference
|
|
2
|
+
|
|
3
|
+
The `lattice` command-line tool for generating TypeScript types, SQL migrations, scaffold files, and entity context directories from a YAML config.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Commands](#commands)
|
|
11
|
+
- [`lattice generate`](#lattice-generate)
|
|
12
|
+
- [`lattice render`](#lattice-render)
|
|
13
|
+
- [`lattice reconcile`](#lattice-reconcile)
|
|
14
|
+
- [`lattice status`](#lattice-status)
|
|
15
|
+
- [`lattice watch`](#lattice-watch)
|
|
16
|
+
- [`lattice gui`](#lattice-gui)
|
|
17
|
+
- [Global options](#global-options)
|
|
18
|
+
- [Generated files](#generated-files)
|
|
19
|
+
- [Examples](#examples)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
The CLI is bundled with the `latticesql` package:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm install latticesql
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
After installation, the `lattice` binary is available via `npx`:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npx lattice --help
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or add it to `package.json` scripts:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"scripts": {
|
|
42
|
+
"codegen": "lattice generate"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
For global access:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm install -g latticesql
|
|
51
|
+
lattice --help
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Commands
|
|
57
|
+
|
|
58
|
+
### `lattice generate`
|
|
59
|
+
|
|
60
|
+
Generate TypeScript interface types, a SQL migration file, and (optionally) scaffold render output files from a `lattice.config.yml`.
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
lattice generate [options]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Options:**
|
|
67
|
+
|
|
68
|
+
| Option | Short | Default | Description |
|
|
69
|
+
| ----------------- | ----- | ---------------------- | ---------------------------------------------- |
|
|
70
|
+
| `--config <path>` | `-c` | `./lattice.config.yml` | Path to the YAML config file |
|
|
71
|
+
| `--out <dir>` | `-o` | `./generated` | Output directory for generated files |
|
|
72
|
+
| `--scaffold` | – | off | Also create empty scaffold render output files |
|
|
73
|
+
|
|
74
|
+
**Output files:**
|
|
75
|
+
|
|
76
|
+
| File | Description |
|
|
77
|
+
| ----------------------- | ---------------------------------------------------------- |
|
|
78
|
+
| `<out>/types.ts` | TypeScript interfaces, one per entity |
|
|
79
|
+
| `<out>/migration.sql` | `CREATE TABLE IF NOT EXISTS` SQL for all entities |
|
|
80
|
+
| `<outDir>/<outputFile>` | _(only with `--scaffold`)_ Empty placeholder context files |
|
|
81
|
+
|
|
82
|
+
**Exit codes:**
|
|
83
|
+
|
|
84
|
+
| Code | Meaning |
|
|
85
|
+
| ---- | ----------------------------------------------------------------------- |
|
|
86
|
+
| `0` | Success |
|
|
87
|
+
| `1` | Config file not found, YAML parse error, or missing required config key |
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### `lattice render`
|
|
92
|
+
|
|
93
|
+
One-shot context generation. Reads the config, connects to the database, and writes all entity context directories to the output directory.
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
lattice render [options]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Options:**
|
|
100
|
+
|
|
101
|
+
| Option | Short | Default | Description |
|
|
102
|
+
| ----------------- | ----- | ---------------------- | -------------------------------------------------- |
|
|
103
|
+
| `--config <path>` | `-c` | `./lattice.config.yml` | Path to the YAML config file |
|
|
104
|
+
| `--output <dir>` | – | `./context` | Output directory for rendered entity context files |
|
|
105
|
+
|
|
106
|
+
**Exit codes:**
|
|
107
|
+
|
|
108
|
+
| Code | Meaning |
|
|
109
|
+
| ---- | ------------------------------ |
|
|
110
|
+
| `0` | Success |
|
|
111
|
+
| `1` | Config error or render failure |
|
|
112
|
+
|
|
113
|
+
**Example:**
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
lattice render --config ./lattice.config.yml --output ./context
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
Rendered 6 files in 42ms
|
|
121
|
+
✓ /project/context/agents/alpha/AGENT.md
|
|
122
|
+
✓ /project/context/agents/alpha/SKILLS.md
|
|
123
|
+
...
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### `lattice reconcile`
|
|
129
|
+
|
|
130
|
+
Render + orphan cleanup. Writes entity context directories and then removes any orphaned entity directories and files that are no longer present in the database or declared in the config.
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
lattice reconcile [options]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Options:**
|
|
137
|
+
|
|
138
|
+
| Option | Short | Default | Description |
|
|
139
|
+
| ------------------- | ----- | ---------------------- | -------------------------------------------------------- |
|
|
140
|
+
| `--config <path>` | `-c` | `./lattice.config.yml` | Path to the YAML config file |
|
|
141
|
+
| `--output <dir>` | – | `./context` | Output directory for rendered entity context files |
|
|
142
|
+
| `--dry-run` | – | off | Report orphans but do not delete anything |
|
|
143
|
+
| `--no-orphan-dirs` | – | off | Skip removal of orphaned entity directories |
|
|
144
|
+
| `--no-orphan-files` | – | off | Skip removal of orphaned files inside entity directories |
|
|
145
|
+
| `--protected <csv>` | – | – | Comma-separated list of protected filenames |
|
|
146
|
+
|
|
147
|
+
**Exit codes:**
|
|
148
|
+
|
|
149
|
+
| Code | Meaning |
|
|
150
|
+
| ---- | ----------------------------------------- |
|
|
151
|
+
| `0` | Success |
|
|
152
|
+
| `1` | Config error, render failure, or warnings |
|
|
153
|
+
|
|
154
|
+
**Example:**
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
lattice reconcile --output ./context --protected SESSION.md
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
Rendered 6 files in 38ms
|
|
162
|
+
✓ /project/context/agents/alpha/AGENT.md
|
|
163
|
+
Cleanup: removed 1 directories, 0 files
|
|
164
|
+
✓ Removed /project/context/agents/beta
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### `lattice status`
|
|
170
|
+
|
|
171
|
+
Dry-run reconcile — shows what would change without writing or deleting anything. Alias for `lattice reconcile --dry-run`.
|
|
172
|
+
|
|
173
|
+
```sh
|
|
174
|
+
lattice status [options]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Options:**
|
|
178
|
+
|
|
179
|
+
| Option | Short | Default | Description |
|
|
180
|
+
| ----------------- | ----- | ---------------------- | -------------------------------------------------- |
|
|
181
|
+
| `--config <path>` | `-c` | `./lattice.config.yml` | Path to the YAML config file |
|
|
182
|
+
| `--output <dir>` | – | `./context` | Output directory for rendered entity context files |
|
|
183
|
+
|
|
184
|
+
**Example:**
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
lattice status --output ./context
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
DRY RUN — no changes made
|
|
192
|
+
Rendered 6 files in 35ms
|
|
193
|
+
Cleanup: removed 1 directories, 0 files
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### `lattice watch`
|
|
199
|
+
|
|
200
|
+
Starts a polling loop that re-renders entity context directories on each interval. Optionally runs orphan cleanup after each render cycle.
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
lattice watch [options]
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Options:**
|
|
207
|
+
|
|
208
|
+
| Option | Short | Default | Description |
|
|
209
|
+
| ------------------- | ----- | ---------------------- | ------------------------------------------------------------------------ |
|
|
210
|
+
| `--config <path>` | `-c` | `./lattice.config.yml` | Path to the YAML config file |
|
|
211
|
+
| `--output <dir>` | – | `./context` | Output directory for rendered entity context files |
|
|
212
|
+
| `--interval <ms>` | – | `5000` | Poll interval in milliseconds |
|
|
213
|
+
| `--cleanup` | – | off | Enable orphan cleanup after each render cycle |
|
|
214
|
+
| `--no-orphan-dirs` | – | off | Skip removal of orphaned entity directories (requires `--cleanup`) |
|
|
215
|
+
| `--no-orphan-files` | – | off | Skip removal of orphaned files inside entity dirs (requires `--cleanup`) |
|
|
216
|
+
| `--protected <csv>` | – | – | Comma-separated list of protected filenames (requires `--cleanup`) |
|
|
217
|
+
|
|
218
|
+
Sends `SIGINT` or `SIGTERM` to stop gracefully.
|
|
219
|
+
|
|
220
|
+
**Example:**
|
|
221
|
+
|
|
222
|
+
```sh
|
|
223
|
+
lattice watch --config ./lattice.config.yml --output ./context --interval 3000 --cleanup --protected SESSION.md
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
[10:42:00] Rendered 6 files in 41ms
|
|
228
|
+
[10:42:03] Rendered 6 files in 38ms
|
|
229
|
+
[10:42:06] Rendered 5 files in 39ms
|
|
230
|
+
[10:42:06] Cleanup: removed 0 dirs, 1 files
|
|
231
|
+
^C
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### `lattice gui`
|
|
237
|
+
|
|
238
|
+
Starts a local-only browser GUI for exploring _and editing_ the data in a
|
|
239
|
+
Lattice database. The server opens the DB referenced by `db:` in the config
|
|
240
|
+
and exposes a small HTTP surface that delegates straight to Lattice's CRUD
|
|
241
|
+
methods — no separate state, no schema duplication.
|
|
242
|
+
|
|
243
|
+
```sh
|
|
244
|
+
lattice gui [options]
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Options:**
|
|
248
|
+
|
|
249
|
+
| Option | Short | Default | Description |
|
|
250
|
+
| ----------------- | ----- | ---------------------- | ----------------------------------------------------- |
|
|
251
|
+
| `--config <path>` | `-c` | `./lattice.config.yml` | Path to the YAML config file |
|
|
252
|
+
| `--output <dir>` | – | `./context` | Output directory (used by the relationship graph) |
|
|
253
|
+
| `--port <number>` | – | `4317` | Localhost port; auto-increments when the port is busy |
|
|
254
|
+
| `--no-open` | – | off | Print the URL without opening a browser |
|
|
255
|
+
|
|
256
|
+
**Example:**
|
|
257
|
+
|
|
258
|
+
```sh
|
|
259
|
+
lattice gui --config ./lattice.config.yml
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
Lattice GUI listening at http://127.0.0.1:4317
|
|
264
|
+
Press Ctrl+C to stop.
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Views:**
|
|
268
|
+
|
|
269
|
+
- **Dashboard** (`#/`) — one card per first-class entity with live row counts.
|
|
270
|
+
- **Workspace / folder grid** (`#/fs/<entity>`, default in v2.0+) — the entity's
|
|
271
|
+
rows as folder/file tiles instead of a table.
|
|
272
|
+
- **Item view** (`#/fs/<entity>/<id>[/<relation>/<id>…]`, default in v2.0+) — the
|
|
273
|
+
row rendered as a document built from its columns (long-form fields as
|
|
274
|
+
markdown); **click any value to edit it in place** (saves via `PATCH`,
|
|
275
|
+
undoable). The row's relationships — reverse `belongsTo` children + junctions —
|
|
276
|
+
appear as **sub-folders** you can drill into arbitrarily deep, with a clickable
|
|
277
|
+
breadcrumb. Native `files` rows show the inline file/markdown preview.
|
|
278
|
+
- **Table view** (`#/objects/<entity>`, Advanced mode) — a SQL-like table with
|
|
279
|
+
intrinsic columns, belongsTo chips, and a column per junction this entity
|
|
280
|
+
participates in. `+ New` adds a row inline; each row has a delete control and a
|
|
281
|
+
click-through to its detail page.
|
|
282
|
+
- **Detail view** (`#/objects/<entity>/<id>`, Advanced mode) — read mode by
|
|
283
|
+
default; `Edit` flips intrinsic + belongsTo cells into inputs (`Save` PATCHes,
|
|
284
|
+
`Cancel` reverts). `Delete` confirms and removes the row.
|
|
285
|
+
- **Settings** (v2.0+) — opened from the header **gear** (top-right): a slide-over
|
|
286
|
+
drawer with **Database / Lattice / User** tabs plus an **Advanced mode** toggle
|
|
287
|
+
(switches the object views between the file-system workspace and the classic
|
|
288
|
+
table/row editor). The legacy `#/settings/*` hashes still resolve and open the
|
|
289
|
+
drawer.
|
|
290
|
+
- **Data Model** (inside Database Settings) — an entity-level graph plus a side
|
|
291
|
+
panel for adding / removing junction-table links between rows.
|
|
292
|
+
|
|
293
|
+
**HTTP surface** (all routes scoped to `http://127.0.0.1:<port>/api`):
|
|
294
|
+
|
|
295
|
+
| Route | Method | Lattice call |
|
|
296
|
+
| -------------------------- | ------ | ----------------------------- |
|
|
297
|
+
| `/project` | GET | (config + manifest summary) |
|
|
298
|
+
| `/entities` | GET | tables + `db.count` per table |
|
|
299
|
+
| `/graph` | GET | (schema graph for Data Model) |
|
|
300
|
+
| `/tables/:table/rows` | GET | `db.query(table, …)` |
|
|
301
|
+
| `/tables/:table/rows` | POST | `db.insert(table, body)` |
|
|
302
|
+
| `/tables/:table/rows/:id` | GET | `db.get(table, id)` |
|
|
303
|
+
| `/tables/:table/rows/:id` | PATCH | `db.update(table, id, body)` |
|
|
304
|
+
| `/tables/:table/rows/:id` | DELETE | `db.delete(table, id)` |
|
|
305
|
+
| `/tables/:junction/link` | POST | `db.link(junction, body)` |
|
|
306
|
+
| `/tables/:junction/unlink` | POST | `db.unlink(junction, body)` |
|
|
307
|
+
|
|
308
|
+
Junction tables (any table with exactly two `belongsTo` relations) are hidden
|
|
309
|
+
from the Objects sidebar and the dashboard; link/unlink lives on the Data Model
|
|
310
|
+
page. The server only binds to `127.0.0.1` and does not implement auth — it's
|
|
311
|
+
intended for local development against a config you trust.
|
|
312
|
+
|
|
313
|
+
**Internal tables added on first open.** Opening a database with `lattice gui`
|
|
314
|
+
creates three additive bookkeeping tables prefixed with `_lattice_gui_`:
|
|
315
|
+
|
|
316
|
+
| Table | Purpose |
|
|
317
|
+
| -------------------------- | ----------------------------------------------------------- |
|
|
318
|
+
| `_lattice_gui_meta` | Per-entity icon overrides edited from the browser |
|
|
319
|
+
| `_lattice_gui_column_meta` | Per-column flags (e.g. mark a column as `secret`) |
|
|
320
|
+
| `_lattice_gui_audit` | Linear audit log of every GUI mutation — powers undo / redo |
|
|
321
|
+
|
|
322
|
+
These tables are filtered out of `/api/entities`, the dashboard, and rendered
|
|
323
|
+
context output. They are not part of your declared schema and do not affect any
|
|
324
|
+
`Lattice` API calls. No fictional / demo rows are ever inserted — the GUI only
|
|
325
|
+
shows the data already in your database.
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Cloud
|
|
330
|
+
|
|
331
|
+
There are **no `lattice teams` (or `lattice serve`) subcommands**. A Lattice cloud
|
|
332
|
+
is a shared Postgres database secured by Postgres Row-Level Security — there is no
|
|
333
|
+
server process to run and nothing to bootstrap from the CLI. The three cloud flows
|
|
334
|
+
(migrate a local Lattice in, join an existing cloud with the scoped credentials the
|
|
335
|
+
owner gave you, invite a member) are driven from `lattice gui` or directly from the
|
|
336
|
+
library API:
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
import {
|
|
340
|
+
Lattice,
|
|
341
|
+
// migrate
|
|
342
|
+
openTargetLatticeForMigration,
|
|
343
|
+
migrateLatticeData,
|
|
344
|
+
installCloudRls,
|
|
345
|
+
backfillOwnership,
|
|
346
|
+
enableRlsForTable,
|
|
347
|
+
archiveLocalSqlite,
|
|
348
|
+
// invite / membership
|
|
349
|
+
memberRoleName,
|
|
350
|
+
generateMemberPassword,
|
|
351
|
+
provisionMemberRole,
|
|
352
|
+
revokeMemberRole,
|
|
353
|
+
// sharing + probe
|
|
354
|
+
setRowVisibility,
|
|
355
|
+
probeCloud,
|
|
356
|
+
} from 'latticesql';
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
See [docs/cloud.md](./cloud.md) for the full architecture, the three flows, the
|
|
360
|
+
RLS / role model, and how sharing works.
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Global options
|
|
365
|
+
|
|
366
|
+
| Option | Short | Description |
|
|
367
|
+
| ----------- | ----- | ---------------------------------- |
|
|
368
|
+
| `--help` | `-h` | Show help message |
|
|
369
|
+
| `--version` | `-v` | Print the installed version number |
|
|
370
|
+
|
|
371
|
+
```sh
|
|
372
|
+
lattice --version # → 1.11.0
|
|
373
|
+
lattice --help
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## Generated files
|
|
379
|
+
|
|
380
|
+
### `types.ts`
|
|
381
|
+
|
|
382
|
+
One TypeScript `export interface` per entity. Field names are preserved as-is; entity names are converted to PascalCase.
|
|
383
|
+
|
|
384
|
+
Given this config:
|
|
385
|
+
|
|
386
|
+
```yaml
|
|
387
|
+
entities:
|
|
388
|
+
task_comment:
|
|
389
|
+
fields:
|
|
390
|
+
id: { type: uuid, primaryKey: true }
|
|
391
|
+
body: { type: text, required: true }
|
|
392
|
+
task_id: { type: uuid, ref: task }
|
|
393
|
+
score: { type: integer, default: 0 }
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Generates:
|
|
397
|
+
|
|
398
|
+
```ts
|
|
399
|
+
// Auto-generated by `lattice generate`. Do not edit manually.
|
|
400
|
+
|
|
401
|
+
export interface TaskComment {
|
|
402
|
+
id: string;
|
|
403
|
+
body: string;
|
|
404
|
+
task_id?: string; // → task
|
|
405
|
+
score?: number;
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Type mapping rules:**
|
|
410
|
+
|
|
411
|
+
- `uuid`, `text`, `datetime`, `date` → `string`
|
|
412
|
+
- `integer`, `int`, `real`, `float` → `number`
|
|
413
|
+
- `boolean`, `bool` → `boolean`
|
|
414
|
+
- `blob` → `Buffer`
|
|
415
|
+
- Fields marked `primaryKey: true` or `required: true` are non-optional (no `?`)
|
|
416
|
+
- All other fields are optional (suffixed with `?`)
|
|
417
|
+
- Fields with `ref` get an inline comment `// → <target>`
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
### `migration.sql`
|
|
422
|
+
|
|
423
|
+
A `CREATE TABLE IF NOT EXISTS` statement for every entity. Safe to run on a fresh or existing database — it will not overwrite data.
|
|
424
|
+
|
|
425
|
+
```sql
|
|
426
|
+
-- Auto-generated by `lattice generate`. Do not edit manually.
|
|
427
|
+
-- Run this file once against your SQLite database to create the initial schema.
|
|
428
|
+
-- For subsequent schema changes, write versioned migrations (see docs/migrations.md).
|
|
429
|
+
|
|
430
|
+
CREATE TABLE IF NOT EXISTS "task_comment" (
|
|
431
|
+
"id" TEXT PRIMARY KEY,
|
|
432
|
+
"body" TEXT NOT NULL,
|
|
433
|
+
"task_id" TEXT,
|
|
434
|
+
"score" INTEGER DEFAULT 0
|
|
435
|
+
);
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
> **Note:** This file is for initial schema setup only. For schema changes to existing databases, write versioned migrations. See the [Migration Guide](./migrations.md).
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
### Scaffold files (with `--scaffold`)
|
|
443
|
+
|
|
444
|
+
When `--scaffold` is passed, `lattice generate` creates an empty file at each entity's `outputFile` path (resolved relative to `--out`). These serve as placeholders until the first sync populates them.
|
|
445
|
+
|
|
446
|
+
```sh
|
|
447
|
+
lattice generate --scaffold
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
If the file already exists, it is not overwritten.
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## Examples
|
|
455
|
+
|
|
456
|
+
### Basic usage
|
|
457
|
+
|
|
458
|
+
```sh
|
|
459
|
+
lattice generate
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
Reads `./lattice.config.yml`, writes to `./generated/`:
|
|
463
|
+
|
|
464
|
+
```
|
|
465
|
+
Generated 2 file(s):
|
|
466
|
+
✓ /project/generated/types.ts
|
|
467
|
+
✓ /project/generated/migration.sql
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
### Custom config and output directory
|
|
473
|
+
|
|
474
|
+
```sh
|
|
475
|
+
lattice generate --config ./config/lattice.yml --out ./src/generated
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
### Generate with scaffold files
|
|
481
|
+
|
|
482
|
+
```sh
|
|
483
|
+
lattice generate --scaffold
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
Generated 5 file(s):
|
|
488
|
+
✓ /project/generated/types.ts
|
|
489
|
+
✓ /project/generated/migration.sql
|
|
490
|
+
✓ /project/context/AGENTS.md
|
|
491
|
+
✓ /project/context/TASKS.md
|
|
492
|
+
✓ /project/context/USERS.md
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
### In a package.json script
|
|
498
|
+
|
|
499
|
+
```json
|
|
500
|
+
{
|
|
501
|
+
"scripts": {
|
|
502
|
+
"codegen": "lattice generate --out src/generated",
|
|
503
|
+
"codegen:scaffold": "lattice generate --out src/generated --scaffold"
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
### Verify installed version
|
|
511
|
+
|
|
512
|
+
```sh
|
|
513
|
+
npx lattice --version
|
|
514
|
+
# 1.11.0
|
|
515
|
+
```
|