@inkeep/open-knowledge 0.41.2 → 0.41.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/{acp-harness-probe-Ba7DTFOh.mjs → acp-harness-probe-dWM8QqyG.mjs} +2 -2
  2. package/dist/assets/skills/discovery/SKILL.md +1 -1
  3. package/dist/assets/skills/project/SKILL.md +1 -1
  4. package/dist/cli.mjs +45 -45
  5. package/dist/constants-BsMWdC-D.mjs +2 -0
  6. package/dist/{git-handle-ZhJgz79A.mjs → git-handle-C0Vkx9lA.mjs} +2 -2
  7. package/dist/git-handle-z2kbZHY3.mjs +1 -0
  8. package/dist/index.d.mts +3 -3
  9. package/dist/index.mjs +1 -1
  10. package/dist/init-C1GOW1lc.mjs +1 -0
  11. package/dist/{init-CBWhyX1U.mjs → init-DxYBLBvE.mjs} +4 -4
  12. package/dist/{launch-json-removal-0rPdkMtH.mjs → launch-json-removal-B9b5arZ-.mjs} +2 -2
  13. package/dist/loader-DAgcKHeV.mjs +1 -0
  14. package/dist/{loader-C0DzGeNZ.mjs → loader-LPkh4OOC.mjs} +2 -2
  15. package/dist/md-manager-B4y6B-tT.mjs +2 -0
  16. package/dist/{open-browser-BvP05JKj.mjs → open-browser-B4QMCuDE.mjs} +2 -2
  17. package/dist/parse-worker.mjs +1 -1
  18. package/dist/preview-D6cRXhqM.mjs +1 -0
  19. package/dist/{preview-Dn1YxNMX.mjs → preview-IcKq7IAx.mjs} +2 -2
  20. package/dist/public/assets/{ActivityModeContent-BPE8dCmt.js → ActivityModeContent-V56HhfHm.js} +1 -1
  21. package/dist/public/assets/{AgentDiffPane-DBIJrjq2.js → AgentDiffPane-DnNDgiq4.js} +1 -1
  22. package/dist/public/assets/{AgentThreadClientBinder-DIlw7iBC.js → AgentThreadClientBinder-Dg8x_dvd.js} +1 -1
  23. package/dist/public/assets/{CodeMirrorPropInput-RC4sdh9E.js → CodeMirrorPropInput-CiPNj8ti.js} +1 -1
  24. package/dist/public/assets/{DocumentContext-DhKWMrL2.js → DocumentContext-BKR16aYr.js} +2 -2
  25. package/dist/public/assets/{EditorModeToggle-EBc2Cv8z.js → EditorModeToggle-D8dxPhYZ.js} +1 -1
  26. package/dist/public/assets/{EnableSyncConfirmDialog-Dv9jJ1OH.js → EnableSyncConfirmDialog-BzDGK1B9.js} +1 -1
  27. package/dist/public/assets/FeedbackForm-B-fO65RC.js +1 -0
  28. package/dist/public/assets/{GraphPanel-DBxTtvfS.js → GraphPanel-BB3PZd_i.js} +1 -1
  29. package/dist/public/assets/{LintConfigEditor-COmMwK8k.js → LintConfigEditor-DtvxnniJ.js} +1 -1
  30. package/dist/public/assets/{ManagedArtifactProperties-urT0cuW8.js → ManagedArtifactProperties-DYQ1JUmF.js} +1 -1
  31. package/dist/public/assets/{McpConsentDialogBody-QnsIyr5m.js → McpConsentDialogBody-DscJLJPg.js} +1 -1
  32. package/dist/public/assets/{MermaidDocEditor-CNmMqMG0.js → MermaidDocEditor-wUCR0srX.js} +1 -1
  33. package/dist/public/assets/{PropertyPanel-mY4SzTn-.js → PropertyPanel-CckAc_Sq.js} +1 -1
  34. package/dist/public/assets/{ReportBugDialogBody-D6DyX_AO.js → ReportBugDialogBody-BMejD0M2.js} +1 -1
  35. package/dist/public/assets/{SchemaConfigEditor-DOlc8PRA.js → SchemaConfigEditor-nuU-YHpP.js} +1 -1
  36. package/dist/public/assets/{SettingsDialogBody-DT5rxl3R.js → SettingsDialogBody-DNdlho-U.js} +1 -1
  37. package/dist/public/assets/{ShareBranchSwitchDialog-DOd9FqHR.js → ShareBranchSwitchDialog-BzvjNuw_.js} +1 -1
  38. package/dist/public/assets/{ShareReceiveDialog-WarQNnjb.js → ShareReceiveDialog-CznGTWez.js} +1 -1
  39. package/dist/public/assets/{ShareReceiveMissDialog-B4qzjtcO.js → ShareReceiveMissDialog-BKcrHSOs.js} +1 -1
  40. package/dist/public/assets/{SkillEditorActions-BgCcV1OO.js → SkillEditorActions-C7jWaMNZ.js} +1 -1
  41. package/dist/public/assets/{SourceEditor-iS9U8XVV.js → SourceEditor-DVqYQflP.js} +1 -1
  42. package/dist/public/assets/{TerminalPanel-DCL0YXc0.js → TerminalPanel-CDDchf68.js} +1 -1
  43. package/dist/public/assets/{TerminalSessionsHost-CjgiUwL3.js → TerminalSessionsHost-DEXiA3WZ.js} +2 -2
  44. package/dist/public/assets/{TerminalWindowApp-BZhG11Jf.js → TerminalWindowApp-CSzPSa7h.js} +1 -1
  45. package/dist/public/assets/{ThreadView-BExAZkQQ.js → ThreadView-CoHq4aL7.js} +1 -1
  46. package/dist/public/assets/{TimelineDiffPane-BBVTd7ZF.js → TimelineDiffPane-BTaUZ3Kb.js} +1 -1
  47. package/dist/public/assets/{agent-diff-store-C_yI-auj.js → agent-diff-store-CE54PhoR.js} +1 -1
  48. package/dist/public/assets/{agent-visibility-BKKH1E-K.js → agent-visibility-BsnQwNdc.js} +1 -1
  49. package/dist/public/assets/{auth-state-cache-BYWBVAT1.js → auth-state-cache-nPfU5e_O.js} +7 -7
  50. package/dist/public/assets/{client-version-D0idjqLu.js → client-version-C9dKI6XY.js} +1 -1
  51. package/dist/public/assets/{config-provider-DDGPIoo7.js → config-provider-DNKyP_6q.js} +1 -1
  52. package/dist/public/assets/{dist-DgX6o3Xd.js → dist-BGfU2QP2.js} +1 -1
  53. package/dist/public/assets/{doc-hash-CzmSG2uM.js → doc-hash-BSk1YYn9.js} +1 -1
  54. package/dist/public/assets/{documents-events-0MJ8ER3I.js → documents-events-BtgGTIqA.js} +1 -1
  55. package/dist/public/assets/{file-tree-adapter-DGXFJhkO.js → file-tree-adapter-C0J3tc2q.js} +1 -1
  56. package/dist/public/assets/{file-tree-utils-BvgxJuFW.js → file-tree-utils-DAVYMBYf.js} +1 -1
  57. package/dist/public/assets/{globals-CpkAXqfZ.js → globals-CnEbugkx.js} +1 -1
  58. package/dist/public/assets/{index-DDSda67s.js → index-CQ4DveM_.js} +7 -7
  59. package/dist/public/assets/{lint-config-client-DXbikwgI.js → lint-config-client-CNmTHHQl.js} +1 -1
  60. package/dist/public/assets/{markdownlint-rule-browser-DHpnQBnJ.js → markdownlint-rule-browser-IrQQnbe7.js} +1 -1
  61. package/dist/public/assets/{navigation-targets-Bo1TKplU.js → navigation-targets-CGUSVL6j.js} +1 -1
  62. package/dist/public/assets/{open-managed-artifact-tab-Dvme3cv4.js → open-managed-artifact-tab-CxOXkAIY.js} +1 -1
  63. package/dist/public/assets/{pending-receive-nav-store-CVH9OLs-.js → pending-receive-nav-store-D4kTIsaK.js} +1 -1
  64. package/dist/public/assets/{prop-types-BjU4ptk9.js → prop-types-Benz74B2.js} +1 -1
  65. package/dist/public/assets/{receive-store-DHX5arqk.js → receive-store-DbySZt8N.js} +1 -1
  66. package/dist/public/assets/{selection-context-Cp7p3Q_N.js → selection-context-DCJMxWzU.js} +1 -1
  67. package/dist/public/assets/{skill-actions-bZFiRAYm.js → skill-actions-S0UIcdB8.js} +1 -1
  68. package/dist/public/assets/{skills-api-DstI-vVv.js → skills-api-D8XA69bH.js} +1 -1
  69. package/dist/public/assets/{src-CAZXe_Ov.js → src-DrSxCOVW.js} +1 -1
  70. package/dist/public/assets/{tag-pill-input-C7Caa2Cw.js → tag-pill-input-CScqBN3p.js} +1 -1
  71. package/dist/public/assets/{target-navigation-intent-B54BgTCv.js → target-navigation-intent-mVGCycSm.js} +1 -1
  72. package/dist/public/assets/{terminal-launch-events-DG8hI3w-.js → terminal-launch-events-BMUxfSI9.js} +1 -1
  73. package/dist/public/assets/{terminal-telemetry-DSZCcYb_.js → terminal-telemetry-BbC-kUyB.js} +1 -1
  74. package/dist/public/assets/{typing-burst-detector-DfFn9ASH.js → typing-burst-detector-w83TGJFT.js} +1 -1
  75. package/dist/public/assets/{uninstall-C2rwdK6e.js → uninstall-B8_uL8NV.js} +1 -1
  76. package/dist/public/assets/{use-activity-panel-CHsvsZ8L.js → use-activity-panel-YhP8vGtR.js} +1 -1
  77. package/dist/public/assets/{use-apply-config-color-theme-Gy3JNvol.js → use-apply-config-color-theme-u-JcfGJu.js} +1 -1
  78. package/dist/public/assets/{use-collab-url-9qlw7MfN.js → use-collab-url-DRZdoC-F.js} +1 -1
  79. package/dist/public/assets/{use-live-xterm-theme-7CBgYc0a.js → use-live-xterm-theme-DcxHtUZd.js} +1 -1
  80. package/dist/public/assets/{use-settings-route-DEm8dDzV.js → use-settings-route-CcWyPW0f.js} +1 -1
  81. package/dist/public/assets/{use-terminal-enabled-Bx_nsTHh.js → use-terminal-enabled-DznqTIoa.js} +1 -1
  82. package/dist/public/assets/{use-timeline-entry-diff-Y2CdT0M4.js → use-timeline-entry-diff-CYoaYTqW.js} +1 -1
  83. package/dist/public/assets/{use-workspace-DnIHeQAh.js → use-workspace-RSGV5qeq.js} +1 -1
  84. package/dist/public/assets/{workspace-paths-CGx2PUFr.js → workspace-paths-CTLwXmK5.js} +1 -1
  85. package/dist/public/index.html +36 -36
  86. package/dist/public/uninstall.html +3 -3
  87. package/dist/{repair-launch-json-BVxKvPAo.mjs → repair-launch-json-DTEGmN1O.mjs} +2 -2
  88. package/dist/{repair-mcp-configs-CL00iu8h.mjs → repair-mcp-configs-CRoM0Ijk.mjs} +2 -2
  89. package/dist/repair-skills-BNFFh5kk.mjs +1 -0
  90. package/dist/{repair-skills-xgU4BBSK.mjs → repair-skills-XXmzc0-v.mjs} +2 -2
  91. package/dist/{server-lock-D7lpEbZj.mjs → server-lock-NDXM24F6.mjs} +2 -2
  92. package/dist/server-lock-l_qcQskg.mjs +1 -0
  93. package/dist/{src-3SN72BHH.mjs → src-BTs5LPkM.mjs} +20 -20
  94. package/dist/src-BbntdRLo.mjs +3265 -0
  95. package/dist/{src-CxD3JHmH.mjs → src-CAK6XVGy.mjs} +6 -6
  96. package/dist/src-CdRO3m1f.mjs +1 -0
  97. package/dist/start-BpCmMdYn.mjs +1 -0
  98. package/dist/{start-5e_XN39i.mjs → start-DtLzPL0C.mjs} +2 -2
  99. package/dist/{write-project-skill-4OvW1cn1.mjs → write-project-skill-C-xPIQus.mjs} +3 -3
  100. package/package.json +4 -4
  101. package/dist/constants-Ej-ZzjYT.mjs +0 -2
  102. package/dist/git-handle-Cg7vsIVu.mjs +0 -1
  103. package/dist/init-BHsIRFIC.mjs +0 -1
  104. package/dist/loader-CjpqkbhW.mjs +0 -1
  105. package/dist/md-manager-BOzKVLRL.mjs +0 -2
  106. package/dist/preview-DSJriqm9.mjs +0 -1
  107. package/dist/public/assets/FeedbackForm-Bb9Yf3Zz.js +0 -1
  108. package/dist/repair-skills-DnayrFzZ.mjs +0 -1
  109. package/dist/server-lock-CIl-U-as.mjs +0 -1
  110. package/dist/src-Cf8OhPA7.mjs +0 -1
  111. package/dist/src-DAzaO37g.mjs +0 -3265
  112. package/dist/start-DULQ0fI2.mjs +0 -1
