@inkeep/open-knowledge 0.37.1 → 0.37.3

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 (111) hide show
  1. package/dist/{acp-harness-probe-BaXcmDE0.mjs → acp-harness-probe-N1sSMZGg.mjs} +2 -2
  2. package/dist/assets/skills/discovery/SKILL.md +1 -1
  3. package/dist/assets/skills/project/SKILL.md +1 -1
  4. package/dist/assets/skills/write-skill/SKILL.md +1 -1
  5. package/dist/cli.mjs +62 -63
  6. package/dist/constants-CchUdUMd.mjs +2 -0
  7. package/dist/{git-handle-Dn9o6II0.mjs → git-handle-BNHoFrny.mjs} +2 -2
  8. package/dist/git-handle-CBwvOa-O.mjs +1 -0
  9. package/dist/index.d.mts +12 -1
  10. package/dist/index.mjs +1 -1
  11. package/dist/init-AZMgQ3nS.mjs +1 -0
  12. package/dist/init-CBfUP8hN.mjs +643 -0
  13. package/dist/{launch-json-removal-BNpNXmQG.mjs → launch-json-removal-RCdxWSel.mjs} +2 -2
  14. package/dist/{loader-Cz_WhlON.mjs → loader-DcESlMxI.mjs} +2 -2
  15. package/dist/loader-EZiQC7cG.mjs +1 -0
  16. package/dist/{open-browser-BTGfTWF8.mjs → open-browser-DGOoelb3.mjs} +2 -2
  17. package/dist/{preview-DJt8zOrQ.mjs → preview-Bt-_RLQB.mjs} +2 -2
  18. package/dist/preview-DGyDBzMH.mjs +1 -0
  19. package/dist/public/assets/{ActivityModeContent-fBC0Voik.js → ActivityModeContent-Cgqa56C2.js} +1 -1
  20. package/dist/public/assets/{AgentDiffPane-ChHaUBEu.js → AgentDiffPane-BnvGYsRG.js} +1 -1
  21. package/dist/public/assets/{AgentThreadClientBinder-BMUA20Qq.js → AgentThreadClientBinder-Dzf4FbOU.js} +1 -1
  22. package/dist/public/assets/{CodeMirrorPropInput-0TqZTWBW.js → CodeMirrorPropInput-Cx9FW420.js} +3 -3
  23. package/dist/public/assets/{DocumentContext-BcosLIs9.js → DocumentContext-Dog3N-Wc.js} +17 -17
  24. package/dist/public/assets/{EnableSyncConfirmDialog-Bo_sKBNs.js → EnableSyncConfirmDialog-DtYm7V_O.js} +1 -1
  25. package/dist/public/assets/{GraphPanel-CpJnEgaj.js → GraphPanel-CvqA9xnU.js} +1 -1
  26. package/dist/public/assets/{ManagedArtifactProperties-Cq1ODSN4.js → ManagedArtifactProperties-67a94DaU.js} +1 -1
  27. package/dist/public/assets/{McpConsentDialogBody-hjXtWWhb.js → McpConsentDialogBody-KLslh1LR.js} +1 -1
  28. package/dist/public/assets/{MermaidDocEditor-Bxza5rNh.js → MermaidDocEditor-DH7WRAfL.js} +1 -1
  29. package/dist/public/assets/{PropertyPanel-BoUU2Tf8.js → PropertyPanel-BoKsESSi.js} +1 -1
  30. package/dist/public/assets/{ReportBugDialogBody-CYIt3IGK.js → ReportBugDialogBody-Dg8V3ei2.js} +1 -1
  31. package/dist/public/assets/SettingsDialogBody-DVTTk_BU.js +7 -0
  32. package/dist/public/assets/{ShareBranchSwitchDialog-BDTs1Q1p.js → ShareBranchSwitchDialog-l3OatXNl.js} +1 -1
  33. package/dist/public/assets/ShareReceiveDialog-DuvJdcqg.js +1 -0
  34. package/dist/public/assets/{ShareReceiveMissDialog-Dh6JMbsb.js → ShareReceiveMissDialog-DLNWM2Pm.js} +1 -1
  35. package/dist/public/assets/{SkillEditorActions-NiL9cPXX.js → SkillEditorActions-B5cWxK9p.js} +1 -1
  36. package/dist/public/assets/{SourceEditor-DAvUlAy0.js → SourceEditor-yoaSx3d8.js} +1 -1
  37. package/dist/public/assets/{TerminalPanel-OeXRTBwe.js → TerminalPanel-D3vyvoTf.js} +1 -1
  38. package/dist/public/assets/TerminalSessionsHost-D500Eh7g.js +2 -0
  39. package/dist/public/assets/{TerminalWindowApp-CH4As48E.js → TerminalWindowApp-aWCNBKLz.js} +1 -1
  40. package/dist/public/assets/{ThreadView-BsUfIPqU.js → ThreadView-nnZWrgGO.js} +1 -1
  41. package/dist/public/assets/{TimelineDiffPane-DsFAdXX4.js → TimelineDiffPane-B7O4osuT.js} +1 -1
  42. package/dist/public/assets/{agent-diff-store-CmFPaGyV.js → agent-diff-store-DuUxJBjU.js} +1 -1
  43. package/dist/public/assets/{agent-visibility-BKHfJySh.js → agent-visibility-D2Mr5Jzk.js} +1 -1
  44. package/dist/public/assets/{auth-state-cache-CnAAGiPA.js → auth-state-cache-CEBkZrQO.js} +7 -7
  45. package/dist/public/assets/{config-provider-DMJrhWUp.js → config-provider-pXCSDe7I.js} +2 -2
  46. package/dist/public/assets/dist-CAKhzFlX.js +124 -0
  47. package/dist/public/assets/{dist-CJUUFO9W.js → dist-DZ_OIHsD.js} +1 -1
  48. package/dist/public/assets/{dist-D6R8vG-1.js → dist-zc03OoUp.js} +2 -2
  49. package/dist/public/assets/{doc-hash-sxvnKnL5.js → doc-hash-D8EI7kHA.js} +1 -1
  50. package/dist/public/assets/{documents-events-Bd2Tt95I.js → documents-events-BTDcCELc.js} +1 -1
  51. package/dist/public/assets/{file-tree-adapter-Cl9Gep-E.js → file-tree-adapter-BJqJ74LH.js} +1 -1
  52. package/dist/public/assets/index-1TeKfA3W.js +1995 -0
  53. package/dist/public/assets/index-CJ_7DqKn.css +1 -0
  54. package/dist/public/assets/{keyboard-shortcuts-ziymY5lY.js → keyboard-shortcuts-g08DUgcY.js} +1 -1
  55. package/dist/public/assets/{lint-config-client-B4tvFSj6.js → lint-config-client-BcxnEgHO.js} +1 -1
  56. package/dist/public/assets/{navigation-targets-CdngrI3e.js → navigation-targets-DUt4VF6E.js} +1 -1
  57. package/dist/public/assets/{open-managed-artifact-tab-CLJdEdvs.js → open-managed-artifact-tab-CRLFq4-B.js} +1 -1
  58. package/dist/public/assets/{pending-receive-nav-store-pcoVj0T5.js → pending-receive-nav-store-C4eKkzcx.js} +1 -1
  59. package/dist/public/assets/{prop-types-DIMZw1aA.js → prop-types-CBBOToAL.js} +1 -1
  60. package/dist/public/assets/{receive-store-CnAYtEWn.js → receive-store-nuIidOiz.js} +1 -1
  61. package/dist/public/assets/{selection-context-BLlRaGhH.js → selection-context-DgIDY04o.js} +1 -1
  62. package/dist/public/assets/{skill-actions-D_uHXMrN.js → skill-actions-DzaHqGRg.js} +1 -1
  63. package/dist/public/assets/{skills-api-CMDs_cbJ.js → skills-api-BOe6s3mN.js} +1 -1
  64. package/dist/public/assets/{src-DPcWwhgv.js → src-gANoUa2-.js} +1 -1
  65. package/dist/public/assets/{target-navigation-intent-BojcuU7o.js → target-navigation-intent-DzXHO48d.js} +1 -1
  66. package/dist/public/assets/{telemetry-impl-CDBAVJb9.js → telemetry-impl-ClWP6_iI.js} +1 -1
  67. package/dist/public/assets/{telemetry-startup-CZwQc5d3.js → telemetry-startup-D0otGNQT.js} +1 -1
  68. package/dist/public/assets/{terminal-launch-events-fYxl8byx.js → terminal-launch-events-BcKnMQ0G.js} +1 -1
  69. package/dist/public/assets/{terminal-telemetry-YHplv3Gm.js → terminal-telemetry-B-c91nRO.js} +1 -1
  70. package/dist/public/assets/{typing-burst-detector-rg4heHQj.js → typing-burst-detector-B_jwquxb.js} +1 -1
  71. package/dist/public/assets/{use-activity-panel-DXQ7UC10.js → use-activity-panel-Ds1FSy22.js} +1 -1
  72. package/dist/public/assets/{use-apply-config-color-theme-Bb_FV0b5.js → use-apply-config-color-theme-CTTOdBYC.js} +1 -1
  73. package/dist/public/assets/{use-collab-url-xyz-Nyoe.js → use-collab-url-DJN-Eh99.js} +1 -1
  74. package/dist/public/assets/{use-live-xterm-theme-qqv_COHj.js → use-live-xterm-theme-BVrjqV4f.js} +1 -1
  75. package/dist/public/assets/{use-terminal-enabled-CoqSHX6g.js → use-terminal-enabled-WZKABQLf.js} +1 -1
  76. package/dist/public/assets/{use-timeline-entry-diff-vDsLY3JP.js → use-timeline-entry-diff-DD8d8a6p.js} +1 -1
  77. package/dist/public/assets/{use-workspace--VMy_KL1.js → use-workspace-CqL9iZdQ.js} +1 -1
  78. package/dist/public/assets/{workspace-paths-0CCDk_CH.js → workspace-paths-d9KyFHx6.js} +1 -1
  79. package/dist/public/index.html +34 -34
  80. package/dist/{repair-launch-json-QySpBNGz.mjs → repair-launch-json-zFpMB98b.mjs} +2 -2
  81. package/dist/{repair-mcp-configs-BnLNbEPY.mjs → repair-mcp-configs-BooTRwN8.mjs} +2 -2
  82. package/dist/repair-skills-DXhO-R2J.mjs +1 -0
  83. package/dist/{repair-skills-my6e7ABJ.mjs → repair-skills-M9d8MZVm.mjs} +2 -2
  84. package/dist/server-lock-3eYo5zvq.mjs +1 -0
  85. package/dist/{server-lock-BCKlDt3u.mjs → server-lock-DfCsjalw.mjs} +2 -2
  86. package/dist/src-CDixjEaS.mjs +3262 -0
  87. package/dist/src-CL0d0X9t.mjs +1 -0
  88. package/dist/{src-CB6BqwdE.mjs → src-CXOotH7J.mjs} +109 -109
  89. package/dist/src-DRGXfsmB.mjs +21 -0
  90. package/dist/{start-BzmMNHPk.mjs → start-CJDgfxsl.mjs} +2 -2
  91. package/dist/start-DWQUoMMz.mjs +1 -0
  92. package/dist/{write-project-skill-BIiTrHhN.mjs → write-project-skill-B7oIs3rt.mjs} +4 -4
  93. package/package.json +5 -5
  94. package/dist/constants-BtC4Ad17.mjs +0 -2
  95. package/dist/git-handle-CeDCG6sj.mjs +0 -1
  96. package/dist/init-B-c_JFb0.mjs +0 -1
  97. package/dist/init-CCXK-jEf.mjs +0 -643
  98. package/dist/loader-Cc0XghVD.mjs +0 -1
  99. package/dist/preview-BS1Ouf2D.mjs +0 -1
  100. package/dist/public/assets/SettingsDialogBody-Ya-LreoD.js +0 -7
  101. package/dist/public/assets/ShareReceiveDialog-B2mln2_V.js +0 -1
  102. package/dist/public/assets/TerminalSessionsHost-uEP7qR5I.js +0 -2
  103. package/dist/public/assets/dist-CG58rUCC.js +0 -113
  104. package/dist/public/assets/index-CD3OM1Xi.js +0 -1995
  105. package/dist/public/assets/index-DS4HqlZl.css +0 -1
  106. package/dist/repair-skills-ZB7QzRgz.mjs +0 -1
  107. package/dist/server-lock-BrjnkHOv.mjs +0 -1
  108. package/dist/src-5hx6F-Ql.mjs +0 -3262
  109. package/dist/src-B1d5f35Y.mjs +0 -21
  110. package/dist/src-BuzTw3li.mjs +0 -1
  111. package/dist/start-DkuS68HX.mjs +0 -1
