@inkeep/open-knowledge 0.85.0-beta.0 → 0.85.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/cli.mjs +58 -58
  2. package/dist/constants-CEWqiFCf.mjs +1 -0
  3. package/dist/dist-CqZISrZN.mjs +2212 -0
  4. package/dist/{dist-Dda0D3aV.mjs → dist-DjEZX3vG.mjs} +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/dist/{init-8obEC39z.mjs → init-BontxrPQ.mjs} +21 -21
  7. package/dist/init-BtiXJkEo.mjs +1 -0
  8. package/dist/{launch-json-removal-gEgkQN8h.mjs → launch-json-removal-CDHWF-ku.mjs} +1 -1
  9. package/dist/loader-CkxCQRBx.mjs +1 -0
  10. package/dist/{loader-DWY1RHg1.mjs → loader-DMoA9Hv1.mjs} +1 -1
  11. package/dist/{md-manager-BGnqyqi1-CKR6E7Rf.mjs → md-manager-BGnqyqi1-dBGkA2rR.mjs} +176 -155
  12. package/dist/native/native-config.win32-arm64-msvc.node +0 -0
  13. package/dist/native/native-config.win32-x64-msvc.node +0 -0
  14. package/dist/native/package.json +1 -1
  15. package/dist/{open-browser-Bd-Va7d5.mjs → open-browser-CbRl45f4.mjs} +1 -1
  16. package/dist/parse-worker.mjs +1 -1
  17. package/dist/preview-Cf5VnxW_.mjs +1 -0
  18. package/dist/{preview-BK4eZzn2.mjs → preview-vc6NgNe_.mjs} +1 -1
  19. package/dist/{registry-probes-SbSR_s99.mjs → registry-probes-Cwx6O6kv.mjs} +3 -3
  20. package/dist/{removal-file-path-gFE6O5Or.mjs → removal-file-path-D0LbC71-.mjs} +1 -1
  21. package/dist/{repair-launch-json-QdjFSCpy.mjs → repair-launch-json-sysIcyZL.mjs} +1 -1
  22. package/dist/{repair-mcp-configs-DGRbJX9u.mjs → repair-mcp-configs-mZrdQ93t.mjs} +1 -1
  23. package/dist/src-BKnvpIkn.mjs +14 -0
  24. package/dist/src-DWEbxzXJ.mjs +1 -0
  25. package/dist/start-Dh1mqp4M.mjs +1 -0
  26. package/dist/{start-QSvpDCbj.mjs → start-lQOFYtsk.mjs} +3 -3
  27. package/package.json +4 -4
  28. package/dist/constants-CLSFu78r.mjs +0 -1
  29. package/dist/dist-C8gZeqCx.mjs +0 -2212
  30. package/dist/init-DNQgK__1.mjs +0 -1
  31. package/dist/loader-gqcYinvk.mjs +0 -1
  32. package/dist/preview-DVmWbeys.mjs +0 -1
  33. package/dist/src-D-5pW72q.mjs +0 -1
  34. package/dist/src-DnbociwA.mjs +0 -14
  35. package/dist/start-Da-7M-7H.mjs +0 -1
