@cachly-dev/mcp-server 0.10.280 → 0.10.281
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/cli-argumente.js +1 -1
- package/dist/src/client-kopf.js +1 -0
- package/dist/src/handlers/brain.js +71 -70
- package/dist/src/handlers/share.js +11 -11
- package/dist/src/handlers/team.js +49 -43
- package/dist/src/import-docs.js +11 -0
- package/dist/src/index.js +127 -123
- package/dist/src/rolle.js +12 -0
- package/dist/src/schluessel-klassen.js +1 -0
- package/dist/src/speicher-zugang.js +1 -0
- package/dist/src/suchstatistik.js +1 -1
- package/glama.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{AsyncLocalStorage as O}from"node:async_hooks";import{mitgliedDarfSchreiben as T}from"./schluessel-klassen.js";const D=new Set(["admin","reviewer","contributor","viewer"]),M=6e4,w="https://cachly.dev/team";let m=null,x=()=>"";const p=new Map,g=new Map;function P(t){m=t.abruf,x=t.bereich??(()=>""),p.clear(),g.clear()}function W(){P({abruf:null}),d.clear()}function z(t){if(!t||typeof t!="object")return null;const e=t;if(typeof e.role!="string"||!D.has(e.role))return null;const n=e.can&&typeof e.can=="object"?e.can:{};return{role:e.role,source:typeof e.source=="string"?e.source:"",can:{learn:n.learn===!0,confirm:n.confirm===!0,withdraw:n.withdraw===!0,manage:n.manage===!0},review_mode:e.review_mode===!0,protection:typeof e.protection=="string"?e.protection:"",...e.knowledge&&typeof e.knowledge=="object"?{knowledge:e.knowledge}:{},...typeof e.min_mcp=="string"?{min_mcp:e.min_mcp}:{}}}function $(t){return`${x()}|${t}`}async function q(t){if(!m||!t)return null;const e=$(t),n=p.get(e);if(n&&Date.now()-n.am<M)return n.auskunft;const r=g.get(e);return n?(r||S(e,t,n),n.auskunft):r||S(e,t,void 0)}function S(t,e,n){if(!m)return Promise.resolve(n?.auskunft??null);const r=m,o=(async()=>{try{const i=z(await r(`/api/v1/instances/${encodeURIComponent(e)}/role`));return p.set(t,{auskunft:i,am:Date.now()}),i}catch(i){return h(i).status===404?(p.set(t,{auskunft:null,am:Date.now()}),null):n?.auskunft??null}})().finally(()=>g.delete(t));return g.set(t,o),o}function C(t){return p.get($(t))?.auskunft??null}function K(t,e,n){if(t&&typeof t=="object"){const r=n&&typeof n=="object"?n:{};Object.assign(t,{apiStatus:e,...typeof r.code=="string"?{apiCode:r.code}:{},...typeof r.role=="string"?{apiRole:r.role}:{},...typeof r.reason=="string"?{apiReason:r.reason}:{}})}return t}function h(t){const e=t&&typeof t=="object"?t:{},n=(c,a)=>typeof c=="string"?c:typeof a=="string"?a:void 0,r={},o=typeof e.apiStatus=="number"?e.apiStatus:typeof e.status=="number"?e.status:void 0;o!==void 0&&(r.status=o);const i=n(e.apiCode,e.code);i!==void 0&&(r.code=i);const s=n(e.apiRole,e.role);s!==void 0&&(r.role=s);const u=n(e.apiReason,e.reason);if(u!==void 0&&(r.reason=u),r.status===void 0){const c=/\((\d{3})\)|error (\d{3})/.exec(String(e.message??""));c&&(r.status=Number(c[1]??c[2]))}return r}const b=new WeakMap;function R(t){return t&&typeof t=="object"?b.get(t):void 0}function I(t){return R(t)?.access==="member"}function L(t){const e=R(t);return(e?.instanceId?C(e.instanceId)?.role:void 0)??e?.role??"contributor"}function Q(t,e){return!I(t)||T(e)}const X="member_access_unavailable";function Y(t,e){const n=e?` (Grund: ${e})`:"";return[`\u{1F512} Der Zugang fuer Mitglieder zu Brain "${t}" geht gerade nicht${n}.`,`Bitte den Besitzer des Brains oder einen Org-Admin fragen. Rollen und Zugang stehen unter ${w}.`,"(Member access to this brain is not available right now; ask the brain owner or an organisation admin.)"].join(`
|
|
2
|
+
`)}const v="Das darf nur der Besitzer oder ein Admin.";function A(t){return`${v} Deine Rolle: ${t}.`}class U extends Error{rolle;constructor(e){super(A(e)),this.name="SchreibVerweigert",this.rolle=e}}function _(t){if(!t||typeof t!="object")return!1;const e=t;return/\bNOPERM\b/.test(String(e.message??""))?!0:Array.isArray(e.previousErrors)&&e.previousErrors.some(n=>_(n))}const k=new O;function F(t){const e=k.getStore();e&&(e.abgewiesen++,e.rolle=t)}async function ee(t){const e={abgewiesen:0};return{ergebnis:await k.run(e,t),abgewiesen:e.abgewiesen,rolle:e.rolle}}function te(t,e,n="contributor"){if(e<=0||t.includes(v))return t;const r=e===1?"1 Schreibbefehl":`${e} Schreibbefehle`;return`${t}
|
|
3
|
+
|
|
4
|
+
\u{1F512} ${A(n)} Nicht gespeichert: ${r} dieses Aufrufs.`}function y(t){return!!t&&typeof t.then=="function"}function V(t){return e=>{if(!_(e))return e;const n=t();return F(n),new U(n)}}function Z(t,e){return Array.isArray(t)?t.map(n=>Array.isArray(n)&&n[0]?[e(n[0]),n[1]]:n):t}function H(t,e){const n=new Map,r=new Proxy(t,{get(o,i){const s=Reflect.get(o,i,o);if(typeof s!="function")return s;if(n.has(i))return n.get(i);const u=(...c)=>{const a=s.apply(o,c);return a===o?r:i==="exec"&&y(a)?a.then(l=>Z(l,e),l=>{throw e(l)}):y(a)?a.then(void 0,l=>{throw e(l)}):a};return n.set(i,u),u}});return r}function ne(t,e){const n={...e,access:"member"},r=V(()=>L(i)),o=new Map,i=new Proxy(t,{get(s,u){const c=Reflect.get(s,u,s);if(typeof c!="function")return c;if(o.has(u))return o.get(u);const a=(...l)=>{const f=c.apply(s,l);return f===s?i:y(f)?f.then(void 0,B=>{throw r(B)}):(u==="pipeline"||u==="multi")&&f&&typeof f=="object"?H(f,r):f};return o.set(u,a),a}});return b.set(i,n),i}function re(t,e={}){b.set(t,{...e,access:"full"})}function N(t,e){const n=h(t);return n.role?n.role:n.code?.startsWith("role_")?n.code.slice(5):e}function E(t){return(t instanceof Error?t.message:String(t)).split(`
|
|
5
|
+
`)[0].slice(0,300)}async function oe(t,e,n,r){let o;try{o=await t(`/api/v1/instances/${encodeURIComponent(e)}/learn`,{method:"POST",body:JSON.stringify({source:"mcp",...n})})}catch(s){return h(s).status===403?[`\u{1F512} Deine Rolle (${N(s,r)}) darf in diesem Brain keine Lektionen speichern. Nichts wurde gespeichert.`,`Rollen setzt der Besitzer oder ein Admin unter ${w}.`].join(`
|
|
6
|
+
`):`\u26A0\uFE0F Nicht gespeichert: Die API hat \`${n.topic}\` nicht angenommen (${E(s)}). Bitte noch einmal versuchen.`}const i=o?.topic||n.topic;return o?.proposed?[`\u{1F4DD} **Lesson submitted for review** \u2014 \`${i}\` is now a pending proposal.`,"","This team requires review before knowledge enters the Team Brain (org setting).","An org owner/admin can approve or reject it in the dashboard under **Team \u2192 Review**.","Until approved it will NOT surface in `smart_recall` / `team_recall`."].join(`
|
|
7
|
+
`):[`\u2705 Lesson stored: \`${i}\` (${n.outcome}) \u2014 saved through the cachly API as a team member (role: ${r}).`,`\u{1F4A1} ${String(n.what_worked??"").slice(0,120)}`].join(`
|
|
8
|
+
`)}async function ie(t,e,n,r){try{const o=await t(`/api/v1/instances/${encodeURIComponent(e)}/lessons/confirm`,{method:"POST",body:JSON.stringify(n)}),i=o?.review_level==="senior"?"\u{1F6E1}\uFE0F senior-reviewed":"\u2714\uFE0F peer-reviewed",s=Number(o?.endorsements??0);return`${i} \u2014 \`${o?.topic??n.topic}\` confirmed by **${o?.reviewed_by??"?"}** (role: ${r}, ${s} distinct endorsement${s===1?"":"s"}).
|
|
9
|
+
\u{1F4C8} This lesson now ranks higher in \`smart_recall\` / \`team_recall\`.`}catch(o){const i=h(o);return i.status===403?[`\u{1F512} Bestaetigen duerfen nur reviewer und admin. Deine Rolle: ${N(o,r)}. Nichts wurde geaendert.`,`Rollen setzt der Besitzer oder ein Admin unter ${w}.`].join(`
|
|
10
|
+
`):i.status===404?`\u{1F4ED} No best-solution lesson found for \`${n.topic}\`.
|
|
11
|
+
|
|
12
|
+
A lesson must exist (store one with \`team_learn\` / \`learn_from_attempts\`) before it can be confirmed.`:`\u26A0\uFE0F Nicht bestaetigt: Die API hat \`${n.topic}\` nicht angenommen (${E(o)}).`}}const j=25,d=new Set;function se(t,e,n){const r=[...new Set(n.map(o=>String(o).trim()).filter(o=>o&&o.length<=200))];for(let o=0;o<r.length;o+=j){const i=r.slice(o,o+j),s=t(`/api/v1/instances/${encodeURIComponent(e)}/lessons/recalled`,{method:"POST",body:JSON.stringify({topics:i})}).then(()=>{},()=>{}).finally(()=>{d.delete(s)});d.add(s)}}async function ue(){for(;d.size>0;)await Promise.all([...d])}export{j as ABRUF_HOECHSTENS,X as CODE_ZUGANG_NICHT_VERFUEGBAR,w as ROLLEN_SEITE,M as ROLLE_FRISCH_MS,v as SCHREIBVERBOT_ANFANG,U as SchreibVerweigert,ue as abrufMeldungenFertig,ne as alsMitgliedsSpeicher,z as alsRollenAuskunft,h as apiFehler,ie as bestaetigeUeberApi,Q as darfDirektSchreiben,q as holeRolle,ee as imWerkzeugLauf,I as istMitglied,_ as istNoPerm,oe as lerneUeberApi,K as markiereApiFehler,se as meldeAbrufe,re as merkeVollenZugang,te as mitAbweisungsHinweis,P as richteRolleEin,L as rolleFuer,C as rolleImSpeicher,A as schreibverbotText,W as setzeRollenZustandZurueck,Y as zugangNichtVerfuegbarText,R as zugangVon};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l=Object.freeze({team:"S",lesson:"W",lessons:"W",ckg:"W",crystal:"W",contradictions:"W",idx:"W",index:"W",withdrawn:"W",global:"W",fedbrain:"W",fed:"W",brain:"W",brain_from_git:"W",meta:"W",public:"W",doppel:"W","letzter-recall":"W",liefer:"W",ctx:"B",cls:"B",wirkung:"B",lock:"B",mcp:"B",mcm:"B",prefs:"B",dep:"B",session:"B",stats:"B",sem:"B",roadmap:"B",recall:"B",streak:"B",agents:"B",stream:"B",vek:"B",startwissen:"B",versuch:"B",quota:"B",aussetzer:"B"}),i=Object.freeze(["%R~*","~[^c]*","~c[^a]*","~ca[^c]*","~cac[^h]*","~cach[^l]*","~cachl[^y]*","~cachly[^:]*","~cachly:[^tlciwgfbmpd]*","~cachly:ctx:*","~cachly:cls:*","~cachly:wirkung:*","~cachly:lock:*","~cachly:mcp:*","~cachly:mcm:*","~cachly:prefs:*","~cachly:dep:*","+@all","-@admin","-@dangerous","+keys","+info"]);function o(e){let c="";for(let t=0;t<e.length;t++){const s=e[t];if(s==="*")c+="[\\s\\S]*";else if(s==="?")c+="[\\s\\S]";else if(s==="["){const n=e.indexOf("]",t+1);if(n===-1){c+="\\[";continue}let a=e.slice(t+1,n);const r=a.startsWith("^");r&&(a=a.slice(1)),c+=`[${r?"^":""}${a.replace(/[\\\]]/g,"\\$&")}]`,t=n}else s==="\\"&&t+1<e.length?c+=e[++t].replace(/[.*+?^${}()|[\]\\/]/g,"\\$&"):c+=s.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}return new RegExp(`^${c}$`)}const f=i.filter(e=>e.startsWith("~")).map(e=>o(e.slice(1)));function B(e){return f.some(c=>c.test(e))}function h(e){const c=/^cachly:([A-Za-z0-9_-]+)/.exec(e);return c?c[1]:""}function p(e){return e.startsWith("cachly:")?l[h(e)]:"B"}export{i as MITGLIED_MUSTER,l as SCHLUESSEL_KLASSEN,h as familieVon,o as globAlsRegex,p as klasseVon,B as mitgliedDarfSchreiben};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ErrorCode as t,McpError as i}from"@modelcontextprotocol/sdk/types.js";import{alsMitgliedsSpeicher as d,apiFehler as a,CODE_ZUGANG_NICHT_VERFUEGBAR as u,zugangNichtVerfuegbarText as p}from"./rolle.js";async function h(e,o){try{return await e()}catch(r){const s=a(r);if(s.status===409&&s.code===u)throw new i(t.InvalidRequest,p(o,s.reason));const n=r instanceof Error?r.message:String(r);if(n.includes("401")||n.includes("403")||n.includes("Unauthorized"))throw new i(t.InvalidRequest,"API key rejected \u2014 run `cachly setup` to refresh your credentials.");return}}function w(e){const o=typeof e?.username=="string"&&e.username?e.username:void 0,r=typeof e?.password=="string"&&e.password?e.password:void 0;return{...o?{username:o}:{},...r?{password:r}:{},mitglied:e?.access==="member",...typeof e?.role=="string"?{role:e.role}:{}}}function l(e){return{...e.username?{username:e.username}:{},password:e.password||void 0}}function g(e,o,r,s){const n=new e({...o,...l(r)}),c=r.mitglied?d(n,{role:r.role,username:r.username,instanceId:s}):n;return{roh:n,nutzbar:c}}export{l as anmeldeOptionen,w as anmeldungAus,g as baueSpeicherClient,h as holeVerbindungsAuskunft};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{darfDirektSchreiben as l}from"./rolle.js";const t={gesamt:"cachly:meta:brain:total_searches",jeTag:n=>`cachly:meta:brain:searches:${n}`,latenz:"cachly:meta:brain:latency_ms",bestenliste:"cachly:meta:brain:top_queries"},o=168*3600,h=200;async function m(n,r,s){try{if(!l(n,t.gesamt))return;const i=new Date().toISOString().slice(0,10),c=t.jeTag(i),e=n.pipeline();e.incr(t.gesamt),e.incr(c),e.expire(c,o),e.lpush(t.latenz,String(Math.max(0,Math.round(s)))),e.ltrim(t.latenz,0,h-1);const a=r.trim().split(/\s+/).join(" ");a.length>0&&a.length<=200&&e.zincrby(t.bestenliste,1,a.length>80?`${a.slice(0,80)}\u2026`:a),await e.exec()}catch{}}export{h as LATENZ_FENSTER,t as SUCHSTATISTIK_SCHLUESSEL,o as TAGESZAHL_TTL_SEKUNDEN,m as merkeSuchlauf};
|
package/glama.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cachly-dev/mcp-server",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.281",
|
|
4
4
|
"mcpName": "io.github.cachly-dev/mcp-server",
|
|
5
5
|
"description": "Explain it once. Every AI knows it. cachly keeps your project's rules, decisions and fixes for every AI tool, for you, your team and your company.",
|
|
6
6
|
"type": "module",
|
package/server.json
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"url": "https://github.com/cachly-dev/cachly-mcp",
|
|
18
18
|
"source": "github"
|
|
19
19
|
},
|
|
20
|
-
"version": "0.10.
|
|
20
|
+
"version": "0.10.281",
|
|
21
21
|
"packages": [
|
|
22
22
|
{
|
|
23
23
|
"registryType": "npm",
|
|
24
24
|
"identifier": "@cachly-dev/mcp-server",
|
|
25
|
-
"version": "0.10.
|
|
25
|
+
"version": "0.10.281",
|
|
26
26
|
"runtimeHint": "npx",
|
|
27
27
|
"transport": {
|
|
28
28
|
"type": "stdio"
|