@inkeep/open-knowledge 0.73.0-beta.3 → 0.73.0-beta.4

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 (158) hide show
  1. package/dist/cli.mjs +22 -22
  2. package/dist/constants-DXgziVS3.mjs +1 -0
  3. package/dist/{dist-RMxvFZJz.mjs → dist-BHzXo_n8.mjs} +1 -1
  4. package/dist/{dist-CkxNiJMy.mjs → dist-CYtBexjQ.mjs} +485 -485
  5. package/dist/index.mjs +1 -1
  6. package/dist/init-L91v6Ho6.mjs +1 -0
  7. package/dist/{init-B-EmtfJH.mjs → init-h7MX0AMg.mjs} +7 -7
  8. package/dist/{launch-json-removal-CYnvGNDp.mjs → launch-json-removal-D0jg76Nz.mjs} +1 -1
  9. package/dist/{loader-9XB8Jpbn.mjs → loader-Dqt3JX6k.mjs} +1 -1
  10. package/dist/loader-ZtMmWylB.mjs +1 -0
  11. package/dist/{md-manager-BGnqyqi1-DANVan-c.mjs → md-manager-BGnqyqi1-Cs2lSNJk.mjs} +156 -156
  12. package/dist/{open-browser-BTAGCSFt.mjs → open-browser-C1awBPyA.mjs} +1 -1
  13. package/dist/parse-worker.mjs +1 -1
  14. package/dist/preview-BpL5dC8j.mjs +1 -0
  15. package/dist/{preview-BwPbXbnu.mjs → preview-G6yYmK1V.mjs} +1 -1
  16. package/dist/public/assets/{ActivityModeContent-d9fNMoEr.js → ActivityModeContent-Bl9awT67.js} +1 -1
  17. package/dist/public/assets/AddPropertiesButton-BU01euTJ.js +2 -0
  18. package/dist/public/assets/{AgentDiffPane-Civhsmqq.js → AgentDiffPane-DaEMF6uj.js} +1 -1
  19. package/dist/public/assets/{AgentIconCluster-C_JZohB8.js → AgentIconCluster-omoQ7eAJ.js} +1 -1
  20. package/dist/public/assets/{AgentThreadClientBinder-BN_qo4Wm.js → AgentThreadClientBinder-Bp8XB0lY.js} +1 -1
  21. package/dist/public/assets/{BugReportHistory-CP02nlQl.js → BugReportHistory-RHno_6G6.js} +1 -1
  22. package/dist/public/assets/{BugReportHistoryDialog-CQm_Om5A.js → BugReportHistoryDialog-PM9xEu5P.js} +1 -1
  23. package/dist/public/assets/{CodeMirrorPropInput-Cd2Qlf2e.js → CodeMirrorPropInput-D5lh67CX.js} +1 -1
  24. package/dist/public/assets/{ConsentDialogBody-DYemewMQ.js → ConsentDialogBody-mQbZEIS3.js} +1 -1
  25. package/dist/public/assets/{DiffViewBoundary-C8iouqgY.js → DiffViewBoundary-BJrVHRy9.js} +1 -1
  26. package/dist/public/assets/{DocumentContext-CNpXYnXn.js → DocumentContext-CahS-SQ_.js} +11 -11
  27. package/dist/public/assets/{EditorModeToggle-B_1Zwyl0.js → EditorModeToggle-BUgxC2Fh.js} +1 -1
  28. package/dist/public/assets/{EnableSyncConfirmDialog-BTzd9J-Z.js → EnableSyncConfirmDialog-CFDG8HWU.js} +1 -1
  29. package/dist/public/assets/{ExcalidrawDocEditor-CLydALlU.js → ExcalidrawDocEditor-BF9NzZsZ.js} +1 -1
  30. package/dist/public/assets/FeedbackForm-u8Bcnhy6.js +1 -0
  31. package/dist/public/assets/{GraphPanel-8kvbOqVa.js → GraphPanel-B04m5Bu-.js} +1 -1
  32. package/dist/public/assets/{ImageAttachments-DNOv8fQj.js → ImageAttachments-D73BlFNZ.js} +1 -1
  33. package/dist/public/assets/{ImportSkillDialog-C8_7Cq9m.js → ImportSkillDialog-Dhl8EXXp.js} +1 -1
  34. package/dist/public/assets/{LintConfigEditor-CD9cnQFA.js → LintConfigEditor-C96groqA.js} +1 -1
  35. package/dist/public/assets/ManagedArtifactProperties-BLdbpOl-.js +1 -0
  36. package/dist/public/assets/{ManagedArtifactProperties-BWhLXfu3.js → ManagedArtifactProperties-BWc7ewvl.js} +1 -1
  37. package/dist/public/assets/{MermaidDocEditor-DIT0XQJ0.js → MermaidDocEditor-Cddck50m.js} +1 -1
  38. package/dist/public/assets/{OpenInAgentMenuItem-DvodHfoX.js → OpenInAgentMenuItem-DpkJbvPO.js} +1 -1
  39. package/dist/public/assets/{PropertyDisplayRow-Cf9F1VYQ.js → PropertyDisplayRow-DjvRBrwp.js} +1 -1
  40. package/dist/public/assets/{RegisteredAgentIcon-Cu4JpYmm.js → RegisteredAgentIcon-BThKjBdv.js} +1 -1
  41. package/dist/public/assets/{ReportBugDialogBody-bCKyMgtb.js → ReportBugDialogBody-BNuJNPm1.js} +1 -1
  42. package/dist/public/assets/{ReportBugMenuTrigger-Bnkzyzq5.js → ReportBugMenuTrigger-pPZC4Khd.js} +2 -2
  43. package/dist/public/assets/{SchemaConfigEditor-CY1yGTJ6.js → SchemaConfigEditor-DRNM5f00.js} +1 -1
  44. package/dist/public/assets/{SessionsHost-CzbJPXnu.js → SessionsHost-BV_MS9Ek.js} +2 -2
  45. package/dist/public/assets/{SettingsDialogBody-BbgDNTOn.js → SettingsDialogBody-CYfQN5qY.js} +4 -4
  46. package/dist/public/assets/{ShareBranchSwitchDialog-DhxwPxsC.js → ShareBranchSwitchDialog-DArKFReO.js} +1 -1
  47. package/dist/public/assets/{ShareReceiveDialog-88ynXZfc.js → ShareReceiveDialog-CQSVt7tv.js} +1 -1
  48. package/dist/public/assets/{ShareReceiveMissDialog-6Y56Pxq4.js → ShareReceiveMissDialog-DMhjLVGI.js} +1 -1
  49. package/dist/public/assets/{SkillCostValue-5P_wpRdV.js → SkillCostValue-BeSfWWtB.js} +1 -1
  50. package/dist/public/assets/{SkillEditBanner-CuQh2loL.js → SkillEditBanner-C63WNMDZ.js} +1 -1
  51. package/dist/public/assets/{SkillForkDialog-X83VCAlL.js → SkillForkDialog-D4ZyexlA.js} +1 -1
  52. package/dist/public/assets/{SkillInstallMenu-BAhi0Xx4.js → SkillInstallMenu-BgBucN1S.js} +1 -1
  53. package/dist/public/assets/{SkillOriginInline-DS3BVoCL.js → SkillOriginInline-D76hKo24.js} +1 -1
  54. package/dist/public/assets/{SkillToolbarControls-BuAuB7IE.js → SkillToolbarControls-CR1ap7GN.js} +1 -1
  55. package/dist/public/assets/{SlidesToolbarControls-B4ssb3Pt.js → SlidesToolbarControls-BTfHiyYu.js} +1 -1
  56. package/dist/public/assets/{SourceEditor---Cgog-0.js → SourceEditor-CDzkyBBc.js} +1 -1
  57. package/dist/public/assets/{TerminalPanel-NPca0A3h.js → TerminalPanel-d9n0Vnji.js} +3 -3
  58. package/dist/public/assets/{TerminalWindowApp-DAbY_6i9.js → TerminalWindowApp-BkVvf23p.js} +1 -1
  59. package/dist/public/assets/{TextDocEditor-qtuvqtO6.js → TextDocEditor-BFnmyyXK.js} +1 -1
  60. package/dist/public/assets/ThreadView-19iXC8RB.js +18 -0
  61. package/dist/public/assets/{TimelineDiffPane-D1KgksCm.js → TimelineDiffPane-100mmj3-.js} +1 -1
  62. package/dist/public/assets/{agent-connection-status-BazpsdSj.js → agent-connection-status-DZbOImds.js} +1 -1
  63. package/dist/public/assets/auth-state-cache-yKG3xBAQ.js +11 -0
  64. package/dist/public/assets/{bug-report-send-manager-CU9M5Xtp.js → bug-report-send-manager-JXlioVrM.js} +1 -1
  65. package/dist/public/assets/{client-version-DXJcBYv4.js → client-version-hldFhH0x.js} +1 -1
  66. package/dist/public/assets/{comment-chips-B8KUZPk3.js → comment-chips-DkS94ZmE.js} +1 -1
  67. package/dist/public/assets/{config-provider-BkpjPZKc.js → config-provider-DFGo1L5C.js} +1 -1
  68. package/dist/public/assets/{css-color-to-hex-CfpSkqRk.js → css-color-to-hex-C9tO-_EZ.js} +1 -1
  69. package/dist/public/assets/{dist-uOn7psPn.js → dist-PDvkPYep.js} +190 -190
  70. package/dist/public/assets/{doc-paths-CykYZH4R.js → doc-paths-BIeXMIcv.js} +1 -1
  71. package/dist/public/assets/{doc-undo-manager-DM2ra4s2.js → doc-undo-manager-vVBz_wDu.js} +1 -1
  72. package/dist/public/assets/{documents-events-hdkFhx5V.js → documents-events-CV-uem4k.js} +1 -1
  73. package/dist/public/assets/{file-tree-adapter-WgrZApcA.js → file-tree-adapter-CXAS-GwH.js} +1 -1
  74. package/dist/public/assets/{file-tree-utils-E9Kg3dJD.js → file-tree-utils-20nthbKk.js} +1 -1
  75. package/dist/public/assets/{folder-config-api-BB-91-mn.js → folder-config-api-BPbLmdMa.js} +1 -1
  76. package/dist/public/assets/{index-B7-o2lka.js → index-CGy_FL1B.js} +13 -13
  77. package/dist/public/assets/{lint-config-client-CbsC0A72.js → lint-config-client-BEcR85A9.js} +1 -1
  78. package/dist/public/assets/{markdownlint-rule-browser-P5SrSjtw.js → markdownlint-rule-browser-DUaNQNIl.js} +1 -1
  79. package/dist/public/assets/messages-BKYtfF_a.js +1 -0
  80. package/dist/public/assets/messages-BaqYmYkO.js +1 -0
  81. package/dist/public/assets/messages-Bq7OAq39.js +1 -0
  82. package/dist/public/assets/messages-Cs896rgg.js +1 -0
  83. package/dist/public/assets/messages-D6bNKe75.js +1 -0
  84. package/dist/public/assets/messages-DWTDTIgh.js +1 -0
  85. package/dist/public/assets/messages-DuRtMnXh.js +1 -0
  86. package/dist/public/assets/messages-EogT4aB4.js +1 -0
  87. package/dist/public/assets/messages-FPFstBrI.js +1 -0
  88. package/dist/public/assets/messages-LCMcKcaH.js +1 -0
  89. package/dist/public/assets/messages-gZxpVz4p.js +1 -0
  90. package/dist/public/assets/messages-pthQ0X7f.js +1 -0
  91. package/dist/public/assets/{navigation-targets-Be3L7gCC.js → navigation-targets-C6lx7ovc.js} +1 -1
  92. package/dist/public/assets/{page-list-cache-D_1WdPAP.js → page-list-cache-DdkS1NxH.js} +1 -1
  93. package/dist/public/assets/{pending-receive-nav-store-Dyfdh-zH.js → pending-receive-nav-store-DUGXaA4g.js} +1 -1
  94. package/dist/public/assets/{progress-DCiIIjE5.js → progress-CaH25FNb.js} +1 -1
  95. package/dist/public/assets/{project-paths-C4hrLpHa.js → project-paths-DjmzBrDQ.js} +1 -1
  96. package/dist/public/assets/{prop-types-Dipzx0F0.js → prop-types-vkxZuVZ9.js} +1 -1
  97. package/dist/public/assets/{receive-store-DrdUor9w.js → receive-store-BQHZ74jj.js} +1 -1
  98. package/dist/public/assets/{selection-context-DNU6YKBa.js → selection-context-D-a5wZEH.js} +1 -1
  99. package/dist/public/assets/{skill-scope-CGBqTRe3.js → skill-scope-BxR-aybK.js} +1 -1
  100. package/dist/public/assets/{skills-api-DRQnTiOn.js → skills-api-BEGuCdXz.js} +1 -1
  101. package/dist/public/assets/{src-J8i3VAnQ.js → src-CUejlr_5.js} +1 -1
  102. package/dist/public/assets/{startup-marks-CTJiE9DG.js → startup-marks-BePF-27I.js} +1 -1
  103. package/dist/public/assets/{tag-pill-input-CuFn1ANA.js → tag-pill-input-DorfUPZk.js} +1 -1
  104. package/dist/public/assets/{target-navigation-intent-B4mW5JvD.js → target-navigation-intent-DhYDMvgK.js} +1 -1
  105. package/dist/public/assets/{telemetry-startup-CjKKZoZg.js → telemetry-startup-CHI8oMpP.js} +1 -1
  106. package/dist/public/assets/{terminal-cli-display-CyFO3zu5.js → terminal-cli-display-Dg1Dh7Vi.js} +1 -1
  107. package/dist/public/assets/{terminal-command-events-DlQ3pxTI.js → terminal-command-events-k9Z4lFOj.js} +1 -1
  108. package/dist/public/assets/{terminal-launch-events-PWq7UD-a.js → terminal-launch-events-CDv1zmEc.js} +1 -1
  109. package/dist/public/assets/{terminal-telemetry-BIGl_GBP.js → terminal-telemetry-CaYd1m0y.js} +1 -1
  110. package/dist/public/assets/{typing-burst-detector-BNE8s0ys.js → typing-burst-detector-CylQcXf3.js} +1 -1
  111. package/dist/public/assets/{uninstall-BKfXc8Lh.js → uninstall-CZzQ9rwB.js} +1 -1
  112. package/dist/public/assets/{use-activity-panel-a6nmcCQD.js → use-activity-panel-BjGxIEij.js} +1 -1
  113. package/dist/public/assets/{use-apply-config-language-Bjsu53TA.js → use-apply-config-language-B4-B1agU.js} +2 -2
  114. package/dist/public/assets/{use-collab-url-Dm-9dIrQ.js → use-collab-url-CiOtWcg4.js} +1 -1
  115. package/dist/public/assets/{use-conflicts-DqHQ8MFV.js → use-conflicts-icC7Ryte.js} +1 -1
  116. package/dist/public/assets/{use-live-xterm-theme-Dj1DQYNM.js → use-live-xterm-theme-CMs8KelT.js} +1 -1
  117. package/dist/public/assets/{use-open-skill-BX8gas_Z.js → use-open-skill-Essosx0v.js} +1 -1
  118. package/dist/public/assets/{use-settings-route-D_wuRBu-.js → use-settings-route-j3dwmlQi.js} +1 -1
  119. package/dist/public/assets/{use-skill-origin-Ce7gHGc3.js → use-skill-origin-BhaGvMvj.js} +1 -1
  120. package/dist/public/assets/{use-skills-CgzMBYgo.js → use-skills-C1wTERlX.js} +1 -1
  121. package/dist/public/assets/{use-terminal-enabled-czStGj6s.js → use-terminal-enabled-CnkQfS_I.js} +1 -1
  122. package/dist/public/assets/{use-timeline-entry-diff-CqQXDxtA.js → use-timeline-entry-diff-BnFb33b4.js} +1 -1
  123. package/dist/public/assets/{use-workspace-tpFIpBme.js → use-workspace-wLyRfOGV.js} +1 -1
  124. package/dist/public/index.html +55 -55
  125. package/dist/public/uninstall.html +4 -4
  126. package/dist/{registry-probes-UKIu8-Jt.mjs → registry-probes-Cs0c05MN.mjs} +2 -2
  127. package/dist/{removal-file-path-CqBQ1wer.mjs → removal-file-path-CLOX9HOE.mjs} +1 -1
  128. package/dist/{repair-launch-json-DTz20CZ3.mjs → repair-launch-json-BIgUkt55.mjs} +1 -1
  129. package/dist/{repair-mcp-configs-Bp6VQwEc.mjs → repair-mcp-configs-BJuXJzf2.mjs} +1 -1
  130. package/dist/src-B57nffjF.mjs +11 -0
  131. package/dist/src-BSMcFbnT.mjs +1 -0
  132. package/dist/{start-DBYpRraD.mjs → start-BIeKVKeG.mjs} +3 -3
  133. package/dist/start-CQCGVcQ8.mjs +1 -0
  134. package/package.json +4 -4
  135. package/dist/constants-CzoY31nN.mjs +0 -1
  136. package/dist/init-CFFn_3qD.mjs +0 -1
  137. package/dist/loader-DI6GS-t_.mjs +0 -1
  138. package/dist/preview-C7X2VjIE.mjs +0 -1
  139. package/dist/public/assets/AddPropertiesButton-WXzRqY87.js +0 -2
  140. package/dist/public/assets/FeedbackForm-BE5KDNjH.js +0 -1
  141. package/dist/public/assets/ManagedArtifactProperties-BBtAzYrO.js +0 -1
  142. package/dist/public/assets/ThreadView-7vfmHpCX.js +0 -16
  143. package/dist/public/assets/auth-state-cache-AC39IkQK.js +0 -11
  144. package/dist/public/assets/messages-2_krnt-J.js +0 -1
  145. package/dist/public/assets/messages-8mUkYVn5.js +0 -1
  146. package/dist/public/assets/messages-CDOqoBfG.js +0 -1
  147. package/dist/public/assets/messages-CaPzXTW5.js +0 -1
  148. package/dist/public/assets/messages-Ck5QFE56.js +0 -1
  149. package/dist/public/assets/messages-CqZI-CVf.js +0 -1
  150. package/dist/public/assets/messages-D3R7TZVI.js +0 -1
  151. package/dist/public/assets/messages-D5iwMbL_.js +0 -1
  152. package/dist/public/assets/messages-Dv6OgDLY.js +0 -1
  153. package/dist/public/assets/messages-DyWtLR5D.js +0 -1
  154. package/dist/public/assets/messages-LIImwOT9.js +0 -1
  155. package/dist/public/assets/messages-yY5hf_IP.js +0 -1
  156. package/dist/src-CCvThoMl.mjs +0 -1
  157. package/dist/src-DfB67DHH.mjs +0 -11
  158. package/dist/start-BztDLMV8.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -1534,6 +1534,6 @@ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){funct
1534
1534
  `);re(e,o)}function M9(e,t){let n=S(e,`utf-8`);if(n.trim().length!==0)try{let r=A9(JSON.parse(n),t),i=n.endsWith(`
1535
1535
  `)?`
1536
1536
  `:``;re(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=k9(n,t.contentDir);r!==n&&re(e,r)}}function N9(e,t){let n=S(e,`utf-8`),r=k9(n,t.contentDir);r!==n&&re(e,r)}function P9(e){try{return w(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>N(e,t.name))}catch{return[]}}const cAe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function F9(e){return/\.log\.\d+$/.test(e)}function lAe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||F9(e)}const uAe=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function dAe(e){let t={contentDir:e.contentDir};for(let n of uAe)for(let r of P9(N(e.stagingDir,n)))lAe(r)?j9(r,t):r.endsWith(`.json`)?M9(r,t):N9(r,t);for(let n of P9(N(e.stagingDir,`state`))){let e=me(n);n.endsWith(`.jsonl`)?j9(n,t):cAe.has(e)?M9(n,t):N9(n,t)}}const I9=[`.ok`,`local`,`telemetry`],L9=[`.ok`,`local`,`logs`],R9=[`.ok`,`local`,`loss-capture`],z9=`spans-current.jsonl`,B9=`spans-prev.jsonl`,V9=`server-current.jsonl`,H9=`server-prev.jsonl`,U9=`loss-current.jsonl`,W9=`loss-prev.jsonl`;function fAe(e){return N(e,...I9,z9)}function pAe(e){return N(e,...I9,B9)}function mAe(e){return N(e,...L9,V9)}function hAe(e){return N(e,...L9,H9)}function gAe(e){return N(e,...R9,U9)}function _Ae(e){return N(e,...R9,W9)}const G9=1e3;async function vAe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function yAe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function bAe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}function xAe(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(`
1537
- `)}\n`:null}catch{return null}}function SAe(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],G6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function CAe(e){let t=N(e,`.git`,`ok`);if(!g(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/`],G6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){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 wAe(){return{nodeVersion:process.version,platform:le(),arch:ae()}}function TAe(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,nn.parse)(S(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(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function EAe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return EAe(e.maxBytes)}function DAe(e){let t=J9(RQ(`project`,e)),n=J9(RQ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function OAe(e){return Ne(`sha256`).update(e).digest(`hex`)}function kAe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const AAe=[`"doc.name"`,`"docName"`];function jAe(e){let t=S(e,`utf-8`),n=0;for(let e of AAe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(M(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,w7(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const MAe=new Set([`.jsonl`]);function NAe(e){let t=e.lastIndexOf(`.`);return t!==-1&&MAe.has(e.slice(t))}const PAe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function FAe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&PAe.has(e.slice(t))}function IAe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!FAe(r))continue;let{redacted:i,patterns:a,lineCount:o}=bB(S(n,`utf-8`));a.length!==0&&(re(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 ye(e,t).split(xe).join(`/`)}async function LAe(e){let t=be(e.contentDir),n=be(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??vAe,a=r.fetchAgentEffects??yAe,o=r.fetchWatcherRecent??bAe,s=r.readShadowHead??SAe,c=r.readCheckpointRefs??CAe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.73.0-beta.3`),d=r.readDesktopEnv??K9,f=r.readLanguage??O9,p=r.readRuntime??wAe,h=r.isOtlpPushEnabled??TAe,_=y(N(A(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),Z9(fAe(n),N(_,`telemetry`,z9)),Z9(pAe(n),N(_,`telemetry`,B9)),Z9(mAe(n),N(_,`logs`,V9)),Z9(hAe(n),N(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,N(_,`logs`,me(t)));for(let t of e.userStateFiles??[])Z9(t,N(_,QL,me(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,N(_,`diagnostic-reports`,me(t)))&&(y+=1);let b=N(n,`.ok`,`local`),x=N(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,N(_,`state`,`server.lock`));try{let e=S(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`:(re(N(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(N(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=xAe(n);e!==null&&re(N(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(N(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(N(_,`state`,`checkpoint-refs.txt`),D),Z9(gAe(n),N(_,`state`,U9)),Z9(_Ae(n),N(_,`state`,W9)),Z9(N(b,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),Z9(N(b,Nu),N(_,`state`,Nu)),Z9(N(b,Pu),N(_,`state`,Pu));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}};re(N(_,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let oe=C===`running`?`running
1537
+ `)}\n`:null}catch{return null}}function SAe(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],G6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function CAe(e){let t=N(e,`.git`,`ok`);if(!g(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/`],G6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){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 wAe(){return{nodeVersion:process.version,platform:le(),arch:ae()}}function TAe(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,nn.parse)(S(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(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function EAe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return EAe(e.maxBytes)}function DAe(e){let t=J9(RQ(`project`,e)),n=J9(RQ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function OAe(e){return Ne(`sha256`).update(e).digest(`hex`)}function kAe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const AAe=[`"doc.name"`,`"docName"`];function jAe(e){let t=S(e,`utf-8`),n=0;for(let e of AAe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(M(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,w7(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const MAe=new Set([`.jsonl`]);function NAe(e){let t=e.lastIndexOf(`.`);return t!==-1&&MAe.has(e.slice(t))}const PAe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function FAe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&PAe.has(e.slice(t))}function IAe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!FAe(r))continue;let{redacted:i,patterns:a,lineCount:o}=bB(S(n,`utf-8`));a.length!==0&&(re(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 ye(e,t).split(xe).join(`/`)}async function LAe(e){let t=be(e.contentDir),n=be(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??vAe,a=r.fetchAgentEffects??yAe,o=r.fetchWatcherRecent??bAe,s=r.readShadowHead??SAe,c=r.readCheckpointRefs??CAe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.73.0-beta.4`),d=r.readDesktopEnv??K9,f=r.readLanguage??O9,p=r.readRuntime??wAe,h=r.isOtlpPushEnabled??TAe,_=y(N(A(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),Z9(fAe(n),N(_,`telemetry`,z9)),Z9(pAe(n),N(_,`telemetry`,B9)),Z9(mAe(n),N(_,`logs`,V9)),Z9(hAe(n),N(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,N(_,`logs`,me(t)));for(let t of e.userStateFiles??[])Z9(t,N(_,QL,me(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,N(_,`diagnostic-reports`,me(t)))&&(y+=1);let b=N(n,`.ok`,`local`),x=N(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,N(_,`state`,`server.lock`));try{let e=S(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`:(re(N(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(N(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=xAe(n);e!==null&&re(N(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(N(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(N(_,`state`,`checkpoint-refs.txt`),D),Z9(gAe(n),N(_,`state`,U9)),Z9(_Ae(n),N(_,`state`,W9)),Z9(N(b,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),Z9(N(b,Nu),N(_,`state`,Nu)),Z9(N(b,Pu),N(_,`state`,Pu));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}};re(N(_,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let oe=C===`running`?`running
1538
1538
  `:`not-running (${w})\n`;re(N(_,`state`,`server-status.txt`),oe);let se=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:C7(e.diagnosticReports,y);if(re(N(_,`state`,`diagnostic-reports-status.txt`),`${se}\n`),e.processDir&&g(e.processDir)){let t=N(_,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let k=e.redact===!0;k&&dAe({stagingDir:_,contentDir:t}),e.note&&re(N(_,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=IAe(_));for(let t of e.extraFiles??[])Z9(t.sourcePath,N(_,`extra`,t.zipName??me(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let le=DAe(n),ue=Q9(_),A=[],j=0,de=0;for(let e of ue){let t=$9(_,e),n=te(e).size,r=NAe(t)?kAe(e):0;A.push({path:t,bytes:n,lines:r}),j+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(de+=jAe(e))}let fe={applied:k};ce!==null&&(fe.secretScrub=ce);let pe={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie},contentDir:{pathSha256:OAe(t),absolutePath:k?`<CONTENT_DIR>`:t},telemetry:{localSink:le,otlpPushEnabled:h()},redaction:fe,serverStatus:C,files:A};re(N(_,`manifest.json`),`${JSON.stringify(pe,null,2)}\n`);let M=ue.some(e=>{try{return S(e,`utf-8`).includes(t)}catch{return!1}}),he={stagedDiagnosticReports:y,totalBytes:j,fileCount:A.length,docNameCount:de,contentDirVisible:M,redacted:k},ge=!1;return{stagingDir:_,manifest:pe,summary:he,cleanup:()=>{ge||(ge=!0,O(_,{recursive:!0,force:!0}))}}}catch(e){throw O(_,{recursive:!0,force:!0}),e}}async function RAe(e){let{collected:t,outputPath:n}=e,r=M(n);if(!g(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new ZSe.ZipFile,a=Q9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=h(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 zAe(e,t){let n=N(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,nn.parse)(S(n,`utf-8`)),r=q8(t)?t.content:void 0,i=q8(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return be(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 be(e)}async function BAe(e,t,n,r,i){let a=E7(t,e.logger),o=await LAe({contentDir:zAe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...XOe(a,e.userLogsDir??N(k(),`.ok`,`logs`)),...O7(e.cachesDir??N(k(),`Library`,`Caches`))],userStateFiles:k7(e.bugReportsDir??T7()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{v(M(e.outputPath),{recursive:!0}),await RAe({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function VAe(e){let{projectDir:t}=e,n=e.readDesktopEnv??K9,r=e.readLanguage??O9,i=()=>KOe(e.diagnosticReportsDir??N(k(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return BAe(e,t,n,r,i());let{zipPath:a,summary:o}=await tke({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:O7(e.cachesDir??N(k(),`Library`,`Caches`)),bugReportLedgerFiles:k7(e.bugReportsDir??T7()),diagnosticReports:e.level===`full`?i():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{e5 as ALL_EDITOR_IDS,t5 as EDITOR_LABELS,j5 as EDITOR_TARGETS,fDe as HOSTS_WITH_USER_SKILL_DIR,MOe as LAUNCH_CONFIG_NAME,Wke as PATH_SHIM_BEGIN,Kke as PATH_SHIM_BLOCK_RE,Gke as PATH_SHIM_END,uOe as addOkPathsToGitExclude,R5 as assertProjectPathSafe,p5 as buildManagedServerEntry,Pke as buildMcpConfigDeclineEvent,Fke as buildMcpConfigMigrateEvent,b7 as classifyExistingMcpEntry,VAe as collectReportBundle,Zke as createCliProbeResolver,sn as createTokenStore,qOe as defaultBugReportZipPath,We as detectGh,qe as detectGhAccounts,IOe as detectInstalledEditors,S5 as droppedManagedKeys,NDe as editorConfigPathDisplay,MDe as editorEntryLocator,Cke as ensurePiBridge,Q5 as formatTrackedRemediation,pOe as getExcludedOkPaths,X5 as getInstalledSkillProjectionPaths,dDe as getNativeTomlMcpEditor,Y5 as getOkArtifactPaths,d5 as isEntryUpToDate,m5 as isOwnManagedEntry,Vke as loadConfig,yee as makeLazyProbeTokenStore,T7 as okBugReportsDir,b9 as parseGitHubBlobUrl,Hke as parseGitHubShareUrl,x9 as parseGitHubTreeUrl,y9 as parseGitUrl,qke as pathInstallMarkerPath,JDe as previewContent,LOe as probeOwnManagedEditorMcpEntry,xke as probePiBridgeState,Z5 as probeTrackedOkPaths,v7 as readExistingMcpEntry,fOe as readSharingMode,bB as redactContent,dOe as removeOkPathsFromGitExclude,Ake as removeOwnMcpEntry,oOe as removeProjectSkill,$ke as removeUserGlobalSkillBundle,aAe as removeUserSkill,eOe as resolveProjectRoot,Rke as runStop,h9 as truncatePriorEntry,E9 as userGlobalSkillBundleTargets,iAe as userSkillPresentAnywhere,Uke as validateLocalFolderForShare,_7 as writeEditorMcpConfig,nAe as writeProjectAiIntegrations,W5 as writeProjectSkill,FOe as writeUserMcpConfigs,rAe as writeUserSkill};
1539
1539
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ import"./dist-CYtBexjQ.mjs";import{_ as e}from"./init-h7MX0AMg.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{Ad as r,Ed as i,Fd as a,Mt as o,Nu as s,Od as c,Pd as l,Pu as u,Ru as d,Td as f,Ul as p,gs as m,jd as h,jl as g,ku as _,ms as v,tc as y,zl as b}from"./md-manager-BGnqyqi1-DANVan-c.mjs";import{Eo as x,Er as S,Hi as ee,I as te,In as ne,Ki as re,L as ie,Mo as ae,Mr as oe,Ro as se,So as ce,Ui as le,Un as ue,Ur as de,V as fe,Zt as pe,ao as me,bo as C,br as he,ia as ge,it as _e,m as ve,no as ye,nt as be,so as xe,vo as Se,wt as Ce,xo as we,yo as Te}from"./dist-CkxNiJMy.mjs";import{i as w,n as T,o as E,r as Ee,s as D,t as O}from"./colors-r_owlCuY.mjs";import{t as k}from"./is-object-BGze3w87.mjs";import{t as De}from"./constants-CzoY31nN.mjs";import{t as Oe}from"./preview-BwPbXbnu.mjs";import{createRequire as ke}from"node:module";import{execFileSync as Ae}from"node:child_process";import je,{basename as Me,dirname as A,isAbsolute as Ne,join as j,posix as Pe,relative as M,resolve as N,sep as P,win32 as Fe}from"node:path";import F from"node:process";import{fileURLToPath as Ie}from"node:url";import{cpSync as Le,existsSync as I,lstatSync as Re,mkdirSync as ze,readFileSync as L,readdirSync as Be,readlinkSync as Ve,realpathSync as He,rmSync as Ue,statSync as We,writeFileSync as Ge}from"node:fs";import{homedir as R}from"node:os";import{inspect as Ke,stripVTControlCharacters as qe,styleText as z}from"node:util";import*as Je from"node:readline";import{AsyncLocalStorage as Ye,AsyncResource as Xe}from"node:async_hooks";var Ze=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})),Qe=n((e=>{let{InvalidArgumentError:t}=Ze();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})),$e=n((e=>{let{humanReadableArgName:t}=Qe();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{Ad as r,Bu as i,Dd as a,Id as o,Ld as s,Md as c,Mt as l,Nd as u,Nu as d,Od as f,Pu as p,Ul as m,gs as h,jl as g,ku as _,ms as v,tc as y,zl as b}from"./md-manager-BGnqyqi1-Cs2lSNJk.mjs";import{Eo as x,Er as S,Hi as ee,I as te,In as ne,Ki as re,L as ie,Mo as ae,Mr as oe,Ro as se,So as ce,Ui as le,Un as ue,Ur as de,V as fe,Zt as pe,ao as me,bo as C,br as he,ia as ge,it as _e,m as ve,no as ye,nt as be,so as xe,vo as Se,wt as Ce,xo as we,yo as Te}from"./dist-CYtBexjQ.mjs";import{i as w,n as T,o as E,r as Ee,s as D,t as O}from"./colors-r_owlCuY.mjs";import{t as k}from"./is-object-BGze3w87.mjs";import{t as De}from"./constants-DXgziVS3.mjs";import{t as Oe}from"./preview-G6yYmK1V.mjs";import{createRequire as ke}from"node:module";import{execFileSync as Ae}from"node:child_process";import je,{basename as Me,dirname as A,isAbsolute as Ne,join as j,posix as Pe,relative as M,resolve as N,sep as P,win32 as Fe}from"node:path";import F from"node:process";import{fileURLToPath as Ie}from"node:url";import{cpSync as Le,existsSync as I,lstatSync as Re,mkdirSync as ze,readFileSync as L,readdirSync as Be,readlinkSync as Ve,realpathSync as He,rmSync as Ue,statSync as We,writeFileSync as Ge}from"node:fs";import{homedir as R}from"node:os";import{inspect as Ke,stripVTControlCharacters as qe,styleText as z}from"node:util";import*as Je from"node:readline";import{AsyncLocalStorage as Ye,AsyncResource as Xe}from"node:async_hooks";var Ze=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})),Qe=n((e=>{let{InvalidArgumentError:t}=Ze();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})),$e=n((e=>{let{humanReadableArgName:t}=Qe();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})),et=n((e=>{let{InvalidArgumentError:t}=Ze();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}
@@ -278,7 +278,7 @@ let br=/^[a-z0-9-_]+$/i;function xr(e){let t=typeof e;if(t===`object`){if(Array.
278
278
  `)+Or(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=wr(t[c],e,r,i),a+=`
279
279
  `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function kr(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(xr(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Or(0,e,``,t,n);return r[r.length-1]===`
280
280
  `?r:r+`
281
- `}var Ar=_();function jr(e){let t=e&&typeof e==`object`&&`code`in e?e.code:void 0;return t===`MODULE_NOT_FOUND`||t===`ERR_MODULE_NOT_FOUND`}function Mr(e){return!e||typeof e!=`object`?String(e):`${typeof e} keys=[${Object.keys(e).join(`,`)}]`}function Nr(e,t){let n=[],r=new WeakSet,i=t;for(;i instanceof Error&&!r.has(i);)r.add(i),n.push(i.message),i=i.cause;return n.length===0?`${e}: ${Mr(t)}`:`${e}: ${n.reverse().slice(0,5).join(` -> `)}`}function J(e,t){process.env.OK_DEBUG_NATIVE&&process.stderr.write(`[ok] native-config ${Nr(e,t)}\n`)}const Pr=[`native`,`index.js`];function Fr(e={},t=J){let n=e.moduleUrl??import.meta.url,r=e.requireModule??ke(n);try{let e=A(Ie(n));return r(j(e,...Pr))}catch(e){jr(e)||t(`bundled loader failed to load`,e)}try{return r(`@inkeep/open-knowledge-native-config`)}catch(e){return jr(e)||t(`workspace addon failed to load`,e),null}}function Ir(){let e=Fr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Lr(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return J(`addon loaded but probe failed`,e),!1}}function Rr(e){if(!k(e))throw Error(`TOML root is not a table`);return e}function zr(e){return{backend:`native`,parseToObject(t){return Rr(JSON.parse(e.parseTomlToJson(t)))},upsertEntry(t,n,r){let i=e.upsertMcpServer(t,n,JSON.stringify(r));return{text:i.text,existed:i.existed}},removeEntry(t,n){let r=e.removeMcpServer(t,n);return{text:r.text,existed:r.existed}},removeEntryKey(t,n,r){let i=e.removeMcpServerKey(t,n,r);return{text:i.text,existed:i.existed}}}}function Br(){return{backend:`fallback`,parseToObject(e){return Rr(yr(e))}}}function Vr(e=Ir){let t=e();return t&&Lr(t)?zr(t):Br()}let Hr=null;function Ur(){return Hr===null&&(Hr=Vr()),Hr}function Wr(){let e=Ur();return e.backend===`native`?e:void 0}const Gr=f,Y=i,Kr=r,qr=`node`,Jr={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},Yr=`# ok-mcp-v2`,Xr=`# ok-mcp-v2
281
+ `}var Ar=_();function jr(e){let t=e&&typeof e==`object`&&`code`in e?e.code:void 0;return t===`MODULE_NOT_FOUND`||t===`ERR_MODULE_NOT_FOUND`}function Mr(e){return!e||typeof e!=`object`?String(e):`${typeof e} keys=[${Object.keys(e).join(`,`)}]`}function Nr(e,t){let n=[],r=new WeakSet,i=t;for(;i instanceof Error&&!r.has(i);)r.add(i),n.push(i.message),i=i.cause;return n.length===0?`${e}: ${Mr(t)}`:`${e}: ${n.reverse().slice(0,5).join(` -> `)}`}function J(e,t){process.env.OK_DEBUG_NATIVE&&process.stderr.write(`[ok] native-config ${Nr(e,t)}\n`)}const Pr=[`native`,`index.js`];function Fr(e={},t=J){let n=e.moduleUrl??import.meta.url,r=e.requireModule??ke(n);try{let e=A(Ie(n));return r(j(e,...Pr))}catch(e){jr(e)||t(`bundled loader failed to load`,e)}try{return r(`@inkeep/open-knowledge-native-config`)}catch(e){return jr(e)||t(`workspace addon failed to load`,e),null}}function Ir(){let e=Fr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Lr(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return J(`addon loaded but probe failed`,e),!1}}function Rr(e){if(!k(e))throw Error(`TOML root is not a table`);return e}function zr(e){return{backend:`native`,parseToObject(t){return Rr(JSON.parse(e.parseTomlToJson(t)))},upsertEntry(t,n,r){let i=e.upsertMcpServer(t,n,JSON.stringify(r));return{text:i.text,existed:i.existed}},removeEntry(t,n){let r=e.removeMcpServer(t,n);return{text:r.text,existed:r.existed}},removeEntryKey(t,n,r){let i=e.removeMcpServerKey(t,n,r);return{text:i.text,existed:i.existed}}}}function Br(){return{backend:`fallback`,parseToObject(e){return Rr(yr(e))}}}function Vr(e=Ir){let t=e();return t&&Lr(t)?zr(t):Br()}let Hr=null;function Ur(){return Hr===null&&(Hr=Vr()),Hr}function Wr(){let e=Ur();return e.backend===`native`?e:void 0}const Gr=a,Y=f,Kr=c,qr=`node`,Jr={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},Yr=`# ok-mcp-v2`,Xr=`# ok-mcp-v2
282
282
  USER_BUNDLE="$HOME/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
283
283
  [ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
284
284
  BUNDLE="/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
@@ -314,16 +314,16 @@ foreach ($d in $dirs) {
314
314
  if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '@inkeep/open-knowledge@latest' mcp; exit $LASTEXITCODE }
315
315
  }
316
316
  [Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
317
- exit 127`,ei=`// ok-pi-bridge`,ti=`${ei}-v1`;function ni(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return di(e,Yr)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return di(e,Zr)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return di(e,Yr)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return di(e,Zr)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(ti)}return!1}function ri(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=N(e);if(Me(t)===`cli.mjs`&&Me(A(t))===`dist`)return t;let n=t.split(P),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r),a=i.length===0?P:i.join(P);return j(a,`packages`,`cli`,`dist`,`cli.mjs`)}function X(e={}){return e.mode===`dev`?{command:qr,args:[ri(),`mcp`],env:{...Jr}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,$r]}:{command:`/bin/sh`,args:[`-l`,`-c`,Xr]}}function ii(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[qr,ri(),`mcp`],environment:{...Jr}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,$r]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,Xr]}}function ai(e){if(typeof e!=`object`||!e)return!1;let t=e;return oi(t,X({mode:`published`,platformName:`darwin`}))||oi(t,X({mode:`published`,platformName:`win32`}))}function oi(e,t){return Object.keys(e).length===Object.keys(t).length&&si(e,t)}function si(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function ci(e,t){let n=e=>fi(e);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`&&e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3])}function li(e){return e.format===`toml`?Ur().backend===`native`:e.format===`json`||e.format===`yaml`}function ui(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function di(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function fi(e){return di(e,`# ok-mcp`)}function pi(e){return typeof e==`string`&&(e===Qr||e.startsWith(`${Qr}@`))}function mi(e){if(typeof e!=`object`||!e)return!1;let t=ui(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&fi(t[n+1])?!0:t.some(pi)}function hi(e){if(typeof e!=`object`||!e)return!1;let t=ui(e);if(t[0]!==qr||t[2]!==`mcp`)return!1;try{return t[1]===ri()}catch{return!1}}const gi=[`command`,`args`,`env`],_i=[`type`,`command`,`environment`];function vi(e){return e.type===`local`&&Array.isArray(e.command)?_i:gi}function yi(e,t){if(typeof e!=`object`||!e)return[];let n=e;return vi(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function bi(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function xi(e,t){return yi(e,t).length>0}function Si(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:ci(t.args,t.command)}function Ci(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&ci(r,n)}function Z(e){return e===`win32`?Fe:Pe}function wi(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=e.env??process.env,i=Z(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA||i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME||i.join(n,`.config`)}function Ti(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.claude.json`)}function Ei(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=e.env??process.env;if(t===`darwin`)return Pe.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Fe.join(n,`AppData`,`Roaming`);return Fe.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Di(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.cursor`,`mcp.json`)}function Oi(e={}){let t=e.platformName??process.platform,n=e.home??R();return(e.env??process.env).CODEX_HOME??Z(t).join(n,`.codex`)}function ki(e={}){return Z(e.platformName??process.platform).join(Oi(e),`config.toml`)}function Ai(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=(e.env??process.env).COPILOT_HOME??Z(t).join(n,`.copilot`);return Z(t).join(r,`mcp-config.json`)}function ji(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=e.env??process.env,i=Z(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function Mi(e={}){return Z(e.platformName??process.platform).join(ji(e),`opencode.json`)}function Ni(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.openclaw`,`openclaw.json`)}function Pi(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.hermes`,`config.yaml`)}function Fi(e={}){let t=e.platformName??process.platform,n=e.home??R();return(e.env??process.env).PI_CODING_AGENT_DIR??Z(t).join(n,`.pi`,`agent`)}function Ii(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Li(e,t){let n=Z(t);return[{file:n.join(e,`.lmstudio`,`mcp.json`),dir:n.join(e,`.lmstudio`)},{file:n.join(e,`.cache`,`lm-studio`,`mcp.json`),dir:n.join(e,`.cache`,`lm-studio`)}]}function Ri(e){try{return Be(e).length>0}catch{return!1}}function zi(e={}){let t=e.platformName??process.platform,[n,r]=Li(e.home??R(),t),i=[n,r].find(e=>I(e.file));return i?i.file:Ri(r.dir)?r.file:n.file}const Q={claude:{id:`claude`,label:Y.claude,configPath:(e,t)=>Ti({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>u,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.claude`),projectConfigPath:e=>j(e,`.mcp.json`),projectSkillPath:e=>j(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:Y[`claude-desktop`],configPath:(e,t)=>Ei({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>u,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(Ei({home:t}))},cursor:{id:`cursor`,label:Y.cursor,configPath:(e,t)=>Di({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>u,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(Di({home:t})),projectConfigPath:e=>j(e,`.cursor`,`mcp.json`),projectSkillPath:e=>j(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:Y.codex,configPath:(e,t)=>ki({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>u,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(ki({home:t})),projectConfigPath:e=>j(e,`.codex`,`config.toml`),projectSkillPath:e=>j(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:Y.copilot,configPath:(e,t)=>Ai({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>u,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(Ai({home:t})),projectSkillPath:e=>j(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:Y.opencode,configPath:(e,t)=>Mi({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>u,buildEntry:(e,t)=>ii(t),scope:`global`,detectPath:(e,t)=>A(Mi({home:t})),projectConfigPath:e=>j(e,`opencode.json`),projectSkillPath:e=>j(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:Y.openclaw,configPath:(e,t)=>Ni({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>u,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:Y.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>u,scope:`project`,detectPath:(e,t)=>Fi({home:t}),projectConfigPath:e=>j(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>j(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:Y.antigravity,configPath:(e,t)=>Ii({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>u,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:Y[`lm-studio`],configPath:(e,t)=>zi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>u,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(zi({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:Y.hermes,configPath:(e,t)=>Pi({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>u,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.hermes`),offerOnlyWhenDetected:!0}};function Bi(e){let t=e.filter(e=>!Object.hasOwn(Q,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${Gr.join(`, `)}`);return e.map(e=>Q[e])}const Vi=`**/.ok/*`,Hi=`!**/${b}/`;function Ui(e){let t=[`.ok/`,`.okignore`];for(let n of Gr){let r=Q[n];r.projectConfigPath&&t.push(ia(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function Wi(e){let t=j(e,...o);if(!I(t))return[];try{let e=v(L(t,`utf-8`));if(!e)return[];let n=[];for(let[t,r]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of r.hosts){let r=c[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function Gi(e,t){let n=Yi(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:$i(n)};let r=ea(e);if(r.kind!==`ok`)return r.result;let i=I(r.path)?L(r.path,`utf-8`):``,a=new Set(Wi(e)),o=[],s=a.size===0?i:i.split(`
317
+ exit 127`,ei=`// ok-pi-bridge`,ti=`${ei}-v1`;function ni(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return di(e,Yr)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return di(e,Zr)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return di(e,Yr)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return di(e,Zr)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(ti)}return!1}function ri(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=N(e);if(Me(t)===`cli.mjs`&&Me(A(t))===`dist`)return t;let n=t.split(P),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r),a=i.length===0?P:i.join(P);return j(a,`packages`,`cli`,`dist`,`cli.mjs`)}function X(e={}){return e.mode===`dev`?{command:qr,args:[ri(),`mcp`],env:{...Jr}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,$r]}:{command:`/bin/sh`,args:[`-l`,`-c`,Xr]}}function ii(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[qr,ri(),`mcp`],environment:{...Jr}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,$r]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,Xr]}}function ai(e){if(typeof e!=`object`||!e)return!1;let t=e;return oi(t,X({mode:`published`,platformName:`darwin`}))||oi(t,X({mode:`published`,platformName:`win32`}))}function oi(e,t){return Object.keys(e).length===Object.keys(t).length&&si(e,t)}function si(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function ci(e,t){let n=e=>fi(e);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`&&e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3])}function li(e){return e.format===`toml`?Ur().backend===`native`:e.format===`json`||e.format===`yaml`}function ui(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function di(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function fi(e){return di(e,`# ok-mcp`)}function pi(e){return typeof e==`string`&&(e===Qr||e.startsWith(`${Qr}@`))}function mi(e){if(typeof e!=`object`||!e)return!1;let t=ui(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&fi(t[n+1])?!0:t.some(pi)}function hi(e){if(typeof e!=`object`||!e)return!1;let t=ui(e);if(t[0]!==qr||t[2]!==`mcp`)return!1;try{return t[1]===ri()}catch{return!1}}const gi=[`command`,`args`,`env`],_i=[`type`,`command`,`environment`];function vi(e){return e.type===`local`&&Array.isArray(e.command)?_i:gi}function yi(e,t){if(typeof e!=`object`||!e)return[];let n=e;return vi(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function bi(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function xi(e,t){return yi(e,t).length>0}function Si(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:ci(t.args,t.command)}function Ci(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&ci(r,n)}function Z(e){return e===`win32`?Fe:Pe}function wi(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=e.env??process.env,i=Z(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA||i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME||i.join(n,`.config`)}function Ti(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.claude.json`)}function Ei(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=e.env??process.env;if(t===`darwin`)return Pe.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Fe.join(n,`AppData`,`Roaming`);return Fe.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Di(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.cursor`,`mcp.json`)}function Oi(e={}){let t=e.platformName??process.platform,n=e.home??R();return(e.env??process.env).CODEX_HOME??Z(t).join(n,`.codex`)}function ki(e={}){return Z(e.platformName??process.platform).join(Oi(e),`config.toml`)}function Ai(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=(e.env??process.env).COPILOT_HOME??Z(t).join(n,`.copilot`);return Z(t).join(r,`mcp-config.json`)}function ji(e={}){let t=e.platformName??process.platform,n=e.home??R(),r=e.env??process.env,i=Z(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function Mi(e={}){return Z(e.platformName??process.platform).join(ji(e),`opencode.json`)}function Ni(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.openclaw`,`openclaw.json`)}function Pi(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.hermes`,`config.yaml`)}function Fi(e={}){let t=e.platformName??process.platform,n=e.home??R();return(e.env??process.env).PI_CODING_AGENT_DIR??Z(t).join(n,`.pi`,`agent`)}function Ii(e={}){let t=e.platformName??process.platform,n=e.home??R();return Z(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Li(e,t){let n=Z(t);return[{file:n.join(e,`.lmstudio`,`mcp.json`),dir:n.join(e,`.lmstudio`)},{file:n.join(e,`.cache`,`lm-studio`,`mcp.json`),dir:n.join(e,`.cache`,`lm-studio`)}]}function Ri(e){try{return Be(e).length>0}catch{return!1}}function zi(e={}){let t=e.platformName??process.platform,[n,r]=Li(e.home??R(),t),i=[n,r].find(e=>I(e.file));return i?i.file:Ri(r.dir)?r.file:n.file}const Q={claude:{id:`claude`,label:Y.claude,configPath:(e,t)=>Ti({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.claude`),projectConfigPath:e=>j(e,`.mcp.json`),projectSkillPath:e=>j(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:Y[`claude-desktop`],configPath:(e,t)=>Ei({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(Ei({home:t}))},cursor:{id:`cursor`,label:Y.cursor,configPath:(e,t)=>Di({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(Di({home:t})),projectConfigPath:e=>j(e,`.cursor`,`mcp.json`),projectSkillPath:e=>j(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:Y.codex,configPath:(e,t)=>ki({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(ki({home:t})),projectConfigPath:e=>j(e,`.codex`,`config.toml`),projectSkillPath:e=>j(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:Y.copilot,configPath:(e,t)=>Ai({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(Ai({home:t})),projectSkillPath:e=>j(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:Y.opencode,configPath:(e,t)=>Mi({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>p,buildEntry:(e,t)=>ii(t),scope:`global`,detectPath:(e,t)=>A(Mi({home:t})),projectConfigPath:e=>j(e,`opencode.json`),projectSkillPath:e=>j(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:Y.openclaw,configPath:(e,t)=>Ni({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:Y.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>p,scope:`project`,detectPath:(e,t)=>Fi({home:t}),projectConfigPath:e=>j(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>j(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:Y.antigravity,configPath:(e,t)=>Ii({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:Y[`lm-studio`],configPath:(e,t)=>zi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>A(zi({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:Y.hermes,configPath:(e,t)=>Pi({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(t??R(),`.hermes`),offerOnlyWhenDetected:!0}};function Bi(e){let t=e.filter(e=>!Object.hasOwn(Q,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${Gr.join(`, `)}`);return e.map(e=>Q[e])}const Vi=`**/.ok/*`,Hi=`!**/${b}/`;function Ui(e){let t=[`.ok/`,`.okignore`];for(let n of Gr){let r=Q[n];r.projectConfigPath&&t.push(ia(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function Wi(e){let t=j(e,...l);if(!I(t))return[];try{let e=v(L(t,`utf-8`));if(!e)return[];let n=[];for(let[t,i]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of i.hosts){let i=r[e];i&&n.push(`${i}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function Gi(e,t){let n=Yi(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:$i(n)};let r=ea(e);if(r.kind!==`ok`)return r.result;let i=I(r.path)?L(r.path,`utf-8`):``,a=new Set(Wi(e)),o=[],s=a.size===0?i:i.split(`
318
318
  `).filter(e=>{let t=e.trim();return!a.has(t)||(o.push(t),!1)}).join(`
319
319
  `),c=ra(s),l=[],u=[];for(let e of t)na(c,e)?u.push(e):l.push(e);if(l.length===0&&o.length===0)return{kind:`updated`,appended:l,alreadyPresent:u,removed:[]};let d=l.length===0||s.length===0||s.endsWith(`
320
320
  `)?``:`
321
321
  `,f=l.length===0?``:`${l.join(`
322
322
  `)}\n`;try{Ge(r.path,`${s}${d}${f}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:l,alreadyPresent:u,removed:o}}function Ki(e,t){let n=ea(e);if(n.kind!==`ok`)return n.result;if(!I(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>ta(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(Vi),i.add(Hi);for(let t of Wi(e))i.add(t);let a;try{a=L(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let o=a.split(`
323
323
  `),s=new Set,c=[];for(let e of o){let t=e.trim();if(i.has(t)){s.add(t);continue}c.push(e)}let l=[...s];if(s.size===0)return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let u=c.join(`
324
- `);if(u!==a)try{Ge(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function qi(e){let t=ea(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!I(t.path))return`shared`;let n;try{n=L(t.path,`utf-8`)}catch{return`shared`}let r=ra(n),i=Ui(e);for(let e of i)if(na(r,e))return`local-only`;return r.has(Vi)?`local-only`:`shared`}function Ji(e){let t=ea(e);if(t.kind!==`ok`||!I(t.path))return[];let n;try{n=L(t.path,`utf-8`)}catch{return[]}let r=ra(n),i=[...Ui(e),...Wi(e)].filter(e=>na(r,e)),a=new Set(i),o=[];for(let e of Object.values(c))e!==null&&o.push(e);let s=[];for(let e of r){if(a.has(e))continue;if(e===Vi||e===Hi){s.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);o.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&s.push(e)}return[...i,...s]}function Yi(e,t){let n=[];for(let r of t){let t=N(e,r);if(I(t))try{Ae(`git`,[`ls-files`,`--error-unmatch`,...m([r])],ye({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}const Xi=/^[\w.\-/]+$/;function Zi(e){return process.platform===`win32`?`"${e.replaceAll(`"`,``)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`}function Qi(e){return Xi.test(e)?e:Zi(y(e))}function $i(e){let t=[];t.push(`Cannot switch OpenKnowledge to local-only — these OK files are tracked upstream:`),t.push(``);for(let n of e)t.push(` ${n}`);t.push(``),t.push(`.git/info/exclude only hides files that git isn't already tracking. To proceed, untrack them first:`),t.push(``);for(let n of e){let e=n.replace(/\/$/,``),r=n.endsWith(`/`)?`-r `:``;t.push(` git rm --cached ${r}-- ${Qi(e)}`)}return t.push(``),t.push("Then re-run the command. Note: `git rm --cached` removes the files from the index — your teammates will see a deletion on their next pull. If you don't want that, leave sharing mode set to 'shared'."),t.join(`
324
+ `);if(u!==a)try{Ge(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function qi(e){let t=ea(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!I(t.path))return`shared`;let n;try{n=L(t.path,`utf-8`)}catch{return`shared`}let r=ra(n),i=Ui(e);for(let e of i)if(na(r,e))return`local-only`;return r.has(Vi)?`local-only`:`shared`}function Ji(e){let t=ea(e);if(t.kind!==`ok`||!I(t.path))return[];let n;try{n=L(t.path,`utf-8`)}catch{return[]}let i=ra(n),a=[...Ui(e),...Wi(e)].filter(e=>na(i,e)),o=new Set(a),s=[];for(let e of Object.values(r))e!==null&&s.push(e);let c=[];for(let e of i){if(o.has(e))continue;if(e===Vi||e===Hi){c.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);s.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&c.push(e)}return[...a,...c]}function Yi(e,t){let n=[];for(let r of t){let t=N(e,r);if(I(t))try{Ae(`git`,[`ls-files`,`--error-unmatch`,...h([r])],ye({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}const Xi=/^[\w.\-/]+$/;function Zi(e){return process.platform===`win32`?`"${e.replaceAll(`"`,``)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`}function Qi(e){return Xi.test(e)?e:Zi(y(e))}function $i(e){let t=[];t.push(`Cannot switch OpenKnowledge to local-only — these OK files are tracked upstream:`),t.push(``);for(let n of e)t.push(` ${n}`);t.push(``),t.push(`.git/info/exclude only hides files that git isn't already tracking. To proceed, untrack them first:`),t.push(``);for(let n of e){let e=n.replace(/\/$/,``),r=n.endsWith(`/`)?`-r `:``;t.push(` git rm --cached ${r}-- ${Qi(e)}`)}return t.push(``),t.push("Then re-run the command. Note: `git rm --cached` removes the files from the index — your teammates will see a deletion on their next pull. If you don't want that, leave sharing mode set to 'shared'."),t.join(`
325
325
  `)}function ea(e){let t=se(e);switch(t.kind){case`repository`:{let e=t.repository.readCommonDir();if(e.kind===`unreadable`)return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}};let n=j(e.path,`info`);return I(n)?{kind:`ok`,path:j(n,`exclude`)}:{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-info-dir`}}}case`absent`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-git`}};case`malformed-pointer`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`malformed-pointer`}};case`inaccessible`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}}}}function ta(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function na(e,t){for(let n of ta(t))if(e.has(n))return!0;return!1}function ra(e){let t=new Set;for(let n of e.split(`
326
- `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function ia(e,t){return aa(M(t,e))}function aa(e){return P===`/`?e:e.split(P).join(`/`)}function oa(e,t){let n;try{n=Re(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);ca(e,t)}function sa(e,t){ca(e,t)}function ca(e,t){la(e,t)}function la(e,t){let n=t,r;try{r=He(n)}catch{r=N(n)}let i=A(e);for(;i.length>1&&i!==P;){let t;try{t=He(i)}catch(e){if(e.code===`ENOENT`){i=A(i);continue}throw e}let n=M(r,t);if(n===``||!n.startsWith(`..`)&&!Ne(n))return;throw Error(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function ua(e,t){let n=A(t),r=I(t)?`overwritten`:`written`;if(r===`written`&&I(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return Ue(n,{recursive:!0,force:!0}),ze(A(n),{recursive:!0}),Le(e,n,{recursive:!0}),r}function da(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fa(e,t,n){try{if(We(n).size>10485760)return!1}catch{return!1}let r;try{r=L(n,`utf-8`)}catch{return!1}let i=[],a=we(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!da(a))return!1;let o=a[e.topLevelKey];if(!da(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!da(s))return!1;let c=s[e.serverName(t)];return da(c)&&c.enabled===!1?!1:mi(c)||hi(c)}function pa(e){let t=s[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:d(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:Q[n.editor]??null}function ma(e,t,n={}){if(!a.includes(e.id))return!0;let r=pa(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&fa(r,t,i))return!0;try{return fa(e,t,e.configPath(t,n.home))}catch{return!1}}function ha(e){let t=new Set(h.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function ga(e,t){if(ha(t).length===0)return null;let n=j(e,g,l,`SKILL.md`);try{let t=re(`project`,{checkDesktop:!0});return oa(A(n),e),{editorId:`agents`,label:`.agents hub`,action:ua(t,n),path:n}}catch(e){return{editorId:`agents`,label:`.agents hub`,action:`failed`,path:n,error:e instanceof Error?e.message:String(e)}}}function _a(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!ma(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=re(`project`,{checkDesktop:!0});oa(A(r),t);let i=ua(n,r);return{editorId:e.id,label:e.label,action:i,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function va(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=A(n);return I(n)?(sa(r,t),Ue(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function ya(e){switch(e?.code){case`EACCES`:case`EPERM`:return`permission-denied`;case`ELOOP`:return`unresolved-symlink`;case`EISDIR`:case`ENOTDIR`:return`not-a-file`;case`ENOENT`:return`disappeared`;default:return`unreadable`}}function ba(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions, then retry`;case`missing-symlink-target`:return`the symlink target is missing; restore the target or correct the symlink, then retry`;case`unresolved-symlink`:return`the path or symlink could not be resolved; check path permissions and repair any symlink cycle, then retry`;case`not-a-file`:return`the path is not a regular file; restore the intended configuration file, then retry`;case`disappeared`:return`the file disappeared; retry to check its current state`;case`unreadable`:return`the file could not be read; check that the path is accessible, then retry`;default:throw Error(`unhandled configuration file decline reason: ${e}`)}}function xa(e){for(let t of e.split(`
326
+ `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function ia(e,t){return aa(M(t,e))}function aa(e){return P===`/`?e:e.split(P).join(`/`)}function oa(e,t){let n;try{n=Re(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);ca(e,t)}function sa(e,t){ca(e,t)}function ca(e,t){la(e,t)}function la(e,t){let n=t,r;try{r=He(n)}catch{r=N(n)}let i=A(e);for(;i.length>1&&i!==P;){let t;try{t=He(i)}catch(e){if(e.code===`ENOENT`){i=A(i);continue}throw e}let n=M(r,t);if(n===``||!n.startsWith(`..`)&&!Ne(n))return;throw Error(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function ua(e,t){let n=A(t),r=I(t)?`overwritten`:`written`;if(r===`written`&&I(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return Ue(n,{recursive:!0,force:!0}),ze(A(n),{recursive:!0}),Le(e,n,{recursive:!0}),r}function da(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fa(e,t,n){try{if(We(n).size>10485760)return!1}catch{return!1}let r;try{r=L(n,`utf-8`)}catch{return!1}let i=[],a=we(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!da(a))return!1;let o=a[e.topLevelKey];if(!da(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!da(s))return!1;let c=s[e.serverName(t)];return da(c)&&c.enabled===!1?!1:mi(c)||hi(c)}function pa(e){let t=d[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:i(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:Q[n.editor]??null}function ma(e,t,n={}){if(!s.includes(e.id))return!0;let r=pa(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&fa(r,t,i))return!0;try{return fa(e,t,e.configPath(t,n.home))}catch{return!1}}function ha(e){let t=new Set(u.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function ga(e,t){if(ha(t).length===0)return null;let n=j(e,g,o,`SKILL.md`);try{let t=re(`project`,{checkDesktop:!0});return oa(A(n),e),{editorId:`agents`,label:`.agents hub`,action:ua(t,n),path:n}}catch(e){return{editorId:`agents`,label:`.agents hub`,action:`failed`,path:n,error:e instanceof Error?e.message:String(e)}}}function _a(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!ma(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=re(`project`,{checkDesktop:!0});oa(A(r),t);let i=ua(n,r);return{editorId:e.id,label:e.label,action:i,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function va(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=A(n);return I(n)?(sa(r,t),Ue(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function ya(e){switch(e?.code){case`EACCES`:case`EPERM`:return`permission-denied`;case`ELOOP`:return`unresolved-symlink`;case`EISDIR`:case`ENOTDIR`:return`not-a-file`;case`ENOENT`:return`disappeared`;default:return`unreadable`}}function ba(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions, then retry`;case`missing-symlink-target`:return`the symlink target is missing; restore the target or correct the symlink, then retry`;case`unresolved-symlink`:return`the path or symlink could not be resolved; check path permissions and repair any symlink cycle, then retry`;case`not-a-file`:return`the path is not a regular file; restore the intended configuration file, then retry`;case`disappeared`:return`the file disappeared; retry to check its current state`;case`unreadable`:return`the file could not be read; check that the path is accessible, then retry`;default:throw Error(`unhandled configuration file decline reason: ${e}`)}}function xa(e){for(let t of e.split(`
327
327
  `)){let e=t.trimStart();if(e.length!==0&&e.length!==t.length)return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function Sa(e){let t=(e.match(/\r\n/g)??[]).length;return t!==0&&t>=(e.match(/\n/g)??[]).length-t}function Ca(e){try{return We(e).mode&511}catch{return}}function wa(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
328
328
  `)?`\r
329
329
  `:`
@@ -687,7 +687,7 @@ export default function okBridge(pi: {
687
687
  `)||(m=`${m}\n`):m=m.replace(/\n+$/,``),h&&(m=m.replace(/\r\n/g,`
688
688
  `).replace(/\n/g,`\r
689
689
  `));let g=`${s?``:``}${m}`;return g!==o&&x(e,g,{mode:Ca(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const _o=e=>e!==`project`,vo=e=>e!==`user`;async function yo(){let e=await Ma({message:`Where should the MCP server be configured?
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 bo(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??yo)():`both`}async function xo(e){return La({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 `ok config-sharing share`."}]})}async function So(e){if(e.sharing!==void 0)return e.sharing;let t=qi(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??xo)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Co(e){if(e===void 0||e===!0)return new Set(be);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(Ce.filter(e=>t.includes(e)))}function wo(e,t,n){let r=N(n,e),i;try{i=We(r)}catch(e){let t=e.code;throw t===`ENOENT`?new $(`--content-dir path does not exist: ${r}`):new $(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new $(`--content-dir must be a directory: ${r}`);let a=To(t),o=To(r),s=M(a,o);if(s.startsWith(`..`)||Ne(s))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function To(e){try{return He(e)}catch{return e}}const Eo=`open-knowledge-ui`;function Do(e,t,n){try{let r=e.detectPath?.(t,n)??A(e.configPath(t,n));return I(r)}catch{return!1}}function Oo(e,t,n){try{let r=N(A(e.configPath(t,n))),i=N(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+P)}catch{return!1}}function ko(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`||!I(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||Oo(e,t,r);if(!i&&c&&!Do(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{oa(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 jo(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||ze(A(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{ae(`${o}.lock`,()=>{let t=Xa(o).writePath;if(s||ze(A(t),{recursive:!0}),e.format===`toml`){let r=po(Ur(),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=go(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=fo(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 Ao={pi:Ha};function jo(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=Ao[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{ze(A(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{ae(`${t}.lock`,()=>{let e=null;try{e=L(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}x(t,c,e===null?void 0:{mode:Ca(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 Mo(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!I(n)))return{editorId:e.id,label:e.label,path:n}}async function No(e){let t=Bi(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>ko(t,``,n,e.home))}function Po(e,t,n,r){let i=Io(e,t,n,r);return i.kind===`present`?i.entry:null}function Fo(e,t,n,r){let i=uo(e,t,r);if(!k(i))return{kind:`no-entry`};let a=i[n];return k(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Io(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!I(i))return{kind:`absent`};try{if(We(i).size>io)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:ya(e)}}let a;try{a=L(i,`utf-8`)}catch(e){return{kind:`decline`,reason:ya(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Va(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Ur().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Fo(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Ar.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Fo(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=$a(a);return s?eo(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Fo(Te(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Lo(e={}){let t=N(e.cwd??process.cwd()),n=Ga(t,{homeDir:e.home}),r=n.projectRoot;if(oe(r,e.home??R()))throw new fe(r);let i=!I(j(r,`.ok`)),a=n.gitRootPromoted?M(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:wo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${D(`[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 \`ok init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},c=await ue(r),l;try{l=he(r,{contentDir:o})}catch(t){let i=Q.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:c.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 u=l.created.includes(De),d=!1;if(c.didInit)try{d=xe(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{ee(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 f=await bo({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??Uo(r,e.home),h=e.editors??m,g=Bi(m),_=Bi(h),v=e.mcp===!1||f===null,y=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),b=g.filter(t=>Do(t,r,e.home)),x=[],te=[],re=new Set;for(let t of y){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}x.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(_o(f)&&g.includes(t)&&t.scope===`global`&&x.push(ko(t,r,s,e.home)),vo(f)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=ko(t,r,s,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&re.add(n)}}let ie=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||ie.has(n)||(ie.add(n),te.push(_a(t,r,{home:e.home})))}let ae=ga(r,_.map(e=>e.id));ae&&te.push(ae);let se=te.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(se.length>0){let t=e.home??R();le({source:p,skills:[ve.project],agents:se,scope:r},{home:t,enabled:ge(t).enabled})}let ce=!v&&f!==null&&vo(f)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,de=v?[]:b.map(e=>Mo(e,r)).filter(e=>e!==void 0).filter(e=>!re.has(e.path)),pe=e.installUserSkill??S,C=e.home??R(),_e=Co(e.skills),ye=!1,be=!1,Se=!1,we=!1,Te=!1;for(let t of Ce){if(!_e.has(t))continue;await me(C,ve[t],!0).catch(()=>{}),ye=!0;let n=await pe({home:e.home,bundleId:t,force:!0});n===`installed`?be=!0:n===`failed`?Se=!0:n===`no-hosts`?Te=!0:we=!0}let w=Se?`failed`:be?`installed`:ye&&we?`skip-current`:ye&&Te?`no-hosts`:`declined`,T=be?ne(C).map(e=>e.editorId):[],E=v?`skipped-flag`:`skipped-missing`,Ee=x.find(e=>e.editorId===`claude`)??x[0]??{action:E,configPath:Q.claude.configPath(r,e.home)},O=await Ro({projectRoot:r,desiredMode:await So({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:l.created,contentUpdated:l.updated,contentSkipped:l.skipped,editors:x,projectSkills:te,legacyProjectConfigs:de,skillInstall:w,skillHosts:T,didGitInit:c.didInit,rootGitignoreCreated:d,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:u?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Ee.action,mcpPath:Ee.configPath,mcpError:`error`in Ee?Ee.error:void 0,projectScopeUnsupportedLabels:ce,sharing:O}}async function Ro(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=qi(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=Ui(t);if(n===`local-only`){let e=Gi(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`}:zo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Ki(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:zo(t,o,`remove`)}function zo(e,t,n){let r=qi(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 Bo(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 Vo(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let s=j(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(O(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(O(`Content already present at ${s}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(O(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(O(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(O(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?M(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`open-knowledge`?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${E(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${E(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${Ee(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Bo(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(O(`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?M(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${E(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${E(`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} ${Ee(`FAILED`)}: ${r.error}`)}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${M(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(O(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>Y[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${E(`installed for ${r}`)}`),n.push(` ${T(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${T(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${E(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${T(`skipped for this run (--no-skills)`)}`),n.push(` ${T(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${T(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${T(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${T(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${D(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${D(` ok repair-skills`)}`)}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(D(`⚠ --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(D(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(Oe(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...Ko(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${E(`✓`)} ${O(`Next steps:`)}`),n.push(` 1. Open your editor (${w(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${w(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${w(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
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 bo(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??yo)():`both`}async function xo(e){return La({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 `ok config-sharing share`."}]})}async function So(e){if(e.sharing!==void 0)return e.sharing;let t=qi(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??xo)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Co(e){if(e===void 0||e===!0)return new Set(be);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(Ce.filter(e=>t.includes(e)))}function wo(e,t,n){let r=N(n,e),i;try{i=We(r)}catch(e){let t=e.code;throw t===`ENOENT`?new $(`--content-dir path does not exist: ${r}`):new $(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new $(`--content-dir must be a directory: ${r}`);let a=To(t),o=To(r),s=M(a,o);if(s.startsWith(`..`)||Ne(s))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function To(e){try{return He(e)}catch{return e}}const Eo=`open-knowledge-ui`;function Do(e,t,n){try{let r=e.detectPath?.(t,n)??A(e.configPath(t,n));return I(r)}catch{return!1}}function Oo(e,t,n){try{let r=N(A(e.configPath(t,n))),i=N(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+P)}catch{return!1}}function ko(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`||!I(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||Oo(e,t,r);if(!i&&c&&!Do(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{oa(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 jo(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||ze(A(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{ae(`${o}.lock`,()=>{let t=Xa(o).writePath;if(s||ze(A(t),{recursive:!0}),e.format===`toml`){let r=po(Ur(),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=go(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=fo(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 Ao={pi:Ha};function jo(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=Ao[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{ze(A(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{ae(`${t}.lock`,()=>{let e=null;try{e=L(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}x(t,c,e===null?void 0:{mode:Ca(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 Mo(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!I(n)))return{editorId:e.id,label:e.label,path:n}}async function No(e){let t=Bi(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>ko(t,``,n,e.home))}function Po(e,t,n,r){let i=Io(e,t,n,r);return i.kind===`present`?i.entry:null}function Fo(e,t,n,r){let i=uo(e,t,r);if(!k(i))return{kind:`no-entry`};let a=i[n];return k(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Io(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!I(i))return{kind:`absent`};try{if(We(i).size>io)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:ya(e)}}let a;try{a=L(i,`utf-8`)}catch(e){return{kind:`decline`,reason:ya(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Va(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Ur().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Fo(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Ar.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Fo(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=$a(a);return s?eo(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Fo(Te(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Lo(e={}){let t=N(e.cwd??process.cwd()),n=Ga(t,{homeDir:e.home}),r=n.projectRoot;if(oe(r,e.home??R()))throw new fe(r);let i=!I(j(r,`.ok`)),a=n.gitRootPromoted?M(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:wo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${D(`[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 \`ok init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},c=await ue(r),l;try{l=he(r,{contentDir:o})}catch(t){let i=Q.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:c.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 u=l.created.includes(De),d=!1;if(c.didInit)try{d=xe(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{ee(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 f=await bo({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),p=e.editors??Uo(r,e.home),h=e.editors??p,g=Bi(p),_=Bi(h),v=e.mcp===!1||f===null,y=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),b=g.filter(t=>Do(t,r,e.home)),x=[],te=[],re=new Set;for(let t of y){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}x.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(_o(f)&&g.includes(t)&&t.scope===`global`&&x.push(ko(t,r,s,e.home)),vo(f)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=ko(t,r,s,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&re.add(n)}}let ie=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||ie.has(n)||(ie.add(n),te.push(_a(t,r,{home:e.home})))}let ae=ga(r,_.map(e=>e.id));ae&&te.push(ae);let se=te.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(se.length>0){let t=e.home??R();le({source:m,skills:[ve.project],agents:se,scope:r},{home:t,enabled:ge(t).enabled})}let ce=!v&&f!==null&&vo(f)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,de=v?[]:b.map(e=>Mo(e,r)).filter(e=>e!==void 0).filter(e=>!re.has(e.path)),pe=e.installUserSkill??S,C=e.home??R(),_e=Co(e.skills),ye=!1,be=!1,Se=!1,we=!1,Te=!1;for(let t of Ce){if(!_e.has(t))continue;await me(C,ve[t],!0).catch(()=>{}),ye=!0;let n=await pe({home:e.home,bundleId:t,force:!0});n===`installed`?be=!0:n===`failed`?Se=!0:n===`no-hosts`?Te=!0:we=!0}let w=Se?`failed`:be?`installed`:ye&&we?`skip-current`:ye&&Te?`no-hosts`:`declined`,T=be?ne(C).map(e=>e.editorId):[],E=v?`skipped-flag`:`skipped-missing`,Ee=x.find(e=>e.editorId===`claude`)??x[0]??{action:E,configPath:Q.claude.configPath(r,e.home)},O=await Ro({projectRoot:r,desiredMode:await So({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:l.created,contentUpdated:l.updated,contentSkipped:l.skipped,editors:x,projectSkills:te,legacyProjectConfigs:de,skillInstall:w,skillHosts:T,didGitInit:c.didInit,rootGitignoreCreated:d,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:u?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Ee.action,mcpPath:Ee.configPath,mcpError:`error`in Ee?Ee.error:void 0,projectScopeUnsupportedLabels:ce,sharing:O}}async function Ro(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=qi(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=Ui(t);if(n===`local-only`){let e=Gi(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`}:zo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Ki(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:zo(t,o,`remove`)}function zo(e,t,n){let r=qi(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 Bo(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 Vo(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let s=j(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(O(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(O(`Content already present at ${s}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(O(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(O(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(O(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?M(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`open-knowledge`?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${E(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${E(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${Ee(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Bo(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(O(`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?M(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${E(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${E(`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} ${Ee(`FAILED`)}: ${r.error}`)}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${M(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(O(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>Y[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${E(`installed for ${r}`)}`),n.push(` ${T(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${T(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${E(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${T(`skipped for this run (--no-skills)`)}`),n.push(` ${T(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${T(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${T(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${T(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${D(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${D(` ok repair-skills`)}`)}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(D(`⚠ --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(D(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(Oe(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...Ko(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${E(`✓`)} ${O(`Next steps:`)}`),n.push(` 1. Open your editor (${w(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${w(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${w(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
691
691
  `)}function Ho(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 Uo(e,t){let n=[];for(let r of Gr)r!==`claude-desktop`&&Do(Q[r],e,t)&&n.push(r);return n}function Wo(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Ke(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 Go(){return new ut(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new ft(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new ft(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new ft(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?Wo():null;try{let r;try{r=await Lo({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof $||e instanceof fe){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof te||e instanceof ie){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof _e){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-DI6GS-t_.mjs`),{resolveContentDir:s}=await import(`./dist-RMxvFZJz.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-C7X2VjIE.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(Ho(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Vo(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Ko(e,t){let n=[];switch(e.kind){case`applied`:return n.push(O(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${E(`local-only`)} — appended ${e.appended.length} path(s) to ${O(`${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(` ${E(`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(` ${E(`local-only`)} — already excluded; nothing to do.`):n.push(` ${E(`local-only`)}`):e.action===`removed`?n.push(` ${E(`shared`)} — removed OK paths from ${O(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${E(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(D(`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-ZtMmWylB.mjs`),{resolveContentDir:s}=await import(`./dist-BHzXo_n8.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-BpL5dC8j.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(Ho(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Vo(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Ko(e,t){let n=[];switch(e.kind){case`applied`:return n.push(O(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${E(`local-only`)} — appended ${e.appended.length} path(s) to ${O(`${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(` ${E(`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(` ${E(`local-only`)} — already excluded; nothing to do.`):n.push(` ${E(`local-only`)}`):e.action===`removed`?n.push(` ${E(`shared`)} — removed OK paths from ${O(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${E(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(D(`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 ${w(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(D(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${w(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${w(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(D(`Sharing mode unavailable: ${e.reason}.`));return n}}export{yi as $,wa as A,$i as B,Ga as C,ct as Ct,Ma as D,La as E,sa as F,qi as G,Wi as H,va as I,Y as J,Ki as K,ua as L,ya as M,la as N,Ca as O,oa as P,bi as Q,_a as R,Xa as S,ut as St,Ba as T,Ui as U,Ji as V,Yi as W,Kr as X,Q as Y,X as Z,Lo as _,Zt as _t,Ho as a,Z as at,No as b,H as bt,Vo as c,li as ct,Do as d,J as dt,xi as et,Po as f,Nr as ft,So as g,Hn as gt,wo as h,$n as ht,Ro as i,Ci as it,ba as j,Sa as k,Ko as l,Wr as lt,bo as m,Fr as mt,Eo as n,ni as nt,Io as o,wi as ot,Co as p,Mr as pt,Gr as q,Ao as r,ai as rt,Uo as s,Fi as st,$ as t,Si as tt,Go as u,Ur as ut,co as v,Jt as vt,Ha as w,ft as wt,Oo as x,xt,ko as y,qt as yt,Gi as z};
@@ -1 +1 @@
1
- import{Eo as e,So as t,yo as n}from"./dist-CkxNiJMy.mjs";import{A as r,M as i,O as a}from"./init-B-EmtfJH.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-CqBQ1wer.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:i(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}=r(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{Eo as e,So as t,yo as n}from"./dist-CYtBexjQ.mjs";import{A as r,M as i,O as a}from"./init-h7MX0AMg.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-CLOX9HOE.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:i(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}=r(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 +1 @@
1
- import{$c as e,as as t,cl as n,ku as r,tl as i,to as a,yl as o}from"./md-manager-BGnqyqi1-DANVan-c.mjs";import{Ao as s,Oo as c,b as l}from"./dist-CkxNiJMy.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-CzoY31nN.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=r();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 r=n??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,r),_=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=(t,n=!1)=>{let r=v(t);if(r.diagnostic!==void 0&&p.push(r.diagnostic),r.value===null)return{};let i=e({value:r.value,file:r.path,source:r.source,doc:r.doc});p.push(...i),u.push(t);let s=i.length>0?o(r.value):r.value;return n&&h.push(...a({value:s,file:r.path,source:r.source,doc:r.doc})),s},x=f(r,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,r)),w=t(_.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(i(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{$c as e,as as t,cl as n,ku as r,tl as i,to as a,yl as o}from"./md-manager-BGnqyqi1-Cs2lSNJk.mjs";import{Ao as s,Oo as c,b as l}from"./dist-CYtBexjQ.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-DXgziVS3.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=r();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 r=n??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,r),_=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=(t,n=!1)=>{let r=v(t);if(r.diagnostic!==void 0&&p.push(r.diagnostic),r.value===null)return{};let i=e({value:r.value,file:r.path,source:r.source,doc:r.doc});p.push(...i),u.push(t);let s=i.length>0?o(r.value):r.value;return n&&h.push(...a({value:s,file:r.path,source:r.source,doc:r.doc})),s},x=f(r,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,r)),w=t(_.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(i(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};
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-Dqt3JX6k.mjs";export{e as loadConfig};