@inkeep/open-knowledge 0.0.0-dev-20260428055023 → 0.0.0-dev-20260428142050

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/THIRD_PARTY_NOTICES.md +10 -0
  2. package/dist/cli.mjs +9 -9
  3. package/dist/constants-DhGUM6YN.mjs +2 -0
  4. package/dist/{dist-DoVDgyml.mjs → dist-6JXIwkTW.mjs} +6 -6
  5. package/dist/dist-Rkr9VTaR.mjs +1 -0
  6. package/dist/{esm-29fM6BBO.mjs → esm-wByiX8MO.mjs} +2 -2
  7. package/dist/index.d.mts +22 -4
  8. package/dist/index.mjs +1 -1
  9. package/dist/init-BrI8fBKs.mjs +1 -0
  10. package/dist/init-DBuBmDI5.mjs +255 -0
  11. package/dist/{init-DVCAi_du.mjs → init-DIWqrqf9.mjs} +2 -2
  12. package/dist/init-qwnR6Vjd.mjs +1 -0
  13. package/dist/{loader-C9LBHYiT.mjs → loader-B_QTYk1P.mjs} +2 -2
  14. package/dist/loader-BblmW_z9.mjs +1 -0
  15. package/dist/paths-COHIVkzx.mjs +1 -0
  16. package/dist/{paths-zc2uvZxY.mjs → paths-Q37hEzLf.mjs} +2 -2
  17. package/dist/{preview-CPxqdDCe.mjs → preview-CSrbRBrj.mjs} +2 -2
  18. package/dist/preview-CzMVj-U-.mjs +1 -0
  19. package/dist/public/assets/McpConsentDialogBody-BbZirIXN.js +1 -0
  20. package/dist/public/assets/{index-CjMTCid5.js → index-BZbSuKIM.js} +2 -2
  21. package/dist/public/index.html +1 -1
  22. package/dist/server-lock-n3Y5JWNv-3o7br8XE.mjs +2 -0
  23. package/dist/server-lock-n3Y5JWNv-DXpg9_eU.mjs +1 -0
  24. package/dist/src-Bolm-3_X.mjs +1 -0
  25. package/dist/start-Cj_Aqfor.mjs +1 -0
  26. package/dist/{start-BnROvKwD.mjs → start-t12xqSci.mjs} +2 -2
  27. package/package.json +2 -1
  28. package/dist/constants-D9m8dzHP.mjs +0 -2
  29. package/dist/dist-CC_QsyED.mjs +0 -1
  30. package/dist/init-D-fChIzY.mjs +0 -1
  31. package/dist/init-D3711KPb.mjs +0 -1
  32. package/dist/init-DNs9ffRY.mjs +0 -254
  33. package/dist/loader-Bc5pJk1m.mjs +0 -1
  34. package/dist/paths-CDgE-NKk.mjs +0 -1
  35. package/dist/preview-EfkiZS-n.mjs +0 -1
  36. package/dist/public/assets/McpConsentDialogBody-BNfu0z8x.js +0 -1
  37. package/dist/server-lock-QiPvrcO9-A3jWEIJ6.mjs +0 -2
  38. package/dist/server-lock-QiPvrcO9-CB330FUa.mjs +0 -1
  39. package/dist/src-CccGTsc2.mjs +0 -1
  40. package/dist/start-DdFbQnn0.mjs +0 -1
@@ -20,7 +20,7 @@
20
20
  nothing for the formatter to reindent.
21
21
  -->
22
22
  <script>(() => { let mode = 'wysiwyg'; try { const raw = localStorage.getItem('ok-editor-mode-v1'); if (raw === 'wysiwyg' || raw === 'source') mode = raw; } catch {} window.__OK_EDITOR_MODE__ = mode; })();</script>
23
- <script type="module" crossorigin src="./assets/index-CjMTCid5.js"></script>
23
+ <script type="module" crossorigin src="./assets/index-BZbSuKIM.js"></script>
24
24
  <link rel="modulepreload" crossorigin href="./assets/chunk-DECur_0Z.js">
25
25
  <link rel="modulepreload" crossorigin href="./assets/propagation-api-Bugyj7xy.js">
