@kitelev/exocortex-cli 15.122.0 → 15.122.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.
- 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.122.
|
|
2
|
+
// @kitelev/exocortex-cli v15.122.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 @@ ${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(xF,"dynamicCommandCommand");function U2(n){let e=[],t=[];W2(n,t);let r=CF(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??IF(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=$g(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(U2,"scanCommands");async function mQ(n,e){let{tripleStore:t}=await B2(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(mQ,"listCommandsForTarget");function gQ(n){let e=[],t=[];W2(n,t);let r=CF(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??IF(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=$g(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=$g(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)?$g(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(gQ,"validateCommands");async function B2(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(B2,"buildTripleStore");function q2(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}:`),q2(n.steps[t],e+" ")}}o(q2,"printGrounding");function W2(n,e){let t;try{t=(0,gs.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,ys.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;W2(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,gs.readFileSync)(i,"utf-8"),a=pQ.parse(s);a.exists&&e.push({filePath:i,fm:yQ(a.content)})}catch{}}}o(W2,"collectParsedFiles");function yQ(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(yQ,"parseYamlFrontmatter");var _Q=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function CF(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(CF,"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&&_Q.test(c)&&t.get(c)===e)return!0}return!1}o(Ql,"hasClass");function $g(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($g,"normalizeWikilink");function IF(n){return(0,ys.basename)(n,".md")}o(IF,"extractLabelFromFilename");var Yl=require("fs"),Zf=require("path"),Pt=X(Bt());var vQ={turtle:"turtle",ntriples:"n-triples",jsonld:"json-ld"},SQ=new Pt.IRI(`${Pt.Namespace.RDF.iri.value}type`),RF=[Pt.Namespace.RDF,Pt.Namespace.RDFS,Pt.Namespace.OWL,Pt.Namespace.XSD,Pt.Namespace.EXO,Pt.Namespace.EMS,Pt.Namespace.EXOCMD,Pt.Namespace.IMS,Pt.Namespace.ZTLK,Pt.Namespace.PTMS,Pt.Namespace.LIT,Pt.Namespace.INBOX];function bQ(n){let e=n.trim();if(e.startsWith("http://")||e.startsWith("https://"))return new Pt.IRI(e);let t=e.match(/^([a-zA-Z][a-zA-Z0-9]*)__(.+)$/);if(t){let[,i,s]=t,a=RF.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=RF.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(bQ,"resolveClassIri");function wQ(n,e){let t=new Set;for(let r of n)r.predicate.equals(SQ)&&r.object instanceof Pt.IRI&&r.object.equals(e)&&t.add(r.subject.toString());return t.size===0?[]:n.filter(r=>t.has(r.subject.toString()))}o(wQ,"filterByClass");function OF(){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=vQ[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,Zf.resolve)(n.vault);if(!(0,Yl.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 Pt.NoteToRDFConverter(i).convertVault();if(n.filter){let f=bQ(n.filter);a=wQ(a,f)}let c=new Pt.InMemoryTripleStore;await c.addAll(a);let u=new Pt.RDFSerializer(c).serializeTriples(a,t,{pretty:t==="json-ld",indent:2});if(n.out){let f=(0,Zf.resolve)(n.out);try{(0,Yl.mkdirSync)((0,Zf.dirname)(f),{recursive:!0}),(0,Yl.writeFileSync)(f,u,"utf-8")}catch(d){throw new mf("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(OF,"convertCommand");function PF(n){n.addCommand(EO()),n.addCommand(CO()),n.addCommand(IO())}o(PF,"addQuerySubcommands");function FF(n){let e=new Fe;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.122.
|
|
753
|
+
`)}catch(t){N.handle(t)}})}o(OF,"convertCommand");function PF(n){n.addCommand(EO()),n.addCommand(CO()),n.addCommand(IO())}o(PF,"addQuerySubcommands");function FF(n){let e=new Fe;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.122.1");let t=e.command("exoql").description("ExoQL query execution and cache management");PF(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return PF(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(kP()),e.addCommand($P()),e.addCommand(VP()),e.addCommand(BP()),e.addCommand(qP()),e.addCommand(QP()),e.addCommand(JP()),e.addCommand(aF()),e.addCommand(lF()),e.addCommand(pF()),e.addCommand(yF()),e.addCommand(_F()),e.addCommand(SF()),e.addCommand(xF()),e.addCommand(OF()),e}o(FF,"createProgram");FF().parse();0&&(module.exports={createProgram});
|
|
754
754
|
/*! Bundled license information:
|
|
755
755
|
|
|
756
756
|
reflect-metadata/Reflect.js:
|
package/package.json
CHANGED