@kitelev/exocortex-cli 16.191.0 → 16.191.1
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 v16.191.
|
|
2
|
+
// @kitelev/exocortex-cli v16.191.1
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
@@ -550,7 +550,7 @@ Hidden by precondition (${n.hidden.length}):`),n.hidden.length===0)console.log("
|
|
|
550
550
|
`),console.log(` Instances: ${c}`),console.log(` Properties: ${f.length}
|
|
551
551
|
`),f.length===0){console.log(" No properties found.");return}let p=Math.max(...f.map(h=>h.name.length),10);console.log(" \u250C"+"\u2500".repeat(p+2)+"\u252C"+"\u2500".repeat(10)+"\u2510"),console.log(" \u2502 "+"Property".padEnd(p)+" \u2502 "+"Usage".padEnd(8)+" \u2502"),console.log(" \u251C"+"\u2500".repeat(p+2)+"\u253C"+"\u2500".repeat(10)+"\u2524");for(let h of f)console.log(" \u2502 "+h.name.padEnd(p)+" \u2502 "+h.usageCount.toString().padStart(8)+" \u2502");console.log(" \u2514"+"\u2500".repeat(p+2)+"\u2534"+"\u2500".repeat(10)+"\u2518")}}a(Fle,"showClassDetails");function G5(n){let e=n.replace(/^<|>$/g,""),t=e.lastIndexOf("#");if(t!==-1)return e.substring(t+1);let r=e.lastIndexOf("/");return r!==-1?e.substring(r+1):e}a(G5,"extractLocalName");var H5=require("fs"),z5=require("path"),al=Se(it());function W5(n,e){return e.concat([n])}a(W5,"collect");function Lle(n,e){let t={},r=a((i,s)=>{let o=i.indexOf("=");if(o<=0)throw new Error(`Invalid --param "${i}" \u2014 expected name=value.`);let c=i.slice(0,o),l=i.slice(o+1);t[c]={value:s==="iri"?(0,al.vaultPathToIRI)(l):l,kind:s}},"add");for(let i of n)r(i,"literal");for(let i of e)r(i,"iri");return Object.keys(t).length>0?t:void 0}a(Lle,"buildParams");function K5(){return new Le("run-query").description("Execute a query__NamedQuery asset (read-only SELECT / ASK / CONSTRUCT) by UID and print its result.").argument("<uid>","UID of the query__NamedQuery asset to run").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: table|json","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--use-cache","Use persistent cache (faster for repeated queries)").option("--current-asset <path>","Vault-relative path injected as $currentAsset (an IRI) into the query body").option("--param <name=value>","Literal parameter $<name> substituted as an escaped string. Repeatable.",W5,[]).option("--param-iri <name=path>","IRI parameter $<name>; value is a vault-relative path resolved to an IRI. Repeatable.",W5,[]).action(async(n,e)=>{let t=e.output||"text",r=t==="json"||e.format==="json";Ee.setFormat(t);try{let i=(0,z5.resolve)(e.vault);if(!(0,H5.existsSync)(i))throw new Je(i);r||console.log(`\u{1F4E6} Loading vault: ${i}...`);let s;e.useCache??!1?s=(await new Ti(i).loadOrBuild()).triples:s=await new al.NoteToRDFConverter(new $t(i)).convertVault();let o=new al.InMemoryTripleStore;await o.addAll(s);let c=Z_(o,i),l={};e.currentAsset&&(l.currentAsset=(0,al.vaultPathToIRI)(e.currentAsset));let u=Lle(e.param,e.paramIri);u&&(l.params=u);let f=await c.run(n,l);f===null&&Ee.handleWithMessage(`No resolvable query__NamedQuery for UID "${n}" (asset not found, or it has no \`\`\`sparql code-block).`,3,"VALIDATION_FILE_NOT_FOUND"),Nle(f,r)}catch(i){Ee.handle(i)}})}a(K5,"runQueryCommand");function Nle(n,e){if(n.kind==="ask"){console.log(e?JSON.stringify(ft.success({kind:"ask",result:n.result}),null,2):String(n.result));return}if(n.kind==="construct"){let t=n.triples.map(r=>({subject:r.subject.toString(),predicate:r.predicate.toString(),object:r.object.toString()}));if(e)console.log(JSON.stringify(ft.success({kind:"construct",triples:t,count:t.length}),null,2));else{console.log(`\u{1F4CA} CONSTRUCT \u2014 ${t.length} triple(s):
|
|
552
552
|
`);for(let r of t)console.log(`${r.subject} ${r.predicate} ${r.object} .`)}return}if(e){let t=n.rows.map(r=>{let i={};for(let s of r.variables()){let o=r.get(s);i[s]=o?o.toString():null}return i});console.log(JSON.stringify(ft.success({kind:"select",rows:t,count:t.length}),null,2))}else console.log(new cf().format(n.rows))}a(Nle,"printResult");var r$=require("path"),Hx=require("fs"),n$=require("fs"),wf=Se(it());var Ux=class extends Error{static{a(this,"ClassNotFoundError")}constructor(e,t){let r=`Class '${e}' not found in vault`;t&&t.length>0&&(r+=`
|
|
553
|
-
Available classes: ${t.join(", ")}`),super(r),this.name="ClassNotFoundError"}},tb=class{constructor(e){this.fsAdapter=e;this.cache=new Map}static{a(this,"ClassResolverService")}async resolve(e,t){if(this.isUUID(t))return t;let r=await this.getOrBuildIndex(e),i=r.get(t);if(!i){let s=Array.from(r.keys()).filter(o=>!this.isUUID(o));throw new Ux(t,s)}return i}async listClasses(e){let t=await this.getOrBuildIndex(e);return Array.from(t.keys())}async getOrBuildIndex(e){if(this.cache.has(e))return this.cache.get(e);let t=await this.buildIndex(e);return this.cache.set(e,t),t}async buildIndex(e){let t=new Map,r=await this.fsAdapter.getMarkdownFiles(),i=[],s=new Set;for(let o of r)try{let c=await this.fsAdapter.getFileMetadata(o),l=this.getBasename(o),u=c.exo__Asset_uid;!u&&this.isUUID(l)&&(u=l);let f=u?String(u):void 0,d=c.exo__Asset_label,p=typeof d=="string"?d:void 0,h=c.exo__Instance_class,_=h?(Array.isArray(h)?h:[h]).map(y=>String(y)):[];i.push({basename:l,uid:f,label:p,classValues:_}),f&&(p==="exo__Class"||p==="ims__Class")&&s.add(f)}catch{continue}for(let o of i)o.uid&&this.isClassDefinition(o.classValues,s)&&(o.basename&&t.set(o.basename,o.uid),o.label&&o.label!==o.basename&&t.set(o.label,o.uid));return t}isClassDefinition(e,t){return e.some(r=>{if(r.includes("ims__Class")||r.includes("exo__Class"))return!0;for(let i of t)if(i&&r.includes(i))return!0;return!1})}getBasename(e){let t=e.split("/");return t[t.length-1].replace(/\.md$/,"")}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}};var Bx=class extends Error{static{a(this,"WikilinkNotFoundError")}constructor(e,t){let r=t?`|${t}`:"";super(`Wikilink [[${e}${r}]] \u2014 file not found in vault`),this.name="WikilinkNotFoundError"}},gf=class{constructor(e){this.fsAdapter=e}static{a(this,"WikilinkValidator")}static{this.WIKILINK_PATTERN=/\[\[([^\]|]+)(?:\|[^\]]*)?]]/g}async validatePropertyValues(e){for(let[,t]of Object.entries(e)){let r=Array.isArray(t)?t:[t];for(let i of r)await this.validateValue(i)}}async validateValue(e){let t=this.extractWikilinks(e);for(let r of t)await this.validateWikilink(r.uuid,r.label)}extractWikilinks(e){let t=[],r=/\[\[([^\]|]+)(?:\|([^\]]*))?\]\]/g,i;for(;(i=r.exec(e))!==null;)t.push({uuid:i[1].trim(),label:i[2]?.trim()});return t}async validateWikilink(e,t){if(!this.looksLikeUUID(e)||await this.fsAdapter.findFileByUidFilename(e))return;if(!await this.fsAdapter.findFileByUID(e))throw new Bx(e,t)}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}};var yf=class n{constructor(e){this.vaultPath=e;this.cache=null}static{a(this,"PropertyNameValidator")}static{this.KEY_SHAPE=/^([A-Za-z][A-Za-z0-9]*)__.+$/}static{this.PROPERTY_METACLASS_UIDS=["38277bfa-d7f9-4a75-b856-b23276ab0db3","9a1cf31c-9d41-4ef3-9023-584a8d087d16","ae56ca4c-b610-42a4-a25d-058c23673296"]}static{this.PROPERTY_METACLASS_LABELS=["exo__Property","exo__ObjectProperty","exo__DatatypeProperty"]}async validate(e){let{names:t,prefixes:r}=await this.collect();if(t.size!==0)for(let i of e){let s=n.KEY_SHAPE.exec(i);if(!s||t.has(i))continue;let o=s[1],c=r.has(o)?o:void 0,l=n.suggest(i,t,c);throw new eh(i,l)}}async collect(){if(this.cache)return this.cache;let{readdir:e,readFile:t}=await import("fs/promises"),r=
|
|
553
|
+
Available classes: ${t.join(", ")}`),super(r),this.name="ClassNotFoundError"}},tb=class{constructor(e){this.fsAdapter=e;this.cache=new Map}static{a(this,"ClassResolverService")}async resolve(e,t){if(this.isUUID(t))return t;let r=await this.getOrBuildIndex(e),i=r.get(t);if(!i){let s=Array.from(r.keys()).filter(o=>!this.isUUID(o));throw new Ux(t,s)}return i}async listClasses(e){let t=await this.getOrBuildIndex(e);return Array.from(t.keys())}async getOrBuildIndex(e){if(this.cache.has(e))return this.cache.get(e);let t=await this.buildIndex(e);return this.cache.set(e,t),t}async buildIndex(e){let t=new Map,r=await this.fsAdapter.getMarkdownFiles(),i=[],s=new Set;for(let o of r)try{let c=await this.fsAdapter.getFileMetadata(o),l=this.getBasename(o),u=c.exo__Asset_uid;!u&&this.isUUID(l)&&(u=l);let f=u?String(u):void 0,d=c.exo__Asset_label,p=typeof d=="string"?d:void 0,h=c.exo__Instance_class,_=h?(Array.isArray(h)?h:[h]).map(y=>String(y)):[];i.push({basename:l,uid:f,label:p,classValues:_}),f&&(p==="exo__Class"||p==="ims__Class")&&s.add(f)}catch{continue}for(let o of i)o.uid&&this.isClassDefinition(o.classValues,s)&&(o.basename&&t.set(o.basename,o.uid),o.label&&o.label!==o.basename&&t.set(o.label,o.uid));return t}isClassDefinition(e,t){return e.some(r=>{if(r.includes("ims__Class")||r.includes("exo__Class"))return!0;for(let i of t)if(i&&r.includes(i))return!0;return!1})}getBasename(e){let t=e.split("/");return t[t.length-1].replace(/\.md$/,"")}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}};var Bx=class extends Error{static{a(this,"WikilinkNotFoundError")}constructor(e,t){let r=t?`|${t}`:"";super(`Wikilink [[${e}${r}]] \u2014 file not found in vault`),this.name="WikilinkNotFoundError"}},gf=class{constructor(e){this.fsAdapter=e}static{a(this,"WikilinkValidator")}static{this.WIKILINK_PATTERN=/\[\[([^\]|]+)(?:\|[^\]]*)?]]/g}async validatePropertyValues(e){for(let[,t]of Object.entries(e)){let r=Array.isArray(t)?t:[t];for(let i of r)await this.validateValue(i)}}async validateValue(e){let t=this.extractWikilinks(e);for(let r of t)await this.validateWikilink(r.uuid,r.label)}extractWikilinks(e){let t=[],r=/\[\[([^\]|]+)(?:\|([^\]]*))?\]\]/g,i;for(;(i=r.exec(e))!==null;)t.push({uuid:i[1].trim(),label:i[2]?.trim()});return t}async validateWikilink(e,t){if(!this.looksLikeUUID(e)||await this.fsAdapter.findFileByUidFilename(e))return;if(!await this.fsAdapter.findFileByUID(e))throw new Bx(e,t)}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}};var yf=class n{constructor(e){this.vaultPath=e;this.cache=null}static{a(this,"PropertyNameValidator")}static{this.KEY_SHAPE=/^([A-Za-z][A-Za-z0-9]*)__.+$/}static{this.PROPERTY_METACLASS_UIDS=["38277bfa-d7f9-4a75-b856-b23276ab0db3","9a1cf31c-9d41-4ef3-9023-584a8d087d16","ae56ca4c-b610-42a4-a25d-058c23673296"]}static{this.PROPERTY_METACLASS_LABELS=["exo__Property","exo__ObjectProperty","exo__DatatypeProperty"]}static{this.CLASS_METACLASS_UID="8619c4fc-64f1-4869-b17e-e34186cacca9"}static{this.CLASS_METACLASS_LABEL="exo__Class"}async validate(e){let{names:t,prefixes:r}=await this.collect();if(t.size!==0)for(let i of e){let s=n.KEY_SHAPE.exec(i);if(!s||t.has(i))continue;let o=s[1],c=r.has(o)?o:void 0,l=n.suggest(i,t,c);throw new eh(i,l)}}async collect(){if(this.cache)return this.cache;let{readdir:e,readFile:t}=await import("fs/promises"),r=[],i=[],s=a(async u=>{let f;try{f=await e(u,{withFileTypes:!0})}catch{return}for(let d of f){let p=`${u}/${d.name}`;if(d.isDirectory())await s(p);else if(d.isFile()&&d.name.endsWith(".md")){let h;try{h=await t(p,"utf-8")}catch{continue}n.scan(h,r,i)}}},"walk");await s(this.vaultPath);let o=n.buildPropertyMetaclassClosure(r),c=new Set,l=new Set;for(let u of i){if(!u.classRefs.some(d=>o.has(d)))continue;c.add(u.name);let f=n.KEY_SHAPE.exec(u.name);f&&l.add(f[1])}return this.cache={names:c,prefixes:l},this.cache}static scan(e,t,r){let i=n.parseFrontmatter(e);if(!i)return;let s=n.asArray(i.exo__Instance_class).flatMap(c=>n.refHalves(c));if(s.length===0)return;let o=n.cleanLabel(i.exo__Asset_label);if(s.some(c=>n.isClassMetaclass(c))){let c=i.exo__Asset_uid,l=typeof c=="string"?c.trim():null,u=n.asArray(i.exo__Class_superClass).flatMap(f=>n.refHalves(f));t.push({uid:l,label:o,superRefs:u});return}o===null||!n.KEY_SHAPE.test(o)||r.push({classRefs:s,name:o})}static buildPropertyMetaclassClosure(e){let t=new Set([...n.PROPERTY_METACLASS_UIDS,...n.PROPERTY_METACLASS_LABELS]),r=!0;for(;r;){r=!1;for(let i of e)i.uid!==null&&t.has(i.uid)||i.label!==null&&t.has(i.label)||i.superRefs.some(o=>t.has(o))&&(i.uid!==null&&t.add(i.uid),i.label!==null&&t.add(i.label),r=!0)}return t}static isClassMetaclass(e){return e===n.CLASS_METACLASS_UID||e===n.CLASS_METACLASS_LABEL}static refHalves(e){let t=String(e).replace(/^["']|["']$/g,"").trim(),r=/\[\[([^\]]+)\]\]/.exec(t);return(r?r[1]:t).split("|").map(s=>s.trim()).filter(s=>s.length>0)}static cleanLabel(e){if(typeof e!="string")return null;let t=e.replace(/^["']|["']$/g,"").trim();return t.length>0?t:null}static asArray(e){return Array.isArray(e)?e.map(String):typeof e=="string"?[e]:[]}static parseFrontmatter(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!t)return null;let r={},i=t[1].split(/\r?\n/),s=null,o=null;for(let c of i){let l=/^ {2}- (.*)$/.exec(c);if(l){s&&o&&o.push(l[1].trim());continue}s&&o&&(r[s]=o,s=null,o=null);let u=/^([^:]+):\s*(.*)$/.exec(c);if(!u)continue;let f=u[1].trim(),d=u[2].trim();d===""?(s=f,o=[]):r[f]=d}return s&&o&&(r[s]=o),r}static suggest(e,t,r){let i=r?[...t].filter(o=>o.startsWith(`${r}__`)):[...t],s=Math.max(3,Math.floor(e.length*.4));return i.map(o=>({name:o,distance:n.levenshtein(e,o)})).filter(o=>o.distance<=s).sort((o,c)=>o.distance-c.distance||o.name.localeCompare(c.name)).slice(0,3).map(o=>o.name)}static levenshtein(e,t){let r=e.length,i=t.length;if(r===0)return i;if(i===0)return r;let s=Array.from({length:i+1},(c,l)=>l),o=new Array(i+1);for(let c=1;c<=r;c++){o[0]=c;for(let l=1;l<=i;l++){let u=e[c-1]===t[l-1]?0:1;o[l]=Math.min(s[l]+1,o[l-1]+1,s[l-1]+u)}[s,o]=[o,s]}return s[i]}};var Y5="ems__Effort",kle="ems__EffortStatus",rb=class{constructor(e){this.fsAdapter=e;this.statusUidCache=new Map}static{a(this,"EffortStatusResolver")}async isStatusBearing(e){let t=new Set,r=[e];for(;r.length>0;){let i=r.shift();if(i===void 0)break;if(t.has(i))continue;if(t.add(i),i===Y5)return!0;let s=await this.resolveClassFile(i);if(!s)continue;let o;try{o=await this.fsAdapter.getFileMetadata(s)}catch{continue}if(o.exo__Asset_label===Y5)return!0;let c=o.exo__Class_superClass,l=Array.isArray(c)?c:c!=null?[c]:[];for(let u of l){let f=jle(String(u));f&&!t.has(f)&&r.push(f)}}return!1}async resolveStatusUid(e){let t=Mle(e),r=this.statusUidCache.get(t);if(r!==void 0)return r;let i=null,s=await this.fsAdapter.findFilesByMetadata({exo__Asset_label:t});for(let o of s)try{let c=await this.fsAdapter.getFileMetadata(o);if(c.exo__Asset_uid){i=String(c.exo__Asset_uid);break}}catch{continue}return this.statusUidCache.set(t,i),i}async resolveClassFile(e){if($le(e))return this.fsAdapter.findFileByUidFilename(e);let t=await this.fsAdapter.findFilesByMetadata({exo__Asset_label:e});return t.length>0?t[0]:null}};function Mle(n){let e=n.trim();if(e.startsWith("ems__"))return e;let t=e.charAt(0).toUpperCase()+e.slice(1);return`${kle}${t}`}a(Mle,"toStatusEnumLabel");function jle(n){return n.trim().replace(/^["']|["']$/g,"").replace(/^\[\[|\]\]$/g,"").split("|")[0].trim()||null}a(jle,"extractRef");function $le(n){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)}a($le,"isUuid");var _f=require("fs"),Vx=require("path"),X5=Se(it());function nb(n){(0,X5.registerOrderSpecLoader)(()=>{let e=Ule(n);for(let t of e){let r=Ble(t);if(r)return r}return null})}a(nb,"registerOrderSpecFromVault");function Ule(n){return[(0,Vx.join)(n,"assetspaces","exo")]}a(Ule,"collectCandidateDirs");function Ble(n){if(!(0,_f.existsSync)(n))return null;let e;try{e=(0,_f.readdirSync)(n)}catch{return null}for(let t of e){if(!t.endsWith(".md"))continue;let r=(0,Vx.join)(n,t),i;try{i=(0,_f.readFileSync)(r,"utf-8")}catch{continue}let s=Vle(i);if(s&&/^exo__FrontmatterOrderSpec_default:\s*true\b/m.test(s))return{head:Q5(s,"exo__FrontmatterOrderSpec_head"),tail:Q5(s,"exo__FrontmatterOrderSpec_tail"),middleStrategy:qle(s,"exo__FrontmatterOrderSpec_middleStrategy")??"alphabetical"}}return null}a(Ble,"scanDirForDefault");function Vle(n){let e=n.match(/^---\n([\s\S]*?)\n---/);return e?e[1]:null}a(Vle,"extractFrontmatter");function qle(n,e){let t=new RegExp(`^${J5(e)}:\\s*(.+)$`,"m"),r=n.match(t);return r?r[1].trim():null}a(qle,"extractScalar");function Q5(n,e){let t=new RegExp(`^${J5(e)}:\\s*\\n((?: -.*\\n?)+)`,"m"),r=n.match(t);return r?r[1].split(`
|
|
554
554
|
`).map(i=>i.trim()).filter(i=>i.startsWith("- ")).map(i=>i.slice(2).trim()):[]}a(Q5,"extractList");function J5(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(J5,"escapeRegex");var bf=Se(require("path")),Gx=Se(it());async function Sf(n,e,t){let r=e.endsWith(".md")?e:`${e}.md`;if(e.includes("/")&&await n.fileExists(r))return r;let i=bf.default.dirname(t),s=i!=="."?`${i}/${r}`:r;if(await n.fileExists(s))return s;let c=await n.findFileByUID(e);return c||(await n.getMarkdownFiles()).find(f=>{let d=bf.default.basename(f,".md"),p=bf.default.basename(r,".md");return d===p})||null}a(Sf,"findReferencedFile");function Wx(n){return n.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"")}a(Wx,"normalizePath");async function ib(n,e){let t=(0,Gx.extractAssetReference)(e);if(!t||t.startsWith("!"))return null;let r=await Sf(n,t,"");if(!r)return null;let i=bf.default.dirname(r);return i==="."?"":i}a(ib,"resolveCoLocationFolder");function qx(n){let e=n;for(;Array.isArray(e);){if(e.length===0)return null;e=e[0]}return(0,Gx.extractAssetReference)(e)}a(qx,"wikilinkTarget");async function Z5(n,e,t,r){let i=new Set;if(e&&i.add(e),t&&i.add(t),i.size===0)return null;let s=qx(r),o=await n.getMarkdownFiles(),c=new Map;for(let d of o){let p;try{p=await n.getFileMetadata(d)}catch{continue}if(qx(p.exo__Asset_isDefinedBy)!==s)continue;let h=p.exo__Instance_class;if(!(Array.isArray(h)?h:[h]).some(T=>{let O=qx(T);return O!==null&&i.has(O)}))continue;let S=bf.default.dirname(d),w=S==="."?"":S;c.set(w,(c.get(w)??0)+1)}if(c.size===0)return null;let l=null,u=-1,f=Array.from(c.entries()).sort((d,p)=>d[0]<p[0]?-1:d[0]>p[0]?1:0);for(let[d,p]of f)p>u&&(l=d,u=p);return l}a(Z5,"resolveNeighbourFolderByClass");var e$="01 Inbox",Gle="Asia/Almaty",Wle="4ef3962d-b8a7-42b5-bd28-88ec846f1d13",t$="Backlog",sb="ems__Effort_status";function Hle(n){if(!n||n.length===0)return{};let e={};for(let t of n){let r=t.indexOf("=");if(r===-1)throw new Error(`Invalid property format: "${t}". Expected "key=value" format.`);let i=t.substring(0,r).trim(),s=t.substring(r+1).trim();if(!i)throw new Error(`Invalid property format: "${t}". Key cannot be empty.`);let o=e[i];o===void 0?e[i]=s:Array.isArray(o)?o.push(s):e[i]=[o,s]}return e}a(Hle,"parseProperties");async function zle(n){if(n.bodyFile){if(!(0,Hx.existsSync)(n.bodyFile))throw new Error(`Body file not found: ${n.bodyFile}`);return(0,n$.readFileSync)(n.bodyFile,"utf-8")}if(n.body==="-")return Kle(3e4);if(n.body)return n.body}a(zle,"resolveBody");function Kle(n){return new Promise((e,t)=>{let r=[],i=setTimeout(()=>{process.stdin.removeAllListeners(),process.stdin.destroy(),t(new Error(`Stdin read timed out after ${n}ms. Ensure you pipe content to stdin or close the pipe.`))},n);process.stdin.on("data",s=>{r.push(s)}),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(r).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)}),process.stdin.isTTY&&(clearTimeout(i),e("")),process.stdin.resume()})}a(Kle,"readStdin");function i$(){return new Le("create").description("Create a new vault asset with auto-generated UUID, timestamp, and frontmatter").requiredOption("--class <name>","Class short name (e.g. ztlk__PermanentNote) or UUID").requiredOption("--label <text>","Human-readable label for the asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--aliases <names...>","Additional aliases for the asset").option("--property <key=value...>","Property key-value pairs (repeatable; the SAME key passed more than once accumulates into a YAML array)",Yle,[]).option("--body <text>","Markdown body content (use '-' to read from stdin)").option("--body-file <path>","Read body content from file").option("--dry-run","Preview frontmatter without writing file").option("--created-by <uuid>","Creator UUID (defaults to ExoAssistant)").option("--status <name>","ems__Effort_status for status-bearing classes (default: Backlog; e.g. Draft, Doing, Done). Errors for non-status-bearing classes.").option("--yes","Accepted for symmetry with the apply subcommands (create is non-interactive; no-op)").option("--timezone <tz>","Timezone for timestamps (defaults to Asia/Almaty)").option("--skip-wikilink-validation","Skip wikilink existence validation").action(async n=>{try{let e=(0,r$.resolve)(n.vault);if(!(0,Hx.existsSync)(e))throw new Je(e);if(nb(e),!n.label||n.label.trim().length===0)throw new Error("Label cannot be empty");let t=n.label.trim(),r=Hle(n.property);await new yf(e).validate(Object.keys(r));let s=await zle(n);s&&(s=s.replace(/\\n/g,`
|
|
555
555
|
`));let o=new pi(e),c=new tb(o),l=new gf(o),u=await c.resolve(e,n.class),f=new rb(o),d=sb in r;if(n.status&&d)throw new Error(`Cannot pass both --status and --property ${sb}=... (ambiguous). Use one.`);if(!d){let B=await f.isStatusBearing(u);if(n.status){if(!B)throw new Error(`--status only applies to status-bearing classes (ems__Effort subclasses); '${n.class}' is not one.`);let M=await f.resolveStatusUid(n.status);if(!M)throw new Error(`Unknown status '${n.status}' \u2014 no matching ems__EffortStatus<Name> enum asset found in the vault.`);r[sb]=`[[${M}]]`}else if(B){let M=await f.resolveStatusUid(t$);M?r[sb]=`[[${M}]]`:process.stderr.write(`\u26A0 status-bearing class but no ${t$} status enum found in the vault \u2014 created without ems__Effort_status.
|
|
556
556
|
`)}}let p=Object.keys(r).length>0?r:void 0;p&&!n.skipWikilinkValidation&&await l.validatePropertyValues(p);let h=e$,_=p?.exo__Asset_isDefinedBy,y=Array.isArray(_)?_[0]:_;if(y){let B=await ib(o,y);B&&(h=B)}if(h===e$){let B=await Z5(o,u,n.class,y);B&&(h=B)}let S;try{S=await wf.ShapeLoader.loadFromVaultFS(e)}catch{S=new wf.ShapeRegistry}let w=new $t(e),T=new wf.GenericAssetCreationService(w),O={className:n.class,classRefForm:"uuid",classUid:u,label:t,aliases:n.aliases,folderPath:h,createdBy:n.createdBy||Wle,timezone:n.timezone||Gle,body:s,propertyValues:p,shapeRegistry:S},A,x;if(n.dryRun){let B=T.buildAsset(O);A=B.uid,x=B.path,process.stderr.write(`--- DRY RUN PREVIEW ---
|
|
@@ -643,7 +643,7 @@ Duplicate bindings (${n.duplicates.length}) \u2014 uid claimed by >1 test (warni
|
|
|
643
643
|
Skipped floor check for ${n.unknownPriority} requirement(s) with unparseable priority (fail-open).`),n.clean?e==="hard"&&!n.rampReady?console.error(`
|
|
644
644
|
FAIL (hard gate): ramp not ready \u2014 ${n.p0Orphans} P0 requirement(s) unbound`+(n.p0Total===0?" (no P0 requirements found)":"")+"."):console.log(`
|
|
645
645
|
OK: no hard findings (dangling tags + binding-class floor are clean).`):console.error(`
|
|
646
|
-
FAIL: ${n.dangling.length} dangling + ${n.floorViolations.length} floor violation(s) + ${n.activeViolations.length} active-requirement invariant violation(s) + ${n.danglingEvidence.length} dangling evidence link(s).`)}a(mde,"renderText");function gde(n,e,t){return!n.clean||t&&n.orphans.length>0||e==="hard"&&!n.rampReady}a(gde,"isHardFail");function y6(){return new Le("audit").description("Audit requirement\u2194test traceability: orphans, dangling @req tags, duplicate bindings, binding-class floor, coverage, P0 ramp-readiness").requiredOption("--reqs <path>","Directory tree containing req__Requirement assets (a vault or a reqs assetspace clone)").option("--tests <path>","Test-corpus root scanned for @req:<uid> tags",".").option("--output <type>","Response format: text|json","text").option("--strict","Also exit 1 on orphan requirements",!1).option("--gate <mode>","Gate mode: soft (warn only on hard findings) | hard (also block when the P0 checklist is not ramp-ready)","soft").action(async n=>{let e=n.output??"text";Ee.setFormat(e);let t=n.gate==="hard"?"hard":"soft";try{let r=(0,nc.resolve)(n.reqs);if(!(0,ic.existsSync)(r)||!(0,ic.statSync)(r).isDirectory())throw new Je(r);let i=(0,nc.resolve)(n.tests??".");if(!(0,ic.existsSync)(i)||!(0,ic.statSync)(i).isDirectory())throw new Je(i);let[s,o]=await Promise.all([ude(r),dde(i)]),c=pde(s,o);e==="json"?console.log(JSON.stringify({...c,gate:t},null,2)):mde(c,t),gde(c,t,n.strict===!0)&&(process.exitCode=1)}catch(r){Ee.handle(r)}})}a(y6,"requirementsAuditCommand");function _6(){let n=new Le("requirements").description("Requirements-management tooling (RFC 0003): traceability checker");return n.addCommand(y6()),n}a(_6,"requirementsCommand");function Ib(n){let e=new Le;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(n??"16.191.
|
|
646
|
+
FAIL: ${n.dangling.length} dangling + ${n.floorViolations.length} floor violation(s) + ${n.activeViolations.length} active-requirement invariant violation(s) + ${n.danglingEvidence.length} dangling evidence link(s).`)}a(mde,"renderText");function gde(n,e,t){return!n.clean||t&&n.orphans.length>0||e==="hard"&&!n.rampReady}a(gde,"isHardFail");function y6(){return new Le("audit").description("Audit requirement\u2194test traceability: orphans, dangling @req tags, duplicate bindings, binding-class floor, coverage, P0 ramp-readiness").requiredOption("--reqs <path>","Directory tree containing req__Requirement assets (a vault or a reqs assetspace clone)").option("--tests <path>","Test-corpus root scanned for @req:<uid> tags",".").option("--output <type>","Response format: text|json","text").option("--strict","Also exit 1 on orphan requirements",!1).option("--gate <mode>","Gate mode: soft (warn only on hard findings) | hard (also block when the P0 checklist is not ramp-ready)","soft").action(async n=>{let e=n.output??"text";Ee.setFormat(e);let t=n.gate==="hard"?"hard":"soft";try{let r=(0,nc.resolve)(n.reqs);if(!(0,ic.existsSync)(r)||!(0,ic.statSync)(r).isDirectory())throw new Je(r);let i=(0,nc.resolve)(n.tests??".");if(!(0,ic.existsSync)(i)||!(0,ic.statSync)(i).isDirectory())throw new Je(i);let[s,o]=await Promise.all([ude(r),dde(i)]),c=pde(s,o);e==="json"?console.log(JSON.stringify({...c,gate:t},null,2)):mde(c,t),gde(c,t,n.strict===!0)&&(process.exitCode=1)}catch(r){Ee.handle(r)}})}a(y6,"requirementsAuditCommand");function _6(){let n=new Le("requirements").description("Requirements-management tooling (RFC 0003): traceability checker");return n.addCommand(y6()),n}a(_6,"requirementsCommand");function Ib(n){let e=new Le;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(n??"16.191.1"),e.addCommand(f$()),e.addCommand(S$()),e.addCommand(p5()),e.addCommand(y5()),e.addCommand(k5()),e.addCommand(_5()),e.addCommand(T5()),e.addCommand(q5()),e.addCommand(K5()),e.addCommand(i$()),e.addCommand(a$()),e.addCommand(c$()),e.addCommand(j$()),e.addCommand(B$()),e.addCommand(n6()),e.addCommand(s6()),e.addCommand(c6()),e.addCommand(l6()),e.addCommand(p6()),e.addCommand(K$()),e.addCommand(e6()),e.addCommand(_6()),e}a(Ib,"createProgram");Ib().parse();0&&(module.exports={createProgram});
|
|
647
647
|
/*! Bundled license information:
|
|
648
648
|
|
|
649
649
|
reflect-metadata/Reflect.js:
|
package/package.json
CHANGED