@kitelev/exocortex-cli 15.105.1 → 15.105.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.105.
|
|
2
|
+
// @kitelev/exocortex-cli v15.105.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 @@ ${Dr.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){F.handle(r)}}),n}o(tD,"dynamicCommandCommand");function A2(n){let e=[],t=[];I2(n,t);for(let{filePath:r,fm:i}of t){if(!Vl(i,"exocmd__Command"))continue;let s=i.exo__Asset_uid??"",a=i.exo__Asset_label??rD(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=Og(String(f)),p=t.find(_=>_.fm.exo__Asset_uid===h&&Vl(_.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(A2,"scanCommands");async function pH(n,e){let{tripleStore:t}=await x2(n),r=new jt.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(pH,"listCommandsForTarget");function mH(n){let e=[],t=[];I2(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(!Vl(s,"exocmd__Command"))continue;let a=s.exo__Asset_uid??"",c=s.exo__Asset_label??rD(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=Og(String(u)),p=r.get(h);if(!p)l.push(`Grounding reference "${h}" not found in vault`);else if(!Vl(p.fm,"exocmd__Grounding"))l.push(`Grounding reference "${h}" is not an exocmd__Grounding asset`);else{let _=p.fm,S=_.exocmd__Grounding_type;S?(Object.values(jt.GroundingType).includes(S)||l.push(`Grounding "${h}" has invalid type "${S}"`),(S===jt.GroundingType.PROPERTY_SET||S===jt.GroundingType.PROPERTY_DELETE)&&!_.exocmd__Grounding_targetProperty&&l.push(`Grounding "${h}" (${S}) missing targetProperty`),S===jt.GroundingType.PROPERTY_SET&&!_.exocmd__Grounding_targetValue&&l.push(`Grounding "${h}" (property_set) missing targetValue`),S===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=Og(String(f)),p=r.get(h);if(!p)l.push(`Precondition reference "${h}" not found in vault`);else if(!Vl(p.fm,"exocmd__Precondition"))l.push(`Precondition reference "${h}" is not an exocmd__Precondition asset`);else{let _=p.fm.exocmd__Precondition_sparqlAsk,S=p.fm.exocmd__Precondition_hostFunction;!_&&!S&&l.push(`Precondition "${h}" missing both sparqlAsk and hostFunction`)}}t.some(h=>Vl(h.fm,"exocmd__CommandBinding")?Og(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(mH,"validateCommands");async function x2(n){let e=new Zt(n),r=await new jt.NoteToRDFConverter(e).convertVault(),i=new jt.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}o(x2,"buildTripleStore");function C2(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}:`),C2(n.steps[t],e+" ")}}o(C2,"printGrounding");function I2(n,e){let t;try{t=(0,ds.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,hs.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;I2(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,ds.readFileSync)(i,"utf-8"),a=hH.parse(s);a.exists&&e.push({filePath:i,fm:gH(a.content)})}catch{}}}o(I2,"collectParsedFiles");function gH(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(gH,"parseYamlFrontmatter");function Vl(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(Vl,"hasClass");function Og(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(Og,"normalizeWikilink");function rD(n){return(0,hs.basename)(n,".md")}o(rD,"extractLabelFromFilename");var Ul=require("fs"),zf=require("path"),Ot=X(Bt());var yH={turtle:"turtle",ntriples:"n-triples",jsonld:"json-ld"},_H=new Ot.IRI(`${Ot.Namespace.RDF.iri.value}type`),nD=[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 vH(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=nD.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=nD.find(c=>c.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.')}o(vH,"resolveClassIri");function SH(n,e){let t=new Set;for(let r of n)r.predicate.equals(_H)&&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(SH,"filterByClass");function iD(){return new De("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";F.setFormat(e);try{let t=yH[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,zf.resolve)(n.vault);if(!(0,Ul.existsSync)(r))throw new xe(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=vH(n.filter);a=SH(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,zf.resolve)(n.out);try{(0,Ul.mkdirSync)((0,zf.dirname)(f),{recursive:!0}),(0,Ul.writeFileSync)(f,u,"utf-8")}catch(d){throw new cf("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){F.handle(t)}})}o(iD,"convertCommand");function sD(n){n.addCommand(JR()),n.addCommand(rO()),n.addCommand(nO())}o(sD,"addQuerySubcommands");function aD(n){let e=new De;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.105.
|
|
753
|
+
`)}catch(t){F.handle(t)}})}o(iD,"convertCommand");function sD(n){n.addCommand(JR()),n.addCommand(rO()),n.addCommand(nO())}o(sD,"addQuerySubcommands");function aD(n){let e=new De;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.105.2");let t=e.command("exoql").description("ExoQL query execution and cache management");sD(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return sD(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(fP()),e.addCommand(pP()),e.addCommand(mP()),e.addCommand(yP()),e.addCommand(_P()),e.addCommand(EP()),e.addCommand(CP()),e.addCommand(LP()),e.addCommand(jP()),e.addCommand(qP()),e.addCommand(zP()),e.addCommand(HP()),e.addCommand(YP()),e.addCommand(tD()),e.addCommand(iD()),e}o(aD,"createProgram");aD().parse();0&&(module.exports={createProgram});
|
|
754
754
|
/*! Bundled license information:
|
|
755
755
|
|
|
756
756
|
reflect-metadata/Reflect.js:
|
package/package.json
CHANGED