dreamteamer 0.35.0 → 0.36.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.35.0",
3
+ "version": "0.36.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>",
package/src/cli.js CHANGED
@@ -441,6 +441,8 @@ export async function run(argv) {
441
441
  if (!results.length) { console.log('nothing pending'); process.exit(0); }
442
442
  for (const r of results) {
443
443
  if (r.blocked) { console.error(`✖ ${r.repo}: ${r.blocked} — ${r.rows.length} record(s) left uncommitted`); continue; }
444
+ if (r.failed) { console.error(`✖ ${r.repo}: ${r.failed} — ${r.rows.length} record(s) left uncommitted, nothing staged`); continue; }
445
+ 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; }
444
446
  if (r.warning) console.warn(`⚠ ${r.repo}: ${r.warning}`);
445
447
  console.log(`✔ ${r.repo === '.' ? 'workspace' : r.repo}${r.sha ? ` ${r.sha}` : ' (dry run)'} — ${r.subject}`);
446
448
  for (const row of r.rows.slice(0, ROWS_SHOWN)) console.log(` ${row.verb} ${row.collection}/${row.id}`);
@@ -474,7 +476,7 @@ export async function run(argv) {
474
476
  console.warn(' (if that refuses as entangled, the refusal names the other pending records — add them to the same command)');
475
477
  }
476
478
  }
477
- process.exit(results.some((r) => r.blocked) ? 1 : 0);
479
+ process.exit(results.some((r) => r.blocked || r.failed) ? 1 : 0);
478
480
  }
