@inkeep/open-knowledge 0.82.0-beta.5 → 0.82.0-beta.7

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 (85) hide show
  1. package/dist/THIRD_PARTY_NOTICES.md +5 -0
  2. package/dist/cli.mjs +39 -39
  3. package/dist/constants-BKemPkSE.mjs +1 -0
  4. package/dist/{dist-BKMK4uhh.mjs → dist-Bv0NxzRu.mjs} +255 -255
  5. package/dist/{dist-DX-OB6FC.mjs → dist-CIQpPYpS.mjs} +1 -1
  6. package/dist/index.d.mts +3 -0
  7. package/dist/index.mjs +226 -226
  8. package/dist/init-CjAc6IHR.mjs +1 -0
  9. package/dist/{init-Bvmrrn6M.mjs → init-DUsPZVSD.mjs} +9 -9
  10. package/dist/{launch-json-removal-DGgpI_Jz.mjs → launch-json-removal-DxM646OD.mjs} +1 -1
  11. package/dist/{loader-DyhgFxyu.mjs → loader-B0DQFTgm.mjs} +1 -1
  12. package/dist/loader-D6Rlal6B.mjs +1 -0
  13. package/dist/{md-manager-BGnqyqi1-CnT_8Ivp.mjs → md-manager-BGnqyqi1-BTTBdzKI.mjs} +119 -119
  14. package/dist/native/native-config.win32-arm64-msvc.node +0 -0
  15. package/dist/native/native-config.win32-x64-msvc.node +0 -0
  16. package/dist/{open-browser-CuuJWVs1.mjs → open-browser-4EOegGoh.mjs} +1 -1
  17. package/dist/parse-worker.mjs +1 -1
  18. package/dist/preview-B_8NOnki.mjs +1 -0
  19. package/dist/{preview-CS-ZP7yP.mjs → preview-BsI78FfC.mjs} +1 -1
  20. package/dist/public/assets/{ActivityModeContent-CVkgwfSl.js → ActivityModeContent-CMJY3iPZ.js} +1 -1
  21. package/dist/public/assets/{AddPropertiesButton-D16oCS_N.js → AddPropertiesButton-CEHnfIOR.js} +1 -1
  22. package/dist/public/assets/{AgentDiffPane-HH8jeegf.js → AgentDiffPane-Ci_WlUqJ.js} +1 -1
  23. package/dist/public/assets/{CodeMirrorPropInput-DF3sY_TW.js → CodeMirrorPropInput-BvsTaGnu.js} +1 -1
  24. package/dist/public/assets/{DocumentContext-Be48_bAF.js → DocumentContext-1IN55dhx.js} +1 -1
  25. package/dist/public/assets/{EditorModeToggle-DtMDf2MQ.js → EditorModeToggle-qt2PNGdC.js} +1 -1
  26. package/dist/public/assets/{ExcalidrawDocEditor-BJ2A3QGa.js → ExcalidrawDocEditor-EX0AGT48.js} +1 -1
  27. package/dist/public/assets/FeedbackForm-CJD21fJO.js +1 -0
  28. package/dist/public/assets/{ImportSkillDialog-BldGupBv.js → ImportSkillDialog-Bebn-RLY.js} +1 -1
  29. package/dist/public/assets/{LintConfigEditor-DnD5pFzI.js → LintConfigEditor-izVq_bYk.js} +1 -1
  30. package/dist/public/assets/{ManagedArtifactProperties-BtTz8dwV.js → ManagedArtifactProperties-B717BQDe.js} +1 -1
  31. package/dist/public/assets/ManagedArtifactProperties-CIrkTNd5.js +1 -0
  32. package/dist/public/assets/{MermaidDocEditor-CkwkPZvu.js → MermaidDocEditor-6x9pXT5e.js} +1 -1
  33. package/dist/public/assets/{PropertyDisplayRow-FgvNazvo.js → PropertyDisplayRow-D4nY1-k0.js} +1 -1
  34. package/dist/public/assets/{SchemaConfigEditor-BU8wFtDN.js → SchemaConfigEditor-3RhKxmLf.js} +1 -1
  35. package/dist/public/assets/{SessionsHost-BdpjIit2.js → SessionsHost-PaeFusQS.js} +2 -2
  36. package/dist/public/assets/{SettingsDialogBody-DmPhthSq.js → SettingsDialogBody-C95zPMwR.js} +1 -1
  37. package/dist/public/assets/{ShareReceiveMissDialog-C6Yv1L_L.js → ShareReceiveMissDialog-4bA55vn5.js} +1 -1
  38. package/dist/public/assets/{SkillInstallMenu-BW2fj8iT.js → SkillInstallMenu-BK0wvn5U.js} +1 -1
  39. package/dist/public/assets/{SkillToolbarControls-xd9ybWt3.js → SkillToolbarControls-BXpDNT0R.js} +1 -1
  40. package/dist/public/assets/{SourceEditor-xUkiBN-x.js → SourceEditor-BtmK5cJH.js} +1 -1
  41. package/dist/public/assets/{SyncStatusBadge-CMEBaJDA.js → SyncStatusBadge-CWQSe8pe.js} +1 -1
  42. package/dist/public/assets/{TerminalWindowApp-D8Gswz-L.js → TerminalWindowApp-BFl5AncI.js} +1 -1
  43. package/dist/public/assets/{TextDocEditor-CjRA_0cY.js → TextDocEditor-Bf_oBx7o.js} +1 -1
  44. package/dist/public/assets/{ThreadView-CKZltO5Y.js → ThreadView-CSfRmmXE.js} +1 -1
  45. package/dist/public/assets/{TimelineDiffPane-BxiAJgWC.js → TimelineDiffPane-IJZfcy5d.js} +1 -1
  46. package/dist/public/assets/{auth-state-cache-DkvW2mTJ.js → auth-state-cache-DwtH4Lkk.js} +1 -1
  47. package/dist/public/assets/{client-version-aG92qoP2.js → client-version-Bzy_UEKq.js} +1 -1
  48. package/dist/public/assets/{comment-chips-C8z94Yh3.js → comment-chips-DcgD9BSP.js} +1 -1
  49. package/dist/public/assets/{config-provider-myFxAeZJ.js → config-provider-Cz7yJeqI.js} +1 -1
  50. package/dist/public/assets/{doc-undo-manager-Bb2wXN7B.js → doc-undo-manager-Ause2OKj.js} +1 -1
  51. package/dist/public/assets/{globals-Bx4DAP1K.css → globals-B1rEv4ky.css} +1 -1
  52. package/dist/public/assets/{index-Xs-rHCdv.js → index-DXUGzU6-.js} +8 -8
  53. package/dist/public/assets/{pending-receive-nav-store-C6LJ2Kzv.js → pending-receive-nav-store-C6nBYFJa.js} +1 -1
  54. package/dist/public/assets/{progress-Dutcigeg.js → progress-CDFU5XuP.js} +1 -1
  55. package/dist/public/assets/{selection-context-Cq2VCQBg.js → selection-context-BQknXKNK.js} +1 -1
  56. package/dist/public/assets/{src-CGPFfpcu.js → src-D0fT5ICF.js} +1 -1
  57. package/dist/public/assets/{telemetry-impl-C6m58fJK.js → telemetry-impl-9EPdsALE.js} +1 -1
  58. package/dist/public/assets/{telemetry-startup-CMJw54MN.js → telemetry-startup-_ylgB7-C.js} +1 -1
  59. package/dist/public/assets/{typing-burst-detector-SGbZpXed.js → typing-burst-detector-D_VGJ9dT.js} +1 -1
  60. package/dist/public/assets/{uninstall-Bqv6A4OL.js → uninstall-BXBr3BfR.js} +1 -1
  61. package/dist/public/assets/{use-activity-panel-D3mCupUz.js → use-activity-panel-BImUsjDN.js} +1 -1
  62. package/dist/public/assets/{use-open-skill-DV5hhMVO.js → use-open-skill-D2yatv2H.js} +1 -1
  63. package/dist/public/assets/{use-terminal-enabled-Djcq-lbC.js → use-terminal-enabled-DxJng8VS.js} +1 -1
  64. package/dist/public/assets/{use-timeline-entry-diff-BGpMCJkj.js → use-timeline-entry-diff-CdTwqczN.js} +1 -1
  65. package/dist/public/index.html +20 -20
  66. package/dist/public/uninstall.html +3 -3
  67. package/dist/{registry-probes-BqQhP0ax.mjs → registry-probes-B4LbC0Cy.mjs} +2 -2
  68. package/dist/{removal-file-path-BeRPeEws.mjs → removal-file-path-BGThVV41.mjs} +1 -1
  69. package/dist/{repair-launch-json-CzMEUN6E.mjs → repair-launch-json-DB_0Tzwv.mjs} +1 -1
  70. package/dist/{repair-mcp-configs-DiEzfN1-.mjs → repair-mcp-configs-BqB-mWg7.mjs} +1 -1
  71. package/dist/src-D8fqWnvY.mjs +1 -0
  72. package/dist/src-V7QduQ4P.mjs +11 -0
  73. package/dist/start-BWSPnX0l.mjs +1 -0
  74. package/dist/{start-jgWvvxuy.mjs → start-CbIjAVQD.mjs} +3 -3
  75. package/package.json +5 -5
  76. package/dist/constants-ChfpQjIj.mjs +0 -1
  77. package/dist/init-kMgqplOQ.mjs +0 -1
  78. package/dist/loader-DgBlR4_N.mjs +0 -1
  79. package/dist/preview-3fHrsz6g.mjs +0 -1
  80. package/dist/public/assets/FeedbackForm-Ap-gvcmO.js +0 -1
  81. package/dist/public/assets/ManagedArtifactProperties-BsdnBIW1.js +0 -1
  82. package/dist/src-C_P2wuNq.mjs +0 -1
  83. package/dist/src-DwoFHSWS.mjs +0 -11
  84. package/dist/start-Ct8veQKD.mjs +0 -1
  85. /package/dist/public/assets/{globals-Cn1sYXH0.js → globals-DfvLF-dy.js} +0 -0
