dreamteamer 0.48.1 → 0.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -39
- package/collections/modules.collection.yaml +11 -0
- package/package.json +1 -1
- package/skills/using-dreamteamer/SKILL.md +8 -6
- package/skills/using-dreamteamer/references/before-you-build.md +8 -6
- package/skills/using-dreamteamer/references/collections.md +16 -7
- package/skills/using-dreamteamer/references/commands.md +4 -3
- package/skills/using-dreamteamer/references/data-modeling.md +3 -2
- package/skills/using-dreamteamer/references/extensions.md +13 -12
- package/skills/using-dreamteamer/references/getting-started.md +4 -3
- package/skills/using-dreamteamer/references/records.md +4 -4
- package/skills/using-dreamteamer/references/setup.md +7 -5
- package/skills/using-dreamteamer/references/ui-components.md +1 -1
- package/skills/using-dreamteamer/references/ui-views.md +39 -1
- package/skills/using-dreamteamer/references/writing-a-module.md +3 -2
- package/src/api.d.ts +18 -0
- package/src/api.js +7 -0
- package/src/check-alone.js +58 -8
- package/src/check.js +10 -0
- package/src/cli.js +36 -18
- package/src/collections-cli.js +9 -41
- package/src/compile-collections.js +20 -3
- package/src/compile.js +59 -8
- package/src/extensions.js +1 -1
- package/src/init.js +1 -1
- package/src/install-modules.js +113 -46
- package/src/nav-fragments.js +190 -0
- package/src/nav.js +185 -0
- package/src/schema-ops.js +4 -4
- package/src/semver.js +4 -0
- package/src/setup.js +6 -3
- package/src/store.js +35 -11
- package/src/unread-data.js +74 -0
- package/src/update-setup.js +6 -5
- package/src/update.js +43 -12
- package/src/workspace.js +52 -13
|
@@ -22,6 +22,7 @@ the next compile.
|
|
|
22
22
|
| narrowing the rows | filters |
|
|
23
23
|
| layout settings | options |
|
|
24
24
|
| writing views from the CLI | the verbs |
|
|
25
|
+
| where each collection sits in the left nav | the nav document — nav.yaml |
|
|
25
26
|
|
|
26
27
|
## when a view earns existence
|
|
27
28
|
|
|
@@ -150,7 +151,7 @@ silently. Two edges:
|
|
|
150
151
|
`dt add ui-views --route /people/recent --scope collection --collection collections/people
|
|
151
152
|
display.list.layout=cards`, `dt set ui-views/<id> <dotted.key>=<value>`, `dt rm ui-views/<id>`
|
|
152
153
|
— all through the compile gate, committing themselves. `add` derives the record id from `route`,
|
|
153
|
-
so a view saved from the CLI and one saved from a surface land on the **same record**.
|
|
154
|
+
so a view saved from the CLI and one saved from a surface land on the **same record**. Four edges:
|
|
154
155
|
|
|
155
156
|
- **`add` writes the workspace module** — right for an operator's own daily surface; a view that
|
|
156
157
|
is part of a module's canonical shape belongs in that module's `ui-views/`, hand-written.
|
|
@@ -181,6 +182,42 @@ collections/<c> display.…` on a package's collection writes the keys that diff
|
|
|
181
182
|
in the workspace module (writing `options` whole when one option changes, so none is dropped), says
|
|
182
183
|
when it also declares `<c>` in that module's `peer_collections`, and never writes the package.
|
|
183
184
|
|
|
185
|
+
## the nav document — nav.yaml
|
|
186
|
+
|
|
187
|
+
Where each COLLECTION sits in the left nav is one tracked file at the workspace root, `nav.yaml`, and
|
|
188
|
+
it is the operator's: the editor's drag and drop writes it, and so may you. A ui-view keeps its own
|
|
189
|
+
`display.nav.order`; a collection's `display.nav.order` and `section` are ignored (0.49.0).
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
# The left nav of this workspace. Drag and drop writes this file; so may you.
|
|
193
|
+
tree:
|
|
194
|
+
- folder: Work # label, optional icon, optional hidden: true, items
|
|
195
|
+
icon: rocket
|
|
196
|
+
items: [tasks, projects, { folder: Plans, items: [decisions, risks] }]
|
|
197
|
+
- collection: contacts # the long form, to override the icon
|
|
198
|
+
icon: person
|
|
199
|
+
- namespace: rnd # a namespace folder; no items = all of it unplaced
|
|
200
|
+
items: [rnd/change-requests, { folder: Product, items: [rnd/user-stories] }]
|
|
201
|
+
hidden: [file-drives] # rows not drawn; a hidden name counts as placed
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
- **A collection the file does not name draws after the tree**, alphabetical; a namespaced one inside
|
|
205
|
+
its namespace's folder. A name listed twice draws at its first place. `dt check` prints a ⚠ line for
|
|
206
|
+
a name that resolves to nothing, a name listed twice and a file it cannot read, never a violation.
|
|
207
|
+
- **A module ships a fragment** (`dreamteamer.nav`, `collections.md`). After `dt install` and
|
|
208
|
+
`dt update` compile, the fragments of what they installed are merged in and `nav.yaml` joins their
|
|
209
|
+
commit. The merge only ADDS rows the file does not place yet, never moves one. A same-label folder
|
|
210
|
+
or the same namespace AT THE SAME LEVEL is reused. A folder whose rows are all placed is not created.
|
|
211
|
+
A fragment row nothing installed owns is dropped quietly (a removed preset member). A row another
|
|
212
|
+
module owns refuses the whole call, and the pre-image comes back.
|
|
213
|
+
- **Old nav settings** (`dreamteamer.navGroups`, `navOrder`, `navHidden` in `.vscode/settings.json`)
|
|
214
|
+
with no `nav.yaml` make install of a package that ships a fragment, and update of any module, refuse
|
|
215
|
+
before npm. Migrate first with `npx -p @dreamteamer/protocol@0.3 dt-nav migrate`, or open the
|
|
216
|
+
workspace once in the editor 0.27 or later. `--allow nav-reset` starts from the fragments and leaves
|
|
217
|
+
the settings unread. `dt update --engine` is never refused.
|
|
218
|
+
- **A host writes through the engine**: `readNavDoc`, `validateNavDoc`, `writeNavDoc` and
|
|
219
|
+
`applyNavFragments` on `import('dreamteamer')`. There is one grammar and one writer.
|
|
220
|
+
|
|
184
221
|
## common mistakes
|
|
185
222
|
|
|
186
223
|
| mistake | reality |
|
|
@@ -192,4 +229,5 @@ when it also declares `<c>` in that module's `peer_collections`, and never write
|
|
|
192
229
|
| `filter` written inside `options` | read by nobody — compile warns; move it up |
|
|
193
230
|
| a view to change the collection's default columns | edit the collection's `display.list` — every surface follows |
|
|
194
231
|
| omitting `nav` and expecting a sidebar entry | a view's nav is never inherited |
|
|
232
|
+
| `display.nav.order` on a collection to move its row | ignored since 0.49 — move the row in `nav.yaml` |
|
|
195
233
|
| a module ui-view naming one person | a hard-coded id resolves in no other workspace |
|
|
@@ -111,8 +111,9 @@ dt check modules/acme --alone
|
|
|
111
111
|
Packs the module, installs it into a fresh workspace on this engine with only its declared
|
|
112
112
|
`dreamteamer.dependencies` (packed from this workspace, never fetched), compiles, checks, and prints
|
|
113
113
|
its setup line. **Exit 0 is publishable** — including a unit still waiting for an input a stranger
|
|
114
|
-
will give. Exit 1 names what is wrong (a dependency not held here, a
|
|
115
|
-
|
|
114
|
+
will give. Exit 1 names what is wrong (a dependency not held here, a module preset member named with
|
|
115
|
+
its pin, a floor above this engine, a `files` list that leaves out a source the module authors — a kind
|
|
116
|
+
folder, its UI bundle, its nav fragment — a compile or check error); 2 is usage. `--keep` leaves the temp
|
|
116
117
|
workspace. It does not run your `npm test` — run both. It packs with `--ignore-scripts` (it runs none of
|
|
117
118
|
your code); `pack()` in your own tests runs your `prepack`. A module that builds in `prepack` ships its
|
|
118
119
|
built files in `files`, or the gate judges the unbuilt package.
|
package/src/api.d.ts
CHANGED
|
@@ -95,6 +95,24 @@ export function validateTemplate(tpl: string, ctx: { position: string; fields: I
|
|
|
95
95
|
export function renderDisplay(tpl: string, record: Record<string, unknown>, opts?: { resolve?: (ref: string) => string | undefined; isReference?: (field: string) => boolean }): string;
|
|
96
96
|
export function satisfies(version: string, range: string): boolean | null;
|
|
97
97
|
|
|
98
|
+
// ---- the nav document (nav.yaml) --------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
/** One entry of nav.yaml's tree: a collection by name, its long form, a folder, or a namespace folder. */
|
|
101
|
+
export type NavEntry =
|
|
102
|
+
| string
|
|
103
|
+
| { collection: string; icon?: string }
|
|
104
|
+
| { folder: string; icon?: string; hidden?: boolean; items: NavEntry[] }
|
|
105
|
+
| { namespace: string; icon?: string; hidden?: boolean; items?: NavEntry[] };
|
|
106
|
+
export type NavDoc = { tree: NavEntry[]; hidden: string[] };
|
|
107
|
+
/** `<root>/nav.yaml`, or null when absent; throws a NavDocError (its message names the problem) when it cannot be read or is not a mapping. */
|
|
108
|
+
export function readNavDoc(root: string): NavDoc | null;
|
|
109
|
+
/** What `dt check` reports: unknown collections and namespaces, names listed twice. */
|
|
110
|
+
export function validateNavDoc(doc: NavDoc, ctx: { collections: Set<string>; namespaces: string[] }): { warning: string }[];
|
|
111
|
+
/** The one writer: the whole document, atomically, under its header line. Returns false when the bytes were already there. */
|
|
112
|
+
export function writeNavDoc(root: string, doc: NavDoc): boolean;
|
|
113
|
+
/** The installed modules' nav fragments merged into nav.yaml (written only when something was placed); throws NavFragmentRefusal for a fragment placing another module's collection. */
|
|
114
|
+
export function applyNavFragments(root: string, opts?: { names?: string[]; ignoreSettings?: boolean }): { written: boolean; placed: string[]; skipped?: 'settings' };
|
|
115
|
+
|
|
98
116
|
// ---- the compiler, schema and module operations --------------------------------------------------
|
|
99
117
|
|
|
100
118
|
/** throws CompileError on a bad source; prints its summary; returns 0 */
|
package/src/api.js
CHANGED
|
@@ -15,6 +15,7 @@ import { findWorkspace } from './workspace.js';
|
|
|
15
15
|
import { loadExtensions, manifestViolations } from './extensions.js';
|
|
16
16
|
import fs from 'node:fs';
|
|
17
17
|
import { KINDS, discoverModules } from './compile.js';
|
|
18
|
+
import { unreadDataWarnings } from './unread-data.js';
|
|
18
19
|
import { DERIVED_KINDS } from './runtime.js';
|
|
19
20
|
import { KNOWN_HARNESSES } from './harnesses.js';
|
|
20
21
|
import { CORE_VERBS } from './cli.js';
|
|
@@ -58,6 +59,8 @@ export async function contributedViolations(ws) {
|
|
|
58
59
|
for (const v of manifestViolations(pkg, path.relative(ws.root, path.join(m.root, 'package.json')))) out.push({ file: v.file, msg: v.message });
|
|
59
60
|
}
|
|
60
61
|
} catch { /* discovery failing is compile's to report */ }
|
|
62
|
+
// record files under data/ no compiled collection reads — a collection that left with a module
|
|
63
|
+
try { out.push(...unreadDataWarnings(ws)); } catch { /* a warning pass never breaks check */ }
|
|
61
64
|
for (const e of (ws.extensions ?? []).filter((x) => x.check)) {
|
|
62
65
|
try {
|
|
63
66
|
for (const v of (await e.check({ root: ws.root, ws, dt: self })) ?? []) out.push({ file: v.file ?? e.name, msg: `${v.message} (${e.name})`, ...(v.warning === true ? { warning: true } : {}) });
|
|
@@ -76,6 +79,10 @@ export { envContext, renderTemplate, parseEnvValues } from './env-vars.js';
|
|
|
76
79
|
// `display.record.subtitle`, `card_title` and `item_title` with, so no surface keeps a second parser
|
|
77
80
|
export { parseTemplate, validateTemplate, renderDisplay } from './template.js';
|
|
78
81
|
export { satisfies } from './semver.js';
|
|
82
|
+
// the nav document (cr-dt-008): nav.yaml read, checked and written, and the shipped fragments merged into it —
|
|
83
|
+
// what every host (the editor, dt web) uses, so there is one grammar and one writer
|
|
84
|
+
export { readNavDoc, validateNavDoc, writeNavDoc } from './nav.js';
|
|
85
|
+
export { applyNavFragments } from './nav-fragments.js';
|
|
79
86
|
|
|
80
87
|
// ---- the compiler, schema and module operations ---------------------------------------------------
|
|
81
88
|
export { compile, staleness, warnIfStale, discoverModules, CompileError, KINDS } from './compile.js';
|
package/src/check-alone.js
CHANGED
|
@@ -20,6 +20,7 @@ import path from 'node:path';
|
|
|
20
20
|
import { spawnSync } from 'node:child_process';
|
|
21
21
|
import { fileURLToPath } from 'node:url';
|
|
22
22
|
import { resolveNpm, childEnv } from './checkout.js';
|
|
23
|
+
import { KINDS, kindDir } from './compile.js';
|
|
23
24
|
|
|
24
25
|
const ENGINE = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
25
26
|
const IDENTITY = { GIT_AUTHOR_NAME: 'dreamteamer check', GIT_AUTHOR_EMAIL: 'check@example.invalid', GIT_COMMITTER_NAME: 'dreamteamer check', GIT_COMMITTER_EMAIL: 'check@example.invalid' };
|
|
@@ -57,13 +58,49 @@ function locate(root, name) {
|
|
|
57
58
|
return fs.existsSync(path.join(npm, 'package.json')) ? fs.realpathSync(npm) : null;
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
/** Pack `dir` into `dest`; returns the tarball's name and the package-relative paths it ships (null
|
|
62
|
+
* when npm's --json listing does not parse — the shipped-sources judgement is then skipped). */
|
|
60
63
|
function npmPack(npm, dir, dest) {
|
|
61
64
|
const before = new Set(fs.readdirSync(dest));
|
|
62
|
-
const r = spawnSync(npm, ['pack', '--silent', '--ignore-scripts', '--pack-destination', dest], { cwd: dir, encoding: 'utf8', timeout: 120_000, env: childEnv() });
|
|
65
|
+
const r = spawnSync(npm, ['pack', '--json', '--silent', '--ignore-scripts', '--pack-destination', dest], { cwd: dir, encoding: 'utf8', timeout: 120_000, env: childEnv() });
|
|
63
66
|
if (r.status !== 0) throw new Error(`npm pack failed in ${dir}: ${(r.stderr || r.stdout).trim().split('\n')[0]}`);
|
|
64
|
-
|
|
67
|
+
let files = null;
|
|
68
|
+
try { files = JSON.parse(r.stdout)[0].files.map((f) => f.path.split(path.sep).join('/')); } catch { /* an npm without --json for pack */ }
|
|
69
|
+
return { file: fs.readdirSync(dest).find((f) => f.endsWith('.tgz') && !before.has(f)), files };
|
|
65
70
|
}
|
|
66
71
|
|
|
72
|
+
/** Every file under `rel` in `dir` (dotfiles left out — npm never packs .DS_Store and the like), `/`-joined. */
|
|
73
|
+
function filesUnder(dir, rel) {
|
|
74
|
+
const out = [];
|
|
75
|
+
const walk = (r) => {
|
|
76
|
+
for (const e of fs.readdirSync(path.join(dir, r), { withFileTypes: true })) {
|
|
77
|
+
if (e.name.startsWith('.') || e.name === 'node_modules') continue;
|
|
78
|
+
const sub = `${r}/${e.name}`;
|
|
79
|
+
if (e.isDirectory()) walk(sub); else if (e.isFile()) out.push(sub);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
if (fs.existsSync(path.join(dir, rel)) && fs.statSync(path.join(dir, rel)).isDirectory()) walk(rel);
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* What the source authors that compile would read and the tarball does not ship — the kind folders, a UI
|
|
88
|
+
* bundle and the nav fragment the manifest names — as `{ missing, folder }`, or null when it all ships.
|
|
89
|
+
* A folder left out of the package's `files` list is not published: a stranger installs a module without it.
|
|
90
|
+
*/
|
|
91
|
+
export function unshippedSources(dir, manifest, shipped) {
|
|
92
|
+
if (!shipped) return null;
|
|
93
|
+
const has = new Set(shipped);
|
|
94
|
+
const authored = [];
|
|
95
|
+
for (const k of KINDS) authored.push(...filesUnder(dir, path.relative(dir, kindDir(dir, k)).split(path.sep).join('/')));
|
|
96
|
+
for (const ui of ['ui', 'studio']) authored.push(...filesUnder(dir, ui));
|
|
97
|
+
const nav = manifest.dreamteamer?.nav;
|
|
98
|
+
if (typeof nav === 'string' && fs.existsSync(path.join(dir, nav))) authored.push(nav.split(path.sep).join('/').replace(/^\.\//, ''));
|
|
99
|
+
const missing = authored.filter((f) => !has.has(f));
|
|
100
|
+
return missing.length ? { missing, folder: missing[0].split('/')[0] } : null;
|
|
101
|
+
}
|
|
102
|
+
const unshippedLine = (name, u) => `${name} does not ship ${u.missing[0]}${u.missing.length > 1 ? ` (and ${u.missing.length - 1} more)` : ''} — package.json "files" leaves out ${u.folder}, so a stranger's install would have none of it; add "${u.folder}" to "files"`;
|
|
103
|
+
|
|
67
104
|
/** The gate. `target` is the positional (`modules/<id>`); returns the exit code. */
|
|
68
105
|
export function checkAlone(ws, { target, keep = false, log = console.log, error = console.error } = {}) {
|
|
69
106
|
const usage = (m) => { error(`✖ ${m}`); return 2; };
|
|
@@ -84,19 +121,32 @@ export function checkAlone(ws, { target, keep = false, log = console.log, error
|
|
|
84
121
|
// the module and its declared dependency closure, packed into one folder `dt install --from` reads
|
|
85
122
|
const from = path.join(tmp, 'from');
|
|
86
123
|
fs.mkdirSync(from);
|
|
87
|
-
npmPack(npm, dir, from);
|
|
124
|
+
const own = unshippedSources(dir, pkg, npmPack(npm, dir, from).files);
|
|
125
|
+
if (own) return refuse(unshippedLine(pkg.name, own));
|
|
88
126
|
const deps = [];
|
|
89
127
|
const seen = new Set([pkg.name]);
|
|
90
|
-
|
|
128
|
+
// a module preset's members are packed like dependencies (CR-dt-008): install walks them at their
|
|
129
|
+
// pins. Each need remembers who listed it and under which key, so a missing one is named rightly.
|
|
130
|
+
const needs = (p) => [
|
|
131
|
+
...(p.dreamteamer?.dependencies ?? []).map((name) => ({ name, by: p.name })),
|
|
132
|
+
...Object.entries(p.dreamteamer?.preset ?? {}).map(([name, pin]) => ({ name, by: p.name, pin })),
|
|
133
|
+
];
|
|
134
|
+
const queue = needs(pkg);
|
|
91
135
|
while (queue.length) {
|
|
92
|
-
const name = queue.shift();
|
|
136
|
+
const { name, by, pin } = queue.shift();
|
|
93
137
|
if (seen.has(name)) continue;
|
|
94
138
|
seen.add(name);
|
|
95
139
|
const at = locate(ws.root, name);
|
|
96
|
-
if (!at)
|
|
97
|
-
|
|
140
|
+
if (!at) {
|
|
141
|
+
return refuse(pin !== undefined
|
|
142
|
+
? `module preset member ${name}@${pin} (pinned in ${by}'s dreamteamer.preset) is not here — neither modules/ nor node_modules holds it; bring it back, or drop it from dreamteamer.preset`
|
|
143
|
+
: `dependency ${name} is not installed here — install it, or drop it from dreamteamer.dependencies`);
|
|
144
|
+
}
|
|
145
|
+
const packed = npmPack(npm, at, from);
|
|
146
|
+
const theirs = unshippedSources(at, readPkg(at), packed.files);
|
|
147
|
+
if (theirs) return refuse(`${pin !== undefined ? 'module preset member' : 'dependency'} ${unshippedLine(name, theirs)}`);
|
|
98
148
|
deps.push(name);
|
|
99
|
-
queue.push(...(readPkg(at)
|
|
149
|
+
queue.push(...needs(readPkg(at)));
|
|
100
150
|
}
|
|
101
151
|
// a fresh workspace on this engine, the module installed the way a stranger installs it
|
|
102
152
|
const root = path.join(tmp, 'ws');
|
package/src/check.js
CHANGED
|
@@ -14,6 +14,7 @@ import { parseRef } from './namespace.js';
|
|
|
14
14
|
import { relationsOf, expectedMirrors, ownersReadIn } from './relations.js';
|
|
15
15
|
import { collectRefFields, valuesAt, EXPORTS_FILE, readExports, exportsContext, sees, outsideRefs, regenerate, isStale } from './exports.js';
|
|
16
16
|
import { placementOf, placedRecords, ownerIdOf, symlinkedChildRoots } from './placement.js';
|
|
17
|
+
import { readNavDoc, validateNavDoc, NavDocError } from './nav.js';
|
|
17
18
|
|
|
18
19
|
import { storageOf, jsonSchemaOf, fieldsOf, unresolvedPeersOf, bodyFieldOf, idsOf, recordTitleOf } from './descriptor.js';
|
|
19
20
|
export function check({ root }, { extra = [], strictExport = false } = {}) {
|
|
@@ -380,6 +381,15 @@ export function check({ root }, { extra = [], strictExport = false } = {}) {
|
|
|
380
381
|
console.log(`⚠ peer collection "${coll}" is declared but not installed — ${n} reference${n === 1 ? '' : 's'} unresolvable`);
|
|
381
382
|
}
|
|
382
383
|
for (const w of extra.filter((v) => v.warning)) console.log(`⚠ ${w.file} — ${w.msg}`);
|
|
384
|
+
// the nav document: a name that resolves to nothing or is listed twice is worth seeing, never a
|
|
385
|
+
// violation — the drawing skips the one and draws the other at its first place (design §3 rule 5)
|
|
386
|
+
try {
|
|
387
|
+
const nav = readNavDoc(root);
|
|
388
|
+
if (nav) for (const { warning } of validateNavDoc(nav, { collections: new Set(descriptors.keys()), namespaces })) console.log(`⚠ nav.yaml — ${warning}`);
|
|
389
|
+
} catch (e) {
|
|
390
|
+
if (!(e instanceof NavDocError)) throw e;
|
|
391
|
+
console.log(`⚠ nav.yaml — ${e.message}`);
|
|
392
|
+
}
|
|
383
393
|
if (violations.length === 0) {
|
|
384
394
|
console.log(`✔ 0 violations (${[...index.values()].reduce((n, m) => n + m.size, 0)} records across ${descriptors.size} collections)`);
|
|
385
395
|
return 0;
|
package/src/cli.js
CHANGED
|
@@ -31,7 +31,7 @@ import { splitRef, canonicalCollection } from './ref.js';
|
|
|
31
31
|
import { envContext, renderTemplate } from './env-vars.js';
|
|
32
32
|
import { doctorBoard, renderBoard } from './doctor.js';
|
|
33
33
|
import { setupCommand, statusLines, renderStatusLines } from './setup.js';
|
|
34
|
-
import { installModules } from './install-modules.js';
|
|
34
|
+
import { installModules, presetMembers } from './install-modules.js';
|
|
35
35
|
import { updateModules, parseUpdateArgs } from './update.js';
|
|
36
36
|
import { storageOf } from './descriptor.js';
|
|
37
37
|
|
|
@@ -155,7 +155,9 @@ commits there.
|
|
|
155
155
|
rm <system>/<id> [--force] [--dry-run]
|
|
156
156
|
rename <system>/<id> <new-id> (a collection's rename moves its records, re-suffixes
|
|
157
157
|
the files and rewrites every inbound ref, ONE commit)
|
|
158
|
-
reorder
|
|
158
|
+
reorder collections/<c> … (refused since 0.49: the nav's order is nav.yaml — the
|
|
159
|
+
sidebar's Move entries or a hand edit; display.nav.order
|
|
160
|
+
compiles and moves no row)
|
|
159
161
|
get collections/<c> [--module <m>] (--module prints ONE module's source contribution
|
|
160
162
|
rather than the merged descriptor)
|
|
161
163
|
list modules | collections | skills | … (id · location · path · namespaces · package name)
|
|
@@ -243,28 +245,34 @@ workspace verbs:
|
|
|
243
245
|
checkout ready; --all is the explicit opt-in, e.g. before going offline
|
|
244
246
|
install <spec>… [--from <dir>] bring a MODULE in: a name, name@version, ./file.tgz,
|
|
245
247
|
./folder (a development link) or a git URL — installs it and every module its
|
|
246
|
-
dreamteamer.dependencies names
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
versions, compiles,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
248
|
+
dreamteamer.dependencies names, and a module preset's members at the versions it pins
|
|
249
|
+
(refusing, before npm writes anything, a package with no dreamteamer key, an engine
|
|
250
|
+
floor this engine does not meet, a ring, and a version installed differently), pins
|
|
251
|
+
exact versions, compiles, merges the shipped nav fragments into nav.yaml, runs the
|
|
252
|
+
safe part of the module's setup and commits package.json, package-lock.json, nav.yaml
|
|
253
|
+
and what setup wrote. Without a version: npm's latest. --from resolves names from a
|
|
254
|
+
folder of tarballs (offline). Old nav settings with no nav.yaml refuse a package that
|
|
255
|
+
ships a nav fragment until migrated; [--allow nav-reset] starts from the fragments.
|
|
256
|
+
Setup flags as for \`setup\`: [--input <id>=<value>]… [--allow <kind>]… [--no-input];
|
|
257
|
+
[--no-commit] [--json]
|
|
253
258
|
Exit 0 done · 1 refused or failed (nothing half-written) · 2 usage · 3 input missing
|
|
254
259
|
install --clone <url> [name] attach a git module to this workspace
|
|
255
260
|
update <name>[@<version>] | --engine move ONE npm pin forward on purpose: to the latest
|
|
256
261
|
release (or the named version), re-pinned exactly, closure-checked as install is,
|
|
257
|
-
compiled, committed
|
|
258
|
-
|
|
262
|
+
compiled, committed; a module preset moves its installed members to its new pins.
|
|
263
|
+
A downgrade needs [--allow downgrade]; old nav settings with no nav.yaml refuse a
|
|
264
|
+
module update until migrated, or [--allow nav-reset]; a development link is skipped
|
|
265
|
+
and named; [--from <dir>] resolves from a folder of tarballs; [--no-commit]
|
|
259
266
|
update pull git_modules clones forward (ff-only on the lockfile ref), rebuild,
|
|
260
267
|
then compile; [<name>] updates just one. dirty clones are skipped
|
|
261
268
|
compile materialize modules + workspace sources into .dreamteamer (+ harness adapters)
|
|
262
269
|
[--watch] recompile on source changes
|
|
263
270
|
check validate every record against the compiled descriptors (report-only), then every
|
|
264
271
|
installed extension's own checks. A reference this workspace's own records reach only
|
|
265
|
-
through a record layer is a ⚠ line
|
|
266
|
-
|
|
267
|
-
|
|
272
|
+
through a record layer is a ⚠ line until its exports manifest lists it (a reader
|
|
273
|
+
without that layer sees it dangle); a reference no root answers is external when the
|
|
274
|
+
referring repo's manifest vouches for it. nav.yaml: a name that resolves to nothing or
|
|
275
|
+
is listed twice is a ⚠ line, never a violation
|
|
268
276
|
[--strict-export] makes each unlisted one, and a stale manifest, a violation
|
|
269
277
|
modules/<id> --alone: is that inline module publishable — packed, installed into a fresh
|
|
270
278
|
workspace on this engine with only its declared dependencies, compiled, checked; exit 0
|
|
@@ -301,7 +309,7 @@ workspace verbs:
|
|
|
301
309
|
[<collection>|<collection>/<id> …] [-m <subject>] [--dry-run] [--json]
|
|
302
310
|
help this text
|
|
303
311
|
|
|
304
|
-
extension verbs — an extension (a
|
|
312
|
+
extension verbs — an extension (a module that also ships code: its package.json declares
|
|
305
313
|
\`dreamteamer.extension\`) adds its own verbs, listed below when this workspace has any.
|
|
306
314
|
`;
|
|
307
315
|
|
|
@@ -358,7 +366,7 @@ export const CORE_VERBS = [
|
|
|
358
366
|
* install line. The container verbs belong to the global `dt-docker` bin, which needs no workspace. */
|
|
359
367
|
const VERB_PACKAGES = {
|
|
360
368
|
prove: '@dreamteamer/proofs', land: '@dreamteamer/worktrees', worktree: '@dreamteamer/worktrees',
|
|
361
|
-
serve: '@dreamteamer/
|
|
369
|
+
serve: '@dreamteamer/web', web: '@dreamteamer/web', notebooklm: '@dreamteamer/notebooklm',
|
|
362
370
|
};
|
|
363
371
|
const DOCKER_VERBS = new Set(['start', 'stop', 'open', 'export', 'import']);
|
|
364
372
|
|
|
@@ -612,7 +620,9 @@ export async function run(argv) {
|
|
|
612
620
|
}
|
|
613
621
|
if (rest.includes('--json')) {
|
|
614
622
|
const { modules: mods } = discoverModules(ws.root, ws.pkg);
|
|
615
|
-
|
|
623
|
+
const presets = presetMembers(ws);
|
|
624
|
+
const modEntry = (m) => ({ name: m.name, location: locationOf(m, ws.root), ...(presets.has(m.name) ? { preset: true, members: presets.get(m.name).members } : {}) });
|
|
625
|
+
emit(JSON.stringify({ workspace: { root: ws.root, name: ws.pkg?.name ?? null }, compiled: s.manifest.compiled, stale: s.stale, modules: mods.map(modEntry), setup: statusLines(ws) }, null, 2));
|
|
616
626
|
process.exit(0);
|
|
617
627
|
}
|
|
618
628
|
console.log(`compiled: ${s.manifest.compiled}`);
|
|
@@ -629,6 +639,7 @@ export async function run(argv) {
|
|
|
629
639
|
// provenance is LIVE discovery (not the manifest) — shows what the next compile would use
|
|
630
640
|
const { modules, shadows } = discoverModules(ws.root, ws.pkg);
|
|
631
641
|
const shadowed = new Map(shadows.map((sh) => [sh.name, sh]));
|
|
642
|
+
const presets = presetMembers(ws);
|
|
632
643
|
console.log('modules:');
|
|
633
644
|
for (const m of modules) {
|
|
634
645
|
// §10: the folder name IS the label. `hr git_modules @ 3f2a1c (dirty)` needs no
|
|
@@ -647,7 +658,14 @@ export async function run(argv) {
|
|
|
647
658
|
}
|
|
648
659
|
const sh = shadowed.get(m.name);
|
|
649
660
|
if (sh) line += ` — shadows ${CHANNEL_LABEL[sh.loser]} copy`;
|
|
661
|
+
// a MODULE PRESET (CR-dt-008): how many members are here, then each absent and each drifted one
|
|
662
|
+
const p = presets.get(m.name);
|
|
663
|
+
if (p) line += ` · preset · ${p.members.length} members · ${p.members.filter((x) => x.installed).length} installed`;
|
|
650
664
|
console.log(line);
|
|
665
|
+
if (p) {
|
|
666
|
+
for (const x of p.members) if (!x.installed) console.log(` ${x.name} not installed — dt install ${x.name}`);
|
|
667
|
+
for (const x of p.members) if (x.installed && x.installed !== x.pinned) console.log(` ${x.name} ${x.installed} (preset ${p.id} names ${x.pinned})`);
|
|
668
|
+
}
|
|
651
669
|
}
|
|
652
670
|
// record layers: other workspaces cloned here for their records. The collections listed are
|
|
653
671
|
// the ones FOUND — compiled with this layer as a root and holding a folder in the clone —
|
|
@@ -839,7 +857,7 @@ export async function run(argv) {
|
|
|
839
857
|
process.exit(2);
|
|
840
858
|
}
|
|
841
859
|
if (VERB_PACKAGES[cmd]) {
|
|
842
|
-
console.error(`✖ \`dt ${cmd}\` comes from an extension this workspace does not have — install it
|
|
860
|
+
console.error(`✖ \`dt ${cmd}\` comes from an extension this workspace does not have — install it:\n dt install ${VERB_PACKAGES[cmd]}`);
|
|
843
861
|
process.exit(2);
|
|
844
862
|
}
|
|
845
863
|
if (DOCKER_VERBS.has(cmd)) {
|
package/src/collections-cli.js
CHANGED
|
@@ -135,7 +135,9 @@ export function collectionCommand(ws, collection, verb, args) {
|
|
|
135
135
|
// collection may author a field called `file` or `repo` (an issue tracker's `repo` is one)
|
|
136
136
|
if (flags.json) { emit(JSON.stringify(rows.map((r) => ({ ...r, ...whereKeys(store.locationOf(d, files.get(r.id))) })), null, 2)); return 0; }
|
|
137
137
|
const cols = listColumns(d);
|
|
138
|
-
|
|
138
|
+
// a module preset's row says so right after its id (CR-dt-008); every other row is unchanged
|
|
139
|
+
const rowCols = (r) => (collection === 'modules' && r.preset_summary ? ['id', 'preset_summary', ...cols.slice(1)] : cols);
|
|
140
|
+
for (const r of rows) console.log(rowCols(r).map((c) => fmtCell(r[c])).join(' '));
|
|
139
141
|
if (!rows.length) console.log(`(no ${collection}${narrowed ? ' matching' : ''})`);
|
|
140
142
|
return 0;
|
|
141
143
|
}
|
|
@@ -530,50 +532,16 @@ function metaCollectionsSet(ws, store, flags, pos) {
|
|
|
530
532
|
}
|
|
531
533
|
|
|
532
534
|
/**
|
|
533
|
-
* `dt reorder collections
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
* which uses one because a record collection has thousands of rows and a dense integer would
|
|
539
|
-
* renumber everything below the insertion point. A workspace has tens of collections and their
|
|
540
|
-
* `order` values are hand-authored and readable (10, 40, 140), so a midpoint is the right shape:
|
|
541
|
-
* it writes ONE descriptor and keeps the numbers legible.
|
|
535
|
+
* `dt reorder collections/<c> …` — REFUSED since 0.49 (cr-dt-008). The nav is `nav.yaml` at the
|
|
536
|
+
* workspace root, the one placement every surface draws from; a collection's `display.nav.order`
|
|
537
|
+
* still compiles and moves no row. The verb used to write that key, compile, commit and print "the
|
|
538
|
+
* nav order is live" while nothing on screen moved, so it now says where the order lives and writes
|
|
539
|
+
* nothing. `module=` stays the move between modules (`dt set collections/<c> module=<m>`).
|
|
542
540
|
*/
|
|
543
541
|
function metaCollectionsMove(ws, store, flags, pos) {
|
|
544
542
|
const name = need(pos, 0, 'collection name');
|
|
545
543
|
store.descriptor(name);
|
|
546
|
-
|
|
547
|
-
.map(([id, d]) => ({ id, order: typeof displayOf(d).nav?.order === 'number' ? displayOf(d).nav.order : null }))
|
|
548
|
-
.filter((r) => r.id !== name && r.order !== null)
|
|
549
|
-
.sort((a, b) => a.order - b.order);
|
|
550
|
-
const anchorId = oneValue(flags, 'after') ?? oneValue(flags, 'before');
|
|
551
|
-
let next;
|
|
552
|
-
if (flags.top) {
|
|
553
|
-
next = rows.length ? rows[0].order - 10 : 10;
|
|
554
|
-
} else if (flags.bottom) {
|
|
555
|
-
next = rows.length ? rows[rows.length - 1].order + 10 : 10;
|
|
556
|
-
} else {
|
|
557
|
-
if (!anchorId) throw new Error(`dt reorder collections/${name} needs --after <c> | --before <c> | --top | --bottom`);
|
|
558
|
-
const i = rows.findIndex((r) => r.id === anchorId);
|
|
559
|
-
if (i < 0) throw new Error(`"${anchorId}" has no \`display.nav.order\` to sit beside — set one first (dreamteamer set collections/${anchorId} display.nav.order=<n>), or use --top/--bottom.`);
|
|
560
|
-
const anchorOrder = rows[i].order;
|
|
561
|
-
const neighbour = flags.after ? rows[i + 1]?.order : rows[i - 1]?.order;
|
|
562
|
-
// a MIDPOINT when there is a neighbour, a step of 10 when the anchor is at the end — and
|
|
563
|
-
// nothing else is renumbered, which is the whole point
|
|
564
|
-
next = neighbour === undefined
|
|
565
|
-
? (flags.after ? anchorOrder + 10 : anchorOrder - 10)
|
|
566
|
-
: Math.round((anchorOrder + neighbour) / 2);
|
|
567
|
-
if (next === anchorOrder || next === neighbour) {
|
|
568
|
-
throw new Error(`no room between ${anchorId} (${anchorOrder}) and its neighbour (${neighbour}) — the two are adjacent integers. Spread them first: dreamteamer set collections/${anchorId} display.nav.order=<n>.`);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
const out = setCollectionScalars(ws, store, name, { 'display.nav.order': next });
|
|
572
|
-
if (flags.json) { emit(JSON.stringify({ ...out, order: next })); return 0; }
|
|
573
|
-
console.log(`✔ ${name} display.nav.order=${next}`);
|
|
574
|
-
console.log('✔ compiled — the nav order is live');
|
|
575
|
-
reportCommits(out.commits);
|
|
576
|
-
return 0;
|
|
544
|
+
throw new Error(`dt reorder collections/${name} is refused: since 0.49 the nav's order is nav.yaml at the workspace root, and a collection's display.nav.order compiles but moves no row. Move the row in the sidebar (Move up · Move down · Move to top/bottom, or drag it), or edit nav.yaml by hand — nothing was written.`);
|
|
577
545
|
}
|
|
578
546
|
|
|
579
547
|
/** `dt get collections/<c> --module <m>` — ONE module's source contribution, not the merged
|
|
@@ -59,6 +59,7 @@ const titleCase = (id) => String(id).split(/[_\-\s/]+/).filter(Boolean).map((w)
|
|
|
59
59
|
* @param {Set<string>} ctx.runtimeKinds storage paths that are build output
|
|
60
60
|
* @param {Set<string>} ctx.core collections every module may reference
|
|
61
61
|
* @param {Map<string,string[]>} ctx.moduleDeps
|
|
62
|
+
* @param {Map<string,Record<string,string>>} [ctx.modulePresets] module preset name -> { member: exact version }; a dependency on a preset reaches its members
|
|
62
63
|
* @param {Map<string,string[]>} ctx.modulePeers
|
|
63
64
|
* @param {Map<string,string>} ctx.channelOf module name -> inline | git | npm
|
|
64
65
|
* @param {string} ctx.wsModuleName
|
|
@@ -77,7 +78,23 @@ const titleCase = (id) => String(id).split(/[_\-\s/]+/).filter(Boolean).map((w)
|
|
|
77
78
|
* @returns {{ compiled: Map<string, {doc, sources}>, inert: {path, hash}[], moduleColls: Map<string, Set<string>> }}
|
|
78
79
|
*/
|
|
79
80
|
export function compileCollections(ctx) {
|
|
80
|
-
const { groups, mixins, namespaces, nsOwners, runtimeKinds, core, moduleDeps, modulePeers, channelOf, wsModuleName, engineName, dataOwners, moduleSources, unownableBecause, layers = [], repoOf, dataPath, vars, moduleId, fail, warn, root = vars?.workspaceFolder ?? '.' } = ctx;
|
|
81
|
+
const { groups, mixins, namespaces, nsOwners, runtimeKinds, core, moduleDeps, modulePresets = new Map(), modulePeers, channelOf, wsModuleName, engineName, dataOwners, moduleSources, unownableBecause, layers = [], repoOf, dataPath, vars, moduleId, fail, warn, root = vars?.workspaceFolder ?? '.' } = ctx;
|
|
82
|
+
|
|
83
|
+
// What a module may reach: its dependencies and, for a dependency that is a MODULE PRESET (CR-dt-008),
|
|
84
|
+
// the preset's members, flattened through nested presets (a seen-set stops a ring).
|
|
85
|
+
const reachCache = new Map();
|
|
86
|
+
const reachable = (m) => {
|
|
87
|
+
if (reachCache.has(m)) return reachCache.get(m);
|
|
88
|
+
const out = new Set();
|
|
89
|
+
const visit = (name) => {
|
|
90
|
+
if (out.has(name)) return;
|
|
91
|
+
out.add(name);
|
|
92
|
+
for (const member of Object.keys(modulePresets.get(name) ?? {})) visit(member);
|
|
93
|
+
};
|
|
94
|
+
for (const dep of moduleDeps.get(m) ?? []) visit(dep);
|
|
95
|
+
reachCache.set(m, out);
|
|
96
|
+
return out;
|
|
97
|
+
};
|
|
81
98
|
|
|
82
99
|
// ---- v1 is refused, every file at once --------------------------------------------------
|
|
83
100
|
const v1 = [];
|
|
@@ -255,7 +272,7 @@ export function compileCollections(ctx) {
|
|
|
255
272
|
const overlaidBy = [...new Set(overlays.map((o) => moduleId(o.moduleName)))].filter((m) => m !== ownerId).sort();
|
|
256
273
|
const ns = namespaceOf(name, namespaces);
|
|
257
274
|
const nsOwner = ns ? nsOwners.get(ns) : null;
|
|
258
|
-
if (nsOwner && !groupModules.includes(nsOwner) && !groupModules.some((m) => (
|
|
275
|
+
if (nsOwner && !groupModules.includes(nsOwner) && !groupModules.some((m) => reachable(m).has(nsOwner))) {
|
|
259
276
|
fail(`collection "${name}" sits in namespace "${ns}", which module ${moduleId(nsOwner)} declares — ${groupModules.map(moduleId).join('/')} neither owns it nor depends on it.\n dt set modules/${moduleId(groupModules[0])} dependencies=modules/${moduleId(nsOwner)}`);
|
|
260
277
|
}
|
|
261
278
|
for (const m of groupModules) {
|
|
@@ -280,7 +297,7 @@ export function compileCollections(ctx) {
|
|
|
280
297
|
referenced.add(t);
|
|
281
298
|
if (core.has(t) || owners.get(t) === g.moduleName || groups.get(t)?.some((x) => x.moduleName === g.moduleName && x.doc.overlay !== true)) continue;
|
|
282
299
|
const tOwner = owners.get(t);
|
|
283
|
-
if (tOwner && (
|
|
300
|
+
if (tOwner && reachable(g.moduleName).has(tOwner)) continue;
|
|
284
301
|
if ((modulePeers.get(g.moduleName) ?? []).includes(t)) continue;
|
|
285
302
|
if (g.moduleName === wsModuleName && tOwner) continue;
|
|
286
303
|
fail(`collection "${name}": field "${field}" (${g.src.path}) references "${t}", which module ${g.moduleName} neither owns nor declares.\n ${tOwner ? `add "${tOwner}" to dreamteamer.dependencies, or "${t}" to dreamteamer.peer_collections if the module should work without it` : `add "${t}" to dreamteamer.peer_collections — no installed module provides it`}.`);
|