@cachly-dev/mcp-server 0.10.201 → 0.10.203
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 +39 -13
- package/dist/src/ambient-hooks.js +9 -9
- package/dist/src/brain-watch-hook.js +2 -2
- package/dist/src/cls-hook.js +2 -2
- package/dist/src/index.js +172 -177
- package/dist/src/konto-anlegen.js +1 -1
- package/dist/src/projektdateien.js +6 -0
- package/dist/src/uninstall.js +16 -0
- package/glama.json +1 -1
- package/hooks/cachly-ambient-einblendung.mjs +15 -15
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{closeSync as _,existsSync as b,mkdirSync as m,openSync as w,readFileSync as I,renameSync as k,statSync as F,unlinkSync as K,writeFileSync as v,writeSync as M}from"node:fs";import{dirname as l,join as
|
|
1
|
+
import{closeSync as _,existsSync as b,mkdirSync as m,openSync as w,readFileSync as I,renameSync as k,statSync as F,unlinkSync as K,writeFileSync as v,writeSync as M}from"node:fs";import{dirname as l,join as c}from"node:path";import{credentialsPath as R,readInstanceId as L,readSavedApiKey as N,saveApiKey as j,saveInstanceId as H}from"./credentials.js";import{holeSofortTest as O,SOFORT_TEST_FRIST_MS as $}from"./sofort-test.js";const z=15e3,U=100,Z=600*1e3,D=1440*60*1e3,A="anlegen.lock",G="anlegen.fehler",y="startwissen-auftrag.json";function ee(e=process.env){return!/^(0|false|off|no|nein)$/i.test((e.CACHLY_STARTWISSEN??"").trim())}function u(e){return l(R(e))}const P=e=>new Promise(t=>setTimeout(t,e));function T(e){return{apiKey:N(e),instanzId:L(e)}}function C(e,t){try{m(l(e),{recursive:!0})}catch{return"kein-zugriff"}try{const n=w(e,"wx",384);try{M(n,`${process.pid} ${t}`)}finally{_(n)}return"ja"}catch(n){return n?.code==="EEXIST"?"belegt":"kein-zugriff"}}function h(e,t){try{return t-F(e).mtimeMs}catch{return null}}function g(e){try{K(e)}catch{}}function J(e,t=Date.now()){const n=h(c(u(e),A),t);return n!==null&&n<z}function V(e,t,n){if(t<=0)return!1;let i=null;try{const a=Number(I(e,"utf8").trim());Number.isFinite(a)&&a>0&&(i=a)}catch{}const r=i!==null?n-i:h(e,n);return r!==null&&r>=0&&r<t}function W(e,t){try{m(l(e),{recursive:!0}),v(e,String(t),{mode:384})}catch{}}async function te(e){const t=e.jetzt??Date.now,n=e.schlafen??P,i=t()+e.fristMs,r=u(e),a=c(r,A),o=c(r,G);try{for(;;){const s=T(e);if(s.apiKey&&(s.instanzId||!J(e,t())))return{art:"vorhanden",apiKey:s.apiKey,instanzId:s.instanzId};if(!s.apiKey){const p=C(a,t());if(p==="kein-zugriff")return{art:"gescheitert",grund:"kein-schreibzugriff"};if(p==="ja")try{const d=T(e);if(d.apiKey)return{art:"vorhanden",apiKey:d.apiKey,instanzId:d.instanzId};if(V(o,e.abkuehlungMs??0,t()))return{art:"gescheitert",grund:"abgekuehlt"};const x=Math.max(500,i-t()),f=await O({apiUrl:e.apiUrl,version:e.version,holen:e.holen,env:e.env,fristMs:Math.min(x,e.anfrageMs??$),speichern:E=>j(E,e)});return f?(H(f.instanzId,{...e,apiKey:f.apiKey}),g(o),{art:"angelegt",test:f}):(W(o,t()),{art:"gescheitert",grund:"kein-test"})}finally{g(a)}const S=h(a,t());S!==null&&S>=z&&g(a)}if(t()>=i)return s.apiKey?{art:"vorhanden",apiKey:s.apiKey,instanzId:s.instanzId}:{art:"gescheitert",grund:"sperre-belegt"};await n(U)}}catch{return{art:"gescheitert",grund:"kein-test"}}}function B(e){const t=e;if(!t||t.art!=="git"&&t.art!=="startvorrat")return;const n=Number(t.lektionen);return Number.isInteger(n)&&n>0?{art:t.art,lektionen:n}:void 0}function ne(e,t={}){try{const n=c(u(t),y);m(l(n),{recursive:!0});const i=`${n}.${process.pid}.tmp`;v(i,JSON.stringify({...e,am:new Date().toISOString()}),{mode:384}),k(i,n)}catch{}}function re(e={}){return b(c(u(e),y))}function ie(e={},t=Date.now()){const n=c(u(e),y),i=`${n}.${process.pid}.genommen`;try{k(n,i)}catch{return null}try{const r=JSON.parse(I(i,"utf8")),a=Date.parse(String(r?.am??""));if(!r||typeof r.instanzId!="string"||!r.instanzId||!Number.isFinite(a)||t-a>D)return null;const o=B(r.vomHook);return{instanzId:r.instanzId,projekt:typeof r.projekt=="string"?r.projekt:"",am:String(r.am),...o?{vomHook:o}:{}}}catch{return null}finally{try{K(i)}catch{}}}export{Z as ABKUEHLUNG_HOOK_MS,y as AUFTRAG,D as AUFTRAG_VERFAELLT_MS,G as FEHLSCHLAG,A as SPERRE,z as SPERRE_VERALTET_MS,U as WARTE_TAKT_MS,re as auftragLiegt,ie as nimmAuftrag,ne as schreibeAuftrag,te as sichereKonto,J as sperreLiegt,ee as startwissenEingeschaltet};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const s="<!-- cachly-brain-start -->",c="<!-- cachly-brain-end -->";function o(n=""){return new RegExp(`${s}[\\s\\S]*?${c}`,n)}const e=`---
|
|
2
|
+
description: Cachly AI Brain \u2014 persistent memory protocol (recall before tasks, learn after fixes)
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`,r={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"},t=[{pfad:["CLAUDE.md"]},{pfad:["AGENTS.md"]},{pfad:[".github","copilot-instructions.md"]},{pfad:[".cursor","rules","cachly.mdc"],prefix:e},{pfad:[".windsurfrules"]},{pfad:[".clinerules"]},{pfad:[".aiassistant","rules","cachly.md"],nurMitIdea:!0}];export{t as ANWEISUNGS_DATEIEN,c as CLAUDE_MD_MARKER_END,s as CLAUDE_MD_MARKER_START,e as CURSOR_MDC_FRONTMATTER,r as EDITOR_FILES,o as blockMuster};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{existsSync as R,lstatSync as x,readFileSync as Q,readdirSync as j,rmSync as C,rmdirSync as Z,writeFileSync as ee}from"node:fs";import{basename as b,dirname as T,isAbsolute as I,join as g,relative as H,resolve as k,sep as S}from"node:path";import{ANWEISUNGS_DATEIEN as te,CLAUDE_MD_MARKER_END as D,CLAUDE_MD_MARKER_START as N,EDITOR_FILES as ne,blockMuster as re}from"./projektdateien.js";import{PROJEKT_HOOK_MARKE as z,istCachlyEintrag as P}from"./hook-zugang.js";import{CLS_BLOCK_RE as oe}from"./cls-hook.js";import{BRAIN_WATCH_BLOCK_RE as se}from"./brain-watch-hook.js";import{CLAUDE_HOOK_DIR as ie,CLAUDE_SETTINGS_DATEI as ae,CODEX_HOOKS_DATEI as ce,CODEX_HOOK_DIR as le,COPILOT_HOOKS_DATEI as he,COPILOT_HOOK_DIR as ue,CURSOR_HOOKS_DATEI as fe,CURSOR_HOOK_DIR as de,GEMINI_HOOK_DIR as pe,GEMINI_SETTINGS_DATEI as O}from"./ambient-hooks.js";import{CURSOR_ABLAGE_ORDNER as me}from"./cursor-hook.js";import{COPILOT_ABLAGE_ORDNER as ge}from"./copilot-hook.js";import{credentialsPath as B}from"./credentials.js";import{defaultLedgerPath as L,readLedger as ye}from"./ambient-ledger.js";import{defaultMilestonePath as ke}from"./funnel-milestones.js";import{defaultKostprobePath as be}from"./kostprobe.js";import{standPfad as ve}from"./neue-fassung.js";import{AUFTRAG as je,FEHLSCHLAG as we,SPERRE as _e}from"./konto-anlegen.js";import{netBalance as Ee}from"./ambient-recall.js";import{istTestSchluessel as Se}from"./uebernahme.js";const Oe='broken Stop hook from setup_ai_memory ("checkpoint" is not a command)',M="Your lessons stay in your cachly account. uninstall never deletes cloud data. To erase your account and everything in it (GDPR Art. 17), write to privacy@cachly.dev (https://cachly.dev/legal/datenschutz).",$e=[B({home:""}),L(),ke(),be(),ve(""),_e,we,je].map(t=>b(t));function Ae(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Re=new RegExp(`^(?:${$e.map(Ae).join("|")})(?:\\.[\\w.-]*(?:tmp|genommen))?$`),xe=/^cachly-(?:ambient|leser-sicherung|lernen-arme|projektversionen|startwissen-import)-[\w.-]+\.(?:json|jsonl|lock|tmp)$/,Ce=["cachly-lernen",b(me),b(ge)];function Te(t,e){return e?Ce.includes(t):xe.test(t)}function p(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function $(t){try{const e=JSON.parse(t);return p(e)?e:null}catch{return null}}function K(t,e){const n=/^([ \t]+)"/m.exec(e)?.[1]??2,r=e.includes(`\r
|
|
2
|
+
`);let o=JSON.stringify(t,null,n);return r&&(o=o.replace(/\n/g,`\r
|
|
3
|
+
`)),/\n$/.test(e)?o+(r?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`):o}function y(t){try{return x(t).isFile()?Q(t,"utf8"):null}catch{return null}}function F(t){try{return x(t).isDirectory()}catch{return!1}}function Ie(t){if(!p(t))return"";const n=(p(t.env)?t.env:p(t.command)&&p(t.command.env)?t.command.env:null)?.CACHLY_BRAIN_INSTANCE_ID;return typeof n=="string"?n:""}function w(t,e,n){const r=t[e];return!p(r)||!("cachly"in r)?!1:(n.push(r.cachly),delete r.cachly,Object.keys(r).length===0&&delete t[e],!0)}function U(t){return p(t)?p(t.env)&&("CACHLY_JWT"in t.env||"CACHLY_BRAIN_INSTANCE_ID"in t.env)?!0:JSON.stringify(t).includes("@cachly-dev/mcp-server"):!1}function A(t,e){const n=$(t);if(!n)return{art:"unlesbar"};const r=[],o=[];if(e==="mcpServers"&&w(n,"mcpServers",r)&&o.push("mcpServers.cachly"),e==="vscode"&&(w(n,"servers",r)&&o.push("servers.cachly"),w(n,"mcpServers",r)&&o.push("mcpServers.cachly")),e==="zed"&&w(n,"context_servers",r)&&o.push("context_servers.cachly"),e==="continue"){const c=n.experimental,a=p(c)?c.modelContextProtocolServers:void 0;if(p(c)&&Array.isArray(a)){const s=a.filter(l=>!U(l));s.length<a.length&&(r.push(...a.filter(U)),o.push(`experimental.modelContextProtocolServers (${a.length-s.length})`),s.length===0?delete c.modelContextProtocolServers:c.modelContextProtocolServers=s,Object.keys(c).length===0&&delete n.experimental)}}if(o.length===0)return{art:"nichts"};const i=r.map(Ie).find(Boolean)??"";return{art:"geaendert",nachher:Object.keys(n).length===0?null:K(n,t),entfernt:o,instanz:i}}function He(t){if(P(t))return"ambient";const e=String(t?.command??"");return e.includes("@cachly-dev/mcp-server")&&e.includes(" checkpoint")?"checkpoint":null}function _(t){return P(t)?"ambient":null}function De(t,e,n=[]){const r=$(t);if(!r)return{art:"unlesbar"};const o=r.hooks;if(!p(o))return{art:"nichts"};const i=[];for(const[a,s]of Object.entries(o)){if(!Array.isArray(s))continue;const l=i.length,h=[];for(const u of s){const d=p(u)&&Array.isArray(u.hooks)?u.hooks:null;if(!d){const f=e(u);f?i.push(f):h.push(u);continue}const m=d.filter(f=>{const E=e(f);return E&&i.push(E),!E});m.length===d.length?h.push(u):m.length>0&&h.push({...u,hooks:m})}i.length!==l&&(h.length===0?delete o[a]:o[a]=h)}return i.length===0?{art:"nichts"}:(Object.keys(o).length===0&&delete r.hooks,{art:"geaendert",nachher:Object.keys(r).filter(a=>!n.includes(a)).length===0?null:K(r,t),entfernt:i,instanz:""})}function Ne(t,e,n){let r=e;t[e-1]===`
|
|
6
|
+
`&&(r=t[e-2]==="\r"?e-2:e-1);let o=n;return t[n]===`
|
|
7
|
+
`?o=n+1:t[n]==="\r"&&t[n+1]===`
|
|
8
|
+
`&&(o=n+2),r<e&&o>n&&r>0&&o<t.length&&t[r-1]!==`
|
|
9
|
+
`&&t[o]!==`
|
|
10
|
+
`&&t[o]!=="\r"&&(o=n),t.slice(0,r)+t.slice(o)}function ze(t){if(!t.includes(N)&&!t.includes(D))return{art:"kein-block"};let e=t,n=0;for(;;){const r=re().exec(e);if(!r)break;e=Ne(e,r.index,r.index+r[0].length),n++}return n===0||e.includes(N)||e.includes(D)?{art:"kaputt"}:{art:"entfernt",rest:e}}function Pe(t){const e=t.trim().split(/\r?\n/);if(e[0]?.trim()!=="---")return!1;const n=e.findIndex((r,o)=>o>0&&r.trim()==="---");return n>0&&e.slice(n+1).every(r=>r.trim()==="")}function Be(t,e){return t.trim()===""||e&&Pe(t)}function Le(t){let e=t;const n=[],r=[["CLS hook",oe],["brain_watch hook",se]];for(const[i,c]of r)for(;;){const a=c.exec(e);if(!a)break;const s=e.slice(0,a.index).replace(/\s+$/,""),l=e.slice(a.index+a[0].length).replace(/^\s*\n/,"");e=s+(s&&l.trim()?`
|
|
11
|
+
|
|
12
|
+
`:"")+l,n.push(i)}if(n.length===0)return{rest:t,entfernt:n};const o=e.trim();return o===""||o.startsWith("#!")&&!o.includes(`
|
|
13
|
+
`)?{rest:"",entfernt:n}:{rest:e.replace(/\s+$/,"")+`
|
|
14
|
+
`,entfernt:n}}function Me(t,e){const n=H(e,t);return n!==""&&!n.startsWith("..")&&!I(n)}function G(t,e,n,r){const o=new Set(t.filter(a=>a.stufe===e&&(a.aktion==="datei-loeschen"||a.aktion==="ordner-loeschen")).map(a=>a.pfad)),i=new Set;for(const a of o)for(let s=T(a);s!==r&&Me(s,n)&&!s.split(S).includes(".git");s=T(s))i.add(s);const c=[];for(const a of[...i].sort((s,l)=>l.length-s.length)){let s;try{s=j(a)}catch{continue}s.every(l=>o.has(g(a,l)))&&(o.add(a),c.push({stufe:e,aktion:"ordner-entfernen",pfad:a,was:"empty folder"}))}return c}function Ke(t,e){const n=new Map;for(const[r,o]of Object.entries(ne))n.set(o,r==="continue"?"continue":r==="zed"?"zed":o===".vscode/mcp.json"?"vscode":"mcpServers");for(const[r,o]of n){const i=k(t.projekt,r),c=y(i);if(R(`${i}.bak`)&&e.funde.push({stufe:"projekt",aktion:"melden",pfad:`${i}.bak`,was:"your old file is there; uninstall does not restore it"}),c===null)continue;const a=A(c,o);if(a.art==="unlesbar"){c.includes("cachly")&&e.vonHand.push({stufe:"projekt",text:`${r}: cannot be read as plain JSON (comments or another format). Remove the "cachly" entry by hand.`});continue}a.art!=="nichts"&&(e.instanz||=a.instanz,a.nachher===null?e.funde.push({stufe:"projekt",aktion:"datei-loeschen",pfad:i,was:'MCP server entry "cachly", the only thing in the file',vorher:c}):e.funde.push({stufe:"projekt",aktion:"eintrag-entfernen",pfad:i,was:'MCP server entry "cachly"; other servers and settings stay',vorher:c,nachher:a.nachher}))}}function Fe(t,e){for(const n of te){const r=k(t.projekt,...n.pfad),o=y(r);if(o===null)continue;const i=n.pfad.join("/"),c=ze(o);if(c.art==="kein-block"){o.startsWith("# cachly AI Brain")&&e.vonHand.push({stufe:"projekt",text:`${i}: looks like the whole file was written by the setup_ai_memory tool (no markers). Check it and remove it by hand if it is not yours.`});continue}if(c.art==="kaputt"){e.vonHand.push({stufe:"projekt",text:`${i}: a cachly marker has no partner. Remove the block by hand.`});continue}Be(c.rest,i.endsWith(".mdc"))?e.funde.push({stufe:"projekt",aktion:"datei-loeschen",pfad:r,was:"only the cachly block was in it",vorher:o}):e.funde.push({stufe:"projekt",aktion:"block-entfernen",pfad:r,was:"cachly block between the markers; your text stays as it is",vorher:o,nachher:c.rest})}}function v(t,e,n,r,o){const i=k(t.projekt,n),c=y(i);if(c===null)return;const a=De(c,r,o);if(a.art==="unlesbar"){(c.includes(z)||c.includes("@cachly-dev/mcp-server"))&&e.vonHand.push({stufe:"projekt",text:`${n}: cannot be read as plain JSON (comments or another format). Remove the cachly hooks by hand.`});return}if(a.art==="nichts")return;const s=a.entfernt.filter(u=>u==="ambient").length,l=a.entfernt.filter(u=>u==="checkpoint").length,h=[...s?[`${s} Ambient Recall hook${s===1?"":"s"}`]:[],...l?[`${l} ${Oe}`]:[]];a.nachher===null?e.funde.push({stufe:"projekt",aktion:"datei-loeschen",pfad:i,was:`${h.join(" and ")}, the only thing in the file`,vorher:c}):e.funde.push({stufe:"projekt",aktion:"eintrag-entfernen",pfad:i,was:`${h.join(" and ")}; other hooks and settings stay`,vorher:c,nachher:a.nachher})}function Ue(t,e,n){const r=k(t.projekt,n);let o;try{o=j(r)}catch{return}for(const i of o.sort()){const c=g(r,i);!i.startsWith(z)||y(c)===null||e.funde.push({stufe:"projekt",aktion:"datei-loeschen",pfad:c,was:"Ambient Recall hook script"})}}function Ge(t,e){v(t,e,ae,He,[]),v(t,e,fe,_,["version"]),v(t,e,he,_,["version"]),v(t,e,ce,_,[]),v(t,e,O,_,[]);for(const r of[ie,de,ue,le,pe])Ue(t,e,r);const n=$(y(k(t.projekt,O))??"");n&&p(n.mcpServers)&&"cachly"in n.mcpServers&&e.vonHand.push({stufe:"projekt",text:`${O}: the MCP server "cachly" (added by "gemini mcp add") stays. Remove that entry by hand.`})}function We(t,e){const n=g(t.projekt,".git");if(!R(n))return;if(!F(n)){e.vonHand.push({stufe:"projekt",text:".git is a file here (a Git worktree). cachly never writes a post-commit hook there. If you set one up in the main repository, check its .git/hooks/post-commit."});return}const r=g(n,"hooks","post-commit"),o=y(r);if(o===null)return;const i=Le(o);if(i.entfernt.length===0)return;const c=i.entfernt.join(" and ");i.rest===""?e.funde.push({stufe:"projekt",aktion:"datei-loeschen",pfad:r,was:`${c}, the only thing in the hook`,vorher:o}):e.funde.push({stufe:"projekt",aktion:"block-entfernen",pfad:r,was:`${c}; your own commands stay`,vorher:o,nachher:i.rest})}function Je(t,e){const n=g(t.heim,".claude","mcp.json"),r=y(n);if(r!==null){const s=A(r,"mcpServers");s.art==="unlesbar"&&r.includes("cachly")?e.vonHand.push({stufe:"global",text:'~/.claude/mcp.json: cannot be read as plain JSON. Remove the "cachly" entry by hand.'}):s.art==="geaendert"&&(e.instanz||=s.instanz,s.nachher===null?e.funde.push({stufe:"global",aktion:"datei-loeschen",pfad:n,was:'MCP server entry "cachly", the only thing in the file (it holds your key)',vorher:r}):e.funde.push({stufe:"global",aktion:"eintrag-entfernen",pfad:n,was:'MCP server entry "cachly" (it holds your key); other servers stay',vorher:r,nachher:s.nachher}))}for(const s of[g(t.heim,".cursor","mcp.json"),g(t.heim,".codeium","windsurf","mcp_config.json")]){const l=y(s);if(l===null)continue;const h=A(l,"mcpServers");(h.art==="geaendert"||h.art==="unlesbar"&&l.includes("cachly"))&&e.funde.push({stufe:"global",aktion:"melden",pfad:s,was:'has a "cachly" server entry. You set this file up yourself, so uninstall leaves it. Remove the entry by hand.'})}const o=g(t.heim,".cachly");let i=[];try{i=j(o)}catch{}const c=[];for(const s of i.sort()){const l=g(o,s);if(Re.test(s)&&y(l)!==null){const h=s===b(B({home:""}))?"your key and Brain id; other projects on this computer lose their access":"cachly data on this computer";e.funde.push({stufe:"global",aktion:"datei-loeschen",pfad:l,was:h})}else c.push(s)}c.length>0&&e.vonHand.push({stufe:"global",text:`~/.cachly also holds ${c.join(", ")}. Not written by this package, so it stays.${c.includes("vscode-mcp.env")?" vscode-mcp.env holds your key (written by the VS Code extension): uninstall the extension, then delete it.":""}`});let a=[];try{a=j(t.tmp)}catch{}for(const s of a.sort()){if(!s.startsWith("cachly-"))continue;const l=g(t.tmp,s),h=F(l);Te(s,h)&&e.funde.push({stufe:"global",aktion:h?"ordner-loeschen":"datei-loeschen",pfad:l,was:"cache in the temp folder"})}}function Ye(t){const e={projekt:k(t.projekt),heim:k(t.heim),tmp:k(t.tmp)},n={funde:[],vonHand:[],instanz:""};return Ke(e,n),Fe(e,n),Ge(e,n),We(e,n),Je(e,n),n.funde.push(...G(n.funde,"projekt",e.projekt,e.tmp)),n.funde.push(...G(n.funde,"global",e.heim,e.tmp)),n}function W(t){return t.split(S).length}function J(t){return[...t].sort((n,r)=>{const o=i=>i.aktion==="ordner-entfernen"?1:0;return o(n)-o(r)||(o(n)?W(r.pfad)-W(n.pfad):0)}).map(n=>{if(n.aktion==="melden")return{fund:n,status:"uebersprungen",grund:"only reported"};try{return n.vorher!==void 0&&y(n.pfad)!==n.vorher?{fund:n,status:"uebersprungen",grund:"the file changed after the plan was made"}:(n.aktion==="datei-loeschen"?C(n.pfad,{force:!0}):n.aktion==="ordner-loeschen"?C(n.pfad,{recursive:!0,force:!0}):n.aktion==="ordner-entfernen"?Z(n.pfad):ee(n.pfad,n.nachher??"","utf8"),{fund:n,status:"entfernt"})}catch(r){const o=r.code==="ENOTEMPTY"?"the folder is not empty":r.message;return{fund:n,status:"uebersprungen",grund:o}}})}async function Ve(t){const e=await ye(g(t.heim,".cachly",b(L()))),n=Ee(e),r={schluessel:t.schluessel?Se(t.schluessel)?"test":"konto":"keiner",turns:e.length,injected:n.injected,prevented:n.prevented,net:n.net,lektionen:null};if(!t.schluessel||!t.instanz)return r.lektionenFehlt="no-instance",r;try{const o=await(t.fetchFn??fetch)(`${t.apiUrl}/api/v1/instances/${t.instanz}/memory`,{headers:{Authorization:`Bearer ${t.schluessel}`},signal:AbortSignal.timeout(5e3)});if(!o.ok)throw new Error(`HTTP ${o.status}`);const i=(await o.json()).lesson_count;if(typeof i!="number")throw new Error("no lesson_count");r.lektionen=i}catch{r.lektionenFehlt="unreachable"}return r}const Xe={"datei-loeschen":"delete file","ordner-loeschen":"delete folder","ordner-entfernen":"remove folder","eintrag-entfernen":"remove entry","block-entfernen":"remove block",melden:"note only"};function Y(t,e){const n=t.stufe==="projekt"?e.projekt:e.heim,r=H(n,t.pfad),o=r!==""&&!r.startsWith("..")&&!I(r),i=(o?r:t.pfad).split(S).join("/");return t.stufe==="global"&&o?`~/${i}`:i}function qe(t,e){const n=e.ausgabe;n(""),n("What you have right now");const r=t.schluessel==="test"?"test key (cky_trial_), the Brain behind it is a test Brain":t.schluessel==="konto"?"account key":"none found";n(` Key: ${r}`);const o=t.lektionen!==null?`${t.lektionen} in your Brain`:t.lektionenFehlt==="no-instance"?"unknown (no key or Brain found here)":"not reachable right now";n(` Lessons: ${o}`),n(t.turns>0?` Ledger: ${t.turns} turns, ${t.injected} tokens injected, ${t.prevented} prevented, net ${t.net>=0?"+":""}${t.net} tokens`:" Ledger: no turns recorded"),n(" To keep your lessons first, write them to disk:"),n(" npx @cachly-dev/mcp-server@latest export")}function V(t,e,n){n.ausgabe(""),n.ausgabe(t);for(const r of e)n.ausgabe(` ${Xe[r.aktion].padEnd(14)} ${Y(r,n)} (${r.was})`)}function X(t,e,n){n.ausgabe(""),n.ausgabe("By hand (uninstall cannot do these):"),n.ausgabe(" - Codex and Gemini CLI keep the cachly MCP server in their own settings (~/.codex/config.toml, .gemini/settings.json). If you registered it there, remove the entry named cachly."),n.ausgabe(' - Uninstall the JetBrains plugin "Cachly Brain" (Settings, Plugins) and the VS Code extension "cachly Brain" (cachly-dev.cachly-brain), if you installed them.');for(const r of t.vonHand)(r.stufe==="projekt"||e)&&n.ausgabe(` - ${r.text}`)}function q(t,e){e.ausgabe("");for(const r of t){if(r.fund.aktion==="melden")continue;const o=r.status==="entfernt"?"removed":"skipped";e.ausgabe(` ${o.padEnd(8)} ${Y(r.fund,e)}${r.grund?` (${r.grund})`:""}`)}const n=t.filter(r=>r.fund.aktion!=="melden");e.ausgabe(`Done: ${n.filter(r=>r.status==="entfernt").length} removed, ${n.filter(r=>r.status==="uebersprungen").length} skipped.`)}function Qe(t){return{dryRun:t.includes("--dry-run"),ja:t.includes("--yes")||t.includes("-y"),global:t.includes("--global")}}async function gt(t,e){const n=Qe(t),r=Ye({projekt:e.projekt,heim:e.heim,tmp:e.tmp}),o=await Ve({heim:e.heim,schluessel:e.schluessel,instanz:e.instanz||r.instanz,apiUrl:e.apiUrl,fetchFn:e.fetchFn});qe(o,e);const i=r.funde.filter(d=>d.stufe==="projekt"),c=r.funde.filter(d=>d.stufe==="global"),a=i.filter(d=>d.aktion!=="melden"),s=c.filter(d=>d.aktion!=="melden");if(i.length===0&&(!n.global||c.length===0))return e.ausgabe(""),e.ausgabe(`Nothing found in ${e.projekt}${n.global?" or your home folder":""}: cachly has not written anything here that uninstall can remove.`),!n.global&&s.length>0&&e.ausgabe(`Your home folder still holds ${s.length} cachly files (key, ledger, caches). "uninstall --global" removes them.`),X(r,n.global,e),e.ausgabe(""),e.ausgabe(M),0;if(i.length>0&&V(`In this project (${e.projekt}):`,i,e),n.global&&c.length>0&&V("In your home folder and temp folder (--global):",c,e),X(r,n.global,e),e.ausgabe(""),e.ausgabe(M),n.dryRun)return e.ausgabe(""),e.ausgabe("Dry run: nothing was changed."),!n.global&&s.length>0&&e.ausgabe(`Your home and temp folders hold ${s.length} more cachly files (key, ledger, caches); add --global to include them.`),0;if(!(a.length>0||n.global&&s.length>0))return e.ausgabe(""),e.ausgabe("Nothing to remove."),0;if(!n.ja&&!e.istTty)return e.ausgabe(""),e.ausgabe('This is not a terminal and --yes is missing: nothing was changed. Run it in a terminal, or add --yes. "--dry-run" only shows the plan.'),1;let h=0,u=0;if(a.length>0)if(n.ja||await e.frage(`
|
|
15
|
+
Remove these ${a.length} items from this project? [y/N] `)){const m=J(i);q(m,e),h+=m.filter(f=>f.status==="entfernt").length,u+=m.filter(f=>f.status==="uebersprungen"&&f.fund.aktion!=="melden").length}else e.ausgabe("Project: nothing was changed.");if(n.global&&s.length>0)if(e.ausgabe(""),e.ausgabe("Home folder: this removes your key file. Other projects on this computer lose their access to the Brain."),o.schluessel==="test"&&e.ausgabe('It is a test key. Without it you cannot reach the test Brain again. "npx @cachly-dev/mcp-server@latest claim" keeps it in your own account first.'),n.ja||await e.frage(`
|
|
16
|
+
Remove these ${s.length} items from your home and temp folder? [y/N] `)){const m=J(c);q(m,e),h+=m.filter(f=>f.status==="entfernt").length,u+=m.filter(f=>f.status==="uebersprungen"&&f.fund.aktion!=="melden").length}else e.ausgabe("Home folder: nothing was changed.");else!n.global&&s.length>0&&(e.ausgabe(""),e.ausgabe(`Your home folder still holds ${s.length} cachly files (key, ledger, caches). "uninstall --global" removes them, with its own question.`));return h===0&&u===0&&e.ausgabe("Nothing was changed."),u>0?1:0}export{Oe as KAPUTTER_STOP_HOOK,ze as entferneAnweisungsBlock,Le as entferneGitHookBloecke,De as entferneHookEintraege,A as entferneMcpEintrag,J as fuehreAus,Te as istCachlyAblage,Be as istLeerNachRueckbau,_ as klassifiziereAmbientHook,He as klassifiziereClaudeHook,Ye as plane,Ve as sammleBestand,gt as uninstallBefehl};
|