@inkeep/open-knowledge 0.9.0-beta.5 → 0.9.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +51 -51
  4. package/dist/constants-BpFjnS4c.mjs +2 -0
  5. package/dist/dist-BrGmF_uy.mjs +1 -0
  6. package/dist/dist-qfNwHap3.mjs +3084 -0
  7. package/dist/gh-detect-BAYi0Rn6.mjs +4 -0
  8. package/dist/git-handle-BJwB5EBp-DA7Yg-p3.mjs +1 -0
  9. package/dist/{git-handle-uz8TUFSi-BRV63-ar.mjs → git-handle-uz8TUFSi-DaMTjKLA.mjs} +1 -1
  10. package/dist/index.mjs +1 -1
  11. package/dist/{init-DwLGKHOJ.mjs → init--sZ9G3mR.mjs} +7 -7
  12. package/dist/init-cl59p9H4.mjs +1 -0
  13. package/dist/loader-BbB7wnzI.mjs +1 -0
  14. package/dist/loader-n719Lx4L.mjs +4 -0
  15. package/dist/{preview-DQUlTvw4.mjs → preview-D7mJ_l8c.mjs} +2 -2
  16. package/dist/preview-DEizQVu6.mjs +1 -0
  17. package/dist/public/assets/{ActivityModeContent-DJXpiZd9.js → ActivityModeContent-D9oMZP0Q.js} +1 -1
  18. package/dist/public/assets/DocumentContext-3_9FOxXe.js +61 -0
  19. package/dist/public/assets/{GraphPanel-CkyBCnW-.js → GraphPanel-7INU_4XO.js} +3 -3
  20. package/dist/public/assets/{SettingsDialogBody-BaPvetlg.js → SettingsDialogBody-CYRlwMBM.js} +2 -2
  21. package/dist/public/assets/{SourceEditor-B1_Gixe_.js → SourceEditor-FiumNAzD.js} +1 -1
  22. package/dist/public/assets/config-validation-events-tR_2m1Bt.js +12 -0
  23. package/dist/public/assets/index-DXJpL9JA.css +1 -0
  24. package/dist/public/assets/index-MNZNqKCl.js +1914 -0
  25. package/dist/public/assets/{prop-types-CMBUMzzz.js → prop-types-kmSrjLlV.js} +152 -152
  26. package/dist/public/assets/{target-navigation-intent-DK3GQaQx.js → target-navigation-intent-CoXNdpnE.js} +1 -1
  27. package/dist/public/assets/{telemetry-impl-DPRMO_b_.js → telemetry-impl-DLAKvA29.js} +1 -1
  28. package/dist/public/assets/{toggle-group-Dx4VUJtk.js → toggle-group-5aVb_hvg.js} +1 -1
  29. package/dist/public/assets/typing-burst-detector-DyKUJgdU.js +2 -0
  30. package/dist/public/index.html +8 -8
  31. package/dist/{repair-launch-json-vIRa-3co.mjs → repair-launch-json-C1RTZGRE.mjs} +2 -2
  32. package/dist/{repair-mcp-configs-Dlc--ykk.mjs → repair-mcp-configs-Dnz0Nf3w.mjs} +2 -2
  33. package/dist/repair-skills-DPC766QE.mjs +1 -0
  34. package/dist/{repair-skills-B2NKABTJ.mjs → repair-skills-TOO7tEqO.mjs} +2 -2
  35. package/dist/server-lock-BpjJj3OD-DXaV7wqn.mjs +428 -0
  36. package/dist/server-lock-CyhBidkz-BnPShbLX.mjs +1 -0
  37. package/dist/{src-iCrNc821.mjs → src-Cw8njPpT.mjs} +2 -2
  38. package/dist/start-BgM96Ckj.mjs +1 -0
  39. package/dist/start-Dn3gv1sh.mjs +3 -0
  40. package/dist/{write-project-skill-Dol4FEz9.mjs → write-project-skill-Cb9Cuf8k.mjs} +2 -2
  41. package/package.json +1 -1
  42. package/dist/constants-Bz06c8hN.mjs +0 -2
  43. package/dist/dist-BkOSFGR2.mjs +0 -3511
  44. package/dist/dist-CcwJUIV6.mjs +0 -1
  45. package/dist/gh-detect-CXkelKVd.mjs +0 -4
  46. package/dist/git-handle-BJwB5EBp-D5YTDzvd.mjs +0 -1
  47. package/dist/init-jTViq3OZ.mjs +0 -1
  48. package/dist/loader-B0gRV8ky.mjs +0 -1
  49. package/dist/loader-DwAApXf7.mjs +0 -4
  50. package/dist/preview-le3hO-Wh.mjs +0 -1
  51. package/dist/public/assets/DocumentContext-DTuvLW_x.js +0 -61
  52. package/dist/public/assets/config-validation-events-BL3EPRrw.js +0 -12
  53. package/dist/public/assets/index-D1S1GyyV.js +0 -1914
  54. package/dist/public/assets/index-D4TqB27u.css +0 -1
  55. package/dist/public/assets/typing-burst-detector-BC-nkePC.js +0 -2
  56. package/dist/repair-skills-9sqdgFxP.mjs +0 -1
  57. package/dist/server-lock-BIY3RMaC-CfCHCMTe.mjs +0 -2
  58. package/dist/server-lock-v2ktHD7l-C-3wEnoU.mjs +0 -1
  59. package/dist/start-7ediTKw1.mjs +0 -3
  60. package/dist/start-DLG9QOtB.mjs +0 -1
