aegisone 1.0.60 → 1.0.61

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AEGISONE
2
2
 
3
- Product version: **1.0.60**
3
+ Product version: **1.0.61**
4
4
 
5
5
  One product, two faces: the terminal (`aegiscode`) and the window (`aegis-desktop`),
6
6
  reached through one command — `aegis` — and released as one version.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegisone",
3
3
  "productName": "AEGISONE",
4
- "version": "1.0.60",
4
+ "version": "1.0.61",
5
5
  "description": "AEGISONE — one product, two faces. `aegis` opens the window when there is nothing else to do and runs the terminal otherwise; `aegiscode` keeps behaving exactly as it always has.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",
package/src/doctor.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- "use strict";const path=require("node:path"),fs=require("node:fs"),crypto=require("node:crypto"),EXIT=Object.freeze({OK:0,WARN:1,BROKEN:2}),FACE_PACKAGES=Object.freeze([Object.freeze({dir:"cli",package:"aegiscode"}),Object.freeze({dir:"desktop",package:"aegis-desktop"})]),BUNDLE_FACES=Object.freeze([Object.freeze({face:"cli",root:"cli",staged:"one/vendor/cli"}),Object.freeze({face:"desktop",root:"desktop",staged:"one/vendor/desktop"})]);function oneDir(){return path.resolve(__dirname,"..")}function repoDir(){return path.resolve(__dirname,"..","..")}function layoutOf(e,t){const n=t=>{try{return Boolean(e.exists(t))}catch{return!1}};if(t){const e=!n(path.join(t,"one","package.json"));return{root:t,installed:e,facePrefix:e?["vendor"]:[]}}const r=repoDir(),o=!n(path.join(r,"one","package.json"));return{root:o?oneDir():r,installed:o,facePrefix:o?["vendor"]:[]}}function inLayout(e,t){if(!e.installed)return t;const n=t.split("/");if("one"===n[0]){const e=n.slice(1).join("/");return"src/selfhost.js"===e?"vendor/desktop/vendor/selfhost.js":("vendor/cli"===e||e.startsWith("vendor/"),e)}return"cli"===n[0]||"desktop"===n[0]?path.posix.join("vendor",t).split(path.sep).join("/"):path.posix.join("vendor","cli","vendor",t).split(path.sep).join("/")}function homeHint(e){const t=e||{};return t.AEGISCODE_HOME||t.AEGIS_HOME||null}function homeDir(e){const t=e||{};let n=!1;try{n=require("./host.js").hostSeams({}).win32}catch{}const r=n?t.USERPROFILE||t.HOME:t.HOME||t.USERPROFILE;if(r)return String(r);try{return String(require("node:os").homedir()||"")}catch{return""}}function defaultFs(){return{exists:e=>{try{return fs.existsSync(e)}catch{return!1}},readFile:e=>{try{return fs.readFileSync(e,"utf8")}catch(e){if(e&&("ENOENT"===e.code||"EISDIR"===e.code))return null;throw e}},hashFile:e=>crypto.createHash("sha256").update(fs.readFileSync(e)).digest("hex"),listFiles:(e,t)=>listFiles(e,void 0===t?e:t)}}function listFiles(e,t){const n=[],r=e=>{let o;try{o=fs.readdirSync(e,{withFileTypes:!0})}catch{return}for(const s of o){if("node_modules"===s.name||".git"===s.name)continue;const o=path.join(e,s.name);s.isDirectory()?r(o):n.push(path.relative(t,o).split(path.sep).join("/"))}};return r(e),n.sort()}function defaultElectronPaths(e,t){const n=t||{},r=homeHint(e)||path.join(homeDir(e),".aegiscode");return{electron:void 0!==n.electron?n.electron:null,desktopMain:void 0!==n.desktopMain?n.desktopMain:null,userData:void 0!==n.userData?n.userData:r,keychain:void 0!==n.keychain?n.keychain:path.join(r,"settings.json")}}function defaultRegistry(e){let t=null;const n=()=>{if(t)return t;const n=e&&e.layout?e.layout:{root:repoDir(),installed:!1},r=[path.join(n.root,"client","update.js"),path.join(n.root,"vendor","cli","vendor","client","update.js")];for(const e of r)try{t=require(e);break}catch{}return t};return{check(e){const t=n();return t&&"function"==typeof t.updateNotice?t.updateNotice(e||{}):{latest:null,behind:!1,reason:"unavailable"}},plan(e){const t=n();return t&&"function"==typeof t.updatePlan?t.updatePlan(e||{}):null}}}function clientModuleCandidates(e){return[path.join(e.root,"client"),path.join(e.root,"vendor","cli","vendor","client")]}function loadClientModule(e,t){const n=e&&e.layout?e.layout:{root:repoDir(),installed:!1};for(const e of clientModuleCandidates(n))try{return require(path.join(e,t))}catch{}return null}function defaultStorePath(e,t){try{const n=loadClientModule(t,"prefs.js");if(n&&"function"==typeof n.prefsFile)return n.prefsFile(e)}catch{}const n=homeHint(e)||path.join(homeDir(e),".aegiscode");return path.join(n,"preferences.json")}function defaultCredentials(e){let t=null,n=!1;return{resolve(r){if(n||(n=!0,t=loadClientModule(e,"credentials.js")),!t||"function"!=typeof t.resolveApiKey)return{key:"",source:"none",from:""};try{return t.resolveApiKey(r||{})}catch{return{key:"",source:"none",from:""}}}}}function vendorPairs(e){const{exists:t}=e,n=[];if((e.layout||{installed:!1,facePrefix:[]}).installed)return n;for(const{face:r,root:o,staged:s}of BUNDLE_FACES){const a=path.join(e.root,s),i=e.listFiles(a,a);for(const a of i){const i=[];if(a.startsWith("vendor/")){const e=a.slice(7);if(i.push(e),i.push(path.join(o,e)),"selfhost.js"===e&&i.push(path.join("one","src","selfhost.js")),"protocol.js"===e&&i.push(path.join("one","src","protocol.js")),"pty.js"===e&&i.push(path.join("one","src","iface","pty.js")),"desktop"===r){const t=path.basename(e);for(const e of["client","mcp","covenant","commands","skills","tools","hosts"])i.push(path.join(e,t));i.push(t)}}else i.push(path.join(o,a)),i.push(a);const l=i.find((n=>t(path.join(e.root,n))))||null;n.push({face:r,staged:path.join(s,a),source:l,candidates:i})}}return n}function layoutsInstalled(e){return Boolean(e&&e.installed)}function checkVendor(e,t){const n=t||vendorPairs(e),r=[],o=[];let s=0,a=0;const i=e.layout||{installed:!1,facePrefix:[]};if(layoutsInstalled(i)){for(const t of BUNDLE_FACES){const n=path.join(e.root,inLayout(i,t.staged));e.exists(n)&&(a+=e.listFiles(n,n).length)}return{staged:a,matched:0,mismatch:o,missingSource:r,stale:0===a,checked:0}}for(const t of n){if(!e.exists(path.join(e.root,t.staged)))continue;if(a+=1,!t.source){r.push(t.staged);continue}let n,i;try{n=e.hashFile(path.join(e.root,t.source)),i=e.hashFile(path.join(e.root,t.staged))}catch(e){o.push({staged:t.staged,source:t.source,error:String(e&&e.message||e)});continue}n===i?s+=1:o.push({staged:t.staged,source:t.source})}return{staged:a,matched:s,mismatch:o,missingSource:r,stale:n.length>0&&0===a,checked:n.length}}function readJson(e,t){const n=path.join(e.root,t);if(!e.exists(n))return{ok:!1,missing:!0,value:null,path:t};let r;try{r=e.readFile(n)}catch(e){return{ok:!1,unreadable:!0,value:null,path:t,error:String(e&&e.message||e)}}if(null==r)return{ok:!1,missing:!0,value:null,path:t};try{return{ok:!0,value:JSON.parse(r),path:t}}catch(e){return{ok:!1,unreadable:!0,value:null,path:t,error:String(e&&e.message||e)}}}function resolveSeams(e){const t=e||{},n=t.env||{},r=defaultFs(),o=t||{},s=o.exists||r.exists,a=t.layout||layoutOf({exists:s,root:t.root},t.root),i=t.root||a.root,l={root:i,layout:Object.assign({},a,{root:i}),platform:t.platform||"linux",env:n,exists:s,readFile:o.readFile||r.readFile,hashFile:o.hashFile||r.hashFile,listFiles:o.listFiles||r.listFiles,electronPaths:t.electronPaths||defaultElectronPaths(n,t),updateCache:t.updateCache,saveUpdateCache:t.saveUpdateCache,now:"number"==typeof t.now?t.now:0,guiRequested:Boolean(t.guiRequested),guiImplied:t.guiImplied,vendorPairs:t.vendorPairs};return l.credentials=t.credentials||defaultCredentials(l),l.storePath=t.storePath||defaultStorePath(n,l),l.registry=t.registry||defaultRegistry(l),l}function diagnose(e){const t=resolveSeams(e),n=[],r=(e,t)=>n.push({level:"broken",code:e,detail:t}),o=(e,t)=>n.push({level:"warn",code:e,detail:t}),s=t.layout,a=inLayout(s,"one/package.json"),i=readJson(t,a),l=i.ok?{name:i.value.name||"aegisone",version:String(i.value.version||"")}:{name:"aegisone",version:""};i.ok||r("product-unreadable",`${a} ${i.unreadable?"is unreadable":"is missing"}`);let c=null;try{c=require("./release.js").deriveFaceVersions(l.version)}catch(e){c=null,i.ok&&r("product-version-invalid",`${l.version}: ${String(e&&e.message||e)}`)}const u={};for(const{dir:e,package:n}of FACE_PACKAGES){const o=inLayout(s,`${e}/package.json`),a=readJson(t,o),i=a.ok?String(a.value.version||""):"",d=c&&c[n]?c[n].version:null;a.ok?d&&i!==d&&r("version-mismatch",`${n} is ${i}, product ${l.version} derives ${d}`):r("face-unreadable",`${o} ${a.unreadable?"is unreadable":"is missing"}`),u[n]={dir:e,version:i,expected:d,ok:Boolean(d&&i===d)}}let d={key:"",source:"none",from:""};try{d=t.credentials.resolve({env:t.env})||d}catch{d={key:"",source:"none",from:""}}const h=t.electronPaths||{};let p=d.key?"env"===d.source?"env":(d.source,"env-file"):"none";if(!d.key&&h.keychain&&t.exists(h.keychain)){const e=(()=>{try{return t.readFile(h.keychain)}catch{return null}})();e&&/encrypt|safeStorage/i.test(e)&&(p="keychain")}"none"===p&&o("no-credential","no credential found (env, credentials.json, or the OS keychain)");const f={path:t.storePath,exists:!1,readable:null,legacy:null};try{f.exists=t.exists(t.storePath)}catch{f.exists=!1}let g,v=f.path;if(f.exists){let e=null;try{e=t.readFile(f.path)}catch(e){f.readable=!1,r("store-unreadable",`${f.path}: ${String(e&&e.message||e)}`)}if(null===f.readable)if(null==e)f.readable=!1,r("store-unreadable",`${f.path} exists but could not be read`);else try{const t=JSON.parse(e);f.readable=!0,f.legacy=t&&t.version||null}catch(e){f.readable=!1,r("store-unreadable",`${f.path} is not valid JSON: ${String(e&&e.message||e)}`)}v=path.basename(f.path)}f.display=v;try{g=checkVendor(t,t.vendorPairs)}catch(e){g={staged:0,matched:0,mismatch:[],missingSource:[],stale:!1,checked:0,error:String(e&&e.message||e)},r("vendor-unreadable",g.error)}for(const e of g.mismatch)r("vendor-hash-mismatch",`${e.staged} differs from ${e.source||"its source"}`);for(const e of g.missingSource)r("vendor-source-missing",`${e} has no source to be re-derived from`);g.stale&&(s.installed?r("vendor-missing","the ONE bundle is empty — reinstall aegisone"):o("vendor-stale","the ONE bundle has never been staged (one/vendor is empty) — run `npm run predist`"));const m={channel:"npm",current:l.version,latest:null,behind:!1,reason:null,checkedAt:null,cached:!0,action:"none",applier:"npm",instruction:null};try{const e=t.registry.check({current:l.version,cache:t.updateCache,save:t.saveUpdateCache,now:t.now})||{};m.latest=e.latest||null,m.behind=Boolean(e.behind),m.reason=e.reason||null}catch(e){m.reason="unavailable",m.error=String(e&&e.message||e)}try{const e=t.registry.plan({current:l.version,latest:m.latest,behind:m.behind});e&&(m.action=e.action,m.applier=e.applier,m.instruction=e.instruction)}catch{}m.behind&&o("update-available",`${m.current} → ${m.latest} (${m.instruction||"run the channel updater"})`);const y=h&&h.electron||null;t.guiRequested&&!y&&r("gui-without-electron","--gui was requested but Electron is not installed — use --tui");const b=n.filter((e=>"broken"===e.level)).length,j=n.filter((e=>"warn"===e.level)).length,k=b?EXIT.BROKEN:j?EXIT.WARN:EXIT.OK;return{report:{aegis:"one",status:b?"broken":j?"warn":"healthy",exitCode:k,product:l,faces:u,credential:{source:p,found:Boolean(d.key),from:d.key?d.from:""},store:{path:f.path,exists:f.exists,readable:f.exists?!0===f.readable:null},vendor:{staged:g.staged,matched:g.matched,mismatched:g.mismatch.length,missingSource:g.missingSource.length,stale:g.stale,verifiable:!s.installed},update:m,gui:{requested:Boolean(t.guiRequested),electron:y||null,usable:Boolean(y)&&(!t.guiImplied||t.guiImplied)},problems:n},code:k}}function render(e){const t=[];t.push(`aegis doctor — ${e.status} (exit ${e.exitCode})`),t.push(` product ${e.product.name} ${e.product.version}`);for(const[r,o]of Object.entries(e.faces)){const e=o.ok?"":` (expected ${o.expected||"unknown"})`;t.push(` ${n=r,14,String(n)+" ".repeat(Math.max(0,14-String(n).length))} ${o.version||"unknown"}${e}`)}var n;t.push(` credential ${e.credential.source}`),t.push(` shared store ${e.store.path} ${e.store.exists?e.store.readable?"(readable)":"(unreadable)":"(absent)"}`),t.push(!1===e.vendor.verifiable?` vendor ${e.vendor.staged} staged (sources not shipped — not re-derivable here)`:` vendor ${e.vendor.staged} staged, ${e.vendor.matched} matching, ${e.vendor.mismatched} mismatched, ${e.vendor.missingSource} without a source`+(e.vendor.stale?" (never staged)":""));const r=e.update;if(t.push(" update "+(r.behind?`${r.current} → ${r.latest}`:`${r.current} is current`)+` (next: ${r.action}${r.instruction?` — ${r.instruction}`:""})`),t.push(" window face "+(e.gui.electron?`Electron at ${e.gui.electron}`:"not installed")),e.problems.length){t.push(" problems:");for(const n of e.problems)t.push(` ${"broken"===n.level?"✗":"!"} ${n.code}: ${n.detail}`)}return t.join("\n")+"\n"}function wantsGui(e,t){return!!(Array.isArray(e)?e:[]).includes("--gui")||"gui"===(t||{}).AEGISONE_FACE}function main(e,t){const n=t||{},r=Array.isArray(e)?e:[],o=n.stdout||process.stdout,s=n.env||process.env||{},a=Object.assign({},n,{env:s,guiRequested:wantsGui(r,s)}),{report:i,code:l}=diagnose(a),c=r.includes("--json")?JSON.stringify(i)+"\n":render(i);try{o.write(c)}catch{}return l}module.exports={EXIT:EXIT,FACE_PACKAGES:FACE_PACKAGES,wantsGui:wantsGui,diagnose:diagnose,render:render,main:main,vendorPairs:vendorPairs,resolveSeams:resolveSeams},require.main===module&&(process.exitCode=main(process.argv.slice(2)));
3
+ "use strict";const path=require("node:path"),fs=require("node:fs"),crypto=require("node:crypto"),EXIT=Object.freeze({OK:0,WARN:1,BROKEN:2}),FACE_PACKAGES=Object.freeze([Object.freeze({dir:"cli",package:"aegiscode"}),Object.freeze({dir:"desktop",package:"aegis-desktop"})]),BUNDLE_FACES=Object.freeze([Object.freeze({face:"cli",root:"cli",staged:"one/vendor/cli"}),Object.freeze({face:"desktop",root:"desktop",staged:"one/vendor/desktop"})]);function oneDir(){return path.resolve(__dirname,"..")}function repoDir(){return path.resolve(__dirname,"..","..")}function layoutOf(e,t){const n=t=>{try{return Boolean(e.exists(t))}catch{return!1}};if(t){const e=!n(path.join(t,"one","package.json"));return{root:t,installed:e,facePrefix:e?["vendor"]:[]}}const r=repoDir(),o=!n(path.join(r,"one","package.json"));return{root:o?oneDir():r,installed:o,facePrefix:o?["vendor"]:[]}}function inLayout(e,t){if(!e.installed)return t;const n=t.split("/");if("one"===n[0]){const e=n.slice(1).join("/");return"src/selfhost.js"===e?"vendor/desktop/vendor/selfhost.js":("vendor/cli"===e||e.startsWith("vendor/"),e)}return"cli"===n[0]||"desktop"===n[0]?path.posix.join("vendor",t).split(path.sep).join("/"):path.posix.join("vendor","cli","vendor",t).split(path.sep).join("/")}function homeHint(e){const t=e||{};return t.AEGISCODE_HOME||t.AEGIS_HOME||null}function homeDir(e){try{return require("./host.js").hostHome(e||{})}catch{const t=e||{},n=t.USERPROFILE||t.HOME;return n?String(n).trim():""}}function defaultFs(){return{exists:e=>{try{return fs.existsSync(e)}catch{return!1}},readFile:e=>{try{return fs.readFileSync(e,"utf8")}catch(e){if(e&&("ENOENT"===e.code||"EISDIR"===e.code))return null;throw e}},hashFile:e=>crypto.createHash("sha256").update(fs.readFileSync(e)).digest("hex"),listFiles:(e,t)=>listFiles(e,void 0===t?e:t)}}function listFiles(e,t){const n=[],r=e=>{let o;try{o=fs.readdirSync(e,{withFileTypes:!0})}catch{return}for(const s of o){if("node_modules"===s.name||".git"===s.name)continue;const o=path.join(e,s.name);s.isDirectory()?r(o):n.push(path.relative(t,o).split(path.sep).join("/"))}};return r(e),n.sort()}function defaultElectronPaths(e,t){const n=t||{},r=homeHint(e)||path.join(homeDir(e),".aegiscode");return{electron:void 0!==n.electron?n.electron:null,desktopMain:void 0!==n.desktopMain?n.desktopMain:null,userData:void 0!==n.userData?n.userData:r,keychain:void 0!==n.keychain?n.keychain:path.join(r,"settings.json")}}function defaultRegistry(e){let t=null;const n=()=>{if(t)return t;const n=e&&e.layout?e.layout:{root:repoDir(),installed:!1},r=[path.join(n.root,"client","update.js"),path.join(n.root,"vendor","cli","vendor","client","update.js")];for(const e of r)try{t=require(e);break}catch{}return t};return{check(e){const t=n();return t&&"function"==typeof t.updateNotice?t.updateNotice(e||{}):{latest:null,behind:!1,reason:"unavailable"}},plan(e){const t=n();return t&&"function"==typeof t.updatePlan?t.updatePlan(e||{}):null}}}function clientModuleCandidates(e){return[path.join(e.root,"client"),path.join(e.root,"vendor","cli","vendor","client")]}function loadClientModule(e,t){const n=e&&e.layout?e.layout:{root:repoDir(),installed:!1};for(const e of clientModuleCandidates(n))try{return require(path.join(e,t))}catch{}return null}function defaultStorePath(e,t){try{const n=loadClientModule(t,"prefs.js");if(n&&"function"==typeof n.prefsFile)return n.prefsFile(e)}catch{}const n=homeHint(e)||path.join(homeDir(e),".aegiscode");return path.join(n,"preferences.json")}function defaultCredentials(e){let t=null,n=!1;return{resolve(r){if(n||(n=!0,t=loadClientModule(e,"credentials.js")),!t||"function"!=typeof t.resolveApiKey)return{key:"",source:"none",from:""};try{return t.resolveApiKey(r||{})}catch{return{key:"",source:"none",from:""}}}}}function vendorPairs(e){const{exists:t}=e,n=[];if((e.layout||{installed:!1,facePrefix:[]}).installed)return n;for(const{face:r,root:o,staged:s}of BUNDLE_FACES){const a=path.join(e.root,s),i=e.listFiles(a,a);for(const a of i){const i=[];if(a.startsWith("vendor/")){const e=a.slice(7);if(i.push(e),i.push(path.join(o,e)),"selfhost.js"===e&&i.push(path.join("one","src","selfhost.js")),"protocol.js"===e&&i.push(path.join("one","src","protocol.js")),"pty.js"===e&&i.push(path.join("one","src","iface","pty.js")),"desktop"===r){const t=path.basename(e);for(const e of["client","mcp","covenant","commands","skills","tools","hosts"])i.push(path.join(e,t));i.push(t)}}else i.push(path.join(o,a)),i.push(a);const l=i.find((n=>t(path.join(e.root,n))))||null;n.push({face:r,staged:path.join(s,a),source:l,candidates:i})}}return n}function layoutsInstalled(e){return Boolean(e&&e.installed)}function checkVendor(e,t){const n=t||vendorPairs(e),r=[],o=[];let s=0,a=0;const i=e.layout||{installed:!1,facePrefix:[]};if(layoutsInstalled(i)){for(const t of BUNDLE_FACES){const n=path.join(e.root,inLayout(i,t.staged));e.exists(n)&&(a+=e.listFiles(n,n).length)}return{staged:a,matched:0,mismatch:o,missingSource:r,stale:0===a,checked:0}}for(const t of n){if(!e.exists(path.join(e.root,t.staged)))continue;if(a+=1,!t.source){r.push(t.staged);continue}let n,i;try{n=e.hashFile(path.join(e.root,t.source)),i=e.hashFile(path.join(e.root,t.staged))}catch(e){o.push({staged:t.staged,source:t.source,error:String(e&&e.message||e)});continue}n===i?s+=1:o.push({staged:t.staged,source:t.source})}return{staged:a,matched:s,mismatch:o,missingSource:r,stale:n.length>0&&0===a,checked:n.length}}function readJson(e,t){const n=path.join(e.root,t);if(!e.exists(n))return{ok:!1,missing:!0,value:null,path:t};let r;try{r=e.readFile(n)}catch(e){return{ok:!1,unreadable:!0,value:null,path:t,error:String(e&&e.message||e)}}if(null==r)return{ok:!1,missing:!0,value:null,path:t};try{return{ok:!0,value:JSON.parse(r),path:t}}catch(e){return{ok:!1,unreadable:!0,value:null,path:t,error:String(e&&e.message||e)}}}function resolveSeams(e){const t=e||{},n=t.env||{},r=defaultFs(),o=t||{},s=o.exists||r.exists,a=t.layout||layoutOf({exists:s,root:t.root},t.root),i=t.root||a.root,l={root:i,layout:Object.assign({},a,{root:i}),platform:t.platform||"linux",env:n,exists:s,readFile:o.readFile||r.readFile,hashFile:o.hashFile||r.hashFile,listFiles:o.listFiles||r.listFiles,electronPaths:t.electronPaths||defaultElectronPaths(n,t),updateCache:t.updateCache,saveUpdateCache:t.saveUpdateCache,now:"number"==typeof t.now?t.now:0,guiRequested:Boolean(t.guiRequested),guiImplied:t.guiImplied,vendorPairs:t.vendorPairs};return l.credentials=t.credentials||defaultCredentials(l),l.storePath=t.storePath||defaultStorePath(n,l),l.registry=t.registry||defaultRegistry(l),l}function diagnose(e){const t=resolveSeams(e),n=[],r=(e,t)=>n.push({level:"broken",code:e,detail:t}),o=(e,t)=>n.push({level:"warn",code:e,detail:t}),s=t.layout,a=inLayout(s,"one/package.json"),i=readJson(t,a),l=i.ok?{name:i.value.name||"aegisone",version:String(i.value.version||"")}:{name:"aegisone",version:""};i.ok||r("product-unreadable",`${a} ${i.unreadable?"is unreadable":"is missing"}`);let c=null;try{c=require("./release.js").deriveFaceVersions(l.version)}catch(e){c=null,i.ok&&r("product-version-invalid",`${l.version}: ${String(e&&e.message||e)}`)}const u={};for(const{dir:e,package:n}of FACE_PACKAGES){const o=inLayout(s,`${e}/package.json`),a=readJson(t,o),i=a.ok?String(a.value.version||""):"",d=c&&c[n]?c[n].version:null;a.ok?d&&i!==d&&r("version-mismatch",`${n} is ${i}, product ${l.version} derives ${d}`):r("face-unreadable",`${o} ${a.unreadable?"is unreadable":"is missing"}`),u[n]={dir:e,version:i,expected:d,ok:Boolean(d&&i===d)}}let d={key:"",source:"none",from:""};try{d=t.credentials.resolve({env:t.env})||d}catch{d={key:"",source:"none",from:""}}const h=t.electronPaths||{};let p=d.key?"env"===d.source?"env":(d.source,"env-file"):"none";if(!d.key&&h.keychain&&t.exists(h.keychain)){const e=(()=>{try{return t.readFile(h.keychain)}catch{return null}})();e&&/encrypt|safeStorage/i.test(e)&&(p="keychain")}"none"===p&&o("no-credential","no credential found (env, credentials.json, or the OS keychain)");const f={path:t.storePath,exists:!1,readable:null,legacy:null};try{f.exists=t.exists(t.storePath)}catch{f.exists=!1}let g,v=f.path;if(f.exists){let e=null;try{e=t.readFile(f.path)}catch(e){f.readable=!1,r("store-unreadable",`${f.path}: ${String(e&&e.message||e)}`)}if(null===f.readable)if(null==e)f.readable=!1,r("store-unreadable",`${f.path} exists but could not be read`);else try{const t=JSON.parse(e);f.readable=!0,f.legacy=t&&t.version||null}catch(e){f.readable=!1,r("store-unreadable",`${f.path} is not valid JSON: ${String(e&&e.message||e)}`)}v=path.basename(f.path)}f.display=v;try{g=checkVendor(t,t.vendorPairs)}catch(e){g={staged:0,matched:0,mismatch:[],missingSource:[],stale:!1,checked:0,error:String(e&&e.message||e)},r("vendor-unreadable",g.error)}for(const e of g.mismatch)r("vendor-hash-mismatch",`${e.staged} differs from ${e.source||"its source"}`);for(const e of g.missingSource)r("vendor-source-missing",`${e} has no source to be re-derived from`);g.stale&&(s.installed?r("vendor-missing","the ONE bundle is empty — reinstall aegisone"):o("vendor-stale","the ONE bundle has never been staged (one/vendor is empty) — run `npm run predist`"));const m={channel:"npm",current:l.version,latest:null,behind:!1,reason:null,checkedAt:null,cached:!0,action:"none",applier:"npm",instruction:null};try{const e=t.registry.check({current:l.version,cache:t.updateCache,save:t.saveUpdateCache,now:t.now})||{};m.latest=e.latest||null,m.behind=Boolean(e.behind),m.reason=e.reason||null}catch(e){m.reason="unavailable",m.error=String(e&&e.message||e)}try{const e=t.registry.plan({current:l.version,latest:m.latest,behind:m.behind});e&&(m.action=e.action,m.applier=e.applier,m.instruction=e.instruction)}catch{}m.behind&&o("update-available",`${m.current} → ${m.latest} (${m.instruction||"run the channel updater"})`);const y=h&&h.electron||null;t.guiRequested&&!y&&r("gui-without-electron","--gui was requested but Electron is not installed — use --tui");const b=n.filter((e=>"broken"===e.level)).length,j=n.filter((e=>"warn"===e.level)).length,k=b?EXIT.BROKEN:j?EXIT.WARN:EXIT.OK;return{report:{aegis:"one",status:b?"broken":j?"warn":"healthy",exitCode:k,product:l,faces:u,credential:{source:p,found:Boolean(d.key),from:d.key?d.from:""},store:{path:f.path,exists:f.exists,readable:f.exists?!0===f.readable:null},vendor:{staged:g.staged,matched:g.matched,mismatched:g.mismatch.length,missingSource:g.missingSource.length,stale:g.stale,verifiable:!s.installed},update:m,gui:{requested:Boolean(t.guiRequested),electron:y||null,usable:Boolean(y)&&(!t.guiImplied||t.guiImplied)},problems:n},code:k}}function render(e){const t=[];t.push(`aegis doctor — ${e.status} (exit ${e.exitCode})`),t.push(` product ${e.product.name} ${e.product.version}`);for(const[r,o]of Object.entries(e.faces)){const e=o.ok?"":` (expected ${o.expected||"unknown"})`;t.push(` ${n=r,14,String(n)+" ".repeat(Math.max(0,14-String(n).length))} ${o.version||"unknown"}${e}`)}var n;t.push(` credential ${e.credential.source}`),t.push(` shared store ${e.store.path} ${e.store.exists?e.store.readable?"(readable)":"(unreadable)":"(absent)"}`),t.push(!1===e.vendor.verifiable?` vendor ${e.vendor.staged} staged (sources not shipped — not re-derivable here)`:` vendor ${e.vendor.staged} staged, ${e.vendor.matched} matching, ${e.vendor.mismatched} mismatched, ${e.vendor.missingSource} without a source`+(e.vendor.stale?" (never staged)":""));const r=e.update;if(t.push(" update "+(r.behind?`${r.current} → ${r.latest}`:`${r.current} is current`)+` (next: ${r.action}${r.instruction?` — ${r.instruction}`:""})`),t.push(" window face "+(e.gui.electron?`Electron at ${e.gui.electron}`:"not installed")),e.problems.length){t.push(" problems:");for(const n of e.problems)t.push(` ${"broken"===n.level?"✗":"!"} ${n.code}: ${n.detail}`)}return t.join("\n")+"\n"}function wantsGui(e,t){return!!(Array.isArray(e)?e:[]).includes("--gui")||"gui"===(t||{}).AEGISONE_FACE}function main(e,t){const n=t||{},r=Array.isArray(e)?e:[],o=n.stdout||process.stdout,s=n.env||process.env||{},a=Object.assign({},n,{env:s,guiRequested:wantsGui(r,s)}),{report:i,code:l}=diagnose(a),c=r.includes("--json")?JSON.stringify(i)+"\n":render(i);try{o.write(c)}catch{}return l}module.exports={EXIT:EXIT,FACE_PACKAGES:FACE_PACKAGES,wantsGui:wantsGui,diagnose:diagnose,render:render,main:main,vendorPairs:vendorPairs,resolveSeams:resolveSeams},require.main===module&&(process.exitCode=main(process.argv.slice(2)));
package/src/host.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- "use strict";const fs=require("node:fs"),path=require("node:path");function seamCandidates(t){const o=t||__dirname;return[path.join(o,"..","..","client","platform.js"),path.join(o,"..","vendor","desktop","vendor","platform.js"),path.join(o,"..","vendor","cli","vendor","client","platform.js")]}function platformSeam(t){const o=t||{},e=o.exists||fs.existsSync,a=o.load||require;for(const t of seamCandidates(o.dir))if(e(t))try{const o=a(t);if(o&&"function"==typeof o.seams)return o}catch{}return null}function hostPlatform(t){const o=t||{},e=platformSeam(o);return e?e.seams(o.options||{}).platform:require("node:os").platform()}function hostSeams(t){const o=t||{},e=platformSeam(o);if(e){const t=e.seams({platform:o.platform});return{platform:t.platform,win32:Boolean(t.win32)}}const a=o.platform||require("node:os").platform();return{platform:a,win32:"win32"===a}}module.exports={seamCandidates:seamCandidates,platformSeam:platformSeam,hostPlatform:hostPlatform,hostSeams:hostSeams};
3
+ "use strict";const fs=require("node:fs"),path=require("node:path");function seamCandidates(t){const o=t||__dirname;return[path.join(o,"..","..","client","platform.js"),path.join(o,"..","vendor","desktop","vendor","platform.js"),path.join(o,"..","vendor","cli","vendor","client","platform.js")]}function platformSeam(t){const o=t||{},r=o.exists||fs.existsSync,e=o.load||require;for(const t of seamCandidates(o.dir))if(r(t))try{const o=e(t);if(o&&"function"==typeof o.seams)return o}catch{}return null}function hostPlatform(t){const o=t||{},r=platformSeam(o);return r?r.seams(o.options||{}).platform:require("node:os").platform()}function hostSeams(t){const o=t||{},r=platformSeam(o);if(r){const t=r.seams({platform:o.platform});return{platform:t.platform,win32:Boolean(t.win32)}}const e=o.platform||require("node:os").platform();return{platform:e,win32:"win32"===e}}function hostHome(t,o){const r=o||{},e=t&&"object"==typeof t?t:{},n=platformSeam(r);if(n&&"function"==typeof n.homeDir)try{const t=n.homeDir({env:e,platform:r.platform});if(t)return String(t).trim()}catch{}const a="win32"===hostPlatform(r)?e.USERPROFILE||e.HOME:e.HOME||e.USERPROFILE;return a?String(a).trim():""}module.exports={seamCandidates:seamCandidates,platformSeam:platformSeam,hostPlatform:hostPlatform,hostSeams:hostSeams,hostHome:hostHome};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegiscode",
3
3
  "productName": "AEGIS Code",
