@cachly-dev/mcp-server 0.10.240 → 0.10.242

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.
@@ -1 +1 @@
1
- import{readdirSync as f,readFileSync as l}from"node:fs";import{homedir as k}from"node:os";import{join as n}from"node:path";import{readInstanceId as d,resolveApiKey as j}from"./credentials.js";import{echterWert as a}from"./zugang.js";function E(o=process.env){return{env:o,heim:o.HOME||o.USERPROFILE||k(),projekt:o.CLAUDE_PROJECT_DIR||process.cwd()}}function i(o){try{return JSON.parse(l(o,"utf8"))}catch{return null}}function u(o){return[n(o.heim,".claude","mcp.json"),n(o.projekt,".mcp.json"),n(o.heim,".cursor","mcp.json"),n(o.heim,".codeium","windsurf","mcp_config.json")].map(e=>{const r=i(e)?.mcpServers?.cachly?.env;return r&&typeof r=="object"?r:{}})}function h(...o){for(const e of o){const r=a(e);if(r)return r}return""}function g(o){return h(o.env.CLAUDE_PLUGIN_OPTION_API_KEY,j({env:o.env,home:o.heim,cwd:o.projekt}),...u(o).map(e=>e.CACHLY_JWT))}function v(o){return h(o.env.CLAUDE_PLUGIN_OPTION_INSTANCE_ID,o.env.CACHLY_BRAIN_INSTANCE_ID,d({home:o.heim}),...u(o).map(e=>e.CACHLY_BRAIN_INSTANCE_ID))}function N(o){const e=a(o.env.CLAUDE_PLUGIN_ROOT);if(!e)return"unbekannt";const r=i(n(e,".claude-plugin","plugin.json"))?.version;return typeof r=="string"&&/^\d[0-9A-Za-z.+-]{0,30}$/.test(r)?r:"unbekannt"}const m="cachly-ambient-";function H(o){return[n(o.projekt,".cursor","hooks.json"),n(o.heim,".cursor","hooks.json")].some(e=>{const r=i(e)?.hooks;return!!r&&typeof r=="object"&&Object.values(r).some(t=>Array.isArray(t)&&t.some(s=>String(s?.command??"").includes(m)))})}function A(o){const e=o;return[e?.command,e?.bash,e?.powershell].some(r=>String(r??"").includes(m))}function L(o){const e=o.env.COPILOT_HOME?n(o.env.COPILOT_HOME,"hooks"):n(o.heim,".copilot","hooks");return[n(o.projekt,".github","hooks"),e].some(r=>{let t;try{t=f(r).filter(s=>s.endsWith(".json"))}catch{return!1}return t.some(s=>{const c=i(n(r,s))?.hooks;return!!c&&typeof c=="object"&&Object.values(c).some(p=>Array.isArray(p)&&p.some(A))})})}function S(o,e){return[n(e.projekt,".claude","settings.json"),n(e.projekt,".claude","settings.local.json"),n(e.heim,".claude","settings.json")].some(r=>{const t=i(r)?.hooks?.[o];return Array.isArray(t)&&t.some(s=>Array.isArray(s?.hooks)&&s.hooks.some(c=>String(c?.command??"").includes(m)))})}export{m as PROJEKT_HOOK_MARKE,L as copilotHatHook,H as cursorHatHook,v as findeInstanz,g as findeSchluessel,E as hookUmfeld,A as istCachlyEintrag,N as pluginVersion,S as projektHatHook};
1
+ import{readdirSync as l,readFileSync as f}from"node:fs";import{homedir as k}from"node:os";import{join as n}from"node:path";import{readInstanceId as d,resolveApiKey as j}from"./credentials.js";import{echterWert as u}from"./zugang.js";function H(o=process.env){return{env:o,heim:o.HOME||o.USERPROFILE||k(),projekt:o.CLAUDE_PROJECT_DIR||process.cwd()}}function i(o){try{return JSON.parse(f(o,"utf8"))}catch{return null}}function a(o){return[n(o.heim,".claude","mcp.json"),n(o.projekt,".mcp.json"),n(o.heim,".cursor","mcp.json"),n(o.heim,".codeium","windsurf","mcp_config.json")].map(e=>{const r=i(e)?.mcpServers?.cachly?.env;return r&&typeof r=="object"?r:{}})}function h(...o){for(const e of o){const r=u(e);if(r)return r}return""}function v(o){return h(o.env.CLAUDE_PLUGIN_OPTION_API_KEY,j({env:o.env,home:o.heim,cwd:o.projekt}),...a(o).map(e=>e.CACHLY_JWT))}function N(o){return h(o.env.CLAUDE_PLUGIN_OPTION_INSTANCE_ID,o.env.CACHLY_BRAIN_INSTANCE_ID,d({home:o.heim}),...a(o).map(e=>e.CACHLY_BRAIN_INSTANCE_ID))}function b(o){const e=u(o.env.CLAUDE_PLUGIN_ROOT);if(!e)return"unbekannt";const r=i(n(e,".claude-plugin","plugin.json"))?.version;return typeof r=="string"&&/^\d[0-9A-Za-z.+-]{0,30}$/.test(r)?r:"unbekannt"}const m="cachly-ambient-";function L(o){return[n(o.projekt,".cursor","hooks.json"),n(o.heim,".cursor","hooks.json")].some(e=>{const r=i(e)?.hooks;return!!r&&typeof r=="object"&&Object.values(r).some(t=>Array.isArray(t)&&t.some(s=>String(s?.command??"").includes(m)))})}function _(o){const e=o;return[e?.command,e?.bash,e?.powershell].some(r=>String(r??"").includes(m))}function P(o){const e=o.env.COPILOT_HOME?n(o.env.COPILOT_HOME,"hooks"):n(o.heim,".copilot","hooks");return[n(o.projekt,".github","hooks"),e].some(r=>{let t;try{t=l(r).filter(s=>s.endsWith(".json"))}catch{return!1}return t.some(s=>{const c=i(n(r,s))?.hooks;return!!c&&typeof c=="object"&&Object.values(c).some(p=>Array.isArray(p)&&p.some(_))})})}function S(o,e){return[n(e.projekt,".claude","settings.json"),n(e.projekt,".claude","settings.local.json"),n(e.heim,".claude","settings.json")].some(r=>{const t=i(r)?.hooks?.[o];return Array.isArray(t)&&t.some(s=>Array.isArray(s?.hooks)&&s.hooks.some(c=>O(String(c?.command??""))))})}const A=/tools[\\/]+ambient-recall[\\/]+(session-start|user-prompt-submit|stop)\.mjs/;function O(o){return o.includes(m)||A.test(o)}export{m as PROJEKT_HOOK_MARKE,P as copilotHatHook,L as cursorHatHook,N as findeInstanz,v as findeSchluessel,H as hookUmfeld,_ as istCachlyEintrag,b as pluginVersion,S as projektHatHook};
@@ -0,0 +1,7 @@
1
+ import{spawn as d}from"node:child_process";import{existsSync as O,mkdirSync as l,readdirSync as I,readFileSync as h,renameSync as L,rmSync as a,statSync as E,writeFileSync as g}from"node:fs";import{homedir as C}from"node:os";import{dirname as T,join as i,resolve as x}from"node:path";import{fileURLToPath as D,pathToFileURL as M}from"node:url";const y="@cachly-dev/mcp-server",N="--auffrischen",z=3600*1e3,$=600*1e3,A=2e4,p=/^\d+\.\d+\.\d+$/,b=process.platform==="win32";function _(e=process.env){const t=e.CACHLY_SERVER_ORDNER?.trim();return t||i(e.HOME||e.USERPROFILE||C(),".cachly","server")}function k(e,t){return i(e,"fassungen",t)}function w(e,t){try{const r=JSON.parse(h(i(e,"package.json"),"utf8"));if(r.version!==t)return null;const s=typeof r.bin=="string"?r.bin:r.bin?.["cachly-mcp"],n=x(e,s??r.main??"dist/src/index.js");return O(n)?n:null}catch{return null}}function S(e){return i(e,"node_modules","@cachly-dev","mcp-server")}function F(e){try{const t=JSON.parse(h(i(e,"stand.json"),"utf8"));if(typeof t.fassung!="string"||!p.test(t.fassung))return null;const r=w(S(k(e,t.fassung)),t.fassung);return r?{fassung:t.fassung,datei:r}:null}catch{return null}}function R(e,t){for(let r=1;;r++)try{L(e,t);return}catch(s){const n=s.code;if(r>=6||n!=="EPERM"&&n!=="EBUSY"&&n!=="EACCES")throw s;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100*r)}}function v(e,t){l(T(e),{recursive:!0});const r=`${e}.${process.pid}.${Date.now()}`;g(r,t,"utf8");try{R(r,e)}catch(s){throw a(r,{force:!0}),s}}function j(e,t=Date.now()){try{const{at:r}=JSON.parse(h(i(e,"pruefung.json"),"utf8"));return typeof r!="number"||t-r>=z||r>t}catch{return!0}}function H(e,t){const r=i(e,"holt.sperre");l(e,{recursive:!0});for(let s=0;s<2;s++)try{return g(r,String(process.pid),{flag:"wx"}),()=>a(r,{force:!0})}catch{try{if(t-E(r).mtimeMs<$)return null;a(r,{force:!0})}catch{return null}}return null}function J(e,t,r=Date.now()){const s=i(e,"fassungen");let n;try{n=I(s)}catch{return}for(const o of n){if(t.includes(o))continue;const u=i(s,o);try{if(o.startsWith(".neu-")&&r-E(u).mtimeMs<$)continue;a(u,{recursive:!0,force:!0})}catch{}}}async function B(e,t){const r=t.jetzt?.()??Date.now();if(!j(e,r))return"nicht dran";const s=H(e,r);if(!s)return"ein anderer Nebenlauf holt gerade";try{v(i(e,"pruefung.json"),`${JSON.stringify({at:r})}
2
+ `);const n=await t.holeNeueste();if(!n||!p.test(n))return"npm gab keine Fassung";const o=F(e);if(o?.fassung===n)return`aktuell (${n})`;const u=k(e,n);if(!w(S(u),n)){const c=i(e,"fassungen",`.neu-${n}-${process.pid}`);if(a(c,{recursive:!0,force:!0}),l(c,{recursive:!0}),g(i(c,"package.json"),`{ "private": true }
3
+ `,"utf8"),await t.installiere(c,n),!w(S(c),n))return a(c,{recursive:!0,force:!0}),`Installation von ${n} unvollstaendig`;a(u,{recursive:!0,force:!0}),R(c,u)}return v(i(e,"stand.json"),`${JSON.stringify({fassung:n})}
4
+ `),J(e,[n,o?.fassung],r),`geholt (${o?.fassung??"keine"} -> ${n})`}catch(n){return`Fehler: ${n.message}`}finally{s()}}function P(e,t,r){return new Promise((s,n)=>{const o=d("npm",e,{cwd:t,shell:b,windowsHide:!0,stdio:["ignore","pipe","ignore"]});let u="";o.stdout?.on("data",f=>{u+=String(f)});const c=setTimeout(()=>{o.kill(),n(new Error(`npm ${e[0]}: Zeitgrenze`))},r);o.on("error",f=>{clearTimeout(c),n(f)}),o.on("exit",f=>{clearTimeout(c),f===0?s(u):n(new Error(`npm ${e[0]}: Ende mit ${f}`))})})}const W=e=>({holeNeueste:async()=>{l(e,{recursive:!0});const t=(await P(["view",`${y}@latest`,"version"],e,3e4)).trim();return p.test(t)?t:null},installiere:async(t,r)=>{if(!p.test(r))throw new Error("ungueltige Fassung");await P(["install",`${y}@${r}`,"--omit=dev","--ignore-scripts","--no-audit","--no-fund","--no-package-lock","--loglevel=error"],t,5*6e4)}});function G(e){try{const t=d(process.execPath,[e,N],{detached:!0,stdio:"ignore",windowsHide:!0,env:process.env});t.on("error",()=>{}),t.unref()}catch{}}function U(){const e=d("npx",["-y",y],{stdio:"inherit",shell:b,windowsHide:!0});e.on("error",t=>{process.stderr.write(`[cachly-start] npx liess sich nicht starten: ${t.message}
5
+ `),process.exit(1)}),e.on("exit",(t,r)=>process.exit(t??(r?1:0)));for(const t of["SIGINT","SIGTERM"])process.on(t,()=>e.kill(t))}async function Y(e,t=process.env){const r=_(t);if(/^(1|true|on|ja|yes)$/i.test((t.CACHLY_PLUGIN_NPX??"").trim())){U();return}j(r)&&G(e);const s=F(r);if(s)try{await import(M(s.datei).href);return}catch(n){if(process.stdin.listenerCount("data")>0)throw n;process.stderr.write(`[cachly-start] Kopie ${s.fassung} laedt nicht (${n.message}) \u2014 starte ueber npx.
6
+ `);try{a(i(r,"stand.json"),{force:!0})}catch{}}U()}async function K(e=process.env){const t=Number(e.CACHLY_NEBENLAUF_PAUSE_MS??A);await new Promise(n=>setTimeout(n,Number.isFinite(t)?t:A));const r=_(e),s=await B(r,W(r));try{v(i(r,"letzter-lauf.json"),`${JSON.stringify({at:new Date().toISOString(),ergebnis:s})}
7
+ `)}catch{}}const m=process.argv[1]?x(process.argv[1]):"",V=D(import.meta.url);m&&(m===V||m.endsWith("cachly-server-start.mjs"))&&(process.argv[2]===N?(await K().catch(()=>{}),process.exit(0)):await Y(m));export{N as AUFFRISCHEN,A as NEBENLAUF_PAUSE_MS,y as PAKET,z as PRUEF_ABSTAND_MS,$ as SPERRE_VERFALL_MS,B as auffrischen,w as einstieg,F as liesStand,W as npmWerkzeuge,j as pruefungDran,J as raeumeAuf,_ as serverOrdner,Y as starte};
package/glama.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://glama.ai/mcp/schemas/server.json",
3
- "version": "0.10.240",
3
+ "version": "0.10.242",
4
4
  "maintainers": [
5
5
  "HeinrichNebula"
6
6
  ],