@inkeep/open-knowledge 0.84.0-beta.10 → 0.84.0-beta.11

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 (128) hide show
  1. package/dist/cli.mjs +71 -71
  2. package/dist/constants-GoNSmmHC.mjs +1 -0
  3. package/dist/dist-ASBco0Dy.mjs +2212 -0
  4. package/dist/dist-CI4jGrUv.mjs +1 -0
  5. package/dist/index.d.mts +1 -1
  6. package/dist/index.mjs +1 -1
  7. package/dist/init-BMbMbpaM.mjs +1 -0
  8. package/dist/{init-ZiC_qPS2.mjs → init-CXkz2PQz.mjs} +54 -54
  9. package/dist/{launch-json-removal-AkSL-k1w.mjs → launch-json-removal-B88zT7Yg.mjs} +1 -1
  10. package/dist/{loader-DXV01FEG.mjs → loader-Bdedlh_I.mjs} +1 -1
  11. package/dist/loader-C1wr_xdg.mjs +1 -0
  12. package/dist/{open-browser-tzVDF1eD.mjs → open-browser-_mf6YkKD.mjs} +1 -1
  13. package/dist/preview-BHzfKSsK.mjs +1 -0
  14. package/dist/{preview-CfRTddxX.mjs → preview-D8X7GT0G.mjs} +1 -1
  15. package/dist/public/assets/{AccountSection-DzdMuT_J.js → AccountSection-CcFhIuKn.js} +1 -1
  16. package/dist/public/assets/{ActivityModeContent-DoZnuYGa.js → ActivityModeContent-C0JqJh_W.js} +1 -1
  17. package/dist/public/assets/{AddPropertiesButton-DD0OBA-l.js → AddPropertiesButton-0AlTkIIp.js} +1 -1
  18. package/dist/public/assets/{AgentDiffPane-BDig4K3J.js → AgentDiffPane-CUKAe9qN.js} +1 -1
  19. package/dist/public/assets/{AttachmentsSection-BWJyVXgH.js → AttachmentsSection-DrAtEVHV.js} +1 -1
  20. package/dist/public/assets/{CodeMirrorPropInput-DrSmujd5.js → CodeMirrorPropInput-Do7nSTb0.js} +1 -1
  21. package/dist/public/assets/ConsentDialogBody-D79cEEFu.js +2 -0
  22. package/dist/public/assets/{ContentRulesSection-CffRuHfA.js → ContentRulesSection-D99GwTBa.js} +1 -1
  23. package/dist/public/assets/{DocumentContext-D8TnLZMo.js → DocumentContext-D3I5hwIX.js} +1 -1
  24. package/dist/public/assets/{EditorModeToggle-DFb9s9P6.js → EditorModeToggle-CMIIvpQ1.js} +1 -1
  25. package/dist/public/assets/{ExcalidrawDocEditor-0C73ad4N.js → ExcalidrawDocEditor-BAH8CKWS.js} +1 -1
  26. package/dist/public/assets/FeedbackForm-B00a8by5.js +1 -0
  27. package/dist/public/assets/{ImportSkillDialog-CNeazF-G.js → ImportSkillDialog-DpWpWTj9.js} +1 -1
  28. package/dist/public/assets/{LinkPreviewsSection-BH7oUnak.js → LinkPreviewsSection-CVhMCyqv.js} +1 -1
  29. package/dist/public/assets/{LintConfigEditor-CBDD_tLD.js → LintConfigEditor-D_ZlJsuJ.js} +1 -1
  30. package/dist/public/assets/{LintingSection-BHt8QqtA.js → LintingSection-CxWFbr4y.js} +1 -1
  31. package/dist/public/assets/ManagedArtifactProperties-Crgt7BJp.js +1 -0
  32. package/dist/public/assets/{ManagedArtifactProperties-IjwB8-yG.js → ManagedArtifactProperties-D8YQyA0O.js} +1 -1
  33. package/dist/public/assets/{MermaidDocEditor-L8DaX5Id.js → MermaidDocEditor-CGWMNeyW.js} +1 -1
  34. package/dist/public/assets/{NetworkAccessSection-DnVCXfdh.js → NetworkAccessSection-CqBhmTwX.js} +1 -1
  35. package/dist/public/assets/{PropertyDisplayRow-i2I1A0Ba.js → PropertyDisplayRow-2fH34wwP.js} +1 -1
  36. package/dist/public/assets/{PublishToGitHubDialog-C9dpKyMf.js → PublishToGitHubDialog-ByMaK4s_.js} +1 -1
  37. package/dist/public/assets/{SchemaConfigEditor-C6HvOFuV.js → SchemaConfigEditor-MTTAovID.js} +1 -1
  38. package/dist/public/assets/{SearchSection-Cj1r4r7t.js → SearchSection-5u_qCLv4.js} +1 -1
  39. package/dist/public/assets/{SessionsHost-BIQfFpNX.js → SessionsHost-WZATBnYe.js} +2 -2
  40. package/dist/public/assets/{SettingsDialogBody-CNDQb7sY.js → SettingsDialogBody-0ex_IfqA.js} +2 -2
  41. package/dist/public/assets/{ShareReceiveMissDialog-D9rmTdNf.js → ShareReceiveMissDialog-bdN4FJQB.js} +1 -1
  42. package/dist/public/assets/{SkillToolbarControls-Bncu3tVe.js → SkillToolbarControls-Ca0UKhB2.js} +1 -1
  43. package/dist/public/assets/{SourceEditor-DPM24wFV.js → SourceEditor-6ec_4awF.js} +1 -1
  44. package/dist/public/assets/{SpellingSettings-BJoBhzez.js → SpellingSettings-CUh8Cur5.js} +1 -1
  45. package/dist/public/assets/{SyncSection-BXL3vVGV.js → SyncSection-D-l0j93S.js} +1 -1
  46. package/dist/public/assets/{SyncStatusBadge-BY0dbdUl.js → SyncStatusBadge-CVLTODPA.js} +1 -1
  47. package/dist/public/assets/{TerminalSection-C2iU1i4h.js → TerminalSection-Sgh4OULE.js} +1 -1
  48. package/dist/public/assets/{TerminalWindowApp-Cl41lh1g.js → TerminalWindowApp-B_q3wJA1.js} +1 -1
  49. package/dist/public/assets/{TextDocEditor-Cfgoa8Ap.js → TextDocEditor-CMGd0oZO.js} +1 -1
  50. package/dist/public/assets/{ThemePluginSection-BK71Plgj.js → ThemePluginSection-D5RMx1zr.js} +1 -1
  51. package/dist/public/assets/{ThreadView-EM0ArHvn.js → ThreadView-BXyRrKwk.js} +1 -1
  52. package/dist/public/assets/{TimelineDiffPane-Bcrv-3ap.js → TimelineDiffPane-SM_XoZyD.js} +1 -1
  53. package/dist/public/assets/{comment-chips-Dc9AyaeT.js → comment-chips-BMoPD1Ry.js} +1 -1
  54. package/dist/public/assets/{config-provider-BpDfgoSI.js → config-provider-BTi-sP7f.js} +1 -1
  55. package/dist/public/assets/config-schema-eyeMoQiU.js +1 -0
  56. package/dist/public/assets/{doc-undo-manager-Cl0eevTV.js → doc-undo-manager-Cbc4PXWq.js} +1 -1
  57. package/dist/public/assets/field-controls-CimT-Q0n.js +1 -0
  58. package/dist/public/assets/{field-controls-DpJXxyPk.js → field-controls-HfNIifff.js} +1 -1
  59. package/dist/public/assets/{index-BMLZ69to.js → index-CkF842Pf.js} +7 -7
  60. package/dist/public/assets/{lint-config-client-Cj3Jt5m2.js → lint-config-client-C3bXT9G3.js} +1 -1
  61. package/dist/public/assets/{lint-plugins-RYXoVRXF.js → lint-plugins--vl7cqvK.js} +1 -1
  62. package/dist/public/assets/{markdown-lint-BVkEhglC.js → markdown-lint-CHBB9p4R.js} +1 -1
  63. package/dist/public/assets/{markdownlint-rule-browser-ldRZcg6r.js → markdownlint-rule-browser-wxyNMQfV.js} +1 -1
  64. package/dist/public/assets/messages-1uhX2IsZ.js +1 -0
  65. package/dist/public/assets/messages-B2-eoUL3.js +1 -0
  66. package/dist/public/assets/messages-BcCiD7aG.js +1 -0
  67. package/dist/public/assets/messages-BgyOnrYq.js +1 -0
  68. package/dist/public/assets/messages-CQMoMyU1.js +1 -0
  69. package/dist/public/assets/messages-CT5_GTjF.js +1 -0
  70. package/dist/public/assets/messages-CfUUYlOM.js +1 -0
  71. package/dist/public/assets/messages-CquoFi0L.js +1 -0
  72. package/dist/public/assets/messages-D5IRECaM.js +1 -0
  73. package/dist/public/assets/messages-DANY6DR0.js +1 -0
  74. package/dist/public/assets/messages-DMAo6q_T.js +1 -0
  75. package/dist/public/assets/messages-Ds-TaR2B.js +1 -0
  76. package/dist/public/assets/messages-aWcvBlQS.js +1 -0
  77. package/dist/public/assets/{pending-receive-nav-store-CBvL7hAw.js → pending-receive-nav-store-B_q3sJ8u.js} +1 -1
  78. package/dist/public/assets/{progress-76173s7V.js → progress-BWQfFuw_.js} +1 -1
  79. package/dist/public/assets/{saved-themes-client-CeB36dNr.js → saved-themes-client-lSuPRRmb.js} +1 -1
  80. package/dist/public/assets/{schema-section-CYDmXwKv.js → schema-section-DbGu5Jz2.js} +1 -1
  81. package/dist/public/assets/{selection-context-BUZTIeDP.js → selection-context-CzcI-CBa.js} +1 -1
  82. package/dist/public/assets/{src-D7rCHhfK.js → src-DMXiZZVP.js} +1 -1
  83. package/dist/public/assets/{typing-burst-detector-iu7L-hA6.js → typing-burst-detector-CH2d1q_L.js} +1 -1
  84. package/dist/public/assets/{uninstall-D2-KYdsO.js → uninstall-D_aGIo20.js} +1 -1
  85. package/dist/public/assets/{use-activity-panel-WtogOEEi.js → use-activity-panel-B_vTmuEF.js} +1 -1
  86. package/dist/public/assets/{use-apply-config-language-COUD5OO7.js → use-apply-config-language-CHpGJFkS.js} +2 -2
  87. package/dist/public/assets/{use-open-skill-Bl-rypEG.js → use-open-skill-CSv_mbe3.js} +1 -1
  88. package/dist/public/assets/{use-terminal-enabled-DeBsOZ1A.js → use-terminal-enabled-wZmZdfpX.js} +1 -1
  89. package/dist/public/assets/{use-timeline-entry-diff-nEONCY6R.js → use-timeline-entry-diff-DJ_He9j4.js} +1 -1
  90. package/dist/public/index.html +21 -21
  91. package/dist/public/uninstall.html +3 -3
  92. package/dist/registry-probes-BSgmu91A.mjs +17 -0
  93. package/dist/{removal-file-path-BuLpw6F5.mjs → removal-file-path-BkTuavpH.mjs} +1 -1
  94. package/dist/{repair-launch-json-CtAdQsRf.mjs → repair-launch-json-rStAXlRd.mjs} +1 -1
  95. package/dist/{repair-mcp-configs-Bfys7jKY.mjs → repair-mcp-configs-fKZa8aHb.mjs} +1 -1
  96. package/dist/src-DE0UAXjz.mjs +11 -0
  97. package/dist/src-DnCuhNWM.mjs +1 -0
  98. package/dist/start-Dsj-6Klp.mjs +1 -0
  99. package/dist/{start-BcbkXw2n.mjs → start-ziWoBDkE.mjs} +3 -3
  100. package/package.json +4 -4
  101. package/dist/constants-CYVYQ2Ib.mjs +0 -1
  102. package/dist/dist-Bc3_Wt6N.mjs +0 -2212
  103. package/dist/dist-CvUzxHSS.mjs +0 -1
  104. package/dist/init-B1y8bkga.mjs +0 -1
  105. package/dist/loader-CQKOpKdM.mjs +0 -1
  106. package/dist/preview-CXeJgzGh.mjs +0 -1
  107. package/dist/public/assets/ConsentDialogBody-BRj-qPxP.js +0 -2
  108. package/dist/public/assets/FeedbackForm-BLpLr_CW.js +0 -1
  109. package/dist/public/assets/ManagedArtifactProperties-DevwE2aa.js +0 -1
  110. package/dist/public/assets/config-schema-CQminH5Z.js +0 -1
  111. package/dist/public/assets/field-controls-DPAPGMXV.js +0 -1
  112. package/dist/public/assets/messages-BGmazN_U.js +0 -1
  113. package/dist/public/assets/messages-B_44cpaN.js +0 -1
  114. package/dist/public/assets/messages-BcrGi_eE.js +0 -1
  115. package/dist/public/assets/messages-CLW4C_8a.js +0 -1
  116. package/dist/public/assets/messages-CfPKtrVG.js +0 -1
  117. package/dist/public/assets/messages-Cqjl8Mn1.js +0 -1
  118. package/dist/public/assets/messages-CrST-PfZ.js +0 -1
  119. package/dist/public/assets/messages-Crqxy7un.js +0 -1
  120. package/dist/public/assets/messages-Cs1spxzv.js +0 -1
  121. package/dist/public/assets/messages-D9RqT3Hq.js +0 -1
  122. package/dist/public/assets/messages-DNPfTsXY.js +0 -1
  123. package/dist/public/assets/messages-DidnvYXX.js +0 -1
  124. package/dist/public/assets/messages-VaXD108f.js +0 -1
  125. package/dist/registry-probes-DNaU56kl.mjs +0 -17
  126. package/dist/src-C6syC3v6.mjs +0 -11
  127. package/dist/src-LtjCkl-j.mjs +0 -1
  128. package/dist/start-DdmSNHh0.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$d as r,B as i,G as a,La as o,Qd as s,R as c,Ra as l,Vu as u,Zd as d,_f as f,a as p,af as m,dc as h,df as g,et as _,gf as v,id as y,mf as b,nf as x,of as S,pf as C,sd as ee,tf as te,uf as ne,xf as re}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{Ao as ie,Br as ae,Do as oe,Go as se,H as ce,Ko as le,L as ue,Mo as de,Oa as fe,Pr as pe,Qo as w,R as me,Uo as he,Wo as ge,Xn as _e,as as ve,at as ye,da as be,ds as xe,ha as Se,kt as Ce,li as we,m as Te,oi as Ee,qo as De,qr as Oe,rr as ke,rt as Ae,ua as je,un as Me}from"./dist-Bc3_Wt6N.mjs";import{i as Ne,n as T,o as E,r as Pe,s as D,t as O}from"./colors-r_owlCuY.mjs";import{t as k}from"./is-object-BGze3w87.mjs";import{t as Fe}from"./constants-CYVYQ2Ib.mjs";import{t as Ie}from"./preview-CfRTddxX.mjs";import{createRequire as Le}from"node:module";import{execFileSync as Re}from"node:child_process";import ze,{basename as Be,dirname as A,isAbsolute as Ve,join as j,posix as He,relative as M,resolve as N,sep as P,win32 as Ue}from"node:path";import F from"node:process";import{fileURLToPath as We}from"node:url";import{cpSync as Ge,existsSync as I,lstatSync as Ke,mkdirSync as qe,readFileSync as L,readdirSync as Je,readlinkSync as Ye,realpathSync as Xe,rmSync as Ze,statSync as Qe,writeFileSync as $e}from"node:fs";import{homedir as R}from"node:os";import{inspect as et,stripVTControlCharacters as tt,styleText as z}from"node:util";import*as nt from"node:readline";import{AsyncLocalStorage as rt,AsyncResource as it}from"node:async_hooks";var at=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})),ot=n((e=>{let{InvalidArgumentError:t}=at();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})),st=n((e=>{let{humanReadableArgName:t}=ot();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{$d as r,B as i,G as a,La as o,Qd as s,R as c,Ra as l,Vu as u,Zd as d,_f as f,a as p,af as m,dc as h,df as g,et as _,gf as v,id as y,mf as b,nf as x,of as S,pf as C,sd as ee,tf as te,uf as ne,xf as re}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{Aa as ie,At as ae,F as oe,Fr as se,Go as ce,Jo as le,Ko as w,Mo as ue,Po as de,R as fe,U as pe,Vr as me,Yo as he,Yr as ge,Zn as _e,_a as ve,ci as ye,di as be,dn as xe,es as T,fa as Se,ir as Ce,it as we,ko as Te,m as Ee,ot as De,pa as Oe,ps as ke,qo as Ae,qr as je,ss as E,z as Me}from"./dist-ASBco0Dy.mjs";import{i as Ne,n as D,o as O,r as Pe,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Fe}from"./constants-GoNSmmHC.mjs";import{t as Ie}from"./preview-D8X7GT0G.mjs";import{createRequire as Le}from"node:module";import{execFileSync as Re}from"node:child_process";import ze,{basename as Be,dirname as M,isAbsolute as Ve,join as N,posix as He,relative as P,resolve as F,sep as I,win32 as Ue}from"node:path";import L from"node:process";import{fileURLToPath as We}from"node:url";import{cpSync as Ge,existsSync as R,lstatSync as Ke,mkdirSync as qe,readFileSync as z,readdirSync as Je,readlinkSync as Ye,realpathSync as Xe,rmSync as Ze,statSync as Qe,writeFileSync as $e}from"node:fs";import{homedir as B}from"node:os";import{inspect as et,stripVTControlCharacters as tt,styleText as V}from"node:util";import*as nt from"node:readline";import{AsyncLocalStorage as rt,AsyncResource as it}from"node:async_hooks";var at=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})),ot=n((e=>{let{InvalidArgumentError:t}=at();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})),st=n((e=>{let{humanReadableArgName:t}=ot();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})),ct=n((e=>{let{InvalidArgumentError:t}=at();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}
@@ -16,7 +16,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
16
16
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17
17
  - ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function c(e,t){let n=i.resolve(e,t);if(a.existsSync(n))return n;if(s.includes(i.extname(t)))return;let r=s.find(e=>a.existsSync(`${n}${e}`));if(r)return`${n}${r}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=i.resolve(i.dirname(e),d)}if(d){let t=c(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=i.basename(this._scriptPath,i.extname(this._scriptPath));n!==this._name&&(t=c(d,`${n}-${e._name}`))}u=t||u}n=s.includes(i.extname(u));let f;o.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.execPath,t,{stdio:`inherit`})):n?(t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.argv[0],t,{stdio:`inherit`})):f=r.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{o.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new l(e,`commander.executeSubCommandAsync`,`(close)`)):o.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)o.exit(1);else{let e=new l(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)!==void 0&&this.getOptionValueSource(t)!=="default"});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
18
18
  `),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in o.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,o.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new p(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=m(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=m(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>c(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=i.basename(e,i.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(o.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
19
- Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}t.Command=h,t.useColor=_}));const{program:dt,createCommand:ft,createArgument:pt,createOption:mt,CommanderError:ht,InvalidArgumentError:gt,InvalidOptionArgumentError:_t,Command:vt,Argument:yt,Option:bt,Help:xt}=t(n((e=>{let{Argument:t}=ot(),{Command:n}=ut(),{CommanderError:r,InvalidArgumentError:i}=at(),{Help:a}=st(),{Option:o}=ct();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default,St=new Set([`emacs`,`vim`]);function Ct(e){return St.has(e)}function wt(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Ct))):[]}const Tt=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Et=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Dt=e=>e.name===`space`,Ot=e=>e.name===`backspace`,kt=e=>`1234567890`.includes(e.name),At=e=>e.name===`enter`||e.name===`return`;var jt=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Mt=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Nt=class extends Error{name=`ExitPromptError`},Pt=class extends Error{name=`HookError`},Ft=class extends Error{name=`ValidationError`};const It=new rt;function Lt(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Rt(e,t){let n=Lt(e);return It.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function B(){let e=It.getStore();if(!e)throw new Pt(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function zt(){return B().rl}function Bt(e){return it.bind((...t)=>{let n=B(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function Vt(e){let t=B(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function Ht(){B().handleChange()}const Ut={queue(e){let t=B(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(zt());if(r!=null&&typeof r!=`function`)throw new Ft(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=B();Bt(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=B();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function Wt(e){return typeof e==`function`}function V(e){return Vt(t=>{let n=it.bind(function(e){t.get()!==e&&(t.set(e),Ht())});if(t.initialized)return[t.get(),n];let r=Wt(e)?e():e;return t.set(r),[r,n]})}function Gt(e,t){Vt(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&Ut.queue(e),n.set(t)})}function Kt(){return F.platform.startsWith(`win`)?!!F.env.CI||!!F.env.WT_SESSION||!!F.env.TERMINUS_SUBLIME||F.env.ConEmuTask===`{cmd::Cmder}`||F.env.TERM_PROGRAM===`Terminus-Sublime`||F.env.TERM_PROGRAM===`vscode`||F.env.TERM===`xterm-256color`||F.env.TERM===`alacritty`||F.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:F.env.TERM!==`linux`}const qt={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},Jt={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},Yt={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},Xt={...qt,...Jt},Zt={...qt,...Yt},H=Kt()?Xt:Zt;Object.entries(Jt);const Qt={prefix:{idle:z(`blue`,`?`),done:z(`green`,H.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>z(`yellow`,e))},keybindings:[],style:{answer:e=>z(`cyan`,e),message:e=>z(`bold`,e),error:e=>z(`red`,`> ${e}`),defaultAnswer:e=>z(`dim`,`(${e})`),help:e=>z(`dim`,e),highlight:e=>z(`cyan`,e),key:e=>z(`cyan`,z(`bold`,`<${e}>`))}};function $t(){return{...Qt,keybindings:wt()}}function en(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function tn(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=en(n)&&en(r)?tn(n,r):r}return t}function nn(...e){return tn($t(),...e.filter(e=>e!=null))}function rn({status:e=`idle`,theme:t}){let[n,r]=V(!1),[i,a]=V(0),{prefix:o,spinner:s}=nn(t);return Gt(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function an(e,t){return Vt(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function on(e){return V({current:e})[0]}function sn(e){let t=on(e);t.current=e,Gt(e=>{let n=!1,r=Bt((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var cn=t(n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}))(),1);const ln=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),un=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,dn=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,fn=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,pn=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,mn=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,hn=/\t{1,1000}/y,gn=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,_n=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,vn=/\p{M}+/gu,yn={limit:1/0,ellipsis:``},bn=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?bn(i,yn,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[_n,l],[fn,0],[pn,o],[hn,s],[gn,c],[mn,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(vn,``)){let t=e.codePointAt(0)||0;if(S=un(t)?2:dn(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===mn?ln(e.slice(p,n.lastIndex)):n===gn?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},xn={limit:1/0,ellipsis:``,ellipsisWidth:0},U=(e,t={})=>bn(e,xn,t).width,Sn=`]8;;`,Cn=RegExp(`(?:\\[(?<code>\\d+)m|\\${Sn}(?<uri>.*))`,`y`),wn=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Tn=e=>`[${e}m`,En=e=>`${Sn}${e}`,Dn=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:U(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=U(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Sn,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},On=e=>{let t=e.split(` `),n=t.length;for(;n&&!U(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},kn=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=U(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=U(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Dn(s,r,t),c=U(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Dn(s,r,t),c=U(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Dn(s,r,t),c=U(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>On(e)));let l=s.join(`
19
+ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}t.Command=h,t.useColor=_}));const{program:dt,createCommand:ft,createArgument:pt,createOption:mt,CommanderError:ht,InvalidArgumentError:gt,InvalidOptionArgumentError:_t,Command:vt,Argument:yt,Option:bt,Help:xt}=t(n((e=>{let{Argument:t}=ot(),{Command:n}=ut(),{CommanderError:r,InvalidArgumentError:i}=at(),{Help:a}=st(),{Option:o}=ct();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default,St=new Set([`emacs`,`vim`]);function Ct(e){return St.has(e)}function wt(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Ct))):[]}const Tt=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Et=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Dt=e=>e.name===`space`,Ot=e=>e.name===`backspace`,kt=e=>`1234567890`.includes(e.name),At=e=>e.name===`enter`||e.name===`return`;var jt=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Mt=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Nt=class extends Error{name=`ExitPromptError`},Pt=class extends Error{name=`HookError`},Ft=class extends Error{name=`ValidationError`};const It=new rt;function Lt(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Rt(e,t){let n=Lt(e);return It.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function H(){let e=It.getStore();if(!e)throw new Pt(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function zt(){return H().rl}function Bt(e){return it.bind((...t)=>{let n=H(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function Vt(e){let t=H(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function Ht(){H().handleChange()}const Ut={queue(e){let t=H(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(zt());if(r!=null&&typeof r!=`function`)throw new Ft(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=H();Bt(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=H();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function Wt(e){return typeof e==`function`}function U(e){return Vt(t=>{let n=it.bind(function(e){t.get()!==e&&(t.set(e),Ht())});if(t.initialized)return[t.get(),n];let r=Wt(e)?e():e;return t.set(r),[r,n]})}function Gt(e,t){Vt(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&Ut.queue(e),n.set(t)})}function Kt(){return L.platform.startsWith(`win`)?!!L.env.CI||!!L.env.WT_SESSION||!!L.env.TERMINUS_SUBLIME||L.env.ConEmuTask===`{cmd::Cmder}`||L.env.TERM_PROGRAM===`Terminus-Sublime`||L.env.TERM_PROGRAM===`vscode`||L.env.TERM===`xterm-256color`||L.env.TERM===`alacritty`||L.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:L.env.TERM!==`linux`}const qt={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},Jt={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},Yt={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},Xt={...qt,...Jt},Zt={...qt,...Yt},W=Kt()?Xt:Zt;Object.entries(Jt);const Qt={prefix:{idle:V(`blue`,`?`),done:V(`green`,W.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>V(`yellow`,e))},keybindings:[],style:{answer:e=>V(`cyan`,e),message:e=>V(`bold`,e),error:e=>V(`red`,`> ${e}`),defaultAnswer:e=>V(`dim`,`(${e})`),help:e=>V(`dim`,e),highlight:e=>V(`cyan`,e),key:e=>V(`cyan`,V(`bold`,`<${e}>`))}};function $t(){return{...Qt,keybindings:wt()}}function en(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function tn(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=en(n)&&en(r)?tn(n,r):r}return t}function nn(...e){return tn($t(),...e.filter(e=>e!=null))}function rn({status:e=`idle`,theme:t}){let[n,r]=U(!1),[i,a]=U(0),{prefix:o,spinner:s}=nn(t);return Gt(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function an(e,t){return Vt(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function on(e){return U({current:e})[0]}function sn(e){let t=on(e);t.current=e,Gt(e=>{let n=!1,r=Bt((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var cn=t(n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}))(),1);const ln=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),un=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,dn=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,fn=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,pn=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,mn=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,hn=/\t{1,1000}/y,gn=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,_n=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,vn=/\p{M}+/gu,yn={limit:1/0,ellipsis:``},bn=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?bn(i,yn,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[_n,l],[fn,0],[pn,o],[hn,s],[gn,c],[mn,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(vn,``)){let t=e.codePointAt(0)||0;if(S=un(t)?2:dn(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===mn?ln(e.slice(p,n.lastIndex)):n===gn?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},xn={limit:1/0,ellipsis:``,ellipsisWidth:0},G=(e,t={})=>bn(e,xn,t).width,Sn=`]8;;`,Cn=RegExp(`(?:\\[(?<code>\\d+)m|\\${Sn}(?<uri>.*))`,`y`),wn=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Tn=e=>`[${e}m`,En=e=>`${Sn}${e}`,Dn=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:G(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=G(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Sn,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},On=e=>{let t=e.split(` `),n=t.length;for(;n&&!G(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},kn=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=G(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=G(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Dn(s,r,t),c=G(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Dn(s,r,t),c=G(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Dn(s,r,t),c=G(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>On(e)));let l=s.join(`
20
20
  `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){Cn.lastIndex=e+1;let t=Cn.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
21
21
  `){a&&(r+=En(``));let e=i?wn(i):void 0;i&&e&&(r+=Tn(e))}else t===`
22
22
  `&&(i&&wn(i)&&(r+=Tn(i)),a&&(r+=En(a)))}return r},An=/\r?\n/;function jn(e,t,n){return String(e).normalize().split(An).map(e=>kn(e,t,n)).join(`
@@ -25,12 +25,12 @@ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let
25
25
  `).map(e=>e.trimEnd())).join(`
26
26
  `)}function Nn(){return(0,cn.default)({defaultWidth:80,output:zt().output})}function Pn({active:e,renderedItems:t,pageSize:n,loop:r}){let i=on({lastPointer:e,lastActive:void 0}),{lastPointer:a,lastActive:o}=i.current,s=Math.floor(n/2),c=t.reduce((e,t)=>e+t.length,0),l=t.slice(0,e).reduce((e,t)=>e+t.length,0),u=l;if(c>n){if(r)u=a,o!=null&&o<e&&e-o<n&&(u=Math.min(s,Math.abs(e-o)===1?Math.min(a+(t[o]?.length??0),Math.max(l,a)):a+e-o));else{let r=t.slice(e).reduce((e,t)=>e+t.length,0);u=r<n-s?n-r:Math.min(l,s)}}return i.current.lastPointer=u,i.current.lastActive=e,u}function Fn({items:e,active:t,renderItem:n,pageSize:r,loop:i=!0}){let a=Nn(),o=t=>(t%e.length+e.length)%e.length,s=e.map((e,r)=>e==null?[]:Mn(n({item:e,index:r,isActive:r===t}),a).split(`
27
27
  `)),c=s.reduce((e,t)=>e+t.length,0),l=e=>s[e]??[],u=Pn({active:t,renderedItems:s,pageSize:r,loop:i}),d=l(t).slice(0,r),f=u+d.length<=r?u:r-d.length,p=Array.from({length:r});p.splice(f,d.length,...d);let m=new Set([t]),h=f+d.length,g=o(t+1);for(;h<r&&!m.has(g)&&(i&&c>r?g!==t:g>t);){let e=l(g).slice(0,r-h);p.splice(h,e.length,...e),m.add(g),h+=e.length,g=o(g+1)}for(h=f-1,g=o(t-1);h>=0&&!m.has(g)&&(i&&c>r?g!==t:g<t);){let e=l(g),t=e.slice(Math.max(0,e.length-h-1));p.splice(h-t.length+1,t.length,...t),m.add(g),h-=t.length,g=o(g-1)}return p.filter(e=>typeof e==`string`).join(`
28
- `)}var In=t(n(((t,n)=>{let r=e(`stream`);n.exports=class extends r{#e=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on(`pipe`,this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,t){return this._dest?this._dest[e]:this._src?this._src[e]:t}#n(e,...t){typeof this._dest?.[e]==`function`&&this._dest[e](...t),typeof this._src?.[e]==`function`&&this._src[e](...t)}get isTTY(){return this.#e===null?this.#t(`isTTY`,!1):this.#e}set isTTY(e){this.#e=e}get rows(){return this.#t(`rows`)}get columns(){return this.#t(`columns`)}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return e.indexOf(this._prompt)===0&&(e=e.slice(this._prompt.length),e=e.replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit(`data`,e);this._prompt&&this._hadControl&&e.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit(`data`,this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit(`data`,e)}end(e){this.muted&&(e=e&&this.replace?e.toString().replace(/./g,this.replace):null),e&&this.emit(`data`,e),this.emit(`end`)}destroy(...e){return this.#n(`destroy`,...e)}destroySoon(...e){return this.#n(`destroySoon`,...e)}close(...e){return this.#n(`close`,...e)}}}))(),1);const W=[];W.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&W.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&W.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const Ln=e=>!!e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`,Rn=Symbol.for(`signal-exit emitter`),zn=globalThis,Bn=Object.defineProperty.bind(Object);var Vn=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(zn[Rn])return zn[Rn];Bn(zn,Rn,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let n=this.listeners[e],r=n.indexOf(t);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let i of this.listeners[e])r=i(t,n)===!0||r;return e===`exit`&&(r=this.emit(`afterExit`,t,n)||r),r}},Hn=class{};const Un=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var Wn=class extends Hn{onExit(){return()=>{}}load(){}unload(){}},Gn=class extends Hn{#e=Kn.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new Vn;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of W)this.#a[t]=()=>{let n=this.#n.listeners(t),{count:r}=this.#t,i=e;if(typeof i.__signal_exit_emitter__==`object`&&typeof i.__signal_exit_emitter__.count==`number`&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();let n=this.#t.emit(`exit`,null,t),r=t===`SIGHUP`?this.#e:t;n||e.kill(e.pid,r)}};this.#i=e.reallyExit,this.#r=e.emit}onExit(e,t){if(!Ln(this.#n))return()=>{};this.#o===!1&&this.load();let n=t?.alwaysLast?`afterExit`:`exit`;return this.#t.on(n,e),()=>{this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(let e of W)try{let t=this.#a[e];t&&this.#n.on(e,t)}catch{}this.#n.emit=(e,...t)=>this.#c(e,...t),this.#n.reallyExit=e=>this.#s(e)}}unload(){this.#o&&(this.#o=!1,W.forEach(e=>{let t=this.#a[e];if(!t)throw Error(`Listener not defined for signal: `+e);try{this.#n.removeListener(e,t)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#i,--this.#t.count)}#s(e){return Ln(this.#n)?(this.#n.exitCode=e||0,this.#t.emit(`exit`,this.#n.exitCode,null),this.#i.call(this.#n,this.#n.exitCode)):0}#c(e,...t){let n=this.#r;if(e===`exit`&&Ln(this.#n)){typeof t[0]==`number`&&(this.#n.exitCode=t[0]);let r=n.call(this.#n,e,...t);return this.#t.emit(`exit`,this.#n.exitCode,null),r}return n.call(this.#n,e,...t)}};const Kn=globalThis.process,{onExit:qn,load:Jn,unload:Yn}=Un(Ln(Kn)?new Gn(Kn):new Wn),Xn=`\x1B[?25l`,Zn=(e=1)=>e>0?`[${e}A`:``,Qn=(e=1)=>e>0?`[${e}B`:``,$n=(e,t)=>typeof t==`number`&&!Number.isNaN(t)?`[${t+1};${e+1}H`:`[${e+1}G`,er=e=>e>0?(`\x1B[2K`+Zn(1)).repeat(e-1)+`\x1B[2K\x1B[G`:``,tr=e=>e.split(`
29
- `).length,nr=e=>e.split(`
30
- `).pop()??``;var rr=class{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=``){let n=nr(e),r=tt(n),i=r;this.rl.line.length>0&&(i=i.slice(0,-this.rl.line.length)),this.rl.setPrompt(i),this.cursorPos=this.rl.getCursorPos();let a=Nn();e=Mn(e,a),t=Mn(t,a),r.length%a===0&&(e+=`
28
+ `)}var In=t(n(((t,n)=>{let r=e(`stream`);n.exports=class extends r{#e=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on(`pipe`,this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,t){return this._dest?this._dest[e]:this._src?this._src[e]:t}#n(e,...t){typeof this._dest?.[e]==`function`&&this._dest[e](...t),typeof this._src?.[e]==`function`&&this._src[e](...t)}get isTTY(){return this.#e===null?this.#t(`isTTY`,!1):this.#e}set isTTY(e){this.#e=e}get rows(){return this.#t(`rows`)}get columns(){return this.#t(`columns`)}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return e.indexOf(this._prompt)===0&&(e=e.slice(this._prompt.length),e=e.replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit(`data`,e);this._prompt&&this._hadControl&&e.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit(`data`,this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit(`data`,e)}end(e){this.muted&&(e=e&&this.replace?e.toString().replace(/./g,this.replace):null),e&&this.emit(`data`,e),this.emit(`end`)}destroy(...e){return this.#n(`destroy`,...e)}destroySoon(...e){return this.#n(`destroySoon`,...e)}close(...e){return this.#n(`close`,...e)}}}))(),1);const Ln=[];Ln.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&Ln.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&Ln.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const Rn=e=>!!e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`,zn=Symbol.for(`signal-exit emitter`),Bn=globalThis,Vn=Object.defineProperty.bind(Object);var Hn=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Bn[zn])return Bn[zn];Vn(Bn,zn,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let n=this.listeners[e],r=n.indexOf(t);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let i of this.listeners[e])r=i(t,n)===!0||r;return e===`exit`&&(r=this.emit(`afterExit`,t,n)||r),r}},Un=class{};const Wn=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var Gn=class extends Un{onExit(){return()=>{}}load(){}unload(){}},Kn=class extends Un{#e=qn.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new Hn;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of Ln)this.#a[t]=()=>{let n=this.#n.listeners(t),{count:r}=this.#t,i=e;if(typeof i.__signal_exit_emitter__==`object`&&typeof i.__signal_exit_emitter__.count==`number`&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();let n=this.#t.emit(`exit`,null,t),r=t===`SIGHUP`?this.#e:t;n||e.kill(e.pid,r)}};this.#i=e.reallyExit,this.#r=e.emit}onExit(e,t){if(!Rn(this.#n))return()=>{};this.#o===!1&&this.load();let n=t?.alwaysLast?`afterExit`:`exit`;return this.#t.on(n,e),()=>{this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(let e of Ln)try{let t=this.#a[e];t&&this.#n.on(e,t)}catch{}this.#n.emit=(e,...t)=>this.#c(e,...t),this.#n.reallyExit=e=>this.#s(e)}}unload(){this.#o&&(this.#o=!1,Ln.forEach(e=>{let t=this.#a[e];if(!t)throw Error(`Listener not defined for signal: `+e);try{this.#n.removeListener(e,t)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#i,--this.#t.count)}#s(e){return Rn(this.#n)?(this.#n.exitCode=e||0,this.#t.emit(`exit`,this.#n.exitCode,null),this.#i.call(this.#n,this.#n.exitCode)):0}#c(e,...t){let n=this.#r;if(e===`exit`&&Rn(this.#n)){typeof t[0]==`number`&&(this.#n.exitCode=t[0]);let r=n.call(this.#n,e,...t);return this.#t.emit(`exit`,this.#n.exitCode,null),r}return n.call(this.#n,e,...t)}};const qn=globalThis.process,{onExit:Jn,load:Yn,unload:Xn}=Wn(Rn(qn)?new Kn(qn):new Gn),Zn=`\x1B[?25l`,Qn=(e=1)=>e>0?`[${e}A`:``,$n=(e=1)=>e>0?`[${e}B`:``,er=(e,t)=>typeof t==`number`&&!Number.isNaN(t)?`[${t+1};${e+1}H`:`[${e+1}G`,tr=e=>e>0?(`\x1B[2K`+Qn(1)).repeat(e-1)+`\x1B[2K\x1B[G`:``,nr=e=>e.split(`
29
+ `).length,rr=e=>e.split(`
30
+ `).pop()??``;var ir=class{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=``){let n=rr(e),r=tt(n),i=r;this.rl.line.length>0&&(i=i.slice(0,-this.rl.line.length)),this.rl.setPrompt(i),this.cursorPos=this.rl.getCursorPos();let a=Nn();e=Mn(e,a),t=Mn(t,a),r.length%a===0&&(e+=`
31
31
  `);let o=e+(t?`
32
- `+t:``),s=Math.floor(r.length/a)-this.cursorPos.rows+(t?tr(t):0);s>0&&(o+=Zn(s)),o+=$n(this.cursorPos.cols),this.write(Qn(this.extraLinesUnderPrompt)+er(this.height)+o),this.extraLinesUnderPrompt=s,this.height=tr(o)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write($n(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt(``);let t=Qn(this.extraLinesUnderPrompt);t+=e?er(this.height):`
33
- `,t+=`\x1B[G`,t+=`\x1B[?25h`,this.write(t),this.rl.close()}},ir=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}};const ar=globalThis.setImmediate;function or(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(e,n)=>{let r=n.slice(1);return t=r,r},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function sr(e){let t=or();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,s=new In.default;s.pipe(r.output??process.stdout);let c=nt.createInterface({terminal:!0,input:i,output:s});s.mute();let l=new rr(c),{promise:u,resolve:d,reject:f}=ir.withResolver(),p=()=>f(new Mt);if(a){let e=()=>f(new jt({cause:a.reason}));if(a.aborted)return e(),Object.assign(u,{cancel:p});a.addEventListener(`abort`,e),o.add(()=>a.removeEventListener(`abort`,e))}o.add(qn((e,t)=>{f(new Nt(`User force closed the prompt with ${e} ${t}`))}));let m=()=>f(new Nt(`User force closed the prompt with SIGINT`));return c.on(`SIGINT`,m),o.add(()=>c.removeListener(`SIGINT`,m)),Rt(c,a=>{let m=it.bind(()=>Ut.clearAll());c.on(`close`,m),o.add(()=>c.removeListener(`close`,m));let h=()=>{let r=()=>l.checkCursorPos();c.input.on(`keypress`,r),o.add(()=>c.input.removeListener(`keypress`,r));let i=null;a(()=>{let r=!1;try{let a=e(n,e=>{r?d(e):i={value:e}});if(a===void 0){let e=t[1]?.getFileName();throw e&&!e.startsWith(`file://`)&&(e=ze.resolve(e)),Error(`Prompt functions must return a string.\n at ${e}`)}let[o,s]=typeof a==`string`?[a]:a;l.render(o,s),Ut.run()}catch(e){f(e)}if(r=!0,i!==null){let{value:e}=i;i=null,d(e)}})};return`readableFlowing`in i?ar(h):h(),Object.assign(u.then(e=>(Ut.clearAll(),e),e=>{throw Ut.clearAll(),e}).finally(()=>{o.forEach(e=>e()),l.done({clearContent:!!r.clearPromptOnDone}),s.end()}).then(()=>u),{cancel:p})})}}var G=class{separator=z(`dim`,Array.from({length:15}).join(H.line));type=`separator`;constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`separator`)}};
32
+ `+t:``),s=Math.floor(r.length/a)-this.cursorPos.rows+(t?nr(t):0);s>0&&(o+=Qn(s)),o+=er(this.cursorPos.cols),this.write($n(this.extraLinesUnderPrompt)+tr(this.height)+o),this.extraLinesUnderPrompt=s,this.height=nr(o)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(er(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt(``);let t=$n(this.extraLinesUnderPrompt);t+=e?tr(this.height):`
33
+ `,t+=`\x1B[G`,t+=`\x1B[?25h`,this.write(t),this.rl.close()}},ar=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}};const or=globalThis.setImmediate;function sr(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(e,n)=>{let r=n.slice(1);return t=r,r},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function cr(e){let t=sr();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,s=new In.default;s.pipe(r.output??process.stdout);let c=nt.createInterface({terminal:!0,input:i,output:s});s.mute();let l=new ir(c),{promise:u,resolve:d,reject:f}=ar.withResolver(),p=()=>f(new Mt);if(a){let e=()=>f(new jt({cause:a.reason}));if(a.aborted)return e(),Object.assign(u,{cancel:p});a.addEventListener(`abort`,e),o.add(()=>a.removeEventListener(`abort`,e))}o.add(Jn((e,t)=>{f(new Nt(`User force closed the prompt with ${e} ${t}`))}));let m=()=>f(new Nt(`User force closed the prompt with SIGINT`));return c.on(`SIGINT`,m),o.add(()=>c.removeListener(`SIGINT`,m)),Rt(c,a=>{let m=it.bind(()=>Ut.clearAll());c.on(`close`,m),o.add(()=>c.removeListener(`close`,m));let h=()=>{let r=()=>l.checkCursorPos();c.input.on(`keypress`,r),o.add(()=>c.input.removeListener(`keypress`,r));let i=null;a(()=>{let r=!1;try{let a=e(n,e=>{r?d(e):i={value:e}});if(a===void 0){let e=t[1]?.getFileName();throw e&&!e.startsWith(`file://`)&&(e=ze.resolve(e)),Error(`Prompt functions must return a string.\n at ${e}`)}let[o,s]=typeof a==`string`?[a]:a;l.render(o,s),Ut.run()}catch(e){f(e)}if(r=!0,i!==null){let{value:e}=i;i=null,d(e)}})};return`readableFlowing`in i?or(h):h(),Object.assign(u.then(e=>(Ut.clearAll(),e),e=>{throw Ut.clearAll(),e}).finally(()=>{o.forEach(e=>e()),l.done({clearContent:!!r.clearPromptOnDone}),s.end()}).then(()=>u),{cancel:p})})}}var K=class{separator=V(`dim`,Array.from({length:15}).join(W.line));type=`separator`;constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`separator`)}};
34
34
  /*!
35
35
  * Copyright (c) Squirrel Chat et al., All rights reserved.
36
36
  * SPDX-License-Identifier: BSD-3-Clause
@@ -58,7 +58,7 @@ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let
58
58
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
59
59
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60
60
  */
61
- let cr=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var lr=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(cr);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
61
+ let lr=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var ur=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(lr);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
62
62
  /*!
63
63
  * Copyright (c) Squirrel Chat et al., All rights reserved.
64
64
  * SPDX-License-Identifier: BSD-3-Clause
@@ -86,9 +86,9 @@ let cr=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]
86
86
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
87
87
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88
88
  */
89
- function ur(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function dr(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
89
+ function dr(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function fr(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
90
90
  `,e===t&&(i+=` `.repeat(a+n+2),i+=`^
91
- `))}return i}var K=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=ur(t.toml,t.ptr),i=dr(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
91
+ `))}return i}var q=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=dr(t.toml,t.ptr),i=fr(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
92
92
  /*!
93
93
  * Copyright (c) Squirrel Chat et al., All rights reserved.
94
94
  * SPDX-License-Identifier: BSD-3-Clause
@@ -116,12 +116,12 @@ function ur(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop()
116
116
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
117
117
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
118
118
  */
119
- let fr=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,pr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,mr=/^[+-]?0[0-9_]/;function hr(e,t){let n=e[t++],r=n,i=n===`'`,a=n===e[t]&&n===e[t+1];a&&(e[t+=2]===`
119
+ let pr=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,mr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,hr=/^[+-]?0[0-9_]/;function gr(e,t){let n=e[t++],r=n,i=n===`'`,a=n===e[t]&&n===e[t+1];a&&(e[t+=2]===`
120
120
  `?t++:e[t]===`\r`&&e[t+1]===`
121
121
  `&&(t+=2));let o=``,s=t,c=0;for(let l=t;l<e.length;l++)if(n=e[l],a&&(n===`
122
122
  `||n===`\r`&&e[l+1]===`
123
- `))c&&=3;else if(n<` `&&n!==` `||n===``)throw new K(`control characters are not allowed in strings`,{toml:e,ptr:l});else if((!c||c===3)&&n===r&&(!a||e[l+1]===r&&e[l+2]===r))return a&&(e[l+3]===r&&l++,e[l+3]===r&&l++),[c?o:o+e.slice(s,l),l+(a?3:1)];else if(!c)!i&&n===`\\`&&(o+=e.slice(s,s=l),c=1);else if(c===1){if(n===`x`||n===`u`||n===`U`){let t=0,r=n===`x`?2:n===`u`?4:8;for(let n=0;n<r;n++,l++){let n=e.charCodeAt(l+1),r=n>=48&&n<=57?n-48:n>=65&&n<=70?n-65+10:n>=97&&n<=102?n-97+10:-1;if(r<0)throw new K(`invalid non-hex character in unicode escape`,{toml:e,ptr:l+1});t=t<<4|r}if(t<0||t>1114111||t>=55296&&t<=57343)throw new K(`invalid unicode escape`,{toml:e,ptr:l});o+=String.fromCodePoint(t),s=l+1,c=0}else if(n===` `||n===` `)c=2;else{if(n===`b`)o+=`\b`;else if(n===`t`)o+=` `;else if(n===`n`)o+=`
124
- `;else if(n===`f`)o+=`\f`;else if(n===`r`)o+=`\r`;else if(n===`e`)o+=`\x1B`;else if(n===`"`)o+=`"`;else if(n===`\\`)o+=`\\`;else throw new K(`unrecognized escape sequence`,{toml:e,ptr:l});s=l+1,c=0}}else if(n!==` `&&n!==` `){if(c===2)throw new K(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:s});c=+(!i&&n===`\\`),s=l}throw new K(`unfinished string`,{toml:e,ptr:t})}function gr(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=fr.test(e);if(i||pr.test(e)){if(mr.test(e))throw new K(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new K(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new K(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new lr(e);if(!a.isValid())throw new K(`invalid value`,{toml:t,ptr:n});return a}
123
+ `))c&&=3;else if(n<` `&&n!==` `||n===``)throw new q(`control characters are not allowed in strings`,{toml:e,ptr:l});else if((!c||c===3)&&n===r&&(!a||e[l+1]===r&&e[l+2]===r))return a&&(e[l+3]===r&&l++,e[l+3]===r&&l++),[c?o:o+e.slice(s,l),l+(a?3:1)];else if(!c)!i&&n===`\\`&&(o+=e.slice(s,s=l),c=1);else if(c===1){if(n===`x`||n===`u`||n===`U`){let t=0,r=n===`x`?2:n===`u`?4:8;for(let n=0;n<r;n++,l++){let n=e.charCodeAt(l+1),r=n>=48&&n<=57?n-48:n>=65&&n<=70?n-65+10:n>=97&&n<=102?n-97+10:-1;if(r<0)throw new q(`invalid non-hex character in unicode escape`,{toml:e,ptr:l+1});t=t<<4|r}if(t<0||t>1114111||t>=55296&&t<=57343)throw new q(`invalid unicode escape`,{toml:e,ptr:l});o+=String.fromCodePoint(t),s=l+1,c=0}else if(n===` `||n===` `)c=2;else{if(n===`b`)o+=`\b`;else if(n===`t`)o+=` `;else if(n===`n`)o+=`
124
+ `;else if(n===`f`)o+=`\f`;else if(n===`r`)o+=`\r`;else if(n===`e`)o+=`\x1B`;else if(n===`"`)o+=`"`;else if(n===`\\`)o+=`\\`;else throw new q(`unrecognized escape sequence`,{toml:e,ptr:l});s=l+1,c=0}}else if(n!==` `&&n!==` `){if(c===2)throw new q(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:s});c=+(!i&&n===`\\`),s=l}throw new q(`unfinished string`,{toml:e,ptr:t})}function _r(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=pr.test(e);if(i||mr.test(e)){if(hr.test(e))throw new q(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new q(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new q(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new ur(e);if(!a.isValid())throw new q(`invalid value`,{toml:t,ptr:n});return a}
125
125
  /*!
126
126
  * Copyright (c) Squirrel Chat et al., All rights reserved.
127
127
  * SPDX-License-Identifier: BSD-3-Clause
@@ -149,14 +149,14 @@ let fr=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,pr=/^[+-]?
149
149
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
150
150
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
151
151
  */
152
- function _r(e,t=0,n=e.length){let r=e.indexOf(`
153
- `,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function vr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
152
+ function vr(e,t=0,n=e.length){let r=e.indexOf(`
153
+ `,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function yr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
154
154
  `)return n;if(r===`\r`&&e[n+1]===`
155
- `)return n+1;if(r<` `&&r!==` `||r===``)throw new K(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function q(e,t,n,r){let i;for(;;){for(;(i=e[t])===` `||i===` `||!n&&(i===`
155
+ `)return n+1;if(r<` `&&r!==` `||r===``)throw new q(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function J(e,t,n,r){let i;for(;;){for(;(i=e[t])===` `||i===` `||!n&&(i===`
156
156
  `||i===`\r`&&e[t+1]===`
157
- `);)t++;if(r||i!==`#`)break;t=vr(e,t)}return t}function yr(e,t,n,r,i=!1){if(!r)return t=_r(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=_r(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
157
+ `);)t++;if(r||i!==`#`)break;t=yr(e,t)}return t}function br(e,t,n,r,i=!1){if(!r)return t=vr(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=vr(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
158
158
  `||t===`\r`&&e[a+1]===`
159
- `))return a}throw new K(`cannot find end of structure`,{toml:e,ptr:t})}
159
+ `))return a}throw new q(`cannot find end of structure`,{toml:e,ptr:t})}
160
160
  /*!
161
161
  * Copyright (c) Squirrel Chat et al., All rights reserved.
162
162
  * SPDX-License-Identifier: BSD-3-Clause
@@ -184,8 +184,8 @@ function _r(e,t=0,n=e.length){let r=e.indexOf(`
184
184
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
185
185
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
186
186
  */
187
- function br(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(vr(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function xr(e,t,n,r,i){if(r===0)throw new K(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?Tr(e,t,r,i):wr(e,t,r,i);if(n){if(s=q(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new K(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}if(a===`"`||a===`'`){let[r,i]=hr(e,t);if(n){if(i=q(e,i),e[i]&&e[i]!==`,`&&e[i]!==n&&e[i]!==`
188
- `&&e[i]!==`\r`)throw new K(`unexpected character encountered`,{toml:e,ptr:i});e[i]===`,`&&i++}return[r,i]}let o=yr(e,t,`,`,n),s=br(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new K(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=q(e,t+s[1]),e[o]===`,`&&o++),[gr(s[0],e,t,i),o]}
187
+ function xr(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(yr(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function Sr(e,t,n,r,i){if(r===0)throw new q(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?Er(e,t,r,i):Tr(e,t,r,i);if(n){if(s=J(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new q(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}if(a===`"`||a===`'`){let[r,i]=gr(e,t);if(n){if(i=J(e,i),e[i]&&e[i]!==`,`&&e[i]!==n&&e[i]!==`
188
+ `&&e[i]!==`\r`)throw new q(`unexpected character encountered`,{toml:e,ptr:i});e[i]===`,`&&i++}return[r,i]}let o=br(e,t,`,`,n),s=xr(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new q(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=J(e,t+s[1]),e[o]===`,`&&o++),[_r(s[0],e,t,i),o]}
189
189
  /*!
190
190
  * Copyright (c) Squirrel Chat et al., All rights reserved.
191
191
  * SPDX-License-Identifier: BSD-3-Clause
@@ -213,9 +213,9 @@ function br(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(vr(e,i),r=r
213
213
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
214
214
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
215
215
  */
216
- let Sr=/^[a-zA-Z0-9-_]+[ \t]*$/;function Cr(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new K(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `){if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new K(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let[s,c]=hr(e,t);r=e.indexOf(`.`,c);let l=e.slice(c,r<0||r>a?a:r),u=_r(l);if(u>-1)throw new K(`newlines are not allowed in keys`,{toml:e,ptr:t+r+u});if(l.trimStart())throw new K(`found extra tokens after the string part`,{toml:e,ptr:c});if(a<c&&(a=e.indexOf(n,c),a<0))throw new K(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(s)}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!Sr.test(n))throw new K(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}}while(r+1&&r<a);return[i,q(e,a+1,!0,!0)]}function wr(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new K(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=vr(e,t);else if(o!==` `&&o!==` `&&o!==`
217
- `&&o!==`\r`){let o,s=i,c=!1,[l,u]=Cr(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new K(`trying to redefine an already defined value`,{toml:e,ptr:t});!c&&o===`__proto__`&&Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new K(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=xr(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new K(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function Tr(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new K(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=vr(e,t);else if(a!==` `&&a!==` `&&a!==`
218
- `&&a!==`\r`){let a=xr(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new K(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}
216
+ let Cr=/^[a-zA-Z0-9-_]+[ \t]*$/;function wr(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new q(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `){if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new q(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let[s,c]=gr(e,t);r=e.indexOf(`.`,c);let l=e.slice(c,r<0||r>a?a:r),u=vr(l);if(u>-1)throw new q(`newlines are not allowed in keys`,{toml:e,ptr:t+r+u});if(l.trimStart())throw new q(`found extra tokens after the string part`,{toml:e,ptr:c});if(a<c&&(a=e.indexOf(n,c),a<0))throw new q(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(s)}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!Cr.test(n))throw new q(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}}while(r+1&&r<a);return[i,J(e,a+1,!0,!0)]}function Tr(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new q(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=yr(e,t);else if(o!==` `&&o!==` `&&o!==`
217
+ `&&o!==`\r`){let o,s=i,c=!1,[l,u]=wr(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new q(`trying to redefine an already defined value`,{toml:e,ptr:t});!c&&o===`__proto__`&&Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new q(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=Sr(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new q(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function Er(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new q(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=yr(e,t);else if(a!==` `&&a!==` `&&a!==`
218
+ `&&a!==`\r`){let a=Sr(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new q(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}
219
219
  /*!
220
220
  * Copyright (c) Squirrel Chat et al., All rights reserved.
221
221
  * SPDX-License-Identifier: BSD-3-Clause
@@ -243,8 +243,8 @@ let Sr=/^[a-zA-Z0-9-_]+[ \t]*$/;function Cr(e,t,n=`=`){let r=t-1,i=[],a=e.indexO
243
243
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
244
244
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
245
245
  */
246
- function Er(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&(r!==1||c.t!==3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function Dr(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=q(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=Cr(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new K(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=Er(n[0],r,i,t?2:1);if(!c)throw new K(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=Cr(e,s),i=Er(r[0],a,o,0);if(!i)throw new K(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=xr(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=q(e,s,!0),e[s]&&e[s]!==`
247
- `&&e[s]!==`\r`)throw new K(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=q(e,s)}return r}
246
+ function Dr(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&(r!==1||c.t!==3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function Or(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=J(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=wr(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new q(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=Dr(n[0],r,i,t?2:1);if(!c)throw new q(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=wr(e,s),i=Dr(r[0],a,o,0);if(!i)throw new q(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=Sr(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=J(e,s,!0),e[s]&&e[s]!==`
247
+ `&&e[s]!==`\r`)throw new q(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=J(e,s)}return r}
248
248
  /*!
249
249
  * Copyright (c) Squirrel Chat et al., All rights reserved.
250
250
  * SPDX-License-Identifier: BSD-3-Clause
@@ -272,13 +272,13 @@ function Er(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i
272
272
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
273
273
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274
274
  */
275
- let Or=/^[a-z0-9-_]+$/i;function kr(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function Ar(e){for(let t=0;t<e.length;t++)if(kr(e[t])!==`object`)return!1;return e.length!=0}function jr(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function Mr(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:Number.isInteger(e)&&(r||!Number.isSafeInteger(e))?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return jr(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return Nr(e,n,r);if(t===`array`)return Pr(e,n,r)}function Nr(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=Or.test(o)?o:jr(o),i+=` = `,i+=Mr(e[o],kr(e[o]),t-1,n)}return i+` }`}function Pr(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=Mr(e[i],kr(e[i]),t-1,n)}return r+` ]`}function Fr(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
276
- `}[[${t}]]\n`,i+=Ir(0,e[a],t,n,r);return i}function Ir(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=kr(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=Or.test(c)?c:jr(c);if(e===`array`&&Ar(t[c]))o+=(o&&`
277
- `)+Fr(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
278
- `)+Ir(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=Mr(t[c],e,r,i),a+=`
279
- `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Lr(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(kr(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Ir(0,e,``,t,n);return r[r.length-1]===`
275
+ let kr=/^[a-z0-9-_]+$/i;function Ar(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function jr(e){for(let t=0;t<e.length;t++)if(Ar(e[t])!==`object`)return!1;return e.length!=0}function Mr(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function Nr(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:Number.isInteger(e)&&(r||!Number.isSafeInteger(e))?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return Mr(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return Pr(e,n,r);if(t===`array`)return Fr(e,n,r)}function Pr(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=kr.test(o)?o:Mr(o),i+=` = `,i+=Nr(e[o],Ar(e[o]),t-1,n)}return i+` }`}function Fr(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=Nr(e[i],Ar(e[i]),t-1,n)}return r+` ]`}function Ir(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
276
+ `}[[${t}]]\n`,i+=Lr(0,e[a],t,n,r);return i}function Lr(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=Ar(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=kr.test(c)?c:Mr(c);if(e===`array`&&jr(t[c]))o+=(o&&`
277
+ `)+Ir(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
278
+ `)+Lr(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=Nr(t[c],e,r,i),a+=`
279
+ `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Rr(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Ar(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Lr(0,e,``,t,n);return r[r.length-1]===`
280
280
  `?r:r+`
281
- `}var J=u();function Rr(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 zr(e){return!e||typeof e!=`object`?String(e):`${typeof e} keys=[${Object.keys(e).join(`,`)}]`}function Br(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}: ${zr(t)}`:`${e}: ${n.reverse().slice(0,5).join(` -> `)}`}function Y(e,t){process.env.OK_DEBUG_NATIVE&&process.stderr.write(`[ok] native-config ${Br(e,t)}\n`)}const Vr=[`native`,`index.js`];function Hr(e={},t=Y){let n=e.moduleUrl??import.meta.url,r=e.requireModule??Le(n);try{let e=A(We(n));return r(j(e,...Vr))}catch(e){Rr(e)||t(`bundled loader failed to load`,e)}try{return r(`@inkeep/open-knowledge-native-config`)}catch(e){return Rr(e)||t(`workspace addon failed to load`,e),null}}function Ur(){let e=Hr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Wr(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 Gr(e){if(!k(e))throw Error(`TOML root is not a table`);return e}function Kr(e){return{backend:`native`,parseToObject(t){return Gr(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 qr(){return{backend:`fallback`,parseToObject(e){return Gr(Dr(e))}}}function Jr(e=Ur){let t=e();return t&&Wr(t)?Kr(t):qr()}let Yr=null;function Xr(){return Yr===null&&(Yr=Jr()),Yr}function Zr(){let e=Xr();return e.backend===`native`?e:void 0}const Qr=d,X=s,$r=te,ei=`node`,ti={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},ni=`@inkeep/open-knowledge`;function ri(e){return`${c(`unix-chain`,e.mcpChainTag)}2`}function ii(e){return`${c(`windows-chain`,e.mcpChainTag)}1`}function ai(e){let t=C[e],n=`${ni}@${t.npmDistTag}`,r=e===`stable`?``:`\nexport ${b}=${e}`;return`${ri(t)}${r}
281
+ `}var zr=u();function Br(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 Vr(e){return!e||typeof e!=`object`?String(e):`${typeof e} keys=[${Object.keys(e).join(`,`)}]`}function Hr(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}: ${Vr(t)}`:`${e}: ${n.reverse().slice(0,5).join(` -> `)}`}function Y(e,t){process.env.OK_DEBUG_NATIVE&&process.stderr.write(`[ok] native-config ${Hr(e,t)}\n`)}const Ur=[`native`,`index.js`];function Wr(e={},t=Y){let n=e.moduleUrl??import.meta.url,r=e.requireModule??Le(n);try{let e=M(We(n));return r(N(e,...Ur))}catch(e){Br(e)||t(`bundled loader failed to load`,e)}try{return r(`@inkeep/open-knowledge-native-config`)}catch(e){return Br(e)||t(`workspace addon failed to load`,e),null}}function Gr(){let e=Wr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Kr(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 qr(e){if(!j(e))throw Error(`TOML root is not a table`);return e}function Jr(e){return{backend:`native`,parseToObject(t){return qr(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 Yr(){return{backend:`fallback`,parseToObject(e){return qr(Or(e))}}}function Xr(e=Gr){let t=e();return t&&Kr(t)?Jr(t):Yr()}let Zr=null;function Qr(){return Zr===null&&(Zr=Xr()),Zr}function $r(){let e=Qr();return e.backend===`native`?e:void 0}const ei=d,X=s,ti=te,ni=`node`,ri={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},ii=`@inkeep/open-knowledge`;function ai(e){return`${c(`unix-chain`,e.mcpChainTag)}2`}function oi(e){return`${c(`windows-chain`,e.mcpChainTag)}1`}function si(e){let t=C[e],n=`${ii}@${t.npmDistTag}`,r=e===`stable`?``:`\nexport ${b}=${e}`;return`${ai(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 oi(e){let t=C[e],n=`${ni}@${t.npmDistTag}`,r=`${t.cliCommandNames[0]}.cmd`,i=t.npmDistTag===`latest`?ni:n,a=e===`stable`?``:`\n$env:${b} = '${e}'`;return`${ii(t)}${a}
293
+ exit 127`}function ci(e){let t=C[e],n=`${ii}@${t.npmDistTag}`,r=`${t.cliCommandNames[0]}.cmd`,i=t.npmDistTag===`latest`?ii:n,a=e===`stable`?``:`\n$env:${b} = '${e}'`;return`${oi(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`}ri(C.stable),ai(`stable`),ii(C.stable),oi(`stable`);function si(e){return`// ok-pi-bridge${e.mcpChainTag}`}function ci(e){return`${si(e)}-v1`}si(C.stable),ci(C.stable);function li(e){if(typeof e!=`object`||!e)return!1;let t=v(),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 vi(e,ri(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 vi(e,ii(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 vi(e,ri(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 vi(e,ii(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(ci(t))}return!1}function ui(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=N(e);if(Be(t)===`cli.mjs`&&Be(A(t))===`dist`)return t;let n=t.split(P),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?P:i.join(P);return j(a,`packages`,`cli`,`dist`,`cli.mjs`)}function Z(e={}){return e.mode===`dev`?{command:ei,args:[ui(),`mcp`],env:{...ti}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,oi(re())]}:{command:`/bin/sh`,args:[`-l`,`-c`,ai(re())]}}function di(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[ei,ui(),`mcp`],environment:{...ti}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,oi(re())]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,ai(re())]}}function fi(e){if(typeof e!=`object`||!e)return!1;let t=e;return pi(t,Z({mode:`published`,platformName:`darwin`}))||pi(t,Z({mode:`published`,platformName:`win32`}))}function pi(e,t){return Object.keys(e).length===Object.keys(t).length&&mi(e,t)}function mi(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 hi(e,t){let n=e=>yi(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 gi(e){return e.format===`toml`?Xr().backend===`native`:e.format===`json`||e.format===`yaml`}function _i(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function vi(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function yi(e){return vi(e,`# ok-mcp`)}function bi(e){return typeof e==`string`&&(e===ni||e.startsWith(`${ni}@`))}function xi(e){if(typeof e!=`object`||!e)return!1;let t=_i(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&yi(t[n+1])?!0:t.some(bi)}function Si(e){if(typeof e!=`object`||!e)return!1;let t=_i(e);if(t[0]!==ei||t[2]!==`mcp`)return!1;try{return t[1]===ui()}catch{return!1}}const Ci=[`command`,`args`,`env`],wi=[`type`,`command`,`environment`];function Ti(e){return e.type===`local`&&Array.isArray(e.command)?wi:Ci}function Ei(e,t){if(typeof e!=`object`||!e)return[];let n=e;return Ti(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function Di(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function Oi(e,t){return Ei(e,t).length>0}function ki(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:hi(t.args,t.command)}function Ai(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`&&hi(r,n)}function Q(e){return e===`win32`?Ue:He}function ji(e={}){let t=e.platformName??process.platform,n=e.home??R(),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 Mi(e={}){let t=e.platformName??process.platform,n=e.home??R();return Q(t).join(n,`.claude.json`)}function Ni(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=e.env??process.env;if(t===`darwin`)return He.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Ue.join(n,`AppData`,`Roaming`);return Ue.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Pi(e={}){let t=e.platformName??process.platform,n=e.home??R();return Q(t).join(n,`.cursor`,`mcp.json`)}function Fi(e={}){let t=e.platformName??process.platform,n=e.home??R();return(e.env??process.env).CODEX_HOME??Q(t).join(n,`.codex`)}function Ii(e={}){return Q(e.platformName??process.platform).join(Fi(e),`config.toml`)}function Li(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=(e.env??process.env).COPILOT_HOME??Q(t).join(n,`.copilot`);return Q(t).join(r,`mcp-config.json`)}function Ri(e={}){let t=e.platformName??process.platform,n=e.home??R(),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 zi(e={}){return Q(e.platformName??process.platform).join(Ri(e),`opencode.json`)}function Bi(e={}){let t=e.platformName??process.platform,n=e.home??R();return Q(t).join(n,`.openclaw`,`openclaw.json`)}function Vi(e={}){let t=e.platformName??process.platform,n=e.home??R();return Q(t).join(n,`.hermes`,`config.yaml`)}function Hi(e={}){let t=e.platformName??process.platform,n=e.home??R();return(e.env??process.env).PI_CODING_AGENT_DIR??Q(t).join(n,`.pi`,`agent`)}function Ui(e={}){let t=e.platformName??process.platform,n=e.home??R();return Q(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Wi(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 Gi(e){try{return Je(e).length>0}catch{return!1}}function Ki(e={}){let t=e.platformName??process.platform,[n,r]=Wi(e.home??R(),t),i=[n,r].find(e=>I(e.file));return i?i.file:Gi(r.dir)?r.file:n.file}const $={claude:{id:`claude`,label:X.claude,configPath:(e,t)=>Mi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.claude`),projectConfigPath:e=>j(e,`.mcp.json`),projectSkillPath:e=>j(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:X[`claude-desktop`],configPath:(e,t)=>Ni({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>A(Ni({home:t}))},cursor:{id:`cursor`,label:X.cursor,configPath:(e,t)=>Pi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>A(Pi({home:t})),projectConfigPath:e=>j(e,`.cursor`,`mcp.json`),projectSkillPath:e=>j(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:X.codex,configPath:(e,t)=>Ii({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>A(Ii({home:t})),projectConfigPath:e=>j(e,`.codex`,`config.toml`),projectSkillPath:e=>j(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:X.copilot,configPath:(e,t)=>Li({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>A(Li({home:t})),projectSkillPath:e=>j(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:X.opencode,configPath:(e,t)=>zi({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>f(),buildEntry:(e,t)=>di(t),scope:`global`,detectPath:(e,t)=>A(zi({home:t})),projectConfigPath:e=>j(e,`opencode.json`),projectSkillPath:e=>j(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:X.openclaw,configPath:(e,t)=>Bi({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.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(v())} (run \`ok init\` in the project).`)},format:`file`,topLevelKey:`mcpServers`,serverName:()=>f(),scope:`project`,detectPath:(e,t)=>Hi({home:t}),projectConfigPath:e=>j(e,ne(v())),projectSkillPath:e=>j(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:X.antigravity,configPath:(e,t)=>Ui({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:X[`lm-studio`],configPath:(e,t)=>Ki({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>A(Ki({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:X.hermes,configPath:(e,t)=>Vi({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.hermes`),offerOnlyWhenDetected:!0}};function qi(e){let t=e.filter(e=>!Object.hasOwn($,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${Qr.join(`, `)}`);return e.map(e=>$[e])}const Ji=`**/.ok/*`,Yi=`!**/${h}/`;function Xi(e){let t=[`.ok/`,`.okignore`];for(let n of Qr){let r=$[n];r.projectConfigPath&&t.push(da(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function Zi(e){let t=j(e,...p);if(!I(t))return[];try{let e=i(L(t,`utf-8`));if(!e)return[];let n=[];for(let[t,i]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of i.hosts){let i=r[e];i&&n.push(`${i}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function Qi(e,t){let n=na(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:oa(n)};let r=sa(e);if(r.kind!==`ok`)return r.result;let i=I(r.path)?L(r.path,`utf-8`):``,a=new Set(Zi(e)),o=[],s=a.size===0?i:i.split(`
317
+ exit 127`}ai(C.stable),si(`stable`),oi(C.stable),ci(`stable`);function li(e){return`// ok-pi-bridge${e.mcpChainTag}`}function ui(e){return`${li(e)}-v1`}li(C.stable),ui(C.stable);function di(e){if(typeof e!=`object`||!e)return!1;let t=v(),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 bi(e,ai(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 bi(e,oi(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 bi(e,ai(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 bi(e,oi(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(ui(t))}return!1}function fi(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(Be(t)===`cli.mjs`&&Be(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:ni,args:[fi(),`mcp`],env:{...ri}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,ci(re())]}:{command:`/bin/sh`,args:[`-l`,`-c`,si(re())]}}function pi(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[ni,fi(),`mcp`],environment:{...ri}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,ci(re())]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,si(re())]}}function mi(e){if(typeof e!=`object`||!e)return!1;let t=e;return hi(t,Z({mode:`published`,platformName:`darwin`}))||hi(t,Z({mode:`published`,platformName:`win32`}))}function hi(e,t){return Object.keys(e).length===Object.keys(t).length&&gi(e,t)}function gi(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 _i(e,t){let n=e=>xi(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 vi(e){return e.format===`toml`?Qr().backend===`native`:e.format===`json`||e.format===`yaml`}function yi(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function bi(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function xi(e){return bi(e,`# ok-mcp`)}function Si(e){return typeof e==`string`&&(e===ii||e.startsWith(`${ii}@`))}function Ci(e){if(typeof e!=`object`||!e)return!1;let t=yi(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&xi(t[n+1])?!0:t.some(Si)}function wi(e){if(typeof e!=`object`||!e)return!1;let t=yi(e);if(t[0]!==ni||t[2]!==`mcp`)return!1;try{return t[1]===fi()}catch{return!1}}const Ti=[`command`,`args`,`env`],Ei=[`type`,`command`,`environment`];function Di(e){return e.type===`local`&&Array.isArray(e.command)?Ei:Ti}function Oi(e,t){if(typeof e!=`object`||!e)return[];let n=e;return Di(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function ki(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function Ai(e,t){return Oi(e,t).length>0}function ji(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:_i(t.args,t.command)}function Mi(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`&&_i(r,n)}function Q(e){return e===`win32`?Ue:He}function Ni(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 Pi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.claude.json`)}function Fi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env;if(t===`darwin`)return He.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Ue.join(n,`AppData`,`Roaming`);return Ue.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Ii(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.cursor`,`mcp.json`)}function Li(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).CODEX_HOME??Q(t).join(n,`.codex`)}function Ri(e={}){return Q(e.platformName??process.platform).join(Li(e),`config.toml`)}function zi(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 Bi(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 Vi(e={}){return Q(e.platformName??process.platform).join(Bi(e),`opencode.json`)}function Hi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.openclaw`,`openclaw.json`)}function Ui(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.hermes`,`config.yaml`)}function Wi(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 Gi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Ki(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 qi(e){try{return Je(e).length>0}catch{return!1}}function Ji(e={}){let t=e.platformName??process.platform,[n,r]=Ki(e.home??B(),t),i=[n,r].find(e=>R(e.file));return i?i.file:qi(r.dir)?r.file:n.file}const $={claude:{id:`claude`,label:X.claude,configPath:(e,t)=>Pi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),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)=>Fi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Fi({home:t}))},cursor:{id:`cursor`,label:X.cursor,configPath:(e,t)=>Ii({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ii({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)=>Ri({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ri({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)=>zi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(zi({home:t})),projectSkillPath:e=>N(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:X.opencode,configPath:(e,t)=>Vi({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>f(),buildEntry:(e,t)=>pi(t),scope:`global`,detectPath:(e,t)=>M(Vi({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)=>Hi({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>f(),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(v())} (run \`ok init\` in the project).`)},format:`file`,topLevelKey:`mcpServers`,serverName:()=>f(),scope:`project`,detectPath:(e,t)=>Wi({home:t}),projectConfigPath:e=>N(e,ne(v())),projectSkillPath:e=>N(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:X.antigravity,configPath:(e,t)=>Gi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),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)=>Ji({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ji({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:X.hermes,configPath:(e,t)=>Ui({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>f(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.hermes`),offerOnlyWhenDetected:!0}};function Yi(e){let t=e.filter(e=>!Object.hasOwn($,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${ei.join(`, `)}`);return e.map(e=>$[e])}const Xi=`**/.ok/*`,Zi=`!**/${h}/`;function Qi(e){let t=[`.ok/`,`.okignore`];for(let n of ei){let r=$[n];r.projectConfigPath&&t.push(pa(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function $i(e){let t=N(e,...p);if(!R(t))return[];try{let e=i(z(t,`utf-8`));if(!e)return[];let n=[];for(let[t,i]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of i.hosts){let i=r[e];i&&n.push(`${i}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function ea(e,t){let n=ia(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:ca(n)};let r=la(e);if(r.kind!==`ok`)return r.result;let i=R(r.path)?z(r.path,`utf-8`):``,a=new Set($i(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
- `),c=ua(s),l=[],u=[];for(let e of t)la(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(`
319
+ `),c=fa(s),l=[],u=[];for(let e of t)da(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
- `)}\n`;try{$e(r.path,`${s}${d}${f}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:l,alreadyPresent:u,removed:o}}function $i(e,t){let n=sa(e);if(n.kind!==`ok`)return n.result;if(!I(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>ca(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(Ji),i.add(Yi);for(let t of Zi(e))i.add(t);let a;try{a=L(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let o=a.split(`
322
+ `)}\n`;try{$e(r.path,`${s}${d}${f}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:l,alreadyPresent:u,removed:o}}function ta(e,t){let n=la(e);if(n.kind!==`ok`)return n.result;if(!R(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>ua(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(Xi),i.add(Zi);for(let t of $i(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{$e(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function ea(e){let t=sa(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!I(t.path))return`shared`;let n;try{n=L(t.path,`utf-8`)}catch{return`shared`}let r=ua(n),i=Xi(e);for(let e of i)if(la(r,e))return`local-only`;return r.has(Ji)?`local-only`:`shared`}function ta(e){let t=sa(e);if(t.kind!==`ok`||!I(t.path))return[];let n;try{n=L(t.path,`utf-8`)}catch{return[]}let i=ua(n),a=[...Xi(e),...Zi(e)].filter(e=>la(i,e)),o=new Set(a),s=[];for(let e of Object.values(r))e!==null&&s.push(e);let c=[];for(let e of i){if(o.has(e))continue;if(e===Ji||e===Yi){c.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);s.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&c.push(e)}return[...a,...c]}function na(e,t){let n=[];for(let r of t){let t=N(e,r);if(I(t))try{Re(`git`,[`ls-files`,`--error-unmatch`,...a([r])],oe({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}const ra=/^[\w.\-/]+$/;function ia(e){return process.platform===`win32`?`"${e.replaceAll(`"`,``)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`}function aa(e){return ra.test(e)?e:ia(_(e))}function oa(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}-- ${aa(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 sa(e){let t=xe(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=j(e.path,`info`);return I(n)?{kind:`ok`,path:j(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 ca(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function la(e,t){for(let n of ca(t))if(e.has(n))return!0;return!1}function ua(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 da(e,t){return fa(M(t,e))}function fa(e){return P===`/`?e:e.split(P).join(`/`)}var pa=class extends Error{name=`ProjectPathSafetyError`;code=`PROJECT_PATH_SAFETY`};function ma(e,t){let n;try{n=Ke(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw new pa(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);ga(e,t)}function ha(e,t){ga(e,t)}function ga(e,t){_a(e,t)}function _a(e,t){let n=t,r;try{r=Xe(n)}catch{r=N(n)}let i=A(e);for(;i.length>1&&i!==P;){let t;try{t=Xe(i)}catch(e){if(e.code===`ENOENT`){i=A(i);continue}throw e}let n=M(r,t);if(n===``||!n.startsWith(`..`)&&!Ve(n))return;throw new pa(`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 va(e,t){let n=A(t),r=I(t)?`overwritten`:`written`;if(r===`written`&&I(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 Ze(n,{recursive:!0,force:!0}),qe(A(n),{recursive:!0}),Ge(e,n,{recursive:!0}),r}function ya(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ba(e,t,n){try{if(Qe(n).size>10485760)return!1}catch{return!1}let r;try{r=L(n,`utf-8`)}catch{return!1}let i=[],a=le(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!ya(a))return!1;let o=a[e.topLevelKey];if(!ya(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!ya(s))return!1;let c=s[e.serverName(t)];return ya(c)&&c.enabled===!1?!1:xi(c)||Si(c)}function xa(e){let t=y[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:ee(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:$[n.editor]??null}function Sa(e,t,n={}){if(!S.includes(e.id))return!0;let r=xa(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&ba(r,t,i))return!0;try{return ba(e,t,e.configPath(t,n.home))}catch{return!1}}function Ca(e){let t=new Set(x.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function wa(e,t){if(Ca(t).length===0)return null;let n=j(e,o,m,`SKILL.md`);try{let t=Se(`project`,{checkDesktop:!0});return ma(A(n),e),{editorId:`agents`,label:`.agents hub`,action:va(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 Ta(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Sa(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=Se(`project`,{checkDesktop:!0});ma(A(r),t);let i=va(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 Ea(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=A(n);return I(n)?(ha(r,t),Ze(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 Da(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 Oa(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 ka(e){for(let t of e.split(`
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 Aa(e){let t=(e.match(/\r\n/g)??[]).length;return t!==0&&t>=(e.match(/\n/g)??[]).length-t}function ja(e){try{return Qe(e).mode&511}catch{return}}function Ma(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
324
+ `);if(u!==a)try{$e(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function na(e){let t=la(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=fa(n),i=Qi(e);for(let e of i)if(da(r,e))return`local-only`;return r.has(Xi)?`local-only`:`shared`}function ra(e){let t=la(e);if(t.kind!==`ok`||!R(t.path))return[];let n;try{n=z(t.path,`utf-8`)}catch{return[]}let i=fa(n),a=[...Qi(e),...$i(e)].filter(e=>da(i,e)),o=new Set(a),s=[];for(let e of Object.values(r))e!==null&&s.push(e);let c=[];for(let e of i){if(o.has(e))continue;if(e===Xi||e===Zi){c.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);s.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&c.push(e)}return[...a,...c]}function ia(e,t){let n=[];for(let r of t){let t=F(e,r);if(R(t))try{Re(`git`,[`ls-files`,`--error-unmatch`,...a([r])],Te({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}const aa=/^[\w.\-/]+$/;function oa(e){return process.platform===`win32`?`"${e.replaceAll(`"`,``)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`}function sa(e){return aa.test(e)?e:oa(_(e))}function ca(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}-- ${sa(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 la(e){let t=ke(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 ua(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function da(e,t){for(let n of ua(t))if(e.has(n))return!0;return!1}function fa(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 pa(e,t){return ma(P(t,e))}function ma(e){return I===`/`?e:e.split(I).join(`/`)}var ha=class extends Error{name=`ProjectPathSafetyError`;code=`PROJECT_PATH_SAFETY`};function ga(e,t){let n;try{n=Ke(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw new ha(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);va(e,t)}function _a(e,t){va(e,t)}function va(e,t){ya(e,t)}function ya(e,t){let n=t,r;try{r=Xe(n)}catch{r=F(n)}let i=M(e);for(;i.length>1&&i!==I;){let t;try{t=Xe(i)}catch(e){if(e.code===`ENOENT`){i=M(i);continue}throw e}let n=P(r,t);if(n===``||!n.startsWith(`..`)&&!Ve(n))return;throw new ha(`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 ba(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 Ze(n,{recursive:!0,force:!0}),qe(M(n),{recursive:!0}),Ge(e,n,{recursive:!0}),r}function xa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sa(e,t,n){try{if(Qe(n).size>10485760)return!1}catch{return!1}let r;try{r=z(n,`utf-8`)}catch{return!1}let i=[],a=le(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!xa(a))return!1;let o=a[e.topLevelKey];if(!xa(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!xa(s))return!1;let c=s[e.serverName(t)];return xa(c)&&c.enabled===!1?!1:Ci(c)||wi(c)}function Ca(e){let t=y[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:ee(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:$[n.editor]??null}function wa(e,t,n={}){if(!S.includes(e.id))return!0;let r=Ca(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&Sa(r,t,i))return!0;try{return Sa(e,t,e.configPath(t,n.home))}catch{return!1}}function Ta(e){let t=new Set(x.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function Ea(e,t){if(Ta(t).length===0)return null;let n=N(e,o,m,`SKILL.md`);try{let t=ve(`project`,{checkDesktop:!0});return ga(M(n),e),{editorId:`agents`,label:`.agents hub`,action:ba(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 Da(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!wa(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=ve(`project`,{checkDesktop:!0});ga(M(r),t);let i=ba(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 Oa(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)?(_a(r,t),Ze(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 ka(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 Aa(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 ja(e){for(let t of e.split(`
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 Ma(e){let t=(e.match(/\r\n/g)??[]).length;return t!==0&&t>=(e.match(/\n/g)??[]).length-t}function Na(e){try{return Qe(e).mode&511}catch{return}}function Pa(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=se(r,t,void 0,{formattingOptions:{...ka(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${he(r,a)}`;return{text:o,changed:o!==e}}const Na={icon:{checked:z(`green`,H.circleFilled),unchecked:H.circle,cursor:H.pointer,disabledChecked:z(`green`,H.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>z(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>z(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${z(`bold`,e)} ${z(`dim`,t)}`).join(z(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`}};function Pa(e){return!G.isSeparator(e)&&!e.disabled}function Fa(e){return!G.isSeparator(e)}function Ia(e){return!G.isSeparator(e)&&e.checked}function La(e){return Pa(e)?{...e,checked:!e.checked}:e}function Ra(e){return function(t){return Pa(t)?{...t,checked:e}:t}}function za(e){return e.map(e=>{if(G.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 Ba=sr((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=nn(Na,e.theme),{keybindings:c}=s,[l,u]=V(`idle`),d=rn({status:l,theme:s}),[f,p]=V(za(e.choices)),m=an(()=>{let e=f.findIndex(Fa),t=f.findLastIndex(Fa);if(e===-1)throw new Ft(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=V(m.first),[_,v]=V();sn(async e=>{if(At(e)){let e=f.filter(Ia),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(Tt(e,c)||Et(e,c)){if(_&&v(void 0),r||Tt(e,c)&&h!==m.first||Et(e,c)&&h!==m.last){let t=Tt(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Fa(f[n]));g(n)}}else if(Dt(e)){let e=f[h];e&&!G.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?La(e):e))))}else if(e.name===o.all){let e=f.some(e=>Pa(e)&&!e.checked);p(f.map(Ra(e)))}else if(e.name===o.invert)p(f.map(La));else if(kt(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>!G.isSeparator(e)&&(n++,n===t)),i=f[r];i&&Pa(i)&&(g(r),p(f.map((e,t)=>t===r?La(e):e)))}});let y=s.style.message(e.message,l),b,x=Fn({items:f,active:h,renderItem({item:e,isActive:t}){if(G.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(Ia);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()}${Xn}`});const Va={icon:{cursor:H.pointer},style:{disabled:e=>z(`dim`,e),description:e=>z(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${z(`bold`,e)} ${z(`dim`,t)}`).join(z(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be selected.`},indexMode:`hidden`};function Ha(e){return!G.isSeparator(e)&&!e.disabled}function Ua(e){return!G.isSeparator(e)}function Wa(e){return e.map(e=>{if(G.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 Ga=sr((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=nn(Va,e.theme),{keybindings:a}=i,[o,s]=V(`idle`),c=rn({status:o,theme:i}),l=on(),u=!a.includes(`vim`),d=an(()=>Wa(e.choices),[e.choices]),f=an(()=>{let e=d.findIndex(Ua),t=d.findLastIndex(Ua);if(e===-1)throw new Ft(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=an(()=>`default`in e?d.findIndex(t=>Ha(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=V(p===-1?f.first:p),g=d[m];if(g==null||G.isSeparator(g))throw Error(`Active index does not point to a choice`);let[_,v]=V();sn((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),At(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(Tt(e,a)||Et(e,a)){if(r.clearLine(0),n||Tt(e,a)&&m!==f.first||Et(e,a)&&m!==f.last){let t=Tt(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!Ua(d[n]));h(n)}}else if(kt(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>!G.isSeparator(n)&&(t++,t===e)),i=d[n];i!=null&&Ha(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(Ot(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>G.isSeparator(t)||!Ha(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),Gt(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Fn({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(G.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()}${Xn}`});function Ka(e){let t=si(v());return e.startsWith(t)?Object.values(C).map(si).every(n=>n.length<=t.length||!e.startsWith(n)):!1}function qa(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`&&Ka(n)}function Ja(e){return{command:`ok-pi-managed-extension`,args:[e]}}function Ya(e={}){let t=e.mode===`dev`,n=v(),r=t?`${si(n)}-dev`:ci(n),i=`${g(n)}_`,a={unix:Z({...e,platformName:`darwin`}),win32:Z({...e,platformName:`win32`})};return`${r}
330
+ `,a=Ae(r,t,void 0,{formattingOptions:{...ja(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${ce(r,a)}`;return{text:o,changed:o!==e}}const Fa={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 Ia(e){return!K.isSeparator(e)&&!e.disabled}function La(e){return!K.isSeparator(e)}function Ra(e){return!K.isSeparator(e)&&e.checked}function za(e){return Ia(e)?{...e,checked:!e.checked}:e}function Ba(e){return function(t){return Ia(t)?{...t,checked:e}:t}}function Va(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 Ha=cr((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=nn(Fa,e.theme),{keybindings:c}=s,[l,u]=U(`idle`),d=rn({status:l,theme:s}),[f,p]=U(Va(e.choices)),m=an(()=>{let e=f.findIndex(La),t=f.findLastIndex(La);if(e===-1)throw new Ft(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=U(m.first),[_,v]=U();sn(async e=>{if(At(e)){let e=f.filter(Ra),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(Tt(e,c)||Et(e,c)){if(_&&v(void 0),r||Tt(e,c)&&h!==m.first||Et(e,c)&&h!==m.last){let t=Tt(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!La(f[n]));g(n)}}else if(Dt(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?za(e):e))))}else if(e.name===o.all){let e=f.some(e=>Ia(e)&&!e.checked);p(f.map(Ba(e)))}else if(e.name===o.invert)p(f.map(za));else if(kt(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>!K.isSeparator(e)&&(n++,n===t)),i=f[r];i&&Ia(i)&&(g(r),p(f.map((e,t)=>t===r?za(e):e)))}});let y=s.style.message(e.message,l),b,x=Fn({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(Ra);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()}${Zn}`});const Ua={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 Wa(e){return!K.isSeparator(e)&&!e.disabled}function Ga(e){return!K.isSeparator(e)}function Ka(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 qa=cr((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=nn(Ua,e.theme),{keybindings:a}=i,[o,s]=U(`idle`),c=rn({status:o,theme:i}),l=on(),u=!a.includes(`vim`),d=an(()=>Ka(e.choices),[e.choices]),f=an(()=>{let e=d.findIndex(Ga),t=d.findLastIndex(Ga);if(e===-1)throw new Ft(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=an(()=>`default`in e?d.findIndex(t=>Wa(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();sn((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),At(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(Tt(e,a)||Et(e,a)){if(r.clearLine(0),n||Tt(e,a)&&m!==f.first||Et(e,a)&&m!==f.last){let t=Tt(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!Ga(d[n]));h(n)}}else if(kt(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&&Wa(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(Ot(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>K.isSeparator(t)||!Wa(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),Gt(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Fn({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()}${Zn}`});function Ja(e){let t=li(v());return e.startsWith(t)?Object.values(C).map(li).every(n=>n.length<=t.length||!e.startsWith(n)):!1}function Ya(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`&&Ja(n)}function Xa(e){return{command:`ok-pi-managed-extension`,args:[e]}}function Za(e={}){let t=e.mode===`dev`,n=v(),r=t?`${li(n)}-dev`:ui(n),i=`${g(n)}_`,a={unix:Z({...e,platformName:`darwin`}),win32:Z({...e,platformName:`win32`})};return`${r}
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
@@ -672,22 +672,22 @@ export default function okBridge(pi: {
672
672
  }
673
673
  });
674
674
  }
675
- `}function Xa(e,t){let n=M(Me(t),Me(e));return n.length>0&&!n.startsWith(`..`)&&!Ve(n)}const Za=e=>{try{let t=Re(`git`,[`rev-parse`,`--show-toplevel`],oe({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function Qa(e,t={}){let n=t.homeDir??R(),r=t.gitTopLevel??Za,i=N(e),a;try{a=Xe(i)}catch{a=i}let o=a,s=0;for(;s<30&&o!==n&&o!==`/`&&o!==``;){if(Ee(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=A(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&Xa(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 $a(){let e=Hr();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function eo(e){let t=e,n=new Set;for(;;){let r;try{r=Ke(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=Ye(t)}catch(t){return Y(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=Ve(i)?i:j(A(t),i)}}let to;function no(){return to===void 0&&(to=$a()),to}function ro(e,t=no){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 eo(e)}const io={allowTrailingComma:!0,disallowComments:!1};function ao(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function oo(e){let t=[],n=De(e,t,io);return t.some(t=>!ao(t,e))||n?.type!==`object`?null:n}function so(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&ge(e)===t&&(n+=1)}return n}function co(e,t){w(e,`${JSON.stringify(t,null,2)}\n`)}function lo(e,t){let n=Lr(t);w(e,n.endsWith(`
676
- `)?n:`${n}\n`)}function uo(e,t){let n=(0,J.stringify)(t);w(e,n.endsWith(`
677
- `)?n:`${n}\n`)}const fo=10485760;function po(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)=>po(e,t[n]));if(k(e)&&k(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&po(e[n],t[n]))}return!1}function mo(e,t,n){return k(e)&&n.every(n=>po(e[n],t[n]))}function ho(e){for(let t of e.split(`
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 go(e,t,n){return t===void 0?[e,n]:[e,t,n]}function _o(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function vo(e,t,n){let r=e[t];return n===void 0?r:k(r)?r[n]:void 0}function yo(e,t,n,r,i,a=!1,o=!1){if(!I(e))return o?{kind:`unchanged`}:(co(e,_o(t,i,n,r)),{kind:`written`});let s;try{s=L(e,`utf-8`)}catch(e){return Y(`json config read failed`,e),{kind:`declined`,reason:Da(e)}}if(s.trim()===``)return o?{kind:`unchanged`}:(co(e,_o(t,i,n,r)),{kind:`written`});if(Buffer.byteLength(s,`utf-8`)>fo)return{kind:`declined`,reason:`oversize`};let c=oo(s);if(!c)return{kind:`declined`,reason:`unparseable`};if(so(c,t)>1)return{kind:`declined`,reason:`duplicate-container`};let l=vo(ge(c),t,i),u=k(l)?l[n]:void 0,d=u!==void 0,f=Ti(r);if(d&&a?fi(u):d&&mo(u,r,f))return{kind:o?`unchanged`:`overwritten`};let p=s.charCodeAt(0)===65279,m=p?s.slice(1):s,h=m.includes(`\r
675
+ `}function Qa(e,t){let n=P(xe(t),xe(e));return n.length>0&&!n.startsWith(`..`)&&!Ve(n)}const $a=e=>{try{let t=Re(`git`,[`rev-parse`,`--show-toplevel`],Te({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function eo(e,t={}){let n=t.homeDir??B(),r=t.gitTopLevel??$a,i=F(e),a;try{a=Xe(i)}catch{a=i}let o=a,s=0;for(;s<30&&o!==n&&o!==`/`&&o!==``;){if(ye(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&&Qa(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 to(){let e=Wr();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function no(e){let t=e,n=new Set;for(;;){let r;try{r=Ke(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=Ye(t)}catch(t){return Y(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=Ve(i)?i:N(M(t),i)}}let ro;function io(){return ro===void 0&&(ro=to()),ro}function ao(e,t=io){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 no(e)}const oo={allowTrailingComma:!0,disallowComments:!1};function so(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function co(e){let t=[],n=he(e,t,oo);return t.some(t=>!so(t,e))||n?.type!==`object`?null:n}function lo(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&w(e)===t&&(n+=1)}return n}function uo(e,t){T(e,`${JSON.stringify(t,null,2)}\n`)}function fo(e,t){let n=Rr(t);T(e,n.endsWith(`
676
+ `)?n:`${n}\n`)}function po(e,t){let n=(0,zr.stringify)(t);T(e,n.endsWith(`
677
+ `)?n:`${n}\n`)}const mo=10485760;function ho(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)=>ho(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)&&ho(e[n],t[n]))}return!1}function go(e,t,n){return j(e)&&n.every(n=>ho(e[n],t[n]))}function _o(e){for(let t of e.split(`
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 vo(e,t,n){return t===void 0?[e,n]:[e,t,n]}function yo(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function bo(e,t,n){let r=e[t];return n===void 0?r:j(r)?r[n]:void 0}function xo(e,t,n,r,i,a=!1,o=!1){if(!R(e))return o?{kind:`unchanged`}:(uo(e,yo(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:ka(e)}}if(s.trim()===``)return o?{kind:`unchanged`}:(uo(e,yo(t,i,n,r)),{kind:`written`});if(Buffer.byteLength(s,`utf-8`)>mo)return{kind:`declined`,reason:`oversize`};let c=co(s);if(!c)return{kind:`declined`,reason:`unparseable`};if(lo(c,t)>1)return{kind:`declined`,reason:`duplicate-container`};let l=bo(w(c),t,i),u=j(l)?l[n]:void 0,d=u!==void 0,f=Di(r);if(d&&a?mi(u):d&&go(u,r,f))return{kind:o?`unchanged`:`overwritten`};let p=s.charCodeAt(0)===65279,m=p?s.slice(1):s,h=m.includes(`\r
679
679
  `)?`\r
680
680
  `:`
681
- `,g={...ho(m),eol:h},_=go(t,i,n),v=m;if(o)for(let e of d?Ei(u,r):[]){let t=se(v,[..._,e],void 0,{formattingOptions:g});v=he(v,t)}else if(d&&!a&&xi(u))for(let e of f){let t=se(v,[..._,e],r[e],{formattingOptions:g});v=he(v,t)}else{let e=se(v,_,r,{formattingOptions:g});v=he(v,e)}let y=`${p?``:``}${v}`;return y!==s&&w(e,y,{mode:ja(e)}),o&&y===s?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}function bo(e,t,n,r,i,a=!1,o=!1){let s=``;if(I(t))try{s=L(t,`utf-8`)}catch(e){return Y(`toml config read failed`,e),{kind:`declined`,reason:Da(e)}}let c=s.trim()===``;if(c&&o)return{kind:`unchanged`};if(e.backend===`fallback`)return c?(lo(t,{[n]:{[r]:i}}),{kind:`written`}):{kind:`declined`,reason:`no-native-writer`};let l=s.charCodeAt(0)===65279,u=l?s.slice(1):s,d=Aa(u),f=c||u.endsWith(`
682
- `),p,m=!1;try{let t=xo(e,u,n,r);if(o){let n=u;for(let a of t===void 0?[]:Ei(t,i))n=e.removeEntryKey(n,r,a).text;p={text:n,existed:t!==void 0}}else{let n=So(t,i,a);m=n.kind===`replace`;let o=m?e.removeEntry(u,r).text:u;if(n.kind===`merge`)for(let t of n.prune)o=e.removeEntryKey(o,r,t).text;p=e.upsertEntry(o,r,i)}}catch(e){return Y(`upsertEntry failed`,e),{kind:`declined`,reason:`unparseable`}}let h=p.text;f?h.endsWith(`
681
+ `,g={..._o(m),eol:h},_=vo(t,i,n),v=m;if(o)for(let e of d?Oi(u,r):[]){let t=Ae(v,[..._,e],void 0,{formattingOptions:g});v=ce(v,t)}else if(d&&!a&&Ci(u))for(let e of f){let t=Ae(v,[..._,e],r[e],{formattingOptions:g});v=ce(v,t)}else{let e=Ae(v,_,r,{formattingOptions:g});v=ce(v,e)}let y=`${p?``:``}${v}`;return y!==s&&T(e,y,{mode:Na(e)}),o&&y===s?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}function So(e,t,n,r,i,a=!1,o=!1){let s=``;if(R(t))try{s=z(t,`utf-8`)}catch(e){return Y(`toml config read failed`,e),{kind:`declined`,reason:ka(e)}}let c=s.trim()===``;if(c&&o)return{kind:`unchanged`};if(e.backend===`fallback`)return c?(fo(t,{[n]:{[r]:i}}),{kind:`written`}):{kind:`declined`,reason:`no-native-writer`};let l=s.charCodeAt(0)===65279,u=l?s.slice(1):s,d=Ma(u),f=c||u.endsWith(`
682
+ `),p,m=!1;try{let t=Co(e,u,n,r);if(o){let n=u;for(let a of t===void 0?[]:Oi(t,i))n=e.removeEntryKey(n,r,a).text;p={text:n,existed:t!==void 0}}else{let n=wo(t,i,a);m=n.kind===`replace`;let o=m?e.removeEntry(u,r).text:u;if(n.kind===`merge`)for(let t of n.prune)o=e.removeEntryKey(o,r,t).text;p=e.upsertEntry(o,r,i)}}catch(e){return Y(`upsertEntry failed`,e),{kind:`declined`,reason:`unparseable`}}let h=p.text;f?h.endsWith(`
683
683
  `)||(h=`${h}\n`):h=h.replace(/\n+$/,``),d&&(h=h.replace(/\r\n/g,`
684
684
  `).replace(/\n/g,`\r
685
- `));let g=`${l?``:``}${h}`;return g!==s&&w(t,g,{mode:ja(t)}),o&&g===s?{kind:`unchanged`}:{kind:p.existed||m?`overwritten`:`written`}}function xo(e,t,n,r){if(t.trim()===``)return;let i=e.parseToObject(t)[n],a=k(i)?i[r]:void 0;return k(a)?a:void 0}function So(e,t,n){return e===void 0||fi(e)?{kind:`merge`,prune:[]}:n||!xi(e)?{kind:`replace`}:{kind:`merge`,prune:Ei(e,t)}}function Co(e,t,n,r,i=!1,a=!1){let o=``;if(I(e))try{o=L(e,`utf-8`)}catch(e){return Y(`yaml config read failed`,e),{kind:`declined`,reason:Da(e)}}if(o.trim()===``)return a?{kind:`unchanged`}:(uo(e,{[t]:{[n]:r}}),{kind:`written`});if(Buffer.byteLength(o,`utf-8`)>fo)return{kind:`declined`,reason:`oversize`};let s=o.charCodeAt(0)===65279,c=s?o.slice(1):o,l=(0,J.parseDocument)(c);if(l.errors.length>0)return{kind:`declined`,reason:`unparseable`};let u=[t,n],d=l.hasIn(u);l.hasIn([t])&&!(0,J.isCollection)(l.getIn([t],!0))&&l.deleteIn([t]);let f=l.getIn(u,!0),p=d&&(0,J.isCollection)(f)&&(i?fi(f.toJSON()):xi(f.toJSON()));if(a){if(d&&(0,J.isCollection)(f))for(let e of Ei(f.toJSON(),r))l.deleteIn([...u,e])}else if(p)for(let e of Ti(r))r[e]===void 0?l.deleteIn([...u,e]):l.setIn([...u,e],l.createNode(r[e]));else l.setIn(u,l.createNode(r));let m=l.toString(),h=Aa(c);c.endsWith(`
685
+ `));let g=`${l?``:``}${h}`;return g!==s&&T(t,g,{mode:Na(t)}),o&&g===s?{kind:`unchanged`}:{kind:p.existed||m?`overwritten`:`written`}}function Co(e,t,n,r){if(t.trim()===``)return;let i=e.parseToObject(t)[n],a=j(i)?i[r]:void 0;return j(a)?a:void 0}function wo(e,t,n){return e===void 0||mi(e)?{kind:`merge`,prune:[]}:n||!Ci(e)?{kind:`replace`}:{kind:`merge`,prune:Oi(e,t)}}function To(e,t,n,r,i=!1,a=!1){let o=``;if(R(e))try{o=z(e,`utf-8`)}catch(e){return Y(`yaml config read failed`,e),{kind:`declined`,reason:ka(e)}}if(o.trim()===``)return a?{kind:`unchanged`}:(po(e,{[t]:{[n]:r}}),{kind:`written`});if(Buffer.byteLength(o,`utf-8`)>mo)return{kind:`declined`,reason:`oversize`};let s=o.charCodeAt(0)===65279,c=s?o.slice(1):o,l=(0,zr.parseDocument)(c);if(l.errors.length>0)return{kind:`declined`,reason:`unparseable`};let u=[t,n],d=l.hasIn(u);l.hasIn([t])&&!(0,zr.isCollection)(l.getIn([t],!0))&&l.deleteIn([t]);let f=l.getIn(u,!0),p=d&&(0,zr.isCollection)(f)&&(i?mi(f.toJSON()):Ci(f.toJSON()));if(a){if(d&&(0,zr.isCollection)(f))for(let e of Oi(f.toJSON(),r))l.deleteIn([...u,e])}else if(p)for(let e of Di(r))r[e]===void 0?l.deleteIn([...u,e]):l.setIn([...u,e],l.createNode(r[e]));else l.setIn(u,l.createNode(r));let m=l.toString(),h=Ma(c);c.endsWith(`
686
686
  `)?m.endsWith(`
687
687
  `)||(m=`${m}\n`):m=m.replace(/\n+$/,``),h&&(m=m.replace(/\r\n/g,`
688
688
  `).replace(/\n/g,`\r
689
- `));let g=`${s?``:``}${m}`;return g!==o&&w(e,g,{mode:ja(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const wo=e=>e!==`project`,To=e=>e!==`user`;async function Eo(){let e=await Ba({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 Do(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Eo)():`both`}async function Oo(e){return Ga({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 ko(e){if(e.sharing!==void 0)return e.sharing;let t=ea(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Oo)(t):t}var Ao=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function jo(e){if(e===void 0||e===!0)return new Set(Ae);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(Ce.filter(e=>t.includes(e)))}function Mo(e,t,n){let r=N(n,e),i;try{i=Qe(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Ao(`--content-dir path does not exist: ${r}`):new Ao(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Ao(`--content-dir must be a directory: ${r}`);let a=No(t),o=No(r),s=M(a,o);if(s.startsWith(`..`)||Ve(s))throw new Ao(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function No(e){try{return Xe(e)}catch{return e}}const Po=`open-knowledge-ui`;function Fo(e,t,n){try{let r=e.detectPath?.(t,n)??A(e.configPath(t,n));return I(r)}catch{return!1}}function Io(e,t,n){try{let r=N(A(e.configPath(t,n))),i=N(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+P)}catch{return!1}}function Lo(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`||!I(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||Io(e,t,r);if(!i&&c&&!Fo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{ma(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 zo(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||qe(A(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{ve(`${o}.lock`,()=>{let t=ro(o).writePath;if(s||qe(A(t),{recursive:!0}),e.format===`toml`){let r=bo(Xr(),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=Co(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=yo(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 Ro={pi:Ya};function zo(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=Ro[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{qe(A(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{ve(`${t}.lock`,()=>{let e=null;try{e=L(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}w(t,c,e===null?void 0:{mode:ja(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 Bo(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!I(n)))return{editorId:e.id,label:e.label,path:n}}async function Vo(e){let t=qi(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=>Lo(t,``,n,e.home))}function Ho(e,t,n,r){let i=Wo(e,t,n,r);return i.kind===`present`?i.entry:null}function Uo(e,t,n,r){let i=vo(e,t,r);if(!k(i))return{kind:`no-entry`};let a=i[n];return k(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Wo(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!I(i))return{kind:`absent`};try{if(Qe(i).size>fo)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Da(e)}}let a;try{a=L(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Da(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Ja(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Xr().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Uo(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,J.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Uo(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=oo(a);return s?so(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Uo(ge(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Go(e={}){let t=N(e.cwd??process.cwd()),n=Qa(t,{homeDir:e.home}),r=n.projectRoot;if(Oe(r,e.home??R()))throw new ce(r);let i=!I(j(r,`.ok`)),a=n.gitRootPromoted?M(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:Mo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${D(`[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 ke(r),u;try{u=pe(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 d=u.created.includes(Fe),f=!1;if(c.didInit)try{f=de(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{je(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 p=await Do({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??Zo(r,e.home),h=e.editors??m,g=qi(m),_=qi(h),v=e.mcp===!1||p===null,y=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),b=g.filter(t=>Fo(t,r,e.home)),x=[],S=[],C=new Set;for(let t of y){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}x.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(wo(p)&&g.includes(t)&&t.scope===`global`&&x.push(Lo(t,r,s,e.home)),To(p)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Lo(t,r,s,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&C.add(n)}}let ee=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||ee.has(n)||(ee.add(n),S.push(Ta(t,r,{home:e.home})))}let te=wa(r,_.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??R();be({source:l,skills:[Te.project],agents:ne,scope:r},{home:t,enabled:fe(t).enabled})}let re=!v&&p!==null&&To(p)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,oe=v?[]:b.map(e=>Bo(e,r)).filter(e=>e!==void 0).filter(e=>!C.has(e.path)),se=e.installUserSkill??ae,le=e.home??R(),ue=jo(e.skills),w=!1,me=!1,he=!1,ge=!1,ve=!1,ye=[];for(let t of Ce){if(!ue.has(t))continue;await ie(le,Te[t],!0).catch(()=>{}),w=!0;let n=await se({home:e.home,bundleId:t,force:!0});ye.push({bundleId:t,result:n}),n===`installed`?me=!0:n===`failed`?he=!0:n===`no-hosts`?ve=!0:ge=!0}let xe=he?`failed`:me?`installed`:w&&ge?`skip-current`:w&&ve?`no-hosts`:`declined`,Se=me?_e(le).map(e=>e.editorId):[],Ee=fe(le).enabled&&!we(),De=v?`skipped-flag`:`skipped-missing`,Ae=x.find(e=>e.editorId===`claude`)??x[0]??{action:De,configPath:$.claude.configPath(r,e.home)},Me=await Ko({projectRoot:r,desiredMode:await ko({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:x,projectSkills:S,legacyProjectConfigs:oe,skillInstall:xe,skillBundles:ye,skillsRequested:e.skills,skillHosts:Se,skillInstallsCounted:Ee,didGitInit:c.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Ae.action,mcpPath:Ae.configPath,mcpError:`error`in Ae?Ae.error:void 0,projectScopeUnsupportedLabels:re,sharing:Me}}async function Ko(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=ea(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=Xi(t);if(n===`local-only`){let e=Qi(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`}:qo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=$i(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:qo(t,o,`remove`)}function qo(e,t,n){let r=ea(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 Jo(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 Yo(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=j(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(O(`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(O(`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(O(`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(O(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(O(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?M(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===f()?``:` (${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} ${E(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${E(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${Pe(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Jo(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(O(`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?M(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${E(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${E(`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} ${Pe(`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} ${M(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===`declined`)n.push(``),n.push(O(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${T(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${Ce.join(`, `)})`)}`),n.push(` ${T(`No user-global skill was installed or removed.`)}`)):(n.push(` ${T(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${T(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${T(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${T(` ok init`)}`),n.push(` ${T(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(O(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>Te[e.bundleId].length));for(let i of t){let t=Te[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${E(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${E(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${T(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${D(`${t} install failed`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${T(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${T(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${D(`Retry with: ok repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(D(`⚠ --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(D(`⚠ 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(Ie(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...es(e.sharing,t));let c=e=>[`${e}- ${Ne(`ok seed --list-packs`)} — browse the starter packs`,`${e}- ${Ne(`ok seed`)} — scaffold an empty repo`];if(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(`${E(`✓`)} ${O(`Next steps:`)}`),n.push(` 1. Open your editor (${Ne(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...c(` `))),n.push(` ${i}. 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.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${O(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...c(` `)));return n.join(`
691
- `)}function Xo(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 Zo(e,t){let n=[];for(let r of Qr)r!==`claude-desktop`&&Fo($[r],e,t)&&n.push(r);return n}function Qo(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:et(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 $o(){return new vt(`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 bt(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new bt(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new bt(`--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?Qo():null;try{let r;try{r=await Go({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Ao||e instanceof ce){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof ue||e instanceof me){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof ye){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-CQKOpKdM.mjs`),{resolveContentDir:s}=await import(`./dist-CvUzxHSS.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-CXeJgzGh.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(Xo(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Yo(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function es(e,t){let n=[];switch(e.kind){case`applied`:return n.push(O(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${E(`local-only`)} — appended ${e.appended.length} path(s) to ${O(`${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(` ${E(`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(` ${E(`local-only`)} — already excluded; nothing to do.`):n.push(` ${E(`local-only`)}`):e.action===`removed`?n.push(` ${E(`shared`)} — removed OK paths from ${O(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${E(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(D(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
693
- `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${Ne(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(D(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${Ne(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${Ne(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(D(`Sharing mode unavailable: ${e.reason}.`));return n}}export{Di as $,Ma as A,Qi as B,Qa as C,vt as Ct,Ba as D,Ga as E,ma as F,na as G,ta as H,ha as I,Qr as J,ea as K,Ea as L,Da as M,pa as N,ja as O,_a as P,Z as Q,va as R,ro as S,At as St,qa as T,bt as Tt,Zi as U,oa as V,Xi as W,$ as X,X as Y,$r as Z,Go as _,Xn as _t,Xo as a,Ai as at,Vo as b,nn as bt,Yo as c,Hi as ct,Fo as d,Xr as dt,Ei as et,Ho as f,Y as ft,ko as g,sr as gt,Mo as h,Hr as ht,Ko as i,fi as it,Oa as j,Aa as k,es as l,gi as lt,Do as m,zr as mt,Po as n,ki as nt,Wo as o,Q as ot,jo as p,Br as pt,$i as q,Ro as r,li as rt,Zo as s,ji as st,Ao as t,Oi as tt,$o as u,Zr as ut,go as v,sn as vt,Ya as w,gt as wt,Io as x,V as xt,Lo as y,rn as yt,Ta as z};
689
+ `));let g=`${s?``:``}${m}`;return g!==o&&T(e,g,{mode:Na(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const Eo=e=>e!==`project`,Do=e=>e!==`user`;async function Oo(){let e=await Ha({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 ko(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Oo)():`both`}async function Ao(e){return qa({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 jo(e){if(e.sharing!==void 0)return e.sharing;let t=na(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Ao)(t):t}var Mo=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function No(e){if(e===void 0||e===!0)return new Set(we);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(ae.filter(e=>t.includes(e)))}function Po(e,t,n){let r=F(n,e),i;try{i=Qe(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Mo(`--content-dir path does not exist: ${r}`):new Mo(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Mo(`--content-dir must be a directory: ${r}`);let a=Fo(t),o=Fo(r),s=P(a,o);if(s.startsWith(`..`)||Ve(s))throw new Mo(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Fo(e){try{return Xe(e)}catch{return e}}const Io=`open-knowledge-ui`;function Lo(e,t,n){try{let r=e.detectPath?.(t,n)??M(e.configPath(t,n));return R(r)}catch{return!1}}function Ro(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 zo(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||Ro(e,t,r);if(!i&&c&&!Lo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{ga(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 Vo(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||qe(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{E(`${o}.lock`,()=>{let t=ao(o).writePath;if(s||qe(M(t),{recursive:!0}),e.format===`toml`){let r=So(Qr(),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=To(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=xo(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 Bo={pi:Za};function Vo(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=Bo[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{qe(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{E(`${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:Na(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 Ho(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function Uo(e){let t=Yi(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=>zo(t,``,n,e.home))}function Wo(e,t,n,r){let i=Ko(e,t,n,r);return i.kind===`present`?i.entry:null}function Go(e,t,n,r){let i=bo(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 Ko(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(Qe(i).size>mo)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:ka(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:ka(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Xa(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Qr().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Go(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,zr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Go(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=co(a);return s?lo(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Go(w(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function qo(e={}){let t=F(e.cwd??process.cwd()),n=eo(t,{homeDir:e.home}),r=n.projectRoot;if(ge(r,e.home??B()))throw new pe(r);if(je(r))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:Po(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),u;try{u=se(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 d=u.created.includes(Fe),f=!1;if(c.didInit)try{f=de(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{Se(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 p=await ko({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??$o(r,e.home),h=e.editors??m,g=Yi(m),_=Yi(h),v=e.mcp===!1||p===null,y=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),b=g.filter(t=>Lo(t,r,e.home)),x=[],S=[],C=new Set;for(let t of y){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}x.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Eo(p)&&g.includes(t)&&t.scope===`global`&&x.push(zo(t,r,s,e.home)),Do(p)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=zo(t,r,s,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&C.add(n)}}let ee=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||ee.has(n)||(ee.add(n),S.push(Da(t,r,{home:e.home})))}let te=Ea(r,_.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();Oe({source:l,skills:[Ee.project],agents:ne,scope:r},{home:t,enabled:ie(t).enabled})}let re=!v&&p!==null&&Do(p)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ce=v?[]:b.map(e=>Ho(e,r)).filter(e=>e!==void 0).filter(e=>!C.has(e.path)),le=e.installUserSkill??me,w=e.home??B(),fe=No(e.skills),he=!1,ve=!1,ye=!1,xe=!1,T=!1,we=[];for(let t of ae){if(!fe.has(t))continue;await ue(w,Ee[t],!0).catch(()=>{}),he=!0;let n=await le({home:e.home,bundleId:t,force:!0});we.push({bundleId:t,result:n}),n===`installed`?ve=!0:n===`failed`?ye=!0:n===`no-hosts`?T=!0:xe=!0}let Te=ye?`failed`:ve?`installed`:he&&xe?`skip-current`:he&&T?`no-hosts`:`declined`,De=ve?_e(w).map(e=>e.editorId):[],ke=ie(w).enabled&&!be(),Ae=v?`skipped-flag`:`skipped-missing`,E=x.find(e=>e.editorId===`claude`)??x[0]??{action:Ae,configPath:$.claude.configPath(r,e.home)},Me=await Jo({projectRoot:r,desiredMode:await jo({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:x,projectSkills:S,legacyProjectConfigs:ce,skillInstall:Te,skillBundles:we,skillsRequested:e.skills,skillHosts:De,skillInstallsCounted:ke,didGitInit:c.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:re,sharing:Me}}async function Jo(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=na(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=Qi(t);if(n===`local-only`){let e=ea(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`}:Yo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=ta(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Yo(t,o,`remove`)}function Yo(e,t,n){let r=na(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 Xo(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 Zo(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===f()?``:` (${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} ${Pe(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Xo(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} ${Pe(`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===`declined`)n.push(``),n.push(A(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${D(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${ae.join(`, `)})`)}`),n.push(` ${D(`No user-global skill was installed or removed.`)}`)):(n.push(` ${D(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${D(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ok init`)}`),n.push(` ${D(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(A(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>Ee[e.bundleId].length));for(let i of t){let t=Ee[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${O(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${O(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`${t} install failed`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(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.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${k(`Retry with: ok repair-skills`)}`)}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(Ie(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...ns(e.sharing,t));let c=e=>[`${e}- ${Ne(`ok seed --list-packs`)} — browse the starter packs`,`${e}- ${Ne(`ok seed`)} — scaffold an empty repo`];if(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 (${Ne(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...c(` `))),n.push(` ${i}. 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.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${A(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...c(` `)));return n.join(`
691
+ `)}function Qo(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 $o(e,t){let n=[];for(let r of ei)r!==`claude-desktop`&&Lo($[r],e,t)&&n.push(r);return n}function es(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:et(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 ts(){return new vt(`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 bt(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new bt(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new bt(`--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?es():null;try{let r;try{r=await qo({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Mo||e instanceof pe||e instanceof oe){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof fe||e instanceof Me){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof De){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-C1wr_xdg.mjs`),{resolveContentDir:s}=await import(`./dist-CI4jGrUv.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-BHzfKSsK.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(Qo(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Zo(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function ns(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
+ `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${Ne(`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 ${Ne(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${Ne(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(k(`Sharing mode unavailable: ${e.reason}.`));return n}}export{ki as $,Pa as A,ea as B,eo as C,vt as Ct,Ha as D,qa as E,ga as F,ia as G,ra as H,_a as I,ei as J,na as K,Oa as L,ka as M,ha as N,Na as O,ya as P,Z as Q,ba as R,ao as S,At as St,Ya as T,bt as Tt,$i as U,ca as V,Qi as W,$ as X,X as Y,ti as Z,qo as _,Zn as _t,Qo as a,Mi as at,Uo as b,nn as bt,Zo as c,Wi as ct,Lo as d,Qr as dt,Oi as et,Wo as f,Y as ft,jo as g,cr as gt,Po as h,Wr as ht,Jo as i,mi as it,Aa as j,Ma as k,ns as l,vi as lt,ko as m,Vr as mt,Io as n,ji as nt,Ko as o,Q as ot,No as p,Hr as pt,ta as q,Bo as r,di as rt,$o as s,Ni as st,Mo as t,Ai as tt,ts as u,$r as ut,vo as v,sn as vt,Za as w,gt as wt,Ro as x,U as xt,zo as y,rn as yt,Da as z};