@inkeep/open-knowledge 0.88.6-beta.1 → 0.88.6-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/cli.mjs +6 -6
  2. package/dist/constants-t9AfZY26.mjs +1 -0
  3. package/dist/{dist-BDrQsVYX.mjs → dist-BO5LOWYA.mjs} +1 -1
  4. package/dist/{dist-2lLb6-A6.mjs → dist-CWmsgB4D.mjs} +1 -1
  5. package/dist/index.mjs +3 -3
  6. package/dist/init-CTAfywlr.mjs +1 -0
  7. package/dist/{init-BPIylED-.mjs → init-DEZvHVW0.mjs} +2 -2
  8. package/dist/{launch-json-removal-D2MG5vwV.mjs → launch-json-removal-BiFnBtfK.mjs} +1 -1
  9. package/dist/loader-BVV3rwB9.mjs +1 -0
  10. package/dist/{loader-DgrgTQ37.mjs → loader-CiUplufh.mjs} +1 -1
  11. package/dist/{md-manager-BGnqyqi1-1WhsA8vv.mjs → md-manager-BGnqyqi1-COpgRhOl.mjs} +175 -173
  12. package/dist/{open-browser-D6bWSvWe.mjs → open-browser-DUUDzeiw.mjs} +1 -1
  13. package/dist/parse-worker.mjs +1 -1
  14. package/dist/preview-785_n4-9.mjs +1 -0
  15. package/dist/{preview-XbQaCJ3P.mjs → preview-BGT8FQ6l.mjs} +1 -1
  16. package/dist/public/assets/{AccountSection-CWruFc04.js → AccountSection-B533_CFl.js} +1 -1
  17. package/dist/public/assets/{ActivityModeContent-OCa-VxAn.js → ActivityModeContent-Bm2TgMK9.js} +1 -1
  18. package/dist/public/assets/{AddPropertiesButton-Du0GrCIg.js → AddPropertiesButton-DkHyn0cf.js} +1 -1
  19. package/dist/public/assets/{AgentConnectionsSection-BNRBe4FT.js → AgentConnectionsSection-BDpKRta5.js} +1 -1
  20. package/dist/public/assets/{AgentDiffPane-CIHKqaVC.js → AgentDiffPane-BodTaWgj.js} +1 -1
  21. package/dist/public/assets/{AttachmentsSection-FFnxL4AC.js → AttachmentsSection-64MnxUzI.js} +1 -1
  22. package/dist/public/assets/{CodeMirrorPropInput-B5qCGGIe.js → CodeMirrorPropInput-BpVp-E5x.js} +74 -74
  23. package/dist/public/assets/{ContentRulesSection-CSPiGJ-Q.js → ContentRulesSection-DmWfN_iy.js} +1 -1
  24. package/dist/public/assets/{DiffViewBoundary-BSZq1ctS.js → DiffViewBoundary-DE5ZZM6m.js} +1 -1
  25. package/dist/public/assets/DocumentContext-Cdsi5u2c.js +108 -0
  26. package/dist/public/assets/EditorModeToggle-DVVGiGDr.js +1 -0
  27. package/dist/public/assets/{ExcalidrawDocEditor-DDh2F5wX.js → ExcalidrawDocEditor-CXmmiQYE.js} +1 -1
  28. package/dist/public/assets/FeedbackForm-BSIF07lL.js +1 -0
  29. package/dist/public/assets/{ImportSkillDialog-CdnMVTQU.js → ImportSkillDialog-D94_dDU2.js} +1 -1
  30. package/dist/public/assets/{LinkPreviewsSection-DaE6CPLZ.js → LinkPreviewsSection-BcBB5Mr2.js} +1 -1
  31. package/dist/public/assets/{LintConfigEditor-B_NGO3_g.js → LintConfigEditor-dTqg6HBx.js} +1 -1
  32. package/dist/public/assets/{LintingSection-BLZjpOkj.js → LintingSection-CNCSP8QA.js} +1 -1
  33. package/dist/public/assets/{ManagedArtifactProperties-DKeTmK4r.js → ManagedArtifactProperties-BwRDC8sA.js} +1 -1
  34. package/dist/public/assets/ManagedArtifactProperties-CcAxjAa9.js +1 -0
  35. package/dist/public/assets/MermaidDocEditor-C1OgCPt4.js +1 -0
  36. package/dist/public/assets/{NetworkAccessSection-CNquEJ_U.js → NetworkAccessSection-DkX1Ccg2.js} +1 -1
  37. package/dist/public/assets/{PropertyDisplayRow-C0KKoVKA.js → PropertyDisplayRow-vYb8HrL-.js} +1 -1
  38. package/dist/public/assets/{PublishToGitHubDialog-vRTXJ5mS.js → PublishToGitHubDialog-Cp8YBcmH.js} +1 -1
  39. package/dist/public/assets/{SchemaConfigEditor-BXuzUT87.js → SchemaConfigEditor-WGJhlBCs.js} +1 -1
  40. package/dist/public/assets/{SearchSection-BhURm7NP.js → SearchSection-2P2_lNpn.js} +1 -1
  41. package/dist/public/assets/{SessionsHost-CD9QWcqn.js → SessionsHost-Dp9DeiAL.js} +2 -2
  42. package/dist/public/assets/{SettingsDialogBody-B3DtndlE.js → SettingsDialogBody-e6zwfLq2.js} +2 -2
  43. package/dist/public/assets/{ShareReceiveMissDialog-Bh-Pawsk.js → ShareReceiveMissDialog-C3LqR6yF.js} +1 -1
  44. package/dist/public/assets/{SkillToolbarControls-Cj1m3M_D.js → SkillToolbarControls-CwJU-tSi.js} +1 -1
  45. package/dist/public/assets/{SlidesToolbarControls-CkfjnfCl.js → SlidesToolbarControls-l-1sv-Cc.js} +1 -1
  46. package/dist/public/assets/SourceEditor-CH7OXRAW.js +1 -0
  47. package/dist/public/assets/{SyncSection-DA2y-Hwu.js → SyncSection-BJcZEjza.js} +1 -1
  48. package/dist/public/assets/{SyncStatusBadge-CuccsVp8.js → SyncStatusBadge-B50CKijD.js} +1 -1
  49. package/dist/public/assets/{TerminalLaunchContext-C5Rn2V0P.js → TerminalLaunchContext-B_gF4ByT.js} +1 -1
  50. package/dist/public/assets/{TerminalSection-DV6OfLfp.js → TerminalSection-izE_v8FN.js} +1 -1
  51. package/dist/public/assets/{TerminalWindowApp-Dttw_-wb.js → TerminalWindowApp-C1epN9CZ.js} +1 -1
  52. package/dist/public/assets/TextDocEditor-C3xrbdGv.js +1 -0
  53. package/dist/public/assets/{ThreadView-DcGvbYNe.js → ThreadView-DeLnbOfd.js} +1 -1
  54. package/dist/public/assets/{TimelineDiffPane-B5ihwsfW.js → TimelineDiffPane-PhoLGDyW.js} +1 -1
  55. package/dist/public/assets/{bridge-J5ARnBfd.js → bridge-BPIZEBCD.js} +9 -7
  56. package/dist/public/assets/{client-version-Ds8dKP3S.js → client-version-Bn38fidh.js} +1 -1
  57. package/dist/public/assets/cm-theme-DpKmjLo0.js +3 -0
  58. package/dist/public/assets/{comment-chips-DpV2PLim.js → comment-chips-BulsIGPm.js} +1 -1
  59. package/dist/public/assets/{config-provider-CYT9QAxv.js → config-provider-CbxzkzQ_.js} +1 -1
  60. package/dist/public/assets/{doc-undo-manager-CxrXee0V.js → doc-undo-manager-D2TgPcLo.js} +1 -1
  61. package/dist/public/assets/{ime-composition-BVJIRkRG.js → ime-composition-Fkxh3sb0.js} +1 -1
  62. package/dist/public/assets/{index-CRLcSRcP.js → index-CMyXHFY-.js} +7 -7
  63. package/dist/public/assets/{lint-plugins-DT37pCLD.js → lint-plugins-9842_I0-.js} +1 -1
  64. package/dist/public/assets/{markdownlint-rule-browser-DJ3hT7EE.js → markdownlint-rule-browser-BPUY-_hO.js} +1 -1
  65. package/dist/public/assets/{pending-receive-nav-store-BjPsgYNX.js → pending-receive-nav-store-BMCbYLuG.js} +1 -1
  66. package/dist/public/assets/{preferred-session-events-v4dLd1D3.js → preferred-session-events-BAlt9BzP.js} +1 -1
  67. package/dist/public/assets/{progress-Dh17ODC1.js → progress-COOClRZR.js} +1 -1
  68. package/dist/public/assets/{selection-context-BaXuwC8q.js → selection-context-BILpjCfJ.js} +1 -1
  69. package/dist/public/assets/{src-DErDTvvA.js → src-CwpH-C2-.js} +1 -1
  70. package/dist/public/assets/storage-scope-D0LHO15T.js +1 -0
  71. package/dist/public/assets/{tag-pill-input-CWGS7aQi.js → tag-pill-input-BSnGPd75.js} +1 -1
  72. package/dist/public/assets/{telemetry-impl-BufA9jTT.js → telemetry-impl-BY6m4dQu.js} +1 -1
  73. package/dist/public/assets/{telemetry-startup-BKKVbdkC.js → telemetry-startup-BXj909u4.js} +1 -1
  74. package/dist/public/assets/{typing-burst-detector-CjW6VPCG.js → typing-burst-detector-CvX8VoiX.js} +1 -1
  75. package/dist/public/assets/{use-activity-panel-C9mpIqKR.js → use-activity-panel-BCtT92Ba.js} +1 -1
  76. package/dist/public/assets/{use-open-skill-DYEQ1l_s.js → use-open-skill-DhY4Y0NP.js} +1 -1
  77. package/dist/public/assets/{use-terminal-enabled-BHb6WGCI.js → use-terminal-enabled-eL9XPx7R.js} +1 -1
  78. package/dist/public/assets/{use-timeline-entry-diff-wagvdoa6.js → use-timeline-entry-diff-CjTYJ45T.js} +1 -1
  79. package/dist/public/index.html +24 -24
  80. package/dist/{registry-probes-CL7CtgcH.mjs → registry-probes-bcwiwmsg.mjs} +1 -1
  81. package/dist/{removal-file-path-Lhdnt_8C.mjs → removal-file-path-vEg6Crwy.mjs} +1 -1
  82. package/dist/{repair-launch-json-BfhC4Uz3.mjs → repair-launch-json-DiAuyB8X.mjs} +1 -1
  83. package/dist/{repair-mcp-configs-0EMOXCcV.mjs → repair-mcp-configs-BF5SpuqE.mjs} +1 -1
  84. package/dist/src-C6vKy7oA.mjs +1 -0
  85. package/dist/{src-Cryizi3y.mjs → src-CIxs_FQO.mjs} +1 -1
  86. package/dist/{start-Ii5OzflL.mjs → start-D3SEY0yE.mjs} +3 -3
  87. package/dist/start-DqBQYZEF.mjs +1 -0
  88. package/package.json +4 -4
  89. package/dist/constants-CIdryYLD.mjs +0 -1
  90. package/dist/init-CmKJ4GqI.mjs +0 -1
  91. package/dist/loader-DPw8HKwV.mjs +0 -1
  92. package/dist/preview-B-4pTdig.mjs +0 -1
  93. package/dist/public/assets/DocumentContext-DdwkHm-8.js +0 -108
  94. package/dist/public/assets/EditorModeToggle-BdSgDYBt.js +0 -1
  95. package/dist/public/assets/FeedbackForm-kPjpeGxM.js +0 -1
  96. package/dist/public/assets/ManagedArtifactProperties-9H2U3tkI.js +0 -1
  97. package/dist/public/assets/MermaidDocEditor-CWTrRzU0.js +0 -1
  98. package/dist/public/assets/SourceEditor-DIwQ0GAl.js +0 -1
  99. package/dist/public/assets/TextDocEditor-XVYm-eND.js +0 -1
  100. package/dist/public/assets/cm-theme-ZGYbhAB4.js +0 -3
  101. package/dist/public/assets/storage-scope-BdMZBgIQ.js +0 -1
  102. package/dist/src-CeyWeqBH.mjs +0 -1
  103. package/dist/start-D5IUmX3A.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -398,7 +398,7 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content:
398
398
  `,i);if(e===-1)return null;i=e+1}let a=t.indexOf(`
399
399
  `,i),o=a===-1?t.length:a,s=i+r-1;return s<=o?s:null}function Sve(e,t){if(!e)return null;let n=jK(e.start,t),r=jK(e.end,t);return n===null||r===null||r<n?null:t.slice(n,r)}function Cve(e,t){let n=Sve(e.position,t);return{type:`rawMdxFallbackMdast`,originalType:e.type??`unknown`,value:n??``,unresolvedPosition:n===null,position:e.position}}function wve(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``,r=typeof process<`u`&&process.env?.OK_DEBUG_POSITION_SLICE===`1`,i=!1;rp(e,(e,t,a)=>{if(a!==void 0&&typeof t==`number`&&typeof e.type==`string`&&!xve.has(e.type)){let r=Cve(e,n);return a.children[t]=r,Mf}if(`children`in e&&Array.isArray(e.children)){let t=e;t.children.some(e=>e.type===`text`)&&(ave(t,n),uP(t,n))}if(sve(e,n,r,a),dve(e,a)&&(i=!0),e.type===`heading`&&a!==void 0&&typeof t==`number`){let n=e.position?.end?.line,r=a.children[t+1],i=r?.position?.start?.line;if(r?.type===`paragraph`&&typeof n==`number`&&typeof i==`number`&&i===n+1){let t=e;t.data??={},t.data.sourceContiguousNext=!0}}}),i&&bve(e,n)}}function Tve(e,t){let n={type:`mdxJsxFlowElement`,name:`MermaidFence`,attributes:[{type:`mdxJsxAttribute`,name:`chart`,value:e}],children:[]};return t&&(n.position=t),n}function Eve(){return e=>{rp(e,`code`,(e,t,n)=>{if(!n||t==null||e.lang!==`mermaid`)return;let r=Tve(typeof e.value==`string`?e.value:``,e.position);n.children[t]=r})}}function MK(e,t,n){for(let r=t;r<n;r++)e[r]=` `}function Dve(e,t){if(e[t]!==`<`)return null;let n=e.slice(t).toLowerCase();for(let r of[`pre`,`code`]){if(!n.startsWith(`<${r}`))continue;let i=e[t+r.length+1];if(i===`>`||i===`/`||i===` `||i===` `)return r}return null}function Ove(e,t){let n=null;for(let r=t;r<e.length;r++){let t=e[r];if(n!==null)t===n&&(n=null);else if(t===`"`||t===`'`)n=t;else if(t===`>`)return r+1}return null}function NK(e,t,n){let r=RegExp(`</${n}\\s*>`,`i`).exec(e.slice(t));return r?.index===void 0?null:t+r.index+r[0].length}function kve(e,t){let n=0;for(;e[t+n]==="`";)n+=1;if(n===0)return null;let r=t+n,i=r;for(;i<e.length;){if(e[i]!=="`"){i+=1;continue}let t=0;for(;e[i+t]==="`";)t+=1;if(t===n)return i+n;i+=t}return r}function Ave(e){let t=ZU(),n=!1,r=null;return e.map(({text:e,start:i})=>{if(r===null&&!n&&t(e))return{text:` `.repeat(e.length),start:i};let a=e.split(``),o=0;for(;o<e.length;){if(n){let t=e.indexOf(`-->`,o),r=t<0?e.length:t+3;if(MK(a,o,r),o=r,t<0)break;n=!1;continue}if(r!==null){let t=NK(e,o,r);if(MK(a,o,t??e.length),t===null)break;o=t,r=null;continue}let t=e.indexOf(`<!--`,o),i=-1,s=null;for(let t=o;t<e.length;t++){let n=Dve(e,t);if(n!==null){i=t,s=n;break}}let c=e.indexOf("`",o),l=t<0?i:i<0?t:Math.min(t,i);if(c>=0&&(l<0||c<l)){o=kve(e,c)??c+1;continue}if(t<0&&i<0)break;if(t>=0&&(i<0||t<i)){let r=e.indexOf(`-->`,t+4),i=r<0?e.length:r+3;if(MK(a,t,i),o=i,n=r<0,n)break;continue}let u=Ove(e,i);if(u===null||s===null)break;let d=NK(e,u,s),f=d??e.length;if(MK(a,i,f),o=f,r=d===null?s:null,r!==null)break}return{text:a.join(``),start:i}})}function jve(e){let t=[],n=0;for(let r=0;r<e.length;r++){let i=e[r];i===`
400
400
  `?(t.push({text:e.slice(n,r),start:n}),n=r+1):i===`\r`&&(t.push({text:e.slice(n,r),start:n}),e[r+1]===`
