@kitelev/exocortex-cli 17.5.8 → 17.5.10

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 +4 -4
  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 v17.5.8
2
+ // @kitelev/exocortex-cli v17.5.10
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -241,7 +241,7 @@ aliases:
241
241
  ?instance exo:Asset_label ?label .
242
242
  }
243
243
  ORDER BY ?instance
244
- `,o=await this.sparqlService.query(s);return this.buildEnumValues(o)}buildEnumValues(e){let t=[],n=new Set;for(let i of e){let s=this.getBindingValue(i,"instance");if(!s||n.has(s))continue;n.add(s);let o=this.getBindingValue(i,"label")??s,l=`[[${this.fromFullIRI(s)}]]`;t.push({value:l,label:o})}return t}buildRankProperty(e){let t=OR.Namespace.fromPropertyKey(e);return t?`${t.namespace.prefix}__${t.localName}_rank`:null}normalizeClassName(e){return e.replace(/\[\[|\]\]/g,"").trim()}getBindingValue(e,t){let n=e.get(t);if(n!=null)return String(n)}toFullIRI(e){if(e.startsWith("http://")||e.startsWith("https://"))return e;let t=OR.Namespace.fromPropertyKey(e);return t?t.namespace.term(t.localName).value:e}fromFullIRI(e){let t=OR.Namespace.fromTermIRI(e);return t?`${t.namespace.prefix}__${t.localName}`:e}};Pa.EnumValueResolver=PR;Pa.EnumValueResolver=PR=mne([(0,yne.injectable)(),gne("design:paramtypes",[Object,Object])],PR)});var DR=T(Ns=>{"use strict";var bne=Ns&&Ns.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},_ne=Ns&&Ns.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Sne=Ns&&Ns.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(Ns,"__esModule",{value:!0});Ns.GenericAssetCreationService=void 0;var Cj=lt(),Yh=Ts(),wne=Ea(),Ene=mo(),vne=At(),xj=Zl(),Tne=oi(),Ao=zy(),Ane=Mh(),Ine=$b(),FR=class{static{a(this,"GenericAssetCreationService")}constructor(e){this.vault=e,this.clock=(0,Ane.liveClock)(),this.uidGen=(0,Ine.liveUidGenerator)()}withDeterminism(e){return e.clock&&(this.clock=e.clock),e.uidGenerator&&(this.uidGen=e.uidGenerator),this}async createAsset(e,t){let{folderPath:n,path:i,content:s}=this.buildAsset(e,t);return this.vault.getAbstractFileByPath(n)||await this.vault.createFolder(n),await this.vault.create(i,s)}buildAsset(e,t){let n=this.uidGen.next(),i=this.generateFrontmatter(e,t||[],n),s=e.declaredRanges,o=new Map;for(let d of Object.keys(e.propertyValues??{}))o.set((0,xj.canonicalYamlKey)(d),d);let c=wne.MetadataHelpers.buildFileContent(i,e.body,s===void 0?void 0:d=>s.get(o.get(d)??d)),l=e.folderPath||this.getDefaultFolderPath(e),u=`${n}.md`,f=l?`${l}/${u}`:u;return{uid:n,folderPath:l,path:f,frontmatter:i,content:c}}generateFrontmatter(e,t=[],n=this.uidGen.next()){let i={},s=new Map;for(let u of t)s.set(u.name,u.fieldType);i.exo__Asset_uid=n;let o=e.timezone?this.generateTimestampInTimezone(e.timezone):Yh.DateFormatter.toLocalTimestamp(this.clock.now());i.exo__Asset_createdAt=o,i.exo__Asset_updatedAt=o;let c=e.classRefForm==="uuid"&&e.classUid?e.classUid:e.className;i.exo__Instance_class=[this.formatWikilink(c)];let l=e.propertyValues?.exo__Instance_class;if(l!=null){let u=i.exo__Instance_class,f=Array.isArray(l)?l:[l];for(let d of f){if(d==null||String(d).trim()==="")continue;let p=this.formatWikilink(String(d));u.includes(p)||u.push(p)}}if(e.createdBy&&e.createdBy.trim()!==""&&(i.exo__Asset_createdBy=this.formatWikilink(e.createdBy.trim())),e.label&&e.label.trim()!==""){let u=e.label.trim();i.exo__Asset_label=u;let f=[u];if(e.aliases)for(let d of e.aliases)f.includes(d)||f.push(d);i.aliases=f}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(i,e),e.propertyValues)for(let[u,f]of Object.entries(e.propertyValues)){let d=(0,xj.canonicalYamlKey)(u);if(!(d==="exo__Asset_uid"||d==="exo__Asset_createdAt"||d==="exo__Asset_updatedAt"||d==="exo__Asset_createdBy"||d==="exo__Instance_class"||d==="exo__Asset_label"||d==="aliases")&&f!=null)if(e.shapeRegistry!==void 0)Array.isArray(f)?i[d]=f.map(p=>this.quoteWikilinkValue(String(p))):i[d]=this.formatPropertyValueWithCardinality(d,String(f),e.shapeRegistry);else{let p=s.get(d);i[d]=this.formatValue(f,p)}}return i}inheritParentContext(e,t){let n=t.parentMetadata||{},i=t.parentFile?.basename;if(t.className==="ems__Task"||t.className.startsWith("ems__Task")){let s=n.exo__Instance_class,c=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[c]=i?this.formatWikilink(i):null}if(t.className==="ems__Project"||t.className.startsWith("ems__Project")){let s=n.exo__Instance_class,c=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[c]=i?this.formatWikilink(i):null}if(n.exo__Asset_isDefinedBy){let s=n.exo__Asset_isDefinedBy;e.exo__Asset_isDefinedBy=typeof s=="string"?this.formatWikilink(s):s}}isAreaClass(e,t){if(!e)return!1;let n=Array.isArray(e)?e:[e],i=a(()=>null,"noopResolver");return n.some(s=>{let o=Ene.WikiLinkHelpers.resolveSymbolic(String(s),t??i);return o.includes("Area")||o.includes("ems__Area")})}getDefaultFolderPath(e){if(e.parentFile?.parent?.path)return e.parentFile.parent.path;let t={ems__Task:"tasks",ems__Project:"projects",ems__Area:"areas",ems__Meeting:"meetings",exo__Event:"events",ims__Concept:"concepts"};if(t[e.className])return t[e.className];for(let[n,i]of Object.entries(t))if(e.className.startsWith(n))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case Ao.PropertyFieldType.Text:return String(e);case Ao.PropertyFieldType.Wikilink:case Ao.PropertyFieldType.Reference:case Ao.PropertyFieldType.StatusSelect:case Ao.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case Ao.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case Ao.PropertyFieldType.Boolean:return this.formatBoolean(e);case Ao.PropertyFieldType.Date:case Ao.PropertyFieldType.DateTime:case Ao.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?Yh.DateFormatter.toLocalTimestamp(e):typeof e=="string"?e.startsWith("[[")||e.startsWith('"[[')?this.formatWikilink(e):e:String(e)}formatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:`"[[${e}]]"`}formatBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"}return typeof e=="number"?e!==0:!!e}formatTimestamp(e){if(e instanceof Date)return Yh.DateFormatter.toLocalTimestamp(e);if(typeof e=="string"){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e))return e;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e.replace("Z","");let t=new Date(e);return isNaN(t.getTime())?e:Yh.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return Yh.DateFormatter.toLocalTimestamp(t)}return String(e)}formatPropertyValueWithCardinality(e,t,n){let i=this.quoteWikilinkValue(t);return i.includes("[[")&&this.shouldEmitAsArray(e,n)?[i]:i}quoteWikilinkValue(e){return e.includes("[[")?e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`:e}shouldEmitAsArray(e,t){if(!t)return!1;let n=vne.Namespace.fromPropertyKey(e);if(!n)return!1;let i=n.namespace.term(n.localName).value;return t.get(i)?.cardinality==="Multiple"}generateTimestampInTimezone(e){let t=this.clock.now(),i=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t),s=a(o=>i.find(c=>c.type===o)?.value||"00","get");return`${s("year")}-${s("month")}-${s("day")}T${s("hour")}:${s("minute")}:${s("second")}`}};Ns.GenericAssetCreationService=FR;Ns.GenericAssetCreationService=FR=bne([(0,Cj.injectable)(),Sne(0,(0,Cj.inject)(Tne.DI_TOKENS.IVaultAdapter)),_ne("design:paramtypes",[Object])],FR)});var Pj=T(ks=>{"use strict";var Rne=ks&&ks.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Cne=ks&&ks.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},xne=ks&&ks.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(ks,"__esModule",{value:!0});ks.ArchiveAssetService=void 0;var Oj=lt(),One=oi(),Pne=eu(),LR=class{static{a(this,"ArchiveAssetService")}constructor(e){this.vault=e,this.frontmatterService=new Pne.FrontmatterService}async archiveAsset(e){let t=await this.vault.read(e),n=this.frontmatterService.updateProperty(t,"exo__Asset_archived","true");n=this.frontmatterService.removeProperty(n,"aliases"),n!==t&&await this.vault.modify(e,n)}};ks.ArchiveAssetService=LR;ks.ArchiveAssetService=LR=Rne([(0,Oj.injectable)(),xne(0,(0,Oj.inject)(One.DI_TOKENS.IVaultAdapter)),Cne("design:paramtypes",[Object])],LR)});var Dj=T(Ms=>{"use strict";var Fne=Ms&&Ms.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Dne=Ms&&Ms.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Lne=Ms&&Ms.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(Ms,"__esModule",{value:!0});Ms.FixMissingLabelService=void 0;var Fj=lt(),Nne=oi(),kne=eu(),NR=class{static{a(this,"FixMissingLabelService")}constructor(e){this.vault=e,this.frontmatterService=new kne.FrontmatterService}async fixMissingLabel(e){let t=await this.vault.read(e);if(this.hasNonEmptyLabel(t))return;let n=this.frontmatterService.updateProperty(t,"exo__Asset_label",e.basename);n!==t&&await this.vault.modify(e,n)}hasNonEmptyLabel(e){let t=this.frontmatterService.parse(e);if(!t.exists)return!1;let n=t.content.match(/^exo__Asset_label:\s*(.*)$/m);if(!n)return!1;let i=n[1].trim();return!(i===""||i==='""'||i==="''")}};Ms.FixMissingLabelService=NR;Ms.FixMissingLabelService=NR=Fne([(0,Fj.injectable)(),Lne(0,(0,Fj.inject)(Nne.DI_TOKENS.IVaultAdapter)),Dne("design:paramtypes",[Object])],NR)});var Lj=T(Da=>{"use strict";var Mne=Da&&Da.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},jne=Da&&Da.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(Da,"__esModule",{value:!0});Da.GraphQueryService=void 0;var $ne=lt(),Xh=De(),Une=He(),Fa=At(),Bne=qv(),js={INSTANCE_CLASS:Fa.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Fa.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Fa.Namespace.EXO.term("Asset_prototype"),ASSET_ARCHIVED:Fa.Namespace.EXO.term("Asset_archived"),ASSET_IS_ARCHIVED:Fa.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Fa.Namespace.EMS.term("Effort_parent"),REFERENCES:Fa.Namespace.EXO.term("references"),REFERENCED_BY:Fa.Namespace.EXO.term("referencedBy"),RDF_TYPE:Fa.Namespace.RDF.term("type")},kR=class{static{a(this,"GraphQueryService")}constructor(e,t={},n){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.logger=n,this.config={defaultLimit:t.defaultLimit??100,maxLimit:t.maxLimit??1e4,defaultDepth:t.defaultDepth??2,maxDepth:t.maxDepth??10,includeArchivedByDefault:t.includeArchivedByDefault??!1,cacheTTL:t.cacheTTL??3e4}}async loadGraphData(e={}){let t=Date.now(),n=await this.loadNodes(e),i=await this.loadEdges(n,e),s=this.computeStats(n,i),o=Date.now()-t;return o>100&&n.length>0&&this.logger?.debug(`GraphQueryService: loaded ${n.length} nodes in ${o}ms (${(o/n.length).toFixed(2)}ms/node)`),{nodes:n,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),n=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:n}),s=i.length>t,o=s?i.slice(0,t):i,c=await this.loadEdges(o,e);return{nodes:o,edges:c,hasMore:s,totalCount:void 0,cursor:s?String(n+t):void 0}}async loadConnectedNodes(e,t={}){let n=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,o=[{id:e,currentDepth:0}],c=[];for(;o.length>0&&c.length<i;){let u=o.shift();if(!u)break;let{id:f,currentDepth:d}=u;if(s.has(f))continue;s.add(f);let p=await this.getNodeById(f,t);if(p&&(c.push(p),d<n)){let h=await this.getConnectedNodeIds(f);for(let g of h)s.has(g)||o.push({id:g,currentDepth:d+1})}}let l=await this.loadEdges(c,t);return{nodes:c,edges:l,hasMore:o.length>0,totalCount:s.size+o.length}}async getNodeById(e,t={}){let n=this.getCachedNode(e);if(n)return{...n};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let o=this.triplesToNode(e,s,t);return o&&this.cacheNode(o),o}subscribe(e){return this.subscribers.add(e),{unsubscribe:a(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(n){this.logger?.error("GraphQueryService: error in subscriber callback",n instanceof Error?n:new Error(String(n)))}this.invalidateCache()}async getStats(){let e=await this.loadNodes({includeArchived:!0}),t=await this.loadEdges(e,{});return this.computeStats(e,t)}clearCache(){this.nodeCache.clear(),this.lastCacheUpdate=0}async loadNodes(e){let t=e.includeArchived??this.config.includeArchivedByDefault,n=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,js.INSTANCE_CLASS,void 0),o=s;if(e.classes&&e.classes.length>0){let h=new Set(e.classes);o=s.filter(g=>{let m=this.getObjectValue(g.object);return m&&h.has(m)})}let c=new Set;for(let h of o)c.add(this.subjectToId(h.subject));let f=Array.from(c).slice(i,i+n).map(h=>this.getNodeById(h,e));return(await Promise.all(f)).filter(h=>!(!h||!t&&h.isArchived))}async loadEdges(e,t){let n=new Set(e.map(o=>o.id)),i=[],s=new Set;for(let o of e){let c=this.idToIRI(o.id),l=await this.tripleStore.match(c,void 0,void 0);for(let u of l){let f=this.tripleToEdge(o.id,u,n);f&&f.id&&!s.has(f.id)&&(!t.edgeTypes||t.edgeTypes.includes(f.type))&&(s.add(f.id),i.push(f))}}return i}async getConnectedNodeIds(e){let t=this.idToIRI(e),n=[],i=await this.tripleStore.match(t,void 0,void 0);for(let o of i){let c=this.objectToId(o.object);c&&n.push(c)}let s=await this.tripleStore.match(void 0,void 0,t);for(let o of s)n.push(this.subjectToId(o.subject));return[...new Set(n)]}triplesToNode(e,t,n){let i={},s,o,c,l,u=!1;for(let p of t){let h=p.predicate.value,g=this.getObjectValue(p.object);if(h===js.INSTANCE_CLASS.value)s=g;else if(h===js.ASSET_LABEL.value)o=g;else if(h===js.ASSET_PROTOTYPE.value)c=this.objectToId(p.object)??g;else if(h===js.EFFORT_PARENT.value)l=this.objectToId(p.object)??g;else if(h===js.ASSET_ARCHIVED.value||h===js.ASSET_IS_ARCHIVED.value)u=u||g==="true"||g==="1";else{let m=this.predicateToPropertyName(h);m&&(i[m]=g)}}if(u&&!(n.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),d=o??this.pathToTitle(f);return{id:e,path:f,title:d,label:d,assetClass:s,isArchived:u,uri:e.startsWith("http")?e:void 0,prototype:c,parent:l,properties:Object.keys(i).length>0?i:void 0}}tripleToEdge(e,t,n){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!n.has(s)||s===e)return null;let o=this.predicateToEdgeType(i);if(!o)return null;let c=(0,Bne.createEdgeId)(e,s,o,i),l=this.predicateToLabel(i);return{id:c,source:e,target:s,type:o,predicate:i,label:l}}predicateToEdgeType(e){return e===js.EFFORT_PARENT.value?"hierarchy":e===js.ASSET_PROTOTYPE.value?"prototype":e===js.REFERENCES.value?"forward-link":e===js.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),n=e.lastIndexOf("/"),i=Math.max(t,n);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let n={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let c of e){let l=c.assetClass??"unknown";n[l]=(n[l]??0)+1}for(let c of t)i[c.type]=(i[c.type]??0)+1;let s=new Map,o=new Map;for(let c of t)o.set(c.source,(o.get(c.source)??0)+1),s.set(c.target,(s.get(c.target)??0)+1);for(let c of e)c.inDegree=s.get(c.id)??0,c.outDegree=o.get(c.id)??0,c.weight=c.inDegree+c.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:n,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new Xh.IRI(e):new Xh.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof Xh.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof Xh.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof Une.Literal||e instanceof Xh.IRI)return e.value}idToPath(e){if(e.startsWith("obsidian://vault/"))return decodeURIComponent(e.replace("obsidian://vault/",""));if(e.startsWith("http://")||e.startsWith("https://")){let t=e.match(/\/([^/]+\.md)$/);if(t)return t[1]}return e}pathToTitle(e){return(e.split("/").pop()??e).replace(/\.md$/,"")}getCachedNode(e){return Date.now()-this.lastCacheUpdate>this.config.cacheTTL?(this.clearCache(),null):this.nodeCache.get(e)??null}cacheNode(e){this.nodeCache.set(e.id,e),this.lastCacheUpdate===0&&(this.lastCacheUpdate=Date.now())}invalidateCache(){this.clearCache()}};Da.GraphQueryService=kR;Da.GraphQueryService=kR=Mne([(0,$ne.injectable)(),jne("design:paramtypes",[Object,Object,Object])],kR)});var kj=T(La=>{"use strict";var Vne=La&&La.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Gne=La&&La.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(La,"__esModule",{value:!0});La.TypeRegistry=void 0;var qne=lt(),Io=De(),Nj=sr(),Wne=He(),zne=ru(),kt=Wv(),MR=class{static{a(this,"TypeRegistry")}constructor(e=null,t={}){this.nodeTypes=new Map,this.edgeTypes=new Map,this.typeHierarchy=new Map,this.subscribers=new Set,this.discoveryComplete=!1,this.tripleStore=e,this.config={autoDiscoverTypes:t.autoDiscoverTypes??!0,includeBuiltInStyles:t.includeBuiltInStyles??!0,styleResolution:t.styleResolution??{mergeStyles:!0,inheritParentStyles:!0,defaultNodeStyle:kt.DEFAULT_NODE_STYLE,defaultEdgeStyle:kt.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let n=this.nodeTypes.get(e.uri)?"type-updated":"type-added";this.nodeTypes.set(e.uri,e),e.parentTypes&&e.parentTypes.length>0&&this.typeHierarchy.set(e.uri,e.parentTypes),this.emit({type:n,typeUri:e.uri,definition:e})}registerEdgeType(e){let n=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:n,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),n=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||n)&&this.emit({type:"type-removed",typeUri:e})}getNodeType(e){return this.nodeTypes.get(e)}getEdgeType(e){return this.edgeTypes.get(e)}getAllNodeTypes(){return Array.from(this.nodeTypes.values())}getAllEdgeTypes(){return Array.from(this.edgeTypes.values())}getParentTypes(e,t=this.config.maxInheritanceDepth){let n=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let o=s.shift();if(!o)break;let{uri:c,currentDepth:l}=o;if(i.has(c)||(i.add(c),l>=t))continue;let u=this.typeHierarchy.get(c)??[];for(let f of u)i.has(f)||(n.push(f),s.push({uri:f,currentDepth:l+1}))}return n}getChildTypes(e){let t=[];for(let[n,i]of this.typeHierarchy)i.includes(e)&&t.push(n);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],n="unknown",i="custom";if(e.assetClass){let c=this.normalizeTypeUri(e.assetClass);t.push(c),n=c,i="exo:Instance_class"}let s=e.properties?.[kt.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),n==="unknown"&&(n=s,i="rdf:type"));for(let c of[...t]){let l=this.getParentTypes(c);for(let u of l)t.includes(u)||t.push(u)}let o=this.resolveNodeStyle(t);return{primaryType:n,types:t,resolvedStyle:o,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,n=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:n}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:n}=this.config.styleResolution,i={...n},s=[];for(let o of e){let c=this.nodeTypes.get(o);c&&s.push(c)}if(s.sort((o,c)=>o.priority-c.priority),t)for(let o of s)i=(0,kt.mergeNodeStyles)(i,o.style);else if(s.length>0){let o=s[s.length-1];i=(0,kt.mergeNodeStyles)(i,o.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,n={...t},i=this.edgeTypes.get(e);return i&&(n=(0,kt.mergeEdgeStyles)(n,i.style)),n}filterNodes(e,t){return e.filter(n=>{let i=this.resolveNodeType(n);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(n=>{let i=n.predicate??n.type;return!(t.includeEdgeTypes&&t.includeEdgeTypes.length>0&&!t.includeEdgeTypes.includes(i)||t.excludeEdgeTypes&&t.excludeEdgeTypes.length>0&&t.excludeEdgeTypes.includes(i))})}groupNodesByType(e,t,n={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:o=0,maxGroups:c=20,customGroupFn:l}=n,u=new Map;for(let p of e){let h=this.resolveNodeType(p),g;if(l?g=l(h.types):s&&h.types.length>o?g=h.types[o]??h.primaryType:i?g=h.primaryType:g="all",!u.has(g)){let _=this.nodeTypes.get(g)?.label??(0,kt.extractLocalName)(g);u.set(g,{nodeIds:new Set,label:_})}let m=u.get(g);m&&m.nodeIds.add(p.id)}let f=Array.from(u.entries()).map(([p,h])=>({id:p,label:h.label,nodeIds:Array.from(h.nodeIds)}));if(f.length>c){f.sort((g,m)=>m.nodeIds.length-g.nodeIds.length);let p=f.slice(0,c-1),h=f.slice(c-1).flatMap(g=>g.nodeIds);p.push({id:"other",label:"Other",nodeIds:h}),f=p}let d=new Map;for(let p of f)for(let h of p.nodeIds)d.set(h,p.id);return f.map((p,h)=>{let g=new Set(p.nodeIds),m=[],b=[];for(let A of t){let E=g.has(A.source),w=g.has(A.target);E&&w?A.id&&m.push(A.id):(E||w)&&A.id&&b.push(A.id)}let S=`hsl(${h*137.5%360}, 70%, 50%)`;return{id:p.id,label:p.label,nodeIds:p.nodeIds,internalEdgeIds:m,externalEdgeIds:b,color:S,stats:{nodeCount:p.nodeIds.length,internalEdgeCount:m.length,externalEdgeCount:b.length}}})}validateTypes(e,t){let n=[],i=[];for(let s of e){let o=this.resolveNodeType(s);if(o.primaryType!=="unknown"){let c=this.nodeTypes.get(o.primaryType);!c&&o.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${o.primaryType}" is not registered`,elementId:s.id,suggestion:"Register the type with registerNodeType()"}),c?.deprecated&&i.push({code:"DEPRECATED_NODE_TYPE",message:`Node uses deprecated type "${o.primaryType}"`,elementId:s.id,suggestion:"Migrate to a non-deprecated type"})}else i.push({code:"MISSING_NODE_TYPE",message:"Node has no type information",elementId:s.id,suggestion:"Add exo:Instance_class or rdf:type to the node"})}for(let s of t){let o=s.predicate??s.type,c=this.edgeTypes.get(o);if(c?.domain&&c.domain.length>0){let l=e.find(u=>u.id===s.source);if(l){let u=this.resolveNodeType(l);c.domain.some(d=>u.types.includes(d))||n.push({code:"DOMAIN_VIOLATION",message:"Edge source does not match expected domain",elementId:s.id,expected:c.domain,actual:u.types})}}if(c?.range&&c.range.length>0){let l=e.find(u=>u.id===s.target);if(l){let u=this.resolveNodeType(l);c.range.some(d=>u.types.includes(d))||n.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:c.range,actual:u.types})}}}return{valid:n.length===0,errors:n,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new Io.IRI(kt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let n of e){let i=this.getObjectValue(n.object);if(i&&(0,kt.isClassType)(i)){let s=this.getSubjectValue(n.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let n of t){let i=this.getSubjectValue(n.subject),s=this.getObjectValue(n.object);if(i&&s){let o=this.typeHierarchy.get(i)??[];if(!o.includes(s)){o.push(s),this.typeHierarchy.set(i,o);let c=this.nodeTypes.get(i);c&&(c.parentTypes=o)}}}this.discoveryComplete=!0,this.emit({type:"hierarchy-updated",rootTypes:this.getRootTypes()})}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}clear(){this.nodeTypes.clear(),this.edgeTypes.clear(),this.typeHierarchy.clear(),this.discoveryComplete=!1,this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerBuiltInTypes(){for(let[e,t]of Object.entries(kt.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,kt.extractLocalName)(e),source:"custom",style:(0,kt.mergeNodeStyles)(kt.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(kt.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,kt.extractLocalName)(e),source:"custom",style:(0,kt.mergeEdgeStyles)(kt.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),n=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,kt.extractLocalName)(e):(0,kt.extractLocalName)(e),s=n.length>0?this.getObjectValue(n[0].object):void 0,o="rdfs:Class",c=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of c)if(this.getObjectValue(f.object)===kt.RDF_TYPE_PREDICATES.OWL_CLASS){o="owl:Class";break}let l=kt.BUILT_IN_NODE_STYLES[e]??kt.BUILT_IN_NODE_STYLES[(0,kt.extractLocalName)(e)],u={uri:e,label:i,description:s,source:o,style:(0,kt.mergeNodeStyles)(kt.DEFAULT_NODE_STYLE,l??{}),priority:1};this.registerNodeType(u)}normalizeTypeUri(e){let t=e.match(/^\[\[(.+?)\]\]$/);return t?t[1]:e}getSubjectValue(e){if(e instanceof Io.IRI)return e.value;if(e instanceof Nj.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof Wne.Literal||e instanceof Io.IRI)return e.value;if(e instanceof Nj.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let n of this.typeHierarchy.values())for(let i of n)e.add(i);let t=[];for(let n of this.nodeTypes.keys()){let i=this.typeHierarchy.get(n);(!i||i.length===0)&&e.has(n)&&t.push(n)}return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(n){zne.LoggingService.error("TypeRegistry: error in subscriber callback",n instanceof Error?n:new Error(String(n)))}}};La.TypeRegistry=MR;La.TypeRegistry=MR=Vne([(0,qne.injectable)(),Gne("design:paramtypes",[Object,Object])],MR)});var Mj=T(E_=>{"use strict";Object.defineProperty(E_,"__esModule",{value:!0});E_.SPARQL_PREFIXES=void 0;E_.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
244
+ `,o=await this.sparqlService.query(s);return this.buildEnumValues(o)}buildEnumValues(e){let t=[],n=new Set;for(let i of e){let s=this.getBindingValue(i,"instance");if(!s||n.has(s))continue;n.add(s);let o=this.getBindingValue(i,"label")??s,l=`[[${this.fromFullIRI(s)}]]`;t.push({value:l,label:o})}return t}buildRankProperty(e){let t=OR.Namespace.fromPropertyKey(e);return t?`${t.namespace.prefix}__${t.localName}_rank`:null}normalizeClassName(e){return e.replace(/\[\[|\]\]/g,"").trim()}getBindingValue(e,t){let n=e.get(t);if(n!=null)return String(n)}toFullIRI(e){if(e.startsWith("http://")||e.startsWith("https://"))return e;let t=OR.Namespace.fromPropertyKey(e);return t?t.namespace.term(t.localName).value:e}fromFullIRI(e){let t=OR.Namespace.fromTermIRI(e);return t?`${t.namespace.prefix}__${t.localName}`:e}};Pa.EnumValueResolver=PR;Pa.EnumValueResolver=PR=mne([(0,yne.injectable)(),gne("design:paramtypes",[Object,Object])],PR)});var DR=T(Ns=>{"use strict";var bne=Ns&&Ns.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},_ne=Ns&&Ns.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Sne=Ns&&Ns.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(Ns,"__esModule",{value:!0});Ns.GenericAssetCreationService=void 0;var Cj=lt(),Yh=Ts(),wne=Ea(),Ene=mo(),vne=At(),xj=Zl(),Tne=oi(),Ao=zy(),Ane=Mh(),Ine=$b(),FR=class{static{a(this,"GenericAssetCreationService")}constructor(e){this.vault=e,this.clock=(0,Ane.liveClock)(),this.uidGen=(0,Ine.liveUidGenerator)()}withDeterminism(e){return e.clock&&(this.clock=e.clock),e.uidGenerator&&(this.uidGen=e.uidGenerator),this}async createAsset(e,t){let{folderPath:n,path:i,content:s}=this.buildAsset(e,t);return this.vault.getAbstractFileByPath(n)||await this.vault.createFolder(n),await this.vault.create(i,s)}buildAsset(e,t){let n=this.uidGen.next(),i=this.generateFrontmatter(e,t||[],n),s=e.declaredRanges,o=new Map;for(let d of Object.keys(e.propertyValues??{}))o.set((0,xj.canonicalYamlKey)(d),d);let c=wne.MetadataHelpers.buildFileContent(i,e.body,s===void 0?void 0:d=>s.get(o.get(d)??d)),l=e.folderPath||this.getDefaultFolderPath(e),u=`${n}.md`,f=l?`${l}/${u}`:u;return{uid:n,folderPath:l,path:f,frontmatter:i,content:c}}generateFrontmatter(e,t=[],n=this.uidGen.next()){let i={},s=new Map;for(let u of t)s.set(u.name,u.fieldType);i.exo__Asset_uid=n;let o=e.timezone?this.generateTimestampInTimezone(e.timezone):Yh.DateFormatter.toLocalTimestamp(this.clock.now());i.exo__Asset_createdAt=o,i.exo__Asset_updatedAt=o;let c=e.classRefForm==="uuid"&&e.classUid?e.classUid:e.className;i.exo__Instance_class=[this.formatWikilink(c)];let l=e.propertyValues?.exo__Instance_class;if(l!=null){let u=i.exo__Instance_class,f=Array.isArray(l)?l:[l];for(let d of f){if(d==null||String(d).trim()==="")continue;let p=this.formatWikilink(String(d));u.includes(p)||u.push(p)}}if(e.createdBy&&e.createdBy.trim()!==""&&(i.exo__Asset_createdBy=this.formatWikilink(e.createdBy.trim())),e.label&&e.label.trim()!==""){let u=e.label.trim();i.exo__Asset_label=u;let f=[u];if(e.aliases)for(let d of e.aliases)f.includes(d)||f.push(d);i.aliases=f}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(i,e),e.propertyValues)for(let[u,f]of Object.entries(e.propertyValues)){let d=(0,xj.canonicalYamlKey)(u);if(!(d==="exo__Asset_uid"||d==="exo__Asset_createdAt"||d==="exo__Asset_updatedAt"||d==="exo__Asset_createdBy"||d==="exo__Instance_class"||d==="exo__Asset_label"||d==="aliases")&&f!=null)if(e.shapeRegistry!==void 0)Array.isArray(f)?i[d]=f.map(p=>this.quoteWikilinkValue(String(p))):i[d]=this.formatPropertyValueWithCardinality(d,String(f),e.shapeRegistry);else{let p=s.get(d);i[d]=this.formatValue(f,p)}}return i}inheritParentContext(e,t){let n=t.parentMetadata||{},i=t.parentFile?.basename;if(t.className==="ems__Task"||t.className.startsWith("ems__Task")){let s=n.exo__Instance_class,c=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[c]=i?this.formatWikilink(i):null}if(t.className==="ems__Project"||t.className.startsWith("ems__Project")){let s=n.exo__Instance_class,c=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[c]=i?this.formatWikilink(i):null}if(n.exo__Asset_isDefinedBy){let s=n.exo__Asset_isDefinedBy;e.exo__Asset_isDefinedBy=typeof s=="string"?this.formatWikilink(s):s}}isAreaClass(e,t){if(!e)return!1;let n=Array.isArray(e)?e:[e],i=a(()=>null,"noopResolver");return n.some(s=>{let o=Ene.WikiLinkHelpers.resolveSymbolic(String(s),t??i);return o.includes("Area")||o.includes("ems__Area")})}getDefaultFolderPath(e){if(e.parentFile?.parent?.path)return e.parentFile.parent.path;let t={ems__Task:"tasks",ems__Project:"projects",ems__Area:"areas",ems__Meeting:"meetings",exo__Event:"events"};if(t[e.className])return t[e.className];for(let[n,i]of Object.entries(t))if(e.className.startsWith(n))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case Ao.PropertyFieldType.Text:return String(e);case Ao.PropertyFieldType.Wikilink:case Ao.PropertyFieldType.Reference:case Ao.PropertyFieldType.StatusSelect:case Ao.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case Ao.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case Ao.PropertyFieldType.Boolean:return this.formatBoolean(e);case Ao.PropertyFieldType.Date:case Ao.PropertyFieldType.DateTime:case Ao.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?Yh.DateFormatter.toLocalTimestamp(e):typeof e=="string"?e.startsWith("[[")||e.startsWith('"[[')?this.formatWikilink(e):e:String(e)}formatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:`"[[${e}]]"`}formatBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"}return typeof e=="number"?e!==0:!!e}formatTimestamp(e){if(e instanceof Date)return Yh.DateFormatter.toLocalTimestamp(e);if(typeof e=="string"){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e))return e;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e.replace("Z","");let t=new Date(e);return isNaN(t.getTime())?e:Yh.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return Yh.DateFormatter.toLocalTimestamp(t)}return String(e)}formatPropertyValueWithCardinality(e,t,n){let i=this.quoteWikilinkValue(t);return i.includes("[[")&&this.shouldEmitAsArray(e,n)?[i]:i}quoteWikilinkValue(e){return e.includes("[[")?e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`:e}shouldEmitAsArray(e,t){if(!t)return!1;let n=vne.Namespace.fromPropertyKey(e);if(!n)return!1;let i=n.namespace.term(n.localName).value;return t.get(i)?.cardinality==="Multiple"}generateTimestampInTimezone(e){let t=this.clock.now(),i=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t),s=a(o=>i.find(c=>c.type===o)?.value||"00","get");return`${s("year")}-${s("month")}-${s("day")}T${s("hour")}:${s("minute")}:${s("second")}`}};Ns.GenericAssetCreationService=FR;Ns.GenericAssetCreationService=FR=bne([(0,Cj.injectable)(),Sne(0,(0,Cj.inject)(Tne.DI_TOKENS.IVaultAdapter)),_ne("design:paramtypes",[Object])],FR)});var Pj=T(ks=>{"use strict";var Rne=ks&&ks.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Cne=ks&&ks.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},xne=ks&&ks.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(ks,"__esModule",{value:!0});ks.ArchiveAssetService=void 0;var Oj=lt(),One=oi(),Pne=eu(),LR=class{static{a(this,"ArchiveAssetService")}constructor(e){this.vault=e,this.frontmatterService=new Pne.FrontmatterService}async archiveAsset(e){let t=await this.vault.read(e),n=this.frontmatterService.updateProperty(t,"exo__Asset_archived","true");n=this.frontmatterService.removeProperty(n,"aliases"),n!==t&&await this.vault.modify(e,n)}};ks.ArchiveAssetService=LR;ks.ArchiveAssetService=LR=Rne([(0,Oj.injectable)(),xne(0,(0,Oj.inject)(One.DI_TOKENS.IVaultAdapter)),Cne("design:paramtypes",[Object])],LR)});var Dj=T(Ms=>{"use strict";var Fne=Ms&&Ms.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Dne=Ms&&Ms.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Lne=Ms&&Ms.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(Ms,"__esModule",{value:!0});Ms.FixMissingLabelService=void 0;var Fj=lt(),Nne=oi(),kne=eu(),NR=class{static{a(this,"FixMissingLabelService")}constructor(e){this.vault=e,this.frontmatterService=new kne.FrontmatterService}async fixMissingLabel(e){let t=await this.vault.read(e);if(this.hasNonEmptyLabel(t))return;let n=this.frontmatterService.updateProperty(t,"exo__Asset_label",e.basename);n!==t&&await this.vault.modify(e,n)}hasNonEmptyLabel(e){let t=this.frontmatterService.parse(e);if(!t.exists)return!1;let n=t.content.match(/^exo__Asset_label:\s*(.*)$/m);if(!n)return!1;let i=n[1].trim();return!(i===""||i==='""'||i==="''")}};Ms.FixMissingLabelService=NR;Ms.FixMissingLabelService=NR=Fne([(0,Fj.injectable)(),Lne(0,(0,Fj.inject)(Nne.DI_TOKENS.IVaultAdapter)),Dne("design:paramtypes",[Object])],NR)});var Lj=T(Da=>{"use strict";var Mne=Da&&Da.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},jne=Da&&Da.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(Da,"__esModule",{value:!0});Da.GraphQueryService=void 0;var $ne=lt(),Xh=De(),Une=He(),Fa=At(),Bne=qv(),js={INSTANCE_CLASS:Fa.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Fa.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Fa.Namespace.EXO.term("Asset_prototype"),ASSET_ARCHIVED:Fa.Namespace.EXO.term("Asset_archived"),ASSET_IS_ARCHIVED:Fa.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Fa.Namespace.EMS.term("Effort_parent"),REFERENCES:Fa.Namespace.EXO.term("references"),REFERENCED_BY:Fa.Namespace.EXO.term("referencedBy"),RDF_TYPE:Fa.Namespace.RDF.term("type")},kR=class{static{a(this,"GraphQueryService")}constructor(e,t={},n){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.logger=n,this.config={defaultLimit:t.defaultLimit??100,maxLimit:t.maxLimit??1e4,defaultDepth:t.defaultDepth??2,maxDepth:t.maxDepth??10,includeArchivedByDefault:t.includeArchivedByDefault??!1,cacheTTL:t.cacheTTL??3e4}}async loadGraphData(e={}){let t=Date.now(),n=await this.loadNodes(e),i=await this.loadEdges(n,e),s=this.computeStats(n,i),o=Date.now()-t;return o>100&&n.length>0&&this.logger?.debug(`GraphQueryService: loaded ${n.length} nodes in ${o}ms (${(o/n.length).toFixed(2)}ms/node)`),{nodes:n,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),n=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:n}),s=i.length>t,o=s?i.slice(0,t):i,c=await this.loadEdges(o,e);return{nodes:o,edges:c,hasMore:s,totalCount:void 0,cursor:s?String(n+t):void 0}}async loadConnectedNodes(e,t={}){let n=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,o=[{id:e,currentDepth:0}],c=[];for(;o.length>0&&c.length<i;){let u=o.shift();if(!u)break;let{id:f,currentDepth:d}=u;if(s.has(f))continue;s.add(f);let p=await this.getNodeById(f,t);if(p&&(c.push(p),d<n)){let h=await this.getConnectedNodeIds(f);for(let g of h)s.has(g)||o.push({id:g,currentDepth:d+1})}}let l=await this.loadEdges(c,t);return{nodes:c,edges:l,hasMore:o.length>0,totalCount:s.size+o.length}}async getNodeById(e,t={}){let n=this.getCachedNode(e);if(n)return{...n};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let o=this.triplesToNode(e,s,t);return o&&this.cacheNode(o),o}subscribe(e){return this.subscribers.add(e),{unsubscribe:a(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(n){this.logger?.error("GraphQueryService: error in subscriber callback",n instanceof Error?n:new Error(String(n)))}this.invalidateCache()}async getStats(){let e=await this.loadNodes({includeArchived:!0}),t=await this.loadEdges(e,{});return this.computeStats(e,t)}clearCache(){this.nodeCache.clear(),this.lastCacheUpdate=0}async loadNodes(e){let t=e.includeArchived??this.config.includeArchivedByDefault,n=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,js.INSTANCE_CLASS,void 0),o=s;if(e.classes&&e.classes.length>0){let h=new Set(e.classes);o=s.filter(g=>{let m=this.getObjectValue(g.object);return m&&h.has(m)})}let c=new Set;for(let h of o)c.add(this.subjectToId(h.subject));let f=Array.from(c).slice(i,i+n).map(h=>this.getNodeById(h,e));return(await Promise.all(f)).filter(h=>!(!h||!t&&h.isArchived))}async loadEdges(e,t){let n=new Set(e.map(o=>o.id)),i=[],s=new Set;for(let o of e){let c=this.idToIRI(o.id),l=await this.tripleStore.match(c,void 0,void 0);for(let u of l){let f=this.tripleToEdge(o.id,u,n);f&&f.id&&!s.has(f.id)&&(!t.edgeTypes||t.edgeTypes.includes(f.type))&&(s.add(f.id),i.push(f))}}return i}async getConnectedNodeIds(e){let t=this.idToIRI(e),n=[],i=await this.tripleStore.match(t,void 0,void 0);for(let o of i){let c=this.objectToId(o.object);c&&n.push(c)}let s=await this.tripleStore.match(void 0,void 0,t);for(let o of s)n.push(this.subjectToId(o.subject));return[...new Set(n)]}triplesToNode(e,t,n){let i={},s,o,c,l,u=!1;for(let p of t){let h=p.predicate.value,g=this.getObjectValue(p.object);if(h===js.INSTANCE_CLASS.value)s=g;else if(h===js.ASSET_LABEL.value)o=g;else if(h===js.ASSET_PROTOTYPE.value)c=this.objectToId(p.object)??g;else if(h===js.EFFORT_PARENT.value)l=this.objectToId(p.object)??g;else if(h===js.ASSET_ARCHIVED.value||h===js.ASSET_IS_ARCHIVED.value)u=u||g==="true"||g==="1";else{let m=this.predicateToPropertyName(h);m&&(i[m]=g)}}if(u&&!(n.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),d=o??this.pathToTitle(f);return{id:e,path:f,title:d,label:d,assetClass:s,isArchived:u,uri:e.startsWith("http")?e:void 0,prototype:c,parent:l,properties:Object.keys(i).length>0?i:void 0}}tripleToEdge(e,t,n){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!n.has(s)||s===e)return null;let o=this.predicateToEdgeType(i);if(!o)return null;let c=(0,Bne.createEdgeId)(e,s,o,i),l=this.predicateToLabel(i);return{id:c,source:e,target:s,type:o,predicate:i,label:l}}predicateToEdgeType(e){return e===js.EFFORT_PARENT.value?"hierarchy":e===js.ASSET_PROTOTYPE.value?"prototype":e===js.REFERENCES.value?"forward-link":e===js.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),n=e.lastIndexOf("/"),i=Math.max(t,n);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let n={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let c of e){let l=c.assetClass??"unknown";n[l]=(n[l]??0)+1}for(let c of t)i[c.type]=(i[c.type]??0)+1;let s=new Map,o=new Map;for(let c of t)o.set(c.source,(o.get(c.source)??0)+1),s.set(c.target,(s.get(c.target)??0)+1);for(let c of e)c.inDegree=s.get(c.id)??0,c.outDegree=o.get(c.id)??0,c.weight=c.inDegree+c.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:n,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new Xh.IRI(e):new Xh.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof Xh.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof Xh.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof Une.Literal||e instanceof Xh.IRI)return e.value}idToPath(e){if(e.startsWith("obsidian://vault/"))return decodeURIComponent(e.replace("obsidian://vault/",""));if(e.startsWith("http://")||e.startsWith("https://")){let t=e.match(/\/([^/]+\.md)$/);if(t)return t[1]}return e}pathToTitle(e){return(e.split("/").pop()??e).replace(/\.md$/,"")}getCachedNode(e){return Date.now()-this.lastCacheUpdate>this.config.cacheTTL?(this.clearCache(),null):this.nodeCache.get(e)??null}cacheNode(e){this.nodeCache.set(e.id,e),this.lastCacheUpdate===0&&(this.lastCacheUpdate=Date.now())}invalidateCache(){this.clearCache()}};Da.GraphQueryService=kR;Da.GraphQueryService=kR=Mne([(0,$ne.injectable)(),jne("design:paramtypes",[Object,Object,Object])],kR)});var kj=T(La=>{"use strict";var Vne=La&&La.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Gne=La&&La.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(La,"__esModule",{value:!0});La.TypeRegistry=void 0;var qne=lt(),Io=De(),Nj=sr(),Wne=He(),zne=ru(),kt=Wv(),MR=class{static{a(this,"TypeRegistry")}constructor(e=null,t={}){this.nodeTypes=new Map,this.edgeTypes=new Map,this.typeHierarchy=new Map,this.subscribers=new Set,this.discoveryComplete=!1,this.tripleStore=e,this.config={autoDiscoverTypes:t.autoDiscoverTypes??!0,includeBuiltInStyles:t.includeBuiltInStyles??!0,styleResolution:t.styleResolution??{mergeStyles:!0,inheritParentStyles:!0,defaultNodeStyle:kt.DEFAULT_NODE_STYLE,defaultEdgeStyle:kt.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let n=this.nodeTypes.get(e.uri)?"type-updated":"type-added";this.nodeTypes.set(e.uri,e),e.parentTypes&&e.parentTypes.length>0&&this.typeHierarchy.set(e.uri,e.parentTypes),this.emit({type:n,typeUri:e.uri,definition:e})}registerEdgeType(e){let n=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:n,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),n=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||n)&&this.emit({type:"type-removed",typeUri:e})}getNodeType(e){return this.nodeTypes.get(e)}getEdgeType(e){return this.edgeTypes.get(e)}getAllNodeTypes(){return Array.from(this.nodeTypes.values())}getAllEdgeTypes(){return Array.from(this.edgeTypes.values())}getParentTypes(e,t=this.config.maxInheritanceDepth){let n=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let o=s.shift();if(!o)break;let{uri:c,currentDepth:l}=o;if(i.has(c)||(i.add(c),l>=t))continue;let u=this.typeHierarchy.get(c)??[];for(let f of u)i.has(f)||(n.push(f),s.push({uri:f,currentDepth:l+1}))}return n}getChildTypes(e){let t=[];for(let[n,i]of this.typeHierarchy)i.includes(e)&&t.push(n);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],n="unknown",i="custom";if(e.assetClass){let c=this.normalizeTypeUri(e.assetClass);t.push(c),n=c,i="exo:Instance_class"}let s=e.properties?.[kt.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),n==="unknown"&&(n=s,i="rdf:type"));for(let c of[...t]){let l=this.getParentTypes(c);for(let u of l)t.includes(u)||t.push(u)}let o=this.resolveNodeStyle(t);return{primaryType:n,types:t,resolvedStyle:o,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,n=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:n}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:n}=this.config.styleResolution,i={...n},s=[];for(let o of e){let c=this.nodeTypes.get(o);c&&s.push(c)}if(s.sort((o,c)=>o.priority-c.priority),t)for(let o of s)i=(0,kt.mergeNodeStyles)(i,o.style);else if(s.length>0){let o=s[s.length-1];i=(0,kt.mergeNodeStyles)(i,o.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,n={...t},i=this.edgeTypes.get(e);return i&&(n=(0,kt.mergeEdgeStyles)(n,i.style)),n}filterNodes(e,t){return e.filter(n=>{let i=this.resolveNodeType(n);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(n=>{let i=n.predicate??n.type;return!(t.includeEdgeTypes&&t.includeEdgeTypes.length>0&&!t.includeEdgeTypes.includes(i)||t.excludeEdgeTypes&&t.excludeEdgeTypes.length>0&&t.excludeEdgeTypes.includes(i))})}groupNodesByType(e,t,n={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:o=0,maxGroups:c=20,customGroupFn:l}=n,u=new Map;for(let p of e){let h=this.resolveNodeType(p),g;if(l?g=l(h.types):s&&h.types.length>o?g=h.types[o]??h.primaryType:i?g=h.primaryType:g="all",!u.has(g)){let _=this.nodeTypes.get(g)?.label??(0,kt.extractLocalName)(g);u.set(g,{nodeIds:new Set,label:_})}let m=u.get(g);m&&m.nodeIds.add(p.id)}let f=Array.from(u.entries()).map(([p,h])=>({id:p,label:h.label,nodeIds:Array.from(h.nodeIds)}));if(f.length>c){f.sort((g,m)=>m.nodeIds.length-g.nodeIds.length);let p=f.slice(0,c-1),h=f.slice(c-1).flatMap(g=>g.nodeIds);p.push({id:"other",label:"Other",nodeIds:h}),f=p}let d=new Map;for(let p of f)for(let h of p.nodeIds)d.set(h,p.id);return f.map((p,h)=>{let g=new Set(p.nodeIds),m=[],b=[];for(let A of t){let E=g.has(A.source),w=g.has(A.target);E&&w?A.id&&m.push(A.id):(E||w)&&A.id&&b.push(A.id)}let S=`hsl(${h*137.5%360}, 70%, 50%)`;return{id:p.id,label:p.label,nodeIds:p.nodeIds,internalEdgeIds:m,externalEdgeIds:b,color:S,stats:{nodeCount:p.nodeIds.length,internalEdgeCount:m.length,externalEdgeCount:b.length}}})}validateTypes(e,t){let n=[],i=[];for(let s of e){let o=this.resolveNodeType(s);if(o.primaryType!=="unknown"){let c=this.nodeTypes.get(o.primaryType);!c&&o.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${o.primaryType}" is not registered`,elementId:s.id,suggestion:"Register the type with registerNodeType()"}),c?.deprecated&&i.push({code:"DEPRECATED_NODE_TYPE",message:`Node uses deprecated type "${o.primaryType}"`,elementId:s.id,suggestion:"Migrate to a non-deprecated type"})}else i.push({code:"MISSING_NODE_TYPE",message:"Node has no type information",elementId:s.id,suggestion:"Add exo:Instance_class or rdf:type to the node"})}for(let s of t){let o=s.predicate??s.type,c=this.edgeTypes.get(o);if(c?.domain&&c.domain.length>0){let l=e.find(u=>u.id===s.source);if(l){let u=this.resolveNodeType(l);c.domain.some(d=>u.types.includes(d))||n.push({code:"DOMAIN_VIOLATION",message:"Edge source does not match expected domain",elementId:s.id,expected:c.domain,actual:u.types})}}if(c?.range&&c.range.length>0){let l=e.find(u=>u.id===s.target);if(l){let u=this.resolveNodeType(l);c.range.some(d=>u.types.includes(d))||n.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:c.range,actual:u.types})}}}return{valid:n.length===0,errors:n,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new Io.IRI(kt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let n of e){let i=this.getObjectValue(n.object);if(i&&(0,kt.isClassType)(i)){let s=this.getSubjectValue(n.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let n of t){let i=this.getSubjectValue(n.subject),s=this.getObjectValue(n.object);if(i&&s){let o=this.typeHierarchy.get(i)??[];if(!o.includes(s)){o.push(s),this.typeHierarchy.set(i,o);let c=this.nodeTypes.get(i);c&&(c.parentTypes=o)}}}this.discoveryComplete=!0,this.emit({type:"hierarchy-updated",rootTypes:this.getRootTypes()})}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}clear(){this.nodeTypes.clear(),this.edgeTypes.clear(),this.typeHierarchy.clear(),this.discoveryComplete=!1,this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerBuiltInTypes(){for(let[e,t]of Object.entries(kt.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,kt.extractLocalName)(e),source:"custom",style:(0,kt.mergeNodeStyles)(kt.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(kt.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,kt.extractLocalName)(e),source:"custom",style:(0,kt.mergeEdgeStyles)(kt.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),n=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,kt.extractLocalName)(e):(0,kt.extractLocalName)(e),s=n.length>0?this.getObjectValue(n[0].object):void 0,o="rdfs:Class",c=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of c)if(this.getObjectValue(f.object)===kt.RDF_TYPE_PREDICATES.OWL_CLASS){o="owl:Class";break}let l=kt.BUILT_IN_NODE_STYLES[e]??kt.BUILT_IN_NODE_STYLES[(0,kt.extractLocalName)(e)],u={uri:e,label:i,description:s,source:o,style:(0,kt.mergeNodeStyles)(kt.DEFAULT_NODE_STYLE,l??{}),priority:1};this.registerNodeType(u)}normalizeTypeUri(e){let t=e.match(/^\[\[(.+?)\]\]$/);return t?t[1]:e}getSubjectValue(e){if(e instanceof Io.IRI)return e.value;if(e instanceof Nj.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof Wne.Literal||e instanceof Io.IRI)return e.value;if(e instanceof Nj.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let n of this.typeHierarchy.values())for(let i of n)e.add(i);let t=[];for(let n of this.nodeTypes.keys()){let i=this.typeHierarchy.get(n);(!i||i.length===0)&&e.has(n)&&t.push(n)}return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(n){zne.LoggingService.error("TypeRegistry: error in subscriber callback",n instanceof Error?n:new Error(String(n)))}}};La.TypeRegistry=MR;La.TypeRegistry=MR=Vne([(0,qne.injectable)(),Gne("design:paramtypes",[Object,Object])],MR)});var Mj=T(E_=>{"use strict";Object.defineProperty(E_,"__esModule",{value:!0});E_.SPARQL_PREFIXES=void 0;E_.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
245
245
  PREFIX ems: <https://exocortex.my/ontology/ems#>
246
246
  PREFIX ims: <https://exocortex.my/ontology/ims#>
247
247
  PREFIX gtd: <https://exocortex.my/ontology/gtd#>
@@ -598,7 +598,7 @@ ${S.content}--- END PREVIEW ---
598
598
  `+_.map(E=>` - ${E.path}
599
599
  `).join("")),await Lg(5);return}process.stdout.write(JSON.stringify(_)+`
600
600
  `),await Lg(0)}catch(t){if(t instanceof il){process.stderr.write(`\u274C create-batch: ${t.message}
601
- `),await Lg(2);return}ue.handle(t)}})}a(CV,"createBatchCommand");function IV(r,e,t){return new sl.GenericAssetCreationService(r).withDeterminism({uidGenerator:{next:a(()=>e,"next")},clock:{now:a(()=>new Date(t.getTime()),"now")}})}a(IV,"pinnedService");ct();var no=require("path"),_p=require("fs"),cl=Q(Pe());St();Mt();var kg=Q(Pe());var ol="Asia/Almaty",Ja="exo__Asset_updatedAt";var EF={ems__Effort_status:{commands:["mark-done","move-to-backlog","rollback-to-backlog","start-effort","set-draft-status"]},ems__Task_zone:{commands:["set-criticality-high","set-criticality-medium","set-criticality-low"]},ems__Effort_parent:{commands:["set-parent"],argSuffix:`--input '{"parent":"<uid>"}'`},exo__Asset_label:{commands:["set-label"],argSuffix:`--input '{"label":"<text>"}'`},exo__Instance_class:{commands:["convert-to-task","convert-to-project"],note:"reclassing is a semantic operation with a precondition"},ems__Effort_startTimestamp:{commands:["start-effort","rollback-to-backlog","park-waiting"],clearedBy:["rollback-to-backlog","park-waiting"],note:"start-effort sets it; the others clear it as a side effect of the status change"},ems__Effort_endTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_resolutionTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_plannedStartTimestamp:{commands:["set-planned-start","plan-on-today","plan-for-evening","shift-day-forward","shift-day-backward"]},ems__Effort_plannedEndTimestamp:{commands:["set-planned-end"]},ems__Effort_scheduledDate:{commands:["set-scheduled-date"]},ems__Effort_votes:{commands:["vote-on-effort"]},archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]},exo__Asset_archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]}};function Mg(r){return Object.prototype.hasOwnProperty.call(EF,r)?EF[r]:void 0}a(Mg,"guardedRouteFor");function NE(r,e){if(e.size===0)return vF(r);let t=r.commands.filter(n=>e.has(n));return t.length===0?`apply ${r.commands.join("|")} <path> (\u26D4 none of these resolve in this vault \u2014 the owning assetspace looks unmounted)`:vF({...r,commands:t})}a(NE,"renderGuardedRouteResolved");function vF(r){let e=`apply ${r.commands.join("|")} <path>`,t=r.argSuffix?`${e} ${r.argSuffix}`:e;return r.note?`${t} (${r.note})`:t}a(vF,"renderGuardedRoute");var QBe=Object.fromEntries(Object.entries(EF).map(([r,e])=>[r,vF(e)])),kE={exo__Asset_uid:"the asset identity \u2014 changing it breaks UID-canon filenames and every inbound [[uid]] wikilink",[Ja]:"auto-managed (bumped on every mutation)"};function xV(r){let e=Mg(r);if(e===void 0)return;let t=e.clearedBy??[];if(t.length===0)return;let{note:n,...i}=e;return{...i,commands:t}}a(xV,"clearingRouteFor");function OV(r){return`Refusing to remove "${r}" via remove-property \u2014 it is guarded, and no dedicated command clears it (the ones that own it assign a value). If dropping the facet is intended, say so explicitly: --force --reason "<why>"`}a(OV,"renderNoClearingPathRefusal");function ME(r,e,t,n){return`Refusing to ${r} "${t}" via ${e} \u2014 it has a dedicated guarded command so the state machine / precondition is not bypassed. Use: exocortex ${n} --vault <v>`}a(ME,"renderGuardRefusal");function jE(r,e){return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}a(jE,"guardedReason");function al(r,e){let n=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(r),i=a(s=>n.find(o=>o.type===s)?.value??"00","get");return`${i("year")}-${i("month")}-${i("day")}T${i("hour")}:${i("minute")}:${i("second")}`}a(al,"stampTimestamp");var cSe=/^\s*exocmd__Command_cliName:\s*(.+?)\s*$/gm;function lSe(r){let e=r.trim();return e.length>=2&&(e[0]==='"'||e[0]==="'")&&e[e.length-1]===e[0]?e.slice(1,-1).trim():e}a(lSe,"unquote");var bp=class{constructor(e){this.vaultPath=e}static{a(this,"CommandNameRegistry")}async collect(){if(this.cache)return this.cache;let{readdir:e,readFile:t}=await import("fs/promises"),n=new Set,i=a(async s=>{let o;try{o=await e(s,{withFileTypes:!0})}catch{return}for(let c of o){let l=`${s}/${c.name}`;if(c.isDirectory()){if(c.name===".git"||c.name==="node_modules")continue;await i(l)}else if(c.isFile()&&c.name.endsWith(".md")){let u;try{u=await t(l,"utf-8")}catch{continue}for(let f of u.matchAll(cSe)){let d=lSe(f[1]);d&&n.add(d)}}}},"walk");return await i(this.vaultPath),this.cache=n,n}};var PV="exo__Asset_isDefinedBy";function uSe(r){let e=a(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean","isScalar");if(e(r)||Array.isArray(r)&&r.every(e))return;let t=r===null?"null":Array.isArray(r)?"an array with non-scalar elements":typeof r;throw new Error(`--input.value must be a scalar (string/number/boolean) or an array of scalars, not ${t}`)}a(uSe,"assertScalarOrScalarArray");function fSe(r,e){if(e==="")throw new Error(`Refusing to set "${r}" to an EMPTY value \u2014 an empty string writes a junk key (${r}: "") rather than clearing the property. To delete it use: exocortex remove-property <path> --property ${r} --vault <v>`)}a(fSe,"assertNonEmptyValue");function dSe(r){let e=r.input!==void 0,t=r.property!==void 0;if(e&&t)throw new Ye("Pass --input OR --property/--value, not both.",`set-property <path> --input '{"property":"<name>","value":<v>}'`);if(e){let n;try{n=JSON.parse(r.input)}catch(o){let c=o instanceof Error?o.message:String(o);throw new Error(`--input: invalid JSON (${c})`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error('--input must be a JSON object of the form {"property":"<name>","value":<v>}');let i=n,s=i.property;if(typeof s!="string"||s.trim().length===0)throw new Error("--input.property must be a non-empty string");if(!("value"in i))throw new Error("--input.value is required");return{property:s.trim(),value:i.value}}if(t){if(r.value===void 0)throw new Error("--property requires --value (or use --input for a typed/array value)");return{property:r.property.trim(),value:r.value}}throw new Ye("No property provided.",`set-property <path> --input '{"property":"<name>","value":<v>}' OR set-property <path> --property <name> --value <string>`)}a(dSe,"resolvePropertyAndValue");function pSe(r,e,t){let n=cl.STRING_SCALAR_PROPERTIES.has(e);return Array.isArray(r)?r.map(i=>(0,cl.serializeYamlScalar)(i,n,t)):(0,cl.serializeYamlScalar)(r,n,t)}a(pSe,"serializeForWrite");function FV(){return new pe("set-property").description("Set an arbitrary non-guarded frontmatter property on an existing vault asset (bumps exo__Asset_updatedAt only when the value actually changed; a no-op leaves the file byte-identical). Refuses state-machine-guarded properties (status/zone/parent/label/fact-timestamps) \u2014 those keep their dedicated `apply` commands. Issues #3795 / #3848.").argument("<path>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>",'JSON {"property":"<name>","value":<v>} \u2014 value is JSON-typed (boolean/number/string/array). Primary form.').option("--property <name>","Property name (string-value convenience form; pair with --value; use --input for boolean/number/array values)").option("--value <value>","Property value as a string (pair with --property; use --input for typed/array values)").option("--skip-wikilink-validation","Skip [[...]] wikilink existence validation").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--dry-run","Preview the resulting frontmatter without writing").option("--yes","Accepted for symmetry with the apply/create subcommands (set-property is non-interactive; no-op)").action(async(r,e)=>{try{let t=(0,no.resolve)(e.vault);if(!(0,_p.existsSync)(t))throw new Le(t);let n=(0,no.resolve)(t,r),i=(0,no.relative)(t,n);if(i===".."||i.startsWith(`..${no.sep}`)||(0,no.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);let s;try{s=(0,_p.readFileSync)(n,"utf-8")}catch(w){throw w.code==="ENOENT"?new Error(`Target file not found: ${r}`):w}if(!/^\s*exo__Asset_uid:/m.test(s))throw new Error(`Not a vault asset (no exo__Asset_uid): ${i}. set-property only mutates existing assets.`);let{property:o,value:c}=dSe(e),l=cl.FrontmatterService.normalizeIRI(o),u=jE(kE,l);if(u!==void 0)throw new Error(`Refusing to set "${l}" \u2014 ${u}.`);let f=Mg(l);if(f!==void 0){let w=await new bp(t).collect();throw new Error(ME("set","set-property",l,NE(f,w)))}let d=new nl(t,{warn:a(w=>process.stderr.write(`\u26A0 ${w}
601
+ `),await Lg(2);return}ue.handle(t)}})}a(CV,"createBatchCommand");function IV(r,e,t){return new sl.GenericAssetCreationService(r).withDeterminism({uidGenerator:{next:a(()=>e,"next")},clock:{now:a(()=>new Date(t.getTime()),"now")}})}a(IV,"pinnedService");ct();var no=require("path"),_p=require("fs"),cl=Q(Pe());St();Mt();var kg=Q(Pe());var ol="Asia/Almaty",Ja="exo__Asset_updatedAt";var EF={ems__Effort_status:{commands:["mark-done","move-to-backlog","rollback-to-backlog","start-effort","set-draft-status"]},ems__Task_zone:{commands:["set-criticality-high","set-criticality-medium","set-criticality-low"]},ems__Effort_parent:{commands:["set-parent"],argSuffix:`--input '{"parent":"<uid>"}'`},exo__Asset_label:{commands:["set-label"],argSuffix:`--input '{"label":"<text>"}'`},exo__Instance_class:{commands:["convert-to-task","convert-to-project","append-instance-class","replace-instance-class"],note:`reclassing is a semantic operation with a precondition; append/replace take --input '{"class":"[[<uid>]]"}' \u2014 append ADDS a second class (dual-type deprecation), the others replace`},ems__Effort_startTimestamp:{commands:["start-effort","rollback-to-backlog","park-waiting"],clearedBy:["rollback-to-backlog","park-waiting"],note:"start-effort sets it; the others clear it as a side effect of the status change"},ems__Effort_endTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_resolutionTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_plannedStartTimestamp:{commands:["set-planned-start","plan-on-today","plan-for-evening","shift-day-forward","shift-day-backward"]},ems__Effort_plannedEndTimestamp:{commands:["set-planned-end"]},ems__Effort_scheduledDate:{commands:["set-scheduled-date"]},ems__Effort_votes:{commands:["vote-on-effort"]},archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]},exo__Asset_archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]}};function Mg(r){return Object.prototype.hasOwnProperty.call(EF,r)?EF[r]:void 0}a(Mg,"guardedRouteFor");function NE(r,e){if(e.size===0)return vF(r);let t=r.commands.filter(n=>e.has(n));return t.length===0?`apply ${r.commands.join("|")} <path> (\u26D4 none of these resolve in this vault \u2014 the owning assetspace looks unmounted)`:vF({...r,commands:t})}a(NE,"renderGuardedRouteResolved");function vF(r){let e=`apply ${r.commands.join("|")} <path>`,t=r.argSuffix?`${e} ${r.argSuffix}`:e;return r.note?`${t} (${r.note})`:t}a(vF,"renderGuardedRoute");var QBe=Object.fromEntries(Object.entries(EF).map(([r,e])=>[r,vF(e)])),kE={exo__Asset_uid:"the asset identity \u2014 changing it breaks UID-canon filenames and every inbound [[uid]] wikilink",[Ja]:"auto-managed (bumped on every mutation)"};function xV(r){let e=Mg(r);if(e===void 0)return;let t=e.clearedBy??[];if(t.length===0)return;let{note:n,...i}=e;return{...i,commands:t}}a(xV,"clearingRouteFor");function OV(r){return`Refusing to remove "${r}" via remove-property \u2014 it is guarded, and no dedicated command clears it (the ones that own it assign a value). If dropping the facet is intended, say so explicitly: --force --reason "<why>"`}a(OV,"renderNoClearingPathRefusal");function ME(r,e,t,n){return`Refusing to ${r} "${t}" via ${e} \u2014 it has a dedicated guarded command so the state machine / precondition is not bypassed. Use: exocortex ${n} --vault <v>`}a(ME,"renderGuardRefusal");function jE(r,e){return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}a(jE,"guardedReason");function al(r,e){let n=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(r),i=a(s=>n.find(o=>o.type===s)?.value??"00","get");return`${i("year")}-${i("month")}-${i("day")}T${i("hour")}:${i("minute")}:${i("second")}`}a(al,"stampTimestamp");var cSe=/^\s*exocmd__Command_cliName:\s*(.+?)\s*$/gm;function lSe(r){let e=r.trim();return e.length>=2&&(e[0]==='"'||e[0]==="'")&&e[e.length-1]===e[0]?e.slice(1,-1).trim():e}a(lSe,"unquote");var bp=class{constructor(e){this.vaultPath=e}static{a(this,"CommandNameRegistry")}async collect(){if(this.cache)return this.cache;let{readdir:e,readFile:t}=await import("fs/promises"),n=new Set,i=a(async s=>{let o;try{o=await e(s,{withFileTypes:!0})}catch{return}for(let c of o){let l=`${s}/${c.name}`;if(c.isDirectory()){if(c.name===".git"||c.name==="node_modules")continue;await i(l)}else if(c.isFile()&&c.name.endsWith(".md")){let u;try{u=await t(l,"utf-8")}catch{continue}for(let f of u.matchAll(cSe)){let d=lSe(f[1]);d&&n.add(d)}}}},"walk");return await i(this.vaultPath),this.cache=n,n}};var PV="exo__Asset_isDefinedBy";function uSe(r){let e=a(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean","isScalar");if(e(r)||Array.isArray(r)&&r.every(e))return;let t=r===null?"null":Array.isArray(r)?"an array with non-scalar elements":typeof r;throw new Error(`--input.value must be a scalar (string/number/boolean) or an array of scalars, not ${t}`)}a(uSe,"assertScalarOrScalarArray");function fSe(r,e){if(e==="")throw new Error(`Refusing to set "${r}" to an EMPTY value \u2014 an empty string writes a junk key (${r}: "") rather than clearing the property. To delete it use: exocortex remove-property <path> --property ${r} --vault <v>`)}a(fSe,"assertNonEmptyValue");function dSe(r){let e=r.input!==void 0,t=r.property!==void 0;if(e&&t)throw new Ye("Pass --input OR --property/--value, not both.",`set-property <path> --input '{"property":"<name>","value":<v>}'`);if(e){let n;try{n=JSON.parse(r.input)}catch(o){let c=o instanceof Error?o.message:String(o);throw new Error(`--input: invalid JSON (${c})`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error('--input must be a JSON object of the form {"property":"<name>","value":<v>}');let i=n,s=i.property;if(typeof s!="string"||s.trim().length===0)throw new Error("--input.property must be a non-empty string");if(!("value"in i))throw new Error("--input.value is required");return{property:s.trim(),value:i.value}}if(t){if(r.value===void 0)throw new Error("--property requires --value (or use --input for a typed/array value)");return{property:r.property.trim(),value:r.value}}throw new Ye("No property provided.",`set-property <path> --input '{"property":"<name>","value":<v>}' OR set-property <path> --property <name> --value <string>`)}a(dSe,"resolvePropertyAndValue");function pSe(r,e,t){let n=cl.STRING_SCALAR_PROPERTIES.has(e);return Array.isArray(r)?r.map(i=>(0,cl.serializeYamlScalar)(i,n,t)):(0,cl.serializeYamlScalar)(r,n,t)}a(pSe,"serializeForWrite");function FV(){return new pe("set-property").description("Set an arbitrary non-guarded frontmatter property on an existing vault asset (bumps exo__Asset_updatedAt only when the value actually changed; a no-op leaves the file byte-identical). Refuses state-machine-guarded properties (status/zone/parent/label/fact-timestamps) \u2014 those keep their dedicated `apply` commands. Issues #3795 / #3848.").argument("<path>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>",'JSON {"property":"<name>","value":<v>} \u2014 value is JSON-typed (boolean/number/string/array). Primary form.').option("--property <name>","Property name (string-value convenience form; pair with --value; use --input for boolean/number/array values)").option("--value <value>","Property value as a string (pair with --property; use --input for typed/array values)").option("--skip-wikilink-validation","Skip [[...]] wikilink existence validation").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--dry-run","Preview the resulting frontmatter without writing").option("--yes","Accepted for symmetry with the apply/create subcommands (set-property is non-interactive; no-op)").action(async(r,e)=>{try{let t=(0,no.resolve)(e.vault);if(!(0,_p.existsSync)(t))throw new Le(t);let n=(0,no.resolve)(t,r),i=(0,no.relative)(t,n);if(i===".."||i.startsWith(`..${no.sep}`)||(0,no.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);let s;try{s=(0,_p.readFileSync)(n,"utf-8")}catch(w){throw w.code==="ENOENT"?new Error(`Target file not found: ${r}`):w}if(!/^\s*exo__Asset_uid:/m.test(s))throw new Error(`Not a vault asset (no exo__Asset_uid): ${i}. set-property only mutates existing assets.`);let{property:o,value:c}=dSe(e),l=cl.FrontmatterService.normalizeIRI(o),u=jE(kE,l);if(u!==void 0)throw new Error(`Refusing to set "${l}" \u2014 ${u}.`);let f=Mg(l);if(f!==void 0){let w=await new bp(t).collect();throw new Error(ME("set","set-property",l,NE(f,w)))}let d=new nl(t,{warn:a(w=>process.stderr.write(`\u26A0 ${w}
602
602
  `),"warn")});if(await d.validate([l]),uSe(c),fSe(o,c),!e.skipWikilinkValidation){let w=new rl(new Xn(t)),R=Array.isArray(c)?c:[c];for(let x of R)typeof x=="string"&&await w.validateValue(x)}l===PV&&await FE(c,new Xn(t),i,"set-property");let p=new cl.FrontmatterService,h=(0,kg.canonicalYamlKey)(l),g=await d.declaredRange(l),m=p.updateProperty(s,h,pSe(c,h,g)),b=m!==s,_=m,S;if(b){let w=e.frozenClock?new Date(e.frozenClock):new Date,R=e.timezone??ol;S=al(w,R),_=p.updateProperty(m,Ja,S)}let A;if(l===PV){let w=Array.isArray(c)?c[0]:c,R=await fV(new Xn(t),w);if(R!==null){let x=(0,no.dirname)(i),P=x==="."?"":x;P!==R&&(A=`\u26A0 co-location: exo__Asset_isDefinedBy now points at "${R||"<vault root>"}" but the file is in "${P||"<vault root>"}". Move it to match: exocortex apply repair-folder ${i} --vault <v>`)}}e.dryRun?process.stderr.write(`--- DRY RUN PREVIEW ---
603
603
  ${_}
604
604
  --- END PREVIEW ---
@@ -708,7 +708,7 @@ Next steps:
708
708
  `).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(jEe,"parseLastJsonLine");function uq(r,e){return e.filter(t=>{let n=r[t];return typeof n!="string"||n.trim().length===0})}a(uq,"missingStringFields");var dv=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:lq,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:lq,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:kEe,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:cq}};case"tools/call":return{jsonrpc:"2.0",id:i,result:await this.callTool(e.params??{})};default:return{jsonrpc:"2.0",id:i,error:{code:MEe,message:`Method not found: ${e.method}`}}}}async callTool(e){let t=e.name,n=e.arguments??{},i;if(t==="create_asset"){let c=uq(n,["vault","class","label"]);if(c.length>0)return Dp(`create_asset: missing required argument(s): ${c.join(", ")}`,!0);let l=sq(n);if(l!==null)return Dp(`create_asset: ${l}`,!0);i=oq(n)}else if(t==="create_effort"){let c=uq(n,["vault","command","target"]);if(c.length>0)return Dp(`create_effort: missing required argument(s): ${c.join(", ")}`,!0);i=aq(n)}else return Dp(`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 Dp(`exocortex-cli exited ${s.exitCode}
709
709
  ${c}`,!0)}let o=jEe(s.stdout);return Dp(o===void 0?s.stdout.trim():JSON.stringify(o))}};var pq=require("child_process");var $Ee=32*1024*1024;function hq(r){return e=>new Promise(t=>{(0,pq.execFile)(process.execPath,[r,...e],{maxBuffer:$Ee},(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(hq,"createSelfCliRunner");async function UEe(r,e,t){let n=(0,mq.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:fq,message:"Parse error: invalid JSON"}})+`
710
710
  `);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:dq,message:`Internal error: ${l instanceof Error?l.message:String(l)}`}}}c!==null&&t(JSON.stringify(c)+`
711
- `)}}a(UEe,"runStdioServer");function gq(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 dv({runCli:hq(t),version:r??"unknown"});await UEe(n,process.stdin,i=>process.stdout.write(i))})}a(gq,"mcpCommand");function pv(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??"17.5.8"),e.addCommand($V()),e.addCommand(YV()),e.addCommand(S7()),e.addCommand(T7()),e.addCommand(W7()),e.addCommand(A7()),e.addCommand(O7()),e.addCommand(P7()),e.addCommand(Z7()),e.addCommand(iV()),e.addCommand(vV()),e.addCommand(CV()),e.addCommand(FV()),e.addCommand(DV()),e.addCommand(NV()),e.addCommand(kV()),e.addCommand(bG()),e.addCommand(wG()),e.addCommand(HG()),e.addCommand(YG()),e.addCommand(JG()),e.addCommand(ZG()),e.addCommand(rq()),e.addCommand(kG()),e.addCommand(qG()),e.addCommand(nq()),e.addCommand(gq(r??"17.5.8")),e}a(pv,"createProgram");pv().parse();0&&(module.exports={createProgram});
711
+ `)}}a(UEe,"runStdioServer");function gq(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 dv({runCli:hq(t),version:r??"unknown"});await UEe(n,process.stdin,i=>process.stdout.write(i))})}a(gq,"mcpCommand");function pv(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??"17.5.10"),e.addCommand($V()),e.addCommand(YV()),e.addCommand(S7()),e.addCommand(T7()),e.addCommand(W7()),e.addCommand(A7()),e.addCommand(O7()),e.addCommand(P7()),e.addCommand(Z7()),e.addCommand(iV()),e.addCommand(vV()),e.addCommand(CV()),e.addCommand(FV()),e.addCommand(DV()),e.addCommand(NV()),e.addCommand(kV()),e.addCommand(bG()),e.addCommand(wG()),e.addCommand(HG()),e.addCommand(YG()),e.addCommand(JG()),e.addCommand(ZG()),e.addCommand(rq()),e.addCommand(kG()),e.addCommand(qG()),e.addCommand(nq()),e.addCommand(gq(r??"17.5.10")),e}a(pv,"createProgram");pv().parse();0&&(module.exports={createProgram});
712
712
  /*! Bundled license information:
713
713
 
714
714
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitelev/exocortex-cli",
3
- "version": "17.5.8",
3
+ "version": "17.5.10",
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": {