@kitelev/exocortex-cli 16.240.11 → 16.240.12
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 +12 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// @kitelev/exocortex-cli v16.240.
|
|
2
|
+
// @kitelev/exocortex-cli v16.240.12
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
@@ -571,26 +571,28 @@ Available classes: ${t.join(", ")}`),super(n),this.name="ClassNotFoundError"}},E
|
|
|
571
571
|
`);if(K.length>0)throw new qm(Z.path,K)}let L,P;if(r.dryRun){let O=S.buildAsset(R);L=O.uid,P=O.path,process.stderr.write(`--- DRY RUN PREVIEW ---
|
|
572
572
|
${O.content}--- END PREVIEW ---
|
|
573
573
|
`)}else{let O=await S.createAsset(R);L=O.basename,P=O.path}let M={uuid:L,path:P,label:t};process.stdout.write(JSON.stringify(M)+`
|
|
574
|
-
`),process.exit(0)}catch(e){ce.handle(e)}})}a(O6,"createCommand");function yge(r,e){return e.concat([r])}a(yge,"collect");ct();var Ks=require("path"),Yd=require("fs"),Vc=ne(We());Rt();Bt();var rg=ne(We());var Uc="Asia/Almaty",Ma="exo__Asset_updatedAt";var kO={ems__Effort_status:{commands:["mark-done","move-to-backlog","rollback-to-backlog","start-effort","set-draft-status"]},ems__Task_zone:{commands:["set-criticality-high","set-criticality-medium","set-criticality-low"]},ems__Effort_parent:{commands:["set-parent"],argSuffix:`--input '{"parent":"<uid>"}'`},exo__Asset_label:{commands:["set-label"],argSuffix:`--input '{"label":"<text>"}'`},exo__Instance_class:{commands:["convert-to-task","convert-to-project"],note:"reclassing is a semantic operation with a precondition"},ems__Effort_startTimestamp:{commands:["start-effort","rollback-to-backlog","park-waiting"],clearedBy:["rollback-to-backlog","park-waiting"],note:"start-effort sets it; the others clear it as a side effect of the status change"},ems__Effort_endTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_resolutionTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_plannedStartTimestamp:{commands:["set-planned-start","plan-on-today","plan-for-evening","shift-day-forward","shift-day-backward"]},ems__Effort_plannedEndTimestamp:{commands:["set-planned-end"]},ems__Effort_scheduledDate:{commands:["set-scheduled-date"]},ems__Effort_votes:{commands:["vote-on-effort"]},archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]},exo__Asset_archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]}};function ng(r){return Object.prototype.hasOwnProperty.call(kO,r)?kO[r]:void 0}a(ng,"guardedRouteFor");function xw(r,e){if(e.size===0)return MO(r);let t=r.commands.filter(n=>e.has(n));return t.length===0?`apply ${r.commands.join("|")} <path> (\u26D4 none of these resolve in this vault \u2014 the owning assetspace looks unmounted)`:MO({...r,commands:t})}a(xw,"renderGuardedRouteResolved");function MO(r){let e=`apply ${r.commands.join("|")} <path>`,t=r.argSuffix?`${e} ${r.argSuffix}`:e;return r.note?`${t} (${r.note})`:t}a(MO,"renderGuardedRoute");var aje=Object.fromEntries(Object.entries(kO).map(([r,e])=>[r,MO(e)])),Ow={exo__Asset_uid:"the asset identity \u2014 changing it breaks UID-canon filenames and every inbound [[uid]] wikilink",[Ma]:"auto-managed (bumped on every mutation)"};function P6(r){let e=ng(r);if(e===void 0)return;let t=e.clearedBy??[];if(t.length===0)return;let{note:n,...i}=e;return{...i,commands:t}}a(P6,"clearingRouteFor");function D6(r){return`Refusing to remove "${r}" via remove-property \u2014 it is guarded, and no dedicated command clears it (the ones that own it assign a value). If dropping the facet is intended, say so explicitly: --force --reason "<why>"`}a(D6,"renderNoClearingPathRefusal");function Pw(r,e,t,n){return`Refusing to ${r} "${t}" via ${e} \u2014 it has a dedicated guarded command so the state machine / precondition is not bypassed. Use: exocortex ${n} --vault <v>`}a(Pw,"renderGuardRefusal");function Dw(r,e){return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}a(Dw,"guardedReason");function Bc(r,e){let n=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(r),i=a(s=>n.find(o=>o.type===s)?.value??"00","get");return`${i("year")}-${i("month")}-${i("day")}T${i("hour")}:${i("minute")}:${i("second")}`}a(Bc,"stampTimestamp");var _ge=/^\s*exocmd__Command_cliName:\s*(.+?)\s*$/gm;function bge(r){let e=r.trim();return e.length>=2&&(e[0]==='"'||e[0]==="'")&&e[e.length-1]===e[0]?e.slice(1,-1).trim():e}a(bge,"unquote");var Kd=class{constructor(e){this.vaultPath=e}static{a(this,"CommandNameRegistry")}async collect(){if(this.cache)return this.cache;let{readdir:e,readFile:t}=await import("fs/promises"),n=new Set,i=a(async s=>{let o;try{o=await e(s,{withFileTypes:!0})}catch{return}for(let c of o){let l=`${s}/${c.name}`;if(c.isDirectory()){if(c.name===".git"||c.name==="node_modules")continue;await i(l)}else if(c.isFile()&&c.name.endsWith(".md")){let u;try{u=await t(l,"utf-8")}catch{continue}for(let f of u.matchAll(_ge)){let d=bge(f[1]);d&&n.add(d)}}}},"walk");return await i(this.vaultPath),this.cache=n,n}};var Sge="exo__Asset_isDefinedBy";function wge(r){let e=a(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean","isScalar");if(e(r)||Array.isArray(r)&&r.every(e))return;let t=r===null?"null":Array.isArray(r)?"an array with non-scalar elements":typeof r;throw new Error(`--input.value must be a scalar (string/number/boolean) or an array of scalars, not ${t}`)}a(wge,"assertScalarOrScalarArray");function Ege(r,e){if(e==="")throw new Error(`Refusing to set "${r}" to an EMPTY value \u2014 an empty string writes a junk key (${r}: "") rather than clearing the property. To delete it use: exocortex remove-property <path> --property ${r} --vault <v>`)}a(Ege,"assertNonEmptyValue");function vge(r){let e=r.input!==void 0,t=r.property!==void 0;if(e&&t)throw new Ke("Pass --input OR --property/--value, not both.",`set-property <path> --input '{"property":"<name>","value":<v>}'`);if(e){let n;try{n=JSON.parse(r.input)}catch(o){let c=o instanceof Error?o.message:String(o);throw new Error(`--input: invalid JSON (${c})`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error('--input must be a JSON object of the form {"property":"<name>","value":<v>}');let i=n,s=i.property;if(typeof s!="string"||s.trim().length===0)throw new Error("--input.property must be a non-empty string");if(!("value"in i))throw new Error("--input.value is required");return{property:s.trim(),value:i.value}}if(t){if(r.value===void 0)throw new Error("--property requires --value (or use --input for a typed/array value)");return{property:r.property.trim(),value:r.value}}throw new Ke("No property provided.",`set-property <path> --input '{"property":"<name>","value":<v>}' OR set-property <path> --property <name> --value <string>`)}a(vge,"resolvePropertyAndValue");function Tge(r,e){let t=Vc.STRING_SCALAR_PROPERTIES.has(e);return Array.isArray(r)?r.map(n=>(0,Vc.serializeYamlScalar)(n,t)):(0,Vc.serializeYamlScalar)(r,t)}a(Tge,"serializeForWrite");function F6(){return new de("set-property").description("Set an arbitrary non-guarded frontmatter property on an existing vault asset (bumps exo__Asset_updatedAt). Refuses state-machine-guarded properties (status/zone/parent/label/fact-timestamps) \u2014 those keep their dedicated `apply` commands. Issues #3795 / #3848.").argument("<path>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>",'JSON {"property":"<name>","value":<v>} \u2014 value is JSON-typed (boolean/number/string/array). Primary form.').option("--property <name>","Property name (string-value convenience form; pair with --value; use --input for boolean/number/array values)").option("--value <value>","Property value as a string (pair with --property; use --input for typed/array values)").option("--skip-wikilink-validation","Skip [[...]] wikilink existence validation").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--dry-run","Preview the resulting frontmatter without writing").option("--yes","Accepted for symmetry with the apply/create subcommands (set-property is non-interactive; no-op)").action(async(r,e)=>{try{let t=(0,Ks.resolve)(e.vault);if(!(0,Yd.existsSync)(t))throw new ke(t);let n=(0,Ks.resolve)(t,r),i=(0,Ks.relative)(t,n);if(i===".."||i.startsWith(`..${Ks.sep}`)||(0,Ks.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);let s;try{s=(0,Yd.readFileSync)(n,"utf-8")}catch(w){throw w.code==="ENOENT"?new Error(`Target file not found: ${r}`):w}if(!/^\s*exo__Asset_uid:/m.test(s))throw new Error(`Not a vault asset (no exo__Asset_uid): ${i}. set-property only mutates existing assets.`);let{property:o,value:c}=vge(e),l=Vc.FrontmatterService.normalizeIRI(o),u=Dw(Ow,l);if(u!==void 0)throw new Error(`Refusing to set "${l}" \u2014 ${u}.`);let f=ng(l);if(f!==void 0){let w=await new Kd(t).collect();throw new Error(Pw("set","set-property",l,xw(f,w)))}if(await new jc(t).validate([l]),wge(c),Ege(o,c),!e.skipWikilinkValidation){let w=new Mc(new ui(t)),S=Array.isArray(c)?c:[c];for(let R of S)typeof R=="string"&&await w.validateValue(R)}let p=new Vc.FrontmatterService,h=e.frozenClock?new Date(e.frozenClock):new Date,
|
|
575
|
-
${
|
|
574
|
+
`),process.exit(0)}catch(e){ce.handle(e)}})}a(O6,"createCommand");function yge(r,e){return e.concat([r])}a(yge,"collect");ct();var Ks=require("path"),Yd=require("fs"),Vc=ne(We());Rt();Bt();var rg=ne(We());var Uc="Asia/Almaty",Ma="exo__Asset_updatedAt";var kO={ems__Effort_status:{commands:["mark-done","move-to-backlog","rollback-to-backlog","start-effort","set-draft-status"]},ems__Task_zone:{commands:["set-criticality-high","set-criticality-medium","set-criticality-low"]},ems__Effort_parent:{commands:["set-parent"],argSuffix:`--input '{"parent":"<uid>"}'`},exo__Asset_label:{commands:["set-label"],argSuffix:`--input '{"label":"<text>"}'`},exo__Instance_class:{commands:["convert-to-task","convert-to-project"],note:"reclassing is a semantic operation with a precondition"},ems__Effort_startTimestamp:{commands:["start-effort","rollback-to-backlog","park-waiting"],clearedBy:["rollback-to-backlog","park-waiting"],note:"start-effort sets it; the others clear it as a side effect of the status change"},ems__Effort_endTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_resolutionTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_plannedStartTimestamp:{commands:["set-planned-start","plan-on-today","plan-for-evening","shift-day-forward","shift-day-backward"]},ems__Effort_plannedEndTimestamp:{commands:["set-planned-end"]},ems__Effort_scheduledDate:{commands:["set-scheduled-date"]},ems__Effort_votes:{commands:["vote-on-effort"]},archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]},exo__Asset_archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]}};function ng(r){return Object.prototype.hasOwnProperty.call(kO,r)?kO[r]:void 0}a(ng,"guardedRouteFor");function xw(r,e){if(e.size===0)return MO(r);let t=r.commands.filter(n=>e.has(n));return t.length===0?`apply ${r.commands.join("|")} <path> (\u26D4 none of these resolve in this vault \u2014 the owning assetspace looks unmounted)`:MO({...r,commands:t})}a(xw,"renderGuardedRouteResolved");function MO(r){let e=`apply ${r.commands.join("|")} <path>`,t=r.argSuffix?`${e} ${r.argSuffix}`:e;return r.note?`${t} (${r.note})`:t}a(MO,"renderGuardedRoute");var aje=Object.fromEntries(Object.entries(kO).map(([r,e])=>[r,MO(e)])),Ow={exo__Asset_uid:"the asset identity \u2014 changing it breaks UID-canon filenames and every inbound [[uid]] wikilink",[Ma]:"auto-managed (bumped on every mutation)"};function P6(r){let e=ng(r);if(e===void 0)return;let t=e.clearedBy??[];if(t.length===0)return;let{note:n,...i}=e;return{...i,commands:t}}a(P6,"clearingRouteFor");function D6(r){return`Refusing to remove "${r}" via remove-property \u2014 it is guarded, and no dedicated command clears it (the ones that own it assign a value). If dropping the facet is intended, say so explicitly: --force --reason "<why>"`}a(D6,"renderNoClearingPathRefusal");function Pw(r,e,t,n){return`Refusing to ${r} "${t}" via ${e} \u2014 it has a dedicated guarded command so the state machine / precondition is not bypassed. Use: exocortex ${n} --vault <v>`}a(Pw,"renderGuardRefusal");function Dw(r,e){return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}a(Dw,"guardedReason");function Bc(r,e){let n=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(r),i=a(s=>n.find(o=>o.type===s)?.value??"00","get");return`${i("year")}-${i("month")}-${i("day")}T${i("hour")}:${i("minute")}:${i("second")}`}a(Bc,"stampTimestamp");var _ge=/^\s*exocmd__Command_cliName:\s*(.+?)\s*$/gm;function bge(r){let e=r.trim();return e.length>=2&&(e[0]==='"'||e[0]==="'")&&e[e.length-1]===e[0]?e.slice(1,-1).trim():e}a(bge,"unquote");var Kd=class{constructor(e){this.vaultPath=e}static{a(this,"CommandNameRegistry")}async collect(){if(this.cache)return this.cache;let{readdir:e,readFile:t}=await import("fs/promises"),n=new Set,i=a(async s=>{let o;try{o=await e(s,{withFileTypes:!0})}catch{return}for(let c of o){let l=`${s}/${c.name}`;if(c.isDirectory()){if(c.name===".git"||c.name==="node_modules")continue;await i(l)}else if(c.isFile()&&c.name.endsWith(".md")){let u;try{u=await t(l,"utf-8")}catch{continue}for(let f of u.matchAll(_ge)){let d=bge(f[1]);d&&n.add(d)}}}},"walk");return await i(this.vaultPath),this.cache=n,n}};var Sge="exo__Asset_isDefinedBy";function wge(r){let e=a(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean","isScalar");if(e(r)||Array.isArray(r)&&r.every(e))return;let t=r===null?"null":Array.isArray(r)?"an array with non-scalar elements":typeof r;throw new Error(`--input.value must be a scalar (string/number/boolean) or an array of scalars, not ${t}`)}a(wge,"assertScalarOrScalarArray");function Ege(r,e){if(e==="")throw new Error(`Refusing to set "${r}" to an EMPTY value \u2014 an empty string writes a junk key (${r}: "") rather than clearing the property. To delete it use: exocortex remove-property <path> --property ${r} --vault <v>`)}a(Ege,"assertNonEmptyValue");function vge(r){let e=r.input!==void 0,t=r.property!==void 0;if(e&&t)throw new Ke("Pass --input OR --property/--value, not both.",`set-property <path> --input '{"property":"<name>","value":<v>}'`);if(e){let n;try{n=JSON.parse(r.input)}catch(o){let c=o instanceof Error?o.message:String(o);throw new Error(`--input: invalid JSON (${c})`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error('--input must be a JSON object of the form {"property":"<name>","value":<v>}');let i=n,s=i.property;if(typeof s!="string"||s.trim().length===0)throw new Error("--input.property must be a non-empty string");if(!("value"in i))throw new Error("--input.value is required");return{property:s.trim(),value:i.value}}if(t){if(r.value===void 0)throw new Error("--property requires --value (or use --input for a typed/array value)");return{property:r.property.trim(),value:r.value}}throw new Ke("No property provided.",`set-property <path> --input '{"property":"<name>","value":<v>}' OR set-property <path> --property <name> --value <string>`)}a(vge,"resolvePropertyAndValue");function Tge(r,e){let t=Vc.STRING_SCALAR_PROPERTIES.has(e);return Array.isArray(r)?r.map(n=>(0,Vc.serializeYamlScalar)(n,t)):(0,Vc.serializeYamlScalar)(r,t)}a(Tge,"serializeForWrite");function F6(){return new de("set-property").description("Set an arbitrary non-guarded frontmatter property on an existing vault asset (bumps exo__Asset_updatedAt only when the value actually changed; a no-op leaves the file byte-identical). Refuses state-machine-guarded properties (status/zone/parent/label/fact-timestamps) \u2014 those keep their dedicated `apply` commands. Issues #3795 / #3848.").argument("<path>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>",'JSON {"property":"<name>","value":<v>} \u2014 value is JSON-typed (boolean/number/string/array). Primary form.').option("--property <name>","Property name (string-value convenience form; pair with --value; use --input for boolean/number/array values)").option("--value <value>","Property value as a string (pair with --property; use --input for typed/array values)").option("--skip-wikilink-validation","Skip [[...]] wikilink existence validation").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--dry-run","Preview the resulting frontmatter without writing").option("--yes","Accepted for symmetry with the apply/create subcommands (set-property is non-interactive; no-op)").action(async(r,e)=>{try{let t=(0,Ks.resolve)(e.vault);if(!(0,Yd.existsSync)(t))throw new ke(t);let n=(0,Ks.resolve)(t,r),i=(0,Ks.relative)(t,n);if(i===".."||i.startsWith(`..${Ks.sep}`)||(0,Ks.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);let s;try{s=(0,Yd.readFileSync)(n,"utf-8")}catch(w){throw w.code==="ENOENT"?new Error(`Target file not found: ${r}`):w}if(!/^\s*exo__Asset_uid:/m.test(s))throw new Error(`Not a vault asset (no exo__Asset_uid): ${i}. set-property only mutates existing assets.`);let{property:o,value:c}=vge(e),l=Vc.FrontmatterService.normalizeIRI(o),u=Dw(Ow,l);if(u!==void 0)throw new Error(`Refusing to set "${l}" \u2014 ${u}.`);let f=ng(l);if(f!==void 0){let w=await new Kd(t).collect();throw new Error(Pw("set","set-property",l,xw(f,w)))}if(await new jc(t).validate([l]),wge(c),Ege(o,c),!e.skipWikilinkValidation){let w=new Mc(new ui(t)),S=Array.isArray(c)?c:[c];for(let R of S)typeof R=="string"&&await w.validateValue(R)}let p=new Vc.FrontmatterService,h=(0,rg.canonicalYamlKey)(l),m=p.updateProperty(s,h,Tge(c,h)),g=m!==s,_=m,b;if(g){let w=e.frozenClock?new Date(e.frozenClock):new Date,S=e.timezone??Uc;b=Bc(w,S),_=p.updateProperty(m,Ma,b)}let T;if(l===Sge){let w=Array.isArray(c)?c[0]:c,S=await Iw(new ui(t),w);if(S!==null){let R=(0,Ks.dirname)(i),L=R==="."?"":R;L!==S&&(T=`\u26A0 co-location: exo__Asset_isDefinedBy now points at "${S||"<vault root>"}" but the file is in "${L||"<vault root>"}". Move it to match: exocortex apply repair-folder ${i} --vault <v>`)}}e.dryRun?process.stderr.write(`--- DRY RUN PREVIEW ---
|
|
575
|
+
${_}
|
|
576
576
|
--- END PREVIEW ---
|
|
577
|
-
`):(0,Yd.writeFileSync)(n,
|
|
578
|
-
`)
|
|
577
|
+
`):g&&(0,Yd.writeFileSync)(n,_,"utf-8"),g||process.stderr.write(`\u2139 no change: "${l}" already has this value \u2014 exo__Asset_updatedAt untouched
|
|
578
|
+
`),T&&process.stderr.write(T+`
|
|
579
|
+
`);let I={path:i,property:l,value:c,changed:g,...b?{updatedAt:b}:{},...T?{coLocationWarning:!0}:{}};process.stdout.write(JSON.stringify(I)+`
|
|
579
580
|
`),process.exit(0)}catch(t){ce.handle(t)}})}a(F6,"setPropertyCommand");ct();var ja=require("path"),Qd=require("fs"),jO=ne(We());Rt();Bt();function Age(r){let e=r.input!==void 0,t=r.property!==void 0;if(e&&t)throw new Ke("Pass --input OR --property, not both.","remove-property <path> --property <name>");if(e){let n;try{n=JSON.parse(r.input)}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`--input: invalid JSON (${o})`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error('--input must be a JSON object of the form {"property":"<name>"}');let i=n.property;if(typeof i!="string"||i.trim().length===0)throw new Error("--input.property must be a non-empty string");return i.trim()}if(t){let n=r.property.trim();if(n.length===0)throw new Error("--property must be a non-empty name");return n}throw new Ke("No property provided.",`remove-property <path> --property <name> OR remove-property <path> --input '{"property":"<name>"}'`)}a(Age,"resolveProperty");function L6(){return new de("remove-property").description("Delete a non-guarded frontmatter property from an existing vault asset (bumps exo__Asset_updatedAt when a change occurs). The delete-side counterpart of set-property; refuses state-machine-guarded properties (status/zone/parent/label/fact-timestamps) \u2014 those keep their dedicated `apply` commands. Issue #3926.").argument("<path>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>",`JSON {"property":"<name>"} \u2014 the property to remove (symmetric with set-property's --input).`).option("--property <name>","Property name to remove (convenience form; use --input for scripting)").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--force","Remove a guarded property that has NO clearing command (requires --reason). Refused when a clearing command exists \u2014 see req 148ce5a4.").option("--reason <text>","Why the guarded property is being dropped; recorded on stderr as the audit trail of a deliberate bypass").option("--dry-run","Preview the resulting frontmatter without writing").option("--yes","Accepted for symmetry with the apply/create subcommands (remove-property is non-interactive; no-op)").action(async(r,e)=>{try{let t=(0,ja.resolve)(e.vault);if(!(0,Qd.existsSync)(t))throw new ke(t);let n=(0,ja.resolve)(t,r),i=(0,ja.relative)(t,n);if(i===".."||i.startsWith(`..${ja.sep}`)||(0,ja.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);let s;try{s=(0,Qd.readFileSync)(n,"utf-8")}catch(_){throw _.code==="ENOENT"?new Error(`Target file not found: ${r}`):_}if(!/^\s*exo__Asset_uid:/m.test(s))throw new Error(`Not a vault asset (no exo__Asset_uid): ${i}. remove-property only mutates existing assets.`);let o=Age(e),c=jO.FrontmatterService.normalizeIRI(o),l=Dw(Ow,c);if(l!==void 0)throw new Error(`Refusing to remove "${c}" \u2014 ${l}.`);if(ng(c)!==void 0){let _=P6(c);if(_!==void 0){let T=await new Kd(t).collect();throw new Error(Pw("remove","remove-property",c,xw(_,T)))}let b=typeof e.reason=="string"?e.reason.trim():"";if(e.force!==!0||b.length===0)throw new Error(D6(c));console.error(`[guard-bypass] remove-property "${c}" on ${i} \u2014 reason: ${b}`)}let f=new jO.FrontmatterService,d=f.removeProperty(s,(0,rg.canonicalYamlKey)(c)),p=d!==s,h=d,m;if(p){let _=e.frozenClock?new Date(e.frozenClock):new Date,b=e.timezone??Uc;m=Bc(_,b),h=f.updateProperty(d,Ma,m)}p||await new jc(t).isUnknownName(c)&&process.stderr.write(`\u26A0\uFE0F Nothing was removed, and "${c}" is not a property in the mounted TBox \u2014 check the spelling (an undeclared property is removable, so this is a hint, not a refusal).
|
|
580
581
|
`),e.dryRun?process.stderr.write(`--- DRY RUN PREVIEW ---
|
|
581
582
|
${h}
|
|
582
583
|
--- END PREVIEW ---
|
|
583
584
|
`):p&&(0,Qd.writeFileSync)(n,h,"utf-8");let g={path:i,property:c,removed:p,...m?{updatedAt:m}:{}};process.stdout.write(JSON.stringify(g)+`
|
|
584
|
-
`),process.exit(0)}catch(t){ce.handle(t)}})}a(L6,"removePropertyCommand");ct();var $a=require("path"),Gc=require("fs"),N6=ne(We());Rt();Bt();function Ige(r){return new Promise((e,t)=>{let n=[],i=setTimeout(()=>{t(new Error(`Timed out reading body from stdin after ${r}ms`))},r);process.stdin.on("data",s=>n.push(Buffer.from(s))),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(n).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)})})}a(Ige,"readStdin");async function Rge(r){if(r.bodyFile){if(!(0,Gc.existsSync)(r.bodyFile))throw new Error(`Body file not found: ${r.bodyFile}`);return{text:(0,Gc.readFileSync)(r.bodyFile,"utf-8"),source:"file"}}if(r.body==="-")return{text:await Ige(3e4),source:"stdin"};if(r.body!==void 0)return{text:r.body,source:"inline"}}a(Rge,"resolveNewBody");function k6(){return new de("set-body").description("Overwrite the markdown BODY of an existing vault asset (frontmatter untouched, exo__Asset_updatedAt bumped, new-body wikilinks validated). The dogfood body-rewrite path \u2014 no raw backup\u2192rm\u2192Write. Issue #3943.").argument("<path>","Vault-relative path to the asset to rewrite").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--body-file <path>","Read the new body from a file").option("--body <text>","New body text ('-' reads from stdin)").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--dry-run","Preview the resulting content without writing").option("--skip-wikilink-validation","Skip wikilink existence validation for the new body").action(async(r,e)=>{try{let t=(0,$a.resolve)(e.vault);if(!(0,Gc.existsSync)(t))throw new ke(t);let n=(0,$a.resolve)(t,r),i=(0,$a.relative)(t,n);if(i===".."||i.startsWith(`..${$a.sep}`)||(0,$a.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);if(e.bodyFile===void 0&&e.body===void 0)throw new Error("Provide the new body via --body-file <path>, --body <text>, or --body - (stdin).");let s;try{s=(0,Gc.readFileSync)(n,"utf-8")}catch(
|
|
585
|
+
`),process.exit(0)}catch(t){ce.handle(t)}})}a(L6,"removePropertyCommand");ct();var $a=require("path"),Gc=require("fs"),N6=ne(We());Rt();Bt();function Ige(r){return new Promise((e,t)=>{let n=[],i=setTimeout(()=>{t(new Error(`Timed out reading body from stdin after ${r}ms`))},r);process.stdin.on("data",s=>n.push(Buffer.from(s))),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(n).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)})})}a(Ige,"readStdin");async function Rge(r){if(r.bodyFile){if(!(0,Gc.existsSync)(r.bodyFile))throw new Error(`Body file not found: ${r.bodyFile}`);return{text:(0,Gc.readFileSync)(r.bodyFile,"utf-8"),source:"file"}}if(r.body==="-")return{text:await Ige(3e4),source:"stdin"};if(r.body!==void 0)return{text:r.body,source:"inline"}}a(Rge,"resolveNewBody");function k6(){return new de("set-body").description("Overwrite the markdown BODY of an existing vault asset (frontmatter untouched, exo__Asset_updatedAt bumped only when the body actually changed \u2014 a byte-identical body is a no-op, new-body wikilinks validated). The dogfood body-rewrite path \u2014 no raw backup\u2192rm\u2192Write. Issue #3943.").argument("<path>","Vault-relative path to the asset to rewrite").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--body-file <path>","Read the new body from a file").option("--body <text>","New body text ('-' reads from stdin)").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--dry-run","Preview the resulting content without writing").option("--skip-wikilink-validation","Skip wikilink existence validation for the new body").action(async(r,e)=>{try{let t=(0,$a.resolve)(e.vault);if(!(0,Gc.existsSync)(t))throw new ke(t);let n=(0,$a.resolve)(t,r),i=(0,$a.relative)(t,n);if(i===".."||i.startsWith(`..${$a.sep}`)||(0,$a.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);if(e.bodyFile===void 0&&e.body===void 0)throw new Error("Provide the new body via --body-file <path>, --body <text>, or --body - (stdin).");let s;try{s=(0,Gc.readFileSync)(n,"utf-8")}catch(b){throw b.code==="ENOENT"?new Error(`Target file not found: ${r}`):b}if(!/^\s*exo__Asset_uid:/m.test(s))throw new Error(`Not a vault asset (no exo__Asset_uid): ${i}. set-body only rewrites existing assets.`);let o=new N6.FrontmatterService,c=o.parse(s);if(!c.exists)throw new Error(`No frontmatter block found in ${i}; set-body preserves the frontmatter and only rewrites the body.`);let l=`---
|
|
585
586
|
${c.content}
|
|
586
587
|
---`,u=await Rge(e),f=u?.text??"";u?.source==="inline"&&(f=f.replace(/\\n/g,`
|
|
587
588
|
`)),e.skipWikilinkValidation||await new Mc(new ui(t)).validateValue(f);let d=f.length>0?f.endsWith(`
|
|
588
589
|
`)?f:`${f}
|
|
589
590
|
`:"",p=`${l}
|
|
590
|
-
${d}`,h=e.frozenClock?new Date(e.frozenClock):new Date,
|
|
591
|
-
${
|
|
591
|
+
${d}`,h=p!==s,m=p,g;if(h){let b=e.frozenClock?new Date(e.frozenClock):new Date,T=e.timezone??Uc;g=Bc(b,T),m=o.updateProperty(p,Ma,g)}e.dryRun?process.stderr.write(`--- DRY RUN PREVIEW ---
|
|
592
|
+
${m}
|
|
592
593
|
--- END PREVIEW ---
|
|
593
|
-
`):(0,Gc.writeFileSync)(n,
|
|
594
|
+
`):h&&(0,Gc.writeFileSync)(n,m,"utf-8"),h||process.stderr.write(`\u2139 no change: the body is byte-identical \u2014 exo__Asset_updatedAt untouched
|
|
595
|
+
`);let _={path:i,changed:h,...g?{updatedAt:g}:{},bodyBytes:Buffer.byteLength(d,"utf8")};process.stdout.write(JSON.stringify(_)+`
|
|
594
596
|
`),process.exit(0)}catch(t){ce.handle(t)}})}a(k6,"setBodyCommand");ct();var Ua=require("path"),Xd=require("fs"),ig=ne(We());Rt();Bt();function Cge(r){let e=new ig.FrontmatterService,t=e.parseObject(r);if(!t)return{changed:!1,content:r,canonicalized:[]};let n=r,i=[];for(let[s,o]of ig.LEGACY_YAML_KEYS){let c=o.find(u=>Object.prototype.hasOwnProperty.call(t,u));if(c===void 0)continue;let l=Object.prototype.hasOwnProperty.call(t,s)?t[s]:t[c];n=e.updateProperty(n,s,l),i.push({from:c,to:s})}return{changed:i.length>0,content:n,canonicalized:i}}a(Cge,"canonicalizeLegacyKeys");var xge=/^([^\s#][^:]*):(?:\s.*)?$/;function Oge(r){let e=r.match(/^(---\r?\n)([\s\S]*?)(\r?\n---)/);if(!e)return{changed:!1,content:r,removed:[]};let[,t,n,i]=e,s=t.includes(`\r
|
|
595
597
|
`)?`\r
|
|
596
598
|
`:`
|
|
@@ -674,7 +676,7 @@ Next steps:
|
|
|
674
676
|
`).map(n=>n.trim()).filter(n=>n.length>0),t=e[e.length-1];if(t!==void 0)try{return JSON.parse(t)}catch{return}}a(Y0e,"parseLastJsonLine");function t8(r,e){return e.filter(t=>{let n=r[t];return typeof n!="string"||n.trim().length===0})}a(t8,"missingStringFields");var rE=class{constructor(e){this.deps=e}static{a(this,"McpServer")}async handle(e){if(typeof e!="object"||e===null||Array.isArray(e))return{jsonrpc:"2.0",id:null,error:{code:e8,message:"Invalid request: expected a JSON-RPC object"}};let t=e.id,n=t===void 0;if(typeof e.method!="string")return n?null:{jsonrpc:"2.0",id:t??null,error:{code:e8,message:"Invalid request: missing method"}};if(n)return null;let i=t??null;switch(e.method){case"initialize":return{jsonrpc:"2.0",id:i,result:{protocolVersion:z0e,capabilities:{tools:{}},serverInfo:{name:"exocortex",version:this.deps.version}}};case"ping":return{jsonrpc:"2.0",id:i,result:{}};case"tools/list":return{jsonrpc:"2.0",id:i,result:{tools:Z7}};case"tools/call":return{jsonrpc:"2.0",id:i,result:await this.callTool(e.params??{})};default:return{jsonrpc:"2.0",id:i,error:{code:K0e,message:`Method not found: ${e.method}`}}}}async callTool(e){let t=e.name,n=e.arguments??{},i;if(t==="create_asset"){let c=t8(n,["vault","class","label"]);if(c.length>0)return op(`create_asset: missing required argument(s): ${c.join(", ")}`,!0);let l=Q7(n);if(l!==null)return op(`create_asset: ${l}`,!0);i=X7(n)}else if(t==="create_effort"){let c=t8(n,["vault","command","target"]);if(c.length>0)return op(`create_effort: missing required argument(s): ${c.join(", ")}`,!0);i=J7(n)}else return op(`Unknown tool: ${String(t)}`,!0);let s=await this.deps.runCli(i);if(s.exitCode!==0){let c=s.stderr.trim()||s.stdout.trim()||"(no diagnostic output)";return op(`exocortex-cli exited ${s.exitCode}
|
|
675
677
|
${c}`,!0)}let o=Y0e(s.stdout);return op(o===void 0?s.stdout.trim():JSON.stringify(o))}};var i8=require("child_process");var Q0e=32*1024*1024;function s8(r){return e=>new Promise(t=>{(0,i8.execFile)(process.execPath,[r,...e],{maxBuffer:Q0e},(n,i,s)=>{let o=0;if(n){let c=n.code;o=typeof c=="number"?c:1}t({stdout:i,stderr:s,exitCode:o})})})}a(s8,"createSelfCliRunner");async function X0e(r,e,t){let n=(0,o8.createInterface)({input:e,crlfDelay:1/0});for await(let i of n){let s=i.trim();if(s.length===0)continue;let o;try{o=JSON.parse(s)}catch{t(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:r8,message:"Parse error: invalid JSON"}})+`
|
|
676
678
|
`);continue}let c;try{c=await r.handle(o)}catch(l){c={jsonrpc:"2.0",id:typeof o?.id=="string"||typeof o?.id=="number"?o.id:null,error:{code:n8,message:`Internal error: ${l instanceof Error?l.message:String(l)}`}}}c!==null&&t(JSON.stringify(c)+`
|
|
677
|
-
`)}}a(X0e,"runStdioServer");function a8(r){return new de("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new rE({runCli:s8(t),version:r??"unknown"});await X0e(n,process.stdin,i=>process.stdout.write(i))})}a(a8,"mcpCommand");function nE(r){let e=new de;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"16.240.
|
|
679
|
+
`)}}a(X0e,"runStdioServer");function a8(r){return new de("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new rE({runCli:s8(t),version:r??"unknown"});await X0e(n,process.stdin,i=>process.stdout.write(i))})}a(a8,"mcpCommand");function nE(r){let e=new de;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"16.240.12"),e.addCommand(U6()),e.addCommand(Y6()),e.addCommand(LB()),e.addCommand(jB()),e.addCommand(o6()),e.addCommand($B()),e.addCommand(WB()),e.addCommand(HB()),e.addCommand(p6()),e.addCommand(_6()),e.addCommand(O6()),e.addCommand(F6()),e.addCommand(L6()),e.addCommand(k6()),e.addCommand(M6()),e.addCommand(S7()),e.addCommand(v7()),e.addCommand(j7()),e.addCommand(U7()),e.addCommand(G7()),e.addCommand(q7()),e.addCommand(z7()),e.addCommand(x7()),e.addCommand(N7()),e.addCommand(K7()),e.addCommand(a8(r??"16.240.12")),e}a(nE,"createProgram");nE().parse();0&&(module.exports={createProgram});
|
|
678
680
|
/*! Bundled license information:
|
|
679
681
|
|
|
680
682
|
reflect-metadata/Reflect.js:
|
package/package.json
CHANGED