mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-09-30 12:39:42 +02:00
feat(predictive-echo): second vendor bundle wiring
postinstall + build.mjs build vendor/xterm-predictive-echo.js as a SEPARATE IIFE (window.PredictiveEchoAddon + self-activating PredictiveEchoOverlay); the zerolag bundle command is untouched and its output verified sha256-identical. index.html loads it after the zerolag tag (cacheBustAssets covers it), sw.js precaches it, build.mjs HASHABLE content-hashes it. A missing or broken bundle degrades codex to plain PTY echo. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,22 @@ appendFileSync(
|
||||
'}\n'
|
||||
);
|
||||
|
||||
// Predictive echo (codex): separate bundle so the zerolag bundle stays byte-identical
|
||||
run('xterm-predictive-echo', 'npx esbuild packages/xterm-zerolag-input/src/predictive-echo-addon.ts --bundle --minify --format=iife --global-name=XtermPredictiveEcho --outfile=dist/web/public/vendor/xterm-predictive-echo.js');
|
||||
appendFileSync(
|
||||
join(ROOT, 'dist/web/public/vendor/xterm-predictive-echo.js'),
|
||||
'\n// Global aliases for browser usage\n' +
|
||||
'if(typeof window!=="undefined"){' +
|
||||
'window.PredictiveEchoAddon=XtermPredictiveEcho.PredictiveEchoAddon;' +
|
||||
'window.PredictiveEchoOverlay=class extends XtermPredictiveEcho.PredictiveEchoAddon{' +
|
||||
'constructor(terminal){' +
|
||||
'super({});' +
|
||||
'this.activate(terminal);' +
|
||||
'}' +
|
||||
'};' +
|
||||
'}\n'
|
||||
);
|
||||
|
||||
// 4. Minify frontend assets
|
||||
run('minify input-cjk.js', 'npx esbuild dist/web/public/input-cjk.js --minify --outfile=dist/web/public/input-cjk.js --allow-overwrite');
|
||||
run('minify i18n.js', 'npx esbuild dist/web/public/i18n.js --minify --outfile=dist/web/public/i18n.js --allow-overwrite');
|
||||
@@ -106,6 +122,7 @@ console.log('\n[build] content-hash cache busting');
|
||||
'subagent-windows.js',
|
||||
'image-input.js',
|
||||
'vendor/xterm-zerolag-input.js',
|
||||
'vendor/xterm-predictive-echo.js',
|
||||
];
|
||||
const manifest = {};
|
||||
for (const file of HASHABLE) {
|
||||
|
||||
@@ -304,6 +304,35 @@ if (isGlobalInstall) {
|
||||
} catch {
|
||||
console.log(colors.yellow('⚠ Failed to bundle xterm-zerolag-input — overlay may not work in dev mode'));
|
||||
}
|
||||
|
||||
// Predictive echo (codex): SEPARATE bundle so the zerolag bundle above stays
|
||||
// byte-identical. If this file is missing or broken, codex simply falls back
|
||||
// to plain PTY echo (pre-predictive behavior); nothing else is affected.
|
||||
try {
|
||||
const predSrc = join(import.meta.dirname, '..', 'packages', 'xterm-zerolag-input', 'src', 'predictive-echo-addon.ts');
|
||||
const predOut = join(vendorDir, 'xterm-predictive-echo.js');
|
||||
execSync(
|
||||
`npx esbuild "${predSrc}" --bundle --format=iife --global-name=XtermPredictiveEcho --outfile="${predOut}"`,
|
||||
{ stdio: 'pipe' }
|
||||
);
|
||||
const { appendFileSync } = await import('fs');
|
||||
appendFileSync(
|
||||
predOut,
|
||||
'\n// Global aliases for browser usage\n' +
|
||||
'if(typeof window!=="undefined"){' +
|
||||
'window.PredictiveEchoAddon=XtermPredictiveEcho.PredictiveEchoAddon;' +
|
||||
'window.PredictiveEchoOverlay=class extends XtermPredictiveEcho.PredictiveEchoAddon{' +
|
||||
'constructor(terminal){' +
|
||||
'super({});' +
|
||||
'this.activate(terminal);' +
|
||||
'}' +
|
||||
'};' +
|
||||
'}\n'
|
||||
);
|
||||
console.log(colors.green('✓ xterm-predictive-echo bundled to vendor/'));
|
||||
} catch (e) {
|
||||
console.log(colors.yellow('⚠ predictive-echo bundle failed (codex uses plain echo): ' + e.message));
|
||||
}
|
||||
} catch (err) {
|
||||
hasWarnings = true;
|
||||
console.log(colors.yellow('⚠ Failed to copy xterm vendor files'));
|
||||
|
||||
Reference in New Issue
Block a user