@inkeep/open-knowledge 0.41.0-beta.2 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/{acp-harness-probe-3CFDDPVl.mjs → acp-harness-probe-DecRl8LO.mjs} +3 -3
  2. package/dist/assets/skills/discovery/SKILL.md +1 -1
  3. package/dist/assets/skills/project/SKILL.md +1 -1
  4. package/dist/cli.mjs +48 -48
  5. package/dist/constants-Cqeohkbe.mjs +2 -0
  6. package/dist/index.d.mts +1 -1
  7. package/dist/index.mjs +1 -1
  8. package/dist/init-BeJfZs6k.mjs +1 -0
  9. package/dist/init-DDBwCP2s.mjs +643 -0
  10. package/dist/{launch-json-removal-CptGKLK_.mjs → launch-json-removal-BYSfutY8.mjs} +2 -2
  11. package/dist/{loader-4upXoAKc.mjs → loader-BbIO0d5P.mjs} +2 -2
  12. package/dist/loader-sHkW9VkF.mjs +1 -0
  13. package/dist/{open-browser-BLiH8Wh1.mjs → open-browser-BvP05JKj.mjs} +2 -2
  14. package/dist/{preview-DxtFkMmQ.mjs → preview-B7LrVAQ_.mjs} +2 -2
  15. package/dist/preview-CJGkRFCh.mjs +1 -0
  16. package/dist/{repair-launch-json-D3XbPlDO.mjs → repair-launch-json-C3CNbBhP.mjs} +2 -2
  17. package/dist/repair-mcp-configs-De_QzF4I.mjs +2 -0
  18. package/dist/repair-skills-DnayrFzZ.mjs +1 -0
  19. package/dist/repair-skills-xgU4BBSK.mjs +4 -0
  20. package/dist/src-BRhvjLkk.mjs +22 -0
  21. package/dist/src-Cf8OhPA7.mjs +1 -0
  22. package/dist/{src-B1AY2I2p.mjs → src-DAzaO37g.mjs} +313 -313
  23. package/dist/{start-y5LmZhJG.mjs → start-Brjd-nh_.mjs} +2 -2
  24. package/dist/start-DPkQR_Bf.mjs +1 -0
  25. package/dist/{write-project-skill-CLv32EpR.mjs → write-project-skill-4OvW1cn1.mjs} +7 -7
  26. package/package.json +4 -5
  27. package/dist/constants-CZ8NFmlZ.mjs +0 -2
  28. package/dist/init-2yIvpr4B.mjs +0 -643
  29. package/dist/init-CtYgAsHx.mjs +0 -1
  30. package/dist/loader-CbsXNIN0.mjs +0 -1
  31. package/dist/preview-DkPNmdc1.mjs +0 -1
  32. package/dist/repair-mcp-configs-DY2IxCII.mjs +0 -2
  33. package/dist/repair-skills-BMHM_-y2.mjs +0 -3
  34. package/dist/repair-skills-Bnuf7XDW.mjs +0 -1
  35. package/dist/src-B4xOeCWv.mjs +0 -1
  36. package/dist/src-CnyjX5Lj.mjs +0 -22
  37. package/dist/start-zeyY0ALU.mjs +0 -1
  38. package/scripts/postinstall.mjs +0 -52