401
- `&&(r+=1),n=r+1)}t.push({text:e.slice(n),start:n});let r=Ave(t),i=e.split(``);for(let e of r)for(let t=0;t<e.text.length;t++)i[e.start+t]=e.text[t];return i.join(``)}function Mve(e,t,n,r){return r<=n||e.slice(n,r).trim().length===0?!1:t.slice(n,r).trim().length===0}function Nve(e){return e.type===`link`||e.type===`linkReference`}function Pve(e,t,n,r){let i=n.position?.start.offset,a=n.position?.end.offset;if(i===void 0||a===void 0)return;let o=r.slice(i,a),s={type:`text`,value:o,data:{sourceRaw:o},position:n.position};e.children.splice(t,1,s)}function Fve(){return(e,t)=>{let n=typeof t.value==`string`?t.value:String(t.value??``);if(n.length===0||!n.includes(`<!--`)&&!/<(pre|code)[\s/>]/i.test(n))return;let r=jve(n),i=e=>{for(let t=e.children.length-1;t>=0;t--){let a=e.children[t];if(!a||(`children`in a&&Array.isArray(a.children)&&i(a),!Nve(a)))continue;let o=a.position?.start.offset,s=a.position?.end.offset;o!==void 0&&s!==void 0&&Mve(n,r,o,s)&&Pve(e,t,a,n)}};i(e)}}const Ive=Object.assign(dye,{peek:()=>`$`}),Lve=Object.assign(fye,{peek:()=>`~`}),Rve=(()=>{for(let e of TU.extensions??[]){let t=e?.handlers?.mdxJsxFlowElement;if(typeof t==`function`)return t}throw Error(`mdast-util-mdx-jsx mdxJsxFlowElement to-markdown handler not found — the dirty MDX JSX serialize path cannot bind. Likely a breaking change in mdast-util-mdx-jsx (pinned in the root overrides); re-run the markdown-pipeline upgrade protocol (test:fidelity).`)})(),zve=/^[ \t]*(?:$|#{1,6}(?:[ \t]|[ \t]*$)|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function Bve(e){let t=e;return t.type===`rawMdxFallback`?{type:`mdxJsxFlowElement`,name:null,attributes:[],children:[],data:{sourceRaw:t.value??``}}:e}const Vve={text(e,t,n,r){if(typeof e.data?.sourceRaw==`string`&&YO(e.data.sourceRaw,e.value??``))return e.data.sourceRaw;let i=WN(e.data);if(i.kind===`malformed`&&typeof process<`u`&&process.env?.OK_DEBUG_POSITION_SLICE===`1`&&console.warn(`[escape-provenance] malformed escapedChars metadata: CommonMark-safe serialization applies`),i.kind===`valid`&&i.data.escapedChars.length>0){let t=e.value??``,a=i.data.escapedChars,o=``,s=0,c,l=(e,t)=>{if(!e)return;let i=c===`<`?e.indexOf(`>`):-1;i>=0&&(o+=VK(n,e.slice(0,i+1),{...r,before:r.before+o,after:e.slice(i+1,i+2)||t},!0),e=e.slice(i+1)),e&&(o+=VK(n,e,{...r,before:r.before+o,after:t}))};for(let{offset:e,char:n}of a)e>s&&l(t.slice(s,e),`\\`),o+=`\\${n}`,s=e+1,c=n;return s<t.length&&l(t.slice(s),r.after),o}return VK(n,e.value??``,r)},emphasis(e,t,n,r){let i=e.data?.sourceDelimiter??`*`,a=n.createTracker(r),o=n.enter(`emphasis`),s=a.move(i);return s+=WK(n.containerPhrasing(e,{before:s,after:i,...a.current()}),r,i),s+=a.move(i),o(),s},strong(e,t,n,r){let i=e.data?.sourceDelimiter??`**`,a=n.createTracker(r),o=n.enter(`strong`),s=a.move(i);return s+=WK(n.containerPhrasing(e,{before:s,after:i,...a.current()}),r,i),s+=a.move(i),o(),s},link(e,t,n,r){if(e.data?.sourceStyle===`autolink`&&Jve(e))return`<${e.url}>`;if(e.data?.sourceStyle===`gfm-autolink`){let i=e.children?.length===1?e.children[0]:null;if(i?.type===`text`&&typeof i.value==`string`){let a=i.value,o=qve(a,e.url);if(o===void 0||$ve(o,Zve(e,t,n,r)))return a;if(o===`protocol`&&eye(a))return`<${a}>`}}let i=n.createTracker(r),a=n.enter(`link`),o=n.enter(`label`),s=i.move(`[`);if(s+=i.move(n.containerPhrasing(e,{before:s,after:`](`,...i.current()})),s+=i.move(`](`),o(),s+=BK(n,i,e),e.title){let t=e.data?.sourceTitleMarker??`double`;s+=i.move(zK(e.title,t))}return s+=i.move(`)`),a(),s},image(e,t,n,r){let i=n.createTracker(r),a=n.enter(`image`),o=n.enter(`label`),s=i.move(`![`);if(s+=i.move(n.safe(e.alt??``,{before:s,after:`](`,...i.current()})),s+=i.move(`](`),o(),s+=BK(n,i,e),e.title){let t=n.enter(`titleQuote`);s+=i.move(` "`),s+=i.move(n.safe(e.title,{before:s,after:`"`,...i.current()})),s+=i.move(`"`),t()}return s+=i.move(`)`),a(),s},definition(e,t,n,r){let i=e.data?.sourceLayout??`inline`,a=e.data?.sourceTitleMarker??`double`,o=n.enter(`definition`),s=n.createTracker(r),c=n.enter(`label`),l=s.move(`[`);l+=s.move(n.safe(n.associationId(e),{before:l,after:`]`,...s.current()})),l+=s.move(`]:`),c();let u=i===`multiline`?`
401
+ `&&(r+=1),n=r+1)}t.push({text:e.slice(n),start:n});let r=Ave(t),i=e.split(``);for(let e of r)for(let t=0;t<e.text.length;t++)i[e.start+t]=e.text[t];return i.join(``)}function Mve(e,t,n,r){return r<=n||e.slice(n,r).trim().length===0?!1:t.slice(n,r).trim().length===0}function Nve(e){return e.type===`link`||e.type===`linkReference`}function Pve(e,t,n,r){let i=n.position?.start.offset,a=n.position?.end.offset;if(i===void 0||a===void 0)return;let o=r.slice(i,a),s={type:`text`,value:o,data:{sourceRaw:o},position:n.position};e.children.splice(t,1,s)}function Fve(){return(e,t)=>{let n=typeof t.value==`string`?t.value:String(t.value??``);if(n.length===0||!n.includes(`<!--`)&&!/<(pre|code)[\s/>]/i.test(n))return;let r=jve(n),i=e=>{for(let t=e.children.length-1;t>=0;t--){let a=e.children[t];if(!a||(`children`in a&&Array.isArray(a.children)&&i(a),!Nve(a)))continue;let o=a.position?.start.offset,s=a.position?.end.offset;o!==void 0&&s!==void 0&&Mve(n,r,o,s)&&Pve(e,t,a,n)}};i(e)}}const Ive=Object.assign(dye,{peek:()=>`$`}),Lve=Object.assign(fye,{peek:()=>`~`}),Rve=(()=>{for(let e of TU.extensions??[]){let t=e?.handlers?.mdxJsxFlowElement;if(typeof t==`function`)return t}throw Error(`mdast-util-mdx-jsx mdxJsxFlowElement to-markdown handler not found — the dirty MDX JSX serialize path cannot bind. Likely a breaking change in mdast-util-mdx-jsx (pinned in the root overrides); re-run the markdown-pipeline upgrade protocol (test:fidelity).`)})(),zve=/^[ \t]*(?:$|#{1,6}(?:[ \t]|[ \t]*$)|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function Bve(e){let t=e;return t.type===`rawMdxFallback`?{type:`mdxJsxFlowElement`,name:null,attributes:[],children:[],data:{sourceRaw:t.value??``}}:e}const Vve={text(e,t,n,r){if(typeof e.data?.sourceRaw==`string`&&YO(e.data.sourceRaw,e.value??``))return e.data.sourceRaw;let i=WN(e.data);if(i.kind===`malformed`&&typeof process<`u`&&process.env?.OK_DEBUG_POSITION_SLICE===`1`&&console.warn(`[escape-provenance] malformed escapedChars metadata: CommonMark-safe serialization applies`),i.kind===`valid`&&i.data.escapedChars.length>0){let t=e.value??``,a=i.data.escapedChars,o=``,s=0,c,l=(e,t)=>{if(!e)return;let i=c===`<`?e.indexOf(`>`):-1;i>=0&&(o+=VK(n,e.slice(0,i+1),{...r,before:r.before+o,after:e.slice(i+1,i+2)||t},!0),e=e.slice(i+1)),e&&(o+=VK(n,e,{...r,before:r.before+o,after:t}))};for(let{offset:e,char:n}of a)e>s&&l(t.slice(s,e),`\\`),o+=`\\${n}`,s=e+1,c=n;return s<t.length&&l(t.slice(s),r.after),o}return VK(n,e.value??``,r)},emphasis(e,t,n,r){let i=e.data?.sourceDelimiter??`*`,a=n.createTracker(r),o=n.enter(`emphasis`),s=a.move(i);return s+=WK(n.containerPhrasing(e,{before:s,after:i,...a.current()}),r,i),s+=a.move(i),o(),s},strong(e,t,n,r){let i=e.data?.sourceDelimiter??`**`,a=n.createTracker(r),o=n.enter(`strong`),s=a.move(i);return s+=WK(n.containerPhrasing(e,{before:s,after:i,...a.current()}),r,i),s+=a.move(i),o(),s},link(e,t,n,r){if(e.data?.sourceStyle===`autolink`&&Jve(e))return`<${e.url}>`;if(e.data?.sourceStyle===`gfm-autolink`){let i=e.children?.length===1?e.children[0]:null;if(i?.type===`text`&&typeof i.value==`string`){let a=i.value,o=qve(a,e.url);if(o===void 0||$ve(o,Zve(a,e,t,n,r)))return a;if(o===`protocol`&&eye(a))return`<${a}>`}}let i=n.createTracker(r),a=n.enter(`link`),o=n.enter(`label`),s=i.move(`[`);if(s+=i.move(n.containerPhrasing(e,{before:s,after:`](`,...i.current()})),s+=i.move(`](`),o(),s+=BK(n,i,e),e.title){let t=e.data?.sourceTitleMarker??`double`;s+=i.move(zK(e.title,t))}return s+=i.move(`)`),a(),s},image(e,t,n,r){let i=n.createTracker(r),a=n.enter(`image`),o=n.enter(`label`),s=i.move(`![`);if(s+=i.move(n.safe(e.alt??``,{before:s,after:`](`,...i.current()})),s+=i.move(`](`),o(),s+=BK(n,i,e),e.title){let t=n.enter(`titleQuote`);s+=i.move(` "`),s+=i.move(n.safe(e.title,{before:s,after:`"`,...i.current()})),s+=i.move(`"`),t()}return s+=i.move(`)`),a(),s},definition(e,t,n,r){let i=e.data?.sourceLayout??`inline`,a=e.data?.sourceTitleMarker??`double`,o=n.enter(`definition`),s=n.createTracker(r),c=n.enter(`label`),l=s.move(`[`);l+=s.move(n.safe(n.associationId(e),{before:l,after:`]`,...s.current()})),l+=s.move(`]:`),c();let u=i===`multiline`?`
402
402
  `:` `;l+=s.move(u);let d=String(e.url??``);if(l+=BK(n,s,e,!d||/[\0- ]/.test(d)),e.title){let t=i===`multiline`?`
403
403
  `:` `;l+=s.move(zK(e.title,a,t))}return o(),l},thematicBreak(e){return e.data?.sourceRaw??`---`},break(e,t,n){let r=e.data?.sourceRaw;return typeof r==`string`&&r.length>0?r:n.stack.includes(`tableCell`)||n.stack.includes(`okAtxHeading`)?`<br />`:e.data?.sourceStyle===`backslash`?`\\
404
404
  `:`
@@ -424,7 +424,7 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content:
424
424
  `:`
425
425
  `;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(`
426
426
  `)},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=PK(i.attributes??[]),l=i.data?.sourceBody;if(l&&s&&!c.includes(`
427
- `))return`${l.leading}<${s}${c?` ${c}`:``}>${l.afterOpenTag}`;if(!i.children||i.children.length===0)return s?c?`<${s} ${c} />`:`<${s} />`:``;let u={...i,attributes:(i.attributes??[]).map(Hve),children:(i.children??[]).map(Bve)};return Rve(u,t,n,r)},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=WK(n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),r,`==`),o+=i.move(`==`),a(),o},underline(e,t,n,r){let i=e.data?.sourceForm===`ins`?`<ins>`:`<u>`,a=e.data?.sourceForm===`ins`?`</ins>`:`</u>`,o=n.createTracker(r),s=n.enter(`underline`),c=o.move(i);return c+=n.containerPhrasing(e,{before:c,after:a,...o.current()}),c+=o.move(a),s(),c},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=PK(e.attributes??[]),i=(e.children??[]).map(e=>e&&typeof e==`object`&&`value`in e?String(e.value??``):``).join(``);return i?r?`<${n} ${r}>${i}</${n}>`:`<${n}>${i}</${n}>`: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=c++,i=s?.[r];return i===`lazy`&&r>0&&!zve.test(e)?e:i===`none`||i===0?`>${e}`:typeof i==`number`&&i>=2&&!e.startsWith(` `)?`>${` `.repeat(i)}${e}`:`> ${e}`})}};function PK(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}={${FK(n.value)}}`):t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function FK(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Hve(e){return e.type===`mdxJsxAttribute`&&typeof e.value==`string`&&e.value.includes(`"`)?{type:`mdxJsxAttribute`,name:e.name,value:{type:`mdxJsxAttributeValueExpression`,value:FK(e.value)}}:e}const Uve=/^https?:\/\//i,Wve=/^www\./i,Gve=/^https?:\/\/[A-Za-z0-9./:?#@+,;()!'-]*$/i,Kve=/www\./i;function qve(e,t){if(e===t&&Uve.test(e))return`protocol`;if(t===`http://${e}`&&Wve.test(e))return`www`;if(t===`mailto:${e}`)return`email`}function Jve(e){let t=``;for(let n of e.children){if(n.type!==`text`)return!1;t+=n.value}return t===e.url}function IK(e){return e>=65&&e<=90||e>=97&&e<=122}function LK(e){return IK(e)||e>=48&&e<=57}function RK(e){return e===45||e===95||LK(e)}function Yve(e){return e===43||e===46||RK(e)}function Xve(e){return e!==47&&!Yve(e)}function Zve(e,t,n,r){let i=t?.children??[],a=i.indexOf(e),o=a>0?i[a-1]:void 0,s=a>=0?i[a+1]:void 0,c=o?.type===`text`?o.value:r.before,l=s===void 0?r.after:n.handle(s,t,n,{...n.createTracker(r).current(),before:``,after:``});return{before:c.charCodeAt(c.length-1),after:l.charCodeAt(0),afterNext:l.charCodeAt(1)}}function Qve(e,t){return RK(e)||e===46&&LK(t)}function $ve(e,{before:t,after:n,afterNext:r}){return e===`email`?Xve(t)&&!Qve(n,r):(e===`protocol`?!IK(t):UK(t)!==`other`)&&UK(n)!==`other`}function eye(e){return Gve.test(e)&&!Kve.test(e)}function zK(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function BK(e,t,n,r=!1){let i=String(n.url??``),a=i.startsWith(`<`)&&i.endsWith(`>`);if(n.data?.sourceUrlForm===`angle-bracketed`&&!a||r){let n=e.enter(`destinationLiteral`),r=t.move(tye(i,e.stack.includes(`tableCell`)));return n(),r}let o=e.enter(`destinationRaw`),s=t.move(nye(i));return o(),s}function tye(e,t=!1){let n=`<`;for(let r=0;r<e.length;r++){let i=e[r];oH(i)||t&&i===`|`?n+=`\\${i}`:n+=i===`
427
+ `))return`${l.leading}<${s}${c?` ${c}`:``}>${l.afterOpenTag}`;if(!i.children||i.children.length===0)return s?c?`<${s} ${c} />`:`<${s} />`:``;let u={...i,attributes:(i.attributes??[]).map(Hve),children:(i.children??[]).map(Bve)};return Rve(u,t,n,r)},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=WK(n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),r,`==`),o+=i.move(`==`),a(),o},underline(e,t,n,r){let i=e.data?.sourceForm===`ins`?`<ins>`:`<u>`,a=e.data?.sourceForm===`ins`?`</ins>`:`</u>`,o=n.createTracker(r),s=n.enter(`underline`),c=o.move(i);return c+=n.containerPhrasing(e,{before:c,after:a,...o.current()}),c+=o.move(a),s(),c},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=PK(e.attributes??[]),i=(e.children??[]).map(e=>e&&typeof e==`object`&&`value`in e?String(e.value??``):``).join(``);return i?r?`<${n} ${r}>${i}</${n}>`:`<${n}>${i}</${n}>`: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=c++,i=s?.[r];return i===`lazy`&&r>0&&!zve.test(e)?e:i===`none`||i===0?`>${e}`:typeof i==`number`&&i>=2&&!e.startsWith(` `)?`>${` `.repeat(i)}${e}`:`> ${e}`})}};function PK(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}={${FK(n.value)}}`):t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function FK(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Hve(e){return e.type===`mdxJsxAttribute`&&typeof e.value==`string`&&e.value.includes(`"`)?{type:`mdxJsxAttribute`,name:e.name,value:{type:`mdxJsxAttributeValueExpression`,value:FK(e.value)}}:e}const Uve=/^https?:\/\//i,Wve=/^www\./i,Gve=/^https?:\/\/[A-Za-z0-9./:?#@+,;()!'-]*$/i,Kve=/www\./i;function qve(e,t){if(e===t&&Uve.test(e))return`protocol`;if(t===`http://${e}`&&Wve.test(e))return`www`;if(t===`mailto:${e}`)return`email`}function Jve(e){let t=``;for(let n of e.children){if(n.type!==`text`)return!1;t+=n.value}return t===e.url}function IK(e){return e>=65&&e<=90||e>=97&&e<=122}function LK(e){return IK(e)||e>=48&&e<=57}function RK(e){return e===45||e===95||LK(e)}function Yve(e){return e===43||e===46||RK(e)}function Xve(e){return e!==47&&!Yve(e)}function Zve(e,t,n,r,i){let a=n?.children??[],o=a.indexOf(t),s=o>0?a[o-1]:void 0,c=o>=0?a[o+1]:void 0,l=s?.type===`text`?s.value:i.before,u=c===void 0?i.after:r.handle(c,n,r,{...r.createTracker(i).current(),before:e,after:``});return{before:l.charCodeAt(l.length-1),after:u.charCodeAt(0),afterNext:u.charCodeAt(1)}}function Qve(e,t){return RK(e)||e===46&&LK(t)}function $ve(e,{before:t,after:n,afterNext:r}){return e===`email`?Xve(t)&&!Qve(n,r):(e===`protocol`?!IK(t):UK(t)!==`other`)&&UK(n)!==`other`}function eye(e){return Gve.test(e)&&!Kve.test(e)}function zK(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function BK(e,t,n,r=!1){let i=String(n.url??``),a=i.startsWith(`<`)&&i.endsWith(`>`);if(n.data?.sourceUrlForm===`angle-bracketed`&&!a||r){let n=e.enter(`destinationLiteral`),r=t.move(tye(i,e.stack.includes(`tableCell`)));return n(),r}let o=e.enter(`destinationRaw`),s=t.move(nye(i));return o(),s}function tye(e,t=!1){let n=`<`;for(let r=0;r<e.length;r++){let i=e[r];oH(i)||t&&i===`|`?n+=`\\${i}`:n+=i===`
428
428
  `?`&#xA;`:i===`\r`?`&#xD;`:i===`\\`?sH(e[r+1])?`\\\\`:`\\`:i}return`${n}>`}function nye(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 rye(e){return e.replace(/(?<!\\)&(?=(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z][A-Za-z0-9]*);)/g,(e,t)=>iye(t)?e:`\\${e}`)}function iye(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||t===160}const aye=/&#(?:x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);/g;function oye(e){return e.replace(aye,e=>_c(e)?``+e.slice(1):e)}function sye(e){return/[\r\n][\t ]*$/.test(e)}function VK(e,t,n,r=!1){let{matched:i}=hU(t,{escapeAware:!1});if(i.length===0)return HK(e,t,n,r);let a=``,o=0,s=i=>{i>o&&(a+=HK(e,t.slice(o,i),{...n,before:n.before+a,after:t.slice(i,i+1)||n.after},r)),o=i};for(let e of i)s(e.start),!sye(n.before+a)&&(a+=t.slice(e.start,e.end),o=e.end);return s(t.length),a}function HK(e,t,n,r=!1){let i=e.unsafe;e.unsafe=i.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]`||r&&e.character===`:`&&e.before===`[ps]`&&e.after===`\\/`||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
429
429
  ]|$)`};return delete t._compiled,t});let a;try{a=e.safe(oye(t),n)}finally{e.unsafe=i}return a=a.replaceAll(``,`\\&`),rye(uye(a,n))}function UK(e){if(Number.isNaN(e))return`ws`;let t=ep(e);return t===1?`ws`:t===2?`punct`:`other`}function cye(e,t,n){let r=UK(t),i=UK(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 lye(e,t,n){let r=t;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;if(r<e.length)return e[r]===`
