dreamteamer 0.41.0 → 0.42.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dreamteamer",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "description": "A workspace compiler for coding agents — schema-validated records as plain files over git, compiled into every harness",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Gilad Khen <giladkhen@gmail.com>",
@@ -99,6 +99,38 @@ the primary workspace's, whoever shipped the skill you are reading.
99
99
  the wrong workspace passes validation, because the collection usually exists in both, so that line
100
100
  is what distinguishes them.
101
101
 
102
+ ## a reply that wrote records ends with the record report
103
+
104
+ a write prints one `✔` line into a tool result the operator does not read. so any reply that
105
+ follows a write — a record verb, `dt commit`, a system verb, a script that called them, a
106
+ hand-edited record — ENDS with the record report, and nothing written, nothing appended.
107
+
108
+ **measure it, never recall it.** run `dt changes` before replying: it lists what is written and
109
+ not committed, in this workspace and every record layer it reads. if you committed during the turn,
110
+ `dt changes --since <the sha HEAD had before your first write>` (or fold what `dt commit` printed —
111
+ the same block). the report, for a turn that added a contact, set two, removed a meeting and added
112
+ an issue with `-w project-a`:
113
+
114
+ ```
115
+ records — contacts: 1 created, 2 updated · issues (project-a): 1 created · meetings: 1 deleted
116
+ [contacts/sam-diaz](data/contacts/sam-diaz.contact.md) (created) · [contacts/dana-oren](data/contacts/dana-oren.contact.md) (updated) · [contacts/harbor-mutual-desk](data/contacts/harbor-mutual-desk.contact.md) (updated) · [issues/login-times-out](git_modules/project-a/data/issues/login-times-out.issue.md) (created) · meetings/kickoff (deleted)
117
+ ```
118
+
119
+ - **line one is `dt changes`'s first line, verbatim**: one entry per collection touched, counts per
120
+ verb; a write into a record layer shows as `<collection> (<layer>)`.
121
+ - **then every record as a link** — `[<ref>](<path>)`, the path column `dt changes` prints, which is
122
+ relative to the workspace root (a layer's record too) so the editor opens it. a deleted record has
123
+ no file: write its ref with `(deleted)`, unlinked. past twenty records, say `+ N more` and
124
+ point at `dt changes --json`.
125
+ - **measured, not attributed.** `dt changes` measures the shared state exactly but cannot say
126
+ whose: another session's pending records show too. a turn that committed by id reports
127
+ `dt commit`'s block unchanged — that IS this turn's writes, measured. otherwise report
128
+ `dt changes` whole; when you leave out rows that were pending before your first write, append
129
+ `(N pending rows left out — not this turn's)` and never drop a row silently. line one is verbatim
130
+ when every row is yours.
131
+ - **nothing written, nothing appended** — no empty report, no "no records changed" line. a system
132
+ write (`dt add-field` …) is reported the same way under its collection.
133
+
102
134
  ## two acts, one map
103
135
 
104
136
  Act one is **working with data** — the records themselves. Act two is **modeling the workspace**
@@ -109,7 +141,7 @@ Load by the map; nothing here is loaded "just in case".
109
141
  |---|---|
110
142
  | a brand-new or empty workspace, dreamteamer over an existing pile of files, "help me set this up" | `references/getting-started.md` |
111
143
  | read, create, update, rename, delete, commit — or UNDO — a record | `references/records.md` |
112
- | "what changed while I was away" | `references/changes.md` |
144
+ | "what changed while I was away", what this turn changed, the record report | `references/changes.md` |
113
145
  | the workspace seems unable to do something — a new kind of thing, a missing capability, "don't we already have this?" | `references/before-you-build.md` (look first); a new model then continues `references/data-modeling.md` (decide) → `references/collections.md` (write it) |
114
146
  | a collection or field, mechanically — the descriptor and its field vocabulary, ids, `display`, the system and field verbs, mixins and overlays, the `package.json` block, a compile or check message | `references/collections.md` |
115
147
  | "keep a company's meetings in the company's folder" — records stored beside the record they belong to, a `placed … but` check report, `dt relocate` | `references/collections.md` (declaring it) · `references/records.md` (working with it) |
@@ -1,41 +1,56 @@
1
- # what changed — record events derived from git
1
+ # what changed — the uncommitted state and the commits, per record
2
2
 
3
- **core principle:** record events are never observed live — they are **derived from git
4
- history**. a closed laptop loses nothing, every derivation is auditable and replayable forever,
5
- and history IS the queue: there is no events file, and there never should be.
3
+ **core principle:** record changes are never observed live — they are **read off git**: the
4
+ working tree against HEAD for what is written and not committed, and the history for what was
5
+ committed. a closed laptop loses nothing, every answer is auditable and replayable, and history IS
6
+ the queue: there is no events file, no mark file and no cursor, and there never should be.
6
7
 
7
8
  ```bash
8
- dt changes # what the last commit changed (--since HEAD~1)
9
- dt changes --since <sha|YYYY-MM-DD>
9
+ dt changes # what is written and not committed — every repo, each against its own HEAD
10
+ dt changes --since <sha|YYYY-MM-DD> # everything since then: the commits AND the uncommitted state
11
+ dt changes --since HEAD~1 # what 0.41.0's bare `dt changes` answered: the last commit, plus anything pending
10
12
  dt changes --json
13
+ dt changes -w <layer> # the same, run IN a record layer (its own paths, its own HEAD)
11
14
  ```
12
15
 
13
- per record it reports the collection, the id and one of `item-added` / `item-updated` /
14
- `item-removed`, grouped by collection with counts. **read-only by construction** — no cursor,
15
- nothing stored, so running it twice is free and running it wrong costs nothing.
16
+ per record it reports `change` — `created` / `updated` / `deleted` — the `ref`, the
17
+ workspace-relative `path`, the `repo` it lives in, the record `layer` it was read from (empty for
18
+ the workspace and for a module's own clone) and whether it is `committed`. the human output's FIRST
19
+ LINE is the report line a reply ends with (`SKILL.md`, "a reply that wrote records ends with the
20
+ record report"), then one row per record, then the count. `dt commit` prints the same block for
21
+ what it just published. **read-only by construction** — nothing stored, so running it twice is free
22
+ and running it wrong costs nothing.
23
+
24
+ `--json` is `{ since, head, events, collections }`: `events` one entry per record (carrying 0.41.0's
25
+ `type` — `item-added` / `item-updated` / `item-removed` — beside `change`, so an older reader keeps
26
+ working), `collections` one count row per collection and layer.
16
27
 
17
28
  ## when to use
18
29
 
19
- the operator asks what changed or what they missed; you are reconciling after a batch of edits or
20
- a bulk rewrite; you want to know what a range of commits did to the *data*. **not for** ordinary
21
- "show me the diff" questions — plain `git log` / `git diff` is better — not for reading or
22
- writing individual records (`records.md`), and not for UNCOMMITTED writes: it diffs commits, so
23
- pending records are invisible to it (`dt commit --dry-run` shows those).
30
+ before replying after any write (the record report); the operator asks what changed or what they
31
+ missed; you are reconciling after a batch of edits or a bulk rewrite; you want to know what a range
32
+ of commits did to the *data*. **not for** ordinary "show me the diff" questions — plain `git log` /
33
+ `git diff` is better — and not for reading or writing individual records (`records.md`).
24
34
 
25
35
  ## the mechanism — enough to trust its edges
26
36
 
27
- 1. it covers **every repo that holds records**: each compiled descriptor's `storage.path`,
28
- grouped per repo (a module can own its records). a changed path that matches no descriptor is
29
- **skipped** — source and runtime churn are not data events — and runtime entities never
30
- appear.
31
- 2. `--since` takes a sha or a date. a sha is resolved to its commit DATE in the workspace repo
37
+ 1. it covers **every repo that holds records**: each compiled descriptor's roots — the write root
38
+ and every record layer's — grouped per repo (a module can own its records). a changed path that
39
+ matches no descriptor is **skipped** — source and runtime churn are not data events — and
40
+ runtime entities never appear.
41
+ 2. the uncommitted half is the same `git status` sample `dt commit` publishes from and `dt status`
42
+ counts, so the three can never disagree. it cannot say WHICH SESSION wrote a pending record —
43
+ git does not know — which is why the report rule says to keep only your own.
44
+ 3. `--since` takes a sha or a date. a sha is resolved to its commit DATE in the workspace repo
32
45
  (a sha means nothing in another repo), and each repo then resolves that date against its own
33
- history; a repo younger than the date reports everything in it as added. ⚠ a bare date is
46
+ history; a repo younger than the date reports everything in it as created. ⚠ a bare date is
34
47
  pinned to **midnight** deliberately — git's own approxidate fills missing fields from the
35
48
  current clock, so the same command would answer differently morning and evening (measured).
36
- 3. the git status letter becomes the event: `A` → added, `M` → updated, `D` → removed. **a
37
- rename emits removed + added** — there is deliberately no `item-renamed`, because the id IS
38
- the path and a moved record is a different record to any consumer.
49
+ 4. the two halves fold per record: created then deleted inside the window is not reported (it
50
+ existed at neither end); created then edited is still created; deleted then re-created is an
51
+ update; a record moved inside one repo (`dt relocate`) is one update at its new path.
52
+ 5. **a rename is deleted + created** — there is deliberately no `renamed`, because the id IS the
53
+ path and a moved record is a different record to any consumer.
39
54
 
40
55
  ## if you are ever asked to automate on top of this
41
56
 
@@ -43,13 +58,17 @@ this derivation is the surviving half of a removed automation layer (its run-rec
43
58
  one workflow, nine runs, seven abandoned, in three days). the lessons it left: **never store an
44
59
  event queue** — a queue drifts from reality, history cannot; make every evaluator **idempotent
45
60
  over a range** (the old design keyed on `trigger + item + commit` — reuse that shape); and **a
46
- migration is not a data event** — a bulk rewrite looks like N added records, so scope past it
61
+ migration is not a data event** — a bulk rewrite looks like N created records, so scope past it
47
62
  rather than run over it.
48
63
 
49
64
  ## common mistakes
50
65
 
51
66
  | mistake | reality |
52
67
  |---|---|
53
- | hand-rolling the diff + path mapping | `dt changes` is the mechanism; a hand-roll misses folder-shape records, per-repo grouping and the rename split |
68
+ | writing the record report from memory of your `✔` lines | `dt changes` measures it; memory misses a script's writes and a hand-edit |
69
+ | reporting every row `dt changes` prints | the uncommitted state is shared with other sessions — keep only your own writes |
70
+ | an empty report when nothing was written | nothing written, nothing appended |
71
+ | expecting bare `dt changes` to show the last commit | since 0.42.0 it is the uncommitted state; `--since HEAD~1` adds the last commit |
72
+ | hand-rolling the diff + path mapping | `dt changes` is the mechanism; a hand-roll misses folder-shape records, layers, per-repo HEADs and the rename split |
54
73
  | writing an events file to "remember" what changed | history is the record; anything you write can drift from it |
55
74
  | reading the output as a to-do list | it says what changed, not what it means — the judgment is yours |
@@ -249,6 +249,10 @@ lists it. What belongs in a module is judgment — `data-modeling.md` Part III
249
249
  | `env` · `vars` | the `.env` keys it needs · the `${env:…}` names its records use (the workspace must allow each) |
250
250
  | `extension` · `ignore` · `local_assets` | an extension entry (`extensions.md`) · folders that are not kinds · gitignored files a worktree links |
251
251
 
252
+ A version floor on another module is not a key of this block: it is npm's own peer-dependency range,
253
+ at the top level of the module's package.json. A present module outside the range fails compile,
254
+ naming both versions and the fix.
255
+
252
256
  ## the workspace manifest — the `dreamteamer` block in `package.json`
253
257
 
254
258
  Keys are snake_case and closed: compile refuses an unknown one, naming the list. `dt init` writes
@@ -50,6 +50,7 @@ never disagree with the one the operator ran. It returns a contribution; every k
50
50
  | `hooks` | `{ <ClaudeHookEvent>: '<dt verb args>' }` | merged into `dt install --print-adapters` |
51
51
  | `check` | `({ root, ws, dt }) → [{ file, message }]` | `dt check` reports each as a violation after the schema's, attributed to the extension; a throw is a violation too |
52
52
  | `doctor` | `({ root, ws, dt }) → [{ label, state: ok\|warn\|bad, detail?, fix? }]` | `dt doctor` renders the rows as one capability named after the extension: READY, DEGRADED (a warn) or UNAVAILABLE (a bad), each fix on its row |
53
+ | `next` | `({ root, ws, collection, ids }) → [{ id, text }]`, synchronous | `dt next <ref>` prints each line under the bound commands (`--json`: `notes`, attributed); a throw is one failure line, never a failed `dt next`. `contributedNotes(ws, collection, ids)` is the same call for a surface |
53
54
 
54
55
  The `draft` is data only: the staged entries, the final merged descriptors, the modules, declared var
55
56
  and env key NAMES, and the previous manifest. No writer, no Store, no environment values — an analysis
@@ -174,7 +174,7 @@ source_file: ${env:FILES_FOLDER}/2026/q3.pdf
174
174
 
175
175
  ## committing — publishing what you wrote
176
176
 
177
- - **commit when a logical change is complete.** an uncommitted write is invisible to `dt changes` and to every
177
+ - **commit when a logical change is complete.** an uncommitted write is what a bare `dt changes` lists, and it is invisible to every
178
178
  other CLONE — while a session SHARING this tree sees it immediately, which is why the sweep
179
179
  rules below exist — `auto_commit` off makes the commit a deliberate act, not a
180
180
  forbidden one, and publishing what the operator asked you to write needs scope, not permission.
@@ -160,6 +160,26 @@ so a view saved from the CLI and one saved from a surface land on the **same rec
160
160
  - **An empty value REMOVES the key**, so the setting whose meaningful value IS empty is written
161
161
  QUOTED: `'display.list.sort=""'`. A value holding a template is quoted the same way:
162
162
  `'display.list.options.card_title="{{ name }}"'`.
163
+ - **`dt set ui-views/<id> module=<m>` MOVES the view** to another module's `ui-views/` (bytes and
164
+ comments kept, one compile gate, one commit per repo — a linked clone's module commits there).
165
+ `--dry-run` shows the plan. A package's view never moves; save it under a new name and move that.
166
+
167
+ ## a package's view, changed from here — `overlay: true`
168
+
169
+ A view an installed package ships is never written in `node_modules/`. A source in the workspace
170
+ module with the SAME id and `overlay: true` is merged onto it at compile: deep, the overlay wins at a
171
+ leaf, a list is replaced whole, `null` removes a key the package sets. The compiled view names
172
+ `compiled.module` and `compiled.overlaid_by`. `dt set` on a package's view writes exactly that
173
+ overlay — only what differs from the package — and setting it back removes it. A same-id view
174
+ WITHOUT the flag is still a name collision.
175
+
176
+ A COLLECTION overlay merges by a different, shallower rule — know which one you are writing: its
177
+ `display` is merged ONE key deep (`display.list` keeps the package's keys and takes yours, but a
178
+ `display.list.options` you write replaces the package's `options` whole), a list replaces whole, and
179
+ `null` is a value, not a removal — nothing can be deleted from the package's display. `dt set
180
+ collections/<c> display.…` on a package's collection writes the keys that differ into such an overlay
181
+ in the workspace module (writing `options` whole when one option changes, so none is dropped), says
182
+ when it also declares `<c>` in that module's `peer_collections`, and never writes the package.
163
183
 
164
184
  ## common mistakes
165
185
 
package/src/api.d.ts CHANGED
@@ -28,6 +28,8 @@ export interface Contribution {
28
28
  check?(ctx: ExtensionContext): { file?: string; message: string }[] | void | Promise<{ file?: string; message: string }[] | void>;
29
29
  /** machine checks: `dt doctor` renders the rows as one capability named after the extension */
30
30
  doctor?(ctx: ExtensionContext): DoctorRow[] | void | Promise<DoctorRow[] | void>;
31
+ /** a line about a record's state that `dt next` prints under the bound commands — synchronous */
32
+ next?(ctx: { root: string; ws: Workspace; collection: string; ids: string[] }): { id: string; text: string }[] | void;
31
33
  }
32
34
  export interface DoctorRow { label: string; state: 'ok' | 'warn' | 'bad'; detail?: string; fix?: string }
33
35
  export interface ExtensionContext { root: string; ws: Workspace; dt: typeof import('./api.js') }
@@ -43,6 +45,7 @@ export interface LoadedExtension {
43
45
  hooks: Record<string, string>;
44
46
  check: Contribution['check'] | null;
45
47
  doctor: Contribution['doctor'] | null;
48
+ next: Contribution['next'] | null;
46
49
  }
47
50
  export type Entry = { sources: { path: string; hash: string }[]; bytes: Buffer };
48
51
  export interface CompileDraft {
@@ -70,6 +73,8 @@ export function openWorkspace(start?: string): Promise<Workspace & { extensions:
70
73
  export function findWorkspace(start?: string): Workspace;
71
74
  /** every extension's `check` contribution on `ws`, in the shape `check(ws, { extra })` takes */
72
75
  export function contributedViolations(ws: Workspace): Promise<{ file: string; msg: string }[]>;
76
+ /** every extension's `next` lines about `ids` of `collection` — what `dt next` prints; a throw is one `error: true` line */
77
+ export function contributedNotes(ws: Workspace, collection: string, ids?: string[]): { id: string | null; text: string; by: string; error?: true }[];
73
78
  export function declaredExtensions(ws: Workspace): { name: string; version: string; dir: string; entry: string }[];
74
79
  export const engineBin: string;
75
80
  export const engineRoot: string;
@@ -104,7 +109,7 @@ export const addField: SchemaOp, updateField: SchemaOp, removeField: SchemaOp, r
104
109
  export const renameValue: SchemaOp, renameValuePlan: SchemaOp;
105
110
  /** One v2 field from the field-verb flag vocabulary, applied over `previous` (the field as its source declares it). */
106
111
  export function fieldFromFlags(store: Store, flags: Record<string, unknown>, previous?: Record<string, unknown>): Record<string, unknown>;
107
- export const saveUiView: SchemaOp, removeUiView: SchemaOp;
112
+ export const saveUiView: SchemaOp, removeUiView: SchemaOp, moveUiView: SchemaOp;
108
113
  export const createModule: SchemaOp, setModule: SchemaOp, renameModule: SchemaOp, removeModule: SchemaOp;
109
114
  export const createSkill: SchemaOp, refuseHandAuthored: SchemaOp, removeEntity: SchemaOp, renameEntity: SchemaOp, setEntityFrontmatter: SchemaOp;
110
115
  export function init(opts?: { flags?: Record<string, string> }): 0;
package/src/api.js CHANGED
@@ -35,7 +35,7 @@ export async function openWorkspace(start = process.cwd()) {
35
35
  return ws;
36
36
  }
37
37
  export { findWorkspace };
38
- export { EXTENSION_API, declaredExtensions } from './extensions.js';
38
+ export { EXTENSION_API, declaredExtensions, contributedNotes } from './extensions.js';
39
39
 
40
40
  /** What every extension's `check` reports on `ws`, as `check(ws, { extra })` takes it — attributed to
41
41
  * the extension, a throw being a violation. `dt check` and an in-process caller get one verdict. */
@@ -66,7 +66,7 @@ export { MANAGED_BLOCKS } from './harnesses.js';
66
66
  export {
67
67
  createCollection, removeCollection, renameCollection, moveCollection, setCollectionScalars,
68
68
  addField, updateField, removeField, removeFieldPlan, renameField, renameFieldPlan, renameValue, renameValuePlan, fieldFromFlags,
69
- saveUiView, removeUiView,
69
+ saveUiView, removeUiView, moveUiView,
70
70
  createModule, setModule, renameModule, removeModule,
71
71
  createSkill, refuseHandAuthored, removeEntity, renameEntity, setEntityFrontmatter,
72
72
  } from './schema-ops.js';
package/src/cli.js CHANGED
@@ -20,8 +20,8 @@ import { collectionCommand, emit, relationsCommand, reportCommits } from './coll
20
20
  import { formatDescriptors } from './schema-ops.js';
21
21
  import { init, installClone, update, listRepos } from './init.js';
22
22
  import { installCommand, describeCheckout } from './checkout.js';
23
- import { deriveEvents } from './events.js';
24
- import { commitPending } from './commit.js';
23
+ import { foldChanges, groupChanges, reportLine } from './events.js';
24
+ import { commitPending, recordChanges, rowChanges } from './commit.js';
25
25
  import { Store } from './store.js';
26
26
  import { splitRef, canonicalCollection } from './ref.js';
27
27
  import { envContext, renderTemplate } from './env-vars.js';
@@ -233,13 +233,17 @@ workspace verbs:
233
233
  anything is UNAVAILABLE [--json]
234
234
  status workspace status: compiled runtime freshness, per-module channel/ref, staleness
235
235
 
236
- changes what changed in every repo that holds records, as record events
237
- [--since <sha|YYYY-MM-DD>] (default: HEAD~1 — the last commit's own changes) [--json]
236
+ changes the records created / updated / deleted in every repo that holds records — the
237
+ workspace and each record layer — grouped by collection, each with its path, layer
238
+ and whether it is committed. Its first line is the report a reply ends with
239
+ [--since <sha|YYYY-MM-DD>] (default: HEAD — what is written but not committed;
240
+ a sha or date adds the commits since then, e.g. --since HEAD~1) [--json]
238
241
  commit publish records already written to disk: samples git status over every
239
242
  collection's record dirs, one commit PER REPO, subject composed from the
240
243
  status letters. Scope it with any number of targets, each either a whole
241
244
  <collection> or one <collection>/<id> — the record form is what keeps a
242
- concurrent session's pending records out of your commit.
245
+ concurrent session's pending records out of your commit. Ends with the same
246
+ record report \`changes\` prints, for what it published.
243
247
  [<collection>|<collection>/<id> …] [-m <subject>] [--dry-run] [--json]
244
248
  help this text
245
249
 
@@ -303,6 +307,21 @@ const VERB_PACKAGES = {
303
307
  };
304
308
  const DOCKER_VERBS = new Set(['start', 'stop', 'open', 'export', 'import']);
305
309
 
310
+ /** The record-change report: the report line, then one row per record — its change, ref, workspace
311
+ * path (what a reply links to), committed or not, and the layer it landed in — capped like every
312
+ * other listing here. `dt changes` and `dt commit` print it identically, so what a session copies
313
+ * into its reply does not depend on which of the two it ran. */
314
+ function printChanges(changes) {
315
+ const groups = groupChanges(changes);
316
+ console.log(reportLine(groups));
317
+ const rows = groups.flatMap((g) => g.records);
318
+ for (const c of rows.slice(0, ROWS_SHOWN)) {
319
+ const state = c.committed ? `committed${c.sha ? ` ${c.sha}` : ''}` : 'uncommitted';
320
+ console.log(` ${c.change.padEnd(7)} ${c.ref} ${c.path} · ${state}${c.layer ? ` · layer ${c.layer}` : ''}`);
321
+ }
322
+ if (rows.length > ROWS_SHOWN) console.log(` + ${rows.length - ROWS_SHOWN} more — --json lists every record`);
323
+ }
324
+
306
325
  export async function run(argv) {
307
326
  const [cmd, ...rest] = argv;
308
327
  try {
@@ -412,25 +431,23 @@ export async function run(argv) {
412
431
  // record events from git history was the genuinely used half (catch-up — "what happened
413
432
  // while I was away"), while creating run records from triggers was not. Read-only by
414
433
  // construction: no cursor to advance, nothing to store, so it is safe to run twice.
434
+ // Since 0.42.0 its default is the UNCOMMITTED state (`HEAD`), because the question a
435
+ // session asks after a write is "what did I just change" — and its first line is the
436
+ // report line the skill tells a session to end its reply with.
415
437
  case 'changes': {
416
438
  warnIfStale(ws.root);
417
439
  const si = rest.indexOf('--since');
418
- const since = si > -1 ? rest[si + 1] : 'HEAD~1';
419
- const store = new Store(ws);
420
- const events = deriveEvents(ws.root, store.descriptors, since, 'HEAD');
421
- if (rest.includes('--json')) { emit(JSON.stringify({ since, head: 'HEAD', events }, null, 2)); process.exit(0); }
422
- if (!events.length) { console.log(`✔ no record changes since ${since}`); process.exit(0); }
423
- const byCollection = new Map();
424
- for (const e of events) {
425
- if (!byCollection.has(e.collection)) byCollection.set(e.collection, []);
426
- byCollection.get(e.collection).push(e);
427
- }
428
- console.log(`${events.length} record change(s) since ${since}:`);
429
- for (const [c, list] of [...byCollection].sort()) {
430
- const n = (t) => list.filter((e) => e.type === t).length;
431
- console.log(` ${c}: ${n('item-added')} added, ${n('item-updated')} updated, ${n('item-removed')} removed`);
432
- for (const e of list) console.log(` ${e.type.replace('item-', '').padEnd(7)} ${c}/${e.id}`);
440
+ if (si > -1 && (!rest[si + 1] || rest[si + 1].startsWith('-'))) throw new Error('--since needs a commit or a date: dt changes --since <sha|YYYY-MM-DD> (bare `dt changes` is the uncommitted state)');
441
+ const since = si > -1 ? rest[si + 1] : 'HEAD';
442
+ const events = recordChanges(new Store(ws), { since });
443
+ if (rest.includes('--json')) {
444
+ emit(JSON.stringify({ since, head: 'HEAD', events, collections: groupChanges(events).map(({ records, ...g }) => g) }, null, 2));
445
+ process.exit(0);
433
446
  }
447
+ if (!events.length) { console.log(`✔ no record changes since ${since}`); process.exit(0); }
448
+ printChanges(events);
449
+ const open = events.filter((e) => !e.committed).length;
450
+ console.log(`${events.length} record change(s) since ${since} — ${open ? `${open} uncommitted` : 'all committed'}`);
434
451
  process.exit(0);
435
452
  }
436
453
  // the other half of `auto-commit: false` — record writes land on disk uncommitted, and
@@ -447,6 +464,7 @@ export async function run(argv) {
447
464
  const results = commitPending(store, { only, message, dryRun: rest.includes('--dry-run') });
448
465
  if (rest.includes('--json')) { emit(JSON.stringify(results, null, 2)); process.exit(0); }
449
466
  if (!results.some((r) => !r.outside)) console.log('nothing pending');
467
+ const published = [];
450
468
  for (const r of results) {
451
469
  // an env-pointed collection's folder is outside every repo here: kept, never committed, said
452
470
  if (r.outside) { console.log(`· ${r.outside}: ${r.repo} is outside every git repo here (storage.path ${r.template}) — its records are kept on this machine, never committed`); continue; }
@@ -455,8 +473,8 @@ export async function run(argv) {
455
473
  if (r.pending) { console.error(`⚠ ${r.repo}: ${r.rows.length} record(s) left pending — ${r.pending}; run dreamteamer commit again once it is fixed`); continue; }
456
474
  if (r.warning) console.warn(`⚠ ${r.repo}: ${r.warning}`);
457
475
  console.log(`✔ ${r.repo === '.' ? 'workspace' : r.repo}${r.sha ? ` ${r.sha}` : ' (dry run)'} — ${r.subject}`);
458
- for (const row of r.rows.slice(0, ROWS_SHOWN)) console.log(` ${row.verb} ${row.collection}/${row.id}`);
459
- if (r.rows.length > ROWS_SHOWN) console.log(` + ${r.rows.length - ROWS_SHOWN} more`);
476
+ // what this repo published, for the ONE report block printed after every repo
477
+ for (const c of rowChanges(store.descriptors, r.repo, r.rows)) published.push({ ...c, sha: r.sha });
460
478
  // Half a pair was published — name the records that finish it. `dt commit
461
479
  // <collection>` publishes exactly that collection by design, so this is an honest
462
480
  // report of what it left behind, not a failure: HEAD fails `check` until they land.
@@ -486,6 +504,8 @@ export async function run(argv) {
486
504
  console.warn(' (if that refuses as entangled, the refusal names the other pending records — add them to the same command)');
487
505
  }
488
506
  }
507
+ // the same block `dt changes` prints, for what was published — a dry run's rows are uncommitted
508
+ if (published.length) printChanges(foldChanges(published.filter((c) => c.sha), published.filter((c) => !c.sha)));
489
509
  process.exit(results.some((r) => r.blocked || r.failed) ? 1 : 0);
490
510
  }
491
511
  case 'status': {
@@ -577,8 +597,8 @@ export async function run(argv) {
577
597
  for (const r of repos) if (!r.present) console.log(` absent: ${r.id} → ${r.path}${r.unresolved ? ` — ${r.unresolved}` : ` (dreamteamer install repos/${r.id})`}`);
578
598
  }
579
599
  } catch { /* no repos descriptor compiled — nothing to report */ }
580
- // Uncommitted records are invisible to `dt changes` (it diffs commits), so the
581
- // count belongs here — otherwise deferred work accumulates silently.
600
+ // `dt changes` lists the uncommitted records one by one (0.42.0); status keeps the
601
+ // COUNT per repo, so deferred work is visible at a glance here too.
582
602
  try {
583
603
  const pending = commitPending(new Store(ws), { dryRun: true });
584
604
  const total = pending.reduce((n, r) => n + r.rows.length, 0);
@@ -9,7 +9,7 @@ import { Store, bodyField, serialize, atomicWrite } from './store.js';
9
9
  import { load, dump } from './yaml.js';
10
10
  import { slug } from './template.js';
11
11
  import {
12
- createCollection, removeCollection, renameCollection, addField, updateField, removeField, fieldFromFlags, saveUiView, removeUiView,
12
+ createCollection, removeCollection, renameCollection, addField, updateField, removeField, fieldFromFlags, saveUiView, removeUiView, moveUiView,
13
13
  // was copy-pasted here, and the copy went stale the moment the source layout gained a second
14
14
  // spelling — one implementation, two callers
15
15
  workspaceSystemDir,
@@ -20,6 +20,7 @@ import {
20
20
  import { KINDS } from './compile.js';
21
21
  import { history, historyDiff } from './history.js';
22
22
  import { commandsFor, recordResolver } from './record-commands.js';
23
+ import { contributedNotes } from './extensions.js';
23
24
  import { distinctValues } from './field-values.js';
24
25
  import { matchesFilter, unknownTokens, VALUE_TOKENS } from './filter.js';
25
26
  import { baseNameOf, defaultStoragePath } from './namespace.js';
@@ -316,13 +317,17 @@ function metaCommandsFor(ws, store, flags, pos) {
316
317
  const collection = need(pos, 0, 'collection');
317
318
  const ids = (oneValue(flags, 'ids') ?? '').split(',').map((s) => s.trim()).filter(Boolean);
318
319
  const out = commandsFor(store, collection, ids);
319
- if (flags.json) { emit(JSON.stringify(out, null, 2)); return 0; }
320
- if (!out.commands.length) { console.log(`(no commands bound to ${collection})`); return 0; }
320
+ // what an installed extension says about these records (a session holding one, say) — after the
321
+ // commands, because the commands are the answer and a note is context for it
322
+ const notes = contributedNotes(ws, collection, ids);
323
+ if (flags.json) { emit(JSON.stringify({ ...out, notes }, null, 2)); return 0; }
324
+ if (!out.commands.length) console.log(`(no commands bound to ${collection})`);
321
325
  for (const c of out.commands) {
322
326
  if (c.scope === 'collection') { console.log(`${c.name} [collection] ${c.invocation}`); continue; }
323
327
  const counts = ids.length ? ` ${c.eligible.length}/${ids.length} eligible${c.done.length ? `, ${c.done.length} done` : ''}` : ' (no ids given)';
324
328
  console.log(`${c.name} [record]${counts}${c.invocation ? `\n ${c.invocation}` : ''}`);
325
329
  }
330
+ for (const n of notes) console.log(n.error ? `✖ ${n.by}: ${n.text}` : `● ${collection}/${n.id} — ${n.text} (${n.by})`);
326
331
  return 0;
327
332
  }
328
333
 
@@ -517,7 +522,7 @@ function metaCollectionsSet(ws, store, flags, pos) {
517
522
  const out = setCollectionScalars(ws, store, name, changes, { moduleId: undefined });
518
523
  if (flags.json) { emit(JSON.stringify(out)); return 0; }
519
524
  if (out.unchanged) return alreadyThat(`collections/${name} ${out.changed.join(', ')}`);
520
- console.log(`✔ ${rel(ws.root, out.file)} — ${out.changed.join(', ')}`);
525
+ console.log(`✔ ${rel(ws.root, out.file)} — ${out.changed.join(', ')}${out.peer ? `, and declared ${out.peer.collection} as a peer collection of ${out.peer.module}` : ''}`);
521
526
  console.log('✔ compiled — the descriptor is up to date');
522
527
  reportCommits(out.commits);
523
528
  return 0;
@@ -913,6 +918,24 @@ function metaUiView(ws, store, verb, flags, pos) {
913
918
  // that shadows it, which is the same thing saving one in the UI does.
914
919
  let view = {};
915
920
  let id = oneValue(flags, 'id');
921
+ // `module=` on a set is the MOVE, spelled as it is for a collection (`dt set collections/<c>
922
+ // module=<m>`): a value being written, not the `--module` selector `add` takes.
923
+ const moveArg = verb === 'set' ? pos.slice(1).find((p) => p.startsWith('module=')) : undefined;
924
+ if (moveArg) {
925
+ const viewId = id ?? need(pos, 0, 'ui-view id');
926
+ const moveTo = moveArg.slice('module='.length);
927
+ const others = [...pos.slice(1).filter((p) => p !== moveArg && p.includes('=')), ...Object.keys(flags).filter((k) => !VIEW_META_FLAGS.has(k) && k !== 'dry-run')];
928
+ if (others.length) throw new Error(`module= moves the view to another module; the other keys rewrite it. Run them as two commands: dreamteamer set ui-views/${viewId} module=${moveTo}, then dreamteamer set ui-views/${viewId} ${others.join(' ')}`);
929
+ const out = moveUiView(ws, store, viewId, moveTo, { dryRun: !!flags['dry-run'] });
930
+ if (flags.json) { emit(JSON.stringify(out)); return 0; }
931
+ if (out.dryRun) return dryRunPlan(`set ui-views/${viewId} module=${moveTo}`, { descriptors: 1 }, [`view source ${out.from} → ${out.to} (${out.file})`]);
932
+ if (!out.moved) { console.log(`✔ ui-views/${viewId} — already in ${out.to}, nothing to do`); return 0; }
933
+ console.log(`✔ ui-views/${viewId}: ${out.from} → ${out.to} (${out.file})`);
934
+ console.log('✔ compiled — the move is live');
935
+ reportCommits(out.commits);
936
+ return 0;
937
+ }
938
+ if (flags['dry-run']) throw new Error('--dry-run plans a move (module=<m>); a key write has no plan to show — run it without the flag');
916
939
  if (verb === 'set') {
917
940
  id ??= need(pos, 0, 'ui-view id');
918
941
  const { fields } = store.read('ui-views', id);
@@ -1309,7 +1332,7 @@ export const VERB_FLAGS = {
1309
1332
  // is deliberately UNCHECKED — a skill's frontmatter is an open document (`allowed-tools`, `model`,
1310
1333
  // whatever a harness reads), so there is no closed set to check it against.
1311
1334
  'skills:add': ['json', 'module', 'name', 'description'],
1312
- 'ui-views:add': ['json', 'module', 'id', 'force'], 'ui-views:set': ['json', 'module', 'id', 'force'], 'ui-views:rm': FORCE_RM,
1335
+ 'ui-views:add': ['json', 'module', 'id', 'force'], 'ui-views:set': ['json', 'module', 'id', 'force', 'dry-run'], 'ui-views:rm': FORCE_RM,
1313
1336
  };
1314
1337
 
1315
1338
  /** Edit distance, capped — enough to turn `--fliter` into "did you mean --filter?", and to refuse to
package/src/commit.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import { execFileSync } from 'node:child_process';
5
5
  import fs from 'node:fs';
6
6
  import path from 'node:path';
7
- import { pathToRecord } from './events.js';
7
+ import { pathToRecord, deriveEvents, foldChanges, CHANGE_OF, TYPE_OF } from './events.js';
8
8
  import { parseRecordText } from './records.js';
9
9
  import { relationsOf } from './relations.js';
10
10
  import { splitRef, canonicalCollection } from './ref.js';
@@ -572,3 +572,40 @@ function commitPlan(store, { only = [], message, dryRun = false } = {}) {
572
572
  }
573
573
  return results;
574
574
  }
575
+
576
+ /** The record layer a repo is, by name — what a descriptor's root carries — or null for the workspace
577
+ * and for a module's clone that merely holds its own records. */
578
+ function layerOf(descriptors, repo) {
579
+ for (const d of descriptors.values()) for (const r of storageOf(d).roots) if (r.repo === repo && r.layer) return r.layer;
580
+ return null;
581
+ }
582
+
583
+ /** One sampled repo's rows (the sampler above: `dt commit`, `dt status`) as report changes. A staged
584
+ * rename is two records — the id IS the path — so the old id is read back off the old path. */
585
+ export function rowChanges(descriptors, repo, rows) {
586
+ const prefix = repo === '.' ? '' : `${repo}/`;
587
+ const layer = layerOf(descriptors, repo);
588
+ const of = (rec, rel, change) => ({ collection: rec.collection, id: rec.id, ref: `${rec.collection}/${rec.id}`, path: prefix + rel, repo, layer, change });
589
+ const out = [];
590
+ for (const r of rows) {
591
+ out.push(of(r, r.repoRel, r.verb === 'add' || r.verb === 'rename' ? 'created' : r.verb === 'rm' ? 'deleted' : 'updated'));
592
+ const old = r.verb === 'rename' && r.fromRel ? pathToRecord(descriptors, prefix + r.fromRel) : null;
593
+ if (old) out.push(of(old, r.fromRel, 'deleted'));
594
+ }
595
+ return out;
596
+ }
597
+
598
+ /** `dt changes`: the records changed since `since`, across every repo that holds records. `HEAD` (the
599
+ * default) is the UNCOMMITTED state, each repo against its own HEAD — sampled by the same dry run
600
+ * `dt status` counts with, so the two can never disagree. Any other `since` (a sha or a date) adds
601
+ * the commits since then, read by `deriveEvents`, and folds the two per record. Stateless: no mark
602
+ * file and no cursor, so it is free to run twice and cannot drift from git. */
603
+ export function recordChanges(store, { since = 'HEAD' } = {}) {
604
+ const pending = [];
605
+ for (const r of commitPending(store, { dryRun: true })) if (!r.outside) pending.push(...rowChanges(store.descriptors, r.repo, r.rows));
606
+ const committed = since === 'HEAD' ? [] : deriveEvents(store.root, store.descriptors, since).map((e) => ({
607
+ collection: e.collection, id: e.id, ref: `${e.collection}/${e.id}`, path: e.path, repo: e.repo, layer: layerOf(store.descriptors, e.repo), change: CHANGE_OF[e.type],
608
+ }));
609
+ // `type` is the 0.41.0 spelling of `change`, kept so a reader of the old JSON keeps working
610
+ return foldChanges(committed, pending).map((c) => ({ ...c, type: TYPE_OF[c.change] }));
611
+ }
package/src/compile.js CHANGED
@@ -9,7 +9,7 @@ import { load, dump } from './yaml.js';
9
9
  import { slug } from './template.js';
10
10
  import { walk } from './records.js';
11
11
  import { placedRecords } from './placement.js';
12
- import { viewErrors, viewDisplay, bindingErrors } from './views.js';
12
+ import { viewErrors, viewDisplay, bindingErrors, overlayView } from './views.js';
13
13
  import {
14
14
  normalizeNamespaces, namespaceProblems, unqualifiedProblems, defaultStoragePath, storageOverlaps,
15
15
  baseNameOf, singular, namespaceOf } from './namespace.js';
@@ -426,6 +426,8 @@ export function compile(ws) {
426
426
  const moduleDeps = new Map(); // module name -> [module names] — HARD, must be acyclic
427
427
  const modulePeers = new Map(); // module name -> [collection names] — SOFT, cannot cycle
428
428
  const moduleNamespaces = new Map(); // module name -> [namespaces it DECLARES] (§8, option A)
429
+ const moduleVersions = new Map(); // module name -> its package.json version
430
+ const moduleFloors = new Map(); // module name -> npm `peerDependencies` — a version floor on a sibling module
429
431
  const moduleLocalAssets = []; // {rel, owner, base} — validated with the workspace's own, below
430
432
  // the package.json `dreamteamer` block is a closed set of snake_case keys, the workspace's and
431
433
  // every module's alike — a key outside it is a typo or a spelling this engine does not read
@@ -467,6 +469,10 @@ export function compile(ws) {
467
469
  }
468
470
  moduleNamespaces.set(source.name, ns);
469
471
  }
472
+ if (source.root !== root) {
473
+ moduleVersions.set(source.name, mpkg.version);
474
+ if (mpkg.peerDependencies && typeof mpkg.peerDependencies === 'object') moduleFloors.set(source.name, mpkg.peerDependencies);
475
+ }
470
476
  const range = mpkg.dreamteamer?.engine;
471
477
  if (range && satisfies(engineVer, range) === null) console.warn(`⚠ module ${source.name}: engine range "${range}" not understood by the built-in checker (see src/semver.js) — not verified`);
472
478
  // `dreamteamer.env` (keys the module needs) and, in a module, `dreamteamer.vars` (the
@@ -594,6 +600,21 @@ export function compile(ws) {
594
600
  }
595
601
  }
596
602
  }
603
+ // npm's `peerDependencies` naming ANOTHER discovered module is a VERSION FLOOR: npm refuses the install
604
+ // below it, and this refuses the channels npm never saw — a git_modules clone, an inline copy, an
605
+ // install that went around the peer check. An absent sibling is `dependencies`' business, not this one's.
606
+ {
607
+ const byName = new Map(sources.map((s) => [s.name, s]));
608
+ const misses = [];
609
+ for (const [mod, floors] of moduleFloors) for (const [dep, range] of Object.entries(floors)) {
610
+ const sib = byName.get(dep), have = moduleVersions.get(dep);
611
+ if (!sib || dep === mod) continue;
612
+ const ok = satisfies(have, range);
613
+ if (ok === null) console.warn(`⚠ module ${mod}: peerDependencies range "${range}" for "${dep}" (${have ?? 'no version'}) not understood by the built-in checker (see src/semver.js) — not verified`);
614
+ else if (!ok) misses.push(`module "${mod}" ${moduleVersions.get(mod)} needs "${dep}" ${range} (its peerDependencies) — this workspace has ${have}, from ${CHANNEL_LABEL[sib.channel]}.\n fix: ${sib.channel === 'npm' ? `npm install "${dep}@${range}"` : `bring ${rel(sib.root)} to a version in ${range}`}`);
615
+ }
616
+ if (misses.length) fail(misses.join('\n'));
617
+ }
597
618
  // DFS with an explicit path so the error can print the ring rather than just naming one module
598
619
  {
599
620
  const state = new Map(); // name -> 'open' | 'done'
@@ -621,6 +642,14 @@ export function compile(ws) {
621
642
 
622
643
  /** entries: runtime-relative path -> { sources: [workspace-relative], bytes } */
623
644
  const entries = new Map();
645
+ /** ui-view sources carrying `overlay: true` — merged onto their base after discovery */
646
+ const viewOverlays = [];
647
+ const isViewOverlay = (srcPath) => {
648
+ const text = fs.readFileSync(srcPath, 'utf8');
649
+ // the regex is only a cheap pre-filter, so it must not be stricter than YAML: a trailing comment
650
+ // or space on the flag line still carries the flag (the parsed value is what decides)
651
+ return /^overlay:\s*true\b/m.test(text) && loadSource(text, rel(srcPath))?.overlay === true;
652
+ };
624
653
  const counts = {};
625
654
  /** collection descriptors collected per name, a base and its overlays: name -> [{src, doc, moduleName}] */
626
655
  const descriptorGroups = new Map();
@@ -718,6 +747,13 @@ export function compile(ws) {
718
747
  counts[kind]++;
719
748
  } else if (!isDir) {
720
749
  refuseEmptySource(srcPath);
750
+ // a view OVERLAY is merged onto the view it names once every source is in (below), so
751
+ // discovery order between the two modules never decides which is the base
752
+ if (kind === 'ui-views' && isViewOverlay(srcPath)) {
753
+ viewOverlays.push({ runtimePath: toPosix(path.join(kind, name)), srcPath, moduleName: source.name });
754
+ contributedBy.add(source.name);
755
+ continue;
756
+ }
721
757
  addEntry(path.join(kind, name), srcPath);
722
758
  contributedBy.add(source.name);
723
759
  counts[kind]++;
@@ -734,6 +770,26 @@ export function compile(ws) {
734
770
  }
735
771
  }
736
772
 
773
+ // ---- ui-view overlays: a same-id view carrying `overlay: true` MERGES onto the shipped one --------
774
+ // The way a collection overlay refines a descriptor it does not own, so a workspace changes a
775
+ // package's view in the few lines that differ instead of copying it (and losing every later fix
776
+ // the package ships). DEEP, overlay wins at the leaves, a list is replaced whole, and `null`
777
+ // REMOVES the key — the one spelling an overlay has for "the package sets this; I do not". A
778
+ // view without the flag and the same id is still the collision `addEntry` names.
779
+ const ownerOf = (file) => sources.map((s) => ({ s, at: rel(s.root) })).filter(({ at }) => !at || file.startsWith(`${at}/`)).sort((a, b) => b.at.length - a.at.length)[0]?.s;
780
+ for (const o of viewOverlays) {
781
+ const e = entries.get(o.runtimePath);
782
+ const id = path.posix.basename(o.runtimePath).replace(/\.ui-view\.yaml$/, '');
783
+ if (!e) fail(`${rel(o.srcPath)}: an overlay of ui-view "${id}" (overlay: true), but no module ships a view "${id}" — drop \`overlay: true\` to make it a view of its own, or install the module that ships it.`);
784
+ const bytes = fs.readFileSync(o.srcPath);
785
+ const { overlay: _flag, ...ov } = loadSource(bytes.toString('utf8'), rel(o.srcPath)) ?? {};
786
+ const merged = overlayView(loadSource(e.bytes.toString('utf8'), e.sources[0].path) ?? {}, ov);
787
+ e.bytes = Buffer.from(dump(merged));
788
+ e.sources.push({ path: rel(o.srcPath), hash: sha256(bytes) });
789
+ e.module ??= moduleId(ownerOf(e.sources[0].path)?.name ?? '');
790
+ (e.overlaidBy ??= []).push(moduleId(o.moduleName));
791
+ }
792
+
737
793
  // ---- stage module UI bundles ---------------------------------------------------
738
794
  // modules ship a PRE-BUILT app.js that registers components/layouts against the surface's
739
795
  // registry (design "the UI": components are module code, never records). staged under
@@ -1042,7 +1098,8 @@ export function compile(ws) {
1042
1098
  if (errors.length) fail(errors.join('\n '));
1043
1099
  for (const w of warnings) console.warn(`⚠ ${w}`);
1044
1100
  const text = e.bytes.toString('utf8');
1045
- e.bytes = Buffer.from(`${text}${text.endsWith('\n') ? '' : '\n'}${dump({ compiled: { display: viewDisplay(d ? displayOf(d) : {}, view) } })}`);
1101
+ const provenance = e.overlaidBy ? { module: e.module, overlaid_by: e.overlaidBy } : {};
1102
+ e.bytes = Buffer.from(`${text}${text.endsWith('\n') ? '' : '\n'}${dump({ compiled: { display: viewDisplay(d ? displayOf(d) : {}, view), ...provenance } })}`);
1046
1103
  }
1047
1104
  // a command's id is its path under commands/, folders included: `commands/rnd/design.command.md` is
1048
1105
  // `rnd/design`, typed as `/rnd:design` — the folder is the namespace, as claude-code already reads it
package/src/events.js CHANGED
@@ -134,3 +134,68 @@ export function eventCommit(root, fromSha, toSha, relPath) {
134
134
  .toString().trim();
135
135
  return out || toSha;
136
136
  }
137
+
138
+ // ── the record-change report (0.42.0) ────────────────────────────────────────────────────────────
139
+ // What `dt changes` and `dt commit` print, and what a session appends to its reply after a write.
140
+ // A change is `{ collection, id, ref, path, repo, layer, change }` with `change` one of the three
141
+ // words the report uses; `deriveEvents`' `item-*` types are the same three facts, older spelling.
142
+ export const CHANGE_OF = { 'item-added': 'created', 'item-updated': 'updated', 'item-removed': 'deleted' };
143
+ export const TYPE_OF = { created: 'item-added', updated: 'item-updated', deleted: 'item-removed' };
144
+
145
+ /** `before` (the committed half, oldest first) folded with `after` (the pending half) — one entry per
146
+ * record per repo, `committed` true when no pending part is left. Inside one half a ref can appear
147
+ * twice only as a MOVE (a relocate, a placed record re-parented: deleted at one path, created at
148
+ * another), which is one update at the live path. Across the halves the net change wins: created
149
+ * then deleted never existed at either end and is dropped; created then edited is still created;
150
+ * deleted then re-created is an update. The SAME ref in two repos is two records — a layer's copy
151
+ * is not the workspace's. */
152
+ export function foldChanges(before, after) {
153
+ const key = (c) => `${c.repo}\0${c.ref}`;
154
+ const half = (list) => {
155
+ const m = new Map();
156
+ for (const c of list) {
157
+ const had = m.get(key(c));
158
+ m.set(key(c), had ? { ...(c.change === 'deleted' ? had : c), change: 'updated' } : c);
159
+ }
160
+ return m;
161
+ };
162
+ const out = new Map();
163
+ for (const [k, c] of half(before)) out.set(k, { ...c, committed: true });
164
+ for (const [k, c] of half(after)) {
165
+ const was = out.get(k)?.change;
166
+ const change = !was ? c.change
167
+ : was === 'created' ? (c.change === 'deleted' ? null : 'created')
168
+ : was === 'deleted' && c.change === 'created' ? 'updated' : c.change;
169
+ if (change) out.set(k, { ...c, change, committed: false });
170
+ else out.delete(k);
171
+ }
172
+ const order = (c) => [c.collection, c.layer ?? '', c.id];
173
+ return [...out.values()].sort((a, b) => {
174
+ const [x, y] = [order(a), order(b)];
175
+ for (let i = 0; i < x.length; i++) if (x[i] !== y[i]) return x[i] < y[i] ? -1 : 1;
176
+ return 0;
177
+ });
178
+ }
179
+
180
+ /** One group per collection AND layer, in the order `foldChanges` sorted them: a collection changed
181
+ * both here and in a layer is two entries, so the line never hides which repo a write landed in. */
182
+ export function groupChanges(changes) {
183
+ const groups = new Map();
184
+ for (const c of changes) {
185
+ const k = `${c.collection}\0${c.layer ?? ''}`;
186
+ if (!groups.has(k)) groups.set(k, { collection: c.collection, layer: c.layer ?? null, created: 0, updated: 0, deleted: 0, records: [] });
187
+ const g = groups.get(k);
188
+ g[c.change]++;
189
+ g.records.push(c);
190
+ }
191
+ return [...groups.values()];
192
+ }
193
+
194
+ /** `records — contacts: 1 created, 2 updated · issues (project-a): 1 created` — the report's first
195
+ * line, the one the skill tells a session to end its reply with. Empty when nothing changed: the
196
+ * rule is that nothing written appends nothing. */
197
+ export function reportLine(groups) {
198
+ if (!groups.length) return '';
199
+ const counts = (g) => ['created', 'updated', 'deleted'].filter((w) => g[w]).map((w) => `${g[w]} ${w}`).join(', ');
200
+ return `records — ${groups.map((g) => `${g.collection}${g.layer ? ` (${g.layer})` : ''}: ${counts(g)}`).join(' · ')}`;
201
+ }
package/src/extensions.js CHANGED
@@ -21,6 +21,7 @@
21
21
  // hooks { <ClaudeHookEvent>: '<dt verb args>' } rendered by `dt install --print-adapters`
22
22
  // check ({ root, ws, dt }) → [{ file, message }] cross-record rules `dt check` reports after the schema's
23
23
  // doctor ({ root, ws, dt }) → [{ label, state, detail?, fix? }] rows `dt doctor` renders as one capability
24
+ // next ({ root, ws, collection, ids }) → [{ id, text }] a line about a record `dt next` prints (sync)
24
25
  //
25
26
  // Two contributions claiming the same verb, kind or harness is a refusal — there is no "last one
26
27
  // wins", because the loser would be an extension the operator installed that silently does nothing.
@@ -52,7 +53,7 @@ export function v1ManifestRefusal(block, where) {
52
53
 
53
54
  export const EXTENSION_API = 1;
54
55
 
55
- const CONTRIBUTION_KEYS = new Set(['commands', 'sourceKinds', 'analyze', 'harnesses', 'orientation', 'hooks', 'check', 'doctor']);
56
+ const CONTRIBUTION_KEYS = new Set(['commands', 'sourceKinds', 'analyze', 'harnesses', 'orientation', 'hooks', 'check', 'doctor', 'next']);
56
57
 
57
58
  /** The modules that declare an extension entry: the workspace's own `modules/<id>/` first, then each
58
59
  * clone under `git_modules/` (the clone's root, then the modules it bundles under `modules/`), then its
@@ -151,12 +152,32 @@ export async function loadExtensions(ws, api, reserved = {}) {
151
152
  const sourceKinds = (c.sourceKinds ?? []).map((k) => normalizeKind(ext.name, k));
152
153
  for (const k of sourceKinds) claim('kind', k.kind, ext.name);
153
154
  for (const id of Object.keys(c.harnesses ?? {})) claim('harness', id, ext.name);
154
- for (const fn of ['analyze', 'check', 'doctor']) if (c[fn] !== undefined && typeof c[fn] !== 'function') throw new Error(`extension ${ext.name}: ${fn} must be a function`);
155
- loaded.push({ name: ext.name, version: ext.version, commands, sourceKinds, analyze: c.analyze ?? null, harnesses: c.harnesses ?? {}, orientation: c.orientation ?? null, hooks: c.hooks ?? {}, check: c.check ?? null, doctor: c.doctor ?? null });
155
+ for (const fn of ['analyze', 'check', 'doctor', 'next']) if (c[fn] !== undefined && typeof c[fn] !== 'function') throw new Error(`extension ${ext.name}: ${fn} must be a function`);
156
+ loaded.push({ name: ext.name, version: ext.version, commands, sourceKinds, analyze: c.analyze ?? null, harnesses: c.harnesses ?? {}, orientation: c.orientation ?? null, hooks: c.hooks ?? {}, check: c.check ?? null, doctor: c.doctor ?? null, next: c.next ?? null });
156
157
  }
157
158
  return loaded;
158
159
  }
159
160
 
161
+ /**
162
+ * What every extension's `next` says about the records `ids` of `collection` — the lines `dt next`
163
+ * prints under the bound commands, and the editor draws on a row and a page. SYNCHRONOUS, like the
164
+ * store it reads: `dt next` is a sync verb. A line about an id that was not asked about, or one with no
165
+ * text, is dropped; a throw is ONE line attributed to the extension (`error: true`), never a failed
166
+ * `dt next` — what a record can do next does not depend on an optional tool being healthy.
167
+ */
168
+ export function contributedNotes(ws, collection, ids = []) {
169
+ const out = [];
170
+ const asked = new Set(ids);
171
+ for (const e of (ws.extensions ?? []).filter((x) => x.next)) {
172
+ try {
173
+ for (const n of e.next({ root: ws.root, ws, collection, ids: [...ids] }) ?? []) {
174
+ if (asked.has(n?.id) && typeof n.text === 'string' && n.text.trim()) out.push({ id: n.id, text: n.text.trim(), by: e.name });
175
+ }
176
+ } catch (err) { out.push({ id: null, text: `next failed — ${String(err?.message ?? err).split('\n')[0]}`, by: e.name, error: true }); }
177
+ }
178
+ return out;
179
+ }
180
+
160
181
  /** A contributed source kind: a plain folder name, and excluded subtrees that stay RELATIVE to it. */
161
182
  function normalizeKind(by, k) {
162
183
  const kind = typeof k === 'string' ? k : k?.kind;
package/src/harnesses.js CHANGED
@@ -511,6 +511,9 @@ function orientationBlock(flavor, skillsIndex, sourceLayout = 'flat', namespaces
511
511
  'files; ids are paths; references are `<collection>/<id>`. run `dreamteamer check` (`npm run',
512
512
  'check`) after bulk edits; run `dreamteamer compile` (`npm run compile`) after changing any',
513
513
  'source or installing modules.',
514
+ // the record report (0.42.0): the RULE is here because this block is in every turn and the reply
515
+ // that owes it may be forty turns past the skill's loading; the FORMAT lives in the skill only
516
+ 'a reply that wrote records ends with the record report `dt changes` prints — the format is in the skill.',
514
517
  ];
515
518
  // an installed extension's own paragraph — how an optional tool tells every session it exists
516
519
  for (const p of extra.paragraphs) lines.push(p.trim());
package/src/schema-ops.js CHANGED
@@ -11,11 +11,11 @@ import { load, dump, writeSource, renameKeys, commentCount, formatSource } from
11
11
  import { compile, kindDir, KINDS, repoRootOf, discoverModules } from './compile.js';
12
12
  import { V2_KEYS, isV2 } from './descriptor-v2.js';
13
13
  import { v1Refusal } from './compile-collections.js';
14
- import { readManifest, loadDescriptors } from './runtime.js';
14
+ import { readManifest, loadDescriptors, engineId } from './runtime.js';
15
15
  import { normalizeNamespaces, namespaceOf, baseNameOf, qualify, defaultStoragePath, singular } from './namespace.js';
16
16
  import { fieldsOf, targetsOf, storageOf, isRuntime, bodyFieldOf, moduleOf } from './descriptor.js';
17
17
  import { SCALAR_TYPES, enumValues, INJECTED_FIELDS } from './fields.js';
18
- import { FIELD_OPTIONS, TEMPLATE_OPTIONS } from './views.js';
18
+ import { FIELD_OPTIONS, TEMPLATE_OPTIONS, viewOverlayOf } from './views.js';
19
19
 
20
20
  // Same rule as store.js: a git failure we CATCH must not also print git's own error on top of the
21
21
  // clean message we throw. stdout stays piped because some callers read it.
@@ -849,7 +849,12 @@ export function setCollectionScalars(ws, store, name, changes, { moduleId } = {}
849
849
  // silently win over the owner's choice.
850
850
  const owned = baseDescriptorSource(ws, name).base;
851
851
  if (owned && IN_NODE_MODULES(owned)) {
852
- throw new Error(`"${name}" ships from node_modules (${owned}) — a write there is erased by the next \`npm install\`, and a collection-level key belongs to the module that owns it. Add "collections/${name}" to dreamteamer.disable and declare your own instead.`);
852
+ // How the collection is DRAWN is the one collection-level thing a workspace may change about a
853
+ // package's collection — compile already merges an overlay's `display` per sub-block — so a
854
+ // display write becomes that overlay. Every other key belongs to the module that owns it.
855
+ const notDisplay = Object.keys(changes).filter((k) => !k.startsWith('display.'));
856
+ if (!notDisplay.length) return setCollectionDisplayOverlay(ws, store, name, changes, owned);
857
+ throw new Error(`"${name}" ships from node_modules (${owned}) — a write there is erased by the next \`npm install\`, and a collection-level key (${notDisplay.join(', ')}) belongs to the module that owns it. Its display.* keys can be changed from here (they are written as an overlay in the workspace module); for the rest, add "collections/${name}" to dreamteamer.disable and declare your own instead.`);
853
858
  }
854
859
  const { file } = collectionSourceFile(ws, store, name, moduleId, { subject: name });
855
860
  if (!fs.existsSync(file)) throw new Error(`${path.relative(ws.root, file)} is not on disk — run \`dreamteamer compile\` and re-run.`);
@@ -868,6 +873,64 @@ export function setCollectionScalars(ws, store, name, changes, { moduleId } = {}
868
873
  return { name, file, changed, commits: gate.commits, unchanged: gate.unchanged };
869
874
  }
870
875
 
876
+ /**
877
+ * A package collection's DISPLAY, changed from the workspace: the `display.*` keys that differ from the
878
+ * package's own source, written into the workspace module's overlay of it (created, updated, or removed
879
+ * when nothing differs any more). A cleared key falls back to the package's value — an overlay can
880
+ * refine a block and cannot delete from it. `options` is written WHOLE when any option differs:
881
+ * compile merges `display.<block>` one key deep, so a lone option would drop every option the package
882
+ * sets beside it.
883
+ */
884
+ function setCollectionDisplayOverlay(ws, store, name, changes, owned) {
885
+ const { file } = collectionSourceFile(ws, store, name, undefined, { subject: name });
886
+ const base = load(fs.readFileSync(path.join(ws.root, owned), 'utf8')) ?? {};
887
+ const existed = fs.existsSync(file);
888
+ const previousText = existed ? fs.readFileSync(file, 'utf8') : null;
889
+ // `fields: {}` is what makes a source v2 at all (`isV2`), the same scaffold add-field writes
890
+ const doc = existed ? load(previousText) : { name, overlay: true, fields: {} };
891
+ const at = (o, dotted) => dotted.split('.').reduce((n, k) => (n && typeof n === 'object' ? n[k] : undefined), o);
892
+ const same = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
893
+ const changed = [];
894
+ for (const [k, raw] of Object.entries(changes)) {
895
+ const clear = raw === '' || raw === null;
896
+ const opt = /^(display\.[^.]+\.options)\.(.+)$/.exec(k);
897
+ if (opt) {
898
+ const options = structuredClone(at(doc, opt[1]) ?? at(base, opt[1]) ?? {});
899
+ if (clear) delete options[opt[2]];
900
+ else options[opt[2]] = settableOf(k)(raw);
901
+ if (same(options, at(base, opt[1]))) deletePath(doc, opt[1]);
902
+ else setPath(doc, opt[1], options);
903
+ } else {
904
+ const value = clear ? undefined : settableOf(k)(raw);
905
+ if (clear || same(value, at(base, k))) deletePath(doc, k);
906
+ else setPath(doc, k, value);
907
+ }
908
+ changed.push(k);
909
+ }
910
+ const empty = Object.keys(doc).every((k) => ['name', 'overlay'].includes(k) || (k === 'fields' && !Object.keys(doc.fields ?? {}).length));
911
+ if (empty && !existed) return { name, file, changed, overlay: true, unchanged: true };
912
+ // compile refuses an overlay whose module neither depends on the base's module nor lists the
913
+ // collection in `peer_collections`. The PEER declaration is the one that fits a display overlay —
914
+ // it applies while the package is installed and is inert once it is not — so it is written for the
915
+ // person in the same gated write, rather than handed back as compile's remedy to type.
916
+ const wmPkg = path.join(ws.pkg.dreamteamer?.workspace_module ? path.join(ws.root, 'modules', ws.pkg.dreamteamer.workspace_module) : ws.root, 'package.json');
917
+ const owner = moduleRows(store).filter((r) => owned.startsWith(`${r.fields.path}/`)).sort((a, b) => b.fields.path.length - a.fields.path.length)[0];
918
+ const declared = (JSON.parse(fs.readFileSync(wmPkg, 'utf8')).dreamteamer ?? {});
919
+ const ownerPkg = owner ? packageNameOf(store, owner.id) : null;
920
+ // the engine's own collections are every module's to overlay (compile asks nothing of those)
921
+ const needsPeer = !empty && ownerPkg !== engineId().replace(/@[^@]*$/, '') && !(declared.peer_collections ?? []).includes(name)
922
+ && !(ownerPkg && (declared.dependencies ?? []).includes(ownerPkg));
923
+ const gate = writeGated(ws, store, needsPeer ? [file, wmPkg] : [file], `dreamteamer: collections set ${name} ${Object.keys(changes).join(' ')} (overlay)`, () => {
924
+ if (empty) return fs.rmSync(file);
925
+ fs.mkdirSync(path.dirname(file), { recursive: true });
926
+ fs.writeFileSync(file, writeSource(previousText, doc));
927
+ if (needsPeer) editModulePkg(wmPkg, (dt) => { dt.peer_collections = [...(dt.peer_collections ?? []), name]; });
928
+ }, undefined, { commentsMayDecrease: true });
929
+ // the declaration is a write to the module's manifest, so the result names it for every surface to say
930
+ const peer = needsPeer ? { collection: name, module: ws.pkg.dreamteamer?.workspace_module ?? ws.pkg.name } : undefined;
931
+ return { name, file, changed, overlay: true, removed: empty || undefined, peer, commits: gate.commits, unchanged: gate.unchanged };
932
+ }
933
+
871
934
  // ---- the positions that name a field, and a value ----------------------------------------------
872
935
  // A field is referenced BY NAME, not as a `<collection>/<id>` reference, so `store.rewriteRefs` can
873
936
  // see none of it. Rule 6 is the list of every position a descriptor, a view or a binding may name a
@@ -2549,14 +2612,21 @@ export function saveUiView(ws, store, { id, view, moduleId }) {
2549
2612
  // would later object to. An explicit target module resolves the destination; without one the
2550
2613
  // manifest answers (an existing view is edited where it lives), and the workspace module is the
2551
2614
  // fallback for a new one.
2552
- const { file: dest, shipped } = moduleId
2553
- ? { file: path.join(kindDir(path.join(ws.root, moduleRecord(store, moduleId).fields.path), 'ui-views'), `${id}.ui-view.yaml`), shipped: null }
2615
+ const target = moduleId ? moduleRecord(store, moduleId) : null;
2616
+ if (target && IN_NODE_MODULES(target.fields.path)) {
2617
+ throw new Error(`module "${moduleId}" ships from node_modules (${target.fields.path}) — a write there is erased by the next npm install.\n pick a module whose sources are in this workspace (the workspace module is the default).`);
2618
+ }
2619
+ const { file: dest, shipped } = target
2620
+ ? { file: path.join(kindDir(path.join(ws.root, target.fields.path), 'ui-views'), `${id}.ui-view.yaml`), shipped: null }
2554
2621
  : uiViewSourceFile(ws, id);
2555
- if (shipped && /(^|\/)node_modules\//.test(shipped))
2556
- throw new Error(`ui-view "${id}" is shipped by an installed package (${shipped}) — a write there is erased by the next npm install.\n save it under a different name, or disable it (dreamteamer.disable) and re-create it.`);
2557
- const existed = fs.existsSync(dest);
2558
2622
  // `compiled` is compile's: a view read back from the runtime carries it, and a source never does
2559
- view = Object.fromEntries(Object.entries(view).filter(([k]) => k !== 'compiled'));
2623
+ view = Object.fromEntries(Object.entries(view).filter(([k]) => k !== 'compiled' && k !== 'overlay'));
2624
+ // A view an installed package ships is never written where npm would erase it, and never refused
2625
+ // either: the save becomes an OVERLAY in the workspace module carrying only what differs from the
2626
+ // package's source, which compile merges onto it (`overlay: true`, compile.js). A changed column
2627
+ // list is a few lines, and every later fix the package ships still reaches the rest of the view.
2628
+ if (shipped && IN_NODE_MODULES(shipped)) return saveUiViewOverlay(ws, store, id, view, shipped);
2629
+ const existed = fs.existsSync(dest);
2560
2630
  // A module source is where this project writes down WHY a view exists; `dump` cannot keep that.
2561
2631
  const previous = existed ? fs.readFileSync(dest, 'utf8') : null;
2562
2632
  // ⚠ opted OUT of the comment invariant, on the same rule `rm-field` is: this write REPLACES
@@ -2570,6 +2640,66 @@ export function saveUiView(ws, store, { id, view, moduleId }) {
2570
2640
  return { id, file: dest, updated: existed, commits: gate.commits, unchanged: gate.unchanged };
2571
2641
  }
2572
2642
 
2643
+ /** The save of a package's view: the workspace module's overlay, rewritten from the package source
2644
+ * each time (never stacked on the previous overlay), and removed when the view equals the package's. */
2645
+ function saveUiViewOverlay(ws, store, id, view, shipped) {
2646
+ const dest = path.join(workspaceSystemDir(ws, 'ui-views'), `${id}.ui-view.yaml`);
2647
+ const existed = fs.existsSync(dest);
2648
+ const delta = viewOverlayOf(load(fs.readFileSync(path.join(ws.root, shipped), 'utf8')) ?? {}, view);
2649
+ const out = { id, file: dest, overlay: true, overlays: shipped };
2650
+ if (!Object.keys(delta).length && !existed) return { ...out, updated: false, unchanged: true };
2651
+ const previous = existed ? fs.readFileSync(dest, 'utf8') : null;
2652
+ const gate = writeGated(ws, store, [dest], `dreamteamer: ui-views overlay ${id}`, () => {
2653
+ if (!Object.keys(delta).length) return fs.rmSync(dest);
2654
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
2655
+ fs.writeFileSync(dest, writeSource(previous, { overlay: true, ...delta }));
2656
+ }, undefined, { commentsMayDecrease: true });
2657
+ return { ...out, updated: existed, removed: !Object.keys(delta).length || undefined, commits: gate.commits, unchanged: gate.unchanged };
2658
+ }
2659
+
2660
+ /**
2661
+ * `dt set ui-views/<id> module=<m>` — MOVE a view's source to another module, the way `moveCollection`
2662
+ * moves a descriptor: the same bytes at the new path (a view's comments are its module's reasoning),
2663
+ * the old file gone, one compile gate, one commit per repo it touches — so a move into a linked
2664
+ * clone's module commits there, ready to publish with that module.
2665
+ */
2666
+ export function moveUiView(ws, store, id, toModule, { dryRun = false } = {}) {
2667
+ const { shipped } = uiViewSourceFile(ws, id);
2668
+ if (!shipped) throw new Error(`ui-view "${id}" does not exist`);
2669
+ if (IN_NODE_MODULES(shipped)) {
2670
+ throw new Error(`ui-view "${id}" is shipped by an installed package (${shipped}) — it moves with its package, not from here.\n save it under a new name, then move that one.`);
2671
+ }
2672
+ const to = moduleRecord(store, toModule); // throws with the known-module list
2673
+ if (IN_NODE_MODULES(to.fields.path)) {
2674
+ throw new Error(`module "${toModule}" ships from node_modules (${to.fields.path}) — a write there is erased by the next npm install.\n pick a module whose sources are in this workspace.`);
2675
+ }
2676
+ const owner = moduleRows(store).filter((r) => shipped.startsWith(`${r.fields.path}/`)).sort((a, b) => b.fields.path.length - a.fields.path.length)[0];
2677
+ const src = path.join(ws.root, shipped);
2678
+ const dest = path.join(kindDir(path.join(ws.root, to.fields.path), 'ui-views'), `${id}.ui-view.yaml`);
2679
+ const plan = { id, from: owner?.id ?? null, to: toModule, file: path.relative(ws.root, dest) };
2680
+ if (path.resolve(dest) === path.resolve(src)) return { ...plan, moved: false };
2681
+ if (fs.existsSync(dest)) throw new Error(`${plan.file} already exists — move or remove it first; nothing was moved`);
2682
+ if (dryRun) return { ...plan, moved: false, dryRun: true };
2683
+ const bytes = fs.readFileSync(src);
2684
+ let moved = false;
2685
+ const out = gatedTreeOp(ws, store, {
2686
+ subject: `dreamteamer: ui-views set ${id} module=${toModule}`,
2687
+ paths: [shipped, plan.file],
2688
+ mutate: () => {
2689
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
2690
+ fs.writeFileSync(dest, bytes);
2691
+ fs.rmSync(src);
2692
+ moved = true;
2693
+ },
2694
+ undo: () => {
2695
+ if (moved && fs.existsSync(dest)) fs.rmSync(dest);
2696
+ fs.mkdirSync(path.dirname(src), { recursive: true });
2697
+ fs.writeFileSync(src, bytes);
2698
+ },
2699
+ });
2700
+ return { ...plan, moved: true, commits: out.commits };
2701
+ }
2702
+
2573
2703
  export function removeUiView(ws, store, id) {
2574
2704
  // Same source resolution as the save above — an inline module's view is under this repo's git
2575
2705
  // history like everything else, so deleting it is one revertable commit. Refusing it while
package/src/views.js CHANGED
@@ -174,3 +174,33 @@ export function viewDisplay(collectionDisplay, view) {
174
174
  }
175
175
  return out;
176
176
  }
177
+
178
+ // ---- view overlays ---------------------------------------------------------------------------------
179
+ // A ui-view source with `overlay: true` and the id of a view another module ships is MERGED onto it at
180
+ // compile (compile.js). These two are the whole grammar, and inverse: `overlayView(base, viewOverlayOf(
181
+ // base, view))` is `view` again, which is what lets a save over a package's view write only what differs.
182
+
183
+ /** `base` refined by `overlay`: deep, overlay wins at a leaf, a list is replaced whole, `null` removes. */
184
+ export function overlayView(base, overlay) {
185
+ const out = structuredClone(base ?? {});
186
+ for (const [k, v] of Object.entries(overlay ?? {})) {
187
+ if (v === null) delete out[k];
188
+ else if (isMap(v) && isMap(out[k])) out[k] = overlayView(out[k], v);
189
+ else out[k] = structuredClone(v);
190
+ }
191
+ return out;
192
+ }
193
+
194
+ /** The smallest overlay turning `base` into `view` — `{}` when they agree. */
195
+ export function viewOverlayOf(base, view) {
196
+ const out = {};
197
+ for (const [k, v] of Object.entries(view ?? {})) {
198
+ const b = base?.[k];
199
+ if (isMap(v) && isMap(b)) {
200
+ const inner = viewOverlayOf(b, v);
201
+ if (Object.keys(inner).length) out[k] = inner;
202
+ } else if (JSON.stringify(v) !== JSON.stringify(b)) out[k] = structuredClone(v);
203
+ }
204
+ for (const k of Object.keys(base ?? {})) if (!(k in (view ?? {}))) out[k] = null;
205
+ return out;
206
+ }