@inkeep/open-knowledge 0.43.0-beta.0 → 0.43.0-beta.10

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 (138) hide show
  1. package/dist/{acp-harness-probe-BI6bXf3a.mjs → acp-harness-probe-D9cTkuMT.mjs} +2 -2
  2. package/dist/assets/skills/discovery/SKILL.md +1 -1
  3. package/dist/assets/skills/project/SKILL.md +1 -1
  4. package/dist/assets/skills/write-skill/SKILL.md +1 -1
  5. package/dist/cli.mjs +50 -50
  6. package/dist/config-schema.json +26 -0
  7. package/dist/config.project.schema.json +26 -0
  8. package/dist/constants-BT3Cjn4w.mjs +2 -0
  9. package/dist/fs-traced-CeWo_16n.mjs +1 -0
  10. package/dist/{fs-traced-BmZQL7v9.mjs → fs-traced-DDm-belY.mjs} +2 -2
  11. package/dist/git-handle-BS2VGYSG.mjs +1 -0
  12. package/dist/{git-handle-bosCq-DO.mjs → git-handle-UIC7K5Fw.mjs} +2 -2
  13. package/dist/index.d.mts +4 -4
  14. package/dist/index.mjs +1 -1
  15. package/dist/{init-BUp3cQ_4.mjs → init-C3jLZpVV.mjs} +33 -33
  16. package/dist/init-mD_V5dOp.mjs +1 -0
  17. package/dist/{launch-json-removal-CwOqJJze.mjs → launch-json-removal-XwBCEaAO.mjs} +2 -2
  18. package/dist/{loader-y7Mn8M-Z.mjs → loader-BYtT6HwT.mjs} +2 -2
  19. package/dist/loader-CqtToSGf.mjs +1 -0
  20. package/dist/md-manager-DP9jzxy1.mjs +2 -0
  21. package/dist/{open-browser-CkLowmAw.mjs → open-browser-CGiyukoG.mjs} +2 -2
  22. package/dist/parse-worker.mjs +1 -1
  23. package/dist/preview-BCOpQaY2.mjs +1 -0
  24. package/dist/{preview-BV8bR51k.mjs → preview-DlzwRGU_.mjs} +2 -2
  25. package/dist/public/assets/{ActivityModeContent-CCFHLlT9.js → ActivityModeContent-BjW-VNSE.js} +1 -1
  26. package/dist/public/assets/{AgentDiffPane-CQfhJYfr.js → AgentDiffPane-j36DVL1g.js} +1 -1
  27. package/dist/public/assets/{AgentThreadClientBinder-DZwzRPDa.js → AgentThreadClientBinder-CE6rI2aT.js} +1 -1
  28. package/dist/public/assets/{CodeMirrorPropInput-BqDZpzvH.js → CodeMirrorPropInput-CVrIx84a.js} +2 -2
  29. package/dist/public/assets/DocumentContext-BBZuJCfz.js +38 -0
  30. package/dist/public/assets/{EditorModeToggle-1xLWvnWd.js → EditorModeToggle-CX5Jh4N0.js} +1 -1
  31. package/dist/public/assets/{EnableSyncConfirmDialog-CPuodmd5.js → EnableSyncConfirmDialog-B10u8n1i.js} +1 -1
  32. package/dist/public/assets/FeedbackForm-DxEuHipa.js +1 -0
  33. package/dist/public/assets/{GraphPanel-U2ZyS1Aa.js → GraphPanel-CJYpjaIw.js} +2 -2
  34. package/dist/public/assets/LintConfigEditor-CgfN9-PD.js +1 -0
  35. package/dist/public/assets/{ManagedArtifactProperties-EDghUFni.js → ManagedArtifactProperties-BDVq5wN3.js} +1 -1
  36. package/dist/public/assets/{McpConsentDialogBody-C8VSVSPz.js → McpConsentDialogBody-Coe3N-YS.js} +1 -1
  37. package/dist/public/assets/{MermaidDocEditor-BwjUe5g_.js → MermaidDocEditor-DcZ_-MzA.js} +1 -1
  38. package/dist/public/assets/PropertyPanel-BISGQmxU.js +2 -0
  39. package/dist/public/assets/ReportBugDialogBody-C5wWE46i.js +3 -0
  40. package/dist/public/assets/SchemaConfigEditor-B3eLp98_.js +1 -0
  41. package/dist/public/assets/{SettingsDialogBody-_7c5ty2t.js → SettingsDialogBody-D4dqeST7.js} +3 -3
  42. package/dist/public/assets/{ShareBranchSwitchDialog-Dj6PdkLL.js → ShareBranchSwitchDialog-D_HYrO-M.js} +1 -1
  43. package/dist/public/assets/{ShareReceiveDialog-Cmfia-Vl.js → ShareReceiveDialog-CCw_xKkg.js} +1 -1
  44. package/dist/public/assets/{ShareReceiveMissDialog-xHTJ1V_2.js → ShareReceiveMissDialog-TDfzNW6D.js} +1 -1
  45. package/dist/public/assets/{SkillEditorActions-Cw7itVro.js → SkillEditorActions-Donhizbo.js} +1 -1
  46. package/dist/public/assets/SourceEditor-D2SZ5OF3.js +1 -0
  47. package/dist/public/assets/{TerminalPanel-Dfvz7JrY.js → TerminalPanel-C7pIldJ0.js} +2 -2
  48. package/dist/public/assets/{TerminalSessionsHost-D6vvdN1I.js → TerminalSessionsHost-BTWnv_Gu.js} +2 -2
  49. package/dist/public/assets/{TerminalWindowApp-CfeLvqLD.js → TerminalWindowApp-iqp-Np-a.js} +1 -1
  50. package/dist/public/assets/{ThreadView-S_XJwwbZ.js → ThreadView-DbS6XYBN.js} +3 -3
  51. package/dist/public/assets/{TimelineDiffPane-DgS-xWyU.js → TimelineDiffPane-CT7VsrDy.js} +1 -1
  52. package/dist/public/assets/{agent-diff-store-Cn0Zbsuy.js → agent-diff-store-CmJJu7WO.js} +1 -1
  53. package/dist/public/assets/{agent-visibility-B4n6jrOx.js → agent-visibility-DujHi06m.js} +1 -1
  54. package/dist/public/assets/auth-state-cache-C8cTMd6P.js +11 -0
  55. package/dist/public/assets/client-version-Z-1kpNfZ.js +1 -0
  56. package/dist/public/assets/{config-provider-GshVNiWq.js → config-provider-BI6LhEXG.js} +2 -2
  57. package/dist/public/assets/{dist-Cgpf3BIr.js → dist-BlIr-8t0.js} +172 -172
  58. package/dist/public/assets/{doc-hash-Bso39bSh.js → doc-hash-D0_HbJ23.js} +1 -1
  59. package/dist/public/assets/{documents-events-CtKncdGv.js → documents-events-CJea1fR_.js} +1 -1
  60. package/dist/public/assets/{file-tree-adapter-SJF4yRd-.js → file-tree-adapter-DzAMgO1O.js} +1 -1
  61. package/dist/public/assets/{file-tree-utils-llNa05uo.js → file-tree-utils-3pfPI1X_.js} +1 -1
  62. package/dist/public/assets/{globals-88oPHAs4.css → globals-B1VH9dVh.css} +1 -1
  63. package/dist/public/assets/{globals-BzYms-F0.js → globals-CdwCpkXl.js} +1 -1
  64. package/dist/public/assets/index-C0AkDryr.js +2013 -0
  65. package/dist/public/assets/{lint-config-client-BYECwWuu.js → lint-config-client-DbBWIg_9.js} +1 -1
  66. package/dist/public/assets/{markdownlint-rule-browser-BR80y6ho.js → markdownlint-rule-browser-CUFRDZ2I.js} +1 -1
  67. package/dist/public/assets/{navigation-targets-SdStq-nY.js → navigation-targets-dewfI5_V.js} +1 -1
  68. package/dist/public/assets/{open-managed-artifact-tab-CgQ5akUh.js → open-managed-artifact-tab-kMJwQpt4.js} +1 -1
  69. package/dist/public/assets/pending-receive-nav-store-CDDIEMIE.js +1 -0
  70. package/dist/public/assets/{prop-types-CU-rIGvv.js → prop-types-BmO8uGg2.js} +1 -1
  71. package/dist/public/assets/{receive-store-C5uRDARd.js → receive-store-4fDKib_S.js} +1 -1
  72. package/dist/public/assets/{schema-fields-view-intent-BeD8vY0v.js → schema-fields-view-intent-D_s-Cynn.js} +1 -1
  73. package/dist/public/assets/{selection-context-DtzxXWAX.js → selection-context-C0NUwqpZ.js} +1 -1
  74. package/dist/public/assets/{skill-actions-PBEWDc_3.js → skill-actions-BLuXIHSm.js} +1 -1
  75. package/dist/public/assets/{skills-api-Cd3IvPjQ.js → skills-api-SMCgwzEY.js} +1 -1
  76. package/dist/public/assets/{src-Dum6a22K.js → src-itVDbQfo.js} +1 -1
  77. package/dist/public/assets/{tag-pill-input-CS-2Qx-_.js → tag-pill-input-DR244KKn.js} +1 -1
  78. package/dist/public/assets/{target-navigation-intent-D3w-HLu3.js → target-navigation-intent-Cbl2tfqs.js} +1 -1
  79. package/dist/public/assets/{telemetry-impl-Z8PmW_aL.js → telemetry-impl-llHFvtad.js} +1 -1
  80. package/dist/public/assets/{telemetry-startup-Cy7C8oSF.js → telemetry-startup-Ce8-_9qU.js} +1 -1
  81. package/dist/public/assets/{terminal-launch-events-CTVJjVZG.js → terminal-launch-events-BRcRf0Xe.js} +1 -1
  82. package/dist/public/assets/{terminal-telemetry-pdIn1zDv.js → terminal-telemetry-B2HfhwZL.js} +1 -1
  83. package/dist/public/assets/typing-burst-detector-D-YHMlG7.js +8 -0
  84. package/dist/public/assets/{uninstall-BpVYvA3J.js → uninstall-CBrvDiNY.js} +1 -1
  85. package/dist/public/assets/{use-activity-panel-B8RDBgok.js → use-activity-panel-DmOMj8An.js} +1 -1
  86. package/dist/public/assets/{use-apply-config-color-theme-A0jx7vnI.js → use-apply-config-color-theme-CVaACVk5.js} +2 -2
  87. package/dist/public/assets/{use-collab-url-bpUtly6S.js → use-collab-url-CNP-irXj.js} +1 -1
  88. package/dist/public/assets/{use-live-xterm-theme-w8QeNUlq.js → use-live-xterm-theme-Dcnl-fJO.js} +1 -1
  89. package/dist/public/assets/use-settings-route-u-AZNZ9O.js +1 -0
  90. package/dist/public/assets/{use-terminal-enabled-CuFAAh8J.js → use-terminal-enabled-CkLthL6Z.js} +1 -1
  91. package/dist/public/assets/use-timeline-entry-diff-YCuC-AiR.js +6 -0
  92. package/dist/public/assets/{use-workspace-CNWEPWim.js → use-workspace-Cn4V4yWb.js} +1 -1
  93. package/dist/public/assets/{workspace-paths-DQOJHVhV.js → workspace-paths-Cs9eIuPX.js} +1 -1
  94. package/dist/public/index.html +37 -37
  95. package/dist/public/uninstall.html +4 -4
  96. package/dist/{repair-launch-json-_2TGq22B.mjs → repair-launch-json-B7EsRree.mjs} +2 -2
  97. package/dist/{repair-mcp-configs-Cf6t84yK.mjs → repair-mcp-configs-CAdsYeAL.mjs} +2 -2
  98. package/dist/repair-skills-ClK8g58l.mjs +1 -0
  99. package/dist/{repair-skills-DwQqF8O8.mjs → repair-skills-DVSrDMGl.mjs} +2 -2
  100. package/dist/schemas/v0/config.project.schema.json +26 -0
  101. package/dist/server-lock-W-oGU6ba.mjs +1 -0
  102. package/dist/{server-lock-DpWXnrNF.mjs → server-lock-WyY-R-p6.mjs} +2 -2
  103. package/dist/{sleep-DTzPXGtM.mjs → sleep-DDnWCWup.mjs} +2 -2
  104. package/dist/src-BBhkxvx7.mjs +3275 -0
  105. package/dist/src-BMO6onuh.mjs +1 -0
  106. package/dist/{src-JZ7OJ1TB.mjs → src-BzvNUgtF.mjs} +7 -7
  107. package/dist/{src-DY417osM.mjs → src-DjCV5AKN.mjs} +124 -124
  108. package/dist/start-BYvqfT9V.mjs +4 -0
  109. package/dist/start-ConG7Bk_.mjs +1 -0
  110. package/dist/{write-project-skill-cxdqSDsT.mjs → write-project-skill-CS4rRA1W.mjs} +4 -4
  111. package/package.json +5 -5
  112. package/dist/constants-BKJ7B5iw.mjs +0 -2
  113. package/dist/fs-traced-B9Czc2nP.mjs +0 -1
  114. package/dist/git-handle-B1uGukUi.mjs +0 -1
  115. package/dist/init-CIt3KTw5.mjs +0 -1
  116. package/dist/loader-Bofa7u1n.mjs +0 -1
  117. package/dist/md-manager-DPw-b4lt.mjs +0 -2
  118. package/dist/preview-CUhu4iSu.mjs +0 -1
  119. package/dist/public/assets/DocumentContext-WcIs30H8.js +0 -38
  120. package/dist/public/assets/FeedbackForm-DXei5e26.js +0 -1
  121. package/dist/public/assets/LintConfigEditor-DEUL9rFl.js +0 -1
  122. package/dist/public/assets/PropertyPanel-F1tECi8I.js +0 -2
  123. package/dist/public/assets/ReportBugDialogBody-Cz_kN3Qc.js +0 -3
  124. package/dist/public/assets/SchemaConfigEditor-C_t3p7aQ.js +0 -1
  125. package/dist/public/assets/SourceEditor-DGpQCfDe.js +0 -1
  126. package/dist/public/assets/auth-state-cache-PC5ml3gS.js +0 -11
  127. package/dist/public/assets/client-version-BmlQC9U8.js +0 -1
  128. package/dist/public/assets/index-BVWeqqNi.js +0 -2014
  129. package/dist/public/assets/pending-receive-nav-store-DTqMgVXW.js +0 -1
  130. package/dist/public/assets/typing-burst-detector-BEbZgL9-.js +0 -6
  131. package/dist/public/assets/use-settings-route-CFvCFlXS.js +0 -1
  132. package/dist/public/assets/use-timeline-entry-diff-DlW9hmrR.js +0 -6
  133. package/dist/repair-skills-CtpTVpw_.mjs +0 -1
  134. package/dist/server-lock-CZMSbPZ0.mjs +0 -1
  135. package/dist/src-BFcAqZ_V.mjs +0 -1
  136. package/dist/src-BkP5u3RK.mjs +0 -3269
  137. package/dist/start-0twfe-vW.mjs +0 -1
  138. package/dist/start-BcTJLNem.mjs +0 -3
