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
dsh/materialize: a harness with no workspace.marker gets its template
dee879b187b4db7
diff --git a/cli/src/dsh/materialize.spec.ts b/cli/src/dsh/materialize.spec.tsindex 2f70d12b4..f204316c8 100644--- a/cli/src/dsh/materialize.spec.ts+++ b/cli/src/dsh/materialize.spec.ts@@ -1,10 +1,10 @@-import { afterEach, beforeEach, describe, expect, it } from 'vitest'-import { existsSync, lstatSync, mkdtempSync, readFileSync, readlinkSync, realpathSync, rmSync, writeFileSync } from 'node:fs'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'import { join } from 'node:path'import { fileURLToPath } from 'node:url'import type { InstalledDsh } from './installed.js'-import { readDshManifest } from './manifest.js'+import { parseDshManifest, readDshManifest } from './manifest.js'import { dshMarkerLine, materializeWorkspace, resolveDshCommand, skillDirsIn } from './materialize.js'const STARTER = realpathSync(fileURLToPath(new URL('../../../store/starter', import.meta.url)))@@ -111,4 +111,120 @@ describe('resolveDshCommand', () => {expect(resolveDshCommand({ realDir: STARTER }, 'toolchain/missing.sh')).toBe('toolchain/missing.sh')expect(resolveDshCommand({ realDir: STARTER }, 'npm run viewer -- --port $HARNESS_VIEWER_PORT')).toBe('npm run viewer -- --port $HARNESS_VIEWER_PORT')})++ it('quotes an install path with a quote in it so the shell runs the script it names', async () => {+ const dir = realpathSync(mkdtempSync(join(tmpdir(), "dsh-it's-")))+ try {+ writeFileSync(join(dir, 'run.sh'), '#!/bin/sh\necho "ran $1"\n', { mode: 0o755 })+ const command = resolveDshCommand({ realDir: dir }, 'run.sh')+ expect(command).toBe(`'${join(dir, 'run.sh').replace(/'/g, `'\\''`)}'`)+ const { execFileSync } = await import('node:child_process')+ expect(execFileSync('/bin/sh', ['-c', `${command} ok`], { encoding: 'utf8' })).toBe('ran ok\n')+ } finally {+ rmSync(dir, { recursive: true, force: true })+ }+ })+})++describe('materializeWorkspace, on harnesses other than the starter', () => {+ let root: string+ let harness: string+ let workspace: string+ beforeEach(() => {+ root = realpathSync(mkdtempSync(join(tmpdir(), 'dsh-mat-')))+ harness = join(root, 'harness')+ workspace = join(root, 'workspace')+ mkdirSync(harness)+ mkdirSync(workspace)+ })+ afterEach(() => {+ vi.useRealTimers()+ rmSync(root, { recursive: true, force: true })+ })++ const install = (manifest: Record<string, unknown>, files: Record<string, string> = {}): InstalledDsh => {+ for (const [name, body] of Object.entries(files)) {+ mkdirSync(join(harness, name, '..'), { recursive: true })+ writeFileSync(join(harness, name), body, { mode: name.endsWith('.sh') ? 0o755 : 0o644 })+ }+ const read = parseDshManifest(JSON.stringify({ spec: 1, id: 'acme/thing', name: 'Thing', ...manifest }))+ if (!read.ok) throw new Error(read.error)+ return { id: 'acme/thing', dir: harness, realDir: harness, source: harness, ref: null, commit: null, linked: true, installedAt: 0, manifest: read.manifest }+ }++ it('lays nothing out for a viewer package', async () => {+ const dsh = install({ kind: 'viewer', viewer: { command: 'v.sh', url: 'http://127.0.0.1:${port}/' } })+ const result = await materializeWorkspace(dsh, workspace)+ expect(result).toEqual({ created: [], kept: [], warnings: ['acme/thing is a viewer package; it has no workspace to lay out'], initLines: [] })+ expect(readdirSync(workspace)).toEqual([])+ })++ it('a harness with no workspace, instructions or skills gets only .harness/', async () => {+ const result = await materializeWorkspace(install({ engine: 'codex' }), workspace)+ expect(result).toEqual({ created: [], kept: [], warnings: [], initLines: [] })+ expect(readdirSync(workspace)).toEqual(['.harness'])+ })++ it('with no marker declared, copies the template (never over a file) and runs the init at every create', async () => {+ const dsh = install({ engine: 'codex', workspace: { template: 'template', init: 'init.sh' } }, {+ 'template/deck.md': '# from the template\n',+ 'init.sh': '#!/bin/sh\necho "init in $(basename "$PWD") for $HARNESS_DSH" >> init.log\necho ran\n',+ })+ writeFileSync(join(workspace, 'deck.md'), '# mine\n')+ const first = await materializeWorkspace(dsh, workspace)+ expect(first.created).toContain(`template → ${workspace}`)+ expect(first.initLines).toEqual(['ran'])+ expect(readFileSync(join(workspace, 'deck.md'), 'utf8')).toBe('# mine\n')+ await materializeWorkspace(dsh, workspace)+ expect(readFileSync(join(workspace, 'init.log'), 'utf8')).toBe('init in workspace for acme/thing\ninit in workspace for acme/thing\n')+ })++ it('says what it could not do: a missing template, unreadable instructions, a skills root with no skills', async () => {+ const dsh = install({ engine: 'claude', workspace: { template: 'gone', marker: 'deck.md' }, agent: { instructions: 'MISSING.md', skills: ['empty'] } }, { 'empty/README.md': '' })+ const result = await materializeWorkspace(dsh, workspace)+ expect(result.warnings).toEqual([+ `template ${join(harness, 'gone')} is missing`,+ `instructions ${join(harness, 'MISSING.md')} could not be read`,+ 'no SKILL.md under empty',+ ])+ expect(existsSync(join(workspace, 'AGENTS.md'))).toBe(false)+ expect(existsSync(join(workspace, 'CLAUDE.md'))).toBe(false)+ })++ it('an init that fails, or is killed, is a warning with how it ended, never a thrown error', async () => {+ const failing = install({ engine: 'codex', workspace: { marker: 'done', init: 'echo half-way; exit 3' } })+ const failed = await materializeWorkspace(failing, workspace)+ expect(failed.initLines).toEqual(['half-way'])+ expect(failed.warnings).toEqual(['init exited 3'])+ const killed = install({ engine: 'codex', workspace: { marker: 'done', init: 'kill -KILL $$' } })+ expect((await materializeWorkspace(killed, workspace)).warnings).toEqual(['init exited SIGKILL'])+ })++ it('an init that is still running after five minutes is stopped and said to have timed out', async () => {+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] })+ const slow = install({ engine: 'codex', workspace: { marker: 'done', init: 'sleep 30' } })+ const pending = materializeWorkspace(slow, workspace)+ vi.advanceTimersByTime(5 * 60_000)+ const result = await pending+ expect(result.warnings).toEqual(['init exited by timeout'])+ })++ it('repoints a skill link an earlier install path left, and skips a skill entry it cannot stat', async () => {+ const dsh = install({ engine: 'codex', agent: { skills: ['skills'] } }, { 'skills/draw/SKILL.md': '---\nname: draw\n---\n' })+ symlinkSync(join(root, 'nowhere'), join(harness, 'skills', 'dangling'))+ mkdirSync(join(workspace, '.agents', 'skills'), { recursive: true })+ symlinkSync(join(root, 'old-install', 'draw'), join(workspace, '.agents', 'skills', 'draw'))+ const result = await materializeWorkspace(dsh, workspace)+ expect(result.created).toEqual(['.agents/skills/draw'])+ expect(readlinkSync(join(workspace, '.agents', 'skills', 'draw'))).toBe(join(harness, 'skills', 'draw'))+ expect(existsSync(join(workspace, '.agents', 'skills', 'dangling'))).toBe(false)+ })++ it('an agent manifest with no engine (the type allows it) is laid out for Claude Code', async () => {+ const dsh = install({ engine: 'claude', agent: { instructions: 'AGENTS.md', skills: ['skills'] } }, { 'AGENTS.md': '# Thing\n', 'skills/draw/SKILL.md': '' })+ const { engine: _engine, ...manifest } = dsh.manifest+ await materializeWorkspace({ ...dsh, manifest }, workspace)+ expect(readFileSync(join(workspace, 'CLAUDE.md'), 'utf8')).toBe('@AGENTS.md\n')+ expect(lstatSync(join(workspace, '.claude', 'skills', 'draw')).isSymbolicLink()).toBe(true)+ })})diff --git a/cli/src/dsh/materialize.ts b/cli/src/dsh/materialize.tsindex 6a68893a7..c5baef5b9 100644--- a/cli/src/dsh/materialize.ts+++ b/cli/src/dsh/materialize.ts@@ -158,7 +158,9 @@ export async function materializeWorkspace(dsh: InstalledDsh, workspace: string)}const ws = dsh.manifest.workspaceconst marker = ws?.marker ? join(workspace, ws.marker) : null- const fresh = marker ? !existsSync(marker) : false+ // No marker declared means nothing can say the workspace is laid out: the template is copied (never+ // over a file) and the init runs at every create — what the spec says, and what `dsh check` warns of.+ const fresh = marker ? !existsSync(marker) : trueif (fresh && ws?.template) copyTemplate(join(dsh.realDir, ws.template), workspace, result)if (fresh && ws?.init) {// The init runs IN the workspace, so a command that names a script by its path inside the