26
26
  <link rel="modulepreload" crossorigin href="./assets/w3c-keyname-CSlwavrd.js">
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./rolldown-runtime-wcPFST8Q-BB0WpHs3.mjs";import{dirname as t,resolve as n}from"node:path";import{closeSync as r,existsSync as i,mkdirSync as a,openSync as o,readFileSync as s,unlinkSync as c,writeFileSync as l,writeSync as u}from"node:fs";import{hostname as d}from"node:os";import{fileURLToPath as f}from"node:url";function p(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function m(){try{let e=n(t(f(import.meta.url)),`..`,`package.json`),r=JSON.parse(s(e,`utf-8`));if(typeof r.version==`string`&&r.version.length>0)return r.version}catch{}return`0.0.0-unknown`}const h=m();var g=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function _(e,t){return n(e,`${t}.lock`)}const v=new Map;function y(e){v.set(e,(v.get(e)??0)+1)}function b(e){let t=v.get(e);return t===void 0||t<=1?(v.delete(e),!0):(v.set(e,t-1),!1)}function x(e,t){try{let n=JSON.parse(s(e,`utf-8`));return n&&typeof n==`object`&&typeof n.pid==`number`?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function S(e){let{lockName:t,lockDir:n,metadata:s}=e,f=`[${t}-lock]`;a(n,{recursive:!0});let m=_(n,t),v={pid:process.pid,hostname:d(),port:s.port,startedAt:new Date().toISOString(),worktreeRoot:s.worktreeRoot,...s.kind!==void 0&&{kind:s.kind},...s.parentPid!==void 0&&{parentPid:s.parentPid},...s.capabilities!==void 0&&{capabilities:s.capabilities},protocolVersion:s.protocolVersion??1,runtimeVersion:s.runtimeVersion??h},b=JSON.stringify(v,null,2);for(let e=0;e<3;e++){if(!i(m))try{let e=o(m,`wx`,384);try{u(e,b)}finally{r(e)}return y(m),C({lockName:t,lockDir:n,lockPath:m})}catch(e){if(e.code!==`EEXIST`)throw e}let e=x(m,f);if(e){let r=e.hostname===d();if(r&&e.pid===process.pid)return l(m,b,{encoding:`utf-8`,mode:384}),y(m),C({lockName:t,lockDir:n,lockPath:m});if(r&&p(e.pid))throw new g(e,m,t);console.warn(`${f} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{c(m)}catch{}}throw Error(`${f} Failed to acquire ${m} after 3 attempts (concurrent acquire contention).`)}function C(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>E({lockName:t,lockDir:n}),updatePort:e=>w({lockName:t,lockDir:n,port:e})}}function w(e){let{lockName:t,lockDir:n,port:r}=e,a=`[${t}-lock]`,o=_(n,t);if(!i(o)){console.warn(`${a} Lock file missing at ${o} during port update — skipping`);return}let c;try{let e=JSON.parse(s(o,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`){console.warn(`${a} Corrupt lock at ${o} during port update — skipping`);return}c=e}catch{console.warn(`${a} Unreadable lock at ${o} during port update — skipping`);return}if(c.pid===process.pid&&!(typeof c.hostname==`string`&&c.hostname!==d())){c.port=r;try{l(o,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${a} Failed to update port in ${o}: ${e instanceof Error?e.message:String(e)}`)}}}function T(e){let{lockName:t,lockDir:n}=e,r=_(n,t);if(!i(r))return null;let a;try{let e=JSON.parse(s(r,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`)return null;a=e}catch{return null}if(a.hostname!==d())return null;if(!p(a.pid)){try{c(r)}catch{}return null}return a}function E(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,a=_(n,t);if(b(a)&&i(a))try{let e=JSON.parse(s(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==d())return;c(a)}catch(e){console.warn(`${r} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}var D=e({ServerLockCollisionError:()=>O,acquireServerLock:()=>k,readServerLock:()=>j,releaseServerLock:()=>M,updateServerLockPort:()=>A}),O=class extends g{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function k(e,t){try{return S({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof g&&e.lockName===`server`?new O(e.existing,e.lockPath):e}}function A(e,t){w({lockName:`server`,lockDir:e,port:t})}function j(e){return T({lockName:`server`,lockDir:e})}function M(e){E({lockName:`server`,lockDir:e})}export{k as a,T as c,M as d,D as f,S as i,j as l,A as m,h as n,p as o,w as p,O as r,_ as s,g as t,E as u};
2
+ //# sourceMappingURL=server-lock-n3Y5JWNv-3o7br8XE.mjs.map
@@ -0,0 +1 @@
1
+ import{f as e}from"./server-lock-n3Y5JWNv-3o7br8XE.mjs";export{e as a};
@@ -0,0 +1 @@
1
+ import"./init-DBuBmDI5.mjs";import"./loader-B_QTYk1P.mjs";export{};
@@ -0,0 +1 @@
1
+ import{o as e}from"./start-t12xqSci.mjs";export{e as startCommand};
@@ -1,2 +1,2 @@
1
- import{t as e}from"./esm-29fM6BBO.mjs";import{i as t}from"./constants-D9m8dzHP.mjs";import{p as n}from"./dist-DRC09WNZ.mjs";import{spawn as r}from"node:child_process";import{join as i}from"node:path";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c}from"node:fs";import{setTimeout as l}from"node:timers/promises";function u(){let e=process.execPath,t=process.argv[1];return t?{command:e,prefixArgs:[t]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx @inkeep/open-knowledge\`. This re-introduces the version-drift surface that re-exec was fixing. Observed argv: ${JSON.stringify(process.argv)}`),{command:`npx`,prefixArgs:[`@inkeep/open-knowledge`]})}function d(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function f(e){o(e.lockDir)||s(e.lockDir,{recursive:!0});let t=c(i(e.lockDir,`last-spawn-error.log`),`w`),n=e.spawn??r,{PORT:l,...d}=process.env,f=u();try{let r=n(f.command,[...f.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:d});return r.unref(),r}finally{try{a(t)}catch{}}}async function p(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}function m(e){let t=e.sigtermGraceMs??1e4,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>l(e));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function h(e){let{config:t,cwd:r}=e,i=e.skipAutoInit??!1,a=e.skipUiAutoSpawn??!1,o=e.idleThresholdMs??18e5,{existsSync:s,mkdirSync:c}=await import(`node:fs`),{resolve:u}=await import(`node:path`),{bootServer:h,ensureProjectGit:g,getLogger:_,isProcessAlive:v,readUiLock:y}=await import(`./dist-CC_QsyED.mjs`),{resolveContentDir:b}=await import(`./paths-CDgE-NKk.mjs`),x=e.log??_(`start`),S=b(t,r);s(S)||(c(S,{recursive:!0}),x.info({contentDir:S},`Created content directory`));let C=!s(u(r,n)),w=i?void 0:async()=>{try{let{initContent:e}=await import(`./init-D3711KPb.mjs`),t=e(r);return C||t.created.length>0}catch(e){return console.warn(`Auto-init failed:`,e instanceof Error?e.message:e),!1}},T=!1,E=u(S,n),D=t.server.openOnAgentEdit?()=>{if(T)return;let e=y(E);if(!e||e.port<=0||!v(e.pid))return;T=!0;let t=`http://localhost:${e.port}`;import(`./open-browser-BzMQ6cLf.mjs`).then(({openBrowser:e})=>e(t)).catch(()=>{})}:void 0,O=null,k=await h({contentDir:S,projectDir:r,contentRoot:t.content.dir,port:t.server.port,host:t.server.host,quiet:!1,debounce:t.persistence.debounceMs,maxDebounce:t.persistence.maxDebounceMs,includePatterns:t.content.include,excludePatterns:t.content.exclude,onAgentWrite:D,localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:!0,idleShutdownMs:o,skipAutoInit:i,autoInitFn:w,ensureProjectGitFn:i?void 0:()=>g(r),spawnUiSiblingFn:async({lockDir:t})=>{if(O=d({uiLock:y(t),isAlive:v}),O.action===`spawn`&&!a)try{f({lockDir:t,cwd:r,spawn:e.spawn}),x.info({reason:O.reason},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else O.action===`skip`&&x.info({port:O.port,pid:O.pid},`UI already running at port ${O.port}`)},idleShutdownHandler:e=>m({readUiLock:()=>y(k.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:x}),log:x});O||={action:`skip`,reason:`alive`,pid:0,port:0};let A=O,j=null;if(A.action===`skip`)j=A.port>0?A.port:null;else if(!a){let t=e.uiBindTimeoutMs??3e3;j=await p({readUiLock:()=>y(k.lockDir),now:Date.now,sleep:e=>l(e),timeoutMs:t,pollIntervalMs:50}),j===null&&x.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:k.httpServer,destroy:k.destroy,lockDir:k.lockDir,contentDir:S,port:k.port,ready:k.ready,degraded:k.degraded,uiSpawnDecision:O,resolvedUiPort:j,didAutoInit:k.didAutoInit,didGitInit:k.didGitInit}}function g(r){return new e(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--no-init`,`Skip auto-scaffolding of ${n}/`).action(async e=>{let{renderBanner:i}=await import(`./banner-BxI1wnW9.mjs`),{dim:a,error:o,info:s,warning:c}=await import(`./colors-BnZ-i-vb.mjs`),l=r(),u=process.cwd();e.port!==void 0&&(l.server.port=Number(e.port)),e.host!==void 0&&(l.server.host=e.host);let d;try{d=await h({config:l,cwd:u,skipAutoInit:e.init===!1})}catch(e){let{ProjectGitInitError:t}=await import(`./dist-CC_QsyED.mjs`);e instanceof t&&(console.error(o(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.`)),e.stderr&&console.error(a(e.stderr.trim())),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let f=!1,p=async e=>{if(!f){f=!0,console.log(a(`\nShutting down (${e})...`));try{await d.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)}};process.once(`SIGINT`,()=>{p(`SIGINT`)}),process.once(`SIGTERM`,()=>{p(`SIGTERM`)});let m=`http://${l.server.host}:${d.port}`,g=l.server.host===`0.0.0.0`||l.server.host===`::`?`http://0.0.0.0:${d.port}`:void 0,_=d.resolvedUiPort,v=_!==null&&_>0?`http://${l.server.host}:${_}`:m;console.log(i({name:`open-knowledge`,version:t,localUrl:v,apiUrl:v===m?void 0:m,networkUrl:g})),d.didAutoInit&&(console.log(` ${s(`✓`)} Scaffolded ${n}/ (first run)`),console.log(` ${a("Tip: Run `open-knowledge init` to register MCP tools for Claude Code")}\n`));let y={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};d.ready.then(async()=>{if(d.degraded.length>0){console.log();for(let e of d.degraded){let t=y[e]??`${e} (check server logs for details)`;console.warn(` ${c(`⚠`)} ${c(e)}: ${a(t)}`)}console.log()}if(d.didAutoInit||d.didGitInit)if(d.didGitInit&&console.log(`\n ${s(`✓`)} Initialized git repo at ${u}/.git/ (default branch: main)`),d.didAutoInit)try{let{previewContent:e,formatPreviewBlock:t}=await import(`./preview-EfkiZS-n.mjs`),n=e({projectDir:u,contentDir:d.contentDir,include:l.content.include,exclude:l.content.exclude});console.log(`\n${t(n,u)}\n`)}catch(e){console.warn(`Content preview unavailable: ${e instanceof Error?e.message:String(e)}`)}else console.log();if(e.open){let{openBrowser:e}=await import(`./open-browser-BzMQ6cLf.mjs`);e(v)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})})}export{f as a,d as i,h as n,g as o,m as r,u as s,p as t};
2
- //# sourceMappingURL=start-BnROvKwD.mjs.map
1
+ import{t as e}from"./esm-wByiX8MO.mjs";import{i as t}from"./constants-DhGUM6YN.mjs";import{p as n}from"./dist-DRC09WNZ.mjs";import{spawn as r}from"node:child_process";import{join as i}from"node:path";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c}from"node:fs";import{setTimeout as l}from"node:timers/promises";function u(){let e=process.execPath,t=process.argv[1];return t?{command:e,prefixArgs:[t]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx @inkeep/open-knowledge\`. This re-introduces the version-drift surface that re-exec was fixing. Observed argv: ${JSON.stringify(process.argv)}`),{command:`npx`,prefixArgs:[`@inkeep/open-knowledge`]})}function d(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function f(e){o(e.lockDir)||s(e.lockDir,{recursive:!0});let t=c(i(e.lockDir,`last-spawn-error.log`),`w`),n=e.spawn??r,{PORT:l,...d}=process.env,f=u();try{let r=n(f.command,[...f.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:d});return r.unref(),r}finally{try{a(t)}catch{}}}async function p(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}function m(e){let t=e.sigtermGraceMs??1e4,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>l(e));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function h(e){let{config:t,cwd:r}=e,i=e.skipAutoInit??!1,a=e.skipUiAutoSpawn??!1,o=e.idleThresholdMs??18e5,{existsSync:s,mkdirSync:c}=await import(`node:fs`),{resolve:u}=await import(`node:path`),{bootServer:h,ensureProjectGit:g,getLogger:_,isProcessAlive:v,readUiLock:y}=await import(`./dist-Rkr9VTaR.mjs`),{resolveContentDir:b}=await import(`./paths-COHIVkzx.mjs`),x=e.log??_(`start`),S=b(t,r);s(S)||(c(S,{recursive:!0}),x.info({contentDir:S},`Created content directory`));let C=!s(u(r,n)),w=i?void 0:async()=>{try{let{initContent:e}=await import(`./init-qwnR6Vjd.mjs`),t=e(r);return C||t.created.length>0}catch(e){return console.warn(`Auto-init failed:`,e instanceof Error?e.message:e),!1}},T=!1,E=u(S,n),D=t.server.openOnAgentEdit?()=>{if(T)return;let e=y(E);if(!e||e.port<=0||!v(e.pid))return;T=!0;let t=`http://localhost:${e.port}`;import(`./open-browser-BzMQ6cLf.mjs`).then(({openBrowser:e})=>e(t)).catch(()=>{})}:void 0,O=null,k=await h({contentDir:S,projectDir:r,contentRoot:t.content.dir,port:t.server.port,host:t.server.host,quiet:!1,debounce:t.persistence.debounceMs,maxDebounce:t.persistence.maxDebounceMs,includePatterns:t.content.include,excludePatterns:t.content.exclude,onAgentWrite:D,localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:!0,idleShutdownMs:o,skipAutoInit:i,autoInitFn:w,ensureProjectGitFn:i?void 0:()=>g(r),spawnUiSiblingFn:async({lockDir:t})=>{if(O=d({uiLock:y(t),isAlive:v}),O.action===`spawn`&&!a)try{f({lockDir:t,cwd:r,spawn:e.spawn}),x.info({reason:O.reason},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else O.action===`skip`&&x.info({port:O.port,pid:O.pid},`UI already running at port ${O.port}`)},idleShutdownHandler:e=>m({readUiLock:()=>y(k.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:x}),log:x});O||={action:`skip`,reason:`alive`,pid:0,port:0};let A=O,j=null;if(A.action===`skip`)j=A.port>0?A.port:null;else if(!a){let t=e.uiBindTimeoutMs??3e3;j=await p({readUiLock:()=>y(k.lockDir),now:Date.now,sleep:e=>l(e),timeoutMs:t,pollIntervalMs:50}),j===null&&x.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:k.httpServer,destroy:k.destroy,lockDir:k.lockDir,contentDir:S,port:k.port,ready:k.ready,degraded:k.degraded,uiSpawnDecision:O,resolvedUiPort:j,didAutoInit:k.didAutoInit,didGitInit:k.didGitInit}}function g(r){return new e(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--no-init`,`Skip auto-scaffolding of ${n}/`).action(async e=>{let{renderBanner:i}=await import(`./banner-BxI1wnW9.mjs`),{dim:a,error:o,info:s,warning:c}=await import(`./colors-BnZ-i-vb.mjs`),l=r(),u=process.cwd();e.port!==void 0&&(l.server.port=Number(e.port)),e.host!==void 0&&(l.server.host=e.host);let d;try{d=await h({config:l,cwd:u,skipAutoInit:e.init===!1})}catch(e){let{ProjectGitInitError:t}=await import(`./dist-Rkr9VTaR.mjs`);e instanceof t&&(console.error(o(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.`)),e.stderr&&console.error(a(e.stderr.trim())),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let f=!1,p=async e=>{if(!f){f=!0,console.log(a(`\nShutting down (${e})...`));try{await d.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)}};process.once(`SIGINT`,()=>{p(`SIGINT`)}),process.once(`SIGTERM`,()=>{p(`SIGTERM`)});let m=`http://${l.server.host}:${d.port}`,g=l.server.host===`0.0.0.0`||l.server.host===`::`?`http://0.0.0.0:${d.port}`:void 0,_=d.resolvedUiPort,v=_!==null&&_>0?`http://${l.server.host}:${_}`:m;console.log(i({name:`open-knowledge`,version:t,localUrl:v,apiUrl:v===m?void 0:m,networkUrl:g})),d.didAutoInit&&(console.log(` ${s(`✓`)} Scaffolded ${n}/ (first run)`),console.log(` ${a("Tip: Run `open-knowledge init` to register MCP tools for Claude Code")}\n`));let y={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};d.ready.then(async()=>{if(d.degraded.length>0){console.log();for(let e of d.degraded){let t=y[e]??`${e} (check server logs for details)`;console.warn(` ${c(`⚠`)} ${c(e)}: ${a(t)}`)}console.log()}if(d.didAutoInit||d.didGitInit)if(d.didGitInit&&console.log(`\n ${s(`✓`)} Initialized git repo at ${u}/.git/ (default branch: main)`),d.didAutoInit)try{let{previewContent:e,formatPreviewBlock:t}=await import(`./preview-CzMVj-U-.mjs`),n=e({projectDir:u,contentDir:d.contentDir,include:l.content.include,exclude:l.content.exclude});console.log(`\n${t(n,u)}\n`)}catch(e){console.warn(`Content preview unavailable: ${e instanceof Error?e.message:String(e)}`)}else console.log();if(e.open){let{openBrowser:e}=await import(`./open-browser-BzMQ6cLf.mjs`);e(v)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})})}export{f as a,d as i,h as n,g as o,m as r,u as s,p as t};
2
+ //# sourceMappingURL=start-t12xqSci.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/open-knowledge",
3
- "version": "0.0.0-dev-20260428055023",
3
+ "version": "0.0.0-dev-20260428142050",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -42,6 +42,7 @@
42
42
  "prepublishOnly": "bash ../../scripts/check-notices-clean.sh && bun run build && bun run test"
43
43
  },
44
44
  "dependencies": {
45
+ "@inquirer/checkbox": "^5.0.11",
45
46
  "@inquirer/password": "^5.0.11",
46
47
  "@modelcontextprotocol/sdk": "^1.28.0",
47
48
  "@napi-rs/keyring": "^1.2.0",
@@ -1,2 +0,0 @@
1
- import"./dist-DRC09WNZ.mjs";var e=`0.0.0-dev-20260428055023`;const t=`config.yml`,n=`cache`,r=e,i=`open-knowledge`;export{r as i,t as n,i as r,n as t};
2
- //# sourceMappingURL=constants-D9m8dzHP.mjs.map
@@ -1 +0,0 @@
1
- import"./dist-DRC09WNZ.mjs";import{a as e,c as t}from"./server-lock-QiPvrcO9-A3jWEIJ6.mjs";import{A as n,Bt as r,St as i,T as a,X as o,_ as s,q as c,vt as l,w as u}from"./dist-DoVDgyml.mjs";export{s as ProjectGitInitError,u as UiLockCollisionError,a as acquireUiLock,n as bootServer,c as ensureProjectGit,o as getLogger,e as isProcessAlive,t as readServerLock,l as readUiLock,i as releaseUiLock,r as updateUiLockPort};
@@ -1 +0,0 @@
1
- import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./init-DNs9ffRY.mjs";export{o as detectInstalledEditors,n as formatInitResult,i as initCommand,t as readExistingMcpEntry,e as runInit,r as writeEditorMcpConfig,a as writeUserMcpConfigs};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./init-DVCAi_du.mjs";export{t as ensureOkGitignoredAtRoot,e as initContent};
@@ -1,254 +0,0 @@
1
- import{t as e}from"./esm-29fM6BBO.mjs";import{r as t}from"./constants-D9m8dzHP.mjs";import{p as n}from"./dist-DRC09WNZ.mjs";import{K as r,_ as i,at as a,q as o}from"./dist-DoVDgyml.mjs";import{n as s}from"./init-DVCAi_du.mjs";import{t as c}from"./preview-CPxqdDCe.mjs";import{s as l,t as u}from"./colors-DoPZvo1q.mjs";import{t as d}from"./is-object-BNVklKxg.mjs";import{basename as f,dirname as p,join as m,posix as h,relative as g,resolve as ee,sep as _,win32 as v}from"node:path";import{existsSync as y,mkdirSync as b,readFileSync as x,writeFileSync as S}from"node:fs";import{homedir as C}from"node:os";
2
- /*!
3
- * Copyright (c) Squirrel Chat et al., All rights reserved.
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted provided that the following conditions are met:
8
- *
9
- * 1. Redistributions of source code must retain the above copyright notice, this
10
- * list of conditions and the following disclaimer.
11
- * 2. Redistributions in binary form must reproduce the above copyright notice,
12
- * this list of conditions and the following disclaimer in the
13
- * documentation and/or other materials provided with the distribution.
14
- * 3. Neither the name of the copyright holder nor the names of its contributors
15
- * may be used to endorse or promote products derived from this software without
16
- * specific prior written permission.
17
- *
18
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
29
- function te(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function ne(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
30
- `,e===t&&(i+=` `.repeat(a+n+2),i+=`^
31
- `))}return i}var w=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=te(t.toml,t.ptr),i=ne(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
32
- /*!
33
- * Copyright (c) Squirrel Chat et al., All rights reserved.
34
- * SPDX-License-Identifier: BSD-3-Clause
35
- *
36
- * Redistribution and use in source and binary forms, with or without
37
- * modification, are permitted provided that the following conditions are met:
38
- *
39
- * 1. Redistributions of source code must retain the above copyright notice, this
40
- * list of conditions and the following disclaimer.
41
- * 2. Redistributions in binary form must reproduce the above copyright notice,
42
- * this list of conditions and the following disclaimer in the
43
- * documentation and/or other materials provided with the distribution.
44
- * 3. Neither the name of the copyright holder nor the names of its contributors
45
- * may be used to endorse or promote products derived from this software without
46
- * specific prior written permission.
47
- *
48
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
49
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
52
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
54
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
55
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58
- */
59
- function re(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}function T(e,t=0,n=e.length){let r=e.indexOf(`
60
- `,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function E(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
61
- `)return n;if(r===`\r`&&e[n+1]===`
62
- `)return n+1;if(r<` `&&r!==` `||r===``)throw new w(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function D(e,t,n,r){let i;for(;;){for(;(i=e[t])===` `||i===` `||!n&&(i===`
63
- `||i===`\r`&&e[t+1]===`
64
- `);)t++;if(r||i!==`#`)break;t=E(e,t)}return t}function ie(e,t,n,r,i=!1){if(!r)return t=T(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=T(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
65
- `||t===`\r`&&e[a+1]===`
66
- `))return a}throw new w(`cannot find end of structure`,{toml:e,ptr:t})}function O(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do t=e.indexOf(r,++t);while(t>-1&&n!==`'`&&re(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}
67
- /*!
68
- * Copyright (c) Squirrel Chat et al., All rights reserved.
69
- * SPDX-License-Identifier: BSD-3-Clause
70
- *
71
- * Redistribution and use in source and binary forms, with or without
72
- * modification, are permitted provided that the following conditions are met:
73
- *
74
- * 1. Redistributions of source code must retain the above copyright notice, this
75
- * list of conditions and the following disclaimer.
76
- * 2. Redistributions in binary form must reproduce the above copyright notice,
77
- * this list of conditions and the following disclaimer in the
78
- * documentation and/or other materials provided with the distribution.
79
- * 3. Neither the name of the copyright holder nor the names of its contributors
80
- * may be used to endorse or promote products derived from this software without
81
- * specific prior written permission.
82
- *
83
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
84
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
87
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
88
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
89
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
90
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
91
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
92
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93
- */
94
- let ae=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var oe=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(ae);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
95
- /*!
96
- * Copyright (c) Squirrel Chat et al., All rights reserved.
97
- * SPDX-License-Identifier: BSD-3-Clause
98
- *
99
- * Redistribution and use in source and binary forms, with or without
100
- * modification, are permitted provided that the following conditions are met:
101
- *
102
- * 1. Redistributions of source code must retain the above copyright notice, this
103
- * list of conditions and the following disclaimer.
104
- * 2. Redistributions in binary form must reproduce the above copyright notice,
105
- * this list of conditions and the following disclaimer in the
106
- * documentation and/or other materials provided with the distribution.
107
- * 3. Neither the name of the copyright holder nor the names of its contributors
108
- * may be used to endorse or promote products derived from this software without
109
- * specific prior written permission.
110
- *
111
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
112
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
113
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
114
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
115
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
116
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
117
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
118
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
119
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
120
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
121
- */
122
- let se=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,ce=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,le=/^[+-]?0[0-9_]/,ue=/^[0-9a-f]{2,8}$/i,k={b:`\b`,t:` `,n:`
123
- `,f:`\f`,r:`\r`,e:`\x1B`,'"':`"`,"\\":`\\`};function de(e,t=0,n=e.length){let r=e[t]===`'`,i=e[t++]===e[t]&&e[t]===e[t+1];i&&(n-=2,e[t+=2]===`\r`&&t++,e[t]===`
124
- `&&t++);let a=0,o,s=``,c=t;for(;t<n-1;){let n=e[t++];if(n===`
125
- `||n===`\r`&&e[t]===`
126
- `){if(!i)throw new w(`newlines are not allowed in strings`,{toml:e,ptr:t-1})}else if(n<` `&&n!==` `||n===``)throw new w(`control characters are not allowed in strings`,{toml:e,ptr:t-1});if(o){if(o=!1,n===`x`||n===`u`||n===`U`){let r=e.slice(t,t+=n===`x`?2:n===`u`?4:8);if(!ue.test(r))throw new w(`invalid unicode escape`,{toml:e,ptr:a});try{s+=String.fromCodePoint(parseInt(r,16))}catch{throw new w(`invalid unicode escape`,{toml:e,ptr:a})}}else if(i&&(n===`
127
- `||n===` `||n===` `||n===`\r`)){if(t=D(e,t-1,!0),e[t]!==`
128
- `&&e[t]!==`\r`)throw new w(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:a});t=D(e,t)}else if(n in k)s+=k[n];else throw new w(`unrecognized escape sequence`,{toml:e,ptr:a});c=t}else !r&&n===`\\`&&(a=t-1,o=!0,s+=e.slice(c,a))}return s+e.slice(c,n-1)}function fe(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=se.test(e);if(i||ce.test(e)){if(le.test(e))throw new w(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new w(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new w(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new oe(e);if(!a.isValid())throw new w(`invalid value`,{toml:t,ptr:n});return a}
129
- /*!
130
- * Copyright (c) Squirrel Chat et al., All rights reserved.
131
- * SPDX-License-Identifier: BSD-3-Clause
132
- *
133
- * Redistribution and use in source and binary forms, with or without
134
- * modification, are permitted provided that the following conditions are met:
135
- *
136
- * 1. Redistributions of source code must retain the above copyright notice, this
137
- * list of conditions and the following disclaimer.
138
- * 2. Redistributions in binary form must reproduce the above copyright notice,
139
- * this list of conditions and the following disclaimer in the
140
- * documentation and/or other materials provided with the distribution.
141
- * 3. Neither the name of the copyright holder nor the names of its contributors
142
- * may be used to endorse or promote products derived from this software without
143
- * specific prior written permission.
144
- *
145
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
146
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
147
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
148
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
149
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
150
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
151
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
152
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
153
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
154
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
155
- */
156
- function pe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(E(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function A(e,t,n,r,i){if(r===0)throw new w(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?ge(e,t,r,i):he(e,t,r,i);if(n){if(s=D(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new w(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}let o;if(a===`"`||a===`'`){o=O(e,t);let r=de(e,t,o);if(n){if(o=D(e,o),e[o]&&e[o]!==`,`&&e[o]!==n&&e[o]!==`
157
- `&&e[o]!==`\r`)throw new w(`unexpected character encountered`,{toml:e,ptr:o});o+=+(e[o]===`,`)}return[r,o]}o=ie(e,t,`,`,n);let s=pe(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new w(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=D(e,t+s[1]),o+=+(e[o]===`,`)),[fe(s[0],e,t,i),o]}
158
- /*!
159
- * Copyright (c) Squirrel Chat et al., All rights reserved.
160
- * SPDX-License-Identifier: BSD-3-Clause
161
- *
162
- * Redistribution and use in source and binary forms, with or without
163
- * modification, are permitted provided that the following conditions are met:
164
- *
165
- * 1. Redistributions of source code must retain the above copyright notice, this
166
- * list of conditions and the following disclaimer.
167
- * 2. Redistributions in binary form must reproduce the above copyright notice,
168
- * this list of conditions and the following disclaimer in the
169
- * documentation and/or other materials provided with the distribution.
170
- * 3. Neither the name of the copyright holder nor the names of its contributors
171
- * may be used to endorse or promote products derived from this software without
172
- * specific prior written permission.
173
- *
174
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
175
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
176
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
177
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
178
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
179
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
180
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
181
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
182
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
183
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
184
- */
185
- let me=/^[a-zA-Z0-9-_]+[ \t]*$/;function j(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new w(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `)if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new w(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let s=O(e,t);if(s<0)throw new w(`unfinished string encountered`,{toml:e,ptr:t});r=e.indexOf(`.`,s);let c=e.slice(s,r<0||r>a?a:r),l=T(c);if(l>-1)throw new w(`newlines are not allowed in keys`,{toml:e,ptr:t+r+l});if(c.trimStart())throw new w(`found extra tokens after the string part`,{toml:e,ptr:s});if(a<s&&(a=e.indexOf(n,s),a<0))throw new w(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(de(e,t,s))}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!me.test(n))throw new w(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}while(r+1&&r<a);return[i,D(e,a+1,!0,!0)]}function he(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new w(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=E(e,t);else if(o!==` `&&o!==` `&&o!==`
186
- `&&o!==`\r`){let o,s=i,c=!1,[l,u]=j(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new w(`trying to redefine an already defined value`,{toml:e,ptr:t});!c&&o===`__proto__`&&Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new w(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=A(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new w(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function ge(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new w(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=E(e,t);else if(a!==` `&&a!==` `&&a!==`
187
- `&&a!==`\r`){let a=A(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new w(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}
188
- /*!
189
- * Copyright (c) Squirrel Chat et al., All rights reserved.
190
- * SPDX-License-Identifier: BSD-3-Clause
191
- *
192
- * Redistribution and use in source and binary forms, with or without
193
- * modification, are permitted provided that the following conditions are met:
194
- *
195
- * 1. Redistributions of source code must retain the above copyright notice, this
196
- * list of conditions and the following disclaimer.
197
- * 2. Redistributions in binary form must reproduce the above copyright notice,
198
- * this list of conditions and the following disclaimer in the
199
- * documentation and/or other materials provided with the distribution.
200
- * 3. Neither the name of the copyright holder nor the names of its contributors
201
- * may be used to endorse or promote products derived from this software without
202
- * specific prior written permission.
203
- *
204
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
205
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
206
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
207
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
208
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
209
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
210
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
211
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
212
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
213
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
214
- */
215
- function M(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function _e(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=D(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=j(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new w(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=M(n[0],r,i,t?2:1);if(!c)throw new w(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=j(e,s),i=M(r[0],a,o,0);if(!i)throw new w(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=A(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=D(e,s,!0),e[s]&&e[s]!==`
216
- `&&e[s]!==`\r`)throw new w(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=D(e,s)}return r}
217
- /*!
218
- * Copyright (c) Squirrel Chat et al., All rights reserved.
219
- * SPDX-License-Identifier: BSD-3-Clause
220
- *
221
- * Redistribution and use in source and binary forms, with or without
222
- * modification, are permitted provided that the following conditions are met:
223
- *
224
- * 1. Redistributions of source code must retain the above copyright notice, this
225
- * list of conditions and the following disclaimer.
226
- * 2. Redistributions in binary form must reproduce the above copyright notice,
227
- * this list of conditions and the following disclaimer in the
228
- * documentation and/or other materials provided with the distribution.
229
- * 3. Neither the name of the copyright holder nor the names of its contributors
230
- * may be used to endorse or promote products derived from this software without
231
- * specific prior written permission.
232
- *
233
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
234
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
235
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
236
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
237
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
238
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
239
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
240
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
241
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
242
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
243
- */
244
- let N=/^[a-z0-9-_]+$/i;function P(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function ve(e){for(let t=0;t<e.length;t++)if(P(e[t])!==`object`)return!1;return e.length!=0}function F(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function I(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:r&&Number.isInteger(e)?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return F(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return ye(e,n,r);if(t===`array`)return be(e,n,r)}function ye(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=N.test(o)?o:F(o),i+=` = `,i+=I(e[o],P(e[o]),t-1,n)}return i+` }`}function be(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=I(e[i],P(e[i]),t-1,n)}return r+` ]`}function xe(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
245
- `}[[${t}]]\n`,i+=L(0,e[a],t,n,r);return i}function L(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=P(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=N.test(c)?c:F(c);if(e===`array`&&ve(t[c]))o+=(o&&`
246
- `)+xe(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
247
- `)+L(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=I(t[c],e,r,i),a+=`
248
- `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Se(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(P(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=L(0,e,``,t,n);return r[r.length-1]===`
249
- `?r:r+`
250
- `}const R=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],Ce=[`@inkeep/open-knowledge`,`mcp`],we={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function z(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=ee(e);if(f(t)===`cli.mjs`&&f(p(t))===`dist`)return t;let n=t.split(_),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);return m(i.length===0?_:i.join(_),`packages`,`cli`,`dist`,`cli.mjs`)}function B(e={}){return e.cliPath?{command:e.cliPath,args:[`mcp`]}:e.mode===`dev`?{command:`node`,args:[z(e.cliEntryPath),`mcp`],env:{...we}}:{command:`npx`,args:[...Ce]}}function V(e){return e===`win32`?v:h}function Te(e={}){let t=e.platformName??process.platform,n=e.home??C(),r=e.env??process.env,i=V(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 Ee(e={}){let t=e.platformName??process.platform,n=e.home??C();return V(t).join(n,`.claude.json`)}function H(e={}){let t=e.platformName??process.platform,n=e.home??C(),r=e.env??process.env;if(t===`darwin`)return h.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??v.join(n,`AppData`,`Roaming`);return v.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??C();return V(t).join(n,`.cursor`,`mcp.json`)}function W(e={}){return V(e.platformName??process.platform).join(Te(e),`Code`,`User`,`mcp.json`)}function G(e={}){let t=e.platformName??process.platform,n=e.home??C();return V(t).join(n,`.codeium`,`windsurf`,`mcp_config.json`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??C();return(e.env??process.env).CODEX_HOME??V(t).join(n,`.codex`)}function K(e={}){return V(e.platformName??process.platform).join(De(e),`config.toml`)}function q(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>q(e,t[n]));if(d(e)&&d(t)){let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((e,t)=>e===r[t])&&n.every(n=>q(e[n],t[n]))}return!1}function Oe(e,t){return Object.entries(t).every(([t,n])=>q(e[t],n))}function ke(e,t){return{...e,...t}}function J(e){return{...e,isCompatible(t,n,r){return Oe(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return ke(t,e.buildEntry(n,r))}}}const Y={claude:J({id:`claude`,label:`Claude Code`,configPath:(e,t)=>Ee({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>m(t??C(),`.claude`),legacyProjectConfigPath:e=>m(e,`.mcp.json`)}),"claude-desktop":J({id:`claude-desktop`,label:`Claude Desktop`,configPath:(e,t)=>H({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(H({home:t}))}),cursor:J({id:`cursor`,label:`Cursor`,configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(U({home:t})),legacyProjectConfigPath:e=>m(e,`.cursor`,`mcp.json`)}),vscode:J({id:`vscode`,label:`VS Code`,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`servers`,serverName:()=>t,buildEntry:(e,t)=>({type:`stdio`,...B(t)}),scope:`global`,detectPath:(e,t)=>p(W({home:t})),legacyProjectConfigPath:e=>m(e,`.vscode`,`mcp.json`)}),windsurf:J({id:`windsurf`,label:`Windsurf`,configPath:(e,t)=>G({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(G({home:t}))}),codex:J({id:`codex`,label:`Codex`,configPath:(e,t)=>K({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(K({home:t})),legacyProjectConfigPath:e=>m(e,`.codex`,`config.toml`)})};function Ae(e){let t=e.filter(e=>!(e in Y));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${R.join(`, `)}`);return e.map(e=>Y[e])}function je(e){if(!y(e))return{};let t=x(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(d(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function Me(e){if(!y(e))return{};let t=x(e,`utf-8`).trim();if(t===``)return{};try{let n=_e(t);if(d(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function Ne(e,t){b(p(e),{recursive:!0}),S(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function Pe(e,t){b(p(e),{recursive:!0});let n=Se(t);S(e,n.endsWith(`
251
- `)?n:`${n}\n`,`utf-8`)}const Fe=`0.0.1`,X=`open-knowledge-ui`;function Ie(e,t={}){let n=m(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[z(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!y(n))return b(p(n),{recursive:!0}),S(n,`${JSON.stringify({version:Fe,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let e=x(n,`utf-8`).trim(),t=e?JSON.parse(e):{};if(!d(t))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let i=Array.isArray(t.configurations)?t.configurations:[],a=i.findIndex(e=>d(e)&&e.name===X);a>=0?i[a]=r:i.push(r);let o={...t,version:t.version??Fe,configurations:i};return S(n,`${JSON.stringify(o,null,2)}\n`,`utf-8`),{action:a>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function Z(e,t,n){try{return y(e.detectPath?.(t,n)??p(e.configPath(t,n)))}catch{return!1}}function Q(e,t,n,r){let i=e.serverName(t),a;try{a=e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:i,error:t instanceof Error?t.message:String(t)}}if(!n.skipAvailabilityCheck&&!Z(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:a,serverName:i};let o;try{o=e.format===`toml`?Me(a):je(a)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}let s=o[e.topLevelKey]??{},c=s[i],l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}let u={...o,[e.topLevelKey]:{...s,[i]:l}};try{e.format===`toml`?Pe(a,u):Ne(a,u)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:c===void 0?`written`:`overwritten`,configPath:a,serverName:i}}function Le(e,t){let n=e.legacyProjectConfigPath?.(t);if(!(!n||!y(n)))return{editorId:e.id,label:e.label,path:n}}async function Re(e){let t=Ae(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Q(t,``,n,e.home))}function ze(e,t,n){let r;try{r=e.configPath(t,n)}catch{return null}let i;try{i=e.format===`toml`?Me(r):je(r)}catch{return null}let a=i[e.topLevelKey];if(!d(a))return null;let o=a[e.serverName(t)];return d(o)?o:null}async function Be(e={}){let t=ee(e.cwd??process.cwd()),n={mode:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},i=await o(t),c;try{c=s(t)}catch(n){let r=Y.claude.configPath(t,e.home);return{contentCreated:[],contentSkipped:[],editors:[],legacyProjectConfigs:[],didGitInit:i.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:r,mcpError:`Content scaffolding failed: ${n instanceof Error?n.message:String(n)}`}}let l=Ae(e.editors??$(t,e.home)),u=l.filter(n=>Z(n,t,e.home)),d=[];for(let r of l){if(e.mcp===!1){let n=``;try{n=r.configPath(t,e.home)}catch{}d.push({editorId:r.id,label:r.label,action:`skipped-flag`,configPath:n,serverName:r.serverName(t)});continue}d.push(Q(r,t,n,e.home))}let f=e.mcp===!1?[]:u.map(e=>Le(e,t)).filter(e=>e!==void 0),p=u.some(e=>e.id===`claude`)&&e.mcp!==!1?Ie(t,n):void 0,m=await(e.installUserSkill??a)({home:e.home}),h=r({home:e.home}),g=e.mcp===!1?`skipped-flag`:`skipped-missing`,_=d.find(e=>e.editorId===`claude`)??d[0]??{action:g,configPath:Y.claude.configPath(t,e.home)};return{contentCreated:c.created,contentSkipped:c.skipped,editors:d,legacyProjectConfigs:f,launchJson:p,skillInstall:m,didGitInit:i.didInit,claudeDesktopDetected:h,mcpAction:_.action,mcpPath:_.configPath,mcpError:`error`in _?_.error:void 0}}function Ve(e,t){let r=[],i=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),a=e.editors.some(e=>e.action===`failed`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),s=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),d=e=>{let n=e.configPath.startsWith(t)?g(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&r.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let f=m(t,n);if(e.contentCreated.length>0?(r.push(`Content scaffolded at ${f}/`),r.push(` Created: ${e.contentCreated.join(`, `)}`)):r.push(`Content already present at ${f}/`),e.contentSkipped.length>0&&r.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),r.push(``),e.mcpError&&e.editors.length===0)r.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)r.push(`MCP server configuration:`),r.push(e.mcpAction===`skipped-flag`?` MCP config not written — use without --no-mcp to configure editors`:` No supported editor config directories detected; skipped MCP registration`);else if(o)r.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)r.push(`MCP server configuration:`),r.push(` No supported editor config directories detected; skipped MCP registration`);else{r.push(`MCP server configuration:`);for(let n of e.editors){let i=n.configPath.startsWith(t)?g(t,n.configPath):n.configPath.replace(/^\/Users\/[^/]+/,`~`),a=n.serverName===`open-knowledge`?``:` (${n.serverName})`,o=` `.repeat(Math.max(1,14-n.label.length)),s=n.editorId===`claude-desktop`&&(n.action===`written`||n.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(n.action){case`written`:r.push(` ${n.label}${o}${i} registered${a}${s}`);break;case`overwritten`:r.push(` ${n.label}${o}${i} updated${a}${s}`);break;case`skipped-missing`:r.push(` ${n.label}${o}${i} config root missing; skipped`);break;case`failed`:r.push(` ${n.label}${o}${i} FAILED: ${n.error}`);break;case`skipped-flag`:break}n.editorId===`claude`&&e.launchJson&&r.push(d(e.launchJson))}}if(a&&(r.push(``),r.push(`For failed editors, add the MCP server entry manually. See:`),r.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){r.push(``),r.push(`Legacy project MCP configs detected:`);for(let n of e.legacyProjectConfigs)r.push(` ${n.label} ${g(t,n.path)}`);r.push(` These project-local files may override the new global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(r.push(``),r.push(`User-global skill:`),e.skillInstall){case`installed`:r.push(" open-knowledge installed to detected agent hosts via `npx skills`");break;case`skip-current`:r.push(` open-knowledge already installed at current version`);break;case`failed`:r.push(` ${l(`open-knowledge install failed — MCP still configured; run manually:`)}`),r.push(` ${l(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(r.push(``),r.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${u(`ok install-skill`)}`)),e.preview?(r.push(``),r.push(c(e.preview,t))):e.previewWarning&&(r.push(``),r.push(`Content preview unavailable: ${e.previewWarning}`)),i){let t=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.label);r.push(``),r.push(`Next steps:`),r.push(` 1. Open your editor (${t.join(` / `)})`),r.push(` 2. Approve the MCP server when prompted`),r.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),r.push(` - ok seed`),r.push(` 4. Use the three MCP workflow tools as you build the wiki:`),r.push(` - mcp__open-knowledge__ingest — capture an external source`),r.push(` - mcp__open-knowledge__research — gather sources and write findings`),r.push(` - mcp__open-knowledge__consolidate — promote research to canonical articles`)}return r.join(`
252
- `)}function $(e,t){let n=[];for(let r of R)Z(Y[r],e,t)&&n.push(r);return n}function He(){return new e(`init`).description(`Scaffold ${n}/ 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 ${n}/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).action(async e=>{let t=process.cwd(),n;try{n=await Be({cwd:t,mcp:e.mcp,devMcp:e.devMcp})}catch(e){if(e instanceof i){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
253
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-EfkiZS-n.mjs`),{loadConfig:r}=await import(`./loader-Bc5pJk1m.mjs`),{resolveContentDir:i}=await import(`./paths-CDgE-NKk.mjs`),{config:a}=r(t),o=i(a,t);n.preview=e({projectDir:t,contentDir:o,include:a.content.include,exclude:a.content.exclude})}catch(e){n.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${Ve(n,t)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{Be as a,R as c,ze as i,Y as l,Ve as n,Q as o,He as r,Re as s,$ as t};
254
- //# sourceMappingURL=init-DNs9ffRY.mjs.map
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-C9LBHYiT.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./paths-zc2uvZxY.mjs";export{t as resolveContentDir,e as resolveLockDir};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-CPxqdDCe.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +0,0 @@
1
- import{i as e,n as t,r as n,t as r}from"./index-CjMTCid5.js";export{r as McpConsentDialogBody,r as default,t as computeInitialSelection,n as selectedIdsOrdered,e as toggleSelectedId};
@@ -1,2 +0,0 @@
1
- import{t as e}from"./rolldown-runtime-wcPFST8Q-BB0WpHs3.mjs";import{resolve as t}from"node:path";import{closeSync as n,existsSync as r,mkdirSync as i,openSync as a,readFileSync as o,unlinkSync as s,writeFileSync as c,writeSync as l}from"node:fs";import{hostname as u}from"node:os";function d(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}var f=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function p(e,n){return t(e,`${n}.lock`)}const m=new Map;function h(e){m.set(e,(m.get(e)??0)+1)}function g(e){let t=m.get(e);return t===void 0||t<=1?(m.delete(e),!0):(m.set(e,t-1),!1)}function _(e,t){try{let n=JSON.parse(o(e,`utf-8`));return n&&typeof n==`object`&&typeof n.pid==`number`?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function v(e){let{lockName:t,lockDir:o,metadata:m}=e,g=`[${t}-lock]`;i(o,{recursive:!0});let v=p(o,t),b={pid:process.pid,hostname:u(),port:m.port,startedAt:new Date().toISOString(),worktreeRoot:m.worktreeRoot,...m.kind!==void 0&&{kind:m.kind},...m.parentPid!==void 0&&{parentPid:m.parentPid},...m.capabilities!==void 0&&{capabilities:m.capabilities}},x=JSON.stringify(b,null,2);for(let e=0;e<3;e++){if(!r(v))try{let e=a(v,`wx`,384);try{l(e,x)}finally{n(e)}return h(v),y({lockName:t,lockDir:o,lockPath:v})}catch(e){if(e.code!==`EEXIST`)throw e}let e=_(v,g);if(e){let n=e.hostname===u();if(n&&e.pid===process.pid)return c(v,x,{encoding:`utf-8`,mode:384}),h(v),y({lockName:t,lockDir:o,lockPath:v});if(n&&d(e.pid))throw new f(e,v,t);console.warn(`${g} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{s(v)}catch{}}throw Error(`${g} Failed to acquire ${v} after 3 attempts (concurrent acquire contention).`)}function y(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>S({lockName:t,lockDir:n}),updatePort:e=>b({lockName:t,lockDir:n,port:e})}}function b(e){let{lockName:t,lockDir:n,port:i}=e,a=`[${t}-lock]`,s=p(n,t);if(!r(s)){console.warn(`${a} Lock file missing at ${s} during port update — skipping`);return}let l;try{let e=JSON.parse(o(s,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`){console.warn(`${a} Corrupt lock at ${s} during port update — skipping`);return}l=e}catch{console.warn(`${a} Unreadable lock at ${s} during port update — skipping`);return}if(l.pid===process.pid&&!(typeof l.hostname==`string`&&l.hostname!==u())){l.port=i;try{c(s,JSON.stringify(l,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function x(e){let{lockName:t,lockDir:n}=e,i=p(n,t);if(!r(i))return null;let a;try{let e=JSON.parse(o(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`)return null;a=e}catch{return null}if(a.hostname!==u())return null;if(!d(a.pid)){try{s(i)}catch{}return null}return a}function S(e){let{lockName:t,lockDir:n}=e,i=`[${t}-lock]`,a=p(n,t);if(g(a)&&r(a))try{let e=JSON.parse(o(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==u())return;s(a)}catch(e){console.warn(`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}var C=e({ServerLockCollisionError:()=>w,acquireServerLock:()=>T,readServerLock:()=>D,releaseServerLock:()=>O,updateServerLockPort:()=>E}),w=class extends f{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function T(e,t){try{return v({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof f&&e.lockName===`server`?new w(e.existing,e.lockPath):e}}function E(e,t){b({lockName:`server`,lockDir:e,port:t})}function D(e){return x({lockName:`server`,lockDir:e})}function O(e){S({lockName:`server`,lockDir:e})}export{d as a,D as c,C as d,b as f,T as i,S as l,w as n,p as o,E as p,v as r,x as s,f as t,O as u};
2
- //# sourceMappingURL=server-lock-QiPvrcO9-A3jWEIJ6.mjs.map
@@ -1 +0,0 @@
1
- import{d as e}from"./server-lock-QiPvrcO9-A3jWEIJ6.mjs";export{e as a};
@@ -1 +0,0 @@
1
- import"./init-DNs9ffRY.mjs";import"./loader-C9LBHYiT.mjs";export{};
@@ -1 +0,0 @@
1
- import{o as e}from"./start-BnROvKwD.mjs";export{e as startCommand};