@kitelev/exocortex-cli 16.92.0 → 16.92.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.92.
|
|
2
|
+
// @kitelev/exocortex-cli v16.92.1
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
@@ -765,7 +765,7 @@ Next steps:
|
|
|
765
765
|
`),process.stdout.write(` URL: ${n.url}
|
|
766
766
|
`),process.stdout.write(` SHA: ${c.sha} (${c.fileCount} files)
|
|
767
767
|
`),process.stdout.write(` .gitmodules: ${l.added?"entry added":"entry already present"}
|
|
768
|
-
`)),process.exit(0)}catch(e){ge.handle(e)}})}a(g4,"assetSpaceAddCommand");var _4=require("node:path"),b4=require("node:fs");var J0=Z(xo()),_A=Z(require("path"));var e_=Z(nt());var Z0=class{static{a(this,"RegistryDependencyResolver")}constructor(e={}){this.warn=e.warn??(()=>{})}async resolve(e,t){let r=await this.scanRegistry(e),i=this.matchSelf(r,t);if(i===null)return{outcome:"self-not-found",selfIdentifier:t,descriptorCount:r.size};let s=new Map;for(let g of r.values())g.dependsOn.length>0&&s.set(g.uid,g.dependsOn);let o=(0,e_.transitiveDependsOnClosure)([i.uid],s);o.delete(i.uid);let c=[],l=new Set,u=new Set([i.uid]),f=[...i.dependsOn];for(;f.length>0;){let g=f.shift();if(g===void 0||u.has(g))continue;u.add(g),o.has(g)&&!l.has(g)&&(c.push(g),l.add(g));let E=r.get(g);if(E!==void 0)for(let b of E.dependsOn)u.has(b)||f.push(b)}for(let g of o)l.has(g)||(c.push(g),l.add(g));let d=[],h=[];for(let g of c){let E=r.get(g);E===void 0?h.push(g):d.push(E)}let p=d.filter(g=>g.source===null||g.source.length===0),y=d.filter(g=>g.source!==null&&g.source.length>0&&!Die(g.source));return{outcome:"resolved",self:i,dependencies:d,missingDescriptors:h,sourceless:p,unsafeSources:y}}matchSelf(e,t){let r=y4(t);if(r!==null)for(let i of e.values()){if(i.source===null)continue;let s=y4(i.source);if(s!==null&&s===r)return i}for(let i of e.values())if(i.namespace!==null&&i.namespace===t)return i;return null}async scanRegistry(e){let t=new Map,r=_A.default.resolve(e);if(!await J0.default.pathExists(r))return this.warn(`[RegistryDependencyResolver] registry path does not exist: ${r}`),t;let i=[r];for(;i.length>0;){let s=i.pop(),o;try{o=await J0.default.readdir(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=_A.default.join(s,c.name);if(c.isDirectory()){if(c.name.startsWith(".")||c.name==="node_modules"||c.name===".obsidian"||c.name===".exocortex")continue;i.push(l);continue}if(!c.isFile()||!c.name.endsWith(".md"))continue;let u=await this.tryReadFrontmatter(l);if(u===null||!Lo(u.exo__Instance_class).some(g=>g===hh))continue;let d=u.exo__Asset_uid;if(typeof d!="string"||d.length===0)continue;let h=typeof u.exo__AssetSpace_source=="string"?u.exo__AssetSpace_source:typeof u.exo__AssetSpace_git=="string"?u.exo__AssetSpace_git:null,p=typeof u.exo__AssetSpace_namespace=="string"?u.exo__AssetSpace_namespace:null,y=Lo(u.exo__AssetSpace_dependsOn);t.has(d)&&this.warn(`[RegistryDependencyResolver] duplicate AssetSpace descriptor for uid=${d} \u2014 last wins (${l})`),t.set(d,{uid:d,namespace:p,source:h,dependsOn:y})}}return t}async tryReadFrontmatter(e){let t;try{t=await J0.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let r=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(r===null)return null;try{let i=_r.load(r[1]);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function y4(n){let e=n.trim();if(e.length===0)return null;let t=(0,e_.derivePath)(e);if(t!==null)return t.replace(/^assetspaces\//,"").toLowerCase();if(!e.includes("://")&&!e.includes("@")){let i=e.replace(/\.git$/i,"").replace(/\/+$/,"").split("/").filter(s=>s.length>0);if(i.length===2)return`${i[0]}/${i[1]}`.toLowerCase()}return null}a(y4,"ownerRepoSlug");function Die(n){return typeof n!="string"||n.length===0||/[\s\x00-\x1f]/.test(n)||n.startsWith("-")||/^(ext|file|fd|ftp|ftps)::/i.test(n)?!1:!!(/^https?:\/\/[^\s]+$/i.test(n)||/^ssh:\/\/[^\s]+$/i.test(n)||/^git:\/\/[^\s]+$/i.test(n)||/^[A-Za-z0-9._-]+@[A-Za-z0-9._
|
|
768
|
+
`)),process.exit(0)}catch(e){ge.handle(e)}})}a(g4,"assetSpaceAddCommand");var _4=require("node:path"),b4=require("node:fs");var J0=Z(xo()),_A=Z(require("path"));var e_=Z(nt());var Z0=class{static{a(this,"RegistryDependencyResolver")}constructor(e={}){this.warn=e.warn??(()=>{})}async resolve(e,t){let r=await this.scanRegistry(e),i=this.matchSelf(r,t);if(i===null)return{outcome:"self-not-found",selfIdentifier:t,descriptorCount:r.size};let s=new Map;for(let g of r.values())g.dependsOn.length>0&&s.set(g.uid,g.dependsOn);let o=(0,e_.transitiveDependsOnClosure)([i.uid],s);o.delete(i.uid);let c=[],l=new Set,u=new Set([i.uid]),f=[...i.dependsOn];for(;f.length>0;){let g=f.shift();if(g===void 0||u.has(g))continue;u.add(g),o.has(g)&&!l.has(g)&&(c.push(g),l.add(g));let E=r.get(g);if(E!==void 0)for(let b of E.dependsOn)u.has(b)||f.push(b)}for(let g of o)l.has(g)||(c.push(g),l.add(g));let d=[],h=[];for(let g of c){let E=r.get(g);E===void 0?h.push(g):d.push(E)}let p=d.filter(g=>g.source===null||g.source.length===0),y=d.filter(g=>g.source!==null&&g.source.length>0&&!Die(g.source));return{outcome:"resolved",self:i,dependencies:d,missingDescriptors:h,sourceless:p,unsafeSources:y}}matchSelf(e,t){let r=y4(t);if(r!==null)for(let i of e.values()){if(i.source===null)continue;let s=y4(i.source);if(s!==null&&s===r)return i}for(let i of e.values())if(i.namespace!==null&&i.namespace===t)return i;return null}async scanRegistry(e){let t=new Map,r=_A.default.resolve(e);if(!await J0.default.pathExists(r))return this.warn(`[RegistryDependencyResolver] registry path does not exist: ${r}`),t;let i=[r];for(;i.length>0;){let s=i.pop(),o;try{o=await J0.default.readdir(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=_A.default.join(s,c.name);if(c.isDirectory()){if(c.name.startsWith(".")||c.name==="node_modules"||c.name===".obsidian"||c.name===".exocortex")continue;i.push(l);continue}if(!c.isFile()||!c.name.endsWith(".md"))continue;let u=await this.tryReadFrontmatter(l);if(u===null||!Lo(u.exo__Instance_class).some(g=>g===hh))continue;let d=u.exo__Asset_uid;if(typeof d!="string"||d.length===0)continue;let h=typeof u.exo__AssetSpace_source=="string"?u.exo__AssetSpace_source:typeof u.exo__AssetSpace_git=="string"?u.exo__AssetSpace_git:null,p=typeof u.exo__AssetSpace_namespace=="string"?u.exo__AssetSpace_namespace:null,y=Lo(u.exo__AssetSpace_dependsOn);t.has(d)&&this.warn(`[RegistryDependencyResolver] duplicate AssetSpace descriptor for uid=${d} \u2014 last wins (${l})`),t.set(d,{uid:d,namespace:p,source:h,dependsOn:y})}}return t}async tryReadFrontmatter(e){let t;try{t=await J0.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let r=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(r===null)return null;try{let i=_r.load(r[1]);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function y4(n){let e=n.trim();if(e.length===0)return null;let t=(0,e_.derivePath)(e);if(t!==null)return t.replace(/^assetspaces\//,"").toLowerCase();if(!e.includes("://")&&!e.includes("@")){let i=e.replace(/\.git$/i,"").replace(/\/+$/,"").split("/").filter(s=>s.length>0);if(i.length===2)return`${i[0]}/${i[1]}`.toLowerCase()}return null}a(y4,"ownerRepoSlug");function Die(n){return typeof n!="string"||n.length===0||/[\s\x00-\x1f]/.test(n)||n.startsWith("-")||/^(ext|file|fd|ftp|ftps)::/i.test(n)?!1:!!(/^https?:\/\/[^\s]+$/i.test(n)||/^ssh:\/\/[^\s]+$/i.test(n)||/^git:\/\/[^\s]+$/i.test(n)||/^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+:[^\s]+$/.test(n))}a(Die,"isSafeCloneUrl");async function Fie(n,e={}){let t=e.out??(l=>process.stdout.write(`${l}
|
|
769
769
|
`)),r=e.err??(l=>process.stderr.write(`${l}
|
|
770
770
|
`));if(!n.registry)throw new ke("--registry <path> is required");if(!n.self)throw new ke("--self <owner/repo | git-url | namespace> is required");let i=(0,_4.resolve)(n.registry);if(!(0,b4.existsSync)(i))throw new ke(`Registry path does not exist: ${i}`,"Clone kitelev/exoas-registry first, then pass --registry <path>");let o=await new Z0({warn:a(l=>r(l),"warn")}).resolve(i,n.self),c=n.format??"urls";if(o.outcome==="self-not-found"){let l=`[resolve-deps] self '${n.self}' not found among ${o.descriptorCount} registry descriptor(s) \u2014 validating standalone (no dependencies to materialise).`;return n.strict?(r(`[resolve-deps] STRICT: self '${n.self}' not registered. Add an exo__AssetSpace descriptor to kitelev/exoas-registry.`),c==="json"&&t(JSON.stringify(o,null,2)),{exitCode:2,outcome:o}):(r(l),c==="json"&&t(JSON.stringify(o,null,2)),{exitCode:0,outcome:o})}if(o.missingDescriptors.length>0&&r(`[resolve-deps] \u26A0\uFE0F ${o.missingDescriptors.length} dangling dependsOn edge(s) (no descriptor in registry): `+o.missingDescriptors.join(", ")),o.sourceless.length>0&&r(`[resolve-deps] \u26A0\uFE0F ${o.sourceless.length} dependency descriptor(s) have no source URL (cannot clone): `+o.sourceless.map(l=>l.namespace??l.uid).join(", ")),o.unsafeSources.length>0&&r(`[resolve-deps] \u26A0\uFE0F ${o.unsafeSources.length} dependency source(s) rejected as unsafe git-clone targets (option/transport injection) \u2014 NOT emitted: `+o.unsafeSources.map(l=>`${l.namespace??l.uid}=${l.source}`).join(", ")),c==="json")t(JSON.stringify(o,null,2));else{let l=new Set(o.unsafeSources.map(u=>u.uid));for(let u of o.dependencies)u.source&&u.source.length>0&&!l.has(u.uid)&&t(u.source)}return{exitCode:0,outcome:o}}a(Fie,"runResolveDeps");function S4(){return new Re("resolve-deps").description("Resolve an AssetSpace repo's transitive dependsOn closure from the central registry and print dependency clone URLs (issue #3513). Used by the per-AssetSpace SHACL CI gate to materialise dependent TBox.").requiredOption("--registry <path>","Path to a checked-out central registry (kitelev/exoas-registry)").requiredOption("--self <id>","Identity of the calling repo: an owner/repo slug (e.g. kitelev/exoas-exo, matches GitHub's github.repository), a full git URL, or a bare namespace").option("--format <type>","Output format: urls (one clone URL per line) | json (full diagnostics)","urls").option("--strict","Exit non-zero (2) when self is not registered, instead of validating standalone",!1).action(async n=>{try{let{exitCode:e}=await Fie(n);process.exit(e)}catch(e){ge.handle(e)}})}a(S4,"resolveDepsCommand");var v4=require("node:fs"),T4=require("node:path");var w4=require("node:child_process"),E4=Z(nt());var Lie=6e4,No=class n{static{a(this,"RestPushService")}static{this.PAT_REGEX=/(?:gh[pousr]_[A-Za-z0-9_]{36,}|github_pat_[A-Za-z0-9_]{22,}_[A-Za-z0-9_]{59,})/g}constructor(e={}){this.fetchImpl=e.fetchImpl??globalThis.fetch,this.token=e.token??"",this.apiBase=(e.apiBase??"https://api.github.com").replace(/\/$/,"")}static resolveGhToken(e){let t=e??(()=>(0,w4.execFileSync)("gh",["auth","token"],{encoding:"utf8",timeout:15e3})),r;try{r=t()}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`RestPushService: \`gh auth token\` failed \u2014 is GitHub CLI installed and authenticated? (run \`gh auth login\`). Underlying: ${o}`.replace(n.PAT_REGEX,"***REDACTED***"))}let i=r.trim();if(i.length===0)throw new Error("RestPushService: `gh auth token` returned empty output \u2014 not authenticated. Run `gh auth login`.");return i}redact(e){return(typeof e=="string"?e:String(e)).replace(n.PAT_REGEX,"***REDACTED***")}async push(e,t,r,i,s){return(0,E4.restCreateCommit)(this.buildTransport(),{owner:e,repo:t,branch:r,files:i,message:s,baseURL:this.apiBase,redact:a(o=>this.redact(o),"redact")})}transport(){return this.buildTransport()}buildTransport(){let e=this.token,t=this.fetchImpl,r=a(i=>this.redact(i),"redact");return async i=>{let s={Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"exocortex-cli"};e.length>0&&(s.Authorization=`Bearer ${e}`),i.contentType&&(s["Content-Type"]=i.contentType);let o;try{o=await t(i.url,{method:i.method,headers:s,body:i.body,signal:AbortSignal.timeout(Lie)})}catch(u){throw new Error(r(`GitHub request failed: ${Nie(u)}`))}let c=await o.text().catch(()=>"");if(o.status<200||o.status>=300)throw new Error(kie(r(`GitHub request ${i.method} ${i.url} \u2192 HTTP ${o.status}: ${c}`),512));let l;try{l=c.length>0?JSON.parse(c):void 0}catch{l=void 0}return{status:o.status,json:l,text:c}}}};function Nie(n){if(n instanceof Error)return n.message;if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}a(Nie,"errMsg");function kie(n,e){return n.length>e?n.slice(0,e)+"...":n}a(kie,"truncate");function A4(){let n=new Re("experimental").description("Opt-in experimental features (gated by EXOCORTEX_EXPERIMENTAL_REST_PUSH=1 or --experimental). Unstable \u2014 may change or be removed.");return n.addCommand(Uie()),n}a(A4,"experimentalCommand");function Mie(n,e=process.env){return n.experimental===!0||e.EXOCORTEX_EXPERIMENTAL_REST_PUSH==="1"}a(Mie,"experimentalEnabled");function jie(n){if(typeof n!="string"||n.length===0)throw new ke("--repo is required (owner/repo)");let e=n.split("/");if(e.length!==2||e[0].length===0||e[1].length===0)throw new ke(`--repo must be exactly <owner>/<repo>, got: ${n}`);let[t,r]=e;if(/[^a-zA-Z0-9_-]/.test(t)||/[^a-zA-Z0-9_.-]/.test(r))throw new ke(`--repo has invalid characters in owner/repo: ${n}`);if(t===".."||r===".."||r.startsWith(".")||r.startsWith("-")||t.startsWith("-"))throw new ke(`--repo has path-traversal/flag pattern: ${n}`);return{owner:t,repo:r}}a(jie,"parseRepoSlug");async function $ie(n,e={}){let t=e.env??process.env,r=e.readFileImpl??(p=>(0,v4.readFileSync)((0,T4.resolve)(p),"utf8")),i=e.serviceFactory??(p=>new No(p));if(!Mie(n,t))throw new ke("rest-push is experimental and opt-in. Enable with EXOCORTEX_EXPERIMENTAL_REST_PUSH=1 or pass --experimental.");let{owner:s,repo:o}=jie(n.repo),c=n.branch||"main";if(typeof n.message!="string"||n.message.length===0)throw new ke("--message is required");if(typeof n.file!="string"||n.file.length===0)throw new ke("--file is required");if(n.content!==void 0&&n.contentFile!==void 0)throw new ke("Pass exactly one of --content or --content-file, not both");let l;if(n.content!==void 0)l=n.content;else if(n.contentFile!==void 0)l=r(n.contentFile);else throw new ke("Provide file content via --content <text> or --content-file <localPath>");let u;if(n.tokenFromGh?u=No.resolveGhToken(e.ghTokenRunner):u=n.token||t.GITHUB_TOKEN||t.GH_TOKEN||void 0,!u)throw new ke("A GitHub token is required to push. Use --token-from-gh, --token <pat>, or set GITHUB_TOKEN / GH_TOKEN.");let f=i({token:u,apiBase:n.apiBase}),d=new Map([[n.file,l]]),h=await f.push(s,o,c,d,n.message);return{ok:!0,repo:`${s}/${o}`,branch:c,file:n.file,sha:h,url:`https://github.com/${s}/${o}/commit/${h}`,transport:"fetch",method:"git-data-api"}}a($ie,"runRestPush");function Uie(){return new Re("rest-push").description("EXPERIMENTAL: commit+push a file to a GitHub repo via pure REST Git Data API (no git binary). Gated behind EXOCORTEX_EXPERIMENTAL_REST_PUSH=1 or --experimental.").requiredOption("--repo <owner/repo>","Target repo as owner/repo").option("--branch <branch>","Branch to commit on","main").requiredOption("--file <repoPath>","Path WITHIN the repo to write").option("--content <text>","Inline file content").option("--content-file <localPath>","Read file content from a local path").requiredOption("--message <msg>","Commit message").option("--token-from-gh","Resolve PAT via `gh auth token` (GitHub CLI must be authenticated)",!1).option("--token <pat>","GitHub PAT (or env GITHUB_TOKEN / GH_TOKEN). Prefer --token-from-gh.").option("--experimental","Opt into experimental command (alternative to EXOCORTEX_EXPERIMENTAL_REST_PUSH=1)",!1).option("--api-base <url>","GitHub API base URL","https://api.github.com").option("--json","Emit result as JSON",!1).action(async n=>{try{n.json&&ge.setFormat("json"),process.stderr.write(`[rest-push] Committing ${n.file} \u2192 ${n.repo}@${n.branch} via REST (no git binary)...
|
|
771
771
|
`);let e=await $ie(n);n.json?process.stdout.write(JSON.stringify(e,null,2)+`
|
|
@@ -775,7 +775,7 @@ Next steps:
|
|
|
775
775
|
`),process.stdout.write(` File: ${e.file}
|
|
776
776
|
`),process.stdout.write(` Commit: ${e.sha}
|
|
777
777
|
`),process.stdout.write(` URL: ${e.url}
|
|
778
|
-
`)),process.exit(0)}catch(e){let t=e instanceof Error?e:new Error(String(e)),r=new No;t.message=r.redact(t.message),t.stack&&(t.stack=r.redact(t.stack)),ge.handle(t)}})}a(Uie,"restPushCommand");var ko=require("node:fs"),I4=require("node:crypto"),Si=Z(require("node:path"));var wi=Z(nt());var Bie=a(async n=>{let e=await I4.webcrypto.subtle.digest("SHA-1",n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")},"nodeSha1"),Vie={parse:a(n=>_r.load(n,{schema:_r.CORE_SCHEMA}),"parse"),stringify:a(n=>_r.dump(n,{schema:_r.CORE_SCHEMA,lineWidth:-1}),"stringify")};function Gie(n,e){if(n.tokenFromGh===!0)return No.resolveGhToken(e.ghTokenRunner);let t=e.env??process.env,r=n.token||t.GITHUB_TOKEN||t.GH_TOKEN||"";if(r.length===0)throw new Error("A GitHub token is required (private sync units read as 404 without one). Use --token-from-gh, --token <pat>, or set GITHUB_TOKEN / GH_TOKEN.");return r}a(Gie,"resolveToken");function qie(n){let e=a(r=>Si.join(n,r),"abs"),t=a(async(r,i)=>{let s;try{s=await ko.promises.readdir(r,{withFileTypes:!0})}catch{return}for(let o of s){let c=Si.join(r,o.name);if(o.isDirectory()){if(o.name===".git")continue;await t(c,i)}else o.isFile()&&i.push(Si.relative(n,c).split(Si.sep).join("/"))}},"walk");return{async list(){let r=[];return(0,ko.existsSync)(n)&&await t(n,r),r},read:a(r=>ko.promises.readFile(e(r),"utf-8"),"read"),async readBinary(r){return new Uint8Array(await ko.promises.readFile(e(r)))},async write(){throw new Error("exosync-parity is read-only \u2014 write refused")},async delete(){throw new Error("exosync-parity is read-only \u2014 delete refused")}}}a(qie,"nodeLocalFilesPort");function Wie(n){let e=new ht(n),t=new wi.SpaceSpecAccumulator;for(let r of e.getAllFiles()){let i=e.getFrontmatter(r);if(!i)continue;let s=(0,wi.classifySpaceDeclaration)(i,r.path);if(s.kind==="not-space"||(s.warning!==void 0&&t.warnings.push(s.warning),s.kind==="skip"))continue;let o=t.offer(s.candidate);o!==null&&(0,ko.existsSync)(Si.join(n,o.localPath))&&t.commit(s.candidate)}return{specs:t.specs,warnings:t.warnings}}a(Wie,"collectVaultSpecs");function zie(n,e){for(let t of n.repos){let r=t.headSha!==void 0?` @${t.headSha.slice(0,7)}`:"";e(`${t.repoKey}${r}: ${t.status} \u2014 ${t.inParity}/${t.filesChecked} in parity, M2 diffs ${t.m2SemanticDiffs}, accounted ${t.accountedCount}, M1 violations ${t.m1Violations.length}${t.attachmentHashSetIdentical!==void 0?`, attachment hash-set ${t.attachmentHashSetIdentical?"identical":"DIFFERS"}`:""}`),t.detail!==void 0&&e(` ${t.detail}`);for(let i of t.warnings)e(` warn: ${i}`);for(let i of t.discrepancies)e(` ${i.cls}: ${i.path}${i.detail!==void 0?` (${i.detail})`:""}`);for(let i of t.m1Violations)e(` M1 VIOLATION: ${i.path} \u2014 ${i.detail}`)}e((0,wi.summarizeParityRound)(n))}a(zie,"printHumanReport");async function Hie(n,e={}){let t=e.out??(y=>console.log(y)),r=Si.resolve(n.vault);if(!(0,ko.existsSync)(r))throw new Error(`Vault path does not exist: ${r}`);let i=Gie(n,e),s=new No({token:i,...n.apiBase!==void 0?{apiBase:n.apiBase}:{}}),o=e.transportFactory?.(i,n.apiBase)??s.transport(),{specs:c,warnings:l}=Wie(r);for(let y of l)t(`warn: ${y}`);if(c.length===0)return t("Nothing to check \u2014 no materialized AssetSpaces with a GitHub source found in this vault."),2;let u=n.configDir??".obsidian",f=Si.join(r,u,"plugins","exocortex",wi.WATERMARK_STORE_FILENAME),d=new wi.FileWatermarkStore({read:a(async()=>{try{return await ko.promises.readFile(f,"utf-8")}catch{return null}},"read"),writeAtomic:a(async()=>{throw new Error("exosync-parity: watermark access is read-only by contract")},"writeAtomic")}),h=new wi.ParityValidator({transport:o,sha1:Bie,localFilesFor:a(y=>qie(Si.join(r,y.localPath)),"localFilesFor"),watermarks:{get:a(y=>d.get(y),"get")},yaml:Vie,redact:a(y=>s.redact(y),"redact"),...n.apiBase!==void 0?{baseURL:n.apiBase}:{}});t(`ExoSync parity check: ${c.length} repo(s), vault ${r}`);let p=await h.runRound(c,{trigger:"standalone"});return n.json===!0?t(JSON.stringify(p,null,2)):zie(p,t),p.vacuous?2:p.ok?0:1}a(Hie,"runExosyncParity");function x4(){return new Re("exosync-parity").description("ExoSync M1/M2 parity report: compare materialized sync units against their remote heads (read-only; RFC 4e4dc453 Phase E)").requiredOption("--vault <path>","Vault root path").option("--config-dir <name>","Obsidian config dir name (watermark location)",".obsidian").option("--json","Print the full round record as JSON").option("--token <pat>","GitHub PAT (or env GITHUB_TOKEN / GH_TOKEN). Prefer --token-from-gh.").option("--token-from-gh","Resolve the PAT via `gh auth token`").option("--api-base <url>","GitHub API base (testing)").action(async n=>{try{process.exitCode=await Hie(n)}catch(e){ge.handle(e,{command:"exosync-parity"}),process.exitCode=1}})}a(x4,"exosyncParityCommand");function R4(n){let e=new Re;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.92.
|
|
778
|
+
`)),process.exit(0)}catch(e){let t=e instanceof Error?e:new Error(String(e)),r=new No;t.message=r.redact(t.message),t.stack&&(t.stack=r.redact(t.stack)),ge.handle(t)}})}a(Uie,"restPushCommand");var ko=require("node:fs"),I4=require("node:crypto"),Si=Z(require("node:path"));var wi=Z(nt());var Bie=a(async n=>{let e=await I4.webcrypto.subtle.digest("SHA-1",n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")},"nodeSha1"),Vie={parse:a(n=>_r.load(n,{schema:_r.CORE_SCHEMA}),"parse"),stringify:a(n=>_r.dump(n,{schema:_r.CORE_SCHEMA,lineWidth:-1}),"stringify")};function Gie(n,e){if(n.tokenFromGh===!0)return No.resolveGhToken(e.ghTokenRunner);let t=e.env??process.env,r=n.token||t.GITHUB_TOKEN||t.GH_TOKEN||"";if(r.length===0)throw new Error("A GitHub token is required (private sync units read as 404 without one). Use --token-from-gh, --token <pat>, or set GITHUB_TOKEN / GH_TOKEN.");return r}a(Gie,"resolveToken");function qie(n){let e=a(r=>Si.join(n,r),"abs"),t=a(async(r,i)=>{let s;try{s=await ko.promises.readdir(r,{withFileTypes:!0})}catch{return}for(let o of s){let c=Si.join(r,o.name);if(o.isDirectory()){if(o.name===".git")continue;await t(c,i)}else o.isFile()&&i.push(Si.relative(n,c).split(Si.sep).join("/"))}},"walk");return{async list(){let r=[];return(0,ko.existsSync)(n)&&await t(n,r),r},read:a(r=>ko.promises.readFile(e(r),"utf-8"),"read"),async readBinary(r){return new Uint8Array(await ko.promises.readFile(e(r)))},async write(){throw new Error("exosync-parity is read-only \u2014 write refused")},async delete(){throw new Error("exosync-parity is read-only \u2014 delete refused")}}}a(qie,"nodeLocalFilesPort");function Wie(n){let e=new ht(n),t=new wi.SpaceSpecAccumulator;for(let r of e.getAllFiles()){let i=e.getFrontmatter(r);if(!i)continue;let s=(0,wi.classifySpaceDeclaration)(i,r.path);if(s.kind==="not-space"||(s.warning!==void 0&&t.warnings.push(s.warning),s.kind==="skip"))continue;let o=t.offer(s.candidate);o!==null&&(0,ko.existsSync)(Si.join(n,o.localPath))&&t.commit(s.candidate)}return{specs:t.specs,warnings:t.warnings}}a(Wie,"collectVaultSpecs");function zie(n,e){for(let t of n.repos){let r=t.headSha!==void 0?` @${t.headSha.slice(0,7)}`:"";e(`${t.repoKey}${r}: ${t.status} \u2014 ${t.inParity}/${t.filesChecked} in parity, M2 diffs ${t.m2SemanticDiffs}, accounted ${t.accountedCount}, M1 violations ${t.m1Violations.length}${t.attachmentHashSetIdentical!==void 0?`, attachment hash-set ${t.attachmentHashSetIdentical?"identical":"DIFFERS"}`:""}`),t.detail!==void 0&&e(` ${t.detail}`);for(let i of t.warnings)e(` warn: ${i}`);for(let i of t.discrepancies)e(` ${i.cls}: ${i.path}${i.detail!==void 0?` (${i.detail})`:""}`);for(let i of t.m1Violations)e(` M1 VIOLATION: ${i.path} \u2014 ${i.detail}`)}e((0,wi.summarizeParityRound)(n))}a(zie,"printHumanReport");async function Hie(n,e={}){let t=e.out??(y=>console.log(y)),r=Si.resolve(n.vault);if(!(0,ko.existsSync)(r))throw new Error(`Vault path does not exist: ${r}`);let i=Gie(n,e),s=new No({token:i,...n.apiBase!==void 0?{apiBase:n.apiBase}:{}}),o=e.transportFactory?.(i,n.apiBase)??s.transport(),{specs:c,warnings:l}=Wie(r);for(let y of l)t(`warn: ${y}`);if(c.length===0)return t("Nothing to check \u2014 no materialized AssetSpaces with a GitHub source found in this vault."),2;let u=n.configDir??".obsidian",f=Si.join(r,u,"plugins","exocortex",wi.WATERMARK_STORE_FILENAME),d=new wi.FileWatermarkStore({read:a(async()=>{try{return await ko.promises.readFile(f,"utf-8")}catch{return null}},"read"),writeAtomic:a(async()=>{throw new Error("exosync-parity: watermark access is read-only by contract")},"writeAtomic")}),h=new wi.ParityValidator({transport:o,sha1:Bie,localFilesFor:a(y=>qie(Si.join(r,y.localPath)),"localFilesFor"),watermarks:{get:a(y=>d.get(y),"get")},yaml:Vie,redact:a(y=>s.redact(y),"redact"),...n.apiBase!==void 0?{baseURL:n.apiBase}:{}});t(`ExoSync parity check: ${c.length} repo(s), vault ${r}`);let p=await h.runRound(c,{trigger:"standalone"});return n.json===!0?t(JSON.stringify(p,null,2)):zie(p,t),p.vacuous?2:p.ok?0:1}a(Hie,"runExosyncParity");function x4(){return new Re("exosync-parity").description("ExoSync M1/M2 parity report: compare materialized sync units against their remote heads (read-only; RFC 4e4dc453 Phase E)").requiredOption("--vault <path>","Vault root path").option("--config-dir <name>","Obsidian config dir name (watermark location)",".obsidian").option("--json","Print the full round record as JSON").option("--token <pat>","GitHub PAT (or env GITHUB_TOKEN / GH_TOKEN). Prefer --token-from-gh.").option("--token-from-gh","Resolve the PAT via `gh auth token`").option("--api-base <url>","GitHub API base (testing)").action(async n=>{try{process.exitCode=await Hie(n)}catch(e){ge.handle(e,{command:"exosync-parity"}),process.exitCode=1}})}a(x4,"exosyncParityCommand");function R4(n){let e=new Re;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.92.1"),e.addCommand(kM()),e.addCommand(zM()),e.addCommand(Rk()),e.addCommand(Ok()),e.addCommand(oM()),e.addCommand(Nk()),e.addCommand(kk()),e.addCommand(Bk()),e.addCommand(lM()),e.addCommand(_M()),e.addCommand(SM()),e.addCommand(AM()),e.addCommand(NM()),e.addCommand(a4()),e.addCommand(h4()),e.addCommand(p4()),e.addCommand(g4()),e.addCommand(S4()),e.addCommand(A4()),e.addCommand(x4()),e}a(R4,"createProgram");R4().parse();0&&(module.exports={createProgram});
|
|
779
779
|
/*! Bundled license information:
|
|
780
780
|
|
|
781
781
|
reflect-metadata/Reflect.js:
|