Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(review): address review feedback on worktree linking and pregate hint
[._.]/ Adam Eivy1e62accc0506
diff --git a/scripts/link-worktree-deps.test.js b/scripts/link-worktree-deps.test.jsindex 89d5b3025e..0e943925d9 100644--- a/scripts/link-worktree-deps.test.js+++ b/scripts/link-worktree-deps.test.js@@ -83,9 +83,10 @@ describe('link-worktree-deps script', () => {mkdirSync(join(source, 'node_modules'), { recursive: true });writeFileSync(join(source, 'node_modules', 'real-pkg.txt'), 'real');- // Simulate vitest creating a cache-only node_modules before linking+ // Simulate vitest creating cache directories before linkingmkdirSync(join(worktree, 'node_modules', '.vite'), { recursive: true });mkdirSync(join(worktree, 'node_modules', '.vitest-cache'), { recursive: true });+ mkdirSync(join(worktree, 'node_modules', '.cache'), { recursive: true });const result = runScript(source, worktree);@@ -111,8 +112,9 @@ describe('link-worktree-deps script', () => {expect(result.status).toBe(0);expect(lstatSync(join(worktree, 'node_modules')).isSymbolicLink()).toBe(false);expect(existsSync(join(worktree, 'node_modules', 'some-package', 'index.js'))).toBe(true);- expect(result.stdout).toContain('⚠️');- expect(result.stdout).toContain(join(worktree, 'node_modules'));+ const output = (result.stderr || '') + (result.stdout || '');+ expect(output).toContain('⚠️');+ expect(output).toContain(join(worktree, 'node_modules'));// Source checkout real node_modules is never touchedexpect(existsSync(join(source, 'node_modules', 'source-pkg.txt'))).toBe(true);});diff --git a/scripts/pregate.js b/scripts/pregate.jsindex 02179f46f8..d2176f1fe0 100644--- a/scripts/pregate.js+++ b/scripts/pregate.js@@ -676,16 +676,22 @@ async function main() {const dependencyProblems = dependencyConsistencyProblems(REPO_ROOT);if (dependencyProblems.length > 0) {- const gitCommonDir = git(['rev-parse', '--git-common-dir']);- const gitDir = git(['rev-parse', '--git-dir']);- const isLinkedWorktree = resolve(REPO_ROOT, gitCommonDir) !== resolve(REPO_ROOT, gitDir);- const primaryCheckout = isLinkedWorktree ? resolve(REPO_ROOT, gitCommonDir, '..') : null;+ let primaryCheckout = null;+ try {+ const gitCommonDir = git(['rev-parse', '--git-common-dir']);+ const gitDir = git(['rev-parse', '--git-dir']);+ if (resolve(REPO_ROOT, gitCommonDir) !== resolve(REPO_ROOT, gitDir)) {+ primaryCheckout = resolve(REPO_ROOT, gitCommonDir, '..');+ }+ } catch {+ // ignore git error+ }console.error('❌ Dependency consistency preflight failed; lint/tests have not run.');for (const { label, linked, owner, issues } of dependencyProblems) {console.error(` ${label} (${linked ? 'linked' : 'owned'} node_modules):\n${issues.map(issue => ` ${issue}`).join('\n')}`);- if (isLinkedWorktree && (!linked || issues.some(i => i.includes('missing') || i.includes('unreadable')))) {- console.error(` Worktree dependency dir is missing or unlinked for ${label}. Re-link with: node scripts/link-worktree-deps.js ${primaryCheckout || '<primary-checkout>'} ${REPO_ROOT}`);+ if (primaryCheckout && (linked || issues.some(i => i.includes('missing') || i.includes('unreadable')))) {+ console.error(` Worktree dependency dir is missing or unlinked for ${label}. Re-link with: node scripts/link-worktree-deps.js ${primaryCheckout} ${REPO_ROOT}`);} else {console.error(linked? ` Reconcile dependencies in the owning source checkout (${owner}), with a full development install (npm ci --include=dev), or validate in a separate clone with its own locked installs. Never run npm install/ci through worktree links.`diff --git a/server/services/worktreeManager.js b/server/services/worktreeManager.jsindex bb0326071a..18206aa113 100644--- a/server/services/worktreeManager.js+++ b/server/services/worktreeManager.js@@ -84,14 +84,14 @@ export async function linkWorktreeDependencies(sourceWorkspace, worktreePath) {if (!sourceExists) return;const targetStat = await lstat(targetPath).catch(() => null);if (targetStat) {- const isSymlink = typeof targetStat.isSymbolicLink === 'function' ? targetStat.isSymbolicLink() : false;- const isDir = typeof targetStat.isDirectory === 'function' ? targetStat.isDirectory() : !isSymlink;+ const isSymlink = targetStat.isSymbolicLink?.() ?? false;+ const isDir = targetStat.isDirectory?.() ?? !isSymlink;if (!isSymlink && isDir) {const entries = await readdir(targetPath).catch(() => null);if (entries !== null && entries.length > 0 && entries.every(name => CACHE_ENTRIES.has(name))) {await rm(targetPath, { recursive: true, force: true });} else {- console.log(`⚠️ linkWorktreeDependencies: skipping existing ${targetPath} (not a cache-only directory)`);+ console.warn(`⚠️ linkWorktreeDependencies: skipping existing ${targetPath} (not a cache-only directory)`);return;}} else {