@inkeep/open-knowledge 0.59.0-beta.1 → 0.59.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/README.md +43 -0
  2. package/dist/acp-harness-probe-B-zYNbKH.mjs +3 -0
  3. package/dist/cli.mjs +63 -63
  4. package/dist/constants-CuvKewzN.mjs +2 -0
  5. package/dist/index.d.mts +14 -0
  6. package/dist/index.mjs +8 -8
  7. package/dist/init-B5gPgKmk.mjs +1 -0
  8. package/dist/init-BzZZQKjK.mjs +638 -0
  9. package/dist/{launch-json-removal-CpLIRGzz.mjs → launch-json-removal-BFc1Zjdt.mjs} +2 -2
  10. package/dist/loader-Bowldk_b.mjs +1 -0
  11. package/dist/{loader-BZ93QvlM.mjs → loader-gs03Z0wR.mjs} +2 -2
  12. package/dist/{open-browser-CtfBqG33.mjs → open-browser-00vuZ49B.mjs} +2 -2
  13. package/dist/{preview-CfZUHqGM.mjs → preview-D-cqfvmS.mjs} +2 -2
  14. package/dist/preview-DrxJEWLx.mjs +1 -0
  15. package/dist/public/assets/{ActivityModeContent-DBbldt0k.js → ActivityModeContent-7I3FAqNa.js} +1 -1
  16. package/dist/public/assets/{AgentDiffPane-DwjS2yV9.js → AgentDiffPane-BQC85Rn1.js} +1 -1
  17. package/dist/public/assets/{AgentThreadClientBinder-DoFc7NfG.js → AgentThreadClientBinder-q7HjbS_V.js} +1 -1
  18. package/dist/public/assets/{BugReportHistory-Dj4DWBsG.js → BugReportHistory-DnmaPA_t.js} +1 -1
  19. package/dist/public/assets/{BugReportHistoryDialog-DNOoF0sF.js → BugReportHistoryDialog-BjRpH89b.js} +1 -1
  20. package/dist/public/assets/{CodeMirrorPropInput-Bbe8zInO.js → CodeMirrorPropInput-Bf5PV704.js} +3 -3
  21. package/dist/public/assets/{DiffView-BuSYMH4e.js → DiffView-B-B3fi5F.js} +1 -1
  22. package/dist/public/assets/DocumentContext-YI07j2yc.js +38 -0
  23. package/dist/public/assets/{EditorModeToggle-K2dlTUFw.js → EditorModeToggle-B3XSSPCP.js} +1 -1
  24. package/dist/public/assets/{EnableSyncConfirmDialog-Crl0PHbt.js → EnableSyncConfirmDialog-DrBUTfFU.js} +1 -1
  25. package/dist/public/assets/{ExcalidrawDocEditor-C89vengD.js → ExcalidrawDocEditor-T3TL3VQu.js} +1 -1
  26. package/dist/public/assets/FeedbackForm-bekuqqT1.js +1 -0
  27. package/dist/public/assets/{GraphPanel-BioJjRJE.js → GraphPanel-B_Mg9p1O.js} +1 -1
  28. package/dist/public/assets/{ImportSkillDialog-CTisXGKo.js → ImportSkillDialog-B5zHicwe.js} +1 -1
  29. package/dist/public/assets/{LintConfigEditor-2PX1Y8Gp.js → LintConfigEditor-D5Dg5HLZ.js} +1 -1
  30. package/dist/public/assets/ManagedArtifactProperties-DXXsE5wd.js +1 -0
  31. package/dist/public/assets/ManagedArtifactProperties-WOaAexG2.js +1 -0
  32. package/dist/public/assets/McpConsentDialogBody-CQXH8Lp7.js +1 -0
  33. package/dist/public/assets/{MermaidDocEditor-Q13CWidl.js → MermaidDocEditor-CwD8mOHB.js} +1 -1
  34. package/dist/public/assets/{PropertyDisplayRow-DVXahRWZ.js → PropertyDisplayRow-CKXJ3p74.js} +1 -1
  35. package/dist/public/assets/{ReportBugDialogBody-BTwtPNzB.js → ReportBugDialogBody-CVQgnZSP.js} +1 -1
  36. package/dist/public/assets/{SchemaConfigEditor-BzfcQ3Bd.js → SchemaConfigEditor-kvdPUUAX.js} +1 -1
  37. package/dist/public/assets/SessionsHost-x_FfXVKL.js +2 -0
  38. package/dist/public/assets/{SettingsDialogBody-CBraPHPP.js → SettingsDialogBody-CgHSjRrN.js} +4 -4
  39. package/dist/public/assets/{ShareReceiveMissDialog-CjolEfpx.js → ShareReceiveMissDialog-DBLKwZ22.js} +1 -1
  40. package/dist/public/assets/{SkillInstallMenu-CIrDCCxr.js → SkillInstallMenu-BXOomxqv.js} +2 -2
  41. package/dist/public/assets/{SkillOriginInline-9ArgS7v6.js → SkillOriginInline-B1B3kTSz.js} +1 -1
  42. package/dist/public/assets/{SkillToolbarControls-B9LFwwR_.js → SkillToolbarControls-NUcxAczC.js} +1 -1
  43. package/dist/public/assets/{SourceEditor-BwO15VQF.js → SourceEditor-DYdjbyzp.js} +1 -1
  44. package/dist/public/assets/{TerminalPanel-B4u8CA0m.js → TerminalPanel-DkxYnA6s.js} +1 -1
  45. package/dist/public/assets/{TerminalWindowApp-BgTVBGP9.js → TerminalWindowApp-CEKKfG52.js} +1 -1
  46. package/dist/public/assets/{TextDocEditor-DHilRKxH.js → TextDocEditor-CaNNKmLz.js} +1 -1
  47. package/dist/public/assets/ThreadView-Bt_MQTAE.js +14 -0
  48. package/dist/public/assets/{TimelineDiffPane-DBuwXW3c.js → TimelineDiffPane-yi7kMXSo.js} +1 -1
  49. package/dist/public/assets/{agent-diff-store-C3QOPAgw.js → agent-diff-store-SkFUI7rS.js} +1 -1
  50. package/dist/public/assets/{auth-state-cache-DBcpAYj1.js → auth-state-cache-DbD6wjBD.js} +1 -1
  51. package/dist/public/assets/{client-version-Cea4CPxm.js → client-version-p4OJ2Mf5.js} +1 -1
  52. package/dist/public/assets/{cm-theme-Da-a0GOT.js → cm-theme-Bi-g5j8J.js} +1 -1
  53. package/dist/public/assets/{comment-chips-PokDlHuL.js → comment-chips-DiZPWTPl.js} +1 -1
  54. package/dist/public/assets/{config-provider-C7t6oRiN.js → config-provider-USxiO_wH.js} +3 -3
  55. package/dist/public/assets/{dist-BpbQP0nJ.js → dist-8oXszleg.js} +1 -1
  56. package/dist/public/assets/{dist-DJO8o4ls2.js → dist-BJNERzM02.js} +1 -1
  57. package/dist/public/assets/{dist-DAvyu-Pu.js → dist-BLe6Laue.js} +1 -1
  58. package/dist/public/assets/{dist-DV5JQxhA.js → dist-BOvI9R-K.js} +1 -1
  59. package/dist/public/assets/{dist-RIwmEtSi.js → dist-CB_NMgy4.js} +1 -1
  60. package/dist/public/assets/{dist-9jLm2WMy.js → dist-CuMGVsog.js} +1 -1
  61. package/dist/public/assets/{dist-j8YNkBWX.js → dist-CyQvb_hJ.js} +1 -1
  62. package/dist/public/assets/{dist-CrpG6qZF.js → dist-DMk7rHfk.js} +1 -1
  63. package/dist/public/assets/{dist-DtBd-emT.js → dist-DpwTwWzy.js} +1 -1
  64. package/dist/public/assets/{dist-83_CVK0Y.js → dist-RP9GkCTw.js} +1 -1
  65. package/dist/public/assets/{dist-CIfqGNU5.js → dist-THE2PCU5.js} +1 -1
  66. package/dist/public/assets/{dist-CmZSQ_Dr.js → dist-TdeurvvU.js} +1 -1
  67. package/dist/public/assets/{file-tree-adapter-BAEEzFBR.js → file-tree-adapter-Bo3rGytc.js} +1 -1
  68. package/dist/public/assets/{follow-file-4OaGQKr8.js → follow-file-DWqYp0pE.js} +1 -1
  69. package/dist/public/assets/{globals-DMVk7DOF.css → globals-CStTfhCT.css} +1 -1
  70. package/dist/public/assets/i18n-DLbGfWG4.js +1 -0
  71. package/dist/public/assets/{index-DjHwk3he.js → index-C6Xk875v.js} +7 -7
  72. package/dist/public/assets/known-skill-dirs-toPil01C.js +1 -0
  73. package/dist/public/assets/{markdownlint-rule-browser-B4O09K7a.js → markdownlint-rule-browser-T68WxSIo.js} +1 -1
  74. package/dist/public/assets/messages-BFlTGREq.js +1 -0
  75. package/dist/public/assets/messages-BN7zDSVo.js +1 -0
  76. package/dist/public/assets/messages-BP5GGrRC.js +1 -0
  77. package/dist/public/assets/messages-Cdv9hd10.js +1 -0
  78. package/dist/public/assets/messages-CgyRKo5g.js +1 -0
  79. package/dist/public/assets/messages-D13EOsYw.js +1 -0
  80. package/dist/public/assets/messages-D2-S61MT.js +1 -0
  81. package/dist/public/assets/messages-DQkd1f5c.js +1 -0
  82. package/dist/public/assets/messages-D_5Iek_V.js +1 -0
  83. package/dist/public/assets/messages-Daexf5KZ.js +1 -0
  84. package/dist/public/assets/messages-DvC9XHhc.js +1 -0
  85. package/dist/public/assets/messages-Fy0K5qZm.js +1 -0
  86. package/dist/public/assets/navigation-targets-D6rHX3Pq.js +1 -0
  87. package/dist/public/assets/{pending-receive-nav-store-CUM2yGMy.js → pending-receive-nav-store-BaBTyiLf.js} +1 -1
  88. package/dist/public/assets/{prop-types-efgXxLQK.js → prop-types-CizsurD0.js} +1 -1
  89. package/dist/public/assets/{selection-context-0QPVSyyM.js → selection-context-DV36ssJQ.js} +1 -1
  90. package/dist/public/assets/skill-actions-ayyLVAw5.js +1 -0
  91. package/dist/public/assets/skills-api-DO54o34O.js +1 -0
  92. package/dist/public/assets/{src-C-kGu7U9.js → src-B3OD2BqU.js} +1 -1
  93. package/dist/public/assets/{tag-pill-input-BbNgNG5U.js → tag-pill-input-D2qVy9HA.js} +1 -1
  94. package/dist/public/assets/{target-navigation-intent-CQRrvMAa.js → target-navigation-intent-BqElNT05.js} +1 -1
  95. package/dist/public/assets/{telemetry-impl-B-PaTlR_.js → telemetry-impl-DhefnhPq.js} +1 -1
  96. package/dist/public/assets/{telemetry-startup-toj6ifVD.js → telemetry-startup--1E51CEj.js} +1 -1
  97. package/dist/public/assets/{terminal-cli-display-w0URjEKX.js → terminal-cli-display-BTQdEy1j.js} +1 -1
  98. package/dist/public/assets/{terminal-launch-events-CLm4Tujb.js → terminal-launch-events-DNmxO4ft.js} +1 -1
  99. package/dist/public/assets/{terminal-telemetry-Bwit7Ew2.js → terminal-telemetry-BC3JNC05.js} +1 -1
  100. package/dist/public/assets/{text-viewer-languages-BTH8XtqT.js → text-viewer-languages-CF6DiXgT.js} +2 -2
  101. package/dist/public/assets/{typing-burst-detector-BSBim2fh.js → typing-burst-detector-cZASYUag.js} +1 -1
  102. package/dist/public/assets/{uninstall-DjCmbDes.js → uninstall-D9_hPyyW.js} +1 -1
  103. package/dist/public/assets/{use-activity-panel-Dsk5r0Dh.js → use-activity-panel-Drw3hRT0.js} +1 -1
  104. package/dist/public/assets/use-open-skill-C-OW-Q9z.js +1 -0
  105. package/dist/public/assets/use-popular-skills-BIvBkMNA.js +1 -0
  106. package/dist/public/assets/use-skill-origin-FTbTIS5Y.js +1 -0
  107. package/dist/public/assets/{use-terminal-enabled-nco9YpDh.js → use-terminal-enabled-CSNDVdz8.js} +1 -1
  108. package/dist/public/assets/{use-timeline-entry-diff-C_A3TeSj.js → use-timeline-entry-diff-DGCq_9Hl.js} +1 -1
  109. package/dist/public/index.html +53 -53
  110. package/dist/public/uninstall.html +6 -6
  111. package/dist/{repair-launch-json-Dw_5c8F0.mjs → repair-launch-json-TrmFTJtM.mjs} +2 -2
  112. package/dist/repair-mcp-configs-D3EO32iD.mjs +2 -0
  113. package/dist/repair-skills-CTJ78v6_.mjs +4 -0
  114. package/dist/repair-skills-lEisdlv1.mjs +1 -0
  115. package/dist/{write-project-skill-B7q9oxw9.mjs → resolve-project-root-CAzm4bRw.mjs} +7 -7
  116. package/dist/{skill-teardown-Cx7h3ooY.mjs → skill-teardown-CwUORgAd.mjs} +2 -2
  117. package/dist/{src-Cqh-Fhfh.mjs → src-BEA-yn6c.mjs} +341 -335
  118. package/dist/src-BNK2WY-u.mjs +20 -0
  119. package/dist/{src-COqGK-op.mjs → src-Bz8L1kRK.mjs} +1 -1
  120. package/dist/src-Dhp-cFHN.mjs +1 -0
  121. package/dist/start-BgU8qitb.mjs +1 -0
  122. package/dist/{start-CxkA_vzO.mjs → start-sc9lI5yb.mjs} +5 -5
  123. package/dist/{ui-C7ao4aMi.mjs → ui-BxBKs2IM.mjs} +3 -3
  124. package/package.json +17 -6
  125. package/scripts/verify-package-surface.mjs +57 -0
  126. package/dist/acp-harness-probe-CiWbxcI-.mjs +0 -3
  127. package/dist/constants-CW2Rx-IF.mjs +0 -2
  128. package/dist/init-3jheO70m.mjs +0 -638
  129. package/dist/init-Dbv25kpt.mjs +0 -1
  130. package/dist/loader-CrvsnWLF.mjs +0 -1
  131. package/dist/preview-uqiPA7dK.mjs +0 -1
  132. package/dist/public/assets/DocumentContext-BC38uC8R.js +0 -38
  133. package/dist/public/assets/FeedbackForm-wyWA05iX.js +0 -1
  134. package/dist/public/assets/ManagedArtifactProperties-BkJurdY8.js +0 -1
  135. package/dist/public/assets/ManagedArtifactProperties-Bmcgejtj.js +0 -1
  136. package/dist/public/assets/McpConsentDialogBody-5ojAKZte.js +0 -1
  137. package/dist/public/assets/SessionsHost-Bn80i4wO.js +0 -2
  138. package/dist/public/assets/ThreadView-7sbMEVak.js +0 -14
  139. package/dist/public/assets/i18n-BzFVw6me.js +0 -1
  140. package/dist/public/assets/messages-7TQ4p_5e.js +0 -1
  141. package/dist/public/assets/messages-BAyOSOzR.js +0 -1
  142. package/dist/public/assets/messages-BLbXONgk.js +0 -1
  143. package/dist/public/assets/messages-BjIH4q0G.js +0 -1
  144. package/dist/public/assets/messages-BzRqDtdz.js +0 -1
  145. package/dist/public/assets/messages-Cimiq3nE.js +0 -1
  146. package/dist/public/assets/messages-Cn23SiIt.js +0 -1
  147. package/dist/public/assets/messages-Cpdcajhh.js +0 -1
  148. package/dist/public/assets/messages-DEperCf5.js +0 -1
  149. package/dist/public/assets/messages-Vju40UVv.js +0 -1
  150. package/dist/public/assets/messages-agMQw_WX.js +0 -1
  151. package/dist/public/assets/messages-pwWS2IL9.js +0 -1
  152. package/dist/public/assets/navigation-targets-saCskzOA.js +0 -1
  153. package/dist/public/assets/skill-actions-H0gbk5VS.js +0 -1
  154. package/dist/public/assets/skills-api-DriOKSSy.js +0 -1
  155. package/dist/public/assets/use-open-skill-BNgqZmZx.js +0 -1
  156. package/dist/public/assets/use-popular-skills-CfasFpLW.js +0 -1
  157. package/dist/public/assets/use-skill-origin-Bpi6sqBq.js +0 -1
  158. package/dist/public/assets/use-skills-DJ009sMa.js +0 -1
  159. package/dist/repair-mcp-configs-xmhaYrkC.mjs +0 -2
  160. package/dist/repair-skills-D7rSfppe.mjs +0 -4
  161. package/dist/repair-skills-aO5Yt4lm.mjs +0 -1
  162. package/dist/src-DczLeXzm.mjs +0 -1
  163. package/dist/src-DzdxikwQ.mjs +0 -20
  164. package/dist/start-mpbcgl9V.mjs +0 -1
  165. /package/dist/public/assets/{asset-dispatch-KsnhYIM1.js → asset-dispatch-CdZ_--jl.js} +0 -0
  166. /package/dist/public/assets/{badge-BHNK6NBf.js → badge-BG5JKjNK.js} +0 -0
  167. /package/dist/public/assets/{dist-D9pOpWzq.js → dist-ZfIywMZM.js} +0 -0
  168. /package/dist/public/assets/{external-link-B0bVg1hn.js → external-link-B4qPZwve.js} +0 -0
  169. /package/dist/public/assets/{globals--kx1ORbr.js → globals-tNjN0wSq.js} +0 -0
  170. /package/dist/public/assets/{stex-BUFg5G8g.js → stex-Bh4EH31F.js} +0 -0
  171. /package/dist/public/assets/{use-collab-url-cmMNtL6Q.js → use-collab-url-B7oEo69p.js} +0 -0
