codex-plus-patcher 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +198 -0
- package/README.md +121 -0
- package/package.json +33 -0
- package/src/cli.js +224 -0
- package/src/core/asar.js +90 -0
- package/src/core/patch-engine.js +219 -0
- package/src/core/plist.js +31 -0
- package/src/core/release.js +46 -0
- package/src/patches/26.616.41845-4198.js +262 -0
- package/src/patches/26.616.51431-4212.js +334 -0
- package/src/patches/index.js +8 -0
- package/src/plus/repositories.js +55 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
const childProcess = require("node:child_process");
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
|
|
5
|
+
const { patchAsar, sha256File } = require("./asar");
|
|
6
|
+
const { readPlistValue, replacePlistString, setPlistBuddyValue } = require("./plist");
|
|
7
|
+
|
|
8
|
+
const ASAR_PATH_IN_BUNDLE = "Contents/Resources/app.asar";
|
|
9
|
+
const PATCHER_REPO_URL = "https://github.com/OWNER/codex-plus-patcher";
|
|
10
|
+
|
|
11
|
+
function run(command, args) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const child = childProcess.spawn(command, args, { stdio: ["inherit", "pipe", "pipe"] });
|
|
14
|
+
const stdout = [];
|
|
15
|
+
const stderr = [];
|
|
16
|
+
child.stdout.on("data", (chunk) => stdout.push(chunk));
|
|
17
|
+
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
18
|
+
child.on("error", reject);
|
|
19
|
+
child.on("close", (code, signal) => {
|
|
20
|
+
if (code === 0) {
|
|
21
|
+
resolve();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const error = new Error(`${command} failed${signal ? ` with signal ${signal}` : ` with exit code ${code}`}`);
|
|
25
|
+
error.stdout = Buffer.concat(stdout);
|
|
26
|
+
error.stderr = Buffer.concat(stderr);
|
|
27
|
+
reject(error);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function reportProgress(progress, event) {
|
|
33
|
+
if (progress) progress(event);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function withProgress(progress, step, total, label, action) {
|
|
37
|
+
reportProgress(progress, { status: "start", step, total, label });
|
|
38
|
+
try {
|
|
39
|
+
const result = await action();
|
|
40
|
+
reportProgress(progress, { status: "succeed", step, total, label });
|
|
41
|
+
return result;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
reportProgress(progress, { status: "fail", step, total, label });
|
|
44
|
+
if (error.stdout && error.stdout.length > 0) process.stdout.write(error.stdout);
|
|
45
|
+
if (error.stderr && error.stderr.length > 0) process.stderr.write(error.stderr);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getAppIdentity(appPath) {
|
|
51
|
+
const plistPath = path.join(appPath, "Contents/Info.plist");
|
|
52
|
+
return {
|
|
53
|
+
version: readPlistValue(plistPath, "CFBundleShortVersionString"),
|
|
54
|
+
bundleVersion: readPlistValue(plistPath, "CFBundleVersion"),
|
|
55
|
+
asarSha256: sha256File(path.join(appPath, ASAR_PATH_IN_BUNDLE)),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function selectPatch(patchSets, identity) {
|
|
60
|
+
const selected = patchSets.find(
|
|
61
|
+
(patchSet) =>
|
|
62
|
+
patchSet.codexVersion === identity.version &&
|
|
63
|
+
patchSet.bundleVersion === identity.bundleVersion &&
|
|
64
|
+
patchSet.asarSha256 === identity.asarSha256,
|
|
65
|
+
);
|
|
66
|
+
if (!selected) {
|
|
67
|
+
const supported = patchSets
|
|
68
|
+
.map((patchSet) => `${patchSet.codexVersion} (${patchSet.bundleVersion}) ${patchSet.asarSha256}`)
|
|
69
|
+
.join("\n");
|
|
70
|
+
throw new Error(
|
|
71
|
+
`Unsupported Codex.app ${identity.version} (${identity.bundleVersion}) ${identity.asarSha256}\nSupported:\n${supported}`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return selected;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function collectPatchQueue(patchSet) {
|
|
78
|
+
if (Array.isArray(patchSet.patches)) return patchSet.patches;
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
id: patchSet.id,
|
|
82
|
+
infoPlistStrings: patchSet.infoPlistStrings || {},
|
|
83
|
+
fileTransforms: patchSet.fileTransforms || [],
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function collectFileTransforms(patchSet) {
|
|
89
|
+
return collectPatchQueue(patchSet).flatMap((patch) => patch.fileTransforms || []);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function collectInfoPlistStrings(patchSet) {
|
|
93
|
+
return Object.assign(
|
|
94
|
+
{},
|
|
95
|
+
patchSet.infoPlistStrings || {},
|
|
96
|
+
...collectPatchQueue(patchSet).map((patch) => patch.infoPlistStrings || {}),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function getPatcherGitSha({ cwd = path.resolve(__dirname, "../.."), execFileSync = childProcess.execFileSync } = {}) {
|
|
101
|
+
try {
|
|
102
|
+
return execFileSync("git", ["rev-parse", "--short=12", "HEAD"], {
|
|
103
|
+
cwd,
|
|
104
|
+
encoding: "utf8",
|
|
105
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
106
|
+
}).trim() || "unknown";
|
|
107
|
+
} catch {
|
|
108
|
+
return "unknown";
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function buildPatchContext(patchSet, patchQueue, operations = {}) {
|
|
113
|
+
const readPatcherGitSha = operations.getPatcherGitSha || (() => getPatcherGitSha());
|
|
114
|
+
return {
|
|
115
|
+
patcherRepoUrl: PATCHER_REPO_URL,
|
|
116
|
+
patcherGitSha: readPatcherGitSha(),
|
|
117
|
+
patchSetId: patchSet.id,
|
|
118
|
+
codexVersion: patchSet.codexVersion,
|
|
119
|
+
bundleVersion: patchSet.bundleVersion,
|
|
120
|
+
sourceAsarSha256: patchSet.asarSha256,
|
|
121
|
+
appliedPatches: patchQueue.map((patch) => patch.id),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function applyPatchSet({
|
|
126
|
+
sourceApp,
|
|
127
|
+
targetApp,
|
|
128
|
+
patchSet,
|
|
129
|
+
dryRun = false,
|
|
130
|
+
progress,
|
|
131
|
+
progressOffset = 0,
|
|
132
|
+
progressTotal = 6,
|
|
133
|
+
operations = {},
|
|
134
|
+
}) {
|
|
135
|
+
const fsImpl = operations.fs || fs;
|
|
136
|
+
const runCommand = operations.run || run;
|
|
137
|
+
const patchAsarFile = operations.patchAsar || patchAsar;
|
|
138
|
+
const replacePlistStringValue = operations.replacePlistString || replacePlistString;
|
|
139
|
+
const setPlistBuddyStringValue = operations.setPlistBuddyValue || setPlistBuddyValue;
|
|
140
|
+
const patchQueue = collectPatchQueue(patchSet);
|
|
141
|
+
const fileTransforms = collectFileTransforms(patchSet);
|
|
142
|
+
if (dryRun) {
|
|
143
|
+
return {
|
|
144
|
+
sourceApp,
|
|
145
|
+
targetApp,
|
|
146
|
+
patchSet: patchSet.id,
|
|
147
|
+
patches: patchQueue.map((patch) => patch.id),
|
|
148
|
+
patchedFiles: fileTransforms.map(([filePath]) => filePath),
|
|
149
|
+
dryRun: true,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
await withProgress(progress, progressOffset + 1, progressTotal, "Prepare target app", () => {
|
|
154
|
+
fsImpl.rmSync(targetApp, { recursive: true, force: true });
|
|
155
|
+
fsImpl.mkdirSync(path.dirname(targetApp), { recursive: true });
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
await withProgress(progress, progressOffset + 2, progressTotal, "Copy app bundle", () =>
|
|
159
|
+
runCommand("/usr/bin/ditto", [sourceApp, targetApp]),
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const targetAsar = path.join(targetApp, ASAR_PATH_IN_BUNDLE);
|
|
163
|
+
const patchContext = buildPatchContext(patchSet, patchQueue, operations);
|
|
164
|
+
const patchedAsarSha = await withProgress(progress, progressOffset + 3, progressTotal, "Patch app.asar", () =>
|
|
165
|
+
patchAsarFile(targetAsar, fileTransforms, patchContext),
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
const plistPath = path.join(targetApp, "Contents/Info.plist");
|
|
169
|
+
await withProgress(progress, progressOffset + 4, progressTotal, "Update bundle metadata", () => {
|
|
170
|
+
for (const [keyPath, value] of Object.entries(collectInfoPlistStrings(patchSet))) {
|
|
171
|
+
replacePlistStringValue(plistPath, keyPath, value);
|
|
172
|
+
}
|
|
173
|
+
setPlistBuddyStringValue(plistPath, ":ElectronAsarIntegrity:Resources/app.asar:hash", patchedAsarSha);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
await withProgress(progress, progressOffset + 5, progressTotal, "Sign copied app", () =>
|
|
177
|
+
runCommand("/usr/bin/codesign", ["--force", "--deep", "--sign", "-", targetApp]),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
await withProgress(progress, progressOffset + 6, progressTotal, "Finish", () => {});
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
sourceApp,
|
|
184
|
+
targetApp,
|
|
185
|
+
patchSet: patchSet.id,
|
|
186
|
+
patches: patchQueue.map((patch) => patch.id),
|
|
187
|
+
patchedFiles: fileTransforms.map(([filePath]) => filePath),
|
|
188
|
+
patchedAsarSha,
|
|
189
|
+
dryRun: false,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async function patchCodexApp({ sourceApp, targetApp, patchSets, dryRun = false, progress, operations }) {
|
|
194
|
+
const applyProgress = dryRun ? undefined : progress;
|
|
195
|
+
const identity = await withProgress(applyProgress, 1, 8, "Inspect source app", () => getAppIdentity(sourceApp));
|
|
196
|
+
const patchSet = await withProgress(applyProgress, 2, 8, "Select patch set", () => selectPatch(patchSets, identity));
|
|
197
|
+
return applyPatchSet({
|
|
198
|
+
sourceApp,
|
|
199
|
+
targetApp,
|
|
200
|
+
patchSet,
|
|
201
|
+
dryRun,
|
|
202
|
+
progress: applyProgress,
|
|
203
|
+
progressOffset: 2,
|
|
204
|
+
progressTotal: 8,
|
|
205
|
+
operations,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
module.exports = {
|
|
210
|
+
ASAR_PATH_IN_BUNDLE,
|
|
211
|
+
applyPatchSet,
|
|
212
|
+
collectFileTransforms,
|
|
213
|
+
collectInfoPlistStrings,
|
|
214
|
+
collectPatchQueue,
|
|
215
|
+
getPatcherGitSha,
|
|
216
|
+
getAppIdentity,
|
|
217
|
+
patchCodexApp,
|
|
218
|
+
selectPatch,
|
|
219
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const childProcess = require("node:child_process");
|
|
2
|
+
|
|
3
|
+
function execFile(command, args, options = {}) {
|
|
4
|
+
return childProcess.execFileSync(command, args, {
|
|
5
|
+
encoding: "utf8",
|
|
6
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
7
|
+
...options,
|
|
8
|
+
}).trim();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function readPlistValue(plistPath, keyPath) {
|
|
12
|
+
return execFile("/usr/bin/plutil", ["-extract", keyPath, "raw", plistPath]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function replacePlistString(plistPath, keyPath, value) {
|
|
16
|
+
childProcess.execFileSync("/usr/bin/plutil", ["-replace", keyPath, "-string", value, plistPath], {
|
|
17
|
+
stdio: "inherit",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function setPlistBuddyValue(plistPath, keyPath, value) {
|
|
22
|
+
childProcess.execFileSync("/usr/libexec/PlistBuddy", ["-c", `Set ${keyPath} ${value}`, plistPath], {
|
|
23
|
+
stdio: "inherit",
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
readPlistValue,
|
|
29
|
+
replacePlistString,
|
|
30
|
+
setPlistBuddyValue,
|
|
31
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const childProcess = require("node:child_process");
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const os = require("node:os");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
|
|
6
|
+
async function downloadFile(url, destination) {
|
|
7
|
+
const response = await fetch(url, {
|
|
8
|
+
headers: { "user-agent": "codex-plus-patcher" },
|
|
9
|
+
});
|
|
10
|
+
if (!response.ok) throw new Error(`Failed to download ${url}: HTTP ${response.status}`);
|
|
11
|
+
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
|
12
|
+
fs.writeFileSync(destination, Buffer.from(await response.arrayBuffer()));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function getGitHubReleaseAssetUrl({ repo, tag = "latest", assetName }) {
|
|
16
|
+
const releaseUrl =
|
|
17
|
+
tag === "latest"
|
|
18
|
+
? `https://api.github.com/repos/${repo}/releases/latest`
|
|
19
|
+
: `https://api.github.com/repos/${repo}/releases/tags/${encodeURIComponent(tag)}`;
|
|
20
|
+
const response = await fetch(releaseUrl, {
|
|
21
|
+
headers: { "user-agent": "codex-plus-patcher" },
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) throw new Error(`Failed to fetch ${releaseUrl}: HTTP ${response.status}`);
|
|
24
|
+
const release = await response.json();
|
|
25
|
+
const asset = release.assets?.find((asset) => asset.name === assetName);
|
|
26
|
+
if (!asset) throw new Error(`Release ${repo}@${tag} does not contain asset ${assetName}`);
|
|
27
|
+
return asset.browser_download_url;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function resolveReleasePatchDirectory({ repo, tag = "latest", assetName, cacheDir }) {
|
|
31
|
+
const root = cacheDir || path.join(os.homedir(), ".cache", "codex-plus-patcher");
|
|
32
|
+
const archive = path.join(root, `${repo.replaceAll("/", "-")}-${tag}-${assetName}`);
|
|
33
|
+
const extracted = path.join(root, `${repo.replaceAll("/", "-")}-${tag}`);
|
|
34
|
+
const url = await getGitHubReleaseAssetUrl({ repo, tag, assetName });
|
|
35
|
+
await downloadFile(url, archive);
|
|
36
|
+
fs.rmSync(extracted, { recursive: true, force: true });
|
|
37
|
+
fs.mkdirSync(extracted, { recursive: true });
|
|
38
|
+
childProcess.execFileSync("/usr/bin/tar", ["-xzf", archive, "-C", extracted], { stdio: "inherit" });
|
|
39
|
+
return extracted;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
downloadFile,
|
|
44
|
+
getGitHubReleaseAssetUrl,
|
|
45
|
+
resolveReleasePatchDirectory,
|
|
46
|
+
};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
const { parsePlusToml, unquoteTomlValue } = require("../plus/repositories");
|
|
2
|
+
|
|
3
|
+
const oldTitle = "<title>Codex</title>";
|
|
4
|
+
const newTitle = "<title>Codex Plus</title>";
|
|
5
|
+
const titleFile = "webview/index.html";
|
|
6
|
+
const workerFile = ".vite/build/worker.js";
|
|
7
|
+
const appShellFile = "webview/assets/app-shell-DCvuE1cb.js";
|
|
8
|
+
const generalSettingsFile = "webview/assets/general-settings-Bit-KX17.js";
|
|
9
|
+
const threadSidePanelTabsFile = "webview/assets/thread-side-panel-tabs-D0dd27Zf.js";
|
|
10
|
+
const userMessageAttachmentsFile = "webview/assets/user-message-attachments-CgyXEK9U.js";
|
|
11
|
+
const composerFile = "webview/assets/composer-CCuv6v-2.js";
|
|
12
|
+
|
|
13
|
+
function replaceOnce(text, oldText, newText, label) {
|
|
14
|
+
const matches = text.split(oldText).length - 1;
|
|
15
|
+
if (matches !== 1) throw new Error(`Expected one ${label}, found ${matches}`);
|
|
16
|
+
return text.replace(oldText, newText);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function functionSource(fn, newName, replacements = []) {
|
|
20
|
+
let source = fn.toString().replace(new RegExp(`function ${fn.name}`), `function ${newName}`);
|
|
21
|
+
for (const [from, to] of replacements) source = source.replaceAll(from, to);
|
|
22
|
+
return source;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function codexPlusWorkerHelpers() {
|
|
26
|
+
const unquoteSource = functionSource(unquoteTomlValue, "CPX_unquote");
|
|
27
|
+
const parseSource = functionSource(parsePlusToml, "CPX_parsePlusToml", [
|
|
28
|
+
["unquoteTomlValue", "CPX_unquote"],
|
|
29
|
+
]);
|
|
30
|
+
return `
|
|
31
|
+
function CPX_error(e){return{name:e?.name??null,code:e?.code??null,message:e?.message??String(e)}}function CPX_trace(e,t){try{let n=require(\`node:fs\`),r={ts:new Date().toISOString(),event:e,data:t??null};n.appendFileSync(\`/tmp/codex-plus-trace.log\`,\`\${JSON.stringify(r)}\\n\`)}catch{}}function CPX_traceRequest(e){return CPX_trace(e?.event??\`trace\`,e?.data??null),{ok:!0}}${unquoteSource}${parseSource}async function CPX_readPlusToml(e,t){let n=await t.platformPath(),r=n.join(e,\`.codex\`,\`plus.toml\`),i={path:r,attempted:!0,readOk:!1,bytes:0,preview:null,error:null};CPX_trace(\`plus-toml:read-start\`,{path:r});try{let e=await new Response(await t.readFile(r)).text();return i.readOk=!0,i.bytes=e.length,i.preview=e.slice(0,300),CPX_trace(\`plus-toml:read-ok\`,{path:r,bytes:i.bytes,preview:i.preview}),{text:e,debug:i}}catch(e){return i.error=CPX_error(e),CPX_trace(\`plus-toml:read-error\`,{path:r,error:i.error}),{text:null,debug:i}}}async function CPX_repositoryTargets(e,t,n,r){CPX_trace(\`repository-targets:start\`,{cwd:t?.cwd,hostId:t?.hostId});let i=[],a=await e.getStableMetadata(t.cwd,n);if(a==null){let e={main:null,repositories:[],warnings:[{type:\`main-not-git\`,path:t.cwd,message:\`Current directory is not inside a git repository.\`}],debug:{requestCwd:t.cwd,projectRoot:null}};return CPX_trace(\`repository-targets:main-not-git\`,e),e}let o={id:\`main:\${a.root}\`,kind:\`main\`,path:\`.\`,label:\`Main\`,cwd:a.root,root:a.root,commonDir:a.commonDir,valid:!0},s=await n.platformPath(),c=(await pae(e.getWorktreeRepositoryForRoot(a.root,n),r)).map(e=>({kind:\`submodule\`,path:e,label:e.split(\`/\`).filter(Boolean).pop()||e})),l=await CPX_readPlusToml(a.root,n),u=CPX_parsePlusToml(l.text),d=u.repositories.map(e=>({kind:\`configured\`,...e})),f={requestCwd:t.cwd,projectRoot:a.root,plusToml:{...l.debug,parsedRepositories:u.repositories.length,tableCount:u.tableCount,ignoredLines:u.ignoredLines.slice(0,12)},submoduleCandidates:c.map(e=>({path:e.path,label:e.label})),configuredCandidates:d.map(e=>({path:e.path,label:e.label??null})),accepted:[],skipped:[]},p=new Set,m=[];CPX_trace(\`repository-targets:parsed\`,{projectRoot:a.root,plusToml:f.plusToml,submoduleCandidates:f.submoduleCandidates,configuredCandidates:f.configuredCandidates});function h(e){i.push(e),f.skipped.push(e),CPX_trace(\`repository-targets:skip\`,e)}async function g(t){let r=t.path.trim();if(r.length===0){h({kind:t.kind,type:\`empty-path\`,path:r,message:\`Skipped empty repository path.\`});return}if(s.isAbsolute(r)||r===\`..\`||r.startsWith(\`../\`)||r.startsWith(\`..\\\\\`)){h({kind:t.kind,type:\`out-of-root\`,path:r,message:\`Skipped repository outside project root.\`});return}let c=s.normalize(s.join(a.root,r)),l=s.relative(a.root,c);if(l===\`\`||l===\`..\`||l.startsWith(\`..\${s.sep}\`)||s.isAbsolute(l)){h({kind:t.kind,type:\`out-of-root\`,path:r,resolved:c,relative:l,message:\`Skipped repository outside project root.\`});return}let u=b3(l),d=\`\${t.kind}:\${u}\`;if(p.has(u)){h({kind:t.kind,type:\`duplicate\`,path:u,message:\`Skipped duplicate repository path.\`});return}p.add(u);let g;try{g=await e.getStableMetadata(c,n)}catch(e){g=null,h({kind:t.kind,type:\`metadata-error\`,path:u,resolved:c,error:CPX_error(e),message:\`Failed to inspect repository metadata.\`});return}if(g==null){t.kind===\`configured\`&&h({kind:t.kind,type:\`non-git\`,path:u,resolved:c,message:\`Configured repository is not a git repository.\`});return}let _={id:d,kind:t.kind,path:u,label:t.label??u,cwd:c,root:g.root,commonDir:g.commonDir,valid:!0};m.push(_),f.accepted.push({kind:t.kind,path:u,cwd:c,root:g.root}),CPX_trace(\`repository-targets:accept\`,{kind:t.kind,path:u,cwd:c,root:g.root})}for(let e of c)await g(e);for(let e of d)await g(e);let _={main:o,repositories:m,warnings:i,debug:f};return CPX_trace(\`repository-targets:done\`,{repositoryCount:m.length,warningCount:i.length,accepted:f.accepted,skipped:f.skipped}),_}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function patchTitle(text) {
|
|
35
|
+
return replaceOnce(text, oldTitle, newTitle, `${oldTitle} in ${titleFile}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function patchWorker(text) {
|
|
39
|
+
let patched = replaceOnce(
|
|
40
|
+
text,
|
|
41
|
+
"function pae(e,t){return e.queryClient.fetchQuery",
|
|
42
|
+
`${codexPlusWorkerHelpers()}function pae(e,t){return e.queryClient.fetchQuery`,
|
|
43
|
+
"worker helper insertion anchor",
|
|
44
|
+
);
|
|
45
|
+
patched = replaceOnce(
|
|
46
|
+
patched,
|
|
47
|
+
"case`submodule-paths`:a=X({paths:await pae(this.gitManager.getWorktreeRepositoryForRoot(e.params.root,r),t.signal)});break;",
|
|
48
|
+
"case`codex-plus-trace`:a=X(CPX_traceRequest(e.params));break;case`repository-targets`:a=X(await CPX_repositoryTargets(this.gitManager,e.params,r,t.signal));break;case`submodule-paths`:a=X({paths:await pae(this.gitManager.getWorktreeRepositoryForRoot(e.params.root,r),t.signal)});break;",
|
|
49
|
+
"repository-targets worker switch anchor",
|
|
50
|
+
);
|
|
51
|
+
patched = replaceOnce(
|
|
52
|
+
patched,
|
|
53
|
+
"function u2({requestKind:e,source:t}){return l2.has(e??``)||d2(t)}",
|
|
54
|
+
"function CPX_isReadOnlyBranchRequest(e,t){return t===`codex_plus_review`&&(e===`recent-branches`||e===`search-branches`)}function u2({requestKind:e,source:t}){return l2.has(e??``)||d2(t)||CPX_isReadOnlyBranchRequest(e,t)}",
|
|
55
|
+
"codex plus branch picker git allowlist anchor",
|
|
56
|
+
);
|
|
57
|
+
return replaceOnce(
|
|
58
|
+
patched,
|
|
59
|
+
"case`commit-message-diff`:case`submodule-paths`:case`cat-file`:",
|
|
60
|
+
"case`commit-message-diff`:case`codex-plus-trace`:case`repository-targets`:case`submodule-paths`:case`cat-file`:",
|
|
61
|
+
"repository-targets worker readonly method anchor",
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const codexPlusReviewHelpers = `
|
|
66
|
+
function CPX_repoKey(e){return e?.id??e?.cwd??e?.path??\`unknown\`}function CPX_label(e){return e?.kind===\`main\`?\`Main\`:e?.label??e?.path??\`Repository\`}function CPX_sessionKey(e,t,n){return JSON.stringify([e,t,n])}function CPXWarnings({warnings:e}){return!e||e.length===0?null:(0,$.jsx)(\`div\`,{className:\`px-3 py-2 text-xs text-token-description-foreground\`,children:e.map((e,t)=>(0,$.jsx)(\`div\`,{children:e.message??e.type??String(e)},\`\${e.type??\`warning\`}:\${e.path??t}\`))})}function CPXDebugText(e){try{return JSON.stringify(e,(e,t)=>typeof t===\`bigint\`?String(t):t,2)??\`\`}catch(t){return\`Unable to render debug object: \${t instanceof Error?t.message:String(t)}\`}}function CPXDebug({debug:e}){if(e==null)return null;let t=e.plusToml??{},n=t.readOk===!0?\`read ok\`:\`not read\`,r=String(t.parsedRepositories??0),i=CPXDebugText(e);return(0,$.jsxs)(\`details\`,{className:\`mx-3 mb-2 rounded-md border border-token-border bg-token-main-surface-secondary px-2 py-1 text-xs text-token-description-foreground\`,children:[(0,$.jsxs)(\`summary\`,{className:\`cursor-pointer select-none\`,children:[\`plus.toml debug: \`,n,\`, parsed \`,r]}),(0,$.jsx)(\`pre\`,{className:\`mt-2 max-h-72 overflow-auto whitespace-pre-wrap font-vscode-editor text-[11px] leading-4 text-token-foreground\`,children:i})]})}function CPXMainGroup({children:e,repo:t,collapsed:n,onToggle:r}){return(0,$.jsxs)(\`section\`,{className:\`border-b border-token-border-default\`,children:[(0,$.jsxs)(\`button\`,{type:\`button\`,className:\`flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-sm text-token-foreground hover:bg-token-list-hover-background\`,onClick:r,"aria-expanded":!n,children:[(0,$.jsxs)(\`span\`,{className:\`min-w-0\`,children:[(0,$.jsx)(\`span\`,{className:\`font-medium\`,children:CPX_label(t)}),(0,$.jsx)(\`span\`,{className:\`ml-2 text-xs text-token-description-foreground\`,children:t?.path??\`.\`})]}),(0,$.jsx)(\`span\`,{className:\`shrink-0 text-xs text-token-description-foreground\`,children:n?\`Show\`:\`Hide\`})]}),n?null:e]})}function CPXBranchPicker({repo:e,hostConfig:t,baseBranch:n,setBaseBranch:r}){let[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),[f,m]=(0,Q.useState)(\`\`),[h,g]=(0,Q.useState)([]),[_,v]=(0,Q.useState)(!1),[A0,b]=(0,Q.useState)(null),x=(n??\`\`).trim(),S=()=>{let n=new AbortController;l(!0),d(null),y(\`git\`).request({method:\`recent-branches\`,params:{root:e.root,limit:100,hostConfig:t,operationSource:\`codex_plus_review\`},signal:n.signal}).then(e=>{s(e?.branches??[])}).catch(e=>{n.signal.aborted||d(e instanceof Error?e.message:String(e))}).finally(()=>{n.signal.aborted||l(!1)});return n};(0,Q.useEffect)(()=>{if(!i)return;let e=S();return()=>e.abort()},[i,e.root,t.id]);(0,Q.useEffect)(()=>{if(!i)return;let n=f.trim();if(n.length===0){g([]),b(null),v(!1);return}let r=new AbortController,A=setTimeout(()=>{v(!0),b(null),y(\`git\`).request({method:\`search-branches\`,params:{root:e.root,query:n,limit:50,hostConfig:t,operationSource:\`codex_plus_review\`},signal:r.signal}).then(e=>{g(e?.branches??[])}).catch(e=>{r.signal.aborted||b(e instanceof Error?e.message:String(e))}).finally(()=>{r.signal.aborted||v(!1)})},250);return()=>{clearTimeout(A),r.abort()}},[i,f,e.root,t.id]);let C=x.length>0?x:\`Unstaged\`,w=x.length>0?null:\`Working tree changes\`,T=(0,$.jsxs)(Y,{type:\`button\`,color:x.length>0?\`ghostActive\`:\`ghost\`,size:\`toolbar\`,className:\`max-w-44 min-w-0 shrink-0 border-token-border px-1.5\`,children:[(0,$.jsx)(\`span\`,{className:\`min-w-0 truncate\`,children:C}),(0,$.jsx)(Je,{className:\`icon-2xs text-token-input-placeholder-foreground\`})]}),E=(0,$.jsx)(Ae,{tooltipContent:w??\`Base branch: \${C}\`,children:T}),D=(0,$.jsx)(CPXBranchPickerDropdownContent,{branches:o,selectedBranch:x,disabled:!1,isError:u!=null,isLoading:c,isSearchError:A0!=null,isSearchLoading:_,onClose:()=>a(!1),onRetry:S,onRetrySearch:()=>m(f),onSearchQueryChange:m,onSelectBranch:e=>{r(e),a(!1)},searchedBranches:h,searchQuery:f}),O=x.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vi.Separator,{}),(0,$.jsx)(vi.Item,{onSelect:()=>{r(\`\`),a(!1)},children:\`Show unstaged changes\`})]}):null;return(0,$.jsx)(yi,{align:\`end\`,contentWidth:\`menu\`,open:i,onOpenChange:a,triggerButton:E,children:(0,$.jsxs)($.Fragment,{children:[D,O]})})}function CPXRepoPatchGroup({repo:e,hostConfig:t,hostId:n,conversationId:r,baseBranch:i,setBaseBranch:a,collapsed:o,setCollapsed:s}){let[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let r=!1,A=new AbortController;l(null),m(null),d(!0),y(\`git\`).request({method:\`current-branch\`,params:{root:e.root,hostConfig:t,operationSource:\`codex_plus_review\`},signal:A.signal}).then(e=>{r||g(e?.branch??null)}).catch(e=>{r||g(null)});let C=(i??\`\`).trim(),D=C.length>0?\`branch\`:\`unstaged\`;y(\`git\`).request({method:\`review-patch\`,params:{cwd:B(e.cwd),source:D,operationSource:\`codex_plus_review\`,hostConfig:t,...C.length>0?{baseBranch:C}:{}},signal:A.signal}).then(e=>{if(r)return;let t=e?.diff?.type===\`success\`?(e.diff.unifiedDiff??e.diff.diff??\`\`):\`\`;l(t.trim().length>0?t:null)}).catch(e=>{r||m(e instanceof Error?e.message:String(e))}).finally(()=>{r||d(!1)});return()=>{r=!0,A.abort()}},[e.cwd,e.root,t.id,i]);let _=CPX_label(e),v=e.path??\`\`,A0=(i??\`\`).trim(),b=f??(u?\`Loading diff...\`:c==null?\`No changes\`:c);return(0,$.jsxs)(\`section\`,{className:\`border-b border-token-border-default\`,children:[(0,$.jsxs)(\`div\`,{className:\`flex min-w-0 items-center gap-2 px-3 py-2\`,children:[(0,$.jsxs)(\`button\`,{type:\`button\`,className:\`min-w-0 flex-1 text-left hover:bg-token-list-hover-background\`,onClick:()=>s(!o),"aria-expanded":!o,children:[(0,$.jsx)(\`div\`,{className:\`truncate text-sm font-medium text-token-foreground\`,children:_}),(0,$.jsx)(\`div\`,{className:\`truncate text-xs text-token-description-foreground\`,children:[e.kind,v,h?\` - \${h}\`:\`\`].filter(Boolean).join(\` / \`)})]}),(0,$.jsx)(CPXBranchPicker,{repo:e,hostConfig:t,baseBranch:i,setBaseBranch:a}),(0,$.jsx)(dp,{conversationId:r,cwd:e.cwd,hostId:n,codexWorktree:!1,surface:\`review-toolbar\`,reviewToolbarCompact:!0},e.id)]}),o?null:(0,$.jsx)(\`pre\`,{className:\`mx-3 mb-3 max-h-[520px] overflow-auto whitespace-pre-wrap rounded-md border border-token-border bg-token-main-surface-secondary p-3 font-vscode-editor text-xs leading-5 text-token-foreground\`,children:b})]})}function CPXReviewMux(e){let t=s(ft),n=l(Or),r=l(Dr),i=l(kr),a=l(jr),o=t.value.routeKind===\`local-thread\`?t.value.conversationId:null,[c,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(()=>new Map),[m,h]=(0,Q.useState)(()=>new Map),p=e.mainReviewContent,g=(0,Q.useMemo)(()=>p??(0,$.jsx)(of,e),[p,e.diffRefs,e.diffMode,e.isCappedMode,e.reviewDiffMetrics,e.showReviewGitActions]);(0,Q.useEffect)(()=>{if(n==null||i==null){u(null);return}let e=!1,t=new AbortController;y(\`git\`).request({method:\`repository-targets\`,params:{cwd:B(n),hostId:r,hostConfig:i,operationSource:\`codex_plus_review\`},signal:t.signal}).then(t=>{e||u(t)}).catch(t=>{u({main:null,repositories:[],warnings:[{type:\`load-error\`,message:t instanceof Error?t.message:String(t)}]})});return()=>{e=!0,t.abort()}},[n,r,i?.id]);let _=c?.main??(n==null?null:{id:\`main:\${n}\`,kind:\`main\`,path:\`.\`,label:\`Main\`,cwd:n}),v=_,A0=c?.repositories??[],b=[v,...A0].filter(Boolean);if(_==null||b.length<=1&&(!c?.warnings||c.warnings.length===0)&&c?.debug==null)return g;let x=CPX_sessionKey(r,o,n),S=e=>\`\${x}:\${CPX_repoKey(e)}\`,C=e=>d.get(S(e))===!0,w=(e,t)=>f(n=>{let r=new Map(n);return t?r.set(S(e),!0):r.delete(S(e)),r}),T=(e,t)=>h(n=>{let r=new Map(n);return r.set(S(e),t),r});return(0,$.jsxs)(\`div\`,{className:\`flex flex-col\`,children:[(0,$.jsx)(\`div\`,{className:\`px-3 py-1 text-[11px] font-medium uppercase tracking-wide text-token-description-foreground\`,children:\`Codex Plus repositories\`}),(0,$.jsx)(CPXWarnings,{warnings:c?.warnings??[]}),(0,$.jsx)(CPXDebug,{debug:c?.debug}),_?(0,$.jsx)(CPXMainGroup,{repo:_,collapsed:C(_),onToggle:()=>w(_,!C(_)),children:g},CPX_repoKey(_)):g,A0.map(e=>(0,$.jsx)(CPXRepoPatchGroup,{repo:e,hostConfig:i,hostId:r,conversationId:o,baseBranch:m.get(S(e))??\`\`,setBaseBranch:t=>T(e,t),collapsed:C(e),setCollapsed:t=>w(e,t)},CPX_repoKey(e)))]})}`;
|
|
67
|
+
|
|
68
|
+
const codexPlusSubrepoDiffHelpers = `
|
|
69
|
+
function CPXPlainDiff({text:e}){return(0,$.jsx)(\`pre\`,{className:\`mx-3 mb-3 max-h-[520px] overflow-auto whitespace-pre-wrap rounded-md border border-token-border bg-token-main-surface-secondary p-3 font-vscode-editor text-xs leading-5 text-token-foreground\`,children:e})}function CPXRepoDiffBody({cwd:e,hostConfig:t,conversationId:n,diffMode:r,diffText:i,statusText:a,error:o,isLoading:s}){if(o!=null||s||i==null)return(0,$.jsx)(CPXPlainDiff,{text:a});let c;try{c=xr(i)}catch(e){let t=e instanceof Error?e.message:String(e);return(0,$.jsx)(CPXPlainDiff,{text:\`Unable to parse diff: \${t}\\n\\n\${i}\`})}return c==null||c.length===0?(0,$.jsx)(CPXPlainDiff,{text:a}):(0,$.jsx)(\`div\`,{className:\`mx-3 mb-3 flex flex-col gap-2\`,children:c.map((a,o)=>(0,Q.createElement)(Ma,{key:\`\${a.metadata?.newPath??a.metadata?.oldPath??o}:\${o}\`,containerClassName:\`codex-review-diff-card extension:rounded-lg\`,conversationId:n??void 0,cwd:B(e),defaultOpen:!0,diff:a,diffViewWrap:!0,expandScope:\`review\`,fullContentNextFallbackToDisk:!0,headerVariant:\`full-review\`,hostConfig:t,hunkActionsVariant:\`unstaged\`,hunkSeparators:a.metadata?.additionLines?\`line-info\`:\`metadata\`,roundedCorners:!1,showFileActions:!1,showHunkActions:!1,stickyHeader:!1,viewType:r??\`unified\`}))})}`;
|
|
70
|
+
|
|
71
|
+
function patchThreadSidePanelTabs(text) {
|
|
72
|
+
let patched = replaceOnce(
|
|
73
|
+
text,
|
|
74
|
+
"import{r as vi,t as yi}from\"./dropdown-CTBRoADH.js\";",
|
|
75
|
+
"import{r as vi,t as yi}from\"./dropdown-CTBRoADH.js\";import{t as CPXBranchPickerDropdownContent}from\"./git-branch-picker-dropdown-content-Ch_voM6R.js\";",
|
|
76
|
+
"branch picker content import anchor",
|
|
77
|
+
);
|
|
78
|
+
patched = replaceOnce(
|
|
79
|
+
patched,
|
|
80
|
+
"function uf({cwd:e,fileEntries:t,generatedPathsReady:n,hasUnhandledAttributesFiles:r,isCappedMode:i,repositorySource:a,reviewSummarySource:o}){",
|
|
81
|
+
`${codexPlusSubrepoDiffHelpers}${codexPlusReviewHelpers}function uf({cwd:e,fileEntries:t,generatedPathsReady:n,hasUnhandledAttributesFiles:r,isCappedMode:i,repositorySource:a,reviewSummarySource:o}){`,
|
|
82
|
+
"review helpers insertion anchor",
|
|
83
|
+
);
|
|
84
|
+
patched = replaceOnce(
|
|
85
|
+
patched,
|
|
86
|
+
"function CPXRepoPatchGroup({repo:e,hostConfig:t,hostId:n,conversationId:r,baseBranch:i,setBaseBranch:a,collapsed:o,setCollapsed:s}){",
|
|
87
|
+
"function CPXRepoPatchGroup({repo:e,hostConfig:t,hostId:n,conversationId:r,diffMode:A1,baseBranch:i,setBaseBranch:a,collapsed:o,setCollapsed:s}){",
|
|
88
|
+
"subrepo diff mode prop anchor",
|
|
89
|
+
);
|
|
90
|
+
patched = replaceOnce(
|
|
91
|
+
patched,
|
|
92
|
+
"o?null:(0,$.jsx)(`pre`,{className:`mx-3 mb-3 max-h-[520px] overflow-auto whitespace-pre-wrap rounded-md border border-token-border bg-token-main-surface-secondary p-3 font-vscode-editor text-xs leading-5 text-token-foreground`,children:b})",
|
|
93
|
+
"o?null:(0,$.jsx)(CPXRepoDiffBody,{cwd:e.cwd,hostConfig:t,conversationId:r,diffMode:A1,diffText:c,statusText:b,error:f,isLoading:u})",
|
|
94
|
+
"subrepo highlighted diff body anchor",
|
|
95
|
+
);
|
|
96
|
+
patched = replaceOnce(
|
|
97
|
+
patched,
|
|
98
|
+
"CPXRepoPatchGroup,{repo:e,hostConfig:i,hostId:r,conversationId:o,baseBranch:m.get(S(e))??``",
|
|
99
|
+
"CPXRepoPatchGroup,{repo:e,hostConfig:i,hostId:r,conversationId:o,diffMode:a,baseBranch:m.get(S(e))??``",
|
|
100
|
+
"subrepo diff mode caller anchor",
|
|
101
|
+
);
|
|
102
|
+
patched = replaceOnce(
|
|
103
|
+
patched,
|
|
104
|
+
"className:`mx-3 mb-3 flex flex-col gap-2`",
|
|
105
|
+
"className:`mx-3 mb-3 flex min-w-0 max-w-none flex-col gap-2`",
|
|
106
|
+
"subrepo diff body width anchor",
|
|
107
|
+
);
|
|
108
|
+
patched = replaceOnce(
|
|
109
|
+
patched,
|
|
110
|
+
"children:c.map((a,o)=>(0,Q.createElement)(Ma,{key:`${a.metadata?.newPath??a.metadata?.oldPath??o}:${o}`,containerClassName:`codex-review-diff-card extension:rounded-lg`",
|
|
111
|
+
"children:c.map((a,o)=>(0,Q.createElement)(Ma,{key:`${a.metadata?.newPath??a.metadata?.oldPath??o}:${o}`,containerClassName:`codex-review-diff-card extension:rounded-lg w-full max-w-none`",
|
|
112
|
+
"subrepo diff card width anchor",
|
|
113
|
+
);
|
|
114
|
+
patched = replaceOnce(
|
|
115
|
+
patched,
|
|
116
|
+
"return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`div`,{className:`px-3 py-1 text-[11px] font-medium uppercase tracking-wide text-token-description-foreground`,children:`Codex Plus repositories`})",
|
|
117
|
+
"return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto`,children:[(0,$.jsx)(`div`,{className:`px-3 py-1 text-[11px] font-medium uppercase tracking-wide text-token-description-foreground`,children:`Codex Plus repositories`})",
|
|
118
|
+
"review mux scroll container anchor",
|
|
119
|
+
);
|
|
120
|
+
return replaceOnce(
|
|
121
|
+
patched,
|
|
122
|
+
"let s;t[1]!==a||t[2]!==r||t[3]!==i?(s=(0,$.jsx)(Tf,{diffMode:a,setTabState:r,tabState:i}),t[1]=a,t[2]=r,t[3]=i,t[4]=s):s=t[4];let c;",
|
|
123
|
+
"let s;t[1]!==a||t[2]!==r||t[3]!==i?(s=(0,$.jsx)(CPXReviewMux,{mainReviewContent:(0,$.jsx)(Tf,{diffMode:a,setTabState:r,tabState:i})}),t[1]=a,t[2]=r,t[3]=i,t[4]=s):s=t[4];let c;",
|
|
124
|
+
"review body mux anchor",
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function patchAppShell(text) {
|
|
129
|
+
let patched = replaceOnce(
|
|
130
|
+
text,
|
|
131
|
+
"function En(e){return(0,Q.jsx)(wn,{onRetry:()=>{e.resetError()}})}",
|
|
132
|
+
"function En(e){return(0,Q.jsx)(wn,{error:e.error,onRetry:()=>{e.resetError()}})}",
|
|
133
|
+
"app shell error fallback prop anchor",
|
|
134
|
+
);
|
|
135
|
+
patched = replaceOnce(
|
|
136
|
+
patched,
|
|
137
|
+
"children:[r,(0,Q.jsx)(Le,{color:`secondary`,size:`default`,onClick:n,children:i})]",
|
|
138
|
+
"children:[r,(0,Q.jsx)(`pre`,{className:`max-h-80 max-w-full overflow-auto whitespace-pre-wrap rounded-md border border-token-border bg-token-main-surface-secondary p-2 text-left font-vscode-editor text-[11px] leading-4 text-token-text-primary`,children:e.error?.stack??e.error?.message??String(e.error??``)}),(0,Q.jsx)(Le,{color:`secondary`,size:`default`,onClick:n,children:i})]",
|
|
139
|
+
"app shell error detail insertion anchor",
|
|
140
|
+
);
|
|
141
|
+
patched = replaceOnce(
|
|
142
|
+
patched,
|
|
143
|
+
"return t[2]===n?a=t[3]:(a=(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center gap-3 p-4 text-center text-sm text-token-text-secondary`,children:",
|
|
144
|
+
"return t[2]===n&&t[3]===e.error?a=t[4]:(a=(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center gap-3 p-4 text-center text-sm text-token-text-secondary`,children:",
|
|
145
|
+
"app shell error cache condition anchor",
|
|
146
|
+
);
|
|
147
|
+
return replaceOnce(
|
|
148
|
+
patched,
|
|
149
|
+
"}),t[2]=n,t[3]=a),a}function Tn(e){return e.composedPath().some",
|
|
150
|
+
"}),t[2]=n,t[3]=e.error,t[4]=a),a}function Tn(e){return e.composedPath().some",
|
|
151
|
+
"app shell error cache assignment anchor",
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const codexPlusUserBubbleSettingsHelpers = `
|
|
156
|
+
const CPX_USER_BUBBLE_COLORS_KEY=\`codex-plus:user-message-bubble-colors\`,CPX_USER_BUBBLE_COLORS_EVENT=\`codex-plus:user-message-bubble-colors-change\`;function CPX_isUserBubbleColor(e){return typeof e===\`string\`&&/^#[0-9a-fA-F]{6}$/.test(e)}function CPX_defaultUserBubbleColor(e){return e===\`dark\`?\`#2f2f2f\`:\`#f2f2f2\`}function CPX_isStoredUserBubbleColor(e,t){return CPX_isUserBubbleColor(t)&&t.toLowerCase()!==CPX_defaultUserBubbleColor(e)}function CPX_readUserBubbleColors(){try{let e=JSON.parse(localStorage.getItem(CPX_USER_BUBBLE_COLORS_KEY)??\`{}\`)??{};return{light:CPX_isStoredUserBubbleColor(\`light\`,e.light)?e.light:\`\`,dark:CPX_isStoredUserBubbleColor(\`dark\`,e.dark)?e.dark:\`\`}}catch{return{light:\`\`,dark:\`\`}}}function CPX_writeUserBubbleColor(e,t){let n=CPX_readUserBubbleColors();CPX_isStoredUserBubbleColor(e,t)?n[e]=t:delete n[e],localStorage.setItem(CPX_USER_BUBBLE_COLORS_KEY,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(CPX_USER_BUBBLE_COLORS_EVENT,{detail:n}))}function CPXUserBubbleColorRow({variant:e,label:t,ariaLabel:n}){let[r,i]=(0,X.useState)(()=>CPX_readUserBubbleColors()[e]||CPX_defaultUserBubbleColor(e));return(0,X.useEffect)(()=>{let t=()=>i(CPX_readUserBubbleColors()[e]||CPX_defaultUserBubbleColor(e));return window.addEventListener(CPX_USER_BUBBLE_COLORS_EVENT,t),()=>window.removeEventListener(CPX_USER_BUBBLE_COLORS_EVENT,t)},[e]),(0,Z.jsx)(J,{control:(0,Z.jsx)(sn,{ariaLabel:n,value:r,onChange:t=>{i(t),CPX_writeUserBubbleColor(e,t)}}),label:t,variant:\`nested\`})}
|
|
157
|
+
`;
|
|
158
|
+
|
|
159
|
+
function patchGeneralSettings(text) {
|
|
160
|
+
let patched = replaceOnce(
|
|
161
|
+
text,
|
|
162
|
+
"function tn({showCodeFont:e,showTranslucentSidebarToggle:t,variant:n}){",
|
|
163
|
+
`${codexPlusUserBubbleSettingsHelpers}function tn({showCodeFont:e,showTranslucentSidebarToggle:t,variant:n}){`,
|
|
164
|
+
"user bubble settings helper insertion anchor",
|
|
165
|
+
);
|
|
166
|
+
patched = replaceOnce(
|
|
167
|
+
patched,
|
|
168
|
+
"chromeThemeCodeFont:{id:`settings.general.appearance.chromeTheme.codeFontFamily.short`,defaultMessage:`Code font`,description:`Short label for the code font input`},pointerCursors:",
|
|
169
|
+
"chromeThemeCodeFont:{id:`settings.general.appearance.chromeTheme.codeFontFamily.short`,defaultMessage:`Code font`,description:`Short label for the code font input`},userBubble:{id:`settings.general.appearance.userMessageBubble.short`,defaultMessage:`User bubble`,description:`Short label for the user message bubble color input`},pointerCursors:",
|
|
170
|
+
"user bubble settings message anchor",
|
|
171
|
+
);
|
|
172
|
+
patched = replaceOnce(
|
|
173
|
+
patched,
|
|
174
|
+
"let r=a(s),i=N(),o=i.formatMessage(Q.chromeThemeAccent),c=i.formatMessage(Q.chromeThemeBackground),l=i.formatMessage(Q.chromeThemeForeground),u=i.formatMessage(Q.chromeThemeContrast),d=i.formatMessage(Q.chromeThemeTranslucentSidebar),",
|
|
175
|
+
"let r=a(s),i=N(),o=i.formatMessage(Q.chromeThemeAccent),c=i.formatMessage(Q.chromeThemeBackground),l=i.formatMessage(Q.chromeThemeForeground),CPX_userBubbleLabel=i.formatMessage(Q.userBubble),u=i.formatMessage(Q.chromeThemeContrast),d=i.formatMessage(Q.chromeThemeTranslucentSidebar),",
|
|
176
|
+
"user bubble settings label anchor",
|
|
177
|
+
);
|
|
178
|
+
return replaceOnce(
|
|
179
|
+
patched,
|
|
180
|
+
"children:[D.map(e=>(0,Z.jsx)(J,{control:(0,Z.jsx)(sn,{ariaLabel:e.ariaLabel,value:x[e.role],onChange:t=>{k(e.role,t)}}),label:e.label,variant:`nested`},e.role)),O.map",
|
|
181
|
+
"children:[D.map(e=>(0,Z.jsx)(J,{control:(0,Z.jsx)(sn,{ariaLabel:e.ariaLabel,value:x[e.role],onChange:t=>{k(e.role,t)}}),label:e.label,variant:`nested`},e.role)),(0,Z.jsx)(CPXUserBubbleColorRow,{variant:n,label:CPX_userBubbleLabel,ariaLabel:i.formatMessage({id:`settings.general.appearance.userMessageBubble`,defaultMessage:`{variant} user message bubble color`,description:`Aria label for the user message bubble color input in appearance settings`},{variant:S})}),O.map",
|
|
182
|
+
"user bubble settings row anchor",
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const codexPlusUserBubbleHelpers = `
|
|
187
|
+
const CPX_USER_BUBBLE_COLORS_KEY=\`codex-plus:user-message-bubble-colors\`,CPX_USER_BUBBLE_COLORS_EVENT=\`codex-plus:user-message-bubble-colors-change\`;function CPX_isUserBubbleColor(e){return typeof e===\`string\`&&/^#[0-9a-fA-F]{6}$/.test(e)}function CPX_defaultUserBubbleColor(e){return e===\`dark\`?\`#2f2f2f\`:\`#f2f2f2\`}function CPX_isStoredUserBubbleColor(e,t){return CPX_isUserBubbleColor(t)&&t.toLowerCase()!==CPX_defaultUserBubbleColor(e)}function CPX_readUserBubbleColors(){try{let e=JSON.parse(localStorage.getItem(CPX_USER_BUBBLE_COLORS_KEY)??\`{}\`)??{};return{light:CPX_isStoredUserBubbleColor(\`light\`,e.light)?e.light:null,dark:CPX_isStoredUserBubbleColor(\`dark\`,e.dark)?e.dark:null}}catch{return{light:null,dark:null}}}function CPX_userBubbleTextColor(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16),i=e=>{let t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)},a=.2126*i(t)+.7152*i(n)+.0722*i(r);return a>.46?\`#111111\`:\`#ffffff\`}function CPX_setUserBubbleVars(){let e=CPX_readUserBubbleColors(),t=document.documentElement;for(let n of[\`light\`,\`dark\`]){let r=e[n];r==null?(t.style.removeProperty(\`--codex-plus-user-bubble-\${n}-bg\`),t.style.removeProperty(\`--codex-plus-user-bubble-\${n}-fg\`)):(t.style.setProperty(\`--codex-plus-user-bubble-\${n}-bg\`,r),t.style.setProperty(\`--codex-plus-user-bubble-\${n}-fg\`,CPX_userBubbleTextColor(r)))}}function CPX_installUserBubbleColors(){if(typeof document===\`undefined\`)return;let e=\`codex-plus-user-bubble-colors\`;document.getElementById(e)==null&&document.head?.appendChild(Object.assign(document.createElement(\`style\`),{id:e,textContent:\`:root:not(.dark):not(.electron-dark) :is([data-codex-plus-user-bubble],[data-codex-plus-user-entry]){background-color:var(--codex-plus-user-bubble-light-bg);color:var(--codex-plus-user-bubble-light-fg)}:root:not(.dark):not(.electron-dark) [data-codex-plus-user-entry] :is(.ProseMirror,.ProseMirror *,textarea,[contenteditable="true"],[data-placeholder]),:root:not(.dark):not(.electron-dark) [data-codex-plus-user-entry] :is(button:not([class*="bg-token-foreground"]),[role="button"]:not([class*="bg-token-foreground"]),button:not([class*="bg-token-foreground"]) svg,[role="button"]:not([class*="bg-token-foreground"]) svg,[class*="text-token-foreground"],[class*="text-token-description-foreground"],[class*="text-token-input-placeholder-foreground"]){color:var(--codex-plus-user-bubble-light-fg)}:root:not(.dark):not(.electron-dark) [data-codex-plus-user-entry] :is([data-placeholder],[class*="text-token-input-placeholder-foreground"])::before,:root:not(.dark):not(.electron-dark) [data-codex-plus-user-entry] :is([data-placeholder],[class*="text-token-input-placeholder-foreground"])::after,:root:not(.dark):not(.electron-dark) [data-codex-plus-user-entry] :is(input,textarea,[contenteditable="true"],[class*="placeholder:text-token-input-placeholder-foreground"])::placeholder{color:var(--codex-plus-user-bubble-light-fg)}:root.dark :is([data-codex-plus-user-bubble],[data-codex-plus-user-entry]),:root.electron-dark :is([data-codex-plus-user-bubble],[data-codex-plus-user-entry]){background-color:var(--codex-plus-user-bubble-dark-bg);color:var(--codex-plus-user-bubble-dark-fg)}:root.dark [data-codex-plus-user-entry] :is(.ProseMirror,.ProseMirror *,textarea,[contenteditable="true"],[data-placeholder]),:root.electron-dark [data-codex-plus-user-entry] :is(.ProseMirror,.ProseMirror *,textarea,[contenteditable="true"],[data-placeholder]),:root.dark [data-codex-plus-user-entry] :is(button:not([class*="bg-token-foreground"]),[role="button"]:not([class*="bg-token-foreground"]),button:not([class*="bg-token-foreground"]) svg,[role="button"]:not([class*="bg-token-foreground"]) svg,[class*="text-token-foreground"],[class*="text-token-description-foreground"],[class*="text-token-input-placeholder-foreground"]),:root.electron-dark [data-codex-plus-user-entry] :is(button:not([class*="bg-token-foreground"]),[role="button"]:not([class*="bg-token-foreground"]),button:not([class*="bg-token-foreground"]) svg,[role="button"]:not([class*="bg-token-foreground"]) svg,[class*="text-token-foreground"],[class*="text-token-description-foreground"],[class*="text-token-input-placeholder-foreground"]){color:var(--codex-plus-user-bubble-dark-fg)}:root.dark [data-codex-plus-user-entry] :is([data-placeholder],[class*="text-token-input-placeholder-foreground"])::before,:root.dark [data-codex-plus-user-entry] :is([data-placeholder],[class*="text-token-input-placeholder-foreground"])::after,:root.dark [data-codex-plus-user-entry] :is(input,textarea,[contenteditable="true"],[class*="placeholder:text-token-input-placeholder-foreground"])::placeholder,:root.electron-dark [data-codex-plus-user-entry] :is([data-placeholder],[class*="text-token-input-placeholder-foreground"])::before,:root.electron-dark [data-codex-plus-user-entry] :is([data-placeholder],[class*="text-token-input-placeholder-foreground"])::after,:root.electron-dark [data-codex-plus-user-entry] :is(input,textarea,[contenteditable="true"],[class*="placeholder:text-token-input-placeholder-foreground"])::placeholder{color:var(--codex-plus-user-bubble-dark-fg)}\`})),CPX_setUserBubbleVars(),window.addEventListener(CPX_USER_BUBBLE_COLORS_EVENT,CPX_setUserBubbleVars)}CPX_installUserBubbleColors();
|
|
188
|
+
`;
|
|
189
|
+
|
|
190
|
+
function patchUserMessageAttachments(text) {
|
|
191
|
+
let patched = replaceOnce(
|
|
192
|
+
text,
|
|
193
|
+
"var Z=i(),Q=e(n(),1),$=r();function Ue(e){",
|
|
194
|
+
`var Z=i(),Q=e(n(),1),$=r();${codexPlusUserBubbleHelpers}function Ue(e){`,
|
|
195
|
+
"user bubble helper insertion anchor",
|
|
196
|
+
);
|
|
197
|
+
patched = replaceOnce(
|
|
198
|
+
patched,
|
|
199
|
+
"Se=W?(0,$.jsx)(`div`,{className:`w-full p-px`,children:(0,$.jsx)(it,{cwd:T??null,hostId:k,initialMessage:U.trim(),onCancel:()=>{q(null)},onDraftChange:e=>{q(e)},onSubmit:ge})}):le?(0,$.jsx)(`div`,{\"data-user-message-bubble\":!0,role:H?`button`:void 0,tabIndex:0,className:D(e,`text-left focus-visible:ring-2 focus-visible:ring-token-focus-border focus-visible:outline-none`,H&&`cursor-interaction`),",
|
|
200
|
+
"Se=W?(0,$.jsx)(`div`,{className:`w-full p-px`,children:(0,$.jsx)(it,{cwd:T??null,hostId:k,initialMessage:U.trim(),onCancel:()=>{q(null)},onDraftChange:e=>{q(e)},onSubmit:ge})}):le?(0,$.jsx)(`div`,{\"data-user-message-bubble\":!0,\"data-codex-plus-user-bubble\":!0,role:H?`button`:void 0,tabIndex:0,className:D(e,`text-left focus-visible:ring-2 focus-visible:ring-token-focus-border focus-visible:outline-none`,H&&`cursor-interaction`),",
|
|
201
|
+
"user bubble marker attribute anchor",
|
|
202
|
+
);
|
|
203
|
+
return replaceOnce(
|
|
204
|
+
patched,
|
|
205
|
+
"return(0,$.jsx)(`form`,{className:`relative flex w-full flex-col rounded-3xl bg-token-foreground/5`,onSubmit:e=>{e.preventDefault(),v()},children:",
|
|
206
|
+
"return(0,$.jsx)(`form`,{\"data-codex-plus-user-entry\":!0,className:`relative flex w-full flex-col rounded-3xl bg-token-foreground/5`,onSubmit:e=>{e.preventDefault(),v()},children:",
|
|
207
|
+
"edit user message entry marker anchor",
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function patchComposer(text) {
|
|
212
|
+
let patched = replaceOnce(
|
|
213
|
+
text,
|
|
214
|
+
"function oh(e){let t=(0,$.c)(13),",
|
|
215
|
+
`${codexPlusUserBubbleHelpers}function oh(e){let t=(0,$.c)(13),`,
|
|
216
|
+
"composer user bubble helper insertion anchor",
|
|
217
|
+
);
|
|
218
|
+
return replaceOnce(
|
|
219
|
+
patched,
|
|
220
|
+
"(0,Q.jsx)(Jt.div,{inert:a,className:v,onDragEnter:c,onDragOver:u,onDragLeave:l,onDrop:d,children:n})",
|
|
221
|
+
"(0,Q.jsx)(Jt.div,{inert:a,\"data-codex-plus-user-entry\":!0,className:v,onDragEnter:c,onDragOver:u,onDragLeave:l,onDrop:d,children:n})",
|
|
222
|
+
"composer user entry marker anchor",
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
module.exports = {
|
|
227
|
+
id: "codex-26.616.41845-4198",
|
|
228
|
+
codexVersion: "26.616.41845",
|
|
229
|
+
bundleVersion: "4198",
|
|
230
|
+
asarSha256: "9d43c52872934895b2add6e291d4743ad40435ae010ba02a6e3f4d5acfd61120",
|
|
231
|
+
patches: [
|
|
232
|
+
{
|
|
233
|
+
id: "bundle-identity",
|
|
234
|
+
infoPlistStrings: {
|
|
235
|
+
CFBundleDisplayName: "Codex Plus",
|
|
236
|
+
CFBundleName: "Codex Plus",
|
|
237
|
+
CFBundleIdentifier: "com.openai.codex-plus",
|
|
238
|
+
},
|
|
239
|
+
fileTransforms: [[titleFile, patchTitle]],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
id: "nested-repository-worker",
|
|
243
|
+
fileTransforms: [[workerFile, patchWorker]],
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
id: "multi-repository-review",
|
|
247
|
+
fileTransforms: [[threadSidePanelTabsFile, patchThreadSidePanelTabs]],
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: "diagnostic-error-boundary",
|
|
251
|
+
fileTransforms: [[appShellFile, patchAppShell]],
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
id: "user-message-bubble-colors",
|
|
255
|
+
fileTransforms: [
|
|
256
|
+
[generalSettingsFile, patchGeneralSettings],
|
|
257
|
+
[userMessageAttachmentsFile, patchUserMessageAttachments],
|
|
258
|
+
[composerFile, patchComposer],
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
};
|