@inkeep/open-knowledge 0.80.0-beta.4 → 0.80.0-beta.6

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 (149) hide show
  1. package/dist/cli.mjs +72 -74
  2. package/dist/config-schema.json +3 -3
  3. package/dist/config.project-local.schema.json +1 -1
  4. package/dist/config.user.schema.json +2 -2
  5. package/dist/constants-BM21y1CS.mjs +1 -0
  6. package/dist/dist-BBi7mVvL.mjs +1 -0
  7. package/dist/dist-GcFBLEr5.mjs +2130 -0
  8. package/dist/index.mjs +233 -233
  9. package/dist/{init-BSjC6Lzt.mjs → init-BR_RY0pY.mjs} +17 -17
  10. package/dist/init-z4dkIpZb.mjs +1 -0
  11. package/dist/{js-exec-VXN6TZ7U-B4rL1N_3.mjs → js-exec-VXN6TZ7U-Z8_USGOo.mjs} +4 -4
  12. package/dist/{launch-json-removal-B6RQofWo.mjs → launch-json-removal-CSulcUxI.mjs} +1 -1
  13. package/dist/loader-CDBcy7_5.mjs +1 -0
  14. package/dist/{loader-4haslDjN.mjs → loader-CpDpte48.mjs} +1 -1
  15. package/dist/{lzma-C5bZvzmx.mjs → lzma-CEMDJHEs.mjs} +2 -2
  16. package/dist/{md-manager-BGnqyqi1-BsJX7ufl.mjs → md-manager-BGnqyqi1-DCa5-0ww.mjs} +153 -153
  17. package/dist/{open-browser-CNeVrnyI.mjs → open-browser-CDL2mqCk.mjs} +1 -1
  18. package/dist/parse-worker.mjs +1 -1
  19. package/dist/{preview-C6n4fjw9.mjs → preview-BCSrELqH.mjs} +1 -1
  20. package/dist/preview-rGoADBsd.mjs +1 -0
  21. package/dist/public/assets/{ActivityModeContent-DCTiw2hr.js → ActivityModeContent-DItZVTCk.js} +1 -1
  22. package/dist/public/assets/{AddPropertiesButton-DLf1hC8K.js → AddPropertiesButton-CvdBSXbP.js} +2 -2
  23. package/dist/public/assets/{AgentDiffPane-DHRU8AxR.js → AgentDiffPane-Cm2GzZBM.js} +1 -1
  24. package/dist/public/assets/{AgentThreadClientBinder-trT1r05W.js → AgentThreadClientBinder-CFgtBbQR.js} +1 -1
  25. package/dist/public/assets/{BugReportHistory-BlMaMheB.js → BugReportHistory-DDQ7rrrr.js} +1 -1
  26. package/dist/public/assets/{BugReportHistoryDialog-Dl2J_kNN.js → BugReportHistoryDialog-Bt-xM9-I.js} +1 -1
  27. package/dist/public/assets/{CodeMirrorPropInput-BepO6Sgu.js → CodeMirrorPropInput-Bf645WUa.js} +1 -1
  28. package/dist/public/assets/{ConsentDialogBody-D70gfceW.js → ConsentDialogBody-RBMJ0gc0.js} +1 -1
  29. package/dist/public/assets/{DeleteConfirmationDialog-CyFvmBqi.js → DeleteConfirmationDialog-n90yA0mh.js} +1 -1
  30. package/dist/public/assets/{DiffViewBoundary-B_W1cw_1.js → DiffViewBoundary-DsG9GOLX.js} +1 -1
  31. package/dist/public/assets/{DocumentContext-DlueKLbL.js → DocumentContext-B3xlplVb.js} +1 -1
  32. package/dist/public/assets/{EditorModeToggle-ljJ8FSrJ.js → EditorModeToggle-Blopqyef.js} +1 -1
  33. package/dist/public/assets/{EnableSyncConfirmDialog-DzvC0Mpe.js → EnableSyncConfirmDialog-B056XoQ0.js} +1 -1
  34. package/dist/public/assets/{ExcalidrawDocEditor-D04cXs58.js → ExcalidrawDocEditor-C4F3udw2.js} +1 -1
  35. package/dist/public/assets/FeedbackForm-GRSOr0fy.js +1 -0
  36. package/dist/public/assets/{GraphPanel-Df2U0G-4.js → GraphPanel-CewYgyfZ.js} +1 -1
  37. package/dist/public/assets/{ImageAttachments-C-5sQ75E.js → ImageAttachments-DmjOMNqA.js} +1 -1
  38. package/dist/public/assets/{ImportSkillDialog-CeL9MmZg.js → ImportSkillDialog-CgCFe5Pv.js} +1 -1
  39. package/dist/public/assets/{LintConfigEditor-dnd2fiqC.js → LintConfigEditor-BgrTlSeu.js} +1 -1
  40. package/dist/public/assets/{ManagedArtifactProperties-Mq7GjcqR.js → ManagedArtifactProperties-BTFq6Ngk.js} +1 -1
  41. package/dist/public/assets/ManagedArtifactProperties-mFeT6hbW.js +1 -0
  42. package/dist/public/assets/{MermaidDocEditor-Cy09YvVZ.js → MermaidDocEditor-C5hGyxfZ.js} +1 -1
  43. package/dist/public/assets/{OpenInAgentMenuItem-bUqSoKzB.js → OpenInAgentMenuItem-QrteG6Br.js} +1 -1
  44. package/dist/public/assets/{PropertyDisplayRow-B9rs80AL.js → PropertyDisplayRow-D2nLNITg.js} +1 -1
  45. package/dist/public/assets/{RegisteredAgentIcon-C8cUr8Cj.js → RegisteredAgentIcon--fiCkSba.js} +1 -1
  46. package/dist/public/assets/{ReportBugDialogBody-BxDyGvcN.js → ReportBugDialogBody-BHJJSRc_.js} +1 -1
  47. package/dist/public/assets/{ReportBugMenuTrigger-BeP1PVk8.js → ReportBugMenuTrigger-DDbgWwFU.js} +1 -1
  48. package/dist/public/assets/{SchemaConfigEditor-BTanVu9K.js → SchemaConfigEditor-CkjLP98S.js} +1 -1
  49. package/dist/public/assets/{SessionsHost-CEwBUwt_.js → SessionsHost-4CsyZngA.js} +2 -2
  50. package/dist/public/assets/{SettingsDialogBody-C5bZMc1S.js → SettingsDialogBody-bpn_QRzv.js} +1 -1
  51. package/dist/public/assets/{ShareBranchSwitchDialog-C1waHnQi.js → ShareBranchSwitchDialog-C4Eqwx_r.js} +1 -1
  52. package/dist/public/assets/{ShareReceiveDialog-B0UXIgi2.js → ShareReceiveDialog-CNa1HD1Q.js} +1 -1
  53. package/dist/public/assets/{ShareReceiveMissDialog-DDowoFuB.js → ShareReceiveMissDialog-B-_2h-KD.js} +1 -1
  54. package/dist/public/assets/{SkillCostValue-C15WAhMi.js → SkillCostValue-CYw_tCqR.js} +1 -1
  55. package/dist/public/assets/{SkillEditBanner-bDQFTZSd.js → SkillEditBanner-BuW2sJvG.js} +1 -1
  56. package/dist/public/assets/{SkillForkDialog-Dw_VC1vk.js → SkillForkDialog-DAn5-JZV.js} +1 -1
  57. package/dist/public/assets/{SkillInstallMenu-CsHLrBd-.js → SkillInstallMenu-Cesp0OI6.js} +1 -1
  58. package/dist/public/assets/{SkillOriginInline-FSJgJOE4.js → SkillOriginInline-_uPhVG7Y.js} +1 -1
  59. package/dist/public/assets/{SkillToolbarControls-pnJALCK3.js → SkillToolbarControls-C3cT4d_4.js} +1 -1
  60. package/dist/public/assets/{SlidesToolbarControls-CD75Z1Oh.js → SlidesToolbarControls-zHguPndQ.js} +1 -1
  61. package/dist/public/assets/{SourceEditor-CG4SyAGZ.js → SourceEditor-Dkmhiwbb.js} +1 -1
  62. package/dist/public/assets/{TerminalPanel-DSqS__4Q.js → TerminalPanel-BzL8_A5I.js} +1 -1
  63. package/dist/public/assets/{TerminalWindowApp-CdPZNLJf.js → TerminalWindowApp-vD_LAXsa.js} +1 -1
  64. package/dist/public/assets/{TextDocEditor-CGyF06C_.js → TextDocEditor-DqBZzHgY.js} +1 -1
  65. package/dist/public/assets/{ThreadView-CCIPW-QB.js → ThreadView-DMbL0dhG.js} +1 -1
  66. package/dist/public/assets/{TimelineDiffPane-DB6dAe2o.js → TimelineDiffPane-vm_67Xp-.js} +1 -1
  67. package/dist/public/assets/{agent-connections-xDHnlWZF.js → agent-connections-BZwWjV-L.js} +1 -1
  68. package/dist/public/assets/{auth-state-cache-BQi0FKqV.js → auth-state-cache-DYtj5a86.js} +1 -1
  69. package/dist/public/assets/{bug-report-send-manager-D-nmYpHV.js → bug-report-send-manager-DOLrtOEv.js} +1 -1
  70. package/dist/public/assets/{client-version-CaNa0QvT.js → client-version-CDitBjAS.js} +1 -1
  71. package/dist/public/assets/{comment-chips-C2jJwXUK.js → comment-chips-ClsM-kmI.js} +1 -1
  72. package/dist/public/assets/{config-provider-Caglq5qS.js → config-provider-Ca2HUShB.js} +1 -1
  73. package/dist/public/assets/{css-color-to-hex-DJhZ-QPk.js → css-color-to-hex-AUn7eIel.js} +1 -1
  74. package/dist/public/assets/{diagnostic-breadcrumb-9HmqdG9O.js → diagnostic-breadcrumb-g0QEaFL4.js} +1 -1
  75. package/dist/public/assets/{dist-CKSoioI8.js → dist-DILeGueK.js} +192 -192
  76. package/dist/public/assets/{doc-paths-a4fVjLYy.js → doc-paths-BWrKtSx2.js} +1 -1
  77. package/dist/public/assets/{doc-undo-manager-8ldpXoUT.js → doc-undo-manager-DSaQkZ_X.js} +1 -1
  78. package/dist/public/assets/{documents-events-CZtSmQGF.js → documents-events-Do7TM3Hd.js} +1 -1
  79. package/dist/public/assets/{file-tree-adapter-DjSzNafC.js → file-tree-adapter-C1_qOMsA.js} +1 -1
  80. package/dist/public/assets/{file-tree-utils-BDrf8D6F.js → file-tree-utils-BcIIWtsU.js} +1 -1
  81. package/dist/public/assets/{folder-config-api-Biu9PH2S.js → folder-config-api-CDR1eAcz.js} +1 -1
  82. package/dist/public/assets/{index-llzPc8ii.js → index-KTOtrBN1.js} +8 -8
  83. package/dist/public/assets/{lint-config-client-CtpTLmxs.js → lint-config-client--83L6Vzq.js} +1 -1
  84. package/dist/public/assets/{markdownlint-rule-browser-CmYWGfCY.js → markdownlint-rule-browser-Dwh97LWk.js} +1 -1
  85. package/dist/public/assets/{navigation-targets-CUokC1RP.js → navigation-targets-CJ9ZxyzV.js} +1 -1
  86. package/dist/public/assets/{page-list-cache-CWP9yGOL.js → page-list-cache-C6t_W1Qs.js} +1 -1
  87. package/dist/public/assets/{pending-receive-nav-store-Bap5Raub.js → pending-receive-nav-store-CRjoDiuf.js} +1 -1
  88. package/dist/public/assets/{preferred-session-events-CUEIYFT-.js → preferred-session-events-CwZtdTs7.js} +1 -1
  89. package/dist/public/assets/{progress-C9lBCHrW.js → progress-_zYa5fpq.js} +1 -1
  90. package/dist/public/assets/{project-paths-BQ-o05KT.js → project-paths-ygpKMwOT.js} +1 -1
  91. package/dist/public/assets/{prop-types-B8o3EswU.js → prop-types-CT1xGqpW.js} +1 -1
  92. package/dist/public/assets/{receive-store-lDX8cgeG.js → receive-store-DutQ_RL1.js} +1 -1
  93. package/dist/public/assets/{selection-context-B-PzVRtY.js → selection-context-C1ld48kx.js} +1 -1
  94. package/dist/public/assets/{sign-in-terminal-events-CfJ3mBLe.js → sign-in-terminal-events-BqTVNN-V.js} +1 -1
  95. package/dist/public/assets/{skill-scope-DI5gmqPM.js → skill-scope-CUAEKGV-.js} +1 -1
  96. package/dist/public/assets/{skills-api-De9HEjhb.js → skills-api-CM8h9xtl.js} +1 -1
  97. package/dist/public/assets/{src-DOIqQXkv.js → src-U7mQYf3e.js} +1 -1
  98. package/dist/public/assets/{startup-marks-CFWs3syR.js → startup-marks-vgWlVGPK.js} +1 -1
  99. package/dist/public/assets/{tag-pill-input-Y6ljfhvB.js → tag-pill-input-BRyN2FKA.js} +1 -1
  100. package/dist/public/assets/{target-navigation-intent-XdliCJgy.js → target-navigation-intent-7jeW8XWM.js} +1 -1
  101. package/dist/public/assets/{telemetry-startup-C2599gsZ.js → telemetry-startup-DiFICPCo.js} +1 -1
  102. package/dist/public/assets/{terminal-command-events-D2A3ox61.js → terminal-command-events-CVCqfbNT.js} +1 -1
  103. package/dist/public/assets/{terminal-launch-events-CJ38YxgG.js → terminal-launch-events-DuaMfoq_.js} +1 -1
  104. package/dist/public/assets/{terminal-telemetry-BWruQjxx.js → terminal-telemetry-BHuv7G5q.js} +1 -1
  105. package/dist/public/assets/{thread-client-opUSjoT6.js → thread-client-BZoVbxhe.js} +1 -1
  106. package/dist/public/assets/{typing-burst-detector-CWE4R_n-.js → typing-burst-detector-d8VRIyWa.js} +1 -1
  107. package/dist/public/assets/{uninstall-BQgdI1YE.js → uninstall-D2krzbU2.js} +1 -1
  108. package/dist/public/assets/{use-activity-panel-BbAFb6_B.js → use-activity-panel-HUILZrq4.js} +1 -1
  109. package/dist/public/assets/{use-apply-config-language-DLpBqdmj.js → use-apply-config-language-BwIOrXvC.js} +1 -1
  110. package/dist/public/assets/{use-collab-url-BnNySuyB.js → use-collab-url-JUcW-mVG.js} +1 -1
  111. package/dist/public/assets/{use-conflicts-By3vedGU.js → use-conflicts-yBw-ZjZM.js} +1 -1
  112. package/dist/public/assets/{use-git-sync-status-DbY7lQ6w.js → use-git-sync-status-CoUdayE7.js} +1 -1
  113. package/dist/public/assets/{use-installed-clis-C-H8pD3V.js → use-installed-clis-j9XDtwV2.js} +2 -2
  114. package/dist/public/assets/{use-live-xterm-theme-Dq7SoxPx.js → use-live-xterm-theme-DBWjwre6.js} +1 -1
  115. package/dist/public/assets/{use-open-skill-aZlFxB21.js → use-open-skill-Ci_4ajE0.js} +1 -1
  116. package/dist/public/assets/{use-settings-route-CnBwjcNG.js → use-settings-route-DHuAch1j.js} +1 -1
  117. package/dist/public/assets/{use-skill-origin-C6A_84cR.js → use-skill-origin-DhcploXf.js} +1 -1
  118. package/dist/public/assets/{use-skills-DJtnRsFe.js → use-skills-DJX6inxB.js} +1 -1
  119. package/dist/public/assets/{use-terminal-enabled-Dc7IhmBw.js → use-terminal-enabled-Y78SBxmZ.js} +1 -1
  120. package/dist/public/assets/{use-timeline-entry-diff-CroxWSA-.js → use-timeline-entry-diff-Cf1oA_J7.js} +1 -1
  121. package/dist/public/assets/{use-workspace-VBOqTrTw.js → use-workspace-2aIeQVoi.js} +1 -1
  122. package/dist/public/index.html +59 -59
  123. package/dist/public/uninstall.html +3 -3
  124. package/dist/{python3-DNGS4G3E-Cm5Hwa-u.mjs → python3-DNGS4G3E-CixyRGKv.mjs} +3 -3
  125. package/dist/registry-probes-CpUHw0Pt.mjs +17 -0
  126. package/dist/{removal-file-path-DgmD5_nT.mjs → removal-file-path-D4u7hIns.mjs} +1 -1
  127. package/dist/{repair-launch-json-B7mDQWuX.mjs → repair-launch-json-D12M3uwf.mjs} +1 -1
  128. package/dist/{repair-mcp-configs-BdVJr4yx.mjs → repair-mcp-configs-CFOzC6j6.mjs} +1 -1
  129. package/dist/schemas/v0/config.project-local.schema.json +1 -1
  130. package/dist/schemas/v0/config.user.schema.json +2 -2
  131. package/dist/{sqlite3-TE5AIOTF-DxxxT49W.mjs → sqlite3-TE5AIOTF-DVwda1Ow.mjs} +3 -3
  132. package/dist/src-CO1INi5A.mjs +11 -0
  133. package/dist/src-DmfAVE82.mjs +1 -0
  134. package/dist/{start-DoprBiXl.mjs → start-CfQ2ZJ9V.mjs} +3 -3
  135. package/dist/start-DjI3fnEc.mjs +1 -0
  136. package/dist/{tar-MZQD7NO4-JRjaVj6V.mjs → tar-MZQD7NO4-BRGDcHqv.mjs} +2 -2
  137. package/package.json +5 -5
  138. package/dist/constants-JLtAmcu6.mjs +0 -1
  139. package/dist/dist-Bkhn2suz.mjs +0 -1
  140. package/dist/dist-lSvSC9qO.mjs +0 -2130
  141. package/dist/init-ChDK6xct.mjs +0 -1
  142. package/dist/loader-Csbf4Lbe.mjs +0 -1
  143. package/dist/preview-DqQqCrui.mjs +0 -1
  144. package/dist/public/assets/FeedbackForm-xJjXCTv5.js +0 -1
  145. package/dist/public/assets/ManagedArtifactProperties-5Ub_9KlH.js +0 -1
  146. package/dist/registry-probes-CavTb20W.mjs +0 -17
  147. package/dist/src-BxPOrcsE.mjs +0 -11
  148. package/dist/src-CIddp0Q3.mjs +0 -1
  149. package/dist/start-B2WF7iC_.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Hd as r,Jl as i,Kd as a,Ku as o,Pt as s,Ud as c,Wd as l,Xd as u,Xu as d,Zd as f,af as p,bs as m,cf as h,df as g,ic as _,if as v,nf as y,nu as b,ou as x,qd as S,sf as C,ss as ee,td as te,tf as ne,vs as re}from"./md-manager-BGnqyqi1-BsJX7ufl.mjs";import{$i as ie,$o as ae,Fo as oe,H as se,Io as ce,Jn as le,L as ue,Mo as w,No as de,Po as fe,R as pe,Rr as me,Tr as he,Tt as ge,Vn as _e,Vo as T,Zr as ve,_a as ye,at as be,ea as xe,go as Se,ia as Ce,jr as we,m as Te,qo as Ee,rt as De,tn as Oe,xo as ke,yo as Ae}from"./dist-lSvSC9qO.mjs";import{i as E,n as D,o as O,r as je,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Me}from"./constants-JLtAmcu6.mjs";import{t as Ne}from"./preview-C6n4fjw9.mjs";import{createRequire as Pe}from"node:module";import{execFileSync as Fe}from"node:child_process";import Ie,{basename as Le,dirname as M,isAbsolute as Re,join as N,posix as ze,relative as P,resolve as F,sep as I,win32 as Be}from"node:path";import L from"node:process";import{fileURLToPath as Ve}from"node:url";import{cpSync as He,existsSync as R,lstatSync as Ue,mkdirSync as We,readFileSync as z,readdirSync as Ge,readlinkSync as Ke,realpathSync as qe,rmSync as Je,statSync as Ye,writeFileSync as Xe}from"node:fs";import{homedir as B}from"node:os";import{inspect as Ze,stripVTControlCharacters as Qe,styleText as V}from"node:util";import*as $e from"node:readline";import{AsyncLocalStorage as et,AsyncResource as tt}from"node:async_hooks";var nt=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),rt=n((e=>{let{InvalidArgumentError:t}=nt();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),it=n((e=>{let{humanReadableArgName:t}=rt();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
1
+ import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Cf as r,Cs as i,Df as a,Os as o,Pt as s,Yl as c,_d as l,_f as u,af as d,bf as f,cf as p,ed as m,fc as h,fd as g,ff as _,fs as v,if as y,lf as b,of as x,pf as S,ru as ee,su as te,vf as ne,wf as C,xf as re}from"./md-manager-BGnqyqi1-DCa5-0ww.mjs";import{$i as ie,Fo as ae,H as oe,Io as se,Jn as ce,Jo as le,L as ue,Mo as w,No as de,Po as fe,R as pe,Rr as me,Tr as he,Tt as ge,Vn as _e,Vo as T,Zr as ve,_a as ye,at as be,ea as xe,es as Se,go as Ce,ia as we,jr as Te,m as Ee,rt as De,tn as Oe,xo as ke,yo as Ae}from"./dist-GcFBLEr5.mjs";import{i as E,n as D,o as O,r as je,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Me}from"./constants-BM21y1CS.mjs";import{t as Ne}from"./preview-BCSrELqH.mjs";import{createRequire as Pe}from"node:module";import{execFileSync as Fe}from"node:child_process";import Ie,{basename as Le,dirname as M,isAbsolute as Re,join as N,posix as ze,relative as P,resolve as F,sep as I,win32 as Be}from"node:path";import L from"node:process";import{fileURLToPath as Ve}from"node:url";import{cpSync as He,existsSync as R,lstatSync as Ue,mkdirSync as We,readFileSync as z,readdirSync as Ge,readlinkSync as Ke,realpathSync as qe,rmSync as Je,statSync as Ye,writeFileSync as Xe}from"node:fs";import{homedir as B}from"node:os";import{inspect as Ze,stripVTControlCharacters as Qe,styleText as V}from"node:util";import*as $e from"node:readline";import{AsyncLocalStorage as et,AsyncResource as tt}from"node:async_hooks";var nt=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),rt=n((e=>{let{InvalidArgumentError:t}=nt();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),it=n((e=>{let{humanReadableArgName:t}=rt();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
2
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
3
3
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
4
4
  `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),at=n((e=>{let{InvalidArgumentError:t}=nt();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -278,7 +278,7 @@ let Er=/^[a-z0-9-_]+$/i;function Dr(e){let t=typeof e;if(t===`object`){if(Array.
278
278
  `)+Pr(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=Ar(t[c],e,r,i),a+=`
279
279
  `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Fr(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Dr(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Pr(0,e,``,t,n);return r[r.length-1]===`
280
280
  `?r:r+`
281
- `}var Ir=o();function Lr(e){let t=e&&typeof e==`object`&&`code`in e?e.code:void 0;return t===`MODULE_NOT_FOUND`||t===`ERR_MODULE_NOT_FOUND`}function Rr(e){return!e||typeof e!=`object`?String(e):`${typeof e} keys=[${Object.keys(e).join(`,`)}]`}function zr(e,t){let n=[],r=new WeakSet,i=t;for(;i instanceof Error&&!r.has(i);)r.add(i),n.push(i.message),i=i.cause;return n.length===0?`${e}: ${Rr(t)}`:`${e}: ${n.reverse().slice(0,5).join(` -> `)}`}function Y(e,t){process.env.OK_DEBUG_NATIVE&&process.stderr.write(`[ok] native-config ${zr(e,t)}\n`)}const Br=[`native`,`index.js`];function Vr(e={},t=Y){let n=e.moduleUrl??import.meta.url,r=e.requireModule??Pe(n);try{let e=M(Ve(n));return r(N(e,...Br))}catch(e){Lr(e)||t(`bundled loader failed to load`,e)}try{return r(`@inkeep/open-knowledge-native-config`)}catch(e){return Lr(e)||t(`workspace addon failed to load`,e),null}}function Hr(){let e=Vr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Ur(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return Y(`addon loaded but probe failed`,e),!1}}function Wr(e){if(!j(e))throw Error(`TOML root is not a table`);return e}function Gr(e){return{backend:`native`,parseToObject(t){return Wr(JSON.parse(e.parseTomlToJson(t)))},upsertEntry(t,n,r){let i=e.upsertMcpServer(t,n,JSON.stringify(r));return{text:i.text,existed:i.existed}},removeEntry(t,n){let r=e.removeMcpServer(t,n);return{text:r.text,existed:r.existed}},removeEntryKey(t,n,r){let i=e.removeMcpServerKey(t,n,r);return{text:i.text,existed:i.existed}}}}function Kr(){return{backend:`fallback`,parseToObject(e){return Wr(Tr(e))}}}function qr(e=Hr){let t=e();return t&&Ur(t)?Gr(t):Kr()}let Jr=null;function Yr(){return Jr===null&&(Jr=qr()),Jr}function Xr(){let e=Yr();return e.backend===`native`?e:void 0}const Zr=r,X=c,Qr=a,$r=`node`,ei={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},ti=`@inkeep/open-knowledge`;function ni(e){return`${ee(`unix-chain`,e.mcpChainTag)}2`}function ri(e){return`${ee(`windows-chain`,e.mcpChainTag)}1`}function ii(e){let t=v[e],n=`${ti}@${t.npmDistTag}`,r=e===`stable`?``:`\nexport ${p}=${e}`;return`${ni(t)}${r}
281
+ `}var Ir=m();function Lr(e){let t=e&&typeof e==`object`&&`code`in e?e.code:void 0;return t===`MODULE_NOT_FOUND`||t===`ERR_MODULE_NOT_FOUND`}function Rr(e){return!e||typeof e!=`object`?String(e):`${typeof e} keys=[${Object.keys(e).join(`,`)}]`}function zr(e,t){let n=[],r=new WeakSet,i=t;for(;i instanceof Error&&!r.has(i);)r.add(i),n.push(i.message),i=i.cause;return n.length===0?`${e}: ${Rr(t)}`:`${e}: ${n.reverse().slice(0,5).join(` -> `)}`}function Y(e,t){process.env.OK_DEBUG_NATIVE&&process.stderr.write(`[ok] native-config ${zr(e,t)}\n`)}const Br=[`native`,`index.js`];function Vr(e={},t=Y){let n=e.moduleUrl??import.meta.url,r=e.requireModule??Pe(n);try{let e=M(Ve(n));return r(N(e,...Br))}catch(e){Lr(e)||t(`bundled loader failed to load`,e)}try{return r(`@inkeep/open-knowledge-native-config`)}catch(e){return Lr(e)||t(`workspace addon failed to load`,e),null}}function Hr(){let e=Vr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Ur(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return Y(`addon loaded but probe failed`,e),!1}}function Wr(e){if(!j(e))throw Error(`TOML root is not a table`);return e}function Gr(e){return{backend:`native`,parseToObject(t){return Wr(JSON.parse(e.parseTomlToJson(t)))},upsertEntry(t,n,r){let i=e.upsertMcpServer(t,n,JSON.stringify(r));return{text:i.text,existed:i.existed}},removeEntry(t,n){let r=e.removeMcpServer(t,n);return{text:r.text,existed:r.existed}},removeEntryKey(t,n,r){let i=e.removeMcpServerKey(t,n,r);return{text:i.text,existed:i.existed}}}}function Kr(){return{backend:`fallback`,parseToObject(e){return Wr(Tr(e))}}}function qr(e=Hr){let t=e();return t&&Ur(t)?Gr(t):Kr()}let Jr=null;function Yr(){return Jr===null&&(Jr=qr()),Jr}function Xr(){let e=Yr();return e.backend===`native`?e:void 0}const Zr=y,X=d,Qr=p,$r=`node`,ei={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},ti=`@inkeep/open-knowledge`;function ni(e){return`${v(`unix-chain`,e.mcpChainTag)}2`}function ri(e){return`${v(`windows-chain`,e.mcpChainTag)}1`}function ii(e){let t=f[e],n=`${ti}@${t.npmDistTag}`,r=e===`stable`?``:`\nexport ${re}=${e}`;return`${ni(t)}${r}
282
282
  USER_BUNDLE="$HOME/Applications/${t.productName}.app/Contents/Resources/cli/bin/ok.sh"
283
283
  [ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
284
284
  BUNDLE="/Applications/${t.productName}.app/Contents/Resources/cli/bin/ok.sh"
@@ -290,7 +290,7 @@ for d in "$HOME/.nvm/versions/node"/*/bin "$HOME/.fnm/node-versions"/*/installat
290
290
  [ -f "$d/npx" ] && [ -x "$d/npx" ] && exec "$d/npx" -y ${n} mcp
291
291
  done
292
292
  echo "OpenKnowledge: install OK Desktop or Node.js 24+, then restart your editor" >&2
293
- exit 127`}function ai(e){let t=v[e],n=`${ti}@${t.npmDistTag}`,r=`${t.cliCommandNames[0]}.cmd`,i=t.npmDistTag===`latest`?ti:n,a=e===`stable`?``:`\n$env:${p} = '${e}'`;return`${ri(t)}${a}
293
+ exit 127`}function ai(e){let t=f[e],n=`${ti}@${t.npmDistTag}`,r=`${t.cliCommandNames[0]}.cmd`,i=t.npmDistTag===`latest`?ti:n,a=e===`stable`?``:`\n$env:${re} = '${e}'`;return`${ri(t)}${a}
294
294
  if ($env:PATHEXT -notmatch 'CMD') { $env:PATHEXT = '.COM;.EXE;.BAT;.CMD;' + $env:PATHEXT }
295
295
  if ($env:APPDATA) {
296
296
  $shim = Join-Path $env:APPDATA 'npm\\${r}'
@@ -314,22 +314,22 @@ foreach ($d in $dirs) {
314
314
  if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '${n}' mcp; exit $LASTEXITCODE }
315
315
  }
316
316
  [Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g ${i}), then restart your editor')
317
- exit 127`}ni(v.stable),ii(`stable`),ri(v.stable),ai(`stable`);function oi(e){return`// ok-pi-bridge${e.mcpChainTag}`}function si(e){return`${oi(e)}-v1`}oi(v.stable),si(v.stable);function ci(e){if(typeof e!=`object`||!e)return!1;let t=C(),n=e;if(n.command===`/bin/sh`){if(!Array.isArray(n.args)||n.args[0]!==`-l`||n.args[1]!==`-c`)return!1;let e=n.args[2];return _i(e,ni(t))}if(n.command===`powershell`){if(!Array.isArray(n.args)||n.args[0]!==`-NoProfile`||n.args[1]!==`-NonInteractive`||n.args[2]!==`-Command`)return!1;let e=n.args[3];return _i(e,ri(t))}if(n.type===`local`&&Array.isArray(n.command)){if(n.command[0]===`/bin/sh`){if(n.command[1]!==`-l`||n.command[2]!==`-c`)return!1;let e=n.command[3];return _i(e,ni(t))}if(n.command[0]===`powershell`){if(n.command[1]!==`-NoProfile`||n.command[2]!==`-NonInteractive`||n.command[3]!==`-Command`)return!1;let e=n.command[4];return _i(e,ri(t))}return!1}if(n.command===`ok-pi-managed-extension`){if(!Array.isArray(n.args))return!1;let e=n.args[0];return typeof e==`string`&&e.startsWith(si(t))}return!1}function li(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=F(e);if(Le(t)===`cli.mjs`&&Le(M(t))===`dist`)return t;let n=t.split(I),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r),a=i.length===0?I:i.join(I);return N(a,`packages`,`cli`,`dist`,`cli.mjs`)}function Z(e={}){return e.mode===`dev`?{command:$r,args:[li(),`mcp`],env:{...ei}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,ai(g())]}:{command:`/bin/sh`,args:[`-l`,`-c`,ii(g())]}}function ui(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[$r,li(),`mcp`],environment:{...ei}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,ai(g())]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,ii(g())]}}function di(e){if(typeof e!=`object`||!e)return!1;let t=e;return fi(t,Z({mode:`published`,platformName:`darwin`}))||fi(t,Z({mode:`published`,platformName:`win32`}))}function fi(e,t){return Object.keys(e).length===Object.keys(t).length&&pi(e,t)}function pi(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function mi(e,t){let n=e=>vi(e);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`&&e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3])}function hi(e){return e.format===`toml`?Yr().backend===`native`:e.format===`json`||e.format===`yaml`}function gi(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function _i(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function vi(e){return _i(e,`# ok-mcp`)}function yi(e){return typeof e==`string`&&(e===ti||e.startsWith(`${ti}@`))}function bi(e){if(typeof e!=`object`||!e)return!1;let t=gi(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&vi(t[n+1])?!0:t.some(yi)}function xi(e){if(typeof e!=`object`||!e)return!1;let t=gi(e);if(t[0]!==$r||t[2]!==`mcp`)return!1;try{return t[1]===li()}catch{return!1}}const Si=[`command`,`args`,`env`],Ci=[`type`,`command`,`environment`];function wi(e){return e.type===`local`&&Array.isArray(e.command)?Ci:Si}function Ti(e,t){if(typeof e!=`object`||!e)return[];let n=e;return wi(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function Ei(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function Di(e,t){return Ti(e,t).length>0}function Oi(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:mi(t.args,t.command)}function ki(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&mi(r,n)}function Q(e){return e===`win32`?Be:ze}function Ai(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA||i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME||i.join(n,`.config`)}function ji(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.claude.json`)}function Mi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env;if(t===`darwin`)return ze.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Be.join(n,`AppData`,`Roaming`);return Be.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Ni(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.cursor`,`mcp.json`)}function Pi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).CODEX_HOME??Q(t).join(n,`.codex`)}function Fi(e={}){return Q(e.platformName??process.platform).join(Pi(e),`config.toml`)}function Ii(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=(e.env??process.env).COPILOT_HOME??Q(t).join(n,`.copilot`);return Q(t).join(r,`mcp-config.json`)}function Li(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function Ri(e={}){return Q(e.platformName??process.platform).join(Li(e),`opencode.json`)}function zi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.openclaw`,`openclaw.json`)}function Bi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.hermes`,`config.yaml`)}function Vi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).PI_CODING_AGENT_DIR??Q(t).join(n,`.pi`,`agent`)}function Hi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Ui(e,t){let n=Q(t);return[{file:n.join(e,`.lmstudio`,`mcp.json`),dir:n.join(e,`.lmstudio`)},{file:n.join(e,`.cache`,`lm-studio`,`mcp.json`),dir:n.join(e,`.cache`,`lm-studio`)}]}function Wi(e){try{return Ge(e).length>0}catch{return!1}}function Gi(e={}){let t=e.platformName??process.platform,[n,r]=Ui(e.home??B(),t),i=[n,r].find(e=>R(e.file));return i?i.file:Wi(r.dir)?r.file:n.file}const $={claude:{id:`claude`,label:X.claude,configPath:(e,t)=>ji({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>h(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.claude`),projectConfigPath:e=>N(e,`.mcp.json`),projectSkillPath:e=>N(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:X[`claude-desktop`],configPath:(e,t)=>Mi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>h(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Mi({home:t}))},cursor:{id:`cursor`,label:X.cursor,configPath:(e,t)=>Ni({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>h(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ni({home:t})),projectConfigPath:e=>N(e,`.cursor`,`mcp.json`),projectSkillPath:e=>N(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:X.codex,configPath:(e,t)=>Fi({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>h(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Fi({home:t})),projectConfigPath:e=>N(e,`.codex`,`config.toml`),projectSkillPath:e=>N(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:X.copilot,configPath:(e,t)=>Ii({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>h(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ii({home:t})),projectSkillPath:e=>N(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:X.opencode,configPath:(e,t)=>Ri({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>h(),buildEntry:(e,t)=>ui(t),scope:`global`,detectPath:(e,t)=>M(Ri({home:t})),projectConfigPath:e=>N(e,`opencode.json`),projectSkillPath:e=>N(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:X.openclaw,configPath:(e,t)=>zi({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>h(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:X.pi,configPath:()=>{throw Error(`Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at ${ne(C())} (run \`ok init\` in the project).`)},format:`file`,topLevelKey:`mcpServers`,serverName:()=>h(),scope:`project`,detectPath:(e,t)=>Vi({home:t}),projectConfigPath:e=>N(e,ne(C())),projectSkillPath:e=>N(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:X.antigravity,configPath:(e,t)=>Hi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>h(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:X[`lm-studio`],configPath:(e,t)=>Gi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>h(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Gi({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:X.hermes,configPath:(e,t)=>Bi({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>h(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.hermes`),offerOnlyWhenDetected:!0}};function Ki(e){let t=e.filter(e=>!Object.hasOwn($,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${Zr.join(`, `)}`);return e.map(e=>$[e])}const qi=`**/.ok/*`,Ji=`!**/${b}/`;function Yi(e){let t=[`.ok/`,`.okignore`];for(let n of Zr){let r=$[n];r.projectConfigPath&&t.push(ua(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function Xi(e){let t=N(e,...s);if(!R(t))return[];try{let e=re(z(t,`utf-8`));if(!e)return[];let n=[];for(let[t,r]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of r.hosts){let r=l[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function Zi(e,t){let n=ta(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:aa(n)};let r=oa(e);if(r.kind!==`ok`)return r.result;let i=R(r.path)?z(r.path,`utf-8`):``,a=new Set(Xi(e)),o=[],s=a.size===0?i:i.split(`
317
+ exit 127`}ni(f.stable),ii(`stable`),ri(f.stable),ai(`stable`);function oi(e){return`// ok-pi-bridge${e.mcpChainTag}`}function si(e){return`${oi(e)}-v1`}oi(f.stable),si(f.stable);function ci(e){if(typeof e!=`object`||!e)return!1;let t=r(),n=e;if(n.command===`/bin/sh`){if(!Array.isArray(n.args)||n.args[0]!==`-l`||n.args[1]!==`-c`)return!1;let e=n.args[2];return _i(e,ni(t))}if(n.command===`powershell`){if(!Array.isArray(n.args)||n.args[0]!==`-NoProfile`||n.args[1]!==`-NonInteractive`||n.args[2]!==`-Command`)return!1;let e=n.args[3];return _i(e,ri(t))}if(n.type===`local`&&Array.isArray(n.command)){if(n.command[0]===`/bin/sh`){if(n.command[1]!==`-l`||n.command[2]!==`-c`)return!1;let e=n.command[3];return _i(e,ni(t))}if(n.command[0]===`powershell`){if(n.command[1]!==`-NoProfile`||n.command[2]!==`-NonInteractive`||n.command[3]!==`-Command`)return!1;let e=n.command[4];return _i(e,ri(t))}return!1}if(n.command===`ok-pi-managed-extension`){if(!Array.isArray(n.args))return!1;let e=n.args[0];return typeof e==`string`&&e.startsWith(si(t))}return!1}function li(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=F(e);if(Le(t)===`cli.mjs`&&Le(M(t))===`dist`)return t;let n=t.split(I),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r),a=i.length===0?I:i.join(I);return N(a,`packages`,`cli`,`dist`,`cli.mjs`)}function Z(e={}){return e.mode===`dev`?{command:$r,args:[li(),`mcp`],env:{...ei}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,ai(a())]}:{command:`/bin/sh`,args:[`-l`,`-c`,ii(a())]}}function ui(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[$r,li(),`mcp`],environment:{...ei}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,ai(a())]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,ii(a())]}}function di(e){if(typeof e!=`object`||!e)return!1;let t=e;return fi(t,Z({mode:`published`,platformName:`darwin`}))||fi(t,Z({mode:`published`,platformName:`win32`}))}function fi(e,t){return Object.keys(e).length===Object.keys(t).length&&pi(e,t)}function pi(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function mi(e,t){let n=e=>vi(e);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`&&e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3])}function hi(e){return e.format===`toml`?Yr().backend===`native`:e.format===`json`||e.format===`yaml`}function gi(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function _i(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function vi(e){return _i(e,`# ok-mcp`)}function yi(e){return typeof e==`string`&&(e===ti||e.startsWith(`${ti}@`))}function bi(e){if(typeof e!=`object`||!e)return!1;let t=gi(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&vi(t[n+1])?!0:t.some(yi)}function xi(e){if(typeof e!=`object`||!e)return!1;let t=gi(e);if(t[0]!==$r||t[2]!==`mcp`)return!1;try{return t[1]===li()}catch{return!1}}const Si=[`command`,`args`,`env`],Ci=[`type`,`command`,`environment`];function wi(e){return e.type===`local`&&Array.isArray(e.command)?Ci:Si}function Ti(e,t){if(typeof e!=`object`||!e)return[];let n=e;return wi(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function Ei(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function Di(e,t){return Ti(e,t).length>0}function Oi(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:mi(t.args,t.command)}function ki(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&mi(r,n)}function Q(e){return e===`win32`?Be:ze}function Ai(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA||i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME||i.join(n,`.config`)}function ji(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.claude.json`)}function Mi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env;if(t===`darwin`)return ze.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Be.join(n,`AppData`,`Roaming`);return Be.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Ni(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.cursor`,`mcp.json`)}function Pi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).CODEX_HOME??Q(t).join(n,`.codex`)}function Fi(e={}){return Q(e.platformName??process.platform).join(Pi(e),`config.toml`)}function Ii(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=(e.env??process.env).COPILOT_HOME??Q(t).join(n,`.copilot`);return Q(t).join(r,`mcp-config.json`)}function Li(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function Ri(e={}){return Q(e.platformName??process.platform).join(Li(e),`opencode.json`)}function zi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.openclaw`,`openclaw.json`)}function Bi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.hermes`,`config.yaml`)}function Vi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).PI_CODING_AGENT_DIR??Q(t).join(n,`.pi`,`agent`)}function Hi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Ui(e,t){let n=Q(t);return[{file:n.join(e,`.lmstudio`,`mcp.json`),dir:n.join(e,`.lmstudio`)},{file:n.join(e,`.cache`,`lm-studio`,`mcp.json`),dir:n.join(e,`.cache`,`lm-studio`)}]}function Wi(e){try{return Ge(e).length>0}catch{return!1}}function Gi(e={}){let t=e.platformName??process.platform,[n,r]=Ui(e.home??B(),t),i=[n,r].find(e=>R(e.file));return i?i.file:Wi(r.dir)?r.file:n.file}const $={claude:{id:`claude`,label:X.claude,configPath:(e,t)=>ji({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.claude`),projectConfigPath:e=>N(e,`.mcp.json`),projectSkillPath:e=>N(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:X[`claude-desktop`],configPath:(e,t)=>Mi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Mi({home:t}))},cursor:{id:`cursor`,label:X.cursor,configPath:(e,t)=>Ni({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ni({home:t})),projectConfigPath:e=>N(e,`.cursor`,`mcp.json`),projectSkillPath:e=>N(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:X.codex,configPath:(e,t)=>Fi({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Fi({home:t})),projectConfigPath:e=>N(e,`.codex`,`config.toml`),projectSkillPath:e=>N(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:X.copilot,configPath:(e,t)=>Ii({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ii({home:t})),projectSkillPath:e=>N(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:X.opencode,configPath:(e,t)=>Ri({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>C(),buildEntry:(e,t)=>ui(t),scope:`global`,detectPath:(e,t)=>M(Ri({home:t})),projectConfigPath:e=>N(e,`opencode.json`),projectSkillPath:e=>N(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:X.openclaw,configPath:(e,t)=>zi({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:X.pi,configPath:()=>{throw Error(`Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at ${u(r())} (run \`ok init\` in the project).`)},format:`file`,topLevelKey:`mcpServers`,serverName:()=>C(),scope:`project`,detectPath:(e,t)=>Vi({home:t}),projectConfigPath:e=>N(e,u(r())),projectSkillPath:e=>N(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:X.antigravity,configPath:(e,t)=>Hi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:X[`lm-studio`],configPath:(e,t)=>Gi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Gi({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:X.hermes,configPath:(e,t)=>Bi({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.hermes`),offerOnlyWhenDetected:!0}};function Ki(e){let t=e.filter(e=>!Object.hasOwn($,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${Zr.join(`, `)}`);return e.map(e=>$[e])}const qi=`**/.ok/*`,Ji=`!**/${ee}/`;function Yi(e){let t=[`.ok/`,`.okignore`];for(let n of Zr){let r=$[n];r.projectConfigPath&&t.push(ua(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function Xi(e){let t=N(e,...s);if(!R(t))return[];try{let e=i(z(t,`utf-8`));if(!e)return[];let n=[];for(let[t,r]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of r.hosts){let r=x[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function Zi(e,t){let n=ta(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:aa(n)};let r=oa(e);if(r.kind!==`ok`)return r.result;let i=R(r.path)?z(r.path,`utf-8`):``,a=new Set(Xi(e)),o=[],s=a.size===0?i:i.split(`
318
318
  `).filter(e=>{let t=e.trim();return!a.has(t)||(o.push(t),!1)}).join(`
319
319
  `),c=la(s),l=[],u=[];for(let e of t)ca(c,e)?u.push(e):l.push(e);if(l.length===0&&o.length===0)return{kind:`updated`,appended:l,alreadyPresent:u,removed:[]};let d=l.length===0||s.length===0||s.endsWith(`
320
320
  `)?``:`
321
321
  `,f=l.length===0?``:`${l.join(`
322
322
  `)}\n`;try{Xe(r.path,`${s}${d}${f}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:l,alreadyPresent:u,removed:o}}function Qi(e,t){let n=oa(e);if(n.kind!==`ok`)return n.result;if(!R(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>sa(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(qi),i.add(Ji);for(let t of Xi(e))i.add(t);let a;try{a=z(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let o=a.split(`
323
323
  `),s=new Set,c=[];for(let e of o){let t=e.trim();if(i.has(t)){s.add(t);continue}c.push(e)}let l=[...s];if(s.size===0)return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let u=c.join(`
324
- `);if(u!==a)try{Xe(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function $i(e){let t=oa(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!R(t.path))return`shared`;let n;try{n=z(t.path,`utf-8`)}catch{return`shared`}let r=la(n),i=Yi(e);for(let e of i)if(ca(r,e))return`local-only`;return r.has(qi)?`local-only`:`shared`}function ea(e){let t=oa(e);if(t.kind!==`ok`||!R(t.path))return[];let n;try{n=z(t.path,`utf-8`)}catch{return[]}let r=la(n),i=[...Yi(e),...Xi(e)].filter(e=>ca(r,e)),a=new Set(i),o=[];for(let e of Object.values(l))e!==null&&o.push(e);let s=[];for(let e of r){if(a.has(e))continue;if(e===qi||e===Ji){s.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);o.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&s.push(e)}return[...i,...s]}function ta(e,t){let n=[];for(let r of t){let t=F(e,r);if(R(t))try{Fe(`git`,[`ls-files`,`--error-unmatch`,...m([r])],Se({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}const na=/^[\w.\-/]+$/;function ra(e){return process.platform===`win32`?`"${e.replaceAll(`"`,``)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`}function ia(e){return na.test(e)?e:ra(_(e))}function aa(e){let t=[];t.push(`Cannot switch OpenKnowledge to local-only — these OK files are tracked upstream:`),t.push(``);for(let n of e)t.push(` ${n}`);t.push(``),t.push(`.git/info/exclude only hides files that git isn't already tracking. To proceed, untrack them first:`),t.push(``);for(let n of e){let e=n.replace(/\/$/,``),r=n.endsWith(`/`)?`-r `:``;t.push(` git rm --cached ${r}-- ${ia(e)}`)}return t.push(``),t.push("Then re-run the command. Note: `git rm --cached` removes the files from the index — your teammates will see a deletion on their next pull. If you don't want that, leave sharing mode set to 'shared'."),t.join(`
325
- `)}function oa(e){let t=ae(e);switch(t.kind){case`repository`:{let e=t.repository.readCommonDir();if(e.kind===`unreadable`)return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}};let n=N(e.path,`info`);return R(n)?{kind:`ok`,path:N(n,`exclude`)}:{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-info-dir`}}}case`absent`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-git`}};case`malformed-pointer`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`malformed-pointer`}};case`inaccessible`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}}}}function sa(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function ca(e,t){for(let n of sa(t))if(e.has(n))return!0;return!1}function la(e){let t=new Set;for(let n of e.split(`
326
- `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function ua(e,t){return da(P(t,e))}function da(e){return I===`/`?e:e.split(I).join(`/`)}var fa=class extends Error{name=`ProjectPathSafetyError`;code=`PROJECT_PATH_SAFETY`};function pa(e,t){let n;try{n=Ue(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw new fa(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);ha(e,t)}function ma(e,t){ha(e,t)}function ha(e,t){ga(e,t)}function ga(e,t){let n=t,r;try{r=qe(n)}catch{r=F(n)}let i=M(e);for(;i.length>1&&i!==I;){let t;try{t=qe(i)}catch(e){if(e.code===`ENOENT`){i=M(i);continue}throw e}let n=P(r,t);if(n===``||!n.startsWith(`..`)&&!Re(n))return;throw new fa(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function _a(e,t){let n=M(t),r=R(t)?`overwritten`:`written`;if(r===`written`&&R(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return Je(n,{recursive:!0,force:!0}),We(M(n),{recursive:!0}),He(e,n,{recursive:!0}),r}function va(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ya(e,t,n){try{if(Ye(n).size>10485760)return!1}catch{return!1}let r;try{r=z(n,`utf-8`)}catch{return!1}let i=[],a=oe(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!va(a))return!1;let o=a[e.topLevelKey];if(!va(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!va(s))return!1;let c=s[e.serverName(t)];return va(c)&&c.enabled===!1?!1:bi(c)||xi(c)}function ba(e){let t=d[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:te(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:$[n.editor]??null}function xa(e,t,n={}){if(!f.includes(e.id))return!0;let r=ba(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&ya(r,t,i))return!0;try{return ya(e,t,e.configPath(t,n.home))}catch{return!1}}function Sa(e){let t=new Set(S.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function Ca(e,t){if(Sa(t).length===0)return null;let n=N(e,i,u,`SKILL.md`);try{let t=Ce(`project`,{checkDesktop:!0});return pa(M(n),e),{editorId:`agents`,label:`.agents hub`,action:_a(t,n),path:n}}catch(e){return{editorId:`agents`,label:`.agents hub`,action:`failed`,path:n,error:e instanceof Error?e.message:String(e)}}}function wa(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!xa(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=Ce(`project`,{checkDesktop:!0});pa(M(r),t);let i=_a(n,r);return{editorId:e.id,label:e.label,action:i,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function Ta(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=M(n);return R(n)?(ma(r,t),Je(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function Ea(e){switch(e?.code){case`EACCES`:case`EPERM`:return`permission-denied`;case`ELOOP`:return`unresolved-symlink`;case`EISDIR`:case`ENOTDIR`:return`not-a-file`;case`ENOENT`:return`disappeared`;default:return`unreadable`}}function Da(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions, then retry`;case`missing-symlink-target`:return`the symlink target is missing; restore the target or correct the symlink, then retry`;case`unresolved-symlink`:return`the path or symlink could not be resolved; check path permissions and repair any symlink cycle, then retry`;case`not-a-file`:return`the path is not a regular file; restore the intended configuration file, then retry`;case`disappeared`:return`the file disappeared; retry to check its current state`;case`unreadable`:return`the file could not be read; check that the path is accessible, then retry`;default:throw Error(`unhandled configuration file decline reason: ${e}`)}}function Oa(e){for(let t of e.split(`
324
+ `);if(u!==a)try{Xe(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function $i(e){let t=oa(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!R(t.path))return`shared`;let n;try{n=z(t.path,`utf-8`)}catch{return`shared`}let r=la(n),i=Yi(e);for(let e of i)if(ca(r,e))return`local-only`;return r.has(qi)?`local-only`:`shared`}function ea(e){let t=oa(e);if(t.kind!==`ok`||!R(t.path))return[];let n;try{n=z(t.path,`utf-8`)}catch{return[]}let r=la(n),i=[...Yi(e),...Xi(e)].filter(e=>ca(r,e)),a=new Set(i),o=[];for(let e of Object.values(x))e!==null&&o.push(e);let s=[];for(let e of r){if(a.has(e))continue;if(e===qi||e===Ji){s.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);o.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&s.push(e)}return[...i,...s]}function ta(e,t){let n=[];for(let r of t){let t=F(e,r);if(R(t))try{Fe(`git`,[`ls-files`,`--error-unmatch`,...o([r])],Ce({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}const na=/^[\w.\-/]+$/;function ra(e){return process.platform===`win32`?`"${e.replaceAll(`"`,``)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`}function ia(e){return na.test(e)?e:ra(h(e))}function aa(e){let t=[];t.push(`Cannot switch OpenKnowledge to local-only — these OK files are tracked upstream:`),t.push(``);for(let n of e)t.push(` ${n}`);t.push(``),t.push(`.git/info/exclude only hides files that git isn't already tracking. To proceed, untrack them first:`),t.push(``);for(let n of e){let e=n.replace(/\/$/,``),r=n.endsWith(`/`)?`-r `:``;t.push(` git rm --cached ${r}-- ${ia(e)}`)}return t.push(``),t.push("Then re-run the command. Note: `git rm --cached` removes the files from the index — your teammates will see a deletion on their next pull. If you don't want that, leave sharing mode set to 'shared'."),t.join(`
325
+ `)}function oa(e){let t=Se(e);switch(t.kind){case`repository`:{let e=t.repository.readCommonDir();if(e.kind===`unreadable`)return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}};let n=N(e.path,`info`);return R(n)?{kind:`ok`,path:N(n,`exclude`)}:{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-info-dir`}}}case`absent`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-git`}};case`malformed-pointer`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`malformed-pointer`}};case`inaccessible`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}}}}function sa(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function ca(e,t){for(let n of sa(t))if(e.has(n))return!0;return!1}function la(e){let t=new Set;for(let n of e.split(`
326
+ `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function ua(e,t){return da(P(t,e))}function da(e){return I===`/`?e:e.split(I).join(`/`)}var fa=class extends Error{name=`ProjectPathSafetyError`;code=`PROJECT_PATH_SAFETY`};function pa(e,t){let n;try{n=Ue(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw new fa(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);ha(e,t)}function ma(e,t){ha(e,t)}function ha(e,t){ga(e,t)}function ga(e,t){let n=t,r;try{r=qe(n)}catch{r=F(n)}let i=M(e);for(;i.length>1&&i!==I;){let t;try{t=qe(i)}catch(e){if(e.code===`ENOENT`){i=M(i);continue}throw e}let n=P(r,t);if(n===``||!n.startsWith(`..`)&&!Re(n))return;throw new fa(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function _a(e,t){let n=M(t),r=R(t)?`overwritten`:`written`;if(r===`written`&&R(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return Je(n,{recursive:!0,force:!0}),We(M(n),{recursive:!0}),He(e,n,{recursive:!0}),r}function va(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ya(e,t,n){try{if(Ye(n).size>10485760)return!1}catch{return!1}let r;try{r=z(n,`utf-8`)}catch{return!1}let i=[],a=ae(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!va(a))return!1;let o=a[e.topLevelKey];if(!va(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!va(s))return!1;let c=s[e.serverName(t)];return va(c)&&c.enabled===!1?!1:bi(c)||xi(c)}function ba(e){let t=g[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:l(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:$[n.editor]??null}function xa(e,t,n={}){if(!S.includes(e.id))return!0;let r=ba(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&ya(r,t,i))return!0;try{return ya(e,t,e.configPath(t,n.home))}catch{return!1}}function Sa(e){let t=new Set(b.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function Ca(e,t){if(Sa(t).length===0)return null;let n=N(e,c,_,`SKILL.md`);try{let t=we(`project`,{checkDesktop:!0});return pa(M(n),e),{editorId:`agents`,label:`.agents hub`,action:_a(t,n),path:n}}catch(e){return{editorId:`agents`,label:`.agents hub`,action:`failed`,path:n,error:e instanceof Error?e.message:String(e)}}}function wa(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!xa(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=we(`project`,{checkDesktop:!0});pa(M(r),t);let i=_a(n,r);return{editorId:e.id,label:e.label,action:i,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function Ta(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=M(n);return R(n)?(ma(r,t),Je(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function Ea(e){switch(e?.code){case`EACCES`:case`EPERM`:return`permission-denied`;case`ELOOP`:return`unresolved-symlink`;case`EISDIR`:case`ENOTDIR`:return`not-a-file`;case`ENOENT`:return`disappeared`;default:return`unreadable`}}function Da(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions, then retry`;case`missing-symlink-target`:return`the symlink target is missing; restore the target or correct the symlink, then retry`;case`unresolved-symlink`:return`the path or symlink could not be resolved; check path permissions and repair any symlink cycle, then retry`;case`not-a-file`:return`the path is not a regular file; restore the intended configuration file, then retry`;case`disappeared`:return`the file disappeared; retry to check its current state`;case`unreadable`:return`the file could not be read; check that the path is accessible, then retry`;default:throw Error(`unhandled configuration file decline reason: ${e}`)}}function Oa(e){for(let t of e.split(`
327
327
  `)){let e=t.trimStart();if(e.length!==0&&e.length!==t.length)return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function ka(e){let t=(e.match(/\r\n/g)??[]).length;return t!==0&&t>=(e.match(/\n/g)??[]).length-t}function Aa(e){try{return Ye(e).mode&511}catch{return}}function ja(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
328
328
  `)?`\r
329
329
  `:`
330
- `,a=fe(r,t,void 0,{formattingOptions:{...Oa(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${w(r,a)}`;return{text:o,changed:o!==e}}const Ma={icon:{checked:V(`green`,W.circleFilled),unchecked:W.circle,cursor:W.pointer,disabledChecked:V(`green`,W.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>V(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>V(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${V(`bold`,e)} ${V(`dim`,t)}`).join(V(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`}};function Na(e){return!K.isSeparator(e)&&!e.disabled}function Pa(e){return!K.isSeparator(e)}function Fa(e){return!K.isSeparator(e)&&e.checked}function Ia(e){return Na(e)?{...e,checked:!e.checked}:e}function La(e){return function(t){return Na(t)?{...t,checked:e}:t}}function Ra(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,checkedName:t,disabled:!1,checked:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,checkedName:e.checkedName??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(n.description=e.description),n})}var za=ar((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=$t(Ma,e.theme),{keybindings:c}=s,[l,u]=U(`idle`),d=en({status:l,theme:s}),[f,p]=U(Ra(e.choices)),m=tn(()=>{let e=f.findIndex(Pa),t=f.findLastIndex(Pa);if(e===-1)throw new Mt(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=U(m.first),[_,v]=U();rn(async e=>{if(Dt(e)){let e=f.filter(Fa),n=await a([...e]);i&&!e.length?v(`At least one choice must be selected`):n===!0?(u(`done`),t(e.map(e=>e.value))):v(n||`You must select a valid value`)}else if(St(e,c)||Ct(e,c)){if(_&&v(void 0),r||St(e,c)&&h!==m.first||Ct(e,c)&&h!==m.last){let t=St(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Pa(f[n]));g(n)}}else if(wt(e)){let e=f[h];e&&!K.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?Ia(e):e))))}else if(e.name===o.all){let e=f.some(e=>Na(e)&&!e.checked);p(f.map(La(e)))}else if(e.name===o.invert)p(f.map(Ia));else if(Et(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>!K.isSeparator(e)&&(n++,n===t)),i=f[r];i&&Na(i)&&(g(r),p(f.map((e,t)=>t===r?Ia(e):e)))}});let y=s.style.message(e.message,l),b,x=Mn({items:f,active:h,renderItem({item:e,isActive:t}){if(K.isSeparator(e))return` ${e.separator}`;let n=t?s.icon.cursor:` `;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=e.checked?s.icon.disabledChecked:s.icon.disabledUnchecked;return s.style.disabled(`${n}${r} ${e.name} ${t}`)}t&&(b=e.description);let r=e.checked?s.icon.checked:s.icon.unchecked,i=e.checked?e.checkedName:e.name;return(t?s.style.highlight:e=>e)(`${n}${r} ${i}`)},pageSize:n,loop:r});if(l===`done`){let e=f.filter(Fa);return[d,y,s.style.answer(s.style.renderSelectedChoices(e,f))].filter(Boolean).join(` `)}let S=[[`↑↓`,`navigate`],[`space`,`select`]];o.all&&S.push([o.all,`all`]),o.invert&&S.push([o.invert,`invert`]),S.push([`⏎`,`submit`]);let C=s.style.keysHelpTip(S);return`${[[d,y].filter(Boolean).join(` `),x,` `,b?s.style.description(b):``,_?s.style.error(_):``,C].filter(Boolean).join(`
331
- `).trimEnd()}${Jn}`});const Ba={icon:{cursor:W.pointer},style:{disabled:e=>V(`dim`,e),description:e=>V(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${V(`bold`,e)} ${V(`dim`,t)}`).join(V(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be selected.`},indexMode:`hidden`};function Va(e){return!K.isSeparator(e)&&!e.disabled}function Ha(e){return!K.isSeparator(e)}function Ua(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,disabled:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(n.description=e.description),n})}var Wa=ar((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=$t(Ba,e.theme),{keybindings:a}=i,[o,s]=U(`idle`),c=en({status:o,theme:i}),l=nn(),u=!a.includes(`vim`),d=tn(()=>Ua(e.choices),[e.choices]),f=tn(()=>{let e=d.findIndex(Ha),t=d.findLastIndex(Ha);if(e===-1)throw new Mt(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=tn(()=>`default`in e?d.findIndex(t=>Va(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=U(p===-1?f.first:p),g=d[m];if(g==null||K.isSeparator(g))throw Error(`Active index does not point to a choice`);let[_,v]=U();rn((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Dt(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(St(e,a)||Ct(e,a)){if(r.clearLine(0),n||St(e,a)&&m!==f.first||Ct(e,a)&&m!==f.last){let t=St(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!Ha(d[n]));h(n)}}else if(Et(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>!K.isSeparator(n)&&(t++,t===e)),i=d[n];i!=null&&Va(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(Tt(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>K.isSeparator(t)||!Va(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),Ht(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Mn({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(K.isSeparator(e))return x++,` ${e.separator}`;let r=t?i.icon.cursor:` `,a=i.indexMode===`number`?`${n+1-x}. `:``;if(e.disabled){let n=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=t?i.icon.cursor:`-`;return i.style.disabled(`${r} ${a}${e.name} ${n}`)}return(t?i.style.highlight:e=>e)(`${r} ${a}${e.name}`)},pageSize:r,loop:n});if(o===`done`)return[c,y,i.style.answer(g.short)].filter(Boolean).join(` `);let{description:C}=g;return`${[[c,y].filter(Boolean).join(` `),S,` `,C?i.style.description(C):``,_?i.style.error(_):``,b].filter(Boolean).join(`
332
- `).trimEnd()}${Jn}`});function Ga(e){let t=oi(C());return e.startsWith(t)?Object.values(v).map(oi).every(n=>n.length<=t.length||!e.startsWith(n)):!1}function Ka(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command!==`ok-pi-managed-extension`||!Array.isArray(t.args))return!1;let n=t.args[0];return typeof n==`string`&&Ga(n)}function qa(e){return{command:`ok-pi-managed-extension`,args:[e]}}function Ja(e={}){let t=e.mode===`dev`,n=C(),r=t?`${oi(n)}-dev`:si(n),i=`${y(n)}_`,a={unix:Z({...e,platformName:`darwin`}),win32:Z({...e,platformName:`win32`})};return`${r}
330
+ `,a=fe(r,t,void 0,{formattingOptions:{...Oa(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${w(r,a)}`;return{text:o,changed:o!==e}}const Ma={icon:{checked:V(`green`,W.circleFilled),unchecked:W.circle,cursor:W.pointer,disabledChecked:V(`green`,W.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>V(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>V(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${V(`bold`,e)} ${V(`dim`,t)}`).join(V(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`}};function Na(e){return!K.isSeparator(e)&&!e.disabled}function Pa(e){return!K.isSeparator(e)}function Fa(e){return!K.isSeparator(e)&&e.checked}function Ia(e){return Na(e)?{...e,checked:!e.checked}:e}function La(e){return function(t){return Na(t)?{...t,checked:e}:t}}function Ra(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,checkedName:t,disabled:!1,checked:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,checkedName:e.checkedName??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(n.description=e.description),n})}var za=ar((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=$t(Ma,e.theme),{keybindings:c}=s,[l,u]=U(`idle`),d=en({status:l,theme:s}),[f,p]=U(Ra(e.choices)),m=tn(()=>{let e=f.findIndex(Pa),t=f.findLastIndex(Pa);if(e===-1)throw new Mt(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=U(m.first),[_,v]=U();rn(async e=>{if(Dt(e)){let e=f.filter(Fa),n=await a([...e]);i&&!e.length?v(`At least one choice must be selected`):n===!0?(u(`done`),t(e.map(e=>e.value))):v(n||`You must select a valid value`)}else if(St(e,c)||Ct(e,c)){if(_&&v(void 0),r||St(e,c)&&h!==m.first||Ct(e,c)&&h!==m.last){let t=St(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Pa(f[n]));g(n)}}else if(wt(e)){let e=f[h];e&&!K.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?Ia(e):e))))}else if(e.name===o.all){let e=f.some(e=>Na(e)&&!e.checked);p(f.map(La(e)))}else if(e.name===o.invert)p(f.map(Ia));else if(Et(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>!K.isSeparator(e)&&(n++,n===t)),i=f[r];i&&Na(i)&&(g(r),p(f.map((e,t)=>t===r?Ia(e):e)))}});let y=s.style.message(e.message,l),b,x=Mn({items:f,active:h,renderItem({item:e,isActive:t}){if(K.isSeparator(e))return` ${e.separator}`;let n=t?s.icon.cursor:` `;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=e.checked?s.icon.disabledChecked:s.icon.disabledUnchecked;return s.style.disabled(`${n}${r} ${e.name} ${t}`)}t&&(b=e.description);let r=e.checked?s.icon.checked:s.icon.unchecked,i=e.checked?e.checkedName:e.name;return(t?s.style.highlight:e=>e)(`${n}${r} ${i}`)},pageSize:n,loop:r});if(l===`done`){let e=f.filter(Fa);return[d,y,s.style.answer(s.style.renderSelectedChoices(e,f))].filter(Boolean).join(` `)}let S=[[`↑↓`,`navigate`],[`space`,`select`]];o.all&&S.push([o.all,`all`]),o.invert&&S.push([o.invert,`invert`]),S.push([`⏎`,`submit`]);let ee=s.style.keysHelpTip(S);return`${[[d,y].filter(Boolean).join(` `),x,` `,b?s.style.description(b):``,_?s.style.error(_):``,ee].filter(Boolean).join(`
331
+ `).trimEnd()}${Jn}`});const Ba={icon:{cursor:W.pointer},style:{disabled:e=>V(`dim`,e),description:e=>V(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${V(`bold`,e)} ${V(`dim`,t)}`).join(V(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be selected.`},indexMode:`hidden`};function Va(e){return!K.isSeparator(e)&&!e.disabled}function Ha(e){return!K.isSeparator(e)}function Ua(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,disabled:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(n.description=e.description),n})}var Wa=ar((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=$t(Ba,e.theme),{keybindings:a}=i,[o,s]=U(`idle`),c=en({status:o,theme:i}),l=nn(),u=!a.includes(`vim`),d=tn(()=>Ua(e.choices),[e.choices]),f=tn(()=>{let e=d.findIndex(Ha),t=d.findLastIndex(Ha);if(e===-1)throw new Mt(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=tn(()=>`default`in e?d.findIndex(t=>Va(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=U(p===-1?f.first:p),g=d[m];if(g==null||K.isSeparator(g))throw Error(`Active index does not point to a choice`);let[_,v]=U();rn((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Dt(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(St(e,a)||Ct(e,a)){if(r.clearLine(0),n||St(e,a)&&m!==f.first||Ct(e,a)&&m!==f.last){let t=St(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!Ha(d[n]));h(n)}}else if(Et(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>!K.isSeparator(n)&&(t++,t===e)),i=d[n];i!=null&&Va(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(Tt(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>K.isSeparator(t)||!Va(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),Ht(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Mn({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(K.isSeparator(e))return x++,` ${e.separator}`;let r=t?i.icon.cursor:` `,a=i.indexMode===`number`?`${n+1-x}. `:``;if(e.disabled){let n=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=t?i.icon.cursor:`-`;return i.style.disabled(`${r} ${a}${e.name} ${n}`)}return(t?i.style.highlight:e=>e)(`${r} ${a}${e.name}`)},pageSize:r,loop:n});if(o===`done`)return[c,y,i.style.answer(g.short)].filter(Boolean).join(` `);let{description:ee}=g;return`${[[c,y].filter(Boolean).join(` `),S,` `,ee?i.style.description(ee):``,_?i.style.error(_):``,b].filter(Boolean).join(`
332
+ `).trimEnd()}${Jn}`});function Ga(e){let t=oi(r());return e.startsWith(t)?Object.values(f).map(oi).every(n=>n.length<=t.length||!e.startsWith(n)):!1}function Ka(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command!==`ok-pi-managed-extension`||!Array.isArray(t.args))return!1;let n=t.args[0];return typeof n==`string`&&Ga(n)}function qa(e){return{command:`ok-pi-managed-extension`,args:[e]}}function Ja(e={}){let t=e.mode===`dev`,n=r(),i=t?`${oi(n)}-dev`:si(n),a=`${ne(n)}_`,o={unix:Z({...e,platformName:`darwin`}),win32:Z({...e,platformName:`win32`})};return`${i}
333
333
  /**
334
334
  * Open Knowledge bridge for Pi — MANAGED FILE, written by \`ok init\`.
335
335
  * Hand edits are overwritten whenever OK re-syncs this project; remove it
@@ -338,15 +338,15 @@ exit 127`}ni(v.stable),ii(`stable`),ri(v.stable),ai(`stable`);function oi(e){ret
338
338
  * On session start it spawns Open Knowledge's MCP stdio server via OK's
339
339
  * resilient launcher (bundle, then npx, then version-manager probes), performs
340
340
  * the MCP handshake, and registers each MCP tool as a Pi tool under an
341
- * \`${i}\` prefix (Pi has no MCP namespacing; the prefix keeps OK's \`edit\` /
341
+ * \`${a}\` prefix (Pi has no MCP namespacing; the prefix keeps OK's \`edit\` /
342
342
  * \`write\` from shadowing Pi's built-in tools).
343
343
  */
344
344
  import { spawn } from "node:child_process";
345
345
  import type { ChildProcessWithoutNullStreams } from "node:child_process";
346
346
 
347
- const LAUNCHERS = ${JSON.stringify(a,null,2)} as const;
347
+ const LAUNCHERS = ${JSON.stringify(o,null,2)} as const;
348
348
 
349
- const TOOL_PREFIX = ${JSON.stringify(i)};
349
+ const TOOL_PREFIX = ${JSON.stringify(a)};
350
350
  // First contact may cold-install the CLI through npx — allow a generous window.
351
351
  const INIT_TIMEOUT_MS = 120000;
352
352
  const STDERR_TAIL_LIMIT = 2000;
@@ -672,7 +672,7 @@ export default function okBridge(pi: {
672
672
  }
673
673
  });
674
674
  }
675
- `}function Ya(e,t){let n=P(Oe(t),Oe(e));return n.length>0&&!n.startsWith(`..`)&&!Re(n)}const Xa=e=>{try{let t=Fe(`git`,[`rev-parse`,`--show-toplevel`],Se({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function Za(e,t={}){let n=t.homeDir??B(),r=t.gitTopLevel??Xa,i=F(e),a;try{a=qe(i)}catch{a=i}let o=a,s=0;for(;s<30&&o!==n&&o!==`/`&&o!==``;){if(ve(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=M(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&Ya(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function Qa(){let e=Vr();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function $a(e){let t=e,n=new Set;for(;;){let r;try{r=Ue(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=Ke(t)}catch(t){return Y(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=Re(i)?i:N(M(t),i)}}let eo;function to(){return eo===void 0&&(eo=Qa()),eo}function no(e,t=to){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){Y(`resolveSymlinkWritePath threw`,e)}return $a(e)}const ro={allowTrailingComma:!0,disallowComments:!1};function io(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function ao(e){let t=[],n=ce(e,t,ro);return t.some(t=>!io(t,e))||n?.type!==`object`?null:n}function oo(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&de(e)===t&&(n+=1)}return n}function so(e,t){T(e,`${JSON.stringify(t,null,2)}\n`)}function co(e,t){let n=Fr(t);T(e,n.endsWith(`
675
+ `}function Ya(e,t){let n=P(Oe(t),Oe(e));return n.length>0&&!n.startsWith(`..`)&&!Re(n)}const Xa=e=>{try{let t=Fe(`git`,[`rev-parse`,`--show-toplevel`],Ce({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function Za(e,t={}){let n=t.homeDir??B(),r=t.gitTopLevel??Xa,i=F(e),a;try{a=qe(i)}catch{a=i}let o=a,s=0;for(;s<30&&o!==n&&o!==`/`&&o!==``;){if(ve(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=M(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&Ya(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function Qa(){let e=Vr();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function $a(e){let t=e,n=new Set;for(;;){let r;try{r=Ue(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=Ke(t)}catch(t){return Y(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=Re(i)?i:N(M(t),i)}}let eo;function to(){return eo===void 0&&(eo=Qa()),eo}function no(e,t=to){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){Y(`resolveSymlinkWritePath threw`,e)}return $a(e)}const ro={allowTrailingComma:!0,disallowComments:!1};function io(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function ao(e){let t=[],n=se(e,t,ro);return t.some(t=>!io(t,e))||n?.type!==`object`?null:n}function oo(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&de(e)===t&&(n+=1)}return n}function so(e,t){T(e,`${JSON.stringify(t,null,2)}\n`)}function co(e,t){let n=Fr(t);T(e,n.endsWith(`
676
676
  `)?n:`${n}\n`)}function lo(e,t){let n=(0,Ir.stringify)(t);T(e,n.endsWith(`
677
677
  `)?n:`${n}\n`)}const uo=10485760;function fo(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>fo(e,t[n]));if(j(e)&&j(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&fo(e[n],t[n]))}return!1}function po(e,t,n){return j(e)&&n.every(n=>fo(e[n],t[n]))}function mo(e){for(let t of e.split(`
678
678
  `)){let e=t.trimStart();if(e.length!==0&&e.length!==t.length)return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function ho(e,t,n){return t===void 0?[e,n]:[e,t,n]}function go(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function _o(e,t,n){let r=e[t];return n===void 0?r:j(r)?r[n]:void 0}function vo(e,t,n,r,i,a=!1,o=!1){if(!R(e))return o?{kind:`unchanged`}:(so(e,go(t,i,n,r)),{kind:`written`});let s;try{s=z(e,`utf-8`)}catch(e){return Y(`json config read failed`,e),{kind:`declined`,reason:Ea(e)}}if(s.trim()===``)return o?{kind:`unchanged`}:(so(e,go(t,i,n,r)),{kind:`written`});if(Buffer.byteLength(s,`utf-8`)>uo)return{kind:`declined`,reason:`oversize`};let c=ao(s);if(!c)return{kind:`declined`,reason:`unparseable`};if(oo(c,t)>1)return{kind:`declined`,reason:`duplicate-container`};let l=_o(de(c),t,i),u=j(l)?l[n]:void 0,d=u!==void 0,f=wi(r);if(d&&a?di(u):d&&po(u,r,f))return{kind:o?`unchanged`:`overwritten`};let p=s.charCodeAt(0)===65279,m=p?s.slice(1):s,h=m.includes(`\r
@@ -687,7 +687,7 @@ export default function okBridge(pi: {
687
687
  `)||(m=`${m}\n`):m=m.replace(/\n+$/,``),h&&(m=m.replace(/\r\n/g,`
688
688
  `).replace(/\n/g,`\r
689
689
  `));let g=`${s?``:``}${m}`;return g!==o&&T(e,g,{mode:Aa(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const Co=e=>e!==`project`,wo=e=>e!==`user`;async function To(){let e=await za({message:`Where should the MCP server be configured?
690
- `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Eo(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??To)():`both`}async function Do(e){return Wa({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function Oo(e){if(e.sharing!==void 0)return e.sharing;let t=$i(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Do)(t):t}var ko=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Ao(e){if(e===void 0||e===!0)return new Set(De);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(ge.filter(e=>t.includes(e)))}function jo(e,t,n){let r=F(n,e),i;try{i=Ye(r)}catch(e){let t=e.code;throw t===`ENOENT`?new ko(`--content-dir path does not exist: ${r}`):new ko(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new ko(`--content-dir must be a directory: ${r}`);let a=Mo(t),o=Mo(r),s=P(a,o);if(s.startsWith(`..`)||Re(s))throw new ko(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Mo(e){try{return qe(e)}catch{return e}}const No=`open-knowledge-ui`;function Po(e,t,n){try{let r=e.detectPath?.(t,n)??M(e.configPath(t,n));return R(r)}catch{return!1}}function Fo(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+I)}catch{return!1}}function Io(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!R(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||Fo(e,t,r);if(!i&&c&&!Po(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{pa(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return Ro(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||We(M(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{Ee(`${o}.lock`,()=>{let t=no(o).writePath;if(s||We(M(t),{recursive:!0}),e.format===`toml`){let r=yo(Yr(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=So(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=vo(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Lo={pi:Ja};function Ro(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Lo[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{We(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{Ee(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Aa(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function zo(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function Bo(e){let t=Ki(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>Io(t,``,n,e.home))}function Vo(e,t,n,r){let i=Uo(e,t,n,r);return i.kind===`present`?i.entry:null}function Ho(e,t,n,r){let i=_o(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Uo(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};try{if(Ye(i).size>uo)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ea(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ea(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:qa(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Yr().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Ho(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Ir.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Ho(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=ao(a);return s?oo(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Ho(de(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Wo(e={}){let t=F(e.cwd??process.cwd()),n=Za(t,{homeDir:e.home}),r=n.projectRoot;if(me(r,e.home??B()))throw new se(r);let i=!R(N(r,`.ok`)),a=n.gitRootPromoted?P(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:jo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${k(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},c=await le(r),l;try{l=he(r,{contentDir:o})}catch(t){let i=$.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:c.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let u=l.created.includes(Me),d=!1;if(c.didInit)try{d=ke(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{ie(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let f=await Eo({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),p=e.editors??Xo(r,e.home),m=e.editors??p,h=Ki(p),g=Ki(m),_=e.mcp===!1||f===null,v=Array.from(new Map([...h,..._?[]:g].map(e=>[e.id,e])).values()),y=h.filter(t=>Po(t,r,e.home)),b=[],S=[],C=new Set;for(let t of v){if(_){let n=``;try{n=t.configPath(r,e.home)}catch{}b.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Co(f)&&h.includes(t)&&t.scope===`global`&&b.push(Io(t,r,s,e.home)),wo(f)&&g.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Io(t,r,s,e.home,n);b.push(i),(i.action===`written`||i.action===`overwritten`)&&C.add(n)}}let ee=new Set;for(let t of g){let n=t.projectSkillPath?.(r);!n||ee.has(n)||(ee.add(n),S.push(wa(t,r,{home:e.home})))}let te=Ca(r,g.map(e=>e.id));te&&S.push(te);let ne=S.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(ne.length>0){let t=e.home??B();xe({source:x,skills:[Te.project],agents:ne,scope:r},{home:t,enabled:ye(t).enabled})}let re=!_&&f!==null&&wo(f)?g.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ae=_?[]:y.map(e=>zo(e,r)).filter(e=>e!==void 0).filter(e=>!C.has(e.path)),oe=e.installUserSkill??we,ce=e.home??B(),ue=Ao(e.skills),w=!1,de=!1,fe=!1,pe=!1,T=!1;for(let t of ge){if(!ue.has(t))continue;await Ae(ce,Te[t],!0).catch(()=>{}),w=!0;let n=await oe({home:e.home,bundleId:t,force:!0});n===`installed`?de=!0:n===`failed`?fe=!0:n===`no-hosts`?T=!0:pe=!0}let ve=fe?`failed`:de?`installed`:w&&pe?`skip-current`:w&&T?`no-hosts`:`declined`,be=de?_e(ce).map(e=>e.editorId):[],Se=_?`skipped-flag`:`skipped-missing`,Ce=b.find(e=>e.editorId===`claude`)??b[0]??{action:Se,configPath:$.claude.configPath(r,e.home)},Ee=await Go({projectRoot:r,desiredMode:await Oo({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:l.created,contentUpdated:l.updated,contentSkipped:l.skipped,editors:b,projectSkills:S,legacyProjectConfigs:ae,skillInstall:ve,skillHosts:be,didGitInit:c.didInit,rootGitignoreCreated:d,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:u?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Ce.action,mcpPath:Ce.configPath,mcpError:`error`in Ce?Ce.error:void 0,projectScopeUnsupportedLabels:re,sharing:Ee}}async function Go(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=$i(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=Yi(t);if(n===`local-only`){let e=Zi(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:Ko(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Qi(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Ko(t,o,`remove`)}function Ko(e,t,n){let r=$i(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function qo(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function Jo(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let s=N(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(A(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(A(`Content already present at ${s}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(A(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(A(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(A(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?P(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===h()?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${O(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${O(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${je(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${qo(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(A(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?P(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${je(`FAILED`)}: ${r.error}`)}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${P(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(A(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>X[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${O(`installed for ${r}`)}`),n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${O(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${D(`skipped for this run (--no-skills)`)}`),n.push(` ${D(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${k(` ok repair-skills`)}`)}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(k(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(k(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(Ne(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...$o(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${E(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${E(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${E(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
691
- `)}function Yo(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function Xo(e,t){let n=[];for(let r of Zr)r!==`claude-desktop`&&Po($[r],e,t)&&n.push(r);return n}function Zo(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Ze(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Qo(){return new ht(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new _t(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new _t(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new _t(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?Zo():null;try{let r;try{r=await Wo({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof ko||e instanceof se){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof ue||e instanceof pe){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof be){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
692
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-Csbf4Lbe.mjs`),{resolveContentDir:s}=await import(`./dist-Bkhn2suz.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-DqQqCrui.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Yo(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Jo(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function $o(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
690
+ `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Eo(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??To)():`both`}async function Do(e){return Wa({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function Oo(e){if(e.sharing!==void 0)return e.sharing;let t=$i(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Do)(t):t}var ko=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Ao(e){if(e===void 0||e===!0)return new Set(De);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(ge.filter(e=>t.includes(e)))}function jo(e,t,n){let r=F(n,e),i;try{i=Ye(r)}catch(e){let t=e.code;throw t===`ENOENT`?new ko(`--content-dir path does not exist: ${r}`):new ko(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new ko(`--content-dir must be a directory: ${r}`);let a=Mo(t),o=Mo(r),s=P(a,o);if(s.startsWith(`..`)||Re(s))throw new ko(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Mo(e){try{return qe(e)}catch{return e}}const No=`open-knowledge-ui`;function Po(e,t,n){try{let r=e.detectPath?.(t,n)??M(e.configPath(t,n));return R(r)}catch{return!1}}function Fo(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+I)}catch{return!1}}function Io(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!R(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||Fo(e,t,r);if(!i&&c&&!Po(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{pa(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return Ro(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||We(M(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{le(`${o}.lock`,()=>{let t=no(o).writePath;if(s||We(M(t),{recursive:!0}),e.format===`toml`){let r=yo(Yr(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=So(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=vo(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Lo={pi:Ja};function Ro(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Lo[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{We(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{le(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Aa(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function zo(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function Bo(e){let t=Ki(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>Io(t,``,n,e.home))}function Vo(e,t,n,r){let i=Uo(e,t,n,r);return i.kind===`present`?i.entry:null}function Ho(e,t,n,r){let i=_o(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Uo(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};try{if(Ye(i).size>uo)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ea(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ea(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:qa(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Yr().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Ho(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Ir.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Ho(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=ao(a);return s?oo(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Ho(de(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Wo(e={}){let t=F(e.cwd??process.cwd()),n=Za(t,{homeDir:e.home}),r=n.projectRoot;if(me(r,e.home??B()))throw new oe(r);let i=!R(N(r,`.ok`)),a=n.gitRootPromoted?P(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:jo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${k(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},c=await ce(r),l;try{l=he(r,{contentDir:o})}catch(t){let i=$.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:c.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let u=l.created.includes(Me),d=!1;if(c.didInit)try{d=ke(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{ie(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let f=await Eo({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),p=e.editors??Xo(r,e.home),m=e.editors??p,h=Ki(p),g=Ki(m),_=e.mcp===!1||f===null,v=Array.from(new Map([...h,..._?[]:g].map(e=>[e.id,e])).values()),y=h.filter(t=>Po(t,r,e.home)),b=[],x=[],S=new Set;for(let t of v){if(_){let n=``;try{n=t.configPath(r,e.home)}catch{}b.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Co(f)&&h.includes(t)&&t.scope===`global`&&b.push(Io(t,r,s,e.home)),wo(f)&&g.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Io(t,r,s,e.home,n);b.push(i),(i.action===`written`||i.action===`overwritten`)&&S.add(n)}}let ee=new Set;for(let t of g){let n=t.projectSkillPath?.(r);!n||ee.has(n)||(ee.add(n),x.push(wa(t,r,{home:e.home})))}let ne=Ca(r,g.map(e=>e.id));ne&&x.push(ne);let C=x.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(C.length>0){let t=e.home??B();xe({source:te,skills:[Ee.project],agents:C,scope:r},{home:t,enabled:ye(t).enabled})}let re=!_&&f!==null&&wo(f)?g.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ae=_?[]:y.map(e=>zo(e,r)).filter(e=>e!==void 0).filter(e=>!S.has(e.path)),se=e.installUserSkill??Te,le=e.home??B(),ue=Ao(e.skills),w=!1,de=!1,fe=!1,pe=!1,T=!1;for(let t of ge){if(!ue.has(t))continue;await Ae(le,Ee[t],!0).catch(()=>{}),w=!0;let n=await se({home:e.home,bundleId:t,force:!0});n===`installed`?de=!0:n===`failed`?fe=!0:n===`no-hosts`?T=!0:pe=!0}let ve=fe?`failed`:de?`installed`:w&&pe?`skip-current`:w&&T?`no-hosts`:`declined`,be=de?_e(le).map(e=>e.editorId):[],Se=_?`skipped-flag`:`skipped-missing`,Ce=b.find(e=>e.editorId===`claude`)??b[0]??{action:Se,configPath:$.claude.configPath(r,e.home)},we=await Go({projectRoot:r,desiredMode:await Oo({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:l.created,contentUpdated:l.updated,contentSkipped:l.skipped,editors:b,projectSkills:x,legacyProjectConfigs:ae,skillInstall:ve,skillHosts:be,didGitInit:c.didInit,rootGitignoreCreated:d,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:u?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Ce.action,mcpPath:Ce.configPath,mcpError:`error`in Ce?Ce.error:void 0,projectScopeUnsupportedLabels:re,sharing:we}}async function Go(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=$i(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=Yi(t);if(n===`local-only`){let e=Zi(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:Ko(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Qi(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Ko(t,o,`remove`)}function Ko(e,t,n){let r=$i(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function qo(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function Jo(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let s=N(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(A(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(A(`Content already present at ${s}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(A(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(A(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(A(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?P(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===C()?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${O(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${O(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${je(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${qo(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(A(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?P(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${je(`FAILED`)}: ${r.error}`)}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${P(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(A(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>X[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${O(`installed for ${r}`)}`),n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${O(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${D(`skipped for this run (--no-skills)`)}`),n.push(` ${D(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${k(` ok repair-skills`)}`)}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(k(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(k(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(Ne(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...$o(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${E(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${E(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${E(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
691
+ `)}function Yo(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function Xo(e,t){let n=[];for(let r of Zr)r!==`claude-desktop`&&Po($[r],e,t)&&n.push(r);return n}function Zo(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Ze(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Qo(){return new ht(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new _t(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new _t(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new _t(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?Zo():null;try{let r;try{r=await Wo({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof ko||e instanceof oe){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof ue||e instanceof pe){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof be){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
692
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-CDBcy7_5.mjs`),{resolveContentDir:s}=await import(`./dist-BBi7mVvL.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-rGoADBsd.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Yo(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Jo(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function $o(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
693
693
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${E(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(k(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${E(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${E(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(k(`Sharing mode unavailable: ${e.reason}.`));return n}}export{Ei as $,ja as A,Zi as B,Za as C,ht as Ct,za as D,Wa as E,pa as F,ta as G,ea as H,ma as I,Zr as J,$i as K,Ta as L,Ea as M,fa as N,Aa as O,ga as P,Z as Q,_a as R,no as S,Dt as St,Ka as T,_t as Tt,Xi as U,aa as V,Yi as W,$ as X,X as Y,Qr as Z,Wo as _,Jn as _t,Yo as a,ki as at,Bo as b,$t as bt,Jo as c,Vi as ct,Po as d,Yr as dt,Ti as et,Vo as f,Y as ft,Oo as g,ar as gt,jo as h,Vr as ht,Go as i,di as it,Da as j,ka as k,$o as l,hi as lt,Eo as m,Rr as mt,No as n,Oi as nt,Uo as o,Q as ot,Ao as p,zr as pt,Qi as q,Lo as r,ci as rt,Xo as s,Ai as st,ko as t,Di as tt,Qo as u,Xr as ut,ho as v,rn as vt,Ja as w,pt as wt,Fo as x,U as xt,Io as y,en as yt,wa as z};
@@ -0,0 +1 @@
1
+ import"./dist-GcFBLEr5.mjs";import{_ as e}from"./init-BR_RY0pY.mjs";export{e as runInit};
@@ -1,4 +1,4 @@
1
- import"./chunk-R6VWJ2ZL-Cu1kOJ3f.mjs";import"./chunk-CWQS3NFK-Dma10iZG.mjs";import"./chunk-DXB73IDG-MLBj3lvC.mjs";import{t as e}from"./chunk-5QMZ5MUS-B37CnsNb.mjs";import{n as t,t as n}from"./chunk-A5O5YHGN-2_dxLAd1.mjs";import{n as r}from"./chunk-OJDRYQWQ-DOhqJ55-.mjs";import{n as i,t as a}from"./chunk-3THT3N7L-DVKHLRUO.mjs";import{t as o}from"./chunk-44UOCSGV-CeGMLWmo.mjs";import{t as s}from"./chunk-74CEPOFO-BuzahJu2.mjs";import{n as c,t as l}from"./chunk-I57KEIP3-CtKTv_KT.mjs";import{randomBytes as u}from"node:crypto";import{fileURLToPath as d}from"node:url";import{Worker as f}from"node:worker_threads";import{AsyncLocalStorage as p}from"node:async_hooks";var m=1e4,h=6e4,g=new p,_=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
1
+ import"./chunk-R6VWJ2ZL-Cu1kOJ3f.mjs";import"./chunk-CWQS3NFK-Dma10iZG.mjs";import"./chunk-DXB73IDG-MLBj3lvC.mjs";import{t as e}from"./chunk-5QMZ5MUS-B37CnsNb.mjs";import{n as t,t as n}from"./chunk-A5O5YHGN-2_dxLAd1.mjs";import{n as r}from"./chunk-OJDRYQWQ-DOhqJ55-.mjs";import{n as i,t as a}from"./chunk-3THT3N7L-DVKHLRUO.mjs";import{t as o}from"./chunk-44UOCSGV-CeGMLWmo.mjs";import{t as s}from"./chunk-74CEPOFO-BuzahJu2.mjs";import{n as c,t as l}from"./chunk-I57KEIP3-CtKTv_KT.mjs";import{fileURLToPath as u}from"node:url";import{randomBytes as d}from"node:crypto";import{Worker as f}from"node:worker_threads";import{AsyncLocalStorage as p}from"node:async_hooks";var m=1e4,h=6e4,g=new p,_=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
2
2
 
3
3
  Usage: js-exec [OPTIONS] [-c CODE | FILE] [ARGS...]
4
4
 
@@ -85,8 +85,8 @@ Limits:
85
85
  Engine: QuickJS (compiled to WebAssembly)
86
86
  `;function v(e){let t={code:null,scriptFile:null,showVersion:!1,scriptArgs:[],isModule:!1,stripTypes:!1};if(e.length===0)return t;for(let n=0;n<e.length;n++){let r=e[n];if(r===`-m`||r===`--module`){t.isModule=!0;continue}if(r===`--strip-types`){t.stripTypes=!0;continue}if(r===`-c`)return n+1>=e.length?{stdout:``,stderr:`js-exec: option requires an argument -- 'c'
87
87
  `,exitCode:2}:(t.code=e[n+1],t.scriptArgs=e.slice(n+2),t);if(r===`--version`||r===`-V`)return t.showVersion=!0,t;if(r.startsWith(`-`)&&r!==`-`&&r!==`--`)return{stdout:``,stderr:`js-exec: unrecognized option '${r}'
88
- `,exitCode:2};if(r===`--`)return n+1<e.length&&(t.scriptFile=e[n+1],t.scriptArgs=e.slice(n+2)),t;if(!r.startsWith(`-`))return t.scriptFile=r,t.scriptArgs=e.slice(n+1),t}return t}var y=null,b=null,x=[],S=null,C=d(new URL(`./js-exec-worker.js`,import.meta.url));function w(){for(;x.length>0&&x[0].canceled;)x.shift();if(S||x.length===0)return;let e=x.shift();e&&(S=e,E().postMessage(S.input))}function T(e,t){if(!e||typeof e!=`object`)return{success:!1,error:`Malformed worker response`};let n=e;return typeof n.protocolToken!=`string`||n.protocolToken!==t?{success:!1,error:`Malformed worker response: invalid protocol token`}:typeof n.success==`boolean`?n.success?{success:!0}:{success:!1,error:typeof n.error==`string`&&n.error.length>0?n.error:`Worker execution failed`}:{success:!1,error:`Malformed worker response: missing success flag`}}function E(){if(b&&=(t(b),null),y)return y;let n=e.runTrusted(()=>new f(C));return y=n,n.on(`message`,e=>{if(y===n){if(S){let t=T(e,S.input.protocolToken);S.resolve(t),S=null}x.length>0?w():D()}}),n.on(`error`,e=>{if(y===n){if(S){let t=a(o(e));S.resolve({success:!1,error:t}),S=null}for(let e of x)e.resolve({success:!1,error:`Worker crashed`});x.length=0,y=null}}),n.on(`exit`,()=>{y===n&&(y=null,S&&=(S.resolve({success:!1,error:`Worker exited unexpectedly`}),null),x.length>0&&w())}),n}function D(){b=n(()=>{y&&!S&&x.length===0&&(y.terminate(),y=null)},5e3)}async function O(e,t,n,r=[],i,a,o){return g.getStore()?{stdout:``,stderr:`js-exec: recursive invocation is not supported
89
- `,exitCode:1}:k(e,t,n,r,i,a,o)}async function k(e,i,s,d=[],f,p,_){let v=c(),b=i.exec,C=b?(e,t)=>g.run(!0,()=>b(e,t)):void 0,T=new l(v,i.fs,i.cwd,`js-exec`,i.fetch,i.limits?.maxOutputSize??0,C),E=i.limits?.maxJsTimeoutMs??m,D=i.fetch?Math.max(E,h):E,O={protocolToken:u(16).toString(`hex`),sharedBuffer:v,jsCode:e,cwd:i.cwd,env:r(i.env),args:d,scriptPath:s,bootstrapCode:f,isModule:p,stripTypes:_,timeoutMs:D},k,A=new Promise(e=>{k=e}),j={input:O,resolve:()=>{}},M=n(()=>{if(S===j){let e=y;e&&(y=null,e.terminate()),S=null,w()}else j.canceled=!0,S||w();j.resolve({success:!1,error:`Execution timeout: exceeded ${D}ms limit`})},D);j.resolve=e=>{t(M),k(e)},x.push(j),w();let[N,P]=await Promise.all([T.run(D),A.catch(e=>({success:!1,error:a(o(e))}))]);return!P.success&&P.error?{stdout:N.stdout,stderr:`${N.stderr}js-exec: ${a(P.error)}
88
+ `,exitCode:2};if(r===`--`)return n+1<e.length&&(t.scriptFile=e[n+1],t.scriptArgs=e.slice(n+2)),t;if(!r.startsWith(`-`))return t.scriptFile=r,t.scriptArgs=e.slice(n+1),t}return t}var y=null,b=null,x=[],S=null,C=u(new URL(`./js-exec-worker.js`,import.meta.url));function w(){for(;x.length>0&&x[0].canceled;)x.shift();if(S||x.length===0)return;let e=x.shift();e&&(S=e,E().postMessage(S.input))}function T(e,t){if(!e||typeof e!=`object`)return{success:!1,error:`Malformed worker response`};let n=e;return typeof n.protocolToken!=`string`||n.protocolToken!==t?{success:!1,error:`Malformed worker response: invalid protocol token`}:typeof n.success==`boolean`?n.success?{success:!0}:{success:!1,error:typeof n.error==`string`&&n.error.length>0?n.error:`Worker execution failed`}:{success:!1,error:`Malformed worker response: missing success flag`}}function E(){if(b&&=(t(b),null),y)return y;let n=e.runTrusted(()=>new f(C));return y=n,n.on(`message`,e=>{if(y===n){if(S){let t=T(e,S.input.protocolToken);S.resolve(t),S=null}x.length>0?w():D()}}),n.on(`error`,e=>{if(y===n){if(S){let t=a(o(e));S.resolve({success:!1,error:t}),S=null}for(let e of x)e.resolve({success:!1,error:`Worker crashed`});x.length=0,y=null}}),n.on(`exit`,()=>{y===n&&(y=null,S&&=(S.resolve({success:!1,error:`Worker exited unexpectedly`}),null),x.length>0&&w())}),n}function D(){b=n(()=>{y&&!S&&x.length===0&&(y.terminate(),y=null)},5e3)}async function O(e,t,n,r=[],i,a,o){return g.getStore()?{stdout:``,stderr:`js-exec: recursive invocation is not supported
89
+ `,exitCode:1}:k(e,t,n,r,i,a,o)}async function k(e,i,s,u=[],f,p,_){let v=c(),b=i.exec,C=b?(e,t)=>g.run(!0,()=>b(e,t)):void 0,T=new l(v,i.fs,i.cwd,`js-exec`,i.fetch,i.limits?.maxOutputSize??0,C),E=i.limits?.maxJsTimeoutMs??m,D=i.fetch?Math.max(E,h):E,O={protocolToken:d(16).toString(`hex`),sharedBuffer:v,jsCode:e,cwd:i.cwd,env:r(i.env),args:u,scriptPath:s,bootstrapCode:f,isModule:p,stripTypes:_,timeoutMs:D},k,A=new Promise(e=>{k=e}),j={input:O,resolve:()=>{}},M=n(()=>{if(S===j){let e=y;e&&(y=null,e.terminate()),S=null,w()}else j.canceled=!0,S||w();j.resolve({success:!1,error:`Execution timeout: exceeded ${D}ms limit`})},D);j.resolve=e=>{t(M),k(e)},x.push(j),w();let[N,P]=await Promise.all([T.run(D),A.catch(e=>({success:!1,error:a(o(e))}))]);return!P.success&&P.error?{stdout:N.stdout,stderr:`${N.stderr}js-exec: ${a(P.error)}
90
90
  `,exitCode:N.exitCode||1}:N}var A={name:`js-exec`,async execute(e,t){if(s(e))return{stdout:_,stderr:``,exitCode:0};let n=v(e);if(`exitCode`in n)return n;if(n.showVersion)return{stdout:`QuickJS (quickjs-emscripten)
91
91
  `,stderr:``,exitCode:0};let r,a;if(n.code!==null)r=n.code,a=`-c`;else if(n.scriptFile!==null){let e=t.fs.resolvePath(t.cwd,n.scriptFile);if(!await t.fs.exists(e))return{stdout:``,stderr:`js-exec: can't open file '${n.scriptFile}': No such file or directory
92
92
  `,exitCode:2};try{r=await t.fs.readFile(e),a=e}catch(e){return{stdout:``,stderr:`js-exec: can't open file '${n.scriptFile}': ${i(e.message)}
@@ -94,4 +94,4 @@ Limits:
94
94
  `,exitCode:2};let o=n.isModule,c=n.stripTypes;a&&a!==`-c`&&a!==`<stdin>`&&((a.endsWith(`.mjs`)||a.endsWith(`.mts`)||a.endsWith(`.ts`))&&(o=!0),(a.endsWith(`.ts`)||a.endsWith(`.mts`))&&(c=!0)),!o&&/\bawait\s+[\w([`]/.test(r)&&(o=!0);let l=t.jsBootstrapCode;return O(r,t,a,n.scriptArgs,l,o,c)}},j={name:`node`,async execute(){return{stdout:``,stderr:`node: this sandbox uses js-exec instead of node
95
95
 
96
96
  ${_}`,exitCode:1}}};export{A as jsExecCommand,j as nodeStubCommand};
97
- //# sourceMappingURL=js-exec-VXN6TZ7U-B4rL1N_3.mjs.map
97
+ //# sourceMappingURL=js-exec-VXN6TZ7U-Z8_USGOo.mjs.map
@@ -1 +1 @@
1
- import{Io as e,No as t,Vo as n}from"./dist-lSvSC9qO.mjs";import{A as r,M as i,O as a}from"./init-BSjC6Lzt.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-DgmD5_nT.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:i(e)}}let g=[],_=e(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=t(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=r(h,[`configurations`,y]);return x?(n(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
1
+ import{Io as e,No as t,Vo as n}from"./dist-GcFBLEr5.mjs";import{A as r,M as i,O as a}from"./init-BR_RY0pY.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-D4u7hIns.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:i(e)}}let g=[],_=e(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=t(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=r(h,[`configurations`,y]);return x?(n(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-CpDpte48.mjs";export{e as loadConfig};
@@ -1 +1 @@
1
- import{Cl as e,Fl as t,Ku as n,cs as r,hl as i,no as a,pl as o}from"./md-manager-BGnqyqi1-BsJX7ufl.mjs";import{Go as s,Uo as c,x as l}from"./dist-lSvSC9qO.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-JLtAmcu6.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=n();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(t,n){return t.map(t=>{let r=t.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:t.message,issueCode:t.code};if(n.doc!==null&&n.source!==null){let t=e({file:n.path,source:n.source,doc:n.doc,path:r});if(t!==void 0)return{...i,source:t}}return i})}function b(e){let n=e??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,n),_=c({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,n=!1)=>{let r=v(e);if(r.diagnostic!==void 0&&p.push(r.diagnostic),r.value===null)return{};let i=o({value:r.value,file:r.path,source:r.source,doc:r.doc});p.push(...i),u.push(e);let s=i.length>0?t(r.value):r.value;return n&&h.push(...a({value:s,file:r.path,source:r.source,doc:r.doc})),s},x=f(n,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,n)),w=r(_.value,S,C),T=l.safeParse(w);if(!T.success){let e=v(x),t={code:`SCHEMA_INVALID`,issues:y(T.error.issues,e)};throw Error(i(t))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
1
+ import{Il as e,ed as t,gl as n,ml as r,ps as i,so as a,wl as o}from"./md-manager-BGnqyqi1-DCa5-0ww.mjs";import{Ko as s,Wo as c,x as l}from"./dist-GcFBLEr5.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-BM21y1CS.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=t();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=o({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function b(t){let o=t??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,o),_=c({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(t,n=!1)=>{let i=v(t);if(i.diagnostic!==void 0&&p.push(i.diagnostic),i.value===null)return{};let o=r({value:i.value,file:i.path,source:i.source,doc:i.doc});p.push(...o),u.push(t);let s=o.length>0?e(i.value):i.value;return n&&h.push(...a({value:s,file:i.path,source:i.source,doc:i.doc})),s},x=f(o,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,o)),w=i(_.value,S,C),T=l.safeParse(w);if(!T.success){let e=v(x),t={code:`SCHEMA_INVALID`,issues:y(T.error.issues,e)};throw Error(n(t))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
@@ -1,2 +1,2 @@
1
- import{createRequire as e}from"node:module";import{createReadStream as t,createWriteStream as n}from"node:fs";import*as r from"node:os";import*as i from"node:path";import{fileURLToPath as a}from"node:url";import{Transform as o}from"node:stream";import{EventEmitter as s}from"node:events";import{pipeline as c}from"node:stream/promises";import*as l from"node:assert";var u=class extends Error{constructor(e,t){super(e),this.name=`LZMAError`,this.errno=t,this.code=t,Error.captureStackTrace(this,this.constructor)}},d=class extends u{constructor(e){super(`Cannot allocate memory`,e),this.name=`LZMAMemoryError`}},ee=class extends u{constructor(e){super(`Memory usage limit was reached`,e),this.name=`LZMAMemoryLimitError`}},te=class extends u{constructor(e){super(`File format not recognized`,e),this.name=`LZMAFormatError`}},ne=class extends u{constructor(e){super(`Invalid or unsupported options`,e),this.name=`LZMAOptionsError`}},re=class extends u{constructor(e){super(`Data is corrupt`,e),this.name=`LZMADataError`}},f=class extends u{constructor(e){super(`No progress is possible`,e),this.name=`LZMABufferError`}},p=class extends u{constructor(e){super(`Programming error`,e),this.name=`LZMAProgrammingError`}};function ie(e,t){switch(e){case 5:return new d(e);case 6:return new ee(e);case 7:return new te(e);case 8:return new ne(e);case 9:return new re(e);case 10:return new f(e);case 11:return new p(e);default:return new u(t||ae(e),e)}}function ae(e){let t=[`Operation completed successfully`,`End of stream was reached`,`Input stream has no integrity check`,`Cannot calculate the integrity check`,`Integrity check type is not available`,`Cannot allocate memory`,`Memory usage limit was reached`,`File format not recognized`,`Invalid or unsupported options`,`Data is corrupt`,`No progress is possible`,`Programming error`];return e<0||e>=t.length?`Unknown LZMA error code: ${e}`:t[e]}var oe=class extends s{constructor(e=10){if(super(),this.maxConcurrent=e,this.queue=[],this.metrics={active:0,queued:0,completed:0,failed:0},e<1)throw RangeError(`maxConcurrent must be at least 1`)}async compress(e,t){return this.enqueue(()=>Q(e,t))}async decompress(e,t){return this.enqueue(()=>$(e,t))}getMetrics(){return{...this.metrics}}get queueLength(){return this.queue.length}get activeCount(){return this.metrics.active}get isAtCapacity(){return this.metrics.active>=this.maxConcurrent}async enqueue(e){return new Promise((t,n)=>{this.queue.push({fn:e,resolve:t,reject:n}),this.metrics.queued=this.queue.length,this.emit(`queue`,{...this.metrics}),this.processQueue()})}processQueue(){if(this.metrics.active>=this.maxConcurrent||this.queue.length===0)return;let e=this.queue.shift();e&&(this.metrics.active++,this.metrics.queued=this.queue.length,this.emit(`start`,{...this.metrics}),Promise.resolve().then(()=>e.fn()).then(t=>{this.metrics.completed++,e.resolve(t),this.emit(`complete`,{...this.metrics})}).catch(t=>{this.metrics.failed++,e.reject(t),this.emit(`error-task`,t,{...this.metrics})}).finally(()=>{this.metrics.active--,this.emit(`metrics`,{...this.metrics}),this.processQueue()}))}async drain(){return this.metrics.active===0?Promise.resolve():new Promise(e=>{let t=()=>{this.metrics.active===0&&(this.off(`metrics`,t),e())};this.on(`metrics`,t)})}clearQueue(){let e=this.queue.length,t=Error(`Task cancelled: queue cleared`);for(let e of this.queue)e.reject(t);return this.queue=[],this.metrics.queued=0,this.emit(`metrics`,{...this.metrics}),e}};const se=a(import.meta.url),ce=i.dirname(se),le=e(import.meta.url),ue=i.resolve(i.join(ce,`..`)),m=le("node-gyp-build")(ue),de=r.cpus().length,h={NONE:m.LZMA_CHECK_NONE,CRC32:m.LZMA_CHECK_CRC32,CRC64:m.LZMA_CHECK_CRC64,SHA256:m.LZMA_CHECK_SHA256},g={DEFAULT:m.LZMA_PRESET_DEFAULT,EXTREME:m.LZMA_PRESET_EXTREME},fe={TELL_NO_CHECK:m.LZMA_TELL_NO_CHECK,TELL_UNSUPPORTED_CHECK:m.LZMA_TELL_UNSUPPORTED_CHECK,TELL_ANY_CHECK:m.LZMA_TELL_ANY_CHECK,CONCATENATED:m.LZMA_CONCATENATED},_={LZMA2:m.LZMA_FILTER_LZMA2,X86:m.LZMA_FILTER_X86,POWERPC:m.LZMA_FILTER_POWERPC,IA64:m.LZMA_FILTER_IA64,ARM:m.LZMA_FILTER_ARM,ARMTHUMB:m.LZMA_FILTER_ARMTHUMB,SPARC:m.LZMA_FILTER_SPARC},v={FAST:m.LZMA_MODE_FAST,NORMAL:m.LZMA_MODE_NORMAL},y={RUN:m.LZMA_RUN,SYNC_FLUSH:m.LZMA_SYNC_FLUSH,FULL_FLUSH:m.LZMA_FULL_FLUSH,FINISH:m.LZMA_FINISH},b={OK:m.LZMA_OK,STREAM_END:m.LZMA_STREAM_END,NO_CHECK:m.LZMA_NO_CHECK,UNSUPPORTED_CHECK:m.LZMA_UNSUPPORTED_CHECK,GET_CHECK:m.LZMA_GET_CHECK,MEM_ERROR:m.LZMA_MEM_ERROR,MEMLIMIT_ERROR:m.LZMA_MEMLIMIT_ERROR,FORMAT_ERROR:m.LZMA_FORMAT_ERROR,OPTIONS_ERROR:m.LZMA_OPTIONS_ERROR,DATA_ERROR:m.LZMA_DATA_ERROR,BUF_ERROR:m.LZMA_BUF_ERROR,PROG_ERROR:m.LZMA_PROG_ERROR},x={..._,X86_ALT:m.LZMA_FILTER_X86,POWERPC_ALT:m.LZMA_FILTER_POWERPC,IA64_ALT:m.LZMA_FILTER_IA64,ARM_ALT:m.LZMA_FILTER_ARM,ARMTHUMB_ALT:m.LZMA_FILTER_ARMTHUMB,FILTERS_MAX:m.LZMA_FILTERS_MAX},S=y.RUN,C=y.SYNC_FLUSH,w=y.FULL_FLUSH,T=y.FINISH,E=b.OK,D=b.STREAM_END,O=b.NO_CHECK,k=b.UNSUPPORTED_CHECK,A=b.GET_CHECK,j=b.MEM_ERROR,M=b.MEMLIMIT_ERROR,N=b.FORMAT_ERROR,P=b.OPTIONS_ERROR,F=b.DATA_ERROR,I=b.BUF_ERROR,L=b.PROG_ERROR,R=x.X86_ALT,z=x.POWERPC_ALT,B=x.IA64_ALT,V=x.ARM_ALT,pe=x.ARMTHUMB_ALT,H=x.FILTERS_MAX;var U=class extends o{constructor(e,t={},n){super(n);let r;if(t.filters){if(!Array.isArray(t.filters))throw Error(`Filters need to be in an array!`);try{r=[...t.filters]}catch{throw Error(`Filters need to be in an array!`)}}else r=[_.LZMA2];this._opts={check:t.check??h.NONE,preset:t.preset??g.DEFAULT,filters:r,mode:t.mode??v.NORMAL,threads:t.threads??1,chunkSize:t.chunkSize??m.BUFSIZ,flushFlag:t.flushFlag??m.LZMA_RUN},this._chunkSize=this._opts.chunkSize,this._flushFlag=this._opts.flushFlag,l.ok(Array.isArray(this._opts.filters),`Filters need to be in an array!`),this._opts.filters.indexOf(_.LZMA2)===-1&&this._opts.filters.push(_.LZMA2);let i=this._opts.filters.indexOf(_.LZMA2);i!==-1&&i!==this._opts.filters.length-1&&(this._opts.filters.splice(i,1),this._opts.filters.push(_.LZMA2)),e===m.STREAM_ENCODE&&(m.HAS_THREADS_SUPPORT||(this._opts.threads=1),this._opts.threads===0&&(this._opts.threads=de)),this.lzma=new m.LZMA(e,this._opts),this._closed=!1,this._hadError=!1,this._offset=0,this._buffer=Buffer.alloc(this._chunkSize),this._bytesRead=0,this._bytesWritten=0,this.on(`onerror`,e=>{this._hadError=!0;let t=this._createLZMAError(e);this.emit(`error`,t)}),this.once(`end`,()=>this.close())}_createLZMAError(e){return ie(e)}get bytesRead(){return this._bytesRead}get bytesWritten(){return this._bytesWritten}_emitProgress(){let e={bytesRead:this._bytesRead,bytesWritten:this._bytesWritten};this.emit(`progress`,e)}_reallocateBuffer(){this._offset=0,this._buffer=Buffer.alloc(this._chunkSize)}flush(e,t){let n=this._writableState,r,i;typeof e==`function`||e===void 0&&!t?(i=e,r=m.LZMA_SYNC_FLUSH):(r=e,i=t),n.ended?i&&process.nextTick(i):n.ending?i&&this.once(`end`,i):n.needDrain?this.once(`drain`,()=>{this.flush(i)}):(this._flushFlag=r,this.write(Buffer.alloc(0),`utf8`,i))}close(e){e&&process.nextTick(e),!this._closed&&(this.lzma.close(),this._closed=!0,process.nextTick(()=>{this.emit(`close`)}))}_transform(e,t,n){let r=this._writableState,i=(r.ending||r.ended)&&(!e||r.length===e.length);if(e!==null&&!(e instanceof Buffer)){n(Error(`invalid input`));return}if(this._closed){n(Error(`lzma binding closed`));return}e&&(this._bytesRead+=e.length);let a;i?a=m.LZMA_FINISH:(a=this._flushFlag,e&&e.length>=r.length&&(this._flushFlag=this._opts.flushFlag)),this._processChunk(e,a,n)}_flush(e){if(this._closed){process.nextTick(()=>e());return}this._transform(Buffer.alloc(0),`utf8`,e)}_processChunk(e,t,n){let r=typeof n==`function`;l.ok(!this._closed,`Stream closed!`);let i=e?.length,a=this._chunkSize-this._offset,o=0;if(!r){let n=[],r=0,s=null,c=(e,t,s)=>{if(this._hadError)return!1;if(e!==m.LZMA_OK&&e!==m.LZMA_STREAM_END)return this.emit(`onerror`,e),!1;let c=a-s;if(l.ok(c>=0,`More bytes after than before! Delta = ${c}`),c>0){let e=this._buffer.subarray(this._offset,this._offset+c);this._offset+=c,n.push(e),r+=c}return(s===0||this._offset>=this._chunkSize)&&(a=this._chunkSize,this._reallocateBuffer()),s===0||t>0?(o+=(i??0)-t,i=t,!0):!1};for(this.on(`error`,e=>{s=e});;){let[n,r,a]=this.lzma.codeSync(t,e,o,i,this._buffer,this._offset);if(this._hadError||!c(n,r,a))break}try{if(this._hadError)throw s??Error(`Unknown LZMA error`);return Buffer.concat(n,r)}finally{this.close()}}let s=(r,c,u)=>{if(this._hadError)return!1;if(r!==m.LZMA_OK&&r!==m.LZMA_STREAM_END)return this.emit(`onerror`,r),!1;let d=a-u;if(l.ok(d>=0,`More bytes after than before! Delta = ${d}`),d>0){let e=this._buffer.subarray(this._offset,this._offset+d);this._offset+=d,this._bytesWritten+=d,this.push(e),this._emitProgress()}if((u===0||this._offset>=this._chunkSize)&&(a=this._chunkSize,this._reallocateBuffer()),u===0||c>0)return o+=(i??0)-c,i=c,this.lzma.code(t,e,o,i,this._buffer,this._offset,s),!1;if(n&&!this._closed)try{n()}catch{this.emit(`onerror`,m.LZMA_PROG_ERROR)}return!1};this.lzma.code(t,e,o,i,this._buffer,this._offset,s)}},W=class extends U{constructor(e,t){super(m.STREAM_ENCODE,e,t)}},G=class extends U{constructor(e,t){super(m.STREAM_DECODE,e,t)}};function K(e,t){return new W(e,t)}function q(e,t){return new G(e,t)}function me(){return m.HAS_THREADS_SUPPORT}function he(e){return m.isXZ(e)}function ge(){return m.versionString()}function _e(){return m.versionNumber()}function ve(e){return m.easyEncoderMemusage(e)}function ye(){return m.easyDecoderMemusage()}function be(e){return m.parseFileIndex(e)}var J;(function(e){e.SUCCESS=`Operation completed successfully`,e.STREAM_END=`End of stream was reached`,e.NO_CHECK=`Input stream has no integrity check`,e.UNSUPPORTED_CHECK=`Cannot calculate the integrity check`,e.GET_CHECK=`Integrity check type is not available`,e.MEM_ERROR=`Cannot allocate memory`,e.MEMLIMIT_ERROR=`Memory usage limit was reached`,e.FORMAT_ERROR=`File format not recognized`,e.OPTIONS_ERROR=`Invalid or unsupported options`,e.DATA_ERROR=`Data is corrupt`,e.BUF_ERROR=`No progress is possible`,e.PROG_ERROR=`Programming error`})(J||={});const xe=[J.SUCCESS,J.STREAM_END,J.NO_CHECK,J.UNSUPPORTED_CHECK,J.GET_CHECK,J.MEM_ERROR,J.MEMLIMIT_ERROR,J.FORMAT_ERROR,J.OPTIONS_ERROR,J.DATA_ERROR,J.BUF_ERROR,J.PROG_ERROR];function Y(e,t,n){let r,i;typeof t==`function`?(i=t,r={}):(r=t,i=n),Ce(new G(r),e,i)}function Se(e,t){return we(new G(t),e)}function X(e,t,n){let r,i;typeof t==`function`?(i=t,r={}):(r=t,i=n),Ce(new W(r),e,i)}function Z(e,t){return we(new W(t),e)}function Q(e,t){return new Promise((n,r)=>{X(e,t||{},(e,t)=>{e?r(e):n(t)})})}function $(e,t){return new Promise((n,r)=>{Y(e,t||{},(e,t)=>{e?r(e):n(t)})})}function Ce(e,t,n){let r=[],i=0,a=()=>{let t;for(;(t=e.read())!==null;)r.push(t),i+=t.length;e.once(`readable`,a)},o=()=>{n(null,Buffer.concat(r,i)),e.close()};e.on(`error`,t=>{e.removeListener(`end`,o),e.removeListener(`readable`,a),n(t)}),e.on(`end`,o),e.end(t),a()}function we(e,t){let n;if(typeof t==`string`)n=Buffer.from(t);else if(t instanceof Buffer)n=t;else throw TypeError(`Not a string or buffer`);return e._processChunk(n,m.LZMA_FINISH)}async function Te(e,r,i){let a=t(e),o=n(r),s=K(i);await c(a,s,o)}async function Ee(e,r,i){let a=t(e),o=n(r),s=q(i);await c(a,s,o)}var De={Xz:W,Unxz:G,XzStream:U,hasThreads:me,messages:xe,check:h,preset:g,flag:fe,filter:_,mode:v,createXz:K,createUnxz:q,unxz:Y,unxzSync:Se,xz:X,xzSync:Z,xzAsync:Q,unxzAsync:$,LZMA_RUN:S,LZMA_SYNC_FLUSH:C,LZMA_FULL_FLUSH:w,LZMA_FINISH:T,LZMA_OK:E,LZMA_STREAM_END:D,LZMA_NO_CHECK:O,LZMA_UNSUPPORTED_CHECK:k,LZMA_GET_CHECK:A,LZMA_MEM_ERROR:j,LZMA_MEMLIMIT_ERROR:M,LZMA_FORMAT_ERROR:N,LZMA_OPTIONS_ERROR:P,LZMA_DATA_ERROR:F,LZMA_BUF_ERROR:I,LZMA_PROG_ERROR:L,LZMA_FILTER_X86:R,LZMA_FILTER_POWERPC:z,LZMA_FILTER_IA64:B,LZMA_FILTER_ARM:V,LZMA_FILTER_ARMTHUMB:pe,LZMA_FILTERS_MAX:H};export{y as LZMAAction,f as LZMABufferError,re as LZMADataError,u as LZMAError,J as LZMAErrorMessage,x as LZMAFilter,te as LZMAFormatError,d as LZMAMemoryError,ee as LZMAMemoryLimitError,ne as LZMAOptionsError,oe as LZMAPool,p as LZMAProgrammingError,b as LZMAStatus,I as LZMA_BUF_ERROR,F as LZMA_DATA_ERROR,H as LZMA_FILTERS_MAX,V as LZMA_FILTER_ARM,pe as LZMA_FILTER_ARMTHUMB,B as LZMA_FILTER_IA64,z as LZMA_FILTER_POWERPC,R as LZMA_FILTER_X86,T as LZMA_FINISH,N as LZMA_FORMAT_ERROR,w as LZMA_FULL_FLUSH,A as LZMA_GET_CHECK,M as LZMA_MEMLIMIT_ERROR,j as LZMA_MEM_ERROR,O as LZMA_NO_CHECK,E as LZMA_OK,P as LZMA_OPTIONS_ERROR,L as LZMA_PROG_ERROR,S as LZMA_RUN,D as LZMA_STREAM_END,C as LZMA_SYNC_FLUSH,k as LZMA_UNSUPPORTED_CHECK,G as Unxz,W as Xz,U as XzStream,h as check,q as createUnxz,K as createXz,De as default,ye as easyDecoderMemusage,ve as easyEncoderMemusage,_ as filter,fe as flag,me as hasThreads,he as isXZ,xe as messages,v as mode,be as parseFileIndex,g as preset,Y as unxz,$ as unxzAsync,Ee as unxzFile,Se as unxzSync,_e as versionNumber,ge as versionString,X as xz,Q as xzAsync,Te as xzFile,Z as xzSync};
2
- //# sourceMappingURL=lzma-C5bZvzmx.mjs.map
1
+ import{createRequire as e}from"node:module";import{createReadStream as t,createWriteStream as n}from"node:fs";import*as r from"node:path";import{fileURLToPath as i}from"node:url";import*as a from"node:os";import{Transform as o}from"node:stream";import{EventEmitter as s}from"node:events";import{pipeline as c}from"node:stream/promises";import*as l from"node:assert";var u=class extends Error{constructor(e,t){super(e),this.name=`LZMAError`,this.errno=t,this.code=t,Error.captureStackTrace(this,this.constructor)}},d=class extends u{constructor(e){super(`Cannot allocate memory`,e),this.name=`LZMAMemoryError`}},ee=class extends u{constructor(e){super(`Memory usage limit was reached`,e),this.name=`LZMAMemoryLimitError`}},te=class extends u{constructor(e){super(`File format not recognized`,e),this.name=`LZMAFormatError`}},ne=class extends u{constructor(e){super(`Invalid or unsupported options`,e),this.name=`LZMAOptionsError`}},re=class extends u{constructor(e){super(`Data is corrupt`,e),this.name=`LZMADataError`}},f=class extends u{constructor(e){super(`No progress is possible`,e),this.name=`LZMABufferError`}},p=class extends u{constructor(e){super(`Programming error`,e),this.name=`LZMAProgrammingError`}};function ie(e,t){switch(e){case 5:return new d(e);case 6:return new ee(e);case 7:return new te(e);case 8:return new ne(e);case 9:return new re(e);case 10:return new f(e);case 11:return new p(e);default:return new u(t||ae(e),e)}}function ae(e){let t=[`Operation completed successfully`,`End of stream was reached`,`Input stream has no integrity check`,`Cannot calculate the integrity check`,`Integrity check type is not available`,`Cannot allocate memory`,`Memory usage limit was reached`,`File format not recognized`,`Invalid or unsupported options`,`Data is corrupt`,`No progress is possible`,`Programming error`];return e<0||e>=t.length?`Unknown LZMA error code: ${e}`:t[e]}var oe=class extends s{constructor(e=10){if(super(),this.maxConcurrent=e,this.queue=[],this.metrics={active:0,queued:0,completed:0,failed:0},e<1)throw RangeError(`maxConcurrent must be at least 1`)}async compress(e,t){return this.enqueue(()=>Q(e,t))}async decompress(e,t){return this.enqueue(()=>$(e,t))}getMetrics(){return{...this.metrics}}get queueLength(){return this.queue.length}get activeCount(){return this.metrics.active}get isAtCapacity(){return this.metrics.active>=this.maxConcurrent}async enqueue(e){return new Promise((t,n)=>{this.queue.push({fn:e,resolve:t,reject:n}),this.metrics.queued=this.queue.length,this.emit(`queue`,{...this.metrics}),this.processQueue()})}processQueue(){if(this.metrics.active>=this.maxConcurrent||this.queue.length===0)return;let e=this.queue.shift();e&&(this.metrics.active++,this.metrics.queued=this.queue.length,this.emit(`start`,{...this.metrics}),Promise.resolve().then(()=>e.fn()).then(t=>{this.metrics.completed++,e.resolve(t),this.emit(`complete`,{...this.metrics})}).catch(t=>{this.metrics.failed++,e.reject(t),this.emit(`error-task`,t,{...this.metrics})}).finally(()=>{this.metrics.active--,this.emit(`metrics`,{...this.metrics}),this.processQueue()}))}async drain(){return this.metrics.active===0?Promise.resolve():new Promise(e=>{let t=()=>{this.metrics.active===0&&(this.off(`metrics`,t),e())};this.on(`metrics`,t)})}clearQueue(){let e=this.queue.length,t=Error(`Task cancelled: queue cleared`);for(let e of this.queue)e.reject(t);return this.queue=[],this.metrics.queued=0,this.emit(`metrics`,{...this.metrics}),e}};const se=i(import.meta.url),ce=r.dirname(se),le=e(import.meta.url),ue=r.resolve(r.join(ce,`..`)),m=le("node-gyp-build")(ue),de=a.cpus().length,h={NONE:m.LZMA_CHECK_NONE,CRC32:m.LZMA_CHECK_CRC32,CRC64:m.LZMA_CHECK_CRC64,SHA256:m.LZMA_CHECK_SHA256},g={DEFAULT:m.LZMA_PRESET_DEFAULT,EXTREME:m.LZMA_PRESET_EXTREME},fe={TELL_NO_CHECK:m.LZMA_TELL_NO_CHECK,TELL_UNSUPPORTED_CHECK:m.LZMA_TELL_UNSUPPORTED_CHECK,TELL_ANY_CHECK:m.LZMA_TELL_ANY_CHECK,CONCATENATED:m.LZMA_CONCATENATED},_={LZMA2:m.LZMA_FILTER_LZMA2,X86:m.LZMA_FILTER_X86,POWERPC:m.LZMA_FILTER_POWERPC,IA64:m.LZMA_FILTER_IA64,ARM:m.LZMA_FILTER_ARM,ARMTHUMB:m.LZMA_FILTER_ARMTHUMB,SPARC:m.LZMA_FILTER_SPARC},v={FAST:m.LZMA_MODE_FAST,NORMAL:m.LZMA_MODE_NORMAL},y={RUN:m.LZMA_RUN,SYNC_FLUSH:m.LZMA_SYNC_FLUSH,FULL_FLUSH:m.LZMA_FULL_FLUSH,FINISH:m.LZMA_FINISH},b={OK:m.LZMA_OK,STREAM_END:m.LZMA_STREAM_END,NO_CHECK:m.LZMA_NO_CHECK,UNSUPPORTED_CHECK:m.LZMA_UNSUPPORTED_CHECK,GET_CHECK:m.LZMA_GET_CHECK,MEM_ERROR:m.LZMA_MEM_ERROR,MEMLIMIT_ERROR:m.LZMA_MEMLIMIT_ERROR,FORMAT_ERROR:m.LZMA_FORMAT_ERROR,OPTIONS_ERROR:m.LZMA_OPTIONS_ERROR,DATA_ERROR:m.LZMA_DATA_ERROR,BUF_ERROR:m.LZMA_BUF_ERROR,PROG_ERROR:m.LZMA_PROG_ERROR},x={..._,X86_ALT:m.LZMA_FILTER_X86,POWERPC_ALT:m.LZMA_FILTER_POWERPC,IA64_ALT:m.LZMA_FILTER_IA64,ARM_ALT:m.LZMA_FILTER_ARM,ARMTHUMB_ALT:m.LZMA_FILTER_ARMTHUMB,FILTERS_MAX:m.LZMA_FILTERS_MAX},S=y.RUN,C=y.SYNC_FLUSH,w=y.FULL_FLUSH,T=y.FINISH,E=b.OK,D=b.STREAM_END,O=b.NO_CHECK,k=b.UNSUPPORTED_CHECK,A=b.GET_CHECK,j=b.MEM_ERROR,M=b.MEMLIMIT_ERROR,N=b.FORMAT_ERROR,P=b.OPTIONS_ERROR,F=b.DATA_ERROR,I=b.BUF_ERROR,L=b.PROG_ERROR,R=x.X86_ALT,z=x.POWERPC_ALT,B=x.IA64_ALT,V=x.ARM_ALT,pe=x.ARMTHUMB_ALT,H=x.FILTERS_MAX;var U=class extends o{constructor(e,t={},n){super(n);let r;if(t.filters){if(!Array.isArray(t.filters))throw Error(`Filters need to be in an array!`);try{r=[...t.filters]}catch{throw Error(`Filters need to be in an array!`)}}else r=[_.LZMA2];this._opts={check:t.check??h.NONE,preset:t.preset??g.DEFAULT,filters:r,mode:t.mode??v.NORMAL,threads:t.threads??1,chunkSize:t.chunkSize??m.BUFSIZ,flushFlag:t.flushFlag??m.LZMA_RUN},this._chunkSize=this._opts.chunkSize,this._flushFlag=this._opts.flushFlag,l.ok(Array.isArray(this._opts.filters),`Filters need to be in an array!`),this._opts.filters.indexOf(_.LZMA2)===-1&&this._opts.filters.push(_.LZMA2);let i=this._opts.filters.indexOf(_.LZMA2);i!==-1&&i!==this._opts.filters.length-1&&(this._opts.filters.splice(i,1),this._opts.filters.push(_.LZMA2)),e===m.STREAM_ENCODE&&(m.HAS_THREADS_SUPPORT||(this._opts.threads=1),this._opts.threads===0&&(this._opts.threads=de)),this.lzma=new m.LZMA(e,this._opts),this._closed=!1,this._hadError=!1,this._offset=0,this._buffer=Buffer.alloc(this._chunkSize),this._bytesRead=0,this._bytesWritten=0,this.on(`onerror`,e=>{this._hadError=!0;let t=this._createLZMAError(e);this.emit(`error`,t)}),this.once(`end`,()=>this.close())}_createLZMAError(e){return ie(e)}get bytesRead(){return this._bytesRead}get bytesWritten(){return this._bytesWritten}_emitProgress(){let e={bytesRead:this._bytesRead,bytesWritten:this._bytesWritten};this.emit(`progress`,e)}_reallocateBuffer(){this._offset=0,this._buffer=Buffer.alloc(this._chunkSize)}flush(e,t){let n=this._writableState,r,i;typeof e==`function`||e===void 0&&!t?(i=e,r=m.LZMA_SYNC_FLUSH):(r=e,i=t),n.ended?i&&process.nextTick(i):n.ending?i&&this.once(`end`,i):n.needDrain?this.once(`drain`,()=>{this.flush(i)}):(this._flushFlag=r,this.write(Buffer.alloc(0),`utf8`,i))}close(e){e&&process.nextTick(e),!this._closed&&(this.lzma.close(),this._closed=!0,process.nextTick(()=>{this.emit(`close`)}))}_transform(e,t,n){let r=this._writableState,i=(r.ending||r.ended)&&(!e||r.length===e.length);if(e!==null&&!(e instanceof Buffer)){n(Error(`invalid input`));return}if(this._closed){n(Error(`lzma binding closed`));return}e&&(this._bytesRead+=e.length);let a;i?a=m.LZMA_FINISH:(a=this._flushFlag,e&&e.length>=r.length&&(this._flushFlag=this._opts.flushFlag)),this._processChunk(e,a,n)}_flush(e){if(this._closed){process.nextTick(()=>e());return}this._transform(Buffer.alloc(0),`utf8`,e)}_processChunk(e,t,n){let r=typeof n==`function`;l.ok(!this._closed,`Stream closed!`);let i=e?.length,a=this._chunkSize-this._offset,o=0;if(!r){let n=[],r=0,s=null,c=(e,t,s)=>{if(this._hadError)return!1;if(e!==m.LZMA_OK&&e!==m.LZMA_STREAM_END)return this.emit(`onerror`,e),!1;let c=a-s;if(l.ok(c>=0,`More bytes after than before! Delta = ${c}`),c>0){let e=this._buffer.subarray(this._offset,this._offset+c);this._offset+=c,n.push(e),r+=c}return(s===0||this._offset>=this._chunkSize)&&(a=this._chunkSize,this._reallocateBuffer()),s===0||t>0?(o+=(i??0)-t,i=t,!0):!1};for(this.on(`error`,e=>{s=e});;){let[n,r,a]=this.lzma.codeSync(t,e,o,i,this._buffer,this._offset);if(this._hadError||!c(n,r,a))break}try{if(this._hadError)throw s??Error(`Unknown LZMA error`);return Buffer.concat(n,r)}finally{this.close()}}let s=(r,c,u)=>{if(this._hadError)return!1;if(r!==m.LZMA_OK&&r!==m.LZMA_STREAM_END)return this.emit(`onerror`,r),!1;let d=a-u;if(l.ok(d>=0,`More bytes after than before! Delta = ${d}`),d>0){let e=this._buffer.subarray(this._offset,this._offset+d);this._offset+=d,this._bytesWritten+=d,this.push(e),this._emitProgress()}if((u===0||this._offset>=this._chunkSize)&&(a=this._chunkSize,this._reallocateBuffer()),u===0||c>0)return o+=(i??0)-c,i=c,this.lzma.code(t,e,o,i,this._buffer,this._offset,s),!1;if(n&&!this._closed)try{n()}catch{this.emit(`onerror`,m.LZMA_PROG_ERROR)}return!1};this.lzma.code(t,e,o,i,this._buffer,this._offset,s)}},W=class extends U{constructor(e,t){super(m.STREAM_ENCODE,e,t)}},G=class extends U{constructor(e,t){super(m.STREAM_DECODE,e,t)}};function K(e,t){return new W(e,t)}function q(e,t){return new G(e,t)}function me(){return m.HAS_THREADS_SUPPORT}function he(e){return m.isXZ(e)}function ge(){return m.versionString()}function _e(){return m.versionNumber()}function ve(e){return m.easyEncoderMemusage(e)}function ye(){return m.easyDecoderMemusage()}function be(e){return m.parseFileIndex(e)}var J;(function(e){e.SUCCESS=`Operation completed successfully`,e.STREAM_END=`End of stream was reached`,e.NO_CHECK=`Input stream has no integrity check`,e.UNSUPPORTED_CHECK=`Cannot calculate the integrity check`,e.GET_CHECK=`Integrity check type is not available`,e.MEM_ERROR=`Cannot allocate memory`,e.MEMLIMIT_ERROR=`Memory usage limit was reached`,e.FORMAT_ERROR=`File format not recognized`,e.OPTIONS_ERROR=`Invalid or unsupported options`,e.DATA_ERROR=`Data is corrupt`,e.BUF_ERROR=`No progress is possible`,e.PROG_ERROR=`Programming error`})(J||={});const xe=[J.SUCCESS,J.STREAM_END,J.NO_CHECK,J.UNSUPPORTED_CHECK,J.GET_CHECK,J.MEM_ERROR,J.MEMLIMIT_ERROR,J.FORMAT_ERROR,J.OPTIONS_ERROR,J.DATA_ERROR,J.BUF_ERROR,J.PROG_ERROR];function Y(e,t,n){let r,i;typeof t==`function`?(i=t,r={}):(r=t,i=n),Ce(new G(r),e,i)}function Se(e,t){return we(new G(t),e)}function X(e,t,n){let r,i;typeof t==`function`?(i=t,r={}):(r=t,i=n),Ce(new W(r),e,i)}function Z(e,t){return we(new W(t),e)}function Q(e,t){return new Promise((n,r)=>{X(e,t||{},(e,t)=>{e?r(e):n(t)})})}function $(e,t){return new Promise((n,r)=>{Y(e,t||{},(e,t)=>{e?r(e):n(t)})})}function Ce(e,t,n){let r=[],i=0,a=()=>{let t;for(;(t=e.read())!==null;)r.push(t),i+=t.length;e.once(`readable`,a)},o=()=>{n(null,Buffer.concat(r,i)),e.close()};e.on(`error`,t=>{e.removeListener(`end`,o),e.removeListener(`readable`,a),n(t)}),e.on(`end`,o),e.end(t),a()}function we(e,t){let n;if(typeof t==`string`)n=Buffer.from(t);else if(t instanceof Buffer)n=t;else throw TypeError(`Not a string or buffer`);return e._processChunk(n,m.LZMA_FINISH)}async function Te(e,r,i){let a=t(e),o=n(r),s=K(i);await c(a,s,o)}async function Ee(e,r,i){let a=t(e),o=n(r),s=q(i);await c(a,s,o)}var De={Xz:W,Unxz:G,XzStream:U,hasThreads:me,messages:xe,check:h,preset:g,flag:fe,filter:_,mode:v,createXz:K,createUnxz:q,unxz:Y,unxzSync:Se,xz:X,xzSync:Z,xzAsync:Q,unxzAsync:$,LZMA_RUN:S,LZMA_SYNC_FLUSH:C,LZMA_FULL_FLUSH:w,LZMA_FINISH:T,LZMA_OK:E,LZMA_STREAM_END:D,LZMA_NO_CHECK:O,LZMA_UNSUPPORTED_CHECK:k,LZMA_GET_CHECK:A,LZMA_MEM_ERROR:j,LZMA_MEMLIMIT_ERROR:M,LZMA_FORMAT_ERROR:N,LZMA_OPTIONS_ERROR:P,LZMA_DATA_ERROR:F,LZMA_BUF_ERROR:I,LZMA_PROG_ERROR:L,LZMA_FILTER_X86:R,LZMA_FILTER_POWERPC:z,LZMA_FILTER_IA64:B,LZMA_FILTER_ARM:V,LZMA_FILTER_ARMTHUMB:pe,LZMA_FILTERS_MAX:H};export{y as LZMAAction,f as LZMABufferError,re as LZMADataError,u as LZMAError,J as LZMAErrorMessage,x as LZMAFilter,te as LZMAFormatError,d as LZMAMemoryError,ee as LZMAMemoryLimitError,ne as LZMAOptionsError,oe as LZMAPool,p as LZMAProgrammingError,b as LZMAStatus,I as LZMA_BUF_ERROR,F as LZMA_DATA_ERROR,H as LZMA_FILTERS_MAX,V as LZMA_FILTER_ARM,pe as LZMA_FILTER_ARMTHUMB,B as LZMA_FILTER_IA64,z as LZMA_FILTER_POWERPC,R as LZMA_FILTER_X86,T as LZMA_FINISH,N as LZMA_FORMAT_ERROR,w as LZMA_FULL_FLUSH,A as LZMA_GET_CHECK,M as LZMA_MEMLIMIT_ERROR,j as LZMA_MEM_ERROR,O as LZMA_NO_CHECK,E as LZMA_OK,P as LZMA_OPTIONS_ERROR,L as LZMA_PROG_ERROR,S as LZMA_RUN,D as LZMA_STREAM_END,C as LZMA_SYNC_FLUSH,k as LZMA_UNSUPPORTED_CHECK,G as Unxz,W as Xz,U as XzStream,h as check,q as createUnxz,K as createXz,De as default,ye as easyDecoderMemusage,ve as easyEncoderMemusage,_ as filter,fe as flag,me as hasThreads,he as isXZ,xe as messages,v as mode,be as parseFileIndex,g as preset,Y as unxz,$ as unxzAsync,Ee as unxzFile,Se as unxzSync,_e as versionNumber,ge as versionString,X as xz,Q as xzAsync,Te as xzFile,Z as xzSync};
2
+ //# sourceMappingURL=lzma-CEMDJHEs.mjs.map