@cachly-dev/mcp-server 0.10.206 → 0.10.208

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/README.md CHANGED
@@ -341,8 +341,8 @@ Manual snippets are in [Manual Setup](#manual-setup).
341
341
  | **Cursor** | yes, detected via `.cursor/` | `.cursor/mcp.json`, hooks in `.cursor/hooks.json` | no | Project-level; restart Cursor after setup. Lessons arrive with the first tool call of a turn |
342
342
  | **Windsurf** | yes, detected via `.windsurf/` | `.windsurf/mcp.json` | no | Project-level; restart Windsurf after setup |
343
343
  | **VS Code + Copilot** | yes, detected via `.vscode/` | `.vscode/mcp.json`, hooks in `.github/hooks/cachly-ambient.json` | no | Needs the VS Code MCP support or Copilot chat. Briefing at session start, lessons before each prompt |
344
- | **Codex CLI** | hooks yes, detected via `~/.codex` | hooks in `.codex/hooks.json` | no | Trust `.codex/` and confirm the hook once in `/hooks`. For the tools, `init --editor codex` prints the `codex mcp add` line |
345
- | **Gemini CLI** | hooks yes, detected via `~/.gemini` | `hooks` in `.gemini/settings.json` | no | Lessons are appended to the prompt (`BeforeAgent`). For the tools, `init --editor gemini` prints the `gemini mcp add` line |
344
+ | **Codex CLI** | yes, detected via `~/.codex` | `.codex/config.toml` (`[mcp_servers.cachly]`), hooks in `.codex/hooks.json` | no | Codex loads both once you trust the folder; confirm the hook once in `/hooks` |
345
+ | **Gemini CLI** | yes, detected via `~/.gemini` | `mcpServers.cachly` and `hooks` in `.gemini/settings.json` | no | Gemini loads both once you trust the folder. Lessons are appended to the prompt (`BeforeAgent`) |
346
346
  | **Cline** | yes, detected via VS Code | `.vscode/mcp.json` | no | Shares the config with Copilot; restart VS Code |
347
347
  | **Continue.dev** | yes, detected via `.continue/` | `.continue/config.json` | no | Uses the `modelContextProtocolServers` key |
348
348
  | **Zed** | yes, detected via `.zed/` | `.zed/settings.json` | no | Uses the `context_servers` key |
@@ -1,4 +1,4 @@
1
- import{readFileSync as x}from"node:fs";import{tmpdir as z}from"node:os";import{parseHookPayload as H,runEinblendung as C,stopLernanfrage as K,stopObservation as N}from"./ambient-cli.js";import{stopAntwort as j}from"./schreibbeleg.js";import{holeBestand as R,hookAusgabe as M,starteNebenlauf as G}from"./einblendung.js";import{STARTWISSEN_IMPORT as y,hookImportFuerAuftrag as B,importiereStartwissen as Y}from"./startwissen-hook.js";import{belohnungMelden as $}from"./lernen.js";import{appendLedgerEntry as D,reportLedgerEntry as J}from"./ambient-ledger.js";import{copilotHatHook as V,cursorHatHook as Q,findeInstanz as g,findeSchluessel as h,hookUmfeld as S,pluginVersion as W,projektHatHook as X}from"./hook-zugang.js";import{ABKUEHLUNG_HOOK_MS as q,schreibeAuftrag as O,sichereKonto as Z,startwissenEingeschaltet as tt}from"./konto-anlegen.js";import{istInstanzKennung as U,sofortTestHinweis as et}from"./zugang.js";import{CURSOR_FLAG as p,cursorEreignis as L,cursorHookAntwort as nt,cursorLeer as rt,istCursorNutzlast as P}from"./cursor-hook.js";import{COPILOT_FLAG as w,copilotEreignis as ot,copilotHookAntwort as it,istFremdeLaufzeit as T}from"./copilot-hook.js";import{CODEX_FLAG as v,codexHookAntwort as st}from"./codex-hook.js";import{GEMINI_FLAG as _,geminiEreignis as ct,geminiHookAntwort as ut}from"./gemini-hook.js";const at="https://api.cachly.dev",E=5e3,ft="ambient-auffrischen",F=new Set(["SessionStart","UserPromptSubmit","PreToolUse","Stop"]);async function lt(t,e){if(!t.args.includes(p)&&(L(e,t.args)!=="sessionStart"||Q(t.umfeld)))return"";const o=t.args.filter(r=>r==="--plugin");return nt({payload:e,args:t.args,claudeLauf:(r,u)=>I({...t,raw:r,args:[u,...o]}),ablageOrdner:t.cursorAblage})}function pt(t,e){const n=(o,r)=>I({...t,raw:o,args:[r]});return t.args.includes(w)?it({payload:e,args:t.args,claudeLauf:n,ablageOrdner:t.copilotAblage}):t.args.includes(v)?st({payload:e,args:t.args,claudeLauf:n}):t.args.includes(_)?ut({payload:e,args:t.args,claudeLauf:n}):null}function dt(t,e){return t.includes(p)||P(e)?"cursor":t.includes(w)?"copilot":t.includes(v)?"codex":t.includes(_)?"gemini":T(e)?"vscode":"claude"}async function mt(t){const e=await Z({apiUrl:t.apiUrl,version:W(t.umfeld),home:t.umfeld.heim,env:{...t.umfeld.env,CACHLY_QUELLE:"claude-code-plugin"},fristMs:E,anfrageMs:E,abkuehlungMs:q,holen:t.fetchFn});if(e.art==="vorhanden")return{apiKey:e.apiKey,instanzId:e.instanzId,hinweis:""};if(e.art!=="angelegt")return null;if(tt(t.umfeld.env)){const n={apiUrl:t.apiUrl,jwt:e.test.apiKey,instanceId:e.test.instanzId};t.selbst&&(t.nebenlauf??G)(n,[t.selbst,y,t.umfeld.projekt],{zweck:y,ordner:z()})||O({instanzId:e.test.instanzId,projekt:t.umfeld.projekt},{home:t.umfeld.heim})}return{apiKey:e.test.apiKey,instanzId:e.test.instanzId,hinweis:et(e.test)}}function gt(t,e){const n=e.replace(/^\s+/,"");if(!t)return M("SessionStart",n);try{const o=JSON.parse(t),r=o.hookSpecificOutput?.additionalContext;return!o.hookSpecificOutput||typeof r!="string"?t:(o.hookSpecificOutput.additionalContext=`${n}
1
+ import{readFileSync as z}from"node:fs";import{tmpdir as x}from"node:os";import{parseHookPayload as H,runEinblendung as C,stopLernanfrage as K,stopObservation as N}from"./ambient-cli.js";import{stopAntwort as j}from"./schreibbeleg.js";import{holeBestand as R,hookAusgabe as M,starteNebenlauf as G}from"./einblendung.js";import{STARTWISSEN_IMPORT as y,hookImportFuerAuftrag as B,importiereStartwissen as Y}from"./startwissen-hook.js";import{belohnungMelden as $}from"./lernen.js";import{appendLedgerEntry as D,reportLedgerEntry as J}from"./ambient-ledger.js";import{copilotHatHook as V,cursorHatHook as Q,findeInstanz as g,findeSchluessel as h,hookUmfeld as S,pluginVersion as W,projektHatHook as X}from"./hook-zugang.js";import{ABKUEHLUNG_HOOK_MS as q,schreibeAuftrag as O,sichereKonto as Z,startwissenEingeschaltet as tt}from"./konto-anlegen.js";import{istInstanzKennung as U,sofortTestHinweis as et}from"./zugang.js";import{CURSOR_FLAG as p,cursorEreignis as L,cursorHookAntwort as nt,cursorLeer as rt,istCursorNutzlast as P}from"./cursor-hook.js";import{COPILOT_FLAG as w,copilotEreignis as ot,copilotHookAntwort as it,istFremdeLaufzeit as T}from"./copilot-hook.js";import{CODEX_FLAG as v,codexHookAntwort as st}from"./codex-hook.js";import{GEMINI_FLAG as _,geminiEreignis as ct,geminiHookAntwort as at}from"./gemini-hook.js";const ut="https://api.cachly.dev",E=5e3,ft="ambient-auffrischen",F=new Set(["SessionStart","UserPromptSubmit","PreToolUse","Stop"]);async function lt(t,e){if(!t.args.includes(p)&&(L(e,t.args)!=="sessionStart"||Q(t.umfeld)))return"";const o=t.args.filter(r=>r==="--plugin");return nt({payload:e,args:t.args,claudeLauf:(r,a)=>I({...t,raw:r,args:[a,...o]}),ablageOrdner:t.cursorAblage})}function pt(t,e){const n=(o,r)=>I({...t,raw:o,args:[r]});return t.args.includes(w)?it({payload:e,args:t.args,claudeLauf:n,ablageOrdner:t.copilotAblage}):t.args.includes(v)?st({payload:e,args:t.args,claudeLauf:n}):t.args.includes(_)?at({payload:e,args:t.args,claudeLauf:n}):null}function dt(t,e){return t.includes(p)||P(e)?"cursor":t.includes(w)?"copilot":t.includes(v)?"codex":t.includes(_)?"gemini":T(e)?"vscode":"claude"}async function mt(t){const e=await Z({apiUrl:t.apiUrl,version:W(t.umfeld),home:t.umfeld.heim,env:{...t.umfeld.env,CACHLY_QUELLE:"claude-code-plugin"},fristMs:E,anfrageMs:E,abkuehlungMs:q,holen:t.fetchFn});if(e.art==="vorhanden")return{apiKey:e.apiKey,instanzId:e.instanzId,hinweis:""};if(e.art!=="angelegt")return null;if(tt(t.umfeld.env)){const n={apiUrl:t.apiUrl,jwt:e.test.apiKey,instanceId:e.test.instanzId};t.selbst&&(t.nebenlauf??G)(n,[t.selbst,y,t.umfeld.projekt],{zweck:y,ordner:x()})||O({instanzId:e.test.instanzId,projekt:t.umfeld.projekt},{home:t.umfeld.heim})}return{apiKey:e.test.apiKey,instanzId:e.test.instanzId,hinweis:et(e.test)}}function gt(t,e){const n=e.replace(/^\s+/,"");if(!t)return M("SessionStart",n);try{const o=JSON.parse(t),r=o.hookSpecificOutput?.additionalContext;return!o.hookSpecificOutput||typeof r!="string"?t:(o.hookSpecificOutput.additionalContext=`${n}
2
2
 
3
- ${r}`,JSON.stringify(o))}catch{return t}}async function I(t){try{const e=H(t.raw),n={...t,editor:t.editor??dt(t.args,e)};if(n.args.includes(p)||P(e))return await lt(n,e);const o=pt(n,e);if(o)return await o;const r=e?.hook_event_name??n.args.find(i=>F.has(i))??n.umfeld.env.CACHLY_HOOK_EVENT??"";if(T(e)&&(r!=="SessionStart"&&r!=="UserPromptSubmit"||V(n.umfeld))||n.args.includes("--plugin")&&r&&X(r,n.umfeld))return"";let u=null;if(r==="Stop"&&e?.transcript_path)try{u=x(e.transcript_path,"utf-8").split(`
4
- `);const i=j(u,e.stop_hook_active===!0);if(i)return i}catch{}let a=h(n.umfeld),c=g(n.umfeld),s="";if(!a&&r==="SessionStart"&&n.args.includes("--plugin")&&!U(c)){const i=await mt(n);i&&(a=i.apiKey,c=i.instanzId??c,s=i.hinweis)}if(!a||!c)return"";const f={apiUrl:n.apiUrl,jwt:a,instanceId:c};if(r==="Stop"){const i=e?N(e):null,m=i?(n.fetchFn??fetch)(`${f.apiUrl}/api/v1/instances/${f.instanceId}/learn`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.jwt}`},body:JSON.stringify(K(i)),signal:AbortSignal.timeout(8e3)}).catch(()=>{}):void 0,l=$(f,e?.session_id??null,u,{fetchFn:n.fetchFn});return await Promise.all([m,l]),""}let d;const A=await(n.einblenden??C)(n.raw,{cfg:f,nebenlauf:n.selbst?[n.selbst,ft]:void 0,editor:n.editor,fetchFn:n.fetchFn,onInject:(i,m)=>{const l={ts:new Date().toISOString(),event:m,injected:i,prevented:0};D(l),d=J(f,l,n.fetchFn)}});return d&&await Promise.race([d,new Promise(i=>setTimeout(i,500))]),s?gt(A,s):A}catch{return""}}async function ht(){if(process.stdin.isTTY)return"";const t=[];for await(const e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function b(){return process.env.CACHLY_API_URL||at}const k={SessionStart:25e3,UserPromptSubmit:8e3,PreToolUse:8e3,Stop:5e4,sessionStart:25e3,beforeSubmitPrompt:8e3,postToolUse:3e3,userPromptSubmitted:8e3,PostToolUse:3e3,BeforeAgent:8e3};function St(t,e){return t.includes(p)?rt(L(e,t)):t.includes(w)?ot(e,t)?"{}":"":t.includes(_)&&ct(e,t)?"{}":""}async function Ft(t,e){try{const n=await ht(),o=H(n),r=o?.hook_event_name??t.find(s=>F.has(s)||Object.hasOwn(k,s))??"",u=Number(process.env.CACHLY_HOOK_FRIST_MS)||k[r]||k.UserPromptSubmit,a=St(t,o),c=await Promise.race([I({args:t,raw:n,umfeld:S(),apiUrl:b(),selbst:e}),new Promise(s=>setTimeout(()=>s(a),u))]);c&&await new Promise(s=>process.stdout.write(c,()=>s()))}catch{}process.exit(0)}async function xt(){try{const t=S(),e=h(t),n=g(t);e&&n&&await R({apiUrl:b(),jwt:e,instanceId:n},{force:!0,lernen:!0})}catch{}process.exit(0)}async function zt(t){try{const e=S(),n=h(e),o=g(e);if(n&&U(o)){const r=await Y({cfg:{apiUrl:b(),jwt:n,instanceId:o},projekt:t,env:e.env});r.art!=="aus"&&O({instanzId:o,projekt:t,vomHook:B(r)},{home:e.heim})}}catch{}process.exit(0)}export{ft as AUFFRISCHEN,k as HOOK_FRIST_MS,E as KONTO_FRIST_MS,at as STANDARD_API_URL,xt as auffrischenHauptlauf,dt as editorVon,I as hookAntwort,Ft as hookHauptlauf,zt as startwissenImportHauptlauf};
3
+ ${r}`,JSON.stringify(o))}catch{return t}}async function I(t){try{const e=H(t.raw),n={...t,editor:t.editor??dt(t.args,e)};if(n.args.includes(p)||P(e))return await lt(n,e);const o=pt(n,e);if(o)return await o;const r=e?.hook_event_name??n.args.find(i=>F.has(i))??n.umfeld.env.CACHLY_HOOK_EVENT??"";if(T(e)&&(r!=="SessionStart"&&r!=="UserPromptSubmit"||V(n.umfeld))||n.args.includes("--plugin")&&r&&X(r,n.umfeld))return"";let a=null;if(r==="Stop"&&e?.transcript_path)try{a=z(e.transcript_path,"utf-8").split(`
4
+ `);const i=j(a,e.stop_hook_active===!0);if(i)return i}catch{}let f=h(n.umfeld),c=g(n.umfeld),s="";if(!f&&r==="SessionStart"&&n.args.includes("--plugin")&&!U(c)){const i=await mt(n);i&&(f=i.apiKey,c=i.instanzId??c,s=i.hinweis)}if(!f||!c)return"";const u={apiUrl:n.apiUrl,jwt:f,instanceId:c};if(r==="Stop"){const i=e?N(e):null,m=i?(n.fetchFn??fetch)(`${u.apiUrl}/api/v1/instances/${u.instanceId}/learn`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u.jwt}`},body:JSON.stringify(K(i)),signal:AbortSignal.timeout(8e3)}).catch(()=>{}):void 0,l=$(u,e?.session_id??null,a,{fetchFn:n.fetchFn});return await Promise.all([m,l]),""}let d;const A=await(n.einblenden??C)(n.raw,{cfg:u,nebenlauf:n.selbst?[n.selbst,ft]:void 0,editor:n.editor,fetchFn:n.fetchFn,onInject:(i,m)=>{const l={ts:new Date().toISOString(),event:m,injected:i,prevented:0,instanz:u.instanceId};D(l),d=J(u,l,n.fetchFn)}});return d&&await Promise.race([d,new Promise(i=>setTimeout(i,500))]),s?gt(A,s):A}catch{return""}}async function ht(){if(process.stdin.isTTY)return"";const t=[];for await(const e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function b(){return process.env.CACHLY_API_URL||ut}const k={SessionStart:25e3,UserPromptSubmit:8e3,PreToolUse:8e3,Stop:5e4,sessionStart:25e3,beforeSubmitPrompt:8e3,postToolUse:3e3,userPromptSubmitted:8e3,PostToolUse:3e3,BeforeAgent:8e3};function St(t,e){return t.includes(p)?rt(L(e,t)):t.includes(w)?ot(e,t)?"{}":"":t.includes(_)&&ct(e,t)?"{}":""}async function Ft(t,e){try{const n=await ht(),o=H(n),r=o?.hook_event_name??t.find(s=>F.has(s)||Object.hasOwn(k,s))??"",a=Number(process.env.CACHLY_HOOK_FRIST_MS)||k[r]||k.UserPromptSubmit,f=St(t,o),c=await Promise.race([I({args:t,raw:n,umfeld:S(),apiUrl:b(),selbst:e}),new Promise(s=>setTimeout(()=>s(f),a))]);c&&await new Promise(s=>process.stdout.write(c,()=>s()))}catch{}process.exit(0)}async function zt(){try{const t=S(),e=h(t),n=g(t);e&&n&&await R({apiUrl:b(),jwt:e,instanceId:n},{force:!0,lernen:!0})}catch{}process.exit(0)}async function xt(t){try{const e=S(),n=h(e),o=g(e);if(n&&U(o)){const r=await Y({cfg:{apiUrl:b(),jwt:n,instanceId:o},projekt:t,env:e.env});r.art!=="aus"&&O({instanzId:o,projekt:t,vomHook:B(r)},{home:e.heim})}}catch{}process.exit(0)}export{ft as AUFFRISCHEN,k as HOOK_FRIST_MS,E as KONTO_FRIST_MS,ut as STANDARD_API_URL,zt as auffrischenHauptlauf,dt as editorVon,I as hookAntwort,Ft as hookHauptlauf,xt as startwissenImportHauptlauf};
@@ -1,6 +1,6 @@
1
- import{appendFile as u,readFile as a,rename as d,writeFile as p}from"node:fs/promises";import{mkdir as f}from"node:fs/promises";import{homedir as m}from"node:os";import{dirname as l,resolve as y}from"node:path";function c(){return y(m(),".cachly","ambient-ledger.jsonl")}function v(e){return JSON.stringify({ts:e.ts,event:e.event,injected:Math.max(0,Math.round(e.injected)),prevented:Math.max(0,Math.round(e.prevented)),...e.note?{note:e.note.slice(0,200)}:{}})}function h(e){const n=[];for(const r of e.split(`
2
- `)){const o=r.trim();if(o)try{const t=JSON.parse(o);if(typeof t!="object"||t===null)continue;const i=Number(t.injected),s=Number(t.prevented);if(!Number.isFinite(i)||!Number.isFinite(s))continue;n.push({ts:typeof t.ts=="string"?t.ts:"",event:typeof t.event=="string"?t.event:"unknown",injected:Math.max(0,i),prevented:Math.max(0,s),...typeof t.note=="string"?{note:t.note}:{}})}catch{}}return n}const E=256*1024,j=400;async function L(e,n=c()){try{await f(l(n),{recursive:!0}),await u(n,v(e)+`
3
- `,"utf-8");const r=await a(n,"utf-8");if(Buffer.byteLength(r,"utf-8")>E){const t=r.split(`
4
- `).filter(Boolean).slice(-j).join(`
1
+ import{appendFile as u,readFile as a,rename as d,writeFile as f}from"node:fs/promises";import{mkdir as p}from"node:fs/promises";import{homedir as l}from"node:os";import{dirname as m,resolve as h}from"node:path";function N(e,n){if(!n)return{eigene:e,ohneInstanz:0,andereInstanzen:0};const r=new Set;let o=0;const t=[];for(const i of e)i.instanz?i.instanz===n?t.push(i):r.add(i.instanz):o++;return{eigene:t,ohneInstanz:o,andereInstanzen:r.size}}function c(){return h(l(),".cachly","ambient-ledger.jsonl")}function y(e){return JSON.stringify({ts:e.ts,event:e.event,injected:Math.max(0,Math.round(e.injected)),prevented:Math.max(0,Math.round(e.prevented)),...e.note?{note:e.note.slice(0,200)}:{},...e.instanz?{instanz:e.instanz}:{}})}function v(e){const n=[];for(const r of e.split(`
2
+ `)){const o=r.trim();if(o)try{const t=JSON.parse(o);if(typeof t!="object"||t===null)continue;const i=Number(t.injected),s=Number(t.prevented);if(!Number.isFinite(i)||!Number.isFinite(s))continue;n.push({ts:typeof t.ts=="string"?t.ts:"",event:typeof t.event=="string"?t.event:"unknown",injected:Math.max(0,i),prevented:Math.max(0,s),...typeof t.note=="string"?{note:t.note}:{},...typeof t.instanz=="string"&&t.instanz?{instanz:t.instanz}:{}})}catch{}}return n}const z=256*1024,g=400;async function b(e,n=c()){try{await p(m(n),{recursive:!0}),await u(n,y(e)+`
3
+ `,"utf-8");const r=await a(n,"utf-8");if(Buffer.byteLength(r,"utf-8")>z){const t=r.split(`
4
+ `).filter(Boolean).slice(-g).join(`
5
5
  `)+`
6
- `,i=n+".tmp";await p(i,t,"utf-8"),await d(i,n)}}catch{}}async function N(e=c()){try{return h(await a(e,"utf-8"))}catch{return[]}}function M(e,n,r=fetch){return!e.instanceId||!e.jwt||process.env.CACHLY_NO_TELEMETRY==="1"?Promise.resolve():r(`${e.apiUrl}/api/v1/instances/${e.instanceId}/ambient-events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.jwt}`},body:JSON.stringify({events:[n]}),signal:AbortSignal.timeout(3e3)}).then(()=>{},()=>{})}export{L as appendLedgerEntry,c as defaultLedgerPath,h as parseLedger,N as readLedger,M as reportLedgerEntry,v as serializeEntry};
6
+ `,i=n+".tmp";await f(i,t,"utf-8"),await d(i,n)}}catch{}}async function L(e=c()){try{return v(await a(e,"utf-8"))}catch{return[]}}function I(e,n,r=fetch){return!e.instanceId||!e.jwt||process.env.CACHLY_NO_TELEMETRY==="1"?Promise.resolve():r(`${e.apiUrl}/api/v1/instances/${e.instanceId}/ambient-events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.jwt}`},body:JSON.stringify({events:[n]}),signal:AbortSignal.timeout(3e3)}).then(()=>{},()=>{})}export{b as appendLedgerEntry,c as defaultLedgerPath,v as parseLedger,L as readLedger,I as reportLedgerEntry,y as serializeEntry,N as teileNachInstanz};
@@ -0,0 +1,10 @@
1
+ import{existsSync as d}from"node:fs";import{mkdir as p,readFile as l,writeFile as f}from"node:fs/promises";import{dirname as m,resolve as h}from"node:path";import{GEMINI_SETTINGS_DATEI as x}from"./ambient-hooks.js";const a=".codex/config.toml",y="npx",g=["-y","@cachly-dev/mcp-server@latest"],i=n=>JSON.stringify(n),O=/^[A-Za-z0-9_-]+$/,_=/^\s*\[\[?[^[\],]+\]\]?\s*(?:#.*)?$/,w=/^\s*\[\s*mcp_servers\s*\.\s*(?:cachly|"cachly"|'cachly')\s*(?:\.[^\]]*)?\]\s*(?:#.*)?$/,C=/^\s*(?:mcp_servers\s*\.\s*)?["']?cachly["']?\s*(?:\.|=)/m;function N(n){const c=Object.entries(n).map(([t,e])=>{if(!O.test(t))throw new Error(`env name not usable as a TOML key: ${t}`);return`${t} = ${i(e)}`});return["[mcp_servers.cachly]",`command = ${i(y)}`,`args = [${g.map(i).join(", ")}]`,`env = { ${c.join(", ")} }`].join(`
2
+ `)}function A(n){const c=[];let t=!1,e=!1;for(const r of n.replace(/\r\n/g,`
3
+ `).split(`
4
+ `)){if(_.test(r)&&(t=w.test(r),t)){e=!0;continue}t||c.push(r)}const s=c.join(`
5
+ `).replace(/\s+$/,"");return{rest:s?s+`
6
+ `:"",entfernt:e}}function $(n,c){const t=N(c),e=n.replace(/\r\n/g,`
7
+ `),{rest:s}=A(e);if(C.test(s))return{grund:'has a "cachly" server in a form cachly does not rewrite (inline table or dotted key)'};const r=(s?s+`
8
+ `:"")+t+`
9
+ `;return{text:r,changed:r!==e}}async function J(n,c){const t=h(n,a),e=d(t)?await l(t,"utf-8"):"",s=e.charCodeAt(0)===65279?e.slice(1):e,r=$(s,c);return"grund"in r?{datei:a,status:"skipped",grund:r.grund}:r.changed?(await p(m(t),{recursive:!0}),await f(t,r.text,"utf-8"),{datei:a,status:e?"updated":"written"}):{datei:a,status:"unchanged"}}const S=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);async function L(n,c){const t=x,e=h(n,t),s=d(e)?await l(e,"utf-8"):"",r=s.charCodeAt(0)===65279?s.slice(1):s;let o;try{o=r.trim()?JSON.parse(r):{}}catch{const v=/^\s*\/\/|\/\*/m.test(r)?"has comments, and cachly only rewrites plain JSON":"is not valid JSON";return{datei:t,status:"skipped",grund:v}}if(!S(o))return{datei:t,status:"skipped",grund:"is not a JSON object"};if(o.mcpServers!==void 0&&!S(o.mcpServers))return{datei:t,status:"skipped",grund:'has a "mcpServers" field that is not an object'};const E={command:y,args:[...g],env:c},u={...o,mcpServers:{...o.mcpServers??{},cachly:E}};return JSON.stringify(u)===JSON.stringify(o)?{datei:t,status:"unchanged"}:(await p(m(e),{recursive:!0}),await f(e,JSON.stringify(u,null,2)+`
10
+ `,"utf-8"),{datei:t,status:s?"updated":"written"})}export{a as CODEX_CONFIG_DATEI,N as codexMcpBlock,J as installCodexMcp,L as installGeminiMcp,A as ohneCodexMcpEintrag,$ as setzeCodexMcpEintrag};