@inkeep/open-knowledge 0.36.0-beta.5 → 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.
Files changed (33) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +13 -13
  4. package/dist/constants-0O0dVRLJ.mjs +2 -0
  5. package/dist/index.d.mts +2 -5
  6. package/dist/index.mjs +1 -1
  7. package/dist/init-BstDp_v4.mjs +643 -0
  8. package/dist/init-PpuK2y4U.mjs +1 -0
  9. package/dist/{launch-json-removal-DZxESjmT.mjs → launch-json-removal-BcCQpGx-.mjs} +2 -2
  10. package/dist/loader-KRk29DXE.mjs +1 -0
  11. package/dist/{loader-By-CDx1k.mjs → loader-l_BC7vjs.mjs} +2 -2
  12. package/dist/{open-browser-B6D9fYyH.mjs → open-browser-DQGzqcdn.mjs} +2 -2
  13. package/dist/{preview-BrBt8LSP.mjs → preview-B7BjNEAS.mjs} +2 -2
  14. package/dist/preview-DuBMNs-o.mjs +1 -0
  15. package/dist/{repair-launch-json-CKwlXNT1.mjs → repair-launch-json-_jEBMO7G.mjs} +2 -2
  16. package/dist/{repair-mcp-configs-2LSm2qfK.mjs → repair-mcp-configs-u0ad9dnP.mjs} +2 -2
  17. package/dist/repair-skills-BwrIt7pC.mjs +1 -0
  18. package/dist/{repair-skills-B1G1QeKl.mjs → repair-skills-D638Scyb.mjs} +2 -2
  19. package/dist/{src-DjjyaKSr.mjs → src-DNAWQUHg.mjs} +1 -1
  20. package/dist/src-g3nRJry6.mjs +21 -0
  21. package/dist/{src-C-7wAp3_.mjs → src-up-FAzhh.mjs} +381 -382
  22. package/dist/{start-Cyi_lms5.mjs → start-BCCf0LEE.mjs} +2 -2
  23. package/dist/start-Bt-spF0y.mjs +1 -0
  24. package/dist/{write-project-skill-yzj7GOCS.mjs → write-project-skill-D3N9lJbe.mjs} +2 -2
  25. package/package.json +4 -4
  26. package/dist/constants-Bdeer1af.mjs +0 -2
  27. package/dist/init-Bhrz0jN-.mjs +0 -643
  28. package/dist/init-Criuw29c.mjs +0 -1
  29. package/dist/loader-KbIm0NCU.mjs +0 -1
  30. package/dist/preview-F-KstQlT.mjs +0 -1
  31. package/dist/repair-skills-C5TRYdRl.mjs +0 -1
  32. package/dist/src-TIYY1fSb.mjs +0 -21
  33. package/dist/start-HxMQXJT1.mjs +0 -1
