@modality-counter/core 1.4.2 → 1.4.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 +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -894,15 +894,15 @@ ${Vqs(c,{depth:null,colors:!0})}
|
|
|
894
894
|
`)}async function tBs(e,t,r="skill"){let i=(await ym(["method"],t)).sort((s,c)=>s.id.localeCompare(c.id)),n=i[0]?.id,o=i[1]?.id,a=[`${e} ${r}`];return n&&(a.push(`${e} ${r} ${n}`),a.push(`${e} ${r} ${n} --help`)),o&&a.push(`${e} ${r} ${o}`),{usage:[`${e} ${r} <method-name>`,`${e} ${r} <method-name> --help`,`${e} ${r} <method-name> --refs`,`${e} ${r}${" ".repeat(20)}(list available methods)`],examples:a}}function rBs(e,t,r=Qqs,i="skill"){return async n=>{let o=n[0],a=n.includes("--help")||n.includes("-h");if(!o||o.startsWith("-")||!a)return!1;let s=await ym(["method"],t),c=s.find(u=>u.id===o);return c||(console.error(`Method '${o}' not found.`),s.length>0&&console.error(`Available: ${s.map(u=>u.id).join(", ")}`),process.exit(1)),console.log(await eBs(e,i,c,r)),!0}}var bm={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 iCe={MIN_LENGTH:20,MAX_LENGTH:500};var zct=Re.lazy(()=>Re.union([Re.string().min(1,"Execution flow step cannot be empty"),Re.array(Re.lazy(()=>zct)).min(1,"Nested array must contain at least one step").max(10,"Nested array should not exceed 10 steps for clarity")])),OD=Re.array(zct).min(1,"Execution flow must contain at least one step").max(15,"Execution flow should not exceed 15 steps for clarity").optional();var Ayo=Re.string().min(bm.ITEM_MIN_LENGTH,`Output item should be at least ${bm.ITEM_MIN_LENGTH} characters`).max(bm.ITEM_MAX_LENGTH,`Output item should not exceed ${bm.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"),nBs=Re.array(Ayo).min(bm.ARRAY_MIN_ITEMS,`Expected output should contain at least ${bm.ARRAY_MIN_ITEMS} items`).max(bm.ARRAY_MAX_ITEMS,`Expected output should not exceed ${bm.ARRAY_MAX_ITEMS} items for readability`),iBs=Re.record(Re.string().regex(bm.GROUP_NAME_PATTERN,"Group name should be lowercase with dashes and numbers only"),Re.array(Ayo).min(bm.GROUP_ITEM_MIN,`Group should contain at least ${bm.GROUP_ITEM_MIN} item`).max(bm.GROUP_ITEM_MAX,`Group should not exceed ${bm.GROUP_ITEM_MAX} items for optimal cognitive load`)).refine(e=>Object.keys(e).length>=bm.GROUP_MIN_COUNT,`Nested expected_output should contain at least ${bm.GROUP_MIN_COUNT} groups`).refine(e=>Object.keys(e).length<=bm.GROUP_MAX_COUNT,`Nested expected_output should not exceed ${bm.GROUP_MAX_COUNT} groups for readability`).refine(e=>Object.values(e).reduce((r,i)=>r+i.length,0)>=bm.TOTAL_ITEMS_MIN,`Total items across all groups should be at least ${bm.TOTAL_ITEMS_MIN}`).refine(e=>Object.values(e).reduce((r,i)=>r+i.length,0)<=bm.TOTAL_ITEMS_MAX,`Total items across all groups should not exceed ${bm.TOTAL_ITEMS_MAX} for readability`),oBs=Re.union([nBs,iBs]),aBs=Re.string().min(iCe.MIN_LENGTH,`Purpose field should be at least ${iCe.MIN_LENGTH} characters`).max(iCe.MAX_LENGTH,`Purpose field should not exceed ${iCe.MAX_LENGTH} characters`).regex(/^[A-Z]/,"Purpose should start with capital letter").regex(/[.!]$/,"Purpose should end with punctuation"),sBs=Re.object({description:Re.string().min(1,"Parameter description is required"),type:Re.enum(["string","number","integer","boolean","array","object"]).optional(),required:Re.boolean().default(!1),options:Re.array(Re.string()).optional(),default:Re.union([Re.string(),Re.number(),Re.boolean()]).optional()}).catchall(Re.unknown()),cBs=Re.object({method:Re.string().min(1,"Usage method is required"),parameters:Re.record(Re.string(),sBs).optional(),examples:Re.array(Re.string()).optional(),elicit:Re.boolean().optional()}).strict(),uBs=Re.object({name:Re.string().regex(/^\*[a-z0-9-]+$/,"Method name should start with * and use lowercase with hyphens and numbers"),icon:Re.string().min(1,"Method icon is required"),category:Re.string().min(1,"Method category is required"),introduce:Re.string().min(1,"Method introduce is required"),usage:cBs,agent_compatibility:Re.array(Re.string()).min(1,"Agent compatibility is required and must contain at least one agent"),references:Re.record(Re.string(),Re.object({description:Re.string().min(1,"Reference description is required"),content:Re.string().optional()})).optional()}).strict(),lBs=Re.object({template_ref:Re.string().min(1,"Template reference filename is required"),description:Re.string().min(1,"Template description is required"),when_to_trigger:Re.array(Re.string()).optional()}).strict(),dBs=Re.array(lBs).min(1,"Template integration must be an array containing at least one template"),fBs=Re.object({method:Re.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:Re.string().min(1,"Purpose is required for composition item").max(200,"Purpose should not exceed 200 characters for clarity"),execution_flow:OD,when_to_trigger:OD}).strict(),pBs=Re.record(Re.string().regex(/^[a-z0-9-]+$/,"Composition key should be lowercase with hyphens and numbers only"),fBs).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(),mBs=Re.record(Re.string(),Re.array(Re.union([Re.string().min(1,"Action checklist item cannot be empty"),Re.record(Re.string(),Re.string().min(1,"Protocol reference cannot be empty"))]))).optional(),hBs=Re.object({purpose:Re.string().min(1,"Usage mode purpose is required"),execution_flow:OD,fallback:Re.array(Re.string().min(1,"Fallback step cannot be empty")).optional(),when_to_trigger:OD,usage_example:Re.array(Re.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(),gBs=Re.record(Re.string().regex(/^[a-z0-9-]+$/,"Usage mode key should be lowercase with hyphens and numbers only"),hBs).optional(),yBs=Re.object({validation_protocols:Re.record(Re.string(),Re.any()).optional(),action_checklists:Re.union([mBs,Re.array(Re.string())]),mission_critical:OD}).strict(),bBs=Re.any().superRefine((e,t)=>{if(e&&typeof e=="object"){let i=Object.keys(e);if(i[i.length-1]!=="mission_critical")return t.addIssue({code:"custom",message:`mission_critical must be the last property in tactical_notes (current order: ${i.join(", ")})`,path:[]}),Re.NEVER}let r=yBs.safeParse(e);r.success||r.error.issues.forEach(i=>{t.addIssue({code:"custom",message:`${i.code}: ${i.message}`,path:i.path})})}),vBs=Re.object({purpose:aBs,expected_output:oBs,composition:pBs}).strict(),Pyo=Re.object({method:uBs,methodology:vBs,template_integration:dBs.optional(),integration_protocols:Re.record(Re.string(),Re.any()).optional(),usage_modes:gBs,tactical_notes:bBs}).catchall(Re.unknown()).refine(e=>{let t=["method","methodology","template_integration","tactical_notes","integration_protocols","usage_modes","multi_market_integration","data_sources"],i=Object.keys(e).filter(n=>!t.includes(n)).filter(n=>!n.endsWith("-tmpl")&&!n.endsWith("-protocol"));return i.length&&console.dir(i,{deep:!0}),i.length===0},{message:"Additional root properties found."});function DSr(e,t){let r=Pyo.safeParse(e);if(r.success)return{success:!0,data:r.data};{let i=t?`${t}: `:"";return{success:!1,errors:r.error.issues.map(n=>`${i}${n.path.join(".")}: ${n.message}`)}}}var xBs=Re.object({header_sections:Re.array(Re.string()).optional().describe("Header content sections"),separators:Re.record(Re.string(),Re.string()).optional().describe("Visual separator content as Record<string, string>"),body_sections:Re.array(Re.string()).optional().describe("Main content sections"),footer_sections:Re.array(Re.string()).optional().describe("Footer content sections")}).strict().describe("Output structure organization - strict validation enforces consistent *_sections naming pattern"),_Bs=Re.record(Re.string(),Re.any()).describe("Display format and presentation specifications - accepts any key-value pairs for flexible formatting options"),SBs=Re.object({format:Re.string().optional().describe("Output format type (e.g., 'structured_markdown_report')"),filename:Re.string().optional().describe("Filename pattern for template output (supports {{variables}})"),structure:xBs.optional().describe("Output structure organization into header/body/footer sections")}).describe("Template output configuration - specifies how template results are generated and structured"),wBs=Re.object({title:Re.string().optional().describe("Section display title"),description:Re.string().optional().describe("Section description and purpose"),sub_sections:Re.array(Re.string()).optional().describe("List of sub-section names or descriptions"),content:Re.string().optional().describe("Plaintext content, examples, or instructions for this section"),type:Re.string().optional().describe("Section type classification for categorization"),focus:Re.string().optional().describe("Specific focus area for this section")}).catchall(Re.unknown()).describe("Individual template section - supports custom fields via passthrough"),kBs=Re.record(Re.string(),wBs).describe("Map of section names to section configurations"),EBs=Re.object({output:SBs.optional().describe("File output configuration (filename, format, structure)"),display_format:_Bs.optional().describe("Display and presentation specifications")}).strict().describe("Core template configuration - groups output & display specifications under 'template:' key"),IBs=Re.object({template:EBs.describe("REQUIRED: Configuration section - groups output and display specifications"),execution_flow:OD.optional().describe("OPTIONAL: Root-level execution workflow steps"),sections:kBs.describe("REQUIRED: Root-level section definitions for template content")}).strict().describe("TEMPLATE FILE ROOT STRUCTURE - contains template config, execution workflow, and content sections"),Dyo=Re.object({name:Re.string().min(1,"Template name is required and must not be empty").describe("Template name from YAML frontmatter"),description:Re.string().min(1,"Template description is required and must not be empty").describe("Template description from YAML frontmatter")}).catchall(Re.union([IBs,Re.string(),Re.number(),Re.boolean(),Re.null(),Re.array(Re.unknown())])).describe("Complete template file: YAML frontmatter metadata + one template definition following TemplateContentSchema");function _6(e){let t=Dyo.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,errors:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`)}}var Ryo=Re.union([Re.string().min(10,"Protocol content should be at least 10 characters"),Re.array(Re.union([Re.string().min(3,"Array item should be at least 3 characters"),Re.record(Re.string(),Re.any())])).min(1,"Array should not be empty"),Re.record(Re.string(),Re.union([Re.string().min(3,"Object value should be at least 3 characters"),Re.array(zct),Re.record(Re.string(),Re.any())])).refine(e=>Object.keys(e).length>0,"Object should not be empty"),Re.lazy(()=>Re.record(Re.string(),Ryo))]),Nyo=Re.record(Re.string(),Ryo).refine(e=>{let t=Object.keys(e);return t.some(i=>{let n=e[i];return typeof n=="string"?n.trim().length>=10:Array.isArray(n)?n.length>0:typeof n=="object"&&n!==null?Object.keys(n).length>0:!1})&&t.length>0},"Protocol should contain at least one meaningful section with content"),TBs=Re.object({name:Re.string().min(1,"Protocol name is required"),description:Re.string().min(10,"Protocol description should be at least 10 characters")}).catchall(Nyo).refine(e=>{let t=["name","description"],r=Object.keys(e).filter(n=>!t.includes(n));if(r.length!==1)return!1;let i=e[r[0]];return Nyo.safeParse(i).success},"Protocol should have exactly one root key containing the protocol structure (in addition to name and description)");function OBs(e){let t=TBs.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,errors:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`)}}function CBs(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 $Bs(e){let r={filename:"unknown",type:"protocol",status:"excellent",errors:[],warnings:[],advisories:[],score:0},i=OBs(e);return!i.success&&i.errors&&i.errors.forEach(n=>{n.includes("should be at least")||n.includes("should not exceed")||n.includes("should start with")||n.includes("should use")?r.advisories.push(`ADVISORY: ${n}`):n.includes("required")||n.includes("should contain")||n.includes("should have at least")?r.errors.push(`CRITICAL: ${n}`):r.warnings.push(`WARNING: ${n}`)}),r.score=CBs(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 ABs,test as Myo,expect as zyo}from"bun:test";import{lstatSync as PBs,existsSync as DBs}from"fs";import{join as Fyo,basename as NBs,dirname as Fct}from"path";async function RBs(e){let t=await ym(["method"],e);ABs("Category Link Validation",()=>{Myo("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 i of t){let n=i.filePath,o=i.category;if(!o)continue;let a=NBs(Fct(n)),s=Fct(Fct(n)),c=Fct(s),u=Fyo(c,"categories"),l=Fyo(u,o,a);if(!DBs(l)){r.push(`${l} not exists`);continue}try{PBs(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:
|
|
895
895
|
${r.join(`
|
|
896
896
|
`)}`),zyo(r.length).toBe(0)}),Myo("should discover all method items",()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping method discovery check - no method items found");return}zyo(t.length).toBeGreaterThan(0),console.log(`\u2705 Validated ${t.length} method category links`)})})}import{describe as MBs,test as jyo,expect as Lyo}from"bun:test";import{existsSync as zBs}from"fs";import{join as FBs}from"path";async function jBs(e){let t=await ym(["method"],e);MBs("General Method Validation",()=>{jyo("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 i of t){let{promptData:n}=await sT(t,i.callSign)||{};n&&(delete n.callSign,delete n.name,delete n.description,delete n.method.references);let o=DSr(n,i.filePath);if(!o.success){let a=o.errors?.map(s=>`
|
|
897
|
-
\u2192 ${s}`).join("")||"Unknown error";r.push(`\u{1F4C4} ${i.id}:${a}`)}}
|
|
897
|
+
\u2192 ${s}`).join("")||"Unknown error";r.push(`\u{1F4C4} ${i.id}:${a}`)}}r.length>0&&console.error(`
|
|
898
898
|
\u274C FAILURES (${r.length}/${t.length}):
|
|
899
899
|
${r.join(`
|
|
900
900
|
`)}
|
|
901
|
-
`),
|
|
901
|
+
`),console.log(`\u2705 Validated ${t.length} methods`),Lyo(r).toEqual([])}),jyo("All reference files should have parseable frontmatter with a description",async()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping reference validation - no method items found");return}let r=[],i=0;for(let n of t){if(!n.folderPath)continue;let o=FBs(n.folderPath,"references");if(!zBs(o))continue;let a=await IOe(o);for(let[s,c]of Object.entries(a))i++,c.description||r.push(`\u{1F4C4} ${n.id}/references/${s}: frontmatter has no usable 'description' \u2014 the field is missing, the frontmatter block is absent, or the YAML failed to parse (a common culprit is an unquoted ": " colon-space in a value; wrap such values in double quotes).`)}r.length>0&&console.error(`
|
|
902
902
|
\u274C REFERENCE FAILURES (${r.length}/${i}):
|
|
903
903
|
${r.join(`
|
|
904
904
|
`)}
|
|
905
|
-
`),
|
|
905
|
+
`),console.log(`\u2705 Validated ${i} reference files`),Lyo(r).toEqual([])})})}import{describe as VBs,test as WBs,expect as HBs}from"bun:test";var LBs=Re.object({id:Re.string().min(1,"Agent ID is required").regex(/^[a-z-]+$/,"Agent ID should follow format: {role} (e.g., developer, analyst)"),icon:Re.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:Re.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:Re.string().min(5,"Agent acronym should be at least 10 characters").max(200,"Agent acronym should not exceed 200 characters"),whenToUse:Re.array(Re.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(),UBs=Re.object({core_principles:OD}).strict(),qBs=Re.record(Re.string().min(1,"Method key is required").regex(/^[a-z0-9-]+$/,"Method key should be lowercase with hyphens and numbers only"),Re.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"),BBs=Re.object({methods:Re.array(Re.string()).optional()}).strict(),ZBs=Re.object({name:Re.string().min(1,"Name is required").regex(/^[A-Z]+$/,"Name should be all uppercase letters (e.g., JAMES, FRIDAY)"),description:Re.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:LBs,persona:UBs,methods:qBs,dependencies:BBs}).catchall(Re.unknown()).refine(e=>{let t=["name","description","agent","persona","methods","dependencies"],i=Object.keys(e).filter(n=>!t.includes(n)).filter(n=>!n.endsWith("-protocol"));return i.length&&console.dir(i,{deep:!0}),i.length===0},{message:"Additional root properties found."});function Uyo(e){let t=ZBs.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 JBs}from"fs";import{basename as GBs}from"path";async function KBs(e){let t=await ym(["persona"],e);VBs("General Persona Validation",()=>{WBs("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 i of t){let n=JBs(i.filePath,"utf8"),o=GBs(i.filePath);if(!n.match(/```yaml\s*\n([\s\S]*?)\n\s*```/)){r.push(`\u{1F4C4} ${o}: No YAML block found`);continue}let s=await sT(t,i.callSign);delete s.promptData.callSign;let c=Uyo(s.promptData);if(!c.success){let u=c.errors?.map(l=>`
|
|
906
906
|
\u2192 ${l}`).join("")||"Unknown error";r.push(`\u{1F4C4} ${o}:${u}`)}}if(r.length>0)throw console.error(`
|
|
907
907
|
\u274C FAILURES (${r.length}/${t.length}):
|
|
908
908
|
${r.join(`
|
package/package.json
CHANGED