@inkeep/open-knowledge 0.72.1 → 0.73.0-beta.0

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 (105) hide show
  1. package/dist/cli.mjs +46 -46
  2. package/dist/constants-CEZpdo1d.mjs +1 -0
  3. package/dist/{dist-CcOixwu-.mjs → dist-CVJfSfJh.mjs} +487 -487
  4. package/dist/{dist-CXSbeq2s.mjs → dist-zTxXoqu4.mjs} +1 -1
  5. package/dist/index.mjs +139 -139
  6. package/dist/{init-BS1jW1ap.mjs → init-BvmRO7re.mjs} +7 -7
  7. package/dist/init-C8CSY0Tx.mjs +1 -0
  8. package/dist/{launch-json-removal-Dmx0AXXx.mjs → launch-json-removal-CosW_PcO.mjs} +1 -1
  9. package/dist/{loader-CL02d_x_.mjs → loader-CEEaL4dv.mjs} +1 -1
  10. package/dist/loader-F8eJIfWh.mjs +1 -0
  11. package/dist/{md-manager-BGnqyqi1-BjukM0Wf.mjs → md-manager-BGnqyqi1-BMsQT5x6.mjs} +2 -2
  12. package/dist/{open-browser-DG4YB3Kq.mjs → open-browser-CRzbTK-f.mjs} +1 -1
  13. package/dist/parse-worker.mjs +1 -1
  14. package/dist/{preview-3wmj89l7.mjs → preview-BB49HMe1.mjs} +1 -1
  15. package/dist/preview-k50i2F9f.mjs +1 -0
  16. package/dist/public/assets/{ActivityModeContent-uyL7HxG4.js → ActivityModeContent-D2Z1UD5R.js} +1 -1
  17. package/dist/public/assets/{AddPropertiesButton-kMcRRaht.js → AddPropertiesButton-Bc5I-T1P.js} +1 -1
  18. package/dist/public/assets/{AgentDiffPane-DlRsWC8t.js → AgentDiffPane-C1-isSha.js} +1 -1
  19. package/dist/public/assets/{CodeMirrorPropInput-Osrkcwto.js → CodeMirrorPropInput-BFpi9-JK.js} +1 -1
  20. package/dist/public/assets/{DocumentContext-Ckj_fGkD.js → DocumentContext-Ce2jrrZM.js} +1 -1
  21. package/dist/public/assets/{EditorModeToggle-CQxeuGZ_.js → EditorModeToggle-DpldfDuY.js} +1 -1
  22. package/dist/public/assets/{EnableSyncConfirmDialog-CA01i92r.js → EnableSyncConfirmDialog-BD40jYPB.js} +1 -1
  23. package/dist/public/assets/{ExcalidrawDocEditor-D-ocWTWF.js → ExcalidrawDocEditor-DYjthBkp.js} +1 -1
  24. package/dist/public/assets/FeedbackForm-C5jyOOK8.js +1 -0
  25. package/dist/public/assets/{ImportSkillDialog-R3IhN3Zg.js → ImportSkillDialog-DlUE4xMR.js} +1 -1
  26. package/dist/public/assets/{LintConfigEditor-CXH61qO_.js → LintConfigEditor-CMb40sS3.js} +1 -1
  27. package/dist/public/assets/ManagedArtifactProperties-Bqjumbt5.js +1 -0
  28. package/dist/public/assets/{ManagedArtifactProperties-BdPi4vMO.js → ManagedArtifactProperties-DvfLdDaI.js} +1 -1
  29. package/dist/public/assets/{MermaidDocEditor-C12-umtW.js → MermaidDocEditor-DtgUtnxJ.js} +1 -1
  30. package/dist/public/assets/{PropertyDisplayRow-u_fa68vA.js → PropertyDisplayRow-keuAQPQN.js} +1 -1
  31. package/dist/public/assets/{SchemaConfigEditor-uitUtWhc.js → SchemaConfigEditor-DJC8iCyK.js} +1 -1
  32. package/dist/public/assets/{SessionsHost-3PDZonm6.js → SessionsHost-YiyoMDk5.js} +2 -2
  33. package/dist/public/assets/{SettingsDialogBody-Dlu-99dz.js → SettingsDialogBody-DLC4YQqo.js} +3 -3
  34. package/dist/public/assets/{ShareReceiveMissDialog-BZ0Lb3a2.js → ShareReceiveMissDialog-ap4bFNBa.js} +1 -1
  35. package/dist/public/assets/{SkillToolbarControls-BSHCQUbz.js → SkillToolbarControls-HlbPVAU5.js} +1 -1
  36. package/dist/public/assets/{SourceEditor-poDc1YYf.js → SourceEditor-BVS7qo5G.js} +1 -1
  37. package/dist/public/assets/{TerminalWindowApp-DxC0L8ej.js → TerminalWindowApp-D5YwfFOH.js} +1 -1
  38. package/dist/public/assets/{TextDocEditor-CNydPhYv.js → TextDocEditor-Cm1Rk7ny.js} +1 -1
  39. package/dist/public/assets/{ThreadView-3ZJAojtX.js → ThreadView-BPVZsQ5l.js} +1 -1
  40. package/dist/public/assets/{TimelineDiffPane-BNpCxl6F.js → TimelineDiffPane-YAy1OOxQ.js} +1 -1
  41. package/dist/public/assets/auth-state-cache-iQdJ_AHz.js +11 -0
  42. package/dist/public/assets/client-version-CMGzUGQE.js +1 -0
  43. package/dist/public/assets/{comment-chips-wepHZxJr.js → comment-chips-DmIwJ-wW.js} +1 -1
  44. package/dist/public/assets/{config-provider-CgevtbAS.js → config-provider-qcD7mGjX.js} +1 -1
  45. package/dist/public/assets/{doc-undo-manager-CKf9Alk-.js → doc-undo-manager-DJOkcu-w.js} +1 -1
  46. package/dist/public/assets/{index-Bjwwfhy7.js → index-D_nXtmmr.js} +9 -9
  47. package/dist/public/assets/messages-2CCeaXgq.js +1 -0
  48. package/dist/public/assets/messages-B5Cy4Veu.js +1 -0
  49. package/dist/public/assets/messages-BCR56nIb.js +1 -0
  50. package/dist/public/assets/messages-Bb4gjUnB.js +1 -0
  51. package/dist/public/assets/messages-Bo_5-aWE.js +1 -0
  52. package/dist/public/assets/messages-BsEqbtZD.js +1 -0
  53. package/dist/public/assets/messages-BuYjs7AI.js +1 -0
  54. package/dist/public/assets/messages-Cu2My5ex.js +1 -0
  55. package/dist/public/assets/messages-CzRLSOUe.js +1 -0
  56. package/dist/public/assets/messages-DxD6EViS.js +1 -0
  57. package/dist/public/assets/messages-ORxAvZuU.js +1 -0
  58. package/dist/public/assets/messages-Pop8iOQs.js +1 -0
  59. package/dist/public/assets/{pending-receive-nav-store-MCJgRMYe.js → pending-receive-nav-store-Dp-GJh6H.js} +1 -1
  60. package/dist/public/assets/{progress-DJjufkGx.js → progress-0bc15e77.js} +1 -1
  61. package/dist/public/assets/{selection-context-B8ZIL5JO.js → selection-context-QyOAcEgY.js} +1 -1
  62. package/dist/public/assets/{src-BElhG2ey.js → src-DhTYDBF3.js} +1 -1
  63. package/dist/public/assets/{telemetry-impl-G9GQmQGJ.js → telemetry-impl-8ZYvwPMn.js} +1 -1
  64. package/dist/public/assets/{telemetry-startup-CFqb8A-j.js → telemetry-startup-CyNQc5no.js} +1 -1
  65. package/dist/public/assets/{typing-burst-detector-ioDPbVRU.js → typing-burst-detector-CJQTOwN-.js} +1 -1
  66. package/dist/public/assets/{uninstall-DUwSv4xo.js → uninstall-D7J9l_Nx.js} +1 -1
  67. package/dist/public/assets/{use-activity-panel-L8e44D-R.js → use-activity-panel-mkYR166G.js} +1 -1
  68. package/dist/public/assets/{use-apply-config-language-B1_PbqOr.js → use-apply-config-language-CIgvKvgq.js} +2 -2
  69. package/dist/public/assets/{use-open-skill-CBFScxeq.js → use-open-skill-UUYljzC3.js} +1 -1
  70. package/dist/public/assets/{use-terminal-enabled-DJfeEdc9.js → use-terminal-enabled-D-QN86kl.js} +1 -1
  71. package/dist/public/assets/{use-timeline-entry-diff-C0-bJpxe.js → use-timeline-entry-diff-bJ09tm3c.js} +1 -1
  72. package/dist/public/index.html +19 -19
  73. package/dist/public/uninstall.html +3 -3
  74. package/dist/{registry-probes-DKj0WLeS.mjs → registry-probes-DckeILOy.mjs} +2 -2
  75. package/dist/{removal-file-path-DhT0omld.mjs → removal-file-path-BFu_FOlk.mjs} +1 -1
  76. package/dist/{repair-launch-json-CNzchJ8n.mjs → repair-launch-json-DMmLuuJS.mjs} +1 -1
  77. package/dist/{repair-mcp-configs-DaUjejVb.mjs → repair-mcp-configs-CuM0zUY4.mjs} +1 -1
  78. package/dist/src-CFwCZ01D.mjs +11 -0
  79. package/dist/src-CH-N8Aye.mjs +1 -0
  80. package/dist/start-BHgaCGiL.mjs +1 -0
  81. package/dist/{start-pHLrP0Fc.mjs → start-CJt2OxMi.mjs} +3 -3
  82. package/package.json +4 -4
  83. package/dist/constants-D-4RXqyQ.mjs +0 -1
  84. package/dist/init-F7KLTwk5.mjs +0 -1
  85. package/dist/loader-CtwQlMad.mjs +0 -1
  86. package/dist/preview-DlQPs5AD.mjs +0 -1
  87. package/dist/public/assets/FeedbackForm-BlgbTCeE.js +0 -1
  88. package/dist/public/assets/ManagedArtifactProperties-DVepOHzB.js +0 -1
  89. package/dist/public/assets/auth-state-cache-viUmuSBS.js +0 -11
  90. package/dist/public/assets/client-version-Dpo5n_gA.js +0 -1
  91. package/dist/public/assets/messages-8o9dkJJ8.js +0 -1
  92. package/dist/public/assets/messages-BApjWZBM.js +0 -1
  93. package/dist/public/assets/messages-BKwDlgqX.js +0 -1
  94. package/dist/public/assets/messages-BcN2AMRx.js +0 -1
  95. package/dist/public/assets/messages-BvWDj_ta.js +0 -1
  96. package/dist/public/assets/messages-C5r4coom.js +0 -1
  97. package/dist/public/assets/messages-CDBtIcly.js +0 -1
  98. package/dist/public/assets/messages-DToR3YWR.js +0 -1
  99. package/dist/public/assets/messages-DY_W63qi.js +0 -1
  100. package/dist/public/assets/messages-DaESnN9t.js +0 -1
  101. package/dist/public/assets/messages-DnLgXawv.js +0 -1
  102. package/dist/public/assets/messages-oUlW9lVw.js +0 -1
  103. package/dist/src-JVd8AAVk.mjs +0 -11
  104. package/dist/src-db54VFgM.mjs +0 -1
  105. package/dist/start-CMHGAxEf.mjs +0 -1
