dreamteamer 0.37.0 → 0.39.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 +1 -1
- package/skills/using-dreamteamer/references/collections.md +20 -0
- package/skills/using-dreamteamer/references/commands.md +6 -0
- package/src/check.js +9 -1
- package/src/cli.js +17 -1
- package/src/commit.js +12 -0
- package/src/compile-collections.js +44 -2
- package/src/compile.js +12 -4
- package/src/descriptor.js +6 -0
- package/src/events.js +2 -0
- package/src/harnesses.js +7 -5
- package/src/history.js +9 -0
- package/src/namespace.js +5 -0
- package/src/record-commands.js +3 -3
- package/src/schema-ops.js +1 -1
- package/src/store.js +21 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dreamteamer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.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>",
|
|
@@ -291,6 +291,26 @@ and it refuses to guess: `--namespace health`. `--namespace ''` means none.
|
|
|
291
291
|
- ⚠ **No collection may store records inside another's folder.** The one declared exception is
|
|
292
292
|
the next section, where compile knows which files belong to whom.
|
|
293
293
|
|
|
294
|
+
## an env-pointed root — records in a per-machine folder
|
|
295
|
+
|
|
296
|
+
`storage.path` may be a template: `${env:NAME}/<subpath>`, `${userHome}/…` or
|
|
297
|
+
`${workspaceFolder}/…`. Compile renders it per machine — the same renderer `dt resolve` uses, against
|
|
298
|
+
the workspace `.env` — so a collection whose records should never land in a shared tree (one
|
|
299
|
+
person's working trace, a cache of local readings) lives in a folder of this machine's choosing.
|
|
300
|
+
Ids and references are unchanged; `add`, `list`, `get`, `check`, `relations` and `commit` read the
|
|
301
|
+
rendered folder; `dt status` names it under `storage:`. Three rules follow from "per machine":
|
|
302
|
+
|
|
303
|
+
- **An unset or empty var refuses, loudly, and never creates a literal folder.** Compile warns,
|
|
304
|
+
naming the collection and the var; every record verb on the collection then refuses with the same
|
|
305
|
+
names until the var is set and the workspace recompiled. `check` says once that the collection is
|
|
306
|
+
not read here and stays green, as it does for an uninstalled record layer.
|
|
307
|
+
- **A folder outside the workspace is outside every git repo here.** `dt commit` reports it on its
|
|
308
|
+
own line and never commits it — the records are kept, by design, on this machine only. A path
|
|
309
|
+
that renders inside the workspace is an ordinary root, committed like any other.
|
|
310
|
+
- **Declare the var** in the shipping module's `dreamteamer.vars` (or the workspace's), so
|
|
311
|
+
`.env.example` names it; one declared nowhere warns at compile and still renders. It combines with
|
|
312
|
+
neither `storage.owner: module` nor `storage.under`, and a record layer may not list it.
|
|
313
|
+
|
|
294
314
|
## relationship-based storage — records beside the record they belong to
|
|
295
315
|
|
|
296
316
|
A collection can keep each record INSIDE the folder of its parent record, so a browse of
|
|
@@ -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/check.js
CHANGED
|
@@ -42,7 +42,7 @@ export function check({ root }, { extra = [] } = {}) {
|
|
|
42
42
|
// declared here rather than beside the validation pass: indexing can itself produce a
|
|
43
43
|
// finding (an unreachable data root, below) before a single record is read.
|
|
44
44
|
const violations = [];
|
|
45
|
-
const dirOf = (d) => path.
|
|
45
|
+
const dirOf = (d) => path.resolve(storageOf(d).runtime ? RUNTIME : root, storageOf(d).path); // resolve: an env-pointed root is absolute
|
|
46
46
|
// per indexed file: the repo that holds it (mirrors are expected per repo) and the record layer it
|
|
47
47
|
// came from, if any (its findings are reported under the layer, not as this workspace's data)
|
|
48
48
|
const fileRepo = new Map();
|
|
@@ -61,6 +61,13 @@ export function check({ root }, { extra = [] } = {}) {
|
|
|
61
61
|
if (layer) fileLayer.set(f, layer);
|
|
62
62
|
return true;
|
|
63
63
|
};
|
|
64
|
+
// An env-pointed root this machine cannot render is the normal state of a per-machine
|
|
65
|
+
// collection elsewhere — said once, like an absent layer, and not read: a literal `${env:…}`
|
|
66
|
+
// folder is never looked at, and a reference into the collection is not a finding here.
|
|
67
|
+
if (storageOf(d).unavailable) {
|
|
68
|
+
layerNotes.set(`collection:${name}`, `⚠ collection ${name}: ${storageOf(d).unavailable} — its records are not read on this machine, and references into it are not checked`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
64
71
|
// runtime-based (knowhow/meta) collections are read from the COMPILED runtime —
|
|
65
72
|
// their sources may live in any module; .dreamteamer is the merged read surface
|
|
66
73
|
const dir = dirOf(d);
|
|
@@ -288,6 +295,7 @@ export function check({ root }, { extra = [] } = {}) {
|
|
|
288
295
|
}
|
|
289
296
|
if (!index.get(coll).has(id)) {
|
|
290
297
|
if (soft) return; // resolve if present, ignore if absent
|
|
298
|
+
if (storageOf(descriptors.get(coll)).unavailable) return; // the collection is unread here, not empty
|
|
291
299
|
return flag(file, `${fieldPath.join('.')}: dangling reference "${value}" — no such record`);
|
|
292
300
|
}
|
|
293
301
|
}
|
package/src/cli.js
CHANGED
|
@@ -26,6 +26,7 @@ import { Store } from './store.js';
|
|
|
26
26
|
import { splitRef, canonicalCollection } from './ref.js';
|
|
27
27
|
import { envContext, renderTemplate } from './env-vars.js';
|
|
28
28
|
import { doctorBoard, renderBoard } from './doctor.js';
|
|
29
|
+
import { storageOf } from './descriptor.js';
|
|
29
30
|
|
|
30
31
|
// git calls whose failure we CATCH must not print git's own error: execFileSync forwards the
|
|
31
32
|
// child's stderr to ours unless told otherwise, so a handled "not a git repository" still
|
|
@@ -438,8 +439,10 @@ export async function run(argv) {
|
|
|
438
439
|
const only = rest.filter((a, i) => !a.startsWith('-') && (mi === -1 || i !== mi + 1));
|
|
439
440
|
const results = commitPending(store, { only, message, dryRun: rest.includes('--dry-run') });
|
|
440
441
|
if (rest.includes('--json')) { emit(JSON.stringify(results, null, 2)); process.exit(0); }
|
|
441
|
-
if (!results.
|
|
442
|
+
if (!results.some((r) => !r.outside)) console.log('nothing pending');
|
|
442
443
|
for (const r of results) {
|
|
444
|
+
// an env-pointed collection's folder is outside every repo here: kept, never committed, said
|
|
445
|
+
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; }
|
|
443
446
|
if (r.blocked) { console.error(`✖ ${r.repo}: ${r.blocked} — ${r.rows.length} record(s) left uncommitted`); continue; }
|
|
444
447
|
if (r.failed) { console.error(`✖ ${r.repo}: ${r.failed} — ${r.rows.length} record(s) left uncommitted, nothing staged`); continue; }
|
|
445
448
|
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; }
|
|
@@ -527,6 +530,19 @@ export async function run(argv) {
|
|
|
527
530
|
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) : '-'}` : ''}`);
|
|
528
531
|
}
|
|
529
532
|
}
|
|
533
|
+
// env-pointed roots (`storage.path: ${env:NAME}/…`), rendered per machine by compile: the
|
|
534
|
+
// folder a record of each lands in on THIS machine, or why it cannot. Wrapped like the
|
|
535
|
+
// blocks below — status is the command run when things are already wrong.
|
|
536
|
+
try {
|
|
537
|
+
const pointed = [...new Store(ws).descriptors.values()].filter((d) => typeof d.storage?.path === 'string' && d.storage.path.includes('${'));
|
|
538
|
+
if (pointed.length) {
|
|
539
|
+
console.log('storage:');
|
|
540
|
+
for (const d of pointed) {
|
|
541
|
+
const st = storageOf(d);
|
|
542
|
+
console.log(` ${d.name.padEnd(20)} ${st.unavailable ? `✖ ${d.storage.path} — ${st.unavailable}` : `${st.path} (${d.storage.path})${st.external ? ' — outside every repo here, never committed' : ''}`}`);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
} catch { /* no runtime yet — status must still print */ }
|
|
530
546
|
// ⚠ WHICH CHECKOUT AM I. Everything `install` decides turns on this, and a linked
|
|
531
547
|
// worktree is indistinguishable from the primary by eye — so it is stated. Wrapped like
|
|
532
548
|
// every other block below: `status` is the command run when things are already wrong.
|
package/src/commit.js
CHANGED
|
@@ -330,6 +330,9 @@ function scopeByRepo(descriptors, only) {
|
|
|
330
330
|
// bare kind name (`skills`), so the old test admitted all seven — and this list becomes a
|
|
331
331
|
// `git add` pathspec, which fails outright on a path the workspace root does not have.
|
|
332
332
|
if (!p || storageOf(d).runtime) continue;
|
|
333
|
+
// an env-pointed root outside the workspace is outside every repo here (commitPlan says so),
|
|
334
|
+
// and one that did not render has no folder to sample
|
|
335
|
+
if (storageOf(d).external || storageOf(d).unavailable) continue;
|
|
333
336
|
if (only.length && !only.includes(d.name)) continue;
|
|
334
337
|
const repo = storageOf(d).repo;
|
|
335
338
|
if (!byRepo.has(repo)) byRepo.set(repo, []);
|
|
@@ -553,5 +556,14 @@ function commitPlan(store, { only = [], message, dryRun = false } = {}) {
|
|
|
553
556
|
const sha = dryRun ? null : execFileSync('git', ['rev-parse', '--short', 'HEAD'], { cwd }).toString().trim();
|
|
554
557
|
results.push({ repo, rows, subject, sha, warning, leftPending });
|
|
555
558
|
}
|
|
559
|
+
// An env-pointed collection whose folder is outside the workspace has no repo here to publish to:
|
|
560
|
+
// its records are kept on this machine and never committed, BY DESIGN. Said in the report — for a
|
|
561
|
+
// collection named as a target, or holding records when nothing was named — rather than passed
|
|
562
|
+
// off as "nothing pending", the one report that looks like success.
|
|
563
|
+
for (const d of store.descriptors.values()) {
|
|
564
|
+
if (!storageOf(d).external) continue;
|
|
565
|
+
if (targets.scoped ? !targets.scope.includes(d.name) : store.ids(d.name).size === 0) continue;
|
|
566
|
+
results.push({ repo: storageOf(d).path, rows: [], outside: d.name, template: d.storage.path });
|
|
567
|
+
}
|
|
556
568
|
return results;
|
|
557
569
|
}
|
|
@@ -19,6 +19,7 @@ import { targetsOf } from './descriptor.js';
|
|
|
19
19
|
import { defaultStoragePath, baseNameOf, singular, inflects, namespaceOf, storageOverlaps } from './namespace.js';
|
|
20
20
|
import { subpathProblem } from './placement.js';
|
|
21
21
|
import { patternRe } from './records.js';
|
|
22
|
+
import { renderTemplate } from './env-vars.js';
|
|
22
23
|
|
|
23
24
|
import { CONVERTER } from './extensions.js';
|
|
24
25
|
export { CONVERTER };
|
|
@@ -68,13 +69,14 @@ const titleCase = (id) => String(id).split(/[_\-\s/]+/).filter(Boolean).map((w)
|
|
|
68
69
|
* @param {(moduleRoot: string) => string} ctx.repoOf workspace-relative git repo of a module root
|
|
69
70
|
* @param {(p: string) => string} ctx.rel
|
|
70
71
|
* @param {string} ctx.dataPath
|
|
72
|
+
* @param {{env: Map<string,string>, workspaceFolder: string, declared: Set<string>}} ctx.vars what an env-pointed `storage.path` renders against: this machine's .env values, the root, and every declared var
|
|
71
73
|
* @param {(n: string) => string} ctx.moduleId
|
|
72
74
|
* @param {(msg: string) => never} ctx.fail
|
|
73
75
|
* @param {(msg: string) => void} ctx.warn
|
|
74
76
|
* @returns {{ compiled: Map<string, {doc, sources}>, inert: {path, hash}[], moduleColls: Map<string, Set<string>> }}
|
|
75
77
|
*/
|
|
76
78
|
export function compileCollections(ctx) {
|
|
77
|
-
const { groups, mixins, namespaces, nsOwners, runtimeKinds, core, moduleDeps, modulePeers, channelOf, wsModuleName, engineName, dataOwners, moduleSources, unownableBecause, layers = [], repoOf, dataPath, moduleId, fail, warn } = ctx;
|
|
79
|
+
const { groups, mixins, namespaces, nsOwners, runtimeKinds, core, moduleDeps, modulePeers, channelOf, wsModuleName, engineName, dataOwners, moduleSources, unownableBecause, layers = [], repoOf, dataPath, vars, moduleId, fail, warn } = ctx;
|
|
78
80
|
|
|
79
81
|
// ---- v1 is refused, every file at once --------------------------------------------------
|
|
80
82
|
const v1 = [];
|
|
@@ -150,6 +152,44 @@ export function compileCollections(ctx) {
|
|
|
150
152
|
if (modRel) storagePath = `${modRel}/${storagePath}`;
|
|
151
153
|
repo = repoOf(source.root);
|
|
152
154
|
}
|
|
155
|
+
// ---- an env-pointed root: `storage.path: ${env:NAME}/…` is rendered HERE, per machine ----
|
|
156
|
+
// The one renderer (`dt resolve`'s), never a second. ⚠ A template left unrendered compiled and
|
|
157
|
+
// wrote into a literal `${env:NAME}/` folder inside the workspace, every verb reporting ✔ — so a
|
|
158
|
+
// template that cannot render is stamped `unavailable` and every record verb refuses, and one
|
|
159
|
+
// that renders outside the workspace is stamped `external`: its folder is outside every repo
|
|
160
|
+
// here, which `dt commit` and `dt status` say rather than fail on.
|
|
161
|
+
let external = false;
|
|
162
|
+
let unavailable = null;
|
|
163
|
+
const pointed = typeof a.path === 'string' && a.path.includes('${');
|
|
164
|
+
if (pointed) {
|
|
165
|
+
const at = `collection "${name}": storage.path "${a.path}"`;
|
|
166
|
+
if (owner === 'module') fail(`${at} is a template, so the records live in a per-machine folder — not in a module's clone; drop storage.owner: module (${where})`);
|
|
167
|
+
if (a.under) fail(`${at} is a template, but a placed collection keeps its records inside its parent's folders — drop storage.under or the template (${where})`);
|
|
168
|
+
const keys = [...a.path.matchAll(/\$\{env:([A-Za-z0-9_]*)\}/g)].map((m) => m[1]).filter(Boolean);
|
|
169
|
+
// Declared by the workspace or REQUESTED by a module (its `dreamteamer.vars`): the descriptor
|
|
170
|
+
// itself is the explicit request to render, so an undeclared var warns the way an undeclared
|
|
171
|
+
// request does — and renders — rather than refusing a module that forgot to list it.
|
|
172
|
+
const declared = new Set(vars.declared);
|
|
173
|
+
for (const k of keys) {
|
|
174
|
+
if (declared.has(k)) continue;
|
|
175
|
+
warn(`⚠ collection ${name}: storage.path reads \${env:${k}}, which no dreamteamer.vars declares — add it to module ${moduleId(base.moduleName)}'s dreamteamer.vars (or the workspace's) so .env.example names it`);
|
|
176
|
+
declared.add(k);
|
|
177
|
+
}
|
|
178
|
+
let rendered = null;
|
|
179
|
+
try { rendered = renderTemplate(a.path, { env: vars.env, workspaceFolder: vars.workspaceFolder, declared: [...declared] }); }
|
|
180
|
+
catch (e) {
|
|
181
|
+
unavailable = e.message;
|
|
182
|
+
warn(`⚠ collection ${name}: storage.path ${a.path} cannot render on this machine — ${e.message}. Its records are unreachable here, and every record verb on ${name} refuses until ${keys.join(', ') || 'it'} is set in .env`);
|
|
183
|
+
}
|
|
184
|
+
if (rendered !== null) {
|
|
185
|
+
if (rendered.includes('${')) fail(`${at} still holds "\${…}" after rendering — a storage path renders \${env:NAME}, \${workspaceFolder} and \${userHome}, nothing else (${where})`);
|
|
186
|
+
const abs = path.resolve(vars.workspaceFolder, rendered);
|
|
187
|
+
const inside = path.relative(vars.workspaceFolder, abs);
|
|
188
|
+
if (inside === '') fail(`${at} renders to the workspace root itself — point it at a folder (${where})`);
|
|
189
|
+
if (inside.startsWith('..') || path.isAbsolute(inside)) { storagePath = abs; external = true; }
|
|
190
|
+
else storagePath = inside.split(path.sep).join('/'); // inside the workspace: an ordinary root
|
|
191
|
+
}
|
|
192
|
+
}
|
|
153
193
|
const bare = baseNameOf(name, namespaces);
|
|
154
194
|
const sdefaults = {};
|
|
155
195
|
if (a.path === undefined || storagePath !== a.path) sdefaults.path = storagePath;
|
|
@@ -163,7 +203,7 @@ export function compileCollections(ctx) {
|
|
|
163
203
|
const collLayers = [];
|
|
164
204
|
for (const l of layers) {
|
|
165
205
|
if (!l.records.includes(name)) continue;
|
|
166
|
-
const why = runtime ? 'is a compiled source' : owner === 'module' ? `is \`storage.owner: module\` — one shared list read from the module's clone, which a layer would duplicate` : a.under ? 'is stored under another collection (storage.under) — a placed collection is not layered' : null;
|
|
206
|
+
const why = runtime ? 'is a compiled source' : owner === 'module' ? `is \`storage.owner: module\` — one shared list read from the module's clone, which a layer would duplicate` : a.under ? 'is stored under another collection (storage.under) — a placed collection is not layered' : pointed ? 'is env-pointed (its storage.path is a template) — its records are per machine, not a clone\'s' : null;
|
|
167
207
|
if (why) fail(`git_modules.${l.name}.records names "${name}", which ${why}`);
|
|
168
208
|
collLayers.push({ name: l.name, path: `${l.root}/${a.path ?? defaultStoragePath(name, namespaces, l.dataPath)}`, repo: l.root });
|
|
169
209
|
}
|
|
@@ -273,6 +313,8 @@ export function compileCollections(ctx) {
|
|
|
273
313
|
fields: resolved,
|
|
274
314
|
json_schema: jsonSchema,
|
|
275
315
|
...(collLayers.length ? { layers: collLayers } : {}),
|
|
316
|
+
...(external ? { external: true } : {}),
|
|
317
|
+
...(unavailable ? { unavailable } : {}),
|
|
276
318
|
},
|
|
277
319
|
storage: { path: storagePath, format, shape: a.shape ?? 'file', entry: a.entry, under: a.under, repo, runtime },
|
|
278
320
|
});
|
package/src/compile.js
CHANGED
|
@@ -518,9 +518,16 @@ export function compile(ws) {
|
|
|
518
518
|
for (const [k, mods] of requestedVars) {
|
|
519
519
|
if (!declaredVars.includes(k)) for (const mod of mods) console.warn(`⚠ module ${mod} reads \${env:${k}} — add it to the workspace's dreamteamer.vars`);
|
|
520
520
|
}
|
|
521
|
+
// ⚠ THE ONE PARSE of .env, shared with the collections pass: an env-pointed `storage.path`
|
|
522
|
+
// renders against exactly the values the warnings below name keys from. Values never reach any
|
|
523
|
+
// output or the manifest; a rendered storage path is the one thing a value becomes, and it lands
|
|
524
|
+
// only in the gitignored runtime. `declared` is the workspace's own list plus every module's
|
|
525
|
+
// request — the descriptor that names a var is the request to render it (compile-collections).
|
|
526
|
+
const envPath = path.join(root, '.env');
|
|
527
|
+
const parsedEnv = parseEnvValues(fs.existsSync(envPath) ? fs.readFileSync(envPath, 'utf8') : '');
|
|
528
|
+
const storageVars = { env: parsedEnv, workspaceFolder: root, declared: new Set([...declaredVars, ...requestedVars.keys()]) };
|
|
521
529
|
if (declaredEnv.size || declaredVars.length) {
|
|
522
530
|
// .env is parsed for KEY names ONLY — values never reach any output or the manifest
|
|
523
|
-
const envPath = path.join(root, '.env');
|
|
524
531
|
if (!fs.existsSync(envPath)) {
|
|
525
532
|
if (declaredEnv.size) console.warn(`⚠ no .env — modules declare env keys: ${[...declaredEnv.keys()].join(', ')} (see .env.example)`);
|
|
526
533
|
if (declaredVars.length) console.warn(`⚠ no .env — dreamteamer.vars declares ${declaredVars.join(', ')}, so no \${env:…} template can render here (see .env.example)`);
|
|
@@ -535,7 +542,6 @@ export function compile(ws) {
|
|
|
535
542
|
// A key present with an EMPTY (or whitespace-only) value is treated as absent, same as
|
|
536
543
|
// resolve's renderTemplate — `FILES_FOLDER=` must warn here exactly as `FILES_FOLDER`
|
|
537
544
|
// missing entirely would, or compile says nothing and resolve fails on the same line.
|
|
538
|
-
const parsedEnv = parseEnvValues(fs.readFileSync(envPath, 'utf8'));
|
|
539
545
|
const present = new Set([...parsedEnv].filter(([, v]) => v.trim() !== '').map(([k]) => k));
|
|
540
546
|
for (const [k, mods] of declaredEnv) {
|
|
541
547
|
if (present.has(k)) continue;
|
|
@@ -878,7 +884,7 @@ export function compile(ws) {
|
|
|
878
884
|
runtimeKinds: new Set([...kinds, ...DERIVED_KINDS]), core: CORE_COLLECTIONS,
|
|
879
885
|
moduleDeps, modulePeers, channelOf, wsModuleName, engineName, dataOwners,
|
|
880
886
|
moduleSources: new Map(sources.map((s) => [s.name, s])), unownableBecause, layers,
|
|
881
|
-
repoOf: (moduleRoot) => repoRootOf(moduleRoot, root), rel, dataPath: config.data_path ?? 'data',
|
|
887
|
+
repoOf: (moduleRoot) => repoRootOf(moduleRoot, root), rel, dataPath: config.data_path ?? 'data', vars: storageVars,
|
|
882
888
|
moduleId, fail: collectionsFail, warn: (m) => console.warn(m),
|
|
883
889
|
});
|
|
884
890
|
refusePlacementTransitions(root, compiledColls);
|
|
@@ -1038,7 +1044,9 @@ export function compile(ws) {
|
|
|
1038
1044
|
const text = e.bytes.toString('utf8');
|
|
1039
1045
|
e.bytes = Buffer.from(`${text}${text.endsWith('\n') ? '' : '\n'}${dump({ compiled: { display: viewDisplay(d ? displayOf(d) : {}, view) } })}`);
|
|
1040
1046
|
}
|
|
1041
|
-
|
|
1047
|
+
// a command's id is its path under commands/, folders included: `commands/rnd/design.command.md` is
|
|
1048
|
+
// `rnd/design`, typed as `/rnd:design` — the folder is the namespace, as claude-code already reads it
|
|
1049
|
+
const commandIds = new Set([...entries.keys()].filter((k) => k.startsWith('commands/')).map((k) => k.slice('commands/'.length).replace(/\.command\.md$/, '')));
|
|
1042
1050
|
for (const [rt, e] of entries) {
|
|
1043
1051
|
if (!rt.startsWith('command-bindings/')) continue;
|
|
1044
1052
|
const file = e.sources[0].path;
|
package/src/descriptor.js
CHANGED
|
@@ -56,6 +56,12 @@ export function storageOf(d) {
|
|
|
56
56
|
suffix: a.suffix ?? s.suffix,
|
|
57
57
|
repo: block(d).repo ?? '.',
|
|
58
58
|
runtime: block(d).runtime === true,
|
|
59
|
+
// An env-pointed root (`storage.path: ${env:NAME}/…`), rendered by compile for THIS machine.
|
|
60
|
+
// `external`: the rendered folder is outside the workspace, so no repo here publishes it.
|
|
61
|
+
// `unavailable`: it could not render (the var is unset or empty) and this says why — `path` is
|
|
62
|
+
// then still the template, and a reader refuses or skips rather than touching a literal folder.
|
|
63
|
+
external: block(d).external === true,
|
|
64
|
+
unavailable: block(d).unavailable ?? null,
|
|
59
65
|
};
|
|
60
66
|
// write root first, then each record layer (a clone whose listed collections are read here)
|
|
61
67
|
out.layers = (block(d).layers ?? []).map((l) => ({ name: l.name, path: l.path, repo: l.repo }));
|
package/src/events.js
CHANGED
|
@@ -17,6 +17,7 @@ export function deriveEvents(root, descriptors, from, to = 'HEAD') {
|
|
|
17
17
|
const byRepo = new Map();
|
|
18
18
|
for (const d of descriptors.values()) {
|
|
19
19
|
if (storageOf(d).runtime) continue; // runtime entities aren't item events
|
|
20
|
+
if (storageOf(d).external || storageOf(d).unavailable) continue; // an env-pointed root: no repo here holds its history
|
|
20
21
|
for (const { path: p, repo } of storageOf(d).roots) {
|
|
21
22
|
if (!p) continue;
|
|
22
23
|
if (!byRepo.has(repo)) byRepo.set(repo, []);
|
|
@@ -103,6 +104,7 @@ export function pathToRecord(descriptors, relPath) {
|
|
|
103
104
|
let best = null; // { d, base } — the longest root, across the write root and every record layer
|
|
104
105
|
for (const d of descriptors.values()) {
|
|
105
106
|
if (storageOf(d).runtime) continue; // runtime entities aren't item events
|
|
107
|
+
if (storageOf(d).unavailable) continue; // its path is still the template — a literal `${env:…}/` folder is nobody's record
|
|
106
108
|
for (const { path: base } of storageOf(d).roots) {
|
|
107
109
|
if (!base || !relPath.startsWith(base + '/')) continue;
|
|
108
110
|
if (best && base.length <= best.base.length) continue;
|
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
|
-
|
|
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] :
|
|
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) =>
|
|
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(
|
|
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) => `-
|
|
543
|
+
...buildCommandsIndex(entries).map((c) => `- \`${slash(c.id)}\` — ${c.desc}`),
|
|
542
544
|
);
|
|
543
545
|
}
|
|
544
546
|
return lines.join('\n');
|
package/src/history.js
CHANGED
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
import { execFileSync } from 'node:child_process';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import { RUNTIME_DIR, readManifest } from './runtime.js';
|
|
11
|
+
import { storageOf } from './descriptor.js';
|
|
12
|
+
|
|
13
|
+
/** A record under an env-pointed root outside the workspace has no repo here, so no past: said in
|
|
14
|
+
* one sentence rather than as git's "outside repository". */
|
|
15
|
+
function assertInRepo(descriptor, collection, id) {
|
|
16
|
+
if (storageOf(descriptor).external) throw new Error(`${collection}/${id} is kept under ${storageOf(descriptor).path}, outside every git repo here — it has no history`);
|
|
17
|
+
}
|
|
11
18
|
|
|
12
19
|
const FORMAT = '%H%x00%an%x00%aI%x00%s';
|
|
13
20
|
|
|
@@ -45,6 +52,7 @@ const repoOf = (store, descriptor, file) => path.resolve(store.root, store.repoO
|
|
|
45
52
|
|
|
46
53
|
export function history(store, collection, id) {
|
|
47
54
|
const { file, descriptor } = store.read(collection, id);
|
|
55
|
+
assertInRepo(descriptor, collection, id);
|
|
48
56
|
const cwd = repoOf(store, descriptor, file);
|
|
49
57
|
const paths = trackedPaths(store, file, cwd);
|
|
50
58
|
const follow = paths.length === 1 ? ['--follow'] : [];
|
|
@@ -62,6 +70,7 @@ export function history(store, collection, id) {
|
|
|
62
70
|
/** The patch one revision applied to this record. `hash~1` means the ROOT commit has no diff. */
|
|
63
71
|
export function historyDiff(store, collection, id, hash = 'HEAD') {
|
|
64
72
|
const { file, descriptor } = store.read(collection, id);
|
|
73
|
+
assertInRepo(descriptor, collection, id);
|
|
65
74
|
const cwd = repoOf(store, descriptor, file);
|
|
66
75
|
const paths = trackedPaths(store, file, cwd);
|
|
67
76
|
const diff = execFileSync('git', ['diff', `${hash}~1`, hash, '--', ...paths], { cwd }).toString();
|
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, ':')}`;
|
package/src/record-commands.js
CHANGED
|
@@ -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:
|
|
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 ?
|
|
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
|
package/src/schema-ops.js
CHANGED
|
@@ -1647,7 +1647,7 @@ export function removeCollection(ws, store, name, { force = false } = {}) {
|
|
|
1647
1647
|
}
|
|
1648
1648
|
const dest = path.join(ws.root, base);
|
|
1649
1649
|
const storage = storageOf(d);
|
|
1650
|
-
const dataDir = path.
|
|
1650
|
+
const dataDir = path.resolve(ws.root, storage.path); // resolve: an env-pointed root is absolute
|
|
1651
1651
|
// the index, not only the folder: a collection stored UNDER another keeps most of its records
|
|
1652
1652
|
// inside the parent's folders, where a readdir of its own root sees nothing
|
|
1653
1653
|
const hasRecords = store.ids(name).size > 0 || (fs.existsSync(dataDir) && fs.readdirSync(dataDir).some((e) => !e.startsWith('.')));
|
package/src/store.js
CHANGED
|
@@ -242,7 +242,17 @@ export class Store {
|
|
|
242
242
|
* the FALLBACK root — where a record with no owner lives — and not an enumeration of where its
|
|
243
243
|
* records are: that is `ids()`, and the directories git has to be asked about are `recordDirs`. */
|
|
244
244
|
dir(d) {
|
|
245
|
-
return path.
|
|
245
|
+
return path.resolve(storageOf(d).runtime ? this.runtime : this.root, this.rootPath(d));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** The write root's path as compile resolved it — absolute for an env-pointed root outside the
|
|
249
|
+
* workspace, which is why every root is `path.resolve`d and never `path.join`ed. ⚠ An env-pointed
|
|
250
|
+
* root that could NOT render on this machine refuses HERE, at the first verb that would touch it:
|
|
251
|
+
* the alternative was reading and writing a literal `${env:NAME}/` folder with every verb saying ✔. */
|
|
252
|
+
rootPath(d) {
|
|
253
|
+
const s = storageOf(d);
|
|
254
|
+
if (s.unavailable) throw new Error(`collection "${d.name}" keeps its records at ${s.path}, which cannot render on this machine — ${s.unavailable}. Set it in .env and run dreamteamer compile; nothing was read or written.`);
|
|
255
|
+
return s.path;
|
|
246
256
|
}
|
|
247
257
|
|
|
248
258
|
/** The parent collection's folder, for a collection stored under one. */
|
|
@@ -260,7 +270,8 @@ export class Store {
|
|
|
260
270
|
/** Every root a record of `d` can be READ from, write root first, then each record layer — another
|
|
261
271
|
* workspace cloned under git_modules/ whose manifest entry lists this collection. */
|
|
262
272
|
rootsOf(d) {
|
|
263
|
-
|
|
273
|
+
this.rootPath(d); // the refusal, before any root is resolved
|
|
274
|
+
return storageOf(d).roots.map((r) => ({ ...r, abs: path.resolve(storageOf(d).runtime ? this.runtime : this.root, r.path) }));
|
|
264
275
|
}
|
|
265
276
|
|
|
266
277
|
/** Does a record layer contribute to `d`? Such a collection is indexed across every root. */
|
|
@@ -592,6 +603,7 @@ export class Store {
|
|
|
592
603
|
const d = this.descriptor(collection);
|
|
593
604
|
if (!fieldsOf(d).created) return undefined;
|
|
594
605
|
if (fields?.created) return fields.created;
|
|
606
|
+
if (storageOf(d).external) return undefined; // outside every repo here: no commit ever held it
|
|
595
607
|
const from = [idsOf(d).from ?? []].flat();
|
|
596
608
|
if (/^\{\{\s*created\b/.test(String(from[0] ?? ''))) {
|
|
597
609
|
const day = /(\d{4}-\d{2}-\d{2})/.exec(id)?.[1];
|
|
@@ -650,6 +662,7 @@ export class Store {
|
|
|
650
662
|
const d = this.writableDescriptor(collection);
|
|
651
663
|
this.assertUnambiguous(collection, id);
|
|
652
664
|
const { fields: currentFields, file } = this.read(collection, id);
|
|
665
|
+
if (storageOf(d).external) throw new Error(`${collection}/${id} is kept under ${storageOf(d).path}, outside every git repo here — there is no revision to revert to. nothing was reverted.`);
|
|
653
666
|
// A placed record may have sat in ANOTHER parent's folder at `hash` — the move is what is being
|
|
654
667
|
// reverted — so the historical path is looked up in that commit's tree, not assumed to be today's.
|
|
655
668
|
// `<rev>:<path>` takes `/` on every OS — Windows' path.relative spells it with `\`
|
|
@@ -1409,6 +1422,7 @@ export class Store {
|
|
|
1409
1422
|
*recordFiles() {
|
|
1410
1423
|
const seen = new Set();
|
|
1411
1424
|
for (const d of this.descriptors.values()) {
|
|
1425
|
+
if (storageOf(d).unavailable) continue; // an env-pointed root this machine cannot render: nothing to walk
|
|
1412
1426
|
// for runtime-based collections, inbound-ref surgery targets SOURCES, not the runtime
|
|
1413
1427
|
// a layer's records name records of this workspace too, so a removal or a rename must see them
|
|
1414
1428
|
const dirs = storageOf(d).runtime ? this.sourceRoots().map((r) => path.join(r, storageOf(d).path)) : this.rootsOf(d).map((r) => r.abs);
|
|
@@ -1613,6 +1627,11 @@ export class Store {
|
|
|
1613
1627
|
* `repo` is the workspace-relative root of the git repo that owns them ('.' = workspace). */
|
|
1614
1628
|
commit(files, subject, undo, repo = '.') {
|
|
1615
1629
|
if (!this.autoCommit) return;
|
|
1630
|
+
// A file under an env-pointed root outside the workspace is outside every repo here BY DESIGN
|
|
1631
|
+
// — never handed to git, which would refuse it and roll the write back.
|
|
1632
|
+
const outside = (this._outside ??= [...this.descriptors.values()].filter((d) => storageOf(d).external).map((d) => path.resolve(this.root, storageOf(d).path) + path.sep));
|
|
1633
|
+
files = files.filter((f) => !outside.some((o) => path.resolve(f).startsWith(o)));
|
|
1634
|
+
if (!files.length) return;
|
|
1616
1635
|
// ONE COMMIT PER REPO. The record's own repo is `repo`; a file a rename rewrote in a record
|
|
1617
1636
|
// layer belongs to that layer's clone, so the files are grouped by the longest known repo that
|
|
1618
1637
|
// holds each. A failure in a later group leaves an earlier group's commit standing — the same
|