@inkeep/open-knowledge 0.87.0-beta.0 → 0.87.0-beta.2

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 (146) hide show
  1. package/dist/cli.mjs +6 -6
  2. package/dist/constants-BHRHFiiA.mjs +1 -0
  3. package/dist/index.mjs +1 -1
  4. package/dist/init-D8PiEGEU.mjs +1 -0
  5. package/dist/{init-DRDwcEOj.mjs → init-DIAKdBV0.mjs} +2 -2
  6. package/dist/{launch-json-removal-BdlZ0vPm.mjs → launch-json-removal-DJC4Yapa.mjs} +1 -1
  7. package/dist/loader-CjDr4LBh.mjs +1 -0
  8. package/dist/{loader-C4IPKtMB.mjs → loader-CnGe_Flu.mjs} +1 -1
  9. package/dist/preview-Bb3fqNig.mjs +1 -0
  10. package/dist/{preview-CbulwVyu.mjs → preview-c3qAKdkh.mjs} +1 -1
  11. package/dist/public/assets/{AccountSection-DArMM190.js → AccountSection-Bo4dPyFQ.js} +1 -1
  12. package/dist/public/assets/{ActivityModeContent-BmmqkbZB.js → ActivityModeContent-CfexCY5K.js} +1 -1
  13. package/dist/public/assets/{AddPropertiesButton-CvR-LNTP.js → AddPropertiesButton-DhN1KHUi.js} +1 -1
  14. package/dist/public/assets/{AgentConnectionsSection-B9_oKPEW.js → AgentConnectionsSection-BBrTu_Hd.js} +1 -1
  15. package/dist/public/assets/{AgentDiffPane-CARKEc-n.js → AgentDiffPane-B4ONrFEX.js} +1 -1
  16. package/dist/public/assets/{AgentThreadClientBinder-C_cPFOsE.js → AgentThreadClientBinder-BKZL1FEK.js} +1 -1
  17. package/dist/public/assets/{AttachmentsSection-CTDcS4G0.js → AttachmentsSection-CCkTnF8H.js} +1 -1
  18. package/dist/public/assets/{BugReportHistory-CHujhV74.js → BugReportHistory-DCPpzbO5.js} +1 -1
  19. package/dist/public/assets/{BugReportHistoryDialog-CaE3cXFx.js → BugReportHistoryDialog-D-QZYqdF.js} +1 -1
  20. package/dist/public/assets/{CodeMirrorPropInput-DziaSRyA.js → CodeMirrorPropInput-C14KgbUB.js} +1 -1
  21. package/dist/public/assets/{ContentRulesSection-BoUMLaMI.js → ContentRulesSection-B9osiZ5e.js} +1 -1
  22. package/dist/public/assets/{DeleteConfirmationDialog-CUUTX6Ez.js → DeleteConfirmationDialog-B0lltyMh.js} +1 -1
  23. package/dist/public/assets/{DocumentContext-Cx6cWR4i.js → DocumentContext-B534Taw0.js} +1 -1
  24. package/dist/public/assets/{EditorModeToggle-BmS5EYHk.js → EditorModeToggle-lBQIZux4.js} +1 -1
  25. package/dist/public/assets/{ExcalidrawDocEditor-BY4UQfw2.js → ExcalidrawDocEditor-DiwiWo-5.js} +1 -1
  26. package/dist/public/assets/FeedbackForm-DN-7wKfh.js +1 -0
  27. package/dist/public/assets/{ImportSkillDialog-BlJk9fjc.js → ImportSkillDialog-gWGVsUXL.js} +1 -1
  28. package/dist/public/assets/{LinkPreviewsSection-Cj6sCkS3.js → LinkPreviewsSection-BCYSzx82.js} +1 -1
  29. package/dist/public/assets/{LintConfigEditor-Y8b1VzmV.js → LintConfigEditor-d7iNbkFu.js} +1 -1
  30. package/dist/public/assets/{LintingSection-DSdgtZap.js → LintingSection-BfQJhSqK.js} +1 -1
  31. package/dist/public/assets/{ManagedArtifactProperties-S7GjNV3d.js → ManagedArtifactProperties-CgYx_raS.js} +1 -1
  32. package/dist/public/assets/ManagedArtifactProperties-D0kvL_kU.js +1 -0
  33. package/dist/public/assets/{McpConsentDialogBody-CVZcuVhW.js → McpConsentDialogBody-9u-ImAfw.js} +1 -1
  34. package/dist/public/assets/{MermaidDocEditor-PBklQH0n.js → MermaidDocEditor-hIN30U4A.js} +1 -1
  35. package/dist/public/assets/{NetworkAccessSection-zZuupGBt.js → NetworkAccessSection-Bc1mBEpU.js} +1 -1
  36. package/dist/public/assets/{ProjectTemplatesSection-BEchYRnN.js → ProjectTemplatesSection-DYj1MFJG.js} +1 -1
  37. package/dist/public/assets/{PropertyDisplayRow-C3EiK8jV.js → PropertyDisplayRow-DYZRoIHn.js} +1 -1
  38. package/dist/public/assets/{PublishToGitHubDialog-CDIxzUHp.js → PublishToGitHubDialog-CWgik3XO.js} +1 -1
  39. package/dist/public/assets/{ReportBugDialogBody-jHepd9au.js → ReportBugDialogBody-Bbd3DGIB.js} +1 -1
  40. package/dist/public/assets/{ReportBugMenuTrigger-KsljCE5p.js → ReportBugMenuTrigger-DFg5tOG8.js} +1 -1
  41. package/dist/public/assets/{SchemaConfigEditor-DcuHTuF-.js → SchemaConfigEditor-kryiWiDK.js} +1 -1
  42. package/dist/public/assets/{SearchSection-CmKxwaFI.js → SearchSection-Cj7FdFQQ.js} +1 -1
  43. package/dist/public/assets/{SessionsHost-CFfbnCiC.js → SessionsHost-B9gM79-g.js} +2 -2
  44. package/dist/public/assets/{SettingsDialogBody-CwlAR3oi.js → SettingsDialogBody-CdmGZmCh.js} +2 -2
  45. package/dist/public/assets/{ShareReceiveMissDialog-Dfh_u69r.js → ShareReceiveMissDialog-BydqiR7F.js} +1 -1
  46. package/dist/public/assets/SkillInstallMenu-DtXyIqB8.js +1 -0
  47. package/dist/public/assets/{SkillPluginBundleDialog-BnQu_DSM.js → SkillPluginBundleDialog-XB1fO90e.js} +1 -1
  48. package/dist/public/assets/{SkillToolbarControls-DCBGvG7b.js → SkillToolbarControls-KYUxZQNe.js} +1 -1
  49. package/dist/public/assets/{SkillsManagerSection-D4YW1uOY.js → SkillsManagerSection-DCJlhnvy.js} +1 -1
  50. package/dist/public/assets/{SourceEditor-Ct16BvoA.js → SourceEditor-BIPGmkaK.js} +1 -1
  51. package/dist/public/assets/{SpellingSettings-BFvKxALP.js → SpellingSettings-DhyHqpT4.js} +1 -1
  52. package/dist/public/assets/{SyncSection-7RBalU2A.js → SyncSection-CPLGR0K4.js} +1 -1
  53. package/dist/public/assets/{SyncStatusBadge-CvIcZmIZ.js → SyncStatusBadge-Co74i3q_.js} +1 -1
  54. package/dist/public/assets/{TemplateRow-4LHta_yW.js → TemplateRow-B04s7sdl.js} +1 -1
  55. package/dist/public/assets/{TerminalLaunchContext-DprnLNoQ.js → TerminalLaunchContext-VC_1IQ2O.js} +1 -1
  56. package/dist/public/assets/{TerminalPanel-D93jMQs_.js → TerminalPanel-Bj0ZrCsM.js} +2 -2
  57. package/dist/public/assets/{TerminalSection-uEJkYj2U.js → TerminalSection-DEVYY41F.js} +1 -1
  58. package/dist/public/assets/{TerminalWindowApp-Bis-JDdP.js → TerminalWindowApp-XRrhf3K3.js} +1 -1
  59. package/dist/public/assets/{TextDocEditor-IMDFjQrq.js → TextDocEditor-Eqrxtsiw.js} +1 -1
  60. package/dist/public/assets/{ThemePluginSection-C-CpTYq_.js → ThemePluginSection-DvtPYcRy.js} +1 -1
  61. package/dist/public/assets/ThreadView-CDE0BRUz.js +28 -0
  62. package/dist/public/assets/{TimelineDiffPane-DMgLR5AW.js → TimelineDiffPane-CLScmppv.js} +1 -1
  63. package/dist/public/assets/{agent-connections-D6YhmKlS.js → agent-connections-BdU_6bUV.js} +1 -1
  64. package/dist/public/assets/alert-dialog-Mwvu63aS.js +7 -0
  65. package/dist/public/assets/{client-version-2Mppplfj.js → client-version-V5JX2_9H.js} +1 -1
  66. package/dist/public/assets/{comment-chips-BwBti9Bl.js → comment-chips-B6PiUF0P.js} +1 -1
  67. package/dist/public/assets/{config-provider-DRxl68wD.js → config-provider-CY8rv6VT.js} +1 -1
  68. package/dist/public/assets/config-schema-gPKGwQR7.js +1 -0
  69. package/dist/public/assets/{doc-undo-manager-C91Oo7rt.js → doc-undo-manager-BgNKZ6KQ.js} +1 -1
  70. package/dist/public/assets/field-controls-DShsojhy.js +1 -0
  71. package/dist/public/assets/{field-controls-BpWYzCuF.js → field-controls-DtQ6Aw_j.js} +1 -1
  72. package/dist/public/assets/{index-Co3uFj5v.js → index-zyBtEQ0N.js} +8 -8
  73. package/dist/public/assets/{lint-config-client-Dg87hhVT.js → lint-config-client-DZxh6x0d.js} +1 -1
  74. package/dist/public/assets/{lint-plugins-DVI7vQmE.js → lint-plugins-D1JSXJl8.js} +1 -1
  75. package/dist/public/assets/{markdown-lint-x790xNNy.js → markdown-lint-CYB8LZHY.js} +1 -1
  76. package/dist/public/assets/{markdownlint-rule-browser-8GiyDBq_.js → markdownlint-rule-browser-BHLBJ88w.js} +1 -1
  77. package/dist/public/assets/messages-BDCxJPx2.js +1 -0
  78. package/dist/public/assets/messages-BEW0uPVX.js +1 -0
  79. package/dist/public/assets/messages-BO-eBk9m.js +1 -0
  80. package/dist/public/assets/messages-BaDp2_Fp.js +1 -0
  81. package/dist/public/assets/messages-CDO-xexo.js +1 -0
  82. package/dist/public/assets/messages-CRHWN_nJ.js +1 -0
  83. package/dist/public/assets/messages-CVuWmrbN.js +1 -0
  84. package/dist/public/assets/messages-C_w7Btlk.js +1 -0
  85. package/dist/public/assets/messages-CtVlTdzP.js +1 -0
  86. package/dist/public/assets/messages-Cz11LTJA.js +1 -0
  87. package/dist/public/assets/messages-D3qz2TwL.js +1 -0
  88. package/dist/public/assets/messages-DHXe_6Gj.js +1 -0
  89. package/dist/public/assets/messages-DKWtuhsU.js +1 -0
  90. package/dist/public/assets/{pending-receive-nav-store-D00zGtAr.js → pending-receive-nav-store-DDsjXMmg.js} +1 -1
  91. package/dist/public/assets/{preferred-session-events-HEU-5nkP.js → preferred-session-events-YlTzEpA1.js} +1 -1
  92. package/dist/public/assets/{progress-BtyrAYUy.js → progress-fe7kZ4GR.js} +1 -1
  93. package/dist/public/assets/{saved-themes-client-CiHeGH6d.js → saved-themes-client-BPWMEtsb.js} +1 -1
  94. package/dist/public/assets/{schema-section-CzcjDNJt.js → schema-section-DUv4SBzP.js} +1 -1
  95. package/dist/public/assets/{selection-context-HzQ8FtwX.js → selection-context-CJj4QU9m.js} +1 -1
  96. package/dist/public/assets/{sign-in-terminal-events-DFnpq2Xu.js → sign-in-terminal-events-BjvOWBuh.js} +1 -1
  97. package/dist/public/assets/{src-23Nu47Ud.js → src-DHA7yznt.js} +1 -1
  98. package/dist/public/assets/{telemetry-impl-DXS2NSHU.js → telemetry-impl-BoQfVHFh.js} +1 -1
  99. package/dist/public/assets/{telemetry-startup-D9zsSdNI.js → telemetry-startup-BePJfd1G.js} +1 -1
  100. package/dist/public/assets/thread-client-CySNJ-9g.js +3 -0
  101. package/dist/public/assets/{typing-burst-detector-DHfcudgi.js → typing-burst-detector-DEB_IQXO.js} +1 -1
  102. package/dist/public/assets/{uninstall-Dpuk0rjl.js → uninstall-DnITG12q.js} +1 -1
  103. package/dist/public/assets/{use-activity-panel-Bihi6LUs.js → use-activity-panel-DmN2jwm1.js} +1 -1
  104. package/dist/public/assets/{use-apply-config-language-B6Gq14bn.js → use-apply-config-language-DlSviEmN.js} +2 -2
  105. package/dist/public/assets/{use-installed-clis-BTrIR9--.js → use-installed-clis-IB8iDaEn.js} +2 -2
  106. package/dist/public/assets/{use-open-skill-B3yZzcRf.js → use-open-skill-D8ppWfzv.js} +1 -1
  107. package/dist/public/assets/{use-terminal-enabled-KnMOlCdw.js → use-terminal-enabled-CnYgBQu6.js} +1 -1
  108. package/dist/public/assets/{use-timeline-entry-diff-CahLIRQA.js → use-timeline-entry-diff-Bj9IKZ0j.js} +1 -1
  109. package/dist/public/index.html +33 -33
  110. package/dist/public/uninstall.html +3 -3
  111. package/dist/{registry-probes-5d1sNdrt.mjs → registry-probes-DjoTkaRp.mjs} +1 -1
  112. package/dist/{removal-file-path-Ce-SU21T.mjs → removal-file-path-C3qKjXP1.mjs} +1 -1
  113. package/dist/{repair-launch-json-loOJnWcB.mjs → repair-launch-json-BLLbBwuS.mjs} +1 -1
  114. package/dist/{repair-mcp-configs-F5gZqTRO.mjs → repair-mcp-configs-Du599MHw.mjs} +1 -1
  115. package/dist/src-C3wvr_Qn.mjs +1 -0
  116. package/dist/{src-CogLbAhI.mjs → src-CV7s8o8N.mjs} +1 -1
  117. package/dist/start-B6ETYSpw.mjs +1 -0
  118. package/dist/{start-Bqp-AUZl.mjs → start-WZZeXyQg.mjs} +2 -2
  119. package/package.json +4 -4
  120. package/dist/constants-DKjIJ8BH.mjs +0 -1
  121. package/dist/init-CT4iXGbs.mjs +0 -1
  122. package/dist/loader-DMgqHZVT.mjs +0 -1
  123. package/dist/preview-BGPQ_giI.mjs +0 -1
  124. package/dist/public/assets/FeedbackForm-DvRjZiGv.js +0 -1
  125. package/dist/public/assets/ManagedArtifactProperties-q4TqoQV2.js +0 -1
  126. package/dist/public/assets/SkillInstallMenu-29VzNm-A.js +0 -2
  127. package/dist/public/assets/ThreadView-Bv4nKAfi.js +0 -28
  128. package/dist/public/assets/alert-dialog-BA3e7-10.js +0 -7
  129. package/dist/public/assets/config-schema-C-FQk_Mm.js +0 -1
  130. package/dist/public/assets/field-controls-CeiuhLz4.js +0 -1
  131. package/dist/public/assets/messages-7ot3-W0V.js +0 -1
  132. package/dist/public/assets/messages-BApsFcNp.js +0 -1
  133. package/dist/public/assets/messages-BBuXP7Ld.js +0 -1
  134. package/dist/public/assets/messages-BNJUhcVY.js +0 -1
  135. package/dist/public/assets/messages-BuskOiEV.js +0 -1
  136. package/dist/public/assets/messages-CARxKltJ.js +0 -1
  137. package/dist/public/assets/messages-CJU9Nxin.js +0 -1
  138. package/dist/public/assets/messages-CTMApgaB.js +0 -1
  139. package/dist/public/assets/messages-CgDzjmQd.js +0 -1
  140. package/dist/public/assets/messages-DBYYZ3YE.js +0 -1
  141. package/dist/public/assets/messages-DZ7BcTw6.js +0 -1
  142. package/dist/public/assets/messages-DZILDMH3.js +0 -1
  143. package/dist/public/assets/messages-DrbEzBII.js +0 -1
  144. package/dist/public/assets/thread-client-B5QuHu0p.js +0 -3
  145. package/dist/src-XoibUPmJ.mjs +0 -1
  146. package/dist/start-TeIncOoZ.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$u as r,Bf as i,Df as a,Ef as o,Ff as s,If as c,Jc as l,Lf as u,Mf as d,Uc as f,Wa as p,df as m,ff as h,kf as g,lf as _,mf as v,yd as y}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Aa as ee,Uo as b,Vn as te,bs as x,gr as ne,hs as S,is as re,m as C,ms as w,tr as ie,xs as ae}from"./dist-0gI1oLbO.mjs";import{A as oe,E as se,F as ce,M as le,N as T,S as ue,T as de,Y as fe,Z as E,at as pe,b as me,et as he,f as ge,ft as _e,it as ve,j as ye,k as D,lt as be,nt as xe,ot as Se,p as Ce,rt as we,s as Te,ut as Ee,y as De,z as Oe}from"./init-DRDwcEOj.mjs";import{t as ke}from"./is-object-BGze3w87.mjs";import{t as Ae}from"./removal-file-path-Ce-SU21T.mjs";import{spawn as je}from"node:child_process";import{basename as O,dirname as k,join as A,resolve as j,win32 as Me}from"node:path";import{accessSync as Ne,constants as M,existsSync as N,lstatSync as P,mkdirSync as Pe,readFileSync as F,readdirSync as I,realpathSync as L,rmSync as Fe,rmdirSync as Ie,statSync as R,unlinkSync as Le}from"node:fs";import{homedir as z}from"node:os";import{createHash as Re}from"node:crypto";import{isDeepStrictEqual as ze}from"node:util";import{setTimeout as Be}from"node:timers/promises";var Ve=r();let He;function Ue(){return He}function We(e,t){if(t!==void 0&&t.length>0)return t;try{return ne(e)?.rootPath}catch{return}}function Ge(e){let t=We(e.cwd,e.configuredProjectName),n=te({name:`cli`,project:t});return He=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}function B(){return l(f)}function V(){return d().keyringService}function H(e){try{e()}catch{}}var Ke=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(V(),e).getPassword()}catch(t){return H(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return H(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return H(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(V(),e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(V(),e).deletePassword()}catch{}}},U=class{backend=`file`;authFile;constructor(e){this.authFile=e??A(S(),`auth.yml`)}read(){if(!N(this.authFile))return{};try{let e=F(this.authFile,`utf-8`);return(0,Ve.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=k(this.authFile);N(t)||Pe(t,{recursive:!0,mode:448}),w(this.authFile,(0,Ve.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},qe=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ${B()} to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function Je(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(V(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
1
+ import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$u as r,Bf as i,Df as a,Ef as o,Ff as s,If as c,Jc as l,Lf as u,Mf as d,Uc as f,Wa as p,df as m,ff as h,kf as g,lf as _,mf as v,yd as y}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Aa as ee,Uo as b,Vn as te,bs as x,gr as ne,hs as S,is as re,m as C,ms as w,tr as ie,xs as ae}from"./dist-0gI1oLbO.mjs";import{A as oe,E as se,F as ce,M as le,N as T,S as ue,T as de,Y as fe,Z as E,at as pe,b as me,et as he,f as ge,ft as _e,it as ve,j as ye,k as D,lt as be,nt as xe,ot as Se,p as Ce,rt as we,s as Te,ut as Ee,y as De,z as Oe}from"./init-DIAKdBV0.mjs";import{t as ke}from"./is-object-BGze3w87.mjs";import{t as Ae}from"./removal-file-path-C3qKjXP1.mjs";import{spawn as je}from"node:child_process";import{basename as O,dirname as k,join as A,resolve as j,win32 as Me}from"node:path";import{accessSync as Ne,constants as M,existsSync as N,lstatSync as P,mkdirSync as Pe,readFileSync as F,readdirSync as I,realpathSync as L,rmSync as Fe,rmdirSync as Ie,statSync as R,unlinkSync as Le}from"node:fs";import{homedir as z}from"node:os";import{createHash as Re}from"node:crypto";import{isDeepStrictEqual as ze}from"node:util";import{setTimeout as Be}from"node:timers/promises";var Ve=r();let He;function Ue(){return He}function We(e,t){if(t!==void 0&&t.length>0)return t;try{return ne(e)?.rootPath}catch{return}}function Ge(e){let t=We(e.cwd,e.configuredProjectName),n=te({name:`cli`,project:t});return He=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}function B(){return l(f)}function V(){return d().keyringService}function H(e){try{e()}catch{}}var Ke=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(V(),e).getPassword()}catch(t){return H(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return H(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return H(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(V(),e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(V(),e).deletePassword()}catch{}}},U=class{backend=`file`;authFile;constructor(e){this.authFile=e??A(S(),`auth.yml`)}read(){if(!N(this.authFile))return{};try{let e=F(this.authFile,`utf-8`);return(0,Ve.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=k(this.authFile);N(t)||Pe(t,{recursive:!0,mode:448}),w(this.authFile,(0,Ve.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},qe=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ${B()} to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function Je(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(V(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
2
2
  `),H(()=>t?.onBackendSelected?.({backend:`keyring`})),new qe(new Ke(t?.onKeychainRead),new U(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (${B()}) — OS keychain unavailable: ${r}\n`),H(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new U(e)}}function Ye(e){let t=null;return function(){if(t)return t;let n=2e3;return t=(async()=>{let t=null,r=new Promise(r=>{t=setTimeout(()=>{process.stderr.write(`[auth] token storage: keyring init exceeded ${n}ms; falling back to file (${B()})\n`),r(new U(e))},n)});try{return await Promise.race([Je(e),r])}catch{return new U(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function Xe(e){let t=Ye(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token,login:n.login}}}}function Ze(e){let t=Ye(e);return{backend:`file`,async get(e){return(await t()).get(e)},async set(e,n,r,i){return(await t()).set(e,n,r,i)},async clear(e){return(await t()).clear(e)}}}async function Qe(e,t){let n=[],r=new U(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));let i;try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(V(),`__probe__`);let r,a=await new Ke(e=>{e.kind===`read-error`&&(r=e.error??`read-error`)}).get(e);if(r!==void 0)i=r;else if(a!=null)try{new t(V(),e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}function $e(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function et(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function tt(e){return b({detached:!0,stdio:`ignore`,shell:!1,env:$e(e)})}function nt(e,t,n={}){let r=(n.spawn??je)(e,[...t],tt(n.env??process.env));return r.unref(),r}function rt(e,t,n={}){let r=n.spawn??je,i=n.timeoutMs??2e3;return new Promise(a=>{let o=!1,s=e=>{o||(o=!0,a(e))},c=setTimeout(()=>s({ok:!1,reason:`timeout`}),i);try{let i=r(e,[...t],tt(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(et(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(et(e))}})}const it=o.stable.appId,W=g,at=[`stable`,`beta`];function ot(e,t,n=e=>console.error(e)){try{return i(e,t)}catch(r){let o=i({...e,[a]:void 0},t);return n(`Treating this CLI as ${s(o)} for this command: ${r instanceof Error?r.message:String(r)}`),o}}function G(e){return at.includes(e)||!W.includes(e)?at:[e,...at]}function st(e){return e.bundlePath===void 0?null:{bundlePath:e.bundlePath,protocolScheme:o[e.product].protocolScheme}}function ct(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return R(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function lt(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let n=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(n?.[1]){let e=n[1];return{path:e,product:W.find(t=>e.endsWith(`/${o[t].productName}.app`))??t}}}let n=e.homeDir??z();for(let r of G(t)){let{productName:t}=o[r];for(let i of[A(n,`Applications`),`/Applications`]){let n=A(i,`${t}.app`);if(ut(e,A(n,`Contents`,`MacOS`,t)))return{path:n,product:r}}}return null}function ut(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}function dt(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=W.find(t=>e.execPath.toLowerCase().endsWith(`\\${c(o[t]).toLowerCase()}`));if(t)return{path:e.execPath,product:t}}let n=e.env.LOCALAPPDATA;if(n)for(let r of G(t))for(let t of u(o[r])){let i=Me.join(n,`Programs`,t,c(o[r]));if(ut(e,i))return{path:i,product:r}}return null}function ft(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=W.find(t=>e.execPath.endsWith(`/${o[t].linuxExecutableName}`));if(t)return{path:e.execPath,product:t}}for(let n of G(t)){let{productName:t,linuxExecutableName:r}=o[n],i=`/opt/${t}/${r}`;if(ut(e,i))return{path:i,product:n}}return null}function pt(e){let t=ot(e.env,e.execPath,e.warn);if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`,cliProduct:t};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`,cliProduct:t};let n;try{n=e.platform===`darwin`?lt(e,t):e.platform===`win32`?dt(e,t):ft(e,t)}catch{return{available:!1,reason:`stat-error`,cliProduct:t}}if(!n)return{available:!1,reason:`no-bundle`,cliProduct:t};let r={bundlePath:n.path,product:n.product,cliProduct:t};return e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,...r}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,...r}:{available:!0,reason:`available`,...r}}function mt(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(t.bundlePath===void 0){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}let{productName:i}=o[t.product],[a]=o[t.cliProduct].cliCommandNames;n(`Launching ${i} desktop (use \`${a} start\` for the browser server, or \`OK_FORCE_BROWSER=1\` to always skip)`);let s=t.bundlePath;if(r===`darwin`){nt(`open`,[`-a`,s],{spawn:e.spawn});return}nt(s,[],{spawn:e.spawn})}function ht(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it from https://openknowledge.ai/download, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function K(e){return e.replace(/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\u200b\ufeff]/gu,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function gt(e){return Re(`sha256`).update(e).digest(`hex`)}function q(e){return A(S(j(e)),`pi-trust`)}function _t(e,t){return A(q(e),gt(j(t)))}function vt(e,t,n){return A(_t(e,t),`${gt(n)}.json`)}var J=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${K(e)} ${K(t)}; ${K(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function Y(e,t,n){let r=n.code,i=n instanceof Error?n.message:String(n),a;switch(r){case`EACCES`:case`EPERM`:a=`check receipt and parent-directory permissions, then retry`;break;case`ENOENT`:a=`the location no longer exists; restore access to its expected location, then retry`;break;default:a=`check the path and available storage, then retry`}return new J(e,`could not ${t}: ${i}`,a,n)}function X(e){let t;try{t=P(e)}catch(t){if(t.code===`ENOENT`)return!1;throw Y(e,`be inspected`,t)}if(!t.isDirectory())throw new J(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function yt(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function bt(e,t){if(!ke(e)||!yt(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==j(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==j(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==j(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!ke(e.previous))throw new J(t,`has invalid contents`,`restore a valid ownership record from a backup without guessing its trust decision, then retry`);let n;if(e.previous.present===!1&&yt(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&yt(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new J(t,`has an invalid previous decision`,`restore the recorded previous decision from a backup without guessing its value, then retry`);return{version:1,cwd:e.cwd,configuredTrustPath:e.configuredTrustPath,canonicalTrustPath:e.canonicalTrustPath,state:e.state,previous:n}}function xt(e,t,n){let r;try{r=P(n)}catch(e){throw Y(n,`be inspected`,e)}if(!r.isFile())throw new J(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=F(n,`utf8`)}catch(e){throw Y(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new J(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=bt(a,n);if(o.cwd!==j(t)||n!==vt(e,t,o.canonicalTrustPath))throw new J(n,`does not match its project or trust-store location`,`restore the ownership record to its original project and trust-store location, then retry`);return{path:n,record:o}}function St(e,t){let{record:n,path:r}=t;for(let t of[q(e),_t(e,n.cwd)])if(!X(t))throw new J(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=xt(e,n.cwd,r);if(!ze(i.record,n))throw new J(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function Ct(e,t,n,r,i){let a={version:1,cwd:j(t),configuredTrustPath:j(n),canonicalTrustPath:j(r),state:`pending`,previous:i},o=vt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!ze(bt(JSON.parse(s),o),a))throw new J(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);X(q(e)),X(k(o));try{Pe(k(o),{recursive:!0,mode:448})}catch(e){throw Y(k(o),`be created`,e)}let c;try{c=P(o,{throwIfNoEntry:!1})}catch(e){throw Y(o,`be inspected`,e)}if(c)throw new J(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{w(o,s,{mode:384})}catch(e){throw Y(o,`be written`,e)}return{path:o,record:a}}function wt(e,t){let n=St(e,t);if(n.record.state!==`pending`)throw new J(n.path,`is already committed`,`use the current ownership record without committing it again`);let r={...n.record,state:`committed`};try{w(n.path,`${JSON.stringify(r,null,2)}\n`,{mode:384})}catch(e){throw Y(n.path,`be committed`,e)}return{path:n.path,record:r}}function Z(e,t){if(!X(q(e)))return[];let n=_t(e,t);if(!X(n))return[];let r;try{r=I(n).sort()}catch(e){throw Y(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>xt(e,t,A(n,r)))}function Tt(e,t){let n=St(e,t);try{Le(n.path)}catch(e){throw Y(n.path,`be removed after reconciling its grant`,e)}for(let t of[k(n.path),q(e)])try{Ie(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw Y(t,`be removed after reconciling its grant`,e)}}var Et=n(((t,n)=>{var r=e(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),Dt=n(((t,n)=>{var r=e(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),Ot=n(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),kt=n(((t,n)=>{var r=e(`fs`),i=Et(),a=Dt(),o=Ot(),s=e(`util`),c,l;typeof Symbol==`function`&&typeof Symbol.for==`function`?(c=Symbol.for(`graceful-fs.queue`),l=Symbol.for(`graceful-fs.previous`)):(c=`___graceful-fs.queue`,l=`___graceful-fs.previous`);function u(){}function d(e,t){Object.defineProperty(e,c,{get:function(){return t}})}var f=u;s.debuglog?f=s.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(f=function(){var e=s.format.apply(s,arguments);e=`GFS4: `+e.split(/\n/).join(`
3
3
  GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){function t(t,n){return e.call(r,t,function(e){e||g(),typeof n==`function`&&n.apply(this,arguments)})}return Object.defineProperty(t,l,{value:e}),t})(r.close),r.closeSync=(function(e){function t(t){e.apply(r,arguments),g()}return Object.defineProperty(t,l,{value:e}),t})(r.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){f(r[c]),e(`assert`).equal(r[c].length,0)})),global[c]||d(global,r[c]),n.exports=p(o(r)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!r.__patched&&(n.exports=p(r),r.__patched=!0);function p(e){i(e),e.gracefulify=p,e.createReadStream=S,e.createWriteStream=re;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?m([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=o;function o(e,t,n,i){return typeof n==`function`&&(i=n,n=null),a(e,t,n,i);function a(e,t,n,i,o){return r(e,t,n,function(r){r&&(r.code===`EMFILE`||r.code===`ENFILE`)?m([a,[e,t,n,i],r,o||Date.now(),Date.now()]):typeof i==`function`&&i.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var f=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=f.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?m([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=a(e);b=g.ReadStream,x=g.WriteStream}var _=e.ReadStream;_&&(b.prototype=Object.create(_.prototype),b.prototype.open=te);var v=e.WriteStream;v&&(x.prototype=Object.create(v.prototype),x.prototype.open=ne),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0});var y=b;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var ee=x;Object.defineProperty(e,"FileWriteStream",{get:function(){return ee},set:function(e){ee=e},enumerable:!0,configurable:!0});function b(e,t){return this instanceof b?(_.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function te(){var e=this;w(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function x(e,t){return this instanceof x?(v.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function ne(){var e=this;w(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function S(t,n){return new e.ReadStream(t,n)}function re(t,n){return new e.WriteStream(t,n)}var C=e.open;e.open=w;function w(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return C(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function m(e){f(`ENQUEUE`,e[0].name,e[1]),r[c].push(e),_()}var h;function g(){for(var e=Date.now(),t=0;t<r[c].length;++t)r[c][t].length>2&&(r[c][t][3]=e,r[c][t][4]=e);_()}function _(){if(clearTimeout(h),h=void 0,r[c].length!==0){var e=r[c].shift(),t=e[0],n=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)f(`RETRY`,t.name,n),t.apply(null,n);else if(Date.now()-a>=6e4){f(`TIMEOUT`,t.name,n);var s=n.pop();typeof s==`function`&&s.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(f(`RETRY`,t.name,n),t.apply(null,n.concat([a]))):r[c].push(e)}h===void 0&&(h=setTimeout(_,0))}}})),At=n(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0){if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1}var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),jt=n((e=>{var t=At();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),Mt=n(((e,t)=>{t.exports=jt()})),Nt=n(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),Pt=n(((t,n)=>{var r=global.process;let i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=Nt(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}return _.apply(this,arguments)}}})),Ft=n(((e,t)=>{let n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),It=n(((t,n)=>{let r=e(`path`),i=kt(),a=Mt(),o=Pt(),s=Ft(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function d(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?d(e,{...t,stale:0},n):n(r);if(!f(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));p(e,t,r=>{if(r)return n(r);d(e,{...t,stale:0},n)})})})}function f(e,t){return e.mtime.getTime()<Date.now()-t.stale}function p(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function m(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return h(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,m(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function h(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function g(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{d(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};m(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));_(r,{...t,realpath:!1},e)})})})})}function _(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],p(r,t,n)})}function v(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!f(r,t)))})}function y(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=g,n.exports.unlock=_,n.exports.check=v,n.exports.getLocks=y})),Lt=n(((e,t)=>{let n=kt();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),Rt=t(n(((e,t)=>{let n=It(),{toPromise:r,toSync:i,toSyncOptions:a}=Lt();async function o(e,t){let i=await r(n.lock)(e,t);return r(i)}function s(e,t){let r=i(n.lock)(e,a(t));return i(r)}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}))(),1);const zt=5e3;function Bt(e,t,n){if(!(e instanceof Error)||!(`code`in e)||e.code!==`ELOCKED`)throw e;let r=t-performance.now();if(r<=0)throw Object.assign(Error(`Could not acquire Pi trust lock at ${n}.lock within ${zt}ms`,{cause:e}),{code:`ELOCKED`});return Math.min(25,r)}function Vt(e,t){Ue()?.warn(t,e)}function Ht(e,t){if(e.length===0)return;if(e.length===1)throw e[0];let[n,r]=e,i=n instanceof Error?n.message:String(n),a=r instanceof Error?r.message:String(r);throw AggregateError(e,`Pi trust update failed: ${i}\nReleasing Pi trust lock ${t}.lock also failed: ${a}`)}async function Ut(e,t,n){await x(`${t}.ok.lock`,async()=>{let t=performance.now()+zt,r;for(;;)try{r=await Rt.default.lock(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Be(Bt(n,t,e))}let i=[];try{n()}catch(e){i.push(e)}finally{try{await r()}catch(e){i.push(e)}}Ht(i,e)},{onWarn:Vt})}function Wt(e,t,n){ae(`${t}.ok.lock`,()=>{let t=performance.now()+zt,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=Rt.default.lockSync(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){Atomics.wait(r,0,0,Bt(n,t,e))}let a=[];try{n()}catch(e){a.push(e)}finally{try{i()}catch(e){a.push(e)}}Ht(a,e)},{onWarn:Vt})}const Gt=[`settings.json`,`prompts`,`themes`,`SYSTEM.md`,`APPEND_SYSTEM.md`];var Kt=class extends Error{name=`PiResourceInspectionError`};function qt(e){let t;try{t=P(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}let n;try{n=R(e)}catch(e){throw t.isSymbolicLink()&&e.code===`ENOENT`?new Kt(le(`missing-symlink-target`),{cause:e}):e}return Ne(e,M.R_OK|(n.isDirectory()?M.X_OK:0)),!0}function Jt(e){return e===`open-knowledge`||e.startsWith(`open-knowledge-`)}function Yt(e,t,n){let r=e;try{let i=L(e),a;r=t;try{a=L(t)}catch(e){if(e.code!==`ENOENT`)throw e;a=j(t)}let o=A(a,`.agents`,`skills`),s=[];for(let e of Gt)r=A(i,`.pi`,e),qt(r)&&s.push(r);if(r=A(i,`.pi`,`extensions`),qt(r))for(let t of I(r).sort()){let i=A(r,t);j(n)!==A(j(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[A(i,`.pi`,`skills`),A(i,`.agents`,`skills`)])if(e!==o&&(r=e,qt(e)))for(let t of I(e).sort())Jt(t)||s.push(A(e,t));let c=k(i);for(;c!==i;){r=A(c,`.agents`,`skills`),r!==o&&qt(r)&&s.push(r);let e=k(c);if(e===c)break;c=e}return s.length===0?{kind:`none`}:{kind:`shared`,paths:s.sort()}}catch(e){return{kind:`unreadable`,error:`Could not inspect Pi project resources at ${K(r)}: ${e instanceof Kt?e.message:le(T(e))}`}}}function Xt(e,t,n){let r=j(e),i=be({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:E.pi.projectConfigPath(r),trustPath:A(i,`trust.json`)}}function Zt(e){try{let t=L(e);return R(t).isDirectory()?(Ne(t,M.X_OK),{kind:`ready`,project:{path:e,canonical:t}}):{kind:`refused`,error:`Pi project path ${K(e)} is not a directory; restore the intended project directory, then retry`}}catch(t){return{kind:`refused`,error:`Pi project directory ${K(e)} could not be resolved or accessed: ${K(t instanceof Error?t.message:String(t))}; restore the directory or symlink and check its permissions, then retry`}}}function Qt(e){let t=Zt(e.path);if(t.kind===`refused`)return t.error;if(t.project.canonical!==e.canonical)return`Pi project path ${K(e.path)} changed while waiting for its trust lock; restore the intended project location, then retry`}function $t(e,t,n){let r=Te(E.pi,e,n,t);if(r.kind===`absent`)return{state:`absent`,text:null};if(r.kind!==`present`)return{state:`unreadable`,text:null};let i=r.entry,a=Array.isArray(i.args)&&typeof i.args[0]==`string`?i.args[0]:null;return ve(i)?{state:`own-current`,text:a}:se(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function en(e,t){let n;try{n=F(e.path,`utf-8`)}catch(t){let n=t.code;return e.kind===`missing`&&n===`ENOENT`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,reason:T(t)}}if(n.trim()===``)return{state:`untrusted`,entries:{},trailingNewline:!1};let r;try{r=JSON.parse(n)}catch{return{state:`unreadable`,reason:`invalid-json`}}return ke(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
4
4
  `)}:{state:`unreadable`,reason:`invalid-json`}}function tn(e){switch(e){case`invalid-json`:return`the file is not a valid JSON object; repair its JSON, then retry`;case`path-changed`:return`the path changed while waiting for its lock; retry to check its current state`;case`unavailable-root`:return`the filesystem root is unavailable; reconnect the drive or network share, then retry`;default:return le(e)}}function Q(e,t){return{kind:`refused`,error:`trust store ${K(e)}: ${tn(t)}`}}function nn(e){let t=Ae(e);try{switch(t.kind){case`declined`:return Q(e,t.reason);case`ready`:return{kind:`ready`,path:L(t.path)};case`not-present`:break;default:throw Error(`unhandled trust file resolution: ${t}`)}let n=k(e),r=[O(e)],i=P(n,{throwIfNoEntry:!1});for(;!i;){let t=k(n);if(t===n)return Q(e,`unavailable-root`);r.unshift(O(n)),n=t,i=P(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:A(L(n),...r)}}catch(t){return Q(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:T(t))}}catch(t){return Q(e,T(t))}}function rn(e,t){let n=nn(e);return n.kind===`refused`?n:n.path!==t.path||t.kind===`ready`&&n.kind===`missing`?Q(e,`path-changed`):n}function an(e,t,n){let r=Xt(e,t,n),i=Zt(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=$t(r.cwd,r.bridgePath,t).state,o=nn(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:en(o,i.project.canonical).state;return{...r,project:`ready`,canonicalCwd:i.project.canonical,bridge:a,trust:s,bridgeLoadable:(a===`own-current`||a===`own-stale`)&&s===`trusted`,otherExtensions:on(r.bridgePath).displayNames}}function on(e){let t=k(e),n=O(e);try{return{displayNames:I(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>K(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function sn(e,t={mode:`published`},n,r,i){let a=Xt(e,n,r),o=Zt(a.cwd);if(o.kind===`refused`)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:o.error};if(i!==void 0&&o.project.canonical!==i)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:`The approved Pi project directory ${K(i)} no longer matches the current directory ${K(o.project.canonical)}. Reopen the intended project and approve the Pi integration again; no bridge or trust settings were changed.`};let s=$t(a.cwd,a.bridgePath,n);if(s.state===`foreign`)return{...a,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(s.state===`unreadable`)return{...a,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let c;if(s.state===`absent`)c=`written`;else{let e;try{e=de(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=me(E.pi,a.cwd,t,n,a.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...a,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error===void 0?`bridge write ${e.action}`:K(e.error)}}let l=await cn(a.trustPath,o.project,n??z());return{...a,ok:l.action===`already-trusted`||l.action===`added`,bridge:c,trust:l.action,...l.error===void 0?{}:{error:l.error}}}async function cn(e,t,n){let r=t.canonical,i=nn(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{Pe(k(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:K(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await Ut(e,i.path,()=>{let o=Qt(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=rn(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=en(s,r);if(c.state===`trusted`){a.action=`already-trusted`;return}if(c.state===`unreadable`){a.action=`refused-unreadable`,a.error=Q(e,c.reason).error;return}let l=$(n,()=>{let t=Z(n,r).find(e=>e.record.canonicalTrustPath===s.path);return t&&Tt(n,t),Ct(n,r,e,s.path,Object.hasOwn(c.entries,r)?{present:!0,value:c.entries[r]}:{present:!1})}),u={...c.entries,[r]:!0},d=JSON.stringify(u,null,2)+(c.trailingNewline?`
@@ -1 +1 @@
1
- import{C as e,N as t}from"./init-DRDwcEOj.mjs";import{lstatSync as n,statSync as r}from"node:fs";function i(i){let a;try{a=n(i).isSymbolicLink()}catch(e){return e.code===`ENOENT`?{kind:`not-present`}:{kind:`declined`,reason:t(e)}}let o=e(i);if(o.readPath===null)return{kind:`declined`,reason:`unresolved-symlink`};try{if(!r(o.readPath).isFile())return{kind:`declined`,reason:`not-a-file`}}catch(e){return{kind:`declined`,reason:a&&e.code===`ENOENT`?`missing-symlink-target`:t(e)}}return{kind:`ready`,path:o.writePath,symlink:a}}export{i as t};
1
+ import{C as e,N as t}from"./init-DIAKdBV0.mjs";import{lstatSync as n,statSync as r}from"node:fs";function i(i){let a;try{a=n(i).isSymbolicLink()}catch(e){return e.code===`ENOENT`?{kind:`not-present`}:{kind:`declined`,reason:t(e)}}let o=e(i);if(o.readPath===null)return{kind:`declined`,reason:`unresolved-symlink`};try{if(!r(o.readPath).isFile())return{kind:`declined`,reason:`not-a-file`}}catch(e){return{kind:`declined`,reason:a&&e.code===`ENOENT`?`missing-symlink-target`:t(e)}}return{kind:`ready`,path:o.writePath,symlink:a}}export{i as t};
@@ -1 +1 @@
1
- import{t as e}from"./launch-json-removal-BdlZ0vPm.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=(n.removeOwnLaunchEntryFn??e)(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,severity:`warn`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`;return s&&i({event:`launch-json-repair-removed`,severity:`info`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
1
+ import{t as e}from"./launch-json-removal-DJC4Yapa.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=(n.removeOwnLaunchEntryFn??e)(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,severity:`warn`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`;return s&&i({event:`launch-json-repair-removed`,severity:`info`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
@@ -1 +1 @@
1
- import{E as e}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Y as t,Z as n,b as r,et as i,it as a,p as o,tt as s}from"./init-DRDwcEOj.mjs";import{homedir as c}from"node:os";function l(e){let{priorCommand:t,priorArgs:n}=u(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function u(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function d(e){let r=e.logger??h,i=e.home??c(),a=[];if(e.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of t){let t=n[o],s=f(()=>t.configPath(``,i));if(s!==null&&a.push(p({scope:`user`,editorId:o,target:t,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),t.projectConfigPath){let n=t.projectConfigPath,i=f(()=>n(e.projectDir));i!==null&&a.push(p({scope:`project`,editorId:o,target:t,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function f(e){try{return e()}catch{return null}}function p(t){let n={scope:t.scope,editorId:t.editorId,configPath:t.configPath},c=o(t.target,t.cwd,t.home,t.configPathOverride);if(c===null)return{...n,outcome:`no-entry`};if(t.target.format===`file`){if(a(c))return{...n,outcome:`canonical`}}else{let a=e(c);if(a.kind===`recognized`&&a.disposition===`keep`){let e=s(c,i(t.target,t.cwd));if(e.length===0)return{...n,outcome:`canonical`};let a=m(t,n,r(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0,pruneOnly:!0},t.home,t.configPathOverride));return(a.outcome===`repaired`||a.outcome===`canonical`)&&t.logger({event:a.outcome===`repaired`?`mcp-config-repair-pruned`:`mcp-config-repair-prune-unchanged`,severity:a.outcome===`repaired`?`info`:`warn`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,keys:e}),a.outcome===`canonical`?{...n,outcome:`prune-unchanged`}:a}if(a.kind===`declined`&&t.scope===`project`)return t.logger({event:`mcp-config-repair-skipped-foreign`,severity:`info`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:a.reason}),{...n,outcome:`foreign`,reason:a.reason}}return t.logger({...l({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:c}),severity:`info`}),m(t,n,r(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride))}function m(e,t,n){if(n.action===`failed`){let r=n.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:r}),{...t,outcome:`write-failed`,error:r}}return n.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:n.declineReason}),{...t,outcome:`declined`,reason:n.declineReason}):n.action===`skipped-flag`?{...t,outcome:`canonical`}:{...t,outcome:`repaired`}}function h(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{u as n,d as repairMcpConfigs,l as t};
1
+ import{E as e}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Y as t,Z as n,b as r,et as i,it as a,p as o,tt as s}from"./init-DIAKdBV0.mjs";import{homedir as c}from"node:os";function l(e){let{priorCommand:t,priorArgs:n}=u(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function u(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function d(e){let r=e.logger??h,i=e.home??c(),a=[];if(e.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of t){let t=n[o],s=f(()=>t.configPath(``,i));if(s!==null&&a.push(p({scope:`user`,editorId:o,target:t,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),t.projectConfigPath){let n=t.projectConfigPath,i=f(()=>n(e.projectDir));i!==null&&a.push(p({scope:`project`,editorId:o,target:t,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function f(e){try{return e()}catch{return null}}function p(t){let n={scope:t.scope,editorId:t.editorId,configPath:t.configPath},c=o(t.target,t.cwd,t.home,t.configPathOverride);if(c===null)return{...n,outcome:`no-entry`};if(t.target.format===`file`){if(a(c))return{...n,outcome:`canonical`}}else{let a=e(c);if(a.kind===`recognized`&&a.disposition===`keep`){let e=s(c,i(t.target,t.cwd));if(e.length===0)return{...n,outcome:`canonical`};let a=m(t,n,r(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0,pruneOnly:!0},t.home,t.configPathOverride));return(a.outcome===`repaired`||a.outcome===`canonical`)&&t.logger({event:a.outcome===`repaired`?`mcp-config-repair-pruned`:`mcp-config-repair-prune-unchanged`,severity:a.outcome===`repaired`?`info`:`warn`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,keys:e}),a.outcome===`canonical`?{...n,outcome:`prune-unchanged`}:a}if(a.kind===`declined`&&t.scope===`project`)return t.logger({event:`mcp-config-repair-skipped-foreign`,severity:`info`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:a.reason}),{...n,outcome:`foreign`,reason:a.reason}}return t.logger({...l({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:c}),severity:`info`}),m(t,n,r(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride))}function m(e,t,n){if(n.action===`failed`){let r=n.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:r}),{...t,outcome:`write-failed`,error:r}}return n.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:n.declineReason}),{...t,outcome:`declined`,reason:n.declineReason}):n.action===`skipped-flag`?{...t,outcome:`canonical`}:{...t,outcome:`repaired`}}function h(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{u as n,d as repairMcpConfigs,l as t};
@@ -0,0 +1 @@
1
+ import"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import"./src-CV7s8o8N.mjs";import"./init-DIAKdBV0.mjs";import"./registry-probes-DjoTkaRp.mjs";import"./start-WZZeXyQg.mjs";import{n as e}from"./loader-CnGe_Flu.mjs";import"./preview-c3qAKdkh.mjs";import"./repair-mcp-configs-Du599MHw.mjs";export{e as loadConfig};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as t,$u as n,Bf as r,Bl as i,Ca as a,Ef as o,Ff as s,G as c,If as l,Jc as u,Mf as d,Sa as f,Tf as p,U as m,Vl as h,W as g,Yc as _,bf as v,el as y,jf as b,kf as x,l as S,u as ee}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Co as C,Di as w,Ei as T,Gi as E,Mt as D,Ra as O,Rs as k,Ti as A,Uo as j,Zt as te,_s as M,fi as N,fr as ne,ga as re,gr as ie,hs as P,ki as ae,m as oe,nr as F,qi as se,ra as ce,ri as le,vs as ue,ya as de,yi as fe,ys as pe}from"./dist-0gI1oLbO.mjs";import{t as me}from"./yazl-BBz29IQN.mjs";import{ct as he,gt as ge,ht as _e,mt as ve,pt as ye,st as be,wt as xe}from"./init-DRDwcEOj.mjs";import{T as Se,l as Ce,u as we}from"./registry-probes-5d1sNdrt.mjs";import{c as Te}from"./colors-r_owlCuY.mjs";import{t as Ee}from"./is-object-BGze3w87.mjs";import{n as De}from"./constants-DKjIJ8BH.mjs";import"./loader-C4IPKtMB.mjs";import"./preview-CbulwVyu.mjs";import{execFile as Oe,execSync as ke,spawnSync as Ae}from"node:child_process";import{basename as I,dirname as L,isAbsolute as je,join as R,relative as Me,resolve as z,sep as B,win32 as Ne}from"node:path";import{closeSync as Pe,cpSync as Fe,createWriteStream as Ie,existsSync as V,lstatSync as Le,mkdirSync as H,mkdtempSync as Re,openSync as ze,readFileSync as U,readSync as Be,readdirSync as W,readlinkSync as Ve,realpathSync as He,rmSync as G,rmdirSync as Ue,statSync as We,writeFileSync as K}from"node:fs";import{arch as Ge,freemem as Ke,homedir as q,hostname as qe,platform as Je,release as Ye,tmpdir as Xe,totalmem as Ze,type as Qe,uptime as $e}from"node:os";import{readFile as et,readdir as tt,stat as nt}from"node:fs/promises";import{createHash as rt}from"node:crypto";function it(e,t){let n=t.map(e=>[k(e),e]);for(let t of e){let e=k(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function at(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=it([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=it(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function ot(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const st=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function ct(e,t,n=ie){if(e!==void 0&&!st.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let lt=null;function ut(e){lt=e}function dt(){return lt??process.cwd()}const ft=`Open Knowledge`;function pt(e={}){let t=e.platformName??process.platform,n=e.productName??d().productName;return be(t).join(he({...e,platformName:t}),n)}function mt(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=be(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`${d().packageName.replaceAll(`/`,``)}-updater`)}function ht(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function gt(e){let t=R(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return ht(n)??[]}function _t(e){let t=R(e,`state.json`);if(!V(t))return!1;try{return ht(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const vt=8192;function yt(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function bt(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const xt=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function St(e){return e.replace(xt,`$1"[REDACTED-DEVICE-ID]"`)}function Ct(e){return St(bt(e))}const wt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Tt(e){if(typeof e!=`string`)return null;let t=wt.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function Et(e){let t=ze(e,`r`);try{let e=Buffer.alloc(vt),n=0,r=!1;for(;n<vt;){let i=Be(t,e,n,vt-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{Pe(t)}}function Dt(e){try{let t=Et(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:Tt(a)}}catch{return{kind:`unreadable`}}}function Ot(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function kt(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=W(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=R(e,t.name),r;try{r=We(n).mtimeMs}catch{continue}if(r<i)continue;let c=Dt(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Ot(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}const At=`state/os-termination-evidence.json`,jt=6048e5,Mt=/openknowledge/i,Nt=x.map(e=>l(o[e]));function Pt(e={}){return(t,n)=>new Promise(r=>{try{Oe(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...Ft(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function Ft(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function It(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
1
+ import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as t,$u as n,Bf as r,Bl as i,Ca as a,Ef as o,Ff as s,G as c,If as l,Jc as u,Mf as d,Sa as f,Tf as p,U as m,Vl as h,W as g,Yc as _,bf as v,el as y,jf as b,kf as x,l as S,u as ee}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Co as C,Di as w,Ei as T,Gi as E,Mt as D,Ra as O,Rs as k,Ti as A,Uo as j,Zt as te,_s as M,fi as N,fr as ne,ga as re,gr as ie,hs as P,ki as ae,m as oe,nr as F,qi as se,ra as ce,ri as le,vs as ue,ya as de,yi as fe,ys as pe}from"./dist-0gI1oLbO.mjs";import{t as me}from"./yazl-BBz29IQN.mjs";import{ct as he,gt as ge,ht as _e,mt as ve,pt as ye,st as be,wt as xe}from"./init-DIAKdBV0.mjs";import{T as Se,l as Ce,u as we}from"./registry-probes-DjoTkaRp.mjs";import{c as Te}from"./colors-r_owlCuY.mjs";import{t as Ee}from"./is-object-BGze3w87.mjs";import{n as De}from"./constants-BHRHFiiA.mjs";import"./loader-CnGe_Flu.mjs";import"./preview-c3qAKdkh.mjs";import{execFile as Oe,execSync as ke,spawnSync as Ae}from"node:child_process";import{basename as I,dirname as L,isAbsolute as je,join as R,relative as Me,resolve as z,sep as B,win32 as Ne}from"node:path";import{closeSync as Pe,cpSync as Fe,createWriteStream as Ie,existsSync as V,lstatSync as Le,mkdirSync as H,mkdtempSync as Re,openSync as ze,readFileSync as U,readSync as Be,readdirSync as W,readlinkSync as Ve,realpathSync as He,rmSync as G,rmdirSync as Ue,statSync as We,writeFileSync as K}from"node:fs";import{arch as Ge,freemem as Ke,homedir as q,hostname as qe,platform as Je,release as Ye,tmpdir as Xe,totalmem as Ze,type as Qe,uptime as $e}from"node:os";import{readFile as et,readdir as tt,stat as nt}from"node:fs/promises";import{createHash as rt}from"node:crypto";function it(e,t){let n=t.map(e=>[k(e),e]);for(let t of e){let e=k(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function at(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=it([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=it(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function ot(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const st=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function ct(e,t,n=ie){if(e!==void 0&&!st.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let lt=null;function ut(e){lt=e}function dt(){return lt??process.cwd()}const ft=`Open Knowledge`;function pt(e={}){let t=e.platformName??process.platform,n=e.productName??d().productName;return be(t).join(he({...e,platformName:t}),n)}function mt(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=be(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`${d().packageName.replaceAll(`/`,``)}-updater`)}function ht(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function gt(e){let t=R(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return ht(n)??[]}function _t(e){let t=R(e,`state.json`);if(!V(t))return!1;try{return ht(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const vt=8192;function yt(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function bt(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const xt=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function St(e){return e.replace(xt,`$1"[REDACTED-DEVICE-ID]"`)}function Ct(e){return St(bt(e))}const wt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Tt(e){if(typeof e!=`string`)return null;let t=wt.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function Et(e){let t=ze(e,`r`);try{let e=Buffer.alloc(vt),n=0,r=!1;for(;n<vt;){let i=Be(t,e,n,vt-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{Pe(t)}}function Dt(e){try{let t=Et(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:Tt(a)}}catch{return{kind:`unreadable`}}}function Ot(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function kt(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=W(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=R(e,t.name),r;try{r=We(n).mtimeMs}catch{continue}if(r<i)continue;let c=Dt(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Ot(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}const At=`state/os-termination-evidence.json`,jt=6048e5,Mt=/openknowledge/i,Nt=x.map(e=>l(o[e]));function Pt(e={}){return(t,n)=>new Promise(r=>{try{Oe(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...Ft(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function Ft(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function It(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
2
2
  `)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function J(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function Lt(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function Rt(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function zt(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Bt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Vt(e,t){let n=t.indexOf(`
3
3
  `);if(n===-1)return null;let r,i;try{r=Bt(JSON.parse(t.slice(0,n))),i=Bt(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=Bt(e);t===null||typeof t.name!=`string`||!Ot(t.name)||a.push({name:t.name,pid:zt(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:zt(t.rpages),lifetimeMaxPages:zt(t.lifetimeMax)})}let o=Tt(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:zt(Bt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?Ot(i.largestProcess):null,ownedProcesses:a}}const Ht=/^JetsamEvent-.*\.ips$/;function Ut(e,t,n,r){let i=e.flatMap(({file:e,mtimeMs:n})=>n!==null&&n>=t?[{file:e,mtimeMs:n}]:[]);return i.sort((e,t)=>r===`newest-first`?t.mtimeMs-e.mtimeMs:e.mtimeMs-t.mtimeMs),{files:i.slice(0,n).map(({file:e})=>e),statFailed:e.filter(({mtimeMs:e})=>e===null).length,droppedOverCap:Math.max(0,i.length-n)}}async function Wt(e,t){let n=J(`darwin`,`macos-jetsam`,[R(e,`JetsamEvent-*.ips`)]),r;try{r=await tt(e)}catch(e){return Lt(n,e.code??`unknown`)}let i=Ut(await Promise.all(r.filter(e=>Ht.test(e)).map(async t=>{try{return{file:t,mtimeMs:(await nt(R(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-jt,50,`newest-first`);n.unparseable+=i.statFailed,n.droppedOverCap=i.droppedOverCap;for(let t of i.files){let r=null;try{r=Vt(t,await et(R(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return Rt(n)}const Gt=[`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Out of memory|oom-kill|Killed process|Killed /|memory pressure`,`_TRANSPORT=kernel`,`+`,`_SYSTEMD_UNIT=systemd-oomd.service`],Kt=[`--user`,`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Fatal Wayland communication error|Wayland protocol error|X IO error|Missing X server`],qt=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/,Jt=/\[(\d+)(?::\d+)?:\d{4}\/\d{6}\.\d+:[A-Z0-9]+:[^\]]*\]\s*(.*)$/,Yt=/^desktop\.\d{4}-\d{2}-\d{2}\.log$/;async function Xt(e,t){let n=new Set,r;try{r=await tt(e)}catch{return{pids:n,unreadable:!0}}let i=!1;for(let a of r){if(!Yt.test(a))continue;let r=R(e,a);try{if(t.getTime()-(await nt(r)).mtimeMs>jt)continue;for(let e of(await et(r,`utf8`)).split(`
4
4
  `)){if(!e.includes(`"event":"desktop.boot"`))continue;let t=/"pid":(\d+)/.exec(e)?.[1];t!==void 0&&n.add(Number(t))}}catch{i=!0}}return{pids:n,unreadable:i}}function Zt(e,t){if(e===`systemd-oomd`){let e=/^Killed (\S+)/.exec(t);if(e===null)return null;let n=e[1]?.split(`/`).pop()??``;return{origin:`systemd-oomd`,action:`oomd-kill`,pid:null,processName:null,unit:Mt.test(n)?n:null,trigger:/swap used/.test(t)?`swap`:/memory pressure/.test(t)?`memory-pressure`:null}}if(e!==`kernel`)return null;let n=/Killed process (\d+) \(([^)]+)\)/.exec(t);if(n!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(n[1]),processName:n[2]??null,unit:null,trigger:null};let r=/task=([^,]+),pid=(\d+)/.exec(t);if(r!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(r[2]),processName:r[1]??null,unit:null,trigger:null};let i=/^(\S+) invoked oom-killer/.exec(t);return i===null?null:{origin:`kernel`,action:`oom-invoked`,pid:null,processName:i[1]??null,unit:null,trigger:null}}function Qt(e){let t=[],n=0,r=0;for(let i of e.split(`
@@ -0,0 +1 @@
1
+ import{S as e,m as t,p as n,r}from"./start-WZZeXyQg.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
@@ -1,5 +1,5 @@
1
- import{C as e,Cl as t,I as n,Q as r,Z as i,i as a,jf as o,yd as s}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Ai as c,As as l,Ti as u,Wi as d,_s as f,k as p,pi as m,ys as h}from"./dist-0gI1oLbO.mjs";import{B as g,Et as _,R as v,Tt as y,Z as b,b as x,dt as S,wt as C,x as w}from"./init-DRDwcEOj.mjs";import{C as T,a as E,c as ee,d as D,g as O,h as k,i as A,m as j,n as M,o as N,r as P,s as F,t as I}from"./registry-probes-5d1sNdrt.mjs";import{n as te}from"./constants-DKjIJ8BH.mjs";import{execFileSync as L,spawn as R}from"node:child_process";import{basename as z,dirname as B,resolve as V}from"node:path";import{existsSync as H,realpathSync as ne}from"node:fs";import{homedir as re,tmpdir as ie}from"node:os";import{rm as ae}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";const se=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ce={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function le(e,t={}){let{login:n}=t,r=t._exec??L,i=U(t._fileExists??H),a=e?[`--hostname`,e]:[];if(n){let e=W(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=W(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function U(e){return[`gh`,...se.filter(e)]}function W(e,t,n){for(let r of t)try{let t=e(r,n,ce).toString().trim();if(t.length>0)return t}catch{}}function ue(e,t={}){let n=t._exec??L,r=U(t._fileExists??H),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=W(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=de(a,e);if(t)return t}let o=W(n,r,i);if(o!==void 0){let e=ge(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function de(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const fe=/Logged in to \S+ account (\S+) \(/,pe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,me=/^\s*-\s*Active account:\s*true\s*$/,he=/\u001b\[[0-9;]*m/g;function ge(e){let t=[],n;for(let r of e.split(`
2
- `)){let e=r.replace(he,``),i=fe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(pe.test(e)){n=void 0;continue}n&&me.test(e)&&(n.active=!0)}return t}const _e={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){l(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ve(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function ye(e,t,n,r,i){let a=b[e];try{let o=N(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ve(o.kind)}catch(i){return l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function be(e,t,n){if(b[e].scope!==`global`)return q();if(n===`absent`)return ye(e,``,t.home,void 0,t.env);let r=(await w({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function xe(e,t,n){let r=b[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ye(e,t.cwd,t.home,r,t.env);let i=x(b[e],t.cwd,_e,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Se(e,t,n){let r=t.home??re();if(n===`absent`){let t=P(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Ce(e,t,n){if(n===`absent`){let n=v(b[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=g(b[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function we(e){return t=>{if(t.pathId===void 0)return Y();let n=s(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return be(n.editor,e,t.desired);case`editor-project-config`:return xe(n.editor,e,t.desired);case`editor-project-skill-root`:return Ce(n.editor,e,t.desired);case`editor-user-skill-root`:return Se(n.editor,e,t.desired)}}}function Te(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Ee(e){if(e===`server`)return e;throw new y(`--only must be 'server'`)}function De(e=H,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[V(t,`public`),V(t,`../../app/dist`),V(t,`../../../app/dist`)];return e(V(t,`../../app.asar`))&&n.push(V(t,`../../app`)),n.find(t=>e(t))}function Oe(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function ke(e){if(e===`off`)return`off`;if(!t.test(e))throw new y(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function Ae(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function je(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Me(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||Ae(e.host))&&e.isTTY}function Ne(e,t){let n;try{n=new URL(t)}catch{throw new y(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new y(`${e} must be an http(s) origin (got: ${t})`);return t}function Pe(e){return Ne(`--external-url`,e)}function Fe(e){let t=z(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super(`This directory isn't set up yet. Run \`${o()} init\` first, then \`${o()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${o()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?V(e):null}},a=V(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(B(a));o=e===null?null:V(e,z(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&B(o)===s&&z(o).startsWith(`ok-ephemeral-`)}function Ie(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Le(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function $(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-_mI3Jjf-.mjs`),x=e.log??g(`start`),C=e.singleFile!==void 0,w=C?d(e.singleFile).canonicalFilePath:void 0,E=w?u(w):void 0,D=w?l(w):void 0,O,k=!1;if(E!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Q(O))throw new Z(O);o(f(O,`.ok`,`config.yml`))||y(O,E)}else O=h(E),k=!0}let j=async()=>{if(!(!k||O===void 0)){if(!Q(O)){x.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(O,{recursive:!0,force:!0})}catch(e){x.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},N=O;if(!C){if(!i&&!m(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?x.debug({event:e},`[start] reclaim sweep event`):x.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-F5gZqTRO.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&x.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){x.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-loOJnWcB.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){x.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),x.info({contentDir:P},`Created content directory`));let te=T(),L=c(),R;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&x.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}R=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:ue,tokenStore:te,embeddingsKeyStore:L,mcpTomlEditor:S(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>M(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>F(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:re(),env:process.env};return{probe:I(e),execute:we(e),userSkillPresentAnywhere:A}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Le(N===void 0?n:Ie(n,N),{log:x,exit:e.idleExit})},log:x,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let z=R.destroy,B=k?async()=>{try{await z()}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:P,port:R.port,ready:R.ready,degraded:R.degraded}}function Re(e,t,n=()=>f({absPath:h(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function ze(e){if(e===`browser`||e===`app`)return e;throw new y(`--mode must be 'browser' or 'app'`)}function Be(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Ve(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function He(t,o){let s=Re(t,o.singleFile),c=Be(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Fe(m);let h;try{h=i(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=e(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);je({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(e(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
1
+ import{C as e,Cl as t,I as n,Q as r,Z as i,i as a,jf as o,yd as s}from"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";import{Ai as c,As as l,Ti as u,Wi as d,_s as f,k as p,pi as m,ys as h}from"./dist-0gI1oLbO.mjs";import{B as g,Et as _,R as v,Tt as y,Z as b,b as x,dt as S,wt as C,x as w}from"./init-DIAKdBV0.mjs";import{C as T,a as E,c as ee,d as D,g as O,h as k,i as A,m as j,n as M,o as N,r as P,s as F,t as I}from"./registry-probes-DjoTkaRp.mjs";import{n as te}from"./constants-BHRHFiiA.mjs";import{execFileSync as L,spawn as R}from"node:child_process";import{basename as z,dirname as B,resolve as V}from"node:path";import{existsSync as H,realpathSync as ne}from"node:fs";import{homedir as re,tmpdir as ie}from"node:os";import{rm as ae}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";const se=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ce={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function le(e,t={}){let{login:n}=t,r=t._exec??L,i=U(t._fileExists??H),a=e?[`--hostname`,e]:[];if(n){let e=W(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=W(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function U(e){return[`gh`,...se.filter(e)]}function W(e,t,n){for(let r of t)try{let t=e(r,n,ce).toString().trim();if(t.length>0)return t}catch{}}function ue(e,t={}){let n=t._exec??L,r=U(t._fileExists??H),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=W(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=de(a,e);if(t)return t}let o=W(n,r,i);if(o!==void 0){let e=ge(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function de(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const fe=/Logged in to \S+ account (\S+) \(/,pe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,me=/^\s*-\s*Active account:\s*true\s*$/,he=/\u001b\[[0-9;]*m/g;function ge(e){let t=[],n;for(let r of e.split(`
2
+ `)){let e=r.replace(he,``),i=fe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(pe.test(e)){n=void 0;continue}n&&me.test(e)&&(n.active=!0)}return t}const _e={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){l(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ve(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function ye(e,t,n,r,i){let a=b[e];try{let o=N(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ve(o.kind)}catch(i){return l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function be(e,t,n){if(b[e].scope!==`global`)return q();if(n===`absent`)return ye(e,``,t.home,void 0,t.env);let r=(await w({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function xe(e,t,n){let r=b[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ye(e,t.cwd,t.home,r,t.env);let i=x(b[e],t.cwd,_e,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Se(e,t,n){let r=t.home??re();if(n===`absent`){let t=P(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Ce(e,t,n){if(n===`absent`){let n=v(b[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=g(b[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function we(e){return t=>{if(t.pathId===void 0)return Y();let n=s(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return be(n.editor,e,t.desired);case`editor-project-config`:return xe(n.editor,e,t.desired);case`editor-project-skill-root`:return Ce(n.editor,e,t.desired);case`editor-user-skill-root`:return Se(n.editor,e,t.desired)}}}function Te(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Ee(e){if(e===`server`)return e;throw new y(`--only must be 'server'`)}function De(e=H,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[V(t,`public`),V(t,`../../app/dist`),V(t,`../../../app/dist`)];return e(V(t,`../../app.asar`))&&n.push(V(t,`../../app`)),n.find(t=>e(t))}function Oe(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function ke(e){if(e===`off`)return`off`;if(!t.test(e))throw new y(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function Ae(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function je(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Me(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||Ae(e.host))&&e.isTTY}function Ne(e,t){let n;try{n=new URL(t)}catch{throw new y(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new y(`${e} must be an http(s) origin (got: ${t})`);return t}function Pe(e){return Ne(`--external-url`,e)}function Fe(e){let t=z(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super(`This directory isn't set up yet. Run \`${o()} init\` first, then \`${o()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${o()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?V(e):null}},a=V(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(B(a));o=e===null?null:V(e,z(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&B(o)===s&&z(o).startsWith(`ok-ephemeral-`)}function Ie(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Le(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function $(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-_mI3Jjf-.mjs`),x=e.log??g(`start`),C=e.singleFile!==void 0,w=C?d(e.singleFile).canonicalFilePath:void 0,E=w?u(w):void 0,D=w?l(w):void 0,O,k=!1;if(E!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Q(O))throw new Z(O);o(f(O,`.ok`,`config.yml`))||y(O,E)}else O=h(E),k=!0}let j=async()=>{if(!(!k||O===void 0)){if(!Q(O)){x.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(O,{recursive:!0,force:!0})}catch(e){x.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},N=O;if(!C){if(!i&&!m(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?x.debug({event:e},`[start] reclaim sweep event`):x.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-Du599MHw.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&x.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){x.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-BLLbBwuS.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){x.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),x.info({contentDir:P},`Created content directory`));let te=T(),L=c(),R;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&x.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}R=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:ue,tokenStore:te,embeddingsKeyStore:L,mcpTomlEditor:S(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>M(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>F(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:re(),env:process.env};return{probe:I(e),execute:we(e),userSkillPresentAnywhere:A}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Le(N===void 0?n:Ie(n,N),{log:x,exit:e.idleExit})},log:x,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let z=R.destroy,B=k?async()=>{try{await z()}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:P,port:R.port,ready:R.ready,degraded:R.degraded}}function Re(e,t,n=()=>f({absPath:h(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function ze(e){if(e===`browser`||e===`app`)return e;throw new y(`--mode must be 'browser' or 'app'`)}function Be(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Ve(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function He(t,o){let s=Re(t,o.singleFile),c=Be(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Fe(m);let h;try{h=i(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=e(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);je({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(e(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
3
3
  `)))}let ee=o.port===void 0?void 0:Number(o.port),D=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=ee??D??s.server?.port,k=Oe({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:De}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await $({config:s,cwd:m,host:C,port:O,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:n(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{},...o.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-_mI3Jjf-.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(f(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(f(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(f(e.message)),process.exit(1)),Ge(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await Ue({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>oe(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=We(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=Ke(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let M=!1,N=async e=>{if(M)return;M=!0;let[t,...n]=Ve(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await j.destroy(`external-signal`)}catch(e){console.error(`${f(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{N(`SIGINT`)}),process.once(`SIGTERM`,()=>{N(`SIGTERM`)});let P=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${j.port}`,F=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,I=P;console.log(l({name:`open-knowledge`,version:te,localUrl:I,networkUrl:F,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let L={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};j.ready.then(async()=>{if(j.degraded.length>0){console.log();for(let e of j.degraded){let t=L[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(Me({openBrowser:o.openBrowser!==!1&&E.openBrowser,explicitOn:o.openBrowser!==!1&&g.server?.openBrowser===!0,host:C,isTTY:process.stdout.isTTY===!0,ephemeral:o.singleFile!==void 0,only:o.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-3bURxjbo.mjs`);e(I)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function Ue(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:u(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function We(e){return[`${e.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${e.pid}).`,` ${e.url}`,`Leaving it running — run \`${o()} stop\` first if you want a fresh server.`]}function Ge(e,t,n){let r=t.ServerLockCollisionError;if(r!==void 0&&e instanceof r)return!0;let i=t.ServerAuthorityCollisionError;if(i===void 0||!(e instanceof i))return!1;try{return e.existing.scope.kind===`tree`&&ne.native(n)===e.existing.projectDir}catch{return!1}}function Ke(e,t,n){let r=n.ServerAuthorityCollisionError;if(r!==void 0&&e instanceof r)return e.message;let i=n.ServerAuthorityRegistryError;if(i!==void 0&&e instanceof i)return e.message;let a=n.ProcessLockFileError;if(a!==void 0&&e instanceof a)return e.message;let s=n.ServerLockCollisionError;if(s===void 0||!(e instanceof s))return null;try{let e=n.readServerLock(n.resolveLockDir(t)),r=o();return e?.kind===`mcp-spawned`?`An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run \`${r} stop\`.`:`OpenKnowledge server is already running on this project — check \`${r} status\` or \`${r} stop\`.`}catch{return null}}function qe(e){return new C(`start`).description(`Start the OpenKnowledge server (UI + API + MCP + collab on one port)`).option(`-p, --port <port>`,`Server port`,void 0).option(`--bind <address>`,`Bind address (repeatable; default 127.0.0.1 — loopback only)`,(e,t)=>[...t??[],e]).option(`--no-open-browser`,`Do not open the browser after start (interactive loopback starts open it by default)`).option(`--only <module>`,`Serve one module: 'server' (API + MCP only, no shell or browser)`,Ee).option(`--idle-shutdown <duration>`,`Shut the server down after this long with no connected clients ('off', or a duration like 90s, 30m, 2h; default 30m)`,ke).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ze).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path>`).addOption(new _(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new _(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new _(`--terminal-auth`,`Tell in-app agents that this server's client can run terminal sign-ins (the desktop app passes it when it has a terminal)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,Pe).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
4
4
  `),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
5
5
  `),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=j(D());if(n.available){k({spawn:R},n);return}console.error(O(n.reason)),process.exit(1)}await He(n,t)})}export{Ke as C,ue as D,le as E,qe as S,Le as T,Be as _,We as a,Me as b,Q as c,ke as d,Ee as f,Re as g,Ue as h,Fe as i,Ge as l,Te as m,X as n,Ve as o,De as p,$ as r,Ae as s,Z as t,Pe as u,Oe as v,Ie as w,je as x,He as y};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/open-knowledge",
3
- "version": "0.87.0-beta.0",
3
+ "version": "0.87.0-beta.2",
4
4
  "description": "Local-first, agent-friendly Markdown knowledge base with a cross-platform CLI and web editor",
5
5
  "keywords": [
6
6
  "knowledge-base",
@@ -65,10 +65,10 @@
65
65
  "@parcel/watcher": "^2.5.6"
66
66
  },
67
67
  "devDependencies": {
68
- "@inkeep/open-knowledge-app": "0.87.0-beta.0",
69
- "@inkeep/open-knowledge-core": "0.87.0-beta.0",
68
+ "@inkeep/open-knowledge-app": "0.87.0-beta.2",
69
+ "@inkeep/open-knowledge-core": "0.87.0-beta.2",
70
70
  "@inkeep/open-knowledge-native-config": "0.0.0",
71
- "@inkeep/open-knowledge-server": "0.87.0-beta.0",
71
+ "@inkeep/open-knowledge-server": "0.87.0-beta.2",
72
72
  "@types/node": "^24.7.0",
73
73
  "@types/proper-lockfile": "^4.1.4",
74
74
  "@types/yazl": "^3.3.1",
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-I7NmBKjQ.mjs";var e=`0.87.0-beta.0`;const t=`config.yml`,n=e;export{n,t};
@@ -1 +0,0 @@
1
- import"./dist-0gI1oLbO.mjs";import{v as e}from"./init-DRDwcEOj.mjs";export{e as runInit};
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-C4IPKtMB.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-CbulwVyu.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +0,0 @@
1
- import{t as e}from"./index-Co3uFj5v.js";export{e as FeedbackForm};
@@ -1 +0,0 @@
1
- import{t as e}from"./ManagedArtifactProperties-S7GjNV3d.js";export{e as ManagedArtifactProperties};
@@ -1,2 +0,0 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./AgentIconCluster-DYP1yNXm.js";import{i as s,n as c,t as l}from"./tooltip-Bz6z4_se.js";import{t as u}from"./button-DzgjsZzC.js";import{n as d}from"./dist-BGzUo_18.js";import{c as f}from"./documents-events-ddyuXdQl.js";import{n as p}from"./constants-editors-DmmORwNP.js";import{n as m,r as h,t as g}from"./skill-targets-schema-D6kA7J61.js";import{t as _}from"./createLucideIcon-DdBzwsHe.js";import{a as v,f as y,i as b,m as x,n as S,o as C,p as w,u as T}from"./dropdown-menu-5XqyQTVx.js";import{t as E}from"./folder-QqUoFRPR.js";import"./constants-skills-BLHVRW90.js";import{i as ee,l as te,n as D,r as O}from"./skill-scope-DOTLd4gL.js";import{a as k,c as A,i as j,l as M,n as N,o as P,s as F,u as I}from"./context-menu-B5MxEep2.js";import{F as L,S as ne,j as R,x as z}from"./skills-api-CCijBzjo.js";import{t as B}from"./use-skills-CkvdjORj.js";import{t as V}from"./ChangedOutsideBadge-BfH3veLO.js";var H=_(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),U=e(n(),1),W=a(),G=t();function K(e){let t=(0,W.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({menuKind:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=n===`context`?(0,G.jsx)(j,{...r}):(0,G.jsx)(b,{...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function re(e){let t=(0,W.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({menuKind:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=n===`context`?(0,G.jsx)(k,{...r}):(0,G.jsx)(v,{...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function ie(e){let t=(0,W.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({menuKind:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=n===`context`?(0,G.jsx)(N,{...r}):(0,G.jsx)(S,{...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function ae(e){let t=(0,W.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({menuKind:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=n===`context`?(0,G.jsx)(P,{...r}):(0,G.jsx)(C,{...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function oe(e){let t=(0,W.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({menuKind:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=n===`context`?(0,G.jsx)(F,{...r}):(0,G.jsx)(T,{...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function se(e){let t=(0,W.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({menuKind:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=n===`context`?(0,G.jsx)(A,{...r}):(0,G.jsx)(y,{...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function ce(e){let t=(0,W.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({menuKind:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=n===`context`?(0,G.jsx)(M,{...r}):(0,G.jsx)(w,{...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function le(e){let t=(0,W.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({menuKind:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=n===`context`?(0,G.jsx)(I,{...r}):(0,G.jsx)(x,{...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}var q=Object.freeze({hosts:null,source:null}),J=new Map,Y=new Map;function X(e,t){return`${e}:${t}`}function Z(e){return J.get(e)??q}function ue(e,t){let n=Y.get(e)??new Set;return Y.set(e,n),n.add(t),()=>{n.delete(t),n.size===0&&Y.delete(e)}}function Q(e,t){let n=Z(e),r={...n,...t};if(!(r.hosts===n.hosts&&r.source===n.source)){r.hosts===null&&r.source===null?J.delete(e):J.set(e,r);for(let t of Y.get(e)??[])t()}}var de=g.options,fe=m.options,pe=`.agents/`;function me({skill:e,allSkills:t,hostSet:n,sourceHostOverlay:r,linkMode:i}){let a=t=>e?`${te(t,e.scope)}/${e.name}`:null,o=e?.hubOffered??(e&&t!==null?t.find(t=>t.scope===e.scope)?.hubOffered:void 0),s=e!==void 0&&(o===!0||(e.hosts??[]).includes(`agents`)||t?.some(t=>t.scope===e.scope&&(t.hosts.includes(`agents`)||t.path.startsWith(pe)))),c=e?.hostAliases??(e&&t!==null?Object.assign({},...t.filter(t=>t.scope===e.scope).map(e=>e.hostAliases??{})):{}),l=e?.installableEditors??(e&&t!==null?t.find(t=>t.scope===e.scope)?.installableEditors:void 0),u=l?new Set(l):null,d=e?.scope===`global`?fe:de,f=(s?[...d,`agents`]:d).filter(e=>!(e in c)).filter(e=>e===`agents`||u===null||u.has(e)||n.has(e)),p=new Set(f.map(e=>a(e))),m=e?.scope===`global`?`~/`:``,h=e?.path?.includes(`/`)?`${m}${e.path.replace(/\/SKILL\.mdx?$/i,``)}`:null,g=h!==null&&!p.has(h)?h:null,_=g===null?r??e?.hosts?.[0]:void 0,v=new Set(e?.conflictHosts??[]),y=new Set(e?.driftPaths??[]),b=new Set(e?.symlinkedHosts??[]),x=[...[...n].filter(e=>e!==_&&!(e in c)&&!v.has(e)&&!e.includes(`/`)).map(e=>({target:e,display:a(e)??e,mode:b.has(e)?`link`:`copy`})),...(e?.customPlacements??[]).map(e=>({target:O(e),display:`${m}${e.path}`,mode:e.mode}))],S=x.map(e=>e.mode),C=S.filter(e=>e===`link`).length,w=S.length===0?i?`link`:`copy`:C*2>=S.length?`link`:`copy`,T=new Map((e?.customPlacements??[]).map(e=>[O(e),e])),E=new Set(T.keys());if(t!==null&&e){for(let n of t)if(n.scope===e.scope)for(let e of n.customPlacements??[]){let t=O(e);t!==``&&E.add(t)}}return{pathFor:a,aliases:c,rows:f,sourceRow:g,sourceHost:_,conflicted:v,drifted:y,linked:b,expectedMode:w,convertible:x,customRootRows:e===void 0?[]:[...E].sort().map(t=>({root:t,display:`${m}${t}/${e.name}`,placed:T.get(t)??null})).filter(e=>!p.has(e.display)&&e.display!==h&&!(e.root in c))}}var he=`min-w-[24rem]`;function ge(e,t){let n=(0,W.c)(45),r=t.installingName===e.name,i=(0,U.useRef)(e),[a,o]=(0,U.useState)(!1),s=(0,U.useRef)(!1),c,l;n[0]===r?(c=n[1],l=n[2]):(c=()=>{s.current&&!r&&o(!0),s.current=r},l=[r],n[0]=r,n[1]=c,n[2]=l),(0,U.useEffect)(c,l);let u,f;n[3]===e?(u=n[4],f=n[5]):(u=()=>{e!==i.current&&(i.current=e,o(!1))},f=[e],n[3]=e,n[4]=u,n[5]=f),(0,U.useEffect)(u,f);let p=r||a,m;n[6]!==e.name||n[7]!==e.scope?(m=X(e.scope,e.name),n[6]=e.name,n[7]=e.scope,n[8]=m):m=n[8];let g=m,_,v;n[9]===g?(_=n[10],v=n[11]):(_=e=>ue(g,e),v=()=>Z(g),n[9]=g,n[10]=_,n[11]=v);let y=(0,U.useSyncExternalStore)(_,v),b=y.hosts,x=y.source,S,C;n[12]!==x||n[13]!==g||n[14]!==e.hosts?(S=()=>{x!==null&&e.hosts[0]===x&&Q(g,{source:null})},C=[e.hosts,x,g],n[12]=x,n[13]=g,n[14]=e.hosts,n[15]=S,n[16]=C):(S=n[15],C=n[16]),(0,U.useEffect)(S,C);let w=e.linkMode===!0,T=b??e.hosts,E;n[17]===T?E=n[18]:(E=new Set(T),n[17]=T,n[18]=E);let ee=E,te=b?b.length>0:e.installed,D=(0,U.useRef)(e.hosts),O,k;n[19]!==b||n[20]!==e.hosts?(O=()=>{b===null&&(D.current=e.hosts)},k=[b,e.hosts],n[19]=b,n[20]=e.hosts,n[21]=O,n[22]=k):(O=n[21],k=n[22]),(0,U.useEffect)(O,k);let A;n[23]===e.hosts?A=n[24]:(A=[...e.hosts].sort().join(`,`),n[23]=e.hosts,n[24]=A);let j=A,M,N;n[25]!==g||n[26]!==j?(M=()=>{let e=Z(g).hosts;e&&[...e].sort().join(`,`)===j&&Q(g,{hosts:null})},N=[j,g],n[25]=g,n[26]=j,n[27]=M,n[28]=N):(M=n[27],N=n[28]),(0,U.useEffect)(M,N);let P=(0,U.useRef)(null),F=(0,U.useRef)(null),I,ne;n[29]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>()=>{P.current&&clearTimeout(P.current),F.current?.(),F.current=null},ne=[],n[29]=I,n[30]=ne):(I=n[29],ne=n[30]),(0,U.useEffect)(I,ne);let B;n[31]!==t||n[32]!==g||n[33]!==e?(B=function(n,r){D.current=n,Q(g,{hosts:n}),P.current&&clearTimeout(P.current);let i=async()=>{F.current=null,P.current=null;let r=await t.install(e,n.filter(h));if(!r.ok){Q(g,{hosts:null});return}D.current=[...r.hosts],Q(g,{hosts:[...r.hosts]})};r?(F.current=()=>void i(),P.current=setTimeout(()=>void i(),350)):(F.current=null,i())},n[31]=t,n[32]=g,n[33]=e,n[34]=B):B=n[34];let V=B,H;return n[35]!==t||n[36]!==V||n[37]!==ee||n[38]!==te||n[39]!==p||n[40]!==x||n[41]!==g||n[42]!==w||n[43]!==e?(H={hostSet:ee,installed:te,installing:p,toggleEditor(e,t){let n=new Set(D.current);t?n.add(e):n.delete(e),V([...n],!0)},installAll(){let t=e.scope===`global`?fe:de,n=D.current.filter(e=>!t.includes(e)),r=e.installableEditors??t,i=t.filter(e=>r.includes(e)||D.current.includes(e));V([...n,...i],!1)},linkMode:w,sourceHost:x??e.hosts[0],placeAt(n,r){t.runLocationWrite(e,()=>z({scope:e.scope,name:e.name,dir:n,mode:r})).then(ve)},unplaceAt(n){t.runLocationWrite(e,()=>L({scope:e.scope,name:e.name,path:n})).then(_e)},setSource(n){Q(g,{source:n}),t.runLocationWrite(e,()=>R({scope:e.scope,name:e.name,target:n})).then(e=>{e.ok||(Q(g,{source:null}),d.error(e.error))})},convertLocation(n,r){t.convertLocations(e,[{target:n,mode:r}])},convertLocations(n){t.convertLocations(e,n)}},n[35]=t,n[36]=V,n[37]=ee,n[38]=te,n[39]=p,n[40]=x,n[41]=g,n[42]=w,n[43]=e,n[44]=H):H=n[44],H}function _e(e){e.ok||d.error(e.error)}function ve(e){e.ok||d.error(e.error)}function $(e){let t=(0,W.c)(7),{hint:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,G.jsx)(s,{asChild:!0,children:r}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,G.jsx)(c,{side:`right`,className:`max-w-xs`,children:n}),t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,G.jsxs)(l,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function ye(e){let t=(0,W.c)(77),{toggles:n,skill:a,onResolveFork:s,onRunStart:c,menuKind:l}=e,m=l===void 0?`dropdown`:l,{_:h}=i(),{hostSet:g,toggleEditor:_,installAll:v}=n,y=B(),b,x,S,C,w,T,O,k,A,j;if(t[0]!==h||t[1]!==y.data||t[2]!==y.status||t[3]!==g||t[4]!==v||t[5]!==m||t[6]!==s||t[7]!==c||t[8]!==a||t[9]!==_||t[10]!==n){let{pathFor:e,aliases:i,rows:l,sourceRow:M,sourceHost:N,conflicted:P,drifted:F,linked:I,expectedMode:L,convertible:R,customRootRows:z}=me({skill:a,allSkills:y.status===`ready`?y.data:null,hostSet:g,sourceHostOverlay:n.sourceHost,linkMode:n.linkMode});w=l,T=M,C=L,x=R,S=z;let B=e=>D(i,e),H=Ee,U=e=>{let t=B(e);return t.length===0?!0:window.confirm(h({id:`Uobeu9`,values:{0:t.map(H).join(`, `),rootRel:e}}))},W;t[21]!==h||t[22]!==a?(W=(e,t)=>{let n=e.includes(`/`)?e:te(e,a?.scope??`project`);return(0,G.jsx)($,{hint:h({id:`0dslv8`,values:{0:H(e),1:H(e),2:a?.name??``,poolRootRel:t,subRoot:n}}),children:(0,G.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-4 shrink-0 px-0`,"aria-label":h({id:`G6Lrs_`,values:{0:H(e)}}),onClick:r=>{r.preventDefault(),r.stopPropagation(),window.confirm(h({id:`iiqOKM`,values:{0:H(e),1:a.name,2:H(e),subRoot:n,poolRootRel:t}}))&&ne({scope:a.scope,root:n,action:`unlink`,exclude:[a.name]}).then(e=>{e.ok?f():d.error(h({id:`PRgIJh`,values:{0:e.error,subRoot:n}}))})},"data-testid":`skill-audience-unfollow-${e}`,children:(0,G.jsx)(o,{host:e,"aria-hidden":!0,className:`size-3.5`})})},e)},t[21]=h,t[22]=a,t[23]=W):W=t[23];let K=W;b=n.installing;let re=ee(a),oe=Te,se;t[24]!==h||t[25]!==c||t[26]!==n?(se=(e,t,i)=>{let a=i===`link`?`copy`:`link`;return(0,G.jsx)($,{hint:h(i===`link`?{id:`FeXcUS`,values:{display:t}}:{id:`ugQcJX`,values:{display:t}}),children:(0,G.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-warning/40 bg-warning/10 px-1 font-normal text-[10px] text-warning uppercase tracking-wide hover:bg-warning/20 hover:text-warning dark:hover:bg-warning/20`,onClick:r=>{r.preventDefault(),r.stopPropagation(),window.confirm(h(a===`link`?{id:`m0eHej`,values:{display:t}}:{id:`HbcQYf`,values:{display:t}}))&&(c?.(),n.convertLocation?.(e,a))},"data-testid":`skill-convert-${e}`,children:i===`link`?(0,G.jsx)(r,{id:`uUCrBv`}):(0,G.jsx)(r,{id:`iaPtht`})})})},t[24]=h,t[25]=c,t[26]=n,t[27]=se):se=t[27];let ce=se,le;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,G.jsx)(r,{id:`npcziF`}),t[28]=le):le=t[28];let q;t[29]===h?q=t[30]:(q=h({id:`6f_UX4`}),t[29]=h,t[30]=q);let J;t[31]===v?J=t[32]:(J=()=>v(),t[31]=v,t[32]=J);let Y;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,G.jsx)(r,{id:`N40H-G`}),t[33]=Y):Y=t[33];let X;t[34]!==b||t[35]!==J?(X=(0,G.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-5 px-1.5 font-normal text-[11px] text-muted-foreground hover:text-foreground`,disabled:b,onClick:J,"data-testid":`skill-install-all`,children:Y}),t[34]=b,t[35]=J,t[36]=X):X=t[36];let Z;t[37]!==q||t[38]!==X?(Z=(0,G.jsx)($,{hint:q,children:X}),t[37]=q,t[38]=X,t[39]=Z):Z=t[39],t[40]!==m||t[41]!==Z?(O=(0,G.jsxs)(ae,{menuKind:m,className:`flex items-center justify-between gap-2`,children:[le,Z]}),t[40]=m,t[41]=Z,t[42]=O):O=t[42],k=T===null?null:(0,G.jsx)($,{hint:h({id:`pXB6SL`}),children:(0,G.jsxs)(ie,{menuKind:m,disabled:b,checked:!0,onSelect:we,"data-testid":`skill-source-row`,children:[(0,G.jsx)(E,{"aria-hidden":!0,className:`size-4 text-muted-foreground`}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:T}),(()=>{let e=oe(T).split(`/`).slice(0,-1).join(`/`),t=B(e);return t.length>0?(0,G.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-testid":`skill-row-audience-source`,children:t.map(t=>K(t,e))}):null})(),(0,G.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded border border-border/60 px-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:(0,G.jsx)(r,{id:`tiFPjk`})})]})]})}),A=w.map(t=>{let i=e(t),c=t===`agents`?`.agents`:p[t],l=oe(i).split(`/`).slice(0,-1).join(`/`),d=B(l);return(0,G.jsx)($,{hint:P.has(t)?h({id:`8HvJlU`,values:{0:i??c}}):t===N?i?h({id:`ssk6rl`,values:{path:i}}):c:g.has(t)?h(i?{id:`9ieZhu`,values:{path:i}}:{id:`n3T3EE`,values:{label:c}}):re?.editor===t?h({id:`_3S4Ql`,values:{0:a?.name??``,1:re.plugin,2:i??c,label:c}}):h(i?N===void 0?{id:`xk133d`,values:{path:i}}:C===`link`?{id:`1LtA5r`,values:{path:i}}:{id:`opPbzN`,values:{path:i}}:{id:`Pp0Vgd`,values:{label:c}}),children:(0,G.jsxs)(ie,{menuKind:m,disabled:b,checked:g.has(t),onCheckedChange:e=>{P.has(t)||e===!0&&!U(l)||_(t,e===!0)},onSelect:Ce,className:`group`,"data-testid":`skill-install-editor-${t}`,children:[(0,G.jsx)(o,{host:t,"aria-hidden":!0,className:`size-4`}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:i??c}),d.length>0?(0,G.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-testid":`skill-row-audience-${t}`,children:d.map(e=>K(e,l))}):null,re?.editor===t&&!g.has(t)?(0,G.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded border border-border/60 px-1 text-[10px] uppercase tracking-wide text-muted-foreground`,"data-testid":`skill-row-plugin-covered-${t}`,children:(0,G.jsx)(r,{id:`scRzTw`})}):null,P.has(t)?(0,G.jsx)($,{hint:h({id:`_O7dJS`}),children:(0,G.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-warning/40 bg-warning/10 px-1 text-[10px] text-warning uppercase tracking-wide hover:bg-warning/20 hover:text-warning dark:hover:bg-warning/20`,onClick:e=>{e.preventDefault(),s?.(t)},"data-testid":`skill-fork-chip-${t}`,children:(0,G.jsx)(r,{id:`jng7Ko`})})}):t===N?(0,G.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded border border-border/60 px-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:(0,G.jsx)(r,{id:`tiFPjk`})}):g.has(t)&&a?.hosts?(0,G.jsxs)(G.Fragment,{children:[!b&&(I.has(t)?`link`:`copy`)!==C?ce(t,i??c,I.has(t)?`link`:`copy`):null,(0,G.jsx)($,{hint:h({id:`nBgzKO`}),children:(0,G.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-border/60 px-1 font-normal text-[10px] text-muted-foreground uppercase tracking-wide opacity-0 focus-visible:opacity-100 group-hover:opacity-100 hover:border-foreground/40 hover:text-foreground`,onClick:e=>{e.preventDefault(),e.stopPropagation(),n.setSource?.(t)},"data-testid":`skill-set-source-${t}`,children:(0,G.jsx)(r,{id:`VNNRfN`})})})]}):null,!b&&F.has(oe(i))?(0,G.jsx)($,{hint:h({id:`iz1LdD`}),children:(0,G.jsx)(V,{testId:`skill-drift-${t}`})}):null]})]})},t)}),j=S.map(e=>{let t=e.display;return(0,G.jsx)($,{hint:e.placed===null?h(N===void 0?{id:`xk133d`,values:{path:t}}:C===`link`?{id:`1LtA5r`,values:{path:t}}:{id:`opPbzN`,values:{path:t}}):h({id:`9ieZhu`,values:{path:t}}),children:(0,G.jsxs)(ie,{menuKind:m,disabled:b,checked:e.placed!==null,onCheckedChange:t=>{if(t===!0&&e.placed===null){if(!U(e.root))return;n.placeAt(e.root,C)}else e.placed!==null&&n.unplaceAt?.(e.placed.path)},onSelect:Se,className:`group`,"data-testid":`skill-custom-root-${e.root}`,children:[e.root===`.agents/skills`?(0,G.jsx)(o,{host:`agents`,"aria-hidden":!0,className:`size-4`}):(0,G.jsx)(E,{"aria-hidden":!0,className:`size-4 text-muted-foreground`}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.display}),B(e.root).length>0?(0,G.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-testid":`skill-row-audience-custom-${e.root}`,children:B(e.root).map(t=>K(t,e.root))}):null,!b&&e.placed!==null&&F.has(e.placed.path)?(0,G.jsx)($,{hint:h({id:`iz1LdD`}),children:(0,G.jsx)(V,{testId:`skill-drift-custom-${e.root}`})}):e.placed===null?null:(0,G.jsxs)(G.Fragment,{children:[!b&&e.placed.mode!==C?ce(e.root,e.display,e.placed.mode):null,(0,G.jsx)($,{hint:h({id:`nBgzKO`}),children:(0,G.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-border/60 px-1 font-normal text-[10px] text-muted-foreground uppercase tracking-wide opacity-0 focus-visible:opacity-100 group-hover:opacity-100 hover:border-foreground/40 hover:text-foreground`,onClick:t=>{t.preventDefault(),t.stopPropagation(),n.setSource?.(e.root)},"data-testid":`skill-set-source-custom-${e.root}`,children:(0,G.jsx)(r,{id:`VNNRfN`})})})]})]})]})},e.root)}),t[0]=h,t[1]=y.data,t[2]=y.status,t[3]=g,t[4]=v,t[5]=m,t[6]=s,t[7]=c,t[8]=a,t[9]=_,t[10]=n,t[11]=b,t[12]=x,t[13]=S,t[14]=C,t[15]=w,t[16]=T,t[17]=O,t[18]=k,t[19]=A,t[20]=j}else b=t[11],x=t[12],S=t[13],C=t[14],w=t[15],T=t[16],O=t[17],k=t[18],A=t[19],j=t[20];let M;t[43]!==S||t[44]!==w.length||t[45]!==T?(M=w.length===0&&S.length===0&&T===null?(0,G.jsx)(`div`,{className:`px-2 py-1.5 text-[11px] text-muted-foreground leading-snug`,"data-testid":`skill-install-no-destinations`,children:(0,G.jsx)(r,{id:`MOAoFO`})}):null,t[43]=S,t[44]=w.length,t[45]=T,t[46]=M):M=t[46];let N;t[47]!==h||t[48]!==b||t[49]!==x||t[50]!==C||t[51]!==c||t[52]!==n?(N=x.length>0&&n.convertLocations?(0,G.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-1 pb-1.5`,children:[(0,G.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-auto whitespace-normal p-0 text-left font-normal text-[11px] text-muted-foreground leading-snug hover:bg-transparent hover:text-foreground`,onClick:e=>{e.preventDefault();let t=C===`link`?`copy`:`link`,r=x.filter(e=>e.mode!==t);if(r.length===0)return;let i=h(t===`copy`?{id:`iOAsF1`}:{id:`MS8lMS`}),a=h(t===`copy`?{id:`gZiT5e`}:{id:`PhIa-X`}),o=r.map(xe).join(`
2
- `);window.confirm(`${i}\n\n${a}\n\n${o}\n\n${h({id:`Cu6GXQ`})}`)&&(c?.(),n.convertLocations?.(r.map(e=>({target:e.target,mode:t}))))},disabled:b,"data-testid":`skill-convert-all`,children:C===`link`?(0,G.jsx)(r,{id:`rcJmK8`}):(0,G.jsx)(r,{id:`LBv_TR`})}),(0,G.jsx)($,{hint:h({id:`0J6nhG`}),children:(0,G.jsx)(u,{variant:`ghost`,size:`sm`,"aria-label":h({id:`qJSo0_`}),className:`size-4 shrink-0 rounded-full border border-border/60 p-0 font-normal text-[9px] text-muted-foreground hover:border-foreground/40 hover:bg-transparent hover:text-foreground`,onClick:be,"data-testid":`skill-convert-all-help`,children:`?`})})]}):null,t[47]=h,t[48]=b,t[49]=x,t[50]=C,t[51]=c,t[52]=n,t[53]=N):N=t[53];let P;t[54]===m?P=t[55]:(P=(0,G.jsx)(oe,{menuKind:m}),t[54]=m,t[55]=P);let F;t[56]===h?F=t[57]:(F=h({id:`5ymuTA`}),t[56]=h,t[57]=F);let I;t[58]===a?.scope?I=t[59]:(I=()=>{window.location.hash=a?.scope===`global`?`#settings/user-skills`:`#settings/skills`},t[58]=a?.scope,t[59]=I);let L,R;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,G.jsx)(H,{"aria-hidden":!0}),R=(0,G.jsx)(r,{id:`ZBF9fn`}),t[60]=L,t[61]=R):(L=t[60],R=t[61]);let z;t[62]!==m||t[63]!==I?(z=(0,G.jsxs)(re,{menuKind:m,onSelect:I,children:[L,R]}),t[62]=m,t[63]=I,t[64]=z):z=t[64];let U;t[65]!==z||t[66]!==F?(U=(0,G.jsx)($,{hint:F,children:z}),t[65]=z,t[66]=F,t[67]=U):U=t[67];let K;return t[68]!==U||t[69]!==O||t[70]!==k||t[71]!==A||t[72]!==j||t[73]!==M||t[74]!==N||t[75]!==P?(K=(0,G.jsxs)(G.Fragment,{children:[O,k,A,j,M,N,P,U]}),t[68]=U,t[69]=O,t[70]=k,t[71]=A,t[72]=j,t[73]=M,t[74]=N,t[75]=P,t[76]=K):K=t[76],K}function be(e){return e.preventDefault()}function xe(e){return e.display}function Se(e){return e.preventDefault()}function Ce(e){return e.preventDefault()}function we(e){return e.preventDefault()}function Te(e){return(e??``).replace(/^~\//,``)}function Ee(e){return e===`agents`?`.agents`:p[e]??e}export{de as a,ae as c,ce as d,le as f,fe as i,oe as l,ye as n,K as o,H as p,ge as r,re as s,he as t,se as u};