@inkeep/open-knowledge 0.88.2 → 0.88.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +62 -62
- package/dist/constants-iKekN_P_.mjs +1 -0
- package/dist/{dist-DuYtMHVN.mjs → dist-CqRTItlw.mjs} +482 -482
- package/dist/{dist-Crqm_bf2.mjs → dist-DZ47D2ZS.mjs} +1 -1
- package/dist/index.mjs +224 -224
- package/dist/init-D3X4bUI7.mjs +1 -0
- package/dist/{init-C_lwDiAV.mjs → init-DcojktK8.mjs} +13 -13
- package/dist/{launch-json-removal-Bf0eLIOI.mjs → launch-json-removal-CZJIrfQI.mjs} +1 -1
- package/dist/loader-6aogCPbH.mjs +1 -0
- package/dist/{loader-BTHLXSrR.mjs → loader-BiwGF8bz.mjs} +1 -1
- package/dist/{md-manager-BGnqyqi1-B15iekH4.mjs → md-manager-BGnqyqi1-C2MED2uJ.mjs} +163 -163
- package/dist/{open-browser-Bo79lvT6.mjs → open-browser-Bc67k1xM.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-DI932-V9.mjs → preview-B6_6Xw8I.mjs} +1 -1
- package/dist/preview-C8jLntfA.mjs +1 -0
- package/dist/public/assets/{AccountSection-Bd2Z33D1.js → AccountSection-BN4Cw37c.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-YTzRnX5n.js → ActivityModeContent-DOQAQjfZ.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-Bu_WIuTC.js → AddPropertiesButton-Bl5CfmF_.js} +2 -2
- package/dist/public/assets/{AgentConnectionsSection-D1UZu8Ey.js → AgentConnectionsSection-DN4d1HNW.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-Les4ME8w.js → AgentDiffPane-CtSQuPtF.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-CumN8CdR.js → AttachmentsSection-C8Kht0A-.js} +1 -1
- package/dist/public/assets/{AuthModal-D_er5IFs.js → AuthModal-P5IZP2Eq.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-DAZHM79_.js → CodeMirrorPropInput-BzqkkbNX.js} +1 -1
- package/dist/public/assets/{ContentRulesSection-NFcap9gI.js → ContentRulesSection-cZPJ290U.js} +1 -1
- package/dist/public/assets/{DiffViewBoundary-UE7vW8Oe.js → DiffViewBoundary-BhsVUgGr.js} +1 -1
- package/dist/public/assets/{DocumentContext-Ctqn5fOP.js → DocumentContext-DY2SpfLc.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-Cyboe5y3.js → EditorModeToggle-DDWiImgF.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-Cz_mguf_.js → ExcalidrawDocEditor-CQfnUtWJ.js} +1 -1
- package/dist/public/assets/FeedbackForm-DqvCDmlT.js +1 -0
- package/dist/public/assets/{GraphPanel-CXHBO6Pi.js → GraphPanel-DkTlYTKG.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-ksqIv5xT.js → ImportSkillDialog-BRbHATtN.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-C09Nk7dH.js → LinkPreviewsSection-CaVr6XOD.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-zlALml2I.js → LintConfigEditor-DaWYe45j.js} +1 -1
- package/dist/public/assets/{LintingSection-CNSUoev6.js → LintingSection-D8iY3BeV.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-BtDc4gv6.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-BaL_kw3y.js → ManagedArtifactProperties-Ds7bk2Cg.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-BmucleIU.js → MermaidDocEditor-D5p_P15E.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-wic4VCgq.js → NetworkAccessSection-CdPfWL-6.js} +1 -1
- package/dist/public/assets/{ProjectTemplatesSection-ouBMlVOa.js → ProjectTemplatesSection-f4lSAHFv.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-Dbvapk3n.js → PropertyDisplayRow-CGtf6FxV.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-HlcnTsOX.js → PublishToGitHubDialog-C966LBq0.js} +1 -1
- package/dist/public/assets/{RegisteredAgentIcon-Coqfs_TZ.js → RegisteredAgentIcon-maJiImvv.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-DtDCNnTy.js → SchemaConfigEditor-DV-OqSmg.js} +1 -1
- package/dist/public/assets/{SearchSection-DNZzZ3Lc.js → SearchSection-B6rHqfp_.js} +1 -1
- package/dist/public/assets/{SessionsHost-D8Fu7-o1.js → SessionsHost-C80PQ9Ji.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-CBt0qUoM.js → SettingsDialogBody-DpdBlukg.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-Ca7s4WEZ.js → ShareReceiveMissDialog-bsQuI8F-.js} +1 -1
- package/dist/public/assets/{SkillCostValue-GMRpMoz9.js → SkillCostValue-h4MKJn9R.js} +1 -1
- package/dist/public/assets/{SkillForkDialog-CQyz0hoz.js → SkillForkDialog-VtCTRWYw.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-y5Yyw5Le.js → SkillInstallMenu-B14_Gl1G.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-8uW0jMLl.js → SkillOriginInline-BgrR-T50.js} +1 -1
- package/dist/public/assets/{SkillPluginBundleDialog-BI-aqYln.js → SkillPluginBundleDialog-C4GtanKU.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-Cvk3JPgJ.js → SkillToolbarControls-C7VMQV0g.js} +1 -1
- package/dist/public/assets/{SkillsManagerSection-BjQTCsHj.js → SkillsManagerSection-AnAwZ1DX.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-DB1DwUOw.js → SlidesToolbarControls-DZlISnZM.js} +1 -1
- package/dist/public/assets/{SourceEditor-C0-uXruR.js → SourceEditor-3mT49S9c.js} +1 -1
- package/dist/public/assets/{SpellingSettings-B0irQ8c8.js → SpellingSettings-D30VvdF4.js} +1 -1
- package/dist/public/assets/{SyncSection-BJqGpaaw.js → SyncSection--UJ18oO3.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-C0V8VEC5.js → SyncStatusBadge-a4kNafeZ.js} +1 -1
- package/dist/public/assets/{TemplateRow-DEd3Tkto.js → TemplateRow-DAMw2W8v.js} +1 -1
- package/dist/public/assets/{TerminalLaunchContext-Cf9DNV3V.js → TerminalLaunchContext-D0zWlhAb.js} +1 -1
- package/dist/public/assets/{TerminalPanel-DxeDkNhO.js → TerminalPanel-DD-D7eio.js} +1 -1
- package/dist/public/assets/{TerminalSection-LDCYSdvb.js → TerminalSection-RYIum5Rn.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-BKyoHFal.js → TerminalWindowApp-HOVOYe31.js} +1 -1
- package/dist/public/assets/{TextDocEditor-BBPKbbLY.js → TextDocEditor-Bnv8NUnt.js} +1 -1
- package/dist/public/assets/{ThemePluginSection-Ts6Qi5Kl.js → ThemePluginSection-C-7r58fl.js} +1 -1
- package/dist/public/assets/{ThreadView-CnA0FFby.js → ThreadView-B65BxjmT.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-BhAvElhq.js → TimelineDiffPane-DFsTESmd.js} +1 -1
- package/dist/public/assets/{agent-connections-eIAONhYw.js → agent-connections-BBFERALo.js} +1 -1
- package/dist/public/assets/{agent-registry-B5GJuQIb.js → agent-registry-DFOT0lVX.js} +1 -1
- package/dist/public/assets/{bridge-D8zLwSJL.js → bridge-D--JjETV.js} +1 -1
- package/dist/public/assets/{catalog-3ZWO8rRk.js → catalog-BWH8_QmX.js} +1 -1
- package/dist/public/assets/{client-version-DSS54kA-.js → client-version-BDuwu8nN.js} +1 -1
- package/dist/public/assets/{comment-chips-BDP5SsC2.js → comment-chips-CmVjOzx9.js} +1 -1
- package/dist/public/assets/{config-provider-DnOTG839.js → config-provider-B9LKWNeQ.js} +1 -1
- package/dist/public/assets/config-schema-DJX8I1Ej.js +1 -0
- package/dist/public/assets/{css-color-to-hex-BTwrxN_f.js → css-color-to-hex-CP6Q3H0q.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-BVhMS1FZ.js → doc-undo-manager-g1jPjDAZ.js} +1 -1
- package/dist/public/assets/{field-controls-BmamcfuR.js → field-controls-BQEIzg0e.js} +1 -1
- package/dist/public/assets/field-controls-UxpzH3V6.js +1 -0
- package/dist/public/assets/{ime-composition-BGkVl2cJ.js → ime-composition-CYUPSAhg.js} +1 -1
- package/dist/public/assets/{index-BxVo6I9E.js → index-DZ5ANdd4.js} +7 -7
- package/dist/public/assets/{lint-config-client-CBQpIZKK.js → lint-config-client-BrVeQOG-.js} +1 -1
- package/dist/public/assets/{lint-plugins-B_TXMLHi.js → lint-plugins-Dztmq1iU.js} +1 -1
- package/dist/public/assets/{markdown-lint-DRIU7cWm.js → markdown-lint-C8vEJEsc.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-Bq2a8pIJ.js → markdownlint-rule-browser-Bobt53lD.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-BCGe6Xfo.js → pending-receive-nav-store-BG9-tW7s.js} +1 -1
- package/dist/public/assets/{preferred-session-events-DnP4zC3r.js → preferred-session-events-CiOjVspY.js} +1 -1
- package/dist/public/assets/{progress-DbMpcFHn.js → progress-HDmUIvkS.js} +1 -1
- package/dist/public/assets/{saved-themes-client-BJyf6Xyq.js → saved-themes-client-CqJpWEsN.js} +1 -1
- package/dist/public/assets/{schema-section-Kq5cLLZ1.js → schema-section-DMJAJ2yT.js} +1 -1
- package/dist/public/assets/schemas-api-BVrasm34.js +112 -0
- package/dist/public/assets/{selection-context-u10gJxcX.js → selection-context-CXsG3XPe.js} +1 -1
- package/dist/public/assets/{skills-api-J_HhXiVW.js → skills-api-UsV4esNc.js} +1 -1
- package/dist/public/assets/{src-fK2Sw-1_.js → src-Dx3dqWI2.js} +1 -1
- package/dist/public/assets/storage-scope-BLQBiE_R.js +1 -0
- package/dist/public/assets/{tag-pill-input-Pho2DfA3.js → tag-pill-input-DblQVbzJ.js} +1 -1
- package/dist/public/assets/{telemetry-impl-BlgkXIxZ.js → telemetry-impl-Yh79UJVk.js} +1 -1
- package/dist/public/assets/{telemetry-startup-CkECIh_r.js → telemetry-startup-DCztiQrG.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-CuBvrguH.js → terminal-launch-events-Br7k8Gq4.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-QXEikW5S.js → typing-burst-detector-Cua3oA5j.js} +1 -1
- package/dist/public/assets/{use-activity-panel-Dn46P0mY.js → use-activity-panel-WNt6B2Wq.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-UxYGcH5_.js → use-apply-config-color-theme-8k1Gcfxa.js} +1 -1
- package/dist/public/assets/{use-conflicts-YCXnAde0.js → use-conflicts-COX94NQZ.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-TUL8x9zo.js → use-live-xterm-theme-dvvmL2-x.js} +1 -1
- package/dist/public/assets/{use-open-skill-2zKffhZc.js → use-open-skill-g8pBIBzf.js} +1 -1
- package/dist/public/assets/{use-semantic-search-status-Df9VvQzo.js → use-semantic-search-status-BzadL1_f.js} +1 -1
- package/dist/public/assets/{use-skill-origin-BtzerRt3.js → use-skill-origin-DSpPNIP8.js} +1 -1
- package/dist/public/assets/{use-skill-targets-BOXqbEpE.js → use-skill-targets-CHzDmIG8.js} +1 -1
- package/dist/public/assets/{use-skills-CdZMRawk.js → use-skills-DtKZux5S.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-CAte7icy.js → use-terminal-enabled-D1gCuuSr.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-BOTSSNkz.js → use-timeline-entry-diff-BjRr2sCn.js} +1 -1
- package/dist/public/assets/{use-workspace-D0H3LThj.js → use-workspace-C7oiH0Lx.js} +1 -1
- package/dist/public/index.html +47 -47
- package/dist/{registry-probes-COWMU8kF.mjs → registry-probes-BB52WJE5.mjs} +3 -3
- package/dist/{removal-file-path-DwVXimeA.mjs → removal-file-path-CGfVL-G_.mjs} +1 -1
- package/dist/{repair-launch-json-CHJQ6iHo.mjs → repair-launch-json-C6Z8Lt66.mjs} +1 -1
- package/dist/{repair-mcp-configs-B3eA7NCU.mjs → repair-mcp-configs-Ho22omwW.mjs} +1 -1
- package/dist/src-BC52Vdpm.mjs +1 -0
- package/dist/src-DbQpB5ed.mjs +16 -0
- package/dist/start-B4pN-Gox.mjs +1 -0
- package/dist/{start-D-q6LSX4.mjs → start-DW9nXQC_.mjs} +3 -3
- package/package.json +4 -4
- package/dist/constants-Bt01xRhJ.mjs +0 -1
- package/dist/init-BEaSgrXN.mjs +0 -1
- package/dist/loader-DgSsisKy.mjs +0 -1
- package/dist/preview-7cPyYO2g.mjs +0 -1
- package/dist/public/assets/FeedbackForm-qz_rYN8n.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-DQ_wf9t-.js +0 -1
- package/dist/public/assets/config-schema-mRzIAFKz.js +0 -1
- package/dist/public/assets/field-controls-PGacnR0J.js +0 -1
- package/dist/public/assets/schemas-api-SZDu_YyA.js +0 -112
- package/dist/public/assets/storage-scope-BvRo-u56.js +0 -1
- package/dist/src-B3KfWFLo.mjs +0 -16
- package/dist/src-CQombtdS.mjs +0 -1
- package/dist/start-BpLazRHf.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./dist-CqRTItlw.mjs";import{v as e}from"./init-DcojktK8.mjs";export{e as runInit};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$f as r,Ac as i,
|
|
1
|
+
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$f as r,Ac as i,Ad as a,Bf as o,Cf as s,Df as c,Gf as l,If as u,Jf as d,K as f,Kf as p,Lf as m,Mf as h,Nd as g,Of as _,Tf as v,V as y,Vf as b,Xa as x,Ya as S,_ as ee,a as C,ep as te,fd as ne,jf as re,ol as ie,qf as w,tt as ae,wf as oe,z as se,zf as ce}from"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import{B as le,Br as ue,Cs as de,Da as fe,Ea as pe,F as me,Kr as he,Nt as ge,Qr as _e,R as ve,W as ye,Wa as be,Wo as xe,Yo as Se,Zi as Ce,_i as we,at as Te,cs as Ee,ct as De,ei as Oe,hn as ke,hs as T,ja as Ae,ks as je,lr as Me,ls as Ne,m as Pe,mi as Fe,nr as Ie,os as Le,qo as Re,ss as E,us as ze,z as Be}from"./dist-CqRTItlw.mjs";import{i as Ve,n as D,o as O,r as He,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Ue}from"./constants-iKekN_P_.mjs";import{t as We}from"./preview-B6_6Xw8I.mjs";import{createRequire as Ge}from"node:module";import{execFileSync as Ke}from"node:child_process";import qe,{basename as Je,dirname as M,isAbsolute as Ye,join as N,posix as Xe,relative as P,resolve as F,sep as I,win32 as Ze}from"node:path";import L from"node:process";import{fileURLToPath as Qe}from"node:url";import{copyFileSync as $e,existsSync as R,lstatSync as et,mkdirSync as tt,readFileSync as z,readdirSync as nt,readlinkSync as rt,realpathSync as it,rmSync as at,statSync as ot,writeFileSync as st}from"node:fs";import{homedir as B}from"node:os";import{inspect as ct,stripVTControlCharacters as lt,styleText as V}from"node:util";import*as ut from"node:readline";import{AsyncLocalStorage as dt,AsyncResource as ft}from"node:async_hooks";var pt=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),mt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ht=n((e=>{let{humanReadableArgName:t}=mt();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
2
2
|
`)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
3
3
|
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
4
4
|
`)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),gt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
@@ -278,7 +278,7 @@ let Lr=/^[a-z0-9-_]+$/i;function Rr(e){let t=typeof e;if(t===`object`){if(Array.
|
|
|
278
278
|
`)+Gr(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=Vr(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(Rr(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Gr(0,e,``,t,n);return r[r.length-1]===`
|
|
280
280
|
`?r:r+`
|
|
281
|
-
`}var qr=
|
|
281
|
+
`}var qr=ne();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 Yr(e){return!e||typeof e!=`object`?String(e):`${typeof e} keys=[${Object.keys(e).join(`,`)}]`}function Xr(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}: ${Yr(t)}`:`${e}: ${n.reverse().slice(0,5).join(` -> `)}`}function Y(e,t){process.env.OK_DEBUG_NATIVE&&process.stderr.write(`[ok] native-config ${Xr(e,t)}\n`)}const Zr=[`native`,`index.js`];function Qr(e={},t=Y){let n=e.moduleUrl??import.meta.url,r=e.requireModule??Ge(n);try{let e=M(Qe(n));return r(N(e,...Zr))}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 $r(){let e=Qr();return e&&typeof e.parseTomlToJson==`function`?e:null}function ei(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return Y(`addon loaded but probe failed`,e),!1}}function ti(e){if(!j(e))throw Error(`TOML root is not a table`);return e}function ni(e){return{backend:`native`,parseToObject(t){return ti(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 ri(){return{backend:`fallback`,parseToObject(e){return ti(Ir(e))}}}function ii(e=$r){let t=e();return t&&ei(t)?ni(t):ri()}let ai=null;function oi(){return ai===null&&(ai=ii()),ai}function si(){let e=oi();return e.backend===`native`?e:void 0}const ci=s,X=oe,li=c,ui=`node`,di={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function fi(){let e=te();return e===`stable`?{...di}:{...di,[b]:e}}const pi=`@inkeep/open-knowledge`;function mi(e){return`${se(`unix-chain`,e.mcpChainTag)}2`}function hi(e){return`${se(`windows-chain`,e.mcpChainTag)}1`}function gi(e){let t=o[e],n=`${pi}@${t.npmDistTag}`,r=e===`stable`?``:`\nexport ${b}=${e}`;return`${mi(t)}${r}
|
|
282
282
|
USER_BUNDLE="$HOME/Applications/${t.productName}.app/Contents/Resources/cli/bin/ok.sh"
|
|
283
283
|
[ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
|
|
284
284
|
BUNDLE="/Applications/${t.productName}.app/Contents/Resources/cli/bin/ok.sh"
|
|
@@ -290,7 +290,7 @@ for d in "$HOME/.nvm/versions/node"/*/bin "$HOME/.fnm/node-versions"/*/installat
|
|
|
290
290
|
[ -f "$d/npx" ] && [ -x "$d/npx" ] && exec "$d/npx" -y ${n} mcp
|
|
291
291
|
done
|
|
292
292
|
echo "OpenKnowledge: install OK Desktop or Node.js 24+, then restart your editor" >&2
|
|
293
|
-
exit 127`}function _i(e){let t=
|
|
293
|
+
exit 127`}function _i(e){let t=o[e],n=`${pi}@${t.npmDistTag}`,r=`${t.cliCommandNames[0]}.cmd`,i=t.npmDistTag===`latest`?pi:n,a=e===`stable`?``:`\n$env:${b} = '${e}'`;return`${hi(t)}${a}
|
|
294
294
|
if ($env:PATHEXT -notmatch 'CMD') { $env:PATHEXT = '.COM;.EXE;.BAT;.CMD;' + $env:PATHEXT }
|
|
295
295
|
if ($env:APPDATA) {
|
|
296
296
|
$shim = Join-Path $env:APPDATA 'npm\\${r}'
|
|
@@ -314,26 +314,26 @@ foreach ($d in $dirs) {
|
|
|
314
314
|
if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '${n}' mcp; exit $LASTEXITCODE }
|
|
315
315
|
}
|
|
316
316
|
[Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g ${i}), then restart your editor')
|
|
317
|
-
exit 127`}const vi=`A dev build writes no MCP launcher for an installed OpenKnowledge channel, because that launcher runs a released CLI. Register this checkout by running \`${_} init --dev-mcp\` in the project, or set OK_CHANNEL=stable.`;function yi(){let e=r();if(e===`dev`)throw Error(vi);return e}mi(w.stable),gi(`stable`),hi(w.stable),_i(`stable`);function bi(e){return`// ok-pi-bridge${e.mcpChainTag}`}function xi(e){return`${bi(e)}-v1`}function Si(e){return`${bi(e)}-dev`}bi(w.stable),xi(w.stable);function Ci(e){if(typeof e!=`object`||!e)return!1;let t=d(),n=e;if(n.command===`/bin/sh`){if(!Array.isArray(n.args)||n.args[0]!==`-l`||n.args[1]!==`-c`)return!1;let e=n.args[2];return Mi(e,mi(t))}if(n.command===`powershell`){if(!Array.isArray(n.args)||n.args[0]!==`-NoProfile`||n.args[1]!==`-NonInteractive`||n.args[2]!==`-Command`)return!1;let e=n.args[3];return Mi(e,hi(t))}if(n.type===`local`&&Array.isArray(n.command)){if(n.command[0]===`/bin/sh`){if(n.command[1]!==`-l`||n.command[2]!==`-c`)return!1;let e=n.command[3];return Mi(e,mi(t))}if(n.command[0]===`powershell`){if(n.command[1]!==`-NoProfile`||n.command[2]!==`-NonInteractive`||n.command[3]!==`-Command`)return!1;let e=n.command[4];return Mi(e,hi(t))}return!1}if(n.command===`ok-pi-managed-extension`){if(!Array.isArray(n.args))return!1;let e=n.args[0];return typeof e==`string`&&e.startsWith(xi(t))}return!1}function wi(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=F(e);if(Je(t)===`cli.mjs`&&Je(M(t))===`dist`)return t;let n=t.split(I),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?I:i.join(I);return N(a,`packages`,`cli`,`dist`,`cli.mjs`)}function Z(e={}){return e.mode===`dev`?{command:ui,args:[wi(),`mcp`],env:fi()}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,_i(yi())]}:{command:`/bin/sh`,args:[`-l`,`-c`,gi(yi())]}}function Ti(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[ui,wi(),`mcp`],environment:fi()}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,_i(yi())]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,gi(yi())]}}function Ei(e){if(typeof e!=`object`||!e||g())return!1;let t=e;return Di(t,Z({mode:`published`,platformName:`darwin`}))||Di(t,Z({mode:`published`,platformName:`win32`}))}function Di(e,t){return Object.keys(e).length===Object.keys(t).length&&Oi(e,t)}function Oi(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 ki(e,t){let n=e=>Ni(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 Ai(e){return e.format===`toml`?oi().backend===`native`:e.format===`json`||e.format===`yaml`}function ji(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function Mi(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function Ni(e){return Mi(e,`# ok-mcp`)}function Pi(e){return typeof e==`string`&&(e===pi||e.startsWith(`${pi}@`))}function Fi(e){if(typeof e!=`object`||!e)return!1;let t=ji(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&Ni(t[n+1])?!0:t.some(Pi)}function Ii(e){if(typeof e!=`object`||!e)return!1;let t=ji(e);if(t[0]!==ui||t[2]!==`mcp`)return!1;try{return t[1]===wi()}catch{return!1}}const Li=[`command`,`args`,`env`],Ri=[`type`,`command`,`environment`];function zi(e){return e.type===`local`&&Array.isArray(e.command)?Ri:Li}function Bi(e,t){if(t===null||typeof e!=`object`||!e)return[];let n=e;return zi(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function Vi(e,t){return e.format===`file`||g()?null:e.buildEntry(t,{})}function Hi(e,t){return Bi(e,t).length>0}function Ui(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:ki(t.args,t.command)}function Wi(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`&&ki(r,n)}function Q(e){return e===`win32`?Ze:Xe}function Gi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(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 Ki(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.claude.json`)}function qi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env;if(t===`darwin`)return Xe.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Ze.join(n,`AppData`,`Roaming`);return Ze.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Ji(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.cursor`,`mcp.json`)}function Yi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).CODEX_HOME??Q(t).join(n,`.codex`)}function Xi(e={}){return Q(e.platformName??process.platform).join(Yi(e),`config.toml`)}function Zi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=(e.env??process.env).COPILOT_HOME??Q(t).join(n,`.copilot`);return Q(t).join(r,`mcp-config.json`)}function Qi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(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 $i(e={}){return Q(e.platformName??process.platform).join(Qi(e),`opencode.json`)}function ea(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.openclaw`,`openclaw.json`)}function ta(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.hermes`,`config.yaml`)}function na(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).PI_CODING_AGENT_DIR??Q(t).join(n,`.pi`,`agent`)}function ra(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function ia(e,t){let n=Q(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 aa(e){try{return nt(e).length>0}catch{return!1}}function oa(e={}){let t=e.platformName??process.platform,[n,r]=ia(e.home??B(),t),i=[n,r].find(e=>R(e.file));return i?i.file:aa(r.dir)?r.file:n.file}const $={claude:{id:`claude`,label:X.claude,configPath:(e,t)=>Ki({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>m(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.claude`),projectConfigPath:e=>N(e,`.mcp.json`),projectSkillPath:e=>N(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:X[`claude-desktop`],configPath:(e,t)=>qi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>m(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(qi({home:t}))},cursor:{id:`cursor`,label:X.cursor,configPath:(e,t)=>Ji({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>m(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ji({home:t})),projectConfigPath:e=>N(e,`.cursor`,`mcp.json`),projectSkillPath:e=>N(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:X.codex,configPath:(e,t)=>Xi({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>m(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Xi({home:t})),projectConfigPath:e=>N(e,`.codex`,`config.toml`),projectSkillPath:e=>N(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:X.copilot,configPath:(e,t)=>Zi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>m(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Zi({home:t})),projectSkillPath:e=>N(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:X.opencode,configPath:(e,t)=>$i({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>m(),buildEntry:(e,t)=>Ti(t),scope:`global`,detectPath:(e,t)=>M($i({home:t})),projectConfigPath:e=>N(e,`opencode.json`),projectSkillPath:e=>N(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:X.openclaw,configPath:(e,t)=>ea({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>m(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:X.pi,configPath:()=>{throw Error(`Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at ${u(d())} (run \`${b()} init\` in the project).`)},format:`file`,topLevelKey:`mcpServers`,serverName:()=>m(),scope:`project`,detectPath:(e,t)=>na({home:t}),projectConfigPath:e=>N(e,u(d())),projectSkillPath:e=>N(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:X.antigravity,configPath:(e,t)=>ra({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>m(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:X[`lm-studio`],configPath:(e,t)=>oa({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>m(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(oa({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:X.hermes,configPath:(e,t)=>ta({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>m(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.hermes`),offerOnlyWhenDetected:!0}};function sa(e){let t=e.filter(e=>!Object.hasOwn($,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${ci.join(`, `)}`);return e.map(e=>$[e])}const ca=`**/.ok/*`,la=`!**/${i}/`;function ua(e){let t=[`.ok/`,`.okignore`];for(let n of ci){let r=$[n];r.projectConfigPath&&t.push(Ta(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function da(e){let t=N(e,...C);if(!R(t))return[];try{let e=y(z(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=se[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function fa(e,t){let n=ga(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:ba(n)};let r=xa(e);if(r.kind!==`ok`)return r.result;let i=R(r.path)?z(r.path,`utf-8`):``,a=new Set(da(e)),o=[],s=a.size===0?i:i.split(`
|
|
317
|
+
exit 127`}const vi=`A dev build writes no MCP launcher for an installed OpenKnowledge channel, because that launcher runs a released CLI. Register this checkout by running \`${ce} init --dev-mcp\` in the project, or set OK_CHANNEL=stable.`;function yi(){let e=te();if(e===`dev`)throw Error(vi);return e}mi(o.stable),gi(`stable`),hi(o.stable),_i(`stable`);function bi(e){return`// ok-pi-bridge${e.mcpChainTag}`}function xi(e){return`${bi(e)}-v1`}function Si(e){return`${bi(e)}-dev`}bi(o.stable),xi(o.stable);function Ci(e){if(typeof e!=`object`||!e)return!1;let t=p(),n=e;if(n.command===`/bin/sh`){if(!Array.isArray(n.args)||n.args[0]!==`-l`||n.args[1]!==`-c`)return!1;let e=n.args[2];return Mi(e,mi(t))}if(n.command===`powershell`){if(!Array.isArray(n.args)||n.args[0]!==`-NoProfile`||n.args[1]!==`-NonInteractive`||n.args[2]!==`-Command`)return!1;let e=n.args[3];return Mi(e,hi(t))}if(n.type===`local`&&Array.isArray(n.command)){if(n.command[0]===`/bin/sh`){if(n.command[1]!==`-l`||n.command[2]!==`-c`)return!1;let e=n.command[3];return Mi(e,mi(t))}if(n.command[0]===`powershell`){if(n.command[1]!==`-NoProfile`||n.command[2]!==`-NonInteractive`||n.command[3]!==`-Command`)return!1;let e=n.command[4];return Mi(e,hi(t))}return!1}if(n.command===`ok-pi-managed-extension`){if(!Array.isArray(n.args))return!1;let e=n.args[0];return typeof e==`string`&&e.startsWith(xi(t))}return!1}function wi(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=F(e);if(Je(t)===`cli.mjs`&&Je(M(t))===`dist`)return t;let n=t.split(I),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?I:i.join(I);return N(a,`packages`,`cli`,`dist`,`cli.mjs`)}function Z(e={}){return e.mode===`dev`?{command:ui,args:[wi(),`mcp`],env:fi()}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,_i(yi())]}:{command:`/bin/sh`,args:[`-l`,`-c`,gi(yi())]}}function Ti(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[ui,wi(),`mcp`],environment:fi()}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,_i(yi())]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,gi(yi())]}}function Ei(e){if(typeof e!=`object`||!e||r())return!1;let t=e;return Di(t,Z({mode:`published`,platformName:`darwin`}))||Di(t,Z({mode:`published`,platformName:`win32`}))}function Di(e,t){return Object.keys(e).length===Object.keys(t).length&&Oi(e,t)}function Oi(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 ki(e,t){let n=e=>Ni(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 Ai(e){return e.format===`toml`?oi().backend===`native`:e.format===`json`||e.format===`yaml`}function ji(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function Mi(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function Ni(e){return Mi(e,`# ok-mcp`)}function Pi(e){return typeof e==`string`&&(e===pi||e.startsWith(`${pi}@`))}function Fi(e){if(typeof e!=`object`||!e)return!1;let t=ji(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&Ni(t[n+1])?!0:t.some(Pi)}function Ii(e){if(typeof e!=`object`||!e)return!1;let t=ji(e);if(t[0]!==ui||t[2]!==`mcp`)return!1;try{return t[1]===wi()}catch{return!1}}const Li=[`command`,`args`,`env`],Ri=[`type`,`command`,`environment`];function zi(e){return e.type===`local`&&Array.isArray(e.command)?Ri:Li}function Bi(e,t){if(t===null||typeof e!=`object`||!e)return[];let n=e;return zi(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function Vi(e,t){return e.format===`file`||r()?null:e.buildEntry(t,{})}function Hi(e,t){return Bi(e,t).length>0}function Ui(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:ki(t.args,t.command)}function Wi(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`&&ki(r,n)}function Q(e){return e===`win32`?Ze:Xe}function Gi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(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 Ki(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.claude.json`)}function qi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env;if(t===`darwin`)return Xe.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Ze.join(n,`AppData`,`Roaming`);return Ze.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Ji(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.cursor`,`mcp.json`)}function Yi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).CODEX_HOME??Q(t).join(n,`.codex`)}function Xi(e={}){return Q(e.platformName??process.platform).join(Yi(e),`config.toml`)}function Zi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=(e.env??process.env).COPILOT_HOME??Q(t).join(n,`.copilot`);return Q(t).join(r,`mcp-config.json`)}function Qi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(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 $i(e={}){return Q(e.platformName??process.platform).join(Qi(e),`opencode.json`)}function ea(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.openclaw`,`openclaw.json`)}function ta(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.hermes`,`config.yaml`)}function na(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).PI_CODING_AGENT_DIR??Q(t).join(n,`.pi`,`agent`)}function ra(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function ia(e,t){let n=Q(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 aa(e){try{return nt(e).length>0}catch{return!1}}function oa(e={}){let t=e.platformName??process.platform,[n,r]=ia(e.home??B(),t),i=[n,r].find(e=>R(e.file));return i?i.file:aa(r.dir)?r.file:n.file}const $={claude:{id:`claude`,label:X.claude,configPath:(e,t)=>Ki({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.claude`),projectConfigPath:e=>N(e,`.mcp.json`),projectSkillPath:e=>N(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:X[`claude-desktop`],configPath:(e,t)=>qi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(qi({home:t}))},cursor:{id:`cursor`,label:X.cursor,configPath:(e,t)=>Ji({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ji({home:t})),projectConfigPath:e=>N(e,`.cursor`,`mcp.json`),projectSkillPath:e=>N(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:X.codex,configPath:(e,t)=>Xi({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Xi({home:t})),projectConfigPath:e=>N(e,`.codex`,`config.toml`),projectSkillPath:e=>N(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:X.copilot,configPath:(e,t)=>Zi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Zi({home:t})),projectSkillPath:e=>N(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:X.opencode,configPath:(e,t)=>$i({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>w(),buildEntry:(e,t)=>Ti(t),scope:`global`,detectPath:(e,t)=>M($i({home:t})),projectConfigPath:e=>N(e,`opencode.json`),projectSkillPath:e=>N(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:X.openclaw,configPath:(e,t)=>ea({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:X.pi,configPath:()=>{throw Error(`Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at ${u(p())} (run \`${l()} init\` in the project).`)},format:`file`,topLevelKey:`mcpServers`,serverName:()=>w(),scope:`project`,detectPath:(e,t)=>na({home:t}),projectConfigPath:e=>N(e,u(p())),projectSkillPath:e=>N(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:X.antigravity,configPath:(e,t)=>ra({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:X[`lm-studio`],configPath:(e,t)=>oa({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(oa({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:X.hermes,configPath:(e,t)=>ta({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.hermes`),offerOnlyWhenDetected:!0}};function sa(e){let t=e.filter(e=>!Object.hasOwn($,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${ci.join(`, `)}`);return e.map(e=>$[e])}const ca=`**/.ok/*`,la=`!**/${i}/`;function ua(e){let t=[`.ok/`,`.okignore`];for(let n of ci){let r=$[n];r.projectConfigPath&&t.push(Ta(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function da(e){let t=N(e,...C);if(!R(t))return[];try{let e=y(z(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=v[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function fa(e,t){let n=ga(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:ba(n)};let r=xa(e);if(r.kind!==`ok`)return r.result;let i=R(r.path)?z(r.path,`utf-8`):``,a=new Set(da(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=wa(s),l=[],u=[];for(let e of t)Ca(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{st(r.path,`${s}${d}${f}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:l,alreadyPresent:u,removed:o}}function pa(e,t){let n=xa(e);if(n.kind!==`ok`)return n.result;if(!R(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>Sa(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(ca),i.add(la);for(let t of da(e))i.add(t);let a;try{a=z(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{st(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function ma(e){let t=xa(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!R(t.path))return`shared`;let n;try{n=z(t.path,`utf-8`)}catch{return`shared`}let r=wa(n),i=ua(e);for(let e of i)if(Ca(r,e))return`local-only`;return r.has(ca)?`local-only`:`shared`}function ha(e){let t=xa(e);if(t.kind!==`ok`||!R(t.path))return[];let n;try{n=z(t.path,`utf-8`)}catch{return[]}let r=wa(n),i=[...ua(e),...da(e)].filter(e=>Ca(r,e)),a=new Set(i),o=[];for(let e of Object.values(
|
|
324
|
+
`);if(u!==a)try{st(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function ma(e){let t=xa(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!R(t.path))return`shared`;let n;try{n=z(t.path,`utf-8`)}catch{return`shared`}let r=wa(n),i=ua(e);for(let e of i)if(Ca(r,e))return`local-only`;return r.has(ca)?`local-only`:`shared`}function ha(e){let t=xa(e);if(t.kind!==`ok`||!R(t.path))return[];let n;try{n=z(t.path,`utf-8`)}catch{return[]}let r=wa(n),i=[...ua(e),...da(e)].filter(e=>Ca(r,e)),a=new Set(i),o=[];for(let e of Object.values(v))e!==null&&o.push(e);let s=[];for(let e of r){if(a.has(e))continue;if(e===ca||e===la){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 ga(e,t){let n=[];for(let r of t){let t=F(e,r);if(R(t))try{Ke(`git`,[`ls-files`,`--error-unmatch`,...f([r])],xe({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}const _a=/^[\w.\-/]+$/;function va(e){return process.platform===`win32`?`"${e.replaceAll(`"`,``)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`}function ya(e){return _a.test(e)?e:va(ae(e))}function ba(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}-- ${ya(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 xa(e){let t=je(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=N(e.path,`info`);return R(n)?{kind:`ok`,path:N(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 Sa(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function Ca(e,t){for(let n of Sa(t))if(e.has(n))return!0;return!1}function wa(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 Ta(e,t){return Ea(P(t,e))}function Ea(e){return I===`/`?e:e.split(I).join(`/`)}function Da(e,t){let n=M(t),r=R(t)?`overwritten`:`written`;if(r===`written`&&R(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 at(n,{recursive:!0,force:!0}),tt(M(n),{recursive:!0}),Oa(e,n),r}function Oa(e,t){tt(t,{recursive:!0});for(let n of nt(e,{withFileTypes:!0})){let r=N(e,n.name),i=N(t,n.name);n.isDirectory()?Oa(r,i):$e(r,i)}}var ka=class extends Error{name=`ProjectPathSafetyError`;code=`PROJECT_PATH_SAFETY`};function Aa(e,t){let n;try{n=et(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw new ka(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Ma(e,t)}function ja(e,t){Ma(e,t)}function Ma(e,t){Na(e,t)}function Na(e,t){let n=t,r;try{r=it(n)}catch{r=F(n)}let i=M(e);for(;i.length>1&&i!==I;){let t;try{t=it(i)}catch(e){if(e.code===`ENOENT`){i=M(i);continue}throw e}let n=P(r,t);if(n===``||!n.startsWith(`..`)&&!Ye(n))return;throw new ka(`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 Pa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fa(e,t,n){try{if(ot(n).size>10485760)return!1}catch{return!1}let r;try{r=z(n,`utf-8`)}catch{return!1}let i=[],a=Ne(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!Pa(a))return!1;let o=a[e.topLevelKey];if(!Pa(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!Pa(s))return!1;let c=s[e.serverName(t)];return Pa(c)&&c.enabled===!1?!1:Fi(c)||Ii(c)}function Ia(e){let t=
|
|
326
|
+
`)){let e=n.trim();e.length!==0&&t.add(e)}return t}function Ta(e,t){return Ea(P(t,e))}function Ea(e){return I===`/`?e:e.split(I).join(`/`)}function Da(e,t){let n=M(t),r=R(t)?`overwritten`:`written`;if(r===`written`&&R(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 at(n,{recursive:!0,force:!0}),tt(M(n),{recursive:!0}),Oa(e,n),r}function Oa(e,t){tt(t,{recursive:!0});for(let n of nt(e,{withFileTypes:!0})){let r=N(e,n.name),i=N(t,n.name);n.isDirectory()?Oa(r,i):$e(r,i)}}var ka=class extends Error{name=`ProjectPathSafetyError`;code=`PROJECT_PATH_SAFETY`};function Aa(e,t){let n;try{n=et(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw new ka(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Ma(e,t)}function ja(e,t){Ma(e,t)}function Ma(e,t){Na(e,t)}function Na(e,t){let n=t,r;try{r=it(n)}catch{r=F(n)}let i=M(e);for(;i.length>1&&i!==I;){let t;try{t=it(i)}catch(e){if(e.code===`ENOENT`){i=M(i);continue}throw e}let n=P(r,t);if(n===``||!n.startsWith(`..`)&&!Ye(n))return;throw new ka(`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 Pa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fa(e,t,n){try{if(ot(n).size>10485760)return!1}catch{return!1}let r;try{r=z(n,`utf-8`)}catch{return!1}let i=[],a=Ne(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!Pa(a))return!1;let o=a[e.topLevelKey];if(!Pa(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!Pa(s))return!1;let c=s[e.serverName(t)];return Pa(c)&&c.enabled===!1?!1:Fi(c)||Ii(c)}function Ia(e){let t=a[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:g(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:$[n.editor]??null}function La(e,t,n={}){if(!h.includes(e.id))return!0;let r=Ia(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 Ra(e){let t=new Set(_.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function za(e,t){if(Ra(t).length===0)return null;let n=N(e,S,re,`SKILL.md`);try{let t=Ae(`project`,{checkDesktop:!0});return Aa(M(n),e),{editorId:`agents`,label:`.agents hub`,action:Da(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 Ba(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!La(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=Ae(`project`,{checkDesktop:!0});Aa(M(r),t);let i=Da(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=M(n);return R(n)?(ja(r,t),at(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 Ha(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 Ua(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 Wa(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 Ga(e){let t=(e.match(/\r\n/g)??[]).length;return t!==0&&t>=(e.match(/\n/g)??[]).length-t}function Ka(e){try{return ot(e).mode&511}catch{return}}function qa(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
|
|
328
328
|
`)?`\r
|
|
329
329
|
`:`
|
|
330
330
|
`,a=Ee(r,t,void 0,{formattingOptions:{...Wa(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${Le(r,a)}`;return{text:o,changed:o!==e}}const Ja={icon:{checked:V(`green`,W.circleFilled),unchecked:W.circle,cursor:W.pointer,disabledChecked:V(`green`,W.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>V(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>V(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${V(`bold`,e)} ${V(`dim`,t)}`).join(V(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`}};function Ya(e){return!K.isSeparator(e)&&!e.disabled}function Xa(e){return!K.isSeparator(e)}function Za(e){return!K.isSeparator(e)&&e.checked}function Qa(e){return Ya(e)?{...e,checked:!e.checked}:e}function $a(e){return function(t){return Ya(t)?{...t,checked:e}:t}}function eo(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,checkedName:t,disabled:!1,checked:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,checkedName:e.checkedName??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(n.description=e.description),n})}var to=gr((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=dn(Ja,e.theme),{keybindings:c}=s,[l,u]=U(`idle`),d=fn({status:l,theme:s}),[f,p]=U(eo(e.choices)),m=pn(()=>{let e=f.findIndex(Xa),t=f.findLastIndex(Xa);if(e===-1)throw new Ut(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=U(m.first),[_,v]=U();hn(async e=>{if(Rt(e)){let e=f.filter(Za),n=await a([...e]);i&&!e.length?v(`At least one choice must be selected`):n===!0?(u(`done`),t(e.map(e=>e.value))):v(n||`You must select a valid value`)}else if(Nt(e,c)||Pt(e,c)){if(_&&v(void 0),r||Nt(e,c)&&h!==m.first||Pt(e,c)&&h!==m.last){let t=Nt(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Xa(f[n]));g(n)}}else if(Ft(e)){let e=f[h];e&&!K.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?Qa(e):e))))}else if(e.name===o.all){let e=f.some(e=>Ya(e)&&!e.checked);p(f.map($a(e)))}else if(e.name===o.invert)p(f.map(Qa));else if(Lt(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>!K.isSeparator(e)&&(n++,n===t)),i=f[r];i&&Ya(i)&&(g(r),p(f.map((e,t)=>t===r?Qa(e):e)))}});let y=s.style.message(e.message,l),b,x=Un({items:f,active:h,renderItem({item:e,isActive:t}){if(K.isSeparator(e))return` ${e.separator}`;let n=t?s.icon.cursor:` `;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=e.checked?s.icon.disabledChecked:s.icon.disabledUnchecked;return s.style.disabled(`${n}${r} ${e.name} ${t}`)}t&&(b=e.description);let r=e.checked?s.icon.checked:s.icon.unchecked,i=e.checked?e.checkedName:e.name;return(t?s.style.highlight:e=>e)(`${n}${r} ${i}`)},pageSize:n,loop:r});if(l===`done`){let e=f.filter(Za);return[d,y,s.style.answer(s.style.renderSelectedChoices(e,f))].filter(Boolean).join(` `)}let S=[[`↑↓`,`navigate`],[`space`,`select`]];o.all&&S.push([o.all,`all`]),o.invert&&S.push([o.invert,`invert`]),S.push([`⏎`,`submit`]);let ee=s.style.keysHelpTip(S);return`${[[d,y].filter(Boolean).join(` `),x,` `,b?s.style.description(b):``,_?s.style.error(_):``,ee].filter(Boolean).join(`
|
|
331
331
|
`).trimEnd()}${ar}`});const no={icon:{cursor:W.pointer},style:{disabled:e=>V(`dim`,e),description:e=>V(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${V(`bold`,e)} ${V(`dim`,t)}`).join(V(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be selected.`},indexMode:`hidden`};function ro(e){return!K.isSeparator(e)&&!e.disabled}function io(e){return!K.isSeparator(e)}function ao(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,disabled:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(n.description=e.description),n})}var oo=gr((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=dn(no,e.theme),{keybindings:a}=i,[o,s]=U(`idle`),c=fn({status:o,theme:i}),l=mn(),u=!a.includes(`vim`),d=pn(()=>ao(e.choices),[e.choices]),f=pn(()=>{let e=d.findIndex(io),t=d.findLastIndex(io);if(e===-1)throw new Ut(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=pn(()=>`default`in e?d.findIndex(t=>ro(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=U(p===-1?f.first:p),g=d[m];if(g==null||K.isSeparator(g))throw Error(`Active index does not point to a choice`);let[_,v]=U();hn((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Rt(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(Nt(e,a)||Pt(e,a)){if(r.clearLine(0),n||Nt(e,a)&&m!==f.first||Pt(e,a)&&m!==f.last){let t=Nt(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!io(d[n]));h(n)}}else if(Lt(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>!K.isSeparator(n)&&(t++,t===e)),i=d[n];i!=null&&ro(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(It(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>K.isSeparator(t)||!ro(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),$t(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Un({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(K.isSeparator(e))return x++,` ${e.separator}`;let r=t?i.icon.cursor:` `,a=i.indexMode===`number`?`${n+1-x}. `:``;if(e.disabled){let n=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=t?i.icon.cursor:`-`;return i.style.disabled(`${r} ${a}${e.name} ${n}`)}return(t?i.style.highlight:e=>e)(`${r} ${a}${e.name}`)},pageSize:r,loop:n});if(o===`done`)return[c,y,i.style.answer(g.short)].filter(Boolean).join(` `);let{description:ee}=g;return`${[[c,y].filter(Boolean).join(` `),S,` `,ee?i.style.description(ee):``,_?i.style.error(_):``,b].filter(Boolean).join(`
|
|
332
|
-
`).trimEnd()}${ar}`});function so(e){let t=
|
|
332
|
+
`).trimEnd()}${ar}`});function so(e){let t=p(),n=e.split(/\r?\n/,1)[0]??``;if(n===Si(t))return!0;let r=bi(t);return n.startsWith(r)&&/^-v\d+$/.test(n.slice(r.length))}function co(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command!==`ok-pi-managed-extension`||!Array.isArray(t.args))return!1;let n=t.args[0];return typeof n==`string`&&so(n)}function lo(e){return{command:`ok-pi-managed-extension`,args:[e]}}function uo(e={}){let t=e.mode===`dev`,n=p(),r=t?Si(n):xi(n),i=`${m(n)}_`,a={unix:Z({...e,platformName:`darwin`}),win32:Z({...e,platformName:`win32`})};return`${r}
|
|
333
333
|
/**
|
|
334
|
-
* Open Knowledge bridge for Pi — MANAGED FILE, written by \`${
|
|
334
|
+
* Open Knowledge bridge for Pi — MANAGED FILE, written by \`${l()} init\`.
|
|
335
335
|
* Hand edits are overwritten whenever OK re-syncs this project; remove it
|
|
336
|
-
* with \`${
|
|
336
|
+
* with \`${l()} deinit\` (or delete the file) to disconnect Pi from OK.
|
|
337
337
|
*
|
|
338
338
|
* On session start it spawns Open Knowledge's MCP stdio server via OK's
|
|
339
339
|
* resilient launcher (bundle, then npx, then version-manager probes), performs
|
|
@@ -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&&T(e,g,{mode:Ka(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const zo=e=>e!==`project`,Bo=e=>e!==`user`;async function Vo(){let e=await to({message:`Where should the MCP server be configured?
|
|
690
|
-
`,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Ho(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Vo)():`both`}async function Uo(e){return oo({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:`OK config stays on this machine only; teammates do not see it. Safe escape hatch via \`${b()} config-sharing share\`.`}]})}async function Wo(e){if(e.sharing!==void 0)return e.sharing;let t=ma(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Uo)(t):t}var Go=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}},Ko=class extends Error{constructor(e){super(`A dev MCP entry is written to project config only, never to user-level editor config, so --scope ${e} is not supported with --dev-mcp or OK_CHANNEL=dev. Re-run with --scope project or without --scope.`),this.name=`DevMcpScopeError`}};const qo=`A dev build registers OpenKnowledge MCP in project config only, never in user-level editor config. Run \`${_} init --dev-mcp\` in the project, or set OK_CHANNEL=stable.`;function Jo(e){if(e===void 0||e===!0)return new Set(Te);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(ge.filter(e=>t.includes(e)))}function Yo(e,t,n){let r=F(n,e),i;try{i=ot(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Go(`--content-dir path does not exist: ${r}`):new Go(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Go(`--content-dir must be a directory: ${r}`);let a=Xo(t),o=Xo(r),s=P(a,o);if(s.startsWith(`..`)||Ye(s))throw new Go(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Xo(e){try{return it(e)}catch{return e}}const Zo=`open-knowledge-ui`;function Qo(e,t,n){try{let r=e.detectPath?.(t,n)??M(e.configPath(t,n));return R(r)}catch{return!1}}function $o(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+I)}catch{return!1}}function es(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!R(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||$o(e,t,r);if(!i&&c&&!Qo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{Aa(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return ns(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||tt(M(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{de(`${o}.lock`,()=>{let t=yo(o).writePath;if(s||tt(M(t),{recursive:!0}),e.format===`toml`){let r=Fo(oi(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=Ro(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=Po(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const ts={pi:uo};function ns(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=ts[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{tt(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{de(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Ka(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function rs(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function is(e){let t=sa(e.editors).filter(e=>e.scope===`global`);if(g())return t.map(t=>({editorId:t.id,label:t.label,action:`failed`,configPath:t.configPath(``,e.home),serverName:t.serverName(``),error:qo}));let n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>es(t,``,n,e.home))}function as(e,t,n,r){let i=ss(e,t,n,r);return i.kind===`present`?i.entry:null}function os(e,t,n,r){let i=No(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function ss(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};try{if(ot(i).size>Do)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ha(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ha(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:lo(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=oi().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return os(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,qr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:os(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=So(a);return s?Co(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:os(E(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function cs(e={}){let t=F(e.cwd??process.cwd()),n=mo(t,{homeDir:e.home}),r=n.projectRoot;if(Oe(r,e.home??B()))throw new ye(r);if(_e(r))throw new me(r);let i=!R(N(r,`.ok`)),a=n.gitRootPromoted?P(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:Yo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${k(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`${b()} init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},c=e.devMcp===!0||g();if(c&&e.mcp!==!1&&e.scope&&e.scope!==`project`)throw new Ko(e.scope);let l=await Me(r),u;try{u=ue(r,{contentDir:o})}catch(t){let i=$.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let d=u.created.includes(Ue),f=!1;if(l.didInit)try{f=Se(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{pe(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let p=await Ho({scope:c?`project`:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??ms(r,e.home),h=e.editors??m,_=sa(m),v=sa(h),y=e.mcp===!1||p===null,S=Array.from(new Map([..._,...y?[]:v].map(e=>[e.id,e])).values()),ee=_.filter(t=>Qo(t,r,e.home)),C=[],te=[],ne=new Set;for(let t of S){if(y){let n=``;try{n=t.configPath(r,e.home)}catch{}C.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(zo(p)&&_.includes(t)&&t.scope===`global`&&C.push(es(t,r,s,e.home)),Bo(p)&&v.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=es(t,r,s,e.home,n);C.push(i),(i.action===`written`||i.action===`overwritten`)&&ne.add(n)}}let re=new Set;for(let t of v){let n=t.projectSkillPath?.(r);!n||re.has(n)||(re.add(n),te.push(Ba(t,r,{home:e.home})))}let ie=za(r,v.map(e=>e.id));ie&&te.push(ie);let ae=te.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(ae.length>0){let t=e.home??B();fe({source:x,skills:[Pe.project],agents:ae,scope:r},{home:t,enabled:be(t).enabled})}let oe=!y&&p!==null&&Bo(p)?v.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,se=y?[]:ee.map(e=>rs(e,r)).filter(e=>e!==void 0).filter(e=>!ne.has(e.path)),ce=e.installUserSkill??he,w=e.home??B(),le=Jo(e.skills),de=typeof e.skills!=`string`,ve=!1,xe=!1,Te=!1,Ee=!1,De=!1,ke=!1,T=!1,Ae=[];for(let t of ge){if(!le.has(t))continue;if(ve=!0,de){let e=await Ce(w,Pe[t]).then(e=>({ok:!0,value:e}),()=>({ok:!1}));if(!e.ok){Ae.push({bundleId:t,result:`decision-read-failed`}),T=!0;continue}if(e.value===!1){Ae.push({bundleId:t,result:`opted-out`}),ke=!0;continue}}await Re(w,Pe[t],!0).catch(()=>{});let n=await ce({home:e.home,bundleId:t,force:!0});Ae.push({bundleId:t,result:n}),n===`installed`?xe=!0:n===`failed`?Te=!0:n===`no-hosts`?De=!0:Ee=!0}let je=Te?`failed`:T?`decision-read-failed`:xe?`installed`:ve&&Ee?`skip-current`:ve&&De?`no-hosts`:ke?`opted-out`:`declined`,Ne=xe?Ie(w).map(e=>e.editorId):[],Fe=be(w).enabled&&!we(),Le=y?`skipped-flag`:`skipped-missing`,E=C.find(e=>e.editorId===`claude`)??C[0]??{action:Le,configPath:$.claude.configPath(r,e.home)},ze=await ls({projectRoot:r,desiredMode:await Wo({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:C,projectSkills:te,legacyProjectConfigs:se,skillInstall:je,skillBundles:Ae,skillsRequested:e.skills,skillHosts:Ne,skillInstallsCounted:Fe,didGitInit:l.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:oe,sharing:ze}}async function ls(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=ma(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=ua(t);if(n===`local-only`){let e=fa(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:us(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=pa(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:us(t,o,`remove`)}function us(e,t,n){let r=ma(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function ds(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function fs(e,t){let n=[],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=N(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(A(`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(A(`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(A(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(A(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(A(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?P(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===m()?``:` (${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} ${O(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${O(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${He(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${ds(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`)}let r=w.dev.mcpServerName;e.editors.some(e=>e.serverName===r&&(e.action===`written`||e.action===`overwritten`))&&n.push(` The ${r} entry runs this checkout on this machine only; keep it out of commits.`)}if(e.projectSkills.length>0){n.push(``),n.push(A(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?P(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${He(`FAILED`)}: ${r.error}`)}}}if(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} ${P(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall===`declined`)n.push(``),n.push(A(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${D(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${ge.join(`, `)})`)}`),n.push(` ${D(`No user-global skill was installed or removed.`)}`)):(n.push(` ${D(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${D(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ${b()} init`)}`),n.push(` ${D(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(A(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>Pe[e.bundleId].length));for(let i of t){let t=Pe[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${O(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${O(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`${t} install failed`)}`);break;case`opted-out`:n.push(` ${t} ${D(`not installed — turned off on this machine; reinstall with ${b()} init --skills ${i.bundleId} or Settings → Skills Studio`)}`);break;case`decision-read-failed`:n.push(` ${k(`${t} not installed — could not read whether it is turned off on this machine; rerun ${b()} init once ${ie(ee)} is readable`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${k(`Retry with: ${b()} repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(k(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(k(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`${b()} 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 \`${b()} init --content-dir .\` from there, or set`),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(We(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(..._s(e.sharing,t));let c=e=>[`${e}- ${Ve(`${b()} seed --list-packs`)} — browse the starter packs`,`${e}- ${Ve(`${b()} seed`)} — scaffold an empty repo`];if(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(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${Ve(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...c(` `))),n.push(` ${i}. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${A(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...c(` `)));return n.join(`
|
|
691
|
-
`)}function ps(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function ms(e,t){let n=[];for(let r of ci)r!==`claude-desktop`&&Qo($[r],e,t)&&n.push(r);return n}function hs(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:ct(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function gs(){return new Et(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry (node + packages/cli/dist/cli.mjs, debug logging) in project config only, as the dev channel unless OK_CHANNEL is set`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new Ot(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new Ot(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new Ot(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd();e.devMcp&&
|
|
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-
|
|
693
|
-
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${Ve(`${
|
|
690
|
+
`,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Ho(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Vo)():`both`}async function Uo(e){return oo({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:`OK config stays on this machine only; teammates do not see it. Safe escape hatch via \`${l()} config-sharing share\`.`}]})}async function Wo(e){if(e.sharing!==void 0)return e.sharing;let t=ma(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Uo)(t):t}var Go=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}},Ko=class extends Error{constructor(e){super(`A dev MCP entry is written to project config only, never to user-level editor config, so --scope ${e} is not supported with --dev-mcp or OK_CHANNEL=dev. Re-run with --scope project or without --scope.`),this.name=`DevMcpScopeError`}};const qo=`A dev build registers OpenKnowledge MCP in project config only, never in user-level editor config. Run \`${ce} init --dev-mcp\` in the project, or set OK_CHANNEL=stable.`;function Jo(e){if(e===void 0||e===!0)return new Set(Te);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(ge.filter(e=>t.includes(e)))}function Yo(e,t,n){let r=F(n,e),i;try{i=ot(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Go(`--content-dir path does not exist: ${r}`):new Go(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Go(`--content-dir must be a directory: ${r}`);let a=Xo(t),o=Xo(r),s=P(a,o);if(s.startsWith(`..`)||Ye(s))throw new Go(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Xo(e){try{return it(e)}catch{return e}}const Zo=`open-knowledge-ui`;function Qo(e,t,n){try{let r=e.detectPath?.(t,n)??M(e.configPath(t,n));return R(r)}catch{return!1}}function $o(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+I)}catch{return!1}}function es(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!R(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||$o(e,t,r);if(!i&&c&&!Qo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{Aa(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return ns(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||tt(M(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{de(`${o}.lock`,()=>{let t=yo(o).writePath;if(s||tt(M(t),{recursive:!0}),e.format===`toml`){let r=Fo(oi(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=Ro(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=Po(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const ts={pi:uo};function ns(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=ts[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{tt(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{de(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Ka(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function rs(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function is(e){let t=sa(e.editors).filter(e=>e.scope===`global`);if(r())return t.map(t=>({editorId:t.id,label:t.label,action:`failed`,configPath:t.configPath(``,e.home),serverName:t.serverName(``),error:qo}));let n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>es(t,``,n,e.home))}function as(e,t,n,r){let i=ss(e,t,n,r);return i.kind===`present`?i.entry:null}function os(e,t,n,r){let i=No(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function ss(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};try{if(ot(i).size>Do)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ha(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ha(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:lo(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=oi().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return os(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,qr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:os(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=So(a);return s?Co(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:os(E(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function cs(e={}){let t=F(e.cwd??process.cwd()),n=mo(t,{homeDir:e.home}),i=n.projectRoot;if(Oe(i,e.home??B()))throw new ye(i);if(_e(i))throw new me(i);let a=!R(N(i,`.ok`)),o=n.gitRootPromoted?P(i,t):void 0,s=e.contentDir===void 0?n.defaultContentDir:Yo(e.contentDir,i,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${i}`):n.gitRootPromoted&&a&&s===`.`&&process.stderr.write(`${k(`[ok] Content scope promoted to the git repo root: ${i}`)}\n Ran in ${o}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`${l()} init --content-dir .\`, or set content.dir: ${o} in .ok/config.yml.\n`);let c={mode:e.devMcp?`dev`:`published`},u=e.devMcp===!0||r();if(u&&e.mcp!==!1&&e.scope&&e.scope!==`project`)throw new Ko(e.scope);let d=await Me(i),f;try{f=ue(i,{contentDir:s})}catch(t){let r=$.claude.configPath(i,e.home);return{projectRoot:i,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:d.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:r,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let p=f.created.includes(Ue),m=!1;if(d.didInit)try{m=Se(i)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${i}: ${e instanceof Error?e.message:String(e)}`)}try{pe(i)===`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 ${i}: ${e instanceof Error?e.message:String(e)}`)}let h=await Ho({scope:u?`project`:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),g=e.editors??ms(i,e.home),_=e.editors??g,v=sa(g),y=sa(_),b=e.mcp===!1||h===null,S=Array.from(new Map([...v,...b?[]:y].map(e=>[e.id,e])).values()),ee=v.filter(t=>Qo(t,i,e.home)),C=[],te=[],ne=new Set;for(let t of S){if(b){let n=``;try{n=t.configPath(i,e.home)}catch{}C.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(i)});continue}if(zo(h)&&v.includes(t)&&t.scope===`global`&&C.push(es(t,i,c,e.home)),Bo(h)&&y.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(i),r=es(t,i,c,e.home,n);C.push(r),(r.action===`written`||r.action===`overwritten`)&&ne.add(n)}}let re=new Set;for(let t of y){let n=t.projectSkillPath?.(i);!n||re.has(n)||(re.add(n),te.push(Ba(t,i,{home:e.home})))}let ie=za(i,y.map(e=>e.id));ie&&te.push(ie);let w=te.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(w.length>0){let t=e.home??B();fe({source:x,skills:[Pe.project],agents:w,scope:i},{home:t,enabled:be(t).enabled})}let ae=!b&&h!==null&&Bo(h)?y.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,oe=b?[]:ee.map(e=>rs(e,i)).filter(e=>e!==void 0).filter(e=>!ne.has(e.path)),se=e.installUserSkill??he,ce=e.home??B(),le=Jo(e.skills),de=typeof e.skills!=`string`,ve=!1,xe=!1,Te=!1,Ee=!1,De=!1,ke=!1,T=!1,Ae=[];for(let t of ge){if(!le.has(t))continue;if(ve=!0,de){let e=await Ce(ce,Pe[t]).then(e=>({ok:!0,value:e}),()=>({ok:!1}));if(!e.ok){Ae.push({bundleId:t,result:`decision-read-failed`}),T=!0;continue}if(e.value===!1){Ae.push({bundleId:t,result:`opted-out`}),ke=!0;continue}}await Re(ce,Pe[t],!0).catch(()=>{});let n=await se({home:e.home,bundleId:t,force:!0});Ae.push({bundleId:t,result:n}),n===`installed`?xe=!0:n===`failed`?Te=!0:n===`no-hosts`?De=!0:Ee=!0}let je=Te?`failed`:T?`decision-read-failed`:xe?`installed`:ve&&Ee?`skip-current`:ve&&De?`no-hosts`:ke?`opted-out`:`declined`,Ne=xe?Ie(ce).map(e=>e.editorId):[],Fe=be(ce).enabled&&!we(),Le=b?`skipped-flag`:`skipped-missing`,E=C.find(e=>e.editorId===`claude`)??C[0]??{action:Le,configPath:$.claude.configPath(i,e.home)},ze=await ls({projectRoot:i,desiredMode:await Wo({sharing:e.sharing,projectRoot:i,isTTY:e.isTTY,freshProject:a,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:i,contentCreated:f.created,contentUpdated:f.updated,contentSkipped:f.skipped,editors:C,projectSkills:te,legacyProjectConfigs:oe,skillInstall:je,skillBundles:Ae,skillsRequested:e.skills,skillHosts:Ne,skillInstallsCounted:Fe,didGitInit:d.didInit,rootGitignoreCreated:m,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDir:p?s:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:ae,sharing:ze}}async function ls(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=ma(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=ua(t);if(n===`local-only`){let e=fa(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:us(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=pa(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:us(t,o,`remove`)}function us(e,t,n){let r=ma(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function ds(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function fs(e,t){let n=[],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`),s=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let c=N(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(A(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(A(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(A(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)n.push(A(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(A(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?P(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===w()?``:` (${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} ${O(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${O(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${He(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${ds(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`)}let r=o.dev.mcpServerName;e.editors.some(e=>e.serverName===r&&(e.action===`written`||e.action===`overwritten`))&&n.push(` The ${r} entry runs this checkout on this machine only; keep it out of commits.`)}if(e.projectSkills.length>0){n.push(``),n.push(A(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?P(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${He(`FAILED`)}: ${r.error}`)}}}if(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} ${P(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall===`declined`)n.push(``),n.push(A(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${D(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${ge.join(`, `)})`)}`),n.push(` ${D(`No user-global skill was installed or removed.`)}`)):(n.push(` ${D(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${D(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ${l()} init`)}`),n.push(` ${D(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(A(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>Pe[e.bundleId].length));for(let i of t){let t=Pe[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${O(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${O(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`${t} install failed`)}`);break;case`opted-out`:n.push(` ${t} ${D(`not installed — turned off on this machine; reinstall with ${l()} init --skills ${i.bundleId} or Settings → Skills Studio`)}`);break;case`decision-read-failed`:n.push(` ${k(`${t} not installed — could not read whether it is turned off on this machine; rerun ${l()} init once ${ie(ee)} is readable`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${k(`Retry with: ${l()} repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(k(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(k(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`${l()} 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 \`${l()} init --content-dir .\` from there, or set`),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(We(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(..._s(e.sharing,t));let u=e=>[`${e}- ${Ve(`${l()} seed --list-packs`)} — browse the starter packs`,`${e}- ${Ve(`${l()} seed`)} — scaffold an empty repo`];if(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(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${Ve(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `))),n.push(` ${i}. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${A(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `)));return n.join(`
|
|
691
|
+
`)}function ps(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function ms(e,t){let n=[];for(let r of ci)r!==`claude-desktop`&&Qo($[r],e,t)&&n.push(r);return n}function hs(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:ct(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function gs(){return new Et(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry (node + packages/cli/dist/cli.mjs, debug logging) in project config only, as the dev channel unless OK_CHANNEL is set`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new Ot(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new Ot(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new Ot(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd();e.devMcp&&d(process.env);let n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?hs():null;try{let r;try{r=await cs({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Go||e instanceof Ko||e instanceof ye||e instanceof me){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof ve||e instanceof Be||e instanceof le){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof De){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-6aogCPbH.mjs`),{resolveContentDir:s}=await import(`./dist-DZ47D2ZS.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-C8jLntfA.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ps(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${fs(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function _s(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${O(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
|
|
693
|
+
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${Ve(`${l()} config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(k(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${Ve(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${Ve(`${l()} config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(k(`Sharing mode unavailable: ${e.reason}.`));return n}}export{Z as $,Ga as A,Da as B,yo as C,Rt as Ct,oo as D,co as E,Ot as Et,Na as F,ua as G,ba as H,Aa as I,pa as J,ga as K,ja as L,Ua as M,Ha as N,to as O,ka as P,li as Q,Va as R,$o as S,U as St,uo as T,wt as Tt,ha as U,fa as V,da as W,X,ci as Y,$ as Z,Wo as _,gr as _t,ls as a,Ei as at,es as b,fn as bt,ms as c,Gi as ct,gs as d,si as dt,Vi as et,Qo as f,oi as ft,Yo as g,Qr as gt,Ho as h,Yr as ht,ts as i,Ci as it,qa as j,Ka as k,fs as l,na as lt,Jo as m,Xr as mt,Ko as n,Hi as nt,ps as o,Wi as ot,as as p,Y as pt,ma as q,Zo as r,Ui as rt,ss as s,Q as st,Go as t,Bi as tt,_s as u,Ai as ut,cs as v,ar as vt,mo as w,Et as wt,is as x,dn as xt,jo as y,hn as yt,Ba as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hs as e,ss as t,us as n}from"./dist-
|
|
1
|
+
import{hs as e,ss as t,us as n}from"./dist-CqRTItlw.mjs";import{N as r,j as i,k as a}from"./init-DcojktK8.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-CGfVL-G_.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:r(e)}}let g=[],_=n(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=t(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=i(h,[`configurations`,y]);return x?(e(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-BiwGF8bz.mjs";export{e as loadConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Jc as e,Kc as t,bl as n,fd as r,gl as i,k as a,ml as o}from"./md-manager-BGnqyqi1-
|
|
1
|
+
import{Jc as e,Kc as t,bl as n,fd as r,gl as i,k as a,ml as o}from"./md-manager-BGnqyqi1-C2MED2uJ.mjs";import{x as s,xs as c,ys as l}from"./dist-CqRTItlw.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-iKekN_P_.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 n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=i({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function b(r){let i=r??process.cwd(),u=[],p=[],m=[],h=[],g=c(`user`,i),_=l({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,t=!1)=>{let r=v(e);if(r.diagnostic!==void 0&&p.push(r.diagnostic),r.value===null)return{};let i=o({value:r.value,file:r.path,source:r.source,doc:r.doc});p.push(...i),u.push(e);let s=i.length>0?n(r.value):r.value;return t&&h.push(...a({value:s,file:r.path,source:r.source,doc:r.doc})),s},x=f(i,`.ok`,d),S=b(x,!0),C=b(c(`project-local`,i)),w=t(_.value,S,C),T=s.safeParse(w);if(!T.success){let t=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,t)};throw Error(e(n))}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};
|