430
430
  `||e[r]===`\r`;let i=n.after.charCodeAt(0);return Number.isNaN(i)||i===10||i===13}function uye(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)&&lye(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+=cye(i,o,s)?`\\${i}`.repeat(a-r):e.slice(r,a)}r=a;continue}n+=i,r+=1}return n}function WK(e,t,n){let r=n.startsWith(`_`)?`_`:`*`,i=t.before??``,a=t.after??``,o=e,s=o.charCodeAt(0);GK(i.charCodeAt(i.length-1),s,r)&&(o=KK(s)+o.slice(1));let c=o.charCodeAt(o.length-1);return GK(a.charCodeAt(0),c,r)&&(o=o.slice(0,-1)+KK(c)),o}function GK(e,t,n){return!(ep(t)!==1||n===`_`&&ep(e)===void 0)}function KK(e){return`&#x${e.toString(16).toUpperCase()};`}function dye(e,t,n,r){let i=e.value??``,a=e.data?.sourceDelimiter,o=typeof a==`string`&&/^\$+$/.test(a)?a.length:2;for(o===1&&!pye(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 fye(e,t,n,r){let i=e.data?.sourceDelimiter===`~`?`~`:`~~`,a=n.createTracker(r),o=n.enter(`strikethrough`),s=a.move(i);return s+=WK(n.containerPhrasing(e,{...a.current(),before:s,after:`~`}),r,i),s+=a.move(i),o(),s}function pye(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(`\\`))}const qK=[{mode:`protecting`,protect:yH,reservations:_H},{mode:`protecting`,protect:vU,reservations:wH},{mode:`protecting`,protect:pH,reservations:lH},{mode:`serializer-only`,reservations:[{to:``}]}];new Set(qK.flatMap(({reservations:e})=>e.map(({to:e})=>e)));function mye(e,t){switch(t.mode){case`protecting`:return t.protect(e);case`serializer-only`:return e}}function JK(e){return qK.reduce(mye,e)}function YK(e){return e.data?.sourceRaw}function hye(e){return e.type===`text`?e.value===``:e.type===`mdxJsxTextElement`&&YK(e)===``}function XK(e){return e.type===`paragraph`&&(e.children??[]).every(hye)}function ZK(e){let t=e.children??[],n=t[0]?.children?.length??0,r=0;for(let e=1;e<t.length;e++)r=Math.max(r,t[e]?.children?.length??0);let i=e.align??[];return Math.max(n,r,i.length)}function gye(e){switch(e.type){case`table`:return ZK(e)===0;case`code`:return e.data?.sourceStyle===`indented`&&/^\n*$/.test(e.value??``);case`thematicBreak`:return YK(e)===``;case`html`:return(e.value??``)===``;case`mdxJsxFlowElement`:return YK(e)===void 0&&e.data?.htmlBoundary===void 0&&(e.children??[]).length===0&&!e.name;case`list`:return(e.children??[]).length===0;default:return!1}}function _ye(e){let t=[];for(let n of e.children){if(n.type===`table`&&ZK(n)===0){console.warn(JSON.stringify({event:`table-serialize-dropped-empty`,rows:(n.children??[]).length}));continue}gye(n)||(n.type===`paragraph`&&n.children.length>0&&XK(n)&&(n.children=[]),t.push(n))}e.children=t}function vye(e,t){let n=e,r=t;return n.type===`heading`&&n.data?.sourceContiguousNext===!0&&r.type===`paragraph`}const yye=(e,t)=>{if(XK(e)||vye(e,t))return 0;let n=e.position,r=t.position;if(!n||!r)return;let i=r.start.line-n.end.line-1;return i>=1?i:void 0},QK=/(?<!\\)\$(?=\S)([^$\n]*?[^\s$])\$(?!\d)/g;function bye(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``;rp(e,`text`,(e,t,r)=>{if(r===void 0||t==null)return;let i=e.value;if(i.indexOf(`$`)===-1)return;let a=XN(e);QK.lastIndex=0;let o=[],s;for(;(s=QK.exec(i))!==null;){let e=s.index,t=e+s[0].length;if(eP(a,e,1)||eP(a,t-1,1)){QK.lastIndex=e+1;continue}o.push(s)}if(o.length===0)return;let c=[],l=0;for(let t of o){let r=t.index,i=r+t[0].length;r>l&&c.push($N(n,e,l,r));let a={type:`inlineMath`,value:t[1]},o=rP(n,e,r,i);o&&(a.position=o),c.push(a),l=i}return l<i.length&&c.push($N(n,e,l,i.length)),r.children.splice(t,1,...c),[Mf,t+c.length]})}}const xye=new Set([`strong`,`emphasis`,`delete`,`link`,`mark`,`comment`]);function Sye(e){if(e?.type!==`break`)return!1;let t=e.data?.sourceRaw;return typeof t!=`string`||t.length===0}function Cye(e){e.data??={},e.data.sourceRaw=`<br />`,e.data.sourceStyle=`html`}function $K(e){if(e?.type!==`text`)return!1;let t=e.data?.sourceRaw;return typeof t!=`string`||t.length===0}const eq=/[ \t]+$/,tq=/^[ \t]*$/;function wye(e){return e.some(e=>!($K(e)&&tq.test(e.value)))}function nq(e,t=!1){for(;e.length>0;){let n=e[e.length-1];if(Sye(n)){Cye(n);break}if(n&&xye.has(n.type)&&`children`in n){let t=n.children;if(nq(t,!0),t.length===0){e.pop();continue}}if(!t&&$K(n)&&eq.test(n.value)){let t=n.value.replace(eq,``);if(t.length>0){n.value=t;continue}if(wye(e.slice(0,-1))){e.pop();continue}if(e.every(e=>$K(e)&&tq.test(e.value))){let t=e[0];t.value=t.value.charAt(0),e.splice(1)}}break}}const Tye=new Set([`paragraph`,`heading`,`tableCell`]);function Eye(e){let t=e=>{if(Tye.has(e.type)&&`children`in e&&nq(e.children),`children`in e)for(let n of e.children)t(n)};t(e)}const rq={handlers:{tag:e=>`#${e.value}`},unsafe:[{character:`#`,inConstruct:[`phrasing`],before:`\\s`,after:`[A-Za-z]|[^\\x00-\\x7F]`}]};function Dye(){let e=this.data();e.toMarkdownExtensions||=[],e.toMarkdownExtensions.some(e=>e===rq)||e.toMarkdownExtensions.push(rq)}const Oye=new Set([`u`,`ins`]);function kye(){return e=>{rp(e,`mdxJsxTextElement`,(e,t,n)=>{if(n===void 0||t==null||e.name===null||!Oye.has(e.name)||(e.attributes??[]).length>0)return;let r={type:`underline`,children:e.children??[],data:{sourceForm:e.name===`ins`?`ins`:`u`}};return e.position&&(r.position=e.position),n.children.splice(t,1,r),t+1})}}function Aye(e){return e.children.some(e=>{let t=e.type;return t!==`yaml`&&t!==`toml`})?e:{...e,children:[...e.children,{type:`paragraph`,children:[]}]}}const jye=[{name:`remark-parse`,plugin:G_},{name:`escape-provenance`,plugin:H_e},{name:`remark-mdx-agnostic`,plugin:EU},{name:`remark-gfm`,plugin:ug},{name:`remark-math`,plugin:EW,options:{singleDollarTextMath:!1}},{name:`remark-wiki-link`,plugin:YU},{name:`remark-github-alerts`,plugin:SW,options:aG},{name:`callout-transformer`,plugin:iG},{name:`restore-from-mdx`,plugin:bU},{name:`void-br-promoter`,plugin:AU},{name:`restore-entity-refs`,plugin:gH},{name:`restore-backslash-escapes`,plugin:bH},{name:`details-accordion-promoter`,plugin:UG},{name:`div-align-promoter`,plugin:QG},{name:`image-promoter`,plugin:K_e},{name:`indented-code-promoter`,plugin:Z_e},{name:`math-promoter`,plugin:ive},{name:`single-dollar-math-promoter`,plugin:bye},{name:`highlight-promoter`,plugin:G_e},{name:`underline-promoter`,plugin:kye},{name:`mermaid-promoter`,plugin:Eve},{name:`comment-promoter`,plugin:cG},{name:`merged-post-parse-walker`,plugin:wve},{name:`empty-task-item-unmint`,plugin:aK},{name:`link-reference-destination`,plugin:rve},{name:`non-rendering-context-demote`,plugin:Fve},{name:`ensure-non-empty-doc`,plugin:()=>Aye}];function Mye(e){let t=jg();for(let e of jye)t=`options`in e&&e.options!==void 0?t.use(e.plugin,e.options):t.use(e.plugin);return t=t.use(mW,{schema:e.schema,handlers:e.handlers}),t.freeze(),t}function Nye(e){let t=jg().use(o_,[`yaml`]).use(ug,{tablePipeAlign:!1}).use(EW,{singleDollarTextMath:!1}).use(EU).use(YU).use(Dye).use(Vz,{bullet:`-`,fences:!0,rule:`-`,join:[yye],...e.toMarkdownHandlers?{handlers:e.toMarkdownHandlers}:{}});return t.freeze(),t}function iq(e){return e.charCodeAt(0)===65279?{source:e.slice(1),hadBom:!0}:{source:e,hadBom:!1}}const aq=/^\n+$/,oq=/^\n{2,}$/;function sq(e,t,n){let r,i,a=e.children;if(a.length>0){let e=a[0]?.position?.start?.offset;if(typeof e==`number`&&e>0){let n=t.slice(0,e);aq.test(n)&&(r=n)}let n=a[a.length-1]?.position?.end?.offset;if(typeof n==`number`&&n<=t.length){let e=t.slice(n);oq.test(e)&&(i=e)}}if(!n&&r===void 0&&i===void 0)return;let o={...n?{bom:!0}:{},...r===void 0?{}:{leading:r},...i===void 0?{}:{trailing:i}};return e.data??={},e.data.sourceDocBoundary=o,o}function Pye(e){if(typeof e!=`object`||!e)return;let t=e,n={};return t.bom===!0&&(n.bom=!0),typeof t.leading==`string`&&aq.test(t.leading)&&(n.leading=t.leading),typeof t.trailing==`string`&&oq.test(t.trailing)&&(n.trailing=t.trailing),n.bom||n.leading||n.trailing?n:void 0}function Fye(e,t){let{source:n,hadBom:r}=iq(e),i=MG(n),a=new Cg(JK(i)),o=t.parse(a);a.value=i;let s=t.runSync(o,a);yK(s,i);let c=sq(s,i,r),l=c?Ms(s,c):void 0,u=t.stringify(s);return l?u.type.create({...u.attrs,sourceDocBoundary:l},u.content,u.marks):u}function Iye(e,t){return cq(e,t,!1)}function Lye(e,t){return cq(e,t,!0)}function cq(e,t,n){let{source:r,hadBom:i}=iq(e),a=MG(r),o=new Cg(JK(a)),s=t.parse(o);o.value=a;let c=t.runSync(s,o);n&&yK(c,a);let l=sq(c,a,i);return n&&l&&Ms(c,l),c}function Rye(e,t,n){let r=gW(e,{schema:n.schema,nodeHandlers:n.pmNodeHandlers,markHandlers:n.pmMarkHandlers});lq(r),rK(r),Eye(r),_ye(r);let i=Pye(e.attrs?.sourceDocBoundary),a=String(t.stringify(r));return i?.leading&&(a=i.leading+a),i?.trailing&&(a=a.replace(/\n+$/,``)+i.trailing),i?.bom&&(a=`\uFEFF${a}`),a}function lq(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)lq(t);for(let t=0;t+1<e.children.length;){let n=e.children[t],r=e.children[t+1],i=n?.data,a=r?.data,o=GN(i)?i.escapedChars:null,s=GN(a)?a.escapedChars:null;if(n?.type!==`text`||r?.type!==`text`||typeof n.data?.sourceRaw==`string`||typeof r.data?.sourceRaw==`string`||o===null&&s===null){t+=1;continue}let c=n.value.length;n.value+=r.value,n.data??={},n.data.escapedChars=[...o??[],...(s??[]).map(e=>({...e,offset:e.offset+c}))],r.data?.entityRefSpans?.length&&(n.data.entityRefSpans=[...n.data.entityRefSpans??[],...r.data.entityRefSpans.map(e=>({...e,offset:e.offset+c}))]),e.children.splice(t+1,1)}}}var zye=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};freshnessHolder={checker:void 0};authoredJsxSource=jW(e=>this.schema.nodeFromJSON(this.parseWithFallback(e)));constructor(e){this.schema=mO(e.extensions),this.handlers=Uye(this.schema,this.parseCtx),this.freshnessHolder.checker=e.deriveStructuralFreshness?sc({parse:e=>this.parseWithFallback(e)}):void 0;let{nodeHandlers:t,markHandlers:n}=Wye(this.schema,this.freshnessHolder,this.authoredJsxSource);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=Mye({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=Nye({toMarkdownHandlers:Vve})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return Fye(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?Iye(e,this.parseProcessor):{type:`root`,children:[]}}parseToEditorMdast(e){return e.trim()?Lye(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?PW(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 Rye(n,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}finally{this.freshnessHolder.checker=r}}};const uq=IB();function dq(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 r[e]=i?.type===`boolean`?t.value===`true`:t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function fq(e){let t=!1;return e.descendants(e=>t?!1:e.type.name===`jsxInline`?(e.attrs.sourceDirty&&(t=!0),!1):e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function Bye(e,t){return e.attrs.sourceDirty||fq(e)?!0:t?t.isDiverged(e.toJSON()):!1}function Vye(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0||t.every(e=>e.type===`text`&&e.value===``)}function pq(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 mq(e,t){if(e.length===0)return pq({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return pq({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:[mq(n.children,t)]}}return pq({type:`inlineCode`,value:hq(e)},t)}function hq(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=hq(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const Hye=Uc;function Uye(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=dW(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=dW(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=ks(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r,sourceUrlForm:e.data?.sourceUrlForm??null})},i.imageReference=n.imageReference?e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):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)return r.sourceLiteral?e.text(n,[r.sourceLiteral.create({sourceRaw:i})]):e.text(n);let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n);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&&bc(t.raw)!==null&&_c(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);r&&l.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length);if(i){if(t.kind===`escape`)l.push(e.text(i,[r.escapeMark.create()]));else if(r.sourceLiteral){let n=bc(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);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=fW(a,e=>({sourceDelimiter:e.data?.sourceDelimiter===`~`?`~`:`~~`}))),r.highlight&&(i.mark=fW(r.highlight)),r.underline&&(i.underline=fW(r.underline,e=>({sourceForm:e.data?.sourceForm===`ins`?`ins`:`u`}))),r.comment&&(i.comment=fW(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=dW(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=fW(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=fW(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=dW(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,sourceUnclosedFence:t.data?.sourceUnclosedFence??!1,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=dW(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=dW(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:n.data?.resolvedUrl??``,title:n.data?.resolvedTitle??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,s=!!o.spec.attrs?.sourceUrlForm;i.definition=i=>{let c={title:i.title??null};return n&&(c.identifier=i.identifier??``),c.label=i.label??i.identifier??``,e?c.url=i.url??``:t&&(c.href=i.url??``),r&&(c.sourceLayout=i.data?.sourceLayout??null),a&&(c.sourceTitleMarker=i.data?.sourceTitleMarker??null),s&&(c.sourceUrlForm=i.data?.sourceUrlForm??null),o.createAndFill(c)}}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=uq.getOrWildcard(o),c=dq(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=ks(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})}let i=t.name??``,o=i?uq.get(i):void 0;if(o&&n.jsxInline){let e=dq(t.attributes,o.props),a=r(t.data)??``,s=(t.children??[]).map(e=>e&&typeof e==`object`&&`value`in e?String(e.value??``):``).join(``);return s&&(e.children=s),n.jsxInline.createAndFill({componentName:i,attributes:t.attributes,sourceRaw:a,sourceDirty:!1,props: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=i.data?.sourceTarget??null,u=i.data?.sourceAnchor??null,d=i.data?.sourceAlias??null,f=tk(o),{resolveEmbed:p,sourcePath:m}=t.current,h=p&&m?p(o,m)??null:null,g=h?`/${h}`:o,_=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(_&&Hye.has(f)&&n.jsxComponent&&uq.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,alt:s??o,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d}});if(_&&Wc.has(f)&&n.jsxComponent&&uq.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,title:s??o,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d}});if(_&&Kc.has(f)&&n.jsxComponent&&uq.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,title:s??o,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d}});if(_&&qc.has(f)&&n.jsxComponent&&uq.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&m?e(o,m)??null:null,i=r===null?null:$U(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,target:o,anchor:c,alias:s,size:i,sourceTarget:l,sourceAnchor:u,sourceAlias:d}})}let v=s||(c?`${o}#${c}`:o);if(r.link){let t=r.link.create({href:g,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d});return e.text(v,[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=dW(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 Wye(e,t,n){let r={},i={},a=e.nodes,o=e.marks;a.paragraph&&(r.paragraph=_W(`paragraph`)),a.blockquote&&(r.blockquote=_W(`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}:{}})),a.heading&&(r.heading=_W(`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||void 0,sourceLeadingIndent:e.attrs.sourceLeadingIndent??void 0,sourceInteriorSpacing:e.attrs.sourceInteriorSpacing??void 0}}))),a.codeBlock&&(r.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,sourceUnclosedFence:e.attrs.sourceUnclosedFence===!0||void 0,sourceFenceIndent:e.attrs.sourceFenceIndent??void 0,sourceInfoPadding:e.attrs.sourceInfoPadding??void 0,sourceIndents:e.attrs.sourceIndents??void 0}}}),a.thematicBreak&&(r.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),a.hardBreak&&(r.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle,...typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0?{sourceRaw:e.attrs.sourceRaw}:{}}})),a.list&&(r.list=_W(`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}}))),a.listItem&&(r.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&Vye(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}}),a.table&&(r.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}),a.tableRow&&(r.tableRow=_W(`tableRow`));let s=(e,t)=>{let n={type:`tableCell`,children:wP(t)},r=e.attrs.sourcePadding;return typeof r==`object`&&r&&typeof r.left==`number`&&typeof r.right==`number`&&(n.data={sourcePadding:r}),n};if(a.tableCell&&(r.tableCell=(e,t,n)=>s(e,n.all(e))),a.tableHeader&&(r.tableHeader=(e,t,n)=>s(e,n.all(e))),a.image&&(r.image=e=>{let t={type:`image`,url:Os(e.attrs.src,e.attrs.sourceUrl),alt:e.attrs.alt,title:e.attrs.title};return e.attrs.sourceUrlForm===`angle-bracketed`&&(t.data={sourceUrlForm:`angle-bracketed`}),t}),a.imageReference&&(r.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`}}),a.htmlBlock&&(r.htmlBlock=e=>({type:`html`,value:e.attrs.content})),a.linkDefinition??a.linkRefDef){let e=a.linkDefinition?`linkDefinition`:`linkRefDef`;r[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),e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);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(a.jsxComponent&&(r.jsxComponent=(e,r,i)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let a=e.attrs.componentName||null,o=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[],s=()=>({type:`mdxJsxFlowElement`,name:a,attributes:o,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}});if(!Bye(e,t.checker)&&e.attrs.sourceRaw)return s();let c=uq.getOrWildcard(a??`*`),l={all:e=>i.all(e),registry:uq,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.`)}},u=c.serialize(e,l),d=kW(u,a);if(!d||fq(e))return u;let f=n.read(e,d,e=>c.serialize(e,l));return f?f.kind===`verbatim`?s():{...d,data:{...d.data,sourceBody:f.body}}:d}),a.rawMdxFallback&&(r.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}}}}),a.jsxInline&&(r.jsxInline=e=>{let t=e.attrs.componentName||``;if(t&&e.attrs.sourceDirty)return aB(t,e,uq.get(t)?.props);let n=e.attrs.attributes,r=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:t||null,attributes:Array.isArray(n)?n:[],children:[],data:{sourceRaw:String(r)}}}),a.mathInline&&(r.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}}:{}}}),a.wikiLink&&(r.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}]}}),a.tag&&(r.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),a.wikiLinkEmbed&&(r.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}]}}),o.emphasis&&(i.emphasis=vW(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),o.strong&&(i.strong=vW(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),o.code&&(i.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return mq(n,{sourceFenceChar:r,sourceFenceLength:i,sourcePadded:e.attrs.sourcePadded===!0||void 0})}),o.strike??o.delete){let e=o.strike?`strike`:`delete`;i[e]=vW(`delete`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter===`~`?`~`:`~~`}}))}return o.highlight&&(i.highlight=vW(`mark`)),o.underline&&(i.underline=vW(`underline`,e=>({data:{sourceForm:e.attrs.sourceForm===`ins`?`ins`:`u`}}))),o.comment&&(i.comment=vW(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),a.commentBlock&&(r.commentBlock=_W(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),a.footnoteReference&&(r.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),a.footnoteDefinition&&(r.footnoteDefinition=_W(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),o.link&&(i.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=typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,o=typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,s=typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null,c=i||(r?`${t}#${r}`:t),l=n.map(e=>`value`in e&&typeof e.value==`string`?e.value:``).join(``);return l!==c&&l.trim().length>0&&!l.includes(`]]`)&&(i=l,c=l),{type:`wikiLinkEmbed`,value:c,data:{target:t,anchor:r,alias:i,sourceTarget:a,sourceAnchor:o,sourceAlias:s},children:[{type:`text`,value:c}]}}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}}),o.escapeMark&&(i.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}),o.sourceLiteral&&(i.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 YO(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:r,markHandlers:i}}const Gye=new Set([`img`,`video`,`audio`,`mark`,`u`,`ins`]);new Map(PB.flatMap(e=>e.surface===`compat`&&Gye.has(e.rendersAs)?[[e.name,e]]:[])),em(`<>`);var gq={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100};gq.SINGLE_TILDE,gq.COMPARISON_OPERATORS,gq.HTML_TAGS,gq.SETEXT_HEADINGS,gq.LINKS,gq.BOLD_ITALIC,gq.BOLD,gq.ITALIC_DOUBLE_UNDERSCORE,gq.ITALIC_SINGLE_ASTERISK,gq.ITALIC_SINGLE_UNDERSCORE,gq.INLINE_CODE,gq.STRIKETHROUGH,gq.KATEX,gq.INLINE_KATEX,jg().use(G_).use(ug);const _q=U(xt),Kye=U(iee),qye=V({alwaysOn:L().int().nonnegative(),onTrigger:L().int().nonnegative(),onDemand:L().int().nonnegative()}).strict();V({intents:B(V({satisfierId:I().min(1),desired:U([`present`,`absent`])}).loose()),...tf,summary:nf}).loose();const Jye=V({satisfierId:I(),agentId:I(),piece:I(),scope:I(),kind:I(),pathId:I().optional(),desired:U([`present`,`absent`]),action:U(_a),errorId:I().optional()}).loose(),Yye=V({kind:I(),satisfierIds:B(I()),agentIds:B(I()),pathId:I().optional(),blockedReason:I().optional()}).loose(),Xye=V({state:I(),strictness:B(U(ha)).optional()}).loose(),Zye=V({probes:V({env:U([`desktop`,`local-web`,`remote-web`]),satisfiers:H(I(),Xye)}).loose(),detection:V({detected:B(I()),probed:R()}).loose()}).loose();V({actions:B(Jye),conflicts:B(Yye),withheld:B(I()),snapshot:Zye}).loose(),V({entries:B(V({level:U([`info`,`warn`,`error`]),message:I().max(8192),event:I().optional(),fields:H(I(),z()).optional(),ts:L().optional(),sourceId:I().optional(),lineNumber:L().optional()}).loose()).max(100),droppedSinceLastFlush:L().int().min(0).optional()}).loose(),V({accepted:L().int().min(0)}).loose();const Qye=V({exact:I().min(1),prefix:I(),suffix:I(),start:L().int().nonnegative(),end:L().int().nonnegative()}),$ye=B(Qi([I(),L().int().nonnegative()])),ebe=$i(`kind`,[V({kind:W(`body`)}),V({kind:W(`property`),key:I().min(1),path:$ye.default([])})]).default({kind:`body`}),tbe=U([`anchored`,`orphaned`,`resolved`]),vq=V({threadId:I().min(1),docName:I().min(1),target:ebe,anchor:Qye.nullable(),state:tbe,queued:R(),latestComment:I(),createdBy:I().min(1),createdAt:L(),updatedAt:L().optional()}),yq=V({docName:I(),instruction:I(),property:I().nullable(),passage:V({exact:I(),prefix:I(),suffix:I()}).nullable(),anchorLost:R(),passageRepeats:R()}).loose(),bq=V({threadId:I(),ok:W(!0)}),xq=V({threadId:I(),ok:W(!1),error:W(`not-found`)});V({threads:B(vq)}).loose(),V({meta:vq,orphaned:R()}).loose(),V({threadId:I()}).loose(),V({meta:vq,payload:yq}).loose(),V({results:B(Qi([bq.extend({meta:vq,payload:yq}),xq]))}).loose(),V({results:B(Qi([bq.extend({meta:vq}),xq]))}).loose();const Sq=[`ours`,`theirs`],Cq=[`check-failed`,`too-large`,`conflict-markers`,`no-base`,`no-merge-engine`,`outside-settings-applied`,`outside-settings-invalid`],nbe=[`no-history-or-backup`,`keeps-changing`,`not-utf8`,`unreadable`],rbe=V({duplicated:L().int().nonnegative(),restoredDeletedHere:L().int().nonnegative(),restoredDeletedOutside:L().int().nonnegative()}),wq={id:I().min(1),docName:I().min(1),file:I().min(1),firstAt:I().min(1),lastAt:I().min(1),events:L().int().positive(),entries:B(I().min(1))},Tq=$i(`kind`,[V({...wq,kind:W(`both-kept`),kept:rbe}).loose(),V({...wq,kind:W(`moved-to-history`),side:U(Sq),reason:U(Cq)}).loose(),V({...wq,kind:W(`moved-to-backup`),side:U(Sq),reason:U(Cq),backup:I().min(1)}).loose(),V({...wq,kind:W(`save-held`),cause:U(nbe)}).loose()]);V({notices:B(Tq)}).loose(),V({docName:I().min(1),id:I().min(1)}).loose(),V({dismissed:R()}).loose();const ibe=V({status:I().min(1),reason:I()}).loose();V({docName:I().min(1),content:I(),lifecycle:ibe.nullable()}).loose(),V({documents:B(V({kind:U([`document`,`asset`,`folder`,`file`]).default(`document`),docName:I().min(1).optional(),docExt:I().min(1).default(`.md`),size:L().int().nonnegative(),modified:I().min(1),isSymlink:R().default(!1),canonicalDocName:I().nullable().default(null),targetPath:I().nullable().default(null),path:I().min(1).optional(),assetExt:I().min(1).optional(),mediaKind:U([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`,`excalidraw`]).nullable().optional(),referencedBy:B(I().min(1)).optional(),hasChildren:R().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:R().optional()}).loose();const abe=V({source:I().min(1),anchor:I().nullable(),title:I(),snippet:I().nullable()}).loose();V({docName:I().min(1),backlinks:B(abe)}).loose(),V({counts:H(I().min(1),L().int().nonnegative())}).loose(),V({counts:H(I().min(1),L().int().nonnegative())}).loose();const obe=$i(`kind`,[V({kind:W(`doc`),docName:I().min(1),anchor:I().nullable(),title:I(),snippet:I().nullable()}).loose(),V({kind:W(`external`),url:I().min(1),title:I(),snippet:I().nullable()}).loose()]),sbe=V({role:I().min(1),sourceForm:I().min(1),targetKind:I().min(1),href:I(),resolvedTarget:I().nullable(),status:I().min(1),reason:I().nullable(),resolutionMethod:I().min(1),fallbackTarget:I().nullable().default(null),range:V({start:L().int().nonnegative(),end:L().int().nonnegative()}),line:L().int().nonnegative(),column:L().int().nonnegative(),definition:V({label:I(),line:L().int().nonnegative()}).nullable().default(null)}).loose();V({docName:I().min(1),forwardLinks:B(obe),localTargets:B(sbe).optional()}).loose();const cbe=$i(`kind`,[V({id:I().min(1),kind:W(`doc`),docName:I().min(1),anchor:I().nullable(),label:I(),cluster:I().nullable(),category:I().nullable(),tags:B(I()).nullable(),managed:R().optional()}).loose(),V({id:I().min(1),kind:W(`external`),url:I().min(1),label:I()}).loose()]),lbe=V({source:I().min(1),target:I().min(1)}).loose();V({nodes:B(cbe),links:B(lbe)}).loose(),V({docNames:B(I().min(1).max(1024)).min(1).max(64)}).loose(),V({checked:L().int().nonnegative(),found:L().int().nonnegative()}).loose();const ube=V({ts:L().int().min(0),url:I(),method:I(),ua:I().optional(),origin:I().optional(),referer:I().optional(),host:I().optional(),remote:I().optional(),secChUa:I().optional(),secChUaMobile:I().optional(),secChUaPlatform:I().optional(),secFetchSite:I().optional(),secFetchDest:I().optional(),secFetchMode:I().optional(),secFetchUser:I().optional()}).loose(),dbe=V({app:Qi([W(`cursor`),W(`codex`),W(`claude`),Ki()]),signals_fired:B(I())}).loose();V({entries:B(ube),count:L().int().min(0),detection:dbe}).loose();const Eq=V({path:I().min(1),code:U([`M`,`A`,`D`,`R`,`C`,`U`,`T`,`?`,`!`,` `]),origPath:I().min(1).optional(),syncScoped:R(),open:$i(`kind`,[V({kind:W(`doc`),docName:I().min(1)}),V({kind:W(`asset`),path:I().min(1)})]).optional()}).loose();V({branch:I().nullable(),detached:R(),upstream:I().nullable(),staged:B(Eq),notStaged:B(Eq),untracked:B(Eq),incoming:B(Eq),truncated:R(),readable:R().default(!0)}).loose();const fbe=U([`AWAITING_CHECKS`,`LOCKED`,`MERGEABLE`,`QUEUED`,`UNMERGEABLE`]),pbe=U([`BEHIND`,`BLOCKED`,`CLEAN`,`DIRTY`,`DRAFT`,`HAS_HOOKS`,`UNKNOWN`,`UNSTABLE`]),mbe=U([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]),hbe=U([`ERROR`,`EXPECTED`,`FAILURE`,`PENDING`,`SUCCESS`]),gbe=V({mergeQueue:V({position:L().int().nonnegative(),state:fbe.nullable().catch(null)}).nullable().catch(null),autoMerge:R(),mergeState:pbe.nullable().catch(null),reviewDecision:mbe.nullable().catch(null),checks:hbe.nullable().catch(null)}).loose(),_be=V({kind:U([`pull`,`issue`]),repo:I().min(1),number:L().int().positive(),title:I(),author:I().nullable(),createdAt:I(),lifecycle:U([`open`,`draft`,`merged`,`closed`,`completed`,`not-planned`]),additions:L().int().nonnegative().optional(),deletions:L().int().nonnegative().optional(),status:gbe.optional()}).loose();V({url:I()}).loose(),$i(`ok`,[V({ok:W(!0),preview:_be}).loose(),V({ok:W(!1),reason:I()}).loose()]),V({writers:B(V({id:I().min(1),name:I().optional(),email:I().optional()}).loose()).optional(),summary:nf,...tf}).loose(),V({checkpointRef:I().min(1)}).loose();const vbe=V({v:L().int().optional(),id:I().min(1),name:I().min(1),colorSeed:I().optional(),docs:B(I()),summaries:B(I()).optional()}).loose();V({entries:B(V({sha:I().min(1),timestamp:I().min(1),author:I(),authorEmail:I(),type:U([`checkpoint`,`wip`,`upstream`,`park`]),message:I(),contributors:B(vbe),checkpoint:z().nullable(),parentSha:I().nullable().optional()}).loose()),total:L().int().nonnegative().optional(),truncated:R().optional(),hasMore:R().optional()}).loose(),V({sha:I().regex(/^[0-9a-f]{40}$/i),content:I(),timestamp:I(),author:I()}).loose(),V({contentDir:I().min(1),pathSeparator:U([`/`,`\\`]),symlinkResolved:R()}).loose(),B($i(`source`,[V({docName:I().min(1),timestamp:I().min(1),size:L().int().nonnegative(),source:W(`flat`)}).loose(),V({docName:I().min(1),timestamp:I().min(1),source:W(`timeline`),sha:I().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."});const ybe=V({domain:I().min(1),title:I().optional(),description:I().optional(),siteName:I().optional(),faviconDataUri:I().optional()}).loose();V({url:I()}).loose(),$i(`ok`,[V({ok:W(!0),metadata:ybe}).loose(),V({ok:W(!1),reason:I()}).loose()]),V({orphans:B(V({docName:I().min(1),title:I()}).loose())}).loose(),V({hubs:B(V({docName:I().min(1),title:I(),count:L().int().nonnegative()}).loose())}).loose();const bbe=V({source:I().min(1),title:I(),snippet:I().nullable()}).loose();V({deadLinks:B(V({target:I().min(1),sources:B(bbe)}).loose())}).loose(),V({target:V({docName:I().min(1),title:I(),aliases:B(I())}).loose(),mentions:B(V({source:I().min(1),excerpt:I(),offset:L().int().nonnegative()}).loose()),truncated:R()}).loose(),V({projectPath:I().min(1)}).loose();const xbe=U([`not-a-git-worktree`,`init-failed`]);$i(`ok`,[V({ok:W(!0),projectPath:I().min(1)}).loose(),V({ok:W(!1),reason:xbe,message:I().min(1)}).loose()]),V({host:I().min(1).optional()}).loose(),V({host:I().min(1).optional(),token:I().min(1)}).loose(),V({host:I(),login:I()}).loose(),V({host:I().refine(kc,{message:`Host must be a hostname with an optional :port, with no scheme or path`}),username:I().min(1),token:I().min(1)}).loose(),V({host:I(),login:I()}).loose(),V({key:I().min(1)}).loose(),V({keyPresent:R()}).loose();const Sbe=U([`no_key`,`invalid_endpoint`,`rate_limit`,`timeout`,`http_error`,`network`,`dims_mismatch`,`malformed_response`]);$i(`ok`,[V({ok:W(!0),endpoint:I().min(1),model:I().min(1),dimensions:L().int().positive()}).loose(),V({ok:W(!1),endpoint:I().min(1),model:I().min(1),reason:Sbe,status:L().int().optional()}).loose()]),V({name:I().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:I().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),V({authenticated:R()}).loose(),V({channel:U([`login`,`gh-login`]).default(`login`)}).loose(),V({}).loose();const Cbe=V({stackIndex:L().int().min(0),ts:L().int().min(0),additions:L().int().min(0),deletions:L().int().min(0)}).loose(),wbe=V({docName:I().min(1),additionsTotal:L().int().min(0),deletionsTotal:L().int().min(0),lastTs:L().int().min(0),bursts:B(Cbe)}).loose(),Tbe=V({displayName:I().min(1),color:I().min(1),icon:I().optional(),connectionId:I().min(1)}).loose();V({sessionAlive:R(),agent:Tbe.nullable(),files:B(wbe)}).loose(),V({diff:I(),before:I(),after:I(),properties:dP,generatedAt:L().int().min(0)}).loose(),V({}).loose(),V({}).loose(),V({}).loose(),V({}).loose(),V({}).loose(),V({}).loose();const Ebe=V({displayName:I().min(1),icon:I(),color:I().min(1),currentDoc:I().nullable(),mode:U([`idle`,`writing`]),ts:L().int().min(0)}).loose();V({presence:H(I().min(1),Ebe)}).loose();const Dbe=V({sessionId:I().min(1),agentType:I().min(1),ts:L().int().min(0),insertedChars:L().int().min(0),deletedChars:L().int().min(0)}).loose();V({effects:B(V({"doc.name":I().min(1),entries:B(Dbe)}).loose())}).loose(),V({decisions:B(V({ts:L().int().min(0),decision:I().min(1),kind:I().min(1),"doc.name":I().min(1),pathRole:I().min(1)}).loose())}).loose(),H(I().min(1),R()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`}),V({path:I().min(1,`path must be non-empty`)}).loose(),V({}).loose();const Obe=V({fromDocName:I().min(1),toDocName:I().min(1)}).loose(),kbe=V({fromPath:I().min(1),toPath:I().min(1)}).loose();V({}).loose(),V({path:I().min(1),...tf,summary:nf}).loose(),V({docName:I().min(1)}).loose(),V({path:I().min(1),...tf,summary:nf}).loose(),V({path:I().min(1)}).loose(),V({kind:U([`file`,`folder`]),path:I().min(1),...tf,summary:nf}).loose(),V({kind:U([`file`,`folder`]),path:I().min(1),duplicatedDocNames:B(I().min(1))}).loose(),V({pages:B(V({docName:I().min(1),title:I(),docExt:I().min(1),size:L().int().nonnegative(),modified:I().min(1),icon:I().min(1).max(2048).optional()}).loose())}).loose();const Abe=V({level:L().int().min(1).max(6),text:I(),slug:I()}).loose();V({docName:I().min(1),headings:B(Abe)}).loose();const jbe=V({docName:I().min(1),rewrites:L().int().nonnegative()}).loose();V({kind:U([`file`,`folder`,`asset`]),fromPath:I().min(1),toPath:I().min(1),...tf,summary:nf}).loose(),V({renamed:B(Obe),renamedAssets:B(kbe),rewrittenDocs:B(jbe).optional(),summary:of.optional()}).loose(),V({kind:U([`file`,`folder`,`asset`]),path:I().min(1),...tf}).loose(),V({deletedDocNames:B(I().min(1))}).loose(),V({kind:U([`file`,`folder`,`asset`]),path:I().min(1),...tf,summary:nf}).loose(),V({deletedDocNames:B(I().min(1))}).loose(),V({docName:I().min(1),commitSha:I().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:nf,...tf}).loose(),V({...af,restoredFrom:I().min(1),timestamp:I().min(1),summary:of.optional(),warnings:df.optional()}).loose();const Mbe=/^#[0-9a-fA-F]{6}$/,Nbe=V(Object.fromEntries(gl.map(e=>[e,I().regex(Mbe,`must be a #rrggbb hex color`)]))),Dq=I().min(1).refine(xl,{message:`must contain a non-whitespace character`}),Oq=V({name:Dq,author:Dq.optional(),variant:U([`dark`,`light`]),palette:Nbe}).loose();V({name:I().min(1),scheme:Oq,stem:I().min(1).optional(),extension:U([`.yaml`,`.yml`]).optional()}).loose(),V({id:I().min(1),filename:I().min(1)}).loose(),V({id:I().min(1),scheme:Oq}).loose(),V({id:I().min(1),filename:I().min(1)}).loose(),$i(`existed`,[V({existed:W(!1)}).loose(),V({existed:W(!0),filename:I().min(1),scheme:Oq}).loose()]),V({themes:B($i(`ok`,[V({ok:W(!0),id:I().min(1),filename:I().min(1),scheme:Oq}),V({ok:W(!1),filename:I().min(1),id:I().min(1).optional(),code:I().min(1),conflictingFilenames:B(I().min(1)).min(2).optional()})])),truncated:R()}).loose();function Pbe(e){return e.replace(/\\/g,`/`).split(`/`).filter(e=>e!==``&&e!==`.`)}function Fbe(e){let t=Pbe(e).at(-1);return t!==void 0&&Ic.some(e=>t.toLowerCase().endsWith(e))}V({tags:B(V({name:I().min(1),count:L().int().nonnegative(),isLeaf:R()}).loose())}).loose();const Ibe=V({docName:I().min(1),title:I(),matchingTags:B(I().min(1)),snippet:I().nullable()}).loose();V({name:I().min(1),docs:B(Ibe)}).loose(),V({folder:z(),frontmatter_local:H(I(),z()).nullable(),warnings:B(I()).optional().meta({description:"Non-fatal degradations of this response, one per entry; the field each affects is absent, null, or incomplete — the aligned `warningCodes` entry names which field and how."}),warningCodes:B(U([`symlink-refused`,`malformed-yaml`,`unverifiable`,`templates-symlink-refused`,`templates-unverifiable`])).optional().meta({description:"Machine-readable codes aligned 1:1 with `warnings`; switch on these, never on the English. `symlink-refused` / `malformed-yaml` / `unverifiable`: this folder's own `.ok/frontmatter.yml` (a symlink, malformed YAML, or an lstat failure) — `frontmatter_local` is null. `templates-symlink-refused` / `templates-unverifiable`: the `.ok/templates` directory on this folder, or a `.ok` or `.ok/templates` directory on an ancestor it inherits from — a symlink (wherever it points, dangling included), or a non-ENOTDIR `lstat` failure — `folder.templates_available` omits that directory's templates and may still list others. A non-directory `.ok` / `.ok/templates` (ENOTDIR) is treated as empty and yields no `templates-*` code. This folder's own symlinked `.ok` is a 400, never a warning."})}).loose(),V({path:I(),frontmatter:so(z()).optional()}).loose(),V({applied:z()}).loose();const kq=H(I(),z()).meta({description:`Free-form frontmatter map embedded in template payloads.`});V({template:V({name:I().min(1),folder:I(),scope:U([`local`,`inherited`]),path:I().min(1),frontmatter:kq,body:I()}).strict()}).strict(),V({templates:B(V({name:I().min(1),title:I().optional(),description:I().optional(),path:I().min(1),source_folder:I()}).strict()),truncated:R()}).strict(),V({folder:I(),name:I(),body:Qd.optional(),frontmatter:kq.optional(),...tf,summary:nf}).strict(),V({...af,path:I().min(1),created:R(),warnings:B(I())}).strict(),V({sourcePath:I().min(1),targetFolder:I(),name:I().optional(),title:I().optional(),deleteSource:R().optional(),...tf,summary:nf}).strict(),V({...af,path:I().min(1),created:R(),warnings:B(I())}).strict(),V({existed:R(),path:I().min(1)}).strict(),V({fromFolder:I(),fromName:I(),toFolder:I(),toName:I(),body:Qd.optional(),frontmatter:kq.optional(),...tf,summary:nf}).strict(),V({from:I().min(1),to:I().min(1),committed:R()}).strict();const Aq=U(zd),Lbe=/^[a-z0-9-]+$/,jq=V({name:I(),description:I(),metadata:V({pack:I()}).strict().optional()}).strict();V({skill:V({name:I().min(1),scope:Aq,path:I().min(1),frontmatter:jq,body:I(),files:B(V({path:I().min(1),text:I().nullable()})).optional(),managed:R().optional()}).strict()}).strict();const Rbe=V({source:I().min(1),publisher:I().optional(),skill:I().optional(),marketplaceUrl:I().optional(),importedAt:I().min(1),autoUpdate:R().optional()}).strict(),zbe=V({name:I().min(1),description:I().optional(),scope:Aq,path:I().min(1),canonicalPath:I().min(1).optional(),filePaths:B(I()).optional(),absolutePath:I().min(1).optional(),installed:R(),hosts:B(I()),hostQualifier:I().optional().meta({description:"Set on a GLOBAL entry that shares its name with a distinct-content bundle in another host dir AND is not the by-name default: the host id whose root holds THIS bundle. Doc-name builders append it (`__skill__/global/<name>@<host>`) so each same-named bundle keeps its own tab and its own write-back path; the default bundle keeps the stable unqualified name."}),driftPaths:B(I()).optional().meta({description:`Recorded locations whose on-disk form (copy vs symlink) no longer matches what OK last wrote there — evidence another tool rewrote the path.`}),hostAliases:H(I(),I()).optional().meta({description:`Host skills roots that are symlink ALIASES of another location (host id → base-relative target root). An aliased folder is a derived view — no menu row, never a write target; the host's icon rides the target root's row.`}),conflictHosts:B(I()).optional().meta({description:`Hosts whose dir holds a DIFFERENT same-name skill (fork/conflict) — occupied, not this skill.`}),symlinkedHosts:B(I()).optional(),installableEditors:B(I()).optional(),hubOffered:R().optional().meta({description:"Whether the vendor-neutral `.agents/skills` hub is a live destination at this scope on THIS machine — server-computed via the same predicate that filters the Folders surface, so the install menu and Settings cannot disagree. True when the project already uses the hub OR a host that reads it is installed (`HUB_READER_EDITORS`)."}),linkMode:R().optional(),customPlacements:B(V({path:I(),mode:U([`copy`,`link`])}).strict()).optional(),plugin:V({name:I().min(1),marketplace:I().min(1),provider:I().min(1),url:I().optional()}).strict().optional(),managed:R().optional(),origin:Rbe.optional(),pack:I().optional(),modified:R().optional(),revertable:R().optional(),ignored:R().optional(),size:qye.optional()}).strict();V({name:I().min(1),scope:Aq,apply:R().optional()}).strict(),V({line:I().min(1),gitignorePath:I().min(1),applied:R(),alreadyTracked:R().optional()}).strict(),V({skills:B(zbe),truncated:R()}).strict(),V({scope:Aq.default(`project`),name:I().meta({description:`Managed skill name to create or update.`}),body:Qd.optional(),frontmatter:jq,...tf,summary:nf}).strict();const Mq=[`skill-name-vendor-word`,`skill-body-too-long`],Nq=B(U(Mq)).meta({description:"Machine-readable codes aligned 1:1 with `warnings` (`warnings[i]` is the display text for `warningCodes[i]`)."});V({...af,path:I().min(1),created:R(),warnings:B(I()),warningCodes:Nq}).strict(),V({scope:Aq.default(`project`),name:I(),dryRun:R().optional(),setAutoUpdate:R().optional(),...tf,summary:nf}).strict(),V({name:I().min(1),updated:R(),source:I().min(1),localBody:I().optional(),upstreamBody:I().optional(),gitTracked:R().optional(),warnings:B(I()),warningCodes:Nq}).strict(),V({scope:Aq.default(`project`),name:I(),...tf,summary:nf}).strict(),V({name:I().min(1),baselineRef:I().min(1),restoredFiles:B(I()),warnings:B(I())}).strict();const Pq=`This member also carries the one bookkeeping failure that does not undo the operation: the content change landed, but a state file this server keeps beside it refused to be rewritten because it could not be read, so the install or import records still describe the old state until an operator repairs that file. Absent when there is nothing to report; a server that predates this member omits it, so treat its absence as no warning rather than as an error.`;V({existed:R(),path:I().min(1),warnings:B(I()).optional().meta({description:`Present when this delete removed a directory a retention record ties to a recovery copy an earlier failed move kept, whose source was never verified unchanged — either because this server verified the deleted directory against the copy that record describes, or because it could not read the directory and so could not confirm either way. Each entry says which of the two it is; neither claims more than the check established. ${Pq}`})}).strict(),V({scope:Aq.default(`project`),fromName:I(),toName:I(),body:Qd.optional(),frontmatter:jq.optional(),...tf,summary:nf}).strict(),V({from:I().min(1),to:I().min(1),committed:R(),warnings:B(I()).optional().meta({description:`Present when the rename itself completed but something beside it did not. ${Pq}`})}).strict(),V({name:I(),toName:I().optional().meta({description:"Name for the skill at the destination scope; defaults to `name`. The SKILL.md `name` frontmatter is rewritten to match."}),fromScope:Aq,toScope:Aq,...tf,summary:nf}).strict(),V({scope:Aq,path:I().optional(),droppedLocations:B(I()).default([]).meta({description:"Locations the skill occupied at the source that were removed and not re-created at the destination: the `agents` hub and custom roots, which projection does not cover. Entries are install location ids, so they can be passed straight back as an install `add` list with `scope` set to the destination scope; custom roots resolve against that scope's base."}),warnings:B(I()).optional().meta({description:`Present when the move itself completed but something beside it did not. ${Pq}`})}).strict().meta({description:"Scope-move result. Rename paths deliberately do not emit authoring warnings, consistent with same-scope rename and duplicate. Content-authoring and import responses carry those warnings and their codes. The Skills Studio client parses `droppedLocations` off the wire but deliberately does not render it yet; how a human is told what was removed is an open product decision."}),V({scope:Aq,name:I(),toName:I(),...tf,summary:nf}).strict(),V({name:I().min(1)}).strict(),V({name:I(),home:I().min(1)}).strict(),V({docName:I().min(1)}).strict();const Fq=U([`reference`,`script`,`file`]);V({scope:Aq.default(`project`),name:I(),path:I().min(1),content:I(),...tf,summary:nf}).strict().superRefine((e,t)=>{Fbe(e.path)&&Zd(e.content,t,[`content`])}),V({...af,path:I().min(1),created:R(),kind:Fq,content:R()}).strict(),V({scope:Aq.default(`project`),name:I(),from:I().min(1),to:I().min(1),...tf,summary:nf}).strict(),V({from:I().min(1),to:I().min(1),fromDocName:I().optional(),toDocName:I().optional()}).strict(),V({path:I().min(1),kind:Fq,text:I()}).strict(),V({path:I().min(1),existed:R(),kind:Fq}).strict();const Iq=Qi([Kye,W(`agents`)]),Lq=I().min(1).refine(e=>!e.startsWith(`/`)&&!e.startsWith(`~`)&&!/^[A-Za-z]:/.test(e),{error:`a custom root is base-relative (e.g. ".tim/skills"), not absolute or ~-prefixed`}).refine(e=>e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),{error:`a custom root may not contain "..", "." or empty path segments`}).refine(e=>e.includes(`/`),{error:`a custom root is a path (e.g. ".tim/skills") — bare editor names are host ids`}),Rq=Qi([Iq,Lq]);V({scope:Aq.default(`project`),name:I(),targets:B(Iq).optional().meta({description:'SET-EXACT install targets (editor ids, plus "agents" for the .agents hub — in-place skills only): the COMPLETE resulting host set. Omit to use project-configured editors; pass [] to uninstall everywhere. Stateless callers should prefer `add`/`remove`.'}),add:B(Rq).optional().meta({description:`Locations to ADD the skill to (everything else untouched). Editor ids fan out a managed copy/symlink; a custom root path (".tim/skills") places the bundle there.`}),remove:B(Rq).optional().meta({description:"Locations to REMOVE the skill from (lossless only — a hand-edited fork is refused, never deleted). The source cannot be removed; move it first with `source`."}),mode:U([`copy`,`link`]).optional().meta({description:`"link": one real folder (the source); every other location becomes a symlink to it. "copy": independent real folders, refreshed from the source until hand-edited (a hand-edit forks that copy). Converts existing locations losslessly. Omit to follow the form the skill already uses.`}),source:Rq.optional().meta({description:`Move the skill's REAL folder to this location (the old source becomes a symlink to it — never a removal). Sticky across rescans.`}),linkMode:R().optional(),setSource:I().min(1).optional(),place:V({dir:I().min(1).meta({description:`Project-relative directory the bundle dir is created under (e.g. ".windsurf/skills").`}),mode:U([`copy`,`link`])}).strict().optional(),convert:V({target:Rq.meta({description:`The installed location to convert — an editor id, "agents", or a recorded custom placement path.`}),mode:U([`copy`,`link`]).meta({description:`"link": replace this location with a symlink to the source. "copy": replace it with an independent real folder.`})}).strict().optional(),unplace:V({path:I().min(1).meta({description:`The recorded placement bundle path (e.g. ".windsurf/skills/my-skill").`})}).strict().optional(),...tf,summary:nf,fork:V({editor:I().min(1),action:U([`align`,`make-source`,`rename`]),toName:I().optional()}).strict().optional()}).strict().refine(e=>e.targets===void 0||e.add===void 0&&e.remove===void 0,{error:"`targets` is set-exact; `add`/`remove` are additive — use one style per call"}).refine(e=>e.fork===void 0||e.targets===void 0&&e.add===void 0&&e.remove===void 0&&e.source===void 0&&e.setSource===void 0,{error:"`fork` is its own operation — run it in a separate call"}).refine(e=>e.fork?.action!==`rename`||e.fork.toName!==void 0,{error:"`fork.rename` requires `toName`"}).refine(e=>e.source===void 0||e.add===void 0&&e.remove===void 0,{error:"a `source` move is its own operation — run it in a separate call from `add`/`remove`"}).refine(e=>[e.targets!==void 0||e.add!==void 0||e.remove!==void 0,e.place!==void 0,e.unplace!==void 0,e.convert!==void 0,e.source!==void 0||e.setSource!==void 0,e.fork!==void 0].filter(Boolean).length<=1,{error:"one operation per call — membership (`targets`/`add`/`remove`), `place`, `unplace`, `convert`, `source`, and `fork` are mutually exclusive"});const zq=[`no-targets`,`scripts-present`,`name-conflict`,`no-description`,`skill-fork-name-unpatched`,`place-path-invalid`,`place-fork-refused`,`links-not-permitted`];V({name:I().min(1).meta({description:`Managed skill name installed or uninstalled.`}),hosts:B(I()).meta({description:`Editor ids the skill is projected into after the operation; [] is expected after uninstall.`}),scripts:R().meta({description:`True when the skill ships executable scripts, projected but never run.`}),warnings:B(I()).meta({description:`Non-fatal install/uninstall warnings from target projection.`}),warningCodes:B(U(zq)).meta({description:"Machine-readable warning codes aligned with `warnings`."}),placedAt:I().optional(),sourceMovedTo:I().optional()}).strict(),V({scope:Aq.default(`project`),name:I().meta({description:`Managed skill name to uninstall without deleting source.`})}).strict(),V({name:I().min(1).meta({description:`Managed skill name requested for uninstall.`}),uninstalled:R().meta({description:`True when an install marker existed and was removed; false for an idempotent no-op.`})}).strict(),V({targets:B(_q),configured:R(),folders:B(V({scope:Aq,host:I(),root:I(),state:U([`own`,`linked`,`linked-parent`,`absent`]),target:I().optional(),drift:W(!0).optional(),expected:I().optional()}).strict()).optional()}).strict();const Bq=V({action:W(`link`),scope:Aq,root:I().min(1).meta({description:`The folder to link (e.g. ".codex/skills").`}),target:I().min(1).meta({description:`The root it merges into (e.g. ".agents/skills"). Required.`})}),Vq=V({action:W(`unlink`),scope:Aq,root:I().min(1).meta({description:`The linked folder to materialize back.`}),exclude:B(I().min(1)).optional().meta({description:`Skill names to LEAVE OUT when materializing — the folder keeps every other skill it currently sees (as per-skill links) and stops auto-following the target root.`})}).strict(),Hq=V({action:W(`add-root`),scope:Aq,root:Lq.meta({description:`New custom skills root to declare (base-relative, e.g. ".team/skills").`})}).strict(),Bbe=$i(`action`,[Bq.extend({preview:R().optional().meta({description:`Return the merge plan only (moves, drops, removes, conflicts, strays) — nothing is written.`})}).strict(),Vq,Hq]);$i(`action`,[Bq.strict(),Vq,Hq]),V({folderAction:Bbe}).strict();const Vbe=V({moves:B(I()),drops:B(I()),removes:B(I()),replaces:B(I()),conflicts:B(I()),strays:B(I())}).strict();V({targets:B(_q),reprojected:B(V({name:I(),hosts:B(I())}).strict()),bundleHosts:B(I()),removedFrom:B(I()),folder:V({moved:B(I()),dropped:B(I()),linked:B(I())}).strict().optional(),preview:Vbe.optional()}).strict(),V({scope:Aq.default(`project`),name:I(),version:I().regex(/^[0-9a-f]{40}$/i),...tf,summary:nf}).strict(),V({name:I().min(1),version:I(),restoredFiles:B(I()),warnings:B(I())}).strict(),V({query:I().optional(),intent:U([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:U([`navigation`,`relevance`]).optional(),scopes:B(U([`page`,`folder`,`content`,`file`])).optional(),scope:I().optional(),limit:L().int().nonnegative().optional(),semantic:R().optional(),source:U([`omnibar`,`mcp`,`http`]).optional()}).loose();const Hbe=V({kind:U([`page`,`folder`,`content`,`file`]),path:I().min(1),title:I(),score:L(),signals:H(I(),z()),snippet:I().optional()}).loose(),Ube=U([`applied`,`no_match`,`warming`,`incapable`,`provider_error`,`restart_required`,`query_too_short`]),Uq=U([`warm`,`corpus`,`query`,`dimensions`,`configured_dimensions`]),Wq=V({capable:R(),applied:R(),outcome:Ube,providerErrorReason:Uq.nullable().optional().catch(null),coverage:V({embedded:L().int().nonnegative(),total:L().int().nonnegative()})}).loose();V({enabled:R(),keyPresent:R(),keyNotRequired:R(),keySource:U([`project`,`file`,`env`]).nullable(),keyHint:I().nullable(),ready:R(),capable:R(),providerError:R().optional(),providerErrorReason:Uq.nullable().optional().catch(null),embedded:L().int().nonnegative(),total:L().int().nonnegative()}).loose(),V({query:I(),intent:U([`autocomplete`,`full_text`,`omnibar`]),results:B(Hbe),elapsedMs:L().nonnegative(),semantic:Wq.optional(),truncated:R().optional(),ready:R().optional()}).loose();const Wbe=V({version:I().min(1),recordedAt:I().min(1)}).loose();V({currentVersion:I().min(1),targets:H(I(),Wbe.nullable())}).loose(),V({scope:Aq.default(`project`),source:I().min(1).meta({description:`External skill source: full skills.sh skill-page URL (https://www.skills.sh/<owner>/<repo>/<skill>, or https://www.skills.sh/site/<hostname>/<skill> for a website catalog), GitHub owner/repo[/subpath], git URL, or local/file path.`}),skill:I().min(1).optional().meta({description:`Specific skill name to import from a multi-skill source.`}),install:R().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection (the caller installs explicitly afterwards). Default true.`}),marketplace:R().optional().meta({description:"The source came from a skills.sh listing the user chose (the Explore tab), so the install is reported to skills.sh and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...tf,summary:nf}).strict(),V({scope:Aq.default(`project`),source:I().min(1).meta({description:`External skill source: full skills.sh skill-page URL, GitHub owner/repo[/subpath], git URL, or local/file path.`}),skills:B(I().min(1)).min(1).max(100).meta({description:`Skill names to import from the source.`}),install:R().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection. Default true.`}),marketplace:R().optional().meta({description:"The source came from a skills.sh listing the user chose (a marketplace plugin bundle), so the import is reported to skills.sh as one batched install event and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...tf,summary:nf}).strict(),V({results:B(V({requested:I(),status:U([`imported`,`already-imported`,`not-found`,`failed`]),name:I().optional(),collisionRenamedFrom:I().optional(),warnings:B(I()),warningCodes:Nq,error:I().optional()}).loose()),imported:L(),alreadyImported:L(),failed:L()}).loose(),V({scope:Aq.default(`project`),names:B(I().min(1)).min(1).max(100).meta({description:`Managed skill names to refresh from their recorded upstreams.`}),...tf,summary:nf}).strict(),V({results:B(V({requested:I(),status:U([`updated`,`up-to-date`,`not-found`,`failed`]),source:I().optional(),warnings:B(I()),warningCodes:Nq,error:I().optional()}).loose()),updated:L(),upToDate:L(),failed:L()}).loose();const Gbe=V({source:I(),ref:I().optional(),contentHash:I(),publisher:I().optional()}).loose();V({name:I().min(1).meta({description:`Managed skill name created or matched.`}),path:I().min(1).meta({description:`Store-relative path to the imported skill source.`}),created:R().meta({description:`True when this request created new source files.`}),alreadyImported:R().meta({description:`True when identical content was already present and no files changed.`}),collisionRenamedFrom:I().optional().meta({description:`Original source name when collision handling renamed the import.`}),provenance:Gbe,warnings:B(I()).meta({description:`Non-fatal import warnings, such as skipped unsupported files.`}),warningCodes:Nq}).loose();const Kbe=U([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`,`comments`,`lint-config`,`local-targets`]);V({v:W(1),ch:W(`server-info`),seq:L(),serverInstanceId:I().min(1),currentBranch:I().min(1).optional()}).loose(),V({v:W(1),ch:W(`branch-switched`),seq:L(),branch:I().min(1)}).loose(),V({v:W(1),ch:Kbe,seq:L()}).loose(),V({v:W(1),ch:W(`disk-ack`),seq:L(),docName:I().min(1),sv:I().min(1)}).loose(),V({v:W(1),ch:W(`config-validation-rejected`),seq:L(),docName:I().min(1),error:bae}).loose(),V({v:W(1),ch:W(`config-ignore-nested-error`),seq:L(),path:I().min(1),error:I().min(1)}).loose(),(()=>{let e=globalThis.Intl.Segmenter;return e?new e(`en`,{granularity:`word`}):null})();const qbe=Xi({name:I(),description:I(),files:Xi({skillMd:I(),scripts:B(I()),references:B(I())})}),Jbe=Xi({pluginProvider:I().optional(),plugin:I().optional(),marketplace:I().optional(),repositoryUrl:I().optional(),version:I().optional(),gitCommitSha:I().optional(),scope:I().optional(),projectPath:I().optional()}),Ybe=Xi({commands:R(),hooks:R(),mcp:R()}),Xbe=Xi({...qbe.shape,sourceHarness:I(),sourceHarnesses:B(I()),home:I(),provenance:Jbe,inert:Ybe,outsideProject:R().optional()}),Zbe=Xi({schema:W(1),name:I(),version:I(),description:I().optional(),author:Xi({name:I()}).optional(),skills:B(I()),hostCompatibility:B(I()).optional(),capabilities:Xi({scripts:I(),network:I(),inert:B(I())}).optional(),provenance:Xi({source:I(),ref:I(),contentHash:I()}).optional()});V({skills:B(Xbe),packs:B(Zbe)}).loose(),V({results:B(V({id:I().min(1),name:I().min(1),source:I().min(1),description:I(),installs:L().int().nonnegative().nullable(),publisher:I().nullable()}).loose()),backend:U([`skills.sh`,`github-fallback`]),degraded:R()}).loose(),V({title:I(),description:I(),image:I().nullable(),skillsUrl:I().nullable(),sourceKind:U([`github`,`site`]),sourceUrl:I()}).loose(),V({skills:B(V({name:I(),description:I().nullable()}).loose())}).loose(),V({kind:U([`local`,`import`,`none`]),scope:U(zd).optional(),name:I().optional(),dir:I().optional(),source:I().optional(),ref:I().optional(),via:U([`source`,`publisher`]).optional()}).loose();const Qbe=V({relPath:I(),content:I().nullable()}).loose(),$be=V({provider:I(),plugin:I(),version:I().optional(),marketplace:I().optional(),repositoryUrl:I().optional()}).loose(),exe=V({provider:I(),plugin:I(),version:I().optional(),description:I().optional(),repositoryUrl:I().optional(),bundledSkills:B(I()),capabilities:V({commands:R(),hooks:R(),mcp:R(),agents:R()}),setupSupported:R()}).loose();V({name:I(),description:I().nullable(),skillMd:I(),files:B(Qbe),plugin:$be.optional(),pluginBundle:exe.optional()}).loose();const txe=[`auth-error`,`detached-head`,`dirty-tree`,`diverged-local-commits`,`external-changes-pending`,`git-index-locked`,`git-operation-in-progress`,`no-commits-yet`,`no-push-permission`,`non-content-merge-failure`,`protected-branch`,`unsafe-incoming-symlinks`],Gq=e=>e*8+4;Gq(92),Gq(40),(()=>{let e=globalThis.Intl.Segmenter;return e?new e(void 0,{granularity:`grapheme`}):null})(),Array.from({length:256},(e,t)=>(t+256).toString(16).slice(1));const Kq={fileSystem:`File System`,gitUpstream:`Git (upstream)`,service:`OpenKnowledge (service)`,generator:`OpenKnowledge (generated)`},qq=`state/bug-reports`,nxe=Xi({at:I(),transport:I(),outcome:I(),reference:I().optional(),error:I().optional(),errorCode:I().optional()}),rxe=Xi({reason:I(),at:I(),errorCode:I().optional()});Xi({version:L().int().catch(1),id:I(),createdAt:I(),bundleLevel:I(),zipBytes:L().int().nonnegative().catch(0),zipDeleted:R().optional(),state:I(),systemWide:R().optional(),projectSlug:I().nullable().optional(),reference:I().optional(),lastError:rxe.optional(),attempts:B(nxe).optional(),note:I().optional()}),Xi({version:L().int().catch(1),id:I().optional(),sentAt:I().optional(),reference:I().optional()});const ixe=new Map([[`PORT`,[`server`,`port`]],[`OK_BIND`,[`server`,`bind`]],[`OK_EXTERNAL_URL`,[`server`,`externalUrl`]],[`OK_ALLOW_EXTERNAL`,[`server`,`allowExternal`]],[`OK_OPEN_BROWSER`,[`server`,`openBrowser`]],[`OK_IDLE_SHUTDOWN`,[`server`,`idleShutdown`]]]);function axe(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toUpperCase()}function oxe(e){return`OK_${(e[0]===`server`?e.slice(1):e).map(axe).join(`_`)}`}function sxe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cxe(e){let{value:t,file:n,source:r,doc:i}=e,a=[],o=(e,t)=>{if(t.length>0){let e=tu(eu,t);if(e!==void 0){if(e.scope===`project-local`){let e=oxe(t),o;i!=null&&r!=null&&n!=null&&(o=cd({file:n,source:r,doc:i,path:t})),a.push({path:[...t],...ixe.has(e)?{envVar:e}:{},...o===void 0?{}:{source:o}})}return}}if(sxe(e))for(let[n,r]of Object.entries(e))o(r,[...t,n])};return o(t,[]),a}const Jq=`(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)`;RegExp(`^127\\.${Jq}\\.${Jq}\\.${Jq}$`);function Yq(e,t){return e===`unix-chain`?`# ok-mcp${t}-v`:`# ok-mcp${t}-win-v`}function Xq(e){return e.replace(/\/+/g,`/`).replace(/\/+$/,``)}function lxe(e){return it[e].userHomeDirName}function uxe(e,t,n=`darwin`,r){return e===`stable`?n===`linux`?`${Xq(r?.startsWith(`/`)?r:`${Xq(t)}/.config`)}/OpenKnowledge/path-install.json`:`${Xq(t)}/Library/Application Support/OpenKnowledge/path-install.json`:`${Xq(t)}/${lxe(e)}/path-install.json`}const dxe=[`.ok`,xd,`installed-skills.json`],fxe=U(zd),pxe=Xi({hosts:B(I()),scope:fxe,scripts:R(),installedAt:Ti(),projection:U([`symlink`,`copy`]).optional(),contentHash:I().optional()}),mxe=Xi({schema:W(1),skills:H(I(),pxe).default({})});function hxe(e){let t;try{t=JSON.parse(e)}catch{return null}let n=mxe.safeParse(t);return n.success?n.data:null}function Zq(e){if(e===``)throw Error(`toPathspec: empty path. ":(literal)" is an empty pattern that matches every tracked path; pass "." if you meant the repo root.`);return`:(literal)${e}`}function gxe(e){if(e.length===0)throw Error(`pathspecArgs: empty path list. A bare "--" removes the pathspec restriction rather than selecting nothing.`);return[`--`,...e.map(e=>Zq(e))]}const Qq=[{tagName:`Mirror`,attrName:`src`,resolution:`bare-doc-name`},{tagName:`Excalidraw`,attrName:`src`,resolution:`doc-relative`}];for(let e of Qq){let t=PB.find(t=>t.name===e.tagName);if(!t)throw Error(`JSX_SRC_REF_TAGS: no built-in component descriptor named '${e.tagName}' — the rename-rewrite and backlink passes for this entry would silently never match. Fix the tagName to match a descriptor in builtInComponents.`);if(!t.props.some(t=>t.name===e.attrName))throw Error(`JSX_SRC_REF_TAGS: component '${e.tagName}' declares no prop named '${e.attrName}' — the rename-rewrite and backlink passes for this entry would silently never match. Fix the attrName to match one of the descriptor's props.`)}QV(),gV(),_V();function _xe(){return PB.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function vxe(){return _xe().filter(e=>{let t=yxe(e);return t!==`fence`&&t!==`html`})}function yxe(e){return e.name===`MermaidFence`?`fence`:e.name===`HtmlAlignBlock`?`html`:e.hasChildren?`jsx-block`:`jsx-void`}const $q=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),eJ=globalThis;eJ[$q]===void 0&&(eJ[$q]=lr());const tJ=eJ[$q],nJ=Xi({version:I().regex(/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(tJ,{description:`Recorded skill version for this target.`}),recordedAt:Ti().register(tJ,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:U([`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`]).register(tJ,{description:`Install-source surface that recorded this entry.`}).optional()}),bxe=Xi({enabled:R().register(tJ,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:Ti().register(tJ,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})});Xi({schema:W(1).register(tJ,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Xi({"claude-cowork":nJ.optional(),"cli-hosts":nJ.optional()}).register(tJ,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:H(I(),bxe).register(tJ,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional(),installsReported:B(I()).register(tJ,{description:"Skill installs already reported to skills.sh from this machine, as `<owner/repo>#<skill>`. Append-only; presence suppresses a re-report."}).optional()});const xxe=/<script(?![^>]*\ssrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi;function Sxe(e){return[[`script-src 'self' 'unsafe-eval' 'wasm-unsafe-eval'`,...[...e.matchAll(xxe)].map(e=>`'sha256-${Ee(`sha256`).update(e[1]??``).digest(`base64`)}'`)].join(` `),`worker-src 'self' blob:`,`object-src 'none'`,`base-uri 'self'`].join(`; `)}Sxe(``);function Cxe(e,t,n,r){return e.success?{code:`UNKNOWN`,message:`unexpected success in error path`}:{code:`SCHEMA_INVALID`,issues:e.error.issues.map(e=>{let i=e.path.map(e=>typeof e==`symbol`?String(e):e),a=cd({file:r,source:n,doc:t,path:i});return{path:i,message:e.message,issueCode:e.code,...a===void 0?{}:{source:a}}})}}function rJ(e,t,n){let r=`${e}.invalid-${t.replace(/[:.]/g,`-`)}`;try{return ee(e,r),r}catch(t){n(`[config] Could not sideline invalid config file ${e} → ${r}: ${t instanceof Error?t.message:String(t)}. File left in place; using schema defaults.`);return}}function iJ(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||Array.isArray(n))return;n=Reflect.get(n,e)}return n}function wxe(e){let t=[],n=[[`maxBatchSize`,1,Gl],[`maxBatchChars`,1,Kl],[`docTimeoutMs`,1,ql]];for(let[r,i,a]of n){let n=[`search`,`semantic`,r],o=iJ(e.rawConfig,n),s=e.config.search.semantic[r];if(o===void 0||o===s)continue;let c=`Expected an integer between ${i} and ${a}; using default ${s}.`,l=cd({file:e.absPath,source:e.source,doc:e.doc,path:n});t.push({path:n,message:c,...l===void 0?{}:{source:{file:l.file,line:l.line,column:l.column}}})}return t.length>0?[{code:`VALUE_FALLBACK`,issues:t}]:[]}function Txe(e){let t=iJ(e.rawConfig,[`git`,`hosts`]);if(t===void 0)return[];let n=jie.safeParse(t);return n.success?[]:[{code:`VALUE_FALLBACK`,issues:n.error.issues.map(t=>{let n=[`git`,`hosts`,...t.path.map(String)],r=cd({file:e.absPath,source:e.source,doc:e.doc,path:n});return{path:n,message:`${t.message}; ignoring this git-host declaration.`,...r===void 0?{}:{source:{file:r.file,line:r.line,column:r.column}}}})}]}function Exe(e){let t=iJ(e.rawConfig,[`autolinks`]);if(t===void 0)return[];let n=Mie.safeParse(t);return n.success?[]:[{code:`VALUE_FALLBACK`,issues:n.error.issues.map(t=>{let n=[`autolinks`,...t.path.map(String)],r=cd({file:e.absPath,source:e.source,doc:e.doc,path:n});return{path:n,message:t.path.length===0?`${t.message}; ignoring autolinks.`:`${t.message}; ignoring this autolink entry.`,...r===void 0?{}:{source:{file:r.file,line:r.line,column:r.column}}}})}]}function aJ(e){let{absPath:t,sideline:n=!0,timestamp:r=new Date().toISOString()}=e,i=e.warn??(e=>console.warn(e)),a=eu.parse({});if(!_(t))return{valid:!0,value:a,source:void 0,diagnostics:[]};let o;try{o=C(t,`utf-8`)}catch(e){let n=e instanceof Error?e.message:String(e);i(`[config] Could not read ${t}: ${n}. Using schema defaults.`);let r={code:`UNREADABLE`,detail:n};return{valid:!1,value:a,error:r,diagnostics:[{...r}]}}let s=(0,xs.parseDocument)(o);if(s.errors.length>0){let e=s.errors.map(e=>e.message).join(`; `);i(`[config] ${t} contains invalid YAML (${e}). Using schema defaults.`+(n?``:` Pass-through mode: file left in place.`));let o=n?rJ(t,r,i):void 0,c={code:`YAML_PARSE`,detail:e};return{valid:!1,value:a,error:c,diagnostics:[{...c}],...o===void 0?{}:{sidelinedTo:o}}}let c=s.toJSON()??{},l=pd({value:c,file:t,source:o,doc:s}),u=l.length>0?hd(c):c,d=[...Txe({rawConfig:u,doc:s,source:o,absPath:t}),...Exe({rawConfig:u,doc:s,source:o,absPath:t})];for(let e of d)for(let n of e.issues)i(`[config] ${t} ${n.path.join(`.`)}: ${n.message}`);let f=eu.safeParse(u);if(!f.success){let e=Cxe(f,s,o,t),c=eu.shape.git.safeParse(iJ(u,[`git`])).data??a.git,p=Object.keys(c.hosts).length>0?`Using schema defaults while preserving valid git-host declarations.`:`Using schema defaults.`;i(`[config] ${t} fails schema validation (${f.error.issues.length} issue(s)). ${p}`+(n?``:` Pass-through mode: file left in place.`));let m=n?rJ(t,r,i):void 0,h=[...l,...d,...Id(e)&&e.code===`SCHEMA_INVALID`?[{...e}]:[]];return{valid:!1,value:{...a,git:c},error:e,diagnostics:h,...m===void 0?{}:{sidelinedTo:m}}}let p=[...l,...d,...wxe({rawConfig:u,config:f.data,doc:s,source:o,absPath:t})];return{valid:!0,value:f.data,source:t,diagnostics:p}}function oJ(e=ve()){return j(e,pt().userHomeDirName)}const sJ=`.tmp.`,cJ=[8,4,4,4,12];function Dxe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const Oxe=cJ.map(e=>`[0-9a-f]`.repeat(e)).join(`-`),kxe=cJ.map(e=>`[0-9a-f]{${e}}`).join(`-`);`${Oxe}`,RegExp(`${Dxe(sJ)}${kxe}$`);function Axe(e){return`${e}${sJ}${De()}`}function jxe(e){try{let t=k(e),n=`${oe(e)}${sJ}`,r=Date.now()-3e4;for(let e of T(t)){if(!e.startsWith(n))continue;let i=j(t,e);try{re(i).mtimeMs<r&&ie(i)}catch{}}}catch{}}function lJ(e,t,n={}){jxe(e);let r=Axe(e);try{O(r,t,{encoding:`utf-8`,mode:n.mode??420}),ee(r,e)}catch(e){try{ie(r)}catch{}throw e}}var uJ=class extends Error{code=`LOCK_TIMEOUT`;lockPath;timeoutMs;constructor(e,t){super(`Could not acquire file lock at ${e} within ${t}ms`),this.name=`FileLockTimeoutError`,this.lockPath=e,this.timeoutMs=t}};async function Mxe(e,t,n={}){let r=n.timeoutMs??5e3,i=n.retryIntervalMs??25,a=r*2,o=Date.now()+r,s=!0;for(;;){if(!s&&Date.now()>=o)throw new uJ(e,r);s=!1;let c;try{c=x(e,`wx`,384)}catch(t){if(t.code!==`EEXIST`)throw t;let s;try{let t=re(e);s=Date.now()-t.mtimeMs}catch{continue}let c=!1;if(s>a){n.onWarn?.(`cleared stale file lock`,{lockPath:e,ageMs:s,staleThresholdMs:a});try{ie(e),c=!0}catch{}}if(c)continue;if(Date.now()>=o)throw new uJ(e,r);await pae(i);continue}try{return await t()}finally{try{f(c)}catch{}try{ie(e)}catch{}}}}function Nxe(e){let t=Date.now()+e;for(;Date.now()<t;);}function dJ(e,t,n={}){let r=n.timeoutMs??5e3,i=n.retryIntervalMs??25,a=r*2,o=Date.now()+r,s=!0;for(;;){if(!s&&Date.now()>=o)throw new uJ(e,r);s=!1;let c;try{c=x(e,`wx`,384)}catch(t){if(t.code!==`EEXIST`)throw t;let s;try{let t=re(e);s=Date.now()-t.mtimeMs}catch{continue}let c=!1;if(s>a){n.onWarn?.(`cleared stale file lock`,{lockPath:e,ageMs:s,staleThresholdMs:a});try{ie(e),c=!0}catch{}}if(c)continue;if(Date.now()>=o)throw new uJ(e,r);Nxe(i);continue}try{return t()}finally{try{f(c)}catch{}try{ie(e)}catch{}}}}const fJ=`config.yml`;function pJ(e,t,n){if(e===`user`)return le(oJ(n??ve()),`global.yml`);let r=se(t)?t:le(t);return e===`project-local`?le(r,`.ok`,xd,fJ):le(r,`.ok`,fJ)}const Pxe=[`LC_ALL`,`LC_MESSAGES`,`LANG`];function mJ(e){let t=e.trim().split(`@`)[0].split(`.`)[0];return t===``||t===`C`||t===`POSIX`?null:pP(t.replaceAll(`_`,`-`))}function Fxe(e){for(let t of Pxe){let n=e[t]?.trim();if(n!==void 0&&n!==``)return mJ(n)}return null}function Ixe(e){let t=e.OK_LANG?.trim();if(t!==void 0&&t!==``)return pP(t)??void 0}function Lxe(e=process.env){let t=Ixe(e),n=Fxe(e);if(n===null)return{override:t,preferenceList:[]};let r=[],i=e.LANGUAGE;if(i!==void 0)for(let e of i.split(`:`)){let t=mJ(e);t!==null&&r.push(t)}return{override:t,preferenceList:[...r,n]}}function Rxe(e){return Ee(`sha256`).update(e).digest(`hex`)}function zxe(e,t){return j(hJ(e,t),gd)}function hJ(e,t){let n=le(e);try{n=D.native(n)}catch{}let r=Rxe(n);return j(oJ(t),`logs`,`projects`,r)}function gJ(){return Ed(Cd)}function _J(){return pt().keyringService}function vJ(e){try{e()}catch{}}var Bxe=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(_J(),e).getPassword()}catch(t){return vJ(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return vJ(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return vJ(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(_J(),e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(_J(),e).deletePassword()}catch{}}},yJ=class{backend=`file`;authFile;constructor(e){this.authFile=e??j(oJ(),`auth.yml`)}read(){if(!_(this.authFile))return{};try{let e=C(this.authFile,`utf-8`);return(0,xs.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=k(this.authFile);_(t)||y(t,{recursive:!0,mode:448}),lJ(this.authFile,(0,xs.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},Vxe=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ${gJ()} to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function bJ(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(_J(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
