codex-plus-patcher 0.5.0 → 0.7.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.
Files changed (48) hide show
  1. package/README.md +12 -1
  2. package/package.json +5 -2
  3. package/src/cli.js +97 -0
  4. package/src/patches/26.616.41845-4198.js +2 -0
  5. package/src/patches/26.616.51431-4212.js +2 -0
  6. package/src/patches/26.616.71553-4265.js +6 -0
  7. package/src/patches/26.616.81150-4306.js +7 -0
  8. package/src/patches/lib/common-patches.js +175 -58
  9. package/src/patches/lib/hooks/about.js +7 -0
  10. package/src/patches/lib/hooks/diagnostics.js +7 -0
  11. package/src/patches/lib/hooks/mermaid.js +7 -0
  12. package/src/patches/lib/hooks/message-composer.js +7 -0
  13. package/src/patches/lib/hooks/native-main.js +7 -0
  14. package/src/patches/lib/hooks/project-selector.js +12 -0
  15. package/src/patches/lib/hooks/review.js +7 -0
  16. package/src/patches/lib/hooks/settings-commands.js +12 -0
  17. package/src/patches/lib/hooks/sidebar.js +12 -0
  18. package/src/patches/lib/hooks/thread-header.js +7 -0
  19. package/src/patches/lib/hooks/worker.js +7 -0
  20. package/src/patches/lib/project-selector-shortcut-patch.js +55 -0
  21. package/src/runtime/api/about.js +16 -0
  22. package/src/runtime/api/commands.js +85 -0
  23. package/src/runtime/api/composer.js +14 -0
  24. package/src/runtime/api/diagnostics.js +38 -0
  25. package/src/runtime/api/errors.js +20 -0
  26. package/src/runtime/api/index.js +79 -0
  27. package/src/runtime/api/mermaid.js +14 -0
  28. package/src/runtime/api/message.js +14 -0
  29. package/src/runtime/api/modules.js +57 -0
  30. package/src/runtime/api/native.js +14 -0
  31. package/src/runtime/api/patches.js +31 -0
  32. package/src/runtime/api/review.js +20 -0
  33. package/src/runtime/api/settings.js +76 -0
  34. package/src/runtime/api/sidebar.js +24 -0
  35. package/src/runtime/api/styles.js +28 -0
  36. package/src/runtime/api/threadHeader.js +41 -0
  37. package/src/runtime/assets.js +58 -13
  38. package/src/runtime/host/messageComposer.js +16 -0
  39. package/src/runtime/host/nativeMain.js +159 -0
  40. package/src/runtime/host/projectSelector.js +58 -0
  41. package/src/runtime/host/review.js +62 -0
  42. package/src/runtime/host/sidebar.js +21 -0
  43. package/src/runtime/host/threadHeader.js +9 -0
  44. package/src/runtime/{worker.js → host/worker.js} +7 -0
  45. package/src/runtime/plugins/devTools.js +33 -0
  46. package/src/runtime/plugins/projectPathHeader.js +116 -0
  47. package/src/runtime/plugins/projectSelectorShortcut.js +207 -0
  48. package/src/runtime/runtime.js +22 -355
