@modality-counter/core 1.2.2 → 1.2.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
@@ -562,13 +562,13 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
562
562
  `).filter(n=>n.indexOf("at load")!==-1).pop()),i||(i=r.stack?.split(`
563
563
  `).filter(n=>n.indexOf("at <anonymous>")!==-1).pop()),i){let n=/(?<path>[^\(\s]+):[0-9]+:[0-9]+/.exec(i)?.groups?.path.replace("file://","");e=W0a(n||"")}}return e||process.cwd()},Y0a=async e=>{let t=await import(e);if(typeof t.default!="function")throw new Error(`MDX file at ${e} does not export a valid React component. ${t.default}`);return t.default};import{YAML as e_a}from"bun";import{jsx as Bhi}from"react/jsx-runtime";function Vhi(e,t){let r={...e};return WZt(e)&&WZt(t)&&Object.keys(t).forEach(i=>{Array.isArray(t[i])?Array.isArray(r[i])?r[i].push(...t[i]):r[i]=t[i]:WZt(t[i])&&i in e?r[i]=Vhi(e[i],t[i]):r[i]=t[i]}),r}function WZt(e){return e&&typeof e=="object"&&!Array.isArray(e)}var Whi=async(e,t)=>{if(typeof e=="string"){let r=await VZt(e);return Gqe(Bhi(r,{...t}))}else return Gqe(Bhi(e,{...t}))},DN=async(e,t)=>{let r=await Whi(e,t),o=Hhi(r).filter(a=>a.language==="yaml"||a.language==="yml").reduce((a,s)=>{let u=e_a.parse(s.code);return Vhi(a,u)},{});if(typeof e=="string"){let a=Zhi(e,"utf-8"),s=FQ(a);Object.assign(o,s)}return o};function t_a(e){try{let t=__dirname||Q0a(__filename),r=X0a(t,"prompts",e);return Zhi(r,"utf-8")}catch(t){throw console.error(`Failed to read prompt file: ${e}`,t),new Error(`Could not load prompt: ${e}`)}}function Hhi(e){let t=/```(\w+)?\n?([\s\S]*?)\n?```/g,r=[],i;for(;(i=t.exec(e))!==null;)r.push({language:i[1]?.toLowerCase().trim()||"",code:i[2].trim()});return r}import{existsSync as n4s}from"fs";import{join as i4s,basename as lvr,extname as o4s,dirname as a4s}from"path";var Kqe=["persona","method","workflow"],Jhi=Ce.object({topic:Ce.string().describe("The topic for the Counter to discuss and debate"),context:Ce.string().optional().describe("Optional additional context or background for the discussion"),recommendedHeroes:Ce.array(Ce.string()).optional().describe("Optional array of recommended hero names or call signs to prioritize for the discussion"),deployedHeroes:Ce.array(Ce.string()).optional().describe("CRITICAL: Array of hero names or call signs already active in current session - prevents duplicate deployment and maintains session continuity. Use when adding heroes to existing active sessions.")}).describe("Start a party mode discussion with all Counter heroes"),Ghi=Ce.object({method:Ce.string().describe("The method name to execute"),params:Ce.preprocess(e=>typeof e=="string"?JSON.parse(e):e,Ce.record(Ce.string(),Ce.any())).optional().describe("Parameters for the method")}),Khi=Ce.object({callSign:Ce.string().describe("The callSign to deploy (e.g., 'SARAH', 'JAMES')")}).describe("Deploy a specific Counter hero persona"),Yhi=Ce.object({name:Ce.string().describe("The workflow identifier to deploy (e.g., 'team-architect')")}).describe("Execute a specific Counter workflow for multi-step task orchestration"),Xhi=Ce.object({types:Ce.array(Ce.enum(Kqe)).default(["persona"]).describe("Array of resource types to filter by. Defaults to ['persona'] for hero listings")}).describe("Get Counter resources filtered by type");mno();var ryr=(e,t)=>(t&&Object.entries(e).forEach(([r,i])=>{let n=i.name!=null?i.name:r,{inputSchema:o,...a}=i;t.addTool({...a,parameters:o,name:n})}),e);KV();KV();var c4u=300*1e3,l4u={initialize:1800*1e3,"tools/list":300*1e3,"resources/list":60*1e3,"prompts/list":300*1e3};KV();var KNs=function(t){var r,i=(r=(t??"")[0])===null||r===void 0?void 0:r.toUpperCase();return i?i+t.slice(1):null},xco=KNs;var YNs={code:["change","modify","develop","update","implement","add","remove","fix","improve"],"code-verify":["check","code-test"],"fix-bun-test":["bun-test"],"counter-manager":["method-manager"],presentation:["ppt"],"daily-planner":["daily"],help:["assemble"],"business-edm":["b2b"],"transform-narrative":["write"],"persuade-convert":["sell"],"technical-engage":["blog"],"task-decomposer":["atomic"],"content-intelligence":["content","audit","audience"],"visual-craft":["image"],"get-cursor-codesymbol":["cursor"],"fomo-retail-investor":["fomo"],"crisis-response":["sos"]},XNs={change:{method:"code"},modify:{method:"code"},develop:{method:"code"},update:{method:"code"},implement:{method:"code"},add:{method:"code"},remove:{method:"code"},fix:{method:"code"},improve:{method:"code"},check:{method:"code-verify"},"code-test":{method:"code-verify"},"bun-test":{method:"fix-bun-test"},"method-manager":{method:"counter-manager",parameters:{"component-type":"method"}},daily:{method:"daily-planner",parameters:{action:"now"}},atomic:{method:"task-decomposer",parameters:{action:"ai-first"}},ppt:{method:"presentation"},help:{method:"assemble"},b2b:{method:"business-edm"},write:{method:"transform-narrative"},sell:{method:"persuade-convert"},blog:{method:"technical-engage"},content:{method:"content-intelligence",parameters:{action:"comprehensive"}},audit:{method:"content-intelligence",parameters:{action:"persuasion"}},audience:{method:"content-intelligence",parameters:{action:"audience"}},image:{method:"visual-craft"},cursor:{method:"get-cursor-codesymbol"},fomo:{method:"fomo-retail-investor"},sos:{method:"crisis-response"}},_co=e=>YNs[e]||[],iat=e=>XNs[e];var cvr={dev:"JAMES",developer:"JAMES",engineer:"JAMES",code:"JAMES",implementation:"JAMES",strategy:"FRIDAY",analyst:"FRIDAY",intel:"FRIDAY",research:"FRIDAY",po:"SARAH",design:"WANDA",designer:"WANDA",ux:"WANDA",ui:"WANDA",finance:"PEPPER",financial:"PEPPER",business:"PEPPER",cfo:"PEPPER"};function Sco(e){let t=e.toLowerCase().trim();return cvr[t]?.toLowerCase()||t}async function wco(){try{return(await Ig(["persona"])).map(t=>xco(t.name))}catch(e){return console.error("Failed to get hero names:",e),[]}}KV();import{existsSync as QNs,readFileSync as e4s}from"fs";import{basename as kco,dirname as t4s}from"path";async function r4s(e){let t={};if(!e||!QNs(e))return t;try{let r=t4s(e),i=kco(e),n=lae(r,{targetFolderName:i,fileExtensions:oat,fileNameFilter:o=>!o.toLowerCase().includes("readme")&&!o.toLowerCase().includes("summary"),excludePatterns:[".","_"]});for(let o of n)try{let a=e4s(o.fullPath,"utf-8"),s=FQ(a),u=kco(o.fullPath),c=s.description,l=s.name;t[u]={description:c,name:l,content:a}}catch(a){console.warn(`Failed to read ${o.fullPath}:`,a)}}catch(r){console.warn("Failed to scan references directory:",r)}return t}async function Eco(e,t){if(!e)return;let r=await r4s(e+"/references");if(!r||Object.keys(r).length===0)return;let i=Object.entries(r).map(([n,o])=>`- ${n}: ${o.description||""}`).join(`
