@inkeep/open-knowledge 0.58.0-beta.14 → 0.58.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{acp-harness-probe-DDZTh5_s.mjs → acp-harness-probe-DS_7zIK_.mjs} +2 -2
- package/dist/cli.mjs +62 -62
- package/dist/constants-BIeVtBfo.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-CKnF84QV.mjs → init-DpK4E47u.mjs} +11 -11
- package/dist/init-iZIn7AB8.mjs +1 -0
- package/dist/{launch-json-removal-Cxdw1SJA.mjs → launch-json-removal-CKKETfkd.mjs} +2 -2
- package/dist/{loader-BgREGV98.mjs → loader-DNYUnJfz.mjs} +2 -2
- package/dist/loader-DnW-i20_.mjs +1 -0
- package/dist/{open-browser-XCXpL8oR.mjs → open-browser-CqPwNS9p.mjs} +2 -2
- package/dist/preview-BHCrM7Ai.mjs +1 -0
- package/dist/{preview-DIcZNxR_.mjs → preview-CIC9NRPO.mjs} +2 -2
- package/dist/{repair-launch-json-Dk7mB908.mjs → repair-launch-json-CBdzInqd.mjs} +2 -2
- package/dist/{repair-mcp-configs-C__k-elB.mjs → repair-mcp-configs-BkdYQCB5.mjs} +2 -2
- package/dist/repair-skills-DZYRwlOA.mjs +1 -0
- package/dist/{repair-skills-DltCY6z2.mjs → repair-skills-dfeOpqoD.mjs} +2 -2
- package/dist/{skill-teardown-DhZjMVeU.mjs → skill-teardown-DMHte1Ul.mjs} +2 -2
- package/dist/src-BZYY4rMh.mjs +20 -0
- package/dist/src-CfZQlksq.mjs +1 -0
- package/dist/{src-DVlcBUL2.mjs → src-D1B-8GA1.mjs} +289 -289
- package/dist/src-mrqXaTi8.mjs +1 -0
- package/dist/{start-hUBMuQB3.mjs → start-D8fnkCvw.mjs} +4 -4
- package/dist/start-F9zFpCUi.mjs +1 -0
- package/dist/{ui-CNdWjnA7.mjs → ui-CtfzlLI1.mjs} +3 -3
- package/dist/{write-project-skill-GQSmUhGW.mjs → write-project-skill-_XCsfJhR.mjs} +3 -3
- package/package.json +5 -5
- package/dist/constants-Dnljz18I.mjs +0 -2
- package/dist/init-CrImy7bq.mjs +0 -1
- package/dist/loader-C_m2rJyW.mjs +0 -1
- package/dist/preview-CQGxW6YH.mjs +0 -1
- package/dist/repair-skills-CS14x_hO.mjs +0 -1
- package/dist/src-5XnFzMUO.mjs +0 -1
- package/dist/src-CJB5BraF.mjs +0 -1
- package/dist/src-DryBqCCq.mjs +0 -20
- package/dist/start-Cs4-Dt03.mjs +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,pt as n,q as r}from"./sleep-B416PNUo.mjs";import{ho as i,it as a,rt as o,vc as s,yc as c}from"./src-C1ipB-PD.mjs";import{Fn as l,at as u,it as d,ot as f,rt as p,ti as m,wi as h}from"./src-D1B-8GA1.mjs";import{D as g,F as _,I as v,k as y}from"./fs-traced-CJ0NSnI0.mjs";import{C as b,S as x,_ as S,d as C}from"./server-lock-CnbGjeVA.mjs";import{t as w}from"./yazl-DZr4PyKA.mjs";import{m as T,p as E,v as D}from"./write-project-skill-_XCsfJhR.mjs";import{c as ee}from"./colors-BsmVIwfM.mjs";import{n as te}from"./acp-harness-probe-DS_7zIK_.mjs";import{E as O,T as k,_ as ne,o as re,w as A,x as j,y as ie}from"./init-DpK4E47u.mjs";import{n as ae}from"./constants-BIeVtBfo.mjs";import{t as M}from"./is-object-ByG7RnjH.mjs";import"./loader-DNYUnJfz.mjs";import"./skill-teardown-DMHte1Ul.mjs";import"./preview-CIC9NRPO.mjs";import{execSync as oe,spawnSync as N}from"node:child_process";import{basename as P,dirname as F,join as I,relative as se,resolve as L,sep as ce}from"node:path";import{cpSync as le,createWriteStream as ue,existsSync as R,lstatSync as de,mkdirSync as z,mkdtempSync as fe,readFileSync as B,readdirSync as pe,readlinkSync as me,rmSync as he,statSync as ge,writeFileSync as V}from"node:fs";import{arch as _e,freemem as ve,homedir as H,hostname as ye,platform as be,release as xe,tmpdir as Se,totalmem as Ce,type as we,uptime as Te}from"node:os";import"node:fs/promises";import{createHash as Ee}from"node:crypto";var De=n();const Oe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ke(e,t,n=l){if(e!==void 0&&!Oe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ae=null;function je(e){Ae=e}function Me(){return Ae??process.cwd()}function Ne(){return I(H(),`.ok`,`bug-reports`)}function Pe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Ne(),r=`${t}-bugreport`,i=I(n,`${r}.zip`);for(let e=2;R(i);e+=1)i=I(n,`${r}-${e}.zip`);return i}function Fe(e,t){let n=I(e,`.ok`,`config.yml`);if(R(n))try{let e=B(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return R(I(e,`.ok`))?Ee(`sha256`).update(L(e)).digest(`hex`).slice(0,12):null}function Ie(){let e={timestamp:new Date().toISOString(),platform:be(),osType:we(),osRelease:xe(),hostname:`[redacted]`,uptime:Te(),freeMem:ve(),totalMem:Ce(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=oe(`sw_vers -productVersion 2>/dev/null`,m({encoding:`utf8`})).trim()}catch{}try{let t=I(__dirname,`..`,`..`,`package.json`);R(t)&&(e.okVersion=JSON.parse(B(t,`utf8`)).version)}catch{}return e}const Le=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function U(e){let t=P(e);return Le.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Re(e,t){return Ve(e,t).files}const ze=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function Be(e,t=te){let n=I(e,`${t}.ShipIt`);return R(n)?ze.map(e=>I(n,e)).filter(e=>R(e)):[]}function Ve(e,t){if(!R(t))return{files:[],excludedByProjectSlug:0};let n=pe(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>I(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(U),i=[],a=r.filter(t=>{try{return B(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!U(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function He(e){let t=I(e,`.ok`,`local`);return R(t)?{files:[`server.lock`,`last-spawn-error.log`,o].map(e=>I(t,e)).filter(e=>R(e))}:{files:[]}}function Ue(e){let t=I(e,`.ok`,`local`,`logs`);return R(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>I(t,e)).filter(e=>R(e))}:{files:[]}}function We(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=c(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{We({zipfile:e.zipfile,name:`${e.prefix}/${P(t)}`,content:B(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Ge(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??I(H(),`.ok`,`logs`),o=t.projectDir?Fe(t.projectDir,i):null;z(F(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let c=Ie();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=Ve(o,a),{files:d}=t.projectDir?He(t.projectDir):{files:[]},{files:f}=t.projectDir?Ue(t.projectDir):{files:[]},p=t.shipItLogFiles??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length},`files collected`);let m=[],h=[],{ZipFile:g}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),_=new g;W({zipfile:_,files:[...l,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:i}),W({zipfile:_,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:i}),W({zipfile:_,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=B(e.sourcePath),n=`extra/${e.zipName??P(e.sourcePath)}`;_.addBuffer(t,n),h.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&We({zipfile:_,name:`note.txt`,content:t.note,redact:n,bundleFiles:h,redactions:m});let v=JSON.stringify(c,null,2);_.addBuffer(Buffer.from(v,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let y={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:h,redactions:m,sysinfo:c};_.addBuffer(Buffer.from(JSON.stringify(y,null,2),`utf8`),`MANIFEST.json`);let b=m.reduce((e,t)=>e+t.lineCount,0),x=new Set(p.map(e=>`logs/${P(e)}`)),S=h.filter(e=>x.has(e)),C=o?h.filter(e=>e.startsWith(`logs/`)&&!U(e)&&!x.has(e)):[],w=[`# Bug Report Bundle`,``,`Generated: ${y.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${y.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...C.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...C.map(e=>`- ${e}`),``]:[],...S.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...S.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${s.join(`, `)}`,b>0?`${b} line(s) were scrubbed across ${m.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
|
|
2
|
+
`);_.addBuffer(Buffer.from(w,`utf8`),`README.md`),_.end();let T=ue(r);return _.outputStream.pipe(T),await new Promise((e,t)=>{T.on(`close`,e),T.on(`error`,t)}),i?.info({bundlePath:r,fileCount:h.length,redactionCount:b},`bundle written`),{zipPath:r,summary:{projectSlug:o,files:h,redactions:m,redactedLineCount:b,generatedAt:y.generatedAt}}}var Ke=e(w(),1),G=e(ee(),1);function qe(e){return v({absPath:y(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Je({home:e=H(),env:n=process.env}={}){let a=qe(e),{override:o,preferenceList:s}=g(n),{locale:c,source:l}=i({override:o,storedPreference:a,supportedLocales:r,preferenceList:s,autoDetectableLocales:t});return{preference:a,locale:c,source:l,systemLanguages:s}}function K(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return K(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!Ye(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function Xe(e,t){let n=B(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
|
+
`),i=n.split(`
|
|
4
|
+
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=q(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}V(e,r?`${a.join(`
|
|
5
|
+
`)}\n`:a.join(`
|
|
6
|
+
`))}function Ze(e,t){let n=B(e,`utf-8`);if(n.trim().length!==0)try{let r=q(JSON.parse(n),t),i=n.endsWith(`
|
|
7
|
+
`)?`
|
|
8
|
+
`:``;V(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=K(n,t.contentDir);r!==n&&V(e,r)}}function Qe(e,t){let n=B(e,`utf-8`),r=K(n,t.contentDir);r!==n&&V(e,r)}function $e(e){try{return pe(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>I(e,t.name))}catch{return[]}}const et=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function tt(e){return/\.log\.\d+$/.test(e)}function nt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||tt(e)}function rt(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of $e(I(e.stagingDir,n)))nt(r)?Xe(r,t):r.endsWith(`.json`)?Ze(r,t):Qe(r,t);for(let n of $e(I(e.stagingDir,`state`))){let e=P(n);n.endsWith(`.jsonl`)?Xe(n,t):et.has(e)?Ze(n,t):Qe(n,t)}}const it=[`.ok`,`local`,`telemetry`],at=[`.ok`,`local`,`logs`],ot=[`.ok`,`local`,`loss-capture`],st=`spans-current.jsonl`,ct=`spans-prev.jsonl`,lt=`server-current.jsonl`,ut=`server-prev.jsonl`,dt=`loss-current.jsonl`,ft=`loss-prev.jsonl`;function pt(e){return I(e,...it,st)}function mt(e){return I(e,...it,ct)}function ht(e){return I(e,...at,lt)}function gt(e){return I(e,...at,ut)}function _t(e){return I(e,...ot,dt)}function vt(e){return I(e,...ot,ft)}const yt=1e3;async function bt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(yt)});return t.ok?await t.text():null}catch{return null}}async function xt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(yt)});return t.ok?await t.text():null}catch{return null}}async function St(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(yt)});return t.ok?await t.text():null}catch{return null}}function Ct(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
9
|
+
`)}\n`:null}catch{return null}}function wt(e){let t=I(e,`.git`,`ok`);if(!R(t))return null;let n=N(`git`,[`-C`,t,`log`,`--oneline`,`-50`],m({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Tt(e){let t=I(e,`.git`,`ok`);if(!R(t))return null;let n=N(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],m({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Et(){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 Dt(){return{nodeVersion:process.version,platform:be(),arch:_e()}}function Ot(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e){if(!R(e))return{};let t;try{t=(0,De.parse)(B(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(!J(t))return{};let n=t.telemetry;if(!J(n))return{};let r=n.localSink;return J(r)?r:{}}function At(e){return typeof e==`boolean`?e:void 0}function jt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return jt(e.maxBytes)}function Mt(e){let t=kt(y(`project`,e)),n=kt(y(`project-local`,e));return{enabled:At(n.enabled)??At(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Nt(e){return Ee(`sha256`).update(e).digest(`hex`)}function Pt(e){let t=B(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Ft(e){let t=B(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 X(e,t){if(!R(e))return!1;try{return z(F(t),{recursive:!0}),le(e,t),!0}catch{return!1}}function It(e){let t=[],n=e=>{let r=pe(e,{withFileTypes:!0});for(let i of r){let r=I(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Lt=new Set([`.jsonl`]);function Rt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Lt.has(e.slice(t))}const zt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Bt(e){if(tt(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:zt.has(e.slice(t))}function Vt(e){let t=[];for(let n of It(e)){let r=Ht(e,n);if(!Bt(r))continue;let{redacted:i,patterns:a,lineCount:o}=c(B(n,`utf-8`));a.length!==0&&(V(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Ht(e,t){return se(e,t).split(ce).join(`/`)}async function Ut(e){let t=L(e.contentDir),n=L(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??bt,s=r.fetchAgentEffects??xt,c=r.fetchWatcherRecent??St,l=r.readShadowHead??wt,u=r.readCheckpointRefs??Tt,d=r.now??(()=>new Date),f=r.okVersion??(()=>ae),p=r.readDesktopEnv??Et,m=r.readLanguage??Je,h=r.readRuntime??Dt,g=r.isOtlpPushEnabled??Ot,_=fe(I(Se(),`ok-bundle-`));try{z(I(_,`telemetry`),{recursive:!0}),z(I(_,`logs`),{recursive:!0}),z(I(_,`state`),{recursive:!0}),X(pt(n),I(_,`telemetry`,st)),X(mt(n),I(_,`telemetry`,ct)),X(ht(n),I(_,`logs`,lt)),X(gt(n),I(_,`logs`,ut));for(let t of e.userLogFiles??[])X(t,I(_,`logs`,P(t)));let v=I(n,`.ok`,`local`),y=I(v,`server.lock`),b=`not-running`,x=`no server.lock`,S=null;if(R(y)){X(y,I(_,`state`,`server.lock`));try{let e=B(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?S=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(S!==null){let e=await i(S);e===null?x=`agent-presence endpoint at :${S} unreachable`:(V(I(_,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await s(S);t!==null&&V(I(_,`state`,`agent-effects.json`),t);let n=await c(S);if(n!==null){let e=Ct(n);e!==null&&V(I(_,`state`,`watcher-recent.jsonl`),e)}}let C=l(t);C!==null&&V(I(_,`state`,`shadow-head.txt`),C);let w=u(t);w!==null&&V(I(_,`state`,`checkpoint-refs.txt`),w),X(_t(n),I(_,`state`,dt)),X(vt(n),I(_,`state`,ft)),X(I(v,`last-spawn-error.log`),I(_,`state`,`last-spawn-error.log`)),X(I(v,a),I(_,`state`,a)),X(I(v,o),I(_,`state`,o));let T=h(),E=p(),D=m(),ee={ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D}};V(I(_,`state`,`runtime.json`),`${JSON.stringify(ee,null,2)}\n`);let te=b===`running`?`running
|
|
10
|
+
`:`not-running (${x})\n`;if(V(I(_,`state`,`server-status.txt`),te),e.processDir&&R(e.processDir)){let t=I(_,`process`);z(t,{recursive:!0}),le(e.processDir,t,{recursive:!0})}let O=e.redact===!0;O&&rt({stagingDir:_,contentDir:t}),e.note&&V(I(_,`note.txt`),e.note);let k=null;e.scrubSecrets===!0&&(k=Vt(_));for(let t of e.extraFiles??[])X(t.sourcePath,I(_,`extra`,t.zipName??P(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let ne=Mt(n),re=It(_),A=[],j=0,ie=0;for(let e of re){let t=Ht(_,e),n=ge(e).size,r=Rt(t)?Pt(e):0;A.push({path:t,bytes:n,lines:r}),j+=n,t.startsWith(`telemetry/`)&&Rt(t)&&(ie+=Ft(e))}let ae={applied:O};k!==null&&(ae.secretScrub=k);let M={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D},contentDir:{pathSha256:Nt(t),absolutePath:O?`<CONTENT_DIR>`:t},telemetry:{localSink:ne,otlpPushEnabled:g()},redaction:ae,serverStatus:b,files:A};V(I(_,`manifest.json`),`${JSON.stringify(M,null,2)}\n`);let oe=re.some(e=>{try{return B(e,`utf-8`).includes(t)}catch{return!1}}),N={totalBytes:j,fileCount:A.length,docNameCount:ie,contentDirVisible:oe,redacted:O},F=!1;return{stagingDir:_,manifest:M,summary:N,cleanup:()=>{F||(F=!0,he(_,{recursive:!0,force:!0}))}}}catch(e){throw he(_,{recursive:!0,force:!0}),e}}async function Wt(e){let{collected:t,outputPath:n}=e,r=F(n);if(!R(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Ke.ZipFile,a=It(t.stagingDir);for(let e of a){let n=Ht(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 Gt(e,t){let n=I(e,`.ok`,`config.yml`);if(R(n))try{let t=(0,De.parse)(B(n,`utf-8`)),r=M(t)?t.content:void 0,i=M(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return L(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 L(e)}async function Kt(e,t,n,r){let i=Fe(t,e.logger),a=await Ut({contentDir:Gt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...Re(i,e.userLogsDir??I(H(),`.ok`,`logs`)),...Be(e.cachesDir??I(H(),`Library`,`Caches`))],deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{z(F(e.outputPath),{recursive:!0}),await Wt({collected:a,outputPath:e.outputPath});let t=a.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:i,files:a.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:a.manifest.createdAt}}}finally{a.cleanup()}}async function qt(e){let{projectDir:t}=e,n=e.readDesktopEnv??Et,r=e.readLanguage??Je;if(e.level===`full`&&t!==void 0)return Kt(e,t,n,r);let{zipPath:i,summary:a}=await Ge({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:Be(e.cachesDir??I(H(),`Library`,`Caches`)),logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:i,summary:{level:e.level,systemWide:t===void 0,projectSlug:a.projectSlug,files:a.files,redactions:a.redactions,redactedLineCount:a.redactedLineCount,generatedAt:a.generatedAt}}}function Z(e,t,n={}){let r=C(e,t);if(!R(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(B(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!b(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??x)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??S())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??ye();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Jt(e){return e.replace(/:\d+$/,``)}function Yt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Jt(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Jt(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Jt(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 Xt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Zt(e){return I(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Qt={existsSync:e=>R(e),readFileSync:(e,t)=>B(e,t),lstatSync:e=>de(e),readlinkSync:e=>me(e)};function $t(e,t=Qt){let n=Zt(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 en(e){let t=e.replace(Xt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function tn(e,t,n=Qt){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function nn(e){return E(e)||T(e)||j(e)}const rn=10*1024*1024;function an(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(!nn(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`?(he(a,{force:!0}),{kind:`removed`}):e.format===`toml`?cn(a,o):e.format===`yaml`?sn(a,e.topLevelKey,o):on(a,e.topLevelKey,e.serverMapSubKey,o)}function on(e,t,n,r){let i;try{i=B(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=O(i,ne(t,n,r));return o?(_(e,a,{mode:A(e)}),{kind:`removed`}):{kind:`not-present`}}function sn(e,t,n){let r;try{r=B(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,De.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=k(a);a.trim()===``||a.endsWith(`
|
|
11
|
+
`)?c.endsWith(`
|
|
12
|
+
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
13
|
+
`).replace(/\n/g,`\r
|
|
14
|
+
`));let u=`${i?``:``}${c}`;return u!==r&&_(e,u,{mode:A(e)}),{kind:`removed`}}function cn(e,t){let n=ie();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=B(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=k(a),s=a.trim()===``||a.endsWith(`
|
|
15
|
+
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
16
|
+
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
17
|
+
`).replace(/\n/g,`\r
|
|
18
|
+
`));let u=`${i?``:``}${l}`;return u!==r&&_(e,u,{mode:A(e)}),{kind:`removed`}}function ln(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function un(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 dn(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:d(r),command:r,isDesktop:ln(r)}}function fn(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`&&fn(e)?`ui-orphan`:`stale`}const pn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function mn(e){switch(e){case`running`:return G.default.green(e);case`desktop`:return G.default.blue(e);case`foreign`:return G.default.cyan(e);case`ui-orphan`:return G.default.magenta(e);case`stale`:return G.default.yellow(e)}}function hn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function gn(e){return`${hn(e.server.usage)} | ${hn(e.ui?.usage??null)}`}function _n(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function vn(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,_n(e),gn(e),t,String(n),un(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=mn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=G.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
19
|
+
`)}async function yn(e={}){let t=e.discover??p,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??u,a=e.resolveUsage??f,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=dn(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&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(vn(e.all?s:s.filter(e=>pn.has(Q(e)))))}function bn(){return new D(`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 yn({all:t.all===!0||e===`all`,json:t.json===!0})})}function xn(e,t,n={}){let r=n.isAlive??x,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function Sn(e){let t=e.inspect??(t=>Z(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=xn(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 Cn(e,t=x){let n=await p(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(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 wn(e){let t=Sn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Tn(e){return new D(`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=Sn({lockDir:h(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 yn({});return}if(n===`all`){let e=await p();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Z(n,`server`),r=Z(n,`ui`);!$(e,x)&&!$(r,x)||(wn(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 Cn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}wn(t);return}wn(h(L(Me(),n)))})}export{Me as _,Xt as a,$t as c,Z as d,qt as f,Ne as g,Pe as h,an as i,en as l,Wt as m,Tn as n,tn as o,Ut as p,bn as r,Zt as s,Sn as t,Yt as u,je as v,ke as y};
|
|
20
|
+
//# sourceMappingURL=src-BZYY4rMh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./src-C1ipB-PD.mjs";import"./write-project-skill-_XCsfJhR.mjs";import"./src-BZYY4rMh.mjs";import"./acp-harness-probe-DS_7zIK_.mjs";import"./init-DpK4E47u.mjs";import{n as e}from"./loader-DNYUnJfz.mjs";import"./skill-teardown-DMHte1Ul.mjs";import"./preview-CIC9NRPO.mjs";import"./mcp-migrate-event-B1gJf6bG.mjs";export{e as loadConfig};
|