@inkeep/open-knowledge 0.53.0 → 0.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{acp-harness-probe-B5_ar7rl.mjs → acp-harness-probe-CwhklR1t.mjs} +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/constants-ggtyHegG.mjs +2 -0
- package/dist/index.mjs +173 -173
- package/dist/{init-BGPdBpY7.mjs → init-DryQvpzo.mjs} +3 -3
- package/dist/init-DzEphcZj.mjs +1 -0
- package/dist/{launch-json-removal-BYbu5C86.mjs → launch-json-removal-C04K7xd0.mjs} +2 -2
- package/dist/{loader-ejjX_n1a.mjs → loader-DAyo63Sq.mjs} +2 -2
- package/dist/loader-tHonavs_.mjs +1 -0
- package/dist/{open-browser-CtVpc_8x.mjs → open-browser-DF0vEOcg.mjs} +2 -2
- package/dist/preview-CbOTxxpX.mjs +1 -0
- package/dist/{preview-R6iAeACo.mjs → preview-Dvl3K5Z6.mjs} +2 -2
- package/dist/{repair-launch-json-D4L6s57C.mjs → repair-launch-json-CMlO4J6-.mjs} +2 -2
- package/dist/{repair-mcp-configs-1m14wb_8.mjs → repair-mcp-configs-C5d_qH2p.mjs} +2 -2
- package/dist/repair-skills-Bjx_4xAb.mjs +1 -0
- package/dist/{repair-skills-Dn9wtbHi.mjs → repair-skills-hlHv35hU.mjs} +2 -2
- package/dist/{skill-teardown-riJHlPak.mjs → skill-teardown-BCQ-qH0I.mjs} +2 -2
- package/dist/{src-ISYL0cXX.mjs → src-BZC89n0v.mjs} +2 -2
- package/dist/{src-BVxZYLJj.mjs → src-Bev_iKqg.mjs} +383 -383
- package/dist/{src-CeMQBLDa.mjs → src-C3V2v4Fb.mjs} +1 -1
- package/dist/src-DChs1wj2.mjs +1 -0
- package/dist/{start-DqsRiUST.mjs → start-B8fRTezu.mjs} +4 -4
- package/dist/start-CZ-kN2jU.mjs +1 -0
- package/dist/{ui-CyO6JCpp.mjs → ui-CXX6eedF.mjs} +3 -3
- package/dist/{write-project-skill-Bx22NW0a.mjs → write-project-skill-CTfu6uzb.mjs} +2 -2
- package/package.json +5 -5
- package/dist/constants-BGKDDuS6.mjs +0 -2
- package/dist/init-CJLXPIkG.mjs +0 -1
- package/dist/loader-gRh8KR8b.mjs +0 -1
- package/dist/preview-Ddz36Ink.mjs +0 -1
- package/dist/repair-skills-cJ41S9pk.mjs +0 -1
- package/dist/src-CclRwMug.mjs +0 -1
- package/dist/start-8PynebPz.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{ft as r}from"./sleep-A0G7hOuG.mjs";import{Ro as i,W as a,os as o,q as s,xs as c}from"./src-RGB2pEts.mjs";import{Br as l,Cr as u,Ea as d,Ir as f,Lr as p,Pn as m,Rr as h,Sn as g,Zr as _,an as v,ar as y,bn as b,c as x,hr as S,in as C,ir as ee,l as te,or as ne,pr as re,u as ie,wr as ae,yn as oe}from"./src-BVxZYLJj.mjs";import{F as w,N as se}from"./fs-traced-DV9uD41t.mjs";import{_ as ce,a as le,b as T,c as E,d as ue,i as de,l as fe,o as D,r as pe,t as me,u as he,v as ge}from"./write-project-skill-Bx22NW0a.mjs";import{i as O,n as k,o as A,r as j,s as M,t as N}from"./colors-BsmVIwfM.mjs";import{t as _e}from"./constants-BGKDDuS6.mjs";import{t as P}from"./is-object-ByG7RnjH.mjs";import{t as ve}from"./preview-R6iAeACo.mjs";import{createRequire as ye}from"node:module";import{execFileSync as be}from"node:child_process";import xe,{dirname as F,isAbsolute as I,join as L,relative as R,resolve as Se,sep as Ce}from"node:path";import z from"node:process";import{fileURLToPath as we}from"node:url";import{existsSync as B,lstatSync as Te,mkdirSync as Ee,readFileSync as V,readlinkSync as De,realpathSync as Oe,statSync as ke,writeFileSync as Ae}from"node:fs";import{homedir as je}from"node:os";import*as Me from"node:readline";import{inspect as Ne,stripVTControlCharacters as Pe,styleText as H}from"node:util";import{AsyncLocalStorage as Fe,AsyncResource as Ie}from"node:async_hooks";const Le=new Set([`emacs`,`vim`]);function Re(e){return Le.has(e)}function ze(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Re))):[]}const U=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Be=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Ve=e=>e.name===`space`,He=e=>e.name===`backspace`,Ue=e=>`1234567890`.includes(e.name),We=e=>e.name===`enter`||e.name===`return`;var Ge=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Ke=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},qe=class extends Error{name=`ExitPromptError`},Je=class extends Error{name=`HookError`},Ye=class extends Error{name=`ValidationError`};const Xe=new Fe;function Ze(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Qe(e,t){let n=Ze(e);return Xe.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function W(){let e=Xe.getStore();if(!e)throw new Je(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function $e(){return W().rl}function et(e){return Ie.bind((...t)=>{let n=W(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function tt(e){let t=W(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function nt(){W().handleChange()}const rt={queue(e){let t=W(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e($e());if(r!=null&&typeof r!=`function`)throw new Ye(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=W();et(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=W();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function it(e){return typeof e==`function`}function G(e){return tt(t=>{let n=Ie.bind(function(e){t.get()!==e&&(t.set(e),nt())});if(t.initialized)return[t.get(),n];let r=it(e)?e():e;return t.set(r),[r,n]})}function at(e,t){tt(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&rt.queue(e),n.set(t)})}function ot(){return z.platform.startsWith(`win`)?!!z.env.CI||!!z.env.WT_SESSION||!!z.env.TERMINUS_SUBLIME||z.env.ConEmuTask===`{cmd::Cmder}`||z.env.TERM_PROGRAM===`Terminus-Sublime`||z.env.TERM_PROGRAM===`vscode`||z.env.TERM===`xterm-256color`||z.env.TERM===`alacritty`||z.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:z.env.TERM!==`linux`}const st={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:`╱`},ct={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:`⅒`},lt={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`},ut={...st,...ct},dt={...st,...lt},K=ot()?ut:dt;Object.entries(ct);const ft={prefix:{idle:H(`blue`,`?`),done:H(`green`,K.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>H(`yellow`,e))},keybindings:[],style:{answer:e=>H(`cyan`,e),message:e=>H(`bold`,e),error:e=>H(`red`,`> ${e}`),defaultAnswer:e=>H(`dim`,`(${e})`),help:e=>H(`dim`,e),highlight:e=>H(`cyan`,e),key:e=>H(`cyan`,H(`bold`,`<${e}>`))}};function pt(){return{...ft,keybindings:ze()}}function mt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ht(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mt(n)&&mt(r)?ht(n,r):r}return t}function gt(...e){return ht(pt(),...e.filter(e=>e!=null))}function _t({status:e=`idle`,theme:t}){let[n,r]=G(!1),[i,a]=G(0),{prefix:o,spinner:s}=gt(t);return at(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function vt(e,t){return tt(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function yt(e){return G({current:e})[0]}function bt(e){let t=yt(e);t.current=e,at(e=>{let n=!1,r=et((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var xt=t(n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}))(),1);const St=(()=>{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}})(),Ct=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,wt=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,Tt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Et=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Dt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Ot=/\t{1,1000}/y,kt=/[\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,At=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,jt=/\p{M}+/gu,Mt={limit:1/0,ellipsis:``},Nt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Nt(i,Mt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[At,l],[Tt,0],[Et,o],[Ot,s],[kt,c],[Dt,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(jt,``)){let t=e.codePointAt(0)||0;if(S=Ct(t)?2:wt(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===Dt?St(e.slice(p,n.lastIndex)):n===kt?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}},Pt={limit:1/0,ellipsis:``,ellipsisWidth:0},q=(e,t={})=>Nt(e,Pt,t).width,Ft=`]8;;`,It=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ft}(?<uri>.*))`,`y`),Lt=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},Rt=e=>`[${e}m`,zt=e=>`${Ft}${e}`,Bt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:q(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=q(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(Ft,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())},Vt=e=>{let t=e.split(` `),n=t.length;for(;n&&!q(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ht=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=q(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=q(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Bt(s,r,t),c=q(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Bt(s,r,t),c=q(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Bt(s,r,t),c=q(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Vt(e)));let l=s.join(`
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{ft as r}from"./sleep-A0G7hOuG.mjs";import{Ro as i,W as a,os as o,q as s,xs as c}from"./src-RGB2pEts.mjs";import{Br as l,Cr as u,Ea as d,Ir as f,Lr as p,Pn as m,Rr as h,Sn as g,Zr as _,an as v,ar as y,bn as b,c as x,hr as S,in as C,ir as ee,l as te,or as ne,pr as re,u as ie,wr as ae,yn as oe}from"./src-Bev_iKqg.mjs";import{F as w,N as se}from"./fs-traced-DV9uD41t.mjs";import{_ as ce,a as le,b as T,c as E,d as ue,i as de,l as fe,o as D,r as pe,t as me,u as he,v as ge}from"./write-project-skill-CTfu6uzb.mjs";import{i as O,n as k,o as A,r as j,s as M,t as N}from"./colors-BsmVIwfM.mjs";import{t as _e}from"./constants-ggtyHegG.mjs";import{t as P}from"./is-object-ByG7RnjH.mjs";import{t as ve}from"./preview-Dvl3K5Z6.mjs";import{createRequire as ye}from"node:module";import{execFileSync as be}from"node:child_process";import xe,{dirname as F,isAbsolute as I,join as L,relative as R,resolve as Se,sep as Ce}from"node:path";import z from"node:process";import{fileURLToPath as we}from"node:url";import{existsSync as B,lstatSync as Te,mkdirSync as Ee,readFileSync as V,readlinkSync as De,realpathSync as Oe,statSync as ke,writeFileSync as Ae}from"node:fs";import{homedir as je}from"node:os";import*as Me from"node:readline";import{inspect as Ne,stripVTControlCharacters as Pe,styleText as H}from"node:util";import{AsyncLocalStorage as Fe,AsyncResource as Ie}from"node:async_hooks";const Le=new Set([`emacs`,`vim`]);function Re(e){return Le.has(e)}function ze(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Re))):[]}const U=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Be=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Ve=e=>e.name===`space`,He=e=>e.name===`backspace`,Ue=e=>`1234567890`.includes(e.name),We=e=>e.name===`enter`||e.name===`return`;var Ge=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Ke=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},qe=class extends Error{name=`ExitPromptError`},Je=class extends Error{name=`HookError`},Ye=class extends Error{name=`ValidationError`};const Xe=new Fe;function Ze(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Qe(e,t){let n=Ze(e);return Xe.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function W(){let e=Xe.getStore();if(!e)throw new Je(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function $e(){return W().rl}function et(e){return Ie.bind((...t)=>{let n=W(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function tt(e){let t=W(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function nt(){W().handleChange()}const rt={queue(e){let t=W(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e($e());if(r!=null&&typeof r!=`function`)throw new Ye(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=W();et(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=W();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function it(e){return typeof e==`function`}function G(e){return tt(t=>{let n=Ie.bind(function(e){t.get()!==e&&(t.set(e),nt())});if(t.initialized)return[t.get(),n];let r=it(e)?e():e;return t.set(r),[r,n]})}function at(e,t){tt(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&rt.queue(e),n.set(t)})}function ot(){return z.platform.startsWith(`win`)?!!z.env.CI||!!z.env.WT_SESSION||!!z.env.TERMINUS_SUBLIME||z.env.ConEmuTask===`{cmd::Cmder}`||z.env.TERM_PROGRAM===`Terminus-Sublime`||z.env.TERM_PROGRAM===`vscode`||z.env.TERM===`xterm-256color`||z.env.TERM===`alacritty`||z.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:z.env.TERM!==`linux`}const st={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:`╱`},ct={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:`⅒`},lt={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`},ut={...st,...ct},dt={...st,...lt},K=ot()?ut:dt;Object.entries(ct);const ft={prefix:{idle:H(`blue`,`?`),done:H(`green`,K.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>H(`yellow`,e))},keybindings:[],style:{answer:e=>H(`cyan`,e),message:e=>H(`bold`,e),error:e=>H(`red`,`> ${e}`),defaultAnswer:e=>H(`dim`,`(${e})`),help:e=>H(`dim`,e),highlight:e=>H(`cyan`,e),key:e=>H(`cyan`,H(`bold`,`<${e}>`))}};function pt(){return{...ft,keybindings:ze()}}function mt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ht(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mt(n)&&mt(r)?ht(n,r):r}return t}function gt(...e){return ht(pt(),...e.filter(e=>e!=null))}function _t({status:e=`idle`,theme:t}){let[n,r]=G(!1),[i,a]=G(0),{prefix:o,spinner:s}=gt(t);return at(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function vt(e,t){return tt(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function yt(e){return G({current:e})[0]}function bt(e){let t=yt(e);t.current=e,at(e=>{let n=!1,r=et((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var xt=t(n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}))(),1);const St=(()=>{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}})(),Ct=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,wt=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,Tt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Et=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Dt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Ot=/\t{1,1000}/y,kt=/[\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,At=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,jt=/\p{M}+/gu,Mt={limit:1/0,ellipsis:``},Nt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Nt(i,Mt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[At,l],[Tt,0],[Et,o],[Ot,s],[kt,c],[Dt,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(jt,``)){let t=e.codePointAt(0)||0;if(S=Ct(t)?2:wt(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===Dt?St(e.slice(p,n.lastIndex)):n===kt?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}},Pt={limit:1/0,ellipsis:``,ellipsisWidth:0},q=(e,t={})=>Nt(e,Pt,t).width,Ft=`]8;;`,It=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ft}(?<uri>.*))`,`y`),Lt=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},Rt=e=>`[${e}m`,zt=e=>`${Ft}${e}`,Bt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:q(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=q(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(Ft,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())},Vt=e=>{let t=e.split(` `),n=t.length;for(;n&&!q(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ht=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=q(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=q(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Bt(s,r,t),c=q(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Bt(s,r,t),c=q(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Bt(s,r,t),c=q(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Vt(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===``){It.lastIndex=e+1;let t=It.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+=zt(``));let e=i?Lt(i):void 0;i&&e&&(r+=Rt(e))}else t===`
|
|
4
4
|
`&&(i&&Lt(i)&&(r+=Rt(i)),a&&(r+=zt(a)))}return r},Ut=/\r?\n/;function Wt(e,t,n){return String(e).normalize().split(Ut).map(e=>Ht(e,t,n)).join(`
|
|
@@ -633,6 +633,6 @@ export default function okBridge(pi: {
|
|
|
633
633
|
`));let f=`${a?``:``}${u}`;return f!==i&&w(e,f,{mode:Hn(e)}),{kind:l?`overwritten`:`written`}}const bi=e=>e!==`project`,xi=e=>e!==`user`;async function Si(){let e=await Zn({message:`Where should the MCP server be configured?
|
|
634
634
|
`,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Ci(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Si)():`both`}async function wi(e){return nr({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json, project skills)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function Ti(e){if(e.sharing!==void 0)return e.sharing;let t=kn(e.projectRoot)===`local-only`?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??wi)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Ei(e){if(e===void 0||e===!0)return new Set(ae);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(ae.filter(e=>t.includes(e)))}function Di(e,t,n){let r=Se(n,e),i;try{i=ke(r)}catch(e){let t=e.code;throw t===`ENOENT`?new $(`--content-dir path does not exist: ${r}`):new $(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new $(`--content-dir must be a directory: ${r}`);let a=R(Oi(t),Oi(r));if(a.startsWith(`..`)||I(a))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return a===``?`.`:a}function Oi(e){try{return Oe(e)}catch{return e}}const ki=`open-knowledge-ui`;function Ai(e,t,n){try{return B(e.detectPath?.(t,n)??F(e.configPath(t,n)))}catch{return!1}}function ji(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0;if(!i&&s&&!Ai(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{me(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return Ni(e,o,a,n,{isProjectScope:i!==void 0});let c;try{c=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{Ee(F(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let l={action:`written`},u;try{se(`${o}.lock`,()=>{let t=Yr(o).writePath;if(Ee(F(t),{recursive:!0}),e.format===`toml`){let n=vi(ri(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=yi(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=_i(t,e.topLevelKey,a,c,e.serverMapSubKey);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){u=e instanceof Error?e:Error(String(e))}return u?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:u.message,...i===void 0?{}:{configScope:`project`}}:l.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:l.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:l.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Mi={pi:Lr};function Ni(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Mi[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{Ee(F(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{se(`${t}.lock`,()=>{let e=null;try{e=V(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}w(t,c,e===null?void 0:{mode:Hn(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function Pi(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!B(n)))return{editorId:e.id,label:e.label,path:n}}function Fi(e,t,n,r){let i=Li(e,t,n,r);return i.kind===`present`?i.entry:null}function Ii(e,t,n,r){let i=gi(e,t,r);if(!P(i))return{kind:`no-entry`};let a=i[n];return P(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Li(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!B(i))return{kind:`absent`};try{if(ke(i).size>di)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=V(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Ir(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ri().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Ii(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Cn.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Ii(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=oi(a);return s?si(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Ii(p(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ri(e={}){let t=Se(e.cwd??process.cwd()),n=Vr(t,{homeDir:e.home}),r=n.projectRoot,a=!B(L(r,`.ok`)),o=n.gitRootPromoted?R(r,t):void 0,s=e.contentDir===void 0?n.defaultContentDir:Di(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&a&&s===`.`&&process.stderr.write(`${M(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${o}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${o} in .ok/config.yml.\n`);let c={mode:e.devMcp?`dev`:`published`},l=await ie(r),d;try{d=b(r,{contentDir:s})}catch(t){let i=D.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let f=d.created.includes(_e),p=!1;if(l.didInit)try{p=g(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{oe(r)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore entry at ${r}: ${e instanceof Error?e.message:String(e)}`)}let m=await x(r);m.kind===`untracked`&&console.warn(`[ok] Untracked the OpenKnowledge project skill (${m.dirs.join(`, `)}) — it is now local-only. Teammates will see this as a deletion on their next pull.`);let h=await Ci({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),_=e.editors??Wi(r,e.home),v=e.editors??de.filter(e=>D[e].projectConfigPath!==void 0||D[e].projectSkillPath!==void 0),C=ce(_),te=ce(v),w=e.mcp===!1||h===null,se=Array.from(new Map([...C,...w?[]:te].map(e=>[e.id,e])).values()),le=C.filter(t=>Ai(t,r,e.home)),T=[],E=[],ue=new Set;for(let t of se){if(w){let n=``;try{n=t.configPath(r,e.home)}catch{}T.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(bi(h)&&C.includes(t)&&t.scope===`global`&&T.push(ji(t,r,c,e.home)),xi(h)&&te.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=ji(t,r,c,e.home,n);T.push(i),(i.action===`written`||i.action===`overwritten`)&&ue.add(n)}}let fe=new Set;for(let t of te){let n=t.projectSkillPath?.(r);!n||fe.has(n)||(fe.add(n),E.push(pe(t,r,{home:e.home})))}let me=E.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(me.length>0){let t=e.home??je();ne({source:i,skills:[u.project],agents:me,scope:r},{home:t,enabled:S(t).enabled})}let he=!w&&h!==null&&xi(h)?te.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ge=w?[]:le.map(e=>Pi(e,r)).filter(e=>e!==void 0).filter(e=>!ue.has(e.path)),O=e.installUserSkill??y,k=e.home??je(),A=Ei(e.skills),j=!1,N=!1,P=!1,ve=!1,ye=!1;for(let t of ae){if(!A.has(t))continue;await re(k,u[t],!0).catch(()=>{}),j=!0;let n=await O({home:e.home,bundleId:t,force:!0});n===`installed`?N=!0:n===`failed`?P=!0:n===`no-hosts`?ye=!0:ve=!0}let be=P?`failed`:N?`installed`:j&&ve?`skip-current`:j&&ye?`no-hosts`:`declined`,xe=N?ee(k).map(e=>e.editorId):[],F=w?`skipped-flag`:`skipped-missing`,I=T.find(e=>e.editorId===`claude`)??T[0]??{action:F,configPath:D.claude.configPath(r,e.home)},Ce=await zi({projectRoot:r,desiredMode:await Ti({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:d.created,contentUpdated:d.updated,contentSkipped:d.skipped,editors:T,projectSkills:E,legacyProjectConfigs:ge,skillInstall:be,skillHosts:xe,didGitInit:l.didInit,rootGitignoreCreated:p,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDir:f?s:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:I.action,mcpPath:I.configPath,mcpError:`error`in I?I.error:void 0,projectScopeUnsupportedLabels:he,sharing:Ce}}async function zi(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=kn(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=En(t);if(n===`local-only`){let e=Dn(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:Bi(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=On(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Bi(t,o,`remove`)}function Bi(e,t,n){let r=kn(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:[]}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function Vi(e){switch(e){case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;default:return`config not readable`}}function Hi(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let s=L(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(N(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(N(`Content already present at ${s}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(N(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(N(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(N(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?R(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`open-knowledge`?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${A(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${A(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${j(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Vi(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(N(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?R(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${A(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${A(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${j(`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} ${R(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(N(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>le[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${A(`installed for ${r}`)}`),n.push(` ${k(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${k(`Opt out: DO_NOT_TRACK=1, or Settings → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${A(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${k(`skipped for this run (--no-skills)`)}`),n.push(` ${k(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${k(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${k(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${k(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${M(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${M(` ok repair-skills`)}`);break}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(M(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(M(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(ve(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...qi(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${A(`✓`)} ${N(`Next steps:`)}`),n.push(` 1. Open your editor (${O(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${O(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${O(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
|
|
635
635
|
`)}function Ui(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function Wi(e,t){let n=[];for(let r of de)Ai(D[r],e,t)&&n.push(r);return n}function Gi(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Ne(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Ki(){return new ge(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new T(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new T(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new T(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?Gi():null;try{let r;try{r=await Ri({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof $){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof C||e instanceof v){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof te){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
|
|
636
|
-
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-
|
|
636
|
+
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-tHonavs_.mjs`),{resolveContentDir:s}=await import(`./src-C3V2v4Fb.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-CbOTxxpX.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Ui(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Hi(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function qi(e,t){let n=[];switch(e.kind){case`applied`:return n.push(N(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${A(`local-only`)} — appended ${e.appended.length} path(s) to ${N(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${A(`local-only`)} — already excluded; nothing to do.`):n.push(` ${A(`local-only`)}`):e.action===`removed`?n.push(` ${A(`shared`)} — removed OK paths from ${N(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${A(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(M(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
|
|
637
637
|
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${O(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(M(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${O(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${O(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(M(`Sharing mode unavailable: ${e.reason}.`));return n}}export{En as A,G as B,Zn as C,Dn as D,Un as E,Sn as F,un as I,bt as L,kn as M,jn as N,Nn as O,On as P,_t as R,nr as S,Vn as T,We as V,mi as _,Ui as a,Vr as b,Hi as c,Fi as d,Ei as f,Ri as g,Ti as h,zi as i,Mn as j,An as k,qi as l,Di as m,ki as n,Li as o,Ci as p,Mi as r,Wi as s,$ as t,Ki as u,ji as v,Hn as w,Fr as x,ri as y,gt as z};
|
|
638
|
-
//# sourceMappingURL=init-
|
|
638
|
+
//# sourceMappingURL=init-DryQvpzo.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./init-DryQvpzo.mjs";export{e as runInit};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Br as e,Lr as t}from"./src-
|
|
2
|
-
//# sourceMappingURL=launch-json-removal-
|
|
1
|
+
import{Br as e,Lr as t}from"./src-Bev_iKqg.mjs";import{F as n}from"./fs-traced-DV9uD41t.mjs";import{E as r,w as i}from"./init-DryQvpzo.mjs";import{t as a}from"./is-object-ByG7RnjH.mjs";import{join as o}from"node:path";import{existsSync as s,readFileSync as c,rmSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(f){let p=o(f,`.claude`,`launch.json`);if(!s(p))return{kind:`not-present`};let m;try{m=c(p,`utf-8`)}catch{return{kind:`declined`}}let h=[],g=e(m,h,u)??void 0;if(h.some(e=>!d(e,m))||!g||g.type!==`object`)return{kind:`declined`};let _=t(g).configurations;if(!Array.isArray(_))return{kind:`not-present`};let v=_.findIndex(e=>a(e)&&e.name===`open-knowledge-ui`);if(v===-1)return{kind:`not-present`};if(_.length===1)return l(p,{force:!0}),{kind:`removed-file`};let{text:y,changed:b}=r(m,[`configurations`,v]);return b?(n(p,y,{mode:i(p)}),{kind:`removed`}):{kind:`not-present`}}export{f as t};
|
|
2
|
+
//# sourceMappingURL=launch-json-removal-C04K7xd0.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as e,ft as t,l as n,m as r,u as i}from"./sleep-A0G7hOuG.mjs";import{Vs as a}from"./src-RGB2pEts.mjs";import{_ as o}from"./src-
|
|
2
|
-
//# sourceMappingURL=loader-
|
|
1
|
+
import{d as e,ft as t,l as n,m as r,u as i}from"./sleep-A0G7hOuG.mjs";import{Vs as a}from"./src-RGB2pEts.mjs";import{_ as o}from"./src-Bev_iKqg.mjs";import{I as s,k as c}from"./fs-traced-DV9uD41t.mjs";import{t as l}from"./constants-ggtyHegG.mjs";import{t as u}from"./is-object-ByG7RnjH.mjs";import{resolve as d}from"node:path";import{existsSync as f,readFileSync as p}from"node:fs";import{realpath as m}from"node:fs/promises";var h=t();async function g(e){let t=d(e);try{return await m(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function _(e){if(!f(e))return{value:null,path:e,source:null,doc:null};let t;try{t=p(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,h.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function v(t,n){return t.map(t=>{let r=t.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:t.message,issueCode:t.code};if(n.doc!==null&&n.source!==null){let t=e({file:n.path,source:n.source,doc:n.doc,path:r});if(t!==void 0)return{...i,source:t}}return i})}function y(e){let t=e??process.cwd(),u=[],f=[],p=[],m=c(`user`,t),h=s({absPath:m});f.push(...h.diagnostics),!h.valid&&h.sidelinedTo!==void 0&&p.push({from:m,to:h.sidelinedTo}),h.valid&&h.source!==void 0&&u.push(m);let g=e=>{let t=_(e);if(t.diagnostic!==void 0&&f.push(t.diagnostic),t.value===null)return{};let r=n({value:t.value,file:t.path,source:t.source,doc:t.doc});return f.push(...r),u.push(e),r.length>0?i(t.value):t.value},y=d(t,`.ok`,l),b=g(y),x=g(c(`project-local`,t)),S=a(h.value,b,x),C=o.safeParse(S);if(!C.success){let e=_(y),t={code:`SCHEMA_INVALID`,issues:v(C.error.issues,e)};throw Error(r(t))}return{config:C.data,sources:u,diagnostics:f,sidelined:p}}function b(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??y,r=new Map,i=new Map,a=g(e.startupCwd);return async o=>{let s=await g(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{y as n,b as t};
|
|
2
|
+
//# sourceMappingURL=loader-DAyo63Sq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-DAyo63Sq.mjs";export{e as loadConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Zr as e}from"./src-
|
|
2
|
-
//# sourceMappingURL=open-browser-
|
|
1
|
+
import{Zr as e}from"./src-Bev_iKqg.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}t(process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,process.platform===`win32`?[`/c`,`start`,``,a]:[a],e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
|
|
2
|
+
//# sourceMappingURL=open-browser-DF0vEOcg.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-Dvl3K5Z6.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Vr as e}from"./src-
|
|
1
|
+
import{Vr as e}from"./src-Bev_iKqg.mjs";import"./constants-ggtyHegG.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
|
|
2
2
|
`)}export{c as n,l as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-Dvl3K5Z6.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./launch-json-removal-
|
|
2
|
-
//# sourceMappingURL=repair-launch-json-
|
|
1
|
+
import{t as e}from"./launch-json-removal-C04K7xd0.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=e(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`||o.kind===`removed-file`;return s&&i({event:`launch-json-repair-removed`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
|
|
2
|
+
//# sourceMappingURL=repair-launch-json-CMlO4J6-.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,o as t,p as n}from"./write-project-skill-
|
|
2
|
-
//# sourceMappingURL=repair-mcp-configs-
|
|
1
|
+
import{i as e,o as t,p as n}from"./write-project-skill-CTfu6uzb.mjs";import{d as r,v as i}from"./init-DryQvpzo.mjs";import{t as a}from"./mcp-migrate-event-B1gJf6bG.mjs";import{homedir as o}from"node:os";function s(n){let r=n.logger??u,i=n.home??o(),a=[];if(n.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of e){let e=t[o],s=c(()=>e.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:e,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),e.projectConfigPath){let t=e.projectConfigPath,i=c(()=>t(n.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:e,home:void 0,cwd:n.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(e){let t={scope:e.scope,editorId:e.editorId,configPath:e.configPath},o=r(e.target,e.cwd,e.home,e.configPathOverride);if(o===null)return{...t,outcome:`no-entry`};if(n(o))return{...t,outcome:`canonical`};e.logger(a({scope:e.scope,surface:`cli-repair`,editorId:e.editorId,configPath:e.configPath,priorEntry:o}));let s=i(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(s.action===`failed`){let n=s.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:n}),{...t,outcome:`write-failed`,error:n}}return s.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:s.declineReason}),{...t,outcome:`declined`}):{...t,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
|
|
2
|
+
//# sourceMappingURL=repair-mcp-configs-C5d_qH2p.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./repair-skills-hlHv35hU.mjs";export{e as repairSkills};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as e}from"./src-RGB2pEts.mjs";import{Cr as t,_r as n,cr as r,fr as i,lr as a,mr as o,pr as s,wr as c,yr as l}from"./src-
|
|
1
|
+
import{z as e}from"./src-RGB2pEts.mjs";import{Cr as t,_r as n,cr as r,fr as i,lr as a,mr as o,pr as s,wr as c,yr as l}from"./src-Bev_iKqg.mjs";import{o as u,s as d,t as f,v as p}from"./write-project-skill-CTfu6uzb.mjs";import{n as m,s as h,t as g}from"./colors-BsmVIwfM.mjs";import{n as _,r as v,t as y}from"./skill-teardown-BCQ-qH0I.mjs";import{dirname as b,join as x,relative as S,resolve as C}from"node:path";import{existsSync as w,mkdirSync as T,readFileSync as E,readdirSync as D,rmSync as O,statSync as k,writeFileSync as A}from"node:fs";import{homedir as j}from"node:os";import{createInterface as M}from"node:readline/promises";const N={existsSync:e=>w(e),isDirectory:e=>{try{return k(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>D(e),readFileSync:e=>E(e),writeFileSync:(e,t)=>{A(e,t)},mkdirSync:(e,t)=>{T(e,t)},rmSync:(e,t)=>{O(e,t)}},P={resolveProjectBundledSkillDir:()=>l(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>l(e,{checkDesktop:!1}),readBundledVersion:()=>a(),readRecordedVersion:e=>i(e,`cli-hosts`),writeRecordedVersion:(e,t)=>o(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>n(e),readBundleDecision:(e,t)=>r(e,t),writeBundleDecision:(e,t,n)=>s(e,t,n),removeBundleFromDisk:(e,t)=>v(e,t)};function F(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function I(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(b(t),{recursive:!0}),L(e,t,n)}function L(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=x(e,r),a=x(t,r);n.isDirectory(i)?L(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function R(e,t,n,r,i,a){let o=[],s=x(e,`.agents`,`skills`,t),c=!1;if(r.existsSync(s))o.push({kind:`central`,path:s,outcome:`skipped-present`});else try{I(n,s,r),c=!0,o.push({kind:`central`,path:s,outcome:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let c of d){let l=x(e,c.hostDir),u=x(l,`skills`,t);if(u===s){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(l)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(r.existsSync(u)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-present`});continue}try{I(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,error:t})}}return{entries:o,centralWritten:c}}function z(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function B(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of d){let o=x(e,t.hostDir,`skills`,`open-knowledge`),s=x(o,`SKILL.md`);if(n.existsSync(s)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`present`});continue}let c=u[t.editorId]?.projectConfigPath?.(e);if(!z(c,n)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{f(o,e),I(i,o,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`created`}),r({event:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function V(n,r,i,a){let o=e=>{r.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),l;try{l=await r.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await r.readRecordedVersion(n)}catch(e){a({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of c)try{d.push({id:e,sourceDir:r.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return a({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let o of d){let s=t[o.id],c=i.existsSync(x(n,`.agents`,`skills`,s)),l=await r.readBundleDecision(n,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{r.removeBundleFromDisk(n,o.id),a({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){a({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await r.writeBundleDecision(n,s,!0)}catch(e){a({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}p.push(o)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>i.existsSync(x(n,`.agents`,`skills`,t[e.id])));if(u!==null&&u===l&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:l}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===c.length,_=[];for(let{id:e,sourceDir:r}of p){let o=R(n,t[e],r,i,a,l);h.push(...o.entries),_.push({id:e,centralWritten:o.centralWritten})}let v=h.some(e=>e.kind===`central`&&e.outcome===`failed`);if(g&&!v){let e=null;try{await r.writeRecordedVersion(n,l),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:l})}catch(t){e=t instanceof Error?t.message:String(t),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:l,error:e})}for(let{id:t,centralWritten:n}of _)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?n?`installed`:`skip-current`:`failed`,version:l,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{let e=h.some(e=>e.kind===`host`&&e.outcome===`failed`);o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:l,reason:g?e?`all-writes-failed`:`central-write-failed`:`bundle-unresolved`})}return{outcome:`done`,version:l,entries:h}}async function H(e){let t=e.logger??F,n=e.fs??N,r=e.home??j(),i={...P,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=B(e.projectDir,i,n,t),o=await V(r,i,n,t),s=_(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=y(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function U(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function W(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
|
|
2
2
|
`)}function G(){return new p(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").option(`-y, --yes`,`Skip the confirmation prompt for removing directories left by a pre-0.42 install.`).action(async e=>{let t=await H({projectDir:C(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null,confirmLegacyCleanup:t=>K(t,{yes:e.yes===!0})});process.stdout.write(`${W(t)}\n`),process.exitCode=U(t)})}async function K(e,t){let n=j(),r=e=>`~/${S(n,e)}`,i=t.input??process.stdin,a=[``,g(`A previous version of OpenKnowledge installed its skill into agent tools you may never have used.`),m(`(Versions before 0.42 wrote to every host a third-party installer knew about — see issue #820.)`)];if(e.skillDirs.length>0&&a.push(``,`${g(`Remove OpenKnowledge skills:`)} ${e.skillDirs.length}`,...e.skillDirs.map(e=>` ${r(e)}`)),e.emptyDirs.length>0){let t=e.skillDirs.length>0?`Then remove these, which hold nothing else once the above are gone:`:`Remove these empty directories, left behind by that install:`;a.push(``,`${g(t)} ${e.emptyDirs.length}`,...e.emptyDirs.map(e=>` ${r(e)}`))}if(a.push(``,m(`Nothing outside these paths is touched. A directory that still holds anything is kept.`)),process.stdout.write(`${a.join(`
|
|
3
3
|
`)}\n`),t.yes)return!0;if(!i.isTTY)return process.stdout.write(`${h("Not a terminal — skipping cleanup. Re-run with `ok repair-skills --yes` to remove these.")}\n`),!1;let o=M({input:i,output:process.stdout});try{let e=(await o.question(`\n${g(`Remove them?`)} ${m(`[y/N] `)}`)).trim().toLowerCase();return e===`y`||e===`yes`}finally{o.close()}}export{G as n,H as t};
|
|
4
|
-
//# sourceMappingURL=repair-skills-
|
|
4
|
+
//# sourceMappingURL=repair-skills-hlHv35hU.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Cr as e,wr as t}from"./src-
|
|
2
|
-
//# sourceMappingURL=skill-teardown-
|
|
1
|
+
import{Cr as e,wr as t}from"./src-Bev_iKqg.mjs";import{s as n}from"./write-project-skill-CTfu6uzb.mjs";import{dirname as r,isAbsolute as i,join as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,lstatSync as u,readdirSync as d,rmSync as f,rmdirSync as p}from"node:fs";const m=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],h=[...t.map(t=>e[t]),`open-knowledge`];function g(e){if(!i(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=s(e);if(t===c||r(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function _(e,t){let n=o(e,t);if(n.startsWith(`..`)||i(n))return!1;let r=e;for(let e of n.split(c)){r=a(r,e);try{if(!u(r).isDirectory())return!1}catch{return!1}}return!0}function v(e,t){try{return d(e).every(n=>t.has(a(e,n)))}catch{return!1}}function y(e){let t=g(e),n=[],i=[],o=new Set;for(let e of m){let s=a(t,e.hostDir,`skills`);if(!_(t,s))continue;let u=h.map(e=>a(s,e)).filter(e=>l(e));n.push(...u);for(let e of u)o.add(e);let d=a(t,e.pruneRoot),f=s;for(;v(f,o)&&(i.push(f),o.add(f),f!==d);){let e=r(f);if(e===f||e===t||!e.startsWith(t+c))break;f=e}}return{skillDirs:n,emptyDirs:i}}function b(e){try{if(!u(e).isDirectory())return!1;let t=d(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function x(e){let t=new Set,n=new Set;for(let i of m){let o=a(e,i.hostDir,`skills`);for(let e of h)t.add(a(o,e));let s=a(e,i.pruneRoot),l=o;for(;n.add(l),l!==s;){let t=r(l);if(t===l||t===e||!t.startsWith(e+c))break;l=t}}return{skillDirs:t,emptyDirs:n}}function S(e,t){let n=g(e),r=x(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(_(n,e)&&b(e))try{f(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(_(n,e))try{p(e),a.push(e)}catch{}return a}function C(r){let i=g(r),o=[];for(let r of t){let t=e[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let e of n)o.push({path:a(i,e.hostDir,`skills`,t),bundleId:r,scope:`host`,hostDir:e.hostDir})}return o}function w(e,t){let n=[];for(let r of C(e))if(r.bundleId===t)try{f(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}export{C as i,y as n,w as r,S as t};
|
|
2
|
+
//# sourceMappingURL=skill-teardown-BCQ-qH0I.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sleep-A0G7hOuG.mjs";import{Js as i,X as a,Ys as o,Z as s,Za as c}from"./src-RGB2pEts.mjs";import{Nn as l,Zr as u,at as d,bi as f,it as p,ot as m,rt as h}from"./src-
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sleep-A0G7hOuG.mjs";import{Js as i,X as a,Ys as o,Z as s,Za as c}from"./src-RGB2pEts.mjs";import{Nn as l,Zr as u,at as d,bi as f,it as p,ot as m,rt as h}from"./src-Bev_iKqg.mjs";import{D as ee,F as g,I as _,k as v}from"./fs-traced-DV9uD41t.mjs";import{C as y,S as b,d as x,y as S}from"./server-lock-D8tFCW-G.mjs";import{t as C}from"./yazl-DZr4PyKA.mjs";import{m as w,p as te,v as T}from"./write-project-skill-CTfu6uzb.mjs";import{c as ne}from"./colors-BsmVIwfM.mjs";import{n as re}from"./acp-harness-probe-CwhklR1t.mjs";import{E,T as D,_ as ie,o as O,w as k,x as ae,y as oe}from"./init-DryQvpzo.mjs";import{n as se}from"./constants-ggtyHegG.mjs";import{t as A}from"./is-object-ByG7RnjH.mjs";import"./loader-DAyo63Sq.mjs";import"./skill-teardown-BCQ-qH0I.mjs";import"./preview-Dvl3K5Z6.mjs";import{execSync as ce,spawnSync as j}from"node:child_process";import{basename as M,dirname as N,join as P,relative as le,resolve as F,sep as ue}from"node:path";import{cpSync as de,createWriteStream as fe,existsSync as I,lstatSync as pe,mkdirSync as L,mkdtempSync as me,readFileSync as R,readdirSync as z,readlinkSync as he,rmSync as B,statSync as ge,writeFileSync as V}from"node:fs";import{arch as _e,freemem as ve,homedir as H,hostname as ye,platform as be,release as xe,tmpdir as Se,totalmem as Ce,type as we,uptime as Te}from"node:os";import"node:fs/promises";import{createHash as Ee}from"node:crypto";var U=n();const De=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Oe(e,t,n=l){if(e!==void 0&&!De.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let ke=null;function Ae(e){ke=e}function je(){return ke??process.cwd()}function Me(){return P(H(),`.ok`,`bug-reports`)}function Ne(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Me(),r=`${t}-bugreport`,i=P(n,`${r}.zip`);for(let e=2;I(i);e+=1)i=P(n,`${r}-${e}.zip`);return i}function Pe(e,t){let n=P(e,`.ok`,`config.yml`);if(I(n))try{let e=R(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return I(P(e,`.ok`))?Ee(`sha256`).update(F(e)).digest(`hex`).slice(0,12):null}function Fe(){let e={timestamp:new Date().toISOString(),platform:be(),osType:we(),osRelease:xe(),hostname:`[redacted]`,uptime:Te(),freeMem:ve(),totalMem:Ce(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ce(`sw_vers -productVersion 2>/dev/null`,u({encoding:`utf8`})).trim()}catch{}try{let t=P(__dirname,`..`,`..`,`package.json`);I(t)&&(e.okVersion=JSON.parse(R(t,`utf8`)).version)}catch{}return e}const Ie=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function W(e){let t=M(e);return Ie.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Le(e,t){return Be(e,t).files}const Re=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function ze(e,t=re){let n=P(e,`${t}.ShipIt`);return I(n)?Re.map(e=>P(n,e)).filter(e=>I(e)):[]}function Be(e,t){if(!I(t))return{files:[],excludedByProjectSlug:0};let n=z(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>P(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(W),i=[],a=r.filter(t=>{try{return R(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!W(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ve(e){let t=P(e,`.ok`,`local`);return I(t)?{files:[`server.lock`,`last-spawn-error.log`,a].map(e=>P(t,e)).filter(e=>I(e))}:{files:[]}}function He(e){let t=P(e,`.ok`,`local`,`logs`);return I(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>P(t,e)).filter(e=>I(e))}:{files:[]}}function Ue(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=o(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function G(e){for(let t of e.files)try{Ue({zipfile:e.zipfile,name:`${e.prefix}/${M(t)}`,content:R(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function We(t){let{redact:n,outputPath:r,logger:a}=t,o=t.userLogsDir??P(H(),`.ok`,`logs`),s=t.projectDir?Pe(t.projectDir,a):null;L(N(r),{recursive:!0}),a?.info({projectSlug:s},`gathering diagnostic data`);let c=Fe();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=Be(s,o),{files:d}=t.projectDir?Ve(t.projectDir):{files:[]},{files:f}=t.projectDir?He(t.projectDir):{files:[]},p=t.shipItLogFiles??[];a?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length},`files collected`);let m=[],h=[],{ZipFile:ee}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),g=new ee;G({zipfile:g,files:[...l,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:a}),G({zipfile:g,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:a}),G({zipfile:g,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:a});for(let e of t.extraFiles??[])try{let t=R(e.sourcePath),n=`extra/${e.zipName??M(e.sourcePath)}`;g.addBuffer(t,n),h.push(n)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Ue({zipfile:g,name:`note.txt`,content:t.note,redact:n,bundleFiles:h,redactions:m});let _=JSON.stringify(c,null,2);g.addBuffer(Buffer.from(_,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let v={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:h,redactions:m,sysinfo:c};g.addBuffer(Buffer.from(JSON.stringify(v,null,2),`utf8`),`MANIFEST.json`);let y=m.reduce((e,t)=>e+t.lineCount,0),b=new Set(p.map(e=>`logs/${M(e)}`)),x=h.filter(e=>b.has(e)),S=s?h.filter(e=>e.startsWith(`logs/`)&&!W(e)&&!b.has(e)):[],C=[`# Bug Report Bundle`,``,`Generated: ${v.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${v.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...S.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...S.map(e=>`- ${e}`),``]:[],...x.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...x.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${i.join(`, `)}`,y>0?`${y} line(s) were scrubbed across ${m.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
|
|
2
2
|
`);g.addBuffer(Buffer.from(C,`utf8`),`README.md`),g.end();let w=fe(r);return g.outputStream.pipe(w),await new Promise((e,t)=>{w.on(`close`,e),w.on(`error`,t)}),a?.info({bundlePath:r,fileCount:h.length,redactionCount:y},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:h,redactions:m,redactedLineCount:y,generatedAt:v.generatedAt}}}var Ge=e(C(),1),K=e(ne(),1);function Ke(e){return _({absPath:v(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function qe({home:e=H(),env:n=process.env}={}){let i=Ke(e),{override:a,preferenceList:o}=ee(n),{locale:s,source:l}=c({override:a,storedPreference:i,supportedLocales:r,preferenceList:o,autoDetectableLocales:t});return{preference:i,locale:s,source:l,systemLanguages:o}}function Je(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return Je(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!Ye(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function Xe(e,t){let n=R(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
3
|
`),i=n.split(`
|
|
4
4
|
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=q(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}V(e,r?`${a.join(`
|
|
@@ -17,4 +17,4 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sle
|
|
|
17
17
|
`).replace(/\n/g,`\r
|
|
18
18
|
`));let u=`${i?``:``}${l}`;return u!==r&&g(e,u,{mode:k(e)}),{kind:`removed`}}function ln(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function un(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function dn(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:p(r),command:r,isDesktop:ln(r)}}function fn(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&fn(e)?`ui-orphan`:`stale`}const pn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function mn(e){switch(e){case`running`:return K.default.green(e);case`desktop`:return K.default.blue(e);case`foreign`:return K.default.cyan(e);case`ui-orphan`:return K.default.magenta(e);case`stale`:return K.default.yellow(e)}}function hn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function gn(e){return`${hn(e.server.usage)} | ${hn(e.ui?.usage??null)}`}function _n(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function vn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,_n(e),gn(e),t,String(n),un(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=mn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=K.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
19
19
|
`)}async function yn(e={}){let t=e.discover??h,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??d,a=e.resolveUsage??m,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=dn(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(vn(e.all?s:s.filter(e=>pn.has(Q(e)))))}function bn(){return new T(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await yn({all:t.all===!0||e===`all`,json:t.json===!0})})}function xn(e,t,n={}){let r=n.isAlive??b,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function Sn(e){let t=e.inspect??(t=>Z(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=xn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Cn(e,t=b){let n=await h(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function wn(e){let t=Sn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Tn(e){return new T(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=Sn({lockDir:f(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await yn({});return}if(n===`all`){let e=await h();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Z(n,`server`),r=Z(n,`ui`);!$(e,b)&&!$(r,b)||(wn(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Cn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}wn(t);return}wn(f(F(je(),n)))})}export{je as _,Xt as a,$t as c,Z as d,qt as f,Me as g,Ne as h,an as i,en as l,Wt as m,Tn as n,tn as o,Ut as p,bn as r,Zt as s,Sn as t,Yt as u,Ae as v,Oe as y};
|
|
20
|
-
//# sourceMappingURL=src-
|
|
20
|
+
//# sourceMappingURL=src-BZC89n0v.mjs.map
|