@kitelev/exocortex-cli 16.241.11 → 16.241.13
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 +4 -4
- 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.241.
|
|
2
|
+
// @kitelev/exocortex-cli v16.241.13
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
@@ -325,7 +325,7 @@ To resolve:
|
|
|
325
325
|
\u2022 Check service initialization parameters
|
|
326
326
|
\u2022 Verify all required dependencies are available
|
|
327
327
|
\u2022 Review service logs for detailed error information
|
|
328
|
-
\u2022 Contact support if the issue persists`}};R_.ServiceError=HI});var gj=T(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.ServiceError=Fr.ResourceExhaustedError=Fr.NotFoundError=Fr.PermissionError=Fr.StateTransitionError=Fr.NetworkError=Fr.ValidationError=Fr.ApplicationError=Fr.ErrorCode=void 0;var tie=wo();Object.defineProperty(Fr,"ErrorCode",{enumerable:!0,get:a(function(){return tie.ErrorCode},"get")});var rie=Eo();Object.defineProperty(Fr,"ApplicationError",{enumerable:!0,get:a(function(){return rie.ApplicationError},"get")});var nie=lj();Object.defineProperty(Fr,"ValidationError",{enumerable:!0,get:a(function(){return nie.ValidationError},"get")});var iie=uj();Object.defineProperty(Fr,"NetworkError",{enumerable:!0,get:a(function(){return iie.NetworkError},"get")});var sie=fj();Object.defineProperty(Fr,"StateTransitionError",{enumerable:!0,get:a(function(){return sie.StateTransitionError},"get")});var oie=dj();Object.defineProperty(Fr,"PermissionError",{enumerable:!0,get:a(function(){return oie.PermissionError},"get")});var aie=pj();Object.defineProperty(Fr,"NotFoundError",{enumerable:!0,get:a(function(){return aie.NotFoundError},"get")});var cie=hj();Object.defineProperty(Fr,"ResourceExhaustedError",{enumerable:!0,get:a(function(){return cie.ResourceExhaustedError},"get")});var lie=mj();Object.defineProperty(Fr,"ServiceError",{enumerable:!0,get:a(function(){return lie.ServiceError},"get")})});var YI=T(C_=>{"use strict";Object.defineProperty(C_,"__esModule",{value:!0});C_.ShapeRegistry=void 0;var KI=class{static{a(this,"ShapeRegistry")}constructor(){this.shapes=new Map}get(e){return this.shapes.get(e)}register(e){this.shapes.set(e.propertyIRI,e)}getAll(){return Array.from(this.shapes.values())}get size(){return this.shapes.size}};C_.ShapeRegistry=KI});var yj=T(vo=>{"use strict";var uie=vo&&vo.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),fie=vo&&vo.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),XI=vo&&vo.__importStar||(function(){var r=a(function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[n.length]=i);return n},r(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),i=0;i<n.length;i++)n[i]!=="default"&&uie(t,e,n[i]);return fie(t,e),t}})();Object.defineProperty(vo,"__esModule",{value:!0});vo.ShapeLoader=void 0;var QI=YI(),js=Le(),id=Xe(),_r=Yt(),die=Ky(),x_="http://www.w3.org/ns/shacl#",vCe=[["exo__",_r.Namespace.EXO],["ems__",_r.Namespace.EMS],["exocmd__",_r.Namespace.EXOCMD],["ims__",_r.Namespace.IMS],["ztlk__",_r.Namespace.ZTLK],["ptms__",_r.Namespace.PTMS],["lit__",_r.Namespace.LIT],["inbox__",_r.Namespace.INBOX],["pmbok__",_r.Namespace.PMBOK]],Ca=class r{static{a(this,"ShapeLoader")}static async loadFromVaultFS(e){let{readdir:t,readFile:n}=await Promise.resolve().then(()=>XI(require("fs/promises"))),i=await Promise.resolve().then(()=>XI(require("path"))),s=new QI.ShapeRegistry,o={classEdges:[],candidates:[],uidToLabel:new Map};await r.scanDir(e,o,{readdir:t,readFile:n,path:i});let c=r.propertyClassKeysFromEdges(o.classEdges);for(let l of o.candidates)try{r.registerCandidate(l,s,c,i,o.uidToLabel)}catch{}return s}static async loadFromRDFGraph(e){let t=new QI.ShapeRegistry,n=_r.Namespace.EXO,i=_r.Namespace.RDFS,s=_r.Namespace.RDF,o=await r.buildUidClassIndex(e),c=await r.collectPropertyClassIRIs(e,o),l=await Promise.all([...c].map(async f=>{try{return await e.match(void 0,s.term("type"),new js.IRI(f))}catch{return[]}})),u=new Set;for(let f of l.flat())f.subject instanceof js.IRI&&u.add(f.subject.value);for(let f of u){let d;try{d=new js.IRI(f)}catch{continue}let[p,h,g,m,b,_,E,I,w]=await Promise.all([e.match(d,i.term("domain"),void 0),e.match(d,n.term("Property_domain"),void 0),e.match(d,i.term("range"),void 0),e.match(d,n.term("Property_range"),void 0),e.match(d,n.term("Property_cardinality"),void 0),e.match(d,n.term("Property_severity"),void 0),e.match(d,n.term("Asset_label"),void 0),e.match(d,i.term("label"),void 0),e.match(d,n.term("Property_minCount"),void 0)]),S=[...E,...I],R=[...p,...h],P=[...g,...m];if(R.length===0)continue;let x=null;for(let V of S)if(V.object instanceof id.Literal&&(x=r.labelToIRI(V.object.value),x))break;if(!x)continue;let M=await Promise.all(R.map(async V=>V.object instanceof js.IRI?await r.resolveClassIRI(V.object.value,e,o):null)),U=Array.from(new Set(M.filter(V=>V!==null))),D=await Promise.all(P.map(async V=>V.object instanceof js.IRI?await r.resolveClassIRI(V.object.value,e,o):V.object instanceof id.Literal?r.datatypeRangeToIRI(V.object.value):null)),Q=Array.from(new Set(D.filter(V=>V!==null))),ue=r.cardinalityFromIRI(b[0]?.object instanceof js.IRI?b[0].object.value:void 0),$=r.severityFromValue(_[0]?.object instanceof id.Literal||_[0]?.object instanceof js.IRI?_[0].object.value:void 0),le=w[0]?.object,H=le instanceof id.Literal?parseInt(le.value,10):NaN,ie=isNaN(H)?void 0:H;t.register({propertyIRI:x,domain:U,range:Q.length>0?Q:void 0,cardinality:ue,severity:$,minCount:ie})}return t}static async loadFromShapeJSON(e){let{readFile:t}=await Promise.resolve().then(()=>XI(require("fs/promises"))),n=await t(e,"utf-8"),i=JSON.parse(n),s=new QI.ShapeRegistry;for(let o of Object.values(i.shapes))s.register(o);return s}static extractUidFromFileIRI(e){let t=r.FILE_IRI_UID_RE.exec(e);return t?t[1].toLowerCase():null}static async buildUidClassIndex(e){let t=_r.Namespace.RDFS,n=_r.Namespace.EXO,[i,s]=await Promise.all([e.match(void 0,t.term("label"),void 0),e.match(void 0,n.term("Asset_label"),void 0)]),o=new Map;for(let c of[...i,...s]){if(!(c.subject instanceof js.IRI)||!(c.object instanceof id.Literal))continue;let l=r.extractUidFromFileIRI(c.subject.value);if(!l||o.has(l))continue;let u=c.object.value.trim();if(/\s/.test(u))continue;let f=r.labelToIRI(u);f&&o.set(l,f)}return o}static async collectPropertyClassIRIs(e,t){let n=_r.Namespace.EXO,i=_r.Namespace.RDFS,[s,o]=await Promise.all([e.match(void 0,n.term("Class_superClass"),void 0),e.match(void 0,i.term("subClassOf"),void 0)]),c=new Map,l=a(async p=>{let h=c.get(p);return h===void 0&&(h=await r.resolveClassIRI(p,e,t),c.set(p,h)),h},"canon"),u=new Map;for(let p of[...s,...o]){if(!(p.subject instanceof js.IRI)||!(p.object instanceof js.IRI))continue;let[h,g]=await Promise.all([l(p.subject.value),l(p.object.value)]);if(!h||!g||h===g)continue;let m=u.get(g)??new Set;m.add(h),u.set(g,m)}let f=new Set([n.term("Property").value,n.term("ObjectProperty").value]),d=[...f];for(;d.length>0;){let p=d.shift();for(let h of u.get(p)??[])f.has(h)||(f.add(h),d.push(h))}return f}static async resolveClassIRI(e,t,n){if(e.startsWith("https://exocortex.my/ontology/")||e.startsWith("http://www.w3.org/"))return e;let i;try{i=new js.IRI(e)}catch{return null}let s=_r.Namespace.RDFS,o=_r.Namespace.EXO,[c,l]=await Promise.all([t.match(i,s.term("label"),void 0),t.match(i,o.term("Asset_label"),void 0)]);for(let u of[...c,...l])if(u.object instanceof id.Literal){let f=r.labelToIRI(u.object.value);if(f)return f}if(n){let u=r.extractUidFromFileIRI(e);if(u){let f=n.get(u);if(f)return f}}return e}static propertyClassKeysFromEdges(e){let t=["exo__Property",r.EXO_PROPERTY_UID,"exo__ObjectProperty",r.EXO_OBJECT_PROPERTY_UID],n=new Set(t),i=[...t];for(;i.length>0;){let s=i.shift();for(let o of e)if(o.parentKeys.includes(s)&&!o.childKeys.some(c=>n.has(c)))for(let c of o.childKeys)n.add(c),i.push(c)}return n}static wikilinkClassKeys(e){let t=r.extractWikilinkRef(e);if(!t)return[];let n=[t.trim()];for(let i of t.split("|")){let s=i.trim();s.length>0&&n.push(s)}return n}static async scanDir(e,t,n){let i;try{i=await n.readdir(e,{withFileTypes:!0})}catch{return}i.sort((s,o)=>s.name<o.name?-1:s.name>o.name?1:0);for(let s of i){let o=n.path.join(e,s.name);if(s.isDirectory())await r.scanDir(o,t,n);else if(s.isFile()&&s.name.endsWith(".md"))try{await r.collectFile(o,t,n.readFile,n.path)}catch{}}}static async collectFile(e,t,n,i){let s;try{s=await n(e,"utf-8")}catch{return}let o=r.parseFrontmatter(s);if(!o)return;r.indexUidLabel(e,o,t.uidToLabel,i);let c=r.asArray(o.exo__Class_superClass);if(c.length>0){let l=[i.basename(e,".md")],u=o.exo__Asset_uid;typeof u=="string"&&u.trim().length>0&&l.push(u.trim().replace(/^["']|["']$/g,""));let f=o.exo__Asset_label;typeof f=="string"&&f.trim().length>0&&l.push(f.trim().replace(/^["']|["']$/g,"")),t.classEdges.push({childKeys:l,parentKeys:c.flatMap(d=>r.wikilinkClassKeys(d))})}r.asArray(o.exo__Property_domain).length>0&&t.candidates.push({filePath:e,fm:o})}static indexUidLabel(e,t,n,i){let s=t.exo__Asset_label;if(typeof s!="string")return;let o=s.trim().replace(/^["']|["']$/g,"");if(o.length===0||/\s/.test(o)||!_r.Namespace.fromPropertyKey(o))return;let c=t.exo__Asset_uid,l=[typeof c=="string"?c.trim().replace(/^["']|["']$/g,""):"",i.basename(e,".md")];for(let u of l){if(!r.BARE_UID_RE.test(u))continue;let f=u.toLowerCase();n.has(f)||n.set(f,o)}}static registerCandidate(e,t,n,i,s){let{filePath:o,fm:c}=e;if(!r.asArray(c.exo__Instance_class).some(x=>r.wikilinkClassKeys(x).some(M=>n.has(M))))return;let f=null,d=c.exo__Asset_label;if(typeof d=="string"&&d.trim().length>0)f=d.trim();else{let x=i.basename(o,".md");_r.Namespace.fromPropertyKey(x)&&(f=x)}if(!f)return;let p=r.labelToIRI(f);if(!p)return;let h=c.exo__Property_domain,g=c.exo__Property_range,m=c.exo__Property_cardinality,b=c.exo__Property_severity,_=c.exo__Property_minCount,E=r.asArray(h).map(x=>r.wikilinkToIRI(x,s)).filter(x=>x!==null);if(E.length===0)return;let I=r.asArray(g).map(x=>r.wikilinkToIRI(x,s)).filter(x=>x!==null),w=r.cardinalityFromLabel(typeof m=="string"?m:void 0),S=r.severityFromValue(typeof b=="string"?b:void 0),R=typeof _=="string"?parseInt(_,10):void 0,P=R!==void 0&&!isNaN(R)?R:void 0;t.register({propertyIRI:p,domain:E,range:I.length>0?I:void 0,cardinality:w,severity:S,minCount:P})}static parseFrontmatter(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!t)return null;let n=t[1],i={},s=n.split(/\r?\n/),o=null,c=null;for(let l of s){let u=/^ {2}- (.*)$/.exec(l);if(u){o&&c&&c.push(u[1].trim());continue}o&&c&&(i[o]=c,o=null,c=null);let f=/^([^:]+):\s*(.*)$/.exec(l);if(!f)continue;let d=f[1].trim(),p=f[2].trim();p===""?(o=d,c=[]):i[d]=p}return o&&c&&(i[o]=c),i}static labelToIRI(e){let t=_r.Namespace.fromPropertyKey(e);if(!t)return null;try{return t.namespace.term(t.localName).value}catch{return null}}static extractWikilinkRef(e){let t=e.replace(/^["']|["']$/g,""),n=/\[\[([^\]]+)\]\]/.exec(t);return n?n[1]:t}static wikilinkToIRI(e,t){let n=r.extractWikilinkRef(e);if(!n)return null;let i=n.split("|"),s=i.length>1?[i[1],i[0]]:[i[0]];for(let c of s){let l=r.labelToIRI(c.trim());if(l)return l}let o=r.datatypeRangeToIRI(n);if(o)return o;if(n.startsWith("sh:"))return x_+n.substring(3);if(t)for(let c of s){let l=t.get(c.trim().toLowerCase());if(l===void 0)continue;let u=r.labelToIRI(l);if(u)return u}return null}static datatypeRangeToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?e:(0,die.xsdDatatypeIRI)(e)}static asArray(e){return Array.isArray(e)?e.map(String):typeof e=="string"?[e]:[]}static cardinalityFromIRI(e){if(e){if(e.endsWith("PropertyCardinalitySingle"))return"Single";if(e.endsWith("PropertyCardinalityMultiple"))return"Multiple";if(e.includes(r.CARDINALITY_SINGLE_UID))return"Single";if(e.includes(r.CARDINALITY_MULTIPLE_UID))return"Multiple"}}static cardinalityFromLabel(e){if(!e)return;let t=r.extractWikilinkRef(e)??e,n=t.split("|").pop()??t;if(n.includes("Single"))return"Single";if(n.includes("Multiple"))return"Multiple";if(t.includes(r.CARDINALITY_SINGLE_UID))return"Single";if(t.includes(r.CARDINALITY_MULTIPLE_UID))return"Multiple"}static severityFromValue(e){return!e||e.includes("Violation")||e===x_+"Violation"?"sh:Violation":e.includes("Warning")||e===x_+"Warning"?"sh:Warning":e.includes("Info")||e===x_+"Info"?"sh:Info":"sh:Violation"}};vo.ShapeLoader=Ca;Ca.FILE_IRI_UID_RE=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;Ca.BARE_UID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;Ca.EXO_PROPERTY_UID="38277bfa-d7f9-4a75-b856-b23276ab0db3";Ca.EXO_OBJECT_PROPERTY_UID="9a1cf31c-9d41-4ef3-9023-584a8d087d16";Ca.CARDINALITY_SINGLE_UID="c93c4b2f-b43d-4cc9-8dd0-31514d608da2";Ca.CARDINALITY_MULTIPLE_UID="59a37aa7-ffbe-4e0d-ba60-06ae370d880f"});var eR=T(sd=>{"use strict";Object.defineProperty(sd,"__esModule",{value:!0});sd.ShapeRegistry=void 0;sd.extractUidFromIRI=ZI;sd.validate=Iie;var pie=Le(),JI=class{static{a(this,"ShapeRegistry")}constructor(e=[],t="https://exocortex.my/ontology/exo#Instance_class"){this.shapeMap=new Map(e.map(n=>[n.propertyIRI,n])),this.typePredicateIRI=t}getShape(e){return this.shapeMap.get(e)}getAllShapes(){return Array.from(this.shapeMap.values())}hasShape(e){return this.shapeMap.has(e)}};sd.ShapeRegistry=JI;var hie="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",mie=["http://www.w3.org/2001/XMLSchema#","http://www.w3.org/1999/02/22-rdf-syntax-ns#","http://www.w3.org/2000/01/rdf-schema#","http://www.w3.org/2002/07/owl#","http://www.w3.org/ns/shacl#","http://www.w3.org/2004/02/skos/core#","http://purl.org/dc/elements/1.1/","http://purl.org/dc/terms/","http://xmlns.com/foaf/0.1/","https://schema.org/","https://exocortex.my/ontology/xsd#","https://exocortex.my/ontology/rdf#","https://exocortex.my/ontology/rdfs#","https://exocortex.my/ontology/owl#","https://exocortex.my/ontology/skos#"];function gie(r){return mie.some(e=>r.startsWith(e))}a(gie,"isExternalOntologyIRI");var Sj=["http://www.w3.org/2001/XMLSchema#","https://exocortex.my/ontology/xsd#"];function yie(r){return Sj.some(e=>r.startsWith(e))}a(yie,"isXSDDatatypeIRI");function bie(r){for(let e of Sj)if(r.startsWith(e))return r.substring(e.length);return null}a(bie,"xsdLocalName");var _ie="http://www.w3.org/2001/XMLSchema#decimal",Sie="http://www.w3.org/2001/XMLSchema#integer",bj="http://www.w3.org/2001/XMLSchema#string",Vh=/^[+-]?\d+$/,Gh=/^\+?\d+$/,wie=/^[+-]?(\d+(\.\d*)?|\.\d+)$/,_j=/^([+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?|[+-]?INF|NaN)$/,Eie={integer:Vh,long:Vh,int:Vh,short:Vh,byte:Vh,nonNegativeInteger:Gh,unsignedLong:Gh,unsignedInt:Gh,unsignedShort:Gh,unsignedByte:Gh,positiveInteger:/^\+?0*[1-9]\d*$/,nonPositiveInteger:/^(-\d+|\+?0+)$/,negativeInteger:/^-0*[1-9]\d*$/,decimal:wie,float:_j,double:_j,gYear:/^-?\d{4,}(Z|[+-]\d{2}:\d{2})?$/},vie=/^(true|false)$/;function Tie(r,e,t){if(e===t)return!0;let n=bie(t);if(n===null)return!1;if(e===_ie||e===Sie){let i=Eie[n];return i!==void 0&&i.test(r)}return e===bj&&n==="boolean"?vie.test(r):e===bj&&n==="anyURI"?pie.IRI.isValidIRI(r):!1}a(Tie,"literalConformsToDatatype");var Aie=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function ZI(r){let e=Aie.exec(r);return e?e[1].toLowerCase():null}a(ZI,"extractUidFromIRI");function Iie(r,e,t,n){let i=new Map,s=new Map;for(let l of r){let{subject:u,predicate:f,object:d}=l;if(u.type!=="iri"||f.type!=="iri"||d.type!=="iri"&&d.type!=="literal")continue;let p=u.value,h=f.value,g=d;if(h===e.typePredicateIRI||h===hie){if(g.type==="iri"){let b=i.get(p)??[];b.push(g.value),i.set(p,b);let _=ZI(p);if(_){let E=`uid:${_}`,I=i.get(E)??[];I.push(g.value),i.set(E,I)}}}else{let b=s.get(p);b||(b=new Map,s.set(p,b));let _=b.get(h)??[];_.push(g),b.set(h,_)}}let o=[],c=new Set([...i.keys(),...s.keys()]);for(let l of c){if(l.startsWith("uid:"))continue;let u=i.get(l)??[],f=s.get(l)??new Map;for(let d of e.getAllShapes()){if(!(d.domain.length===0||d.domain.some(g=>u.some(m=>m===g||t.isSubClassOf(m,g)))))continue;let h=f.get(d.propertyIRI)??[];if(d.minCount!==void 0&&d.minCount>0&&h.length<d.minCount){o.push({focusNode:l,propertyPath:d.propertyIRI,severity:d.severity,constraint:"minCount",message:d.message??`sh:minCount violation: expected at least ${d.minCount} value(s) for <${d.propertyIRI}>`});continue}if(h.length!==0){if(d.cardinality==="Single"&&h.length>1){o.push({focusNode:l,propertyPath:d.propertyIRI,severity:d.severity,constraint:"maxCount",message:d.message??`sh:maxCount violation: expected at most 1 value for <${d.propertyIRI}>, got ${h.length}`});continue}if(d.range&&d.range.length>0){for(let g of h)if(g.type==="iri"){if(gie(g.value))continue;let m=i.get(g.value)??[];if(m.length===0){let _=ZI(g.value);_&&(m=i.get(`uid:${_}`)??[])}if(!d.range.some(_=>m.some(E=>E===_||t.isSubClassOf(E,_)))){let _=m.length===0;o.push({focusNode:l,propertyPath:d.propertyIRI,severity:_?"sh:Warning":d.severity,constraint:"class",message:_?`sh:class unresolvable-ref: <${g.value}> has no resolvable type in this vault (cross-vault, symbolic, or external reference); not validated against ${d.range.join(" | ")}`:d.message??`sh:class violation: <${g.value}> does not conform to expected class ${d.range.join(" | ")}`,actualValue:g.value,expectedRange:d.range.join(" | ")})}}else if(g.type==="literal"){let m=d.range.filter(E=>yie(E));if(m.length===0)continue;let b=g.datatype??"http://www.w3.org/2001/XMLSchema#string";m.some(E=>Tie(g.value,b,E))||o.push({focusNode:l,propertyPath:d.propertyIRI,severity:d.severity,constraint:"datatype",message:d.message??`sh:datatype violation: literal "${g.value}" has datatype <${b}>, expected ${m.join(" | ")}`,actualValue:g.value,expectedRange:m.join(" | ")})}}}}}if(n?.closedWorldMode)for(let l of c){let u=s.get(l)??new Map;for(let f of u.keys())e.hasShape(f)||o.push({focusNode:l,propertyPath:f,severity:"sh:Warning",constraint:"unknown-property",message:`Unknown property: <${f}> has no registered shape`})}return o.sort((l,u)=>{let f=l.focusNode.localeCompare(u.focusNode);return f!==0?f:l.propertyPath.localeCompare(u.propertyPath)}),{conforms:!o.some(l=>l.severity==="sh:Violation"),violations:o}}a(Iie,"validate")});var wj=T(O_=>{"use strict";Object.defineProperty(O_,"__esModule",{value:!0});O_.ApplicationErrorHandler=void 0;var tR=Eo(),Rie=wo(),Cie=Gl(),rR=class{static{a(this,"ApplicationErrorHandler")}constructor(e={},t,n){this.logger=t,this.notifier=n,this.telemetryHooks=new Set,this.retryConfig={maxRetries:e.maxRetries??3,initialDelayMs:e.initialDelayMs??1e3,backoffMultiplier:e.backoffMultiplier??2,maxDelayMs:e.maxDelayMs??1e4}}handle(e,t){let n=this.ensureApplicationError(e,t);return this.notifier&&this.notifier.error(n.message),this.callTelemetryHooks("onError",n,t),this.formatError(n)}async executeWithRetry(e,t){let n,i=0;for(;i<=this.retryConfig.maxRetries;)try{return await e()}catch(s){if(n=this.ensureApplicationError(s,t),!n.retriable||i>=this.retryConfig.maxRetries)throw this.callTelemetryHooks("onError",n,t),i>=this.retryConfig.maxRetries&&n.retriable&&this.callTelemetryHooks("onRetryExhausted",n,i+1),n;let o=this.calculateDelay(i);this.callTelemetryHooks("onRetry",n,i+1,o),this.logger?.debug(`Retrying after ${o}ms (attempt ${i+1}/${this.retryConfig.maxRetries})`),await this.sleep(o),i++}throw n}registerTelemetryHook(e){this.telemetryHooks.add(e)}unregisterTelemetryHook(e){this.telemetryHooks.delete(e)}ensureApplicationError(e,t){if(e instanceof tR.ApplicationError){if(t){let i=e,s={...e.context,...t};return new class extends tR.ApplicationError{constructor(){super(...arguments),this.code=i.code,this.retriable=i.retriable,this.guidance=i.guidance}}(e.message,s)}return e}return new class extends tR.ApplicationError{static{a(this,"UnknownError")}constructor(s,o){super(s,{originalError:o.name,...t}),this.code=Rie.ErrorCode.UNKNOWN_ERROR,this.retriable=!1,this.guidance="An unexpected error occurred"}}(e.message,e)}formatError(e){let t=[];return t.push(`\u274C ${e.name}: ${e.message}`),e.guidance&&t.push(`\u{1F4A1} ${e.guidance}`),e.context&&Object.keys(e.context).length>0&&t.push(`Context: ${JSON.stringify(e.context,null,2)}`),t.join(`
|
|
328
|
+
\u2022 Contact support if the issue persists`}};R_.ServiceError=HI});var gj=T(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.ServiceError=Fr.ResourceExhaustedError=Fr.NotFoundError=Fr.PermissionError=Fr.StateTransitionError=Fr.NetworkError=Fr.ValidationError=Fr.ApplicationError=Fr.ErrorCode=void 0;var tie=wo();Object.defineProperty(Fr,"ErrorCode",{enumerable:!0,get:a(function(){return tie.ErrorCode},"get")});var rie=Eo();Object.defineProperty(Fr,"ApplicationError",{enumerable:!0,get:a(function(){return rie.ApplicationError},"get")});var nie=lj();Object.defineProperty(Fr,"ValidationError",{enumerable:!0,get:a(function(){return nie.ValidationError},"get")});var iie=uj();Object.defineProperty(Fr,"NetworkError",{enumerable:!0,get:a(function(){return iie.NetworkError},"get")});var sie=fj();Object.defineProperty(Fr,"StateTransitionError",{enumerable:!0,get:a(function(){return sie.StateTransitionError},"get")});var oie=dj();Object.defineProperty(Fr,"PermissionError",{enumerable:!0,get:a(function(){return oie.PermissionError},"get")});var aie=pj();Object.defineProperty(Fr,"NotFoundError",{enumerable:!0,get:a(function(){return aie.NotFoundError},"get")});var cie=hj();Object.defineProperty(Fr,"ResourceExhaustedError",{enumerable:!0,get:a(function(){return cie.ResourceExhaustedError},"get")});var lie=mj();Object.defineProperty(Fr,"ServiceError",{enumerable:!0,get:a(function(){return lie.ServiceError},"get")})});var YI=T(C_=>{"use strict";Object.defineProperty(C_,"__esModule",{value:!0});C_.ShapeRegistry=void 0;var KI=class{static{a(this,"ShapeRegistry")}constructor(){this.shapes=new Map}get(e){return this.shapes.get(e)}register(e){this.shapes.set(e.propertyIRI,e)}getAll(){return Array.from(this.shapes.values())}get size(){return this.shapes.size}};C_.ShapeRegistry=KI});var yj=T(vo=>{"use strict";var uie=vo&&vo.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),fie=vo&&vo.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),XI=vo&&vo.__importStar||(function(){var r=a(function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[n.length]=i);return n},r(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),i=0;i<n.length;i++)n[i]!=="default"&&uie(t,e,n[i]);return fie(t,e),t}})();Object.defineProperty(vo,"__esModule",{value:!0});vo.ShapeLoader=void 0;var QI=YI(),js=Le(),id=Xe(),_r=Yt(),die=Ky(),x_="http://www.w3.org/ns/shacl#",vCe=[["exo__",_r.Namespace.EXO],["ems__",_r.Namespace.EMS],["exocmd__",_r.Namespace.EXOCMD],["ims__",_r.Namespace.IMS],["ztlk__",_r.Namespace.ZTLK],["ptms__",_r.Namespace.PTMS],["lit__",_r.Namespace.LIT],["inbox__",_r.Namespace.INBOX],["pmbok__",_r.Namespace.PMBOK]],Ca=class r{static{a(this,"ShapeLoader")}static async loadFromVaultFS(e){let{readdir:t,readFile:n}=await Promise.resolve().then(()=>XI(require("fs/promises"))),i=await Promise.resolve().then(()=>XI(require("path"))),s=new QI.ShapeRegistry,o={classEdges:[],candidates:[],uidToLabel:new Map};await r.scanDir(e,o,{readdir:t,readFile:n,path:i});let c=r.propertyClassKeysFromEdges(o.classEdges);for(let l of o.candidates)try{r.registerCandidate(l,s,c,i,o.uidToLabel)}catch{}return s}static async loadFromRDFGraph(e){let t=new QI.ShapeRegistry,n=_r.Namespace.EXO,i=_r.Namespace.RDFS,s=_r.Namespace.RDF,o=await r.buildUidClassIndex(e),c=await r.collectPropertyClassIRIs(e,o),l=await Promise.all([...c].map(async f=>{try{return await e.match(void 0,s.term("type"),new js.IRI(f))}catch{return[]}})),u=new Set;for(let f of l.flat())f.subject instanceof js.IRI&&u.add(f.subject.value);for(let f of u){let d;try{d=new js.IRI(f)}catch{continue}let[p,h,g,m,b,_,E,I,w]=await Promise.all([e.match(d,i.term("domain"),void 0),e.match(d,n.term("Property_domain"),void 0),e.match(d,i.term("range"),void 0),e.match(d,n.term("Property_range"),void 0),e.match(d,n.term("Property_cardinality"),void 0),e.match(d,n.term("Property_severity"),void 0),e.match(d,n.term("Asset_label"),void 0),e.match(d,i.term("label"),void 0),e.match(d,n.term("Property_minCount"),void 0)]),S=[...E,...I],R=[...p,...h],P=[...g,...m];if(R.length===0)continue;let x=null;for(let V of S)if(V.object instanceof id.Literal&&(x=r.labelToIRI(V.object.value),x))break;if(!x)continue;let M=await Promise.all(R.map(async V=>V.object instanceof js.IRI?await r.resolveClassIRI(V.object.value,e,o):null)),U=Array.from(new Set(M.filter(V=>V!==null))),D=await Promise.all(P.map(async V=>V.object instanceof js.IRI?await r.resolveClassIRI(V.object.value,e,o):V.object instanceof id.Literal?r.datatypeRangeToIRI(V.object.value):null)),Q=Array.from(new Set(D.filter(V=>V!==null))),ue=r.cardinalityFromIRI(b[0]?.object instanceof js.IRI?b[0].object.value:void 0),$=r.severityFromValue(_[0]?.object instanceof id.Literal||_[0]?.object instanceof js.IRI?_[0].object.value:void 0),le=w[0]?.object,H=le instanceof id.Literal?parseInt(le.value,10):NaN,ie=isNaN(H)?void 0:H;t.register({propertyIRI:x,domain:U,range:Q.length>0?Q:void 0,cardinality:ue,severity:$,minCount:ie})}return t}static async loadFromShapeJSON(e){let{readFile:t}=await Promise.resolve().then(()=>XI(require("fs/promises"))),n=await t(e,"utf-8"),i=JSON.parse(n),s=new QI.ShapeRegistry;for(let o of Object.values(i.shapes))s.register(o);return s}static extractUidFromFileIRI(e){let t=r.FILE_IRI_UID_RE.exec(e);return t?t[1].toLowerCase():null}static async buildUidClassIndex(e){let t=_r.Namespace.RDFS,n=_r.Namespace.EXO,[i,s]=await Promise.all([e.match(void 0,t.term("label"),void 0),e.match(void 0,n.term("Asset_label"),void 0)]),o=new Map;for(let c of[...i,...s]){if(!(c.subject instanceof js.IRI)||!(c.object instanceof id.Literal))continue;let l=r.extractUidFromFileIRI(c.subject.value);if(!l||o.has(l))continue;let u=c.object.value.trim();if(/\s/.test(u))continue;let f=r.labelToIRI(u);f&&o.set(l,f)}return o}static async collectPropertyClassIRIs(e,t){let n=_r.Namespace.EXO,i=_r.Namespace.RDFS,[s,o]=await Promise.all([e.match(void 0,n.term("Class_superClass"),void 0),e.match(void 0,i.term("subClassOf"),void 0)]),c=new Map,l=a(async p=>{let h=c.get(p);return h===void 0&&(h=await r.resolveClassIRI(p,e,t),c.set(p,h)),h},"canon"),u=new Map;for(let p of[...s,...o]){if(!(p.subject instanceof js.IRI)||!(p.object instanceof js.IRI))continue;let[h,g]=await Promise.all([l(p.subject.value),l(p.object.value)]);if(!h||!g||h===g)continue;let m=u.get(g)??new Set;m.add(h),u.set(g,m)}let f=new Set([n.term("Property").value,n.term("ObjectProperty").value]),d=[...f];for(;d.length>0;){let p=d.shift();for(let h of u.get(p)??[])f.has(h)||(f.add(h),d.push(h))}return f}static async resolveClassIRI(e,t,n){if(e.startsWith("https://exocortex.my/ontology/")||e.startsWith("http://www.w3.org/"))return e;let i;try{i=new js.IRI(e)}catch{return null}let s=_r.Namespace.RDFS,o=_r.Namespace.EXO,[c,l]=await Promise.all([t.match(i,s.term("label"),void 0),t.match(i,o.term("Asset_label"),void 0)]);for(let u of[...c,...l])if(u.object instanceof id.Literal){let f=r.labelToIRI(u.object.value);if(f)return f}if(n){let u=r.extractUidFromFileIRI(e);if(u){let f=n.get(u);if(f)return f}}return e}static propertyClassKeysFromEdges(e){let t=["exo__Property",r.EXO_PROPERTY_UID,"exo__ObjectProperty",r.EXO_OBJECT_PROPERTY_UID],n=new Set(t),i=[...t];for(;i.length>0;){let s=i.shift();for(let o of e)if(o.parentKeys.includes(s)&&!o.childKeys.some(c=>n.has(c)))for(let c of o.childKeys)n.add(c),i.push(c)}return n}static wikilinkClassKeys(e){let t=r.extractWikilinkRef(e);if(!t)return[];let n=[t.trim()];for(let i of t.split("|")){let s=i.trim();s.length>0&&n.push(s)}return n}static async scanDir(e,t,n){let i;try{i=await n.readdir(e,{withFileTypes:!0})}catch{return}i.sort((s,o)=>s.name<o.name?-1:s.name>o.name?1:0);for(let s of i){let o=n.path.join(e,s.name);if(s.isDirectory())await r.scanDir(o,t,n);else if(s.isFile()&&s.name.endsWith(".md"))try{await r.collectFile(o,t,n.readFile,n.path)}catch{}}}static async collectFile(e,t,n,i){let s;try{s=await n(e,"utf-8")}catch{return}let o=r.parseFrontmatter(s);if(!o)return;r.indexUidLabel(e,o,t.uidToLabel,i);let c=r.asArray(o.exo__Class_superClass);if(c.length>0){let l=[i.basename(e,".md")],u=o.exo__Asset_uid;typeof u=="string"&&u.trim().length>0&&l.push(u.trim().replace(/^["']|["']$/g,""));let f=o.exo__Asset_label;typeof f=="string"&&f.trim().length>0&&l.push(f.trim().replace(/^["']|["']$/g,"")),t.classEdges.push({childKeys:l,parentKeys:c.flatMap(d=>r.wikilinkClassKeys(d))})}r.asArray(o.exo__Property_domain).length>0&&t.candidates.push({filePath:e,fm:o})}static indexUidLabel(e,t,n,i){let s=t.exo__Asset_label;if(typeof s!="string")return;let o=s.trim().replace(/^["']|["']$/g,"");if(o.length===0||/\s/.test(o)||!_r.Namespace.fromPropertyKey(o))return;let c=t.exo__Asset_uid,l=[typeof c=="string"?c.trim().replace(/^["']|["']$/g,""):"",i.basename(e,".md")];for(let u of l){if(!r.BARE_UID_RE.test(u))continue;let f=u.toLowerCase();n.has(f)||n.set(f,o)}}static registerCandidate(e,t,n,i,s){let{filePath:o,fm:c}=e;if(!r.asArray(c.exo__Instance_class).some(x=>r.wikilinkClassKeys(x).some(M=>n.has(M))))return;let f=null,d=c.exo__Asset_label;if(typeof d=="string"&&d.trim().length>0)f=d.trim().replace(/^["']|["']$/g,"");else{let x=i.basename(o,".md");_r.Namespace.fromPropertyKey(x)&&(f=x)}if(!f)return;let p=r.labelToIRI(f);if(!p)return;let h=c.exo__Property_domain,g=c.exo__Property_range,m=c.exo__Property_cardinality,b=c.exo__Property_severity,_=c.exo__Property_minCount,E=r.asArray(h).map(x=>r.wikilinkToIRI(x,s)).filter(x=>x!==null);if(E.length===0)return;let I=r.asArray(g).map(x=>r.wikilinkToIRI(x,s)).filter(x=>x!==null),w=r.cardinalityFromLabel(typeof m=="string"?m:void 0),S=r.severityFromValue(typeof b=="string"?b:void 0),R=typeof _=="string"?parseInt(_,10):void 0,P=R!==void 0&&!isNaN(R)?R:void 0;t.register({propertyIRI:p,domain:E,range:I.length>0?I:void 0,cardinality:w,severity:S,minCount:P})}static parseFrontmatter(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!t)return null;let n=t[1],i={},s=n.split(/\r?\n/),o=null,c=null;for(let l of s){let u=/^ {2}- (.*)$/.exec(l);if(u){o&&c&&c.push(u[1].trim());continue}o&&c&&(i[o]=c,o=null,c=null);let f=/^([^:]+):\s*(.*)$/.exec(l);if(!f)continue;let d=f[1].trim(),p=f[2].trim();p===""?(o=d,c=[]):i[d]=p}return o&&c&&(i[o]=c),i}static labelToIRI(e){let t=_r.Namespace.fromPropertyKey(e);if(!t)return null;try{return t.namespace.term(t.localName).value}catch{return null}}static extractWikilinkRef(e){let t=e.replace(/^["']|["']$/g,""),n=/\[\[([^\]]+)\]\]/.exec(t);return n?n[1]:t}static wikilinkToIRI(e,t){let n=r.extractWikilinkRef(e);if(!n)return null;let i=n.split("|"),s=i.length>1?[i[1],i[0]]:[i[0]];for(let c of s){let l=r.labelToIRI(c.trim());if(l)return l}let o=r.datatypeRangeToIRI(n);if(o)return o;if(n.startsWith("sh:"))return x_+n.substring(3);if(t)for(let c of s){let l=t.get(c.trim().toLowerCase());if(l===void 0)continue;let u=r.labelToIRI(l);if(u)return u}return null}static datatypeRangeToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?e:(0,die.xsdDatatypeIRI)(e)}static asArray(e){return Array.isArray(e)?e.map(String):typeof e=="string"?[e]:[]}static cardinalityFromIRI(e){if(e){if(e.endsWith("PropertyCardinalitySingle"))return"Single";if(e.endsWith("PropertyCardinalityMultiple"))return"Multiple";if(e.includes(r.CARDINALITY_SINGLE_UID))return"Single";if(e.includes(r.CARDINALITY_MULTIPLE_UID))return"Multiple"}}static cardinalityFromLabel(e){if(!e)return;let t=r.extractWikilinkRef(e)??e,n=t.split("|").pop()??t;if(n.includes("Single"))return"Single";if(n.includes("Multiple"))return"Multiple";if(t.includes(r.CARDINALITY_SINGLE_UID))return"Single";if(t.includes(r.CARDINALITY_MULTIPLE_UID))return"Multiple"}static severityFromValue(e){return!e||e.includes("Violation")||e===x_+"Violation"?"sh:Violation":e.includes("Warning")||e===x_+"Warning"?"sh:Warning":e.includes("Info")||e===x_+"Info"?"sh:Info":"sh:Violation"}};vo.ShapeLoader=Ca;Ca.FILE_IRI_UID_RE=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;Ca.BARE_UID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;Ca.EXO_PROPERTY_UID="38277bfa-d7f9-4a75-b856-b23276ab0db3";Ca.EXO_OBJECT_PROPERTY_UID="9a1cf31c-9d41-4ef3-9023-584a8d087d16";Ca.CARDINALITY_SINGLE_UID="c93c4b2f-b43d-4cc9-8dd0-31514d608da2";Ca.CARDINALITY_MULTIPLE_UID="59a37aa7-ffbe-4e0d-ba60-06ae370d880f"});var eR=T(sd=>{"use strict";Object.defineProperty(sd,"__esModule",{value:!0});sd.ShapeRegistry=void 0;sd.extractUidFromIRI=ZI;sd.validate=Iie;var pie=Le(),JI=class{static{a(this,"ShapeRegistry")}constructor(e=[],t="https://exocortex.my/ontology/exo#Instance_class"){this.shapeMap=new Map(e.map(n=>[n.propertyIRI,n])),this.typePredicateIRI=t}getShape(e){return this.shapeMap.get(e)}getAllShapes(){return Array.from(this.shapeMap.values())}hasShape(e){return this.shapeMap.has(e)}};sd.ShapeRegistry=JI;var hie="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",mie=["http://www.w3.org/2001/XMLSchema#","http://www.w3.org/1999/02/22-rdf-syntax-ns#","http://www.w3.org/2000/01/rdf-schema#","http://www.w3.org/2002/07/owl#","http://www.w3.org/ns/shacl#","http://www.w3.org/2004/02/skos/core#","http://purl.org/dc/elements/1.1/","http://purl.org/dc/terms/","http://xmlns.com/foaf/0.1/","https://schema.org/","https://exocortex.my/ontology/xsd#","https://exocortex.my/ontology/rdf#","https://exocortex.my/ontology/rdfs#","https://exocortex.my/ontology/owl#","https://exocortex.my/ontology/skos#"];function gie(r){return mie.some(e=>r.startsWith(e))}a(gie,"isExternalOntologyIRI");var Sj=["http://www.w3.org/2001/XMLSchema#","https://exocortex.my/ontology/xsd#"];function yie(r){return Sj.some(e=>r.startsWith(e))}a(yie,"isXSDDatatypeIRI");function bie(r){for(let e of Sj)if(r.startsWith(e))return r.substring(e.length);return null}a(bie,"xsdLocalName");var _ie="http://www.w3.org/2001/XMLSchema#decimal",Sie="http://www.w3.org/2001/XMLSchema#integer",bj="http://www.w3.org/2001/XMLSchema#string",Vh=/^[+-]?\d+$/,Gh=/^\+?\d+$/,wie=/^[+-]?(\d+(\.\d*)?|\.\d+)$/,_j=/^([+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?|[+-]?INF|NaN)$/,Eie={integer:Vh,long:Vh,int:Vh,short:Vh,byte:Vh,nonNegativeInteger:Gh,unsignedLong:Gh,unsignedInt:Gh,unsignedShort:Gh,unsignedByte:Gh,positiveInteger:/^\+?0*[1-9]\d*$/,nonPositiveInteger:/^(-\d+|\+?0+)$/,negativeInteger:/^-0*[1-9]\d*$/,decimal:wie,float:_j,double:_j,gYear:/^-?\d{4,}(Z|[+-]\d{2}:\d{2})?$/},vie=/^(true|false)$/;function Tie(r,e,t){if(e===t)return!0;let n=bie(t);if(n===null)return!1;if(e===_ie||e===Sie){let i=Eie[n];return i!==void 0&&i.test(r)}return e===bj&&n==="boolean"?vie.test(r):e===bj&&n==="anyURI"?pie.IRI.isValidIRI(r):!1}a(Tie,"literalConformsToDatatype");var Aie=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function ZI(r){let e=Aie.exec(r);return e?e[1].toLowerCase():null}a(ZI,"extractUidFromIRI");function Iie(r,e,t,n){let i=new Map,s=new Map;for(let l of r){let{subject:u,predicate:f,object:d}=l;if(u.type!=="iri"||f.type!=="iri"||d.type!=="iri"&&d.type!=="literal")continue;let p=u.value,h=f.value,g=d;if(h===e.typePredicateIRI||h===hie){if(g.type==="iri"){let b=i.get(p)??[];b.push(g.value),i.set(p,b);let _=ZI(p);if(_){let E=`uid:${_}`,I=i.get(E)??[];I.push(g.value),i.set(E,I)}}}else{let b=s.get(p);b||(b=new Map,s.set(p,b));let _=b.get(h)??[];_.push(g),b.set(h,_)}}let o=[],c=new Set([...i.keys(),...s.keys()]);for(let l of c){if(l.startsWith("uid:"))continue;let u=i.get(l)??[],f=s.get(l)??new Map;for(let d of e.getAllShapes()){if(!(d.domain.length===0||d.domain.some(g=>u.some(m=>m===g||t.isSubClassOf(m,g)))))continue;let h=f.get(d.propertyIRI)??[];if(d.minCount!==void 0&&d.minCount>0&&h.length<d.minCount){o.push({focusNode:l,propertyPath:d.propertyIRI,severity:d.severity,constraint:"minCount",message:d.message??`sh:minCount violation: expected at least ${d.minCount} value(s) for <${d.propertyIRI}>`});continue}if(h.length!==0){if(d.cardinality==="Single"&&h.length>1){o.push({focusNode:l,propertyPath:d.propertyIRI,severity:d.severity,constraint:"maxCount",message:d.message??`sh:maxCount violation: expected at most 1 value for <${d.propertyIRI}>, got ${h.length}`});continue}if(d.range&&d.range.length>0){for(let g of h)if(g.type==="iri"){if(gie(g.value))continue;let m=i.get(g.value)??[];if(m.length===0){let _=ZI(g.value);_&&(m=i.get(`uid:${_}`)??[])}if(!d.range.some(_=>m.some(E=>E===_||t.isSubClassOf(E,_)))){let _=m.length===0;o.push({focusNode:l,propertyPath:d.propertyIRI,severity:_?"sh:Warning":d.severity,constraint:"class",message:_?`sh:class unresolvable-ref: <${g.value}> has no resolvable type in this vault (cross-vault, symbolic, or external reference); not validated against ${d.range.join(" | ")}`:d.message??`sh:class violation: <${g.value}> does not conform to expected class ${d.range.join(" | ")}`,actualValue:g.value,expectedRange:d.range.join(" | ")})}}else if(g.type==="literal"){let m=d.range.filter(E=>yie(E));if(m.length===0)continue;let b=g.datatype??"http://www.w3.org/2001/XMLSchema#string";m.some(E=>Tie(g.value,b,E))||o.push({focusNode:l,propertyPath:d.propertyIRI,severity:d.severity,constraint:"datatype",message:d.message??`sh:datatype violation: literal "${g.value}" has datatype <${b}>, expected ${m.join(" | ")}`,actualValue:g.value,expectedRange:m.join(" | ")})}}}}}if(n?.closedWorldMode)for(let l of c){let u=s.get(l)??new Map;for(let f of u.keys())e.hasShape(f)||o.push({focusNode:l,propertyPath:f,severity:"sh:Warning",constraint:"unknown-property",message:`Unknown property: <${f}> has no registered shape`})}return o.sort((l,u)=>{let f=l.focusNode.localeCompare(u.focusNode);return f!==0?f:l.propertyPath.localeCompare(u.propertyPath)}),{conforms:!o.some(l=>l.severity==="sh:Violation"),violations:o}}a(Iie,"validate")});var wj=T(O_=>{"use strict";Object.defineProperty(O_,"__esModule",{value:!0});O_.ApplicationErrorHandler=void 0;var tR=Eo(),Rie=wo(),Cie=Gl(),rR=class{static{a(this,"ApplicationErrorHandler")}constructor(e={},t,n){this.logger=t,this.notifier=n,this.telemetryHooks=new Set,this.retryConfig={maxRetries:e.maxRetries??3,initialDelayMs:e.initialDelayMs??1e3,backoffMultiplier:e.backoffMultiplier??2,maxDelayMs:e.maxDelayMs??1e4}}handle(e,t){let n=this.ensureApplicationError(e,t);return this.notifier&&this.notifier.error(n.message),this.callTelemetryHooks("onError",n,t),this.formatError(n)}async executeWithRetry(e,t){let n,i=0;for(;i<=this.retryConfig.maxRetries;)try{return await e()}catch(s){if(n=this.ensureApplicationError(s,t),!n.retriable||i>=this.retryConfig.maxRetries)throw this.callTelemetryHooks("onError",n,t),i>=this.retryConfig.maxRetries&&n.retriable&&this.callTelemetryHooks("onRetryExhausted",n,i+1),n;let o=this.calculateDelay(i);this.callTelemetryHooks("onRetry",n,i+1,o),this.logger?.debug(`Retrying after ${o}ms (attempt ${i+1}/${this.retryConfig.maxRetries})`),await this.sleep(o),i++}throw n}registerTelemetryHook(e){this.telemetryHooks.add(e)}unregisterTelemetryHook(e){this.telemetryHooks.delete(e)}ensureApplicationError(e,t){if(e instanceof tR.ApplicationError){if(t){let i=e,s={...e.context,...t};return new class extends tR.ApplicationError{constructor(){super(...arguments),this.code=i.code,this.retriable=i.retriable,this.guidance=i.guidance}}(e.message,s)}return e}return new class extends tR.ApplicationError{static{a(this,"UnknownError")}constructor(s,o){super(s,{originalError:o.name,...t}),this.code=Rie.ErrorCode.UNKNOWN_ERROR,this.retriable=!1,this.guidance="An unexpected error occurred"}}(e.message,e)}formatError(e){let t=[];return t.push(`\u274C ${e.name}: ${e.message}`),e.guidance&&t.push(`\u{1F4A1} ${e.guidance}`),e.context&&Object.keys(e.context).length>0&&t.push(`Context: ${JSON.stringify(e.context,null,2)}`),t.join(`
|
|
329
329
|
`)}calculateDelay(e){let t=this.retryConfig.initialDelayMs*Math.pow(this.retryConfig.backoffMultiplier,e);return Math.min(t,this.retryConfig.maxDelayMs)}sleep(e){return new Promise(t=>setTimeout(t,e))}callTelemetryHooks(e,...t){for(let n of this.telemetryHooks)try{let i=n[e];i&&i.apply(n,t)}catch(i){Cie.LoggingService.error("Error in telemetry hook",i instanceof Error?i:new Error(String(i)))}}};O_.ApplicationErrorHandler=rR});var Ej=T(P_=>{"use strict";Object.defineProperty(P_,"__esModule",{value:!0});P_.ApplicationErrorHandler=void 0;var xie=wj();Object.defineProperty(P_,"ApplicationErrorHandler",{enumerable:!0,get:a(function(){return xie.ApplicationErrorHandler},"get")})});var vj=T(F_=>{"use strict";Object.defineProperty(F_,"__esModule",{value:!0});F_.ClassHierarchy=void 0;var Oie="http://www.w3.org/2000/01/rdf-schema#subClassOf",nR=class{static{a(this,"ClassHierarchy")}constructor(e){this.adjacency=new Map;for(let t of e){if(t.predicate.type!=="iri"||t.predicate.value!==Oie||t.subject.type!=="iri"||t.object.type!=="iri")continue;let n=t.subject.value,i=t.object.value,s=this.adjacency.get(n);s||(s=new Set,this.adjacency.set(n,s)),s.add(i)}}isSubClassOf(e,t){if(e===t)return!0;let n=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(s===void 0)break;if(n.has(s))continue;n.add(s);let o=this.adjacency.get(s);if(o)for(let c of o){if(c===t)return!0;n.has(c)||i.push(c)}}return!1}getAncestors(e){let t=new Set,n=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(s===void 0)break;if(n.has(s))continue;n.add(s);let o=this.adjacency.get(s);if(o)for(let c of o)t.add(c),n.has(c)||i.push(c)}return t}};F_.ClassHierarchy=nR});var iR=T(D_=>{"use strict";Object.defineProperty(D_,"__esModule",{value:!0});D_.parseTarball=Ij;D_.parseTarballGzip=kie;var Pie={0:"file",1:"hardLink",2:"symbolicLink",3:"characterDevice",4:"blockDevice",5:"directory",6:"fifo",7:"contiguousFile",g:"globalExtendedHeader",x:"extendedHeader",D:"gnuDirectory",I:"gnuInodeMetadata",K:"gnuLongLinkName",L:"gnuLongFileName",N:"gnuOldLongFileName",M:"gnuMultiVolume",S:"gnuSparseFile",E:"gnuExtendedSparse"},Fie=new Set(["extendedHeader","globalExtendedHeader","gnuLongFileName","gnuOldLongFileName","gnuLongLinkName"]),Tj;function Aj(){return Tj??(Tj=new TextDecoder)}a(Aj,"getDecoder");function qh(r,e,t){let n=r.subarray(e,e+t),i=n.indexOf(0);return Aj().decode(i===-1?n:n.subarray(0,i))}a(qh,"readString");function Die(r,e,t){let n="";for(let s=0;s<t;s++)n+=String.fromCodePoint(r[e+s]);let i=Number.parseInt(n,8);return Number.isNaN(i)?0:i}a(Die,"readNumber");function Lie(r){let e=Aj().decode(r),t={};for(let n of e.split(`
|
|
330
330
|
`)){let i=n.indexOf("=");if(i===-1)continue;let s=n.slice(n.indexOf(" ")+1,i),o=n.slice(i+1);s&&(t[s]=o)}return t}a(Lie,"parseExtendedHeaders");function Nie(r){let e=r.replace(/\\/g,"/");e=e.replace(/^[a-zA-Z]:\//,""),e=e.replace(/^\/+/,"");let t=e.startsWith("./"),n=e.split("/"),i=[];for(let o of n)o===".."?i.pop():o!=="."&&o!==""&&i.push(o);let s=i.join("/");return t&&!s.startsWith("./")&&(s="./"+s),r.endsWith("/")&&!s.endsWith("/")&&(s+="/"),s}a(Nie,"sanitizePath");function Ij(r){let e=r.byteOffset===0&&r.byteLength===r.buffer.byteLength?r:r.slice(),t=[],n=0,i,s;for(;n+512<=e.byteLength;){let o=qh(e,n,100);if(o.length===0)break;let c=!1;if(i){let h=i.path??i.linkpath;h&&(o=h,c=!0)}let l=Die(e,n+124,12),u=512+512*Math.trunc(l/512)+(l%512?512:0),f=qh(e,n+156,1)||"0",d=Pie[f]??f;if(d==="extendedHeader"||d==="globalExtendedHeader"){let h=Lie(e.subarray(n+512,n+512+l));d==="extendedHeader"?i=h:(i=void 0,s={...s,...h}),n+=u;continue}if(Fie.has(d)){i={path:qh(e,n+512,l)},n+=u;continue}if(!c&&qh(e,n+257,6).startsWith("ustar")){let g=qh(e,n+345,155);g.length>0&&(o=`${g}/${o}`)}o=Nie(o);let p=l===0?void 0:e.subarray(n+512,n+512+l);t.push({name:o,type:d,size:l,data:p}),i=void 0,n+=u}return t}a(Ij,"parseTarball");async function kie(r){let e=new Uint8Array(r instanceof Uint8Array?r:new Uint8Array(r)),t=new DecompressionStream("gzip"),n=t.writable.getWriter(),[,i]=await Promise.all([n.write(e).then(()=>n.close()),new Response(t.readable).arrayBuffer()]);return Ij(new Uint8Array(i))}a(kie,"parseTarballGzip")});var N_=T(L_=>{"use strict";Object.defineProperty(L_,"__esModule",{value:!0});L_.isBinaryPayload=oR;L_.restCreateCommit=jie;function oR(r){return typeof r!="string"}a(oR,"isBinaryPayload");var Mie="https://api.github.com";function Rj(r){if(r!==null&&typeof r=="object"&&"object"in r){let e=r.object;if(e!==null&&typeof e=="object"&&"sha"in e){let t=e.sha;return typeof t=="string"?t:void 0}}}a(Rj,"readObjectSha");function sR(r){if(r!==null&&typeof r=="object"&&"sha"in r){let e=r.sha;return typeof e=="string"?e:void 0}}a(sR,"readSha");async function jie(r,e){let{owner:t,repo:n,branch:i,files:s,message:o}=e,c=e.deletions??[],l=(e.baseURL??Mie).replace(/\/$/,""),u=e.redact??(x=>x);if(typeof t!="string"||t.length===0)throw new Error("restCreateCommit: owner is required");if(typeof n!="string"||n.length===0)throw new Error("restCreateCommit: repo is required");if(typeof i!="string"||i.length===0)throw new Error("GitHub createCommit: branch is required");if(!(s instanceof Map)||s.size===0&&c.length===0)throw new Error("GitHub createCommit: files map must be non-empty (unless deletions are provided)");let f=new Set;for(let x of c){if(typeof x!="string"||x.length===0)throw new Error("GitHub createCommit: deletion path must be a non-empty string");if(s.has(x))throw new Error(u(`GitHub createCommit: path ${x} is both written and deleted \u2014 ambiguous`));f.add(x)}if(typeof o!="string"||o.length===0)throw new Error("GitHub createCommit: message is required");let d=encodeURIComponent(t),p=encodeURIComponent(n),h=encodeURIComponent(i),g=await r({method:"GET",url:`${l}/repos/${d}/${p}/git/refs/heads/${h}`}),m=Rj(g?.json);if(typeof m!="string"||m.length===0)throw new Error(u(`GitHub createCommit: missing object.sha for ref heads/${i}`));if(e.expectedHeadSha!==void 0&&m!==e.expectedHeadSha)throw new Error(u(`GitHub createCommit: head heads/${i} moved since the caller's check (expected ${e.expectedHeadSha}, found ${m}) \u2014 refusing to avoid overwriting a concurrent change`));let b=new Map;for(let[x,M]of s){if(!oR(M))continue;let U=await r({method:"POST",url:`${l}/repos/${d}/${p}/git/blobs`,contentType:"application/json",body:JSON.stringify({content:M.base64,encoding:"base64"})}),D=sR(U?.json);if(typeof D!="string"||D.length===0)throw new Error(u(`GitHub createCommit: blob create returned no sha for ${x}`));b.set(x,D)}let _=Array.from(s.entries()).map(([x,M])=>oR(M)?{path:x,mode:"100644",type:"blob",sha:b.get(x)}:{path:x,mode:"100644",type:"blob",content:M});for(let x of f)_.push({path:x,mode:"100644",type:"blob",sha:null});let E=await r({method:"POST",url:`${l}/repos/${d}/${p}/git/trees`,contentType:"application/json",body:JSON.stringify({base_tree:m,tree:_})}),I=sR(E?.json);if(typeof I!="string"||I.length===0)throw new Error(u("GitHub createCommit: tree create returned no sha"));let w=await r({method:"POST",url:`${l}/repos/${d}/${p}/git/commits`,contentType:"application/json",body:JSON.stringify({message:o,tree:I,parents:[m]})}),S=sR(w?.json);if(typeof S!="string"||S.length===0)throw new Error(u("GitHub createCommit: commit create returned no sha"));let R=await r({method:"PATCH",url:`${l}/repos/${d}/${p}/git/refs/heads/${h}`,contentType:"application/json",body:JSON.stringify({sha:S,force:!1})}),P=Rj(R?.json);if(P!==S)throw new Error(u(`GitHub createCommit: ref update mismatch (expected ${S}, got ${P})`));return S}a(jie,"restCreateCommit")});var Oj=T(Fi=>{"use strict";Object.defineProperty(Fi,"__esModule",{value:!0});Fi.MATERIALIZE_PROGRESS_MIN_FILES=Fi.MATERIALIZE_PROGRESS_INTERVAL=void 0;Fi.discoverWrapperDir=Cj;Fi.extractShaFromWrapper=xj;Fi.mountAssetSpaceFiles=Bie;Fi.escapeGitmodulesRegex=cR;Fi.appendGitmodulesEntry=Vie;Fi.stripGitmodulesEntry=Gie;var $ie=iR(),aR=new Set(["globalExtendedHeader","extendedHeader"]);function k_(r){let e=r.replace(/\\/g,"/").replace(/\/+/g,"/");for(;e.startsWith("./");)e=e.slice(2);return e}a(k_,"normalizeEntryPath");function Cj(r){let e=r.find(s=>!aR.has(s.type)&&k_(s.name).includes("/"));if(e===void 0)throw new Error("discoverWrapperDir: no wrapper-bearing entry in tarball");let t=k_(e.name),n=t.slice(0,t.indexOf("/"));if(n.length===0)throw new Error(`discoverWrapperDir: empty wrapper segment in entry "${e.name}"`);let i=n+"/";for(let s of r){if(aR.has(s.type))continue;let o=k_(s.name);if(!(o===n||o===i)&&!o.startsWith(i))throw new Error(`discoverWrapperDir: entry "${s.name}" not under wrapper "${n}"`)}return n}a(Cj,"discoverWrapperDir");function xj(r){let e=r.match(/-([0-9a-fA-F]{7,40})$/);if(e===null)throw new Error(`extractShaFromWrapper: wrapper "${r}" does not match expected GitHub pattern <owner>-<repo>-<sha>`);return e[1].toLowerCase()}a(xj,"extractShaFromWrapper");function Uie(r,e){let t=e+"/",n=[];for(let i of r){if(i.type==="symbolicLink"||i.type==="hardLink")throw new Error(`${i.type} entry "${i.name}" rejected for security`);if(aR.has(i.type)||i.type==="directory")continue;let s=k_(i.name);if(s===e||s===t)continue;if(!s.startsWith(t))throw new Error(`entry "${i.name}" not under wrapper "${e}"`);let o=s.slice(t.length);if(o.length!==0){if(o.split("/").some(c=>c===".."))throw new Error(`path traversal detected for entry "${i.name}"`);i.data!==void 0&&n.push({relPath:o,content:i.data})}}return n}a(Uie,"buildMountFiles");Fi.MATERIALIZE_PROGRESS_INTERVAL=200;Fi.MATERIALIZE_PROGRESS_MIN_FILES=500;async function Bie(r){let{http:e,fs:t,owner:n,repo:i,ref:s,targetPath:o}=r,c=a((b,_)=>{if(r.onProgress!==void 0)try{r.onProgress(b,_)}catch{}},"emit");c("fetch");let l=await e.fetchTarball(n,i,s);c("extract");let u=await(0,$ie.parseTarballGzip)(l);if(u.length===0)throw new Error(`tarball empty for ${n}/${i}@${s}`);let f=Cj(u),d=xj(f),p=Uie(u,f);c("materialize");let h=p.length,g=r.onProgress!==void 0&&h>Fi.MATERIALIZE_PROGRESS_MIN_FILES,m=await t.materialize(o,p,g?b=>{b%Fi.MATERIALIZE_PROGRESS_INTERVAL===0&&b<h&&c("materialize",{processed:b,total:h})}:void 0);return{sha:d,fileCount:m}}a(Bie,"mountAssetSpaceFiles");function cR(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(cR,"escapeGitmodulesRegex");function Vie(r,e,t){let n=new RegExp(`^\\s*\\[submodule\\s+"${cR(e)}"\\]`,"m");if(r.length>0&&n.test(r))return{content:r,added:!1};let i=r.length===0||r.endsWith(`
|
|
331
331
|
`)?"":`
|
|
@@ -606,7 +606,7 @@ ${g}
|
|
|
606
606
|
`);return}e.dryRun||(0,ip.writeFileSync)(n,c,"utf-8"),process.stdout.write(JSON.stringify({path:i,changed:!0,dryRun:!!e.dryRun,removed:o.removed,...e.canonicalizeKeys?{canonicalized:l}:{},...u?{updatedAt:u}:{},...e.dryRun?{diff:i0e(s,c)}:{}})+`
|
|
607
607
|
`)}catch(t){ce.handle(t)}})}a(N7,"repairFrontmatterCommand");at();var k7=require("fs"),M7=require("path"),ds=ee(Ve());Fo();Rt();Ut();ar();Aw();var s0e="https://exocortex.my/ontology/find#Alias_sparql",o0e="https://exocortex.my/ontology/exo#Asset_label";function sp(r){if(r&&typeof r=="object"&&"value"in r){let e=r.value;return typeof e=="string"?e:String(e)}return String(r)}a(sp,"nodeValue");async function a0e(r,e){let t=await r.match(void 0,void 0,void 0),n=[];for(let s of t)sp(s.predicate)!==o0e||sp(s.object)!==e||n.push(sp(s.subject));if(n.length===0)return null;let i=[];for(let s of n)for(let o of t)sp(o.predicate)===s0e&&sp(o.subject)===s&&i.push(sp(o.object));if(i.length===0)return null;if(i.length>1)throw new Ke(`Ambiguous find__Alias "${e}" \u2014 ${i.length} instances define a sparql fragment`,`Ensure exactly one find__Alias asset has exo:Asset_label "${e}"`);return i[0]}a(a0e,"resolveAliasFragment");var c0e=/^([a-z][a-zA-Z0-9]*)__([A-Za-z0-9_]+)$/,l0e="https://exocortex.my/ontology/";function u0e(r,e){let t=c0e.exec(e);if(t){let i=`<${l0e}${t[1]}#${t[2]}>`;return r.replace(/\?value\b/g,i)}let n=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return r.replace(/\?value\b/g,`"${n}"`)}a(u0e,"bindValueLiteral");function j7(){return new pe("find").description("Find vault assets via SPARQL \u2014 outputs file paths one per line (RFC 8e83442b T1.1)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--sparql <query>","SPARQL SELECT query (must bind ?path)").option("--class <value>","Filter by class label via find__Alias 'class' (e.g. ems__Task)").action(async r=>{ce.setFormat("text");try{if(r.sparql&&r.class)throw new Ke("--sparql and --class are mutually exclusive","Pass either a raw --sparql query or a find__Alias-backed flag like --class");if(!r.sparql&&!r.class)throw new Ke("one of --sparql <query> or --class <value> is required",'exocortex find --class ems__Task OR exocortex find --sparql "SELECT ?path WHERE { ... }"');let e=(0,M7.resolve)(r.vault);if(!(0,k7.existsSync)(e))throw new ke(e);let t=new Zt(e),i=await new ds.NoteToRDFConverter(t).convertVault(),s=new ds.InMemoryTripleStore;await s.addAll(i);let o;if(r.class){let b=await a0e(s,"class");if(b===null)throw new Ke('No find__Alias with exo:Asset_label "class" was found in the vault',"Seed a find__Alias asset (label=class) or fall back to exocortex find --sparql");o=`SELECT ?path WHERE { ${u0e(b,r.class)} }`}else o=r.sparql;let c=vw(o);c=Xd(c);let l=new ds.ExoQLParser,u=Tw(Ew(e));u.size>0&&l.setVaultPrefixes(u);let f=l.parse(c),p=new ds.ExoQLAlgebraTranslator().translate(f);p.type!=="construct"&&(p=new ds.AlgebraOptimizer().optimize(p));let g=await new ds.ExoQLQueryExecutor(s).executeAll(p),m="obsidian://vault/";for(let b of g){let E=b.toJSON().path;if(typeof E!="string"||!E.startsWith(m))continue;let I=E.slice(m.length),w;try{w=decodeURIComponent(I)}catch{w=I}process.stdout.write(w+`
|
|
608
608
|
`)}}catch(e){ce.handle(e),process.exit(5)}})}a(j7,"findCommand");at();var mP=require("fs"),Qa=require("path"),De=ee(Ve());Rt();Ut();ar();Fo();var Cn=ee(Ve());var Ww=new Map([["exo__Asset_uid",Cn.Namespace.EXO.term("Asset_uid").value],["exo__Asset_label",Cn.Namespace.EXO.term("Asset_label").value],["aliases",Cn.Namespace.EXO.term("Asset_aliases").value]]),zw=class r extends mi{constructor(t,n){super(t);this.source=n;this.indexPromise=null;this.pathKeys=new Map;this.stats={indexedLookups:0,scanFallbacks:0,candidateReads:0,zeroTripleReads:0}}static{a(this,"TripleStoreIndexedFsAdapter")}async findFilesByMetadata(t){let n=Object.entries(t);if(!(n.length>0&&n.every(([u,f])=>Ww.has(u)&&this.normalizeValue(f).length>0)))return this.stats.scanFallbacks++,super.findFilesByMetadata(t);let s=await this.ensureIndex();this.stats.indexedLookups++;let o=null;for(let[u,f]of n){let d=s.get(u)?.get(this.normalizeValue(f))??[];if(o=o===null?[...d]:o.filter(p=>d.includes(p)),o.length===0)return[]}let c=[...o??[]].filter(u=>!r.hasDotSegment(u)).sort(),l=[];for(let u of c){this.stats.candidateReads++;try{let f=await this.getFileMetadata(u);this.matchesQuery(f,t)&&l.push(u)}catch{continue}}return l}async createFile(t,n){let i=await super.createFile(t,n);return await this.reindexOwnWrite(t,n),i}async updateFile(t,n){await super.updateFile(t,n),await this.reindexOwnWrite(t,n)}async writeFile(t,n){await super.writeFile(t,n),await this.reindexOwnWrite(t,n)}async deleteFile(t){await super.deleteFile(t),this.forget(await this.ensureIndex(),r.rel(t))}async renameFile(t,n){await super.renameFile(t,n);let i=await this.ensureIndex(),s=r.rel(t),o=[...this.pathKeys.get(s)??[]];this.forget(i,s);let c=r.rel(n);for(let[l,u]of o)this.addKey(i,l,u,c)}async reindexOwnWrite(t,n){let i=await this.ensureIndex(),s=r.rel(t);this.forget(i,s);let o;try{o=this.extractFrontmatter(n)}catch{return}this.indexFrontmatter(i,s,o)}static rel(t){return t.replace(/\\/g,"/").replace(/^\.\//,"")}static hasDotSegment(t){return t.split("/").some(n=>n.startsWith("."))}async ensureIndex(){return this.indexPromise===null&&(this.indexPromise=this.buildIndex()),this.indexPromise}async buildIndex(){let t=new Map;for(let u of Ww.keys())t.set(u,new Map);let n=new Map;for(let[u,f]of Ww)n.set(f,u);let i=new Map,s=new Map,o=new Map,c=[];for(let u of this.source.explicitTriples){let f=n.get(u.predicate.value);if(f===void 0)continue;let d=r.subjectToPath(u);if(d===null)continue;c.push([f,d,u.object]);let p=u.object;if(f==="exo__Asset_uid"){p instanceof Cn.Literal&&!i.has(d)&&i.set(d,p.value);continue}if(p instanceof Cn.Literal)r.push(s,d,p.value);else if(p instanceof Cn.IRI){let h=Cn.Namespace.fromTermIRI(p.value);h&&(r.push(s,d,`${h.namespace.prefix}__${h.localName}`),f==="exo__Asset_label"&&r.push(o,p.value,d))}}let l=new Map;for(let[u,f]of o)l.set(u,f.map(d=>i.get(d)).filter(d=>d!==void 0));for(let[u,f,d]of c){let p=r.keysForObject(d,l,s);for(let h of p)this.addKey(t,u,this.normalizeValue(h),f)}for(let u of this.source.zeroTriplePaths){this.stats.zeroTripleReads++;try{this.indexFrontmatter(t,u,await this.getFileMetadata(u))}catch{continue}}return t}indexFrontmatter(t,n,i){for(let s of Ww.keys()){let o=i[s],c=Array.isArray(o)?o:[o];for(let l of c)this.addKey(t,s,this.normalizeValue(l),n)}}addKey(t,n,i,s){if(i.length===0)return;let o=t.get(n);if(o===void 0)return;let c=o.get(i);c===void 0?o.set(i,[s]):c.includes(s)||c.push(s),r.push(this.pathKeys,s,[n,i])}forget(t,n){let i=this.pathKeys.get(n);if(i){for(let[s,o]of i){let c=t.get(s)?.get(o);if(!c)continue;let l=c.indexOf(n);l>=0&&c.splice(l,1)}this.pathKeys.delete(n)}}static push(t,n,i){let s=t.get(n);s===void 0?t.set(n,[i]):s.push(i)}static subjectToPath(t){let n=t.subject;if(!(n instanceof Cn.IRI))return null;let i=(0,Cn.iriToVaultPath)(n.value);return i===null||i.startsWith("/")||i.startsWith("..")||i.includes("/../")?null:i}static keysForObject(t,n,i){if(t instanceof Cn.Literal)return[t.value];if(!(t instanceof Cn.IRI))return[];let s=Cn.Namespace.fromTermIRI(t.value);if(s)return[`${s.namespace.prefix}__${s.localName}`,...n.get(t.value)??[]];let o=(0,Cn.iriToVaultPath)(t.value);if(o!==null){let c=o.lastIndexOf("/"),l=c===-1?o:o.slice(c+1);return[l.endsWith(".md")?l.slice(0,-3):l,...i.get(o)??[]]}return[t.value]}};var W7=ee(Ve()),zt=ee(V7());var G7="obsidian://vault/";function F0e(r){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return{async resolveTargetPath(t){if(!t)throw new Error("Cannot resolve empty targetIRI to a vault path");let n=t;if(n.startsWith(G7))n=decodeURI(n.slice(G7.length));else if(e.test(n)){let i=await r.findFileByUID(n);if(!i)throw new Error(`No vault file found for UID: ${n}`);n=i}if(n.endsWith(".md")||(n=`${n}.md`),!await r.fileExists(n))throw new Error(`Cannot resolve target file for IRI "${t}" (tried "${n}")`);return n}}}a(F0e,"createCliPathResolver");var D0e=["openFile","sparqlSelect","getActiveFileIRI","getActiveFilePath","trashFile","duplicateFile"],hP=class extends Error{constructor(t){super(`Service "${t}" is not implemented in the CLI (no-op stub). dyncommand exec on this service_call grounding cannot change vault state. See CLI parity issues #2865-#2868 for port status.`);this.serviceId=t;this.name="CliServiceNotImplementedError"}static{a(this,"CliServiceNotImplementedError")}};function q7(r){return{async execute(){throw new hP(r)}}}a(q7,"notImplementedService");function L0e(r){return e=>{let t=r.getFirstLinkpathDest(e,"");if(!t||!("basename"in t))return null;let i=r.getFrontmatter(t)?.exo__Asset_label;return typeof i=="string"&&i.length>0?i:null}}a(L0e,"createCliClassResolver");function z7(r,e){for(let t of D0e)r.register(t,q7(t));for(let t of["updateProperty","removeProperty","setStatus","createAsset"])r.register(t,q7(t));if(e){if(e.fsAdapter){let t=new W7.FrontmatterService,n=F0e(e.fsAdapter);r.register("updateProperty",(0,zt.createUpdatePropertyService)(e.fsAdapter,t,n)),r.register("removeProperty",(0,zt.createRemovePropertyService)(e.fsAdapter,t,n)),r.register("setStatus",(0,zt.createSetStatusService)(e.fsAdapter,t,n)),r.register("createAsset",(0,zt.createCreateAssetService)(e.vaultAdapter,e.fsAdapter,L0e(e.vaultAdapter))),r.register("instantiatePrototypeSubtree",(0,zt.createInstantiatePrototypeSubtreeService)(e.vaultAdapter,e.fsAdapter))}r.register("createRelatedTask",(0,zt.createCreateRelatedTaskService)(e.vaultAdapter,e.genericAssetCreationService)),r.register("createRelatedProject",(0,zt.createCreateRelatedProjectService)(e.vaultAdapter,e.genericAssetCreationService)),r.register("archiveAsset",(0,zt.createArchiveAssetService)(e.vaultAdapter,e.archiveAssetService)),r.register("planForEvening",(0,zt.createPlanForEveningService)(e.vaultAdapter,e.taskStatusService)),r.register("cleanProperties",(0,zt.createCleanPropertiesService)(e.vaultAdapter,e.propertyCleanupService)),r.register("renameToUid",(0,zt.createRenameToUidService)(e.vaultAdapter,e.renameToUidService)),r.register("repairFolder",(0,zt.createRepairFolderService)(e.vaultAdapter,e.folderRepairService)),r.register("fixMissingLabel",(0,zt.createFixMissingLabelService)(e.vaultAdapter,e.fixMissingLabelService))}}a(z7,"populateCliServiceRegistry");Ba();function N0e(r,e){let t=r.getAbstractFileByPath(e),n=t!==null&&"basename"in t?t:null,i=n?r.getFrontmatter(n):null,s=i&&typeof i=="object"?i.exo__Asset_label:void 0;return{uuid:n?.basename??e.replace(/^.*\//,"").replace(/\.md$/,""),path:e,label:typeof s=="string"?s:""}}a(N0e,"buildCreatedAsset");var k0e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function M0e(){if(process.stdin.isTTY)return[];let r=[];for await(let t of process.stdin)r.push(t);return Buffer.concat(r).toString("utf-8").split(`
|
|
609
|
-
`).map(t=>t.trim()).filter(t=>t.length>0)}a(M0e,"readStdinLines");function Yw(r){if(r&&typeof r=="object"&&"value"in r){let e=r.value;return typeof e=="string"?e:String(e)}return String(r)}a(Yw,"nodeValue");async function j0e(r,e){let t=new De.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),n=await r.match(void 0,t,void 0),i=[];for(let s of n)if(Yw(s.object)===e){let l=Yw(s.subject).match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i);l&&i.push(l[1])}if(i.length===0)return null;if(i.length>1)throw new Ke(`Ambiguous cliName "${e}" \u2014 resolves to ${i.length} commands: ${i.join(", ")}`,"Use the UUID directly: exocortex apply <uuid> <path>");return i[0]}a(j0e,"resolveSlugToUuid");async function $0e(r,e){let t=new De.IRI("https://exocortex.my/ontology/exocmd#Command_destructive"),n=await r.match(void 0,t,void 0);for(let i of n)if(Yw(i.subject).includes(e)){let o=Yw(i.object);if(o==="true"||o==="True")return!0}return!1}a($0e,"isDestructive");async function U0e(r,e,t,n,i,s,o,c,l){let u={ok:!1,created:[],executed:!1},f=(0,Qa.resolve)(r,s);if(!(0,mP.existsSync)(f))return console.error(`\u274C Target file not found: ${s}`),u;let d=(0,Qa.relative)(r,f);if(d===".."||d.startsWith(`..${Qa.sep}`)||(0,Qa.isAbsolute)(d))return console.error(`\u274C Target is outside the vault: ${s} (vault: ${r})`),u;let p=new De.CommandResolver(e,Ow),h=await p.loadCommand(i);if(!h)return console.error(`\u274C Command with UID "${i}" not found.`),u;if(await $0e(e,i)&&!o.dryRun&&!o.yes)return console.error(`\u274C Command "${h.name}" is marked destructive. Add --dry-run to preview, or --yes to apply.`),u;let m=(0,De.vaultPathToIRI)(d),b=new Zt(r),_=new De.FolderRepairService(b),E=new De.PreconditionEvaluator(e,void 0,{clock:c});(0,De.registerDefaultHostFunctions)(E),E.registerHostFunction("isInWrongFolder",Rw(b,_)),E.registerHostFunction("hasObsoleteProperties",Cw(b));let I=b.getAbstractFileByPath(d),w=I!==null&&"basename"in I?I:null,S=w?b.getFrontmatter(w):null,R=S&&typeof S=="object"?S.exo__Asset_uid:void 0,P={targetIRI:m,filePath:d,fileBasename:w?.basename,assetUid:typeof R=="string"?R:void 0};if(!await E.evaluate(h.precondition,m,P))return console.error(`\u274C Precondition not satisfied for "${h.name}" on "${d}".`),u;if(o.dryRun)return o.json||console.log(`\u{1F50D} Dry-run: would apply "${h.name}" to "${d}" (precondition passed).`),{ok:!0,created:[],executed:!1};let M=new De.ServiceRegistry,U=new De.GenericAssetCreationService(b).withDeterminism({clock:c,uidGenerator:l}),D=new De.ArchiveAssetService(b),Q=new De.PropertyCleanupService(b),ue=new De.FixMissingLabelService(b),$=new De.RenameToUidService(b),le=new De.TaskStatusService(b,new De.EffortStatusWorkflow,new De.StatusTimestampService(b));z7(M,{vaultAdapter:b,fsAdapter:n,genericAssetCreationService:U,archiveAssetService:D,taskStatusService:le,propertyCleanupService:Q,fixMissingLabelService:ue,renameToUidService:$,folderRepairService:_});let H=new De.NamedQueryRunner(new Jd(e,n),e),ie=new De.GroundingExecutor(n,n,M,(0,De.createVaultFrontmatterClassLabelResolver)(n),{clock:c,uidGenerator:l,workflowResolver:t,groundingLoader:a(ne=>p.loadGroundingByUid(ne),"groundingLoader"),templateLoader:a(async ne=>{let Ie=await n.findFileByUID(ne);return Ie?(0,De.stripTemplateFrontmatter)(await n.readFile(Ie)):null},"templateLoader"),namedQueryRunner:H,refToFolder:(0,De.createVaultFrontmatterRefToFolderResolver)(n),refToFrontmatter:(0,De.createVaultFrontmatterRefToFrontmatterResolver)(n)}),V;if(o.input)try{let ne=JSON.parse(o.input);if(typeof ne!="object"||ne===null||Array.isArray(ne))throw new Error("must be a JSON object");V=ne}catch(ne){let Ie=ne instanceof Error?ne.message:String(ne);return console.error(`\u274C --input: invalid JSON object (${Ie})`),u}let z=await ie.execute(h.grounding,m,d,V);if(z.success){let ne=[];z.openPath&&ne.push(z.openPath),z.createdPaths&&ne.push(...z.createdPaths);let Ie=[],Z=new Set;for(let Y of ne)Z.has(Y)||(Z.add(Y),Ie.push(N0e(b,Y)));if(!o.json){let Y=h.successMessage??`Applied "${h.name}" to "${d}".`,se=z.openPath??z.createdPaths?.[0],X=se?` \u2192 ${se}`:"";console.log(`\u2705 ${Y}${X}`)}return{ok:!0,created:Ie,executed:!0}}else return console.error(`\u274C "${h.name}" failed on "${d}": ${z.error}`),{ok:!1,created:[],executed:!0}}a(U0e,"executeOnTarget");function H7(){return new pe("apply").description("Apply an exocmd__Command to one or more vault assets (RFC 8e83442b T1.2). Pass a path arg or pipe paths via stdin.").argument("<cmd>","Command UUID or cliName slug").argument("[path]","Vault-relative path to target asset (omit to read paths from stdin)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--dry-run","Preview without writing").option("--yes","Skip destructive-command confirmation").option("--input <json>",`JSON userInput for a grounding. Value-setting commands need a value key, e.g. set-planned-start / set-scheduled-date: --input '{"value":"<ISO>"}'
|
|
609
|
+
`).map(t=>t.trim()).filter(t=>t.length>0)}a(M0e,"readStdinLines");function Yw(r){if(r&&typeof r=="object"&&"value"in r){let e=r.value;return typeof e=="string"?e:String(e)}return String(r)}a(Yw,"nodeValue");async function j0e(r,e){let t=new De.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),n=await r.match(void 0,t,void 0),i=[];for(let s of n)if(Yw(s.object)===e){let l=Yw(s.subject).match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i);l&&i.push(l[1])}if(i.length===0)return null;if(i.length>1)throw new Ke(`Ambiguous cliName "${e}" \u2014 resolves to ${i.length} commands: ${i.join(", ")}`,"Use the UUID directly: exocortex apply <uuid> <path>");return i[0]}a(j0e,"resolveSlugToUuid");async function $0e(r,e){let t=new De.IRI("https://exocortex.my/ontology/exocmd#Command_destructive"),n=await r.match(void 0,t,void 0);for(let i of n)if(Yw(i.subject).includes(e)){let o=Yw(i.object);if(o==="true"||o==="True")return!0}return!1}a($0e,"isDestructive");async function U0e(r,e,t,n,i,s,o,c,l){let u={ok:!1,created:[],executed:!1},f=(0,Qa.resolve)(r,s);if(!(0,mP.existsSync)(f))return console.error(`\u274C Target file not found: ${s}`),u;let d=(0,Qa.relative)(r,f);if(d===".."||d.startsWith(`..${Qa.sep}`)||(0,Qa.isAbsolute)(d))return console.error(`\u274C Target is outside the vault: ${s} (vault: ${r})`),u;let p=new De.CommandResolver(e,Ow),h=await p.loadCommand(i);if(!h)return console.error(`\u274C Command with UID "${i}" not found.`),u;if(await $0e(e,i)&&!o.dryRun&&!o.yes)return console.error(`\u274C Command "${h.name}" is marked destructive. Add --dry-run to preview, or --yes to apply.`),u;let m=(0,De.vaultPathToIRI)(d),b=new Zt(r),_=new De.FolderRepairService(b),E=new De.PreconditionEvaluator(e,void 0,{clock:c});(0,De.registerDefaultHostFunctions)(E),E.registerHostFunction("isInWrongFolder",Rw(b,_)),E.registerHostFunction("hasObsoleteProperties",Cw(b));let I=b.getAbstractFileByPath(d),w=I!==null&&"basename"in I?I:null,S=w?b.getFrontmatter(w):null,R=S&&typeof S=="object"?S.exo__Asset_uid:void 0,P={targetIRI:m,filePath:d,fileBasename:w?.basename,assetUid:typeof R=="string"?R:void 0};if(!await E.evaluate(h.precondition,m,P))return console.error(`\u274C Precondition not satisfied for "${h.name}" on "${d}".`),u;if(o.dryRun)return o.json||console.log(`\u{1F50D} Dry-run: would apply "${h.name}" to "${d}" (precondition passed).`),{ok:!0,created:[],executed:!1};let M=new De.ServiceRegistry,U=new De.GenericAssetCreationService(b).withDeterminism({clock:c,uidGenerator:l}),D=new De.ArchiveAssetService(b),Q=new De.PropertyCleanupService(b),ue=new De.FixMissingLabelService(b),$=new De.RenameToUidService(b),le=new De.TaskStatusService(b,new De.EffortStatusWorkflow,new De.StatusTimestampService(b));z7(M,{vaultAdapter:b,fsAdapter:n,genericAssetCreationService:U,archiveAssetService:D,taskStatusService:le,propertyCleanupService:Q,fixMissingLabelService:ue,renameToUidService:$,folderRepairService:_});let H=new De.NamedQueryRunner(new Jd(e,n),e),ie=new De.GroundingExecutor(n,n,M,(0,De.createVaultFrontmatterClassLabelResolver)(n),{clock:c,uidGenerator:l,workflowResolver:t,groundingLoader:a(ne=>p.loadGroundingByUid(ne),"groundingLoader"),templateLoader:a(async ne=>{let Ie=await n.findFileByUID(ne);return Ie?(0,De.stripTemplateFrontmatter)(await n.readFile(Ie)):null},"templateLoader"),namedQueryRunner:H,refToFolder:(0,De.createVaultFrontmatterRefToFolderResolver)(n),refToFrontmatter:(0,De.createVaultFrontmatterRefToFrontmatterResolver)(n)}),V;if(o.input)try{let ne=JSON.parse(o.input);if(typeof ne!="object"||ne===null||Array.isArray(ne))throw new Error("must be a JSON object");V=ne}catch(ne){let Ie=ne instanceof Error?ne.message:String(ne);return console.error(`\u274C --input: invalid JSON object (${Ie})`),u}let z=await ie.execute(h.grounding,m,d,V);if(z.success){let ne=[];z.openPath&&ne.push(z.openPath),z.createdPaths&&ne.push(...z.createdPaths);let Ie=[],Z=new Set;for(let Y of ne)Z.has(Y)||(Z.add(Y),Ie.push(N0e(b,Y)));if(!o.json){let Y=h.successMessage??`Applied "${h.name}" to "${d}".`,se=z.openPath??z.createdPaths?.[0],X=se?` \u2192 ${se}`:"";console.log(`\u2705 ${Y}${X}`)}return{ok:!0,created:Ie,executed:!0}}else return console.error(`\u274C "${h.name}" failed on "${d}": ${z.error}`),{ok:!1,created:[],executed:!0}}a(U0e,"executeOnTarget");function H7(){return new pe("apply").description("Apply an exocmd__Command to one or more vault assets (RFC 8e83442b T1.2). Pass a path arg or pipe paths via stdin.").argument("<cmd>","Command UUID or cliName slug").argument("[path]","Vault-relative path to target asset (omit to read paths from stdin)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--dry-run","Preview without writing").option("--yes","Skip destructive-command confirmation").option("--input <json>",`JSON userInput for a grounding. Value-setting commands need a value key, e.g. set-planned-start / set-scheduled-date: --input '{"value":"<ISO>"}'. A command whose grounding declares its own input key uses THAT key: set-label: --input '{"label":"New label"}'. Asset-reference inputs (set-parent: --input '{"parent":"<uid>"}'; set-blocker: --input '{"blocker":"<uid>"}') take a BARE uid; a copied [[uid]] or [[uid|alias]] is accepted and unwrapped, anything else that still looks like a link is refused. The required key is named in the error if omitted.`).option("--seed <uuid>","Deterministic UID seed for test/replay (uses seededUidGenerator)").option("--frozen-clock <iso>","Freeze clock to ISO timestamp for test/replay (uses frozenClock)").option("--json","Emit a machine-readable JSON result ({command,target,created:[{uuid,path,label}]}) instead of human-readable output").option("--use-cache","Use the persistent triple cache (hit / delta / rebuild) instead of a full vault parse; a mutation is picked up by the NEXT --use-cache process as a delta unless --write-through is also given").option("--write-through","With --use-cache: after a grounding executed, fold the mutation into the persistent cache in this process, so the next --use-cache process is a plain hit (the delta is paid by this writer instead of the next reader). Refused without --use-cache").action(async(r,e,t)=>{if(ce.setFormat("text"),t.writeThrough&&!t.useCache){process.stderr.write(`\u274C --write-through requires --use-cache (there is no cache to write through to without it); nothing was applied
|
|
610
610
|
`),process.exit(2);return}try{let n=(0,Qa.resolve)(t.vault);if(!(0,mP.existsSync)(n))throw new ke(n);Mw(n);let i=t.frozenClock?(0,De.frozenClock)(t.frozenClock):(0,De.liveClock)(),s=t.seed?(0,De.seededUidGenerator)(t.seed):(0,De.liveUidGenerator)(),o=t.useCache??!1,c=await hi(n,{useCache:o});o&&process.stderr.write(`${yu(c)}
|
|
611
611
|
`);let l=new De.InMemoryTripleStore;await l.addAll(c.triples);let u=new zw(n,{explicitTriples:c.triples.slice(0,c.explicitCount),zeroTriplePaths:c.zeroTriplePaths}),f=new De.WorkflowResolver(l),d;if(k0e.test(r))d=r;else{let _=await j0e(l,r);_||(console.error(`\u274C No command found with UUID or cliName "${r}".`),process.exit(3)),d=_}let p;if(e)p=[e];else if(p=await M0e(),p.length===0)throw new Ke("No target path provided and stdin is empty.","exocortex apply <uuid> <path> OR exocortex find ... | exocortex apply <uuid>");let h=0,g=0,m=!1,b=[];for(let _ of p){let E=await U0e(n,l,f,u,d,_,t,i,s);E.ok?h++:g++,E.executed&&(m=!0),b.push(...E.created)}if(o&&t.writeThrough&&m&&c.cacheManager){let _=await fO(c.cacheManager);process.stderr.write(`${dO(_)}
|
|
612
612
|
`)}if(p.length>1&&!t.json&&console.log(`
|
|
@@ -685,7 +685,7 @@ Next steps:
|
|
|
685
685
|
`).map(n=>n.trim()).filter(n=>n.length>0),t=e[e.length-1];if(t!==void 0)try{return JSON.parse(t)}catch{return}}a(E_e,"parseLastJsonLine");function Z8(r,e){return e.filter(t=>{let n=r[t];return typeof n!="string"||n.trim().length===0})}a(Z8,"missingStringFields");var gE=class{constructor(e){this.deps=e}static{a(this,"McpServer")}async handle(e){if(typeof e!="object"||e===null||Array.isArray(e))return{jsonrpc:"2.0",id:null,error:{code:J8,message:"Invalid request: expected a JSON-RPC object"}};let t=e.id,n=t===void 0;if(typeof e.method!="string")return n?null:{jsonrpc:"2.0",id:t??null,error:{code:J8,message:"Invalid request: missing method"}};if(n)return null;let i=t??null;switch(e.method){case"initialize":return{jsonrpc:"2.0",id:i,result:{protocolVersion:S_e,capabilities:{tools:{}},serverInfo:{name:"exocortex",version:this.deps.version}}};case"ping":return{jsonrpc:"2.0",id:i,result:{}};case"tools/list":return{jsonrpc:"2.0",id:i,result:{tools:Q8}};case"tools/call":return{jsonrpc:"2.0",id:i,result:await this.callTool(e.params??{})};default:return{jsonrpc:"2.0",id:i,error:{code:w_e,message:`Method not found: ${e.method}`}}}}async callTool(e){let t=e.name,n=e.arguments??{},i;if(t==="create_asset"){let c=Z8(n,["vault","class","label"]);if(c.length>0)return pp(`create_asset: missing required argument(s): ${c.join(", ")}`,!0);let l=K8(n);if(l!==null)return pp(`create_asset: ${l}`,!0);i=Y8(n)}else if(t==="create_effort"){let c=Z8(n,["vault","command","target"]);if(c.length>0)return pp(`create_effort: missing required argument(s): ${c.join(", ")}`,!0);i=X8(n)}else return pp(`Unknown tool: ${String(t)}`,!0);let s=await this.deps.runCli(i);if(s.exitCode!==0){let c=s.stderr.trim()||s.stdout.trim()||"(no diagnostic output)";return pp(`exocortex-cli exited ${s.exitCode}
|
|
686
686
|
${c}`,!0)}let o=E_e(s.stdout);return pp(o===void 0?s.stdout.trim():JSON.stringify(o))}};var rV=require("child_process");var v_e=32*1024*1024;function nV(r){return e=>new Promise(t=>{(0,rV.execFile)(process.execPath,[r,...e],{maxBuffer:v_e},(n,i,s)=>{let o=0;if(n){let c=n.code;o=typeof c=="number"?c:1}t({stdout:i,stderr:s,exitCode:o})})})}a(nV,"createSelfCliRunner");async function T_e(r,e,t){let n=(0,iV.createInterface)({input:e,crlfDelay:1/0});for await(let i of n){let s=i.trim();if(s.length===0)continue;let o;try{o=JSON.parse(s)}catch{t(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:eV,message:"Parse error: invalid JSON"}})+`
|
|
687
687
|
`);continue}let c;try{c=await r.handle(o)}catch(l){c={jsonrpc:"2.0",id:typeof o?.id=="string"||typeof o?.id=="number"?o.id:null,error:{code:tV,message:`Internal error: ${l instanceof Error?l.message:String(l)}`}}}c!==null&&t(JSON.stringify(c)+`
|
|
688
|
-
`)}}a(T_e,"runStdioServer");function sV(r){return new pe("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new gE({runCli:nV(t),version:r??"unknown"});await T_e(n,process.stdin,i=>process.stdout.write(i))})}a(sV,"mcpCommand");function yE(r){let e=new pe;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"16.241.
|
|
688
|
+
`)}}a(T_e,"runStdioServer");function sV(r){return new pe("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new gE({runCli:nV(t),version:r??"unknown"});await T_e(n,process.stdin,i=>process.stdout.write(i))})}a(sV,"mcpCommand");function yE(r){let e=new pe;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"16.241.13"),e.addCommand(j7()),e.addCommand(H7()),e.addCommand(P6()),e.addCommand(N6()),e.addCommand(n7()),e.addCommand(k6()),e.addCommand(V6()),e.addCommand(G6()),e.addCommand(f7()),e.addCommand(g7()),e.addCommand(C7()),e.addCommand(P7()),e.addCommand(F7()),e.addCommand(L7()),e.addCommand(N7()),e.addCommand(b8()),e.addCommand(w8()),e.addCommand(k8()),e.addCommand(j8()),e.addCommand(B8()),e.addCommand(V8()),e.addCommand(W8()),e.addCommand(R8()),e.addCommand(D8()),e.addCommand(z8()),e.addCommand(sV(r??"16.241.13")),e}a(yE,"createProgram");yE().parse();0&&(module.exports={createProgram});
|
|
689
689
|
/*! Bundled license information:
|
|
690
690
|
|
|
691
691
|
reflect-metadata/Reflect.js:
|
package/package.json
CHANGED