4
- "version": "7.0.52",
4
+ "version": "7.0.53",
5
5
  "description": "aegiscode — the command-line version of AEGIS One. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",
@@ -1,3 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- "use strict";const fs=require("node:fs"),path=require("node:path"),DIFF_LIMITS={fileBytes:262144,lcsCells:25e4,rows:400,context:3};function splitLines(t){const e=String(null==t?"":t).replace(/\r\n?/g,"\n");if(""===e)return[];const n=e.split("\n");return n.length&&""===n[n.length-1]&&n.pop(),n}function lineDiff(t,e){const n=splitLines(t),s=splitLines(e);let i=0;for(;i<n.length&&i<s.length&&n[i]===s[i];)i++;let r=0;for(;r<n.length-i&&r<s.length-i&&n[n.length-1-r]===s[s.length-1-r];)r++;const l=n.slice(i,n.length-r),o=s.slice(i,s.length-r),a=lcsOps(l,o),c=null===a,g=a||[...l.map((t=>({sign:"-",text:t}))),...o.map((t=>({sign:"+",text:t})))];if(!g.some((t=>" "!==t.sign)))return{rows:[],adds:0,dels:0,truncated:c};const u=DIFF_LIMITS.context,p=[];let d=1,f=1;const h=i>u?i-u:0,x=h;x>0&&p.push({sign:" ",text:"",marker:!0,note:`… ${x} unchanged line${1===x?"":"s"}`});for(let t=h;t<i;t++)p.push({sign:" ",text:n[t],no:f}),f++,d++;for(const t of g)" "===t.sign?(p.push({sign:" ",text:t.text,no:f}),f++,d++):"-"===t.sign?(p.push({sign:"-",text:t.text,no:d}),d++):(p.push({sign:"+",text:t.text,no:f}),f++);const m=s.length-r,I=Math.min(r,u);f=m+1;for(let t=0;t<I;t++)p.push({sign:" ",text:s[m+t],no:f}),f++,d++;if(r>u){const t=r-u;p.push({sign:" ",text:"",marker:!0,note:`… ${t} unchanged line${1===t?"":"s"}`})}const _=p.filter((t=>"+"===t.sign)).length,w=p.filter((t=>"-"===t.sign)).length;let F=p,y=!1;return F.length>DIFF_LIMITS.rows&&(F=F.slice(0,DIFF_LIMITS.rows),F.push({sign:" ",text:"",marker:!0,note:`… ${p.length-DIFF_LIMITS.rows} more diff lines`}),y=!0),{rows:F,adds:_,dels:w,truncated:c||y}}function lcsOps(t,e){const n=t.length,s=e.length;if(!n||!s)return[...t.map((t=>({sign:"-",text:t}))),...e.map((t=>({sign:"+",text:t})))];if(n*s>DIFF_LIMITS.lcsCells)return null;const i=s+1,r=new Int32Array((n+1)*i);for(let l=n-1;l>=0;l--)for(let n=s-1;n>=0;n--)r[l*i+n]=t[l]===e[n]?r[(l+1)*i+(n+1)]+1:Math.max(r[(l+1)*i+n],r[l*i+(n+1)]);const l=[];let o=0,a=0;for(;o<n&&a<s;)t[o]===e[a]?(l.push({sign:" ",text:t[o]}),o++,a++):r[(o+1)*i+a]>=r[o*i+(a+1)]?(l.push({sign:"-",text:t[o]}),o++):(l.push({sign:"+",text:e[a]}),a++);for(;o<n;)l.push({sign:"-",text:t[o++]});for(;a<s;)l.push({sign:"+",text:e[a++]});return l}function fileRows(t){const e=splitLines(t),n=e.slice(0,DIFF_LIMITS.rows),s=n.map(((t,e)=>({sign:" ",text:t,no:e+1}))),i=e.length-n.length;return i>0&&s.push({sign:" ",text:"",marker:!0,note:`… ${i} more lines`}),{rows:s,adds:0,dels:0,truncated:i>0}}function readCapped(t,e={}){const n=null==e.bytes?DIFF_LIMITS.fileBytes:e.bytes;try{const e=fs.statSync(t);if(!e.isFile())return{text:null,missing:!0};const s=fs.readFileSync(t,"utf8");return e.size>n?{text:s.slice(0,n),missing:!1,truncated:!0}:{text:s,missing:!1}}catch{return{text:null,missing:!0}}}function shortPath(t,e){const n=String(t||"");if(!e)return n;const s=path.relative(e,n);if(s&&!s.startsWith("..")&&!path.isAbsolute(s))return s;const i=n.split(path.sep).filter(Boolean),r=n.startsWith(path.sep)?path.sep:"";return i.length>2?r+"…"+path.sep+i.slice(-2).join(path.sep):n}function editPreview(t,e,n={}){try{const s=null==n.cwd?process.cwd():n.cwd,i=n.readFile||readCapped;if(!e||"object"!=typeof e)return null;const r="string"==typeof e.file_path?e.file_path:"string"==typeof e.path?e.path:null;if(!r)return null;const l={file:r,short:shortPath(r,s)};if("Edit"===t||"editFile"===t)return"string"!=typeof e.old_string||"string"!=typeof e.new_string?null:Object.assign({kind:"Update"},l,lineDiff(e.old_string,e.new_string),{replaceAll:!!e.replace_all});if("Write"===t||"writeFile"===t){if("string"!=typeof e.content)return null;const t=i(r)||{text:null,missing:!0};let n=lineDiff(null==t.text?"":t.text,e.content);return n.rows.length||t.missing||!e.content||(n=fileRows(e.content)),Object.assign({kind:t.missing?"Create":"Write"},l,n,{truncated:n.truncated||!!t.truncated})}if("MultiEdit"===t){const t=(Array.isArray(e.edits)?e.edits:[]).filter((t=>t&&"string"==typeof t.old_string&&"string"==typeof t.new_string));if(!t.length)return null;const n=i(r)||{text:null,missing:!0};if("string"==typeof n.text){let e=n.text,s=0;for(const n of t)-1!==e.indexOf(n.old_string)?e=n.replace_all?e.split(n.old_string).join(n.new_string):e.replace(n.old_string,n.new_string):s++;const i=lineDiff(n.text,e);return Object.assign({kind:"Update"},l,i,{misses:s,replaceAll:t.some((t=>t.replace_all))})}let s=[],o=0,a=0,c=!1;return t.forEach(((e,n)=>{const i=lineDiff(e.old_string,e.new_string);n&&s.push({sign:" ",text:"",marker:!0,note:`… edit ${n+1} of ${t.length}`}),s=s.concat(i.rows),o+=i.adds,a+=i.dels,c=c||i.truncated})),Object.assign({kind:"Update"},l,{rows:s,adds:o,dels:a,truncated:c,stacked:t.length})}return null}catch{return null}}function changeSummary(t){const e=[];return t.adds&&e.push(`Added ${t.adds} line${1===t.adds?"":"s"}`),t.dels&&e.push(`removed ${t.dels} line${1===t.dels?"":"s"}`),e.length?e.join(", "):"no line changes"}module.exports={DIFF_LIMITS:DIFF_LIMITS,splitLines:splitLines,lineDiff:lineDiff,readCapped:readCapped,shortPath:shortPath,changeSummary:changeSummary,editPreview:editPreview};
3
+ "use strict";const fs=require("node:fs"),path=require("node:path"),DIFF_LIMITS={fileBytes:262144,lcsCells:25e4,rows:400,context:3};function splitLines(t){const e=String(null==t?"":t).replace(/\r\n?/g,"\n");if(""===e)return[];const n=e.split("\n");return n.length&&""===n[n.length-1]&&n.pop(),n}function lineDiff(t,e){const n=splitLines(t),s=splitLines(e);let i=0;for(;i<n.length&&i<s.length&&n[i]===s[i];)i++;let r=0;for(;r<n.length-i&&r<s.length-i&&n[n.length-1-r]===s[s.length-1-r];)r++;const l=n.slice(i,n.length-r),o=s.slice(i,s.length-r),a=lcsOps(l,o),c=null===a,g=a||[...l.map((t=>({sign:"-",text:t}))),...o.map((t=>({sign:"+",text:t})))];if(!g.some((t=>" "!==t.sign)))return{rows:[],adds:0,dels:0,truncated:c};const d=DIFF_LIMITS.context,f=[];let u=1,p=1;const h=i>d?i-d:0,x=h;x>0&&f.push({sign:" ",text:"",marker:!0,note:`… ${x} unchanged line${1===x?"":"s"}`});for(let t=h;t<i;t++)f.push({sign:" ",text:n[t],no:p}),p++,u++;for(const t of g)" "===t.sign?(f.push({sign:" ",text:t.text,no:p}),p++,u++):"-"===t.sign?(f.push({sign:"-",text:t.text,no:u}),u++):(f.push({sign:"+",text:t.text,no:p}),p++);const m=s.length-r,I=Math.min(r,d);p=m+1;for(let t=0;t<I;t++)f.push({sign:" ",text:s[m+t],no:p}),p++,u++;if(r>d){const t=r-d;f.push({sign:" ",text:"",marker:!0,note:`… ${t} unchanged line${1===t?"":"s"}`})}const _=f.filter((t=>"+"===t.sign)).length,w=f.filter((t=>"-"===t.sign)).length;let y=f,F=!1;return y.length>DIFF_LIMITS.rows&&(y=y.slice(0,DIFF_LIMITS.rows),y.push({sign:" ",text:"",marker:!0,note:`… ${f.length-DIFF_LIMITS.rows} more diff lines`}),F=!0),{rows:y,adds:_,dels:w,truncated:c||F}}function lcsOps(t,e){const n=t.length,s=e.length;if(!n||!s)return[...t.map((t=>({sign:"-",text:t}))),...e.map((t=>({sign:"+",text:t})))];if(n*s>DIFF_LIMITS.lcsCells)return null;const i=s+1,r=new Int32Array((n+1)*i);for(let l=n-1;l>=0;l--)for(let n=s-1;n>=0;n--)r[l*i+n]=t[l]===e[n]?r[(l+1)*i+(n+1)]+1:Math.max(r[(l+1)*i+n],r[l*i+(n+1)]);const l=[];let o=0,a=0;for(;o<n&&a<s;)t[o]===e[a]?(l.push({sign:" ",text:t[o]}),o++,a++):r[(o+1)*i+a]>=r[o*i+(a+1)]?(l.push({sign:"-",text:t[o]}),o++):(l.push({sign:"+",text:e[a]}),a++);for(;o<n;)l.push({sign:"-",text:t[o++]});for(;a<s;)l.push({sign:"+",text:e[a++]});return l}function fileRows(t){const e=splitLines(t),n=e.slice(0,DIFF_LIMITS.rows),s=n.map(((t,e)=>({sign:" ",text:t,no:e+1}))),i=e.length-n.length;return i>0&&s.push({sign:" ",text:"",marker:!0,note:`… ${i} more lines`}),{rows:s,adds:0,dels:0,truncated:i>0}}function readCapped(t,e={}){const n=null==e.bytes?DIFF_LIMITS.fileBytes:e.bytes;try{const e=fs.statSync(t);if(!e.isFile())return{text:null,missing:!0};const s=fs.readFileSync(t,"utf8");return e.size>n?{text:s.slice(0,n),missing:!1,truncated:!0}:{text:s,missing:!1}}catch{return{text:null,missing:!0}}}function shortPath(t,e){const n=String(t||"");if(!e)return n;const s=path.relative(e,n);if(s&&!s.startsWith("..")&&!path.isAbsolute(s))return s;const i=n.split(path.sep).filter(Boolean),r=n.startsWith(path.sep)?path.sep:"";return i.length>2?r+"…"+path.sep+i.slice(-2).join(path.sep):n}function editsDiff(t,e,n){const s=n(t)||{text:null,missing:!0};if("string"==typeof s.text){let t=s.text,n=0;for(const s of e)-1!==t.indexOf(s.old_string)?t=s.replace_all?t.split(s.old_string).join(s.new_string):t.replace(s.old_string,s.new_string):n++;const i=lineDiff(s.text,t);return Object.assign({kind:"Update"},i,{misses:n,replaceAll:e.some((t=>t.replace_all))})}let i=[],r=0,l=0,o=!1;return e.forEach(((t,n)=>{const s=lineDiff(t.old_string,t.new_string);n&&i.push({sign:" ",text:"",marker:!0,note:`… edit ${n+1} of ${e.length}`}),i=i.concat(s.rows),r+=s.adds,l+=s.dels,o=o||s.truncated})),{kind:"Update",rows:i,adds:r,dels:l,truncated:o,stacked:e.length}}function editPreview(t,e,n={}){try{const s=null==n.cwd?process.cwd():n.cwd,i=n.readFile||readCapped;if(!e||"object"!=typeof e)return null;const r="string"==typeof e.file_path?e.file_path:"string"==typeof e.path?e.path:null;if(!r)return null;const l={file:r,short:shortPath(r,s)};if("Edit"===t||"editFile"===t){if("string"==typeof e.old_string&&"string"==typeof e.new_string)return Object.assign({kind:"Update"},l,lineDiff(e.old_string,e.new_string),{replaceAll:!!e.replace_all});const t=(Array.isArray(e.edits)?e.edits:[]).filter((t=>t&&"string"==typeof t.old_string&&"string"==typeof t.new_string));return t.length?Object.assign({kind:"Update"},l,editsDiff(r,t,i)):null}if("Write"===t||"writeFile"===t){if("string"!=typeof e.content)return null;const t=i(r)||{text:null,missing:!0};let n=lineDiff(null==t.text?"":t.text,e.content);return n.rows.length||t.missing||!e.content||(n=fileRows(e.content)),Object.assign({kind:t.missing?"Create":"Write"},l,n,{truncated:n.truncated||!!t.truncated})}if("MultiEdit"===t){const t=(Array.isArray(e.edits)?e.edits:[]).filter((t=>t&&"string"==typeof t.old_string&&"string"==typeof t.new_string));return t.length?Object.assign({kind:"Update"},l,editsDiff(r,t,i)):null}return null}catch{return null}}function changeSummary(t){const e=[];return t.adds&&e.push(`Added ${t.adds} line${1===t.adds?"":"s"}`),t.dels&&e.push(`removed ${t.dels} line${1===t.dels?"":"s"}`),e.length?e.join(", "):"no line changes"}module.exports={DIFF_LIMITS:DIFF_LIMITS,splitLines:splitLines,lineDiff:lineDiff,readCapped:readCapped,shortPath:shortPath,changeSummary:changeSummary,editPreview:editPreview};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";function normalizeSubject(e){return String(e||"").trim().toLowerCase().replace(/^(the|a|an)\s+/,"")}const FACT_PATTERNS=[/^(?:the\s+)?(.+?)\s+(?:is|was|are|were)\s+(.+)$/i,/^(.+?):\s*(.+)$/];function extractFact(e){const t=String(e||"").trim();if(!t)return null;for(const e of FACT_PATTERNS){const n=e.exec(t);if(!n)continue;const s=n[1].trim(),o=n[2].trim();if(!s||!o)continue;const i=normalizeSubject(s);if(i)return{key:i,value:o,displaySubject:s}}return null}function bodyOf(e){return String(e&&(e.body||e.content||e.text)||"").trim()}function collectFacts({notes:e,transcripts:t}){const n=[];for(const t of e||[]){const e=extractFact(bodyOf(t));e&&n.push({...e,citation:{type:"note",id:String(t&&t.id||"")},recency:Number(t&&t.updated)||0,order:n.length})}for(const e of t||[]){const t=extractFact(String(e&&e.text||""));t&&n.push({...t,citation:{type:"session",id:String(e&&e.sessionId||"")},recency:Number(e&&e.ts)||0,order:n.length})}return n}function citationLabel(e){return"session"===e.type?`session ${e.id}`:`note ${e.id}`}function slug(e){return String(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"untitled"}function groupFactsIntoPages(e){const t=new Map;for(const n of e){const e=t.get(n.key);e?(e.citations.push(n.citation),n.value!==e.value&&(n.recency>e.recency?(e.supersededValues.push(e.value),e.value=n.value,e.recency=n.recency):e.supersededValues.push(n.value))):t.set(n.key,{key:n.key,title:n.displaySubject,value:n.value,recency:n.recency,citations:[n.citation],supersededValues:[]})}return[...t.values()]}function computeLinks(e){const t=e.map((e=>new Set(e.citations.map(citationLabel))));return e.map(((n,s)=>{const o=[];for(let n=0;n<e.length;n++){if(s===n)continue;let i=!1;for(const e of t[s])if(t[n].has(e)){i=!0;break}i&&o.push(e[n].title)}return{...n,links:o}}))}function renderBody(e){const t=[`${e.title} ${e.value}.`];return e.supersededValues.length&&t.push(`Superseded: ${e.supersededValues.join("; ")}`),e.links.length&&t.push(`See also: ${e.links.map((e=>`[[${e}]]`)).join(", ")}`),t.push(`Sources: ${[...new Set(e.citations.map(citationLabel))].join(", ")}`),t.join("\n")}function buildWikiPages({notes:e=[],transcripts:t=[],existingPages:n=[]}={}){const s=computeLinks(groupFactsIntoPages(collectFacts({notes:e,transcripts:t}))).map((e=>({...e,body:renderBody(e)}))),o=new Map((n||[]).map((e=>[e.key,e])));let i=0,c=0,r=0;for(const e of s){const t=o.get(e.key);t?t.body!==e.body&&(c+=1):i+=1;const n=new Set(t&&t.links||[]);r+=e.links.filter((e=>!n.has(e))).length}return{pages:s,report:{pagesCreated:i,pagesExtended:c,linksAdded:r}}}function pagesToStagedEntries(e,{now:t=Date.now()}={}){return e.map((e=>({id:`dream/wiki/${slug(e.key)}`,body:e.body,scope:"default",tags:["dream","wiki"],updated:t,source:"dream"})))}module.exports={normalizeSubject:normalizeSubject,extractFact:extractFact,collectFacts:collectFacts,groupFactsIntoPages:groupFactsIntoPages,computeLinks:computeLinks,buildWikiPages:buildWikiPages,pagesToStagedEntries:pagesToStagedEntries,slug:slug};
@@ -134,7 +134,7 @@ const UNITS = Object.freeze([
134
134
  * (`tools/desktop-seal.mjs` in the source tree, `tools/obfuscate-faces.mjs`
135
135
  * after obfuscation), never by hand.
136
136
  */
137
- const SEALED = 'f2a24b8db64bbb0b88cbe663d6c7dddc15b584a68609213b4b147516dd596aec';
137
+ const SEALED = '25478904c5c5181aee2f2d4cb3b2ae8c4653b51f7de37e94f0aa4119d3775253';
138
138
 
139
139
  /**
140
140
  * Ask the question. Never throws — a check that can break the program it is
@@ -4560,6 +4560,42 @@ function resolveUpdateOwner({
4560
4560
  return { pkg: 'aegis-desktop', current: 'unknown', productDir: null };
4561
4561
  }
4562
4562
 
4563
+ /**
4564
+ * The one line of npm's stderr that names what actually went wrong.
4565
+ *
4566
+ * npm prints a failure as a block whose *last* lines are the consequence, not
4567
+ * the cause:
4568
+ *
4569
+ * npm error code ETARGET
4570
+ * npm error notarget No matching version found for aegisone@1.0.60.
4571
+ * npm error notarget In most cases you or one of your dependencies are requesting
4572
+ * npm error notarget a package version that doesn't exist.
4573
+ * npm error A complete log of this run can be found in: …/_logs/…-debug-0.log
4574
+ *
4575
+ * Taking `slice(-3)` of that — which is what this did — kept the boilerplate,
4576
+ * the log path and the two continuation lines, and threw away the sentence
4577
+ * carrying the actual reason. A real ETARGET therefore reached the user as
4578
+ * four repetitions of "In most cases you…" with the cause nowhere on screen.
4579
+ *
4580
+ * So: strip npm's own prefix, drop the log path and the trailing explanation,
4581
+ * and keep the first line that survives. `code ETARGET` is a label rather than
4582
+ * a message, so the line after it is preferred and the code is appended.
4583
+ */
4584
+ function installFailureText(output, fallback = 'the installer failed') {
4585
+ const lines = String(output == null ? '' : output)
4586
+ .split('\n')
4587
+ .map((line) => line.replace(/^\s*npm\s+(error|ERR!)\s*/i, '').trim())
4588
+ .filter(Boolean)
4589
+ .filter((line) => !/^A complete log of this run can be found/i.test(line))
4590
+ .filter((line) => !/^In most cases you or one of your dependencies/i.test(line))
4591
+ .filter((line) => !/^a package version that doesn't exist\.?$/i.test(line));
4592
+ if (!lines.length) return fallback;
4593
+ const at = lines.findIndex((line) => /^code\s+[A-Z]/i.test(line));
4594
+ const message = at >= 0 && lines[at + 1] ? lines[at + 1] : lines[0];
4595
+ const code = at >= 0 ? lines[at].replace(/^code\s+/i, '') : '';
4596
+ return code ? `${message} (${code})` : message;
4597
+ }
4598
+
4563
4599
  function createNpmUpdateManager({
4564
4600
  onStatus,
4565
4601
  // A packaged build (AppImage/deb/NSIS/dmg) is NOT the npm copy. `npm i -g`
@@ -4591,6 +4627,11 @@ function createNpmUpdateManager({
4591
4627
  status: 'idle',
4592
4628
  version: null,
4593
4629
  error: null,
4630
+ // Which step the last failure came from: 'check' (the registry read) or
4631
+ // 'install' (npm itself refusing). The banner used to call both "Update
4632
+ // check failed", so an install that failed was reported as a check that
4633
+ // failed — blaming the registry for a real ETARGET.
4634
+ phase: null,
4594
4635
  channel: 'npm',
4595
4636
  reason: null,
4596
4637
  transient: false,
@@ -4753,7 +4794,7 @@ function createNpmUpdateManager({
4753
4794
  // What we already knew, so a transient failure cannot erase it.
4754
4795
  const priorStatus = state.status;
4755
4796
  const priorVersion = state.version;
4756
- set({ status: 'checking', error: null, reason: null, transient: false });
4797
+ set({ status: 'checking', error: null, reason: null, transient: false, phase: null });
4757
4798
 
4758
4799
  let res;
4759
4800
  try {
@@ -4840,7 +4881,7 @@ function createNpmUpdateManager({
4840
4881
  attempts,
4841
4882
  });
4842
4883
  }
4843
- return set({ status: 'error', error: message, reason: res.reason, transient: true, attempts });
4884
+ return set({ status: 'error', phase: 'check', error: message, reason: res.reason, transient: true, attempts });
4844
4885
  }
4845
4886
 
4846
4887
  // The registry answered and the answer was no (404, 403, unreadable). That
@@ -4849,7 +4890,7 @@ function createNpmUpdateManager({
4849
4890
  clearRetry();
4850
4891
  retryAt = 0;
4851
4892
  return set({
4852
- status: 'error', error: message, reason: res.reason,
4893
+ status: 'error', phase: 'check', error: message, reason: res.reason,
4853
4894
  transient: false, attempts, retryInMs: 0,
4854
4895
  });
4855
4896
  })();
@@ -4923,7 +4964,7 @@ function createNpmUpdateManager({
4923
4964
  canDownload: false,
4924
4965
  });
4925
4966
  }
4926
- set({ status: 'downloading', error: null, progress: 0 });
4967
+ set({ status: 'downloading', error: null, progress: 0, phase: null });
4927
4968
  const res = await runInstall(target);
4928
4969
  if (!res.ok) {
4929
4970
  // `transient: false` deliberately: an installer that refused is not a
@@ -4932,7 +4973,9 @@ function createNpmUpdateManager({
4932
4973
  return set({
4933
4974
  status: 'error',
4934
4975
  transient: false,
4935
- error: res.output.trim().split('\n').slice(-3).join(' ').trim() || 'the installer failed',
4976
+ // The install step, named as such — not a failed check.
4977
+ phase: 'install',
4978
+ error: installFailureText(res.output),
4936
4979
  command: `${target.command} ${target.args.join(' ')}`,
4937
4980
  });
4938
4981
  }
@@ -7217,6 +7260,7 @@ module.exports = {
7217
7260
  isSafeExternalUrl,
7218
7261
  createUpdateManager,
7219
7262
  createNpmUpdateManager,
7263
+ installFailureText,
7220
7264
  resolveUpdateOwner,
7221
7265
  createUpdateDispatch,
7222
7266
  describeRegistryFailure,
@@ -134,7 +134,7 @@ const UNITS = Object.freeze([
134
134
  * (`tools/desktop-seal.mjs` in the source tree, `tools/obfuscate-faces.mjs`
135
135
  * after obfuscation), never by hand.
136
136
  */
137
- const SEALED = 'f2a24b8db64bbb0b88cbe663d6c7dddc15b584a68609213b4b147516dd596aec';
137
+ const SEALED = '25478904c5c5181aee2f2d4cb3b2ae8c4653b51f7de37e94f0aa4119d3775253';
138
138
 
139
139
  /**
140
140
  * Ask the question. Never throws — a check that can break the program it is
@@ -4560,6 +4560,42 @@ function resolveUpdateOwner({
4560
4560
  return { pkg: 'aegis-desktop', current: 'unknown', productDir: null };
4561
4561
  }
4562
4562
 
4563
+ /**
4564
+ * The one line of npm's stderr that names what actually went wrong.
4565
+ *
4566
+ * npm prints a failure as a block whose *last* lines are the consequence, not
4567
+ * the cause:
4568
+ *
4569
+ * npm error code ETARGET
4570
+ * npm error notarget No matching version found for aegisone@1.0.60.
4571
+ * npm error notarget In most cases you or one of your dependencies are requesting
4572
+ * npm error notarget a package version that doesn't exist.
4573
+ * npm error A complete log of this run can be found in: …/_logs/…-debug-0.log
4574
+ *
4575
+ * Taking `slice(-3)` of that — which is what this did — kept the boilerplate,
4576
+ * the log path and the two continuation lines, and threw away the sentence
4577
+ * carrying the actual reason. A real ETARGET therefore reached the user as
4578
+ * four repetitions of "In most cases you…" with the cause nowhere on screen.
4579
+ *
4580
+ * So: strip npm's own prefix, drop the log path and the trailing explanation,
4581
+ * and keep the first line that survives. `code ETARGET` is a label rather than
4582
+ * a message, so the line after it is preferred and the code is appended.
4583
+ */
4584
+ function installFailureText(output, fallback = 'the installer failed') {
4585
+ const lines = String(output == null ? '' : output)
4586
+ .split('\n')
4587
+ .map((line) => line.replace(/^\s*npm\s+(error|ERR!)\s*/i, '').trim())
4588
+ .filter(Boolean)
4589
+ .filter((line) => !/^A complete log of this run can be found/i.test(line))
4590
+ .filter((line) => !/^In most cases you or one of your dependencies/i.test(line))
4591
+ .filter((line) => !/^a package version that doesn't exist\.?$/i.test(line));
4592
+ if (!lines.length) return fallback;
4593
+ const at = lines.findIndex((line) => /^code\s+[A-Z]/i.test(line));
4594
+ const message = at >= 0 && lines[at + 1] ? lines[at + 1] : lines[0];
4595
+ const code = at >= 0 ? lines[at].replace(/^code\s+/i, '') : '';
4596
+ return code ? `${message} (${code})` : message;
4597
+ }
4598
+
4563
4599
  function createNpmUpdateManager({
4564
4600
  onStatus,
4565
4601
  // A packaged build (AppImage/deb/NSIS/dmg) is NOT the npm copy. `npm i -g`
@@ -4591,6 +4627,11 @@ function createNpmUpdateManager({
4591
4627
  status: 'idle',
4592
4628
  version: null,
4593
4629
  error: null,
4630
+ // Which step the last failure came from: 'check' (the registry read) or
4631
+ // 'install' (npm itself refusing). The banner used to call both "Update
4632
+ // check failed", so an install that failed was reported as a check that
4633
+ // failed — blaming the registry for a real ETARGET.
4634
+ phase: null,
4594
4635
  channel: 'npm',
4595
4636
  reason: null,
4596
4637
  transient: false,
@@ -4753,7 +4794,7 @@ function createNpmUpdateManager({
4753
4794
  // What we already knew, so a transient failure cannot erase it.
4754
4795
  const priorStatus = state.status;
4755
4796
  const priorVersion = state.version;
4756
- set({ status: 'checking', error: null, reason: null, transient: false });
4797
+ set({ status: 'checking', error: null, reason: null, transient: false, phase: null });
4757
4798
 
4758
4799
  let res;
4759
4800
  try {
@@ -4840,7 +4881,7 @@ function createNpmUpdateManager({
4840
4881
  attempts,
4841
4882
  });
4842
4883
  }
4843
- return set({ status: 'error', error: message, reason: res.reason, transient: true, attempts });
4884
+ return set({ status: 'error', phase: 'check', error: message, reason: res.reason, transient: true, attempts });
4844
4885
  }
4845
4886
 
4846
4887
  // The registry answered and the answer was no (404, 403, unreadable). That
@@ -4849,7 +4890,7 @@ function createNpmUpdateManager({
4849
4890
  clearRetry();
4850
4891
  retryAt = 0;
4851
4892
  return set({
4852
- status: 'error', error: message, reason: res.reason,
4893
+ status: 'error', phase: 'check', error: message, reason: res.reason,
4853
4894
  transient: false, attempts, retryInMs: 0,
4854
4895
  });
4855
4896
  })();
@@ -4923,7 +4964,7 @@ function createNpmUpdateManager({
4923
4964
  canDownload: false,
4924
4965
  });
4925
4966
  }
4926
- set({ status: 'downloading', error: null, progress: 0 });
4967
+ set({ status: 'downloading', error: null, progress: 0, phase: null });
4927
4968
  const res = await runInstall(target);
4928
4969
  if (!res.ok) {
4929
4970
  // `transient: false` deliberately: an installer that refused is not a
@@ -4932,7 +4973,9 @@ function createNpmUpdateManager({
4932
4973
  return set({
4933
4974
  status: 'error',
4934
4975
  transient: false,
4935
- error: res.output.trim().split('\n').slice(-3).join(' ').trim() || 'the installer failed',
4976
+ // The install step, named as such — not a failed check.
4977
+ phase: 'install',
4978
+ error: installFailureText(res.output),
4936
4979
  command: `${target.command} ${target.args.join(' ')}`,
4937
4980
  });
4938
4981
  }
@@ -7217,6 +7260,7 @@ module.exports = {
7217
7260
  isSafeExternalUrl,
7218
7261
  createUpdateManager,
7219
7262
  createNpmUpdateManager,
7263
+ installFailureText,
7220
7264
  resolveUpdateOwner,
7221
7265
  createUpdateDispatch,
7222
7266
  describeRegistryFailure,
@@ -2,7 +2,7 @@
2
2
  "name": "aegis-desktop",
3
3
  "productName": "aegis one",
4
4
  "desktopName": "aegis-desktop",
5
- "version": "1.0.52",
5
+ "version": "1.0.53",
6
6
  "description": "Thin Electron host for AEGIS — a local chat UI over the shared client/aegis.js transport. Ships transport + UI only; engine logic stays server-side.",
7
7
  "author": {
8
8
  "name": "AEGIS Code",