@modality-counter/core 2.5.1 → 2.5.2
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
|
@@ -1002,7 +1002,7 @@ ${wpu(u,{depth:null,colors:!0})}
|
|
|
1002
1002
|
`);let c=await OAe({method:i,...Object.keys(u).length?{params:u}:{}},n,{buildInvocation:a});if(r.includes("--help")){Epu(t,i,o.description,c);return}s?console.log(JSON.stringify(c,null,2)):process.stdout.write((0,h2o.stringify)(c,{lineWidth:0}))}}import{existsSync as g2o}from"node:fs";var Apu={bold:e=>e,dim:e=>e,header:e=>e,example:e=>e};async function Dpu(e,t,r,i){let{bold:n,dim:o,header:a,example:s}=i,u=(await R_(r.filePath)).method,c=u?.introduce,l=u?.usage,d=l?.parameters,p=l?.examples,f=[];if(f.push(""),f.push(`${n(`${e} ${t} ${r.id}`)} ${o(`\u2014 ${r.category??"general"}`)}`),f.push(""),(c??r.description)&&(f.push(c??r.description),f.push("")),d&&Object.keys(d).length){f.push(`${a("Parameters:")}`),f.push("");for(let[m,y]of Object.entries(d)){let _=[];y.type&&_.push(String(y.type)),y.required&&_.push("required"),y.default!==void 0&&_.push(`default: ${y.default}`);let E=_.length?` (${_.join(", ")})`:"";f.push(` ${m}${E}`),y.description&&f.push(` ${y.description}`),Array.isArray(y.options)&&y.options.length&&f.push(` Options: ${y.options.join(", ")}`),f.push("")}}f.push(`${a("Source:")} ${o(r.filePath)}`),f.push(""),f.push(`${a("Examples:")}`);for(let m of p??[`${e} ${t} ${r.id}`])f.push(` ${s(m)}`);return f.push(""),f.push(`${a("Usage:")} ${s(`${e} ${t} ${r.id} [parameters]`)}`),f.push(""),f.join(`
|
|
1003
1003
|
`)}async function Ppu(e,t,r="skill"){if(!g2o(t))return{usage:[],examples:[]};let i=(await pm(["method"],t)).sort((s,u)=>s.id.localeCompare(u.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 Rpu(e,t,r=Apu,i="skill"){return async n=>{let o=n[0],a=n.includes("--help")||n.includes("-h");if(!o||o.startsWith("-")||!a)return!1;g2o(t)||(console.error(`Methods directory not found: ${t}`),process.exit(1));let s=await pm(["method"],t),u=s.find(c=>c.id===o);return u||(console.error(`Method '${o}' not found.`),s.length>0&&console.error(`Available: ${s.map(c=>c.id).join(", ")}`),process.exit(1)),console.log(await Dpu(e,i,u,r)),!0}}var mm={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 s2e={MIN_LENGTH:20,MAX_LENGTH:500};function a9(e,t,r=""){let i=e.safeParse(t);return i.success?{success:!0,data:i.data}:{success:!1,errors:i.error.issues.map(n=>`${r}${n.path.map(String).join(".")}: ${n.message}`)}}var Fpt=ge.lazy(()=>ge.union([ge.string().min(1,"Execution flow step cannot be empty"),ge.array(ge.lazy(()=>Fpt)).min(1,"Nested array must contain at least one step").max(10,"Nested array should not exceed 10 steps for clarity")])),BP=ge.array(Fpt).min(1,"Execution flow must contain at least one step").max(15,"Execution flow should not exceed 15 steps for clarity").optional();var y2o=ge.string().min(mm.ITEM_MIN_LENGTH,`Output item should be at least ${mm.ITEM_MIN_LENGTH} characters`).max(mm.ITEM_MAX_LENGTH,`Output item should not exceed ${mm.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"),Npu=ge.array(y2o).min(mm.ARRAY_MIN_ITEMS,`Expected output should contain at least ${mm.ARRAY_MIN_ITEMS} items`).max(mm.ARRAY_MAX_ITEMS,`Expected output should not exceed ${mm.ARRAY_MAX_ITEMS} items for readability`),Mpu=ge.record(ge.string().regex(mm.GROUP_NAME_PATTERN,"Group name should be lowercase with dashes and numbers only"),ge.array(y2o).min(mm.GROUP_ITEM_MIN,`Group should contain at least ${mm.GROUP_ITEM_MIN} item`).max(mm.GROUP_ITEM_MAX,`Group should not exceed ${mm.GROUP_ITEM_MAX} items for optimal cognitive load`)).refine(e=>Object.keys(e).length>=mm.GROUP_MIN_COUNT,`Nested expected_output should contain at least ${mm.GROUP_MIN_COUNT} groups`).refine(e=>Object.keys(e).length<=mm.GROUP_MAX_COUNT,`Nested expected_output should not exceed ${mm.GROUP_MAX_COUNT} groups for readability`).refine(e=>Object.values(e).reduce((r,i)=>r+i.length,0)>=mm.TOTAL_ITEMS_MIN,`Total items across all groups should be at least ${mm.TOTAL_ITEMS_MIN}`).refine(e=>Object.values(e).reduce((r,i)=>r+i.length,0)<=mm.TOTAL_ITEMS_MAX,`Total items across all groups should not exceed ${mm.TOTAL_ITEMS_MAX} for readability`),zpu=ge.union([Npu,Mpu]),Fpu=ge.string().min(s2e.MIN_LENGTH,`Purpose field should be at least ${s2e.MIN_LENGTH} characters`).max(s2e.MAX_LENGTH,`Purpose field should not exceed ${s2e.MAX_LENGTH} characters`).regex(/^[A-Z]/,"Purpose should start with capital letter").regex(/[.!]$/,"Purpose should end with punctuation"),Lpu=ge.object({description:ge.string().min(1,"Parameter description is required"),type:ge.enum(["string","number","integer","boolean","array","object"]).optional(),required:ge.boolean().default(!1),options:ge.array(ge.string()).optional(),default:ge.union([ge.string(),ge.number(),ge.boolean()]).optional()}).catchall(ge.unknown()),Upu=ge.object({method:ge.string().min(1,"Usage method is required"),parameters:ge.record(ge.string(),Lpu).optional(),examples:ge.array(ge.string()).optional(),elicit:ge.boolean().optional()}).strict(),jpu=ge.object({name:ge.string().regex(/^\*[a-z0-9-]+$/,"Method name should start with * and use lowercase with hyphens and numbers"),icon:ge.string().min(1,"Method icon is required"),category:ge.string().min(1,"Method category is required"),introduce:ge.string().min(1,"Method introduce is required"),usage:Upu,agent_compatibility:ge.array(ge.string()).min(1,"Agent compatibility is required and must contain at least one agent"),references:ge.record(ge.string(),ge.object({description:ge.string().min(1,"Reference description is required"),content:ge.string().optional()})).optional()}).strict(),qpu=ge.object({template_ref:ge.string().min(1,"Template reference filename is required"),description:ge.string().min(1,"Template description is required"),when_to_trigger:ge.array(ge.string()).optional()}).strict(),Bpu=ge.array(qpu).min(1,"Template integration must be an array containing at least one template"),Zpu=ge.object({method:ge.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:ge.string().min(1,"Purpose is required for composition item").max(200,"Purpose should not exceed 200 characters for clarity"),execution_flow:BP,when_to_trigger:BP}).strict(),Vpu=ge.record(ge.string().regex(/^[a-z0-9-]+$/,"Composition key should be lowercase with hyphens and numbers only"),Zpu).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(),Wpu=ge.record(ge.string(),ge.array(ge.union([ge.string().min(1,"Action checklist item cannot be empty"),ge.record(ge.string(),ge.string().min(1,"Protocol reference cannot be empty"))]))).optional(),Hpu=ge.object({purpose:ge.string().min(1,"Usage mode purpose is required"),execution_flow:BP,fallback:ge.array(ge.string().min(1,"Fallback step cannot be empty")).optional(),when_to_trigger:BP,usage_example:ge.array(ge.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(),Gpu=ge.record(ge.string().regex(/^[a-z0-9-]+$/,"Usage mode key should be lowercase with hyphens and numbers only"),Hpu).optional(),Jpu=ge.object({validation_protocols:ge.record(ge.string(),ge.any()).optional(),action_checklists:ge.union([Wpu,ge.array(ge.string())]),mission_critical:BP}).strict(),Kpu=ge.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:[]}),ge.NEVER}let r=Jpu.safeParse(e);r.success||r.error.issues.forEach(i=>{t.addIssue({code:"custom",message:`${i.code}: ${i.message}`,path:i.path})})}),Ypu=ge.object({purpose:Fpu,expected_output:zpu,composition:Vpu}).strict(),v2o=ge.object({method:jpu,methodology:Ypu,template_integration:Bpu.optional(),integration_protocols:ge.record(ge.string(),ge.any()).optional(),usage_modes:Gpu,tactical_notes:Kpu}).catchall(ge.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 N$r(e,t){return a9(v2o,e,t?`${t}: `:"")}var Xpu=ge.object({header_sections:ge.array(ge.string()).optional().describe("Header content sections"),separators:ge.record(ge.string(),ge.string()).optional().describe("Visual separator content as Record<string, string>"),body_sections:ge.array(ge.string()).optional().describe("Main content sections"),footer_sections:ge.array(ge.string()).optional().describe("Footer content sections")}).strict().describe("Output structure organization - strict validation enforces consistent *_sections naming pattern"),Qpu=ge.record(ge.string(),ge.any()).describe("Display format and presentation specifications - accepts any key-value pairs for flexible formatting options"),emu=ge.object({format:ge.string().optional().describe("Output format type (e.g., 'structured_markdown_report')"),filename:ge.string().optional().describe("Filename pattern for template output (supports {{variables}})"),structure:Xpu.optional().describe("Output structure organization into header/body/footer sections")}).describe("Template output configuration - specifies how template results are generated and structured"),tmu=ge.object({title:ge.string().optional().describe("Section display title"),description:ge.string().optional().describe("Section description and purpose"),sub_sections:ge.array(ge.string()).optional().describe("List of sub-section names or descriptions"),content:ge.string().optional().describe("Plaintext content, examples, or instructions for this section"),type:ge.string().optional().describe("Section type classification for categorization"),focus:ge.string().optional().describe("Specific focus area for this section")}).catchall(ge.unknown()).describe("Individual template section - supports custom fields via passthrough"),rmu=ge.record(ge.string(),tmu).describe("Map of section names to section configurations"),nmu=ge.object({output:emu.optional().describe("File output configuration (filename, format, structure)"),display_format:Qpu.optional().describe("Display and presentation specifications")}).strict().describe("Core template configuration - groups output & display specifications under 'template:' key"),imu=ge.object({template:nmu.describe("REQUIRED: Configuration section - groups output and display specifications"),execution_flow:BP.optional().describe("OPTIONAL: Root-level execution workflow steps"),sections:rmu.describe("REQUIRED: Root-level section definitions for template content")}).strict().describe("TEMPLATE FILE ROOT STRUCTURE - contains template config, execution workflow, and content sections"),b2o=ge.object({name:ge.string().min(1,"Template name is required and must not be empty").describe("Template name from YAML frontmatter"),description:ge.string().min(1,"Template description is required and must not be empty").describe("Template description from YAML frontmatter")}).catchall(ge.union([imu,ge.string(),ge.number(),ge.boolean(),ge.null(),ge.array(ge.unknown())])).describe("Complete template file: YAML frontmatter metadata + one template definition following TemplateContentSchema");function V6(e){return a9(b2o,e)}var _2o=ge.union([ge.string().min(10,"Protocol content should be at least 10 characters"),ge.array(ge.union([ge.string().min(3,"Array item should be at least 3 characters"),ge.record(ge.string(),ge.any())])).min(1,"Array should not be empty"),ge.record(ge.string(),ge.union([ge.string().min(3,"Object value should be at least 3 characters"),ge.array(Fpt),ge.record(ge.string(),ge.any())])).refine(e=>Object.keys(e).length>0,"Object should not be empty"),ge.lazy(()=>ge.record(ge.string(),_2o))]),x2o=ge.record(ge.string(),_2o).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"),omu=ge.object({name:ge.string().min(1,"Protocol name is required"),description:ge.string().min(10,"Protocol description should be at least 10 characters")}).catchall(x2o).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 x2o.safeParse(i).success},"Protocol should have exactly one root key containing the protocol structure (in addition to name and description)");function amu(e){return a9(omu,e)}function smu(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 umu(e){let r={filename:"unknown",type:"protocol",status:"excellent",errors:[],warnings:[],advisories:[],score:0},i=amu(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=smu(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 cmu,test as S2o,expect as w2o}from"bun:test";import{lstatSync as lmu,existsSync as dmu}from"fs";import{join as k2o,basename as fmu,dirname as Lpt}from"path";async function pmu(e){let t=await pm(["method"],e);cmu("Category Link Validation",()=>{S2o("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=fmu(Lpt(n)),s=Lpt(Lpt(n)),u=Lpt(s),c=k2o(u,"categories"),l=k2o(c,o,a);if(!dmu(l)){r.push(`${l} not exists`);continue}try{lmu(l).isSymbolicLink()||r.push(`Not Link: ${l}`)}catch(d){r.push(`Error reading link ${l}: ${d}`)}}r.length>0&&console.error(`\u274C Link validation failures:
|
|
1004
1004
|
${r.join(`
|
|
1005
|
-
`)}`),w2o(r.length).toBe(0)}),S2o("should discover all method items",()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping method discovery check - no method items found");return}w2o(t.length).toBeGreaterThan(0),console.log(`\u2705 Validated ${t.length} method category links`)})})}import{describe as mmu,test as Upt,expect as Yue}from"bun:test";import{existsSync as hmu,readFileSync as gmu}from"fs";import{basename as ymu,dirname as vmu,join as bmu}from"path";function E2o(e){e&&(delete e.callSign,delete e.name,delete e.description,e.method?.references&&delete e.method.references)}function xmu(e){E2o(e);let t=Object.keys(e);return t[t.length-1]}function M$r(e){let t=ymu(e),r=vmu(e);mmu(`Method Validation: ${t}`,()=>{Upt("should pass Zod schema validation",async()=>{let i=await R_(e);if(!i){console.error(`
|
|
1005
|
+
`)}`),w2o(r.length).toBe(0)}),S2o("should discover all method items",()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping method discovery check - no method items found");return}w2o(t.length).toBeGreaterThan(0),console.log(`\u2705 Validated ${t.length} method category links`)})})}import{describe as mmu,test as Upt,expect as Yue}from"bun:test";import{existsSync as hmu,readFileSync as gmu}from"fs";import{basename as ymu,dirname as vmu,join as bmu}from"path";function E2o(e){e&&(delete e.callSign,delete e.name,delete e.description,e.method?.references&&delete e.method.references)}function xmu(e){E2o(e);let t=Object.keys(e).filter(r=>!r.endsWith("-tmpl")&&!r.endsWith("-protocol"));return t[t.length-1]}function M$r(e){let t=ymu(e),r=vmu(e);mmu(`Method Validation: ${t}`,()=>{Upt("should pass Zod schema validation",async()=>{let i=await R_(e);if(!i){console.error(`
|
|
1006
1006
|
\u274C ${t}: Failed to parse MDX YAML \u2014 readMdxYaml returned null/undefined
|
|
1007
1007
|
`),Yue(i).toBeDefined();return}E2o(i);let n=N$r(i,e);n.success||console.error(`
|
|
1008
1008
|
\u274C ${t}:
|
package/package.json
CHANGED