exocortex-cli 13.139.0 → 13.141.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.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // exocortex-cli v13.139.0
2
+ // exocortex-cli v13.141.0
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -277,7 +277,7 @@ globstar while`,e,p,t,g,w),this.matchOne(e.slice(p),t.slice(g),i))return this.de
277
277
  \u{1F4DD} Note: Actual command execution will be implemented in follow-up issues.`),console.log(" This PR establishes the infrastructure foundation."),process.exit(0)}catch(n){Pe.handle(n)}}getVaultRoot(){return this.context.pathResolver.getVaultRoot()}async executeStart(e){return this.statusExecutor.executeStart(e)}async executeComplete(e){return this.statusExecutor.executeComplete(e)}async executeTrash(e){return this.statusExecutor.executeTrash(e)}async executeArchive(e){return this.statusExecutor.executeArchive(e)}async executeMoveToBacklog(e){return this.statusExecutor.executeMoveToBacklog(e)}async executeMoveToAnalysis(e){return this.statusExecutor.executeMoveToAnalysis(e)}async executeMoveToToDo(e){return this.statusExecutor.executeMoveToToDo(e)}async executeCreateTask(e,t,i={}){return this.creationExecutor.executeCreateTask(e,t,i)}async executeCreateMeeting(e,t,i={}){return this.creationExecutor.executeCreateMeeting(e,t,i)}async executeCreateProject(e,t,i={}){return this.creationExecutor.executeCreateProject(e,t,i)}async executeCreateArea(e,t,i={}){return this.creationExecutor.executeCreateArea(e,t,i)}async executeRenameToUid(e){return this.propertyExecutor.executeRenameToUid(e)}async executeUpdateLabel(e,t){return this.propertyExecutor.executeUpdateLabel(e,t)}async executeSchedule(e,t){return this.propertyExecutor.executeSchedule(e,t)}async executeSetDeadline(e,t){return this.propertyExecutor.executeSetDeadline(e,t)}};function Ht(r,e,t,i,n){if(r==="json"){let s={command:e,filepath:t,action:i,...n&&{changes:n}},a=gt.success(s);console.log(JSON.stringify(a,null,2))}else console.log(`\u2705 ${i}`)}o(Ht,"outputResult");function ys(r,e,t,i){let n=new tt(`--${e} option is required for ${t} command`,i,{command:t,missingOption:e});Pe.handle(n)}o(ys,"handleMissingOption");function XS(){return new Pr("command").description("Execute plugin command on single asset").argument("<command-name>","Command to execute (rename-to-uid, start, complete, schedule, set-deadline, etc.)").argument("<filepath>","Path to asset file (relative to vault root or absolute)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--label <value>","Asset label (required for update-label and creation commands)").option("--prototype <uid>","Prototype UID for inheritance (creation commands)").option("--area <uid>","Area UID for effort linkage (creation commands)").option("--parent <uid>","Parent UID for effort linkage (creation commands)").option("--date <value>","Date in YYYY-MM-DD format (required for schedule and set-deadline commands)").option("--dry-run","Preview changes without modifying files").option("--format <type>","Output format: text|json (default: text)","text").action(async(r,e,t)=>{let i=t.format||"text";Pe.setFormat(i);try{let n=(0,JS.resolve)(t.vault),s=new Kl(n,t.dryRun);switch(r){case"rename-to-uid":await s.executeRenameToUid(e),Ht(i,r,e,"Renamed file to UID-based name");break;case"update-label":t.label||ys(i,"label","update-label",'exocortex command update-label <filepath> --label "<value>"'),await s.executeUpdateLabel(e,t.label),Ht(i,r,e,`Updated label to "${t.label}"`,{label:t.label});break;case"start":await s.executeStart(e),Ht(i,r,e,"Started task");break;case"complete":await s.executeComplete(e),Ht(i,r,e,"Completed task");break;case"trash":await s.executeTrash(e),Ht(i,r,e,"Moved task to trash");break;case"archive":await s.executeArchive(e),Ht(i,r,e,"Archived task");break;case"move-to-backlog":await s.executeMoveToBacklog(e),Ht(i,r,e,"Moved task to backlog");break;case"move-to-analysis":await s.executeMoveToAnalysis(e),Ht(i,r,e,"Moved task to analysis");break;case"move-to-todo":await s.executeMoveToToDo(e),Ht(i,r,e,"Moved task to todo");break;case"create-task":t.label||ys(i,"label","create-task",'exocortex command create-task <filepath> --label "<value>"'),await s.executeCreateTask(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),Ht(i,r,e,`Created task "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"create-meeting":t.label||ys(i,"label","create-meeting",'exocortex command create-meeting <filepath> --label "<value>"'),await s.executeCreateMeeting(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),Ht(i,r,e,`Created meeting "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"create-project":t.label||ys(i,"label","create-project",'exocortex command create-project <filepath> --label "<value>"'),await s.executeCreateProject(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),Ht(i,r,e,`Created project "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"create-area":t.label||ys(i,"label","create-area",'exocortex command create-area <filepath> --label "<value>"'),await s.executeCreateArea(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),Ht(i,r,e,`Created area "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"schedule":t.date||ys(i,"date","schedule",'exocortex command schedule <filepath> --date "YYYY-MM-DD"'),await s.executeSchedule(e,t.date),Ht(i,r,e,`Scheduled task for ${t.date}`,{date:t.date});break;case"set-deadline":t.date||ys(i,"date","set-deadline",'exocortex command set-deadline <filepath> --date "YYYY-MM-DD"'),await s.executeSetDeadline(e,t.date),Ht(i,r,e,`Set deadline to ${t.date}`,{date:t.date});break;default:await s.execute(r,e,t),Ht(i,r,e,`Executed ${r}`);break}}catch(n){Pe.handle(n)}})}o(XS,"commandCommand");var ew=require("path");var cn=Qe(require("fs")),y1=Qe(require("path")),ZS=require("events");var rR={watch:cn.default.watch.bind(cn.default),existsSync:cn.default.existsSync.bind(cn.default),statSync:cn.default.statSync.bind(cn.default),readFileSync:cn.default.readFileSync.bind(cn.default)},Yl=class extends ZS.EventEmitter{constructor(t,i={}){super();this.watcher=null;this.debounceTimers=new Map;this.isRunning=!1;this.vaultPath=y1.default.resolve(t),this.fsAdapter=i.fsAdapter??rR,this.options={pattern:i.pattern??"**/*.md",assetType:i.assetType??"",debounceMs:i.debounceMs??100,recursive:i.recursive??!0}}static{o(this,"FileSystemWatcher")}start(){this.isRunning||(this.watcher=this.fsAdapter.watch(this.vaultPath,{recursive:this.options.recursive},(t,i)=>{i&&this.handleFileEvent(t,i.toString())}),this.watcher.on("error",t=>{this.emit("error",t)}),this.isRunning=!0,this.emit("started"))}stop(){if(this.isRunning){for(let t of this.debounceTimers.values())clearTimeout(t);this.debounceTimers.clear(),this.watcher&&(this.watcher.close(),this.watcher=null),this.isRunning=!1,this.emit("stopped")}}isWatching(){return this.isRunning}handleFileEvent(t,i){let n=y1.default.join(this.vaultPath,i),s=i;if(!this.matchesPattern(s))return;let a=this.debounceTimers.get(n);a&&clearTimeout(a);let c=setTimeout(()=>{this.debounceTimers.delete(n),this.processFileEvent(n,s)},this.options.debounceMs);this.debounceTimers.set(n,c)}processFileEvent(t,i){let n=this.fsAdapter.existsSync(t),s;if(!n)s="delete";else{let u=this.fsAdapter.statSync(t);s=Date.now()-u.birthtimeMs<1e3?"create":"modify"}let a;if(n&&t.endsWith(".md")&&(a=this.extractAssetType(t)),this.options.assetType&&a!==this.options.assetType)return;let c={type:s,path:t,relativePath:i,timestamp:new Date().toISOString(),assetType:a};this.emit("change",c)}matchesPattern(t){return this.options.pattern?Lt(t,this.options.pattern):!0}extractAssetType(t){try{let n=this.fsAdapter.readFileSync(t,"utf-8").match(/^---\n([\s\S]*?)\n---/);if(!n)return;let a=n[1].match(/exo__Instance_class:\s*(?:\[?"?\[\[([^\]]+)\]\]"?\]?|"?\[\[([^\]]+)\]\]"?)/);return a?a[1]||a[2]:void 0}catch{return}}};var v1=Qe(require("fs"));function tw(){return new Pr("watch").description("Watch vault for file changes and emit NDJSON events").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--pattern <glob>","Glob pattern to filter files (e.g., '*.md', 'tasks/**')").option("--asset-type <type>","Filter by asset type (e.g., 'ems__Task', 'ems__Project')").option("--debounce <ms>","Debounce interval in milliseconds","100").action(async r=>{Pe.setFormat("json");try{let e=(0,ew.resolve)(r.vault);if(!v1.default.existsSync(e))throw new nn(e);if(!v1.default.statSync(e).isDirectory())throw new tt(`Vault path is not a directory: ${e}`,"Provide a path to a directory, not a file",{vaultPath:e});let t=parseInt(r.debounce?.toString()??"100",10);if(isNaN(t)||t<0)throw new tt("--debounce must be a non-negative integer","Use a positive integer value for debounce",{debounce:r.debounce});let i=new Yl(e,{pattern:r.pattern,assetType:r.assetType,debounceMs:t});i.on("change",s=>{console.log(JSON.stringify(s))}),i.on("error",s=>{let a=gt.error("INTERNAL_OPERATION_FAILED",s.message,5,{recovery:{message:"Check file permissions and vault access",suggestion:"Ensure the vault directory is accessible"}});console.log(JSON.stringify(a))});let n=o(()=>{i.stop(),process.exit(0)},"shutdown");process.on("SIGINT",n),process.on("SIGTERM",n),console.error(`Watching vault: ${e}`),r.pattern&&console.error(` Pattern filter: ${r.pattern}`),r.assetType&&console.error(` Asset type filter: ${r.assetType}`),console.error(` Debounce: ${t}ms`),console.error("Press Ctrl+C to stop"),i.start()}catch(e){Pe.handle(e)}})}o(tw,"watchCommand");var S1=require("path"),w1=Qe(aa());var Aa=Qe(bn());var di=Qe(aa()),_1=Qe(require("crypto"));var Ql=class{constructor(){this.backups=new Map;this.fileHashes=new Map}static{o(this,"TransactionManager")}async begin(e){if(!di.default.existsSync(e))throw new Error(`Cannot backup non-existent file: ${e}`);let t=await di.default.readFile(e,"utf-8"),i=_1.default.createHash("sha256").update(t).digest("hex");this.fileHashes.set(e,i);let n=`${e}.backup.${Date.now()}`;await di.default.writeFile(n,t,"utf-8"),this.backups.set(e,n)}async verify(e){let t=this.fileHashes.get(e);if(!t)return!0;if(!di.default.existsSync(e))return!1;let i=await di.default.readFile(e,"utf-8");return _1.default.createHash("sha256").update(i).digest("hex")===t}async commit(){for(let e of this.backups.values())di.default.existsSync(e)&&await di.default.remove(e);this.backups.clear(),this.fileHashes.clear()}async rollback(){for(let[e,t]of this.backups.entries())di.default.existsSync(t)&&(await di.default.copy(t,e,{overwrite:!0}),await di.default.remove(t));this.backups.clear(),this.fileHashes.clear()}getTrackedFiles(){return Array.from(this.backups.keys())}};var Go=class{static{o(this,"BatchExecutor")}constructor(e,t=!1){this.pathResolver=new Ea(e),this.fsAdapter=new ba(e),this.frontmatterService=new Aa.FrontmatterService,this.transactionManager=new Ql,this.dryRun=t}async executeBatch(e,t=!1){let i=Date.now(),n=[],s=0,a=0,c=!1;if(e.length===0)return{success:!0,total:0,succeeded:0,failed:0,results:[],durationMs:Date.now()-i,atomic:t};if(t&&!this.dryRun)try{await this.backupAllFiles(e)}catch(f){return{success:!1,total:e.length,succeeded:0,failed:e.length,results:e.map(l=>({success:!1,command:l.command,filepath:l.filepath,error:`Backup failed: ${f.message}`})),durationMs:Date.now()-i,atomic:t}}for(let f of e){let l=await this.executeSingleOperation(f);if(n.push(l),l.success)s++;else if(a++,t&&!this.dryRun){await this.transactionManager.rollback(),c=!0;let h=n.length;for(let p=h;p<e.length;p++)n.push({success:!1,command:e[p].command,filepath:e[p].filepath,error:"Not executed due to atomic rollback"}),a++;return{success:!1,total:e.length,succeeded:0,failed:e.length,results:n,durationMs:Date.now()-i,atomic:t,rolledBack:!0}}}return t&&!this.dryRun&&!c&&await this.transactionManager.commit(),{success:a===0,total:e.length,succeeded:s,failed:a,results:n,durationMs:Date.now()-i,atomic:t,...t&&{rolledBack:c}}}static parseInput(e){try{let t=JSON.parse(e);if(!Array.isArray(t))throw new tt("Batch input must be a JSON array of operations",`exo batch --input '[{"command":"start","filepath":"task.md"}]'`);for(let i of t){if(!i.command||typeof i.command!="string")throw new tt('Each operation must have a "command" string property','{"command":"start","filepath":"task.md"}');if(!i.filepath||typeof i.filepath!="string")throw new tt('Each operation must have a "filepath" string property','{"command":"start","filepath":"task.md"}')}return t}catch(t){throw t instanceof tt?t:new tt(`Failed to parse batch input: ${t.message}`,`exo batch --input '[{"command":"start","filepath":"task.md"}]'`)}}async backupAllFiles(e){let t=new Set;for(let i of e){let n=this.pathResolver.resolve(i.filepath);t.add(n)}for(let i of t)await this.transactionManager.begin(i)}async executeSingleOperation(e){try{let t=this.pathResolver.resolve(e.filepath);this.pathResolver.validate(t);let i=t.replace(this.pathResolver.getVaultRoot()+"/",""),n=await this.fsAdapter.readFile(i);if(this.dryRun)return{success:!0,command:e.command,filepath:e.filepath,action:`Would execute ${e.command} (dry-run)`};switch(e.command){case"start":return await this.executeStart(i,e);case"complete":return await this.executeComplete(i,e);case"trash":return await this.executeTrash(i,e);case"archive":return await this.executeArchive(i,e);case"move-to-backlog":return await this.executeStatusUpdate(i,e,"ems__EffortStatusBacklog","Moved to backlog");case"move-to-analysis":return await this.executeStatusUpdate(i,e,"ems__EffortStatusAnalysis","Moved to analysis");case"move-to-todo":return await this.executeStatusUpdate(i,e,"ems__EffortStatusToDo","Moved to todo");case"update-label":return await this.executeUpdateLabel(i,e);case"schedule":return await this.executeSchedule(i,e);case"set-deadline":return await this.executeSetDeadline(i,e);default:return{success:!1,command:e.command,filepath:e.filepath,error:`Unknown command: ${e.command}`}}}catch(t){return{success:!1,command:e.command,filepath:e.filepath,error:t.message}}}getCurrentTimestamp(){return Aa.DateFormatter.toLocalTimestamp(new Date)}async executeStart(e,t){let i=await this.fsAdapter.readFile(e),n=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(i,"ems__Effort_status",'"[[ems__EffortStatusDoing]]"');return s=this.frontmatterService.updateProperty(s,"ems__Effort_startTimestamp",n),await this.fsAdapter.updateFile(e,s),{success:!0,command:t.command,filepath:t.filepath,action:"Started task",changes:{status:"Doing",startTimestamp:n}}}async executeComplete(e,t){let i=await this.fsAdapter.readFile(e),n=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(i,"ems__Effort_status",'"[[ems__EffortStatusDone]]"');return s=this.frontmatterService.updateProperty(s,"ems__Effort_endTimestamp",n),s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",n),await this.fsAdapter.updateFile(e,s),{success:!0,command:t.command,filepath:t.filepath,action:"Completed task",changes:{status:"Done",endTimestamp:n,resolutionTimestamp:n}}}async executeTrash(e,t){let i=await this.fsAdapter.readFile(e),n=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(i,"ems__Effort_status",'"[[ems__EffortStatusTrashed]]"');return s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",n),await this.fsAdapter.updateFile(e,s),{success:!0,command:t.command,filepath:t.filepath,action:"Trashed task",changes:{status:"Trashed",resolutionTimestamp:n}}}async executeArchive(e,t){let i=await this.fsAdapter.readFile(e),n=this.frontmatterService.updateProperty(i,"archived","true");return n=this.frontmatterService.removeProperty(n,"aliases"),await this.fsAdapter.updateFile(e,n),{success:!0,command:t.command,filepath:t.filepath,action:"Archived task",changes:{archived:!0,aliasesRemoved:!0}}}async executeStatusUpdate(e,t,i,n){let s=await this.fsAdapter.readFile(e),a=this.frontmatterService.updateProperty(s,"ems__Effort_status",`"[[${i}]]"`);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:n,changes:{status:i.replace("ems__EffortStatus","")}}}async executeUpdateLabel(e,t){let i=t.options?.label;if(!i||i.trim()==="")return{success:!1,command:t.command,filepath:t.filepath,error:'Missing required option: "label"'};let n=i.trim(),s=await this.fsAdapter.readFile(e),a=this.frontmatterService.updateProperty(s,"exo__Asset_label",`"${n}"`);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:`Updated label to "${n}"`,changes:{label:n}}}async executeSchedule(e,t){let i=t.options?.date;if(!i)return{success:!1,command:t.command,filepath:t.filepath,error:'Missing required option: "date"'};if(!/^\d{4}-\d{2}-\d{2}$/.test(i))return{success:!1,command:t.command,filepath:t.filepath,error:`Invalid date format: ${i}. Expected YYYY-MM-DD`};let n=await this.fsAdapter.readFile(e),s=Aa.DateFormatter.toTimestampAtStartOfDay(i),a=this.frontmatterService.updateProperty(n,"ems__Effort_scheduledTimestamp",s);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:`Scheduled for ${i}`,changes:{scheduledTimestamp:s}}}async executeSetDeadline(e,t){let i=t.options?.date;if(!i)return{success:!1,command:t.command,filepath:t.filepath,error:'Missing required option: "date"'};if(!/^\d{4}-\d{2}-\d{2}$/.test(i))return{success:!1,command:t.command,filepath:t.filepath,error:`Invalid date format: ${i}. Expected YYYY-MM-DD`};let n=await this.fsAdapter.readFile(e),s=Aa.DateFormatter.toTimestampAtStartOfDay(i),a=this.frontmatterService.updateProperty(n,"ems__Effort_deadlineTimestamp",s);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:`Set deadline to ${i}`,changes:{deadlineTimestamp:s}}}};function iR(r,e){if(r==="json"){let t=gt.success(e,{durationMs:e.durationMs,itemCount:e.total});console.log(JSON.stringify(t,null,2))}else{if(console.log(`
278
278
  \u{1F4E6} Batch Execution ${e.success?"Complete":"Failed"}`),console.log(` Total: ${e.total} operations`),console.log(` \u2705 Succeeded: ${e.succeeded}`),console.log(` \u274C Failed: ${e.failed}`),console.log(` \u23F1\uFE0F Duration: ${e.durationMs}ms`),e.atomic&&console.log(` \u{1F512} Atomic mode: ${e.rolledBack?"Rolled back":"Committed"}`),e.failed>0){console.log(`
279
279
  \u{1F4CB} Failed Operations:`);for(let t of e.results.filter(i=>!i.success))console.log(` \u274C ${t.command} ${t.filepath}: ${t.error}`)}if(e.succeeded>0&&r==="text"){console.log(`
280
- \u{1F4CB} Successful Operations:`);for(let t of e.results.filter(i=>i.success))console.log(` \u2705 ${t.command} ${t.filepath}: ${t.action}`)}}}o(iR,"outputResult");function rw(){return new Pr("batch").description("Execute multiple operations in a single CLI invocation").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>","JSON array of operations to execute").option("--file <path>","Path to JSON file containing operations").option("--atomic","All-or-nothing execution (rollback on any failure)").option("--dry-run","Preview changes without modifying files").option("--format <type>","Output format: text|json (default: text)","text").action(async r=>{let e=r.format||"text";Pe.setFormat(e);try{let t=(0,S1.resolve)(r.vault),i;if(r.input)i=r.input;else if(r.file){let c=(0,S1.resolve)(r.file);if(!w1.default.existsSync(c))throw new tt(`Batch file not found: ${c}`,"exocortex batch --file operations.json");i=await w1.default.readFile(c,"utf-8")}else throw new tt("Either --input or --file option is required",`exocortex batch --input '[{"command":"start","filepath":"task.md"}]' or exocortex batch --file operations.json`);let n=Go.parseInput(i);if(n.length===0)throw new tt("Batch input contains no operations",`exocortex batch --input '[{"command":"start","filepath":"task.md"}]'`);let a=await new Go(t,r.dryRun).executeBatch(n,r.atomic);iR(e,a),process.exit(a.success?0:5)}catch(t){Pe.handle(t)}})}o(rw,"batchCommand");var Jl=require("fs"),pi=require("path");function iw(){return new Pr("resolve").description("Resolve UUID to file path").argument("<uuid>","Full or partial UUID to resolve").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: uri|path|json (default: uri)","uri").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--partial","Match partial UUIDs (returns all matches)").action(async(r,e)=>{let t=e.output||"text";Pe.setFormat(t);try{let i=Date.now();if(!nR(r))throw new tt(`Invalid UUID format: ${r}`,"exocortex resolve <uuid> [--format uri|path|json] [--partial]",{uuid:r});let n=(0,pi.resolve)(e.vault);if(!(0,Jl.existsSync)(n))throw new nn(n);let s=sR(n,r,e.partial??!1),a=Date.now()-i;if(s.length===0){if(t==="json"){let c=gt.error("VALIDATION_FILE_NOT_FOUND",`UUID not found: ${r}`,3,{context:{uuid:r}});console.log(JSON.stringify(c,null,2))}else console.error(`UUID not found: ${r}`);process.exit(1)}e.partial||s.length>1?oR(s,n,e.format,t,r,a):aR(s[0],n,e.format,t,r,a)}catch(i){Pe.handle(i)}})}o(iw,"resolveCommand");function nR(r){if(r.length<4)return!1;let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,t=/^[0-9a-f-]+$/i;return e.test(r)||t.test(r)}o(nR,"isValidUuidFormat");function sR(r,e,t){let i=[],n=e.toLowerCase();function s(a){let c=(0,Jl.readdirSync)(a,{withFileTypes:!0});for(let u of c){let f=(0,pi.join)(a,u.name);if(u.isDirectory())!u.name.startsWith(".")&&u.name!=="node_modules"&&s(f);else if(u.isFile()&&u.name.endsWith(".md")){let l=u.name.toLowerCase();t?l.includes(n)&&i.push(f):(l.startsWith(n+".md")||l.startsWith(n+" ")||l.startsWith(n+"-"))&&i.push(f)}}}return o(s,"walk"),s(r),i}o(sR,"findFilesWithUuid");function nw(r){return`obsidian://vault/${encodeURI(r)}`}o(nw,"pathToObsidianUri");function sw(r){let e=r.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);return e?e[1]:(0,pi.basename)(r,".md")}o(sw,"extractUuidFromFilename");function aR(r,e,t,i,n,s){let a=(0,pi.relative)(e,r),c=nw(a),u=sw((0,pi.basename)(r));if(i==="json"){let f={uuid:u,path:a,absolutePath:r,uri:c},l=gt.success(f,{durationMs:s,searchUuid:n});console.log(JSON.stringify(l,null,2))}else switch(t){case"path":console.log(r);break;case"json":console.log(JSON.stringify({uuid:u,path:a,absolutePath:r,uri:c},null,2));break;case"uri":default:console.log(c);break}}o(aR,"outputSingleResult");function oR(r,e,t,i,n,s){let a=r.map(c=>{let u=(0,pi.relative)(e,c),f=nw(u);return{uuid:sw((0,pi.basename)(c)),path:u,absolutePath:c,uri:f}});if(i==="json"){let c=gt.success({matches:a,count:a.length},{durationMs:s,searchUuid:n,itemCount:a.length});console.log(JSON.stringify(c,null,2))}else switch(t){case"path":for(let c of a)console.log(c.absolutePath);break;case"json":console.log(JSON.stringify(a,null,2));break;case"uri":default:for(let c of a)console.log(c.uri);break}}o(oR,"outputMultipleResults");var vs=new Pr;vs.name("exocortex").description("CLI tool for Exocortex knowledge management system").version("13.139.0");vs.command("sparql").description("SPARQL query execution").addCommand(W_());vs.addCommand(XS());vs.addCommand(tw());vs.addCommand(rw());vs.addCommand(iw());vs.parse();
280
+ \u{1F4CB} Successful Operations:`);for(let t of e.results.filter(i=>i.success))console.log(` \u2705 ${t.command} ${t.filepath}: ${t.action}`)}}}o(iR,"outputResult");function rw(){return new Pr("batch").description("Execute multiple operations in a single CLI invocation").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>","JSON array of operations to execute").option("--file <path>","Path to JSON file containing operations").option("--atomic","All-or-nothing execution (rollback on any failure)").option("--dry-run","Preview changes without modifying files").option("--format <type>","Output format: text|json (default: text)","text").action(async r=>{let e=r.format||"text";Pe.setFormat(e);try{let t=(0,S1.resolve)(r.vault),i;if(r.input)i=r.input;else if(r.file){let c=(0,S1.resolve)(r.file);if(!w1.default.existsSync(c))throw new tt(`Batch file not found: ${c}`,"exocortex batch --file operations.json");i=await w1.default.readFile(c,"utf-8")}else throw new tt("Either --input or --file option is required",`exocortex batch --input '[{"command":"start","filepath":"task.md"}]' or exocortex batch --file operations.json`);let n=Go.parseInput(i);if(n.length===0)throw new tt("Batch input contains no operations",`exocortex batch --input '[{"command":"start","filepath":"task.md"}]'`);let a=await new Go(t,r.dryRun).executeBatch(n,r.atomic);iR(e,a),process.exit(a.success?0:5)}catch(t){Pe.handle(t)}})}o(rw,"batchCommand");var Jl=require("fs"),pi=require("path");function iw(){return new Pr("resolve").description("Resolve UUID to file path").argument("<uuid>","Full or partial UUID to resolve").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: uri|path|json (default: uri)","uri").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--partial","Match partial UUIDs (returns all matches)").action(async(r,e)=>{let t=e.output||"text";Pe.setFormat(t);try{let i=Date.now();if(!nR(r))throw new tt(`Invalid UUID format: ${r}`,"exocortex resolve <uuid> [--format uri|path|json] [--partial]",{uuid:r});let n=(0,pi.resolve)(e.vault);if(!(0,Jl.existsSync)(n))throw new nn(n);let s=sR(n,r,e.partial??!1),a=Date.now()-i;if(s.length===0){if(t==="json"){let c=gt.error("VALIDATION_FILE_NOT_FOUND",`UUID not found: ${r}`,3,{context:{uuid:r}});console.log(JSON.stringify(c,null,2))}else console.error(`UUID not found: ${r}`);process.exit(1)}e.partial||s.length>1?oR(s,n,e.format,t,r,a):aR(s[0],n,e.format,t,r,a)}catch(i){Pe.handle(i)}})}o(iw,"resolveCommand");function nR(r){if(r.length<4)return!1;let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,t=/^[0-9a-f-]+$/i;return e.test(r)||t.test(r)}o(nR,"isValidUuidFormat");function sR(r,e,t){let i=[],n=e.toLowerCase();function s(a){let c=(0,Jl.readdirSync)(a,{withFileTypes:!0});for(let u of c){let f=(0,pi.join)(a,u.name);if(u.isDirectory())!u.name.startsWith(".")&&u.name!=="node_modules"&&s(f);else if(u.isFile()&&u.name.endsWith(".md")){let l=u.name.toLowerCase();t?l.includes(n)&&i.push(f):(l.startsWith(n+".md")||l.startsWith(n+" ")||l.startsWith(n+"-"))&&i.push(f)}}}return o(s,"walk"),s(r),i}o(sR,"findFilesWithUuid");function nw(r){return`obsidian://vault/${encodeURI(r)}`}o(nw,"pathToObsidianUri");function sw(r){let e=r.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);return e?e[1]:(0,pi.basename)(r,".md")}o(sw,"extractUuidFromFilename");function aR(r,e,t,i,n,s){let a=(0,pi.relative)(e,r),c=nw(a),u=sw((0,pi.basename)(r));if(i==="json"){let f={uuid:u,path:a,absolutePath:r,uri:c},l=gt.success(f,{durationMs:s,searchUuid:n});console.log(JSON.stringify(l,null,2))}else switch(t){case"path":console.log(r);break;case"json":console.log(JSON.stringify({uuid:u,path:a,absolutePath:r,uri:c},null,2));break;case"uri":default:console.log(c);break}}o(aR,"outputSingleResult");function oR(r,e,t,i,n,s){let a=r.map(c=>{let u=(0,pi.relative)(e,c),f=nw(u);return{uuid:sw((0,pi.basename)(c)),path:u,absolutePath:c,uri:f}});if(i==="json"){let c=gt.success({matches:a,count:a.length},{durationMs:s,searchUuid:n,itemCount:a.length});console.log(JSON.stringify(c,null,2))}else switch(t){case"path":for(let c of a)console.log(c.absolutePath);break;case"json":console.log(JSON.stringify(a,null,2));break;case"uri":default:for(let c of a)console.log(c.uri);break}}o(oR,"outputMultipleResults");var vs=new Pr;vs.name("exocortex").description("CLI tool for Exocortex knowledge management system").version("13.141.0");vs.command("sparql").description("SPARQL query execution").addCommand(W_());vs.addCommand(XS());vs.addCommand(tw());vs.addCommand(rw());vs.addCommand(iw());vs.parse();
281
281
  /*! Bundled license information:
282
282
 
283
283
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exocortex-cli",
3
- "version": "13.139.0",
3
+ "version": "13.141.0",
4
4
  "description": "CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more",
5
5
  "main": "dist/index.js",
6
6
  "bin": {