dreamteamer 0.36.0 → 0.38.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.36.0",
3
+ "version": "0.38.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>",
@@ -259,7 +259,7 @@ Keys are snake_case and closed: compile refuses an unknown one, naming the list.
259
259
  | `vars` | the `.env` keys records may reference as `${env:KEY}` (`records.md`) |
260
260
  | `auto_commit` | whether a record write also commits (default off) |
261
261
  | `harnesses` | which coding-agent adapters compile writes |
262
- | `git_modules` | the lockfile map `dt install` restores into `git_modules/` — `{ url, ref }` per clone; an entry that also lists `records: [<collection>…]` is a RECORD LAYER (below), not a module |
262
+ | `git_modules` | the lockfile map `dt install` restores into `git_modules/` — `{ url, ref }` per clone; an entry that also lists `records: [<collection>…]` is a RECORD LAYER (below), not a bundle — `module: true` adds its one workspace module |
263
263
  | `disable` | what to drop from the compile: `modules/<id>` (a whole module, its code included) or `<kind>/<id>` (one entity) |
264
264
  | `local_assets` · `postinstall` · `repos_path` · `gitignore_runtime_folder` | links a worktree gets · a script `dt install` runs · where `repos` records materialise · whether `.dreamteamer/` is gitignored |
265
265
 
@@ -403,13 +403,23 @@ entry, which collections that clone contributes:
403
403
  ```json
404
404
  "git_modules": {
405
405
  "org": { "url": "…", "ref": "main" },
406
- "project-alpha": { "url": "…", "ref": "main", "records": ["tasks", "sessions", "projects"] }
406
+ "project-alpha": { "url": "…", "ref": "main", "records": ["tasks", "sessions", "projects"], "module": true }
407
407
  }
408
408
  ```
409
409
 
410
- - **A clone with `records` is a layer, never a module.** Its own `modules/` is not unpacked and it
410
+ - **A clone with `records` is a layer, never a bundle.** Its own `modules/` is not unpacked and it
411
411
  is not an extension; the shapes are the modules both workspaces install. Its nested
412
412
  `git_modules/` are never read.
413
+ - **`module: true` also compiles the clone's WORKSPACE module** — `modules/<workspace_module>`, as
414
+ the clone's own package.json names it — as a module source here, the way a bundle's module
415
+ compiles: its agents, skills, commands, command-bindings, ui-views, mixins and collections, with a
416
+ `modules/<id>` record whose `path` is inside the clone. That is how a project's own agent becomes
417
+ dispatchable from the workspace that oversees it. Only that one module, only its sources (an
418
+ extension entry in it is not loaded), and the records half is unchanged. Compile refuses, naming
419
+ the entry: a clone with no `workspace_module`; a module whose id is `default` (the role name every
420
+ workspace's own module carries — name the project's module after the project); an id another
421
+ module here already holds; and `module: true` on an entry without `records`, which is a bundle
422
+ already. `dt status` adds `· module <id>` to the layer's line.
413
423
  - **Each listed collection gains the clone's data folder as a read root below the workspace's
414
424
  own** — the compiled descriptor states them as `compiled.layers`, and `storageOf(d).roots` is the
415
425
  write root first, then each layer. `dt list`, `get`, `check`, the inbound-reference guard of `rm`
@@ -46,6 +46,12 @@ what the operator types. Compile copies the file **verbatim** to `.claude/comman
46
46
  straight to the harness untouched. Harnesses without native command discovery get a
47
47
  `/<name> — description` index in their orientation block instead.
48
48
 
49
+ **A folder is a namespace.** `commands/rnd/design.command.md` has the id `rnd/design` (its `name`
50
+ is `rnd/design` too), compiles to `.claude/commands/rnd/design.md`, and is typed `/rnd:design` —
51
+ the spelling the orientation block, the bindings section and `dt next` all use. A binding names it
52
+ `commands/rnd/design`. One folder deep; a family of commands shipped by one module takes its id as
53
+ the folder, so eight lifecycle commands read as one family in the picker.
54
+
49
55
  ```markdown
