fix(scripts): avoid false-positive legacy Codex sync detection

Tighten uninstall auto-detection so it only falls back to the legacy
sync-ecc-to-codex.sh path when there is an ownership manifest
(~/.codex/ecc/legacy-sync-state.json) or an ECC marker block in
~/.codex/AGENTS.md. Previously a clean Codex home with unrelated prompt
files could be misclassified as a legacy install, causing uninstall to
skip normal install-state reconciliation and exit with a partial warning.

Also make the no-state fallback return 'not-found' when there is no
marker to remove and no candidate files to clean, and make explicit
--legacy-codex-sync report the same on a clean home.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Santhi Prakash
2026-08-24 20:09:12 -04:00
committed by haelyra
co-authored by Paperclip
parent 09d6d22c09
commit f4f5cf9027
3 changed files with 84 additions and 10 deletions
+7 -8
View File
@@ -5,7 +5,10 @@ const path = require('path');
const { uninstallInstalledStates } = require('./lib/install-lifecycle');
const { SUPPORTED_INSTALL_TARGETS } = require('./lib/install-manifests');
const { exitFeedbackLines } = require('./lib/feedback-links');
const { uninstallLegacyCodexSync } = require('./lib/codex-legacy-sync');
const {
detectLegacyCodexSync,
uninstallLegacyCodexSync,
} = require('./lib/codex-legacy-sync');
function showHelp(exitCode = 0) {
console.log(`
@@ -90,12 +93,8 @@ function printHuman(result) {
}
}
function detectLegacyCodexSync(codexHome) {
const probe = uninstallLegacyCodexSync({
codexHome,
dryRun: true,
});
return probe.status !== 'not-found';
function legacyCodexSyncDetected(codexHome) {
return detectLegacyCodexSync(codexHome);
}
function printLegacy(result, dryRun) {
@@ -149,7 +148,7 @@ async function main() {
if (
result.results.length === 0
&& includesCodexTarget(options.targets)
&& detectLegacyCodexSync(codexHomePath())
&& legacyCodexSyncDetected(codexHomePath())
) {
result = uninstallLegacyCodexSync({
codexHome: codexHomePath(),