@inkeep/open-knowledge 0.67.0-beta.2 → 0.67.0
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/{acp-harness-probe-CQY5xnxl.mjs → acp-harness-probe-CnAEsOyg.mjs} +2 -2
- package/dist/cli.mjs +29 -29
- package/dist/constants-Cizrn7IS.mjs +2 -0
- package/dist/index.mjs +26 -26
- package/dist/{init-BnAKA1pC.mjs → init-CBfbbyZt.mjs} +12 -12
- package/dist/init-DID56zG4.mjs +1 -0
- package/dist/{launch-json-removal-BcBDWCAT.mjs → launch-json-removal-Ds6to5PD.mjs} +2 -2
- package/dist/{loader-DWla98le.mjs → loader-BBetk1pa.mjs} +2 -2
- package/dist/loader-DZ7BYCCO.mjs +1 -0
- package/dist/{open-browser-B5VbCpAQ.mjs → open-browser-zyR1fJMP.mjs} +2 -2
- package/dist/{preview-CfABQUF8.mjs → preview-Bc6KqZjp.mjs} +2 -2
- package/dist/preview-kgUumBQN.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-DpHKV3Fo.js → ActivityModeContent-LZXobglw.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-DCG8p8wj.js → AddPropertiesButton-C_oEF-k6.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-CyCKmqFc.js → AgentDiffPane-rwXOyXfA.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-u4XFoleT.js → CodeMirrorPropInput-Cg5Vd3nt.js} +1 -1
- package/dist/public/assets/{DocumentContext-Dnh6K82B.js → DocumentContext-CMYNrz-_.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-DeXquZw1.js → EditorModeToggle-DX78JcBR.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-BQhuZB86.js → EnableSyncConfirmDialog-CrT56rTk.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-B5oJcC6a.js → ExcalidrawDocEditor-DA40b8B-.js} +1 -1
- package/dist/public/assets/FeedbackForm-pTBV_Sai.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-DrVFzW8E.js → ImportSkillDialog-BsGvRMLu.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-DWVqaaqf.js → LintConfigEditor-3TmQmk5q.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-DfK-lOLp.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-PAJxXrcG.js → ManagedArtifactProperties-Dk0ISqgs.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-Cp9hfV1H.js → MermaidDocEditor-CNBiD7BP.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-DAgkBnyy.js → PropertyDisplayRow-CcPBwh6r.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-D2FZCIZ7.js → SchemaConfigEditor-Bp9Z2cMc.js} +1 -1
- package/dist/public/assets/{SessionsHost-CLKxzr4u.js → SessionsHost-Dgg43wAS.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-aojU_6yY.js → SettingsDialogBody-TzbcWBGf.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-Bni3yXgl.js → ShareReceiveMissDialog-1s-ohJqA.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-BHR-9UNP.js → SkillInstallMenu-C9UMFcD3.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-iK4e4bEe.js → SkillToolbarControls-DaWIfh6l.js} +1 -1
- package/dist/public/assets/{SourceEditor-CRs3D5y2.js → SourceEditor-BxwgAoZn.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-CzZqjo-p.js → TerminalWindowApp-CLntLiBg.js} +1 -1
- package/dist/public/assets/{TextDocEditor-CdjxMtrt.js → TextDocEditor-DQNW37-H.js} +1 -1
- package/dist/public/assets/{ThreadView-C6uVuEhA.js → ThreadView-id1IVufe.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-DFbxsUjY.js → TimelineDiffPane-BVYNGbjv.js} +1 -1
- package/dist/public/assets/{agent-diff-store-CI9-nZ0i.js → agent-diff-store-BnFkUQtB.js} +1 -1
- package/dist/public/assets/{auth-state-cache-B_mn7bAt.js → auth-state-cache-CSFL7s9x.js} +1 -1
- package/dist/public/assets/{client-version-CEClhR52.js → client-version-DqyRNVDY.js} +1 -1
- package/dist/public/assets/{comment-chips-yb9PnjC0.js → comment-chips-Dj0DZmYi.js} +1 -1
- package/dist/public/assets/{config-provider-BKNG21ZO.js → config-provider-Flf2Xj2j.js} +1 -1
- package/dist/public/assets/{index-C7cNeh3S.js → index-DdYtMWnx.js} +7 -7
- package/dist/public/assets/{pending-receive-nav-store-Dw2-EiMe.js → pending-receive-nav-store-nAr29ZoF.js} +1 -1
- package/dist/public/assets/{progress-vSWRgJqM.js → progress-BVlIPHs6.js} +1 -1
- package/dist/public/assets/{selection-context-BPiksgZ3.js → selection-context-DyWxJNcr.js} +1 -1
- package/dist/public/assets/{src-Mka2WkyS.js → src-BLASU-Ua.js} +1 -1
- package/dist/public/assets/{telemetry-impl-ClRJ18fy.js → telemetry-impl-C-lVM95D.js} +1 -1
- package/dist/public/assets/{telemetry-startup-B_4IqvTc.js → telemetry-startup-Pp18qmqI.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-dsiADuQh.js → typing-burst-detector-BU0mlOLf.js} +1 -1
- package/dist/public/assets/{use-activity-panel-CQXXnWdh.js → use-activity-panel-CucXmSmA.js} +1 -1
- package/dist/public/assets/{use-open-skill-Cl-CoKvQ.js → use-open-skill-F34G6MU_.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-DJjeF-1r.js → use-terminal-enabled-CeycTmer.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-j3PBCTgr.js → use-timeline-entry-diff-Dq2wYxOI.js} +1 -1
- package/dist/public/index.html +19 -19
- package/dist/{repair-launch-json-DxcVTMbs.mjs → repair-launch-json-BWJ0jKGP.mjs} +2 -2
- package/dist/{repair-mcp-configs-DZQWWQln.mjs → repair-mcp-configs-CqU-BJ_C.mjs} +2 -2
- package/dist/repair-skills-B1grg5zx.mjs +1 -0
- package/dist/{repair-skills-k83Ipv-J.mjs → repair-skills-Cw8bOvSl.mjs} +2 -2
- package/dist/{resolve-project-root-DCYPHzur.mjs → resolve-project-root-GAALlgK0.mjs} +3 -3
- package/dist/{skill-teardown-CUW2_c9Q.mjs → skill-teardown-BOK6k1kP.mjs} +2 -2
- package/dist/src-B2uhXnAX.mjs +2045 -0
- package/dist/src-BNwNQSm-.mjs +1 -0
- package/dist/src-BQ4HXNsS.mjs +1 -0
- package/dist/{src-CA9zRmPt.mjs → src-CVxEsgpN.mjs} +2 -2
- package/dist/start-B7lWVYBX.mjs +1 -0
- package/dist/{start-DuCVBkW-.mjs → start-CdBFw8_n.mjs} +3 -3
- package/package.json +4 -4
- package/dist/constants-CzBR8OPk.mjs +0 -2
- package/dist/init-BR7HCaX9.mjs +0 -1
- package/dist/loader-Dd9ywqT3.mjs +0 -1
- package/dist/preview-DDpTCIRk.mjs +0 -1
- package/dist/public/assets/FeedbackForm-2-zq8vF8.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-DGS7RCxV.js +0 -1
- package/dist/repair-skills-C7esPWUj.mjs +0 -1
- package/dist/src-CNuuM8T0.mjs +0 -2045
- package/dist/src-CkQqw1Wp.mjs +0 -1
- package/dist/src-DraT8WdY.mjs +0 -1
- package/dist/start-Cp7U3NfU.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{yt as r}from"./sleep-BZCw-NJO.mjs";import{Hs as i,cc as a,ot as o,rt as s,ys as c}from"./src-CS_k7GF4.mjs";import{Ar as l,Bi as u,La as d,Mi as f,Mr as p,Ni as m,Or as h,_n as g,bi as _,bn as v,d as y,er as b,f as x,fr as S,gn as ee,kr as C,mn as te,p as ne,pn as re,rr as ie,tr as ae,ur as oe,xi as se,yi as ce}from"./src-CNuuM8T0.mjs";import{I as w,P as le}from"./fs-traced-C5AXyho0.mjs";import{C as ue,a as T,d as de,f as fe,i as pe,l as me,n as he,o as ge,s as _e,t as ve,u as ye,x as be,y as xe}from"./resolve-project-root-DCYPHzur.mjs";import{i as E,n as D,o as O,r as Se,s as k,t as A}from"./colors-DSyAT9Cz.mjs";import{t as Ce}from"./constants-CzBR8OPk.mjs";import{t as j}from"./is-object-Bw0-z8qH.mjs";import{t as we}from"./preview-CfABQUF8.mjs";import{createRequire as Te}from"node:module";import{execFileSync as Ee}from"node:child_process";import De,{dirname as M,isAbsolute as Oe,join as N,relative as P,resolve as F,sep as ke}from"node:path";import I from"node:process";import{fileURLToPath as Ae}from"node:url";import{existsSync as L,lstatSync as je,mkdirSync as Me,readFileSync as R,readlinkSync as Ne,realpathSync as Pe,statSync as Fe,writeFileSync as Ie}from"node:fs";import{homedir as Le}from"node:os";import*as Re from"node:readline";import{inspect as ze,stripVTControlCharacters as Be,styleText as z}from"node:util";import{AsyncLocalStorage as Ve,AsyncResource as He}from"node:async_hooks";const Ue=new Set([`emacs`,`vim`]);function We(e){return Ue.has(e)}function Ge(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(We))):[]}const B=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Ke=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,qe=e=>e.name===`space`,Je=e=>e.name===`backspace`,Ye=e=>`1234567890`.includes(e.name),Xe=e=>e.name===`enter`||e.name===`return`;var Ze=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Qe=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},$e=class extends Error{name=`ExitPromptError`},et=class extends Error{name=`HookError`},tt=class extends Error{name=`ValidationError`};const nt=new Ve;function rt(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function it(e,t){let n=rt(e);return nt.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function V(){let e=nt.getStore();if(!e)throw new et(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function at(){return V().rl}function ot(e){return He.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 st(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 ct(){V().handleChange()}const H={queue(e){let t=V(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(at());if(r!=null&&typeof r!=`function`)throw new tt(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=V();ot(()=>{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 lt(e){return typeof e==`function`}function U(e){return st(t=>{let n=He.bind(function(e){t.get()!==e&&(t.set(e),ct())});if(t.initialized)return[t.get(),n];let r=lt(e)?e():e;return t.set(r),[r,n]})}function ut(e,t){st(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&H.queue(e),n.set(t)})}function dt(){return I.platform.startsWith(`win`)?!!I.env.CI||!!I.env.WT_SESSION||!!I.env.TERMINUS_SUBLIME||I.env.ConEmuTask===`{cmd::Cmder}`||I.env.TERM_PROGRAM===`Terminus-Sublime`||I.env.TERM_PROGRAM===`vscode`||I.env.TERM===`xterm-256color`||I.env.TERM===`alacritty`||I.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:I.env.TERM!==`linux`}const ft={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:`╱`},pt={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:`⅒`},mt={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`},ht={...ft,...pt},gt={...ft,...mt},W=dt()?ht:gt;Object.entries(pt);const _t={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 vt(){return{..._t,keybindings:Ge()}}function yt(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 bt(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=yt(n)&&yt(r)?bt(n,r):r}return t}function xt(...e){return bt(vt(),...e.filter(e=>e!=null))}function St({status:e=`idle`,theme:t}){let[n,r]=U(!1),[i,a]=U(0),{prefix:o,spinner:s}=xt(t);return ut(()=>{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 Ct(e,t){return st(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 wt(e){return U({current:e})[0]}function Tt(e){let t=wt(e);t.current=e,ut(e=>{let n=!1,r=ot((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var Et=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 Dt=(()=>{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}})(),Ot=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,kt=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,At=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,jt=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Mt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Nt=/\t{1,1000}/y,Pt=/[\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,Ft=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,It=/\p{M}+/gu,Lt={limit:1/0,ellipsis:``},Rt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Rt(i,Lt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Ft,l],[At,0],[jt,o],[Nt,s],[Pt,c],[Mt,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(It,``)){let t=e.codePointAt(0)||0;if(S=Ot(t)?2:kt(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===Mt?Dt(e.slice(p,n.lastIndex)):n===Pt?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}},zt={limit:1/0,ellipsis:``,ellipsisWidth:0},G=(e,t={})=>Rt(e,zt,t).width,Bt=`]8;;`,Vt=RegExp(`(?:\\[(?<code>\\d+)m|\\${Bt}(?<uri>.*))`,`y`),Ht=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},Ut=e=>`[${e}m`,Wt=e=>`${Bt}${e}`,Gt=(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(Bt,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())},Kt=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(``)},qt=(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(``),Gt(s,r,t),c=G(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Gt(s,r,t),c=G(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Gt(s,r,t),c=G(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Kt(e)));let l=s.join(`
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{yt as r}from"./sleep-BZCw-NJO.mjs";import{Hs as i,cc as a,ot as o,rt as s,ys as c}from"./src-CS_k7GF4.mjs";import{Bi as l,Cn as u,En as d,Fr as f,Ir as p,La as m,Mi as h,Ni as g,Pr as _,Rr as v,Sn as y,bi as b,bn as x,d as S,f as C,gr as ee,lr as te,or as ne,p as re,sr as ie,vr as ae,xi as oe,yi as se,yn as ce}from"./src-B2uhXnAX.mjs";import{I as w,P as le}from"./fs-traced-C5AXyho0.mjs";import{C as ue,a as T,d as de,f as fe,i as pe,l as me,n as he,o as ge,s as _e,t as ve,u as ye,x as be,y as xe}from"./resolve-project-root-GAALlgK0.mjs";import{i as E,n as D,o as O,r as Se,s as k,t as A}from"./colors-DSyAT9Cz.mjs";import{t as Ce}from"./constants-Cizrn7IS.mjs";import{t as j}from"./is-object-Bw0-z8qH.mjs";import{t as we}from"./preview-Bc6KqZjp.mjs";import{createRequire as Te}from"node:module";import{execFileSync as Ee}from"node:child_process";import De,{dirname as M,isAbsolute as Oe,join as N,relative as P,resolve as F,sep as ke}from"node:path";import I from"node:process";import{fileURLToPath as Ae}from"node:url";import{existsSync as L,lstatSync as je,mkdirSync as Me,readFileSync as R,readlinkSync as Ne,realpathSync as Pe,statSync as Fe,writeFileSync as Ie}from"node:fs";import{homedir as Le}from"node:os";import*as Re from"node:readline";import{inspect as ze,stripVTControlCharacters as Be,styleText as z}from"node:util";import{AsyncLocalStorage as Ve,AsyncResource as He}from"node:async_hooks";const Ue=new Set([`emacs`,`vim`]);function We(e){return Ue.has(e)}function Ge(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(We))):[]}const B=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Ke=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,qe=e=>e.name===`space`,Je=e=>e.name===`backspace`,Ye=e=>`1234567890`.includes(e.name),Xe=e=>e.name===`enter`||e.name===`return`;var Ze=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Qe=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},$e=class extends Error{name=`ExitPromptError`},et=class extends Error{name=`HookError`},tt=class extends Error{name=`ValidationError`};const nt=new Ve;function rt(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function it(e,t){let n=rt(e);return nt.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function V(){let e=nt.getStore();if(!e)throw new et(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function at(){return V().rl}function ot(e){return He.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 st(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 ct(){V().handleChange()}const H={queue(e){let t=V(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(at());if(r!=null&&typeof r!=`function`)throw new tt(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=V();ot(()=>{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 lt(e){return typeof e==`function`}function U(e){return st(t=>{let n=He.bind(function(e){t.get()!==e&&(t.set(e),ct())});if(t.initialized)return[t.get(),n];let r=lt(e)?e():e;return t.set(r),[r,n]})}function ut(e,t){st(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&H.queue(e),n.set(t)})}function dt(){return I.platform.startsWith(`win`)?!!I.env.CI||!!I.env.WT_SESSION||!!I.env.TERMINUS_SUBLIME||I.env.ConEmuTask===`{cmd::Cmder}`||I.env.TERM_PROGRAM===`Terminus-Sublime`||I.env.TERM_PROGRAM===`vscode`||I.env.TERM===`xterm-256color`||I.env.TERM===`alacritty`||I.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:I.env.TERM!==`linux`}const ft={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:`╱`},pt={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:`⅒`},mt={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`},ht={...ft,...pt},gt={...ft,...mt},W=dt()?ht:gt;Object.entries(pt);const _t={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 vt(){return{..._t,keybindings:Ge()}}function yt(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 bt(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=yt(n)&&yt(r)?bt(n,r):r}return t}function xt(...e){return bt(vt(),...e.filter(e=>e!=null))}function St({status:e=`idle`,theme:t}){let[n,r]=U(!1),[i,a]=U(0),{prefix:o,spinner:s}=xt(t);return ut(()=>{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 Ct(e,t){return st(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 wt(e){return U({current:e})[0]}function Tt(e){let t=wt(e);t.current=e,ut(e=>{let n=!1,r=ot((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var Et=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 Dt=(()=>{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}})(),Ot=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,kt=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,At=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,jt=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Mt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Nt=/\t{1,1000}/y,Pt=/[\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,Ft=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,It=/\p{M}+/gu,Lt={limit:1/0,ellipsis:``},Rt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Rt(i,Lt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Ft,l],[At,0],[jt,o],[Nt,s],[Pt,c],[Mt,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(It,``)){let t=e.codePointAt(0)||0;if(S=Ot(t)?2:kt(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===Mt?Dt(e.slice(p,n.lastIndex)):n===Pt?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}},zt={limit:1/0,ellipsis:``,ellipsisWidth:0},G=(e,t={})=>Rt(e,zt,t).width,Bt=`]8;;`,Vt=RegExp(`(?:\\[(?<code>\\d+)m|\\${Bt}(?<uri>.*))`,`y`),Ht=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},Ut=e=>`[${e}m`,Wt=e=>`${Bt}${e}`,Gt=(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(Bt,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())},Kt=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(``)},qt=(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(``),Gt(s,r,t),c=G(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Gt(s,r,t),c=G(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Gt(s,r,t),c=G(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Kt(e)));let l=s.join(`
|
|
2
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===``){Vt.lastIndex=e+1;let t=Vt.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
3
|
`){a&&(r+=Wt(``));let e=i?Ht(i):void 0;i&&e&&(r+=Ut(e))}else t===`
|
|
4
4
|
`&&(i&&Ht(i)&&(r+=Ut(i)),a&&(r+=Wt(a)))}return r},Jt=/\r?\n/;function Yt(e,t,n){return String(e).normalize().split(Jt).map(e=>qt(e,t,n)).join(`
|
|
@@ -19,14 +19,14 @@ import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{yt as r}from"./sle
|
|
|
19
19
|
`,f=l.length===0?``:`${l.join(`
|
|
20
20
|
`)}\n`;try{Ie(r.path,`${s}${d}${f}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:l,alreadyPresent:u,removed:o}}function Nn(e,t){let n=Rn(e);if(n.kind!==`ok`)return n.result;if(!L(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>zn(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(On),i.add(kn);for(let t of jn(e))i.add(t);let a;try{a=R(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let o=a.split(`
|
|
21
21
|
`),s=new Set,c=[];for(let e of o){let t=e.trim();if(i.has(t)){s.add(t);continue}c.push(e)}let l=[...s];if(s.size===0)return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let u=c.join(`
|
|
22
|
-
`);if(u!==a)try{Ie(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function Pn(e){let t=Rn(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!L(t.path))return`shared`;let n;try{n=R(t.path,`utf-8`)}catch{return`shared`}let r=Vn(n),i=An(e);for(let e of i)if(Bn(r,e))return`local-only`;return r.has(On)?`local-only`:`shared`}function Fn(e){let t=Rn(e);if(t.kind!==`ok`||!L(t.path))return[];let n;try{n=R(t.path,`utf-8`)}catch{return[]}let r=Vn(n),a=[...An(e),...jn(e)].filter(e=>Bn(r,e)),o=new Set(a),s=[];for(let e of Object.values(i))e!==null&&s.push(e);let c=[];for(let e of r){if(o.has(e))continue;if(e===On||e===kn){c.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);s.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&c.push(e)}return[...a,...c]}function In(e,t){let n=[];for(let r of t)if(L(F(e,r)))try{Ee(`git`,[`ls-files`,`--error-unmatch`,`--`,r],
|
|
23
|
-
`)}function Rn(e){let t=
|
|
22
|
+
`);if(u!==a)try{Ie(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function Pn(e){let t=Rn(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!L(t.path))return`shared`;let n;try{n=R(t.path,`utf-8`)}catch{return`shared`}let r=Vn(n),i=An(e);for(let e of i)if(Bn(r,e))return`local-only`;return r.has(On)?`local-only`:`shared`}function Fn(e){let t=Rn(e);if(t.kind!==`ok`||!L(t.path))return[];let n;try{n=R(t.path,`utf-8`)}catch{return[]}let r=Vn(n),a=[...An(e),...jn(e)].filter(e=>Bn(r,e)),o=new Set(a),s=[];for(let e of Object.values(i))e!==null&&s.push(e);let c=[];for(let e of r){if(o.has(e))continue;if(e===On||e===kn){c.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);s.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&c.push(e)}return[...a,...c]}function In(e,t){let n=[];for(let r of t)if(L(F(e,r)))try{Ee(`git`,[`ls-files`,`--error-unmatch`,`--`,r],l({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}return{tracked:n}}function Ln(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(`
|
|
23
|
+
`)}function Rn(e){let t=m(e);switch(t.kind){case`repository`:{let e=t.repository.readCommonDir();if(e.kind===`unreadable`)return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}};let n=N(e.path,`info`);return L(n)?{kind:`ok`,path:N(n,`exclude`)}:{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-info-dir`}}}case`absent`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-git`}};case`malformed-pointer`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`malformed-pointer`}};case`inaccessible`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}}}}function zn(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function Bn(e,t){for(let n of zn(t))if(e.has(n))return!0;return!1}function Vn(e){let t=new Set;for(let n of e.split(`
|
|
24
24
|
`)){let e=n.trim();e.length!==0&&t.add(e)}return t}function Hn(e,t){return Un(P(t,e))}function Un(e){return ke===`/`?e:e.split(ke).join(`/`)}function Wn(e){for(let t of e.split(`
|
|
25
25
|
`)){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 Gn(e){let t=(e.match(/\r\n/g)??[]).length;return t===0?!1:t>=(e.match(/\n/g)??[]).length-t}function Y(e){try{return Fe(e).mode&511}catch{return}}function Kn(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
|
|
26
26
|
`)?`\r
|
|
27
27
|
`:`
|
|
28
|
-
`,a=
|
|
29
|
-
`).trimEnd()}${hn}`});const tr={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 nr(e){return!q.isSeparator(e)&&!e.disabled}function rr(e){return!q.isSeparator(e)}function ir(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 ar=Dn((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=xt(tr,e.theme),{keybindings:a}=i,[o,s]=U(`idle`),c=St({status:o,theme:i}),l=wt(),u=!a.includes(`vim`),d=Ct(()=>ir(e.choices),[e.choices]),f=Ct(()=>{let e=d.findIndex(rr),t=d.findLastIndex(rr);if(e===-1)throw new tt(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=Ct(()=>`default`in e?d.findIndex(t=>nr(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();Tt((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Xe(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(B(e,a)||Ke(e,a)){if(r.clearLine(0),n||B(e,a)&&m!==f.first||Ke(e,a)&&m!==f.last){let t=B(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!rr(d[n]));h(n)}}else if(Ye(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&&nr(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(Je(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>q.isSeparator(t)||!nr(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),ut(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=$t({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:
|
|
28
|
+
`,a=p(r,t,void 0,{formattingOptions:{...Wn(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${_(r,a)}`;return{text:o,changed:o!==e}}const qn={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 Jn(e){return!q.isSeparator(e)&&!e.disabled}function Yn(e){return!q.isSeparator(e)}function Xn(e){return!q.isSeparator(e)&&e.checked}function Zn(e){return Jn(e)?{...e,checked:!e.checked}:e}function Qn(e){return function(t){return Jn(t)?{...t,checked:e}:t}}function $n(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 er=Dn((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=xt(qn,e.theme),{keybindings:c}=s,[l,u]=U(`idle`),d=St({status:l,theme:s}),[f,p]=U($n(e.choices)),m=Ct(()=>{let e=f.findIndex(Yn),t=f.findLastIndex(Yn);if(e===-1)throw new tt(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=U(m.first),[_,v]=U();Tt(async e=>{if(Xe(e)){let e=f.filter(Xn),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)||Ke(e,c)){if(_&&v(void 0),r||B(e,c)&&h!==m.first||Ke(e,c)&&h!==m.last){let t=B(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Yn(f[n]));g(n)}}else if(qe(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?Zn(e):e))))}else if(e.name===o.all){let e=f.some(e=>Jn(e)&&!e.checked);p(f.map(Qn(e)))}else if(e.name===o.invert)p(f.map(Zn));else if(Ye(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>q.isSeparator(e)?!1:(n++,n===t)),i=f[r];i&&Jn(i)&&(g(r),p(f.map((e,t)=>t===r?Zn(e):e)))}});let y=s.style.message(e.message,l),b,x=$t({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(Xn);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(`
|
|
29
|
+
`).trimEnd()}${hn}`});const tr={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 nr(e){return!q.isSeparator(e)&&!e.disabled}function rr(e){return!q.isSeparator(e)}function ir(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 ar=Dn((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=xt(tr,e.theme),{keybindings:a}=i,[o,s]=U(`idle`),c=St({status:o,theme:i}),l=wt(),u=!a.includes(`vim`),d=Ct(()=>ir(e.choices),[e.choices]),f=Ct(()=>{let e=d.findIndex(rr),t=d.findLastIndex(rr);if(e===-1)throw new tt(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=Ct(()=>`default`in e?d.findIndex(t=>nr(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();Tt((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Xe(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(B(e,a)||Ke(e,a)){if(r.clearLine(0),n||B(e,a)&&m!==f.first||Ke(e,a)&&m!==f.last){let t=B(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!rr(d[n]));h(n)}}else if(Ye(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&&nr(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(Je(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>q.isSeparator(t)||!nr(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),ut(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=$t({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(`
|
|
30
30
|
`).trimEnd()}${hn}`});
|
|
31
31
|
/*!
|
|
32
32
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -618,13 +618,13 @@ export default function okBridge(pi: {
|
|
|
618
618
|
}
|
|
619
619
|
});
|
|
620
620
|
}
|
|
621
|
-
`}function Vr(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 Hr=[`native`,`index.js`];function Ur(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??Te(t);try{return n(N(M(Ae(t)),...Hr))}catch(e){Vr(e)||Q(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return Vr(e)||Q(`workspace addon failed to load`,e),null}}function Wr(){let e=Ur();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function Gr(e){let t=e,n=new Set;for(;;){let r;try{r=je(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=Ne(t)}catch(t){return Q(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=Oe(i)?i:N(M(t),i)}}let Kr;function qr(){return Kr===void 0&&(Kr=Wr()),Kr}function Jr(e,t=qr){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 Gr(e)}function Yr(){let e=Ur();return e&&typeof e.parseTomlToJson==`function`?e:null}function Xr(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 Zr(e){if(!j(e))throw Error(`TOML root is not a table`);return e}function Qr(e){return{backend:`native`,parseToObject(t){return Zr(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 $r(){return{backend:`fallback`,parseToObject(e){return Zr(Tr(e))}}}function ei(e=Yr){let t=e();return t&&Xr(t)?Qr(t):$r()}let ti=null;function ni(){return ti===null&&(ti=ei()),ti}function ri(){let e=ni();return e.backend===`native`?e:void 0}const ii={allowTrailingComma:!0,disallowComments:!1};function ai(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function oi(e){let t=[],n=
|
|
621
|
+
`}function Vr(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 Hr=[`native`,`index.js`];function Ur(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??Te(t);try{return n(N(M(Ae(t)),...Hr))}catch(e){Vr(e)||Q(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return Vr(e)||Q(`workspace addon failed to load`,e),null}}function Wr(){let e=Ur();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function Gr(e){let t=e,n=new Set;for(;;){let r;try{r=je(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=Ne(t)}catch(t){return Q(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=Oe(i)?i:N(M(t),i)}}let Kr;function qr(){return Kr===void 0&&(Kr=Wr()),Kr}function Jr(e,t=qr){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 Gr(e)}function Yr(){let e=Ur();return e&&typeof e.parseTomlToJson==`function`?e:null}function Xr(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 Zr(e){if(!j(e))throw Error(`TOML root is not a table`);return e}function Qr(e){return{backend:`native`,parseToObject(t){return Zr(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 $r(){return{backend:`fallback`,parseToObject(e){return Zr(Tr(e))}}}function ei(e=Yr){let t=e();return t&&Xr(t)?Qr(t):$r()}let ti=null;function ni(){return ti===null&&(ti=ei()),ti}function ri(){let e=ni();return e.backend===`native`?e:void 0}const ii={allowTrailingComma:!0,disallowComments:!1};function ai(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function oi(e){let t=[],n=v(e,t,ii);return t.some(t=>!ai(t,e))||!n||n.type!==`object`?null:n}function si(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&f(e)===t&&(n+=1)}return n}function ci(e,t){w(e,`${JSON.stringify(t,null,2)}\n`)}function li(e,t){let n=Fr(t);w(e,n.endsWith(`
|
|
622
622
|
`)?n:`${n}\n`)}function ui(e,t){let n=(0,J.stringify)(t);w(e,n.endsWith(`
|
|
623
623
|
`)?n:`${n}\n`)}const di=10*1024*1024;function fi(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)=>fi(e,t[n]));if(j(e)&&j(t)){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>Object.hasOwn(t,n)&&fi(e[n],t[n])):!1}return!1}const pi=[`command`,`args`],mi=[`type`,`command`];function hi(e){return e.type===`local`&&Array.isArray(e.command)?mi:pi}function gi(e,t,n){return j(e)&&n.every(n=>fi(e[n],t[n]))}function _i(e){for(let t of e.split(`
|
|
624
|
-
`)){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 vi(e,t,n){return t===void 0?[e,n]:[e,t,n]}function yi(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function bi(e,t,n){let r=e[t];return n===void 0?r:j(r)?r[n]:void 0}function xi(e,t,n,r,i){if(!L(e))return ci(e,yi(t,i,n,r)),{kind:`written`};let a;try{a=R(e,`utf-8`)}catch(e){return Q(`json config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(a.trim()===``)return ci(e,yi(t,i,n,r)),{kind:`written`};if(Buffer.byteLength(a,`utf-8`)>di)return{kind:`declined`,reason:`oversize`};let o=oi(a);if(!o)return{kind:`declined`,reason:`unparseable`};if(si(o,t)>1)return{kind:`declined`,reason:`duplicate-container`};let s=bi(
|
|
624
|
+
`)){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 vi(e,t,n){return t===void 0?[e,n]:[e,t,n]}function yi(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function bi(e,t,n){let r=e[t];return n===void 0?r:j(r)?r[n]:void 0}function xi(e,t,n,r,i){if(!L(e))return ci(e,yi(t,i,n,r)),{kind:`written`};let a;try{a=R(e,`utf-8`)}catch(e){return Q(`json config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(a.trim()===``)return ci(e,yi(t,i,n,r)),{kind:`written`};if(Buffer.byteLength(a,`utf-8`)>di)return{kind:`declined`,reason:`oversize`};let o=oi(a);if(!o)return{kind:`declined`,reason:`unparseable`};if(si(o,t)>1)return{kind:`declined`,reason:`duplicate-container`};let s=bi(f(o),t,i),c=j(s)?s[n]:void 0,l=c!==void 0,u=hi(r);if(l&&gi(c,r,u))return{kind:`overwritten`};let d=a.charCodeAt(0)===65279,m=d?a.slice(1):a,h=m.includes(`\r
|
|
625
625
|
`)?`\r
|
|
626
626
|
`:`
|
|
627
|
-
`,g={..._i(
|
|
627
|
+
`,g={..._i(m),eol:h},v=vi(t,i,n),y=m;if(l&&j(c))for(let e of u){let t=p(y,[...v,e],r[e],{formattingOptions:g});y=_(y,t)}else{let e=p(y,v,r,{formattingOptions:g});y=_(y,e)}let b=`${d?``:``}${y}`;return b!==a&&w(e,b,{mode:Y(e)}),{kind:l?`overwritten`:`written`}}function Si(e,t,n,r,i){let a=``;if(L(t))try{a=R(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?(li(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=Gn(c),u=o||c.endsWith(`
|
|
628
628
|
`),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(`
|
|
629
629
|
`)||(f=`${f}\n`):f=f.replace(/\n+$/,``),l&&(f=f.replace(/\r\n/g,`
|
|
630
630
|
`).replace(/\n/g,`\r
|
|
@@ -633,8 +633,8 @@ export default function okBridge(pi: {
|
|
|
633
633
|
`)||(d=`${d}\n`):d=d.replace(/\n+$/,``),f&&(d=d.replace(/\r\n/g,`
|
|
634
634
|
`).replace(/\n/g,`\r
|
|
635
635
|
`));let p=`${a?``:``}${d}`;return p!==i&&w(e,p,{mode:Y(e)}),{kind:l?`overwritten`:`written`}}const wi=e=>e!==`project`,Ti=e=>e!==`user`;async function Ei(){let e=await er({message:`Where should the MCP server be configured?
|
|
636
|
-
`,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 Di(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Ei)():`both`}async function Oi(e){return ar({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function ki(e){if(e.sharing!==void 0)return e.sharing;let t=Pn(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Oi)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Ai(e){if(e===void 0||e===!0)return new Set(_);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(se.filter(e=>t.includes(e)))}function ji(e,t,n){let r=F(n,e),i;try{i=Fe(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(Mi(t),Mi(r));if(a.startsWith(`..`)||Oe(a))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return a===``?`.`:a}function Mi(e){try{return Pe(e)}catch{return e}}const Ni=`open-knowledge-ui`;function Pi(e,t,n){try{return L(e.detectPath?.(t,n)??M(e.configPath(t,n)))}catch{return!1}}function Fi(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+ke)}catch{return!1}}function Ii(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||Fi(e,t,r);if(!i&&s&&!Pi(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{he(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return Ri(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{Me(M(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let l={action:`written`},u;try{le(`${o}.lock`,()=>{let t=Jr(o).writePath;if(Me(M(t),{recursive:!0}),e.format===`toml`){let n=Si(ni(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=Ci(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=xi(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 Li={pi:Br};function Ri(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=Li[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{Me(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{le(`${t}.lock`,()=>{let e=null;try{e=R(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}w(t,c,e===null?void 0:{mode:Y(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 zi(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!L(n)))return{editorId:e.id,label:e.label,path:n}}function Bi(e,t,n,r){let i=Hi(e,t,n,r);return i.kind===`present`?i.entry:null}function Vi(e,t,n,r){let i=bi(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Hi(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!L(i))return{kind:`absent`};try{if(Fe(i).size>di)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=R(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:zr(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ni().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Vi(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,J.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Vi(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=oi(a);return s?si(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Vi(C(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ui(e={}){let t=F(e.cwd??process.cwd()),n=ve(t,{homeDir:e.home}),r=n.projectRoot;if(v(r,e.home??Le()))throw new g(r);let i=!L(N(r,`.ok`)),a=n.gitRootPromoted?P(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:ji(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`},l=await ne(r),u;try{u=te(r,{contentDir:o})}catch(t){let i=_e.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let d=u.created.includes(Ce),f=!1;if(l.didInit)try{f=ee(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{re(r)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore entry at ${r}: ${e instanceof Error?e.message:String(e)}`)}let p=await y(r);p.kind===`untracked`&&console.warn(`[ok] Untracked the OpenKnowledge project skill (${p.dirs.join(`, `)}) — it is now local-only. Teammates will see this as a deletion on their next pull.`);let m=await Di({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),h=e.editors??Yi(r,e.home),_=e.editors??h,x=xe(h),C=xe(_),w=e.mcp===!1||m===null,le=Array.from(new Map([...x,...w?[]:C].map(e=>[e.id,e])).values()),ue=x.filter(t=>Pi(t,r,e.home)),T=[],de=[],fe=new Set;for(let t of le){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(wi(m)&&x.includes(t)&&t.scope===`global`&&T.push(Ii(t,r,s,e.home)),Ti(m)&&C.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Ii(t,r,s,e.home,n);T.push(i),(i.action===`written`||i.action===`overwritten`)&&fe.add(n)}}let me=new Set;for(let t of C){let n=t.projectSkillPath?.(r);!n||me.has(n)||(me.add(n),de.push(pe(t,r,{home:e.home})))}let he=de.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(he.length>0){let t=e.home??Le();ie({source:c,skills:[ce.project],agents:he,scope:r},{home:t,enabled:S(t).enabled})}let ge=!w&&m!==null&&Ti(m)?C.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ye=w?[]:ue.map(e=>zi(e,r)).filter(e=>e!==void 0).filter(e=>!fe.has(e.path)),be=e.installUserSkill??ae,E=e.home??Le(),D=Ai(e.skills),O=!1,Se=!1,A=!1,j=!1,we=!1;for(let t of se){if(!D.has(t))continue;await oe(E,ce[t],!0).catch(()=>{}),O=!0;let n=await be({home:e.home,bundleId:t,force:!0});n===`installed`?Se=!0:n===`failed`?A=!0:n===`no-hosts`?we=!0:j=!0}let Te=A?`failed`:Se?`installed`:O&&j?`skip-current`:O&&we?`no-hosts`:`declined`,Ee=Se?b(E).map(e=>e.editorId):[],De=w?`skipped-flag`:`skipped-missing`,M=T.find(e=>e.editorId===`claude`)??T[0]??{action:De,configPath:_e.claude.configPath(r,e.home)},Oe=await Wi({projectRoot:r,desiredMode:await ki({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:T,projectSkills:de,legacyProjectConfigs:ye,skillInstall:Te,skillHosts:Ee,didGitInit:l.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:M.action,mcpPath:M.configPath,mcpError:`error`in M?M.error:void 0,projectScopeUnsupportedLabels:ge,sharing:Oe}}async function Wi(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=Pn(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=An(t);if(n===`local-only`){let e=Mn(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`}:Gi(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Nn(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Gi(t,o,`remove`)}function Gi(e,t,n){let r=Pn(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function Ki(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 qi(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} ${Se(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Ki(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} ${Se(`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`:{let t=(e.skillHosts??[]).map(e=>ge[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${O(`installed for ${r}`)}`),n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${O(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${D(`skipped for this run (--no-skills)`)}`),n.push(` ${D(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${k(` ok repair-skills`)}`);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(we(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...Qi(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${E(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${E(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${E(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
|
|
637
|
-
`)}function Ji(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 Yi(e,t){let n=[];for(let r of T)Pi(_e[r],e,t)&&n.push(r);return n}function Xi(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:ze(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Zi(){return new be(`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 ue(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new ue(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new ue(`--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?Xi():null;try{let r;try{r=await Ui({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof $||e instanceof
|
|
638
|
-
`),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-
|
|
636
|
+
`,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 Di(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Ei)():`both`}async function Oi(e){return ar({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function ki(e){if(e.sharing!==void 0)return e.sharing;let t=Pn(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Oi)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Ai(e){if(e===void 0||e===!0)return new Set(b);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(oe.filter(e=>t.includes(e)))}function ji(e,t,n){let r=F(n,e),i;try{i=Fe(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(Mi(t),Mi(r));if(a.startsWith(`..`)||Oe(a))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return a===``?`.`:a}function Mi(e){try{return Pe(e)}catch{return e}}const Ni=`open-knowledge-ui`;function Pi(e,t,n){try{return L(e.detectPath?.(t,n)??M(e.configPath(t,n)))}catch{return!1}}function Fi(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+ke)}catch{return!1}}function Ii(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||Fi(e,t,r);if(!i&&s&&!Pi(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{he(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return Ri(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{Me(M(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let l={action:`written`},u;try{le(`${o}.lock`,()=>{let t=Jr(o).writePath;if(Me(M(t),{recursive:!0}),e.format===`toml`){let n=Si(ni(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=Ci(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=xi(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 Li={pi:Br};function Ri(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=Li[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{Me(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{le(`${t}.lock`,()=>{let e=null;try{e=R(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}w(t,c,e===null?void 0:{mode:Y(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 zi(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!L(n)))return{editorId:e.id,label:e.label,path:n}}function Bi(e,t,n,r){let i=Hi(e,t,n,r);return i.kind===`present`?i.entry:null}function Vi(e,t,n,r){let i=bi(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Hi(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!L(i))return{kind:`absent`};try{if(Fe(i).size>di)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=R(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:zr(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ni().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Vi(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,J.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Vi(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=oi(a);return s?si(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Vi(f(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ui(e={}){let t=F(e.cwd??process.cwd()),n=ve(t,{homeDir:e.home}),r=n.projectRoot;if(d(r,e.home??Le()))throw new u(r);let i=!L(N(r,`.ok`)),a=n.gitRootPromoted?P(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:ji(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`},l=await re(r),f;try{f=x(r,{contentDir:o})}catch(t){let i=_e.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let p=f.created.includes(Ce),m=!1;if(l.didInit)try{m=y(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{ce(r)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore entry at ${r}: ${e instanceof Error?e.message:String(e)}`)}let h=await S(r);h.kind===`untracked`&&console.warn(`[ok] Untracked the OpenKnowledge project skill (${h.dirs.join(`, `)}) — it is now local-only. Teammates will see this as a deletion on their next pull.`);let g=await Di({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),_=e.editors??Yi(r,e.home),v=e.editors??_,b=xe(_),C=xe(v),w=e.mcp===!1||g===null,le=Array.from(new Map([...b,...w?[]:C].map(e=>[e.id,e])).values()),ue=b.filter(t=>Pi(t,r,e.home)),T=[],de=[],fe=new Set;for(let t of le){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(wi(g)&&b.includes(t)&&t.scope===`global`&&T.push(Ii(t,r,s,e.home)),Ti(g)&&C.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Ii(t,r,s,e.home,n);T.push(i),(i.action===`written`||i.action===`overwritten`)&&fe.add(n)}}let me=new Set;for(let t of C){let n=t.projectSkillPath?.(r);!n||me.has(n)||(me.add(n),de.push(pe(t,r,{home:e.home})))}let he=de.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(he.length>0){let t=e.home??Le();te({source:c,skills:[se.project],agents:he,scope:r},{home:t,enabled:ae(t).enabled})}let ge=!w&&g!==null&&Ti(g)?C.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ye=w?[]:ue.map(e=>zi(e,r)).filter(e=>e!==void 0).filter(e=>!fe.has(e.path)),be=e.installUserSkill??ie,E=e.home??Le(),D=Ai(e.skills),O=!1,Se=!1,A=!1,j=!1,we=!1;for(let t of oe){if(!D.has(t))continue;await ee(E,se[t],!0).catch(()=>{}),O=!0;let n=await be({home:e.home,bundleId:t,force:!0});n===`installed`?Se=!0:n===`failed`?A=!0:n===`no-hosts`?we=!0:j=!0}let Te=A?`failed`:Se?`installed`:O&&j?`skip-current`:O&&we?`no-hosts`:`declined`,Ee=Se?ne(E).map(e=>e.editorId):[],De=w?`skipped-flag`:`skipped-missing`,M=T.find(e=>e.editorId===`claude`)??T[0]??{action:De,configPath:_e.claude.configPath(r,e.home)},Oe=await Wi({projectRoot:r,desiredMode:await ki({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:f.created,contentUpdated:f.updated,contentSkipped:f.skipped,editors:T,projectSkills:de,legacyProjectConfigs:ye,skillInstall:Te,skillHosts:Ee,didGitInit:l.didInit,rootGitignoreCreated:m,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:p?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:M.action,mcpPath:M.configPath,mcpError:`error`in M?M.error:void 0,projectScopeUnsupportedLabels:ge,sharing:Oe}}async function Wi(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=Pn(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=An(t);if(n===`local-only`){let e=Mn(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`}:Gi(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Nn(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Gi(t,o,`remove`)}function Gi(e,t,n){let r=Pn(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function Ki(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 qi(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} ${Se(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Ki(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} ${Se(`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`:{let t=(e.skillHosts??[]).map(e=>ge[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${O(`installed for ${r}`)}`),n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${O(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${D(`skipped for this run (--no-skills)`)}`),n.push(` ${D(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${k(` ok repair-skills`)}`);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(we(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...Qi(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${E(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${E(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${E(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
|
|
637
|
+
`)}function Ji(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 Yi(e,t){let n=[];for(let r of T)Pi(_e[r],e,t)&&n.push(r);return n}function Xi(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:ze(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Zi(){return new be(`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 ue(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new ue(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new ue(`--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?Xi():null;try{let r;try{r=await Ui({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof $||e instanceof u){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof h||e instanceof g){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof C){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.
|
|
638
|
+
`),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-DZ7BYCCO.mjs`),{resolveContentDir:s}=await import(`./src-BQ4HXNsS.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-kgUumBQN.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(Ji(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${qi(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Qi(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
|
|
639
639
|
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${E(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(k(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${E(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${E(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(k(`Sharing mode unavailable: ${e.reason}.`));return n}}export{Fn as A,xt as B,ar as C,Kn as D,Gn as E,Nn as F,Xe as H,Dn as I,hn as L,An as M,In as N,Mn as O,Pn as P,Tt as R,Rr as S,Y as T,U as V,vi as _,Ji as a,ni as b,qi as c,Bi as d,Ai as f,Ui as g,ki as h,Wi as i,jn as j,Ln as k,Qi as l,ji as m,Ni as n,Hi as o,Di as p,Li as r,Yi as s,$ as t,Zi as u,Ii as v,er as w,Br as x,ri as y,St as z};
|
|
640
|
-
//# sourceMappingURL=init-
|
|
640
|
+
//# sourceMappingURL=init-CBfbbyZt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./src-B2uhXnAX.mjs";import{g as e}from"./init-CBfbbyZt.mjs";export{e as runInit};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=launch-json-removal-
|
|
1
|
+
import{Fr as e,Rr as t}from"./src-B2uhXnAX.mjs";import{I as n}from"./fs-traced-C5AXyho0.mjs";import{D as r,T as i}from"./init-CBfbbyZt.mjs";import{t as a}from"./is-object-Bw0-z8qH.mjs";import{join as o}from"node:path";import{existsSync as s,readFileSync as c}from"node:fs";const l={allowTrailingComma:!0,disallowComments:!1};function u(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function d(a){let d=o(a,`.claude`,`launch.json`);if(!s(d))return{kind:`not-present`};let p;try{p=c(d,`utf-8`)}catch{return{kind:`declined`}}let m=[],h=t(p,m,l)??void 0;if(m.some(e=>!u(e,p))||!h||h.type!==`object`)return{kind:`declined`};let g=e(h).configurations;if(!Array.isArray(g))return{kind:`not-present`};let _=g.findIndex(f);if(_===-1)return{kind:`not-present`};let{text:v,changed:y}=r(p,[`configurations`,_]);return y?(n(d,v,{mode:i(d)}),{kind:`removed`}):{kind:`not-present`}}function f(e){if(!a(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?p.some(e=>m(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const p=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function m(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{d as t};
|
|
2
|
+
//# sourceMappingURL=launch-json-removal-Ds6to5PD.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as e,h as t,x as n,y as r,yt as i}from"./sleep-BZCw-NJO.mjs";import{Oc as a,kc as o}from"./src-CS_k7GF4.mjs";import{b as s}from"./src-
|
|
2
|
-
//# sourceMappingURL=loader-
|
|
1
|
+
import{g as e,h as t,x as n,y as r,yt as i}from"./sleep-BZCw-NJO.mjs";import{Oc as a,kc as o}from"./src-CS_k7GF4.mjs";import{b as s}from"./src-B2uhXnAX.mjs";import{A as c,L as l}from"./fs-traced-C5AXyho0.mjs";import{t as u}from"./constants-Cizrn7IS.mjs";import{t as d}from"./is-object-Bw0-z8qH.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=i();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return d(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=n({file:t.path,source:t.source,doc:t.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function b(n){let i=n??process.cwd(),d=[],p=[],m=[],h=[],g=c(`user`,i),_=l({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&d.push(g);let b=(n,r=!1)=>{let i=v(n);if(i.diagnostic!==void 0&&p.push(i.diagnostic),i.value===null)return{};let a=t({value:i.value,file:i.path,source:i.source,doc:i.doc});p.push(...a),d.push(n);let s=a.length>0?e(i.value):i.value;return r&&h.push(...o({value:s,file:i.path,source:i.source,doc:i.doc})),s},x=f(i,`.ok`,u),S=b(x,!0),C=b(c(`project-local`,i)),w=a(_.value,S,C),T=s.safeParse(w);if(!T.success){let e=v(x),t={code:`SCHEMA_INVALID`,issues:y(T.error.issues,e)};throw Error(r(t))}return{config:T.data,sources:d,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
|
|
2
|
+
//# sourceMappingURL=loader-BBetk1pa.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-BBetk1pa.mjs";export{e as loadConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Bi as e}from"./src-
|
|
2
|
-
//# sourceMappingURL=open-browser-
|
|
1
|
+
import{Bi as e}from"./src-B2uhXnAX.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}t(process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,process.platform===`win32`?[`/c`,`start`,``,a]:[a],e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
|
|
2
|
+
//# sourceMappingURL=open-browser-zyR1fJMP.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{zr as e}from"./src-B2uhXnAX.mjs";import"./constants-Cizrn7IS.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
|
|
2
2
|
`)}export{c as n,l as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-Bc6KqZjp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-Bc6KqZjp.mjs";export{t as formatPreviewBlock,e as previewContent};
|
package/dist/public/assets/{ActivityModeContent-DpHKV3Fo.js → ActivityModeContent-LZXobglw.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{a as n,i as r}from"./DocumentContext-Dnh6K82B.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{t as c}from"./button-Cym3gapE.js";import{i as l,n as u,t as d}from"./tooltip-DttaCTqz.js";import{a as f,c as p,i as m,o as h,s as g,t as _}from"./dialog-doK3a8ht.js";import{n as v}from"./dist-CJhtNlOm2.js";import{t as y}from"./dist-Cr4-nBVI.js";import{m as b}from"./Mermaid-BKe9ENk5.js";import{t as x}from"./circle-alert-b-E0_BIP.js";import{i as S}from"./prop-types-DoF2_bUg.js";import{t as C}from"./spinner-BY5pJxJc.js";import{t as w}from"./undo-2-E_jsrA9n.js";import{f as T}from"./doc-paths-BQkA8AK7.js";import{d as E}from"./page-list-cache-DXgYf538.js";import{a as D,i as O,n as k,o as A,t as ee}from"./agent-diff-store-CI9-nZ0i.js";import{t as j}from"./timeline-diff-store-CcRV6ImP.js";import{n as M}from"./use-activity-panel-CQXXnWdh.js";var N=s(),P=e(i(),1),F=t();function te(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function I(e){let t=(0,N.c)(86),{burst:n,docName:r,editCount:i,sessionAlive:s,inFlight:v,onOpenDiff:y,onRestore:b}=e,{_:x}=o(),[S,T]=(0,P.useState)(ne),E,O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{let e=setInterval(()=>T(Date.now()),3e4);return()=>clearInterval(e)},O=[],t[0]=E,t[1]=O):(E=t[0],O=t[1]),(0,P.useEffect)(E,O);let[k,A]=(0,P.useState)(!1),ee=D(),j=n.stackIndex+1,M=ee?.docName===r&&ee.keptCount===j,I=i-j,re=!s||v||I<=0,ie;t[2]!==I||t[3]!==b?(ie=function(){A(!1),b(I)},t[2]=I,t[3]=b,t[4]=ie):ie=t[4];let ae=ie,L;t[5]!==n||t[6]!==y?(L=()=>y(n),t[5]=n,t[6]=y,t[7]=L):L=t[7];let R;t[8]!==x||t[9]!==j||t[10]!==r?(R=x({id:`Z79bnE`,values:{burstNumber:j,docName:r}}),t[8]=x,t[9]=j,t[10]=r,t[11]=R):R=t[11];let oe=M?`bg-muted`:`hover:bg-muted/40`,se;t[12]===oe?se=t[13]:(se=[`flex min-w-0 flex-1 items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground transition-colors`,oe],t[12]=oe,t[13]=se);let ce=se.join(` `),z;t[14]!==n.ts||t[15]!==S?(z=te(n.ts,S),t[14]=n.ts,t[15]=S,t[16]=z):z=t[16];let B;t[17]===z?B=t[18]:(B=(0,F.jsx)(`span`,{className:`font-mono`,children:z}),t[17]=z,t[18]=B);let V;t[19]===n.additions?V=t[20]:(V=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[19]=n.additions,t[20]=V);let H;t[21]===n.deletions?H=t[22]:(H=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[21]=n.deletions,t[22]=H);let U;t[23]!==V||t[24]!==H?(U=(0,F.jsxs)(`span`,{className:`ml-auto font-mono`,children:[V,` `,H]}),t[23]=V,t[24]=H,t[25]=U):U=t[25];let W;t[26]!==M||t[27]!==B||t[28]!==U||t[29]!==L||t[30]!==R||t[31]!==ce?(W=(0,F.jsxs)(`button`,{type:`button`,onClick:L,"aria-pressed":M,"aria-label":R,"data-testid":`activity-panel-burst-open`,className:ce,children:[B,U]}),t[26]=M,t[27]=B,t[28]=U,t[29]=L,t[30]=R,t[31]=ce,t[32]=W):W=t[32];let le;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-3 w-px shrink-0 bg-border`}),t[33]=le):le=t[33];let G;t[34]!==x||t[35]!==j||t[36]!==r?(G=x({id:`Zhe80e`,values:{burstNumber:j,docName:r}}),t[34]=x,t[35]=j,t[36]=r,t[37]=G):G=t[37];let ue;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>A(!0),t[38]=ue):ue=t[38];let K;t[39]===v?K=t[40]:(K=v?(0,F.jsx)(C,{className:`size-3`,"aria-hidden":`true`}):(0,F.jsx)(w,{className:`size-3`,"aria-hidden":`true`}),t[39]=v,t[40]=K);let q;t[41]!==re||t[42]!==G||t[43]!==K?(q=(0,F.jsx)(l,{asChild:!0,children:(0,F.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`activity-panel-burst-restore`,"aria-label":G,disabled:re,onClick:ue,children:K})}),t[41]=re,t[42]=G,t[43]=K,t[44]=q):q=t[44];let J;t[45]!==x||t[46]!==I||t[47]!==s?(J=x(s?I>0?{id:`SOPwPh`}:{id:`62bOuM`}:{id:`NzFvyK`}),t[45]=x,t[46]=I,t[47]=s,t[48]=J):J=t[48];let Y;t[49]===J?Y=t[50]:(Y=(0,F.jsx)(u,{side:`left`,children:J}),t[49]=J,t[50]=Y);let X;t[51]!==q||t[52]!==Y?(X=(0,F.jsxs)(d,{children:[q,Y]}),t[51]=q,t[52]=Y,t[53]=X):X=t[53];let Z;t[54]!==W||t[55]!==X?(Z=(0,F.jsxs)(`div`,{className:`flex items-center border-t border-border/50 pr-3`,children:[W,le,X]}),t[54]=W,t[55]=X,t[56]=Z):Z=t[56];let Q;t[57]===v?Q=t[58]:(Q=e=>{!e&&!v?A(!1):e&&A(!0)},t[57]=v,t[58]=Q);let de;t[59]===x?de=t[60]:(de=x({id:`a4FRQv`}),t[59]=x,t[60]=de);let fe;t[61]===de?fe=t[62]:(fe=(0,F.jsx)(p,{children:de}),t[61]=de,t[62]=fe);let pe;t[63]===I?pe=t[64]:(pe=(0,F.jsx)(f,{children:(0,F.jsx)(a,{id:`LKIPzv`,values:{laterEdits:I}})}),t[63]=I,t[64]=pe);let $;t[65]!==fe||t[66]!==pe?($=(0,F.jsxs)(g,{children:[fe,pe]}),t[65]=fe,t[66]=pe,t[67]=$):$=t[67];let me;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,F.jsx)(c,{variant:`outline`,"data-testid":`activity-panel-burst-restore-cancel`,onClick:()=>A(!1),children:(0,F.jsx)(a,{id:`dEgA5A`})}),t[68]=me):me=t[68];let he;t[69]===v?he=t[70]:(he=v?(0,F.jsx)(C,{className:`mr-2 size-4`,"aria-hidden":`true`}):null,t[69]=v,t[70]=he);let ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,F.jsx)(a,{id:`9uI_rE`}),t[71]=ge):ge=t[71];let _e;t[72]!==ae||t[73]!==v||t[74]!==he?(_e=(0,F.jsxs)(h,{children:[me,(0,F.jsxs)(c,{variant:`destructive`,"data-testid":`activity-panel-burst-restore-confirm`,disabled:v,onClick:ae,children:[he,ge]})]}),t[72]=ae,t[73]=v,t[74]=he,t[75]=_e):_e=t[75];let ve;t[76]!==$||t[77]!==_e?(ve=(0,F.jsxs)(m,{children:[$,_e]}),t[76]=$,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==k||t[80]!==Q||t[81]!==ve?(ye=(0,F.jsx)(_,{open:k,onOpenChange:Q,children:ve}),t[79]=k,t[80]=Q,t[81]=ve,t[82]=ye):ye=t[82];let be;return t[83]!==Z||t[84]!==ye?(be=(0,F.jsxs)(F.Fragment,{children:[Z,ye]}),t[83]=Z,t[84]=ye,t[85]=be):be=t[85],be}function ne(){return Date.now()}function re(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return y._({id:`nYeBmY`,values:{hours:r}})}function ie(e){let t=(0,N.c)(56),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoDrop:c,onSetVersion:l}=e,{_:u}=o(),{docName:d}=n,[f,p]=(0,P.useState)(!1),[m,h]=(0,P.useState)(ae),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(e)},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,P.useEffect)(g,_);let v=n.bursts.length,y;t[2]!==n.docName||t[3]!==c||t[4]!==r||t[5]!==f?(y=e=>{e<=0||!r||f||(p(!0),Promise.resolve(c(n.docName,e)).finally(()=>{p(!1),ee()}))},t[2]=n.docName,t[3]=c,t[4]=r,t[5]=f,t[6]=y):y=t[6];let b=y;if(n.bursts.length===0)return null;let x;t[7]!==n.docName||t[8]!==s?(x=()=>s(n.docName),t[7]=n.docName,t[8]=s,t[9]=x):x=t[9];let S;t[10]!==u||t[11]!==d?(S=u({id:`QcpeeE`,values:{docName:d}}),t[10]=u,t[11]=d,t[12]=S):S=t[12];let C;t[13]!==n.docName||t[14]!==x||t[15]!==S?(C=(0,F.jsx)(`button`,{type:`button`,onClick:x,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":S,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[13]=n.docName,t[14]=x,t[15]=S,t[16]=C):C=t[16];let w;t[17]===n.additionsTotal?w=t[18]:(w=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[17]=n.additionsTotal,t[18]=w);let T;t[19]===n.deletionsTotal?T=t[20]:(T=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[19]=n.deletionsTotal,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[w,` `,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==n.lastTs||t[25]!==m?(D=re(n.lastTs,m),t[24]=n.lastTs,t[25]=m,t[26]=D):D=t[26];let O;t[27]===D?O=t[28]:(O=(0,F.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k;t[29]===i?k=t[30]:(k=i?(0,F.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,F.jsx)(a,{id:`6q0rnH`})}):null,t[29]=i,t[30]=k);let A;t[31]!==O||t[32]!==k||t[33]!==C||t[34]!==E?(A=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[C,E,O,k]}),t[31]=O,t[32]=k,t[33]=C,t[34]=E,t[35]=A):A=t[35];let j;if(t[36]!==b||t[37]!==v||t[38]!==n.bursts||t[39]!==n.docName||t[40]!==l||t[41]!==r||t[42]!==f){let e;t[44]!==b||t[45]!==v||t[46]!==n.docName||t[47]!==l||t[48]!==r||t[49]!==f?(e=e=>(0,F.jsx)(I,{burst:e,docName:n.docName,editCount:v,sessionAlive:r,inFlight:f,onOpenDiff:e=>l(e.stackIndex+1),onRestore:b},`${n.docName}:${e.stackIndex}`),t[44]=b,t[45]=v,t[46]=n.docName,t[47]=l,t[48]=r,t[49]=f,t[50]=e):e=t[50],j=n.bursts.map(e),t[36]=b,t[37]=v,t[38]=n.bursts,t[39]=n.docName,t[40]=l,t[41]=r,t[42]=f,t[43]=j}else j=t[43];let M;t[51]===j?M=t[52]:(M=(0,F.jsx)(`div`,{children:j}),t[51]=j,t[52]=M);let te;return t[53]!==A||t[54]!==M?(te=(0,F.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[A,M]}),t[53]=A,t[54]=M,t[55]=te):te=t[55],te}function ae(){return Date.now()}async function L(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function R(e){typeof window>`u`||(window.location.hash=T(e))}function oe(){let e=(0,N.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(C,{className:`mr-2 size-4`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,F.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,F.jsx)(`span`,{className:`text-sm`,children:(0,F.jsx)(a,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function se(e){let t=(0,N.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,F.jsx)(x,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:(0,F.jsx)(a,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,F.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(a,{id:`6gRgw8`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,F.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:l}),t[5]=r,t[6]=u);let d;return t[7]!==s||t[8]!==u?(d=(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,u]}),t[7]=s,t[8]=u,t[9]=d):d=t[9],d}function ce(){let e=(0,N.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,F.jsx)(`p`,{className:`text-sm italic`,children:(0,F.jsx)(a,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function z(e){let t=(0,N.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=o(),s;t[0]===i?s=t[1]:(s=i({id:`kYL1lH`}),t[0]=i,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=r?(0,F.jsx)(B,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[c,l]}),t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,F.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,F.jsx)(a,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==s||t[10]!==u?(f=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":s,children:[u,d]}),t[9]=s,t[10]=u,t[11]=f):f=t[11],f}function B(e){let t=(0,N.c)(9),{onClick:n}=e,{_:r}=o(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(b,{}),t[2]=s):s=t[2];let f;t[3]!==n||t[4]!==i?(f=(0,F.jsx)(l,{asChild:!0,children:(0,F.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:s})}),t[3]=n,t[4]=i,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,F.jsx)(u,{side:`bottom`,children:(0,F.jsx)(a,{id:`ogAuyr`})}),t[6]=p):p=t[6];let m;return t[7]===f?m=t[8]:(m=(0,F.jsxs)(d,{children:[f,p]}),t[7]=f,t[8]=m),m}function V(e){let t=(0,N.c)(9),{lastTs:n}=e,[r]=(0,P.useState)(H),i;t[0]!==n||t[1]!==r?(i=n?U(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let o=i,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(`span`,{className:`font-medium`,children:(0,F.jsx)(a,{id:`LCUy_N`})}),t[3]=s):s=t[3];let c;t[4]===o?c=t[5]:(c=o?(0,F.jsxs)(`span`,{children:[` · `,o]}):null,t[4]=o,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,F.jsx)(a,{id:`GK-IRZ`})}),t[6]=l):l=t[6];let u;return t[7]===c?u=t[8]:(u=(0,F.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[s,c,l]}),t[7]=c,t[8]=u),u}function H(){return Date.now()}function U(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return y._({id:`nYeBmY`,values:{hours:n}})}function W(e){let t=(0,N.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,F.jsx)(A,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function le(e){let t=(0,N.c)(25),{data:n,status:r,error:i,reload:s,onExit:c,onNavigate:l,onUndoDrop:u,onSetVersion:d,showBackButton:f}=e,{_:p}=o(),m=n?.files?.[0]?.lastTs??null,h=n?.files?.length??0,g;t[0]===p?g=t[1]:(g=p({id:`kYL1lH`}),t[0]=p,t[1]=g);let _;t[2]!==c||t[3]!==f?(_=f?(0,F.jsx)(B,{onClick:c}):null,t[2]=c,t[3]=f,t[4]=_):_=t[4];let v;t[5]!==n||t[6]!==h||t[7]!==m?(v=n?.agent?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(W,{agent:n.agent}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,F.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,F.jsx)(a,{id:`F6pfE9`}):m===null?(0,F.jsx)(a,{id:`PMyJ9C`}):(0,F.jsx)(a,{id:`237hSL`}),n.files.length>0?(0,F.jsxs)(F.Fragment,{children:[` · `,(0,F.jsx)(a,{id:`u3BOHd`,values:{fileCount:h}})]}):null]})]})]}):(0,F.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})})}),t[5]=n,t[6]=h,t[7]=m,t[8]=v):v=t[8];let y;t[9]!==_||t[10]!==v?(y=(0,F.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]!==n||t[13]!==i||t[14]!==m||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==r?(b=(0,F.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,F.jsx)(oe,{}):r===`error`&&i?(0,F.jsx)(se,{error:i,onRetry:s}):n===null?(0,F.jsx)(ce,{}):(0,F.jsxs)(F.Fragment,{children:[!n.sessionAlive&&m!==null?(0,F.jsx)(V,{lastTs:m}):null,n.files.length===0?(0,F.jsx)(ce,{}):n.files.map(e=>(0,F.jsx)(ie,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:l,onUndoDrop:u,onSetVersion:t=>d(e,t)},e.docName))]})}),t[12]=n,t[13]=i,t[14]=m,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=r,t[20]=b):b=t[20];let x;return t[21]!==g||t[22]!==y||t[23]!==b?(x=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":g,children:[y,b]}),t[21]=g,t[22]=y,t[23]=b,t[24]=x):x=t[24],x}function G(e){let t=(0,N.c)(30),i;t[0]===e?i=t[1]:(i=e===void 0?{}:e,t[0]=e,t[1]=i);let{showBackButton:a}=i,s=a===void 0?!0:a,{_:c}=o(),{docPanelAgentId:l,closeActivityPanel:u}=r(),{openTargetTransition:d}=n(),{pageMeta:f}=S(),{data:p,status:m,error:h,reload:g}=M(l),_,y;if(t[2]!==p||t[3]!==l?(_=()=>{if(!(!p||l===null))for(let e of p.files)O(l,e.docName,e.bursts.length)},y=[p,l],t[2]=p,t[3]=l,t[4]=_,t[5]=y):(_=t[4],y=t[5]),(0,P.useEffect)(_,y),l===null){let e;return t[6]!==u||t[7]!==s?(e=(0,F.jsx)(z,{onExit:u,showBackButton:s}),t[6]=u,t[7]=s,t[8]=e):e=t[8],e}let b;t[9]!==d||t[10]!==f?(b=e=>{d(E({kind:`doc`,target:e,docName:e},f),{disposition:`permanent`,consumeActiveNewTab:!0}),R(e)},t[9]=d,t[10]=f,t[11]=b):b=t[11];let x=b,C;t[12]!==p||t[13]!==l?(C=(e,t)=>{if(!p?.agent||l===null)return;j();let n=e.bursts.length;k({agentId:l,agentName:p.agent.displayName,agentColor:p.agent.color,agentIcon:p.agent.icon,docName:e.docName,keptCount:Math.max(0,Math.min(t,n)),maxVersions:n})},t[12]=p,t[13]=l,t[14]=C):C=t[14];let w=C,T;t[15]!==c||t[16]!==p||t[17]!==l||t[18]!==g?(T=async(e,t)=>{if(!(t<=0))try{await L({connectionId:l,docName:e,scope:`count`,count:t,agentName:p?.agent?.displayName}),v.success(c(t===1?{id:`-dNlfM`,values:{docName:e}}:{id:`ApeA0n`,values:{dropCount:t,docName:e}})),g()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);v.error(c({id:`EqrC_R`,values:{message:n}})),g()}},t[15]=c,t[16]=p,t[17]=l,t[18]=g,t[19]=T):T=t[19];let D=T,A;return t[20]!==u||t[21]!==p||t[22]!==h||t[23]!==x||t[24]!==w||t[25]!==D||t[26]!==g||t[27]!==s||t[28]!==m?(A=(0,F.jsx)(le,{data:p,status:m,error:h,reload:g,onExit:u,onNavigate:x,onUndoDrop:D,onSetVersion:w,showBackButton:s}),t[20]=u,t[21]=p,t[22]=h,t[23]=x,t[24]=w,t[25]=D,t[26]=g,t[27]=s,t[28]=m,t[29]=A):A=t[29],A}export{G as ActivityModeContent};
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{a as n,i as r}from"./DocumentContext-CMYNrz-_.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{t as c}from"./button-Cym3gapE.js";import{i as l,n as u,t as d}from"./tooltip-DttaCTqz.js";import{a as f,c as p,i as m,o as h,s as g,t as _}from"./dialog-doK3a8ht.js";import{n as v}from"./dist-CJhtNlOm2.js";import{t as y}from"./dist-Cr4-nBVI.js";import{m as b}from"./Mermaid-BKe9ENk5.js";import{t as x}from"./circle-alert-b-E0_BIP.js";import{i as S}from"./prop-types-DoF2_bUg.js";import{t as C}from"./spinner-BY5pJxJc.js";import{t as w}from"./undo-2-E_jsrA9n.js";import{f as T}from"./doc-paths-BQkA8AK7.js";import{d as E}from"./page-list-cache-DXgYf538.js";import{a as D,i as O,n as k,o as A,t as ee}from"./agent-diff-store-BnFkUQtB.js";import{t as j}from"./timeline-diff-store-CcRV6ImP.js";import{n as M}from"./use-activity-panel-CucXmSmA.js";var N=s(),P=e(i(),1),F=t();function te(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function I(e){let t=(0,N.c)(86),{burst:n,docName:r,editCount:i,sessionAlive:s,inFlight:v,onOpenDiff:y,onRestore:b}=e,{_:x}=o(),[S,T]=(0,P.useState)(ne),E,O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{let e=setInterval(()=>T(Date.now()),3e4);return()=>clearInterval(e)},O=[],t[0]=E,t[1]=O):(E=t[0],O=t[1]),(0,P.useEffect)(E,O);let[k,A]=(0,P.useState)(!1),ee=D(),j=n.stackIndex+1,M=ee?.docName===r&&ee.keptCount===j,I=i-j,re=!s||v||I<=0,ie;t[2]!==I||t[3]!==b?(ie=function(){A(!1),b(I)},t[2]=I,t[3]=b,t[4]=ie):ie=t[4];let ae=ie,L;t[5]!==n||t[6]!==y?(L=()=>y(n),t[5]=n,t[6]=y,t[7]=L):L=t[7];let R;t[8]!==x||t[9]!==j||t[10]!==r?(R=x({id:`Z79bnE`,values:{burstNumber:j,docName:r}}),t[8]=x,t[9]=j,t[10]=r,t[11]=R):R=t[11];let oe=M?`bg-muted`:`hover:bg-muted/40`,se;t[12]===oe?se=t[13]:(se=[`flex min-w-0 flex-1 items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground transition-colors`,oe],t[12]=oe,t[13]=se);let ce=se.join(` `),z;t[14]!==n.ts||t[15]!==S?(z=te(n.ts,S),t[14]=n.ts,t[15]=S,t[16]=z):z=t[16];let B;t[17]===z?B=t[18]:(B=(0,F.jsx)(`span`,{className:`font-mono`,children:z}),t[17]=z,t[18]=B);let V;t[19]===n.additions?V=t[20]:(V=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[19]=n.additions,t[20]=V);let H;t[21]===n.deletions?H=t[22]:(H=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[21]=n.deletions,t[22]=H);let U;t[23]!==V||t[24]!==H?(U=(0,F.jsxs)(`span`,{className:`ml-auto font-mono`,children:[V,` `,H]}),t[23]=V,t[24]=H,t[25]=U):U=t[25];let W;t[26]!==M||t[27]!==B||t[28]!==U||t[29]!==L||t[30]!==R||t[31]!==ce?(W=(0,F.jsxs)(`button`,{type:`button`,onClick:L,"aria-pressed":M,"aria-label":R,"data-testid":`activity-panel-burst-open`,className:ce,children:[B,U]}),t[26]=M,t[27]=B,t[28]=U,t[29]=L,t[30]=R,t[31]=ce,t[32]=W):W=t[32];let le;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-3 w-px shrink-0 bg-border`}),t[33]=le):le=t[33];let G;t[34]!==x||t[35]!==j||t[36]!==r?(G=x({id:`Zhe80e`,values:{burstNumber:j,docName:r}}),t[34]=x,t[35]=j,t[36]=r,t[37]=G):G=t[37];let ue;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>A(!0),t[38]=ue):ue=t[38];let K;t[39]===v?K=t[40]:(K=v?(0,F.jsx)(C,{className:`size-3`,"aria-hidden":`true`}):(0,F.jsx)(w,{className:`size-3`,"aria-hidden":`true`}),t[39]=v,t[40]=K);let q;t[41]!==re||t[42]!==G||t[43]!==K?(q=(0,F.jsx)(l,{asChild:!0,children:(0,F.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`activity-panel-burst-restore`,"aria-label":G,disabled:re,onClick:ue,children:K})}),t[41]=re,t[42]=G,t[43]=K,t[44]=q):q=t[44];let J;t[45]!==x||t[46]!==I||t[47]!==s?(J=x(s?I>0?{id:`SOPwPh`}:{id:`62bOuM`}:{id:`NzFvyK`}),t[45]=x,t[46]=I,t[47]=s,t[48]=J):J=t[48];let Y;t[49]===J?Y=t[50]:(Y=(0,F.jsx)(u,{side:`left`,children:J}),t[49]=J,t[50]=Y);let X;t[51]!==q||t[52]!==Y?(X=(0,F.jsxs)(d,{children:[q,Y]}),t[51]=q,t[52]=Y,t[53]=X):X=t[53];let Z;t[54]!==W||t[55]!==X?(Z=(0,F.jsxs)(`div`,{className:`flex items-center border-t border-border/50 pr-3`,children:[W,le,X]}),t[54]=W,t[55]=X,t[56]=Z):Z=t[56];let Q;t[57]===v?Q=t[58]:(Q=e=>{!e&&!v?A(!1):e&&A(!0)},t[57]=v,t[58]=Q);let de;t[59]===x?de=t[60]:(de=x({id:`a4FRQv`}),t[59]=x,t[60]=de);let fe;t[61]===de?fe=t[62]:(fe=(0,F.jsx)(p,{children:de}),t[61]=de,t[62]=fe);let pe;t[63]===I?pe=t[64]:(pe=(0,F.jsx)(f,{children:(0,F.jsx)(a,{id:`LKIPzv`,values:{laterEdits:I}})}),t[63]=I,t[64]=pe);let $;t[65]!==fe||t[66]!==pe?($=(0,F.jsxs)(g,{children:[fe,pe]}),t[65]=fe,t[66]=pe,t[67]=$):$=t[67];let me;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,F.jsx)(c,{variant:`outline`,"data-testid":`activity-panel-burst-restore-cancel`,onClick:()=>A(!1),children:(0,F.jsx)(a,{id:`dEgA5A`})}),t[68]=me):me=t[68];let he;t[69]===v?he=t[70]:(he=v?(0,F.jsx)(C,{className:`mr-2 size-4`,"aria-hidden":`true`}):null,t[69]=v,t[70]=he);let ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,F.jsx)(a,{id:`9uI_rE`}),t[71]=ge):ge=t[71];let _e;t[72]!==ae||t[73]!==v||t[74]!==he?(_e=(0,F.jsxs)(h,{children:[me,(0,F.jsxs)(c,{variant:`destructive`,"data-testid":`activity-panel-burst-restore-confirm`,disabled:v,onClick:ae,children:[he,ge]})]}),t[72]=ae,t[73]=v,t[74]=he,t[75]=_e):_e=t[75];let ve;t[76]!==$||t[77]!==_e?(ve=(0,F.jsxs)(m,{children:[$,_e]}),t[76]=$,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==k||t[80]!==Q||t[81]!==ve?(ye=(0,F.jsx)(_,{open:k,onOpenChange:Q,children:ve}),t[79]=k,t[80]=Q,t[81]=ve,t[82]=ye):ye=t[82];let be;return t[83]!==Z||t[84]!==ye?(be=(0,F.jsxs)(F.Fragment,{children:[Z,ye]}),t[83]=Z,t[84]=ye,t[85]=be):be=t[85],be}function ne(){return Date.now()}function re(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return y._({id:`nYeBmY`,values:{hours:r}})}function ie(e){let t=(0,N.c)(56),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoDrop:c,onSetVersion:l}=e,{_:u}=o(),{docName:d}=n,[f,p]=(0,P.useState)(!1),[m,h]=(0,P.useState)(ae),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(e)},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,P.useEffect)(g,_);let v=n.bursts.length,y;t[2]!==n.docName||t[3]!==c||t[4]!==r||t[5]!==f?(y=e=>{e<=0||!r||f||(p(!0),Promise.resolve(c(n.docName,e)).finally(()=>{p(!1),ee()}))},t[2]=n.docName,t[3]=c,t[4]=r,t[5]=f,t[6]=y):y=t[6];let b=y;if(n.bursts.length===0)return null;let x;t[7]!==n.docName||t[8]!==s?(x=()=>s(n.docName),t[7]=n.docName,t[8]=s,t[9]=x):x=t[9];let S;t[10]!==u||t[11]!==d?(S=u({id:`QcpeeE`,values:{docName:d}}),t[10]=u,t[11]=d,t[12]=S):S=t[12];let C;t[13]!==n.docName||t[14]!==x||t[15]!==S?(C=(0,F.jsx)(`button`,{type:`button`,onClick:x,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":S,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[13]=n.docName,t[14]=x,t[15]=S,t[16]=C):C=t[16];let w;t[17]===n.additionsTotal?w=t[18]:(w=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[17]=n.additionsTotal,t[18]=w);let T;t[19]===n.deletionsTotal?T=t[20]:(T=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[19]=n.deletionsTotal,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[w,` `,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==n.lastTs||t[25]!==m?(D=re(n.lastTs,m),t[24]=n.lastTs,t[25]=m,t[26]=D):D=t[26];let O;t[27]===D?O=t[28]:(O=(0,F.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k;t[29]===i?k=t[30]:(k=i?(0,F.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,F.jsx)(a,{id:`6q0rnH`})}):null,t[29]=i,t[30]=k);let A;t[31]!==O||t[32]!==k||t[33]!==C||t[34]!==E?(A=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[C,E,O,k]}),t[31]=O,t[32]=k,t[33]=C,t[34]=E,t[35]=A):A=t[35];let j;if(t[36]!==b||t[37]!==v||t[38]!==n.bursts||t[39]!==n.docName||t[40]!==l||t[41]!==r||t[42]!==f){let e;t[44]!==b||t[45]!==v||t[46]!==n.docName||t[47]!==l||t[48]!==r||t[49]!==f?(e=e=>(0,F.jsx)(I,{burst:e,docName:n.docName,editCount:v,sessionAlive:r,inFlight:f,onOpenDiff:e=>l(e.stackIndex+1),onRestore:b},`${n.docName}:${e.stackIndex}`),t[44]=b,t[45]=v,t[46]=n.docName,t[47]=l,t[48]=r,t[49]=f,t[50]=e):e=t[50],j=n.bursts.map(e),t[36]=b,t[37]=v,t[38]=n.bursts,t[39]=n.docName,t[40]=l,t[41]=r,t[42]=f,t[43]=j}else j=t[43];let M;t[51]===j?M=t[52]:(M=(0,F.jsx)(`div`,{children:j}),t[51]=j,t[52]=M);let te;return t[53]!==A||t[54]!==M?(te=(0,F.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[A,M]}),t[53]=A,t[54]=M,t[55]=te):te=t[55],te}function ae(){return Date.now()}async function L(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function R(e){typeof window>`u`||(window.location.hash=T(e))}function oe(){let e=(0,N.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(C,{className:`mr-2 size-4`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,F.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,F.jsx)(`span`,{className:`text-sm`,children:(0,F.jsx)(a,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function se(e){let t=(0,N.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,F.jsx)(x,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:(0,F.jsx)(a,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,F.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(a,{id:`6gRgw8`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,F.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:l}),t[5]=r,t[6]=u);let d;return t[7]!==s||t[8]!==u?(d=(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,u]}),t[7]=s,t[8]=u,t[9]=d):d=t[9],d}function ce(){let e=(0,N.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,F.jsx)(`p`,{className:`text-sm italic`,children:(0,F.jsx)(a,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function z(e){let t=(0,N.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=o(),s;t[0]===i?s=t[1]:(s=i({id:`kYL1lH`}),t[0]=i,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=r?(0,F.jsx)(B,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[c,l]}),t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,F.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,F.jsx)(a,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==s||t[10]!==u?(f=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":s,children:[u,d]}),t[9]=s,t[10]=u,t[11]=f):f=t[11],f}function B(e){let t=(0,N.c)(9),{onClick:n}=e,{_:r}=o(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(b,{}),t[2]=s):s=t[2];let f;t[3]!==n||t[4]!==i?(f=(0,F.jsx)(l,{asChild:!0,children:(0,F.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:s})}),t[3]=n,t[4]=i,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,F.jsx)(u,{side:`bottom`,children:(0,F.jsx)(a,{id:`ogAuyr`})}),t[6]=p):p=t[6];let m;return t[7]===f?m=t[8]:(m=(0,F.jsxs)(d,{children:[f,p]}),t[7]=f,t[8]=m),m}function V(e){let t=(0,N.c)(9),{lastTs:n}=e,[r]=(0,P.useState)(H),i;t[0]!==n||t[1]!==r?(i=n?U(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let o=i,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(`span`,{className:`font-medium`,children:(0,F.jsx)(a,{id:`LCUy_N`})}),t[3]=s):s=t[3];let c;t[4]===o?c=t[5]:(c=o?(0,F.jsxs)(`span`,{children:[` · `,o]}):null,t[4]=o,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,F.jsx)(a,{id:`GK-IRZ`})}),t[6]=l):l=t[6];let u;return t[7]===c?u=t[8]:(u=(0,F.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[s,c,l]}),t[7]=c,t[8]=u),u}function H(){return Date.now()}function U(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return y._({id:`nYeBmY`,values:{hours:n}})}function W(e){let t=(0,N.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,F.jsx)(A,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function le(e){let t=(0,N.c)(25),{data:n,status:r,error:i,reload:s,onExit:c,onNavigate:l,onUndoDrop:u,onSetVersion:d,showBackButton:f}=e,{_:p}=o(),m=n?.files?.[0]?.lastTs??null,h=n?.files?.length??0,g;t[0]===p?g=t[1]:(g=p({id:`kYL1lH`}),t[0]=p,t[1]=g);let _;t[2]!==c||t[3]!==f?(_=f?(0,F.jsx)(B,{onClick:c}):null,t[2]=c,t[3]=f,t[4]=_):_=t[4];let v;t[5]!==n||t[6]!==h||t[7]!==m?(v=n?.agent?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(W,{agent:n.agent}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,F.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,F.jsx)(a,{id:`F6pfE9`}):m===null?(0,F.jsx)(a,{id:`PMyJ9C`}):(0,F.jsx)(a,{id:`237hSL`}),n.files.length>0?(0,F.jsxs)(F.Fragment,{children:[` · `,(0,F.jsx)(a,{id:`u3BOHd`,values:{fileCount:h}})]}):null]})]})]}):(0,F.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})})}),t[5]=n,t[6]=h,t[7]=m,t[8]=v):v=t[8];let y;t[9]!==_||t[10]!==v?(y=(0,F.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]!==n||t[13]!==i||t[14]!==m||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==r?(b=(0,F.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,F.jsx)(oe,{}):r===`error`&&i?(0,F.jsx)(se,{error:i,onRetry:s}):n===null?(0,F.jsx)(ce,{}):(0,F.jsxs)(F.Fragment,{children:[!n.sessionAlive&&m!==null?(0,F.jsx)(V,{lastTs:m}):null,n.files.length===0?(0,F.jsx)(ce,{}):n.files.map(e=>(0,F.jsx)(ie,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:l,onUndoDrop:u,onSetVersion:t=>d(e,t)},e.docName))]})}),t[12]=n,t[13]=i,t[14]=m,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=r,t[20]=b):b=t[20];let x;return t[21]!==g||t[22]!==y||t[23]!==b?(x=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":g,children:[y,b]}),t[21]=g,t[22]=y,t[23]=b,t[24]=x):x=t[24],x}function G(e){let t=(0,N.c)(30),i;t[0]===e?i=t[1]:(i=e===void 0?{}:e,t[0]=e,t[1]=i);let{showBackButton:a}=i,s=a===void 0?!0:a,{_:c}=o(),{docPanelAgentId:l,closeActivityPanel:u}=r(),{openTargetTransition:d}=n(),{pageMeta:f}=S(),{data:p,status:m,error:h,reload:g}=M(l),_,y;if(t[2]!==p||t[3]!==l?(_=()=>{if(!(!p||l===null))for(let e of p.files)O(l,e.docName,e.bursts.length)},y=[p,l],t[2]=p,t[3]=l,t[4]=_,t[5]=y):(_=t[4],y=t[5]),(0,P.useEffect)(_,y),l===null){let e;return t[6]!==u||t[7]!==s?(e=(0,F.jsx)(z,{onExit:u,showBackButton:s}),t[6]=u,t[7]=s,t[8]=e):e=t[8],e}let b;t[9]!==d||t[10]!==f?(b=e=>{d(E({kind:`doc`,target:e,docName:e},f),{disposition:`permanent`,consumeActiveNewTab:!0}),R(e)},t[9]=d,t[10]=f,t[11]=b):b=t[11];let x=b,C;t[12]!==p||t[13]!==l?(C=(e,t)=>{if(!p?.agent||l===null)return;j();let n=e.bursts.length;k({agentId:l,agentName:p.agent.displayName,agentColor:p.agent.color,agentIcon:p.agent.icon,docName:e.docName,keptCount:Math.max(0,Math.min(t,n)),maxVersions:n})},t[12]=p,t[13]=l,t[14]=C):C=t[14];let w=C,T;t[15]!==c||t[16]!==p||t[17]!==l||t[18]!==g?(T=async(e,t)=>{if(!(t<=0))try{await L({connectionId:l,docName:e,scope:`count`,count:t,agentName:p?.agent?.displayName}),v.success(c(t===1?{id:`-dNlfM`,values:{docName:e}}:{id:`ApeA0n`,values:{dropCount:t,docName:e}})),g()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);v.error(c({id:`EqrC_R`,values:{message:n}})),g()}},t[15]=c,t[16]=p,t[17]=l,t[18]=g,t[19]=T):T=t[19];let D=T,A;return t[20]!==u||t[21]!==p||t[22]!==h||t[23]!==x||t[24]!==w||t[25]!==D||t[26]!==g||t[27]!==s||t[28]!==m?(A=(0,F.jsx)(le,{data:p,status:m,error:h,reload:g,onExit:u,onNavigate:x,onUndoDrop:D,onSetVersion:w,showBackButton:s}),t[20]=u,t[21]=p,t[22]=h,t[23]=x,t[24]=w,t[25]=D,t[26]=g,t[27]=s,t[28]=m,t[29]=A):A=t[29],A}export{G as ActivityModeContent};
|