@@ -1,11 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Ac as t,Df as n,Ds as r,Es as i,Fn as a,Ks as o,Ls as s,Oc as c,Pn as l,Ts as ee,Un as te,al as ne,jf as u,jo as d,nl as f,rl as p,td as m,yf as h}from"./md-manager-BGnqyqi1-CnT_8Ivp.mjs";import{$o as g,Co as _,Dt as v,Mi as y,Ni as b,Qo as x,Sr as S,Yn as C,Yo as w,Zo as T,_i as E,ar as D,gi as re,hi as ie,li as O,lr as k,m as A,ri as j,ya as M}from"./dist-BKMK4uhh.mjs";import{t as N}from"./yazl-BBz29IQN.mjs";import{Ct as P,ot as F,st as ae}from"./init-Bvmrrn6M.mjs";import{l as oe,x as se}from"./registry-probes-BqQhP0ax.mjs";import{c as ce}from"./colors-r_owlCuY.mjs";import{t as le}from"./is-object-BGze3w87.mjs";import{n as ue}from"./constants-ChfpQjIj.mjs";import"./loader-DyhgFxyu.mjs";import"./preview-CS-ZP7yP.mjs";import{execSync as de,spawnSync as fe}from"node:child_process";import{basename as I,dirname as L,isAbsolute as pe,join as R,relative as me,resolve as z,sep as B}from"node:path";import{closeSync as he,cpSync as ge,createWriteStream as _e,existsSync as V,lstatSync as ve,mkdirSync as H,mkdtempSync as ye,openSync as be,readFileSync as U,readSync as xe,readdirSync as W,readlinkSync as Se,rmSync as G,rmdirSync as Ce,statSync as we,writeFileSync as K}from"node:fs";import{arch as Te,freemem as Ee,homedir as q,hostname as De,platform as Oe,release as ke,tmpdir as Ae,totalmem as je,type as Me,uptime as Ne}from"node:os";import"node:fs/promises";import{createHash as Pe}from"node:crypto";const Fe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function Ie(e,t,n=k){if(e!==void 0&&!Fe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Le=null;function Re(e){Le=e}function ze(){return Le??process.cwd()}const Be=`Open Knowledge`;function Ve(e={}){let t=e.platformName??process.platform,r=e.productName??n().productName;return F(t).join(ae({...e,platformName:t}),r)}function He(e={}){let t=e.platformName??process.platform,r=e.home??q(),i=e.env??process.env,a=F(t),o;return o=t===`win32`?i.LOCALAPPDATA||a.join(r,`AppData`,`Local`):t===`darwin`?a.join(r,`Library`,`Caches`):i.XDG_CACHE_HOME||a.join(r,`.cache`),a.join(o,`${n().packageName.replaceAll(`/`,``)}-updater`)}function Ue(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 We(e){let t=R(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return Ue(n)??[]}function Ge(e){let t=R(e,`state.json`);if(!V(t))return!1;try{return Ue(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const Ke=8192;function qe(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 Je(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Ye=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function Xe(e){return e.replace(Ye,`$1"[REDACTED-DEVICE-ID]"`)}function Ze(e){return Xe(Je(e))}const Qe=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function $e(e){if(typeof e!=`string`)return null;let t=Qe.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 et(e){let t=be(e,`r`);try{let e=Buffer.alloc(Ke),n=0,r=!1;for(;n<Ke;){let i=xe(t,e,n,Ke-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{he(t)}}function tt(e){try{let t=et(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:$e(a)}}catch{return{kind:`unreadable`}}}function nt(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function rt(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=R(e,t.name),r;try{r=we(n).mtimeMs}catch{continue}if(r<i)continue;let c=tt(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!nt(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 R(w(),`bug-reports`)}function it(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=J(),r=`${t}-bugreport`,i=R(n,`${r}.zip`);for(let e=2;V(i);e+=1)i=R(n,`${r}-${e}.zip`);return i}function at(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function ot(e,t){let n=R(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(R(e,`.ok`))?Pe(`sha256`).update(z(e)).digest(`hex`).slice(0,12):null}function st(){let e={timestamp:new Date().toISOString(),platform:Oe(),osType:Me(),osRelease:ke(),hostname:`[redacted]`,uptime:Ne(),freeMem:Ee(),totalMem:je(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=de(`sw_vers -productVersion 2>/dev/null`,_({encoding:`utf8`})).trim()}catch{}try{let t=R(__dirname,`..`,`..`,`package.json`);V(t)&&(e.okVersion=JSON.parse(U(t,`utf8`)).version)}catch{}return e}const ct=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function lt(e){let t=I(e);return ct.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function ut(e,t){return mt(e,t).files}const dt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function ft(e,t=oe){let n=R(e,`${t}.ShipIt`);if(!V(n))return[];let r;try{r=W(n)}catch{return[]}return dt.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=>R(n,e.entry)))}function pt(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,-l.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>R(e,t))}catch{return[]}}function mt(e,t){if(!V(t))return{files:[],excludedByProjectSlug:0};let n=W(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>R(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(lt),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=>!lt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function ht(e){let t=R(e,`.ok`,`local`);return V(t)?{files:[`server.lock`,`last-spawn-error.log`,f,c].map(e=>R(t,e)).filter(e=>V(e))}:{files:[]}}function gt(e){let t=R(e,`.ok`,`local`,`logs`);return V(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>R(t,e)).filter(e=>V(e))}:{files:[]}}function _t(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#${Pe(`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 vt(e){let t=e.revealDocNames?e.content:_t(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=s(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`);vt({zipfile:e.zipfile,name:`${e.prefix}/${I(t)}`,content:t.endsWith(`.ips`)?Ze(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 yt(t){let{redact:n,outputPath:r,logger:i}=t,o=t.revealDocNames??!1,s=t.userLogsDir??R(w(),`logs`),c=t.projectDir?ot(t.projectDir,i):null;H(L(r),{recursive:!0}),i?.info({projectSlug:c},`gathering diagnostic data`);let l=st();l.desktop=t.desktop??null,l.language=t.language??null;let{files:ee,excludedByProjectSlug:ne}=mt(c,s),{files:u}=t.projectDir?ht(t.projectDir):{files:[]},{files:d}=t.projectDir?gt(t.projectDir):{files:[]},f=t.shipItLogFiles??[],p=t.diagnosticReports?.files??[];i?.info({logFileCount:ee.length,logFilesExcludedByProjectSlug:ne,lockFileCount:u.length,localSinkFileCount:d.length,shipItLogFileCount:f.length,diagnosticReportCount:p.length},`files collected`);let m=[],h=[],{ZipFile:g}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),_=new g;Y({zipfile:_,files:[...ee,...f],prefix:`logs`,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i}),Y({zipfile:_,files:u,prefix:`lockdir`,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i}),Y({zipfile:_,files:d,prefix:`local-logs`,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i}),Y({zipfile:_,files:t.bugReportLedgerFiles??[],prefix:a,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i}),Y({zipfile:_,files:p,prefix:`diagnostic-reports`,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=U(e.sourcePath),n=`extra/${e.zipName??I(e.sourcePath)}`;_.addBuffer(t,n),h.push(n);let r=at(e,n);r!==null&&m.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&vt({zipfile:_,name:`note.txt`,content:t.note,redact:n,revealDocNames:o,bundleFiles:h,redactions:m});let v=new Set(p.map(e=>`diagnostic-reports/${I(e)}`)),y=h.filter(e=>v.has(e)),b=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:qe(t.diagnosticReports,y.length);_.addBuffer(Buffer.from(`${b}\n`,`utf8`),`state/diagnostic-reports-status.txt`),h.push(`state/diagnostic-reports-status.txt`);let x=JSON.stringify(l,null,2);_.addBuffer(Buffer.from(x,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let S={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:c,files:h,redactions:m,sysinfo:l};_.addBuffer(Buffer.from(JSON.stringify(S,null,2),`utf8`),`MANIFEST.json`);let C=m.reduce((e,t)=>e+t.lineCount,0),T=new Set(f.map(e=>`logs/${I(e)}`)),E=h.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${a}/${I(e)}`)),re=h.filter(e=>D.has(e)),ie=c?h.filter(e=>e.startsWith(`logs/`)&&!lt(e)&&!T.has(e)):[],O=y.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.`]:[],k=O.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...O]:[`Redaction was disabled for this bundle; file contents are unmodified.`],A=[`# Bug Report Bundle`,``,`Generated: ${S.generatedAt}`,`Project: ${c??`(unscoped)`}`,`Discipline version: ${S.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...ie.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:`,...ie.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}`),``]:[],...y.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:`,...y.map(e=>`- ${e}`),``]:[],...re.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:`,...re.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${te.join(`, `)}`,C>0?`${C} line(s) were scrubbed across ${m.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...O,``,`This bundle is safe to attach to a GitHub issue.`]:k].join(`
2
- `);_.addBuffer(Buffer.from(A,`utf8`),`README.md`),_.end();let j=_e(r);return _.outputStream.pipe(j),await new Promise((e,t)=>{j.on(`close`,e),j.on(`error`,t)}),i?.info({bundlePath:r,fileCount:h.length,redactionCount:C},`bundle written`),{zipPath:r,summary:{projectSlug:c,files:h,redactions:m,redactedLineCount:C,generatedAt:S.generatedAt}}}var bt=m(),xt=e(N(),1),X=e(ce(),1);function St(e){let t=g(`user`,e,e);return T({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Ct({home:e=q(),env:n=process.env}={}){let r=St(e),{override:i,preferenceList:a}=x(n),{locale:s,source:c}=o({override:i,storedPreference:r,supportedLocales:ne,preferenceList:a,autoDetectableLocales:t});return{preference:r,locale:s,source:c,systemLanguages:a}}function wt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Tt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Et(e,t){if(typeof e==`string`)return wt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>Et(e,t));if(!Tt(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Et(i,t);return n}function Dt(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=Et(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 Ot(e,t){let n=U(e,`utf-8`);if(n.trim().length!==0)try{let r=Et(JSON.parse(n),t),i=n.endsWith(`
7
- `)?`
8
- `:``;K(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=wt(n,t.contentDir);r!==n&&K(e,r)}}function kt(e,t){let n=U(e,`utf-8`),r=wt(n,t.contentDir);r!==n&&K(e,r)}function At(e){try{return W(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>R(e,t.name))}catch{return[]}}const jt=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Mt(e){return/\.log\.\d+$/.test(e)}function Nt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Mt(e)}const Pt=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Ft(e){let t={contentDir:e.contentDir};for(let n of Pt)for(let r of At(R(e.stagingDir,n)))Nt(r)?Dt(r,t):r.endsWith(`.json`)?Ot(r,t):kt(r,t);for(let n of At(R(e.stagingDir,`state`))){let e=I(n);n.endsWith(`.jsonl`)?Dt(n,t):jt.has(e)?Ot(n,t):kt(n,t)}}const It=[`.ok`,`local`,`telemetry`],Lt=[`.ok`,`local`,`logs`],Rt=[`.ok`,`local`,`loss-capture`],zt=`spans-current.jsonl`,Bt=`spans-prev.jsonl`,Vt=`server-current.jsonl`,Ht=`server-prev.jsonl`,Ut=`loss-current.jsonl`,Wt=`loss-prev.jsonl`;function Gt(e){return R(e,...It,zt)}function Kt(e){return R(e,...It,Bt)}function qt(e){return R(e,...Lt,Vt)}function Jt(e){return R(e,...Lt,Ht)}function Yt(e){return R(e,...Rt,Ut)}function Xt(e){return R(e,...Rt,Wt)}const Zt=1e3;async function Qt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Zt)});return t.ok?await t.text():null}catch{return null}}async function $t(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Zt)});return t.ok?await t.text():null}catch{return null}}async function en(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Zt)});return t.ok?await t.text():null}catch{return null}}function tn(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 nn(e){let t=R(e,`.git`,`ok`);if(!V(t))return null;let n=fe(`git`,[`-C`,t,`log`,`--oneline`,`-50`],_({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function rn(e){let t=R(e,`.git`,`ok`);if(!V(t))return null;let n=fe(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],_({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function an(){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 on(){return{nodeVersion:process.version,platform:Oe(),arch:Te()}}function sn(){return process.env.OTEL_SDK_DISABLED===`false`}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cn(e){if(!V(e))return{};let t;try{t=(0,bt.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 ln(e){return typeof e==`boolean`?e:void 0}function un(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function dn(e){if(Z(e))return un(e.maxBytes)}function fn(e){let t=cn(g(`project`,e)),n=cn(g(`project-local`,e));return{enabled:ln(n.enabled)??ln(t.enabled)??!0,spansMaxBytes:dn(n.spans)??dn(t.spans)??52428800,logsMaxBytes:dn(n.logs)??dn(t.logs)??26214400}}function pn(e){return Pe(`sha256`).update(e).digest(`hex`)}function mn(e){let t=U(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const hn=[`"doc.name"`,`"docName"`];function gn(e){let t=U(e,`utf-8`),n=0;for(let e of hn){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(L(t),{recursive:!0}),e.endsWith(`.ips`)?K(t,Ze(U(e,`utf-8`))):ge(e,t),!0}catch{return!1}}function _n(e){let t=[],n=e=>{let r=W(e,{withFileTypes:!0});for(let i of r){let r=R(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const vn=new Set([`.jsonl`]);function yn(e){let t=e.lastIndexOf(`.`);return t!==-1&&vn.has(e.slice(t))}const bn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function xn(e){if(Mt(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&bn.has(e.slice(t))}function Sn(e){let t=[];for(let n of _n(e)){let r=Cn(e,n);if(!xn(r))continue;let{redacted:i,patterns:a,lineCount:o}=s(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 Cn(e,t){return me(e,t).split(B).join(`/`)}async function wn(e){let t=z(e.contentDir),n=z(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Qt,o=r.fetchAgentEffects??$t,s=r.fetchWatcherRecent??en,l=r.readShadowHead??nn,ee=r.readCheckpointRefs??rn,te=r.now??(()=>new Date),ne=r.okVersion??(()=>ue),u=r.readDesktopEnv??an,d=r.readLanguage??Ct,m=r.readRuntime??on,h=r.isOtlpPushEnabled??sn,g=ye(R(Ae(),`ok-bundle-`));try{H(R(g,`telemetry`),{recursive:!0}),H(R(g,`logs`),{recursive:!0}),H(R(g,`state`),{recursive:!0}),Q(Gt(n),R(g,`telemetry`,zt)),Q(Kt(n),R(g,`telemetry`,Bt)),Q(qt(n),R(g,`logs`,Vt)),Q(Jt(n),R(g,`logs`,Ht));for(let t of e.userLogFiles??[])Q(t,R(g,`logs`,I(t)));for(let t of e.userStateFiles??[])Q(t,R(g,a,I(t)));let _=0;for(let t of e.diagnosticReports?.files??[])Q(t,R(g,`diagnostic-reports`,I(t)))&&(_+=1);let v=R(n,`.ok`,`local`),y=R(v,`server.lock`),b=`not-running`,x=`no server.lock`,S=null;if(V(y)){Q(y,R(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(R(g,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await o(S);t!==null&&K(R(g,`state`,`agent-effects.json`),t);let n=await s(S);if(n!==null){let e=tn(n);e!==null&&K(R(g,`state`,`watcher-recent.jsonl`),e)}}let C=l(t);C!==null&&K(R(g,`state`,`shadow-head.txt`),C);let w=ee(t);w!==null&&K(R(g,`state`,`checkpoint-refs.txt`),w),Q(Yt(n),R(g,`state`,Ut)),Q(Xt(n),R(g,`state`,Wt)),Q(R(v,`last-spawn-error.log`),R(g,`state`,`last-spawn-error.log`)),Q(R(v,p),R(g,`state`,p)),Q(R(v,f),R(g,`state`,f)),Q(R(v,c),R(g,`state`,c));let T=m(),E=u(),D=d(),re={ok:{version:ne(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D}};K(R(g,`state`,`runtime.json`),`${JSON.stringify(re,null,2)}\n`);let ie=b===`running`?`running
10
- `:`not-running (${x})\n`;K(R(g,`state`,`server-status.txt`),ie);let O=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:qe(e.diagnosticReports,_);if(K(R(g,`state`,`diagnostic-reports-status.txt`),`${O}\n`),e.processDir&&V(e.processDir)){let t=R(g,`process`);H(t,{recursive:!0}),ge(e.processDir,t,{recursive:!0})}let k=e.redact===!0;k&&Ft({stagingDir:g,contentDir:t}),e.note&&K(R(g,`note.txt`),e.note);let A=null;e.scrubSecrets===!0&&(A=Sn(g));for(let t of e.extraFiles??[]){let e=t.zipName??I(t.sourcePath);if(!Q(t.sourcePath,R(g,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=at(t,`extra/${e}`);n!==null&&(A??={redactions:[],redactedLineCount:0},A.redactions.push(n),A.redactedLineCount+=n.lineCount)}let j=fn(n),M=_n(g),N=[],P=0,F=0;for(let e of M){let t=Cn(g,e),n=we(e).size,r=yn(t)?mn(e):0;N.push({path:t,bytes:n,lines:r}),P+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(F+=gn(e))}let ae={applied:k};A!==null&&(ae.secretScrub=A);let oe={schemaVersion:2,createdAt:te().toISOString(),ok:{version:ne(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D},contentDir:{pathSha256:pn(t),absolutePath:k?`<CONTENT_DIR>`:t},telemetry:{localSink:j,otlpPushEnabled:h()},redaction:ae,serverStatus:b,files:N};K(R(g,`manifest.json`),`${JSON.stringify(oe,null,2)}\n`);let se=M.some(e=>{try{return U(e,`utf-8`).includes(t)}catch{return!1}}),ce={stagedDiagnosticReports:_,totalBytes:P,fileCount:N.length,docNameCount:F,contentDirVisible:se,redacted:k},le=!1;return{stagingDir:g,manifest:oe,summary:ce,cleanup:()=>{le||(le=!0,G(g,{recursive:!0,force:!0}))}}}catch(e){throw G(g,{recursive:!0,force:!0}),e}}async function Tn(e){let{collected:t,outputPath:n}=e,r=L(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 xt.ZipFile,a=_n(t.stagingDir);for(let e of a){let n=Cn(t.stagingDir,e);i.addFile(e,n)}i.end();let o=_e(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 En(e,t){let n=R(e,`.ok`,`config.yml`);if(V(n))try{let t=(0,bt.parse)(U(n,`utf-8`)),r=le(t)?t.content:void 0,i=le(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 Dn(e,t,n,r,i){let a=ot(t,e.logger),o=await wn({contentDir:En(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...ut(a,e.userLogsDir??R(w(),`logs`)),...ft(e.cachesDir??R(q(),`Library`,`Caches`))],userStateFiles:pt(e.bugReportsDir??J()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{H(L(e.outputPath),{recursive:!0}),await Tn({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 On(e){let{projectDir:t}=e,n=e.readDesktopEnv??an,r=e.readLanguage??Ct,i=()=>rt(e.diagnosticReportsDir??R(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Dn(e,t,n,r,i());let{zipPath:a,summary:o}=await yt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:ft(e.cachesDir??R(q(),`Library`,`Caches`)),bugReportLedgerFiles:pt(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=E(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??S()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??De());if(!a||typeof a!=`object`||!O(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??j)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function kn(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 An(e){return e.replace(/:\d+$/,``)}function jn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:An(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:An(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:An(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 Mn=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Nn(e){return r(u(),e)}function Pn(){return i(u())}function Fn(){let e=u();if(e===`stable`)return Mn;let t=ee(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const In={existsSync:e=>V(e),readFileSync:(e,t)=>U(e,t),lstatSync:e=>ve(e),readlinkSync:e=>Se(e)};function Ln(e,t=In){let n=Nn(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function Rn(e){let t=e.replace(Fn(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function zn(e,t,n=In){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const Bn=[{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`}],Vn=[...v.map(e=>A[e]),`open-knowledge`];function Hn(e){if(!pe(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=z(e);if(t===B||L(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Un(e,t){let n=me(e,t);if(n.startsWith(`..`)||pe(n))return!1;let r=e;for(let e of n.split(B)){r=R(r,e);try{if(!ve(r).isDirectory())return!1}catch{return!1}}return!0}function Wn(e,t){try{return W(e).every(n=>t.has(R(e,n)))}catch{return!1}}function Gn(e){let t=Hn(e),n=[],r=[],i=new Set;for(let e of Bn){let a=R(t,e.hostDir,`skills`);if(!Un(t,a))continue;let o=Vn.map(e=>R(a,e)).filter(e=>V(e));n.push(...o);for(let e of o)i.add(e);let s=R(t,e.pruneRoot),c=a;for(;Wn(c,i)&&(r.push(c),i.add(c),c!==s);){let e=L(c);if(e===c||e===t||!e.startsWith(t+B))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Kn(e){try{if(!ve(e).isDirectory())return!1;let t=W(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function qn(e){let t=new Set,n=new Set;for(let r of Bn){let i=R(e,r.hostDir,`skills`);for(let e of Vn)t.add(R(i,e));let a=R(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=L(o);if(t===o||t===e||!t.startsWith(e+B))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Jn(e,t){let n=Hn(e),r=qn(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(Un(n,e)&&Kn(e))try{G(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Un(n,e))try{Ce(e),a.push(e)}catch{}return a}function Yn(e){let t=Hn(e),n=[];for(let e of v){let r=A[e];n.push({path:R(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of h)n.push({path:R(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Xn(e,t){let n=[];for(let r of Yn(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 Zn(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Qn(e,t=Date.now()){if(e===null)return`—`;let n=d(e,t);return n===`unknown`?`—`:n}function $n(e){let t=L(e);return I(e)===`local`&&I(t)===`.ok`?L(t):I(e)===`.ok`?t:null}function er(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:$n(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`&&ie(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:D(n),command:n,isDesktop:Zn(n)}}function tr(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 nr=new Set([`running`,`desktop`,`foreign`,`unverified`]);function rr(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 ir(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ar(e){return`${ir(e.server.usage)} | ${ir(e.ui?.usage??null)}`}function or(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function sr(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??`—`,or(e),ar(e),tr(e),String(e.server.pid),Qn(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=rr(tr(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 cr(e={}){let t=e.discover??C,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??y,a=e.resolveUsage??b,o=await t(),s=[];for(let e of o){let t=n(e),r=er(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:tr(e)}));r(JSON.stringify(e,null,2));return}r(sr(e.all?s:s.filter(e=>nr.has(tr(e)))))}function lr(){return new P(`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 cr({all:t.all===!0||e===`all`,json:t.json===!0})})}async function ur(e,t=se()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=re(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 dr(e,t={}){return{targets:pr(e,t.isAlive??j)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function fr(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??ur,o=e.logger??se(),s=dr(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 pr(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function mr(e,t=j){let n=await C(),r=null;for(let i of n){let n=$(i,`server`);if(pr(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function hr(e,t){let n=await fr({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function gr(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 _r(e){let t=await C(),n=0;for(let r of t)r!==e&&pr($(r,`server`),j)&&n++;return n}function vr(e){return new P(`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=M(process.cwd()),n=await fr({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 _r(t);console.log(gr(process.cwd(),e,{listingFollows:e>0})),e>0&&await cr({})}return}if(i===`all`){let e=await C();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)pr($(n,`server`),j)&&(await hr(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 mr(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await hr(t,r);return}let a=z(ze(),i),o=M(a),s=[],c=await fr({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(gr(a,await _r(o)))})}export{ze as A,rt as C,Ve as D,He as E,Ie as M,We as O,J as S,Be as T,$ as _,Jn as a,Tn as b,Yn as c,Nn as d,Pn as f,kn as g,jn as h,lr as i,Re as j,Ge as k,Mn as l,Rn as m,fr as n,Gn as o,Ln as p,vr as r,Xn as s,ur as t,zn as u,On as v,qe as w,it as x,wn as y};
@@ -1 +0,0 @@
1
- import{S as e,m as t,p as n,r}from"./start-jgWvvxuy.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};