@inkeep/open-knowledge 0.68.24 → 0.68.25

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 (150) hide show
  1. package/dist/{acp-harness-probe-DGGiqS4w.mjs → acp-harness-probe-cDPpq4cK.mjs} +2 -2
  2. package/dist/cli.mjs +24 -24
  3. package/dist/constants-veaDdIy0.mjs +2 -0
  4. package/dist/{git-handle-C0onz3KH.mjs → git-handle-BI08KePL.mjs} +2 -2
  5. package/dist/git-handle-tx24n4m3.mjs +1 -0
  6. package/dist/index.d.mts +1 -0
  7. package/dist/index.mjs +1 -1
  8. package/dist/init-BFc6ZlDx.mjs +1 -0
  9. package/dist/{init-CM3eAtKs.mjs → init-HwwBx7jE.mjs} +6 -6
  10. package/dist/{launch-json-removal-9fz2YpN1.mjs → launch-json-removal-Bmp4pEbr.mjs} +2 -2
  11. package/dist/{loader-Dk9XSmKX.mjs → loader-BgZTHjwC.mjs} +2 -2
  12. package/dist/loader-CPxCqyid.mjs +1 -0
  13. package/dist/md-manager-C0JXW59s.mjs +2 -0
  14. package/dist/{open-browser-7DkBQF9D.mjs → open-browser-DtPQklA3.mjs} +2 -2
  15. package/dist/parse-worker.mjs +1 -1
  16. package/dist/preview-B8bqmjqa.mjs +1 -0
  17. package/dist/{preview-Csse3lpM.mjs → preview-C_JkVRHU.mjs} +2 -2
  18. package/dist/public/assets/{ActivityModeContent-DrxGfMvz.js → ActivityModeContent-BsN1q6on.js} +1 -1
  19. package/dist/public/assets/{AddPropertiesButton-BJo_rppq.js → AddPropertiesButton-DKeaL1oS.js} +2 -2
  20. package/dist/public/assets/{AgentDiffPane-DsCk_N38.js → AgentDiffPane-BM1ahAik.js} +1 -1
  21. package/dist/public/assets/{AgentThreadClientBinder-Bf50AUBi.js → AgentThreadClientBinder-oLrPSNPH.js} +1 -1
  22. package/dist/public/assets/{BugReportHistory-wK4InFbA.js → BugReportHistory-CjOQKfkD.js} +1 -1
  23. package/dist/public/assets/{BugReportHistoryDialog-Ba01rTam.js → BugReportHistoryDialog-Diu9xO83.js} +1 -1
  24. package/dist/public/assets/CodeMirrorPropInput-C-O6O9wI.js +3 -0
  25. package/dist/public/assets/{ConsentDialogBody-D6hJwNXp.js → ConsentDialogBody-DRoNvqho.js} +1 -1
  26. package/dist/public/assets/{DiffViewBoundary-B13gBLtK.js → DiffViewBoundary-CBAGr4M4.js} +1 -1
  27. package/dist/public/assets/DocumentContext-BL03B6Lo.js +38 -0
  28. package/dist/public/assets/{EditorModeToggle-QltvWtP-.js → EditorModeToggle-BsK6ZKYQ.js} +1 -1
  29. package/dist/public/assets/{EnableSyncConfirmDialog-CMKantv5.js → EnableSyncConfirmDialog-DjaFG6MU.js} +1 -1
  30. package/dist/public/assets/{ExcalidrawDocEditor-C48E2J8X.js → ExcalidrawDocEditor-DphKGPeJ.js} +1 -1
  31. package/dist/public/assets/FeedbackForm-CqA8hjj8.js +1 -0
  32. package/dist/public/assets/{GraphPanel-u52WU2oL.js → GraphPanel-B2aFesGW.js} +2 -2
  33. package/dist/public/assets/{ImageAttachments-DyK8QuNY.js → ImageAttachments-Zj80uHKI.js} +1 -1
  34. package/dist/public/assets/{ImportSkillDialog-DXRVURiF.js → ImportSkillDialog-BEWZQmnc.js} +1 -1
  35. package/dist/public/assets/{LintConfigEditor-CB0o3K-6.js → LintConfigEditor-DuIbFKSd.js} +1 -1
  36. package/dist/public/assets/ManagedArtifactProperties-Dl3pabto.js +1 -0
  37. package/dist/public/assets/ManagedArtifactProperties-PLZuubo-.js +1 -0
  38. package/dist/public/assets/{MermaidDocEditor-J4ci7jAA.js → MermaidDocEditor-CdignfBs.js} +1 -1
  39. package/dist/public/assets/{PropertyDisplayRow-ONE-tzKI.js → PropertyDisplayRow-CyD4-Wb_.js} +1 -1
  40. package/dist/public/assets/ReportBugDialogBody-BUuxy0j2.js +3 -0
  41. package/dist/public/assets/{ReportBugMenuTrigger-AGOrr1fp.js → ReportBugMenuTrigger-sk-thNZX.js} +2 -2
  42. package/dist/public/assets/{SchemaConfigEditor-B0JgoJX1.js → SchemaConfigEditor-CDpCKyKB.js} +1 -1
  43. package/dist/public/assets/{SessionsHost-CkWnHm7-.js → SessionsHost-B-TEBDCp.js} +2 -2
  44. package/dist/public/assets/{SettingsDialogBody-BsN9Kdfy.js → SettingsDialogBody-DK0PsIIc.js} +4 -4
  45. package/dist/public/assets/{ShareBranchSwitchDialog-Cd1IH1tv.js → ShareBranchSwitchDialog-DCgiR2i-.js} +1 -1
  46. package/dist/public/assets/{ShareReceiveDialog-CDOEKYVB.js → ShareReceiveDialog-DUqJV0UV.js} +1 -1
  47. package/dist/public/assets/{ShareReceiveMissDialog-DdLLhrno.js → ShareReceiveMissDialog-JxBpkBFR.js} +1 -1
  48. package/dist/public/assets/{SkillCostValue-Da0rHHTz.js → SkillCostValue-Dz6a2Lnk.js} +1 -1
  49. package/dist/public/assets/{SkillEditBanner-Cs-3UGuA.js → SkillEditBanner-BNP9V25d.js} +1 -1
  50. package/dist/public/assets/{SkillForkDialog-DNBDX1CX.js → SkillForkDialog-DoQVCana.js} +1 -1
  51. package/dist/public/assets/{SkillInstallMenu-Bbcf0WK7.js → SkillInstallMenu-Bu9LANwb.js} +2 -2
  52. package/dist/public/assets/{SkillOriginInline-B0dcs7tW.js → SkillOriginInline-CuE2lMFY.js} +1 -1
  53. package/dist/public/assets/{SkillToolbarControls-D_3eESsK.js → SkillToolbarControls-HtxNAB1G.js} +1 -1
  54. package/dist/public/assets/{SlidesToolbarControls-DHvw4uBT.js → SlidesToolbarControls-BZNlyduc.js} +1 -1
  55. package/dist/public/assets/SourceEditor-CDklgrky.js +1 -0
  56. package/dist/public/assets/{TerminalPanel-12Llnh6U.js → TerminalPanel-BuPs5mVj.js} +3 -3
  57. package/dist/public/assets/{TerminalWindowApp-Cgj_x6tD.js → TerminalWindowApp-BTj6QFKN.js} +1 -1
  58. package/dist/public/assets/{TextDocEditor-CmulZC7e.js → TextDocEditor-Dby0nL6U.js} +1 -1
  59. package/dist/public/assets/{ThreadView-Cw7ub95K.js → ThreadView-CUE8ki-r.js} +1 -1
  60. package/dist/public/assets/{TimelineDiffPane-6vZyy4l3.js → TimelineDiffPane-DkPuC0ku.js} +1 -1
  61. package/dist/public/assets/{agent-diff-store-wSkpgVlI.js → agent-diff-store-IPzzfrOx.js} +1 -1
  62. package/dist/public/assets/auth-state-cache-DTs2CUC0.js +11 -0
  63. package/dist/public/assets/{bug-report-send-manager-D7ZKWC13.js → bug-report-send-manager-Bss057qg.js} +1 -1
  64. package/dist/public/assets/{client-version-CyfblLiq.js → client-version-f3Ic3dkW.js} +1 -1
  65. package/dist/public/assets/{comment-chips-CAw_--st.js → comment-chips-C9DBUwjq.js} +1 -1
  66. package/dist/public/assets/config-provider-Bvsjfg7O.js +5 -0
  67. package/dist/public/assets/{dist-Cwdy6rNm.js → dist-o3yaQSBE.js} +1 -1
  68. package/dist/public/assets/{doc-hash-2ijBcFw2.js → doc-hash-gt3yar-W.js} +1 -1
  69. package/dist/public/assets/{doc-undo-manager-Ca9imJ6U.js → doc-undo-manager-CpfBEWAw.js} +1 -1
  70. package/dist/public/assets/{documents-events-D-zWDKxn.js → documents-events-Du6II0Ei.js} +1 -1
  71. package/dist/public/assets/{file-tree-adapter-D-PRw9QY.js → file-tree-adapter-Ws51oJtV.js} +1 -1
  72. package/dist/public/assets/{file-tree-utils-CRgAMcDx.js → file-tree-utils-CjXPIk9u.js} +1 -1
  73. package/dist/public/assets/{folder-config-api-CSxHXv7z.js → folder-config-api-DRfPX6G9.js} +1 -1
  74. package/dist/public/assets/i18n-gYJ8jvKw.js +1 -0
  75. package/dist/public/assets/{index-CTmmlQJN.js → index-3LY7lc1S.js} +14 -14
  76. package/dist/public/assets/{launcher-selection-BtWIyLvk.js → launcher-selection-CDIa5FVF.js} +1 -1
  77. package/dist/public/assets/{lint-config-client-mcvTJc2v.js → lint-config-client-Mu5rBBK-.js} +1 -1
  78. package/dist/public/assets/{markdownlint-rule-browser-BMGCypxy.js → markdownlint-rule-browser-CpUZseqZ.js} +1 -1
  79. package/dist/public/assets/page-list-cache-Cu9DOD34.js +1 -0
  80. package/dist/public/assets/{pending-receive-nav-store-BlPeJUhN.js → pending-receive-nav-store-vjeswZ1S.js} +1 -1
  81. package/dist/public/assets/{progress-Dc-mYmpO.js → progress-Bjq-7B_h.js} +3 -3
  82. package/dist/public/assets/{project-paths-CkPw54qq.js → project-paths-D-0JbskM.js} +1 -1
  83. package/dist/public/assets/{prop-types-BWOU-3iS.js → prop-types-BMmnqO1F.js} +1 -1
  84. package/dist/public/assets/{receive-store-DbCZayFQ.js → receive-store-Ch7q4td5.js} +1 -1
  85. package/dist/public/assets/{selection-context-DPh4FTXp.js → selection-context-DxsBdCm9.js} +1 -1
  86. package/dist/public/assets/{skill-scope-Cc_tGDGk.js → skill-scope-Byq13eLB.js} +1 -1
  87. package/dist/public/assets/{skills-api-DOBXco7b.js → skills-api-B8VoCUW6.js} +1 -1
  88. package/dist/public/assets/{src-DsA5nyew.js → src-2dTcoAYc.js} +1 -1
  89. package/dist/public/assets/{startup-marks-XRsgWWbt.js → startup-marks-CTXUS1Ul.js} +1 -1
  90. package/dist/public/assets/{tag-pill-input-B5neay0J.js → tag-pill-input-D-HYAX8D.js} +1 -1
  91. package/dist/public/assets/{target-navigation-intent-OdVNpD6p.js → target-navigation-intent-D3ncb9fZ.js} +1 -1
  92. package/dist/public/assets/{telemetry-startup-BLz9UO1p.js → telemetry-startup-CH9llubG.js} +1 -1
  93. package/dist/public/assets/{terminal-cli-display-C4WdyJL_.js → terminal-cli-display-C0s5xXdy.js} +1 -1
  94. package/dist/public/assets/{terminal-command-events-WuiqDErm.js → terminal-command-events-DaFJ29gM.js} +1 -1
  95. package/dist/public/assets/{typing-burst-detector-BGsY9LD0.js → typing-burst-detector-oKnQh0ov.js} +3 -3
  96. package/dist/public/assets/{uninstall-ClePMC9B.js → uninstall-Cdgarx0X.js} +1 -1
  97. package/dist/public/assets/{use-activity-panel-DRcDcqVD.js → use-activity-panel-BM_l4tMu.js} +1 -1
  98. package/dist/public/assets/{use-apply-config-color-theme-ZQo6F7Ch.js → use-apply-config-color-theme-BzF4dCGo.js} +1 -1
  99. package/dist/public/assets/{use-collab-url-VKEV6_yX.js → use-collab-url-DhrFhtyH.js} +1 -1
  100. package/dist/public/assets/{use-conflicts-BdD4tOPl.js → use-conflicts-BsmHy6Ah.js} +1 -1
  101. package/dist/public/assets/{use-live-xterm-theme-B9XRMlxA.js → use-live-xterm-theme-Drc41C1Y.js} +1 -1
  102. package/dist/public/assets/{use-open-skill-xa-WPLIN.js → use-open-skill-Bc_MMBNx.js} +1 -1
  103. package/dist/public/assets/{use-settings-route-DdY4FJ0e.js → use-settings-route-D_hrIks1.js} +1 -1
  104. package/dist/public/assets/{use-skill-origin-AvtTl_ol.js → use-skill-origin-CteAWX6H.js} +1 -1
  105. package/dist/public/assets/{use-skills-0lg-f7-C.js → use-skills-B_7BHHiH.js} +1 -1
  106. package/dist/public/assets/{use-terminal-enabled-B-jpEe-2.js → use-terminal-enabled-BS4HcL8d.js} +1 -1
  107. package/dist/public/assets/use-timeline-entry-diff-CjVpx90u.js +5 -0
  108. package/dist/public/assets/{use-workspace-B6rNZ9sM.js → use-workspace-BBjLPqCO.js} +1 -1
  109. package/dist/public/index.html +50 -50
  110. package/dist/public/uninstall.html +3 -3
  111. package/dist/{repair-launch-json-Cwko5D5P.mjs → repair-launch-json-DfVqqhks.mjs} +2 -2
  112. package/dist/{repair-mcp-configs-DXaEIK-z.mjs → repair-mcp-configs-CY74SE23.mjs} +2 -2
  113. package/dist/repair-skills-BJog_ZkO.mjs +1 -0
  114. package/dist/{repair-skills-DV5Ex1fA.mjs → repair-skills-lRCFwvhr.mjs} +2 -2
  115. package/dist/{resolve-project-root-Cc2d51uk.mjs → resolve-project-root-BQmlxjbX.mjs} +3 -3
  116. package/dist/{server-lock-DKS1ePB3.mjs → server-lock-DMUPUL90.mjs} +2 -2
  117. package/dist/server-lock-qVil2gut.mjs +1 -0
  118. package/dist/{skill-teardown-CnsEXQ4M.mjs → skill-teardown-BWwkRO-B.mjs} +2 -2
  119. package/dist/{src-B2bAQ64a.mjs → src-BSHNcVXn.mjs} +107 -107
  120. package/dist/src-BxqApSys.mjs +2045 -0
  121. package/dist/src-DhnY2n-M.mjs +1 -0
  122. package/dist/src-Dx0OEah9.mjs +20 -0
  123. package/dist/{src-BRvdXeYI.mjs → src-SbH90xWg.mjs} +1 -1
  124. package/dist/start-BLvelUky.mjs +1 -0
  125. package/dist/{start-BFDC8kpc.mjs → start-sZmCG1Do.mjs} +3 -3
  126. package/package.json +4 -4
  127. package/dist/constants-DQeD1wr9.mjs +0 -2
  128. package/dist/git-handle-GcGVb-Kt.mjs +0 -1
  129. package/dist/init-UF5ZVhNj.mjs +0 -1
  130. package/dist/loader-C0Fw8hG9.mjs +0 -1
  131. package/dist/md-manager--OJ_B4tb.mjs +0 -2
  132. package/dist/preview-CK-F7cCH.mjs +0 -1
  133. package/dist/public/assets/CodeMirrorPropInput-CGOtxTRF.js +0 -3
  134. package/dist/public/assets/DocumentContext-D05VcwL0.js +0 -38
  135. package/dist/public/assets/FeedbackForm-CtwwmLh-.js +0 -1
  136. package/dist/public/assets/ManagedArtifactProperties-CmlPj4Nz.js +0 -1
  137. package/dist/public/assets/ManagedArtifactProperties-PfnMwxJm.js +0 -1
  138. package/dist/public/assets/ReportBugDialogBody-CG8yDGbK.js +0 -3
  139. package/dist/public/assets/SourceEditor-CNdEIp7F.js +0 -1
  140. package/dist/public/assets/auth-state-cache-BkAb7BNf.js +0 -11
  141. package/dist/public/assets/config-provider-C4M_g0W4.js +0 -5
  142. package/dist/public/assets/i18n-BO9Xvo8q.js +0 -1
  143. package/dist/public/assets/page-list-cache-B-YfJ4Pd.js +0 -1
  144. package/dist/public/assets/use-timeline-entry-diff-CJDIRaWs.js +0 -5
  145. package/dist/repair-skills-Cd0ulalA.mjs +0 -1
  146. package/dist/server-lock-D-DD35fh.mjs +0 -1
  147. package/dist/src-Bb6TT2TZ.mjs +0 -1
  148. package/dist/src-IiV9Xv8E.mjs +0 -2045
  149. package/dist/src-Nl1-dukn.mjs +0 -20
  150. package/dist/start-C0pPitjA.mjs +0 -1
