@inkeep/open-knowledge 0.30.0-beta.4 → 0.30.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +54 -54
- package/dist/constants-CvXLVbm6.mjs +2 -0
- package/dist/{dist-DXIG2Jyg.mjs → dist-Cz2oOaYb.mjs} +13 -11
- package/dist/dist-DArAF-Z8.mjs +1 -0
- package/dist/{gh-detect-BMbpd_Yj.mjs → gh-detect-OjM7QxYB.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/init-BRSDpXwQ.mjs +1 -0
- package/dist/{init-CkBE_apM.mjs → init-iHmXas-2.mjs} +5 -5
- package/dist/{launch-json-removal-YtOryh7V.mjs → launch-json-removal-yifel8HM.mjs} +2 -2
- package/dist/loader-b4IAzAz6.mjs +1 -0
- package/dist/{loader-BOmEZv00.mjs → loader-hl0o6W6h.mjs} +3 -3
- package/dist/{open-browser-gwoFcjXN.mjs → open-browser-BE9TwPRU.mjs} +2 -2
- package/dist/{preview-CJm1A1UQ.mjs → preview-CPvGhej6.mjs} +2 -2
- package/dist/preview-DTCU2jNI.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-C0_GSBuC.js → ActivityModeContent-D2vlnwuv.js} +1 -1
- package/dist/public/assets/CodeMirrorPropInput-DIQ7Kf5H.js +3 -0
- package/dist/public/assets/DocumentContext-D3J8u-yJ.js +35 -0
- package/dist/public/assets/{EnableSyncConfirmDialog-BhwhYBFL.js → EnableSyncConfirmDialog-BARabdkd.js} +1 -1
- package/dist/public/assets/{GraphPanel-ByzLo6-b.js → GraphPanel-fXnpaAgY.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-DAzdDsOt.js → ManagedArtifactProperties-BLeL9TCx.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-BwDo5LSJ.js → McpConsentDialogBody-x2AhHc7a.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-BpnOw4CA.js → MermaidDocEditor-sSBTLHZ8.js} +1 -1
- package/dist/public/assets/{PropertyPanel-B3wmhQBT.js → PropertyPanel-DGyVDpJX.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-DVvKGL9J.js → SettingsDialogBody-UFh0-nb1.js} +2 -2
- package/dist/public/assets/{ShareBranchSwitchDialog-i35Gg8js.js → ShareBranchSwitchDialog-CHkvSij0.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-LrK6Us6O.js → ShareReceiveDialog-DJb80ZUd.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-CEV0ExUm.js → ShareReceiveMissDialog-CtSEaJGF.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-BoEoI6NN.js → SkillEditorActions-Dd3W2TJ2.js} +1 -1
- package/dist/public/assets/SourceEditor-DpFI9KX7.js +1 -0
- package/dist/public/assets/{TerminalPanel-Di7sR9_K.js → TerminalPanel-D1ztFh-8.js} +1 -1
- package/dist/public/assets/{agent-presence-DOgDiPgh.js → agent-presence-DYvXM7da.js} +1 -1
- package/dist/public/assets/{auth-state-cache-CZRVpVW6.js → auth-state-cache-DCGhumiU.js} +1 -1
- package/dist/public/assets/{config-provider-BnOnKhga.js → config-provider-Bkj9YufI.js} +1 -1
- package/dist/public/assets/{dist-xdRBzARh.js → dist-B27DnPFz.js} +2 -2
- package/dist/public/assets/{dist-D7PDymSy.js → dist-W-hKJCWn.js} +10 -4
- package/dist/public/assets/{doc-hash-i5oNLfum.js → doc-hash-CCfJH4d9.js} +1 -1
- package/dist/public/assets/{documents-events-D26lhbOZ.js → documents-events-C2yqFJPg.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-N1FVhfKw.js → file-tree-adapter-8cV2wqcm.js} +1 -1
- package/dist/public/assets/{index-KSKNKDpJ.js → index-BJaSDWbA.js} +10 -10
- package/dist/public/assets/{keyboard-shortcuts-Bgozgsx2.js → keyboard-shortcuts-BrZDq1VP.js} +1 -1
- package/dist/public/assets/{navigation-targets-D_wZddL9.js → navigation-targets-D5Vr3b-e.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-kOn8WHrp.js → open-managed-artifact-tab-7RGWt7Lr.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-CDyGvnwD.js → pending-receive-nav-store-DRc7Xpt6.js} +1 -1
- package/dist/public/assets/{prop-types-BK5m4zFC.js → prop-types-Zdll0W8u.js} +1 -1
- package/dist/public/assets/{receive-store-Jc3PEGIh.js → receive-store-Brkf98BO.js} +1 -1
- package/dist/public/assets/{selection-context-72mLve4s.js → selection-context-DArc3SI0.js} +1 -1
- package/dist/public/assets/{skill-actions-CeU8Dbpm.js → skill-actions-BfvtIGj9.js} +1 -1
- package/dist/public/assets/{skills-api-k47WvkqQ.js → skills-api-DQp0sBix.js} +1 -1
- package/dist/public/assets/{src-B6vksAtW.js → src-BGo7Caak.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-DEwTup1R.js → target-navigation-intent-BH9odHdJ.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BC1YUpwK.js → typing-burst-detector-DiAheTFV.js} +2 -2
- package/dist/public/assets/{workspace-paths-D4weWrbA.js → workspace-paths-DDVHpOi-.js} +1 -1
- package/dist/public/index.html +25 -25
- package/dist/{repair-launch-json-DO2QDHDR.mjs → repair-launch-json-Ci58ZFOB.mjs} +2 -2
- package/dist/{repair-mcp-configs-RYSmTXdj.mjs → repair-mcp-configs-BZ3WjjMF.mjs} +2 -2
- package/dist/{repair-skills-BrAdfxB-.mjs → repair-skills-DEr0n_7M.mjs} +2 -2
- package/dist/repair-skills-Do4RqKu3.mjs +1 -0
- package/dist/server-lock-GuuouVft-BiYh08SN.mjs +1 -0
- package/dist/{server-lock-iLcBw_q0-DB1Ahu2b.mjs → server-lock-iLcBw_q0-7VqZoW4r.mjs} +23 -16
- package/dist/{src-2ZRymDy2.mjs → src-DhuiHwcZ.mjs} +3 -3
- package/dist/{start-CR2-ryWz.mjs → start-CmL4qv8P.mjs} +2 -2
- package/dist/start-D06sB6Pa.mjs +1 -0
- package/dist/{write-project-skill-XZCJ5TEZ.mjs → write-project-skill-DNrA5OdY.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-UBjBavXu.mjs +0 -2
- package/dist/dist-B5JbDwWb.mjs +0 -1
- package/dist/init-CoL8N4la.mjs +0 -1
- package/dist/loader-eceKqMkc.mjs +0 -1
- package/dist/preview-DHkr2cX1.mjs +0 -1
- package/dist/public/assets/CodeMirrorPropInput-C2VECyjO.js +0 -3
- package/dist/public/assets/DocumentContext-f6XQqg_y.js +0 -35
- package/dist/public/assets/SourceEditor-DuPpY_T6.js +0 -1
- package/dist/repair-skills-NtsjF26d.mjs +0 -1
- package/dist/server-lock-GuuouVft-CXM0Fdz7.mjs +0 -1
- package/dist/start-D2aYJnFK.mjs +0 -1
|
@@ -411,43 +411,50 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
|
|
|
411
411
|
`):f},inlineCode(e,t,n){let r=e.value??``,i=e.data?.sourceFenceChar===`~`?`~`:"`",a=typeof e.data?.sourceFenceLength==`number`&&e.data.sourceFenceLength>0?e.data.sourceFenceLength:1,o=i==="`"?"`":`~`,s=a;for(;RegExp(`(^|[^${o}])${o.repeat(s)}([^${o}]|$)`).test(r);)s+=1;let c=i.repeat(s);/[^ \r\n]/.test(r)&&(e.data?.sourcePadded===!0||/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||r.startsWith(i)||r.endsWith(i))&&(r=` ${r} `);let l=`${c}${r}${c}`;return n.stack.includes(`tableCell`)?l.replace(/\|/g,`\\$&`):l},inlineMath:JQ,delete:YQ,heading(e,t,n,r){let i=e.data?.sourceStyle??`atx`,a=e.depth;if(i===`setext`&&(a===1||a===2)){let t=n.containerPhrasing(e,{...r,before:`
|
|
412
412
|
`,after:`
|
|
413
413
|
`}),i=e.data?.sourceUnderlineLength,o=typeof i==`number`&&i>=1?i:Math.max(t.length,3);return`${t}\n${(a===1?`=`:`-`).repeat(o)}`}let o=e.data?.sourceLeadingIndent,s=typeof o==`number`&&o>=1&&o<=3?` `.repeat(o):``,c=e.data?.sourceInteriorSpacing,l=typeof c==`number`&&c>=2?` `.repeat(c):` `,u=`#`.repeat(a),d=n.enter(`okAtxHeading`),f=n.containerPhrasing(e,{...r,before:`${u} `,after:`
|
|
414
|
-
`});d();let p=e.data?.sourceTrailingHashes;if(typeof p==`number`&&p>0){let e=`#`.repeat(p);return f?`${s}${u}${l}${f} ${e}`:`${s}${u} ${e}`}return f?`${s}${u}${l}${f}`:`${s}${u}`},list(e,t,n,r){let i=n.options.bullet||`-`,a=!!e.ordered,o=n.bulletCurrent,s=n.bulletLastUsed;if(!a){let t=e.data?.bulletMarker;(t===`-`||t===`*`||t===`+`)&&(n.bulletCurrent=t)}let c=e.children||[],l=[],u=a?e.data?.listMarkerDelimiter??`.`:null,d=e.start??1;for(let t=0;t<c.length;t++){let o=c[t],s=o.data?.sourceOrdinal,f=typeof s==`number`&&s>=0?s:d+t,p=a?`${f}${u}`:e.data?.bulletMarker??i,m=o.data?.sourceMarkerSpacing,h=typeof m==`number`&&m>=2&&m<=4?m:1,g=` `.repeat(h),_=p;o.checked===!0?_+=`${g}[${o.data?.sourceCheckboxChar===`X`?`X`:`x`}]`:o.checked===!1&&(_+=`${g}[ ]`);let v=o.data?.sourceContinuationIndent,y=p.length+h,b=typeof v==`number`&&v>=y&&v<=y+3?v:y,x=` `.repeat(b),S=o.checked===null||o.checked===void 0?g:` `,C=n.containerFlow(o,r).split(`
|
|
414
|
+
`});d();let p=e.data?.sourceTrailingHashes;if(typeof p==`number`&&p>0){let e=`#`.repeat(p);return f?`${s}${u}${l}${f} ${e}`:`${s}${u} ${e}`}return f?`${s}${u}${l}${f}`:`${s}${u}`},list(e,t,n,r){let i=n.options.bullet||`-`,a=!!e.ordered,o=n.bulletCurrent,s=n.bulletLastUsed;if(!a){let t=e.data?.bulletMarker;(t===`-`||t===`*`||t===`+`)&&(n.bulletCurrent=t)}let c=e.children||[],l=[],u=a?e.data?.listMarkerDelimiter??`.`:null,d=e.start??1;for(let t=0;t<c.length;t++){let o=c[t],s=o.data?.sourceOrdinal,f=typeof s==`number`&&s>=0?s:d+t,p=a?`${f}${u}`:e.data?.bulletMarker??i,m=o.data?.sourceMarkerSpacing,h=typeof m==`number`&&m>=2&&m<=4?m:1,g=` `.repeat(h),_=p;o.checked===!0?_+=`${g}[${o.data?.sourceCheckboxChar===`X`?`X`:`x`}]`:o.checked===!1&&(_+=`${g}[ ]`);let v=o.data?.sourceContinuationIndent,y=p.length+h,b=typeof v==`number`&&v>=y&&v<=y+3?v:y,x=` `.repeat(b),S=o.checked===null||o.checked===void 0?g:` `,C=o.children??[],w=C[0]?.type===`list`,T;if(w){let e=o.checked!==null&&o.checked!==void 0,t=n.containerFlow({...o,children:[C[0]]},r),i=C.slice(1),a=i.length?n.containerFlow({...o,children:i},r):``,s=t.split(`
|
|
415
|
+
`).map((t,n)=>n===0?e?`${x}${t}`:`${_}${S}${t}`:t&&`${x}${t}`).join(`
|
|
416
|
+
`),c=[];if(e?c.push(_,``,s):c.push(s),a){let e=a.split(`
|
|
417
|
+
`).map(e=>e&&`${x}${e}`).join(`
|
|
418
|
+
`);c.push(``,e)}T=c.join(`
|
|
419
|
+
`)}else T=n.containerFlow(o,r).split(`
|
|
415
420
|
`).map((e,t)=>t===0?`${_}${S}${e}`:e&&`${x}${e}`).join(`
|
|
416
|
-
`);l.push(
|
|
421
|
+
`);l.push(T)}n.bulletCurrent=o,n.bulletLastUsed=s;let f=e.spread?`
|
|
417
422
|
|
|
418
423
|
`:`
|
|
419
424
|
`;return l.join(f)},table(e,t,n,r){let i=n.enter(`table`),a=[],o=[],s=e.children??[];for(let e of s){let t=e.children??[],i=[],s=[];for(let e of t){let t=n.enter(`tableCell`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,{...r,before:` `,after:` `});a(),t(),i.push(o);let c=e.data?.sourcePadding;s.push(c&&typeof c.left==`number`&&typeof c.right==`number`?{left:c.left,right:c.right}:null)}a.push(i),o.push(s)}i();let c=e.align??[],l=e.data?.sourceDashCounts,u=a[0]?.length??0,d=a.slice(1).reduce((e,t)=>Math.max(e,t.length),0),f=Math.max(u,d,c.length);if(f===0)return console.warn(JSON.stringify({event:`table-serialize-dropped-empty`,rows:s.length})),``;let p=[];for(let e=0;e<f;e++){let t=c[e],n=``,r=``;t===`center`?(n=`:`,r=`:`):t===`left`?n=`:`:t===`right`&&(r=`:`);let i=l?.[e],a=typeof i==`number`&&i>=1?i:1;p.push(n+`-`.repeat(a)+r)}let m=(e,t)=>{let n=[];for(let r=0;r<f;r++){let i=e[r]??``,a=t[r]??{left:1,right:1};n.push(` `.repeat(a.left)+i+` `.repeat(a.right))}let r=v&&!v.leading?``:`|`,i=v&&!v.trailing?``:`|`;return`${r}${n.join(`|`)}${i}`},h=e.data?.sourceAlignmentPadding,g=Array.from({length:f},(e,t)=>{let n=h?.[t];return n&&typeof n.left==`number`&&typeof n.right==`number`?n:null}),_=e.data?.sourceOuterPipes,v=_&&f>=2&&a.every(e=>{let t=(e[0]??``).trim(),n=(e[f-1]??``).trim();return(_.leading||t.length>0)&&(_.trailing||n.length>0&&!n.endsWith(`\\`))})?_:null;if(a.length===0)return m(p,g);let y=[];y.push(m(a[0],o[0]??[])),y.push(m(p,g));for(let e=1;e<a.length;e++)y.push(m(a[e],o[e]??[]));return y.join(`
|
|
420
|
-
`)},mdxJsxFlowElement(e,t,n,r){let i=e,a=i.data?.sourceRaw;if(typeof a==`string`)return a;let o=i.data?.htmlBoundary;if(o&&typeof o.opener==`string`&&typeof o.closer==`string`){let e=n.containerFlow({type:`root`,children:i.children??[]},r);return`${o.opener}\n\n${e}\n\n${o.closer}`}let s=i.name??``,c=QQ(i.attributes??[]);return!i.children||i.children.length===0?s?c?`<${s} ${c} />`:`<${s} />`:``:XQ({...i,attributes:(i.attributes??[]).map(e$)},t,n,r)},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=u$(n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),r,`==`),o+=i.move(`==`),a(),o},comment(e,t,n,r){let i=e.data?.sourceForm,a=i===`html`?`<!-- `:`%%`,o=i===`html`?` -->`:`%%`,s=n.createTracker(r),c=n.enter(`comment`),l=s.move(a);return l+=n.containerPhrasing(e,{before:l,after:o,...s.current()}),l+=s.move(o),c(),l},commentBlock(e,t,n,r){let i=n.createTracker(r),a=n.enter(`commentBlock`),o=e.children??[],s=e.data?.sourceForm,c=e.data?.sourceLayout,l=o.length===1&&o[0]?.type===`paragraph`;if(s===`html`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`<!-- `,after:` -->`,...i.current()});return a(),`<!-- ${t} -->`}if(c===`inline`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`%% `,after:` %%`,...i.current()});return a(),`%% ${t} %%`}let u=n.containerFlow(e,i.current());return a(),`%%\n\n${u}\n\n%%`},mdxJsxTextElement(e){let t=e.data?.sourceRaw;if(typeof t==`string`)return t;let n=e.name??``,r=QQ(e.attributes??[]);return r?`<${n} ${r} />`:`<${n}/>`},rawMdxFallback(e){return e.value??``},blockquote(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.containerFlow(e,a.current());i();let s=e.data?.sourceMarkerSpacings,c=0;return n.indentLines(o,(e,t,n)=>{if(n)return`>`;let r=s?.[c++];return r===`none`||r===0?`>${e}`:typeof r==`number`&&r>=2&&!e.startsWith(` `)?`>${` `.repeat(r)}${e}`:`> ${e}`})}};function QQ(e){let t=[];for(let n of e){if(n.type===`mdxJsxExpressionAttribute`){t.push(`{${n.value}}`);continue}let e=n.name;if(n.value===null||n.value===void 0){t.push(e);continue}if(typeof n.value==`string`){n.value.includes(`"`)?t.push(`${e}={${$Q(n.value)}}`):t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function $Q(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function e$(e){return e.type===`mdxJsxAttribute`&&typeof e.value==`string`&&e.value.includes(`"`)?{type:`mdxJsxAttribute`,name:e.name,value:{type:`mdxJsxAttributeValueExpression`,value:$Q(e.value)}}:e}function t$(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function n$(e){if(!e)return``;let t=0,n=!0;for(let r of e)r===`(`?t++:r===`)`&&(t--,t<0&&(n=!1));return t!==0&&(n=!1),n?e:e.replace(/[\\()]/g,`\\$&`)}function r$(e){return e.replace(/(?<!\\)&(?=(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z][A-Za-z0-9]*);)/g,(e,t)=>i$(t)?e:`\\${e}`)}function i$(e){if(e.charCodeAt(0)!==35)return!1;let t=e[1]===`x`||e[1]===`X`?Number.parseInt(e.slice(2),16):Number.parseInt(e.slice(1),10);return t===9||t===10||t===11||t===12||t===13||t===32}function a$(e,t,n){let r=e.unsafe;e.unsafe=r.filter(e=>!(e.character===`&`&&e.after===`[#A-Za-z]`||e.character===`<`||e.character===`[`||e.character===`(`||e.character==="`"||(e.character===`*`||e.character===`_`||e.character===`~`)&&e.inConstruct===`phrasing`||e.character===`=`&&e.atBreak===!0||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`))
|
|
425
|
+
`)},mdxJsxFlowElement(e,t,n,r){let i=e,a=i.data?.sourceRaw;if(typeof a==`string`)return a;let o=i.data?.htmlBoundary;if(o&&typeof o.opener==`string`&&typeof o.closer==`string`){let e=n.containerFlow({type:`root`,children:i.children??[]},r);return`${o.opener}\n\n${e}\n\n${o.closer}`}let s=i.name??``,c=QQ(i.attributes??[]);return!i.children||i.children.length===0?s?c?`<${s} ${c} />`:`<${s} />`:``:XQ({...i,attributes:(i.attributes??[]).map(e$)},t,n,r)},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=u$(n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),r,`==`),o+=i.move(`==`),a(),o},comment(e,t,n,r){let i=e.data?.sourceForm,a=i===`html`?`<!-- `:`%%`,o=i===`html`?` -->`:`%%`,s=n.createTracker(r),c=n.enter(`comment`),l=s.move(a);return l+=n.containerPhrasing(e,{before:l,after:o,...s.current()}),l+=s.move(o),c(),l},commentBlock(e,t,n,r){let i=n.createTracker(r),a=n.enter(`commentBlock`),o=e.children??[],s=e.data?.sourceForm,c=e.data?.sourceLayout,l=o.length===1&&o[0]?.type===`paragraph`;if(s===`html`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`<!-- `,after:` -->`,...i.current()});return a(),`<!-- ${t} -->`}if(c===`inline`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`%% `,after:` %%`,...i.current()});return a(),`%% ${t} %%`}let u=n.containerFlow(e,i.current());return a(),`%%\n\n${u}\n\n%%`},mdxJsxTextElement(e){let t=e.data?.sourceRaw;if(typeof t==`string`)return t;let n=e.name??``,r=QQ(e.attributes??[]);return r?`<${n} ${r} />`:`<${n}/>`},rawMdxFallback(e){return e.value??``},blockquote(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.containerFlow(e,a.current());i();let s=e.data?.sourceMarkerSpacings,c=0;return n.indentLines(o,(e,t,n)=>{if(n)return`>`;let r=s?.[c++];return r===`none`||r===0?`>${e}`:typeof r==`number`&&r>=2&&!e.startsWith(` `)?`>${` `.repeat(r)}${e}`:`> ${e}`})}};function QQ(e){let t=[];for(let n of e){if(n.type===`mdxJsxExpressionAttribute`){t.push(`{${n.value}}`);continue}let e=n.name;if(n.value===null||n.value===void 0){t.push(e);continue}if(typeof n.value==`string`){n.value.includes(`"`)?t.push(`${e}={${$Q(n.value)}}`):t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function $Q(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function e$(e){return e.type===`mdxJsxAttribute`&&typeof e.value==`string`&&e.value.includes(`"`)?{type:`mdxJsxAttribute`,name:e.name,value:{type:`mdxJsxAttributeValueExpression`,value:$Q(e.value)}}:e}function t$(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function n$(e){if(!e)return``;let t=0,n=!0;for(let r of e)r===`(`?t++:r===`)`&&(t--,t<0&&(n=!1));return t!==0&&(n=!1),n?e:e.replace(/[\\()]/g,`\\$&`)}function r$(e){return e.replace(/(?<!\\)&(?=(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z][A-Za-z0-9]*);)/g,(e,t)=>i$(t)?e:`\\${e}`)}function i$(e){if(e.charCodeAt(0)!==35)return!1;let t=e[1]===`x`||e[1]===`X`?Number.parseInt(e.slice(2),16):Number.parseInt(e.slice(1),10);return t===9||t===10||t===11||t===12||t===13||t===32}function a$(e,t,n){let r=e.unsafe;e.unsafe=r.filter(e=>!(e.character===`&`&&e.after===`[#A-Za-z]`||e.character===`<`||e.character===`[`||e.character===`(`||e.character===`!`&&e.after===`\\[`&&e.inConstruct===`phrasing`||e.character===`@`&&e.before===`[+\\-.\\w]`||e.character===`{`&&Array.isArray(e.inConstruct)&&e.inConstruct.includes(`phrasing`)||e.character==="`"||(e.character===`*`||e.character===`_`||e.character===`~`)&&e.inConstruct===`phrasing`||e.character===`=`&&e.atBreak===!0||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`)),e.unsafe=e.unsafe.map(e=>{if(e.character!==`)`||e.atBreak!==!0||e.before!==`\\d+`||e.after!==void 0)return e;let t={...e,after:`(?:[ \r
|
|
426
|
+
]|$)`};return delete t._compiled,t});let i;try{i=e.safe(t,n)}finally{e.unsafe=r}return r$(l$(i,n))}function o$(e){if(Number.isNaN(e))return`ws`;let t=HN(e);return t===1?`ws`:t===2?`punct`:`other`}function s$(e,t,n){let r=o$(t),i=o$(n),a=i!==`ws`&&(i===`other`||r!==`other`),o=r!==`ws`&&(r===`other`||i!==`other`);return e===`_`?a&&(!o||r===`punct`)||o&&(!a||i===`punct`):a||o}function c$(e,t,n){let r=t;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;if(r<e.length)return e[r]===`
|
|
421
427
|
`||e[r]===`\r`;let i=n.after.charCodeAt(0);return Number.isNaN(i)||i===10||i===13}function l$(e,t){let n=``,r=0;for(;r<e.length;){let i=e.charAt(r);if(i===`\\`){n+=e.slice(r,r+2),r+=2;continue}if(i===`*`||i===`_`||i===`~`||i===`=`){let a=r+1;for(;a<e.length&&e.charAt(a)===i;)a++;let o=r===0?t.before.charCodeAt(t.before.length-1):e.charCodeAt(r-1);if(i===`=`)n+=(Number.isNaN(o)||o===10||o===13)&&c$(e,a,t)?`\\${e.slice(r,a)}`:e.slice(r,a);else{let s=a<e.length?e.charCodeAt(a):t.after.charCodeAt(0);n+=s$(i,o,s)?`\\${i}`.repeat(a-r):e.slice(r,a)}r=a;continue}n+=i,r+=1}return n}function u$(e,t,n){let r=n.startsWith(`_`)?`_`:`*`,i=t.before??``,a=t.after??``,o=e,s=o.charCodeAt(0);d$(i.charCodeAt(i.length-1),s,r)&&(o=f$(s)+o.slice(1));let c=o.charCodeAt(o.length-1);return d$(a.charCodeAt(0),c,r)&&(o=o.slice(0,-1)+f$(c)),o}function d$(e,t,n){return!(HN(t)!==1||n===`_`&&HN(e)===void 0)}function f$(e){return`&#x${e.toString(16).toUpperCase()};`}function p$(e,t,n,r){let i=e.value??``,a=e.data?.sourceDelimiter,o=typeof a==`string`&&/^\$+$/.test(a)?a.length:2;for(o===1&&!h$(i,r)&&(o=2);RegExp(`(^|[^$])${`\\$`.repeat(o)}([^$]|$)`).test(i);)o++;let s=`$`.repeat(o);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` ${i} `);let c=-1;for(;++c<n.unsafe.length;){let e=n.unsafe[c];if(!e.atBreak)continue;let t=n.compilePattern(e),r;for(;(r=t.exec(i))!==null;){let e=r.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=`${i.slice(0,e)} ${i.slice(r.index+1)}`}}return s+i+s}function m$(e,t,n,r){let i=e.data?.sourceDelimiter===`~`?`~`:`~~`,a=n.createTracker(r),o=n.enter(`strikethrough`),s=a.move(i);return s+=u$(n.containerPhrasing(e,{...a.current(),before:s,after:`~`}),r,i),s+=a.move(i),o(),s}function h$(e,t){return!(e.length===0||!/^\S/.test(e)||!/\S$/.test(e)||/[$\r\n]/.test(e)||e.endsWith(`\\`)||/\\[!-/:-@[-`{-~]/.test(e)||/^\d/.test(t.after)||t.before.endsWith(`\\`))}function g$(e){if(!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KiB`,`MiB`,`GiB`,`TiB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(1).replace(/\.0$/,``)} ${t[r]}`}var _$=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};freshnessHolder={checker:void 0};constructor(e){this.schema=gb(e.extensions),this.handlers=D$(this.schema,this.parseCtx),this.freshnessHolder.checker=e.deriveStructuralFreshness?RJ({parse:e=>this.parseWithFallback(e)}):void 0;let{nodeHandlers:t,markHandlers:n}=O$(this.schema,this.freshnessHolder);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=PQ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=FQ({toMarkdownHandlers:ZQ})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return VQ(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?HQ(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?HY(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e,t){let n;try{n=this.schema.nodeFromJSON(e)}catch(t){let n=`MarkdownManager.serialize() failed: schema rejected JSONContent (type=${e.type}, childCount=${e.content?.length??0})`;throw Error(n,{cause:t})}let r=this.freshnessHolder.checker;t?.skipFreshnessDerive&&(this.freshnessHolder.checker=void 0);try{return UQ(n,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}finally{this.freshnessHolder.checker=r}}};const v$=AY();function y$(e,t){let n=new Map;for(let e of t)n.set(e.name,e);let r={};for(let t of e){if(t.type===`mdxJsxExpressionAttribute`)continue;let e=t.name,i=n.get(e);if(t.value===null||t.value===void 0){r[e]=!0;continue}if(typeof t.value==`string`){if(i?.type===`number`){let n=Number(t.value);r[e]=Number.isNaN(n)?t.value:n}else i?.type===`boolean`?r[e]=t.value===`true`:r[e]=t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function b$(e){let t=!1;return e.descendants(e=>t||e.type.name===`jsxInline`?!1:e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function x$(e,t){return e.attrs.sourceDirty||b$(e)?!0:t?t.isDiverged(e.toJSON()):!1}function S$(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0?!0:t.every(e=>e.type===`text`&&e.value===``)}function C$(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),t.sourcePadded===!0&&(n.sourcePadded=!0),Object.keys(n).length===0?e:{...e,data:n}}function w$(e,t){if(e.length===0)return C$({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return C$({type:`inlineCode`,value:e.map(e=>e.value).join(``)},t);if(e.length===1&&`children`in e[0]){let n=e[0];return{...n,children:[w$(n.children,t)]}}return C$({type:`inlineCode`,value:T$(e)},t)}function T$(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=T$(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const E$=Vc;function D$(e,t){let n=e.nodes,r=e.marks,i={};n.paragraph&&(i.paragraph=(e,t,r)=>{let i=r.all(e).flat(),a=i.some(e=>e?.isBlock&&!e?.isInline),o=i.some(e=>e?.isInline||e?.isText||e?.isTextblock);if(a&&!o)return i.length===1?i[0]:i;if(a&&o){let e=i.filter(e=>!e?.isBlock||e?.isInline),t=i.filter(e=>e?.isBlock&&!e?.isInline),r=[],a=n.paragraph.createAndFill(null,e.length>0?e:null);return a&&r.push(a),r.push(...t),r.length===1?r[0]:r}return n.paragraph.createAndFill(null,i.length>0?i:null)}),n.blockquote&&(i.blockquote=jR(n.blockquote,e=>({sourceMarkerSpacings:e.data?.sourceMarkerSpacings??null}))),n.tableCell&&(i.tableCell=(e=>(t,r,i)=>{let a=i.all(t).flat();if(a.length>0&&n.paragraph){let t=n.paragraph.create(null,a);return e.createAndFill(null,[t])}return e.createAndFill(null,null)})(n.tableCell)),n.tableRow&&(i.tableRow=jR(n.tableRow)),n.table&&n.tableRow&&n.tableCell&&(i.table=(e,t,r)=>{let i=e.align??[],a=e.children??[],o=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type!==`tableRow`)continue;let s=t.children??[],c=[];for(let t=0;t<s.length;t++){let a=s[t];if(a.type!==`tableCell`)continue;let o=r.all(a).flat(),l=o.length>0&&n.paragraph?[n.paragraph.create(null,o)]:null,u=i[t]??null,d=e===0&&n.tableHeader?n.tableHeader:n.tableCell,f=a.data?.sourcePadding??null,p=d.createAndFill({align:u,sourcePadding:f},l);p&&c.push(p)}let l=n.tableRow.createAndFill(null,c.length>0?c:null);l&&o.push(l)}let s=e.data?.sourceDashCounts??null,c=e.data?.sourceOuterPipes??null,l=e.data?.sourceAlignmentPadding??null;return n.table.createAndFill({sourceDashCounts:s,sourceOuterPipes:c,sourceAlignmentPadding:l},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=qQ(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r})},n.imageReference?i.imageReference=e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):i.imageReference=e=>n.image.createAndFill({src:``,alt:e.alt??null,title:null})),r.escapeMark&&(i.text=t=>{let n=t.value??``,i=typeof t.data?.sourceRaw==`string`?t.data.sourceRaw:null;if(!n&&!i)return null;if(i){let t=n.replaceAll(`\xA0`,` `);return r.sourceLiteral?e.text(t,[r.sourceLiteral.create({sourceRaw:i})]):e.text(t)}let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n.replaceAll(`\xA0`,` `));let s=[...(a??[]).map(e=>({kind:`escape`,offset:e.offset,length:1})),...(o??[]).map(e=>({kind:`entity`,offset:e.offset,length:e.length,raw:e.raw}))];s.sort((e,t)=>e.offset-t.offset);let c=[];for(let e of s){let t=c[c.length-1];e.kind===`entity`&&t?.kind===`entity`&&t.offset+t.length===e.offset&&YK(t.raw)!==null&&KK(e.raw)?c[c.length-1]={kind:`entity`,offset:t.offset,length:t.length+e.length,raw:t.raw+e.raw}:c.push(e)}let l=[],u=0;for(let t of c){if(t.offset>u){let r=n.slice(u,t.offset).replaceAll(`\xA0`,` `);r&&l.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length).replaceAll(`\xA0`,` `);if(i)if(t.kind===`escape`)l.push(e.text(i,[r.escapeMark.create()]));else if(r.sourceLiteral){let n=YK(t.raw);l.push(e.text(n??i,[r.sourceLiteral.create({sourceRaw:t.raw})]))}else l.push(e.text(i));u=t.offset+t.length}}if(u<n.length){let t=n.slice(u).replaceAll(`\xA0`,` `);t&&l.push(e.text(t))}return l.length===1?l[0]:l}),r.code&&(i.inlineCode=t=>e.text(t.value,[r.code.create({sourceFenceChar:t.data?.sourceFenceChar??"`",sourceFenceLength:typeof t.data?.sourceFenceLength==`number`?t.data.sourceFenceLength:1,sourcePadded:t.data?.sourcePadded===!0})]));let a=r.strike??r.delete;if(a&&(i.delete=MR(a,e=>({sourceDelimiter:e.data?.sourceDelimiter===`~`?`~`:`~~`}))),r.highlight&&(i.mark=MR(r.highlight)),r.comment&&(i.comment=MR(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=jR(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=MR(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=MR(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=jR(n.heading,e=>({level:e.depth,headingStyle:e.data?.sourceStyle??`atx`,sourceTrailingHashes:e.data?.sourceTrailingHashes??null,sourceUnderlineLength:e.data?.sourceUnderlineLength??null,sourceContiguousNext:e.data?.sourceContiguousNext??!1,sourceLeadingIndent:e.data?.sourceLeadingIndent??null,sourceInteriorSpacing:e.data?.sourceInteriorSpacing??null}))),n.codeBlock&&(i.code=t=>{let r=t.value?[e.text(t.value)]:[];return n.codeBlock.createAndFill({language:t.lang??null,meta:t.meta??null,fenceDelimiter:t.data?.sourceFenceChar??"`",fenceLength:t.data?.sourceFenceLength??3,sourceStyle:t.data?.sourceStyle??`fenced`,sourceClosingFenceLength:t.data?.sourceClosingFenceLength??null,sourceFenceIndent:t.data?.sourceFenceIndent??null,sourceInfoPadding:t.data?.sourceInfoPadding??null,sourceIndents:t.data?.sourceIndents??null},r)}),n.thematicBreak&&(i.thematicBreak=e=>n.thematicBreak.createAndFill({sourceRaw:e.data?.sourceRaw??`---`})),n.hardBreak&&(i.break=e=>n.hardBreak.createAndFill({hardBreakStyle:e.data?.sourceStyle??`spaces`,sourceRaw:e.data?.sourceRaw??null})),n.list&&(i.list=jR(n.list,e=>({ordered:!!e.ordered,start:e.start??1,spread:!!e.spread,bulletMarker:e.data?.bulletMarker??null,listMarkerDelimiter:e.data?.listMarkerDelimiter??null}))),n.listItem&&(i.listItem=jR(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread,sourceMarkerSpacing:e.data?.sourceMarkerSpacing??null,sourceOrdinal:e.data?.sourceOrdinal??null,sourceCheckboxChar:e.data?.sourceCheckboxChar??null,sourceContinuationIndent:e.data?.sourceContinuationIndent??null}))),r.link){let t=r.sourceLiteral;i.link=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[](${n.url??``})`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.url??``,title:n.title??null,linkStyle:n.data?.sourceStyle??`inline`,refLabel:null,sourceUrlForm:n.data?.sourceUrlForm??null,sourceTitleMarker:n.data?.sourceTitleMarker??null});return o.map(e=>e.mark(s.addToSet(e.marks)))},i.linkReference=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[${n.label??``}][${n.identifier??``}]`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:``,title:null,linkStyle:n.referenceType??`shortcut`,refLabel:n.label??n.identifier??null});return o.map(e=>e.mark(s.addToSet(e.marks)))}}n.htmlBlock&&(i.html=e=>n.htmlBlock.createAndFill({content:e.value??``}));let o=n.linkDefinition??n.linkRefDef;if(o){let e=!!o.spec.attrs?.url,t=!!o.spec.attrs?.href,n=!!o.spec.attrs?.identifier,r=!!o.spec.attrs?.sourceLayout,a=!!o.spec.attrs?.sourceTitleMarker;i.definition=i=>{let s={title:i.title??null};return n&&(s.identifier=i.identifier??``),s.label=i.label??i.identifier??``,e?s.url=i.url??``:t&&(s.href=i.url??``),r&&(s.sourceLayout=i.data?.sourceLayout??null),a&&(s.sourceTitleMarker=i.data?.sourceTitleMarker??null),o.createAndFill(s)}}if(n.jsxComponent){let r=e=>{if(e&&typeof e==`object`&&`sourceRaw`in e){let t=e.sourceRaw;if(typeof t==`string`)return t}};i.mdxJsxFlowElement=(e,i,a)=>{let o=e.name??``,s=v$.getOrWildcard(o),c=y$(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=qQ(e,t.current.sourcePath);n!==e&&(c.src=n,c.sourceUrl=e)}let l=a.all(e).flat();return n.jsxComponent.createAndFill({componentName:o,kind:`element`,attributes:e.attributes,sourceRaw:r(e.data)??``,sourceDirty:!1,props:c},l.length?l:void 0)};let a=(e,t)=>{let n=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return n&&typeof n.value==`string`?n.value:null};i.mdxJsxTextElement=t=>{if(t.name===`InlineMath`&&n.mathInline){let e=a(t,`formula`)??``,r=a(t,`id`);return n.mathInline.create({formula:e,id:r??null})}if(t.name===`Tag`&&n.tag){let e=a(t,`value`)??``;return n.tag.create({value:e})}if(n.jsxInline){let i=r(t.data)??``;return n.jsxInline.createAndFill({},i?[e.text(i)]:null)}return n.jsxComponent.createAndFill({sourceRaw:r(t.data)??``})},i.mdxFlowExpression=e=>{let t=r(e.data)??`{${e.value??``}}`;return n.jsxComponent.createAndFill({kind:`expression`,sourceRaw:t,sourceDirty:!1})},i.mdxTextExpression=t=>{let n=r(t.data)??`{${t.value??``}}`;return e.text(n)}}return n.wikiLink&&(i.wikiLink=e=>n.wikiLink.createAndFill({target:e.data?.target??``,alias:e.data?.alias??null,anchor:e.data?.anchor??null,sourceTarget:e.data?.sourceTarget??null,sourceAnchor:e.data?.sourceAnchor??null,sourceAlias:e.data?.sourceAlias??null})),n.tag&&(i.tag=e=>n.tag.createAndFill({value:e.value})),n.wikiLinkEmbed&&(i.wikiLinkEmbed=(i,a)=>{let o=i.data?.target??``,s=i.data?.alias??null,c=i.data?.anchor??null,l=uq(o),{resolveEmbed:u,sourcePath:d}=t.current,f=u&&d?u(o,d)??null:null,p=f?`/${f}`:o,m=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(m&&E$.has(l)&&n.jsxComponent&&v$.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,alt:s??o,target:o,anchor:c,alias:s}});if(m&&Hc.has(l)&&n.jsxComponent&&v$.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&Wc.has(l)&&n.jsxComponent&&v$.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&Gc.has(l)&&n.jsxComponent&&v$.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&d?e(o,d)??null:null,i=r===null?null:g$(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,target:o,anchor:c,alias:s,size:i}})}let h=s||(c?`${o}#${c}`:o);if(r.link){let t=r.link.create({href:p,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s});return e.text(h,[t])}throw Error("[wikiLinkEmbed handler] schema lacks `link` mark — cannot dispatch without violating the STOP rule against emitting PM wikiLinkEmbed server-side")}),n.mathInline&&(i.inlineMath=e=>n.mathInline.create({formula:e.value??``,sourceDelimiter:e.data?.sourceDelimiter??null})),i.math||=t=>{let r=t.value==null?`«unknown:${t.type}»`:t.value;return n.rawMdxFallback?(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled block mdast: ${t.type}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled block mdast: ${t.type}`},r?[e.text(r)]:null)):null},i.inlineMath||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled inline mdast: ${t.type}`})),t.value==null?e.text(`«unknown:${t.type}»`):e.text(t.value)),n.footnoteReference?i.footnoteReference=e=>n.footnoteReference.create({identifier:e.identifier,label:e.label??e.identifier}):i.footnoteReference||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteReference`,reason:`FootnoteReference extension missing — recovering [^id] source`})),e.text(`[^${t.label??t.identifier}]`)),n.footnoteDefinition?i.footnoteDefinition=jR(n.footnoteDefinition,e=>{let t=e;return{identifier:t.identifier,label:t.label??t.identifier}}):i.footnoteDefinition||=t=>{console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteDefinition`,reason:`FootnoteDefinition extension missing — recovering [^id]: marker`}));let r=`[^${t.label??t.identifier}]: `;return n.paragraph?n.paragraph.create(null,e.text(r)):null},i.rawMdxFallbackMdast=t=>{if(!n.rawMdxFallback)return null;let r=t.position?{start:t.position.start?.offset??0,end:t.position.end?.offset??0}:{start:0,end:0};return console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.originalType,reason:`Unhandled mdast: ${t.originalType}`,unresolvedPosition:t.unresolvedPosition??!1})),n.rawMdxFallback.createAndFill({reason:`Unhandled mdast: ${t.originalType}`,originalSpan:r},t.value?[e.text(t.value)]:null)},i}function O$(e,t){let n={},r={},i=e.nodes,a=e.marks;i.paragraph&&(n.paragraph=LR(`paragraph`)),i.blockquote&&(n.blockquote=LR(`blockquote`,e=>{let t=e.attrs.sourceMarkerSpacings,n={};return Array.isArray(t)&&t.length>0&&(n.sourceMarkerSpacings=t),Object.keys(n).length>0?{data:n}:{}})),i.heading&&(n.heading=LR(`heading`,e=>({depth:e.attrs.level,data:{sourceStyle:e.attrs.headingStyle,sourceTrailingHashes:e.attrs.sourceTrailingHashes??void 0,sourceUnderlineLength:e.attrs.sourceUnderlineLength??void 0,sourceContiguousNext:e.attrs.sourceContiguousNext===!0?!0:void 0,sourceLeadingIndent:e.attrs.sourceLeadingIndent??void 0,sourceInteriorSpacing:e.attrs.sourceInteriorSpacing??void 0}}))),i.codeBlock&&(n.codeBlock=e=>{let t=e.attrs.sourceStyle===`indented`?`indented`:`fenced`;return{type:`code`,lang:t===`indented`?null:e.attrs.language??null,meta:t===`indented`?null:e.attrs.meta??null,value:e.textContent??``,data:{sourceFenceChar:e.attrs.fenceDelimiter,sourceFenceLength:e.attrs.fenceLength,sourceStyle:t,sourceClosingFenceLength:e.attrs.sourceClosingFenceLength??void 0,sourceFenceIndent:e.attrs.sourceFenceIndent??void 0,sourceInfoPadding:e.attrs.sourceInfoPadding??void 0,sourceIndents:e.attrs.sourceIndents??void 0}}}),i.thematicBreak&&(n.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),i.hardBreak&&(n.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle,...typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0?{sourceRaw:e.attrs.sourceRaw}:{}}})),i.list&&(n.list=LR(`list`,e=>({ordered:e.attrs.ordered??!1,start:e.attrs.ordered?e.attrs.start??1:null,spread:e.attrs.spread??!1,data:{bulletMarker:e.attrs.bulletMarker,listMarkerDelimiter:e.attrs.listMarkerDelimiter}}))),i.listItem&&(n.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&S$(r[0])?r.slice(1):r,a={};return typeof e.attrs.sourceMarkerSpacing==`number`&&(a.sourceMarkerSpacing=e.attrs.sourceMarkerSpacing),typeof e.attrs.sourceOrdinal==`number`&&(a.sourceOrdinal=e.attrs.sourceOrdinal),e.attrs.sourceCheckboxChar===`X`&&(a.sourceCheckboxChar=`X`),typeof e.attrs.sourceContinuationIndent==`number`&&(a.sourceContinuationIndent=e.attrs.sourceContinuationIndent),{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,...Object.keys(a).length>0?{data:a}:{},children:i}}),i.table&&(n.table=(e,t,n)=>{let r=n.all(e),i=[],a=e.firstChild;a&&a.forEach(e=>{let t=e.attrs.align;i.push(t===`left`||t===`right`||t===`center`?t:null)});let o=r.filter(e=>e.type===`tableRow`),s=e.attrs.sourceDashCounts,c={};Array.isArray(s)&&s.length>0&&(c.sourceDashCounts=s);let l=e.attrs.sourceOuterPipes;typeof l==`object`&&l&&typeof l.leading==`boolean`&&typeof l.trailing==`boolean`&&(c.sourceOuterPipes=l);let u=e.attrs.sourceAlignmentPadding;Array.isArray(u)&&u.length>0&&(c.sourceAlignmentPadding=u);let d=Object.keys(c).length>0?c:void 0,f={type:`table`,align:i,children:o};return d&&(f.data=d),f}),i.tableRow&&(n.tableRow=LR(`tableRow`));let o=(e,t)=>{let n={type:`tableCell`,children:uJ(t)},r=e.attrs.sourcePadding;return typeof r==`object`&&r&&typeof r.left==`number`&&typeof r.right==`number`&&(n.data={sourcePadding:r}),n};if(i.tableCell&&(n.tableCell=(e,t,n)=>o(e,n.all(e))),i.tableHeader&&(n.tableHeader=(e,t,n)=>o(e,n.all(e))),i.image&&(n.image=e=>({type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title})),i.imageReference&&(n.imageReference=e=>{let t=e.attrs.label??``,n=e.attrs.identifier??t;return{type:`imageReference`,alt:e.attrs.alt??``,identifier:n,label:t||n,referenceType:e.attrs.referenceType??`shortcut`}}),i.htmlBlock&&(n.htmlBlock=e=>({type:`html`,value:e.attrs.content})),i.linkDefinition??i.linkRefDef){let e=i.linkDefinition?`linkDefinition`:`linkRefDef`;n[e]=e=>{let t={},n=e.attrs.sourceLayout;(n===`multiline`||n===`inline`)&&(t.sourceLayout=n);let r=e.attrs.sourceTitleMarker;(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r);let i={type:`definition`,identifier:e.attrs.identifier??e.attrs.label??``,label:e.attrs.label??e.attrs.identifier??``,url:e.attrs.url??e.attrs.href??``,title:e.attrs.title};return Object.keys(t).length>0&&(i.data=t),i}}if(i.jsxComponent&&(n.jsxComponent=(e,n,r)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let i=e.attrs.componentName||null,a=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!x$(e,t.checker)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:i,attributes:a,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:v$.getOrWildcard(i??`*`).serialize(e,{all:e=>r.all(e),registry:v$,serializeChildren:()=>{throw Error(`SerializeContext.serializeChildren is not available in the PM→mdast handler. Compat descriptors that need markdown-byte body rendering must emit a marker mdast node and let the to-markdown handler render the body via state.containerFlow.`)}})}),i.rawMdxFallback&&(n.rawMdxFallback=e=>{let t=e.textContent??``,n=typeof e.attrs.reason==`string`?e.attrs.reason:``,r=e.attrs.originalSpan;return{type:`rawMdxFallback`,value:t,data:{reason:n,originalSpan:r&&typeof r==`object`&&`start`in r&&`end`in r?{start:Number(r.start)||0,end:Number(r.end)||0}:{start:0,end:0}}}}),i.jsxInline&&(n.jsxInline=e=>{let t=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:null,attributes:[],children:[],data:{sourceRaw:String(t)}}}),i.mathInline&&(n.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;if(typeof n==`string`&&n.length>0)return{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]};let r=e.attrs.sourceDelimiter;return{type:`inlineMath`,value:t,...typeof r==`string`&&r.length>0?{data:{sourceDelimiter:r}}:{}}}),i.wikiLink&&(n.wikiLink=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLink`,value:i,data:{target:t,anchor:n,alias:r,sourceTarget:typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,sourceAnchor:typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,sourceAlias:typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null},children:[{type:`text`,value:i}]}}),i.tag&&(n.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),i.wikiLinkEmbed&&(n.wikiLinkEmbed=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),a.emphasis&&(r.emphasis=RR(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.strong&&(r.strong=RR(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.code&&(r.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return w$(n,{sourceFenceChar:r,sourceFenceLength:i,sourcePadded:e.attrs.sourcePadded===!0?!0:void 0})}),a.strike??a.delete){let e=a.strike?`strike`:`delete`;r[e]=RR(`delete`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter===`~`?`~`:`~~`}}))}return a.highlight&&(r.highlight=RR(`mark`)),a.comment&&(r.comment=RR(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),i.commentBlock&&(n.commentBlock=LR(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),i.footnoteReference&&(n.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),i.footnoteDefinition&&(n.footnoteDefinition=LR(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),a.link&&(r.link=(e,t,n)=>{if(e.attrs.sourceForm===`wikiembed`){let t=typeof e.attrs.target==`string`&&e.attrs.target.length>0?e.attrs.target:e.attrs.href??``,r=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,i=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,a=i||(r?`${t}#${r}`:t),o=n.map(e=>`value`in e&&typeof e.value==`string`?e.value:``).join(``);return o!==a&&o.trim().length>0&&!o.includes(`]]`)&&(i=o,a=o),{type:`wikiLinkEmbed`,value:a,data:{target:t,anchor:r,alias:i},children:[{type:`text`,value:a}]}}let r=e.attrs.linkStyle;if(r===`autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`autolink`}};if(r===`gfm-autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`gfm-autolink`}};if(r===`inline`||!r){let t={};e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let r=e.attrs.sourceTitleMarker;return(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),{type:`link`,url:e.attrs.href??``,title:e.attrs.title??null,children:n,...Object.keys(t).length>0?{data:t}:{}}}return{type:`linkReference`,identifier:(e.attrs.refLabel??``).toLowerCase(),label:e.attrs.refLabel,referenceType:r,children:n}}),a.escapeMark&&(r.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data??={},t.data.escapedChars??=[];for(let e=0;e<t.value.length;e++)t.data.escapedChars.push({offset:e,char:t.value[e]})}return n.length===1?n[0]:n}),a.sourceLiteral&&(r.sourceLiteral=(e,t,n)=>{let r=typeof e.attrs.sourceRaw==`string`?e.attrs.sourceRaw:``;if(n.length===1&&n[0]?.type===`text`){let e=n[0],t=r||e.value;return ZK(t,e.value)&&(e.data??={},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:n,markHandlers:r}}const k$=/\p{M}+/gu,A$=/[^\p{L}\p{N}]+/gu,j$=/^-+|-+$/g;function M$(e){return e.trim().normalize(`NFKD`).replace(k$,``).toLowerCase().replace(A$,`-`).replace(j$,``)}function N$(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function P$(e,t){let n=M$(e);return n?N$(n,t):``}const F$=new Set([`img`,`video`,`audio`,`mark`]);new Map(OY.flatMap(e=>e.surface===`compat`&&F$.has(e.rendersAs)?[[e.name,e]]:[])),WF(`<>`);const I$=DV(),L$=GB(),R$=KB();function z$(){return OY.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function B$(){return z$().filter(e=>V$(e)!==`fence`)}function V$(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function H$(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:V$(e)}}function U$(e){if(e.hidden!==!0&&e.type!==`reactnode`){if(`defaultValue`in e&&e.defaultValue!==void 0)return e.defaultValue;if(e.type===`enum`)return e.enumValues[0];if(e.type===`string`)return``;if(e.type===`number`)return 0;if(e.type===`boolean`)return!1}}function W$(e,t){return!(e.omitOnDefault===!0&&`defaultValue`in e&&Object.is(e.defaultValue,t)||e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&t===``)}function G$(e){let t=[];for(let n of e.props){let e=U$(n);e!==void 0&&W$(n,e)&&t.push(VJ(n.name,e))}return t}function K$(e){return $z(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[I$],mdastExtensions:[L$]}).children}function q$(e){let t=V$(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
|
|
422
428
|
A --> B`};else{let r=G$(e),i=t===`jsx-block`?K$(e):[];n={type:`mdxJsxFlowElement`,name:e.name,attributes:r,children:i}}return GP({type:`root`,children:[n]},{extensions:[R$]}).trimEnd()}function J$(e){let t=[];for(let n of e.props){if(n.hidden===!0)continue;let e={name:n.name,type:n.type,required:n.required};n.description!==void 0&&(e.description=n.description),n.advanced===!0&&(e.advanced=!0),n.omitOnDefault===!0&&(e.omitOnDefault=!0),n.type===`enum`&&(e.values=n.enumValues,n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue)),n.type===`string`&&(n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.language!==void 0&&(e.language=n.language),n.accept!==void 0&&(e.accept=n.accept)),n.type===`boolean`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.type===`number`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),t.push(e)}return t}function Y$(e){return{...H$(e),example:q$(e),params:J$(e)}}function X$(){return[``,"**Custom canonical components.** OK `.md` / `.mdx` supports the JSX components below — use whichever is semantically useful in any part of the doc. For full source syntax + parameter schemas, call `palette({ components: [ids] })` with the ids you want to use. Fenced code blocks render naturally and don't need a fetch — including ` ```mermaid ` for diagrams (mermaid label text has sharp edges — `palette({ components: [\"Mermaid\"] })` lists them; parse failures come back as `warnings` entries on write/edit) and ` ```html preview ` for interactive HTML/JS/CSS pages (the fence info-string `preview` token renders the block as a live iframe; works for `html` / `htm` / `xml`; optional `h=` / `w=` tokens set size, e.g. ` ```html preview h=400px `). Use ` ```html preview ` whenever you want anything interactive or JS-powered (charts, demos, calculators, animations) — just author the standalone HTML page in the fence. Call `palette` for the markdown-native component forms (write `> [!NOTE]`, not `<Callout>`), copy-ready themed `html preview` starters, and the theme tokens (`var(--chart-1)`, `var(--foreground)`, …) an embed should reference so it tracks the reader's light/dark theme. Arbitrary `<TagName>` JSX falls through as raw MDX when no canonical fits.",``,...B$().map(H$).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
|
|
423
429
|
`)}const Z$=[`text`,`number`,`boolean`,`date`,`list`,`object`];F(Z$);const Q$=$s([A(),j(),M()]),$$=kc(()=>$s([Q$.transform(e=>String(e)),ac(A(),e1),N($$)])),e1=kc(()=>$s([A(),j(),M(),N($$),ac(A(),e1)]));function t1(e){if(Array.isArray(e)){let t=[];for(let n of e)n!==null&&t.push(t1(n));return t}if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e))t[n]=r===null?``:t1(r);return t}return e}const n1=Pc(t1,ac(A(),e1));ac(A(),$s([e1,Hs()]));function r1(e){return!!(e===null||typeof e==`string`&&e===``||Array.isArray(e)&&e.length===0)}const i1=P({docName:yq,summary:xq,content:A().optional(),...bq}).loose(),a1=P({docName:yq,summary:xq,markdown:A(),position:F([`append`,`prepend`,`replace`]).optional(),extension:F(BG).optional(),...bq}).loose(),o1=P({docName:yq,summary:xq,find:A().min(1),replace:A(),offset:j().int().nonnegative().optional(),...bq}).loose(),s1=P({docName:yq,connectionId:A().min(1),scope:F([`last`,`session`,`file`]).optional(),...bq}).loose(),c1=P({value:A(),truncatedFrom:j().int().nonnegative().optional(),hint:A().optional()}).loose(),l1=tc(`kind`,[P({kind:I(`inline`),content:A()}),P({kind:I(`truncated`),byteLength:j().int().nonnegative(),hint:A()})]),u1=P({kind:I(`content-divergence`),intendedBytes:j().int().nonnegative(),actualBytes:j().int().nonnegative(),byteDelta:j().int(),divergenceType:A().optional(),currentState:l1.optional(),hint:A().optional()}).loose(),d1=P({type:I(`orphan`),parentCandidates:N(A()),message:A()}).loose(),f1=P({kind:I(`disk-edit-reconciled`),intendedBytes:j().int().nonnegative(),actualBytes:j().int().nonnegative(),byteDelta:j().int(),mergeOutcome:A().optional(),hint:A().optional()}).loose(),p1=tc(`kind`,[u1,f1]),m1=tc(`kind`,[u1,f1,P({kind:I(`mermaid-parse-error`),fenceIndex:j().int().positive(),fenceFirstLine:A(),message:A(),line:j().int().positive().optional()}).loose()]),h1=N(m1).min(1),g1=P({href:A(),resolvedTo:A().nullable(),reason:F([`no-such-doc`,`no-such-file`,`unresolvable`])}).loose(),_1=N(g1),v1=P({timestamp:A().min(1),summary:c1.optional(),warning:p1.optional(),warnings:h1.optional()}).loose(),y1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),hints:N(d1).optional(),summary:c1.optional(),warning:p1.optional(),warnings:h1.optional(),brokenLinks:_1}).loose(),b1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),summary:c1.optional(),warning:p1.optional(),warnings:h1.optional(),brokenLinks:_1}).loose(),x1=P({docName:A().min(1),scope:F([`last`,`session`]),undone:M()}).loose(),S1=P({docName:yq,patch:ac(A(),$s([e1,Hs()])),types:ac(A(),F(Z$)).optional(),summary:xq,...bq}).loose(),C1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),appliedKeys:N(A()),summary:c1.optional(),warning:p1.optional(),warnings:h1.optional(),brokenLinks:_1}).loose(),w1=P({entries:N(P({level:F([`info`,`warn`,`error`]),message:A().max(8192),event:A().optional(),fields:ac(A(),Ks()).optional(),ts:j().optional(),sourceId:A().optional(),lineNumber:j().optional()}).loose()).max(100)}).loose(),T1=P({accepted:j().int().min(0)}).loose(),E1=P({status:A().min(1),reason:A()}).loose(),D1=P({docName:A().min(1),content:A(),lifecycle:E1.nullable()}).loose(),O1=P({documents:N(P({kind:F([`document`,`asset`,`folder`,`file`]).default(`document`),docName:A().min(1).optional(),docExt:A().min(1).default(`.md`),size:j().int().nonnegative(),modified:A().min(1),isSymlink:M().default(!1),canonicalDocName:A().nullable().default(null),targetPath:A().nullable().default(null),path:A().min(1).optional(),assetExt:A().min(1).optional(),mediaKind:F([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`]).nullable().optional(),referencedBy:N(A().min(1)).optional(),hasChildren:M().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.kind===`file`?e.path!==void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder/file kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName; file → path, no mediaKind/referencedBy/hasChildren)`})),truncated:M().optional()}).loose(),k1=P({source:A().min(1),anchor:A().nullable(),title:A(),snippet:A().nullable()}).loose(),A1=P({docName:A().min(1),backlinks:N(k1)}).loose(),j1=P({counts:ac(A().min(1),j().int().nonnegative())}).loose(),M1=tc(`kind`,[P({kind:I(`doc`),docName:A().min(1),anchor:A().nullable(),title:A(),snippet:A().nullable()}).loose(),P({kind:I(`external`),url:A().min(1),title:A(),snippet:A().nullable()}).loose()]),N1=P({docName:A().min(1),forwardLinks:N(M1)}).loose(),P1=tc(`kind`,[P({id:A().min(1),kind:I(`doc`),docName:A().min(1),anchor:A().nullable(),label:A(),cluster:A().nullable(),category:A().nullable(),tags:N(A()).nullable()}).loose(),P({id:A().min(1),kind:I(`external`),url:A().min(1),label:A()}).loose()]),F1=P({source:A().min(1),target:A().min(1)}).loose(),I1=P({nodes:N(P1),links:N(F1)}).loose(),L1=P({ts:j().int().min(0),url:A(),method:A(),ua:A().optional(),origin:A().optional(),referer:A().optional(),host:A().optional(),remote:A().optional(),secChUa:A().optional(),secChUaMobile:A().optional(),secChUaPlatform:A().optional(),secFetchSite:A().optional(),secFetchDest:A().optional(),secFetchMode:A().optional(),secFetchUser:A().optional()}).loose(),R1=P({app:$s([I(`cursor`),I(`codex`),I(`claude`),Hs()]),signals_fired:N(A())}).loose(),z1=P({entries:N(L1),count:j().int().min(0),detection:R1}).loose(),B1=P({writers:N(P({id:A().min(1),name:A().optional(),email:A().optional()}).loose()).optional(),summary:xq,...bq}).loose(),V1=P({checkpointRef:A().min(1)}).loose(),H1=P({v:j().int().optional(),id:A().min(1),name:A().min(1),colorSeed:A().optional(),docs:N(A()),summaries:N(A()).optional()}).loose(),U1=P({entries:N(P({sha:A().min(1),timestamp:A().min(1),author:A(),authorEmail:A(),type:F([`checkpoint`,`wip`,`upstream`,`park`]),message:A(),contributors:N(H1),checkpoint:Ks().nullable()}).loose()),total:j().int().nonnegative().optional(),truncated:M().optional(),hasMore:M().optional()}).loose(),W1=P({sha:A().regex(/^[0-9a-f]{40}$/i),content:A(),timestamp:A(),author:A()}).loose(),G1=P({contentDir:A().min(1),pathSeparator:F([`/`,`\\`]),symlinkResolved:M()}).loose(),K1=N(tc(`source`,[P({docName:A().min(1),timestamp:A().min(1),size:j().int().nonnegative(),source:I(`flat`)}).loose(),P({docName:A().min(1),timestamp:A().min(1),source:I(`timeline`),sha:A().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),q1=P({orphans:N(P({docName:A().min(1),title:A()}).loose())}).loose(),J1=P({hubs:N(P({docName:A().min(1),title:A(),count:j().int().nonnegative()}).loose())}).loose(),Y1=P({source:A().min(1),title:A(),snippet:A().nullable()}).loose(),X1=P({deadLinks:N(P({target:A().min(1),sources:N(Y1)}).loose())}).loose(),Z1=P({target:P({docName:A().min(1),title:A(),aliases:N(A())}).loose(),mentions:N(P({source:A().min(1),excerpt:A(),offset:j().int().nonnegative()}).loose()),truncated:M()}).loose(),Q1=P({projectPath:A().min(1)}).loose(),$1=F([`not-a-git-worktree`,`init-failed`]),e0=tc(`ok`,[P({ok:I(!0),projectPath:A().min(1)}).loose(),P({ok:I(!1),reason:$1,message:A().min(1)}).loose()]),t0=P({host:A().min(1).optional()}).loose(),n0=P({key:A().min(1)}).loose(),r0=P({keyPresent:M()}).loose(),i0=P({name:A().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:A().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),a0=P({authenticated:M()}).loose(),o0=P({}).loose(),s0=P({stackIndex:j().int().min(0),ts:j().int().min(0),additions:j().int().min(0),deletions:j().int().min(0)}).loose(),c0=P({docName:A().min(1),additionsTotal:j().int().min(0),deletionsTotal:j().int().min(0),lastTs:j().int().min(0),bursts:N(s0)}).loose(),l0=P({displayName:A().min(1),color:A().min(1),icon:A().optional(),connectionId:A().min(1)}).loose(),u0=P({sessionAlive:M(),agent:l0.nullable(),files:N(c0)}).loose(),d0=P({diff:A(),generatedAt:j().int().min(0)}).loose(),f0=P({}).loose(),p0=P({}).loose(),m0=P({}).loose(),h0=P({}).loose(),g0=P({}).loose(),_0=P({}).loose(),v0=P({displayName:A().min(1),icon:A(),color:A().min(1),currentDoc:A().nullable(),mode:F([`idle`,`writing`]),ts:j().int().min(0)}).loose(),y0=P({presence:ac(A().min(1),v0)}).loose(),b0=ac(A().min(1),M()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});P({path:A().min(1,`path must be non-empty`)}).loose();const x0=P({}).loose(),S0=P({fromDocName:A().min(1),toDocName:A().min(1)}).loose(),C0=P({fromPath:A().min(1),toPath:A().min(1)}).loose(),w0=P({}).loose(),T0=P({path:A().min(1),...bq,summary:xq}).loose(),E0=P({docName:A().min(1)}).loose(),D0=P({path:A().min(1),...bq,summary:xq}).loose(),O0=P({path:A().min(1)}).loose(),k0=P({kind:F([`file`,`folder`]),path:A().min(1),...bq,summary:xq}).loose(),A0=P({kind:F([`file`,`folder`]),path:A().min(1),duplicatedDocNames:N(A().min(1))}).loose(),j0=P({pages:N(P({docName:A().min(1),title:A(),docExt:A().min(1),size:j().int().nonnegative(),modified:A().min(1),icon:A().min(1).max(2048).optional()}).loose())}).loose(),M0=P({level:j().int().min(1).max(6),text:A(),slug:A()}).loose(),N0=P({docName:A().min(1),headings:N(M0)}).loose(),P0=P({docName:A().min(1),rewrites:j().int().nonnegative()}).loose(),F0=P({kind:F([`file`,`folder`,`asset`]),fromPath:A().min(1),toPath:A().min(1),...bq,summary:xq}).loose(),I0=P({renamed:N(S0),renamedAssets:N(C0),rewrittenDocs:N(P0).optional(),summary:c1.optional()}).loose(),L0=P({kind:F([`file`,`folder`,`asset`]),path:A().min(1),...bq}).loose(),R0=P({deletedDocNames:N(A().min(1))}).loose(),z0=P({kind:F([`file`,`folder`,`asset`]),path:A().min(1),...bq,summary:xq}).loose(),B0=P({deletedDocNames:N(A().min(1))}).loose(),V0=P({docName:A().min(1),commitSha:A().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:xq,...bq}).loose(),H0=P({restoredFrom:A().min(1),timestamp:A().min(1),summary:c1.optional(),warning:u1.optional(),warnings:h1.optional()}).loose(),U0=F([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),W0=P({label:A().min(1),webUrl:xs().nullable()}).loose(),G0=tc(`checkStatus`,[P({checkStatus:I(`allowed`)}).loose(),P({checkStatus:I(`denied`),deniedReason:F([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),P({checkStatus:I(`unknown`),unknownError:F([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),K0=F([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),q0=P({state:U0,lastSyncUtc:A().nullable(),lastFetchUtc:A().nullable(),lastPushedSha:A().nullable(),ahead:j().int().min(0),behind:j().int().min(0),consecutiveFailures:j().int().min(0),conflictCount:j().int().min(0),hasRemote:M(),syncEnabled:M(),identityUnresolved:M(),remote:W0.nullable().optional(),pushError:A().optional(),pushErrorCode:K0.optional(),pullError:A().optional(),pullErrorCode:K0.optional(),pausedReason:A().optional(),pushPermission:G0.optional()}).loose(),J0=P({op:F([`sync`,`push`,`pull`]).optional()}).loose(),Y0=P({op:F([`sync`,`push`,`pull`])}).loose(),X0=P({conflicts:N(P({file:A().min(1),detectedAt:A().min(1),oursSha:A().optional(),theirsSha:A().optional(),baseSha:A().optional()}).loose())}).loose(),Z0=P({file:A().min(1),strategy:F([`mine`,`theirs`,`content`,`delete`]),content:A().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),Q0=P({}).loose(),$0=P({file:A().min(1),base:A(),ours:A(),theirs:A(),kind:F([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:A().nullable()}).loose(),e2=P({plan:jc(e=>e!==void 0,{message:`plan is required`})}).loose(),t2=P({plan:jc(e=>e!==void 0,{message:`plan is required`})}).loose(),n2=P({result:jc(e=>e!==void 0,{message:`result is required`})}).loose(),r2=P({path:A().min(1),summary:A().min(1)}).loose(),i2=P({files:j().int().nonnegative(),folders:j().int().nonnegative()}).loose(),a2=P({packs:N(P({id:A().min(1),name:A().min(1),description:A().min(1),defaultSubfolder:A().optional(),folders:N(r2),entryCounts:i2}).loose())}).loose(),o2=P({noOpen:M().optional(),out:A().min(1).optional()}).loose(),s2=P({reason:F([`unsupported-platform`,`spawn-error`]),message:A()}).loose(),c2=tc(`status`,[P({status:I(`installed`),outputPath:A(),size:j().int().nonnegative(),sha256:A(),skillVersion:A()}).loose(),P({status:I(`built`),outputPath:A(),size:j().int().nonnegative(),sha256:A(),skillVersion:A(),handoffError:s2.optional()}).loose(),P({status:I(`failed`),buildError:A()}).loose(),P({status:I(`skip-current`),skillVersion:A(),recordedAt:A().optional()}).loose()]),l2=[`.ok`,`skill-targets.json`],u2=F(KG),d2=Zs({schema:I(1),targets:N(u2).default([])});function f2(e){let t;try{t=JSON.parse(e)}catch{return null}let n=d2.safeParse(t);return n.success?n.data:null}const p2=P({tags:N(P({name:A().min(1),count:j().int().nonnegative(),isLeaf:M()}).loose())}).loose(),m2=P({docName:A().min(1),title:A(),matchingTags:N(A().min(1)),snippet:A().nullable()}).loose(),h2=P({name:A().min(1),docs:N(m2)}).loose(),g2=P({folder:Ks(),frontmatter_local:ac(A(),Ks()).nullable()}).loose(),_2=P({path:A(),frontmatter:ac(A(),Ks()).optional()}).loose(),v2=P({applied:Ks()}).loose(),y2=ac(A(),Ks()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),b2=P({template:P({name:A().min(1),folder:A(),scope:F([`local`,`inherited`]),path:A().min(1),frontmatter:y2,body:A()}).strict()}).strict(),x2=P({templates:N(P({name:A().min(1),title:A().optional(),description:A().optional(),path:A().min(1),source_folder:A()}).strict()),truncated:M()}).strict(),S2=P({folder:A(),name:A(),body:A().optional(),frontmatter:y2.optional(),...bq,summary:xq}).strict(),C2=P({path:A().min(1),created:M(),warnings:N(A())}).strict(),w2=P({existed:M(),path:A().min(1)}).strict(),T2=P({fromFolder:A(),fromName:A(),toFolder:A(),toName:A(),body:A().optional(),frontmatter:y2.optional(),...bq,summary:xq}).strict(),E2=P({from:A().min(1),to:A().min(1),committed:M()}).strict(),D2=F(TG),O2=/^[a-z0-9-]+$/,k2=/<\/?[A-Za-z][^>]*>/;function A2(e){return k2.test(e)}const j2=/^[A-Za-z0-9_-]+$/,M2=P({name:A(),description:A()}).strict(),N2=P({skill:P({name:A().min(1),scope:D2,path:A().min(1),frontmatter:M2,body:A(),files:N(P({path:A().min(1),text:A().nullable()})).optional()}).strict()}).strict(),P2=P({skills:N(P({name:A().min(1),description:A().optional(),scope:D2,path:A().min(1),absolutePath:A().min(1).optional(),installed:M(),hosts:N(A()),installedVersion:A().optional(),bundledVersion:A().optional(),updateAvailable:M().optional()}).strict()),truncated:M()}).strict(),F2=P({scope:D2.default(`project`),name:A(),body:A().optional(),frontmatter:M2,...bq,summary:xq}).strict(),I2=P({path:A().min(1),created:M(),warnings:N(A())}).strict(),L2=P({scope:D2.default(`project`),name:A(),...bq,summary:xq}).strict(),R2=P({name:A().min(1),version:A().min(1),previousVersion:A().optional(),checkpointRef:A().optional()}).strict(),z2=P({existed:M(),path:A().min(1)}).strict(),B2=P({scope:D2.default(`project`),fromName:A(),toName:A(),body:A().optional(),frontmatter:M2.optional(),...bq,summary:xq}).strict(),V2=P({from:A().min(1),to:A().min(1),committed:M()}).strict(),H2=F([`reference`,`script`]),U2=P({scope:D2.default(`project`),name:A(),path:A().min(1),content:A(),...bq,summary:xq}).strict(),W2=P({path:A().min(1),created:M(),kind:H2,content:M()}).strict(),G2=P({path:A().min(1),kind:H2,text:A()}).strict(),K2=P({path:A().min(1),existed:M(),kind:H2}).strict(),q2=P({scope:D2.default(`project`),name:A(),targets:N(u2).optional().meta({description:`Explicit editor ids to install into; omit to use project-configured editors.`}),...bq,summary:xq}).strict(),J2=P({name:A().min(1),hosts:N(A()),scripts:M(),warnings:N(A()),warningCodes:N(F([`no-targets`,`scripts-present`]))}).strict(),Y2=P({scope:D2.default(`project`),name:A()}).strict(),X2=P({name:A().min(1),uninstalled:M()}).strict(),Z2=P({targets:N(u2),configured:M()}).strict(),Q2=P({targets:N(u2)}).strict(),$2=P({targets:N(u2),reprojected:N(P({name:A(),hosts:N(A())}).strict()),bundleHosts:N(A()),removedFrom:N(A())}).strict(),e4=P({scope:D2.default(`project`),name:A(),version:A().regex(/^[0-9a-f]{40}$/i),...bq,summary:xq}).strict(),t4=P({name:A().min(1),version:A(),restoredFiles:N(A()),warnings:N(A())}).strict(),n4=P({query:A().optional(),intent:F([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:F([`navigation`,`relevance`]).optional(),scopes:N(F([`page`,`folder`,`content`,`file`])).optional(),scope:A().optional(),limit:j().int().nonnegative().optional(),semantic:M().optional(),source:F([`omnibar`,`mcp`,`http`]).optional()}).loose(),r4=P({kind:F([`page`,`folder`,`content`,`file`]),path:A().min(1),title:A(),score:j(),signals:ac(A(),Ks()),snippet:A().optional()}).loose(),i4=P({capable:M(),applied:M(),coverage:P({embedded:j().int().nonnegative(),total:j().int().nonnegative()})}).loose(),a4=P({enabled:M(),keyPresent:M(),keySource:F([`file`,`env`]).nullable(),keyHint:A().nullable(),ready:M(),capable:M(),embedded:j().int().nonnegative(),total:j().int().nonnegative()}).loose(),o4=P({query:A(),intent:F([`autocomplete`,`full_text`,`omnibar`]),results:N(r4),elapsedMs:j().nonnegative(),semantic:i4.optional(),truncated:M().optional(),ready:M().optional()}).loose(),s4=P({version:A().min(1),recordedAt:A().min(1)}).loose(),c4=P({currentVersion:A().min(1),targets:ac(A(),s4.nullable())}).loose(),l4=`server-info`,u4=`branch-switched`,d4=`disk-ack`,f4=`config-validation-rejected`,p4=`config-ignore-nested-error`,m4=F([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),h4=P({v:I(1),ch:I(l4),seq:j(),serverInstanceId:A().min(1),currentBranch:A().min(1).optional()}).loose(),g4=P({v:I(1),ch:I(u4),seq:j(),branch:A().min(1)}).loose(),_4=P({v:I(1),ch:m4,seq:j()}).loose(),v4=P({v:I(1),ch:I(d4),seq:j(),docName:A().min(1),sv:A().min(1)}).loose(),y4=P({v:I(1),ch:I(f4),seq:j(),docName:A().min(1),error:Kl}).loose(),b4=P({v:I(1),ch:I(p4),seq:j(),path:A().min(1),error:A().min(1)}).loose(),x4=new fG.default;function S4(e,t){if(e===t)return[{value:e}];let{chars1:n,chars2:r,lineArray:i}=x4.diff_linesToChars_(e,t),a=x4.diff_main(n,r,!1);x4.diff_charsToLines_(a,i),x4.diff_cleanupSemantic(a);let o=[];for(let[e,t]of a)e===fG.default.DIFF_DELETE?o.push({value:t,removed:!0}):e===fG.default.DIFF_INSERT?o.push({value:t,added:!0}):o.push({value:t});return o}const C4=new fG.default;C4.Diff_Timeout=.25;const w4=256*1024;function T4(e,t,n){if(t===n)return;let r=S4(t,n),i=0;for(let n=0;n<r.length;n++){let a=r[n],o=r[n+1];if(a.removed&&o?.added){if(t.substring(i,i+o.value.length)===o.value){i+=o.value.length,n++;continue}e.delete(i,a.value.length),e.insert(i,o.value),i+=o.value.length,n++}else a.removed?e.delete(i,a.value.length):(a.added&&e.insert(i,a.value),i+=a.value.length)}}function E4(e,t,n){if(t===n)return;if(t.length>w4||n.length>w4){D4(e,t,n);return}let r=C4.diff_main(t,n);C4.diff_cleanupSemantic(r);let i=0;for(let[t,n]of r)t===0?i+=n.length:t===-1?e.delete(i,n.length):t===1&&(e.insert(i,n),i+=n.length)}function D4(e,t,n){let r=0,i=Math.min(t.length,n.length);for(;r<i&&t.charCodeAt(r)===n.charCodeAt(r);)r++;let a=0;for(;a<i-r&&t.charCodeAt(t.length-1-a)===n.charCodeAt(n.length-1-a);)a++;let o=t.length-r-a,s=n.slice(r,n.length-a);o>0&&e.delete(r,o),s.length>0&&e.insert(r,s)}const O4=P({path:N($s([A(),j()])),message:A(),issueCode:A()});tc(`code`,[P({code:I(`SCHEMA_INVALID`),issues:N(O4)}),P({code:I(`WRITE_ERROR`),detail:A()})]);const k4={defaultKeyType:`PLAIN`,defaultStringType:`PLAIN`,lineWidth:0};function A4(e){if(e.trim()===``)return{doc:new Fc.Document({}),map:{}};let t;try{t=(0,Fc.parseDocument)(e)}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new Fc.Document({}),map:null,parseError:`parse threw: ${t}`}}if(t.errors.length>0)return{doc:t,map:null,parseError:t.errors[0]?.message??`yaml parse errors`};let n;try{n=t.toJS()}catch(e){let n=e instanceof Error?e.message:String(e);return{doc:t,map:null,parseError:`toJS threw: ${n}`}}if(typeof n!=`object`||!n||Array.isArray(n))return{doc:t,map:null,parseError:`top-level value is not a mapping`};let r=n1.safeParse(n);if(!r.success){let e=r.error.issues[0],n=e&&Array.isArray(e.path)?e.path.join(`.`):``,i=e?.message??`unknown`;return{doc:t,map:null,parseError:n?`value at "${n}" failed schema: ${i}`:`schema validation failed: ${i}`}}return{doc:t,map:r.data}}function j4(e){return Object.keys(e).length===0?``:new Fc.Document(e).toString(k4)}function M4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N4(e,t,n){if(Array.isArray(n)){let r=e.createNode(n),i=(0,Fc.isSeq)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}if(M4(n)){let r=e.createNode(n),i=(0,Fc.isMap)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}return n}function P4(e){return e===``?``:`---\n${e.endsWith(`
|
|
424
430
|
`)?e.slice(0,-1):e}\n---\n`}function F4(e){let t=e.match(uK);return t?{fenced:t[0],body:e.slice(t[0].length)}:{fenced:``,body:e}}function I4(e){if(e.trim()===``)return{doc:new Fc.Document({}),map:{}};let t;try{t=(0,Fc.parseDocument)(e,{uniqueKeys:!1})}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new Fc.Document({}),map:null,parseError:`parse threw: ${t}`}}if(t.errors.length>0)return{doc:t,map:null,parseError:t.errors[0]?.message??`yaml parse errors`};let n;try{n=t.toJS()}catch(e){let n=e instanceof Error?e.message:String(e);return{doc:t,map:null,parseError:`toJS threw: ${n}`}}if(typeof n!=`object`||!n||Array.isArray(n))return{doc:t,map:null,parseError:`top-level value is not a mapping`};let r=n1.safeParse(n);if(!r.success){let e=r.error.issues[0],n=e&&Array.isArray(e.path)?e.path.join(`.`):``,i=e?.message??`unknown`;return{doc:t,map:null,parseError:n?`value at "${n}" failed schema: ${i}`:`schema validation failed: ${i}`}}return{doc:t,map:r.data}}function L4(e){return e===``?{doc:new Fc.Document({}),map:{}}:I4(pK(e))}function R4(e){let{fenced:t}=F4(e),{map:n}=L4(t);return n??{}}function z4(e){if(e.contents==null||!(`items`in e.contents)){let t=e.createNode({});return e.contents=t,t}return e.contents}function B4(e){let t=e.contents;return!t||!(`items`in t)||(t.items?.length??0)===0?``:P4(e.toString(k4))}function V4(e){let t=new TextEncoder().encode(e).byteLength;return t>65536?{kind:`region_too_large`,bytes:t,limit:65536}:null}function H4(e){let t=B4(e),n=V4(t);return n?{ok:!1,error:n}:{ok:!0,nextFenced:t}}function U4(e,t){if(Object.hasOwn(t,`frontmatter`))return{ok:!1,error:{kind:`reserved_key`,key:`frontmatter`}};let{doc:n,map:r}=L4(e);if(r===null)return{ok:!1,error:{kind:`parse_failed`,reason:`fm region unparseable`}};try{z4(n);for(let[e,r]of Object.entries(t)){if(r===null){n.delete(e);continue}let t=e1.safeParse(r);if(!t.success)return{ok:!1,error:{kind:`invalid_value`,key:e,reason:t.error.issues[0]?.message??`invalid value`}};n.set(e,N4(n,n.get(e,!0),t.data))}return H4(n)}catch(e){return{ok:!1,error:{kind:`parse_failed`,reason:`yaml@2 threw: ${e instanceof Error?e.message:String(e)}`}}}}Object.freeze({source:`local`,skipStoreHooks:!1,context:Object.freeze({origin:`form-write`})});function W4(e,t){let n=t?.verbose===!0,r=t?.nowMs===void 0?new Date().toISOString():new Date(t.nowMs).toISOString(),i={event:`bridge-invariant-violation`,site:e.site,"doc.name":e.docName??null,"tolerance-class-attempted":`untracked`,"normalize-equal-modulo-tolerance":!1,ytextLen:e.ytextSnapshot.length,fragmentLen:e.fragmentMdSnapshot.length,ytextHash:lu(e.ytextSnapshot),fragmentHash:lu(e.fragmentMdSnapshot),redacted:!n,timestamp:r};return n?{...i,diff:e.unifiedDiff}:i}var G4=class extends Error{violation;constructor(e){let t=typeof e.origin==`string`?e.origin:e.origin?.context?.origin??`unknown-object`,n=e.docName?` doc='${e.docName}'`:``;super(`Bridge invariant violated [site='${e.site}'${n}, origin='${t}'].\n Y.Text (${e.ytextSnapshot.length} chars): ${e.ytextSnapshot.slice(0,200)}...\n Fragment (${e.fragmentMdSnapshot.length} chars): ${e.fragmentMdSnapshot.slice(0,200)}...\n Diff:\n${e.unifiedDiff}`),this.name=`BridgeInvariantViolationError`,this.violation=e}};const K4=/^(?:\r?\n)+/;function q4(e){let{frontmatter:t,body:n}=dK(e),r=n.match(K4);if(!r)return{boundary:``,text:e};let i=n.slice(r[0].length);return t===``&&uK.test(i)?{boundary:``,text:e}:{boundary:r[0],text:t+i}}function J4(e,t){if(t===``)return e;let{frontmatter:n,body:r}=dK(e);return n+t+r}function Y4(e){let t=q4(e).text;return dK(t).frontmatter===``?t:J4(t,`
|
|
425
|
-
`)}
|
|
431
|
+
`)}function X4(e,t=16){let n=e.trim();return n.length<t?!1:!(n.startsWith(`<`)||n.startsWith("```")||n.startsWith(`|`))}function Z4(e,t=16){let n=new Map;for(let r of e.split(`
|
|
432
|
+
`)){if(!X4(r,t))continue;let e=r.trim();n.set(e,(n.get(e)??0)+1)}return n}function Q4(e,t,n=16){let r=Z4(t,n),i=[];for(let[t,a]of Z4(e,n))a>=2&&a>(r.get(t)??0)&&i.push(t);return i}const $4=new fG.default;$4.Match_Threshold=.5;function e3(e,t,n){let r=t3(e,t,n);return o3(e,t,n,r),r}function t3(e,t,n){if(e===t)return n;if(e===n||t===n)return t;let r=MV(t.split(`
|
|
426
433
|
`),e.split(`
|
|
427
434
|
`),n.split(`
|
|
428
435
|
`)),i=[];for(let e=0;e<r.length;e++){let t=r[e];if(`ok`in t&&t.ok)i.push(t.ok.join(`
|
|
429
436
|
`));else if(`conflict`in t&&t.conflict){let e=t.conflict.o.join(`
|
|
430
437
|
`),n=t.conflict.a.join(`
|
|
431
438
|
`),r=t.conflict.b.join(`
|
|
432
|
-
`);i.push(
|
|
433
|
-
`)}function
|
|
434
|
-
`)){let t=e.trim();t.length!==0&&r.push(t)}return r}function
|
|
439
|
+
`);i.push(s3(e,n,r))}}return i.join(`
|
|
440
|
+
`)}function n3(e){return e.map(e=>({len:e.length,digest:lu(e)}))}var r3=class extends Error{info;constructor(e){let t=e.lostSubstrings.map(e=>JSON.stringify(e.length>80?`${e.slice(0,77)}...`:e)).join(`, `);super(`Bridge merge content loss (which=${e.which}, side=${e.side}): ${t}`),this.name=`BridgeMergeContentLossError`,this.info=e}toLog(e){let t=e?.verbose===!0;return{event:`bridge-merge-content-loss`,which:this.info.which,side:this.info.side,baselineLen:this.info.baseline.length,userTextLen:this.info.userText.length,agentTextLen:this.info.agentText.length,resultLen:this.info.result.length,lostSubstrings:t?this.info.lostSubstrings:n3(this.info.lostSubstrings),redacted:!t}}};function i3(e,t){if(e===t)return[];let n=$4.diff_main(e,t);$4.diff_cleanupSemantic(n);let r=[];for(let[e,t]of n)if(e===1)for(let e of t.split(`
|
|
441
|
+
`)){let t=e.trim();t.length!==0&&r.push(t)}return r}function a3(e,t){let n=0;for(let r of t){let t=e.indexOf(r,n);if(t<0){if(e.indexOf(r)<0)continue;return r}n=t+r.length}return null}function o3(e,t,n,r){let i=i3(e,t),a=i3(e,n),o=i.filter(e=>!r.includes(e));if(o.length>0)throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:o,which:`substring`,side:`user`});let s=a.filter(e=>!r.includes(e));if(s.length>0)throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:s,which:`substring`,side:`agent`});let c=a3(r,i);if(c!==null)throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[c],which:`order`,side:`user`});let l=a3(r,a);if(l!==null)throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[l],which:`order`,side:`agent`});let u=Z4(e),d=Z4(t),f=Z4(n);for(let[i,a]of Z4(r))if(!(a<2)&&a>Math.max(u.get(i)??0,d.get(i)??0,f.get(i)??0))throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[i],which:`growth`,side:`user`})}function s3(e,t,n){if(t===``)return n;if(n===``)return t;let r=$4.patch_make(e,t),[i,a]=$4.patch_apply(r,n);return a.some(e=>!e)&&console.warn(JSON.stringify({event:`bridge-merge-patch-drop`,applied:a.filter(Boolean).length,total:a.length,regionSize:n.length})),i}const c3=/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g,l3=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/,u3=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/,d3=/^\d+([.)])(?=\s)/,f3=/\*\*\s*(`[^`]+`)\s*\*\*/g,p3=/^(`{3,}|~{3,})/;function m3(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r].trimEnd(),a=p3.exec(i);if(a){let e=a[1][0];if(n===null){n=e;continue}if(n===e){n=null;continue}}if(n!==null||r===0||!l3.test(i))continue;let o=e[r-1].trimEnd();if(!(!o.startsWith(`|`)||l3.test(o))){t.add(r-1),t.add(r);for(let n=r+1;n<e.length&&e[n].trimEnd().startsWith(`|`);n++)t.add(n)}}return t}function h3(e){return e.slice(0,-1).trimEnd()}const g3=/^(?:#{1,6}[ \t]|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function _3(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r]??``,a=/^(`{3,}|~{3,})/.exec(i.trimStart());if(a?.[1]){let e=a[1][0];if(n===null){n=e;continue}if(n===e){n=null;continue}}n!==null&&t.add(r)}return t}const v3=/^<\/?[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,y3=/^<[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,b3=/^<\/[A-Z][A-Za-z0-9.]*\s*>$/,x3=/<\/?[A-Z]/;function S3(e){let t=!1;for(let n=0;n<e.length;n++)if(x3.test(e[n]??``)){t=!0;break}if(!t)return e;let n=_3(e),r=[],i=[],a=0;for(let t=0;t<e.length;t++){let o=e[t]??``,s=o.trim();if(n.has(t)){r.push(!1),i.push(a);continue}let c=a>=1||!/^[ \t]/.test(o);r.push(c&&v3.test(s));let l=c&&b3.test(s),u=c&&!l&&y3.test(s)&&!s.endsWith(`/>`);l?(a=Math.max(0,a-1),i.push(a)):(i.push(a),u&&(a+=1))}let o=Array(e.length);for(let t=0,n=-1;t<e.length;t++)o[t]=n,(e[t]??``).trim()!==``&&(n=t);let s=Array(e.length);for(let t=e.length-1,n=e.length;t>=0;t--)s[t]=n,(e[t]??``).trim()!==``&&(n=t);let c=new Set;for(let t=0;t<e.length;t++){if((e[t]??``).trim()!==``||n.has(t)||(i[t]??0)<1)continue;let a=o[t]??-1,l=s[t]??e.length;(a>=0&&r[a]===!0||l<e.length&&r[l]===!0)&&c.add(t)}let l=[];for(let t=0;t<e.length;t++){if(c.has(t))continue;let n=e[t]??``;l.push(r[t]===!0&&(i[t]??0)>=1?n.replace(/^[ \t]+/,``):n)}return l}function C3(e){let t=S3(e.replace(/^/,``).replace(/\r/g,``).replace(c3,`$1`).replace(f3,`$1`).replace(/^\n+/,``).replace(/^[*-]{3,}(?=\n|$)/,`---`).replace(/(\n)([#>+-]|\d+[.)]|`{3,}|~{3,})/g,`
|
|
435
442
|
|
|
436
443
|
$2`).replace(/^([#>+-].*|\d+[.)].*|`{3,}.*|~{3,}.*)\n([^\n])/gm,`$1
|
|
437
444
|
|
|
438
445
|
$2`).split(`
|
|
439
|
-
`)),n=
|
|
446
|
+
`)),n=m3(t),r=_3(t);return t.map((e,i)=>{let a=e.trimEnd();if(i>0&&!r.has(i)&&/^[ \t]+\S/.test(a)&&(t[i-1]??``).trim()!==``&&!u3.test(a)&&!g3.test(a.trimStart())){let e=(t[i-1]??``).trimStart();if(!g3.test(e)&&!e.startsWith(`|`))return a.replace(/^[ \t]+/,``)}if(l3.test(a)){let e=a.replace(/\s+/g,``);return n.has(i)&&e.length>1&&e.startsWith(`|`)&&e.endsWith(`|`)?h3(e):e}let o=u3.test(a)?a.replace(/^[ \t]+/,``):a;return n.has(i)&&o.length>1&&o.startsWith(`|`)&&o.endsWith(`|`)&&(o=h3(o)),o.replace(d3,`1$1`)}).join(`
|
|
440
447
|
`).replace(/\n{3,}/g,`
|
|
441
448
|
|
|
442
|
-
`).replace(/\n+$/,``)}function
|
|
449
|
+
`).replace(/\n+$/,``)}function w3(e,t){let n=[];(e.charCodeAt(0)===65279||t.charCodeAt(0)===65279)&&n.push(`bom`),(e.includes(`\r`)||t.includes(`\r`))&&n.push(`crlf`),(/\\[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/.test(e)||/\\[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/.test(t))&&n.push(`commonmark-escape`),(/\*\*\s*`[^`]+`\s*\*\*/.test(e)||/\*\*\s*`[^`]+`\s*\*\*/.test(t))&&n.push(`emphasis-around-code`);let r=e.replace(/^/,``),i=t.replace(/^/,``);r.startsWith(`
|
|
443
450
|
`)!==i.startsWith(`
|
|
444
451
|
`)&&n.push(`leading-newline`);let a=r.replace(/^\n+/,``),o=i.replace(/^\n+/,``),s=/^\*{3,}(?=\n|$)/.test(a),c=/^-{3,}(?=\n|$)/.test(a),l=/^\*{3,}(?=\n|$)/.test(o),u=/^-{3,}(?=\n|$)/.test(o);(s&&u||c&&l)&&n.push(`doc-start-thematic`);let d=/\n\n([#>+-]|\d+[.)]|`{3,}|~{3,})/,f=/^([#>+-].*|\d+[.)].*|`{3,}.*|~{3,}.*)\n\n[^\n]/m,p=d.test(r),m=d.test(i),h=f.test(r),g=f.test(i);(p!==m||h!==g)&&n.push(`block-separator-collapse`);let _=r.replace(/\r/g,``),v=i.replace(/\r/g,``),y=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/m;(y.test(_)||y.test(v))&&n.push(`table-align-row-spacing`);let b=e=>y.test(e)&&/^\|[^\n]*[^|\s][ \t]*$/m.test(e);b(_)!==b(v)&&n.push(`row-no-trailing-pipe`);let x=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/m;(x.test(_)||x.test(v))&&n.push(`list-indent-canonical`);let S=/[^\n]\n[ \t]+(?![-+*>#]|\d+[.)])\S/;(S.test(_)||S.test(v))&&n.push(`paragraph-continuation-indent`);let C=_.split(`
|
|
445
452
|
`),w=v.split(`
|
|
446
|
-
`),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&
|
|
453
|
+
`),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&v3.test(n),a=n===``&&r!==``&&v3.test(r);if(i||a)return!0}return!1};(T(C)||T(w))&&n.push(`jsx-container-boundary-blank`);let E=e=>e.replace(/^[ \t]+/,``).replace(d3,`1$1`),ee=Math.min(C.length,w.length);for(let e=0;e<ee;e++){let t=C[e]??``,r=w[e]??``;if(t!==r&&E(t)===E(r)&&/^[ \t]*\d+[.)]\s/.test(t)){n.push(`ordered-list-marker-number`);break}}return(/[ \t]\n/.test(_)||/[ \t]\n/.test(v))&&n.push(`trailing-whitespace`),(/[ \t]$/.test(_)||/[ \t]$/.test(v))&&(n.includes(`trailing-whitespace`)||n.push(`trailing-whitespace`)),(/\n{3,}/.test(_)||/\n{3,}/.test(v))&&n.push(`blank-line-collapse`),_.endsWith(`
|
|
447
454
|
`)!==v.endsWith(`
|
|
448
|
-
`)&&n.push(`trailing-newline`),n}const
|
|
449
|
-
`).map(e=>e.replace(T3,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const D3=new Set;function O3(e,t,n){let r=dK(e),i=dK(t);if(r.frontmatter!==i.frontmatter)return!1;if(r.body===i.body)return!0;let a;try{a=n(r.body)}catch(e){let t=e instanceof Error?e.message:String(e);return D3.size<8&&!D3.has(t)&&(D3.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return C3(w3(a))===C3(w3(i.body))?dJ(E3(r.body),E3(a)):!1}const k3={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},A3={"emphasis-around-code":`pm-model-caused`,bom:`parser-caused`,crlf:`parser-caused`,"commonmark-escape":`parser-caused`,"leading-newline":`parser-caused`,"paragraph-continuation-indent":`parser-caused`,"doc-start-thematic":`parser-caused`,"block-separator-collapse":`serializer-caused`,"table-align-row-spacing":`serializer-caused`,"row-no-trailing-pipe":`serializer-caused`,"ordered-list-marker-number":`serializer-caused`,"list-indent-canonical":`serializer-caused`,"jsx-container-boundary-blank":`serializer-caused`,"trailing-whitespace":`serializer-caused`,"blank-line-collapse":`serializer-caused`,"trailing-newline":`serializer-caused`,"parse-equivalence":`parser-caused`};function j3(e){return A3[e]}function M3(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return e.length===t.length?-1:n}let N3=null;function P3(e){N3=e}function F3(e,t,n,r){if(!N3||e.length===0)return;let i=M3(t,n),a=new Date().toISOString();for(let t of e)N3({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:j3(t)})}const I3=1e4,L3=`last-spawn-error.log`,R3=/^[a-zA-Z0-9][\w/-]*$/;function z3(e){return e.startsWith(`#`)?e.slice(1):e}function B3(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function V3(e){if(!e||e.trim()===``)return[];let{map:t}=A4(e);if(!t)return[];let n=B3(t.tags),r=[];for(let e of n){let t=z3(e);R3.test(t)&&r.push(t)}return r}const H3=[`.ok`,`local`,`installed-skills.json`],U3=F(TG),W3=Zs({hosts:N(A()),scope:U3,scripts:M(),installedAt:Go()}),G3=Zs({schema:I(1),skills:ac(A(),W3).default({})});function K3(){return{schema:1,skills:{}}}function q3(e){let t;try{t=JSON.parse(e)}catch{return null}let n=G3.safeParse(t);return n.success?n.data:null}const J3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},Y3=new WeakMap;function X3(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function Z3(e){return e.trim().toLowerCase()}const Q3=/\.(?:md|mdx)$/;function $3(e,t){if(t!==`page`)return e;let n=e.replace(Q3,``);return n.length>0?n:e}function e6(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function t6(e){let t=e6(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function n6(e){let t=SW({schema:J3});return e.length>0&&NW(t,e),t}function r6(e){let t={documents:e};return Y3.set(t,n6(e)),t}function i6(e){let t=Y3.get(e);if(t)return t;let n=n6(e.documents);return Y3.set(e,n),n}function a6(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function o6(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function s6(e,t){let n=Z3(t);if(!n)return 0;let r=$3(n,e.kind),i=Z3(e.title),a=Z3(e.name),o=Z3(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function c6(e,t){let n=s6(e,t);return n<=0?n:_q(e.path)?n*.5:n}function l6(e){return e===`file`?-60:0}function u6(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function d6(e,t,n,r){return e+t*20+n+l6(r)}function f6(e,t,n,r,i,a){return e===`relevance`?d6(t,n,r,i):u6(t,n,r,i,a)}function p6(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function m6(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function h6(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function g6(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function _6(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function v6(e,t){return Z3(t).length<4?0:e===`full_text`?1:0}function y6(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function b6(e){let t=[],n=[],r=[];for(let i of e){let e=y6(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function x6(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=b6(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function S6(e,t,n={}){let r=n.intent??`omnibar`,i=p6(r,n.ranking),a=X3(n.limit),o=new Set(n.scopes??a6(r)),s=e.documents.filter(e=>o6(e,o)),c=Z3(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=lG(i6(e),{term:c,properties:g6(r),boost:_6(r),tolerance:v6(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>o6(e.document,o)).map(e=>[e.document.id,e.score])),d=h6(s),f=new Map;for(let e of s)c6(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)o6(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=m6(f.values(),u);return x6([...f.values()].map(t=>{let n=Math.max(0,c6(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:f6(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return x6(w6({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function C6(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function w6(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=m6(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,c6(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?f6(o,t,n,s,e.kind,m):d6(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=C6(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=C6(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function T6(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),E6(n)}function E6(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const D6=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),O6=globalThis;O6[D6]===void 0&&(O6[D6]=Ri());const k6=O6[D6],A6=[`.ok`,`skill-state.yml`],j6=[`claude-cowork`,`cli-hosts`],M6=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],N6=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,P6=Zs({version:A().regex(N6,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(k6,{description:`Recorded skill version for this target.`}),recordedAt:Go().register(k6,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:F(M6).register(k6,{description:`Install-source surface that recorded this entry.`}).optional()}),F6=Zs({enabled:M().register(k6,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:Go().register(k6,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),I6=Zs({schema:I(1).register(k6,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Zs({"claude-cowork":P6.optional(),"cli-hosts":P6.optional()}).register(k6,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:ac(A(),F6).register(k6,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function L6(e,t){return e??t.installedOnDisk}function R6(){return{schema:1,targets:{}}}const z6=`template`;function B6(e){if(e.trim()===``)return{};let t;try{t=(0,Fc.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function V6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function H6(e){let{frontmatter:t,body:n}=dK(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:pK(t),markdown:n}}function U6(e){let t=e.split(`
|
|
450
|
-
`);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=
|
|
451
|
-
`))[
|
|
452
|
-
`).replace(/\n+$/,``)}}function W6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=dK(t);if(n===``)return{identity:{},starterContent:t};let i=pK(n),a=U6(i);if(a)return{identity:a.identity,starterContent:V6(a.docFrontmatterText,r)};let{frontmatter:o}=dK(r);if(o!==``)return{identity:B6(i),starterContent:r};let s=B6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:V6(i,r)}}function G6(e,t){let{docFrontmatterText:n,markdown:r}=H6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Fc.stringify)({[z6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function K6(e){return W6(e).starterContent}function q6(){let e=!1,t=``,n=0;return r=>{let i=J6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function J6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const Y6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],X6={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function Z6(e,t=Y6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const Q6={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function $6(e){return e?Q6[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const e8={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function t8(e){let t=e?.trim();return t?e8[$6(t)]??t:`Agent`}function n8(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const r8=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function i8(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function a8(e){let t=e.trim();return r8.test(t)||t.startsWith(`//`)}function o8(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(a8(n))return{kind:`external`,url:n};let r=n8(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=i8(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function s8(e,t){let n=e.trim();if(!n)return null;if(a8(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=i8(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function c8(e,t){let n=e.trim();if(!n||r8.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function l8(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function u8(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function d8(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function f8(e){return e.split(`/`).filter(e=>e!==``)}function p8(e,t){let n=d8(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function m8(e,t){let n=d8(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:f8(r).length}function h8(e,t){let n=f8(e),r=f8(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function g8(){let e=new Map;function t(t){let n=l8(t);if(n===``)return;let r=u8(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=l8(t),r=u8(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=d8(l8(n)),o=[],s=[];for(let e of i)p8(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=m8(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=m8(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=h8(a,d8(t));for(let r=1;r<e.length;r++){let i=e[r],o=h8(a,d8(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function _8(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function v8(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function y8(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function b8(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}const x8=/^[A-Za-z0-9-]{8,64}$/;let S8=null;function C8(e){return l(e??m(),`.ok`,`machine-id`)}function w8(e){if(e===void 0&&S8!==null)return S8;let t=C8(e),n=null;try{let e=b(t,`utf-8`).trim();x8.test(e)&&(n=e)}catch{}if(n===null){n=w();try{v(c(t),{recursive:!0}),S(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){console.warn(`[machine-id] Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(S8=n),n}function T8(){try{let e=u(c(f(import.meta.url)),`..`,`package.json`),t=JSON.parse(b(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const E8=T8(),D8=1;var O8=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${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 k8(e,t){return u(e,`${t}.lock`)}const A8=new Map;function j8(e){A8.set(e,(A8.get(e)??0)+1)}function M8(e){let t=A8.get(e);return t===void 0||t<=1?(A8.delete(e),!0):(A8.set(e,t-1),!1)}function N8(e){return typeof e.machineId==`string`?e.machineId===w8():e.hostname===h()}const P8=new Set;let F8=!1;function I8(e){P8.add(e),!F8&&(F8=!0,process.on(`exit`,()=>{for(let e of P8)try{let t=JSON.parse(b(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==w8()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==h())continue;x(e)}catch{}}))}function L8(e,t){try{let n=JSON.parse(b(e,`utf-8`));return n&&typeof n==`object`&&b8(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 R8(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;v(n,{recursive:!0});let a=k8(n,t),o={pid:process.pid,hostname:h(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:w8(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??E8},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!_(a))try{let e=y(a,`wx`,384);try{C(e,s)}finally{g(e)}return j8(a),I8(a),z8({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=L8(a,i);if(e){if(N8(e)&&e.pid===process.pid)return S(a,s,{encoding:`utf-8`,mode:384}),j8(a),I8(a),z8({lockName:t,lockDir:n,lockPath:a});if(y8(e.pid))throw new O8(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{x(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function z8(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>G8({lockName:t,lockDir:n}),updatePort:e=>B8({lockName:t,lockDir:n,port:e})}}function B8(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=k8(n,t);if(!_(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||!b8(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&N8(o)){o.port=r;try{S(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function V8(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k8(n,t);if((A8.get(i)??0)>1)return;let a;try{let e=JSON.parse(b(i,`utf-8`));if(!e||typeof e!=`object`||!b8(e.pid)){console.warn(`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){e.code!==`ENOENT`&&console.warn(`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N8(a)&&a.draining!==!0){a.draining=!0;try{S(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function H8(e){let{lockName:t,lockDir:n}=e,r=k8(n,t);if(!_(r))return null;let i;try{let e=JSON.parse(b(r,`utf-8`));if(!e||typeof e!=`object`||!b8(e.pid))return null;i=e}catch{return null}if(!N8(i))return null;if(!y8(i.pid)){try{x(r)}catch{}return null}return i}function U8(e){let{lockName:t,lockDir:n}=e,r=k8(n,t);if(!_(r))return{status:`absent`};let i;try{i=JSON.parse(b(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!b8(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N8(o))return{status:`stale`,lock:o};if(!y8(o.pid)){try{x(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}async function W8(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>H8({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function G8(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k8(n,t);if(M8(a)){if(r){V8({lockName:t,lockDir:n});return}if(_(a))try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N8(e))return;x(a),P8.delete(a)}catch(e){console.warn(`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var K8=class extends O8{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function q8(e,t){try{return R8({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O8&&e.lockName===`server`?new K8(e.existing,e.lockPath):e}}function J8(e,t){B8({lockName:`server`,lockDir:e,port:t})}function Y8(e){return H8({lockName:`server`,lockDir:e})}function X8(e,t){G8({lockName:`server`,lockDir:e,...t})}function Z8(e){V8({lockName:`server`,lockDir:e})}function Q8(e,t){return W8({lockName:`server`,lockDir:e,...t})}export{mG as $,fl as $a,f2 as $i,z2 as $n,YG as $r,n0 as $t,a1 as A,lu as Aa,g$ as Ai,N6 as An,Uo as Ao,X0 as Ar,_2 as At,g1 as B,Kc as Ba,Gq as Bi,n2 as Bn,cn as Bo,w2 as Br,H3 as Bt,m1 as C,M$ as Ca,t8 as Ci,K1 as Cn,Pc as Co,L2 as Cr,A0 as Ct,b1 as D,gb as Da,T6 as Di,O2 as Dn,Ks as Do,lJ as Dr,z1 as Dt,o1 as E,P4 as Ea,R6 as Ei,DG as En,$s as Eo,x0 as Er,GG as Et,j1 as F,Cl as Fa,$6 as Fi,B1 as Fn,br as Fo,Y0 as Fr,e1 as Ft,v4 as G,nu as Ga,zG as Gi,Cq as Gn,ht as Go,C2 as Gr,VG as Gt,b4 as H,pl as Ha,QG as Hi,e2 as Hn,Dt as Ho,T2 as Hr,c2 as Ht,A1 as I,wl as Ia,K6 as Ii,V1 as In,un as Io,z6 as Ir,qG as It,p4 as J,jl as Ja,A4 as Ji,Aq as Jn,p0 as Jr,t0 as Jt,h4 as K,Yc as Ka,Z4 as Ki,Eq as Kn,mt as Ko,x2 as Kr,I1 as Kt,qq as L,Sl as La,Rq as Li,n4 as Ln,fn as Lo,j2 as Lr,U1 as Lt,i1 as M,ou as Ma,P$ as Mi,L3 as Mn,Ka as Mo,Q0 as Mr,N1 as Mt,v1 as N,Dl as Na,IY as Ni,BG as Nn,qa as No,q0 as Nr,S1 as Nt,s1 as O,op as Oa,_8 as Oi,A6 as On,xs as Oo,Z1 as Or,w0 as Ot,nJ as P,Zc as Pa,cq as Pi,gG as Pn,si as Po,J0 as Pr,C1 as Pt,_G as Q,ql as Qa,MG as Qi,Qq as Qn,B0 as Qr,r0 as Qt,G4 as R,xl as Ra,r1 as Ri,o4 as Rn,mn as Ro,h2 as Rr,W1 as Rt,UG as S,W4 as Sa,F4 as Si,I0 as Sn,dc as So,X2 as Sr,k0 as St,d0 as T,hq as Ta,K3 as Ti,H0 as Tn,A as To,P2 as Tr,JG as Tt,y4 as U,cu as Ua,O3 as Ui,a4 as Un,k as Uo,E2 as Ur,b0 as Ut,g4 as V,Xc as Va,EG as Vi,a2 as Vn,zt as Vo,b2 as Vr,o2 as Vt,_4 as W,su as Wa,Iq as Wi,eJ as Wn,O as Wo,S2 as Wr,G3 as Wt,d4 as X,au as Xa,q3 as Xi,Fq as Xn,f0 as Xr,a0 as Xt,f4 as Y,Rl as Ya,PG as Yi,Nq as Yn,m0 as Yr,i0 as Yt,l4 as Z,Xl as Za,LG as Zi,Zq as Zn,z0 as Zr,cJ as Zt,X8 as _,mq as _a,WZ as _i,N0 as _n,rc as _o,Z2 as _r,X1 as _t,R8 as a,OG as aa,U4 as ai,$G as an,Il as ao,q2 as ar,Jq as at,Q8 as b,dK as ba,k3 as bi,aJ as bn,j as bo,d2 as br,O1 as bt,y8 as c,X$ as ca,o8 as ci,_0 as cn,Ls as co,B2 as cr,T1 as ct,V8 as d,n8 as da,Z6 as di,q1 as dn,Hs as do,I2 as dr,T0 as dt,W6 as ea,sJ as ei,Q1 as en,El as eo,K2 as er,SG as et,Z8 as f,AG as fa,kJ as fi,S3 as fn,Ws as fo,e4 as fr,E0 as ft,G8 as g,fq as ga,q6 as gi,pG as gn,tc as go,u2 as gr,HG as gt,Y8 as h,P3 as ha,g8 as hi,KG as hn,jc as ho,I6 as hr,I3 as ht,K8 as i,Y4 as ia,T4 as ii,TG as in,zl as io,N2 as ir,yG as it,y1 as j,qc as ja,B$ as ji,l2 as jn,ma as jo,Z0 as jr,v2 as jt,x1 as k,L as ka,V3 as ki,j6 as kn,Go as ko,$0 as kr,g2 as kt,b8 as l,c8 as la,s8 as li,g0 as ln,uc as lo,V2 as lr,D0 as lt,U8 as m,j4 as ma,A2 as mi,nK as mn,M as mo,D2 as mr,rK as mt,E8 as n,tK as na,G1 as ni,CG as nn,ml as no,U2 as nr,vG as nt,q8 as o,R4 as oa,iJ as oi,_$ as on,kl as oo,c4 as or,Xq as ot,H8 as p,S6 as pa,G6 as pi,eK as pn,N as po,t4 as pr,XG as pt,u4 as q,Jc as qa,b3 as qi,jq as qn,h0 as qr,o0 as qt,D8 as r,Y$ as ra,E4 as ri,wG as rn,Tl as ro,W2 as rr,bG as rt,w8 as s,J4 as sa,Wq as si,y0 as sn,Al as so,J2 as sr,w1 as st,O8 as t,fK as ta,oJ as ti,e0 as tn,eu as to,G2 as tr,xG as tt,k8 as u,L6 as ua,hG as ui,ZG as un,F as uo,F2 as ur,O0 as ut,B8 as v,FG as va,r6 as vi,j0 as vn,I as vo,Q2 as vr,L0 as vt,u0 as w,pK as wa,F3 as wi,V0 as wn,ac as wo,R2 as wr,WG as wt,X6 as x,v8 as xa,x3 as xi,F0 as xn,P as xo,Y2 as xr,D1 as xt,J8 as y,q4 as ya,t6 as yi,tJ as yn,Zs as yo,$2 as yr,R0 as yt,e3 as z,bl as za,_q as zi,t2 as zn,gn as zo,p2 as zr,J1 as zt};
|
|
453
|
-
//# sourceMappingURL=server-lock-iLcBw_q0-
|
|
455
|
+
`)&&n.push(`trailing-newline`),n}const T3=`parse-equivalence`;function E3(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function D3(e){return e.replace(/[ \t]+$/gm,``)}const O3=/^([ \t]*)\d+([.)])(?=[ \t])/;function k3(e){return e.split(`
|
|
456
|
+
`).map(e=>e.replace(O3,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const A3=new Set;function j3(e,t,n){let r=dK(e),i=dK(t);if(r.frontmatter!==i.frontmatter)return!1;if(r.body===i.body)return!0;let a;try{a=n(r.body)}catch(e){let t=e instanceof Error?e.message:String(e);return A3.size<8&&!A3.has(t)&&(A3.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return E3(D3(a))===E3(D3(i.body))?dJ(k3(r.body),k3(a)):!1}const M3={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},N3={"emphasis-around-code":`pm-model-caused`,bom:`parser-caused`,crlf:`parser-caused`,"commonmark-escape":`parser-caused`,"leading-newline":`parser-caused`,"paragraph-continuation-indent":`parser-caused`,"doc-start-thematic":`parser-caused`,"block-separator-collapse":`serializer-caused`,"table-align-row-spacing":`serializer-caused`,"row-no-trailing-pipe":`serializer-caused`,"ordered-list-marker-number":`serializer-caused`,"list-indent-canonical":`serializer-caused`,"jsx-container-boundary-blank":`serializer-caused`,"trailing-whitespace":`serializer-caused`,"blank-line-collapse":`serializer-caused`,"trailing-newline":`serializer-caused`,"parse-equivalence":`parser-caused`};function P3(e){return N3[e]}function F3(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return e.length===t.length?-1:n}let I3=null;function L3(e){I3=e}function R3(e,t,n,r){if(!I3||e.length===0)return;let i=F3(t,n),a=new Date().toISOString();for(let t of e)I3({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:P3(t)})}const z3=1e4,B3=`last-spawn-error.log`,V3=/^[a-zA-Z0-9][\w/-]*$/;function H3(e){return e.startsWith(`#`)?e.slice(1):e}function U3(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function W3(e){if(!e||e.trim()===``)return[];let{map:t}=A4(e);if(!t)return[];let n=U3(t.tags),r=[];for(let e of n){let t=H3(e);V3.test(t)&&r.push(t)}return r}const G3=[`.ok`,`local`,`installed-skills.json`],K3=F(TG),q3=Zs({hosts:N(A()),scope:K3,scripts:M(),installedAt:Go()}),J3=Zs({schema:I(1),skills:ac(A(),q3).default({})});function Y3(){return{schema:1,skills:{}}}function X3(e){let t;try{t=JSON.parse(e)}catch{return null}let n=J3.safeParse(t);return n.success?n.data:null}const Z3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},Q3=new WeakMap;function $3(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function e6(e){return e.trim().toLowerCase()}const t6=/\.(?:md|mdx)$/;function n6(e,t){if(t!==`page`)return e;let n=e.replace(t6,``);return n.length>0?n:e}function r6(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function i6(e){let t=r6(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function a6(e){let t=SW({schema:Z3});return e.length>0&&NW(t,e),t}function o6(e){let t={documents:e};return Q3.set(t,a6(e)),t}function s6(e){let t=Q3.get(e);if(t)return t;let n=a6(e.documents);return Q3.set(e,n),n}function c6(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function l6(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function u6(e,t){let n=e6(t);if(!n)return 0;let r=n6(n,e.kind),i=e6(e.title),a=e6(e.name),o=e6(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function d6(e,t){let n=u6(e,t);return n<=0?n:_q(e.path)?n*.5:n}function f6(e){return e===`file`?-60:0}function p6(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function m6(e,t,n,r){return e+t*20+n+f6(r)}function h6(e,t,n,r,i,a){return e===`relevance`?m6(t,n,r,i):p6(t,n,r,i,a)}function g6(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function _6(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function v6(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function y6(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function b6(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function x6(e,t){return e6(t).length<4?0:e===`full_text`?1:0}function S6(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function C6(e){let t=[],n=[],r=[];for(let i of e){let e=S6(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function w6(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=C6(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function T6(e,t,n={}){let r=n.intent??`omnibar`,i=g6(r,n.ranking),a=$3(n.limit),o=new Set(n.scopes??c6(r)),s=e.documents.filter(e=>l6(e,o)),c=e6(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=lG(s6(e),{term:c,properties:y6(r),boost:b6(r),tolerance:x6(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>l6(e.document,o)).map(e=>[e.document.id,e.score])),d=v6(s),f=new Map;for(let e of s)d6(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)l6(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=_6(f.values(),u);return w6([...f.values()].map(t=>{let n=Math.max(0,d6(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:h6(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return w6(D6({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function E6(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function D6(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=_6(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,d6(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?h6(o,t,n,s,e.kind,m):m6(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=E6(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=E6(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function O6(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),k6(n)}function k6(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const A6=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),j6=globalThis;j6[A6]===void 0&&(j6[A6]=Ri());const M6=j6[A6],N6=[`.ok`,`skill-state.yml`],P6=[`claude-cowork`,`cli-hosts`],F6=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],I6=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,L6=Zs({version:A().regex(I6,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(M6,{description:`Recorded skill version for this target.`}),recordedAt:Go().register(M6,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:F(F6).register(M6,{description:`Install-source surface that recorded this entry.`}).optional()}),R6=Zs({enabled:M().register(M6,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:Go().register(M6,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),z6=Zs({schema:I(1).register(M6,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Zs({"claude-cowork":L6.optional(),"cli-hosts":L6.optional()}).register(M6,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:ac(A(),R6).register(M6,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function B6(e,t){return e??t.installedOnDisk}function V6(){return{schema:1,targets:{}}}const H6=`template`;function U6(e){if(e.trim()===``)return{};let t;try{t=(0,Fc.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function W6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function G6(e){let{frontmatter:t,body:n}=dK(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:pK(t),markdown:n}}function K6(e){let t=e.split(`
|
|
457
|
+
`);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=U6(n.join(`
|
|
458
|
+
`))[H6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
|
|
459
|
+
`).replace(/\n+$/,``)}}function q6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=dK(t);if(n===``)return{identity:{},starterContent:t};let i=pK(n),a=K6(i);if(a)return{identity:a.identity,starterContent:W6(a.docFrontmatterText,r)};let{frontmatter:o}=dK(r);if(o!==``)return{identity:U6(i),starterContent:r};let s=U6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:W6(i,r)}}function J6(e,t){let{docFrontmatterText:n,markdown:r}=G6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Fc.stringify)({[H6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function Y6(e){return q6(e).starterContent}function X6(){let e=!1,t=``,n=0;return r=>{let i=Z6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function Z6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const Q6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],$6={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function e8(e,t=Q6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const t8={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function n8(e){return e?t8[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const r8={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function i8(e){let t=e?.trim();return t?r8[n8(t)]??t:`Agent`}function a8(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const o8=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function s8(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function c8(e){let t=e.trim();return o8.test(t)||t.startsWith(`//`)}function l8(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(c8(n))return{kind:`external`,url:n};let r=a8(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=s8(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function u8(e,t){let n=e.trim();if(!n)return null;if(c8(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=s8(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function d8(e,t){let n=e.trim();if(!n||o8.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function f8(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function p8(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function m8(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function h8(e){return e.split(`/`).filter(e=>e!==``)}function g8(e,t){let n=m8(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function _8(e,t){let n=m8(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:h8(r).length}function v8(e,t){let n=h8(e),r=h8(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function y8(){let e=new Map;function t(t){let n=f8(t);if(n===``)return;let r=p8(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=f8(t),r=p8(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=m8(f8(n)),o=[],s=[];for(let e of i)g8(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=_8(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=_8(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=v8(a,m8(t));for(let r=1;r<e.length;r++){let i=e[r],o=v8(a,m8(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function b8(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function x8(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function S8(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function C8(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}const w8=/^[A-Za-z0-9-]{8,64}$/;let T8=null;function E8(e){return l(e??m(),`.ok`,`machine-id`)}function D8(e){if(e===void 0&&T8!==null)return T8;let t=E8(e),n=null;try{let e=b(t,`utf-8`).trim();w8.test(e)&&(n=e)}catch{}if(n===null){n=w();try{v(c(t),{recursive:!0}),S(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){console.warn(`[machine-id] Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(T8=n),n}function O8(){try{let e=u(c(f(import.meta.url)),`..`,`package.json`),t=JSON.parse(b(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const k8=O8(),A8=1;var j8=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${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 M8(e,t){return u(e,`${t}.lock`)}const N8=new Map;function P8(e){N8.set(e,(N8.get(e)??0)+1)}function F8(e){let t=N8.get(e);return t===void 0||t<=1?(N8.delete(e),!0):(N8.set(e,t-1),!1)}function I8(e){return typeof e.machineId==`string`?e.machineId===D8():e.hostname===h()}const L8=new Set;let R8=!1;function z8(e){L8.add(e),!R8&&(R8=!0,process.on(`exit`,()=>{for(let e of L8)try{let t=JSON.parse(b(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==D8()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==h())continue;x(e)}catch{}}))}function B8(e,t){try{let n=JSON.parse(b(e,`utf-8`));return n&&typeof n==`object`&&C8(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 V8(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;v(n,{recursive:!0});let a=M8(n,t),o={pid:process.pid,hostname:h(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:D8(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??k8},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!_(a))try{let e=y(a,`wx`,384);try{C(e,s)}finally{g(e)}return P8(a),z8(a),H8({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=B8(a,i);if(e){if(I8(e)&&e.pid===process.pid)return S(a,s,{encoding:`utf-8`,mode:384}),P8(a),z8(a),H8({lockName:t,lockDir:n,lockPath:a});if(S8(e.pid))throw new j8(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{x(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function H8(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>J8({lockName:t,lockDir:n}),updatePort:e=>U8({lockName:t,lockDir:n,port:e})}}function U8(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=M8(n,t);if(!_(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||!C8(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&I8(o)){o.port=r;try{S(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function W8(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=M8(n,t);if((N8.get(i)??0)>1)return;let a;try{let e=JSON.parse(b(i,`utf-8`));if(!e||typeof e!=`object`||!C8(e.pid)){console.warn(`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){e.code!==`ENOENT`&&console.warn(`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&I8(a)&&a.draining!==!0){a.draining=!0;try{S(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function G8(e){let{lockName:t,lockDir:n}=e,r=M8(n,t);if(!_(r))return null;let i;try{let e=JSON.parse(b(r,`utf-8`));if(!e||typeof e!=`object`||!C8(e.pid))return null;i=e}catch{return null}if(!I8(i))return null;if(!S8(i.pid)){try{x(r)}catch{}return null}return i}function K8(e){let{lockName:t,lockDir:n}=e,r=M8(n,t);if(!_(r))return{status:`absent`};let i;try{i=JSON.parse(b(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!C8(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!I8(o))return{status:`stale`,lock:o};if(!S8(o.pid)){try{x(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}async function q8(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>G8({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function J8(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=M8(n,t);if(F8(a)){if(r){W8({lockName:t,lockDir:n});return}if(_(a))try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!I8(e))return;x(a),L8.delete(a)}catch(e){console.warn(`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var Y8=class extends j8{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function X8(e,t){try{return V8({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof j8&&e.lockName===`server`?new Y8(e.existing,e.lockPath):e}}function Z8(e,t){U8({lockName:`server`,lockDir:e,port:t})}function Q8(e){return G8({lockName:`server`,lockDir:e})}function $8(e,t){J8({lockName:`server`,lockDir:e,...t})}function e5(e){W8({lockName:`server`,lockDir:e})}function t5(e,t){return q8({lockName:`server`,lockDir:e,...t})}export{mG as $,ql as $a,MG as $i,z2 as $n,YG as $r,n0 as $t,a1 as A,L as Aa,g$ as Ai,I6 as An,Go as Ao,X0 as Ar,_2 as At,g1 as B,bl as Ba,Gq as Bi,n2 as Bn,gn as Bo,w2 as Br,G3 as Bt,m1 as C,W4 as Ca,i8 as Ci,K1 as Cn,dc as Co,L2 as Cr,A0 as Ct,b1 as D,P4 as Da,O6 as Di,O2 as Dn,$s as Do,lJ as Dr,z1 as Dt,o1 as E,hq as Ea,V6 as Ei,DG as En,A as Eo,x0 as Er,GG as Et,j1 as F,Zc as Fa,n8 as Fi,B1 as Fn,si as Fo,Y0 as Fr,e1 as Ft,v4 as G,su as Ga,zG as Gi,Cq as Gn,O as Go,C2 as Gr,VG as Gt,b4 as H,Xc as Ha,QG as Hi,e2 as Hn,zt as Ho,T2 as Hr,c2 as Ht,A1 as I,Cl as Ia,Y6 as Ii,V1 as In,br as Io,H6 as Ir,qG as It,p4 as J,Jc as Ja,Q4 as Ji,Aq as Jn,p0 as Jr,t0 as Jt,h4 as K,nu as Ka,e3 as Ki,Eq as Kn,ht as Ko,x2 as Kr,I1 as Kt,qq as L,wl as La,Rq as Li,n4 as Ln,un as Lo,j2 as Lr,U1 as Lt,i1 as M,qc as Ma,P$ as Mi,B3 as Mn,ma as Mo,Q0 as Mr,N1 as Mt,v1 as N,ou as Na,IY as Ni,BG as Nn,Ka as No,q0 as Nr,S1 as Nt,s1 as O,gb as Oa,b8 as Oi,N6 as On,Ks as Oo,Z1 as Or,w0 as Ot,nJ as P,Dl as Pa,cq as Pi,gG as Pn,qa as Po,J0 as Pr,C1 as Pt,_G as Q,Xl as Qa,LG as Qi,Qq as Qn,B0 as Qr,r0 as Qt,G4 as R,Sl as Ra,r1 as Ri,o4 as Rn,fn as Ro,h2 as Rr,W1 as Rt,UG as S,x8 as Sa,F4 as Si,I0 as Sn,P as So,X2 as Sr,k0 as St,d0 as T,pK as Ta,Y3 as Ti,H0 as Tn,ac as To,P2 as Tr,JG as Tt,y4 as U,pl as Ua,j3 as Ui,a4 as Un,Dt as Uo,E2 as Ur,b0 as Ut,g4 as V,Kc as Va,EG as Vi,a2 as Vn,cn as Vo,b2 as Vr,o2 as Vt,_4 as W,cu as Wa,Iq as Wi,eJ as Wn,k as Wo,S2 as Wr,J3 as Wt,d4 as X,Rl as Xa,PG as Xi,Fq as Xn,f0 as Xr,a0 as Xt,f4 as Y,jl as Ya,A4 as Yi,Nq as Yn,m0 as Yr,i0 as Yt,l4 as Z,au as Za,X3 as Zi,Zq as Zn,z0 as Zr,cJ as Zt,$8 as _,fq as _a,WZ as _i,N0 as _n,tc as _o,Z2 as _r,X1 as _t,V8 as a,Y4 as aa,U4 as ai,$G as an,zl as ao,q2 as ar,Jq as at,t5 as b,q4 as ba,M3 as bi,aJ as bn,Zs as bo,d2 as br,O1 as bt,S8 as c,J4 as ca,l8 as ci,_0 as cn,Al as co,B2 as cr,T1 as ct,W8 as d,B6 as da,e8 as di,q1 as dn,F as do,I2 as dr,T0 as dt,f2 as ea,sJ as ei,Q1 as en,fl as eo,K2 as er,SG as et,e5 as f,a8 as fa,kJ as fi,T3 as fn,Hs as fo,e4 as fr,E0 as ft,J8 as g,L3 as ga,X6 as gi,pG as gn,jc as go,u2 as gr,HG as gt,Q8 as h,j4 as ha,y8 as hi,KG as hn,M as ho,z6 as hr,z3 as ht,Y8 as i,Y$ as ia,T4 as ii,TG as in,Tl as io,N2 as ir,yG as it,y1 as j,lu as ja,B$ as ji,l2 as jn,Uo as jo,Z0 as jr,v2 as jt,x1 as k,op as ka,W3 as ki,P6 as kn,xs as ko,$0 as kr,g2 as kt,C8 as l,X$ as la,u8 as li,g0 as ln,Ls as lo,V2 as lr,D0 as lt,K8 as m,T6 as ma,A2 as mi,nK as mn,N as mo,D2 as mr,rK as mt,k8 as n,fK as na,G1 as ni,CG as nn,eu as no,U2 as nr,vG as nt,X8 as o,OG as oa,iJ as oi,_$ as on,Il as oo,c4 as or,Xq as ot,G8 as p,AG as pa,J6 as pi,eK as pn,Ws as po,t4 as pr,XG as pt,u4 as q,Yc as qa,C3 as qi,jq as qn,mt as qo,h0 as qr,o0 as qt,A8 as r,tK as ra,E4 as ri,wG as rn,ml as ro,W2 as rr,bG as rt,D8 as s,R4 as sa,Wq as si,y0 as sn,kl as so,J2 as sr,w1 as st,j8 as t,q6 as ta,oJ as ti,e0 as tn,El as to,G2 as tr,xG as tt,M8 as u,d8 as ua,hG as ui,ZG as un,uc as uo,F2 as ur,O0 as ut,U8 as v,mq as va,o6 as vi,j0 as vn,rc as vo,Q2 as vr,L0 as vt,u0 as w,M$ as wa,R3 as wi,V0 as wn,Pc as wo,R2 as wr,WG as wt,$6 as x,dK as xa,w3 as xi,F0 as xn,j as xo,Y2 as xr,D1 as xt,Z8 as y,FG as ya,i6 as yi,tJ as yn,I as yo,$2 as yr,R0 as yt,r3 as z,xl as za,_q as zi,t2 as zn,mn as zo,p2 as zr,J1 as zt};
|
|
460
|
+
//# sourceMappingURL=server-lock-iLcBw_q0-7VqZoW4r.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as e}from"./chunk-C94x7I9S.mjs";import{
|
|
1
|
+
import{s as e}from"./chunk-C94x7I9S.mjs";import{c as t,l as n,qo as r,s as i,u as a}from"./server-lock-iLcBw_q0-7VqZoW4r.mjs";import{Ar as o,Sn as s,ei as c,fa as l,kr as u,un as d,vn as f}from"./dist-Cz2oOaYb.mjs";import{t as p}from"./esm-CsQUg9js.mjs";import"./gh-detect-OjM7QxYB.mjs";import{E as m,S as ee,T as h,_ as g,b as te,o as ne,v as re,w as _}from"./init-iHmXas-2.mjs";import{_ as ie,d as ae,i as oe,v}from"./write-project-skill-DNrA5OdY.mjs";import"./loader-hl0o6W6h.mjs";import{c as y}from"./colors-8SzMRIVy.mjs";import"./preview-CPvGhej6.mjs";import{dirname as b,isAbsolute as x,join as S,relative as C,resolve as w}from"node:path";import{hostname as se}from"node:os";import{existsSync as T,lstatSync as ce,readFileSync as E,readlinkSync as le,rmSync as ue,statSync as de}from"node:fs";import{readFile as D,realpath as O}from"node:fs/promises";function k(e,r,o={}){let s=a(e,r);if(!T(s))return{status:`missing`,lockPath:s};let c;try{c=JSON.parse(E(s,`utf-8`))}catch{return{status:`corrupt`,lockPath:s}}if(!c||typeof c!=`object`||!n(c.pid))return{status:`corrupt`,lockPath:s};let l=c;if(!(o.isAlive??t)(l.pid))return{status:`dead-pid`,lockPath:s,lock:l};if(typeof l.machineId==`string`)return l.machineId===(o.machineId??i())?{status:`alive`,lockPath:s,lock:l}:{status:`foreign-host`,lockPath:s,lock:l};let u=o.host??se();return l.hostname===u?{status:`alive`,lockPath:s,lock:l}:{status:`foreign-host`,lockPath:s,lock:l}}function A(e){return e.replace(/:\d+$/,``)}function j(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:A(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:A(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:A(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function M(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function N(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function P(e){let t=M(e);if(t)return{kind:`doc`,...t};let n=N(e);return n?{kind:`folder`,...n}:null}const F=`# >>> open-knowledge cli >>>`,I=`# <<< open-knowledge cli <<<`,L=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function R(e){return S(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const z={existsSync:e=>T(e),readFileSync:(e,t)=>E(e,t),lstatSync:e=>ce(e),readlinkSync:e=>le(e)};function B(e,t=z){let n=R(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function V(e){let t=e.replace(L,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function H(e,t,n=z){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}var fe=r();function pe(e){return ie(e)||v(e)||ee(e)}const U=10*1024*1024;function me(e,t,n,r){let i=ne(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!pe(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(ue(a,{force:!0}),{kind:`removed`}):e.format===`toml`?_e(a,o):e.format===`yaml`?ge(a,e.topLevelKey,o):he(a,e.topLevelKey,e.serverMapSubKey,o)}function he(e,t,n,r){let i;try{i=E(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>U)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=m(i,g(t,n,r));return o?(l(e,a,{mode:_(e)}),{kind:`removed`}):{kind:`not-present`}}function ge(e,t,n){let r;try{r=E(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>U)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,fe.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),u=h(a);a.trim()===``||a.endsWith(`
|
|
2
2
|
`)?c.endsWith(`
|
|
3
3
|
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),u&&(c=c.replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\n/g,`\r
|
|
@@ -7,5 +7,5 @@ import{s as e}from"./chunk-C94x7I9S.mjs";import{Ko as t,c as n,l as r,s as i,u a
|
|
|
7
7
|
`)||(u=`${u}\n`):u=u.replace(/\n+$/,``),o&&(u=u.replace(/\r\n/g,`
|
|
8
8
|
`).replace(/\n/g,`\r
|
|
9
9
|
`));let d=`${i?``:``}${u}`;return d!==r&&l(e,d,{mode:_(e)}),{kind:`removed`}}const ve=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`deinit`]);function ye(e,t,n=s){if(e!==void 0&&!ve.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let W=null;function be(e){W=e}function xe(){return W??process.cwd()}var G=e(y(),1);function Se(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Ce(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 we(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:f(r),command:r,isDesktop:Se(r)}}function Te(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function K(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&Te(e)?`ui-orphan`:`stale`}const Ee=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function De(e){switch(e){case`running`:return G.default.green(e);case`desktop`:return G.default.blue(e);case`foreign`:return G.default.cyan(e);case`ui-orphan`:return G.default.magenta(e);case`stale`:return G.default.yellow(e)}}function q(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Oe(e){return`${q(e.server.usage)} | ${q(e.ui?.usage??null)}`}function ke(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function Ae(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=K(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,ke(e),Oe(e),t,String(n),Ce(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=De(K(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=G.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
10
|
-
`)}async function J(e={}){let t=e.discover??d,n=e.inspect??k,r=e.log??(e=>console.log(e)),i=e.resolveCommand??u,a=e.resolveUsage??o,s=await t(),c=[];for(let e of s){let t=n(e,`server`),r=n(e,`ui`),o=we(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&&c.push(o)}if(e.json){let e=c.map(e=>({...e,displayStatus:K(e)}));r(JSON.stringify(e,null,2));return}r(Ae(e.all?c:c.filter(e=>Ee.has(K(e)))))}function je(){return new p(`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 J({all:t.all===!0||e===`all`,json:t.json===!0})})}function Me(e,
|
|
11
|
-
//# sourceMappingURL=src-
|
|
10
|
+
`)}async function J(e={}){let t=e.discover??d,n=e.inspect??k,r=e.log??(e=>console.log(e)),i=e.resolveCommand??u,a=e.resolveUsage??o,s=await t(),c=[];for(let e of s){let t=n(e,`server`),r=n(e,`ui`),o=we(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&&c.push(o)}if(e.json){let e=c.map(e=>({...e,displayStatus:K(e)}));r(JSON.stringify(e,null,2));return}r(Ae(e.all?c:c.filter(e=>Ee.has(K(e)))))}function je(){return new p(`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 J({all:t.all===!0||e===`all`,json:t.json===!0})})}function Me(e,n,r={}){let i=r.isAlive??t,a=[];for(let[t,r]of[[`server`,e],[`ui`,n]])(r.status===`alive`||r.status===`foreign-host`&&i(r.lock.pid))&&a.push({name:t,pid:r.lock.pid,port:r.lock.port});return{targets:a}}function Y(e){let t=e.inspect??(t=>k(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=Me(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 X(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Ne(e,n=t){let r=await d(),i=null;for(let t of r){let r=k(t,`server`),a=k(t,`ui`);if(X(r,n)&&r.lock.port===e||X(a,n)&&a.lock.port===e)return t;i===null&&(X(r,n)&&r.lock.pid===e||X(a,n)&&a.lock.pid===e)&&(i=t)}return i}function Z(e){let t=Y({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Pe(e){return new p(`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 n=>{let r=n.length===0?void 0:n.join(` `);if(r===void 0){e();let t=Y({lockDir:c(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 J({});return}if(r===`all`){let e=await d();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let n=0;for(let r of e){let e=k(r,`server`),i=k(r,`ui`);!X(e,t)&&!X(i,t)||(Z(r),n++)}n===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(r)){let e=Number.parseInt(r,10),t=await Ne(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Z(t);return}Z(c(w(xe(),r)))})}function Fe(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Q(e,t){let n,r;try{n=await O(w(e)),r=await O(w(b(e)))}catch{return{kind:`not-git`}}if(!$(n,r))return{kind:`symlink-escape`};let i=S(n,`.git`),a;try{a=de(i)}catch{return{kind:`not-git`}}let o;if(a.isDirectory()){let e;try{e=await O(i)}catch{return{kind:`not-git`}}if(!$(e,n))return{kind:`symlink-escape`};o=e}else if(a.isFile()){let e;try{e=await D(i,`utf-8`)}catch{return{kind:`not-git`}}let t=/^gitdir:\s*(.+)$/m.exec(e.trim());if(!t)return{kind:`not-git`};let r=t[1].trim(),a=x(r)?r:w(n,r);try{o=await O(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=S(await Ie(o),`config`),c;try{c=await D(s,`utf-8`)}catch{return{kind:`not-git`}}let l=Re(c);if(l===null)return{kind:`no-origin`};let u=j(l);if(u===null||u.hostname!==`github.com`)return{kind:`non-github`};let d=u.owner.toLowerCase()===t.owner.toLowerCase(),f=u.name.toLowerCase()===t.repo.toLowerCase();return!d||!f?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://github.com/${u.owner}/${u.name}.git`}}async function Ie(e){let t;try{t=(await D(S(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=x(t)?t:w(e,t);try{return await O(n)}catch{return n}}function $(e,t){if(e===t)return!0;let n=C(t,e);return n.length>0&&!n.startsWith(`..`)&&!x(n)}function Le(e){let t=e.indexOf(`#`),n=e.indexOf(`;`),r=-1;return t>=0&&n>=0?r=Math.min(t,n):t>=0?r=t:n>=0&&(r=n),(r===-1?e:e.slice(0,r)).trim()}function Re(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=Le(n);if(e.length===0)continue;if(e.startsWith(`[`)){t=/^\[\s*remote\s+["']origin["']\s*\]$/.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/.exec(e);if(r)return ze(r[1])}return null}function ze(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const Be=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=re(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let n=oe(e,t);return{integration:`project-skill`,editorId:e.id,action:n.action,...n.path?{path:n.path}:{},...n.error?{error:n.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function Ve(e,t,n={},r=Be){let i=[];for(let a of t){let t=ae[a];for(let a of r)i.push(a.write(t,e,n))}return i}function He(e,t,n={}){return{integrations:Ve(e,t,n)}}export{M as _,Pe as a,j as b,ye as c,L as d,I as f,V as g,B as h,Y as i,me as l,R as m,Q as n,je as o,H as p,Fe as r,be as s,He as t,F as u,P as v,k as x,N as y};
|
|
11
|
+
//# sourceMappingURL=src-DhuiHwcZ.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Mn as e,ht as t}from"./server-lock-iLcBw_q0-DB1Ahu2b.mjs";import{Or as n,ar as r,vr as i}from"./dist-DXIG2Jyg.mjs";import{n as a,t as o}from"./esm-CsQUg9js.mjs";import{i as s,t as c}from"./gh-detect-BMbpd_Yj.mjs";import{n as l}from"./constants-UBjBavXu.mjs";import{spawn as u}from"node:child_process";import{basename as d,dirname as f,join as p}from"node:path";import{homedir as m}from"node:os";import{closeSync as h,existsSync as g,mkdirSync as _,openSync as v,statSync as y}from"node:fs";import{rm as b}from"node:fs/promises";import{setTimeout as x}from"node:timers/promises";const S=`OpenKnowledge.app`,C=`/Applications/${S}`;function w(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return y(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function T(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(E(e,C))return C;let t=p(e.homeDir??m(),`Applications`,S);return E(e,t)?t:null}function E(e,t){try{let n=p(t,`Contents`,`MacOS`,`OpenKnowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function D(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=T(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 O(e){(e.log??(e=>console.error(e)))("Launching OpenKnowledge 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 k(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${C}. 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 ${C} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${C} but launch dispatch did not fire (caller bug).`}}function A(e){return p(f(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const j=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function M(e){if(e.platform!==`darwin`||!j.test(e.execPath))return null;let t=A(e.execPath);return e.exists(t)?t:null}function N(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??g,a=r[1];return a?{command:M({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 P(e,t){return e.host??t.HOST??`127.0.0.1`}function F(e){let t=d(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var I=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 L(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 R(t){g(t.lockDir)||_(t.lockDir,{recursive:!0});let n=v(p(t.lockDir,e),`w`),r=t.spawn??u,{PORT:i,...a}=process.env,o=N();try{let e=r(o.command,[...o.prefixArgs,...t.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:t.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return e.unref(),e}finally{try{h(n)}catch{}}}function z(e,t,n){return e??(n===void 0?t:void 0)}function B(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function V(e,t,n){return e??(t!=null&&!n?1:0)}async function H(e){let t=e.spawn??u,n=N(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=V(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function U(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 W=t;function G(e,t,n=e=>b(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function K(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:i?1:0,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(i?1:0)}}}function q(e){let t=e.sigtermGraceMs??W,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>x(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 J(e){let{config:t,cwd:a,host:o}=e,l=e.skipAutoInit??!1,u=e.skipUiAutoSpawn??!1,d=e.idleThresholdMs??18e5,{existsSync:f,mkdirSync:p}=await import(`node:fs`),{basename:m,dirname:h}=await import(`node:path`),{bootServer:g,getLogger:_,isProcessAlive:v,readUiLock:y,resolveContentDir:b,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./dist-B5JbDwWb.mjs`),w=e.log??_(`start`),T=e.singleFile!==void 0,E=e.projectDir??a,D=T?n(e.singleFile).canonicalFilePath:void 0,O=D?h(D):void 0,k=D?m(D):void 0;if(!T){if(!l&&!r(a))throw new I(a);let t=process.env.OK_RECLAIM_DISABLE??null,n=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&w.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-RYSmTXdj.mjs`)).repairMcpConfigs)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){w.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-DO2QDHDR.mjs`)).repairLaunchJson)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){w.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-NtsjF26d.mjs`)).repairSkills)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){w.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let A=O??b(t,a);!T&&!f(A)&&(p(A,{recursive:!0}),w.info({contentDir:A},`Created content directory`));let j=null,M=async({lockDir:t})=>{if(j=L({uiLock:y(t),isAlive:v}),j.action===`spawn`&&!u)try{let n=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];R({lockDir:t,cwd:a,spawn:e.spawn,args:n}),w.info({reason:j.reason,uiPort:e.uiPort},`[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 j.action===`skip`&&w.info({port:j.port,pid:j.pid},`UI already running at port ${j.port}`)},N=e.reactShellDistDir===void 0,P=s(),F=i();{let e=S(T?E:a),t=Date.now(),n=await C(e);n!==`no-drain`&&w.info({event:`start-waited-for-draining-predecessor`,outcome:n,waitedMs:Date.now()-t,drainLockDir:e},n===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let z=await g({config:t,contentDir:A,projectDir:T?E:a,contentRoot:T?void 0:t.content.dir,port:e.port,host:o,quiet:!1,detectGh:c,tokenStore:P,embeddingsKeyStore:F,...T?{ephemeral:!0,singleDocRelPath:k,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:N,idleShutdownMs:d,skipAutoInit:!0,...N?{spawnUiSiblingFn:M}:{},idleShutdownHandler:t=>{let n=q({readUiLock:()=>y(z.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:w});return K(T?G(n,E):n,{log:w,exit:e.idleExit})},log:w,...e.serveContentAssets?{serveContentAssets:!0}:{},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});j||={action:`skip`,reason:`alive`,pid:0,port:0};let B=j,V=null;if(B.action===`skip`)V=B.port>0?B.port:null;else if(!u){let t=e.uiBindTimeoutMs??3e3;V=await U({readUiLock:()=>y(z.lockDir),now:Date.now,sleep:e=>x(e),timeoutMs:t,pollIntervalMs:50}),V===null&&w.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:z.httpServer,destroy:z.destroy,lockDir:z.lockDir,contentDir:A,port:z.port,ready:z.ready,degraded:z.degraded,uiSpawnDecision:j,resolvedUiPort:V}}function ee(e){if(e===`browser`||e===`app`)return e;throw new a(`--mode must be 'browser' or 'app'`)}function te(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new a(`--ui-port must be a port number between 1 and 65535`);return t}function Y(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function X(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Z(e,t){let n=Y(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner-BLebOalA.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-CmkIIbww.mjs`),c=process.cwd(),u=e;process.title=F(c);let d=P(t,process.env),f=t.port===void 0?void 0:Number(t.port),p=process.env.PORT?Number(process.env.PORT):void 0,m=t.uiPort===void 0?void 0:Number(t.uiPort),h=z(f,p,m);if(m!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./dist-B5JbDwWb.mjs`);if(B(m,e(t(c)))){await H({cwd:c,uiPort:m});return}}let g;try{g=await J({config:u,cwd:c,host:d,port:h,...m===void 0?{}:{uiPort:m},...t.serveContentAssets?{serveContentAssets:!0}:{},...t.reactShellDistDir?{reactShellDistDir:t.reactShellDistDir}:{},...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{}})}catch(e){e instanceof I&&(console.error(o(e.message)),process.exit(1));let t=await import(`./dist-B5JbDwWb.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(o(e.message)),process.exit(1)),m!==void 0&&Q(e,t)){await H({cwd:c,uiPort:m});return}let n=$(e,c,t);n!==null&&(console.error(o(n)),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let _=!1,v=async e=>{if(_)return;_=!0;let[t,...n]=X(e);console.log(i(`\n${t}`));for(let e of n)console.log(a(` ${e}`));try{await g.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{v(`SIGINT`)}),process.once(`SIGTERM`,()=>{v(`SIGTERM`)});let y=`http://${d}:${g.port}`,b=d===`0.0.0.0`||d===`::`?`http://0.0.0.0:${g.port}`:void 0,x=g.resolvedUiPort,S=x!==null&&x>0?`http://${d}:${x}`:y;console.log(r({name:`open-knowledge`,version:l,localUrl:S,apiUrl:S===y?void 0:y,networkUrl:b,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let C={"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`};g.ready.then(async()=>{if(g.degraded.length>0){console.log();for(let e of g.degraded){let t=C[e]??`${e} (check server logs for details)`;console.warn(` ${s(`⚠`)} ${s(e)}: ${a(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-gwoFcjXN.mjs`);e(S)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function Q(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function $(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=p(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`OpenKnowledge 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`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function ne(e){return new o(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`--ui-port <port>`,`Pin the ok ui sibling to <port> and connect (not exit) if a server already runs here — the worktree-preview recipe path`,te).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ee).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)`).option(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).option(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).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)
|
|
1
|
+
import{Mn as e,ht as t}from"./server-lock-iLcBw_q0-7VqZoW4r.mjs";import{Or as n,ar as r,vr as i}from"./dist-Cz2oOaYb.mjs";import{n as a,t as o}from"./esm-CsQUg9js.mjs";import{i as s,t as c}from"./gh-detect-OjM7QxYB.mjs";import{n as l}from"./constants-CvXLVbm6.mjs";import{spawn as u}from"node:child_process";import{basename as d,dirname as f,join as p}from"node:path";import{homedir as m}from"node:os";import{closeSync as h,existsSync as g,mkdirSync as _,openSync as v,statSync as y}from"node:fs";import{rm as b}from"node:fs/promises";import{setTimeout as x}from"node:timers/promises";const S=`OpenKnowledge.app`,C=`/Applications/${S}`;function w(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return y(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function T(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(E(e,C))return C;let t=p(e.homeDir??m(),`Applications`,S);return E(e,t)?t:null}function E(e,t){try{let n=p(t,`Contents`,`MacOS`,`OpenKnowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function D(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=T(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 O(e){(e.log??(e=>console.error(e)))("Launching OpenKnowledge 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 k(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${C}. 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 ${C} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${C} but launch dispatch did not fire (caller bug).`}}function A(e){return p(f(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const j=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function M(e){if(e.platform!==`darwin`||!j.test(e.execPath))return null;let t=A(e.execPath);return e.exists(t)?t:null}function N(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??g,a=r[1];return a?{command:M({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 P(e,t){return e.host??t.HOST??`127.0.0.1`}function F(e){let t=d(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var I=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 L(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 R(t){g(t.lockDir)||_(t.lockDir,{recursive:!0});let n=v(p(t.lockDir,e),`w`),r=t.spawn??u,{PORT:i,...a}=process.env,o=N();try{let e=r(o.command,[...o.prefixArgs,...t.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:t.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return e.unref(),e}finally{try{h(n)}catch{}}}function z(e,t,n){return e??(n===void 0?t:void 0)}function B(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function V(e,t,n){return e??(t!=null&&!n?1:0)}async function H(e){let t=e.spawn??u,n=N(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=V(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function U(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 W=t;function G(e,t,n=e=>b(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function K(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:i?1:0,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(i?1:0)}}}function q(e){let t=e.sigtermGraceMs??W,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>x(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 J(e){let{config:t,cwd:a,host:o}=e,l=e.skipAutoInit??!1,u=e.skipUiAutoSpawn??!1,d=e.idleThresholdMs??18e5,{existsSync:f,mkdirSync:p}=await import(`node:fs`),{basename:m,dirname:h}=await import(`node:path`),{bootServer:g,getLogger:_,isProcessAlive:v,readUiLock:y,resolveContentDir:b,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./dist-DArAF-Z8.mjs`),w=e.log??_(`start`),T=e.singleFile!==void 0,E=e.projectDir??a,D=T?n(e.singleFile).canonicalFilePath:void 0,O=D?h(D):void 0,k=D?m(D):void 0;if(!T){if(!l&&!r(a))throw new I(a);let t=process.env.OK_RECLAIM_DISABLE??null,n=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&w.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-BZ3WjjMF.mjs`)).repairMcpConfigs)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){w.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-Ci58ZFOB.mjs`)).repairLaunchJson)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){w.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-Do4RqKu3.mjs`)).repairSkills)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){w.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let A=O??b(t,a);!T&&!f(A)&&(p(A,{recursive:!0}),w.info({contentDir:A},`Created content directory`));let j=null,M=async({lockDir:t})=>{if(j=L({uiLock:y(t),isAlive:v}),j.action===`spawn`&&!u)try{let n=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];R({lockDir:t,cwd:a,spawn:e.spawn,args:n}),w.info({reason:j.reason,uiPort:e.uiPort},`[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 j.action===`skip`&&w.info({port:j.port,pid:j.pid},`UI already running at port ${j.port}`)},N=e.reactShellDistDir===void 0,P=s(),F=i();{let e=S(T?E:a),t=Date.now(),n=await C(e);n!==`no-drain`&&w.info({event:`start-waited-for-draining-predecessor`,outcome:n,waitedMs:Date.now()-t,drainLockDir:e},n===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let z=await g({config:t,contentDir:A,projectDir:T?E:a,contentRoot:T?void 0:t.content.dir,port:e.port,host:o,quiet:!1,detectGh:c,tokenStore:P,embeddingsKeyStore:F,...T?{ephemeral:!0,singleDocRelPath:k,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:N,idleShutdownMs:d,skipAutoInit:!0,...N?{spawnUiSiblingFn:M}:{},idleShutdownHandler:t=>{let n=q({readUiLock:()=>y(z.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:w});return K(T?G(n,E):n,{log:w,exit:e.idleExit})},log:w,...e.serveContentAssets?{serveContentAssets:!0}:{},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});j||={action:`skip`,reason:`alive`,pid:0,port:0};let B=j,V=null;if(B.action===`skip`)V=B.port>0?B.port:null;else if(!u){let t=e.uiBindTimeoutMs??3e3;V=await U({readUiLock:()=>y(z.lockDir),now:Date.now,sleep:e=>x(e),timeoutMs:t,pollIntervalMs:50}),V===null&&w.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:z.httpServer,destroy:z.destroy,lockDir:z.lockDir,contentDir:A,port:z.port,ready:z.ready,degraded:z.degraded,uiSpawnDecision:j,resolvedUiPort:V}}function ee(e){if(e===`browser`||e===`app`)return e;throw new a(`--mode must be 'browser' or 'app'`)}function te(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new a(`--ui-port must be a port number between 1 and 65535`);return t}function Y(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function X(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Z(e,t){let n=Y(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner-BLebOalA.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-CmkIIbww.mjs`),c=process.cwd(),u=e;process.title=F(c);let d=P(t,process.env),f=t.port===void 0?void 0:Number(t.port),p=process.env.PORT?Number(process.env.PORT):void 0,m=t.uiPort===void 0?void 0:Number(t.uiPort),h=z(f,p,m);if(m!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./dist-DArAF-Z8.mjs`);if(B(m,e(t(c)))){await H({cwd:c,uiPort:m});return}}let g;try{g=await J({config:u,cwd:c,host:d,port:h,...m===void 0?{}:{uiPort:m},...t.serveContentAssets?{serveContentAssets:!0}:{},...t.reactShellDistDir?{reactShellDistDir:t.reactShellDistDir}:{},...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{}})}catch(e){e instanceof I&&(console.error(o(e.message)),process.exit(1));let t=await import(`./dist-DArAF-Z8.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(o(e.message)),process.exit(1)),m!==void 0&&Q(e,t)){await H({cwd:c,uiPort:m});return}let n=$(e,c,t);n!==null&&(console.error(o(n)),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let _=!1,v=async e=>{if(_)return;_=!0;let[t,...n]=X(e);console.log(i(`\n${t}`));for(let e of n)console.log(a(` ${e}`));try{await g.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{v(`SIGINT`)}),process.once(`SIGTERM`,()=>{v(`SIGTERM`)});let y=`http://${d}:${g.port}`,b=d===`0.0.0.0`||d===`::`?`http://0.0.0.0:${g.port}`:void 0,x=g.resolvedUiPort,S=x!==null&&x>0?`http://${d}:${x}`:y;console.log(r({name:`open-knowledge`,version:l,localUrl:S,apiUrl:S===y?void 0:y,networkUrl:b,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let C={"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`};g.ready.then(async()=>{if(g.degraded.length>0){console.log();for(let e of g.degraded){let t=C[e]??`${e} (check server logs for details)`;console.warn(` ${s(`⚠`)} ${s(e)}: ${a(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-BE9TwPRU.mjs`);e(S)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function Q(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function $(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=p(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`OpenKnowledge 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`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function ne(e){return new o(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`--ui-port <port>`,`Pin the ok ui sibling to <port> and connect (not exit) if a server already runs here — the worktree-preview recipe path`,te).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ee).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)`).option(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).option(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).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
2
|
`),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.uiPort!==void 0&&e.push(`--ui-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=D(w());if(n.available){O({spawn:u});return}console.error(k(n.reason)),process.exit(1)}await Z(n,t)})}export{D as C,w as S,ne as _,V as a,K as b,F as c,z as d,P as f,R as g,B as h,q as i,X as l,Z as m,U as n,H as o,Y as p,J as r,L as s,I as t,Q as u,$ as v,O as w,N as x,G as y};
|
|
3
|
-
//# sourceMappingURL=start-
|
|
3
|
+
//# sourceMappingURL=start-CmL4qv8P.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,f as t,r as n}from"./start-CmL4qv8P.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};
|