@cachly-dev/mcp-server 0.10.175 → 0.10.177
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/dist/src/bedeutung.js +2 -2
- package/dist/src/einblendung.js +6 -6
- package/dist/src/embeddings.js +4 -4
- package/dist/src/handlers/brain.js +17 -17
- package/dist/src/handlers/fedbrain.js +5 -5
- package/dist/src/handlers/share.js +8 -8
- package/dist/src/index.js +104 -104
- package/dist/src/leser-sicherung.js +1 -0
- package/dist/src/leser.js +1 -1
- package/dist/src/startwissen.js +11 -0
- package/dist/src/zugang.js +3 -3
- package/glama.json +1 -1
- package/hooks/cachly-ambient-einblendung.mjs +17 -17
- package/package.json +1 -1
- package/server.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as p,writeFileSync as g,renameSync as m,mkdirSync as S,rmSync as y}from"node:fs";import{dirname as d}from"node:path";const o=3,c=10*6e4,h={fehlschlaege:0,offenBis:0};function f(){return["0","off","aus","false"].includes(String(process.env.CACHLY_LESER_SICHERUNG??"").toLowerCase())}function E(e){return e===503?"abgeschaltet":e>=500?"fehlschlag":"neutral"}function b(e){return e?.name==="SyntaxError"?"neutral":"fehlschlag"}function l(e){const t=e??{},r=s=>typeof s=="number"&&Number.isFinite(s)&&s>0?s:0;return{fehlschlaege:Math.floor(r(t.fehlschlaege)),offenBis:r(t.offenBis)}}class A{speicher;jetzt;constructor(t,r=()=>Date.now()){this.speicher=t,this.jetzt=r}offen(){if(f())return!1;const t=this.speicher.lies();if(t.fehlschlaege<o)return!1;const r=this.jetzt();return r<t.offenBis&&t.offenBis-r<=c}darfFragen(){if(f())return!0;if(this.offen())return!1;const t=this.speicher.lies();return t.fehlschlaege>=o&&this.speicher.schreib({fehlschlaege:t.fehlschlaege,offenBis:this.jetzt()+c}),!0}melde(t){if(t==="neutral"||f())return;const r=this.speicher.lies();if(t==="erfolg"){(r.fehlschlaege!==0||r.offenBis!==0)&&this.speicher.schreib({...h});return}const s=t==="abgeschaltet"?Math.max(r.fehlschlaege+1,o):r.fehlschlaege+1;this.speicher.schreib({fehlschlaege:s,offenBis:s>=o?this.jetzt()+c:0})}}const a={art:"ohne"};async function N(e,t){if(!t.darfFragen())return{art:"uebersprungen"};const r=e.fetchFn??fetch;try{const s=await r(e.url,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.jwt}`,...e.zusatzKopf??{}},body:JSON.stringify({query:e.frage,texts:e.texte,instance_id:e.instanceId}),signal:AbortSignal.timeout(e.zeitlimitMs)});if(!s.ok)return t.melde(E(s.status)),a;const i=await s.json(),n=Array.isArray(i?.scores)?i.scores:null;return!n||n.length!==e.texte.length||!n.every(u=>typeof u=="number"&&Number.isFinite(u))?a:(t.melde("erfolg"),{art:"punkte",scores:n,provider:typeof i.provider=="string"?i.provider:"?",ms:Number(i.ms)||0})}catch(s){return t.melde(b(s)),a}}function j(){let e={...h};return{lies:()=>({...e}),schreib:t=>{e=l(t)}}}function B(e){return{lies:()=>{try{return l(JSON.parse(p(e,"utf8")))}catch{return{...h}}},schreib:t=>{const r=`${e}.${process.pid}.tmp`;try{S(d(e),{recursive:!0}),g(r,JSON.stringify(l(t)),{mode:384}),m(r,e)}catch{try{y(r,{force:!0})}catch{}}}}}export{o as LESER_SICHERUNG_FEHLSCHLAEGE,c as LESER_SICHERUNG_PAUSE_MS,A as LeserSicherung,B as dateiSpeicher,N as frageLeser,b as leserErgebnisAusFehler,E as leserErgebnisAusStatus,f as sicherungAbgeschaltet,j as speicherImProzess};
|
package/dist/src/leser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{embedConfig as
|
|
1
|
+
import{embedConfig as o}from"./embeddings.js";import{LESER_GEWICHT as f,LESER_ZEITLIMIT_MS as h}from"./rangfolge-stellschrauben.js";import{LeserSicherung as L,frageLeser as I,speicherImProzess as z}from"./leser-sicherung.js";const c=new Map;function u(t){const s=t??"";let e=c.get(s);return e||(e=new L(z()),c.set(s,e)),e}function E(t){return f<=0||(process.env.CACHLY_LESER??"").toLowerCase()in{0:1,off:1,aus:1,false:1}||!o.jwt?!1:!u(t).offen()}function d(){c.clear()}async function w(t,s,e){if(!E(e?.instanceId)||s.length===0)return null;const i=await I({url:`${o.apiUrl}/api/v1/rerank`,jwt:o.jwt,frage:t,texte:s,instanceId:e?.instanceId,zeitlimitMs:e?.zeitlimitMs??h,fetchFn:e?.fetchFn,zusatzKopf:e?.zusatzKopf},u(e?.instanceId));return i.art==="punkte"?i.scores:null}function C(t,s,e=f){const i=n=>{const r=Math.min(...n),a=Math.max(...n);return a>r?n.map(m=>(m-r)/(a-r)):n.map(()=>0)},l=i(t),p=i(s);return t.map((n,r)=>({i:r,p:l[r]+e*p[r]})).sort((n,r)=>r.p-n.p||n.i-r.i).map(n=>n.i)}export{E as leserAktiv,w as leserPunkte,d as leserSperreLoeschen,C as mischeMitLeser};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{execFile as $}from"node:child_process";import{homedir as b}from"node:os";import{basename as A,isAbsolute as I,relative as k,resolve as u}from"node:path";import{safeJsonParse as R,scanKeys as S}from"./utils.js";import{NAME_VEKTOR_PRAEFIX as N,VEKTOR_NACHTRAG as E,VEKTOR_PRAEFIX as v,packe as _,textFuerNamensVektor as T,textFuerVektor as P}from"./bedeutung.js";const w="cachly:startwissen:git",y=30,z=1500,C=1e3,D=3,x=90*86400,O=t=>new Promise(e=>setTimeout(e,t));function Z(t){for(const r of t.wurzeln??[])if(r.uri.startsWith("file:"))try{return t.dateiPfad(r.uri)}catch{}const e=t.env??{};for(const r of["CLAUDE_PROJECT_DIR","CACHLY_WORKSPACE"]){const n=(e[r]??"").trim();if(n&&!n.includes("${"))return n}return t.cwd}function F(t,e){const r=k(e,t);return r===""||!r.startsWith("..")&&!I(r)}function L(t,e){return process.platform==="win32"?t.toLowerCase()===e.toLowerCase():t===e}function M(t,e=process.env){const r=u(t),n=(e.CLAUDE_PLUGIN_ROOT??"").trim();if(n&&!n.includes("${")&&F(r,u(n)))return"plugin-ordner";if(r.split(/[\\/]+/).some(a=>a==="node_modules"||a==="_npx"))return"paketordner";const s=e.HOME||e.USERPROFILE||b();return s&&L(r,u(s))?"heimordner":""}function G(t){return new Promise(e=>{try{$("git",["rev-parse","--show-toplevel"],{cwd:t,timeout:5e3,windowsHide:!0},(r,n)=>{const s=String(n??"").trim();e(r||!s?"":u(s))})}catch{e("")}})}function K(t,e){return["","","---",`\u2139\uFE0F **cachly:** this new Brain just learned ${t} lesson${t===1?"":"s"} from the git history of \`${A(e)}\` (last ${y} commits at most). \`smart_recall\` finds them now. Tell the user once.`].join(`
|
|
2
|
+
`)}let d="";function Y(){const t=d;return d="",t}async function U(t){const e=t.protokoll??(n=>{process.stderr.write(n)}),r=t.env??process.env;try{const n=u(await t.projektOrdner()),s=await(t.gitWurzel??G)(n);if(!s)return e(`cachly: ${n} is not a git repository \u2014 the new Brain starts without git history.
|
|
3
|
+
`),{art:"kein-repo",ordner:n};const a=M(s,r);if(a)return e(`cachly: ${s} is not a user project (${a}) \u2014 no import from git history.
|
|
4
|
+
`),{art:"ausgeschlossen",ordner:s,grund:a};const i=await t.verbindung(t.instanzId);if((await S(i,"cachly:lesson:best:*",{max:1})).length>0)return e(`cachly: this Brain already has lessons \u2014 no import from git history.
|
|
5
|
+
`),{art:"hat-lektionen"};if(await i.set(w,JSON.stringify({stand:"laeuft",seit:new Date().toISOString(),ordner:s}),"NX")!=="OK")return{art:"schon-erledigt"};e(`cachly: new Brain \u2014 learning from the last ${y} commits of ${s} in the background.
|
|
6
|
+
`);const f=Date.now();try{await t.ausGit({instance_id:t.instanzId,repo_path:s,limit:y})}catch(c){const l=c instanceof Error?c.message:String(c);return await i.set(w,JSON.stringify({stand:"abgebrochen",am:new Date().toISOString(),grund:l.slice(0,200)})).catch(()=>{}),e(`cachly: import from git history failed: ${l}
|
|
7
|
+
`),{art:"fehler",grund:l}}const o=[];for(const c of await S(i,"cachly:lesson:best:*",{max:1e3})){const l=R(await i.get(c),{});(Array.isArray(l.tags)?l.tags:[]).includes("brain_from_git")&&o.push({topic:c.slice(19),lektion:l})}await i.set(w,JSON.stringify({stand:"fertig",am:new Date().toISOString(),ordner:s,lektionen:o.length})).catch(()=>{});const p=((Date.now()-f)/1e3).toFixed(1);e(`cachly: learned ${o.length} lessons from git history in ${p} s.
|
|
8
|
+
`),o.length>0&&(d=K(o.length,s));try{t.melde?.(o.length)}catch{}const g=await W(i,o,t,e);return{art:"fertig",ordner:s,lektionen:o.length,vektoren:g}}catch(n){const s=n instanceof Error?n.message:String(n);return e(`cachly: import from git history stopped: ${s}
|
|
9
|
+
`),{art:"fehler",grund:s}}}async function W(t,e,r,n){const s=r.einbetten;if(!s||e.length===0||!(r.hatEinbettung??(()=>!0))())return 0;for(const{topic:o}of e)await t.sadd(E,o).catch(()=>{});const a=r.schlafen??O,i=r.pauseMs??z;let h=0,f=0;for(const{topic:o,lektion:p}of e)try{await a(i);const g=await s(P({...p,topic:o}));g?.length&&(await t.set(`${v}${o}`,_(g),"EX",x),await t.srem(E,o),h++),await a(i);const c=await s(T(o));c?.length&&await t.set(`${N}${o}`,_(c),"EX",x),f=0}catch{if(f++,f>=D){n(`cachly: embedding service unavailable \u2014 ${e.length-h} lessons wait in the backlog; smart_recall fills them in later.
|
|
10
|
+
`);break}}return n(`cachly: search vectors for git lessons: ${h}/${e.length}.
|
|
11
|
+
`),h}const m=new Map;function Q(t){const e=m.get(t.instanzId);if(e)return e;const r=(async()=>(await(t.schlafen??O)(t.anlaufMs??C),U(t)))().catch(n=>({art:"fehler",grund:n instanceof Error?n.message:String(n)}));return m.set(t.instanzId,r),r}function q(t){return m.has(t)}async function tt(t,e){return await t.set(w,JSON.stringify({stand:e,seit:new Date().toISOString()}),"NX")==="OK"}function et(){m.clear(),d=""}export{C as ANLAUF_MS,z as EINBETT_PAUSE_MS,y as STARTWISSEN_COMMITS,w as STARTWISSEN_MARKE,et as _startwissenZuruecksetzen,M as ausschlussGrund,tt as beanspruchStartwissen,G as echteGitWurzel,Y as holeStartwissenHinweis,U as lerneAusGitGeschichte,Q as starteStartwissen,q as startwissenGestartet,K as startwissenSatz,Z as waehleProjektOrdner};
|
package/dist/src/zugang.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{istPlatzhalter as a}from"./credentials.js";function o(e){if(typeof e!="string")return"";const t=e.trim();return t&&!a(t)?t:""}const c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function
|
|
2
|
-
`)}let r=null;function
|
|
1
|
+
import{istPlatzhalter as a}from"./credentials.js";function o(e){if(typeof e!="string")return"";const t=e.trim();return t&&!a(t)?t:""}const c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function i(e){return c.test(o(e))}function u(e){return["","","---",`\u2139\uFE0F **cachly:** no API key was found, so a test Brain was created on EU servers \u2014 no sign-up. Tell the user once: it keeps working without an account (${e.tarifEndetAm&&/^\d{4}-\d{2}-\d{2}/.test(e.tarifEndetAm)?`Dev tier until ${e.tarifEndetAm.slice(0,10)}`:"14 days of Dev tier"}, then the free tier, same key). To use their own cachly account instead, run \`npx @cachly-dev/mcp-server@latest autopilot\` \u2014 that account gets a new Brain; lessons from this test Brain do not move over yet.`].join(`
|
|
2
|
+
`)}let r=null;function f(){r=null}async function d(e){if(e.schluessel)return e.werkzeug();if(i(e.konfigurierteInstanz)||i(e.aufrufInstanz))return e.anmelden();const t=r===null;t&&(r=e.holeSofortTest());const n=await r;if(!n)return e.anmelden();if(!t)return e.werkzeug();e.ablagen.setzeSchluessel(n.apiKey),e.ablagen.setEmbedJwt(n.apiKey),e.ablagen.saveApiKey(n.apiKey),e.ablagen.merkeInstanz(n.instanzId),await e.ablagen.persistApiKeyToConfig(n.apiKey),await e.ablagen.persistInstanceIdToConfig(n.instanzId),e.meldeEreignis("instant_trial_started",{tool:e.werkzeugName,instance_id:n.instanzId}),(e.protokoll??(s=>{process.stderr.write(s)}))(`
|
|
3
3
|
cachly: no API key found \u2014 created a test Brain on EU servers (instance ${n.instanzId}).
|
|
4
4
|
cachly: the key is stored in ~/.cachly/credentials.json. Own account: npx @cachly-dev/mcp-server@latest autopilot
|
|
5
5
|
|
|
6
|
-
`)
|
|
6
|
+
`);try{return await e.werkzeug()+u(n)}finally{try{e.neuesBrain?.(n.instanzId)}catch{}}}export{f as _zugangZuruecksetzen,o as echterWert,i as istInstanzKennung,d as sichereZugang,u as sofortTestHinweis};
|