50
56
  ---
51
57
  name: process-inbox
package/src/api.d.ts CHANGED
@@ -94,7 +94,7 @@ export function satisfies(version: string, range: string): boolean | null;
94
94
  export function compile(ws: Workspace): 0;
95
95
  export function staleness(root: string): { compiled: boolean; stale: string[]; manifest?: Manifest; message?: string };
96
96
  export function warnIfStale(root: string): ReturnType<typeof staleness>;
97
- export function discoverModules(root: string, pkg: Workspace['pkg']): { modules: { name: string; root: string; channel: string }[]; shadows: unknown[]; disabledModules: string[] };
97
+ export function discoverModules(root: string, pkg: Workspace['pkg']): { modules: { name: string; root: string; channel: string; layer?: string }[]; shadows: unknown[]; disabledModules: string[]; layerRefusals: string[] };
98
98
  export class CompileError extends Error {}
99
99
  export const KINDS: readonly string[];
100
100
  export const MANAGED_BLOCKS: readonly { id: 'orientation' | 'instructions'; begin: string; end: string }[];
package/src/cli.js CHANGED
@@ -14,7 +14,7 @@ import path from 'node:path';
14
14
  import { execFileSync } from 'node:child_process';
15
15
  import * as api from './api.js';
16
16
  import { openWorkspace } from './api.js';
17
- import { compile, staleness, warnIfStale, discoverModules, CHANNEL_LABEL, locationOf, kindsOf } from './compile.js';
17
+ import { compile, staleness, warnIfStale, discoverModules, CHANNEL_LABEL, locationOf, kindsOf, moduleIdOf } from './compile.js';
18
18
  import { check } from './check.js';
19
19
  import { collectionCommand, emit, relationsCommand, reportCommits } from './collections-cli.js';
20
20
  import { formatDescriptors } from './schema-ops.js';
@@ -523,7 +523,8 @@ export async function run(argv) {
523
523
  for (const [name, e] of layers) {
524
524
  const dir = path.join(ws.root, 'git_modules', name);
525
525
  const ref = fs.existsSync(dir) ? tryGit(dir, ['rev-parse', '--short', 'HEAD']) : null;
526
- console.log(` ${name.padEnd(20)} ${ref ? `git_modules @ ${ref}${tryGit(dir, ['status', '--porcelain']) ? ' (dirty)' : ''}` : 'not installed — dreamteamer install'} · records: ${e.records.join(', ')}`);
526
+ const mod = e.module === true ? modules.find((m) => m.layer === name) : null;
527
+ console.log(` ${name.padEnd(20)} ${ref ? `git_modules @ ${ref}${tryGit(dir, ['status', '--porcelain']) ? ' (dirty)' : ''}` : 'not installed — dreamteamer install'} · records: ${e.records.join(', ')}${e.module === true ? ` · module ${mod ? moduleIdOf(mod.name) : '-'}` : ''}`);
527
528
  }
528
529
  }
529
530
  // ⚠ WHICH CHECKOUT AM I. Everything `install` decides turns on this, and a linked