@@ -1 +0,0 @@
1
- import{g as e}from"./init-Bhrz0jN-.mjs";export{e as runInit};
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-By-CDx1k.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-BrBt8LSP.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +0,0 @@
1
- import{t as e}from"./repair-skills-B1G1QeKl.mjs";export{e as repairSkills};
@@ -1,21 +0,0 @@
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,la as c,nn as l,nt as u,rt as d,tt as f}from"./src-C-7wAp3_.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 b,T as x,_ as ee,b as S,o as C,v as te,w}from"./init-Bhrz0jN-.mjs";import{n as T}from"./constants-Bdeer1af.mjs";import{t as E}from"./is-object-DYBErO9v.mjs";import{_ as ne,d as re,i as D,v as ie}from"./write-project-skill-yzj7GOCS.mjs";import"./loader-By-CDx1k.mjs";import{c as ae}from"./colors-B_qgKwrk.mjs";import"./preview-BrBt8LSP.mjs";import{execSync as oe,spawnSync as O}from"node:child_process";import{basename as k,dirname as A,isAbsolute as j,join as M,relative as N,resolve as P,sep as se}from"node:path";import{cpSync as ce,createWriteStream as le,existsSync as F,lstatSync as ue,mkdirSync as I,mkdtempSync as de,readFileSync as L,readdirSync as R,readlinkSync as fe,rmSync as pe,statSync as me,writeFileSync as z}from"node:fs";import{arch as he,freemem as ge,homedir as _e,hostname as ve,platform as ye,release as be,tmpdir as xe,totalmem as Se,type as Ce,uptime as we}from"node:os";import{readFile as B,realpath as V}from"node:fs/promises";import{createHash as H}from"node:crypto";const Te=[{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]@`}],Ee=Te.map(e=>e.name);function U(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 Te)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 De(){return M(_e(),`.ok`,`bug-reports`)}function Oe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`);return M(De(),`${t}-bugreport.zip`)}function ke(e,t){let n=M(e,`.ok`,`config.yml`);if(F(n))try{let e=L(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 F(M(e,`.ok`))?H(`sha256`).update(P(e)).digest(`hex`).slice(0,12):null}function Ae(){let e={timestamp:new Date().toISOString(),platform:ye(),osType:Ce(),osRelease:be(),hostname:`[redacted]`,uptime:we(),freeMem:ge(),totalMem:Se(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=oe(`sw_vers -productVersion 2>/dev/null`,i({encoding:`utf8`})).trim()}catch{}try{let t=M(__dirname,`..`,`..`,`package.json`);F(t)&&(e.okVersion=JSON.parse(L(t,`utf8`)).version)}catch{}return e}function je(e,t){if(!F(t))return{files:[]};let n=R(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>M(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return L(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function Me(e){let t=M(e,`.ok`,`local`);return F(t)?{files:[`server.lock`,`last-spawn-error.log`,r].map(e=>M(t,e)).filter(e=>F(e))}:{files:[]}}function Ne(e){let t=M(e,`.ok`,`local`,`logs`);return F(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>M(t,e)).filter(e=>F(e))}:{files:[]}}function Pe(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=U(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function W(e){for(let t of e.files)try{Pe({zipfile:e.zipfile,name:`${e.prefix}/${k(t)}`,content:L(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 Fe(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??M(_e(),`.ok`,`logs`),o=t.projectDir?ke(t.projectDir,i):null;I(A(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let s=Ae();s.desktop=t.desktop??null;let{files:c}=je(o,a),{files:l}=t.projectDir?Me(t.projectDir):{files:[]},{files:u}=t.projectDir?Ne(t.projectDir):{files:[]};i?.info({logFileCount:c.length,lockFileCount:l.length,localSinkFileCount:u.length},`files collected`);let d=[],f=[],{ZipFile:p}=await import(`./yazl-DvlathRc.mjs`).then(t=>e(t.default,1)),m=new p;W({zipfile:m,files:c,prefix:`logs`,redact:n,bundleFiles:f,redactions:d,logger:i}),W({zipfile:m,files:l,prefix:`lockdir`,redact:n,bundleFiles:f,redactions:d,logger:i}),W({zipfile:m,files:u,prefix:`local-logs`,redact:n,bundleFiles:f,redactions:d,logger:i});for(let e of t.extraFiles??[])try{let t=L(e.sourcePath),n=`extra/${e.zipName??k(e.sourcePath)}`;m.addBuffer(t,n),f.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Pe({zipfile:m,name:`note.txt`,content:t.note,redact:n,bundleFiles:f,redactions:d});let h=JSON.stringify(s,null,2);m.addBuffer(Buffer.from(h,`utf8`),`sysinfo.json`),f.push(`sysinfo.json`);let g={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:f,redactions:d,sysinfo:s};m.addBuffer(Buffer.from(JSON.stringify(g,null,2),`utf8`),`MANIFEST.json`);let _=d.reduce((e,t)=>e+t.lineCount,0),v=[`# Bug Report Bundle`,``,`Generated: ${g.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${g.disciplineVersion}`,``,`## Contents`,``,...f.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${Ee.join(`, `)}`,_>0?`${_} 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
- `);m.addBuffer(Buffer.from(v,`utf8`),`README.md`),m.end();let y=le(r);return m.outputStream.pipe(y),await new Promise((e,t)=>{y.on(`close`,e),y.on(`error`,t)}),i?.info({bundlePath:r,fileCount:f.length,redactionCount:_},`bundle written`),{zipPath:r,summary:{projectSlug:o,files:f,redactions:d,redactedLineCount:_,generatedAt:g.generatedAt}}}var G=n(),Ie=e(_(),1);const Le=new Set([`doc.name`,`currentDoc`]);function Re(e){return`doc:${H(`sha256`).update(e).digest(`hex`).slice(0,8)}`}function ze(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 Be(e,t){let n=t.originalToHashed.get(e);if(n!==void 0)return n;let r=Re(e);return t.originalToHashed.set(e,r),ze(t,e,r),r}function Ve(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function He(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){if(typeof e==`string`)return Ve(e,t.contentDir);if(Array.isArray(e))return e.map(e=>K(e,t));if(!He(e))return e;let n=typeof e.key==`string`&&Le.has(e.key)&&He(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`&&He(a)){let e=Be(n,t);r[i]={...a,stringValue:e}}else Le.has(i)&&typeof a==`string`?r[i]=Be(a,t):r[i]=K(a,t);return r}function Ue(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 We(e,t){let n=L(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=K(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}z(e,r?`${a.join(`
7
- `)}\n`:a.join(`
8
- `))}function Ge(e,t){let n=L(e,`utf-8`);if(n.trim().length!==0)try{let r=K(JSON.parse(n),t),i=n.endsWith(`
9
- `)?`
10
- `:``;z(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Ue(Ve(n,t.contentDir),t);r!==n&&z(e,r)}}function Ke(e,t){let n=L(e,`utf-8`),r=Ve(n,t.contentDir);r!==n&&z(e,r)}function qe(e){try{return R(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>M(e,t.name))}catch{return[]}}const Je=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Ye(e){let t={contentDir:e.contentDir,docNameMap:{},originalToHashed:new Map,docNameCollisions:{}};for(let n of[`telemetry`,`logs`,`process`])for(let r of qe(M(e.stagingDir,n)))r.endsWith(`.jsonl`)?We(r,t):r.endsWith(`.json`)?Ge(r,t):Ke(r,t);for(let n of qe(M(e.stagingDir,`state`))){let e=k(n);Je.has(e)?Ge(n,t):Ke(n,t)}return{docNameMap:t.docNameMap,docNameCollisions:t.docNameCollisions}}const Xe=[`.ok`,`local`,`telemetry`],Ze=[`.ok`,`local`,`logs`],Qe=`spans-current.jsonl`,$e=`spans-prev.jsonl`,et=`server-current.jsonl`,tt=`server-prev.jsonl`;function nt(e){return M(e,...Xe,Qe)}function rt(e){return M(e,...Xe,$e)}function it(e){return M(e,...Ze,et)}function at(e){return M(e,...Ze,tt)}const ot=1e3;async function st(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(ot)});return t.ok?await t.text():null}catch{return null}}async function ct(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(ot)});return t.ok?await t.text():null}catch{return null}}function lt(e){let t=M(e,`.git`,`ok`);if(!F(t))return null;let n=O(`git`,[`-C`,t,`log`,`--oneline`,`-50`],i({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ut(e){let t=M(e,`.git`,`ok`);if(!F(t))return null;let n=O(`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 dt(){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 ft(){return{nodeVersion:process.version,platform:ye(),arch:he()}}function pt(){return process.env.OTEL_SDK_DISABLED===`false`}function q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function mt(e){if(!F(e))return{};let t;try{t=(0,G.parse)(L(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q(t))return{};let n=t.telemetry;if(!q(n))return{};let r=n.localSink;return q(r)?r:{}}function ht(e){return typeof e==`boolean`?e:void 0}function gt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function J(e){if(q(e))return gt(e.maxBytes)}function _t(e){let t=mt(c(`project`,e)),n=mt(c(`project-local`,e));return{enabled:ht(n.enabled)??ht(t.enabled)??!0,spansMaxBytes:J(n.spans)??J(t.spans)??52428800,logsMaxBytes:J(n.logs)??J(t.logs)??26214400}}function vt(e){return H(`sha256`).update(e).digest(`hex`)}function yt(e){let t=L(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function bt(e){let t=L(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function Y(e,t){return F(e)?(I(A(t),{recursive:!0}),ce(e,t),!0):!1}function xt(e){let t=[],n=e=>{let r=R(e,{withFileTypes:!0});for(let i of r){let r=M(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const St=new Set([`.jsonl`]);function Ct(e){let t=e.lastIndexOf(`.`);return t===-1?!1:St.has(e.slice(t))}const wt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Tt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:wt.has(e.slice(t))}function Et(e){let t=[];for(let n of xt(e)){let r=Dt(e,n);if(!Tt(r))continue;let{redacted:i,patterns:a,lineCount:o}=U(L(n,`utf-8`));a.length!==0&&(z(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Dt(e,t){return N(e,t).split(se).join(`/`)}async function Ot(e){let n=P(e.contentDir),i=P(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??st,s=a.fetchAgentEffects??ct,c=a.readShadowHead??lt,l=a.readCheckpointRefs??ut,u=a.now??(()=>new Date),d=a.okVersion??(()=>T),f=a.readDesktopEnv??dt,p=a.readRuntime??ft,m=a.isOtlpPushEnabled??pt,h=de(M(xe(),`ok-bundle-`));try{I(M(h,`telemetry`),{recursive:!0}),I(M(h,`logs`),{recursive:!0}),I(M(h,`state`),{recursive:!0}),Y(nt(i),M(h,`telemetry`,Qe)),Y(rt(i),M(h,`telemetry`,$e)),Y(it(i),M(h,`logs`,et)),Y(at(i),M(h,`logs`,tt));let g=M(i,`.ok`,`local`),_=M(g,`server.lock`),v=`not-running`,y=`no server.lock`,b=null;if(F(_)){Y(_,M(h,`state`,`server.lock`));try{let e=L(_,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?b=t.port:y=`lock present but no port`}catch{y=`lock present but unparseable`}}if(b!==null){let e=await o(b);e===null?y=`agent-presence endpoint at :${b} unreachable`:(z(M(h,`state`,`agent-presence.json`),e),v=`running`,y=``);let t=await s(b);t!==null&&z(M(h,`state`,`agent-effects.json`),t)}let x=c(n);x!==null&&z(M(h,`state`,`shadow-head.txt`),x);let ee=l(n);ee!==null&&z(M(h,`state`,`checkpoint-refs.txt`),ee),Y(M(g,`last-spawn-error.log`),M(h,`state`,`last-spawn-error.log`)),Y(M(g,t),M(h,`state`,t)),Y(M(g,r),M(h,`state`,r));let S=p(),C=f(),te={ok:{version:d(),nodeVersion:S.nodeVersion,platform:S.platform,arch:S.arch},host:{desktop:C}};z(M(h,`state`,`runtime.json`),`${JSON.stringify(te,null,2)}\n`);let w=v===`running`?`running
11
- `:`not-running (${y})\n`;if(z(M(h,`state`,`server-status.txt`),w),e.processDir&&F(e.processDir)){let t=M(h,`process`);I(t,{recursive:!0}),ce(e.processDir,t,{recursive:!0})}let T=null;e.redact===!0&&(T=Ye({stagingDir:h,contentDir:n})),e.note&&z(M(h,`note.txt`),e.note);let E=null;e.scrubSecrets===!0&&(E=Et(h));for(let t of e.extraFiles??[])Y(t.sourcePath,M(h,`extra`,t.zipName??k(t.sourcePath)))||a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let ne=_t(i),re=xt(h),D=[],ie=0,ae=0;for(let e of re){let t=Dt(h,e),n=me(e).size,r=Ct(t)?yt(e):0;D.push({path:t,bytes:n,lines:r}),ie+=n,t.startsWith(`telemetry/`)&&Ct(t)&&(ae+=bt(e))}let oe=T===null?{applied:!1,docNameMapSidecar:null}:Object.keys(T.docNameCollisions).length>0?{applied:!0,docNameMapSidecar:null,docNameCollisions:T.docNameCollisions}:{applied:!0,docNameMapSidecar:null};E!==null&&(oe.secretScrub=E);let O={schemaVersion:1,createdAt:u().toISOString(),ok:{version:d(),nodeVersion:S.nodeVersion,platform:S.platform,arch:S.arch},host:{desktop:C},contentDir:{pathSha256:vt(n),absolutePath:T===null?n:`<CONTENT_DIR>`},telemetry:{localSink:ne,otlpPushEnabled:m()},redaction:oe,serverStatus:v,files:D};z(M(h,`manifest.json`),`${JSON.stringify(O,null,2)}\n`);let A=re.some(e=>{try{return L(e,`utf-8`).includes(n)}catch{return!1}}),j={totalBytes:ie,fileCount:D.length,docNameCount:ae,contentDirVisible:A,redacted:T!==null},N=!1;return{stagingDir:h,manifest:O,summary:j,redactionMapPayload:T===null?null:{docNameMap:T.docNameMap,docNameCollisions:T.docNameCollisions},cleanup:()=>{N||(N=!0,pe(h,{recursive:!0,force:!0}))}}}catch(e){throw pe(h,{recursive:!0,force:!0}),e}}async function kt(e){let{collected:t,outputPath:n}=e,r=A(n);if(!F(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=`${k(n,`.zip`)}.docnames.json`,r={...t.manifest,redaction:{...t.manifest.redaction,applied:!0,docNameMapSidecar:e}};z(M(t.stagingDir,`manifest.json`),`${JSON.stringify(r,null,2)}\n`)}let i=new Ie.ZipFile,a=xt(t.stagingDir);for(let e of a){let n=Dt(t.stagingDir,e);i.addFile(e,n)}i.end(),t.redactionMapPayload!==null&&z(M(r,`${k(n,`.zip`)}.docnames.json`),`${JSON.stringify({docNameMap:t.redactionMapPayload.docNameMap,docNameCollisions:t.redactionMapPayload.docNameCollisions},null,2)}\n`,{mode:384});let o=le(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 At(e,t){let n=M(e,`.ok`,`config.yml`);if(F(n))try{let t=(0,G.parse)(L(n,`utf-8`)),r=E(t)?t.content:void 0,i=E(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return P(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 P(e)}async function jt(e,t,n){let r=await Ot({contentDir:At(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,deps:{readDesktopEnv:n,logger:e.logger}});try{I(A(e.outputPath),{recursive:!0}),await kt({collected:r,outputPath:e.outputPath});let n=r.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:ke(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 Mt(e){let{projectDir:t}=e,n=e.readDesktopEnv??dt;if(e.level===`full`&&t!==void 0)return jt(e,t,n);let{zipPath:r,summary:i}=await Fe({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 X(e,t,n={}){let r=m(e,t);if(!F(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(L(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??ve();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Nt(e){return e.replace(/:\d+$/,``)}function Pt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Nt(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Nt(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Nt(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 Ft(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 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(`/`);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 Lt(e){let t=Ft(e);if(t)return{kind:`doc`,...t};let n=It(e);return n?{kind:`folder`,...n}:null}var Z=e(ae(),1);const Rt=`# >>> open-knowledge cli >>>`,zt=`# <<< open-knowledge cli <<<`,Bt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Vt(e){return M(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Ht={existsSync:e=>F(e),readFileSync:(e,t)=>L(e,t),lstatSync:e=>ue(e),readlinkSync:e=>fe(e)};function Ut(e,t=Ht){let n=Vt(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 Wt(e){let t=e.replace(Bt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Gt(e,t,n=Ht){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function Kt(e){return ne(e)||ie(e)||b(e)}const qt=10*1024*1024;function Jt(e,t,n,r){let i=C(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(!Kt(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`?(pe(a,{force:!0}),{kind:`removed`}):e.format===`toml`?Zt(a,o):e.format===`yaml`?Xt(a,e.topLevelKey,o):Yt(a,e.topLevelKey,e.serverMapSubKey,o)}function Yt(e,t,n,r){let i;try{i=L(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>qt)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=y(i,ee(t,n,r));return o?(s(e,a,{mode:w(e)}),{kind:`removed`}):{kind:`not-present`}}function Xt(e,t,n){let r;try{r=L(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>qt)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,G.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=x(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:w(e)}),{kind:`removed`}}function Zt(e,t){let n=S();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=L(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=x(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:w(e)}),{kind:`removed`}}const Qt=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function $t(e,t,n=l){if(e!==void 0&&!Qt.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let en=null;function tn(e){en=e}function nn(){return en??process.cwd()}function rn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function an(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 on(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:f(r),command:r,isDesktop:rn(r)}}function sn(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&sn(e)?`ui-orphan`:`stale`}const cn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function ln(e){switch(e){case`running`:return Z.default.green(e);case`desktop`:return Z.default.blue(e);case`foreign`:return Z.default.cyan(e);case`ui-orphan`:return Z.default.magenta(e);case`stale`:return Z.default.yellow(e)}}function un(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function dn(e){return`${un(e.server.usage)} | ${un(e.ui?.usage??null)}`}function fn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function pn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,fn(e),dn(e),t,String(n),an(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=ln(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=Z.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
20
- `)}async function mn(e={}){let t=e.discover??o,n=e.inspect??X,r=e.log??(e=>console.log(e)),i=e.resolveCommand??u,a=e.resolveUsage??d,s=await t(),c=[];for(let e of s){let t=n(e,`server`),r=n(e,`ui`),o=on(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:Q(e)}));r(JSON.stringify(e,null,2));return}r(pn(e.all?c:c.filter(e=>cn.has(Q(e)))))}function hn(){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 mn({all:t.all===!0||e===`all`,json:t.json===!0})})}function gn(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 _n(e){let t=e.inspect??(t=>X(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=gn(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=X(i,`server`),a=X(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=_n({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=_n({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 mn({});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=X(n,`server`),r=X(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(P(nn(),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 V(P(e)),r=await V(P(A(e)))}catch{return{kind:`not-git`}}if(!wn(n,r))return{kind:`symlink-escape`};let i=M(n,`.git`),a;try{a=me(i)}catch{return{kind:`not-git`}}let o;if(a.isDirectory()){let e;try{e=await V(i)}catch{return{kind:`not-git`}}if(!wn(e,n))return{kind:`symlink-escape`};o=e}else if(a.isFile()){let e;try{e=await B(i,`utf-8`)}catch{return{kind:`not-git`}}let t=/^gitdir:\s*(.+)$/m.exec(e.trim());if(!t)return{kind:`not-git`};let r=t[1].trim(),a=j(r)?r:P(n,r);try{o=await V(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=M(await Cn(o),`config`),c;try{c=await B(s,`utf-8`)}catch{return{kind:`not-git`}}let l=En(c);if(l===null)return{kind:`no-origin`};let u=Pt(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`}}async function Cn(e){let t;try{t=(await B(M(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=j(t)?t:P(e,t);try{return await V(n)}catch{return n}}function wn(e,t){if(e===t)return!0;let n=N(t,e);return n.length>0&&!n.startsWith(`..`)&&!j(n)}function Tn(e){let t=e.indexOf(`#`),n=e.indexOf(`;`),r=-1;return t>=0&&n>=0?r=Math.min(t,n):t>=0?r=t:n>=0&&(r=n),(r===-1?e:e.slice(0,r)).trim()}function En(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=Tn(n);if(e.length===0)continue;if(e.startsWith(`[`)){t=/^\[\s*remote\s+["']origin["']\s*\]$/.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/.exec(e);if(r)return Dn(r[1])}return null}function Dn(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const On=[{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=te(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=D(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 kn(e,t,n={},r=On){let i=[];for(let a of t){let t=re[a];for(let a of r)i.push(a.write(t,e,n))}return i}function An(e,t,n={}){return{integrations:kn(e,t,n)}}export{Mt as C,U as D,Oe as E,X as S,kt as T,Wt as _,bn as a,It as b,tn as c,Rt as d,Bt as f,Ut as g,Vt as h,_n as i,$t as l,Gt as m,Sn as n,hn as o,zt as p,xn as r,nn as s,An as t,Jt as u,Ft as v,Ot as w,Pt as x,Lt as y};
21
- //# sourceMappingURL=src-TIYY1fSb.mjs.map
@@ -1 +0,0 @@
1
- import{_ as e,f as t,r as n}from"./start-Cyi_lms5.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};