@cachly-dev/mcp-server 0.10.198 → 0.10.200

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{kosinus as P}from"./bedeutung.js";import{DOPPEL_SCHWELLE as _}from"./rangfolge-stellschrauben.js";const f="cachly:doppel:kandidaten",w=40,x=14,T=30,d=90*86400,y=6,E=864e5,D=t=>typeof t.what_worked=="string"?t.what_worked.trim().length:0;function k(t,e,o,n=_){return t.topic===e.topic||!(o>=n)||D(t)<w||D(e)<w?!1:!(t.ersetzt===e.topic||t.ersetzt_durch===e.topic||e.ersetzt===t.topic||e.ersetzt_durch===t.topic)}function O(t,e){let o=null;for(const n of e)k(t,n.lektion,n.naehe)&&(!o||n.naehe>o.naehe)&&(o={topic:n.lektion.topic,naehe:n.naehe});return o}function g(t){if(!t)return null;try{const e=JSON.parse(t);return e&&typeof e=="object"?e:null}catch{return null}}const S=t=>Math.round(t*1e3)/1e3;async function v(t,e,o,n,c=new Date){try{await n.aktualisiere(t);const i=n.aehnlichste(o,y+1).filter(l=>l.topic!==e.topic&&l.naehe>=_);let a=null;if(i.length>0){const l=await t.mget(...i.map(u=>`cachly:lesson:best:${u.topic}`)),h=i.flatMap((u,L)=>{const m=g(l[L]);return m?[{lektion:{...m,topic:u.topic},naehe:u.naehe}]:[]});a=O(e,h)}const p=await t.hgetall(f),r=Object.entries(p).filter(([l,h])=>l===e.topic||c.getTime()-Date.parse(String(g(h)?.am??""))>T*E||!g(h)).map(([l])=>l);if(r.length>0&&await t.hdel(f,...r),!a)return null;const s={neu:e.topic,alt:a.topic,naehe:S(a.naehe),am:c.toISOString()};return await t.hset(f,e.topic,JSON.stringify({alt:s.alt,naehe:s.naehe,am:s.am})),await t.expire(f,d),s}catch{return null}}async function M(t,e,o=new Date){try{const n=await t.hgetall(f),c=new Map(e.map(a=>[a.topic,a])),i=[];for(const[a,p]of Object.entries(n)){const r=g(p);if(!r||typeof r.alt!="string")continue;const s=String(r.am??"");if(!(o.getTime()-Date.parse(s)<=x*E))continue;const l=c.get(a),h=c.get(r.alt),u=Number(r.naehe);!l||!h||!k(l,h,u)||i.push({neu:a,alt:r.alt,naehe:u,am:s})}return i.sort((a,p)=>p.naehe-a.naehe)}catch{return[]}}function z(t){const e=[];for(let o=0;o<t.length;o++)for(let n=o+1;n<t.length;n++){const c=t[o],i=t[n],a=P(c.vektor,i.vektor);if(!k(c.lektion,i.lektion,a))continue;const p=String(c.lektion.ts??"")>=String(i.lektion.ts??""),[r,s]=p?[c.lektion,i.lektion]:[i.lektion,c.lektion];e.push({neu:r.topic,alt:s.topic,naehe:S(a)})}return e.sort((o,n)=>n.naehe-o.naehe)}export{x as DOPPEL_BRIEFING_TAGE,T as DOPPEL_HALTEN_TAGE,w as DOPPEL_MINDEST_TEXT,f as DOPPEL_SCHLUESSEL,d as DOPPEL_TTL_S,z as doppelPaare,M as leseDoppelKandidaten,v as pruefeDoppelung,O as waehleDoppelKandidat,k as zaehltAlsDoppelung};
1
+ import{kosinus as x}from"./bedeutung.js";import{DOPPEL_SCHWELLE as w}from"./rangfolge-stellschrauben.js";const f="cachly:doppel:kandidaten",_=40,D=14,L=30,T=90*86400,y=1500,O=6,k=864e5,E=t=>typeof t.what_worked=="string"?t.what_worked.trim().length:0;function m(t,e,n,o=w){return t.topic===e.topic||!(n>=o)||E(t)<_||E(e)<_?!1:!(t.ersetzt===e.topic||t.ersetzt_durch===e.topic||e.ersetzt===t.topic||e.ersetzt_durch===t.topic)}function A(t,e){let n=null;for(const o of e)m(t,o.lektion,o.naehe)&&(!n||o.naehe>n.naehe)&&(n={topic:o.lektion.topic,naehe:o.naehe});return n}function g(t){if(!t)return null;try{const e=JSON.parse(t);return e&&typeof e=="object"?e:null}catch{return null}}const S=t=>Math.round(t*1e3)/1e3;async function z(t,e,n,o,a=new Date){try{await o.aktualisiere(t);const r=o.aehnlichste(n,O+1).filter(s=>s.topic!==e.topic&&s.naehe>=w);let i=null;if(r.length>0){const s=await t.mget(...r.map(h=>`cachly:lesson:best:${h.topic}`)),p=r.flatMap((h,P)=>{const d=g(s[P]);return d?[{lektion:{...d,topic:h.topic},naehe:h.naehe}]:[]});i=A(e,p)}const u=await t.hgetall(f),c=Object.entries(u).filter(([s,p])=>s===e.topic||a.getTime()-Date.parse(String(g(p)?.am??""))>L*k||!g(p)).map(([s])=>s);if(c.length>0&&await t.hdel(f,...c),!i)return null;const l={neu:e.topic,alt:i.topic,naehe:S(i.naehe),am:a.toISOString()};return await t.hset(f,e.topic,JSON.stringify({alt:l.alt,naehe:l.naehe,am:l.am})),await t.expire(f,T),l}catch{return null}}async function I(t,e=y){let n;const o=new Promise(a=>{n=setTimeout(()=>a(null),e),n.unref?.()});try{return await Promise.race([t,o])}finally{n&&clearTimeout(n)}}function M(t,e=""){return!t||e.includes(`\`${t.alt}\``)?"":`\u267B\uFE0F Sagt fast dasselbe wie \`${t.alt}\` (Bedeutung ${t.naehe.toFixed(2)}). Ist das die neuere Fassung: dieselbe Lektion noch einmal mit \`ersetzt="${t.alt}"\` und \`grund\` schreiben. Ist es eine eigene Sache: nichts zu tun.`}async function v(t,e,n=new Date){try{const o=await t.hgetall(f),a=new Map(e.map(i=>[i.topic,i])),r=[];for(const[i,u]of Object.entries(o)){const c=g(u);if(!c||typeof c.alt!="string")continue;const l=String(c.am??"");if(!(n.getTime()-Date.parse(l)<=D*k))continue;const s=a.get(i),p=a.get(c.alt),h=Number(c.naehe);!s||!p||!m(s,p,h)||r.push({neu:i,alt:c.alt,naehe:h,am:l})}return r.sort((i,u)=>u.naehe-i.naehe)}catch{return[]}}function H(t){const e=[];for(let n=0;n<t.length;n++)for(let o=n+1;o<t.length;o++){const a=t[n],r=t[o],i=x(a.vektor,r.vektor);if(!m(a.lektion,r.lektion,i))continue;const u=String(a.lektion.ts??"")>=String(r.lektion.ts??""),[c,l]=u?[a.lektion,r.lektion]:[r.lektion,a.lektion];e.push({neu:c.topic,alt:l.topic,naehe:S(i)})}return e.sort((n,o)=>o.naehe-n.naehe)}export{D as DOPPEL_BRIEFING_TAGE,L as DOPPEL_HALTEN_TAGE,_ as DOPPEL_MINDEST_TEXT,f as DOPPEL_SCHLUESSEL,T as DOPPEL_TTL_S,y as DOPPEL_WARTE_MS,M as doppelHinweis,H as doppelPaare,v as leseDoppelKandidaten,I as mitFrist,z as pruefeDoppelung,A as waehleDoppelKandidat,m as zaehltAlsDoppelung};