package/src/compile.js CHANGED
@@ -152,6 +152,9 @@ const sha256 = (buf) => 'sha256:' + createHash('sha256').update(buf).digest('hex
152
152
  // on purpose: renaming a symbol under src/ is a cross-repo change, and this one buys nothing.)
153
153
  export const CHANNEL_LABEL = { inline: 'modules', git: 'git_modules', npm: 'node_modules' };
154
154
 
155
+ /** A module's record id: its package name with the npm scope stripped, so `@dreamteamer/crm` is `crm`. */
156
+ export const moduleIdOf = (n) => slug(String(n).replace(/^@[^/]+\//, ''));
157
+
155
158
  /** A module's `location` — the folder its sources sit in. `root` is the classic layout, where the
156
159
  * workspace's own sources are at its root rather than under `modules/<id>/`; discovery reports that
157
160
  * as the `inline` channel with `root === '.'`, which is the one case the label table cannot see. */
@@ -173,8 +176,10 @@ export function discoverModules(root, pkg) {
173
176
  const disable = pkg?.dreamteamer?.disable ?? [];
174
177
  const disabledHits = new Set();
175
178
  // A clone whose manifest entry lists `records` is a RECORD LAYER — another workspace's data read
176
- // here — never a module: its own modules/ would otherwise unpack as a bundle and collide with ours.
177
- const layers = new Set(layerEntries(pkg).map((l) => l.name));
179
+ // here — never a bundle: its own modules/ would otherwise unpack and collide with ours. With
180
+ // `module: true` its ONE workspace module is a source too (below).
181
+ const layerList = layerEntries(pkg);
182
+ const layers = new Set(layerList.map((l) => l.name));
178
183
  // the same rule the extension loader applies (full package name, or its scope-stripped id), so a
179
184
  // disabled package loses its content AND its code together
180
185
  const disabled = (name) => {
@@ -231,7 +236,25 @@ export function discoverModules(root, pkg) {
231
236
  const mpkg = readPkg(srcRoot);
232
237
  if (mpkg) tryAddOrUnpack(mpkg.name ?? dep, srcRoot, 'npm');
233
238
  }
234
- return { modules: [...byName.values()], shadows, disabledModules: [...disabledHits] };
239
+ // A layer with `module: true` contributes the clone's WORKSPACE module — `modules/<workspace_module>`
240
+ // as its own manifest names it — as a git-channel source, the way a bundle contributes its modules.
241
+ // Kept out of `byName` on purpose: a name another channel holds must be REFUSED, never shadowed, and
242
+ // compile does that, naming the entry. A clone not on disk contributes nothing, like any layer.
243
+ const layerModules = [];
244
+ const layerRefusals = [];
245
+ for (const l of layerList) {
246
+ const clone = path.join(gitDir, l.name);
247
+ if (!l.module || !fs.existsSync(clone)) continue;
248
+ const wm = readPkg(clone)?.dreamteamer?.workspace_module;
249
+ const srcRoot = wm ? path.join(clone, 'modules', wm) : null;
250
+ const mpkg = srcRoot ? readPkg(srcRoot) : null;
251
+ if (!mpkg) {
252
+ layerRefusals.push(`git_modules.${l.name}.module: ${wm ? `the clone names workspace_module "${wm}", but modules/${wm}/ holds no module package.json` : 'the clone names no dreamteamer.workspace_module'} — there is no module to contribute. Drop \`module\`, or give the clone a workspace module.`);
253
+ } else if (!disabled(mpkg.name ?? wm)) {
254
+ layerModules.push({ name: mpkg.name ?? wm, root: srcRoot, channel: 'git', layer: l.name });
255
+ }
256
+ }
257
+ return { modules: [...byName.values(), ...layerModules], shadows, disabledModules: [...disabledHits], layerRefusals };
235
258
  }
236
259
 
237
260
  // ---- module-owned data ----------------------------------------------------------
@@ -274,17 +297,22 @@ const toPosix = (p) => p.split(path.sep).join('/');
274
297
  // records: each listed collection reads that clone's data folder as a root below this workspace's
275
298
  // own. The clone contributes no sources — its shapes are the modules both workspaces install.
276
299
 
277
- /** The declared layers, validated: `{ name, records }` per entry. `records` is a non-empty list of
278
- * collection names; which collections exist is compile-collections' question. */
300
+ /** The declared layers, validated: `{ name, records, module }` per entry. `records` is a non-empty list
301
+ * of collection names; which collections exist is compile-collections' question. `module: true` also
302
+ * compiles the clone's workspace module (discoverModules), and is refused on an entry with no `records`. */
279
303
  export function layerEntries(pkg) {
280
304
  const out = [];
281
305
  for (const [name, entry] of Object.entries(pkg?.dreamteamer?.git_modules ?? {})) {
306
+ if (entry?.module !== undefined && typeof entry.module !== 'boolean') throw new Error(`git_modules.${name}.module must be true or false (got ${JSON.stringify(entry.module)})`);
307
+ if (entry?.module === true && entry.records === undefined) {
308
+ throw new Error(`git_modules.${name}.module: true without \`records\` — an entry without records is already a bundle: every module under its modules/ compiles. Drop \`module\`, or list the collections it layers.`);
309
+ }
282
310
  if (!entry || entry.records === undefined) continue;
283
311
  const r = entry.records;
284
312
  if (!Array.isArray(r) || !r.length || r.some((c) => typeof c !== 'string' || !c.trim())) {
285
313
  throw new Error(`git_modules.${name}.records must be a non-empty list of collection names (got ${JSON.stringify(r)})`);
286
314
  }
287
- out.push({ name, records: r });
315
+ out.push({ name, records: r, module: entry.module === true });
288
316
  }
289
317
  return out;
290
318
  }
@@ -354,7 +382,8 @@ export function compile(ws) {
354
382
  };
355
383
 
356
384
  // ---- discover sources: channel modules then the workspace's own -----------------
357
- const { modules: discovered, shadows, disabledModules } = discoverModules(root, pkg);
385
+ const { modules: discovered, shadows, disabledModules, layerRefusals } = discoverModules(root, pkg);
386
+ for (const r of layerRefusals) fail(r);
358
387
  for (const s of shadows) console.warn(shadowWarning(s));
359
388
  const sources = [...discovered];
360
389
  // workspace-owned sources: either at the root (classic layout) or in the designated
@@ -393,7 +422,16 @@ export function compile(ws) {
393
422
  // A module's record id: the npm scope stripped, so `@dreamteamer/crm` reads as `crm` — which is
394
423
  // what every message in this engine already calls it. Defined HERE, above the namespace pass,
395
424
  // because a namespace error has to name the module by the id the fix is typed with.
396
- const moduleId = (n) => slug(String(n).replace(/^@[^/]+\//, ''));
425
+ const moduleId = moduleIdOf;
426
+ // A layer's workspace module (`module: true`) must answer to an id of its own: `default` is the ROLE
427
+ // every workspace's own module carries, and an id another module holds would merge two modules' records.
428
+ for (const s of sources.filter((x) => x.layer)) {
429
+ const at = `git_modules.${s.layer}.module`;
430
+ const id = moduleId(s.name);
431
+ if (id === 'default') fail(`${at}: the clone's workspace module is "default" — the role name every workspace's own module carries, so it cannot be told apart from this one's. Name the project's module after the project (its workspace_module, and the folder under modules/).`);
432
+ const other = sources.find((o) => o !== s && moduleId(o.name) === id);
433
+ if (other) fail(`${at}: the clone's workspace module "${id}" collides with module "${other.name}" at ${rel(other.root) || '.'} — a module id names one module. Rename one of them.`);
434
+ }
397
435
  const channelOf = new Map(sources.map((s) => [s.name, s.channel]));
398
436
  const declaredEnv = new Map(); // env key -> [module names]
399
437
  const requestedVars = new Map(); // var a module READS through ${env:…} -> [module names]
@@ -1000,7 +1038,9 @@ export function compile(ws) {
1000
1038
  const text = e.bytes.toString('utf8');
1001
1039
  e.bytes = Buffer.from(`${text}${text.endsWith('\n') ? '' : '\n'}${dump({ compiled: { display: viewDisplay(d ? displayOf(d) : {}, view) } })}`);
1002
1040
  }
1003
- const commandIds = new Set([...entries.keys()].filter((k) => k.startsWith('commands/')).map((k) => path.basename(k).replace(/\.command\.md$/, '')));
1041
+ // a command's id is its path under commands/, folders included: `commands/rnd/design.command.md` is
1042
+ // `rnd/design`, typed as `/rnd:design` — the folder is the namespace, as claude-code already reads it
1043
+ const commandIds = new Set([...entries.keys()].filter((k) => k.startsWith('commands/')).map((k) => k.slice('commands/'.length).replace(/\.command\.md$/, '')));
1004
1044
  for (const [rt, e] of entries) {
1005
1045
  if (!rt.startsWith('command-bindings/')) continue;
1006
1046
  const file = e.sources[0].path;
package/src/harnesses.js CHANGED
@@ -11,6 +11,7 @@
11
11
  // .cursor) are gitignored and pruned by stamp. removing a harness from config removes its
12
12
  // block/file on the next compile.
13
13
  import fs from 'node:fs';
14
+ import { slash } from './namespace.js';
14
15
  import path from 'node:path';
15
16
  import { load, dump } from './yaml.js';
16
17
 
@@ -115,7 +116,8 @@ export function runHarnessAdapters({ root, entries, harnesses, prevManifest, sou
115
116
  write(path.join('.claude/agents', path.basename(rt).replace(/\.agent\.md$/, '.md')), stampMd(transformAgent(e.bytes)));
116
117
  n++;
117
118
  } else if (rt.startsWith('commands/')) {
118
- write(path.join('.claude/commands', path.basename(rt).replace(/\.command\.md$/, '.md')), stampMd(e.bytes));
119
+ // the folder is the namespace: commands/rnd/design.command.md → .claude/commands/rnd/design.md → /rnd:design
120
+ write(path.join('.claude/commands', rt.slice('commands/'.length).replace(/\.command\.md$/, '.md')), stampMd(e.bytes));
119
121
  n++;
120
122
  }
121
123
  }
@@ -307,7 +309,7 @@ function buildModulesIndex(entries) {
307
309
  if (!kind) continue;
308
310
  const src = e.sources?.[0]?.path ?? '';
309
311
  const owner = mods.find((mod) => src.startsWith(mod.path));
310
- if (owner) owner[kind].push(kind === 'skills' ? rt.split('/')[1] : path.basename(rt).replace(/\.command\.md$/, ''));
312
+ if (owner) owner[kind].push(kind === 'skills' ? rt.split('/')[1] : rt.slice('commands/'.length).replace(/\.command\.md$/, ''));
311
313
  }
312
314
  for (const mod of mods) { mod.skills.sort(); mod.commands.sort(); }
313
315
  return mods;
@@ -383,7 +385,7 @@ function collectionsSection(index, modules, workspaceModule, verbs) {
383
385
  for (const m of groups) {
384
386
  const where = [`\`${m.id}\``, m.path ? m.path.replace(/\/$/, '') : 'the workspace root', ...(m.namespaces.length ? [`namespaces: ${m.namespaces.join(' · ')}`] : [])];
385
387
  lines.push('', `**${m.title}** (${where.join(' · ')})${m.description ? ` — ${m.description}` : ''}`);
386
- const ships = [...(m.skills.length ? [`skills: ${m.skills.join(' · ')}`] : []), ...(m.commands.length ? [`commands: ${m.commands.map((c) => `/${c}`).join(' · ')}`] : []), ...(m.bin.length ? [`runs: ${m.bin.join(' · ')}`] : []), ...(verbs.get(m.id)?.length ? [`verbs: ${verbs.get(m.id).map((v) => `dt ${v}`).join(' · ')}`] : [])];
388
+ const ships = [...(m.skills.length ? [`skills: ${m.skills.join(' · ')}`] : []), ...(m.commands.length ? [`commands: ${m.commands.map((c) => slash(c)).join(' · ')}`] : []), ...(m.bin.length ? [`runs: ${m.bin.join(' · ')}`] : []), ...(verbs.get(m.id)?.length ? [`verbs: ${verbs.get(m.id).map((v) => `dt ${v}`).join(' · ')}`] : [])];
387
389
  if (ships.length) lines.push(` ${ships.join(' · ')}`);
388
390
  for (const c of data.filter((c) => c.module === m.id)) {
389
391
  lines.push(`- ${c.name}${c.description ? ` — ${c.description}` : ''}`);
@@ -470,7 +472,7 @@ function bindingsSection(entries) {
470
472
  if (!coll || !cmd) continue;
471
473
  const gate = [renderGate('available when', d.available_when), renderGate('done when', d.done_when)].filter(Boolean).join(' · ');
472
474
  if (!byCollection.has(coll)) byCollection.set(coll, []);
473
- byCollection.get(coll).push(`/${cmd}${gate ? ` (${gate})` : ''}`);
475
+ byCollection.get(coll).push(`${slash(cmd)}${gate ? ` (${gate})` : ''}`);
474
476
  }
475
477
  if (!byCollection.size) return [];
476
478
  const lines = ['', 'VERBS BOUND TO COLLECTIONS (`dt next <collection>[/<id>]` answers per record):'];
@@ -538,7 +540,7 @@ function orientationBlock(flavor, skillsIndex, sourceLayout = 'flat', namespaces
538
540
  '',
539
541
  'agent personas live at `.dreamteamer/agents/*.agent.md`; commands at',
540
542
  '`.dreamteamer/commands/`, invoked as `/<name>` by the harness:',
541
- ...buildCommandsIndex(entries).map((c) => `- \`/${c.id}\` — ${c.desc}`),
543
+ ...buildCommandsIndex(entries).map((c) => `- \`${slash(c.id)}\` — ${c.desc}`),
542
544
  );
543
545
  }
544
546
  return lines.join('\n');
package/src/namespace.js CHANGED
@@ -208,3 +208,8 @@ export function storageOverlaps(entries) {
208
208
  }
209
209
  return problems;
210
210
  }
211
+
212
+ /** How a command id is typed: `/<id>`, with a namespace folder spelled as claude-code spells it —
213
+ * `rnd/design` is `/rnd:design`. One rule for the orientation block, the bindings section, the
214
+ * commands index and `dt next`, so what a session reads is what it types. */
215
+ export const slash = (id) => `/${String(id).replace(/\//g, ':')}`;
@@ -5,7 +5,7 @@
5
5
  // ref traversal (tier 1). serves `dreamteamer commands for`, GET /api/commands/:name,
6
6
  // and (through the extension's api.ts port) the studio's Commands tab.
7
7
  import { matchesFilter } from './filter.js';
8
- import { parseRef } from './namespace.js';
8
+ import { parseRef, slash } from './namespace.js';
9
9
 
10
10
  // memoized `<collection>/<id>` → parsed fields (or null) for ONE evaluation pass:
11
11
  // overlapping refs across a 50-record selection parse once, and filter.js stays
@@ -66,7 +66,7 @@ export function commandsFor(store, collection, ids = []) {
66
66
  scope: b.scope ?? 'record',
67
67
  };
68
68
  if (row.scope === 'collection') {
69
- rows.push({ ...row, invocation: `/${cmd.name} ${collection}` });
69
+ rows.push({ ...row, invocation: `${slash(cmd.name)} ${collection}` });
70
70
  continue;
71
71
  }
72
72
  const states = {};
@@ -85,7 +85,7 @@ export function commandsFor(store, collection, ids = []) {
85
85
  states,
86
86
  eligible,
87
87
  done: ids.filter((id) => states[id] === 'done'),
88
- invocation: eligible.length ? `/${cmd.name} ${eligible.map((id) => `${collection}/${id}`).join(' ')}` : null,
88
+ invocation: eligible.length ? `${slash(cmd.name)} ${eligible.map((id) => `${collection}/${id}`).join(' ')}` : null,
89
89
  });
90
90
  }
91
91
  // record commands first (the headline on a record page), then collection commands; name-sorted within