479
481
  case 'status': {
480
482
  const s = staleness(ws.root);
package/src/commit.js CHANGED
@@ -21,6 +21,10 @@ const QUIET = ['ignore', 'pipe', 'ignore'];
21
21
  // moved. So the one call that writes to stdin spells its stdio out itself rather than reusing QUIET.
22
22
  const QUIET_IN = ['pipe', 'pipe', 'ignore'];
23
23
 
24
+ // The two calls that MAKE the commit keep git's stderr, piped: a refusing hook says why on it, and
25
+ // that line is the whole report when the commit fails — so it is read, not inherited or dropped.
26
+ const QUIET_ERR = ['ignore', 'pipe', 'pipe'];
27
+
24
28
  // One batch is one buffer, and execFileSync's default ceiling is 1 MiB — less than a collection's
25
29
  // worth of pre-images. 64 MiB is ~40,000 record files at the size a text record actually runs to,
26
30
  // and going over it is not a failure: the batch returns nothing and every row falls back to its own
@@ -496,6 +500,13 @@ function commitPlan(store, { only = [], message, dryRun = false } = {}) {
496
500
  const reader = edgeReader(store, rels, sampled);
497
501
  const sweep = targets.scoped ? planSweep(targets, reader) : new Set();
498
502
  const results = [];
503
+ // ⚠ ONE COMMIT PER REPO, AND NOT ATOMIC ACROSS THEM — git has no transaction spanning clones.
504
+ // What the verb owes instead is an honest report: a repo whose commit fails has its index reset
505
+ // (as the store's own auto-commit does) and is named, the repos before it keep their commits and
506
+ // stay in the report, and the repos after it are NOT attempted and are named as left pending.
507
+ // Before this, a refusing hook in the second of three repos left the first commit standing, the
508
+ // second repo's index staged, the third untouched, and printed nothing at all.
509
+ let failed = null;
499
510
  for (const { repo, cwd, rows: all } of sampled) {
500
511
  // The SAMPLER is deliberately left alone — it is what makes a hand-edited record
501
512
  // indistinguishable from one the store wrote. Narrowing happens HERE, on the sampled rows, so
@@ -516,6 +527,7 @@ function commitPlan(store, { only = [], message, dryRun = false } = {}) {
516
527
  const leftPending = targets.whole.size ? partnersLeftPending(reader, published) : [];
517
528
  const warning = detached(cwd) ? 'HEAD is detached — this commit will be reachable only by sha' : null;
518
529
  const subject = message ?? composeSubject(rows);
530
+ if (failed) { results.push({ repo, rows, pending: `not attempted, ${failed} failed first` }); continue; }
519
531
  if (!dryRun) {
520
532
  const paths = rows.map((r) => r.repoRel);
521
533
  // A rename only reports as `R` once it is STAGED, so its old path is in neither the
@@ -525,8 +537,17 @@ function commitPlan(store, { only = [], message, dryRun = false } = {}) {
525
537
  // `--all` here is PATHSPEC-SCOPED — "including deletions of these named files", not
526
538
  // "everything in the tree" (the unscoped form CLAUDE.md rule 6 forbids). Same shape
527
539
  // store.js has always used.
528
- execFileSync('git', ['add', '--all', '--', ...paths], { cwd });
529
- execFileSync('git', ['commit', '--quiet', '-m', subject, '--', ...paths, ...alreadyStaged], { cwd });
540
+ try {
541
+ execFileSync('git', ['add', '--all', '--', ...paths], { cwd, stdio: QUIET_ERR });
542
+ execFileSync('git', ['commit', '--quiet', '-m', subject, '--', ...paths, ...alreadyStaged], { cwd, stdio: QUIET_ERR });
543
+ } catch (e) {
544
+ try { execFileSync('git', ['reset', '--quiet', '--', ...paths], { cwd, stdio: QUIET }); } catch { /* nothing staged */ }
545
+ store.headMoved(); // a commit that threw may still have moved HEAD — see store.gitHead
546
+ failed = repo === '.' ? 'workspace' : repo;
547
+ const why = (e.stderr?.toString().trim().split('\n')[0]) || e.message.split('\n')[0];
548
+ results.push({ repo, rows, failed: `git commit failed — ${why}` });
549
+ continue;
550
+ }
530
551
  store.headMoved(); // the verb that exists to move HEAD — see store.gitHead
531
552
  }
532
553
  const sha = dryRun ? null : execFileSync('git', ['rev-parse', '--short', 'HEAD'], { cwd }).toString().trim();
package/src/events.js CHANGED
@@ -10,15 +10,18 @@ import { storageOf } from './descriptor.js';
10
10
  /** Record events between two points, across EVERY repo that holds records. `from` is a sha or a
11
11
  * date — a sha is meaningless in another repo, so it is resolved to its commit DATE and each
12
12
  * repo then resolves that date to its own sha. Still cursor-less and stores nothing, so it can
13
- * be run twice with no consequence. */
13
+ * be run twice with no consequence. Every ROOT of a collection is sampled — the write root and
14
+ * each record layer's — and an event carries the repo it was read from; sampling the write root
15
+ * alone answered `events: []` for a commit made in a layer's clone. */
14
16
  export function deriveEvents(root, descriptors, from, to = 'HEAD') {
15
17
  const byRepo = new Map();
16
18
  for (const d of descriptors.values()) {
17
- const p = storageOf(d).path;
18
- if (!p || storageOf(d).runtime) continue; // runtime entities aren't item events
19
- const repo = storageOf(d).repo;
20
- if (!byRepo.has(repo)) byRepo.set(repo, []);
21
- byRepo.get(repo).push(p);
19
+ if (storageOf(d).runtime) continue; // runtime entities aren't item events
20
+ for (const { path: p, repo } of storageOf(d).roots) {
21
+ if (!p) continue;
22
+ if (!byRepo.has(repo)) byRepo.set(repo, []);
23
+ if (!byRepo.get(repo).includes(p)) byRepo.get(repo).push(p);
24
+ }
22
25
  }
23
26
  const when = asDate(root, from);
24
27
  const events = [];
@@ -87,11 +87,12 @@ export function parseRecordText(text: string, d: Descriptor, bodyField?: string
87
87
  export function idFromRecordPath(d: Descriptor, file: string): string;
88
88
  /** 0 clean · 1 violations · 2 no compiled runtime; prints its report */
89
89
  export function check(ws: { root: string; pkg?: unknown }, opts?: { extra?: { file: string; msg: string }[] }): 0 | 1 | 2;
90
- export function commitPending(store: Store, opts?: { only?: string[]; message?: string; dryRun?: boolean }): { repo: string; sha?: string; subject: string; rows: { verb: string; collection: string; id: string }[]; blocked?: string; warning?: string; leftPending?: string[] }[];
90
+ export function commitPending(store: Store, opts?: { only?: string[]; message?: string; dryRun?: boolean }): { repo: string; sha?: string; subject: string; rows: { verb: string; collection: string; id: string }[]; blocked?: string; failed?: string; pending?: string; warning?: string; leftPending?: string[] }[];
91
91
  export function composeSubject(rows: unknown[]): string;
92
92
  export function history(store: Store, collection: string, id: string): { hash: string; date: string; author: string; subject: string }[];
93
93
  export function historyDiff(store: Store, collection: string, id: string, hash?: string): { hash: string; path: string; diff: string };
94
- export function deriveEvents(root: string, descriptors: Descriptors, since: string, head?: string): { type: string; collection: string; id: string }[];
94
+ /** Every root of every collection is sampled — the write root and each record layer's clone. `since` is a sha or a date; a sha is resolved to its commit date in the workspace and each repo resolves that date to its own sha. `repo` is the workspace-relative repo the event was read from ('.' = the workspace). */
95
+ export function deriveEvents(root: string, descriptors: Descriptors, since: string, head?: string): { type: 'item-added' | 'item-updated' | 'item-removed'; collection: string; id: string; path: string; repo: string }[];
95
96
  export function relationsOf(descriptors: Descriptors): any[];
96
97
 
97
98
  // ---- values, references and queries ------------------------------------------------------------------
package/src/store.js CHANGED
@@ -1327,9 +1327,19 @@ export class Store {
1327
1327
  const parentChanged = nested && newParent !== parentOfNestedId(oldId);
1328
1328
  if (nested && !newId.includes('/')) throw new Error(`${collection}/${newId}: ids of ${collection} begin with their ${under.parent}'s id — nothing was renamed.`);
1329
1329
  if (parentChanged && !this.ids(under.collection).has(newParent)) throw new Error(`${collection}/${newId}: there is no ${under.collection}/${newParent} to move it under — nothing was renamed.`);
1330
+ // ⚠ The destination is DERIVED, never looked up: recordRoot answers for a record that EXISTS —
1331
+ // from the index for a layered collection and for an opaque one — so asking it for the new id
1332
+ // threw "no such record" on every rename of a workspace-own record once any layer contributed
1333
+ // to the collection (clone on disk or not), and on every rename of a `format: binary` record.
1334
+ // The record is in the write root (a layer's was refused above), so its new unit is the write
1335
+ // root's: the folder for a folder shape, the file otherwise — keeping the extension an opaque
1336
+ // record carries, which only its current file name knows.
1330
1337
  const newUnit = nested
1331
1338
  ? path.join(placedRoot(under, this.dir(d), this.parentDir(d), newParent), recordFileName(d, localOfNestedId(newId)))
1332
- : placementOf(d) ? path.join(this.rootOfFile(d, oldUnit), recordFileName(d, newId)) : this.recordRoot(d, newId);
1339
+ : placementOf(d) ? path.join(this.rootOfFile(d, oldUnit), recordFileName(d, newId))
1340
+ : storageOf(d).shape === 'folder' ? path.join(this.dir(d), newId)
1341
+ : storageOf(d).format === 'binary' ? path.join(this.dir(d), `${newId}.${storageOf(d).suffix}${path.extname(oldUnit)}`)
1342
+ : path.join(this.dir(d), recordFileName(d, newId));
1333
1343
  this._assertContained(d, newUnit);
1334
1344
  if (fs.existsSync(newUnit) || (placementOf(d) && this.ids(collection).has(newId))) throw new Error(`${collection}/${newId} already exists — nothing was renamed.`);
1335
1345
  return this.withWriteLock(() => {
@@ -1607,8 +1617,12 @@ export class Store {
1607
1617
  // layer belongs to that layer's clone, so the files are grouped by the longest known repo that
1608
1618
  // holds each. A failure in a later group leaves an earlier group's commit standing — the same
1609
1619
  // per-repo truth `dt commit` prints, stated here rather than pretended away.
1620
+ // ⚠ A file under NO known clone is the workspace's — never the caller's repo. The fallback used
1621
+ // to be `repo`, so renaming a module-owned record that a workspace record named sent the
1622
+ // workspace's rewritten `data/tasks/…` to `git add` inside the module clone as `../../data/…`,
1623
+ // which git refuses, and the rename rolled back every time auto-commit was on.
1610
1624
  const repos = (this._repos ??= [...new Set([...this.descriptors.values()].flatMap((d) => storageOf(d).roots.map((r) => r.repo)))].filter((r) => r !== '.').sort((a, b) => b.length - a.length));
1611
- const repoOf = (f) => { const rel = path.relative(this.root, f).split(path.sep).join('/'); return repos.find((r) => rel.startsWith(`${r}/`)) ?? repo; };
1625
+ const repoOf = (f) => { const rel = path.relative(this.root, f).split(path.sep).join('/'); return [...repos, repo].find((r) => r !== '.' && rel.startsWith(`${r}/`)) ?? '.'; };
1612
1626
  const groups = new Map();
1613
1627
  for (const f of files) { const r = repoOf(f); if (!groups.has(r)) groups.set(r, []); groups.get(r).push(f); }
1614
1628
  for (const [r, group] of groups) this._commitIn(path.resolve(this.root, r), group, subject, undo);