@@ -1,20 +0,0 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{Ha as t,Ia as n,La as r,ac as i,oc as a}from"./src-B2bAQ64a.mjs";import{$ as o,Ct as s,Q as c,c as l,s as u}from"./sleep-zea4v2sB.mjs";import{Bi as d,ct as ee,ei as f,h as p,lt as m,st as h,ut as g,xr as _}from"./src-IiV9Xv8E.mjs";import{A as v,I as y,L as b,O as x}from"./fs-traced-DgX7lP1u.mjs";import{C as S,S as C,_ as w,d as T,f as E,r as D}from"./server-lock-DKS1ePB3.mjs";import{t as O}from"./yazl-DejPO9b3.mjs";import{_ as k,h as A,m as j,v as M,x as N}from"./resolve-project-root-Cc2d51uk.mjs";import{c as P}from"./colors-DSyAT9Cz.mjs";import{a as te,i as F}from"./acp-harness-probe-DGGiqS4w.mjs";import{D as ne,E as I,S as re,T as L,_ as ie,b as ae,o as oe}from"./init-CM3eAtKs.mjs";import{n as se}from"./constants-DQeD1wr9.mjs";import{t as ce}from"./is-object-Bw0-z8qH.mjs";import"./loader-Dk9XSmKX.mjs";import"./skill-teardown-CnsEXQ4M.mjs";import"./preview-Csse3lpM.mjs";import{execSync as le,spawnSync as ue}from"node:child_process";import{basename as R,dirname as z,join as B,relative as de,resolve as V,sep as fe}from"node:path";import{closeSync as pe,cpSync as me,createWriteStream as he,existsSync as H,lstatSync as ge,mkdirSync as U,mkdtempSync as _e,openSync as ve,readFileSync as W,readSync as ye,readdirSync as G,readlinkSync as be,rmSync as xe,statSync as Se,writeFileSync as K}from"node:fs";import{arch as Ce,freemem as we,homedir as q,hostname as Te,platform as Ee,release as De,tmpdir as Oe,totalmem as ke,type as Ae,uptime as je}from"node:os";import"node:fs/promises";import{createHash as Me}from"node:crypto";var Ne=s();let Pe;function Fe(){return Pe}function Ie(e,t){if(t!==void 0&&t.length>0)return t;try{return f(e)?.rootPath}catch{return}}function Le(e){let t=Ie(e.cwd,e.configuredProjectName),n=p({name:`cli`,project:t});return Pe=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}const Re=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ze(e,t,n=f){if(e!==void 0&&!Re.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Be=null;function Ve(e){Be=e}function He(){return Be??process.cwd()}const Ue=`Open Knowledge`;function We(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return k(t).join(M({...e,platformName:t}),n)}function Ge(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=k(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 Ke(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 qe(e){let t=B(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Ke(n)??[]}function Je(e){let t=B(e,`state.json`);if(!H(t))return!1;try{return Ke(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Ye=8192;function Xe(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 Ze(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Qe=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function $e(e){return e.replace(Qe,`$1"[REDACTED-DEVICE-ID]"`)}function et(e){return $e(Ze(e))}const tt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function nt(e){if(typeof e!=`string`)return null;let t=tt.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 rt(e){let t=ve(e,`r`);try{let e=Buffer.alloc(Ye),n=0,r=!1;for(;n<Ye;){let i=ye(t,e,n,Ye-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{pe(t)}}function it(e){try{let t=rt(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:nt(a)}}catch{return{kind:`unreadable`}}}function at(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function ot(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=B(e,t.name),r;try{r=Se(n).mtimeMs}catch{continue}if(r<i)continue;let c=it(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!at(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 B(q(),`.ok`,`bug-reports`)}function st(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=J(),r=`${t}-bugreport`,i=B(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=B(n,`${r}-${e}.zip`);return i}function ct(e,t){let n=B(e,`.ok`,`config.yml`);if(H(n))try{let e=W(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return H(B(e,`.ok`))?Me(`sha256`).update(V(e)).digest(`hex`).slice(0,12):null}function lt(){let e={timestamp:new Date().toISOString(),platform:Ee(),osType:Ae(),osRelease:De(),hostname:`[redacted]`,uptime:je(),freeMem:we(),totalMem:ke(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=le(`sw_vers -productVersion 2>/dev/null`,d({encoding:`utf8`})).trim()}catch{}try{let t=B(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const ut=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function dt(e){let t=R(e);return ut.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function ft(e,t){return gt(e,t).files}const pt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function mt(e,t=te){let n=B(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return pt.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=>B(n,e.entry)))}function ht(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-i.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=>B(e,t))}catch{return[]}}function gt(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>B(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(dt),i=[],a=r.filter(t=>{try{return W(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!dt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function _t(e){let t=B(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,`last-spawn-error.log`,u].map(e=>B(t,e)).filter(e=>H(e))}:{files:[]}}function vt(e){let t=B(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>B(t,e)).filter(e=>H(e))}:{files:[]}}function yt(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#${Me(`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 bt(e){let t=e.revealDocNames?e.content:yt(e.content).text;if(e.redact){let{redacted:n,patterns:i,lineCount:a}=r(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),i.length>0&&e.redactions.push({file:e.name,lineCount:a,patterns:i})}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=W(t,`utf8`);bt({zipfile:e.zipfile,name:`${e.prefix}/${R(t)}`,content:t.endsWith(`.ips`)?et(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 xt(t){let{redact:r,outputPath:i,logger:o}=t,s=t.revealDocNames??!1,c=t.userLogsDir??B(q(),`.ok`,`logs`),l=t.projectDir?ct(t.projectDir,o):null;U(z(i),{recursive:!0}),o?.info({projectSlug:l},`gathering diagnostic data`);let u=lt();u.desktop=t.desktop??null,u.language=t.language??null;let{files:d,excludedByProjectSlug:ee}=gt(l,c),{files:f}=t.projectDir?_t(t.projectDir):{files:[]},{files:p}=t.projectDir?vt(t.projectDir):{files:[]},m=t.shipItLogFiles??[],h=t.diagnosticReports?.files??[];o?.info({logFileCount:d.length,logFilesExcludedByProjectSlug:ee,lockFileCount:f.length,localSinkFileCount:p.length,shipItLogFileCount:m.length,diagnosticReportCount:h.length},`files collected`);let g=[],_=[],{ZipFile:v}=await import(`./yazl-BwMlCqRQ.mjs`).then(t=>e(t.default,1)),y=new v;Y({zipfile:y,files:[...d,...m],prefix:`logs`,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o}),Y({zipfile:y,files:f,prefix:`lockdir`,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o}),Y({zipfile:y,files:p,prefix:`local-logs`,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o}),Y({zipfile:y,files:t.bugReportLedgerFiles??[],prefix:a,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o}),Y({zipfile:y,files:h,prefix:`diagnostic-reports`,redact:r,revealDocNames:s,bundleFiles:_,redactions:g,logger:o});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??R(e.sourcePath)}`;y.addBuffer(t,n),_.push(n)}catch(t){o?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&bt({zipfile:y,name:`note.txt`,content:t.note,redact:r,revealDocNames:s,bundleFiles:_,redactions:g});let b=new Set(h.map(e=>`diagnostic-reports/${R(e)}`)),x=_.filter(e=>b.has(e)),S=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Xe(t.diagnosticReports,x.length);y.addBuffer(Buffer.from(`${S}\n`,`utf8`),`state/diagnostic-reports-status.txt`),_.push(`state/diagnostic-reports-status.txt`);let C=JSON.stringify(u,null,2);y.addBuffer(Buffer.from(C,`utf8`),`sysinfo.json`),_.push(`sysinfo.json`);let w={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:l,files:_,redactions:g,sysinfo:u};y.addBuffer(Buffer.from(JSON.stringify(w,null,2),`utf8`),`MANIFEST.json`);let T=g.reduce((e,t)=>e+t.lineCount,0),E=new Set(m.map(e=>`logs/${R(e)}`)),D=_.filter(e=>E.has(e)),O=new Set((t.bugReportLedgerFiles??[]).map(e=>`${a}/${R(e)}`)),k=_.filter(e=>O.has(e)),A=l?_.filter(e=>e.startsWith(`logs/`)&&!dt(e)&&!E.has(e)):[],j=x.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.`]:[],M=j.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...j]:[`Redaction was disabled for this bundle; file contents are unmodified.`],N=[`# Bug Report Bundle`,``,`Generated: ${w.generatedAt}`,`Project: ${l??`(unscoped)`}`,`Discipline version: ${w.disciplineVersion}`,``,`## Contents`,``,..._.map(e=>`- ${e}`),``,`## Privacy`,``,...A.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:`,...A.map(e=>`- ${e}`),``]:[],...D.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:`,...D.map(e=>`- ${e}`),``]:[],...x.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:`,...x.map(e=>`- ${e}`),``]:[],...k.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:`,...k.map(e=>`- ${e}`),``]:[],...r?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${n.join(`, `)}`,T>0?`${T} line(s) were scrubbed across ${g.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...j,``,`This bundle is safe to attach to a GitHub issue.`]:M].join(`
2
- `);y.addBuffer(Buffer.from(N,`utf8`),`README.md`),y.end();let P=he(i);return y.outputStream.pipe(P),await new Promise((e,t)=>{P.on(`close`,e),P.on(`error`,t)}),o?.info({bundlePath:i,fileCount:_.length,redactionCount:T},`bundle written`),{zipPath:i,summary:{projectSlug:l,files:_,redactions:g,redactedLineCount:T,generatedAt:w.generatedAt}}}var St=e(O(),1),X=e(P(),1);function Ct(e){return b({absPath:v(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function wt({home:e=q(),env:n=process.env}={}){let r=Ct(e),{override:i,preferenceList:a}=x(n),{locale:s,source:l}=t({override:i,storedPreference:r,supportedLocales:o,preferenceList:a,autoDetectableLocales:c});return{preference:r,locale:s,source:l,systemLanguages:a}}function Tt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e,t){if(typeof e==`string`)return Tt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>Z(e,t));if(!Et(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Z(i,t);return n}function Dt(e,t){let n=W(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)}}}K(e,r?`${a.join(`
5
- `)}\n`:a.join(`
6
- `))}function Ot(e,t){let n=W(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=Tt(n,t.contentDir);r!==n&&K(e,r)}}function kt(e,t){let n=W(e,`utf-8`),r=Tt(n,t.contentDir);r!==n&&K(e,r)}function At(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>B(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(B(e.stagingDir,n)))Nt(r)?Dt(r,t):r.endsWith(`.json`)?Ot(r,t):kt(r,t);for(let n of At(B(e.stagingDir,`state`))){let e=R(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 B(e,...It,zt)}function Kt(e){return B(e,...It,Bt)}function qt(e){return B(e,...Lt,Vt)}function Jt(e){return B(e,...Lt,Ht)}function Yt(e){return B(e,...Rt,Ut)}function Xt(e){return B(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=B(e,`.git`,`ok`);if(!H(t))return null;let n=ue(`git`,[`-C`,t,`log`,`--oneline`,`-50`],d({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function rn(e){let t=B(e,`.git`,`ok`);if(!H(t))return null;let n=ue(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],d({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:Ee(),arch:Ce()}}function sn(){return process.env.OTEL_SDK_DISABLED===`false`}function cn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ln(e){if(!H(e))return{};let t;try{t=(0,Ne.parse)(W(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!cn(t))return{};let n=t.telemetry;if(!cn(n))return{};let r=n.localSink;return cn(r)?r:{}}function un(e){return typeof e==`boolean`?e:void 0}function dn(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function fn(e){if(cn(e))return dn(e.maxBytes)}function pn(e){let t=ln(v(`project`,e)),n=ln(v(`project-local`,e));return{enabled:un(n.enabled)??un(t.enabled)??!0,spansMaxBytes:fn(n.spans)??fn(t.spans)??52428800,logsMaxBytes:fn(n.logs)??fn(t.logs)??26214400}}function mn(e){return Me(`sha256`).update(e).digest(`hex`)}function hn(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const gn=[`"doc.name"`,`"docName"`];function _n(e){let t=W(e,`utf-8`),n=0;for(let e of gn){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!H(e))return!1;try{return U(z(t),{recursive:!0}),e.endsWith(`.ips`)?K(t,et(W(e,`utf-8`))):me(e,t),!0}catch{return!1}}function vn(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=B(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const yn=new Set([`.jsonl`]);function bn(e){let t=e.lastIndexOf(`.`);return t===-1?!1:yn.has(e.slice(t))}const xn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function Sn(e){if(Mt(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:xn.has(e.slice(t))}function Cn(e){let t=[];for(let n of vn(e)){let i=wn(e,n);if(!Sn(i))continue;let{redacted:a,patterns:o,lineCount:s}=r(W(n,`utf-8`));o.length!==0&&(K(n,a),t.push({file:i,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function wn(e,t){return de(e,t).split(fe).join(`/`)}async function Tn(e){let t=V(e.contentDir),n=V(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Qt,o=r.fetchAgentEffects??$t,s=r.fetchWatcherRecent??en,c=r.readShadowHead??nn,d=r.readCheckpointRefs??rn,ee=r.now??(()=>new Date),f=r.okVersion??(()=>se),p=r.readDesktopEnv??an,m=r.readLanguage??wt,h=r.readRuntime??on,g=r.isOtlpPushEnabled??sn,_=_e(B(Oe(),`ok-bundle-`));try{U(B(_,`telemetry`),{recursive:!0}),U(B(_,`logs`),{recursive:!0}),U(B(_,`state`),{recursive:!0}),Q(Gt(n),B(_,`telemetry`,zt)),Q(Kt(n),B(_,`telemetry`,Bt)),Q(qt(n),B(_,`logs`,Vt)),Q(Jt(n),B(_,`logs`,Ht));for(let t of e.userLogFiles??[])Q(t,B(_,`logs`,R(t)));for(let t of e.userStateFiles??[])Q(t,B(_,a,R(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Q(t,B(_,`diagnostic-reports`,R(t)))&&(v+=1);let y=B(n,`.ok`,`local`),b=B(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(H(b)){Q(b,B(_,`state`,`server.lock`));try{let e=W(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:S=`lock present but no port`}catch{S=`lock present but unparseable`}}if(C!==null){let e=await i(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(K(B(_,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await o(C);t!==null&&K(B(_,`state`,`agent-effects.json`),t);let n=await s(C);if(n!==null){let e=tn(n);e!==null&&K(B(_,`state`,`watcher-recent.jsonl`),e)}}let w=c(t);w!==null&&K(B(_,`state`,`shadow-head.txt`),w);let T=d(t);T!==null&&K(B(_,`state`,`checkpoint-refs.txt`),T),Q(Yt(n),B(_,`state`,Ut)),Q(Xt(n),B(_,`state`,Wt)),Q(B(y,`last-spawn-error.log`),B(_,`state`,`last-spawn-error.log`)),Q(B(y,l),B(_,`state`,l)),Q(B(y,u),B(_,`state`,u));let E=h(),D=p(),O=m(),k={ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};K(B(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let A=x===`running`?`running
10
- `:`not-running (${S})\n`;K(B(_,`state`,`server-status.txt`),A);let j=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Xe(e.diagnosticReports,v);if(K(B(_,`state`,`diagnostic-reports-status.txt`),`${j}\n`),e.processDir&&H(e.processDir)){let t=B(_,`process`);U(t,{recursive:!0}),me(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&Ft({stagingDir:_,contentDir:t}),e.note&&K(B(_,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=Cn(_));for(let t of e.extraFiles??[])Q(t.sourcePath,B(_,`extra`,t.zipName??R(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let P=pn(n),te=vn(_),F=[],ne=0,I=0;for(let e of te){let t=wn(_,e),n=Se(e).size,r=bn(t)?hn(e):0;F.push({path:t,bytes:n,lines:r}),ne+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(I+=_n(e))}let re={applied:M};N!==null&&(re.secretScrub=N);let L={schemaVersion:2,createdAt:ee().toISOString(),ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:mn(t),absolutePath:M?`<CONTENT_DIR>`:t},telemetry:{localSink:P,otlpPushEnabled:g()},redaction:re,serverStatus:x,files:F};K(B(_,`manifest.json`),`${JSON.stringify(L,null,2)}\n`);let ie=te.some(e=>{try{return W(e,`utf-8`).includes(t)}catch{return!1}}),ae={stagedDiagnosticReports:v,totalBytes:ne,fileCount:F.length,docNameCount:I,contentDirVisible:ie,redacted:M},oe=!1;return{stagingDir:_,manifest:L,summary:ae,cleanup:()=>{oe||(oe=!0,xe(_,{recursive:!0,force:!0}))}}}catch(e){throw xe(_,{recursive:!0,force:!0}),e}}async function En(e){let{collected:t,outputPath:n}=e,r=z(n);if(!H(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new St.ZipFile,a=vn(t.stagingDir);for(let e of a){let n=wn(t.stagingDir,e);i.addFile(e,n)}i.end();let o=he(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 Dn(e,t){let n=B(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,Ne.parse)(W(n,`utf-8`)),r=ce(t)?t.content:void 0,i=ce(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return V(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 V(e)}async function On(e,t,n,r,i){let a=ct(t,e.logger),o=await Tn({contentDir:Dn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...ft(a,e.userLogsDir??B(q(),`.ok`,`logs`)),...mt(e.cachesDir??B(q(),`Library`,`Caches`))],userStateFiles:ht(e.bugReportsDir??J()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(z(e.outputPath),{recursive:!0}),await En({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 kn(e){let{projectDir:t}=e,n=e.readDesktopEnv??an,r=e.readLanguage??wt,i=()=>ot(e.diagnosticReportsDir??B(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return On(e,t,n,r,i());let{zipPath:a,summary:o}=await xt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:mt(e.cachesDir??B(q(),`Library`,`Caches`)),bugReportLedgerFiles:ht(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);if(!H(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(W(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!S(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??C)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??w())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??Te();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}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 B(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Pn={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>ge(e),readlinkSync:e=>be(e)};function Fn(e,t=Pn){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 In(e){let t=e.replace(Mn,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Ln(e,t,n=Pn){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function Rn(e){return j(e)||A(e)||re(e)}const zn=10*1024*1024;function Bn(e,t,n,r){let i=oe(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!Rn(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);if(e.format===`file`){xe(a,{force:!0});let e=F(t,n);return{kind:`removed`,trust:e.action,...e.error===void 0?{}:{trustError:e.error}}}return e.format===`toml`?Un(a,o):e.format===`yaml`?Hn(a,e.topLevelKey,o):Vn(a,e.topLevelKey,e.serverMapSubKey,o)}function Vn(e,t,n,r){let i;try{i=W(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>zn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=ne(i,ie(t,n,r));return o?(y(e,a,{mode:L(e)}),{kind:`removed`}):{kind:`not-present`}}function Hn(e,t,n){let r;try{r=W(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>zn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,Ne.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=I(a);a.trim()===``||a.endsWith(`
11
- `)?c.endsWith(`
12
- `)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
13
- `).replace(/\n/g,`\r
14
- `));let u=`${i?``:``}${c}`;return u!==r&&y(e,u,{mode:L(e)}),{kind:`removed`}}function Un(e,t){let n=ae();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=W(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=I(a),s=a.trim()===``||a.endsWith(`
15
- `),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
16
- `)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
17
- `).replace(/\n/g,`\r
18
- `));let u=`${i?``:``}${l}`;return u!==r&&y(e,u,{mode:L(e)}),{kind:`removed`}}function Wn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Gn(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Kn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;let i=t.lock,a=t.status===`alive`&&D(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:ee(n),command:n,isDesktop:Wn(n)}}function qn(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const Jn=new Set([`running`,`desktop`,`foreign`]);function Yn(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 Xn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Zn(e){return`${Xn(e.server.usage)} | ${Xn(e.ui?.usage??null)}`}function Qn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function $n(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,Qn(e),Zn(e),qn(e),String(e.server.pid),Gn(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=Yn(qn(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(`
19
- `)}async function er(e={}){let t=e.discover??h,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??m,a=e.resolveUsage??g,o=await t(),s=[];for(let e of o){let t=n(e),r=Kn(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:qn(e)}));r(JSON.stringify(e,null,2));return}r($n(e.all?s:s.filter(e=>Jn.has(qn(e)))))}function tr(){return new N(`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 er({all:t.all===!0||e===`all`,json:t.json===!0})})}async function nr(e,t=Fe()){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 rr(e,t={}){return{targets:ar(e,t.isAlive??C)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function ir(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??nr,o=e.logger??Fe(),s=rr(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 ar(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function or(e,t=C){let n=await h(),r=null;for(let i of n){let n=$(i,`server`);if(ar(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function sr(e,t){let n=await ir({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function cr(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 lr(e){let t=await h(),n=0;for(let r of t)r!==e&&ar($(r,`server`),C)&&n++;return n}function ur(e){return new N(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. 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=_(process.cwd()),n=await ir({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 lr(t);console.log(cr(process.cwd(),e,{listingFollows:e>0})),e>0&&await er({})}return}if(i===`all`){let e=await h();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)ar($(n,`server`),C)&&(await sr(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 or(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await sr(t,r);return}let a=V(He(),i),o=_(a),s=[],c=await ir({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(cr(a,await lr(o)))})}export{qe as C,ze as D,Ve as E,Fe as O,We as S,He as T,J as _,Bn as a,Ue as b,Nn as c,jn as d,$ as f,st as g,En as h,tr as i,Le as k,Fn as l,Tn as m,ir as n,Mn as o,kn as p,ur as r,Ln as s,nr as t,In as u,ot as v,Je as w,Ge as x,Xe as y};
20
- //# sourceMappingURL=src-Nl1-dukn.mjs.map
@@ -1 +0,0 @@
1
- import{S as e,m as t,p as n,r}from"./start-BFDC8kpc.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};