@@ -1,2 +0,0 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,i as n,o as r,r as i,t as a}from"./compiler-runtime-Cs91PcD2.js";import{A as o,j as s,k as c,n as l,ut as u,wn as d}from"./DocumentContext-DTuvLW_x.js";import{a as f,c as ee,i as te,n as ne,o as re,r as ie,s as ae,t as oe,u as se}from"./panel-BNBODYwB.js";import{Ai as p,Xt as m,qt as h,u as ce}from"./prop-types-CMBUMzzz.js";import{S as le}from"./button-DenIdY-r.js";import{$ as g,At as _,Bt as v,Dt as y,E as ue,Et as b,Ft as x,Ht as S,J as C,Mt as w,N as T,Ot as E,Pt as D,Q as O,Rt as k,Ut as A,X as j,_ as de,_t as M,ct as N,dt as P,et as F,f as I,gt as L,ht as R,l as fe,lt as pe,mt as me,nt as he,ot as ge,rt as _e,st as ve,tt as ye,ut as be,wt as z,y as xe,yt as B,zt as Se}from"./dist-sw9fzKjM.js";import{i as Ce,n as we,o as Te,r as Ee}from"./dist-Cwt7KtW7.js";var De=e(t(),1),Oe=a(),ke=new Map;function Ae(e,t){ke.set(e,t)}function je(e){let t=ke.get(e)??null;return ke.delete(e),t}function Me(e){ke.delete(e)}function Ne(e,t){let n=(0,Oe.c)(4),r=t===void 0?!1:t,[i,a]=(0,De.useState)(void 0),o=(0,De.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,De.useEffect)(s,c),i}var V=r(),Pe=300;async function Fe(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new u(p._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=m.safeParse(n);throw e.success?Error(e.data.title):new u(p._({id:`zlErBl`}),{status:t.status})}let r=h.safeParse(n);if(!r.success)throw new u(p._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var Ie=32,Le=12,Re=6,ze=`open-knowledge:outline-nav`;function Be(e){let t=(0,Oe.c)(2),n;return t[0]===e?n=t[1]:(n=(0,V.jsx)(d,{name:`outline-panel`,children:(0,V.jsx)(Ve,{...e})}),t[0]=e,t[1]=n),n}function Ve(e){let t=(0,Oe.c)(50),{docName:r,isSourceMode:a,className:o}=e,s=o===void 0?``:o,{_:c}=n(),{pages:u,loading:d}=ce(),p=se(),{activeProvider:m,activeDocName:h}=l(),g,_;t[0]===r?(g=t[1],_=t[2]):(g=[`page-headings`,r],_=()=>Fe(r),t[0]=r,t[1]=g,t[2]=_);let v;t[3]!==r||t[4]!==d||t[5]!==u?(v=!d&&u.has(r),t[3]=r,t[4]=d,t[5]=u,t[6]=v):v=t[6];let y;t[7]!==g||t[8]!==_||t[9]!==v?(y={queryKey:g,queryFn:_,enabled:v,staleTime:1/0},t[7]=g,t[8]=_,t[9]=v,t[10]=y):y=t[10];let{data:ue,isLoading:b,error:x}=ee(y),S;t[11]===ue?S=t[12]:(S=ue===void 0?[]:ue,t[11]=ue,t[12]=S);let C=S,w,T;t[13]!==h||t[14]!==m||t[15]!==r||t[16]!==p?(w=()=>{if(!m||h!==r)return;let e=m.document,t=null,n=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,p.invalidateQueries({queryKey:[`page-headings`,r]})},Pe)};return e.on(`update`,n),()=>{e.off(`update`,n),t!==null&&clearTimeout(t)}},T=[m,h,r,p],t[13]=h,t[14]=m,t[15]=r,t[16]=p,t[17]=w,t[18]=T):(w=t[17],T=t[18]),(0,De.useEffect)(w,T);let E;t[19]===C?E=t[20]:(E=C.map(He),t[19]=C,t[20]=E);let D=Ne(E,a),O;t[21]!==D||t[22]!==C?(O=D?C.findIndex(e=>e.slug===D):-1,t[21]=D,t[22]=C,t[23]=O):O=t[23];let k=O,A;t[24]!==r||t[25]!==a?(A=function(e,t){let n={index:e,slug:t,mode:a?`source`:`wysiwyg`};n.mode===`source`&&Ae(r,{kind:`outline`,detail:n}),window.dispatchEvent(new CustomEvent(ze,{detail:n}))},t[24]=r,t[25]=a,t[26]=A):A=t[26];let j=A,de=((k>=0?C[k].level:1)-1)*Le+(Le-Re)/2,M=k*Ie+(Ie-Re)/2,N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,V.jsx)(ae,{children:(0,V.jsx)(i,{id:`dD7NPy`})}),t[27]=N):N=t[27];let P;t[28]!==C.length||t[29]!==b?(P=!b&&(0,V.jsx)(ie,{children:C.length}),t[28]=C.length,t[29]=b,t[30]=P):P=t[30];let F;t[31]===P?F=t[32]:(F=(0,V.jsxs)(re,{children:[N,P]}),t[31]=P,t[32]=F);let I;t[33]!==c||t[34]!==k||t[35]!==D||t[36]!==x||t[37]!==j||t[38]!==C||t[39]!==b||t[40]!==de||t[41]!==M?(I=x?(0,V.jsx)(f,{className:`px-2`,children:x instanceof Error?x.message:c({id:`GuqOb1`})}):C.length===0&&!b?(0,V.jsx)(te,{className:`px-2`,children:(0,V.jsx)(i,{id:`0BB9ID`})}):(0,V.jsxs)(`nav`,{"aria-label":c({id:`BymzO4`}),className:`relative`,children:[k>=0&&(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:Re,height:Re,transform:`translate(${de}px, ${M}px)`}}),C.map((e,t)=>{let n=e.slug===D;return(0,V.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>j(t,e.slug),className:le(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*Le+20}px`},title:e.text,children:e.text},t)})]}),t[33]=c,t[34]=k,t[35]=D,t[36]=x,t[37]=j,t[38]=C,t[39]=b,t[40]=de,t[41]=M,t[42]=I):I=t[42];let L;t[43]!==b||t[44]!==I?(L=(0,V.jsx)(ne,{className:`px-3 py-2`,"aria-busy":b,children:I}),t[43]=b,t[44]=I,t[45]=L):L=t[45];let R;return t[46]!==s||t[47]!==F||t[48]!==L?(R=(0,V.jsxs)(oe,{className:s,children:[F,L]}),t[46]=s,t[47]=F,t[48]=L,t[49]=R):R=t[49],R}function He(e){return e.slug}var Ue=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,H=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Ue(e)):Ue,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return k(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=A(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Se(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(H.prototype[Symbol.iterator]=function(){return this});var We={from:-1,to:-1,match:/.*/.exec(``)},Ge=`gm`+(/x/.unicode==null?``:`u`),Ke=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=We,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Ye(e,t,n,r,i);this.re=new RegExp(t,Ge+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=Ze(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Ze(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},qe=new WeakMap,Je=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=qe.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return qe.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),qe.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Ye=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=We,this.matchPos=Ze(e,r),this.re=new RegExp(t,Ge+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Je.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=Ze(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Je.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Ke.prototype[Symbol.iterator]=Ye.prototype[Symbol.iterator]=function(){return this});function Xe(e){try{return new RegExp(e,Ge),!0}catch{return!1}}function Ze(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Qe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=L(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),ee=b.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,j.scrollIntoView(ee.from,{y:`center`})],selection:ee})}),!0},$e={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},et=E.define({combine(e){return v(e,$e,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function tt(e){let t=[st,ot];return e&&t.push(et.of(e)),t}var nt=C.mark({class:`cm-selectionMatch`}),rt=C.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function it(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=z.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=z.Word)}function at(e,t,n,r){return e(t.sliceDoc(n,n+1))==z.Word&&e(t.sliceDoc(r-1,r))==z.Word}var ot=O.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(et),{state:n}=e,r=n.selection;if(r.ranges.length>1)return C.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return C.none;let e=n.wordAt(i.head);if(!e)return C.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return C.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(it(o,n,i.from,i.to)&&at(o,n,i.from,i.to)))return C.none}else if(a=n.sliceDoc(i.from,i.to),!a)return C.none}let s=[];for(let r of e.visibleRanges){let e=new H(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||it(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(rt.range(r,a)):(r>=i.to||a<=i.from)&&s.push(nt.range(r,a)),s.length>t.maxMatches))return C.none}}return C.set(s)}},{decorations:e=>e.decorations}),st=j.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),ct=({state:e,dispatch:t})=>{let{selection:n}=e,r=b.create(n.ranges.map(t=>e.wordAt(t.head)||b.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function lt(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new H(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new H(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var ut=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return ct({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=lt(e,r);return i?(t(e.update({selection:e.selection.addRange(b.range(i.from,i.to),!1),effects:j.scrollIntoView(i.to)})),!0):!1},U=E.define({combine(e){return v(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new zt(e),scrollToMatch:e=>j.scrollIntoView(e)})}}),dt=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Xe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
- `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new bt(this):new ht(this)}getCursor(e,t=0,n){let r=e.doc?e:y.create({doc:e});return n??=r.doc.length,this.regexp?G(this,r,t,n):W(this,r,t,n)}},ft=class{constructor(e){this.spec=e}};function pt(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function W(e,t,n,r){let i;return e.wholeWord&&(i=mt(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=pt(e.test,t,i)),new H(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function mt(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(_t(i,n-a))!=z.Word||t(vt(i,n-a))!=z.Word)&&(t(vt(i,r-a))!=z.Word||t(_t(i,r-a))!=z.Word))}var ht=class extends ft{constructor(e){super(e)}nextMatch(e,t,n){let r=W(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=W(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=W(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=W(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=W(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function gt(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function G(e,t,n,r){let i;return e.wholeWord&&(i=yt(t.charCategorizer(t.selection.main.head))),e.test&&(i=gt(e.test,t,i)),new Ke(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function _t(e,t){return e.slice(S(e,t,!1),t)}function vt(e,t){return e.slice(t,S(e,t))}function yt(e){return(t,n,r)=>!r[0].length||(e(_t(r.input,r.index))!=z.Word||e(vt(r.input,r.index))!=z.Word)&&(e(vt(r.input,r.index+r[0].length))!=z.Word||e(_t(r.input,r.index+r[0].length))!=z.Word)}var bt=class extends ft{nextMatch(e,t,n){let r=G(this.spec,e,n,e.doc.length).next();return r.done&&(r=G(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=G(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=G(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=G(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},K=D.define(),xt=D.define(),q=x.define({create(e){return new St(Nt(e).create(),null)},update(e,t){for(let n of t.effects)n.is(K)?e=new St(n.value.create(),e.panel):n.is(xt)&&(e=new St(e.query,n.value?Mt:null));return e},provide:e=>M.from(e,e=>e.panel)}),St=class{constructor(e,t){this.query=e,this.panel=t}},Ct=C.mark({class:`cm-searchMatch`}),wt=C.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Tt=O.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(q))}update(e){let t=e.state.field(q);(t!=e.startState.field(q)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return C.none;let{view:n}=this,r=new w;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?wt:Ct)})}return r.finish()}},{decorations:e=>e.decorations});function J(e){return t=>{let n=t.state.field(q,!1);return n&&n.query.spec.valid?e(t,n):It(t)}}var Et=J((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=b.single(r.from,r.to),a=e.state.facet(U);return e.dispatch({selection:i,effects:[Ht(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),Ft(e),!0}),Dt=J((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=b.single(i.from,i.to),o=e.state.facet(U);return e.dispatch({selection:a,effects:[Ht(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),Ft(e),!0}),Ot=J((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:b.create(n.map(e=>b.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),kt=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new H(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(b.range(t.value.from,t.value.to))}return t(e.update({selection:b.create(a,o),userEvent:`select.search.matches`})),!0},At=J((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(j.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=b.single(o.from,o.to).map(d),u.push(Ht(e,o)),u.push(n.facet(U).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),jt=J((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:j.announce.of(r),userEvent:`input.replace.all`}),!0});function Mt(e){return e.state.facet(U).createPanel(e)}function Nt(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(U);return new dt({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function Pt(e){let t=_e(e,Mt);return t&&t.dom.querySelector(`[main-field]`)}function Ft(e){let t=Pt(e);t&&t==e.root.activeElement&&t.select()}var It=e=>{let t=e.state.field(q,!1);if(t&&t.panel){let n=Pt(e);if(n&&n!=e.root.activeElement){let r=Nt(e.state,t.query.spec);r.valid&&e.dispatch({effects:K.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[xt.of(!0),t?K.of(Nt(e.state,t.query.spec)):D.appendConfig.of(Wt)]});return!0},Lt=e=>{let t=e.state.field(q,!1);if(!t||!t.panel)return!1;let n=_e(e,Mt);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:xt.of(!1)}),!0},Rt=[{key:`Mod-f`,run:It,scope:`editor search-panel`},{key:`F3`,run:Et,shift:Dt,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Et,shift:Dt,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Lt,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:kt},{key:`Mod-Alt-g`,run:Qe},{key:`Mod-d`,run:ut,preventDefault:!0}],zt=class{constructor(e){this.view=e;let t=this.query=e.state.field(q).query.spec;this.commit=this.commit.bind(this),this.searchField=B(`input`,{value:t.search,placeholder:Y(e,`Find`),"aria-label":Y(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=B(`input`,{value:t.replace,placeholder:Y(e,`Replace`),"aria-label":Y(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=B(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=B(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=B(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return B(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=B(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Et(e),[Y(e,`next`)]),n(`prev`,()=>Dt(e),[Y(e,`previous`)]),n(`select`,()=>Ot(e),[Y(e,`all`)]),B(`label`,null,[this.caseField,Y(e,`match case`)]),B(`label`,null,[this.reField,Y(e,`regexp`)]),B(`label`,null,[this.wordField,Y(e,`by word`)]),...e.state.readOnly?[]:[B(`br`),this.replaceField,n(`replace`,()=>At(e),[Y(e,`replace`)]),n(`replaceAll`,()=>jt(e),[Y(e,`replace all`)])],B(`button`,{name:`close`,onclick:()=>Lt(e),"aria-label":Y(e,`close`),type:`button`},[`×`])])}commit(){let e=new dt({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:K.of(e)}))}keydown(e){R(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Dt:Et)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),At(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(K)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(U).top}};function Y(e,t){return e.state.phrase(t)}var Bt=30,Vt=/[\s\.,:;?!]/;function Ht(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-Bt),o=Math.min(i,n+Bt),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Bt;e++)if(!Vt.test(s[e+1])&&Vt.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Bt;e--)if(!Vt.test(s[e-1])&&Vt.test(s[e])){s=s.slice(0,e);break}}return j.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Ut=j.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Wt=[q,_.low(Tt),Ut],Gt=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},X=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet($).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new w,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=mn(s);if(i)o.add(n,n,C.widget({widget:new sn(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,C.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,Z(f))}};function Z(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new Gt(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Gt(r.from,n,r.diagnostic)}),r}function Kt(e,t){let n=t.pos,r=t.end||n,i=e.state.facet($).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(Jt))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function qt(e,t){return e.field(Q,!1)?t:t.concat(D.appendConfig.of(hn))}var Jt=D.define(),Yt=D.define(),Xt=D.define(),Q=x.define({create(){return new X(C.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Z(n,e.selected.diagnostic,i)||Z(n,null,i)}!n.size&&i&&t.state.facet($).autoPanel&&(i=null),e=new X(n,i,r)}for(let n of t.effects)if(n.is(Jt)){let r=t.state.facet($).autoPanel?n.value.length?ln.open:null:e.panel;e=X.init(n.value,r,t.state)}else n.is(Yt)?e=new X(e.diagnostics,n.value?ln.open:null,e.selected):n.is(Xt)&&(e=new X(e.diagnostics,e.panel,n.value));return e},provide:e=>[M.from(e,e=>e.panel),j.decorations.from(e,e=>e.diagnostics)]}),Zt=C.mark({class:`cm-lintRange cm-lintRange-active`});function Qt(e,t,n){let{diagnostics:r}=e.state.field(Q),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet($).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:$t(e,i)}}}:null}function $t(e,t){return B(`ul`,{class:`cm-tooltip-lint`},t.map(t=>on(e,t,!1)))}var en=e=>{let t=e.state.field(Q,!1);(!t||!t.panel)&&e.dispatch({effects:qt(e.state,[Yt.of(!0)])});let n=_e(e,ln.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},tn=e=>{let t=e.state.field(Q,!1);return!t||!t.panel?!1:(e.dispatch({effects:Yt.of(!1)}),!0)},nn=[{key:`Mod-Shift-m`,run:en,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Q,!1);if(!t)return!1;let n=e.state.selection.main,r=Z(t.diagnostics,null,n.to+1);return!r&&(r=Z(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],$=E.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...v(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:rn,tooltipFilter:rn,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function rn(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function an(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function on(e,t,n){let r=n?an(t.actions):[];return B(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},B(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Z(e.state.field(Q).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),B(`u`,s.slice(c,c+1)),s.slice(c+1)];return B(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&B(`div`,{class:`cm-diagnosticSource`},t.source))}var sn=class extends g{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return B(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},cn=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=on(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},ln=class e{constructor(e){this.view=e,this.items=[],this.list=B(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)tn(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=an(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=Z(this.view.state.field(Q).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=B(`div`,{class:`cm-panel-lint`},this.list,B(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>tn(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Q).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Q),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new cn(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new cn(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Z(this.view.state.field(Q).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Xt.of(t)})}static open(t){return new e(t)}};function un(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function dn(e){return un(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var fn=j.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:dn(`#d11`)},".cm-lintRange-warning":{backgroundImage:dn(`orange`)},".cm-lintRange-info":{backgroundImage:dn(`#999`)},".cm-lintRange-hint":{backgroundImage:dn(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function pn(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function mn(e){let t=`hint`,n=1;for(let r of e){let e=pn(r.severity);e>n&&(n=e,t=r.severity)}return t}var hn=[Q,j.decorations.compute([Q],e=>{let{selected:t,panel:n}=e.field(Q);return!t||!n||t.from==t.to?C.none:C.set([Zt.range(t.from,t.to)])}),pe(Qt,{hideOn:Kt}),fn],gn=[P(),ve(),N(),o(),de(),ye(),he(),y.allowMultipleSelections.of(!0),ue(),T(I,{fallback:!0}),fe(),Ee(),we(),me(),F(),ge(),tt(),be.of([...Ce,...c,...Rt,...s,...xe,...Te,...nn])];N(),o(),ye(),T(I,{fallback:!0}),be.of([...c,...s]);export{je as a,Me as i,ze as n,Ae as o,Be as r,gn as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./repair-skills-B2NKABTJ.mjs";export{e as repairSkills};
@@ -1,2 +0,0 @@
1
- import{dirname as e,resolve as t}from"node:path";import{closeSync as n,existsSync as r,mkdirSync as i,openSync as a,readFileSync as o,unlinkSync as s,writeFileSync as c,writeSync as l}from"node:fs";import{hostname as u}from"node:os";import{fileURLToPath as d}from"node:url";function f(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function p(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function m(){try{let n=t(e(d(import.meta.url)),`..`,`package.json`),r=JSON.parse(o(n,`utf-8`));if(typeof r.version==`string`&&r.version.length>0)return r.version}catch{}return`0.0.0-unknown`}const h=m(),g=1;var _=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function v(e,n){return t(e,`${n}.lock`)}const y=new Map;function b(e){y.set(e,(y.get(e)??0)+1)}function x(e){let t=y.get(e);return t===void 0||t<=1?(y.delete(e),!0):(y.set(e,t-1),!1)}function S(e,t){try{let n=JSON.parse(o(e,`utf-8`));return n&&typeof n==`object`&&p(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function C(e){let{lockName:t,lockDir:o,metadata:d}=e,p=`[${t}-lock]`;i(o,{recursive:!0});let m=v(o,t),g={pid:process.pid,hostname:u(),port:d.port,startedAt:new Date().toISOString(),worktreeRoot:d.worktreeRoot,...d.kind!==void 0&&{kind:d.kind},...d.parentPid!==void 0&&{parentPid:d.parentPid},...d.capabilities!==void 0&&{capabilities:d.capabilities},protocolVersion:d.protocolVersion??1,runtimeVersion:d.runtimeVersion??h},y=JSON.stringify(g,null,2);for(let e=0;e<3;e++){if(!r(m))try{let e=a(m,`wx`,384);try{l(e,y)}finally{n(e)}return b(m),w({lockName:t,lockDir:o,lockPath:m})}catch(e){if(e.code!==`EEXIST`)throw e}let e=S(m,p);if(e){let n=e.hostname===u();if(n&&e.pid===process.pid)return c(m,y,{encoding:`utf-8`,mode:384}),b(m),w({lockName:t,lockDir:o,lockPath:m});if(n&&f(e.pid))throw new _(e,m,t);console.warn(`${p} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{s(m)}catch{}}throw Error(`${p} Failed to acquire ${m} after 3 attempts (concurrent acquire contention).`)}function w(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>O({lockName:t,lockDir:n}),updatePort:e=>T({lockName:t,lockDir:n,port:e})}}function T(e){let{lockName:t,lockDir:n,port:i}=e,a=`[${t}-lock]`,s=v(n,t);if(!r(s)){console.warn(`${a} Lock file missing at ${s} during port update — skipping`);return}let l;try{let e=JSON.parse(o(s,`utf-8`));if(!e||typeof e!=`object`||!p(e.pid)){console.warn(`${a} Corrupt lock at ${s} during port update — skipping`);return}l=e}catch{console.warn(`${a} Unreadable lock at ${s} during port update — skipping`);return}if(l.pid===process.pid&&!(typeof l.hostname==`string`&&l.hostname!==u())){l.port=i;try{c(s,JSON.stringify(l,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function E(e){let{lockName:t,lockDir:n}=e,i=v(n,t);if(!r(i))return null;let a;try{let e=JSON.parse(o(i,`utf-8`));if(!e||typeof e!=`object`||!p(e.pid))return null;a=e}catch{return null}if(a.hostname!==u())return null;if(!f(a.pid)){try{s(i)}catch{}return null}return a}function D(e){let{lockName:t,lockDir:n}=e,i=v(n,t);if(!r(i))return{status:`absent`};let a;try{a=JSON.parse(o(i,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!a||typeof a!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:a};let c=a;if(!p(c.pid)||typeof c.hostname!=`string`||typeof c.port!=`number`||typeof c.startedAt!=`string`||typeof c.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:a};let l={pid:c.pid,hostname:c.hostname,port:c.port,startedAt:c.startedAt,worktreeRoot:c.worktreeRoot,protocolVersion:typeof c.protocolVersion==`number`?c.protocolVersion:void 0,runtimeVersion:typeof c.runtimeVersion==`string`?c.runtimeVersion:void 0};if(l.hostname!==u())return{status:`stale`,lock:l};if(!f(l.pid)){try{s(i)}catch{}return{status:`stale`,lock:l}}return l.protocolVersion===void 0||l.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:a}:{status:`live`,lock:l}}function O(e){let{lockName:t,lockDir:n}=e,i=`[${t}-lock]`,a=v(n,t);if(x(a)&&r(a))try{let e=JSON.parse(o(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==u())return;s(a)}catch(e){console.warn(`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}var k=class extends _{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function A(e,t){try{return C({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof _&&e.lockName===`server`?new k(e.existing,e.lockPath):e}}function j(e,t){T({lockName:`server`,lockDir:e,port:t})}function M(e){return E({lockName:`server`,lockDir:e})}function N(e){O({lockName:`server`,lockDir:e})}export{C as a,p as c,D as d,M as f,j as g,T as h,k as i,v as l,N as m,h as n,A as o,O as p,g as r,f as s,_ as t,E as u};
2
- //# sourceMappingURL=server-lock-BIY3RMaC-CfCHCMTe.mjs.map
@@ -1 +0,0 @@
1
- import{g as e}from"./server-lock-BIY3RMaC-CfCHCMTe.mjs";export{e as updateServerLockPort};
@@ -1,3 +0,0 @@
1
- import{n as e,t}from"./esm-CEs3LWY3.mjs";import{Mi as n,kn as r,zi as i}from"./dist-BkOSFGR2.mjs";import{i as a,t as o}from"./gh-detect-CXkelKVd.mjs";import{n as s}from"./constants-Bz06c8hN.mjs";import{spawn as c}from"node:child_process";import{basename as l,dirname as u,join as d}from"node:path";import{closeSync as f,existsSync as p,mkdirSync as m,openSync as h,statSync as g}from"node:fs";import{homedir as _}from"node:os";import{setTimeout as v}from"node:timers/promises";const y=`Open Knowledge.app`,b=`/Applications/${y}`;function x(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return g(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function S(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(C(e,b))return b;let t=d(e.homeDir??_(),`Applications`,y);return C(e,t)?t:null}function C(e,t){try{let n=d(t,`Contents`,`MacOS`,`Open Knowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function w(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`)return{available:!1,reason:`darwin-only`};let t;try{t=S(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:e.isTTY!==!0||e.env.SSH_CONNECTION||e.env.SSH_TTY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function T(e){(e.log??(e=>console.error(e)))("Launching Open Knowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)");let t={...process.env};delete t.ELECTRON_RUN_AS_NODE,e.spawn(`open`,[`-b`,`com.inkeep.open-knowledge`],{detached:!0,stdio:`ignore`,env:t}).unref()}function E(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${b}. Install via DMG, or omit --mode for browser mode.`;case`darwin-only`:return`Desktop app is macOS-only on this release. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect desktop bundle at ${b} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${b} but launch dispatch did not fire (caller bug).`}}function D(e){return d(u(e),`..`,`Frameworks`,`Open Knowledge Server.app`,`Contents`,`MacOS`,`Open Knowledge Helper`)}const O=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function k(e){if(e.platform!==`darwin`||!O.test(e.execPath))return null;let t=D(e.execPath);return e.exists(t)?t:null}function A(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??p,a=r[1];return a?{command:k({execPath:t,platform:n,exists:i})??t,prefixArgs:[a]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(r)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function j(e,t){return e.host??t.HOST??`localhost`}function M(e){let t=l(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var N=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function P(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function F(e){p(e.lockDir)||m(e.lockDir,{recursive:!0});let t=h(d(e.lockDir,i),`w`),n=e.spawn??c,{PORT:r,...a}=process.env,o=A();try{let r=n(o.command,[...o.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return r.unref(),r}finally{try{f(t)}catch{}}}async function I(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}const L=n;function R(e){let t=e.sigtermGraceMs??L,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>v(e));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function z(e){let{config:t,cwd:n,host:i}=e,s=e.skipAutoInit??!1,c=e.skipUiAutoSpawn??!1,l=e.idleThresholdMs??18e5,{existsSync:u,mkdirSync:d}=await import(`node:fs`),{bootServer:f,getLogger:p,isProcessAlive:m,readUiLock:h,resolveContentDir:g}=await import(`./dist-CcwJUIV6.mjs`),_=e.log??p(`start`);if(!s&&!r(n))throw new N(n);let y=process.env.OK_RECLAIM_DISABLE??null;try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-Dlc--ykk.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:y})}catch(e){_.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-vIRa-3co.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:y})}catch(e){_.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-9sqdgFxP.mjs`)).repairSkills)({projectDir:n,reclaimDisableEnv:y})}catch(e){_.warn({err:e},`[start] skill repair sweep failed; continuing`)}let b=g(t,n);u(b)||(d(b,{recursive:!0}),_.info({contentDir:b},`Created content directory`));let x=null,S=async({lockDir:t})=>{if(x=P({uiLock:h(t),isAlive:m}),x.action===`spawn`&&!c)try{F({lockDir:t,cwd:n,spawn:e.spawn}),_.info({reason:x.reason},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else x.action===`skip`&&_.info({port:x.port,pid:x.pid},`UI already running at port ${x.port}`)},C=e.reactShellDistDir===void 0,w=a(),T=await f({config:t,contentDir:b,projectDir:n,contentRoot:t.content.dir,port:e.port,host:i,quiet:!1,detectGh:o,tokenStore:w,localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:C,idleShutdownMs:l,skipAutoInit:!0,...C?{spawnUiSiblingFn:S}:{},idleShutdownHandler:e=>R({readUiLock:()=>h(T.lockDir),isAlive:m,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:_}),log:_,...e.serveContentAssets?{serveContentAssets:!0}:{},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});x||={action:`skip`,reason:`alive`,pid:0,port:0};let E=x,D=null;if(E.action===`skip`)D=E.port>0?E.port:null;else if(!c){let t=e.uiBindTimeoutMs??3e3;D=await I({readUiLock:()=>h(T.lockDir),now:Date.now,sleep:e=>v(e),timeoutMs:t,pollIntervalMs:50}),D===null&&_.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:T.httpServer,destroy:T.destroy,lockDir:T.lockDir,contentDir:b,port:T.port,ready:T.ready,degraded:T.degraded,uiSpawnDecision:x,resolvedUiPort:D}}function B(t){if(t===`browser`||t===`app`)return t;throw new e(`--mode must be 'browser' or 'app'`)}async function V(e,t){let{renderBanner:n}=await import(`./banner-D39r_H1d.mjs`),{dim:r,error:i,warning:a}=await import(`./colors-t2HkW8lF.mjs`),o=process.cwd(),c=e;process.title=M(o);let l=j(t,process.env),u=t.port===void 0?void 0:Number(t.port),d=process.env.PORT?Number(process.env.PORT):void 0,f=u??d,p;try{p=await z({config:c,cwd:o,host:l,port:f,...t.serveContentAssets?{serveContentAssets:!0}:{},...t.reactShellDistDir?{reactShellDistDir:t.reactShellDistDir}:{}})}catch(e){e instanceof N&&(console.error(i(e.message)),process.exit(1));let t=await import(`./dist-CcwJUIV6.mjs`);(e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78);let n=H(e,o,t);n!==null&&(console.error(i(n)),process.exit(1)),console.error(`${i(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let m=!1,h=async e=>{if(!m){m=!0,console.log(r(`\nShutting down (${e})`));try{await p.destroy()}catch(e){console.error(`${i(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)}};process.once(`SIGINT`,()=>{h(`SIGINT`)}),process.once(`SIGTERM`,()=>{h(`SIGTERM`)});let g=`http://${l}:${p.port}`,_=l===`0.0.0.0`||l===`::`?`http://0.0.0.0:${p.port}`:void 0,v=p.resolvedUiPort,y=v!==null&&v>0?`http://${l}:${v}`:g;console.log(n({name:`open-knowledge`,version:s,localUrl:y,apiUrl:y===g?void 0:g,networkUrl:_}));let b={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};p.ready.then(async()=>{if(p.degraded.length>0){console.log();for(let e of p.degraded){let t=b[e]??`${e} (check server logs for details)`;console.warn(` ${a(`⚠`)} ${a(e)}: ${r(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-C6LU_1mt.mjs`);e(y)}}).catch(e=>{console.error(` ${i(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function H(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=d(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`Open Knowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function U(e){return new t(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,B).option(`--serve-content-assets`,`Serve content assets from this server`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path> (suppresses ok ui sibling)`).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
2
- `),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.host!==void 0&&e.push(`--host`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=w(x());if(n.available){T({spawn:c});return}console.error(E(n.reason)),process.exit(1)}await V(n,t)})}export{P as a,V as c,H as d,A as f,T as h,R as i,F as l,w as m,I as n,M as o,x as p,z as r,j as s,N as t,U as u};
3
- //# sourceMappingURL=start-7ediTKw1.mjs.map
@@ -1 +0,0 @@
1
- import{u as e}from"./start-7ediTKw1.mjs";export{e as startCommand};