dreamteamer 0.46.0 → 0.46.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dreamteamer",
3
- "version": "0.46.0",
3
+ "version": "0.46.1",
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/checkout.js CHANGED
@@ -144,7 +144,8 @@ export function observeState(ws) {
144
144
  // the first install only this workspace's own are visible.
145
145
  gitModules: [...new Set([
146
146
  ...[...declaredGitModules(ws.pkg, ws.root).map].filter(([n, m]) => !resolves(here(path.join('git_modules', n))) || offRef(here(path.join('git_modules', n)), m.ref) || m.declarers.some((by) => by && !resolves(here(path.join(by, 'git_modules', n))))).map(([n]) => n),
147
- ...declaredGitModules(ws.pkg, ws.root).nested.filter((c) => !resolves(here(path.join(c.by, 'git_modules', c.name))) || offRef(here(path.join(c.by, 'git_modules', c.name)), c.ref)).map((c) => c.name),
147
+ // a nested copy that is still a LINK (laid while the declarer agreed with the top) is work to do
148
+ ...declaredGitModules(ws.pkg, ws.root).nested.filter((c) => isLink(here(path.join(c.by, 'git_modules', c.name))) || !resolves(here(path.join(c.by, 'git_modules', c.name))) || offRef(here(path.join(c.by, 'git_modules', c.name)), c.ref)).map((c) => c.name),
148
149
  ])],
149
150
  stale: !s.compiled || s.stale.length > 0,
150
151
  postinstall: ws.pkg.dreamteamer?.postinstall ?? null,
@@ -275,12 +276,15 @@ const RUN = {
275
276
  * any step errored — one failure never abandons the rest, because a checkout half-made-ready with
276
277
  * a named failure is more useful than one that stopped at the first thing it could not do. */
277
278
  export async function applyInstall(ws, state, steps, { dryRun = false, log = console.log, stdio = 'inherit', npm = resolveNpm(), open = null } = {}) {
278
- let failed = 0, installed = false;
279
+ let failed = 0, installed = false, restored = false;
279
280
  for (const s of steps) {
280
281
  // ⚠ NEW PACKAGES ARE NEW SOURCES. The plan judged the runtime fresh BEFORE npm put a module (or an
281
282
  // extension) into node_modules, so a compiled workspace that just gained a dependency kept the
282
283
  // old runtime at exit 0. Once dependencies were installed, the compile runs whatever the plan said.
283
- if (s.id === 'compile' && installed && s.state === 'already') Object.assign(s, { label: 'compile: dependencies were just installed', state: 'todo' });
284
+ // ⚠ A RESTORED LAYER IS A NEW INPUT TOO: compile bakes a layer's package name and data path into the
285
+ // runtime, and staleness hashes sources only — so a layer the git_modules step just cloned left
286
+ // `✔ compile: fresh` and a runtime that did not know it (the first review of 0.46.0, finding eng-03).
287
+ if (s.id === 'compile' && (installed || restored) && s.state === 'already') Object.assign(s, { label: installed ? 'compile: dependencies were just installed' : 'compile: git modules were just restored', state: 'todo' });
284
288
  const glyph = s.state === 'todo' ? '▶' : s.state === 'already' ? '✔' : '—';
285
289
  log(`${glyph} ${s.label}${s.why ? `\n ${s.why}` : ''}`);
286
290
  if (s.state !== 'todo' || dryRun) continue;
@@ -295,6 +299,7 @@ export async function applyInstall(ws, state, steps, { dryRun = false, log = con
295
299
  const code = RUN[kind](ws, state, rel, stdio, npm);
296
300
  if (code !== 0) { failed++; log(`✖ ${s.id} failed (exit ${code})`); }
297
301
  else if (kind === 'dependencies') installed = true;
302
+ else if (kind === 'git_modules') restored = true;
298
303
  }
299
304
  return failed ? 1 : 0;
300
305
  }
package/src/init.js CHANGED
@@ -200,6 +200,11 @@ export function install({ root, pkg }) {
200
200
  for (const t of [...top, ...under]) {
201
201
  done.add(t.by ? `${t.by}/${t.name}` : t.name);
202
202
  fs.mkdirSync(path.dirname(t.dest), { recursive: true });
203
+ // ⚠ A LINK IS NOT A CLONE. A declarer that agreed with the top at the first install was given a
204
+ // link; once its declaration diverges its copy is nested HERE, and the link standing where the
205
+ // nested clone goes must be replaced — never re-pointed through, which would move the shared
206
+ // top-level clone every other reader sits on (the first review of 0.46.0, finding eng-01).
207
+ if (t.by && isLink(t.dest)) fs.unlinkSync(t.dest);
203
208
  if (fs.existsSync(t.dest)) { if (!repoint(t.dest, path.relative(path.join(root, 'git_modules'), t.dest), t.ref)) unreachable.push(t.name); continue; }
204
209
  clone(t.url, t.ref, t.dest, t.name, t.note);
205
210
  if (t.by) excludeIn(path.join(root, t.by), `git_modules/${t.name}`);
@@ -221,7 +226,8 @@ export function install({ root, pkg }) {
221
226
  * explicit on disk, resolved by a tool that knows nothing of dreamteamer. A clone of its own standing there
222
227
  * may hold work: left as it is, and said — `dt status` draws it too. */
223
228
  function linkLayer(root, by, name) {
224
- const at = path.join(root, by, 'git_modules', name), want = path.join('..', '..', name);
229
+ // relative from wherever the declarer sits — a nested copy's own needs link from two levels deeper
230
+ const at = path.join(root, by, 'git_modules', name), want = path.relative(path.dirname(at), path.join(root, 'git_modules', name));
225
231
  let st = null;
226
232
  try { st = fs.lstatSync(at); } catch { /* nothing there */ }
227
233
  if (st && !st.isSymbolicLink()) { console.log(`… ${by}/git_modules/${name} is a clone of its own — left as it is`); return; }
@@ -291,6 +297,7 @@ function tryGit(cwd, args, timeout = 30_000) {
291
297
  try { return execFileSync('git', args, { cwd, stdio: QUIET, timeout }).toString().trim() || null; } catch { return null; }
292
298
  }
293
299
 
300
+ const isLink = (p) => { try { return fs.lstatSync(p).isSymbolicLink(); } catch { return false; } };
294
301
  const ran = (cwd, args, timeout) => { try { execFileSync('git', args, { cwd, stdio: QUIET, timeout }); return true; } catch { return false; } };
295
302
  const commitOf = (dest, rev) => tryGit(dest, ['rev-parse', '--verify', '--quiet', `${rev}^{commit}`]);
296
303
 
@@ -299,7 +306,7 @@ const commitOf = (dest, rev) => tryGit(dest, ['rev-parse', '--verify', '--quiet'
299
306
  * what the clone already knows, so a settled clone costs no fetch. A folder that is not itself a
300
307
  * clone is never re-pointed: git would walk up and act on the workspace repo. */
301
308
  export function offRef(dest, ref) {
302
- if (!fs.existsSync(path.join(dest, '.git'))) return false;
309
+ if (isLink(dest) || !fs.existsSync(path.join(dest, '.git'))) return false; // never judged, never moved, through a link
303
310
  if (tryGit(dest, ['symbolic-ref', '--quiet', '--short', 'HEAD']) === ref) return false;
304
311
  const branch = ['refs/heads/', 'refs/remotes/origin/'].some((p) => tryGit(dest, ['rev-parse', '--verify', '--quiet', p + ref]));
305
312
  return branch || !commitOf(dest, ref) || commitOf(dest, ref) !== commitOf(dest, 'HEAD');