@inkeep/open-knowledge 0.88.3-beta.3 → 0.88.3-beta.5

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 (133) hide show
  1. package/dist/cli.mjs +75 -75
  2. package/dist/config-schema.json +1 -1
  3. package/dist/config.project.schema.json +1 -1
  4. package/dist/constants-BrQxqUNL.mjs +1 -0
  5. package/dist/{dist-RdM5Fw_L.mjs → dist-BniR5KN1.mjs} +507 -507
  6. package/dist/dist-D5Ry9hFU.mjs +1 -0
  7. package/dist/index.mjs +241 -241
  8. package/dist/init-CxYfudet.mjs +1 -0
  9. package/dist/{init-DxmL4VOM.mjs → init-UZr9GVxw.mjs} +17 -17
  10. package/dist/{launch-json-removal-joOXjG0j.mjs → launch-json-removal-DdasfWvu.mjs} +1 -1
  11. package/dist/{loader-7rHc_jKi.mjs → loader-Dbq_EWV8.mjs} +1 -1
  12. package/dist/loader-iVVo3m-3.mjs +1 -0
  13. package/dist/{md-manager-BGnqyqi1-C2MED2uJ.mjs → md-manager-BGnqyqi1-CSFPyGy0.mjs} +170 -170
  14. package/dist/{open-browser-BdzTIyUA.mjs → open-browser-CDTeL9eY.mjs} +1 -1
  15. package/dist/parse-worker.mjs +1 -1
  16. package/dist/{preview-BGzTZvt_.mjs → preview-BRJmRFNY.mjs} +1 -1
  17. package/dist/preview-ca3pkl9K.mjs +1 -0
  18. package/dist/public/assets/{AccountSection-liNW8VsY.js → AccountSection-B7HfUudL.js} +1 -1
  19. package/dist/public/assets/{ActivityModeContent-DxGsZGgV.js → ActivityModeContent-CmhZGNsW.js} +1 -1
  20. package/dist/public/assets/{AddPropertiesButton-B3R_loiY.js → AddPropertiesButton-BT2D84aD.js} +1 -1
  21. package/dist/public/assets/{AgentDiffPane-Dz8RCVvt.js → AgentDiffPane-CHF9pABO.js} +1 -1
  22. package/dist/public/assets/{AttachmentsSection-De2g52kJ.js → AttachmentsSection-ByGVMvG9.js} +1 -1
  23. package/dist/public/assets/{CodeMirrorPropInput-B7U-juwF.js → CodeMirrorPropInput-DR1N5trk.js} +1 -1
  24. package/dist/public/assets/{ContentRulesSection-CsfIqEzL.js → ContentRulesSection-C9Req4oF.js} +1 -1
  25. package/dist/public/assets/{DocumentContext-C4f5Y70q.js → DocumentContext-CSDucywQ.js} +28 -28
  26. package/dist/public/assets/{EditorModeToggle-C9QIZNw1.js → EditorModeToggle-gpcNAVY7.js} +1 -1
  27. package/dist/public/assets/{ExcalidrawDocEditor-D6UENgJN.js → ExcalidrawDocEditor-Cgmhgars.js} +1 -1
  28. package/dist/public/assets/FeedbackForm-ZahAS6z-.js +1 -0
  29. package/dist/public/assets/{ImportSkillDialog-DrRHS0gi.js → ImportSkillDialog-D_sEyaYd.js} +1 -1
  30. package/dist/public/assets/{LinkPreviewsSection-DlsYZvWP.js → LinkPreviewsSection-9BI_Ve7c.js} +1 -1
  31. package/dist/public/assets/{LintConfigEditor-DK2vLKmh.js → LintConfigEditor-Cd7vchN2.js} +1 -1
  32. package/dist/public/assets/{LintingSection-CHdefNBM.js → LintingSection-CYt6Mzbc.js} +1 -1
  33. package/dist/public/assets/ManagedArtifactProperties-BBtQ0jlN.js +1 -0
  34. package/dist/public/assets/{ManagedArtifactProperties-DX3SBi-r.js → ManagedArtifactProperties-DD9uK5we.js} +1 -1
  35. package/dist/public/assets/{MermaidDocEditor-LPiNsM_Y.js → MermaidDocEditor-C_HMHLXm.js} +1 -1
  36. package/dist/public/assets/{NetworkAccessSection-DBr35sw3.js → NetworkAccessSection-BrbkXzyJ.js} +1 -1
  37. package/dist/public/assets/{PropertyDisplayRow-Dcqf2vtN.js → PropertyDisplayRow-DrvArJ_K.js} +1 -1
  38. package/dist/public/assets/{PublishToGitHubDialog-3E5sNc_C.js → PublishToGitHubDialog-D0GzPYlL.js} +1 -1
  39. package/dist/public/assets/{SchemaConfigEditor-IrI43FpI.js → SchemaConfigEditor-Cxv9ZBLk.js} +1 -1
  40. package/dist/public/assets/{SearchSection-AaRMMipY.js → SearchSection-B2hY3rln.js} +1 -1
  41. package/dist/public/assets/{SessionsHost-PrQ4fSfv.js → SessionsHost-Dhya-YYl.js} +2 -2
  42. package/dist/public/assets/{SettingsDialogBody-onEowQv-.js → SettingsDialogBody-BqSzx5Tb.js} +2 -2
  43. package/dist/public/assets/{ShareReceiveMissDialog-CWhnF66w.js → ShareReceiveMissDialog-BIVMX9w3.js} +1 -1
  44. package/dist/public/assets/{SkillToolbarControls-Ce8HyDfK.js → SkillToolbarControls-F1L2HGgN.js} +1 -1
  45. package/dist/public/assets/{SourceEditor-CGa5C04v.js → SourceEditor-KucnhTGF.js} +1 -1
  46. package/dist/public/assets/{SpellingSettings-ojjyX__V.js → SpellingSettings-DdfEMafp.js} +1 -1
  47. package/dist/public/assets/{SyncSection-DvDM3TJk.js → SyncSection-B5pv2M0p.js} +1 -1
  48. package/dist/public/assets/{SyncStatusBadge-BGKNwwqG.js → SyncStatusBadge-emJ3GW6F.js} +1 -1
  49. package/dist/public/assets/{TerminalSection-uPIUKsXh.js → TerminalSection-BTwUAO1z.js} +1 -1
  50. package/dist/public/assets/{TerminalWindowApp-BrmUwrT7.js → TerminalWindowApp-DqRB0Vv9.js} +1 -1
  51. package/dist/public/assets/{TextDocEditor-DpwR30S1.js → TextDocEditor-DI35AumM.js} +1 -1
  52. package/dist/public/assets/{ThemePluginSection-DnaaY8Z2.js → ThemePluginSection-C-SayLL7.js} +1 -1
  53. package/dist/public/assets/{ThreadView-D5qHL77s.js → ThreadView-Dykd2VWP.js} +1 -1
  54. package/dist/public/assets/{TimelineDiffPane-C4SPjhs4.js → TimelineDiffPane-BMkb_oht.js} +1 -1
  55. package/dist/public/assets/{client-version-DY4pmZts.js → client-version-BLwdND1C.js} +1 -1
  56. package/dist/public/assets/{comment-chips-jMy102T_.js → comment-chips-CvYUezma.js} +1 -1
  57. package/dist/public/assets/{config-provider-Br4OqjRm.js → config-provider-DW_79HvK.js} +1 -1
  58. package/dist/public/assets/config-schema-Cdmd2Mb9.js +1 -0
  59. package/dist/public/assets/{doc-undo-manager-DqthvzQR.js → doc-undo-manager-CLhgkmvC.js} +1 -1
  60. package/dist/public/assets/field-controls-B5XGrBle.js +1 -0
  61. package/dist/public/assets/{field-controls-xmZJD7CS.js → field-controls-CxY76_35.js} +1 -1
  62. package/dist/public/assets/{index-DZ4NdVgz.js → index-X807k4xA.js} +7 -7
  63. package/dist/public/assets/{lint-config-client-Cvaam883.js → lint-config-client-Bd8ngCU8.js} +1 -1
  64. package/dist/public/assets/{lint-plugins-DDhE0rAj.js → lint-plugins-Czjcu-H_.js} +1 -1
  65. package/dist/public/assets/{markdown-lint-BwsN6kr-.js → markdown-lint-ABdPsjuJ.js} +1 -1
  66. package/dist/public/assets/{markdownlint-rule-browser-COUuCPT4.js → markdownlint-rule-browser-C56kvk1x.js} +1 -1
  67. package/dist/public/assets/messages-B0A-BhSz.js +1 -0
  68. package/dist/public/assets/messages-Bozj8gn5.js +1 -0
  69. package/dist/public/assets/messages-BsFG2CYm.js +1 -0
  70. package/dist/public/assets/messages-CH4Y5J-b.js +1 -0
  71. package/dist/public/assets/messages-CKXedJpN.js +1 -0
  72. package/dist/public/assets/messages-CSj5vIPE.js +1 -0
  73. package/dist/public/assets/messages-CSujoKud.js +1 -0
  74. package/dist/public/assets/messages-CWaPbX0C.js +1 -0
  75. package/dist/public/assets/messages-CoLA64og.js +1 -0
  76. package/dist/public/assets/messages-Dna-nCpV.js +1 -0
  77. package/dist/public/assets/messages-Q2aFEeTO.js +1 -0
  78. package/dist/public/assets/messages-fzV9fvJY.js +1 -0
  79. package/dist/public/assets/messages-sTf2glOl.js +1 -0
  80. package/dist/public/assets/{pending-receive-nav-store-DEZs5wc3.js → pending-receive-nav-store-C-OIVRCW.js} +1 -1
  81. package/dist/public/assets/{preferred-session-events-KRrpUrGT.js → preferred-session-events-BNgqIkFZ.js} +1 -1
  82. package/dist/public/assets/{progress-BnVhYHVl.js → progress-CWeTZaVu.js} +1 -1
  83. package/dist/public/assets/saved-themes-client-Cq80E6xi.js +1 -0
  84. package/dist/public/assets/{schema-section-wsqWXSSM.js → schema-section-DNLDm-pQ.js} +1 -1
  85. package/dist/public/assets/{selection-context-DVpYX1Ay.js → selection-context-BdQZZ1HB.js} +1 -1
  86. package/dist/public/assets/{src-D9vmg6O3.js → src-DO7J3WVu.js} +1 -1
  87. package/dist/public/assets/{telemetry-impl-Bip4u1Ek.js → telemetry-impl-BTJogCD2.js} +1 -1
  88. package/dist/public/assets/{telemetry-startup-C5oki7WN.js → telemetry-startup-CjA9BXC1.js} +1 -1
  89. package/dist/public/assets/{typing-burst-detector-DS6wGcl3.js → typing-burst-detector-fQQTAQsm.js} +1 -1
  90. package/dist/public/assets/{uninstall-gnyatfna.js → uninstall-wTHWhxcV.js} +1 -1
  91. package/dist/public/assets/{use-activity-panel-CRusEB7v.js → use-activity-panel-D2QIpezB.js} +1 -1
  92. package/dist/public/assets/{use-apply-config-language-GGKe-kOK.js → use-apply-config-language-B_oVrEAw.js} +2 -2
  93. package/dist/public/assets/{use-open-skill-d6yLx6dL.js → use-open-skill-CkTZwt2b.js} +1 -1
  94. package/dist/public/assets/{use-terminal-enabled-CjYCBfkT.js → use-terminal-enabled-CZCtVTgy.js} +1 -1
  95. package/dist/public/assets/{use-timeline-entry-diff-DMMM8WST.js → use-timeline-entry-diff-BwKzDqXd.js} +1 -1
  96. package/dist/public/index.html +24 -24
  97. package/dist/public/uninstall.html +3 -3
  98. package/dist/{registry-probes-CIpYsPg_.mjs → registry-probes-DA_47MnL.mjs} +8 -8
  99. package/dist/{removal-file-path-DaE_OEQ1.mjs → removal-file-path-Yisg-4PO.mjs} +1 -1
  100. package/dist/{repair-launch-json-CzQJldao.mjs → repair-launch-json-ByHbUrvl.mjs} +1 -1
  101. package/dist/{repair-mcp-configs-CtVjr0VS.mjs → repair-mcp-configs-Cz7RUmn9.mjs} +1 -1
  102. package/dist/schemas/v0/config.project.schema.json +1 -1
  103. package/dist/src--qjAZ5fK.mjs +16 -0
  104. package/dist/src-ue3sSI-I.mjs +1 -0
  105. package/dist/{start-CZVNt90K.mjs → start-0pD-b-lJ.mjs} +4 -4
  106. package/dist/start-r-TtnKpy.mjs +1 -0
  107. package/package.json +4 -4
  108. package/dist/constants-DUZK5snO.mjs +0 -1
  109. package/dist/dist-C-GaD236.mjs +0 -1
  110. package/dist/init-dxu5hQlo.mjs +0 -1
  111. package/dist/loader-CjL-5Pk1.mjs +0 -1
  112. package/dist/preview-Cdv-UrrD.mjs +0 -1
  113. package/dist/public/assets/FeedbackForm-BVj8lH2K.js +0 -1
  114. package/dist/public/assets/ManagedArtifactProperties-A88_zVZK.js +0 -1
  115. package/dist/public/assets/config-schema-B392I0mu.js +0 -1
  116. package/dist/public/assets/field-controls-BLuu0LLy.js +0 -1
  117. package/dist/public/assets/messages--wX-6jvz.js +0 -1
  118. package/dist/public/assets/messages-BWH6xaIt.js +0 -1
  119. package/dist/public/assets/messages-Bl6RVy5f.js +0 -1
  120. package/dist/public/assets/messages-C12CEVlb.js +0 -1
  121. package/dist/public/assets/messages-C72PW9gH.js +0 -1
  122. package/dist/public/assets/messages-DnkP1Emg.js +0 -1
  123. package/dist/public/assets/messages-DpgtXjLB.js +0 -1
  124. package/dist/public/assets/messages-F_TitmhP.js +0 -1
  125. package/dist/public/assets/messages-LMNA06Bk.js +0 -1
  126. package/dist/public/assets/messages-l6-R7kj0.js +0 -1
  127. package/dist/public/assets/messages-oVKfHfSb.js +0 -1
  128. package/dist/public/assets/messages-r7y_qPx0.js +0 -1
  129. package/dist/public/assets/messages-uuZvac8w.js +0 -1
  130. package/dist/public/assets/saved-themes-client-BeMdeoNG.js +0 -1
  131. package/dist/src-Bf43s8QJ.mjs +0 -16
  132. package/dist/src-C-R2vPyW.mjs +0 -1
  133. package/dist/start-CINPPjym.mjs +0 -1
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./react-f2sANaYj.js";import{t as n}from"./compiler-runtime-BfE3aGVn.js";import"./constants-upload-CVKO8P4d.js";import{S as r,a as i,d as a,f as o,g as s,i as c,p as l,t as u,u as d,v as f,x as p,y as m}from"./schemas-B93JY9Ef.js";import{c as h,l as g,u as _}from"./share-D-LUU2aX-B7Yg0G_m.js";import{n as v}from"./_envelope-BjFOILGI-BHu_Fgux.js";import{Ct as y,F as b,I as x,L as S,M as C,Mt as w,N as T,P as E,Tt as D,j as O,wt as k}from"./schemas-api-BVrasm34.js";import{t as ee}from"./constants-github-B7yhDvQc.js";import{_ as A,g as j,h as M,y as te}from"./use-apply-config-color-theme-8k1Gcfxa.js";import{u as ne}from"./use-apply-config-language-GGKe-kOK.js";var N=Symbol.for(`@inkeep/open-knowledge/field-registry`),P=globalThis;P[N]===void 0&&(P[N]=r());var F=P[N];function I(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=re(t)?F.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function re(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}var ie=[`markdownlint`,`frontmatter`,`okf`],ae=[`missing`,`invalid`];function oe(e){return e.frontmatterScope!==void 0}[...ie];var se=[`off`,`warning`,`error`],L=`warning`,ce=[`error`,`warning`];function le(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&(w(e.getIn(r,!0))||e.deleteIn(r))}}function ue(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){le(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}le(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function de(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}var R={provider:u(ee).register(F,{scope:`user`,agentSettable:!1,reload:`boot`,defaultScope:`user`,description:"Declares that this git host is a GitHub Enterprise Server instance, so OpenKnowledge treats its remotes the way it treats github.com (OpenKnowledge credential handling, the push-permission check, share links, and the default host for `ok auth`). 'github' is the only accepted value today. A host that is not declared here and is not github.com is treated as a generic git remote, so OpenKnowledge leaves the machine's own git credentials alone and does not check push permission. Per-machine (user scope, global.yml in the OpenKnowledge home folder); a value in a project's `.ok/config.yml` is ignored. The declaration takes effect when OpenKnowledge next starts."})},fe=Object.fromEntries(Object.entries(R).map(([e,t])=>[e,t.optional().catch(void 0)])),pe=Object.fromEntries(Object.entries(R).map(([e,t])=>[e,t.nullish()])),me=a(fe).catch({});s(f(),a(R).partial());var he=a({git:a({hosts:s(f(),a(pe).nullish()).nullish()}).nullish()});function ge(e){let t=he.safeParse(e);return t.success?null:{code:`SCHEMA_INVALID`,issues:t.error.issues.map(de)}}var z=l({prefix:f().regex(/^[A-Za-z][A-Za-z0-9_-]*$/,{message:`prefix must start with a letter and use only letters, digits, _ and -`}),url:f().regex(/^https?:\/\/[^\s<>]*<num>[^\s<>]*$/,{message:`url must be an http or https URL containing <num>`})});c(z);var _e=z.nullable().catch(null);function ve(){return Object.fromEntries(y.map(e=>[e,f().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: base16 ${e} — ${k[e]}, as a #rrggbb hex string.`}).optional()]))}function B(){return A.filter(e=>e!==`default`&&e!==`custom`).map(e=>`'${e}'`).join(`, `)}var V=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),H=52428800,U=26214400,ye=12582912,W=`https://api.openai.com/v1`,G=`text-embedding-3-small`,K=96e3,q=3e4,be=2048,xe=16384e3,Se=6e5,Ce=Object.freeze([`127.0.0.1`]),we=/^[1-9]\d*(s|m|h)$/,Te=/^https?:\/\//,Ee=24550;function De(e){let t;try{t=new URL(e)}catch{return!1}let n=t.hostname.toLowerCase();return n===`localhost`||n===`127.0.0.1`||n===`[::1]`}function Oe(e){let t;try{t=new URL(e)}catch{return`invalid-url`}return t.protocol===`https:`||t.protocol===`http:`&&De(e)?null:`insecure-scheme`}function ke(e){let t=e.trim();return t===``?`./`:t}function Ae(e){let t=ke(e);return t.includes(`\0`)||t.includes(`\\`)?!1:t===`/`?!0:!(t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.split(`/`).some(e=>e===`..`))}var je=a({content:a({dir:f().register(F,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Folder OpenKnowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore. Read at server start; changing it requires a restart.`}).default(`.`),attachmentFolderPath:f().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Where pasted and dropped assets, and MCP write assets given a bare file name, are stored, relative to the content root. './' colocates beside the current document (default); '/' targets the content root; './subdir' targets a subfolder under the current document folder; 'folder' targets a fixed folder under the content root. Whitespace-only values are treated as './'.`}).refine(Ae,{message:`Invalid attachment folder path: must not contain '..' segments, NUL bytes, backslashes, or OS absolute paths (use '/' for the content root).`}).default(`./`)}).default({dir:`.`,attachmentFolderPath:`./`}),appearance:a({theme:u([`light`,`dark`,`system`]).register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),language:u([`system`,...ne]).register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Interface language. 'system' follows the operating system. A personal preference (user scope) — not shared with the project, and never applied to document content.`}).optional(),colorThemeLight:f().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in light mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${B()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(M,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeDark:f().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in dark mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${B()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(M,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorTheme:f().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Superseded by appearance.colorThemeLight / appearance.colorThemeDark. Read as the palette for both modes while neither of those is set. A short theme id (lowercase letters, digits, and hyphens; max 32 characters); an id no palette matches falls back to 'default'. A personal preference (user scope) — not shared with the project.`}).regex(M,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeEnabled:i().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Whether the Themes plugin appears in Settings → Plugins. A personal preference (user scope). Default on.`}).optional(),customTheme:a({name:f().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's display name.`}).optional(),author:f().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's author credit, carried through from an imported base16 scheme.`}).optional(),variant:u([`dark`,`light`]).register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: whether the scheme is 'dark' or 'light'. Auto-detected from the palette when omitted.`}).optional(),...ve()}).optional(),preview:a({autoOpen:i().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:a({showHiddenFiles:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showOnlyMarkdownFiles:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show only markdown documents (.md/.mdx) and folders in the file tree, hiding other file types from view. View-only: hidden files stay on disk and remain reachable via links and search. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillsSection:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show the Skills section in the sidebar. Skill documents remain reachable via links and search while the section is hidden. Per-machine (project-local) — not shared with collaborators.`}).default(!0),showOkFolders:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show .ok folders (skills, templates, and other OpenKnowledge-managed state) in the file tree as read-only entries. .ok/worktrees and .ok/local never appear. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillGroups:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Group skills in the sidebar by where they came from — the publisher they were imported from, or the plugin that ships them. Skills you authored stay ungrouped at the top of their scope. Per-machine (project-local) — not shared with collaborators.`}).default(!0),pinnedProjectSkills:c(f()).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Project-scope skills pinned to the top of the Skills sidebar, by name. A pinned skill also keeps its normal row, so a provenance group still lists everything from its source. Per-machine (project-local) — not shared with collaborators.`}).default([]),pinnedGlobalSkills:c(f()).register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Global-scope skills pinned to the top of the Skills sidebar, by name. Stored per USER rather than per project, so a pinned global skill follows you into every project.`}).default([])}).optional()}).default({preview:{autoOpen:!0}}),editor:a({wordWrap:i().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0),previewTabs:i().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Reuse one tab when clicking through the Files and Skills sidebars, the way an editor preview tab works. Turn off to open every click in its own tab. Pinned tabs keep their own tab either way. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0,previewTabs:!0}),agents:a({autoApproveOkTools:i().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools for agents launched from the built-in terminal (plus `ok open` on Claude) and for in-app Agents-panel chats with any ACP agent. Destructive tools (delete/move/share/install/import) still prompt. Per-machine personal preference (user scope)."}).default(!0),browserTools:i().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Give in-app Claude Code and Codex chats a browser they can drive (Playwright MCP, started through npx from OpenKnowledge's own folder with a fresh in-memory profile), so an agent can open pages, click, and take screenshots. Every browser action asks for approval, with no option to always allow it, unless the agent's own mode or permission settings skip approvals. Needs Google Chrome and Node.js. Off by default; takes effect for chats started after the change. Per-machine personal preference (user scope).`}).default(!1)}).default({autoApproveOkTools:!0,browserTools:!1}),autoSync:a({mode:u(_).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`What this machine syncs on a schedule for this project: 'off' (Manual — nothing scheduled; the manual pull/push actions still work), 'follow' (Auto, pull only — scheduled pulls, never a scheduled push; 'pull' is accepted as a legacy alias), or 'full' (Auto, pull and push — bidirectional). Explicit user-triggered pushes work in every mode. null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared. Supersedes the legacy autoSync.enabled boolean.`}).nullable().default(null),enabled:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Legacy per-machine sync toggle, superseded by autoSync.mode. Read only when mode is absent (true = full, false = off). null = not chosen yet. Per-machine (project-local) — not shared.`}).nullable().default(null),resumeMode:u(g).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`When sync is paused (autoSync.mode 'off') after having been enabled, the active mode to resume into ('follow' | 'full'). Per-machine UI memory; ignored while a mode is active. Not shared.`}).optional(),pullIntervalSeconds:o().int().min(30).max(h).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Seconds between scheduled pulls while autoSync.mode is follow or full (default 30). Per-machine (project-local) — not shared.`}).optional().catch(void 0),pushIntervalSeconds:o().int().min(30).max(h).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Seconds between scheduled pushes while autoSync.mode is full (default 60). Ignored in every other mode, which never pushes on a schedule. Each cycle with pending edits authors a commit, so a shorter interval means more, smaller commits in the repo's shared history. Per-machine (project-local) — not shared.`}).optional().catch(void 0),default:m([i(),u(_)]).register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Committed project default for a machine's sync mode on first open: 'off' | 'follow' | 'full', or the legacy boolean (true = full, false = off). null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.mode choice overrides it.`}).nullable().default(null)}).default({mode:null,enabled:null,default:null}),git:a({hosts:s(f(),me).register(F,{scope:`user`,agentSettable:!1,reload:`boot`,defaultScope:`user`,description:"Per-git-host declarations, keyed by hostname (for example ghes.example.com). Each entry says how OpenKnowledge should treat remotes on that host; today the only key an entry carries is `provider`. Hosts absent from this map are treated as generic git remotes. Per-machine (user scope, global.yml in the OpenKnowledge home folder); a value in a project's `.ok/config.yml` is ignored. Declarations take effect when OpenKnowledge next starts."}).default({}).catch({})}).default({hosts:{}}),terminal:a({enabled:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null),shell:f().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Absolute Windows shell executable override for the in-app terminal. PowerShell, cmd.exe, and Git Bash support OpenKnowledge-managed launches (agent chat tabs and fixed commands such as Resolve in terminal or Install Slidev) and dropped-file path insertion. A different existing executable remains usable for plain terminal tabs and shows a capability notice; requested agent and command launches open only the plain shell without running the agent or command, and dropped-file paths are refused. Empty values use automatic shell discovery. Per-machine (project-local), human-managed, and never shared via git, clone, or sync.`}).optional()}).default({enabled:null}),slides:a({enabled:i().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Whether the Slides plugin appears in Settings → Plugins. When on, a document whose frontmatter has `slides: true` offers an action that opens the deck in a dedicated window (desktop only, requires a resolvable slidev). A personal preference (user scope). Default off."}).default(!1)}).default({enabled:!1}),telemetry:a({localSink:a({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:a({maxBytes:o().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(H)}).default({maxBytes:H}),logs:a({maxBytes:o().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(U)}).default({maxBytes:U}),attributeDenylist:c(f()).register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...V])}).default({enabled:!0,spans:{maxBytes:H},logs:{maxBytes:U},attributeDenylist:[...V]}),skillInstallReports:a({enabled:i().register(F,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Report skill installs to skills.sh so a published skill shows an accurate install count. Sends the skill name, its source repo, and which agent tools it was installed for — never file contents, and never for a private or local source. One report per skill per machine. Default off; when it is on, the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables still turn it off.`}).default(!1)}).default({enabled:!1})}).default({localSink:{enabled:!0,spans:{maxBytes:H},logs:{maxBytes:U},attributeDenylist:[...V]},skillInstallReports:{enabled:!1}}),lossCapture:a({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Record bridge loss-class events (content-free) under .ok/local/loss-capture/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),maxBytes:o().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local loss-capture file before it rotates (default ~12 MB).`}).default(ye)}).default({enabled:!0,maxBytes:ye}),bridge:a({backgroundThrottle:a({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Keep the desktop window's timers running at full rate while it holds unsynced work, so backgrounding the app never starves sync or recovery; when the window is idle the OS-default background throttling is restored (battery). Honored by the desktop app. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),deferGuard:a({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Defer a drain-shaped Observer B re-derive when the WYSIWYG fragment holds an un-propagated keystroke Y.Text lacks, so the keystroke survives instead of being stomped. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),lossDetector:a({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Detect content the bridge silently dropped at its reconciliation boundary (an Observer-A apply arm or a paired agent-undo derive) and write a recovery checkpoint plus a content-free loss event. Detection only — never blocks a write. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),fixedPoint:a({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Bound the Y.Text→WYSIWYG re-derive loop with a drain-count backstop: a run of re-derive drains that never reaches a raw-byte fixed point freezes the re-derive loop and writes a recovery checkpoint plus a content-free loss event, instead of churning unbounded. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),preDrain:a({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Before an agent write or undo rebuilds the WYSIWYG fragment, flush an un-propagated keystroke that provably does not overlap the operation into Y.Text so the keystroke survives instead of needing recovery; overlapping or unmodellable cases fall back to the checkpoint floor. Scope: appending writes and single-frame undos — a write that replaces the whole body (replace / edit) overwrites the keystroke either way, so those always take the checkpoint floor. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),flushOnHide:a({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`On tab hide/unload, force-send each doc's unsynced work to the server and commit its local cache, and re-sync on return to foreground, so a backgrounded tab never strands edits that IndexedDB alone would lose on recycle. Honored client-side. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0})}).default({backgroundThrottle:{enabled:!0},deferGuard:{enabled:!0},lossDetector:{enabled:!0},fixedPoint:{enabled:!0},preDrain:{enabled:!0},flushOnHide:{enabled:!0}}),search:a({semantic:a({enabled:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:f().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override to point at a self-hosted server (Ollama / vLLM / LM Studio) or another provider. The API key is NOT stored here — set it with `ok embeddings set-key` (stored in secrets.yml in the OpenKnowledge home folder); it is sent to whichever endpoint this names."}).default(W),model:f().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(G),dimensions:o().int().positive().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit (recommended) to detect the model's native size from its first response — that is what lets a non-OpenAI model work without knowing its size up front. Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality; a server that ignores the request param then fails loudly instead of silently. Changing it re-embeds the corpus.`}).optional(),similarityFloor:o().min(0).max(1).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional(),maxBatchSize:o().int().min(1).max(be).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Maximum number of text chunks sent in one indexing request (1–2048, default 96). The ceiling follows OpenAI's input-array limit; other providers may impose different limits. Larger requests may still be split by the character budget. Changing it preserves cached vectors and document chunking; it applies to the next indexing pass. Invalid values use the default and are reported by ok config validate and server logs.`}).default(96).catch(96),maxBatchChars:o().int().min(1).max(xe).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Approximate cumulative character budget per indexing request (1–16384000, default 96000). A single chunk can exceed this budget. OpenAI separately caps total input at 300000 tokens per request; this character budget does not enforce that limit, and high values can produce rejected requests. Other providers have their own limits. Changing it preserves cached vectors and document chunking; it applies to the next indexing pass. Invalid values use the default and are reported by ok config validate and server logs.`}).default(K).catch(K),docTimeoutMs:o().int().min(1).max(Se).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Timeout in milliseconds for each indexing request attempt (1–600000, default 30000). A request can retry four times, and a failed grouped request can trigger individual-document requests. There is no total indexing-pass deadline: large timeouts can delay newly queued work for hours. The query timeout remains 8 seconds per attempt. Changing it preserves cached vectors and applies to the next indexing pass; an in-progress pass keeps its current timeout. Invalid values use the default and are reported by ok config validate and server logs.`}).default(q).catch(q)}).default({enabled:!1,baseUrl:W,model:G,maxBatchSize:96,maxBatchChars:K,docTimeoutMs:q})}).default({semantic:{enabled:!1,baseUrl:W,model:G,maxBatchSize:96,maxBatchChars:K,docTimeoutMs:q}}),contentRules:a({markdownlint:l({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the markdownlint plugin (body rules) contributes diagnostics.`}).default(!1)}).default({enabled:!1}),frontmatter:l({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the frontmatter plugin (JSON-Schema validation of document frontmatter) contributes diagnostics.`}).default(!1),schemas:c(l({appliesTo:m([f(),c(f())]).optional(),file:f(),enabled:i().optional()})).register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Frontmatter schema mappings: which docs (appliesTo globs) validate against which JSON Schema file (project-root-relative path).`}).default([])}).default({enabled:!1,schemas:[]}),okf:l({enabled:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the OKF plugin (Open Knowledge Format portability + conformance rules) contributes diagnostics. Advisory warnings; never blocks a write.`}).default(!1),rules:s(f(),i()).register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Per-rule opt-outs for the OKF plugin, keyed by rule id (e.g. no-wiki-links). Omit a rule to leave it enabled; set false to silence it while keeping the plugin on.`}).optional(),generate:l({index:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether OK generates and maintains a navigation index.md in every folder that contains Markdown, each listing the documents in that folder grouped by frontmatter type and linking to its subfolders. OK owns these files: edits to them are replaced on the next rebuild.`}).default(!1)}).default({index:!1})}).default({enabled:!1,generate:{index:!1}})}).default({markdownlint:{enabled:!1},frontmatter:{enabled:!1,schemas:[]},okf:{enabled:!1,generate:{index:!1}}}),validation:a({links:u(se).register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`How broken internal links are reported on the validation plane: 'off' hides them, 'warning' (default) or 'error' sets their severity.`}).default(L),fileTreeIndicators:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the file tree tints and badges files that have validation problems.`}).default(!0),suppressLogLinkAdvisories:i().register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether unresolved links in the reserved change-history documents (lowercase-stemmed log.md / log.mdx at any depth, where the extension's case does not matter and the stem's does) are omitted from broken-link advisories: the Problems panel, file-tree indicators, source diagnostics, audits, and agent write/edit results. Default true. Raw link views still show them, and LOG.md, Log.md, and every other stem spelling are ordinary documents.`}).default(!0)}).default({links:L,fileTreeIndicators:!0,suppressLogLinkAdvisories:!0}),autolinks:c(_e).register(F,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Turn ticket references into links; today they apply to Agents-panel chat messages. Each entry pairs a `prefix` (for example `PRD-`) with a `url` template containing `<num>` (for example `https://linear.app/inkeep/issue/PRD-<num>`); the prefix followed by digits links to that URL with the digits in place of `<num>`. Matching is case-sensitive. An invalid entry is skipped with a warning and the others still apply. Shared with collaborators (project scope, `.ok/config.yml`)."}).default([]).catch([]),linkPreviews:a({enabled:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show a rich preview card (site name, page title, description, favicon) when you hover an external link in the editor, and a status card when you hover a GitHub pull request or issue link in an agent chat. When ON, hovering an external link sends that link's URL to the destination site to fetch its preview metadata, and hovering a GitHub reference asks the GitHub host's API for it, signed in as you when a GitHub sign-in is available — outbound egress, one request per previewed link. Default ON; set to false to turn external previews off. Per-machine (project-local) — not shared with collaborators. Previews of links to other documents in this project are read from the local index with no network request and are always on.`}).default(!0)}).default({enabled:!0}),server:a({port:o().int().min(1).max(65535).register(F,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`TCP port the server listens on. Unset by default: a local start picks a free port dynamically, and deployment platforms inject the PORT environment variable instead. Read at server start; changing it requires a restart.`}).optional(),bind:c(f().min(1)).min(1).register(F,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Addresses the server binds, e.g. [127.0.0.1] or [0.0.0.0]. Default loopback-only ([127.0.0.1]): nothing off this machine can connect. A non-loopback bind additionally requires the server.allowExternal consent interlock. Per-machine (project-local): a value committed to .ok/config.yml is ignored, so one machine exposing the server can never break local clones for the rest of the team — the exposing host sets it via OK_BIND, --bind, or .ok/local/config.yml. Lists replace, never merge. Read at server start; changing it requires a restart.`}).default([...Ce]),externalUrl:p({protocol:/^https?$/}).regex(Te).register(F,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Canonical external origin the server is reached at, e.g. https://kb.example.com — its host joins the Host/Origin allowlists (external-Host + CORS admission). Unset by default: the server admits only loopback Hosts. Setting it declares external exposure, which additionally requires the server.allowExternal consent interlock. Read at server start; changing it requires a restart.`}).optional(),allowExternal:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Exposure consent interlock. A non-loopback server.bind without allowExternal: true is refused at boot with a one-line fix; a server.externalUrl without it boots (a committed externalUrl never arms exposure on clones — but it is project-scoped, so its host still joins the Host/Origin allowlists there), but requests carrying forwarding headers (X-Forwarded-For etc.) are refused until consent is given — proxy tolerance requires both keys. Default off. The server has no authentication of its own, so only consent behind an authenticating edge. Per-machine (project-local) — consent never travels via git, clone, or share; containers consent via the environment instead.`}).default(!1),openBrowser:i().register(F,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Open the UI in a browser when the server starts. Default derived: true when every bind address is loopback (a laptop start pops the UI), false otherwise (a container or exposed bind is headless and must never try). Acts once at start. Per-machine (project-local) — not shared.`}).optional(),idleShutdown:m([d(`off`),f().regex(we)]).register(F,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Shut the server down after this long with no activity: a duration like '30m' (positive integer with unit s, m, or h), or 'off'. Default derived: '30m' for a loopback-only, unexposed server; 'off' otherwise — a non-loopback bind, or a loopback bind declared externally reachable (server.allowExternal + server.externalUrl), stays up, because a remote agent keeps it busy over /mcp, which the idle timer does not count. Residual case the derivation cannot see: a loopback server reached by remote agents with no server.externalUrl (e.g. behind a same-box reverse proxy) still idles at 30m — set 'off' by hand. Reloadable — a valid change applies without a restart. Per-machine (project-local) — not shared.`}).optional()}).default({bind:[...Ce],allowExternal:!1})});function Me(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Ne(e,t){let n=e;for(let e of t){n=Me(n);let t=n?._zod?.def?.shape;if(!t){let e=n?._zod?.def;if(e?.type!==`record`)return;n=e.valueType;continue}if(n=t[String(e)],n===void 0)return}return n}function Pe(e,t){let n=Ne(e,t);if(n!==void 0)return I(n)}var Fe=n(),J=e(t(),1),Y=null,X=new Set;function Ie(){return Y}function Le(e){let t=e!==null&&e.length>0?e:null;if(t!==Y){Y=t;for(let e of X)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function Re(e){return X.add(e),()=>{X.delete(e)}}function ze(){return(0,J.useSyncExternalStore)(Re,Ie,Ie)}function Z(e){return{authoritative:e,themes:j,warnings:[],truncated:!1}}function Be(e){let{scheme:t}=e;return{id:e.id,label:t.name,kind:t.variant,scheme:t,toTokens:()=>D(t)}}function Ve(e,t){return{id:e,label:t.name,kind:t.variant,scheme:t,toTokens:()=>D(t)}}function Q(e,t,n={}){console.warn(JSON.stringify({event:`ok-saved-theme-request-failed`,action:e,result:t,...n.status===void 0?{}:{status:n.status},...n.error===void 0?{}:{errorName:n.error instanceof Error?n.error.name:`UnknownError`}}))}async function He(e={}){let t=e.request??globalThis.fetch;try{let n=await t(`/api/saved-themes`,{signal:e.signal});if(!n.ok)return Q(`list`,`http-error`,{status:n.status}),Z(!1);let r=S.safeParse(await n.json());if(!r.success)return console.warn(`[themes] saved-themes response failed schema validation`,r.error.issues),Z(!1);let i=[],a=[];for(let e of r.data.themes)e.ok?i.push(Be(e)):a.push({filename:e.filename,id:e.id,code:e.code,...e.conflictingFilenames?{conflictingFilenames:e.conflictingFilenames}:{}});return{authoritative:!0,themes:i.length===0?j:[...j,...i],warnings:a,truncated:r.data.truncated}}catch(t){return e.signal?.aborted||Q(`list`,`request-error`,{error:t}),Z(!1)}}function Ue(e){switch(e.detail){case`empty`:case`too-long`:case`invalid-chars`:return e.detail;default:return}}async function We(e,t={}){let n=C.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=T.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=v.safeParse(t);if(!i.success)return{ok:!1,reason:`unexpected`};if(i.data.type===`urn:ok:error:theme-name-taken`)return{ok:!1,reason:`name-taken`};if(i.data.type===`urn:ok:error:theme-name-invalid`){let e=Ue(i.data);return e?{ok:!1,reason:`name-invalid`,detail:e}:{ok:!1,reason:`name-invalid`}}return{ok:!1,reason:`unexpected`}}catch(e){return Q(`save`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function Ge(e,t={}){let n=b.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=x.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=v.safeParse(t);return i.success&&i.data.type===`urn:ok:error:not-found`?{ok:!1,reason:`not-found`}:{ok:!1,reason:`unexpected`}}catch(e){return Q(`update`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function Ke(e,t={}){if(!te(e).ok)return{ok:!1,reason:`unexpected`};let n=t.request??globalThis.fetch;try{let t=await n(`/api/saved-theme?${new URLSearchParams({id:e})}`,{method:`DELETE`}),r=await t.json().catch(()=>null);if(!t.ok)return{ok:!1,reason:`unexpected`};let i=O.safeParse(r);if(!i.success)return{ok:!1,reason:`unexpected`};if(!i.data.existed)return{ok:!0,existed:!1};let a=E.safeParse(i.data.scheme);return a.success?{ok:!0,existed:!0,filename:i.data.filename,scheme:a.data}:{ok:!1,reason:`unexpected`}}catch(e){return Q(`delete`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}var $=(0,J.createContext)(null);function qe(e){let t=(0,Fe.c)(21),{children:n}=e,r=ze(),[i,a]=(0,J.useState)(Ze),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(`custom`),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={},t[0]=g):g=t[0];let _=(0,J.useRef)(g),v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v={},t[1]=v):v=t[1];let[y,b]=(0,J.useState)(v),x=(0,J.useRef)(0),S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{let e=0,t=null,n=!1,r=null,i,o=[250,1e3,4e3],c=()=>{i!==void 0&&clearTimeout(i),i=void 0},u=()=>{if(t)return n=!0,t;let i=e,o=(async()=>{let t;do{n=!1;let o=x.current,u=new AbortController;r=u;let{authoritative:d,...f}=await He({signal:u.signal});if(i!==e)return!1;t=d,d?(c(),o===x.current&&a(f),s(!0),l(!1)):l(!0)}while(n);return t})().finally(()=>{t===o&&(t=null)});return t=o,o};return{refresh:u,startAutomaticRetry:()=>{e+=1;let a=e;r?.abort(),r=null,t=null,n=!1,c();let s=async t=>{let n=await u();a!==e||n||t>=o.length||(i=setTimeout(()=>void s(t+1),o[t]))};return s(0),()=>{a===e&&(e+=1,r?.abort(),r=null,t=null,n=!1,c())}}}},t[2]=S):S=t[2];let[C]=(0,J.useState)(S),w=C.refresh,T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{let e=new Map,t=(t,n)=>{let r=(e.get(t)??Promise.resolve()).then(n,n),i=r.then(Xe,Ye);return e.set(t,i),i.finally(()=>{e.get(t)===i&&e.delete(t)}),r},n=(e,t,n)=>{x.current+=1;let r=Ve(e,t);a(t=>({...t,themes:t.themes.some(t=>t.id===e)?t.themes.map(t=>t.id===e?r:t):[...t.themes,r],warnings:t.warnings.filter(t=>t.id!==e&&(n===void 0||t.filename!==n))}))};return{updateTheme:e=>t(e.id,async()=>{let t=await Ge(e);return t.ok&&n(e.id,e.scheme,t.filename),t}),deleteTheme:e=>t(e,async()=>{let t=await Ke(e);if(t.ok){let t={..._.current,[e]:(_.current[e]??0)+1};_.current=t,b(t),x.current+=1,a(t=>({...t,themes:t.themes.filter(t=>t.id!==e),warnings:t.warnings.filter(t=>t.id!==e)}))}return t}),restoreTheme:e=>t(e.id,async()=>{let t=await We({name:e.name,stem:e.stem,scheme:e.scheme,extension:e.extension});return t.ok&&n(t.id,e.scheme,t.filename),t})}},t[3]=T):T=t[3];let[E]=(0,J.useState)(T),D;t[4]===C?D=t[5]:(D=()=>C.startAutomaticRetry(),t[4]=C,t[5]=D);let O;t[6]!==C||t[7]!==r?(O=[C,r],t[6]=C,t[7]=r,t[8]=O):O=t[8],(0,J.useEffect)(D,O);let k;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(k=function(e){if(e===null){p(!1);return}d(e),p(!0),h(Je)},t[9]=k):k=t[9];let ee=k,A;return t[10]!==n||t[11]!==i||t[12]!==u||t[13]!==c||t[14]!==o||t[15]!==E||t[16]!==w||t[17]!==f||t[18]!==m||t[19]!==y?(A=(0,J.createElement)($,{value:{...i,loaded:o,loadError:c,refresh:w,...E,editingThemeId:u,themeIncarnations:y,themeEditorOpen:f,themeEditorOpenNonce:m,selectThemeToEdit:ee}},n),t[10]=n,t[11]=i,t[12]=u,t[13]=c,t[14]=o,t[15]=E,t[16]=w,t[17]=f,t[18]=m,t[19]=y,t[20]=A):A=t[20],A}function Je(e){return e+1}function Ye(){}function Xe(){}function Ze(){return Z(!1)}function Qe(){let e=(0,J.use)($);if(!e)throw Error(`useSavedThemes must be used within <SavedThemesProvider />`);return e}export{ce as C,ae as S,I as T,Oe as _,Pe as a,ge as b,W as c,G as d,Ee as f,ue as g,be as h,ze as i,q as l,xe as m,Qe as n,Ne as o,Se as p,Le as r,je as s,qe as t,K as u,ke as v,oe as w,L as x,de as y};
@@ -1,16 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$l as t,Bf as n,Da as r,G as i,Gf as a,Kf as o,Oa as s,Pf as c,Ql as l,U as u,Uf as d,W as f,Xf as p,Yf as m,dl as h,ep as g,fd as _,fl as ee,l as v,ol as y,sl as b,u as te,zf as x}from"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import{Ai as S,Bs as C,Di as w,Ei as T,Ji as E,Ki as ne,Nt as D,Oi as re,Qt as O,Wo as k,_a as A,_r as j,_s as M,ba as ie,bi as N,bs as ae,ia as oe,ii as se,m as P,pi as F,pr as ce,rr as I,wo as le,xs as ue,ys as de,za as fe}from"./dist-RdM5Fw_L.mjs";import{t as pe}from"./yazl-BBz29IQN.mjs";import{ct as me,gt as he,ht as ge,mt as _e,pt as ve,st as ye,wt as be}from"./init-DxmL4VOM.mjs";import{T as xe,l as Se,u as Ce}from"./registry-probes-CIpYsPg_.mjs";import{c as we}from"./colors-r_owlCuY.mjs";import{t as Te}from"./is-object-BGze3w87.mjs";import{n as Ee}from"./constants-DUZK5snO.mjs";import"./loader-7rHc_jKi.mjs";import"./preview-BGzTZvt_.mjs";import{execFile as De,execSync as Oe,spawnSync as ke}from"node:child_process";import{basename as L,dirname as R,isAbsolute as Ae,join as z,relative as je,resolve as B,sep as V,win32 as Me}from"node:path";import{closeSync as Ne,cpSync as Pe,createWriteStream as Fe,existsSync as H,lstatSync as Ie,mkdirSync as U,mkdtempSync as Le,openSync as Re,readFileSync as W,readSync as ze,readdirSync as G,readlinkSync as Be,realpathSync as Ve,rmSync as K,rmdirSync as He,statSync as Ue,writeFileSync as q}from"node:fs";import{arch as We,freemem as Ge,homedir as J,hostname as Ke,platform as qe,release as Je,tmpdir as Ye,totalmem as Xe,type as Ze,uptime as Qe}from"node:os";import{readFile as $e,readdir as et,stat as tt}from"node:fs/promises";import{createHash as nt}from"node:crypto";function rt(e,t){let n=t.map(e=>[C(e),e]);for(let t of e){let e=C(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function it(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=rt([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=rt(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function at(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 ot=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function st(e,t,n=j){if(e!==void 0&&!ot.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let ct=null;function lt(e){ct=e}function ut(){return ct??process.cwd()}const dt=`Open Knowledge`;function ft(e={}){let t=e.platformName??process.platform,n=e.productName??o().productName;return ye(t).join(me({...e,platformName:t}),n)}function pt(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=ye(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,`${o().packageName.replaceAll(`/`,``)}-updater`)}function mt(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 ht(e){let t=z(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return mt(n)??[]}function gt(e){let t=z(e,`state.json`);if(!H(t))return!1;try{return mt(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const _t=8192;function vt(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 yt(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const bt=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function xt(e){return e.replace(bt,`$1"[REDACTED-DEVICE-ID]"`)}function St(e){return xt(yt(e))}const Ct=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function wt(e){if(typeof e!=`string`)return null;let t=Ct.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 Tt(e){let t=Re(e,`r`);try{let e=Buffer.alloc(_t),n=0,r=!1;for(;n<_t;){let i=ze(t,e,n,_t-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{Ne(t)}}function Et(e){try{let t=Tt(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:wt(a)}}catch{return{kind:`unreadable`}}}function Dt(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=z(e,t.name),r;try{r=Ue(n).mtimeMs}catch{continue}if(r<i)continue;let c=Et(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Dt(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 kt=`state/os-termination-evidence.json`,At=6048e5,jt=/openknowledge/i,Mt=d.map(e=>p(n[e]));function Nt(e={}){return(t,n)=>new Promise(r=>{try{De(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...Pt(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function Pt(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 Ft(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 Y(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 It(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function Lt(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function Rt(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function zt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Bt(e,t){let n=t.indexOf(`
3
- `);if(n===-1)return null;let r,i;try{r=zt(JSON.parse(t.slice(0,n))),i=zt(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=zt(e);t===null||typeof t.name!=`string`||!Dt(t.name)||a.push({name:t.name,pid:Rt(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:Rt(t.rpages),lifetimeMaxPages:Rt(t.lifetimeMax)})}let o=wt(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:Rt(zt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?Dt(i.largestProcess):null,ownedProcesses:a}}const Vt=/^JetsamEvent-.*\.ips$/;function Ht(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 Ut(e,t){let n=Y(`darwin`,`macos-jetsam`,[z(e,`JetsamEvent-*.ips`)]),r;try{r=await et(e)}catch(e){return It(n,e.code??`unknown`)}let i=Ht(await Promise.all(r.filter(e=>Vt.test(e)).map(async t=>{try{return{file:t,mtimeMs:(await tt(z(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-At,50,`newest-first`);n.unparseable+=i.statFailed,n.droppedOverCap=i.droppedOverCap;for(let t of i.files){let r=null;try{r=Bt(t,await $e(z(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return Lt(n)}const Wt=[`--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`],Gt=[`--user`,`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Fatal Wayland communication error|Wayland protocol error|X IO error|Missing X server`],Kt=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/,qt=/\[(\d+)(?::\d+)?:\d{4}\/\d{6}\.\d+:[A-Z0-9]+:[^\]]*\]\s*(.*)$/,Jt=/^desktop\.\d{4}-\d{2}-\d{2}\.log$/;async function Yt(e,t){let n=new Set,r;try{r=await et(e)}catch{return{pids:n,unreadable:!0}}let i=!1;for(let a of r){if(!Jt.test(a))continue;let r=z(e,a);try{if(t.getTime()-(await tt(r)).mtimeMs>At)continue;for(let e of(await $e(r,`utf8`)).split(`
4
- `)){if(!e.includes(`"event":"desktop.boot"`))continue;let t=/"pid":(\d+)/.exec(e)?.[1];t!==void 0&&n.add(Number(t))}}catch{i=!0}}return{pids:n,unreadable:i}}function Xt(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:jt.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 Zt(e){let t=[],n=0,r=0;for(let i of e.split(`
5
- `)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=Kt.exec(i);if(e===null){r+=1;continue}let[,a=``,o=``,s=``]=e;if(!jt.test(s)){n+=1;continue}let c=Xt(o,s);if(c===null){r+=1;continue}t.push({kind:`journal`,at:a,...c})}return{events:t,foreignIgnored:n,unparseable:r}}function Qt(e){let t=[],n=0,r=0;for(let i of e.split(`
6
- `)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=Kt.exec(i);if(e===null){r+=1;continue}let[,a=``,,o=``]=e,s=qt.exec(o);if(s===null){n+=1;continue}t.push({at:a,pid:Number(s[1]),detail:(s[2]??``).slice(0,200)})}return{lines:t,foreignIgnored:n,unparseable:r}}async function $t(e,t,n){let r=Qt(e);if(r.lines.length===0)return{...r,events:[],unattributed:null};let i=await Yt(t,n),a=[],o=0;for(let e of r.lines){if(!i.pids.has(e.pid)){o+=1;continue}a.push({kind:`journal`,at:e.at,origin:`chromium`,action:`display-connection-lost`,pid:e.pid,processName:null,unit:null,trigger:/Wayland/.test(e.detail)?`wayland`:`x11`,detail:e.detail})}let s=i.pids.size>0&&!i.unreadable;if(o>0&&!s){let e=i.unreadable?`desktop logs unreadable`:`no desktop.boot pid in desktop logs`;return{events:a,foreignIgnored:r.foreignIgnored,unparseable:r.unparseable,unattributed:`${o} Chromium display line(s) not attributed, ${e}`}}return{events:a,foreignIgnored:r.foreignIgnored+o,unparseable:r.unparseable,unattributed:null}}function en(e){return e.status===0||e.status===1&&/^-- No entries --$/m.test(e.stdout)}async function tn(e,t,n){let r=Y(`linux`,`linux-journal`,[`journalctl ${Wt.join(` `)}`,`journalctl ${Gt.join(` `)}`]),[i,a]=await Promise.all([e(`journalctl`,[...Wt]),e(`journalctl`,[...Gt])]),o=[];if(en(i)){let e=Zt(i.stdout);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,/not seeing messages from other users/i.test(`${i.stdout}\n${i.stderr}`)&&(r.restrictedToCurrentUser=!0)}else o.push(`system journal: ${Ft(i)}`);if(en(a)){let e=await $t(a.stdout,n,t);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,e.unattributed!==null&&o.push(`user journal: ${e.unattributed}`)}else o.push(`user journal: ${Ft(a)}`);return o.length===2?It(r,o.join(`; `)):o.length===1?{...r,outcome:`partial`,unavailableReason:o.join(`; `)}:Lt(r)}const nn={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},rn={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function an(e){return e===`System`?nn:rn}function on(e){let t=`System[(${Object.keys(an(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${At}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${Mt.map(e=>`Data='${e}'`).join(` or `)}]]`}function sn(e){return[`qe`,e,`/q:${on(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function cn(e){return Me.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function ln(e){return e.replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&apos;/g,`'`).replace(/&amp;/g,`&`)}function un(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function dn(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>ln(e[1]??``).trim())}function fn(e,t){let n=an(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=dn(o,`Data`),u=dn(o,`Name`),d=[...l,...u].some(e=>jt.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!==``&&!un(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function pn(e,t){let n=cn(t),r=[`System`,`Application`],i=Y(`win32`,`windows-event-log`,r.map(e=>`${n} ${sn(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,sn(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${Ft(t)}`);continue}let n=fn(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?It(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:Lt(i)}async function mn(e={}){let t=e.platform??process.platform,n=e.runCommand??Nt(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return Ut(e.macosReportsDir??`/Library/Logs/DiagnosticReports`,r);case`linux`:return tn(n,r,e.desktopLogsDir??z(M(),`logs`));case`win32`:return pn(n,e.systemRoot??process.env.SystemRoot);default:return{...Y(t,null,[]),outcome:`unsupported`}}}const hn={schemaVersion:1,outcome:`not-collected`};function gn(e){return`${JSON.stringify(e??hn,null,2)}\n`}const _n={"macos-jetsam":`macOS low-memory reports`,"linux-journal":`system and user journals`,"windows-event-log":`Windows event logs`};function vn(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 ${_n[e.source]}`:``,r=e.unavailableReason?`, ${e.unavailableReason}`:``;return`${e.outcome}${n}${r} (${t.join(`; `)})`}function yn(){return z(M(),`bug-reports`)}function bn(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=yn(),r=`${t}-bugreport`,i=z(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=z(n,`${r}-${e}.zip`);return i}function xn(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function Sn(e,t){let n=z(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(z(e,`.ok`))?nt(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function Cn(){let e={timestamp:new Date().toISOString(),platform:qe(),osType:Ze(),osRelease:Je(),hostname:`[redacted]`,uptime:Qe(),freeMem:Ge(),totalMem:Xe(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=Oe(`sw_vers -productVersion 2>/dev/null`,k({encoding:`utf8`})).trim()}catch{}try{let t=z(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const wn=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function Tn(e){let t=L(e);return wn.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function En(e,t){return An(e,t).files}const Dn=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function On(e,t=Ce){let n=z(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return Dn.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=>z(n,e.entry)))}function kn(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,-v.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=>z(e,t))}catch{return[]}}function An(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>z(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(Tn),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=>!Tn(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function jn(e){let t=z(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,`last-spawn-error.log`,h,b].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function Mn(e){let t=z(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function Nn(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#${nt(`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:Nn(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=s(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function X(e){for(let t of e.files)try{let n=W(t,`utf8`);Pn({zipfile:e.zipfile,name:`${e.prefix}/${L(t)}`,content:t.endsWith(`.ips`)?St(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 Fn(t){let{redact:n,outputPath:i,logger:a}=t,o=t.revealDocNames??!1,s=t.userLogsDir??z(M(),`logs`),c=t.projectDir?Sn(t.projectDir,a):null;U(R(i),{recursive:!0}),a?.info({projectSlug:c},`gathering diagnostic data`);let l=Cn();l.desktop=t.desktop??null,l.language=t.language??null;let{files:u,excludedByProjectSlug:d}=An(c,s),{files:f}=t.projectDir?jn(t.projectDir):{files:[]},{files:p}=t.projectDir?Mn(t.projectDir):{files:[]},m=t.shipItLogFiles??[],h=t.diagnosticReports?.files??[];a?.info({logFileCount:u.length,logFilesExcludedByProjectSlug:d,lockFileCount:f.length,localSinkFileCount:p.length,shipItLogFileCount:m.length,diagnosticReportCount:h.length},`files collected`);let g=[],_=[],{ZipFile:ee}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new ee;X({zipfile:v,files:[...u,...m],prefix:`logs`,redact:n,revealDocNames:o,bundleFiles:_,redactions:g,logger:a}),X({zipfile:v,files:f,prefix:`lockdir`,redact:n,revealDocNames:o,bundleFiles:_,redactions:g,logger:a}),X({zipfile:v,files:p,prefix:`local-logs`,redact:n,revealDocNames:o,bundleFiles:_,redactions:g,logger:a}),X({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:te,redact:n,revealDocNames:o,bundleFiles:_,redactions:g,logger:a}),X({zipfile:v,files:h,prefix:`diagnostic-reports`,redact:n,revealDocNames:o,bundleFiles:_,redactions:g,logger:a});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??L(e.sourcePath)}`;v.addBuffer(t,n),_.push(n);let r=xn(e,n);r!==null&&g.push(r)}catch(t){a?.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:o,bundleFiles:_,redactions:g});let y=new Set(h.map(e=>`diagnostic-reports/${L(e)}`)),b=_.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:vt(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),_.push(`state/diagnostic-reports-status.txt`),Pn({zipfile:v,name:kt,content:gn(t.osTerminationEvidence),redact:n,revealDocNames:!0,bundleFiles:_,redactions:g});let S=JSON.stringify(l,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),_.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:c,files:_,redactions:g,sysinfo:l};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=g.reduce((e,t)=>e+t.lineCount,0),T=new Set(m.map(e=>`logs/${L(e)}`)),E=_.filter(e=>T.has(e)),ne=new Set((t.bugReportLedgerFiles??[]).map(e=>`${te}/${L(e)}`)),D=_.filter(e=>ne.has(e)),re=c?_.filter(e=>e.startsWith(`logs/`)&&!Tn(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.`]:[],k=O.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...O]:[`Redaction was disabled for this bundle; file contents are unmodified.`],A=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${c??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,..._.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's own logs, 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, plus display-connection errors this app's desktop`,`process wrote to the user's own journal, with Chromium's message cut to`,`200 characters. 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:`,`- ${kt}`,``]:[],...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: ${r.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${g.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...O,``,`This bundle is safe to attach to a GitHub issue.`]:k].join(`
7
- `);v.addBuffer(Buffer.from(A,`utf8`),`README.md`),v.end();let j=Fe(i);return v.outputStream.pipe(j),await new Promise((e,t)=>{j.on(`close`,e),j.on(`error`,t)}),a?.info({bundlePath:i,fileCount:_.length,redactionCount:w},`bundle written`),{zipPath:i,summary:{projectSlug:c,files:_,redactions:g,redactedLineCount:w,generatedAt:C.generatedAt}}}var In=_(),Ln=e(pe(),1),Z=e(we(),1);function Rn(e){let t=ue(`user`,e,e);return de({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function zn({home:e=J(),env:n=process.env}={}){let r=Rn(e),{override:i,preferenceList:a}=ae(n),{locale:o,source:s}=it({override:i,storedPreference:r,supportedLocales:t,preferenceList:a,autoDetectableLocales:l});return{preference:r,locale:o,source:s,systemLanguages:a}}function Bn(e){let t=new Set([e]);try{t.add(Ve.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 Vn(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function Hn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Un(e,t){if(typeof e==`string`)return Vn(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>Un(e,t));if(!Hn(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Un(i,t);return n}function Wn(e,t){let n=W(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
8
- `),i=n.split(`
9
- `),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=Un(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
10
- `)}\n`:a.join(`
11
- `);q(e,o)}function Gn(e,t){let n=W(e,`utf-8`);if(n.trim().length!==0)try{let r=Un(JSON.parse(n),t),i=n.endsWith(`
12
- `)?`
13
- `:``;q(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Vn(n,t.contentDirSpellings);r!==n&&q(e,r)}}function Kn(e,t){let n=W(e,`utf-8`),r=Vn(n,t.contentDirSpellings);r!==n&&q(e,r)}function qn(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>z(e,t.name))}catch{return[]}}const Jn=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Yn(e){return/\.log\.\d+$/.test(e)}function Xn(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Yn(e)}const Zn=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Qn(e){let t={contentDirSpellings:Bn(e.contentDir)};for(let n of Zn)for(let r of qn(z(e.stagingDir,n)))Xn(r)?Wn(r,t):r.endsWith(`.json`)?Gn(r,t):Kn(r,t);for(let n of qn(z(e.stagingDir,`state`))){let e=L(n);n.endsWith(`.jsonl`)?Wn(n,t):Jn.has(e)?Gn(n,t):Kn(n,t)}}const $n=[`.ok`,`local`,`telemetry`],er=[`.ok`,`local`,`logs`],tr=[`.ok`,`local`,`loss-capture`],nr=`spans-current.jsonl`,rr=`spans-prev.jsonl`,ir=`server-current.jsonl`,ar=`server-prev.jsonl`,or=`loss-current.jsonl`,sr=`loss-prev.jsonl`;function cr(e){return z(e,...$n,nr)}function lr(e){return z(e,...$n,rr)}function ur(e){return z(e,...er,ir)}function dr(e){return z(e,...er,ar)}function fr(e){return z(e,...tr,or)}function pr(e){return z(e,...tr,sr)}const mr=1e3;async function hr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(mr)});return t.ok?await t.text():null}catch{return null}}async function gr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(mr)});return t.ok?await t.text():null}catch{return null}}async function _r(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(mr)});return t.ok?await t.text():null}catch{return null}}function vr(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(`
14
- `)}\n`:null}catch{return null}}function yr(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=ke(`git`,[`-C`,t,`log`,`--oneline`,`-50`],k({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function br(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=ke(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],k({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function xr(){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 Sr(){return{nodeVersion:process.version,platform:qe(),arch:We()}}function Cr(){return process.env.OTEL_SDK_DISABLED===`false`}function wr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tr(e){if(!H(e))return{};let t;try{t=(0,In.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(!wr(t))return{};let n=t.telemetry;if(!wr(n))return{};let r=n.localSink;return wr(r)?r:{}}function Er(e){return typeof e==`boolean`?e:void 0}function Dr(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Or(e){if(wr(e))return Dr(e.maxBytes)}function kr(e){let t=Tr(ue(`project`,e)),n=Tr(ue(`project-local`,e));return{enabled:Er(n.enabled)??Er(t.enabled)??!0,spansMaxBytes:Or(n.spans)??Or(t.spans)??52428800,logsMaxBytes:Or(n.logs)??Or(t.logs)??26214400}}function Ar(e){return nt(`sha256`).update(e).digest(`hex`)}function jr(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const Mr=[`"doc.name"`,`"docName"`];function Nr(e){let t=W(e,`utf-8`),n=0;for(let e of Mr){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(R(t),{recursive:!0}),e.endsWith(`.ips`)?q(t,St(W(e,`utf-8`))):Pe(e,t),!0}catch{return!1}}function Pr(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=z(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Fr=new Set([`.jsonl`]);function Ir(e){let t=e.lastIndexOf(`.`);return t!==-1&&Fr.has(e.slice(t))}const Lr=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function Rr(e){if(Yn(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Lr.has(e.slice(t))}function zr(e){let t=[];for(let n of Pr(e)){let r=Br(e,n);if(!Rr(r))continue;let{redacted:i,patterns:a,lineCount:o}=s(W(n,`utf-8`));a.length!==0&&(q(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Br(e,t){return je(e,t).split(V).join(`/`)}async function Vr(e){let t=B(e.contentDir),n=B(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??hr,a=r.fetchAgentEffects??gr,o=r.fetchWatcherRecent??_r,s=r.readShadowHead??yr,c=r.readCheckpointRefs??br,l=r.now??(()=>new Date),u=r.okVersion??(()=>Ee),d=r.readDesktopEnv??xr,f=r.readLanguage??zn,p=r.readRuntime??Sr,m=r.isOtlpPushEnabled??Cr,g=Le(z(Ye(),`ok-bundle-`));try{U(z(g,`telemetry`),{recursive:!0}),U(z(g,`logs`),{recursive:!0}),U(z(g,`state`),{recursive:!0}),Q(cr(n),z(g,`telemetry`,nr)),Q(lr(n),z(g,`telemetry`,rr)),Q(ur(n),z(g,`logs`,ir)),Q(dr(n),z(g,`logs`,ar));for(let t of e.userLogFiles??[])Q(t,z(g,`logs`,L(t)));for(let t of e.userStateFiles??[])Q(t,z(g,te,L(t)));let _=0;for(let t of e.diagnosticReports?.files??[])Q(t,z(g,`diagnostic-reports`,L(t)))&&(_+=1);let v=z(n,`.ok`,`local`),y=z(v,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(H(y)){Q(y,z(g,`state`,`server.lock`));try{let e=W(y,`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`:(q(z(g,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await a(C);t!==null&&q(z(g,`state`,`agent-effects.json`),t);let n=await o(C);if(n!==null){let e=vr(n);e!==null&&q(z(g,`state`,`watcher-recent.jsonl`),e)}}let w=s(t);w!==null&&q(z(g,`state`,`shadow-head.txt`),w);let T=c(t);T!==null&&q(z(g,`state`,`checkpoint-refs.txt`),T),Q(fr(n),z(g,`state`,or)),Q(pr(n),z(g,`state`,sr)),Q(z(v,`last-spawn-error.log`),z(g,`state`,`last-spawn-error.log`)),Q(z(v,ee),z(g,`state`,ee)),Q(z(v,h),z(g,`state`,h)),Q(z(v,b),z(g,`state`,b));let E=p(),ne=d(),D=f(),re={ok:{version:u(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:ne,language:D}};q(z(g,`state`,`runtime.json`),`${JSON.stringify(re,null,2)}\n`);let O=x===`running`?`running
15
- `:`not-running (${S})\n`;q(z(g,`state`,`server-status.txt`),O);let k=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:vt(e.diagnosticReports,_);if(q(z(g,`state`,`diagnostic-reports-status.txt`),`${k}\n`),q(z(g,kt),gn(e.osTerminationEvidence)),e.processDir&&H(e.processDir)){let t=z(g,`process`);U(t,{recursive:!0}),Pe(e.processDir,t,{recursive:!0})}let A=e.redact===!0;A&&Qn({stagingDir:g,contentDir:t}),e.note&&q(z(g,`note.txt`),e.note);let j=null;e.scrubSecrets===!0&&(j=zr(g));for(let t of e.extraFiles??[]){let e=t.zipName??L(t.sourcePath);if(!Q(t.sourcePath,z(g,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=xn(t,`extra/${e}`);n!==null&&(j??={redactions:[],redactedLineCount:0},j.redactions.push(n),j.redactedLineCount+=n.lineCount)}let M=kr(n),ie=Pr(g),N=[],ae=0,oe=0;for(let e of ie){let t=Br(g,e),n=Ue(e).size,r=Ir(t)?jr(e):0;N.push({path:t,bytes:n,lines:r}),ae+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(oe+=Nr(e))}let se={applied:A};j!==null&&(se.secretScrub=j);let P={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:ne,language:D},contentDir:{pathSha256:Ar(t),absolutePath:A?`<CONTENT_DIR>`:t},telemetry:{localSink:M,otlpPushEnabled:m()},redaction:se,serverStatus:x,files:N};q(z(g,`manifest.json`),`${JSON.stringify(P,null,2)}\n`);let F=Bn(t),ce=ie.some(e=>{try{let t=W(e,`utf-8`);return F.some(e=>t.includes(e))}catch{return!1}}),I={stagedDiagnosticReports:_,totalBytes:ae,fileCount:N.length,docNameCount:oe,contentDirVisible:ce,redacted:A},le=!1;return{stagingDir:g,manifest:P,summary:I,cleanup:()=>{le||(le=!0,K(g,{recursive:!0,force:!0}))}}}catch(e){throw K(g,{recursive:!0,force:!0}),e}}async function Hr(e){let{collected:t,outputPath:n}=e,r=R(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 Ln.ZipFile,a=Pr(t.stagingDir);for(let e of a){let n=Br(t.stagingDir,e);i.addFile(e,n)}i.end();let o=Fe(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 Ur(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,In.parse)(W(n,`utf-8`)),r=Te(t)?t.content:void 0,i=Te(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return B(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 B(e)}async function Wr(e,t,n,r,i,a){let o=Sn(t,e.logger),s=await Vr({contentDir:Ur(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...En(o,e.userLogsDir??z(M(),`logs`)),...On(e.cachesDir??z(J(),`Library`,`Caches`))],userStateFiles:kn(e.bugReportsDir??yn()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(R(e.outputPath),{recursive:!0}),await Hr({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 Gr(e){let{projectDir:t}=e,n=e.readDesktopEnv??xr,r=e.readLanguage??zn,i=()=>Ot(e.diagnosticReportsDir??z(J(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Wr(e,t,n,r,i(),await mn(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await Fn({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:On(e.cachesDir??z(J(),`Library`,`Caches`)),bugReportLedgerFiles:kn(e.bugReportsDir??yn()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await mn(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=re(e,t),i;try{i=W(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,text:i}}let o=a&&typeof a==`object`?a:{},s=A(o),c=s&&!se(o,n);if(!a||typeof a!=`object`||!N(a.pid))return{status:`corrupt`,lockPath:r,text:i,...c?{foreignHost:!0}:{}};let l=le(a),{pid:u}=l;if(c)return{status:`foreign-host`,lockPath:r,lock:l};let d=O(l,{isAlive:n.isAlive,readProcessStart:n.readProcessStart,sameMachine:s});switch(d.verdict){case`gone`:return{status:`dead-pid`,lockPath:r,lock:l,text:i};case`replaced`:return{status:`reused-pid`,lockPath:r,lock:l,text:i};case`unverified`:return d.cause===`unverified-owner`?{status:`unverified-owner`,lockPath:r,pid:u}:{status:`alive`,lockPath:r,lock:l};case`writer`:return{status:`alive`,lockPath:r,lock:l};default:return d}}function Kr(e){return`does not record its owning machine, and its recorded process ${e} is still running on this machine`}function qr(e){return typeof e.machineId==`string`?`records a machine ID different from the one in ${S()}`:`records only the host ${Se(e.hostname)}, not this machine's ${Ke()}`}function Jr(e){return e===`win32`?`USERPROFILE`:`HOME`}function Yr(e){return e.processStart===void 0?` This lock records no process start; a server started by this release records one, which lets \`${a()} stop\` confirm it from any home folder.`:``}function Xr(e,t){let n=`\`${a()} stop\``;return`If the server was started on this machine from another account, run ${n} as that account. If it was started from this account with a different home folder, run ${n} with \`${Jr(t)}\` set to that folder. Otherwise stop it from the machine that owns the lock.${Yr(e)}`}function Zr(e,t){let n=a();return`If the server was started on this machine from another account, run \`${n} stop\` as that account while it is running, or \`${n} clean\` once it has exited. If it was started from this account with a different home folder, run the same command with \`${Jr(t)}\` set to that folder. Otherwise run the same command on the machine that owns the lock.${Yr(e)}`}function Qr(e){return`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} and retry cleanup.`}function $r(e,t=process.platform){let{lock:n,lockPath:r}=e;return`${typeof n.machineId==`string`?Zr(n,t):`If ${Se(n.hostname)} is another machine, stop OpenKnowledge there; if it is an earlier name of this machine, stop OpenKnowledge here if it is still running.`} ${Qr(r)}`}function ei(e,t=process.platform){let{lockPath:n}=e;return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${n} ${Kr(e.pid)}. 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.`:e.status===`corrupt`?`Cannot verify shutdown: the server lock at ${n} records a machine ID or host name that is not this machine's, so its server may run on another machine, or on this one from another account, with a different home folder, or under an earlier host name. Stop OpenKnowledge wherever it was started. ${Qr(n)}`:`Cannot verify shutdown: the server lock at ${n} ${qr(e.lock)}. ${$r(e,t)}`}function ti(e){return e.replace(/:\d+$/,``)}function ni(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:ti(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:ti(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:ti(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 ri=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function ii(e){return i(g(),e)}function ai(){return f(g())}function oi(){let e=g();if(e===`stable`)return ri;let t=u(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const si={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>Ie(e),readlinkSync:e=>Be(e)};function ci(e,t=si){let n=ii(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 li(e){let t=e.replace(oi(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function ui(e,t,n=si){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const di=[{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`}],fi=[...D.map(e=>P[e]),`open-knowledge`];function pi(e){if(!Ae(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||R(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function mi(e,t){let n=je(e,t);if(n.startsWith(`..`)||Ae(n))return!1;let r=e;for(let e of n.split(V)){r=z(r,e);try{if(!Ie(r).isDirectory())return!1}catch{return!1}}return!0}function hi(e,t){try{return G(e).every(n=>t.has(z(e,n)))}catch{return!1}}function gi(e){let t=pi(e),n=[],r=[],i=new Set;for(let e of di){let a=z(t,e.hostDir,`skills`);if(!mi(t,a))continue;let o=fi.map(e=>z(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=z(t,e.pruneRoot),c=a;for(;hi(c,i)&&(r.push(c),i.add(c),c!==s);){let e=R(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function _i(e){try{if(!Ie(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function vi(e){let t=new Set,n=new Set;for(let r of di){let i=z(e,r.hostDir,`skills`);for(let e of fi)t.add(z(i,e));let a=z(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=R(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function yi(e,t){let n=pi(e),r=vi(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(mi(n,e)&&_i(e))try{K(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(mi(n,e))try{He(e),a.push(e)}catch{}return a}function bi(e){let t=pi(e),n=[];for(let e of D){let r=P[e];n.push({path:z(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of c)n.push({path:z(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function xi(e,t){let n=[];for(let r of bi(e))if(r.bundleId===t)try{K(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 Si(e){if(!e||typeof e!=`object`)return String(e);let t=typeof e.readProcessStart;return`${ge(e)} readProcessStart=${t}`}function Ci(e,t={}){if(!Number.isSafeInteger(e)||e<=0||e>4294967295)return null;let n=t.arch??process.arch,r=(e,n,r)=>{ve(n,r),t.onNativeFailure?.({kind:e,reason:_e(n,r)})};try{let i=!1,a=he(t.nativeResolver,(e,t)=>{i=!0,r(`unavailable`,e,t)});if(!a||typeof a!=`object`||!(`readProcessStart`in a)||typeof a.readProcessStart!=`function`){let e;return e=a==null?i?`no usable binding was returned`:`the addon was not found`:Si(a),r(`unavailable`,`the Windows native addon (native-config.win32-${n}-msvc.node) did not load or does not export readProcessStart`,e),null}let o=a.readProcessStart(e);return typeof o==`number`&&Number.isSafeInteger(o)&&o>=0?o:(r(`unavailable`,`readProcessStart returned an invalid value`,ge(o)),null)}catch(e){return r(`query-failed`,`readProcessStart failed`,e),null}}function wi(e,t={}){return oe(e,{platform:t.platform,readNative:e=>Ci(e,{onNativeFailure:t.onNativeFailure})})}function Ti(e){let{platform:t,pid:n,nativeFailures:r,causeRecorded:i}=e,a=r.some(e=>{switch(e.kind){case`unavailable`:return!0;case`query-failed`:return!1;default:return e.kind}}),o=r.length===0?``:a?`Reinstall OpenKnowledge to restore the Windows component that verifies process identity. `:`The Windows component loaded but the operating system refused the query, so reinstalling will not help; retry from an account that can inspect that process. `;return(t===`linux`?`Linux reads the process start from /proc/${n}/stat and /proc/stat; restore read access to /proc and retry. `:t===`darwin`?`macOS reads the process start with ps, and that read failed, as it does inside some sandboxes; retry from a shell where ps can run. `:t===`win32`?o:``)+(r.length>0&&i?`The failure detail is recorded in the CLI log under ${y(`logs`)}. `:``)}function Ei(e){let t=new Set;return ie(n=>{let r=[],i=Ci(n,{onNativeFailure:e=>{r.push(e)}});for(let i of new Set(r.map(e=>e.kind)))t.has(i)||(t.add(i),(e??xe())?.warn({event:`process-start-native-failure`,lockPid:n,kind:i,reasons:r.filter(e=>e.kind===i).map(e=>e.reason)},`the Windows process-start query failed, so lock holders cannot be verified; later failures of this kind are not recorded again`));return i})}function Di(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Oi(e,t=Date.now()){if(e===null)return`—`;let n=at(e,t);return n===`unknown`?`—`:n}function ki(e){let t=R(e);return L(e)===`local`&&L(t)===`.ok`?R(t):L(e)===`.ok`?t:null}function Ai(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:ki(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`&&T(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:ce(n),command:n,isDesktop:Di(n)}}function ji(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`:case`reused-pid`:return`stale`;default:return t}}const Mi=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Ni(e){switch(e){case`running`:return Z.default.green(e);case`desktop`:return Z.default.blue(e);case`foreign`:return Z.default.cyan(e);case`unverified`:case`stale`:return Z.default.yellow(e)}}function Pi(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Fi(e){return`${Pi(e.server.usage)} | ${Pi(e.ui?.usage??null)}`}function Ii(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Li(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??`—`,Ii(e),Fi(e),ji(e),String(e.server.pid),Oi(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 o=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),s=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=Ni(ji(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),c=Z.default.dim(`To stop a server: ${a()} stop <port|pid|directory|all>`);return[o,...s,``,c].join(`
16
- `)}async function Ri(e={}){let t=e.discover??I,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??ne,a=e.resolveUsage??E,o=await t(),s=[];for(let e of o){let t=n(e),r=Ai(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:ji(e)}));r(JSON.stringify(e,null,2));return}r(Li(e.all?s:s.filter(e=>Mi.has(ji(e)))))}function zi(){return new be(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale 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 Bi(e,t=xe()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=w(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 Vi(e,t={}){return Ji(e,t.isAlive??F)?{targets:[{name:`server`,pid:e.lock.pid,port:e.lock.port}],lock:e.lock}:{targets:[]}}function Hi(e){try{return g()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function Ui(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)),o=e.probeClients??Bi,s=e.logger??xe(),c=e.platform??process.platform,l=t(),u=Vi(l,{isAlive:e.isAlive}),{lock:d}=u,f=[],p=[],h=(t,n)=>{s?.warn({lockDir:e.lockDir,lockPath:n.lockPath,lockPid:n.pid,platform:c,cause:n.cause,...`nativeFailures`in n&&n.nativeFailures.length>0?{nativeFailures:n.nativeFailures}:{}},`stop declined: lock holder identity unverified`),p.push({target:t,error:Ki(n,s!==void 0),unverified:n})},g=()=>{if(f.length>0){let e=f.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);r(`Stopped: ${e}`)}if(s?.info({lockDir:e.lockDir,signalled:f.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:p.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),p.length>0){let e=p.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `);i(`Failed to stop: ${e}`)}return{stopped:f,failed:p,hadTargets:!0}};if(l.status===`unverified-owner`){let{pid:e,lockPath:t}=l;return h({name:`server`,pid:e},{cause:`unverified-owner`,pid:e,lockPath:t}),g()}if(d===void 0)return r(`No running open-knowledge processes.`),s?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let _=l.status===`alive`||l.status===`foreign-host`?l.lock.channel:void 0;if(e.force!==!0&&typeof _==`string`&&_.length>0){let t=e.selfChannel??Hi(s);if(t!==void 0&&_!==t)return i(`Not stopping: the server at ${e.lockDir} belongs to ${m(_)}. `+(_===`dev`?`Stop it from that dev build, or run \`${x} stop\` with OK_CHANNEL=dev set, or re-run with --force to terminate anyway.`:`Stop it from that app or its CLI, or re-run with --force to terminate anyway.`)),s?.warn({lockDir:e.lockDir,holderChannel:_,selfChannel:t,pids:u.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:_}}}if(e.force!==!0){let t=await o(e.lockDir,s);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.`),s?.warn({lockDir:e.lockDir,clients:t,pids:u.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}for(let t of u.targets){let o=[],s=(e.readProcessStart??wi)(t.pid,{platform:c,onNativeFailure:e=>{o.push(e)}}),u=O(d,{isAlive:e.isAlive??F,readProcessStart:()=>s,refuseHolderStartedAfterLock:e.refuseHolderStartedAfterLock});switch(u.verdict){case`writer`:try{n(t.pid,`SIGTERM`),f.push(t)}catch(e){p.push({target:t,error:e instanceof Error?e.message:String(e)})}break;case`gone`:r(`${t.name} (pid=${t.pid}) had already exited`);break;case`replaced`:i(`Process ${t.pid} is no longer the server that wrote ${l.lockPath}; it was not signalled. Run \`${a()} clean\` to remove the stale lock.`);break;case`unverified`:h(t,Wi(u.cause,{pid:t.pid,lockPath:l.lockPath,lock:d,platform:c,nativeFailures:o}));break;default:return u}}return g()}function Wi(e,t){let{pid:n,lockPath:r}=t;switch(e){case`foreign-host`:return{cause:e,pid:n,lockPath:r,lock:t.lock,platform:t.platform};case`unverified-owner`:return{cause:e,pid:n,lockPath:r};default:return{cause:e,pid:n,lockPath:r,platform:t.platform,nativeFailures:t.nativeFailures}}}const Gi=`it was not signalled, and --force does not override this check.`;function Ki(e,t){let{pid:n,lockPath:r}=e;switch(e.cause){case`foreign-host`:{let{lock:t}=e;return typeof t.machineId==`string`?`The server lock at ${r} ${qr(t)}, so process ${n}, which is running on this machine, cannot be confirmed as the server that wrote it; ${Gi} ${Xr(t,e.platform)}`:`The server lock at ${r} ${qr(t)}, and the start of process ${n}, which is running on this machine, does not confirm it as the server that wrote the lock; ${Gi} If ${Se(t.hostname)} is another machine, stop the server there. If it is an earlier name of this machine, confirm that process ${n} is an OpenKnowledge server before ending it yourself, and once no OpenKnowledge server is running for this project, remove ${r}.`}case`unverified-owner`:return`The server lock at ${r} ${Kr(n)}, so it cannot be confirmed as the server that wrote the lock; ${Gi} Check whether process ${n} is an OpenKnowledge server, and if it is, stop it yourself. Do not remove the lock file while that process is running.`;default:{let n=qi(e,Gi,`Once you have confirmed no OpenKnowledge server is running for this project, remove ${r}.`,t);return e.cause===`writer-identity-unrecorded`?`${n} A server you start again with this release records its machine ID, so \`${a()} stop\` can confirm it.`:n}}}function qi(e,t,n,r){let{pid:i,lockPath:a,platform:o,nativeFailures:s}=e,c=`Before ending process ${i} yourself, confirm that it is an OpenKnowledge server.`;switch(e.cause){case`process-start-unreadable`:return`Could not read when process ${i} started, so it cannot be confirmed as the server that wrote ${a}; ${t} `+Ti({platform:o,pid:i,nativeFailures:s,causeRecorded:r})+`${c} ${n}`;case`process-start-incomparable`:return`The start of process ${i} cannot be compared with the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-start-mismatch`:return`Process ${i} started before the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-started-after-lock`:return`Process ${i} started after the server lock at ${a} was written, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`recorded-start-in-future`:return`The server lock at ${a} records a start later than the current time on this machine, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;case`writer-identity-unrecorded`:return`The server lock at ${a} records neither a machine ID nor a process start, as locks written by version 0.25.0 and earlier do, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;default:return e.cause}}function Ji(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function Yi(e,t=F){let n=await I(),r=null;for(let i of n){let n=$(i,`server`);if(Ji(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}function Xi(e){(e.failed.length>0||e.declined!==void 0)&&(process.exitCode=1)}async function Zi(e,t){let n=await Ui({lockDir:e,force:t});return Xi(n),n}function Qi(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 \`${a()} ps\` to list them`}.`}async function $i(e){let t=await I(),n=0;for(let r of t)r!==e&&Ji($(r,`server`),F)&&n++;return n}function ea(e){return new be(`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, Beta or a dev build run from source) 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=fe(process.cwd()),n=[],i=await Ui({lockDir:t,force:r,log:e=>n.push(e)});if(i.hadTargets){for(let e of n)console.log(e);Xi(i)}else{let e=await $i(t);console.log(Qi(process.cwd(),e,{listingFollows:e>0})),e>0&&await Ri({})}return}if(i===`all`){let e=await I();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)Ji($(n,`server`),F)&&(await Zi(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 Yi(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await Zi(t,r);return}let a=B(ut(),i),o=fe(a),s=[],c=await Ui({lockDir:o,force:r,log:e=>s.push(e)});if(Xi(c),c.hadTargets)for(let e of s)console.log(e);else console.log(Qi(a,await $i(o)))})}export{Ot as A,Gr as C,yn as D,bn as E,ht as F,gt as I,ut as L,dt as M,pt as N,mn as O,ft as P,lt as R,$ as S,Hr as T,li as _,zi as a,qr as b,yi as c,bi as d,ri as f,ci as g,ai as h,ea as i,vt as j,vn as k,gi as l,ii as m,Bi as n,wi as o,ui as p,Ui as r,Ei as s,qi as t,xi as u,ni as v,Vr as w,ei as x,$r as y,st as z};
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import"./src-Bf43s8QJ.mjs";import"./init-DxmL4VOM.mjs";import"./registry-probes-CIpYsPg_.mjs";import"./start-CZVNt90K.mjs";import{n as e}from"./loader-7rHc_jKi.mjs";import"./preview-BGzTZvt_.mjs";import"./repair-mcp-configs-CtVjr0VS.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{S as e,m as t,p as n,r}from"./start-CZVNt90K.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};