@modality-counter/core 0.8.3 → 0.8.5
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
|
@@ -460,7 +460,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
|
|
|
460
460
|
`),r=/^---\n([\s\S]+?)\n---/,n=t.match(r);if(!n||!n[1])return{};let i=n[1].trim(),o=i.split(`
|
|
461
461
|
`).filter(s=>s.trim());if(!o.every(s=>{let u=s.trim();return/^[#`*\-]/.test(u)?!1:s.includes(":")}))return{};try{let s=D0a.parse(i);return typeof s!="object"||s===null||Array.isArray(s)?{}:s}catch{let s={};for(let u of o){let c=u.indexOf(":");if(c>0){let l=u.slice(0,c).trim(),f=u.slice(c+1).trim();l&&(s[l]=f)}}return s}}var BBe=e=>{let t=N0a(Esi(e)());return L0a.translate(t)},z0a=e=>e.endsWith(".mdx")||e.endsWith(".md")?e:`${e}.mdx`,FUt=async e=>{if(e==null)throw new Error(`Invalid file path: ${e}. Path must be relative and have .md or .mdx extension.`);let t=z0a(e),r=U0a(),n=F0a(r,t);return await j0a(n)},U0a=()=>{let e="";try{_NOT_DEFINED}catch(t){let r=t,n=r.stack?.match(/^\s*at\s+\/[^\s:()]+\.\w+:\d+:\d+$/m)?.[0].trim();if(n||(n=r.stack?.split(`
|
|
462
462
|
`).filter(i=>i.indexOf("at load")!==-1).pop()),n||(n=r.stack?.split(`
|
|
463
|
-
`).filter(i=>i.indexOf("at <anonymous>")!==-1).pop()),n){let i=/(?<path>[^\(\s]+):[0-9]+:[0-9]+/.exec(n)?.groups?.path.replace("file://","");e=$0a(i||"")}}return e||process.cwd()},j0a=async e=>{try{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}catch(t){throw console.error(`Failed to import MDX file: ${e}`),t}};import{YAML as Z0a}from"bun";import{jsx as Bhi}from"react/jsx-runtime";function Zhi(e,t){let r={...e};return LUt(e)&&LUt(t)&&Object.keys(t).forEach(n=>{Array.isArray(t[n])?Array.isArray(r[n])?r[n].push(...t[n]):r[n]=t[n]:LUt(t[n])&&n in e?r[n]=Zhi(e[n],t[n]):r[n]=t[n]}),r}function LUt(e){return e&&typeof e=="object"&&!Array.isArray(e)}var Whi=async(e,t)=>{if(typeof e=="string"){let r=await FUt(e);return BBe(Bhi(r,{...t}))}else return BBe(Bhi(e,{...t}))},AR=async(e,t)=>{let r=await Whi(e,t),o=Vhi(r).filter(a=>a.language==="yaml"||a.language==="yml").reduce((a,s)=>{let u=Z0a.parse(s.code);return Zhi(a,u)},{});if(typeof e=="string"){let a=qhi(e,"utf-8"),s=aee(a);Object.assign(o,s)}return o};function W0a(e){try{let t=__dirname||q0a(__filename),r=B0a(t,"prompts",e);return qhi(r,"utf-8")}catch(t){throw console.error(`Failed to read prompt file: ${e}`,t),new Error(`Could not load prompt: ${e}`)}}function Vhi(e){let t=/```(\w+)?\n?([\s\S]*?)\n?```/g,r=[],n;for(;(n=t.exec(e))!==null;)r.push({language:n[1]?.toLowerCase().trim()||"",code:n[2].trim()});return r}import{existsSync as buo,readFileSync as A3s}from"fs";import{join as C3s,basename as NIe,extname as O3s,dirname as xuo}from"path";var qBe=["persona","method","workflow"],Hhi=We.object({topic:We.string().describe("The topic for the Counter to discuss and debate"),context:We.string().optional().describe("Optional additional context or background for the discussion"),recommendedHeroes:We.array(We.string()).optional().describe("Optional array of recommended hero names or call signs to prioritize for the discussion"),deployedHeroes:We.array(We.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=We.object({method:We.string().describe("The method name to execute"),params:We.record(We.string(),We.any()).optional().describe("Parameters for the method")}),Jhi=We.object({callSign:We.string().describe("The callSign to deploy (e.g., 'SARAH', 'JAMES')")}).describe("Deploy a specific Counter hero persona"),Khi=We.object({name:We.string().describe("The workflow identifier to deploy (e.g., 'team-architect')")}).describe("Execute a specific Counter workflow for multi-step task orchestration"),Yhi=We.object({types:We.array(We.enum(qBe)).default(["persona"]).describe("Array of resource types to filter by. Defaults to ['persona'] for hero listings")}).describe("Get Counter resources filtered by type");dro();var Wpr=(e,t)=>(t&&Object.entries(e).forEach(([r,n])=>{let i=n.name!=null?n.name:r,{inputSchema:o,...a}=n;t.addTool({...a,parameters:o,name:i})}),e);est();est();var cMu=300*1e3,lMu={initialize:1800*1e3,"tools/list":300*1e3,"resources/list":60*1e3,"prompts/list":300*1e3};async function eC(e,t,r,n){let i=e.find(o=>o.callSign===t.trim());try{if(!i)return!1;let o;r?.partyMode&&(o=`**PARTY MODE ACTIVE - ENGAGE OPENING PHASE PROTOCOLS NOW!**
|
|
463
|
+
`).filter(i=>i.indexOf("at <anonymous>")!==-1).pop()),n){let i=/(?<path>[^\(\s]+):[0-9]+:[0-9]+/.exec(n)?.groups?.path.replace("file://","");e=$0a(i||"")}}return e||process.cwd()},j0a=async e=>{try{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}catch(t){throw console.error(`Failed to import MDX file: ${e}`),t}};import{YAML as Z0a}from"bun";import{jsx as Bhi}from"react/jsx-runtime";function Zhi(e,t){let r={...e};return LUt(e)&&LUt(t)&&Object.keys(t).forEach(n=>{Array.isArray(t[n])?Array.isArray(r[n])?r[n].push(...t[n]):r[n]=t[n]:LUt(t[n])&&n in e?r[n]=Zhi(e[n],t[n]):r[n]=t[n]}),r}function LUt(e){return e&&typeof e=="object"&&!Array.isArray(e)}var Whi=async(e,t)=>{if(typeof e=="string"){let r=await FUt(e);return BBe(Bhi(r,{...t}))}else return BBe(Bhi(e,{...t}))},AR=async(e,t)=>{let r=await Whi(e,t),o=Vhi(r).filter(a=>a.language==="yaml"||a.language==="yml").reduce((a,s)=>{let u=Z0a.parse(s.code);return Zhi(a,u)},{});if(typeof e=="string"){let a=qhi(e,"utf-8"),s=aee(a);Object.assign(o,s)}return o};function W0a(e){try{let t=__dirname||q0a(__filename),r=B0a(t,"prompts",e);return qhi(r,"utf-8")}catch(t){throw console.error(`Failed to read prompt file: ${e}`,t),new Error(`Could not load prompt: ${e}`)}}function Vhi(e){let t=/```(\w+)?\n?([\s\S]*?)\n?```/g,r=[],n;for(;(n=t.exec(e))!==null;)r.push({language:n[1]?.toLowerCase().trim()||"",code:n[2].trim()});return r}import{existsSync as buo,readFileSync as A3s}from"fs";import{join as C3s,basename as NIe,extname as O3s,dirname as xuo}from"path";var qBe=["persona","method","workflow"],Hhi=We.object({topic:We.string().describe("The topic for the Counter to discuss and debate"),context:We.string().optional().describe("Optional additional context or background for the discussion"),recommendedHeroes:We.array(We.string()).optional().describe("Optional array of recommended hero names or call signs to prioritize for the discussion"),deployedHeroes:We.array(We.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=We.object({method:We.string().describe("The method name to execute"),params:We.preprocess(e=>typeof e=="string"?JSON.parse(e):e,We.record(We.string(),We.any())).optional().describe("Parameters for the method")}),Jhi=We.object({callSign:We.string().describe("The callSign to deploy (e.g., 'SARAH', 'JAMES')")}).describe("Deploy a specific Counter hero persona"),Khi=We.object({name:We.string().describe("The workflow identifier to deploy (e.g., 'team-architect')")}).describe("Execute a specific Counter workflow for multi-step task orchestration"),Yhi=We.object({types:We.array(We.enum(qBe)).default(["persona"]).describe("Array of resource types to filter by. Defaults to ['persona'] for hero listings")}).describe("Get Counter resources filtered by type");dro();var Wpr=(e,t)=>(t&&Object.entries(e).forEach(([r,n])=>{let i=n.name!=null?n.name:r,{inputSchema:o,...a}=n;t.addTool({...a,parameters:o,name:i})}),e);est();est();var cMu=300*1e3,lMu={initialize:1800*1e3,"tools/list":300*1e3,"resources/list":60*1e3,"prompts/list":300*1e3};async function eC(e,t,r,n){let i=e.find(o=>o.callSign===t.trim());try{if(!i)return!1;let o;r?.partyMode&&(o=`**PARTY MODE ACTIVE - ENGAGE OPENING PHASE PROTOCOLS NOW!**
|
|
464
464
|
|
|
465
465
|
**ACTIVE HEROES: ${r.activeHeroes||"UNKNOWN"}**
|
|
466
466
|
|
|
@@ -646,7 +646,7 @@ ${r.join(`
|
|
|
646
646
|
\u274C FAILURES (${r.length}/${t.length}):
|
|
647
647
|
${r.join(`
|
|
648
648
|
`)}
|
|
649
|
-
`),new Error(`Validation failed for ${r.length} files.`);console.log(`\u2705 Validated ${t.length} methods`),DMs(r.length).toBe(0)})})}import{describe as jMs,test as BMs,expect as qMs}from"bun:test";var $Ms=We.object({id:We.string().min(1,"Agent ID is required").regex(/^[a-z-]+$/,"Agent ID should follow format: {role} (e.g., developer, analyst)"),icon:We.string().min(1,"Agent icon is required").regex(/^[\u{1F000}-\u{1F9FF}\u{2600}-\u{27BF}\u{E000}-\u{F8FF}][\u{FE00}-\u{FE0F}]?$/u,"Agent icon should be a single emoji"),introduce:We.string().min(100,"Agent introduction should be at least 100 characters for proper context").max(2e3,"Agent introduction should not exceed 2000 characters for readability").regex(/^[A-Z]/,"Agent introduction should start with capital letter"),acronym:We.string().min(5,"Agent acronym should be at least 10 characters").max(200,"Agent acronym should not exceed 200 characters"),whenToUse:We.array(We.string().min(3,"When to use item should be at least 3 characters").max(70,"When to use item should not exceed 70 characters")).min(3,"Agent should have at least 3 use cases").max(10,"Agent should not exceed 10 use cases for clarity")}).strict(),FMs=We.object({
|
|
649
|
+
`),new Error(`Validation failed for ${r.length} files.`);console.log(`\u2705 Validated ${t.length} methods`),DMs(r.length).toBe(0)})})}import{describe as jMs,test as BMs,expect as qMs}from"bun:test";var $Ms=We.object({id:We.string().min(1,"Agent ID is required").regex(/^[a-z-]+$/,"Agent ID should follow format: {role} (e.g., developer, analyst)"),icon:We.string().min(1,"Agent icon is required").regex(/^[\u{1F000}-\u{1F9FF}\u{2600}-\u{27BF}\u{E000}-\u{F8FF}][\u{FE00}-\u{FE0F}]?$/u,"Agent icon should be a single emoji"),introduce:We.string().min(100,"Agent introduction should be at least 100 characters for proper context").max(2e3,"Agent introduction should not exceed 2000 characters for readability").regex(/^[A-Z]/,"Agent introduction should start with capital letter"),acronym:We.string().min(5,"Agent acronym should be at least 10 characters").max(200,"Agent acronym should not exceed 200 characters"),whenToUse:We.array(We.string().min(3,"When to use item should be at least 3 characters").max(70,"When to use item should not exceed 70 characters")).min(3,"Agent should have at least 3 use cases").max(10,"Agent should not exceed 10 use cases for clarity")}).strict(),FMs=We.object({core_principles:j3}).strict(),LMs=We.record(We.string().min(1,"Method key is required").regex(/^[a-z0-9-]+$/,"Method key should be lowercase with hyphens and numbers only"),We.string().min(10,"Method description should be at least 10 characters").max(500,"Method description should not exceed 500 characters")).refine(e=>Object.keys(e).length>=3,"Persona should have at least 3 methods").refine(e=>Object.keys(e).length<=25,"Persona should not exceed 25 methods for usability"),zMs=We.object({methods:We.array(We.string()).optional()}).strict(),UMs=We.object({name:We.string().min(1,"Name is required").regex(/^[A-Z]+$/,"Name should be all uppercase letters (e.g., JAMES, FRIDAY)"),description:We.string().min(5,"Description should be at least 100 characters for proper context").max(100,"Description should not exceed 2000 characters for readability").regex(/^[A-Z]/,"Description should start with capital letter"),agent:$Ms,persona:FMs,methods:LMs,dependencies:zMs}).catchall(We.unknown()).refine(e=>{let t=["name","description","agent","persona","methods","dependencies"],n=Object.keys(e).filter(i=>!t.includes(i)).filter(i=>!i.endsWith("-protocol"));return n.length&&console.dir(n,{deep:!0}),n.length===0},{message:"Additional root properties found."});function Puo(e){let t=UMs.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,errors:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`)}}import{readFileSync as ZMs}from"fs";import{basename as WMs}from"path";async function VMs(e){let t=await e0(["persona"],e);jMs("General Persona Validation",()=>{BMs("All persona files should pass validation",async()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping persona validation - no persona files found");return}let r=[];for(let n of t){let i=ZMs(n.filePath,"utf8"),o=WMs(n.filePath);if(!i.match(/```yaml\s*\n([\s\S]*?)\n\s*```/)){r.push(`\u{1F4C4} ${o}: No YAML block found`);continue}let s=await eC(t,n.callSign);delete s.promptData.callSign;let u=Puo(s.promptData);if(!u.success){let c=u.errors?.map(l=>`
|
|
650
650
|
\u2192 ${l}`).join("")||"Unknown error";r.push(`\u{1F4C4} ${o}:${c}`)}}if(r.length>0)throw console.error(`
|
|
651
651
|
\u274C FAILURES (${r.length}/${t.length}):
|
|
652
652
|
${r.join(`
|
|
@@ -10,7 +10,7 @@ export declare const partyModeSchema: z.ZodObject<{
|
|
|
10
10
|
export type PartyMode = z.infer<typeof partyModeSchema>;
|
|
11
11
|
export declare const heroMethodSchema: z.ZodObject<{
|
|
12
12
|
method: z.ZodString;
|
|
13
|
-
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny
|
|
13
|
+
params: z.ZodOptional<z.ZodPipe<z.ZodTransform<any, unknown>, z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
14
14
|
}, z.core.$strip>;
|
|
15
15
|
export type HeroMethodType = z.infer<typeof heroMethodSchema>;
|
|
16
16
|
export declare const heroDeploySchema: z.ZodObject<{
|
|
@@ -18,9 +18,6 @@ declare const AgentSectionSchema: z.ZodObject<{
|
|
|
18
18
|
whenToUse: z.ZodArray<z.ZodString>;
|
|
19
19
|
}, z.core.$strict>;
|
|
20
20
|
declare const PersonaSectionSchema: z.ZodObject<{
|
|
21
|
-
style: z.ZodString;
|
|
22
|
-
identity: z.ZodString;
|
|
23
|
-
focus: z.ZodString;
|
|
24
21
|
core_principles: z.ZodOptional<z.ZodArray<z.ZodType<string | any[] | {
|
|
25
22
|
[key: string]: any[];
|
|
26
23
|
}, unknown, z.core.$ZodTypeInternals<string | any[] | {
|
|
@@ -38,9 +35,6 @@ export declare const PersonaFileSchema: z.ZodObject<{
|
|
|
38
35
|
whenToUse: z.ZodArray<z.ZodString>;
|
|
39
36
|
}, z.core.$strict>;
|
|
40
37
|
persona: z.ZodObject<{
|
|
41
|
-
style: z.ZodString;
|
|
42
|
-
identity: z.ZodString;
|
|
43
|
-
focus: z.ZodString;
|
|
44
38
|
core_principles: z.ZodOptional<z.ZodArray<z.ZodType<string | any[] | {
|
|
45
39
|
[key: string]: any[];
|
|
46
40
|
}, unknown, z.core.$ZodTypeInternals<string | any[] | {
|
package/package.json
CHANGED