@@ -0,0 +1 @@
1
+ import{C as e,Fa as t,Ia as n,Pa as r,Qa as i,So as a,Xa as o,co as s,d as c,l,y as u}from"./src-DjCV5AKN.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,At as y,B as b,Bi as x,Bn as S,Br as C,Bt as w,C as T,Ci as E,Cn as D,Cr as O,Ct as k,D as A,Di as j,Dn as M,Dt as N,E as P,Ei as F,En as I,Er as L,Et as R,F as z,Fi as B,Fn as V,Fr as H,Ft as U,G as W,Gi as G,Gn as K,Gr as q,Gt as J,H as Y,Hi as X,Hn as Z,Hr as Q,Ht as $,I as ee,Ii as te,In as ne,Ir as re,It as ie,J as ae,Ji as oe,Jn as se,Jr as ce,Jt as le,K as ue,Ki as de,Kn as fe,Kr 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,Ot as Ne,P as Pe,Pi as Fe,Pn as Ie,Pr as Le,Pt as Re,Q as ze,Qi as Be,Qn as Ve,Qr as He,Qt as Ue,R as We,Ri as Ge,Rn as Ke,Rr as qe,Rt as Je,S as Ye,Si as Xe,Sn as Ze,Sr as Qe,St as $e,T as et,Ti as tt,Tn as nt,Tr as rt,Tt as it,U as at,Ui as ot,Un as st,Ur as ct,Ut as lt,V as ut,Vi as dt,Vn as ft,Vr as pt,Vt as mt,W as ht,Wi as gt,Wn as _t,Wr as vt,Wt as yt,X as bt,Xi as xt,Xn as St,Xr as Ct,Xt as wt,Y as Tt,Yi as Et,Yn as Dt,Yr as Ot,Yt as kt,Z as At,Zi as jt,Zn as Mt,Zr as Nt,Zt as Pt,_ as Ft,_a as It,_i as Lt,_n as Rt,_r as zt,_t as Bt,a as Vt,aa as Ht,ai as Ut,an as Wt,ar as Gt,at as Kt,b as qt,bi as Jt,bn as Yt,br as Xt,bt as Zt,c as Qt,ca as $t,ci as en,cn as tn,cr as nn,ct as rn,d as an,da as on,di as sn,dn as cn,dr as ln,ea as un,ei as dn,en as fn,er as pn,et as mn,f as hn,fa as gn,fi as _n,fn as vn,fr as yn,g as bn,ga as xn,gi as Sn,gn as Cn,gr as wn,gt as Tn,h as En,ha as Dn,hi as On,hn as kn,hr as An,i as jn,ia as Mn,ii as Nn,in as Pn,ir as Fn,it as In,j as Ln,ji as Rn,jn as zn,jt as Bn,k as Vn,ki as Hn,kn as Un,kt as Wn,l as Gn,la as Kn,li as qn,ln as Jn,lr as Yn,lt as Xn,m as Zn,ma as Qn,mi as $n,mn as er,mr as tr,n as nr,na as rr,ni as ir,nn as ar,nr as or,nt as sr,o as cr,oa as lr,oi as ur,on as dr,or as fr,ot as pr,p as mr,pa as hr,pi as gr,pn as _r,pr as vr,q as yr,qi as br,qn as xr,qr as Sr,qt as Cr,r as wr,ra as Tr,ri as Er,rn as Dr,rr as Or,rt as kr,s as Ar,sa as jr,si as Mr,sn as Nr,sr as Pr,st as Fr,t as Ir,ta as Lr,ti as Rr,tn as zr,tr as Br,tt as Vr,u as Hr,ua as Ur,ui as Wr,un as Gr,ur as Kr,v as qr,va as Jr,vi as Yr,vn as Xr,vr as Zr,vt as Qr,w as $r,wi as ei,wn as ti,wr as ni,wt as ri,x as ii,xi as ai,xn as oi,xr as si,xt as ci,y as li,ya as ui,yi as di,yn as fi,yr as pi,yt as mi,z as hi,zi as gi,zn as _i,zr as vi,zt as yi}from"./src-BBhkxvx7.mjs";import{C as bi,E as xi,T as Si,_ as Ci,b as wi,c as Ti,d as Ei,g as Di,i as Oi,l as ki,m as Ai,n as ji,p as Mi,s as Ni,t as Pi,u as Fi,v as Ii,w as Li,x as Ri,y as zi}from"./fs-traced-DDm-belY.mjs";import{a as Bi,d as Vi,f as Hi,i as Ui,l as Wi,n as Gi,r as Ki,t as qi,u as Ji}from"./logger-B7Z8XO-z.mjs";import{S as Yi,_ as Xi,a as Zi,c as Qi,f as $i,g as ea,h as ta,i as na,l as ra,m as ia,n as aa,o as oa,p as sa,r as ca,s as la,t as ua,u as da,v as fa,x as pa}from"./server-lock-WyY-R-p6.mjs";export{Ur as AGENT_ID_MAX_LEN,on as AGENT_ID_RE,F as AGENT_WRITE_ORIGIN,It as AcpPermissionStore,Qn as AcpRegistry,E as AcpThreadManager,ai as AgentFocusBroadcaster,Jt as AgentPresenceBroadcaster,j as AgentSessionCapacityError,je as AgentSessionManager,Bt as AutoStartDisabledError,yn as BUNDLE_IDS,vr as BUNDLE_SCOPE,tr as BUNDLE_SKILL_NAME,zn as BacklinkIndex,Ge as CC1Broadcaster,i as CC1_CONTRACT_VERSION,ar as CONFIG_FILENAME,I as CONFLICT_MARKER_RE,re as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Ft as ConfigSchema,gt as DEFAULT_CHECKPOINT_RETENTION,He as DEFAULT_EMBEDDINGS_DIMENSIONS,U as DEFAULT_PACK_ID,Y as DocumentDurabilityState,m as EMBEDDINGS_API_KEY_ENV,Dn as FEATURED_AGENT_IDS,G as FILE_SYSTEM_WRITER,v as FILE_WATCHER_ORIGIN,pe as FileEmbeddingsBackend,Pt as GIT_PREFLIGHT_FAIL_SPAN_NAME,de as GIT_UPSTREAM_WRITER,Jr as GitDirAccessError,Ke as GitNotAvailableError,_i as GitTooOldError,Qr as HOCUSPOCUS_AUTH_REJECTION_REASONS,mi as HocuspocusAuthRejection,Zt as HocuspocusAuthTokenSchema,Q as INSTALLED_AGENTS_SCHEMES,o as LINEAGE_EPOCH_KEY,hi as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ie as LOG_MD_TEMPLATE,R as MANAGED_RENAME_ORIGIN,ei as MAX_ACP_THREADS,Hn as MAX_AGENT_SESSIONS,rn as MCP_CONNECTION_ID_HEADER,r as MCP_SERVER_NAME,_ as MIN_EVICTABLE_IDLE_MS,S as MIN_GIT_VERSION,at as MISSING_OK_CONFIG_MESSAGE,ui as MalformedGitPointerError,mn as McpLogger,ht as MissingOkConfigError,xe as OBSERVER_SYNC_ORIGIN,Dr as OK_OKIGNORE_TEMPLATE,t as ORPHAN_MODES,a as PROTOCOL_VERSION,qi as PinoLogger,Qi as ProcessLockCollisionError,Gn as ProjectGitInitError,N as ROLLBACK_ORIGIN,Pn as ROOT_GITIGNORE_TEMPLATE,ea as RUNTIME_VERSION,$n as RemoteConfigError,br as SERVICE_WRITER,Pr as SKILL_INSTALL_EVENTS_FILE_REL,u as SKILL_STATE_TARGETS,ye as STARTER_FOLDERS,Je as STARTER_FOLDER_FRONTMATTER_FILENAME,yi as STARTER_PACKS,w as STARTER_PACK_IDS,mt as STARTER_TEMPLATES,P as STATE_MANIFEST_FILENAME,Xi as STATE_SCHEMA_VERSION,s as SYSTEM_DOC_NAME,Cr as SeedPrerequisiteError,le as SeedRootDirError,ua as ServerLockCollisionError,Ir as SingleFileNotAFileError,nr as SingleFileNotFoundError,wr as SingleFileNotMarkdownError,A as StateManifestError,et as TagIndex,An as USER_GLOBAL_BUNDLE_IDS,De as UiLockCollisionError,Ne as __getShowAllWalkStatsForTesting,Wn as __resetShowAllWalkStatsForTesting,ra as acquireProcessLock,aa as acquireServerLock,Ie as acquireUiLock,Rn as applyAgentMarkdownWrite,ti as applyExternalChange,Re as applySeed,Ae as assertCompatibleStateManifest,ft as assertGitAvailable,vn as assertNeverDiskEvent,Xe as attachAcpThreadSocket,Tn as attachIdleShutdown,qr as bootServer,St as buildAndOpenSkill,Wt as buildConfigYmlContent,Tt as buildExecResult,tt as buildOkMcpStdioCommand,Yn as buildSkillZip,$ as buildStarterFolderFrontmatterYaml,oe as buildWipTree,wn as bundleSkillMdPath,Sr as canonicalProjectKey,_r as classifyEvents,Pi as classifyFsPath,ce as clearAllEmbeddingsKeys,Rr as clearContributors,lt as coercePackId,l as colorFromSeed,Et as commitUpstreamImport,xt as commitWip,jt as commitWipFromTree,Z as compareSemver,pi as composeEffectiveLinterConfig,Xt as composeFrontmatterSchemasConfig,M as containsConflictMarkers,er as contentHash,ir as contributorCount,z as countShadowObjects,ee as countStaleAgentWipRefs,he as countWipRefs,y as createApiExtension,sn as createAssetServeMiddleware,Ce as createContentFilter,Oe as createContentFilterAsync,Ot as createEmbeddingsSecretStore,jn as createEphemeralProjectDir,nt as createExternalChangeHandler,hn as createFileLogger,b as createLiveDerivedIndexExtension,yr as createMcpHttpHandler,ct as createOsProbe,Pe as createPersistenceExtension,T as createServer,be as createServerObserverExtension,B as createStreamingErrorWriter,Gi as createTestLogger,Ct as describeStoredEmbeddingsKey,bn as detectClaudeDesktopPresence,st as detectGit,Vn as detectProjectShape,Mt as detectUserSkillHosts,kr as discoverLockDirs,O as discoverMarkdownlintConfig,Ue as emitPreflightFailureSpan,bt as encodeDocName,At as encodeFolderRoute,ze as encodeSkillRoute,Hr as ensureProjectGit,dr as ensureProjectSkillGitignore,te as errorResponse,kn as evictStaleTrackerEntries,In as extractOkBinaryPath,Se as extractWikiLinksFromMarkdown,_t as fallbackPaths,an as findEnclosingGitRoot,Gr as findEnclosingProjectRoot,ni as findNativeMarkdownlintFile,mr as flushFileLogger,ci as formatAuthRejectionWire,Er as formatContributors,Nn as formatContributorsFrom,we as formatPackRationale,Be as gcCheckpointRefs,Vr as getCurrentMcpLogger,en as getLocalDir,Zn as getLogFilePath,Ki as getLogger,En as getLogsDir,fa as getMachineId,zi as getMeter,Ht as getMetrics,wi as getTracer,lr as handleCollabSocketError,ve as handleSpawnCursor,On as hasForwardingHeaders,We as hasGcLogLatch,c as iconFromClientName,jr as incrementCollabSocketFilteredError,$t as incrementServerObserverFire,Nr as initContent,f as initShadowRepo,Ri as initTelemetry,qt as initToleranceTelemetryWriter,Fr as installPrettyZodErrors,Ui as installTestLoggers,Ve as installUserSkill,gr as isAllowedApiOrigin,Yr as isAllowedWorkspaceHostHeader,gi as isConfigDoc,$e as isHocuspocusAuthRejectionReason,yt as isKnownPackId,x as isLinkIndexExcludedDoc,di as isLoopbackAddress,dt as isManagedArtifactDoc,n as isOrphanMode,Ee as isPairedWriteOrigin,qe as isPathWithinDir,pa as isProcessAlive,cn as isProjectRoot,fe as isProjectSkillManaged,Sn as isRemoteAdmitted,X as isReservedForUserTree,Cn as isSelfWrite,ot as isSystemDoc,ii as isToleranceTelemetryEnabled,Yi as isValidLockPid,Rt as lastKnownHash,un as listRescueCheckpoints,J as listStarterPacks,xn as loadCustomAgents,Te as loadPrincipal,da as lockFilePath,Bi as loggerFactory,Wi as logsCurrentPath,Ji as logsPreviousPath,Nt as makeLazyEmbeddingsKeyStore,ca as markServerLockDraining,W as mountMcpAndApi,ji as normalizeFsPath,zt as originGitHubHost,tn as packageVersionMajorMinor,k as parseAuthRejectionWire,K as parseGitVersion,ri as parseHocuspocusAuthToken,ue as parseKeepaliveConnectionId,Xr as pathToDocName,ke as planSeed,Vt as prepareSingleFileOpen,Kt as processCommand,pr as processUsage,p as readAllTargets,pn as readBundleDecision,rt as readOwnNativeRules,$i as readProcessLock,sa as readProcessLockDetailed,ut as readProjectHeadState,q as readProjectLocalSemanticConfig,na as readServerLock,Br as readServerPackageVersion,or as readSkillInstallStateSnapshot,xr as readSkillManagement,g as readStateManifest,Or as readTargetRecordedAt,Fn as readTargetVersion,V as readUiLock,Me as reconcile,Ut as recordContributor,nn as recordSkillInstallEvent,ae as registerAllTools,fi as registerWrite,ia as releaseProcessLock,Zi as releaseServerLock,ne as releaseUiLock,Yt as removeLastKnownHash,Kn as resetMetrics,e as resolveBundleEnabled,Kr as resolveBundledSkillDir,qn as resolveContentDir,vi as resolveCursorBinaryDefault,C as resolveCursorSpawnInvocation,si as resolveEffectiveLinterConfig,dn as resolveEmbeddingsCredential,Wr as resolveLockDir,Qe as resolveNativeConfigForDoc,L as resolveNativeMarkdownlintConfig,me as resolvePack,Ar as resolvePackageVersion,Lt as resolveRemoteAccess,d as resolveUiInfo,ur as restoreContributors,li as restoreLifecycleFromConflictsJson,Le as rewriteMarkdownLinksForDocumentRename,H as rewriteWikiLinksForDocumentRename,h as runAuthReposSubprocess,fn as runAuthStatusSubprocess,kt as runCloneSubprocess,zr as runDeviceFlowSubprocess,sr as runWithMcpLogger,_n as safeContentPath,Bn as safeSubdir,Lr as safetyCheckpoint,Xn as sanitizeClientName,rr as saveInMemoryCheckpoint,Tr as saveVersion,it as seedBasenameIndex,cr as serializeError,bi as setActiveSpanAttributes,Fe as setupServerObservers,Mn as shadowGit,Li as shutdownTelemetry,se as skillManagementPath,Vi as spansCurrentPath,Hi as spansPreviousPath,pt as spawnDetached,Un as splitMarkdownBlocks,oi as startWatcher,ge as streamingProblemEvent,Mr as swapContributors,Ye as teardownToleranceTelemetryWriter,gn as toBroadcasterKey,Oi as tracedAppendFileSync,Ni as tracedLinkSync,Ti as tracedMkdir,ki as tracedMkdirSync,Fi as tracedRename,Ei as tracedRenameSync,Mi as tracedRmSync,Ai as tracedRmdirSync,Di as tracedUnlinkSync,Ci as tracedWriteFile,Ii as tracedWriteFileSync,$r as trustSystemCertificates,Qt as untrackTrackedProjectSkillProjection,Ze as updateLastKnownHash,ta as updateProcessLockPort,oa as updateServerLockPort,_e as updateUiLockPort,hr as validateAgentId,wt as validateCloneInputs,ln as validateSkillZip,la as waitForServerLockDrain,vt as withHiddenWindowsConsole,Si as withSpan,xi as withSpanSync,Gt as writeBundleDecision,Zr as writeMarkdownlintRule,Jn as writeRootGitignoreForNewRepo,Dt as writeSkillManagement,Ln as writeStateManifest,fr as writeTargetVersion,D as writeTracker};
@@ -1,13 +1,13 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,La as r,_o as i,go as a}from"./src-DY417osM.mjs";import{Kr as o,at as s,fi as c,fn as l,it as u,ot as d,rt as f,va as p}from"./src-BkP5u3RK.mjs";import{K as m}from"./sleep-DTzPXGtM.mjs";import{O as h,P as g}from"./fs-traced-BmZQL7v9.mjs";import{S as _,u as v,v as y,x as b}from"./server-lock-DpWXnrNF.mjs";import{t as x}from"./yazl-BafwB467.mjs";import{C as S,d as C,i as w,v as T,y as ee}from"./write-project-skill-cxdqSDsT.mjs";import{c as te}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-BI6bXf3a.mjs";import{D as E,E as D,S as ne,T as O,_ as k,b as re,o as ie,v as A}from"./init-BUp3cQ_4.mjs";import{n as ae}from"./constants-BKJ7B5iw.mjs";import{t as j}from"./is-object-ByG7RnjH.mjs";import"./loader-y7Mn8M-Z.mjs";import"./preview-BV8bR51k.mjs";import{execSync as oe,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,isAbsolute as se,join as F,relative as ce,resolve as I,sep as le}from"node:path";import{cpSync as ue,createWriteStream as de,existsSync as L,lstatSync as fe,mkdirSync as R,mkdtempSync as pe,readFileSync as z,readdirSync as me,readlinkSync as he,rmSync as ge,statSync as _e,writeFileSync as B}from"node:fs";import{arch as ve,freemem as ye,homedir as be,hostname as xe,platform as Se,release as Ce,tmpdir as we,totalmem as Te,type as Ee,uptime as De}from"node:os";import{realpath as V}from"node:fs/promises";import{createHash as Oe}from"node:crypto";var H=m();const ke=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Ae(e,t,n=l){if(e!==void 0&&!ke.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let je=null;function Me(e){je=e}function Ne(){return je??process.cwd()}function Pe(){return F(be(),`.ok`,`bug-reports`)}function Fe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Pe(),r=`${t}-bugreport`,i=F(n,`${r}.zip`);for(let e=2;L(i);e+=1)i=F(n,`${r}-${e}.zip`);return i}function Ie(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`))?Oe(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Le(){let e={timestamp:new Date().toISOString(),platform:Se(),osType:Ee(),osRelease:Ce(),hostname:`[redacted]`,uptime:De(),freeMem:ye(),totalMem:Te(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=oe(`sw_vers -productVersion 2>/dev/null`,o({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 Re(e,t){return ze(e,t).files}function ze(e,t){if(!L(t))return{files:[]};let n=me(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 Be(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 Ve(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 He(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=i(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 U(e){for(let t of e.files)try{He({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 Ue(t){let{redact:n,outputPath:r,logger:i}=t,o=t.userLogsDir??F(be(),`.ok`,`logs`),s=t.projectDir?Ie(t.projectDir,i):null;R(P(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=Le();c.desktop=t.desktop??null;let{files:l}=ze(s,o),{files:u}=t.projectDir?Be(t.projectDir):{files:[]},{files:d}=t.projectDir?Ve(t.projectDir):{files:[]};i?.info({logFileCount:l.length,lockFileCount:u.length,localSinkFileCount:d.length},`files collected`);let f=[],p=[],{ZipFile:m}=await import(`./yazl-vwTkB7U0.mjs`).then(t=>e(t.default,1)),h=new m;U({zipfile:h,files:l,prefix:`logs`,redact:n,bundleFiles:p,redactions:f,logger:i}),U({zipfile:h,files:u,prefix:`lockdir`,redact:n,bundleFiles:p,redactions:f,logger:i}),U({zipfile:h,files:d,prefix:`local-logs`,redact:n,bundleFiles:p,redactions:f,logger:i});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;h.addBuffer(t,n),p.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&He({zipfile:h,name:`note.txt`,content:t.note,redact:n,bundleFiles:p,redactions:f});let g=JSON.stringify(c,null,2);h.addBuffer(Buffer.from(g,`utf8`),`sysinfo.json`),p.push(`sysinfo.json`);let _={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:p,redactions:f,sysinfo:c};h.addBuffer(Buffer.from(JSON.stringify(_,null,2),`utf8`),`MANIFEST.json`);let v=f.reduce((e,t)=>e+t.lineCount,0),y=[`# Bug Report Bundle`,``,`Generated: ${_.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${_.disciplineVersion}`,``,`## Contents`,``,...p.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${a.join(`, `)}`,v>0?`${v} line(s) were scrubbed across ${f.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
- `);h.addBuffer(Buffer.from(y,`utf8`),`README.md`),h.end();let b=de(r);return h.outputStream.pipe(b),await new Promise((e,t)=>{b.on(`close`,e),b.on(`error`,t)}),i?.info({bundlePath:r,fileCount:p.length,redactionCount:v},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:p,redactions:f,redactedLineCount:v,generatedAt:_.generatedAt}}}var We=e(x(),1),W=e(te(),1);function G(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ge(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){if(typeof e==`string`)return G(e,t.contentDir);if(Array.isArray(e))return e.map(e=>K(e,t));if(!Ge(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=K(i,t);return n}function Ke(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
1
+ import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,vo as r,yo as i,za as a}from"./src-DjCV5AKN.mjs";import{Sa as o,Wr as s,at as c,it as l,ot as u,rt as d,ui as f,un as p}from"./src-BBhkxvx7.mjs";import{K as m}from"./sleep-DDnWCWup.mjs";import{O as h,P as g}from"./fs-traced-DDm-belY.mjs";import{S as _,u as v,v as y,x as b}from"./server-lock-WyY-R-p6.mjs";import{t as x}from"./yazl-BafwB467.mjs";import{C as S,d as C,i as w,v as T,y as ee}from"./write-project-skill-CS4rRA1W.mjs";import{c as te}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-D9cTkuMT.mjs";import{D as E,E as D,S as ne,T as O,_ as k,b as re,o as ie,v as A}from"./init-C3jLZpVV.mjs";import{n as ae}from"./constants-BT3Cjn4w.mjs";import{t as j}from"./is-object-ByG7RnjH.mjs";import"./loader-BYtT6HwT.mjs";import"./preview-DlzwRGU_.mjs";import{execSync as oe,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,isAbsolute as se,join as F,relative as ce,resolve as I,sep as le}from"node:path";import{cpSync as ue,createWriteStream as de,existsSync as L,lstatSync as fe,mkdirSync as R,mkdtempSync as pe,readFileSync as z,readdirSync as me,readlinkSync as he,rmSync as ge,statSync as _e,writeFileSync as B}from"node:fs";import{arch as ve,freemem as ye,homedir as be,hostname as xe,platform as Se,release as Ce,tmpdir as we,totalmem as Te,type as Ee,uptime as De}from"node:os";import{realpath as V}from"node:fs/promises";import{createHash as Oe}from"node:crypto";var H=m();const ke=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Ae(e,t,n=p){if(e!==void 0&&!ke.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let je=null;function Me(e){je=e}function Ne(){return je??process.cwd()}function Pe(){return F(be(),`.ok`,`bug-reports`)}function Fe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Pe(),r=`${t}-bugreport`,i=F(n,`${r}.zip`);for(let e=2;L(i);e+=1)i=F(n,`${r}-${e}.zip`);return i}function Ie(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`))?Oe(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Le(){let e={timestamp:new Date().toISOString(),platform:Se(),osType:Ee(),osRelease:Ce(),hostname:`[redacted]`,uptime:De(),freeMem:ye(),totalMem:Te(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=oe(`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 Re(e,t){return ze(e,t).files}function ze(e,t){if(!L(t))return{files:[]};let n=me(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 Be(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 Ve(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 He(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=i(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 U(e){for(let t of e.files)try{He({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 Ue(t){let{redact:n,outputPath:i,logger:a}=t,o=t.userLogsDir??F(be(),`.ok`,`logs`),s=t.projectDir?Ie(t.projectDir,a):null;R(P(i),{recursive:!0}),a?.info({projectSlug:s},`gathering diagnostic data`);let c=Le();c.desktop=t.desktop??null;let{files:l}=ze(s,o),{files:u}=t.projectDir?Be(t.projectDir):{files:[]},{files:d}=t.projectDir?Ve(t.projectDir):{files:[]};a?.info({logFileCount:l.length,lockFileCount:u.length,localSinkFileCount:d.length},`files collected`);let f=[],p=[],{ZipFile:m}=await import(`./yazl-vwTkB7U0.mjs`).then(t=>e(t.default,1)),h=new m;U({zipfile:h,files:l,prefix:`logs`,redact:n,bundleFiles:p,redactions:f,logger:a}),U({zipfile:h,files:u,prefix:`lockdir`,redact:n,bundleFiles:p,redactions:f,logger:a}),U({zipfile:h,files:d,prefix:`local-logs`,redact:n,bundleFiles:p,redactions:f,logger:a});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;h.addBuffer(t,n),p.push(n)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&He({zipfile:h,name:`note.txt`,content:t.note,redact:n,bundleFiles:p,redactions:f});let g=JSON.stringify(c,null,2);h.addBuffer(Buffer.from(g,`utf8`),`sysinfo.json`),p.push(`sysinfo.json`);let _={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:p,redactions:f,sysinfo:c};h.addBuffer(Buffer.from(JSON.stringify(_,null,2),`utf8`),`MANIFEST.json`);let v=f.reduce((e,t)=>e+t.lineCount,0),y=[`# Bug Report Bundle`,``,`Generated: ${_.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${_.disciplineVersion}`,``,`## Contents`,``,...p.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${r.join(`, `)}`,v>0?`${v} line(s) were scrubbed across ${f.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
+ `);h.addBuffer(Buffer.from(y,`utf8`),`README.md`),h.end();let b=de(i);return h.outputStream.pipe(b),await new Promise((e,t)=>{b.on(`close`,e),b.on(`error`,t)}),a?.info({bundlePath:i,fileCount:p.length,redactionCount:v},`bundle written`),{zipPath:i,summary:{projectSlug:s,files:p,redactions:f,redactedLineCount:v,generatedAt:_.generatedAt}}}var We=e(x(),1),W=e(te(),1);function G(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ge(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){if(typeof e==`string`)return G(e,t.contentDir);if(Array.isArray(e))return e.map(e=>K(e,t));if(!Ge(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=K(i,t);return n}function Ke(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
3
3
  `),i=n.split(`
4
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=K(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}B(e,r?`${a.join(`
5
5
  `)}\n`:a.join(`
6
6
  `))}function qe(e,t){let n=z(e,`utf-8`);if(n.trim().length!==0)try{let r=K(JSON.parse(n),t),i=n.endsWith(`
7
7
  `)?`
8
8
  `:``;B(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=G(n,t.contentDir);r!==n&&B(e,r)}}function Je(e,t){let n=z(e,`utf-8`),r=G(n,t.contentDir);r!==n&&B(e,r)}function Ye(e){try{return me(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>F(e,t.name))}catch{return[]}}const Xe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Ze(e){return/\.log\.\d+$/.test(e)}function Qe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Ze(e)}function $e(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of Ye(F(e.stagingDir,n)))Qe(r)?Ke(r,t):r.endsWith(`.json`)?qe(r,t):Je(r,t);for(let n of Ye(F(e.stagingDir,`state`))){let e=N(n);n.endsWith(`.jsonl`)?Ke(n,t):Xe.has(e)?qe(n,t):Je(n,t)}}const et=[`.ok`,`local`,`telemetry`],tt=[`.ok`,`local`,`logs`],nt=[`.ok`,`local`,`loss-capture`],rt=`spans-current.jsonl`,it=`spans-prev.jsonl`,at=`server-current.jsonl`,ot=`server-prev.jsonl`,st=`loss-current.jsonl`,ct=`loss-prev.jsonl`;function lt(e){return F(e,...et,rt)}function ut(e){return F(e,...et,it)}function dt(e){return F(e,...tt,at)}function ft(e){return F(e,...tt,ot)}function pt(e){return F(e,...nt,st)}function mt(e){return F(e,...nt,ct)}const q=1e3;async function ht(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(q)});return t.ok?await t.text():null}catch{return null}}async function gt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(q)});return t.ok?await t.text():null}catch{return null}}async function _t(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(q)});return t.ok?await t.text():null}catch{return null}}function vt(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 yt(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`log`,`--oneline`,`-50`],o({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function bt(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/`],o({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function xt(){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 St(){return{nodeVersion:process.version,platform:Se(),arch:ve()}}function Ct(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wt(e){if(!L(e))return{};let t;try{t=(0,H.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 Tt(e){return typeof e==`boolean`?e:void 0}function Et(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return Et(e.maxBytes)}function Dt(e){let t=wt(h(`project`,e)),n=wt(h(`project-local`,e));return{enabled:Tt(n.enabled)??Tt(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Ot(e){return Oe(`sha256`).update(e).digest(`hex`)}function kt(e){let t=z(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function At(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}),ue(e,t),!0):!1}function jt(e){let t=[],n=e=>{let r=me(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 Mt=new Set([`.jsonl`]);function Nt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Mt.has(e.slice(t))}const Pt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Ft(e){if(Ze(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Pt.has(e.slice(t))}function It(e){let t=[];for(let n of jt(e)){let r=Lt(e,n);if(!Ft(r))continue;let{redacted:a,patterns:o,lineCount:s}=i(z(n,`utf-8`));o.length!==0&&(B(n,a),t.push({file:r,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Lt(e,t){return ce(e,t).split(le).join(`/`)}async function Rt(e){let r=I(e.contentDir),i=I(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??ht,s=a.fetchAgentEffects??gt,c=a.fetchWatcherRecent??_t,l=a.readShadowHead??yt,u=a.readCheckpointRefs??bt,d=a.now??(()=>new Date),f=a.okVersion??(()=>ae),p=a.readDesktopEnv??xt,m=a.readRuntime??St,h=a.isOtlpPushEnabled??Ct,g=pe(F(we(),`ok-bundle-`));try{R(F(g,`telemetry`),{recursive:!0}),R(F(g,`logs`),{recursive:!0}),R(F(g,`state`),{recursive:!0}),X(lt(i),F(g,`telemetry`,rt)),X(ut(i),F(g,`telemetry`,it)),X(dt(i),F(g,`logs`,at)),X(ft(i),F(g,`logs`,ot));for(let t of e.userLogFiles??[])X(t,F(g,`logs`,N(t)));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`:(B(F(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await s(x);t!==null&&B(F(g,`state`,`agent-effects.json`),t);let n=await c(x);if(n!==null){let e=vt(n);e!==null&&B(F(g,`state`,`watcher-recent.jsonl`),e)}}let S=l(r);S!==null&&B(F(g,`state`,`shadow-head.txt`),S);let C=u(r);C!==null&&B(F(g,`state`,`checkpoint-refs.txt`),C),X(pt(i),F(g,`state`,st)),X(mt(i),F(g,`state`,ct)),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}};B(F(g,`state`,`runtime.json`),`${JSON.stringify(ee,null,2)}\n`);let te=y===`running`?`running
10
- `:`not-running (${b})\n`;if(B(F(g,`state`,`server-status.txt`),te),e.processDir&&L(e.processDir)){let t=F(g,`process`);R(t,{recursive:!0}),ue(e.processDir,t,{recursive:!0})}let E=e.redact===!0;E&&$e({stagingDir:g,contentDir:r}),e.note&&B(F(g,`note.txt`),e.note);let D=null;e.scrubSecrets===!0&&(D=It(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 ne=Dt(i),O=jt(g),k=[],re=0,ie=0;for(let e of O){let t=Lt(g,e),n=_e(e).size,r=Nt(t)?kt(e):0;k.push({path:t,bytes:n,lines:r}),re+=n,t.startsWith(`telemetry/`)&&Nt(t)&&(ie+=At(e))}let A={applied:E};D!==null&&(A.secretScrub=D);let ae={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T},contentDir:{pathSha256:Ot(r),absolutePath:E?`<CONTENT_DIR>`:r},telemetry:{localSink:ne,otlpPushEnabled:h()},redaction:A,serverStatus:y,files:k};B(F(g,`manifest.json`),`${JSON.stringify(ae,null,2)}\n`);let j=O.some(e=>{try{return z(e,`utf-8`).includes(r)}catch{return!1}}),oe={totalBytes:re,fileCount:k.length,docNameCount:ie,contentDirVisible:j,redacted:E},M=!1;return{stagingDir:g,manifest:ae,summary:oe,cleanup:()=>{M||(M=!0,ge(g,{recursive:!0,force:!0}))}}}catch(e){throw ge(g,{recursive:!0,force:!0}),e}}async function zt(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.`);let i=new We.ZipFile,a=jt(t.stagingDir);for(let e of a){let n=Lt(t.stagingDir,e);i.addFile(e,n)}i.end();let o=de(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 Bt(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let t=(0,H.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 Vt(e,t,n){let r=Ie(t,e.logger),i=await Rt({contentDir:Bt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:Re(r,e.userLogsDir??F(be(),`.ok`,`logs`)),deps:{readDesktopEnv:n,logger:e.logger}});try{R(P(e.outputPath),{recursive:!0}),await zt({collected:i,outputPath:e.outputPath});let t=i.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:r,files:i.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:i.manifest.createdAt}}}finally{i.cleanup()}}async function Ht(e){let{projectDir:t}=e,n=e.readDesktopEnv??xt;if(e.level===`full`&&t!==void 0)return Vt(e,t,n);let{zipPath:r,summary:i}=await Ue({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=v(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`||!_(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??b)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??y())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??xe();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Ut(e){return e.replace(/:\d+$/,``)}function Wt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Ut(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 Gt(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 Kt(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 qt(e){let t=Gt(e);if(t)return{kind:`doc`,...t};let n=Kt(e);return n?{kind:`folder`,...n}:null}const Jt=`# >>> open-knowledge cli >>>`,Yt=`# <<< open-knowledge cli <<<`,Xt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Zt(e){return F(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Qt={existsSync:e=>L(e),readFileSync:(e,t)=>z(e,t),lstatSync:e=>fe(e),readlinkSync:e=>he(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 T(e)||ee(e)||ne(e)}const rn=10*1024*1024;function an(e,t,n,r){let i=ie(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`?(ge(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=z(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}=E(i,k(t,n,r));return o?(g(e,a,{mode:O(e)}),{kind:`removed`}):{kind:`not-present`}}function sn(e,t,n){let r;try{r=z(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,H.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=D(a);a.trim()===``||a.endsWith(`
9
+ `)}\n`:null}catch{return null}}function yt(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 bt(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 xt(){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 St(){return{nodeVersion:process.version,platform:Se(),arch:ve()}}function Ct(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wt(e){if(!L(e))return{};let t;try{t=(0,H.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 Tt(e){return typeof e==`boolean`?e:void 0}function Et(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return Et(e.maxBytes)}function Dt(e){let t=wt(h(`project`,e)),n=wt(h(`project-local`,e));return{enabled:Tt(n.enabled)??Tt(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Ot(e){return Oe(`sha256`).update(e).digest(`hex`)}function kt(e){let t=z(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function At(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}),ue(e,t),!0):!1}function jt(e){let t=[],n=e=>{let r=me(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 Mt=new Set([`.jsonl`]);function Nt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Mt.has(e.slice(t))}const Pt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Ft(e){if(Ze(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Pt.has(e.slice(t))}function It(e){let t=[];for(let n of jt(e)){let r=Lt(e,n);if(!Ft(r))continue;let{redacted:a,patterns:o,lineCount:s}=i(z(n,`utf-8`));o.length!==0&&(B(n,a),t.push({file:r,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Lt(e,t){return ce(e,t).split(le).join(`/`)}async function Rt(e){let r=I(e.contentDir),i=I(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??ht,s=a.fetchAgentEffects??gt,c=a.fetchWatcherRecent??_t,l=a.readShadowHead??yt,u=a.readCheckpointRefs??bt,d=a.now??(()=>new Date),f=a.okVersion??(()=>ae),p=a.readDesktopEnv??xt,m=a.readRuntime??St,h=a.isOtlpPushEnabled??Ct,g=pe(F(we(),`ok-bundle-`));try{R(F(g,`telemetry`),{recursive:!0}),R(F(g,`logs`),{recursive:!0}),R(F(g,`state`),{recursive:!0}),X(lt(i),F(g,`telemetry`,rt)),X(ut(i),F(g,`telemetry`,it)),X(dt(i),F(g,`logs`,at)),X(ft(i),F(g,`logs`,ot));for(let t of e.userLogFiles??[])X(t,F(g,`logs`,N(t)));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`:(B(F(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await s(x);t!==null&&B(F(g,`state`,`agent-effects.json`),t);let n=await c(x);if(n!==null){let e=vt(n);e!==null&&B(F(g,`state`,`watcher-recent.jsonl`),e)}}let S=l(r);S!==null&&B(F(g,`state`,`shadow-head.txt`),S);let C=u(r);C!==null&&B(F(g,`state`,`checkpoint-refs.txt`),C),X(pt(i),F(g,`state`,st)),X(mt(i),F(g,`state`,ct)),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}};B(F(g,`state`,`runtime.json`),`${JSON.stringify(ee,null,2)}\n`);let te=y===`running`?`running
10
+ `:`not-running (${b})\n`;if(B(F(g,`state`,`server-status.txt`),te),e.processDir&&L(e.processDir)){let t=F(g,`process`);R(t,{recursive:!0}),ue(e.processDir,t,{recursive:!0})}let E=e.redact===!0;E&&$e({stagingDir:g,contentDir:r}),e.note&&B(F(g,`note.txt`),e.note);let D=null;e.scrubSecrets===!0&&(D=It(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 ne=Dt(i),O=jt(g),k=[],re=0,ie=0;for(let e of O){let t=Lt(g,e),n=_e(e).size,r=Nt(t)?kt(e):0;k.push({path:t,bytes:n,lines:r}),re+=n,t.startsWith(`telemetry/`)&&Nt(t)&&(ie+=At(e))}let A={applied:E};D!==null&&(A.secretScrub=D);let ae={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T},contentDir:{pathSha256:Ot(r),absolutePath:E?`<CONTENT_DIR>`:r},telemetry:{localSink:ne,otlpPushEnabled:h()},redaction:A,serverStatus:y,files:k};B(F(g,`manifest.json`),`${JSON.stringify(ae,null,2)}\n`);let j=O.some(e=>{try{return z(e,`utf-8`).includes(r)}catch{return!1}}),oe={totalBytes:re,fileCount:k.length,docNameCount:ie,contentDirVisible:j,redacted:E},M=!1;return{stagingDir:g,manifest:ae,summary:oe,cleanup:()=>{M||(M=!0,ge(g,{recursive:!0,force:!0}))}}}catch(e){throw ge(g,{recursive:!0,force:!0}),e}}async function zt(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.`);let i=new We.ZipFile,a=jt(t.stagingDir);for(let e of a){let n=Lt(t.stagingDir,e);i.addFile(e,n)}i.end();let o=de(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 Bt(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let t=(0,H.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 Vt(e,t,n){let r=Ie(t,e.logger),i=await Rt({contentDir:Bt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:Re(r,e.userLogsDir??F(be(),`.ok`,`logs`)),deps:{readDesktopEnv:n,logger:e.logger}});try{R(P(e.outputPath),{recursive:!0}),await zt({collected:i,outputPath:e.outputPath});let t=i.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:r,files:i.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:i.manifest.createdAt}}}finally{i.cleanup()}}async function Ht(e){let{projectDir:t}=e,n=e.readDesktopEnv??xt;if(e.level===`full`&&t!==void 0)return Vt(e,t,n);let{zipPath:r,summary:i}=await Ue({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=v(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`||!_(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??b)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??y())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??xe();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Ut(e){return e.replace(/:\d+$/,``)}function Wt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Ut(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Ut(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 Gt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=a(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`).filter(e=>e.length>0);if(r.length<5||r[2]!==`blob`)return null;let i,o,s,c;try{i=decodeURIComponent(r[0]),o=decodeURIComponent(r[1]),s=decodeURIComponent(r[3]),c=r.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!i||!o||!s||c.length===0||c.some(e=>e.length===0)?null:{host:n,owner:i,repo:o,branch:s,path:c.join(`/`)}}function Kt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=a(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`);if(r.length<5||r[0]!==``||r[3]!==`tree`)return null;let i=r.slice(5);i.length===1&&i[0]===``&&i.pop();let o,s,c,l;try{o=decodeURIComponent(r[1]),s=decodeURIComponent(r[2]),c=decodeURIComponent(r[4]),l=i.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 qt(e){let t=Gt(e);if(t)return{kind:`doc`,...t};let n=Kt(e);return n?{kind:`folder`,...n}:null}const Jt=`# >>> open-knowledge cli >>>`,Yt=`# <<< open-knowledge cli <<<`,Xt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Zt(e){return F(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Qt={existsSync:e=>L(e),readFileSync:(e,t)=>z(e,t),lstatSync:e=>fe(e),readlinkSync:e=>he(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 T(e)||ee(e)||ne(e)}const rn=10*1024*1024;function an(e,t,n,r){let i=ie(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`?(ge(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=z(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}=E(i,k(t,n,r));return o?(g(e,a,{mode:O(e)}),{kind:`removed`}):{kind:`not-present`}}function sn(e,t,n){let r;try{r=z(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,H.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=D(a);a.trim()===``||a.endsWith(`
11
11
  `)?c.endsWith(`
12
12
  `)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
13
13
  `).replace(/\n/g,`\r
@@ -15,6 +15,6 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,La as r,_o as i,go
15
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
16
  `)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
17
17
  `).replace(/\n/g,`\r
18
- `));let u=`${i?``:``}${l}`;return u!==r&&g(e,u,{mode:O(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:u(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 W.default.green(e);case`desktop`:return W.default.blue(e);case`foreign`:return W.default.cyan(e);case`ui-orphan`:return W.default.magenta(e);case`stale`:return W.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=W.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??f,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??s,a=e.resolveUsage??d,o=await t(),c=[];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&&c.push(o)}if(e.json){let e=c.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(vn(e.all?c:c.filter(e=>pn.has(Q(e)))))}function bn(){return new S(`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??b,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=b){let n=await f(),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 S(`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:c(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 f();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,b)&&!$(r,b)||(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(c(I(Ne(),n)))})}function En(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Dn(e,t){let n,i;try{n=await V(I(e)),i=await V(I(P(e)))}catch{return{kind:`not-git`}}if(!On(n,i))return{kind:`symlink-escape`};let a=F(n,`.git`),o;try{o=_e(a)}catch{return{kind:`not-git`}}if(o.isDirectory()){let e;try{e=await V(a)}catch{return{kind:`not-git`}}if(!On(e,n))return{kind:`symlink-escape`}}else if(!o.isFile())return{kind:`not-git`};let s=p(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=Wt(l);if(u===null)return{kind:`non-github`};let d=r(u.hostname);if(d===null)return{kind:`non-github`};let f=d===t.host.toLowerCase(),m=u.owner.toLowerCase()===t.owner.toLowerCase(),h=u.name.toLowerCase()===t.repo.toLowerCase();return!f&&m&&h?{kind:`wrong-host`,actualHost:d}:!f||!m||!h?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://${d}/${u.owner}/${u.name}.git`}}function On(e,t){if(e===t)return!0;let n=ce(t,e);return n.length>0&&!n.startsWith(`..`)&&!se(n)}const kn=[{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=w(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 An(e,t,n={},r=kn){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 jn(e,t,n={}){return{integrations:An(e,t,n)}}export{Fe as C,Ae as D,Me as E,zt as S,Ne as T,Kt as _,Tn as a,Ht as b,Jt as c,tn as d,Zt as f,qt as g,Gt as h,Sn as i,Xt as l,en as m,Dn as n,bn as o,$t as p,En as r,an as s,jn as t,Yt as u,Wt as v,Pe as w,Rt as x,Z as y};
20
- //# sourceMappingURL=src-JZ7OJ1TB.mjs.map
18
+ `));let u=`${i?``:``}${l}`;return u!==r&&g(e,u,{mode:O(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:l(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 W.default.green(e);case`desktop`:return W.default.blue(e);case`foreign`:return W.default.cyan(e);case`ui-orphan`:return W.default.magenta(e);case`stale`:return W.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=W.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??d,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??c,a=e.resolveUsage??u,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 S(`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??b,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=b){let n=await d(),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 S(`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:f(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 d();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,b)&&!$(r,b)||(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(f(I(Ne(),n)))})}function En(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Dn(e,t){let n,r;try{n=await V(I(e)),r=await V(I(P(e)))}catch{return{kind:`not-git`}}if(!On(n,r))return{kind:`symlink-escape`};let i=F(n,`.git`),s;try{s=_e(i)}catch{return{kind:`not-git`}}if(s.isDirectory()){let e;try{e=await V(i)}catch{return{kind:`not-git`}}if(!On(e,n))return{kind:`symlink-escape`}}else if(!s.isFile())return{kind:`not-git`};let c=o(n);if(c.kind!==`repository`)return{kind:`not-git`};let l=c.repository.readRemoteUrl(`origin`);if(l.kind===`unreadable`)return{kind:`not-git`};if(l.kind===`absent`)return l.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let u=l.url,d=Wt(u);if(d===null)return{kind:`non-github`};let f=a(d.hostname);if(f===null)return{kind:`non-github`};let p=f===t.host.toLowerCase(),m=d.owner.toLowerCase()===t.owner.toLowerCase(),h=d.name.toLowerCase()===t.repo.toLowerCase();return!p&&m&&h?{kind:`wrong-host`,actualHost:f}:!p||!m||!h?{kind:`wrong-repo`,actualOwner:d.owner,actualRepo:d.name}:{kind:`ok`,gitRemoteUrl:`https://${f}/${d.owner}/${d.name}.git`}}function On(e,t){if(e===t)return!0;let n=ce(t,e);return n.length>0&&!n.startsWith(`..`)&&!se(n)}const kn=[{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=w(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 An(e,t,n={},r=kn){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 jn(e,t,n={}){return{integrations:An(e,t,n)}}export{Fe as C,Ae as D,Me as E,zt as S,Ne as T,Kt as _,Tn as a,Ht as b,Jt as c,tn as d,Zt as f,qt as g,Gt as h,Sn as i,Xt as l,en as m,Dn as n,bn as o,$t as p,En as r,an as s,jn as t,Yt as u,Wt as v,Pe as w,Rt as x,Z as y};
20
+ //# sourceMappingURL=src-BzvNUgtF.mjs.map