@kitelev/exocortex-cli 15.104.0 → 15.105.0
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.
|
|
2
|
+
// @kitelev/exocortex-cli v15.105.0
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
@@ -214,7 +214,7 @@ ${s}`}return`${r}: ${i}`}).join(`
|
|
|
214
214
|
`,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}};Bs.EnumValueResolver=sv;Bs.EnumValueResolver=sv=tj([(0,nj.injectable)(),rj("design:paramtypes",[Object,Object])],sv)});var ov=v(vi=>{"use strict";var ij=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},sj=vi&&vi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},aj=vi&&vi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(vi,"__esModule",{value:!0});vi.AssetConversionService=void 0;var B3=ve(),q3=In(),oj=Yi(),Ap=ya(),cj=Tt(),av=class{static{o(this,"AssetConversionService")}constructor(e){this.vault=e,this.frontmatterService=new oj.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",`["[[${q3.AssetClass.PROJECT}]]"]`),await this.vault.modify(e,r),Ap.LoggingService.info(`Converted Task to Project: ${e.basename} (${e.path})`),e}catch(t){let r=`Failed to convert Task to Project: ${e.path}`;throw Ap.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",`["[[${q3.AssetClass.TASK}]]"]`),await this.vault.modify(e,r),Ap.LoggingService.info(`Converted Project to Task: ${e.basename} (${e.path})`),e}catch(t){let r=`Failed to convert Project to Task: ${e.path}`;throw Ap.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,`
|
|
215
215
|
`).trim();return e.replace(/^---\n[\s\S]*?\n---/,`---
|
|
216
216
|
${i}
|
|
217
|
-
---`)}};vi.AssetConversionService=av;vi.AssetConversionService=av=ij([(0,B3.injectable)(),aj(0,(0,B3.inject)(cj.DI_TOKENS.IVaultAdapter)),sj("design:paramtypes",[Object])],av)});var uv=v(Si=>{"use strict";var lj=Si&&Si.__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=Si&&Si.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},W3=Si&&Si.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Si,"__esModule",{value:!0});Si.SessionEventService=void 0;var cv=ve(),fj=gn(),G3=In(),dj=Vr(),hj=Ki(),z3=Tt(),lv=class{static{o(this,"SessionEventService")}constructor(e,t){this.vault=e,this.vaultSettings=t,this.folderPathCache=null}async createSessionStartEvent(e){return this.createSessionEvent(e,G3.AssetClass.SESSION_START_EVENT)}async createSessionEndEvent(e){return this.createSessionEvent(e,G3.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,fj.v4)(),i=dj.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=hj.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)}};Si.SessionEventService=lv;Si.SessionEventService=lv=lj([(0,cv.injectable)(),W3(0,(0,cv.inject)(z3.DI_TOKENS.IVaultAdapter)),W3(1,(0,cv.inject)(z3.DI_TOKENS.IVaultSettings)),uj("design:paramtypes",[Object,Object])],lv)});var hv=v(bi=>{"use strict";var pj=bi&&bi.__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=bi&&bi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},H3=bi&&bi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(bi,"__esModule",{value:!0});bi.URIConstructionService=void 0;var fv=ve(),Q3=Tt(),gj=ku(),dv=class{static{o(this,"URIConstructionService")}constructor(e,t=gj.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}`}};bi.URIConstructionService=dv;bi.URIConstructionService=dv=pj([(0,fv.injectable)(),H3(0,(0,fv.inject)(Q3.DI_TOKENS.IFileSystemAdapter)),H3(1,(0,fv.inject)(Q3.DI_TOKENS.ILogger)),mj("design:paramtypes",[Object,Object])],dv)});var mv=v(wi=>{"use strict";var yj=wi&&wi.__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},_j=wi&&wi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},vj=wi&&wi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(wi,"__esModule",{value:!0});wi.GenericAssetCreationService=void 0;var Y3=ve(),Sj=gn(),ju=Vr(),bj=Ki(),wj=Tt(),Ji=zd(),pv=class{static{o(this,"GenericAssetCreationService")}constructor(e){this.vault=e}async createAsset(e,t){let r=(0,Sj.v4)(),i=`${r}.md`,s=this.generateFrontmatter(e,t||[],r),a=bj.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=ju.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 Ji.PropertyFieldType.Text:return String(e);case Ji.PropertyFieldType.Wikilink:case Ji.PropertyFieldType.Reference:case Ji.PropertyFieldType.StatusSelect:case Ji.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case Ji.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case Ji.PropertyFieldType.Boolean:return this.formatBoolean(e);case Ji.PropertyFieldType.Date:case Ji.PropertyFieldType.DateTime:case Ji.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?ju.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 ju.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:ju.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return ju.DateFormatter.toLocalTimestamp(t)}return String(e)}};wi.GenericAssetCreationService=pv;wi.GenericAssetCreationService=pv=yj([(0,Y3.injectable)(),vj(0,(0,Y3.inject)(wj.DI_TOKENS.IVaultAdapter)),_j("design:paramtypes",[Object])],pv)});var X3=v(qs=>{"use strict";var Ej=qs&&qs.__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=qs&&qs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(qs,"__esModule",{value:!0});qs.GraphQueryService=void 0;var Aj=ve(),$u=Ae(),xj=Ge(),Sa=Ar(),Cj=_y(),Zi={INSTANCE_CLASS:Sa.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Sa.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Sa.Namespace.EXO.term("Asset_prototype"),ASSET_IS_ARCHIVED:Sa.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Sa.Namespace.EMS.term("Effort_parent"),REFERENCES:Sa.Namespace.EXO.term("references"),REFERENCED_BY:Sa.Namespace.EXO.term("referencedBy"),RDF_TYPE:Sa.Namespace.RDF.term("type")},gv=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,Zi.INSTANCE_CLASS,void 0),a=s;if(e.classes&&e.classes.length>0){let p=new Set(e.classes);a=s.filter(_=>{let S=this.getObjectValue(_.object);return S&&p.has(S)})}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===Zi.INSTANCE_CLASS.value)s=_;else if(p===Zi.ASSET_LABEL.value)a=_;else if(p===Zi.ASSET_PROTOTYPE.value)c=this.objectToId(h.object)??_;else if(p===Zi.EFFORT_PARENT.value)l=this.objectToId(h.object)??_;else if(p===Zi.ASSET_IS_ARCHIVED.value)u=_==="true"||_==="1";else{let S=this.predicateToPropertyName(p);S&&(i[S]=_)}}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,Cj.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===Zi.EFFORT_PARENT.value?"hierarchy":e===Zi.ASSET_PROTOTYPE.value?"prototype":e===Zi.REFERENCES.value?"forward-link":e===Zi.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 $u.IRI(e):new $u.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof $u.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof $u.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof xj.Literal||e instanceof $u.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()}};qs.GraphQueryService=gv;qs.GraphQueryService=gv=Ej([(0,Aj.injectable)(),Tj("design:paramtypes",[Object,Object,Object])],gv)});var J3=v(Ws=>{"use strict";var Ij=Ws&&Ws.__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},Rj=Ws&&Ws.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Ws,"__esModule",{value:!0});Ws.TypeRegistry=void 0;var Oj=ve(),es=Ae(),K3=Ut(),Pj=Ge(),Dj=ya(),ut=vy(),yv=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 S=u.get(_);S&&S.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((_,S)=>S.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),S=[],E=[];for(let R of t){let V=_.has(R.source),z=_.has(R.target);V&&z?R.id&&S.push(R.id):(V||z)&&R.id&&E.push(R.id)}let A=`hsl(${p*137.5%360}, 70%, 50%)`;return{id:h.id,label:h.label,nodeIds:h.nodeIds,internalEdgeIds:S,externalEdgeIds:E,color:A,stats:{nodeCount:h.nodeIds.length,internalEdgeCount:S.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 es.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 es.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 es.IRI(e),new es.IRI(ut.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),r=await this.tripleStore.match(new es.IRI(e),new es.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 es.IRI(e),new es.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 es.IRI)return e.value;if(e instanceof K3.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof Pj.Literal||e instanceof es.IRI)return e.value;if(e instanceof K3.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){Dj.LoggingService.error("TypeRegistry: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}}};Ws.TypeRegistry=yv;Ws.TypeRegistry=yv=Ij([(0,Oj.injectable)(),Rj("design:paramtypes",[Object,Object])],yv)});var _v=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=Fj;j.getTemplateByName=Nj;j.findMatchingTemplates=Lj;j.fillTemplate=kj;j.validateParameters=Mj;j.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
|
|
217
|
+
---`)}};vi.AssetConversionService=av;vi.AssetConversionService=av=ij([(0,B3.injectable)(),aj(0,(0,B3.inject)(cj.DI_TOKENS.IVaultAdapter)),sj("design:paramtypes",[Object])],av)});var uv=v(Si=>{"use strict";var lj=Si&&Si.__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=Si&&Si.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},W3=Si&&Si.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Si,"__esModule",{value:!0});Si.SessionEventService=void 0;var cv=ve(),fj=gn(),G3=In(),dj=Vr(),hj=Ki(),z3=Tt(),lv=class{static{o(this,"SessionEventService")}constructor(e,t){this.vault=e,this.vaultSettings=t,this.folderPathCache=null}async createSessionStartEvent(e){return this.createSessionEvent(e,G3.AssetClass.SESSION_START_EVENT)}async createSessionEndEvent(e){return this.createSessionEvent(e,G3.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,fj.v4)(),i=dj.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=hj.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)}};Si.SessionEventService=lv;Si.SessionEventService=lv=lj([(0,cv.injectable)(),W3(0,(0,cv.inject)(z3.DI_TOKENS.IVaultAdapter)),W3(1,(0,cv.inject)(z3.DI_TOKENS.IVaultSettings)),uj("design:paramtypes",[Object,Object])],lv)});var hv=v(bi=>{"use strict";var pj=bi&&bi.__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=bi&&bi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},H3=bi&&bi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(bi,"__esModule",{value:!0});bi.URIConstructionService=void 0;var fv=ve(),Q3=Tt(),gj=ku(),dv=class{static{o(this,"URIConstructionService")}constructor(e,t=gj.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}`}};bi.URIConstructionService=dv;bi.URIConstructionService=dv=pj([(0,fv.injectable)(),H3(0,(0,fv.inject)(Q3.DI_TOKENS.IFileSystemAdapter)),H3(1,(0,fv.inject)(Q3.DI_TOKENS.ILogger)),mj("design:paramtypes",[Object,Object])],dv)});var mv=v(wi=>{"use strict";var yj=wi&&wi.__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},_j=wi&&wi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},vj=wi&&wi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(wi,"__esModule",{value:!0});wi.GenericAssetCreationService=void 0;var Y3=ve(),Sj=gn(),ju=Vr(),bj=Ki(),wj=Tt(),Ji=zd(),pv=class{static{o(this,"GenericAssetCreationService")}constructor(e){this.vault=e}async createAsset(e,t){let r=(0,Sj.v4)(),i=`${r}.md`,s=this.generateFrontmatter(e,t||[],r),a=bj.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=ju.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,c=this.isAreaClass(s)?"ems__Effort_area":"ems__Effort_parent";e[c]=i?this.formatWikilink(i):null}if(r.exo__Asset_isDefinedBy){let s=r.exo__Asset_isDefinedBy;e.exo__Asset_isDefinedBy=typeof s=="string"?this.formatWikilink(s):s}}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 Ji.PropertyFieldType.Text:return String(e);case Ji.PropertyFieldType.Wikilink:case Ji.PropertyFieldType.Reference:case Ji.PropertyFieldType.StatusSelect:case Ji.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case Ji.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case Ji.PropertyFieldType.Boolean:return this.formatBoolean(e);case Ji.PropertyFieldType.Date:case Ji.PropertyFieldType.DateTime:case Ji.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?ju.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 ju.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:ju.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return ju.DateFormatter.toLocalTimestamp(t)}return String(e)}};wi.GenericAssetCreationService=pv;wi.GenericAssetCreationService=pv=yj([(0,Y3.injectable)(),vj(0,(0,Y3.inject)(wj.DI_TOKENS.IVaultAdapter)),_j("design:paramtypes",[Object])],pv)});var X3=v(qs=>{"use strict";var Ej=qs&&qs.__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=qs&&qs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(qs,"__esModule",{value:!0});qs.GraphQueryService=void 0;var Aj=ve(),$u=Ae(),xj=Ge(),Sa=Ar(),Cj=_y(),Zi={INSTANCE_CLASS:Sa.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Sa.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Sa.Namespace.EXO.term("Asset_prototype"),ASSET_IS_ARCHIVED:Sa.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Sa.Namespace.EMS.term("Effort_parent"),REFERENCES:Sa.Namespace.EXO.term("references"),REFERENCED_BY:Sa.Namespace.EXO.term("referencedBy"),RDF_TYPE:Sa.Namespace.RDF.term("type")},gv=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,Zi.INSTANCE_CLASS,void 0),a=s;if(e.classes&&e.classes.length>0){let p=new Set(e.classes);a=s.filter(_=>{let S=this.getObjectValue(_.object);return S&&p.has(S)})}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===Zi.INSTANCE_CLASS.value)s=_;else if(p===Zi.ASSET_LABEL.value)a=_;else if(p===Zi.ASSET_PROTOTYPE.value)c=this.objectToId(h.object)??_;else if(p===Zi.EFFORT_PARENT.value)l=this.objectToId(h.object)??_;else if(p===Zi.ASSET_IS_ARCHIVED.value)u=_==="true"||_==="1";else{let S=this.predicateToPropertyName(p);S&&(i[S]=_)}}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,Cj.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===Zi.EFFORT_PARENT.value?"hierarchy":e===Zi.ASSET_PROTOTYPE.value?"prototype":e===Zi.REFERENCES.value?"forward-link":e===Zi.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 $u.IRI(e):new $u.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof $u.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof $u.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof xj.Literal||e instanceof $u.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()}};qs.GraphQueryService=gv;qs.GraphQueryService=gv=Ej([(0,Aj.injectable)(),Tj("design:paramtypes",[Object,Object,Object])],gv)});var J3=v(Ws=>{"use strict";var Ij=Ws&&Ws.__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},Rj=Ws&&Ws.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Ws,"__esModule",{value:!0});Ws.TypeRegistry=void 0;var Oj=ve(),es=Ae(),K3=Ut(),Pj=Ge(),Dj=ya(),ut=vy(),yv=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 S=u.get(_);S&&S.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((_,S)=>S.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),S=[],E=[];for(let R of t){let V=_.has(R.source),z=_.has(R.target);V&&z?R.id&&S.push(R.id):(V||z)&&R.id&&E.push(R.id)}let A=`hsl(${p*137.5%360}, 70%, 50%)`;return{id:h.id,label:h.label,nodeIds:h.nodeIds,internalEdgeIds:S,externalEdgeIds:E,color:A,stats:{nodeCount:h.nodeIds.length,internalEdgeCount:S.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 es.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 es.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 es.IRI(e),new es.IRI(ut.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),r=await this.tripleStore.match(new es.IRI(e),new es.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 es.IRI(e),new es.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 es.IRI)return e.value;if(e instanceof K3.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof Pj.Literal||e instanceof es.IRI)return e.value;if(e instanceof K3.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){Dj.LoggingService.error("TypeRegistry: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}}};Ws.TypeRegistry=yv;Ws.TypeRegistry=yv=Ij([(0,Oj.injectable)(),Rj("design:paramtypes",[Object,Object])],yv)});var _v=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=Fj;j.getTemplateByName=Nj;j.findMatchingTemplates=Lj;j.fillTemplate=kj;j.validateParameters=Mj;j.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
|
|
218
218
|
PREFIX ems: <https://exocortex.my/ontology/ems#>
|
|
219
219
|
PREFIX ims: <https://exocortex.my/ontology/ims#>
|
|
220
220
|
PREFIX gtd: <https://exocortex.my/ontology/gtd#>
|
|
@@ -750,7 +750,7 @@ ${Dr.dump(i,{lineWidth:-1})}---
|
|
|
750
750
|
`);for(let c of i){console.log(` \u{1F4C4} ${c.label} (${c.uid}):`);for(let l of c.issues)console.log(` \u2022 ${l}`);console.log()}process.exitCode=5}}}catch(r){F.handle(r)}}),n}o(tD,"dynamicCommandCommand");function A2(n){let e=[],t=[];I2(n,t);for(let{filePath:r,fm:i}of t){if(!Vl(i,"exocmd__Command"))continue;let s=i.exo__Asset_uid??"",a=i.exo__Asset_label??rD(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=Og(String(f)),p=t.find(_=>_.fm.exo__Asset_uid===h&&Vl(_.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(A2,"scanCommands");async function pH(n,e){let{tripleStore:t}=await x2(n),r=new jt.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(pH,"listCommandsForTarget");function mH(n){let e=[],t=[];I2(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(!Vl(s,"exocmd__Command"))continue;let a=s.exo__Asset_uid??"",c=s.exo__Asset_label??rD(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=Og(String(u)),p=r.get(h);if(!p)l.push(`Grounding reference "${h}" not found in vault`);else if(!Vl(p.fm,"exocmd__Grounding"))l.push(`Grounding reference "${h}" is not an exocmd__Grounding asset`);else{let _=p.fm,S=_.exocmd__Grounding_type;S?(Object.values(jt.GroundingType).includes(S)||l.push(`Grounding "${h}" has invalid type "${S}"`),(S===jt.GroundingType.PROPERTY_SET||S===jt.GroundingType.PROPERTY_DELETE)&&!_.exocmd__Grounding_targetProperty&&l.push(`Grounding "${h}" (${S}) missing targetProperty`),S===jt.GroundingType.PROPERTY_SET&&!_.exocmd__Grounding_targetValue&&l.push(`Grounding "${h}" (property_set) missing targetValue`),S===jt.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=Og(String(f)),p=r.get(h);if(!p)l.push(`Precondition reference "${h}" not found in vault`);else if(!Vl(p.fm,"exocmd__Precondition"))l.push(`Precondition reference "${h}" is not an exocmd__Precondition asset`);else{let _=p.fm.exocmd__Precondition_sparqlAsk,S=p.fm.exocmd__Precondition_hostFunction;!_&&!S&&l.push(`Precondition "${h}" missing both sparqlAsk and hostFunction`)}}t.some(h=>Vl(h.fm,"exocmd__CommandBinding")?Og(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(mH,"validateCommands");async function x2(n){let e=new Zt(n),r=await new jt.NoteToRDFConverter(e).convertVault(),i=new jt.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}o(x2,"buildTripleStore");function C2(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}:`),C2(n.steps[t],e+" ")}}o(C2,"printGrounding");function I2(n,e){let t;try{t=(0,ds.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,hs.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;I2(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,ds.readFileSync)(i,"utf-8"),a=hH.parse(s);a.exists&&e.push({filePath:i,fm:gH(a.content)})}catch{}}}o(I2,"collectParsedFiles");function gH(n){let e={},t=n.split(`
|
|
751
751
|
`),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let c=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(c),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let c=a[2].trim();if((c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),c==="true"?c=!0:c==="false"&&(c=!1),c===""){e[r]=[],i=e[r];continue}e[r]=c}}return e}o(gH,"parseYamlFrontmatter");function Vl(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(Vl,"hasClass");function Og(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(Og,"normalizeWikilink");function rD(n){return(0,hs.basename)(n,".md")}o(rD,"extractLabelFromFilename");var Ul=require("fs"),zf=require("path"),Ot=X(Bt());var yH={turtle:"turtle",ntriples:"n-triples",jsonld:"json-ld"},_H=new Ot.IRI(`${Ot.Namespace.RDF.iri.value}type`),nD=[Ot.Namespace.RDF,Ot.Namespace.RDFS,Ot.Namespace.OWL,Ot.Namespace.XSD,Ot.Namespace.EXO,Ot.Namespace.EMS,Ot.Namespace.EXOCMD,Ot.Namespace.IMS,Ot.Namespace.ZTLK,Ot.Namespace.PTMS,Ot.Namespace.LIT,Ot.Namespace.INBOX];function vH(n){let e=n.trim();if(e.startsWith("http://")||e.startsWith("https://"))return new Ot.IRI(e);let t=e.match(/^([a-zA-Z][a-zA-Z0-9]*)__(.+)$/);if(t){let[,i,s]=t,a=nD.find(c=>c.prefix===i);if(a)return a.term(s)}let r=e.match(/^([a-zA-Z][a-zA-Z0-9]*):(.+)$/);if(r){let[,i,s]=r,a=nD.find(c=>c.prefix===i);if(a)return a.term(s)}throw new ze(`Unable to resolve class filter "${n}" to an IRI.`,'Use shorthand like "ems__Task", prefixed like "ems:Task", or a full IRI.')}o(vH,"resolveClassIri");function SH(n,e){let t=new Set;for(let r of n)r.predicate.equals(_H)&&r.object instanceof Ot.IRI&&r.object.equals(e)&&t.add(r.subject.toString());return t.size===0?[]:n.filter(r=>t.has(r.subject.toString()))}o(SH,"filterByClass");function iD(){return new De("convert").description("Dump vault graph as RDF (Turtle/N-Triples/JSON-LD)").option("--format <type>","Serialization format: turtle|ntriples|jsonld","turtle").option("--out <path>","Write serialized output to file (default: stdout)").option("--filter <class>","Keep only instances of the given class (e.g. ems__Task, ems:Task, or full IRI)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format for errors: text|json (for MCP tools)","text").action(async n=>{let e=n.output||"text";F.setFormat(e);try{let t=yH[n.format];if(!t)throw new ze(`Unknown format: "${n.format}". Expected one of turtle|ntriples|jsonld.`,"exocortex convert --format turtle --out vault.ttl");let r=(0,zf.resolve)(n.vault);if(!(0,Ul.existsSync)(r))throw new xe(r);e==="text"&&!n.out||e==="text"&&console.error(`\u{1F4E6} Loading vault: ${r}...`);let i=new Zt(r),a=await new Ot.NoteToRDFConverter(i).convertVault();if(n.filter){let f=vH(n.filter);a=SH(a,f)}let c=new Ot.InMemoryTripleStore;await c.addAll(a);let u=new Ot.RDFSerializer(c).serializeTriples(a,t,{pretty:t==="json-ld",indent:2});if(n.out){let f=(0,zf.resolve)(n.out);try{(0,Ul.mkdirSync)((0,zf.dirname)(f),{recursive:!0}),(0,Ul.writeFileSync)(f,u,"utf-8")}catch(d){throw new cf("convert",`failed to write output to ${f}: ${d.message}`,"Check destination directory exists and is writable.",{outPath:f})}e==="text"&&console.error(`\u2705 Wrote ${a.length} triple(s) to ${f} (${n.format}).`)}else process.stdout.write(u),u.endsWith(`
|
|
752
752
|
`)||process.stdout.write(`
|
|
753
|
-
`)}catch(t){F.handle(t)}})}o(iD,"convertCommand");function sD(n){n.addCommand(JR()),n.addCommand(rO()),n.addCommand(nO())}o(sD,"addQuerySubcommands");function aD(n){let e=new De;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.
|
|
753
|
+
`)}catch(t){F.handle(t)}})}o(iD,"convertCommand");function sD(n){n.addCommand(JR()),n.addCommand(rO()),n.addCommand(nO())}o(sD,"addQuerySubcommands");function aD(n){let e=new De;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.105.0");let t=e.command("exoql").description("ExoQL query execution and cache management");sD(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return sD(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(fP()),e.addCommand(pP()),e.addCommand(mP()),e.addCommand(yP()),e.addCommand(_P()),e.addCommand(EP()),e.addCommand(CP()),e.addCommand(LP()),e.addCommand(jP()),e.addCommand(qP()),e.addCommand(zP()),e.addCommand(HP()),e.addCommand(YP()),e.addCommand(tD()),e.addCommand(iD()),e}o(aD,"createProgram");aD().parse();0&&(module.exports={createProgram});
|
|
754
754
|
/*! Bundled license information:
|
|
755
755
|
|
|
756
756
|
reflect-metadata/Reflect.js:
|
package/package.json
CHANGED