fix: honor global preview in every guided install entry

Scoped adaptation from PR #3088. Keep the canonical atomic writer and dispatcher; exclude the broader provider/tool changes.

Co-authored-by: Geronimo <varungore1@gmail.com>
This commit is contained in:
haelyra
2026-10-11 02:03:09 -04:00
co-authored by Geronimo
parent 5ad9cb931b
commit da87114e05
2 changed files with 52 additions and 1 deletions
+5 -1
View File
@@ -106,7 +106,11 @@ function parseArgs(argv) {
if (options.allHarnesses && options.harnesses.length > 0) {
throw new Error('--all-harnesses and --harness are mutually exclusive.');
}
return options;
const dryRunEnv = process.env.ECC_DRY_RUN;
if (dryRunEnv !== undefined && dryRunEnv !== '0' && dryRunEnv !== '1') {
throw new Error('ECC_DRY_RUN must be "1" or "0" when set');
}
return { ...options, dryRun: options.dryRun || dryRunEnv === '1' };
}
function choicesText(values) {
@@ -0,0 +1,47 @@
'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const { spawnSync } = require('node:child_process');
const test = require('node:test');
const repoRoot = path.resolve(__dirname, '../..');
for (const entry of ['install-guided.js', 'install-apply.js', 'ecc.js']) {
test(`global dry-run protects the actual ${entry} guided workflow`, () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-guided-global-preview-'));
try {
const home = path.join(root, 'home');
const project = path.join(root, 'project');
fs.mkdirSync(home);
fs.mkdirSync(project);
const args = entry === 'ecc.js' ? ['--dry-run', 'install', '--guided']
: entry === 'install-apply.js' ? ['--guided'] : [];
const child = spawnSync(process.execPath, [path.join(repoRoot, 'scripts', entry),
...args, '--harness', 'kimi', '--profile', 'minimal', '--yes', '--json'], {
cwd: project, encoding: 'utf8', timeout: 30000, maxBuffer: 16 * 1024 * 1024,
env: { ...process.env, HOME: home, USERPROFILE: home,
CLAUDE_CONFIG_DIR: path.join(home, '.claude'), ECC_DRY_RUN: '1' },
});
assert.equal(child.status, 0, child.stderr);
const payload = JSON.parse(child.stdout);
assert.equal(payload.dryRun, true);
assert.equal(payload.plan.request.dryRun, true);
assert.deepEqual(fs.readdirSync(home), []);
assert.deepEqual(fs.readdirSync(project), []);
} finally {
fs.rmSync(root, { recursive: true, force: true });
}
});
}
test('invalid global dry-run input is rejected before guided planning', () => {
const child = spawnSync(process.execPath, [path.join(repoRoot, 'scripts/install-guided.js'),
'--harness', 'kimi', '--yes', '--json'], {
encoding: 'utf8', env: { ...process.env, ECC_DRY_RUN: 'yes' },
});
assert.equal(child.status, 1);
assert.match(JSON.parse(child.stderr).error.message, /ECC_DRY_RUN must be "1" or "0"/);
});