@@ -1,638 +0,0 @@
1
- import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{pt as r}from"./sleep-B416PNUo.mjs";import{Ts as i,Us as a,Z as o,et as s,ns as c}from"./src-BxdlvOrw.mjs";import{Aa as l,Br as u,Dr as d,Er as f,Hr as p,In as m,Or as h,Sn as g,Vr as _,Wr as v,c as y,gr as b,l as x,lr as S,on as C,or as ee,sn as te,sr as ne,ti as w,u as re,vr as ie,wn as ae,xn as oe}from"./src-Cqh-Fhfh.mjs";import{F as T,N as se}from"./fs-traced-CJ0NSnI0.mjs";import{_ as ce,a as E,b as D,c as le,d as ue,i as de,l as fe,o as pe,r as me,t as he,u as ge,v as _e}from"./write-project-skill-B7q9oxw9.mjs";import{i as O,n as k,o as A,r as ve,s as j,t as M}from"./colors-BsmVIwfM.mjs";import{t as ye}from"./constants-CW2Rx-IF.mjs";import{t as N}from"./is-object-ByG7RnjH.mjs";import{t as be}from"./preview-CfZUHqGM.mjs";import{createRequire as xe}from"node:module";import{execFileSync as Se}from"node:child_process";import P,{dirname as F,isAbsolute as Ce,join as I,relative as L,resolve as we,sep as Te}from"node:path";import R from"node:process";import{fileURLToPath as Ee}from"node:url";import{existsSync as z,lstatSync as De,mkdirSync as Oe,readFileSync as B,readlinkSync as ke,realpathSync as Ae,statSync as je,writeFileSync as Me}from"node:fs";import{homedir as Ne}from"node:os";import*as Pe from"node:readline";import{inspect as Fe,stripVTControlCharacters as Ie,styleText as V}from"node:util";import{AsyncLocalStorage as Le,AsyncResource as Re}from"node:async_hooks";const ze=new Set([`emacs`,`vim`]);function Be(e){return ze.has(e)}function Ve(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Be))):[]}const H=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,He=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Ue=e=>e.name===`space`,We=e=>e.name===`backspace`,Ge=e=>`1234567890`.includes(e.name),Ke=e=>e.name===`enter`||e.name===`return`;var qe=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Je=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Ye=class extends Error{name=`ExitPromptError`},Xe=class extends Error{name=`HookError`},Ze=class extends Error{name=`ValidationError`};const Qe=new Le;function $e(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function et(e,t){let n=$e(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 Xe(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function tt(){return U().rl}function nt(e){return Re.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 rt(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 it(){U().handleChange()}const W={queue(e){let t=U(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(tt());if(r!=null&&typeof r!=`function`)throw new Ze(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=U();nt(()=>{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 at(e){return typeof e==`function`}function G(e){return rt(t=>{let n=Re.bind(function(e){t.get()!==e&&(t.set(e),it())});if(t.initialized)return[t.get(),n];let r=at(e)?e():e;return t.set(r),[r,n]})}function ot(e,t){rt(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&W.queue(e),n.set(t)})}function st(){return R.platform.startsWith(`win`)?!!R.env.CI||!!R.env.WT_SESSION||!!R.env.TERMINUS_SUBLIME||R.env.ConEmuTask===`{cmd::Cmder}`||R.env.TERM_PROGRAM===`Terminus-Sublime`||R.env.TERM_PROGRAM===`vscode`||R.env.TERM===`xterm-256color`||R.env.TERM===`alacritty`||R.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:R.env.TERM!==`linux`}const ct={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:`╱`},lt={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:`⅒`},ut={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`},dt={...ct,...lt},ft={...ct,...ut},K=st()?dt:ft;Object.entries(lt);const pt={prefix:{idle:V(`blue`,`?`),done:V(`green`,K.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 mt(){return{...pt,keybindings:Ve()}}function ht(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 gt(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=ht(n)&&ht(r)?gt(n,r):r}return t}function _t(...e){return gt(mt(),...e.filter(e=>e!=null))}function vt({status:e=`idle`,theme:t}){let[n,r]=G(!1),[i,a]=G(0),{prefix:o,spinner:s}=_t(t);return ot(()=>{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 yt(e,t){return rt(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 bt(e){return G({current:e})[0]}function xt(e){let t=bt(e);t.current=e,ot(e=>{let n=!1,r=nt((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var St=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 Ct=(()=>{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}})(),wt=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Tt=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,Et=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Dt=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ot=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,kt=/\t{1,1000}/y,At=/[\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,jt=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Mt=/\p{M}+/gu,Nt={limit:1/0,ellipsis:``},Pt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Pt(i,Nt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[jt,l],[Et,0],[Dt,o],[kt,s],[At,c],[Ot,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(Mt,``)){let t=e.codePointAt(0)||0;if(S=wt(t)?2:Tt(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===Ot?Ct(e.slice(p,n.lastIndex)):n===At?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}},Ft={limit:1/0,ellipsis:``,ellipsisWidth:0},q=(e,t={})=>Pt(e,Ft,t).width,It=`]8;;`,Lt=RegExp(`(?:\\[(?<code>\\d+)m|\\${It}(?<uri>.*))`,`y`),Rt=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},zt=e=>`[${e}m`,Bt=e=>`${It}${e}`,Vt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:q(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=q(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(It,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())},Ht=e=>{let t=e.split(` `),n=t.length;for(;n&&!q(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ut=(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=q(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=q(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(``),Vt(s,r,t),c=q(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Vt(s,r,t),c=q(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Vt(s,r,t),c=q(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Ht(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===`›`){Lt.lastIndex=e+1;let t=Lt.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+=Bt(``));let e=i?Rt(i):void 0;i&&e&&(r+=zt(e))}else t===`
4
- `&&(i&&Rt(i)&&(r+=zt(i)),a&&(r+=Bt(a)))}return r},Wt=/\r?\n/;function Gt(e,t,n){return String(e).normalize().split(Wt).map(e=>Ut(e,t,n)).join(`
5
- `)}function Kt(e,t){return e.split(`
6
- `).flatMap(e=>Gt(e,t,{trim:!1,wordWrap:!1}).split(`
7
- `).map(e=>e.trimEnd())).join(`
8
- `)}function qt(){return(0,St.default)({defaultWidth:80,output:tt().output})}function Jt({active:e,renderedItems:t,pageSize:n,loop:r}){let i=bt({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 Yt({items:e,active:t,renderItem:n,pageSize:r,loop:i=!0}){let a=qt(),o=t=>(t%e.length+e.length)%e.length,s=e.map((e,r)=>e==null?[]:Kt(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=Jt({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 Xt=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 J=[];J.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&J.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&J.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const Zt=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`,Qt=Symbol.for(`signal-exit emitter`),$t=globalThis,en=Object.defineProperty.bind(Object);var tn=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if($t[Qt])return $t[Qt];en($t,Qt,{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}},nn=class{};const rn=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var an=class extends nn{onExit(){return()=>{}}load(){}unload(){}},on=class extends nn{#e=sn.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new tn;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of J)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(!Zt(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 J)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,J.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 Zt(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`&&Zt(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 sn=globalThis.process,{onExit:cn,load:ln,unload:un}=rn(Zt(sn)?new on(sn):new an),dn=`\x1B[?25l`,fn=(e=1)=>e>0?`[${e}A`:``,pn=(e=1)=>e>0?`[${e}B`:``,mn=(e,t)=>typeof t==`number`&&!Number.isNaN(t)?`[${t+1};${e+1}H`:`[${e+1}G`,hn=`\x1B[2K`,gn=e=>e>0?(hn+fn(1)).repeat(e-1)+hn+`\x1B[G`:``,_n=e=>e.split(`
11
- `).length,vn=e=>e.split(`
12
- `).pop()??``;var yn=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=Ie(vn(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=qt();e=Kt(e,i),t=Kt(t,i),n.length%i===0&&(e+=`
13
- `);let a=e+(t?`
14
- `+t:``),o=Math.floor(n.length/i)-this.cursorPos.rows+(t?_n(t):0);o>0&&(a+=fn(o)),a+=mn(this.cursorPos.cols),this.write(pn(this.extraLinesUnderPrompt)+gn(this.height)+a),this.extraLinesUnderPrompt=o,this.height=_n(a)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(mn(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt(``);let t=pn(this.extraLinesUnderPrompt);t+=e?gn(this.height):`
15
- `,t+=`\x1B[G`,t+=`\x1B[?25h`,this.write(t),this.rl.close()}},bn=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}};const xn=globalThis.setImmediate;function Sn(){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 Cn(e){let t=Sn();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,s=new Xt.default;s.pipe(r.output??process.stdout);let c=Pe.createInterface({terminal:!0,input:i,output:s});s.mute();let l=new yn(c),{promise:u,resolve:d,reject:f}=bn.withResolver(),p=()=>f(new Je);if(a){let e=()=>f(new qe({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(cn((e,t)=>{f(new Ye(`User force closed the prompt with ${e} ${t}`))}));let m=()=>f(new Ye(`User force closed the prompt with SIGINT`));return c.on(`SIGINT`,m),o.add(()=>c.removeListener(`SIGINT`,m)),et(c,a=>{let m=Re.bind(()=>W.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),W.run()}catch(e){f(e)}if(r=!0,i!==null){let{value:e}=i;i=null,d(e)}})};return`readableFlowing`in i?xn(h):h(),Object.assign(u.then(e=>(W.clearAll(),e),e=>{throw W.clearAll(),e}).finally(()=>{o.forEach(e=>e()),l.done({clearContent:!!r.clearPromptOnDone}),s.end()}).then(()=>u),{cancel:p})})}}var Y=class{separator=V(`dim`,Array.from({length:15}).join(K.line));type=`separator`;constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`separator`)}},wn=r();const Tn=`**/.ok/*`,En=`!**/${a}/`;function Dn(e){let t=[`.ok/`,`.okignore`];for(let n of de){let r=pe[n];r.projectConfigPath&&t.push(zn(r.projectConfigPath(e),e))}t.push(`.claude/launch.json`);let n=I(e,...o);if(z(n))try{let e=s(B(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=i[e];r&&t.push(`${r}/${n}/`)}}}catch{}return Array.from(new Set(t))}function On(e,t){let n=Nn(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:Pn(n)};let r=Fn(e);if(r.kind!==`ok`)return r.result;let i=z(r.path)?B(r.path,`utf-8`):``,a=Rn(i),o=[],s=[];for(let e of t)Ln(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{Me(r.path,`${i}${c}${l}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:o,alreadyPresent:s,removed:[]}}function kn(e,t){let n=Fn(e);if(n.kind!==`ok`)return n.result;if(!z(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>In(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(Tn),i.add(En);let a;try{a=B(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 In(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{Me(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function An(e){let t=Fn(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!z(t.path))return`shared`;let n;try{n=B(t.path,`utf-8`)}catch{return`shared`}let r=Rn(n),i=Dn(e);for(let e of i)if(Ln(r,e))return`local-only`;return r.has(Tn)?`local-only`:`shared`}function jn(e){let t=Fn(e);if(t.kind!==`ok`||!z(t.path))return[];let n;try{n=B(t.path,`utf-8`)}catch{return[]}let r=Rn(n);return Dn(e).filter(e=>Ln(r,e))}function Mn(e){let t=Fn(e);if(t.kind!==`ok`||!z(t.path))return!1;let n;try{n=B(t.path,`utf-8`)}catch{return!1}let r=Rn(n);return r.has(Tn)&&r.has(En)}function Nn(e,t){let n=[];for(let r of t)if(z(we(e,r)))try{Se(`git`,[`ls-files`,`--error-unmatch`,`--`,r],w({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}return{tracked:n}}function Pn(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(`
21
- `)}function Fn(e){let t=l(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 z(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 In(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function Ln(e,t){for(let n of In(t))if(e.has(n))return!0;return!1}function Rn(e){let t=new Set;for(let n of e.split(`
22
- `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function zn(e,t){return Bn(L(t,e))}function Bn(e){return Te===`/`?e:e.split(Te).join(`/`)}function Vn(e){for(let t of e.split(`
23
- `)){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 Hn(e){let t=(e.match(/\r\n/g)??[]).length;return t===0?!1:t>=(e.match(/\n/g)??[]).length-t}function Un(e){try{return je(e).mode&511}catch{return}}function Wn(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
24
- `)?`\r
25
- `:`
26
- `,a=p(r,t,void 0,{formattingOptions:{...Vn(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${u(r,a)}`;return{text:o,changed:o!==e}}const Gn={icon:{checked:V(`green`,K.circleFilled),unchecked:K.circle,cursor:K.pointer,disabledChecked:V(`green`,K.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 Kn(e){return!Y.isSeparator(e)&&!e.disabled}function qn(e){return!Y.isSeparator(e)}function Jn(e){return!Y.isSeparator(e)&&e.checked}function Yn(e){return Kn(e)?{...e,checked:!e.checked}:e}function Xn(e){return function(t){return Kn(t)?{...t,checked:e}:t}}function Zn(e){return e.map(e=>{if(Y.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 Qn=Cn((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=_t(Gn,e.theme),{keybindings:c}=s,[l,u]=G(`idle`),d=vt({status:l,theme:s}),[f,p]=G(Zn(e.choices)),m=yt(()=>{let e=f.findIndex(qn),t=f.findLastIndex(qn);if(e===-1)throw new Ze(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=G(m.first),[_,v]=G();xt(async e=>{if(Ke(e)){let e=f.filter(Jn),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)||He(e,c)){if(_&&v(void 0),r||H(e,c)&&h!==m.first||He(e,c)&&h!==m.last){let t=H(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!qn(f[n]));g(n)}}else if(Ue(e)){let e=f[h];e&&!Y.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?Yn(e):e))))}else if(e.name===o.all){let e=f.some(e=>Kn(e)&&!e.checked);p(f.map(Xn(e)))}else if(e.name===o.invert)p(f.map(Yn));else if(Ge(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>Y.isSeparator(e)?!1:(n++,n===t)),i=f[r];i&&Kn(i)&&(g(r),p(f.map((e,t)=>t===r?Yn(e):e)))}});let y=s.style.message(e.message,l),b,x=Yt({items:f,active:h,renderItem({item:e,isActive:t}){if(Y.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(Jn);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(`
27
- `).trimEnd()}${dn}`});const $n={icon:{cursor:K.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 er(e){return!Y.isSeparator(e)&&!e.disabled}function tr(e){return!Y.isSeparator(e)}function nr(e){return e.map(e=>{if(Y.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 rr=Cn((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=_t($n,e.theme),{keybindings:a}=i,[o,s]=G(`idle`),c=vt({status:o,theme:i}),l=bt(),u=!a.includes(`vim`),d=yt(()=>nr(e.choices),[e.choices]),f=yt(()=>{let e=d.findIndex(tr),t=d.findLastIndex(tr);if(e===-1)throw new Ze(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=yt(()=>`default`in e?d.findIndex(t=>er(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=G(p===-1?f.first:p),g=d[m];if(g==null||Y.isSeparator(g))throw Error(`Active index does not point to a choice`);let[_,v]=G();xt((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Ke(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(H(e,a)||He(e,a)){if(r.clearLine(0),n||H(e,a)&&m!==f.first||He(e,a)&&m!==f.last){let t=H(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!tr(d[n]));h(n)}}else if(Ge(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>Y.isSeparator(n)?!1:(t++,t===e)),i=d[n];i!=null&&er(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(We(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>Y.isSeparator(t)||!er(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),ot(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Yt({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(Y.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(`
28
- `).trimEnd()}${dn}`});
29
- /*!
30
- * Copyright (c) Squirrel Chat et al., All rights reserved.
31
- * SPDX-License-Identifier: BSD-3-Clause
32
- *
33
- * Redistribution and use in source and binary forms, with or without
34
- * modification, are permitted provided that the following conditions are met:
35
- *
36
- * 1. Redistributions of source code must retain the above copyright notice, this
37
- * list of conditions and the following disclaimer.
38
- * 2. Redistributions in binary form must reproduce the above copyright notice,
39
- * this list of conditions and the following disclaimer in the
40
- * documentation and/or other materials provided with the distribution.
41
- * 3. Neither the name of the copyright holder nor the names of its contributors
42
- * may be used to endorse or promote products derived from this software without
43
- * specific prior written permission.
44
- *
45
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
49
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55
- */
56
- let ir=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var ar=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(ir);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}};
57
- /*!
58
- * Copyright (c) Squirrel Chat et al., All rights reserved.
59
- * SPDX-License-Identifier: BSD-3-Clause
60
- *
61
- * Redistribution and use in source and binary forms, with or without
62
- * modification, are permitted provided that the following conditions are met:
63
- *
64
- * 1. Redistributions of source code must retain the above copyright notice, this
65
- * list of conditions and the following disclaimer.
66
- * 2. Redistributions in binary form must reproduce the above copyright notice,
67
- * this list of conditions and the following disclaimer in the
68
- * documentation and/or other materials provided with the distribution.
69
- * 3. Neither the name of the copyright holder nor the names of its contributors
70
- * may be used to endorse or promote products derived from this software without
71
- * specific prior written permission.
72
- *
73
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
74
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
75
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
76
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
77
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
78
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
79
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
80
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
81
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
82
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83
- */
84
- function or(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function sr(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+=`
85
- `,e===t&&(i+=` `.repeat(a+n+2),i+=`^
86
- `))}return i}var X=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=or(t.toml,t.ptr),i=sr(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
87
- /*!
88
- * Copyright (c) Squirrel Chat et al., All rights reserved.
89
- * SPDX-License-Identifier: BSD-3-Clause
90
- *
91
- * Redistribution and use in source and binary forms, with or without
92
- * modification, are permitted provided that the following conditions are met:
93
- *
94
- * 1. Redistributions of source code must retain the above copyright notice, this
95
- * list of conditions and the following disclaimer.
96
- * 2. Redistributions in binary form must reproduce the above copyright notice,
97
- * this list of conditions and the following disclaimer in the
98
- * documentation and/or other materials provided with the distribution.
99
- * 3. Neither the name of the copyright holder nor the names of its contributors
100
- * may be used to endorse or promote products derived from this software without
101
- * specific prior written permission.
102
- *
103
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
104
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
105
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
106
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
107
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
108
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
109
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
110
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
111
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
112
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113
- */
114
- let cr=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,lr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,ur=/^[+-]?0[0-9_]/;function dr(e,t){let n=e[t++],r=n,i=n===`'`,a=n===e[t]&&n===e[t+1];a&&(e[t+=2]===`
115
- `?t++:e[t]===`\r`&&e[t+1]===`
116
- `&&(t+=2));let o=``,s=t,c=0;for(let l=t;l<e.length;l++)if(n=e[l],a&&(n===`
117
- `||n===`\r`&&e[l+1]===`
118
- `))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+=`
119
- `;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 fr(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=cr.test(e);if(i||lr.test(e)){if(ur.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 ar(e);if(!a.isValid())throw new X(`invalid value`,{toml:t,ptr:n});return a}
120
- /*!
121
- * Copyright (c) Squirrel Chat et al., All rights reserved.
122
- * SPDX-License-Identifier: BSD-3-Clause
123
- *
124
- * Redistribution and use in source and binary forms, with or without
125
- * modification, are permitted provided that the following conditions are met:
126
- *
127
- * 1. Redistributions of source code must retain the above copyright notice, this
128
- * list of conditions and the following disclaimer.
129
- * 2. Redistributions in binary form must reproduce the above copyright notice,
130
- * this list of conditions and the following disclaimer in the
131
- * documentation and/or other materials provided with the distribution.
132
- * 3. Neither the name of the copyright holder nor the names of its contributors
133
- * may be used to endorse or promote products derived from this software without
134
- * specific prior written permission.
135
- *
136
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
137
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
138
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
139
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
140
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
141
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
142
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
143
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
144
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146
- */
147
- function pr(e,t=0,n=e.length){let r=e.indexOf(`
148
- `,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function mr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
149
- `)return n;if(r===`\r`&&e[n+1]===`
150
- `)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===`
151
- `||i===`\r`&&e[t+1]===`
152
- `);)t++;if(r||i!==`#`)break;t=mr(e,t)}return t}function hr(e,t,n,r,i=!1){if(!r)return t=pr(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=pr(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
153
- `||t===`\r`&&e[a+1]===`
154
- `))return a}throw new X(`cannot find end of structure`,{toml:e,ptr:t})}
155
- /*!
156
- * Copyright (c) Squirrel Chat et al., All rights reserved.
157
- * SPDX-License-Identifier: BSD-3-Clause
158
- *
159
- * Redistribution and use in source and binary forms, with or without
160
- * modification, are permitted provided that the following conditions are met:
161
- *
162
- * 1. Redistributions of source code must retain the above copyright notice, this
163
- * list of conditions and the following disclaimer.
164
- * 2. Redistributions in binary form must reproduce the above copyright notice,
165
- * this list of conditions and the following disclaimer in the
166
- * documentation and/or other materials provided with the distribution.
167
- * 3. Neither the name of the copyright holder nor the names of its contributors
168
- * may be used to endorse or promote products derived from this software without
169
- * specific prior written permission.
170
- *
171
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
172
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
173
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
174
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
175
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
176
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
177
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
178
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
179
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
180
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
181
- */
182
- function gr(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(mr(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function _r(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===`[`?xr(e,t,r,i):br(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]=dr(e,t);if(n){if(i=Z(e,i),e[i]&&e[i]!==`,`&&e[i]!==n&&e[i]!==`
183
- `&&e[i]!==`\r`)throw new X(`unexpected character encountered`,{toml:e,ptr:i});e[i]===`,`&&i++}return[r,i]}let o=hr(e,t,`,`,n),s=gr(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++),[fr(s[0],e,t,i),o]}
184
- /*!
185
- * Copyright (c) Squirrel Chat et al., All rights reserved.
186
- * SPDX-License-Identifier: BSD-3-Clause
187
- *
188
- * Redistribution and use in source and binary forms, with or without
189
- * modification, are permitted provided that the following conditions are met:
190
- *
191
- * 1. Redistributions of source code must retain the above copyright notice, this
192
- * list of conditions and the following disclaimer.
193
- * 2. Redistributions in binary form must reproduce the above copyright notice,
194
- * this list of conditions and the following disclaimer in the
195
- * documentation and/or other materials provided with the distribution.
196
- * 3. Neither the name of the copyright holder nor the names of its contributors
197
- * may be used to endorse or promote products derived from this software without
198
- * specific prior written permission.
199
- *
200
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
201
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
202
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
203
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
204
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
205
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
206
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
207
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
208
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
209
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
210
- */
211
- let vr=/^[a-zA-Z0-9-_]+[ \t]*$/;function yr(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]=dr(e,t);r=e.indexOf(`.`,c);let l=e.slice(c,r<0||r>a?a:r),u=pr(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(!vr.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 br(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=mr(e,t);else if(o!==` `&&o!==` `&&o!==`
212
- `&&o!==`\r`){let o,s=i,c=!1,[l,u]=yr(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]=_r(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 xr(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=mr(e,t);else if(a!==` `&&a!==` `&&a!==`
213
- `&&a!==`\r`){let a=_r(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]}
214
- /*!
215
- * Copyright (c) Squirrel Chat et al., All rights reserved.
216
- * SPDX-License-Identifier: BSD-3-Clause
217
- *
218
- * Redistribution and use in source and binary forms, with or without
219
- * modification, are permitted provided that the following conditions are met:
220
- *
221
- * 1. Redistributions of source code must retain the above copyright notice, this
222
- * list of conditions and the following disclaimer.
223
- * 2. Redistributions in binary form must reproduce the above copyright notice,
224
- * this list of conditions and the following disclaimer in the
225
- * documentation and/or other materials provided with the distribution.
226
- * 3. Neither the name of the copyright holder nor the names of its contributors
227
- * may be used to endorse or promote products derived from this software without
228
- * specific prior written permission.
229
- *
230
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
231
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
232
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
233
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
234
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
235
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
236
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
237
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
238
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
239
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
240
- */
241
- function Sr(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 Cr(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=yr(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=Sr(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=yr(e,s),i=Sr(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=_r(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]!==`
242
- `&&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}
243
- /*!
244
- * Copyright (c) Squirrel Chat et al., All rights reserved.
245
- * SPDX-License-Identifier: BSD-3-Clause
246
- *
247
- * Redistribution and use in source and binary forms, with or without
248
- * modification, are permitted provided that the following conditions are met:
249
- *
250
- * 1. Redistributions of source code must retain the above copyright notice, this
251
- * list of conditions and the following disclaimer.
252
- * 2. Redistributions in binary form must reproduce the above copyright notice,
253
- * this list of conditions and the following disclaimer in the
254
- * documentation and/or other materials provided with the distribution.
255
- * 3. Neither the name of the copyright holder nor the names of its contributors
256
- * may be used to endorse or promote products derived from this software without
257
- * specific prior written permission.
258
- *
259
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
260
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
261
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
262
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
263
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
264
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
265
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
266
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
267
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
268
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
269
- */
270
- let wr=/^[a-z0-9-_]+$/i;function Tr(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function Er(e){for(let t=0;t<e.length;t++)if(Tr(e[t])!==`object`)return!1;return e.length!=0}function Dr(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function Or(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 Dr(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return kr(e,n,r);if(t===`array`)return Ar(e,n,r)}function kr(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+=wr.test(o)?o:Dr(o),i+=` = `,i+=Or(e[o],Tr(e[o]),t-1,n)}return i+` }`}function Ar(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+=Or(e[i],Tr(e[i]),t-1,n)}return r+` ]`}function jr(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&&`
271
- `}[[${t}]]\n`,i+=Mr(0,e[a],t,n,r);return i}function Mr(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=Tr(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=wr.test(c)?c:Dr(c);if(e===`array`&&Er(t[c]))o+=(o&&`
272
- `)+jr(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
273
- `)+Mr(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=Or(t[c],e,r,i),a+=`
274
- `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Nr(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Tr(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Mr(0,e,``,t,n);return r[r.length-1]===`
275
- `?r:r+`
276
- `}const Pr=`${le}-dev`;function Fr(e){return e.startsWith(le)}function Ir(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`&&Fr(n)}function Lr(e){return{command:ge,args:[e]}}function Rr(e={}){let t=e.mode===`dev`?Pr:fe,n={unix:ue({...e,platformName:`darwin`}),win32:ue({...e,platformName:`win32`})};return`${t}
277
- /**
278
- * Open Knowledge bridge for Pi — MANAGED FILE, written by \`ok init\`.
279
- * Hand edits are overwritten whenever OK re-syncs this project; remove it
280
- * with \`ok deinit\` (or delete the file) to disconnect Pi from OK.
281
- *
282
- * On session start it spawns Open Knowledge's MCP stdio server via OK's
283
- * resilient launcher (bundle, then npx, then version-manager probes), performs
284
- * the MCP handshake, and registers each MCP tool as a Pi tool under an
285
- * \`ok_\` prefix (Pi has no MCP namespacing; the prefix keeps OK's \`edit\` /
286
- * \`write\` from shadowing Pi's built-in tools).
287
- */
288
- import { spawn } from "node:child_process";
289
- import type { ChildProcessWithoutNullStreams } from "node:child_process";
290
-
291
- const LAUNCHERS = ${JSON.stringify(n,null,2)} as const;
292
-
293
- const TOOL_PREFIX = "ok_";
294
- // First contact may cold-install the CLI through npx — allow a generous window.
295
- const INIT_TIMEOUT_MS = 120000;
296
- const STDERR_TAIL_LIMIT = 2000;
297
-
298
- interface McpContentItem {
299
- type: string;
300
- text?: string;
301
- }
302
-
303
- interface McpToolInfo {
304
- name: string;
305
- description?: string;
306
- inputSchema?: Record<string, unknown>;
307
- }
308
-
309
- interface PendingRequest {
310
- resolve: (value: Record<string, unknown>) => void;
311
- reject: (err: Error) => void;
312
- }
313
-
314
- class OkMcpClient {
315
- private child: ChildProcessWithoutNullStreams;
316
- private pending = new Map<number, PendingRequest>();
317
- private nextId = 1;
318
- private buffer = "";
319
- private stderrTail = "";
320
- alive = true;
321
-
322
- constructor(cwd: string, onExit: () => void) {
323
- const launcher = process.platform === "win32" ? LAUNCHERS.win32 : LAUNCHERS.unix;
324
- const env: Record<string, string | undefined> = { ...process.env };
325
- const launcherEnv = (launcher as { env?: Record<string, string> }).env;
326
- if (launcherEnv) Object.assign(env, launcherEnv);
327
- this.child = spawn(launcher.command, [...launcher.args], {
328
- cwd,
329
- env,
330
- stdio: ["pipe", "pipe", "pipe"],
331
- // Inline (not the withHiddenWindowsConsole helper): this spawn lives in the
332
- // GENERATED Pi extension source, which must stay dependency-free (Pi loads
333
- // it with jiti; no npm packages resolve). Hide the console on Windows anyway.
334
- windowsHide: true,
335
- });
336
- this.child.stdout.setEncoding("utf8");
337
- this.child.stdout.on("data", (chunk: string) => this.onStdout(chunk));
338
- this.child.stderr.setEncoding("utf8");
339
- this.child.stderr.on("data", (chunk: string) => {
340
- this.stderrTail = (this.stderrTail + chunk).slice(-STDERR_TAIL_LIMIT);
341
- });
342
- // A write buffered before the pipe breaks surfaces as an 'error' on stdin
343
- // (not on the child); unhandled it would crash Pi's extension host.
344
- // Swallow it — the exit handler owns teardown.
345
- this.child.stdin.on("error", () => {});
346
- const fail = () => {
347
- if (!this.alive) return;
348
- this.alive = false;
349
- const err = new Error(
350
- "Open Knowledge MCP server exited" +
351
- (this.stderrTail ? ": " + this.stderrTail.trim() : ""),
352
- );
353
- for (const p of this.pending.values()) p.reject(err);
354
- this.pending.clear();
355
- onExit();
356
- };
357
- this.child.on("exit", fail);
358
- this.child.on("error", fail);
359
- }
360
-
361
- private onStdout(chunk: string): void {
362
- this.buffer += chunk;
363
- let newline = this.buffer.indexOf("\\n");
364
- while (newline !== -1) {
365
- const line = this.buffer.slice(0, newline).trim();
366
- this.buffer = this.buffer.slice(newline + 1);
367
- if (line.startsWith("{")) {
368
- try {
369
- this.onMessage(JSON.parse(line) as Record<string, unknown>);
370
- } catch {
371
- // Non-JSON noise on stdout is ignored; framing recovers on the next line.
372
- }
373
- }
374
- newline = this.buffer.indexOf("\\n");
375
- }
376
- }
377
-
378
- private onMessage(msg: Record<string, unknown>): void {
379
- const id = msg.id;
380
- if (typeof msg.method === "string") {
381
- // Server-initiated request (e.g. roots/list). This bridge declares no
382
- // client capabilities, so decline rather than leave the server hanging.
383
- if (id !== undefined && id !== null) {
384
- this.send({
385
- jsonrpc: "2.0",
386
- id,
387
- error: { code: -32601, message: "Method not supported by the OK Pi bridge" },
388
- });
389
- }
390
- return;
391
- }
392
- if (typeof id !== "number") return;
393
- const pending = this.pending.get(id);
394
- if (!pending) return;
395
- this.pending.delete(id);
396
- const error = msg.error as { message?: string } | undefined;
397
- if (error) {
398
- pending.reject(new Error(error.message || "Open Knowledge MCP error"));
399
- return;
400
- }
401
- pending.resolve((msg.result ?? {}) as Record<string, unknown>);
402
- }
403
-
404
- private send(msg: Record<string, unknown>): void {
405
- // Buffered stdout can still dispatch onMessage replies after close() ends
406
- // stdin; writing then would raise ERR_STREAM_WRITE_AFTER_END unhandled.
407
- if (!this.alive) return;
408
- this.child.stdin.write(JSON.stringify(msg) + "\\n");
409
- }
410
-
411
- request(
412
- method: string,
413
- params: Record<string, unknown>,
414
- opts: { timeoutMs?: number; signal?: AbortSignal } = {},
415
- ): Promise<Record<string, unknown>> {
416
- if (!this.alive) return Promise.reject(new Error("Open Knowledge MCP server is not running"));
417
- const id = this.nextId++;
418
- return new Promise<Record<string, unknown>>((resolve, reject) => {
419
- let timer: ReturnType<typeof setTimeout> | undefined;
420
- let onAbort: (() => void) | undefined;
421
- const cleanup = () => {
422
- if (timer !== undefined) clearTimeout(timer);
423
- if (onAbort && opts.signal) opts.signal.removeEventListener("abort", onAbort);
424
- this.pending.delete(id);
425
- };
426
- const done: PendingRequest = {
427
- resolve: (value) => {
428
- cleanup();
429
- resolve(value);
430
- },
431
- reject: (err) => {
432
- cleanup();
433
- reject(err);
434
- },
435
- };
436
- this.pending.set(id, done);
437
- if (opts.timeoutMs) {
438
- timer = setTimeout(() => {
439
- done.reject(new Error(method + " timed out after " + opts.timeoutMs + "ms"));
440
- }, opts.timeoutMs);
441
- }
442
- if (opts.signal) {
443
- onAbort = () => {
444
- this.notify("notifications/cancelled", { requestId: id, reason: "aborted" });
445
- done.reject(new Error("Cancelled"));
446
- };
447
- if (opts.signal.aborted) {
448
- onAbort();
449
- return;
450
- }
451
- opts.signal.addEventListener("abort", onAbort, { once: true });
452
- }
453
- this.send({ jsonrpc: "2.0", id, method, params });
454
- });
455
- }
456
-
457
- notify(method: string, params: Record<string, unknown>): void {
458
- if (!this.alive) return;
459
- this.send({ jsonrpc: "2.0", method, params });
460
- }
461
-
462
- close(): void {
463
- this.alive = false;
464
- for (const p of this.pending.values()) {
465
- p.reject(new Error("Open Knowledge MCP client closed"));
466
- }
467
- this.pending.clear();
468
- // ok mcp exits on stdin EOF; the delayed kill is a backstop.
469
- try {
470
- this.child.stdin.end();
471
- } catch {
472
- // Already gone.
473
- }
474
- const child = this.child;
475
- setTimeout(() => {
476
- try {
477
- child.kill();
478
- } catch {
479
- // Already gone.
480
- }
481
- }, 2000).unref();
482
- }
483
- }
484
-
485
- /** JSON Schema pass-through: Pi validates plain JSON Schema parameters. */
486
- function toParameters(inputSchema: Record<string, unknown> | undefined): Record<string, unknown> {
487
- if (!inputSchema || typeof inputSchema !== "object") {
488
- return { type: "object", properties: {} };
489
- }
490
- const schema = { ...inputSchema };
491
- delete schema.$schema;
492
- return schema;
493
- }
494
-
495
- function contentText(content: unknown): string {
496
- if (!Array.isArray(content)) return "";
497
- return (content as McpContentItem[])
498
- .filter((item) => item && item.type === "text" && typeof item.text === "string")
499
- .map((item) => item.text as string)
500
- .join("\\n");
501
- }
502
-
503
- export default function okBridge(pi: {
504
- on(event: string, handler: (event: unknown, ctx: unknown) => unknown): void;
505
- registerTool(definition: Record<string, unknown>): void;
506
- }) {
507
- let client: OkMcpClient | null = null;
508
- let starting: Promise<OkMcpClient> | null = null;
509
- let sessionCwd = process.cwd();
510
- const registeredTools = new Set<string>();
511
-
512
- async function ensureClient(): Promise<OkMcpClient> {
513
- if (client && client.alive) return client;
514
- if (starting) return starting;
515
- starting = (async () => {
516
- const next = new OkMcpClient(sessionCwd, () => {
517
- if (client === next) client = null;
518
- });
519
- try {
520
- await next.request(
521
- "initialize",
522
- {
523
- protocolVersion: "2025-06-18",
524
- capabilities: {},
525
- clientInfo: { name: "pi", version: "1.0.0" },
526
- },
527
- { timeoutMs: INIT_TIMEOUT_MS },
528
- );
529
- } catch (err) {
530
- // A timed-out initialize rejects the request while the child may
531
- // still be running; tear it down so retries don't stack orphans.
532
- next.close();
533
- throw err;
534
- }
535
- next.notify("notifications/initialized", {});
536
- client = next;
537
- return next;
538
- })();
539
- try {
540
- return await starting;
541
- } finally {
542
- starting = null;
543
- }
544
- }
545
-
546
- async function registerOkTools(): Promise<number> {
547
- const mcp = await ensureClient();
548
- const listed = await mcp.request("tools/list", {}, { timeoutMs: INIT_TIMEOUT_MS });
549
- const tools = Array.isArray(listed.tools) ? (listed.tools as McpToolInfo[]) : [];
550
- for (const tool of tools) {
551
- const name = TOOL_PREFIX + tool.name;
552
- if (registeredTools.has(name)) continue;
553
- registeredTools.add(name);
554
- pi.registerTool({
555
- name,
556
- label: "OK " + tool.name,
557
- description: tool.description || "Open Knowledge " + tool.name + " tool.",
558
- parameters: toParameters(tool.inputSchema),
559
- execute: async (
560
- _toolCallId: string,
561
- params: Record<string, unknown>,
562
- signal: AbortSignal | undefined,
563
- ) => {
564
- const live = await ensureClient();
565
- const result = await live.request(
566
- "tools/call",
567
- { name: tool.name, arguments: params ?? {} },
568
- { signal },
569
- );
570
- const text = contentText(result.content);
571
- if (result.isError) {
572
- throw new Error(text || "Open Knowledge tool " + tool.name + " failed");
573
- }
574
- return {
575
- content: [{ type: "text", text }],
576
- details: result.structuredContent,
577
- };
578
- },
579
- });
580
- }
581
- return tools.length;
582
- }
583
-
584
- pi.on("session_start", async (_event, ctx) => {
585
- const cwd = (ctx as { cwd?: string } | undefined)?.cwd;
586
- if (typeof cwd === "string" && cwd.length > 0) sessionCwd = cwd;
587
- try {
588
- await registerOkTools();
589
- } catch (err) {
590
- const ui = (ctx as { ui?: { notify?: (m: string, level: string) => void } } | undefined)?.ui;
591
- try {
592
- ui?.notify?.(
593
- "Open Knowledge tools unavailable: " + (err instanceof Error ? err.message : String(err)),
594
- "warning",
595
- );
596
- } catch {
597
- // Non-interactive mode; the failure will resurface on first tool use.
598
- }
599
- }
600
- });
601
-
602
- pi.on("session_shutdown", async () => {
603
- const pending = starting;
604
- starting = null;
605
- const current = client;
606
- client = null;
607
- current?.close();
608
- // An in-flight ensureClient would otherwise assign a live client after
609
- // shutdown; await it and tear that one down too.
610
- if (pending) {
611
- try {
612
- (await pending).close();
613
- } catch {
614
- // Initialization failed — its catch path already closed the client.
615
- }
616
- }
617
- });
618
- }
619
- `}function zr(e){try{return Ae.native(e)}catch{return e}}function Br(e,t){let n=L(zr(t),zr(e));return n.length>0&&!n.startsWith(`..`)&&!Ce(n)}const Vr=e=>{try{let t=Se(`git`,[`rev-parse`,`--show-toplevel`],w({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function Hr(e,t={}){let n=t.homeDir??Ne(),r=t.gitTopLevel??Vr,i=we(e),a;try{a=Ae(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(m(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&&Br(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 Ur(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 Wr=[`native`,`index.js`];function Gr(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??xe(t);try{return n(I(F(Ee(t)),...Wr))}catch(e){Ur(e)||Q(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return Ur(e)||Q(`workspace addon failed to load`,e),null}}function Kr(){let e=Gr();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function qr(e){let t=e,n=new Set;for(;;){let r;try{r=De(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=ke(t)}catch(t){return Q(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=Ce(i)?i:I(F(t),i)}}let Jr;function Yr(){return Jr===void 0&&(Jr=Kr()),Jr}function Xr(e,t=Yr){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 qr(e)}function Zr(){let e=Gr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Qr(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 $r(e){if(!N(e))throw Error(`TOML root is not a table`);return e}function ei(e){return{backend:`native`,parseToObject(t){return $r(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 ti(){return{backend:`fallback`,parseToObject(e){return $r(Cr(e))}}}function ni(e=Zr){let t=e();return t&&Qr(t)?ei(t):ti()}let ri=null;function ii(){return ri===null&&(ri=ni()),ri}function ai(){let e=ii();return e.backend===`native`?e:void 0}const oi={allowTrailingComma:!0,disallowComments:!1};function si(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function ci(e){let t=[],n=v(e,t,oi);return t.some(t=>!si(t,e))||!n||n.type!==`object`?null:n}function li(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&_(e)===t&&(n+=1)}return n}function ui(e,t){T(e,`${JSON.stringify(t,null,2)}\n`)}function di(e,t){let n=Nr(t);T(e,n.endsWith(`
620
- `)?n:`${n}\n`)}function fi(e,t){let n=(0,wn.stringify)(t);T(e,n.endsWith(`
621
- `)?n:`${n}\n`)}const pi=10*1024*1024;function mi(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)=>mi(e,t[n]));if(N(e)&&N(t)){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>Object.hasOwn(t,n)&&mi(e[n],t[n])):!1}return!1}const hi=[`command`,`args`],gi=[`type`,`command`];function _i(e){return e.type===`local`&&Array.isArray(e.command)?gi:hi}function vi(e,t,n){return N(e)&&n.every(n=>mi(e[n],t[n]))}function yi(e){for(let t of e.split(`
622
- `)){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 bi(e,t,n){return t===void 0?[e,n]:[e,t,n]}function xi(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function Si(e,t,n){let r=e[t];return n===void 0?r:N(r)?r[n]:void 0}function Ci(e,t,n,r,i){if(!z(e))return ui(e,xi(t,i,n,r)),{kind:`written`};let a;try{a=B(e,`utf-8`)}catch(e){return Q(`json config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(a.trim()===``)return ui(e,xi(t,i,n,r)),{kind:`written`};if(Buffer.byteLength(a,`utf-8`)>pi)return{kind:`declined`,reason:`oversize`};let o=ci(a);if(!o)return{kind:`declined`,reason:`unparseable`};if(li(o,t)>1)return{kind:`declined`,reason:`duplicate-container`};let s=Si(_(o),t,i),c=N(s)?s[n]:void 0,l=c!==void 0,d=_i(r);if(l&&vi(c,r,d))return{kind:`overwritten`};let f=a.charCodeAt(0)===65279,m=f?a.slice(1):a,h=m.includes(`\r
623
- `)?`\r
624
- `:`
625
- `,g={...yi(m),eol:h},v=bi(t,i,n),y=m;if(l&&N(c))for(let e of d){let t=p(y,[...v,e],r[e],{formattingOptions:g});y=u(y,t)}else{let e=p(y,v,r,{formattingOptions:g});y=u(y,e)}let b=`${f?``:``}${y}`;return b!==a&&T(e,b,{mode:Un(e)}),{kind:l?`overwritten`:`written`}}function wi(e,t,n,r,i){let a=``;if(z(t))try{a=B(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?(di(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=Hn(c),u=o||c.endsWith(`
626
- `),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(`
627
- `)||(f=`${f}\n`):f=f.replace(/\n+$/,``),l&&(f=f.replace(/\r\n/g,`
628
- `).replace(/\n/g,`\r
629
- `));let p=`${s?``:``}${f}`;return p!==a&&T(t,p,{mode:Un(t)}),{kind:d.existed?`overwritten`:`written`}}function Ti(e,t,n,r){let i=``;if(z(e))try{i=B(e,`utf-8`)}catch(e){return Q(`yaml config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(i.trim()===``)return fi(e,{[t]:{[n]:r}}),{kind:`written`};if(Buffer.byteLength(i,`utf-8`)>pi)return{kind:`declined`,reason:`oversize`};let a=i.charCodeAt(0)===65279,o=a?i.slice(1):i,s=(0,wn.parseDocument)(o);if(s.errors.length>0)return{kind:`declined`,reason:`unparseable`};let c=[t,n],l=s.hasIn(c);s.hasIn([t])&&!(0,wn.isCollection)(s.getIn([t],!0))&&s.deleteIn([t]);let u=s.getIn(c,!0);if(l&&(0,wn.isCollection)(u))for(let e of _i(r))s.setIn([...c,e],s.createNode(r[e]));else s.setIn(c,s.createNode(r));let d=s.toString(),f=Hn(o);o.endsWith(`
630
- `)?d.endsWith(`
631
- `)||(d=`${d}\n`):d=d.replace(/\n+$/,``),f&&(d=d.replace(/\r\n/g,`
632
- `).replace(/\n/g,`\r
633
- `));let p=`${a?``:``}${d}`;return p!==i&&T(e,p,{mode:Un(e)}),{kind:l?`overwritten`:`written`}}const Ei=e=>e!==`project`,Di=e=>e!==`user`;async function Oi(){let e=await Qn({message:`Where should the MCP server be configured?
634
- `,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 ki(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Oi)():`both`}async function Ai(e){return rr({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 ji(e){if(e.sharing!==void 0)return e.sharing;let t=An(e.projectRoot)===`local-only`?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Ai)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Mi(e){if(e===void 0||e===!0)return new Set(d);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(h.filter(e=>t.includes(e)))}function Ni(e,t,n){let r=we(n,e),i;try{i=je(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(Pi(t),Pi(r));if(a.startsWith(`..`)||Ce(a))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return a===``?`.`:a}function Pi(e){try{return Ae(e)}catch{return e}}const Fi=`open-knowledge-ui`;function Ii(e,t,n){try{return z(e.detectPath?.(t,n)??F(e.configPath(t,n)))}catch{return!1}}function Li(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&&!Ii(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{he(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 zi(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{Oe(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{se(`${o}.lock`,()=>{let t=Xr(o).writePath;if(Oe(F(t),{recursive:!0}),e.format===`toml`){let n=wi(ii(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=Ti(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=Ci(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 Ri={pi:Rr};function zi(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=Ri[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{Oe(F(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{se(`${t}.lock`,()=>{let e=null;try{e=B(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Un(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 Bi(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!z(n)))return{editorId:e.id,label:e.label,path:n}}function Vi(e,t,n,r){let i=Ui(e,t,n,r);return i.kind===`present`?i.entry:null}function Hi(e,t,n,r){let i=Si(e,t,r);if(!N(i))return{kind:`no-entry`};let a=i[n];return N(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Ui(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!z(i))return{kind:`absent`};try{if(je(i).size>pi)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=B(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Lr(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ii().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Hi(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,wn.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Hi(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=ci(a);return s?li(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Hi(_(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Wi(e={}){let t=we(e.cwd??process.cwd()),n=Hr(t,{homeDir:e.home}),r=n.projectRoot,i=!z(I(r,`.ok`)),a=n.gitRootPromoted?L(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:Ni(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${j(`[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`},l=await re(r),u;try{u=g(r,{contentDir:o})}catch(t){let i=pe.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let d=u.created.includes(ye),p=!1;if(l.didInit)try{p=ae(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{oe(r)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore entry at ${r}: ${e instanceof Error?e.message:String(e)}`)}let m=await y(r);m.kind===`untracked`&&console.warn(`[ok] Untracked the OpenKnowledge project skill (${m.dirs.join(`, `)}) — it is now local-only. Teammates will see this as a deletion on their next pull.`);let _=await ki({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),v=e.editors??Xi(r,e.home),x=e.editors??v,C=ce(v),te=ce(x),w=e.mcp===!1||_===null,T=Array.from(new Map([...C,...w?[]:te].map(e=>[e.id,e])).values()),se=C.filter(t=>Ii(t,r,e.home)),E=[],D=[],le=new Set;for(let t of T){if(w){let n=``;try{n=t.configPath(r,e.home)}catch{}E.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Ei(_)&&C.includes(t)&&t.scope===`global`&&E.push(Li(t,r,s,e.home)),Di(_)&&te.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Li(t,r,s,e.home,n);E.push(i),(i.action===`written`||i.action===`overwritten`)&&le.add(n)}}let ue=new Set;for(let t of te){let n=t.projectSkillPath?.(r);!n||ue.has(n)||(ue.add(n),D.push(me(t,r,{home:e.home})))}let de=D.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(de.length>0){let t=e.home??Ne();S({source:c,skills:[f.project],agents:de,scope:r},{home:t,enabled:ie(t).enabled})}let fe=!w&&_!==null&&Di(_)?te.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,he=w?[]:se.map(e=>Bi(e,r)).filter(e=>e!==void 0).filter(e=>!le.has(e.path)),ge=e.installUserSkill??ne,_e=e.home??Ne(),O=Mi(e.skills),k=!1,A=!1,ve=!1,M=!1,N=!1;for(let t of h){if(!O.has(t))continue;await b(_e,f[t],!0).catch(()=>{}),k=!0;let n=await ge({home:e.home,bundleId:t,force:!0});n===`installed`?A=!0:n===`failed`?ve=!0:n===`no-hosts`?N=!0:M=!0}let be=ve?`failed`:A?`installed`:k&&M?`skip-current`:k&&N?`no-hosts`:`declined`,xe=A?ee(_e).map(e=>e.editorId):[],Se=w?`skipped-flag`:`skipped-missing`,P=E.find(e=>e.editorId===`claude`)??E[0]??{action:Se,configPath:pe.claude.configPath(r,e.home)},F=await Gi({projectRoot:r,desiredMode:await ji({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:E,projectSkills:D,legacyProjectConfigs:he,skillInstall:be,skillHosts:xe,didGitInit:l.didInit,rootGitignoreCreated:p,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:P.action,mcpPath:P.configPath,mcpError:`error`in P?P.error:void 0,projectScopeUnsupportedLabels:fe,sharing:F}}async function Gi(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=An(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=Dn(t);if(n===`local-only`){let e=On(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`}:Ki(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=kn(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Ki(t,o,`remove`)}function Ki(e,t,n){let r=An(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 qi(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 Ji(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(M(`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(M(`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(M(`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(M(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(M(`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} ${A(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${A(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${ve(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${qi(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(M(`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} ${A(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${A(`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} ${ve(`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(M(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>E[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${A(`installed for ${r}`)}`),n.push(` ${k(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${k(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${A(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${k(`skipped for this run (--no-skills)`)}`),n.push(` ${k(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${k(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${k(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${k(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${j(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${j(` ok repair-skills`)}`);break}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(j(`⚠ --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(j(`⚠ 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(be(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...$i(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(`${A(`✓`)} ${M(`Next steps:`)}`),n.push(` 1. Open your editor (${O(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${O(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${O(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
635
- `)}function Yi(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 Xi(e,t){let n=[];for(let r of de)Ii(pe[r],e,t)&&n.push(r);return n}function Zi(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Fe(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 Qi(){return new _e(`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?Zi():null;try{let r;try{r=await Wi({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 C||e instanceof te){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof x){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.
636
- `),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-CrvsnWLF.mjs`),{resolveContentDir:s}=await import(`./src-COqGK-op.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-uqiPA7dK.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(Yi(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Ji(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function $i(e,t){let n=[];switch(e.kind){case`applied`:return n.push(M(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${A(`local-only`)} — appended ${e.appended.length} path(s) to ${M(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${A(`local-only`)} — already excluded; nothing to do.`):n.push(` ${A(`local-only`)}`):e.action===`removed`?n.push(` ${A(`shared`)} — removed OK paths from ${M(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${A(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(j(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
637
- `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${O(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(j(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${O(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${O(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(j(`Sharing mode unavailable: ${e.reason}.`));return n}}export{jn as A,_t as B,rr as C,Wn as D,Hn as E,kn as F,Ke as H,Cn as I,dn as L,Nn as M,An as N,On as O,Mn as P,xt as R,Ir as S,Un as T,G as V,bi as _,Yi as a,ii as b,Ji as c,Vi as d,Mi as f,Wi as g,ji as h,Gi as i,Dn as j,Pn as k,$i as l,Ni as m,Fi as n,Ui as o,ki as p,Ri as r,Xi as s,$ as t,Qi as u,Li as v,Qn as w,Hr as x,ai as y,vt as z};
638
- //# sourceMappingURL=init-3jheO70m.mjs.map