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
Describe, rename and sweep through the SCM seam; the frame's project gains kind
Adam Hafezac676cc03d70
diff --git a/cli/src/lib/agentFrame.spec.ts b/cli/src/lib/agentFrame.spec.tsindex 4137a3083..34b454009 100644--- a/cli/src/lib/agentFrame.spec.ts+++ b/cli/src/lib/agentFrame.spec.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os'import { join } from 'node:path'import { describe, expect, it } from 'vitest'import { agentFrame } from './agentFrame.js'+import { agentProject } from './agentProject.js'import type { RegisteredSession } from './registry.js'function session(grid: RegisteredSession['grid'], codexHome: RegisteredSession['codexHome'] = null): RegisteredSession {@@ -52,6 +53,21 @@ describe('agentFrame', () => {expect(JSON.stringify(frame)).not.toContain('p-sess')})+ // The SCM seam (scm/scmProjects.ts) names the project's SCM and changes nothing else on it: every+ // field a client reads is exactly what agentProject reports. A folder no SCM claims is `none`.+ it('names the project\'s SCM beside exactly what agentProject reports, and none outside any repository', async () => {+ const dir = await mkdtemp(join(tmpdir(), 'agent-frame-scm-'))+ try {+ const row = { ...session(null), cwd: dir }+ const frame = await agentFrame(row, { selectedModel: null, terminalAvailable: true })+ expect(frame.project).toEqual({ kind: 'none', ...await agentProject(dir) })+ expect(frame.project).toMatchObject({ kind: 'none', cwd: dir, root: null, remote: null, branch: null })+ expect((await agentFrame({ ...row, cwd: null }, { selectedModel: null, terminalAvailable: true })).project).toBeNull()+ } finally {+ await rm(dir, { recursive: true, force: true })+ }+ })+it('reports no assignment as null rather than omitting the field', async () => {const frame = await agentFrame(session(null), { selectedModel: null, terminalAvailable: true })expect(frame).toHaveProperty('grid', null)diff --git a/cli/src/lib/agentFrame.ts b/cli/src/lib/agentFrame.tsindex 9e891fb7f..efd9d3ef0 100644--- a/cli/src/lib/agentFrame.ts+++ b/cli/src/lib/agentFrame.ts@@ -19,7 +19,9 @@ import type { ActivityFrame } from './turnActivity.js'* makes the shape testable without a registry, which is the whole reason the drift went unnoticed.*/-import { agentProject, type AgentProject } from './agentProject.js'+import { agentProject } from './agentProject.js'+import { describeScmProject } from '../scm/scmProjects.js'+import type { ScmDescription } from '../scm/types.js'import { sessionGitContext, SessionGitContextReader, type SessionGitContext } from './sessionGitContext.js'import { sessionGitHistory } from './sessionGitHistory.js'import { transcriptActivityAt } from './transcriptActivity.js'@@ -83,7 +85,9 @@ export type AgentFrame = {selectedModel: string | nullgrid: GridFrameBlock | nullcodexHome: string | null- project: AgentProject | null+ /** The workspace as its SCM describes it, with `kind` (`git`, or `none` for a folder no SCM claims);+ * every other field is exactly what `agentProject` reports (scm/types.ts). */+ project: ScmDescription | null/** Additive display context; project/cwd remain the registered launch workspace. */gitContext: SessionGitContext/** The domain-specific harness this agent was created as, or null for a plain engine. */@@ -187,6 +191,9 @@ export async function agentFrame(s: RegisteredSession,{ selectedModel, terminalAvailable, dsh, tokenUsage, activity: contextActivity }: AgentFrameContext,): Promise<AgentFrame> {+ // The git context is git's own display projection and keeps reading git directly; the frame's+ // `project` goes through the SCM seam. Both resolve through agentProject's shared reader, so the+ // seam adds no Git process.const home = agentProject(s.cwd)const context = gitContexts.read(JSON.stringify([s.agentId, s.sessionId, s.engine, s.codexHome, s.registeredAt]), async () => {const saved = await sessionGitHistory.get(s)@@ -194,7 +201,7 @@ export async function agentFrame(value.history = await sessionGitHistory.observe(s, value)return value})- const [project, updatedAt, gitContext] = await Promise.all([home, lastActivityAt(s), context])+ const [project, updatedAt, gitContext] = await Promise.all([describeScmProject(s.cwd), lastActivityAt(s), context])return {id: s.agentId,sessionId: s.sessionId,diff --git a/cli/src/services/workspaces.ts b/cli/src/services/workspaces.tsindex 6abeb6037..807a717d5 100644--- a/cli/src/services/workspaces.ts+++ b/cli/src/services/workspaces.ts@@ -9,11 +9,9 @@import { homedir } from 'node:os'import { join } from 'node:path'import type { CoreApi, CorePorts } from '../core/api.js'-import { forgetAgentProject } from '../lib/agentProject.js'-import { nameBranchAfterSession } from '../lib/branchNaming.js'import { sid } from '../lib/log.js'import { sessionDisplayTitle } from '../lib/registry.js'-import { sweepWorktrees } from '../lib/worktreeSweep.js'+import { forgetScmProject, renameScmProject, sweepScmProjects } from '../scm/scmProjects.js'export function startWorkspaces(core: CoreApi, ports: CorePorts): void {// A worktree branch Harness made up at Start takes its session's name once it has one@@ -25,10 +23,10 @@ export function startWorkspaces(core: CoreApi, ports: CorePorts): void {if (!title || !session.cwd || branchNamed.has(session.agentId)) continuebranchNamed.add(session.agentId)const cwd = session.cwd- void nameBranchAfterSession(cwd, title).then((renamed) => {+ void renameScmProject(cwd, title).then((renamed) => {if (!renamed) returnconsole.log(`[worktrees] agent ${sid(session.agentId)} branch named ${renamed}`)- forgetAgentProject(cwd)+ forgetScmProject(cwd)const current = core.agents.byAgent(session.agentId)if (current) core.agents.sync(current)}).catch(() => {})@@ -40,7 +38,7 @@ export function startWorkspaces(core: CoreApi, ports: CorePorts): void {const sweepUnusedWorktrees = () => {let inUse: Array<string | null>try { inUse = core.agents.all().map(s => s.cwd) } catch { return }- void sweepWorktrees({ root: join(homedir(), 'harnesses'), inUse })+ void sweepScmProjects({ root: join(homedir(), 'harnesses'), inUse }).then(removed => { if (removed.length) console.log(`[worktrees] removed ${removed.length} unused worktree(s)`) }).catch(() => {})}