@@ -1 +0,0 @@
1
- import{g as e}from"./init-2yIvpr4B.mjs";export{e as runInit};
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-4upXoAKc.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-DxtFkMmQ.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1,2 +0,0 @@
1
- import{g as e,l as t,s as n}from"./write-project-skill-CLv32EpR.mjs";import{d as r,v as i}from"./init-2yIvpr4B.mjs";import{t as a}from"./mcp-migrate-event-CWx0WLdE.mjs";import{homedir as o}from"node:os";function s(e){let r=e.logger??u,i=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of n){let n=t[o],s=c(()=>n.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:n,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),n.projectConfigPath){let t=n.projectConfigPath,i=c(()=>t(e.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:n,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(t){let n={scope:t.scope,editorId:t.editorId,configPath:t.configPath},o=r(t.target,t.cwd,t.home,t.configPathOverride);if(o===null)return{...n,outcome:`no-entry`};if(e(o))return{...n,outcome:`canonical`};t.logger(a({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:o}));let s=i(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return t.logger({event:`mcp-config-repair-write-failed`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,error:e}),{...n,outcome:`write-failed`,error:e}}return s.action===`declined`?(t.logger({event:`mcp-config-repair-declined`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:s.declineReason}),{...n,outcome:`declined`}):{...n,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
- //# sourceMappingURL=repair-mcp-configs-DY2IxCII.mjs.map
@@ -1,3 +0,0 @@
1
- import{C as e}from"./src-3SN72BHH.mjs";import{Cr as t,Dr as n,Nr as r,Pr as i,Tr as a,br as o,kr as s,wr as c,yr as l}from"./src-B1AY2I2p.mjs";import{a as u,l as d,t as f,u as p,x as m}from"./write-project-skill-CLv32EpR.mjs";import{dirname as h,join as g,resolve as _}from"node:path";import{existsSync as v,mkdirSync as y,readFileSync as b,readdirSync as x,rmSync as S,statSync as C,writeFileSync as w}from"node:fs";import{homedir as T}from"node:os";const E={existsSync:e=>v(e),isDirectory:e=>{try{return C(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>x(e),readFileSync:e=>b(e),writeFileSync:(e,t)=>{w(e,t)},mkdirSync:(e,t)=>{y(e,t)},rmSync:(e,t)=>{S(e,t)}},D={resolveProjectBundledSkillDir:()=>s(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>s(e,{checkDesktop:!1}),readBundledVersion:()=>o(),readRecordedVersion:e=>t(e,`cli-hosts`),writeRecordedVersion:(e,t)=>a(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>n(e),readBundleDecision:(e,t)=>l(e,t),writeBundleDecision:(e,t,n)=>c(e,t,n),removeBundleFromDisk:(e,t)=>u(e,t)};function O(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function k(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(h(t),{recursive:!0}),A(e,t,n)}function A(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=g(e,r),a=g(t,r);n.isDirectory(i)?A(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function j(e,t,n,r,i,a){let o=[],s=g(e,`.agents`,`skills`,t),c=r.existsSync(s),l=!1;try{k(n,s,r),l=!0,o.push({kind:`central`,path:s,outcome:c?`overwritten`:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:c,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let c of p){let l=g(e,c.hostDir),u=g(l,`skills`,t);if(u===s){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(l)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-host-absent`});continue}let d=r.existsSync(u);try{k(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:d?`overwritten`:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:d,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,error:t})}}return{entries:o,centralWritten:l}}function M(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function N(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of p){let o=g(e,t.hostDir,`skills`,`open-knowledge`),s=g(o,`SKILL.md`),c=n.existsSync(s),l=d[t.editorId]?.projectConfigPath?.(e),u=!c&&M(l,n);if(!c&&!u){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{f(o,e),k(i,o,n);let s=c?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:c?`project-skill-reclaim-reclaimed`:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function P(t,n,a,o){let s=e=>{n.recordEvent(e).catch(()=>{})},c=()=>new Date().toISOString(),l;try{l=await n.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),s({ts:c(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await n.readRecordedVersion(t)}catch(e){o({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of i)try{d.push({id:e,sourceDir:n.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return o({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),s({ts:c(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let i of d){let s=r[i.id],c=a.existsSync(g(t,`.agents`,`skills`,s)),l=await n.readBundleDecision(t,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{n.removeBundleFromDisk(t,i.id),o({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:i.id})}catch(e){o({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:i.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await n.writeBundleDecision(t,s,!0)}catch(e){o({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:i.id,error:e instanceof Error?e.message:String(e)})}p.push(i)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>a.existsSync(g(t,`.agents`,`skills`,r[e.id])));if(u!==null&&u===l&&m)return o({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:l}),{outcome:`skipped`,reason:`version-current`};let h=[],_=d.length===i.length,v=!0;for(let{id:e,sourceDir:n}of p){let i=j(t,r[e],n,a,o,l);h.push(...i.entries),i.centralWritten||(v=!1)}let y=h.some(e=>e.kind===`central`&&(e.outcome===`written`||e.outcome===`overwritten`));if(_&&v&&y){let e=null;try{await n.writeRecordedVersion(t,l),o({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:l})}catch(t){e=t instanceof Error?t.message:String(t),o({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:l,error:e})}for(let{id:t}of p)s({ts:c(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?`installed`:`failed`,version:l,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{let e=h.some(e=>e.kind===`host`&&e.outcome===`failed`);s({ts:c(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:l,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:l,entries:h}}async function F(e){let t=e.logger??O,n=e.fs??E,r=e.home??T(),i={...D,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:N(e.projectDir,i,n,t),user:await P(r,i,n,t)}}function I(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function L(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
2
- `)}function R(){return new m(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").action(async()=>{let e=await F({projectDir:_(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${L(e)}\n`),process.exitCode=I(e)})}export{R as n,F as t};
3
- //# sourceMappingURL=repair-skills-BMHM_-y2.mjs.map
@@ -1 +0,0 @@
1
- import{t as e}from"./repair-skills-BMHM_-y2.mjs";export{e as repairSkills};
@@ -1 +0,0 @@
1
- import{Ba as e,C as t,Ea as n,Ha as r,Qa as i,Ta as a,d as o,l as s,uo as c,wa as l,y as u}from"./src-3SN72BHH.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Fr as W,Ft as G,G as K,Gi as q,Gn as J,Gr as Y,Gt as X,H as Z,Hi as Q,Hn as $,Hr as ee,Ht as te,I as ne,Ii as re,In as ie,Ir as ae,It as oe,J as se,Ji as ce,Jn as le,Jt as ue,K as de,Ki as fe,Kn as pe,Kt as me,L as he,Li as ge,Ln as _e,Lr as ve,Lt as ye,M as be,Mi as xe,Mn as Se,Mr as Ce,Mt as we,N as Te,Ni as Ee,Nn as De,Nr as Oe,Nt as ke,O as Ae,Oi as je,On as Me,Or as Ne,Ot as Pe,P as Fe,Pi as Ie,Pn as Le,Pr as Re,Pt as ze,Q as Be,Qi as Ve,Qn as He,Qr as Ue,Qt as We,R as Ge,Ri as Ke,Rn as qe,Rr as Je,Rt as Ye,S as Xe,Si as Ze,Sn as Qe,Sr as $e,St as et,T as tt,Ti as nt,Tn as rt,Tr as it,Tt as at,U as ot,Ui as st,Un as ct,Ur as lt,Ut as ut,V as dt,Vi as ft,Vn as pt,Vr as mt,Vt as ht,W as gt,Wi as _t,Wn as vt,Wr as yt,Wt as bt,X as xt,Xi as St,Xn as Ct,Xt as wt,Y as Tt,Yi as Et,Yn as Dt,Yt as Ot,Z as kt,Zi as At,Zn as jt,Zr as Mt,Zt as Nt,_ as Pt,_i as Ft,_n as It,_r as Lt,a as Rt,aa as zt,ai as Bt,an as Vt,ar as Ht,at as Ut,b as Wt,bi as Gt,bn as Kt,br as qt,bt as Jt,c as Yt,ca as Xt,ci as Zt,cn as Qt,cr as $t,ct as en,d as tn,da as nn,di as rn,dn as an,dr as on,dt as sn,ea as cn,ei as ln,en as un,er as dn,et as fn,f as pn,fa as mn,fi as hn,fn as gn,fr as _n,ft as vn,g as yn,gi as bn,gn as xn,gr as Sn,h as Cn,hi as wn,hn as Tn,hr as En,i as Dn,ia as On,ii as kn,in as An,ir as jn,it as Mn,j as Nn,ji as Pn,jn as Fn,jr as In,jt as Ln,k as Rn,ki as zn,kn as Bn,kr as Vn,kt as Hn,l as Un,la as Wn,li as Gn,ln as Kn,lr as qn,lt as Jn,m as Yn,ma as Xn,mi as Zn,mn as Qn,mr as $n,n as er,na as tr,ni as nr,nn as rr,nr as ir,nt as ar,o as or,oa as sr,oi as cr,on as lr,or as ur,ot as dr,p as fr,pa as pr,pi as mr,pn as hr,pr as gr,q as _r,qi as vr,qn as yr,qt as br,r as xr,ra as Sr,ri as Cr,rn as wr,rr as Tr,rt as Er,s as Dr,sa as Or,si as kr,sn as Ar,sr as jr,st as Mr,t as Nr,ta as Pr,ti as Fr,tn as Ir,tr as Lr,tt as Rr,u as zr,ua as Br,ui as Vr,un as Hr,ur as Ur,ut as Wr,v as Gr,vi as Kr,vn as qr,vr as Jr,w as Yr,wi as Xr,wn as Zr,wr as Qr,wt as $r,x as ei,xi as ti,xn as ni,xr as ri,xt as ii,y as ai,yi as oi,yn as si,yr as ci,yt as li,z as ui,zi as di,zn as fi,zr as pi,zt as mi}from"./src-B1AY2I2p.mjs";import{C as hi,E as gi,T as _i,_ as vi,b as yi,c as bi,d as xi,g as Si,i as Ci,l as wi,m as Ti,n as Ei,p as Di,s as Oi,t as ki,u as Ai,v as ji,w as Mi,x as Ni,y as Pi}from"./fs-traced-Cc6WsRtP.mjs";import{a as Fi,d as Ii,f as Li,i as Ri,l as zi,n as Bi,r as Vi,t as Hi,u as Ui}from"./logger-B7Z8XO-z.mjs";import{_ as Wi,a as Gi,b as Ki,c as qi,f as Ji,g as Yi,h as Xi,i as Zi,l as Qi,m as $i,n as ea,o as ta,p as na,r as ra,s as ia,t as aa,u as oa,v as sa,y as ca}from"./server-lock-D7lpEbZj.mjs";export{zt as AGENT_ID_MAX_LEN,sr as AGENT_ID_RE,di as AGENT_WRITE_ORIGIN,mn as AcpPermissionStore,Wn as AcpRegistry,re as AcpThreadManager,Ie as AgentFocusBroadcaster,Ee as AgentPresenceBroadcaster,S as AgentSessionCapacityError,ft as AgentSessionManager,Jt as AutoStartDisabledError,In as BUNDLE_IDS,Ce as BUNDLE_SCOPE,Oe as BUNDLE_SKILL_NAME,jt as BacklinkIndex,ce as CC1Broadcaster,r as CC1_CONTRACT_VERSION,Ar as CONFIG_FILENAME,pe as CONFLICT_MARKER_RE,Fr as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pt as ConfigSchema,Fn as DEFAULT_CHECKPOINT_RETENTION,Ft as DEFAULT_EMBEDDINGS_DIMENSIONS,Ye as DEFAULT_PACK_ID,K as DocumentDurabilityState,Kr as EMBEDDINGS_API_KEY_ENV,Br as FEATURED_AGENT_IDS,Se as FILE_SYSTEM_WRITER,Ct as FILE_WATCHER_ORIGIN,rn as FileEmbeddingsBackend,rr as GIT_PREFLIGHT_FAIL_SPAN_NAME,De as GIT_UPSTREAM_WRITER,pr as GitDirAccessError,jn as GitNotAvailableError,Ht as GitTooOldError,ii as HOCUSPOCUS_AUTH_REJECTION_REASONS,et as HocuspocusAuthRejection,A as HocuspocusAuthTokenSchema,kr as INSTALLED_AGENTS_SCHEMES,e as LINEAGE_EPOCH_KEY,Z as LIVE_DERIVED_INDEX_DEBOUNCE_MS,mi as LOG_MD_TEMPLATE,Hn as MANAGED_RENAME_ORIGIN,ge as MAX_ACP_THREADS,Q as MAX_AGENT_SESSIONS,sn as MCP_CONNECTION_ID_HEADER,l as MCP_SERVER_NAME,st as MIN_EVICTABLE_IDLE_MS,ur as MIN_GIT_VERSION,de as MISSING_OK_CONFIG_MESSAGE,Xn as MalformedGitPointerError,Er as McpLogger,_r as MissingOkConfigError,V as OBSERVER_SYNC_ORIGIN,Qt as OK_OKIGNORE_TEMPLATE,a as ORPHAN_MODES,c as PROTOCOL_VERSION,Hi as PinoLogger,qi as ProcessLockCollisionError,Un as ProjectGitInitError,b as ROLLBACK_ORIGIN,Kn as ROOT_GITIGNORE_TEMPLATE,Yi as RUNTIME_VERSION,Le as SERVICE_WRITER,z as SKILL_INSTALL_EVENTS_FILE_REL,u as SKILL_STATE_TARGETS,T as STARTER_FOLDERS,ht as STARTER_FOLDER_FRONTMATTER_FILENAME,te as STARTER_PACKS,ut as STARTER_PACK_IDS,bt as STARTER_TEMPLATES,I as STATE_MANIFEST_FILENAME,Wi as STATE_SCHEMA_VERSION,i as SYSTEM_DOC_NAME,wt as SeedPrerequisiteError,Nt as SeedRootDirError,aa as ServerLockCollisionError,Nr as SingleFileNotAFileError,er as SingleFileNotFoundError,xr as SingleFileNotMarkdownError,j as StateManifestError,tt as TagIndex,Re as USER_GLOBAL_BUNDLE_IDS,p as UiLockCollisionError,Ln as __getShowAllWalkStatsForTesting,we as __resetShowAllWalkStatsForTesting,Qi as acquireProcessLock,ea as acquireServerLock,dn as acquireUiLock,_t as applyAgentMarkdownWrite,Bn as applyExternalChange,ye as applySeed,Ae as assertCompatibleStateManifest,jr as assertGitAvailable,It as assertNeverDiskEvent,H as attachAcpThreadSocket,li as attachIdleShutdown,Gr as bootServer,Sn as buildAndOpenSkill,Hr as buildConfigYmlContent,Be as buildExecResult,Ke as buildOkMcpStdioCommand,Ne as buildSkillZip,X as buildStarterFolderFrontmatterYaml,U as buildWipTree,W as bundleSkillMdPath,hn as canonicalProjectKey,qr as classifyEvents,ki as classifyFsPath,mr as clearAllEmbeddingsKeys,Gt as clearContributors,me as coercePackId,s as colorFromSeed,ie as commitUpstreamImport,_e as commitWip,qe as commitWipFromTree,$t as compareSemver,Je as composeEffectiveLinterConfig,pi as composeFrontmatterSchemasConfig,yr as containsConflictMarkers,si as contentHash,ti as contributorCount,Ge as countShadowObjects,ui as countStaleAgentWipRefs,x as countWipRefs,ke as createApiExtension,_ as createAssetServeMiddleware,Mt as createContentFilter,Ue as createContentFilterAsync,Zn as createEmbeddingsSecretStore,Dn as createEphemeralProjectDir,v as createExternalChangeHandler,pn as createFileLogger,ot as createLiveDerivedIndexExtension,xt as createMcpHttpHandler,Zt as createOsProbe,Fe as createPersistenceExtension,E as createServer,be as createServerObserverExtension,q as createStreamingErrorWriter,Bi as createTestLogger,wn as describeStoredEmbeddingsKey,yn as detectClaudeDesktopPresence,qn as detectGit,Rn as detectProjectShape,dr as discoverLockDirs,ee as discoverMarkdownlintConfig,wr as emitPreflightFailureSpan,d as encodeDocName,fn as encodeFolderRoute,Rr as encodeSkillRoute,zr as ensureProjectGit,an as ensureProjectSkillGitignore,fe as errorResponse,Kt as evictStaleTrackerEntries,Mr as extractOkBinaryPath,He as extractWikiLinksFromMarkdown,Ur as fallbackPaths,tn as findEnclosingGitRoot,Tn as findEnclosingProjectRoot,lt as findNativeMarkdownlintFile,fr as flushFileLogger,$r as formatAuthRejectionWire,Ze as formatContributors,D as formatContributorsFrom,G as formatPackRationale,fi as gcCheckpointRefs,Mn as getCurrentMcpLogger,M as getLocalDir,Yn as getLogFilePath,Vi as getLogger,Cn as getLogsDir,Ki as getMachineId,Pi as getMeter,cn as getMetrics,yi as getTracer,Pr as handleCollabSocketError,nr as handleSpawnCursor,dt as hasGcLogLatch,o as iconFromClientName,tr as incrementCollabSocketFilteredError,Sr as incrementServerObserverFire,gn as initContent,C as initShadowRepo,Ni as initTelemetry,Wt as initToleranceTelemetryWriter,Wr as installPrettyZodErrors,Ri as installTestLoggers,Lt as installUserSkill,xe as isAllowedApiOrigin,We as isAllowedWorkspaceHostHeader,Et as isConfigDoc,at as isHocuspocusAuthRejectionReason,br as isKnownPackId,St as isLinkIndexExcludedDoc,h as isLoopbackAddress,At as isManagedArtifactDoc,n as isOrphanMode,ne as isPairedWriteOrigin,Cr as isPathWithinDir,sa as isProcessAlive,xn as isProjectRoot,_n as isProjectSkillManaged,Ve as isReservedForUserTree,ni as isSelfWrite,f as isSystemDoc,ei as isToleranceTelemetryEnabled,ca as isValidLockPid,Qe as lastKnownHash,pt as listRescueCheckpoints,ue as listStarterPacks,nn as loadCustomAgents,Te as loadPrincipal,oa as lockFilePath,Fi as loggerFactory,zi as logsCurrentPath,Ui as logsPreviousPath,bn as makeLazyEmbeddingsKeyStore,ra as markServerLockDraining,se as mountMcpAndApi,Ei as normalizeFsPath,ae as originGitHubHost,hr as packageVersionMajorMinor,B as parseAuthRejectionWire,on as parseGitVersion,F as parseHocuspocusAuthToken,Tt as parseKeepaliveConnectionId,O as pathToDocName,oe as planSeed,Rt as prepareSingleFileOpen,en as processCommand,Jn as processUsage,Jr as readAllTargets,ci as readBundleDecision,yt as readOwnNativeRules,Ji as readProcessLock,na as readProcessLockDetailed,gt as readProjectHeadState,Vr as readProjectLocalSemanticConfig,Zi as readServerLock,qt as readServerPackageVersion,ri as readSkillInstallStateSnapshot,gr as readSkillManagement,g as readStateManifest,$e as readTargetRecordedAt,k as readTargetVersion,Lr as readUiLock,le as reconcile,Xr as recordContributor,P as recordSkillInstallEvent,kt as registerAllTools,Zr as registerWrite,$i as releaseProcessLock,Gi as releaseServerLock,ir as releaseUiLock,rt as removeLastKnownHash,On as resetMetrics,t as resolveBundleEnabled,Vn as resolveBundledSkillDir,je as resolveContentDir,kn as resolveCursorBinaryDefault,Bt as resolveCursorSpawnInvocation,w as resolveEffectiveLinterConfig,oi as resolveEmbeddingsCredential,zn as resolveLockDir,mt as resolveNativeConfigForDoc,Y as resolveNativeMarkdownlintConfig,Ot as resolvePack,Dr as resolvePackageVersion,ar as resolveUiInfo,nt as restoreContributors,ai as restoreLifecycleFromConflictsJson,m as rewriteMarkdownLinksForDocumentRename,ln as rewriteWikiLinksForDocumentRename,An as runAuthReposSubprocess,Vt as runAuthStatusSubprocess,un as runCloneSubprocess,lr as runDeviceFlowSubprocess,Ut as runWithMcpLogger,Pn as safeContentPath,ze as safeSubdir,$ as safetyCheckpoint,vn as sanitizeClientName,ct as saveInMemoryCheckpoint,vt as saveVersion,Pe as seedBasenameIndex,or as serializeError,hi as setActiveSpanAttributes,he as setupServerObservers,J as shadowGit,Mi as shutdownTelemetry,$n as skillManagementPath,Ii as spansCurrentPath,Li as spansPreviousPath,cr as spawnDetached,Dt as splitMarkdownBlocks,R as startWatcher,vr as streamingProblemEvent,L as swapContributors,Xe as teardownToleranceTelemetryWriter,Or as toBroadcasterKey,Ci as tracedAppendFileSync,Oi as tracedLinkSync,bi as tracedMkdir,wi as tracedMkdirSync,Ai as tracedRename,xi as tracedRenameSync,Di as tracedRmSync,Ti as tracedRmdirSync,Si as tracedUnlinkSync,vi as tracedWriteFile,ji as tracedWriteFileSync,Yr as trustSystemCertificates,Yt as untrackTrackedProjectSkillProjection,N as updateLastKnownHash,Xi as updateProcessLockPort,ta as updateServerLockPort,Tr as updateUiLockPort,Xt as validateAgentId,Ir as validateCloneInputs,y as validateSkillZip,ia as waitForServerLockDrain,Gn as withHiddenWindowsConsole,_i as withSpan,gi as withSpanSync,Qr as writeBundleDecision,ve as writeMarkdownlintRule,Qn as writeRootGitignoreForNewRepo,En as writeSkillManagement,Nn as writeStateManifest,it as writeTargetVersion,Me as writeTracker};
@@ -1,22 +0,0 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,ka as r}from"./src-3SN72BHH.mjs";import{ct as i,hn as a,ki as o,li as s,lt as c,ot as l,st as u,va as d}from"./src-B1AY2I2p.mjs";import{K as f}from"./sleep-B2L0pvp4.mjs";import{O as p,P as m}from"./fs-traced-Cc6WsRtP.mjs";import{b as h,u as g,v as _,y as v}from"./server-lock-D7lpEbZj.mjs";import{t as y}from"./yazl-BafwB467.mjs";import{_ as b,g as x,i as S,l as C,x as w}from"./write-project-skill-CLv32EpR.mjs";import{c as T}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-3CFDDPVl.mjs";import{D as ee,E,S as D,T as O,_ as te,b as ne,o as k,v as A}from"./init-2yIvpr4B.mjs";import{n as re}from"./constants-CZ8NFmlZ.mjs";import{t as j}from"./is-object-ByG7RnjH.mjs";import"./loader-4upXoAKc.mjs";import"./preview-DxtFkMmQ.mjs";import{execSync as ie,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,isAbsolute as ae,join as F,relative as oe,resolve as I,sep as se}from"node:path";import{cpSync as ce,createWriteStream as le,existsSync as L,lstatSync as ue,mkdirSync as R,mkdtempSync as de,readFileSync as z,readdirSync as B,readlinkSync as fe,rmSync as V,statSync as pe,writeFileSync as H}from"node:fs";import{arch as me,freemem as he,homedir as ge,hostname as _e,platform as ve,release as ye,tmpdir as be,totalmem as xe,type as Se,uptime as Ce}from"node:os";import{realpath as U}from"node:fs/promises";import{createHash as W}from"node:crypto";var G=f();const we=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Te(e,t,n=a){if(e!==void 0&&!we.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ee=null;function De(e){Ee=e}function Oe(){return Ee??process.cwd()}const ke=[{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]@`}],Ae=ke.map(e=>e.name);function je(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 ke)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 Me(){return F(ge(),`.ok`,`bug-reports`)}function Ne(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`);return F(Me(),`${t}-bugreport.zip`)}function Pe(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let e=z(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 L(F(e,`.ok`))?W(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Fe(){let e={timestamp:new Date().toISOString(),platform:ve(),osType:Se(),osRelease:ye(),hostname:`[redacted]`,uptime:Ce(),freeMem:he(),totalMem:xe(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ie(`sw_vers -productVersion 2>/dev/null`,s({encoding:`utf8`})).trim()}catch{}try{let t=F(__dirname,`..`,`..`,`package.json`);L(t)&&(e.okVersion=JSON.parse(z(t,`utf8`)).version)}catch{}return e}function Ie(e,t){if(!L(t))return{files:[]};let n=B(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>F(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return z(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function Le(e){let n=F(e,`.ok`,`local`);return L(n)?{files:[`server.lock`,`last-spawn-error.log`,t].map(e=>F(n,e)).filter(e=>L(e))}:{files:[]}}function Re(e){let t=F(e,`.ok`,`local`,`logs`);return L(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function ze(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=je(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 Be(e){for(let t of e.files)try{ze({zipfile:e.zipfile,name:`${e.prefix}/${N(t)}`,content:z(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 Ve(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??F(ge(),`.ok`,`logs`),o=t.projectDir?Pe(t.projectDir,i):null;R(P(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let s=Fe();s.desktop=t.desktop??null;let{files:c}=Ie(o,a),{files:l}=t.projectDir?Le(t.projectDir):{files:[]},{files:u}=t.projectDir?Re(t.projectDir):{files:[]};i?.info({logFileCount:c.length,lockFileCount:l.length,localSinkFileCount:u.length},`files collected`);let d=[],f=[],{ZipFile:p}=await import(`./yazl-vwTkB7U0.mjs`).then(t=>e(t.default,1)),m=new p;Be({zipfile:m,files:c,prefix:`logs`,redact:n,bundleFiles:f,redactions:d,logger:i}),Be({zipfile:m,files:l,prefix:`lockdir`,redact:n,bundleFiles:f,redactions:d,logger:i}),Be({zipfile:m,files:u,prefix:`local-logs`,redact:n,bundleFiles:f,redactions:d,logger:i});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(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&&ze({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: ${Ae.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 He=e(y(),1),K=e(T(),1);const Ue=new Set([`doc.name`,`currentDoc`]);function We(e){return`doc:${W(`sha256`).update(e).digest(`hex`).slice(0,8)}`}function Ge(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 Ke(e,t){let n=t.originalToHashed.get(e);if(n!==void 0)return n;let r=We(e);return t.originalToHashed.set(e,r),Ge(t,e,r),r}function qe(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return qe(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!Je(e))return e;let n=typeof e.key==`string`&&Ue.has(e.key)&&Je(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`&&Je(a)){let e=Ke(n,t);r[i]={...a,stringValue:e}}else Ue.has(i)&&typeof a==`string`?r[i]=Ke(a,t):r[i]=q(a,t);return r}function Ye(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 Xe(e,t){let n=z(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=q(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}H(e,r?`${a.join(`
7
- `)}\n`:a.join(`
8
- `))}function Ze(e,t){let n=z(e,`utf-8`);if(n.trim().length!==0)try{let r=q(JSON.parse(n),t),i=n.endsWith(`
9
- `)?`
10
- `:``;H(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Ye(qe(n,t.contentDir),t);r!==n&&H(e,r)}}function Qe(e,t){let n=z(e,`utf-8`),r=qe(n,t.contentDir);r!==n&&H(e,r)}function $e(e){try{return B(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>F(e,t.name))}catch{return[]}}const et=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function tt(e){let t={contentDir:e.contentDir,docNameMap:{},originalToHashed:new Map,docNameCollisions:{}};for(let n of[`telemetry`,`logs`,`process`])for(let r of $e(F(e.stagingDir,n)))r.endsWith(`.jsonl`)?Xe(r,t):r.endsWith(`.json`)?Ze(r,t):Qe(r,t);for(let n of $e(F(e.stagingDir,`state`))){let e=N(n);n.endsWith(`.jsonl`)?Xe(n,t):et.has(e)?Ze(n,t):Qe(n,t)}return{docNameMap:t.docNameMap,docNameCollisions:t.docNameCollisions}}const nt=[`.ok`,`local`,`telemetry`],rt=[`.ok`,`local`,`logs`],it=`spans-current.jsonl`,at=`spans-prev.jsonl`,ot=`server-current.jsonl`,st=`server-prev.jsonl`;function ct(e){return F(e,...nt,it)}function lt(e){return F(e,...nt,at)}function ut(e){return F(e,...rt,ot)}function dt(e){return F(e,...rt,st)}const ft=1e3;async function pt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(ft)});return t.ok?await t.text():null}catch{return null}}async function mt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(ft)});return t.ok?await t.text():null}catch{return null}}async function ht(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(ft)});return t.ok?await t.text():null}catch{return null}}function gt(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(`
11
- `)}\n`:null}catch{return null}}function _t(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`log`,`--oneline`,`-50`],s({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function vt(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],s({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function yt(){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 bt(){return{nodeVersion:process.version,platform:ve(),arch:me()}}function xt(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function St(e){if(!L(e))return{};let t;try{t=(0,G.parse)(z(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 Ct(e){return typeof e==`boolean`?e:void 0}function wt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return wt(e.maxBytes)}function Tt(e){let t=St(p(`project`,e)),n=St(p(`project-local`,e));return{enabled:Ct(n.enabled)??Ct(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Et(e){return W(`sha256`).update(e).digest(`hex`)}function Dt(e){let t=z(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Ot(e){let t=z(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){return L(e)?(R(P(t),{recursive:!0}),ce(e,t),!0):!1}function kt(e){let t=[],n=e=>{let r=B(e,{withFileTypes:!0});for(let i of r){let r=F(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const At=new Set([`.jsonl`]);function jt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:At.has(e.slice(t))}const Mt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Nt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Mt.has(e.slice(t))}function Pt(e){let t=[];for(let n of kt(e)){let r=Ft(e,n);if(!Nt(r))continue;let{redacted:i,patterns:a,lineCount:o}=je(z(n,`utf-8`));a.length!==0&&(H(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Ft(e,t){return oe(e,t).split(se).join(`/`)}async function It(e){let r=I(e.contentDir),i=I(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??pt,s=a.fetchAgentEffects??mt,c=a.fetchWatcherRecent??ht,l=a.readShadowHead??_t,u=a.readCheckpointRefs??vt,d=a.now??(()=>new Date),f=a.okVersion??(()=>re),p=a.readDesktopEnv??yt,m=a.readRuntime??bt,h=a.isOtlpPushEnabled??xt,g=de(F(be(),`ok-bundle-`));try{R(F(g,`telemetry`),{recursive:!0}),R(F(g,`logs`),{recursive:!0}),R(F(g,`state`),{recursive:!0}),X(ct(i),F(g,`telemetry`,it)),X(lt(i),F(g,`telemetry`,at)),X(ut(i),F(g,`logs`,ot)),X(dt(i),F(g,`logs`,st));let _=F(i,`.ok`,`local`),v=F(_,`server.lock`),y=`not-running`,b=`no server.lock`,x=null;if(L(v)){X(v,F(g,`state`,`server.lock`));try{let e=z(v,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?x=t.port:b=`lock present but no port`}catch{b=`lock present but unparseable`}}if(x!==null){let e=await o(x);e===null?b=`agent-presence endpoint at :${x} unreachable`:(H(F(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await s(x);t!==null&&H(F(g,`state`,`agent-effects.json`),t);let n=await c(x);if(n!==null){let e=gt(n);e!==null&&H(F(g,`state`,`watcher-recent.jsonl`),e)}}let S=l(r);S!==null&&H(F(g,`state`,`shadow-head.txt`),S);let C=u(r);C!==null&&H(F(g,`state`,`checkpoint-refs.txt`),C),X(F(_,`last-spawn-error.log`),F(g,`state`,`last-spawn-error.log`)),X(F(_,n),F(g,`state`,n)),X(F(_,t),F(g,`state`,t));let w=m(),T=p(),ee={ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T}};H(F(g,`state`,`runtime.json`),`${JSON.stringify(ee,null,2)}\n`);let E=y===`running`?`running
12
- `:`not-running (${b})\n`;if(H(F(g,`state`,`server-status.txt`),E),e.processDir&&L(e.processDir)){let t=F(g,`process`);R(t,{recursive:!0}),ce(e.processDir,t,{recursive:!0})}let D=null;e.redact===!0&&(D=tt({stagingDir:g,contentDir:r})),e.note&&H(F(g,`note.txt`),e.note);let O=null;e.scrubSecrets===!0&&(O=Pt(g));for(let t of e.extraFiles??[])X(t.sourcePath,F(g,`extra`,t.zipName??N(t.sourcePath)))||a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let te=Tt(i),ne=kt(g),k=[],A=0,re=0;for(let e of ne){let t=Ft(g,e),n=pe(e).size,r=jt(t)?Dt(e):0;k.push({path:t,bytes:n,lines:r}),A+=n,t.startsWith(`telemetry/`)&&jt(t)&&(re+=Ot(e))}let j=D===null?{applied:!1,docNameMapSidecar:null}:Object.keys(D.docNameCollisions).length>0?{applied:!0,docNameMapSidecar:null,docNameCollisions:D.docNameCollisions}:{applied:!0,docNameMapSidecar:null};O!==null&&(j.secretScrub=O);let ie={schemaVersion:1,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T},contentDir:{pathSha256:Et(r),absolutePath:D===null?r:`<CONTENT_DIR>`},telemetry:{localSink:te,otlpPushEnabled:h()},redaction:j,serverStatus:y,files:k};H(F(g,`manifest.json`),`${JSON.stringify(ie,null,2)}\n`);let M=ne.some(e=>{try{return z(e,`utf-8`).includes(r)}catch{return!1}}),P={totalBytes:A,fileCount:k.length,docNameCount:re,contentDirVisible:M,redacted:D!==null},ae=!1;return{stagingDir:g,manifest:ie,summary:P,redactionMapPayload:D===null?null:{docNameMap:D.docNameMap,docNameCollisions:D.docNameCollisions},cleanup:()=>{ae||(ae=!0,V(g,{recursive:!0,force:!0}))}}}catch(e){throw V(g,{recursive:!0,force:!0}),e}}async function Lt(e){let{collected:t,outputPath:n}=e,r=P(n);if(!L(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=`${N(n,`.zip`)}.docnames.json`,r={...t.manifest,redaction:{...t.manifest.redaction,applied:!0,docNameMapSidecar:e}};H(F(t.stagingDir,`manifest.json`),`${JSON.stringify(r,null,2)}\n`)}let i=new He.ZipFile,a=kt(t.stagingDir);for(let e of a){let n=Ft(t.stagingDir,e);i.addFile(e,n)}i.end(),t.redactionMapPayload!==null&&H(F(r,`${N(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 Rt(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let t=(0,G.parse)(z(n,`utf-8`)),r=j(t)?t.content:void 0,i=j(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return I(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 I(e)}async function zt(e,t,n){let r=await It({contentDir:Rt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,deps:{readDesktopEnv:n,logger:e.logger}});try{R(P(e.outputPath),{recursive:!0}),await Lt({collected:r,outputPath:e.outputPath});let n=r.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:Pe(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 Bt(e){let{projectDir:t}=e,n=e.readDesktopEnv??yt;if(e.level===`full`&&t!==void 0)return zt(e,t,n);let{zipPath:r,summary:i}=await Ve({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 Z(e,t,n={}){let r=g(e,t);if(!L(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(z(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!v(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??_)(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??_e();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Vt(e){return e.replace(/:\d+$/,``)}function Ht(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Vt(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Vt(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Vt(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 Ut(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=r(t.hostname);if(n===null)return null;let i=t.pathname.split(`/`).filter(e=>e.length>0);if(i.length<5||i[2]!==`blob`)return null;let a,o,s,c;try{a=decodeURIComponent(i[0]),o=decodeURIComponent(i[1]),s=decodeURIComponent(i[3]),c=i.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.length===0||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function Wt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=r(t.hostname);if(n===null)return null;let i=t.pathname.split(`/`);if(i.length<5||i[0]!==``||i[3]!==`tree`)return null;let a=i.slice(5);a.length===1&&a[0]===``&&a.pop();let o,s,c,l;try{o=decodeURIComponent(i[1]),s=decodeURIComponent(i[2]),c=decodeURIComponent(i[4]),l=a.map(e=>decodeURIComponent(e))}catch{return null}return!o||!s||!c||l.some(e=>e.length===0)?null:{host:n,owner:o,repo:s,branch:c,path:l.join(`/`)}}function Gt(e){let t=Ut(e);if(t)return{kind:`doc`,...t};let n=Wt(e);return n?{kind:`folder`,...n}:null}const Kt=`# >>> open-knowledge cli >>>`,qt=`# <<< open-knowledge cli <<<`,Jt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Yt(e){return F(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Xt={existsSync:e=>L(e),readFileSync:(e,t)=>z(e,t),lstatSync:e=>ue(e),readlinkSync:e=>fe(e)};function Zt(e,t=Xt){let n=Yt(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 Qt(e){let t=e.replace(Jt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function $t(e,t,n=Xt){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function en(e){return x(e)||b(e)||D(e)}const tn=10*1024*1024;function nn(e,t,n,r){let i=k(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(!en(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`?(V(a,{force:!0}),{kind:`removed`}):e.format===`toml`?on(a,o):e.format===`yaml`?an(a,e.topLevelKey,o):rn(a,e.topLevelKey,e.serverMapSubKey,o)}function rn(e,t,n,r){let i;try{i=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>tn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=ee(i,te(t,n,r));return o?(m(e,a,{mode:O(e)}),{kind:`removed`}):{kind:`not-present`}}function an(e,t,n){let r;try{r=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>tn)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 s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=E(a);a.trim()===``||a.endsWith(`
13
- `)?c.endsWith(`
14
- `)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
15
- `).replace(/\n/g,`\r
16
- `));let u=`${i?``:``}${c}`;return u!==r&&m(e,u,{mode:O(e)}),{kind:`removed`}}function on(e,t){let n=ne();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=E(a),s=a.trim()===``||a.endsWith(`
17
- `),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(`
18
- `)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
19
- `).replace(/\n/g,`\r
20
- `));let u=`${i?``:``}${l}`;return u!==r&&m(e,u,{mode:O(e)}),{kind:`removed`}}function sn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function cn(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 ln(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:u(r),command:r,isDesktop:sn(r)}}function un(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`&&un(e)?`ui-orphan`:`stale`}const dn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function fn(e){switch(e){case`running`:return K.default.green(e);case`desktop`:return K.default.blue(e);case`foreign`:return K.default.cyan(e);case`ui-orphan`:return K.default.magenta(e);case`stale`:return K.default.yellow(e)}}function pn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function mn(e){return`${pn(e.server.usage)} | ${pn(e.ui?.usage??null)}`}function hn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function gn(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,hn(e),mn(e),t,String(n),cn(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=fn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=K.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
21
- `)}async function _n(e={}){let t=e.discover??l,n=e.inspect??Z,r=e.log??(e=>console.log(e)),a=e.resolveCommand??i,o=e.resolveUsage??c,s=await t(),u=[];for(let e of s){let t=n(e,`server`),r=n(e,`ui`),i=ln(e,t,r,t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:o(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:o(r.lock.pid));i!=null&&u.push(i)}if(e.json){let e=u.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(gn(e.all?u:u.filter(e=>dn.has(Q(e)))))}function vn(){return new w(`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 _n({all:t.all===!0||e===`all`,json:t.json===!0})})}function yn(e,t,n={}){let r=n.isAlive??_,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 bn(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=yn(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 xn(e,t=_){let n=await l(),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 Sn(e){let t=bn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Cn(e){return new w(`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=bn({lockDir:o(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 _n({});return}if(n===`all`){let e=await l();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,_)&&!$(r,_)||(Sn(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 xn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Sn(t);return}Sn(o(I(Oe(),n)))})}function wn(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Tn(e,t){let n,i;try{n=await U(I(e)),i=await U(I(P(e)))}catch{return{kind:`not-git`}}if(!En(n,i))return{kind:`symlink-escape`};let a=F(n,`.git`),o;try{o=pe(a)}catch{return{kind:`not-git`}}if(o.isDirectory()){let e;try{e=await U(a)}catch{return{kind:`not-git`}}if(!En(e,n))return{kind:`symlink-escape`}}else if(!o.isFile())return{kind:`not-git`};let s=d(n);if(s.kind!==`repository`)return{kind:`not-git`};let c=s.repository.readRemoteUrl(`origin`);if(c.kind===`unreadable`)return{kind:`not-git`};if(c.kind===`absent`)return c.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let l=c.url,u=Ht(l);if(u===null)return{kind:`non-github`};let f=r(u.hostname);if(f===null)return{kind:`non-github`};let p=f===t.host.toLowerCase(),m=u.owner.toLowerCase()===t.owner.toLowerCase(),h=u.name.toLowerCase()===t.repo.toLowerCase();return!p&&m&&h?{kind:`wrong-host`,actualHost:f}:!p||!m||!h?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://${f}/${u.owner}/${u.name}.git`}}function En(e,t){if(e===t)return!0;let n=oe(t,e);return n.length>0&&!n.startsWith(`..`)&&!ae(n)}const Dn=[{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=A(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=S(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 On(e,t,n={},r=Dn){let i=[];for(let a of t){let t=C[a];for(let a of r)i.push(a.write(t,e,n))}return i}function kn(e,t,n={}){return{integrations:On(e,t,n)}}export{Ne as C,Te as D,De as E,Lt as S,Oe as T,Wt as _,Cn as a,Bt as b,Kt as c,$t as d,Yt as f,Gt as g,Ut as h,bn as i,Jt as l,Qt as m,Tn as n,vn as o,Zt as p,wn as r,nn as s,kn as t,qt as u,Ht as v,je as w,It as x,Z as y};
22
- //# sourceMappingURL=src-CnyjX5Lj.mjs.map
@@ -1 +0,0 @@
1
- import{_ as e,f as t,r as n}from"./start-y5LmZhJG.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * `@inkeep/open-knowledge` postinstall hook.
4
- *
5
- * Fires `installUserSkill()` once per `npm install` / `bun install` / `npx`
6
- * cache population. Non-fatal: any failure is swallowed so the host install
7
- * never blocks.
8
- *
9
- */
10
-
11
- async function run() {
12
- let installUserSkill;
13
- try {
14
- // Relative import resolves inside the published npm tarball at
15
- // <pkg-root>/dist/index.mjs — the tsdown-bundled entry that re-exports
16
- // `installUserSkill` from @inkeep/open-knowledge-server.
17
- const mod = await import('../dist/index.mjs');
18
- installUserSkill = mod.installUserSkill;
19
- } catch {
20
- // Dev-install scenarios (e.g. running `npm install` against a tarball
21
- // where dist/ is missing, `--ignore-scripts`, or source-only installs)
22
- // never block — fall through to exit 0.
23
- return;
24
- }
25
-
26
- if (typeof installUserSkill !== 'function') return;
27
-
28
- let result;
29
- try {
30
- result = await installUserSkill();
31
- } catch {
32
- // installUserSkill is documented as never-throws; this catch is pure
33
- // defensive hardening so a broken build never blocks `npm install`.
34
- return;
35
- }
36
-
37
- if (result === 'installed') {
38
- process.stdout.write('[open-knowledge] Agent Skill installed to detected agent hosts.\n');
39
- } else if (result === 'failed') {
40
- process.stderr.write(
41
- '[open-knowledge] Agent Skill auto-install failed; run manually: ' +
42
- "npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy\n",
43
- );
44
- }
45
- // result === 'skip-current' → silent.
46
- }
47
-
48
- // Fire-and-forget. Always exit 0 regardless of outcome —
49
- // `npm install` must never fail because skill-install hit an edge case.
50
- run().finally(() => {
51
- process.exit(0);
52
- });