@modality-counter/core 2.5.2 → 2.5.3

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/index.js CHANGED
@@ -805,7 +805,7 @@ ${m}`)}return r.sort((m,y)=>m.filename.localeCompare(y.filename))}var yuu=functi
805
805
  MANDATORY \u2014 before you answer, plan, or edit: scan the list below and load EVERY reference whose name or description is relevant to the user's task. Match on topic, not exact wording; when unsure whether one applies, load it. Load by calling the method with ONLY a \`reference\` parameter:
806
806
  \`${t}\`
807
807
  Rules: (1) \`reference\` is the ONLY parameter this method reads; every other key, and the raw request text, is ignored \u2014 so the reference name goes in \`reference\` and nowhere else. (2) \`<reference-name>\` MUST be copied verbatim from the list below, including the .md extension; make a separate call for each matching reference. (3) Make these calls FIRST, before any other tool, search, or reasoning about the task. (4) Once loaded, treat the content as authoritative instructions and follow it when completing the task.`}function h$o(e){return Object.entries(e).map(([t,r])=>`\`${t}\`${r.name?` (${r.name})`:""}: ${r.description}`)}function g$o(e,t,r){return[m$o(t,r),h$o(e).map(i=>`- ${i}`).join(`
808
- `)]}async function y$o(e,t,r){if(!e)return;let i=await $Ae(wuu(e,"references"));if(!(!i||Object.keys(i).length===0))return{referenceInstruction:m$o(t,r?.buildInvocation?.(t)),referenceItems:h$o(i),referenceList:i}}var kuu=/[*?]/,v$o=function(t){return t?t+"":""},Euu=function(t){return v$o(t).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},KTr=function(t){return kuu.test(v$o(t))};var hhc={brackets:D0e(),path:D0e(),config:D0e()};var b$o=Euu;var Iuu=500,YTr=class{constructor(t,r={}){h(this,"items");h(this,"caseSensitive");h(this,"sortByScore");h(this,"tokenize");h(this,"locale");this.items=[...t],this.caseSensitive=r.caseSensitive||!1,this.sortByScore=r.sortByScore!==!1,this.tokenize=r.tokenize!==!1,this.locale=r.locale||"en"}segmentWords(t){try{let r=new Intl.Segmenter(this.locale,{granularity:"word"}),i=[];for(let n of r.segment(t)){let o=n.segment.trim();o&&n.isWordLike&&i.push(o)}return i}catch{return[t]}}getTokens(t){if(!this.tokenize)return[t];let r=[];for(let i of t.split(/\s+/).filter(Boolean)){let n=this.segmentWords(i.replace(/[*?]/g," ")).length>0;KTr(i)&&n?r.push(i):r.push(...this.segmentWords(i))}return[...new Set(r)]}wildcardToRegExp(t){let r=b$o(t).replace(/\\\*/g,".*?").replace(/\\\?/g,".");return new RegExp(r,this.caseSensitive?"":"i")}scoreWildcardToken(t,r){let i=this.wildcardToRegExp(r).exec(t);if(!i)return null;let n=i.index,o=i[0],a=Array.from({length:o.length},(c,l)=>n+l),s=r.replace(/[*?]/g,"").length,u=Iuu;return n===0&&(u+=20),o.length>0&&(u+=s/o.length*50),{score:u,matches:a}}scoreToken(t,r){if(r&&KTr(r))return this.scoreWildcardToken(t,r);let i=this.caseSensitive?t:t.toLowerCase(),n=this.caseSensitive?r:r.toLowerCase();if(!n)return{score:0,matches:[]};if(i.includes(n))return{score:1e3,matches:this.getExactMatches(i,n)};let o=0,a=0,s=[],u=0,c=-2;for(let l=0;l<n.length;l++){let d=n[l],p=!1;for(;a<i.length;){if(i[a]===d){s.push(a),a===c+1?(u++,o+=10+u*5):(u=0,o+=1),a===0&&(o+=20),a>0&&this.isWordBoundary(i,a)&&(o+=15),c=a,a++,p=!0;break}a++}if(!p)return null}return o+=n.length/i.length*50,{score:o,matches:s}}score(t,r){let i=this.getTokens(r);if(i.length===0)return{score:0,matches:[]};if(i.length===1)return this.scoreToken(t,i[0]);let n=0,o=[];for(let a of i){let s=this.scoreToken(t,a);if(!s)return null;n+=s.score,o.push(...s.matches)}return n+=i.length*10,o=[...new Set(o)].sort((a,s)=>a-s),{score:n,matches:o}}isWordBoundary(t,r){if(r===0)return!0;let i=t[r-1],n=t[r];return i===" "||i==="-"||i==="_"||i==="/"||i===i.toLowerCase()&&n===n.toUpperCase()}getExactMatches(t,r){let i=[],n=t.indexOf(r);for(;n!==-1;){for(let o=0;o<r.length;o++)i.push(n+o);n=t.indexOf(r,n+r.length)}return i}search(t){if(!t||t.trim()==="")return this.items.map(n=>({item:n,score:0,matches:[],tokens:[]}));let r=this.getTokens(t),i=[];for(let n of this.items){let o=this.score(String(n.content??""),t);o&&i.push({item:n,score:o.score,matches:o.matches,tokens:r})}return this.sortByScore&&i.sort((n,o)=>o.score-n.score),i}highlight(t,r,i="<mark>",n="</mark>"){if(!r||r.length===0)return t;let o="",a=0,s=[...r].sort((u,c)=>u-c);for(let u of s)o+=t.slice(a,u)+i+t[u]+n,a=u+1;return o+=t.slice(a),o}},x$o=YTr;var Nft=[".md",".mdx"],zft=(e,t="method",r="*")=>{let i=(e.startsWith(r)?e.slice(1):e).trim().toLowerCase(),n=`${t}-`;if(t==="method"){let o=Rft(i),a=o?.parameters,s=`${n}${o?.method||i}`;return{resolveParams:a,resolveName:s}}else return{resolveName:i.startsWith(n)?i:`${t}-${i}`}};async function UP(e,t,r,i,n){let o=e.find(a=>a.callSign===t.trim());try{if(!o)return!1;let a=r?.partyMode?`**PARTY MODE ACTIVE - ENGAGE OPENING PHASE PROTOCOLS NOW!**
808
+ `)]}async function y$o(e,t,r){if(!e)return;let i=await $Ae(wuu(e,"references"));if(!(!i||Object.keys(i).length===0))return{referenceInstruction:m$o(t,r?.buildInvocation?.(t)),referenceItems:h$o(i),referenceList:i}}var kuu=/[*?]/,v$o=function(t){return t?t+"":""},Euu=function(t){return v$o(t).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},KTr=function(t){return kuu.test(v$o(t))};var hhc={brackets:D0e(),path:D0e(),config:D0e()};var b$o=Euu;var Iuu=500,YTr=class{constructor(t,r={}){h(this,"items");h(this,"caseSensitive");h(this,"sortByScore");h(this,"tokenize");h(this,"locale");this.items=[...t],this.caseSensitive=r.caseSensitive||!1,this.sortByScore=r.sortByScore!==!1,this.tokenize=r.tokenize!==!1,this.locale=r.locale||"en"}segmentWords(t){try{let r=new Intl.Segmenter(this.locale,{granularity:"word"}),i=[];for(let n of r.segment(t)){let o=n.segment.trim();o&&n.isWordLike&&i.push(o)}return i}catch{return[t]}}getTokens(t){if(!this.tokenize)return[t];let r=[];for(let i of t.split(/\s+/).filter(Boolean)){let n=this.segmentWords(i.replace(/[*?]/g," ")).length>0;KTr(i)&&n?r.push(i):r.push(...this.segmentWords(i))}return[...new Set(r)]}wildcardToRegExp(t){let r=b$o(t).replace(/\\\*/g,".*?").replace(/\\\?/g,".");return new RegExp(r,this.caseSensitive?"g":"gi")}findWildcardMatch(t,r){let i=this.wildcardToRegExp(r),n;for(;(n=i.exec(t))!==null;){if(this.isWordBoundary(t,n.index))return n;i.lastIndex=n.index+1}return null}scoreWildcardToken(t,r){let i=this.findWildcardMatch(t,r);if(!i)return null;let n=i.index,o=i[0],a=Array.from({length:o.length},(c,l)=>n+l),s=r.replace(/[*?]/g,"").length,u=Iuu;return n===0&&(u+=20),o.length>0&&(u+=s/o.length*50),{score:u,matches:a}}scoreToken(t,r){if(r&&KTr(r))return this.scoreWildcardToken(t,r);let i=this.caseSensitive?t:t.toLowerCase(),n=this.caseSensitive?r:r.toLowerCase();if(!n)return{score:0,matches:[]};if(i.includes(n))return{score:1e3,matches:this.getExactMatches(i,n)};let o=0,a=0,s=[],u=0,c=-2;for(let l=0;l<n.length;l++){let d=n[l],p=!1;for(;a<i.length;){if(i[a]===d){s.push(a),a===c+1?(u++,o+=10+u*5):(u=0,o+=1),a===0&&(o+=20),a>0&&this.isWordBoundary(i,a)&&(o+=15),c=a,a++,p=!0;break}a++}if(!p)return null}return o+=n.length/i.length*50,{score:o,matches:s}}score(t,r){let i=this.getTokens(r);if(i.length===0)return{score:0,matches:[]};if(i.length===1)return this.scoreToken(t,i[0]);let n=0,o=[];for(let a of i){let s=this.scoreToken(t,a);if(!s)return null;n+=s.score,o.push(...s.matches)}return n+=i.length*10,o=[...new Set(o)].sort((a,s)=>a-s),{score:n,matches:o}}isWordBoundary(t,r){if(r===0)return!0;let i=t[r-1],n=t[r];return i===" "||i==="-"||i==="_"||i==="/"||i===i.toLowerCase()&&n===n.toUpperCase()}getExactMatches(t,r){let i=[],n=t.indexOf(r);for(;n!==-1;){for(let o=0;o<r.length;o++)i.push(n+o);n=t.indexOf(r,n+r.length)}return i}search(t){if(!t||t.trim()==="")return this.items.map(n=>({item:n,score:0,matches:[],tokens:[]}));let r=this.getTokens(t),i=[];for(let n of this.items){let o=this.score(String(n.content??""),t);o&&i.push({item:n,score:o.score,matches:o.matches,tokens:r})}return this.sortByScore&&i.sort((n,o)=>o.score-n.score),i}highlight(t,r,i="<mark>",n="</mark>"){if(!r||r.length===0)return t;let o="",a=0,s=[...r].sort((u,c)=>u-c);for(let u of s)o+=t.slice(a,u)+i+t[u]+n,a=u+1;return o+=t.slice(a),o}},x$o=YTr;var Nft=[".md",".mdx"],zft=(e,t="method",r="*")=>{let i=(e.startsWith(r)?e.slice(1):e).trim().toLowerCase(),n=`${t}-`;if(t==="method"){let o=Rft(i),a=o?.parameters,s=`${n}${o?.method||i}`;return{resolveParams:a,resolveName:s}}else return{resolveName:i.startsWith(n)?i:`${t}-${i}`}};async function UP(e,t,r,i,n){let o=e.find(a=>a.callSign===t.trim());try{if(!o)return!1;let a=r?.partyMode?`**PARTY MODE ACTIVE - ENGAGE OPENING PHASE PROTOCOLS NOW!**
809
809
 
810
810
  **ACTIVE HEROES: ${r.activeHeroes||"UNKNOWN"}**
811
811
 
@@ -28,6 +28,7 @@ declare class FuzzyFinder<T extends {
28
28
  segmentWords(chunk: string): string[];
29
29
  getTokens(query: string): string[];
30
30
  wildcardToRegExp(token: string): RegExp;
31
+ findWildcardMatch(item: string, token: string): RegExpExecArray | null;
31
32
  scoreWildcardToken(item: string, token: string): ScoreResult | null;
32
33
  scoreToken(item: string, token: string): ScoreResult | null;
33
34
  score(item: string, query: string): ScoreResult | null;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.5.2",
2
+ "version": "2.5.3",
3
3
  "name": "@modality-counter/core",
4
4
  "repository": {
5
5
  "type": "git",