@kitelev/exocortex-cli 15.102.1 → 15.102.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 +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.102.
|
|
2
|
+
// @kitelev/exocortex-cli v15.102.2
|
|
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 o of i){console.log(` \u{1F4C4} ${o.label} (${o.uid}):`);for(let l of o.issues)console.log(` \u2022 ${l}`);console.log()}process.exitCode=5}}}catch(r){D.handle(r)}}),n}c(JP,"dynamicCommandCommand");function ES(n){let e=[],t=[];AS(n,t);for(let{filePath:r,fm:i}of t){if(!jl(i,"exocmd__Command"))continue;let s=i.exo__Asset_uid??"",a=i.exo__Asset_label??ZP(r),o=i.exocmd__Command_category,l=i.exocmd__Command_icon,u=!!i.exocmd__Command_precondition,f=i.exocmd__Command_grounding,d;if(f){let h=Ig(String(f)),p=t.find(_=>_.fm.exo__Asset_uid===h&&jl(_.fm,"exocmd__Grounding"));p&&(d=p.fm.exocmd__Grounding_type)}e.push({filePath:r,uid:s,label:a,category:o,icon:l,hasPrecondition:u,groundingType:d})}return e}c(ES,"scanCommands");async function cH(n,e){let{tripleStore:t}=await TS(n),r=new jt.CommandResolver(t),i=await r.findBindings(),s=new Set;for(let o of i)s.add(o.commandRef);let a=[];for(let o of s){let l=await r.loadCommand(o);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}c(cH,"listCommandsForTarget");function lH(n){let e=[],t=[];AS(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(!jl(s,"exocmd__Command"))continue;let a=s.exo__Asset_uid??"",o=s.exo__Asset_label??ZP(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=Ig(String(u)),p=r.get(h);if(!p)l.push(`Grounding reference "${h}" not found in vault`);else if(!jl(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(jt.GroundingType).includes(b)||l.push(`Grounding "${h}" has invalid type "${b}"`),(b===jt.GroundingType.PROPERTY_SET||b===jt.GroundingType.PROPERTY_DELETE)&&!_.exocmd__Grounding_targetProperty&&l.push(`Grounding "${h}" (${b}) missing targetProperty`),b===jt.GroundingType.PROPERTY_SET&&!_.exocmd__Grounding_targetValue&&l.push(`Grounding "${h}" (property_set) missing targetValue`),b===jt.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=Ig(String(f)),p=r.get(h);if(!p)l.push(`Precondition reference "${h}" not found in vault`);else if(!jl(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=>jl(h.fm,"exocmd__CommandBinding")?Ig(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:o,filePath:i,issues:l})}return e}c(lH,"validateCommands");async function TS(n){let e=new Zt(n),r=await new jt.NoteToRDFConverter(e).convertVault(),i=new jt.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}c(TS,"buildTripleStore");function xS(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}:`),xS(n.steps[t],e+" ")}}c(xS,"printGrounding");function AS(n,e){let t;try{t=(0,fs.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,ds.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;AS(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,fs.readFileSync)(i,"utf-8"),a=oH.parse(s);a.exists&&e.push({filePath:i,fm:uH(a.content)})}catch{}}}c(AS,"collectParsedFiles");function uH(n){let e={},t=n.split(`
|
|
751
751
|
`),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let o=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(o),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let o=a[2].trim();if((o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),o==="true"?o=!0:o==="false"&&(o=!1),o===""){e[r]=[],i=e[r];continue}e[r]=o}}return e}c(uH,"parseYamlFrontmatter");function jl(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}c(jl,"hasClass");function Ig(n){if(typeof n!="string")return"";let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.substring(0,t).trim():e}c(Ig,"normalizeWikilink");function ZP(n){return(0,ds.basename)(n,".md")}c(ZP,"extractLabelFromFilename");var $l=require("fs"),qf=require("path"),Ot=X(Bt());var fH={turtle:"turtle",ntriples:"n-triples",jsonld:"json-ld"},dH=new Ot.IRI(`${Ot.Namespace.RDF.iri.value}type`),eF=[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 hH(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=eF.find(o=>o.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=eF.find(o=>o.prefix===i);if(a)return a.term(s)}throw new ze(`Unable to resolve class filter "${n}" to an IRI.`,'Use shorthand like "ems__Task", prefixed like "ems:Task", or a full IRI.')}c(hH,"resolveClassIri");function pH(n,e){let t=new Set;for(let r of n)r.predicate.equals(dH)&&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()))}c(pH,"filterByClass");function tF(){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";D.setFormat(e);try{let t=fH[n.format];if(!t)throw new ze(`Unknown format: "${n.format}". Expected one of turtle|ntriples|jsonld.`,"exocortex convert --format turtle --out vault.ttl");let r=(0,qf.resolve)(n.vault);if(!(0,$l.existsSync)(r))throw new Ae(r);e==="text"&&!n.out||e==="text"&&console.error(`\u{1F4E6} Loading vault: ${r}...`);let i=new Zt(r),a=await new Ot.NoteToRDFConverter(i).convertVault();if(n.filter){let f=hH(n.filter);a=pH(a,f)}let o=new Ot.InMemoryTripleStore;await o.addAll(a);let u=new Ot.RDFSerializer(o).serializeTriples(a,t,{pretty:t==="json-ld",indent:2});if(n.out){let f=(0,qf.resolve)(n.out);try{(0,$l.mkdirSync)((0,qf.dirname)(f),{recursive:!0}),(0,$l.writeFileSync)(f,u,"utf-8")}catch(d){throw new sf("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){D.handle(t)}})}c(tF,"convertCommand");function rF(n){n.addCommand(YR()),n.addCommand(ZR()),n.addCommand(eO())}c(rF,"addQuerySubcommands");function nF(n){let e=new Fe;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.102.
|
|
753
|
+
`)}catch(t){D.handle(t)}})}c(tF,"convertCommand");function rF(n){n.addCommand(YR()),n.addCommand(ZR()),n.addCommand(eO())}c(rF,"addQuerySubcommands");function nF(n){let e=new Fe;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.102.2");let t=e.command("exoql").description("ExoQL query execution and cache management");rF(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return rF(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(cP()),e.addCommand(fP()),e.addCommand(dP()),e.addCommand(pP()),e.addCommand(mP()),e.addCommand(bP()),e.addCommand(TP()),e.addCommand(FP()),e.addCommand(LP()),e.addCommand(VP()),e.addCommand(qP()),e.addCommand(WP()),e.addCommand(zP()),e.addCommand(JP()),e.addCommand(tF()),e}c(nF,"createProgram");nF().parse();0&&(module.exports={createProgram});
|
|
754
754
|
/*! Bundled license information:
|
|
755
755
|
|
|
756
756
|
reflect-metadata/Reflect.js:
|
package/package.json
CHANGED