@inkeep/open-knowledge 0.4.0-beta.30 → 0.4.0-beta.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/assets/skills/open-knowledge/SKILL.md +3 -3
  2. package/dist/cli.mjs +5 -5
  3. package/dist/config-schema.json +0 -13
  4. package/dist/config.project.schema.json +0 -13
  5. package/dist/constants-BVG2ymMz.mjs +2 -0
  6. package/dist/{dist-Va4IjzRw.mjs → dist-Bfw3oOGm.mjs} +23 -23
  7. package/dist/{dist-Cg4a9GjH.mjs → dist-BjlSvO5w.mjs} +1 -1
  8. package/dist/{dist-H3Ld-L-a.mjs → dist-k62w-4-v.mjs} +3 -3
  9. package/dist/index.mjs +1 -1
  10. package/dist/init-CcjfJ0-a.mjs +1 -0
  11. package/dist/{init-DrfKz58U.mjs → init-DsLc7vc7.mjs} +3 -3
  12. package/dist/loader-BLwabAxT.mjs +1 -0
  13. package/dist/{loader-DKoWw50g.mjs → loader-DmKx1Dxe.mjs} +3 -3
  14. package/dist/{preview-D6nLHyS2.mjs → preview-CuLb6srO.mjs} +2 -2
  15. package/dist/preview-GtCa8ObI.mjs +1 -0
  16. package/dist/public/assets/{ActivityModeContent-CSzGBekb.js → ActivityModeContent-PLMlj69Z.js} +1 -1
  17. package/dist/public/assets/{DocumentContext-HTIMnclU.js → DocumentContext-DyDoN3zw.js} +1 -1
  18. package/dist/public/assets/{GraphPanel-Bh6hilLJ.js → GraphPanel-CSCNVbH4.js} +1 -1
  19. package/dist/public/assets/{SettingsDialog-Bn0Qb8Z-.js → SettingsDialog-BZIR95bl.js} +3 -3
  20. package/dist/public/assets/{SourceEditor-CLnmY3Yf.js → SourceEditor-BSNx4vgo.js} +1 -1
  21. package/dist/public/assets/{config-validation-events-CiSk03iO.js → config-validation-events-CQdOhgu4.js} +1 -1
  22. package/dist/public/assets/doc-hash-D_cCMufM.js +422 -0
  23. package/dist/public/assets/{index-6soyXw4M.js → index-DplFbAir.js} +4 -4
  24. package/dist/public/assets/{target-navigation-intent-BpcRYgIB.js → target-navigation-intent-D3oiWq7j.js} +1 -1
  25. package/dist/public/assets/{toggle-group-CZU3XaIH.js → toggle-group-CnwuxlqO.js} +1 -1
  26. package/dist/public/assets/{tooltip-DcfXr4mU.js → tooltip-DZMJlHWf.js} +1 -1
  27. package/dist/public/assets/{typing-burst-detector-BbQifQft.js → typing-burst-detector-2N-LtlIn.js} +1 -1
  28. package/dist/public/index.html +8 -8
  29. package/dist/schemas/v0/config.project.schema.json +0 -13
  30. package/dist/{src-DL2x7ekf.mjs → src-CPSJr8lr.mjs} +2 -2
  31. package/dist/start-BoXsjqPU.mjs +1 -0
  32. package/dist/{start-CKupR8YG.mjs → start-DUBJCx0O.mjs} +2 -2
  33. package/package.json +1 -1
  34. package/dist/constants-BY_EleLO.mjs +0 -2
  35. package/dist/init-BpTa5nQL.mjs +0 -1
  36. package/dist/loader-BcdTtT9v.mjs +0 -1
  37. package/dist/preview-DfT6ddN-.mjs +0 -1
  38. package/dist/public/assets/doc-hash-BSwTWr6y.js +0 -422
  39. package/dist/start-BPfRyvzL.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./chunk-FK9Q3tQk.mjs";import{r,t as i}from"./esm-CEs3LWY3.mjs";import{J as a,ir as o,n as s,or as c}from"./dist-H3Ld-L-a.mjs";import{D as l,F as u,It as d,Pt as f,Wn as p,in as m}from"./dist-Va4IjzRw.mjs";import{n as h,t as g}from"./constants-BY_EleLO.mjs";import{t as _}from"./is-object-C-4FJ0rP.mjs";import{i as v,o as y,r as b,s as x,t as S}from"./colors-BtKMHmBX.mjs";import{t as ee}from"./preview-D6nLHyS2.mjs";import{execFileSync as te}from"node:child_process";import ne,{basename as re,dirname as C,isAbsolute as ie,join as w,posix as ae,relative as T,resolve as E,sep as D,win32 as oe}from"node:path";import{cpSync as se,existsSync as O,lstatSync as ce,mkdirSync as k,readFileSync as A,realpathSync as le,rmSync as ue,writeFileSync as j}from"node:fs";import M from"node:process";import{homedir as N}from"node:os";import{AsyncLocalStorage as de,AsyncResource as fe}from"node:async_hooks";import{stripVTControlCharacters as pe,styleText as P}from"node:util";import*as me from"node:readline";function he(){return M.platform.startsWith(`win`)?!!M.env.CI||!!M.env.WT_SESSION||!!M.env.TERMINUS_SUBLIME||M.env.ConEmuTask===`{cmd::Cmder}`||M.env.TERM_PROGRAM===`Terminus-Sublime`||M.env.TERM_PROGRAM===`vscode`||M.env.TERM===`xterm-256color`||M.env.TERM===`alacritty`||M.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:M.env.TERM!==`linux`}const ge={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:`╱`},_e={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:`⅒`},ve={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`},ye={...ge,..._e},be={...ge,...ve},F=he()?ye:be;Object.entries(_e);var xe=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}}));const Se=(()=>{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}})(),Ce=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,we=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,Te=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ee=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,De=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Oe=/\t{1,1000}/y,ke=/[\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,Ae=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,je=/\p{M}+/gu,Me={limit:1/0,ellipsis:``},Ne=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Ne(i,Me,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Ae,l],[Te,0],[Ee,o],[Oe,s],[ke,c],[De,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(je,``)){let t=e.codePointAt(0)||0;if(S=Ce(t)?2:we(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===De?Se(e.slice(p,n.lastIndex)):n===ke?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}},Pe={limit:1/0,ellipsis:``,ellipsisWidth:0},I=(e,t={})=>Ne(e,Pe,t).width,Fe=`]8;;`,Ie=RegExp(`(?:\\[(?<code>\\d+)m|\\${Fe}(?<uri>.*))`,`y`),Le=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},Re=e=>`[${e}m`,ze=e=>`${Fe}${e}`,Be=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:I(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=I(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Fe,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())},Ve=e=>{let t=e.split(` `),n=t.length;for(;n&&!I(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},He=(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=I(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=I(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(``),Be(s,r,t),c=I(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Be(s,r,t),c=I(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Be(s,r,t),c=I(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Ve(e)));let l=s.join(`
