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
Fix Score first-run installation by managing LilyPond automatically (#145)
Deeb74d3f2b253d
diff --git a/.github/workflows/experience-checks.yml b/.github/workflows/experience-checks.ymlindex acca0a95a..de80ca03c 100644--- a/.github/workflows/experience-checks.yml+++ b/.github/workflows/experience-checks.yml@@ -35,6 +35,15 @@ jobs:run: node --test store/agents/freecad/test/*.test.mjs- name: Check Score contracts, MIDI and delivery (native suite is opt-in)run: node --test store/agents/score/test/*.test.mjs+ - name: Install Score from scratch and engrave with its managed runtime+ env:+ SCORE_RUNTIME_DIR: ${{ runner.temp }}/score-runtime+ run: |+ sh store/agents/score/toolchain/setup.sh+ sh store/agents/score/toolchain/doctor.sh+ score_workspace="$(mktemp -d "$RUNNER_TEMP/score-project.XXXXXX")"+ cp -R store/agents/score/template/. "$score_workspace/"+ HARNESS_WORKSPACE="$score_workspace" sh store/agents/score/skills/score/scripts/render-score.sh- name: Check OpenSCAD contracts and delivery (native suite is opt-in)run: node --test store/agents/openscad/test/*.test.mjs- name: Check OrcaSlicer briefs, G-code and delivery (native suite is opt-in)diff --git a/store/agents/score/PROVENANCE.md b/store/agents/score/PROVENANCE.mdindex e937651be..b3dd0e552 100644--- a/store/agents/score/PROVENANCE.md+++ b/store/agents/score/PROVENANCE.md@@ -5,9 +5,14 @@ instructions and original compositions “After the Rain” and “A Small Beginare OpenHarness work under the included MIT license. The earlier “Lighthouseat Dusk” starter was also original OpenHarness work.-[LilyPond](https://lilypond.org) is the separately installed notation engine,-licensed GPL-3.0-or-later. Tested with the official 2.26.0 macOS Intel distribution.-No LilyPond code, binary, font or sample library is redistributed in this package.+[LilyPond](https://lilypond.org) is the notation engine, licensed GPL-3.0-or-later.+Setup downloads its unmodified official 2.26.0 distribution when a suitable installation+is absent. The [official downloads](https://lilypond.org/download.html) link to the+[release](https://gitlab.com/lilypond/lilypond/-/releases/v2.26.0). Archive SHA-256 values+are pinned in `skills/score/scripts/lilypond.mjs` from the official GitLab package+58476196 `package_files` metadata. Intel macOS installation and native engraving are+tested locally; the download also supports Apple Silicon macOS and x86-64 Linux.+No LilyPond code, binary, font or sample library is bundled in this package.The viewer displays user-generated engraving as images and uses native Web Audiooscillators; no external music, soundfont or audio service is used.diff --git a/store/agents/score/README.md b/store/agents/score/README.mdindex 97501b90c..46879fc16 100644--- a/store/agents/score/README.md+++ b/store/agents/score/README.md@@ -23,10 +23,12 @@ flute revision that leaves the piano MIDI unchanged.## First run-Install `autonomous/score` from the Harness Store and install-[LilyPond](https://lilypond.org/download.html) separately (tested 2.26.0).-Set `LILYPOND_BIN` if it is not on PATH. The managed helper finds Node 20+;-no global npm packages or audio service are needed.+Install `autonomous/score` from the Harness Store. Setup finds an existing LilyPond 2.24.3++or downloads the official, checksummed 2.26.0 release on Intel/Apple Silicon macOS and+x86-64 Linux. The managed copy stays under `~/.harness/runtime/score/`; no Homebrew,+administrator password or shell configuration is needed. Builds find it automatically.+`LILYPOND_BIN` remains available for a custom installation. Node 20+ is supplied by+Harness's runtime helper; no global npm packages or audio service are needed.Describe the music you want. The agent edits `ensemble.json` (brief and limits)and `score.ly` (concert-pitch music), then runs:diff --git a/store/agents/score/skills/score/SKILL.md b/store/agents/score/skills/score/SKILL.mdindex 61a07b1d8..7f0dfb157 100644--- a/store/agents/score/skills/score/SKILL.md+++ b/store/agents/score/skills/score/SKILL.md@@ -60,8 +60,9 @@ Offer concrete revisions in the user's language (“make the ending warmer,”## Boundaries-Requires LilyPond (tested 2.26.0) and Node 20+. `LILYPOND_BIN` overrides the-binary. Only compile trusted input: LilyPond can execute Scheme and read local+Setup installs LilyPond 2.26.0 when needed on supported Macs/Linux x86-64; the builder+finds that managed runtime automatically. Node 20+ comes from the runtime helper.+`LILYPOND_BIN` overrides the binary. Only compile trusted input: LilyPond can execute Scheme and read localfiles. The source allowlist makes delivery explicit; it is not a Scheme sandbox.Do not add unrelated files, credentials or recordings to the portable project.diff --git a/store/agents/score/skills/score/scripts/build.mjs b/store/agents/score/skills/score/scripts/build.mjsindex 0baa1ba01..9e3024faa 100644--- a/store/agents/score/skills/score/scripts/build.mjs+++ b/store/agents/score/skills/score/scripts/build.mjs@@ -6,6 +6,7 @@ import {createHash} from 'node:crypto';import {parseMidi,writePracticeMidi} from './midi.mjs';import {validateEnsemble,validateMusicSources,makeWrapper,checkEnsemble,sameNotes} from './ensemble.mjs';import {zip} from './archive.mjs';+import {resolveLilypond} from './lilypond.mjs';const sha=bytes=>createHash('sha256').update(bytes).digest('hex');const json=value=>JSON.stringify(value,null,2)+'\n';@@ -56,7 +57,7 @@ async function publish(workspace,state,stage,names) {throw error;}}-export async function build(workspace,{bin=process.env.LILYPOND_BIN||'lilypond'}={}) {+export async function build(workspace,{bin}={}) {workspace=resolve(workspace);const meta=join(workspace,'.harness');if (await exists(meta) && (await lstat(meta)).isSymbolicLink()) throw new Error('.harness must not be a symlink.');@@ -72,6 +73,7 @@ export async function build(workspace,{bin=process.env.LILYPOND_BIN||'lilypond'}try {await writeFile(join(lock,'owner.json'),json({pid:process.pid,startedAt:new Date().toISOString()}));await verdict(false,'Engraving fresh music, checking the player brief and preparing practice files');+ bin??=await resolveLilypond();const contract=await exists(join(workspace,'ensemble.json')) ? await regularSource(workspace,'ensemble.json') : null;const spec=contract?validateEnsemble(JSON.parse(contract)):null;const files=await snapshotSources(workspace,spec||{sourceFiles:['score.ly']});@@ -169,8 +171,8 @@ export async function build(workspace,{bin=process.env.LILYPOND_BIN||'lilypond'}const outputs=['score.pdf','score.midi','score.html','score-assets'];if (spec) {const bundle=[...files];- for (const name of ['build.mjs','ensemble.mjs','archive.mjs','midi.mjs','preview.html','preview.js','LICENSE']) bundle.push({name:'rebuild/'+name,bytes:await readFile(new URL(name,import.meta.url))});- bundle.push({name:'REBUILD.md',bytes:Buffer.from('# '+spec.title+'\n\nInstall Node 20+ and LilyPond (tested '+version+'). From this extracted folder run:\n\n node rebuild/build.mjs .\n\nSet LILYPOND_BIN if LilyPond is not on PATH. No Harness account or npm packages required.\nEdit ensemble.json for the saved brief, players and checks; edit score.ly for concert-pitch music variables. Only compile trusted LilyPond: it can execute Scheme.\n\nOpen score.html in a browser. The PDF, MIDI, player parts and practice files work outside Harness. Checks and source hashes are in score-assets/checks.json. A checked export is not a real-player endorsement.\n\nPractice exports use '+spec.practice.speed+'x tempo and '+spec.practice.countInBars+' count-in bar(s). These are note-only synthetic sketches, not recordings. Files in rebuild/ are MIT-licensed tools; see rebuild/LICENSE. Composition credit: '+spec.composer+'. Source permissions remain the creator’s responsibility.\n')});+ for (const name of ['build.mjs','lilypond.mjs','ensemble.mjs','archive.mjs','midi.mjs','preview.html','preview.js','LICENSE']) bundle.push({name:'rebuild/'+name,bytes:await readFile(new URL(name,import.meta.url))});+ bundle.push({name:'REBUILD.md',bytes:Buffer.from('# '+spec.title+'\n\nInstall Node 20+. On supported macOS/Linux x86-64, download the managed LilyPond runtime with `node rebuild/lilypond.mjs --install`, or use your own LilyPond (tested '+version+'). From this extracted folder run:\n\n node rebuild/build.mjs .\n\nSet LILYPOND_BIN if LilyPond is not on PATH. No Harness account or npm packages required.\nEdit ensemble.json for the saved brief, players and checks; edit score.ly for concert-pitch music variables. Only compile trusted LilyPond: it can execute Scheme.\n\nOpen score.html in a browser. The PDF, MIDI, player parts and practice files work outside Harness. Checks and source hashes are in score-assets/checks.json. A checked export is not a real-player endorsement.\n\nPractice exports use '+spec.practice.speed+'x tempo and '+spec.practice.countInBars+' count-in bar(s). These are note-only synthetic sketches, not recordings. Files in rebuild/ are MIT-licensed tools; see rebuild/LICENSE. Composition credit: '+spec.composer+'. Source permissions remain the creator’s responsibility.\n')});for (const name of outputs.filter(name=>name!=='score-assets')) bundle.push({name,bytes:await readFile(join(stage,name))});for (const name of await readdir(assets)) bundle.push({name:'score-assets/'+name,bytes:await readFile(join(assets,name))});await writeFile(join(stage,'score-project.zip'),zip(bundle)); outputs.push('score-project.zip');diff --git a/store/agents/score/skills/score/scripts/lilypond.mjs b/store/agents/score/skills/score/scripts/lilypond.mjsnew file mode 100644index 000000000..e1daa3845--- /dev/null+++ b/store/agents/score/skills/score/scripts/lilypond.mjs@@ -0,0 +1,79 @@+// Official LilyPond binaries, managed beside Harness runtimes. No global package manager.+import { access,mkdir,mkdtemp,readFile,rename,rm } from 'node:fs/promises';+import { spawnSync } from 'node:child_process';+import { createHash,randomUUID } from 'node:crypto';+import { homedir } from 'node:os';+import { join,resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++export const VERSION='2.26.0';+// GitLab's official release package 58476196, package_files API, checked 2026-09-20.+const releases={+ 'darwin-x64':{asset:'darwin-x86_64',sha256:'6dcbca34b13ad6d4ba3606a0b48edd02688284fcd52e9c00141242df1996a148'},+ 'darwin-arm64':{asset:'darwin-arm64',sha256:'18ffc454fef3753c26a015d95a3c232f89b22f052b897c046e0198740a1221be'},+ 'linux-x64':{asset:'linux-x86_64',sha256:'cd8a097a9f52cb2b9f4e7914774786f203f4fc61fcd299afcbb63c23fa5c6b24'},+};+export function releaseFor(platform=process.platform,arch=process.arch){+ const release=releases[platform+'-'+arch];+ if(!release)throw new Error(`Score has no managed LilyPond download for ${platform}/${arch}. A working LilyPond 2.24.3+ on PATH or LILYPOND_BIN can still be used.`);+ const name=`lilypond-${VERSION}-${release.asset}`;+ return {...release,name,url:`https://gitlab.com/api/v4/projects/lilypond%2Flilypond/packages/generic/lilypond/${VERSION}/${name}.tar.gz`};+}+export function runtimeRoot(env=process.env){return env.SCORE_RUNTIME_DIR||join(env.ADAPTER_RUNTIME_DIR||join(homedir(),'.harness','runtime'),'score');}+export function probeLilypond(bin,env=process.env){+ const result=spawnSync(bin,['--version'],{env,encoding:'utf8',timeout:10000,maxBuffer:256*1024});+ const line=(result.stdout||'').split('\n')[0],match=line.match(/^GNU LilyPond (\d+)\.(\d+)\.(\d+)/);+ if(result.error||result.status!==0||!match||Number(match[1])<2||(Number(match[1])===2&&(Number(match[2])<24||(Number(match[2])===24&&Number(match[3])<3))))return null;+ return {bin,version:match.slice(1,4).join('.'),line};+}+export async function findLilypond({env=process.env,platform=process.platform,arch=process.arch,probe=probeLilypond}={}){+ if(env.LILYPOND_BIN){const found=probe(env.LILYPOND_BIN,env);if(!found)throw new Error('The configured LILYPOND_BIN cannot run LilyPond 2.24.3+: '+env.LILYPOND_BIN);return found;}+ let release;try{release=releaseFor(platform,arch);}catch{}+ const candidates=[release&&join(runtimeRoot(env),release.name,'bin/lilypond'),'lilypond'];+ if(platform==='darwin')candidates.push('/opt/homebrew/bin/lilypond','/usr/local/bin/lilypond','/Applications/LilyPond.app/Contents/Resources/bin/lilypond');+ for(const bin of candidates.filter(Boolean)){const found=probe(bin,env);if(found)return found;}+ return null;+}+function command(name,args){+ const run=spawnSync(name,args,{encoding:'utf8',timeout:600000,maxBuffer:16*1024*1024});+ if(run.error||run.status!==0)throw new Error(`${name} failed: ${run.error?.message||(run.stderr||'').trim().slice(-1600)||'exit '+run.status}`);+ return run.stdout;+}+export async function downloadArchive(url,path){command('curl',['-fsSL','--retry','2','--connect-timeout','20','--max-time','540','--output',path,url]);}+export async function unpackArchive(archive,directory){+ const names=command('tar',['-tzf',archive]).split('\n').filter(Boolean);+ if(!names.length||names.some(name=>!name.startsWith('lilypond-'+VERSION+'/')||name.split('/').includes('..')))throw new Error('Unexpected LilyPond archive layout; nothing installed.');+ command('tar',['-xzf',archive,'--strip-components=1','-C',directory]);+}+export async function ensureLilypond({env=process.env,platform=process.platform,arch=process.arch,probe=probeLilypond,download=downloadArchive,unpack=unpackArchive,getRelease=releaseFor,log=console.log}={}){+ const existing=await findLilypond({env,platform,arch,probe});if(existing)return existing;+ const release=getRelease(platform,arch),root=runtimeRoot(env),target=join(root,release.name);+ await mkdir(root,{recursive:true});const scratch=await mkdtemp(join(root,'.lilypond-install-'));+ const archive=join(scratch,'release.tar.gz'),stage=join(scratch,'runtime');let previous;+ try{+ log(`Downloading LilyPond ${VERSION} for Score…`);await download(release.url,archive);+ const digest=createHash('sha256').update(await readFile(archive)).digest('hex');+ if(digest!==release.sha256)throw new Error('LilyPond download did not match its pinned checksum. Nothing was installed; retry the download.');+ log('Verifying and preparing the music engraver…');await mkdir(stage);await unpack(archive,stage);+ if(probe(join(stage,'bin/lilypond'),env)?.version!==VERSION)throw new Error('The downloaded LilyPond could not run on this machine.');+ const bin=join(target,'bin/lilypond');if(probe(bin,env))return probe(bin,env);+ try{await access(target);previous=target+'.previous-'+randomUUID();await rename(target,previous);}catch(error){if(error.code!=='ENOENT')throw error;}+ try{await rename(stage,target);}catch(error){if(!['EEXIST','ENOTEMPTY'].includes(error.code)||!probe(bin,env))throw error;}+ const installed=probe(bin,env);if(!installed)throw new Error('LilyPond could not run from its installed location.');+ return installed;+ }catch(error){+ if(previous){await rm(target,{recursive:true,force:true});await rename(previous,target);}+ throw error;+ }finally{await rm(scratch,{recursive:true,force:true});}+}+export async function resolveLilypond(options){+ const found=await findLilypond(options);if(found)return found.bin;+ throw new Error('Score’s LilyPond runtime is missing. Run Score setup or Retry its installation.');+}+if(process.argv[1]&&resolve(process.argv[1])===fileURLToPath(import.meta.url)){+ try{+ const found=process.argv.includes('--install')?await ensureLilypond():await findLilypond();+ if(!found)throw new Error('Score’s LilyPond runtime is missing. Retry installation to download it.');+ console.log(`ok LilyPond ${found.version} · ${found.bin}`);+ }catch(error){console.error(error.message);process.exitCode=1;}+}diff --git a/store/agents/score/test/ACCEPTANCE.md b/store/agents/score/test/ACCEPTANCE.mdindex 2761f56db..d94971c0f 100644--- a/store/agents/score/test/ACCEPTANCE.md+++ b/store/agents/score/test/ACCEPTANCE.md@@ -4,6 +4,22 @@ Validated 2026-09-20, macOS Intel, Node 22.23.2 and official LilyPond 2.26.0.No physical instruments or real-player evaluation were used. This is softwarevalidation of a composition/edit/export workflow, not a musical-quality rating.+## Managed installation regression — 2026-09-20++A Store first-run failure on an Intel Mac exposed that setup only checked for LilyPond.+Setup now installs the pinned official 2.26.0 archive when needed, verifies its official+SHA-256, checks the extracted executable and reuses the managed runtime. Doctor only checks;+the renderer resolves the same binary. No Homebrew, administrator access or PATH edit is needed.++Verified a fresh real download/install under `/private/tmp/score-native-setup-proof`, then ran+the normal `render-score.sh` without `LILYPOND_BIN`: 55 checks passed and four PDF documents+were produced in `/private/tmp/score-managed-build-HlLWW6`. The full suite passed **19/19**,+including the four native tests and four installer regressions for clean/repeated installs,+failed downloads/extraction, retained old cache, explicit overrides and platform handling.+The retained native fixtures are under `/private/tmp/score-installer-native/`.+CI now performs a clean Linux x86-64 install and real engraving through the managed resolver.+Apple Silicon uses its separately pinned official archive; it was not executed on this Intel Mac.+## Two complete briefs| Job | Requirements and substantive revision | Evidence |diff --git a/store/agents/score/test/installer.test.mjs b/store/agents/score/test/installer.test.mjsnew file mode 100644index 000000000..bc53191db--- /dev/null+++ b/store/agents/score/test/installer.test.mjs@@ -0,0 +1,45 @@+import {test} from 'node:test';+import assert from 'node:assert/strict';+import {mkdir,mkdtemp,writeFile,readFile,chmod,copyFile,rm,readdir} from 'node:fs/promises';+import {join} from 'node:path';+import {tmpdir} from 'node:os';+import {spawnSync} from 'node:child_process';+import {createHash} from 'node:crypto';+import {releaseFor,probeLilypond,findLilypond,ensureLilypond,resolveLilypond,VERSION} from '../skills/score/scripts/lilypond.mjs';++async function fixture(t){+ const root=await mkdtemp(join(tmpdir(),'score-install-'));t.after(()=>rm(root,{recursive:true,force:true}));+ const source=join(root,'source'),folder=join(source,'lilypond-'+VERSION);await mkdir(join(folder,'bin'),{recursive:true});+ const bin=join(folder,'bin/lilypond');await writeFile(bin,'#!/bin/sh\nprintf "GNU LilyPond '+VERSION+'\\n"\n');await chmod(bin,0o755);+ const archive=join(root,'test.tar.gz'),tar=spawnSync('tar',['-czf',archive,'-C',source,'lilypond-'+VERSION],{encoding:'utf8'});assert.equal(tar.status,0,tar.stderr);+ const runtime=join(root,'runtime'),env={...process.env,SCORE_RUNTIME_DIR:runtime,LILYPOND_BIN:''};+ const release={...releaseFor('darwin','x64'),sha256:createHash('sha256').update(await readFile(archive)).digest('hex')};+ const options={env,platform:'darwin',arch:'x64',probe:(bin,env)=>bin.startsWith(runtime)?probeLilypond(bin,env):null,download:(_url,path)=>copyFile(archive,path),getRelease:()=>release,log:()=>{}};+ return {root,bin,archive,runtime,env,release,options};+}+test('a clean install verifies, extracts, runs and reuses its managed runtime',async t=>{+ const f=await fixture(t);assert.equal(await findLilypond(f.options),null);+ let downloads=0;const options={...f.options,download:async(...args)=>{downloads++;await f.options.download(...args);}};+ const installed=await ensureLilypond(options);assert.equal(installed.version,VERSION);assert.equal(downloads,1);+ assert.equal(await resolveLilypond(f.options),installed.bin);assert.equal((await ensureLilypond(options)).bin,installed.bin);assert.equal(downloads,1);+ assert.equal((await readdir(f.runtime)).some(n=>n.startsWith('.lilypond-install-')),false);+});+test('a broken checksum or extraction never publishes a runtime and leaves a retry possible',async t=>{+ const f=await fixture(t);+ await assert.rejects(ensureLilypond({...f.options,download:(_url,path)=>writeFile(path,'corrupt')}),/checksum/);+ assert.deepEqual(await readdir(f.runtime),[]);+ await assert.rejects(ensureLilypond({...f.options,unpack:async()=>{throw new Error('unpack failed');}}),/unpack failed/);+ assert.deepEqual(await readdir(f.runtime),[]);assert.equal((await ensureLilypond(f.options)).version,VERSION);+});+test('repair preserves a broken previous cache; explicit executable overrides are respected',async t=>{+ const f=await fixture(t),target=join(f.runtime,f.release.name);await mkdir(target,{recursive:true});await writeFile(join(target,'keep.txt'),'old cache evidence');+ await ensureLilypond(f.options);const backup=(await readdir(f.runtime)).find(n=>n.startsWith(f.release.name+'.previous-'));+ assert.equal(await readFile(join(f.runtime,backup,'keep.txt'),'utf8'),'old cache evidence');+ const found=await findLilypond({env:{...f.env,LILYPOND_BIN:f.bin}});assert.equal(found.bin,f.bin);+ await assert.rejects(ensureLilypond({...f.options,env:{...f.env,LILYPOND_BIN:join(f.root,'missing')}}),/configured LILYPOND_BIN/);+});+test('an existing system install needs no download, and unsupported machines get a specific error',async()=>{+ let downloaded=false;const result=await ensureLilypond({env:{LILYPOND_BIN:''},platform:'linux',arch:'arm64',probe:bin=>bin==='lilypond'?{bin,version:VERSION}:null,download:async()=>{downloaded=true;}});+ assert.equal(result.bin,'lilypond');assert.equal(downloaded,false);+ await assert.rejects(ensureLilypond({env:{LILYPOND_BIN:''},platform:'linux',arch:'arm64',probe:()=>null}),/linux\/arm64/);+});diff --git a/store/agents/score/toolchain/doctor.sh b/store/agents/score/toolchain/doctor.shindex f2fc0f9bf..45940c88c 100755--- a/store/agents/score/toolchain/doctor.sh+++ b/store/agents/score/toolchain/doctor.sh@@ -1,5 +1,5 @@#!/bin/shset -euHERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)-sh "$HERE/setup.sh" || { echo "miss LilyPond — install from https://lilypond.org/download.html or set LILYPOND_BIN"; exit 1; }+bash "$HERE/node.sh" "$HERE/../skills/score/scripts/lilypond.mjs" --check || exit 1echo "ok LilyPond + Node; PDF/SVG engraving and MIDI playback available"diff --git a/store/agents/score/toolchain/setup.sh b/store/agents/score/toolchain/setup.shindex 407abceec..73fb43d2c 100755--- a/store/agents/score/toolchain/setup.sh+++ b/store/agents/score/toolchain/setup.sh@@ -1,10 +1,4 @@#!/bin/shset -euHERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)-bash "$HERE/node.sh" --version-SCORE_LILYPOND=${LILYPOND_BIN:-lilypond}-if ! command -v "$SCORE_LILYPOND" >/dev/null 2>&1; then- printf '%s\n' 'Score needs LilyPond for engraving. Install it from https://lilypond.org/download.html, or set LILYPOND_BIN to its executable. No musical instruments are needed.' >&2- exit 1-fi-"$SCORE_LILYPOND" --version+bash "$HERE/node.sh" "$HERE/../skills/score/scripts/lilypond.mjs" --install