@@ -1,11 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{An as t,Bc as n,Eu as r,Hc as i,Ms as a,Pd as o,So as s,gc as c,jn as l,xs as u,zc as d,zn as ee}from"./md-manager-BGnqyqi1-BjukM0Wf.mjs";import{$a as f,$r as te,Ct as p,Do as m,Eo as h,Fn as g,Gn as _,Gr as v,Qr as y,To as b,Xi as x,Yn as S,Zr as C,cr as w,gi as T,hi as E,m as D,zr as O}from"./dist-CcOixwu-.mjs";import{t as k}from"./yazl-BBz29IQN.mjs";import{St as A,at as j,ot as M}from"./init-BS1jW1ap.mjs";import{b as N,l as ne}from"./registry-probes-DKj0WLeS.mjs";import{c as re}from"./colors-r_owlCuY.mjs";import{t as ie}from"./is-object-BGze3w87.mjs";import{n as ae}from"./constants-D-4RXqyQ.mjs";import"./loader-CL02d_x_.mjs";import"./preview-3wmj89l7.mjs";import{execSync as oe,spawnSync as P}from"node:child_process";import{basename as F,dirname as I,isAbsolute as se,join as L,relative as R,resolve as z,sep as B}from"node:path";import{closeSync as ce,cpSync as le,createWriteStream as ue,existsSync as V,lstatSync as de,mkdirSync as H,mkdtempSync as fe,openSync as pe,readFileSync as U,readSync as me,readdirSync as W,rmSync as G,rmdirSync as he,statSync as ge,writeFileSync as K}from"node:fs";import{arch as _e,freemem as ve,homedir as q,hostname as ye,platform as be,release as xe,tmpdir as Se,totalmem as Ce,type as we,uptime as Te}from"node:os";import"node:fs/promises";import{createHash as Ee}from"node:crypto";const De=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Oe(e,t,n=S){if(e!==void 0&&!De.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let ke=null;function Ae(e){ke=e}function je(){return ke??process.cwd()}const Me=`Open Knowledge`;function Ne(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return j(t).join(M({...e,platformName:t}),n)}function Pe(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=j(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,`@inkeepopen-knowledge-desktop-updater`)}function Fe(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 Ie(e){let t=L(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return Fe(n)??[]}function Le(e){let t=L(e,`state.json`);if(!V(t))return!1;try{return Fe(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const Re=8192;function ze(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 Be(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Ve=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function He(e){return e.replace(Ve,`$1"[REDACTED-DEVICE-ID]"`)}function Ue(e){return He(Be(e))}const We=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Ge(e){if(typeof e!=`string`)return null;let t=We.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 Ke(e){let t=pe(e,`r`);try{let e=Buffer.alloc(Re),n=0,r=!1;for(;n<Re;){let i=me(t,e,n,Re-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{ce(t)}}function qe(e){try{let t=Ke(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:Ge(a)}}catch{return{kind:`unreadable`}}}function Je(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Ye(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=W(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=L(e,t.name),r;try{r=ge(n).mtimeMs}catch{continue}if(r<i)continue;let c=qe(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Je(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`}}function J(){return L(q(),`.ok`,`bug-reports`)}function Xe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=J(),r=`${t}-bugreport`,i=L(n,`${r}.zip`);for(let e=2;V(i);e+=1)i=L(n,`${r}-${e}.zip`);return i}function Ze(e,t){let n=L(e,`.ok`,`config.yml`);if(V(n))try{let e=U(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 V(L(e,`.ok`))?Ee(`sha256`).update(z(e)).digest(`hex`).slice(0,12):null}function Qe(){let e={timestamp:new Date().toISOString(),platform:be(),osType:we(),osRelease:xe(),hostname:`[redacted]`,uptime:Te(),freeMem:ve(),totalMem:Ce(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=oe(`sw_vers -productVersion 2>/dev/null`,f({encoding:`utf8`})).trim()}catch{}try{let t=L(__dirname,`..`,`..`,`package.json`);V(t)&&(e.okVersion=JSON.parse(U(t,`utf8`)).version)}catch{}return e}const $e=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function et(e){let t=F(e);return $e.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function tt(e,t){return at(e,t).files}const nt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function rt(e,t=ne){let n=L(e,`${t}.ShipIt`);if(!V(n))return[];let r;try{r=W(n)}catch{return[]}return nt.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=>L(n,e.entry)))}function it(e){if(!V(e))return[];try{let n=new Map;for(let r of W(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=r.endsWith(`.sent.yaml`)?r.slice(0,-t.length):r.slice(0,-5),i=n.get(e);i===void 0?n.set(e,[r]):i.push(r)}return[...n.values()].slice(-25).flat().map(t=>L(e,t))}catch{return[]}}function at(e,t){if(!V(t))return{files:[],excludedByProjectSlug:0};let n=W(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>L(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(et),i=[],a=r.filter(t=>{try{return U(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=>!et(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function ot(e){let t=L(e,`.ok`,`local`);return V(t)?{files:[`server.lock`,`last-spawn-error.log`,d].map(e=>L(t,e)).filter(e=>V(e))}:{files:[]}}function st(e){let t=L(e,`.ok`,`local`,`logs`);return V(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>L(t,e)).filter(e=>V(e))}:{files:[]}}function ct(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#${Ee(`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 lt(e){let t=e.revealDocNames?e.content:ct(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=u(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 Y(e){for(let t of e.files)try{let n=U(t,`utf8`);lt({zipfile:e.zipfile,name:`${e.prefix}/${F(t)}`,content:t.endsWith(`.ips`)?Ue(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 ut(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??L(q(),`.ok`,`logs`),s=t.projectDir?Ze(t.projectDir,i):null;H(I(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=Qe();c.desktop=t.desktop??null,c.language=t.language??null;let{files:u,excludedByProjectSlug:d}=at(s,o),{files:f}=t.projectDir?ot(t.projectDir):{files:[]},{files:te}=t.projectDir?st(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:u.length,logFilesExcludedByProjectSlug:d,lockFileCount:f.length,localSinkFileCount:te.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 _;Y({zipfile:v,files:[...u,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:f,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:te,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:l,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({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=U(e.sourcePath),n=`extra/${e.zipName??F(e.sourcePath)}`;v.addBuffer(t,n),g.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&lt({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/${F(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:ze(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`);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/${F(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${l}/${F(e)}`)),O=g.filter(e=>D.has(e)),k=s?g.filter(e=>e.startsWith(`logs/`)&&!et(e)&&!T.has(e)):[],A=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.`]:[],j=A.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...A]:[`Redaction was disabled for this bundle; file contents are unmodified.`],M=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...k.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:`,...k.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}`),``]:[],...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.`,...A,``,`This bundle is safe to attach to a GitHub issue.`]:j].join(`
2
- `);v.addBuffer(Buffer.from(M,`utf8`),`README.md`),v.end();let N=ue(r);return v.outputStream.pipe(N),await new Promise((e,t)=>{N.on(`close`,e),N.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 dt=r(),ft=e(k(),1),X=e(re(),1);function pt(e){let t=m(`user`,e,e);return b({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function mt({home:e=q(),env:t=process.env}={}){let n=pt(e),{override:r,preferenceList:o}=h(t),{locale:s,source:l}=a({override:r,storedPreference:n,supportedLocales:i,preferenceList:o,autoDetectableLocales:c});return{preference:n,locale:s,source:l,systemLanguages:o}}function ht(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function gt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _t(e,t){if(typeof e==`string`)return ht(e,t.contentDir);if(Array.isArray(e))return e.map(e=>_t(e,t));if(!gt(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=_t(i,t);return n}function vt(e,t){let n=U(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
3
- `),i=n.split(`
4
- `),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=_t(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
5
- `)}\n`:a.join(`
6
- `);K(e,o)}function yt(e,t){let n=U(e,`utf-8`);if(n.trim().length!==0)try{let r=_t(JSON.parse(n),t),i=n.endsWith(`
7
- `)?`
8
- `:``;K(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=ht(n,t.contentDir);r!==n&&K(e,r)}}function bt(e,t){let n=U(e,`utf-8`),r=ht(n,t.contentDir);r!==n&&K(e,r)}function xt(e){try{return W(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>L(e,t.name))}catch{return[]}}const St=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Ct(e){return/\.log\.\d+$/.test(e)}function wt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Ct(e)}const Tt=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Et(e){let t={contentDir:e.contentDir};for(let n of Tt)for(let r of xt(L(e.stagingDir,n)))wt(r)?vt(r,t):r.endsWith(`.json`)?yt(r,t):bt(r,t);for(let n of xt(L(e.stagingDir,`state`))){let e=F(n);n.endsWith(`.jsonl`)?vt(n,t):St.has(e)?yt(n,t):bt(n,t)}}const Dt=[`.ok`,`local`,`telemetry`],Ot=[`.ok`,`local`,`logs`],kt=[`.ok`,`local`,`loss-capture`],At=`spans-current.jsonl`,jt=`spans-prev.jsonl`,Mt=`server-current.jsonl`,Nt=`server-prev.jsonl`,Pt=`loss-current.jsonl`,Ft=`loss-prev.jsonl`;function It(e){return L(e,...Dt,At)}function Lt(e){return L(e,...Dt,jt)}function Rt(e){return L(e,...Ot,Mt)}function zt(e){return L(e,...Ot,Nt)}function Bt(e){return L(e,...kt,Pt)}function Vt(e){return L(e,...kt,Ft)}const Ht=1e3;async function Ut(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Ht)});return t.ok?await t.text():null}catch{return null}}async function Wt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Ht)});return t.ok?await t.text():null}catch{return null}}async function Gt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Ht)});return t.ok?await t.text():null}catch{return null}}function Kt(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(`
9
- `)}\n`:null}catch{return null}}function qt(e){let t=L(e,`.git`,`ok`);if(!V(t))return null;let n=P(`git`,[`-C`,t,`log`,`--oneline`,`-50`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Jt(e){let t=L(e,`.git`,`ok`);if(!V(t))return null;let n=P(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Yt(){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 Xt(){return{nodeVersion:process.version,platform:be(),arch:_e()}}function Zt(){return process.env.OTEL_SDK_DISABLED===`false`}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Qt(e){if(!V(e))return{};let t;try{t=(0,dt.parse)(U(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(!Z(t))return{};let n=t.telemetry;if(!Z(n))return{};let r=n.localSink;return Z(r)?r:{}}function $t(e){return typeof e==`boolean`?e:void 0}function en(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function tn(e){if(Z(e))return en(e.maxBytes)}function nn(e){let t=Qt(m(`project`,e)),n=Qt(m(`project-local`,e));return{enabled:$t(n.enabled)??$t(t.enabled)??!0,spansMaxBytes:tn(n.spans)??tn(t.spans)??52428800,logsMaxBytes:tn(n.logs)??tn(t.logs)??26214400}}function rn(e){return Ee(`sha256`).update(e).digest(`hex`)}function an(e){let t=U(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const on=[`"doc.name"`,`"docName"`];function sn(e){let t=U(e,`utf-8`),n=0;for(let e of on){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!V(e))return!1;try{return H(I(t),{recursive:!0}),e.endsWith(`.ips`)?K(t,Ue(U(e,`utf-8`))):le(e,t),!0}catch{return!1}}function cn(e){let t=[],n=e=>{let r=W(e,{withFileTypes:!0});for(let i of r){let r=L(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const ln=new Set([`.jsonl`]);function un(e){let t=e.lastIndexOf(`.`);return t!==-1&&ln.has(e.slice(t))}const dn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function fn(e){if(Ct(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&dn.has(e.slice(t))}function pn(e){let t=[];for(let n of cn(e)){let r=mn(e,n);if(!fn(r))continue;let{redacted:i,patterns:a,lineCount:o}=u(U(n,`utf-8`));a.length!==0&&(K(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function mn(e,t){return R(e,t).split(B).join(`/`)}async function hn(e){let t=z(e.contentDir),r=z(e.projectDir??e.contentDir),i=e.deps??{},a=i.fetchAgentPresence??Ut,o=i.fetchAgentEffects??Wt,s=i.fetchWatcherRecent??Gt,c=i.readShadowHead??qt,u=i.readCheckpointRefs??Jt,ee=i.now??(()=>new Date),f=i.okVersion??(()=>ae),te=i.readDesktopEnv??Yt,p=i.readLanguage??mt,m=i.readRuntime??Xt,h=i.isOtlpPushEnabled??Zt,g=fe(L(Se(),`ok-bundle-`));try{H(L(g,`telemetry`),{recursive:!0}),H(L(g,`logs`),{recursive:!0}),H(L(g,`state`),{recursive:!0}),Q(It(r),L(g,`telemetry`,At)),Q(Lt(r),L(g,`telemetry`,jt)),Q(Rt(r),L(g,`logs`,Mt)),Q(zt(r),L(g,`logs`,Nt));for(let t of e.userLogFiles??[])Q(t,L(g,`logs`,F(t)));for(let t of e.userStateFiles??[])Q(t,L(g,l,F(t)));let _=0;for(let t of e.diagnosticReports?.files??[])Q(t,L(g,`diagnostic-reports`,F(t)))&&(_+=1);let v=L(r,`.ok`,`local`),y=L(v,`server.lock`),b=`not-running`,x=`no server.lock`,S=null;if(V(y)){Q(y,L(g,`state`,`server.lock`));try{let e=U(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?S=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(S!==null){let e=await a(S);e===null?x=`agent-presence endpoint at :${S} unreachable`:(K(L(g,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await o(S);t!==null&&K(L(g,`state`,`agent-effects.json`),t);let n=await s(S);if(n!==null){let e=Kt(n);e!==null&&K(L(g,`state`,`watcher-recent.jsonl`),e)}}let C=c(t);C!==null&&K(L(g,`state`,`shadow-head.txt`),C);let w=u(t);w!==null&&K(L(g,`state`,`checkpoint-refs.txt`),w),Q(Bt(r),L(g,`state`,Pt)),Q(Vt(r),L(g,`state`,Ft)),Q(L(v,`last-spawn-error.log`),L(g,`state`,`last-spawn-error.log`)),Q(L(v,n),L(g,`state`,n)),Q(L(v,d),L(g,`state`,d));let T=m(),E=te(),D=p(),O={ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D}};K(L(g,`state`,`runtime.json`),`${JSON.stringify(O,null,2)}\n`);let k=b===`running`?`running
10
- `:`not-running (${x})\n`;K(L(g,`state`,`server-status.txt`),k);let A=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:ze(e.diagnosticReports,_);if(K(L(g,`state`,`diagnostic-reports-status.txt`),`${A}\n`),e.processDir&&V(e.processDir)){let t=L(g,`process`);H(t,{recursive:!0}),le(e.processDir,t,{recursive:!0})}let j=e.redact===!0;j&&Et({stagingDir:g,contentDir:t}),e.note&&K(L(g,`note.txt`),e.note);let M=null;e.scrubSecrets===!0&&(M=pn(g));for(let t of e.extraFiles??[])Q(t.sourcePath,L(g,`extra`,t.zipName??F(t.sourcePath)))||i.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let N=nn(r),ne=cn(g),re=[],ie=0,ae=0;for(let e of ne){let t=mn(g,e),n=ge(e).size,r=un(t)?an(e):0;re.push({path:t,bytes:n,lines:r}),ie+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(ae+=sn(e))}let oe={applied:j};M!==null&&(oe.secretScrub=M);let P={schemaVersion:2,createdAt:ee().toISOString(),ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D},contentDir:{pathSha256:rn(t),absolutePath:j?`<CONTENT_DIR>`:t},telemetry:{localSink:N,otlpPushEnabled:h()},redaction:oe,serverStatus:b,files:re};K(L(g,`manifest.json`),`${JSON.stringify(P,null,2)}\n`);let I=ne.some(e=>{try{return U(e,`utf-8`).includes(t)}catch{return!1}}),se={stagedDiagnosticReports:_,totalBytes:ie,fileCount:re.length,docNameCount:ae,contentDirVisible:I,redacted:j},R=!1;return{stagingDir:g,manifest:P,summary:se,cleanup:()=>{R||(R=!0,G(g,{recursive:!0,force:!0}))}}}catch(e){throw G(g,{recursive:!0,force:!0}),e}}async function gn(e){let{collected:t,outputPath:n}=e,r=I(n);if(!V(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new ft.ZipFile,a=cn(t.stagingDir);for(let e of a){let n=mn(t.stagingDir,e);i.addFile(e,n)}i.end();let o=ue(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 _n(e,t){let n=L(e,`.ok`,`config.yml`);if(V(n))try{let t=(0,dt.parse)(U(n,`utf-8`)),r=ie(t)?t.content:void 0,i=ie(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return z(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 z(e)}async function vn(e,t,n,r,i){let a=Ze(t,e.logger),o=await hn({contentDir:_n(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...tt(a,e.userLogsDir??L(q(),`.ok`,`logs`)),...rt(e.cachesDir??L(q(),`Library`,`Caches`))],userStateFiles:it(e.bugReportsDir??J()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{H(I(e.outputPath),{recursive:!0}),await gn({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function yn(e){let{projectDir:t}=e,n=e.readDesktopEnv??Yt,r=e.readLanguage??mt,i=()=>Ye(e.diagnosticReportsDir??L(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return vn(e,t,n,r,i());let{zipPath:a,summary:o}=await ut({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:rt(e.cachesDir??L(q(),`Library`,`Caches`)),bugReportLedgerFiles:it(e.bugReportsDir??J()),diagnosticReports:e.level===`full`?i():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=te(e,t),i;try{i=U(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??ye());if(!a||typeof a!=`object`||!v(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??O)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function bn(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 xn(e){return e.replace(/:\d+$/,``)}function Sn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:xn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:xn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:xn(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 Cn=[{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`}],wn=[...p.map(e=>D[e]),`open-knowledge`];function Tn(e){if(!se(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=z(e);if(t===B||I(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function En(e,t){let n=R(e,t);if(n.startsWith(`..`)||se(n))return!1;let r=e;for(let e of n.split(B)){r=L(r,e);try{if(!de(r).isDirectory())return!1}catch{return!1}}return!0}function Dn(e,t){try{return W(e).every(n=>t.has(L(e,n)))}catch{return!1}}function On(e){let t=Tn(e),n=[],r=[],i=new Set;for(let e of Cn){let a=L(t,e.hostDir,`skills`);if(!En(t,a))continue;let o=wn.map(e=>L(a,e)).filter(e=>V(e));n.push(...o);for(let e of o)i.add(e);let s=L(t,e.pruneRoot),c=a;for(;Dn(c,i)&&(r.push(c),i.add(c),c!==s);){let e=I(c);if(e===c||e===t||!e.startsWith(t+B))break;c=e}}return{skillDirs:n,emptyDirs:r}}function kn(e){try{if(!de(e).isDirectory())return!1;let t=W(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function An(e){let t=new Set,n=new Set;for(let r of Cn){let i=L(e,r.hostDir,`skills`);for(let e of wn)t.add(L(i,e));let a=L(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=I(o);if(t===o||t===e||!t.startsWith(e+B))break;o=t}}return{skillDirs:t,emptyDirs:n}}function jn(e,t){let n=Tn(e),r=An(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(En(n,e)&&kn(e))try{G(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(En(n,e))try{he(e),a.push(e)}catch{}return a}function Mn(e){let t=Tn(e),n=[];for(let e of p){let r=D[e];n.push({path:L(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of o)n.push({path:L(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Nn(e,t){let n=[];for(let r of Mn(e))if(r.bundleId===t)try{G(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 Pn(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Fn(e,t=Date.now()){if(e===null)return`—`;let n=s(e,t);return n===`unknown`?`—`:n}function In(e){let t=I(e);return F(e)===`local`&&F(t)===`.ok`?I(t):F(e)===`.ok`?t:null}function Ln(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:In(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`&&C(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:_(n),command:n,isDesktop:Pn(n)}}function Rn(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 zn=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Bn(e){switch(e){case`running`:return X.default.green(e);case`desktop`:return X.default.blue(e);case`foreign`:return X.default.cyan(e);case`unverified`:case`stale`:return X.default.yellow(e)}}function Vn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Hn(e){return`${Vn(e.server.usage)} | ${Vn(e.ui?.usage??null)}`}function Un(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Wn(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??`—`,Un(e),Hn(e),Rn(e),String(e.server.pid),Fn(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=Bn(Rn(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=X.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
11
- `)}async function Gn(e={}){let t=e.discover??g,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??E,a=e.resolveUsage??T,o=await t(),s=[];for(let e of o){let t=n(e),r=Ln(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:Rn(e)}));r(JSON.stringify(e,null,2));return}r(Wn(e.all?s:s.filter(e=>zn.has(Rn(e)))))}function Kn(){return new A(`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 Gn({all:t.all===!0||e===`all`,json:t.json===!0})})}async function qn(e,t=N()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=y(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 Jn(e,t={}){return{targets:Xn(e,t.isAlive??O)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function Yn(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??qn,o=e.logger??N(),s=Jn(t(),{isAlive:e.isAlive});if(s.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};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:s.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let c=[],l=[];for(let e of s.targets)try{n(e.pid,`SIGTERM`),c.push(e)}catch(t){l.push({target:e,error:t instanceof Error?t.message:String(t)})}return c.length>0&&r(`Stopped: ${c.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:c.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:l.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),l.length>0&&i(`Failed to stop: ${l.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:c,failed:l,hadTargets:!0}}function Xn(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function Zn(e,t=O){let n=await g(),r=null;for(let i of n){let n=$(i,`server`);if(Xn(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function Qn(e,t){let n=await Yn({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function $n(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 er(e){let t=await g(),n=0;for(let r of t)r!==e&&Xn($(r,`server`),O)&&n++;return n}function tr(e){return new A(`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 editor windows or agents are still connected to the server`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=x(process.cwd()),n=await Yn({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 er(t);console.log($n(process.cwd(),e,{listingFollows:e>0})),e>0&&await Gn({})}return}if(i===`all`){let e=await g();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)Xn($(n,`server`),O)&&(await Qn(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 Zn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await Qn(t,r);return}let a=z(je(),i),o=x(a),s=[],c=await Yn({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($n(a,await er(o)))})}export{Le as C,Oe as E,Ie as S,Ae as T,Ye as _,jn as a,Pe as b,Mn as c,$ as d,yn as f,J as g,Xe as h,Kn as i,Sn as l,gn as m,Yn as n,On as o,hn as p,tr as r,Nn as s,qn as t,bn as u,ze as v,je as w,Ne as x,Me as y};
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-BjukM0Wf.mjs";import"./init-BS1jW1ap.mjs";import"./registry-probes-DKj0WLeS.mjs";import"./src-JVd8AAVk.mjs";import"./start-pHLrP0Fc.mjs";import{n as e}from"./loader-CL02d_x_.mjs";import"./preview-3wmj89l7.mjs";import"./cli.mjs";import"./repair-mcp-configs-DaUjejVb.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{S as e,m as t,p as n,r}from"./start-pHLrP0Fc.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};