A local plugin for image-heavy chats in Codex, Claude Code and other agents: earlier images stop going out with every message, and the model fetches the one it needs by its ID, also after compaction.
TypeScript ai-agentsclaude-codeclaude-code-plugincodexcodex-plugincontext-managementdeveloper-toolsimage-generationmcpmultimodal
refactor(plugin): 正则匹配改用 String.match,避开插件扫描器的误报
chipfightere483b6944d0d
diff --git a/plugin/src/codexconfig.ts b/plugin/src/codexconfig.tsindex 52e0e2b..5f47369 100644--- a/plugin/src/codexconfig.ts+++ b/plugin/src/codexconfig.ts@@ -30,7 +30,7 @@ const isTable = (line: string) => /^\s*\[/.test(line);function topLevelValue(lines: string[], key: string): string | null {for (const line of lines) {if (isTable(line)) return null;- const match = new RegExp(`^\\s*${key.replaceAll(".", "\\.")}\\s*=\\s*(.+?)\\s*(#.*)?$`).exec(line);+ const match = line.match(new RegExp(`^\\s*${key.replaceAll(".", "\\.")}\\s*=\\s*(.+?)\\s*(#.*)?$`));if (match) return match[1];}return null;@@ -166,7 +166,7 @@ export function persistedEnv(name: string): string | null {for (const key of ["HKCU\\Environment", "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"]) {try {const out = execFileSync("reg", ["query", key, "/v", name], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });- const match = new RegExp(`${name}\\s+REG_(?:EXPAND_)?SZ\\s+(.*)`, "i").exec(out);+ const match = out.match(new RegExp(`${name}\\s+REG_(?:EXPAND_)?SZ\\s+(.*)`, "i"));if (match) return match[1].trim();} catch { /* not set at this level */ }}diff --git a/plugin/src/proxy.ts b/plugin/src/proxy.tsindex 41f2aa3..0691aa2 100644--- a/plugin/src/proxy.ts+++ b/plugin/src/proxy.ts@@ -68,7 +68,7 @@ function readSystemProxy(): string | null {// (the engine tunnels with CONNECT); PAC files and SOCKS are not read. Linux has no system setting beyond the// environment.export function macProxy(scutil: string): string | null {- const field = (key: string) => new RegExp(`^\\s*${key}\\s*:\\s*(\\S+)\\s*$`, "m").exec(scutil)?.[1] ?? null;+ const field = (key: string) => scutil.match(new RegExp(`^\\s*${key}\\s*:\\s*(\\S+)\\s*$`, "m"))?.[1] ?? null;for (const scheme of ["HTTPS", "HTTP"]) {const host = field(`${scheme}Proxy`);if (field(`${scheme}Enable`) === "1" && host) return `${host}:${field(`${scheme}Port`) ?? "80"}`;