@@ -1 +0,0 @@
1
- import"./dist-C8gZeqCx.mjs";import{_ as e}from"./init-8obEC39z.mjs";export{e as runInit};
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-DWY1RHg1.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-BK4eZzn2.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-CKR6E7Rf.mjs";import"./src-DnbociwA.mjs";import"./init-8obEC39z.mjs";import"./registry-probes-SbSR_s99.mjs";import"./start-QSvpDCbj.mjs";import{n as e}from"./loader-DWY1RHg1.mjs";import"./preview-BK4eZzn2.mjs";import"./repair-mcp-configs-DGRbJX9u.mjs";export{e as loadConfig};
@@ -1,14 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Gc as t,H as n,Hu as r,Kc as i,Ml as a,Nl as o,Sf as s,U as c,Vc as l,W as u,_a as d,_f as f,bf as p,ga as ee,l as m,lf as h,mf as g,u as te,yf as _}from"./md-manager-BGnqyqi1-CKR6E7Rf.mjs";import{At as v,Li as y,Qn as b,Ri as x,Si as S,Ta as C,Tr as w,as as T,bi as E,cr as D,fr as O,is as ne,ko as k,m as re,mi as A,rs as j,si as M,ts as N,ws as P,xi as ie}from"./dist-C8gZeqCx.mjs";import{t as ae}from"./yazl-BBz29IQN.mjs";import{Ct as F,ot as I,st as oe}from"./init-8obEC39z.mjs";import{l as se,w as ce}from"./registry-probes-SbSR_s99.mjs";import{c as le}from"./colors-r_owlCuY.mjs";import{t as ue}from"./is-object-BGze3w87.mjs";import{n as de}from"./constants-CLSFu78r.mjs";import"./loader-DWY1RHg1.mjs";import"./preview-BK4eZzn2.mjs";import{execFile as fe,execSync as pe,spawnSync as me}from"node:child_process";import{basename as L,dirname as R,isAbsolute as he,join as z,relative as ge,resolve as B,sep as V,win32 as _e}from"node:path";import{closeSync as ve,cpSync as ye,createWriteStream as be,existsSync as H,lstatSync as xe,mkdirSync as U,mkdtempSync as Se,openSync as Ce,readFileSync as W,readSync as we,readdirSync as G,readlinkSync as Te,realpathSync as Ee,rmSync as K,rmdirSync as De,statSync as Oe,writeFileSync as q}from"node:fs";import{arch as ke,freemem as Ae,homedir as J,hostname as je,platform as Me,release as Ne,tmpdir as Pe,totalmem as Fe,type as Ie,uptime as Le}from"node:os";import{readFile as Re,readdir as ze,stat as Be}from"node:fs/promises";import{createHash as Ve}from"node:crypto";function He(e,t){let n=t.map(e=>[P(e),e]);for(let t of e){let e=P(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function Ue(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=He([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=He(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function We(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const Ge=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function Ke(e,t,n=O){if(e!==void 0&&!Ge.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let qe=null;function Je(e){qe=e}function Ye(){return qe??process.cwd()}const Xe=`Open Knowledge`;function Ze(e={}){let t=e.platformName??process.platform,n=e.productName??f().productName;return I(t).join(oe({...e,platformName:t}),n)}function Qe(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=I(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`${f().packageName.replaceAll(`/`,``)}-updater`)}function $e(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function et(e){let t=z(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return $e(n)??[]}function tt(e){let t=z(e,`state.json`);if(!H(t))return!1;try{return $e(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const nt=8192;function rt(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function it(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const at=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function ot(e){return e.replace(at,`$1"[REDACTED-DEVICE-ID]"`)}function st(e){return ot(it(e))}const ct=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function lt(e){if(typeof e!=`string`)return null;let t=ct.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function ut(e){let t=Ce(e,`r`);try{let e=Buffer.alloc(nt),n=0,r=!1;for(;n<nt;){let i=we(t,e,n,nt-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{ve(t)}}function dt(e){try{let t=ut(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:lt(a)}}catch{return{kind:`unreadable`}}}function ft(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function pt(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=z(e,t.name),r;try{r=Oe(n).mtimeMs}catch{continue}if(r<i)continue;let c=dt(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!ft(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}const mt=`state/os-termination-evidence.json`,ht=6048e5,gt=/openknowledge/i,_t=Object.values(g).map(p);function vt(e={}){return(t,n)=>new Promise(r=>{try{fe(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...yt(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function yt(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function bt(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
2
- `)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function Y(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function xt(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function St(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function Ct(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function wt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Tt(e,t){let n=t.indexOf(`
3
- `);if(n===-1)return null;let r,i;try{r=wt(JSON.parse(t.slice(0,n))),i=wt(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=wt(e);t===null||typeof t.name!=`string`||!ft(t.name)||a.push({name:t.name,pid:Ct(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:Ct(t.rpages),lifetimeMaxPages:Ct(t.lifetimeMax)})}let o=lt(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:Ct(wt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`&&ft(i.largestProcess),ownedProcesses:a}}async function Et(e,t){let n=Y(`darwin`,`macos-jetsam`,[z(e,`JetsamEvent-*.ips`)]),r;try{r=await ze(e)}catch(e){return xt(n,e.code??`unknown`)}let i=t.getTime()-ht,a=[];for(let t of r)if(/^JetsamEvent-.*\.ips$/.test(t))try{let{mtimeMs:n}=await Be(z(e,t));n>=i&&a.push({file:t,mtimeMs:n})}catch{n.unparseable+=1}a.sort((e,t)=>t.mtimeMs-e.mtimeMs),n.droppedOverCap=Math.max(0,a.length-50);for(let{file:t}of a.slice(0,50)){let r=null;try{r=Tt(t,await Re(z(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return St(n)}const Dt=[`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Out of memory|oom-kill|Killed process|Killed /|memory pressure`,`_TRANSPORT=kernel`,`+`,`_SYSTEMD_UNIT=systemd-oomd.service`],Ot=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/;function kt(e,t){if(e===`systemd-oomd`){let e=/^Killed (\S+)/.exec(t);if(e===null)return null;let n=e[1]?.split(`/`).pop()??``;return{origin:`systemd-oomd`,action:`oomd-kill`,pid:null,processName:null,unit:gt.test(n)?n:null,trigger:/swap used/.test(t)?`swap`:/memory pressure/.test(t)?`memory-pressure`:null}}if(e!==`kernel`)return null;let n=/Killed process (\d+) \(([^)]+)\)/.exec(t);if(n!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(n[1]),processName:n[2]??null,unit:null,trigger:null};let r=/task=([^,]+),pid=(\d+)/.exec(t);if(r!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(r[2]),processName:r[1]??null,unit:null,trigger:null};let i=/^(\S+) invoked oom-killer/.exec(t);return i===null?null:{origin:`kernel`,action:`oom-invoked`,pid:null,processName:i[1]??null,unit:null,trigger:null}}function At(e){let t=[],n=0,r=0;for(let i of e.split(`
4
- `)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=Ot.exec(i);if(e===null){r+=1;continue}let[,a=``,o=``,s=``]=e;if(!gt.test(s)){n+=1;continue}let c=kt(o,s);if(c===null){r+=1;continue}t.push({kind:`journal`,at:a,...c})}return{events:t,foreignIgnored:n,unparseable:r}}async function jt(e){let t=Y(`linux`,`linux-journal`,[`journalctl ${Dt.join(` `)}`]),n=await e(`journalctl`,[...Dt]),r=n.status===1&&/^-- No entries --$/m.test(n.stdout);if(n.status!==0&&!r)return xt(t,bt(n));let i=At(n.stdout);return t.droppedOverCap=Math.max(0,i.events.length-50),t.events.push(...i.events.slice(-50)),t.foreignIgnored=i.foreignIgnored,t.unparseable=i.unparseable,/not seeing messages from other users/i.test(`${n.stdout}\n${n.stderr}`)&&(t.restrictedToCurrentUser=!0),St(t)}const Mt={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},Nt={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function Pt(e){return e===`System`?Mt:Nt}function Ft(e){let t=`System[(${Object.keys(Pt(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${ht}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${_t.map(e=>`Data='${e}'`).join(` or `)}]]`}function It(e){return[`qe`,e,`/q:${Ft(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function Lt(e){return _e.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function Rt(e){return e.replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&apos;/g,`'`).replace(/&amp;/g,`&`)}function zt(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function Bt(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>Rt(e[1]??``).trim())}function Vt(e,t){let n=Pt(e),r=[],i=0,a=0;for(let o of t.match(/<Event[\s>][\s\S]*?<\/Event>/g)??[]){let t=/<Provider\s+Name=['"]([^'"]+)['"]/.exec(o)?.[1],s=Number(/<EventID[^>]*>(\d+)<\/EventID>/.exec(o)?.[1]),c=/<TimeCreated\s+SystemTime=['"]([^'"]+)['"]/.exec(o)?.[1];if(t===void 0||!Number.isInteger(s)||c===void 0){a+=1;continue}if(n[s]!==t){i+=1;continue}let l=Bt(o,`Data`),u=Bt(o,`Name`),d=[...l,...u].some(e=>gt.test(e));if(e===`Application`&&!d){i+=1;continue}r.push({kind:`windows-event`,at:c,log:e,provider:t,eventId:s,mentionsOpenKnowledge:d,data:e===`Application`?l.filter(e=>e!==``&&!zt(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function Ht(e,t){let n=Lt(t),r=[`System`,`Application`],i=Y(`win32`,`windows-event-log`,r.map(e=>`${n} ${It(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,It(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${bt(t)}`);continue}let n=Vt(e,t.stdout);i.droppedOverCap+=Math.max(0,n.events.length-50),i.events.push(...n.events.slice(0,50)),i.foreignIgnored+=n.foreignIgnored,i.unparseable+=n.unparseable}return o.length===r.length?xt(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:St(i)}async function Ut(e={}){let t=e.platform??process.platform,n=e.runCommand??vt(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return Et(e.macosReportsDir??`/Library/Logs/DiagnosticReports`,r);case`linux`:return jt(n);case`win32`:return Ht(n,e.systemRoot??process.env.SystemRoot);default:return{...Y(t,null,[]),outcome:`unsupported`}}}const Wt={schemaVersion:1,outcome:`not-collected`};function Gt(e){return`${JSON.stringify(e??Wt,null,2)}\n`}const Kt={"macos-jetsam":`macOS low-memory reports`,"linux-journal":`system journal`,"windows-event-log":`Windows event logs`};function qt(e){let t=[`${e.windowDays}d`,`${e.events.length} kept`,`${e.foreignIgnored} other-process record(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&t.push(`${e.droppedOverCap} older dropped over cap`);let n=e.source?` from ${Kt[e.source]}`:``,r=e.unavailableReason?`, ${e.unavailableReason}`:``;return`${e.outcome}${n}${r} (${t.join(`; `)})`}function Jt(){return z(N(),`bug-reports`)}function Yt(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Jt(),r=`${t}-bugreport`,i=z(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=z(n,`${r}-${e}.zip`);return i}function Xt(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function Zt(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let e=W(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return H(z(e,`.ok`))?Ve(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function Qt(){let e={timestamp:new Date().toISOString(),platform:Me(),osType:Ie(),osRelease:Ne(),hostname:`[redacted]`,uptime:Le(),freeMem:Ae(),totalMem:Fe(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=pe(`sw_vers -productVersion 2>/dev/null`,k({encoding:`utf8`})).trim()}catch{}try{let t=z(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const $t=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function en(e){let t=L(e);return $t.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function tn(e,t){return on(e,t).files}const nn=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function rn(e,t=se){let n=z(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return nn.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>z(n,e.entry)))}function an(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-m.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>z(e,t))}catch{return[]}}function on(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>z(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(en),i=[],a=r.filter(t=>{try{return W(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!en(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function sn(e){let n=z(e,`.ok`,`local`);return H(n)?{files:[`server.lock`,`last-spawn-error.log`,t,l].map(e=>z(n,e)).filter(e=>H(e))}:{files:[]}}function cn(e){let t=z(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function ln(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Ve(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function un(e){let t=e.revealDocNames?e.content:ln(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=d(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function X(e){for(let t of e.files)try{let n=W(t,`utf8`);un({zipfile:e.zipfile,name:`${e.prefix}/${L(t)}`,content:t.endsWith(`.ips`)?st(n):n,redact:e.redact,revealDocNames:e.revealDocNames,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function dn(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??z(N(),`logs`),s=t.projectDir?Zt(t.projectDir,i):null;U(R(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=Qt();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=on(s,o),{files:d}=t.projectDir?sn(t.projectDir):{files:[]},{files:f}=t.projectDir?cn(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new _;X({zipfile:v,files:[...l,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:d,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:f,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:te,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??L(e.sourcePath)}`;v.addBuffer(t,n),g.push(n);let r=Xt(e,n);r!==null&&h.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&un({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${L(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:rt(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`),un({zipfile:v,name:mt,content:Gt(t.osTerminationEvidence),redact:n,revealDocNames:!0,bundleFiles:g,redactions:h});let S=JSON.stringify(c,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:g,redactions:h,sysinfo:c};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${L(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${te}/${L(e)}`)),O=g.filter(e=>D.has(e)),ne=s?g.filter(e=>e.startsWith(`logs/`)&&!en(e)&&!T.has(e)):[],k=b.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],re=k.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...k]:[`Redaction was disabled for this bundle; file contents are unmodified.`],A=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...ne.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...ne.map(e=>`- ${e}`),``]:[],...E.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...E.map(e=>`- ${e}`),``]:[],...b.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...b.map(e=>`- ${e}`),``]:[],...(t.osTerminationEvidence?.events.length??0)>0?[`Termination records: read from the operating system rather than written`,`by OpenKnowledge, covering the last 7 days, to explain an exit the app`,`could not record itself. On macOS: the memory-pressure (jetsam) reports`,`that list processes of this app, with each one's memory use and whether`,`it was killed. On Linux: kernel and systemd-oomd out-of-memory kills of`,`this app, as structured fields with the machine name, cgroup paths and`,`user id left out. On Windows: crash and hang records for this app with`,`file paths left out, plus the time of every shutdown, restart, power`,`loss and low-memory warning on the machine, whatever caused it:`,`- ${mt}`,``]:[],...O.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...O.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${ee.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...k,``,`This bundle is safe to attach to a GitHub issue.`]:re].join(`
5
- `);v.addBuffer(Buffer.from(A,`utf8`),`README.md`),v.end();let j=be(r);return v.outputStream.pipe(j),await new Promise((e,t)=>{j.on(`close`,e),j.on(`error`,t)}),i?.info({bundlePath:r,fileCount:g.length,redactionCount:w},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:g,redactions:h,redactedLineCount:w,generatedAt:C.generatedAt}}}var fn=r(),pn=e(ae(),1),Z=e(le(),1);function mn(e){let t=T(`user`,e,e);return j({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function hn({home:e=J(),env:t=process.env}={}){let n=mn(e),{override:r,preferenceList:i}=ne(t),{locale:s,source:c}=Ue({override:r,storedPreference:n,supportedLocales:o,preferenceList:i,autoDetectableLocales:a});return{preference:n,locale:s,source:c,systemLanguages:i}}function gn(e){let t=new Set([e]);try{t.add(Ee.native(e))}catch{return[e].filter(e=>e.length>0)}return[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length)}function _n(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function vn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yn(e,t){if(typeof e==`string`)return _n(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>yn(e,t));if(!vn(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=yn(i,t);return n}function bn(e,t){let n=W(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
6
- `),i=n.split(`
7
- `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=yn(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
8
- `)}\n`:a.join(`
9
- `);q(e,o)}function xn(e,t){let n=W(e,`utf-8`);if(n.trim().length!==0)try{let r=yn(JSON.parse(n),t),i=n.endsWith(`
10
- `)?`
11
- `:``;q(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=_n(n,t.contentDirSpellings);r!==n&&q(e,r)}}function Sn(e,t){let n=W(e,`utf-8`),r=_n(n,t.contentDirSpellings);r!==n&&q(e,r)}function Cn(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>z(e,t.name))}catch{return[]}}const wn=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Tn(e){return/\.log\.\d+$/.test(e)}function En(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Tn(e)}const Dn=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function On(e){let t={contentDirSpellings:gn(e.contentDir)};for(let n of Dn)for(let r of Cn(z(e.stagingDir,n)))En(r)?bn(r,t):r.endsWith(`.json`)?xn(r,t):Sn(r,t);for(let n of Cn(z(e.stagingDir,`state`))){let e=L(n);n.endsWith(`.jsonl`)?bn(n,t):wn.has(e)?xn(n,t):Sn(n,t)}}const kn=[`.ok`,`local`,`telemetry`],An=[`.ok`,`local`,`logs`],jn=[`.ok`,`local`,`loss-capture`],Mn=`spans-current.jsonl`,Nn=`spans-prev.jsonl`,Pn=`server-current.jsonl`,Fn=`server-prev.jsonl`,In=`loss-current.jsonl`,Ln=`loss-prev.jsonl`;function Rn(e){return z(e,...kn,Mn)}function zn(e){return z(e,...kn,Nn)}function Bn(e){return z(e,...An,Pn)}function Vn(e){return z(e,...An,Fn)}function Hn(e){return z(e,...jn,In)}function Un(e){return z(e,...jn,Ln)}const Wn=1e3;async function Gn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Wn)});return t.ok?await t.text():null}catch{return null}}async function Kn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Wn)});return t.ok?await t.text():null}catch{return null}}async function qn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Wn)});return t.ok?await t.text():null}catch{return null}}function Jn(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
12
- `)}\n`:null}catch{return null}}function Yn(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=me(`git`,[`-C`,t,`log`,`--oneline`,`-50`],k({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Xn(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=me(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],k({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Zn(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Qn(){return{nodeVersion:process.version,platform:Me(),arch:ke()}}function $n(){return process.env.OTEL_SDK_DISABLED===`false`}function er(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tr(e){if(!H(e))return{};let t;try{t=(0,fn.parse)(W(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!er(t))return{};let n=t.telemetry;if(!er(n))return{};let r=n.localSink;return er(r)?r:{}}function nr(e){return typeof e==`boolean`?e:void 0}function rr(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function ir(e){if(er(e))return rr(e.maxBytes)}function ar(e){let t=tr(T(`project`,e)),n=tr(T(`project-local`,e));return{enabled:nr(n.enabled)??nr(t.enabled)??!0,spansMaxBytes:ir(n.spans)??ir(t.spans)??52428800,logsMaxBytes:ir(n.logs)??ir(t.logs)??26214400}}function or(e){return Ve(`sha256`).update(e).digest(`hex`)}function sr(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const cr=[`"doc.name"`,`"docName"`];function lr(e){let t=W(e,`utf-8`),n=0;for(let e of cr){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!H(e))return!1;try{return U(R(t),{recursive:!0}),e.endsWith(`.ips`)?q(t,st(W(e,`utf-8`))):ye(e,t),!0}catch{return!1}}function ur(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=z(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const dr=new Set([`.jsonl`]);function fr(e){let t=e.lastIndexOf(`.`);return t!==-1&&dr.has(e.slice(t))}const pr=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function mr(e){if(Tn(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&pr.has(e.slice(t))}function hr(e){let t=[];for(let n of ur(e)){let r=gr(e,n);if(!mr(r))continue;let{redacted:i,patterns:a,lineCount:o}=d(W(n,`utf-8`));a.length!==0&&(q(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function gr(e,t){return ge(e,t).split(V).join(`/`)}async function _r(e){let n=B(e.contentDir),r=B(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??Gn,s=a.fetchAgentEffects??Kn,c=a.fetchWatcherRecent??qn,u=a.readShadowHead??Yn,d=a.readCheckpointRefs??Xn,f=a.now??(()=>new Date),p=a.okVersion??(()=>de),ee=a.readDesktopEnv??Zn,m=a.readLanguage??hn,h=a.readRuntime??Qn,g=a.isOtlpPushEnabled??$n,_=Se(z(Pe(),`ok-bundle-`));try{U(z(_,`telemetry`),{recursive:!0}),U(z(_,`logs`),{recursive:!0}),U(z(_,`state`),{recursive:!0}),Q(Rn(r),z(_,`telemetry`,Mn)),Q(zn(r),z(_,`telemetry`,Nn)),Q(Bn(r),z(_,`logs`,Pn)),Q(Vn(r),z(_,`logs`,Fn));for(let t of e.userLogFiles??[])Q(t,z(_,`logs`,L(t)));for(let t of e.userStateFiles??[])Q(t,z(_,te,L(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Q(t,z(_,`diagnostic-reports`,L(t)))&&(v+=1);let y=z(r,`.ok`,`local`),b=z(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(H(b)){Q(b,z(_,`state`,`server.lock`));try{let e=W(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:S=`lock present but no port`}catch{S=`lock present but unparseable`}}if(C!==null){let e=await o(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(q(z(_,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await s(C);t!==null&&q(z(_,`state`,`agent-effects.json`),t);let n=await c(C);if(n!==null){let e=Jn(n);e!==null&&q(z(_,`state`,`watcher-recent.jsonl`),e)}}let w=u(n);w!==null&&q(z(_,`state`,`shadow-head.txt`),w);let T=d(n);T!==null&&q(z(_,`state`,`checkpoint-refs.txt`),T),Q(Hn(r),z(_,`state`,In)),Q(Un(r),z(_,`state`,Ln)),Q(z(y,`last-spawn-error.log`),z(_,`state`,`last-spawn-error.log`)),Q(z(y,i),z(_,`state`,i)),Q(z(y,t),z(_,`state`,t)),Q(z(y,l),z(_,`state`,l));let E=h(),D=ee(),O=m(),ne={ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};q(z(_,`state`,`runtime.json`),`${JSON.stringify(ne,null,2)}\n`);let k=x===`running`?`running
13
- `:`not-running (${S})\n`;q(z(_,`state`,`server-status.txt`),k);let re=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:rt(e.diagnosticReports,v);if(q(z(_,`state`,`diagnostic-reports-status.txt`),`${re}\n`),q(z(_,mt),Gt(e.osTerminationEvidence)),e.processDir&&H(e.processDir)){let t=z(_,`process`);U(t,{recursive:!0}),ye(e.processDir,t,{recursive:!0})}let A=e.redact===!0;A&&On({stagingDir:_,contentDir:n}),e.note&&q(z(_,`note.txt`),e.note);let j=null;e.scrubSecrets===!0&&(j=hr(_));for(let t of e.extraFiles??[]){let e=t.zipName??L(t.sourcePath);if(!Q(t.sourcePath,z(_,`extra`,e))){a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=Xt(t,`extra/${e}`);n!==null&&(j??={redactions:[],redactedLineCount:0},j.redactions.push(n),j.redactedLineCount+=n.lineCount)}let M=ar(r),N=ur(_),P=[],ie=0,ae=0;for(let e of N){let t=gr(_,e),n=Oe(e).size,r=fr(t)?sr(e):0;P.push({path:t,bytes:n,lines:r}),ie+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(ae+=lr(e))}let F={applied:A};j!==null&&(F.secretScrub=j);let I={schemaVersion:2,createdAt:f().toISOString(),ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:or(n),absolutePath:A?`<CONTENT_DIR>`:n},telemetry:{localSink:M,otlpPushEnabled:g()},redaction:F,serverStatus:x,files:P};q(z(_,`manifest.json`),`${JSON.stringify(I,null,2)}\n`);let oe=gn(n),se=N.some(e=>{try{let t=W(e,`utf-8`);return oe.some(e=>t.includes(e))}catch{return!1}}),ce={stagedDiagnosticReports:v,totalBytes:ie,fileCount:P.length,docNameCount:ae,contentDirVisible:se,redacted:A},le=!1;return{stagingDir:_,manifest:I,summary:ce,cleanup:()=>{le||(le=!0,K(_,{recursive:!0,force:!0}))}}}catch(e){throw K(_,{recursive:!0,force:!0}),e}}async function vr(e){let{collected:t,outputPath:n}=e,r=R(n);if(!H(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new pn.ZipFile,a=ur(t.stagingDir);for(let e of a){let n=gr(t.stagingDir,e);i.addFile(e,n)}i.end();let o=be(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function yr(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,fn.parse)(W(n,`utf-8`)),r=ue(t)?t.content:void 0,i=ue(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return B(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return B(e)}async function br(e,t,n,r,i,a){let o=Zt(t,e.logger),s=await _r({contentDir:yr(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...tn(o,e.userLogsDir??z(N(),`logs`)),...rn(e.cachesDir??z(J(),`Library`,`Caches`))],userStateFiles:an(e.bugReportsDir??Jt()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(R(e.outputPath),{recursive:!0}),await vr({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function xr(e){let{projectDir:t}=e,n=e.readDesktopEnv??Zn,r=e.readLanguage??hn,i=()=>pt(e.diagnosticReportsDir??z(J(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return br(e,t,n,r,i(),await Ut(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await dn({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:rn(e.cachesDir??z(J(),`Library`,`Caches`)),bugReportLedgerFiles:an(e.bugReportsDir??Jt()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await Ut(e.osTerminationEvidenceDeps):void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=S(e,t),i;try{i=W(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??w()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??je());if(!a||typeof a!=`object`||!A(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??M)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function Sr(e){return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${e.lockPath} does not record its owning machine, and its recorded process ${e.pid} is still running on this machine. Check whether process ${e.pid} is an OpenKnowledge server. If it is, stop it and retry. Do not remove the lock file while that process is running.`:`Cannot verify shutdown: the server lock at ${e.lockPath} belongs to another machine. Stop OpenKnowledge on the owning machine. Confirm that no OpenKnowledge server is using this directory on the owning machine or any other machine sharing it. Only then remove the stale lock file at ${e.lockPath} and retry cleanup.`}function Cr(e){return e.replace(/:\d+$/,``)}function wr(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Cr(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Cr(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Cr(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const Tr=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Er(e){return u(s(),e)}function Dr(){return c(s())}function Or(){let e=s();if(e===`stable`)return Tr;let t=n(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const kr={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>xe(e),readlinkSync:e=>Te(e)};function Ar(e,t=kr){let n=Er(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function jr(e){let t=e.replace(Or(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Mr(e,t,n=kr){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const Nr=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],Pr=[...v.map(e=>re[e]),`open-knowledge`];function Fr(e){if(!he(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||R(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Ir(e,t){let n=ge(e,t);if(n.startsWith(`..`)||he(n))return!1;let r=e;for(let e of n.split(V)){r=z(r,e);try{if(!xe(r).isDirectory())return!1}catch{return!1}}return!0}function Lr(e,t){try{return G(e).every(n=>t.has(z(e,n)))}catch{return!1}}function Rr(e){let t=Fr(e),n=[],r=[],i=new Set;for(let e of Nr){let a=z(t,e.hostDir,`skills`);if(!Ir(t,a))continue;let o=Pr.map(e=>z(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=z(t,e.pruneRoot),c=a;for(;Lr(c,i)&&(r.push(c),i.add(c),c!==s);){let e=R(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function zr(e){try{if(!xe(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Br(e){let t=new Set,n=new Set;for(let r of Nr){let i=z(e,r.hostDir,`skills`);for(let e of Pr)t.add(z(i,e));let a=z(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=R(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Vr(e,t){let n=Fr(e),r=Br(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(Ir(n,e)&&zr(e))try{K(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Ir(n,e))try{De(e),a.push(e)}catch{}return a}function Hr(e){let t=Fr(e),n=[];for(let e of v){let r=re[e];n.push({path:z(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of h)n.push({path:z(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Ur(e,t){let n=[];for(let r of Hr(e))if(r.bundleId===t)try{K(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function Wr(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Gr(e,t=Date.now()){if(e===null)return`—`;let n=We(e,t);return n===`unknown`?`—`:n}function Kr(e){let t=R(e);return L(e)===`local`&&L(t)===`.ok`?R(t):L(e)===`.ok`?t:null}function qr(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:Kr(e),server:{port:null,status:t.status,pid:t.pid,startedAt:null,usage:null},ui:null,hostname:null,lockPath:t.lockPath,binary:null,command:null,isDesktop:!1};let i=t.lock,a=t.status===`alive`&&E(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:D(n),command:n,isDesktop:Wr(n)}}function Jr(e){let t=e.server.status;switch(t){case`unverified-owner`:return`unverified`;case`alive`:return e.isDesktop?`desktop`:`running`;case`foreign-host`:return e.isDesktop?`desktop`:`foreign`;case`dead-pid`:return`stale`;default:return t}}const Yr=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Xr(e){switch(e){case`running`:return Z.default.green(e);case`desktop`:return Z.default.blue(e);case`foreign`:return Z.default.cyan(e);case`unverified`:case`stale`:return Z.default.yellow(e)}}function Zr(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Qr(e){return`${Zr(e.server.usage)} | ${Zr(e.ui?.usage??null)}`}function $r(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function ei(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>[e.directory??`—`,$r(e),Qr(e),Jr(e),String(e.server.pid),Gr(e.server.startedAt),e.binary??`—`]),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=Xr(Jr(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=Z.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
14
- `)}async function ti(e={}){let t=e.discover??b,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??y,a=e.resolveUsage??x,o=await t(),s=[];for(let e of o){let t=n(e),r=qr(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Jr(e)}));r(JSON.stringify(e,null,2));return}r(ei(e.all?s:s.filter(e=>Yr.has(Jr(e)))))}function ni(){return new F(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale entries (foreign and unverified entries already show)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await ti({all:t.all===!0||e===`all`,json:t.json===!0})})}async function ri(e,t=ce()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=ie(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function ii(e,t={}){return{targets:si(e,t.isAlive??M)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}function ai(e){try{return s()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function oi(e){let t=e.inspect??(()=>$(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??ri,o=e.logger??ce(),s=t(),c=ii(s,{isAlive:e.isAlive});if(c.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let l=s.status===`alive`||s.status===`foreign-host`?s.lock.channel:void 0;if(e.force!==!0&&typeof l==`string`&&l.length>0){let t=e.selfChannel??ai(o);if(t!==void 0&&l!==t)return i(`Not stopping: the server at ${e.lockDir} belongs to ${_(l)}. Stop it from that app or its CLI, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,holderChannel:l,selfChannel:t,pids:c.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:l}}}if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:c.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let u=[],d=[];for(let e of c.targets)try{n(e.pid,`SIGTERM`),u.push(e)}catch(t){d.push({target:e,error:t instanceof Error?t.message:String(t)})}return u.length>0&&r(`Stopped: ${u.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:u.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:d.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),d.length>0&&i(`Failed to stop: ${d.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:u,failed:d,hadTargets:!0}}function si(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function ci(e,t=M){let n=await b(),r=null;for(let i of n){let n=$(i,`server`);if(si(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function li(e,t){let n=await oi({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function ui(e,t,n={}){return t===0?`Nothing was running for ${e}, and no other open-knowledge servers are running.`:`Nothing was running for ${e}. ${t} other open-knowledge server${t===1?` is`:`s are`} running${n.listingFollows===!0?``:" — run `ok ps` to list them"}.`}async function di(e){let t=await b(),n=0;for(let r of t)r!==e&&si($(r,`server`),M)&&n++;return n}function fi(e){return new F(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the enclosing project — run it from anywhere inside the project. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).option(`--force`,`Stop even when the server belongs to another OpenKnowledge app (Stable or Beta) or editor windows or agents are still connected to it`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=C(process.cwd()),n=await oi({lockDir:t,force:r,log:()=>{}});if(n.hadTargets){if(n.stopped.length>0){let e=n.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1)}else{let e=await di(t);console.log(ui(process.cwd(),e,{listingFollows:e>0})),e>0&&await ti({})}return}if(i===`all`){let e=await b();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)si($(n,`server`),M)&&(await li(n,r),t++);t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(i)){let e=Number.parseInt(i,10),t=await ci(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await li(t,r);return}let a=B(Ye(),i),o=C(a),s=[],c=await oi({lockDir:o,force:r,log:e=>s.push(e)});if((c.failed.length>0||c.declined!==void 0)&&(process.exitCode=1),c.hadTargets)for(let e of s)console.log(e);else console.log(ui(a,await di(o)))})}export{et as A,Ut as C,Xe as D,rt as E,Ye as M,Je as N,Qe as O,Ke as P,Jt as S,pt as T,$ as _,Vr as a,vr as b,Hr as c,Er as d,Dr as f,Sr as g,wr as h,ni as i,tt as j,Ze as k,Tr as l,jr as m,oi as n,Rr as o,Ar as p,fi as r,Ur as s,ri as t,Mr as u,xr as v,qt as w,Yt as x,_r as y};
@@ -1 +0,0 @@
1
- import{S as e,m as t,p as n,r}from"./start-QSvpDCbj.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};