@kitelev/exocortex-cli 15.114.5 → 15.114.6

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.114.5
2
+ // @kitelev/exocortex-cli v15.114.6
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -750,7 +750,7 @@ ${Fr.dump(i,{lineWidth:-1})}---
750
750
  `);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){N.handle(r)}}),n}o(fF,"dynamicCommandCommand");function O2(n){let e=[],t=[];N2(n,t);let r=dF(t);for(let{filePath:i,fm:s}of t){if(!ql(s,"exocmd__Command",r))continue;let a=s.exo__Asset_uid??"",c=s.exo__Asset_label??hF(i),l=s.exocmd__Command_category,u=s.exocmd__Command_icon,f=!!s.exocmd__Command_precondition,d=s.exocmd__Command_grounding,h;if(d){let p=Dg(String(d)),_=t.find(S=>S.fm.exo__Asset_uid===p&&ql(S.fm,"exocmd__Grounding",r));_&&(h=_.fm.exocmd__Grounding_type)}e.push({filePath:i,uid:a,label:c,category:l,icon:u,hasPrecondition:f,groundingType:h})}return e}o(O2,"scanCommands");async function zH(n,e){let{tripleStore:t}=await F2(n),r=new Le.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(zH,"listCommandsForTarget");function HH(n){let e=[],t=[];N2(n,t);let r=dF(t),i=new Map;for(let s of t){let a=s.fm.exo__Asset_uid;a&&i.set(a,s)}for(let{filePath:s,fm:a}of t){if(!ql(a,"exocmd__Command",r))continue;let c=a.exo__Asset_uid??"",l=a.exo__Asset_label??hF(s),u=[];c||u.push("Missing exo__Asset_uid"),a.exo__Asset_label||u.push("Missing exo__Asset_label");let f=a.exocmd__Command_grounding;if(!f)u.push("Missing exocmd__Command_grounding (required)");else{let p=Dg(String(f)),_=i.get(p);if(!_)u.push(`Grounding reference "${p}" not found in vault`);else if(!ql(_.fm,"exocmd__Grounding",r))u.push(`Grounding reference "${p}" is not an exocmd__Grounding asset`);else{let S=_.fm,E=S.exocmd__Grounding_type;E?(Object.values(Le.GroundingType).includes(E)||u.push(`Grounding "${p}" has invalid type "${E}"`),(E===Le.GroundingType.PROPERTY_SET||E===Le.GroundingType.PROPERTY_DELETE)&&!S.exocmd__Grounding_targetProperty&&u.push(`Grounding "${p}" (${E}) missing targetProperty`),E===Le.GroundingType.PROPERTY_SET&&!S.exocmd__Grounding_targetValue&&u.push(`Grounding "${p}" (property_set) missing targetValue`),E===Le.GroundingType.SERVICE_CALL&&((S.exocmd__Grounding_serviceId??S.exocmd__Grounding_targetProperty)||u.push(`Grounding "${p}" (service_call) missing serviceId and targetProperty`))):u.push(`Grounding "${p}" missing exocmd__Grounding_type`)}}let d=a.exocmd__Command_precondition;if(d){let p=Dg(String(d)),_=i.get(p);if(!_)u.push(`Precondition reference "${p}" not found in vault`);else if(!ql(_.fm,"exocmd__Precondition",r))u.push(`Precondition reference "${p}" is not an exocmd__Precondition asset`);else{let S=_.fm.exocmd__Precondition_sparqlAsk,E=_.fm.exocmd__Precondition_hostFunction;!S&&!E&&u.push(`Precondition "${p}" missing both sparqlAsk and hostFunction`)}}t.some(p=>ql(p.fm,"exocmd__CommandBinding",r)?Dg(String(p.fm.exocmd__CommandBinding_command??""))===c:!1)||u.push("No CommandBinding references this command (command will be unused)"),u.length>0&&e.push({uid:c,label:l,filePath:s,issues:u})}return e}o(HH,"validateCommands");async function F2(n){let e=new qt(n),r=await new Le.NoteToRDFConverter(e).convertVault(),i=new Le.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}o(F2,"buildTripleStore");function D2(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}:`),D2(n.steps[t],e+" ")}}o(D2,"printGrounding");function N2(n,e){let t;try{t=(0,ps.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,ms.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;N2(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,ps.readFileSync)(i,"utf-8"),a=GH.parse(s);a.exists&&e.push({filePath:i,fm:QH(a.content)})}catch{}}}o(N2,"collectParsedFiles");function QH(n){let e={},t=n.split(`
751
751
  `),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(QH,"parseYamlFrontmatter");var YH=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function dF(n){let e=new Map;for(let{fm:t}of n){let r=t.exo__Asset_uid,i=t.exo__Asset_label;typeof r=="string"&&typeof i=="string"&&e.set(r,i)}return e}o(dF,"buildClassLabelIndex");function ql(n,e,t){let r=n.exo__Instance_class;if(!r)return!1;let i=Array.isArray(r)?r:[r];for(let s of i){if(typeof s!="string")continue;let a=s.match(/\[\[([^|\]]+)/),c=a?a[1]:s;if(c===e||t&&YH.test(c)&&t.get(c)===e)return!0}return!1}o(ql,"hasClass");function Dg(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(Dg,"normalizeWikilink");function hF(n){return(0,ms.basename)(n,".md")}o(hF,"extractLabelFromFilename");var Wl=require("fs"),Yf=require("path"),Ot=X(Bt());var XH={turtle:"turtle",ntriples:"n-triples",jsonld:"json-ld"},KH=new Ot.IRI(`${Ot.Namespace.RDF.iri.value}type`),pF=[Ot.Namespace.RDF,Ot.Namespace.RDFS,Ot.Namespace.OWL,Ot.Namespace.XSD,Ot.Namespace.EXO,Ot.Namespace.EMS,Ot.Namespace.EXOCMD,Ot.Namespace.IMS,Ot.Namespace.ZTLK,Ot.Namespace.PTMS,Ot.Namespace.LIT,Ot.Namespace.INBOX];function JH(n){let e=n.trim();if(e.startsWith("http://")||e.startsWith("https://"))return new Ot.IRI(e);let t=e.match(/^([a-zA-Z][a-zA-Z0-9]*)__(.+)$/);if(t){let[,i,s]=t,a=pF.find(c=>c.prefix===i);if(a)return a.term(s)}let r=e.match(/^([a-zA-Z][a-zA-Z0-9]*):(.+)$/);if(r){let[,i,s]=r,a=pF.find(c=>c.prefix===i);if(a)return a.term(s)}throw new He(`Unable to resolve class filter "${n}" to an IRI.`,'Use shorthand like "ems__Task", prefixed like "ems:Task", or a full IRI.')}o(JH,"resolveClassIri");function ZH(n,e){let t=new Set;for(let r of n)r.predicate.equals(KH)&&r.object instanceof Ot.IRI&&r.object.equals(e)&&t.add(r.subject.toString());return t.size===0?[]:n.filter(r=>t.has(r.subject.toString()))}o(ZH,"filterByClass");function mF(){return new Fe("convert").description("Dump vault graph as RDF (Turtle/N-Triples/JSON-LD)").option("--format <type>","Serialization format: turtle|ntriples|jsonld","turtle").option("--out <path>","Write serialized output to file (default: stdout)").option("--filter <class>","Keep only instances of the given class (e.g. ems__Task, ems:Task, or full IRI)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format for errors: text|json (for MCP tools)","text").action(async n=>{let e=n.output||"text";N.setFormat(e);try{let t=XH[n.format];if(!t)throw new He(`Unknown format: "${n.format}". Expected one of turtle|ntriples|jsonld.`,"exocortex convert --format turtle --out vault.ttl");let r=(0,Yf.resolve)(n.vault);if(!(0,Wl.existsSync)(r))throw new xe(r);e==="text"&&!n.out||e==="text"&&console.error(`\u{1F4E6} Loading vault: ${r}...`);let i=new qt(r),a=await new Ot.NoteToRDFConverter(i).convertVault();if(n.filter){let f=JH(n.filter);a=ZH(a,f)}let c=new Ot.InMemoryTripleStore;await c.addAll(a);let u=new Ot.RDFSerializer(c).serializeTriples(a,t,{pretty:t==="json-ld",indent:2});if(n.out){let f=(0,Yf.resolve)(n.out);try{(0,Wl.mkdirSync)((0,Yf.dirname)(f),{recursive:!0}),(0,Wl.writeFileSync)(f,u,"utf-8")}catch(d){throw new ff("convert",`failed to write output to ${f}: ${d.message}`,"Check destination directory exists and is writable.",{outPath:f})}e==="text"&&console.error(`\u2705 Wrote ${a.length} triple(s) to ${f} (${n.format}).`)}else process.stdout.write(u),u.endsWith(`
752
752
  `)||process.stdout.write(`
753
- `)}catch(t){N.handle(t)}})}o(mF,"convertCommand");function gF(n){n.addCommand(cP()),n.addCommand(dP()),n.addCommand(hP())}o(gF,"addQuerySubcommands");function yF(n){let e=new Fe;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.114.5");let t=e.command("exoql").description("ExoQL query execution and cache management");gF(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return gF(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(bO()),e.addCommand(TO()),e.addCommand(AO()),e.addCommand(CO()),e.addCommand(IO()),e.addCommand(DO()),e.addCommand(MO()),e.addCommand(GO()),e.addCommand(QO()),e.addCommand(ZO()),e.addCommand(rF()),e.addCommand(nF()),e.addCommand(sF()),e.addCommand(fF()),e.addCommand(mF()),e}o(yF,"createProgram");yF().parse();0&&(module.exports={createProgram});
753
+ `)}catch(t){N.handle(t)}})}o(mF,"convertCommand");function gF(n){n.addCommand(cP()),n.addCommand(dP()),n.addCommand(hP())}o(gF,"addQuerySubcommands");function yF(n){let e=new Fe;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.114.6");let t=e.command("exoql").description("ExoQL query execution and cache management");gF(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return gF(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(bO()),e.addCommand(TO()),e.addCommand(AO()),e.addCommand(CO()),e.addCommand(IO()),e.addCommand(DO()),e.addCommand(MO()),e.addCommand(GO()),e.addCommand(QO()),e.addCommand(ZO()),e.addCommand(rF()),e.addCommand(nF()),e.addCommand(sF()),e.addCommand(fF()),e.addCommand(mF()),e}o(yF,"createProgram");yF().parse();0&&(module.exports={createProgram});
754
754
  /*! Bundled license information:
755
755
 
756
756
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitelev/exocortex-cli",
3
- "version": "15.114.5",
3
+ "version": "15.114.6",
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": {