@@ -0,0 +1,643 @@
1
+ import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{A as r,D as i,Da as a,ua as o}from"./src-CXOotH7J.mjs";import{$n as s,$t as c,Hn as l,Mn as u,Nr as d,Tn as f,Vn as p,c as m,en as h,er as g,fa as _,fn as v,in as y,l as b,nn as x,pn as S,rr as C,tr as ee,u as te}from"./src-CDixjEaS.mjs";import{U as w}from"./sleep-DcENuR74.mjs";import{M as T,P as E}from"./fs-traced-DamTBe_K.mjs";import{C as ne,S as re,T as D,a as ie,d as O,g as ae,h as oe,i as se,m as ce,p as le,s as ue,t as de}from"./write-project-skill-B7oIs3rt.mjs";import{t as fe}from"./constants-CchUdUMd.mjs";import{t as k}from"./is-object-DKopTkoU.mjs";import{i as A,n as pe,o as j,r as me,s as M,t as N}from"./colors-BslXS0bZ.mjs";import{t as he}from"./preview-Bt-_RLQB.mjs";import{createRequire as ge}from"node:module";import{execFileSync as _e}from"node:child_process";import P,{dirname as F,isAbsolute as ve,join as I,relative as L,resolve as ye,sep as be}from"node:path";import{existsSync as R,lstatSync as xe,mkdirSync as Se,readFileSync as z,readlinkSync as Ce,realpathSync as we,statSync as Te,writeFileSync as Ee}from"node:fs";import{homedir as De}from"node:os";import B from"node:process";import{fileURLToPath as Oe}from"node:url";import*as ke from"node:readline";import{inspect as Ae,stripVTControlCharacters as je,styleText as V}from"node:util";import{AsyncLocalStorage as Me,AsyncResource as Ne}from"node:async_hooks";const Pe=new Set([`emacs`,`vim`]);function Fe(e){return Pe.has(e)}function Ie(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Fe))):[]}const H=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Le=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Re=e=>e.name===`space`,ze=e=>e.name===`backspace`,Be=e=>`1234567890`.includes(e.name),Ve=e=>e.name===`enter`||e.name===`return`;var He=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Ue=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},We=class extends Error{name=`ExitPromptError`},Ge=class extends Error{name=`HookError`},Ke=class extends Error{name=`ValidationError`};const qe=new Me;function Je(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Ye(e,t){let n=Je(e);return qe.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function U(){let e=qe.getStore();if(!e)throw new Ge(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function Xe(){return U().rl}function Ze(e){return Ne.bind((...t)=>{let n=U(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function Qe(e){let t=U(),{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 $e(){U().handleChange()}const et={queue(e){let t=U(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(Xe());if(r!=null&&typeof r!=`function`)throw new Ke(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=U();Ze(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=U();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function tt(e){return typeof e==`function`}function W(e){return Qe(t=>{let n=Ne.bind(function(e){t.get()!==e&&(t.set(e),$e())});if(t.initialized)return[t.get(),n];let r=tt(e)?e():e;return t.set(r),[r,n]})}function nt(e,t){Qe(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&et.queue(e),n.set(t)})}function rt(){return B.platform.startsWith(`win`)?!!B.env.CI||!!B.env.WT_SESSION||!!B.env.TERMINUS_SUBLIME||B.env.ConEmuTask===`{cmd::Cmder}`||B.env.TERM_PROGRAM===`Terminus-Sublime`||B.env.TERM_PROGRAM===`vscode`||B.env.TERM===`xterm-256color`||B.env.TERM===`alacritty`||B.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:B.env.TERM!==`linux`}const it={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:`╱`},at={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:`⅒`},ot={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`},st={...it,...at},ct={...it,...ot},G=rt()?st:ct;Object.entries(at);const lt={prefix:{idle:V(`blue`,`?`),done:V(`green`,G.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 ut(){return{...lt,keybindings:Ie()}}function dt(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 ft(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=dt(n)&&dt(r)?ft(n,r):r}return t}function pt(...e){return ft(ut(),...e.filter(e=>e!=null))}function mt({status:e=`idle`,theme:t}){let[n,r]=W(!1),[i,a]=W(0),{prefix:o,spinner:s}=pt(t);return nt(()=>{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)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function ht(e,t){return Qe(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 gt(e){return W({current:e})[0]}function _t(e){let t=gt(e);t.current=e,nt(e=>{let n=!1,r=Ze((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var vt=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 yt=(()=>{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}})(),bt=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,xt=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,St=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ct=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,wt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Tt=/\t{1,1000}/y,Et=/[\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,Dt=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Ot=/\p{M}+/gu,kt={limit:1/0,ellipsis:``},At=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?At(i,kt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Dt,l],[St,0],[Ct,o],[Tt,s],[Et,c],[wt,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(Ot,``)){let t=e.codePointAt(0)||0;if(S=bt(t)?2:xt(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===wt?yt(e.slice(p,n.lastIndex)):n===Et?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}},jt={limit:1/0,ellipsis:``,ellipsisWidth:0},K=(e,t={})=>At(e,jt,t).width,Mt=`]8;;`,Nt=RegExp(`(?:\\[(?<code>\\d+)m|\\${Mt}(?<uri>.*))`,`y`),Pt=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},Ft=e=>`[${e}m`,It=e=>`${Mt}${e}`,Lt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:K(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=K(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Mt,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())},Rt=e=>{let t=e.split(` `),n=t.length;for(;n&&!K(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},zt=(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=K(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=K(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(``),Lt(s,r,t),c=K(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Lt(s,r,t),c=K(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Lt(s,r,t),c=K(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Rt(e)));let l=s.join(`
2
+ `),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===`›`){Nt.lastIndex=e+1;let t=Nt.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]===`
3
+ `){a&&(r+=It(``));let e=i?Pt(i):void 0;i&&e&&(r+=Ft(e))}else t===`
4
+ `&&(i&&Pt(i)&&(r+=Ft(i)),a&&(r+=It(a)))}return r},Bt=/\r?\n/;function Vt(e,t,n){return String(e).normalize().split(Bt).map(e=>zt(e,t,n)).join(`
5
+ `)}function Ht(e,t){return e.split(`
6
+ `).flatMap(e=>Vt(e,t,{trim:!1,wordWrap:!1}).split(`
7
+ `).map(e=>e.trimEnd())).join(`
8
+ `)}function Ut(){return(0,vt.default)({defaultWidth:80,output:Xe().output})}function Wt({active:e,renderedItems:t,pageSize:n,loop:r}){let i=gt({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 Gt({items:e,active:t,renderItem:n,pageSize:r,loop:i=!0}){let a=Ut(),o=t=>(t%e.length+e.length)%e.length,s=e.map((e,r)=>e==null?[]:Ht(n({item:e,index:r,isActive:r===t}),a).split(`
9
+ `)),c=s.reduce((e,t)=>e+t.length,0),l=e=>s[e]??[],u=Wt({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(`
10
+ `)}var Kt=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 q=[];q.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&q.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&q.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const qt=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`,Jt=Symbol.for(`signal-exit emitter`),Yt=globalThis,Xt=Object.defineProperty.bind(Object);var Zt=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Yt[Jt])return Yt[Jt];Xt(Yt,Jt,{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}},Qt=class{};const $t=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var en=class extends Qt{onExit(){return()=>{}}load(){}unload(){}},tn=class extends Qt{#e=nn.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new Zt;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of q)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(!qt(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 q)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,q.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 qt(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`&&qt(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}else return n.call(this.#n,e,...t)}};const nn=globalThis.process,{onExit:rn,load:an,unload:on}=$t(qt(nn)?new tn(nn):new en),sn=`\x1B[?25l`,cn=(e=1)=>e>0?`[${e}A`:``,ln=(e=1)=>e>0?`[${e}B`:``,un=(e,t)=>typeof t==`number`&&!Number.isNaN(t)?`[${t+1};${e+1}H`:`[${e+1}G`,dn=`\x1B[2K`,fn=e=>e>0?(dn+cn(1)).repeat(e-1)+dn+`\x1B[G`:``,pn=e=>e.split(`
11
+ `).length,mn=e=>e.split(`
12
+ `).pop()??``;var hn=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=je(mn(e)),r=n;this.rl.line.length>0&&(r=r.slice(0,-this.rl.line.length)),this.rl.setPrompt(r),this.cursorPos=this.rl.getCursorPos();let i=Ut();e=Ht(e,i),t=Ht(t,i),n.length%i===0&&(e+=`
13
+ `);let a=e+(t?`
14
+ `+t:``),o=Math.floor(n.length/i)-this.cursorPos.rows+(t?pn(t):0);o>0&&(a+=cn(o)),a+=un(this.cursorPos.cols),this.write(ln(this.extraLinesUnderPrompt)+fn(this.height)+a),this.extraLinesUnderPrompt=o,this.height=pn(a)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(un(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt(``);let t=ln(this.extraLinesUnderPrompt);t+=e?fn(this.height):`
15
+ `,t+=`\x1B[G`,t+=`\x1B[?25h`,this.write(t),this.rl.close()}},gn=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}};const _n=globalThis.setImmediate;function vn(){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 yn(e){let t=vn();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,s=new Kt.default;s.pipe(r.output??process.stdout);let c=ke.createInterface({terminal:!0,input:i,output:s});s.mute();let l=new hn(c),{promise:u,resolve:d,reject:f}=gn.withResolver(),p=()=>f(new Ue);if(a){let e=()=>f(new He({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(rn((e,t)=>{f(new We(`User force closed the prompt with ${e} ${t}`))}));let m=()=>f(new We(`User force closed the prompt with SIGINT`));return c.on(`SIGINT`,m),o.add(()=>c.removeListener(`SIGINT`,m)),Ye(c,a=>{let m=Ne.bind(()=>et.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=P.resolve(e)),Error(`Prompt functions must return a string.\n at ${e}`)}let[o,s]=typeof a==`string`?[a]:a;l.render(o,s),et.run()}catch(e){f(e)}if(r=!0,i!==null){let{value:e}=i;i=null,d(e)}})};return`readableFlowing`in i?_n(h):h(),Object.assign(u.then(e=>(et.clearAll(),e),e=>{throw et.clearAll(),e}).finally(()=>{o.forEach(e=>e()),l.done({clearContent:!!r.clearPromptOnDone}),s.end()}).then(()=>u),{cancel:p})})}}var J=class{separator=V(`dim`,Array.from({length:15}).join(G.line));type=`separator`;constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`separator`)}},bn=w();const xn=`.ok/`,Sn=`**/.ok/*`,Cn=`!**/${a}/`;function wn(e){let t=[`.ok/`,`.okignore`];for(let n of ue){let r=O[n];r.projectConfigPath&&t.push(In(r.projectConfigPath(e),e))}t.push(`.claude/launch.json`);let n=I(e,...i);if(R(n))try{let e=r(z(n,`utf-8`));if(e){for(let[n,r]of Object.entries(e.skills))if(n!==`open-knowledge`)for(let e of r.hosts){let r=o[e];r&&t.push(`${r}/${n}/`)}}}catch{}return Array.from(new Set(t))}function Tn(e,t){let n=jn(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:Mn(n)};let r=Y(e);if(r.kind!==`ok`)return r.result;let i=R(r.path)?z(r.path,`utf-8`):``,a=Fn(i),o=[],s=[];for(let e of t)Pn(a,e)?s.push(e):o.push(e);if(o.length===0)return{kind:`updated`,appended:o,alreadyPresent:s,removed:[]};let c=i.length===0||i.endsWith(`
16
+ `)?``:`
17
+ `,l=`${o.join(`
18
+ `)}\n`;try{Ee(r.path,`${i}${c}${l}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:o,alreadyPresent:s,removed:[]}}function En(e,t){let n=Y(e);if(n.kind!==`ok`)return n.result;if(!R(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>Nn(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(Sn),i.add(Cn);let a;try{a=z(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let o=a.split(`
19
+ `),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=t.filter(e=>{for(let t of Nn(e))if(s.has(t))return!0;return!1});if(s.size===0)return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let u=c.join(`
20
+ `);if(u!==a)try{Ee(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function Dn(e){let t=Y(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=Fn(n),i=wn(e);for(let e of i)if(Pn(r,e))return`local-only`;return r.has(Sn)?`local-only`:`shared`}function On(e){let t=Y(e);if(t.kind!==`ok`||!R(t.path))return[];let n;try{n=z(t.path,`utf-8`)}catch{return[]}let r=Fn(n);return wn(e).filter(e=>Pn(r,e))}function kn(e){let t=Y(e);if(t.kind!==`ok`||!R(t.path))return!1;let n;try{n=z(t.path,`utf-8`)}catch{return!1}let r=Fn(n);return r.has(Sn)&&r.has(Cn)}function An(e,t){let n=Y(e);if(n.kind!==`ok`)return n.result;let r=``;if(R(n.path))try{r=z(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let i=new Set([...Nn(xn),Sn,Cn]),a=r.split(`
21
+ `).filter(e=>!i.has(e.trim())),o=t?[Sn,Cn]:[xn],s=a.join(`
22
+ `),c=`${s}${s.length===0||s.endsWith(`
23
+ `)?``:`
24
+ `}${o.join(`
25
+ `)}\n`;try{Ee(n.path,c,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:o,alreadyPresent:[],removed:[]}}function jn(e,t){let n=[];for(let r of t)if(R(ye(e,r)))try{_e(`git`,[`ls-files`,`--error-unmatch`,`--`,r],d({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}return{tracked:n}}function Mn(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}${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(`
26
+ `)}function Y(e){let t=_(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=I(e.path,`info`);return R(n)?{kind:`ok`,path:I(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 Nn(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function Pn(e,t){for(let n of Nn(t))if(e.has(n))return!0;return!1}function Fn(e){let t=new Set;for(let n of e.split(`
27
+ `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function In(e,t){return Ln(L(t,e))}function Ln(e){return be===`/`?e:e.split(be).join(`/`)}function Rn(e){for(let t of e.split(`
28
+ `)){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 zn(e){let t=(e.match(/\r\n/g)??[]).length;return t===0?!1:t>=(e.match(/\n/g)??[]).length-t}function Bn(e){try{return Te(e).mode&511}catch{return}}function Vn(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
29
+ `)?`\r
30
+ `:`
31
+ `,a=ee(r,t,void 0,{formattingOptions:{...Rn(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${s(r,a)}`;return{text:o,changed:o!==e}}const Hn={icon:{checked:V(`green`,G.circleFilled),unchecked:G.circle,cursor:G.pointer,disabledChecked:V(`green`,G.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 Un(e){return!J.isSeparator(e)&&!e.disabled}function Wn(e){return!J.isSeparator(e)}function Gn(e){return!J.isSeparator(e)&&e.checked}function Kn(e){return Un(e)?{...e,checked:!e.checked}:e}function qn(e){return function(t){return Un(t)?{...t,checked:e}:t}}function Jn(e){return e.map(e=>{if(J.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 Yn=yn((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=pt(Hn,e.theme),{keybindings:c}=s,[l,u]=W(`idle`),d=mt({status:l,theme:s}),[f,p]=W(Jn(e.choices)),m=ht(()=>{let e=f.findIndex(Wn),t=f.findLastIndex(Wn);if(e===-1)throw new Ke(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=W(m.first),[_,v]=W();_t(async e=>{if(Ve(e)){let e=f.filter(Gn),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(H(e,c)||Le(e,c)){if(_&&v(void 0),r||H(e,c)&&h!==m.first||Le(e,c)&&h!==m.last){let t=H(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Wn(f[n]));g(n)}}else if(Re(e)){let e=f[h];e&&!J.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?Kn(e):e))))}else if(e.name===o.all){let e=f.some(e=>Un(e)&&!e.checked);p(f.map(qn(e)))}else if(e.name===o.invert)p(f.map(Kn));else if(Be(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>J.isSeparator(e)?!1:(n++,n===t)),i=f[r];i&&Un(i)&&(g(r),p(f.map((e,t)=>t===r?Kn(e):e)))}});let y=s.style.message(e.message,l),b,x=Gt({items:f,active:h,renderItem({item:e,isActive:t}){if(J.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(Gn);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(`
32
+ `).trimEnd()}${sn}`});const Xn={icon:{cursor:G.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 Zn(e){return!J.isSeparator(e)&&!e.disabled}function Qn(e){return!J.isSeparator(e)}function $n(e){return e.map(e=>{if(J.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 er=yn((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=pt(Xn,e.theme),{keybindings:a}=i,[o,s]=W(`idle`),c=mt({status:o,theme:i}),l=gt(),u=!a.includes(`vim`),d=ht(()=>$n(e.choices),[e.choices]),f=ht(()=>{let e=d.findIndex(Qn),t=d.findLastIndex(Qn);if(e===-1)throw new Ke(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=ht(()=>`default`in e?d.findIndex(t=>Zn(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=W(p===-1?f.first:p),g=d[m];if(g==null||J.isSeparator(g))throw Error(`Active index does not point to a choice`);let[_,v]=W();_t((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Ve(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(H(e,a)||Le(e,a)){if(r.clearLine(0),n||H(e,a)&&m!==f.first||Le(e,a)&&m!==f.last){let t=H(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!Qn(d[n]));h(n)}}else if(Be(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>J.isSeparator(n)?!1:(t++,t===e)),i=d[n];i!=null&&Zn(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(ze(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>J.isSeparator(t)||!Zn(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),nt(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Gt({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(J.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(`
33
+ `).trimEnd()}${sn}`});
34
+ /*!
35
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
36
+ * SPDX-License-Identifier: BSD-3-Clause
37
+ *
38
+ * Redistribution and use in source and binary forms, with or without
39
+ * modification, are permitted provided that the following conditions are met:
40
+ *
41
+ * 1. Redistributions of source code must retain the above copyright notice, this
42
+ * list of conditions and the following disclaimer.
43
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
44
+ * this list of conditions and the following disclaimer in the
45
+ * documentation and/or other materials provided with the distribution.
46
+ * 3. Neither the name of the copyright holder nor the names of its contributors
47
+ * may be used to endorse or promote products derived from this software without
48
+ * specific prior written permission.
49
+ *
50
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
51
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
52
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
53
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
54
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
56
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
57
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
58
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
59
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60
+ */
61
+ let tr=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var nr=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(tr);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
+ /*!
63
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
64
+ * SPDX-License-Identifier: BSD-3-Clause
65
+ *
66
+ * Redistribution and use in source and binary forms, with or without
67
+ * modification, are permitted provided that the following conditions are met:
68
+ *
69
+ * 1. Redistributions of source code must retain the above copyright notice, this
70
+ * list of conditions and the following disclaimer.
71
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
72
+ * this list of conditions and the following disclaimer in the
73
+ * documentation and/or other materials provided with the distribution.
74
+ * 3. Neither the name of the copyright holder nor the names of its contributors
75
+ * may be used to endorse or promote products derived from this software without
76
+ * specific prior written permission.
77
+ *
78
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
79
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
80
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
81
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
82
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
83
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
84
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
85
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
86
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
87
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88
+ */
89
+ function rr(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function ir(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
+ `,e===t&&(i+=` `.repeat(a+n+2),i+=`^
91
+ `))}return i}var X=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=rr(t.toml,t.ptr),i=ir(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
92
+ /*!
93
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
94
+ * SPDX-License-Identifier: BSD-3-Clause
95
+ *
96
+ * Redistribution and use in source and binary forms, with or without
97
+ * modification, are permitted provided that the following conditions are met:
98
+ *
99
+ * 1. Redistributions of source code must retain the above copyright notice, this
100
+ * list of conditions and the following disclaimer.
101
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
102
+ * this list of conditions and the following disclaimer in the
103
+ * documentation and/or other materials provided with the distribution.
104
+ * 3. Neither the name of the copyright holder nor the names of its contributors
105
+ * may be used to endorse or promote products derived from this software without
106
+ * specific prior written permission.
107
+ *
108
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
109
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
110
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
111
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
112
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
113
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
114
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
115
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
116
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
117
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
118
+ */
119
+ let ar=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,or=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,sr=/^[+-]?0[0-9_]/;function cr(e,t){let n=e[t++],r=n,i=n===`'`,a=n===e[t]&&n===e[t+1];a&&(e[t+=2]===`
120
+ `?t++:e[t]===`\r`&&e[t+1]===`
121
+ `&&(t+=2));let o=``,s=t,c=0;for(let l=t;l<e.length;l++)if(n=e[l],a&&(n===`
122
+ `||n===`\r`&&e[l+1]===`
123
+ `))c&&=3;else if(n<` `&&n!==` `||n===``)throw new X(`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 X(`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 X(`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 X(`unrecognized escape sequence`,{toml:e,ptr:l});s=l+1,c=0}else if(n!==` `&&n!==` `){if(c===2)throw new X(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:s});c=+(!i&&n===`\\`),s=l}throw new X(`unfinished string`,{toml:e,ptr:t})}function lr(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=ar.test(e);if(i||or.test(e)){if(sr.test(e))throw new X(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new X(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new X(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new nr(e);if(!a.isValid())throw new X(`invalid value`,{toml:t,ptr:n});return a}
125
+ /*!
126
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
127
+ * SPDX-License-Identifier: BSD-3-Clause
128
+ *
129
+ * Redistribution and use in source and binary forms, with or without
130
+ * modification, are permitted provided that the following conditions are met:
131
+ *
132
+ * 1. Redistributions of source code must retain the above copyright notice, this
133
+ * list of conditions and the following disclaimer.
134
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
135
+ * this list of conditions and the following disclaimer in the
136
+ * documentation and/or other materials provided with the distribution.
137
+ * 3. Neither the name of the copyright holder nor the names of its contributors
138
+ * may be used to endorse or promote products derived from this software without
139
+ * specific prior written permission.
140
+ *
141
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
142
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
143
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
144
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
145
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
146
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
147
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
148
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
149
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
150
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
151
+ */
152
+ function ur(e,t=0,n=e.length){let r=e.indexOf(`
153
+ `,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function dr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
154
+ `)return n;if(r===`\r`&&e[n+1]===`
155
+ `)return n+1;if(r<` `&&r!==` `||r===``)throw new X(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function Z(e,t,n,r){let i;for(;;){for(;(i=e[t])===` `||i===` `||!n&&(i===`
156
+ `||i===`\r`&&e[t+1]===`
157
+ `);)t++;if(r||i!==`#`)break;t=dr(e,t)}return t}function fr(e,t,n,r,i=!1){if(!r)return t=ur(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=ur(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
158
+ `||t===`\r`&&e[a+1]===`
159
+ `))return a}throw new X(`cannot find end of structure`,{toml:e,ptr:t})}
160
+ /*!
161
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
162
+ * SPDX-License-Identifier: BSD-3-Clause
163
+ *
164
+ * Redistribution and use in source and binary forms, with or without
165
+ * modification, are permitted provided that the following conditions are met:
166
+ *
167
+ * 1. Redistributions of source code must retain the above copyright notice, this
168
+ * list of conditions and the following disclaimer.
169
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
170
+ * this list of conditions and the following disclaimer in the
171
+ * documentation and/or other materials provided with the distribution.
172
+ * 3. Neither the name of the copyright holder nor the names of its contributors
173
+ * may be used to endorse or promote products derived from this software without
174
+ * specific prior written permission.
175
+ *
176
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
177
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
178
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
179
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
180
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
181
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
182
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
183
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
184
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
185
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
186
+ */
187
+ function pr(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(dr(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function mr(e,t,n,r,i){if(r===0)throw new X(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?vr(e,t,r,i):_r(e,t,r,i);if(n){if(s=Z(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new X(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}if(a===`"`||a===`'`){let[r,i]=cr(e,t);if(n){if(i=Z(e,i),e[i]&&e[i]!==`,`&&e[i]!==n&&e[i]!==`
188
+ `&&e[i]!==`\r`)throw new X(`unexpected character encountered`,{toml:e,ptr:i});e[i]===`,`&&i++}return[r,i]}let o=fr(e,t,`,`,n),s=pr(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new X(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=Z(e,t+s[1]),e[o]===`,`&&o++),[lr(s[0],e,t,i),o]}
189
+ /*!
190
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
191
+ * SPDX-License-Identifier: BSD-3-Clause
192
+ *
193
+ * Redistribution and use in source and binary forms, with or without
194
+ * modification, are permitted provided that the following conditions are met:
195
+ *
196
+ * 1. Redistributions of source code must retain the above copyright notice, this
197
+ * list of conditions and the following disclaimer.
198
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
199
+ * this list of conditions and the following disclaimer in the
200
+ * documentation and/or other materials provided with the distribution.
201
+ * 3. Neither the name of the copyright holder nor the names of its contributors
202
+ * may be used to endorse or promote products derived from this software without
203
+ * specific prior written permission.
204
+ *
205
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
206
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
207
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
208
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
209
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
210
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
211
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
212
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
213
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
214
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
215
+ */
216
+ let hr=/^[a-zA-Z0-9-_]+[ \t]*$/;function gr(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new X(`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 X(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let[s,c]=cr(e,t);r=e.indexOf(`.`,c);let l=e.slice(c,r<0||r>a?a:r),u=ur(l);if(u>-1)throw new X(`newlines are not allowed in keys`,{toml:e,ptr:t+r+u});if(l.trimStart())throw new X(`found extra tokens after the string part`,{toml:e,ptr:c});if(a<c&&(a=e.indexOf(n,c),a<0))throw new X(`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(!hr.test(n))throw new X(`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,Z(e,a+1,!0,!0)]}function _r(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new X(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=dr(e,t);else if(o!==` `&&o!==` `&&o!==`
217
+ `&&o!==`\r`){let o,s=i,c=!1,[l,u]=gr(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 X(`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 X(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=mr(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new X(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function vr(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new X(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=dr(e,t);else if(a!==` `&&a!==` `&&a!==`
218
+ `&&a!==`\r`){let a=mr(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new X(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}
219
+ /*!
220
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
221
+ * SPDX-License-Identifier: BSD-3-Clause
222
+ *
223
+ * Redistribution and use in source and binary forms, with or without
224
+ * modification, are permitted provided that the following conditions are met:
225
+ *
226
+ * 1. Redistributions of source code must retain the above copyright notice, this
227
+ * list of conditions and the following disclaimer.
228
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
229
+ * this list of conditions and the following disclaimer in the
230
+ * documentation and/or other materials provided with the distribution.
231
+ * 3. Neither the name of the copyright holder nor the names of its contributors
232
+ * may be used to endorse or promote products derived from this software without
233
+ * specific prior written permission.
234
+ *
235
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
236
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
237
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
238
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
239
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
240
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
241
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
242
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
243
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
244
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
245
+ */
246
+ function yr(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 br(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=Z(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=gr(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new X(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=yr(n[0],r,i,t?2:1);if(!c)throw new X(`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=gr(e,s),i=yr(r[0],a,o,0);if(!i)throw new X(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=mr(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=Z(e,s,!0),e[s]&&e[s]!==`
247
+ `&&e[s]!==`\r`)throw new X(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=Z(e,s)}return r}
248
+ /*!
249
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
250
+ * SPDX-License-Identifier: BSD-3-Clause
251
+ *
252
+ * Redistribution and use in source and binary forms, with or without
253
+ * modification, are permitted provided that the following conditions are met:
254
+ *
255
+ * 1. Redistributions of source code must retain the above copyright notice, this
256
+ * list of conditions and the following disclaimer.
257
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
258
+ * this list of conditions and the following disclaimer in the
259
+ * documentation and/or other materials provided with the distribution.
260
+ * 3. Neither the name of the copyright holder nor the names of its contributors
261
+ * may be used to endorse or promote products derived from this software without
262
+ * specific prior written permission.
263
+ *
264
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
265
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
266
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
267
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
268
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
269
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
270
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
271
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
272
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
273
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274
+ */
275
+ let xr=/^[a-z0-9-_]+$/i;function Sr(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function Cr(e){for(let t=0;t<e.length;t++)if(Sr(e[t])!==`object`)return!1;return e.length!=0}function wr(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function Tr(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 wr(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return Er(e,n,r);if(t===`array`)return Dr(e,n,r)}function Er(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+=xr.test(o)?o:wr(o),i+=` = `,i+=Tr(e[o],Sr(e[o]),t-1,n)}return i+` }`}function Dr(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+=Tr(e[i],Sr(e[i]),t-1,n)}return r+` ]`}function Or(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+=kr(0,e[a],t,n,r);return i}function kr(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=Sr(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=xr.test(c)?c:wr(c);if(e===`array`&&Cr(t[c]))o+=(o&&`
277
+ `)+Or(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
278
+ `)+kr(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=Tr(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 Ar(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Sr(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=kr(0,e,``,t,n);return r[r.length-1]===`
280
+ `?r:r+`
281
+ `}const jr=`${le}-dev`;function Mr(e){return e.startsWith(le)}function Nr(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`&&Mr(n)}function Pr(e){return{command:oe,args:[e]}}function Fr(e={}){let t=e.mode===`dev`?jr:ce,n={unix:ae({...e,platformName:`darwin`}),win32:ae({...e,platformName:`win32`})};return`${t}
282
+ /**
283
+ * Open Knowledge bridge for Pi — MANAGED FILE, written by \`ok init\`.
284
+ * Hand edits are overwritten whenever OK re-syncs this project; remove it
285
+ * with \`ok deinit\` (or delete the file) to disconnect Pi from OK.
286
+ *
287
+ * On session start it spawns Open Knowledge's MCP stdio server via OK's
288
+ * resilient launcher (bundle, then npx, then version-manager probes), performs
289
+ * the MCP handshake, and registers each MCP tool as a Pi tool under an
290
+ * \`ok_\` prefix (Pi has no MCP namespacing; the prefix keeps OK's \`edit\` /
291
+ * \`write\` from shadowing Pi's built-in tools).
292
+ */
293
+ import { spawn } from "node:child_process";
294
+ import type { ChildProcessWithoutNullStreams } from "node:child_process";
295
+
296
+ const LAUNCHERS = ${JSON.stringify(n,null,2)} as const;
297
+
298
+ const TOOL_PREFIX = "ok_";
299
+ // First contact may cold-install the CLI through npx — allow a generous window.
300
+ const INIT_TIMEOUT_MS = 120000;
301
+ const STDERR_TAIL_LIMIT = 2000;
302
+
303
+ interface McpContentItem {
304
+ type: string;
305
+ text?: string;
306
+ }
307
+
308
+ interface McpToolInfo {
309
+ name: string;
310
+ description?: string;
311
+ inputSchema?: Record<string, unknown>;
312
+ }
313
+
314
+ interface PendingRequest {
315
+ resolve: (value: Record<string, unknown>) => void;
316
+ reject: (err: Error) => void;
317
+ }
318
+
319
+ class OkMcpClient {
320
+ private child: ChildProcessWithoutNullStreams;
321
+ private pending = new Map<number, PendingRequest>();
322
+ private nextId = 1;
323
+ private buffer = "";
324
+ private stderrTail = "";
325
+ alive = true;
326
+
327
+ constructor(cwd: string, onExit: () => void) {
328
+ const launcher = process.platform === "win32" ? LAUNCHERS.win32 : LAUNCHERS.unix;
329
+ const env: Record<string, string | undefined> = { ...process.env };
330
+ const launcherEnv = (launcher as { env?: Record<string, string> }).env;
331
+ if (launcherEnv) Object.assign(env, launcherEnv);
332
+ this.child = spawn(launcher.command, [...launcher.args], {
333
+ cwd,
334
+ env,
335
+ stdio: ["pipe", "pipe", "pipe"],
336
+ // Inline (not the withHiddenWindowsConsole helper): this spawn lives in the
337
+ // GENERATED Pi extension source, which must stay dependency-free (Pi loads
338
+ // it with jiti; no npm packages resolve). Hide the console on Windows anyway.
339
+ windowsHide: true,
340
+ });
341
+ this.child.stdout.setEncoding("utf8");
342
+ this.child.stdout.on("data", (chunk: string) => this.onStdout(chunk));
343
+ this.child.stderr.setEncoding("utf8");
344
+ this.child.stderr.on("data", (chunk: string) => {
345
+ this.stderrTail = (this.stderrTail + chunk).slice(-STDERR_TAIL_LIMIT);
346
+ });
347
+ // A write buffered before the pipe breaks surfaces as an 'error' on stdin
348
+ // (not on the child); unhandled it would crash Pi's extension host.
349
+ // Swallow it — the exit handler owns teardown.
350
+ this.child.stdin.on("error", () => {});
351
+ const fail = () => {
352
+ if (!this.alive) return;
353
+ this.alive = false;
354
+ const err = new Error(
355
+ "Open Knowledge MCP server exited" +
356
+ (this.stderrTail ? ": " + this.stderrTail.trim() : ""),
357
+ );
358
+ for (const p of this.pending.values()) p.reject(err);
359
+ this.pending.clear();
360
+ onExit();
361
+ };
362
+ this.child.on("exit", fail);
363
+ this.child.on("error", fail);
364
+ }
365
+
366
+ private onStdout(chunk: string): void {
367
+ this.buffer += chunk;
368
+ let newline = this.buffer.indexOf("\\n");
369
+ while (newline !== -1) {
370
+ const line = this.buffer.slice(0, newline).trim();
371
+ this.buffer = this.buffer.slice(newline + 1);
372
+ if (line.startsWith("{")) {
373
+ try {
374
+ this.onMessage(JSON.parse(line) as Record<string, unknown>);
375
+ } catch {
376
+ // Non-JSON noise on stdout is ignored; framing recovers on the next line.
377
+ }
378
+ }
379
+ newline = this.buffer.indexOf("\\n");
380
+ }
381
+ }
382
+
383
+ private onMessage(msg: Record<string, unknown>): void {
384
+ const id = msg.id;
385
+ if (typeof msg.method === "string") {
386
+ // Server-initiated request (e.g. roots/list). This bridge declares no
387
+ // client capabilities, so decline rather than leave the server hanging.
388
+ if (id !== undefined && id !== null) {
389
+ this.send({
390
+ jsonrpc: "2.0",
391
+ id,
392
+ error: { code: -32601, message: "Method not supported by the OK Pi bridge" },
393
+ });
394
+ }
395
+ return;
396
+ }
397
+ if (typeof id !== "number") return;
398
+ const pending = this.pending.get(id);
399
+ if (!pending) return;
400
+ this.pending.delete(id);
401
+ const error = msg.error as { message?: string } | undefined;
402
+ if (error) {
403
+ pending.reject(new Error(error.message || "Open Knowledge MCP error"));
404
+ return;
405
+ }
406
+ pending.resolve((msg.result ?? {}) as Record<string, unknown>);
407
+ }
408
+
409
+ private send(msg: Record<string, unknown>): void {
410
+ // Buffered stdout can still dispatch onMessage replies after close() ends
411
+ // stdin; writing then would raise ERR_STREAM_WRITE_AFTER_END unhandled.
412
+ if (!this.alive) return;
413
+ this.child.stdin.write(JSON.stringify(msg) + "\\n");
414
+ }
415
+
416
+ request(
417
+ method: string,
418
+ params: Record<string, unknown>,
419
+ opts: { timeoutMs?: number; signal?: AbortSignal } = {},
420
+ ): Promise<Record<string, unknown>> {
421
+ if (!this.alive) return Promise.reject(new Error("Open Knowledge MCP server is not running"));
422
+ const id = this.nextId++;
423
+ return new Promise<Record<string, unknown>>((resolve, reject) => {
424
+ let timer: ReturnType<typeof setTimeout> | undefined;
425
+ let onAbort: (() => void) | undefined;
426
+ const cleanup = () => {
427
+ if (timer !== undefined) clearTimeout(timer);
428
+ if (onAbort && opts.signal) opts.signal.removeEventListener("abort", onAbort);
429
+ this.pending.delete(id);
430
+ };
431
+ const done: PendingRequest = {
432
+ resolve: (value) => {
433
+ cleanup();
434
+ resolve(value);
435
+ },
436
+ reject: (err) => {
437
+ cleanup();
438
+ reject(err);
439
+ },
440
+ };
441
+ this.pending.set(id, done);
442
+ if (opts.timeoutMs) {
443
+ timer = setTimeout(() => {
444
+ done.reject(new Error(method + " timed out after " + opts.timeoutMs + "ms"));
445
+ }, opts.timeoutMs);
446
+ }
447
+ if (opts.signal) {
448
+ onAbort = () => {
449
+ this.notify("notifications/cancelled", { requestId: id, reason: "aborted" });
450
+ done.reject(new Error("Cancelled"));
451
+ };
452
+ if (opts.signal.aborted) {
453
+ onAbort();
454
+ return;
455
+ }
456
+ opts.signal.addEventListener("abort", onAbort, { once: true });
457
+ }
458
+ this.send({ jsonrpc: "2.0", id, method, params });
459
+ });
460
+ }
461
+
462
+ notify(method: string, params: Record<string, unknown>): void {
463
+ if (!this.alive) return;
464
+ this.send({ jsonrpc: "2.0", method, params });
465
+ }
466
+
467
+ close(): void {
468
+ this.alive = false;
469
+ for (const p of this.pending.values()) {
470
+ p.reject(new Error("Open Knowledge MCP client closed"));
471
+ }
472
+ this.pending.clear();
473
+ // ok mcp exits on stdin EOF; the delayed kill is a backstop.
474
+ try {
475
+ this.child.stdin.end();
476
+ } catch {
477
+ // Already gone.
478
+ }
479
+ const child = this.child;
480
+ setTimeout(() => {
481
+ try {
482
+ child.kill();
483
+ } catch {
484
+ // Already gone.
485
+ }
486
+ }, 2000).unref();
487
+ }
488
+ }
489
+
490
+ /** JSON Schema pass-through: Pi validates plain JSON Schema parameters. */
491
+ function toParameters(inputSchema: Record<string, unknown> | undefined): Record<string, unknown> {
492
+ if (!inputSchema || typeof inputSchema !== "object") {
493
+ return { type: "object", properties: {} };
494
+ }
495
+ const schema = { ...inputSchema };
496
+ delete schema.$schema;
497
+ return schema;
498
+ }
499
+
500
+ function contentText(content: unknown): string {
501
+ if (!Array.isArray(content)) return "";
502
+ return (content as McpContentItem[])
503
+ .filter((item) => item && item.type === "text" && typeof item.text === "string")
504
+ .map((item) => item.text as string)
505
+ .join("\\n");
506
+ }
507
+
508
+ export default function okBridge(pi: {
509
+ on(event: string, handler: (event: unknown, ctx: unknown) => unknown): void;
510
+ registerTool(definition: Record<string, unknown>): void;
511
+ }) {
512
+ let client: OkMcpClient | null = null;
513
+ let starting: Promise<OkMcpClient> | null = null;
514
+ let sessionCwd = process.cwd();
515
+ const registeredTools = new Set<string>();
516
+
517
+ async function ensureClient(): Promise<OkMcpClient> {
518
+ if (client && client.alive) return client;
519
+ if (starting) return starting;
520
+ starting = (async () => {
521
+ const next = new OkMcpClient(sessionCwd, () => {
522
+ if (client === next) client = null;
523
+ });
524
+ try {
525
+ await next.request(
526
+ "initialize",
527
+ {
528
+ protocolVersion: "2025-06-18",
529
+ capabilities: {},
530
+ clientInfo: { name: "pi", version: "1.0.0" },
531
+ },
532
+ { timeoutMs: INIT_TIMEOUT_MS },
533
+ );
534
+ } catch (err) {
535
+ // A timed-out initialize rejects the request while the child may
536
+ // still be running; tear it down so retries don't stack orphans.
537
+ next.close();
538
+ throw err;
539
+ }
540
+ next.notify("notifications/initialized", {});
541
+ client = next;
542
+ return next;
543
+ })();
544
+ try {
545
+ return await starting;
546
+ } finally {
547
+ starting = null;
548
+ }
549
+ }
550
+
551
+ async function registerOkTools(): Promise<number> {
552
+ const mcp = await ensureClient();
553
+ const listed = await mcp.request("tools/list", {}, { timeoutMs: INIT_TIMEOUT_MS });
554
+ const tools = Array.isArray(listed.tools) ? (listed.tools as McpToolInfo[]) : [];
555
+ for (const tool of tools) {
556
+ const name = TOOL_PREFIX + tool.name;
557
+ if (registeredTools.has(name)) continue;
558
+ registeredTools.add(name);
559
+ pi.registerTool({
560
+ name,
561
+ label: "OK " + tool.name,
562
+ description: tool.description || "Open Knowledge " + tool.name + " tool.",
563
+ parameters: toParameters(tool.inputSchema),
564
+ execute: async (
565
+ _toolCallId: string,
566
+ params: Record<string, unknown>,
567
+ signal: AbortSignal | undefined,
568
+ ) => {
569
+ const live = await ensureClient();
570
+ const result = await live.request(
571
+ "tools/call",
572
+ { name: tool.name, arguments: params ?? {} },
573
+ { signal },
574
+ );
575
+ const text = contentText(result.content);
576
+ if (result.isError) {
577
+ throw new Error(text || "Open Knowledge tool " + tool.name + " failed");
578
+ }
579
+ return {
580
+ content: [{ type: "text", text }],
581
+ details: result.structuredContent,
582
+ };
583
+ },
584
+ });
585
+ }
586
+ return tools.length;
587
+ }
588
+
589
+ pi.on("session_start", async (_event, ctx) => {
590
+ const cwd = (ctx as { cwd?: string } | undefined)?.cwd;
591
+ if (typeof cwd === "string" && cwd.length > 0) sessionCwd = cwd;
592
+ try {
593
+ await registerOkTools();
594
+ } catch (err) {
595
+ const ui = (ctx as { ui?: { notify?: (m: string, level: string) => void } } | undefined)?.ui;
596
+ try {
597
+ ui?.notify?.(
598
+ "Open Knowledge tools unavailable: " + (err instanceof Error ? err.message : String(err)),
599
+ "warning",
600
+ );
601
+ } catch {
602
+ // Non-interactive mode; the failure will resurface on first tool use.
603
+ }
604
+ }
605
+ });
606
+
607
+ pi.on("session_shutdown", async () => {
608
+ const pending = starting;
609
+ starting = null;
610
+ const current = client;
611
+ client = null;
612
+ current?.close();
613
+ // An in-flight ensureClient would otherwise assign a live client after
614
+ // shutdown; await it and tear that one down too.
615
+ if (pending) {
616
+ try {
617
+ (await pending).close();
618
+ } catch {
619
+ // Initialization failed — its catch path already closed the client.
620
+ }
621
+ }
622
+ });
623
+ }
624
+ `}function Ir(e,t){let n=L(t,e);return n.length>0&&!n.startsWith(`..`)&&!ve(n)}const Lr=e=>{try{let t=_e(`git`,[`rev-parse`,`--show-toplevel`],d({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function Rr(e,t={}){let n=t.homeDir??De(),r=t.gitTopLevel??Lr,i=ye(e),a;try{a=we(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(y(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=F(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&Ir(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 zr(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 Q(e,t){if(!process.env.OK_DEBUG_NATIVE)return;let n=t instanceof Error?t.message:String(t);process.stderr.write(`[ok] native-config ${e}: ${n}\n`)}const Br=[`native`,`index.js`];function Vr(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??ge(t);try{return n(I(F(Oe(t)),...Br))}catch(e){zr(e)||Q(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return zr(e)||Q(`workspace addon failed to load`,e),null}}function Hr(){let e=Vr();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function Ur(e){let t=e,n=new Set;for(;;){let r;try{r=xe(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=Ce(t)}catch(t){return Q(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=ve(i)?i:I(F(t),i)}}let Wr;function Gr(){return Wr===void 0&&(Wr=Hr()),Wr}function Kr(e,t=Gr){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){Q(`resolveSymlinkWritePath threw`,e)}return Ur(e)}function qr(){let e=Vr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Jr(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return Q(`addon loaded but probe failed`,e),!1}}function Yr(e){if(!k(e))throw Error(`TOML root is not a table`);return e}function Xr(e){return{backend:`native`,parseToObject(t){return Yr(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}}}}function Zr(){return{backend:`fallback`,parseToObject(e){return Yr(br(e))}}}function Qr(e=qr){let t=e();return t&&Jr(t)?Xr(t):Zr()}let $r=null;function ei(){return $r===null&&($r=Qr()),$r}const ti={allowTrailingComma:!0,disallowComments:!1};function ni(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function ri(e){let t=[],n=C(e,t,ti);return t.some(t=>!ni(t,e))||!n||n.type!==`object`?null:n}function ii(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&g(e)===t&&(n+=1)}return n}function ai(e,t){E(e,`${JSON.stringify(t,null,2)}\n`)}function oi(e,t){let n=Ar(t);E(e,n.endsWith(`
625
+ `)?n:`${n}\n`)}function si(e,t){let n=(0,bn.stringify)(t);E(e,n.endsWith(`
626
+ `)?n:`${n}\n`)}const ci=10*1024*1024;function li(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)=>li(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)&&li(e[n],t[n])):!1}return!1}function ui(e){for(let t of e.split(`
627
+ `)){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 di(e,t,n){return t===void 0?[e,n]:[e,t,n]}function fi(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function pi(e,t,n){let r=e[t];return n===void 0?r:k(r)?r[n]:void 0}function mi(e,t,n,r,i){if(!R(e))return ai(e,fi(t,i,n,r)),{kind:`written`};let a;try{a=z(e,`utf-8`)}catch(e){return Q(`json config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(a.trim()===``)return ai(e,fi(t,i,n,r)),{kind:`written`};if(Buffer.byteLength(a,`utf-8`)>ci)return{kind:`declined`,reason:`oversize`};let o=ri(a);if(!o)return{kind:`declined`,reason:`unparseable`};if(ii(o,t)>1)return{kind:`declined`,reason:`duplicate-container`};let c=pi(g(o),t,i),l=k(c)?c[n]:void 0,u=l!==void 0;if(u&&li(l,r))return{kind:`overwritten`};let d=a.charCodeAt(0)===65279,f=d?a.slice(1):a,p=f.includes(`\r
628
+ `)?`\r
629
+ `:`
630
+ `,m=ee(f,di(t,i,n),r,{formattingOptions:{...ui(f),eol:p}}),h=`${d?``:``}${s(f,m)}`;return h!==a&&E(e,h,{mode:Bn(e)}),{kind:u?`overwritten`:`written`}}function hi(e,t,n,r,i){let a=``;if(R(t))try{a=z(t,`utf-8`)}catch(e){return Q(`toml config read failed`,e),{kind:`declined`,reason:`unparseable`}}let o=a.trim()===``;if(e.backend===`fallback`)return o?(oi(t,{[n]:{[r]:i}}),{kind:`written`}):{kind:`declined`,reason:`no-native-writer`};let s=a.charCodeAt(0)===65279,c=s?a.slice(1):a,l=zn(c),u=o||c.endsWith(`
631
+ `),d;try{d=e.upsertEntry(c,r,i)}catch(e){return Q(`upsertEntry failed`,e),{kind:`declined`,reason:`unparseable`}}let f=d.text;u?f.endsWith(`
632
+ `)||(f=`${f}\n`):f=f.replace(/\n+$/,``),l&&(f=f.replace(/\r\n/g,`
633
+ `).replace(/\n/g,`\r
634
+ `));let p=`${s?``:``}${f}`;return p!==a&&E(t,p,{mode:Bn(t)}),{kind:d.existed?`overwritten`:`written`}}function gi(e,t,n,r){let i=``;if(R(e))try{i=z(e,`utf-8`)}catch(e){return Q(`yaml config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(i.trim()===``)return si(e,{[t]:{[n]:r}}),{kind:`written`};if(Buffer.byteLength(i,`utf-8`)>ci)return{kind:`declined`,reason:`oversize`};let a=i.charCodeAt(0)===65279,o=a?i.slice(1):i,s=(0,bn.parseDocument)(o);if(s.errors.length>0)return{kind:`declined`,reason:`unparseable`};let c=[t,n],l=s.hasIn(c);s.hasIn([t])&&!(0,bn.isCollection)(s.getIn([t],!0))&&s.deleteIn([t]),s.setIn(c,s.createNode(r));let u=s.toString(),d=zn(o);o.endsWith(`
635
+ `)?u.endsWith(`
636
+ `)||(u=`${u}\n`):u=u.replace(/\n+$/,``),d&&(u=u.replace(/\r\n/g,`
637
+ `).replace(/\n/g,`\r
638
+ `));let f=`${a?``:``}${u}`;return f!==i&&E(e,f,{mode:Bn(e)}),{kind:l?`overwritten`:`written`}}const _i=e=>e!==`project`,vi=e=>e!==`user`;async function yi(){let e=await Yn({message:`Where should the MCP server be configured?
639
+ `,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 bi(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??yi)():`both`}async function xi(e){return er({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json, project skills)?`,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 Si(e){if(e.sharing!==void 0)return e.sharing;let t=Dn(e.projectRoot)===`local-only`?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??xi)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Ci(e){if(e===void 0||e===!0)return new Set(l);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(l.filter(e=>t.includes(e)))}function wi(e,t,n){let r=ye(n,e),i;try{i=Te(r)}catch(e){let t=e.code;throw t===`ENOENT`?new $(`--content-dir path does not exist: ${r}`):new $(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new $(`--content-dir must be a directory: ${r}`);let a=L(Ti(t),Ti(r));if(a.startsWith(`..`)||ve(a))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return a===``?`.`:a}function Ti(e){try{return we(e)}catch{return e}}const Ei=`open-knowledge-ui`;function Di(e,t,n){try{return R(e.detectPath?.(t,n)??F(e.configPath(t,n)))}catch{return!1}}function Oi(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.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0;if(!i&&s&&!Di(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{de(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 Ai(e,o,a,n,{isProjectScope:i!==void 0});let c;try{c=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{Se(F(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 l={action:`written`},u;try{T(`${o}.lock`,()=>{let t=Kr(o).writePath;if(Se(F(t),{recursive:!0}),e.format===`toml`){let n=hi(ei(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=gi(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=mi(t,e.topLevelKey,a,c,e.serverMapSubKey);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){u=e instanceof Error?e:Error(String(e))}return u?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:u.message,...i===void 0?{}:{configScope:`project`}}:l.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:l.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:l.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const ki={pi:Fr};function Ai(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=ki[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{Se(F(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{T(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}E(t,c,e===null?void 0:{mode:Bn(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 ji(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function Mi(e){let t=re(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>Oi(t,``,n,e.home))}function Ni(e,t,n,r){let i=Fi(e,t,n,r);return i.kind===`present`?i.entry:null}function Pi(e,t,n,r){let i=pi(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 Fi(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(Te(i).size>ci)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=z(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Pr(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ei().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Pi(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,bn.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Pi(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=ri(a);return s?ii(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Pi(g(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ii(e={}){let t=ye(e.cwd??process.cwd()),n=Rr(t,{homeDir:e.home}),r=n.projectRoot,i=!R(I(r,`.ok`)),a=n.gitRootPromoted?L(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:wi(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${M(`[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`},d=await te(r),g;try{g=h(r,{contentDir:o})}catch(t){let i=O.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:d.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 _=g.created.includes(fe),v=!1;if(d.didInit)try{v=x(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{c(r)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore entry at ${r}: ${e instanceof Error?e.message:String(e)}`)}let y=await m(r);y.kind===`untracked`&&console.warn(`[ok] Untracked the OpenKnowledge project skill (${y.dirs.join(`, `)}) — it is now local-only. Teammates will see this as a deletion on their next pull.`);let b=await bi({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),S=e.editors??Hi(r,e.home),C=e.editors??ue.filter(e=>O[e].projectConfigPath!==void 0||O[e].projectSkillPath!==void 0),ee=re(S),w=re(C),T=e.mcp===!1||b===null,E=Array.from(new Map([...ee,...T?[]:w].map(e=>[e.id,e])).values()),ne=ee.filter(t=>Di(t,r,e.home)),D=[],ae=[],oe=new Set;for(let t of E){if(T){let n=``;try{n=t.configPath(r,e.home)}catch{}D.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(_i(b)&&ee.includes(t)&&t.scope===`global`&&D.push(Oi(t,r,s,e.home)),vi(b)&&w.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Oi(t,r,s,e.home,n);D.push(i),(i.action===`written`||i.action===`overwritten`)&&oe.add(n)}}let ce=new Set;for(let t of w){let n=t.projectSkillPath?.(r);!n||ce.has(n)||(ce.add(n),ae.push(se(t,r,{home:e.home})))}let le=!T&&b!==null&&vi(b)?w.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,de=T?[]:ne.map(e=>ji(e,r)).filter(e=>e!==void 0).filter(e=>!oe.has(e.path)),k=e.installUserSkill??f,A=e.home??De(),pe=Ci(e.skills),j=!1,me=!1,N=!1,he=!1;for(let t of l){let n=pe.has(t);if(await u(A,p[t],n).catch(()=>{}),n){j=!0;let n=await k({home:e.home,bundleId:t,force:!0});n===`installed`?me=!0:n===`failed`?N=!0:he=!0}else try{ie(A,t)}catch{}}let ge=N?`failed`:me?`installed`:j&&he?`skip-current`:`declined`,_e=T?`skipped-flag`:`skipped-missing`,P=D.find(e=>e.editorId===`claude`)??D[0]??{action:_e,configPath:O.claude.configPath(r,e.home)},F=await Li({projectRoot:r,desiredMode:await Si({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:g.created,contentUpdated:g.updated,contentSkipped:g.skipped,editors:D,projectSkills:ae,legacyProjectConfigs:de,skillInstall:ge,didGitInit:d.didInit,rootGitignoreCreated:v,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:_?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:P.action,mcpPath:P.configPath,mcpError:`error`in P?P.error:void 0,projectScopeUnsupportedLabels:le,sharing:F}}async function Li(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=Dn(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=wn(t);if(n===`local-only`){let e=Tn(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`}:Ri(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=En(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Ri(t,o,`remove`)}function Ri(e,t,n){let r=Dn(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:[]}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function zi(e){switch(e){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`;default:return`config not readable`}}function Bi(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=I(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(N(`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(N(`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(N(`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(N(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(N(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?L(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`open-knowledge`?``:` (${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} ${j(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${j(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${me(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${zi(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(N(`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?L(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${j(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${j(`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} ${me(`FAILED`)}: ${r.error}`);break}}}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} ${L(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(N(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${j(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${j(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${pe(`skipped (opted out via --no-skills)`)}`);break;case`failed`:n.push(` ${M(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${M(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(M(`⚠ --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(M(`⚠ 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(he(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...Gi(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${j(`✓`)} ${N(`Next steps:`)}`),n.push(` 1. Open your editor (${A(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${A(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${A(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${A(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${A(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${A(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
640
+ `)}function Vi(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 Hi(e,t){let n=[];for(let r of ue)Di(O[r],e,t)&&n.push(r);return n}function Ui(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Ae(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 Wi(){return new ne(`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 D(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new D(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new D(`--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?Ui():null;try{let r;try{r=await Ii({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof $){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof v||e instanceof S){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof b){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.
641
+ `),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-EZiQC7cG.mjs`),{resolveContentDir:s}=await import(`./src-CL0d0X9t.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-DGyDBzMH.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(Vi(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Bi(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Gi(e,t){let n=[];switch(e.kind){case`applied`:return n.push(N(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${j(`local-only`)} — appended ${e.appended.length} path(s) to ${N(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${j(`local-only`)} — already excluded; nothing to do.`):n.push(` ${j(`local-only`)}`):e.action===`removed`?n.push(` ${j(`shared`)} — removed OK paths from ${N(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${j(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(M(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
642
+ `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${A(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(M(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${A(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${A(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(M(`Sharing mode unavailable: ${e.reason}.`));return n}}export{wn as A,pt as B,Yn as C,Tn as D,Vn as E,An as F,Ve as H,yn as I,sn as L,Dn as M,kn as N,Mn as O,En as P,_t as R,Nr as S,zn as T,W as V,di as _,Vi as a,ei as b,Bi as c,Ni as d,Ci as f,Ii as g,Si as h,Li as i,jn as j,On as k,Gi as l,wi as m,Ei as n,Fi as o,bi as p,ki as r,Hi as s,$ as t,Wi as u,Oi as v,Bn as w,Rr as x,Mi as y,mt as z};
643
+ //# sourceMappingURL=init-CBfUP8hN.mjs.map