@@ -1550,6 +1550,6 @@ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){funct
1550
1550
  `);O(e,o)}function A9(e,t){let n=C(e,`utf-8`);if(n.trim().length!==0)try{let r=O9(JSON.parse(n),t),i=n.endsWith(`
1551
1551
  `)?`
1552
1552
  `:``;O(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=D9(n,t.contentDirSpellings);r!==n&&O(e,r)}}function j9(e,t){let n=C(e,`utf-8`),r=D9(n,t.contentDirSpellings);r!==n&&O(e,r)}function M9(e){try{return T(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>j(e,t.name))}catch{return[]}}const WIe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function N9(e){return/\.log\.\d+$/.test(e)}function GIe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||N9(e)}const KIe=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function P9(e){let t={contentDirSpellings:E9(e.contentDir)};for(let n of KIe)for(let r of M9(j(e.stagingDir,n)))GIe(r)?k9(r,t):r.endsWith(`.json`)?A9(r,t):j9(r,t);for(let n of M9(j(e.stagingDir,`state`))){let e=oe(n);n.endsWith(`.jsonl`)?k9(n,t):WIe.has(e)?A9(n,t):j9(n,t)}}const F9=[`.ok`,`local`,`telemetry`],I9=[`.ok`,`local`,`logs`],L9=[`.ok`,`local`,`loss-capture`],R9=_d.spansCurrent,z9=_d.spansPrevious,B9=_d.logsCurrent,V9=_d.logsPrevious,H9=`loss-current.jsonl`,U9=`loss-prev.jsonl`;function qIe(e){return j(e,...L9,H9)}function JIe(e){return j(e,...L9,U9)}const W9=1e3;async function YIe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function XIe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function ZIe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}function QIe(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
1553
- `)}\n`:null}catch{return null}}function $Ie(e){let t=j(e,`.git`,`ok`);if(!_(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],P6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function eLe(e){let t=j(e,`.git`,`ok`);if(!_(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],P6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function G9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function tLe(){return{nodeVersion:process.version,platform:be(),arch:he()}}function nLe(){return process.env.OTEL_SDK_DISABLED===`false`}function K9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q9(e){if(!_(e))return{};let t;try{t=(0,xs.parse)(C(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!K9(t))return{};let n=t.telemetry;if(!K9(n))return{};let r=n.localSink;return K9(r)?r:{}}function J9(e){return typeof e==`boolean`?e:void 0}function rLe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y9(e){if(K9(e))return rLe(e.maxBytes)}function iLe(e){let t=q9(pJ(`project`,e)),n=q9(pJ(`project-local`,e));return{enabled:J9(n.enabled)??J9(t.enabled)??!0,spansMaxBytes:Y9(n.spans)??Y9(t.spans)??52428800,logsMaxBytes:Y9(n.logs)??Y9(t.logs)??26214400}}function aLe(e){return Ee(`sha256`).update(e).digest(`hex`)}function oLe(e){let t=C(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const sLe=[`"doc.name"`,`"docName"`];function cLe(e){let t=C(e,`utf-8`),n=0;for(let e of sLe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function X9(e,t){if(!_(e))return!1;try{return y(k(t),{recursive:!0}),e.endsWith(`.ips`)?O(t,K5(C(e,`utf-8`))):h(e,t),!0}catch{return!1}}function Z9(e,t,n,r){let i=_(e);X9(e,j(n,r)),X9(t,i?j(n,`legacy`,r):j(n,r))}function Q9(e){let t=[],n=e=>{let r=T(e,{withFileTypes:!0});for(let i of r){let r=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const lLe=new Set([`.jsonl`]);function uLe(e){let t=e.lastIndexOf(`.`);return t!==-1&&lLe.has(e.slice(t))}const dLe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function fLe(e){if(N9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&dLe.has(e.slice(t))}function pLe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!fLe(r))continue;let{redacted:i,patterns:a,lineCount:o}=SP(C(n,`utf-8`));a.length!==0&&(O(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return N(e,t).split(ue).join(`/`)}async function mLe(e){let t=le(e.contentDir),n=le(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??YIe,a=r.fetchAgentEffects??XIe,o=r.fetchWatcherRecent??ZIe,s=r.readShadowHead??$Ie,c=r.readCheckpointRefs??eLe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.88.6-beta.1`),d=r.readDesktopEnv??G9,f=r.readLanguage??T9,p=r.readRuntime??tLe,m=r.isOtlpPushEnabled??nLe,g=b(j(Se(),`ok-bundle-`));try{y(j(g,`telemetry`),{recursive:!0}),y(j(g,`logs`),{recursive:!0}),y(j(g,`state`),{recursive:!0}),Z9(xCe(n),j(n,...F9,R9),g,j(`telemetry`,R9)),Z9(SCe(n),j(n,...F9,z9),g,j(`telemetry`,z9)),Z9(vX(n),j(n,...I9,B9),g,j(`logs`,B9)),Z9(yX(n),j(n,...I9,V9),g,j(`logs`,V9));for(let t of e.userLogFiles??[])X9(t,j(g,`logs`,oe(t)));for(let t of e.userStateFiles??[])X9(t,j(g,qq,oe(t)));let v=0;for(let t of e.diagnosticReports?.files??[])X9(t,j(g,`diagnostic-reports`,oe(t)))&&(v+=1);let b=j(n,`.ok`,`local`),x=j(b,`server.lock`),S=`not-running`,w=`no server.lock`,T=null;if(_(x)){X9(x,j(g,`state`,`server.lock`));try{let e=C(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(O(j(g,`state`,`agent-presence.json`),e),S=`running`,w=``);let t=await a(T);t!==null&&O(j(g,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=QIe(n);e!==null&&O(j(g,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&O(j(g,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&O(j(g,`state`,`checkpoint-refs.txt`),D),X9(qIe(n),j(g,`state`,H9)),X9(JIe(n),j(g,`state`,U9)),Z9(zxe(n),j(b,gd),g,`state/last-spawn-error.log`),X9(j(b,yd),j(g,`state`,yd)),X9(j(b,bd),j(g,`state`,bd)),X9(j(b,vd),j(g,`state`,vd));let ee=p(),ne=d(),ie=f(),ae={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};O(j(g,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let k=S===`running`?`running
1553
+ `)}\n`:null}catch{return null}}function $Ie(e){let t=j(e,`.git`,`ok`);if(!_(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],P6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function eLe(e){let t=j(e,`.git`,`ok`);if(!_(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],P6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function G9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function tLe(){return{nodeVersion:process.version,platform:be(),arch:he()}}function nLe(){return process.env.OTEL_SDK_DISABLED===`false`}function K9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q9(e){if(!_(e))return{};let t;try{t=(0,xs.parse)(C(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!K9(t))return{};let n=t.telemetry;if(!K9(n))return{};let r=n.localSink;return K9(r)?r:{}}function J9(e){return typeof e==`boolean`?e:void 0}function rLe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y9(e){if(K9(e))return rLe(e.maxBytes)}function iLe(e){let t=q9(pJ(`project`,e)),n=q9(pJ(`project-local`,e));return{enabled:J9(n.enabled)??J9(t.enabled)??!0,spansMaxBytes:Y9(n.spans)??Y9(t.spans)??52428800,logsMaxBytes:Y9(n.logs)??Y9(t.logs)??26214400}}function aLe(e){return Ee(`sha256`).update(e).digest(`hex`)}function oLe(e){let t=C(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const sLe=[`"doc.name"`,`"docName"`];function cLe(e){let t=C(e,`utf-8`),n=0;for(let e of sLe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function X9(e,t){if(!_(e))return!1;try{return y(k(t),{recursive:!0}),e.endsWith(`.ips`)?O(t,K5(C(e,`utf-8`))):h(e,t),!0}catch{return!1}}function Z9(e,t,n,r){let i=_(e);X9(e,j(n,r)),X9(t,i?j(n,`legacy`,r):j(n,r))}function Q9(e){let t=[],n=e=>{let r=T(e,{withFileTypes:!0});for(let i of r){let r=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const lLe=new Set([`.jsonl`]);function uLe(e){let t=e.lastIndexOf(`.`);return t!==-1&&lLe.has(e.slice(t))}const dLe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function fLe(e){if(N9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&dLe.has(e.slice(t))}function pLe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!fLe(r))continue;let{redacted:i,patterns:a,lineCount:o}=SP(C(n,`utf-8`));a.length!==0&&(O(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return N(e,t).split(ue).join(`/`)}async function mLe(e){let t=le(e.contentDir),n=le(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??YIe,a=r.fetchAgentEffects??XIe,o=r.fetchWatcherRecent??ZIe,s=r.readShadowHead??$Ie,c=r.readCheckpointRefs??eLe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.88.6-beta.2`),d=r.readDesktopEnv??G9,f=r.readLanguage??T9,p=r.readRuntime??tLe,m=r.isOtlpPushEnabled??nLe,g=b(j(Se(),`ok-bundle-`));try{y(j(g,`telemetry`),{recursive:!0}),y(j(g,`logs`),{recursive:!0}),y(j(g,`state`),{recursive:!0}),Z9(xCe(n),j(n,...F9,R9),g,j(`telemetry`,R9)),Z9(SCe(n),j(n,...F9,z9),g,j(`telemetry`,z9)),Z9(vX(n),j(n,...I9,B9),g,j(`logs`,B9)),Z9(yX(n),j(n,...I9,V9),g,j(`logs`,V9));for(let t of e.userLogFiles??[])X9(t,j(g,`logs`,oe(t)));for(let t of e.userStateFiles??[])X9(t,j(g,qq,oe(t)));let v=0;for(let t of e.diagnosticReports?.files??[])X9(t,j(g,`diagnostic-reports`,oe(t)))&&(v+=1);let b=j(n,`.ok`,`local`),x=j(b,`server.lock`),S=`not-running`,w=`no server.lock`,T=null;if(_(x)){X9(x,j(g,`state`,`server.lock`));try{let e=C(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(O(j(g,`state`,`agent-presence.json`),e),S=`running`,w=``);let t=await a(T);t!==null&&O(j(g,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=QIe(n);e!==null&&O(j(g,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&O(j(g,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&O(j(g,`state`,`checkpoint-refs.txt`),D),X9(qIe(n),j(g,`state`,H9)),X9(JIe(n),j(g,`state`,U9)),Z9(zxe(n),j(b,gd),g,`state/last-spawn-error.log`),X9(j(b,yd),j(g,`state`,yd)),X9(j(b,bd),j(g,`state`,bd)),X9(j(b,vd),j(g,`state`,vd));let ee=p(),ne=d(),ie=f(),ae={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};O(j(g,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let k=S===`running`?`running
1554
1554
  `:`not-running (${w})\n`;O(j(g,`state`,`server-status.txt`),k);let A=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:G5(e.diagnosticReports,v);if(O(j(g,`state`,`diagnostic-reports-status.txt`),`${A}\n`),O(j(g,Y5),g7(e.osTerminationEvidence)),e.processDir&&_(e.processDir)){let t=j(g,`process`);y(t,{recursive:!0}),h(e.processDir,t,{recursive:!0})}let se=e.redact===!0;se&&(P9({stagingDir:g,contentDir:t}),P9({stagingDir:j(g,`legacy`),contentDir:t})),e.note&&O(j(g,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=pLe(g));for(let t of e.extraFiles??[]){let e=t.zipName??oe(t.sourcePath);if(!X9(t.sourcePath,j(g,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=v7(t,`extra/${e}`);n!==null&&(ce??={redactions:[],redactedLineCount:0},ce.redactions.push(n),ce.redactedLineCount+=n.lineCount)}let M=iLe(n),N=Q9(g),le=[],ue=0,de=0;for(let e of N){let t=$9(g,e),n=re(e).size,r=uLe(t)?oLe(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n;let i=t.startsWith(`legacy/`)?t.slice(7):t;(i.startsWith(`telemetry/`)||i.startsWith(`logs/`))&&(de+=cLe(e))}let fe={applied:se};ce!==null&&(fe.secretScrub=ce);let P={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie},contentDir:{pathSha256:aLe(t),absolutePath:se?`<CONTENT_DIR>`:t},telemetry:{localSink:{...M,directory:Ed(`logs`,`projects`)},otlpPushEnabled:m()},redaction:fe,serverStatus:S,files:le};O(j(g,`manifest.json`),`${JSON.stringify(P,null,2)}\n`);let pe=E9(t),me=N.some(e=>{try{let t=C(e,`utf-8`);return pe.some(e=>t.includes(e))}catch{return!1}}),he={stagedDiagnosticReports:v,totalBytes:ue,fileCount:le.length,docNameCount:de,contentDirVisible:me,redacted:se},ge=!1;return{stagingDir:g,manifest:P,summary:he,cleanup:()=>{ge||(ge=!0,te(g,{recursive:!0,force:!0}))}}}catch(e){throw te(g,{recursive:!0,force:!0}),e}}async function hLe(e){let{collected:t,outputPath:n}=e,r=k(n);if(!_(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new yEe.ZipFile,a=Q9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=g(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function gLe(e,t){let n=j(e,`.ok`,`config.yml`);if(_(n))try{let t=(0,xs.parse)(C(n,`utf-8`)),r=PJ(t)?t.content:void 0,i=PJ(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return le(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return le(e)}async function _Le(e,t,n,r,i,a){let o=y7(t,e.logger),s=await mLe({contentDir:gLe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...bFe(o,e.userLogsDir??j(oJ(),`logs`)),...x7(e.cachesDir??j(ve(),`Library`,`Caches`))],userStateFiles:S7(e.bugReportsDir??_7()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{y(k(e.outputPath),{recursive:!0}),await hLe({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function vLe(e){let{projectDir:t}=e,n=e.readDesktopEnv??G9,r=e.readLanguage??T9,i=()=>KPe(e.diagnosticReportsDir??j(ve(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return _Le(e,t,n,r,i(),await h7(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await TFe({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:x7(e.cachesDir??j(ve(),`Library`,`Caches`)),bugReportLedgerFiles:S7(e.bugReportsDir??_7()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await h7(e.osTerminationEvidenceDeps):void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}export{UJ as ALL_EDITOR_IDS,WJ as EDITOR_LABELS,wY as EDITOR_TARGETS,gSe as HOSTS_WITH_USER_SKILL_DIR,I5 as LAUNCH_CONFIG_NAME,EIe as PATH_SHIM_BEGIN,OIe as PATH_SHIM_BLOCK_RE,DIe as PATH_SHIM_END,a5 as ProjectPathSafetyError,fPe as addOkPathsToGitExclude,o5 as assertProjectPathSafe,aY as buildManagedServerEntry,cIe as buildMcpConfigDeclineEvent,lIe as buildMcpConfigMigrateEvent,hY as canonicalEntryFor,H5 as classifyExistingMcpEntry,vLe as collectReportBundle,NIe as createCliProbeResolver,bJ as createTokenStore,_Fe as defaultBugReportZipPath,qe as detectGh,Xe as detectGhAccounts,RPe as detectInstalledEditors,mY as droppedManagedKeys,LSe as editorConfigPathDisplay,ISe as editorEntryLocator,ZFe as ensurePiBridge,QPe as findJetsamKillSync,y5 as formatTrackedRemediation,hPe as getExcludedOkPaths,_5 as getInstalledSkillProjectionPaths,hSe as getNativeTomlMcpEditor,g5 as getOkArtifactPaths,rY as isEntryUpToDate,oY as isOwnManagedEntry,CIe as loadConfig,Uxe as makeLazyProbeTokenStore,_7 as okBugReportsDir,_9 as parseGitHubBlobUrl,wIe as parseGitHubShareUrl,v9 as parseGitHubTreeUrl,g9 as parseGitUrl,kIe as pathInstallMarkerPath,ZNe as previewContent,zPe as probeOwnManagedEditorMcpEntry,YFe as probePiBridgeState,v5 as probeTrackedOkPaths,B5 as readExistingMcpEntry,mPe as readSharingMode,SP as redactContent,kFe as registerWindowsProcessStartReader,pPe as removeOkPathsFromGitExclude,iIe as removeOwnMcpEntry,cPe as removeProjectSkill,FIe as removeUserGlobalSkillBundle,VIe as removeUserSkill,nPe as resolveProjectRoot,_Ie as runStop,u9 as truncatePriorEntry,C9 as userGlobalSkillBundleTargets,BIe as userSkillPresentAnywhere,TIe as validateLocalFolderForShare,z5 as writeEditorMcpConfig,RIe as writeProjectAiIntegrations,d5 as writeProjectSkill,LPe as writeUserMcpConfigs,zIe as writeUserSkill};
1555
1555
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ import"./dist-CWmsgB4D.mjs";import{v as e}from"./init-DEZvHVW0.mjs";export{e as runInit};
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$f as r,Af as i,Gf as a,Hf as o,Id as s,K as c,Kf as l,Lf as u,Nf as d,Pf as f,Qf as p,Rf as m,Uf as h,V as g,Xa as _,Ya as v,Zf as y,_ as b,a as x,al as S,ap as C,ep as w,jf as ee,kc as te,kf as ne,op as re,qf as ie,tt as ae,vd as oe,z as se,zd as ce}from"./md-manager-BGnqyqi1-1WhsA8vv.mjs";import{Aa as le,B as ue,Br as de,F as fe,Hs as pe,Kr as me,Ms as T,Nt as he,Pa as ge,Qo as _e,Qr as ve,R as ye,W as be,Xo as xe,_i as Se,at as Ce,ct as we,ds as Te,ea as Ee,ei as De,fs as Oe,hn as ke,ka as Ae,lr as je,ls as Me,m as Ne,mi as Pe,nr as Fe,ps as Ie,qa as Le,qo as Re,us as E,xs as ze,z as Be}from"./dist-2lLb6-A6.mjs";import{i as Ve,n as D,o as O,r as He,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Ue}from"./constants-CIdryYLD.mjs";import{t as We}from"./preview-XbQaCJ3P.mjs";import{createRequire as Ge}from"node:module";import{execFileSync as Ke}from"node:child_process";import qe,{basename as Je,dirname as M,isAbsolute as Ye,join as N,posix as Xe,relative as P,resolve as F,sep as I,win32 as Ze}from"node:path";import L from"node:process";import{fileURLToPath as Qe}from"node:url";import{copyFileSync as $e,existsSync as R,lstatSync as et,mkdirSync as tt,readFileSync as z,readdirSync as nt,readlinkSync as rt,realpathSync as it,rmSync as at,statSync as ot,writeFileSync as st}from"node:fs";import{homedir as B}from"node:os";import{inspect as ct,stripVTControlCharacters as lt,styleText as V}from"node:util";import*as ut from"node:readline";import{AsyncLocalStorage as dt,AsyncResource as ft}from"node:async_hooks";var pt=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),mt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ht=n((e=>{let{humanReadableArgName:t}=mt();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
1
+ import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$f as r,Af as i,Gf as a,Hf as o,Id as s,K as c,Kf as l,Lf as u,Nf as d,Pf as f,Qf as p,Rf as m,Uf as h,V as g,Xa as _,Ya as v,Zf as y,_ as b,a as x,al as S,ap as C,ep as w,jf as ee,kc as te,kf as ne,op as re,qf as ie,tt as ae,vd as oe,z as se,zd as ce}from"./md-manager-BGnqyqi1-COpgRhOl.mjs";import{Aa as le,B as ue,Br as de,F as fe,Hs as pe,Kr as me,Ms as T,Nt as he,Pa as ge,Qo as _e,Qr as ve,R as ye,W as be,Xo as xe,_i as Se,at as Ce,ct as we,ds as Te,ea as Ee,ei as De,fs as Oe,hn as ke,ka as Ae,lr as je,ls as Me,m as Ne,mi as Pe,nr as Fe,ps as Ie,qa as Le,qo as Re,us as E,xs as ze,z as Be}from"./dist-CWmsgB4D.mjs";import{i as Ve,n as D,o as O,r as He,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Ue}from"./constants-t9AfZY26.mjs";import{t as We}from"./preview-BGT8FQ6l.mjs";import{createRequire as Ge}from"node:module";import{execFileSync as Ke}from"node:child_process";import qe,{basename as Je,dirname as M,isAbsolute as Ye,join as N,posix as Xe,relative as P,resolve as F,sep as I,win32 as Ze}from"node:path";import L from"node:process";import{fileURLToPath as Qe}from"node:url";import{copyFileSync as $e,existsSync as R,lstatSync as et,mkdirSync as tt,readFileSync as z,readdirSync as nt,readlinkSync as rt,realpathSync as it,rmSync as at,statSync as ot,writeFileSync as st}from"node:fs";import{homedir as B}from"node:os";import{inspect as ct,stripVTControlCharacters as lt,styleText as V}from"node:util";import*as ut from"node:readline";import{AsyncLocalStorage as dt,AsyncResource as ft}from"node:async_hooks";var pt=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),mt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ht=n((e=>{let{humanReadableArgName:t}=mt();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
2
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
3
3
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
4
4
  `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),gt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -689,5 +689,5 @@ export default function okBridge(pi: {
689
689
  `));let g=`${s?``:``}${m}`;return g!==o&&T(e,g,{mode:Ka(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const zo=e=>e!==`project`,Bo=e=>e!==`user`;async function Vo(){let e=await to({message:`Where should the MCP server be configured?
690
690
  `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Ho(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Vo)():`both`}async function Uo(e){return oo({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:`OK config stays on this machine only; teammates do not see it. Safe escape hatch via \`${y()} config-sharing share\`.`}]})}async function Wo(e){if(e.sharing!==void 0)return e.sharing;let t=ma(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Uo)(t):t}var Go=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}},Ko=class extends Error{constructor(e){super(`A dev MCP entry is written to project config only, never to user-level editor config, so --scope ${e} is not supported with --dev-mcp or OK_CHANNEL=dev. Re-run with --scope project or without --scope.`),this.name=`DevMcpScopeError`}};const qo=`A dev build registers OpenKnowledge MCP in project config only, never in user-level editor config. Run \`${a} init --dev-mcp\` in the project, or set OK_CHANNEL=stable.`;function Jo(e){if(e===void 0||e===!0)return new Set(Ce);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(he.filter(e=>t.includes(e)))}function Yo(e,t,n){let r=F(n,e),i;try{i=ot(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Go(`--content-dir path does not exist: ${r}`):new Go(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Go(`--content-dir must be a directory: ${r}`);let a=Xo(t),o=Xo(r),s=P(a,o);if(s.startsWith(`..`)||Ye(s))throw new Go(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Xo(e){try{return it(e)}catch{return e}}const Zo=`open-knowledge-ui`;function Qo(e,t,n){try{let r=e.detectPath?.(t,n)??M(e.configPath(t,n));return R(r)}catch{return!1}}function $o(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+I)}catch{return!1}}function es(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!R(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||$o(e,t,r);if(!i&&c&&!Qo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{Aa(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return ns(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||tt(M(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{pe(`${o}.lock`,()=>{let t=yo(o).writePath;if(s||tt(M(t),{recursive:!0}),e.format===`toml`){let r=Fo(oi(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=Ro(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=Po(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const ts={pi:uo};function ns(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=ts[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{tt(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{pe(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Ka(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function rs(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function is(e){let t=sa(e.editors).filter(e=>e.scope===`global`);if(C())return t.map(t=>({editorId:t.id,label:t.label,action:`failed`,configPath:t.configPath(``,e.home),serverName:t.serverName(``),error:qo}));let n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>es(t,``,n,e.home))}function as(e,t,n,r){let i=ss(e,t,n,r);return i.kind===`present`?i.entry:null}function os(e,t,n,r){let i=No(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function ss(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};try{if(ot(i).size>Do)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ha(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ha(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:lo(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=oi().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return os(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,qr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:os(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=So(a);return s?Co(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:os(E(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function cs(e={}){let t=F(e.cwd??process.cwd()),n=e.projectRootMode===`cwd`?{projectRoot:t,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:mo(t,{homeDir:e.home}),r=n.projectRoot;if(De(r,e.home??B()))throw new be(r);if(ve(r))throw new fe(r);let i=!R(N(r,`.ok`)),a=n.gitRootPromoted?P(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:Yo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${k(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`${y()} init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},c=e.devMcp===!0||C();if(c&&e.mcp!==!1&&e.scope&&e.scope!==`project`)throw new Ko(e.scope);let l=await je(r),u;try{u=de(r,{contentDir:o})}catch(t){let i=$.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let d=u.created.includes(Ue),f=!1;if(l.didInit)try{f=_e(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{Ae(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let p=await Ho({scope:c?`project`:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??ms(r,e.home),h=e.editors??m,g=sa(m),v=sa(h),b=e.mcp===!1||p===null,x=Array.from(new Map([...g,...b?[]:v].map(e=>[e.id,e])).values()),S=g.filter(t=>Qo(t,r,e.home)),w=[],ee=[],te=new Set;for(let t of x){if(b){let n=``;try{n=t.configPath(r,e.home)}catch{}w.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(zo(p)&&g.includes(t)&&t.scope===`global`&&w.push(es(t,r,s,e.home)),Bo(p)&&v.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=es(t,r,s,e.home,n);w.push(i),(i.action===`written`||i.action===`overwritten`)&&te.add(n)}}let ne=new Set;for(let t of v){let n=t.projectSkillPath?.(r);!n||ne.has(n)||(ne.add(n),ee.push(Ba(t,r,{home:e.home})))}let re=za(r,v.map(e=>e.id));re&&ee.push(re);let ie=ee.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(ie.length>0){let t=e.home??B();le({source:_,skills:[Ne.project],agents:ie,scope:r},{home:t,enabled:Le(t).enabled})}let ae=!b&&p!==null&&Bo(p)?v.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,oe=b?[]:S.map(e=>rs(e,r)).filter(e=>e!==void 0).filter(e=>!te.has(e.path)),se=e.installUserSkill??me,ce=e.home??B(),ue=Jo(e.skills),pe=typeof e.skills!=`string`,T=!1,ge=!1,ye=!1,Ce=!1,we=!1,Te=!1,Oe=!1,ke=[];for(let t of he){if(!ue.has(t))continue;if(T=!0,pe){let e=await Ee(ce,Ne[t]).then(e=>({ok:!0,value:e}),()=>({ok:!1}));if(!e.ok){ke.push({bundleId:t,result:`decision-read-failed`}),Oe=!0;continue}if(e.value===!1){ke.push({bundleId:t,result:`opted-out`}),Te=!0;continue}}await xe(ce,Ne[t],!0).catch(()=>{});let n=await se({home:e.home,bundleId:t,force:!0});ke.push({bundleId:t,result:n}),n===`installed`?ge=!0:n===`failed`?ye=!0:n===`no-hosts`?we=!0:Ce=!0}let Me=ye?`failed`:Oe?`decision-read-failed`:ge?`installed`:T&&Ce?`skip-current`:T&&we?`no-hosts`:Te?`opted-out`:`declined`,Pe=ge?Fe(ce).map(e=>e.editorId):[],Ie=Le(ce).enabled&&!Se(),Re=b?`skipped-flag`:`skipped-missing`,E=w.find(e=>e.editorId===`claude`)??w[0]??{action:Re,configPath:$.claude.configPath(r,e.home)},ze=await ls({projectRoot:r,desiredMode:await Wo({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:w,projectSkills:ee,legacyProjectConfigs:oe,skillInstall:Me,skillBundles:ke,skillsRequested:e.skills,skillHosts:Pe,skillInstallsCounted:Ie,didGitInit:l.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:ae,sharing:ze}}async function ls(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=ma(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=ua(t);if(n===`local-only`){let e=fa(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:us(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=pa(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:us(t,o,`remove`)}function us(e,t,n){let r=ma(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function ds(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function fs(e,t){let n=[],i=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),a=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),s=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let c=N(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(A(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(A(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(A(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(o)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)n.push(A(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(A(`MCP server configuration:`));for(let i of e.editors){let e=i.configPath.startsWith(t)?P(t,i.configPath):i.configPath.replace(/^\/Users\/[^/]+/,`~`),a=i.serverName===r()?``:` (${i.serverName})`,o=i.configScope===`project`?` (project)`:``,s=`${i.label}${o}`,c=` `.repeat(Math.max(1,20-s.length)),l=i.editorId===`claude-desktop`&&(i.action===`written`||i.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(i.action){case`written`:n.push(` ${s}${c}${e} ${O(`registered`)}${a}${l}`);break;case`overwritten`:n.push(` ${s}${c}${e} ${O(`updated`)}${a}${l}`);break;case`skipped-missing`:n.push(` ${s}${c}${e} config root missing; skipped`);break;case`failed`:n.push(` ${s}${c}${e} ${He(`FAILED`)}: ${i.error}`);break;case`declined`:n.push(` ${s}${c}${e} left unchanged (${ds(i.declineReason)})`);break;case`skipped-flag`:break;default:i.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}let i=l.dev.mcpServerName;e.editors.some(e=>e.serverName===i&&(e.action===`written`||e.action===`overwritten`))&&n.push(` The ${i} entry runs this checkout on this machine only; keep it out of commits.`)}if(e.projectSkills.length>0){n.push(``),n.push(A(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?P(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${He(`FAILED`)}: ${r.error}`)}}}if(a&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${P(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall===`declined`)n.push(``),n.push(A(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${D(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${he.join(`, `)})`)}`),n.push(` ${D(`No user-global skill was installed or removed.`)}`)):(n.push(` ${D(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${D(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ${y()} init`)}`),n.push(` ${D(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(A(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>Ne[e.bundleId].length));for(let i of t){let t=Ne[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${O(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${O(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`${t} install failed`)}`);break;case`opted-out`:n.push(` ${t} ${D(`not installed — turned off on this machine; reinstall with ${y()} init --skills ${i.bundleId} or Settings → Skills Studio`)}`);break;case`decision-read-failed`:n.push(` ${k(`${t} not installed — could not read whether it is turned off on this machine; rerun ${y()} init once ${S(b)} is readable`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${k(`Retry with: ${y()} repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(k(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(k(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`${y()} init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(` To scope to just that sub-folder, re-run \`${y()} init --content-dir .\` from there, or set`),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(We(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(..._s(e.sharing,t));let u=e=>[`${e}- ${Ve(`${y()} seed --list-packs`)} — browse the starter packs`,`${e}- ${Ve(`${y()} seed`)} — scaffold an empty repo`];if(i){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${Ve(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `))),n.push(` ${i}. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${A(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `)));return n.join(`
691
691
  `)}function ps(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function ms(e,t){let n=[];for(let r of ci)r!==`claude-desktop`&&Qo($[r],e,t)&&n.push(r);return n}function hs(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:ct(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function gs(){return new Et(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry (node + packages/cli/dist/cli.mjs, debug logging) in project config only, as the dev channel unless OK_CHANNEL is set`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new Ot(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new Ot(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new Ot(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd();e.devMcp&&w(process.env);let n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?hs():null;try{let r;try{r=await cs({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Go||e instanceof Ko||e instanceof be||e instanceof fe){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof ye||e instanceof Be||e instanceof ue){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof we){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
692
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-DPw8HKwV.mjs`),{resolveContentDir:s}=await import(`./dist-BDrQsVYX.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-B-4pTdig.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ps(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${fs(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function _s(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
692
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-BVV3rwB9.mjs`),{resolveContentDir:s}=await import(`./dist-BO5LOWYA.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-785_n4-9.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ps(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${fs(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function _s(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
693
693
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${Ve(`${y()} config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(k(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${Ve(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${Ve(`${y()} config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(k(`Sharing mode unavailable: ${e.reason}.`));return n}}export{Z as $,Ga as A,Da as B,yo as C,Rt as Ct,oo as D,co as E,Ot as Et,Na as F,ua as G,ba as H,Aa as I,pa as J,ga as K,ja as L,Ua as M,Ha as N,to as O,ka as P,li as Q,Va as R,$o as S,U as St,uo as T,wt as Tt,ha as U,fa as V,da as W,X,ci as Y,$ as Z,Wo as _,gr as _t,ls as a,Ei as at,es as b,fn as bt,ms as c,Gi as ct,gs as d,si as dt,Vi as et,Qo as f,oi as ft,Yo as g,Qr as gt,Ho as h,Yr as ht,ts as i,Ci as it,qa as j,Ka as k,fs as l,na as lt,Jo as m,Xr as mt,Ko as n,Hi as nt,ps as o,Wi as ot,as as p,Y as pt,ma as q,Zo as r,Ui as rt,ss as s,Q as st,Go as t,Bi as tt,_s as u,Ai as ut,cs as v,ar as vt,mo as w,Et as wt,is as x,dn as xt,jo as y,hn as yt,Ba as z};
@@ -1 +1 @@
1
- import{Ms as e,ps as t,us as n}from"./dist-2lLb6-A6.mjs";import{N as r,j as i,k as a}from"./init-BPIylED-.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-Lhdnt_8C.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:r(e)}}let g=[],_=t(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=n(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=i(h,[`configurations`,y]);return x?(e(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
1
+ import{Ms as e,ps as t,us as n}from"./dist-CWmsgB4D.mjs";import{N as r,j as i,k as a}from"./init-DEZvHVW0.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-vEg6Crwy.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:r(e)}}let g=[],_=t(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=n(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=i(h,[`configurations`,y]);return x?(e(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-CiUplufh.mjs";export{e as loadConfig};
@@ -1 +1 @@
1
- import{Gc as e,bl as t,gl as n,k as r,ml as i,qc as a,vd as o}from"./md-manager-BGnqyqi1-1WhsA8vv.mjs";import{Bs as s,Rs as c,x as l}from"./dist-2lLb6-A6.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-CIdryYLD.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=o();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=n({file:t.path,source:t.source,doc:t.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function b(n){let o=n??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,o),_=c({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,n=!1)=>{let a=v(e);if(a.diagnostic!==void 0&&p.push(a.diagnostic),a.value===null)return{};let o=i({value:a.value,file:a.path,source:a.source,doc:a.doc});p.push(...o),u.push(e);let s=o.length>0?t(a.value):a.value;return n&&h.push(...r({value:s,file:a.path,source:a.source,doc:a.doc})),s},x=f(o,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,o)),w=e(_.value,S,C),T=l.safeParse(w);if(!T.success){let e=v(x),t={code:`SCHEMA_INVALID`,issues:y(T.error.issues,e)};throw Error(a(t))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
1
+ import{Gc as e,bl as t,gl as n,k as r,ml as i,qc as a,vd as o}from"./md-manager-BGnqyqi1-COpgRhOl.mjs";import{Bs as s,Rs as c,x as l}from"./dist-CWmsgB4D.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-t9AfZY26.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=o();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=n({file:t.path,source:t.source,doc:t.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function b(n){let o=n??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,o),_=c({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,n=!1)=>{let a=v(e);if(a.diagnostic!==void 0&&p.push(a.diagnostic),a.value===null)return{};let o=i({value:a.value,file:a.path,source:a.source,doc:a.doc});p.push(...o),u.push(e);let s=o.length>0?t(a.value):a.value;return n&&h.push(...r({value:s,file:a.path,source:a.source,doc:a.doc})),s},x=f(o,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,o)),w=e(_.value,S,C),T=l.safeParse(w);if(!T.success){let e=v(x),t={code:`SCHEMA_INVALID`,issues:y(T.error.issues,e)};throw Error(a(t))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};