@kitelev/exocortex-cli 15.77.7 → 15.77.8

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.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // @kitelev/exocortex-cli v15.77.7
2
+ // @kitelev/exocortex-cli v15.77.8
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -687,7 +687,7 @@ ${xr.dump(i,{lineWidth:-1})}---
687
687
  \u{1F50D} Dry-run: command "${l.name}" on "${t.target}"
688
688
  `),console.log(" Precondition: passed \u2705"),console.log(" Grounding (would execute):"),eS(l.grounding," ");return}let h=new kt.ServiceRegistry;pR(h);let p=new Dt(i),b=await new kt.GroundingExecutor(p,p,h).execute(l.grounding,u,t.target);if(r==="json"){let T=Z.success({command:l.name,target:t.target,preconditionPassed:!0,executed:!0,success:b.success,...b.error&&{error:b.error},...l.successMessage&&b.success&&{message:l.successMessage}});console.log(JSON.stringify(T,null,2))}else if(b.success){let T=l.successMessage??`Command "${l.name}" executed successfully.`;console.log(`\u2705 ${T}`)}else console.log(`\u274C Command "${l.name}" failed: ${b.error}`),process.exitCode=5}catch(i){k.handle(i)}}),n.command("validate").description("Validate all dynamic command definitions in vault").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async e=>{let t=e.output||"text";k.setFormat(t);try{let r=(0,os.resolve)(e.vault);if(!(0,as.existsSync)(r))throw new Oe(r);let i=rH(r);if(t==="json"){let s=Z.success({totalCommands:Jb(r).length,totalIssues:i.reduce((a,c)=>a+c.issues.length,0),commandsWithIssues:i.length,issues:i});console.log(JSON.stringify(s,null,2))}else{let s=Jb(r);if(i.length===0)console.log(`\u2705 All ${s.length} dynamic command(s) are valid.`);else{let a=i.reduce((c,l)=>c+l.issues.length,0);console.log(`\u274C Found ${a} issue(s) in ${i.length} command(s) out of ${s.length} total:
689
689
  `);for(let c of i){console.log(` \u{1F4C4} ${c.label} (${c.uid}):`);for(let l of c.issues)console.log(` \u2022 ${l}`);console.log()}process.exitCode=5}}}catch(r){k.handle(r)}}),n}o(mR,"dynamicCommandCommand");function Jb(n){let e=[],t=[];tS(n,t);for(let{filePath:r,fm:i}of t){if(!Pl(i,"exocmd__Command"))continue;let s=i.exo__Asset_uid??"",a=i.exo__Asset_label??gR(r),c=i.exocmd__Command_category,l=i.exocmd__Command_icon,u=!!i.exocmd__Command_precondition,f=i.exocmd__Command_grounding,d;if(f){let h=mg(String(f)),p=t.find(_=>_.fm.exo__Asset_uid===h&&Pl(_.fm,"exocmd__Grounding"));p&&(d=p.fm.exocmd__Grounding_type)}e.push({filePath:r,uid:s,label:a,category:c,icon:l,hasPrecondition:u,groundingType:d})}return e}o(Jb,"scanCommands");async function tH(n,e){let{tripleStore:t}=await Zb(n),r=new kt.CommandResolver(t),i=await r.findBindings(),s=new Set;for(let c of i)s.add(c.commandRef);let a=[];for(let c of s){let l=await r.loadCommand(c);l&&a.push({filePath:"",uid:l.id,label:l.name,category:l.category,icon:l.icon,hasPrecondition:!!l.precondition,groundingType:l.grounding.type})}return a}o(tH,"listCommandsForTarget");function rH(n){let e=[],t=[];tS(n,t);let r=new Map;for(let i of t){let s=i.fm.exo__Asset_uid;s&&r.set(s,i)}for(let{filePath:i,fm:s}of t){if(!Pl(s,"exocmd__Command"))continue;let a=s.exo__Asset_uid??"",c=s.exo__Asset_label??gR(i),l=[];a||l.push("Missing exo__Asset_uid"),s.exo__Asset_label||l.push("Missing exo__Asset_label");let u=s.exocmd__Command_grounding;if(!u)l.push("Missing exocmd__Command_grounding (required)");else{let h=mg(String(u)),p=r.get(h);if(!p)l.push(`Grounding reference "${h}" not found in vault`);else if(!Pl(p.fm,"exocmd__Grounding"))l.push(`Grounding reference "${h}" is not an exocmd__Grounding asset`);else{let _=p.fm,b=_.exocmd__Grounding_type;b?(Object.values(kt.GroundingType).includes(b)||l.push(`Grounding "${h}" has invalid type "${b}"`),(b===kt.GroundingType.PROPERTY_SET||b===kt.GroundingType.PROPERTY_DELETE)&&!_.exocmd__Grounding_targetProperty&&l.push(`Grounding "${h}" (${b}) missing targetProperty`),b===kt.GroundingType.PROPERTY_SET&&!_.exocmd__Grounding_targetValue&&l.push(`Grounding "${h}" (property_set) missing targetValue`),b===kt.GroundingType.SERVICE_CALL&&((_.exocmd__Grounding_serviceId??_.exocmd__Grounding_targetProperty)||l.push(`Grounding "${h}" (service_call) missing serviceId and targetProperty`))):l.push(`Grounding "${h}" missing exocmd__Grounding_type`)}}let f=s.exocmd__Command_precondition;if(f){let h=mg(String(f)),p=r.get(h);if(!p)l.push(`Precondition reference "${h}" not found in vault`);else if(!Pl(p.fm,"exocmd__Precondition"))l.push(`Precondition reference "${h}" is not an exocmd__Precondition asset`);else{let _=p.fm.exocmd__Precondition_sparqlAsk,b=p.fm.exocmd__Precondition_hostFunction;!_&&!b&&l.push(`Precondition "${h}" missing both sparqlAsk and hostFunction`)}}t.some(h=>Pl(h.fm,"exocmd__CommandBinding")?mg(String(h.fm.exocmd__CommandBinding_command??""))===a:!1)||l.push("No CommandBinding references this command (command will be unused)"),l.length>0&&e.push({uid:a,label:c,filePath:i,issues:l})}return e}o(rH,"validateCommands");async function Zb(n){let e=new Ur(n),r=await new kt.NoteToRDFConverter(e).convertVault(),i=new kt.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}o(Zb,"buildTripleStore");function eS(n,e){if(console.log(`${e}ID: ${n.id}`),console.log(`${e}Label: ${n.label}`),console.log(`${e}Type: ${n.type}`),n.targetProperty&&console.log(`${e}Target property: ${n.targetProperty}`),n.targetValue!==void 0&&console.log(`${e}Target value: ${n.targetValue}`),n.sparqlUpdate&&console.log(`${e}SPARQL UPDATE: ${n.sparqlUpdate}`),n.steps&&n.steps.length>0){console.log(`${e}Steps (${n.steps.length}):`);for(let t=0;t<n.steps.length;t++)console.log(`${e} Step ${t+1}:`),eS(n.steps[t],e+" ")}}o(eS,"printGrounding");function tS(n,e){let t;try{t=(0,as.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,os.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;tS(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,as.readFileSync)(i,"utf-8"),a=eH.parse(s);a.exists&&e.push({filePath:i,fm:nH(a.content)})}catch{}}}o(tS,"collectParsedFiles");function nH(n){let e={},t=n.split(`