564
564
 
565
- `);return{referenceInstructions:[`Review these available references. MANDATORY: If the user's task matches any reference by filename, name, or description, load the relevant reference BEFORE answering, planning, or editing files using: ${ZU}(method: "${t}", params: {reference: "<filename.md>"})`,i],referenceList:r}}var oat=[".md",".mdx"],uat=(e,t="method")=>{let r=(e.startsWith("*")?e.slice(1):e).trim().toLowerCase(),i=`${t}-`;if(t==="method"){let n=iat(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 ZI(e,t,r,i){let n=e.find(o=>o.callSign===t.trim());try{if(!n)return!1;let o;r?.partyMode&&(o=`**PARTY MODE ACTIVE - ENGAGE OPENING PHASE PROTOCOLS NOW!**
565
+ `);return{referenceInstructions:[`Review these available references. MANDATORY: If the user's task matches any reference by filename, name, or description, load the relevant reference BEFORE answering, planning, or editing files using: ${ZU}(method: "*${t}", params: {reference: "<filename.md>"})`,i],referenceList:r}}var oat=[".md",".mdx"],uat=(e,t="method")=>{let r=(e.startsWith("*")?e.slice(1):e).trim().toLowerCase(),i=`${t}-`;if(t==="method"){let n=iat(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 ZI(e,t,r,i){let n=e.find(o=>o.callSign===t.trim());try{if(!n)return!1;let o;r?.partyMode&&(o=`**PARTY MODE ACTIVE - ENGAGE OPENING PHASE PROTOCOLS NOW!**
566
566
 
