From 68afd412ae8ea27597db14da22911ee2ac99b165 Mon Sep 17 00:00:00 2001 From: Renan Fagundes Date: Wed, 21 Oct 2026 16:47:12 +0100 Subject: [PATCH] fix: address the review follow-ups on the manifest scripts - build-codex-zip.mts: the SystemRoot fallback was 'C:\Windows', which a single backslash turned into C:Windows. Escape it. - sync-manifests.mts: only rewrite the version in the two sample output lines of .github/README.md, so other version numbers there (such as a Codex CLI version) are left alone. The script fails if a sample line goes missing. Co-Authored-By: Claude Opus 5.5 --- scripts/build-codex-zip.mts | 2 +- scripts/sync-manifests.mts | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/scripts/build-codex-zip.mts b/scripts/build-codex-zip.mts index 2204a8c..4bc1aa3 100644 --- a/scripts/build-codex-zip.mts +++ b/scripts/build-codex-zip.mts @@ -73,7 +73,7 @@ try { execFileSync('zip', ['-r', '-X', '-q', out, 'unity'], { cwd: stage, stdio: 'inherit' }); } else { const tar = - process.platform === 'win32' ? join(process.env.SystemRoot ?? 'C:\Windows', 'System32', 'tar.exe') : 'tar'; + process.platform === 'win32' ? join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'tar.exe') : 'tar'; execFileSync(tar, ['--format', 'zip', '-cf', out, 'unity'], { cwd: stage, stdio: 'inherit' }); } diff --git a/scripts/sync-manifests.mts b/scripts/sync-manifests.mts index 78167ce..a47f80c 100644 --- a/scripts/sync-manifests.mts +++ b/scripts/sync-manifests.mts @@ -103,19 +103,28 @@ for (const { file, set } of targets) { else writeFileSync(file, after); } -// The sample `agy plugin list` and `codex plugin list` output in the README shows the version. +// The sample `codex plugin list` and `agy plugin list` output in the README shows the version. +// Only those two lines are matched, so other version numbers in the README are left alone. const readme = '.github/README.md'; -const readmeText = readFileSync(readme, 'utf8'); -const stale = [...readmeText.matchAll(/\b0\.\d+\.\d+(?:-[a-z0-9.]+)?\b/g)] - .map((m) => m[0]) - .filter((v) => v !== meta.version); -if (stale.length > 0) { - if (check) drifted.push(`${readme} (shows ${[...new Set(stale)].join(', ')})`); - else writeFileSync(readme, readmeText.replaceAll(new RegExp(stale.map(escape).join('|'), 'g'), meta.version)); +// Group 1 is the text before the version, group 2 the version itself. +const samples = [ + /^(unity@unity-agent-plugin\s+installed, enabled\s+)(\S+)$/m, + /^(- unity \(enabled, )([^)]+)\)$/m, +]; +let readmeText = readFileSync(readme, 'utf8').replace(/\r\n/g, '\n'); +const staleVersions = new Set(); +for (const sample of samples) { + const match = sample.exec(readmeText); + if (!match) throw new Error(`${readme}: no line matches ${sample}; update the pattern in this script`); + const [, head, version] = match; + if (version === meta.version) continue; + staleVersions.add(version); + const start = match.index + head.length; + readmeText = readmeText.slice(0, start) + meta.version + readmeText.slice(start + version.length); } - -function escape(s: string): string { - return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +if (staleVersions.size > 0) { + if (check) drifted.push(`${readme} (sample output shows ${[...staleVersions].join(', ')})`); + else writeFileSync(readme, readmeText); } if (drifted.length > 0) {