@cachly-dev/mcp-server 0.10.257 → 0.10.259

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,7 +1,7 @@
1
- import{existsSync as c,mkdirSync as a,readFileSync as f,writeFileSync as p}from"node:fs";import{homedir as b}from"node:os";import{dirname as h,join as m}from"node:path";const i=3;function s(){return m(b(),".cachly","kostproben.json")}function u(r){try{if(!c(r))return{};const e=JSON.parse(f(r,"utf-8"));if(e&&typeof e=="object"&&!Array.isArray(e)){const t={};for(const[n,o]of Object.entries(e))typeof o=="number"&&Number.isFinite(o)&&o>=0&&(t[n]=o);return t}return{}}catch{return{}}}function l(r,e=s()){return u(e)[r]??0}function x(r,e=s()){return l(r,e)<i}function S(r,e=s()){const t=u(e),n=(t[r]??0)+1;try{t[r]=n,a(h(e),{recursive:!0}),p(e,JSON.stringify(t,null,2)+`
1
+ import{existsSync as f,mkdirSync as p,readFileSync as b,writeFileSync as h}from"node:fs";import{homedir as c}from"node:os";import{dirname as m,join as u}from"node:path";const i=3;function s(){return u(c(),".cachly","kostproben.json")}function x(r){const e=r.replace(/[^0-9a-fA-F-]/g,"").slice(0,36)||"ohne";return u(c(),".cachly",`kostproben-${e}.json`)}function a(r){try{if(!f(r))return{};const e=JSON.parse(b(r,"utf-8"));if(e&&typeof e=="object"&&!Array.isArray(e)){const t={};for(const[n,o]of Object.entries(e))typeof o=="number"&&Number.isFinite(o)&&o>=0&&(t[n]=o);return t}return{}}catch{return{}}}function l(r,e=s()){return a(e)[r]??0}function k(r,e=s()){return l(r,e)<i}function S(r,e=s()){const t=a(e),n=(t[r]??0)+1;try{t[r]=n,p(m(e),{recursive:!0}),h(e,JSON.stringify(t,null,2)+`
2
2
  `,"utf-8")}catch{}return n}function K(r,e,t){const n=Math.max(0,i-e);return n>0?`
3
3
 
4
4
  _Kostprobe: \`${r}\` ist eine Premium-Funktion. Noch ${n} ${n===1?"freier Lauf":"freie L\xE4ufe"} auf diesem Rechner._`:`
5
5
 
6
- _Das war deine letzte Kostprobe von \`${r}\`. Weiter geht es hier: ${t}_`}function k(r,e,t){return[`\u{1F512} **\`${r}\`** \u2014 deine ${i} Kostproben sind aufgebraucht.`,"",`Es hat dir hier schon ${i}-mal geantwortet: ${e}`,"","Dein Gratis-Ged\xE4chtnis beh\xE4lt alles andere \u2014 Abruf, Lernen, Sitzungen, Kausalgraph. F\xFCr immer.",`Weiter mit der tieferen Schicht \u2192 ${t}`].join(`
7
- `)}export{i as KOSTPROBEN_JE_WERKZEUG,s as defaultKostprobePath,K as kostprobeHinweis,x as kostprobeUebrig,S as kostprobeVerbrauchen,l as kostprobenVerbraucht,k as schrankeNachKostproben};
6
+ _Das war deine letzte Kostprobe von \`${r}\`. Weiter geht es hier: ${t}_`}function g(r,e,t){return[`\u{1F512} **\`${r}\`** \u2014 deine ${i} Kostproben sind aufgebraucht.`,"",`Es hat dir hier schon ${i}-mal geantwortet: ${e}`,"","Dein Gratis-Ged\xE4chtnis beh\xE4lt alles andere \u2014 Abruf, Lernen, Sitzungen, Kausalgraph. F\xFCr immer.",`Weiter mit der tieferen Schicht \u2192 ${t}`].join(`
7
+ `)}export{i as KOSTPROBEN_JE_WERKZEUG,s as defaultKostprobePath,K as kostprobeHinweis,x as kostprobePfadJeInstanz,k as kostprobeUebrig,S as kostprobeVerbrauchen,l as kostprobenVerbraucht,g as schrankeNachKostproben};
package/dist/src/leser.js CHANGED
@@ -1 +1 @@
1
- import{embedConfig as o}from"./embeddings.js";import{LESER_GEWICHT as a,LESER_ZEITLIMIT_MS as h}from"./rangfolge-stellschrauben.js";import{LeserSicherung as I,frageLeser as L,speicherImProzess as E}from"./leser-sicherung.js";const c=new Map;function f(e){const s=e??"";let n=c.get(s);return n||(n=new I(E()),c.set(s,n)),n}function M(e){return a<=0||(process.env.CACHLY_LESER??"").toLowerCase()in{0:1,off:1,aus:1,false:1}||!o.jwt?!1:!f(e).offen()}function _(){const e=Number(process.env.CACHLY_LESER_ZEITLIMIT_MS);return Number.isInteger(e)&&e>=1&&e<=12e4?e:h}function C(){c.clear()}async function d(e,s,n){if(!M(n?.instanceId)||s.length===0)return null;const i=await L({url:`${o.apiUrl}/api/v1/rerank`,jwt:o.jwt,frage:e,texte:s,instanceId:n?.instanceId,zeitlimitMs:n?.zeitlimitMs??_(),fetchFn:n?.fetchFn,zusatzKopf:n?.zusatzKopf},f(n?.instanceId));return i.art==="punkte"?i.scores:null}function w(e,s,n=a){const i=r=>{const t=Math.min(...r),u=Math.max(...r);return u>t?r.map(m=>(m-t)/(u-t)):r.map(()=>0)},l=i(e),p=i(s);return e.map((r,t)=>({i:t,p:l[t]+n*p[t]})).sort((r,t)=>t.p-r.p||r.i-t.i).map(r=>r.i)}export{M as leserAktiv,d as leserPunkte,C as leserSperreLoeschen,_ as leserZeitlimit,w as mischeMitLeser};
1
+ import{embedConfig as h,embedJwt as u}from"./embeddings.js";import{LESER_GEWICHT as a,LESER_ZEITLIMIT_MS as I}from"./rangfolge-stellschrauben.js";import{LeserSicherung as L,frageLeser as E,speicherImProzess as M}from"./leser-sicherung.js";const o=new Map;function f(e){const s=e??"";let n=o.get(s);return n||(n=new L(M()),o.set(s,n)),n}function _(e){return a<=0||(process.env.CACHLY_LESER??"").toLowerCase()in{0:1,off:1,aus:1,false:1}||!u()?!1:!f(e).offen()}function g(){const e=Number(process.env.CACHLY_LESER_ZEITLIMIT_MS);return Number.isInteger(e)&&e>=1&&e<=12e4?e:I}function d(){o.clear()}async function x(e,s,n){if(!_(n?.instanceId)||s.length===0)return null;const i=await E({url:`${h.apiUrl}/api/v1/rerank`,jwt:u(),frage:e,texte:s,instanceId:n?.instanceId,zeitlimitMs:n?.zeitlimitMs??g(),fetchFn:n?.fetchFn,zusatzKopf:n?.zusatzKopf},f(n?.instanceId));return i.art==="punkte"?i.scores:null}function T(e,s,n=a){const i=r=>{const t=Math.min(...r),c=Math.max(...r);return c>t?r.map(p=>(p-t)/(c-t)):r.map(()=>0)},l=i(e),m=i(s);return e.map((r,t)=>({i:t,p:l[t]+n*m[t]})).sort((r,t)=>t.p-r.p||r.i-t.i).map(r=>r.i)}export{_ as leserAktiv,x as leserPunkte,d as leserSperreLoeschen,g as leserZeitlimit,T as mischeMitLeser};
@@ -1,18 +1,18 @@
1
- const d="<!-- cachly-brain-start -->",p="<!-- cachly-brain-end -->";function f(e=""){return new RegExp(`${d}[\\s\\S]*?${p}`,e)}const m=`---
1
+ import{homedir as h}from"node:os";import{join as i,resolve as w}from"node:path";const l="<!-- cachly-brain-start -->",f="<!-- cachly-brain-end -->";function _(e=""){return new RegExp(`${l}[\\s\\S]*?${f}`,e)}const g=`---
2
2
  description: Cachly AI Brain \u2014 persistent memory protocol (recall before tasks, learn after fixes)
3
3
  alwaysApply: true
4
4
  ---
5
5
 
6
- `,y=`---
6
+ `,E=`---
7
7
  name: cachly AI Brain
8
8
  description: Persistent memory protocol (recall before tasks, learn after fixes)
9
9
  alwaysApply: true
10
10
  ---
11
11
 
12
- `,h={claude:".mcp.json",cursor:".cursor/mcp.json",windsurf:".windsurf/mcp.json",copilot:".vscode/mcp.json",continue:".continue/config.json",cline:".vscode/mcp.json",zed:".zed/settings.json"};function w(e,r,c,n,t,s){if(e.nurMitIdea&&!n(t(r,".idea")))return!1;if(e.nurMit){const i=(e.nurMit.projekt??[]).some(o=>n(t(r,o))),a=(e.nurMit.heim??[]).some(o=>n(t(c,o)));if(!i&&!a)return!1}if(s&&e.editoren&&!e.editoren.includes(s)){const i=n(t(r,...e.pfad)),a=(e.ordner??[]).some(o=>n(t(r,o)));if(!i&&!a)return!1}return!0}async function _(e,r,c){const{writeFile:n,appendFile:t,readFile:s,mkdir:i}=await import("node:fs/promises"),{existsSync:a}=await import("node:fs"),{dirname:o}=await import("node:path");if(await i(o(e),{recursive:!0}),a(e)){const u=await s(e,"utf-8");if(u.includes(d)){const l=u.replace(f(),()=>r);return l===u?"unchanged":(await n(e,l,"utf-8"),"updated")}return await t(e,`
12
+ `,x={claude:".mcp.json",cursor:".cursor/mcp.json",windsurf:".windsurf/mcp.json",copilot:".vscode/mcp.json",continue:".continue/config.json",cline:".vscode/mcp.json",zed:".zed/settings.json"},D=["windsurf","cline"];function m(e){return e.plattform==="win32"?i(e.appData??i(e.heim,"AppData","Roaming"),"Code","User"):e.plattform==="darwin"?i(e.heim,"Library","Application Support","Code","User"):i(e.heim,".config","Code","User")}const y=["globalStorage","saoudrizwan.claude-dev"];function A(e,r){return e==="windsurf"?i(r.heim,".codeium","windsurf","mcp_config.json"):e==="cline"?i(m(r),...y,"settings","cline_mcp_settings.json"):null}function j(e,r,t){return e==="windsurf"?t(i(r.heim,".codeium","windsurf")):e==="cline"?t(i(m(r),...y)):!1}function R(){return{heim:h(),plattform:process.platform,appData:process.env.APPDATA}}const T="mcpServers";function k(e,r,t=R()){const n=A(e,t);if(n){const s=n.startsWith(t.heim)?"~"+n.slice(t.heim.length):n;return{pfad:n,anzeige:s,format:T}}const o=x[e]??".mcp.json";return{pfad:w(r,o),anzeige:o,format:e}}function N(e,r,t,n,o,s){if(e.nurMitIdea&&!n(o(r,".idea")))return!1;if(e.nurMit){const c=(e.nurMit.projekt??[]).some(a=>n(o(r,a))),u=(e.nurMit.heim??[]).some(a=>n(o(t,a)));if(!c&&!u)return!1}if(s&&e.editoren&&!e.editoren.includes(s)){const c=n(o(r,...e.pfad)),u=(e.ordner??[]).some(a=>n(o(r,a)));if(!c&&!u)return!1}return!0}async function v(e,r,t){const{writeFile:n,appendFile:o,readFile:s,mkdir:c}=await import("node:fs/promises"),{existsSync:u}=await import("node:fs"),{dirname:a}=await import("node:path");if(await c(a(e),{recursive:!0}),u(e)){const p=await s(e,"utf-8");if(p.includes(l)){const d=p.replace(_(),()=>r);return d===p?"unchanged":(await n(e,d,"utf-8"),"updated")}return await o(e,`
13
13
  `+r+`
14
- `,"utf-8"),"appended"}return await n(e,(c??"")+r+`
15
- `,"utf-8"),"written"}const E=[{pfad:["CLAUDE.md"],editoren:["claude"],ordner:[".claude"]},{pfad:["AGENTS.md"],editoren:["codex","zed"],ordner:[".codex"]},{pfad:[".github","copilot-instructions.md"],editoren:["copilot"]},{pfad:[".cursor","rules","cachly.mdc"],prefix:m,editoren:["cursor"],ordner:[".cursor"]},{pfad:[".windsurfrules"],editoren:["windsurf"],ordner:[".windsurf"]},{pfad:[".clinerules"],editoren:["cline"]},{pfad:[".aiassistant","rules","cachly.md"],nurMitIdea:!0},{pfad:["GEMINI.md"],nurMit:{projekt:[".gemini"],heim:[".gemini"]}},{pfad:[".junie","guidelines.md"],nurMit:{projekt:[".junie"]}},{pfad:[".continue","rules","cachly.md"],prefix:y,nurMit:{projekt:[".continue"],heim:[".continue"]}},{pfad:[".rules"],nurMit:{projekt:[".rules"]}},{pfad:[".cursorrules"],nurMit:{projekt:[".cursorrules"]}}];function g(e){return`${d}
14
+ `,"utf-8"),"appended"}return await n(e,(t??"")+r+`
15
+ `,"utf-8"),"written"}const C=[{pfad:["CLAUDE.md"],editoren:["claude"],ordner:[".claude"]},{pfad:["AGENTS.md"],editoren:["codex","zed"],ordner:[".codex"]},{pfad:[".github","copilot-instructions.md"],editoren:["copilot"]},{pfad:[".cursor","rules","cachly.mdc"],prefix:g,editoren:["cursor"],ordner:[".cursor"]},{pfad:[".windsurfrules"],editoren:["windsurf"],ordner:[".windsurf"]},{pfad:[".clinerules"],editoren:["cline"]},{pfad:[".aiassistant","rules","cachly.md"],nurMitIdea:!0},{pfad:["GEMINI.md"],nurMit:{projekt:[".gemini"],heim:[".gemini"]}},{pfad:[".junie","guidelines.md"],nurMit:{projekt:[".junie"]}},{pfad:[".continue","rules","cachly.md"],prefix:E,nurMit:{projekt:[".continue"],heim:[".continue"]}},{pfad:[".rules"],nurMit:{projekt:[".rules"]}},{pfad:[".cursorrules"],nurMit:{projekt:[".cursorrules"]}}];function S(e){return`${l}
16
16
  ## Cachly AI Brain \u2014 Always Active
17
17
 
18
18
  The Brain MCP server runs automatically. Instance: \`${e}\`
@@ -67,4 +67,4 @@ Report predicted failure risks to the user before proceeding.
67
67
 
68
68
  ### Half-finished code rule:
69
69
  Never commit code that does not compile. Run \`tsc --noEmit\` / \`go build ./...\` before every commit.
70
- ${p}`}export{E as ANWEISUNGS_DATEIEN,p as CLAUDE_MD_MARKER_END,d as CLAUDE_MD_MARKER_START,y as CONTINUE_RULE_FRONTMATTER,m as CURSOR_MDC_FRONTMATTER,h as EDITOR_FILES,f as blockMuster,g as buildClaudeMdBlock,_ as setzeAnweisungsblock,w as sollSchreiben};
70
+ ${f}`}export{C as ANWEISUNGS_DATEIEN,f as CLAUDE_MD_MARKER_END,l as CLAUDE_MD_MARKER_START,E as CONTINUE_RULE_FRONTMATTER,g as CURSOR_MDC_FRONTMATTER,x as EDITOR_FILES,D as GLOBALE_MCP_EDITOREN,T as MCPSERVERS_FORMAT,_ as blockMuster,S as buildClaudeMdBlock,R as diesesHeim,A as globaleMcpDatei,j as globalerEditorDa,k as mcpZiel,v as setzeAnweisungsblock,N as sollSchreiben,m as vsCodeNutzerOrdner};
@@ -0,0 +1,2 @@
1
+ import{AsyncLocalStorage as x}from"node:async_hooks";import{createHash as S}from"node:crypto";import{KERNWERKZEUGE as v}from"./werkzeug-auswahl.js";const m=new x;let w=!1;function C(t){w=t}function N(){return w}function $(){return m.getStore()}function R(t,e){return m.run(t,e)}function p(t){return S("sha256").update(t).digest("hex")}function j(t,e){return{schluessel:t,schluesselHash:p(t),instanzId:e}}function k(t,e){return`${p(t)}:${e}`}const A=256,_=/^cky_[A-Za-z0-9_-]{8,200}$/,b=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Z(t){if(t===void 0)return{art:"fehlt"};if(Array.isArray(t)){if(t.length>1)return{art:"abgelehnt",grund:"mehrfach"};if(t=t[0],t===void 0)return{art:"fehlt"}}if(t.trim()==="")return{art:"fehlt"};if(t.length>A)return{art:"abgelehnt",grund:"zu-lang"};const e=/^Bearer[ \t]+(\S+)$/i.exec(t.trim());return e?_.test(e[1])?{art:"ok",schluessel:e[1]}:{art:"abgelehnt",grund:"form"}:{art:"abgelehnt",grund:"kein-bearer"}}function G(t){if(t===void 0)return{art:"fehlt"};if(Array.isArray(t))return{art:"abgelehnt"};const e=t.trim();return e===""?{art:"fehlt"}:e.length>36||!b.test(e)?{art:"abgelehnt"}:{art:"ok",instanzId:e.toLowerCase()}}class y{opt;eintraege=new Map;jetzt;constructor(e){this.opt=e,this.jetzt=e.jetzt??Date.now}get groesse(){return this.eintraege.size}has(e){return this.get(e)!==void 0}get(e){const n=this.eintraege.get(e);if(n){if(n.bis<=this.jetzt()){this.eintraege.delete(e),this.opt.beiEntfernen?.(n.wert,"abgelaufen");return}return this.eintraege.delete(e),this.eintraege.set(e,n),n.wert}}set(e,n,i=this.opt.ttlMs){const a=this.eintraege.get(e);for(a&&a.wert!==n&&this.opt.beiEntfernen?.(a.wert,"geloescht"),this.eintraege.delete(e),this.eintraege.set(e,{wert:n,bis:this.jetzt()+i});this.eintraege.size>this.opt.max;){const h=this.eintraege.keys().next().value;if(h===void 0)break;const f=this.eintraege.get(h);this.eintraege.delete(h),f&&this.opt.beiEntfernen?.(f.wert,"verdraengt")}}vergiss(e){this.eintraege.delete(e)}vergissWenn(e,n){this.eintraege.get(e)?.wert===n&&this.eintraege.delete(e)}werte(){return[...this.eintraege.values()].map(e=>e.wert)}leeren(){for(const e of this.eintraege.values())this.opt.beiEntfernen?.(e.wert,"geloescht");this.eintraege.clear()}}class o extends Error{httpStatus;constructor(e,n){super(n),this.httpStatus=e,this.name="ZugangAbgelehnt"}}const z=10*6e4,E=200,D=6e4,I=1e3;function T(t,e){const n=e?.jetzt,i=new y({max:E,ttlMs:z,jetzt:n}),a=new y({max:I,ttlMs:D,jetzt:n}),h=new Map;async function f(d,l){if(l){const r=await t(`/api/v1/instances/${l}`,d);if(r.status===200)return l;throw r.status===401?new o(401,"Der Schluessel wurde abgelehnt (ungueltig, abgelaufen oder widerrufen)."):r.status===403||r.status===404?new o(403,"Dieser Schluessel gilt nicht fuer die angegebene Instanz (Kopf X-Cachly-Instance)."):new o(502,`Die cachly-API antwortete mit ${r.status}; bitte spaeter erneut versuchen.`)}const s=await t("/api/v1/instances",d);if(s.status===401)throw new o(401,"Der Schluessel wurde abgelehnt (ungueltig, abgelaufen oder widerrufen).");if(s.status===403)throw new o(400,'Dieser Schluessel ist an ein einzelnes Brain gebunden und darf keine Instanzliste lesen. Setze den Kopf "X-Cachly-Instance: <Instanz-ID>" (die ID steht im Dashboard unter cachly.dev/instances).');if(s.status!==200)throw new o(502,`Die cachly-API antwortete mit ${s.status}; bitte spaeter erneut versuchen.`);const g=s.body?.data,c=(Array.isArray(g)?g:[]).map(r=>typeof r?.id=="string"?r.id.toLowerCase():"").filter(r=>b.test(r));if(c.length===1)return c[0];throw c.length===0?new o(400,"Zu diesem Schluessel gehoert noch kein Brain. Lege eines an: https://cachly.dev/setup-ai"):new o(400,`Zu diesem Schluessel gehoeren ${c.length} Brains. Waehle eines mit dem Kopf "X-Cachly-Instance: <Instanz-ID>" (Dashboard: cachly.dev/instances).`)}return{async loese(d,l){const s=`${p(d)}|${l??"*"}`,g=i.get(s);if(g)return g;const c=a.get(s);if(c)throw c;let r=h.get(s);return r||(r=f(d,l).then(u=>(i.set(s,u),u)).catch(u=>{throw u instanceof o&&u.httpStatus!==502&&a.set(s,u),u}).finally(()=>{h.delete(s)}),h.set(s,r)),r},leeren(){i.leeren(),a.leeren(),h.clear()}}}const P=["Dieser Remote-MCP-Server braucht deinen cachly-Schluessel, damit er DEIN Brain oeffnet.","The remote MCP server needs your cachly API key to open YOUR Brain.","","1. Schluessel holen / get a key: https://cachly.dev/setup-ai","2. Kopf setzen / set the header, zum Beispiel / for example:",' claude mcp add --transport http cachly https://mcp.cachly.dev/mcp --header "Authorization: Bearer <key>"',' (Cursor / VS Code: "url" und "headers" in der mcp.json, siehe https://cachly.dev/docs)','3. Mehrere Brains im Konto? Zusaetzlich / more than one Brain? Add: --header "X-Cachly-Instance: <instance-id>"',"","Lieber lokal, ohne Kopf: npx @cachly-dev/mcp-server@latest autopilot"].join(`
2
+ `),M=new Set(["autopilot","brain_from_git","index_project"]);function X(t){return v.includes(t)&&!M.has(t)}const L=["workspace_path","repo_path","dir","project_dir"];function H(t){return`Das Werkzeug "${t}" ist ueber den Remote-Server (mcp.cachly.dev) nicht verfuegbar: es liest Dateien auf deinem Rechner oder gehoert nicht zu den Kernwerkzeugen. Lokal geht es: npx @cachly-dev/mcp-server@latest autopilot. / "${t}" is not available on the remote server; run the local server for it.`}function O(t,e){const n=t.instance_id;if(typeof n=="string"&&n.trim()!==""&&n.trim().toLowerCase()!==e)return{fehler:"Die Instanz in instance_id ist nicht die, die dieser Schluessel freigibt. Lass instance_id weg: dieser Server nimmt immer das Brain des Schluessels (oder des Kopfs X-Cachly-Instance)."};const i={...t};for(const a of L)delete i[a];return i.instance_id=e,{args:i}}export{I as ABLEHNUNG_MAX,D as ABLEHNUNG_TTL_MS,P as ANLEITUNG_OHNE_KOPF,y as BegrenzterSpeicher,A as MAX_AUTH_KOPF,M as NUR_LOKAL_WERKZEUGE,L as PFAD_ARGUMENTE,E as ZUGANG_MAX,z as ZUGANG_TTL_MS,o as ZugangAbgelehnt,j as baueKontext,T as baueZugangsAufloeser,O as bereinigeArgumente,p as hashDesSchluessels,R as imMandant,N as istMehrmandant,X as istRemoteErlaubt,Z as leseBearer,G as leseInstanzKopf,$ as mandantKontext,H as nurLokalText,k as poolSchluessel,C as setzeMehrmandant};