Files
ECC/scripts/lib/install-targets/codex-home.js
T
affaan-m c5bb5579fe fix(codex): separate project guidance from user install defaults
Preserve the original contributor histories and apply the exact independently reviewed repair.

Source-Parent: 81df6475b2
Review-Manifest-SHA256: 272ae1970f0b94fe40dbb974b509b7333682176259f5a1493bbae12d9a7e70cb
2026-09-28 06:42:33 -04:00

48 lines
1.7 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const {
HOME_INSTALL_EXCLUDED_SOURCE_PATHS, createInstallTargetAdapter, createManagedOperation,
} = require('./helpers');
const adapter = createInstallTargetAdapter({
id: 'codex-home',
target: 'codex',
kind: 'home',
rootSegments: ['.codex'],
installStatePathSegments: ['ecc-install-state.json'],
nativeRootRelativePath: '.codex',
excludedSourcePaths: HOME_INSTALL_EXCLUDED_SOURCE_PATHS,
});
const USER_REFERENCE = '.codex/user-config.example.toml';
module.exports = Object.freeze({
...adapter,
planOperations(input = {}) {
// Delegate the existing platform filters, exclusions and scaffold metadata.
return adapter.planOperations(input).flatMap(operation => {
if (operation.sourceRelativePath !== '.codex') return [operation];
// Abstract metadata-only plans need no filesystem. A selected real source
// must not silently fall back to the narrower project config.
if (input.repoRoot && fs.existsSync(input.repoRoot)) {
let stat;
try {
stat = fs.lstatSync(path.join(input.repoRoot, USER_REFERENCE));
} catch (error) {
if (error.code !== 'ENOENT') throw error;
}
if (!stat || !stat.isFile() || stat.isSymbolicLink()) {
throw new Error('Codex user reference must exist as a regular file');
}
}
// The planner materializes these operations, then keeps the last copy per
// destination before preview/state/apply. Only the user reference survives.
return [operation, createManagedOperation({
moduleId: operation.moduleId,
sourceRelativePath: USER_REFERENCE,
destinationPath: path.join(operation.destinationPath, 'config.toml'),
})];
});
},
});