Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 55 additions & 7 deletions apps/ade-cli/scripts/build-static.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ function __adeSeaCandidateRuntimeRoots() {
var explicitNodeModules = process.env.ADE_RUNTIME_NODE_MODULES;
if (explicitRoot) roots.push(explicitRoot);
if (explicitNodeModules) roots.push(__adeSeaRuntimeRootFromNodeModules(explicitNodeModules));
roots.push(__adeSeaPath.join(__adeSeaPath.dirname(process.execPath), "ade-" + target + ".native"));
roots.push(__adeSeaPath.dirname(process.execPath));
roots.push(__adeSeaPath.join(__adeSeaPath.dirname(process.execPath), "..", "runtime", target));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if (process.env.NODE_PATH) {
process.env.NODE_PATH.split(__adeSeaPath.delimiter).forEach(function (entry) {
roots.push(__adeSeaRuntimeRootFromNodeModules(entry));
});
}
roots.push(__adeSeaPath.join(__adeSeaPath.dirname(process.execPath), "ade-" + target + ".native"));
roots.push(__adeSeaPath.dirname(process.execPath));
roots.push(__adeSeaPath.join(__adeSeaPath.dirname(process.execPath), "..", "runtime", target));
roots.push(__adeSeaPath.join(__adeSeaOs.homedir(), ".ade", "runtime", target));
return roots.filter(function (entry, index) {
return Boolean(entry) && roots.indexOf(entry) === index;
Expand Down Expand Up @@ -220,7 +220,33 @@ if (__adeSeaRuntimeRoot) {
var __adeSeaFilesystemRequire = __adeSeaModule.createRequire(
__adeSeaRuntimeRoot ? __adeSeaPath.join(__adeSeaRuntimeRoot, ".ade-runtime.cjs") : process.execPath
);
var __adeSeaBuiltinModules = new Set(__adeSeaModule.builtinModules || []);
function __adeSeaIsBuiltinModuleId(id) {
var bare = id.indexOf("node:") === 0 ? id.slice(5) : id;
return __adeSeaBuiltinModules.has(id) || __adeSeaBuiltinModules.has(bare);
}
function __adeSeaIsBareModuleId(id) {
return typeof id === "string"
&& id.length > 0
&& id.charAt(0) !== "."
&& !__adeSeaPath.isAbsolute(id)
&& !/^[A-Za-z]:[\\/]/.test(id);
}
function __adeSeaShouldUseFilesystemRequireFirst(id) {
return Boolean(__adeSeaRuntimeRoot)
&& __adeSeaIsBareModuleId(id)
&& !__adeSeaIsBuiltinModuleId(id);
}
function __adeSeaRequire(id) {
if (__adeSeaShouldUseFilesystemRequireFirst(id)) {
try {
return __adeSeaFilesystemRequire(id);
} catch (error) {
if (!error || (error.code !== "ERR_UNKNOWN_BUILTIN_MODULE" && error.code !== "MODULE_NOT_FOUND")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not fall back after nested require failures

When a native-runtime package exists but one of its own dependencies is missing, __adeSeaFilesystemRequire(id) throws MODULE_NOT_FOUND with the same code used when the top-level package is absent, so this block silently falls back to the SEA-bundled module. That can hide an incomplete/corrupt native runtime and run a mismatched bundled implementation instead of failing the installed/static runtime immediately; only fall back when the missing module is the requested id itself.

Useful? React with 👍 / 👎.

throw error;
}
}
}
try {
return __adeSeaOriginalRequire(id);
} catch (error) {
Expand All @@ -232,6 +258,15 @@ function __adeSeaRequire(id) {
}
Object.assign(__adeSeaRequire, __adeSeaOriginalRequire);
__adeSeaRequire.resolve = function __adeSeaRequireResolve(id, options) {
if (__adeSeaShouldUseFilesystemRequireFirst(id)) {
try {
return __adeSeaFilesystemRequire.resolve(id, options);
} catch (error) {
if (!error || (error.code !== "ERR_UNKNOWN_BUILTIN_MODULE" && error.code !== "MODULE_NOT_FOUND")) {
throw error;
}
}
}
try {
return __adeSeaOriginalRequire.resolve(id, options);
} catch (error) {
Expand Down Expand Up @@ -306,22 +341,35 @@ async function main() {
}
await run(path.join(packageRoot, "node_modules", ".bin", process.platform === "win32" ? "postject.cmd" : "postject"), postjectArgs);
await adHocSignIfNeeded(binaryPath);
await assertStaticRuntimeVersion(binaryPath, runtimeVersion, args.target);

let nativeArchivePath = null;
const nativeStagingRoot = path.join(args.outDir, `ade-${args.target}.native`);
const shouldRemoveNativeStaging = !args.skipNativeDeps && process.env.ADE_KEEP_NATIVE_RUNTIME_STAGING !== "1";
if (!args.skipNativeDeps) {
await run(process.execPath, [
path.join(packageRoot, "scripts", "package-native-deps.mjs"),
"--target",
args.target,
"--out-dir",
args.outDir,
]);
], {
env: {
...process.env,
ADE_KEEP_NATIVE_RUNTIME_STAGING: "1",
},
});
nativeArchivePath = path.join(args.outDir, `ade-${args.target}.native.tar.gz`);
}

if (process.env.ADE_KEEP_STATIC_RUNTIME_STAGING !== "1") {
await fs.rm(workDir, { recursive: true, force: true });
try {
await assertStaticRuntimeVersion(binaryPath, runtimeVersion, args.target);
} finally {
if (shouldRemoveNativeStaging) {
await fs.rm(nativeStagingRoot, { recursive: true, force: true });
}
if (process.env.ADE_KEEP_STATIC_RUNTIME_STAGING !== "1") {
await fs.rm(workDir, { recursive: true, force: true });
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

process.stdout.write(`${JSON.stringify({
Expand Down
8 changes: 8 additions & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@
"from": "../ade-cli/dist/ptyHostWorker.cjs",
"to": "ade-cli/ptyHostWorker.cjs"
},
{
"from": "../ade-cli/dist/cursorSdkWorker.cjs",
"to": "ade-cli/cursorSdkWorker.cjs"
},
{
"from": "../ade-cli/dist/droidSdkWorker.cjs",
"to": "ade-cli/droidSdkWorker.cjs"
},
{
"from": "../ade-cli/dist/adeRpcServer.cjs",
"to": "ade-cli/adeRpcServer.cjs"
Expand Down
4 changes: 4 additions & 0 deletions apps/desktop/scripts/after-pack-runtime-fixes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,15 @@ module.exports = async function afterPack(context) {
const bundledCliPath = path.join(resourcesRoot, "ade-cli", "cli.cjs");
const bundledCliBootstrapPath = path.join(resourcesRoot, "ade-cli", "bootstrap.cjs");
const bundledCliPtyHostWorkerPath = path.join(resourcesRoot, "ade-cli", "ptyHostWorker.cjs");
const bundledCliCursorSdkWorkerPath = path.join(resourcesRoot, "ade-cli", "cursorSdkWorker.cjs");
const bundledCliDroidSdkWorkerPath = path.join(resourcesRoot, "ade-cli", "droidSdkWorker.cjs");
const bundledCliRpcPath = path.join(resourcesRoot, "ade-cli", "adeRpcServer.cjs");
const bundledCliTuiPath = path.join(resourcesRoot, "ade-cli", "tuiClient", "cli.mjs");
requireFile(bundledCliPath, "bundled ADE CLI entry");
requireFile(bundledCliBootstrapPath, "bundled ADE CLI bootstrap entry");
requireFile(bundledCliPtyHostWorkerPath, "bundled ADE CLI PTY host worker");
requireFile(bundledCliCursorSdkWorkerPath, "bundled ADE CLI Cursor SDK worker");
requireFile(bundledCliDroidSdkWorkerPath, "bundled ADE CLI Droid SDK worker");
requireFile(bundledCliRpcPath, "bundled ADE CLI RPC entry");
requireFile(bundledCliTuiPath, "bundled ADE CLI TUI entry");

Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/scripts/ensure-ade-cli-build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const distFiles = [
path.join(cliRoot, "dist", "cli.cjs"),
path.join(cliRoot, "dist", "bootstrap.cjs"),
path.join(cliRoot, "dist", "adeRpcServer.cjs"),
path.join(cliRoot, "dist", "ptyHostWorker.cjs"),
path.join(cliRoot, "dist", "cursorSdkWorker.cjs"),
path.join(cliRoot, "dist", "droidSdkWorker.cjs"),
path.join(cliRoot, "dist", "tuiClient", "cli.mjs"),
];

Expand Down
25 changes: 14 additions & 11 deletions apps/desktop/scripts/validate-mac-artifacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ const bundledAgentSkills = [
"ade-macos-vm",
"ade-deeplinks",
];
const bundledAdeCliFiles = [
["cli.cjs", "bundled ADE CLI entry"],
["bootstrap.cjs", "bundled ADE CLI bootstrap entry"],
["ptyHostWorker.cjs", "bundled ADE CLI PTY host worker"],
["cursorSdkWorker.cjs", "bundled ADE CLI Cursor SDK worker"],
["droidSdkWorker.cjs", "bundled ADE CLI Droid SDK worker"],
["adeRpcServer.cjs", "bundled ADE CLI RPC entry"],
["tuiClient/cli.mjs", "bundled ADE CLI TUI entry"],
["bin/ade", "bundled ADE CLI wrapper"],
["install-path.sh", "bundled ADE CLI PATH installer"],
];

function readFlag(name) {
const prefix = `${name}=`;
Expand Down Expand Up @@ -403,10 +414,6 @@ async function validatePackagedRuntime(appPath, description) {
const resourcesPath = path.join(appPath, "Contents", "Resources");
const appAsarPath = path.join(resourcesPath, "app.asar");
const unpackedPath = await resolveRuntimeUnpackedPath(resourcesPath);
const adeCliPath = path.join(resourcesPath, "ade-cli", "cli.cjs");
const adeCliBootstrapPath = path.join(resourcesPath, "ade-cli", "bootstrap.cjs");
const adeCliPtyHostWorkerPath = path.join(resourcesPath, "ade-cli", "ptyHostWorker.cjs");
const adeCliRpcPath = path.join(resourcesPath, "ade-cli", "adeRpcServer.cjs");
const adeCliTuiPath = path.join(resourcesPath, "ade-cli", "tuiClient", "cli.mjs");
const adeCliBinPath = path.join(resourcesPath, "ade-cli", "bin", "ade");
const adeCliInstallerPath = path.join(resourcesPath, "ade-cli", "install-path.sh");
Expand All @@ -420,13 +427,9 @@ async function validatePackagedRuntime(appPath, description) {
await assertPathExists(appAsarPath, "app.asar payload");
await assertPathExists(unpackedPath, "unpacked runtime payload");
assertPackagedStartupModules(appAsarPath, description);
await assertPathExists(adeCliPath, "bundled ADE CLI entry");
await assertPathExists(adeCliBootstrapPath, "bundled ADE CLI bootstrap entry");
await assertPathExists(adeCliPtyHostWorkerPath, "bundled ADE CLI PTY host worker");
await assertPathExists(adeCliRpcPath, "bundled ADE CLI RPC entry");
await assertPathExists(adeCliTuiPath, "bundled ADE CLI TUI entry");
await assertPathExists(adeCliBinPath, "bundled ADE CLI wrapper");
await assertPathExists(adeCliInstallerPath, "bundled ADE CLI PATH installer");
for (const [relativePath, label] of bundledAdeCliFiles) {
await assertPathExists(path.join(resourcesPath, "ade-cli", relativePath), label);
}
await assertBundledAgentSkills(bundledAgentSkillsRoot);
await assertExecutable(adeCliBinPath, "bundled ADE CLI wrapper");
await assertExecutable(adeCliInstallerPath, "bundled ADE CLI PATH installer");
Expand Down
59 changes: 31 additions & 28 deletions apps/desktop/scripts/validate-win-artifacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ const bundledAgentSkills = [
"ade-macos-vm",
"ade-deeplinks",
];
const bundledAdeCliFiles = [
["cli.cjs", "bundled ADE CLI entry"],
["bootstrap.cjs", "bundled ADE CLI bootstrap entry"],
["ptyHostWorker.cjs", "bundled ADE CLI PTY host worker"],
["cursorSdkWorker.cjs", "bundled ADE CLI Cursor SDK worker"],
["droidSdkWorker.cjs", "bundled ADE CLI Droid SDK worker"],
["adeRpcServer.cjs", "bundled ADE CLI RPC entry"],
["tuiClient/cli.mjs", "bundled ADE CLI TUI entry"],
["bin/ade.cmd", "bundled ADE CLI wrapper"],
["install-path.cmd", "bundled ADE CLI PATH installer"],
];

function readFlag(name) {
const prefix = `${name}=`;
Expand Down Expand Up @@ -171,6 +182,12 @@ function hasExtraResource(to) {
&& pkg.build.extraResources.some((entry) => entry && entry.to === to);
}

function requireExtraResource(to) {
if (!hasExtraResource(to)) {
fail(`package.json build.extraResources must ship ${to}`);
}
}

function escapeRegExp(value) {
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
Expand Down Expand Up @@ -200,23 +217,17 @@ function validatePreflight() {
requireFile("scripts/ade-cli-install-path.cmd", "Windows ADE CLI PATH installer");
requireFile("vendor/crsqlite/win32-x64/crsqlite.dll", "Windows cr-sqlite extension");

if (!hasExtraResource("ade-cli/bin/ade.cmd")) {
fail("package.json build.extraResources must ship ade-cli/bin/ade.cmd");
}
if (!hasExtraResource("ade-cli/bootstrap.cjs")) {
fail("package.json build.extraResources must ship ade-cli/bootstrap.cjs");
}
if (!hasExtraResource("ade-cli/ptyHostWorker.cjs")) {
fail("package.json build.extraResources must ship ade-cli/ptyHostWorker.cjs");
}
if (!hasExtraResource("ade-cli/adeRpcServer.cjs")) {
fail("package.json build.extraResources must ship ade-cli/adeRpcServer.cjs");
}
if (!hasExtraResource("ade-cli/tuiClient")) {
fail("package.json build.extraResources must ship ade-cli/tuiClient");
}
if (!hasExtraResource("ade-cli/install-path.cmd")) {
fail("package.json build.extraResources must ship ade-cli/install-path.cmd");
for (const relativePath of [
"bin/ade.cmd",
"bootstrap.cjs",
"ptyHostWorker.cjs",
"cursorSdkWorker.cjs",
"droidSdkWorker.cjs",
"adeRpcServer.cjs",
"tuiClient",
"install-path.cmd",
]) {
requireExtraResource(`ade-cli/${relativePath}`);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if (!Array.isArray(pkg.build?.asarUnpack) || !pkg.build.asarUnpack.includes("vendor/crsqlite/**")) {
fail("package.json build.asarUnpack must unpack vendor/crsqlite/**");
Expand Down Expand Up @@ -504,10 +515,6 @@ async function validatePackagedRuntime(appDir) {
const resourcesPath = path.join(appDir, "resources");
const appAsarPath = path.join(resourcesPath, "app.asar");
const unpackedPath = path.join(resourcesPath, "app.asar.unpacked");
const adeCliPath = path.join(resourcesPath, "ade-cli", "cli.cjs");
const adeCliBootstrapPath = path.join(resourcesPath, "ade-cli", "bootstrap.cjs");
const adeCliPtyHostWorkerPath = path.join(resourcesPath, "ade-cli", "ptyHostWorker.cjs");
const adeCliRpcPath = path.join(resourcesPath, "ade-cli", "adeRpcServer.cjs");
const adeCliTuiPath = path.join(resourcesPath, "ade-cli", "tuiClient", "cli.mjs");
const adeCliBinPath = path.join(resourcesPath, "ade-cli", "bin", "ade.cmd");
const adeCliInstallerPath = path.join(resourcesPath, "ade-cli", "install-path.cmd");
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
Expand All @@ -521,13 +528,9 @@ async function validatePackagedRuntime(appDir) {
await assertPathExists(appExe, "packaged Windows app executable");
await assertPathExists(appAsarPath, "app.asar payload");
await assertPathExists(unpackedPath, "app.asar.unpacked runtime payload");
await assertPathExists(adeCliPath, "bundled ADE CLI entry");
await assertPathExists(adeCliBootstrapPath, "bundled ADE CLI bootstrap entry");
await assertPathExists(adeCliPtyHostWorkerPath, "bundled ADE CLI PTY host worker");
await assertPathExists(adeCliRpcPath, "bundled ADE CLI RPC entry");
await assertPathExists(adeCliTuiPath, "bundled ADE CLI TUI entry");
await assertPathExists(adeCliBinPath, "bundled ADE CLI wrapper");
await assertPathExists(adeCliInstallerPath, "bundled ADE CLI PATH installer");
for (const [relativePath, label] of bundledAdeCliFiles) {
await assertPathExists(path.join(resourcesPath, "ade-cli", relativePath), label);
}
Comment on lines +532 to +534

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore Windows CLI wrapper path declarations

In the Windows release validator, this refactor replaces the individual path variables with the bundled-file loop, but the live Windows smoke path below still calls runCommand(adeCliBinPath, ...) and runCommand(adeCliInstallerPath, ...). When validate:win:release runs on Windows without --skip-live-runtime, it will pass the new existence loop and then throw a ReferenceError before validating the bundled wrapper/install shim; the mac validator kept these declarations for the same later checks.

Useful? React with 👍 / 👎.

await assertBundledAgentSkills(bundledAgentSkillsRoot);
await assertPathExists(nodePtyModulePath, "unpacked node-pty module");
await assertPathExists(sqlJsModulePath, "unpacked sql.js module");
Expand Down