@inkeep/open-knowledge 0.69.0-beta.6 → 0.69.0-beta.8

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 (112) hide show
  1. package/dist/cli.mjs +33 -33
  2. package/dist/constants-C2Waxo4E.mjs +1 -0
  3. package/dist/dist-B_lhaeFJ.mjs +2096 -0
  4. package/dist/dist-CJ5qX39u.mjs +1 -0
  5. package/dist/index.mjs +1 -1
  6. package/dist/init-AV62II7K.mjs +1 -0
  7. package/dist/{init-YoVVaWK0.mjs → init-CoCCZEvS.mjs} +26 -26
  8. package/dist/{launch-json-removal-BaySWdca.mjs → launch-json-removal-DOsPqTe0.mjs} +1 -1
  9. package/dist/{loader-CsbLLAav.mjs → loader-B0EV14F-.mjs} +1 -1
  10. package/dist/loader-BJKo02P9.mjs +1 -0
  11. package/dist/{open-browser-rcp8z_R5.mjs → open-browser-CdtzidpR.mjs} +1 -1
  12. package/dist/preview-BFGhI49k.mjs +1 -0
  13. package/dist/{preview-C6QTJ0V1.mjs → preview-BWs_Rq1J.mjs} +1 -1
  14. package/dist/public/assets/{ActivityModeContent-BWxFxGGm.js → ActivityModeContent-CximtPXo.js} +1 -1
  15. package/dist/public/assets/{AddPropertiesButton-BadjM61v.js → AddPropertiesButton-CLAxY4Kp.js} +1 -1
  16. package/dist/public/assets/{AgentDiffPane-BN45FrUF.js → AgentDiffPane-CZ6Irl2N.js} +1 -1
  17. package/dist/public/assets/{CodeMirrorPropInput-ZmCpFv-f.js → CodeMirrorPropInput-DyT36_0H.js} +1 -1
  18. package/dist/public/assets/{DocumentContext-p9iubtSb.js → DocumentContext-DS_dUWBr.js} +1 -1
  19. package/dist/public/assets/{EditorModeToggle-Bf9f_Cka.js → EditorModeToggle-Nq_bPbVL.js} +1 -1
  20. package/dist/public/assets/{EnableSyncConfirmDialog-BE-l5JaR.js → EnableSyncConfirmDialog-N-3Oe5uz.js} +1 -1
  21. package/dist/public/assets/{ExcalidrawDocEditor-BUalQW1N.js → ExcalidrawDocEditor-C-NOBDVO.js} +1 -1
  22. package/dist/public/assets/FeedbackForm-Cbz8L9V-.js +1 -0
  23. package/dist/public/assets/{ImportSkillDialog-BUsdhD5G.js → ImportSkillDialog-BASlWroD.js} +1 -1
  24. package/dist/public/assets/{LintConfigEditor-Chet4uSf.js → LintConfigEditor-BL1ZjbK7.js} +1 -1
  25. package/dist/public/assets/ManagedArtifactProperties-1Jje2JUZ.js +1 -0
  26. package/dist/public/assets/{ManagedArtifactProperties--dbkaZZS.js → ManagedArtifactProperties-E5_ddR_p.js} +1 -1
  27. package/dist/public/assets/{MermaidDocEditor-CVwp7Wkq.js → MermaidDocEditor-DE4hSQJD.js} +1 -1
  28. package/dist/public/assets/{PropertyDisplayRow-BnSF_nD0.js → PropertyDisplayRow-B3v_6w4O.js} +1 -1
  29. package/dist/public/assets/{SchemaConfigEditor-BlEpNNfc.js → SchemaConfigEditor-DlZbi0BH.js} +1 -1
  30. package/dist/public/assets/{SessionsHost-BZQLiJFM.js → SessionsHost-Df5IVb6O.js} +2 -2
  31. package/dist/public/assets/SettingsDialogBody-BOCtv6zl.js +12 -0
  32. package/dist/public/assets/{ShareReceiveMissDialog-F6AN6RMT.js → ShareReceiveMissDialog-CrjCM6hU.js} +1 -1
  33. package/dist/public/assets/{SkillInstallMenu-DcpgYBfx.js → SkillInstallMenu-CVK9zId1.js} +1 -1
  34. package/dist/public/assets/{SkillToolbarControls-ygJqOWDY.js → SkillToolbarControls-CMvIOhEL.js} +1 -1
  35. package/dist/public/assets/{SourceEditor-DifRL8Lk.js → SourceEditor-C74huF53.js} +1 -1
  36. package/dist/public/assets/{TerminalWindowApp-B_aTZooW.js → TerminalWindowApp-BusqUG6y.js} +1 -1
  37. package/dist/public/assets/{TextDocEditor-BuRV3Akr.js → TextDocEditor-LT7YyAwm.js} +1 -1
  38. package/dist/public/assets/{ThreadView-CYJcuPjR.js → ThreadView-CMGgpD7W.js} +1 -1
  39. package/dist/public/assets/{TimelineDiffPane-29zdxEjP.js → TimelineDiffPane-Bv8dQirf.js} +1 -1
  40. package/dist/public/assets/{agent-diff-store-Rb8akV6K.js → agent-diff-store-Cle15UKh.js} +1 -1
  41. package/dist/public/assets/{auth-state-cache-Cop0NQF5.js → auth-state-cache-qvH-oSfq.js} +1 -1
  42. package/dist/public/assets/{comment-chips-BWKl9VbL.js → comment-chips-vgbpHTuL.js} +1 -1
  43. package/dist/public/assets/{config-provider-Bobp4tNz.js → config-provider-Ck1DNDm7.js} +3 -3
  44. package/dist/public/assets/{doc-undo-manager-BkpuyXL8.js → doc-undo-manager-VvINx_vq.js} +1 -1
  45. package/dist/public/assets/globals-D927wlz4.css +1 -0
  46. package/dist/public/assets/i18n-LLIw89QS.js +1 -0
  47. package/dist/public/assets/{index-BpD4iquV.js → index-IpcP5FTX.js} +121 -121
  48. package/dist/public/assets/messages-BjR7N346.js +1 -0
  49. package/dist/public/assets/messages-Bms9ZCX3.js +1 -0
  50. package/dist/public/assets/messages-BvsAGBeC.js +1 -0
  51. package/dist/public/assets/messages-Bx4IehS7.js +1 -0
  52. package/dist/public/assets/messages-C3zAHKSk.js +1 -0
  53. package/dist/public/assets/messages-CR_I7Cp3.js +1 -0
  54. package/dist/public/assets/messages-CUzLexij.js +1 -0
  55. package/dist/public/assets/{messages-DU7DEoSn.js → messages-CX2LIRPQ.js} +1 -1
  56. package/dist/public/assets/messages-DGVl_E7x.js +1 -0
  57. package/dist/public/assets/messages-GcLNaJaR.js +1 -0
  58. package/dist/public/assets/messages-c4jjA_8H.js +1 -0
  59. package/dist/public/assets/messages-zMV5QHq9.js +1 -0
  60. package/dist/public/assets/{pending-receive-nav-store-DjuEU1dx.js → pending-receive-nav-store-X1voDf8F.js} +1 -1
  61. package/dist/public/assets/{progress-BNLzMM8p.js → progress-tXfeh49A.js} +1 -1
  62. package/dist/public/assets/{selection-context-CCdILpgG.js → selection-context-VgoGxndZ.js} +1 -1
  63. package/dist/public/assets/{src-DYP6p7XJ.js → src-_s2f2_6g.js} +1 -1
  64. package/dist/public/assets/{typing-burst-detector-jlncpstJ.js → typing-burst-detector-BIDnBCHc.js} +1 -1
  65. package/dist/public/assets/{uninstall-DJEPJuYD.js → uninstall-BPhdiudT.js} +1 -1
  66. package/dist/public/assets/{use-activity-panel-BfeDPTx4.js → use-activity-panel-0Kzpvkwn.js} +1 -1
  67. package/dist/public/assets/{use-open-skill-Df4qaz_1.js → use-open-skill-CCmJFvMI.js} +1 -1
  68. package/dist/public/assets/{use-terminal-enabled-BaXGNHQv.js → use-terminal-enabled-BlfoUmdn.js} +1 -1
  69. package/dist/public/assets/{use-timeline-entry-diff-Bvz88F3c.js → use-timeline-entry-diff-BUFMqeVp.js} +1 -1
  70. package/dist/public/index.html +22 -22
  71. package/dist/public/uninstall.html +5 -5
  72. package/dist/{registry-probes-B_EoML_h.mjs → registry-probes-B_UapTQA.mjs} +5 -5
  73. package/dist/{repair-launch-json-DcTw2dub.mjs → repair-launch-json-I0JPbY-j.mjs} +1 -1
  74. package/dist/{repair-mcp-configs-ngiQYYLV.mjs → repair-mcp-configs-CHDcjBGn.mjs} +1 -1
  75. package/dist/src-BVPWIiic.mjs +11 -0
  76. package/dist/src-e37AQ3jI.mjs +1 -0
  77. package/dist/{start-C201LWw_.mjs → start-CV9e5XLw.mjs} +3 -3
  78. package/dist/start-DtlPjkSc.mjs +1 -0
  79. package/package.json +4 -4
  80. package/dist/constants-DAaEKppY.mjs +0 -1
  81. package/dist/dist-BfGPmTI1.mjs +0 -2096
  82. package/dist/dist-Ct3NR8HA.mjs +0 -1
  83. package/dist/init-DwykpnKC.mjs +0 -1
  84. package/dist/loader-Crone-E4.mjs +0 -1
  85. package/dist/native/native-config.darwin-arm64.node +0 -0
  86. package/dist/native/native-config.darwin-x64.node +0 -0
  87. package/dist/native/native-config.linux-arm64-gnu.node +0 -0
  88. package/dist/native/native-config.linux-arm64-musl.node +0 -0
  89. package/dist/native/native-config.linux-x64-musl.node +0 -0
  90. package/dist/native/native-config.win32-arm64-msvc.node +0 -0
  91. package/dist/native/native-config.win32-x64-msvc.node +0 -0
  92. package/dist/preview-CeWz5LS0.mjs +0 -1
  93. package/dist/public/assets/FeedbackForm-C7zXglFh.js +0 -1
  94. package/dist/public/assets/ManagedArtifactProperties-BtFB2kBJ.js +0 -1
  95. package/dist/public/assets/SettingsDialogBody-BIC3dqR8.js +0 -12
  96. package/dist/public/assets/globals-DVivVCS3.css +0 -1
  97. package/dist/public/assets/i18n-SN-8kqTh.js +0 -1
  98. package/dist/public/assets/messages--WqeRw6M.js +0 -1
  99. package/dist/public/assets/messages--zDRXDo0.js +0 -1
  100. package/dist/public/assets/messages-BVlrnlqc.js +0 -1
  101. package/dist/public/assets/messages-BnR3EYKP.js +0 -1
  102. package/dist/public/assets/messages-CYl2uOxc.js +0 -1
  103. package/dist/public/assets/messages-Cr6C9Hnr.js +0 -1
  104. package/dist/public/assets/messages-CtXBW2rM.js +0 -1
  105. package/dist/public/assets/messages-Ct_698ZS.js +0 -1
  106. package/dist/public/assets/messages-D5gWjKGT.js +0 -1
  107. package/dist/public/assets/messages-PX4xpaZF.js +0 -1
  108. package/dist/public/assets/messages-qzoc5iXP.js +0 -1
  109. package/dist/src-BrwhU5af.mjs +0 -1
  110. package/dist/src-Dfw-4H6Q.mjs +0 -11
  111. package/dist/start-CZAA0gtK.mjs +0 -1
  112. /package/dist/public/assets/{globals-2sss1K50.js → globals-BoP7p4Dy.js} +0 -0
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-Eez8IlhB.mjs";import"./init-YoVVaWK0.mjs";import"./src-Dfw-4H6Q.mjs";import"./registry-probes-B_EoML_h.mjs";import"./start-C201LWw_.mjs";import{n as e}from"./loader-CsbLLAav.mjs";import"./preview-C6QTJ0V1.mjs";import"./cli.mjs";import"./repair-mcp-configs-ngiQYYLV.mjs";export{e as loadConfig};
@@ -1,11 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$u as t,Bs as n,Dn as r,Gl as i,In as a,On as o,ac as s,ic as c,lo as l,ns as u,ps as ee,sc as te}from"./md-manager-BGnqyqi1-Eez8IlhB.mjs";import{$i as d,Do as f,Eo as p,Hr as m,Jn as h,Jr as g,Oo as _,Qn as v,Rn as y,Tt as b,dr as x,ei as S,m as C,ni as w,ti as T,to as E,vi as D,wn as O,yi as k}from"./dist-BfGPmTI1.mjs";import{t as A}from"./yazl-BBz29IQN.mjs";import{ht as j,nt as M,rt as N}from"./init-YoVVaWK0.mjs";import{c as ne}from"./colors-r_owlCuY.mjs";import{l as P}from"./registry-probes-B_EoML_h.mjs";import{t as re}from"./is-object-BGze3w87.mjs";import{n as ie}from"./constants-DAaEKppY.mjs";import"./loader-CsbLLAav.mjs";import"./preview-C6QTJ0V1.mjs";import{execSync as ae,spawnSync as oe}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";let De;function Oe(){return De}function ke(e,t){if(t!==void 0&&t.length>0)return t;try{return v(e)?.rootPath}catch{return}}function Ae(e){let t=ke(e.cwd,e.configuredProjectName),n=O({name:`cli`,project:t});return De=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}const je=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Me(e,t,n=v){if(e!==void 0&&!je.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ne=null;function Pe(e){Ne=e}function Fe(){return Ne??process.cwd()}const Ie=`Open Knowledge`;function Le(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return M(t).join(N({...e,platformName:t}),n)}function Re(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=M(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 ze(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 Be(e){let t=L(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return ze(n)??[]}function Ve(e){let t=L(e,`state.json`);if(!V(t))return!1;try{return ze(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const He=8192;function Ue(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 We(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Ge=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function Ke(e){return e.replace(Ge,`$1"[REDACTED-DEVICE-ID]"`)}function qe(e){return Ke(We(e))}const Je=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Ye(e){if(typeof e!=`string`)return null;let t=Je.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 Xe(e){let t=pe(e,`r`);try{let e=Buffer.alloc(He),n=0,r=!1;for(;n<He;){let i=me(t,e,n,He-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 Ze(e){try{let t=Xe(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:Ye(a)}}catch{return{kind:`unreadable`}}}function Qe(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function $e(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=Ze(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Qe(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 et(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 tt(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 nt(){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=ae(`sw_vers -productVersion 2>/dev/null`,E({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 rt=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function it(e){let t=F(e);return rt.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function at(e,t){return lt(e,t).files}const ot=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function st(e,t=P){let n=L(e,`${t}.ShipIt`);if(!V(n))return[];let r;try{r=W(n)}catch{return[]}return ot.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 ct(e){if(!V(e))return[];try{let t=new Map;for(let n of W(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-r.length):n.slice(0,-5),i=t.get(e);i===void 0?t.set(e,[n]):i.push(n)}return[...t.values()].slice(-25).flat().map(t=>L(e,t))}catch{return[]}}function lt(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(it),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=>!it(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function ut(e){let t=L(e,`.ok`,`local`);return V(t)?{files:[`server.lock`,`last-spawn-error.log`,c].map(e=>L(t,e)).filter(e=>V(e))}:{files:[]}}function dt(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 ft(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 pt(e){let t=e.revealDocNames?e.content:ft(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`);pt({zipfile:e.zipfile,name:`${e.prefix}/${F(t)}`,content:t.endsWith(`.ips`)?qe(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 mt(t){let{redact:n,outputPath:r,logger:i}=t,s=t.revealDocNames??!1,c=t.userLogsDir??L(q(),`.ok`,`logs`),l=t.projectDir?tt(t.projectDir,i):null;H(I(r),{recursive:!0}),i?.info({projectSlug:l},`gathering diagnostic data`);let u=nt();u.desktop=t.desktop??null,u.language=t.language??null;let{files:ee,excludedByProjectSlug:te}=lt(l,c),{files:d}=t.projectDir?ut(t.projectDir):{files:[]},{files:f}=t.projectDir?dt(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:ee.length,logFilesExcludedByProjectSlug:te,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 _;Y({zipfile:v,files:[...ee,...p],prefix:`logs`,redact:n,revealDocNames:s,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:d,prefix:`lockdir`,redact:n,revealDocNames:s,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:f,prefix:`local-logs`,redact:n,revealDocNames:s,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:o,redact:n,revealDocNames:s,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:s,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&&pt({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:s,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)`:Ue(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(u,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:l,files:g,redactions:h,sysinfo:u};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=>`${o}/${F(e)}`)),O=g.filter(e=>D.has(e)),k=l?g.filter(e=>e.startsWith(`logs/`)&&!it(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: ${l??`(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: ${a.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:l,files:g,redactions:h,redactedLineCount:w,generatedAt:C.generatedAt}}}var ht=i(),gt=e(A(),1),X=e(ne(),1);function _t(e){let t=_(`user`,e,e);return p({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function vt({home:e=q(),env:t=process.env}={}){let r=_t(e),{override:i,preferenceList:a}=f(t),{locale:o,source:s}=ee({override:i,storedPreference:r,supportedLocales:te,preferenceList:a,autoDetectableLocales:n});return{preference:r,locale:o,source:s,systemLanguages:a}}function yt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function bt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e,t){if(typeof e==`string`)return yt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>Z(e,t));if(!bt(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Z(i,t);return n}function xt(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=Z(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 St(e,t){let n=U(e,`utf-8`);if(n.trim().length!==0)try{let r=Z(JSON.parse(n),t),i=n.endsWith(`
7
- `)?`
8
- `:``;K(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=yt(n,t.contentDir);r!==n&&K(e,r)}}function Ct(e,t){let n=U(e,`utf-8`),r=yt(n,t.contentDir);r!==n&&K(e,r)}function wt(e){try{return W(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>L(e,t.name))}catch{return[]}}const Tt=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Et(e){return/\.log\.\d+$/.test(e)}function Dt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Et(e)}const Ot=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function kt(e){let t={contentDir:e.contentDir};for(let n of Ot)for(let r of wt(L(e.stagingDir,n)))Dt(r)?xt(r,t):r.endsWith(`.json`)?St(r,t):Ct(r,t);for(let n of wt(L(e.stagingDir,`state`))){let e=F(n);n.endsWith(`.jsonl`)?xt(n,t):Tt.has(e)?St(n,t):Ct(n,t)}}const At=[`.ok`,`local`,`telemetry`],jt=[`.ok`,`local`,`logs`],Mt=[`.ok`,`local`,`loss-capture`],Nt=`spans-current.jsonl`,Pt=`spans-prev.jsonl`,Ft=`server-current.jsonl`,It=`server-prev.jsonl`,Lt=`loss-current.jsonl`,Rt=`loss-prev.jsonl`;function zt(e){return L(e,...At,Nt)}function Bt(e){return L(e,...At,Pt)}function Vt(e){return L(e,...jt,Ft)}function Ht(e){return L(e,...jt,It)}function Ut(e){return L(e,...Mt,Lt)}function Wt(e){return L(e,...Mt,Rt)}const Gt=1e3;async function Kt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Gt)});return t.ok?await t.text():null}catch{return null}}async function qt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Gt)});return t.ok?await t.text():null}catch{return null}}async function Jt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Gt)});return t.ok?await t.text():null}catch{return null}}function Yt(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 Xt(e){let t=L(e,`.git`,`ok`);if(!V(t))return null;let n=oe(`git`,[`-C`,t,`log`,`--oneline`,`-50`],E({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Zt(e){let t=L(e,`.git`,`ok`);if(!V(t))return null;let n=oe(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],E({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Qt(){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 $t(){return{nodeVersion:process.version,platform:be(),arch:_e()}}function en(){return process.env.OTEL_SDK_DISABLED===`false`}function tn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function nn(e){if(!V(e))return{};let t;try{t=(0,ht.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(!tn(t))return{};let n=t.telemetry;if(!tn(n))return{};let r=n.localSink;return tn(r)?r:{}}function rn(e){return typeof e==`boolean`?e:void 0}function an(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function on(e){if(tn(e))return an(e.maxBytes)}function sn(e){let t=nn(_(`project`,e)),n=nn(_(`project-local`,e));return{enabled:rn(n.enabled)??rn(t.enabled)??!0,spansMaxBytes:on(n.spans)??on(t.spans)??52428800,logsMaxBytes:on(n.logs)??on(t.logs)??26214400}}function cn(e){return Ee(`sha256`).update(e).digest(`hex`)}function ln(e){let t=U(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const un=[`"doc.name"`,`"docName"`];function dn(e){let t=U(e,`utf-8`),n=0;for(let e of un){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,qe(U(e,`utf-8`))):le(e,t),!0}catch{return!1}}function fn(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 pn=new Set([`.jsonl`]);function mn(e){let t=e.lastIndexOf(`.`);return t!==-1&&pn.has(e.slice(t))}const hn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function gn(e){if(Et(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&hn.has(e.slice(t))}function _n(e){let t=[];for(let n of fn(e)){let r=vn(e,n);if(!gn(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 vn(e,t){return R(e,t).split(B).join(`/`)}async function yn(e){let t=z(e.contentDir),n=z(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Kt,a=r.fetchAgentEffects??qt,l=r.fetchWatcherRecent??Jt,u=r.readShadowHead??Xt,ee=r.readCheckpointRefs??Zt,te=r.now??(()=>new Date),d=r.okVersion??(()=>ie),f=r.readDesktopEnv??Qt,p=r.readLanguage??vt,m=r.readRuntime??$t,h=r.isOtlpPushEnabled??en,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(zt(n),L(g,`telemetry`,Nt)),Q(Bt(n),L(g,`telemetry`,Pt)),Q(Vt(n),L(g,`logs`,Ft)),Q(Ht(n),L(g,`logs`,It));for(let t of e.userLogFiles??[])Q(t,L(g,`logs`,F(t)));for(let t of e.userStateFiles??[])Q(t,L(g,o,F(t)));let _=0;for(let t of e.diagnosticReports?.files??[])Q(t,L(g,`diagnostic-reports`,F(t)))&&(_+=1);let v=L(n,`.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 i(S);e===null?x=`agent-presence endpoint at :${S} unreachable`:(K(L(g,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await a(S);t!==null&&K(L(g,`state`,`agent-effects.json`),t);let n=await l(S);if(n!==null){let e=Yt(n);e!==null&&K(L(g,`state`,`watcher-recent.jsonl`),e)}}let C=u(t);C!==null&&K(L(g,`state`,`shadow-head.txt`),C);let w=ee(t);w!==null&&K(L(g,`state`,`checkpoint-refs.txt`),w),Q(Ut(n),L(g,`state`,Lt)),Q(Wt(n),L(g,`state`,Rt)),Q(L(v,`last-spawn-error.log`),L(g,`state`,`last-spawn-error.log`)),Q(L(v,s),L(g,`state`,s)),Q(L(v,c),L(g,`state`,c));let T=m(),E=f(),D=p(),O={ok:{version:d(),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)`:Ue(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&&kt({stagingDir:g,contentDir:t}),e.note&&K(L(g,`note.txt`),e.note);let M=null;e.scrubSecrets===!0&&(M=_n(g));for(let t of e.extraFiles??[])Q(t.sourcePath,L(g,`extra`,t.zipName??F(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let N=sn(n),ne=fn(g),P=[],re=0,ie=0;for(let e of ne){let t=vn(g,e),n=ge(e).size,r=mn(t)?ln(e):0;P.push({path:t,bytes:n,lines:r}),re+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(ie+=dn(e))}let ae={applied:j};M!==null&&(ae.secretScrub=M);let oe={schemaVersion:2,createdAt:te().toISOString(),ok:{version:d(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D},contentDir:{pathSha256:cn(t),absolutePath:j?`<CONTENT_DIR>`:t},telemetry:{localSink:N,otlpPushEnabled:h()},redaction:ae,serverStatus:b,files:P};K(L(g,`manifest.json`),`${JSON.stringify(oe,null,2)}\n`);let I=ne.some(e=>{try{return U(e,`utf-8`).includes(t)}catch{return!1}}),se={stagedDiagnosticReports:_,totalBytes:re,fileCount:P.length,docNameCount:ie,contentDirVisible:I,redacted:j},R=!1;return{stagingDir:g,manifest:oe,summary:se,cleanup:()=>{R||(R=!0,G(g,{recursive:!0,force:!0}))}}}catch(e){throw G(g,{recursive:!0,force:!0}),e}}async function bn(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 gt.ZipFile,a=fn(t.stagingDir);for(let e of a){let n=vn(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 xn(e,t){let n=L(e,`.ok`,`config.yml`);if(V(n))try{let t=(0,ht.parse)(U(n,`utf-8`)),r=re(t)?t.content:void 0,i=re(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 Sn(e,t,n,r,i){let a=tt(t,e.logger),o=await yn({contentDir:xn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...at(a,e.userLogsDir??L(q(),`.ok`,`logs`)),...st(e.cachesDir??L(q(),`Library`,`Caches`))],userStateFiles:ct(e.bugReportsDir??J()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{H(I(e.outputPath),{recursive:!0}),await bn({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 Cn(e){let{projectDir:t}=e,n=e.readDesktopEnv??Qt,r=e.readLanguage??vt,i=()=>$e(e.diagnosticReportsDir??L(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Sn(e,t,n,r,i());let{zipPath:a,summary:o}=await mt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:st(e.cachesDir??L(q(),`Library`,`Caches`)),bugReportLedgerFiles:ct(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=w(e,t);if(!V(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(U(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!g(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??m)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??x())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??ye();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function wn(e){return e.replace(/:\d+$/,``)}function Tn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:wn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:wn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:wn(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 En=[{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`}],Dn=[...b.map(e=>C[e]),`open-knowledge`];function On(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 kn(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 An(e,t){try{return W(e).every(n=>t.has(L(e,n)))}catch{return!1}}function jn(e){let t=On(e),n=[],r=[],i=new Set;for(let e of En){let a=L(t,e.hostDir,`skills`);if(!kn(t,a))continue;let o=Dn.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(;An(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 Mn(e){try{if(!de(e).isDirectory())return!1;let t=W(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Nn(e){let t=new Set,n=new Set;for(let r of En){let i=L(e,r.hostDir,`skills`);for(let e of Dn)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 Pn(e,t){let n=On(e),r=Nn(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(kn(n,e)&&Mn(e))try{G(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(kn(n,e))try{he(e),a.push(e)}catch{}return a}function Fn(e){let n=On(e),r=[];for(let e of b){let i=C[e];r.push({path:L(n,`.agents`,`skills`,i),bundleId:e,scope:`central`});for(let a of t)r.push({path:L(n,a.skillsRoot,i),bundleId:e,scope:`host`,hostDir:a.hostDir})}return r}function In(e,t){let n=[];for(let r of Fn(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 Ln(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Rn(e,t=Date.now()){let n=l(e,t);return n===`unknown`?`—`:n}function zn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;let i=t.lock,a=t.status===`alive`&&S(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:h(n),command:n,isDesktop:Ln(n)}}function Bn(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const Vn=new Set([`running`,`desktop`,`foreign`]);function Hn(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`stale`:return X.default.yellow(e)}}function Un(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Wn(e){return`${Un(e.server.usage)} | ${Un(e.ui?.usage??null)}`}function Gn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Kn(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,Gn(e),Wn(e),Bn(e),String(e.server.pid),Rn(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=Hn(Bn(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 qn(e={}){let t=e.discover??y,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??D,a=e.resolveUsage??k,o=await t(),s=[];for(let e of o){let t=n(e),r=zn(e,t,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Bn(e)}));r(JSON.stringify(e,null,2));return}r(Kn(e.all?s:s.filter(e=>Vn.has(Bn(e)))))}function Jn(){return new j(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await qn({all:t.all===!0||e===`all`,json:t.json===!0})})}async function Yn(e,t=Oe()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=T(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500)});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 Xn(e,t={}){return{targets:Qn(e,t.isAlive??m)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function Zn(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??Yn,o=e.logger??Oe(),s=Xn(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 Qn(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function $n(e,t=m){let n=await y(),r=null;for(let i of n){let n=$(i,`server`);if(Qn(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function er(e,t){let n=await Zn({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function tr(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 nr(e){let t=await y(),n=0;for(let r of t)r!==e&&Qn($(r,`server`),m)&&n++;return n}function rr(e){return new j(`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=d(process.cwd()),n=await Zn({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 nr(t);console.log(tr(process.cwd(),e,{listingFollows:e>0})),e>0&&await qn({})}return}if(i===`all`){let e=await y();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)Qn($(n,`server`),m)&&(await er(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 $n(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await er(t,r);return}let a=z(Fe(),i),o=d(a),s=[],c=await Zn({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(tr(a,await nr(o)))})}export{Fe as C,Ae as D,Oe as E,Ve as S,Me as T,Ue as _,Pn as a,Le as b,Fn as c,Cn as d,yn as f,$e as g,J as h,Jn as i,Tn as l,et as m,Zn as n,jn as o,bn as p,rr as r,In as s,Yn as t,$ as u,Ie as v,Pe as w,Be as x,Re as y};
@@ -1 +0,0 @@
1
- import{S as e,m as t,p as n,r}from"./start-C201LWw_.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};