@modality-counter/core 0.2.2 → 0.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 +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -629,7 +629,7 @@ ${l.map((x,T)=>`STEP ${T+1}. <STEP>${Array.isArray(x)?x.join(`
|
|
|
629
629
|
|
|
630
630
|
`)}
|
|
631
631
|
</ACTIVATION_SEQUENCE>
|
|
632
|
-
`;return HV({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:`,...p}]},[d,g])}catch(o){return kse(o,"counter_deploy")}}},[B5]:{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.**",inputSchema:sgi,execute:async i=>{let{method:o,params:a={}}=i,{resolveName:s,resolveParams:u}=elo(o),c={...u,...a||{}};try{let l=c.reference,f=await(l?V2(r,s,c):V2(r,s,c,!0));if(!f)throw new Error(`METHOD '${o}' not found. Available methods: ${r.map(p=>p.name).join(", ")}`);let d=f.promptData;if(l!=null){let p=a6(d,["method","references","referenceList",l,"content"]);if(!p)throw new Error(`Failed to load method reference content. ${o} - ${l}`);return HV(p)}else{let{method:p,tactical_notes:g,...x}=d,T=a6(f.scriptResult,["content"],f.scriptResult);return HV({success:f.scriptSuccess!=null?f.scriptSuccess:!0,instructions:[{message:`${o} EXECUTED!`,currentTimeAtUTC:new Date().toISOString()},x]},[{methodParams:Object.keys(c||{}).length?c:void 0,methodContent:p},{tactical_notes:g},...pmr(T)])}}catch(l){return kse(l,B5)}}},_Counter__DeployWorkflow:{description:"Deploy workflow",inputSchema:cgi,execute:async({callSign:i})=>{let o=await c0(["workflow"],e),{resolveName:a}=elo(i,"workflow"),{promptData:s}=await V2(o,a)||{};try{if(!s)throw new Error(`WORKFLOW '${i}' not found. Available methods: ${o.map(u=>u.id).join(", ")}`);return HV(s)}catch(u){return kse(u,"_Counter__DeployWorkflow")}}},_Counter__PartyMode:{description:await aRs(),inputSchema:agi,execute:async({topic:i,context:o="General discussion",recommendedHeroes:a,deployedHeroes:s})=>{try{let{availableHeroes:u,selectedHeroes:c}=await sRs(e,a,s),l=await c0(["persona"],e),d=(await Promise.all(c.map(async T=>({...T,deployedContent:(await V2(l,T.callSign,{partyMode:!0,activeHeroes:c})||{})?.promptData,deploymentStatus:"AUTO_DEPLOYED"})))).map(T=>({callSign:T.callSign,name:T.name,description:T.description,icon:T.deployedContent?.agent?.icon,methods:T.deployedContent?.methods,partyMode:!0})),p=d.map(T=>`${T.icon} ${T.name} (${T.callSign})`).join(", "),g=u.filter(T=>!c.some(O=>O.id===T.id)).map(T=>`${T.name} (${T.callSign})`).join(", "),x=(await GR(fyr,{activeHeroes:p,topic:i,context:o}))?.PartyMode;return HV({message:"READY_FOR_AUTO_FACILITATION",instructions:[{availableHeroesDisplay:g}]},[{partyModeProtocol:x},{activeHeroes:d}])}catch(u){return kse(u,"PartyMode")}}}};if(t!=null){let i=t;for(let o of r)i.addPrompt({name:o.id,load:async()=>`*${o.id}`})}return Vhr(n,t)};var gh={ARRAY_MIN_ITEMS:1,ARRAY_MAX_ITEMS:20,GROUP_MIN_COUNT:2,GROUP_MAX_COUNT:5,ITEM_MIN_LENGTH:30,ITEM_MAX_LENGTH:200,GROUP_ITEM_MAX:6,GROUP_ITEM_MIN:1,TOTAL_ITEMS_MIN:3,TOTAL_ITEMS_MAX:20,GROUP_NAME_PATTERN:/^[a-z0-9-]+$/};var PTe={MIN_LENGTH:20,MAX_LENGTH:500};var lut=We.lazy(()=>We.union([We.string().min(1,"Execution flow step cannot be empty"),We.array(We.lazy(()=>lut)).min(1,"Nested array must contain at least one step").max(10,"Nested array should not exceed 10 steps for clarity")])),sM=We.array(lut).min(1,"Execution flow must contain at least one step").max(15,"Execution flow should not exceed 15 steps for clarity").optional();var tlo=We.string().min(gh.ITEM_MIN_LENGTH,`Output item should be at least ${gh.ITEM_MIN_LENGTH} characters`).max(gh.ITEM_MAX_LENGTH,`Output item should not exceed ${gh.ITEM_MAX_LENGTH} characters`).regex(/^[A-Z]/,"Output item should start with capital letter").refine(e=>![/comprehensive analysis/i,/detailed report/i,/complete overview/i,/thorough assessment/i].some(r=>r.test(e)),"Output item contains generic phrase - be more specific"),cRs=We.array(tlo).min(gh.ARRAY_MIN_ITEMS,`Expected output should contain at least ${gh.ARRAY_MIN_ITEMS} items`).max(gh.ARRAY_MAX_ITEMS,`Expected output should not exceed ${gh.ARRAY_MAX_ITEMS} items for readability`),lRs=We.record(We.string().regex(gh.GROUP_NAME_PATTERN,"Group name should be lowercase with dashes and numbers only"),We.array(tlo).min(gh.GROUP_ITEM_MIN,`Group should contain at least ${gh.GROUP_ITEM_MIN} item`).max(gh.GROUP_ITEM_MAX,`Group should not exceed ${gh.GROUP_ITEM_MAX} items for optimal cognitive load`)).refine(e=>Object.keys(e).length>=gh.GROUP_MIN_COUNT,`Nested expected_output should contain at least ${gh.GROUP_MIN_COUNT} groups`).refine(e=>Object.keys(e).length<=gh.GROUP_MAX_COUNT,`Nested expected_output should not exceed ${gh.GROUP_MAX_COUNT} groups for readability`).refine(e=>Object.values(e).reduce((r,n)=>r+n.length,0)>=gh.TOTAL_ITEMS_MIN,`Total items across all groups should be at least ${gh.TOTAL_ITEMS_MIN}`).refine(e=>Object.values(e).reduce((r,n)=>r+n.length,0)<=gh.TOTAL_ITEMS_MAX,`Total items across all groups should not exceed ${gh.TOTAL_ITEMS_MAX} for readability`),fRs=We.union([cRs,lRs]),dRs=We.string().min(PTe.MIN_LENGTH,`Purpose field should be at least ${PTe.MIN_LENGTH} characters`).max(PTe.MAX_LENGTH,`Purpose field should not exceed ${PTe.MAX_LENGTH} characters`).regex(/^[A-Z]/,"Purpose should start with capital letter").regex(/[.!]$/,"Purpose should end with punctuation"),pRs=We.object({description:We.string().min(1,"Parameter description is required"),type:We.enum(["string","number","integer","boolean","array","object"]),required:We.boolean().default(!1),options:We.array(We.string()).optional(),default:We.union([We.string(),We.number(),We.boolean()]).optional()}).catchall(We.unknown()),hRs=We.object({method:We.string().min(1,"Usage method is required"),parameters:We.record(We.string(),pRs).optional(),examples:We.array(We.string()).optional(),elicit:We.boolean().optional()}).strict(),mRs=We.object({name:We.string().regex(/^\*[a-z0-9-]+$/,"Method name should start with * and use lowercase with hyphens and numbers"),icon:We.string().min(1,"Method icon is required"),category:We.string().min(1,"Method category is required"),introduce:We.string().min(1,"Method introduce is required"),usage:hRs,agent_compatibility:We.array(We.string()).min(1,"Agent compatibility is required and must contain at least one agent"),references:We.record(We.string(),We.object({description:We.string().min(1,"Reference description is required"),content:We.string().optional()})).optional()}).strict(),gRs=We.object({template_ref:We.string().min(1,"Template reference filename is required"),description:We.string().min(1,"Template description is required"),when_to_trigger:We.array(We.string()).optional()}).strict(),yRs=We.array(gRs).min(1,"Template integration must be an array containing at least one template"),bRs=We.object({method:We.string().min(1,"Method is required for composition").regex(/^\*[a-z0-9-]+(\s+[^\s]+)*$/,"Method must start with * and follow method syntax with optional parameters like [target], [target]-suffix, keywords, or --flags"),purpose:We.string().min(1,"Purpose is required for composition item").max(200,"Purpose should not exceed 200 characters for clarity"),execution_flow:sM,when_to_trigger:sM}).strict(),xRs=We.record(We.string().regex(/^[a-z0-9-]+$/,"Composition key should be lowercase with hyphens and numbers only"),bRs).refine(e=>Object.keys(e).length>=1,"Composition must contain at least one method").refine(e=>Object.keys(e).length<=10,"Composition should not exceed 10 methods for clarity").optional(),vRs=We.record(We.string(),We.array(We.union([We.string().min(1,"Action checklist item cannot be empty"),We.record(We.string(),We.string().min(1,"Protocol reference cannot be empty"))]))).optional(),_Rs=We.object({purpose:We.string().min(1,"Usage mode purpose is required"),execution_flow:sM,fallback:We.array(We.string().min(1,"Fallback step cannot be empty")).optional(),when_to_trigger:sM,usage_example:We.array(We.string().min(1,"Usage example cannot be empty")).min(1,"At least one usage example is required when usage_example is specified").max(3,"Usage examples should not exceed 5 for clarity").optional()}).strict(),SRs=We.record(We.string().regex(/^[a-z0-9-]+$/,"Usage mode key should be lowercase with hyphens and numbers only"),_Rs).optional(),wRs=We.object({validation_protocols:We.record(We.string(),We.any()).optional(),action_checklists:We.union([vRs,We.array(We.string())]),mission_critical:sM}).strict(),kRs=We.any().superRefine((e,t)=>{if(e&&typeof e=="object"){let n=Object.keys(e);if(n[n.length-1]!=="mission_critical")return t.addIssue({code:"custom",message:`mission_critical must be the last property in tactical_notes (current order: ${n.join(", ")})`,path:[]}),We.NEVER}let r=wRs.safeParse(e);r.success||r.error.issues.forEach(n=>{t.addIssue({code:"custom",message:`${n.code}: ${n.message}`,path:n.path})})}),ERs=We.object({purpose:dRs,expected_output:fRs,composition:xRs}).strict(),IRs=We.object({method:mRs,methodology:ERs,template_integration:yRs.optional(),integration_protocols:We.record(We.string(),We.any()).optional(),usage_modes:SRs,multi_market_integration:We.record(We.string(),We.any()).optional(),data_sources:We.record(We.string(),We.any()).optional(),tactical_notes:kRs}).catchall(We.unknown()).refine(e=>{let t=["method","methodology","template_integration","tactical_notes","integration_protocols","usage_modes","multi_market_integration","data_sources"],n=Object.keys(e).filter(i=>!t.includes(i)).filter(i=>!i.endsWith("-tmpl")&&!i.endsWith("-protocol"));return n.length&&console.dir(n,{deep:!0}),n.length===0},{message:"Additional root properties found."});function dyr(e,t){let r=IRs.safeParse(e);if(r.success)return{success:!0,data:r.data};{let n=t?`${t}: `:"";return{success:!1,errors:r.error.issues.map(i=>`${n}${i.path.join(".")}: ${i.message}`)}}}var TRs=We.object({header_sections:We.array(We.string()).optional().describe("Header content sections"),separators:We.record(We.string(),We.string()).optional().describe("Visual separator content as Record<string, string>"),body_sections:We.array(We.string()).optional().describe("Main content sections"),footer_sections:We.array(We.string()).optional().describe("Footer content sections")}).strict().describe("Template output structure configuration - strict validation enforces consistent *_sections naming pattern"),ARs=We.record(We.string(),We.any()).describe("Display format and presentation specifications - accepts any key-value pairs"),CRs=We.object({format:We.string().optional().describe("Output format specification"),filename:We.string().optional().describe("Filename pattern for template output"),structure:TRs.optional().describe("Output structure configuration")}).describe("Template output configuration"),ORs=We.object({title:We.string().optional().describe("Section title"),description:We.string().optional().describe("Section description"),sub_sections:We.array(We.string()).optional().describe("List of sub-section descriptions"),content:We.string().optional().describe("Plaintext content for examples and long text"),type:We.string().optional().describe("Section type classification"),focus:We.string().optional().describe("Section focus area")}).catchall(We.unknown()).describe("Individual template section configuration"),MRs=We.record(We.string(),ORs).describe("Template sections and content structure"),RRs=We.object({output:CRs.optional(),display_format:ARs.optional().describe("Display format specifications")}).strict().describe("Core template configuration"),PRs=We.object({template:RRs.describe("Required template configuration section"),execution_flow:sM.optional().describe("Root-level execution flow specification"),sections:MRs.describe("REQUIRED: Root-level sections specification")}).strict().describe("Template content structure"),DRs=We.object({name:We.string().min(1,"Template name is required and must not be empty").describe("Template name from YAML frontmatter"),description:We.string().min(1,"Template description is required and must not be empty").describe("Template description from YAML frontmatter")}).catchall(PRs).describe("Complete template file with metadata (name, description) and exactly one template-name key containing template content");function hz(e){let t=DRs.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,errors:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`)}}var nlo=We.union([We.string().min(10,"Protocol content should be at least 10 characters"),We.array(We.union([We.string().min(3,"Array item should be at least 3 characters"),We.record(We.string(),We.any())])).min(1,"Array should not be empty"),We.record(We.string(),We.union([We.string().min(3,"Object value should be at least 3 characters"),We.array(lut),We.record(We.string(),We.any())])).refine(e=>Object.keys(e).length>0,"Object should not be empty"),We.lazy(()=>We.record(We.string(),nlo))]),rlo=We.record(We.string(),nlo).refine(e=>{let t=Object.keys(e);return t.some(n=>{let i=e[n];return typeof i=="string"?i.trim().length>=10:Array.isArray(i)?i.length>0:typeof i=="object"&&i!==null?Object.keys(i).length>0:!1})&&t.length>0},"Protocol should contain at least one meaningful section with content"),NRs=We.object({name:We.string().min(1,"Protocol name is required"),description:We.string().min(10,"Protocol description should be at least 10 characters")}).catchall(rlo).refine(e=>{let t=["name","description"],r=Object.keys(e).filter(i=>!t.includes(i));if(r.length!==1)return!1;let n=e[r[0]];return rlo.safeParse(n).success},"Protocol should have exactly one root key containing the protocol structure (in addition to name and description)");function $Rs(e){let t=NRs.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,errors:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`)}}function FRs(e){let t=100;return t-=e.errors.length*25,t-=e.warnings.length*5,t-=e.advisories.length*1,Math.max(0,t)}function LRs(e){let r={filename:"unknown",type:"protocol",status:"excellent",errors:[],warnings:[],advisories:[],score:0},n=$Rs(e);return!n.success&&n.errors&&n.errors.forEach(i=>{i.includes("should be at least")||i.includes("should not exceed")||i.includes("should start with")||i.includes("should use")?r.advisories.push(`ADVISORY: ${i}`):i.includes("required")||i.includes("should contain")||i.includes("should have at least")?r.errors.push(`CRITICAL: ${i}`):r.warnings.push(`WARNING: ${i}`)}),r.score=FRs(r),r.errors.length===0&&r.warnings.length===0?r.status="excellent":r.errors.length===0?r.status="good_with_warnings":r.status="critical_error",r}import{describe as zRs,test as ilo,expect as olo}from"bun:test";import{lstatSync as URs,existsSync as jRs}from"fs";import{join as alo,basename as BRs,dirname as fut}from"path";async function qRs(e){let t=await c0(["method"],e);zRs("Category Link Validation",()=>{ilo("All method categories should have valid symbolic links",()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping category link validation - no method items found");return}let r=[];for(let n of t){let i=n.filePath,o=n.category;if(!o)continue;let a=BRs(fut(i)),s=fut(fut(i)),u=fut(s),c=alo(u,"categories"),l=alo(c,o,a);if(!jRs(l)){r.push(`${l} not exists`);continue}try{URs(l).isSymbolicLink()||r.push(`Not Link: ${l}`)}catch(f){r.push(`Error reading link ${l}: ${f}`)}}r.length>0&&console.error(`\u274C Link validation failures:
|
|
632
|
+
`;return HV({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:`,...p}]},[d,g])}catch(o){return kse(o,"counter_deploy")}}},[B5]:{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.**",inputSchema:sgi,execute:async i=>{let{method:o,params:a={}}=i,{resolveName:s,resolveParams:u}=elo(o),c={...u,...a||{}};try{let l=c.reference,f=await(l?V2(r,s,c):V2(r,s,c,!0));if(!f)throw new Error(`METHOD '${o}' not found. Available methods: ${r.map(p=>p.name).join(", ")}`);let d=f.promptData;if(l!=null){let p=a6(d,["method","references","referenceList",l,"content"]);if(!p)throw new Error(`Failed to load method reference content. ${o} - ${l}`);return HV({message:p})}else{let{method:p,tactical_notes:g,...x}=d,T=a6(f.scriptResult,["content"],f.scriptResult);return HV({success:f.scriptSuccess!=null?f.scriptSuccess:!0,instructions:[{message:`${o} EXECUTED!`,currentTimeAtUTC:new Date().toISOString()},x]},[{methodParams:Object.keys(c||{}).length?c:void 0,methodContent:p},{tactical_notes:g},...pmr(T)])}}catch(l){return kse(l,B5)}}},_Counter__DeployWorkflow:{description:"Deploy workflow",inputSchema:cgi,execute:async({callSign:i})=>{let o=await c0(["workflow"],e),{resolveName:a}=elo(i,"workflow"),{promptData:s}=await V2(o,a)||{};try{if(!s)throw new Error(`WORKFLOW '${i}' not found. Available methods: ${o.map(u=>u.id).join(", ")}`);return HV(s)}catch(u){return kse(u,"_Counter__DeployWorkflow")}}},_Counter__PartyMode:{description:await aRs(),inputSchema:agi,execute:async({topic:i,context:o="General discussion",recommendedHeroes:a,deployedHeroes:s})=>{try{let{availableHeroes:u,selectedHeroes:c}=await sRs(e,a,s),l=await c0(["persona"],e),d=(await Promise.all(c.map(async T=>({...T,deployedContent:(await V2(l,T.callSign,{partyMode:!0,activeHeroes:c})||{})?.promptData,deploymentStatus:"AUTO_DEPLOYED"})))).map(T=>({callSign:T.callSign,name:T.name,description:T.description,icon:T.deployedContent?.agent?.icon,methods:T.deployedContent?.methods,partyMode:!0})),p=d.map(T=>`${T.icon} ${T.name} (${T.callSign})`).join(", "),g=u.filter(T=>!c.some(O=>O.id===T.id)).map(T=>`${T.name} (${T.callSign})`).join(", "),x=(await GR(fyr,{activeHeroes:p,topic:i,context:o}))?.PartyMode;return HV({message:"READY_FOR_AUTO_FACILITATION",instructions:[{availableHeroesDisplay:g}]},[{partyModeProtocol:x},{activeHeroes:d}])}catch(u){return kse(u,"PartyMode")}}}};if(t!=null){let i=t;for(let o of r)i.addPrompt({name:o.id,load:async()=>`*${o.id}`})}return Vhr(n,t)};var gh={ARRAY_MIN_ITEMS:1,ARRAY_MAX_ITEMS:20,GROUP_MIN_COUNT:2,GROUP_MAX_COUNT:5,ITEM_MIN_LENGTH:30,ITEM_MAX_LENGTH:200,GROUP_ITEM_MAX:6,GROUP_ITEM_MIN:1,TOTAL_ITEMS_MIN:3,TOTAL_ITEMS_MAX:20,GROUP_NAME_PATTERN:/^[a-z0-9-]+$/};var PTe={MIN_LENGTH:20,MAX_LENGTH:500};var lut=We.lazy(()=>We.union([We.string().min(1,"Execution flow step cannot be empty"),We.array(We.lazy(()=>lut)).min(1,"Nested array must contain at least one step").max(10,"Nested array should not exceed 10 steps for clarity")])),sM=We.array(lut).min(1,"Execution flow must contain at least one step").max(15,"Execution flow should not exceed 15 steps for clarity").optional();var tlo=We.string().min(gh.ITEM_MIN_LENGTH,`Output item should be at least ${gh.ITEM_MIN_LENGTH} characters`).max(gh.ITEM_MAX_LENGTH,`Output item should not exceed ${gh.ITEM_MAX_LENGTH} characters`).regex(/^[A-Z]/,"Output item should start with capital letter").refine(e=>![/comprehensive analysis/i,/detailed report/i,/complete overview/i,/thorough assessment/i].some(r=>r.test(e)),"Output item contains generic phrase - be more specific"),cRs=We.array(tlo).min(gh.ARRAY_MIN_ITEMS,`Expected output should contain at least ${gh.ARRAY_MIN_ITEMS} items`).max(gh.ARRAY_MAX_ITEMS,`Expected output should not exceed ${gh.ARRAY_MAX_ITEMS} items for readability`),lRs=We.record(We.string().regex(gh.GROUP_NAME_PATTERN,"Group name should be lowercase with dashes and numbers only"),We.array(tlo).min(gh.GROUP_ITEM_MIN,`Group should contain at least ${gh.GROUP_ITEM_MIN} item`).max(gh.GROUP_ITEM_MAX,`Group should not exceed ${gh.GROUP_ITEM_MAX} items for optimal cognitive load`)).refine(e=>Object.keys(e).length>=gh.GROUP_MIN_COUNT,`Nested expected_output should contain at least ${gh.GROUP_MIN_COUNT} groups`).refine(e=>Object.keys(e).length<=gh.GROUP_MAX_COUNT,`Nested expected_output should not exceed ${gh.GROUP_MAX_COUNT} groups for readability`).refine(e=>Object.values(e).reduce((r,n)=>r+n.length,0)>=gh.TOTAL_ITEMS_MIN,`Total items across all groups should be at least ${gh.TOTAL_ITEMS_MIN}`).refine(e=>Object.values(e).reduce((r,n)=>r+n.length,0)<=gh.TOTAL_ITEMS_MAX,`Total items across all groups should not exceed ${gh.TOTAL_ITEMS_MAX} for readability`),fRs=We.union([cRs,lRs]),dRs=We.string().min(PTe.MIN_LENGTH,`Purpose field should be at least ${PTe.MIN_LENGTH} characters`).max(PTe.MAX_LENGTH,`Purpose field should not exceed ${PTe.MAX_LENGTH} characters`).regex(/^[A-Z]/,"Purpose should start with capital letter").regex(/[.!]$/,"Purpose should end with punctuation"),pRs=We.object({description:We.string().min(1,"Parameter description is required"),type:We.enum(["string","number","integer","boolean","array","object"]),required:We.boolean().default(!1),options:We.array(We.string()).optional(),default:We.union([We.string(),We.number(),We.boolean()]).optional()}).catchall(We.unknown()),hRs=We.object({method:We.string().min(1,"Usage method is required"),parameters:We.record(We.string(),pRs).optional(),examples:We.array(We.string()).optional(),elicit:We.boolean().optional()}).strict(),mRs=We.object({name:We.string().regex(/^\*[a-z0-9-]+$/,"Method name should start with * and use lowercase with hyphens and numbers"),icon:We.string().min(1,"Method icon is required"),category:We.string().min(1,"Method category is required"),introduce:We.string().min(1,"Method introduce is required"),usage:hRs,agent_compatibility:We.array(We.string()).min(1,"Agent compatibility is required and must contain at least one agent"),references:We.record(We.string(),We.object({description:We.string().min(1,"Reference description is required"),content:We.string().optional()})).optional()}).strict(),gRs=We.object({template_ref:We.string().min(1,"Template reference filename is required"),description:We.string().min(1,"Template description is required"),when_to_trigger:We.array(We.string()).optional()}).strict(),yRs=We.array(gRs).min(1,"Template integration must be an array containing at least one template"),bRs=We.object({method:We.string().min(1,"Method is required for composition").regex(/^\*[a-z0-9-]+(\s+[^\s]+)*$/,"Method must start with * and follow method syntax with optional parameters like [target], [target]-suffix, keywords, or --flags"),purpose:We.string().min(1,"Purpose is required for composition item").max(200,"Purpose should not exceed 200 characters for clarity"),execution_flow:sM,when_to_trigger:sM}).strict(),xRs=We.record(We.string().regex(/^[a-z0-9-]+$/,"Composition key should be lowercase with hyphens and numbers only"),bRs).refine(e=>Object.keys(e).length>=1,"Composition must contain at least one method").refine(e=>Object.keys(e).length<=10,"Composition should not exceed 10 methods for clarity").optional(),vRs=We.record(We.string(),We.array(We.union([We.string().min(1,"Action checklist item cannot be empty"),We.record(We.string(),We.string().min(1,"Protocol reference cannot be empty"))]))).optional(),_Rs=We.object({purpose:We.string().min(1,"Usage mode purpose is required"),execution_flow:sM,fallback:We.array(We.string().min(1,"Fallback step cannot be empty")).optional(),when_to_trigger:sM,usage_example:We.array(We.string().min(1,"Usage example cannot be empty")).min(1,"At least one usage example is required when usage_example is specified").max(3,"Usage examples should not exceed 5 for clarity").optional()}).strict(),SRs=We.record(We.string().regex(/^[a-z0-9-]+$/,"Usage mode key should be lowercase with hyphens and numbers only"),_Rs).optional(),wRs=We.object({validation_protocols:We.record(We.string(),We.any()).optional(),action_checklists:We.union([vRs,We.array(We.string())]),mission_critical:sM}).strict(),kRs=We.any().superRefine((e,t)=>{if(e&&typeof e=="object"){let n=Object.keys(e);if(n[n.length-1]!=="mission_critical")return t.addIssue({code:"custom",message:`mission_critical must be the last property in tactical_notes (current order: ${n.join(", ")})`,path:[]}),We.NEVER}let r=wRs.safeParse(e);r.success||r.error.issues.forEach(n=>{t.addIssue({code:"custom",message:`${n.code}: ${n.message}`,path:n.path})})}),ERs=We.object({purpose:dRs,expected_output:fRs,composition:xRs}).strict(),IRs=We.object({method:mRs,methodology:ERs,template_integration:yRs.optional(),integration_protocols:We.record(We.string(),We.any()).optional(),usage_modes:SRs,multi_market_integration:We.record(We.string(),We.any()).optional(),data_sources:We.record(We.string(),We.any()).optional(),tactical_notes:kRs}).catchall(We.unknown()).refine(e=>{let t=["method","methodology","template_integration","tactical_notes","integration_protocols","usage_modes","multi_market_integration","data_sources"],n=Object.keys(e).filter(i=>!t.includes(i)).filter(i=>!i.endsWith("-tmpl")&&!i.endsWith("-protocol"));return n.length&&console.dir(n,{deep:!0}),n.length===0},{message:"Additional root properties found."});function dyr(e,t){let r=IRs.safeParse(e);if(r.success)return{success:!0,data:r.data};{let n=t?`${t}: `:"";return{success:!1,errors:r.error.issues.map(i=>`${n}${i.path.join(".")}: ${i.message}`)}}}var TRs=We.object({header_sections:We.array(We.string()).optional().describe("Header content sections"),separators:We.record(We.string(),We.string()).optional().describe("Visual separator content as Record<string, string>"),body_sections:We.array(We.string()).optional().describe("Main content sections"),footer_sections:We.array(We.string()).optional().describe("Footer content sections")}).strict().describe("Template output structure configuration - strict validation enforces consistent *_sections naming pattern"),ARs=We.record(We.string(),We.any()).describe("Display format and presentation specifications - accepts any key-value pairs"),CRs=We.object({format:We.string().optional().describe("Output format specification"),filename:We.string().optional().describe("Filename pattern for template output"),structure:TRs.optional().describe("Output structure configuration")}).describe("Template output configuration"),ORs=We.object({title:We.string().optional().describe("Section title"),description:We.string().optional().describe("Section description"),sub_sections:We.array(We.string()).optional().describe("List of sub-section descriptions"),content:We.string().optional().describe("Plaintext content for examples and long text"),type:We.string().optional().describe("Section type classification"),focus:We.string().optional().describe("Section focus area")}).catchall(We.unknown()).describe("Individual template section configuration"),MRs=We.record(We.string(),ORs).describe("Template sections and content structure"),RRs=We.object({output:CRs.optional(),display_format:ARs.optional().describe("Display format specifications")}).strict().describe("Core template configuration"),PRs=We.object({template:RRs.describe("Required template configuration section"),execution_flow:sM.optional().describe("Root-level execution flow specification"),sections:MRs.describe("REQUIRED: Root-level sections specification")}).strict().describe("Template content structure"),DRs=We.object({name:We.string().min(1,"Template name is required and must not be empty").describe("Template name from YAML frontmatter"),description:We.string().min(1,"Template description is required and must not be empty").describe("Template description from YAML frontmatter")}).catchall(PRs).describe("Complete template file with metadata (name, description) and exactly one template-name key containing template content");function hz(e){let t=DRs.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,errors:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`)}}var nlo=We.union([We.string().min(10,"Protocol content should be at least 10 characters"),We.array(We.union([We.string().min(3,"Array item should be at least 3 characters"),We.record(We.string(),We.any())])).min(1,"Array should not be empty"),We.record(We.string(),We.union([We.string().min(3,"Object value should be at least 3 characters"),We.array(lut),We.record(We.string(),We.any())])).refine(e=>Object.keys(e).length>0,"Object should not be empty"),We.lazy(()=>We.record(We.string(),nlo))]),rlo=We.record(We.string(),nlo).refine(e=>{let t=Object.keys(e);return t.some(n=>{let i=e[n];return typeof i=="string"?i.trim().length>=10:Array.isArray(i)?i.length>0:typeof i=="object"&&i!==null?Object.keys(i).length>0:!1})&&t.length>0},"Protocol should contain at least one meaningful section with content"),NRs=We.object({name:We.string().min(1,"Protocol name is required"),description:We.string().min(10,"Protocol description should be at least 10 characters")}).catchall(rlo).refine(e=>{let t=["name","description"],r=Object.keys(e).filter(i=>!t.includes(i));if(r.length!==1)return!1;let n=e[r[0]];return rlo.safeParse(n).success},"Protocol should have exactly one root key containing the protocol structure (in addition to name and description)");function $Rs(e){let t=NRs.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,errors:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`)}}function FRs(e){let t=100;return t-=e.errors.length*25,t-=e.warnings.length*5,t-=e.advisories.length*1,Math.max(0,t)}function LRs(e){let r={filename:"unknown",type:"protocol",status:"excellent",errors:[],warnings:[],advisories:[],score:0},n=$Rs(e);return!n.success&&n.errors&&n.errors.forEach(i=>{i.includes("should be at least")||i.includes("should not exceed")||i.includes("should start with")||i.includes("should use")?r.advisories.push(`ADVISORY: ${i}`):i.includes("required")||i.includes("should contain")||i.includes("should have at least")?r.errors.push(`CRITICAL: ${i}`):r.warnings.push(`WARNING: ${i}`)}),r.score=FRs(r),r.errors.length===0&&r.warnings.length===0?r.status="excellent":r.errors.length===0?r.status="good_with_warnings":r.status="critical_error",r}import{describe as zRs,test as ilo,expect as olo}from"bun:test";import{lstatSync as URs,existsSync as jRs}from"fs";import{join as alo,basename as BRs,dirname as fut}from"path";async function qRs(e){let t=await c0(["method"],e);zRs("Category Link Validation",()=>{ilo("All method categories should have valid symbolic links",()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping category link validation - no method items found");return}let r=[];for(let n of t){let i=n.filePath,o=n.category;if(!o)continue;let a=BRs(fut(i)),s=fut(fut(i)),u=fut(s),c=alo(u,"categories"),l=alo(c,o,a);if(!jRs(l)){r.push(`${l} not exists`);continue}try{URs(l).isSymbolicLink()||r.push(`Not Link: ${l}`)}catch(f){r.push(`Error reading link ${l}: ${f}`)}}r.length>0&&console.error(`\u274C Link validation failures:
|
|
633
633
|
${r.join(`
|
|
634
634
|
`)}`),olo(r.length).toBe(0)}),ilo("should discover all method items",()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping method discovery check - no method items found");return}olo(t.length).toBeGreaterThan(0),console.log(`\u2705 Validated ${t.length} method category links`)})})}import{describe as ZRs,test as WRs,expect as VRs}from"bun:test";async function HRs(e){let t=await c0(["method"],e);ZRs("General Method Validation",()=>{WRs("All method files should pass validation",async()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping method validation - no method items found");return}let r=[];for(let n of t){let{promptData:i}=await V2(t,n.callSign)||{};i&&(delete i.callSign,delete i.name,delete i.description,delete i.method.references);let o=dyr(i,n.filePath);if(!o.success){let a=o.errors?.map(s=>`
|
|
635
635
|
\u2192 ${s}`).join("")||"Unknown error";r.push(`\u{1F4C4} ${n.id}:${a}`)}}if(r.length>0)throw console.error(`
|
package/package.json
CHANGED