@kitelev/exocortex-cli 15.123.0 → 15.123.1

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.123.0
2
+ // @kitelev/exocortex-cli v15.123.1
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 @@ ${Nr.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(WF,"dynamicCommandCommand");function Jw(n){let e=[],t=[];t2(n,t);let r=GF(t);for(let{filePath:i,fm:s}of t){if(!Jl(s,"exocmd__Command",r))continue;let a=s.exo__Asset_uid??"",c=s.exo__Asset_label??zF(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=Yg(String(d)),_=t.find(v=>v.fm.exo__Asset_uid===p&&Jl(v.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(Jw,"scanCommands");async function JQ(n,e){let{tripleStore:t}=await Zw(n),r=new ke.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(JQ,"listCommandsForTarget");function ZQ(n){let e=[],t=[];t2(n,t);let r=GF(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(!Jl(a,"exocmd__Command",r))continue;let c=a.exo__Asset_uid??"",l=a.exo__Asset_label??zF(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=Yg(String(f)),_=i.get(p);if(!_)u.push(`Grounding reference "${p}" not found in vault`);else if(!Jl(_.fm,"exocmd__Grounding",r))u.push(`Grounding reference "${p}" is not an exocmd__Grounding asset`);else{let v=_.fm,E=v.exocmd__Grounding_type;E?(Object.values(ke.GroundingType).includes(E)||u.push(`Grounding "${p}" has invalid type "${E}"`),(E===ke.GroundingType.PROPERTY_SET||E===ke.GroundingType.PROPERTY_DELETE)&&!v.exocmd__Grounding_targetProperty&&u.push(`Grounding "${p}" (${E}) missing targetProperty`),E===ke.GroundingType.PROPERTY_SET&&!v.exocmd__Grounding_targetValue&&u.push(`Grounding "${p}" (property_set) missing targetValue`),E===ke.GroundingType.SERVICE_CALL&&((v.exocmd__Grounding_serviceId??v.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=Yg(String(d)),_=i.get(p);if(!_)u.push(`Precondition reference "${p}" not found in vault`);else if(!Jl(_.fm,"exocmd__Precondition",r))u.push(`Precondition reference "${p}" is not an exocmd__Precondition asset`);else{let v=_.fm.exocmd__Precondition_sparqlAsk,E=_.fm.exocmd__Precondition_hostFunction;!v&&!E&&u.push(`Precondition "${p}" missing both sparqlAsk and hostFunction`)}}t.some(p=>Jl(p.fm,"exocmd__CommandBinding",r)?Yg(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(ZQ,"validateCommands");async function Zw(n){let e=new Gt(n),r=await new ke.NoteToRDFConverter(e).convertVault(),i=new ke.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}o(Zw,"buildTripleStore");function e2(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}:`),e2(n.steps[t],e+" ")}}o(e2,"printGrounding");function t2(n,e){let t;try{t=(0,_s.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,Ss.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;t2(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,_s.readFileSync)(i,"utf-8"),a=XQ.parse(s);a.exists&&e.push({filePath:i,fm:eY(a.content)})}catch{}}}o(t2,"collectParsedFiles");function eY(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(eY,"parseYamlFrontmatter");var tY=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function GF(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(GF,"buildClassLabelIndex");function Jl(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&&tY.test(c)&&t.get(c)===e)return!0}return!1}o(Jl,"hasClass");function Yg(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(Yg,"normalizeWikilink");function zF(n){return(0,Ss.basename)(n,".md")}o(zF,"extractLabelFromFilename");var Zl=require("fs"),od=require("path"),Ft=K(Wt());var rY={turtle:"turtle",ntriples:"n-triples",jsonld:"json-ld"},nY=new Ft.IRI(`${Ft.Namespace.RDF.iri.value}type`),HF=[Ft.Namespace.RDF,Ft.Namespace.RDFS,Ft.Namespace.OWL,Ft.Namespace.XSD,Ft.Namespace.EXO,Ft.Namespace.EMS,Ft.Namespace.EXOCMD,Ft.Namespace.IMS,Ft.Namespace.ZTLK,Ft.Namespace.PTMS,Ft.Namespace.LIT,Ft.Namespace.INBOX];function iY(n){let e=n.trim();if(e.startsWith("http://")||e.startsWith("https://"))return new Ft.IRI(e);let t=e.match(/^([a-zA-Z][a-zA-Z0-9]*)__(.+)$/);if(t){let[,i,s]=t,a=HF.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=HF.find(c=>c.prefix===i);if(a)return a.term(s)}throw new Qe(`Unable to resolve class filter "${n}" to an IRI.`,'Use shorthand like "ems__Task", prefixed like "ems:Task", or a full IRI.')}o(iY,"resolveClassIri");function sY(n,e){let t=new Set;for(let r of n)r.predicate.equals(nY)&&r.object instanceof Ft.IRI&&r.object.equals(e)&&t.add(r.subject.toString());return t.size===0?[]:n.filter(r=>t.has(r.subject.toString()))}o(sY,"filterByClass");function QF(){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=rY[n.format];if(!t)throw new Qe(`Unknown format: "${n.format}". Expected one of turtle|ntriples|jsonld.`,"exocortex convert --format turtle --out vault.ttl");let r=(0,od.resolve)(n.vault);if(!(0,Zl.existsSync)(r))throw new xe(r);e==="text"&&!n.out||e==="text"&&console.error(`\u{1F4E6} Loading vault: ${r}...`);let i=new Gt(r),a=await new Ft.NoteToRDFConverter(i).convertVault();if(n.filter){let f=iY(n.filter);a=sY(a,f)}let c=new Ft.InMemoryTripleStore;await c.addAll(a);let u=new Ft.RDFSerializer(c).serializeTriples(a,t,{pretty:t==="json-ld",indent:2});if(n.out){let f=(0,od.resolve)(n.out);try{(0,Zl.mkdirSync)((0,od.dirname)(f),{recursive:!0}),(0,Zl.writeFileSync)(f,u,"utf-8")}catch(d){throw new Ef("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(QF,"convertCommand");function YF(n){n.addCommand(BO()),n.addCommand(GO()),n.addCommand(zO())}o(YF,"addQuerySubcommands");function KF(n){let e=new Fe;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.123.0");let t=e.command("exoql").description("ExoQL query execution and cache management");YF(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return YF(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(eF()),e.addCommand(nF()),e.addCommand(iF()),e.addCommand(aF()),e.addCommand(oF()),e.addCommand(dF()),e.addCommand(gF()),e.addCommand(TF()),e.addCommand(CF()),e.addCommand(FF()),e.addCommand(LF()),e.addCommand(kF()),e.addCommand(jF()),e.addCommand(WF()),e.addCommand(QF()),e}o(KF,"createProgram");KF().parse();0&&(module.exports={createProgram});
753
+ `)}catch(t){N.handle(t)}})}o(QF,"convertCommand");function YF(n){n.addCommand(BO()),n.addCommand(GO()),n.addCommand(zO())}o(YF,"addQuerySubcommands");function KF(n){let e=new Fe;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.123.1");let t=e.command("exoql").description("ExoQL query execution and cache management");YF(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return YF(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(eF()),e.addCommand(nF()),e.addCommand(iF()),e.addCommand(aF()),e.addCommand(oF()),e.addCommand(dF()),e.addCommand(gF()),e.addCommand(TF()),e.addCommand(CF()),e.addCommand(FF()),e.addCommand(LF()),e.addCommand(kF()),e.addCommand(jF()),e.addCommand(WF()),e.addCommand(QF()),e}o(KF,"createProgram");KF().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.123.0",
3
+ "version": "15.123.1",
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": {