From 28374c0bb2f66c449a5d16363869b48eef955566 Mon Sep 17 00:00:00 2001 From: wassname <1103714+wassname@users.noreply.github.com> Date: Thu, 10 Sep 2026 18:42:42 +0800 Subject: [PATCH] Prepare isolated trials with bundled dependencies loaded once Validated generated profile and manifest after clean-checkout tests. Co-Authored-By: Pi/OpenAI <288921227+claudypoo@users.noreply.github.com> --- scripts/prepare-trial.mjs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/prepare-trial.mjs b/scripts/prepare-trial.mjs index e2d92d2..4a96e47 100644 --- a/scripts/prepare-trial.mjs +++ b/scripts/prepare-trial.mjs @@ -5,12 +5,10 @@ import { fileURLToPath, pathToFileURL } from 'node:url'; import { execFileSync } from 'node:child_process'; import { homedir, tmpdir } from 'node:os'; const repo = resolve(dirname(fileURLToPath(import.meta.url)), '..'); -const edxeth = process.argv[2]; -const sdkRoot = process.argv[3]; +const sdkRoot = process.argv[2]; const noSandbox = process.argv.includes('--no-sandbox'); -if (!edxeth || !sdkRoot) throw new Error('Usage: node scripts/prepare-trial.mjs EDXETH_CHECKOUT INSTALLED_PI_ROOT'); -const revision = execFileSync('git', ['-C', edxeth, 'rev-parse', 'HEAD'], {encoding:'utf8'}).trim(); -if (revision !== '953c6f6d2fc7d8a5c956c30cd77c51bad697c2a4') throw new Error('Unreviewed edxeth revision; inspect and update the pin explicitly'); +if (!sdkRoot) throw new Error('Usage: node scripts/prepare-trial.mjs INSTALLED_PI_ROOT'); +const revision = execFileSync('git', ['-C', repo, 'rev-parse', 'HEAD'], {encoding:'utf8'}).trim(); const root = mkdtempSync(join(tmpdir(), 'goals-edxeth-trial-')); const cwd = join(root, 'project'); const agentDir = join(root, 'agent'); mkdirSync(cwd); mkdirSync(agentDir, {mode:0o700}); mkdirSync(join(agentDir,'agents')); @@ -20,9 +18,9 @@ const sdk = await import(pathToFileURL(join(sdkRoot,'dist/index.js')).href); const settings = sdk.SettingsManager.create(repo, sourceAgent, { projectTrusted:false }); const manager = new sdk.DefaultPackageManager({cwd:repo, agentDir:sourceAgent, settingsManager:settings}); const packages = manager.listConfiguredPackages().filter((p) => p.scope !== 'project' && !/^\/\//.test(p.source)); -const retained = packages.filter((p) => !/pi-subagents|pi-goals/.test(p.source)); +const retained = packages.filter((p) => !/pi-subagents|pi-goals|pi-intercom|pi-schedule-prompt/.test(p.source)); for (const p of retained) if (!p.installedPath) throw new Error(`Missing installed package: ${p.source}`); -writeFileSync(join(agentDir,'settings.json'), JSON.stringify({...sourceSettings, packages:[...retained.map((p)=>p.installedPath), edxeth, repo]},null,2)); +writeFileSync(join(agentDir,'settings.json'), JSON.stringify({...sourceSettings, packages:[...retained.map((p)=>p.installedPath), repo]},null,2)); // Private copies, not symlinks: a trial OAuth refresh must not write the active auth file. for (const file of ['auth.json','models.json']) if (existsSync(join(sourceAgent,file))) copyFileSync(join(sourceAgent,file),join(agentDir,file)); const workerDefinition = readFileSync(join(repo,'agents/goals-worker.md'),'utf8'); @@ -30,7 +28,7 @@ writeFileSync(join(agentDir,'agents/goals-worker.md'), noSandbox ? workerDefinit execFileSync('git',['init','--quiet',cwd]); writeFileSync(join(cwd,'AGENTS.md'), 'Isolated functional trial. Work only in this project. Do not operate other Herdr panes, use live research sessions, or change global settings. Preserve evidence. The main chat supervises; the goals-worker implements.\n'); writeFileSync(join(cwd,'.gitignore'), 'evidence/\n'); -const manifest={root,cwd,agentDir,repo,edxeth,revision,noSandbox,retainedPackages:retained.map((p)=>p.source),replacedPackages:packages.filter((p)=>!retained.includes(p)).map((p)=>p.source)}; +const manifest={root,cwd,agentDir,repo,revision,noSandbox,retainedPackages:retained.map((p)=>p.source),replacedPackages:packages.filter((p)=>!retained.includes(p)).map((p)=>p.source)}; writeFileSync(join(root,'manifest.json'),JSON.stringify(manifest,null,2)); const quote=(s)=>`'${s.replaceAll("'", "'\\''")}'`; writeFileSync(join(root,'start.zsh'), `#!/usr/bin/env zsh\nset -e\ncd ${quote(cwd)}\nexport PI_CODING_AGENT_DIR=${quote(agentDir)}\nexport PI_SUBAGENT_MUX=herdr\nexport PI_ORCHESTRATOR_MODE=0\nexec pi --approve${noSandbox ? ' --no-sandbox' : ''}\n`,{mode:0o700});