@inkeep/open-knowledge 0.88.3 → 0.88.4-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/THIRD_PARTY_NOTICES.md +2 -1
- package/dist/chunk-3H6UQG3A-Doth9YS5.mjs +9 -0
- package/dist/cli.mjs +7 -7
- package/dist/constants-DkmpmTiN.mjs +1 -0
- package/dist/{dist-Cdi2gf6r.mjs → dist-CVvHVQuh.mjs} +1 -1
- package/dist/{dist-C1xy7ROh.mjs → dist-DAAU-wLM.mjs} +2 -2
- package/dist/{flag-coverage-6JEX67RU-Byy8DkC9.mjs → flag-coverage-6JEX67RU-CvfAS1f3.mjs} +1 -1
- package/dist/{grep-2HUTXO5U-Bu-1kF3P.mjs → grep-2HUTXO5U-CoGVhBxG.mjs} +1 -1
- package/dist/grep-2HUTXO5U-q3hMkiyQ.mjs +10 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +119 -119
- package/dist/init-BJx-rimO.mjs +1 -0
- package/dist/{init-CMLNmVBS.mjs → init-Bam41vCv.mjs} +2 -2
- package/dist/{launch-json-removal-52jAtupz.mjs → launch-json-removal-ByKHrEsD.mjs} +1 -1
- package/dist/loader-BZMH6rz4.mjs +1 -0
- package/dist/{loader-BJSdPFd3.mjs → loader-xTK_xs3Y.mjs} +1 -1
- package/dist/{md-manager-BGnqyqi1-CSFPyGy0.mjs → md-manager-BGnqyqi1-DW5IsDjR.mjs} +156 -156
- package/dist/{open-browser-DZp2CvgD.mjs → open-browser-BLuYnAd6.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-DJ6QVqir.mjs → preview-D_lbKRQL.mjs} +1 -1
- package/dist/preview-DjMEWNn5.mjs +1 -0
- package/dist/public/assets/{AccountSection-CmdU5sya.js → AccountSection-CNUz9CJ1.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-DGJw0zL0.js → ActivityModeContent-BrA3UDOm.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-BvsjJbAv.js → AddPropertiesButton-CBjHYXWE.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-C_h6i8l7.js → AgentDiffPane-Cxxbz777.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-nsetxtV7.js → AttachmentsSection-DTog67g1.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-DukLDCui.js → CodeMirrorPropInput-BqKQ4X--.js} +61 -61
- package/dist/public/assets/{ContentRulesSection-D6P3MefX.js → ContentRulesSection-BrijaGSh.js} +1 -1
- package/dist/public/assets/{DocumentContext-Bq4h5hUX.js → DocumentContext-CZfs_6gH.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-CGBMNwoy.js → EditorModeToggle-5K9G11EF.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-BYvXvEfh.js → ExcalidrawDocEditor-DQg87Nwm.js} +1 -1
- package/dist/public/assets/FeedbackForm-Chf8uJXF.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-CctDcDKs.js → ImportSkillDialog-C3KjtvU_.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-BHc5NDw7.js → LinkPreviewsSection-D9HyOQ6k.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-Dp6T06Ls.js → LintConfigEditor-NqtRWZ7S.js} +1 -1
- package/dist/public/assets/{LintingSection-DJLt9tVo.js → LintingSection-DhSOWZdT.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-DWsraPds.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-3QmZ83FW.js → ManagedArtifactProperties-DhytxUG5.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-C6Kq_7T0.js → MermaidDocEditor-l4XWiITP.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-DMA4Lrwl.js → NetworkAccessSection-CYbq_Mr-.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-D_rtpNN5.js → PropertyDisplayRow-NAGinbjB.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-CyMti3Ks.js → PublishToGitHubDialog-Dg9G8lz0.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-Bf4q1X2j.js → SchemaConfigEditor-1sGx-fwe.js} +1 -1
- package/dist/public/assets/{SearchSection-YzrvGC7c.js → SearchSection-D7KqcbQ4.js} +1 -1
- package/dist/public/assets/{SessionsHost-DimxrVot.js → SessionsHost-O449cqfe.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-D17HbqIR.js → SettingsDialogBody-C-AgemIi.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-Bn178luN.js → ShareReceiveMissDialog-xxkiS9uQ.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-B-o93GFK.js → SkillToolbarControls-D9RP2FwT.js} +1 -1
- package/dist/public/assets/{SourceEditor-5oYkUCvt.js → SourceEditor-B6H7q1aD.js} +1 -1
- package/dist/public/assets/{SyncSection-CCnnjRqb.js → SyncSection-BXEuGbzp.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-6KlaCnEN.js → SyncStatusBadge-mEIsvqGx.js} +1 -1
- package/dist/public/assets/{TerminalSection-DseEvzCB.js → TerminalSection-3ZZ__vuW.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-DM5qsH9r.js → TerminalWindowApp-DLbPdLUI.js} +1 -1
- package/dist/public/assets/{TextDocEditor-CfLSIFnU.js → TextDocEditor-B7UAgPL9.js} +1 -1
- package/dist/public/assets/{ThreadView-D_AR1EEd.js → ThreadView-DEW6DAyJ.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-YnL9JNdR.js → TimelineDiffPane-C0uQxGsG.js} +1 -1
- package/dist/public/assets/{client-version-BLrEYK8-.js → client-version-D_Y71tEt.js} +1 -1
- package/dist/public/assets/{comment-chips-Cv7ITvKo.js → comment-chips-CsdmG7qC.js} +1 -1
- package/dist/public/assets/{config-provider-BDG-sfPW.js → config-provider-DEa9FPV2.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-8U8XR3T-.js → doc-undo-manager-BEnEkaiI.js} +1 -1
- package/dist/public/assets/{index-CxBO9vps.js → index-OIjK6Bsw.js} +7 -7
- package/dist/public/assets/{lint-plugins-nLxSVFtY.js → lint-plugins-DKli6dmw.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-CxwpcNNn.js → pending-receive-nav-store-DOEACxzy.js} +1 -1
- package/dist/public/assets/{preferred-session-events-BAFbYFcT.js → preferred-session-events-sdkCI6R1.js} +1 -1
- package/dist/public/assets/{progress-D9EYl76w.js → progress-BRceZIOx.js} +1 -1
- package/dist/public/assets/{selection-context-IDuqXvJZ.js → selection-context-B8Ew27EI.js} +1 -1
- package/dist/public/assets/{src-DK3WfBGA.js → src-q-O9qt-P.js} +1 -1
- package/dist/public/assets/{telemetry-impl-NFXjLy8d.js → telemetry-impl-D1W1GOkA.js} +1 -1
- package/dist/public/assets/{telemetry-startup-B3sE6BzB.js → telemetry-startup-Bvf7jktL.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-B5Li5ULZ.js → typing-burst-detector-CrZn1kv2.js} +1 -1
- package/dist/public/assets/{use-activity-panel-D6JQ2Om2.js → use-activity-panel-9dflKpc8.js} +1 -1
- package/dist/public/assets/{use-open-skill-BerIajYs.js → use-open-skill-Cu--rlxa.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-Ctsuf01c.js → use-terminal-enabled-kd1FDTzo.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-DeQPiegD.js → use-timeline-entry-diff-BjWoURvX.js} +1 -1
- package/dist/public/index.html +19 -19
- package/dist/{registry-probes-CBusnb_Y.mjs → registry-probes-BCdRmBhQ.mjs} +1 -1
- package/dist/{removal-file-path-CCu-35_y.mjs → removal-file-path-tEguF0LN.mjs} +1 -1
- package/dist/{repair-launch-json-c_BJk9kA.mjs → repair-launch-json-DIJ8uSXj.mjs} +1 -1
- package/dist/{repair-mcp-configs-Cxupq-9r.mjs → repair-mcp-configs-CKZK9Yyu.mjs} +1 -1
- package/dist/{src-BaDVbX4Z.mjs → src-BnTt3RNV.mjs} +2 -2
- package/dist/src-xn1VIRXc.mjs +1 -0
- package/dist/start-6ide4Xag.mjs +1 -0
- package/dist/{start-BTbrWXSB.mjs → start-Dij8Dt2x.mjs} +3 -3
- package/package.json +4 -4
- package/dist/chunk-3H6UQG3A-BTZuQ7ja.mjs +0 -8
- package/dist/constants-BzzQY8TG.mjs +0 -1
- package/dist/grep-2HUTXO5U-Bvpc71YZ.mjs +0 -9
- package/dist/init-SzNKE1LX.mjs +0 -1
- package/dist/loader-bNJsrWAB.mjs +0 -1
- package/dist/preview-DW4U514Y.mjs +0 -1
- package/dist/public/assets/FeedbackForm-isllFU5L.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-mS0tCDpD.js +0 -1
- package/dist/src-afb9qw6F.mjs +0 -1
- package/dist/start-BhxT0Ii7.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$l as t,Bf as n,Da as r,Ff as i,G as a,Kf as o,Oa as s,U as c,Vf as l,W as u,Wf as d,Xf as ee,Zf as f,eu as p,fl as m,l as h,ml as g,ol as _,pd as v,pl as y,qf as b,sl as x,tp as S,u as te,ul as C}from"./md-manager-BGnqyqi1-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$l as t,Bf as n,Da as r,Ff as i,G as a,Kf as o,Oa as s,U as c,Vf as l,W as u,Wf as d,Xf as ee,Zf as f,eu as p,fl as m,l as h,ml as g,ol as _,pd as v,pl as y,qf as b,sl as x,tp as S,u as te,ul as C}from"./md-manager-BGnqyqi1-DW5IsDjR.mjs";import{Ai as w,As as ne,Bs as T,Ca as re,Di as E,Do as D,Ds as O,Ei as k,Fs as A,Gs as j,Ha as ie,Ji as ae,Ls as oe,Nt as M,Oi as N,Os as se,Ps as P,Qt as ce,Rs as le,Xi as ue,_r as de,ba as fe,bi as pe,ii as me,ks as he,m as ge,pi as F,pr as _e,qo as ve,rr as I,sa as ye,zs as be}from"./dist-DAAU-wLM.mjs";import{t as xe}from"./yazl-BBz29IQN.mjs";import{ct as Se,gt as Ce,ht as we,mt as Te,pt as Ee,st as De,wt as Oe}from"./init-Bam41vCv.mjs";import{T as ke,l as Ae,u as je}from"./registry-probes-BCdRmBhQ.mjs";import{c as Me}from"./colors-r_owlCuY.mjs";import{t as Ne}from"./is-object-BGze3w87.mjs";import{n as Pe}from"./constants-DkmpmTiN.mjs";import"./loader-xTK_xs3Y.mjs";import"./preview-D_lbKRQL.mjs";import{execFile as Fe,execSync as Ie,spawnSync as Le}from"node:child_process";import{basename as L,dirname as R,isAbsolute as Re,join as z,relative as ze,resolve as B,sep as V,win32 as Be}from"node:path";import{closeSync as Ve,cpSync as He,createWriteStream as Ue,existsSync as H,lstatSync as We,mkdirSync as U,mkdtempSync as Ge,openSync as Ke,readFileSync as W,readSync as qe,readdirSync as G,readlinkSync as Je,realpathSync as Ye,rmSync as Xe,rmdirSync as Ze,statSync as Qe,writeFileSync as K}from"node:fs";import{arch as $e,freemem as et,homedir as q,hostname as tt,platform as nt,release as rt,tmpdir as it,totalmem as at,type as ot,uptime as st}from"node:os";import{createHash as ct}from"node:crypto";import{readFile as lt,readdir as ut,stat as dt}from"node:fs/promises";function ft(e,t){let n=t.map(e=>[j(e),e]);for(let t of e){let e=j(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function pt(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=ft([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=ft(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function mt(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const ht=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function gt(e,t,n=de){if(e!==void 0&&!ht.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let _t=null;function vt(e){_t=e}function yt(){return _t??process.cwd()}const bt=`Open Knowledge`;function xt(e={}){let t=e.platformName??process.platform,n=e.productName??b().productName;return De(t).join(Se({...e,platformName:t}),n)}function St(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=De(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,`${b().packageName.replaceAll(`/`,``)}-updater`)}function Ct(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 wt(e){let t=z(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Ct(n)??[]}function Tt(e){let t=z(e,`state.json`);if(!H(t))return!1;try{return Ct(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Et=8192;function Dt(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 Ot(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const kt=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function At(e){return e.replace(kt,`$1"[REDACTED-DEVICE-ID]"`)}function jt(e){return At(Ot(e))}const Mt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Nt(e){if(typeof e!=`string`)return null;let t=Mt.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 Pt(e){let t=Ke(e,`r`);try{let e=Buffer.alloc(Et),n=0,r=!1;for(;n<Et;){let i=qe(t,e,n,Et-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{Ve(t)}}function Ft(e){try{let t=Pt(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:Nt(a)}}catch{return{kind:`unreadable`}}}function It(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Lt(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=z(e,t.name),r;try{r=Qe(n).mtimeMs}catch{continue}if(r<i)continue;let c=Ft(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!It(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`}}const Rt=`state/os-termination-evidence.json`,zt=6048e5,Bt=/openknowledge/i,Vt=d.map(e=>f(l[e]));function Ht(e={}){return(t,n)=>new Promise(r=>{try{Fe(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...Ut(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function Ut(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function Wt(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
|
|
2
2
|
`)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function Gt(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function Kt(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function qt(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function Jt(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Yt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Xt(e,t){let n=t.indexOf(`
|
|
3
3
|
`);if(n===-1)return null;let r,i;try{r=Yt(JSON.parse(t.slice(0,n))),i=Yt(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=Yt(e);t===null||typeof t.name!=`string`||!It(t.name)||a.push({name:t.name,pid:Jt(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:Jt(t.rpages),lifetimeMaxPages:Jt(t.lifetimeMax)})}let o=Nt(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:Jt(Yt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?It(i.largestProcess):null,ownedProcesses:a}}const Zt=/^JetsamEvent-.*\.ips$/;function Qt(e,t,n,r){let i=e.flatMap(({file:e,mtimeMs:n})=>n!==null&&n>=t?[{file:e,mtimeMs:n}]:[]);return i.sort((e,t)=>r===`newest-first`?t.mtimeMs-e.mtimeMs:e.mtimeMs-t.mtimeMs),{files:i.slice(0,n).map(({file:e})=>e),statFailed:e.filter(({mtimeMs:e})=>e===null).length,droppedOverCap:Math.max(0,i.length-n)}}async function $t(e,t){let n=Gt(`darwin`,`macos-jetsam`,[z(e,`JetsamEvent-*.ips`)]),r;try{r=await ut(e)}catch(e){return Kt(n,e.code??`unknown`)}let i=Qt(await Promise.all(r.filter(e=>Zt.test(e)).map(async t=>{try{return{file:t,mtimeMs:(await dt(z(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-zt,50,`newest-first`);n.unparseable+=i.statFailed,n.droppedOverCap=i.droppedOverCap;for(let t of i.files){let r=null;try{r=Xt(t,await lt(z(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return qt(n)}const en=[`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Out of memory|oom-kill|Killed process|Killed /|memory pressure`,`_TRANSPORT=kernel`,`+`,`_SYSTEMD_UNIT=systemd-oomd.service`],tn=[`--user`,`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Fatal Wayland communication error|Wayland protocol error|X IO error|Missing X server`],nn=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/,rn=/\[(\d+)(?::\d+)?:\d{4}\/\d{6}\.\d+:[A-Z0-9]+:[^\]]*\]\s*(.*)$/,an=/^desktop\.\d{4}-\d{2}-\d{2}\.log$/;async function on(e,t){let n=new Set,r;try{r=await ut(e)}catch{return{pids:n,unreadable:!0}}let i=!1;for(let a of r){if(!an.test(a))continue;let r=z(e,a);try{if(t.getTime()-(await dt(r)).mtimeMs>zt)continue;for(let e of(await lt(r,`utf8`)).split(`
|
|
4
4
|
`)){if(!e.includes(`"event":"desktop.boot"`))continue;let t=/"pid":(\d+)/.exec(e)?.[1];t!==void 0&&n.add(Number(t))}}catch{i=!0}}return{pids:n,unreadable:i}}function sn(e,t){if(e===`systemd-oomd`){let e=/^Killed (\S+)/.exec(t);if(e===null)return null;let n=e[1]?.split(`/`).pop()??``;return{origin:`systemd-oomd`,action:`oomd-kill`,pid:null,processName:null,unit:Bt.test(n)?n:null,trigger:/swap used/.test(t)?`swap`:/memory pressure/.test(t)?`memory-pressure`:null}}if(e!==`kernel`)return null;let n=/Killed process (\d+) \(([^)]+)\)/.exec(t);if(n!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(n[1]),processName:n[2]??null,unit:null,trigger:null};let r=/task=([^,]+),pid=(\d+)/.exec(t);if(r!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(r[2]),processName:r[1]??null,unit:null,trigger:null};let i=/^(\S+) invoked oom-killer/.exec(t);return i===null?null:{origin:`kernel`,action:`oom-invoked`,pid:null,processName:i[1]??null,unit:null,trigger:null}}function cn(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
@@ -12,5 +12,5 @@ import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$l as t,Bf as n,Da as
|
|
|
12
12
|
`)?`
|
|
13
13
|
`:``;K(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Qn(n,t.contentDirSpellings);r!==n&&K(e,r)}}function rr(e,t){let n=W(e,`utf-8`),r=Qn(n,t.contentDirSpellings);r!==n&&K(e,r)}function ir(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>z(e,t.name))}catch{return[]}}const ar=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function or(e){return/\.log\.\d+$/.test(e)}function sr(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||or(e)}const cr=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function lr(e){let t={contentDirSpellings:Zn(e.contentDir)};for(let n of cr)for(let r of ir(z(e.stagingDir,n)))sr(r)?tr(r,t):r.endsWith(`.json`)?nr(r,t):rr(r,t);for(let n of ir(z(e.stagingDir,`state`))){let e=L(n);n.endsWith(`.jsonl`)?tr(n,t):ar.has(e)?nr(n,t):rr(n,t)}}const ur=[`.ok`,`local`,`telemetry`],dr=[`.ok`,`local`,`logs`],fr=[`.ok`,`local`,`loss-capture`],pr=C.spansCurrent,mr=C.spansPrevious,hr=C.logsCurrent,gr=C.logsPrevious,_r=`loss-current.jsonl`,vr=`loss-prev.jsonl`;function yr(e){return z(e,...fr,_r)}function br(e){return z(e,...fr,vr)}const xr=1e3;async function Sr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(xr)});return t.ok?await t.text():null}catch{return null}}async function Cr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(xr)});return t.ok?await t.text():null}catch{return null}}async function wr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(xr)});return t.ok?await t.text():null}catch{return null}}function Tr(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(`
|
|
14
14
|
`)}\n`:null}catch{return null}}function Er(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=Le(`git`,[`-C`,t,`log`,`--oneline`,`-50`],ve({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Dr(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=Le(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],ve({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Or(){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 kr(){return{nodeVersion:process.version,platform:nt(),arch:$e()}}function Ar(){return process.env.OTEL_SDK_DISABLED===`false`}function jr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mr(e){if(!H(e))return{};let t;try{t=(0,qn.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(!jr(t))return{};let n=t.telemetry;if(!jr(n))return{};let r=n.localSink;return jr(r)?r:{}}function Nr(e){return typeof e==`boolean`?e:void 0}function Pr(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Fr(e){if(jr(e))return Pr(e.maxBytes)}function Ir(e){let t=Mr(T(`project`,e)),n=Mr(T(`project-local`,e));return{enabled:Nr(n.enabled)??Nr(t.enabled)??!0,spansMaxBytes:Fr(n.spans)??Fr(t.spans)??52428800,logsMaxBytes:Fr(n.logs)??Fr(t.logs)??26214400}}function Lr(e){return ct(`sha256`).update(e).digest(`hex`)}function Rr(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const zr=[`"doc.name"`,`"docName"`];function Br(e){let t=W(e,`utf-8`),n=0;for(let e of zr){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function X(e,t){if(!H(e))return!1;try{return U(R(t),{recursive:!0}),e.endsWith(`.ips`)?K(t,jt(W(e,`utf-8`))):He(e,t),!0}catch{return!1}}function Z(e,t,n,r){let i=H(e);X(e,z(n,r)),X(t,i?z(n,`legacy`,r):z(n,r))}function Vr(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=z(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Hr=new Set([`.jsonl`]);function Ur(e){let t=e.lastIndexOf(`.`);return t!==-1&&Hr.has(e.slice(t))}const Wr=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function Gr(e){if(or(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Wr.has(e.slice(t))}function Kr(e){let t=[];for(let n of Vr(e)){let r=qr(e,n);if(!Gr(r))continue;let{redacted:i,patterns:a,lineCount:o}=s(W(n,`utf-8`));a.length!==0&&(K(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function qr(e,t){return ze(e,t).split(V).join(`/`)}async function Jr(e){let t=B(e.contentDir),n=B(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Sr,a=r.fetchAgentEffects??Cr,o=r.fetchWatcherRecent??wr,s=r.readShadowHead??Er,c=r.readCheckpointRefs??Dr,l=r.now??(()=>new Date),u=r.okVersion??(()=>Pe),d=r.readDesktopEnv??Or,ee=r.readLanguage??Xn,f=r.readRuntime??kr,p=r.isOtlpPushEnabled??Ar,h=Ge(z(it(),`ok-bundle-`));try{U(z(h,`telemetry`),{recursive:!0}),U(z(h,`logs`),{recursive:!0}),U(z(h,`state`),{recursive:!0}),Z(he(n),z(n,...ur,pr),h,z(`telemetry`,pr)),Z(ne(n),z(n,...ur,mr),h,z(`telemetry`,mr)),Z(O(n),z(n,...dr,hr),h,z(`logs`,hr)),Z(se(n),z(n,...dr,gr),h,z(`logs`,gr));for(let t of e.userLogFiles??[])X(t,z(h,`logs`,L(t)));for(let t of e.userStateFiles??[])X(t,z(h,te,L(t)));let v=0;for(let t of e.diagnosticReports?.files??[])X(t,z(h,`diagnostic-reports`,L(t)))&&(v+=1);let b=z(n,`.ok`,`local`),S=z(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(H(S)){X(S,z(h,`state`,`server.lock`));try{let e=W(S,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(K(z(h,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&K(z(h,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=Tr(n);e!==null&&K(z(h,`state`,`watcher-recent.jsonl`),e)}}let re=s(t);re!==null&&K(z(h,`state`,`shadow-head.txt`),re);let E=c(t);E!==null&&K(z(h,`state`,`checkpoint-refs.txt`),E),X(yr(n),z(h,`state`,_r)),X(br(n),z(h,`state`,vr)),Z(oe(n),z(b,g),h,`state/last-spawn-error.log`),X(z(b,y),z(h,`state`,y)),X(z(b,m),z(h,`state`,m)),X(z(b,x),z(h,`state`,x));let D=f(),k=d(),A=ee(),j={ok:{version:u(),nodeVersion:D.nodeVersion,platform:D.platform,arch:D.arch},host:{desktop:k,language:A}};K(z(h,`state`,`runtime.json`),`${JSON.stringify(j,null,2)}\n`);let ie=C===`running`?`running
|
|
15
|
-
`:`not-running (${w})\n`;K(z(h,`state`,`server-status.txt`),ie);let ae=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Dt(e.diagnosticReports,v);if(K(z(h,`state`,`diagnostic-reports-status.txt`),`${ae}\n`),K(z(h,Rt),En(e.osTerminationEvidence)),e.processDir&&H(e.processDir)){let t=z(h,`process`);U(t,{recursive:!0}),He(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&(lr({stagingDir:h,contentDir:t}),lr({stagingDir:z(h,`legacy`),contentDir:t})),e.note&&K(z(h,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=Kr(h));for(let t of e.extraFiles??[]){let e=t.zipName??L(t.sourcePath);if(!X(t.sourcePath,z(h,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=jn(t,`extra/${e}`);n!==null&&(N??={redactions:[],redactedLineCount:0},N.redactions.push(n),N.redactedLineCount+=n.lineCount)}let P=Ir(n),ce=Vr(h),le=[],ue=0,de=0;for(let e of ce){let t=qr(h,e),n=Qe(e).size,r=Ur(t)?Rr(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n;let i=t.startsWith(`legacy/`)?t.slice(7):t;(i.startsWith(`telemetry/`)||i.startsWith(`logs/`))&&(de+=Br(e))}let fe={applied:M};N!==null&&(fe.secretScrub=N);let pe={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:D.nodeVersion,platform:D.platform,arch:D.arch},host:{desktop:k,language:A},contentDir:{pathSha256:Lr(t),absolutePath:M?`<CONTENT_DIR>`:t},telemetry:{localSink:{...P,directory:_(`logs`,`projects`)},otlpPushEnabled:p()},redaction:fe,serverStatus:C,files:le};K(z(h,`manifest.json`),`${JSON.stringify(pe,null,2)}\n`);let me=Zn(t),ge=ce.some(e=>{try{let t=W(e,`utf-8`);return me.some(e=>t.includes(e))}catch{return!1}}),F={stagedDiagnosticReports:v,totalBytes:ue,fileCount:le.length,docNameCount:de,contentDirVisible:ge,redacted:M},_e=!1;return{stagingDir:h,manifest:pe,summary:F,cleanup:()=>{_e||(_e=!0,Xe(h,{recursive:!0,force:!0}))}}}catch(e){throw Xe(h,{recursive:!0,force:!0}),e}}async function Yr(e){let{collected:t,outputPath:n}=e,r=R(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 Jn.ZipFile,a=Vr(t.stagingDir);for(let e of a){let n=qr(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 Xr(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,qn.parse)(W(n,`utf-8`)),r=Ne(t)?t.content:void 0,i=Ne(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 Zr(e,t,n,r,i,a){let o=Mn(t,e.logger),s=await Jr({contentDir:Xr(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...In(o,e.userLogsDir??z(A(),`logs`)),...Rn(e.cachesDir??z(q(),`Library`,`Caches`))],userStateFiles:Bn(e.bugReportsDir??kn()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(R(e.outputPath),{recursive:!0}),await Yr({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function Qr(e){let{projectDir:t}=e,n=e.readDesktopEnv??Or,r=e.readLanguage??Xn,i=()=>Lt(e.diagnosticReportsDir??z(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Zr(e,t,n,r,i(),await wn(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await Kn({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:Rn(e.cachesDir??z(q(),`Library`,`Caches`)),bugReportLedgerFiles:Bn(e.bugReportsDir??kn()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await wn(e.osTerminationEvidenceDeps):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 Q(e,t,n={}){let r=N(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,text:i}}let o=a&&typeof a==`object`?a:{},s=fe(o),c=s&&!me(o,n);if(!a||typeof a!=`object`||!pe(a.pid))return{status:`corrupt`,lockPath:r,text:i,...c?{foreignHost:!0}:{}};let l=D(a),{pid:u}=l;if(c)return{status:`foreign-host`,lockPath:r,lock:l};let d=ce(l,{isAlive:n.isAlive,readProcessStart:n.readProcessStart,readBootInstant:n.readBootInstant,sameMachine:s});switch(d.verdict){case`gone`:return{status:`dead-pid`,lockPath:r,lock:l,text:i};case`replaced`:return{status:`reused-pid`,lockPath:r,lock:l,text:i};case`unverified`:return d.cause===`unverified-owner`?{status:`unverified-owner`,lockPath:r,pid:u}:{status:`alive`,lockPath:r,lock:l};case`writer`:return{status:`alive`,lockPath:r,lock:l};default:return d}}function $r(e){return`does not record its owning machine, and its recorded process ${e} is still running on this machine`}function ei(e){return typeof e.machineId==`string`?`records a machine ID different from the one in ${w()}`:`records only the host ${Ae(e.hostname)}, not this machine's ${tt()}`}function ti(e){return e===`win32`?`USERPROFILE`:`HOME`}function ni(e){return e.processStart===void 0?` This lock records no process start; a server started by this release records one, which lets \`${o()} stop\` confirm it from any home folder.`:``}function ri(e,t){let n=`\`${o()} stop\``;return`If the server was started on this machine from another account, run ${n} as that account. If it was started from this account with a different home folder, run ${n} with \`${ti(t)}\` set to that folder. Otherwise stop it from the machine that owns the lock.${ni(e)}`}function ii(e,t){let n=o();return`If the server was started on this machine from another account, run \`${n} stop\` as that account while it is running, or \`${n} clean\` once it has exited. If it was started from this account with a different home folder, run the same command with \`${ti(t)}\` set to that folder. Otherwise run the same command on the machine that owns the lock.${ni(e)}`}function ai(e){return`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} and retry cleanup.`}function oi(e,t=process.platform){let{lock:n,lockPath:r}=e;return`${typeof n.machineId==`string`?ii(n,t):`If ${Ae(n.hostname)} is another machine, stop OpenKnowledge there; if it is an earlier name of this machine, stop OpenKnowledge here if it is still running.`} ${ai(r)}`}function si(e,t=process.platform){let{lockPath:n}=e;return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${n} ${$r(e.pid)}. 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.`:e.status===`corrupt`?`Cannot verify shutdown: the server lock at ${n} records a machine ID or host name that is not this machine's, so its server may run on another machine, or on this one from another account, with a different home folder, or under an earlier host name. Stop OpenKnowledge wherever it was started. ${ai(n)}`:`Cannot verify shutdown: the server lock at ${n} ${ei(e.lock)}. ${oi(e,t)}`}function ci(e){return e.replace(/:\d+$/,``)}function li(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:ci(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:ci(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:ci(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 ui=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function di(e){return a(S(),e)}function fi(){return u(S())}function pi(){let e=S();if(e===`stable`)return ui;let t=c(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const mi={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>We(e),readlinkSync:e=>Je(e)};function hi(e,t=mi){let n=di(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function gi(e){let t=e.replace(pi(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function _i(e,t,n=mi){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const vi=[{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`}],yi=[...M.map(e=>ge[e]),`open-knowledge`];function bi(e){if(!Re(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||R(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function xi(e,t){let n=ze(e,t);if(n.startsWith(`..`)||Re(n))return!1;let r=e;for(let e of n.split(V)){r=z(r,e);try{if(!We(r).isDirectory())return!1}catch{return!1}}return!0}function Si(e,t){try{return G(e).every(n=>t.has(z(e,n)))}catch{return!1}}function Ci(e){let t=bi(e),n=[],r=[],i=new Set;for(let e of vi){let a=z(t,e.hostDir,`skills`);if(!xi(t,a))continue;let o=yi.map(e=>z(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=z(t,e.pruneRoot),c=a;for(;Si(c,i)&&(r.push(c),i.add(c),c!==s);){let e=R(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function wi(e){try{if(!We(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Ti(e){let t=new Set,n=new Set;for(let r of vi){let i=z(e,r.hostDir,`skills`);for(let e of yi)t.add(z(i,e));let a=z(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=R(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Ei(e,t){let n=bi(e),r=Ti(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(xi(n,e)&&wi(e))try{Xe(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(xi(n,e))try{Ze(e),a.push(e)}catch{}return a}function Di(e){let t=bi(e),n=[];for(let e of M){let r=ge[e];n.push({path:z(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let a of i)n.push({path:z(t,a.skillsRoot,r),bundleId:e,scope:`host`,hostDir:a.hostDir})}return n}function Oi(e,t){let n=[];for(let r of Di(e))if(r.bundleId===t)try{Xe(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 ki(e){if(!e||typeof e!=`object`)return String(e);let t=typeof e.readProcessStart;return`${we(e)} readProcessStart=${t}`}function Ai(e,t={}){if(!Number.isSafeInteger(e)||e<=0||e>4294967295)return null;let n=t.arch??process.arch,r=(e,n,r)=>{Ee(n,r),t.onNativeFailure?.({kind:e,reason:Te(n,r)})};try{let i=!1,a=Ce(t.nativeResolver,(e,t)=>{i=!0,r(`unavailable`,e,t)});if(!a||typeof a!=`object`||!(`readProcessStart`in a)||typeof a.readProcessStart!=`function`){let e;return e=a==null?i?`no usable binding was returned`:`the addon was not found`:ki(a),r(`unavailable`,`the Windows native addon (native-config.win32-${n}-msvc.node) did not load or does not export readProcessStart`,e),null}let o=a.readProcessStart(e);return typeof o==`number`&&Number.isSafeInteger(o)&&o>=0?o:(r(`unavailable`,`readProcessStart returned an invalid value`,we(o)),null)}catch(e){return r(`query-failed`,`readProcessStart failed`,e),null}}function ji(e,t={}){return ye(e,{platform:t.platform,readNative:e=>Ai(e,{onNativeFailure:t.onNativeFailure})})}function Mi(e){let{platform:t,pid:n,nativeFailures:r,causeRecorded:i}=e,a=r.some(e=>{switch(e.kind){case`unavailable`:return!0;case`query-failed`:return!1;default:return e.kind}}),o=r.length===0?``:a?`Reinstall OpenKnowledge to restore the Windows component that verifies process identity. `:`The Windows component loaded but the operating system refused the query, so reinstalling will not help; retry from an account that can inspect that process. `;return(t===`linux`?`Linux reads the process start from /proc/${n}/stat and /proc/stat; restore read access to /proc and retry. `:t===`darwin`?`macOS reads the process start with ps, and that read failed, as it does inside some sandboxes; retry from a shell where ps can run. `:t===`win32`?o:``)+(r.length>0&&i?`The failure detail is recorded in the CLI log under ${_(`logs`)}. `:``)}function Ni(e){let t=new Set;return re(n=>{let r=[],i=Ai(n,{onNativeFailure:e=>{r.push(e)}});for(let i of new Set(r.map(e=>e.kind)))t.has(i)||(t.add(i),(e??ke())?.warn({event:`process-start-native-failure`,lockPid:n,kind:i,reasons:r.filter(e=>e.kind===i).map(e=>e.reason)},`the Windows process-start query failed, so lock holders cannot be verified; later failures of this kind are not recorded again`));return i})}function Pi(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Fi(e,t=Date.now()){if(e===null)return`—`;let n=mt(e,t);return n===`unknown`?`—`:n}function Ii(e){let t=R(e);return L(e)===`local`&&L(t)===`.ok`?R(t):L(e)===`.ok`?t:null}function Li(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:Ii(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`&&k(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:_e(n),command:n,isDesktop:Pi(n)}}function Ri(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`:case`reused-pid`:return`stale`;default:return t}}const zi=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Bi(e){switch(e){case`running`:return Y.default.green(e);case`desktop`:return Y.default.blue(e);case`foreign`:return Y.default.cyan(e);case`unverified`:case`stale`:return Y.default.yellow(e)}}function Vi(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Hi(e){return`${Vi(e.server.usage)} | ${Vi(e.ui?.usage??null)}`}function Ui(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Wi(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??`—`,Ui(e),Hi(e),Ri(e),String(e.server.pid),Fi(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(),s=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=Bi(Ri(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),c=Y.default.dim(`To stop a server: ${o()} stop <port|pid|directory|all>`);return[a,...s,``,c].join(`
|
|
15
|
+
`:`not-running (${w})\n`;K(z(h,`state`,`server-status.txt`),ie);let ae=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Dt(e.diagnosticReports,v);if(K(z(h,`state`,`diagnostic-reports-status.txt`),`${ae}\n`),K(z(h,Rt),En(e.osTerminationEvidence)),e.processDir&&H(e.processDir)){let t=z(h,`process`);U(t,{recursive:!0}),He(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&(lr({stagingDir:h,contentDir:t}),lr({stagingDir:z(h,`legacy`),contentDir:t})),e.note&&K(z(h,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=Kr(h));for(let t of e.extraFiles??[]){let e=t.zipName??L(t.sourcePath);if(!X(t.sourcePath,z(h,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=jn(t,`extra/${e}`);n!==null&&(N??={redactions:[],redactedLineCount:0},N.redactions.push(n),N.redactedLineCount+=n.lineCount)}let P=Ir(n),ce=Vr(h),le=[],ue=0,de=0;for(let e of ce){let t=qr(h,e),n=Qe(e).size,r=Ur(t)?Rr(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n;let i=t.startsWith(`legacy/`)?t.slice(7):t;(i.startsWith(`telemetry/`)||i.startsWith(`logs/`))&&(de+=Br(e))}let fe={applied:M};N!==null&&(fe.secretScrub=N);let pe={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:D.nodeVersion,platform:D.platform,arch:D.arch},host:{desktop:k,language:A},contentDir:{pathSha256:Lr(t),absolutePath:M?`<CONTENT_DIR>`:t},telemetry:{localSink:{...P,directory:_(`logs`,`projects`)},otlpPushEnabled:p()},redaction:fe,serverStatus:C,files:le};K(z(h,`manifest.json`),`${JSON.stringify(pe,null,2)}\n`);let me=Zn(t),ge=ce.some(e=>{try{let t=W(e,`utf-8`);return me.some(e=>t.includes(e))}catch{return!1}}),F={stagedDiagnosticReports:v,totalBytes:ue,fileCount:le.length,docNameCount:de,contentDirVisible:ge,redacted:M},_e=!1;return{stagingDir:h,manifest:pe,summary:F,cleanup:()=>{_e||(_e=!0,Xe(h,{recursive:!0,force:!0}))}}}catch(e){throw Xe(h,{recursive:!0,force:!0}),e}}async function Yr(e){let{collected:t,outputPath:n}=e,r=R(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 Jn.ZipFile,a=Vr(t.stagingDir);for(let e of a){let n=qr(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 Xr(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,qn.parse)(W(n,`utf-8`)),r=Ne(t)?t.content:void 0,i=Ne(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 Zr(e,t,n,r,i,a){let o=Mn(t,e.logger),s=await Jr({contentDir:Xr(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...In(o,e.userLogsDir??z(A(),`logs`)),...Rn(e.cachesDir??z(q(),`Library`,`Caches`))],userStateFiles:Bn(e.bugReportsDir??kn()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(R(e.outputPath),{recursive:!0}),await Yr({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function Qr(e){let{projectDir:t}=e,n=e.readDesktopEnv??Or,r=e.readLanguage??Xn,i=()=>Lt(e.diagnosticReportsDir??z(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Zr(e,t,n,r,i(),await wn(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await Kn({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:Rn(e.cachesDir??z(q(),`Library`,`Caches`)),bugReportLedgerFiles:Bn(e.bugReportsDir??kn()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await wn(e.osTerminationEvidenceDeps):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 Q(e,t,n={}){let r=N(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,text:i}}let o=a&&typeof a==`object`?a:{},s=fe(o),c=s&&!me(o,n);if(!a||typeof a!=`object`||!pe(a.pid))return{status:`corrupt`,lockPath:r,text:i,...c?{foreignHost:!0}:{}};let l=D(a),{pid:u}=l;if(c)return{status:`foreign-host`,lockPath:r,lock:l};let d=ce(l,{isAlive:n.isAlive,readProcessStart:n.readProcessStart,readBootInstant:n.readBootInstant,sameMachine:s});switch(d.verdict){case`gone`:return{status:`dead-pid`,lockPath:r,lock:l,text:i};case`replaced`:return{status:`reused-pid`,lockPath:r,lock:l,text:i};case`unverified`:return d.cause===`unverified-owner`?{status:`unverified-owner`,lockPath:r,pid:u}:{status:`alive`,lockPath:r,lock:l};case`writer`:return{status:`alive`,lockPath:r,lock:l};default:return d}}function $r(e){return`does not record its owning machine, and its recorded process ${e} is still running on this machine`}function ei(e){return typeof e.machineId==`string`?`records a machine ID different from the one in ${w()}`:`records only the host ${Ae(e.hostname)}, not this machine's ${tt()}`}function ti(e){return e===`win32`?`USERPROFILE`:`HOME`}function ni(e){return e.processStart===void 0?` This lock records no process start; a server started by this release records one, which lets \`${o()} stop\` confirm it from any home folder.`:``}function ri(e,t){let n=`\`${o()} stop\``;return`If the server was started on this machine from another account, run ${n} as that account. If it was started from this account with a different home folder, run ${n} with \`${ti(t)}\` set to that folder. Otherwise stop it from the machine that owns the lock.${ni(e)}`}function ii(e,t){let n=o();return`If the server was started on this machine from another account, run \`${n} stop\` as that account while it is running, or \`${n} clean\` once it has exited. If it was started from this account with a different home folder, run the same command with \`${ti(t)}\` set to that folder. Otherwise run the same command on the machine that owns the lock.${ni(e)}`}function ai(e){return`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} and retry cleanup.`}function oi(e,t=process.platform){let{lock:n,lockPath:r}=e;return`${typeof n.machineId==`string`?ii(n,t):`If ${Ae(n.hostname)} is another machine, stop OpenKnowledge there; if it is an earlier name of this machine, stop OpenKnowledge here if it is still running.`} ${ai(r)}`}function si(e,t=process.platform){let{lockPath:n}=e;return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${n} ${$r(e.pid)}. 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.`:e.status===`corrupt`?`Cannot verify shutdown: the server lock at ${n} records a machine ID or host name that is not this machine's, so its server may run on another machine, or on this one from another account, with a different home folder, or under an earlier host name. Stop OpenKnowledge wherever it was started. ${ai(n)}`:`Cannot verify shutdown: the server lock at ${n} ${ei(e.lock)}. ${oi(e,t)}`}function ci(e){return e.replace(/:\d+$/,``)}function li(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:ci(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:ci(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:ci(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 ui=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function di(e,t=process.platform,n=process.env){return a(S(),e,t,n.XDG_CONFIG_HOME)}function fi(){return u(S())}function pi(){let e=S();if(e===`stable`)return ui;let t=c(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const mi={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>We(e),readlinkSync:e=>Je(e)};function hi(e,t=mi,n=process.platform,r=process.env){let i=S(),o=di(e,n,r),s=a(i,e),c=t.existsSync(o)?o:i===`stable`&&n===`linux`&&t.existsSync(s)?s:null;if(c===null)return null;try{let e=JSON.parse(t.readFileSync(c,`utf8`));return e?.version===1?e:null}catch{return null}}function gi(e){let t=e.replace(pi(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function _i(e,t,n=mi){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const vi=[{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`}],yi=[...M.map(e=>ge[e]),`open-knowledge`];function bi(e){if(!Re(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||R(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function xi(e,t){let n=ze(e,t);if(n.startsWith(`..`)||Re(n))return!1;let r=e;for(let e of n.split(V)){r=z(r,e);try{if(!We(r).isDirectory())return!1}catch{return!1}}return!0}function Si(e,t){try{return G(e).every(n=>t.has(z(e,n)))}catch{return!1}}function Ci(e){let t=bi(e),n=[],r=[],i=new Set;for(let e of vi){let a=z(t,e.hostDir,`skills`);if(!xi(t,a))continue;let o=yi.map(e=>z(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=z(t,e.pruneRoot),c=a;for(;Si(c,i)&&(r.push(c),i.add(c),c!==s);){let e=R(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function wi(e){try{if(!We(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Ti(e){let t=new Set,n=new Set;for(let r of vi){let i=z(e,r.hostDir,`skills`);for(let e of yi)t.add(z(i,e));let a=z(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=R(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Ei(e,t){let n=bi(e),r=Ti(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(xi(n,e)&&wi(e))try{Xe(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(xi(n,e))try{Ze(e),a.push(e)}catch{}return a}function Di(e){let t=bi(e),n=[];for(let e of M){let r=ge[e];n.push({path:z(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let a of i)n.push({path:z(t,a.skillsRoot,r),bundleId:e,scope:`host`,hostDir:a.hostDir})}return n}function Oi(e,t){let n=[];for(let r of Di(e))if(r.bundleId===t)try{Xe(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 ki(e){if(!e||typeof e!=`object`)return String(e);let t=typeof e.readProcessStart;return`${we(e)} readProcessStart=${t}`}function Ai(e,t={}){if(!Number.isSafeInteger(e)||e<=0||e>4294967295)return null;let n=t.arch??process.arch,r=(e,n,r)=>{Ee(n,r),t.onNativeFailure?.({kind:e,reason:Te(n,r)})};try{let i=!1,a=Ce(t.nativeResolver,(e,t)=>{i=!0,r(`unavailable`,e,t)});if(!a||typeof a!=`object`||!(`readProcessStart`in a)||typeof a.readProcessStart!=`function`){let e;return e=a==null?i?`no usable binding was returned`:`the addon was not found`:ki(a),r(`unavailable`,`the Windows native addon (native-config.win32-${n}-msvc.node) did not load or does not export readProcessStart`,e),null}let o=a.readProcessStart(e);return typeof o==`number`&&Number.isSafeInteger(o)&&o>=0?o:(r(`unavailable`,`readProcessStart returned an invalid value`,we(o)),null)}catch(e){return r(`query-failed`,`readProcessStart failed`,e),null}}function ji(e,t={}){return ye(e,{platform:t.platform,readNative:e=>Ai(e,{onNativeFailure:t.onNativeFailure})})}function Mi(e){let{platform:t,pid:n,nativeFailures:r,causeRecorded:i}=e,a=r.some(e=>{switch(e.kind){case`unavailable`:return!0;case`query-failed`:return!1;default:return e.kind}}),o=r.length===0?``:a?`Reinstall OpenKnowledge to restore the Windows component that verifies process identity. `:`The Windows component loaded but the operating system refused the query, so reinstalling will not help; retry from an account that can inspect that process. `;return(t===`linux`?`Linux reads the process start from /proc/${n}/stat and /proc/stat; restore read access to /proc and retry. `:t===`darwin`?`macOS reads the process start with ps, and that read failed, as it does inside some sandboxes; retry from a shell where ps can run. `:t===`win32`?o:``)+(r.length>0&&i?`The failure detail is recorded in the CLI log under ${_(`logs`)}. `:``)}function Ni(e){let t=new Set;return re(n=>{let r=[],i=Ai(n,{onNativeFailure:e=>{r.push(e)}});for(let i of new Set(r.map(e=>e.kind)))t.has(i)||(t.add(i),(e??ke())?.warn({event:`process-start-native-failure`,lockPid:n,kind:i,reasons:r.filter(e=>e.kind===i).map(e=>e.reason)},`the Windows process-start query failed, so lock holders cannot be verified; later failures of this kind are not recorded again`));return i})}function Pi(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Fi(e,t=Date.now()){if(e===null)return`—`;let n=mt(e,t);return n===`unknown`?`—`:n}function Ii(e){let t=R(e);return L(e)===`local`&&L(t)===`.ok`?R(t):L(e)===`.ok`?t:null}function Li(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:Ii(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`&&k(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:_e(n),command:n,isDesktop:Pi(n)}}function Ri(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`:case`reused-pid`:return`stale`;default:return t}}const zi=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Bi(e){switch(e){case`running`:return Y.default.green(e);case`desktop`:return Y.default.blue(e);case`foreign`:return Y.default.cyan(e);case`unverified`:case`stale`:return Y.default.yellow(e)}}function Vi(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Hi(e){return`${Vi(e.server.usage)} | ${Vi(e.ui?.usage??null)}`}function Ui(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Wi(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??`—`,Ui(e),Hi(e),Ri(e),String(e.server.pid),Fi(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(),s=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=Bi(Ri(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),c=Y.default.dim(`To stop a server: ${o()} stop <port|pid|directory|all>`);return[a,...s,``,c].join(`
|
|
16
16
|
`)}async function Gi(e={}){let t=e.discover??I,n=e.inspect??(e=>Q(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??ae,a=e.resolveUsage??ue,o=await t(),s=[];for(let e of o){let t=n(e),r=Li(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Ri(e)}));r(JSON.stringify(e,null,2));return}r(Wi(e.all?s:s.filter(e=>zi.has(Ri(e)))))}function Ki(){return new Oe(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale 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 Gi({all:t.all===!0||e===`all`,json:t.json===!0})})}async function qi(e,t=ke()){let n=Q(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=E(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 Ji(e,t={}){return $(e,t.isAlive??F)?{targets:[{name:`server`,pid:e.lock.pid,port:e.lock.port}],lock:e.lock}:{targets:[]}}function Yi(e){try{return S()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function Xi(e){let t=e.inspect??(()=>Q(e.lockDir,`server`)),r=e.kill??((e,t)=>process.kill(e,t)),i=e.log??(e=>console.log(e)),a=e.error??(e=>console.error(e)),s=e.probeClients??qi,c=e.logger??ke(),l=e.platform??process.platform,u=t(),d=Ji(u,{isAlive:e.isAlive}),{lock:f}=d,p=[],m=[],h=(t,n)=>{c?.warn({lockDir:e.lockDir,lockPath:n.lockPath,lockPid:n.pid,platform:l,cause:n.cause,...`nativeFailures`in n&&n.nativeFailures.length>0?{nativeFailures:n.nativeFailures}:{}},`stop declined: lock holder identity unverified`),m.push({target:t,error:$i(n,c!==void 0),unverified:n})},g=()=>{if(p.length>0){let e=p.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);i(`Stopped: ${e}`)}if(c?.info({lockDir:e.lockDir,signalled:p.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:m.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),m.length>0){let e=m.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `);a(`Failed to stop: ${e}`)}return{stopped:p,failed:m,hadTargets:!0}};if(u.status===`unverified-owner`){let{pid:e,lockPath:t}=u;return h({name:`server`,pid:e},{cause:`unverified-owner`,pid:e,lockPath:t}),g()}if(f===void 0)return i(`No running open-knowledge processes.`),c?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let _=u.status===`alive`||u.status===`foreign-host`?u.lock.channel:void 0;if(e.force!==!0&&typeof _==`string`&&_.length>0){let t=e.selfChannel??Yi(c);if(t!==void 0&&_!==t)return a(`Not stopping: the server at ${e.lockDir} belongs to ${ee(_)}. `+(_===`dev`?`Stop it from that dev build, or run \`${n} stop\` with OK_CHANNEL=dev set, or re-run with --force to terminate anyway.`:`Stop it from that app or its CLI, or re-run with --force to terminate anyway.`)),c?.warn({lockDir:e.lockDir,holderChannel:_,selfChannel:t,pids:d.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:_}}}if(e.force!==!0){let t=await s(e.lockDir,c);if(t!==null&&t>0)return a(`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.`),c?.warn({lockDir:e.lockDir,clients:t,pids:d.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}for(let t of d.targets){let n=[],s=(e.readProcessStart??ji)(t.pid,{platform:l,onNativeFailure:e=>{n.push(e)}}),c=ce(f,{isAlive:e.isAlive??F,readProcessStart:()=>s,refuseHolderStartedAfterLock:e.refuseHolderStartedAfterLock,platform:l,readBootInstant:e.readBootInstant});switch(c.verdict){case`writer`:try{r(t.pid,`SIGTERM`),p.push(t)}catch(e){m.push({target:t,error:e instanceof Error?e.message:String(e)})}break;case`gone`:i(`${t.name} (pid=${t.pid}) had already exited`);break;case`replaced`:a(`Process ${t.pid} is no longer the server that wrote ${u.lockPath}; it was not signalled. Run \`${o()} clean\` to remove the stale lock.`);break;case`unverified`:h(t,Zi(c.cause,{pid:t.pid,lockPath:u.lockPath,lock:f,platform:l,nativeFailures:n}));break;default:return c}}return g()}function Zi(e,t){let{pid:n,lockPath:r}=t;switch(e){case`foreign-host`:return{cause:e,pid:n,lockPath:r,lock:t.lock,platform:t.platform};case`unverified-owner`:return{cause:e,pid:n,lockPath:r};default:return{cause:e,pid:n,lockPath:r,platform:t.platform,nativeFailures:t.nativeFailures}}}const Qi=`it was not signalled, and --force does not override this check.`;function $i(e,t){let{pid:n,lockPath:r}=e;switch(e.cause){case`foreign-host`:{let{lock:t}=e;return typeof t.machineId==`string`?`The server lock at ${r} ${ei(t)}, so process ${n}, which is running on this machine, cannot be confirmed as the server that wrote it; ${Qi} ${ri(t,e.platform)}`:`The server lock at ${r} ${ei(t)}, and the start of process ${n}, which is running on this machine, does not confirm it as the server that wrote the lock; ${Qi} If ${Ae(t.hostname)} is another machine, stop the server there. If it is an earlier name of this machine, confirm that process ${n} is an OpenKnowledge server before ending it yourself, and once no OpenKnowledge server is running for this project, remove ${r}.`}case`unverified-owner`:return`The server lock at ${r} ${$r(n)}, so it cannot be confirmed as the server that wrote the lock; ${Qi} Check whether process ${n} is an OpenKnowledge server, and if it is, stop it yourself. Do not remove the lock file while that process is running.`;default:{let n=ea(e,Qi,`Once you have confirmed no OpenKnowledge server is running for this project, remove ${r}.`,t);return e.cause===`writer-identity-unrecorded`?`${n} A server you start again with this release records its machine ID, so \`${o()} stop\` can confirm it.`:n}}}function ea(e,t,n,r){let{pid:i,lockPath:a,platform:o,nativeFailures:s}=e,c=`Before ending process ${i} yourself, confirm that it is an OpenKnowledge server.`;switch(e.cause){case`process-start-unreadable`:return`Could not read when process ${i} started, so it cannot be confirmed as the server that wrote ${a}; ${t} `+Mi({platform:o,pid:i,nativeFailures:s,causeRecorded:r})+`${c} ${n}`;case`process-start-incomparable`:return`The start of process ${i} cannot be compared with the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-start-mismatch`:return`Process ${i} started before the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-started-after-lock`:return`Process ${i} started after the server lock at ${a} was written, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`recorded-start-in-future`:return`The server lock at ${a} records a start later than the current time on this machine, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;case`writer-identity-unrecorded`:return`The server lock at ${a} records neither a machine ID nor a process start, as locks written by version 0.25.0 and earlier do, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;default:return e.cause}}function $(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function ta(e,t=F){let n=await I(),r=null;for(let i of n){let n=Q(i,`server`);if($(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}function na(e){(e.failed.length>0||e.declined!==void 0)&&(process.exitCode=1)}async function ra(e,t){let n=await Xi({lockDir:e,force:t});return na(n),n}function ia(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 \`${o()} ps\` to list them`}.`}async function aa(e){let t=await I(),n=0;for(let r of t)r!==e&&$(Q(r,`server`),F)&&n++;return n}function oa(e){return new Oe(`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 the server belongs to another OpenKnowledge app (Stable, Beta or a dev build run from source) or editor windows or agents are still connected to it`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=ie(process.cwd()),n=[],i=await Xi({lockDir:t,force:r,log:e=>n.push(e)});if(i.hadTargets){for(let e of n)console.log(e);na(i)}else{let e=await aa(t);console.log(ia(process.cwd(),e,{listingFollows:e>0})),e>0&&await Gi({})}return}if(i===`all`){let e=await I();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)$(Q(n,`server`),F)&&(await ra(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 ta(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await ra(t,r);return}let a=B(yt(),i),o=ie(a),s=[],c=await Xi({lockDir:o,force:r,log:e=>s.push(e)});if(na(c),c.hadTargets)for(let e of s)console.log(e);else console.log(ia(a,await aa(o)))})}export{Lt as A,Qr as C,kn as D,An as E,wt as F,Tt as I,yt as L,bt as M,St as N,wn as O,xt as P,vt as R,Q as S,Yr as T,gi as _,Ki as a,ei as b,Ei as c,Di as d,ui as f,hi as g,fi as h,oa as i,Dt as j,On as k,Ci as l,di as m,qi as n,ji as o,_i as p,Xi as r,Ni as s,ea as t,Oi as u,li as v,Jr as w,si as x,oi as y,gt as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./md-manager-BGnqyqi1-DW5IsDjR.mjs";import"./src-BnTt3RNV.mjs";import"./init-Bam41vCv.mjs";import"./registry-probes-BCdRmBhQ.mjs";import"./start-Dij8Dt2x.mjs";import{n as e}from"./loader-xTK_xs3Y.mjs";import"./preview-D_lbKRQL.mjs";import"./repair-mcp-configs-CKZK9Yyu.mjs";export{e as loadConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,m as t,p as n,r}from"./start-Dij8Dt2x.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{C as e,I as t,Il as n,Kf as r,Pd as i,Q as a,Z as o,i as s}from"./md-manager-BGnqyqi1-
|
|
2
|
-
`)){let e=r.replace(he,``),i=fe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(pe.test(e)){n=void 0;continue}n&&me.test(e)&&(n.active=!0)}return t}const _e={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){h(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ve(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 ye(e,t,n,r,i){let a=y[e];try{let o=N(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&h(`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`),ve(o.kind)}catch(i){return h(`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 be(e,t,n){if(y[e].scope!==`global`)return q();if(n===`absent`)return ye(e,``,t.home,void 0,t.env);let r=(await C({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 xe(e,t,n){let r=y[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ye(e,t.cwd,t.home,r,t.env);let i=b(y[e],t.cwd,_e,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Se(e,t,n){let r=t.home??re();if(n===`absent`){let t=P(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=E(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 Ce(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 we(e){return t=>{if(t.pathId===void 0)return Y();let n=i(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return be(n.editor,e,t.desired);case`editor-project-config`:return xe(n.editor,e,t.desired);case`editor-project-skill-root`:return Ce(n.editor,e,t.desired);case`editor-user-skill-root`:return Se(n.editor,e,t.desired)}}}function Te(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Ee(e){if(e===`server`)return e;throw new v(`--only must be 'server'`)}function De(e=H,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[V(t,`public`),V(t,`../../app/dist`),V(t,`../../../app/dist`)];return e(V(t,`../../app.asar`))&&n.push(V(t,`../../app`)),n.find(t=>e(t))}function Oe(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 ke(e){if(e===`off`)return`off`;if(!n.test(e))throw new v(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function Ae(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function je(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Me(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||Ae(e.host))&&e.isTTY}function Ne(e,t){let n;try{n=new URL(t)}catch{throw new v(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new v(`${e} must be an http(s) origin (got: ${t})`);return t}function Pe(e){return Ne(`--external-url`,e)}function Fe(e){let t=z(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 \`${r()} init\` first, then \`${r()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${r()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?V(e):null}},a=V(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(B(a));o=e===null?null:V(e,z(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&B(o)===s&&z(o).startsWith(`ok-ephemeral-`)}function Ie(e,t,n=e=>ae(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 ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Le(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function $(e){let{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:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-Cdi2gf6r.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?u(e.singleFile).canonicalFilePath:void 0,E=w?l(w):void 0,D=w?c(w):void 0,O,k=!1;if(E!==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,E)}else O=h(E),k=!0}let j=async()=>{if(!(!k||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 ae(O,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},N=O;if(!C){if(!i&&!m(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-Cxupq-9r.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-c_BJk9kA.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),S.info({contentDir:P},`Created content directory`));let te=T(),L=f(),R;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`)}R=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:ue,tokenStore:te,embeddingsKeyStore:L,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)=>M(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>F(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:re(),env:process.env};return{probe:I(e),execute:we(e),userSkillPresentAnywhere:A}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Le(N===void 0?n:Ie(n,N),{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 z=R.destroy,B=k?async(...e)=>{try{await z(...e)}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:P,port:R.port,ready:R.ready,degraded:R.degraded}}function Re(e,t,n=()=>d({absPath:c(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function ze(e){if(e===`browser`||e===`app`)return e;throw new v(`--mode must be 'browser' or 'app'`)}function Be(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Ve(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 He(n,r){let i=Re(n,r.singleFile),c=Be(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=Fe(m);let h;try{h=o(process.env)}catch(e){throw e instanceof s&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=e(i,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=a(g),S=v??(_||b===void 0?[...x.bind]:[b]);je({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=a(e(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 ee=r.port===void 0?void 0:Number(r.port),D=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=ee??D??i.server?.port,k=Oe({explicitDir:r.reactShellDistDir,only:r.only,findBundledDir:De}),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 $({config:i,cwd:m,host:C,port:O,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{C as e,I as t,Il as n,Kf as r,Pd as i,Q as a,Z as o,i as s}from"./md-manager-BGnqyqi1-DW5IsDjR.mjs";import{Bs as c,Ei as l,Ki as u,Rs as d,ji as f,k as p,mi as m,ws as h}from"./dist-DAAU-wLM.mjs";import{Et as g,R as _,Tt as v,Z as y,b,dt as x,wt as S,x as C,z as w}from"./init-Bam41vCv.mjs";import{C as T,a as E,c as ee,d as D,g as O,h as k,i as A,m as j,n as M,o as N,r as P,s as F,t as I}from"./registry-probes-BCdRmBhQ.mjs";import{n as te}from"./constants-DkmpmTiN.mjs";import{execFileSync as L,spawn as R}from"node:child_process";import{basename as z,dirname as B,resolve as V}from"node:path";import{existsSync as H,realpathSync as ne}from"node:fs";import{homedir as re,tmpdir as ie}from"node:os";import{rm as ae}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";const se=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ce={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function le(e,t={}){let{login:n}=t,r=t._exec??L,i=U(t._fileExists??H),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`,...se.filter(e)]}function W(e,t,n){for(let r of t)try{let t=e(r,n,ce).toString().trim();if(t.length>0)return t}catch{}}function ue(e,t={}){let n=t._exec??L,r=U(t._fileExists??H),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=W(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=de(a,e);if(t)return t}let o=W(n,r,i);if(o!==void 0){let e=ge(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function de(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 fe=/Logged in to \S+ account (\S+) \(/,pe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,me=/^\s*-\s*Active account:\s*true\s*$/,he=/\u001b\[[0-9;]*m/g;function ge(e){let t=[],n;for(let r of e.split(`
|
|
2
|
+
`)){let e=r.replace(he,``),i=fe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(pe.test(e)){n=void 0;continue}n&&me.test(e)&&(n.active=!0)}return t}const _e={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){h(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ve(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 ye(e,t,n,r,i){let a=y[e];try{let o=N(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&h(`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`),ve(o.kind)}catch(i){return h(`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 be(e,t,n){if(y[e].scope!==`global`)return q();if(n===`absent`)return ye(e,``,t.home,void 0,t.env);let r=(await C({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 xe(e,t,n){let r=y[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ye(e,t.cwd,t.home,r,t.env);let i=b(y[e],t.cwd,_e,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Se(e,t,n){let r=t.home??re();if(n===`absent`){let t=P(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=E(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 Ce(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 we(e){return t=>{if(t.pathId===void 0)return Y();let n=i(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return be(n.editor,e,t.desired);case`editor-project-config`:return xe(n.editor,e,t.desired);case`editor-project-skill-root`:return Ce(n.editor,e,t.desired);case`editor-user-skill-root`:return Se(n.editor,e,t.desired)}}}function Te(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Ee(e){if(e===`server`)return e;throw new v(`--only must be 'server'`)}function De(e=H,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[V(t,`public`),V(t,`../../app/dist`),V(t,`../../../app/dist`)];return e(V(t,`../../app.asar`))&&n.push(V(t,`../../app`)),n.find(t=>e(t))}function Oe(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 ke(e){if(e===`off`)return`off`;if(!n.test(e))throw new v(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function Ae(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function je(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Me(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||Ae(e.host))&&e.isTTY}function Ne(e,t){let n;try{n=new URL(t)}catch{throw new v(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new v(`${e} must be an http(s) origin (got: ${t})`);return t}function Pe(e){return Ne(`--external-url`,e)}function Fe(e){let t=z(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 \`${r()} init\` first, then \`${r()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${r()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?V(e):null}},a=V(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(B(a));o=e===null?null:V(e,z(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&B(o)===s&&z(o).startsWith(`ok-ephemeral-`)}function Ie(e,t,n=e=>ae(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 ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Le(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function $(e){let{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:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-CVvHVQuh.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?u(e.singleFile).canonicalFilePath:void 0,E=w?l(w):void 0,D=w?c(w):void 0,O,k=!1;if(E!==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,E)}else O=h(E),k=!0}let j=async()=>{if(!(!k||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 ae(O,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},N=O;if(!C){if(!i&&!m(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-CKZK9Yyu.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-DIJ8uSXj.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),S.info({contentDir:P},`Created content directory`));let te=T(),L=f(),R;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`)}R=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:ue,tokenStore:te,embeddingsKeyStore:L,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)=>M(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>F(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:re(),env:process.env};return{probe:I(e),execute:we(e),userSkillPresentAnywhere:A}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Le(N===void 0?n:Ie(n,N),{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 z=R.destroy,B=k?async(...e)=>{try{await z(...e)}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:P,port:R.port,ready:R.ready,degraded:R.degraded}}function Re(e,t,n=()=>d({absPath:c(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function ze(e){if(e===`browser`||e===`app`)return e;throw new v(`--mode must be 'browser' or 'app'`)}function Be(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Ve(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 He(n,r){let i=Re(n,r.singleFile),c=Be(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=Fe(m);let h;try{h=o(process.env)}catch(e){throw e instanceof s&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=e(i,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=a(g),S=v??(_||b===void 0?[...x.bind]:[b]);je({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=a(e(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 ee=r.port===void 0?void 0:Number(r.port),D=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=ee??D??i.server?.port,k=Oe({explicitDir:r.reactShellDistDir,only:r.only,findBundledDir:De}),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 $({config:i,cwd:m,host:C,port:O,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-CVvHVQuh.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitProbeTimeoutError||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)),Ge(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await Ue({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>oe(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]=We(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=Ke(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]=Ve(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await j.destroy(`external-signal`,{signal:e})}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 P=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${j.port}`,F=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,I=P;console.log(l({name:`open-knowledge`,version:te,localUrl:I,networkUrl:F,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let L={"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=L[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(Me({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-BLuYnAd6.mjs`);e(I)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function Ue(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:l(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 We(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 \`${r()} stop\` first if you want a fresh server.`]}function Ge(e,t,n){let r=t.ServerLockCollisionError;if(r!==void 0&&e instanceof r)return!0;let i=t.ServerAuthorityCollisionError;if(i===void 0||!(e instanceof i))return!1;try{return e.existing.scope.kind===`tree`&&ne.native(n)===e.existing.projectDir}catch{return!1}}function Ke(e,t,n){let i=n.ServerAuthorityCollisionError;if(i!==void 0&&e instanceof i)return e.message;let a=n.ServerAuthorityRegistryError;if(a!==void 0&&e instanceof a)return e.message;let o=n.ProcessLockFileError;if(o!==void 0&&e instanceof o)return e.message;let s=n.ServerLockCollisionError;if(s===void 0||!(e instanceof s))return null;try{let e=n.readServerLock(n.resolveLockDir(t)),i=r();return e?.kind===`mcp-spawned`?`An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run \`${i} stop\`.`:`OpenKnowledge server is already running on this project — check \`${i} status\` or \`${i} stop\`.`}catch{return null}}function qe(e){return new S(`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)`,Ee).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)`,ke).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ze).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 g(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new g(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new g(`--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).`,Pe).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=j(D());if(n.available){k({spawn:R},n);return}console.error(O(n.reason)),process.exit(1)}await He(n,t)})}export{Ke as C,ue as D,le as E,qe as S,Le as T,Be as _,We as a,Me as b,Q as c,ke as d,Ee as f,Re as g,Ue as h,Fe as i,Ge as l,Te as m,X as n,Ve as o,De as p,$ as r,Ae as s,Z as t,Pe as u,Oe as v,Ie as w,je as x,He as y};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.88.
|
|
3
|
+
"version": "0.88.4-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",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@parcel/watcher": "^2.5.6"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@inkeep/open-knowledge-app": "0.88.
|
|
69
|
-
"@inkeep/open-knowledge-core": "0.88.
|
|
68
|
+
"@inkeep/open-knowledge-app": "0.88.4-beta.0",
|
|
69
|
+
"@inkeep/open-knowledge-core": "0.88.4-beta.0",
|
|
70
70
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
71
|
-
"@inkeep/open-knowledge-server": "0.88.
|
|
71
|
+
"@inkeep/open-knowledge-server": "0.88.4-beta.0",
|
|
72
72
|
"@types/node": "^24.7.0",
|
|
73
73
|
"@types/proper-lockfile": "^4.1.4",
|
|
74
74
|
"@types/yazl": "^3.3.1",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./chunk-74CEPOFO-BuzahJu2.mjs";import{t as r}from"./chunk-SNN4IESC-CQKipF97.mjs";import{n as i,t as a}from"./chunk-2TRDZQLB-bwBxC32K.mjs";var o={name:`grep`,summary:`print lines that match patterns`,usage:`grep [OPTION]... PATTERN [FILE]...`,options:[`-E, --extended-regexp PATTERN is an extended regular expression`,`-P, --perl-regexp PATTERN is a Perl regular expression`,`-F, --fixed-strings PATTERN is a set of newline-separated strings`,`-i, --ignore-case ignore case distinctions`,`-v, --invert-match select non-matching lines`,`-w, --word-regexp match only whole words`,`-x, --line-regexp match only whole lines`,`-c, --count print only a count of matching lines`,`-l, --files-with-matches print only names of files with matches`,`-L, --files-without-match print names of files with no matches`,`-m NUM, --max-count=NUM stop after NUM matches`,`-n, --line-number print line number with output lines`,`-h, --no-filename suppress the file name prefix on output`,`-o, --only-matching show only nonempty parts of lines that match`,`-q, --quiet, --silent suppress all normal output`,`-r, -R, --recursive search directories recursively`,`-A NUM print NUM lines of trailing context`,`-B NUM print NUM lines of leading context`,`-C NUM print NUM lines of context`,`-e PATTERN use PATTERN for matching`,` --include=GLOB search only files matching GLOB`,` --exclude=GLOB skip files matching GLOB`,` --exclude-dir=DIR skip directories matching DIR`,` --help display this help and exit`]},s={name:`grep`,async execute(s,c){if(n(s))return t(o);let l=!1,f=!1,p=!1,m=!1,h=!1,g=!1,_=!1,v=!1,y=!1,b=!1,x=!1,S=!1,C=!1,w=!1,T=!1,E=0,D=0,O=0,k=[],A=[],j=[],M=null,N=[];for(let t=0;t<s.length;t++){let n=s[t];if(n.startsWith(`-`)&&n!==`-`){if(n===`-e`&&t+1<s.length){M=s[++t];continue}if(n.startsWith(`--include=`)){k.push(n.slice(10));continue}if(n.startsWith(`--exclude=`)){A.push(n.slice(10));continue}if(n.startsWith(`--exclude-dir=`)){j.push(n.slice(14));continue}if(n.startsWith(`--max-count=`)){E=parseInt(n.slice(12),10);continue}let r=n.match(/^-m(\d+)$/);if(r){E=parseInt(r[1],10);continue}if(n===`-m`&&t+1<s.length){E=parseInt(s[++t],10);continue}let i=n.match(/^-([ABC])(\d+)$/);if(i){let e=parseInt(i[2],10);i[1]===`A`?O=e:i[1]===`B`?D=e:i[1]===`C`&&(D=e,O=e);continue}if((n===`-A`||n===`-B`||n===`-C`)&&t+1<s.length){let e=parseInt(s[++t],10);n===`-A`?O=e:n===`-B`?D=e:(D=e,O=e);continue}let a=n.startsWith(`--`)?[n]:n.slice(1).split(``);for(let t of a)if(t===`i`||t===`--ignore-case`)l=!0;else if(t===`n`||t===`--line-number`)f=!0;else if(t===`v`||t===`--invert-match`)p=!0;else if(t===`c`||t===`--count`)m=!0;else if(t===`l`||t===`--files-with-matches`)h=!0;else if(t===`L`||t===`--files-without-match`)g=!0;else if(t===`r`||t===`R`||t===`--recursive`)_=!0;else if(t===`w`||t===`--word-regexp`)v=!0;else if(t===`x`||t===`--line-regexp`)y=!0;else if(t===`E`||t===`--extended-regexp`)b=!0;else if(t===`P`||t===`--perl-regexp`)x=!0;else if(t===`F`||t===`--fixed-strings`)S=!0;else if(t===`o`||t===`--only-matching`)C=!0;else if(t===`h`||t===`--no-filename`)w=!0;else if(t===`q`||t===`--quiet`||t===`--silent`)T=!0;else{if(t.startsWith(`--`))return e(`grep`,t);if(t.length===1)return e(`grep`,`-${t}`)}}else M===null?M=n:N.push(n)}if(M===null)return{stdout:``,stderr:`grep: missing pattern
|
|
2
|
-
`,exitCode:2};let P=S?`fixed`:b?`extended`:x?`perl`:`basic`,F,I,L;try{let e=a(M,{mode:P,ignoreCase:l,wholeWord:v,lineRegexp:y});F=e.regex,I=e.kResetGroup,L=e.preFilter}catch{return{stdout:``,stderr:`grep: invalid regular expression: ${M}
|
|
3
|
-
`,exitCode:2}}if(N.length===0&&c.stdin!==void 0){let e=i(c.stdin,F,{invertMatch:p,showLineNumbers:f,countOnly:m,filename:``,onlyMatching:C,beforeContext:D,afterContext:O,maxCount:E,kResetGroup:I,preFilter:L});return T?{stdout:``,stderr:``,exitCode:+!e.matched}:{stdout:e.output,stderr:``,exitCode:+!e.matched}}if(N.length===0)return{stdout:``,stderr:`grep: no input files
|
|
4
|
-
`,exitCode:2};let R=``,z=``,B=!1,V=!1,H=[];for(let e of N)if(e.includes(`*`)||e.includes(`?`)||e.includes(`[`)){let t=await u(e,c);if(_)for(let e of t){let t=await d(e.path,c,k,A,j,e.isFile);H.push(...t)}else H.push(...t)}else if(_){let t=await d(e,c,k,A,j);H.push(...t)}else H.push({path:e});let U=(H.length>1||_)&&!w;for(let e=0;e<H.length;e+=50){let t=H.slice(e,e+50),n=await Promise.all(t.map(async e=>{let t=e.path,n=t.split(`/`).pop()||t;if(A.length>0&&!_&&A.some(e=>r(n,e,{stripQuotes:!0}))||k.length>0&&!_&&!k.some(e=>r(n,e,{stripQuotes:!0})))return null;try{let n=c.fs.resolvePath(c.cwd,t),r=!1;if(r=e.isFile===void 0?(await c.fs.stat(n)).isDirectory:!e.isFile,r)return _?null:{error:`grep: ${t}: Is a directory
|
|
5
|
-
`};let a=await c.fs.readFile(n);return{file:t,result:i(a,F,{invertMatch:p,showLineNumbers:f,countOnly:m,filename:U?t:``,onlyMatching:C,beforeContext:D,afterContext:O,maxCount:E,kResetGroup:I,preFilter:L})}}catch{return{error:`grep: ${t}: No such file or directory
|
|
6
|
-
`}}}));for(let e of n){if(e===null)continue;if(`error`in e&&e.error){z+=e.error,e.error.includes(`Is a directory`)||(V=!0);continue}if(!(`file`in e)||!e.result)continue;let{file:t,result:n}=e;if(n.matched){if(B=!0,T)return{stdout:``,stderr:``,exitCode:0};h?R+=`${t}
|
|
7
|
-
`:g||(R+=n.output)}else g?R+=`${t}
|
|
8
|
-
`:m&&!h&&(R+=n.output)}}let W;return W=V?2:g?R.length>0?0:1:+!B,T?{stdout:``,stderr:``,exitCode:W}:{stdout:R,stderr:z,exitCode:W}}},c=256;async function l(e,t,n,i,a=0){if(a>=c)return;let o=n.fs.resolvePath(n.cwd,e);try{if(!(await n.fs.stat(o)).isDirectory){let n=e.split(`/`).pop()||``;if(t){let a=t.replace(/^\//,``);r(n,a,{stripQuotes:!0})&&i.push(e)}return}let s=await n.fs.readdir(o);for(let o of s){let s=e===`.`?o:`${e}/${o}`,c=n.fs.resolvePath(n.cwd,s);if((await n.fs.stat(c)).isDirectory)await l(s,t,n,i,a+1);else if(t){let e=t.replace(/^\//,``);r(o,e,{stripQuotes:!0})&&i.push(s)}}}catch{}}async function u(e,t){let n=[],i=e.lastIndexOf(`/`),a,o;if(i===-1?(a=t.cwd,o=e):(a=e.slice(0,i)||`/`,o=e.slice(i+1)),e.includes(`**`)){let n=[],r=e.split(`**`);return await l(r[0].replace(/\/$/,``)||`.`,r[1]||``,t,n),n.map(e=>({path:e}))}let s=t.fs.resolvePath(t.cwd,a);try{if(t.fs.readdirWithFileTypes){let e=await t.fs.readdirWithFileTypes(s);for(let t of e)if(r(t.name,o,{stripQuotes:!0})){let e=i===-1?t.name:`${a}/${t.name}`;n.push({path:e,isFile:t.isFile})}}else{let e=await t.fs.readdir(s);for(let t of e)if(r(t,o,{stripQuotes:!0})){let e=i===-1?t:`${a}/${t}`;n.push({path:e})}}}catch{}return n.sort((e,t)=>e.path.localeCompare(t.path))}async function d(e,t,n=[],i=[],a=[],o,s=0){if(s>=c)return[];let l=t.fs.resolvePath(t.cwd,e),u=[];try{let c,f;if(o!==void 0)c=o,f=!o;else{let e=await t.fs.stat(l);c=e.isFile,f=e.isDirectory}if(c){let t=e.split(`/`).pop()||e;return i.length>0&&i.some(e=>r(t,e,{stripQuotes:!0}))||n.length>0&&!n.some(e=>r(t,e,{stripQuotes:!0}))?[]:[{path:e,isFile:!0}]}if(!f)return[];let p=e.split(`/`).pop()||e;if(a.length>0&&a.some(e=>r(p,e,{stripQuotes:!0})))return[];if(t.fs.readdirWithFileTypes){let r=await t.fs.readdirWithFileTypes(l);for(let o of r){if(o.name.startsWith(`.`))continue;let r=await d(e===`.`?o.name:`${e}/${o.name}`,t,n,i,a,o.isFile,s+1);u.push(...r)}}else{let r=await t.fs.readdir(l);for(let o of r){if(o.startsWith(`.`))continue;let r=await d(e===`.`?o:`${e}/${o}`,t,n,i,a,void 0,s+1);u.push(...r)}}}catch{}return u}var f={name:`fgrep`,async execute(e,t){return s.execute([`-F`,...e],t)}},p={name:`egrep`,async execute(e,t){return s.execute([`-E`,...e],t)}},m={name:`grep`,flags:[{flag:`-E`,type:`boolean`},{flag:`-F`,type:`boolean`},{flag:`-P`,type:`boolean`},{flag:`-i`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-w`,type:`boolean`},{flag:`-x`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-L`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-h`,type:`boolean`},{flag:`-o`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-m`,type:`value`,valueHint:`number`},{flag:`-A`,type:`value`,valueHint:`number`},{flag:`-B`,type:`value`,valueHint:`number`},{flag:`-C`,type:`value`,valueHint:`number`},{flag:`-e`,type:`value`,valueHint:`pattern`}],stdinType:`text`,needsArgs:!0},h={name:`fgrep`,flags:[],stdinType:`text`,needsArgs:!0},g={name:`egrep`,flags:[],stdinType:`text`,needsArgs:!0};export{h as a,g as i,m as n,p as o,f as r,s as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-CSFPyGy0.mjs";var e=`0.88.3`;const t=`config.yml`,n=e;export{n,t};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-DXB73IDG-MLBj3lvC.mjs";import{n as e,r as t,t as n}from"./chunk-74CEPOFO-BuzahJu2.mjs";import{t as r}from"./chunk-SNN4IESC-CQKipF97.mjs";import{n as i,t as a}from"./chunk-2TRDZQLB-bwBxC32K.mjs";var o={name:`grep`,summary:`print lines that match patterns`,usage:`grep [OPTION]... PATTERN [FILE]...`,options:[`-E, --extended-regexp PATTERN is an extended regular expression`,`-P, --perl-regexp PATTERN is a Perl regular expression`,`-F, --fixed-strings PATTERN is a set of newline-separated strings`,`-i, --ignore-case ignore case distinctions`,`-v, --invert-match select non-matching lines`,`-w, --word-regexp match only whole words`,`-x, --line-regexp match only whole lines`,`-c, --count print only a count of matching lines`,`-l, --files-with-matches print only names of files with matches`,`-L, --files-without-match print names of files with no matches`,`-m NUM, --max-count=NUM stop after NUM matches`,`-n, --line-number print line number with output lines`,`-h, --no-filename suppress the file name prefix on output`,`-o, --only-matching show only nonempty parts of lines that match`,`-q, --quiet, --silent suppress all normal output`,`-r, -R, --recursive search directories recursively`,`-A NUM print NUM lines of trailing context`,`-B NUM print NUM lines of leading context`,`-C NUM print NUM lines of context`,`-e PATTERN use PATTERN for matching`,` --include=GLOB search only files matching GLOB`,` --exclude=GLOB skip files matching GLOB`,` --exclude-dir=DIR skip directories matching DIR`,` --help display this help and exit`]},s={name:`grep`,async execute(s,c){if(n(s))return t(o);let l=!1,f=!1,p=!1,m=!1,h=!1,g=!1,_=!1,v=!1,y=!1,b=!1,x=!1,S=!1,C=!1,w=!1,T=!1,E=0,D=0,O=0,k=[],A=[],j=[],M=null,N=[];for(let t=0;t<s.length;t++){let n=s[t];if(n.startsWith(`-`)&&n!==`-`){if(n===`-e`&&t+1<s.length){M=s[++t];continue}if(n.startsWith(`--include=`)){k.push(n.slice(10));continue}if(n.startsWith(`--exclude=`)){A.push(n.slice(10));continue}if(n.startsWith(`--exclude-dir=`)){j.push(n.slice(14));continue}if(n.startsWith(`--max-count=`)){E=parseInt(n.slice(12),10);continue}let r=n.match(/^-m(\d+)$/);if(r){E=parseInt(r[1],10);continue}if(n===`-m`&&t+1<s.length){E=parseInt(s[++t],10);continue}let i=n.match(/^-([ABC])(\d+)$/);if(i){let e=parseInt(i[2],10);i[1]===`A`?O=e:i[1]===`B`?D=e:i[1]===`C`&&(D=e,O=e);continue}if((n===`-A`||n===`-B`||n===`-C`)&&t+1<s.length){let e=parseInt(s[++t],10);n===`-A`?O=e:n===`-B`?D=e:(D=e,O=e);continue}let a=n.startsWith(`--`)?[n]:n.slice(1).split(``);for(let t of a)if(t===`i`||t===`--ignore-case`)l=!0;else if(t===`n`||t===`--line-number`)f=!0;else if(t===`v`||t===`--invert-match`)p=!0;else if(t===`c`||t===`--count`)m=!0;else if(t===`l`||t===`--files-with-matches`)h=!0;else if(t===`L`||t===`--files-without-match`)g=!0;else if(t===`r`||t===`R`||t===`--recursive`)_=!0;else if(t===`w`||t===`--word-regexp`)v=!0;else if(t===`x`||t===`--line-regexp`)y=!0;else if(t===`E`||t===`--extended-regexp`)b=!0;else if(t===`P`||t===`--perl-regexp`)x=!0;else if(t===`F`||t===`--fixed-strings`)S=!0;else if(t===`o`||t===`--only-matching`)C=!0;else if(t===`h`||t===`--no-filename`)w=!0;else if(t===`q`||t===`--quiet`||t===`--silent`)T=!0;else{if(t.startsWith(`--`))return e(`grep`,t);if(t.length===1)return e(`grep`,`-${t}`)}}else M===null?M=n:N.push(n)}if(M===null)return{stdout:``,stderr:`grep: missing pattern
|
|
2
|
-
`,exitCode:2};let P=S?`fixed`:b?`extended`:x?`perl`:`basic`,F,I,L;try{let e=a(M,{mode:P,ignoreCase:l,wholeWord:v,lineRegexp:y});F=e.regex,I=e.kResetGroup,L=e.preFilter}catch{return{stdout:``,stderr:`grep: invalid regular expression: ${M}
|
|
3
|
-
`,exitCode:2}}if(N.length===0&&c.stdin!==void 0){let e=i(c.stdin,F,{invertMatch:p,showLineNumbers:f,countOnly:m,filename:``,onlyMatching:C,beforeContext:D,afterContext:O,maxCount:E,kResetGroup:I,preFilter:L});return T?{stdout:``,stderr:``,exitCode:+!e.matched}:{stdout:e.output,stderr:``,exitCode:+!e.matched}}if(N.length===0)return{stdout:``,stderr:`grep: no input files
|
|
4
|
-
`,exitCode:2};let R=``,z=``,B=!1,V=!1,H=[];for(let e of N)if(e.includes(`*`)||e.includes(`?`)||e.includes(`[`)){let t=await u(e,c);if(_)for(let e of t){let t=await d(e.path,c,k,A,j,e.isFile);H.push(...t)}else H.push(...t)}else if(_){let t=await d(e,c,k,A,j);H.push(...t)}else H.push({path:e});let U=(H.length>1||_)&&!w;for(let e=0;e<H.length;e+=50){let t=H.slice(e,e+50),n=await Promise.all(t.map(async e=>{let t=e.path,n=t.split(`/`).pop()||t;if(A.length>0&&!_&&A.some(e=>r(n,e,{stripQuotes:!0}))||k.length>0&&!_&&!k.some(e=>r(n,e,{stripQuotes:!0})))return null;try{let n=c.fs.resolvePath(c.cwd,t),r=!1;if(r=e.isFile===void 0?(await c.fs.stat(n)).isDirectory:!e.isFile,r)return _?null:{error:`grep: ${t}: Is a directory
|
|
5
|
-
`};let a=await c.fs.readFile(n);return{file:t,result:i(a,F,{invertMatch:p,showLineNumbers:f,countOnly:m,filename:U?t:``,onlyMatching:C,beforeContext:D,afterContext:O,maxCount:E,kResetGroup:I,preFilter:L})}}catch{return{error:`grep: ${t}: No such file or directory
|
|
6
|
-
`}}}));for(let e of n){if(e===null)continue;if(`error`in e&&e.error){z+=e.error,e.error.includes(`Is a directory`)||(V=!0);continue}if(!(`file`in e)||!e.result)continue;let{file:t,result:n}=e;if(n.matched){if(B=!0,T)return{stdout:``,stderr:``,exitCode:0};h?R+=`${t}
|
|
7
|
-
`:g||(R+=n.output)}else g?R+=`${t}
|
|
8
|
-
`:m&&!h&&(R+=n.output)}}let W;return W=V?2:g?R.length>0?0:1:+!B,T?{stdout:``,stderr:``,exitCode:W}:{stdout:R,stderr:z,exitCode:W}}},c=256;async function l(e,t,n,i,a=0){if(a>=c)return;let o=n.fs.resolvePath(n.cwd,e);try{if(!(await n.fs.stat(o)).isDirectory){let n=e.split(`/`).pop()||``;if(t){let a=t.replace(/^\//,``);r(n,a,{stripQuotes:!0})&&i.push(e)}return}let s=await n.fs.readdir(o);for(let o of s){let s=e===`.`?o:`${e}/${o}`,c=n.fs.resolvePath(n.cwd,s);if((await n.fs.stat(c)).isDirectory)await l(s,t,n,i,a+1);else if(t){let e=t.replace(/^\//,``);r(o,e,{stripQuotes:!0})&&i.push(s)}}}catch{}}async function u(e,t){let n=[],i=e.lastIndexOf(`/`),a,o;if(i===-1?(a=t.cwd,o=e):(a=e.slice(0,i)||`/`,o=e.slice(i+1)),e.includes(`**`)){let n=[],r=e.split(`**`);return await l(r[0].replace(/\/$/,``)||`.`,r[1]||``,t,n),n.map(e=>({path:e}))}let s=t.fs.resolvePath(t.cwd,a);try{if(t.fs.readdirWithFileTypes){let e=await t.fs.readdirWithFileTypes(s);for(let t of e)if(r(t.name,o,{stripQuotes:!0})){let e=i===-1?t.name:`${a}/${t.name}`;n.push({path:e,isFile:t.isFile})}}else{let e=await t.fs.readdir(s);for(let t of e)if(r(t,o,{stripQuotes:!0})){let e=i===-1?t:`${a}/${t}`;n.push({path:e})}}}catch{}return n.sort((e,t)=>e.path.localeCompare(t.path))}async function d(e,t,n=[],i=[],a=[],o,s=0){if(s>=c)return[];let l=t.fs.resolvePath(t.cwd,e),u=[];try{let c,f;if(o!==void 0)c=o,f=!o;else{let e=await t.fs.stat(l);c=e.isFile,f=e.isDirectory}if(c){let t=e.split(`/`).pop()||e;return i.length>0&&i.some(e=>r(t,e,{stripQuotes:!0}))||n.length>0&&!n.some(e=>r(t,e,{stripQuotes:!0}))?[]:[{path:e,isFile:!0}]}if(!f)return[];let p=e.split(`/`).pop()||e;if(a.length>0&&a.some(e=>r(p,e,{stripQuotes:!0})))return[];if(t.fs.readdirWithFileTypes){let r=await t.fs.readdirWithFileTypes(l);for(let o of r){if(o.name.startsWith(`.`))continue;let r=await d(e===`.`?o.name:`${e}/${o.name}`,t,n,i,a,o.isFile,s+1);u.push(...r)}}else{let r=await t.fs.readdir(l);for(let o of r){if(o.startsWith(`.`))continue;let r=await d(e===`.`?o:`${e}/${o}`,t,n,i,a,void 0,s+1);u.push(...r)}}}catch{}return u}var f={name:`fgrep`,async execute(e,t){return s.execute([`-F`,...e],t)}},p={name:`egrep`,async execute(e,t){return s.execute([`-E`,...e],t)}};export{p as egrepCommand,f as fgrepCommand,s as grepCommand};
|
|
9
|
-
//# sourceMappingURL=grep-2HUTXO5U-Bvpc71YZ.mjs.map
|
package/dist/init-SzNKE1LX.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-C1xy7ROh.mjs";import{v as e}from"./init-CMLNmVBS.mjs";export{e as runInit};
|
package/dist/loader-bNJsrWAB.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-BJSdPFd3.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-DJ6QVqir.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./index-CxBO9vps.js";export{e as FeedbackForm};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./ManagedArtifactProperties-3QmZ83FW.js";export{e as ManagedArtifactProperties};
|
package/dist/src-afb9qw6F.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-CSFPyGy0.mjs";import"./src-BaDVbX4Z.mjs";import"./init-CMLNmVBS.mjs";import"./registry-probes-CBusnb_Y.mjs";import"./start-BTbrWXSB.mjs";import{n as e}from"./loader-BJSdPFd3.mjs";import"./preview-DJ6QVqir.mjs";import"./repair-mcp-configs-Cxupq-9r.mjs";export{e as loadConfig};
|
package/dist/start-BhxT0Ii7.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,m as t,p as n,r}from"./start-BTbrWXSB.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|