1
+ import{i as e,o as t,t as n}from"./chunk-FK9Q3tQk.mjs";import{r,t as i}from"./esm-CEs3LWY3.mjs";import{J as a,ir as o,n as s,or as c}from"./dist-k62w-4-v.mjs";import{D as l,F as u,It as d,Pt as f,Wn as p,in as m}from"./dist-Bfw3oOGm.mjs";import{n as h,t as g}from"./constants-BVG2ymMz.mjs";import{t as _}from"./is-object-C-4FJ0rP.mjs";import{i as v,o as y,r as b,s as x,t as S}from"./colors-BtKMHmBX.mjs";import{t as ee}from"./preview-CuLb6srO.mjs";import{execFileSync as te}from"node:child_process";import ne,{basename as re,dirname as C,isAbsolute as ie,join as w,posix as ae,relative as T,resolve as E,sep as D,win32 as oe}from"node:path";import{cpSync as se,existsSync as O,lstatSync as ce,mkdirSync as k,readFileSync as A,realpathSync as le,rmSync as ue,writeFileSync as j}from"node:fs";import M from"node:process";import{homedir as N}from"node:os";import{AsyncLocalStorage as de,AsyncResource as fe}from"node:async_hooks";import{stripVTControlCharacters as pe,styleText as P}from"node:util";import*as me from"node:readline";function he(){return M.platform.startsWith(`win`)?!!M.env.CI||!!M.env.WT_SESSION||!!M.env.TERMINUS_SUBLIME||M.env.ConEmuTask===`{cmd::Cmder}`||M.env.TERM_PROGRAM===`Terminus-Sublime`||M.env.TERM_PROGRAM===`vscode`||M.env.TERM===`xterm-256color`||M.env.TERM===`alacritty`||M.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:M.env.TERM!==`linux`}const ge={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:`╱`},_e={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:`⅒`},ve={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`},ye={...ge,..._e},be={...ge,...ve},F=he()?ye:be;Object.entries(_e);var xe=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}}));const Se=(()=>{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}})(),Ce=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,we=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,Te=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ee=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,De=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Oe=/\t{1,1000}/y,ke=/[\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,Ae=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,je=/\p{M}+/gu,Me={limit:1/0,ellipsis:``},Ne=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Ne(i,Me,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Ae,l],[Te,0],[Ee,o],[Oe,s],[ke,c],[De,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(je,``)){let t=e.codePointAt(0)||0;if(S=Ce(t)?2:we(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===De?Se(e.slice(p,n.lastIndex)):n===ke?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}},Pe={limit:1/0,ellipsis:``,ellipsisWidth:0},I=(e,t={})=>Ne(e,Pe,t).width,Fe=`]8;;`,Ie=RegExp(`(?:\\[(?<code>\\d+)m|\\${Fe}(?<uri>.*))`,`y`),Le=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},Re=e=>`[${e}m`,ze=e=>`${Fe}${e}`,Be=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:I(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=I(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Fe,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())},Ve=e=>{let t=e.split(` `),n=t.length;for(;n&&!I(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},He=(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=I(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=I(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(``),Be(s,r,t),c=I(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Be(s,r,t),c=I(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Be(s,r,t),c=I(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Ve(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===`›`){Ie.lastIndex=e+1;let t=Ie.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+=ze(``));let e=i?Le(i):void 0;i&&e&&(r+=Re(e))}else t===`
4
4
  `&&(i&&Le(i)&&(r+=Re(i)),a&&(r+=ze(a)))}return r},Ue=/\r?\n/;function We(e,t,n){return String(e).normalize().split(Ue).map(e=>He(e,t,n)).join(`
@@ -404,5 +404,5 @@ last-spawn-error.log
404
404
  `)?n:`${n}\n`,`utf-8`)}function ur(e,t){let n;try{n=le(t)}catch{n=E(t)}let r;try{r=ce(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(r?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run \`ok init\`, or pass \`--no-mcp\` to skip MCP config writes.`);let i=C(e);for(;i.length>1&&i!==D;){let t;try{t=le(i)}catch(e){if(e.code===`ENOENT`){i=C(i);continue}throw e}let r=T(n,t);if(r===``||!r.startsWith(`..`)&&!ie(r))return;throw Error(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run, or pass \`--no-mcp\`.`)}}const dr=e=>e!==`project`,fr=e=>e!==`user`;async function pr(){let e=await rn({message:`Where should the MCP server be configured?
405
405
  `,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 mr(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??pr)():`both`}const hr=`0.0.1`,gr=`open-knowledge-ui`;function _r(e,t={}){let n=w(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:gr,runtimeExecutable:`node`,runtimeArgs:[Yn(),`ui`],port:3e3}:{name:gr,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(ur(n,e),!O(n))return k(C(n),{recursive:!0}),j(n,`${JSON.stringify({version:hr,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let t=A(n,`utf-8`).trim(),i=t?JSON.parse(t):{};if(!_(i))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let a=Array.isArray(i.configurations)?i.configurations:[],o=a.findIndex(e=>_(e)&&e.name===gr);o>=0?a[o]=r:a.push(r);let s={...i,version:i.version??hr,configurations:a};return j(n,`${JSON.stringify(s,null,2)}\n`,`utf-8`),{action:o>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function vr(e,t,n){try{return O(e.detectPath?.(t,n)??C(e.configPath(t,n)))}catch{return!1}}function $(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)}}if(!i&&!n.skipAvailabilityCheck&&!vr(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{ur(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`}}let s;try{s=e.format===`toml`?sr(o):or(o)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let c=s[e.topLevelKey]??{},l=c[a],u;try{u=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)}}let d={...s,[e.topLevelKey]:{...c,[a]:u}};try{e.format===`toml`?lr(o,d):cr(o,d)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:l===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function yr(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=p(),i=C(n);ur(i,t);let a=O(n)?`overwritten`:`written`;return ue(i,{recursive:!0,force:!0}),k(C(i),{recursive:!0}),se(r,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function br(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!O(n)))return{editorId:e.id,label:e.label,path:n}}async function xr(e){let t=ar(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>$(t,``,n,e.home))}function Sr(e,t,n){let r;try{r=e.configPath(t,n)}catch{return null}let i;try{i=e.format===`toml`?sr(r):or(r)}catch{return null}let a=i[e.topLevelKey];if(!_(a))return null;let o=a[e.serverName(t)];return _(o)?o:null}async function Cr(e={}){let t=Kn(E(e.cwd??process.cwd()),{homeDir:e.home}),n=t.projectRoot,r=!O(w(n,`.ok`));t.ancestorPromoted?console.log(`[ok] Opened existing project at ${n}`):t.gitRootPromoted&&r&&console.log(`[ok] Initialized OK at ${n} (scoped to ${t.defaultContentDir}/)`);let i={mode:e.devMcp?`dev`:`published`},a=await d(n),o;try{o=Un(n,{contentDir:t.defaultContentDir})}catch(t){let r=Q.claude.configPath(n,e.home);return{projectRoot:n,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:a.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:r,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`}}let s=await mr({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),c=e.editors??Tr(n,e.home),l=e.editors??J.filter(e=>Q[e].projectConfigPath!==void 0),u=ar(c),p=ar(l),h=e.mcp===!1||s===null,g=Array.from(new Map([...u,...h?[]:p].map(e=>[e.id,e])).values()),_=u.filter(t=>vr(t,n,e.home)),v=[],y=[],b=new Set;for(let t of g){if(h){let r=``;try{r=t.configPath(n,e.home)}catch{}v.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:r,serverName:t.serverName(n)});continue}if(dr(s)&&u.includes(t)&&v.push($(t,n,i,e.home)),fr(s)&&p.includes(t)&&t.projectConfigPath){let r=t.projectConfigPath(n),a=$(t,n,i,e.home,r);v.push(a),(a.action===`written`||a.action===`overwritten`)&&(b.add(r),y.push(yr(t,n)))}}let x=!h&&s!==null&&fr(s)?p.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,S=h?[]:_.map(e=>br(e,n)).filter(e=>e!==void 0).filter(e=>!b.has(e.path)),ee=_.some(e=>e.id===`claude`)&&!h?_r(n,i):void 0,te=await(e.installUserSkill??m)({home:e.home}),ne=f({home:e.home}),re=h?`skipped-flag`:`skipped-missing`,C=v.find(e=>e.editorId===`claude`)??v[0]??{action:re,configPath:Q.claude.configPath(n,e.home)};return{projectRoot:n,contentCreated:o.created,contentUpdated:o.updated,contentSkipped:o.skipped,editors:v,projectSkills:y,legacyProjectConfigs:S,launchJson:ee,skillInstall:te,didGitInit:a.didInit,claudeDesktopDetected:ne,mcpAction:C.action,mcpPath:C.configPath,mcpError:`error`in C?C.error:void 0,projectScopeUnsupportedLabels:x}}function wr(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`),s=e=>{let n=e.configPath.startsWith(t)?T(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let c=w(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(S(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(S(`Content already present at ${c}/`)),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(S(`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(S(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(S(`MCP server configuration:`));for(let r of e.editors){let i=r.configPath.startsWith(t)?T(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,c=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-c.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${c}${l}${i} ${y(`registered`)}${a}${u}`);break;case`overwritten`:n.push(` ${c}${l}${i} ${y(`updated`)}${a}${u}`);break;case`skipped-missing`:n.push(` ${c}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${c}${l}${i} ${b(`FAILED`)}: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(s(e.launchJson))}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(S(`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?T(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${y(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${y(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${b(`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} ${T(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(S(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${y(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${y(`already installed at current version`)}`);break;case`failed`:n.push(` ${x(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${x(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(n.push(``),n.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${S(`ok install-skill`)}`)),e.preview?(n.push(``),n.push(ee(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),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(`${y(`✓`)} ${S(`Next steps:`)}`),n.push(` 1. Open your editor (${v(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${v(`ok seed`)}`),n.push(` 4. Use the three MCP workflow tools as you build the wiki:`),n.push(` - ${v(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${v(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${v(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
406
406
  `)}function Tr(e,t){let n=[];for(let r of J)vr(Q[r],e,t)&&n.push(r);return n}function Er(){return new i(`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`).addOption(new r(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).action(async e=>{let t=process.cwd(),n;try{n=await Cr({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope})}catch(e){if(e instanceof u){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
407
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-DfT6ddN-.mjs`),{loadConfig:t}=await import(`./loader-BcdTtT9v.mjs`),{resolveContentDir:r}=await import(`./dist-Cg4a9GjH.mjs`),{config:i}=t(n.projectRoot),a=r(i,n.projectRoot);n.preview=e({projectDir:n.projectRoot,contentDir:a})}catch(e){n.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${wr(n,n.projectRoot)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{We as C,Ge as S,F as T,at as _,mr as a,ut as b,$ as c,Y as d,Q as f,it as g,st as h,Sr as i,xr as l,Un as m,wr as n,Cr as o,Kn as p,Er as r,_r as s,Tr as t,J as u,ct as v,xe as w,tt as x,ot as y};
408
- //# sourceMappingURL=init-DrfKz58U.mjs.map
407
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-GtCa8ObI.mjs`),{loadConfig:t}=await import(`./loader-BLwabAxT.mjs`),{resolveContentDir:r}=await import(`./dist-BjlSvO5w.mjs`),{config:i}=t(n.projectRoot),a=r(i,n.projectRoot);n.preview=e({projectDir:n.projectRoot,contentDir:a})}catch(e){n.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${wr(n,n.projectRoot)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{We as C,Ge as S,F as T,at as _,mr as a,ut as b,$ as c,Y as d,Q as f,it as g,st as h,Sr as i,xr as l,Un as m,wr as n,Cr as o,Kn as p,Er as r,_r as s,Tr as t,J as u,ct as v,xe as w,tt as x,ot as y};
408
+ //# sourceMappingURL=init-DsLc7vc7.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-DmKx1Dxe.mjs";export{e as loadConfig};
@@ -1,4 +1,4 @@
1
- import{Ln as e,Zr as t,lr as n}from"./dist-H3Ld-L-a.mjs";import{Kr as r,f as i}from"./dist-Va4IjzRw.mjs";import{t as a}from"./constants-BY_EleLO.mjs";import{t as o}from"./is-object-C-4FJ0rP.mjs";import{resolve as s}from"node:path";import{existsSync as c,readFileSync as l}from"node:fs";import{homedir as u}from"node:os";import{realpath as d}from"node:fs/promises";async function f(e){let t=s(e);try{return await d(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}}var p=t();function m(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];o(a)&&o(i)?n[r]=m(i,a):a!==void 0&&(n[r]=a)}return n}function h(e){if(!c(e))return{value:null,path:e,source:null,doc:null};let t;try{t=l(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,p.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return o(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}const g=[`include`,`exclude`];function _(e){let t="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.";return e===`exclude`?[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,t].join(` `):[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,t].join(` `)}function v(e){let t=e.value;if(!o(t))return[];let r=t.content;if(!o(r))return[];let i=[];for(let t of g)if(t in r){let r=[`content`,t],a;e.doc!==null&&e.source!==null&&(a=n({file:e.path,source:e.source,doc:e.doc,path:r})),i.push({code:`REMOVED_KEY`,path:r,redirect:_(t),...a===void 0?{}:{source:a}})}return i}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(t){let n=t??process.cwd(),o=[],c=s(u(),`.ok`,a),l=r({absPath:c}),d={};l.valid&&l.source!==void 0?(d=m(d,l.value),o.push(c)):l.valid;let f=s(n,`.ok`,a),p=h(f);if(p.value!==null){let t=v(p);if(t.length>0)throw Error(t.map(e).join(`
1
+ import{Ln as e,Zr as t,lr as n}from"./dist-k62w-4-v.mjs";import{Kr as r,f as i}from"./dist-Bfw3oOGm.mjs";import{t as a}from"./constants-BVG2ymMz.mjs";import{t as o}from"./is-object-C-4FJ0rP.mjs";import{resolve as s}from"node:path";import{existsSync as c,readFileSync as l}from"node:fs";import{homedir as u}from"node:os";import{realpath as d}from"node:fs/promises";async function f(e){let t=s(e);try{return await d(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}}var p=t();function m(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];o(a)&&o(i)?n[r]=m(i,a):a!==void 0&&(n[r]=a)}return n}function h(e){if(!c(e))return{value:null,path:e,source:null,doc:null};let t;try{t=l(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,p.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return o(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}const g=[`include`,`exclude`];function _(e){let t="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.";return e===`exclude`?[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,t].join(` `):[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,t].join(` `)}function v(e){let t=e.value;if(!o(t))return[];let r=t.content;if(!o(r))return[];let i=[];for(let t of g)if(t in r){let r=[`content`,t],a;e.doc!==null&&e.source!==null&&(a=n({file:e.path,source:e.source,doc:e.doc,path:r})),i.push({code:`REMOVED_KEY`,path:r,redirect:_(t),...a===void 0?{}:{source:a}})}return i}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(t){let n=t??process.cwd(),o=[],c=s(u(),`.ok`,a),l=r({absPath:c}),d={};l.valid&&l.source!==void 0?(d=m(d,l.value),o.push(c)):l.valid;let f=s(n,`.ok`,a),p=h(f);if(p.value!==null){let t=v(p);if(t.length>0)throw Error(t.map(e).join(`
2
2
 
3
- `));d=m(d,p.value),o.push(f)}x(d,[`upload`,`maxBytes`],`streaming uploads have no user-facing cap`),x(d,[`github`,`oauthAppClientId`],`use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID env var instead`),x(d,[`server`,`host`],`use the --host flag or HOST env var instead`),x(d,[`server`,`openOnAgentEdit`]),x(d,[`mcp`,`autoStart`],`to disable auto-start, set OK_MCP_AUTOSTART=0`),x(d,[`mcp`,`tools`,`read_document`,`historyDepth`]),x(d,[`mcp`,`tools`,`grep`,`maxResults`]),x(d,[`mcp`,`tools`,`search`,`maxResults`]);let g=i.safeParse(d);if(!g.success){let t={code:`SCHEMA_INVALID`,issues:y(g.error.issues,p)};throw Error(e(t))}return{config:g.data,sources:o}}function x(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){if(!o(r))return;r=r[t[e]]}if(!o(r))return;let i=t[t.length-1];if(r[i]===void 0)return;let a=t.join(`.`);console.warn(`[config] ${a} is no longer user-configurable; ${n??`the value is hardcoded in @inkeep/open-knowledge-core`}. Remove the key to silence this warning.`)}function S(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=f(e.startupCwd);return async o=>{let s=await f(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,S as t};
4
- //# sourceMappingURL=loader-DKoWw50g.mjs.map
3
+ `));d=m(d,p.value),o.push(f)}x(d,[`upload`,`maxBytes`],`streaming uploads have no user-facing cap`),x(d,[`github`,`oauthAppClientId`],`use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID env var instead`),x(d,[`server`,`host`],`use the --host flag or HOST env var instead`),x(d,[`server`,`openOnAgentEdit`]),x(d,[`mcp`,`autoStart`],`to disable auto-start, set OK_MCP_AUTOSTART=0`),x(d,[`mcp`,`tools`,`read_document`,`historyDepth`]),x(d,[`mcp`,`tools`,`grep`,`maxResults`]),x(d,[`mcp`,`tools`,`search`,`maxResults`]),x(d,[`preview`,`baseUrl`],"preview URLs now resolve only to the running UI process — start one with `ok ui`");let g=i.safeParse(d);if(!g.success){let t={code:`SCHEMA_INVALID`,issues:y(g.error.issues,p)};throw Error(e(t))}return{config:g.data,sources:o}}function x(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){if(!o(r))return;r=r[t[e]]}if(!o(r))return;let i=t[t.length-1];if(r[i]===void 0)return;let a=t.join(`.`);console.warn(`[config] ${a} is no longer user-configurable; ${n??`the value is hardcoded in @inkeep/open-knowledge-core`}. Remove the key to silence this warning.`)}function S(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=f(e.startupCwd);return async o=>{let s=await f(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,S as t};
4
+ //# sourceMappingURL=loader-DmKx1Dxe.mjs.map
@@ -1,3 +1,3 @@
1
- import{Ct as e}from"./dist-Va4IjzRw.mjs";import"./constants-BY_EleLO.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(`
1
+ import{Ct as e}from"./dist-Bfw3oOGm.mjs";import"./constants-BVG2ymMz.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-D6nLHyS2.mjs.map
3
+ //# sourceMappingURL=preview-CuLb6srO.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-CuLb6srO.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ActivityPanelDiffView-DeDaG2lq.js","./chunk-CFjPhJqf.js","./compiler-runtime-CVnuRdak.js","./ActivityPanelDiffView-legcy4jI.css"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./preload-helper-2ej06EnG.js";import{n,r,t as i}from"./compiler-runtime-CVnuRdak.js";import{Sn as a,bn as o,n as s,nt as c,on as l,r as u,xn as d}from"./DocumentContext-HTIMnclU.js";import{At as f,G as p,W as m,p as h}from"./doc-hash-BSwTWr6y.js";import{C as g,t as _}from"./button-C1nwPVFQ.js";import{f as v,i as y,m as b,r as x,t as S}from"./agent-presence-BrTlNKmt.js";import{p as C}from"./dist-OTL8-1C2.js";import{i as w,n as T,t as E}from"./tooltip-DcfXr4mU.js";import{a as D,c as O,i as k,o as ee,s as te,t as ne}from"./dialog-BFN-ujuF.js";var re=g(`rewind`,[[`path`,{d:`M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z`,key:`2a1g8i`}],[`path`,{d:`M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z`,key:`rg3s36`}]]),A=i(),j=e(n(),1),ie=500,ae=64;async function oe(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t),r;try{r=await n.json()}catch(e){throw new c(`Could not parse /api/agent-activity response.`,{cause:e,status:n.status})}if(!n.ok){let e=f.safeParse(r);throw e.success?Error(e.data.title):new c(`/api/agent-activity returned a non-RFC-9457 error response.`,{cause:e.error,status:n.status})}let i=m.safeParse(r);if(!i.success)throw new c(`/api/agent-activity returned a body that did not match AgentActivitySuccessSchema.`,{cause:i.error,status:n.status});return i.data}async function se(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r),a;try{a=await i.json()}catch(e){throw new c(`Could not parse /api/agent-burst-diff response.`,{cause:e,status:i.status})}if(!i.ok){let e=f.safeParse(a);throw e.success?Error(e.data.title):new c(`/api/agent-burst-diff returned a non-RFC-9457 error response.`,{cause:e.error,status:i.status})}let o=p.safeParse(a);if(!o.success)throw new c(`/api/agent-burst-diff returned a body that did not match AgentBurstDiffSuccessSchema.`,{cause:o.error,status:i.status});return o.data.diff}function ce(e){let t=(0,A.c)(23),{systemProvider:n}=s(),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(`idle`),[c,l]=(0,j.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new y(ae),t[0]=u):u=t[0];let d=(0,j.useRef)(u),f=(0,j.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;o(`loading`),l(null),oe(e).then(r=>{if(f.current!==t)return;let a=ue(n,e);i({...r,writingDocs:a}),o(`ready`)}).catch(e=>{f.current===t&&(l(e instanceof Error?e.message:String(e)),o(`error`))})},t[1]=n,t[2]=p);let m=p,g;t[3]!==e||t[4]!==m?(g=()=>{if(!e){f.current+=1,i(null),o(`idle`),l(null),d.current.clear();return}d.current.clear(),m(e);let t=null,n=h(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,m(e)},ie))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=m,t[5]=g):g=t[5];let _;t[6]===e?_=t[7]:(_=[e],t[6]=e,t[7]=_),(0,j.useEffect)(g,_);let v,b;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=ue(n,e);i(e=>!e||le(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},b=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=b):(v=t[10],b=t[11]),(0,j.useEffect)(v,b);let x;t[12]===e?x=t[13]:(x=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await se(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=x);let S=x,C;t[14]!==e||t[15]!==m?(C=()=>{e&&m(e)},t[14]=e,t[15]=m,t[16]=C):C=t[16];let w=C,T;return t[17]!==r||t[18]!==c||t[19]!==S||t[20]!==w||t[21]!==a?(T={data:r,status:a,error:c,reload:w,fetchBurstDiff:S},t[17]=r,t[18]=c,t[19]=S,t[20]=w,t[21]=a,t[22]=T):T=t[22],T}function le(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ue(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!S(r))return n;let i=[t,t.startsWith(`agent-`)?t.slice(6):`agent-${t}`];for(let e of r.getStates().values()){let t=e.agentPresence;if(t)for(let e of i){let r=t[e];r&&r.mode===`writing`&&r.currentDoc&&n.add(r.currentDoc)}}return n}var M=r(),de=(0,j.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-DeDaG2lq.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)).ActivityPanelDiffView}));function fe(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function pe(e){let t=(0,A.c)(38),{burst:n,docName:r,fetchBurstDiff:i}=e,[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(null),[u,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(N),_,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{let e=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval(e)},v=[],t[0]=_,t[1]=v):(_=t[0],v=t[1]),(0,j.useEffect)(_,v);let y;t[2]!==n.stackIndex||t[3]!==c||t[4]!==r||t[5]!==o||t[6]!==i||t[7]!==p?(y=()=>{let e=!o;s(e),e&&c===null&&!p&&(m(!0),f(null),i(r,n.stackIndex).then(e=>{l(e),m(!1)}).catch(e=>{f(e instanceof Error?e.message:String(e)),m(!1)}))},t[2]=n.stackIndex,t[3]=c,t[4]=r,t[5]=o,t[6]=i,t[7]=p,t[8]=y):y=t[8];let b=y,x=`${o?`Collapse`:`Expand`} burst ${n.stackIndex+1} diff`,S;t[9]===o?S=t[10]:(S=o?(0,M.jsx)(a,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,M.jsx)(d,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[9]=o,t[10]=S);let C;t[11]!==n.ts||t[12]!==h?(C=fe(n.ts,h),t[11]=n.ts,t[12]=h,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,M.jsx)(`span`,{className:`font-mono`,children:C}),t[14]=C,t[15]=w);let T;t[16]===n.additions?T=t[17]:(T=(0,M.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[16]=n.additions,t[17]=T);let E;t[18]===n.deletions?E=t[19]:(E=(0,M.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[18]=n.deletions,t[19]=E);let D;t[20]!==T||t[21]!==E?(D=(0,M.jsxs)(`span`,{className:`ml-auto font-mono`,children:[T,` `,E]}),t[20]=T,t[21]=E,t[22]=D):D=t[22];let O;t[23]!==o||t[24]!==D||t[25]!==x||t[26]!==S||t[27]!==w||t[28]!==b?(O=(0,M.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground hover:bg-muted/40`,"aria-expanded":o,"aria-label":x,children:[S,w,D]}),t[23]=o,t[24]=D,t[25]=x,t[26]=S,t[27]=w,t[28]=b,t[29]=O):O=t[29];let k;t[30]!==c||t[31]!==o||t[32]!==u||t[33]!==p?(k=o?(0,M.jsx)(`div`,{className:`bg-muted/20`,children:p?(0,M.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff…`}):u?(0,M.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,u]}):c===null?(0,M.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`No diff.`}):(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff…`}),children:(0,M.jsx)(de,{diff:c})})}):null,t[30]=c,t[31]=o,t[32]=u,t[33]=p,t[34]=k):k=t[34];let ee;return t[35]!==O||t[36]!==k?(ee=(0,M.jsxs)(`div`,{className:`border-t border-border/50`,children:[O,k]}),t[35]=O,t[36]=k,t[37]=ee):ee=t[37],ee}function N(){return Date.now()}function me(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function P(e){let t=(0,A.c)(93),{file:n,sessionAlive:r,isWriting:i,onNavigate:o,onUndoLast:s,onUndoAll:c,fetchBurstDiff:l}=e,[u,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(!1),[y,b]=(0,j.useState)(ge),x,S;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=setInterval(()=>b(Date.now()),3e4);return()=>clearInterval(e)},S=[],t[0]=x,t[1]=S):(x=t[0],S=t[1]),(0,j.useEffect)(x,S),n.bursts.length===0)return null;let C=!r||n.bursts.length===0||h,ie=r?n.bursts.length===0?`Nothing to undo on this file`:null:`Session ended — undo unavailable`,ae;t[2]!==C||t[3]!==n.docName||t[4]!==s?(ae=e=>{e.stopPropagation(),!C&&(g(!0),Promise.resolve(s(n.docName)).finally(()=>g(!1)))},t[2]=C,t[3]=n.docName,t[4]=s,t[5]=ae):ae=t[5];let oe=ae,se;t[6]===C?se=t[7]:(se=e=>{e.stopPropagation(),!C&&m(!0)},t[6]=C,t[7]=se);let ce=se,le;t[8]!==C||t[9]!==n.docName||t[10]!==c?(le=()=>{m(!1),!C&&(g(!0),Promise.resolve(c(n.docName)).finally(()=>g(!1)))},t[8]=C,t[9]=n.docName,t[10]=c,t[11]=le):le=t[11];let ue=le,de;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>f(he),t[12]=de):de=t[12];let fe=u?`Collapse ${n.docName}`:`Expand ${n.docName}`,N;t[13]===u?N=t[14]:(N=u?(0,M.jsx)(a,{className:`size-4`,"aria-hidden":`true`}):(0,M.jsx)(d,{className:`size-4`,"aria-hidden":`true`}),t[13]=u,t[14]=N);let P;t[15]!==u||t[16]!==fe||t[17]!==N?(P=(0,M.jsx)(`button`,{type:`button`,onClick:de,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":u,"aria-label":fe,"data-testid":`activity-panel-file-row-carrot`,children:N}),t[15]=u,t[16]=fe,t[17]=N,t[18]=P):P=t[18];let F;t[19]!==n.docName||t[20]!==o?(F=()=>o(n.docName),t[19]=n.docName,t[20]=o,t[21]=F):F=t[21];let _e=`Navigate to ${n.docName}`,I;t[22]!==n.docName||t[23]!==F||t[24]!==_e?(I=(0,M.jsx)(`button`,{type:`button`,onClick:F,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":_e,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[22]=n.docName,t[23]=F,t[24]=_e,t[25]=I):I=t[25];let ve=`Undo last edit on ${n.docName}`,ye;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,M.jsx)(v,{className:`size-3.5`,"aria-hidden":`true`}),t[26]=ye):ye=t[26];let L;t[27]!==C||t[28]!==oe||t[29]!==ve?(L=(0,M.jsx)(w,{asChild:!0,children:(0,M.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:oe,disabled:C,"aria-label":ve,"data-testid":`activity-panel-undo-last`,children:ye})}),t[27]=C,t[28]=oe,t[29]=ve,t[30]=L):L=t[30];let be=ie??`Undo last edit`,R;t[31]===be?R=t[32]:(R=(0,M.jsx)(T,{side:`bottom`,children:be}),t[31]=be,t[32]=R);let z;t[33]!==L||t[34]!==R?(z=(0,M.jsxs)(E,{children:[L,R]}),t[33]=L,t[34]=R,t[35]=z):z=t[35];let xe=`Undo all edits on ${n.docName}`,Se;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,M.jsx)(re,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=Se):Se=t[36];let B;t[37]!==C||t[38]!==ce||t[39]!==xe?(B=(0,M.jsx)(w,{asChild:!0,children:(0,M.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ce,disabled:C,"aria-label":xe,"data-testid":`activity-panel-undo-all`,children:Se})}),t[37]=C,t[38]=ce,t[39]=xe,t[40]=B):B=t[40];let Ce=ie??`Undo all edits`,V;t[41]===Ce?V=t[42]:(V=(0,M.jsx)(T,{side:`bottom`,children:Ce}),t[41]=Ce,t[42]=V);let H;t[43]!==B||t[44]!==V?(H=(0,M.jsxs)(E,{children:[B,V]}),t[43]=B,t[44]=V,t[45]=H):H=t[45];let U;t[46]===n.additionsTotal?U=t[47]:(U=(0,M.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[46]=n.additionsTotal,t[47]=U);let W;t[48]===n.deletionsTotal?W=t[49]:(W=(0,M.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[48]=n.deletionsTotal,t[49]=W);let G;t[50]!==U||t[51]!==W?(G=(0,M.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[U,` `,W]}),t[50]=U,t[51]=W,t[52]=G):G=t[52];let K;t[53]!==n.lastTs||t[54]!==y?(K=me(n.lastTs,y),t[53]=n.lastTs,t[54]=y,t[55]=K):K=t[55];let q;t[56]===K?q=t[57]:(q=(0,M.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:K}),t[56]=K,t[57]=q);let J;t[58]===i?J=t[59]:(J=i?(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:`writing…`}):null,t[58]=i,t[59]=J);let Y;t[60]!==I||t[61]!==z||t[62]!==H||t[63]!==G||t[64]!==q||t[65]!==J||t[66]!==P?(Y=(0,M.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[P,I,z,H,G,q,J]}),t[60]=I,t[61]=z,t[62]=H,t[63]=G,t[64]=q,t[65]=J,t[66]=P,t[67]=Y):Y=t[67];let X;t[68]!==u||t[69]!==l||t[70]!==n.bursts||t[71]!==n.docName?(X=u?(0,M.jsx)(`div`,{children:n.bursts.map(e=>(0,M.jsx)(pe,{burst:e,docName:n.docName,fetchBurstDiff:l},`${n.docName}:${e.stackIndex}`))}):null,t[68]=u,t[69]=l,t[70]=n.bursts,t[71]=n.docName,t[72]=X):X=t[72];let we;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,M.jsx)(O,{children:`Undo all edits on this file?`}),t[73]=we):we=t[73];let Z;t[74]===n.docName?Z=t[75]:(Z=(0,M.jsx)(`span`,{className:`font-mono text-foreground`,children:n.docName}),t[74]=n.docName,t[75]=Z);let Te=n.bursts.length===1?``:`s`,Q;t[76]!==n.bursts.length||t[77]!==Z||t[78]!==Te?(Q=(0,M.jsxs)(te,{children:[we,(0,M.jsxs)(D,{children:[`This will revert every change this agent has made to`,` `,Z,` in their current session (`,n.bursts.length,` burst`,Te,`). Other files and other writers are not affected.`]})]}),t[76]=n.bursts.length,t[77]=Z,t[78]=Te,t[79]=Q):Q=t[79];let Ee;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,M.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>m(!1),"data-testid":`activity-panel-undo-all-cancel`,children:`Cancel`}),t[80]=Ee):Ee=t[80];let $;t[81]===ue?$=t[82]:($=(0,M.jsxs)(ee,{children:[Ee,(0,M.jsx)(_,{type:`button`,variant:`destructive`,onClick:ue,"data-testid":`activity-panel-undo-all-confirm`,children:`Undo all`})]}),t[81]=ue,t[82]=$);let De;t[83]!==Q||t[84]!==$?(De=(0,M.jsxs)(k,{className:`sm:max-w-md`,children:[Q,$]}),t[83]=Q,t[84]=$,t[85]=De):De=t[85];let Oe;t[86]!==p||t[87]!==De?(Oe=(0,M.jsx)(ne,{open:p,onOpenChange:m,children:De}),t[86]=p,t[87]=De,t[88]=Oe):Oe=t[88];let ke;return t[89]!==Y||t[90]!==X||t[91]!==Oe?(ke=(0,M.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[Y,X,Oe]}),t[89]=Y,t[90]=X,t[91]=Oe,t[92]=ke):ke=t[92],ke}function he(e){return!e}function ge(){return Date.now()}async function F(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 _e(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function I(e){typeof window>`u`||(window.location.hash=_e(e))}function ve(){let e=(0,A.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[(0,M.jsx)(l,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`text-sm`,children:`Loading agent activity…`})]}),e[0]=t):t=e[0],t}function ye(e){let t=(0,A.c)(9),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,M.jsx)(o,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=a):a=t[1];let s;t[2]===n?s=t[3]:(s=(0,M.jsxs)(`div`,{className:`space-y-1`,children:[a,(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=(0,M.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=c);let l;return t[6]!==s||t[7]!==c?(l=(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8],l}function L(){let e=(0,A.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,M.jsx)(`p`,{className:`text-sm italic`,children:`No edits yet.`})}),e[0]=t):t=e[0],t}function be(e){let t=(0,A.c)(8),{onExit:n}=e,r;t[0]===n?r=t[1]:(r=(0,M.jsx)(R,{onClick:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,M.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`}),t[2]=i):i=t[2];let a;t[3]===r?a=t[4]:(a=(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[r,i]}),t[3]=r,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,M.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,M.jsx)(`p`,{className:`text-center text-sm italic`,children:`Click an agent's avatar in the presence bar to view their session.`})}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,M.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":`Agent activity`,children:[a,o]}),t[6]=a,t[7]=s),s}function R(e){let t=(0,A.c)(6),{onClick:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,M.jsx)(b,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,M.jsx)(w,{asChild:!0,children:(0,M.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":`Back to document view`,"data-testid":`docpanel-exit-agent-mode`,children:r})}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,M.jsx)(T,{side:`bottom`,children:`Back to document view`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,M.jsxs)(E,{children:[i,a]}),t[4]=i,t[5]=o),o}function z(e){let t=(0,A.c)(9),{lastTs:n}=e,[r]=(0,j.useState)(xe),i;t[0]!==n||t[1]!==r?(i=n?Se(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,M.jsx)(`span`,{className:`font-medium`,children:`Session ended`}),t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=a?(0,M.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,M.jsx)(`div`,{className:`mt-1 opacity-80`,children:`Undo buttons are disabled — per-session state has been garbage-collected.`}),t[6]=c):c=t[6];let l;return t[7]===s?l=t[8]:(l=(0,M.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:[o,s,c]}),t[7]=s,t[8]=l),l}function xe(){return Date.now()}function Se(e){let t=Math.max(0,e);return t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:`${Math.round(t/36e5)}h ago`}function B(e){let t=(0,A.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,M.jsx)(x,{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,M.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 Ce(e){let t=(0,A.c)(20),{data:n,status:r,error:i,reload:a,fetchBurstDiff:o,onExit:s,onNavigate:c,onUndoLast:l,onUndoAll:u}=e,d=n?.files?.[0]?.lastTs??null,f;t[0]===s?f=t[1]:(f=(0,M.jsx)(R,{onClick:s}),t[0]=s,t[1]=f);let p;t[2]===n?p=t[3]:(p=n?.agent?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(B,{agent:n.agent}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,M.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?`Active`:`Ended`,n.files.length>0?` · ${n.files.length} file${n.files.length===1?``:`s`}`:``]})]})]}):(0,M.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,M.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`})}),t[2]=n,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,M.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]!==n||t[8]!==i||t[9]!==o||t[10]!==d||t[11]!==c||t[12]!==u||t[13]!==l||t[14]!==a||t[15]!==r?(h=(0,M.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,M.jsx)(ve,{}):r===`error`&&i?(0,M.jsx)(ye,{error:i,onRetry:a}):n===null?(0,M.jsx)(L,{}):(0,M.jsxs)(M.Fragment,{children:[n.sessionAlive?null:(0,M.jsx)(z,{lastTs:d}),n.files.length===0?(0,M.jsx)(L,{}):n.files.map(e=>(0,M.jsx)(P,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:l,onUndoAll:u,fetchBurstDiff:o},e.docName))]})}),t[7]=n,t[8]=i,t[9]=o,t[10]=d,t[11]=c,t[12]=u,t[13]=l,t[14]=a,t[15]=r,t[16]=h):h=t[16];let g;return t[17]!==m||t[18]!==h?(g=(0,M.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":`Agent activity`,children:[m,h]}),t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function V(){let e=(0,A.c)(22),{docPanelAgentId:t,closeActivityPanel:n}=s(),{openDocumentTransition:r}=u(),{data:i,status:a,error:o,reload:c,fetchBurstDiff:l}=ce(t);if(t===null){let t;return e[0]===n?t=e[1]:(t=(0,M.jsx)(be,{onExit:n}),e[0]=n,e[1]=t),t}let d;e[2]===r?d=e[3]:(d=e=>{r(e),I(e)},e[2]=r,e[3]=d);let f=d,p;e[4]!==i||e[5]!==t||e[6]!==c?(p=async e=>{try{await F({connectionId:t,docName:e,scope:`last`,agentName:i?.agent?.displayName}),c()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);C.error(`Undo failed: ${n}`),c()}},e[4]=i,e[5]=t,e[6]=c,e[7]=p):p=e[7];let m=p,h;e[8]!==i||e[9]!==t||e[10]!==c?(h=async e=>{try{await F({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),C.success(`Undone all edits on ${e}`),c()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);C.error(`Undo all failed: ${n}`),c()}},e[8]=i,e[9]=t,e[10]=c,e[11]=h):h=e[11];let g=h,_;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==f||e[17]!==g||e[18]!==m||e[19]!==c||e[20]!==a?(_=(0,M.jsx)(Ce,{data:i,status:a,error:o,reload:c,fetchBurstDiff:l,onExit:n,onNavigate:f,onUndoLast:m,onUndoAll:g}),e[12]=n,e[13]=i,e[14]=o,e[15]=l,e[16]=f,e[17]=g,e[18]=m,e[19]=c,e[20]=a,e[21]=_):_=e[21],_}export{V as ActivityModeContent};
2
+ import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./preload-helper-2ej06EnG.js";import{n,r,t as i}from"./compiler-runtime-CVnuRdak.js";import{Sn as a,bn as o,n as s,nt as c,on as l,r as u,xn as d}from"./DocumentContext-DyDoN3zw.js";import{At as f,G as p,W as m,p as h}from"./doc-hash-D_cCMufM.js";import{C as g,t as _}from"./button-C1nwPVFQ.js";import{f as v,i as y,m as b,r as x,t as S}from"./agent-presence-BrTlNKmt.js";import{p as C}from"./dist-OTL8-1C2.js";import{i as w,n as T,t as E}from"./tooltip-DZMJlHWf.js";import{a as D,c as O,i as k,o as ee,s as te,t as ne}from"./dialog-BFN-ujuF.js";var re=g(`rewind`,[[`path`,{d:`M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z`,key:`2a1g8i`}],[`path`,{d:`M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z`,key:`rg3s36`}]]),A=i(),j=e(n(),1),ie=500,ae=64;async function oe(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t),r;try{r=await n.json()}catch(e){throw new c(`Could not parse /api/agent-activity response.`,{cause:e,status:n.status})}if(!n.ok){let e=f.safeParse(r);throw e.success?Error(e.data.title):new c(`/api/agent-activity returned a non-RFC-9457 error response.`,{cause:e.error,status:n.status})}let i=m.safeParse(r);if(!i.success)throw new c(`/api/agent-activity returned a body that did not match AgentActivitySuccessSchema.`,{cause:i.error,status:n.status});return i.data}async function se(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r),a;try{a=await i.json()}catch(e){throw new c(`Could not parse /api/agent-burst-diff response.`,{cause:e,status:i.status})}if(!i.ok){let e=f.safeParse(a);throw e.success?Error(e.data.title):new c(`/api/agent-burst-diff returned a non-RFC-9457 error response.`,{cause:e.error,status:i.status})}let o=p.safeParse(a);if(!o.success)throw new c(`/api/agent-burst-diff returned a body that did not match AgentBurstDiffSuccessSchema.`,{cause:o.error,status:i.status});return o.data.diff}function ce(e){let t=(0,A.c)(23),{systemProvider:n}=s(),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(`idle`),[c,l]=(0,j.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new y(ae),t[0]=u):u=t[0];let d=(0,j.useRef)(u),f=(0,j.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;o(`loading`),l(null),oe(e).then(r=>{if(f.current!==t)return;let a=ue(n,e);i({...r,writingDocs:a}),o(`ready`)}).catch(e=>{f.current===t&&(l(e instanceof Error?e.message:String(e)),o(`error`))})},t[1]=n,t[2]=p);let m=p,g;t[3]!==e||t[4]!==m?(g=()=>{if(!e){f.current+=1,i(null),o(`idle`),l(null),d.current.clear();return}d.current.clear(),m(e);let t=null,n=h(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,m(e)},ie))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=m,t[5]=g):g=t[5];let _;t[6]===e?_=t[7]:(_=[e],t[6]=e,t[7]=_),(0,j.useEffect)(g,_);let v,b;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=ue(n,e);i(e=>!e||le(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},b=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=b):(v=t[10],b=t[11]),(0,j.useEffect)(v,b);let x;t[12]===e?x=t[13]:(x=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await se(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=x);let S=x,C;t[14]!==e||t[15]!==m?(C=()=>{e&&m(e)},t[14]=e,t[15]=m,t[16]=C):C=t[16];let w=C,T;return t[17]!==r||t[18]!==c||t[19]!==S||t[20]!==w||t[21]!==a?(T={data:r,status:a,error:c,reload:w,fetchBurstDiff:S},t[17]=r,t[18]=c,t[19]=S,t[20]=w,t[21]=a,t[22]=T):T=t[22],T}function le(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ue(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!S(r))return n;let i=[t,t.startsWith(`agent-`)?t.slice(6):`agent-${t}`];for(let e of r.getStates().values()){let t=e.agentPresence;if(t)for(let e of i){let r=t[e];r&&r.mode===`writing`&&r.currentDoc&&n.add(r.currentDoc)}}return n}var M=r(),de=(0,j.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-DeDaG2lq.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)).ActivityPanelDiffView}));function fe(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function pe(e){let t=(0,A.c)(38),{burst:n,docName:r,fetchBurstDiff:i}=e,[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(null),[u,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(N),_,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{let e=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval(e)},v=[],t[0]=_,t[1]=v):(_=t[0],v=t[1]),(0,j.useEffect)(_,v);let y;t[2]!==n.stackIndex||t[3]!==c||t[4]!==r||t[5]!==o||t[6]!==i||t[7]!==p?(y=()=>{let e=!o;s(e),e&&c===null&&!p&&(m(!0),f(null),i(r,n.stackIndex).then(e=>{l(e),m(!1)}).catch(e=>{f(e instanceof Error?e.message:String(e)),m(!1)}))},t[2]=n.stackIndex,t[3]=c,t[4]=r,t[5]=o,t[6]=i,t[7]=p,t[8]=y):y=t[8];let b=y,x=`${o?`Collapse`:`Expand`} burst ${n.stackIndex+1} diff`,S;t[9]===o?S=t[10]:(S=o?(0,M.jsx)(a,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,M.jsx)(d,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[9]=o,t[10]=S);let C;t[11]!==n.ts||t[12]!==h?(C=fe(n.ts,h),t[11]=n.ts,t[12]=h,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,M.jsx)(`span`,{className:`font-mono`,children:C}),t[14]=C,t[15]=w);let T;t[16]===n.additions?T=t[17]:(T=(0,M.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[16]=n.additions,t[17]=T);let E;t[18]===n.deletions?E=t[19]:(E=(0,M.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[18]=n.deletions,t[19]=E);let D;t[20]!==T||t[21]!==E?(D=(0,M.jsxs)(`span`,{className:`ml-auto font-mono`,children:[T,` `,E]}),t[20]=T,t[21]=E,t[22]=D):D=t[22];let O;t[23]!==o||t[24]!==D||t[25]!==x||t[26]!==S||t[27]!==w||t[28]!==b?(O=(0,M.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground hover:bg-muted/40`,"aria-expanded":o,"aria-label":x,children:[S,w,D]}),t[23]=o,t[24]=D,t[25]=x,t[26]=S,t[27]=w,t[28]=b,t[29]=O):O=t[29];let k;t[30]!==c||t[31]!==o||t[32]!==u||t[33]!==p?(k=o?(0,M.jsx)(`div`,{className:`bg-muted/20`,children:p?(0,M.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff…`}):u?(0,M.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,u]}):c===null?(0,M.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`No diff.`}):(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff…`}),children:(0,M.jsx)(de,{diff:c})})}):null,t[30]=c,t[31]=o,t[32]=u,t[33]=p,t[34]=k):k=t[34];let ee;return t[35]!==O||t[36]!==k?(ee=(0,M.jsxs)(`div`,{className:`border-t border-border/50`,children:[O,k]}),t[35]=O,t[36]=k,t[37]=ee):ee=t[37],ee}function N(){return Date.now()}function me(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function P(e){let t=(0,A.c)(93),{file:n,sessionAlive:r,isWriting:i,onNavigate:o,onUndoLast:s,onUndoAll:c,fetchBurstDiff:l}=e,[u,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(!1),[y,b]=(0,j.useState)(ge),x,S;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=setInterval(()=>b(Date.now()),3e4);return()=>clearInterval(e)},S=[],t[0]=x,t[1]=S):(x=t[0],S=t[1]),(0,j.useEffect)(x,S),n.bursts.length===0)return null;let C=!r||n.bursts.length===0||h,ie=r?n.bursts.length===0?`Nothing to undo on this file`:null:`Session ended — undo unavailable`,ae;t[2]!==C||t[3]!==n.docName||t[4]!==s?(ae=e=>{e.stopPropagation(),!C&&(g(!0),Promise.resolve(s(n.docName)).finally(()=>g(!1)))},t[2]=C,t[3]=n.docName,t[4]=s,t[5]=ae):ae=t[5];let oe=ae,se;t[6]===C?se=t[7]:(se=e=>{e.stopPropagation(),!C&&m(!0)},t[6]=C,t[7]=se);let ce=se,le;t[8]!==C||t[9]!==n.docName||t[10]!==c?(le=()=>{m(!1),!C&&(g(!0),Promise.resolve(c(n.docName)).finally(()=>g(!1)))},t[8]=C,t[9]=n.docName,t[10]=c,t[11]=le):le=t[11];let ue=le,de;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>f(he),t[12]=de):de=t[12];let fe=u?`Collapse ${n.docName}`:`Expand ${n.docName}`,N;t[13]===u?N=t[14]:(N=u?(0,M.jsx)(a,{className:`size-4`,"aria-hidden":`true`}):(0,M.jsx)(d,{className:`size-4`,"aria-hidden":`true`}),t[13]=u,t[14]=N);let P;t[15]!==u||t[16]!==fe||t[17]!==N?(P=(0,M.jsx)(`button`,{type:`button`,onClick:de,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":u,"aria-label":fe,"data-testid":`activity-panel-file-row-carrot`,children:N}),t[15]=u,t[16]=fe,t[17]=N,t[18]=P):P=t[18];let F;t[19]!==n.docName||t[20]!==o?(F=()=>o(n.docName),t[19]=n.docName,t[20]=o,t[21]=F):F=t[21];let _e=`Navigate to ${n.docName}`,I;t[22]!==n.docName||t[23]!==F||t[24]!==_e?(I=(0,M.jsx)(`button`,{type:`button`,onClick:F,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":_e,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[22]=n.docName,t[23]=F,t[24]=_e,t[25]=I):I=t[25];let ve=`Undo last edit on ${n.docName}`,ye;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,M.jsx)(v,{className:`size-3.5`,"aria-hidden":`true`}),t[26]=ye):ye=t[26];let L;t[27]!==C||t[28]!==oe||t[29]!==ve?(L=(0,M.jsx)(w,{asChild:!0,children:(0,M.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:oe,disabled:C,"aria-label":ve,"data-testid":`activity-panel-undo-last`,children:ye})}),t[27]=C,t[28]=oe,t[29]=ve,t[30]=L):L=t[30];let be=ie??`Undo last edit`,R;t[31]===be?R=t[32]:(R=(0,M.jsx)(T,{side:`bottom`,children:be}),t[31]=be,t[32]=R);let z;t[33]!==L||t[34]!==R?(z=(0,M.jsxs)(E,{children:[L,R]}),t[33]=L,t[34]=R,t[35]=z):z=t[35];let xe=`Undo all edits on ${n.docName}`,Se;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,M.jsx)(re,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=Se):Se=t[36];let B;t[37]!==C||t[38]!==ce||t[39]!==xe?(B=(0,M.jsx)(w,{asChild:!0,children:(0,M.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ce,disabled:C,"aria-label":xe,"data-testid":`activity-panel-undo-all`,children:Se})}),t[37]=C,t[38]=ce,t[39]=xe,t[40]=B):B=t[40];let Ce=ie??`Undo all edits`,V;t[41]===Ce?V=t[42]:(V=(0,M.jsx)(T,{side:`bottom`,children:Ce}),t[41]=Ce,t[42]=V);let H;t[43]!==B||t[44]!==V?(H=(0,M.jsxs)(E,{children:[B,V]}),t[43]=B,t[44]=V,t[45]=H):H=t[45];let U;t[46]===n.additionsTotal?U=t[47]:(U=(0,M.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[46]=n.additionsTotal,t[47]=U);let W;t[48]===n.deletionsTotal?W=t[49]:(W=(0,M.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[48]=n.deletionsTotal,t[49]=W);let G;t[50]!==U||t[51]!==W?(G=(0,M.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[U,` `,W]}),t[50]=U,t[51]=W,t[52]=G):G=t[52];let K;t[53]!==n.lastTs||t[54]!==y?(K=me(n.lastTs,y),t[53]=n.lastTs,t[54]=y,t[55]=K):K=t[55];let q;t[56]===K?q=t[57]:(q=(0,M.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:K}),t[56]=K,t[57]=q);let J;t[58]===i?J=t[59]:(J=i?(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:`writing…`}):null,t[58]=i,t[59]=J);let Y;t[60]!==I||t[61]!==z||t[62]!==H||t[63]!==G||t[64]!==q||t[65]!==J||t[66]!==P?(Y=(0,M.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[P,I,z,H,G,q,J]}),t[60]=I,t[61]=z,t[62]=H,t[63]=G,t[64]=q,t[65]=J,t[66]=P,t[67]=Y):Y=t[67];let X;t[68]!==u||t[69]!==l||t[70]!==n.bursts||t[71]!==n.docName?(X=u?(0,M.jsx)(`div`,{children:n.bursts.map(e=>(0,M.jsx)(pe,{burst:e,docName:n.docName,fetchBurstDiff:l},`${n.docName}:${e.stackIndex}`))}):null,t[68]=u,t[69]=l,t[70]=n.bursts,t[71]=n.docName,t[72]=X):X=t[72];let we;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,M.jsx)(O,{children:`Undo all edits on this file?`}),t[73]=we):we=t[73];let Z;t[74]===n.docName?Z=t[75]:(Z=(0,M.jsx)(`span`,{className:`font-mono text-foreground`,children:n.docName}),t[74]=n.docName,t[75]=Z);let Te=n.bursts.length===1?``:`s`,Q;t[76]!==n.bursts.length||t[77]!==Z||t[78]!==Te?(Q=(0,M.jsxs)(te,{children:[we,(0,M.jsxs)(D,{children:[`This will revert every change this agent has made to`,` `,Z,` in their current session (`,n.bursts.length,` burst`,Te,`). Other files and other writers are not affected.`]})]}),t[76]=n.bursts.length,t[77]=Z,t[78]=Te,t[79]=Q):Q=t[79];let Ee;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,M.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>m(!1),"data-testid":`activity-panel-undo-all-cancel`,children:`Cancel`}),t[80]=Ee):Ee=t[80];let $;t[81]===ue?$=t[82]:($=(0,M.jsxs)(ee,{children:[Ee,(0,M.jsx)(_,{type:`button`,variant:`destructive`,onClick:ue,"data-testid":`activity-panel-undo-all-confirm`,children:`Undo all`})]}),t[81]=ue,t[82]=$);let De;t[83]!==Q||t[84]!==$?(De=(0,M.jsxs)(k,{className:`sm:max-w-md`,children:[Q,$]}),t[83]=Q,t[84]=$,t[85]=De):De=t[85];let Oe;t[86]!==p||t[87]!==De?(Oe=(0,M.jsx)(ne,{open:p,onOpenChange:m,children:De}),t[86]=p,t[87]=De,t[88]=Oe):Oe=t[88];let ke;return t[89]!==Y||t[90]!==X||t[91]!==Oe?(ke=(0,M.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[Y,X,Oe]}),t[89]=Y,t[90]=X,t[91]=Oe,t[92]=ke):ke=t[92],ke}function he(e){return!e}function ge(){return Date.now()}async function F(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 _e(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function I(e){typeof window>`u`||(window.location.hash=_e(e))}function ve(){let e=(0,A.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[(0,M.jsx)(l,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`text-sm`,children:`Loading agent activity…`})]}),e[0]=t):t=e[0],t}function ye(e){let t=(0,A.c)(9),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,M.jsx)(o,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=a):a=t[1];let s;t[2]===n?s=t[3]:(s=(0,M.jsxs)(`div`,{className:`space-y-1`,children:[a,(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=(0,M.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=c);let l;return t[6]!==s||t[7]!==c?(l=(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8],l}function L(){let e=(0,A.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,M.jsx)(`p`,{className:`text-sm italic`,children:`No edits yet.`})}),e[0]=t):t=e[0],t}function be(e){let t=(0,A.c)(8),{onExit:n}=e,r;t[0]===n?r=t[1]:(r=(0,M.jsx)(R,{onClick:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,M.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`}),t[2]=i):i=t[2];let a;t[3]===r?a=t[4]:(a=(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[r,i]}),t[3]=r,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,M.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,M.jsx)(`p`,{className:`text-center text-sm italic`,children:`Click an agent's avatar in the presence bar to view their session.`})}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,M.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":`Agent activity`,children:[a,o]}),t[6]=a,t[7]=s),s}function R(e){let t=(0,A.c)(6),{onClick:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,M.jsx)(b,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,M.jsx)(w,{asChild:!0,children:(0,M.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":`Back to document view`,"data-testid":`docpanel-exit-agent-mode`,children:r})}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,M.jsx)(T,{side:`bottom`,children:`Back to document view`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,M.jsxs)(E,{children:[i,a]}),t[4]=i,t[5]=o),o}function z(e){let t=(0,A.c)(9),{lastTs:n}=e,[r]=(0,j.useState)(xe),i;t[0]!==n||t[1]!==r?(i=n?Se(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,M.jsx)(`span`,{className:`font-medium`,children:`Session ended`}),t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=a?(0,M.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,M.jsx)(`div`,{className:`mt-1 opacity-80`,children:`Undo buttons are disabled — per-session state has been garbage-collected.`}),t[6]=c):c=t[6];let l;return t[7]===s?l=t[8]:(l=(0,M.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:[o,s,c]}),t[7]=s,t[8]=l),l}function xe(){return Date.now()}function Se(e){let t=Math.max(0,e);return t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:`${Math.round(t/36e5)}h ago`}function B(e){let t=(0,A.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,M.jsx)(x,{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,M.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 Ce(e){let t=(0,A.c)(20),{data:n,status:r,error:i,reload:a,fetchBurstDiff:o,onExit:s,onNavigate:c,onUndoLast:l,onUndoAll:u}=e,d=n?.files?.[0]?.lastTs??null,f;t[0]===s?f=t[1]:(f=(0,M.jsx)(R,{onClick:s}),t[0]=s,t[1]=f);let p;t[2]===n?p=t[3]:(p=n?.agent?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(B,{agent:n.agent}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,M.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?`Active`:`Ended`,n.files.length>0?` · ${n.files.length} file${n.files.length===1?``:`s`}`:``]})]})]}):(0,M.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,M.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`})}),t[2]=n,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,M.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]!==n||t[8]!==i||t[9]!==o||t[10]!==d||t[11]!==c||t[12]!==u||t[13]!==l||t[14]!==a||t[15]!==r?(h=(0,M.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,M.jsx)(ve,{}):r===`error`&&i?(0,M.jsx)(ye,{error:i,onRetry:a}):n===null?(0,M.jsx)(L,{}):(0,M.jsxs)(M.Fragment,{children:[n.sessionAlive?null:(0,M.jsx)(z,{lastTs:d}),n.files.length===0?(0,M.jsx)(L,{}):n.files.map(e=>(0,M.jsx)(P,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:l,onUndoAll:u,fetchBurstDiff:o},e.docName))]})}),t[7]=n,t[8]=i,t[9]=o,t[10]=d,t[11]=c,t[12]=u,t[13]=l,t[14]=a,t[15]=r,t[16]=h):h=t[16];let g;return t[17]!==m||t[18]!==h?(g=(0,M.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":`Agent activity`,children:[m,h]}),t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function V(){let e=(0,A.c)(22),{docPanelAgentId:t,closeActivityPanel:n}=s(),{openDocumentTransition:r}=u(),{data:i,status:a,error:o,reload:c,fetchBurstDiff:l}=ce(t);if(t===null){let t;return e[0]===n?t=e[1]:(t=(0,M.jsx)(be,{onExit:n}),e[0]=n,e[1]=t),t}let d;e[2]===r?d=e[3]:(d=e=>{r(e),I(e)},e[2]=r,e[3]=d);let f=d,p;e[4]!==i||e[5]!==t||e[6]!==c?(p=async e=>{try{await F({connectionId:t,docName:e,scope:`last`,agentName:i?.agent?.displayName}),c()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);C.error(`Undo failed: ${n}`),c()}},e[4]=i,e[5]=t,e[6]=c,e[7]=p):p=e[7];let m=p,h;e[8]!==i||e[9]!==t||e[10]!==c?(h=async e=>{try{await F({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),C.success(`Undone all edits on ${e}`),c()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);C.error(`Undo all failed: ${n}`),c()}},e[8]=i,e[9]=t,e[10]=c,e[11]=h):h=e[11];let g=h,_;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==f||e[17]!==g||e[18]!==m||e[19]!==c||e[20]!==a?(_=(0,M.jsx)(Ce,{data:i,status:a,error:o,reload:c,fetchBurstDiff:l,onExit:n,onNavigate:f,onUndoLast:m,onUndoAll:g}),e[12]=n,e[13]=i,e[14]=o,e[15]=l,e[16]=f,e[17]=g,e[18]=m,e[19]=c,e[20]=a,e[21]=_):_=e[21],_}export{V as ActivityModeContent};