-
Notifications
You must be signed in to change notification settings - Fork 0
fix all other chats #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| const fs = require("node:fs"); | ||
| const path = require("node:path"); | ||
| const { | ||
| normalizeDesktopRuntimeBinaries, | ||
| resolvePackagedRuntimeRoot, | ||
| } = require("./runtimeBinaryPermissions.cjs"); | ||
|
|
||
| module.exports = async function afterPack(context) { | ||
| const productFilename = context?.packager?.appInfo?.productFilename || "ADE"; | ||
| const appBundlePath = path.join(context?.appOutDir || "", `${productFilename}.app`); | ||
| if (!appBundlePath || !fs.existsSync(appBundlePath)) { | ||
| throw new Error(`[afterPack] Missing packaged app bundle: ${String(appBundlePath)}`); | ||
| } | ||
|
|
||
| const runtimeRoot = resolvePackagedRuntimeRoot(appBundlePath); | ||
| if (!fs.existsSync(runtimeRoot)) { | ||
| throw new Error(`[afterPack] Missing unpacked runtime payload: ${runtimeRoot}`); | ||
| } | ||
|
|
||
| const normalized = normalizeDesktopRuntimeBinaries(runtimeRoot); | ||
| for (const entry of normalized) { | ||
| console.log(`[afterPack] Restored executable mode: ${entry.label} -> ${path.relative(appBundlePath, entry.filePath)}`); | ||
| } | ||
|
|
||
| const requiredScripts = [ | ||
| path.join(runtimeRoot, "dist", "main", "adeMcpProxy.cjs"), | ||
| path.join(runtimeRoot, "dist", "main", "packagedRuntimeSmoke.cjs"), | ||
| ]; | ||
|
|
||
| for (const scriptPath of requiredScripts) { | ||
| if (!fs.existsSync(scriptPath)) { | ||
| throw new Error(`[afterPack] Missing unpacked runtime entry: ${scriptPath}`); | ||
| } | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| const path = require("node:path"); | ||
| const { normalizeDesktopRuntimeBinaries } = require("./runtimeBinaryPermissions.cjs"); | ||
|
|
||
| const appDir = path.resolve(__dirname, ".."); | ||
| const normalized = normalizeDesktopRuntimeBinaries(appDir); | ||
|
|
||
| if (normalized.length === 0) { | ||
| console.log("[runtime-binaries] No executable mode fixes were needed."); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| for (const entry of normalized) { | ||
| console.log(`[runtime-binaries] Restored executable mode: ${entry.label} -> ${path.relative(appDir, entry.filePath)}`); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| const fs = require("node:fs"); | ||
| const path = require("node:path"); | ||
|
|
||
| const EXECUTABLE_MASK = 0o111; | ||
| const NODE_PTY_HELPER_PATH_PATCHES = [ | ||
| { | ||
| from: "helperPath = helperPath.replace('app.asar', 'app.asar.unpacked');", | ||
| to: "helperPath = helperPath.replace(/app\\.asar(?!\\.unpacked)/, 'app.asar.unpacked');", | ||
| }, | ||
| { | ||
| from: "helperPath = helperPath.replace('node_modules.asar', 'node_modules.asar.unpacked');", | ||
| to: "helperPath = helperPath.replace(/node_modules\\.asar(?!\\.unpacked)/, 'node_modules.asar.unpacked');", | ||
| }, | ||
| ]; | ||
|
|
||
| function pathExists(targetPath) { | ||
| try { | ||
| fs.accessSync(targetPath); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| function listDirectories(rootPath) { | ||
| if (!pathExists(rootPath)) return []; | ||
| return fs.readdirSync(rootPath, { withFileTypes: true }) | ||
| .filter((entry) => entry.isDirectory()) | ||
| .map((entry) => path.join(rootPath, entry.name)); | ||
| } | ||
|
|
||
| function ensureExecutable(filePath) { | ||
| const stat = fs.statSync(filePath); | ||
| if (!stat.isFile()) return false; | ||
| const currentMode = stat.mode & 0o777; | ||
| if ((currentMode & EXECUTABLE_MASK) === EXECUTABLE_MASK) { | ||
| return false; | ||
| } | ||
| fs.chmodSync(filePath, currentMode | EXECUTABLE_MASK); | ||
| return true; | ||
| } | ||
|
|
||
| function normalizeFileSet(filePaths, label) { | ||
| const normalized = []; | ||
| for (const filePath of filePaths) { | ||
| if (!pathExists(filePath)) continue; | ||
| if (ensureExecutable(filePath)) normalized.push(filePath); | ||
| } | ||
| return normalized.map((filePath) => ({ filePath, label })); | ||
| } | ||
|
|
||
| function collectDesktopRuntimeExecutableCandidates(rootPath) { | ||
| const candidates = []; | ||
|
|
||
| for (const buildDir of [ | ||
| path.join(rootPath, "node_modules", "node-pty", "build", "Release"), | ||
| path.join(rootPath, "node_modules", "node-pty", "build", "Debug"), | ||
| ]) { | ||
| candidates.push({ | ||
| filePath: path.join(buildDir, "spawn-helper"), | ||
| label: "node-pty spawn helper", | ||
| }); | ||
| } | ||
|
|
||
| for (const prebuildDir of listDirectories(path.join(rootPath, "node_modules", "node-pty", "prebuilds"))) { | ||
| candidates.push({ | ||
| filePath: path.join(prebuildDir, "spawn-helper"), | ||
| label: "node-pty spawn helper", | ||
| }); | ||
| } | ||
|
|
||
| for (const packageDir of listDirectories(path.join(rootPath, "node_modules", "@openai"))) { | ||
| if (!path.basename(packageDir).startsWith("codex-darwin-")) continue; | ||
| for (const vendorDir of listDirectories(path.join(packageDir, "vendor"))) { | ||
| candidates.push({ | ||
| filePath: path.join(vendorDir, "codex", "codex"), | ||
| label: "Codex CLI binary", | ||
| }); | ||
| candidates.push({ | ||
| filePath: path.join(vendorDir, "path", "rg"), | ||
| label: "Codex ripgrep helper", | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| for (const vendorDir of listDirectories(path.join(rootPath, "node_modules", "@anthropic-ai", "claude-agent-sdk", "vendor", "ripgrep"))) { | ||
| candidates.push({ | ||
| filePath: path.join(vendorDir, "rg"), | ||
| label: "Claude ripgrep helper", | ||
| }); | ||
| } | ||
|
|
||
| return candidates; | ||
| } | ||
|
|
||
| function normalizeDesktopRuntimeBinaries(rootPath) { | ||
| const normalized = []; | ||
| for (const candidate of collectDesktopRuntimeExecutableCandidates(rootPath)) { | ||
| if (!pathExists(candidate.filePath)) continue; | ||
| if (ensureExecutable(candidate.filePath)) { | ||
| normalized.push(candidate); | ||
| } | ||
| } | ||
|
|
||
| const helperPathFiles = [ | ||
| path.join(rootPath, "node_modules", "node-pty", "lib", "unixTerminal.js"), | ||
| path.join(rootPath, "node_modules", "node-pty", "src", "unixTerminal.ts"), | ||
| ]; | ||
|
|
||
| for (const filePath of helperPathFiles) { | ||
| if (!pathExists(filePath)) continue; | ||
| const original = fs.readFileSync(filePath, "utf8"); | ||
| let updated = original; | ||
| for (const patch of NODE_PTY_HELPER_PATH_PATCHES) { | ||
| updated = updated.replace(patch.from, patch.to); | ||
| } | ||
| if (updated === original) continue; | ||
| fs.writeFileSync(filePath, updated, "utf8"); | ||
| normalized.push({ | ||
| filePath, | ||
| label: "node-pty helper path patch", | ||
| }); | ||
| } | ||
|
|
||
| return normalized; | ||
| } | ||
|
|
||
| function resolvePackagedRuntimeRoot(appBundlePath) { | ||
| return path.join(appBundlePath, "Contents", "Resources", "app.asar.unpacked"); | ||
| } | ||
|
|
||
| module.exports = { | ||
| normalizeDesktopRuntimeBinaries, | ||
| resolvePackagedRuntimeRoot, | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.