@inkeep/open-knowledge 0.79.2 → 0.79.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +70 -68
- package/dist/constants-wVFbQ-W8.mjs +1 -0
- package/dist/{dist-Cmgb0r3p.mjs → dist-Bt-cb2ik.mjs} +472 -472
- package/dist/dist-CZBCHPnO.mjs +1 -0
- package/dist/index.mjs +188 -188
- package/dist/init-CqGfdMuB.mjs +1 -0
- package/dist/{init-CjbAcLHr.mjs → init-H4L4PCDm.mjs} +14 -14
- package/dist/{launch-json-removal-1V6_UV5_.mjs → launch-json-removal-DAf1fKWA.mjs} +1 -1
- package/dist/loader-BK3wGq2e.mjs +1 -0
- package/dist/{loader-Cmpu_239.mjs → loader-gbJWrT9X.mjs} +1 -1
- package/dist/native/native-config.win32-arm64-msvc.node +0 -0
- package/dist/native/native-config.win32-x64-msvc.node +0 -0
- package/dist/{open-browser-CNVUL-A_.mjs → open-browser-Co1psphf.mjs} +1 -1
- package/dist/{preview-CUsQsBjV.mjs → preview-CMgnC4UA.mjs} +1 -1
- package/dist/preview-DPQ4BPLK.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-CwiUBgGI.js → ActivityModeContent--2lvtA3c.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-B5wgFBcs.js → AddPropertiesButton-C-iLRZ1e.js} +2 -2
- package/dist/public/assets/{AgentDiffPane-DCr3QWvF.js → AgentDiffPane-D6x5wd4h.js} +1 -1
- package/dist/public/assets/{BugReportHistory-BQMbH-qH.js → BugReportHistory-DSKcw3JQ.js} +1 -1
- package/dist/public/assets/{BugReportHistoryDialog-BRdfOcWv.js → BugReportHistoryDialog-N-Ap1hJt.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-CjC1gT00.js → CodeMirrorPropInput-C6PE1vK2.js} +1 -1
- package/dist/public/assets/{ConsentDialogBody-DWjU5hm4.js → ConsentDialogBody-NBiDlYMd.js} +1 -1
- package/dist/public/assets/{DeleteConfirmationDialog-CJJ8Xo5u.js → DeleteConfirmationDialog-DYyGQK4Z.js} +1 -1
- package/dist/public/assets/{DiffViewBoundary-BGdnGPRv.js → DiffViewBoundary-_HbzD0gR.js} +1 -1
- package/dist/public/assets/{DocumentContext-Dlldf3A6.js → DocumentContext-DjP4XRJx.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-CUFvhR2v.js → EditorModeToggle-BOmmVDPD.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-DfwumFEb.js → EnableSyncConfirmDialog-C6j7G_kd.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-CylNX2Db.js → ExcalidrawDocEditor-CAYMSmAF.js} +1 -1
- package/dist/public/assets/FeedbackForm-t3IG2SJR.js +1 -0
- package/dist/public/assets/{GraphPanel-BQaGu4a5.js → GraphPanel-BMOYeFVW.js} +1 -1
- package/dist/public/assets/{ImageAttachments-mkcDupGd.js → ImageAttachments-CIgN2ICo.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-DSya0fK3.js → ImportSkillDialog-BXsrd5h-.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-BsTgh8nL.js → LintConfigEditor-D5DY2Ucg.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-BnJzcs6f.js +1 -0
- package/dist/public/assets/ManagedArtifactProperties-sumfs_C-.js +1 -0
- package/dist/public/assets/{McpConsentDialogBody-BGioo7-j.js → McpConsentDialogBody-Dj5qWFur.js} +1 -1
- package/dist/public/assets/{Mermaid-DP2in8wt.js → Mermaid-BG4D_HOk.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-634q13Qg.js → MermaidDocEditor-CWmiEhhJ.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-B_AEbfI7.js → PropertyDisplayRow-CrxEj3M3.js} +2 -2
- package/dist/public/assets/{ReportBugDialogBody-ABNMdMUU.js → ReportBugDialogBody-C-53A-0F.js} +1 -1
- package/dist/public/assets/{ReportBugMenuTrigger-DRki3qOn.js → ReportBugMenuTrigger-29birQ-y.js} +1 -1
- package/dist/public/assets/{RowDisclosure-B78fx5s2.js → RowDisclosure-roWTy1cj.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-D6Ve-pbq.js → SchemaConfigEditor-DbbukpG5.js} +1 -1
- package/dist/public/assets/{SessionsHost-BqU3aWOR.js → SessionsHost-CKvXoA48.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-UKT3bDul.js → SettingsDialogBody-PbyK1LoL.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-DE7uyxww.js → ShareBranchSwitchDialog-KJzH1_kA.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-D8d3_-15.js → ShareReceiveDialog-CLkMfCLe.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-Bx29cMNb.js → ShareReceiveMissDialog-CLVrxv3V.js} +1 -1
- package/dist/public/assets/{SkillForkDialog-ho4FUABV.js → SkillForkDialog-Cg2OBoX4.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-DpmMcdPv.js → SkillInstallMenu-DBCnHXH-.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-DmEjQplu.js → SkillOriginInline-kzOBcIFc.js} +2 -2
- package/dist/public/assets/{SkillToolbarControls-miZURo1o.js → SkillToolbarControls-DltyfwOH.js} +1 -1
- package/dist/public/assets/{SkillUpdateConflictDialog-BTP9zIit.js → SkillUpdateConflictDialog-kz67-4EX.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-CUfeiKej.js → SlidesToolbarControls-CAxEUrS2.js} +1 -1
- package/dist/public/assets/{SourceEditor-DCGr3Oun.js → SourceEditor-DLEw1wic.js} +1 -1
- package/dist/public/assets/{TerminalPanel-DDye0ppp.js → TerminalPanel-Cb8KkKGX.js} +1 -1
- package/dist/public/assets/{TerminalStartingNotice-CANxPK71.js → TerminalStartingNotice-BbwsOE78.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-QDFQJvJI.js → TerminalWindowApp-BXIexfq8.js} +1 -1
- package/dist/public/assets/{TextDocEditor-Dy2g4z9H.js → TextDocEditor-DeqaHCag.js} +1 -1
- package/dist/public/assets/{ThreadView-e6Emlmew.js → ThreadView-D1YayNv3.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-9-8JYbua.js → TimelineDiffPane-BCk40u8c.js} +1 -1
- package/dist/public/assets/{agent-connection-status-BTfitB3U.js → agent-connection-status-BKDHFOP-.js} +1 -1
- package/dist/public/assets/{alert-Cp5DpEia.js → alert-Bqwsa0Kr.js} +1 -1
- package/dist/public/assets/{alert-dialog-BJIyfEVh.js → alert-dialog-CqqfqWNT.js} +1 -1
- package/dist/public/assets/{auth-state-cache-CIg70qGh.js → auth-state-cache-COORa9sc.js} +1 -1
- package/dist/public/assets/{badge-MuddhvBr.js → badge-lmgHBfMn.js} +1 -1
- package/dist/public/assets/button-BeFNZANd.js +1 -0
- package/dist/public/assets/{calendar-DLVK4LG7.js → calendar-BR8UVbAy.js} +1 -1
- package/dist/public/assets/{client-version-DA4kJKPj.js → client-version-yBzdRoMs.js} +1 -1
- package/dist/public/assets/{comment-chips-Cnc9lZ6c.js → comment-chips-BGRnR7X7.js} +1 -1
- package/dist/public/assets/{config-provider-owr5M3NH.js → config-provider-CTHdqAYx.js} +1 -1
- package/dist/public/assets/{dialog-Q2r_wm4I.js → dialog-BfHNtxM9.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-CaLoly49.js → doc-undo-manager-DxMjEKx4.js} +1 -1
- package/dist/public/assets/{field-Cy222HIR.js → field-BLH6hVAa.js} +1 -1
- package/dist/public/assets/globals-Dg-24adS.css +1 -0
- package/dist/public/assets/index-CWenCiFy.js +2205 -0
- package/dist/public/assets/{input-group-D4IQIBdt.js → input-group-Brp49uT-.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-DYxq-YWd.js → markdownlint-rule-browser-D5yxtwtH.js} +1 -1
- package/dist/public/assets/messages-5nYhcGbk.js +1 -0
- package/dist/public/assets/messages-8wkpGWDl.js +1 -0
- package/dist/public/assets/messages-BE3F6wPf.js +1 -0
- package/dist/public/assets/messages-BYW3-b5z.js +1 -0
- package/dist/public/assets/messages-CE30qzpn.js +1 -0
- package/dist/public/assets/messages-CKBxrXnZ.js +1 -0
- package/dist/public/assets/messages-C_LttG3X.js +1 -0
- package/dist/public/assets/messages-Cd3H31Oo.js +1 -0
- package/dist/public/assets/messages-D-bBxZfD.js +1 -0
- package/dist/public/assets/messages-DLuudO75.js +1 -0
- package/dist/public/assets/messages-DoYSqXZ-.js +1 -0
- package/dist/public/assets/messages-nwFoZCFs.js +1 -0
- package/dist/public/assets/{pending-receive-nav-store-ru8vEtq1.js → pending-receive-nav-store-CQL0bv5o.js} +1 -1
- package/dist/public/assets/{preferred-session-events-Dhjm0Z1H.js → preferred-session-events-BEpzXSN8.js} +1 -1
- package/dist/public/assets/{progress-ChqYJ_wo.js → progress-C8ijsHox.js} +1 -1
- package/dist/public/assets/{project-paths-CDhA3hJy.js → project-paths-B-FMrj5U.js} +1 -1
- package/dist/public/assets/{selection-context-4lSNiVN-.js → selection-context-LrE0_TTe.js} +1 -1
- package/dist/public/assets/{src-C5n8TKJq.js → src-BxNPgEkh.js} +1 -1
- package/dist/public/assets/{tabs-BnFGmv6I.js → tabs-C7_T-n4e.js} +1 -1
- package/dist/public/assets/{tag-pill-input-BQX-_Adc.js → tag-pill-input-B28iAFxa.js} +1 -1
- package/dist/public/assets/{telemetry-impl-BjW04TM-.js → telemetry-impl-CDsHOhvm.js} +1 -1
- package/dist/public/assets/{telemetry-startup-BS9CaXrj.js → telemetry-startup-D-KW_NaP.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-Dmdb2rMF.js → terminal-launch-events-E89-i5D1.js} +1 -1
- package/dist/public/assets/{toggle-group-ZKcYQ5bn.js → toggle-group-BxIyZnUJ.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BEdXQddD.js → typing-burst-detector-BI7H8DPb.js} +2 -2
- package/dist/public/assets/{uninstall-DXJMPkVq.js → uninstall-C5hq5xn8.js} +1 -1
- package/dist/public/assets/{use-activity-panel-CngLVlKx.js → use-activity-panel-D1MJ-kqr.js} +1 -1
- package/dist/public/assets/{use-apply-config-language-DgBG2Y3l.js → use-apply-config-language-DBt73Gpy.js} +2 -2
- package/dist/public/assets/{use-installed-clis-SziirqY4.js → use-installed-clis-F-bc0S3Y.js} +2 -2
- package/dist/public/assets/{use-open-skill-B-WzAe13.js → use-open-skill-BBxnHzMv.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-Dd55GJPP.js → use-terminal-enabled-BePo4VDS.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-D9Fyk7np.js → use-timeline-entry-diff-Cpz7ybaB.js} +1 -1
- package/dist/public/index.html +39 -39
- package/dist/public/uninstall.html +7 -7
- package/dist/registry-probes-DCe3rWZ7.mjs +17 -0
- package/dist/{removal-file-path-4H4PUJxJ.mjs → removal-file-path-DiyOqKix.mjs} +1 -1
- package/dist/{repair-launch-json-DAIGiTv8.mjs → repair-launch-json-CK7gSieg.mjs} +1 -1
- package/dist/{repair-mcp-configs-CO4UASHL.mjs → repair-mcp-configs-B2IwckuL.mjs} +1 -1
- package/dist/{src-CcEkY68s.mjs → src-7sNhM-_B.mjs} +5 -5
- package/dist/src-DZ44CKon.mjs +1 -0
- package/dist/{start-BuIYuZ-E.mjs → start-DYrDwaUD.mjs} +3 -3
- package/dist/start-DaOK3zKh.mjs +1 -0
- package/package.json +4 -4
- package/dist/constants-jpNm5-5s.mjs +0 -1
- package/dist/dist-DzdGKL8W.mjs +0 -1
- package/dist/init-BGM70oJ3.mjs +0 -1
- package/dist/loader-BVs3fR6_.mjs +0 -1
- package/dist/preview-DejneDxR.mjs +0 -1
- package/dist/public/assets/FeedbackForm-B2kRhtsR.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-CVIYFnTZ.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-DCWlX1Qg.js +0 -1
- package/dist/public/assets/button-HKX9wT1K.js +0 -1
- package/dist/public/assets/globals-uZ5VipkR.css +0 -1
- package/dist/public/assets/index-B4DpftwC.js +0 -2205
- package/dist/public/assets/messages-8is2no75.js +0 -1
- package/dist/public/assets/messages-BAuq9QNn.js +0 -1
- package/dist/public/assets/messages-BMB7_c7y.js +0 -1
- package/dist/public/assets/messages-C2mWhO6K.js +0 -1
- package/dist/public/assets/messages-CRnQAmA5.js +0 -1
- package/dist/public/assets/messages-CpKrli-X.js +0 -1
- package/dist/public/assets/messages-CuQCs__I.js +0 -1
- package/dist/public/assets/messages-DUAWetuM.js +0 -1
- package/dist/public/assets/messages-EThDD2lc.js +0 -1
- package/dist/public/assets/messages-JIbrz5bw.js +0 -1
- package/dist/public/assets/messages-eVBmDYMt.js +0 -1
- package/dist/public/assets/messages-tmp_OA3I.js +0 -1
- package/dist/registry-probes-ftrzXHET.mjs +0 -17
- package/dist/src--m06lQMP.mjs +0 -1
- package/dist/start-DqUv0wIj.mjs +0 -1
- /package/dist/public/assets/{globals-DS9_Iy6h.js → globals-BXFJsup3.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as t,As as n,Ec as r,Fn as i,Pn as a,Qc as o,Un as s,Uu as c,Vs as l,ko as u,rf as ee,tl as te,wc as d}from"./md-manager-BGnqyqi1-BWyJhS5F.mjs";import{Bo as f,Ho as p,Ti as m,Tt as h,Vn as g,Vo as _,Yr as v,Zn as y,ci as b,li as x,m as S,mo as C,mr as w,si as T,ti as E,tr as D,ua as O,wi as k}from"./dist-Cmgb0r3p.mjs";import{t as A}from"./yazl-BBz29IQN.mjs";import{Ct as j,ot as M,st as N}from"./init-CjbAcLHr.mjs";import{b as ne,l as re}from"./registry-probes-ftrzXHET.mjs";import{c as P}from"./colors-r_owlCuY.mjs";import{t as F}from"./is-object-BGze3w87.mjs";import{n as ie}from"./constants-jpNm5-5s.mjs";import"./loader-Cmpu_239.mjs";import"./preview-CUsQsBjV.mjs";import{execSync as ae,spawnSync as oe}from"node:child_process";import{basename as I,dirname as L,isAbsolute as se,join as R,relative as z,resolve as B,sep as V}from"node:path";import{closeSync as ce,cpSync as le,createWriteStream as ue,existsSync as H,lstatSync as de,mkdirSync as U,mkdtempSync as fe,openSync as pe,readFileSync as W,readSync as me,readdirSync as G,rmSync as K,rmdirSync as he,statSync as ge,writeFileSync as q}from"node:fs";import{arch as _e,freemem as ve,homedir as J,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";const De=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Oe(e,t,n=D){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()}const Me=`Open Knowledge`;function Ne(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return M(t).join(N({...e,platformName:t}),n)}function Pe(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=M(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`@inkeepopen-knowledge-desktop-updater`)}function Fe(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function Ie(e){let t=R(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Fe(n)??[]}function Le(e){let t=R(e,`state.json`);if(!H(t))return!1;try{return Fe(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Re=8192;function ze(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function Be(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Ve=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function He(e){return e.replace(Ve,`$1"[REDACTED-DEVICE-ID]"`)}function Ue(e){return He(Be(e))}const We=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Ge(e){if(typeof e!=`string`)return null;let t=We.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function Ke(e){let t=pe(e,`r`);try{let e=Buffer.alloc(Re),n=0,r=!1;for(;n<Re;){let i=me(t,e,n,Re-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{ce(t)}}function qe(e){try{let t=Ke(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:Ge(a)}}catch{return{kind:`unreadable`}}}function Je(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Ye(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=R(e,t.name),r;try{r=ge(n).mtimeMs}catch{continue}if(r<i)continue;let c=qe(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Je(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}function Y(){return R(J(),`.ok`,`bug-reports`)}function Xe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Y(),r=`${t}-bugreport`,i=R(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=R(n,`${r}-${e}.zip`);return i}function Ze(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function Qe(e,t){let n=R(e,`.ok`,`config.yml`);if(H(n))try{let e=W(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 H(R(e,`.ok`))?Ee(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function $e(){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=ae(`sw_vers -productVersion 2>/dev/null`,C({encoding:`utf8`})).trim()}catch{}try{let t=R(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const et=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function tt(e){let t=I(e);return et.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function nt(e,t){return ot(e,t).files}const rt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function it(e,t=re){let n=R(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return rt.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>R(n,e.entry)))}function at(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-a.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>R(e,t))}catch{return[]}}function ot(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>R(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(tt),i=[],a=r.filter(t=>{try{return W(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=>!tt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function st(e){let t=R(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,`last-spawn-error.log`,o,d].map(e=>R(t,e)).filter(e=>H(e))}:{files:[]}}function ct(e){let t=R(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>R(t,e)).filter(e=>H(e))}:{files:[]}}function lt(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Ee(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function ut(e){let t=e.revealDocNames?e.content:lt(e.content).text;if(e.redact){let{redacted:r,patterns:i,lineCount:a}=n(t);e.zipfile.addBuffer(Buffer.from(r,`utf8`),e.name),e.bundleFiles.push(e.name),i.length>0&&e.redactions.push({file:e.name,lineCount:a,patterns:i})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function X(e){for(let t of e.files)try{let n=W(t,`utf8`);ut({zipfile:e.zipfile,name:`${e.prefix}/${I(t)}`,content:t.endsWith(`.ips`)?Ue(n):n,redact:e.redact,revealDocNames:e.revealDocNames,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 dt(t){let{redact:n,outputPath:r,logger:a}=t,o=t.revealDocNames??!1,c=t.userLogsDir??R(J(),`.ok`,`logs`),l=t.projectDir?Qe(t.projectDir,a):null;U(L(r),{recursive:!0}),a?.info({projectSlug:l},`gathering diagnostic data`);let u=$e();u.desktop=t.desktop??null,u.language=t.language??null;let{files:ee,excludedByProjectSlug:te}=ot(l,c),{files:d}=t.projectDir?st(t.projectDir):{files:[]},{files:f}=t.projectDir?ct(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];a?.info({logFileCount:ee.length,logFilesExcludedByProjectSlug:te,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new _;X({zipfile:v,files:[...ee,...p],prefix:`logs`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:d,prefix:`lockdir`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:f,prefix:`local-logs`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:i,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??I(e.sourcePath)}`;v.addBuffer(t,n),g.push(n);let r=Ze(e,n);r!==null&&h.push(r)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&ut({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:o,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${I(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:ze(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`);let S=JSON.stringify(u,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:l,files:g,redactions:h,sysinfo:u};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${I(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${i}/${I(e)}`)),O=g.filter(e=>D.has(e)),k=l?g.filter(e=>e.startsWith(`logs/`)&&!tt(e)&&!T.has(e)):[],A=b.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],j=A.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...A]:[`Redaction was disabled for this bundle; file contents are unmodified.`],M=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${l??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...k.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:`,...k.map(e=>`- ${e}`),``]:[],...E.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:`,...E.map(e=>`- ${e}`),``]:[],...b.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...b.map(e=>`- ${e}`),``]:[],...O.length>0?[`Send history: a small record for each 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:`,...O.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${s.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...A,``,`This bundle is safe to attach to a GitHub issue.`]:j].join(`
|
|
2
|
-
`);v.addBuffer(Buffer.from(M,`utf8`),`README.md`),v.end();let N=ue(r);return v.outputStream.pipe(N),await new Promise((e,t)=>{N.on(`close`,e),N.on(`error`,t)}),a?.info({bundlePath:r,fileCount:g.length,redactionCount:w},`bundle written`),{zipPath:r,summary:{projectSlug:l,files:g,redactions:h,redactedLineCount:w,generatedAt:C.generatedAt}}}var ft=c(),pt=e(A(),1),Z=e(P(),1);function mt(e){let t=
|
|
1
|
+
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as t,As as n,Ec as r,Fn as i,Pn as a,Qc as o,Un as s,Uu as c,Vs as l,ko as u,rf as ee,tl as te,wc as d}from"./md-manager-BGnqyqi1-BWyJhS5F.mjs";import{Ho as f,Ti as p,Tt as m,Uo as h,Vn as g,Vo as _,Yr as v,Zn as y,ci as b,li as x,m as S,mo as C,mr as w,si as T,ti as E,tr as D,ua as O,wi as k}from"./dist-Bt-cb2ik.mjs";import{t as A}from"./yazl-BBz29IQN.mjs";import{Ct as j,ot as M,st as N}from"./init-H4L4PCDm.mjs";import{b as ne,l as re}from"./registry-probes-DCe3rWZ7.mjs";import{c as P}from"./colors-r_owlCuY.mjs";import{t as F}from"./is-object-BGze3w87.mjs";import{n as ie}from"./constants-wVFbQ-W8.mjs";import"./loader-gbJWrT9X.mjs";import"./preview-CMgnC4UA.mjs";import{execSync as ae,spawnSync as oe}from"node:child_process";import{basename as I,dirname as L,isAbsolute as se,join as R,relative as z,resolve as B,sep as V}from"node:path";import{closeSync as ce,cpSync as le,createWriteStream as ue,existsSync as H,lstatSync as de,mkdirSync as U,mkdtempSync as fe,openSync as pe,readFileSync as W,readSync as me,readdirSync as G,rmSync as K,rmdirSync as he,statSync as ge,writeFileSync as q}from"node:fs";import{arch as _e,freemem as ve,homedir as J,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";const De=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Oe(e,t,n=D){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()}const Me=`Open Knowledge`;function Ne(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return M(t).join(N({...e,platformName:t}),n)}function Pe(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=M(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`@inkeepopen-knowledge-desktop-updater`)}function Fe(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function Ie(e){let t=R(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Fe(n)??[]}function Le(e){let t=R(e,`state.json`);if(!H(t))return!1;try{return Fe(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Re=8192;function ze(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function Be(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Ve=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function He(e){return e.replace(Ve,`$1"[REDACTED-DEVICE-ID]"`)}function Ue(e){return He(Be(e))}const We=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Ge(e){if(typeof e!=`string`)return null;let t=We.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function Ke(e){let t=pe(e,`r`);try{let e=Buffer.alloc(Re),n=0,r=!1;for(;n<Re;){let i=me(t,e,n,Re-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{ce(t)}}function qe(e){try{let t=Ke(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:Ge(a)}}catch{return{kind:`unreadable`}}}function Je(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Ye(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=R(e,t.name),r;try{r=ge(n).mtimeMs}catch{continue}if(r<i)continue;let c=qe(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Je(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}function Y(){return R(J(),`.ok`,`bug-reports`)}function Xe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Y(),r=`${t}-bugreport`,i=R(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=R(n,`${r}-${e}.zip`);return i}function Ze(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function Qe(e,t){let n=R(e,`.ok`,`config.yml`);if(H(n))try{let e=W(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 H(R(e,`.ok`))?Ee(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function $e(){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=ae(`sw_vers -productVersion 2>/dev/null`,C({encoding:`utf8`})).trim()}catch{}try{let t=R(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const et=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function tt(e){let t=I(e);return et.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function nt(e,t){return ot(e,t).files}const rt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function it(e,t=re){let n=R(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return rt.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>R(n,e.entry)))}function at(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-a.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>R(e,t))}catch{return[]}}function ot(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>R(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(tt),i=[],a=r.filter(t=>{try{return W(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=>!tt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function st(e){let t=R(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,`last-spawn-error.log`,o,d].map(e=>R(t,e)).filter(e=>H(e))}:{files:[]}}function ct(e){let t=R(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>R(t,e)).filter(e=>H(e))}:{files:[]}}function lt(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Ee(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function ut(e){let t=e.revealDocNames?e.content:lt(e.content).text;if(e.redact){let{redacted:r,patterns:i,lineCount:a}=n(t);e.zipfile.addBuffer(Buffer.from(r,`utf8`),e.name),e.bundleFiles.push(e.name),i.length>0&&e.redactions.push({file:e.name,lineCount:a,patterns:i})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function X(e){for(let t of e.files)try{let n=W(t,`utf8`);ut({zipfile:e.zipfile,name:`${e.prefix}/${I(t)}`,content:t.endsWith(`.ips`)?Ue(n):n,redact:e.redact,revealDocNames:e.revealDocNames,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 dt(t){let{redact:n,outputPath:r,logger:a}=t,o=t.revealDocNames??!1,c=t.userLogsDir??R(J(),`.ok`,`logs`),l=t.projectDir?Qe(t.projectDir,a):null;U(L(r),{recursive:!0}),a?.info({projectSlug:l},`gathering diagnostic data`);let u=$e();u.desktop=t.desktop??null,u.language=t.language??null;let{files:ee,excludedByProjectSlug:te}=ot(l,c),{files:d}=t.projectDir?st(t.projectDir):{files:[]},{files:f}=t.projectDir?ct(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];a?.info({logFileCount:ee.length,logFilesExcludedByProjectSlug:te,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new _;X({zipfile:v,files:[...ee,...p],prefix:`logs`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:d,prefix:`lockdir`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:f,prefix:`local-logs`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:i,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a}),X({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:o,bundleFiles:g,redactions:h,logger:a});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??I(e.sourcePath)}`;v.addBuffer(t,n),g.push(n);let r=Ze(e,n);r!==null&&h.push(r)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&ut({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:o,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${I(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:ze(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`);let S=JSON.stringify(u,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:l,files:g,redactions:h,sysinfo:u};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${I(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${i}/${I(e)}`)),O=g.filter(e=>D.has(e)),k=l?g.filter(e=>e.startsWith(`logs/`)&&!tt(e)&&!T.has(e)):[],A=b.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],j=A.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...A]:[`Redaction was disabled for this bundle; file contents are unmodified.`],M=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${l??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...k.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:`,...k.map(e=>`- ${e}`),``]:[],...E.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:`,...E.map(e=>`- ${e}`),``]:[],...b.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...b.map(e=>`- ${e}`),``]:[],...O.length>0?[`Send history: a small record for each 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:`,...O.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${s.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...A,``,`This bundle is safe to attach to a GitHub issue.`]:j].join(`
|
|
2
|
+
`);v.addBuffer(Buffer.from(M,`utf8`),`README.md`),v.end();let N=ue(r);return v.outputStream.pipe(N),await new Promise((e,t)=>{N.on(`close`,e),N.on(`error`,t)}),a?.info({bundlePath:r,fileCount:g.length,redactionCount:w},`bundle written`),{zipPath:r,summary:{projectSlug:l,files:g,redactions:h,redactedLineCount:w,generatedAt:C.generatedAt}}}var ft=c(),pt=e(A(),1),Z=e(P(),1);function mt(e){let t=h(`user`,e,e);return _({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function ht({home:e=J(),env:t=process.env}={}){let n=mt(e),{override:i,preferenceList:a}=f(t),{locale:o,source:s}=l({override:i,storedPreference:n,supportedLocales:te,preferenceList:a,autoDetectableLocales:r});return{preference:n,locale:o,source:s,systemLanguages:a}}function gt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function _t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vt(e,t){if(typeof e==`string`)return gt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>vt(e,t));if(!_t(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=vt(i,t);return n}function yt(e,t){let n=W(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=vt(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
5
5
|
`)}\n`:a.join(`
|
|
6
6
|
`);q(e,o)}function bt(e,t){let n=W(e,`utf-8`);if(n.trim().length!==0)try{let r=vt(JSON.parse(n),t),i=n.endsWith(`
|
|
7
7
|
`)?`
|
|
8
8
|
`:``;q(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=gt(n,t.contentDir);r!==n&&q(e,r)}}function xt(e,t){let n=W(e,`utf-8`),r=gt(n,t.contentDir);r!==n&&q(e,r)}function St(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>R(e,t.name))}catch{return[]}}const Ct=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function wt(e){return/\.log\.\d+$/.test(e)}function Tt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||wt(e)}const Et=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Dt(e){let t={contentDir:e.contentDir};for(let n of Et)for(let r of St(R(e.stagingDir,n)))Tt(r)?yt(r,t):r.endsWith(`.json`)?bt(r,t):xt(r,t);for(let n of St(R(e.stagingDir,`state`))){let e=I(n);n.endsWith(`.jsonl`)?yt(n,t):Ct.has(e)?bt(n,t):xt(n,t)}}const Ot=[`.ok`,`local`,`telemetry`],kt=[`.ok`,`local`,`logs`],At=[`.ok`,`local`,`loss-capture`],jt=`spans-current.jsonl`,Mt=`spans-prev.jsonl`,Nt=`server-current.jsonl`,Pt=`server-prev.jsonl`,Ft=`loss-current.jsonl`,It=`loss-prev.jsonl`;function Lt(e){return R(e,...Ot,jt)}function Rt(e){return R(e,...Ot,Mt)}function zt(e){return R(e,...kt,Nt)}function Bt(e){return R(e,...kt,Pt)}function Vt(e){return R(e,...At,Ft)}function Ht(e){return R(e,...At,It)}const Ut=1e3;async function Wt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Ut)});return t.ok?await t.text():null}catch{return null}}async function Gt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Ut)});return t.ok?await t.text():null}catch{return null}}async function Kt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Ut)});return t.ok?await t.text():null}catch{return null}}function qt(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 Jt(e){let t=R(e,`.git`,`ok`);if(!H(t))return null;let n=oe(`git`,[`-C`,t,`log`,`--oneline`,`-50`],C({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Yt(e){let t=R(e,`.git`,`ok`);if(!H(t))return null;let n=oe(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],C({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Xt(){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 Zt(){return{nodeVersion:process.version,platform:be(),arch:_e()}}function Qt(){return process.env.OTEL_SDK_DISABLED===`false`}function $t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function en(e){if(!H(e))return{};let t;try{t=(0,ft.parse)(W(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(!$t(t))return{};let n=t.telemetry;if(!$t(n))return{};let r=n.localSink;return $t(r)?r:{}}function tn(e){return typeof e==`boolean`?e:void 0}function nn(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function rn(e){if($t(e))return nn(e.maxBytes)}function an(e){let t=en(
|
|
10
|
-
`:`not-running (${S})\n`;q(R(_,`state`,`server-status.txt`),A);let j=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:ze(e.diagnosticReports,v);if(q(R(_,`state`,`diagnostic-reports-status.txt`),`${j}\n`),e.processDir&&H(e.processDir)){let t=R(_,`process`);U(t,{recursive:!0}),le(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&Dt({stagingDir:_,contentDir:n}),e.note&&q(R(_,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=hn(_));for(let t of e.extraFiles??[]){let e=t.zipName??I(t.sourcePath);if(!Q(t.sourcePath,R(_,`extra`,e))){a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=Ze(t,`extra/${e}`);n!==null&&(N??={redactions:[],redactedLineCount:0},N.redactions.push(n),N.redactedLineCount+=n.lineCount)}let ne=an(r),re=un(_),P=[],F=0,ie=0;for(let e of re){let t=gn(_,e),n=ge(e).size,r=fn(t)?sn(e):0;P.push({path:t,bytes:n,lines:r}),F+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(ie+=ln(e))}let ae={applied:M};N!==null&&(ae.secretScrub=N);let oe={schemaVersion:2,createdAt:te().toISOString(),ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:on(n),absolutePath:M?`<CONTENT_DIR>`:n},telemetry:{localSink:ne,otlpPushEnabled:g()},redaction:ae,serverStatus:x,files:P};q(R(_,`manifest.json`),`${JSON.stringify(oe,null,2)}\n`);let L=re.some(e=>{try{return W(e,`utf-8`).includes(n)}catch{return!1}}),se={stagedDiagnosticReports:v,totalBytes:F,fileCount:P.length,docNameCount:ie,contentDirVisible:L,redacted:M},z=!1;return{stagingDir:_,manifest:oe,summary:se,cleanup:()=>{z||(z=!0,K(_,{recursive:!0,force:!0}))}}}catch(e){throw K(_,{recursive:!0,force:!0}),e}}async function vn(e){let{collected:t,outputPath:n}=e,r=L(n);if(!H(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new pt.ZipFile,a=un(t.stagingDir);for(let e of a){let n=gn(t.stagingDir,e);i.addFile(e,n)}i.end();let o=ue(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 yn(e,t){let n=R(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,ft.parse)(W(n,`utf-8`)),r=F(t)?t.content:void 0,i=F(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return B(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 B(e)}async function bn(e,t,n,r,i){let a=Qe(t,e.logger),o=await _n({contentDir:yn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...nt(a,e.userLogsDir??R(J(),`.ok`,`logs`)),...it(e.cachesDir??R(J(),`Library`,`Caches`))],userStateFiles:at(e.bugReportsDir??Y()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(L(e.outputPath),{recursive:!0}),await vn({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function xn(e){let{projectDir:t}=e,n=e.readDesktopEnv??Xt,r=e.readLanguage??ht,i=()=>Ye(e.diagnosticReportsDir??R(J(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return bn(e,t,n,r,i());let{zipPath:a,summary:o}=await dt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:it(e.cachesDir??R(J(),`Library`,`Caches`)),bugReportLedgerFiles:at(e.bugReportsDir??Y()),diagnosticReports:e.level===`full`?i():void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=x(e,t),i;try{i=W(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??w()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??ye());if(!a||typeof a!=`object`||!E(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??v)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function Sn(e){return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${e.lockPath} does not record its owning machine, and its recorded process ${e.pid} is still running on this machine. Check whether process ${e.pid} is an OpenKnowledge server. If it is, stop it and retry. Do not remove the lock file while that process is running.`:`Cannot verify shutdown: the server lock at ${e.lockPath} belongs to another machine. Stop OpenKnowledge on the owning machine. Confirm that no OpenKnowledge server is using this directory on the owning machine or any other machine sharing it. Only then remove the stale lock file at ${e.lockPath} and retry cleanup.`}function Cn(e){return e.replace(/:\d+$/,``)}function wn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Cn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Cn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Cn(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=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],En=[...h.map(e=>S[e]),`open-knowledge`];function Dn(e){if(!se(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||L(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function On(e,t){let n=z(e,t);if(n.startsWith(`..`)||se(n))return!1;let r=e;for(let e of n.split(V)){r=R(r,e);try{if(!de(r).isDirectory())return!1}catch{return!1}}return!0}function kn(e,t){try{return G(e).every(n=>t.has(R(e,n)))}catch{return!1}}function An(e){let t=Dn(e),n=[],r=[],i=new Set;for(let e of Tn){let a=R(t,e.hostDir,`skills`);if(!On(t,a))continue;let o=En.map(e=>R(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=R(t,e.pruneRoot),c=a;for(;kn(c,i)&&(r.push(c),i.add(c),c!==s);){let e=L(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function jn(e){try{if(!de(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Mn(e){let t=new Set,n=new Set;for(let r of Tn){let i=R(e,r.hostDir,`skills`);for(let e of En)t.add(R(i,e));let a=R(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=L(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Nn(e,t){let n=Dn(e),r=Mn(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(On(n,e)&&jn(e))try{K(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(On(n,e))try{he(e),a.push(e)}catch{}return a}function Pn(e){let t=Dn(e),n=[];for(let e of h){let r=S[e];n.push({path:R(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of ee)n.push({path:R(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Fn(e,t){let n=[];for(let r of Pn(e))if(r.bundleId===t)try{K(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function In(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Ln(e,t=Date.now()){if(e===null)return`—`;let n=u(e,t);return n===`unknown`?`—`:n}function Rn(e){let t=L(e);return I(e)===`local`&&I(t)===`.ok`?L(t):I(e)===`.ok`?t:null}function zn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:Rn(e),server:{port:null,status:t.status,pid:t.pid,startedAt:null,usage:null},ui:null,hostname:null,lockPath:t.lockPath,binary:null,command:null,isDesktop:!1};let i=t.lock,a=t.status===`alive`&&T(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:y(n),command:n,isDesktop:In(n)}}function Bn(e){let t=e.server.status;switch(t){case`unverified-owner`:return`unverified`;case`alive`:return e.isDesktop?`desktop`:`running`;case`foreign-host`:return e.isDesktop?`desktop`:`foreign`;case`dead-pid`:return`stale`;default:return t}}const Vn=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Hn(e){switch(e){case`running`:return Z.default.green(e);case`desktop`:return Z.default.blue(e);case`foreign`:return Z.default.cyan(e);case`unverified`:case`stale`:return Z.default.yellow(e)}}function Un(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Wn(e){return`${Un(e.server.usage)} | ${Un(e.ui?.usage??null)}`}function Gn(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Kn(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??`—`,Gn(e),Wn(e),Bn(e),String(e.server.pid),Ln(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=Hn(Bn(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=Z.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
11
|
-
`)}async function qn(e={}){let t=e.discover??g,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??k,a=e.resolveUsage??
|
|
9
|
+
`)}\n`:null}catch{return null}}function Jt(e){let t=R(e,`.git`,`ok`);if(!H(t))return null;let n=oe(`git`,[`-C`,t,`log`,`--oneline`,`-50`],C({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Yt(e){let t=R(e,`.git`,`ok`);if(!H(t))return null;let n=oe(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],C({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Xt(){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 Zt(){return{nodeVersion:process.version,platform:be(),arch:_e()}}function Qt(){return process.env.OTEL_SDK_DISABLED===`false`}function $t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function en(e){if(!H(e))return{};let t;try{t=(0,ft.parse)(W(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(!$t(t))return{};let n=t.telemetry;if(!$t(n))return{};let r=n.localSink;return $t(r)?r:{}}function tn(e){return typeof e==`boolean`?e:void 0}function nn(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function rn(e){if($t(e))return nn(e.maxBytes)}function an(e){let t=en(h(`project`,e)),n=en(h(`project-local`,e));return{enabled:tn(n.enabled)??tn(t.enabled)??!0,spansMaxBytes:rn(n.spans)??rn(t.spans)??52428800,logsMaxBytes:rn(n.logs)??rn(t.logs)??26214400}}function on(e){return Ee(`sha256`).update(e).digest(`hex`)}function sn(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const cn=[`"doc.name"`,`"docName"`];function ln(e){let t=W(e,`utf-8`),n=0;for(let e of cn){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!H(e))return!1;try{return U(L(t),{recursive:!0}),e.endsWith(`.ips`)?q(t,Ue(W(e,`utf-8`))):le(e,t),!0}catch{return!1}}function un(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=R(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const dn=new Set([`.jsonl`]);function fn(e){let t=e.lastIndexOf(`.`);return t!==-1&&dn.has(e.slice(t))}const pn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function mn(e){if(wt(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&pn.has(e.slice(t))}function hn(e){let t=[];for(let r of un(e)){let i=gn(e,r);if(!mn(i))continue;let{redacted:a,patterns:o,lineCount:s}=n(W(r,`utf-8`));o.length!==0&&(q(r,a),t.push({file:i,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function gn(e,t){return z(e,t).split(V).join(`/`)}async function _n(e){let n=B(e.contentDir),r=B(e.projectDir??e.contentDir),a=e.deps??{},s=a.fetchAgentPresence??Wt,c=a.fetchAgentEffects??Gt,l=a.fetchWatcherRecent??Kt,u=a.readShadowHead??Jt,ee=a.readCheckpointRefs??Yt,te=a.now??(()=>new Date),f=a.okVersion??(()=>ie),p=a.readDesktopEnv??Xt,m=a.readLanguage??ht,h=a.readRuntime??Zt,g=a.isOtlpPushEnabled??Qt,_=fe(R(Se(),`ok-bundle-`));try{U(R(_,`telemetry`),{recursive:!0}),U(R(_,`logs`),{recursive:!0}),U(R(_,`state`),{recursive:!0}),Q(Lt(r),R(_,`telemetry`,jt)),Q(Rt(r),R(_,`telemetry`,Mt)),Q(zt(r),R(_,`logs`,Nt)),Q(Bt(r),R(_,`logs`,Pt));for(let t of e.userLogFiles??[])Q(t,R(_,`logs`,I(t)));for(let t of e.userStateFiles??[])Q(t,R(_,i,I(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Q(t,R(_,`diagnostic-reports`,I(t)))&&(v+=1);let y=R(r,`.ok`,`local`),b=R(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(H(b)){Q(b,R(_,`state`,`server.lock`));try{let e=W(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:S=`lock present but no port`}catch{S=`lock present but unparseable`}}if(C!==null){let e=await s(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(q(R(_,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await c(C);t!==null&&q(R(_,`state`,`agent-effects.json`),t);let n=await l(C);if(n!==null){let e=qt(n);e!==null&&q(R(_,`state`,`watcher-recent.jsonl`),e)}}let w=u(n);w!==null&&q(R(_,`state`,`shadow-head.txt`),w);let T=ee(n);T!==null&&q(R(_,`state`,`checkpoint-refs.txt`),T),Q(Vt(r),R(_,`state`,Ft)),Q(Ht(r),R(_,`state`,It)),Q(R(y,`last-spawn-error.log`),R(_,`state`,`last-spawn-error.log`)),Q(R(y,t),R(_,`state`,t)),Q(R(y,o),R(_,`state`,o)),Q(R(y,d),R(_,`state`,d));let E=h(),D=p(),O=m(),k={ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};q(R(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let A=x===`running`?`running
|
|
10
|
+
`:`not-running (${S})\n`;q(R(_,`state`,`server-status.txt`),A);let j=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:ze(e.diagnosticReports,v);if(q(R(_,`state`,`diagnostic-reports-status.txt`),`${j}\n`),e.processDir&&H(e.processDir)){let t=R(_,`process`);U(t,{recursive:!0}),le(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&Dt({stagingDir:_,contentDir:n}),e.note&&q(R(_,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=hn(_));for(let t of e.extraFiles??[]){let e=t.zipName??I(t.sourcePath);if(!Q(t.sourcePath,R(_,`extra`,e))){a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=Ze(t,`extra/${e}`);n!==null&&(N??={redactions:[],redactedLineCount:0},N.redactions.push(n),N.redactedLineCount+=n.lineCount)}let ne=an(r),re=un(_),P=[],F=0,ie=0;for(let e of re){let t=gn(_,e),n=ge(e).size,r=fn(t)?sn(e):0;P.push({path:t,bytes:n,lines:r}),F+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(ie+=ln(e))}let ae={applied:M};N!==null&&(ae.secretScrub=N);let oe={schemaVersion:2,createdAt:te().toISOString(),ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:on(n),absolutePath:M?`<CONTENT_DIR>`:n},telemetry:{localSink:ne,otlpPushEnabled:g()},redaction:ae,serverStatus:x,files:P};q(R(_,`manifest.json`),`${JSON.stringify(oe,null,2)}\n`);let L=re.some(e=>{try{return W(e,`utf-8`).includes(n)}catch{return!1}}),se={stagedDiagnosticReports:v,totalBytes:F,fileCount:P.length,docNameCount:ie,contentDirVisible:L,redacted:M},z=!1;return{stagingDir:_,manifest:oe,summary:se,cleanup:()=>{z||(z=!0,K(_,{recursive:!0,force:!0}))}}}catch(e){throw K(_,{recursive:!0,force:!0}),e}}async function vn(e){let{collected:t,outputPath:n}=e,r=L(n);if(!H(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new pt.ZipFile,a=un(t.stagingDir);for(let e of a){let n=gn(t.stagingDir,e);i.addFile(e,n)}i.end();let o=ue(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 yn(e,t){let n=R(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,ft.parse)(W(n,`utf-8`)),r=F(t)?t.content:void 0,i=F(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return B(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 B(e)}async function bn(e,t,n,r,i){let a=Qe(t,e.logger),o=await _n({contentDir:yn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...nt(a,e.userLogsDir??R(J(),`.ok`,`logs`)),...it(e.cachesDir??R(J(),`Library`,`Caches`))],userStateFiles:at(e.bugReportsDir??Y()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(L(e.outputPath),{recursive:!0}),await vn({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function xn(e){let{projectDir:t}=e,n=e.readDesktopEnv??Xt,r=e.readLanguage??ht,i=()=>Ye(e.diagnosticReportsDir??R(J(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return bn(e,t,n,r,i());let{zipPath:a,summary:o}=await dt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:it(e.cachesDir??R(J(),`Library`,`Caches`)),bugReportLedgerFiles:at(e.bugReportsDir??Y()),diagnosticReports:e.level===`full`?i():void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=x(e,t),i;try{i=W(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??w()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??ye());if(!a||typeof a!=`object`||!E(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??v)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function Sn(e){return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${e.lockPath} does not record its owning machine, and its recorded process ${e.pid} is still running on this machine. Check whether process ${e.pid} is an OpenKnowledge server. If it is, stop it and retry. Do not remove the lock file while that process is running.`:`Cannot verify shutdown: the server lock at ${e.lockPath} belongs to another machine. Stop OpenKnowledge on the owning machine. Confirm that no OpenKnowledge server is using this directory on the owning machine or any other machine sharing it. Only then remove the stale lock file at ${e.lockPath} and retry cleanup.`}function Cn(e){return e.replace(/:\d+$/,``)}function wn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Cn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Cn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Cn(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=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],En=[...m.map(e=>S[e]),`open-knowledge`];function Dn(e){if(!se(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||L(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function On(e,t){let n=z(e,t);if(n.startsWith(`..`)||se(n))return!1;let r=e;for(let e of n.split(V)){r=R(r,e);try{if(!de(r).isDirectory())return!1}catch{return!1}}return!0}function kn(e,t){try{return G(e).every(n=>t.has(R(e,n)))}catch{return!1}}function An(e){let t=Dn(e),n=[],r=[],i=new Set;for(let e of Tn){let a=R(t,e.hostDir,`skills`);if(!On(t,a))continue;let o=En.map(e=>R(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=R(t,e.pruneRoot),c=a;for(;kn(c,i)&&(r.push(c),i.add(c),c!==s);){let e=L(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function jn(e){try{if(!de(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Mn(e){let t=new Set,n=new Set;for(let r of Tn){let i=R(e,r.hostDir,`skills`);for(let e of En)t.add(R(i,e));let a=R(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=L(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Nn(e,t){let n=Dn(e),r=Mn(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(On(n,e)&&jn(e))try{K(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(On(n,e))try{he(e),a.push(e)}catch{}return a}function Pn(e){let t=Dn(e),n=[];for(let e of m){let r=S[e];n.push({path:R(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of ee)n.push({path:R(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Fn(e,t){let n=[];for(let r of Pn(e))if(r.bundleId===t)try{K(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function In(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Ln(e,t=Date.now()){if(e===null)return`—`;let n=u(e,t);return n===`unknown`?`—`:n}function Rn(e){let t=L(e);return I(e)===`local`&&I(t)===`.ok`?L(t):I(e)===`.ok`?t:null}function zn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:Rn(e),server:{port:null,status:t.status,pid:t.pid,startedAt:null,usage:null},ui:null,hostname:null,lockPath:t.lockPath,binary:null,command:null,isDesktop:!1};let i=t.lock,a=t.status===`alive`&&T(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:y(n),command:n,isDesktop:In(n)}}function Bn(e){let t=e.server.status;switch(t){case`unverified-owner`:return`unverified`;case`alive`:return e.isDesktop?`desktop`:`running`;case`foreign-host`:return e.isDesktop?`desktop`:`foreign`;case`dead-pid`:return`stale`;default:return t}}const Vn=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Hn(e){switch(e){case`running`:return Z.default.green(e);case`desktop`:return Z.default.blue(e);case`foreign`:return Z.default.cyan(e);case`unverified`:case`stale`:return Z.default.yellow(e)}}function Un(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Wn(e){return`${Un(e.server.usage)} | ${Un(e.ui?.usage??null)}`}function Gn(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Kn(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??`—`,Gn(e),Wn(e),Bn(e),String(e.server.pid),Ln(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=Hn(Bn(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=Z.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
11
|
+
`)}async function qn(e={}){let t=e.discover??g,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??k,a=e.resolveUsage??p,o=await t(),s=[];for(let e of o){let t=n(e),r=zn(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Bn(e)}));r(JSON.stringify(e,null,2));return}r(Kn(e.all?s:s.filter(e=>Vn.has(Bn(e)))))}function Jn(){return new j(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale entries (foreign and unverified entries already show)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await qn({all:t.all===!0||e===`all`,json:t.json===!0})})}async function Yn(e,t=ne()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=b(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function Xn(e,t={}){return{targets:Qn(e,t.isAlive??v)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function Zn(e){let t=e.inspect??(()=>$(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??Yn,o=e.logger??ne(),s=Xn(t(),{isAlive:e.isAlive});if(s.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:s.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let c=[],l=[];for(let e of s.targets)try{n(e.pid,`SIGTERM`),c.push(e)}catch(t){l.push({target:e,error:t instanceof Error?t.message:String(t)})}return c.length>0&&r(`Stopped: ${c.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:c.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:l.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),l.length>0&&i(`Failed to stop: ${l.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:c,failed:l,hadTargets:!0}}function Qn(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function $n(e,t=v){let n=await g(),r=null;for(let i of n){let n=$(i,`server`);if(Qn(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function er(e,t){let n=await Zn({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function tr(e,t,n={}){return t===0?`Nothing was running for ${e}, and no other open-knowledge servers are running.`:`Nothing was running for ${e}. ${t} other open-knowledge server${t===1?` is`:`s are`} running${n.listingFollows===!0?``:" — run `ok ps` to list them"}.`}async function nr(e){let t=await g(),n=0;for(let r of t)r!==e&&Qn($(r,`server`),v)&&n++;return n}function rr(e){return new j(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the enclosing project — run it from anywhere inside the project. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).option(`--force`,`Stop even when editor windows or agents are still connected to the server`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=O(process.cwd()),n=await Zn({lockDir:t,force:r,log:()=>{}});if(n.hadTargets){if(n.stopped.length>0){let e=n.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1)}else{let e=await nr(t);console.log(tr(process.cwd(),e,{listingFollows:e>0})),e>0&&await qn({})}return}if(i===`all`){let e=await g();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)Qn($(n,`server`),v)&&(await er(n,r),t++);t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(i)){let e=Number.parseInt(i,10),t=await $n(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await er(t,r);return}let a=B(je(),i),o=O(a),s=[],c=await Zn({lockDir:o,force:r,log:e=>s.push(e)});if((c.failed.length>0||c.declined!==void 0)&&(process.exitCode=1),c.hadTargets)for(let e of s)console.log(e);else console.log(tr(a,await nr(o)))})}export{Le as C,Oe as E,Ie as S,Ae as T,Ye as _,Nn as a,Pe as b,Pn as c,$ as d,xn as f,Y as g,Xe as h,Jn as i,wn as l,vn as m,Zn as n,An as o,_n as p,rr as r,Fn as s,Yn as t,Sn as u,ze as v,je as w,Ne as x,Me as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./md-manager-BGnqyqi1-BWyJhS5F.mjs";import"./init-H4L4PCDm.mjs";import"./registry-probes-DCe3rWZ7.mjs";import"./src-7sNhM-_B.mjs";import"./start-DYrDwaUD.mjs";import{n as e}from"./loader-gbJWrT9X.mjs";import"./preview-CMgnC4UA.mjs";import"./cli.mjs";import"./repair-mcp-configs-B2IwckuL.mjs";export{e as loadConfig};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{Hs as e,Lo as t,Qu as n,Uc as r,_t as i,pa as a,qd as o,zs as s}from"./md-manager-BGnqyqi1-BWyJhS5F.mjs";import{
|
|
2
|
-
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){c(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function be(e,t,n,r,i){let a=y[e];try{let o=A(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&c(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return c(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function xe(e,t,n){if(y[e].scope!==`global`)return q();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await b({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function Se(e,t,n){let r=o[e];if(r===null)return q();let i=re(t.cwd,r);if(n===`absent`)return be(e,t.cwd,t.home,i,t.env);let a=C(y[e],t.cwd,ve,void 0,i);switch(a.action){case`written`:case`overwritten`:return{action:a.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Ce(e,t,n){let r=t.home??ae();if(n===`absent`){let t=M(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=T(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function we(e,t,n){if(n===`absent`){let n=_(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=w(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function Te(e){return t=>{if(t.pathId===void 0)return Y();let r=n(t.pathId);if(r===null||r.kind===`central-skill-store`)return Y();switch(r.kind){case`editor-user-config`:return xe(r.editor,e,t.desired);case`editor-project-config`:return Se(r.editor,e,t.desired);case`editor-project-skill-root`:return we(r.editor,e,t.desired);case`editor-user-skill-root`:return Ce(r.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new S(`--only must be 'server'`)}function Oe(e=V){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[B(t,`public`),B(t,`../../app/dist`),B(t,`../../../app/dist`)].find(t=>e(t))}function ke(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 Ae(e){if(e===`off`)return`off`;if(!r.test(e))throw new S(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new S(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new S(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=R(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=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}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${m}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??oe,r=t.realpathFn??ie,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?B(e):null}},a=B(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(z(a));o=e===null?null:B(e,R(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&z(o)===s&&R(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>se(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))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`)}else process.stderr.write(`[start] leaving ${t} in place: only ${m}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function $(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 Re(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:c,dirname:l,resolve:d}=await import(`node:path`),{bootServer:m,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-DzdGKL8W.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?u(e.singleFile).canonicalFilePath:void 0,T=w?l(w):void 0,D=w?c(w):void 0,O,A=!1;if(T!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Q(O))throw new Z(O);o(d(O,`.ok`,`config.yml`))||y(O,T)}else O=h(T),A=!0}let j=async()=>{if(!(!A||O===void 0)){if(!Q(O)){S.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await se(O,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},M=O;if(!C){if(!i&&!f(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-CO4UASHL.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&S.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-DAIGiTv8.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=T??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),S.info({contentDir:P},`Created content directory`));let ne=F(),I=p(),L;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&S.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`)}L=await m({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:H,detectGhAccounts:de,tokenStore:ne,embeddingsKeyStore:I,mcpTomlEditor:x(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>k(e,t),probePiAcpBridge:e=>E(e),ensurePiAcpBridge:(e,t)=>N(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ae(),env:process.env};return{probe:te(e),execute:Te(e),userSkillPresentAnywhere:ee}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return $(M===void 0?n:Le(n,M),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let R=L.destroy,z=A?async()=>{try{await R()}finally{await j()}}:R;return{httpServer:L.httpServer,destroy:z,lockDir:L.lockDir,contentDir:P,port:L.port,ready:L.ready,degraded:L.degraded}}function ze(e,t,n=()=>l({absPath:d(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new S(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(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 Ue(n,r){let o=ze(n,r.singleFile),c=Ve(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Ie(m);let h;try{h=s(process.env)}catch(e){throw e instanceof i&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=a(o,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=r.bind!==void 0&&r.bind.length>0?r.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=e(g),S=v??(_||b===void 0?[...x.bind]:[b]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=r.externalUrl,E=e(a(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ 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 D=r.port===void 0?void 0:Number(r.port),O=h.overrides.find(e=>e.envVar===`PORT`)?.value,ee=D??O??o.server?.port,k=ke({explicitDir:r.reactShellDistDir,only:r.only,findBundledDir:Oe}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await Re({config:o,cwd:m,host:C,port:ee,bind:w,...r.serveContentAssets===void 0?{}:{serveContentAssets:r.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:t(r.idleShutdown??E.idleShutdown),serverRuntime:E,...r.singleFile?{singleFile:r.singleFile}:{},...r.projectDir?{projectDir:r.projectDir}:{},...r.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-
|
|
1
|
+
import{Hs as e,Lo as t,Qu as n,Uc as r,_t as i,pa as a,qd as o,zs as s}from"./md-manager-BGnqyqi1-BWyJhS5F.mjs";import{Ci as c,Uo as l,Vo as u,Xr as d,di as f,es as p,k as m,si as h}from"./dist-Bt-cb2ik.mjs";import{Ct as g,L as _,Tt as v,X as y,b,ut as x,wt as S,y as C,z as w}from"./init-H4L4PCDm.mjs";import{a as T,c as E,d as D,f as O,i as ee,n as k,o as A,p as j,r as M,s as N,t as te,u as P,v as F}from"./registry-probes-DCe3rWZ7.mjs";import{n as ne}from"./constants-wVFbQ-W8.mjs";import{execFileSync as I,spawn as L}from"node:child_process";import{basename as R,dirname as z,join as re,resolve as B}from"node:path";import{existsSync as V,realpathSync as ie}from"node:fs";import{homedir as ae,tmpdir as oe}from"node:os";import{rm as se}from"node:fs/promises";import{setTimeout as ce}from"node:timers/promises";const le=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ue={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function H(e,t={}){let{login:n}=t,r=t._exec??I,i=U(t._fileExists??V),a=e?[`--hostname`,e]:[];if(n){let e=W(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=W(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function U(e){return[`gh`,...le.filter(e)]}function W(e,t,n){for(let r of t)try{let t=e(r,n,ue).toString().trim();if(t.length>0)return t}catch{}}function de(e,t={}){let n=t._exec??I,r=U(t._fileExists??V),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=W(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=fe(a,e);if(t)return t}let o=W(n,r,i);if(o!==void 0){let e=_e(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function fe(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const pe=/Logged in to \S+ account (\S+) \(/,me=/(?:Failed to log in to|Timeout trying to log in to) \S+/,he=/^\s*-\s*Active account:\s*true\s*$/,ge=/\u001b\[[0-9;]*m/g;function _e(e){let t=[],n;for(let r of e.split(`
|
|
2
|
+
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){p(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function be(e,t,n,r,i){let a=y[e];try{let o=A(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function xe(e,t,n){if(y[e].scope!==`global`)return q();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await b({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function Se(e,t,n){let r=o[e];if(r===null)return q();let i=re(t.cwd,r);if(n===`absent`)return be(e,t.cwd,t.home,i,t.env);let a=C(y[e],t.cwd,ve,void 0,i);switch(a.action){case`written`:case`overwritten`:return{action:a.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Ce(e,t,n){let r=t.home??ae();if(n===`absent`){let t=M(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=T(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function we(e,t,n){if(n===`absent`){let n=_(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=w(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function Te(e){return t=>{if(t.pathId===void 0)return Y();let r=n(t.pathId);if(r===null||r.kind===`central-skill-store`)return Y();switch(r.kind){case`editor-user-config`:return xe(r.editor,e,t.desired);case`editor-project-config`:return Se(r.editor,e,t.desired);case`editor-project-skill-root`:return we(r.editor,e,t.desired);case`editor-user-skill-root`:return Ce(r.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new S(`--only must be 'server'`)}function Oe(e=V){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[B(t,`public`),B(t,`../../app/dist`),B(t,`../../../app/dist`)].find(t=>e(t))}function ke(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 Ae(e){if(e===`off`)return`off`;if(!r.test(e))throw new S(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new S(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new S(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=R(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=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}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${m}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??oe,r=t.realpathFn??ie,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?B(e):null}},a=B(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(z(a));o=e===null?null:B(e,R(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&z(o)===s&&R(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>se(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))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`)}else process.stderr.write(`[start] leaving ${t} in place: only ${m}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function $(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 Re(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:p}=await import(`node:path`),{bootServer:m,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-CZBCHPnO.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?c(e.singleFile).canonicalFilePath:void 0,T=w?u(w):void 0,D=w?l(w):void 0,O,A=!1;if(T!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Q(O))throw new Z(O);o(p(O,`.ok`,`config.yml`))||y(O,T)}else O=h(T),A=!0}let j=async()=>{if(!(!A||O===void 0)){if(!Q(O)){S.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await se(O,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},M=O;if(!C){if(!i&&!d(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-B2IwckuL.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&S.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-CK7gSieg.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=T??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),S.info({contentDir:P},`Created content directory`));let ne=F(),I=f(),L;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&S.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`)}L=await m({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:H,detectGhAccounts:de,tokenStore:ne,embeddingsKeyStore:I,mcpTomlEditor:x(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>k(e,t),probePiAcpBridge:e=>E(e),ensurePiAcpBridge:(e,t)=>N(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ae(),env:process.env};return{probe:te(e),execute:Te(e),userSkillPresentAnywhere:ee}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return $(M===void 0?n:Le(n,M),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let R=L.destroy,z=A?async()=>{try{await R()}finally{await j()}}:R;return{httpServer:L.httpServer,destroy:z,lockDir:L.lockDir,contentDir:P,port:L.port,ready:L.ready,degraded:L.degraded}}function ze(e,t,n=()=>u({absPath:l(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new S(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(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 Ue(n,r){let o=ze(n,r.singleFile),c=Ve(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Ie(m);let h;try{h=s(process.env)}catch(e){throw e instanceof i&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=a(o,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=r.bind!==void 0&&r.bind.length>0?r.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=e(g),S=v??(_||b===void 0?[...x.bind]:[b]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=r.externalUrl,E=e(a(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ 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 D=r.port===void 0?void 0:Number(r.port),O=h.overrides.find(e=>e.envVar===`PORT`)?.value,ee=D??O??o.server?.port,k=ke({explicitDir:r.reactShellDistDir,only:r.only,findBundledDir:Oe}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await Re({config:o,cwd:m,host:C,port:ee,bind:w,...r.serveContentAssets===void 0?{}:{serveContentAssets:r.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:t(r.idleShutdown??E.idleShutdown),serverRuntime:E,...r.singleFile?{singleFile:r.singleFile}:{},...r.projectDir?{projectDir:r.projectDir}:{},...r.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-CZBCHPnO.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(f(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(f(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(f(e.message)),process.exit(1)),Ke(e,t)){let e=t.resolveLockDir(m),n=null;try{n=await We({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>ce(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]=Ge(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=qe(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let M=!1,N=async e=>{if(M)return;M=!0;let[t,...n]=He(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await j.destroy(`external-signal`)}catch(e){console.error(`${f(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{N(`SIGINT`)}),process.once(`SIGTERM`,()=>{N(`SIGTERM`)});let te=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${j.port}`,P=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,F=te;console.log(l({name:`open-knowledge`,version:ne,localUrl:F,networkUrl:P,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let I={"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`};j.ready.then(async()=>{if(j.degraded.length>0){console.log();for(let e of j.degraded){let t=I[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(Ne({openBrowser:r.openBrowser!==!1&&E.openBrowser,explicitOn:r.openBrowser!==!1&&g.server?.openBrowser===!0,host:C,isTTY:process.stdout.isTTY===!0,ephemeral:r.singleFile!==void 0,only:r.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-Co1psphf.mjs`);e(F)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function We(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();return n===null||n.draining===!0||n.port<=0?null:h(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function Ge(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 Ke(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function qe(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 Je(e){return new g(`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]).option(`--no-open-browser`,`Do not open the browser after start (interactive loopback starts open it by default)`).option(`--only <module>`,`Serve one module: 'server' (API + MCP only, no shell or browser)`,De).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)`,Ae).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Be).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>`).addOption(new v(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new v(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new v(`--terminal-auth`,`Tell in-app agents that this server's client can run terminal sign-ins (the desktop app passes it when it has a terminal)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,Fe).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
|
|
4
4
|
`),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
|
|
5
5
|
`),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=D(P());if(n.available){O({spawn:L},n);return}console.error(j(n.reason)),process.exit(1)}await Ue(n,t)})}export{qe as C,de as D,H as E,Je as S,$ as T,Ve as _,Ge as a,Ne as b,Q as c,Ae as d,De as f,ze as g,We as h,Ie as i,Ke as l,Ee as m,X as n,He as o,Oe as p,Re as r,je as s,Z as t,Fe as u,ke as v,Le as w,Me as x,Ue as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,m as t,p as n,r}from"./start-DYrDwaUD.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.79.
|
|
3
|
+
"version": "0.79.3-beta.0",
|
|
4
4
|
"description": "Local-first, agent-friendly Markdown knowledge base with a cross-platform CLI and web editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"knowledge-base",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"ajv-formats": "^3.0.1",
|
|
73
73
|
"tsdown": "^0.22.14",
|
|
74
74
|
"typescript": "~7.0.2",
|
|
75
|
-
"@inkeep/open-knowledge-
|
|
75
|
+
"@inkeep/open-knowledge-core": "0.79.3-beta.0",
|
|
76
76
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
77
|
-
"@inkeep/open-knowledge-server": "0.79.
|
|
78
|
-
"@inkeep/open-knowledge-
|
|
77
|
+
"@inkeep/open-knowledge-server": "0.79.3-beta.0",
|
|
78
|
+
"@inkeep/open-knowledge-app": "0.79.3-beta.0"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build:cli": "rm -rf dist && tsdown",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-BWyJhS5F.mjs";var e=`0.79.2`;const t=`config.yml`,n=e;export{n,t};
|
package/dist/dist-DzdGKL8W.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ht as e,Io as t,Jo as n,Kl as r,La as i,Rs as a,Zn as o,su as s,wn as c,yn as l,zd as u}from"./md-manager-BGnqyqi1-BWyJhS5F.mjs";import{$ as d,$a as f,$i as p,$n as m,$o as h,$r as g,$t as _,A as v,Aa as y,Ai as b,An as x,Ar as S,At as C,B as w,Ba as T,Bi as E,Bn as D,Br as O,Bt as k,C as A,Ca as j,Ci as M,Cn as N,Cr as P,Ct as F,D as I,Da as L,Di as R,Dn as z,Dr as B,Dt as V,E as H,Ea as U,Ei as W,En as G,Er as K,Et as q,F as J,Fa as Y,Fi as X,Fn as Z,Fr as Q,Ft as $,G as ee,Ga as te,Gi as ne,Gn as re,Gr as ie,Gt as ae,H as oe,Ha as se,Hi as ce,Hn as le,Hr as ue,Ht as de,I as fe,Ia as pe,Ii as me,In as he,Ir as ge,It as _e,J as ve,Ja as ye,Ji as be,Jn as xe,Jr as Se,Jt as Ce,K as we,Ka as Te,Ki as Ee,Kn as De,Ko as Oe,Kr as ke,Kt as Ae,L as je,La as Me,Li as Ne,Ln as Pe,Lr as Fe,Lt as Ie,M as Le,Ma as Re,Mi as ze,Mn as Be,Mr as Ve,Mt as He,N as Ue,Na as We,Ni as Ge,Nn as Ke,Nr as qe,Nt as Je,O as Ye,Oa as Xe,Oi as Ze,On as Qe,Or as $e,Ot as et,P as tt,Pa as nt,Pi as rt,Pn as it,Pr as at,Pt as ot,Q as st,Qa as ct,Qi as lt,Qn as ut,Qo as dt,Qr as ft,Qt as pt,R as mt,Ra as ht,Ri as gt,Rn as _t,Rr as vt,Rt as yt,S as bt,Sa as xt,Si as St,Sn as Ct,So as wt,Sr as Tt,St as Et,T as Dt,Ta as Ot,Ti as kt,Tn as At,Tr as jt,Tt as Mt,U as Nt,Ua as Pt,Ui as Ft,Un as It,Ur as Lt,Ut as Rt,V as zt,Va as Bt,Vi as Vt,Vn as Ht,Vr as Ut,Vt as Wt,W as Gt,Wa as Kt,Wi as qt,Wn as Jt,Wr as Yt,Wt as Xt,X as Zt,Xa as Qt,Xi as $t,Xn as en,Xr as tn,Xt as nn,Y as rn,Ya as an,Yi as on,Yn as sn,Yr as cn,Yt as ln,Z as un,Za as dn,Zi as fn,Zn as pn,Zo as mn,Zr as hn,Zt as gn,_ as _n,_a as vn,_i as yn,_n as bn,_o as xn,_r as Sn,_t as Cn,a as wn,aa as Tn,ai as En,an as Dn,ao as On,ar as kn,as as An,at as jn,b as Mn,ba as Nn,bi as Pn,bn as Fn,bo as In,br as Ln,bt as Rn,c as zn,ca as Bn,ci as Vn,cn as Hn,co as Un,cr as Wn,ct as Gn,d as Kn,da as qn,di as Jn,dn as Yn,do as Xn,dr as Zn,dt as Qn,ea as $n,ei as er,en as tr,eo as nr,er as rr,es as ir,et as ar,f as or,fa as sr,fi as cr,fn as lr,fo as ur,fr as dr,ft as fr,g as pr,ga as mr,gi as hr,gn as gr,go as _r,gr as vr,gt as yr,h as br,ha as xr,hi as Sr,hn as Cr,ho as wr,hr as Tr,ht as Er,i as Dr,ia as Or,ii as kr,in as Ar,io as jr,ir as Mr,is as Nr,it as Pr,j as Fr,ja as Ir,ji as Lr,jn as Rr,jr as zr,jt as Br,k as Vr,ka as Hr,ki as Ur,kn as Wr,kr as Gr,kt as Kr,l as qr,la as Jr,li as Yr,ln as Xr,lo as Zr,lr as Qr,lt as $r,m as ei,ma as ti,mi as ni,mn as ri,mo as ii,mr as ai,mt as oi,n as si,na as ci,ni as li,nn as ui,no as di,nr as fi,ns as pi,nt as mi,o as hi,oa as gi,oi as _i,on as vi,oo as yi,or as bi,ot as xi,p as Si,pa as Ci,pi as wi,pn as Ti,po as Ei,pr as Di,pt as Oi,q as ki,qa as Ai,qi as ji,qn as Mi,qo as Ni,qr as Pi,qt as Fi,r as Ii,ra as Li,ri as Ri,rn as zi,ro as Bi,rr as Vi,rs as Hi,rt as Ui,s as Wi,sa as Gi,si as Ki,sn as qi,so as Ji,sr as Yi,st as Xi,t as Zi,ta as Qi,ti as $i,tn as ea,to as ta,tr as na,ts as ra,tt as ia,u as aa,ua as oa,ui as sa,un as ca,uo as la,ur as ua,ut as da,v as fa,va as pa,vi as ma,vn as ha,vo as ga,vr as _a,vt as va,w as ya,wa as ba,wi as xa,wn as Sa,wr as Ca,wt as wa,x as Ta,xa as Ea,xi as Da,xn as Oa,xo as ka,xr as Aa,xt as ja,y as Ma,ya as Na,yi as Pa,yn as Fa,yo as Ia,yr as La,yt as Ra,z as za,za as Ba,zi as Va,zn as Ha,zr as Ua,zt as Wa}from"./dist-Cmgb0r3p.mjs";export{Zi as AGENT_ID_MAX_LEN,si as AGENT_ID_RE,Ii as AGENT_WRITE_ORIGIN,Dr as AcpPermissionStore,wn as AcpRegistry,hi as AcpThreadManager,Wi as AgentFocusBroadcaster,zn as AgentPresenceBroadcaster,qr as AgentSessionCapacityError,aa as AgentSessionManager,Kn as AutoStartDisabledError,or as BUNDLE_IDS,Si as BUNDLE_SCOPE,ei as BUNDLE_SKILL_NAME,br as BacklinkIndex,pr as CC1Broadcaster,r as CC1_CONTRACT_VERSION,_n as CONCURRENT_REPLACE_WINDOW_MS,fa as CONFIG_FILENAME,Ma as CONFLICT_MARKER_RE,Mn as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Ta as ConfigSchema,bt as ConflictAuthority,A as DEFAULT_CHECKPOINT_RETENTION,ya as DEFAULT_EMBEDDINGS_DIMENSIONS,Dt as DEFAULT_PACK_ID,H as DocumentDurabilityState,I as DocumentDurabilityStateError,Ye as EMBEDDINGS_API_KEY_ENV,Vr as EPHEMERAL_PROJECT_DIR_PREFIX,v as ExposureConsentError,Fr as FEATURED_AGENT_IDS,Le as FILE_SYSTEM_WRITER,Ue as FILE_WATCHER_ORIGIN,tt as FileEmbeddingsBackend,J as GIT_PREFLIGHT_FAIL_SPAN_NAME,fe as GIT_UPSTREAM_WRITER,Oe as GitDirAccessError,je as GitNotAvailableError,mt as GitTooOldError,za as HOCUSPOCUS_AUTH_REJECTION_REASONS,w as HocuspocusAuthRejection,zt as HocuspocusAuthTokenSchema,oe as HomeProjectRootError,Nt as INSTALLED_AGENTS_SCHEMES,Gt as JSON_SCHEMA_DIALECT_2020_12,e as LINEAGE_EPOCH_KEY,ee as LIVE_DERIVED_INDEX_DEBOUNCE_MS,we as MANAGED_RENAME_ORIGIN,ki as MAX_ACP_THREADS,ve as MAX_AGENT_SESSIONS,rn as MCP_CONNECTION_ID_HEADER,u as MCP_SERVER_NAME,Zt as MIN_EVICTABLE_IDLE_MS,un as MIN_GIT_VERSION,st as MISSING_OK_CONFIG_MESSAGE,Ni as MalformedGitPointerError,d as McpLogger,ar as MissingOkConfigError,ia as OBSERVER_SYNC_ORIGIN,mi as OK_OKIGNORE_TEMPLATE,Ui as ONBOARDING_BUNDLE_IDS,l as ORPHAN_MODES,c as PROTOCOL_VERSION,mn as PinoLogger,Pr as ProcessLockCollisionError,jn as ProjectGitInitError,xi as ROLLBACK_ORIGIN,Xi as ROOT_GITIGNORE_TEMPLATE,Gn as RUNTIME_VERSION,$r as SERVICE_WRITER,da as SKILL_INSTALL_EVENTS_FILE_REL,o as SKILL_STATE_TARGETS,Qn as STARTER_FOLDER_FRONTMATTER_FILENAME,fr as STARTER_PACKS,Oi as STARTER_PACK_IDS,oi as STATE_MANIFEST_FILENAME,Er as STATE_SCHEMA_VERSION,s as SYSTEM_DOC_NAME,yr as SeedPrerequisiteError,Cn as SeedRootDirError,va as ServerLockCollisionError,Ra as SingleFileNotAFileError,Rn as SingleFileNotFoundError,ja as SingleFileNotMarkdownError,Et as SingleFileProjectOverrideError,F as StateManifestError,wa as TagIndex,Mt as USER_GLOBAL_BUNDLE_IDS,q as __getShowAllWalkStatsForTesting,V as __resetShowAllWalkStatsForTesting,et as acpThreadStoreRoots,Kr as acpThreadsDir,C as acquireProcessLock,Br as acquireServerLock,He as applyAgentMarkdownWrite,Je as applyExternalChange,ot as applySeed,$ as assertCompatibleStateManifest,_e as assertGitAvailable,Ie as assertNeverDiskEvent,yt as assertNotHomeProjectRoot,Wa as attachAcpThreadSocket,k as attachCollabClientCounter,Wt as attachIdleShutdown,de as bindConflictAuthority,Rt as bootServer,Xt as buildAndOpenSkill,ae as buildConfigYmlContent,Ae as buildExecResult,Fi as buildIngressPolicy,Ce as buildOkMcpStdioCommand,ln as buildSkillZip,nn as buildStarterFolderFrontmatterYaml,gn as buildWipTree,pt as bundleSkillMdPath,_ as canonicalProjectKey,tr as canonicalizeForCompare,ea as classifyEvents,ui as classifyFsPath,zi as clearAllEmbeddingsKeys,Ar as coercePackId,Dn as collectServerHostSnapshot,i as colorFromSeed,vi as commitUpstreamImport,qi as commitWip,Hn as commitWipFromTree,Xr as compareSemver,ca as composeEffectiveLinterConfig,Yn as composeFrontmatterSchemasConfig,lr as containsConflictMarkers,Ti as contentHash,ri as contributorCount,Cr as countShadowObjects,gr as countStaleAgentWipRefs,bn as countWipRefs,ha as createApiExtension,Fa as createAssetServeMiddleware,Fn as createCollaborationHost,Oa as createContentFilter,Ct as createContentFilterAsync,N as createEmbeddingsSecretStore,Sa as createEphemeralProjectDir,At as createExternalChangeHandler,G as createFileLogger,z as createLiveDerivedIndexExtension,Qe as createMcpHttpHandler,Wr as createOsProbe,x as createPersistenceExtension,Rr as createProbeFailureReporter,Be as createServer,Ke as createServerObserverExtension,it as createServerProbeResolver,Z as createStreamingErrorWriter,dt as createTestLogger,he as describeStoredEmbeddingsKey,Pe as detectClaudeDesktopPresence,_t as detectGit,Ha as detectProjectShape,D as detectUserSkillHosts,Ht as discoverLockDirs,le as discoverMarkdownlintConfig,It as emitPreflightFailureSpan,Jt as encodeDocName,re as encodeFolderRoute,De as encodeSkillRoute,Mi as ensureProjectGit,xe as errorResponse,sn as evictStaleTrackerEntries,en as extractHeadings,pn as extractOkBinaryPath,ut as extractWikiLinksFromMarkdown,m as fallbackPaths,rr as findEnclosingGitRoot,na as findEnclosingProjectRoot,fi as findNativeMarkdownlintFile,Vi as flushFileLogger,Mr as formatAuditBrokenLinkSuppressionLine,kn as formatAuthRejectionWire,bi as formatContributorsFrom,Yi as formatPackRationale,Wn as gcCheckpointRefs,Qr as getCurrentMcpLogger,ua as getIngressContext,Zn as getLocalDir,dr as getLogFilePath,h as getLogger,Di as getLogsDir,ai as getMachineId,Tr as getMeter,vr as getMetrics,Sn as getTracer,_a as handleCollabSocketError,La as handleSpawnCursor,Ln as hasForwardingHeaders,Aa as hasGcLogLatch,t as iconFromClientName,Tt as incrementCollabSocketFilteredError,P as incrementServerObserverFire,Ca as initContent,jt as initShadowRepo,K as initTelemetry,B as initToleranceTelemetryWriter,$e as installJsonSchemaDialect,Gr as installPrettyZodErrors,ir as installTestLoggers,S as installUserSkill,zr as isAllowedApiOrigin,Ve as isAllowedWorkspaceHostHeader,qe as isConfigDoc,at as isDefunctProcess,Q as isDocInConflict,ge as isHocuspocusAuthRejectionReason,Fe as isHomeDir,vt as isHostAdmitted,Ua as isKnownPackId,O as isLinkIndexExcludedDoc,Ut as isLockProcessRunning,ue as isLoopbackAddress,Lt as isManagedArtifactDoc,Yt as isMintedThreadId,ie as isOriginAdmitted,n as isOrphanMode,ke as isPairedWriteOrigin,Pi as isPathWithinDir,Se as isPeerAdmitted,cn as isProcessAlive,tn as isProjectRoot,hn as isReservedForUserTree,ft as isSelfWrite,g as isSystemDoc,er as isToleranceTelemetryEnabled,$i as isValidLockPid,li as lastKnownHash,Ri as listRescueCheckpoints,kr as listStarterPacks,En as loadCustomAgents,_i as loadPrincipal,Ki as lockAdvertisesUi,Vn as lockBaseUrl,Yr as lockFilePath,ra as loggerFactory,sa as loginShapedUserinfoUser,pi as logsCurrentPath,Hi as logsPreviousPath,Jn as makeLazyEmbeddingsKeyStore,cr as markServerLockDraining,wi as mountMcpAndApi,ni as normalizeFsPath,Sr as observeReadiness,hr as packageVersionMajorMinor,yn as parseAuthRejectionWire,ma as parseGitVersion,Pa as parseHocuspocusAuthToken,Pn as parseKeepaliveConnectionId,Da as pathToDocName,St as planSeed,M as prepareSingleFileOpen,xa as processCommand,kt as processUsage,W as readAgentBrowserTools,R as readAllTargets,Ze as readBundleDecision,Ur as readDeclaredGitHubHosts,b as readOriginGitHubRepo,Lr as readOwnNativeRules,ze as readProcessLock,Ge as readProcessLockDetailed,rt as readProcessState,X as readProjectHeadState,me as readProjectLocalSemanticConfig,Ne as readServerLock,gt as readServerPackageVersion,Va as readSkillInstallStateSnapshot,E as readStateManifest,Vt as readTargetRecordedAt,ce as readTargetVersion,Ft as reconcile,qt as recordContributor,ne as recordSkillInstallEvent,Ee as redactShareSubprocessStderr,ji as registerAllTools,be as registerWrite,on as releaseProcessLock,$t as releaseServerLock,fn as removeLastKnownHash,lt as removeProjectSkillGitignoreBlock,p as reportSkillInstall,$n as resetMetrics,Qi as resolveBuiltinSkillHosts,a as resolveBundleEnabled,ci as resolveBundledSkillDir,Li as resolveContentDir,Or as resolveCursorBinaryDefault,Tn as resolveCursorSpawnInvocation,gi as resolveEffectiveLinterConfig,Gi as resolveEmbeddingsCredential,Bn as resolveGitHubAccountFromUrl,Jr as resolveGitHubAuthHost,oa as resolveLockDir,qn as resolveNativeConfigForDoc,sr as resolveNativeMarkdownlintConfig,Ci as resolvePack,ti as resolvePackageVersion,xr as resolveSkillInstallReportSettings,mr as resolveUiInfo,vn as restoreContributors,pa as rewriteMarkdownLinksForDocumentRename,Na as rewriteWikiLinksForDocumentRename,Nn as runAuthReposSubprocess,Ea as runAuthStatusSubprocess,xt as runCloneSubprocess,j as runDeviceFlowSubprocess,ba as runWithMcpLogger,Ot as safeContentPath,U as safeSubdir,L as safetyCheckpoint,Xe as sameGitHubLogin,Hr as sanitizeClientName,y as saveInMemoryCheckpoint,Ir as saveVersion,Re as scanLockProcesses,We as seedBasenameIndex,nt as seedEphemeralProjectDir,Y as serializeError,pe as setActiveSpanAttributes,Me as setupServerObservers,ht as shadowGit,Ba as shutdownTelemetry,Nr as spansCurrentPath,An as spansPreviousPath,T as spawnDetached,Bt as splitMarkdownBlocks,se as startWatcher,Pt as strategiesFor,Kt as streamedChunkOf,te as streamingProblemEvent,Te as swapContributors,Ai as teardownToleranceTelemetryWriter,ye as toBroadcasterKey,an as tracedAppendFileSync,Qt as tracedLinkSync,dn as tracedMkdir,ct as tracedMkdirSync,f as tracedRename,nr as tracedRenameSync,ta as tracedRmSync,di as tracedRmdirSync,Bi as tracedUnlinkSync,jr as tracedWriteFile,On as tracedWriteFileSync,yi as trustSystemCertificates,Ji as updateLastKnownHash,Un as updateProcessLockPort,Zr as updateServerLockPort,la as validateAgentId,Xn as validateCloneInputs,ur as validateSkillZip,Ei as waitForServerLockDrain,ii as withHiddenWindowsConsole,wr as withSpan,_r as withSpanSync,xn as writeBundleDecision,ga as writeMarkdownlintRule,Ia as writeRootGitignoreForNewRepo,In as writeStateManifest,ka as writeTargetVersion,wt as writeTracker};
|
package/dist/init-BGM70oJ3.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-Cmgb0r3p.mjs";import{_ as e}from"./init-CjbAcLHr.mjs";export{e as runInit};
|
package/dist/loader-BVs3fR6_.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-Cmpu_239.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-CUsQsBjV.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./index-B4DpftwC.js";export{e as FeedbackForm};
|