@inkeep/open-knowledge 0.85.0-beta.6 → 0.85.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 (171) hide show
  1. package/dist/cli.mjs +58 -58
  2. package/dist/constants-OzLSP7kj.mjs +1 -0
  3. package/dist/dist-BjOiVhE_.mjs +2212 -0
  4. package/dist/{dist-4xO55Yaw.mjs → dist-D4atjvyH.mjs} +1 -1
  5. package/dist/index.mjs +190 -190
  6. package/dist/{init-ldk3Lxrs.mjs → init-6g-iw3DK.mjs} +9 -9
  7. package/dist/init-DTJy_5ci.mjs +1 -0
  8. package/dist/{launch-json-removal-BXYVKNWi.mjs → launch-json-removal-650Z4u6n.mjs} +1 -1
  9. package/dist/{loader-AVkdw8Hm.mjs → loader-BBLrRncZ.mjs} +1 -1
  10. package/dist/loader-DIC64kiu.mjs +1 -0
  11. package/dist/{md-manager-BGnqyqi1-CDSS__qm.mjs → md-manager-BGnqyqi1-BXD2ehDb.mjs} +125 -125
  12. package/dist/{open-browser-sLXj2Tjq.mjs → open-browser-BhWJfisj.mjs} +1 -1
  13. package/dist/parse-worker.mjs +1 -1
  14. package/dist/preview-Bgb9zo7v.mjs +1 -0
  15. package/dist/{preview-C-hKLhmn.mjs → preview-DBJ0anzA.mjs} +1 -1
  16. package/dist/public/assets/{AccountSection-C2ByOkUI.js → AccountSection-BNZMPivB.js} +1 -1
  17. package/dist/public/assets/{ActivityModeContent-BULJrReB.js → ActivityModeContent-DIae9Tbp.js} +1 -1
  18. package/dist/public/assets/{AddPropertiesButton-C6E3eAY2.js → AddPropertiesButton-zZn1saES.js} +2 -2
  19. package/dist/public/assets/{AgentConnectionsSection-BOlCjbB0.js → AgentConnectionsSection-PbNqCjhO.js} +1 -1
  20. package/dist/public/assets/{AgentDiffPane-BVF6LAi_.js → AgentDiffPane-BZAc5Xl6.js} +1 -1
  21. package/dist/public/assets/{AttachmentsSection-Ckb1l8E_.js → AttachmentsSection-BL6oSGCU.js} +1 -1
  22. package/dist/public/assets/{AuthModal-7ZC-1yVV.js → AuthModal-B97W2kBc.js} +1 -1
  23. package/dist/public/assets/{CodeMirrorPropInput-Cciy5ifm.js → CodeMirrorPropInput-CxJPJCYP.js} +3 -3
  24. package/dist/public/assets/{ContentRulesSection-ujD5Z5Kn.js → ContentRulesSection-BVzUHC1u.js} +1 -1
  25. package/dist/public/assets/{DiffViewBoundary-Cue9UIPe.js → DiffViewBoundary-CukzuN1M.js} +1 -1
  26. package/dist/public/assets/{DocumentContext-O6SVorx1.js → DocumentContext-DxNclLAT.js} +4 -4
  27. package/dist/public/assets/{EditorModeToggle-CQCRRque.js → EditorModeToggle-BpBEA6e_.js} +1 -1
  28. package/dist/public/assets/{ExcalidrawDocEditor-Bf9WFyvx.js → ExcalidrawDocEditor-Xmrc95x1.js} +1 -1
  29. package/dist/public/assets/FeedbackForm-DmQs_RCq.js +1 -0
  30. package/dist/public/assets/{GraphPanel-BmqiikMo.js → GraphPanel-CbRFSjv5.js} +2 -2
  31. package/dist/public/assets/{ImageAttachments-Dd_h_7LM.js → ImageAttachments-DmZlAyNH.js} +1 -1
  32. package/dist/public/assets/{ImportSkillDialog-DtBPqJuu.js → ImportSkillDialog-r142DGtw.js} +1 -1
  33. package/dist/public/assets/{LinkPreviewsSection-BdPyqNSV.js → LinkPreviewsSection-BHHVrJlV.js} +1 -1
  34. package/dist/public/assets/{LintConfigEditor-CjrEvNqp.js → LintConfigEditor-ClB4juPu.js} +1 -1
  35. package/dist/public/assets/{LintingSection-CBA982pF.js → LintingSection-BNRKWP-Z.js} +1 -1
  36. package/dist/public/assets/{ManagedArtifactProperties-DCTAdGr-.js → ManagedArtifactProperties-CkwB2PIQ.js} +1 -1
  37. package/dist/public/assets/ManagedArtifactProperties-CmqgVxv3.js +1 -0
  38. package/dist/public/assets/{MermaidDocEditor-DSrgP38T.js → MermaidDocEditor-DXpYD3G7.js} +1 -1
  39. package/dist/public/assets/{NetworkAccessSection-Dj1ezrw0.js → NetworkAccessSection-lslUnVW1.js} +1 -1
  40. package/dist/public/assets/{OkignoreSection-DYAQ4Haz.js → OkignoreSection-Dg2isYSX.js} +1 -1
  41. package/dist/public/assets/{PageListContext-DgTeRFU-.js → PageListContext-B4oUr1KZ.js} +1 -1
  42. package/dist/public/assets/{ProjectTemplatesSection-oiahzFKw.js → ProjectTemplatesSection-BQRFn0aR.js} +1 -1
  43. package/dist/public/assets/{PropertyDisplayRow-DVJTtG4F.js → PropertyDisplayRow-DTwcXQXe.js} +1 -1
  44. package/dist/public/assets/{PublishToGitHubDialog-CTLXiHm2.js → PublishToGitHubDialog-D7k03ktA.js} +1 -1
  45. package/dist/public/assets/{RegisteredAgentIcon-DKZ8eOKZ.js → RegisteredAgentIcon-CNf09bvo.js} +1 -1
  46. package/dist/public/assets/{ReportBugDialogBody-DoHfZBJP.js → ReportBugDialogBody-DokEvc7U.js} +1 -1
  47. package/dist/public/assets/{ReportBugMenuTrigger-B7ha_vzT.js → ReportBugMenuTrigger-BSorqVCo.js} +1 -1
  48. package/dist/public/assets/{SchemaConfigEditor-B4Sb6R0l.js → SchemaConfigEditor-DfFsfhrT.js} +1 -1
  49. package/dist/public/assets/{SearchSection-caz6Sv4E.js → SearchSection-DOHUN3xQ.js} +1 -1
  50. package/dist/public/assets/{SessionsHost-D5uQjrJt.js → SessionsHost-d345WHMu.js} +2 -2
  51. package/dist/public/assets/{SettingsDialogBody-Drcz-_Cc.js → SettingsDialogBody-BE-vgoRK.js} +2 -2
  52. package/dist/public/assets/{ShareBranchSwitchDialog-BqfHGl0s.js → ShareBranchSwitchDialog-BVpHAvAz.js} +1 -1
  53. package/dist/public/assets/{ShareReceiveDialog-CxPIsiXq.js → ShareReceiveDialog-DuE0Io5t.js} +1 -1
  54. package/dist/public/assets/{ShareReceiveMissDialog-CJ5quzhA.js → ShareReceiveMissDialog-CzdHp0x5.js} +1 -1
  55. package/dist/public/assets/{SkillCostValue-DPX8ruMM.js → SkillCostValue-BAFvtN-A.js} +1 -1
  56. package/dist/public/assets/{SkillForkDialog-BB_XS1nP.js → SkillForkDialog-DK0im2ZH.js} +1 -1
  57. package/dist/public/assets/{SkillInstallMenu-CAjgsxCn.js → SkillInstallMenu-BVEHbRUy.js} +1 -1
  58. package/dist/public/assets/{SkillOriginInline-D1tWqOqr.js → SkillOriginInline-CeyDfqua.js} +1 -1
  59. package/dist/public/assets/{SkillToolbarControls-6WW0LRUN.js → SkillToolbarControls-9aEa-UJt.js} +1 -1
  60. package/dist/public/assets/{SkillsManagerSection-B0OJHWNm.js → SkillsManagerSection-BY_rUJ96.js} +1 -1
  61. package/dist/public/assets/{SlidesPluginSection-Bi8J2lVH.js → SlidesPluginSection-qj2ynzJw.js} +1 -1
  62. package/dist/public/assets/{SlidesToolbarControls-CqXBuf70.js → SlidesToolbarControls-OD5hTRCr.js} +1 -1
  63. package/dist/public/assets/{SourceEditor-ChlmoOF6.js → SourceEditor-D1TMc8Go.js} +1 -1
  64. package/dist/public/assets/{SpellingSettings-Dkdy9B2q.js → SpellingSettings-BvzNDT7g.js} +1 -1
  65. package/dist/public/assets/{SyncSection-Z6vZnE_K.js → SyncSection-DoWGiSZu.js} +1 -1
  66. package/dist/public/assets/{SyncStatusBadge-CM_7PzwW.js → SyncStatusBadge-SzhUJBk8.js} +1 -1
  67. package/dist/public/assets/{TemplateRow-DoNZxhIJ.js → TemplateRow-PUB19e3g.js} +1 -1
  68. package/dist/public/assets/{TerminalLaunchContext-Cwrrh5Ck.js → TerminalLaunchContext-DncO203O.js} +1 -1
  69. package/dist/public/assets/{TerminalPanel-C5LSq4fA.js → TerminalPanel-CNyrqROa.js} +1 -1
  70. package/dist/public/assets/{TerminalSection-68nvfvrh.js → TerminalSection-MyreF3Qr.js} +1 -1
  71. package/dist/public/assets/{TerminalWindowApp-CrSGKKKu.js → TerminalWindowApp-B3LmGgP5.js} +1 -1
  72. package/dist/public/assets/{TextDocEditor-BXOqsewj.js → TextDocEditor-6wfmlzRU.js} +1 -1
  73. package/dist/public/assets/{ThemePluginSection-BT1NQe1R.js → ThemePluginSection-C4i43nY3.js} +2 -2
  74. package/dist/public/assets/{ThreadView-DnrRFDwk.js → ThreadView-BqSr6bFO.js} +1 -1
  75. package/dist/public/assets/{TimelineDiffPane-1hGv8QvR.js → TimelineDiffPane-CL5_9PxD.js} +1 -1
  76. package/dist/public/assets/_envelope-DwyyiIO_-B2czcEJX.js +1 -0
  77. package/dist/public/assets/{agent-connections-CykO_Ezy.js → agent-connections-Dj9-89rY.js} +1 -1
  78. package/dist/public/assets/{agent-registry-pREadnY_.js → agent-registry-CUdBP9oP.js} +1 -1
  79. package/dist/public/assets/{bridge-D8Oy74FE.js → bridge-D0M08jrS.js} +3 -3
  80. package/dist/public/assets/{card-DJoKetZ9.js → card-13ChSYBD.js} +1 -1
  81. package/dist/public/assets/{catalog-CJ_rs_wb.js → catalog-eC0BYrwO.js} +1 -1
  82. package/dist/public/assets/{client-version-B59eMHEh.js → client-version-oaUQD3HJ.js} +1 -1
  83. package/dist/public/assets/{comment-chips-DcGtlMew.js → comment-chips-B1s8pALT.js} +1 -1
  84. package/dist/public/assets/{config-provider-CIK_K42_.js → config-provider-tjvytFTT.js} +2 -2
  85. package/dist/public/assets/config-schema-C_UAFDLp.js +1 -0
  86. package/dist/public/assets/{css-color-to-hex-Cjxd2Xbp.js → css-color-to-hex-9GaMLm_g.js} +1 -1
  87. package/dist/public/assets/{diagnostic-breadcrumb-Cr0C15nJ.js → diagnostic-breadcrumb-DPgUDxA8.js} +1 -1
  88. package/dist/public/assets/{doc-undo-manager-UW0jSZSz.js → doc-undo-manager-B2pccaQo.js} +1 -1
  89. package/dist/public/assets/{field-controls-DSwLWrMh.js → field-controls-Dzoda-yy.js} +1 -1
  90. package/dist/public/assets/field-controls-nUgQuwqO.js +1 -0
  91. package/dist/public/assets/{file-tree-adapter-BeSKxnyg.js → file-tree-adapter-0APd5Uqe.js} +1 -1
  92. package/dist/public/assets/{file-tree-utils-DUpeRMj2.js → file-tree-utils-BPUSn1l0.js} +1 -1
  93. package/dist/public/assets/folder-config-api-CVKiiPvW.js +1 -0
  94. package/dist/public/assets/{frontmatter-tags-CoOxl3mC.js → frontmatter-tags-BEkbJ1mW.js} +1 -1
  95. package/dist/public/assets/{handoff-pwpLEUcJ.js → handoff-Ccrokk1b.js} +1 -1
  96. package/dist/public/assets/{index-CM686K03.js → index-wNheqXqb.js} +13 -13
  97. package/dist/public/assets/{lint-config-client-DDZrpVHz.js → lint-config-client-DNaT4xzp.js} +1 -1
  98. package/dist/public/assets/{lint-plugins-ERzf4kg6.js → lint-plugins-Dx-0Z2XW.js} +1 -1
  99. package/dist/public/assets/{markdown-lint-DeZBsw3J.js → markdown-lint-Bm1176Wf.js} +3 -3
  100. package/dist/public/assets/{markdownlint-rule-browser-60Esn3tM.js → markdownlint-rule-browser-0hwXUugA.js} +1 -1
  101. package/dist/public/assets/{navigation-targets-DTSxcGor.js → navigation-targets-CcY2FHJZ.js} +1 -1
  102. package/dist/public/assets/{page-list-cache-BNFVKu-D.js → page-list-cache-B9RqU_KB.js} +1 -1
  103. package/dist/public/assets/parse-api-error-CeEVOj25.js +1 -0
  104. package/dist/public/assets/{pending-receive-nav-store-Ccvl_4v5.js → pending-receive-nav-store-xUzVOv91.js} +1 -1
  105. package/dist/public/assets/{perf-DZJpLc5j.js → perf-CPPbaRwr.js} +1 -1
  106. package/dist/public/assets/{preferred-session-events-DknIouR1.js → preferred-session-events-0XCr3lk7.js} +1 -1
  107. package/dist/public/assets/{progress-D0oG51o9.js → progress-s1fvMtJc.js} +1 -1
  108. package/dist/public/assets/{receive-store-O9cRwWtJ.js → receive-store-CnWTih4w.js} +1 -1
  109. package/dist/public/assets/saved-themes-client-DfS9q8l3.js +1 -0
  110. package/dist/public/assets/{schema-section-C8DGjvNX.js → schema-section-DFiSaK5s.js} +1 -1
  111. package/dist/public/assets/schemas-api-DbKS2FSh.js +112 -0
  112. package/dist/public/assets/{selection-context-bAocd9VM.js → selection-context-BgqgtfRj.js} +1 -1
  113. package/dist/public/assets/{skills-api-B7NWq2mZ.js → skills-api-B9YEcMtk.js} +1 -1
  114. package/dist/public/assets/{src-CIp5b6be.js → src-BNXwMw_z.js} +1 -1
  115. package/dist/public/assets/{startup-marks-aftNzVFI.js → startup-marks-YB3zPCjL.js} +1 -1
  116. package/dist/public/assets/storage-scope-DTSZLReS.js +1 -0
  117. package/dist/public/assets/{tag-pill-input-C9tJ_ebG.js → tag-pill-input-CUjBNOlr.js} +1 -1
  118. package/dist/public/assets/{target-navigation-intent-D7IZjXLN.js → target-navigation-intent-OCgrT_rG.js} +1 -1
  119. package/dist/public/assets/{telemetry-impl-CKW89ItP.js → telemetry-impl-C-MNVi_-.js} +1 -1
  120. package/dist/public/assets/{telemetry-startup-Bs8b3-XO.js → telemetry-startup-D7wX8v1x.js} +1 -1
  121. package/dist/public/assets/terminal-cli-display-Dfy7Rj7j.js +1 -0
  122. package/dist/public/assets/{terminal-command-events-DYVYsw0p.js → terminal-command-events-YJjbnpwG.js} +1 -1
  123. package/dist/public/assets/{terminal-launch-events-C1I24zal.js → terminal-launch-events-C_GWUJjY.js} +1 -1
  124. package/dist/public/assets/{typing-burst-detector-Bxrmsx3r.js → typing-burst-detector-y3QwDTWh.js} +2 -2
  125. package/dist/public/assets/{use-activity-panel-CdrfMfLb.js → use-activity-panel-XYGcQ1C2.js} +1 -1
  126. package/dist/public/assets/{use-apply-config-color-theme-B9f6n0Cd.js → use-apply-config-color-theme-D0H8BLH0.js} +2 -2
  127. package/dist/public/assets/{use-conflicts-BJFBAg9M.js → use-conflicts-CIO4TSqq.js} +1 -1
  128. package/dist/public/assets/{use-installed-clis-98lB00dU.js → use-installed-clis-CTgVOGN1.js} +2 -2
  129. package/dist/public/assets/{use-live-xterm-theme-CMmPbV7u.js → use-live-xterm-theme-D4ySF_-p.js} +1 -1
  130. package/dist/public/assets/{use-open-skill-ZYDfMBAv.js → use-open-skill-TzSpBLob.js} +1 -1
  131. package/dist/public/assets/{use-semantic-search-status-Cqw3SIgk.js → use-semantic-search-status-CRBCNkG6.js} +1 -1
  132. package/dist/public/assets/{use-skill-origin-f6iU7bK5.js → use-skill-origin-C4Hj71IE.js} +1 -1
  133. package/dist/public/assets/{use-skill-targets-CcZTp1aJ.js → use-skill-targets-9Csbq0fG.js} +1 -1
  134. package/dist/public/assets/{use-skills-D4I9tjyB.js → use-skills-BzbDGc60.js} +1 -1
  135. package/dist/public/assets/{use-terminal-enabled-CrnwtMub.js → use-terminal-enabled-CuAffArr.js} +1 -1
  136. package/dist/public/assets/{use-timeline-entry-diff-DZtvF4rg.js → use-timeline-entry-diff-kcsoRRdt.js} +2 -2
  137. package/dist/public/assets/{use-workspace-CF2-WOaH.js → use-workspace-eebQ7TvN.js} +1 -1
  138. package/dist/public/index.html +70 -70
  139. package/dist/{registry-probes-AWqbJuf-.mjs → registry-probes-C2nD33iz.mjs} +3 -3
  140. package/dist/{removal-file-path-Bl0xISuT.mjs → removal-file-path-12ORsirV.mjs} +1 -1
  141. package/dist/{repair-launch-json-C1q2V-kv.mjs → repair-launch-json-3Gc4O-ML.mjs} +1 -1
  142. package/dist/{repair-mcp-configs-vv41a7xY.mjs → repair-mcp-configs-BY4nLsOK.mjs} +1 -1
  143. package/dist/src-CmzajpZ0.mjs +1 -0
  144. package/dist/src-Cy0PC818.mjs +14 -0
  145. package/dist/{start-sIP2yOWJ.mjs → start-Bp5-1uK5.mjs} +3 -3
  146. package/dist/start-LjitolRl.mjs +1 -0
  147. package/package.json +4 -4
  148. package/dist/constants-BvlvLl1n.mjs +0 -1
  149. package/dist/dist-Bkpf6l5f.mjs +0 -2212
  150. package/dist/init-DBZrc26-.mjs +0 -1
  151. package/dist/loader-ClbHn4dH.mjs +0 -1
  152. package/dist/preview-C8T1hpsw.mjs +0 -1
  153. package/dist/public/assets/FeedbackForm-Nms6yFro.js +0 -1
  154. package/dist/public/assets/ManagedArtifactProperties-Cp5xFdlU.js +0 -1
  155. package/dist/public/assets/_envelope-g8Le8UBe-6j_3zVcA.js +0 -1
  156. package/dist/public/assets/config-schema-Dh_H8E-u.js +0 -1
  157. package/dist/public/assets/field-controls-C6S4B1Im.js +0 -1
  158. package/dist/public/assets/folder-config-api-Db5-uEQR.js +0 -1
  159. package/dist/public/assets/parse-api-error-B5EVRh3T.js +0 -1
  160. package/dist/public/assets/saved-themes-client-ByYw6oZt.js +0 -1
  161. package/dist/public/assets/schemas-api-CQHNNDP6.js +0 -112
  162. package/dist/public/assets/storage-scope-lp6Y3sn1.js +0 -1
  163. package/dist/public/assets/terminal-cli-display-Bn8rI2FY.js +0 -1
  164. package/dist/src-C3d2YqKO.mjs +0 -1
  165. package/dist/src-D7NPnfwO.mjs +0 -14
  166. package/dist/start-BHGwh3sJ.mjs +0 -1
  167. /package/dist/public/assets/{constants-github-DOek7bCt.js → constants-github-B7yhDvQc.js} +0 -0
  168. /package/dist/public/assets/{doc-extensions-CcO7K8uD-B004ggqh.js → doc-extensions-CcO7K8uD-DG9uHV54.js} +0 -0
  169. /package/dist/public/assets/{logging-renderer-log-Bvxj7ztp.js → logging-renderer-log-CqIZVUIQ.js} +0 -0
  170. /package/dist/public/assets/{share-D-LUU2aX-DfD-mrg-.js → share-D-LUU2aX-B7Yg0G_m.js} +0 -0
  171. /package/dist/public/assets/{util-doc-name-D-_o-n0R.js → util-doc-name-DRKmy6g9.js} +0 -0