@@ -0,0 +1,55 @@
1
+ const { replaceOnce } = require("./replace");
2
+ const { projectSelectorSearchHook, projectSelectorTriggerHook } = require("./hooks/project-selector");
3
+
4
+ function patchLocalActiveWorkspaceRootDropdownProjectSelectorShortcut(text) {
5
+ let patched = replaceOnce(
6
+ text,
7
+ "Ne=r();function Pe(e){let t=(0,Ne.c)(42),",
8
+ `Ne=r();${projectSelectorSearchHook()}function Pe(e){let t=(0,Ne.c)(42),`,
9
+ "project selector fuzzy search adapter insertion anchor",
10
+ );
11
+ patched = replaceOnce(
12
+ patched,
13
+ "let e=h.trim().toLowerCase();v=n.filter(t=>{if(!e)return!0;let n=t.repositoryData?.rootFolder??``;return[t.label,n,t.path??``,t.hostDisplayName??``].some(t=>t.toLowerCase().includes(e))});",
14
+ "v=CPXP.fuzzyFilter(n,h);",
15
+ "project selector fuzzy search filter anchor",
16
+ );
17
+ patched = replaceOnce(
18
+ patched,
19
+ "S=(0,H.jsx)(ve,{value:h,onChange:o,placeholder:s,className:`mb-1`})",
20
+ "S=(0,H.jsx)(ve,{value:h,onChange:o,onKeyDown:e=>CPXP.acceptFirst(e,v,i,h),placeholder:s,className:`mb-1`})",
21
+ "project selector accept first match keydown anchor",
22
+ );
23
+ patched = replaceOnce(
24
+ patched,
25
+ "(0,H.jsx)(`span`,{className:`truncate`,children:e.label})",
26
+ "(0,H.jsx)(`span`,{className:`truncate`,children:CPXP.fuzzyHighlight(e.label,h,H.jsx)})",
27
+ "project selector fuzzy search highlight anchor",
28
+ );
29
+ patched = replaceOnce(
30
+ patched,
31
+ "function Ie(e){let t=(0,Ne.c)(81),",
32
+ `${projectSelectorTriggerHook()}function Ie(e){let t=(0,Ne.c)(81),`,
33
+ "project selector shortcut helper insertion anchor",
34
+ );
35
+ return replaceOnce(
36
+ patched,
37
+ "at=(0,H.jsx)(ye,{open:f,onOpenChange:g,onCloseAutoFocus:Y,align:tt,disabled:O,triggerButton:X,contentWidth:`workspace`,contentMaxHeight:`tall`,children:$})",
38
+ "at=(0,H.jsx)(ye,{open:f,onOpenChange:g,onCloseAutoFocus:Y,align:tt,disabled:O,triggerButton:CPXPST(X,k),contentWidth:`workspace`,contentMaxHeight:`tall`,children:$})",
39
+ "project selector shortcut final dropdown trigger anchor",
40
+ );
41
+ }
42
+
43
+ function patchRunCommandProjectSelectorShortcut(text) {
44
+ return replaceOnce(
45
+ text,
46
+ "],[`openFolder`,()=>{r()}],[`toggleSidebar`,",
47
+ "],[`codexPlus.focusProjectSelector`,()=>{window.CodexPlus?.commands?.run?.(`codexPlus.focusProjectSelector`)}],[`openFolder`,()=>{r()}],[`toggleSidebar`,",
48
+ "project selector shortcut command dispatch anchor",
49
+ );
50
+ }
51
+
52
+ module.exports = {
53
+ patchLocalActiveWorkspaceRootDropdownProjectSelectorShortcut,
54
+ patchRunCommandProjectSelectorShortcut,
55
+ };
@@ -0,0 +1,16 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { ui } = globalObject.CodexPlus;
4
+
5
+ const buildInfo = [];
6
+
7
+ function addBuildInfo(fn) {
8
+ buildInfo.push(fn);
9
+ return fn;
10
+ }
11
+
12
+ ui.about = {
13
+ addBuildInfo,
14
+ buildInfo,
15
+ };
16
+ })();
@@ -0,0 +1,85 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { core, safeId } = globalObject.__CodexPlusRuntime;
4
+
5
+ function register(command) {
6
+ core.commands.set(safeId(command.id), command);
7
+ return command;
8
+ }
9
+
10
+ function run(id, ...args) {
11
+ const command = core.commands.get(id);
12
+ if (!command) throw new Error(`Unknown Codex Plus command: ${id}`);
13
+ return command.run?.(...args);
14
+ }
15
+
16
+ function commandGroups(command) {
17
+ return command.menu?.groups || [];
18
+ }
19
+
20
+ function commandKeybindings(command) {
21
+ return command.shortcut?.defaultKeybindings || [];
22
+ }
23
+
24
+ function commandMetadata() {
25
+ return Array.from(core.commands.values())
26
+ .filter((command) => command.palette?.enabled !== false)
27
+ .map((command) => {
28
+ const groups = commandGroups(command);
29
+ return {
30
+ id: command.id,
31
+ title: command.title,
32
+ description: command.description,
33
+ menuGroups: groups,
34
+ defaultKeybindings: commandKeybindings(command),
35
+ commandMenuGroupKey: groups.includes("panels") ? "panels" : groups[0],
36
+ commandMenu: true,
37
+ electron: {
38
+ menuTitle: command.title,
39
+ defaultKeybindings: commandKeybindings(command),
40
+ },
41
+ };
42
+ });
43
+ }
44
+
45
+ function CommandMenuItemHost({ command, deps, group, close }) {
46
+ const jsx = deps?.jsx;
47
+ const MenuItem = deps?.MenuItem;
48
+ if (typeof jsx !== "function" || MenuItem == null) return null;
49
+ const render = (closeMenu) =>
50
+ jsx(
51
+ MenuItem,
52
+ {
53
+ value: command.title,
54
+ title: command.title,
55
+ description: command.description,
56
+ onSelect() {
57
+ run(command.id);
58
+ closeMenu?.();
59
+ close?.();
60
+ },
61
+ },
62
+ command.id,
63
+ );
64
+ deps?.register?.(command.id, () => run(command.id), {
65
+ menuItem: { id: command.id, groupKey: group, render },
66
+ });
67
+ return null;
68
+ }
69
+
70
+ function renderMenuItems({ group, deps, close } = {}) {
71
+ const jsx = deps?.jsx;
72
+ if (typeof jsx !== "function") return [];
73
+ return Array.from(core.commands.values())
74
+ .filter((command) => commandGroups(command).includes(group))
75
+ .map((command) => jsx(CommandMenuItemHost, { command, deps, group, close }, command.id));
76
+ }
77
+
78
+ globalObject.CodexPlus.commands = {
79
+ register,
80
+ run,
81
+ all: () => Array.from(core.commands.values()),
82
+ menuItems: (group) => Array.from(core.commands.values()).filter((command) => commandGroups(command).includes(group)),
83
+ };
84
+ globalObject.CodexPlus.ui.commands = { renderMenuItems, commandMetadata };
85
+ })();
@@ -0,0 +1,14 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { applyDecorators } = globalObject.__CodexPlusRuntime;
4
+ globalObject.CodexPlus.ui.composer = {
5
+ surfaceDecorators: [],
6
+ decorateSurface(fn) {
7
+ this.surfaceDecorators.push(fn);
8
+ return fn;
9
+ },
10
+ surfaceProps(props) {
11
+ return applyDecorators(props, this.surfaceDecorators);
12
+ },
13
+ };
14
+ })();
@@ -0,0 +1,38 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { core } = globalObject.__CodexPlusRuntime;
4
+
5
+ function diagnosticsEnabled() {
6
+ try {
7
+ return globalObject.localStorage?.getItem("codex-plus:diagnostics") === "1";
8
+ } catch {
9
+ return false;
10
+ }
11
+ }
12
+
13
+ function log(event, details = {}) {
14
+ const entry = { event, details, time: new Date().toISOString() };
15
+ core.diagnosticEvents.push(entry);
16
+ if (core.diagnosticEvents.length > 200) core.diagnosticEvents.shift();
17
+ if (diagnosticsEnabled()) {
18
+ try {
19
+ console.info("[Codex Plus]", event, details);
20
+ } catch {}
21
+ }
22
+ return entry;
23
+ }
24
+
25
+ const diagnostics = {
26
+ log,
27
+ snapshot() {
28
+ return core.diagnosticEvents.slice();
29
+ },
30
+ clear() {
31
+ core.diagnosticEvents.splice(0, core.diagnosticEvents.length);
32
+ },
33
+ enabled: diagnosticsEnabled,
34
+ };
35
+
36
+ globalObject.CodexPlus.diagnostics = diagnostics;
37
+ globalObject.CodexPlusDiagnostics = diagnostics;
38
+ })();
@@ -0,0 +1,20 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+
4
+ function renderDetails({ jsx, error, componentStack } = {}) {
5
+ for (const decorator of globalObject.CodexPlus.ui.errors.boundaryDecorators) {
6
+ const detail = decorator({ jsx, error, componentStack });
7
+ if (detail != null) return detail;
8
+ }
9
+ return null;
10
+ }
11
+
12
+ globalObject.CodexPlus.ui.errors = {
13
+ boundaryDecorators: [],
14
+ decorateBoundary(fn) {
15
+ this.boundaryDecorators.push(fn);
16
+ return fn;
17
+ },
18
+ renderDetails,
19
+ };
20
+ })();
@@ -0,0 +1,79 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const core = {
4
+ commands: new Map(),
5
+ diagnosticEvents: [],
6
+ hostModules: new Map(),
7
+ patchDescriptors: [],
8
+ plugins: new Map(),
9
+ settingsListeners: new Map(),
10
+ startedPlugins: new Set(),
11
+ storagePrefix: "codex-plus:plugin:",
12
+ styleElements: new Map(),
13
+ waiters: [],
14
+ };
15
+
16
+ function safeId(id) {
17
+ if (typeof id !== "string" || id.trim() === "") throw new Error("Codex Plus plugin ids must be non-empty strings");
18
+ return id.trim();
19
+ }
20
+
21
+ function definePlugin(definition) {
22
+ const id = safeId(definition.id || definition.name);
23
+ return { ...definition, id };
24
+ }
25
+
26
+ function registerPlugin(definition) {
27
+ const plugin = definePlugin(definition);
28
+ core.plugins.set(plugin.id, plugin);
29
+ if (plugin.settings) plugin.settingsStore = CodexPlus.settings.define(plugin.id, plugin.settings);
30
+ for (const descriptor of plugin.patches || []) CodexPlus.patches.register({ ...descriptor, plugin: plugin.id });
31
+ for (const command of plugin.commands || []) CodexPlus.commands.register({ ...command, plugin: plugin.id });
32
+ if (plugin.styles) CodexPlus.styles.register(plugin.id, plugin.styles);
33
+ if (plugin.required || plugin.enabledByDefault) startPlugin(plugin.id);
34
+ CodexPlus.diagnostics.log("plugin.register", { id: plugin.id, started: core.startedPlugins.has(plugin.id) });
35
+ return plugin;
36
+ }
37
+
38
+ function startPlugin(id) {
39
+ const plugin = core.plugins.get(id);
40
+ if (!plugin || core.startedPlugins.has(id)) return;
41
+ plugin.start?.(CodexPlus);
42
+ core.startedPlugins.add(id);
43
+ CodexPlus.diagnostics.log("plugin.start", { id });
44
+ }
45
+
46
+ function stopPlugin(id) {
47
+ const plugin = core.plugins.get(id);
48
+ if (!plugin || !core.startedPlugins.has(id)) return;
49
+ plugin.stop?.(CodexPlus);
50
+ core.startedPlugins.delete(id);
51
+ }
52
+
53
+ function mergeDataAttributes(base, extra) {
54
+ if (extra == null) return base;
55
+ if (base == null) return extra;
56
+ return { ...base, ...extra, style: { ...base.style, ...extra.style } };
57
+ }
58
+
59
+ function applyDecorators(props, decorators) {
60
+ let result;
61
+ for (const decorator of decorators) result = mergeDataAttributes(result, decorator(props));
62
+ return result;
63
+ }
64
+
65
+ const CodexPlus = {
66
+ definePlugin,
67
+ registerPlugin,
68
+ startPlugin,
69
+ stopPlugin,
70
+ plugins: core.plugins,
71
+ ui: {},
72
+ };
73
+
74
+ globalObject.CodexPlus = CodexPlus;
75
+ globalObject.CodexPlusDiagnostics = null;
76
+ globalObject.CodexPlusHost ||= {};
77
+ globalObject.CodexPlusHost.adapters ||= {};
78
+ globalObject.__CodexPlusRuntime = { core, safeId, mergeDataAttributes, applyDecorators };
79
+ })();
@@ -0,0 +1,14 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { applyDecorators } = globalObject.__CodexPlusRuntime;
4
+ globalObject.CodexPlus.ui.mermaid = {
5
+ diagramDecorators: [],
6
+ decorateDiagram(fn) {
7
+ this.diagramDecorators.push(fn);
8
+ return fn;
9
+ },
10
+ diagramProps(props) {
11
+ return applyDecorators(props, this.diagramDecorators);
12
+ },
13
+ };
14
+ })();
@@ -0,0 +1,14 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { applyDecorators } = globalObject.__CodexPlusRuntime;
4
+ globalObject.CodexPlus.ui.message = {
5
+ userBubbleDecorators: [],
6
+ decorateUserBubble(fn) {
7
+ this.userBubbleDecorators.push(fn);
8
+ return fn;
9
+ },
10
+ userBubbleProps(props) {
11
+ return applyDecorators(props, this.userBubbleDecorators);
12
+ },
13
+ };
14
+ })();
@@ -0,0 +1,57 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { core } = globalObject.__CodexPlusRuntime;
4
+
5
+ function notifyWaiters(name, value) {
6
+ for (let index = core.waiters.length - 1; index >= 0; index -= 1) {
7
+ const waiter = core.waiters[index];
8
+ if (!waiter.filter(value, name)) continue;
9
+ core.waiters.splice(index, 1);
10
+ waiter.resolve(value);
11
+ }
12
+ }
13
+
14
+ function registerHostModule(name, value) {
15
+ core.hostModules.set(name, value);
16
+ notifyWaiters(name, value);
17
+ return value;
18
+ }
19
+
20
+ function moduleValues() {
21
+ return Array.from(core.hostModules.values());
22
+ }
23
+
24
+ function findByProps(...props) {
25
+ return moduleValues().find((value) => value && props.every((prop) => prop in value));
26
+ }
27
+
28
+ function findByCode(text) {
29
+ return moduleValues().find((value) => {
30
+ try {
31
+ return String(value).includes(text);
32
+ } catch {
33
+ return false;
34
+ }
35
+ });
36
+ }
37
+
38
+ function findComponentByCode(text) {
39
+ return moduleValues().find((value) => {
40
+ try {
41
+ return typeof value === "function" && String(value).includes(text);
42
+ } catch {
43
+ return false;
44
+ }
45
+ });
46
+ }
47
+
48
+ function waitFor(filter) {
49
+ for (const [name, value] of core.hostModules) {
50
+ if (filter(value, name)) return Promise.resolve(value);
51
+ }
52
+ return new Promise((resolve) => core.waiters.push({ filter, resolve }));
53
+ }
54
+
55
+ globalObject.CodexPlus.modules = { registerHostModule, findByCode, findByProps, findComponentByCode, waitFor };
56
+ globalObject.CodexPlusHost.register = registerHostModule;
57
+ })();
@@ -0,0 +1,14 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+
4
+ async function request(method, params) {
5
+ return globalObject.codexPlusNative?.request?.(method, params) ?? globalObject.CodexPlusHost?.nativeRequest?.(method, params);
6
+ }
7
+
8
+ function registerNativeMenuItem(item) {
9
+ return globalObject.CodexPlus.native.request("native-menu/register-item", item).catch(() => ({ ok: false }));
10
+ }
11
+
12
+ globalObject.CodexPlus.native = { request };
13
+ globalObject.CodexPlus.nativeMenus = { registerItem: registerNativeMenuItem };
14
+ })();
@@ -0,0 +1,31 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { core } = globalObject.__CodexPlusRuntime;
4
+
5
+ function register(descriptor) {
6
+ core.patchDescriptors.push(descriptor);
7
+ return descriptor;
8
+ }
9
+
10
+ function apply(source, descriptors = core.patchDescriptors) {
11
+ let output = source;
12
+ for (const descriptor of descriptors) {
13
+ const moduleMatches =
14
+ typeof descriptor.find === "string" ? output.includes(descriptor.find) : descriptor.find.test(output);
15
+ if (!moduleMatches) continue;
16
+ const replacements = Array.isArray(descriptor.replacement) ? descriptor.replacement : [descriptor.replacement];
17
+ const beforeGroup = output;
18
+ let appliedGroup = true;
19
+ for (const replacement of replacements) {
20
+ const before = output;
21
+ output = output.replace(replacement.match, replacement.replace);
22
+ if (before === output) appliedGroup = false;
23
+ }
24
+ if (descriptor.group && !appliedGroup) output = beforeGroup;
25
+ if (!descriptor.all) break;
26
+ }
27
+ return output;
28
+ }
29
+
30
+ globalObject.CodexPlus.patches = { register, apply, all: core.patchDescriptors };
31
+ })();
@@ -0,0 +1,20 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+
4
+ function renderBody({ props, deps, defaultBody } = {}) {
5
+ let body = defaultBody;
6
+ for (const wrapper of globalObject.CodexPlus.ui.review.wrappers) {
7
+ body = wrapper({ ...props, mainReviewContent: body }, deps);
8
+ }
9
+ return body;
10
+ }
11
+
12
+ globalObject.CodexPlus.ui.review = {
13
+ wrappers: [],
14
+ wrapBody(wrapper) {
15
+ this.wrappers.push(wrapper);
16
+ return wrapper;
17
+ },
18
+ renderBody,
19
+ };
20
+ })();
@@ -0,0 +1,76 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { core, safeId } = globalObject.__CodexPlusRuntime;
4
+
5
+ function getPluginStore(pluginId) {
6
+ const key = `${core.storagePrefix}${pluginId}`;
7
+ try {
8
+ return JSON.parse(globalObject.localStorage?.getItem(key) || "{}") || {};
9
+ } catch {
10
+ return {};
11
+ }
12
+ }
13
+
14
+ function writePluginStore(pluginId, store) {
15
+ const key = `${core.storagePrefix}${pluginId}`;
16
+ globalObject.localStorage?.setItem(key, JSON.stringify(store));
17
+ }
18
+
19
+ function emitSetting(pluginId, key, value) {
20
+ const listenerKey = `${pluginId}:${key}`;
21
+ for (const listener of core.settingsListeners.get(listenerKey) || []) listener(value);
22
+ }
23
+
24
+ function define(pluginId, definitions) {
25
+ const id = safeId(pluginId);
26
+ const store = getPluginStore(id);
27
+ for (const [key, definition] of Object.entries(definitions || {})) {
28
+ if (!(key in store) && "default" in definition) store[key] = definition.default;
29
+ }
30
+ writePluginStore(id, store);
31
+ return {
32
+ definitions,
33
+ get(key) {
34
+ return getPluginStore(id)[key];
35
+ },
36
+ set(key, value) {
37
+ const next = getPluginStore(id);
38
+ next[key] = value;
39
+ writePluginStore(id, next);
40
+ emitSetting(id, key, value);
41
+ },
42
+ use(key, listener) {
43
+ const listenerKey = `${id}:${key}`;
44
+ const listeners = core.settingsListeners.get(listenerKey) || new Set();
45
+ listeners.add(listener);
46
+ core.settingsListeners.set(listenerKey, listeners);
47
+ listener(getPluginStore(id)[key]);
48
+ return () => listeners.delete(listener);
49
+ },
50
+ };
51
+ }
52
+
53
+ function AppearanceRowHost({ row, deps, variant }) {
54
+ return row.render?.({ ...deps, variant, row }) ?? null;
55
+ }
56
+
57
+ const appearance = {
58
+ rows: [],
59
+ addRow(row) {
60
+ this.rows.push(row);
61
+ return row;
62
+ },
63
+ renderRows({ deps, variant, section = "appearance" } = {}) {
64
+ const jsx = deps?.jsx;
65
+ if (typeof jsx !== "function") return [];
66
+ return this.rows
67
+ .filter((row) => (row.section || "appearance") === section)
68
+ .slice()
69
+ .sort((left, right) => (left.order || 0) - (right.order || 0))
70
+ .map((row) => jsx(AppearanceRowHost, { row, deps, variant }, row.id));
71
+ },
72
+ };
73
+
74
+ globalObject.CodexPlus.ui.settings = { appearance };
75
+ globalObject.CodexPlus.settings = { define };
76
+ })();
@@ -0,0 +1,24 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { applyDecorators, mergeDataAttributes } = globalObject.__CodexPlusRuntime;
4
+ const sidebar = {
5
+ projectDecorators: [],
6
+ threadDecorators: [],
7
+ decorateProjectRow(fn) {
8
+ this.projectDecorators.push(fn);
9
+ return fn;
10
+ },
11
+ decorateThreadRow(fn) {
12
+ this.threadDecorators.push(fn);
13
+ return fn;
14
+ },
15
+ mergeDataAttributes,
16
+ projectRowProps(props) {
17
+ return applyDecorators(props, this.projectDecorators);
18
+ },
19
+ threadRowProps(props) {
20
+ return applyDecorators(props, this.threadDecorators);
21
+ },
22
+ };
23
+ globalObject.CodexPlus.ui.sidebar = sidebar;
24
+ })();
@@ -0,0 +1,28 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+ const { core, safeId } = globalObject.__CodexPlusRuntime;
4
+
5
+ function register(pluginId, cssText) {
6
+ if (typeof document === "undefined") return null;
7
+ const id = `codex-plus-style-${safeId(pluginId)}`;
8
+ let element = core.styleElements.get(id) || document.getElementById(id);
9
+ if (!element) {
10
+ element = document.createElement("style");
11
+ element.id = id;
12
+ document.head?.appendChild(element);
13
+ }
14
+ element.textContent = cssText;
15
+ core.styleElements.set(id, element);
16
+ return element;
17
+ }
18
+
19
+ function setRootVars(vars) {
20
+ if (typeof document === "undefined") return;
21
+ for (const [key, value] of Object.entries(vars || {})) {
22
+ if (value == null) document.documentElement.style.removeProperty(key);
23
+ else document.documentElement.style.setProperty(key, value);
24
+ }
25
+ }
26
+
27
+ globalObject.CodexPlus.styles = { register, setRootVars };
28
+ })();
@@ -0,0 +1,41 @@
1
+ (function () {
2
+ const globalObject = typeof window !== "undefined" ? window : globalThis;
3
+
4
+ function ThreadHeaderAccessoryHost({ accessory, context, deps }) {
5
+ const rendered = accessory?.({ context, ...deps }) ?? null;
6
+ globalObject.CodexPlus.diagnostics.log("threadHeader.accessoryHost.render", {
7
+ accessoryName: accessory?.name || null,
8
+ cwd: typeof context?.cwd === "string" ? context.cwd : null,
9
+ rendered: rendered != null,
10
+ });
11
+ return rendered;
12
+ }
13
+
14
+ function renderAccessories({ context, deps } = {}) {
15
+ const jsx = deps?.jsx;
16
+ if (typeof jsx !== "function") {
17
+ globalObject.CodexPlus.diagnostics.log("threadHeader.render.skip", { reason: "missing-jsx" });
18
+ return null;
19
+ }
20
+ globalObject.CodexPlus.diagnostics.log("threadHeader.render", {
21
+ accessoryCount: globalObject.CodexPlus.ui.threadHeader.accessories.length,
22
+ cwd: typeof context?.cwd === "string" ? context.cwd : null,
23
+ hostId: context?.hostId ?? null,
24
+ header: context?.header ?? null,
25
+ });
26
+ const rendered = globalObject.CodexPlus.ui.threadHeader.accessories.map((accessory, index) =>
27
+ jsx(ThreadHeaderAccessoryHost, { accessory, context, deps }, `thread-header-accessory:${index}`),
28
+ );
29
+ return rendered.length === 0 ? null : rendered;
30
+ }
31
+
32
+ globalObject.CodexPlus.ui.threadHeader = {
33
+ accessories: [],
34
+ addAccessory(fn) {
35
+ this.accessories.push(fn);
36
+ globalObject.CodexPlus.diagnostics.log("threadHeader.addAccessory", { accessoryName: fn?.name || null, accessoryCount: this.accessories.length });
37
+ return fn;
38
+ },
39
+ renderAccessories,
40
+ };
41
+ })();