@kitelev/exocortex-cli 15.90.22 → 15.90.23
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 +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// @kitelev/exocortex-cli v15.90.
|
|
2
|
+
// @kitelev/exocortex-cli v15.90.23
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
@@ -212,7 +212,7 @@ ${s}`}return`${r}: ${i}`}).join(`
|
|
|
212
212
|
`,a=await this.sparqlService.query(s);return this.buildEnumValues(a)}buildEnumValues(e){let t=[],r=new Set;for(let i of e){let s=this.getBindingValue(i,"instance");if(!s||r.has(s))continue;r.add(s);let a=this.getBindingValue(i,"label")??s,l=`[[${this.fromFullIRI(s)}]]`;t.push({value:l,label:a})}return t}buildRankProperty(e){let t=e.match(/^([a-z]+)__(.+)$/);if(!t)return null;let[,r,i]=t;return`${r}__${i}_rank`}normalizeClassName(e){return e.replace(/\[\[|\]\]/g,"").trim()}getBindingValue(e,t){let r=e.get(t);if(r!=null)return String(r)}toFullIRI(e){if(e.startsWith("http://")||e.startsWith("https://"))return e;let t=e.match(/^([a-z]+)__(.+)$/);if(t){let[,r,i]=t;return`https://exocortex.my/ontology/${r}#${i}`}return e}fromFullIRI(e){let t=e.match(/https:\/\/exocortex\.my\/ontology\/([a-z]+)#(.+)$/);if(t){let[,r,i]=t;return`${r}__${i}`}return e}};Vs.EnumValueResolver=Z_;Vs.EnumValueResolver=Z_=U9([(0,q9.injectable)(),B9("design:paramtypes",[Object,Object])],Z_)});var tv=v(gi=>{"use strict";var W9=gi&&gi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},G9=gi&&gi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},z9=gi&&gi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(gi,"__esModule",{value:!0});gi.AssetConversionService=void 0;var L3=ve(),k3=xn(),H9=Hi(),_p=pa(),Q9=Tt(),ev=class{static{o(this,"AssetConversionService")}constructor(e){this.vault=e,this.frontmatterService=new H9.FrontmatterService}async convertTaskToProject(e){try{let t=await this.vault.read(e),r=this.removeInstanceClassProperty(t);return r=this.frontmatterService.updateProperty(r,"exo__Instance_class",`["[[${k3.AssetClass.PROJECT}]]"]`),await this.vault.modify(e,r),_p.LoggingService.info(`Converted Task to Project: ${e.basename} (${e.path})`),e}catch(t){let r=`Failed to convert Task to Project: ${e.path}`;throw _p.LoggingService.error(r,t instanceof Error?t:void 0),new Error(r)}}async convertProjectToTask(e){try{let t=await this.vault.read(e),r=this.removeInstanceClassProperty(t);return r=this.frontmatterService.updateProperty(r,"exo__Instance_class",`["[[${k3.AssetClass.TASK}]]"]`),await this.vault.modify(e,r),_p.LoggingService.info(`Converted Project to Task: ${e.basename} (${e.path})`),e}catch(t){let r=`Failed to convert Project to Task: ${e.path}`;throw _p.LoggingService.error(r,t instanceof Error?t:void 0),new Error(r)}}removeInstanceClassProperty(e){let t=this.frontmatterService.parse(e);if(!t.exists)return e;let r=/^exo__Instance_class:.*$(\n -.*$)*/gm,i=t.content.replace(r,"").replace(/\n\n+/g,`
|
|
213
213
|
`).trim();return e.replace(/^---\n[\s\S]*?\n---/,`---
|
|
214
214
|
${i}
|
|
215
|
-
---`)}};gi.AssetConversionService=ev;gi.AssetConversionService=ev=W9([(0,L3.injectable)(),z9(0,(0,L3.inject)(Q9.DI_TOKENS.IVaultAdapter)),G9("design:paramtypes",[Object])],ev)});var iv=v(yi=>{"use strict";var Y9=yi&&yi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},X9=yi&&yi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},M3=yi&&yi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(yi,"__esModule",{value:!0});yi.SessionEventService=void 0;var rv=ve(),K9=hn(),j3=xn(),J9=rn(),Z9=Yi(),$3=Tt(),nv=class{static{o(this,"SessionEventService")}constructor(e,t){this.vault=e,this.vaultSettings=t,this.folderPathCache=null}async createSessionStartEvent(e){return this.createSessionEvent(e,j3.AssetClass.SESSION_START_EVENT)}async createSessionEndEvent(e){return this.createSessionEvent(e,j3.AssetClass.SESSION_END_EVENT)}getSessionEventFolder(){if(this.folderPathCache!==null)return this.folderPathCache;let e=this.vault.getDefaultNewFileParent();return this.folderPathCache=e?.path||"",this.folderPathCache}async createSessionEvent(e,t){let r=(0,K9.v4)(),i=J9.DateFormatter.toLocalTimestamp(new Date),s={exo__Asset_uid:r,exo__Asset_createdAt:i,exo__Asset_isDefinedBy:this.vaultSettings.getOwnerIdentity(),exo__Instance_class:[`"[[${t}]]"`],ems__SessionEvent_timestamp:i,ems__Session_area:`"[[${e}]]"`},a=Z9.MetadataHelpers.buildFileContent(s),c=this.getSessionEventFolder();c&&!await this.vault.exists(c)&&await this.vault.createFolder(c);let l=c?`${c}/${r}.md`:`${r}.md`;return await this.vault.create(l,a)}};yi.SessionEventService=nv;yi.SessionEventService=nv=Y9([(0,rv.injectable)(),M3(0,(0,rv.inject)($3.DI_TOKENS.IVaultAdapter)),M3(1,(0,rv.inject)($3.DI_TOKENS.IVaultSettings)),X9("design:paramtypes",[Object,Object])],nv)});var ov=v(_i=>{"use strict";var ej=_i&&_i.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},tj=_i&&_i.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},V3=_i&&_i.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(_i,"__esModule",{value:!0});_i.URIConstructionService=void 0;var sv=ve(),U3=Tt(),rj=Du(),av=class{static{o(this,"URIConstructionService")}constructor(e,t=rj.NullLogger){this.fileSystem=e,this.logger=t,this.defaultOntologyURL="https://exocortex.my/default/",this.strictValidation=!0}configure(e){e?.defaultOntologyURL&&(this.defaultOntologyURL=e.defaultOntologyURL),e?.strictValidation!==void 0&&(this.strictValidation=e.strictValidation)}async constructAssetURI(e){let t=this.extractUID(e);if(!t){if(this.strictValidation)throw new Error(`Asset missing exo__Asset_uid: ${e.path}`);return this.logger.warn(`Asset ${e.path} missing UID, using filename fallback`),this.constructFallbackURI(e)}let r=await this.resolveOntologyURL(e);if(!this.validateOntologyURL(r))throw new Error(`Invalid ontology URL: ${r}`);return`${r.endsWith("/")?r:`${r}/`}${t}`}validateOntologyURL(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}async resolveOntologyURL(e){let t=e.frontmatter?.exo__Asset_isDefinedBy;if(!t||typeof t!="string")return this.defaultOntologyURL;let r=this.extractWikiLink(t),i=r,s=await this.fileSystem.fileExists(r);return!s&&!r.endsWith(".md")&&(i=`${r}.md`,s=await this.fileSystem.fileExists(i)),s?(await this.fileSystem.getFileMetadata(i))?.exo__Ontology_url||this.defaultOntologyURL:(this.logger.warn(`Ontology file not found: ${r}, using default`),this.defaultOntologyURL)}extractUID(e){let t=e.frontmatter?.exo__Asset_uid;return typeof t=="string"?t:null}extractWikiLink(e){return e.replace(/^\[\[|\]\]$/g,"")}constructFallbackURI(e){let t=e.path.split("/").pop()?.replace(".md","")||"unknown";return`${this.defaultOntologyURL}${t}`}};_i.URIConstructionService=av;_i.URIConstructionService=av=ej([(0,sv.injectable)(),V3(0,(0,sv.inject)(U3.DI_TOKENS.IFileSystemAdapter)),V3(1,(0,sv.inject)(U3.DI_TOKENS.ILogger)),tj("design:paramtypes",[Object,Object])],av)});var lv=v(vi=>{"use strict";var nj=vi&&vi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},ij=vi&&vi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},sj=vi&&vi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(vi,"__esModule",{value:!0});vi.GenericAssetCreationService=void 0;var B3=ve(),aj=hn(),Nu=rn(),oj=Yi(),cj=Tt(),Xi=$d(),cv=class{static{o(this,"GenericAssetCreationService")}constructor(e){this.vault=e}async createAsset(e,t){let r=(0,aj.v4)(),i=`${r}.md`,s=this.generateFrontmatter(e,t||[],r),a=oj.MetadataHelpers.buildFileContent(s),c=e.folderPath||this.getDefaultFolderPath(e);this.vault.getAbstractFileByPath(c)||await this.vault.createFolder(c);let u=c?`${c}/${i}`:i;return await this.vault.create(u,a)}generateFrontmatter(e,t,r){let i=new Date,s={},a=new Map;for(let c of t)a.set(c.name,c.fieldType);if(s.exo__Asset_uid=r,s.exo__Asset_createdAt=Nu.DateFormatter.toLocalTimestamp(i),s.exo__Instance_class=[this.formatWikilink(e.className)],e.label&&e.label.trim()!==""){let c=e.label.trim();s.exo__Asset_label=c,s.aliases=[c]}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(s,e),e.propertyValues)for(let[c,l]of Object.entries(e.propertyValues)){if(c==="exo__Asset_uid"||c==="exo__Asset_createdAt"||c==="exo__Instance_class"||c==="exo__Asset_label"||c==="aliases"||l==null)continue;let u=a.get(c);s[c]=this.formatValue(l,u)}return s}inheritParentContext(e,t){let r=t.parentMetadata||{},i=t.parentFile?.basename;if((t.className==="ems__Task"||t.className.startsWith("ems__Task"))&&(e.ems__Effort_parent=i?this.formatWikilink(i):null),t.className==="ems__Project"||t.className.startsWith("ems__Project")){let s=r.exo__Instance_class;this.isAreaClass(s)&&(e.ems__Project_area=i?this.formatWikilink(i):null)}r.exo__Asset_isDefinedBy&&(e.exo__Asset_isDefinedBy=r.exo__Asset_isDefinedBy)}isAreaClass(e){return e?(Array.isArray(e)?e:[e]).some(r=>String(r).includes("Area")||String(r).includes("ems__Area")):!1}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[r,i]of Object.entries(t))if(e.className.startsWith(r))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case Xi.PropertyFieldType.Text:return String(e);case Xi.PropertyFieldType.Wikilink:case Xi.PropertyFieldType.Reference:case Xi.PropertyFieldType.StatusSelect:case Xi.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case Xi.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case Xi.PropertyFieldType.Boolean:return this.formatBoolean(e);case Xi.PropertyFieldType.Date:case Xi.PropertyFieldType.DateTime:case Xi.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?Nu.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 Nu.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:Nu.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return Nu.DateFormatter.toLocalTimestamp(t)}return String(e)}};vi.GenericAssetCreationService=cv;vi.GenericAssetCreationService=cv=nj([(0,B3.injectable)(),sj(0,(0,B3.inject)(cj.DI_TOKENS.IVaultAdapter)),ij("design:paramtypes",[Object])],cv)});var q3=v(Us=>{"use strict";var lj=Us&&Us.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},uj=Us&&Us.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Us,"__esModule",{value:!0});Us.GraphQueryService=void 0;var fj=ve(),Lu=xe(),dj=Ge(),ya=wr(),hj=dy(),Ki={INSTANCE_CLASS:ya.Namespace.EXO.term("Instance_class"),ASSET_LABEL:ya.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:ya.Namespace.EXO.term("Asset_prototype"),ASSET_IS_ARCHIVED:ya.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:ya.Namespace.EMS.term("Effort_parent"),REFERENCES:ya.Namespace.EXO.term("references"),REFERENCED_BY:ya.Namespace.EXO.term("referencedBy"),RDF_TYPE:ya.Namespace.RDF.term("type")},uv=class{static{o(this,"GraphQueryService")}constructor(e,t={},r){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.logger=r,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(),r=await this.loadNodes(e),i=await this.loadEdges(r,e),s=this.computeStats(r,i),a=Date.now()-t;return a>100&&r.length>0&&this.logger?.debug(`GraphQueryService: loaded ${r.length} nodes in ${a}ms (${(a/r.length).toFixed(2)}ms/node)`),{nodes:r,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),r=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:r}),s=i.length>t,a=s?i.slice(0,t):i,c=await this.loadEdges(a,e);return{nodes:a,edges:c,hasMore:s,totalCount:void 0,cursor:s?String(r+t):void 0}}async loadConnectedNodes(e,t={}){let r=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,a=[{id:e,currentDepth:0}],c=[];for(;a.length>0&&c.length<i;){let u=a.shift();if(!u)break;let{id:f,currentDepth:d}=u;if(s.has(f))continue;s.add(f);let h=await this.getNodeById(f,t);if(h&&(c.push(h),d<r)){let p=await this.getConnectedNodeIds(f);for(let _ of p)s.has(_)||a.push({id:_,currentDepth:d+1})}}let l=await this.loadEdges(c,t);return{nodes:c,edges:l,hasMore:a.length>0,totalCount:s.size+a.length}}async getNodeById(e,t={}){let r=this.getCachedNode(e);if(r)return{...r};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let a=this.triplesToNode(e,s,t);return a&&this.cacheNode(a),a}subscribe(e){return this.subscribers.add(e),{unsubscribe:o(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(r){this.logger?.error("GraphQueryService: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}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,r=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,Ki.INSTANCE_CLASS,void 0),a=s;if(e.classes&&e.classes.length>0){let p=new Set(e.classes);a=s.filter(_=>{let b=this.getObjectValue(_.object);return b&&p.has(b)})}let c=new Set;for(let p of a)c.add(this.subjectToId(p.subject));let f=Array.from(c).slice(i,i+r).map(p=>this.getNodeById(p,e));return(await Promise.all(f)).filter(p=>!(!p||!t&&p.isArchived))}async loadEdges(e,t){let r=new Set(e.map(a=>a.id)),i=[],s=new Set;for(let a of e){let c=this.idToIRI(a.id),l=await this.tripleStore.match(c,void 0,void 0);for(let u of l){let f=this.tripleToEdge(a.id,u,r);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),r=[],i=await this.tripleStore.match(t,void 0,void 0);for(let a of i){let c=this.objectToId(a.object);c&&r.push(c)}let s=await this.tripleStore.match(void 0,void 0,t);for(let a of s)r.push(this.subjectToId(a.subject));return[...new Set(r)]}triplesToNode(e,t,r){let i={},s,a,c,l,u=!1;for(let h of t){let p=h.predicate.value,_=this.getObjectValue(h.object);if(p===Ki.INSTANCE_CLASS.value)s=_;else if(p===Ki.ASSET_LABEL.value)a=_;else if(p===Ki.ASSET_PROTOTYPE.value)c=this.objectToId(h.object)??_;else if(p===Ki.EFFORT_PARENT.value)l=this.objectToId(h.object)??_;else if(p===Ki.ASSET_IS_ARCHIVED.value)u=_==="true"||_==="1";else{let b=this.predicateToPropertyName(p);b&&(i[b]=_)}}if(u&&!(r.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),d=a??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,r){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!r.has(s)||s===e)return null;let a=this.predicateToEdgeType(i);if(!a)return null;let c=(0,hj.createEdgeId)(e,s,a,i),l=this.predicateToLabel(i);return{id:c,source:e,target:s,type:a,predicate:i,label:l}}predicateToEdgeType(e){return e===Ki.EFFORT_PARENT.value?"hierarchy":e===Ki.ASSET_PROTOTYPE.value?"prototype":e===Ki.REFERENCES.value?"forward-link":e===Ki.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),r=e.lastIndexOf("/"),i=Math.max(t,r);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let r={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let c of e){let l=c.assetClass??"unknown";r[l]=(r[l]??0)+1}for(let c of t)i[c.type]=(i[c.type]??0)+1;let s=new Map,a=new Map;for(let c of t)a.set(c.source,(a.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=a.get(c.id)??0,c.weight=c.inDegree+c.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:r,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new Lu.IRI(e):new Lu.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof Lu.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof Lu.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof dj.Literal||e instanceof Lu.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()}};Us.GraphQueryService=uv;Us.GraphQueryService=uv=lj([(0,fj.injectable)(),uj("design:paramtypes",[Object,Object,Object])],uv)});var G3=v(Bs=>{"use strict";var pj=Bs&&Bs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},mj=Bs&&Bs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Bs,"__esModule",{value:!0});Bs.TypeRegistry=void 0;var gj=ve(),Ji=xe(),W3=Vt(),yj=Ge(),_j=pa(),ut=hy(),fv=class{static{o(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:ut.DEFAULT_NODE_STYLE,defaultEdgeStyle:ut.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let r=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:r,typeUri:e.uri,definition:e})}registerEdgeType(e){let r=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:r,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),r=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||r)&&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 r=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let a=s.shift();if(!a)break;let{uri:c,currentDepth:l}=a;if(i.has(c)||(i.add(c),l>=t))continue;let u=this.typeHierarchy.get(c)??[];for(let f of u)i.has(f)||(r.push(f),s.push({uri:f,currentDepth:l+1}))}return r}getChildTypes(e){let t=[];for(let[r,i]of this.typeHierarchy)i.includes(e)&&t.push(r);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],r="unknown",i="custom";if(e.assetClass){let c=this.normalizeTypeUri(e.assetClass);t.push(c),r=c,i="exo:Instance_class"}let s=e.properties?.[ut.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),r==="unknown"&&(r=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 a=this.resolveNodeStyle(t);return{primaryType:r,types:t,resolvedStyle:a,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,r=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:r}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:r}=this.config.styleResolution,i={...r},s=[];for(let a of e){let c=this.nodeTypes.get(a);c&&s.push(c)}if(s.sort((a,c)=>a.priority-c.priority),t)for(let a of s)i=(0,ut.mergeNodeStyles)(i,a.style);else if(s.length>0){let a=s[s.length-1];i=(0,ut.mergeNodeStyles)(i,a.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,r={...t},i=this.edgeTypes.get(e);return i&&(r=(0,ut.mergeEdgeStyles)(r,i.style)),r}filterNodes(e,t){return e.filter(r=>{let i=this.resolveNodeType(r);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(a=>i.types.includes(a)||t.includeInferred&&this.isSubtypeOf(i.primaryType,a))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(a=>i.types.includes(a)||t.includeInferred&&this.isSubtypeOf(i.primaryType,a))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(r=>{let i=r.predicate??r.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,r={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:a=0,maxGroups:c=20,customGroupFn:l}=r,u=new Map;for(let h of e){let p=this.resolveNodeType(h),_;if(l?_=l(p.types):s&&p.types.length>a?_=p.types[a]??p.primaryType:i?_=p.primaryType:_="all",!u.has(_)){let w=this.nodeTypes.get(_)?.label??(0,ut.extractLocalName)(_);u.set(_,{nodeIds:new Set,label:w})}let b=u.get(_);b&&b.nodeIds.add(h.id)}let f=Array.from(u.entries()).map(([h,p])=>({id:h,label:p.label,nodeIds:Array.from(p.nodeIds)}));if(f.length>c){f.sort((_,b)=>b.nodeIds.length-_.nodeIds.length);let h=f.slice(0,c-1),p=f.slice(c-1).flatMap(_=>_.nodeIds);h.push({id:"other",label:"Other",nodeIds:p}),f=h}let d=new Map;for(let h of f)for(let p of h.nodeIds)d.set(p,h.id);return f.map((h,p)=>{let _=new Set(h.nodeIds),b=[],E=[];for(let R of t){let V=_.has(R.source),z=_.has(R.target);V&&z?R.id&&b.push(R.id):(V||z)&&R.id&&E.push(R.id)}let x=`hsl(${p*137.5%360}, 70%, 50%)`;return{id:h.id,label:h.label,nodeIds:h.nodeIds,internalEdgeIds:b,externalEdgeIds:E,color:x,stats:{nodeCount:h.nodeIds.length,internalEdgeCount:b.length,externalEdgeCount:E.length}}})}validateTypes(e,t){let r=[],i=[];for(let s of e){let a=this.resolveNodeType(s);if(a.primaryType!=="unknown"){let c=this.nodeTypes.get(a.primaryType);!c&&a.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${a.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 "${a.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 a=s.predicate??s.type,c=this.edgeTypes.get(a);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))||r.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))||r.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:c.range,actual:u.types})}}}return{valid:r.length===0,errors:r,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let r of e){let i=this.getObjectValue(r.object);if(i&&(0,ut.isClassType)(i)){let s=this.getSubjectValue(r.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let r of t){let i=this.getSubjectValue(r.subject),s=this.getObjectValue(r.object);if(i&&s){let a=this.typeHierarchy.get(i)??[];if(!a.includes(s)){a.push(s),this.typeHierarchy.set(i,a);let c=this.nodeTypes.get(i);c&&(c.parentTypes=a)}}}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(ut.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,ut.extractLocalName)(e),source:"custom",style:(0,ut.mergeNodeStyles)(ut.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(ut.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,ut.extractLocalName)(e),source:"custom",style:(0,ut.mergeEdgeStyles)(ut.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new Ji.IRI(e),new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),r=await this.tripleStore.match(new Ji.IRI(e),new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,ut.extractLocalName)(e):(0,ut.extractLocalName)(e),s=r.length>0?this.getObjectValue(r[0].object):void 0,a="rdfs:Class",c=await this.tripleStore.match(new Ji.IRI(e),new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of c)if(this.getObjectValue(f.object)===ut.RDF_TYPE_PREDICATES.OWL_CLASS){a="owl:Class";break}let l=ut.BUILT_IN_NODE_STYLES[e]??ut.BUILT_IN_NODE_STYLES[(0,ut.extractLocalName)(e)],u={uri:e,label:i,description:s,source:a,style:(0,ut.mergeNodeStyles)(ut.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 Ji.IRI)return e.value;if(e instanceof W3.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof yj.Literal||e instanceof Ji.IRI)return e.value;if(e instanceof W3.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let r of this.typeHierarchy.values())for(let i of r)e.add(i);let t=[];for(let r of this.nodeTypes.keys()){let i=this.typeHierarchy.get(r);(!i||i.length===0)&&e.has(r)&&t.push(r)}return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(r){_j.LoggingService.error("TypeRegistry: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}}};Bs.TypeRegistry=fv;Bs.TypeRegistry=fv=pj([(0,gj.injectable)(),mj("design:paramtypes",[Object,Object])],fv)});var dv=v(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.SPARQL_TEMPLATES=j.KNOWN_CLASSES=j.KNOWN_PROTOTYPES=j.EFFORT_STATUSES=j.ASSET_CLASSES=j.PREDICATES=j.SPARQL_PREFIXES=void 0;j.findClassByTerm=vj;j.getTemplateByName=bj;j.findMatchingTemplates=Sj;j.fillTemplate=wj;j.validateParameters=Ej;j.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
|
|
215
|
+
---`)}};gi.AssetConversionService=ev;gi.AssetConversionService=ev=W9([(0,L3.injectable)(),z9(0,(0,L3.inject)(Q9.DI_TOKENS.IVaultAdapter)),G9("design:paramtypes",[Object])],ev)});var iv=v(yi=>{"use strict";var Y9=yi&&yi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},X9=yi&&yi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},M3=yi&&yi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(yi,"__esModule",{value:!0});yi.SessionEventService=void 0;var rv=ve(),K9=hn(),j3=xn(),J9=rn(),Z9=Yi(),$3=Tt(),nv=class{static{o(this,"SessionEventService")}constructor(e,t){this.vault=e,this.vaultSettings=t,this.folderPathCache=null}async createSessionStartEvent(e){return this.createSessionEvent(e,j3.AssetClass.SESSION_START_EVENT)}async createSessionEndEvent(e){return this.createSessionEvent(e,j3.AssetClass.SESSION_END_EVENT)}getSessionEventFolder(){if(this.folderPathCache!==null)return this.folderPathCache;let e=this.vault.getDefaultNewFileParent();return this.folderPathCache=e?.path||"",this.folderPathCache}async createSessionEvent(e,t){let r=(0,K9.v4)(),i=J9.DateFormatter.toLocalTimestamp(new Date),s={exo__Asset_uid:r,exo__Asset_createdAt:i,exo__Asset_isDefinedBy:this.vaultSettings.getOwnerIdentity(),exo__Instance_class:[`"[[${t}]]"`],ems__SessionEvent_timestamp:i,ems__Session_area:`"[[${e}]]"`},a=Z9.MetadataHelpers.buildFileContent(s),c=this.getSessionEventFolder();c&&!await this.vault.exists(c)&&await this.vault.createFolder(c);let l=c?`${c}/${r}.md`:`${r}.md`;return await this.vault.create(l,a)}};yi.SessionEventService=nv;yi.SessionEventService=nv=Y9([(0,rv.injectable)(),M3(0,(0,rv.inject)($3.DI_TOKENS.IVaultAdapter)),M3(1,(0,rv.inject)($3.DI_TOKENS.IVaultSettings)),X9("design:paramtypes",[Object,Object])],nv)});var ov=v(_i=>{"use strict";var ej=_i&&_i.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},tj=_i&&_i.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},V3=_i&&_i.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(_i,"__esModule",{value:!0});_i.URIConstructionService=void 0;var sv=ve(),U3=Tt(),rj=Du(),av=class{static{o(this,"URIConstructionService")}constructor(e,t=rj.NullLogger){this.fileSystem=e,this.logger=t,this.defaultOntologyURL="https://exocortex.my/default/",this.strictValidation=!0}configure(e){e?.defaultOntologyURL&&(this.defaultOntologyURL=e.defaultOntologyURL),e?.strictValidation!==void 0&&(this.strictValidation=e.strictValidation)}async constructAssetURI(e){let t=this.extractUID(e);if(!t){if(this.strictValidation)throw new Error(`Asset missing exo__Asset_uid: ${e.path}`);return this.logger.warn(`Asset ${e.path} missing UID, using filename fallback`),this.constructFallbackURI(e)}let r=await this.resolveOntologyURL(e);if(!this.validateOntologyURL(r))throw new Error(`Invalid ontology URL: ${r}`);return`${r.endsWith("/")?r:`${r}/`}${t}`}validateOntologyURL(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}async resolveOntologyURL(e){let t=e.frontmatter?.exo__Asset_isDefinedBy;if(!t||typeof t!="string")return this.defaultOntologyURL;let r=this.extractWikiLink(t),i=r,s=await this.fileSystem.fileExists(r);return!s&&!r.endsWith(".md")&&(i=`${r}.md`,s=await this.fileSystem.fileExists(i)),s?(await this.fileSystem.getFileMetadata(i))?.exo__Ontology_url||this.defaultOntologyURL:(this.logger.warn(`Ontology file not found: ${r}, using default`),this.defaultOntologyURL)}extractUID(e){let t=e.frontmatter?.exo__Asset_uid;return typeof t=="string"?t:null}extractWikiLink(e){return e.replace(/^\[\[|\]\]$/g,"")}constructFallbackURI(e){let t=e.path.split("/").pop()?.replace(".md","")||"unknown";return`${this.defaultOntologyURL}${t}`}};_i.URIConstructionService=av;_i.URIConstructionService=av=ej([(0,sv.injectable)(),V3(0,(0,sv.inject)(U3.DI_TOKENS.IFileSystemAdapter)),V3(1,(0,sv.inject)(U3.DI_TOKENS.ILogger)),tj("design:paramtypes",[Object,Object])],av)});var lv=v(vi=>{"use strict";var nj=vi&&vi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},ij=vi&&vi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},sj=vi&&vi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(vi,"__esModule",{value:!0});vi.GenericAssetCreationService=void 0;var B3=ve(),aj=hn(),Nu=rn(),oj=Yi(),cj=Tt(),Xi=$d(),cv=class{static{o(this,"GenericAssetCreationService")}constructor(e){this.vault=e}async createAsset(e,t){let r=(0,aj.v4)(),i=`${r}.md`,s=this.generateFrontmatter(e,t||[],r),a=oj.MetadataHelpers.buildFileContent(s),c=e.folderPath||this.getDefaultFolderPath(e);this.vault.getAbstractFileByPath(c)||await this.vault.createFolder(c);let u=c?`${c}/${i}`:i;return await this.vault.create(u,a)}generateFrontmatter(e,t,r){let i=new Date,s={},a=new Map;for(let c of t)a.set(c.name,c.fieldType);if(s.exo__Asset_uid=r,s.exo__Asset_createdAt=Nu.DateFormatter.toLocalTimestamp(i),s.exo__Instance_class=[this.formatWikilink(e.className)],e.label&&e.label.trim()!==""){let c=e.label.trim();s.exo__Asset_label=c,s.aliases=[c]}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(s,e),e.propertyValues)for(let[c,l]of Object.entries(e.propertyValues)){if(c==="exo__Asset_uid"||c==="exo__Asset_createdAt"||c==="exo__Instance_class"||c==="exo__Asset_label"||c==="aliases"||l==null)continue;let u=a.get(c);s[c]=this.formatValue(l,u)}return s}inheritParentContext(e,t){let r=t.parentMetadata||{},i=t.parentFile?.basename;if(t.className==="ems__Task"||t.className.startsWith("ems__Task")){let s=r.exo__Instance_class,c=this.isAreaClass(s)?"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=r.exo__Instance_class;this.isAreaClass(s)&&(e.ems__Project_area=i?this.formatWikilink(i):null)}r.exo__Asset_isDefinedBy&&(e.exo__Asset_isDefinedBy=r.exo__Asset_isDefinedBy)}isAreaClass(e){return e?(Array.isArray(e)?e:[e]).some(r=>String(r).includes("Area")||String(r).includes("ems__Area")):!1}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[r,i]of Object.entries(t))if(e.className.startsWith(r))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case Xi.PropertyFieldType.Text:return String(e);case Xi.PropertyFieldType.Wikilink:case Xi.PropertyFieldType.Reference:case Xi.PropertyFieldType.StatusSelect:case Xi.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case Xi.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case Xi.PropertyFieldType.Boolean:return this.formatBoolean(e);case Xi.PropertyFieldType.Date:case Xi.PropertyFieldType.DateTime:case Xi.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?Nu.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 Nu.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:Nu.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return Nu.DateFormatter.toLocalTimestamp(t)}return String(e)}};vi.GenericAssetCreationService=cv;vi.GenericAssetCreationService=cv=nj([(0,B3.injectable)(),sj(0,(0,B3.inject)(cj.DI_TOKENS.IVaultAdapter)),ij("design:paramtypes",[Object])],cv)});var q3=v(Us=>{"use strict";var lj=Us&&Us.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},uj=Us&&Us.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Us,"__esModule",{value:!0});Us.GraphQueryService=void 0;var fj=ve(),Lu=xe(),dj=Ge(),ya=wr(),hj=dy(),Ki={INSTANCE_CLASS:ya.Namespace.EXO.term("Instance_class"),ASSET_LABEL:ya.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:ya.Namespace.EXO.term("Asset_prototype"),ASSET_IS_ARCHIVED:ya.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:ya.Namespace.EMS.term("Effort_parent"),REFERENCES:ya.Namespace.EXO.term("references"),REFERENCED_BY:ya.Namespace.EXO.term("referencedBy"),RDF_TYPE:ya.Namespace.RDF.term("type")},uv=class{static{o(this,"GraphQueryService")}constructor(e,t={},r){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.logger=r,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(),r=await this.loadNodes(e),i=await this.loadEdges(r,e),s=this.computeStats(r,i),a=Date.now()-t;return a>100&&r.length>0&&this.logger?.debug(`GraphQueryService: loaded ${r.length} nodes in ${a}ms (${(a/r.length).toFixed(2)}ms/node)`),{nodes:r,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),r=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:r}),s=i.length>t,a=s?i.slice(0,t):i,c=await this.loadEdges(a,e);return{nodes:a,edges:c,hasMore:s,totalCount:void 0,cursor:s?String(r+t):void 0}}async loadConnectedNodes(e,t={}){let r=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,a=[{id:e,currentDepth:0}],c=[];for(;a.length>0&&c.length<i;){let u=a.shift();if(!u)break;let{id:f,currentDepth:d}=u;if(s.has(f))continue;s.add(f);let h=await this.getNodeById(f,t);if(h&&(c.push(h),d<r)){let p=await this.getConnectedNodeIds(f);for(let _ of p)s.has(_)||a.push({id:_,currentDepth:d+1})}}let l=await this.loadEdges(c,t);return{nodes:c,edges:l,hasMore:a.length>0,totalCount:s.size+a.length}}async getNodeById(e,t={}){let r=this.getCachedNode(e);if(r)return{...r};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let a=this.triplesToNode(e,s,t);return a&&this.cacheNode(a),a}subscribe(e){return this.subscribers.add(e),{unsubscribe:o(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(r){this.logger?.error("GraphQueryService: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}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,r=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,Ki.INSTANCE_CLASS,void 0),a=s;if(e.classes&&e.classes.length>0){let p=new Set(e.classes);a=s.filter(_=>{let b=this.getObjectValue(_.object);return b&&p.has(b)})}let c=new Set;for(let p of a)c.add(this.subjectToId(p.subject));let f=Array.from(c).slice(i,i+r).map(p=>this.getNodeById(p,e));return(await Promise.all(f)).filter(p=>!(!p||!t&&p.isArchived))}async loadEdges(e,t){let r=new Set(e.map(a=>a.id)),i=[],s=new Set;for(let a of e){let c=this.idToIRI(a.id),l=await this.tripleStore.match(c,void 0,void 0);for(let u of l){let f=this.tripleToEdge(a.id,u,r);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),r=[],i=await this.tripleStore.match(t,void 0,void 0);for(let a of i){let c=this.objectToId(a.object);c&&r.push(c)}let s=await this.tripleStore.match(void 0,void 0,t);for(let a of s)r.push(this.subjectToId(a.subject));return[...new Set(r)]}triplesToNode(e,t,r){let i={},s,a,c,l,u=!1;for(let h of t){let p=h.predicate.value,_=this.getObjectValue(h.object);if(p===Ki.INSTANCE_CLASS.value)s=_;else if(p===Ki.ASSET_LABEL.value)a=_;else if(p===Ki.ASSET_PROTOTYPE.value)c=this.objectToId(h.object)??_;else if(p===Ki.EFFORT_PARENT.value)l=this.objectToId(h.object)??_;else if(p===Ki.ASSET_IS_ARCHIVED.value)u=_==="true"||_==="1";else{let b=this.predicateToPropertyName(p);b&&(i[b]=_)}}if(u&&!(r.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),d=a??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,r){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!r.has(s)||s===e)return null;let a=this.predicateToEdgeType(i);if(!a)return null;let c=(0,hj.createEdgeId)(e,s,a,i),l=this.predicateToLabel(i);return{id:c,source:e,target:s,type:a,predicate:i,label:l}}predicateToEdgeType(e){return e===Ki.EFFORT_PARENT.value?"hierarchy":e===Ki.ASSET_PROTOTYPE.value?"prototype":e===Ki.REFERENCES.value?"forward-link":e===Ki.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),r=e.lastIndexOf("/"),i=Math.max(t,r);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let r={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let c of e){let l=c.assetClass??"unknown";r[l]=(r[l]??0)+1}for(let c of t)i[c.type]=(i[c.type]??0)+1;let s=new Map,a=new Map;for(let c of t)a.set(c.source,(a.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=a.get(c.id)??0,c.weight=c.inDegree+c.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:r,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new Lu.IRI(e):new Lu.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof Lu.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof Lu.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof dj.Literal||e instanceof Lu.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()}};Us.GraphQueryService=uv;Us.GraphQueryService=uv=lj([(0,fj.injectable)(),uj("design:paramtypes",[Object,Object,Object])],uv)});var G3=v(Bs=>{"use strict";var pj=Bs&&Bs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},mj=Bs&&Bs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Bs,"__esModule",{value:!0});Bs.TypeRegistry=void 0;var gj=ve(),Ji=xe(),W3=Vt(),yj=Ge(),_j=pa(),ut=hy(),fv=class{static{o(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:ut.DEFAULT_NODE_STYLE,defaultEdgeStyle:ut.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let r=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:r,typeUri:e.uri,definition:e})}registerEdgeType(e){let r=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:r,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),r=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||r)&&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 r=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let a=s.shift();if(!a)break;let{uri:c,currentDepth:l}=a;if(i.has(c)||(i.add(c),l>=t))continue;let u=this.typeHierarchy.get(c)??[];for(let f of u)i.has(f)||(r.push(f),s.push({uri:f,currentDepth:l+1}))}return r}getChildTypes(e){let t=[];for(let[r,i]of this.typeHierarchy)i.includes(e)&&t.push(r);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],r="unknown",i="custom";if(e.assetClass){let c=this.normalizeTypeUri(e.assetClass);t.push(c),r=c,i="exo:Instance_class"}let s=e.properties?.[ut.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),r==="unknown"&&(r=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 a=this.resolveNodeStyle(t);return{primaryType:r,types:t,resolvedStyle:a,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,r=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:r}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:r}=this.config.styleResolution,i={...r},s=[];for(let a of e){let c=this.nodeTypes.get(a);c&&s.push(c)}if(s.sort((a,c)=>a.priority-c.priority),t)for(let a of s)i=(0,ut.mergeNodeStyles)(i,a.style);else if(s.length>0){let a=s[s.length-1];i=(0,ut.mergeNodeStyles)(i,a.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,r={...t},i=this.edgeTypes.get(e);return i&&(r=(0,ut.mergeEdgeStyles)(r,i.style)),r}filterNodes(e,t){return e.filter(r=>{let i=this.resolveNodeType(r);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(a=>i.types.includes(a)||t.includeInferred&&this.isSubtypeOf(i.primaryType,a))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(a=>i.types.includes(a)||t.includeInferred&&this.isSubtypeOf(i.primaryType,a))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(r=>{let i=r.predicate??r.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,r={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:a=0,maxGroups:c=20,customGroupFn:l}=r,u=new Map;for(let h of e){let p=this.resolveNodeType(h),_;if(l?_=l(p.types):s&&p.types.length>a?_=p.types[a]??p.primaryType:i?_=p.primaryType:_="all",!u.has(_)){let w=this.nodeTypes.get(_)?.label??(0,ut.extractLocalName)(_);u.set(_,{nodeIds:new Set,label:w})}let b=u.get(_);b&&b.nodeIds.add(h.id)}let f=Array.from(u.entries()).map(([h,p])=>({id:h,label:p.label,nodeIds:Array.from(p.nodeIds)}));if(f.length>c){f.sort((_,b)=>b.nodeIds.length-_.nodeIds.length);let h=f.slice(0,c-1),p=f.slice(c-1).flatMap(_=>_.nodeIds);h.push({id:"other",label:"Other",nodeIds:p}),f=h}let d=new Map;for(let h of f)for(let p of h.nodeIds)d.set(p,h.id);return f.map((h,p)=>{let _=new Set(h.nodeIds),b=[],E=[];for(let R of t){let V=_.has(R.source),z=_.has(R.target);V&&z?R.id&&b.push(R.id):(V||z)&&R.id&&E.push(R.id)}let x=`hsl(${p*137.5%360}, 70%, 50%)`;return{id:h.id,label:h.label,nodeIds:h.nodeIds,internalEdgeIds:b,externalEdgeIds:E,color:x,stats:{nodeCount:h.nodeIds.length,internalEdgeCount:b.length,externalEdgeCount:E.length}}})}validateTypes(e,t){let r=[],i=[];for(let s of e){let a=this.resolveNodeType(s);if(a.primaryType!=="unknown"){let c=this.nodeTypes.get(a.primaryType);!c&&a.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${a.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 "${a.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 a=s.predicate??s.type,c=this.edgeTypes.get(a);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))||r.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))||r.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:c.range,actual:u.types})}}}return{valid:r.length===0,errors:r,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let r of e){let i=this.getObjectValue(r.object);if(i&&(0,ut.isClassType)(i)){let s=this.getSubjectValue(r.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let r of t){let i=this.getSubjectValue(r.subject),s=this.getObjectValue(r.object);if(i&&s){let a=this.typeHierarchy.get(i)??[];if(!a.includes(s)){a.push(s),this.typeHierarchy.set(i,a);let c=this.nodeTypes.get(i);c&&(c.parentTypes=a)}}}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(ut.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,ut.extractLocalName)(e),source:"custom",style:(0,ut.mergeNodeStyles)(ut.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(ut.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,ut.extractLocalName)(e),source:"custom",style:(0,ut.mergeEdgeStyles)(ut.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new Ji.IRI(e),new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),r=await this.tripleStore.match(new Ji.IRI(e),new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,ut.extractLocalName)(e):(0,ut.extractLocalName)(e),s=r.length>0?this.getObjectValue(r[0].object):void 0,a="rdfs:Class",c=await this.tripleStore.match(new Ji.IRI(e),new Ji.IRI(ut.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of c)if(this.getObjectValue(f.object)===ut.RDF_TYPE_PREDICATES.OWL_CLASS){a="owl:Class";break}let l=ut.BUILT_IN_NODE_STYLES[e]??ut.BUILT_IN_NODE_STYLES[(0,ut.extractLocalName)(e)],u={uri:e,label:i,description:s,source:a,style:(0,ut.mergeNodeStyles)(ut.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 Ji.IRI)return e.value;if(e instanceof W3.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof yj.Literal||e instanceof Ji.IRI)return e.value;if(e instanceof W3.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let r of this.typeHierarchy.values())for(let i of r)e.add(i);let t=[];for(let r of this.nodeTypes.keys()){let i=this.typeHierarchy.get(r);(!i||i.length===0)&&e.has(r)&&t.push(r)}return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(r){_j.LoggingService.error("TypeRegistry: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}}};Bs.TypeRegistry=fv;Bs.TypeRegistry=fv=pj([(0,gj.injectable)(),mj("design:paramtypes",[Object,Object])],fv)});var dv=v(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.SPARQL_TEMPLATES=j.KNOWN_CLASSES=j.KNOWN_PROTOTYPES=j.EFFORT_STATUSES=j.ASSET_CLASSES=j.PREDICATES=j.SPARQL_PREFIXES=void 0;j.findClassByTerm=vj;j.getTemplateByName=bj;j.findMatchingTemplates=Sj;j.fillTemplate=wj;j.validateParameters=Ej;j.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
|
|
216
216
|
PREFIX ems: <https://exocortex.my/ontology/ems#>
|
|
217
217
|
PREFIX ims: <https://exocortex.my/ontology/ims#>
|
|
218
218
|
PREFIX gtd: <https://exocortex.my/ontology/gtd#>
|
|
@@ -744,7 +744,7 @@ ${Pr.dump(i,{lineWidth:-1})}---
|
|
|
744
744
|
\u{1F50D} Dry-run: command "${l.name}" on "${t.target}"
|
|
745
745
|
`),console.log(" Precondition: passed \u2705"),console.log(" Grounding (would execute):"),SS(l.grounding," ");return}let h=new Mt.ServiceRegistry;HO(h);let p=new Ft(i),b=await new Mt.GroundingExecutor(p,p,h).execute(l.grounding,u,t.target);if(r==="json"){let E=Z.success({command:l.name,target:t.target,preconditionPassed:!0,executed:!0,success:b.success,...b.error&&{error:b.error},...l.successMessage&&b.success&&{message:l.successMessage}});console.log(JSON.stringify(E,null,2))}else if(b.success){let E=l.successMessage??`Command "${l.name}" executed successfully.`;console.log(`\u2705 ${E}`)}else console.log(`\u274C Command "${l.name}" failed: ${b.error}`),process.exitCode=5}catch(i){k.handle(i)}}),n.command("validate").description("Validate all dynamic command definitions in vault").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async e=>{let t=e.output||"text";k.setFormat(t);try{let r=(0,fs.resolve)(e.vault);if(!(0,us.existsSync)(r))throw new Ce(r);let i=tH(r);if(t==="json"){let s=Z.success({totalCommands:vS(r).length,totalIssues:i.reduce((a,c)=>a+c.issues.length,0),commandsWithIssues:i.length,issues:i});console.log(JSON.stringify(s,null,2))}else{let s=vS(r);if(i.length===0)console.log(`\u2705 All ${s.length} dynamic command(s) are valid.`);else{let a=i.reduce((c,l)=>c+l.issues.length,0);console.log(`\u274C Found ${a} issue(s) in ${i.length} command(s) out of ${s.length} total:
|
|
746
746
|
`);for(let c of i){console.log(` \u{1F4C4} ${c.label} (${c.uid}):`);for(let l of c.issues)console.log(` \u2022 ${l}`);console.log()}process.exitCode=5}}}catch(r){k.handle(r)}}),n}o(QO,"dynamicCommandCommand");function vS(n){let e=[],t=[];wS(n,t);for(let{filePath:r,fm:i}of t){if(!Ml(i,"exocmd__Command"))continue;let s=i.exo__Asset_uid??"",a=i.exo__Asset_label??YO(r),c=i.exocmd__Command_category,l=i.exocmd__Command_icon,u=!!i.exocmd__Command_precondition,f=i.exocmd__Command_grounding,d;if(f){let h=Tg(String(f)),p=t.find(_=>_.fm.exo__Asset_uid===h&&Ml(_.fm,"exocmd__Grounding"));p&&(d=p.fm.exocmd__Grounding_type)}e.push({filePath:r,uid:s,label:a,category:c,icon:l,hasPrecondition:u,groundingType:d})}return e}o(vS,"scanCommands");async function eH(n,e){let{tripleStore:t}=await bS(n),r=new Mt.CommandResolver(t),i=await r.findBindings(),s=new Set;for(let c of i)s.add(c.commandRef);let a=[];for(let c of s){let l=await r.loadCommand(c);l&&a.push({filePath:"",uid:l.id,label:l.name,category:l.category,icon:l.icon,hasPrecondition:!!l.precondition,groundingType:l.grounding.type})}return a}o(eH,"listCommandsForTarget");function tH(n){let e=[],t=[];wS(n,t);let r=new Map;for(let i of t){let s=i.fm.exo__Asset_uid;s&&r.set(s,i)}for(let{filePath:i,fm:s}of t){if(!Ml(s,"exocmd__Command"))continue;let a=s.exo__Asset_uid??"",c=s.exo__Asset_label??YO(i),l=[];a||l.push("Missing exo__Asset_uid"),s.exo__Asset_label||l.push("Missing exo__Asset_label");let u=s.exocmd__Command_grounding;if(!u)l.push("Missing exocmd__Command_grounding (required)");else{let h=Tg(String(u)),p=r.get(h);if(!p)l.push(`Grounding reference "${h}" not found in vault`);else if(!Ml(p.fm,"exocmd__Grounding"))l.push(`Grounding reference "${h}" is not an exocmd__Grounding asset`);else{let _=p.fm,b=_.exocmd__Grounding_type;b?(Object.values(Mt.GroundingType).includes(b)||l.push(`Grounding "${h}" has invalid type "${b}"`),(b===Mt.GroundingType.PROPERTY_SET||b===Mt.GroundingType.PROPERTY_DELETE)&&!_.exocmd__Grounding_targetProperty&&l.push(`Grounding "${h}" (${b}) missing targetProperty`),b===Mt.GroundingType.PROPERTY_SET&&!_.exocmd__Grounding_targetValue&&l.push(`Grounding "${h}" (property_set) missing targetValue`),b===Mt.GroundingType.SERVICE_CALL&&((_.exocmd__Grounding_serviceId??_.exocmd__Grounding_targetProperty)||l.push(`Grounding "${h}" (service_call) missing serviceId and targetProperty`))):l.push(`Grounding "${h}" missing exocmd__Grounding_type`)}}let f=s.exocmd__Command_precondition;if(f){let h=Tg(String(f)),p=r.get(h);if(!p)l.push(`Precondition reference "${h}" not found in vault`);else if(!Ml(p.fm,"exocmd__Precondition"))l.push(`Precondition reference "${h}" is not an exocmd__Precondition asset`);else{let _=p.fm.exocmd__Precondition_sparqlAsk,b=p.fm.exocmd__Precondition_hostFunction;!_&&!b&&l.push(`Precondition "${h}" missing both sparqlAsk and hostFunction`)}}t.some(h=>Ml(h.fm,"exocmd__CommandBinding")?Tg(String(h.fm.exocmd__CommandBinding_command??""))===a:!1)||l.push("No CommandBinding references this command (command will be unused)"),l.length>0&&e.push({uid:a,label:c,filePath:i,issues:l})}return e}o(tH,"validateCommands");async function bS(n){let e=new hr(n),r=await new Mt.NoteToRDFConverter(e).convertVault(),i=new Mt.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}o(bS,"buildTripleStore");function SS(n,e){if(console.log(`${e}ID: ${n.id}`),console.log(`${e}Label: ${n.label}`),console.log(`${e}Type: ${n.type}`),n.targetProperty&&console.log(`${e}Target property: ${n.targetProperty}`),n.targetValue!==void 0&&console.log(`${e}Target value: ${n.targetValue}`),n.sparqlUpdate&&console.log(`${e}SPARQL UPDATE: ${n.sparqlUpdate}`),n.steps&&n.steps.length>0){console.log(`${e}Steps (${n.steps.length}):`);for(let t=0;t<n.steps.length;t++)console.log(`${e} Step ${t+1}:`),SS(n.steps[t],e+" ")}}o(SS,"printGrounding");function wS(n,e){let t;try{t=(0,us.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,fs.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;wS(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,us.readFileSync)(i,"utf-8"),a=Zz.parse(s);a.exists&&e.push({filePath:i,fm:rH(a.content)})}catch{}}}o(wS,"collectParsedFiles");function rH(n){let e={},t=n.split(`
|
|
747
|
-
`),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let c=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(c),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let c=a[2].trim();if((c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),c==="true"?c=!0:c==="false"&&(c=!1),c===""){e[r]=[],i=e[r];continue}e[r]=c}}return e}o(rH,"parseYamlFrontmatter");function Ml(n,e){let t=n.exo__Instance_class;if(!t)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}o(Ml,"hasClass");function Tg(n){if(typeof n!="string")return"";let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.substring(0,t).trim():e}o(Tg,"normalizeWikilink");function YO(n){return(0,fs.basename)(n,".md")}o(YO,"extractLabelFromFilename");function XO(n){n.addCommand(GR()),n.addCommand(YR()),n.addCommand(XR())}o(XO,"addQuerySubcommands");function KO(n){let e=new Le;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.90.
|
|
747
|
+
`),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let c=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(c),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let c=a[2].trim();if((c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),c==="true"?c=!0:c==="false"&&(c=!1),c===""){e[r]=[],i=e[r];continue}e[r]=c}}return e}o(rH,"parseYamlFrontmatter");function Ml(n,e){let t=n.exo__Instance_class;if(!t)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}o(Ml,"hasClass");function Tg(n){if(typeof n!="string")return"";let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.substring(0,t).trim():e}o(Tg,"normalizeWikilink");function YO(n){return(0,fs.basename)(n,".md")}o(YO,"extractLabelFromFilename");function XO(n){n.addCommand(GR()),n.addCommand(YR()),n.addCommand(XR())}o(XO,"addQuerySubcommands");function KO(n){let e=new Le;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.90.23");let t=e.command("exoql").description("ExoQL query execution and cache management");XO(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return XO(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(iO()),e.addCommand(oO()),e.addCommand(cO()),e.addCommand(uO()),e.addCommand(fO()),e.addCommand(gO()),e.addCommand(bO()),e.addCommand(IO()),e.addCommand(OO()),e.addCommand(kO()),e.addCommand($O()),e.addCommand(VO()),e.addCommand(BO()),e.addCommand(QO()),e}o(KO,"createProgram");KO().parse();0&&(module.exports={createProgram});
|
|
748
748
|
/*! Bundled license information:
|
|
749
749
|
|
|
750
750
|
reflect-metadata/Reflect.js:
|
package/package.json
CHANGED