@inkeep/open-knowledge 0.36.0-beta.4 → 0.36.0-beta.6
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/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +13 -13
- package/dist/constants-0O0dVRLJ.mjs +2 -0
- package/dist/index.d.mts +2 -5
- package/dist/index.mjs +1 -1
- package/dist/init-BstDp_v4.mjs +643 -0
- package/dist/init-PpuK2y4U.mjs +1 -0
- package/dist/{launch-json-removal-1CNNe07w.mjs → launch-json-removal-BcCQpGx-.mjs} +2 -2
- package/dist/loader-KRk29DXE.mjs +1 -0
- package/dist/{loader-FWAVraqg.mjs → loader-l_BC7vjs.mjs} +2 -2
- package/dist/{open-browser-B6D9fYyH.mjs → open-browser-DQGzqcdn.mjs} +2 -2
- package/dist/{preview-Cz7kZO_R.mjs → preview-B7BjNEAS.mjs} +2 -2
- package/dist/preview-DuBMNs-o.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-DKDfj-wj.js → ActivityModeContent-pxRf1aJN.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-Cga_r8sw.js → AgentDiffPane-DNaQz-Mq.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-C8JvhtVu.js → CodeMirrorPropInput-DPWHx5JY.js} +1 -1
- package/dist/public/assets/{DocumentContext-BxcSuq62.js → DocumentContext-C2B3rTzp.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-B8FE0vUl.js → EnableSyncConfirmDialog-E6pVQr5N.js} +1 -1
- package/dist/public/assets/{GraphPanel-CCFMtesP.js → GraphPanel-Uu_iI0e2.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-8ikyrAjW.js → ManagedArtifactProperties-Bc1MX6_d.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-B2VySJUj.js → McpConsentDialogBody-uXC5I7v0.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-BBo-zNLU.js → MermaidDocEditor-ifNinTIR.js} +1 -1
- package/dist/public/assets/{PropertyPanel-CaBLEWY_.js → PropertyPanel-COh4wWRR.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-u3KkM3XQ.js → ReportBugDialogBody-D-YRluvQ.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-BbbSysuv.js → SettingsDialogBody-Qfc19Y66.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-ybiwXirt.js → ShareBranchSwitchDialog-D3GmMG_G.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-Dwl39jtz.js → ShareReceiveDialog-Dk6e1kut.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-BIm4K8oN.js → ShareReceiveMissDialog-CMCijkEu.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-C6vEnKh2.js → SkillEditorActions-CfUbmQvZ.js} +1 -1
- package/dist/public/assets/{SourceEditor-CDpVVnq_.js → SourceEditor-Cu08YT0s.js} +1 -1
- package/dist/public/assets/{TerminalPanel-D6sk4-Kd.js → TerminalPanel-DastTw-6.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-D5zvK7Ny.js → TimelineDiffPane-Bb_XCYTJ.js} +1 -1
- package/dist/public/assets/{agent-presence-DFMtUo1C.js → agent-presence-fq-RYuSQ.js} +1 -1
- package/dist/public/assets/{auth-state-cache-Du1JagTr.js → auth-state-cache-YmhdNw0D.js} +1 -1
- package/dist/public/assets/{config-provider-Bk493fIh.js → config-provider-76O2BCOy.js} +1 -1
- package/dist/public/assets/{dist-C3-XtMKH.js → dist-BOFMo2dd.js} +1 -1
- package/dist/public/assets/{dist-DmtQ3BWj.js → dist-DdW1rQZ4.js} +22 -22
- package/dist/public/assets/{doc-hash-DQ57epoi.js → doc-hash-DF4EhrSv.js} +1 -1
- package/dist/public/assets/{documents-events-Bs9aWn7j.js → documents-events-BIMGwLxq.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-DrO954Qx.js → file-tree-adapter-Cs7SUJtt.js} +1 -1
- package/dist/public/assets/{index-Cg6KBxOO.js → index-CMkVuY-v.js} +8 -8
- package/dist/public/assets/{lint-config-client-CCvQKVwG.js → lint-config-client-t8d-H17G.js} +1 -1
- package/dist/public/assets/{navigation-targets-Tdw8e9I4.js → navigation-targets-CNS6qZYI.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-CyiwHkSB.js → open-managed-artifact-tab-BEWMlKNr.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-C0f8lH7K.js → pending-receive-nav-store-rML3Ra7C.js} +1 -1
- package/dist/public/assets/{prop-types-B4-czAU5.js → prop-types-B67WAG47.js} +1 -1
- package/dist/public/assets/{receive-store-CDzC86Qf.js → receive-store-DweoUsai.js} +1 -1
- package/dist/public/assets/{selection-context-EA87Hx5b.js → selection-context-BM2OkIR1.js} +1 -1
- package/dist/public/assets/{skill-actions-CMddEihx.js → skill-actions-Bu05P2ii.js} +1 -1
- package/dist/public/assets/{skills-api-lAw-Pmq3.js → skills-api-CL094L0u.js} +1 -1
- package/dist/public/assets/{src-Cf5KWMm1.js → src-C3HBM6c0.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-CHElTTNF.js → target-navigation-intent-BI0VRa5c.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-CHKQwyMv.js → typing-burst-detector-CPcl0dzO.js} +1 -1
- package/dist/public/assets/{use-activity-panel-Ci87gMVK.js → use-activity-panel-DvdbUUZ_.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-Buo38V_E.js → use-apply-config-color-theme-Xh0HMcQa.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-ChbIVb9-.js → use-timeline-entry-diff-CIk-Xfew.js} +1 -1
- package/dist/public/assets/{workspace-paths-IhIqkJph.js → workspace-paths-IW091LiQ.js} +1 -1
- package/dist/public/index.html +26 -26
- package/dist/{repair-launch-json-Dpq_iRWZ.mjs → repair-launch-json-_jEBMO7G.mjs} +2 -2
- package/dist/{repair-mcp-configs-16WhlCKl.mjs → repair-mcp-configs-u0ad9dnP.mjs} +2 -2
- package/dist/repair-skills-BwrIt7pC.mjs +1 -0
- package/dist/{repair-skills-B1G1QeKl.mjs → repair-skills-D638Scyb.mjs} +2 -2
- package/dist/{src-DjjyaKSr.mjs → src-DNAWQUHg.mjs} +1 -1
- package/dist/src-g3nRJry6.mjs +21 -0
- package/dist/{src-C-7wAp3_.mjs → src-up-FAzhh.mjs} +381 -382
- package/dist/{start-D2MSzlrH.mjs → start-BCCf0LEE.mjs} +2 -2
- package/dist/start-Bt-spF0y.mjs +1 -0
- package/dist/{write-project-skill-yzj7GOCS.mjs → write-project-skill-D3N9lJbe.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-CnEeEHUm.mjs +0 -2
- package/dist/init-BHzTW1-A.mjs +0 -1
- package/dist/init-DGD-hrCz.mjs +0 -643
- package/dist/loader-DPlwQuHa.mjs +0 -1
- package/dist/preview-B-wK4uH5.mjs +0 -1
- package/dist/repair-skills-C5TRYdRl.mjs +0 -1
- package/dist/src-xegwOMa2.mjs +0 -21
- package/dist/start-D0WQBQvK.mjs +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,Jo as n,P as r}from"./src-S2yxN8_s.mjs";import{Mr as i,Tr as a,et as o,fa as s,ka as c,la as l,nn as u,nt as d,rt as f,tt as ee}from"./src-up-FAzhh.mjs";import{b as p,u as m,v as h,y as g}from"./server-lock-D46oe4zF.mjs";import{t as _}from"./yazl-BucAN8Ez.mjs";import{t as v}from"./esm-EvSEzE_V.mjs";import"./gh-detect-Cdvn1Wl3.mjs";import{E as y,S as te,T as b,_ as x,b as ne,o as re,v as ie,w as S}from"./init-BstDp_v4.mjs";import{n as C}from"./constants-0O0dVRLJ.mjs";import{t as ae}from"./is-object-DYBErO9v.mjs";import{_ as oe,d as w,i as se,v as ce}from"./write-project-skill-D3N9lJbe.mjs";import"./loader-l_BC7vjs.mjs";import{c as T}from"./colors-B_qgKwrk.mjs";import"./preview-B7BjNEAS.mjs";import{execSync as E,spawnSync as D}from"node:child_process";import{basename as O,dirname as k,isAbsolute as le,join as A,relative as ue,resolve as j,sep as de}from"node:path";import{cpSync as fe,createWriteStream as pe,existsSync as M,lstatSync as me,mkdirSync as N,mkdtempSync as he,readFileSync as P,readdirSync as F,readlinkSync as ge,rmSync as I,statSync as _e,writeFileSync as L}from"node:fs";import{arch as ve,freemem as ye,homedir as be,hostname as xe,platform as Se,release as Ce,tmpdir as we,totalmem as Te,type as Ee,uptime as De}from"node:os";import{realpath as R}from"node:fs/promises";import{createHash as z}from"node:crypto";const Oe=[{name:`macos-home-path`,regex:/\/Users\/[^/]+\//g,replacement:`~/`},{name:`linux-home-path`,regex:/\/home\/[^/]+\//g,replacement:`~/`},{name:`github-pat`,regex:/\b(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9]{36,}\b/g,replacement:`[REDACTED-GH-PAT]`},{name:`aws-access-key`,regex:/\b(AKIA|ASIA|ABIA)[A-Z2-7]{16}\b/g,replacement:`[REDACTED-AWS-KEY]`},{name:`anthropic-key`,regex:/\bsk-ant-api03-[A-Za-z0-9_-]{20,}\b/g,replacement:`[REDACTED-ANTHROPIC]`},{name:`openai-key`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g,replacement:`[REDACTED-OPENAI]`},{name:`bearer-token`,regex:/([Aa]uthorization:\s*[Bb]earer\s+)\S+/g,replacement:`$1[REDACTED]`},{name:`jwt`,regex:/eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,replacement:`[REDACTED-JWT]`},{name:`url-credentials`,regex:/:\/\/[^/\s:@]+:[^/\s:@]+@/g,replacement:`://[REDACTED]@`}],ke=Oe.map(e=>e.name);function B(e){let t=new Set,n=0;return{redacted:e.split(`
|
|
2
|
+
`).map(e=>{let r=e;for(let{name:e,regex:i,replacement:a}of Oe)i.lastIndex=0,i.test(r)&&(t.add(e),n++,i.lastIndex=0,r=r.replace(i,a));return r}).join(`
|
|
3
|
+
`),patterns:[...t],lineCount:n}}function Ae(){return A(be(),`.ok`,`bug-reports`)}function je(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`);return A(Ae(),`${t}-bugreport.zip`)}function Me(e,t){let n=A(e,`.ok`,`config.yml`);if(M(n))try{let e=P(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e instanceof Error?e.message:String(e)},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return M(A(e,`.ok`))?z(`sha256`).update(j(e)).digest(`hex`).slice(0,12):null}function Ne(){let e={timestamp:new Date().toISOString(),platform:Se(),osType:Ee(),osRelease:Ce(),hostname:`[redacted]`,uptime:De(),freeMem:ye(),totalMem:Te(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=E(`sw_vers -productVersion 2>/dev/null`,i({encoding:`utf8`})).trim()}catch{}try{let t=A(__dirname,`..`,`..`,`package.json`);M(t)&&(e.okVersion=JSON.parse(P(t,`utf8`)).version)}catch{}return e}function Pe(e,t){if(!M(t))return{files:[]};let n=F(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>A(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return P(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function Fe(e){let t=A(e,`.ok`,`local`);return M(t)?{files:[`server.lock`,`last-spawn-error.log`,r].map(e=>A(t,e)).filter(e=>M(e))}:{files:[]}}function Ie(e){let t=A(e,`.ok`,`local`,`logs`);return M(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>A(t,e)).filter(e=>M(e))}:{files:[]}}function Le(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=B(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function V(e){for(let t of e.files)try{Le({zipfile:e.zipfile,name:`${e.prefix}/${O(t)}`,content:P(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n instanceof Error?n.message:String(n)},`bug-report: skipped unreadable file`)}}async function Re(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??A(be(),`.ok`,`logs`),o=t.projectDir?Me(t.projectDir,i):null;N(k(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let s=Ne();s.desktop=t.desktop??null;let{files:c}=Pe(o,a),{files:l}=t.projectDir?Fe(t.projectDir):{files:[]},{files:u}=t.projectDir?Ie(t.projectDir):{files:[]};i?.info({logFileCount:c.length,lockFileCount:l.length,localSinkFileCount:u.length},`files collected`);let d=[],f=[],{ZipFile:ee}=await import(`./yazl-DvlathRc.mjs`).then(t=>e(t.default,1)),p=new ee;V({zipfile:p,files:c,prefix:`logs`,redact:n,bundleFiles:f,redactions:d,logger:i}),V({zipfile:p,files:l,prefix:`lockdir`,redact:n,bundleFiles:f,redactions:d,logger:i}),V({zipfile:p,files:u,prefix:`local-logs`,redact:n,bundleFiles:f,redactions:d,logger:i});for(let e of t.extraFiles??[])try{let t=P(e.sourcePath),n=`extra/${e.zipName??O(e.sourcePath)}`;p.addBuffer(t,n),f.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Le({zipfile:p,name:`note.txt`,content:t.note,redact:n,bundleFiles:f,redactions:d});let m=JSON.stringify(s,null,2);p.addBuffer(Buffer.from(m,`utf8`),`sysinfo.json`),f.push(`sysinfo.json`);let h={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:f,redactions:d,sysinfo:s};p.addBuffer(Buffer.from(JSON.stringify(h,null,2),`utf8`),`MANIFEST.json`);let g=d.reduce((e,t)=>e+t.lineCount,0),_=[`# Bug Report Bundle`,``,`Generated: ${h.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${h.disciplineVersion}`,``,`## Contents`,``,...f.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${ke.join(`, `)}`,g>0?`${g} line(s) were scrubbed across ${d.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
|
|
4
|
+
`);p.addBuffer(Buffer.from(_,`utf8`),`README.md`),p.end();let v=pe(r);return p.outputStream.pipe(v),await new Promise((e,t)=>{v.on(`close`,e),v.on(`error`,t)}),i?.info({bundlePath:r,fileCount:f.length,redactionCount:g},`bundle written`),{zipPath:r,summary:{projectSlug:o,files:f,redactions:d,redactedLineCount:g,generatedAt:h.generatedAt}}}var H=n(),ze=e(_(),1);const Be=new Set([`doc.name`,`currentDoc`]);function Ve(e){return`doc:${z(`sha256`).update(e).digest(`hex`).slice(0,8)}`}function He(e,t,n){let r=e.docNameMap[n];if(r===void 0){e.docNameMap[n]=t;return}if(r===t)return;let i=e.docNameCollisions[n];i?i.includes(t)||i.push(t):e.docNameCollisions[n]=[t]}function Ue(e,t){let n=t.originalToHashed.get(e);if(n!==void 0)return n;let r=Ve(e);return t.originalToHashed.set(e,r),He(t,e,r),r}function U(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e,t){if(typeof e==`string`)return U(e,t.contentDir);if(Array.isArray(e))return e.map(e=>G(e,t));if(!W(e))return e;let n=typeof e.key==`string`&&Be.has(e.key)&&W(e.value)&&typeof e.value.stringValue==`string`?e.value.stringValue:null,r={};for(let[i,a]of Object.entries(e))if(n!==null&&i===`value`&&W(a)){let e=Ue(n,t);r[i]={...a,stringValue:e}}else Be.has(i)&&typeof a==`string`?r[i]=Ue(a,t):r[i]=G(a,t);return r}function We(e,t){if(t.originalToHashed.size===0)return e;let n=Array.from(t.originalToHashed.entries()).sort(([e],[t])=>t.length-e.length),r=e;for(let[e,t]of n)e.length!==0&&r.includes(e)&&(r=r.split(e).join(t));return r}function Ge(e,t){let n=P(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
5
|
+
`),i=n.split(`
|
|
6
|
+
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=G(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}L(e,r?`${a.join(`
|
|
7
|
+
`)}\n`:a.join(`
|
|
8
|
+
`))}function Ke(e,t){let n=P(e,`utf-8`);if(n.trim().length!==0)try{let r=G(JSON.parse(n),t),i=n.endsWith(`
|
|
9
|
+
`)?`
|
|
10
|
+
`:``;L(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=We(U(n,t.contentDir),t);r!==n&&L(e,r)}}function qe(e,t){let n=P(e,`utf-8`),r=U(n,t.contentDir);r!==n&&L(e,r)}function Je(e){try{return F(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>A(e,t.name))}catch{return[]}}const Ye=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Xe(e){let t={contentDir:e.contentDir,docNameMap:{},originalToHashed:new Map,docNameCollisions:{}};for(let n of[`telemetry`,`logs`,`process`])for(let r of Je(A(e.stagingDir,n)))r.endsWith(`.jsonl`)?Ge(r,t):r.endsWith(`.json`)?Ke(r,t):qe(r,t);for(let n of Je(A(e.stagingDir,`state`))){let e=O(n);Ye.has(e)?Ke(n,t):qe(n,t)}return{docNameMap:t.docNameMap,docNameCollisions:t.docNameCollisions}}const Ze=[`.ok`,`local`,`telemetry`],Qe=[`.ok`,`local`,`logs`],$e=`spans-current.jsonl`,et=`spans-prev.jsonl`,tt=`server-current.jsonl`,nt=`server-prev.jsonl`;function rt(e){return A(e,...Ze,$e)}function it(e){return A(e,...Ze,et)}function at(e){return A(e,...Qe,tt)}function ot(e){return A(e,...Qe,nt)}const st=1e3;async function ct(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(st)});return t.ok?await t.text():null}catch{return null}}async function lt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(st)});return t.ok?await t.text():null}catch{return null}}function ut(e){let t=A(e,`.git`,`ok`);if(!M(t))return null;let n=D(`git`,[`-C`,t,`log`,`--oneline`,`-50`],i({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function dt(e){let t=A(e,`.git`,`ok`);if(!M(t))return null;let n=D(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],i({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ft(){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 pt(){return{nodeVersion:process.version,platform:Se(),arch:ve()}}function mt(){return process.env.OTEL_SDK_DISABLED===`false`}function K(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ht(e){if(!M(e))return{};let t;try{t=(0,H.parse)(P(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(!K(t))return{};let n=t.telemetry;if(!K(n))return{};let r=n.localSink;return K(r)?r:{}}function gt(e){return typeof e==`boolean`?e:void 0}function _t(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function q(e){if(K(e))return _t(e.maxBytes)}function vt(e){let t=ht(l(`project`,e)),n=ht(l(`project-local`,e));return{enabled:gt(n.enabled)??gt(t.enabled)??!0,spansMaxBytes:q(n.spans)??q(t.spans)??52428800,logsMaxBytes:q(n.logs)??q(t.logs)??26214400}}function yt(e){return z(`sha256`).update(e).digest(`hex`)}function bt(e){let t=P(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function xt(e){let t=P(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function J(e,t){return M(e)?(N(k(t),{recursive:!0}),fe(e,t),!0):!1}function St(e){let t=[],n=e=>{let r=F(e,{withFileTypes:!0});for(let i of r){let r=A(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Ct=new Set([`.jsonl`]);function wt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Ct.has(e.slice(t))}const Tt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Et(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Tt.has(e.slice(t))}function Dt(e){let t=[];for(let n of St(e)){let r=Ot(e,n);if(!Et(r))continue;let{redacted:i,patterns:a,lineCount:o}=B(P(n,`utf-8`));a.length!==0&&(L(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Ot(e,t){return ue(e,t).split(de).join(`/`)}async function kt(e){let n=j(e.contentDir),i=j(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??ct,s=a.fetchAgentEffects??lt,c=a.readShadowHead??ut,l=a.readCheckpointRefs??dt,u=a.now??(()=>new Date),d=a.okVersion??(()=>C),f=a.readDesktopEnv??ft,ee=a.readRuntime??pt,p=a.isOtlpPushEnabled??mt,m=he(A(we(),`ok-bundle-`));try{N(A(m,`telemetry`),{recursive:!0}),N(A(m,`logs`),{recursive:!0}),N(A(m,`state`),{recursive:!0}),J(rt(i),A(m,`telemetry`,$e)),J(it(i),A(m,`telemetry`,et)),J(at(i),A(m,`logs`,tt)),J(ot(i),A(m,`logs`,nt));let h=A(i,`.ok`,`local`),g=A(h,`server.lock`),_=`not-running`,v=`no server.lock`,y=null;if(M(g)){J(g,A(m,`state`,`server.lock`));try{let e=P(g,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?y=t.port:v=`lock present but no port`}catch{v=`lock present but unparseable`}}if(y!==null){let e=await o(y);e===null?v=`agent-presence endpoint at :${y} unreachable`:(L(A(m,`state`,`agent-presence.json`),e),_=`running`,v=``);let t=await s(y);t!==null&&L(A(m,`state`,`agent-effects.json`),t)}let te=c(n);te!==null&&L(A(m,`state`,`shadow-head.txt`),te);let b=l(n);b!==null&&L(A(m,`state`,`checkpoint-refs.txt`),b),J(A(h,`last-spawn-error.log`),A(m,`state`,`last-spawn-error.log`)),J(A(h,t),A(m,`state`,t)),J(A(h,r),A(m,`state`,r));let x=ee(),ne=f(),re={ok:{version:d(),nodeVersion:x.nodeVersion,platform:x.platform,arch:x.arch},host:{desktop:ne}};L(A(m,`state`,`runtime.json`),`${JSON.stringify(re,null,2)}\n`);let ie=_===`running`?`running
|
|
11
|
+
`:`not-running (${v})\n`;if(L(A(m,`state`,`server-status.txt`),ie),e.processDir&&M(e.processDir)){let t=A(m,`process`);N(t,{recursive:!0}),fe(e.processDir,t,{recursive:!0})}let S=null;e.redact===!0&&(S=Xe({stagingDir:m,contentDir:n})),e.note&&L(A(m,`note.txt`),e.note);let C=null;e.scrubSecrets===!0&&(C=Dt(m));for(let t of e.extraFiles??[])J(t.sourcePath,A(m,`extra`,t.zipName??O(t.sourcePath)))||a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let ae=vt(i),oe=St(m),w=[],se=0,ce=0;for(let e of oe){let t=Ot(m,e),n=_e(e).size,r=wt(t)?bt(e):0;w.push({path:t,bytes:n,lines:r}),se+=n,t.startsWith(`telemetry/`)&&wt(t)&&(ce+=xt(e))}let T=S===null?{applied:!1,docNameMapSidecar:null}:Object.keys(S.docNameCollisions).length>0?{applied:!0,docNameMapSidecar:null,docNameCollisions:S.docNameCollisions}:{applied:!0,docNameMapSidecar:null};C!==null&&(T.secretScrub=C);let E={schemaVersion:1,createdAt:u().toISOString(),ok:{version:d(),nodeVersion:x.nodeVersion,platform:x.platform,arch:x.arch},host:{desktop:ne},contentDir:{pathSha256:yt(n),absolutePath:S===null?n:`<CONTENT_DIR>`},telemetry:{localSink:ae,otlpPushEnabled:p()},redaction:T,serverStatus:_,files:w};L(A(m,`manifest.json`),`${JSON.stringify(E,null,2)}\n`);let D=oe.some(e=>{try{return P(e,`utf-8`).includes(n)}catch{return!1}}),k={totalBytes:se,fileCount:w.length,docNameCount:ce,contentDirVisible:D,redacted:S!==null},le=!1;return{stagingDir:m,manifest:E,summary:k,redactionMapPayload:S===null?null:{docNameMap:S.docNameMap,docNameCollisions:S.docNameCollisions},cleanup:()=>{le||(le=!0,I(m,{recursive:!0,force:!0}))}}}catch(e){throw I(m,{recursive:!0,force:!0}),e}}async function At(e){let{collected:t,outputPath:n}=e,r=k(n);if(!M(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);if(t.redactionMapPayload!==null){let e=`${O(n,`.zip`)}.docnames.json`,r={...t.manifest,redaction:{...t.manifest.redaction,applied:!0,docNameMapSidecar:e}};L(A(t.stagingDir,`manifest.json`),`${JSON.stringify(r,null,2)}\n`)}let i=new ze.ZipFile,a=St(t.stagingDir);for(let e of a){let n=Ot(t.stagingDir,e);i.addFile(e,n)}i.end(),t.redactionMapPayload!==null&&L(A(r,`${O(n,`.zip`)}.docnames.json`),`${JSON.stringify({docNameMap:t.redactionMapPayload.docNameMap,docNameCollisions:t.redactionMapPayload.docNameCollisions},null,2)}\n`,{mode:384});let o=pe(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function jt(e,t){let n=A(e,`.ok`,`config.yml`);if(M(n))try{let t=(0,H.parse)(P(n,`utf-8`)),r=ae(t)?t.content:void 0,i=ae(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return j(e,i)}catch(e){t?.warn({configPath:n,err:e instanceof Error?e.message:String(e)},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return j(e)}async function Mt(e,t,n){let r=await kt({contentDir:jt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,deps:{readDesktopEnv:n,logger:e.logger}});try{N(k(e.outputPath),{recursive:!0}),await At({collected:r,outputPath:e.outputPath});let n=r.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:Me(t,e.logger),files:r.manifest.files.map(e=>e.path),redactions:n?.redactions??[],redactedLineCount:n?.redactedLineCount??0,generatedAt:r.manifest.createdAt}}}finally{r.cleanup()}}async function Nt(e){let{projectDir:t}=e,n=e.readDesktopEnv??ft;if(e.level===`full`&&t!==void 0)return Mt(e,t,n);let{zipPath:r,summary:i}=await Re({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n()});return{zipPath:r,summary:{level:e.level,systemWide:t===void 0,projectSlug:i.projectSlug,files:i.files,redactions:i.redactions,redactedLineCount:i.redactedLineCount,generatedAt:i.generatedAt}}}function Y(e,t,n={}){let r=m(e,t);if(!M(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(P(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!p(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??g)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??h())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??xe();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Pt(e){return e.replace(/:\d+$/,``)}function Ft(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Pt(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Pt(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Pt(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function It(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function Lt(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function Rt(e){let t=It(e);if(t)return{kind:`doc`,...t};let n=Lt(e);return n?{kind:`folder`,...n}:null}var X=e(T(),1);const zt=`# >>> open-knowledge cli >>>`,Bt=`# <<< open-knowledge cli <<<`,Vt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Ht(e){return A(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Ut={existsSync:e=>M(e),readFileSync:(e,t)=>P(e,t),lstatSync:e=>me(e),readlinkSync:e=>ge(e)};function Wt(e,t=Ut){let n=Ht(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 Gt(e){let t=e.replace(Vt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Kt(e,t,n=Ut){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function qt(e){return oe(e)||ce(e)||te(e)}const Jt=10*1024*1024;function Yt(e,t,n,r){let i=re(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!qt(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(I(a,{force:!0}),{kind:`removed`}):e.format===`toml`?Qt(a,o):e.format===`yaml`?Zt(a,e.topLevelKey,o):Xt(a,e.topLevelKey,e.serverMapSubKey,o)}function Xt(e,t,n,r){let i;try{i=P(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>Jt)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=y(i,x(t,n,r));return o?(s(e,a,{mode:S(e)}),{kind:`removed`}):{kind:`not-present`}}function Zt(e,t,n){let r;try{r=P(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>Jt)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,H.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let c=[t,n];if(!o.hasIn(c))return{kind:`not-present`};o.deleteIn(c);let l=o.toString(),u=b(a);a.trim()===``||a.endsWith(`
|
|
12
|
+
`)?l.endsWith(`
|
|
13
|
+
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),u&&(l=l.replace(/\r\n/g,`
|
|
14
|
+
`).replace(/\n/g,`\r
|
|
15
|
+
`));let d=`${i?``:``}${l}`;return d!==r&&s(e,d,{mode:S(e)}),{kind:`removed`}}function Qt(e,t){let n=ne();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=P(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=b(a),c=a.trim()===``||a.endsWith(`
|
|
16
|
+
`),l;try{l=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!l.existed)return{kind:`not-present`};let u=l.text;c?u.endsWith(`
|
|
17
|
+
`)||(u=`${u}\n`):u=u.replace(/\n+$/,``),o&&(u=u.replace(/\r\n/g,`
|
|
18
|
+
`).replace(/\n/g,`\r
|
|
19
|
+
`));let d=`${i?``:``}${u}`;return d!==r&&s(e,d,{mode:S(e)}),{kind:`removed`}}const $t=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function en(e,t,n=u){if(e!==void 0&&!$t.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let tn=null;function nn(e){tn=e}function rn(){return tn??process.cwd()}function an(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function on(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function sn(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:ee(r),command:r,isDesktop:an(r)}}function cn(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Z(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&cn(e)?`ui-orphan`:`stale`}const ln=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function un(e){switch(e){case`running`:return X.default.green(e);case`desktop`:return X.default.blue(e);case`foreign`:return X.default.cyan(e);case`ui-orphan`:return X.default.magenta(e);case`stale`:return X.default.yellow(e)}}function dn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function fn(e){return`${dn(e.server.usage)} | ${dn(e.ui?.usage??null)}`}function pn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function mn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Z(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,pn(e),fn(e),t,String(n),on(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=un(Z(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=X.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
20
|
+
`)}async function hn(e={}){let t=e.discover??o,n=e.inspect??Y,r=e.log??(e=>console.log(e)),i=e.resolveCommand??d,a=e.resolveUsage??f,s=await t(),c=[];for(let e of s){let t=n(e,`server`),r=n(e,`ui`),o=sn(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&c.push(o)}if(e.json){let e=c.map(e=>({...e,displayStatus:Z(e)}));r(JSON.stringify(e,null,2));return}r(mn(e.all?c:c.filter(e=>ln.has(Z(e)))))}function gn(){return new v(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await hn({all:t.all===!0||e===`all`,json:t.json===!0})})}function _n(e,t,n={}){let r=n.isAlive??g,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function Q(e){let t=e.inspect??(t=>Y(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=_n(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function vn(e,t=g){let n=await o(),r=null;for(let i of n){let n=Y(i,`server`),a=Y(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function yn(e){let t=Q({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function bn(e){return new v(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=Q({lockDir:a(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await hn({});return}if(n===`all`){let e=await o();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Y(n,`server`),r=Y(n,`ui`);!$(e,g)&&!$(r,g)||(yn(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await vn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}yn(t);return}yn(a(j(rn(),n)))})}function xn(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Sn(e,t){let n,r;try{n=await R(j(e)),r=await R(j(k(e)))}catch{return{kind:`not-git`}}if(!Cn(n,r))return{kind:`symlink-escape`};let i=A(n,`.git`),a;try{a=_e(i)}catch{return{kind:`not-git`}}if(a.isDirectory()){let e;try{e=await R(i)}catch{return{kind:`not-git`}}if(!Cn(e,n))return{kind:`symlink-escape`}}else if(!a.isFile())return{kind:`not-git`};let o=c(n);if(o.kind!==`repository`)return{kind:`not-git`};let s=o.repository.readRemoteUrl(`origin`);if(s.kind===`unreadable`)return{kind:`not-git`};if(s.kind===`absent`)return s.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let l=s.url,u=Ft(l);if(u===null||u.hostname!==`github.com`)return{kind:`non-github`};let d=u.owner.toLowerCase()===t.owner.toLowerCase(),f=u.name.toLowerCase()===t.repo.toLowerCase();return!d||!f?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://github.com/${u.owner}/${u.name}.git`}}function Cn(e,t){if(e===t)return!0;let n=ue(t,e);return n.length>0&&!n.startsWith(`..`)&&!le(n)}const wn=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=ie(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=se(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function Tn(e,t,n={},r=wn){let i=[];for(let a of t){let t=w[a];for(let a of r)i.push(a.write(t,e,n))}return i}function En(e,t,n={}){return{integrations:Tn(e,t,n)}}export{Nt as C,B as D,je as E,Y as S,At as T,Gt as _,bn as a,Lt as b,nn as c,zt as d,Vt as f,Wt as g,Ht as h,Q as i,en as l,Kt as m,Sn as n,gn as o,Bt as p,xn as r,rn as s,En as t,Yt as u,It as v,kt as w,Ft as x,Rt as y};
|
|
21
|
+
//# sourceMappingURL=src-g3nRJry6.mjs.map
|