@kitelev/exocortex-cli 16.74.2 → 16.74.3

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 +6 -6
  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 v16.74.2
2
+ // @kitelev/exocortex-cli v16.74.3
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -523,7 +523,7 @@ Use: exocortex command --help for usage information.`;super(t,i,{message:r||"Che
523
523
  Check:
524
524
  \u2022 Path spelling and case sensitivity
525
525
  \u2022 Directory exists and is accessible
526
- \u2022 You have read permissions for the directory`}static{a(this,"VaultNotFoundError")}};var fd=class extends tn{constructor(t,r,i){let s=Math.round(t/1e3),l=`Query timeout after ${r!==void 0?Math.round(r/1e3):s}s (limit: ${s}s)`;super(l,{timeoutMs:t,elapsedMs:r??t,partialResultsCount:i},{message:"Increase timeout with --timeout <duration> (e.g., --timeout 60s)",suggestion:`exocortex sparql query --timeout ${s*2}s "..."`});this.exitCode=5;this.errorCode="INTERNAL_QUERY_TIMEOUT";this.guidance=`Query exceeded the ${s}s timeout limit.
526
+ \u2022 You have read permissions for the directory`}static{a(this,"VaultNotFoundError")}};var fd=class extends tn{constructor(t,r,i){let s=Math.round(t/1e3),l=`Query timeout after ${r!==void 0?Math.round(r/1e3):s}s (limit: ${s}s)`;super(l,{timeoutMs:t,elapsedMs:r??t,partialResultsCount:i},{message:"Increase timeout with --timeout <duration> (e.g., --timeout 60s)",suggestion:`exocortex query --timeout ${s*2}s "..."`});this.exitCode=5;this.errorCode="INTERNAL_QUERY_TIMEOUT";this.guidance=`Query exceeded the ${s}s timeout limit.
527
527
 
528
528
  To fix this:
529
529
  1. Increase timeout: --timeout ${s*2}s
@@ -608,10 +608,10 @@ Available prefixes: ${u}`,this.wellKnownPrefixes[r]&&l.push(`Add: PREFIX ${r}: <
608
608
  `)}formatForJSON(e){return{type:e.type,message:e.message,originalMessage:e.originalMessage,suggestions:e.suggestions,line:e.line,column:e.column,context:e.context?{startLine:e.context.startLine,endLine:e.context.endLine,errorLine:e.context.errorLine,errorColumn:e.context.errorColumn,lines:e.context.lines.map(t=>({number:t.number,content:t.content,isError:t.isError}))}:void 0}}};var hy=class n{static{a(this,"NTriplesFormatter")}static escapeString(e){let t=e.replace(/\\/g,"\\\\");return t=t.replace(/"/g,'\\"'),t=t.replace(/\n/g,"\\n"),t=t.replace(/\r/g,"\\r"),t=t.replace(/\t/g,"\\t"),t}static formatObject(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("urn:")?`<${e}>`:`"${n.escapeString(e)}"`}};var ul=require("fs"),iT=require("path");function ca(n){let e=new Map,t="obsidian://vault/",r;try{r=(0,ul.readdirSync)(n)}catch{return e}for(let i of r){let s=(0,iT.join)(n,i);if(i.startsWith("."))continue;let o;try{o=(0,ul.statSync)(s)}catch{continue}if(!o.isDirectory())continue;let l;try{l=(0,ul.readdirSync)(s)}catch{continue}for(let c of l){let u=(0,iT.join)(s,c);if(c.startsWith("."))continue;let f;try{f=(0,ul.statSync)(u)}catch{continue}if(!f.isDirectory())continue;let d=!1;try{d=(0,ul.readdirSync)(u).some(p=>p.endsWith(".md"))}catch{continue}if(d){let h=`${i}/${c}`,p=encodeURI(h),g=`${t}${p}/`;/^[a-zA-Z][a-zA-Z0-9_]*$/.test(c)&&e.set(c,g)}}}return e}a(ca,"scanVaultNamespaces");var YD=Q(ot());var JK="https://exocortex.my/ontology/",ZK=/^[a-z][a-zA-Z0-9]*$/,KD=new Set(["exo","ems","ims","gtd","period","lit","inbox","rdf","rdfs","owl","xsd"]),eJ=/(<)([a-zA-Z][a-zA-Z0-9]*)__([a-zA-Z][a-zA-Z0-9_]*)(>)/g;function ua(n){let e=new Set,t=/PREFIX\s+(\w+)\s*:/gi,r;for(;(r=t.exec(n))!==null;)e.add(r[1].toLowerCase());let i=YD.SPARQL_PREFIXES.split(`
609
609
  `).filter(f=>f.trim().length>0),s=[];for(let f of i){let d=/PREFIX\s+(\w+)\s*:/i.exec(f);d&&!e.has(d[1].toLowerCase())&&s.push(f)}let o=/(?<![:\w])([a-z][a-zA-Z0-9]*):[a-zA-Z_]/g,l=new Set,c;for(;(c=o.exec(n))!==null;)l.add(c[1]);let u=new Set(e);for(let f of s){let d=/PREFIX\s+(\w+)\s*:/i.exec(f);d&&u.add(d[1].toLowerCase())}for(let f of l)u.has(f.toLowerCase())||ZK.test(f)&&(s.push(`PREFIX ${f}: <${JK}${f}#>`),u.add(f.toLowerCase()));return s.length===0?n:s.join(`
610
610
  `)+`
611
- `+n}a(ua,"injectExocortexPrefixes");function cu(n){return n.replace(eJ,(e,t,r,i,s)=>KD.has(r.toLowerCase())?`${r}:${i}`:e)}a(cu,"transformShorthandNotation");function fa(n){let e=new Map(n);for(let t of KD)e.delete(t);return e}a(fa,"filterOntologyPrefixes");var JD=require("path");var tJ=/\/assetspaces\/([^/]+)\/?$/;function py(n){let e=(0,JD.resolve)(n).replace(/\\/g,"/"),t=tJ.exec(e);return t?`assetspaces/${t[1]}`:""}a(py,"deriveSubjectIriPrefix");var $n=Q(ot());var rJ=new Map([["exo__","https://exocortex.my/ontology/exo#"],["ems__","https://exocortex.my/ontology/ems#"],["exocmd__","https://exocortex.my/ontology/exocmd#"],["ims__","https://exocortex.my/ontology/ims#"],["ztlk__","https://exocortex.my/ontology/ztlk#"],["ptms__","https://exocortex.my/ontology/ptms#"],["lit__","https://exocortex.my/ontology/lit#"],["inbox__","https://exocortex.my/ontology/inbox#"],["place__","https://exocortex.my/ontology/place#"],["exoob__","https://exocortex.my/ontology/exoob#"],["pn__","https://exocortex.my/ontology/pn#"],["period__","https://exocortex.my/ontology/period#"],["rdf__","http://www.w3.org/1999/02/22-rdf-syntax-ns#"],["rdfs__","http://www.w3.org/2000/01/rdf-schema#"],["owl__","http://www.w3.org/2002/07/owl#"]]);function nJ(n){let e=n.indexOf("__");if(e===-1)return null;let t=n.slice(0,e+2),r=n.slice(e+2),i=rJ.get(t);return!i||!r?null:i+r}a(nJ,"labelToOntologyIRI");var ZD="https://exocortex.my/ontology/exo#Instance_class",iJ="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",sJ="http://www.w3.org/2000/01/rdf-schema#label",oJ="https://exocortex.my/ontology/exo#Asset_label",aJ=/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i,lJ=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function my(n){let e=new Map;for(let i of n){if(!(i.subject instanceof $n.DomainIRI)||!(i.predicate instanceof $n.DomainIRI)||!(i.object instanceof $n.DomainLiteral)||i.predicate.value!==sJ&&i.predicate.value!==oJ)continue;let s=lJ.exec(i.subject.value);if(!s)continue;let o=s[1].toLowerCase();if(e.has(o))continue;let l=i.object.value.trim();if(/\s/.test(l))continue;let c=nJ(l);c&&e.set(o,c)}if(e.size===0)return n;let t=new Set,r=[];for(let i of n){if(!(i.subject instanceof $n.DomainIRI)||!(i.predicate instanceof $n.DomainIRI)||!(i.object instanceof $n.DomainLiteral)||i.predicate.value!==ZD)continue;let s=i.object.value.trim(),o=aJ.exec(s);if(!o)continue;let l=o[1].toLowerCase(),c=e.get(l);if(!c)continue;let f=`${i.subject.value}\0${c}`;if(t.has(f))continue;t.add(f);let d=new $n.DomainIRI(c);r.push(new $n.DomainTriple(i.subject,new $n.DomainIRI(ZD),d)),r.push(new $n.DomainTriple(i.subject,new $n.DomainIRI(iJ),d))}return r.length>0?n.concat(r):n}a(my,"resolveCrossVaultInstanceClassWikilinks");var cJ=300,eL=3e4,uJ="EXOCORTEX_SPARQL_TIMEOUT";function fJ(){let n=process.env[uJ];if(!n)return eL;try{let e=dJ(n);if(e!==null&&e>0)return e}catch{}return eL}a(fJ,"getDefaultTimeout");function dJ(n){let e=n.trim().toLowerCase();if(!e)return null;if(e.endsWith("ms")){let r=parseInt(e.slice(0,-2),10);return isNaN(r)||r<=0?null:r}if(e.endsWith("s")){let r=parseInt(e.slice(0,-1),10);return isNaN(r)||r<=0?null:r*1e3}let t=parseInt(e,10);return isNaN(t)||t<=0?null:t*1e3}a(dJ,"parseTimeoutSafe");function hJ(n){if(!n)return cJ;let e=parseInt(n.trim(),10);if(isNaN(e)||e<=0)throw new Le(`Invalid cache TTL: "${n}". Must be a positive number (seconds).`,'exocortex sparql query --cache-ttl 600 "SELECT * WHERE { ?s ?p ?o }"');return e}a(hJ,"parseCacheTtl");function pJ(n){let e=n.trim().toLowerCase();if(e.endsWith("ms")){let r=parseInt(e.slice(0,-2),10);if(isNaN(r)||r<=0)throw new Le(`Invalid timeout format: "${n}". Value must be a positive number.`,'exocortex sparql query --timeout "30s" or --timeout "5000ms"');return r}if(e.endsWith("s")){let r=parseInt(e.slice(0,-1),10);if(isNaN(r)||r<=0)throw new Le(`Invalid timeout format: "${n}". Value must be a positive number.`,'exocortex sparql query --timeout "30s" or --timeout "5000ms"');return r*1e3}let t=parseInt(e,10);if(isNaN(t)||t<=0)throw new Le(`Invalid timeout format: "${n}". Use formats like "30s", "5000ms", or just a number (seconds).`,'exocortex sparql query --timeout "30s" or --timeout "5000ms"');return t*1e3}a(pJ,"parseTimeout");async function sT(n,e,t=Date.now()){let r,i=new Promise((s,o)=>{r=setTimeout(()=>{let l=Date.now()-t;o(new fd(e,l))},e),r&&typeof r=="object"&&"unref"in r&&r.unref()});return Promise.race([n,i])}a(sT,"executeWithTimeout");function mJ(n,e){return e.concat([n])}a(mJ,"collectAlso");function rL(){return new ne("query").description("Execute SPARQL query against Obsidian vault").argument("[query]","SPARQL query string or path to .sparql file (optional if --template is used)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--also <path>","Additional vault to include in query (repeatable)",mJ,[]).option("--format <type>","Output format: table|json|csv|ntriples","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--timeout <duration>","Query timeout (e.g., 30s, 5000ms)","30s").option("--dry-run","Validate query syntax without executing (no vault loading)").option("--explain","Show optimized query plan").option("--stats","Show execution statistics").option("--no-optimize","Disable query optimization").option("--use-cache","Use persistent triple cache (faster vault loading)").option("--cache-ttl <seconds>","Query result cache TTL in seconds (default: 300)").option("--no-cache","Bypass query result cache").option("--template <name>","Use a predefined query template").option("--param <params>","Template parameters (format: key=value,key2=value2)").option("--strict","Fail on unresolved label-form wikilinks in property paths (sets EXOCORTEX_SPARQL_STRICT=1, Issue #3282)").action(async(n,e)=>{let t=e.output||"text";ee.setFormat(t);let r=process.env.EXOCORTEX_SPARQL_STRICT;e.strict&&(process.env.EXOCORTEX_SPARQL_STRICT="1");let i="";try{let s=Date.now(),o=e.timeout?pJ(e.timeout):fJ(),l=hJ(e.cacheTtl),c=e.cache!==!1;if(e.template){let D=new fy,G=e.param?D.parseParamString(e.param):{};if(i=D.applyTemplate(e.template,G),t==="text"){let te=D.getTemplate(e.template);console.log(`\u{1F4CB} Using template: ${e.template}`),Object.keys(G).length>0&&console.log(` Parameters: ${Object.entries(G).map(([q,ie])=>`${q}=${ie}`).join(", ")}`),console.log()}}else if(n)i=gJ(n);else throw new Le("Either a query argument or --template flag is required.",'exocortex sparql query "SELECT * WHERE { ?s ?p ?o }" or exocortex sparql query --template tasks-by-date --param date=2024-01-15');if(e.dryRun){await yJ(i,e,t);return}let u=(0,uu.resolve)(e.vault);if(c){let G=await new su().get(i,l);if(G!==null){let te=Date.now()-s;if(t==="json"){let q=De.success(G,{durationMs:te,itemCount:G.count||0,queryResultCacheHit:!0});console.log(JSON.stringify(q,null,2))}else{console.log(`\u{1F4E6} (cached) Query result loaded from cache in ${te}ms
611
+ `+n}a(ua,"injectExocortexPrefixes");function cu(n){return n.replace(eJ,(e,t,r,i,s)=>KD.has(r.toLowerCase())?`${r}:${i}`:e)}a(cu,"transformShorthandNotation");function fa(n){let e=new Map(n);for(let t of KD)e.delete(t);return e}a(fa,"filterOntologyPrefixes");var JD=require("path");var tJ=/\/assetspaces\/([^/]+)\/?$/;function py(n){let e=(0,JD.resolve)(n).replace(/\\/g,"/"),t=tJ.exec(e);return t?`assetspaces/${t[1]}`:""}a(py,"deriveSubjectIriPrefix");var $n=Q(ot());var rJ=new Map([["exo__","https://exocortex.my/ontology/exo#"],["ems__","https://exocortex.my/ontology/ems#"],["exocmd__","https://exocortex.my/ontology/exocmd#"],["ims__","https://exocortex.my/ontology/ims#"],["ztlk__","https://exocortex.my/ontology/ztlk#"],["ptms__","https://exocortex.my/ontology/ptms#"],["lit__","https://exocortex.my/ontology/lit#"],["inbox__","https://exocortex.my/ontology/inbox#"],["place__","https://exocortex.my/ontology/place#"],["exoob__","https://exocortex.my/ontology/exoob#"],["pn__","https://exocortex.my/ontology/pn#"],["period__","https://exocortex.my/ontology/period#"],["rdf__","http://www.w3.org/1999/02/22-rdf-syntax-ns#"],["rdfs__","http://www.w3.org/2000/01/rdf-schema#"],["owl__","http://www.w3.org/2002/07/owl#"]]);function nJ(n){let e=n.indexOf("__");if(e===-1)return null;let t=n.slice(0,e+2),r=n.slice(e+2),i=rJ.get(t);return!i||!r?null:i+r}a(nJ,"labelToOntologyIRI");var ZD="https://exocortex.my/ontology/exo#Instance_class",iJ="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",sJ="http://www.w3.org/2000/01/rdf-schema#label",oJ="https://exocortex.my/ontology/exo#Asset_label",aJ=/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i,lJ=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function my(n){let e=new Map;for(let i of n){if(!(i.subject instanceof $n.DomainIRI)||!(i.predicate instanceof $n.DomainIRI)||!(i.object instanceof $n.DomainLiteral)||i.predicate.value!==sJ&&i.predicate.value!==oJ)continue;let s=lJ.exec(i.subject.value);if(!s)continue;let o=s[1].toLowerCase();if(e.has(o))continue;let l=i.object.value.trim();if(/\s/.test(l))continue;let c=nJ(l);c&&e.set(o,c)}if(e.size===0)return n;let t=new Set,r=[];for(let i of n){if(!(i.subject instanceof $n.DomainIRI)||!(i.predicate instanceof $n.DomainIRI)||!(i.object instanceof $n.DomainLiteral)||i.predicate.value!==ZD)continue;let s=i.object.value.trim(),o=aJ.exec(s);if(!o)continue;let l=o[1].toLowerCase(),c=e.get(l);if(!c)continue;let f=`${i.subject.value}\0${c}`;if(t.has(f))continue;t.add(f);let d=new $n.DomainIRI(c);r.push(new $n.DomainTriple(i.subject,new $n.DomainIRI(ZD),d)),r.push(new $n.DomainTriple(i.subject,new $n.DomainIRI(iJ),d))}return r.length>0?n.concat(r):n}a(my,"resolveCrossVaultInstanceClassWikilinks");var cJ=300,eL=3e4,uJ="EXOCORTEX_SPARQL_TIMEOUT";function fJ(){let n=process.env[uJ];if(!n)return eL;try{let e=dJ(n);if(e!==null&&e>0)return e}catch{}return eL}a(fJ,"getDefaultTimeout");function dJ(n){let e=n.trim().toLowerCase();if(!e)return null;if(e.endsWith("ms")){let r=parseInt(e.slice(0,-2),10);return isNaN(r)||r<=0?null:r}if(e.endsWith("s")){let r=parseInt(e.slice(0,-1),10);return isNaN(r)||r<=0?null:r*1e3}let t=parseInt(e,10);return isNaN(t)||t<=0?null:t*1e3}a(dJ,"parseTimeoutSafe");function hJ(n){if(!n)return cJ;let e=parseInt(n.trim(),10);if(isNaN(e)||e<=0)throw new Le(`Invalid cache TTL: "${n}". Must be a positive number (seconds).`,'exocortex query --cache-ttl 600 "SELECT * WHERE { ?s ?p ?o }"');return e}a(hJ,"parseCacheTtl");function pJ(n){let e=n.trim().toLowerCase();if(e.endsWith("ms")){let r=parseInt(e.slice(0,-2),10);if(isNaN(r)||r<=0)throw new Le(`Invalid timeout format: "${n}". Value must be a positive number.`,'exocortex query --timeout "30s" or --timeout "5000ms"');return r}if(e.endsWith("s")){let r=parseInt(e.slice(0,-1),10);if(isNaN(r)||r<=0)throw new Le(`Invalid timeout format: "${n}". Value must be a positive number.`,'exocortex query --timeout "30s" or --timeout "5000ms"');return r*1e3}let t=parseInt(e,10);if(isNaN(t)||t<=0)throw new Le(`Invalid timeout format: "${n}". Use formats like "30s", "5000ms", or just a number (seconds).`,'exocortex query --timeout "30s" or --timeout "5000ms"');return t*1e3}a(pJ,"parseTimeout");async function sT(n,e,t=Date.now()){let r,i=new Promise((s,o)=>{r=setTimeout(()=>{let l=Date.now()-t;o(new fd(e,l))},e),r&&typeof r=="object"&&"unref"in r&&r.unref()});return Promise.race([n,i])}a(sT,"executeWithTimeout");function mJ(n,e){return e.concat([n])}a(mJ,"collectAlso");function rL(){return new ne("query").description("Execute SPARQL query against Obsidian vault").argument("[query]","SPARQL query string or path to .sparql file (optional if --template is used)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--also <path>","Additional vault to include in query (repeatable)",mJ,[]).option("--format <type>","Output format: table|json|csv|ntriples","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--timeout <duration>","Query timeout (e.g., 30s, 5000ms)","30s").option("--dry-run","Validate query syntax without executing (no vault loading)").option("--explain","Show optimized query plan").option("--stats","Show execution statistics").option("--no-optimize","Disable query optimization").option("--use-cache","Use persistent triple cache (faster vault loading)").option("--cache-ttl <seconds>","Query result cache TTL in seconds (default: 300)").option("--no-cache","Bypass query result cache").option("--template <name>","Use a predefined query template").option("--param <params>","Template parameters (format: key=value,key2=value2)").option("--strict","Fail on unresolved label-form wikilinks in property paths (sets EXOCORTEX_SPARQL_STRICT=1, Issue #3282)").action(async(n,e)=>{let t=e.output||"text";ee.setFormat(t);let r=process.env.EXOCORTEX_SPARQL_STRICT;e.strict&&(process.env.EXOCORTEX_SPARQL_STRICT="1");let i="";try{let s=Date.now(),o=e.timeout?pJ(e.timeout):fJ(),l=hJ(e.cacheTtl),c=e.cache!==!1;if(e.template){let D=new fy,G=e.param?D.parseParamString(e.param):{};if(i=D.applyTemplate(e.template,G),t==="text"){let te=D.getTemplate(e.template);console.log(`\u{1F4CB} Using template: ${e.template}`),Object.keys(G).length>0&&console.log(` Parameters: ${Object.entries(G).map(([q,ie])=>`${q}=${ie}`).join(", ")}`),console.log()}}else if(n)i=gJ(n);else throw new Le("Either a query argument or --template flag is required.",'exocortex query "SELECT * WHERE { ?s ?p ?o }" or exocortex query --template tasks-by-date --param date=2024-01-15');if(e.dryRun){await yJ(i,e,t);return}let u=(0,uu.resolve)(e.vault);if(c){let G=await new su().get(i,l);if(G!==null){let te=Date.now()-s;if(t==="json"){let q=De.success(G,{durationMs:te,itemCount:G.count||0,queryResultCacheHit:!0});console.log(JSON.stringify(q,null,2))}else{console.log(`\u{1F4E6} (cached) Query result loaded from cache in ${te}ms
612
612
  `);let q=G;q.type==="select"&&q.bindings?(console.log(`\u2705 Found ${q.bindings.length} result(s)
613
613
  `),SJ(q.bindings,e.format)):q.type==="construct"&&q.triples&&(console.log(`\u2705 Generated ${q.triples.length} triple(s)
614
- `),wJ(q.triples,e.format))}return}}if(!(0,fu.existsSync)(u))throw new le(u);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${u}...`);let f=Date.now(),d=e.also||[],h=e.useCache??!1,p=[],g=!1,_=!1;if(h&&d.length>0){let D=new iu(u,d.map(te=>(0,uu.resolve)(te))),G=await D.loadIfValid();G!==null?(p=G.triples,g=!0,_=!0,t==="text"&&console.log(`\u{1F680} Combined cache hit! Loaded ${p.length} triples from cross-vault index (${D.getAllVaultPaths().length} vaults).`)):t==="text"&&console.log("\u2139\uFE0F Combined cache miss (or invalid). Falling back to per-vault load. Run `exocortex sparql index --vault <primary> --also <...>` to build the cross-vault index.")}if(!_){let D=[],G=[];for(let te of d){let q=(0,uu.resolve)(te);if(!(0,fu.existsSync)(q))throw new le(q);let ie=py(q);D.push(new yt(q,{subjectIriPrefix:ie})),G.push({resolvedAlsoPath:q,subjectIriPrefix:ie})}if(h){let q=await new hi(u).loadOrBuild();p=q.triples,g=q.cacheHit,t==="text"&&g&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let te=new yt(u,{siblingAdapters:D});p=await new kt.NoteToRDFConverter(te).convertVault()}for(let te=0;te<D.length;te++){let q=D[te],{resolvedAlsoPath:ie,subjectIriPrefix:de}=G[te];t==="text"&&console.log(`\u{1F4E6} Loading additional vault: ${ie}...`);let K=await new kt.NoteToRDFConverter(q,void 0,{subjectIriPrefix:de}).convertVault();p=p.concat(K),t==="text"&&console.log(` \u2795 Added ${K.length} triples from ${ie}`)}if(d.length>0&&(p=my(p),al())){let te=new yt(u,{siblingAdapters:D}),q=Zg([te,...D]),ie=kt.IRICanonicalizer.canonicalize(p,q);p=ie.triples,t==="text"&&ie.remapCount>0&&console.log(` \u{1FA84} IRI canonicalization (Issue #3286): remapped ${ie.remapCount} triple(s) covering ${ie.uniqueRemapCount} distinct synth-A IRI(s)`)}}let E=new kt.InMemoryTripleStore;await E.addAll(p);let S=Date.now()-f;if(t==="text"){let D=g?" (from cache)":"",G=d.length>0?` (${d.length+1} vaults)`:"";console.log(`\u2705 Loaded ${p.length} triples in ${S}ms${D}${G}
614
+ `),wJ(q.triples,e.format))}return}}if(!(0,fu.existsSync)(u))throw new le(u);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${u}...`);let f=Date.now(),d=e.also||[],h=e.useCache??!1,p=[],g=!1,_=!1;if(h&&d.length>0){let D=new iu(u,d.map(te=>(0,uu.resolve)(te))),G=await D.loadIfValid();G!==null?(p=G.triples,g=!0,_=!0,t==="text"&&console.log(`\u{1F680} Combined cache hit! Loaded ${p.length} triples from cross-vault index (${D.getAllVaultPaths().length} vaults).`)):t==="text"&&console.log("\u2139\uFE0F Combined cache miss (or invalid). Falling back to per-vault load. Run `exocortex index --vault <primary> --also <...>` to build the cross-vault index.")}if(!_){let D=[],G=[];for(let te of d){let q=(0,uu.resolve)(te);if(!(0,fu.existsSync)(q))throw new le(q);let ie=py(q);D.push(new yt(q,{subjectIriPrefix:ie})),G.push({resolvedAlsoPath:q,subjectIriPrefix:ie})}if(h){let q=await new hi(u).loadOrBuild();p=q.triples,g=q.cacheHit,t==="text"&&g&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let te=new yt(u,{siblingAdapters:D});p=await new kt.NoteToRDFConverter(te).convertVault()}for(let te=0;te<D.length;te++){let q=D[te],{resolvedAlsoPath:ie,subjectIriPrefix:de}=G[te];t==="text"&&console.log(`\u{1F4E6} Loading additional vault: ${ie}...`);let K=await new kt.NoteToRDFConverter(q,void 0,{subjectIriPrefix:de}).convertVault();p=p.concat(K),t==="text"&&console.log(` \u2795 Added ${K.length} triples from ${ie}`)}if(d.length>0&&(p=my(p),al())){let te=new yt(u,{siblingAdapters:D}),q=Zg([te,...D]),ie=kt.IRICanonicalizer.canonicalize(p,q);p=ie.triples,t==="text"&&ie.remapCount>0&&console.log(` \u{1FA84} IRI canonicalization (Issue #3286): remapped ${ie.remapCount} triple(s) covering ${ie.uniqueRemapCount} distinct synth-A IRI(s)`)}}let E=new kt.InMemoryTripleStore;await E.addAll(p);let S=Date.now()-f;if(t==="text"){let D=g?" (from cache)":"",G=d.length>0?` (${d.length+1} vaults)`:"";console.log(`\u2705 Loaded ${p.length} triples in ${S}ms${D}${G}
615
615
  `),console.log("\u{1F50D} Parsing SPARQL query...")}let v=new kt.ExoQLParser;i=cu(i),i=ua(i);let A=fa(ca(u));for(let D of d){let G=fa(ca((0,uu.resolve)(D)));for(let[te,q]of G)A.has(te)||A.set(te,q)}A.size>0&&v.setVaultPrefixes(A);let P=v.parse(i);if(P.type==="update"){t==="text"&&console.log("\u{1F504} Executing SPARQL UPDATE...");let D=Date.now(),G=new kt.UpdateExecutor(E),te=await sT(G.execute(P),o,D),q=Date.now()-D,ie=Date.now()-s;if(t==="json"){let de=De.success({query:i,type:"update",results:te},{durationMs:ie,itemCount:te.length,loadDurationMs:S,execDurationMs:q,triplesScanned:p.length,cacheHit:g});console.log(JSON.stringify(de,null,2))}else EJ(te,e.format),console.log(),console.log("\u26A0\uFE0F Changes applied to in-memory store only (not persisted to vault files)"),e.stats&&(console.log(`
616
616
  \u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${S}ms${g?" (from cache)":""}`),console.log(` Query execution: ${q}ms`),console.log(` Total time: ${ie}ms`),console.log(` Triples scanned: ${p.length}`));return}t==="text"&&console.log("\u{1F504} Translating to algebra...");let j=new kt.ExoQLAlgebraTranslator().translate(P);if(!e.noOptimize&&j.type!=="construct")j=new kt.AlgebraOptimizer().optimize(j);else if(!e.noOptimize&&j.type==="construct"){let D=new kt.AlgebraOptimizer,G=j;j={...G,where:D.optimize(G.where)}}if(e.explain&&t==="text"){console.log("\u{1F4CA} Query Plan:");let D=new kt.AlgebraSerializer;if(j.type==="construct"){let G=j;console.log("CONSTRUCT Template:"),console.log(" (template patterns)"),console.log("WHERE:"),console.log(D.toString(G.where))}else console.log(D.toString(j));console.log()}let ye=Date.now(),Ne=new kt.ExoQLQueryExecutor(E);typeof Ne.setTimeout=="function"&&Ne.setTimeout(o);let N=t==="text"?new ly("Executing query",{delayMs:2e3}):null;if(Ne.isConstructQuery(j)){N?.start();let D=await sT(Ne.executeConstruct(j),o,ye),G=Date.now()-ye;N?.stop();let te=Date.now()-s;if(c){let q=new nu,ie={type:"construct",count:D.length,triples:JSON.parse(q.formatJson(D))};await new su().set(i,ie,l)}if(t==="json"){let q=new nu,ie={query:i,count:D.length,triples:JSON.parse(q.formatJson(D))},de=De.success(ie,{durationMs:te,itemCount:D.length,loadDurationMs:S,execDurationMs:G,triplesScanned:p.length,cacheHit:g,queryResultCacheHit:!1});console.log(JSON.stringify(de,null,2))}else console.log(`\u2705 Generated ${D.length} triple(s) in ${G}ms
617
617
  `),D.length>0?bJ(D,e.format):console.log("No triples generated."),e.stats&&(console.log(`
@@ -657,7 +657,7 @@ Available prefixes: ${u}`,this.wellKnownPrefixes[r]&&l.push(`Add: PREFIX ${r}: <
657
657
  \u26A0\uFE0F Found ${i.length} file(s) with IRI issues:
658
658
  `);for(let s of i)console.log(` \u274C ${s.path}`),console.log(` ${s.reason}`);console.log(`
659
659
  \u{1F4DD} To fix these issues:`),console.log(" - Rename files to remove spaces and special characters"),console.log(" - Use dashes (-) or underscores (_) instead of spaces"),console.log(" - Avoid angle brackets (<>) and other special characters"),console.log(`
660
- \u{1F4A1} Run 'exocortex sparql index --strict' to fail on first issue`)}i.length>0&&(process.exitCode=1)}catch(t){ee.handle(t)}})}a(iZ,"validateIriCommand");function LL(){let n=new ne("validate").description("Validate vault files (IRI checks, schema linting, frontmatter shapes)");return n.addCommand(iZ()),n.addCommand(AL()),n.addCommand(OL()),n}a(LL,"validateCommand");var NL=require("fs"),kL=require("path"),Cr=Q(ot());function ML(){return new ne("classes").alias("describe-class").description("List RDF classes in vault, or describe a class (predicates + counts). Alias `describe-class` is provided per #3043 RFC \xA7B (schema introspection).").argument("[class-name]","Optional class name to show details (e.g., ems__Task)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: table|json","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--use-cache","Use persistent cache (faster for repeated queries)").action(async(n,e)=>{let t=e.output||"text";ee.setFormat(t);try{let r=Date.now(),i=(0,kL.resolve)(e.vault);if(!(0,NL.existsSync)(i))throw new le(i);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${i}...`);let s=e.useCache??!1,o,l=!1;if(s){let d=await new hi(i).loadOrBuild();o=d.triples,l=d.cacheHit,t==="text"&&l&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let f=new yt(i);o=await new Cr.NoteToRDFConverter(f).convertVault()}let c=new Cr.InMemoryTripleStore;await c.addAll(o);let u=Date.now()-r;if(t==="text"){let f=l?" (from cache)":"";console.log(`\u2705 Loaded ${o.length} triples in ${u}ms${f}
660
+ \u{1F4A1} Run 'exocortex index --strict' to fail on first issue`)}i.length>0&&(process.exitCode=1)}catch(t){ee.handle(t)}})}a(iZ,"validateIriCommand");function LL(){let n=new ne("validate").description("Validate vault files (IRI checks, schema linting, frontmatter shapes)");return n.addCommand(iZ()),n.addCommand(AL()),n.addCommand(OL()),n}a(LL,"validateCommand");var NL=require("fs"),kL=require("path"),Cr=Q(ot());function ML(){return new ne("classes").alias("describe-class").description("List RDF classes in vault, or describe a class (predicates + counts). Alias `describe-class` is provided per #3043 RFC \xA7B (schema introspection).").argument("[class-name]","Optional class name to show details (e.g., ems__Task)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: table|json","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--use-cache","Use persistent cache (faster for repeated queries)").action(async(n,e)=>{let t=e.output||"text";ee.setFormat(t);try{let r=Date.now(),i=(0,kL.resolve)(e.vault);if(!(0,NL.existsSync)(i))throw new le(i);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${i}...`);let s=e.useCache??!1,o,l=!1;if(s){let d=await new hi(i).loadOrBuild();o=d.triples,l=d.cacheHit,t==="text"&&l&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let f=new yt(i);o=await new Cr.NoteToRDFConverter(f).convertVault()}let c=new Cr.InMemoryTripleStore;await c.addAll(o);let u=Date.now()-r;if(t==="text"){let f=l?" (from cache)":"";console.log(`\u2705 Loaded ${o.length} triples in ${u}ms${f}
661
661
  `)}n?await oZ(c,n,e,t):await sZ(c,e,t)}catch(r){ee.handle(r)}})}a(ML,"classesCommand");async function sZ(n,e,t){let s=new Cr.ExoQLParser().parse(`
662
662
  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
663
663
  SELECT ?class (COUNT(?instance) AS ?count)
@@ -815,7 +815,7 @@ Next steps:
815
815
  `),process.stdout.write(` File: ${e.file}
816
816
  `),process.stdout.write(` Commit: ${e.sha}
817
817
  `),process.stdout.write(` URL: ${e.url}
818
- `)),process.exit(0)}catch(e){let t=e instanceof Error?e:new Error(String(e)),r=new vu;t.message=r.redact(t.message),t.stack&&(t.stack=r.redact(t.stack)),ee.handle(t)}})}a(Yee,"restPushCommand");function ok(n){let e=new ne;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.74.2"),e.addCommand(AN()),e.addCommand(kN()),e.addCommand(rL()),e.addCommand(sL()),e.addCommand(LL()),e.addCommand(cL()),e.addCommand(uL()),e.addCommand(mL()),e.addCommand(ML()),e.addCommand(WL()),e.addCommand(HL()),e.addCommand(XL()),e.addCommand(YL()),e.addCommand(aN()),e.addCommand(lN()),e.addCommand(mN()),e.addCommand(IN()),e.addCommand(WN()),e.addCommand(KN()),e.addCommand(JN()),e.addCommand(ek()),e.addCommand(sk()),e}a(ok,"createProgram");ok().parse();0&&(module.exports={createProgram});
818
+ `)),process.exit(0)}catch(e){let t=e instanceof Error?e:new Error(String(e)),r=new vu;t.message=r.redact(t.message),t.stack&&(t.stack=r.redact(t.stack)),ee.handle(t)}})}a(Yee,"restPushCommand");function ok(n){let e=new ne;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.74.3"),e.addCommand(AN()),e.addCommand(kN()),e.addCommand(rL()),e.addCommand(sL()),e.addCommand(LL()),e.addCommand(cL()),e.addCommand(uL()),e.addCommand(mL()),e.addCommand(ML()),e.addCommand(WL()),e.addCommand(HL()),e.addCommand(XL()),e.addCommand(YL()),e.addCommand(aN()),e.addCommand(lN()),e.addCommand(mN()),e.addCommand(IN()),e.addCommand(WN()),e.addCommand(KN()),e.addCommand(JN()),e.addCommand(ek()),e.addCommand(sk()),e}a(ok,"createProgram");ok().parse();0&&(module.exports={createProgram});
819
819
  /*! Bundled license information:
820
820
 
821
821
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitelev/exocortex-cli",
3
- "version": "16.74.2",
3
+ "version": "16.74.3",
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": {