@@ -1,6 +1,6 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,ka as r}from"./src-3SN72BHH.mjs";import{Ai as i,ct as a,hn as o,lt as s,ot as c,st as l,ui as u,ya as d}from"./src-DAzaO37g.mjs";import{K as f}from"./sleep-B2L0pvp4.mjs";import{O as p,P as m}from"./fs-traced-Cc6WsRtP.mjs";import{b as h,u as g,v as _,y as v}from"./server-lock-D7lpEbZj.mjs";import{t as y}from"./yazl-BafwB467.mjs";import{C as b,d as x,i as ee,v as te,y as S}from"./write-project-skill-4OvW1cn1.mjs";import{c as ne}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-Ba7DTFOh.mjs";import{D as re,E as ie,S as C,T as w,_ as ae,b as oe,o as T,v as E}from"./init-CBWhyX1U.mjs";import{n as D}from"./constants-Ej-ZzjYT.mjs";import{t as O}from"./is-object-ByG7RnjH.mjs";import"./loader-C0DzGeNZ.mjs";import"./preview-Dn1YxNMX.mjs";import{execSync as se,spawnSync as k}from"node:child_process";import{basename as A,dirname as j,isAbsolute as M,join as N,relative as ce,resolve as P,sep as le}from"node:path";import{cpSync as ue,createWriteStream as de,existsSync as F,lstatSync as fe,mkdirSync as I,mkdtempSync as pe,readFileSync as L,readdirSync as me,readlinkSync as he,rmSync as ge,statSync as _e,writeFileSync as R}from"node:fs";import{arch as ve,freemem as ye,homedir as be,hostname as xe,platform as Se,release as Ce,tmpdir as we,totalmem as Te,type as Ee,uptime as De}from"node:os";import{realpath as z}from"node:fs/promises";import{createHash as B}from"node:crypto";var V=f();const Oe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ke(e,t,n=o){if(e!==void 0&&!Oe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ae=null;function je(e){Ae=e}function Me(){return Ae??process.cwd()}const Ne=[{name:`macos-home-path`,regex:/\/Users\/[^/]+\//g,replacement:`~/`},{name:`linux-home-path`,regex:/\/home\/[^/]+\//g,replacement:`~/`},{name:`github-pat`,regex:/\b(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9]{36,}\b/g,replacement:`[REDACTED-GH-PAT]`},{name:`aws-access-key`,regex:/\b(AKIA|ASIA|ABIA)[A-Z2-7]{16}\b/g,replacement:`[REDACTED-AWS-KEY]`},{name:`anthropic-key`,regex:/\bsk-ant-api03-[A-Za-z0-9_-]{20,}\b/g,replacement:`[REDACTED-ANTHROPIC]`},{name:`openai-key`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g,replacement:`[REDACTED-OPENAI]`},{name:`bearer-token`,regex:/([Aa]uthorization:\s*[Bb]earer\s+)\S+/g,replacement:`$1[REDACTED]`},{name:`jwt`,regex:/eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,replacement:`[REDACTED-JWT]`},{name:`url-credentials`,regex:/:\/\/[^/\s:@]+:[^/\s:@]+@/g,replacement:`://[REDACTED]@`}],Pe=Ne.map(e=>e.name);function H(e){let t=new Set,n=0;return{redacted:e.split(`
1
+ import{o as e}from"./chunk-DTipWd-i.mjs";import{Aa as t,F as n,I as r}from"./src-BTs5LPkM.mjs";import{Ai as i,ct as a,hn as o,lt as s,ot as c,st as l,ui as u,ya as d}from"./src-BbntdRLo.mjs";import{K as f}from"./sleep-B2L0pvp4.mjs";import{O as p,P as m}from"./fs-traced-Cc6WsRtP.mjs";import{b as h,u as g,v as _,y as v}from"./server-lock-NDXM24F6.mjs";import{t as y}from"./yazl-BafwB467.mjs";import{C as b,d as x,i as ee,v as te,y as S}from"./write-project-skill-C-xPIQus.mjs";import{c as ne}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-dWM8QqyG.mjs";import{D as re,E as ie,S as C,T as w,_ as ae,b as oe,o as T,v as E}from"./init-DxYBLBvE.mjs";import{n as D}from"./constants-BsMWdC-D.mjs";import{t as O}from"./is-object-ByG7RnjH.mjs";import"./loader-LPkh4OOC.mjs";import"./preview-IcKq7IAx.mjs";import{execSync as se,spawnSync as k}from"node:child_process";import{basename as A,dirname as j,isAbsolute as M,join as N,relative as ce,resolve as P,sep as le}from"node:path";import{cpSync as ue,createWriteStream as de,existsSync as F,lstatSync as fe,mkdirSync as I,mkdtempSync as pe,readFileSync as L,readdirSync as me,readlinkSync as he,rmSync as ge,statSync as _e,writeFileSync as R}from"node:fs";import{arch as ve,freemem as ye,homedir as be,hostname as xe,platform as Se,release as Ce,tmpdir as we,totalmem as Te,type as Ee,uptime as De}from"node:os";import{realpath as z}from"node:fs/promises";import{createHash as B}from"node:crypto";var V=f();const Oe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ke(e,t,n=o){if(e!==void 0&&!Oe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ae=null;function je(e){Ae=e}function Me(){return Ae??process.cwd()}const Ne=[{name:`macos-home-path`,regex:/\/Users\/[^/]+\//g,replacement:`~/`},{name:`linux-home-path`,regex:/\/home\/[^/]+\//g,replacement:`~/`},{name:`github-pat`,regex:/\b(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9]{36,}\b/g,replacement:`[REDACTED-GH-PAT]`},{name:`aws-access-key`,regex:/\b(AKIA|ASIA|ABIA)[A-Z2-7]{16}\b/g,replacement:`[REDACTED-AWS-KEY]`},{name:`anthropic-key`,regex:/\bsk-ant-api03-[A-Za-z0-9_-]{20,}\b/g,replacement:`[REDACTED-ANTHROPIC]`},{name:`openai-key`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g,replacement:`[REDACTED-OPENAI]`},{name:`bearer-token`,regex:/([Aa]uthorization:\s*[Bb]earer\s+)\S+/g,replacement:`$1[REDACTED]`},{name:`jwt`,regex:/eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,replacement:`[REDACTED-JWT]`},{name:`url-credentials`,regex:/:\/\/[^/\s:@]+:[^/\s:@]+@/g,replacement:`://[REDACTED]@`}],Pe=Ne.map(e=>e.name);function H(e){let t=new Set,n=0;return{redacted:e.split(`
2
2
  `).map(e=>{let r=e;for(let{name:e,regex:i,replacement:a}of Ne)i.lastIndex=0,i.test(r)&&(t.add(e),n++,i.lastIndex=0,r=r.replace(i,a));return r}).join(`
