@kitelev/exocortex-cli 15.83.0 → 15.84.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.84.0
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
@@ -86,7 +86,7 @@ ${Object.entries(t).map(([a,c])=>this.serializeValue(a,c)).join(`
|
|
|
86
86
|
${r}`}return`${e}: ${String(t)}`}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};Xh.FrontmatterService=Yh;Yh.FRONTMATTER_REGEX=/^---\n([\s\S]*?)\n---/});var da=v(Kh=>{"use strict";Object.defineProperty(Kh,"__esModule",{value:!0});Kh.LoggingService=void 0;var bu=class{static{o(this,"LoggingService")}static setVerbose(e){this.isVerbose=e}static setDevelopmentMode(e){this.isDevelopment=e}static checkIsDevelopment(){return this.isDevelopment!==void 0?this.isDevelopment:typeof process<"u"?(this.isDevelopment=!1,this.isDevelopment):(this.isDevelopment=!1,this.isDevelopment)}static debug(e,t){this.isVerbose&&console.debug(`[Exocortex] ${e}`,t??"")}static info(e,t){console.log(`[Exocortex] ${e}`,t??"")}static warn(e,t){console.warn(`[Exocortex] ${e}`,t??"")}static error(e,t,r){let i=this.checkIsDevelopment(),s=r?` [${r}]`:"";if(i){let a=t?.stack?`
|
|
87
87
|
Stack trace:
|
|
88
88
|
${t.stack}`:"";console.error(`[Exocortex ERROR]${s} ${e}${a}`,t??"")}else{let a=t?.message?`
|
|
89
|
-
Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${a}`)}}};Kh.LoggingService=bu;bu.isVerbose=!1;bu.isDevelopment=void 0});var KT=v(Jn=>{"use strict";var _M=Jn&&Jn.__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},vM=Jn&&Jn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Jn,"__esModule",{value:!0});Jn.GroundingExecutor=Jn.ServiceRegistry=void 0;var bM=ve(),lo=Yo(),SM=qi(),wM=da(),Jh=class{static{o(this,"ServiceRegistry")}constructor(){this.services=new Map}register(e,t){this.services.set(e,t)}get(e){return this.services.get(e)}has(e){return this.services.has(e)}getRegisteredIds(){return Array.from(this.services.keys())}};Jn.ServiceRegistry=Jh;var XT=20,B1=class{static{o(this,"GroundingExecutor")}constructor(e,t,r){this.frontmatterService=new SM.FrontmatterService,this.fileReader=e,this.fileWriter=t,this.serviceRegistry=r}async execute(e,t,r,i){try{switch(e.type){case lo.GroundingType.PROPERTY_SET:return await this.executePropertySet(e,t,r);case lo.GroundingType.PROPERTY_DELETE:return await this.executePropertyDelete(e,r);case lo.GroundingType.COMPOSITE:return await this.executeComposite(e,t,r,i,0);case lo.GroundingType.SERVICE_CALL:return await this.executeServiceCall(e,t,i);case lo.GroundingType.CREATE_INSTANCE:return{success:!1,error:"create_instance grounding not yet implemented. See RFC-016 Issue #2643."};case lo.GroundingType.SPARQL_UPDATE:return{success:!1,error:"sparql_update grounding not yet implemented. Use property_set/property_delete instead."};default:return{success:!1,error:`Unknown grounding type: ${e.type}`}}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async executePropertySet(e,t,r){if(!e.targetProperty)return{success:!1,error:"property_set requires targetProperty"};if(e.targetValue===void 0)return{success:!1,error:"property_set requires targetValue"};let i=this.substituteVariables(e.targetValue,t),s=await this.fileReader.readFile(r),a=this.frontmatterService.updateProperty(s,e.targetProperty,i);return await this.fileWriter.updateFile(r,a),{success:!0}}async executePropertyDelete(e,t){if(!e.targetProperty)return{success:!1,error:"property_delete requires targetProperty"};let r=await this.fileReader.readFile(t),i=this.frontmatterService.removeProperty(r,e.targetProperty);return await this.fileWriter.updateFile(t,i),{success:!0}}async executeComposite(e,t,r,i,s){if(s>=XT)return{success:!1,error:`Composite grounding exceeded maximum depth of ${XT}`};let a=e.steps??[];if(a.length===0)return{success:!0};let c;try{c=await this.fileReader.readFile(r)}catch{}let l=[];try{for(let u=0;u<a.length;u++){let f=a[u],d=await this.executeStep(f,t,r,i,s+1);if(!d.success)return await this.rollback(c,r,l),{success:!1,error:`Composite step ${u} failed: ${d.error}`};l.push(u)}return{success:!0}}catch(u){return await this.rollback(c,r,l),{success:!1,error:`Composite execution failed: ${u instanceof Error?u.message:String(u)}`}}}async executeServiceCall(e,t,r){let i=e.targetProperty;if(!i)return{success:!1,error:"service_call requires targetProperty as serviceId"};let s=this.serviceRegistry.get(i);return s?(await s.execute(t,r),{success:!0}):{success:!1,error:`Service not found: "${i}". Registered services: ${this.serviceRegistry.getRegisteredIds().join(", ")||"none"}`}}async executeStep(e,t,r,i,s){return e.type===lo.GroundingType.COMPOSITE?this.executeComposite(e,t,r,i,s):this.execute(e,t,r,i)}async rollback(e,t,r){if(e!==void 0)try{await this.fileWriter.updateFile(t,e)}catch(i){wM.LoggingService.error(`[GroundingExecutor] Rollback failed for ${t}`,i instanceof Error?i:new Error(String(i)))}}substituteVariables(e,t){let r=new Date().toISOString(),i=r.slice(0,10);return e.replace(/\$target/g,t).replace(/\$now/g,r).replace(/\$today/g,i)}};Jn.GroundingExecutor=B1;Jn.GroundingExecutor=B1=_M([(0,bM.injectable)(),vM("design:paramtypes",[Object,Object,Jh])],B1)});var tn=v(Zh=>{"use strict";Object.defineProperty(Zh,"__esModule",{value:!0});Zh.DateFormatter=void 0;var q1=class n{static{o(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return`${t}-${r}-${i}T${s}:${a}:${c}`}static toDateWikilink(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${r}-${i}]]"`}static getTodayWikilink(){return n.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${i}`}static parseWikilink(e){let r=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return r?r[1]:null}static addDays(e,t){let r=new Date(e);return r.setDate(r.getDate()+t),r}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),n.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[r,i,s]=t,a=new Date(r,i-1,s,0,0,0,0);if(isNaN(a.getTime()))throw new Error(`Invalid date values: ${e}`);return n.toLocalTimestamp(a)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return n.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};Zh.DateFormatter=q1});var Su=v(Rs=>{"use strict";var EM=Rs&&Rs.__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},TM=Rs&&Rs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Rs,"__esModule",{value:!0});Rs.WorkflowEngine=void 0;var AM=ve(),W1=class{static{o(this,"WorkflowEngine")}constructor(e){this.definition=e}getAvailableTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&!t.isRollback)}getRollbackTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&t.isRollback)}getAllTransitions(e){return this.definition.transitions.filter(t=>t.from===e)}canTransition(e,t){return this.definition.transitions.some(r=>r.from===e&&r.to===t)}getPreviousStatus(e){return this.definition.transitions.find(r=>r.from===e&&r.isRollback)?.to??null}getNextStates(e){return this.getAvailableTransitions(e).map(t=>t.to)}isTerminalState(e){return this.definition.terminalStates.includes(e)}isInitialState(e){return this.definition.initialState===e}getTimestampsForStatus(e){return this.definition.states.find(r=>r.status===e)?.timestampOnEnter??[]}getTransition(e,t){return this.definition.transitions.find(r=>r.from===e&&r.to===t)}getOrderedStates(){return this.definition.states.map(e=>e.status)}getDefinition(){return this.definition}validate(){let e=[],t=new Set(this.definition.states.map(i=>i.status));this.definition.states.length===0&&e.push("Workflow must have at least one state"),t.has(this.definition.initialState)||e.push(`Initial state "${this.definition.initialState}" is not in the states list`);for(let i of this.definition.terminalStates)t.has(i)||e.push(`Terminal state "${i}" is not in the states list`);for(let i of this.definition.transitions)t.has(i.from)||e.push(`Transition "${i.label}" references unknown source state "${i.from}"`),t.has(i.to)||e.push(`Transition "${i.label}" references unknown target state "${i.to}"`);for(let i of this.definition.states){if(this.definition.terminalStates.includes(i.status))continue;this.definition.transitions.filter(a=>a.from===i.status&&!a.isRollback).length===0&&e.push(`State "${i.status}" has no outgoing forward transitions (dead end)`)}let r=new Set;for(let i of this.definition.transitions){let s=`${i.from}\u2192${i.to}`;r.has(s)&&e.push(`Duplicate transition: ${s}`),r.add(s)}return{valid:e.length===0,errors:e}}};Rs.WorkflowEngine=W1;Rs.WorkflowEngine=W1=EM([(0,AM.injectable)(),TM("design:paramtypes",[Object])],W1)});var JT=v(Wi=>{"use strict";Object.defineProperty(Wi,"__esModule",{value:!0});Wi.EFFORT_WORKFLOW_PROPERTY=Wi.WorkflowTransitionProperty=Wi.WorkflowStateProperty=Wi.WorkflowProperty=void 0;Wi.WorkflowProperty={TARGET_CLASS:"ems__Workflow_targetClass",INITIAL_STATE:"ems__Workflow_initialState",TERMINAL_STATES:"ems__Workflow_terminalStates",IS_DEFAULT:"ems__Workflow_isDefault"};Wi.WorkflowStateProperty={WORKFLOW:"ems__WorkflowState_workflow",STATUS:"ems__WorkflowState_status",ORDER:"ems__WorkflowState_order",OPTIONAL:"ems__WorkflowState_optional",TIMESTAMP_ON_ENTER:"ems__WorkflowState_timestampOnEnter",BADGE_COLOR:"ems__WorkflowState_badgeColor"};Wi.WorkflowTransitionProperty={WORKFLOW:"ems__WorkflowTransition_workflow",FROM:"ems__WorkflowTransition_from",TO:"ems__WorkflowTransition_to",LABEL:"ems__WorkflowTransition_label",ICON:"ems__WorkflowTransition_icon",IS_ROLLBACK:"ems__WorkflowTransition_isRollback"};Wi.EFFORT_WORKFLOW_PROPERTY="ems__Effort_workflow"});var Gi=v(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});ep.MetadataHelpers=void 0;var G1=class{static{o(this,"MetadataHelpers")}static findAllReferencingProperties(e,t){let r=[];for(let[i,s]of Object.entries(e))this.containsReference(s,t)&&r.push(i);return r}static findReferencingProperty(e,t){for(let[r,i]of Object.entries(e))if(this.containsReference(i,t))return r}static containsReference(e,t){if(!e)return!1;let r=t.replace(/\.md$/,"");if(typeof e=="string"){let i=/\[\[([^\[\]]+)\]\]/g,s;for(;(s=i.exec(e))!==null;){let c=s[1].split("|")[0].trim();if(c===r||c.endsWith(`/${r}`))return!0}return!1}return Array.isArray(e)?e.some(i=>this.containsReference(i,t)):!1}static isAssetArchived(e){let t=e?.exo__Asset_isArchived;if(t!=null){if(t===!0||t===1)return!0;if(typeof t=="string"){let i=t.toLowerCase().trim();if(i==="true"||i==="yes"||i==="1")return!0}if(typeof t=="boolean")return t}let r=e?.archived;if(r==null)return!1;if(typeof r=="boolean")return r;if(typeof r=="number")return r!==0;if(typeof r=="string"){let i=r.toLowerCase().trim();return i==="true"||i==="yes"||i==="1"}return!1}static getPropertyValue(e,t){return t==="Name"||t==="title"?e.title:t==="created"?e.created:t==="modified"?e.modified:t==="path"?e.path:e.metadata?.[t]}static ensureQuoted(e){return!e||e==='""'?'""':e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`}static buildFileContent(e,t){let r=Object.entries(e).map(([s,a])=>{if(Array.isArray(a)){let c=a.map(l=>` - ${l}`).join(`
|
|
89
|
+
Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${a}`)}}};Kh.LoggingService=bu;bu.isVerbose=!1;bu.isDevelopment=void 0});var KT=v(Jn=>{"use strict";var _M=Jn&&Jn.__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},vM=Jn&&Jn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Jn,"__esModule",{value:!0});Jn.GroundingExecutor=Jn.ServiceRegistry=void 0;var bM=ve(),lo=Yo(),SM=qi(),wM=da(),Jh=class{static{o(this,"ServiceRegistry")}constructor(){this.services=new Map}register(e,t){this.services.set(e,t)}get(e){return this.services.get(e)}has(e){return this.services.has(e)}getRegisteredIds(){return Array.from(this.services.keys())}};Jn.ServiceRegistry=Jh;var XT=20,B1=class{static{o(this,"GroundingExecutor")}constructor(e,t,r){this.frontmatterService=new SM.FrontmatterService,this.fileReader=e,this.fileWriter=t,this.serviceRegistry=r}async execute(e,t,r,i){try{switch(e.type){case lo.GroundingType.PROPERTY_SET:return await this.executePropertySet(e,t,r);case lo.GroundingType.PROPERTY_DELETE:return await this.executePropertyDelete(e,r);case lo.GroundingType.COMPOSITE:return await this.executeComposite(e,t,r,i,0);case lo.GroundingType.SERVICE_CALL:return await this.executeServiceCall(e,t,i);case lo.GroundingType.CREATE_INSTANCE:return await this.executeCreateInstance(e,i);case lo.GroundingType.SPARQL_UPDATE:return{success:!1,error:"sparql_update grounding not yet implemented. Use property_set/property_delete instead."};default:return{success:!1,error:`Unknown grounding type: ${e.type}`}}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async executePropertySet(e,t,r){if(!e.targetProperty)return{success:!1,error:"property_set requires targetProperty"};if(e.targetValue===void 0)return{success:!1,error:"property_set requires targetValue"};let i=this.substituteVariables(e.targetValue,t),s=await this.fileReader.readFile(r),a=this.frontmatterService.updateProperty(s,e.targetProperty,i);return await this.fileWriter.updateFile(r,a),{success:!0}}async executePropertyDelete(e,t){if(!e.targetProperty)return{success:!1,error:"property_delete requires targetProperty"};let r=await this.fileReader.readFile(t),i=this.frontmatterService.removeProperty(r,e.targetProperty);return await this.fileWriter.updateFile(t,i),{success:!0}}async executeComposite(e,t,r,i,s){if(s>=XT)return{success:!1,error:`Composite grounding exceeded maximum depth of ${XT}`};let a=e.steps??[];if(a.length===0)return{success:!0};let c;try{c=await this.fileReader.readFile(r)}catch{}let l=[];try{for(let u=0;u<a.length;u++){let f=a[u],d=await this.executeStep(f,t,r,i,s+1);if(!d.success)return await this.rollback(c,r,l),{success:!1,error:`Composite step ${u} failed: ${d.error}`};l.push(u)}return{success:!0}}catch(u){return await this.rollback(c,r,l),{success:!1,error:`Composite execution failed: ${u instanceof Error?u.message:String(u)}`}}}async executeServiceCall(e,t,r){let i=e.targetProperty;if(!i)return{success:!1,error:"service_call requires targetProperty as serviceId"};let s=this.serviceRegistry.get(i);return s?(await s.execute(t,r),{success:!0}):{success:!1,error:`Service not found: "${i}". Registered services: ${this.serviceRegistry.getRegisteredIds().join(", ")||"none"}`}}async executeCreateInstance(e,t){if(!e.targetFolder)return{success:!1,error:"create_instance requires targetFolder"};let r=globalThis.crypto.randomUUID(),i=t?.label??"Untitled",s={exo__Asset_uid:r,exo__Asset_label:i};e.targetClass&&(s.exo__Instance_class=`"[[${e.targetClass}]]"`),e.targetPrototype&&(s.exo__Asset_prototype=`"[[${e.targetPrototype}]]"`);let a=this.frontmatterService.createFrontmatter("",s),c=`${e.targetFolder}/${r}.md`;return await this.fileWriter.createFile(c,a),{success:!0}}async executeStep(e,t,r,i,s){return e.type===lo.GroundingType.COMPOSITE?this.executeComposite(e,t,r,i,s):this.execute(e,t,r,i)}async rollback(e,t,r){if(e!==void 0)try{await this.fileWriter.updateFile(t,e)}catch(i){wM.LoggingService.error(`[GroundingExecutor] Rollback failed for ${t}`,i instanceof Error?i:new Error(String(i)))}}substituteVariables(e,t){let r=new Date().toISOString(),i=r.slice(0,10);return e.replace(/\$target/g,t).replace(/\$now/g,r).replace(/\$today/g,i)}};Jn.GroundingExecutor=B1;Jn.GroundingExecutor=B1=_M([(0,bM.injectable)(),vM("design:paramtypes",[Object,Object,Jh])],B1)});var tn=v(Zh=>{"use strict";Object.defineProperty(Zh,"__esModule",{value:!0});Zh.DateFormatter=void 0;var q1=class n{static{o(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return`${t}-${r}-${i}T${s}:${a}:${c}`}static toDateWikilink(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${r}-${i}]]"`}static getTodayWikilink(){return n.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${i}`}static parseWikilink(e){let r=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return r?r[1]:null}static addDays(e,t){let r=new Date(e);return r.setDate(r.getDate()+t),r}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),n.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[r,i,s]=t,a=new Date(r,i-1,s,0,0,0,0);if(isNaN(a.getTime()))throw new Error(`Invalid date values: ${e}`);return n.toLocalTimestamp(a)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return n.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};Zh.DateFormatter=q1});var Su=v(Rs=>{"use strict";var EM=Rs&&Rs.__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},TM=Rs&&Rs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Rs,"__esModule",{value:!0});Rs.WorkflowEngine=void 0;var AM=ve(),W1=class{static{o(this,"WorkflowEngine")}constructor(e){this.definition=e}getAvailableTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&!t.isRollback)}getRollbackTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&t.isRollback)}getAllTransitions(e){return this.definition.transitions.filter(t=>t.from===e)}canTransition(e,t){return this.definition.transitions.some(r=>r.from===e&&r.to===t)}getPreviousStatus(e){return this.definition.transitions.find(r=>r.from===e&&r.isRollback)?.to??null}getNextStates(e){return this.getAvailableTransitions(e).map(t=>t.to)}isTerminalState(e){return this.definition.terminalStates.includes(e)}isInitialState(e){return this.definition.initialState===e}getTimestampsForStatus(e){return this.definition.states.find(r=>r.status===e)?.timestampOnEnter??[]}getTransition(e,t){return this.definition.transitions.find(r=>r.from===e&&r.to===t)}getOrderedStates(){return this.definition.states.map(e=>e.status)}getDefinition(){return this.definition}validate(){let e=[],t=new Set(this.definition.states.map(i=>i.status));this.definition.states.length===0&&e.push("Workflow must have at least one state"),t.has(this.definition.initialState)||e.push(`Initial state "${this.definition.initialState}" is not in the states list`);for(let i of this.definition.terminalStates)t.has(i)||e.push(`Terminal state "${i}" is not in the states list`);for(let i of this.definition.transitions)t.has(i.from)||e.push(`Transition "${i.label}" references unknown source state "${i.from}"`),t.has(i.to)||e.push(`Transition "${i.label}" references unknown target state "${i.to}"`);for(let i of this.definition.states){if(this.definition.terminalStates.includes(i.status))continue;this.definition.transitions.filter(a=>a.from===i.status&&!a.isRollback).length===0&&e.push(`State "${i.status}" has no outgoing forward transitions (dead end)`)}let r=new Set;for(let i of this.definition.transitions){let s=`${i.from}\u2192${i.to}`;r.has(s)&&e.push(`Duplicate transition: ${s}`),r.add(s)}return{valid:e.length===0,errors:e}}};Rs.WorkflowEngine=W1;Rs.WorkflowEngine=W1=EM([(0,AM.injectable)(),TM("design:paramtypes",[Object])],W1)});var JT=v(Wi=>{"use strict";Object.defineProperty(Wi,"__esModule",{value:!0});Wi.EFFORT_WORKFLOW_PROPERTY=Wi.WorkflowTransitionProperty=Wi.WorkflowStateProperty=Wi.WorkflowProperty=void 0;Wi.WorkflowProperty={TARGET_CLASS:"ems__Workflow_targetClass",INITIAL_STATE:"ems__Workflow_initialState",TERMINAL_STATES:"ems__Workflow_terminalStates",IS_DEFAULT:"ems__Workflow_isDefault"};Wi.WorkflowStateProperty={WORKFLOW:"ems__WorkflowState_workflow",STATUS:"ems__WorkflowState_status",ORDER:"ems__WorkflowState_order",OPTIONAL:"ems__WorkflowState_optional",TIMESTAMP_ON_ENTER:"ems__WorkflowState_timestampOnEnter",BADGE_COLOR:"ems__WorkflowState_badgeColor"};Wi.WorkflowTransitionProperty={WORKFLOW:"ems__WorkflowTransition_workflow",FROM:"ems__WorkflowTransition_from",TO:"ems__WorkflowTransition_to",LABEL:"ems__WorkflowTransition_label",ICON:"ems__WorkflowTransition_icon",IS_ROLLBACK:"ems__WorkflowTransition_isRollback"};Wi.EFFORT_WORKFLOW_PROPERTY="ems__Effort_workflow"});var Gi=v(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});ep.MetadataHelpers=void 0;var G1=class{static{o(this,"MetadataHelpers")}static findAllReferencingProperties(e,t){let r=[];for(let[i,s]of Object.entries(e))this.containsReference(s,t)&&r.push(i);return r}static findReferencingProperty(e,t){for(let[r,i]of Object.entries(e))if(this.containsReference(i,t))return r}static containsReference(e,t){if(!e)return!1;let r=t.replace(/\.md$/,"");if(typeof e=="string"){let i=/\[\[([^\[\]]+)\]\]/g,s;for(;(s=i.exec(e))!==null;){let c=s[1].split("|")[0].trim();if(c===r||c.endsWith(`/${r}`))return!0}return!1}return Array.isArray(e)?e.some(i=>this.containsReference(i,t)):!1}static isAssetArchived(e){let t=e?.exo__Asset_isArchived;if(t!=null){if(t===!0||t===1)return!0;if(typeof t=="string"){let i=t.toLowerCase().trim();if(i==="true"||i==="yes"||i==="1")return!0}if(typeof t=="boolean")return t}let r=e?.archived;if(r==null)return!1;if(typeof r=="boolean")return r;if(typeof r=="number")return r!==0;if(typeof r=="string"){let i=r.toLowerCase().trim();return i==="true"||i==="yes"||i==="1"}return!1}static getPropertyValue(e,t){return t==="Name"||t==="title"?e.title:t==="created"?e.created:t==="modified"?e.modified:t==="path"?e.path:e.metadata?.[t]}static ensureQuoted(e){return!e||e==='""'?'""':e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`}static buildFileContent(e,t){let r=Object.entries(e).map(([s,a])=>{if(Array.isArray(a)){let c=a.map(l=>` - ${l}`).join(`
|
|
90
90
|
`);return`${s}:
|
|
91
91
|
${c}`}return`${s}: ${a}`}).join(`
|
|
92
92
|
`),i=t?`
|
|
@@ -722,7 +722,7 @@ ${Ir.dump(i,{lineWidth:-1})}---
|
|
|
722
722
|
\u{1F50D} Dry-run: command "${l.name}" on "${t.target}"
|
|
723
723
|
`),console.log(" Precondition: passed \u2705"),console.log(" Grounding (would execute):"),mS(l.grounding," ");return}let h=new kt.ServiceRegistry;kO(h);let p=new Dt(i),b=await new kt.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){M.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";M.setFormat(t);try{let r=(0,cs.resolve)(e.vault);if(!(0,os.existsSync)(r))throw new Oe(r);let i=LH(r);if(t==="json"){let s=Z.success({totalCommands:hS(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=hS(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:
|
|
724
724
|
`);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){M.handle(r)}}),n}o(MO,"dynamicCommandCommand");function hS(n){let e=[],t=[];gS(n,t);for(let{filePath:r,fm:i}of t){if(!Dl(i,"exocmd__Command"))continue;let s=i.exo__Asset_uid??"",a=i.exo__Asset_label??jO(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=vg(String(f)),p=t.find(_=>_.fm.exo__Asset_uid===h&&Dl(_.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(hS,"scanCommands");async function NH(n,e){let{tripleStore:t}=await pS(n),r=new kt.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(NH,"listCommandsForTarget");function LH(n){let e=[],t=[];gS(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(!Dl(s,"exocmd__Command"))continue;let a=s.exo__Asset_uid??"",c=s.exo__Asset_label??jO(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=vg(String(u)),p=r.get(h);if(!p)l.push(`Grounding reference "${h}" not found in vault`);else if(!Dl(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(kt.GroundingType).includes(b)||l.push(`Grounding "${h}" has invalid type "${b}"`),(b===kt.GroundingType.PROPERTY_SET||b===kt.GroundingType.PROPERTY_DELETE)&&!_.exocmd__Grounding_targetProperty&&l.push(`Grounding "${h}" (${b}) missing targetProperty`),b===kt.GroundingType.PROPERTY_SET&&!_.exocmd__Grounding_targetValue&&l.push(`Grounding "${h}" (property_set) missing targetValue`),b===kt.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=vg(String(f)),p=r.get(h);if(!p)l.push(`Precondition reference "${h}" not found in vault`);else if(!Dl(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=>Dl(h.fm,"exocmd__CommandBinding")?vg(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(LH,"validateCommands");async function pS(n){let e=new Br(n),r=await new kt.NoteToRDFConverter(e).convertVault(),i=new kt.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}o(pS,"buildTripleStore");function mS(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}:`),mS(n.steps[t],e+" ")}}o(mS,"printGrounding");function gS(n,e){let t;try{t=(0,os.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,cs.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;gS(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,os.readFileSync)(i,"utf-8"),a=FH.parse(s);a.exists&&e.push({filePath:i,fm:kH(a.content)})}catch{}}}o(gS,"collectParsedFiles");function kH(n){let e={},t=n.split(`
|
|
725
|
-
`),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(kH,"parseYamlFrontmatter");function Dl(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(Dl,"hasClass");function vg(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(vg,"normalizeWikilink");function jO(n){return(0,cs.basename)(n,".md")}o(jO,"extractLabelFromFilename");function $O(n){n.addCommand($R()),n.addCommand(qR()),n.addCommand(WR())}o($O,"addQuerySubcommands");function VO(n){let e=new Ge;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.
|
|
725
|
+
`),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(kH,"parseYamlFrontmatter");function Dl(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(Dl,"hasClass");function vg(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(vg,"normalizeWikilink");function jO(n){return(0,cs.basename)(n,".md")}o(jO,"extractLabelFromFilename");function $O(n){n.addCommand($R()),n.addCommand(qR()),n.addCommand(WR())}o($O,"addQuerySubcommands");function VO(n){let e=new Ge;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.84.0");let t=e.command("exoql").description("ExoQL query execution and cache management");$O(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return $O(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(JP()),e.addCommand(tO()),e.addCommand(rO()),e.addCommand(iO()),e.addCommand(sO()),e.addCommand(uO()),e.addCommand(pO()),e.addCommand(yO()),e.addCommand(bO()),e.addCommand(AO()),e.addCommand(IO()),e.addCommand(RO()),e.addCommand(OO()),e.addCommand(MO()),e}o(VO,"createProgram");VO().parse();0&&(module.exports={createProgram});
|
|
726
726
|
/*! Bundled license information:
|
|
727
727
|
|
|
728
728
|
reflect-metadata/Reflect.js:
|