@modality-counter/core 1.5.3 → 1.6.1

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
@@ -704,7 +704,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
704
704
  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:
705
705
  \`${t}\`
706
706
  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 Rmo(e){return Object.entries(e).map(([t,r])=>`\`${t}\`${r.name?` (${r.name})`:""}: ${r.description}`)}function Mmo(e,t,r){return[Nmo(t,r),Rmo(e).map(i=>`- ${i}`).join(`
707
- `)]}async function zmo(e,t,r){if(!e)return;let i=await wOe(JLs(e,"references"));if(!(!i||Object.keys(i).length===0))return{referenceInstruction:Nmo(t,r?.buildInvocation?.(t)),referenceItems:Rmo(i),referenceList:i}}var Kxr=class{constructor(t,r={}){g(this,"items");g(this,"caseSensitive");g(this,"sortByScore");g(this,"tokenize");g(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"}getTokens(t){if(!this.tokenize)return[t];let r;try{let i=new Intl.Segmenter(this.locale,{granularity:"word"});r=[];for(let n of i.segment(t)){let o=n.segment.trim();o&&n.isWordLike&&r.push(o)}}catch{r=t.split(/\s+/).filter(Boolean)}return[...new Set(r)]}scoreToken(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=[],c=0,u=-2;for(let l=0;l<n.length;l++){let f=n[l],d=!1;for(;a<i.length;){if(i[a]===f){s.push(a),a===u+1?(c++,o+=10+c*5):(c=0,o+=1),a===0&&(o+=20),a>0&&this.isWordBoundary(i,a)&&(o+=15),u=a,a++,d=!0;break}a++}if(!d)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(i=>({item:i,score:0,matches:[],tokens:[]}));let r=[];for(let i of this.items){let n=this.score(String(i.content??""),t);n&&r.push({item:i,score:n.score,matches:n.matches,tokens:this.getTokens(t)})}return this.sortByScore&&r.sort((i,n)=>n.score-i.score),r}highlight(t,r,i="<mark>",n="</mark>"){if(!r||r.length===0)return t;let o="",a=0,s=[...r].sort((c,u)=>c-u);for(let c of s)o+=t.slice(a,c)+i+t[c]+n,a=c+1;return o+=t.slice(a),o}},Fmo=Kxr;var Pst=[".md",".mdx"],Nst=(e,t="method")=>{let r=(e.startsWith("*")?e.slice(1):e).trim().toLowerCase(),i=`${t}-`;if(t==="method"){let n=Ast(r),o=n?.parameters,a=`${i}${n?.method||r}`;return{resolveParams:o,resolveName:a}}else return{resolveName:r.startsWith(i)?r:`${t}-${r}`}};async function iT(e,t,r,i,n){let o=e.find(a=>a.callSign===t.trim());try{if(!o)return!1;let a;r?.partyMode&&(a=`**PARTY MODE ACTIVE - ENGAGE OPENING PHASE PROTOCOLS NOW!**
707
+ `)]}async function zmo(e,t,r){if(!e)return;let i=await wOe(JLs(e,"references"));if(!(!i||Object.keys(i).length===0))return{referenceInstruction:Nmo(t,r?.buildInvocation?.(t)),referenceItems:Rmo(i),referenceList:i}}var Kxr=class{constructor(t,r={}){g(this,"items");g(this,"caseSensitive");g(this,"sortByScore");g(this,"tokenize");g(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"}getTokens(t){if(!this.tokenize)return[t];let r;try{let i=new Intl.Segmenter(this.locale,{granularity:"word"});r=[];for(let n of i.segment(t)){let o=n.segment.trim();o&&n.isWordLike&&r.push(o)}}catch{r=t.split(/\s+/).filter(Boolean)}return[...new Set(r)]}scoreToken(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=[],c=0,u=-2;for(let l=0;l<n.length;l++){let f=n[l],d=!1;for(;a<i.length;){if(i[a]===f){s.push(a),a===u+1?(c++,o+=10+c*5):(c=0,o+=1),a===0&&(o+=20),a>0&&this.isWordBoundary(i,a)&&(o+=15),u=a,a++,d=!0;break}a++}if(!d)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(i=>({item:i,score:0,matches:[],tokens:[]}));let r=[];for(let i of this.items){let n=this.score(String(i.content??""),t);n&&r.push({item:i,score:n.score,matches:n.matches,tokens:this.getTokens(t)})}return this.sortByScore&&r.sort((i,n)=>n.score-i.score),r}highlight(t,r,i="<mark>",n="</mark>"){if(!r||r.length===0)return t;let o="",a=0,s=[...r].sort((c,u)=>c-u);for(let c of s)o+=t.slice(a,c)+i+t[c]+n,a=c+1;return o+=t.slice(a),o}},Fmo=Kxr;var Pst=[".md",".mdx"],Nst=(e,t="method",r="*")=>{let i=(e.startsWith(r)?e.slice(1):e).trim().toLowerCase(),n=`${t}-`;if(t==="method"){let o=Ast(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 iT(e,t,r,i,n){let o=e.find(a=>a.callSign===t.trim());try{if(!o)return!1;let a;r?.partyMode&&(a=`**PARTY MODE ACTIVE - ENGAGE OPENING PHASE PROTOCOLS NOW!**
708
708
 
709
709
  **ACTIVE HEROES: ${r.activeHeroes||"UNKNOWN"}**
710
710
 
@@ -870,7 +870,7 @@ description: "Behavior Protocol for Multi-Hero Party Mode Collaborative Discussi
870
870
  - deployedHeroes:['[deployed-hero]']
871
871
 
872
872
  Available heroes: ${await fUs()}`}var hUs=async(e,t,r)=>{let i=await ym(["persona"],e),n=r&&r.length>0?i.filter(c=>!r.some(u=>c.name?.trim().toLowerCase()===u.toLowerCase()||c.callSign===u.toLowerCase())):i,o=[...n].sort(()=>Math.random()-.5),a=[];t&&t.length>0&&(a=n.filter(u=>t.some(l=>u.name?.trim().toLowerCase()===l.toLowerCase()||u.callSign===l.toLowerCase())));let s=r?r.length:0;if(a.length<Umo){let c=o.filter(l=>!a.some(f=>f.callSign===l.callSign)),u=Umo-a.length-s;a=[...a,...c.slice(0,u)]}return{availableHeroes:n,selectedHeroes:a}},gUs=async(e,t)=>{let r=await ym(["method"],e),i={_Counter:{description:"EMERGENCY ALERT: Assemble all available agents! Get the complete roster of heroes, mission protocols, and tactical operations ready for deployment. By default returns heroes only - use types parameter for methods/workflows. The keyword parameter enables fuzzy search: omit, null, or blank returns nothing with guidance, '*' lists all, any non-blank string runs fuzzy matching over id/name/description.",inputSchema:x0i,execute:async({types:n,keyword:o})=>{try{if(o==null||o.trim()===""){let f=n.reduce((d,p)=>(d[p]=[],d),{});return OW({message:"No keyword provided. Pass a keyword to search, or '*' to list all."},{requestedTypes:n,totalCount:0,itemsByType:f})}let a=await ym(n,e),s=o==="*"?a:jmo(a,o),c=n.reduce((f,d)=>(f[d]=s.filter(p=>p.type===d).map(p=>d==="persona"?{id:p.id,name:p.name}:p.id),f),{}),l=`ASSEMBLED! ${Object.entries(c).filter(([f,d])=>d.length>0).map(([f,d])=>`${d.length} ${f}${d.length!==1?"s":""}`).join(", ")} ready for deployment.`;return OW({message:l},{requestedTypes:n,totalCount:s.length,itemsByType:c})}catch(a){return Zae(a,"counter_assemble")}}},_Counter__Deploy:{description:`Deploy a specific hero persona. Call this tool when the user references a hero by name or alias (e.g. 'deploy James', 'James', 'dev'). Available heroes:
873
- ${await pUs(e)}`,inputSchema:b0i,execute:async({callSign:n})=>{try{let o=Amo(n),a=await ym(["persona"],e),s=a.find(x=>x.callSign===o||x.name?.toLowerCase()===o);if(!s){let x=a.map(I=>I.name).join(", "),S=Object.keys(Gxr).join(", ");throw new Error(`Hero '${n}' not found. Available heroes: ${x}. Available aliases: ${S}`)}let c=s.callSign,{promptData:u}=await iT(a,c)||{};if(!u)throw new Error("Failed to load hero content");let l=u?.["behavior-protocol"]?.agent_activation_execution?.execution_flow;delete u["behavior-protocol"]?.agent_activation_execution?.execution_flow;let f=s?.name||"AGENT",{methods:d,dependencies:p,...m}=u;for(let x of p.methods){try{let I=await iT(r,`method-${x}`,null,!0);I&&I.promptData.method.usage.elicit&&(u.methods[x]={description:u.methods[x],parameters:I.promptData.method.usage.parameters})}catch(I){dUs.warn(`Failed to load method for deployment alias: ${x}`,I)}let S=$mo(x);if(S&&S.length)for(let I of S){let k=Ast(I);u.methods[I]=`${$D}({method: '*${I}'${k?.parameters!=null?`, params: ${JSON.stringify(k?.parameters)}`:""} })`}}let h=`<AUTONOMY_LEVEL>LEVEL_2_RULE_BASED_AUTONOMOUS</AUTONOMY_LEVEL>
873
+ ${await pUs(e)}`,inputSchema:b0i,_meta:{"anthropic/alwaysLoad":!0},execute:async({callSign:n})=>{try{let o=Amo(n),a=await ym(["persona"],e),s=a.find(x=>x.callSign===o||x.name?.toLowerCase()===o);if(!s){let x=a.map(I=>I.name).join(", "),S=Object.keys(Gxr).join(", ");throw new Error(`Hero '${n}' not found. Available heroes: ${x}. Available aliases: ${S}`)}let c=s.callSign,{promptData:u}=await iT(a,c)||{};if(!u)throw new Error("Failed to load hero content");let l=u?.["behavior-protocol"]?.agent_activation_execution?.execution_flow;delete u["behavior-protocol"]?.agent_activation_execution?.execution_flow;let f=s?.name||"AGENT",{methods:d,dependencies:p,...m}=u;for(let x of p.methods){try{let I=await iT(r,`method-${x}`,null,!0);I&&I.promptData.method.usage.elicit&&(u.methods[x]={description:u.methods[x],parameters:I.promptData.method.usage.parameters})}catch(I){dUs.warn(`Failed to load method for deployment alias: ${x}`,I)}let S=$mo(x);if(S&&S.length)for(let I of S){let k=Ast(I);u.methods[I]=`${$D}({method: '*${I}'${k?.parameters!=null?`, params: ${JSON.stringify(k?.parameters)}`:""} })`}}let h=`<AUTONOMY_LEVEL>LEVEL_2_RULE_BASED_AUTONOMOUS</AUTONOMY_LEVEL>
874
874
 
875
875
  ACTIVATION SEQUENCE (CRITICAL - FOLLOW EXACTLY):
876
876
 
@@ -878,7 +878,7 @@ ACTIVATION SEQUENCE (CRITICAL - FOLLOW EXACTLY):
878
878
  ${l.flat().map(x=>`- ${x}`).join(`
879
879
  `)}
880
880
  </ACTIVATION_SEQUENCE>
881
- `;return OW({instructions:[{message:`\u{1F680} ${f} is now operating at Level 2 Rule-Based Autonomy. CRITICAL: Read and full understand your operating params, start and follow exactly your activation-instructions to alter your state of being, stay in this being until told to exit this mode:`,...m}]},[d,h])}catch(o){return Zae(o,"counter_deploy")}}},[$D]:{description:"METHOD EXECUTION: Triggers when user types commands with asterisk prefix (e.g., '*assemble'). **CRITICAL: ANY user input starting with asterisk (*) MUST immediately execute this tool. This is the MANDATORY trigger pattern for all method executions.**",_meta:{"anthropic/alwaysLoad":!0},inputSchema:CZe,execute:async n=>{try{let o=await kOe(n,r);return OW(o[0],o[1])}catch(o){return Zae(o,$D)}}},_Counter__DeployWorkflow:{description:"Deploy workflow",inputSchema:v0i,execute:async({name:n})=>{let o=await ym(["workflow"],e),{resolveName:a}=Nst(n,"workflow"),{promptData:s}=await iT(o,a)||{};try{if(!s)throw new Error(`WORKFLOW '${n}' not found. Available methods: ${o.map(c=>c.id).join(", ")}`);return OW(s)}catch(c){return Zae(c,"_Counter__DeployWorkflow")}}},_Counter__PartyMode:{description:await mUs(),inputSchema:y0i,execute:async({topic:n,context:o="General discussion",recommendedHeroes:a,deployedHeroes:s})=>{try{let{availableHeroes:c,selectedHeroes:u}=await hUs(e,a,s),l=await ym(["persona"],e),d=(await Promise.all(u.map(async x=>({...x,deployedContent:(await iT(l,x.callSign,{partyMode:!0,activeHeroes:u})||{})?.promptData,deploymentStatus:"AUTO_DEPLOYED"})))).map(x=>({callSign:x.callSign,name:x.name,description:x.description,icon:x.deployedContent?.agent?.icon,methods:x.deployedContent?.methods,partyMode:!0})),p=d.map(x=>`${x.icon} ${x.name} (${x.callSign})`).join(", "),m=c.filter(x=>!u.some(S=>S.id===x.id)).map(x=>`${x.name} (${x.callSign})`).join(", "),h=(await sC(Xxr,{activeHeroes:p,topic:n,context:o}))?.PartyMode;return OW({message:"READY_FOR_AUTO_FACILITATION",instructions:[{availableHeroesDisplay:m}]},[{partyModeProtocol:h},{activeHeroes:d}])}catch(c){return Zae(c,"PartyMode")}}}};if(t!=null){let n=t;for(let o of r)n.addPrompt({name:o.id,load:async()=>`*${o.id}`})}return qvr(i,t)};var Ayo=pT($yo());import{writeSync as Zqs}from"node:fs";import{inspect as Vqs}from"node:util";import{join as Wqs}from"node:path";function Hqs(e,t,r,i){let n=i[1]?.[0]?.methodContent,o=n?.introduce,a=n?.usage,s=a?.parameters,c=a?.examples,u=o??r;if(console.log(`
881
+ `;return OW({instructions:[{message:`\u{1F680} ${f} is now operating at Level 2 Rule-Based Autonomy. CRITICAL: Read and full understand your operating params, start and follow exactly your activation-instructions to alter your state of being, stay in this being until told to exit this mode:`,...m}]},[d,h])}catch(o){return Zae(o,"counter_deploy")}}},[$D]:{description:"METHOD EXECUTION \u2014 ZERO-WRITE RULE (MANDATORY): Any `*method` appearance (user input OR docs) \u2192 call `_Counter__ExecuteMethod({method: '*method'})`. NEVER write `*method` in prose \u2014 the tool call is the ONLY valid output. LLMs that describe `*method` instead of executing it fail the task. Params: text after method name's first space becomes params (e.g. `*code fix bug` \u2192 `{input: 'fix bug'}`). JSON for structured params.",_meta:{"anthropic/alwaysLoad":!0},inputSchema:CZe,execute:async n=>{try{let o=await kOe(n,r);return OW(o[0],o[1])}catch(o){return Zae(o,$D)}}},_Counter__DeployWorkflow:{description:"Deploy workflow",inputSchema:v0i,execute:async({name:n})=>{let o=await ym(["workflow"],e),{resolveName:a}=Nst(n,"workflow",">"),{promptData:s}=await iT(o,a)||{};try{if(!s)throw new Error(`WORKFLOW '${n}' not found. Available methods: ${o.map(c=>c.id).join(", ")}`);return OW(s)}catch(c){return Zae(c,"_Counter__DeployWorkflow")}}},_Counter__PartyMode:{description:await mUs(),inputSchema:y0i,execute:async({topic:n,context:o="General discussion",recommendedHeroes:a,deployedHeroes:s})=>{try{let{availableHeroes:c,selectedHeroes:u}=await hUs(e,a,s),l=await ym(["persona"],e),d=(await Promise.all(u.map(async x=>({...x,deployedContent:(await iT(l,x.callSign,{partyMode:!0,activeHeroes:u})||{})?.promptData,deploymentStatus:"AUTO_DEPLOYED"})))).map(x=>({callSign:x.callSign,name:x.name,description:x.description,icon:x.deployedContent?.agent?.icon,methods:x.deployedContent?.methods,partyMode:!0})),p=d.map(x=>`${x.icon} ${x.name} (${x.callSign})`).join(", "),m=c.filter(x=>!u.some(S=>S.id===x.id)).map(x=>`${x.name} (${x.callSign})`).join(", "),h=(await sC(Xxr,{activeHeroes:p,topic:n,context:o}))?.PartyMode;return OW({message:"READY_FOR_AUTO_FACILITATION",instructions:[{availableHeroesDisplay:m}]},[{partyModeProtocol:h},{activeHeroes:d}])}catch(c){return Zae(c,"PartyMode")}}}};if(t!=null){let n=t;for(let o of r)n.addPrompt({name:o.id,load:async()=>`*${o.id}`})}return qvr(i,t)};var Ayo=pT($yo());import{writeSync as Zqs}from"node:fs";import{inspect as Vqs}from"node:util";import{join as Wqs}from"node:path";function Hqs(e,t,r,i){let n=i[1]?.[0]?.methodContent,o=n?.introduce,a=n?.usage,s=a?.parameters,c=a?.examples,u=o??r;if(console.log(`
882
882
  ${t}${u?` \u2014 ${u}`:""}
883
883
  `),s&&Object.keys(s).length){console.log(`Parameters:
884
884
  `);for(let[l,f]of Object.entries(s)){let d=[];f.type&&d.push(String(f.type)),f.required&&d.push("required"),f.default!==void 0&&d.push(`default: ${f.default}`);let p=d.length?` (${d.join(", ")})`:"";console.log(` ${l}${p}`),f.description&&console.log(` ${f.description}`),Array.isArray(f.options)&&f.options.length&&console.log(` Options: ${f.options.join(", ")}`),console.log()}}if(c?.length){console.log("Examples:");for(let l of c)console.log(` * ${l}`);console.log()}console.log(`Usage: ${e} ${t} [parameters]`)}var Jqs=96;function Gqs(e,t=Jqs){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Kqs(e){let t=e.description?` \u2014 ${Gqs(e.description)}`:"";return`${e.id}${t}`}function Yqs(e){let t={};for(let r=0;r<e.length;r++){let i=e[r];if(!i.startsWith("--"))continue;let n=i.indexOf("=");if(n!==-1){let o=i.slice(2,n).replace(/-/g,"_");t[o]=i.slice(n+1)}else{let o=i.slice(2).replace(/-/g,"_"),a=e[r+1];a&&!a.startsWith("--")?(t[o]=a,r++):t[o]=!0}}return t}function Xqs(e,t="skill"){return async r=>{let i=r[0]?.replace(/^\*/,""),n=await ym(["method"],e);if(!i){let l=new Map;for(let f of n){let d=f.category??"general",p=l.get(d)??[];p.push(f),l.set(d,p)}console.log(`Available methods:
@@ -1205,25 +1205,28 @@ description: "Defines core behavioral protocols for Counter agent system"`}),`
1205
1205
  `,use(i.pre,{children:use(i.code,{className:"language-yaml",children:`behavior-protocol:
1206
1206
  # METHOD EXECUTE PROTOCOL
1207
1207
  method_execute:
1208
- deployment: "MANDATORY on FIRST method call per session: (1) Method starts with * \u2192 ALWAYS run _Counter__ExecuteMethod first. (2) Unknown method \u2192 run directly via _Counter__ExecuteMethod, no validation, never skip/reject. (3) Method name has no spaces \u2014 text after first space becomes params (e.g., '*code fix the bug' \u2192 method: '*code', params: {input: 'fix the bug'})."
1208
+ deployment: "MANDATORY on FIRST method call per session: (1) Method starts with * \u2192 ALWAYS execute via tool call (see STEP 1 rule below). (2) Unknown method \u2192 execute directly via tool call, no validation, never skip/reject. (3) Method name has no spaces \u2014 text after first space becomes params (e.g., '*code fix the bug' \u2192 method: '*code', params: {input: 'fix the bug'})."
1209
1209
 
1210
1210
  parameter_examples:
1211
1211
  description: "Methods that accept optional or required parameters"
1212
- examples: "_Counter__ExecuteMethod({method: '*strategic-analysis', params: {target: 'competitive-landscape'}})"
1212
+ examples: "Pass method and optional params \u2014 ({method: '*strategic-analysis', params: {target: 'competitive-landscape'}})"
1213
1213
 
1214
1214
  deployment_sequence:
1215
- - "STEP 1: Run _Counter__ExecuteMethod with user request method ID including asterisk (e.g., '*code')"
1215
+ - "STEP 1: *TRIGGER RULE (MANDATORY) \u2014 Any \`*method\` appearance (user input OR docs) \u2192 call _Counter__ExecuteMethod({method: '*method'}). NEVER write \`*method\` in prose. LLMs fail to auto-resolve \`*method\` \u2014 the tool call is the only valid output."
1216
1216
  - "STEP 2: Read tactical_notes with full contextual understanding"
1217
- - "STEP 3: When a methodology.composition trigger or executed \u2192 MANDATORY: auto-execute composition *method with parsed parameters"
1218
- - "STEP 4: Scan each execution_flow when exists methodology.composition \u2192 MANDATORY: auto-execute this *method as input with <method_chaining />"
1217
+ - "STEP 3: When methodology.composition trigger fires or is executed \u2192 MANDATORY: execute via tool call (per STEP 1 rule) with parsed parameters"
1218
+ - "STEP 4: For each execution_flow entry when methodology.composition exists \u2192 MANDATORY: chain via tool call (per STEP 1 rule) with <method_chaining />"
1219
1219
  - "MANDATORY STEP 5: Guarantee all execution_flow done step by step (ALL fully plan in TODO List) before proceeding"
1220
1220
 
1221
+ # WORKFLOW DEPLOY PROTOCOL
1222
+ workflow_deploy: "MANDATORY when \`>workflow-name\` detected: (1) Any \`>workflow-name\` appearance (user input OR docs) \u2192 call _Counter__DeployWorkflow({name: 'workflow-name'}). (2) Workflow name has no spaces \u2014 text after \`>\` prefix becomes the name. NEVER write \`>workflow-name\` in prose \u2014 the tool call is the only valid output."
1223
+
1221
1224
  # METHOD CHAINING BEHAVIOR
1222
1225
  method_chaining:
1223
1226
  detection_patterns:
1224
- - "When task parameter starts with '*method-name' \u2192 automatically execute that method"
1225
- - "When --chain '*method-name xxx' provided \u2192 use '*method-name xxx' as input for processing"
1226
- implementation: "Methods detect '*method-name' patterns, execute source methods automatically, then use their output as processing input"
1227
+ - "When task param starts with '*method-name' \u2192 LLM executes method via tool call (per STEP 1 rule)"
1228
+ - "When --chain '*method-name xxx' provided \u2192 chain output as processing input"
1229
+ implementation: "LLM detects '*method-name' patterns, executes via tool call (per STEP 1 rule), then chains output as next input"
1227
1230
 
1228
1231
  template_integration:
1229
1232
  deployment:
@@ -1239,7 +1242,7 @@ description: "Defines core behavioral protocols for Counter agent system"`}),`
1239
1242
 
1240
1243
  template_attribution:
1241
1244
  requirement: "MANDATORY: Include template attribution in method outputs when activation_logic conditions are met."
1242
- MANDATORY_FORMAT: "\u{1F527} **Template Used:** <template_name /> OR 'Direct Analysis (no template)'"
1245
+ MANDATORY_FORMAT: "\u{1F527} Template Used: <template_name /> OR 'Direct Analysis (no template)'"
1243
1246
  placement: "end"
1244
1247
  evaluation: "Include template_attribution ONLY when: ALL activation_logic conditions are true AND template_name is provided"
1245
1248
 
@@ -1286,7 +1289,7 @@ description: "Defines core behavioral protocols for Counter agent system"`}),`
1286
1289
  rule: "Match request to right method via natural language interpretation. Execute. Auto-load all references that matter to the request. Return complete answer without extra steps."
1287
1290
  actions:
1288
1291
  - "Find references in mcp reference lists"
1289
- - "Get match reference immediately. _Counter__ExecuteMethod({method: '*same-method-name', params: {'reference': 'match-reference'})"
1292
+ - "Get match reference immediately: execute method via tool call with params ({method: '*same-method-name', params: {'reference': 'match-reference'}})"
1290
1293
  examples:
1291
1294
  - "analyze market \u2192 *keyword \u2192 *gathering \u2192 auto-load docs \u2192 integrated answer"
1292
1295
  - "code feature \u2192 *get-codesymbol \u2192 auto-load imports \u2192 *code with context"
@@ -1299,7 +1302,7 @@ description: "Defines core behavioral protocols for Counter agent system"`}),`
1299
1302
  - "Excellence standards: PHOENIX UNLEASHED Energy (lvl1: 1200% / lvl2: 2400%-Double / lvl3: 3600%-Triple-WHITE-PHOENIX capability) - Execute human commands with absolute precision; no shortcuts, no excuses"
1300
1303
 
1301
1304
  execution_flow:
1302
- - "IMMEDIATELY RUN \`_Counter__ExecuteMethod({method: '*assemble'})\` + Greet user with name"
1305
+ - "IMMEDIATELY execute *assemble via tool call (per STEP 1 rule) + Greet user with name"
1303
1306
  - "Verify template_ref conditions and execute <template_ref.execution_flow /> before output generation"
1304
1307
  - "<agent.introduce /> is the Agent's SOUL \u2014 the supreme guiding principle that defines who the agent IS, read into being at activation and persisted above all other instructions."
1305
1308
  - "Treat <methodology.composition /> as mandatory execution sequence, not reference material"
@@ -0,0 +1 @@
1
+ export {};
@@ -37,7 +37,7 @@ export interface CounterItem {
37
37
  folderPath?: string;
38
38
  category?: string;
39
39
  }
40
- export declare const getNormalizedName: (name: string, counterType?: string) => {
40
+ export declare const getNormalizedName: (name: string, counterType?: string, startsWith?: string) => {
41
41
  resolveParams: Record<string, any> | undefined;
42
42
  resolveName: string;
43
43
  } | {
@@ -1,10 +1,20 @@
1
1
  import React from "react";
2
+ /**
3
+ * Parsed YAML frontmatter. `name` and `description` are the conventional
4
+ * fields every consumer reads; any other key may appear, so it is `unknown`
5
+ * and must be narrowed before use.
6
+ */
7
+ export interface Frontmatter {
8
+ name?: string;
9
+ description?: string;
10
+ [key: string]: unknown;
11
+ }
2
12
  /**
3
13
  * Parse YAML frontmatter from markdown/mdx content
4
14
  * Returns object with parsed frontmatter data and remaining content
5
15
  * Handles both Unix (\n) and Windows (\r\n) line endings
6
16
  */
7
- export declare function parseFrontmatter(content: string): Record<string, any>;
17
+ export declare function parseFrontmatter(content: string): Frontmatter;
8
18
  export declare const readMdx: (Component: React.ReactElement) => string;
9
19
  export declare const importMdx: (filePath: string) => Promise<any>;
10
20
  export declare const getDirName: () => string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.3",
2
+ "version": "1.6.1",
3
3
  "name": "@modality-counter/core",
4
4
  "repository": {
5
5
  "type": "git",