@inkeep/open-knowledge 0.59.0-beta.34 → 0.59.0-beta.36
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-Di_-RWyN.mjs → acp-harness-probe-QCgI53eF.mjs} +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/constants-DX7otkBl.mjs +2 -0
- package/dist/{git-handle-CB29jOi9.mjs → git-handle-BkSalb6i.mjs} +2 -2
- package/dist/git-handle-DaYxKcxM.mjs +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +180 -180
- package/dist/init-BEqinO5H.mjs +1 -0
- package/dist/{init-BPPdgR-3.mjs → init-BWqcAtZ6.mjs} +3 -3
- package/dist/{launch-json-removal-1fEipbyM.mjs → launch-json-removal-DMwzIxnA.mjs} +2 -2
- package/dist/{loader-fWWf7FVt.mjs → loader-CvxR-p7O.mjs} +2 -2
- package/dist/loader-pBGmJ00_.mjs +1 -0
- package/dist/md-manager-_lKMHY2F.mjs +2 -0
- package/dist/{open-browser-BoXWzzB3.mjs → open-browser-CldvWM5B.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-DJ39N-iM.mjs → preview-49bOyskp.mjs} +2 -2
- package/dist/preview-CS_MMxsz.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-ZMkynbjt.js → ActivityModeContent-CPVWFbUj.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-B8nC1KUO.js → AgentDiffPane-vKHDjrFP.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-B0Tnmc_C.js → AgentThreadClientBinder-DuflAOYp.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-D7nB1aDJ.js → CodeMirrorPropInput-zWNXj-An.js} +1 -1
- package/dist/public/assets/{DocumentContext-DK6WjZtm.js → DocumentContext-DZbxXv6H.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-Bw3g_RS7.js → EditorModeToggle-DabSiY81.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-D6G6yrqT.js → EnableSyncConfirmDialog-BqkxgRaX.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-BUL0FNWm.js → ExcalidrawDocEditor-CIIPYb0V.js} +1 -1
- package/dist/public/assets/FeedbackForm-DTsymupO.js +1 -0
- package/dist/public/assets/{GraphPanel-Cxz5VYMl.js → GraphPanel-CDq6Cn96.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-Eb3L_zjp.js → ImportSkillDialog-6I-tdfnK.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-DfvsohvN.js → LintConfigEditor-iIARYye7.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-3se1RZmj.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-BmksuBSn.js → ManagedArtifactProperties-BPyzZkdV.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-QByjyMzX.js → MermaidDocEditor-DxoJLmGh.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-CE9D0uq8.js → PropertyDisplayRow-fMZKhF3_.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-BY7Mi1BQ.js → ReportBugDialogBody-Bkfnn8Pd.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-vZ4Iznw7.js → SchemaConfigEditor-fFuUGFGN.js} +1 -1
- package/dist/public/assets/{SessionsHost-C_VgMQtT.js → SessionsHost-pFFD0VSW.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-CzOL2SRu.js → SettingsDialogBody-CqJssURh.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-Dyzc83GK.js → ShareBranchSwitchDialog-t6-lKq1l.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-CtF5U57_.js → ShareReceiveDialog-LuA8x7YC.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-D4TxU2FH.js → ShareReceiveMissDialog-D8ADRN91.js} +1 -1
- package/dist/public/assets/{SkillCostValue-B9rxsZZe.js → SkillCostValue-CGcui9JR.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-Btv3scxq.js → SkillEditBanner-CNTikXwl.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-Djr9cLyQ.js → SkillInstallMenu-Cpjl7OIH.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-CVtmqSId.js → SkillOriginInline-CXj10KzG.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-NDRzmFvN.js → SkillToolbarControls-Cfi6OPhq.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-BUZLwCo9.js → SlidesToolbarControls-DIQu0p-H.js} +1 -1
- package/dist/public/assets/{SourceEditor-D280BxeC.js → SourceEditor-CqiFwBMC.js} +1 -1
- package/dist/public/assets/{TerminalPanel-B2eMtg9W.js → TerminalPanel-BqbCRTNn.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-CVnAHjIj.js → TerminalWindowApp-Pv-VOJ0w.js} +1 -1
- package/dist/public/assets/{TextDocEditor-B19eo9Zu.js → TextDocEditor-Bw-f5mNN.js} +1 -1
- package/dist/public/assets/{ThreadView-CUlb_KNW.js → ThreadView-CLESX5dJ.js} +2 -2
- package/dist/public/assets/{TimelineDiffPane-iZl0xaNU.js → TimelineDiffPane-NUKr4hbw.js} +1 -1
- package/dist/public/assets/{agent-diff-store-d13OQwxA.js → agent-diff-store-sEwMOwXy.js} +1 -1
- package/dist/public/assets/{auth-state-cache-CE_bMumR.js → auth-state-cache-Cb7mdO-H.js} +1 -1
- package/dist/public/assets/{client-version-BnANtuGb.js → client-version-BSiKYSme.js} +1 -1
- package/dist/public/assets/{comment-chips-DxWHm9Cs.js → comment-chips-C8RgEJKK.js} +1 -1
- package/dist/public/assets/{config-provider-KCmXGgSj.js → config-provider-Cm5WhzR7.js} +1 -1
- package/dist/public/assets/{dist-C7FVgQnF2.js → dist-D-pIxpOA2.js} +1 -1
- package/dist/public/assets/{doc-paths-RsoaUvtD.js → doc-paths-je9IlWgC.js} +1 -1
- package/dist/public/assets/{documents-events-CsY1UHz_.js → documents-events-Dv0-c6Gq.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-VJviIUhC.js → file-tree-adapter-BcQxnXAE.js} +1 -1
- package/dist/public/assets/{file-tree-utils-CFgZ2Cn3.js → file-tree-utils-DaZREteD.js} +1 -1
- package/dist/public/assets/{folder-config-api-C9BPoMvu.js → folder-config-api-CWvrN8lP.js} +1 -1
- package/dist/public/assets/i18n-BaCTU6Zh.js +1 -0
- package/dist/public/assets/{index-CBp1gH73.js → index-Cn_Zo_-J.js} +7 -7
- package/dist/public/assets/{lint-config-client-B7E69j5g.js → lint-config-client-DKa5fmfG.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser--Z9pkvK3.js → markdownlint-rule-browser-r1KXGJzZ.js} +1 -1
- package/dist/public/assets/{navigation-targets-xthiKVG-.js → navigation-targets-D-ukZJM0.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-BSvOi_H-.js → open-managed-artifact-tab-Dz-XpKZV.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-eivLgf-S.js → pending-receive-nav-store-BIWb4fW2.js} +1 -1
- package/dist/public/assets/{progress-BzUYuL-V.js → progress-DN5ZVmeh.js} +1 -1
- package/dist/public/assets/{prop-types-Cy2A7TPC.js → prop-types-CYiFLB9V.js} +1 -1
- package/dist/public/assets/{receive-store-CtzFhr6S.js → receive-store-C4Bb5kEd.js} +1 -1
- package/dist/public/assets/{selection-context-gHo_9Fbo.js → selection-context-GAipzi1C.js} +1 -1
- package/dist/public/assets/{skill-actions-DtcJ1SJd.js → skill-actions-CwEwwoQa.js} +1 -1
- package/dist/public/assets/{skill-scope-Bua0nDSa.js → skill-scope-MvvK5VaZ.js} +1 -1
- package/dist/public/assets/{skills-api-D08ihk2a.js → skills-api-DSiZ01ML.js} +1 -1
- package/dist/public/assets/{src-NjVFjnQM.js → src-Cxbc-uJu.js} +1 -1
- package/dist/public/assets/{tag-pill-input-BilmKPUq.js → tag-pill-input-DLu1afux.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-7U-MrZdc.js → target-navigation-intent-6yA5JFaJ.js} +1 -1
- package/dist/public/assets/{terminal-cli-display-C2erLHKw.js → terminal-cli-display-BYsImxHL.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-CKR4fyca.js → terminal-launch-events-weVUvN2D.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-DVJphneI.js → terminal-telemetry-BdGxgj0Q.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-CgfR26-J.js → typing-burst-detector-CnrmNGX4.js} +1 -1
- package/dist/public/assets/{uninstall-ZTgWvcqD.js → uninstall-DB1pYf9F.js} +1 -1
- package/dist/public/assets/{use-activity-panel-D-Xmd1zX.js → use-activity-panel-BOZG8akM.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-BBRWSHcW.js → use-apply-config-color-theme-Kky-EB37.js} +1 -1
- package/dist/public/assets/{use-collab-url-DElOWqQi.js → use-collab-url-B8CCNpkf.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-JuPkRnhw.js → use-live-xterm-theme-aATfBST5.js} +1 -1
- package/dist/public/assets/{use-open-skill-Cwhk0mI6.js → use-open-skill-CRdMHw50.js} +1 -1
- package/dist/public/assets/{use-popular-skills-C4zNnQqG.js → use-popular-skills-BSlbkBjx.js} +1 -1
- package/dist/public/assets/{use-settings-route-BBLR_URX.js → use-settings-route-B0SXlDtB.js} +1 -1
- package/dist/public/assets/{use-skill-origin-BYWnSATz.js → use-skill-origin-QuR6e3Vu.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-QPWQYOg5.js → use-terminal-enabled-Cwmb5Ljb.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-BcxlAt36.js → use-timeline-entry-diff-DnoIkq-D.js} +1 -1
- package/dist/public/assets/{use-workspace-uY_J8IXy.js → use-workspace-CTA6IT0U.js} +1 -1
- package/dist/public/index.html +45 -45
- package/dist/public/uninstall.html +3 -3
- package/dist/{repair-launch-json-Ds_co6BF.mjs → repair-launch-json-BOcSrWnv.mjs} +2 -2
- package/dist/{repair-mcp-configs-mBJdV4TM.mjs → repair-mcp-configs-Bk2GWwNF.mjs} +2 -2
- package/dist/repair-skills-CS2_jKX3.mjs +1 -0
- package/dist/{repair-skills-CVBoZIiO.mjs → repair-skills-DdLknuYw.mjs} +2 -2
- package/dist/{resolve-project-root-9pJU-v6u.mjs → resolve-project-root-CHFE5Tp7.mjs} +2 -2
- package/dist/server-lock-BZi8m82Z.mjs +1 -0
- package/dist/{server-lock-B3DaXpD-.mjs → server-lock-RKPNHNqb.mjs} +2 -2
- package/dist/{skill-teardown-Bk-FU2uA.mjs → skill-teardown-DcAF7q_b.mjs} +2 -2
- package/dist/src-BC0KB0iC.mjs +1 -0
- package/dist/{src-DM9JDHjF.mjs → src-BD1wHyiU.mjs} +132 -132
- package/dist/src-Bj-Lujyc.mjs +20 -0
- package/dist/{src-DglWR2eG.mjs → src-CKvbaaFV.mjs} +6 -6
- package/dist/{src-C8WBxBLt.mjs → src-nk8WfDCB.mjs} +1 -1
- package/dist/{start-C8fdm-hL.mjs → start-Cjj7wN_L.mjs} +3 -3
- package/dist/start-eJUHUCS6.mjs +1 -0
- package/package.json +4 -4
- package/dist/constants-GAM5x9w9.mjs +0 -2
- package/dist/git-handle-Ci-ka9U-.mjs +0 -1
- package/dist/init-Dd_JpLUw.mjs +0 -1
- package/dist/loader-Dm3E7pLr.mjs +0 -1
- package/dist/md-manager-V3jbnXEF.mjs +0 -2
- package/dist/preview-Dz3G3RQg.mjs +0 -1
- package/dist/public/assets/FeedbackForm-lSXcApar.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-lJ8wwEp2.js +0 -1
- package/dist/public/assets/i18n-CxTgngSa.js +0 -1
- package/dist/repair-skills-C_-Lco2y.mjs +0 -1
- package/dist/server-lock-DEUsqKAE.mjs +0 -1
- package/dist/src-DJEaKGS2.mjs +0 -1
- package/dist/src-MQhU1L8k.mjs +0 -20
- package/dist/start-AoUp7eD_.mjs +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,pt as n,q as r}from"./sleep-DhRrtbfG.mjs";import{Dc as i,Ec as a,bo as o,ct as s,jc as c,lt as l}from"./src-BD1wHyiU.mjs";import{Ci as u,Pn as ee,at as d,ei as f,it as p,ot as m,rt as h}from"./src-CKvbaaFV.mjs";import{D as g,F as _,I as v,k as y}from"./fs-traced-2B_-YK-g.mjs";import{C as b,S as x,_ as S,f as C,r as w}from"./server-lock-RKPNHNqb.mjs";import{t as T}from"./yazl-DZr4PyKA.mjs";import{b as E,h as D,m as te}from"./resolve-project-root-CHFE5Tp7.mjs";import{c as ne}from"./colors-DSyAT9Cz.mjs";import{n as O}from"./acp-harness-probe-QCgI53eF.mjs";import{E as k,T as re,_ as ie,b as A,o as ae,w as j,x as oe}from"./init-BWqcAtZ6.mjs";import{n as se}from"./constants-DX7otkBl.mjs";import{t as ce}from"./is-object-Bw0-z8qH.mjs";import"./loader-CvxR-p7O.mjs";import"./skill-teardown-DcAF7q_b.mjs";import"./preview-49bOyskp.mjs";import{execSync as le,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,join as F,relative as ue,resolve as I,sep as de}from"node:path";import{cpSync as fe,createWriteStream as pe,existsSync as L,lstatSync as me,mkdirSync as R,mkdtempSync as he,readFileSync as z,readdirSync as B,readlinkSync as ge,rmSync as _e,statSync as ve,writeFileSync as V}from"node:fs";import{arch as ye,freemem as be,homedir as H,hostname as xe,platform as Se,release as Ce,tmpdir as we,totalmem as Te,type as Ee,uptime as De}from"node:os";import"node:fs/promises";import{createHash as Oe}from"node:crypto";var ke=n();const Ae=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function je(e,t,n=ee){if(e!==void 0&&!Ae.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Me=null;function Ne(e){Me=e}function Pe(){return Me??process.cwd()}function U(){return F(H(),`.ok`,`bug-reports`)}function Fe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=U(),r=`${t}-bugreport`,i=F(n,`${r}.zip`);for(let e=2;L(i);e+=1)i=F(n,`${r}-${e}.zip`);return i}function Ie(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let e=z(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 L(F(e,`.ok`))?Oe(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Le(){let e={timestamp:new Date().toISOString(),platform:Se(),osType:Ee(),osRelease:Ce(),hostname:`[redacted]`,uptime:De(),freeMem:be(),totalMem:Te(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=le(`sw_vers -productVersion 2>/dev/null`,f({encoding:`utf8`})).trim()}catch{}try{let t=F(__dirname,`..`,`..`,`package.json`);L(t)&&(e.okVersion=JSON.parse(z(t,`utf8`)).version)}catch{}return e}const Re=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function ze(e){let t=N(e);return Re.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Be(e,t){return We(e,t).files}const Ve=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function He(e,t=O){let n=F(e,`${t}.ShipIt`);return L(n)?Ve.map(e=>F(n,e)).filter(e=>L(e)):[]}function Ue(e){if(!L(e))return[];try{return B(e).filter(e=>e.endsWith(`.yaml`)).sort().slice(-25).map(t=>F(e,t))}catch{return[]}}function We(e,t){if(!L(t))return{files:[],excludedByProjectSlug:0};let n=B(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>F(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(ze),i=[],a=r.filter(t=>{try{return z(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=>!ze(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ge(e){let t=F(e,`.ok`,`local`);return L(t)?{files:[`server.lock`,`last-spawn-error.log`,s].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function Ke(e){let t=F(e,`.ok`,`local`,`logs`);return L(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function qe(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 W(e){for(let t of e.files)try{qe({zipfile:e.zipfile,name:`${e.prefix}/${N(t)}`,content:z(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 Je(t){let{redact:n,outputPath:r,logger:i}=t,o=t.userLogsDir??F(H(),`.ok`,`logs`),s=t.projectDir?Ie(t.projectDir,i):null;R(P(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let l=Le();l.desktop=t.desktop??null,l.language=t.language??null;let{files:u,excludedByProjectSlug:ee}=We(s,o),{files:d}=t.projectDir?Ge(t.projectDir):{files:[]},{files:f}=t.projectDir?Ke(t.projectDir):{files:[]},p=t.shipItLogFiles??[];i?.info({logFileCount:u.length,logFilesExcludedByProjectSlug:ee,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length},`files collected`);let m=[],h=[],{ZipFile:g}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),_=new g;W({zipfile:_,files:[...u,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:i}),W({zipfile:_,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:i}),W({zipfile:_,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:i}),W({zipfile:_,files:t.bugReportLedgerFiles??[],prefix:c,redact:n,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;_.addBuffer(t,n),h.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&qe({zipfile:_,name:`note.txt`,content:t.note,redact:n,bundleFiles:h,redactions:m});let v=JSON.stringify(l,null,2);_.addBuffer(Buffer.from(v,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let y={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:h,redactions:m,sysinfo:l};_.addBuffer(Buffer.from(JSON.stringify(y,null,2),`utf8`),`MANIFEST.json`);let b=m.reduce((e,t)=>e+t.lineCount,0),x=new Set(p.map(e=>`logs/${N(e)}`)),S=h.filter(e=>x.has(e)),C=new Set((t.bugReportLedgerFiles??[]).map(e=>`${c}/${N(e)}`)),w=h.filter(e=>C.has(e)),T=s?h.filter(e=>e.startsWith(`logs/`)&&!ze(e)&&!x.has(e)):[],E=[`# Bug Report Bundle`,``,`Generated: ${y.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${y.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...T.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:`,...T.map(e=>`- ${e}`),``]:[],...S.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:`,...S.map(e=>`- ${e}`),``]:[],...w.length>0?[`Send history: one small record per bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...w.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${a.join(`, `)}`,b>0?`${b} 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
|
+
`);_.addBuffer(Buffer.from(E,`utf8`),`README.md`),_.end();let D=pe(r);return _.outputStream.pipe(D),await new Promise((e,t)=>{D.on(`close`,e),D.on(`error`,t)}),i?.info({bundlePath:r,fileCount:h.length,redactionCount:b},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:h,redactions:m,redactedLineCount:b,generatedAt:y.generatedAt}}}var Ye=e(T(),1),G=e(ne(),1);function Xe(e){return v({absPath:y(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Ze({home:e=H(),env:n=process.env}={}){let i=Xe(e),{override:a,preferenceList:s}=g(n),{locale:c,source:l}=o({override:a,storedPreference:i,supportedLocales:r,preferenceList:s,autoDetectableLocales:t});return{preference:i,locale:c,source:l,systemLanguages:s}}function Qe(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function $e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){if(typeof e==`string`)return Qe(e,t.contentDir);if(Array.isArray(e))return e.map(e=>K(e,t));if(!$e(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=K(i,t);return n}function et(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
|
+
`),i=n.split(`
|
|
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=K(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}V(e,r?`${a.join(`
|
|
5
|
+
`)}\n`:a.join(`
|
|
6
|
+
`))}function tt(e,t){let n=z(e,`utf-8`);if(n.trim().length!==0)try{let r=K(JSON.parse(n),t),i=n.endsWith(`
|
|
7
|
+
`)?`
|
|
8
|
+
`:``;V(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Qe(n,t.contentDir);r!==n&&V(e,r)}}function nt(e,t){let n=z(e,`utf-8`),r=Qe(n,t.contentDir);r!==n&&V(e,r)}function rt(e){try{return B(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>F(e,t.name))}catch{return[]}}const it=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function at(e){return/\.log\.\d+$/.test(e)}function ot(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||at(e)}function st(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of rt(F(e.stagingDir,n)))ot(r)?et(r,t):r.endsWith(`.json`)?tt(r,t):nt(r,t);for(let n of rt(F(e.stagingDir,`state`))){let e=N(n);n.endsWith(`.jsonl`)?et(n,t):it.has(e)?tt(n,t):nt(n,t)}}const ct=[`.ok`,`local`,`telemetry`],lt=[`.ok`,`local`,`logs`],ut=[`.ok`,`local`,`loss-capture`],dt=`spans-current.jsonl`,ft=`spans-prev.jsonl`,pt=`server-current.jsonl`,mt=`server-prev.jsonl`,ht=`loss-current.jsonl`,gt=`loss-prev.jsonl`;function _t(e){return F(e,...ct,dt)}function vt(e){return F(e,...ct,ft)}function yt(e){return F(e,...lt,pt)}function bt(e){return F(e,...lt,mt)}function xt(e){return F(e,...ut,ht)}function St(e){return F(e,...ut,gt)}const Ct=1e3;async function wt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Ct)});return t.ok?await t.text():null}catch{return null}}async function Tt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Ct)});return t.ok?await t.text():null}catch{return null}}async function Et(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Ct)});return t.ok?await t.text():null}catch{return null}}function Dt(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 Ot(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`log`,`--oneline`,`-50`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function kt(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function At(){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 jt(){return{nodeVersion:process.version,platform:Se(),arch:ye()}}function Mt(){return process.env.OTEL_SDK_DISABLED===`false`}function q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Nt(e){if(!L(e))return{};let t;try{t=(0,ke.parse)(z(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(!q(t))return{};let n=t.telemetry;if(!q(n))return{};let r=n.localSink;return q(r)?r:{}}function Pt(e){return typeof e==`boolean`?e:void 0}function Ft(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function J(e){if(q(e))return Ft(e.maxBytes)}function It(e){let t=Nt(y(`project`,e)),n=Nt(y(`project-local`,e));return{enabled:Pt(n.enabled)??Pt(t.enabled)??!0,spansMaxBytes:J(n.spans)??J(t.spans)??52428800,logsMaxBytes:J(n.logs)??J(t.logs)??26214400}}function Lt(e){return Oe(`sha256`).update(e).digest(`hex`)}function Rt(e){let t=z(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function zt(e){let t=z(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 Y(e,t){if(!L(e))return!1;try{return R(P(t),{recursive:!0}),fe(e,t),!0}catch{return!1}}function Bt(e){let t=[],n=e=>{let r=B(e,{withFileTypes:!0});for(let i of r){let r=F(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Vt=new Set([`.jsonl`]);function Ht(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Vt.has(e.slice(t))}const Ut=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`]);function Wt(e){if(at(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Ut.has(e.slice(t))}function Gt(e){let t=[];for(let n of Bt(e)){let r=Kt(e,n);if(!Wt(r))continue;let{redacted:a,patterns:o,lineCount:s}=i(z(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 Kt(e,t){return ue(e,t).split(de).join(`/`)}async function qt(e){let t=I(e.contentDir),n=I(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??wt,a=r.fetchAgentEffects??Tt,o=r.fetchWatcherRecent??Et,u=r.readShadowHead??Ot,ee=r.readCheckpointRefs??kt,d=r.now??(()=>new Date),f=r.okVersion??(()=>se),p=r.readDesktopEnv??At,m=r.readLanguage??Ze,h=r.readRuntime??jt,g=r.isOtlpPushEnabled??Mt,_=he(F(we(),`ok-bundle-`));try{R(F(_,`telemetry`),{recursive:!0}),R(F(_,`logs`),{recursive:!0}),R(F(_,`state`),{recursive:!0}),Y(_t(n),F(_,`telemetry`,dt)),Y(vt(n),F(_,`telemetry`,ft)),Y(yt(n),F(_,`logs`,pt)),Y(bt(n),F(_,`logs`,mt));for(let t of e.userLogFiles??[])Y(t,F(_,`logs`,N(t)));for(let t of e.userStateFiles??[])Y(t,F(_,c,N(t)));let v=F(n,`.ok`,`local`),y=F(v,`server.lock`),b=`not-running`,x=`no server.lock`,S=null;if(L(y)){Y(y,F(_,`state`,`server.lock`));try{let e=z(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?S=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(S!==null){let e=await i(S);e===null?x=`agent-presence endpoint at :${S} unreachable`:(V(F(_,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await a(S);t!==null&&V(F(_,`state`,`agent-effects.json`),t);let n=await o(S);if(n!==null){let e=Dt(n);e!==null&&V(F(_,`state`,`watcher-recent.jsonl`),e)}}let C=u(t);C!==null&&V(F(_,`state`,`shadow-head.txt`),C);let w=ee(t);w!==null&&V(F(_,`state`,`checkpoint-refs.txt`),w),Y(xt(n),F(_,`state`,ht)),Y(St(n),F(_,`state`,gt)),Y(F(v,`last-spawn-error.log`),F(_,`state`,`last-spawn-error.log`)),Y(F(v,l),F(_,`state`,l)),Y(F(v,s),F(_,`state`,s));let T=h(),E=p(),D=m(),te={ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D}};V(F(_,`state`,`runtime.json`),`${JSON.stringify(te,null,2)}\n`);let ne=b===`running`?`running
|
|
10
|
+
`:`not-running (${x})\n`;if(V(F(_,`state`,`server-status.txt`),ne),e.processDir&&L(e.processDir)){let t=F(_,`process`);R(t,{recursive:!0}),fe(e.processDir,t,{recursive:!0})}let O=e.redact===!0;O&&st({stagingDir:_,contentDir:t}),e.note&&V(F(_,`note.txt`),e.note);let k=null;e.scrubSecrets===!0&&(k=Gt(_));for(let t of e.extraFiles??[])Y(t.sourcePath,F(_,`extra`,t.zipName??N(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let re=It(n),ie=Bt(_),A=[],ae=0,j=0;for(let e of ie){let t=Kt(_,e),n=ve(e).size,r=Ht(t)?Rt(e):0;A.push({path:t,bytes:n,lines:r}),ae+=n,t.startsWith(`telemetry/`)&&Ht(t)&&(j+=zt(e))}let oe={applied:O};k!==null&&(oe.secretScrub=k);let se={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D},contentDir:{pathSha256:Lt(t),absolutePath:O?`<CONTENT_DIR>`:t},telemetry:{localSink:re,otlpPushEnabled:g()},redaction:oe,serverStatus:b,files:A};V(F(_,`manifest.json`),`${JSON.stringify(se,null,2)}\n`);let ce=ie.some(e=>{try{return z(e,`utf-8`).includes(t)}catch{return!1}}),le={totalBytes:ae,fileCount:A.length,docNameCount:j,contentDirVisible:ce,redacted:O},M=!1;return{stagingDir:_,manifest:se,summary:le,cleanup:()=>{M||(M=!0,_e(_,{recursive:!0,force:!0}))}}}catch(e){throw _e(_,{recursive:!0,force:!0}),e}}async function Jt(e){let{collected:t,outputPath:n}=e,r=P(n);if(!L(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Ye.ZipFile,a=Bt(t.stagingDir);for(let e of a){let n=Kt(t.stagingDir,e);i.addFile(e,n)}i.end();let o=pe(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 Yt(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let t=(0,ke.parse)(z(n,`utf-8`)),r=ce(t)?t.content:void 0,i=ce(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return I(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 I(e)}async function Xt(e,t,n,r){let i=Ie(t,e.logger),a=await qt({contentDir:Yt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...Be(i,e.userLogsDir??F(H(),`.ok`,`logs`)),...He(e.cachesDir??F(H(),`Library`,`Caches`))],userStateFiles:Ue(e.bugReportsDir??U()),deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{R(P(e.outputPath),{recursive:!0}),await Jt({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 Zt(e){let{projectDir:t}=e,n=e.readDesktopEnv??At,r=e.readLanguage??Ze;if(e.level===`full`&&t!==void 0)return Xt(e,t,n,r);let{zipPath:i,summary:a}=await Je({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:He(e.cachesDir??F(H(),`Library`,`Caches`)),bugReportLedgerFiles:Ue(e.bugReportsDir??U()),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 Qt(e,t){if(!L(e))return{status:`missing`,lockPath:e};let n;try{n=JSON.parse(z(e,`utf-8`))}catch{return{status:`corrupt`,lockPath:e}}if(!n||typeof n!=`object`||!b(n.pid))return{status:`corrupt`,lockPath:e};let r=n;if(!(t.isAlive??x)(r.pid))return{status:`dead-pid`,lockPath:e,lock:r};if(typeof r.machineId==`string`)return r.machineId===(t.machineId??S())?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r};let i=t.host??xe();return r.hostname===i?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r}}function X(e,t,n={}){return Qt(C(e,t),n)}function Z(e,t={}){return Qt(F(e,`ui.lock`),t)}function $t(e){return e.replace(/:\d+$/,``)}function en(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:$t(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:$t(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:$t(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 tn=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function nn(e){return F(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const rn={existsSync:e=>L(e),readFileSync:(e,t)=>z(e,t),lstatSync:e=>me(e),readlinkSync:e=>ge(e)};function an(e,t=rn){let n=nn(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 on(e){let t=e.replace(tn,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function sn(e,t,n=rn){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function cn(e){return te(e)||D(e)||oe(e)}const ln=10*1024*1024;function un(e,t,n,r){let i=ae(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(!cn(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`?(_e(a,{force:!0}),{kind:`removed`}):e.format===`toml`?pn(a,o):e.format===`yaml`?fn(a,e.topLevelKey,o):dn(a,e.topLevelKey,e.serverMapSubKey,o)}function dn(e,t,n,r){let i;try{i=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>ln)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=k(i,ie(t,n,r));return o?(_(e,a,{mode:j(e)}),{kind:`removed`}):{kind:`not-present`}}function fn(e,t,n){let r;try{r=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>ln)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,ke.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=re(a);a.trim()===``||a.endsWith(`
|
|
11
|
+
`)?c.endsWith(`
|
|
12
|
+
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
13
|
+
`).replace(/\n/g,`\r
|
|
14
|
+
`));let u=`${i?``:``}${c}`;return u!==r&&_(e,u,{mode:j(e)}),{kind:`removed`}}function pn(e,t){let n=A();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=re(a),s=a.trim()===``||a.endsWith(`
|
|
15
|
+
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
16
|
+
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
17
|
+
`).replace(/\n/g,`\r
|
|
18
|
+
`));let u=`${i?``:``}${l}`;return u!==r&&_(e,u,{mode:j(e)}),{kind:`removed`}}function mn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function hn(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 gn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;let i=t.lock,a=t.status===`alive`&&w(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:p(n),command:n,isDesktop:mn(n)}}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const _n=new Set([`running`,`desktop`,`foreign`]);function vn(e){switch(e){case`running`:return G.default.green(e);case`desktop`:return G.default.blue(e);case`foreign`:return G.default.cyan(e);case`stale`:return G.default.yellow(e)}}function yn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function bn(e){return`${yn(e.server.usage)} | ${yn(e.ui?.usage??null)}`}function xn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Sn(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=>[e.directory,xn(e),bn(e),Q(e),String(e.server.pid),hn(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=vn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=G.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
19
|
+
`)}async function Cn(e={}){let t=e.discover??h,n=e.inspect??X,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=gn(e,t,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(Sn(e.all?s:s.filter(e=>_n.has(Q(e)))))}function wn(){return new E(`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 Cn({all:t.all===!0||e===`all`,json:t.json===!0})})}function Tn(e,t,n={}){let r=n.isAlive??x,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 En(e){let t=e.inspect??(t=>t===`ui`?Z(e.lockDir):X(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=Tn(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 Dn(e,t=x){let n=await h(),r=null;for(let i of n){let n=X(i,`server`),a=Z(i);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 On(e){let t=En({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function kn(e){return new E(`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=En({lockDir:u(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 Cn({});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=X(n,`server`),r=Z(n);!$(e,x)&&!$(r,x)||(On(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 Dn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}On(t);return}On(u(I(Pe(),n)))})}export{U as _,tn as a,je as b,an as c,Z as d,X as f,Fe as g,Jt as h,un as i,on as l,qt as m,kn as n,sn as o,Zt as p,wn as r,nn as s,En as t,en as u,Pe as v,Ne as y};
|
|
20
|
+
//# sourceMappingURL=src-Bj-Lujyc.mjs.map
|