@inkeep/open-knowledge 0.52.0-beta.6 → 0.52.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{acp-harness-probe-Oco-vzbb.mjs → acp-harness-probe-BLW7TG44.mjs} +2 -2
- package/dist/assets/skills/project/references/linking.md +1 -1
- package/dist/cli.mjs +62 -62
- package/dist/constants-WNkLKsdC.mjs +2 -0
- package/dist/git-handle-CEoe8TIl.mjs +1 -0
- package/dist/{git-handle-CH1DpBYP.mjs → git-handle-VuHcNtS4.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{init-3ynssnTV.mjs → init-DFqv4VXb.mjs} +4 -4
- package/dist/init-DRqidFTq.mjs +1 -0
- package/dist/{launch-json-removal-CPurK0jD.mjs → launch-json-removal-DThHl9wH.mjs} +2 -2
- package/dist/loader-DJ8CWiSo.mjs +1 -0
- package/dist/{loader-DAruuWzH.mjs → loader-wzkezGJ8.mjs} +2 -2
- package/dist/md-manager-45eVlaBq.mjs +2 -0
- package/dist/{open-browser-CtVpc_8x.mjs → open-browser-BA50pLLQ.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-CC6sojTR.mjs → preview-B5WQN0UF.mjs} +2 -2
- package/dist/preview-Bh7vu-ai.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-BrdwpjRB.js → ActivityModeContent-BmQRzJZw.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-D56wAlnw.js → AgentDiffPane-DCXp5E1P.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-Bq0gVhV7.js → AgentThreadClientBinder-B7pwGsKU.js} +1 -1
- package/dist/public/assets/{ChangedOutsideBadge-6xW5IDHL.js → ChangedOutsideBadge-J6l1plFR.js} +1 -1
- package/dist/public/assets/CodeMirrorPropInput-DiDkBTg6.js +3 -0
- package/dist/public/assets/DocumentContext-J495RUh0.js +38 -0
- package/dist/public/assets/{EditorModeToggle-Big-nZpB.js → EditorModeToggle-BsFjeEn4.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-Dnl12e_9.js → EnableSyncConfirmDialog-DNDI39lu.js} +1 -1
- package/dist/public/assets/FeedbackForm-BwQovorQ.js +1 -0
- package/dist/public/assets/{GraphPanel-BxgcJTL5.js → GraphPanel-CsRKre3D.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-Dxe9uGaK.js → ImportSkillDialog-DNZi7-O6.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-3U8aK9da.js → LintConfigEditor-nq2Ekm-O.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-CeSsPfJA.js +2 -0
- package/dist/public/assets/ManagedArtifactProperties-D5Q8gGkr.js +1 -0
- package/dist/public/assets/{McpConsentDialogBody-Dt3X7boO.js → McpConsentDialogBody-DEhSeOSg.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-d-Wp_Ka_.js → MermaidDocEditor-DceTAjtX.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-w6ZUZtd9.js → ReportBugDialogBody-DO7eotFd.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-FYNlbIie.js → SchemaConfigEditor-D23bGRYq.js} +1 -1
- package/dist/public/assets/{SessionsHost-BUC4h4T5.js → SessionsHost-BD8Io20F.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-BAUPvgPO.js → SettingsDialogBody-D_2SfOcL.js} +4 -4
- package/dist/public/assets/{ShareBranchSwitchDialog-BMXRhCIc.js → ShareBranchSwitchDialog-B7Bl6qR0.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-D8o-97rY.js → ShareReceiveDialog-BmMkjWTr.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-DPKorVX0.js → ShareReceiveMissDialog-BDYU64bD.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-BpiKPrLW.js → SkillEditBanner-B2U7UdOB.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-C1YncGFC.js → SkillOriginInline-B3wOLT3t.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-DMHQY-lw.js → SkillToolbarControls-BP8iught.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-DNGGM8G-.js → SlidesToolbarControls-56-P71vE.js} +1 -1
- package/dist/public/assets/{SourceEditor-Bt93LccY.js → SourceEditor-8vj7fGo1.js} +1 -1
- package/dist/public/assets/{TerminalPanel-c_g1B919.js → TerminalPanel-Clr6j-jo.js} +3 -3
- package/dist/public/assets/{TerminalWindowApp-QRDsxPvH.js → TerminalWindowApp-Bzu1XJoP.js} +1 -1
- package/dist/public/assets/{TextDocEditor-CGo9TVsr.js → TextDocEditor-Kaj3NBL9.js} +1 -1
- package/dist/public/assets/{ThreadView-D4m34cEL.js → ThreadView-C0oxDyxf.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-DLergBgi.js → TimelineDiffPane-CG6Z1uma.js} +1 -1
- package/dist/public/assets/{agent-diff-store-DvvlIWsW.js → agent-diff-store-DxMs0J9Y.js} +1 -1
- package/dist/public/assets/{auth-state-cache-se0_UkK4.js → auth-state-cache-CGY7eNch.js} +3 -3
- package/dist/public/assets/client-version-BenFW72U.js +1 -0
- package/dist/public/assets/comment-chips-Q0_SZK9C.js +5 -0
- package/dist/public/assets/{config-provider-cC1aAoqP.js → config-provider-B6fsarOv.js} +2 -2
- package/dist/public/assets/{dist-DPUOICsM.js → dist-ILlrHFKs.js} +183 -183
- package/dist/public/assets/{doc-paths-6W3B04qd.js → doc-paths-DAh95jxf.js} +1 -1
- package/dist/public/assets/{documents-events-CFb6q7t5.js → documents-events-CCW6R-r2.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-DhmmoAjL.js → file-tree-adapter-Bf1ZqkPA.js} +1 -1
- package/dist/public/assets/{file-tree-utils-Dua-6LtX.js → file-tree-utils-CgJ4lrP9.js} +1 -1
- package/dist/public/assets/{folder-config-api-CrrPk9A0.js → folder-config-api-CKV5STj1.js} +1 -1
- package/dist/public/assets/follow-file-D4LD9UAw.js +4 -0
- package/dist/public/assets/i18n-C3d0M4ue.js +1 -0
- package/dist/public/assets/{index-Bme5x35Q.js → index-Du6HTehY.js} +14 -14
- package/dist/public/assets/{lint-config-client-DPwH-VHu.js → lint-config-client-xawAT1mQ.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-BdGLlEVb.js → markdownlint-rule-browser-B3UPVPG_.js} +1 -1
- package/dist/public/assets/navigation-targets-C1boWExT.js +1 -0
- package/dist/public/assets/{open-managed-artifact-tab-Cojj8juW.js → open-managed-artifact-tab-G7xdjHph.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-wVA1ZjL8.js → pending-receive-nav-store-BZigj_ik.js} +1 -1
- package/dist/public/assets/prop-types-BIrEWnOv.js +1 -0
- package/dist/public/assets/{receive-store-CFEx5X5f.js → receive-store-BrOspwat.js} +1 -1
- package/dist/public/assets/{selection-context-Bq_81z9T.js → selection-context-PgPm0oHr.js} +1 -1
- package/dist/public/assets/{skill-actions-BfBwH98z.js → skill-actions-Btw-8DsB.js} +2 -2
- package/dist/public/assets/{skill-scope-TY2S7Be7.js → skill-scope-8PP6d5Gw.js} +1 -1
- package/dist/public/assets/{skills-api-OBRuLm8a.js → skills-api-DQ0PK-8O.js} +1 -1
- package/dist/public/assets/{src-CDup1x-i.js → src-DoCu_Oe2.js} +1 -1
- package/dist/public/assets/{tag-pill-input-CIUq78uG.js → tag-pill-input-BHj2SAnj.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-TFQElcz0.js → target-navigation-intent-DpIU3fe6.js} +1 -1
- package/dist/public/assets/{terminal-cli-display-DphQFt7y.js → terminal-cli-display-CgJpdKCI.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-CkYhv0hD.js → terminal-launch-events-DQ0KtteM.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-BrUGs0cG.js → terminal-telemetry-CE1yzjKD.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-3ZZiF2mv.js → typing-burst-detector-XmZhxL72.js} +3 -3
- package/dist/public/assets/{uninstall-ocJf-hjC.js → uninstall-CDJGY7Qx.js} +1 -1
- package/dist/public/assets/{use-activity-panel-B8mUHgso.js → use-activity-panel-DeQ1S88x.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-C68-iamG.js → use-apply-config-color-theme-BatIDUX7.js} +1 -1
- package/dist/public/assets/{use-collab-url-CJzhnqks.js → use-collab-url-7XE2_0_k.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-BnbloOyE.js → use-live-xterm-theme-DS89T4Os.js} +1 -1
- package/dist/public/assets/{use-open-skill-BQ_vHG4k.js → use-open-skill-CgnR7yXa.js} +1 -1
- package/dist/public/assets/{use-popular-skills-DOSbQRlG.js → use-popular-skills-BefXxEcp.js} +1 -1
- package/dist/public/assets/{use-settings-route-Cv-ibnUF.js → use-settings-route-DN0TWdfX.js} +1 -1
- package/dist/public/assets/{use-skill-origin-clrL7XV6.js → use-skill-origin-COh1_mOK.js} +1 -1
- package/dist/public/assets/{use-skills-BDWr4yYQ.js → use-skills-C_HuRxth.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-CRhATtRE.js → use-terminal-enabled-DPQRp9bB.js} +1 -1
- package/dist/public/assets/use-timeline-entry-diff-Bw_6uLLl.js +6 -0
- package/dist/public/assets/{use-workspace-DNFQbKXx.js → use-workspace-CNCW4CS8.js} +1 -1
- package/dist/public/index.html +44 -44
- package/dist/public/uninstall.html +3 -3
- package/dist/{repair-launch-json-mJ3Ye_Mw.mjs → repair-launch-json-C2_MEgOS.mjs} +2 -2
- package/dist/{repair-mcp-configs-BeS1bCUD.mjs → repair-mcp-configs-Ceivh0g-.mjs} +2 -2
- package/dist/repair-skills-BWNXcIRv.mjs +1 -0
- package/dist/{repair-skills-Dn9wtbHi.mjs → repair-skills-Dk0Hee-r.mjs} +2 -2
- package/dist/server-lock-CDm0H6LS.mjs +1 -0
- package/dist/{server-lock-D8tFCW-G.mjs → server-lock-CeKMy65H.mjs} +2 -2
- package/dist/{skill-teardown-riJHlPak.mjs → skill-teardown-DtXC2fAI.mjs} +2 -2
- package/dist/{src-CeMQBLDa.mjs → src--XQg-7vm.mjs} +1 -1
- package/dist/{src-RGB2pEts.mjs → src-Dj6UxpKM.mjs} +124 -124
- package/dist/{src-BVxZYLJj.mjs → src-DvuwJKkU.mjs} +328 -328
- package/dist/src-VQFi4saV.mjs +1 -0
- package/dist/{src-Dc3F4mTO.mjs → src-WP_osKfx.mjs} +4 -4
- package/dist/start-CS7u5aKZ.mjs +12 -0
- package/dist/start-DZkQW5RE.mjs +1 -0
- package/dist/{ui-CyO6JCpp.mjs → ui-7z12LoCq.mjs} +3 -3
- package/dist/{write-project-skill-Bx22NW0a.mjs → write-project-skill-DUj7e5tZ.mjs} +3 -3
- package/package.json +4 -4
- package/dist/constants-C3LdY4-b.mjs +0 -2
- package/dist/git-handle-D_uW8fTU.mjs +0 -1
- package/dist/init-Djv0aq5j.mjs +0 -1
- package/dist/loader-Cwl2ZS4i.mjs +0 -1
- package/dist/md-manager-CUGZ0GRt.mjs +0 -2
- package/dist/preview-CYRkVM0P.mjs +0 -1
- package/dist/public/assets/CodeMirrorPropInput-D11rfM17.js +0 -3
- package/dist/public/assets/DocumentContext-DCB_2FMP.js +0 -38
- package/dist/public/assets/FeedbackForm-goeo0WLf.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-Bn-na6ua.js +0 -2
- package/dist/public/assets/ManagedArtifactProperties-DQMTHKMr.js +0 -1
- package/dist/public/assets/client-version-Cv0iyIKr.js +0 -1
- package/dist/public/assets/comment-chips-DTAZbaPZ.js +0 -5
- package/dist/public/assets/follow-file-K86Sp_6-.js +0 -4
- package/dist/public/assets/i18n-BnkAuR_3.js +0 -1
- package/dist/public/assets/navigation-targets-DSqzY6pU.js +0 -1
- package/dist/public/assets/prop-types-7a0cKWM0.js +0 -1
- package/dist/public/assets/use-timeline-entry-diff-C3vXYWPC.js +0 -6
- package/dist/repair-skills-cJ41S9pk.mjs +0 -1
- package/dist/server-lock-CTrzO_5l.mjs +0 -1
- package/dist/src-DDuAov3v.mjs +0 -1
- package/dist/start-B0EAId8s.mjs +0 -1
- package/dist/start-Coiq5FC4.mjs +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./src-Dj6UxpKM.mjs";import"./write-project-skill-DUj7e5tZ.mjs";import"./src-WP_osKfx.mjs";import"./acp-harness-probe-BLW7TG44.mjs";import"./init-DFqv4VXb.mjs";import{n as e}from"./loader-wzkezGJ8.mjs";import"./skill-teardown-DtXC2fAI.mjs";import"./preview-B5WQN0UF.mjs";import"./mcp-migrate-event-B1gJf6bG.mjs";export{e as loadConfig};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sleep-A0G7hOuG.mjs";import{
|
|
2
|
-
`);g.addBuffer(Buffer.from(C,`utf8`),`README.md`),g.end();let w=fe(r);return g.outputStream.pipe(w),await new Promise((e,t)=>{w.on(`close`,e),w.on(`error`,t)}),
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sleep-A0G7hOuG.mjs";import{$s as i,Qs as a,et as o,to as s,tt as c}from"./src-Dj6UxpKM.mjs";import{Nn as l,Zr as u,at as d,bi as f,it as p,ot as m,rt as h}from"./src-DvuwJKkU.mjs";import{D as ee,F as g,I as _,k as v}from"./fs-traced-DV9uD41t.mjs";import{C as y,S as b,d as x,y as S}from"./server-lock-CeKMy65H.mjs";import{t as C}from"./yazl-DZr4PyKA.mjs";import{m as w,p as te,v as T}from"./write-project-skill-DUj7e5tZ.mjs";import{c as ne}from"./colors-BsmVIwfM.mjs";import{n as re}from"./acp-harness-probe-BLW7TG44.mjs";import{E,T as D,_ as ie,o as O,w as k,x as ae,y as oe}from"./init-DFqv4VXb.mjs";import{n as se}from"./constants-WNkLKsdC.mjs";import{t as A}from"./is-object-ByG7RnjH.mjs";import"./loader-wzkezGJ8.mjs";import"./skill-teardown-DtXC2fAI.mjs";import"./preview-B5WQN0UF.mjs";import{execSync as ce,spawnSync as j}from"node:child_process";import{basename as M,dirname as N,join as P,relative as le,resolve as F,sep as ue}from"node:path";import{cpSync as de,createWriteStream as fe,existsSync as I,lstatSync as pe,mkdirSync as L,mkdtempSync as me,readFileSync as R,readdirSync as z,readlinkSync as he,rmSync as B,statSync as ge,writeFileSync as V}from"node:fs";import{arch as _e,freemem as ve,homedir as H,hostname as ye,platform as be,release as xe,tmpdir as Se,totalmem as Ce,type as we,uptime as Te}from"node:os";import"node:fs/promises";import{createHash as Ee}from"node:crypto";var U=n();const De=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Oe(e,t,n=l){if(e!==void 0&&!De.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let ke=null;function Ae(e){ke=e}function je(){return ke??process.cwd()}function Me(){return P(H(),`.ok`,`bug-reports`)}function Ne(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Me(),r=`${t}-bugreport`,i=P(n,`${r}.zip`);for(let e=2;I(i);e+=1)i=P(n,`${r}-${e}.zip`);return i}function Pe(e,t){let n=P(e,`.ok`,`config.yml`);if(I(n))try{let e=R(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 I(P(e,`.ok`))?Ee(`sha256`).update(F(e)).digest(`hex`).slice(0,12):null}function Fe(){let e={timestamp:new Date().toISOString(),platform:be(),osType:we(),osRelease:xe(),hostname:`[redacted]`,uptime:Te(),freeMem:ve(),totalMem:Ce(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ce(`sw_vers -productVersion 2>/dev/null`,u({encoding:`utf8`})).trim()}catch{}try{let t=P(__dirname,`..`,`..`,`package.json`);I(t)&&(e.okVersion=JSON.parse(R(t,`utf8`)).version)}catch{}return e}const Ie=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function W(e){let t=M(e);return Ie.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Le(e,t){return Be(e,t).files}const Re=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function ze(e,t=re){let n=P(e,`${t}.ShipIt`);return I(n)?Re.map(e=>P(n,e)).filter(e=>I(e)):[]}function Be(e,t){if(!I(t))return{files:[],excludedByProjectSlug:0};let n=z(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>P(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(W),i=[],a=r.filter(t=>{try{return R(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!W(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ve(e){let t=P(e,`.ok`,`local`);return I(t)?{files:[`server.lock`,`last-spawn-error.log`,o].map(e=>P(t,e)).filter(e=>I(e))}:{files:[]}}function He(e){let t=P(e,`.ok`,`local`,`logs`);return I(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>P(t,e)).filter(e=>I(e))}:{files:[]}}function Ue(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=i(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 G(e){for(let t of e.files)try{Ue({zipfile:e.zipfile,name:`${e.prefix}/${M(t)}`,content:R(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 We(t){let{redact:n,outputPath:r,logger:i}=t,o=t.userLogsDir??P(H(),`.ok`,`logs`),s=t.projectDir?Pe(t.projectDir,i):null;L(N(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=Fe();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=Be(s,o),{files:d}=t.projectDir?Ve(t.projectDir):{files:[]},{files:f}=t.projectDir?He(t.projectDir):{files:[]},p=t.shipItLogFiles??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length},`files collected`);let m=[],h=[],{ZipFile:ee}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),g=new ee;G({zipfile:g,files:[...l,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:i}),G({zipfile:g,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:i}),G({zipfile:g,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=R(e.sourcePath),n=`extra/${e.zipName??M(e.sourcePath)}`;g.addBuffer(t,n),h.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Ue({zipfile:g,name:`note.txt`,content:t.note,redact:n,bundleFiles:h,redactions:m});let _=JSON.stringify(c,null,2);g.addBuffer(Buffer.from(_,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let v={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:h,redactions:m,sysinfo:c};g.addBuffer(Buffer.from(JSON.stringify(v,null,2),`utf8`),`MANIFEST.json`);let y=m.reduce((e,t)=>e+t.lineCount,0),b=new Set(p.map(e=>`logs/${M(e)}`)),x=h.filter(e=>b.has(e)),S=s?h.filter(e=>e.startsWith(`logs/`)&&!W(e)&&!b.has(e)):[],C=[`# Bug Report Bundle`,``,`Generated: ${v.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${v.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...S.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...S.map(e=>`- ${e}`),``]:[],...x.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...x.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${a.join(`, `)}`,y>0?`${y} line(s) were scrubbed across ${m.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(`
|
|
2
|
+
`);g.addBuffer(Buffer.from(C,`utf8`),`README.md`),g.end();let w=fe(r);return g.outputStream.pipe(w),await new Promise((e,t)=>{w.on(`close`,e),w.on(`error`,t)}),i?.info({bundlePath:r,fileCount:h.length,redactionCount:y},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:h,redactions:m,redactedLineCount:y,generatedAt:v.generatedAt}}}var Ge=e(C(),1),K=e(ne(),1);function Ke(e){return _({absPath:v(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function qe({home:e=H(),env:n=process.env}={}){let i=Ke(e),{override:a,preferenceList:o}=ee(n),{locale:c,source:l}=s({override:a,storedPreference:i,supportedLocales:r,preferenceList:o,autoDetectableLocales:t});return{preference:i,locale:c,source:l,systemLanguages:o}}function Je(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return Je(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!Ye(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function Xe(e,t){let n=R(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
3
|
`),i=n.split(`
|
|
4
4
|
`),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)}}}V(e,r?`${a.join(`
|
|
5
5
|
`)}\n`:a.join(`
|
|
6
6
|
`))}function Ze(e,t){let n=R(e,`utf-8`);if(n.trim().length!==0)try{let r=q(JSON.parse(n),t),i=n.endsWith(`
|
|
7
7
|
`)?`
|
|
8
8
|
`:``;V(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Je(n,t.contentDir);r!==n&&V(e,r)}}function Qe(e,t){let n=R(e,`utf-8`),r=Je(n,t.contentDir);r!==n&&V(e,r)}function $e(e){try{return z(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>P(e,t.name))}catch{return[]}}const et=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function tt(e){return/\.log\.\d+$/.test(e)}function nt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||tt(e)}function rt(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of $e(P(e.stagingDir,n)))nt(r)?Xe(r,t):r.endsWith(`.json`)?Ze(r,t):Qe(r,t);for(let n of $e(P(e.stagingDir,`state`))){let e=M(n);n.endsWith(`.jsonl`)?Xe(n,t):et.has(e)?Ze(n,t):Qe(n,t)}}const it=[`.ok`,`local`,`telemetry`],at=[`.ok`,`local`,`logs`],ot=[`.ok`,`local`,`loss-capture`],st=`spans-current.jsonl`,ct=`spans-prev.jsonl`,lt=`server-current.jsonl`,ut=`server-prev.jsonl`,dt=`loss-current.jsonl`,ft=`loss-prev.jsonl`;function pt(e){return P(e,...it,st)}function mt(e){return P(e,...it,ct)}function ht(e){return P(e,...at,lt)}function gt(e){return P(e,...at,ut)}function _t(e){return P(e,...ot,dt)}function vt(e){return P(e,...ot,ft)}const yt=1e3;async function bt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(yt)});return t.ok?await t.text():null}catch{return null}}async function xt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(yt)});return t.ok?await t.text():null}catch{return null}}async function St(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(yt)});return t.ok?await t.text():null}catch{return null}}function Ct(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(`
|
|
9
|
-
`)}\n`:null}catch{return null}}function wt(e){let t=P(e,`.git`,`ok`);if(!I(t))return null;let n=j(`git`,[`-C`,t,`log`,`--oneline`,`-50`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Tt(e){let t=P(e,`.git`,`ok`);if(!I(t))return null;let n=j(`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 Et(){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 Dt(){return{nodeVersion:process.version,platform:be(),arch:_e()}}function Ot(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e){if(!I(e))return{};let t;try{t=(0,U.parse)(R(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 At(e){return typeof e==`boolean`?e:void 0}function jt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return jt(e.maxBytes)}function Mt(e){let t=kt(v(`project`,e)),n=kt(v(`project-local`,e));return{enabled:At(n.enabled)??At(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Nt(e){return Ee(`sha256`).update(e).digest(`hex`)}function Pt(e){let t=R(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Ft(e){let t=R(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){if(!I(e))return!1;try{return L(N(t),{recursive:!0}),de(e,t),!0}catch{return!1}}function It(e){let t=[],n=e=>{let r=z(e,{withFileTypes:!0});for(let i of r){let r=P(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Lt=new Set([`.jsonl`]);function Rt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Lt.has(e.slice(t))}const zt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Bt(e){if(tt(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:zt.has(e.slice(t))}function Vt(e){let t=[];for(let n of It(e)){let r=Ht(e,n);if(!Bt(r))continue;let{redacted:
|
|
9
|
+
`)}\n`:null}catch{return null}}function wt(e){let t=P(e,`.git`,`ok`);if(!I(t))return null;let n=j(`git`,[`-C`,t,`log`,`--oneline`,`-50`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Tt(e){let t=P(e,`.git`,`ok`);if(!I(t))return null;let n=j(`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 Et(){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 Dt(){return{nodeVersion:process.version,platform:be(),arch:_e()}}function Ot(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e){if(!I(e))return{};let t;try{t=(0,U.parse)(R(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 At(e){return typeof e==`boolean`?e:void 0}function jt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return jt(e.maxBytes)}function Mt(e){let t=kt(v(`project`,e)),n=kt(v(`project-local`,e));return{enabled:At(n.enabled)??At(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Nt(e){return Ee(`sha256`).update(e).digest(`hex`)}function Pt(e){let t=R(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Ft(e){let t=R(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){if(!I(e))return!1;try{return L(N(t),{recursive:!0}),de(e,t),!0}catch{return!1}}function It(e){let t=[],n=e=>{let r=z(e,{withFileTypes:!0});for(let i of r){let r=P(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Lt=new Set([`.jsonl`]);function Rt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Lt.has(e.slice(t))}const zt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Bt(e){if(tt(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:zt.has(e.slice(t))}function Vt(e){let t=[];for(let n of It(e)){let r=Ht(e,n);if(!Bt(r))continue;let{redacted:a,patterns:o,lineCount:s}=i(R(n,`utf-8`));o.length!==0&&(V(n,a),t.push({file:r,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Ht(e,t){return le(e,t).split(ue).join(`/`)}async function Ut(e){let t=F(e.contentDir),n=F(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??bt,a=r.fetchAgentEffects??xt,s=r.fetchWatcherRecent??St,l=r.readShadowHead??wt,u=r.readCheckpointRefs??Tt,d=r.now??(()=>new Date),f=r.okVersion??(()=>se),p=r.readDesktopEnv??Et,m=r.readLanguage??qe,h=r.readRuntime??Dt,ee=r.isOtlpPushEnabled??Ot,g=me(P(Se(),`ok-bundle-`));try{L(P(g,`telemetry`),{recursive:!0}),L(P(g,`logs`),{recursive:!0}),L(P(g,`state`),{recursive:!0}),X(pt(n),P(g,`telemetry`,st)),X(mt(n),P(g,`telemetry`,ct)),X(ht(n),P(g,`logs`,lt)),X(gt(n),P(g,`logs`,ut));for(let t of e.userLogFiles??[])X(t,P(g,`logs`,M(t)));let _=P(n,`.ok`,`local`),v=P(_,`server.lock`),y=`not-running`,b=`no server.lock`,x=null;if(I(v)){X(v,P(g,`state`,`server.lock`));try{let e=R(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 i(x);e===null?b=`agent-presence endpoint at :${x} unreachable`:(V(P(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await a(x);t!==null&&V(P(g,`state`,`agent-effects.json`),t);let n=await s(x);if(n!==null){let e=Ct(n);e!==null&&V(P(g,`state`,`watcher-recent.jsonl`),e)}}let S=l(t);S!==null&&V(P(g,`state`,`shadow-head.txt`),S);let C=u(t);C!==null&&V(P(g,`state`,`checkpoint-refs.txt`),C),X(_t(n),P(g,`state`,dt)),X(vt(n),P(g,`state`,ft)),X(P(_,`last-spawn-error.log`),P(g,`state`,`last-spawn-error.log`)),X(P(_,c),P(g,`state`,c)),X(P(_,o),P(g,`state`,o));let w=h(),te=p(),T=m(),ne={ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:te,language:T}};V(P(g,`state`,`runtime.json`),`${JSON.stringify(ne,null,2)}\n`);let re=y===`running`?`running
|
|
10
10
|
`:`not-running (${b})\n`;if(V(P(g,`state`,`server-status.txt`),re),e.processDir&&I(e.processDir)){let t=P(g,`process`);L(t,{recursive:!0}),de(e.processDir,t,{recursive:!0})}let E=e.redact===!0;E&&rt({stagingDir:g,contentDir:t}),e.note&&V(P(g,`note.txt`),e.note);let D=null;e.scrubSecrets===!0&&(D=Vt(g));for(let t of e.extraFiles??[])X(t.sourcePath,P(g,`extra`,t.zipName??M(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let ie=Mt(n),O=It(g),k=[],ae=0,oe=0;for(let e of O){let t=Ht(g,e),n=ge(e).size,r=Rt(t)?Pt(e):0;k.push({path:t,bytes:n,lines:r}),ae+=n,t.startsWith(`telemetry/`)&&Rt(t)&&(oe+=Ft(e))}let se={applied:E};D!==null&&(se.secretScrub=D);let A={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:te,language:T},contentDir:{pathSha256:Nt(t),absolutePath:E?`<CONTENT_DIR>`:t},telemetry:{localSink:ie,otlpPushEnabled:ee()},redaction:se,serverStatus:y,files:k};V(P(g,`manifest.json`),`${JSON.stringify(A,null,2)}\n`);let ce=O.some(e=>{try{return R(e,`utf-8`).includes(t)}catch{return!1}}),j={totalBytes:ae,fileCount:k.length,docNameCount:oe,contentDirVisible:ce,redacted:E},N=!1;return{stagingDir:g,manifest:A,summary:j,cleanup:()=>{N||(N=!0,B(g,{recursive:!0,force:!0}))}}}catch(e){throw B(g,{recursive:!0,force:!0}),e}}async function Wt(e){let{collected:t,outputPath:n}=e,r=N(n);if(!I(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Ge.ZipFile,a=It(t.stagingDir);for(let e of a){let n=Ht(t.stagingDir,e);i.addFile(e,n)}i.end();let o=fe(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 Gt(e,t){let n=P(e,`.ok`,`config.yml`);if(I(n))try{let t=(0,U.parse)(R(n,`utf-8`)),r=A(t)?t.content:void 0,i=A(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return F(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 F(e)}async function Kt(e,t,n,r){let i=Pe(t,e.logger),a=await Ut({contentDir:Gt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...Le(i,e.userLogsDir??P(H(),`.ok`,`logs`)),...ze(e.cachesDir??P(H(),`Library`,`Caches`))],deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{L(N(e.outputPath),{recursive:!0}),await Wt({collected:a,outputPath:e.outputPath});let t=a.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:i,files:a.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:a.manifest.createdAt}}}finally{a.cleanup()}}async function qt(e){let{projectDir:t}=e,n=e.readDesktopEnv??Et,r=e.readLanguage??qe;if(e.level===`full`&&t!==void 0)return Kt(e,t,n,r);let{zipPath:i,summary:a}=await We({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:ze(e.cachesDir??P(H(),`Library`,`Caches`)),logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:i,summary:{level:e.level,systemWide:t===void 0,projectSlug:a.projectSlug,files:a.files,redactions:a.redactions,redactedLineCount:a.redactedLineCount,generatedAt:a.generatedAt}}}function Z(e,t,n={}){let r=x(e,t);if(!I(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(R(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!y(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??b)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??S())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??ye();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Jt(e){return e.replace(/:\d+$/,``)}function Yt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Jt(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Jt(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Jt(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}const Xt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Zt(e){return P(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Qt={existsSync:e=>I(e),readFileSync:(e,t)=>R(e,t),lstatSync:e=>pe(e),readlinkSync:e=>he(e)};function $t(e,t=Qt){let n=Zt(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 en(e){let t=e.replace(Xt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function tn(e,t,n=Qt){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function nn(e){return te(e)||w(e)||ae(e)}const rn=10*1024*1024;function an(e,t,n,r){let i=O(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(!nn(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`?(B(a,{force:!0}),{kind:`removed`}):e.format===`toml`?cn(a,o):e.format===`yaml`?sn(a,e.topLevelKey,o):on(a,e.topLevelKey,e.serverMapSubKey,o)}function on(e,t,n,r){let i;try{i=R(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=E(i,ie(t,n,r));return o?(g(e,a,{mode:k(e)}),{kind:`removed`}):{kind:`not-present`}}function sn(e,t,n){let r;try{r=R(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,U.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=D(a);a.trim()===``||a.endsWith(`
|
|
11
11
|
`)?c.endsWith(`
|
|
12
12
|
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
@@ -17,4 +17,4 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sle
|
|
|
17
17
|
`).replace(/\n/g,`\r
|
|
18
18
|
`));let u=`${i?``:``}${l}`;return u!==r&&g(e,u,{mode:k(e)}),{kind:`removed`}}function ln(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function un(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 dn(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:p(r),command:r,isDesktop:ln(r)}}function fn(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`&&fn(e)?`ui-orphan`:`stale`}const pn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function mn(e){switch(e){case`running`:return K.default.green(e);case`desktop`:return K.default.blue(e);case`foreign`:return K.default.cyan(e);case`ui-orphan`:return K.default.magenta(e);case`stale`:return K.default.yellow(e)}}function hn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function gn(e){return`${hn(e.server.usage)} | ${hn(e.ui?.usage??null)}`}function _n(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function vn(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,_n(e),gn(e),t,String(n),un(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=mn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=K.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
19
19
|
`)}async function yn(e={}){let t=e.discover??h,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??d,a=e.resolveUsage??m,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=dn(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(vn(e.all?s:s.filter(e=>pn.has(Q(e)))))}function bn(){return new T(`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 yn({all:t.all===!0||e===`all`,json:t.json===!0})})}function xn(e,t,n={}){let r=n.isAlive??b,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 Sn(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=xn(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 Cn(e,t=b){let n=await h(),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 wn(e){let t=Sn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Tn(e){return new T(`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=Sn({lockDir:f(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 yn({});return}if(n===`all`){let e=await h();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,b)&&!$(r,b)||(wn(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 Cn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}wn(t);return}wn(f(F(je(),n)))})}export{je as _,Xt as a,$t as c,Z as d,qt as f,Me as g,Ne as h,an as i,en as l,Wt as m,Tn as n,tn as o,Ut as p,bn as r,Zt as s,Sn as t,Yt as u,Ae as v,Oe as y};
|
|
20
|
-
//# sourceMappingURL=src-
|
|
20
|
+
//# sourceMappingURL=src-WP_osKfx.mjs.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{M as e}from"./sleep-A0G7hOuG.mjs";import{Hs as t,Js as n,Ks as r,Vs as i,Ws as a,qs as o}from"./src-Dj6UxpKM.mjs";import{Pn as s,a as ee,si as c}from"./src-DvuwJKkU.mjs";import{b as l,v as u,y as d}from"./write-project-skill-DUj7e5tZ.mjs";import{a as f,c as p,d as m,i as h,o as g,r as _,t as v}from"./acp-harness-probe-BLW7TG44.mjs";import{n as y}from"./constants-WNkLKsdC.mjs";import{spawn as b}from"node:child_process";import{basename as x,resolve as S}from"node:path";import{existsSync as C}from"node:fs";import{rm as w}from"node:fs/promises";import{setTimeout as T}from"node:timers/promises";function E(e,t){return e.bind?.[0]??e.host??t.HOST??`127.0.0.1`}function D(e){if(e===`ui`||e===`server`)return e;throw new d(`--only must be 'ui' or 'server'`)}function O(e=C){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[S(t,`public`),S(t,`../../app/dist`),S(t,`../../../app/dist`)].find(t=>e(t))}function k(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function A(t){if(t===`off`)return`off`;if(!e.test(t))throw new d(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return t}function j(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function M(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function N(e){return!e.openBrowser||e.remoteEnabled||e.ephemeral||e.only===`server`||!e.servesUi?!1:e.legacyOpen?!0:(e.explicitOn||j(e.host))&&e.isTTY}function P(e,t){return t&&(e===`::`||e===`::1`||e===`[::1]`||e===`localhost`||e===`0.0.0.0`)?{host:`127.0.0.1`,coerced:!0}:{host:e,coerced:!1}}function te(e,n){return t(n)?e:{publicUrl:e.publicUrl,idleShutdown:e.idleShutdown}}function ne(e,t){if(e===void 0||e===!1)return null;let n=typeof e==`string`?e:t;if(n===void 0||n===``)return{ok:!1,errorMessage:"--remote requires a public tunnel URL — pass it (`ok start --remote https://<your-tunnel-host>`) or set remote.url in .ok/config.yml."};let r;try{r=new URL(n)}catch{return{ok:!1,errorMessage:`remote.url is not a valid URL: ${n}`}}if(r.protocol!==`https:`)return{ok:!1,errorMessage:`remote.url must be https — it is the public tunnel URL remote clients connect to (got: ${n})`};let i=n.replace(/\/+$/,``);return{ok:!0,url:i,serverOverlay:{publicUrl:i,allowExternal:!0,idleShutdown:`off`}}}function F(e){let t;try{t=new URL(e)}catch{throw new d(`--public-url is not a valid URL: ${e}`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new d(`--public-url must be an http(s) origin (got: ${e})`);return e}function I(e){let t=x(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var L=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 R(e,t,n=!1){return e??(n?void 0:t)}function z(e,t,n=e=>w(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 B(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 V(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:l}=await import(`node:fs`),{basename:u,dirname:d}=await import(`node:path`),{bootServer:f,getLogger:h,resolveContentDir:g,resolveLockDir:_,waitForServerLockDrain:y}=await import(`./src--XQg-7vm.mjs`),b=e.log??h(`start`),x=e.singleFile!==void 0,S=e.projectDir??n,C=x?ee(e.singleFile).canonicalFilePath:void 0,w=C?d(C):void 0,T=C?u(C):void 0;if(!x){if(!i&&!s(n))throw new L(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&b.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-Ceivh0g-.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){b.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-C2_MEgOS.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){b.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-BWNXcIRv.mjs`)).repairSkills)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){b.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let E=w??g(t,n);!x&&!o(E)&&(l(E,{recursive:!0}),b.info({contentDir:E},`Created content directory`));let D=m(),O=c();{let e=_(x?S:n),t=Date.now(),r=await y(e);r!==`no-drain`&&b.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let k=await f({config:t,contentDir:E,projectDir:x?S:n,contentRoot:x?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:p,tokenStore:D,embeddingsKeyStore:O,...x?{ephemeral:!0,singleDocRelPath:T,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>v(e,t),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return B(x?z(n,S):n,{log:b,exit:e.idleExit})},log:b,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});return{httpServer:k.httpServer,destroy:k.destroy,lockDir:k.lockDir,contentDir:E,port:k.port,ready:k.ready,degraded:k.degraded}}function H(e){if(e===`browser`||e===`app`)return e;throw new d(`--mode must be 'browser' or 'app'`)}function U(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function W(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 G(e,t){let s=U(process.env);s!==null&&(process.env.OK_CONSOLE_LEVEL=s);let{renderBanner:ee}=await import(`./banner-Ev4hKBM4.mjs`),{accent:c,dim:l,error:u,warning:d}=await import(`./colors-MGDi6UGf.mjs`),f=process.cwd(),p=t.remote!==void 0&&t.remote!==!1;process.title=I(f),p&&console.warn(d("--remote is deprecated — use `OK_IDLE_SHUTDOWN=off OK_ALLOW_EXTERNAL=1 ok start --public-url <url>` instead (add --bind to serve a non-loopback address; keep OK_IDLE_SHUTDOWN=off — the idle timer only counts WS clients and would tear the server down under a live remote MCP client). The flag now just expands to those server.* keys and will be removed in a later release."));let m=ne(t.remote,e.remote?.url);m!==null&&!m.ok&&(console.error(u(m.errorMessage)),process.exit(78));let h=m?.ok?m:null,g=h!==null;h!==null&&console.warn(d([``,`⚠ REMOTE ACCESS ENABLED — no server-side authentication.`,` Anyone who can reach ${h.url} has FULL control of this`,` knowledge base, including sync, publishing, credentials, and local operations.`,` Restrict who can reach it at the tunnel: ngrok OAuth, Cloudflare Access,`,` Tailscale ACLs, or equivalent edge auth.`,``].join(`
|
|
2
|
+
`)));let _;try{_=n(process.env)}catch(e){throw e instanceof r&&(console.error(u(e.message)),process.exit(78)),e}for(let e of _.diagnostics)console.warn(d(`[config] ${e.message}`));let v=o(e,_.layer),b=_.overrides.some(e=>e.envVar===`OK_BIND`),x=t.bind!==void 0&&t.bind.length>0?t.bind:t.host===void 0?void 0:[t.host],S=process.env.HOST,C=S!==void 0&&S.trim()!==``?S:void 0,w=a(v),E=x??(b||C===void 0?[...w.bind]:[C]);M({flagBindSet:x!==void 0,okBindSet:b,hostEnvSet:C!==void 0,fileBindCount:w.bind.length})&&console.warn(d(`[config] HOST=${C} overrides server.bind — dropping the file-configured addresses (${w.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let D=E[0]??`127.0.0.1`,A=P(D,g);A.coerced&&console.warn(`remote access is enabled and ${D} is not an IPv4 loopback bind — tunnels proxy to 127.0.0.1, so binding ${D} would leave the tunnel dialing a dead port. Using 127.0.0.1.`);let j=A.host,F=g?[j]:E,z=h===null?{}:te(h.serverOverlay,F);h!==null&&!(`allowExternal`in z)&&console.warn(d(`--remote does not consent to exposing a non-loopback bind (${F.join(`, `)}) — the tunnel is the only ingress the alias vouches for. Consent explicitly with OK_ALLOW_EXTERNAL=1 (or server.allowExternal in .ok/local/config.yml), or drop the non-loopback bind.`));let B=a(o(v,{server:{bind:F,...z,...t.publicUrl===void 0?{}:{publicUrl:t.publicUrl}}}));if(!g&&B.allowExternal&&(!B.loopbackOnly||B.publicUrl)){let e=B.publicUrl??B.bind.join(`, `);console.warn(d([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
|
|
3
|
+
`)))}let H=t.port===void 0?void 0:Number(t.port),G=_.overrides.find(e=>e.envVar===`PORT`)?.value,X=a(e).port,re=e.server?.port;g&&H===void 0&&G!==void 0&&console.warn(`remote access is enabled — ignoring env PORT=${process.env.PORT}; the tunnel's port mapping targets the stable remote port (${X??24550}). Pass --port to override deliberately.`);let ie=R(H,G,g)??(g?X??24550:re),ae=k({explicitDir:t.reactShellDistDir,only:t.only,findBundledDir:O}),Z=ae.dir;ae.missingBundle&&console.warn(g?`remote access: bundled web UI not found — serving /mcp and /api only over the tunnel.`:`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let Q;try{Q=await V({config:e,cwd:f,host:j,port:ie,bind:F,...t.serveContentAssets===void 0?{}:{serveContentAssets:t.serveContentAssets},...Z?{reactShellDistDir:Z}:{},idleThresholdMs:i((g?void 0:t.idleShutdown)??B.idleShutdown),serverRuntime:B,...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{}})}catch(e){e instanceof L&&(console.error(u(e.message)),process.exit(1));let t=await import(`./src--XQg-7vm.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(u(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(u(e.message)),process.exit(1)),J(e,t)){let e=t.resolveLockDir(f),n=null;try{n=await K({readServerLock:()=>t.readServerLock(e),readUiLock:()=>t.readUiLock(e),now:Date.now,sleep:e=>T(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=q(n);console.log(c(e));for(let e of t)console.log(l(e));process.exit(0)}}let n=Y(e,f,t);n!==null&&(console.error(u(n)),process.exit(1)),console.error(`${u(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let oe=!1,$=async e=>{if(oe)return;oe=!0;let[t,...n]=W(e);console.log(c(`\n${t}`));for(let e of n)console.log(l(` ${e}`));try{await Q.destroy()}catch(e){console.error(`${u(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{$(`SIGINT`)}),process.once(`SIGTERM`,()=>{$(`SIGTERM`)});let se=`http://${j.includes(`:`)&&!j.startsWith(`[`)?`[${j}]`:j}:${Q.port}`,ce=j===`0.0.0.0`||j===`::`?`http://0.0.0.0:${Q.port}`:void 0,le=se;console.log(ee({name:`open-knowledge`,version:y,localUrl:le,networkUrl:ce,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let ue={"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`};Q.ready.then(async()=>{if(Q.degraded.length>0){console.log();for(let e of Q.degraded){let t=ue[e]??`${e} (check server logs for details)`;console.warn(` ${d(`⚠`)} ${d(e)}: ${l(t)}`)}console.log()}if(N({openBrowser:t.openBrowser!==!1&&B.openBrowser,explicitOn:t.openBrowser!==!1&&v.server?.openBrowser===!0,legacyOpen:t.open===!0,host:j,isTTY:process.stdout.isTTY===!0,remoteEnabled:g,ephemeral:t.singleFile!==void 0,only:t.only,servesUi:Z!==void 0})){let{openBrowser:e}=await import(`./open-browser-BA50pLLQ.mjs`);e(le)}}).catch(e=>{console.error(` ${u(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function K(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();if(n===null||n.draining===!0||n.port<=0)return null;if(n.capabilities?.includes(`ui`)===!0&&n.url!==void 0)return{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0};let r=e.readUiLock();return r!==null&&r.port>0?{url:r.url??`http://localhost:${r.port}`,kind:n.kind,pid:n.pid,servesUi:!1}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function q(e){return[`${e.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${e.pid}).`,` ${e.url}`,"Leaving it running — run `ok stop` first if you want a fresh server."]}function J(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function Y(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=n.readServerLock(n.resolveLockDir(t));return e&&e.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`."}catch{return null}}function X(e){return new u(`start`).description(`Start the OpenKnowledge server (UI + API + MCP + collab on one port)`).option(`-p, --port <port>`,`Server port`,void 0).option(`--bind <address>`,`Bind address (repeatable; default 127.0.0.1 — loopback only)`,(e,t)=>[...t??[],e]).addOption(new l(`-H, --host <host>`,`Deprecated alias of --bind`).hideHelp()).option(`--no-open-browser`,`Do not open the browser after start (interactive loopback starts open it by default)`).addOption(new l(`--open`,`Deprecated: force-open the browser after start`).hideHelp()).option(`--only <module>`,`Serve one module: 'server' (API + MCP only, no shell or browser) or 'ui' (shell + proxy only; requires --server-url)`,D).option(`--server-url <url>`,`Project-server URL the --only ui process proxies to (e.g. http://127.0.0.1:24550)`).option(`--idle-shutdown <duration>`,`Shut the server down after this long with no connected clients ('off', or a duration like 90s, 30m, 2h; default 30m)`,A).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,H).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>`).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)`).option(`--public-url <url>`,`Canonical external origin clients dial (sets server.publicUrl for this run) — its host joins the Host/Origin allowlists and issued URLs. External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,F).option(`--remote [url]`,`Deprecated alias: expands to --public-url <url> + OK_ALLOW_EXTERNAL consent on a loopback bind. Serves through a tunnel with NO server-side auth (anyone who can reach the URL has full control — restrict access at the tunnel with edge auth). Bare --remote uses remote.url from .ok/config.yml; --remote <url> supplies it for this run.`).action(async t=>{let n=e();if(t.serverUrl!==void 0&&t.only!==`ui`&&(process.stderr.write(`error: option '--server-url' requires '--only ui'
|
|
4
|
+
`),process.exit(2)),t.publicUrl!==void 0&&t.remote!==void 0&&t.remote!==!1&&(process.stderr.write(`error: option '--remote' cannot be combined with '--public-url' (--remote is a deprecated alias that sets server.publicUrl)
|
|
5
|
+
`),process.exit(2)),t.singleFile!==void 0&&t.remote!==void 0&&t.remote!==!1&&(process.stderr.write(`error: option '--single-file' cannot be combined with '--remote' — ephemeral single-file mode has no project and no consented root to serve remotely
|
|
6
|
+
`),process.exit(2)),t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
|
|
7
|
+
`),process.exit(2)),t.only===`ui`){{let{warning:e}=await import(`./colors-MGDi6UGf.mjs`);console.error(e("[start] `--only ui` is deprecated — plain `ok start` serves the editor UI, API, and MCP on one port. The split-mode proxy will be removed in a future release."))}t.serverUrl===void 0&&(process.stderr.write(`error: '--only ui' requires '--server-url <url>' (where the project server runs)
|
|
8
|
+
`),process.exit(2)),t.mode===`app`&&(process.stderr.write(`error: option '--only ui' cannot be combined with '--mode app'
|
|
9
|
+
`),process.exit(2)),t.remote!==void 0&&t.remote!==!1&&(process.stderr.write(`error: option '--only ui' cannot be combined with '--remote'
|
|
10
|
+
`),process.exit(2));let{runUiCommand:e}=await import(`./ui-7z12LoCq.mjs`);await e(n,{...t.port===void 0?{}:{port:String(t.port)},...t.bind?.[0]===void 0?t.host===void 0?{}:{host:t.host}:{host:t.bind[0]},upstreamUrl:t.serverUrl});return}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)
|
|
11
|
+
`),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.host!==void 0&&e.push(`--host`),t.only!==void 0&&e.push(`--only`),t.serverUrl!==void 0&&e.push(`--server-url`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.publicUrl!==void 0&&e.push(`--public-url`),t.remote!==void 0&&t.remote!==!1&&e.push(`--remote`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=h(_());if(n.available){f({spawn:b},n);return}console.error(g(n.reason)),process.exit(1)}await G(n,t)})}export{X as C,B as E,M as S,z as T,U as _,ne as a,te as b,j as c,D as d,F as f,K as g,E as h,I as i,J as l,R as m,V as n,q as o,O as p,P as r,W as s,L as t,A as u,k as v,Y as w,N as x,G as y};
|
|
12
|
+
//# sourceMappingURL=start-CS7u5aKZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,h as t,n,p as r}from"./start-CS7u5aKZ.mjs";export{n as bootStartServer,r as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Q as e,it as t,tt as n}from"./sleep-A0G7hOuG.mjs";import{
|
|
2
|
-
`)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const y=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function b(e){let t=e.upstreamTimeoutMs??m,n=new Set,r=u((n,r)=>{h(n,r)||x(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{_(t,r)||v(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function ee(e,t,n){x(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??m)}function x(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of y)delete a[e];e.setTimeout(g,()=>{if(t.headersSent)try{t.end()}catch{}else try{p(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${g/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=d({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of y)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)p(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)p(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}async function S(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}function C(e){let t;try{t=new URL(e)}catch{throw Error(`Invalid --server-url '${e}' — expected e.g. http://127.0.0.1:24550`)}if(t.protocol!==`http:`)throw Error(`--server-url must be http: (got '${t.protocol}//') — the UI proxy speaks plain HTTP; terminate TLS at your ingress`);let n=t.port===``?80:Number(t.port);return{host:t.hostname.replace(/^\[(.+)\]$/,`$1`),port:n}}async function w(
|
|
3
|
-
//# sourceMappingURL=ui-
|
|
1
|
+
import{Q as e,it as t,tt as n}from"./sleep-A0G7hOuG.mjs";import{Yo as r,ao as i,dt as a}from"./src-Dj6UxpKM.mjs";import{An as o,Mn as s,jn as c}from"./src-DvuwJKkU.mjs";import{randomUUID as l}from"node:crypto";import{createServer as u,request as d}from"node:http";import{connect as f}from"node:net";function p(e,t,n,r,a){let o=`urn:uuid:${l()}`;if(e.headersSent||e.writableEnded||e.destroyed){console.error(`[ok ui] emitProblem called after headers sent — suppressed`,{type:n,status:t,instance:o});return}let s={type:n,title:r,status:t,instance:o,...a===void 0?{}:{detail:a}},c=i.safeParse(s);if(!c.success){console.error(`[ok ui] emitProblem produced an invalid ProblemDetails body:`,{issues:c.error.issues,originalStatus:t,body:s}),e.writeHead(500,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify({type:`urn:ok:error:internal-server-error`,title:`Internal server error.`,status:500,instance:o}));return}e.writeHead(t,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify(s))}const m=1e4;function h(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!c(n))return p(t,403,`urn:ok:error:loopback-required`,`Request must originate from a loopback address.`),!0;if(!o(e.headers.host))return p(t,403,`urn:ok:error:host-not-allowed`,`Host header is not in the loopback allowlist.`),!0;let r=e.headers.origin;return r!==void 0&&!s(r)?(p(t,403,`urn:ok:error:invalid-origin`,`Origin header is not in the loopback allowlist.`),!0):!1}const g=3e4;function _(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!c(n)||!o(e.headers.host))return t.destroy(),!0;let r=e.headers.origin;return typeof r==`string`&&!s(r)?(t.destroy(),!0):!1}function v(e,t,n,r,i,a){a.add(t),t.once(`close`,()=>a.delete(t));let o=f({host:r,port:i,timeout:m});a.add(o),o.once(`close`,()=>a.delete(o));let s=!1,c=n=>{if(!s){if(s=!0,n!==void 0){let t=n.err;console.warn(JSON.stringify({event:n.event,upstreamHost:r,upstreamPort:i,url:e.url,code:t instanceof Error?t.code:void 0,message:t instanceof Error?t.message:void 0}))}try{o.destroy()}catch{}try{t.destroy()}catch{}}};o.once(`connect`,()=>{o.setTimeout(0);let a=[`${e.method??`GET`} ${e.url??`/`} HTTP/1.1`,`host: ${r}:${i}`];for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()!==`host`&&n!==void 0)if(Array.isArray(n))for(let e of n)a.push(`${t}: ${e}`);else a.push(`${t}: ${n}`);try{o.write(`${a.join(`\r
|
|
2
|
+
`)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const y=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function b(e){let t=e.upstreamTimeoutMs??m,n=new Set,r=u((n,r)=>{h(n,r)||x(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{_(t,r)||v(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function ee(e,t,n){x(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??m)}function x(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of y)delete a[e];e.setTimeout(g,()=>{if(t.headersSent)try{t.end()}catch{}else try{p(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${g/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=d({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of y)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)p(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)p(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}async function S(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}function C(e){let t;try{t=new URL(e)}catch{throw Error(`Invalid --server-url '${e}' — expected e.g. http://127.0.0.1:24550`)}if(t.protocol!==`http:`)throw Error(`--server-url must be http: (got '${t.protocol}//') — the UI proxy speaks plain HTTP; terminate TLS at your ingress`);let n=t.port===``?80:Number(t.port);return{host:t.hostname.replace(/^\[(.+)\]$/,`$1`),port:n}}async function w(i){let{existsSync:o}=await import(`node:fs`),{createServer:s}=await import(`node:http`),{resolve:c}=await import(`node:path`),{acquireUiLock:l,buildIngressPolicy:u,createAssetServeMiddleware:d,createContentFilter:f,readServerLock:m,releaseUiLock:g,updateUiLockPort:y}=await import(`./src--XQg-7vm.mjs`),{default:b}=await import(`./build-BcDJ6qQ2.mjs`),{resolveContentDir:x,resolveLockDir:S}=await import(`./src--XQg-7vm.mjs`),w=x(i.config,i.cwd),E=S(i.cwd);l(E,{port:0,worktreeRoot:i.cwd});let D=import.meta.dirname??new URL(`.`,import.meta.url).pathname,O=[c(D,`public`),c(D,`../../app/dist`),c(D,`../../../app/dist`)],k=i.assetDir??O.find(e=>o(e)),A=k?b(k,{single:!0,gzip:!0,etag:!0,dev:!0,extensions:[]}):null,j=o(w)?d({contentFilter:f({projectDir:i.cwd,contentDir:w}),contentSirv:b(w,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:t,assetExtensions:e,blocklistExtensions:n,ingressPolicy:u({})}):null,M=i.upstreamUrl===void 0?null:C(i.upstreamUrl),N=()=>{if(M!==null)return M;let e=m(E);return!e||e.port<=0?null:{host:r,port:e.port}},P=i.port,F=null,I=(e,t)=>{let n=e.url?.split(`?`)[0];if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&h(e,t))){if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){F?.();let n=e.headers.host??`localhost:${P}`,r=N()===null?null:`ws://${n}/collab`,i=JSON.stringify({collabUrl:r,previewUrl:null,port:P});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(i);return}if(n?.startsWith(`/api/`)){F?.();let r=N();if(r===null){p(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}ee(e,t,{upstreamHost:r.host,upstreamPort:r.port});return}if(A&&n?.startsWith(`/assets/`)){A(e,t,()=>{j?j(e,t,()=>T(t)):T(t)});return}if(j){j(e,t,()=>{A?A(e,t):T(t)});return}if(A){A(e,t);return}T(t)}},L=new Set,R=(e,t,n)=>{if(_(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=N();if(i===null){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}v(e,t,n,i.host,i.port,L)},z=()=>{for(let e of L)try{e.destroy()}catch{}L.clear()},te=i.host===void 0?[`::1`,`127.0.0.1`]:[i.host],B=[],V=i.port,ne=e=>e instanceof Error&&e.code===`EADDRINUSE`,H=async()=>{await Promise.all(B.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},U=async e=>{V=e;for(let e of te){let t=s(I);t.on(`upgrade`,R),B.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(V,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(V=e.port),n()})})}};try{try{await U(i.port)}catch(e){if(i.fallbackToKernel===!0&&ne(e))await H(),await U(0);else throw e}}catch(e){await H();try{g(E)}catch{}throw e}let W=V;P=W,y(E,W,`http://localhost:${W}`);let G=i.scheduler??a,K=i.safetyNetMs??432e5,q=null,J=!1,Y=!1,X=()=>{J||(J=!0,q!==null&&(G.clearTimeout(q),q=null))},Z=()=>{if(X(),!Y){Y=!0;try{g(E)}catch{}}},Q=()=>{J||K<=0||(q!==null&&(G.clearTimeout(q),q=null),q=G.setTimeout(()=>{q=null,console.warn(`[ui] safety-net (${K}ms) reached — shutting down (D-025 backstop)`);try{i.onSafetyNet?.()}catch{}z();for(let e of B)try{e.close()}catch{}Z()},K))},$=()=>{J||K<=0||Q()};return F=$,Q(),{httpServers:B,port:W,release:Z,detachSafetyNet:X,nudgeSafetyNet:$,drainUpgradeSockets:z}}function T(e){e.headersSent||e.writableEnded||e.destroyed||(e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Cache-Control`,`no-store`),e.statusCode=404,e.end())}function E(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:39847,fallbackToKernel:!0}}async function D(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./src--XQg-7vm.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await b({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}async function O(e,t){let{dim:n}=await import(`./colors-MGDi6UGf.mjs`),{UiLockCollisionError:r}=await import(`./src--XQg-7vm.mjs`),{resolveLockDir:i}=await import(`./src--XQg-7vm.mjs`),a=t.host;if(t.upstreamUrl!==void 0)try{C(t.upstreamUrl)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(2)}let o;try{o=E(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(2)}let s=o.port;try{let r=await w({config:e,cwd:process.cwd(),port:s,fallbackToKernel:o.fallbackToKernel,host:a,...t.upstreamUrl===void 0?{}:{upstreamUrl:t.upstreamUrl}}),i=a===void 0||a===`::`||a===`0.0.0.0`?`localhost`:a;console.log(`${n(`[ui]`)} listening on http://${i}:${r.port}`);let c=!1,l=e=>{if(c)return;c=!0,console.log(n(`\n[ui] Shutting down (${e})`)),r.detachSafetyNet();let t=()=>{try{r.release()}finally{process.exit(process.exitCode??0)}};r.drainUpgradeSockets(),S(r.httpServers).then(t,t),setTimeout(t,2e3).unref()};process.once(`SIGINT`,()=>l(`SIGINT`)),process.once(`SIGTERM`,()=>l(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),o=a??`localhost`,c;try{c=await D({requestedPort:s,host:o,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(c.mode===`already-running`){if(console.log(`UI already running at http://${o}:${c.port}`),k(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${o}:${c.upstreamPort}; acting as HTTP proxy on port ${c.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),c.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}}function k(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}export{O as runUiCommand};
|
|
3
|
+
//# sourceMappingURL=ui-7z12LoCq.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{$o as r,cs as i,fs as a,ss as o}from"./src-Dj6UxpKM.mjs";import{yr as s,zr as c}from"./src-DvuwJKkU.mjs";import{basename as l,dirname as u,isAbsolute as d,join as f,posix as p,relative as m,resolve as h,sep as g,win32 as _}from"node:path";import{cpSync as ee,existsSync as v,lstatSync as te,mkdirSync as y,readFileSync as ne,realpathSync as b,rmSync as x,statSync as re}from"node:fs";import{homedir as S}from"node:os";var C=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})),w=n((e=>{let{InvalidArgumentError:t}=C();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})),T=n((e=>{let{humanReadableArgName:t}=w();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})),E=n((e=>{let{InvalidArgumentError:t}=C();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:oe,createCommand:se,createArgument:ce,createOption:le,CommanderError:ue,InvalidArgumentError:D,InvalidOptionArgumentError:de,Command:fe,Argument:pe,Option:me,Help:he}=t(n((e=>{let{Argument:t}=w(),{Command:n}=ae(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();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,O=o,k=
|
|
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:oe,createCommand:se,createArgument:ce,createOption:le,CommanderError:ue,InvalidArgumentError:D,InvalidOptionArgumentError:de,Command:fe,Argument:pe,Option:me,Help:he}=t(n((e=>{let{Argument:t}=w(),{Command:n}=ae(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();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,O=o,k=i,ge=a,A=`node`,j={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},M=`# 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`,P=`// ok-pi-bridge`,F=`${P}-v1`,I=`ok-pi-managed-extension`;function L(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(F)}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=h(e);if(l(t)===`cli.mjs`&&l(u(t))===`dist`)return t;let n=t.split(g),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 f(i.length===0?g:i.join(g),`packages`,`cli`,`dist`,`cli.mjs`)}function z(e={}){return e.mode===`dev`?{command:A,args:[R(),`mcp`],env:{...j}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,N]}:{command:`/bin/sh`,args:[`-l`,`-c`,M]}}function _e(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[A,R(),`mcp`],environment:{...j}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,N]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,M]}}function ve(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?ye(e,t):!1}function ye(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 be(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 xe(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`?_:p}function Se(e={}){let t=e.platformName??process.platform,n=e.home??S(),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 Ce(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.claude.json`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=e.env??process.env;if(t===`darwin`)return p.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??_.join(n,`AppData`,`Roaming`);return _.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??S();return H(t).join(n,`.cursor`,`mcp.json`)}function we(e={}){let t=e.platformName??process.platform,n=e.home??S();return(e.env??process.env).CODEX_HOME??H(t).join(n,`.codex`)}function G(e={}){return H(e.platformName??process.platform).join(we(e),`config.toml`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=(e.env??process.env).COPILOT_HOME??H(t).join(n,`.copilot`);return H(t).join(r,`mcp-config.json`)}function Te(e={}){let t=e.platformName??process.platform,n=e.home??S(),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(Te(e),`opencode.json`)}function Ee(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.openclaw`,`openclaw.json`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.hermes`,`config.yaml`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??S();return(e.env??process.env).PI_CODING_AGENT_DIR??H(t).join(n,`.pi`,`agent`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Ae(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=Ae(e.home??S(),t);return n.find(e=>v(e))||n.find(e=>v(u(e)))||n[0]}const Y={claude:{id:`claude`,label:k.claude,configPath:(e,t)=>Ce({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.claude`),projectConfigPath:e=>f(e,`.mcp.json`),projectSkillPath:e=>f(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:k[`claude-desktop`],configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(U({home:t}))},cursor:{id:`cursor`,label:k.cursor,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(W({home:t})),projectConfigPath:e=>f(e,`.cursor`,`mcp.json`),projectSkillPath:e=>f(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:k.codex,configPath:(e,t)=>G({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(G({home:t})),projectConfigPath:e=>f(e,`.codex`,`config.toml`),projectSkillPath:e=>f(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:k.copilot,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(K({home:t})),projectSkillPath:e=>f(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:k.opencode,configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>r,buildEntry:(e,t)=>_e(t),scope:`global`,detectPath:(e,t)=>u(q({home:t})),projectConfigPath:e=>f(e,`opencode.json`),projectSkillPath:e=>f(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:k.openclaw,configPath:(e,t)=>Ee({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:k.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:()=>r,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)=>Oe({home:t}),projectConfigPath:e=>f(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>f(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:k.antigravity,configPath:(e,t)=>ke({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:k[`lm-studio`],configPath:(e,t)=>J({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(J({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:k.hermes,configPath:(e,t)=>De({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.hermes`),offerOnlyWhenDetected:!0}};function je(e){let t=e.filter(e=>!Object.hasOwn(Y,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${O.join(`, `)}`);return e.map(e=>Y[e])}function X(e,t){let n;try{n=te(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.`);Z(e,t)}function Me(e,t){Z(e,t)}function Z(e,t){let n;try{n=b(t)}catch{n=h(t)}let r=u(e);for(;r.length>1&&r!==g;){let t;try{t=b(r)}catch(e){if(e.code===`ENOENT`){r=u(r);continue}throw e}let i=m(n,t);if(i===``||!i.startsWith(`..`)&&!d(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 Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ne(e,t,n){try{if(re(n).size>10485760)return!1}catch{return!1}let r;try{r=ne(n,`utf-8`)}catch{return!1}let i=[],a=c(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!Q(a))return!1;let o=a[e.topLevelKey];if(!Q(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;return Q(s)?Q(s[e.serverName(t)]):!1}function Pe(e,t,n={}){if(e.id!==`copilot`)return!0;try{return Ne(e,t,e.configPath(t,n.home))}catch{return!1}}function $(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Pe(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=s(`project`,{checkDesktop:!0}),i=u(r);X(i,t);let a=v(r)?`overwritten`:`written`;return x(i,{recursive:!0,force:!0}),y(u(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)}}}export{je as _,k as a,me as b,P as c,z as d,be as f,Se as g,xe as h,O as i,F as l,ve as m,Me as n,Y as o,L as p,$ as r,ge as s,X as t,I as u,fe as v,D as y};
|
|
56
|
-
//# sourceMappingURL=write-project-skill-
|
|
56
|
+
//# sourceMappingURL=write-project-skill-DUj7e5tZ.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.52.0-beta.
|
|
3
|
+
"version": "0.52.0-beta.7",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"ajv-formats": "^3.0.1",
|
|
63
63
|
"tsdown": "^0.21.7",
|
|
64
64
|
"typescript": "^5.9.3",
|
|
65
|
-
"@inkeep/open-knowledge-
|
|
65
|
+
"@inkeep/open-knowledge-app": "0.52.0-beta.7",
|
|
66
66
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
67
|
-
"@inkeep/open-knowledge-
|
|
68
|
-
"@inkeep/open-knowledge-server": "0.52.0-beta.
|
|
67
|
+
"@inkeep/open-knowledge-core": "0.52.0-beta.7",
|
|
68
|
+
"@inkeep/open-knowledge-server": "0.52.0-beta.7"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build:cli": "rm -rf dist && tsdown",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./git-handle-CH1DpBYP.mjs";export{e as createGitInstance};
|
package/dist/init-Djv0aq5j.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as e}from"./init-3ynssnTV.mjs";export{e as runInit};
|
package/dist/loader-Cwl2ZS4i.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-DAruuWzH.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-CC6sojTR.mjs";export{t as formatPreviewBlock,e as previewContent};
|