567
567
  **ACTIVE HEROES: ${r.activeHeroes||"UNKNOWN"}**
568
568
 
569
569
  **BEGIN OPENING PHASE BANTER NOW - DO NOT WAIT FOR USER INPUT**
570
570
 
571
- `);let a=await DN(n.filePath,r);a.callSign=t;let s;if(i){let c=s4s(n.folderPath);if(c){let{aiTool:l}=await import(c),f=l.inputSchema;if(f){let d=await Yit(f);if(a.method.usage.parameters=d.properties,d.required&&d.required.length>0)for(let p of d.required)a.method.usage.parameters[p]=a.method.usage.parameters[p]||{},a.method.usage.parameters[p].required=!0;if(r!=null){let p={};Object.keys(d.properties||{}).forEach(h=>{p[h]=r[h]??void 0});let m=f.safeParse(p);if(!m.success)throw new Error(`Invalid parameters for ${t}: ${m.error.message}`)}}s=l.execute}}let u=await Eco(n.folderPath,t);return u&&(a.method.references=u),{promptData:a,counterScript:s,partyMode:o}}catch(o){throw new Error(`Failed to get CounterContent for '${t}': ${o}`)}}var s4s=e=>{if(e){let t=i4s(e,"scripts","index.ts");if(n4s(t))return t}},aat=null;async function Ig(e=[],t=import.meta.dir){if(aat==null){aat=u8t();for(let i of Kqe)aat[i]=await u4s(t,i)}(!e||e.length===0)&&(e=[...Kqe]);let r=[];for(let i of e)r.push(...aat[i]||[]);return r}async function u4s(e,t){let r=[],i,n,o=!1;t==="method"?(i="skills",n=s=>s==="SKILL.mdx",o=!0):(i=`${t}s`,n=s=>s.endsWith(".md")||s.endsWith(".mdx"));let a=lae(e,{targetFolderName:i,fileNameFilter:n,searchInSubfolders:o,fileExtensions:oat,excludePatterns:[".","__","hidden"]});if(t==="method")for(let s of a){let u=await DN(s.fullPath),c=a4s(s.fullPath),l=lvr(c).toLowerCase();r.push({callSign:`${t}-${l}`,type:t,id:l,name:sat(u,["name"]),folderPath:c,filePath:s.fullPath,description:sat(u,["description"]),category:sat(u,["category"])})}else for(let s of a){let u=await DN(s.fullPath),c=c4s(lvr(s.fullPath));r.push({callSign:`${t}-${c}`,type:t,id:c,name:u.name,description:u.description,category:sat(u,["category"]),filePath:s.fullPath})}return r}var c4s=e=>lvr(e,o4s(e)).toLowerCase(),sat=(e,t)=>{let r=["agent","method"];for(let i of r)for(let n of t){let o=sE(e,[i,n]);if(o!=null)return o}};function Ico(e){let t={fileExtensions:oat,fileNameFilter:r=>r.includes("tmpl")};return[...lae(e,{...t,targetFolderName:"templates"}),...lae(e,{...t,targetFolderName:"assets"})]}KV();KV();async function STe(e,t){let{method:r,params:i={}}=e,{resolveName:n,resolveParams:o}=uat(r),a={...o,...i||{}},s=a.reference,u=await ZI(t,n,a,!s);if(!u)throw new Error(`METHOD '${r}' not found. Available methods: ${t.map($=>$.name).join(", ")}`);let c=u.promptData,l=sE(c,["method","references","referenceList"]),f=Object.keys(l||{});if(s!=null&&f.length){let $=f.filter(z=>z.startsWith(s)||z===s);if($.length===1)return[{message:sE(l,[$[0]])}];let D=f.sort().join(`,
571
+ `);let a=await DN(n.filePath,r);a.callSign=t;let s;if(i){let c=s4s(n.folderPath);if(c){let{aiTool:l}=await import(c),f=l.inputSchema;if(f){let d=await Yit(f);if(a.method.usage.parameters=d.properties,d.required&&d.required.length>0)for(let p of d.required)a.method.usage.parameters[p]=a.method.usage.parameters[p]||{},a.method.usage.parameters[p].required=!0;if(r!=null){let p={};Object.keys(d.properties||{}).forEach(h=>{p[h]=r[h]??void 0});let m=f.safeParse(p);if(!m.success)throw new Error(`Invalid parameters for ${t}: ${m.error.message}`)}}s=l.execute}}let u=await Eco(n.folderPath,n.id);return u&&(a.method.references=u),{promptData:a,counterScript:s,partyMode:o}}catch(o){throw new Error(`Failed to get CounterContent for '${t}': ${o}`)}}var s4s=e=>{if(e){let t=i4s(e,"scripts","index.ts");if(n4s(t))return t}},aat=null;async function Ig(e=[],t=import.meta.dir){if(aat==null){aat=u8t();for(let i of Kqe)aat[i]=await u4s(t,i)}(!e||e.length===0)&&(e=[...Kqe]);let r=[];for(let i of e)r.push(...aat[i]||[]);return r}async function u4s(e,t){let r=[],i,n,o=!1;t==="method"?(i="skills",n=s=>s==="SKILL.mdx",o=!0):(i=`${t}s`,n=s=>s.endsWith(".md")||s.endsWith(".mdx"));let a=lae(e,{targetFolderName:i,fileNameFilter:n,searchInSubfolders:o,fileExtensions:oat,excludePatterns:[".","__","hidden"]});if(t==="method")for(let s of a){let u=await DN(s.fullPath),c=a4s(s.fullPath),l=lvr(c).toLowerCase();r.push({callSign:`${t}-${l}`,type:t,id:l,name:sat(u,["name"]),folderPath:c,filePath:s.fullPath,description:sat(u,["description"]),category:sat(u,["category"])})}else for(let s of a){let u=await DN(s.fullPath),c=c4s(lvr(s.fullPath));r.push({callSign:`${t}-${c}`,type:t,id:c,name:u.name,description:u.description,category:sat(u,["category"]),filePath:s.fullPath})}return r}var c4s=e=>lvr(e,o4s(e)).toLowerCase(),sat=(e,t)=>{let r=["agent","method"];for(let i of r)for(let n of t){let o=sE(e,[i,n]);if(o!=null)return o}};function Ico(e){let t={fileExtensions:oat,fileNameFilter:r=>r.includes("tmpl")};return[...lae(e,{...t,targetFolderName:"templates"}),...lae(e,{...t,targetFolderName:"assets"})]}KV();KV();async function STe(e,t){let{method:r,params:i={}}=e,{resolveName:n,resolveParams:o}=uat(r),a={...o,...i||{}},s=a.reference,u=await ZI(t,n,a,!s);if(!u)throw new Error(`METHOD '${r}' not found. Available methods: ${t.map($=>$.name).join(", ")}`);let c=u.promptData,l=sE(c,["method","references","referenceList"]),f=Object.keys(l||{});if(s!=null&&f.length){let $=f.filter(z=>z.startsWith(s)||z===s);if($.length===1)return[{message:sE(l,[$[0]])}];let D=f.sort().join(`,
572
572
  `);throw new Error(`Failed to load reference content. (${s}).
573
573
 
574
574
  Available references:
@@ -9,7 +9,7 @@ export type MethodReference = Record<string, {
9
9
  content?: string;
10
10
  }>;
11
11
  export declare function getReferenceData(referencesDir?: string): Promise<MethodReference>;
12
- export declare function buildReferences(folderPath: string | undefined, callSign: string): Promise<{
12
+ export declare function buildReferences(folderPath: string | undefined, methodId: string): Promise<{
13
13
  referenceInstructions: string[];
14
14
  referenceList: MethodReference;
15
15
  } | undefined>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.2",
2
+ "version": "1.2.3",
3
3
  "name": "@modality-counter/core",
4
4
  "repository": {
5
5
  "type": "git",