690
- `),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let c=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(c),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let c=a[2].trim();if((c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),c==="true"?c=!0:c==="false"&&(c=!1),c===""){e[r]=[],i=e[r];continue}e[r]=c}}return e}o(nH,"parseYamlFrontmatter");function Pl(n,e){let t=n.exo__Instance_class;if(!t)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}o(Pl,"hasClass");function mg(n){if(typeof n!="string")return"";let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.substring(0,t).trim():e}o(mg,"normalizeWikilink");function gR(n){return(0,os.basename)(n,".md")}o(gR,"extractLabelFromFilename");function yR(n){n.addCommand(yI()),n.addCommand(SI()),n.addCommand(wI())}o(yR,"addQuerySubcommands");function _R(n){let e=new We;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.77.7");let t=e.command("exoql").description("ExoQL query execution and cache management");yR(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return yR(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(OO()),e.addCommand(FO()),e.addCommand(NO()),e.addCommand(kO()),e.addCommand(MO()),e.addCommand(BO()),e.addCommand(HO()),e.addCommand(YO()),e.addCommand(JO()),e.addCommand(nR()),e.addCommand(aR()),e.addCommand(oR()),e.addCommand(lR()),e.addCommand(mR()),e}o(_R,"createProgram");_R().parse();0&&(module.exports={createProgram});
690
+ `),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let c=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(c),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let c=a[2].trim();if((c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),c==="true"?c=!0:c==="false"&&(c=!1),c===""){e[r]=[],i=e[r];continue}e[r]=c}}return e}o(nH,"parseYamlFrontmatter");function Pl(n,e){let t=n.exo__Instance_class;if(!t)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}o(Pl,"hasClass");function mg(n){if(typeof n!="string")return"";let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.substring(0,t).trim():e}o(mg,"normalizeWikilink");function gR(n){return(0,os.basename)(n,".md")}o(gR,"extractLabelFromFilename");function yR(n){n.addCommand(yI()),n.addCommand(SI()),n.addCommand(wI())}o(yR,"addQuerySubcommands");function _R(n){let e=new We;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.77.8");let t=e.command("exoql").description("ExoQL query execution and cache management");yR(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return yR(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(OO()),e.addCommand(FO()),e.addCommand(NO()),e.addCommand(kO()),e.addCommand(MO()),e.addCommand(BO()),e.addCommand(HO()),e.addCommand(YO()),e.addCommand(JO()),e.addCommand(nR()),e.addCommand(aR()),e.addCommand(oR()),e.addCommand(lR()),e.addCommand(mR()),e}o(_R,"createProgram");_R().parse();0&&(module.exports={createProgram});
691
691
  /*! Bundled license information:
692
692
 
693
693
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitelev/exocortex-cli",
3
- "version": "15.77.7",
3
+ "version": "15.77.8",
4
4
  "description": "CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more",
5
5
  "main": "dist/index.js",
6
6
  "bin": {