3
- `),patterns:[...t],lineCount:n}}function Fe(){return N(be(),`.ok`,`bug-reports`)}function Ie(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`);return N(Fe(),`${t}-bugreport.zip`)}function Le(e,t){let n=N(e,`.ok`,`config.yml`);if(F(n))try{let e=L(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return F(N(e,`.ok`))?B(`sha256`).update(P(e)).digest(`hex`).slice(0,12):null}function Re(){let e={timestamp:new Date().toISOString(),platform:Se(),osType:Ee(),osRelease:Ce(),hostname:`[redacted]`,uptime:De(),freeMem:ye(),totalMem:Te(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=se(`sw_vers -productVersion 2>/dev/null`,u({encoding:`utf8`})).trim()}catch{}try{let t=N(__dirname,`..`,`..`,`package.json`);F(t)&&(e.okVersion=JSON.parse(L(t,`utf8`)).version)}catch{}return e}function ze(e,t){if(!F(t))return{files:[]};let n=me(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>N(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return L(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function Be(e){let n=N(e,`.ok`,`local`);return F(n)?{files:[`server.lock`,`last-spawn-error.log`,t].map(e=>N(n,e)).filter(e=>F(e))}:{files:[]}}function Ve(e){let t=N(e,`.ok`,`local`,`logs`);return F(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>N(t,e)).filter(e=>F(e))}:{files:[]}}function He(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=H(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function U(e){for(let t of e.files)try{He({zipfile:e.zipfile,name:`${e.prefix}/${A(t)}`,content:L(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Ue(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??N(be(),`.ok`,`logs`),o=t.projectDir?Le(t.projectDir,i):null;I(j(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let s=Re();s.desktop=t.desktop??null;let{files:c}=ze(o,a),{files:l}=t.projectDir?Be(t.projectDir):{files:[]},{files:u}=t.projectDir?Ve(t.projectDir):{files:[]};i?.info({logFileCount:c.length,lockFileCount:l.length,localSinkFileCount:u.length},`files collected`);let d=[],f=[],{ZipFile:p}=await import(`./yazl-vwTkB7U0.mjs`).then(t=>e(t.default,1)),m=new p;U({zipfile:m,files:c,prefix:`logs`,redact:n,bundleFiles:f,redactions:d,logger:i}),U({zipfile:m,files:l,prefix:`lockdir`,redact:n,bundleFiles:f,redactions:d,logger:i}),U({zipfile:m,files:u,prefix:`local-logs`,redact:n,bundleFiles:f,redactions:d,logger:i});for(let e of t.extraFiles??[])try{let t=L(e.sourcePath),n=`extra/${e.zipName??A(e.sourcePath)}`;m.addBuffer(t,n),f.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&He({zipfile:m,name:`note.txt`,content:t.note,redact:n,bundleFiles:f,redactions:d});let h=JSON.stringify(s,null,2);m.addBuffer(Buffer.from(h,`utf8`),`sysinfo.json`),f.push(`sysinfo.json`);let g={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:f,redactions:d,sysinfo:s};m.addBuffer(Buffer.from(JSON.stringify(g,null,2),`utf8`),`MANIFEST.json`);let _=d.reduce((e,t)=>e+t.lineCount,0),v=[`# Bug Report Bundle`,``,`Generated: ${g.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${g.disciplineVersion}`,``,`## Contents`,``,...f.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${Pe.join(`, `)}`,_>0?`${_} line(s) were scrubbed across ${d.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
3
+ `),patterns:[...t],lineCount:n}}function Fe(){return N(be(),`.ok`,`bug-reports`)}function Ie(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`);return N(Fe(),`${t}-bugreport.zip`)}function Le(e,t){let n=N(e,`.ok`,`config.yml`);if(F(n))try{let e=L(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return F(N(e,`.ok`))?B(`sha256`).update(P(e)).digest(`hex`).slice(0,12):null}function Re(){let e={timestamp:new Date().toISOString(),platform:Se(),osType:Ee(),osRelease:Ce(),hostname:`[redacted]`,uptime:De(),freeMem:ye(),totalMem:Te(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=se(`sw_vers -productVersion 2>/dev/null`,u({encoding:`utf8`})).trim()}catch{}try{let t=N(__dirname,`..`,`..`,`package.json`);F(t)&&(e.okVersion=JSON.parse(L(t,`utf8`)).version)}catch{}return e}function ze(e,t){if(!F(t))return{files:[]};let n=me(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>N(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return L(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function Be(e){let t=N(e,`.ok`,`local`);return F(t)?{files:[`server.lock`,`last-spawn-error.log`,n].map(e=>N(t,e)).filter(e=>F(e))}:{files:[]}}function Ve(e){let t=N(e,`.ok`,`local`,`logs`);return F(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>N(t,e)).filter(e=>F(e))}:{files:[]}}function He(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=H(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function U(e){for(let t of e.files)try{He({zipfile:e.zipfile,name:`${e.prefix}/${A(t)}`,content:L(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Ue(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??N(be(),`.ok`,`logs`),o=t.projectDir?Le(t.projectDir,i):null;I(j(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let s=Re();s.desktop=t.desktop??null;let{files:c}=ze(o,a),{files:l}=t.projectDir?Be(t.projectDir):{files:[]},{files:u}=t.projectDir?Ve(t.projectDir):{files:[]};i?.info({logFileCount:c.length,lockFileCount:l.length,localSinkFileCount:u.length},`files collected`);let d=[],f=[],{ZipFile:p}=await import(`./yazl-vwTkB7U0.mjs`).then(t=>e(t.default,1)),m=new p;U({zipfile:m,files:c,prefix:`logs`,redact:n,bundleFiles:f,redactions:d,logger:i}),U({zipfile:m,files:l,prefix:`lockdir`,redact:n,bundleFiles:f,redactions:d,logger:i}),U({zipfile:m,files:u,prefix:`local-logs`,redact:n,bundleFiles:f,redactions:d,logger:i});for(let e of t.extraFiles??[])try{let t=L(e.sourcePath),n=`extra/${e.zipName??A(e.sourcePath)}`;m.addBuffer(t,n),f.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&He({zipfile:m,name:`note.txt`,content:t.note,redact:n,bundleFiles:f,redactions:d});let h=JSON.stringify(s,null,2);m.addBuffer(Buffer.from(h,`utf8`),`sysinfo.json`),f.push(`sysinfo.json`);let g={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:f,redactions:d,sysinfo:s};m.addBuffer(Buffer.from(JSON.stringify(g,null,2),`utf8`),`MANIFEST.json`);let _=d.reduce((e,t)=>e+t.lineCount,0),v=[`# Bug Report Bundle`,``,`Generated: ${g.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${g.disciplineVersion}`,``,`## Contents`,``,...f.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${Pe.join(`, `)}`,_>0?`${_} line(s) were scrubbed across ${d.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
4
4
  `);m.addBuffer(Buffer.from(v,`utf8`),`README.md`),m.end();let y=de(r);return m.outputStream.pipe(y),await new Promise((e,t)=>{y.on(`close`,e),y.on(`error`,t)}),i?.info({bundlePath:r,fileCount:f.length,redactionCount:_},`bundle written`),{zipPath:r,summary:{projectSlug:o,files:f,redactions:d,redactedLineCount:_,generatedAt:g.generatedAt}}}var We=e(y(),1),W=e(ne(),1);const Ge=new Set([`doc.name`,`currentDoc`]);function Ke(e){return`doc:${B(`sha256`).update(e).digest(`hex`).slice(0,8)}`}function qe(e,t,n){let r=e.docNameMap[n];if(r===void 0){e.docNameMap[n]=t;return}if(r===t)return;let i=e.docNameCollisions[n];i?i.includes(t)||i.push(t):e.docNameCollisions[n]=[t]}function Je(e,t){let n=t.originalToHashed.get(e);if(n!==void 0)return n;let r=Ke(e);return t.originalToHashed.set(e,r),qe(t,e,r),r}function G(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function K(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return G(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!K(e))return e;let n=typeof e.key==`string`&&Ge.has(e.key)&&K(e.value)&&typeof e.value.stringValue==`string`?e.value.stringValue:null,r={};for(let[i,a]of Object.entries(e))if(n!==null&&i===`value`&&K(a)){let e=Je(n,t);r[i]={...a,stringValue:e}}else Ge.has(i)&&typeof a==`string`?r[i]=Je(a,t):r[i]=q(a,t);return r}function Ye(e,t){if(t.originalToHashed.size===0)return e;let n=Array.from(t.originalToHashed.entries()).sort(([e],[t])=>t.length-e.length),r=e;for(let[e,t]of n)e.length!==0&&r.includes(e)&&(r=r.split(e).join(t));return r}function Xe(e,t){let n=L(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
5
5
  `),i=n.split(`
6
6
  `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=q(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}R(e,r?`${a.join(`
@@ -8,8 +8,8 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,ka as r}from"./src
8
8
  `))}function Ze(e,t){let n=L(e,`utf-8`);if(n.trim().length!==0)try{let r=q(JSON.parse(n),t),i=n.endsWith(`
9
9
  `)?`
10
10
  `:``;R(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Ye(G(n,t.contentDir),t);r!==n&&R(e,r)}}function Qe(e,t){let n=L(e,`utf-8`),r=G(n,t.contentDir);r!==n&&R(e,r)}function $e(e){try{return me(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>N(e,t.name))}catch{return[]}}const et=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function tt(e){let t={contentDir:e.contentDir,docNameMap:{},originalToHashed:new Map,docNameCollisions:{}};for(let n of[`telemetry`,`logs`,`process`])for(let r of $e(N(e.stagingDir,n)))r.endsWith(`.jsonl`)?Xe(r,t):r.endsWith(`.json`)?Ze(r,t):Qe(r,t);for(let n of $e(N(e.stagingDir,`state`))){let e=A(n);n.endsWith(`.jsonl`)?Xe(n,t):et.has(e)?Ze(n,t):Qe(n,t)}return{docNameMap:t.docNameMap,docNameCollisions:t.docNameCollisions}}const nt=[`.ok`,`local`,`telemetry`],rt=[`.ok`,`local`,`logs`],it=`spans-current.jsonl`,at=`spans-prev.jsonl`,ot=`server-current.jsonl`,st=`server-prev.jsonl`;function ct(e){return N(e,...nt,it)}function lt(e){return N(e,...nt,at)}function ut(e){return N(e,...rt,ot)}function dt(e){return N(e,...rt,st)}const ft=1e3;async function pt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(ft)});return t.ok?await t.text():null}catch{return null}}async function mt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(ft)});return t.ok?await t.text():null}catch{return null}}async function ht(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(ft)});return t.ok?await t.text():null}catch{return null}}function gt(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
11
- `)}\n`:null}catch{return null}}function _t(e){let t=N(e,`.git`,`ok`);if(!F(t))return null;let n=k(`git`,[`-C`,t,`log`,`--oneline`,`-50`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function vt(e){let t=N(e,`.git`,`ok`);if(!F(t))return null;let n=k(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function yt(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function bt(){return{nodeVersion:process.version,platform:Se(),arch:ve()}}function xt(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function St(e){if(!F(e))return{};let t;try{t=(0,V.parse)(L(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!J(t))return{};let n=t.telemetry;if(!J(n))return{};let r=n.localSink;return J(r)?r:{}}function Ct(e){return typeof e==`boolean`?e:void 0}function wt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return wt(e.maxBytes)}function Tt(e){let t=St(p(`project`,e)),n=St(p(`project-local`,e));return{enabled:Ct(n.enabled)??Ct(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Et(e){return B(`sha256`).update(e).digest(`hex`)}function Dt(e){let t=L(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Ot(e){let t=L(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X(e,t){return F(e)?(I(j(t),{recursive:!0}),ue(e,t),!0):!1}function kt(e){let t=[],n=e=>{let r=me(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const At=new Set([`.jsonl`]);function jt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:At.has(e.slice(t))}const Mt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Nt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Mt.has(e.slice(t))}function Pt(e){let t=[];for(let n of kt(e)){let r=Ft(e,n);if(!Nt(r))continue;let{redacted:i,patterns:a,lineCount:o}=H(L(n,`utf-8`));a.length!==0&&(R(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Ft(e,t){return ce(e,t).split(le).join(`/`)}async function It(e){let r=P(e.contentDir),i=P(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??pt,s=a.fetchAgentEffects??mt,c=a.fetchWatcherRecent??ht,l=a.readShadowHead??_t,u=a.readCheckpointRefs??vt,d=a.now??(()=>new Date),f=a.okVersion??(()=>D),p=a.readDesktopEnv??yt,m=a.readRuntime??bt,h=a.isOtlpPushEnabled??xt,g=pe(N(we(),`ok-bundle-`));try{I(N(g,`telemetry`),{recursive:!0}),I(N(g,`logs`),{recursive:!0}),I(N(g,`state`),{recursive:!0}),X(ct(i),N(g,`telemetry`,it)),X(lt(i),N(g,`telemetry`,at)),X(ut(i),N(g,`logs`,ot)),X(dt(i),N(g,`logs`,st));let _=N(i,`.ok`,`local`),v=N(_,`server.lock`),y=`not-running`,b=`no server.lock`,x=null;if(F(v)){X(v,N(g,`state`,`server.lock`));try{let e=L(v,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?x=t.port:b=`lock present but no port`}catch{b=`lock present but unparseable`}}if(x!==null){let e=await o(x);e===null?b=`agent-presence endpoint at :${x} unreachable`:(R(N(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await s(x);t!==null&&R(N(g,`state`,`agent-effects.json`),t);let n=await c(x);if(n!==null){let e=gt(n);e!==null&&R(N(g,`state`,`watcher-recent.jsonl`),e)}}let ee=l(r);ee!==null&&R(N(g,`state`,`shadow-head.txt`),ee);let te=u(r);te!==null&&R(N(g,`state`,`checkpoint-refs.txt`),te),X(N(_,`last-spawn-error.log`),N(g,`state`,`last-spawn-error.log`)),X(N(_,n),N(g,`state`,n)),X(N(_,t),N(g,`state`,t));let S=m(),ne=p(),re={ok:{version:f(),nodeVersion:S.nodeVersion,platform:S.platform,arch:S.arch},host:{desktop:ne}};R(N(g,`state`,`runtime.json`),`${JSON.stringify(re,null,2)}\n`);let ie=y===`running`?`running
12
- `:`not-running (${b})\n`;if(R(N(g,`state`,`server-status.txt`),ie),e.processDir&&F(e.processDir)){let t=N(g,`process`);I(t,{recursive:!0}),ue(e.processDir,t,{recursive:!0})}let C=null;e.redact===!0&&(C=tt({stagingDir:g,contentDir:r})),e.note&&R(N(g,`note.txt`),e.note);let w=null;e.scrubSecrets===!0&&(w=Pt(g));for(let t of e.extraFiles??[])X(t.sourcePath,N(g,`extra`,t.zipName??A(t.sourcePath)))||a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let ae=Tt(i),oe=kt(g),T=[],E=0,D=0;for(let e of oe){let t=Ft(g,e),n=_e(e).size,r=jt(t)?Dt(e):0;T.push({path:t,bytes:n,lines:r}),E+=n,t.startsWith(`telemetry/`)&&jt(t)&&(D+=Ot(e))}let O=C===null?{applied:!1,docNameMapSidecar:null}:Object.keys(C.docNameCollisions).length>0?{applied:!0,docNameMapSidecar:null,docNameCollisions:C.docNameCollisions}:{applied:!0,docNameMapSidecar:null};w!==null&&(O.secretScrub=w);let se={schemaVersion:1,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:S.nodeVersion,platform:S.platform,arch:S.arch},host:{desktop:ne},contentDir:{pathSha256:Et(r),absolutePath:C===null?r:`<CONTENT_DIR>`},telemetry:{localSink:ae,otlpPushEnabled:h()},redaction:O,serverStatus:y,files:T};R(N(g,`manifest.json`),`${JSON.stringify(se,null,2)}\n`);let k=oe.some(e=>{try{return L(e,`utf-8`).includes(r)}catch{return!1}}),j={totalBytes:E,fileCount:T.length,docNameCount:D,contentDirVisible:k,redacted:C!==null},M=!1;return{stagingDir:g,manifest:se,summary:j,redactionMapPayload:C===null?null:{docNameMap:C.docNameMap,docNameCollisions:C.docNameCollisions},cleanup:()=>{M||(M=!0,ge(g,{recursive:!0,force:!0}))}}}catch(e){throw ge(g,{recursive:!0,force:!0}),e}}async function Lt(e){let{collected:t,outputPath:n}=e,r=j(n);if(!F(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);if(t.redactionMapPayload!==null){let e=`${A(n,`.zip`)}.docnames.json`,r={...t.manifest,redaction:{...t.manifest.redaction,applied:!0,docNameMapSidecar:e}};R(N(t.stagingDir,`manifest.json`),`${JSON.stringify(r,null,2)}\n`)}let i=new We.ZipFile,a=kt(t.stagingDir);for(let e of a){let n=Ft(t.stagingDir,e);i.addFile(e,n)}i.end(),t.redactionMapPayload!==null&&R(N(r,`${A(n,`.zip`)}.docnames.json`),`${JSON.stringify({docNameMap:t.redactionMapPayload.docNameMap,docNameCollisions:t.redactionMapPayload.docNameCollisions},null,2)}\n`,{mode:384});let o=de(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Rt(e,t){let n=N(e,`.ok`,`config.yml`);if(F(n))try{let t=(0,V.parse)(L(n,`utf-8`)),r=O(t)?t.content:void 0,i=O(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return P(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return P(e)}async function zt(e,t,n){let r=await It({contentDir:Rt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,deps:{readDesktopEnv:n,logger:e.logger}});try{I(j(e.outputPath),{recursive:!0}),await Lt({collected:r,outputPath:e.outputPath});let n=r.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:Le(t,e.logger),files:r.manifest.files.map(e=>e.path),redactions:n?.redactions??[],redactedLineCount:n?.redactedLineCount??0,generatedAt:r.manifest.createdAt}}}finally{r.cleanup()}}async function Bt(e){let{projectDir:t}=e,n=e.readDesktopEnv??yt;if(e.level===`full`&&t!==void 0)return zt(e,t,n);let{zipPath:r,summary:i}=await Ue({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n()});return{zipPath:r,summary:{level:e.level,systemWide:t===void 0,projectSlug:i.projectSlug,files:i.files,redactions:i.redactions,redactedLineCount:i.redactedLineCount,generatedAt:i.generatedAt}}}function Z(e,t,n={}){let r=g(e,t);if(!F(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(L(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!v(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??_)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??h())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??xe();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Vt(e){return e.replace(/:\d+$/,``)}function Ht(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Vt(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Vt(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Vt(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function Ut(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=r(t.hostname);if(n===null)return null;let i=t.pathname.split(`/`).filter(e=>e.length>0);if(i.length<5||i[2]!==`blob`)return null;let a,o,s,c;try{a=decodeURIComponent(i[0]),o=decodeURIComponent(i[1]),s=decodeURIComponent(i[3]),c=i.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.length===0||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function Wt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=r(t.hostname);if(n===null)return null;let i=t.pathname.split(`/`);if(i.length<5||i[0]!==``||i[3]!==`tree`)return null;let a=i.slice(5);a.length===1&&a[0]===``&&a.pop();let o,s,c,l;try{o=decodeURIComponent(i[1]),s=decodeURIComponent(i[2]),c=decodeURIComponent(i[4]),l=a.map(e=>decodeURIComponent(e))}catch{return null}return!o||!s||!c||l.some(e=>e.length===0)?null:{host:n,owner:o,repo:s,branch:c,path:l.join(`/`)}}function Gt(e){let t=Ut(e);if(t)return{kind:`doc`,...t};let n=Wt(e);return n?{kind:`folder`,...n}:null}const Kt=`# >>> open-knowledge cli >>>`,qt=`# <<< open-knowledge cli <<<`,Jt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Yt(e){return N(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Xt={existsSync:e=>F(e),readFileSync:(e,t)=>L(e,t),lstatSync:e=>fe(e),readlinkSync:e=>he(e)};function Zt(e,t=Xt){let n=Yt(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function Qt(e){let t=e.replace(Jt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function $t(e,t,n=Xt){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function en(e){return te(e)||S(e)||C(e)}const tn=10*1024*1024;function nn(e,t,n,r){let i=T(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!en(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(ge(a,{force:!0}),{kind:`removed`}):e.format===`toml`?on(a,o):e.format===`yaml`?an(a,e.topLevelKey,o):rn(a,e.topLevelKey,e.serverMapSubKey,o)}function rn(e,t,n,r){let i;try{i=L(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>tn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=re(i,ae(t,n,r));return o?(m(e,a,{mode:w(e)}),{kind:`removed`}):{kind:`not-present`}}function an(e,t,n){let r;try{r=L(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>tn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,V.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=ie(a);a.trim()===``||a.endsWith(`
11
+ `)}\n`:null}catch{return null}}function _t(e){let t=N(e,`.git`,`ok`);if(!F(t))return null;let n=k(`git`,[`-C`,t,`log`,`--oneline`,`-50`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function vt(e){let t=N(e,`.git`,`ok`);if(!F(t))return null;let n=k(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function yt(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function bt(){return{nodeVersion:process.version,platform:Se(),arch:ve()}}function xt(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function St(e){if(!F(e))return{};let t;try{t=(0,V.parse)(L(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!J(t))return{};let n=t.telemetry;if(!J(n))return{};let r=n.localSink;return J(r)?r:{}}function Ct(e){return typeof e==`boolean`?e:void 0}function wt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return wt(e.maxBytes)}function Tt(e){let t=St(p(`project`,e)),n=St(p(`project-local`,e));return{enabled:Ct(n.enabled)??Ct(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Et(e){return B(`sha256`).update(e).digest(`hex`)}function Dt(e){let t=L(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Ot(e){let t=L(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X(e,t){return F(e)?(I(j(t),{recursive:!0}),ue(e,t),!0):!1}function kt(e){let t=[],n=e=>{let r=me(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const At=new Set([`.jsonl`]);function jt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:At.has(e.slice(t))}const Mt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Nt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Mt.has(e.slice(t))}function Pt(e){let t=[];for(let n of kt(e)){let r=Ft(e,n);if(!Nt(r))continue;let{redacted:i,patterns:a,lineCount:o}=H(L(n,`utf-8`));a.length!==0&&(R(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Ft(e,t){return ce(e,t).split(le).join(`/`)}async function It(e){let t=P(e.contentDir),i=P(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??pt,s=a.fetchAgentEffects??mt,c=a.fetchWatcherRecent??ht,l=a.readShadowHead??_t,u=a.readCheckpointRefs??vt,d=a.now??(()=>new Date),f=a.okVersion??(()=>D),p=a.readDesktopEnv??yt,m=a.readRuntime??bt,h=a.isOtlpPushEnabled??xt,g=pe(N(we(),`ok-bundle-`));try{I(N(g,`telemetry`),{recursive:!0}),I(N(g,`logs`),{recursive:!0}),I(N(g,`state`),{recursive:!0}),X(ct(i),N(g,`telemetry`,it)),X(lt(i),N(g,`telemetry`,at)),X(ut(i),N(g,`logs`,ot)),X(dt(i),N(g,`logs`,st));let _=N(i,`.ok`,`local`),v=N(_,`server.lock`),y=`not-running`,b=`no server.lock`,x=null;if(F(v)){X(v,N(g,`state`,`server.lock`));try{let e=L(v,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?x=t.port:b=`lock present but no port`}catch{b=`lock present but unparseable`}}if(x!==null){let e=await o(x);e===null?b=`agent-presence endpoint at :${x} unreachable`:(R(N(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await s(x);t!==null&&R(N(g,`state`,`agent-effects.json`),t);let n=await c(x);if(n!==null){let e=gt(n);e!==null&&R(N(g,`state`,`watcher-recent.jsonl`),e)}}let ee=l(t);ee!==null&&R(N(g,`state`,`shadow-head.txt`),ee);let te=u(t);te!==null&&R(N(g,`state`,`checkpoint-refs.txt`),te),X(N(_,`last-spawn-error.log`),N(g,`state`,`last-spawn-error.log`)),X(N(_,r),N(g,`state`,r)),X(N(_,n),N(g,`state`,n));let S=m(),ne=p(),re={ok:{version:f(),nodeVersion:S.nodeVersion,platform:S.platform,arch:S.arch},host:{desktop:ne}};R(N(g,`state`,`runtime.json`),`${JSON.stringify(re,null,2)}\n`);let ie=y===`running`?`running
12
+ `:`not-running (${b})\n`;if(R(N(g,`state`,`server-status.txt`),ie),e.processDir&&F(e.processDir)){let t=N(g,`process`);I(t,{recursive:!0}),ue(e.processDir,t,{recursive:!0})}let C=null;e.redact===!0&&(C=tt({stagingDir:g,contentDir:t})),e.note&&R(N(g,`note.txt`),e.note);let w=null;e.scrubSecrets===!0&&(w=Pt(g));for(let t of e.extraFiles??[])X(t.sourcePath,N(g,`extra`,t.zipName??A(t.sourcePath)))||a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let ae=Tt(i),oe=kt(g),T=[],E=0,D=0;for(let e of oe){let t=Ft(g,e),n=_e(e).size,r=jt(t)?Dt(e):0;T.push({path:t,bytes:n,lines:r}),E+=n,t.startsWith(`telemetry/`)&&jt(t)&&(D+=Ot(e))}let O=C===null?{applied:!1,docNameMapSidecar:null}:Object.keys(C.docNameCollisions).length>0?{applied:!0,docNameMapSidecar:null,docNameCollisions:C.docNameCollisions}:{applied:!0,docNameMapSidecar:null};w!==null&&(O.secretScrub=w);let se={schemaVersion:1,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:S.nodeVersion,platform:S.platform,arch:S.arch},host:{desktop:ne},contentDir:{pathSha256:Et(t),absolutePath:C===null?t:`<CONTENT_DIR>`},telemetry:{localSink:ae,otlpPushEnabled:h()},redaction:O,serverStatus:y,files:T};R(N(g,`manifest.json`),`${JSON.stringify(se,null,2)}\n`);let k=oe.some(e=>{try{return L(e,`utf-8`).includes(t)}catch{return!1}}),j={totalBytes:E,fileCount:T.length,docNameCount:D,contentDirVisible:k,redacted:C!==null},M=!1;return{stagingDir:g,manifest:se,summary:j,redactionMapPayload:C===null?null:{docNameMap:C.docNameMap,docNameCollisions:C.docNameCollisions},cleanup:()=>{M||(M=!0,ge(g,{recursive:!0,force:!0}))}}}catch(e){throw ge(g,{recursive:!0,force:!0}),e}}async function Lt(e){let{collected:t,outputPath:n}=e,r=j(n);if(!F(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);if(t.redactionMapPayload!==null){let e=`${A(n,`.zip`)}.docnames.json`,r={...t.manifest,redaction:{...t.manifest.redaction,applied:!0,docNameMapSidecar:e}};R(N(t.stagingDir,`manifest.json`),`${JSON.stringify(r,null,2)}\n`)}let i=new We.ZipFile,a=kt(t.stagingDir);for(let e of a){let n=Ft(t.stagingDir,e);i.addFile(e,n)}i.end(),t.redactionMapPayload!==null&&R(N(r,`${A(n,`.zip`)}.docnames.json`),`${JSON.stringify({docNameMap:t.redactionMapPayload.docNameMap,docNameCollisions:t.redactionMapPayload.docNameCollisions},null,2)}\n`,{mode:384});let o=de(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Rt(e,t){let n=N(e,`.ok`,`config.yml`);if(F(n))try{let t=(0,V.parse)(L(n,`utf-8`)),r=O(t)?t.content:void 0,i=O(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return P(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return P(e)}async function zt(e,t,n){let r=await It({contentDir:Rt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,deps:{readDesktopEnv:n,logger:e.logger}});try{I(j(e.outputPath),{recursive:!0}),await Lt({collected:r,outputPath:e.outputPath});let n=r.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:Le(t,e.logger),files:r.manifest.files.map(e=>e.path),redactions:n?.redactions??[],redactedLineCount:n?.redactedLineCount??0,generatedAt:r.manifest.createdAt}}}finally{r.cleanup()}}async function Bt(e){let{projectDir:t}=e,n=e.readDesktopEnv??yt;if(e.level===`full`&&t!==void 0)return zt(e,t,n);let{zipPath:r,summary:i}=await Ue({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n()});return{zipPath:r,summary:{level:e.level,systemWide:t===void 0,projectSlug:i.projectSlug,files:i.files,redactions:i.redactions,redactedLineCount:i.redactedLineCount,generatedAt:i.generatedAt}}}function Z(e,t,n={}){let r=g(e,t);if(!F(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(L(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!v(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??_)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??h())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??xe();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Vt(e){return e.replace(/:\d+$/,``)}function Ht(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Vt(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Vt(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Vt(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function Ut(e){let n;try{n=new URL(e)}catch{return null}if(n.protocol!==`https:`)return null;let r=t(n.hostname);if(r===null)return null;let i=n.pathname.split(`/`).filter(e=>e.length>0);if(i.length<5||i[2]!==`blob`)return null;let a,o,s,c;try{a=decodeURIComponent(i[0]),o=decodeURIComponent(i[1]),s=decodeURIComponent(i[3]),c=i.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.length===0||c.some(e=>e.length===0)?null:{host:r,owner:a,repo:o,branch:s,path:c.join(`/`)}}function Wt(e){let n;try{n=new URL(e)}catch{return null}if(n.protocol!==`https:`)return null;let r=t(n.hostname);if(r===null)return null;let i=n.pathname.split(`/`);if(i.length<5||i[0]!==``||i[3]!==`tree`)return null;let a=i.slice(5);a.length===1&&a[0]===``&&a.pop();let o,s,c,l;try{o=decodeURIComponent(i[1]),s=decodeURIComponent(i[2]),c=decodeURIComponent(i[4]),l=a.map(e=>decodeURIComponent(e))}catch{return null}return!o||!s||!c||l.some(e=>e.length===0)?null:{host:r,owner:o,repo:s,branch:c,path:l.join(`/`)}}function Gt(e){let t=Ut(e);if(t)return{kind:`doc`,...t};let n=Wt(e);return n?{kind:`folder`,...n}:null}const Kt=`# >>> open-knowledge cli >>>`,qt=`# <<< open-knowledge cli <<<`,Jt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Yt(e){return N(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Xt={existsSync:e=>F(e),readFileSync:(e,t)=>L(e,t),lstatSync:e=>fe(e),readlinkSync:e=>he(e)};function Zt(e,t=Xt){let n=Yt(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function Qt(e){let t=e.replace(Jt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function $t(e,t,n=Xt){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function en(e){return te(e)||S(e)||C(e)}const tn=10*1024*1024;function nn(e,t,n,r){let i=T(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!en(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(ge(a,{force:!0}),{kind:`removed`}):e.format===`toml`?on(a,o):e.format===`yaml`?an(a,e.topLevelKey,o):rn(a,e.topLevelKey,e.serverMapSubKey,o)}function rn(e,t,n,r){let i;try{i=L(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>tn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=re(i,ae(t,n,r));return o?(m(e,a,{mode:w(e)}),{kind:`removed`}):{kind:`not-present`}}function an(e,t,n){let r;try{r=L(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>tn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,V.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=ie(a);a.trim()===``||a.endsWith(`
13
13
  `)?c.endsWith(`
14
14
  `)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
15
15
  `).replace(/\n/g,`\r
@@ -18,5 +18,5 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,ka as r}from"./src
18
18
  `)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
19
19
  `).replace(/\n/g,`\r
20
20
  `));let u=`${i?``:``}${l}`;return u!==r&&m(e,u,{mode:w(e)}),{kind:`removed`}}function sn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function cn(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function ln(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:l(r),command:r,isDesktop:sn(r)}}function un(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&un(e)?`ui-orphan`:`stale`}const dn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function fn(e){switch(e){case`running`:return W.default.green(e);case`desktop`:return W.default.blue(e);case`foreign`:return W.default.cyan(e);case`ui-orphan`:return W.default.magenta(e);case`stale`:return W.default.yellow(e)}}function pn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function mn(e){return`${pn(e.server.usage)} | ${pn(e.ui?.usage??null)}`}function hn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function gn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,hn(e),mn(e),t,String(n),cn(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=fn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=W.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
21
- `)}async function _n(e={}){let t=e.discover??c,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??a,o=e.resolveUsage??s,l=await t(),u=[];for(let e of l){let t=n(e,`server`),r=n(e,`ui`),a=ln(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:o(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:o(r.lock.pid));a!=null&&u.push(a)}if(e.json){let e=u.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(gn(e.all?u:u.filter(e=>dn.has(Q(e)))))}function vn(){return new b(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await _n({all:t.all===!0||e===`all`,json:t.json===!0})})}function yn(e,t,n={}){let r=n.isAlive??_,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function bn(e){let t=e.inspect??(t=>Z(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=yn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function xn(e,t=_){let n=await c(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function Sn(e){let t=bn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Cn(e){return new b(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=bn({lockDir:i(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await _n({});return}if(n===`all`){let e=await c();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Z(n,`server`),r=Z(n,`ui`);!$(e,_)&&!$(r,_)||(Sn(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await xn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Sn(t);return}Sn(i(P(Me(),n)))})}function wn(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Tn(e,t){let n,i;try{n=await z(P(e)),i=await z(P(j(e)))}catch{return{kind:`not-git`}}if(!En(n,i))return{kind:`symlink-escape`};let a=N(n,`.git`),o;try{o=_e(a)}catch{return{kind:`not-git`}}if(o.isDirectory()){let e;try{e=await z(a)}catch{return{kind:`not-git`}}if(!En(e,n))return{kind:`symlink-escape`}}else if(!o.isFile())return{kind:`not-git`};let s=d(n);if(s.kind!==`repository`)return{kind:`not-git`};let c=s.repository.readRemoteUrl(`origin`);if(c.kind===`unreadable`)return{kind:`not-git`};if(c.kind===`absent`)return c.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let l=c.url,u=Ht(l);if(u===null)return{kind:`non-github`};let f=r(u.hostname);if(f===null)return{kind:`non-github`};let p=f===t.host.toLowerCase(),m=u.owner.toLowerCase()===t.owner.toLowerCase(),h=u.name.toLowerCase()===t.repo.toLowerCase();return!p&&m&&h?{kind:`wrong-host`,actualHost:f}:!p||!m||!h?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://${f}/${u.owner}/${u.name}.git`}}function En(e,t){if(e===t)return!0;let n=ce(t,e);return n.length>0&&!n.startsWith(`..`)&&!M(n)}const Dn=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=E(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=ee(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function On(e,t,n={},r=Dn){let i=[];for(let a of t){let t=x[a];for(let a of r)i.push(a.write(t,e,n))}return i}function kn(e,t,n={}){return{integrations:On(e,t,n)}}export{Ie as C,ke as D,je as E,Lt as S,Me as T,Wt as _,Cn as a,Bt as b,Kt as c,$t as d,Yt as f,Gt as g,Ut as h,bn as i,Jt as l,Qt as m,Tn as n,vn as o,Zt as p,wn as r,nn as s,kn as t,qt as u,Ht as v,H as w,It as x,Z as y};
22
- //# sourceMappingURL=src-CxD3JHmH.mjs.map
21
+ `)}async function _n(e={}){let t=e.discover??c,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??a,o=e.resolveUsage??s,l=await t(),u=[];for(let e of l){let t=n(e,`server`),r=n(e,`ui`),a=ln(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:o(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:o(r.lock.pid));a!=null&&u.push(a)}if(e.json){let e=u.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(gn(e.all?u:u.filter(e=>dn.has(Q(e)))))}function vn(){return new b(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await _n({all:t.all===!0||e===`all`,json:t.json===!0})})}function yn(e,t,n={}){let r=n.isAlive??_,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function bn(e){let t=e.inspect??(t=>Z(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=yn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function xn(e,t=_){let n=await c(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function Sn(e){let t=bn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Cn(e){return new b(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=bn({lockDir:i(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await _n({});return}if(n===`all`){let e=await c();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Z(n,`server`),r=Z(n,`ui`);!$(e,_)&&!$(r,_)||(Sn(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await xn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Sn(t);return}Sn(i(P(Me(),n)))})}function wn(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Tn(e,n){let r,i;try{r=await z(P(e)),i=await z(P(j(e)))}catch{return{kind:`not-git`}}if(!En(r,i))return{kind:`symlink-escape`};let a=N(r,`.git`),o;try{o=_e(a)}catch{return{kind:`not-git`}}if(o.isDirectory()){let e;try{e=await z(a)}catch{return{kind:`not-git`}}if(!En(e,r))return{kind:`symlink-escape`}}else if(!o.isFile())return{kind:`not-git`};let s=d(r);if(s.kind!==`repository`)return{kind:`not-git`};let c=s.repository.readRemoteUrl(`origin`);if(c.kind===`unreadable`)return{kind:`not-git`};if(c.kind===`absent`)return c.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let l=c.url,u=Ht(l);if(u===null)return{kind:`non-github`};let f=t(u.hostname);if(f===null)return{kind:`non-github`};let p=f===n.host.toLowerCase(),m=u.owner.toLowerCase()===n.owner.toLowerCase(),h=u.name.toLowerCase()===n.repo.toLowerCase();return!p&&m&&h?{kind:`wrong-host`,actualHost:f}:!p||!m||!h?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://${f}/${u.owner}/${u.name}.git`}}function En(e,t){if(e===t)return!0;let n=ce(t,e);return n.length>0&&!n.startsWith(`..`)&&!M(n)}const Dn=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=E(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=ee(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function On(e,t,n={},r=Dn){let i=[];for(let a of t){let t=x[a];for(let a of r)i.push(a.write(t,e,n))}return i}function kn(e,t,n={}){return{integrations:On(e,t,n)}}export{Ie as C,ke as D,je as E,Lt as S,Me as T,Wt as _,Cn as a,Bt as b,Kt as c,$t as d,Yt as f,Gt as g,Ut as h,bn as i,Jt as l,Qt as m,Tn as n,vn as o,Zt as p,wn as r,nn as s,kn as t,qt as u,Ht as v,H as w,It as x,Z as y};
22
+ //# sourceMappingURL=src-CAK6XVGy.mjs.map
@@ -0,0 +1 @@
1
+ import{$a as e,C as t,Da as n,Ea as r,Ta as i,Ua as a,Va as o,d as s,do as c,l,y as u}from"./src-BTs5LPkM.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Fr as W,Ft as G,G as K,Gi as q,Gn as J,Gr as Y,Gt as X,H as Z,Hi as Q,Hn as $,Hr as ee,Ht as te,I as ne,Ii as re,In as ie,Ir as ae,It as oe,J as se,Ji as ce,Jn as le,Jt as ue,K as de,Ki as fe,Kn as pe,Kr as me,Kt as he,L as ge,Li as _e,Ln as ve,Lr as ye,Lt as be,M as xe,Mi as Se,Mn as Ce,Mr as we,Mt as Te,N as Ee,Ni as De,Nn as Oe,Nr as ke,Nt as Ae,O as je,Oi as Me,On as Ne,Or as Pe,Ot as Fe,P as Ie,Pi as Le,Pn as Re,Pr as ze,Pt as Be,Q as Ve,Qi as He,Qn as Ue,Qr as We,Qt as Ge,R as Ke,Ri as qe,Rn as Je,Rr as Ye,Rt as Xe,S as Ze,Si as Qe,Sn as $e,Sr as et,St as tt,T as nt,Ti as rt,Tn as it,Tr as at,Tt as ot,U as st,Ui as ct,Un as lt,Ur as ut,Ut as dt,V as ft,Vi as pt,Vn as mt,Vr as ht,Vt as gt,W as _t,Wi as vt,Wn as yt,Wr as bt,Wt as xt,X as St,Xi as Ct,Xn as wt,Xt as Tt,Y as Et,Yi as Dt,Yn as Ot,Yt as kt,Z as At,Zi as jt,Zn as Mt,Zt as Nt,_ as Pt,_i as Ft,_n as It,_r as Lt,a as Rt,aa as zt,ai as Bt,an as Vt,ar as Ht,at as Ut,b as Wt,bi as Gt,bn as Kt,br as qt,bt as Jt,c as Yt,ca as Xt,ci as Zt,cn as Qt,cr as $t,ct as en,d as tn,da as nn,di as rn,dn as an,dr as on,dt as sn,ea as cn,ei as ln,en as un,er as dn,et as fn,f as pn,fa as mn,fi as hn,fn as gn,fr as _n,ft as vn,g as yn,gi as bn,gn as xn,gr as Sn,h as Cn,ha as wn,hi as Tn,hn as En,hr as Dn,i as On,ia as kn,ii as An,in as jn,ir as Mn,it as Nn,j as Pn,ji as Fn,jn as In,jr as Ln,jt as Rn,k as zn,ki as Bn,kn as Vn,kr as Hn,kt as Un,l as Wn,la as Gn,li as Kn,ln as qn,lr as Jn,lt as Yn,m as Xn,ma as Zn,mi as Qn,mn as $n,mr as er,n as tr,na as nr,ni as rr,nn as ir,nr as ar,nt as or,o as sr,oa as cr,oi as lr,on as ur,or as dr,ot as fr,p as pr,pa as mr,pi as hr,pn as gr,pr as _r,q as vr,qi as yr,qn as br,qt as xr,r as Sr,ra as Cr,ri as wr,rn as Tr,rr as Er,rt as Dr,s as Or,sa as kr,si as Ar,sn as jr,sr as Mr,st as Nr,t as Pr,ta as Fr,ti as Ir,tn as Lr,tr as Rr,tt as zr,u as Br,ua as Vr,ui as Hr,un as Ur,ur as Wr,ut as Gr,v as Kr,vi as qr,vn as Jr,vr as Yr,w as Xr,wi as Zr,wn as Qr,wr as $r,wt as ei,x as ti,xi as ni,xn as ri,xr as ii,xt as ai,y as oi,yi as si,yn as ci,yr as li,yt as ui,z as di,zi as fi,zn as pi,zr as mi,zt as hi}from"./src-BbntdRLo.mjs";import{C as gi,E as _i,T as vi,_ as yi,b as bi,c as xi,d as Si,g as Ci,i as wi,l as Ti,m as Ei,n as Di,p as Oi,s as ki,t as Ai,u as ji,v as Mi,w as Ni,x as Pi,y as Fi}from"./fs-traced-Cc6WsRtP.mjs";import{a as Ii,d as Li,f as Ri,i as zi,l as Bi,n as Vi,r as Hi,t as Ui,u as Wi}from"./logger-B7Z8XO-z.mjs";import{_ as Gi,a as Ki,b as qi,c as Ji,f as Yi,g as Xi,h as Zi,i as Qi,l as $i,m as ea,n as ta,o as na,p as ra,r as ia,s as aa,t as oa,u as sa,v as ca,y as la}from"./server-lock-NDXM24F6.mjs";export{cr as AGENT_ID_MAX_LEN,kr as AGENT_ID_RE,S as AGENT_WRITE_ORIGIN,mr as AcpPermissionStore,Vr as AcpRegistry,_e as AcpThreadManager,H as AgentFocusBroadcaster,Le as AgentPresenceBroadcaster,pt as AgentSessionCapacityError,Q as AgentSessionManager,Jt as AutoStartDisabledError,we as BUNDLE_IDS,ke as BUNDLE_SCOPE,ze as BUNDLE_SKILL_NAME,Mt as BacklinkIndex,Dt as CC1Broadcaster,a as CC1_CONTRACT_VERSION,jr as CONFIG_FILENAME,pe as CONFLICT_MARKER_RE,rr as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pt as ConfigSchema,In as DEFAULT_CHECKPOINT_RETENTION,qr as DEFAULT_EMBEDDINGS_DIMENSIONS,Xe as DEFAULT_PACK_ID,K as DocumentDurabilityState,si as EMBEDDINGS_API_KEY_ENV,nn as FEATURED_AGENT_IDS,Ce as FILE_SYSTEM_WRITER,wt as FILE_WATCHER_ORIGIN,hn as FileEmbeddingsBackend,ir as GIT_PREFLIGHT_FAIL_SPAN_NAME,Oe as GIT_UPSTREAM_WRITER,Zn as GitDirAccessError,Mn as GitNotAvailableError,Ht as GitTooOldError,ai as HOCUSPOCUS_AUTH_REJECTION_REASONS,tt as HocuspocusAuthRejection,A as HocuspocusAuthTokenSchema,Zt as INSTALLED_AGENTS_SCHEMES,o as LINEAGE_EPOCH_KEY,Z as LIVE_DERIVED_INDEX_DEBOUNCE_MS,hi as LOG_MD_TEMPLATE,Un as MANAGED_RENAME_ORIGIN,qe as MAX_ACP_THREADS,ct as MAX_AGENT_SESSIONS,sn as MCP_CONNECTION_ID_HEADER,i as MCP_SERVER_NAME,vt as MIN_EVICTABLE_IDLE_MS,dr as MIN_GIT_VERSION,de as MISSING_OK_CONFIG_MESSAGE,wn as MalformedGitPointerError,Dr as McpLogger,vr as MissingOkConfigError,V as OBSERVER_SYNC_ORIGIN,Qt as OK_OKIGNORE_TEMPLATE,r as ORPHAN_MODES,c as PROTOCOL_VERSION,Ui as PinoLogger,Ji as ProcessLockCollisionError,Wn as ProjectGitInitError,b as ROLLBACK_ORIGIN,qn as ROOT_GITIGNORE_TEMPLATE,Xi as RUNTIME_VERSION,Re as SERVICE_WRITER,P as SKILL_INSTALL_EVENTS_FILE_REL,u as SKILL_STATE_TARGETS,T as STARTER_FOLDERS,gt as STARTER_FOLDER_FRONTMATTER_FILENAME,te as STARTER_PACKS,dt as STARTER_PACK_IDS,xt as STARTER_TEMPLATES,I as STATE_MANIFEST_FILENAME,Gi as STATE_SCHEMA_VERSION,e as SYSTEM_DOC_NAME,Tt as SeedPrerequisiteError,Nt as SeedRootDirError,oa as ServerLockCollisionError,Pr as SingleFileNotAFileError,tr as SingleFileNotFoundError,Sr as SingleFileNotMarkdownError,j as StateManifestError,nt as TagIndex,W as USER_GLOBAL_BUNDLE_IDS,p as UiLockCollisionError,Rn as __getShowAllWalkStatsForTesting,Te as __resetShowAllWalkStatsForTesting,$i as acquireProcessLock,ta as acquireServerLock,dn as acquireUiLock,q as applyAgentMarkdownWrite,Vn as applyExternalChange,be as applySeed,je as assertCompatibleStateManifest,Mr as assertGitAvailable,It as assertNeverDiskEvent,re as attachAcpThreadSocket,ui as attachIdleShutdown,Kr as bootServer,Sn as buildAndOpenSkill,Ur as buildConfigYmlContent,Ve as buildExecResult,fi as buildOkMcpStdioCommand,Hn as buildSkillZip,X as buildStarterFolderFrontmatterYaml,U as buildWipTree,ae as bundleSkillMdPath,hr as canonicalProjectKey,Jr as classifyEvents,Ai as classifyFsPath,Qn as clearAllEmbeddingsKeys,ni as clearContributors,he as coercePackId,l as colorFromSeed,ie as commitUpstreamImport,ve as commitWip,Je as commitWipFromTree,$t as compareSemver,mi as composeEffectiveLinterConfig,w as composeFrontmatterSchemasConfig,br as containsConflictMarkers,ci as contentHash,Qe as contributorCount,Ke as countShadowObjects,di as countStaleAgentWipRefs,x as countWipRefs,Ae as createApiExtension,Fn as createAssetServeMiddleware,We as createContentFilter,m as createContentFilterAsync,Tn as createEmbeddingsSecretStore,On as createEphemeralProjectDir,v as createExternalChangeHandler,pn as createFileLogger,st as createLiveDerivedIndexExtension,St as createMcpHttpHandler,Kn as createOsProbe,Ie as createPersistenceExtension,E as createServer,xe as createServerObserverExtension,fe as createStreamingErrorWriter,Vi as createTestLogger,bn as describeStoredEmbeddingsKey,yn as detectClaudeDesktopPresence,Jn as detectGit,zn as detectProjectShape,Lt as detectUserSkillHosts,fr as discoverLockDirs,ut as discoverMarkdownlintConfig,Tr as emitPreflightFailureSpan,d as encodeDocName,fn as encodeFolderRoute,zr as encodeSkillRoute,Br as ensureProjectGit,an as ensureProjectSkillGitignore,yr as errorResponse,Kt as evictStaleTrackerEntries,Nr as extractOkBinaryPath,Ue as extractWikiLinksFromMarkdown,Wr as fallbackPaths,tn as findEnclosingGitRoot,En as findEnclosingProjectRoot,bt as findNativeMarkdownlintFile,pr as flushFileLogger,ei as formatAuthRejectionWire,D as formatContributors,Zr as formatContributorsFrom,G as formatPackRationale,pi as gcCheckpointRefs,Nn as getCurrentMcpLogger,Me as getLocalDir,Xn as getLogFilePath,Hi as getLogger,Cn as getLogsDir,qi as getMachineId,Fi as getMeter,Fr as getMetrics,bi as getTracer,nr as handleCollabSocketError,wr as handleSpawnCursor,ft as hasGcLogLatch,s as iconFromClientName,Cr as incrementCollabSocketFilteredError,kn as incrementServerObserverFire,gn as initContent,C as initShadowRepo,Pi as initTelemetry,Wt as initToleranceTelemetryWriter,Gr as installPrettyZodErrors,zi as installTestLoggers,Yr as installUserSkill,De as isAllowedApiOrigin,Ge as isAllowedWorkspaceHostHeader,Ct as isConfigDoc,ot as isHocuspocusAuthRejectionReason,xr as isKnownPackId,jt as isLinkIndexExcludedDoc,h as isLoopbackAddress,He as isManagedArtifactDoc,n as isOrphanMode,ne as isPairedWriteOrigin,An as isPathWithinDir,ca as isProcessAlive,xn as isProjectRoot,_n as isProjectSkillManaged,f as isReservedForUserTree,ri as isSelfWrite,cn as isSystemDoc,ti as isToleranceTelemetryEnabled,la as isValidLockPid,$e as lastKnownHash,mt as listRescueCheckpoints,ue as listStarterPacks,mn as loadCustomAgents,Ee as loadPrincipal,sa as lockFilePath,Ii as loggerFactory,Bi as logsCurrentPath,Wi as logsPreviousPath,Ft as makeLazyEmbeddingsKeyStore,ia as markServerLockDraining,se as mountMcpAndApi,Di as normalizeFsPath,ye as originGitHubHost,gr as packageVersionMajorMinor,B as parseAuthRejectionWire,on as parseGitVersion,F as parseHocuspocusAuthToken,Et as parseKeepaliveConnectionId,O as pathToDocName,oe as planSeed,Rt as prepareSingleFileOpen,en as processCommand,Yn as processUsage,li as readAllTargets,qt as readBundleDecision,Y as readOwnNativeRules,Yi as readProcessLock,ra as readProcessLockDetailed,_t as readProjectHeadState,rn as readProjectLocalSemanticConfig,Qi as readServerLock,ii as readServerPackageVersion,et as readSkillInstallStateSnapshot,_r as readSkillManagement,g as readStateManifest,k as readTargetRecordedAt,$r as readTargetVersion,Rr as readUiLock,le as reconcile,rt as recordContributor,Pe as recordSkillInstallEvent,At as registerAllTools,Qr as registerWrite,ea as releaseProcessLock,Ki as releaseServerLock,ar as releaseUiLock,it as removeLastKnownHash,zt as resetMetrics,t as resolveBundleEnabled,y as resolveBundledSkillDir,Bn as resolveContentDir,Bt as resolveCursorBinaryDefault,lr as resolveCursorSpawnInvocation,ht as resolveEffectiveLinterConfig,Gt as resolveEmbeddingsCredential,_ as resolveLockDir,ee as resolveNativeConfigForDoc,me as resolveNativeMarkdownlintConfig,kt as resolvePack,Or as resolvePackageVersion,or as resolveUiInfo,L as restoreContributors,oi as restoreLifecycleFromConflictsJson,ln as rewriteMarkdownLinksForDocumentRename,Ir as rewriteWikiLinksForDocumentRename,jn as runAuthReposSubprocess,Vt as runAuthStatusSubprocess,un as runCloneSubprocess,ur as runDeviceFlowSubprocess,Ut as runWithMcpLogger,Se as safeContentPath,Be as safeSubdir,$ as safetyCheckpoint,vn as sanitizeClientName,lt as saveInMemoryCheckpoint,yt as saveVersion,Fe as seedBasenameIndex,sr as serializeError,gi as setActiveSpanAttributes,ge as setupServerObservers,J as shadowGit,Ni as shutdownTelemetry,er as skillManagementPath,Li as spansCurrentPath,Ri as spansPreviousPath,Ar as spawnDetached,Ot as splitMarkdownBlocks,R as startWatcher,ce as streamingProblemEvent,M as swapContributors,Ze as teardownToleranceTelemetryWriter,Xt as toBroadcasterKey,wi as tracedAppendFileSync,ki as tracedLinkSync,xi as tracedMkdir,Ti as tracedMkdirSync,ji as tracedRename,Si as tracedRenameSync,Oi as tracedRmSync,Ei as tracedRmdirSync,Ci as tracedUnlinkSync,yi as tracedWriteFile,Mi as tracedWriteFileSync,Xr as trustSystemCertificates,Yt as untrackTrackedProjectSkillProjection,N as updateLastKnownHash,Zi as updateProcessLockPort,na as updateServerLockPort,Er as updateUiLockPort,Gn as validateAgentId,Lr as validateCloneInputs,Ln as validateSkillZip,aa as waitForServerLockDrain,Hr as withHiddenWindowsConsole,vi as withSpan,_i as withSpanSync,at as writeBundleDecision,Ye as writeMarkdownlintRule,$n as writeRootGitignoreForNewRepo,Dn as writeSkillManagement,Pn as writeStateManifest,z as writeTargetVersion,Ne as writeTracker};
@@ -0,0 +1 @@
1
+ import{_ as e,f as t,r as n}from"./start-DtLzPL0C.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};
@@ -1,3 +1,3 @@
1
- import{L as e,P as t}from"./src-3SN72BHH.mjs";import{_i as n,a as r,gn as i,ui as a}from"./src-DAzaO37g.mjs";import{C as o,w as s}from"./write-project-skill-4OvW1cn1.mjs";import{a as c,n as l,t as u}from"./acp-harness-probe-Ba7DTFOh.mjs";import{n as d}from"./constants-Ej-ZzjYT.mjs";import{spawn as f}from"node:child_process";import{basename as p,dirname as m,join as h,win32 as g}from"node:path";import{closeSync as _,existsSync as v,mkdirSync as y,openSync as b,statSync as x}from"node:fs";import{homedir as S}from"node:os";import{rm as C}from"node:fs/promises";import{setTimeout as w}from"node:timers/promises";function T(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function E(e,t,n={}){let r=(n.spawn??f)(e,[...t],a({detached:!0,stdio:`ignore`,env:T(n.env??process.env)}));return r.unref(),r}const D=`OpenKnowledge.app`,O=`/Applications/${D}`;function k(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return x(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function A(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(j(e,O))return O;let t=h(e.homeDir??S(),`Applications`,D);return j(e,t)?t:null}function j(e,t){return M(e,h(t,`Contents`,`MacOS`,`OpenKnowledge`))}function M(e,t){try{let n=e.statSync(t);return n&&typeof n.isFile==`function`?n.isFile():!1}catch{return!1}}const N=[`@inkeepopen-knowledge-desktop`,`OpenKnowledge`];function P(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&/\\OpenKnowledge\.exe$/i.test(e.execPath))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of N){let r=g.join(t,`Programs`,n,`OpenKnowledge.exe`);if(M(e,r))return r}return null}function F(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&e.execPath.endsWith(`/openknowledge`))return e.execPath;let t=`/opt/OpenKnowledge/openknowledge`;return M(e,t)?t:null}function I(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`};let t;try{t=e.platform===`darwin`?A(e):e.platform===`win32`?P(e):F(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function L(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),r===`darwin`){E(`open`,[`-b`,`com.inkeep.open-knowledge`],{spawn:e.spawn});return}let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}E(i,[],{spawn:e.spawn})}function R(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function z(e){return h(m(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const B=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function ee(e){if(e.platform!==`darwin`||!B.test(e.execPath))return null;let t=z(e.execPath);return e.exists(t)?t:null}function V(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??v,a=r[1];return a?{command:ee({execPath:t,platform:n,exists:i})??t,prefixArgs:[a]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(r)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function te(e,t){return e.host??t.HOST??`127.0.0.1`}function H(e){let t=p(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var U=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function W(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 G(t){v(t.lockDir)||y(t.lockDir,{recursive:!0});let n=b(h(t.lockDir,e),`w`),r=t.spawn??f,{PORT:i,...a}=process.env,o=V();try{let e=r(o.command,[...o.prefixArgs,...t.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:t.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return e.unref(),e}finally{try{_(n)}catch{}}}function K(e,t,n){return e??(n===void 0?t:void 0)}function q(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function J(e,t,n){return e??+(t!=null&&!n)}async function Y(e){let t=e.spawn??f,n=V(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=J(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function X(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}const ne=t;function Z(e,t,n=e=>C(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function Q(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function $(e){let t=e.sigtermGraceMs??ne,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>w(e)),i=e.reason??`teardown`;try{let a=e.readUiLock(),o=e.spawnedUiPid();if(a&&e.isAlive(a.pid)&&a.pid!==o)e.log?.info({pid:a.pid,port:a.port,spawnedUiPid:o},`${i}: ui.lock holder is not our spawned sibling — leaving it alone`);else if(a&&e.isAlive(a.pid))try{e.killPid(a.pid,`SIGTERM`),e.log?.info({pid:a.pid,port:a.port},`${i}: SIGTERM UI sibling`);let o=Date.now()+t;for(;Date.now()<o&&e.isAlive(a.pid);)await r(n);if(e.isAlive(a.pid))try{e.killPid(a.pid,`SIGKILL`),e.log?.warn({pid:a.pid,graceMs:t},`${i}: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:a.pid,err:t},`${i}: SIGKILL failed`)}}catch(t){e.log?.warn({pid:a.pid,err:t},`${i}: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t},`${i}: UI lookup failed; proceeding`)}}function re(e){let{destroy:t,...n}=e;return async()=>{await $({...n,reason:`idle-shutdown`}),await t()}}async function ie(e){let{config:t,cwd:a,host:o}=e,s=e.skipAutoInit??!1,d=e.skipUiAutoSpawn??!1,f=e.idleThresholdMs??18e5,{existsSync:p,mkdirSync:m}=await import(`node:fs`),{basename:h,dirname:g}=await import(`node:path`),{bootServer:_,getLogger:v,isProcessAlive:y,readUiLock:b,resolveContentDir:x,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./src-Cf8OhPA7.mjs`),T=e.log??v(`start`),E=e.singleFile!==void 0,D=e.projectDir??a,O=E?r(e.singleFile).canonicalFilePath:void 0,k=O?g(O):void 0,A=O?h(O):void 0;if(!E){if(!s&&!i(a))throw new U(a);let t=process.env.OK_RECLAIM_DISABLE??null,n=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&T.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-CL00iu8h.mjs`)).repairMcpConfigs)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-BVxKvPAo.mjs`)).repairLaunchJson)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-DnayrFzZ.mjs`)).repairSkills)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let j=k??x(t,a);!E&&!p(j)&&(m(j,{recursive:!0}),T.info({contentDir:j},`Created content directory`));let M=null,N=null,P=async({lockDir:t})=>{if(M=W({uiLock:b(t),isAlive:y}),M.action===`spawn`&&!d)try{let n=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];N=G({lockDir:t,cwd:a,spawn:e.spawn,args:n}).pid??null,T.info({reason:M.reason,uiPort:e.uiPort},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else M.action===`skip`&&T.info({port:M.port,pid:M.pid},`UI already running at port ${M.port}`)},F=e.reactShellDistDir===void 0,I=c(),L=n();{let e=S(E?D:a),t=Date.now(),n=await C(e);n!==`no-drain`&&T.info({event:`start-waited-for-draining-predecessor`,outcome:n,waitedMs:Date.now()-t,drainLockDir:e},n===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let R=await _({config:t,contentDir:j,projectDir:E?D:a,contentRoot:E?void 0:t.content.dir,port:e.port,host:o,quiet:!1,detectGh:l,tokenStore:I,embeddingsKeyStore:L,...E?{ephemeral:!0,singleDocRelPath:A,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>u(e,t),attachUiSibling:F,idleShutdownMs:f,skipAutoInit:!0,...F?{spawnUiSiblingFn:P}:{},idleShutdownHandler:t=>{let n=re({readUiLock:()=>b(R.lockDir),spawnedUiPid:()=>N,isAlive:y,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:T});return Q(E?Z(n,D):n,{log:T,exit:e.idleExit})},log:T,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});M||={action:`skip`,reason:`alive`,pid:0,port:0};let z=M,B=null;if(z.action===`skip`)B=z.port>0?z.port:null;else if(!d){let t=e.uiBindTimeoutMs??3e3;B=await X({readUiLock:()=>b(R.lockDir),now:Date.now,sleep:e=>w(e),timeoutMs:t,pollIntervalMs:50}),B===null&&T.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:R.httpServer,destroy:R.destroy,lockDir:R.lockDir,contentDir:j,port:R.port,ready:R.ready,degraded:R.degraded,uiSpawnDecision:M,spawnedUiPid:N,resolvedUiPort:B}}function ae(e){if(e===`browser`||e===`app`)return e;throw new s(`--mode must be 'browser' or 'app'`)}function oe(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new s(`--ui-port must be a port number between 1 and 65535`);return t}function se(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function ce(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function le(e,t){let n=se(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner--DGfdMN8.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-MGDi6UGf.mjs`),c=process.cwd(),l=e;process.title=H(c);let u=te(t,process.env),f=t.port===void 0?void 0:Number(t.port),p=process.env.PORT?Number(process.env.PORT):void 0,m=t.uiPort===void 0?void 0:Number(t.uiPort),h=K(f,p,m);if(m!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./src-Cf8OhPA7.mjs`);if(q(m,e(t(c)))){await Y({cwd:c,uiPort:m});return}}let g;try{g=await ie({config:l,cwd:c,host:u,port:h,...m===void 0?{}:{uiPort:m},...t.serveContentAssets===void 0?{}:{serveContentAssets:t.serveContentAssets},...t.reactShellDistDir?{reactShellDistDir:t.reactShellDistDir}:{},...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{}})}catch(e){e instanceof U&&(console.error(o(e.message)),process.exit(1));let t=await import(`./src-Cf8OhPA7.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(o(e.message)),process.exit(1)),m!==void 0&&ue(e,t)){await Y({cwd:c,uiPort:m});return}let n=de(e,c,t);n!==null&&(console.error(o(n)),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let _=!1,v=async e=>{if(_)return;_=!0;let[t,...n]=ce(e);console.log(i(`\n${t}`));for(let e of n)console.log(a(` ${e}`));if(g.spawnedUiPid!==null)try{let{getLogger:e,isProcessAlive:t,readUiLock:n}=await import(`./src-Cf8OhPA7.mjs`);await $({readUiLock:()=>n(g.lockDir),spawnedUiPid:()=>g.spawnedUiPid,isAlive:t,killPid:(e,t)=>process.kill(e,t),log:e(`start`),reason:`shutdown`})}catch(e){console.error(`${o(`ui sibling teardown failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`)}try{await g.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{v(`SIGINT`)}),process.once(`SIGTERM`,()=>{v(`SIGTERM`)});let y=`http://${u}:${g.port}`,b=u===`0.0.0.0`||u===`::`?`http://0.0.0.0:${g.port}`:void 0,x=g.resolvedUiPort,S=x!==null&&x>0?`http://${u}:${x}`:y;console.log(r({name:`open-knowledge`,version:d,localUrl:S,apiUrl:S===y?void 0:y,networkUrl:b,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let C={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};g.ready.then(async()=>{if(g.degraded.length>0){console.log();for(let e of g.degraded){let t=C[e]??`${e} (check server logs for details)`;console.warn(` ${s(`⚠`)} ${s(e)}: ${a(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-BvP05JKj.mjs`);e(S)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function ue(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function de(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=h(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`OpenKnowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function fe(e){return new o(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`--ui-port <port>`,`Pin the ok ui sibling to <port> and connect (not exit) if a server already runs here — the worktree-preview recipe path`,oe).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ae).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path> (suppresses ok ui sibling)`).option(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).option(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
1
+ import{L as e,P as t}from"./src-BTs5LPkM.mjs";import{_i as n,a as r,gn as i,ui as a}from"./src-BbntdRLo.mjs";import{C as o,w as s}from"./write-project-skill-C-xPIQus.mjs";import{a as c,n as l,t as u}from"./acp-harness-probe-dWM8QqyG.mjs";import{n as d}from"./constants-BsMWdC-D.mjs";import{spawn as f}from"node:child_process";import{basename as p,dirname as m,join as h,win32 as g}from"node:path";import{closeSync as _,existsSync as v,mkdirSync as y,openSync as b,statSync as x}from"node:fs";import{homedir as S}from"node:os";import{rm as C}from"node:fs/promises";import{setTimeout as w}from"node:timers/promises";function T(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function E(e,t,n={}){let r=(n.spawn??f)(e,[...t],a({detached:!0,stdio:`ignore`,env:T(n.env??process.env)}));return r.unref(),r}const D=`OpenKnowledge.app`,O=`/Applications/${D}`;function k(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return x(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function A(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(j(e,O))return O;let t=h(e.homeDir??S(),`Applications`,D);return j(e,t)?t:null}function j(e,t){return M(e,h(t,`Contents`,`MacOS`,`OpenKnowledge`))}function M(e,t){try{let n=e.statSync(t);return n&&typeof n.isFile==`function`?n.isFile():!1}catch{return!1}}const N=[`@inkeepopen-knowledge-desktop`,`OpenKnowledge`];function P(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&/\\OpenKnowledge\.exe$/i.test(e.execPath))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of N){let r=g.join(t,`Programs`,n,`OpenKnowledge.exe`);if(M(e,r))return r}return null}function F(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&e.execPath.endsWith(`/openknowledge`))return e.execPath;let t=`/opt/OpenKnowledge/openknowledge`;return M(e,t)?t:null}function I(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`};let t;try{t=e.platform===`darwin`?A(e):e.platform===`win32`?P(e):F(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function L(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),r===`darwin`){E(`open`,[`-b`,`com.inkeep.open-knowledge`],{spawn:e.spawn});return}let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}E(i,[],{spawn:e.spawn})}function R(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function z(e){return h(m(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const B=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function ee(e){if(e.platform!==`darwin`||!B.test(e.execPath))return null;let t=z(e.execPath);return e.exists(t)?t:null}function V(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??v,a=r[1];return a?{command:ee({execPath:t,platform:n,exists:i})??t,prefixArgs:[a]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(r)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function te(e,t){return e.host??t.HOST??`127.0.0.1`}function H(e){let t=p(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var U=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function W(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 G(t){v(t.lockDir)||y(t.lockDir,{recursive:!0});let n=b(h(t.lockDir,e),`w`),r=t.spawn??f,{PORT:i,...a}=process.env,o=V();try{let e=r(o.command,[...o.prefixArgs,...t.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:t.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return e.unref(),e}finally{try{_(n)}catch{}}}function K(e,t,n){return e??(n===void 0?t:void 0)}function q(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function J(e,t,n){return e??+(t!=null&&!n)}async function Y(e){let t=e.spawn??f,n=V(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=J(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function X(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}const ne=t;function Z(e,t,n=e=>C(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function Q(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function $(e){let t=e.sigtermGraceMs??ne,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>w(e)),i=e.reason??`teardown`;try{let a=e.readUiLock(),o=e.spawnedUiPid();if(a&&e.isAlive(a.pid)&&a.pid!==o)e.log?.info({pid:a.pid,port:a.port,spawnedUiPid:o},`${i}: ui.lock holder is not our spawned sibling — leaving it alone`);else if(a&&e.isAlive(a.pid))try{e.killPid(a.pid,`SIGTERM`),e.log?.info({pid:a.pid,port:a.port},`${i}: SIGTERM UI sibling`);let o=Date.now()+t;for(;Date.now()<o&&e.isAlive(a.pid);)await r(n);if(e.isAlive(a.pid))try{e.killPid(a.pid,`SIGKILL`),e.log?.warn({pid:a.pid,graceMs:t},`${i}: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:a.pid,err:t},`${i}: SIGKILL failed`)}}catch(t){e.log?.warn({pid:a.pid,err:t},`${i}: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t},`${i}: UI lookup failed; proceeding`)}}function re(e){let{destroy:t,...n}=e;return async()=>{await $({...n,reason:`idle-shutdown`}),await t()}}async function ie(e){let{config:t,cwd:a,host:o}=e,s=e.skipAutoInit??!1,d=e.skipUiAutoSpawn??!1,f=e.idleThresholdMs??18e5,{existsSync:p,mkdirSync:m}=await import(`node:fs`),{basename:h,dirname:g}=await import(`node:path`),{bootServer:_,getLogger:v,isProcessAlive:y,readUiLock:b,resolveContentDir:x,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./src-CdRO3m1f.mjs`),T=e.log??v(`start`),E=e.singleFile!==void 0,D=e.projectDir??a,O=E?r(e.singleFile).canonicalFilePath:void 0,k=O?g(O):void 0,A=O?h(O):void 0;if(!E){if(!s&&!i(a))throw new U(a);let t=process.env.OK_RECLAIM_DISABLE??null,n=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&T.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-CRoM0Ijk.mjs`)).repairMcpConfigs)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-DTEGmN1O.mjs`)).repairLaunchJson)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-BNFFh5kk.mjs`)).repairSkills)({projectDir:a,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let j=k??x(t,a);!E&&!p(j)&&(m(j,{recursive:!0}),T.info({contentDir:j},`Created content directory`));let M=null,N=null,P=async({lockDir:t})=>{if(M=W({uiLock:b(t),isAlive:y}),M.action===`spawn`&&!d)try{let n=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];N=G({lockDir:t,cwd:a,spawn:e.spawn,args:n}).pid??null,T.info({reason:M.reason,uiPort:e.uiPort},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else M.action===`skip`&&T.info({port:M.port,pid:M.pid},`UI already running at port ${M.port}`)},F=e.reactShellDistDir===void 0,I=c(),L=n();{let e=S(E?D:a),t=Date.now(),n=await C(e);n!==`no-drain`&&T.info({event:`start-waited-for-draining-predecessor`,outcome:n,waitedMs:Date.now()-t,drainLockDir:e},n===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let R=await _({config:t,contentDir:j,projectDir:E?D:a,contentRoot:E?void 0:t.content.dir,port:e.port,host:o,quiet:!1,detectGh:l,tokenStore:I,embeddingsKeyStore:L,...E?{ephemeral:!0,singleDocRelPath:A,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>u(e,t),attachUiSibling:F,idleShutdownMs:f,skipAutoInit:!0,...F?{spawnUiSiblingFn:P}:{},idleShutdownHandler:t=>{let n=re({readUiLock:()=>b(R.lockDir),spawnedUiPid:()=>N,isAlive:y,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:T});return Q(E?Z(n,D):n,{log:T,exit:e.idleExit})},log:T,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});M||={action:`skip`,reason:`alive`,pid:0,port:0};let z=M,B=null;if(z.action===`skip`)B=z.port>0?z.port:null;else if(!d){let t=e.uiBindTimeoutMs??3e3;B=await X({readUiLock:()=>b(R.lockDir),now:Date.now,sleep:e=>w(e),timeoutMs:t,pollIntervalMs:50}),B===null&&T.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:R.httpServer,destroy:R.destroy,lockDir:R.lockDir,contentDir:j,port:R.port,ready:R.ready,degraded:R.degraded,uiSpawnDecision:M,spawnedUiPid:N,resolvedUiPort:B}}function ae(e){if(e===`browser`||e===`app`)return e;throw new s(`--mode must be 'browser' or 'app'`)}function oe(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new s(`--ui-port must be a port number between 1 and 65535`);return t}function se(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function ce(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function le(e,t){let n=se(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner--DGfdMN8.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-MGDi6UGf.mjs`),c=process.cwd(),l=e;process.title=H(c);let u=te(t,process.env),f=t.port===void 0?void 0:Number(t.port),p=process.env.PORT?Number(process.env.PORT):void 0,m=t.uiPort===void 0?void 0:Number(t.uiPort),h=K(f,p,m);if(m!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./src-CdRO3m1f.mjs`);if(q(m,e(t(c)))){await Y({cwd:c,uiPort:m});return}}let g;try{g=await ie({config:l,cwd:c,host:u,port:h,...m===void 0?{}:{uiPort:m},...t.serveContentAssets===void 0?{}:{serveContentAssets:t.serveContentAssets},...t.reactShellDistDir?{reactShellDistDir:t.reactShellDistDir}:{},...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{}})}catch(e){e instanceof U&&(console.error(o(e.message)),process.exit(1));let t=await import(`./src-CdRO3m1f.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(o(e.message)),process.exit(1)),m!==void 0&&ue(e,t)){await Y({cwd:c,uiPort:m});return}let n=de(e,c,t);n!==null&&(console.error(o(n)),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let _=!1,v=async e=>{if(_)return;_=!0;let[t,...n]=ce(e);console.log(i(`\n${t}`));for(let e of n)console.log(a(` ${e}`));if(g.spawnedUiPid!==null)try{let{getLogger:e,isProcessAlive:t,readUiLock:n}=await import(`./src-CdRO3m1f.mjs`);await $({readUiLock:()=>n(g.lockDir),spawnedUiPid:()=>g.spawnedUiPid,isAlive:t,killPid:(e,t)=>process.kill(e,t),log:e(`start`),reason:`shutdown`})}catch(e){console.error(`${o(`ui sibling teardown failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`)}try{await g.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{v(`SIGINT`)}),process.once(`SIGTERM`,()=>{v(`SIGTERM`)});let y=`http://${u}:${g.port}`,b=u===`0.0.0.0`||u===`::`?`http://0.0.0.0:${g.port}`:void 0,x=g.resolvedUiPort,S=x!==null&&x>0?`http://${u}:${x}`:y;console.log(r({name:`open-knowledge`,version:d,localUrl:S,apiUrl:S===y?void 0:y,networkUrl:b,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let C={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};g.ready.then(async()=>{if(g.degraded.length>0){console.log();for(let e of g.degraded){let t=C[e]??`${e} (check server logs for details)`;console.warn(` ${s(`⚠`)} ${s(e)}: ${a(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-B4QMCuDE.mjs`);e(S)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function ue(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function de(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=h(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`OpenKnowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function fe(e){return new o(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`--ui-port <port>`,`Pin the ok ui sibling to <port> and connect (not exit) if a server already runs here — the worktree-preview recipe path`,oe).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ae).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path> (suppresses ok ui sibling)`).option(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).option(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
2
2
  `),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.uiPort!==void 0&&e.push(`--ui-port`),t.host!==void 0&&e.push(`--host`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=I(k());if(n.available){L({spawn:f},n);return}console.error(R(n.reason)),process.exit(1)}await le(n,t)})}export{k as C,E,V as S,L as T,fe as _,J as a,Z as b,H as c,K as d,te as f,G as g,q as h,re as i,ce as l,le as m,X as n,Y as o,se as p,ie as r,W as s,U as t,ue as u,$ as v,I as w,Q as x,de as y};
3
- //# sourceMappingURL=start-5e_XN39i.mjs.map
3
+ //# sourceMappingURL=start-DtLzPL0C.mjs.map
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Fa as r,Ma as i,ja as a,wa as o}from"./src-3SN72BHH.mjs";import{Ar as s,Fr as c,Pr as l,Xr as u}from"./src-DAzaO37g.mjs";import{basename as d,dirname as f,isAbsolute as p,join as m,posix as h,relative as g,resolve as _,sep as v,win32 as y}from"node:path";import{cpSync as ee,existsSync as b,lstatSync as x,mkdirSync as te,readFileSync as ne,readdirSync as re,realpathSync as S,rmSync as C,rmdirSync as ie,statSync as ae}from"node:fs";import{homedir as w}from"node:os";var T=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})),E=n((e=>{let{InvalidArgumentError:t}=T();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;break}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})),D=n((e=>{let{humanReadableArgName:t}=E();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
1
+ import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Ia as r,Ma as i,Na as a,Ta as o}from"./src-BTs5LPkM.mjs";import{Ar as s,Fr as c,Pr as l,Xr as u}from"./src-BbntdRLo.mjs";import{basename as d,dirname as f,isAbsolute as p,join as m,posix as h,relative as g,resolve as _,sep as v,win32 as y}from"node:path";import{cpSync as ee,existsSync as b,lstatSync as x,mkdirSync as te,readFileSync as ne,readdirSync as re,realpathSync as S,rmSync as C,rmdirSync as ie,statSync as ae}from"node:fs";import{homedir as w}from"node:os";var T=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})),E=n((e=>{let{InvalidArgumentError:t}=T();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;break}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})),D=n((e=>{let{humanReadableArgName:t}=E();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})),O=n((e=>{let{InvalidArgumentError:t}=T();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?!1: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}
@@ -16,7 +16,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
16
16
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17
17
  - ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function c(e,t){let n=i.resolve(e,t);if(a.existsSync(n))return n;if(s.includes(i.extname(t)))return;let r=s.find(e=>a.existsSync(`${n}${e}`));if(r)return`${n}${r}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=i.resolve(i.dirname(e),d)}if(d){let t=c(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=i.basename(this._scriptPath,i.extname(this._scriptPath));n!==this._name&&(t=c(d,`${n}-${e._name}`))}u=t||u}n=s.includes(i.extname(u));let f;o.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.execPath,t,{stdio:`inherit`})):n?(t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.argv[0],t,{stdio:`inherit`})):f=r.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{o.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new l(e,`commander.executeSubCommandAsync`,`(close)`)):o.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)o.exit(1);else{let e=new l(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)===void 0?!1:this.getOptionValueSource(t)!==`default`});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
18
18
  `),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in o.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,o.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new p(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=m(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=m(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>c(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=i.basename(e,i.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(o.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
19
- Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}t.Command=h,t.useColor=_}));const{program:ce,createCommand:le,createArgument:ue,createOption:de,CommanderError:fe,InvalidArgumentError:pe,InvalidOptionArgumentError:me,Command:he,Argument:ge,Option:_e,Help:ve}=t(n((e=>{let{Argument:t}=E(),{Command:n}=se(),{CommanderError:r,InvalidArgumentError:i}=T(),{Help:a}=D(),{Option:o}=O();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default,k=a,A=i,j=r,M=`node`,N={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},P=`# ok-mcp-v2
19
+ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}t.Command=h,t.useColor=_}));const{program:ce,createCommand:le,createArgument:ue,createOption:de,CommanderError:fe,InvalidArgumentError:pe,InvalidOptionArgumentError:me,Command:he,Argument:ge,Option:_e,Help:ve}=t(n((e=>{let{Argument:t}=E(),{Command:n}=se(),{CommanderError:r,InvalidArgumentError:i}=T(),{Help:a}=D(),{Option:o}=O();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default,k=i,A=a,j=r,M=`node`,N={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},P=`# ok-mcp-v2
20
20
  USER_BUNDLE="$HOME/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
21
21
  [ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
22
22
  BUNDLE="/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
@@ -53,4 +53,4 @@ foreach ($d in $dirs) {
53
53
  }
54
54
  [Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
55
55
  exit 127`,I=`// ok-pi-bridge`,L=`${I}-v1`,ye=`ok-pi-managed-extension`;function be(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(L)}return!1}function R(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=_(e);if(d(t)===`cli.mjs`&&d(f(t))===`dist`)return t;let n=t.split(v),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?v:i.join(v),`packages`,`cli`,`dist`,`cli.mjs`)}function z(e={}){return e.mode===`dev`?{command:M,args:[R(),`mcp`],env:{...N}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{command:`/bin/sh`,args:[`-l`,`-c`,P]}}function xe(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[M,R(),`mcp`],environment:{...N}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,F]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,P]}}function Se(e){if(typeof e!=`object`||!e)return!1;let t=e;return B(t,z({mode:`published`,platformName:`darwin`}))||B(t,z({mode:`published`,platformName:`win32`}))}function B(e,t){return Object.keys(e).length===Object.keys(t).length?Ce(e,t):!1}function Ce(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 V(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);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]):!1}function we(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:V(t.args,t.command)}function Te(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`&&V(r,n)}function H(e){return e===`win32`?y:h}function Ee(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env,i=H(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 De(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.claude.json`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??w(),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??y.join(n,`AppData`,`Roaming`);return y.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.cursor`,`mcp.json`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??w();return(e.env??process.env).CODEX_HOME??H(t).join(n,`.codex`)}function G(e={}){return H(e.platformName??process.platform).join(Oe(e),`config.toml`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=(e.env??process.env).COPILOT_HOME??H(t).join(n,`.copilot`);return H(t).join(r,`mcp-config.json`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env,i=H(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 q(e={}){return H(e.platformName??process.platform).join(ke(e),`opencode.json`)}function Ae(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.openclaw`,`openclaw.json`)}function je(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.hermes`,`config.yaml`)}function Me(e={}){let t=e.platformName??process.platform,n=e.home??w();return(e.env??process.env).PI_CODING_AGENT_DIR??H(t).join(n,`.pi`,`agent`)}function Ne(e={}){let t=e.platformName??process.platform,n=e.home??w();return H(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Pe(e,t){let n=H(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function J(e={}){let t=e.platformName??process.platform,n=Pe(e.home??w(),t);return n.find(e=>b(e))||n.find(e=>b(f(e)))||n[0]}const Y={claude:{id:`claude`,label:A.claude,configPath:(e,t)=>De({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.claude`),projectConfigPath:e=>m(e,`.mcp.json`),projectSkillPath:e=>m(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:A[`claude-desktop`],configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(U({home:t}))},cursor:{id:`cursor`,label:A.cursor,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(W({home:t})),projectConfigPath:e=>m(e,`.cursor`,`mcp.json`),projectSkillPath:e=>m(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:A.codex,configPath:(e,t)=>G({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(G({home:t})),projectConfigPath:e=>m(e,`.codex`,`config.toml`),projectSkillPath:e=>m(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:A.copilot,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(K({home:t})),projectSkillPath:e=>m(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:A.opencode,configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>o,buildEntry:(e,t)=>xe(t),scope:`global`,detectPath:(e,t)=>f(q({home:t})),projectConfigPath:e=>m(e,`opencode.json`),projectSkillPath:e=>m(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:A.openclaw,configPath:(e,t)=>Ae({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:A.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>Me({home:t}),projectConfigPath:e=>m(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>m(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:A.antigravity,configPath:(e,t)=>Ne({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:A[`lm-studio`],configPath:(e,t)=>J({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(J({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:A.hermes,configPath:(e,t)=>je({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>o,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.hermes`),offerOnlyWhenDetected:!0}};function Fe(e){let t=e.filter(e=>!Object.hasOwn(Y,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${k.join(`, `)}`);return e.map(e=>Y[e])}const Ie=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],Le=[...c.map(e=>l[e]),`open-knowledge`];function X(e){if(!p(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=_(e);if(t===v||f(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Z(e,t){let n=g(e,t);if(n.startsWith(`..`)||p(n))return!1;let r=e;for(let e of n.split(v)){r=m(r,e);try{if(!x(r).isDirectory())return!1}catch{return!1}}return!0}function Re(e,t){try{return re(e).every(n=>t.has(m(e,n)))}catch{return!1}}function ze(e){let t=X(e),n=[],r=[],i=new Set;for(let e of Ie){let a=m(t,e.hostDir,`skills`);if(!Z(t,a))continue;let o=Le.map(e=>m(a,e)).filter(e=>b(e));n.push(...o);for(let e of o)i.add(e);let s=m(t,e.pruneRoot),c=a;for(;Re(c,i)&&(r.push(c),i.add(c),c!==s);){let e=f(c);if(e===c||e===t||!e.startsWith(t+v))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Be(e){try{if(!x(e).isDirectory())return!1;let t=re(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Ve(e){let t=new Set,n=new Set;for(let r of Ie){let i=m(e,r.hostDir,`skills`);for(let e of Le)t.add(m(i,e));let a=m(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=f(o);if(t===o||t===e||!t.startsWith(e+v))break;o=t}}return{skillDirs:t,emptyDirs:n}}function He(e,t){let n=X(e),r=Ve(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(Z(n,e)&&Be(e))try{C(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Z(n,e))try{ie(e),a.push(e)}catch{}return a}function Q(e){let t=X(e),n=[];for(let e of c){let r=l[e];n.push({path:m(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of j)n.push({path:m(t,i.hostDir,`skills`,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Ue(e,t){let n=[];for(let r of Q(e))if(r.bundleId===t)try{C(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function We(e,t){let n;try{n=x(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Ke(e,t)}function Ge(e,t){Ke(e,t)}function Ke(e,t){let n;try{n=S(t)}catch{n=_(t)}let r=f(e);for(;r.length>1&&r!==v;){let t;try{t=S(r)}catch(e){if(e.code===`ENOENT`){r=f(r);continue}throw e}let i=g(n,t);if(i===``||!i.startsWith(`..`)&&!p(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qe(e,t,n){try{if(ae(n).size>10485760)return!1}catch{return!1}let r;try{r=ne(n,`utf-8`)}catch{return!1}let i=[],a=u(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!$(a))return!1;let o=a[e.topLevelKey];if(!$(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;return $(s)?$(s[e.serverName(t)]):!1}function Je(e,t,n={}){if(e.id!==`copilot`)return!0;try{return qe(e,t,e.configPath(t,n.home))}catch{return!1}}function Ye(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Je(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=s(`project`,{checkDesktop:!0}),i=f(r);We(i,t);let a=b(r)?`overwritten`:`written`;return C(i,{recursive:!0,force:!0}),te(f(i),{recursive:!0}),ee(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function Xe(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=f(n);return b(n)?(Ge(r,t),C(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)}}}export{he as C,Fe as S,_e as T,we as _,He as a,Te as b,Q as c,Y as d,j as f,z as g,ye as h,Ye as i,k as l,L as m,Ge as n,ze as o,I as p,Xe as r,Ue as s,We as t,A as u,be as v,pe as w,Ee as x,Se as y};
56
- //# sourceMappingURL=write-project-skill-4OvW1cn1.mjs.map
56
+ //# sourceMappingURL=write-project-skill-C-xPIQus.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/open-knowledge",
3
- "version": "0.41.2",
3
+ "version": "0.41.4",
4
4
  "license": "GPL-3.0-or-later",
5
5
  "private": false,
6
6
  "type": "module",
@@ -61,10 +61,10 @@
61
61
  "ajv-formats": "^3.0.1",
62
62
  "tsdown": "^0.21.7",
63
63
  "typescript": "^5.9.3",
64
- "@inkeep/open-knowledge-core": "0.41.2",
64
+ "@inkeep/open-knowledge-core": "0.41.4",
65
65
  "@inkeep/open-knowledge-native-config": "0.0.0",
66
- "@inkeep/open-knowledge-app": "0.41.2",
67
- "@inkeep/open-knowledge-server": "0.41.2"
66
+ "@inkeep/open-knowledge-app": "0.41.4",
67
+ "@inkeep/open-knowledge-server": "0.41.4"
68
68
  },
69
69
  "scripts": {
70
70
  "build:cli": "tsdown",
@@ -1,2 +0,0 @@
1
- import"./src-3SN72BHH.mjs";var e=`0.41.2`;const t=`config.yml`,n=e;export{n,t};
2
- //# sourceMappingURL=constants-Ej-ZzjYT.mjs.map
@@ -1 +0,0 @@
1
- import{r as e}from"./git-handle-ZhJgz79A.mjs";export{e as createGitInstance};
@@ -1 +0,0 @@
1
- import{g as e}from"./init-CBWhyX1U.mjs";export{e as runInit};
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-C0DzGeNZ.mjs";export{e as loadConfig};
@@ -1,2 +0,0 @@
1
- import{Mi as e,da as t,ga as n}from"./src-3SN72BHH.mjs";const r=new e({extensions:t,deriveStructuralFreshness:!0}),i=n(t);export{i as n,r as t};
2
- //# sourceMappingURL=md-manager-BOzKVLRL.mjs.map
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-Dn1YxNMX.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +0,0 @@
1
- import{t as e}from"./index-DDSda67s.js";export{e as FeedbackForm};
@@ -1 +0,0 @@
1
- import{t as e}from"./repair-skills-xgU4BBSK.mjs";export{e as repairSkills};
@@ -1 +0,0 @@
1
- import{a as e,o as t,r as n}from"./server-lock-D7lpEbZj.mjs";export{n as markServerLockDraining,e as releaseServerLock,t as updateServerLockPort};
@@ -1 +0,0 @@
1
- import{Ba as e,C as t,Ea as n,Ha as r,Qa as i,Ta as a,d as o,l as s,uo as c,wa as l,y as u}from"./src-3SN72BHH.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Fr as W,Ft as G,G as K,Gi as q,Gn as J,Gr as Y,Gt as X,H as Z,Hi as Q,Hn as $,Hr as ee,Ht as te,I as ne,Ii as re,In as ie,Ir as ae,It as oe,J as se,Ji as ce,Jn as le,Jt as ue,K as de,Ki as fe,Kn as pe,Kr as me,Kt as he,L as ge,Li as _e,Ln as ve,Lr as ye,Lt as be,M as xe,Mi as Se,Mn as Ce,Mr as we,Mt as Te,N as Ee,Ni as De,Nn as Oe,Nr as ke,Nt as Ae,O as je,Oi as Me,On as Ne,Or as Pe,Ot as Fe,P as Ie,Pi as Le,Pn as Re,Pr as ze,Pt as Be,Q as Ve,Qi as He,Qn as Ue,Qr as We,Qt as Ge,R as Ke,Ri as qe,Rn as Je,Rr as Ye,Rt as Xe,S as Ze,Si as Qe,Sn as $e,Sr as et,St as tt,T as nt,Ti as rt,Tn as it,Tr as at,Tt as ot,U as st,Ui as ct,Un as lt,Ur as ut,Ut as dt,V as ft,Vi as pt,Vn as mt,Vr as ht,Vt as gt,W as _t,Wi as vt,Wn as yt,Wr as bt,Wt as xt,X as St,Xi as Ct,Xn as wt,Xt as Tt,Y as Et,Yi as Dt,Yn as Ot,Yt as kt,Z as At,Zi as jt,Zn as Mt,Zt as Nt,_ as Pt,_i as Ft,_n as It,_r as Lt,a as Rt,aa as zt,ai as Bt,an as Vt,ar as Ht,at as Ut,b as Wt,bi as Gt,bn as Kt,br as qt,bt as Jt,c as Yt,ca as Xt,ci as Zt,cn as Qt,cr as $t,ct as en,d as tn,da as nn,di as rn,dn as an,dr as on,dt as sn,ea as cn,ei as ln,en as un,er as dn,et as fn,f as pn,fa as mn,fi as hn,fn as gn,fr as _n,ft as vn,g as yn,gi as bn,gn as xn,gr as Sn,h as Cn,ha as wn,hi as Tn,hn as En,hr as Dn,i as On,ia as kn,ii as An,in as jn,ir as Mn,it as Nn,j as Pn,ji as Fn,jn as In,jr as Ln,jt as Rn,k as zn,ki as Bn,kn as Vn,kr as Hn,kt as Un,l as Wn,la as Gn,li as Kn,ln as qn,lr as Jn,lt as Yn,m as Xn,ma as Zn,mi as Qn,mn as $n,mr as er,n as tr,na as nr,ni as rr,nn as ir,nr as ar,nt as or,o as sr,oa as cr,oi as lr,on as ur,or as dr,ot as fr,p as pr,pa as mr,pi as hr,pn as gr,pr as _r,q as vr,qi as yr,qn as br,qt as xr,r as Sr,ra as Cr,ri as wr,rn as Tr,rr as Er,rt as Dr,s as Or,sa as kr,si as Ar,sn as jr,sr as Mr,st as Nr,t as Pr,ta as Fr,ti as Ir,tn as Lr,tr as Rr,tt as zr,u as Br,ua as Vr,ui as Hr,un as Ur,ur as Wr,ut as Gr,v as Kr,vi as qr,vn as Jr,vr as Yr,w as Xr,wi as Zr,wn as Qr,wr as $r,wt as ei,x as ti,xi as ni,xn as ri,xr as ii,xt as ai,y as oi,yi as si,yn as ci,yr as li,yt as ui,z as di,zi as fi,zn as pi,zr as mi,zt as hi}from"./src-DAzaO37g.mjs";import{C as gi,E as _i,T as vi,_ as yi,b as bi,c as xi,d as Si,g as Ci,i as wi,l as Ti,m as Ei,n as Di,p as Oi,s as ki,t as Ai,u as ji,v as Mi,w as Ni,x as Pi,y as Fi}from"./fs-traced-Cc6WsRtP.mjs";import{a as Ii,d as Li,f as Ri,i as zi,l as Bi,n as Vi,r as Hi,t as Ui,u as Wi}from"./logger-B7Z8XO-z.mjs";import{_ as Gi,a as Ki,b as qi,c as Ji,f as Yi,g as Xi,h as Zi,i as Qi,l as $i,m as ea,n as ta,o as na,p as ra,r as ia,s as aa,t as oa,u as sa,v as ca,y as la}from"./server-lock-D7lpEbZj.mjs";export{cr as AGENT_ID_MAX_LEN,kr as AGENT_ID_RE,S as AGENT_WRITE_ORIGIN,mr as AcpPermissionStore,Vr as AcpRegistry,_e as AcpThreadManager,H as AgentFocusBroadcaster,Le as AgentPresenceBroadcaster,pt as AgentSessionCapacityError,Q as AgentSessionManager,Jt as AutoStartDisabledError,we as BUNDLE_IDS,ke as BUNDLE_SCOPE,ze as BUNDLE_SKILL_NAME,Mt as BacklinkIndex,Dt as CC1Broadcaster,r as CC1_CONTRACT_VERSION,jr as CONFIG_FILENAME,pe as CONFLICT_MARKER_RE,rr as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pt as ConfigSchema,In as DEFAULT_CHECKPOINT_RETENTION,qr as DEFAULT_EMBEDDINGS_DIMENSIONS,Xe as DEFAULT_PACK_ID,K as DocumentDurabilityState,si as EMBEDDINGS_API_KEY_ENV,nn as FEATURED_AGENT_IDS,Ce as FILE_SYSTEM_WRITER,wt as FILE_WATCHER_ORIGIN,hn as FileEmbeddingsBackend,ir as GIT_PREFLIGHT_FAIL_SPAN_NAME,Oe as GIT_UPSTREAM_WRITER,Zn as GitDirAccessError,Mn as GitNotAvailableError,Ht as GitTooOldError,ai as HOCUSPOCUS_AUTH_REJECTION_REASONS,tt as HocuspocusAuthRejection,A as HocuspocusAuthTokenSchema,Zt as INSTALLED_AGENTS_SCHEMES,e as LINEAGE_EPOCH_KEY,Z as LIVE_DERIVED_INDEX_DEBOUNCE_MS,hi as LOG_MD_TEMPLATE,Un as MANAGED_RENAME_ORIGIN,qe as MAX_ACP_THREADS,ct as MAX_AGENT_SESSIONS,sn as MCP_CONNECTION_ID_HEADER,l as MCP_SERVER_NAME,vt as MIN_EVICTABLE_IDLE_MS,dr as MIN_GIT_VERSION,de as MISSING_OK_CONFIG_MESSAGE,wn as MalformedGitPointerError,Dr as McpLogger,vr as MissingOkConfigError,V as OBSERVER_SYNC_ORIGIN,Qt as OK_OKIGNORE_TEMPLATE,a as ORPHAN_MODES,c as PROTOCOL_VERSION,Ui as PinoLogger,Ji as ProcessLockCollisionError,Wn as ProjectGitInitError,b as ROLLBACK_ORIGIN,qn as ROOT_GITIGNORE_TEMPLATE,Xi as RUNTIME_VERSION,Re as SERVICE_WRITER,P as SKILL_INSTALL_EVENTS_FILE_REL,u as SKILL_STATE_TARGETS,T as STARTER_FOLDERS,gt as STARTER_FOLDER_FRONTMATTER_FILENAME,te as STARTER_PACKS,dt as STARTER_PACK_IDS,xt as STARTER_TEMPLATES,I as STATE_MANIFEST_FILENAME,Gi as STATE_SCHEMA_VERSION,i as SYSTEM_DOC_NAME,Tt as SeedPrerequisiteError,Nt as SeedRootDirError,oa as ServerLockCollisionError,Pr as SingleFileNotAFileError,tr as SingleFileNotFoundError,Sr as SingleFileNotMarkdownError,j as StateManifestError,nt as TagIndex,W as USER_GLOBAL_BUNDLE_IDS,p as UiLockCollisionError,Rn as __getShowAllWalkStatsForTesting,Te as __resetShowAllWalkStatsForTesting,$i as acquireProcessLock,ta as acquireServerLock,dn as acquireUiLock,q as applyAgentMarkdownWrite,Vn as applyExternalChange,be as applySeed,je as assertCompatibleStateManifest,Mr as assertGitAvailable,It as assertNeverDiskEvent,re as attachAcpThreadSocket,ui as attachIdleShutdown,Kr as bootServer,Sn as buildAndOpenSkill,Ur as buildConfigYmlContent,Ve as buildExecResult,fi as buildOkMcpStdioCommand,Hn as buildSkillZip,X as buildStarterFolderFrontmatterYaml,U as buildWipTree,ae as bundleSkillMdPath,hr as canonicalProjectKey,Jr as classifyEvents,Ai as classifyFsPath,Qn as clearAllEmbeddingsKeys,ni as clearContributors,he as coercePackId,s as colorFromSeed,ie as commitUpstreamImport,ve as commitWip,Je as commitWipFromTree,$t as compareSemver,mi as composeEffectiveLinterConfig,w as composeFrontmatterSchemasConfig,br as containsConflictMarkers,ci as contentHash,Qe as contributorCount,Ke as countShadowObjects,di as countStaleAgentWipRefs,x as countWipRefs,Ae as createApiExtension,Fn as createAssetServeMiddleware,We as createContentFilter,m as createContentFilterAsync,Tn as createEmbeddingsSecretStore,On as createEphemeralProjectDir,v as createExternalChangeHandler,pn as createFileLogger,st as createLiveDerivedIndexExtension,St as createMcpHttpHandler,Kn as createOsProbe,Ie as createPersistenceExtension,E as createServer,xe as createServerObserverExtension,fe as createStreamingErrorWriter,Vi as createTestLogger,bn as describeStoredEmbeddingsKey,yn as detectClaudeDesktopPresence,Jn as detectGit,zn as detectProjectShape,Lt as detectUserSkillHosts,fr as discoverLockDirs,ut as discoverMarkdownlintConfig,Tr as emitPreflightFailureSpan,d as encodeDocName,fn as encodeFolderRoute,zr as encodeSkillRoute,Br as ensureProjectGit,an as ensureProjectSkillGitignore,yr as errorResponse,Kt as evictStaleTrackerEntries,Nr as extractOkBinaryPath,Ue as extractWikiLinksFromMarkdown,Wr as fallbackPaths,tn as findEnclosingGitRoot,En as findEnclosingProjectRoot,bt as findNativeMarkdownlintFile,pr as flushFileLogger,ei as formatAuthRejectionWire,D as formatContributors,Zr as formatContributorsFrom,G as formatPackRationale,pi as gcCheckpointRefs,Nn as getCurrentMcpLogger,Me as getLocalDir,Xn as getLogFilePath,Hi as getLogger,Cn as getLogsDir,qi as getMachineId,Fi as getMeter,Fr as getMetrics,bi as getTracer,nr as handleCollabSocketError,wr as handleSpawnCursor,ft as hasGcLogLatch,o as iconFromClientName,Cr as incrementCollabSocketFilteredError,kn as incrementServerObserverFire,gn as initContent,C as initShadowRepo,Pi as initTelemetry,Wt as initToleranceTelemetryWriter,Gr as installPrettyZodErrors,zi as installTestLoggers,Yr as installUserSkill,De as isAllowedApiOrigin,Ge as isAllowedWorkspaceHostHeader,Ct as isConfigDoc,ot as isHocuspocusAuthRejectionReason,xr as isKnownPackId,jt as isLinkIndexExcludedDoc,h as isLoopbackAddress,He as isManagedArtifactDoc,n as isOrphanMode,ne as isPairedWriteOrigin,An as isPathWithinDir,ca as isProcessAlive,xn as isProjectRoot,_n as isProjectSkillManaged,f as isReservedForUserTree,ri as isSelfWrite,cn as isSystemDoc,ti as isToleranceTelemetryEnabled,la as isValidLockPid,$e as lastKnownHash,mt as listRescueCheckpoints,ue as listStarterPacks,mn as loadCustomAgents,Ee as loadPrincipal,sa as lockFilePath,Ii as loggerFactory,Bi as logsCurrentPath,Wi as logsPreviousPath,Ft as makeLazyEmbeddingsKeyStore,ia as markServerLockDraining,se as mountMcpAndApi,Di as normalizeFsPath,ye as originGitHubHost,gr as packageVersionMajorMinor,B as parseAuthRejectionWire,on as parseGitVersion,F as parseHocuspocusAuthToken,Et as parseKeepaliveConnectionId,O as pathToDocName,oe as planSeed,Rt as prepareSingleFileOpen,en as processCommand,Yn as processUsage,li as readAllTargets,qt as readBundleDecision,Y as readOwnNativeRules,Yi as readProcessLock,ra as readProcessLockDetailed,_t as readProjectHeadState,rn as readProjectLocalSemanticConfig,Qi as readServerLock,ii as readServerPackageVersion,et as readSkillInstallStateSnapshot,_r as readSkillManagement,g as readStateManifest,k as readTargetRecordedAt,$r as readTargetVersion,Rr as readUiLock,le as reconcile,rt as recordContributor,Pe as recordSkillInstallEvent,At as registerAllTools,Qr as registerWrite,ea as releaseProcessLock,Ki as releaseServerLock,ar as releaseUiLock,it as removeLastKnownHash,zt as resetMetrics,t as resolveBundleEnabled,y as resolveBundledSkillDir,Bn as resolveContentDir,Bt as resolveCursorBinaryDefault,lr as resolveCursorSpawnInvocation,ht as resolveEffectiveLinterConfig,Gt as resolveEmbeddingsCredential,_ as resolveLockDir,ee as resolveNativeConfigForDoc,me as resolveNativeMarkdownlintConfig,kt as resolvePack,Or as resolvePackageVersion,or as resolveUiInfo,L as restoreContributors,oi as restoreLifecycleFromConflictsJson,ln as rewriteMarkdownLinksForDocumentRename,Ir as rewriteWikiLinksForDocumentRename,jn as runAuthReposSubprocess,Vt as runAuthStatusSubprocess,un as runCloneSubprocess,ur as runDeviceFlowSubprocess,Ut as runWithMcpLogger,Se as safeContentPath,Be as safeSubdir,$ as safetyCheckpoint,vn as sanitizeClientName,lt as saveInMemoryCheckpoint,yt as saveVersion,Fe as seedBasenameIndex,sr as serializeError,gi as setActiveSpanAttributes,ge as setupServerObservers,J as shadowGit,Ni as shutdownTelemetry,er as skillManagementPath,Li as spansCurrentPath,Ri as spansPreviousPath,Ar as spawnDetached,Ot as splitMarkdownBlocks,R as startWatcher,ce as streamingProblemEvent,M as swapContributors,Ze as teardownToleranceTelemetryWriter,Xt as toBroadcasterKey,wi as tracedAppendFileSync,ki as tracedLinkSync,xi as tracedMkdir,Ti as tracedMkdirSync,ji as tracedRename,Si as tracedRenameSync,Oi as tracedRmSync,Ei as tracedRmdirSync,Ci as tracedUnlinkSync,yi as tracedWriteFile,Mi as tracedWriteFileSync,Xr as trustSystemCertificates,Yt as untrackTrackedProjectSkillProjection,N as updateLastKnownHash,Zi as updateProcessLockPort,na as updateServerLockPort,Er as updateUiLockPort,Gn as validateAgentId,Lr as validateCloneInputs,Ln as validateSkillZip,aa as waitForServerLockDrain,Hr as withHiddenWindowsConsole,vi as withSpan,_i as withSpanSync,at as writeBundleDecision,Ye as writeMarkdownlintRule,$n as writeRootGitignoreForNewRepo,Dn as writeSkillManagement,Pn as writeStateManifest,z as writeTargetVersion,Ne as writeTracker};