@@ -1,14 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Cf as t,Gc as n,Gu as r,H as i,Kc as a,Ml as o,Nl as s,Sf as c,Tf as l,U as u,Vc as d,W as f,_a as p,_f as m,bf as h,ff as g,ga as ee,l as _,u as te}from"./md-manager-BGnqyqi1-CDSS__qm.mjs";import{At as v,Li as y,Qn as b,Ri as x,Si as S,Ta as C,Tr as w,as as T,bi as E,cr as ne,fr as D,is as re,ko as O,m as ie,mi as k,rs as A,si as j,ts as M,ws as N,xi as ae}from"./dist-Bkpf6l5f.mjs";import{t as oe}from"./yazl-BBz29IQN.mjs";import{Ct as P,ot as se,st as ce}from"./init-ldk3Lxrs.mjs";import{l as le,w as ue}from"./registry-probes-AWqbJuf-.mjs";import{c as de}from"./colors-r_owlCuY.mjs";import{t as fe}from"./is-object-BGze3w87.mjs";import{n as pe}from"./constants-BvlvLl1n.mjs";import"./loader-AVkdw8Hm.mjs";import"./preview-C-hKLhmn.mjs";import{execFile as me,execSync as he,spawnSync as ge}from"node:child_process";import{basename as F,dirname as I,isAbsolute as _e,join as L,relative as ve,resolve as R,sep as z,win32 as ye}from"node:path";import{closeSync as be,cpSync as xe,createWriteStream as Se,existsSync as B,lstatSync as Ce,mkdirSync as V,mkdtempSync as we,openSync as Te,readFileSync as H,readSync as Ee,readdirSync as U,readlinkSync as De,realpathSync as Oe,rmSync as ke,rmdirSync as Ae,statSync as je,writeFileSync as W}from"node:fs";import{arch as Me,freemem as Ne,homedir as G,hostname as Pe,platform as Fe,release as Ie,tmpdir as Le,totalmem as Re,type as ze,uptime as Be}from"node:os";import{readFile as Ve,readdir as He,stat as Ue}from"node:fs/promises";import{createHash as We}from"node:crypto";function Ge(e,t){let n=t.map(e=>[N(e),e]);for(let t of e){let e=N(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function Ke(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=Ge([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=Ge(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function qe(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const Je=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function Ye(e,t,n=D){if(e!==void 0&&!Je.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Xe=null;function Ze(e){Xe=e}function Qe(){return Xe??process.cwd()}const $e=`Open Knowledge`;function et(e={}){let t=e.platformName??process.platform,n=e.productName??h().productName;return se(t).join(ce({...e,platformName:t}),n)}function tt(e={}){let t=e.platformName??process.platform,n=e.home??G(),r=e.env??process.env,i=se(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,`${h().packageName.replaceAll(`/`,``)}-updater`)}function nt(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 rt(e){let t=L(e,`state.json`);if(!B(t))return[];let n;try{n=JSON.parse(H(t,`utf-8`))}catch{return[]}return nt(n)??[]}function it(e){let t=L(e,`state.json`);if(!B(t))return!1;try{return nt(JSON.parse(H(t,`utf-8`)))!==null}catch{return!1}}const at=8192;function ot(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 st(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const ct=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function lt(e){return e.replace(ct,`$1"[REDACTED-DEVICE-ID]"`)}function ut(e){return lt(st(e))}const dt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function ft(e){if(typeof e!=`string`)return null;let t=dt.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 pt(e){let t=Te(e,`r`);try{let e=Buffer.alloc(at),n=0,r=!1;for(;n<at;){let i=Ee(t,e,n,at-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{be(t)}}function mt(e){try{let t=pt(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:ft(a)}}catch{return{kind:`unreadable`}}}function ht(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function gt(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=U(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=L(e,t.name),r;try{r=je(n).mtimeMs}catch{continue}if(r<i)continue;let c=mt(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!ht(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}const _t=`state/os-termination-evidence.json`,vt=6048e5,yt=/openknowledge/i,bt=Object.values(m).map(t);function xt(e={}){return(t,n)=>new Promise(r=>{try{me(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...St(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function St(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function Ct(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
2
- `)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function wt(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function Tt(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function Et(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function q(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Dt(e,t){let n=t.indexOf(`
3
- `);if(n===-1)return null;let r,i;try{r=q(JSON.parse(t.slice(0,n))),i=q(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=q(e);t===null||typeof t.name!=`string`||!ht(t.name)||a.push({name:t.name,pid:K(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:K(t.rpages),lifetimeMaxPages:K(t.lifetimeMax)})}let o=ft(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:K(q(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?ht(i.largestProcess):null,ownedProcesses:a}}const Ot=/^JetsamEvent-.*\.ips$/;function kt(e,t,n,r){let i=e.flatMap(({file:e,mtimeMs:n})=>n!==null&&n>=t?[{file:e,mtimeMs:n}]:[]);return i.sort((e,t)=>r===`newest-first`?t.mtimeMs-e.mtimeMs:e.mtimeMs-t.mtimeMs),{files:i.slice(0,n).map(({file:e})=>e),statFailed:e.filter(({mtimeMs:e})=>e===null).length,droppedOverCap:Math.max(0,i.length-n)}}async function At(e,t){let n=wt(`darwin`,`macos-jetsam`,[L(e,`JetsamEvent-*.ips`)]),r;try{r=await He(e)}catch(e){return Tt(n,e.code??`unknown`)}let i=kt(await Promise.all(r.filter(e=>Ot.test(e)).map(async t=>{try{return{file:t,mtimeMs:(await Ue(L(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-vt,50,`newest-first`);n.unparseable+=i.statFailed,n.droppedOverCap=i.droppedOverCap;for(let t of i.files){let r=null;try{r=Dt(t,await Ve(L(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return Et(n)}const jt=[`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Out of memory|oom-kill|Killed process|Killed /|memory pressure`,`_TRANSPORT=kernel`,`+`,`_SYSTEMD_UNIT=systemd-oomd.service`],Mt=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/;function Nt(e,t){if(e===`systemd-oomd`){let e=/^Killed (\S+)/.exec(t);if(e===null)return null;let n=e[1]?.split(`/`).pop()??``;return{origin:`systemd-oomd`,action:`oomd-kill`,pid:null,processName:null,unit:yt.test(n)?n:null,trigger:/swap used/.test(t)?`swap`:/memory pressure/.test(t)?`memory-pressure`:null}}if(e!==`kernel`)return null;let n=/Killed process (\d+) \(([^)]+)\)/.exec(t);if(n!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(n[1]),processName:n[2]??null,unit:null,trigger:null};let r=/task=([^,]+),pid=(\d+)/.exec(t);if(r!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(r[2]),processName:r[1]??null,unit:null,trigger:null};let i=/^(\S+) invoked oom-killer/.exec(t);return i===null?null:{origin:`kernel`,action:`oom-invoked`,pid:null,processName:i[1]??null,unit:null,trigger:null}}function Pt(e){let t=[],n=0,r=0;for(let i of e.split(`
4
- `)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=Mt.exec(i);if(e===null){r+=1;continue}let[,a=``,o=``,s=``]=e;if(!yt.test(s)){n+=1;continue}let c=Nt(o,s);if(c===null){r+=1;continue}t.push({kind:`journal`,at:a,...c})}return{events:t,foreignIgnored:n,unparseable:r}}async function Ft(e){let t=wt(`linux`,`linux-journal`,[`journalctl ${jt.join(` `)}`]),n=await e(`journalctl`,[...jt]),r=n.status===1&&/^-- No entries --$/m.test(n.stdout);if(n.status!==0&&!r)return Tt(t,Ct(n));let i=Pt(n.stdout);return t.droppedOverCap=Math.max(0,i.events.length-50),t.events.push(...i.events.slice(-50)),t.foreignIgnored=i.foreignIgnored,t.unparseable=i.unparseable,/not seeing messages from other users/i.test(`${n.stdout}\n${n.stderr}`)&&(t.restrictedToCurrentUser=!0),Et(t)}const It={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},Lt={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function Rt(e){return e===`System`?It:Lt}function zt(e){let t=`System[(${Object.keys(Rt(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${vt}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${bt.map(e=>`Data='${e}'`).join(` or `)}]]`}function Bt(e){return[`qe`,e,`/q:${zt(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function Vt(e){return ye.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function Ht(e){return e.replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&apos;/g,`'`).replace(/&amp;/g,`&`)}function Ut(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function Wt(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>Ht(e[1]??``).trim())}function Gt(e,t){let n=Rt(e),r=[],i=0,a=0;for(let o of t.match(/<Event[\s>][\s\S]*?<\/Event>/g)??[]){let t=/<Provider\s+Name=['"]([^'"]+)['"]/.exec(o)?.[1],s=Number(/<EventID[^>]*>(\d+)<\/EventID>/.exec(o)?.[1]),c=/<TimeCreated\s+SystemTime=['"]([^'"]+)['"]/.exec(o)?.[1];if(t===void 0||!Number.isInteger(s)||c===void 0){a+=1;continue}if(n[s]!==t){i+=1;continue}let l=Wt(o,`Data`),u=Wt(o,`Name`),d=[...l,...u].some(e=>yt.test(e));if(e===`Application`&&!d){i+=1;continue}r.push({kind:`windows-event`,at:c,log:e,provider:t,eventId:s,mentionsOpenKnowledge:d,data:e===`Application`?l.filter(e=>e!==``&&!Ut(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function Kt(e,t){let n=Vt(t),r=[`System`,`Application`],i=wt(`win32`,`windows-event-log`,r.map(e=>`${n} ${Bt(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,Bt(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${Ct(t)}`);continue}let n=Gt(e,t.stdout);i.droppedOverCap+=Math.max(0,n.events.length-50),i.events.push(...n.events.slice(0,50)),i.foreignIgnored+=n.foreignIgnored,i.unparseable+=n.unparseable}return o.length===r.length?Tt(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:Et(i)}async function qt(e={}){let t=e.platform??process.platform,n=e.runCommand??xt(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return At(e.macosReportsDir??`/Library/Logs/DiagnosticReports`,r);case`linux`:return Ft(n);case`win32`:return Kt(n,e.systemRoot??process.env.SystemRoot);default:return{...wt(t,null,[]),outcome:`unsupported`}}}const Jt={schemaVersion:1,outcome:`not-collected`};function Yt(e){return`${JSON.stringify(e??Jt,null,2)}\n`}const Xt={"macos-jetsam":`macOS low-memory reports`,"linux-journal":`system journal`,"windows-event-log":`Windows event logs`};function Zt(e){let t=[`${e.windowDays}d`,`${e.events.length} kept`,`${e.foreignIgnored} other-process record(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&t.push(`${e.droppedOverCap} older dropped over cap`);let n=e.source?` from ${Xt[e.source]}`:``,r=e.unavailableReason?`, ${e.unavailableReason}`:``;return`${e.outcome}${n}${r} (${t.join(`; `)})`}function J(){return L(M(),`bug-reports`)}function Qt(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=J(),r=`${t}-bugreport`,i=L(n,`${r}.zip`);for(let e=2;B(i);e+=1)i=L(n,`${r}-${e}.zip`);return i}function $t(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function en(e,t){let n=L(e,`.ok`,`config.yml`);if(B(n))try{let e=H(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 B(L(e,`.ok`))?We(`sha256`).update(R(e)).digest(`hex`).slice(0,12):null}function tn(){let e={timestamp:new Date().toISOString(),platform:Fe(),osType:ze(),osRelease:Ie(),hostname:`[redacted]`,uptime:Be(),freeMem:Ne(),totalMem:Re(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=he(`sw_vers -productVersion 2>/dev/null`,O({encoding:`utf8`})).trim()}catch{}try{let t=L(__dirname,`..`,`..`,`package.json`);B(t)&&(e.okVersion=JSON.parse(H(t,`utf8`)).version)}catch{}return e}const nn=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function rn(e){let t=F(e);return nn.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function an(e,t){return ln(e,t).files}const on=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function sn(e,t=le){let n=L(e,`${t}.ShipIt`);if(!B(n))return[];let r;try{r=U(n)}catch{return[]}return on.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>L(n,e.entry)))}function cn(e){if(!B(e))return[];try{let t=new Map;for(let n of U(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-_.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=>L(e,t))}catch{return[]}}function ln(e,t){if(!B(t))return{files:[],excludedByProjectSlug:0};let n=U(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>L(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(rn),i=[],a=r.filter(t=>{try{return H(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=>!rn(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function un(e){let t=L(e,`.ok`,`local`);return B(t)?{files:[`server.lock`,`last-spawn-error.log`,n,d].map(e=>L(t,e)).filter(e=>B(e))}:{files:[]}}function dn(e){let t=L(e,`.ok`,`local`,`logs`);return B(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>L(t,e)).filter(e=>B(e))}:{files:[]}}function fn(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#${We(`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 pn(e){let t=e.revealDocNames?e.content:fn(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=p(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=H(t,`utf8`);pn({zipfile:e.zipfile,name:`${e.prefix}/${F(t)}`,content:t.endsWith(`.ips`)?ut(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 mn(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??L(M(),`logs`),s=t.projectDir?en(t.projectDir,i):null;V(I(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=tn();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=ln(s,o),{files:d}=t.projectDir?un(t.projectDir):{files:[]},{files:f}=t.projectDir?dn(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new _;Y({zipfile:v,files:[...l,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:d,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:f,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:te,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i});for(let e of t.extraFiles??[])try{let t=H(e.sourcePath),n=`extra/${e.zipName??F(e.sourcePath)}`;v.addBuffer(t,n),g.push(n);let r=$t(e,n);r!==null&&h.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&pn({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${F(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:ot(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`),pn({zipfile:v,name:_t,content:Yt(t.osTerminationEvidence),redact:n,revealDocNames:!0,bundleFiles:g,redactions:h});let S=JSON.stringify(c,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:g,redactions:h,sysinfo:c};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${F(e)}`)),E=g.filter(e=>T.has(e)),ne=new Set((t.bugReportLedgerFiles??[]).map(e=>`${te}/${F(e)}`)),D=g.filter(e=>ne.has(e)),re=s?g.filter(e=>e.startsWith(`logs/`)&&!rn(e)&&!T.has(e)):[],O=b.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],ie=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.`],k=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...re.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:`,...re.map(e=>`- ${e}`),``]:[],...E.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...E.map(e=>`- ${e}`),``]:[],...b.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...b.map(e=>`- ${e}`),``]:[],...(t.osTerminationEvidence?.events.length??0)>0?[`Termination records: read from the operating system rather than written`,`by OpenKnowledge, covering the last 7 days, to explain an exit the app`,`could not record itself. On macOS: the memory-pressure (jetsam) reports`,`that list processes of this app, with each one's memory use and whether`,`it was killed. On Linux: kernel and systemd-oomd out-of-memory kills of`,`this app, as structured fields with the machine name, cgroup paths and`,`user id left out. On Windows: crash and hang records for this app with`,`file paths left out, plus the time of every shutdown, restart, power`,`loss and low-memory warning on the machine, whatever caused it:`,`- ${_t}`,``]:[],...D.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:`,...D.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${ee.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...O,``,`This bundle is safe to attach to a GitHub issue.`]:ie].join(`
5
- `);v.addBuffer(Buffer.from(k,`utf8`),`README.md`),v.end();let A=Se(r);return v.outputStream.pipe(A),await new Promise((e,t)=>{A.on(`close`,e),A.on(`error`,t)}),i?.info({bundlePath:r,fileCount:g.length,redactionCount:w},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:g,redactions:h,redactedLineCount:w,generatedAt:C.generatedAt}}}var hn=r(),gn=e(oe(),1),X=e(de(),1);function _n(e){let t=T(`user`,e,e);return A({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function vn({home:e=G(),env:t=process.env}={}){let n=_n(e),{override:r,preferenceList:i}=re(t),{locale:a,source:c}=Ke({override:r,storedPreference:n,supportedLocales:s,preferenceList:i,autoDetectableLocales:o});return{preference:n,locale:a,source:c,systemLanguages:i}}function yn(e){let t=new Set([e]);try{t.add(Oe.native(e))}catch{return[e].filter(e=>e.length>0)}return[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length)}function bn(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function xn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sn(e,t){if(typeof e==`string`)return bn(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>Sn(e,t));if(!xn(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Sn(i,t);return n}function Cn(e,t){let n=H(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
6
- `),i=n.split(`
7
- `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=Sn(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
8
- `)}\n`:a.join(`
9
- `);W(e,o)}function wn(e,t){let n=H(e,`utf-8`);if(n.trim().length!==0)try{let r=Sn(JSON.parse(n),t),i=n.endsWith(`
10
- `)?`
11
- `:``;W(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=bn(n,t.contentDirSpellings);r!==n&&W(e,r)}}function Tn(e,t){let n=H(e,`utf-8`),r=bn(n,t.contentDirSpellings);r!==n&&W(e,r)}function En(e){try{return U(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>L(e,t.name))}catch{return[]}}const Dn=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function On(e){return/\.log\.\d+$/.test(e)}function kn(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||On(e)}const An=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function jn(e){let t={contentDirSpellings:yn(e.contentDir)};for(let n of An)for(let r of En(L(e.stagingDir,n)))kn(r)?Cn(r,t):r.endsWith(`.json`)?wn(r,t):Tn(r,t);for(let n of En(L(e.stagingDir,`state`))){let e=F(n);n.endsWith(`.jsonl`)?Cn(n,t):Dn.has(e)?wn(n,t):Tn(n,t)}}const Mn=[`.ok`,`local`,`telemetry`],Nn=[`.ok`,`local`,`logs`],Pn=[`.ok`,`local`,`loss-capture`],Fn=`spans-current.jsonl`,In=`spans-prev.jsonl`,Ln=`server-current.jsonl`,Rn=`server-prev.jsonl`,zn=`loss-current.jsonl`,Bn=`loss-prev.jsonl`;function Vn(e){return L(e,...Mn,Fn)}function Hn(e){return L(e,...Mn,In)}function Un(e){return L(e,...Nn,Ln)}function Wn(e){return L(e,...Nn,Rn)}function Gn(e){return L(e,...Pn,zn)}function Kn(e){return L(e,...Pn,Bn)}const qn=1e3;async function Jn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(qn)});return t.ok?await t.text():null}catch{return null}}async function Yn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(qn)});return t.ok?await t.text():null}catch{return null}}async function Xn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(qn)});return t.ok?await t.text():null}catch{return null}}function Zn(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
12
- `)}\n`:null}catch{return null}}function Qn(e){let t=L(e,`.git`,`ok`);if(!B(t))return null;let n=ge(`git`,[`-C`,t,`log`,`--oneline`,`-50`],O({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function $n(e){let t=L(e,`.git`,`ok`);if(!B(t))return null;let n=ge(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],O({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function er(){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 tr(){return{nodeVersion:process.version,platform:Fe(),arch:Me()}}function nr(){return process.env.OTEL_SDK_DISABLED===`false`}function rr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ir(e){if(!B(e))return{};let t;try{t=(0,hn.parse)(H(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(!rr(t))return{};let n=t.telemetry;if(!rr(n))return{};let r=n.localSink;return rr(r)?r:{}}function ar(e){return typeof e==`boolean`?e:void 0}function or(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Z(e){if(rr(e))return or(e.maxBytes)}function sr(e){let t=ir(T(`project`,e)),n=ir(T(`project-local`,e));return{enabled:ar(n.enabled)??ar(t.enabled)??!0,spansMaxBytes:Z(n.spans)??Z(t.spans)??52428800,logsMaxBytes:Z(n.logs)??Z(t.logs)??26214400}}function cr(e){return We(`sha256`).update(e).digest(`hex`)}function lr(e){let t=H(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const ur=[`"doc.name"`,`"docName"`];function dr(e){let t=H(e,`utf-8`),n=0;for(let e of ur){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!B(e))return!1;try{return V(I(t),{recursive:!0}),e.endsWith(`.ips`)?W(t,ut(H(e,`utf-8`))):xe(e,t),!0}catch{return!1}}function fr(e){let t=[],n=e=>{let r=U(e,{withFileTypes:!0});for(let i of r){let r=L(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const pr=new Set([`.jsonl`]);function mr(e){let t=e.lastIndexOf(`.`);return t!==-1&&pr.has(e.slice(t))}const hr=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function gr(e){if(On(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&hr.has(e.slice(t))}function _r(e){let t=[];for(let n of fr(e)){let r=vr(e,n);if(!gr(r))continue;let{redacted:i,patterns:a,lineCount:o}=p(H(n,`utf-8`));a.length!==0&&(W(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function vr(e,t){return ve(e,t).split(z).join(`/`)}async function yr(e){let t=R(e.contentDir),r=R(e.projectDir??e.contentDir),i=e.deps??{},o=i.fetchAgentPresence??Jn,s=i.fetchAgentEffects??Yn,c=i.fetchWatcherRecent??Xn,l=i.readShadowHead??Qn,u=i.readCheckpointRefs??$n,f=i.now??(()=>new Date),p=i.okVersion??(()=>pe),m=i.readDesktopEnv??er,h=i.readLanguage??vn,g=i.readRuntime??tr,ee=i.isOtlpPushEnabled??nr,_=we(L(Le(),`ok-bundle-`));try{V(L(_,`telemetry`),{recursive:!0}),V(L(_,`logs`),{recursive:!0}),V(L(_,`state`),{recursive:!0}),Q(Vn(r),L(_,`telemetry`,Fn)),Q(Hn(r),L(_,`telemetry`,In)),Q(Un(r),L(_,`logs`,Ln)),Q(Wn(r),L(_,`logs`,Rn));for(let t of e.userLogFiles??[])Q(t,L(_,`logs`,F(t)));for(let t of e.userStateFiles??[])Q(t,L(_,te,F(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Q(t,L(_,`diagnostic-reports`,F(t)))&&(v+=1);let y=L(r,`.ok`,`local`),b=L(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(B(b)){Q(b,L(_,`state`,`server.lock`));try{let e=H(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:S=`lock present but no port`}catch{S=`lock present but unparseable`}}if(C!==null){let e=await o(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(W(L(_,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await s(C);t!==null&&W(L(_,`state`,`agent-effects.json`),t);let n=await c(C);if(n!==null){let e=Zn(n);e!==null&&W(L(_,`state`,`watcher-recent.jsonl`),e)}}let w=l(t);w!==null&&W(L(_,`state`,`shadow-head.txt`),w);let T=u(t);T!==null&&W(L(_,`state`,`checkpoint-refs.txt`),T),Q(Gn(r),L(_,`state`,zn)),Q(Kn(r),L(_,`state`,Bn)),Q(L(y,`last-spawn-error.log`),L(_,`state`,`last-spawn-error.log`)),Q(L(y,a),L(_,`state`,a)),Q(L(y,n),L(_,`state`,n)),Q(L(y,d),L(_,`state`,d));let E=g(),ne=m(),D=h(),re={ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:ne,language:D}};W(L(_,`state`,`runtime.json`),`${JSON.stringify(re,null,2)}\n`);let O=x===`running`?`running
13
- `:`not-running (${S})\n`;W(L(_,`state`,`server-status.txt`),O);let ie=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:ot(e.diagnosticReports,v);if(W(L(_,`state`,`diagnostic-reports-status.txt`),`${ie}\n`),W(L(_,_t),Yt(e.osTerminationEvidence)),e.processDir&&B(e.processDir)){let t=L(_,`process`);V(t,{recursive:!0}),xe(e.processDir,t,{recursive:!0})}let k=e.redact===!0;k&&jn({stagingDir:_,contentDir:t}),e.note&&W(L(_,`note.txt`),e.note);let A=null;e.scrubSecrets===!0&&(A=_r(_));for(let t of e.extraFiles??[]){let e=t.zipName??F(t.sourcePath);if(!Q(t.sourcePath,L(_,`extra`,e))){i.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=$t(t,`extra/${e}`);n!==null&&(A??={redactions:[],redactedLineCount:0},A.redactions.push(n),A.redactedLineCount+=n.lineCount)}let j=sr(r),M=fr(_),N=[],ae=0,oe=0;for(let e of M){let t=vr(_,e),n=je(e).size,r=mr(t)?lr(e):0;N.push({path:t,bytes:n,lines:r}),ae+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(oe+=dr(e))}let P={applied:k};A!==null&&(P.secretScrub=A);let se={schemaVersion:2,createdAt:f().toISOString(),ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:ne,language:D},contentDir:{pathSha256:cr(t),absolutePath:k?`<CONTENT_DIR>`:t},telemetry:{localSink:j,otlpPushEnabled:ee()},redaction:P,serverStatus:x,files:N};W(L(_,`manifest.json`),`${JSON.stringify(se,null,2)}\n`);let ce=yn(t),le=M.some(e=>{try{let t=H(e,`utf-8`);return ce.some(e=>t.includes(e))}catch{return!1}}),ue={stagedDiagnosticReports:v,totalBytes:ae,fileCount:N.length,docNameCount:oe,contentDirVisible:le,redacted:k},de=!1;return{stagingDir:_,manifest:se,summary:ue,cleanup:()=>{de||(de=!0,ke(_,{recursive:!0,force:!0}))}}}catch(e){throw ke(_,{recursive:!0,force:!0}),e}}async function br(e){let{collected:t,outputPath:n}=e,r=I(n);if(!B(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new gn.ZipFile,a=fr(t.stagingDir);for(let e of a){let n=vr(t.stagingDir,e);i.addFile(e,n)}i.end();let o=Se(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 xr(e,t){let n=L(e,`.ok`,`config.yml`);if(B(n))try{let t=(0,hn.parse)(H(n,`utf-8`)),r=fe(t)?t.content:void 0,i=fe(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return R(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 R(e)}async function Sr(e,t,n,r,i,a){let o=en(t,e.logger),s=await yr({contentDir:xr(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...an(o,e.userLogsDir??L(M(),`logs`)),...sn(e.cachesDir??L(G(),`Library`,`Caches`))],userStateFiles:cn(e.bugReportsDir??J()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{V(I(e.outputPath),{recursive:!0}),await br({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function Cr(e){let{projectDir:t}=e,n=e.readDesktopEnv??er,r=e.readLanguage??vn,i=()=>gt(e.diagnosticReportsDir??L(G(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Sr(e,t,n,r,i(),await qt(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await mn({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:sn(e.cachesDir??L(G(),`Library`,`Caches`)),bugReportLedgerFiles:cn(e.bugReportsDir??J()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await qt(e.osTerminationEvidenceDeps):void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=S(e,t),i;try{i=H(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??w()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??Pe());if(!a||typeof a!=`object`||!k(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 wr(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 Tr(e){return e.replace(/:\d+$/,``)}function Er(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Tr(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Tr(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Tr(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 Dr=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Or(e){return f(l(),e)}function kr(){return u(l())}function Ar(){let e=l();if(e===`stable`)return Dr;let t=i(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const jr={existsSync:e=>B(e),readFileSync:(e,t)=>H(e,t),lstatSync:e=>Ce(e),readlinkSync:e=>De(e)};function Mr(e,t=jr){let n=Or(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 Nr(e){let t=e.replace(Ar(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Pr(e,t,n=jr){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const Fr=[{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`}],Ir=[...v.map(e=>ie[e]),`open-knowledge`];function Lr(e){if(!_e(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=R(e);if(t===z||I(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Rr(e,t){let n=ve(e,t);if(n.startsWith(`..`)||_e(n))return!1;let r=e;for(let e of n.split(z)){r=L(r,e);try{if(!Ce(r).isDirectory())return!1}catch{return!1}}return!0}function zr(e,t){try{return U(e).every(n=>t.has(L(e,n)))}catch{return!1}}function Br(e){let t=Lr(e),n=[],r=[],i=new Set;for(let e of Fr){let a=L(t,e.hostDir,`skills`);if(!Rr(t,a))continue;let o=Ir.map(e=>L(a,e)).filter(e=>B(e));n.push(...o);for(let e of o)i.add(e);let s=L(t,e.pruneRoot),c=a;for(;zr(c,i)&&(r.push(c),i.add(c),c!==s);){let e=I(c);if(e===c||e===t||!e.startsWith(t+z))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Vr(e){try{if(!Ce(e).isDirectory())return!1;let t=U(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Hr(e){let t=new Set,n=new Set;for(let r of Fr){let i=L(e,r.hostDir,`skills`);for(let e of Ir)t.add(L(i,e));let a=L(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=I(o);if(t===o||t===e||!t.startsWith(e+z))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Ur(e,t){let n=Lr(e),r=Hr(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(Rr(n,e)&&Vr(e))try{ke(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Rr(n,e))try{Ae(e),a.push(e)}catch{}return a}function Wr(e){let t=Lr(e),n=[];for(let e of v){let r=ie[e];n.push({path:L(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of g)n.push({path:L(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Gr(e,t){let n=[];for(let r of Wr(e))if(r.bundleId===t)try{ke(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 Kr(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function qr(e,t=Date.now()){if(e===null)return`—`;let n=qe(e,t);return n===`unknown`?`—`:n}function Jr(e){let t=I(e);return F(e)===`local`&&F(t)===`.ok`?I(t):F(e)===`.ok`?t:null}function Yr(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:Jr(e),server:{port:null,status:t.status,pid:t.pid,startedAt:null,usage:null},ui:null,hostname:null,lockPath:t.lockPath,binary:null,command:null,isDesktop:!1};let i=t.lock,a=t.status===`alive`&&E(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:ne(n),command:n,isDesktop:Kr(n)}}function Xr(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 Zr=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Qr(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 $r(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ei(e){return`${$r(e.server.usage)} | ${$r(e.ui?.usage??null)}`}function ti(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function ni(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??`—`,ti(e),ei(e),Xr(e),String(e.server.pid),qr(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=Qr(Xr(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(`
14
- `)}async function ri(e={}){let t=e.discover??b,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??y,a=e.resolveUsage??x,o=await t(),s=[];for(let e of o){let t=n(e),r=Yr(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:Xr(e)}));r(JSON.stringify(e,null,2));return}r(ni(e.all?s:s.filter(e=>Zr.has(Xr(e)))))}function ii(){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 ri({all:t.all===!0||e===`all`,json:t.json===!0})})}async function ai(e,t=ue()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=ae(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 oi(e,t={}){return{targets:li(e,t.isAlive??j)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}function si(e){try{return l()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function ci(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??ai,o=e.logger??ue(),s=t(),l=oi(s,{isAlive:e.isAlive});if(l.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let u=s.status===`alive`||s.status===`foreign-host`?s.lock.channel:void 0;if(e.force!==!0&&typeof u==`string`&&u.length>0){let t=e.selfChannel??si(o);if(t!==void 0&&u!==t)return i(`Not stopping: the server at ${e.lockDir} belongs to ${c(u)}. Stop it from that app or its CLI, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,holderChannel:u,selfChannel:t,pids:l.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:u}}}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:l.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let d=[],f=[];for(let e of l.targets)try{n(e.pid,`SIGTERM`),d.push(e)}catch(t){f.push({target:e,error:t instanceof Error?t.message:String(t)})}return d.length>0&&r(`Stopped: ${d.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:d.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:f.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),f.length>0&&i(`Failed to stop: ${f.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:d,failed:f,hadTargets:!0}}function li(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function ui(e,t=j){let n=await b(),r=null;for(let i of n){let n=$(i,`server`);if(li(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function di(e,t){let n=await ci({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function fi(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 pi(e){let t=await b(),n=0;for(let r of t)r!==e&&li($(r,`server`),j)&&n++;return n}function mi(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 the server belongs to another OpenKnowledge app (Stable or Beta) or editor windows or agents are still connected to it`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=C(process.cwd()),n=await ci({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 pi(t);console.log(fi(process.cwd(),e,{listingFollows:e>0})),e>0&&await ri({})}return}if(i===`all`){let e=await b();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)li($(n,`server`),j)&&(await di(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 ui(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await di(t,r);return}let a=R(Qe(),i),o=C(a),s=[],c=await ci({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(fi(a,await pi(o)))})}export{rt as A,qt as C,$e as D,ot as E,Qe as M,Ze as N,tt as O,Ye as P,J as S,gt as T,$ as _,Ur as a,br as b,Wr as c,Or as d,kr as f,wr as g,Er as h,ii as i,it as j,et as k,Dr as l,Nr as m,ci as n,Br as o,Mr as p,mi as r,Gr as s,ai as t,Pr as u,Cr as v,Zt as w,Qt as x,yr as y};
@@ -1 +0,0 @@
1
- import{S as e,m as t,p as n,r}from"./start-sIP2yOWJ.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};