The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Buddy and start specs pass on Windows (#3388)
harness-for-autonomous[bot]8fa1c2ba940f
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.ymlindex fbbee06b0..8805ea290 100644--- a/.github/workflows/windows.yml+++ b/.github/workflows/windows.yml@@ -178,7 +178,7 @@ jobs:# serialWindows.spec.ts runs the real harness-serial.exe, placed beside the host by the payload step.HARNESS_SERIAL_BIN: ${{ github.workspace }}\pty\target\${{ matrix.target }}\release\harness-serial.exerun: |- $paths = @('src/lib/ptyHostBackend.contract.spec.ts', 'src/lib/ptyHost', 'src/lib/windows', 'src/scripts/windowsCiChecks.spec.ts', 'src/team/windowsTeamRemove.real.spec.ts', 'src/lib/uninstall', 'src/engines/kit/hookRemoval.spec.ts', 'src/engines/kit/windowsHooks.spec.ts', 'src/engines/kit/windowsFiles.spec.ts', 'src/engines/kit/nativePaths.windows.spec.ts', 'src/engines/kit/launchExecutable.windows.spec.ts', 'src/dsh/runtime.windows.spec.ts', 'src/engines/removeHooks.spec.ts', 'src/engines/windowsHomes.spec.ts', 'src/cable/windowsSerial.spec.ts', 'src/cable/serialWindows.spec.ts')+ $paths = @('src/lib/ptyHostBackend.contract.spec.ts', 'src/lib/ptyHost', 'src/lib/windows', 'src/scripts/windowsCiChecks.spec.ts', 'src/team/windowsTeamRemove.real.spec.ts', 'src/lib/uninstall', 'src/engines/kit/hookRemoval.spec.ts', 'src/engines/kit/windowsHooks.spec.ts', 'src/engines/kit/windowsFiles.spec.ts', 'src/engines/kit/nativePaths.windows.spec.ts', 'src/engines/kit/launchExecutable.windows.spec.ts', 'src/dsh/runtime.windows.spec.ts', 'src/engines/removeHooks.spec.ts', 'src/engines/windowsHomes.spec.ts', 'src/cable/windowsSerial.spec.ts', 'src/cable/serialWindows.spec.ts', 'src/superTabs/buddyHome.spec.ts', 'src/superTabs/start.spec.ts', 'src/engines/kit/folderTrust.spec.ts')npx vitest run @paths --maxWorkers=1# Two real builds (sub-project G): the rollover from the previous host to this one (hostMove.real.spec.ts, and# drain.spec.ts's two-build case), and the payload install (the bin\ replacement, and install.ps1 in Windowsdiff --git a/cli/src/engines/kit/folderTrust.spec.ts b/cli/src/engines/kit/folderTrust.spec.tsindex a3641355d..7e631a061 100644--- a/cli/src/engines/kit/folderTrust.spec.ts+++ b/cli/src/engines/kit/folderTrust.spec.ts@@ -1,4 +1,4 @@-import { lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, symlinkSync, writeFileSync } from 'node:fs'+import { lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'import { join } from 'node:path'import { afterEach, describe, expect, it, vi } from 'vitest'@@ -7,6 +7,14 @@ import { launch as claude } from '../claude/launch.js'import { launch as codex } from '../codex/launch.js'import { recordAcceptanceIn, recordTrustIn, trustsIn } from './folderTrust.js'+/** Whether this account may link to a file: Windows lets it only with Developer Mode or as an administrator (Window of Tim,+ * #3815), and a person there with neither has no such link to write through. */+const canLinkFiles = (() => {+ const dir = mkdtempSync(join(tmpdir(), 'file-link-'))+ try { writeFileSync(join(dir, 'f'), ''); symlinkSync(join(dir, 'f'), join(dir, 'l'), 'file'); return true } catch { return false }+ finally { rmSync(dir, { recursive: true, force: true }) }+})()+// The former lib/claudeTrust.spec.ts, its cases unchanged, against the two engines' declared trust (`trust` in// claude/launch.ts and codex/launch.ts) applied by the kit, in the homes the former functions read.const preTrustClaudeProject = (cwd: string, home = launchClaudeConfigDir()) => recordTrustIn(claude.trust!, join(home, claude.trust!.file), cwd)@@ -71,7 +79,7 @@ describe('preTrustClaudeProject', () => {}})- it('writes through a symlinked ~/.claude.json instead of replacing the link', () => {+ it.runIf(canLinkFiles)('writes through a symlinked ~/.claude.json instead of replacing the link', () => {const home = mkdtempSync(join(tmpdir(), 'trust-'))mkdirSync(join(home, 'dotfiles'))writeFileSync(join(home, 'dotfiles', 'claude.json'), JSON.stringify({ projects: {} }))@@ -156,7 +164,7 @@ describe('preTrustCodexProject', () => {expect(preTrustCodexProject(cwd, join(home, '.codex'))).toBe('already')})- it('writes through a symlinked config.toml instead of replacing the link', () => {+ it.runIf(canLinkFiles)('writes through a symlinked config.toml instead of replacing the link', () => {const home = codexHome()mkdirSync(join(home, 'dotfiles'))mkdirSync(join(home, '.codex'))diff --git a/cli/src/superTabs/buddyHome.spec.ts b/cli/src/superTabs/buddyHome.spec.tsindex 788653bd3..8f98e7478 100644--- a/cli/src/superTabs/buddyHome.spec.ts+++ b/cli/src/superTabs/buddyHome.spec.ts@@ -1,13 +1,24 @@import { execFileSync } from 'node:child_process'-import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync } from 'node:fs'+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'-import { join } from 'node:path'+import { basename, join } from 'node:path'import { afterEach, describe, expect, it, vi } from 'vitest'// The login shell's environment is captured once and kept for minutes: each test here moves the engine homes in its own process.env.vi.mock('../engines/kit/launchExecutable.js', async (original) => ({ ...await original<object>(),launchEnvironment: async () => Object.fromEntries(['HOME', 'CLAUDE_CONFIG_DIR', 'CODEX_HOME'].filter(k => process.env[k] !== undefined).map(k => [k, process.env[k]])) }))import { BUDDY_COPIES_FILE, buddyProjectsOf, folderName, prepareBuddyHome, pruneBuddyHome, buddyHomeDue, refreshBuddyHome, removeBuddyHome, trustBuddyHome } from './buddyHome.js'+/** A link to a folder: a junction on Windows, which needs no Developer Mode or administrator (Window of Tim, #3815) and which+ * lstat reads as a link exactly as the Buddy folder's checks do; a symbolic link elsewhere. */+const linkFolder = (target: string, path: string) => symlinkSync(target, path, process.platform === 'win32' ? 'junction' : undefined)+/** Whether this machine lets this account make a link to a file, as git needs to check one out: Windows does only with+ * Developer Mode or as an administrator, and git there writes a committed link as a plain file otherwise. */+const canLinkFiles = (() => {+ const dir = mkdtempSync(join(tmpdir(), 'file-link-'))+ try { writeFileSync(join(dir, 'f'), ''); symlinkSync(join(dir, 'f'), join(dir, 'l'), 'file'); return true } catch { return false }+ finally { rmSync(dir, { recursive: true, force: true }) }+})()+// A person's one Buddy's folder (spec 2026-10-31-one-buddy-per-swarm, Folder): one worktree per project checkout on the// machine, each from its own checkout, and a lost project's out before the next turn. Real git, in a throwaway folder.const made: string[] = []@@ -15,10 +26,20 @@ afterEach(() => { for (const dir of made.splice(0)) rmSync(dir, { recursive: truconst git = (cwd: string, ...args: string[]) => execFileSync('git', args, { cwd, stdio: 'pipe', env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' } }).toString()/** A checkout with one committed file saying which project it is. */+/** The worktrees git lists for [repo], in the file system's own spelling: git prints a folder's long name with forward slashes,+ * and a temporary folder on Windows can hold a short one (C:\Users\HARNES~1, #3815). */+const worktreeList = (repo: string) => git(repo, 'worktree', 'list', '--porcelain').split('\n').filter(line => line.startsWith('worktree '))+ .map(line => { const path = line.slice('worktree '.length); try { return realpathSync.native(path) } catch { return path } }).join('\n')+/** Git on Windows is slower to start each command: a Buddy folder's tests there ran to 42 s on Window of Tim (#3815). */+const GIT_TIMEOUT = process.platform === 'win32' ? 120_000 : 30_000+function checkout(root: string, name: string): string {const dir = join(root, name)mkdirSync(dir, { recursive: true })git(dir, 'init', '-q', '-b', 'main')+ // Git for Windows' installer sets core.autocrlf in its system config, which the code's own git reads: the repository says+ // no, so a Buddy's worktree holds the bytes committed, as on every other machine (Window of Tim, #3815).+ git(dir, 'config', 'core.autocrlf', 'false')writeFileSync(join(dir, 'WHO'), `${name}\n`)git(dir, 'add', 'WHO')git(dir, '-c', '[email protected]', '-c', 'user.name=t', 'commit', '-q', '-m', 'first')@@ -30,7 +51,7 @@ function root(): string {return dir}-describe('a person\'s one Buddy\'s folder', () => {+describe('a person\'s one Buddy\'s folder', { timeout: GIT_TIMEOUT }, () => {// Task #2832: a Codex Buddy runs too, and would sit at Codex's own folder question in a terminal no Swarm view shows.it('answers Claude Code\'s and Codex\'s folder question for it, and leaves any other engine to ask', async () => {const claude = root(), codex = root(), home = join(root(), 'home'), config = join(claude, '.claude.json'), toml = join(codex, 'config.toml')@@ -48,7 +69,7 @@ describe('a person\'s one Buddy\'s folder', () => {expect(saved.map(p => p.hasTrustDialogAccepted)).toEqual([true])await trustBuddyHome(home, 'codex')expect(readFileSync(toml, 'utf8')).toMatch(/trust_level = "trusted"/)- expect(readFileSync(toml, 'utf8')).toContain(home.split('/').pop()!)+ expect(readFileSync(toml, 'utf8')).toContain(basename(home))} finally {if (moved.claude === undefined) delete process.env.CLAUDE_CONFIG_DIR; else process.env.CLAUDE_CONFIG_DIR = moved.claudeif (moved.codex === undefined) delete process.env.CODEX_HOME; else process.env.CODEX_HOME = moved.codex@@ -90,14 +111,15 @@ describe('a person\'s one Buddy\'s folder', () => {expect(existsSync(join(home, 'projects', 'Secret'))).toBe(false)expect(existsSync(join(home, 'projects', 'Web', 'WHO'))).toBe(true)// Its checkout no longer lists the worktree.- expect(git(secret, 'worktree', 'list')).not.toContain(join(home, 'projects', 'Secret'))+ expect(worktreeList(secret)).not.toContain('Secret')expect(await pruneBuddyHome(home, new Set(['web']))).toEqual([])})it('goes whole with its Buddy, worktrees included, read-only files too', async () => {const r = root(), web = checkout(r, 'web-src'), home = join(r, 'home')await prepareBuddyHome(home, [{ id: 'web', name: 'Web', cwd: web }])- execFileSync('chmod', ['-R', 'a-w', join(home, 'projects', 'Web', 'WHO')])+ // Read-only as the file system has it: Node sets the attribute on Windows, which has no chmod program (#3815).+ chmodSync(join(home, 'projects', 'Web', 'WHO'), 0o444)await removeBuddyHome(home)expect(existsSync(home)).toBe(false)expect(git(web, 'worktree', 'list').trim().split('\n')).toHaveLength(1)@@ -131,16 +153,16 @@ describe('a person\'s one Buddy\'s folder', () => {const theirs = join(r, 'their-worktree')git(other, 'worktree', 'add', '--detach', '--', theirs, 'HEAD')rmSync(join(home, 'projects', 'Web'), { recursive: true, force: true })- symlinkSync(theirs, join(home, 'projects', 'Web'))+ linkFolder(theirs, join(home, 'projects', 'Web'))await pruneBuddyHome(home, new Set())expect(readFileSync(join(theirs, 'WHO'), 'utf8')).toBe('other-src\n')- expect(git(other, 'worktree', 'list')).toContain(theirs)+ expect(worktreeList(other)).toContain(realpathSync.native(theirs))expect(existsSync(join(home, 'projects', 'Web'))).toBe(false)// Made again, a link in a project's place is replaced by its own worktree, never kept.const again = join(r, 'home2')await prepareBuddyHome(again, [{ id: 'web', name: 'Web', cwd: web }])rmSync(join(again, 'projects', 'Web'), { recursive: true, force: true })- symlinkSync(theirs, join(again, 'projects', 'Web'))+ linkFolder(theirs, join(again, 'projects', 'Web'))await prepareBuddyHome(again, [{ id: 'web', name: 'Web', cwd: web }])expect(readFileSync(join(again, 'projects', 'Web', 'WHO'), 'utf8')).toBe('web-src\n')expect(readFileSync(join(theirs, 'WHO'), 'utf8')).toBe('other-src\n')@@ -153,18 +175,18 @@ describe('a person\'s one Buddy\'s folder', () => {git(other, 'worktree', 'add', '--detach', '--', theirs, 'HEAD')const elsewhere = join(r, 'elsewhere')mkdirSync(join(elsewhere, 'Web'), { recursive: true })- symlinkSync(theirs, join(elsewhere, 'Web', 'x'))+ linkFolder(theirs, join(elsewhere, 'Web', 'x'))// projects/ is a link to a folder holding a "Web" folder; and a Buddy folder that is itself a link.const home = join(r, 'home')await prepareBuddyHome(home, [{ id: 'web', name: 'Web', cwd: web }])rmSync(join(home, 'projects'), { recursive: true, force: true })git(web, 'worktree', 'prune')- symlinkSync(elsewhere, join(home, 'projects'))+ linkFolder(elsewhere, join(home, 'projects'))await expect(pruneBuddyHome(home, new Set())).rejects.toThrow('BUDDY_FOLDER_NOT_OWN')await expect(prepareBuddyHome(home, [{ id: 'web', name: 'Web', cwd: web }])).rejects.toThrow('BUDDY_FOLDER_NOT_OWN')await removeBuddyHome(home)const linked = join(r, 'linked-home')- symlinkSync(elsewhere, linked)+ linkFolder(elsewhere, linked)await expect(prepareBuddyHome(linked, [{ id: 'web', name: 'Web', cwd: web }])).rejects.toThrow('BUDDY_FOLDER_NOT_OWN')await removeBuddyHome(linked)expect(existsSync(join(elsewhere, 'Web'))).toBe(true)@@ -181,13 +203,18 @@ describe('a person\'s one Buddy\'s folder', () => {expect(folderName('///', new Set())).toBe('project')expect(buddyProjectsOf({ buddyProjects: [{ id: 'a', name: 'A', cwd: '/x' }, { id: '../b', name: 'B', cwd: '/y' }, { id: 'c', name: 'C', cwd: 'relative' }] })).toEqual([{ id: 'a', name: 'A', cwd: '/x' }])+ // A folder is absolute by this machine's own rules (#3815): a drive or a share on Windows; on a Mac or Linux those are+ // relative names, resolved from the service's folder (Linuxtest2), so only a folder from / is kept there.+ expect(buddyProjectsOf({ buddyProjects: [{ id: 'w', name: 'W', cwd: 'C:\\Users\\me\\web' }, { id: 's', name: 'S', cwd: '\\\\server\\share\\web' },+ { id: 'd', name: 'D', cwd: 'C:web' }, { id: 'e', name: 'E', cwd: '\\evil' }] }).map(p => p.id))+ .toEqual(process.platform === 'win32' ? ['w', 's', 'e'] : [])})})// Scholes, 11-02: the Buddy kept saying a merged button was "not in my copy of the code yet". Real git: a bare origin, the// person's clone of it, and new commits pushed from another clone.// Each test here runs dozens of real git commands: a busy machine takes more than the default 5 s (seen with a hook added).-describe('a Buddy\'s copy of a project follows its default branch', { timeout: 30_000 }, () => {+describe('a Buddy\'s copy of a project follows its default branch', { timeout: GIT_TIMEOUT }, () => {const commit = (dir: string, file: string, text: string) => {writeFileSync(join(dir, file), text)git(dir, 'add', file)@@ -200,6 +227,7 @@ describe('a Buddy\'s copy of a project follows its default branch', { timeout: 3const clone = join(r, 'clone'), teammate = join(r, 'teammate')git(r, 'clone', '-q', origin, clone)git(r, 'clone', '-q', origin, teammate)+ for (const dir of [clone, teammate]) git(dir, 'config', 'core.autocrlf', 'false')return { origin, clone, teammate, home: join(r, 'home'), web: [{ id: 'web', name: 'Web', cwd: clone }] }}const advance = (teammate: string, file = 'NEW', text = 'new\n') => { commit(teammate, file, text); git(teammate, 'push', '-q', 'origin', 'main') }@@ -207,6 +235,19 @@ describe('a Buddy\'s copy of a project follows its default branch', { timeout: 3const copy = (home: string) => join(home, 'projects', 'Web')const copies = (home: string) => readFileSync(join(home, BUDDY_COPIES_FILE), 'utf8')+ // Window of Tim, #3815: git reports a folder's real, long name, and the temporary folder there is C:\Users\HARNES~1\…, so a+ // check that compared the two as written found every copy in another repository and moved none. A path in another letter+ // case is the same mismatch on a case-insensitive Mac.+ const caseInsensitive = (() => { const r = mkdtempSync(join(tmpdir(), 'case-')); try { return existsSync(r.toUpperCase()) } finally { rmSync(r, { recursive: true, force: true }) } })()+ it.runIf(caseInsensitive)('moves a copy whose Buddy home is named in another letter case, as Windows names one by its short name', async () => {+ const p = project(root())+ await prepareBuddyHome(p.home, p.web)+ advance(p.teammate)+ await refreshBuddyHome(p.home.toUpperCase())+ expect(head(copy(p.home))).toBe(head(p.teammate))+ expect(copies(p.home)).toContain('This is the latest default branch.')+ })+it('moves a Buddy home made at an old commit to the new origin head on the next prepare, and says where it is', async () => {const p = project(root())await prepareBuddyHome(p.home, p.web)@@ -240,7 +281,10 @@ describe('a Buddy\'s copy of a project follows its default branch', { timeout: 3const marker = join(p.clone, 'HOOK_RAN')writeFileSync(join(p.clone, '.git', 'hooks', 'post-checkout'), `#!/bin/sh\ntouch ${marker}\n`, { mode: 0o755 })await prepareBuddyHome(p.home, p.web)- rmSync(marker, { force: true })+ // Making the copy runs no hook of the person's either: on Windows the hook's shell ate the path's backslashes and left a+ // file in the copy, which then never moved (WinTest3348's diagnostic, #3815).+ expect(existsSync(marker)).toBe(false)+ expect(git(copy(p.home), 'status', '--porcelain')).toBe('')git(p.teammate, 'tag', 'v9')advance(p.teammate)git(p.teammate, 'push', '-q', 'origin', 'v9')@@ -322,7 +366,7 @@ describe('a Buddy\'s copy of a project follows its default branch', { timeout: 3})// Task #2832: a Buddy works in its copies as its owner would, so a move leaves the files it wrote as git writes them.- it('leaves the files a move wrote writable, as git writes them, and never touches a link\'s target', async () => {+ it.runIf(canLinkFiles)('leaves the files a move wrote writable, as git writes them, and never touches a link\'s target', async () => {const r = root(), p = project(r), target = join(r, 'outside')writeFileSync(target, 'x', { mode: 0o644 })await prepareBuddyHome(p.home, p.web)@@ -345,7 +389,7 @@ describe('a Buddy\'s copy of a project follows its default branch', { timeout: 3expect(head(copy(p.home))).toBe(head(p.teammate))})- it('never changes a file outside through a folder a commit turned into a link (review of #2524)', async () => {+ it.runIf(canLinkFiles)('never changes a file outside through a folder a commit turned into a link (review of #2524)', async () => {const r = root(), p = project(r), outside = join(r, 'outside')mkdirSync(outside)writeFileSync(join(outside, 'b.txt'), 'theirs', { mode: 0o644 })@@ -414,7 +458,7 @@ describe('a Buddy\'s copy of a project follows its default branch', { timeout: 3expect(refreshBuddyHome(p.home)).toBe(refreshBuddyHome(p.home))await refreshBuddyHome(p.home)const linked = join(r, 'linked')- symlinkSync(p.home, linked)+ linkFolder(p.home, linked)const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})await expect(refreshBuddyHome(linked)).resolves.toBeUndefined()expect(warn).toHaveBeenCalledTimes(1)diff --git a/cli/src/superTabs/buddyHome.ts b/cli/src/superTabs/buddyHome.tsindex 3aef886d3..188c67e00 100644--- a/cli/src/superTabs/buddyHome.ts+++ b/cli/src/superTabs/buddyHome.ts@@ -9,7 +9,7 @@*/import { execFile } from 'node:child_process'import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs'-import { join } from 'node:path'+import { isAbsolute, join } from 'node:path'import { promisify } from 'node:util'import { launchEnvironment } from '../engines/kit/launchExecutable.js'import { folderTrust } from '../engines/launchPrep.js'@@ -34,16 +34,24 @@ const ID = /^[A-Za-z0-9_-]{1,64}$/export const BUDDY_COPIES_FILE = 'project-copies.txt'const REFRESH_EVERY_MS = 60 * 60_000/** All of one pass's fetches share this: 50 projects offline must not hold a Buddy's start for 50 timeouts. */+/**+ * A hooks folder that holds none, for every git command on a Buddy's copy: the person's hooks are written for their own work.+ * `worktree add` ran their post-checkout in the copy (WinTest3348's diagnostic, #3815). On Windows `/dev/null` names C:\dev\null,+ * a folder any account may make, so there it is the NUL device, which can hold no hook.+ */+const NO_HOOKS = process.platform === 'win32' ? 'NUL' : '/dev/null'const FETCH_BUDGET_MS = 30_000const FETCH_TIMEOUT_MS = 20_000const FETCHES_AT_ONCE = 4-/** The projects a start lists, as far as they are well formed: an id, a name and an absolute folder. */+/** The projects a start lists, as far as they are well formed: an id, a name and a folder absolute by this machine's own rules.+ * A Windows checkout (C:\…, \\server\share\…) was dropped when this asked for a leading /, so a Buddy there had no copy of it+ * (#3815); on a Mac or Linux those names are relative, resolved from the service's folder (Linuxtest2), and stay dropped. */export function buddyProjectsOf(request: Record<string, unknown>): BuddyProject[] {const listed = Array.isArray(request.buddyProjects) ? request.buddyProjects : []return listed.flatMap(entry => {const p = entry as Record<string, unknown>- return typeof p?.id === 'string' && ID.test(p.id) && typeof p.name === 'string' && typeof p.cwd === 'string' && p.cwd.startsWith('/')+ return typeof p?.id === 'string' && ID.test(p.id) && typeof p.name === 'string' && typeof p.cwd === 'string' && isAbsolute(p.cwd)? [{ id: p.id, name: p.name, cwd: p.cwd }] : []}).slice(0, MAX_BUDDY_PROJECTS)}@@ -102,7 +110,7 @@ export async function prepareBuddyHome(home: string, projects: readonly BuddyProtry {// A folder of this name removed before (a link taken out, a folder deleted) may still be listed by its checkout.await run('git', ['-C', project.cwd, 'worktree', 'prune'], { timeout: 60_000 }).catch(() => undefined)- await run('git', ['-C', project.cwd, 'worktree', 'add', '--detach', '--', join(home, 'projects', dir), 'HEAD'], { timeout: 120_000 })+ await run('git', ['-c', `core.hooksPath=${NO_HOOKS}`, '-C', project.cwd, 'worktree', 'add', '--detach', '--', join(home, 'projects', dir), 'HEAD'], { timeout: 120_000 })if (!known) rows.push({ id: project.id, name: project.name, dir })ready.push(project.name)} catch { missing.push(project.name) }@@ -180,14 +188,16 @@ async function refreshCopy(path: string, name: string, deadline: number, signal:const state = (next: CopyState['state'], revision: string | null = null): CopyState => ({ name, revision, state: next })const entry = lstatSync(path, { throwIfNoEntry: false })if (!entry || !entry.isDirectory()) return state('failed')- const words = (args: string[]) => ['--no-optional-locks', '-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=/dev/null', '-C', path, ...args]+ const words = (args: string[]) => ['--no-optional-locks', '-c', 'core.fsmonitor=false', '-c', `core.hooksPath=${NO_HOOKS}`, '-C', path, ...args]const git = async (args: string[], options: { timeout?: number; signal?: AbortSignal } = {}) => (await run('git', words(args),{ timeout: options.timeout ?? 60_000, maxBuffer: 64 * 1024 * 1024, env: gitEnv(process.env), ...(options.signal ? { signal: options.signal } : {}) })).stdout.trim()let at: string | null = nullconst here = async () => await git(['log', '-1', '--no-show-signature', '--format=%h %cs']).catch(() => null)try {- // A folder that lost its .git would otherwise find whichever repository is above it, and move that one.- if (realpathSync(await git(['rev-parse', '--show-toplevel'])) !== realpathSync(path)) return state('failed')+ // A folder that lost its .git would otherwise find whichever repository is above it, and move that one. Compared as the+ // file system resolves them: git reports a folder's real, long name, and on Windows a path can hold a short one+ // (C:\Users\HARNES~1) or another letter case, which made every copy there "another repository" (#3815).+ if (realpathSync.native(await git(['rev-parse', '--show-toplevel'])) !== realpathSync.native(path)) return state('failed')at = await here()const detached = await git(['symbolic-ref', '--quiet', 'HEAD']).then(() => false, () => true)if (!detached || await git(['status', '--porcelain'])) return state('changed', at)diff --git a/cli/src/superTabs/start.spec.ts b/cli/src/superTabs/start.spec.tsindex 59041841d..cd36a3ba3 100644--- a/cli/src/superTabs/start.spec.ts+++ b/cli/src/superTabs/start.spec.ts@@ -1,7 +1,7 @@import { AGENT_FOLDER_MARK, agentFolderFor } from './agentFolder.js'import { projectsRoot } from '../lib/projectFolder.js'import { afterEach, describe, expect, it, vi } from 'vitest'-import { dirname, join } from 'node:path'+import { dirname, join, sep } from 'node:path'import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'import { buddyOwnerFile, buddyOwnerOf } from '../lib/buddyGuard.js'import { worktreeFolderName } from '../lib/agentNames.js'@@ -134,7 +134,10 @@ describe('Swarm permission mode', () => {expect(result).toMatchObject({ ok: true })const payload = f.request.mock.calls.find(c => c[0] === 'agent_create')![1]!expect(payload).toMatchObject({ permissionMode: 'full', bypassPermission: true, swarmRole: 'dev' })- const argv = buildEngineCommandArgv(engine, { permissionMode: String(payload.permissionMode) })+ // On Windows a launch first verifies the flags the engine's startup takes (lib/windows/engineStart.ts); given here as a+ // verified launch gives them, so this reads the permission flags alone (Window of Tim, #3815).+ const argv = buildEngineCommandArgv(engine, { permissionMode: String(payload.permissionMode),+ ...(process.platform === 'win32' ? { native: { startupArgs: [] } as never } : {}) })expect(argv).toContain(engine === 'claude' ? '--dangerously-skip-permissions' : '--dangerously-bypass-approvals-and-sandbox')}})@@ -162,7 +165,7 @@ describe('Swarm permission mode', () => {expect(await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)).toMatchObject({ ok: true })const payload = f.request.mock.calls.find(c => c[0] === 'agent_create')![1]!expect(payload).toMatchObject({ permissionMode: 'teamWritten', bypassPermission: true })- expect(String(payload.codexHome)).toContain(`/${PM_HOMES}/`)+ expect(String(payload.codexHome)).toContain(`${sep}${PM_HOMES}${sep}`)rmSync(dirname(String(payload.codexHome)), { recursive: true, force: true })} finally { teamDaemon.value = false }})@@ -838,7 +841,7 @@ describe('which branch a worktree starts from', () => {})// Scholes, 11-06 (#3713): computer's Dee started in a Claude scratchpad, asked "Do you trust this folder?" on every run.it('is a permanent folder Harness makes and marks when the folder named is a temporary one', async () => {- const [payload] = await created(request => { request.worktree = false; request.cwd = '/private/tmp/claude-501/-Users-mac/abc/scratchpad' })+ const [payload] = await created(request => { request.worktree = false; request.cwd = join(tmpdir(), 'claude-501', '-Users-mac', 'abc', 'scratchpad') })const folder = agentFolderFor(projectsRoot(), 'start')expect(payload).toMatchObject({ cwd: folder })expect(existsSync(join(folder, AGENT_FOLDER_MARK))).toBe(true)diff --git a/docs/plans/2026-11-06-windows-buddy-specs-plan.md b/docs/plans/2026-11-06-windows-buddy-specs-plan.mdnew file mode 100644index 000000000..22fbcf7b8--- /dev/null+++ b/docs/plans/2026-11-06-windows-buddy-specs-plan.md@@ -0,0 +1,73 @@+# Buddy and start specs pass on Windows: Implementation Plan++> Way of working: this project's Engineer role. Each plan task is test first (superpowers:test-driven-development): the+> failing test is committed and watched fail before its code. Steps use checkbox (`- [ ]`) syntax.++**Goal:** On Windows, `superTabs/buddyHome.spec.ts`, `superTabs/start.spec.ts` and `engines/kit/folderTrust.spec.ts` pass in+full. The Buddy folder works there as on a Mac. The three files run in the Windows CI job. Task #3815.++**Architecture:** WinTest3348 ran the three files at main 342edb2d7 on Window of Tim (Node 22.23.2, Git 2.55.0.windows.5,+Developer Mode off): 20 failures with one worker. Two are product bugs and the rest are specs that assume POSIX:+- **Product:** `refreshCopy` compares `git rev-parse --show-toplevel` with the copy's folder through `realpathSync`, which keeps+ a path's case and its 8.3 short names (`C:\Users\HARNES~1`) as written. Git reports the long, real name, so the two never+ match. Every copy is "left where they are", and seven move tests fail on that.+- **Product:** `buddyProjectsOf` keeps a project only when its folder starts with `/`, so a Windows checkout (`C:\…`) is+ dropped and its Buddy gets no copy.+- **Specs:** they make links with `symlinkSync`, which needs Developer Mode or an administrator on Windows (EPERM, seven+ tests); the Buddy-folder group keeps vitest's 5 s timeout, which Windows git outruns (six tests, and the EBUSY of their+ cleanup); and three assertions build or split a path with `/`.++**Tech Stack:** TypeScript, vitest, the GitHub Actions Windows workflow.++**Spec:** task #3815's brief.++## Global Constraints++- docs/windows-rules.md: no window flash; nothing here starts a new process kind.+- Never weaken the link and outside-folder safety checks (security review 1 of #2436). A folder link on Windows is a+ junction, which `lstat` reports as a link exactly as the checks read it. A test that needs a file link, or a link committed+ to git, runs only where the machine can make one, and is never loosened.+- The same files still pass on Mac and Linux.++## Review Focus++1. The toplevel check still refuses a folder that lost its `.git` and finds a repository above it ("moves nothing above a copy+ that lost its .git"): only the spelling of the same folder is made equal.+2. Case is ignored only on Windows and macOS (case-insensitive by default), through the file system's own canonical path.+3. A Windows project path must be absolute (drive or UNC); a relative one is still dropped.++---++### Task 1: The copy's repository check reads the folder the file system resolves++**Files:** `cli/src/superTabs/buddyHome.ts` (`refreshCopy`), `cli/src/superTabs/buddyHome.spec.ts`++- [ ] **Step 1: Write the failing test:** on a case-insensitive temporary folder, `refreshBuddyHome` given the Buddy home in+ another letter case moves the copy to the default branch. Skipped where the temporary folder is case-sensitive (Linux).+- [ ] **Step 2: Run** `npx vitest run src/superTabs/buddyHome.spec.ts -t "letter case"` and watch it fail on a Mac.+- [ ] **Step 3: Implement:** compare `realpathSync.native` of both paths.+- [ ] **Step 4: Run** the whole spec and see it pass. Commit the test first, then the code.++### Task 2: A Windows project folder is kept++**Files:** `cli/src/superTabs/buddyHome.ts` (`buddyProjectsOf`), `cli/src/superTabs/buddyHome.spec.ts`++- [ ] **Step 1: Write the failing test:** `C:\Users\me\web` and `\\server\share\web` are kept; `relative` and `C:web` are+ dropped.+- [ ] **Step 2: Run it and watch it fail.**+- [ ] **Step 3: Implement** with `posix.isAbsolute || win32.isAbsolute` (a drive-relative `C:web` is not absolute).+- [ ] **Step 4: Run and see it pass.** Commit the test first, then the code.++### Task 3: The specs run on Windows as they read++**Files:** `cli/src/superTabs/buddyHome.spec.ts`, `cli/src/superTabs/start.spec.ts`, `cli/src/engines/kit/folderTrust.spec.ts`,+`.github/workflows/windows.yml`++- [ ] **Folder links:** made with a `linkFolder(target, path)` helper, a junction on Windows and a symlink elsewhere.+- [ ] **File links:** `it.runIf(canLinkFiles())` for tests that need a file link or a committed link.+- [ ] **Timeout:** the Buddy-folder group gets `{ timeout: 30_000 }`.+- [ ] **Paths:** built with `sep` and `basename`.+- [ ] **Codex launch test:** on Windows it passes the startup arguments a Windows launch has verified.+- [ ] **Windows CI:** the three files are added to the Windows workflow's CLI spec list.+- [ ] **Evidence:** the three files pass on Mac locally and on Linux in PR CI, and WinTest3348 runs them on Window of Tim at+ the PR head.