@inkeep/open-knowledge 0.34.1-beta.0 → 0.35.0-beta.1
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.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +61 -61
- package/dist/constants-DZx62n7t.mjs +2 -0
- package/dist/index.d.mts +47 -18
- package/dist/index.mjs +1 -1
- package/dist/init-CVLKb3oz.mjs +643 -0
- package/dist/init-CzoKldU1.mjs +1 -0
- package/dist/{launch-json-removal-qQEDGjLt.mjs → launch-json-removal-AdTwk3eT.mjs} +2 -2
- package/dist/{loader-D4oknGbJ.mjs → loader-CJD5H4rj.mjs} +2 -2
- package/dist/loader-CU424QQ7.mjs +1 -0
- package/dist/{open-browser-BgoSoXxW.mjs → open-browser-nDAvg8ub.mjs} +2 -2
- package/dist/preview-CM4FOiPe.mjs +1 -0
- package/dist/{preview-CR6Q94oC.mjs → preview-Dq8FTDPe.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-BS9Inl2p.js → ActivityModeContent-DBgWJhkx.js} +1 -1
- package/dist/public/assets/CodeMirrorPropInput-DKUgIQit.js +3 -0
- package/dist/public/assets/{DocumentContext-_YdjpU4z.js → DocumentContext-CWJ7hfZT.js} +19 -19
- package/dist/public/assets/{EnableSyncConfirmDialog-Bi0Sy7lr.js → EnableSyncConfirmDialog-BFsmDIV-.js} +1 -1
- package/dist/public/assets/{GraphPanel-b-saR1id.js → GraphPanel-C5V7tN6C.js} +2 -2
- package/dist/public/assets/{ManagedArtifactProperties-B_Yv-q_s.js → ManagedArtifactProperties-_V5aR-6k.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-Cz64ech9.js → McpConsentDialogBody-BwgO2quE.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-VbdC-S5H.js → MermaidDocEditor-dbbj76iW.js} +1 -1
- package/dist/public/assets/PropertyPanel-hMoN4Hda.js +2 -0
- package/dist/public/assets/{ReportBugDialogBody-BJe4Bl9v.js → ReportBugDialogBody-memFSmPS.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-iVFEfPD7.js → SettingsDialogBody-SwVDm-ay.js} +2 -2
- package/dist/public/assets/{ShareBranchSwitchDialog-Bsz1K5c9.js → ShareBranchSwitchDialog-DI52ZkaG.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-sVGsg1_r.js → ShareReceiveDialog-C8u6PgdG.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-D8ePHs5G.js → ShareReceiveMissDialog-PR-XSxN1.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-CktMr9Fe.js → SkillEditorActions-DG7dmv6Z.js} +1 -1
- package/dist/public/assets/{SourceEditor-DuWP30Wg.js → SourceEditor-FX3akQbF.js} +1 -1
- package/dist/public/assets/{TerminalPanel-CkiN9kJX.js → TerminalPanel-N3nlUpP9.js} +3 -3
- package/dist/public/assets/{agent-presence-B9lJS9gr.js → agent-presence-CTUYlsSf.js} +1 -1
- package/dist/public/assets/auth-state-cache-ByjLRYDx.js +11 -0
- package/dist/public/assets/{config-provider-eG9dInMX.js → config-provider-CBrCc3Qp.js} +4 -4
- package/dist/public/assets/{dist-CYtyTA7F.js → dist-Cub6hBx7.js} +1 -1
- package/dist/public/assets/{dist-DXyZc_kW.js → dist-GfBYAWEU.js} +116 -115
- package/dist/public/assets/doc-hash-BMXWNo_I.js +1 -0
- package/dist/public/assets/{documents-events-U_LCCcuP.js → documents-events-DJ1GG23v.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-CBvYR3nC.js → file-tree-adapter-DDhSPjxf.js} +1 -1
- package/dist/public/assets/index-D2oet0wG.js +2007 -0
- package/dist/public/assets/index-Zwl7lo8a.css +1 -0
- package/dist/public/assets/lint-config-client-BGM5HIsf.js +1 -0
- package/dist/public/assets/{navigation-targets-dSa8_04l.js → navigation-targets-CW61_XIz.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-BfLYfa7d.js → open-managed-artifact-tab-BGW4m9f4.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-Dnkk-mHa.js → pending-receive-nav-store-9viWJ9VV.js} +1 -1
- package/dist/public/assets/{prop-types-DyrPDiUq.js → prop-types-BvMtVAeG.js} +1 -1
- package/dist/public/assets/{receive-store-iiSp9ERl.js → receive-store-B3-FInQ9.js} +1 -1
- package/dist/public/assets/{selection-context-DEOXYfsZ.js → selection-context-C_A_tH6W.js} +1 -1
- package/dist/public/assets/skill-actions-6AAhO9zY.js +1 -0
- package/dist/public/assets/{skills-api-C5hIkm-I.js → skills-api-BhEjmNIn.js} +1 -1
- package/dist/public/assets/{src-CO_mDEk3.js → src-G334Yrxd.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-DUenOsCZ.js → target-navigation-intent-oLHFF9_D.js} +1 -1
- package/dist/public/assets/typing-burst-detector-CwIqbcfm.js +6 -0
- package/dist/public/assets/{use-apply-config-color-theme-fna_wp8B.js → use-apply-config-color-theme-JH4tQfHA.js} +1 -1
- package/dist/public/assets/{workspace-paths-S9yd7u2Z.js → workspace-paths-DtvYoBMA.js} +1 -1
- package/dist/public/index.html +27 -27
- package/dist/{repair-launch-json-5HmcdZdE.mjs → repair-launch-json-CxNjlqij.mjs} +2 -2
- package/dist/{repair-mcp-configs-CWZ4TNZL.mjs → repair-mcp-configs-Dtnsor_m.mjs} +2 -2
- package/dist/repair-skills-Drky8zkq.mjs +1 -0
- package/dist/{repair-skills-CFabpG6D.mjs → repair-skills-tJI8shk3.mjs} +2 -2
- package/dist/{src-ddPUyd9u.mjs → src-BI8S8yWC.mjs} +301 -301
- package/dist/{src-CsJd4hD1.mjs → src-Z2z9ztGi.mjs} +1 -1
- package/dist/{src-DhhmCwL9.mjs → src-nG3ysTNI.mjs} +2 -2
- package/dist/{start-Dspbwbj4.mjs → start-DLha1qnz.mjs} +2 -2
- package/dist/start-vpVar-h6.mjs +1 -0
- package/dist/{write-project-skill-D59YsAqA.mjs → write-project-skill-Bg3yDMEj.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-B9Y7OjyE.mjs +0 -2
- package/dist/init-CmQ4m4iP.mjs +0 -638
- package/dist/init-DmP2JIBO.mjs +0 -1
- package/dist/loader-C1m6gRpq.mjs +0 -1
- package/dist/preview-Ttf6bU0t.mjs +0 -1
- package/dist/public/assets/CodeMirrorPropInput-CgDBcDCj.js +0 -3
- package/dist/public/assets/PropertyPanel-CptmpM73.js +0 -2
- package/dist/public/assets/auth-state-cache-DwZqt_xI.js +0 -11
- package/dist/public/assets/doc-hash-BALtx6hR.js +0 -1
- package/dist/public/assets/index-B8pIQBJH.js +0 -2006
- package/dist/public/assets/index-F5i20SPk.css +0 -1
- package/dist/public/assets/lint-config-client-DbxK9eCK.js +0 -1
- package/dist/public/assets/skill-actions-CBCRhQ-8.js +0 -1
- package/dist/public/assets/typing-burst-detector-t2o529xJ.js +0 -6
- package/dist/repair-skills-BuztBrD_.mjs +0 -1
- package/dist/start-DmiJEfsU.mjs +0 -1
package/dist/init-CmQ4m4iP.mjs
DELETED
|
@@ -1,638 +0,0 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{E as r,Ho as i,k as a,ra as o}from"./src-CFHcsBtV.mjs";import{$n as s,$t as c,Bn as l,Ia as u,Mr as d,Qn as f,Qt as p,Vn as m,c as h,da as g,dn as _,er as v,fa as y,fn as b,jn as x,l as S,nr as C,rn as w,tn as ee,u as te,wn as ne}from"./src-ddPUyd9u.mjs";import{r as re,t as ie}from"./esm-EvSEzE_V.mjs";import{t as ae}from"./constants-B9Y7OjyE.mjs";import{t as T}from"./is-object-DYBErO9v.mjs";import{a as oe,b as se,d as E,g as ce,h as le,i as ue,m as de,p as fe,s as pe,t as me}from"./write-project-skill-D59YsAqA.mjs";import{i as D,n as he,o as O,r as ge,s as k,t as A}from"./colors-CpVsnmzb.mjs";import{t as _e}from"./preview-CR6Q94oC.mjs";import{createRequire as ve}from"node:module";import{execFileSync as ye}from"node:child_process";import be,{dirname as j,isAbsolute as M,join as N,relative as P,resolve as F,sep as xe}from"node:path";import{existsSync as I,lstatSync as Se,mkdirSync as Ce,readFileSync as L,readlinkSync as we,realpathSync as Te,statSync as Ee,writeFileSync as De}from"node:fs";import{homedir as Oe}from"node:os";import R from"node:process";import{fileURLToPath as ke}from"node:url";import{inspect as Ae,stripVTControlCharacters as je,styleText as z}from"node:util";import{AsyncLocalStorage as Me,AsyncResource as Ne}from"node:async_hooks";import*as Pe from"node:readline";const Fe=new Set([`emacs`,`vim`]);function Ie(e){return Fe.has(e)}function Le(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Ie))):[]}const B=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Re=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,ze=e=>e.name===`space`,Be=e=>e.name===`backspace`,Ve=e=>`1234567890`.includes(e.name),He=e=>e.name===`enter`||e.name===`return`;var Ue=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},We=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Ge=class extends Error{name=`ExitPromptError`},Ke=class extends Error{name=`HookError`},qe=class extends Error{name=`ValidationError`};const Je=new Me;function Ye(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Xe(e,t){let n=Ye(e);return Je.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function V(){let e=Je.getStore();if(!e)throw new Ke(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function Ze(){return V().rl}function Qe(e){return Ne.bind((...t)=>{let n=V(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function $e(e){let t=V(),{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 et(){V().handleChange()}const H={queue(e){let t=V(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(Ze());if(r!=null&&typeof r!=`function`)throw new qe(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=V();Qe(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=V();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function tt(e){return typeof e==`function`}function U(e){return $e(t=>{let n=Ne.bind(function(e){t.get()!==e&&(t.set(e),et())});if(t.initialized)return[t.get(),n];let r=tt(e)?e():e;return t.set(r),[r,n]})}function nt(e,t){$e(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&H.queue(e),n.set(t)})}function rt(){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 it={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},at={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},ot={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},st={...it,...at},ct={...it,...ot},W=rt()?st:ct;Object.entries(at);const lt={prefix:{idle:z(`blue`,`?`),done:z(`green`,W.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>z(`yellow`,e))},keybindings:[],style:{answer:e=>z(`cyan`,e),message:e=>z(`bold`,e),error:e=>z(`red`,`> ${e}`),defaultAnswer:e=>z(`dim`,`(${e})`),help:e=>z(`dim`,e),highlight:e=>z(`cyan`,e),key:e=>z(`cyan`,z(`bold`,`<${e}>`))}};function ut(){return{...lt,keybindings:Le()}}function dt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ft(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=dt(n)&&dt(r)?ft(n,r):r}return t}function pt(...e){return ft(ut(),...e.filter(e=>e!=null))}function mt({status:e=`idle`,theme:t}){let[n,r]=U(!1),[i,a]=U(0),{prefix:o,spinner:s}=pt(t);return nt(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function ht(e,t){return $e(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function gt(e){return U({current:e})[0]}function _t(e){let t=gt(e);t.current=e,nt(e=>{let n=!1,r=Qe((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var vt=t(n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}))(),1);const yt=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),bt=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,xt=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,St=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ct=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,wt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Tt=/\t{1,1000}/y,Et=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Dt=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Ot=/\p{M}+/gu,kt={limit:1/0,ellipsis:``},At=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?At(i,kt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Dt,l],[St,0],[Ct,o],[Tt,s],[Et,c],[wt,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Ot,``)){let t=e.codePointAt(0)||0;if(S=bt(t)?2:xt(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===wt?yt(e.slice(p,n.lastIndex)):n===Et?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},jt={limit:1/0,ellipsis:``,ellipsisWidth:0},G=(e,t={})=>At(e,jt,t).width,Mt=`]8;;`,Nt=RegExp(`(?:\\[(?<code>\\d+)m|\\${Mt}(?<uri>.*))`,`y`),Pt=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Ft=e=>`[${e}m`,It=e=>`${Mt}${e}`,Lt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:G(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=G(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(Mt,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Rt=e=>{let t=e.split(` `),n=t.length;for(;n&&!G(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},zt=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=G(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=G(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Lt(s,r,t),c=G(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Lt(s,r,t),c=G(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Lt(s,r,t),c=G(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Rt(e)));let l=s.join(`
|
|
2
|
-
`),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===``){Nt.lastIndex=e+1;let t=Nt.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
|
|
3
|
-
`){a&&(r+=It(``));let e=i?Pt(i):void 0;i&&e&&(r+=Ft(e))}else t===`
|
|
4
|
-
`&&(i&&Pt(i)&&(r+=Ft(i)),a&&(r+=It(a)))}return r},Bt=/\r?\n/;function Vt(e,t,n){return String(e).normalize().split(Bt).map(e=>zt(e,t,n)).join(`
|
|
5
|
-
`)}function Ht(e,t){return e.split(`
|
|
6
|
-
`).flatMap(e=>Vt(e,t,{trim:!1,wordWrap:!1}).split(`
|
|
7
|
-
`).map(e=>e.trimEnd())).join(`
|
|
8
|
-
`)}function Ut(){return(0,vt.default)({defaultWidth:80,output:Ze().output})}function Wt({active:e,renderedItems:t,pageSize:n,loop:r}){let i=gt({lastPointer:e,lastActive:void 0}),{lastPointer:a,lastActive:o}=i.current,s=Math.floor(n/2),c=t.reduce((e,t)=>e+t.length,0),l=t.slice(0,e).reduce((e,t)=>e+t.length,0),u=l;if(c>n)if(r)u=a,o!=null&&o<e&&e-o<n&&(u=Math.min(s,Math.abs(e-o)===1?Math.min(a+(t[o]?.length??0),Math.max(l,a)):a+e-o));else{let r=t.slice(e).reduce((e,t)=>e+t.length,0);u=r<n-s?n-r:Math.min(l,s)}return i.current.lastPointer=u,i.current.lastActive=e,u}function Gt({items:e,active:t,renderItem:n,pageSize:r,loop:i=!0}){let a=Ut(),o=t=>(t%e.length+e.length)%e.length,s=e.map((e,r)=>e==null?[]:Ht(n({item:e,index:r,isActive:r===t}),a).split(`
|
|
9
|
-
`)),c=s.reduce((e,t)=>e+t.length,0),l=e=>s[e]??[],u=Wt({active:t,renderedItems:s,pageSize:r,loop:i}),d=l(t).slice(0,r),f=u+d.length<=r?u:r-d.length,p=Array.from({length:r});p.splice(f,d.length,...d);let m=new Set([t]),h=f+d.length,g=o(t+1);for(;h<r&&!m.has(g)&&(i&&c>r?g!==t:g>t);){let e=l(g).slice(0,r-h);p.splice(h,e.length,...e),m.add(g),h+=e.length,g=o(g+1)}for(h=f-1,g=o(t-1);h>=0&&!m.has(g)&&(i&&c>r?g!==t:g<t);){let e=l(g),t=e.slice(Math.max(0,e.length-h-1));p.splice(h-t.length+1,t.length,...t),m.add(g),h-=t.length,g=o(g-1)}return p.filter(e=>typeof e==`string`).join(`
|
|
10
|
-
`)}var Kt=t(n(((t,n)=>{let r=e(`stream`);n.exports=class extends r{#e=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on(`pipe`,this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,t){return this._dest?this._dest[e]:this._src?this._src[e]:t}#n(e,...t){typeof this._dest?.[e]==`function`&&this._dest[e](...t),typeof this._src?.[e]==`function`&&this._src[e](...t)}get isTTY(){return this.#e===null?this.#t(`isTTY`,!1):this.#e}set isTTY(e){this.#e=e}get rows(){return this.#t(`rows`)}get columns(){return this.#t(`columns`)}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return e.indexOf(this._prompt)===0&&(e=e.slice(this._prompt.length),e=e.replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit(`data`,e);this._prompt&&this._hadControl&&e.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit(`data`,this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit(`data`,e)}end(e){this.muted&&(e=e&&this.replace?e.toString().replace(/./g,this.replace):null),e&&this.emit(`data`,e),this.emit(`end`)}destroy(...e){return this.#n(`destroy`,...e)}destroySoon(...e){return this.#n(`destroySoon`,...e)}close(...e){return this.#n(`close`,...e)}}}))(),1);const K=[];K.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&K.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&K.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const qt=e=>!!e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`,Jt=Symbol.for(`signal-exit emitter`),Yt=globalThis,Xt=Object.defineProperty.bind(Object);var Zt=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Yt[Jt])return Yt[Jt];Xt(Yt,Jt,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let n=this.listeners[e],r=n.indexOf(t);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let i of this.listeners[e])r=i(t,n)===!0||r;return e===`exit`&&(r=this.emit(`afterExit`,t,n)||r),r}},Qt=class{};const $t=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var en=class extends Qt{onExit(){return()=>{}}load(){}unload(){}},tn=class extends Qt{#e=nn.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new Zt;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of K)this.#a[t]=()=>{let n=this.#n.listeners(t),{count:r}=this.#t,i=e;if(typeof i.__signal_exit_emitter__==`object`&&typeof i.__signal_exit_emitter__.count==`number`&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();let n=this.#t.emit(`exit`,null,t),r=t===`SIGHUP`?this.#e:t;n||e.kill(e.pid,r)}};this.#i=e.reallyExit,this.#r=e.emit}onExit(e,t){if(!qt(this.#n))return()=>{};this.#o===!1&&this.load();let n=t?.alwaysLast?`afterExit`:`exit`;return this.#t.on(n,e),()=>{this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(let e of K)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,K.forEach(e=>{let t=this.#a[e];if(!t)throw Error(`Listener not defined for signal: `+e);try{this.#n.removeListener(e,t)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#i,--this.#t.count)}#s(e){return qt(this.#n)?(this.#n.exitCode=e||0,this.#t.emit(`exit`,this.#n.exitCode,null),this.#i.call(this.#n,this.#n.exitCode)):0}#c(e,...t){let n=this.#r;if(e===`exit`&&qt(this.#n)){typeof t[0]==`number`&&(this.#n.exitCode=t[0]);let r=n.call(this.#n,e,...t);return this.#t.emit(`exit`,this.#n.exitCode,null),r}else return n.call(this.#n,e,...t)}};const nn=globalThis.process,{onExit:rn,load:an,unload:on}=$t(qt(nn)?new tn(nn):new en),sn=`\x1B[?25l`,cn=(e=1)=>e>0?`[${e}A`:``,ln=(e=1)=>e>0?`[${e}B`:``,un=(e,t)=>typeof t==`number`&&!Number.isNaN(t)?`[${t+1};${e+1}H`:`[${e+1}G`,dn=`\x1B[2K`,fn=e=>e>0?(dn+cn(1)).repeat(e-1)+dn+`\x1B[G`:``,pn=e=>e.split(`
|
|
11
|
-
`).length,mn=e=>e.split(`
|
|
12
|
-
`).pop()??``;var hn=class{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=``){let n=je(mn(e)),r=n;this.rl.line.length>0&&(r=r.slice(0,-this.rl.line.length)),this.rl.setPrompt(r),this.cursorPos=this.rl.getCursorPos();let i=Ut();e=Ht(e,i),t=Ht(t,i),n.length%i===0&&(e+=`
|
|
13
|
-
`);let a=e+(t?`
|
|
14
|
-
`+t:``),o=Math.floor(n.length/i)-this.cursorPos.rows+(t?pn(t):0);o>0&&(a+=cn(o)),a+=un(this.cursorPos.cols),this.write(ln(this.extraLinesUnderPrompt)+fn(this.height)+a),this.extraLinesUnderPrompt=o,this.height=pn(a)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(un(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt(``);let t=ln(this.extraLinesUnderPrompt);t+=e?fn(this.height):`
|
|
15
|
-
`,t+=`\x1B[G`,t+=`\x1B[?25h`,this.write(t),this.rl.close()}},gn=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}};const _n=globalThis.setImmediate;function vn(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(e,n)=>{let r=n.slice(1);return t=r,r},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function yn(e){let t=vn();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,s=new Kt.default;s.pipe(r.output??process.stdout);let c=Pe.createInterface({terminal:!0,input:i,output:s});s.mute();let l=new hn(c),{promise:u,resolve:d,reject:f}=gn.withResolver(),p=()=>f(new We);if(a){let e=()=>f(new Ue({cause:a.reason}));if(a.aborted)return e(),Object.assign(u,{cancel:p});a.addEventListener(`abort`,e),o.add(()=>a.removeEventListener(`abort`,e))}o.add(rn((e,t)=>{f(new Ge(`User force closed the prompt with ${e} ${t}`))}));let m=()=>f(new Ge(`User force closed the prompt with SIGINT`));return c.on(`SIGINT`,m),o.add(()=>c.removeListener(`SIGINT`,m)),Xe(c,a=>{let m=Ne.bind(()=>H.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=be.resolve(e)),Error(`Prompt functions must return a string.\n at ${e}`)}let[o,s]=typeof a==`string`?[a]:a;l.render(o,s),H.run()}catch(e){f(e)}if(r=!0,i!==null){let{value:e}=i;i=null,d(e)}})};return`readableFlowing`in i?_n(h):h(),Object.assign(u.then(e=>(H.clearAll(),e),e=>{throw H.clearAll(),e}).finally(()=>{o.forEach(e=>e()),l.done({clearContent:!!r.clearPromptOnDone}),s.end()}).then(()=>u),{cancel:p})})}}var q=class{separator=z(`dim`,Array.from({length:15}).join(W.line));type=`separator`;constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`separator`)}},bn=i();function xn(e){let t=[`.ok/`,`.okignore`];for(let n of pe){let r=E[n];r.projectConfigPath&&t.push(Nn(r.projectConfigPath(e),e))}t.push(`.claude/launch.json`);let n=N(e,...r);if(I(n))try{let e=a(L(n,`utf-8`));if(e){for(let[n,r]of Object.entries(e.skills))if(n!==`open-knowledge`)for(let e of r.hosts){let r=o[e];r&&t.push(`${r}/${n}/`)}}}catch{}return Array.from(new Set(t))}function Sn(e,t){let n=En(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:Dn(n)};let r=On(e);if(r.kind!==`ok`)return r.result;let i=I(r.path)?L(r.path,`utf-8`):``,a=Mn(i),o=[],s=[];for(let e of t)jn(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{De(r.path,`${i}${c}${l}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:o,alreadyPresent:s,removed:[]}}function Cn(e,t){let n=On(e);if(n.kind!==`ok`)return n.result;if(!I(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>An(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);let a;try{a=L(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 An(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{De(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function wn(e){let t=On(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!I(t.path))return`shared`;let n;try{n=L(t.path,`utf-8`)}catch{return`shared`}let r=Mn(n),i=xn(e);for(let e of i)if(jn(r,e))return`local-only`;return`shared`}function Tn(e){let t=On(e);if(t.kind!==`ok`||!I(t.path))return[];let n;try{n=L(t.path,`utf-8`)}catch{return[]}let r=Mn(n);return xn(e).filter(e=>jn(r,e))}function En(e,t){let n=[];for(let r of t)if(I(F(e,r)))try{ye(`git`,[`ls-files`,`--error-unmatch`,`--`,r],d({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}return{tracked:n}}function Dn(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 On(e){let t=u(e);switch(t.kind){case`directory`:case`linked`:{let e=N(kn(t.path),`info`);return I(e)?{kind:`ok`,path:N(e,`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 kn(e){let t=N(e,`commondir`);if(!I(t))return e;let n;try{n=L(t,`utf-8`).trim()}catch{return e}return n.length===0?e:M(n)?n:F(e,n)}function An(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function jn(e,t){for(let n of An(t))if(e.has(n))return!0;return!1}function Mn(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 Nn(e,t){return Pn(P(t,e))}function Pn(e){return xe===`/`?e:e.split(xe).join(`/`)}function Fn(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 In(e){let t=(e.match(/\r\n/g)??[]).length;return t===0?!1:t>=(e.match(/\n/g)??[]).length-t}function J(e){try{return Ee(e).mode&511}catch{return}}function Ln(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
|
|
24
|
-
`)?`\r
|
|
25
|
-
`:`
|
|
26
|
-
`,a=v(r,t,void 0,{formattingOptions:{...Fn(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${f(r,a)}`;return{text:o,changed:o!==e}}const Rn={icon:{checked:z(`green`,W.circleFilled),unchecked:W.circle,cursor:W.pointer,disabledChecked:z(`green`,W.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>z(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>z(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${z(`bold`,e)} ${z(`dim`,t)}`).join(z(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`}};function zn(e){return!q.isSeparator(e)&&!e.disabled}function Bn(e){return!q.isSeparator(e)}function Vn(e){return!q.isSeparator(e)&&e.checked}function Hn(e){return zn(e)?{...e,checked:!e.checked}:e}function Un(e){return function(t){return zn(t)?{...t,checked:e}:t}}function Wn(e){return e.map(e=>{if(q.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 Gn=yn((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=pt(Rn,e.theme),{keybindings:c}=s,[l,u]=U(`idle`),d=mt({status:l,theme:s}),[f,p]=U(Wn(e.choices)),m=ht(()=>{let e=f.findIndex(Bn),t=f.findLastIndex(Bn);if(e===-1)throw new qe(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=U(m.first),[_,v]=U();_t(async e=>{if(He(e)){let e=f.filter(Vn),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(B(e,c)||Re(e,c)){if(_&&v(void 0),r||B(e,c)&&h!==m.first||Re(e,c)&&h!==m.last){let t=B(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Bn(f[n]));g(n)}}else if(ze(e)){let e=f[h];e&&!q.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?Hn(e):e))))}else if(e.name===o.all){let e=f.some(e=>zn(e)&&!e.checked);p(f.map(Un(e)))}else if(e.name===o.invert)p(f.map(Hn));else if(Ve(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>q.isSeparator(e)?!1:(n++,n===t)),i=f[r];i&&zn(i)&&(g(r),p(f.map((e,t)=>t===r?Hn(e):e)))}});let y=s.style.message(e.message,l),b,x=Gt({items:f,active:h,renderItem({item:e,isActive:t}){if(q.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(Vn);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()}${sn}`});const Kn={icon:{cursor:W.pointer},style:{disabled:e=>z(`dim`,e),description:e=>z(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${z(`bold`,e)} ${z(`dim`,t)}`).join(z(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be selected.`},indexMode:`hidden`};function qn(e){return!q.isSeparator(e)&&!e.disabled}function Jn(e){return!q.isSeparator(e)}function Yn(e){return e.map(e=>{if(q.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 Xn=yn((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=pt(Kn,e.theme),{keybindings:a}=i,[o,s]=U(`idle`),c=mt({status:o,theme:i}),l=gt(),u=!a.includes(`vim`),d=ht(()=>Yn(e.choices),[e.choices]),f=ht(()=>{let e=d.findIndex(Jn),t=d.findLastIndex(Jn);if(e===-1)throw new qe(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=ht(()=>`default`in e?d.findIndex(t=>qn(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=U(p===-1?f.first:p),g=d[m];if(g==null||q.isSeparator(g))throw Error(`Active index does not point to a choice`);let[_,v]=U();_t((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),He(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(B(e,a)||Re(e,a)){if(r.clearLine(0),n||B(e,a)&&m!==f.first||Re(e,a)&&m!==f.last){let t=B(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!Jn(d[n]));h(n)}}else if(Ve(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>q.isSeparator(n)?!1:(t++,t===e)),i=d[n];i!=null&&qn(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(Be(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>q.isSeparator(t)||!qn(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),nt(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Gt({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(q.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()}${sn}`});
|
|
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 Zn=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var Qn=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(Zn);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 $n(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function er(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 Y=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=$n(t.toml,t.ptr),i=er(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 tr=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,nr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,rr=/^[+-]?0[0-9_]/;function ir(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 Y(`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 Y(`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 Y(`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 Y(`unrecognized escape sequence`,{toml:e,ptr:l});s=l+1,c=0}else if(n!==` `&&n!==` `){if(c===2)throw new Y(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:s});c=+(!i&&n===`\\`),s=l}throw new Y(`unfinished string`,{toml:e,ptr:t})}function ar(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=tr.test(e);if(i||nr.test(e)){if(rr.test(e))throw new Y(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new Y(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new Y(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new Qn(e);if(!a.isValid())throw new Y(`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 or(e,t=0,n=e.length){let r=e.indexOf(`
|
|
148
|
-
`,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function sr(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 Y(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function X(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=sr(e,t)}return t}function cr(e,t,n,r,i=!1){if(!r)return t=or(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=or(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 Y(`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 lr(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(sr(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function ur(e,t,n,r,i){if(r===0)throw new Y(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?mr(e,t,r,i):pr(e,t,r,i);if(n){if(s=X(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new Y(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}if(a===`"`||a===`'`){let[r,i]=ir(e,t);if(n){if(i=X(e,i),e[i]&&e[i]!==`,`&&e[i]!==n&&e[i]!==`
|
|
183
|
-
`&&e[i]!==`\r`)throw new Y(`unexpected character encountered`,{toml:e,ptr:i});e[i]===`,`&&i++}return[r,i]}let o=cr(e,t,`,`,n),s=lr(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new Y(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=X(e,t+s[1]),e[o]===`,`&&o++),[ar(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 dr=/^[a-zA-Z0-9-_]+[ \t]*$/;function fr(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new Y(`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 Y(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let[s,c]=ir(e,t);r=e.indexOf(`.`,c);let l=e.slice(c,r<0||r>a?a:r),u=or(l);if(u>-1)throw new Y(`newlines are not allowed in keys`,{toml:e,ptr:t+r+u});if(l.trimStart())throw new Y(`found extra tokens after the string part`,{toml:e,ptr:c});if(a<c&&(a=e.indexOf(n,c),a<0))throw new Y(`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(!dr.test(n))throw new Y(`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,X(e,a+1,!0,!0)]}function pr(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new Y(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=sr(e,t);else if(o!==` `&&o!==` `&&o!==`
|
|
212
|
-
`&&o!==`\r`){let o,s=i,c=!1,[l,u]=fr(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 Y(`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 Y(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=ur(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new Y(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function mr(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new Y(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=sr(e,t);else if(a!==` `&&a!==` `&&a!==`
|
|
213
|
-
`&&a!==`\r`){let a=ur(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new Y(`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 hr(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 gr(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=X(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=fr(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new Y(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=hr(n[0],r,i,t?2:1);if(!c)throw new Y(`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=fr(e,s),i=hr(r[0],a,o,0);if(!i)throw new Y(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=ur(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=X(e,s,!0),e[s]&&e[s]!==`
|
|
242
|
-
`&&e[s]!==`\r`)throw new Y(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=X(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 _r=/^[a-z0-9-_]+$/i;function Z(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function vr(e){for(let t=0;t<e.length;t++)if(Z(e[t])!==`object`)return!1;return e.length!=0}function yr(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function br(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 yr(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return xr(e,n,r);if(t===`array`)return Sr(e,n,r)}function xr(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+=_r.test(o)?o:yr(o),i+=` = `,i+=br(e[o],Z(e[o]),t-1,n)}return i+` }`}function Sr(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+=br(e[i],Z(e[i]),t-1,n)}return r+` ]`}function Cr(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+=wr(0,e[a],t,n,r);return i}function wr(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=Z(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=_r.test(c)?c:yr(c);if(e===`array`&&vr(t[c]))o+=(o&&`
|
|
272
|
-
`)+Cr(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
|
|
273
|
-
`)+wr(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=br(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 Tr(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Z(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=wr(0,e,``,t,n);return r[r.length-1]===`
|
|
275
|
-
`?r:r+`
|
|
276
|
-
`}const Er=`${fe}-dev`;function Dr(e){return e.startsWith(fe)}function Or(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`&&Dr(n)}function kr(e){return{command:le,args:[e]}}function Ar(e={}){let t=e.mode===`dev`?Er:de,n={unix:ce({...e,platformName:`darwin`}),win32:ce({...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 jr(e,t){let n=P(t,e);return n.length>0&&!n.startsWith(`..`)&&!M(n)}const Mr=e=>{try{let t=ye(`git`,[`rev-parse`,`--show-toplevel`],d({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function Nr(e,t={}){let n=t.homeDir??Oe(),r=t.gitTopLevel??Mr,i=F(e),a;try{a=Te(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(w(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=j(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&jr(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 Pr(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 Fr=[`native`,`index.js`];function Ir(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??ve(t);try{return n(N(j(ke(t)),...Fr))}catch(e){Pr(e)||Q(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return Pr(e)||Q(`workspace addon failed to load`,e),null}}function Lr(){let e=Ir();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function Rr(e){let t=e,n=new Set;for(;;){let r;try{r=Se(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=we(t)}catch(t){return Q(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=M(i)?i:N(j(t),i)}}let zr;function Br(){return zr===void 0&&(zr=Lr()),zr}function Vr(e,t=Br){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 Rr(e)}function Hr(){let e=Ir();return e&&typeof e.parseTomlToJson==`function`?e:null}function Ur(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return Q(`addon loaded but probe failed`,e),!1}}function Wr(e){if(!T(e))throw Error(`TOML root is not a table`);return e}function Gr(e){return{backend:`native`,parseToObject(t){return Wr(JSON.parse(e.parseTomlToJson(t)))},upsertEntry(t,n,r){let i=e.upsertMcpServer(t,n,JSON.stringify(r));return{text:i.text,existed:i.existed}},removeEntry(t,n){let r=e.removeMcpServer(t,n);return{text:r.text,existed:r.existed}}}}function Kr(){return{backend:`fallback`,parseToObject(e){return Wr(gr(e))}}}function qr(e=Hr){let t=e();return t&&Ur(t)?Gr(t):Kr()}let Jr=null;function Yr(){return Jr===null&&(Jr=qr()),Jr}const Xr={allowTrailingComma:!0,disallowComments:!1};function Zr(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function Qr(e){let t=[],n=C(e,t,Xr);return t.some(t=>!Zr(t,e))||!n||n.type!==`object`?null:n}function $r(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&s(e)===t&&(n+=1)}return n}function ei(e,t){y(e,`${JSON.stringify(t,null,2)}\n`)}function ti(e,t){let n=Tr(t);y(e,n.endsWith(`
|
|
620
|
-
`)?n:`${n}\n`)}function ni(e,t){let n=(0,bn.stringify)(t);y(e,n.endsWith(`
|
|
621
|
-
`)?n:`${n}\n`)}const ri=10*1024*1024;function ii(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)=>ii(e,t[n]));if(T(e)&&T(t)){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>Object.hasOwn(t,n)&&ii(e[n],t[n])):!1}return!1}function ai(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 oi(e,t,n){return t===void 0?[e,n]:[e,t,n]}function si(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function ci(e,t,n){let r=e[t];return n===void 0?r:T(r)?r[n]:void 0}function li(e,t,n,r,i){if(!I(e))return ei(e,si(t,i,n,r)),{kind:`written`};let a;try{a=L(e,`utf-8`)}catch(e){return Q(`json config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(a.trim()===``)return ei(e,si(t,i,n,r)),{kind:`written`};if(Buffer.byteLength(a,`utf-8`)>ri)return{kind:`declined`,reason:`oversize`};let o=Qr(a);if(!o)return{kind:`declined`,reason:`unparseable`};if($r(o,t)>1)return{kind:`declined`,reason:`duplicate-container`};let c=ci(s(o),t,i),l=T(c)?c[n]:void 0,u=l!==void 0;if(u&&ii(l,r))return{kind:`overwritten`};let d=a.charCodeAt(0)===65279,p=d?a.slice(1):a,m=p.includes(`\r
|
|
623
|
-
`)?`\r
|
|
624
|
-
`:`
|
|
625
|
-
`,h=v(p,oi(t,i,n),r,{formattingOptions:{...ai(p),eol:m}}),g=`${d?``:``}${f(p,h)}`;return g!==a&&y(e,g,{mode:J(e)}),{kind:u?`overwritten`:`written`}}function ui(e,t,n,r,i){let a=``;if(I(t))try{a=L(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?(ti(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=In(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&&y(t,p,{mode:J(t)}),{kind:d.existed?`overwritten`:`written`}}function di(e,t,n,r){let i=``;if(I(e))try{i=L(e,`utf-8`)}catch(e){return Q(`yaml config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(i.trim()===``)return ni(e,{[t]:{[n]:r}}),{kind:`written`};if(Buffer.byteLength(i,`utf-8`)>ri)return{kind:`declined`,reason:`oversize`};let a=i.charCodeAt(0)===65279,o=a?i.slice(1):i,s=(0,bn.parseDocument)(o);if(s.errors.length>0)return{kind:`declined`,reason:`unparseable`};let c=[t,n],l=s.hasIn(c);s.hasIn([t])&&!(0,bn.isCollection)(s.getIn([t],!0))&&s.deleteIn([t]),s.setIn(c,s.createNode(r));let u=s.toString(),d=In(o);o.endsWith(`
|
|
630
|
-
`)?u.endsWith(`
|
|
631
|
-
`)||(u=`${u}\n`):u=u.replace(/\n+$/,``),d&&(u=u.replace(/\r\n/g,`
|
|
632
|
-
`).replace(/\n/g,`\r
|
|
633
|
-
`));let f=`${a?``:``}${u}`;return f!==i&&y(e,f,{mode:J(e)}),{kind:l?`overwritten`:`written`}}const fi=e=>e!==`project`,pi=e=>e!==`user`;async function mi(){let e=await Gn({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 hi(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??mi)():`both`}async function gi(e){return Xn({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 _i(e){if(e.sharing!==void 0)return e.sharing;let t=wn(e.projectRoot)===`local-only`?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??gi)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function vi(e){if(e===void 0||e===!0)return new Set(m);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(m.filter(e=>t.includes(e)))}function yi(e,t,n){let r=F(n,e),i;try{i=Ee(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=P(bi(t),bi(r));if(a.startsWith(`..`)||M(a))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return a===``?`.`:a}function bi(e){try{return Te(e)}catch{return e}}const xi=`open-knowledge-ui`;function Si(e,t,n){try{return I(e.detectPath?.(t,n)??j(e.configPath(t,n)))}catch{return!1}}function Ci(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&&!Si(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{me(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 Ti(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{Ce(j(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{g(`${o}.lock`,()=>{let t=Vr(o).writePath;if(Ce(j(t),{recursive:!0}),e.format===`toml`){let n=ui(Yr(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=di(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=li(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 wi={pi:Ar};function Ti(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=wi[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{Ce(j(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{g(`${t}.lock`,()=>{let e=null;try{e=L(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}y(t,c,e===null?void 0:{mode:J(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 Ei(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!I(n)))return{editorId:e.id,label:e.label,path:n}}async function Di(e){let t=se(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>Ci(t,``,n,e.home))}function Oi(e,t,n,r){let i=Ai(e,t,n,r);return i.kind===`present`?i.entry:null}function ki(e,t,n,r){let i=ci(e,t,r);if(!T(i))return{kind:`no-entry`};let a=i[n];return T(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Ai(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!I(i))return{kind:`absent`};try{if(Ee(i).size>ri)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=L(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:kr(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Yr().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return ki(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,bn.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:ki(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let c=Qr(a);return c?$r(c,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:ki(s(c),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function ji(e={}){let t=F(e.cwd??process.cwd()),n=Nr(t,{homeDir:e.home}),r=n.projectRoot,i=!I(N(r,`.ok`)),a=n.gitRootPromoted?P(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:yi(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${k(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},u=await te(r),d;try{d=c(r,{contentDir:o})}catch(t){let i=E.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:u.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 f=d.created.includes(ae),g=!1;if(u.didInit)try{g=ee(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{p(r)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore entry at ${r}: ${e instanceof Error?e.message:String(e)}`)}let _=await h(r);_.kind===`untracked`&&console.warn(`[ok] Untracked the OpenKnowledge project skill (${_.dirs.join(`, `)}) — it is now local-only. Teammates will see this as a deletion on their next pull.`);let v=await hi({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),y=e.editors??Li(r,e.home),b=e.editors??pe.filter(e=>E[e].projectConfigPath!==void 0||E[e].projectSkillPath!==void 0),S=se(y),C=se(b),w=e.mcp===!1||v===null,re=Array.from(new Map([...S,...w?[]:C].map(e=>[e.id,e])).values()),ie=S.filter(t=>Si(t,r,e.home)),T=[],ce=[],le=new Set;for(let t of re){if(w){let n=``;try{n=t.configPath(r,e.home)}catch{}T.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(fi(v)&&S.includes(t)&&t.scope===`global`&&T.push(Ci(t,r,s,e.home)),pi(v)&&C.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Ci(t,r,s,e.home,n);T.push(i),(i.action===`written`||i.action===`overwritten`)&&le.add(n)}}let de=new Set;for(let t of C){let n=t.projectSkillPath?.(r);!n||de.has(n)||(de.add(n),ce.push(ue(t,r,{home:e.home})))}let fe=!w&&v!==null&&pi(v)?C.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,me=w?[]:ie.map(e=>Ei(e,r)).filter(e=>e!==void 0).filter(e=>!le.has(e.path)),D=e.installUserSkill??ne,he=e.home??Oe(),O=vi(e.skills),ge=!1,A=!1,_e=!1,ve=!1;for(let t of m){let n=O.has(t);if(await x(he,l[t],n).catch(()=>{}),n){ge=!0;let n=await D({home:e.home,bundleId:t,force:!0});n===`installed`?A=!0:n===`failed`?_e=!0:ve=!0}else try{oe(he,t)}catch{}}let ye=_e?`failed`:A?`installed`:ge&&ve?`skip-current`:`declined`,be=w?`skipped-flag`:`skipped-missing`,j=T.find(e=>e.editorId===`claude`)??T[0]??{action:be,configPath:E.claude.configPath(r,e.home)},M=await Mi({projectRoot:r,desiredMode:await _i({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:d.created,contentUpdated:d.updated,contentSkipped:d.skipped,editors:T,projectSkills:ce,legacyProjectConfigs:me,skillInstall:ye,didGitInit:u.didInit,rootGitignoreCreated:g,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:f?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:j.action,mcpPath:j.configPath,mcpError:`error`in j?j.error:void 0,projectScopeUnsupportedLabels:fe,sharing:M}}async function Mi(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=wn(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=xn(t);if(n===`local-only`){let e=Sn(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`}:Ni(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Cn(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Ni(t,o,`remove`)}function Ni(e,t,n){let r=wn(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 Pi(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 Fi(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let s=N(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(A(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(A(`Content already present at ${s}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(A(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(A(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(A(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?P(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`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} ${O(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${O(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${ge(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Pi(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(A(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?P(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${ge(`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} ${P(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(A(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${O(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${O(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${he(`skipped (opted out via --no-skills)`)}`);break;case`failed`:n.push(` ${k(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${k(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(k(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(k(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(_e(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...Bi(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${D(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${D(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${D(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${D(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${D(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${D(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
|
|
635
|
-
`)}function Ii(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 Li(e,t){let n=[];for(let r of pe)Si(E[r],e,t)&&n.push(r);return n}function Ri(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Ae(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function zi(){return new ie(`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 re(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new re(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new re(`--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?Ri():null;try{let r;try{r=await ji({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 _||e instanceof b){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof S){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-C1m6gRpq.mjs`),{resolveContentDir:s}=await import(`./src-CsJd4hD1.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-Ttf6bU0t.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(Ii(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Fi(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Bi(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
|
|
637
|
-
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${D(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(k(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${D(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${D(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(k(`Sharing mode unavailable: ${e.reason}.`));return n}}export{xn as A,He as B,Gn as C,Sn as D,Ln as E,sn as F,_t as I,mt as L,wn as M,Cn as N,Dn as O,yn as P,pt as R,Or as S,In as T,oi as _,Ii as a,Yr as b,Fi as c,Oi as d,vi as f,ji as g,_i as h,Mi as i,En as j,Tn as k,Bi as l,yi as m,xi as n,Ai as o,hi as p,wi as r,Li as s,$ as t,zi as u,Ci as v,J as w,Nr as x,Di as y,U as z};
|
|
638
|
-
//# sourceMappingURL=init-CmQ4m4iP.mjs.map
|