@inkeep/open-knowledge 0.52.0-beta.2 → 0.52.0-beta.4

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 (160) hide show
  1. package/dist/{acp-harness-probe-8Sj9j5_f.mjs → acp-harness-probe-BsrCm6PN.mjs} +2 -2
  2. package/dist/cli.mjs +37 -37
  3. package/dist/constants-6rxfoWpc.mjs +2 -0
  4. package/dist/{git-handle--xISIJuo.mjs → git-handle-BxjRPCxW.mjs} +2 -2
  5. package/dist/git-handle-MmJWq1we.mjs +1 -0
  6. package/dist/index.d.mts +17 -17
  7. package/dist/index.mjs +135 -135
  8. package/dist/init-CwMckfG6.mjs +1 -0
  9. package/dist/{init-DyUOE5zl.mjs → init-FysoPMTz.mjs} +5 -5
  10. package/dist/{launch-json-removal-D4uxGOEd.mjs → launch-json-removal-DCGgZaLR.mjs} +2 -2
  11. package/dist/{loader-DGh4bdW9.mjs → loader-D9ASHd7b.mjs} +2 -2
  12. package/dist/loader-zJS8KnFD.mjs +1 -0
  13. package/dist/md-manager-DvauwrLt.mjs +2 -0
  14. package/dist/{open-browser-CV5L0bD3.mjs → open-browser-Bp_PADnW.mjs} +2 -2
  15. package/dist/parse-worker.mjs +1 -1
  16. package/dist/preview-B-lUEPFE.mjs +1 -0
  17. package/dist/{preview-BbSnbtj5.mjs → preview-C3WQiD83.mjs} +2 -2
  18. package/dist/public/assets/{ActivityModeContent-82sBOezj.js → ActivityModeContent-DDjrqNMY.js} +1 -1
  19. package/dist/public/assets/{AgentDiffPane-CoeEE99v.js → AgentDiffPane-ZNFEXc_i.js} +1 -1
  20. package/dist/public/assets/{AgentThreadClientBinder-DoXKRY3h.js → AgentThreadClientBinder-C6VOwZkD.js} +1 -1
  21. package/dist/public/assets/{ChangedOutsideBadge-D047_w8_.js → ChangedOutsideBadge-H7FINGGt.js} +1 -1
  22. package/dist/public/assets/{CodeMirrorPropInput-AfI-A739.js → CodeMirrorPropInput-Dm_i6ZFf.js} +1 -1
  23. package/dist/public/assets/{DocumentContext-RfseIiCK.js → DocumentContext-szVV1fVy.js} +8 -8
  24. package/dist/public/assets/{EditorModeToggle-BFLOwOkQ.js → EditorModeToggle-DvnPLlja.js} +1 -1
  25. package/dist/public/assets/{EnableSyncConfirmDialog-DrKJd8P_.js → EnableSyncConfirmDialog-ChoEq0DU.js} +1 -1
  26. package/dist/public/assets/FeedbackForm-CdfQfmxg.js +1 -0
  27. package/dist/public/assets/{GraphPanel-CIsyWZZL.js → GraphPanel-CEzLuqY6.js} +1 -1
  28. package/dist/public/assets/{ImportSkillDialog-R8BKwyCS.js → ImportSkillDialog-Bb_uaAgF.js} +1 -1
  29. package/dist/public/assets/{LintConfigEditor-CMXHDFZF.js → LintConfigEditor-DK3VGKVs.js} +1 -1
  30. package/dist/public/assets/ManagedArtifactProperties-B5pd1t-W.js +1 -0
  31. package/dist/public/assets/ManagedArtifactProperties-Z-YF-aB8.js +2 -0
  32. package/dist/public/assets/{McpConsentDialogBody-D6qWh37S.js → McpConsentDialogBody-D6vhdhvn.js} +1 -1
  33. package/dist/public/assets/{MermaidDocEditor-DbdolXNy.js → MermaidDocEditor-CdMcNH1K.js} +1 -1
  34. package/dist/public/assets/{ReportBugDialogBody-0zuUulQL.js → ReportBugDialogBody-DeBhdZfN.js} +1 -1
  35. package/dist/public/assets/{SchemaConfigEditor-rEKhSqJM.js → SchemaConfigEditor-DEyXtam3.js} +1 -1
  36. package/dist/public/assets/{SessionsHost-CGV_FZVZ.js → SessionsHost-BMNTi7yU.js} +2 -2
  37. package/dist/public/assets/{SettingsDialogBody-DPjbScQ8.js → SettingsDialogBody-BkgcHbgJ.js} +4 -4
  38. package/dist/public/assets/{ShareBranchSwitchDialog-BHZw8v-i.js → ShareBranchSwitchDialog-DxktB3r8.js} +1 -1
  39. package/dist/public/assets/{ShareReceiveDialog-CA7GkSOU.js → ShareReceiveDialog-D-XtsO7r.js} +1 -1
  40. package/dist/public/assets/{ShareReceiveMissDialog-BVb9iCe7.js → ShareReceiveMissDialog-QyAZHgSx.js} +1 -1
  41. package/dist/public/assets/{SkillEditBanner-Dc5M38zl.js → SkillEditBanner-BWQ32mel.js} +1 -1
  42. package/dist/public/assets/{SkillOriginInline-B-wdZ-wi.js → SkillOriginInline-CCXU6r9K.js} +1 -1
  43. package/dist/public/assets/{SkillToolbarControls-B1VGCLbB.js → SkillToolbarControls-C4l-ExkC.js} +1 -1
  44. package/dist/public/assets/{SlidesToolbarControls-DpEF1_8n.js → SlidesToolbarControls-7AXzTumF.js} +1 -1
  45. package/dist/public/assets/{SourceEditor-BXsOQKW8.js → SourceEditor-n3FmZ5uT.js} +1 -1
  46. package/dist/public/assets/{TerminalPanel-D4k0ePYg.js → TerminalPanel-DnBVJwtb.js} +1 -1
  47. package/dist/public/assets/{TerminalWindowApp-C1Ej4Kb1.js → TerminalWindowApp-MRzFnQYj.js} +1 -1
  48. package/dist/public/assets/{TextDocEditor-DxhziylX.js → TextDocEditor-b-e4xXil.js} +1 -1
  49. package/dist/public/assets/{ThreadView-DlpPbPgC.js → ThreadView-CGFzmia3.js} +1 -1
  50. package/dist/public/assets/{TimelineDiffPane-35Fhuse-.js → TimelineDiffPane-CchFe3_j.js} +1 -1
  51. package/dist/public/assets/{agent-diff-store-BTtYfAZI.js → agent-diff-store-DOZTdgPj.js} +1 -1
  52. package/dist/public/assets/auth-state-cache-Dfg2JLBY.js +11 -0
  53. package/dist/public/assets/{client-version-UVydSM1_.js → client-version-7YMypzyJ.js} +1 -1
  54. package/dist/public/assets/{comment-chips-CspvZbMA.js → comment-chips-DpxHRgmj.js} +1 -1
  55. package/dist/public/assets/{config-provider-DAD08DXO.js → config-provider-adYhj3gU.js} +3 -3
  56. package/dist/public/assets/{dist-CKFXiBrL.js → dist-BzfrsvTh.js} +121 -121
  57. package/dist/public/assets/{doc-paths-aGtYCY4p.js → doc-paths-CW1IFrYA.js} +1 -1
  58. package/dist/public/assets/{documents-events-BNjnUfCu.js → documents-events-DPB-rPGP.js} +1 -1
  59. package/dist/public/assets/{file-tree-adapter-BnKrzDCF.js → file-tree-adapter-SvAwORmT.js} +1 -1
  60. package/dist/public/assets/{file-tree-utils-CPfKs0_W.js → file-tree-utils-CD6AFEev.js} +1 -1
  61. package/dist/public/assets/{folder-config-api-C00aXHgv.js → folder-config-api-DECOVmJn.js} +1 -1
  62. package/dist/public/assets/{follow-file-ClUkwvTW.js → follow-file-CIGLgHvp.js} +1 -1
  63. package/dist/public/assets/i18n-BsOL8j4y.js +1 -0
  64. package/dist/public/assets/index-DPlcZJ0t.js +2095 -0
  65. package/dist/public/assets/{lint-config-client-CwpzRrsJ.js → lint-config-client-xbGFkSUV.js} +1 -1
  66. package/dist/public/assets/{markdownlint-rule-browser-DDivenan.js → markdownlint-rule-browser-mcRSb6TR.js} +1 -1
  67. package/dist/public/assets/messages-B3q8S9Xi.js +1 -0
  68. package/dist/public/assets/messages-BKDPxHLc.js +1 -0
  69. package/dist/public/assets/messages-BZksDSuA.js +1 -0
  70. package/dist/public/assets/messages-BsdSHCbl.js +1 -0
  71. package/dist/public/assets/messages-BvUYpG4U.js +1 -0
  72. package/dist/public/assets/messages-CZj797h9.js +1 -0
  73. package/dist/public/assets/messages-CpTe5fsc.js +1 -0
  74. package/dist/public/assets/messages-Cx10p5ee.js +1 -0
  75. package/dist/public/assets/messages-DRe80BU0.js +1 -0
  76. package/dist/public/assets/messages-RFWmQ0zc.js +1 -0
  77. package/dist/public/assets/messages-f4T0c1f4.js +1 -0
  78. package/dist/public/assets/navigation-targets-Di-e5Xgh.js +1 -0
  79. package/dist/public/assets/{open-managed-artifact-tab-Dxiu79gQ.js → open-managed-artifact-tab-BDrP7c9Q.js} +1 -1
  80. package/dist/public/assets/{pending-receive-nav-store-DTGiCG3P.js → pending-receive-nav-store-C49SWp2G.js} +1 -1
  81. package/dist/public/assets/{prop-types-RgJQCViX.js → prop-types-rNWO17zq.js} +1 -1
  82. package/dist/public/assets/{receive-store-C7RBAUmu.js → receive-store-CzHcxuhu.js} +1 -1
  83. package/dist/public/assets/{selection-context-D_1ahjGj.js → selection-context-BGUOnaGz.js} +1 -1
  84. package/dist/public/assets/skill-actions-C18T1CE_.js +2 -0
  85. package/dist/public/assets/skill-scope-T3ILPDuO.js +1 -0
  86. package/dist/public/assets/skills-api-kF-de_tA.js +1 -0
  87. package/dist/public/assets/{src-Dfy4grTv.js → src-Cwd2nlpi.js} +1 -1
  88. package/dist/public/assets/{tag-pill-input-vgqgNkXB.js → tag-pill-input-B4XQ4nCv.js} +1 -1
  89. package/dist/public/assets/{target-navigation-intent-DEiFgbdU.js → target-navigation-intent-BShDksCm.js} +1 -1
  90. package/dist/public/assets/{terminal-cli-display-Du0YYwUl.js → terminal-cli-display-Cb4hZImR.js} +1 -1
  91. package/dist/public/assets/{terminal-launch-events-C5JkD3Qb.js → terminal-launch-events-BZbUxjf2.js} +1 -1
  92. package/dist/public/assets/{terminal-telemetry-Cj_uo6eX.js → terminal-telemetry-BXei6J5i.js} +1 -1
  93. package/dist/public/assets/{typing-burst-detector-vxYjrFWQ.js → typing-burst-detector-SZlWsWen.js} +3 -3
  94. package/dist/public/assets/{uninstall-C6wmbgyN.js → uninstall-DURll1w5.js} +1 -1
  95. package/dist/public/assets/{use-activity-panel-DtCqiYlm.js → use-activity-panel-Bzjhtdam.js} +1 -1
  96. package/dist/public/assets/{use-apply-config-color-theme-DkVlJHc4.js → use-apply-config-color-theme-4v0CHupZ.js} +1 -1
  97. package/dist/public/assets/{use-collab-url-CpJYowg_.js → use-collab-url-BI8-6Q70.js} +1 -1
  98. package/dist/public/assets/{use-live-xterm-theme-DfHZqsch.js → use-live-xterm-theme-CJcAFhaO.js} +1 -1
  99. package/dist/public/assets/use-open-skill-CO00_zKe.js +1 -0
  100. package/dist/public/assets/{use-popular-skills-C9TB91tU.js → use-popular-skills-BbEsnH4g.js} +1 -1
  101. package/dist/public/assets/{use-settings-route-D_8EQ_KO.js → use-settings-route-BrGJ-4C8.js} +1 -1
  102. package/dist/public/assets/{use-skill-origin-BjB7AiHp.js → use-skill-origin-DJK4B2EI.js} +1 -1
  103. package/dist/public/assets/use-skills-CgW3_c2J.js +1 -0
  104. package/dist/public/assets/{use-terminal-enabled-D2pvXg6e.js → use-terminal-enabled-BBnglW9Q.js} +1 -1
  105. package/dist/public/assets/{use-timeline-entry-diff-Do0ZBwge.js → use-timeline-entry-diff-Bb5ydByU.js} +1 -1
  106. package/dist/public/assets/{use-workspace-e-krFmvC.js → use-workspace-DzB9pyD0.js} +1 -1
  107. package/dist/public/index.html +45 -45
  108. package/dist/public/uninstall.html +4 -4
  109. package/dist/{repair-launch-json-D5bvpzmg.mjs → repair-launch-json-CFQrDiU9.mjs} +2 -2
  110. package/dist/{repair-mcp-configs-CElx4zud.mjs → repair-mcp-configs-JCkDkp5e.mjs} +2 -2
  111. package/dist/{repair-skills-pGap1_gF.mjs → repair-skills-6KHgz0Jo.mjs} +2 -2
  112. package/dist/repair-skills-B_JnDxHU.mjs +1 -0
  113. package/dist/{server-lock-CyyeFKIF.mjs → server-lock-XNc0dGvF.mjs} +2 -2
  114. package/dist/server-lock-vEBQUai6.mjs +1 -0
  115. package/dist/{skill-teardown-DxeHIPsr.mjs → skill-teardown-B6HJfl80.mjs} +2 -2
  116. package/dist/{src-Qlsty_8B.mjs → src-BkmYz3mW.mjs} +1 -1
  117. package/dist/src-CJtJqVBz.mjs +1 -0
  118. package/dist/{src-D3IYzczj.mjs → src-CfKlTuR4.mjs} +4 -4
  119. package/dist/{src-DZEg-Zy7.mjs → src-DVc0ORbR.mjs} +315 -313
  120. package/dist/{src-B8SfUeFe.mjs → src-DiueG9n0.mjs} +120 -120
  121. package/dist/{start-BRLdH4Kk.mjs → start-0sXD_v7Y.mjs} +5 -5
  122. package/dist/start-DTtRSIl6.mjs +1 -0
  123. package/dist/ui-BOU936pt.mjs +1 -0
  124. package/dist/{ui-BQkXNsD0.mjs → ui-CWpbw0Q2.mjs} +3 -3
  125. package/dist/{write-project-skill-DHATTSra.mjs → write-project-skill-B0KKzsOU.mjs} +3 -3
  126. package/package.json +4 -4
  127. package/dist/constants-B_VMjNrS.mjs +0 -2
  128. package/dist/git-handle-Dt3gdxML.mjs +0 -1
  129. package/dist/init-gTl1f87x.mjs +0 -1
  130. package/dist/loader-0WRtkHJU.mjs +0 -1
  131. package/dist/md-manager-RNjkssEV.mjs +0 -2
  132. package/dist/preview-D9IFuChZ.mjs +0 -1
  133. package/dist/public/assets/FeedbackForm-CpyB0Ay7.js +0 -1
  134. package/dist/public/assets/ManagedArtifactProperties-BfpBSbt8.js +0 -2
  135. package/dist/public/assets/ManagedArtifactProperties-CaU-7RSA.js +0 -1
  136. package/dist/public/assets/auth-state-cache-j2uCE1rv.js +0 -11
  137. package/dist/public/assets/i18n-DnAdj3V4.js +0 -1
  138. package/dist/public/assets/index-DkaSwI0X.js +0 -2095
  139. package/dist/public/assets/messages-BFSFw083.js +0 -1
  140. package/dist/public/assets/messages-But-gxxm.js +0 -1
  141. package/dist/public/assets/messages-C2dy97-C.js +0 -1
  142. package/dist/public/assets/messages-C6mfKAsF.js +0 -1
  143. package/dist/public/assets/messages-CT0uUq60.js +0 -1
  144. package/dist/public/assets/messages-CoCHeX4T.js +0 -1
  145. package/dist/public/assets/messages-D2Xjng5y.js +0 -1
  146. package/dist/public/assets/messages-DGIb-W2n.js +0 -1
  147. package/dist/public/assets/messages-DZjmC-3B.js +0 -1
  148. package/dist/public/assets/messages-DmRUKkYi.js +0 -1
  149. package/dist/public/assets/messages-Vp_S0vgN.js +0 -1
  150. package/dist/public/assets/navigation-targets-BN-b0SwY.js +0 -1
  151. package/dist/public/assets/skill-actions-BKW-L6YY.js +0 -2
  152. package/dist/public/assets/skill-scope-D3fqbCKZ.js +0 -1
  153. package/dist/public/assets/skills-api-BAB9Nk_K.js +0 -1
  154. package/dist/public/assets/use-open-skill-DdTYxJp4.js +0 -1
  155. package/dist/public/assets/use-skills-DMV2hvXx.js +0 -1
  156. package/dist/repair-skills-uGkRmBYx.mjs +0 -1
  157. package/dist/server-lock-DwSyFoTt.mjs +0 -1
  158. package/dist/src-BA5_eUW_.mjs +0 -1
  159. package/dist/start-Drc0EilO.mjs +0 -1
  160. package/dist/ui-BkhU6wt_.mjs +0 -1
@@ -32,7 +32,7 @@
32
32
  script above.
33
33
  -->
34
34
  <style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
35
- <script type="module" crossorigin src="./assets/uninstall-C6wmbgyN.js"></script>
35
+ <script type="module" crossorigin src="./assets/uninstall-DURll1w5.js"></script>
36
36
  <link rel="modulepreload" crossorigin href="./assets/chunk-CYidjpOJ.js">
37
37
  <link rel="modulepreload" crossorigin href="./assets/react-f2sANaYj.js">
38
38
  <link rel="modulepreload" crossorigin href="./assets/react-dom-DPxgxlDT.js">
@@ -44,7 +44,7 @@
44
44
  <link rel="modulepreload" crossorigin href="./assets/lib-C0Wr4O8I.js">
45
45
  <link rel="modulepreload" crossorigin href="./assets/markdownit-C1Squg6O.js">
46
46
  <link rel="modulepreload" crossorigin href="./assets/w3c-keyname-Bw5giFqP.js">
47
- <link rel="modulepreload" crossorigin href="./assets/dist-CKFXiBrL.js">
47
+ <link rel="modulepreload" crossorigin href="./assets/dist-BzfrsvTh.js">
48
48
  <link rel="modulepreload" crossorigin href="./assets/dist-DUfEoSbR.js">
49
49
  <link rel="modulepreload" crossorigin href="./assets/jsx-runtime-BUgB2tll.js">
50
50
  <link rel="modulepreload" crossorigin href="./assets/dist-Nvb76hAm.js">
@@ -68,8 +68,8 @@
68
68
  <link rel="modulepreload" crossorigin href="./assets/badge-DFX4S3a5.js">
69
69
  <link rel="modulepreload" crossorigin href="./assets/input-BYiOK210.js">
70
70
  <link rel="modulepreload" crossorigin href="./assets/textarea-yZk4yd9U.js">
71
- <link rel="modulepreload" crossorigin href="./assets/messages-CT0uUq60.js">
72
- <link rel="modulepreload" crossorigin href="./assets/i18n-DnAdj3V4.js">
71
+ <link rel="modulepreload" crossorigin href="./assets/messages-CZj797h9.js">
72
+ <link rel="modulepreload" crossorigin href="./assets/i18n-BsOL8j4y.js">
73
73
  <link rel="stylesheet" crossorigin href="./assets/globals-tIUZlcbW.css">
74
74
  </head>
75
75
 
@@ -1,2 +1,2 @@
1
- import{t as e}from"./launch-json-removal-D4uxGOEd.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`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=e(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`||o.kind===`removed-file`;return s&&i({event:`launch-json-repair-removed`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
2
- //# sourceMappingURL=repair-launch-json-D5bvpzmg.mjs.map
1
+ import{t as e}from"./launch-json-removal-DCGgZaLR.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`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=e(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`||o.kind===`removed-file`;return s&&i({event:`launch-json-repair-removed`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
2
+ //# sourceMappingURL=repair-launch-json-CFQrDiU9.mjs.map
@@ -1,2 +1,2 @@
1
- import{d as e,v as t}from"./init-DyUOE5zl.mjs";import{i as n,o as r,p as i}from"./write-project-skill-DHATTSra.mjs";import{t as a}from"./mcp-migrate-event-BsswfOLm.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,i=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of n){let n=r[o],s=c(()=>n.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:n,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),n.projectConfigPath){let r=n.projectConfigPath,i=c(()=>r(e.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:n,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(n){let r={scope:n.scope,editorId:n.editorId,configPath:n.configPath},o=e(n.target,n.cwd,n.home,n.configPathOverride);if(o===null)return{...r,outcome:`no-entry`};if(i(o))return{...r,outcome:`canonical`};n.logger(a({scope:n.scope,surface:`cli-repair`,editorId:n.editorId,configPath:n.configPath,priorEntry:o}));let s=t(n.target,n.cwd,{mode:`published`,skipAvailabilityCheck:!0},n.home,n.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return n.logger({event:`mcp-config-repair-write-failed`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,error:e}),{...r,outcome:`write-failed`,error:e}}return s.action===`declined`?(n.logger({event:`mcp-config-repair-declined`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,reason:s.declineReason}),{...r,outcome:`declined`}):{...r,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
- //# sourceMappingURL=repair-mcp-configs-CElx4zud.mjs.map
1
+ import{d as e,v as t}from"./init-FysoPMTz.mjs";import{i as n,o as r,p as i}from"./write-project-skill-B0KKzsOU.mjs";import{t as a}from"./mcp-migrate-event-BsswfOLm.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,i=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of n){let n=r[o],s=c(()=>n.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:n,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),n.projectConfigPath){let r=n.projectConfigPath,i=c(()=>r(e.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:n,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(n){let r={scope:n.scope,editorId:n.editorId,configPath:n.configPath},o=e(n.target,n.cwd,n.home,n.configPathOverride);if(o===null)return{...r,outcome:`no-entry`};if(i(o))return{...r,outcome:`canonical`};n.logger(a({scope:n.scope,surface:`cli-repair`,editorId:n.editorId,configPath:n.configPath,priorEntry:o}));let s=t(n.target,n.cwd,{mode:`published`,skipAvailabilityCheck:!0},n.home,n.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return n.logger({event:`mcp-config-repair-write-failed`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,error:e}),{...r,outcome:`write-failed`,error:e}}return s.action===`declined`?(n.logger({event:`mcp-config-repair-declined`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,reason:s.declineReason}),{...r,outcome:`declined`}):{...r,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
+ //# sourceMappingURL=repair-mcp-configs-JCkDkp5e.mjs.map
@@ -1,4 +1,4 @@
1
- import{z as e}from"./src-B8SfUeFe.mjs";import{Cr as t,_r as n,cr as r,fr as i,lr as a,mr as o,pr as s,wr as c,yr as l}from"./src-DZEg-Zy7.mjs";import{t as u}from"./esm-DmX1RzAi.mjs";import{n as d,s as f,t as p}from"./colors-BsmVIwfM.mjs";import{o as m,s as h,t as g}from"./write-project-skill-DHATTSra.mjs";import{n as _,r as v,t as y}from"./skill-teardown-DxeHIPsr.mjs";import{dirname as b,join as x,relative as S,resolve as C}from"node:path";import{existsSync as w,mkdirSync as T,readFileSync as E,readdirSync as D,rmSync as O,statSync as k,writeFileSync as A}from"node:fs";import{homedir as j}from"node:os";import{createInterface as M}from"node:readline/promises";const N={existsSync:e=>w(e),isDirectory:e=>{try{return k(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>D(e),readFileSync:e=>E(e),writeFileSync:(e,t)=>{A(e,t)},mkdirSync:(e,t)=>{T(e,t)},rmSync:(e,t)=>{O(e,t)}},P={resolveProjectBundledSkillDir:()=>l(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>l(e,{checkDesktop:!1}),readBundledVersion:()=>a(),readRecordedVersion:e=>i(e,`cli-hosts`),writeRecordedVersion:(e,t)=>o(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>n(e),readBundleDecision:(e,t)=>r(e,t),writeBundleDecision:(e,t,n)=>s(e,t,n),removeBundleFromDisk:(e,t)=>v(e,t)};function F(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function I(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(b(t),{recursive:!0}),L(e,t,n)}function L(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=x(e,r),a=x(t,r);n.isDirectory(i)?L(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function R(e,t,n,r,i,a){let o=[],s=x(e,`.agents`,`skills`,t),c=!1;if(r.existsSync(s))o.push({kind:`central`,path:s,outcome:`skipped-present`});else try{I(n,s,r),c=!0,o.push({kind:`central`,path:s,outcome:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let c of h){let l=x(e,c.hostDir),u=x(l,`skills`,t);if(u===s){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(l)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(r.existsSync(u)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-present`});continue}try{I(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,error:t})}}return{entries:o,centralWritten:c}}function z(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function B(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of h){let o=x(e,t.hostDir,`skills`,`open-knowledge`),s=x(o,`SKILL.md`);if(n.existsSync(s)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`present`});continue}let c=m[t.editorId]?.projectConfigPath?.(e);if(!z(c,n)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{g(o,e),I(i,o,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`created`}),r({event:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function V(n,r,i,a){let o=e=>{r.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),l;try{l=await r.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await r.readRecordedVersion(n)}catch(e){a({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of c)try{d.push({id:e,sourceDir:r.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return a({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let o of d){let s=t[o.id],c=i.existsSync(x(n,`.agents`,`skills`,s)),l=await r.readBundleDecision(n,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{r.removeBundleFromDisk(n,o.id),a({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){a({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await r.writeBundleDecision(n,s,!0)}catch(e){a({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}p.push(o)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>i.existsSync(x(n,`.agents`,`skills`,t[e.id])));if(u!==null&&u===l&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:l}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===c.length,_=[];for(let{id:e,sourceDir:r}of p){let o=R(n,t[e],r,i,a,l);h.push(...o.entries),_.push({id:e,centralWritten:o.centralWritten})}let v=h.some(e=>e.kind===`central`&&e.outcome===`failed`);if(g&&!v){let e=null;try{await r.writeRecordedVersion(n,l),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:l})}catch(t){e=t instanceof Error?t.message:String(t),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:l,error:e})}for(let{id:t,centralWritten:n}of _)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?n?`installed`:`skip-current`:`failed`,version:l,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{let e=h.some(e=>e.kind===`host`&&e.outcome===`failed`);o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:l,reason:g?e?`all-writes-failed`:`central-write-failed`:`bundle-unresolved`})}return{outcome:`done`,version:l,entries:h}}async function H(e){let t=e.logger??F,n=e.fs??N,r=e.home??j(),i={...P,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=B(e.projectDir,i,n,t),o=await V(r,i,n,t),s=_(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=y(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function U(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function W(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
1
+ import{z as e}from"./src-DiueG9n0.mjs";import{Cr as t,_r as n,cr as r,fr as i,lr as a,mr as o,pr as s,wr as c,yr as l}from"./src-DVc0ORbR.mjs";import{t as u}from"./esm-DmX1RzAi.mjs";import{n as d,s as f,t as p}from"./colors-BsmVIwfM.mjs";import{o as m,s as h,t as g}from"./write-project-skill-B0KKzsOU.mjs";import{n as _,r as v,t as y}from"./skill-teardown-B6HJfl80.mjs";import{dirname as b,join as x,relative as S,resolve as C}from"node:path";import{existsSync as w,mkdirSync as T,readFileSync as E,readdirSync as D,rmSync as O,statSync as k,writeFileSync as A}from"node:fs";import{homedir as j}from"node:os";import{createInterface as M}from"node:readline/promises";const N={existsSync:e=>w(e),isDirectory:e=>{try{return k(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>D(e),readFileSync:e=>E(e),writeFileSync:(e,t)=>{A(e,t)},mkdirSync:(e,t)=>{T(e,t)},rmSync:(e,t)=>{O(e,t)}},P={resolveProjectBundledSkillDir:()=>l(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>l(e,{checkDesktop:!1}),readBundledVersion:()=>a(),readRecordedVersion:e=>i(e,`cli-hosts`),writeRecordedVersion:(e,t)=>o(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>n(e),readBundleDecision:(e,t)=>r(e,t),writeBundleDecision:(e,t,n)=>s(e,t,n),removeBundleFromDisk:(e,t)=>v(e,t)};function F(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function I(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(b(t),{recursive:!0}),L(e,t,n)}function L(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=x(e,r),a=x(t,r);n.isDirectory(i)?L(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function R(e,t,n,r,i,a){let o=[],s=x(e,`.agents`,`skills`,t),c=!1;if(r.existsSync(s))o.push({kind:`central`,path:s,outcome:`skipped-present`});else try{I(n,s,r),c=!0,o.push({kind:`central`,path:s,outcome:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let c of h){let l=x(e,c.hostDir),u=x(l,`skills`,t);if(u===s){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(l)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(r.existsSync(u)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-present`});continue}try{I(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,error:t})}}return{entries:o,centralWritten:c}}function z(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function B(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of h){let o=x(e,t.hostDir,`skills`,`open-knowledge`),s=x(o,`SKILL.md`);if(n.existsSync(s)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`present`});continue}let c=m[t.editorId]?.projectConfigPath?.(e);if(!z(c,n)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{g(o,e),I(i,o,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`created`}),r({event:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function V(n,r,i,a){let o=e=>{r.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),l;try{l=await r.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await r.readRecordedVersion(n)}catch(e){a({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of c)try{d.push({id:e,sourceDir:r.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return a({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let o of d){let s=t[o.id],c=i.existsSync(x(n,`.agents`,`skills`,s)),l=await r.readBundleDecision(n,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{r.removeBundleFromDisk(n,o.id),a({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){a({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await r.writeBundleDecision(n,s,!0)}catch(e){a({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}p.push(o)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>i.existsSync(x(n,`.agents`,`skills`,t[e.id])));if(u!==null&&u===l&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:l}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===c.length,_=[];for(let{id:e,sourceDir:r}of p){let o=R(n,t[e],r,i,a,l);h.push(...o.entries),_.push({id:e,centralWritten:o.centralWritten})}let v=h.some(e=>e.kind===`central`&&e.outcome===`failed`);if(g&&!v){let e=null;try{await r.writeRecordedVersion(n,l),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:l})}catch(t){e=t instanceof Error?t.message:String(t),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:l,error:e})}for(let{id:t,centralWritten:n}of _)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?n?`installed`:`skip-current`:`failed`,version:l,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{let e=h.some(e=>e.kind===`host`&&e.outcome===`failed`);o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:l,reason:g?e?`all-writes-failed`:`central-write-failed`:`bundle-unresolved`})}return{outcome:`done`,version:l,entries:h}}async function H(e){let t=e.logger??F,n=e.fs??N,r=e.home??j(),i={...P,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=B(e.projectDir,i,n,t),o=await V(r,i,n,t),s=_(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=y(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function U(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function W(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
2
2
  `)}function G(){return new u(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").option(`-y, --yes`,`Skip the confirmation prompt for removing directories left by a pre-0.42 install.`).action(async e=>{let t=await H({projectDir:C(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null,confirmLegacyCleanup:t=>K(t,{yes:e.yes===!0})});process.stdout.write(`${W(t)}\n`),process.exitCode=U(t)})}async function K(e,t){let n=j(),r=e=>`~/${S(n,e)}`,i=t.input??process.stdin,a=[``,p(`A previous version of OpenKnowledge installed its skill into agent tools you may never have used.`),d(`(Versions before 0.42 wrote to every host a third-party installer knew about — see issue #820.)`)];if(e.skillDirs.length>0&&a.push(``,`${p(`Remove OpenKnowledge skills:`)} ${e.skillDirs.length}`,...e.skillDirs.map(e=>` ${r(e)}`)),e.emptyDirs.length>0){let t=e.skillDirs.length>0?`Then remove these, which hold nothing else once the above are gone:`:`Remove these empty directories, left behind by that install:`;a.push(``,`${p(t)} ${e.emptyDirs.length}`,...e.emptyDirs.map(e=>` ${r(e)}`))}if(a.push(``,d(`Nothing outside these paths is touched. A directory that still holds anything is kept.`)),process.stdout.write(`${a.join(`
3
3
  `)}\n`),t.yes)return!0;if(!i.isTTY)return process.stdout.write(`${f("Not a terminal — skipping cleanup. Re-run with `ok repair-skills --yes` to remove these.")}\n`),!1;let o=M({input:i,output:process.stdout});try{let e=(await o.question(`\n${p(`Remove them?`)} ${d(`[y/N] `)}`)).trim().toLowerCase();return e===`y`||e===`yes`}finally{o.close()}}export{G as n,H as t};
4
- //# sourceMappingURL=repair-skills-pGap1_gF.mjs.map
4
+ //# sourceMappingURL=repair-skills-6KHgz0Jo.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./repair-skills-6KHgz0Jo.mjs";export{e as repairSkills};
@@ -1,2 +1,2 @@
1
- import"./src-B8SfUeFe.mjs";import{r as e}from"./logger-CnfEoHs1.mjs";import{dirname as t,join as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d,writeSync as f}from"node:fs";import{homedir as p,hostname as m}from"node:os";import{randomUUID as h}from"node:crypto";function g(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function _(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function v(e){return new URL(e.url??``,`http://localhost`).searchParams}function y(e){let t=e?.code;return typeof t==`string`?t:void 0}const b=/^[A-Za-z0-9-]{8,64}$/;let x=null;function S(e){return n(e??p(),`.ok`,`machine-id`)}function C(n){if(n===void 0&&x!==null)return x;let r=S(n),i=null;try{let e=l(r,`utf-8`).trim();b.test(e)&&(i=e)}catch{}if(i===null){i=h();try{s(t(r),{recursive:!0}),d(r,`${i}\n`,{encoding:`utf-8`,mode:384})}catch(t){e(`machine-id`).warn({path:r,err:t},`Failed to persist ${r} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${t instanceof Error?t.message:String(t)}`)}}return n===void 0&&(x=i),i}function w(){try{let e=r(t(i(import.meta.url)),`..`,`package.json`),n=JSON.parse(l(e,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}const T=w(),E=1,D=e(`process-lock`);var O=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running at ${e.url??`port ${e.port}`} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function k(e,t){return r(e,`${t}.lock`)}const A=new Map;function j(e){A.set(e,(A.get(e)??0)+1)}function M(e){let t=A.get(e);return t===void 0||t<=1?(A.delete(e),!0):(A.set(e,t-1),!1)}function N(e){return typeof e.machineId==`string`?e.machineId===C():e.hostname===m()}const P=new Set;let F=!1;function I(e){P.add(e),!F&&(F=!0,process.on(`exit`,()=>{for(let e of P)try{let t=JSON.parse(l(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==C()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==m())continue;u(e)}catch{}}))}function L(e,t){try{let n=JSON.parse(l(e,`utf-8`));return n&&typeof n==`object`&&_(n.pid)?n:(D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null}}function R(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;s(n,{recursive:!0});let l=k(n,t),p={pid:process.pid,hostname:m(),port:r.port,...r.url!==void 0&&{url:r.url},startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:C(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??T},h=JSON.stringify(p,null,2);for(let e=0;e<3;e++){if(!o(l))try{let e=c(l,`wx`,384);try{f(e,h)}finally{a(e)}return j(l),I(l),z({lockName:t,lockDir:n,lockPath:l})}catch(e){if(y(e)!==`EEXIST`)throw e}let e=L(l,i);if(e){if(N(e)&&e.pid===process.pid)return d(l,h,{encoding:`utf-8`,mode:384}),j(l),I(l),z({lockName:t,lockDir:n,lockPath:l});if(g(e.pid))throw new O(e,l,t);D.warn({pid:e.pid,host:e.hostname},`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{u(l)}catch{}}throw Error(`${i} Failed to acquire ${l} after 3 attempts (concurrent acquire contention).`)}function z(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>q({lockName:t,lockDir:n}),updatePort:(e,r)=>H({lockName:t,lockDir:n,port:e,url:r})}}function B(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function V(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=B(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}function H(e){let{lockName:t,lockDir:n,port:r,url:i}=e,a=`[${t}-lock]`,s=k(n,t);if(!o(s)){D.warn({lockPath:s},`${a} Lock file missing at ${s} during port update — skipping`);return}let c;try{let e=JSON.parse(l(s,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:s},`${a} Corrupt lock at ${s} during port update — skipping`);return}c=e}catch{D.warn({lockPath:s},`${a} Unreadable lock at ${s} during port update — skipping`);return}if(c.pid===process.pid&&N(c)){c.port=r,i===void 0?delete c.url:c.url=i;try{d(s,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:s,err:e},`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function U(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k(n,t);if((A.get(i)??0)>1)return;let a;try{let e=JSON.parse(l(i,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:i},`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){y(e)!==`ENOENT`&&D.warn({lockPath:i,err:e},`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N(a)&&a.draining!==!0){a.draining=!0;try{d(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:i,err:e},`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function W(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return null;let i;try{let e=JSON.parse(l(r,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid))return null;i=e}catch{return null}if(!N(i))return null;if(!g(i.pid)){try{u(r)}catch{}return null}return i}function G(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return{status:`absent`};let i;try{i=JSON.parse(l(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!_(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let s={pid:a.pid,hostname:a.hostname,port:a.port,url:typeof a.url==`string`?a.url:void 0,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,capabilities:Array.isArray(a.capabilities)&&a.capabilities.every(e=>typeof e==`string`)?a.capabilities:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N(s))return{status:`stale`,lock:s};if(!g(s.pid)){try{u(r)}catch{}return{status:`stale`,lock:s}}return s.protocolVersion===void 0||s.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:s}}async function K(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>W({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function q(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){U({lockName:t,lockDir:n});return}if(o(a))try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N(e))return;u(a),P.delete(a)}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var J=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Y(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new J(e.existing,e.lockPath):e}}function X(e,t,n){H({lockName:`server`,lockDir:e,port:t,url:n})}function Z(e){return W({lockName:`server`,lockDir:e})}function Q(e,t){q({lockName:`server`,lockDir:e,...t})}function $(e){U({lockName:`server`,lockDir:e})}function ee(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,T as _,Q as a,y as b,O as c,k as d,U as f,H as g,q as h,Z as i,R as l,G as m,Y as n,X as o,W as p,$ as r,ee as s,J as t,V as u,E as v,v as x,C as y};
2
- //# sourceMappingURL=server-lock-CyyeFKIF.mjs.map
1
+ import"./src-DiueG9n0.mjs";import{r as e}from"./logger-CnfEoHs1.mjs";import{dirname as t,join as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d,writeSync as f}from"node:fs";import{homedir as p,hostname as m}from"node:os";import{randomUUID as h}from"node:crypto";function g(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function _(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function v(e){return new URL(e.url??``,`http://localhost`).searchParams}function y(e){let t=e?.code;return typeof t==`string`?t:void 0}const b=/^[A-Za-z0-9-]{8,64}$/;let x=null;function S(e){return n(e??p(),`.ok`,`machine-id`)}function C(n){if(n===void 0&&x!==null)return x;let r=S(n),i=null;try{let e=l(r,`utf-8`).trim();b.test(e)&&(i=e)}catch{}if(i===null){i=h();try{s(t(r),{recursive:!0}),d(r,`${i}\n`,{encoding:`utf-8`,mode:384})}catch(t){e(`machine-id`).warn({path:r,err:t},`Failed to persist ${r} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${t instanceof Error?t.message:String(t)}`)}}return n===void 0&&(x=i),i}function w(){try{let e=r(t(i(import.meta.url)),`..`,`package.json`),n=JSON.parse(l(e,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}const T=w(),E=1,D=e(`process-lock`);var O=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running at ${e.url??`port ${e.port}`} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function k(e,t){return r(e,`${t}.lock`)}const A=new Map;function j(e){A.set(e,(A.get(e)??0)+1)}function M(e){let t=A.get(e);return t===void 0||t<=1?(A.delete(e),!0):(A.set(e,t-1),!1)}function N(e){return typeof e.machineId==`string`?e.machineId===C():e.hostname===m()}const P=new Set;let F=!1;function I(e){P.add(e),!F&&(F=!0,process.on(`exit`,()=>{for(let e of P)try{let t=JSON.parse(l(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==C()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==m())continue;u(e)}catch{}}))}function L(e,t){try{let n=JSON.parse(l(e,`utf-8`));return n&&typeof n==`object`&&_(n.pid)?n:(D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null}}function R(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;s(n,{recursive:!0});let l=k(n,t),p={pid:process.pid,hostname:m(),port:r.port,...r.url!==void 0&&{url:r.url},startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:C(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??T},h=JSON.stringify(p,null,2);for(let e=0;e<3;e++){if(!o(l))try{let e=c(l,`wx`,384);try{f(e,h)}finally{a(e)}return j(l),I(l),z({lockName:t,lockDir:n,lockPath:l})}catch(e){if(y(e)!==`EEXIST`)throw e}let e=L(l,i);if(e){if(N(e)&&e.pid===process.pid)return d(l,h,{encoding:`utf-8`,mode:384}),j(l),I(l),z({lockName:t,lockDir:n,lockPath:l});if(g(e.pid))throw new O(e,l,t);D.warn({pid:e.pid,host:e.hostname},`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{u(l)}catch{}}throw Error(`${i} Failed to acquire ${l} after 3 attempts (concurrent acquire contention).`)}function z(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>q({lockName:t,lockDir:n}),updatePort:(e,r)=>H({lockName:t,lockDir:n,port:e,url:r})}}function B(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function V(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=B(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}function H(e){let{lockName:t,lockDir:n,port:r,url:i}=e,a=`[${t}-lock]`,s=k(n,t);if(!o(s)){D.warn({lockPath:s},`${a} Lock file missing at ${s} during port update — skipping`);return}let c;try{let e=JSON.parse(l(s,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:s},`${a} Corrupt lock at ${s} during port update — skipping`);return}c=e}catch{D.warn({lockPath:s},`${a} Unreadable lock at ${s} during port update — skipping`);return}if(c.pid===process.pid&&N(c)){c.port=r,i===void 0?delete c.url:c.url=i;try{d(s,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:s,err:e},`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function U(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k(n,t);if((A.get(i)??0)>1)return;let a;try{let e=JSON.parse(l(i,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:i},`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){y(e)!==`ENOENT`&&D.warn({lockPath:i,err:e},`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N(a)&&a.draining!==!0){a.draining=!0;try{d(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:i,err:e},`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function W(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return null;let i;try{let e=JSON.parse(l(r,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid))return null;i=e}catch{return null}if(!N(i))return null;if(!g(i.pid)){try{u(r)}catch{}return null}return i}function G(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return{status:`absent`};let i;try{i=JSON.parse(l(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!_(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let s={pid:a.pid,hostname:a.hostname,port:a.port,url:typeof a.url==`string`?a.url:void 0,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,capabilities:Array.isArray(a.capabilities)&&a.capabilities.every(e=>typeof e==`string`)?a.capabilities:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N(s))return{status:`stale`,lock:s};if(!g(s.pid)){try{u(r)}catch{}return{status:`stale`,lock:s}}return s.protocolVersion===void 0||s.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:s}}async function K(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>W({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function q(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){U({lockName:t,lockDir:n});return}if(o(a))try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N(e))return;u(a),P.delete(a)}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var J=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Y(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new J(e.existing,e.lockPath):e}}function X(e,t,n){H({lockName:`server`,lockDir:e,port:t,url:n})}function Z(e){return W({lockName:`server`,lockDir:e})}function Q(e,t){q({lockName:`server`,lockDir:e,...t})}function $(e){U({lockName:`server`,lockDir:e})}function ee(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,T as _,Q as a,y as b,O as c,k as d,U as f,H as g,q as h,Z as i,R as l,G as m,Y as n,X as o,W as p,$ as r,ee as s,J as t,V as u,E as v,v as x,C as y};
2
+ //# sourceMappingURL=server-lock-XNc0dGvF.mjs.map
@@ -0,0 +1 @@
1
+ import{a as e,o as t,r as n}from"./server-lock-XNc0dGvF.mjs";export{n as markServerLockDraining,e as releaseServerLock,t as updateServerLockPort};
@@ -1,2 +1,2 @@
1
- import{Cr as e,wr as t}from"./src-DZEg-Zy7.mjs";import{s as n}from"./write-project-skill-DHATTSra.mjs";import{dirname as r,isAbsolute as i,join as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,lstatSync as u,readdirSync as d,rmSync as f,rmdirSync as p}from"node:fs";const m=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],h=[...t.map(t=>e[t]),`open-knowledge`];function g(e){if(!i(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=s(e);if(t===c||r(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function _(e,t){let n=o(e,t);if(n.startsWith(`..`)||i(n))return!1;let r=e;for(let e of n.split(c)){r=a(r,e);try{if(!u(r).isDirectory())return!1}catch{return!1}}return!0}function v(e,t){try{return d(e).every(n=>t.has(a(e,n)))}catch{return!1}}function y(e){let t=g(e),n=[],i=[],o=new Set;for(let e of m){let s=a(t,e.hostDir,`skills`);if(!_(t,s))continue;let u=h.map(e=>a(s,e)).filter(e=>l(e));n.push(...u);for(let e of u)o.add(e);let d=a(t,e.pruneRoot),f=s;for(;v(f,o)&&(i.push(f),o.add(f),f!==d);){let e=r(f);if(e===f||e===t||!e.startsWith(t+c))break;f=e}}return{skillDirs:n,emptyDirs:i}}function b(e){try{if(!u(e).isDirectory())return!1;let t=d(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function x(e){let t=new Set,n=new Set;for(let i of m){let o=a(e,i.hostDir,`skills`);for(let e of h)t.add(a(o,e));let s=a(e,i.pruneRoot),l=o;for(;n.add(l),l!==s;){let t=r(l);if(t===l||t===e||!t.startsWith(e+c))break;l=t}}return{skillDirs:t,emptyDirs:n}}function S(e,t){let n=g(e),r=x(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(_(n,e)&&b(e))try{f(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(_(n,e))try{p(e),a.push(e)}catch{}return a}function C(r){let i=g(r),o=[];for(let r of t){let t=e[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let e of n)o.push({path:a(i,e.hostDir,`skills`,t),bundleId:r,scope:`host`,hostDir:e.hostDir})}return o}function w(e,t){let n=[];for(let r of C(e))if(r.bundleId===t)try{f(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}export{C as i,y as n,w as r,S as t};
2
- //# sourceMappingURL=skill-teardown-DxeHIPsr.mjs.map
1
+ import{Cr as e,wr as t}from"./src-DVc0ORbR.mjs";import{s as n}from"./write-project-skill-B0KKzsOU.mjs";import{dirname as r,isAbsolute as i,join as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,lstatSync as u,readdirSync as d,rmSync as f,rmdirSync as p}from"node:fs";const m=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],h=[...t.map(t=>e[t]),`open-knowledge`];function g(e){if(!i(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=s(e);if(t===c||r(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function _(e,t){let n=o(e,t);if(n.startsWith(`..`)||i(n))return!1;let r=e;for(let e of n.split(c)){r=a(r,e);try{if(!u(r).isDirectory())return!1}catch{return!1}}return!0}function v(e,t){try{return d(e).every(n=>t.has(a(e,n)))}catch{return!1}}function y(e){let t=g(e),n=[],i=[],o=new Set;for(let e of m){let s=a(t,e.hostDir,`skills`);if(!_(t,s))continue;let u=h.map(e=>a(s,e)).filter(e=>l(e));n.push(...u);for(let e of u)o.add(e);let d=a(t,e.pruneRoot),f=s;for(;v(f,o)&&(i.push(f),o.add(f),f!==d);){let e=r(f);if(e===f||e===t||!e.startsWith(t+c))break;f=e}}return{skillDirs:n,emptyDirs:i}}function b(e){try{if(!u(e).isDirectory())return!1;let t=d(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function x(e){let t=new Set,n=new Set;for(let i of m){let o=a(e,i.hostDir,`skills`);for(let e of h)t.add(a(o,e));let s=a(e,i.pruneRoot),l=o;for(;n.add(l),l!==s;){let t=r(l);if(t===l||t===e||!t.startsWith(e+c))break;l=t}}return{skillDirs:t,emptyDirs:n}}function S(e,t){let n=g(e),r=x(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(_(n,e)&&b(e))try{f(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(_(n,e))try{p(e),a.push(e)}catch{}return a}function C(r){let i=g(r),o=[];for(let r of t){let t=e[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let e of n)o.push({path:a(i,e.hostDir,`skills`,t),bundleId:r,scope:`host`,hostDir:e.hostDir})}return o}function w(e,t){let n=[];for(let r of C(e))if(r.bundleId===t)try{f(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}export{C as i,y as n,w as r,S as t};
2
+ //# sourceMappingURL=skill-teardown-B6HJfl80.mjs.map
@@ -1 +1 @@
1
- import{Cs as e,F as t,Xo as n,Xs as r,Zo as i,d as a,ds as o,p as s,ps as c,qo as l,z as u}from"./src-B8SfUeFe.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Bt as w,C as T,Ca as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Fr as W,Ft as G,G as K,Gi as q,Gn as J,Gr as Y,Gt as X,H as Z,Hi as Q,Hn as $,Hr as ee,Ht as te,I as ne,Ii as re,In as ie,It as ae,J as oe,Ji as se,Jn as ce,Jr as le,Jt as ue,K as de,Ki as fe,Kn as pe,Kr as me,Kt as he,L as ge,Li as _e,Ln as ve,Lt as ye,M as be,Mi as xe,Mn as Se,Mr as Ce,Mt as we,N as Te,Ni as Ee,Nn as De,Nr as Oe,Nt as ke,O as Ae,Oi as je,On as Me,Or as Ne,Ot as Pe,P as Fe,Pi as Ie,Pn as Le,Pr as Re,Pt as ze,Q as Be,Qi as Ve,Qn as He,Qr as Ue,Qt as We,R as Ge,Ri as Ke,Rn as qe,Rt as Je,S as Ye,Sa as Xe,Si as Ze,Sn as Qe,Sr as $e,St as et,T as tt,Ti as nt,Tn as rt,Tr as it,Tt as at,U as ot,Ui as st,Un as ct,Ur as lt,Ut as ut,V as dt,Vi as ft,Vn as pt,Vr as mt,Vt as ht,W as gt,Wi as _t,Wn as vt,Wr as yt,Wt as bt,X as xt,Xi as St,Xn as Ct,Xr as wt,Xt as Tt,Y as Et,Yi as Dt,Yn as Ot,Yr as kt,Yt as At,Z as jt,Zi as Mt,Zn as Nt,Zr as Pt,Zt as Ft,_ as It,_a as Lt,_i as Rt,_n as zt,_r as Bt,_t as Vt,a as Ht,aa as Ut,ai as Wt,an as Gt,ar as Kt,at as qt,b as Jt,ba as Yt,bi as Xt,bn as Zt,br as Qt,bt as $t,c as en,ca as tn,ci as nn,cn as rn,cr as an,d as on,da as sn,di as cn,dn as ln,dr as un,ea as dn,ei as fn,en as pn,er as mn,et as hn,f as gn,fa as _n,fi as vn,fn as yn,fr as bn,g as xn,ga as Sn,gi as Cn,gn as wn,gr as Tn,gt as En,h as Dn,ha as On,hi as kn,hn as An,hr as jn,ht as Mn,i as Nn,ia as Pn,ii as Fn,in as In,ir as Ln,it as Rn,j as zn,ji as Bn,jn as Vn,jr as Hn,jt as Un,k as Wn,ki as Gn,kn as Kn,kr as qn,kt as Jn,l as Yn,la as Xn,li as Zn,ln as Qn,lr as $n,m as er,ma as tr,mi as nr,mn as rr,mr as ir,mt as ar,n as or,na as sr,ni as cr,nn as lr,nr as ur,nt as dr,o as fr,oa as pr,oi as mr,on as hr,or as gr,ot as _r,p as vr,pa as yr,pi as br,pn as xr,pr as Sr,q as Cr,qi as wr,qn as Tr,qr as Er,qt as Dr,r as Or,ra as kr,ri as Ar,rn as jr,rr as Mr,rt as Nr,s as Pr,sa as Fr,si as Ir,sn as Lr,sr as Rr,st as zr,t as Br,ta as Vr,ti as Hr,tn as Ur,tr as Wr,tt as Gr,u as Kr,ua as qr,ui as Jr,un as Yr,ur as Xr,v as Zr,va as Qr,vi as $r,vn as ei,vr as ti,vt as ni,w as ri,wi as ii,wn as ai,wr as oi,wt as si,x as ci,xa as li,xn as ui,xr as di,xt as fi,y as pi,ya as mi,yi as hi,yn as gi,yr as _i,yt as vi,z as yi,zi as bi,zn as xi,zt as Si}from"./src-DZEg-Zy7.mjs";import{C as Ci,E as wi,T as Ti,_ as Ei,b as Di,c as Oi,d as ki,g as Ai,i as ji,l as Mi,m as Ni,n as Pi,p as Fi,s as Ii,t as Li,u as Ri,v as zi,w as Bi,x as Vi,y as Hi}from"./fs-traced-RPXwxrA5.mjs";import{a as Ui,d as Wi,f as Gi,i as Ki,l as qi,n as Ji,r as Yi,t as Xi,u as Zi}from"./logger-CnfEoHs1.mjs";import{C as Qi,S as $i,_ as ea,a as ta,c as na,d as ra,g as ia,h as aa,i as oa,l as sa,m as ca,n as la,o as ua,p as da,r as fa,s as pa,t as ma,u as ha,v as ga,y as _a}from"./server-lock-CyyeFKIF.mjs";export{tr as AGENT_ID_MAX_LEN,On as AGENT_ID_RE,_ as AGENT_WRITE_ORIGIN,li as AcpPermissionStore,Qr as AcpRegistry,nt as AcpThreadManager,D as AgentFocusBroadcaster,Ze as AgentPresenceBroadcaster,Bn as AgentSessionCapacityError,xe as AgentSessionManager,Mn as AutoStartDisabledError,di as BUNDLE_IDS,$e as BUNDLE_SCOPE,k as BUNDLE_SKILL_NAME,Ct as BacklinkIndex,Q as CC1Broadcaster,c as CC1_CONTRACT_VERSION,Yr as CONFIG_FILENAME,vt as CONFLICT_MARKER_RE,lt as CURSOR_BUNDLE_PATHS_BY_PLATFORM,It as ConfigSchema,se as DEFAULT_CHECKPOINT_RETENTION,nn as DEFAULT_EMBEDDINGS_DIMENSIONS,G as DEFAULT_PACK_ID,dt as DocumentDurabilityState,Zn as EMBEDDINGS_API_KEY_ENV,ei as ExposureConsentError,mi as FEATURED_AGENT_IDS,Dt as FILE_SYSTEM_WRITER,ce as FILE_WATCHER_ORIGIN,cr as FileEmbeddingsBackend,Ft as GIT_PREFLIGHT_FAIL_SPAN_NAME,St as GIT_UPSTREAM_WRITER,Xe as GitDirAccessError,h as GitNotAvailableError,pn as GitTooOldError,En as HOCUSPOCUS_AUTH_REJECTION_REASONS,Vt as HocuspocusAuthRejection,ni as HocuspocusAuthTokenSchema,kt as INSTALLED_AGENTS_SCHEMES,o as LINEAGE_EPOCH_KEY,Ge as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ae as LOG_MD_TEMPLATE,at as MANAGED_RENAME_ORIGIN,L as MAX_ACP_THREADS,Ee as MAX_AGENT_SESSIONS,je as MCP_CONNECTION_ID_HEADER,l as MCP_SERVER_NAME,Ie as MIN_EVICTABLE_IDLE_MS,Ur as MIN_GIT_VERSION,Z as MISSING_OK_CONFIG_MESSAGE,E as MalformedGitPointerError,hn as McpLogger,ot as MissingOkConfigError,re as OBSERVER_SYNC_ORIGIN,ln as OK_OKIGNORE_TEMPLATE,n as ORPHAN_MODES,r as PROTOCOL_VERSION,Xi as PinoLogger,na as ProcessLockCollisionError,Yn as ProjectGitInitError,B as ROLLBACK_ORIGIN,yn as ROOT_GITIGNORE_TEMPLATE,ea as RUNTIME_VERSION,Mt as SERVICE_WRITER,Tn as SKILL_INSTALL_EVENTS_FILE_REL,t as SKILL_STATE_TARGETS,ye as STARTER_FOLDERS,Je as STARTER_FOLDER_FRONTMATTER_FILENAME,Si as STARTER_PACKS,w as STARTER_PACK_IDS,ht as STARTER_TEMPLATES,tt as STATE_MANIFEST_FILENAME,ga as STATE_SCHEMA_VERSION,e as SYSTEM_DOC_NAME,Dr as SeedPrerequisiteError,ue as SeedRootDirError,ma as ServerLockCollisionError,Br as SingleFileNotAFileError,or as SingleFileNotFoundError,Or as SingleFileNotMarkdownError,I as StateManifestError,Ot as TagIndex,oi as USER_GLOBAL_BUNDLE_IDS,He as UiLockCollisionError,F as __getShowAllWalkStatsForTesting,Pe as __resetShowAllWalkStatsForTesting,sa as acquireProcessLock,la as acquireServerLock,p as acquireUiLock,H as applyAgentMarkdownWrite,$ as applyExternalChange,ze as applySeed,j as assertCompatibleStateManifest,lr as assertGitAvailable,v as assertNeverDiskEvent,ii as attachAcpThreadSocket,ar as attachIdleShutdown,Zr as bootServer,Mr as buildAndOpenSkill,xr as buildConfigYmlContent,Et as buildExecResult,gi as buildIngressPolicy,M as buildOkMcpStdioCommand,ti as buildSkillZip,te as buildStarterFolderFrontmatterYaml,Ve as buildWipTree,it as bundleSkillMdPath,Ar as canonicalProjectKey,Vn as classifyEvents,Li as classifyFsPath,Fn as clearAllEmbeddingsKeys,cn as clearContributors,ut as coercePackId,a as colorFromSeed,f as commitUpstreamImport,dn as commitWip,Vr as commitWipFromTree,jr as compareSemver,Ne as composeEffectiveLinterConfig,qn as composeFrontmatterSchemasConfig,J as containsConflictMarkers,Se as contentHash,vn as contributorCount,Fe as countShadowObjects,V as countStaleAgentWipRefs,ne as countWipRefs,Jn as createApiExtension,si as createAssetServeMiddleware,K as createCollaborationHost,mt as createContentFilter,ee as createContentFilterAsync,Wt as createEmbeddingsSecretStore,Nn as createEphemeralProjectDir,ct as createExternalChangeHandler,gn as createFileLogger,yi as createLiveDerivedIndexExtension,Cr as createMcpHttpHandler,wt as createOsProbe,Te as createPersistenceExtension,T as createServer,zn as createServerObserverExtension,bi as createStreamingErrorWriter,Ji as createTestLogger,mr as describeStoredEmbeddingsKey,xn as detectClaudeDesktopPresence,In as detectGit,Ae as detectProjectShape,Ln as detectUserSkillHosts,Nr as discoverLockDirs,Ce as discoverMarkdownlintConfig,We as emitPreflightFailureSpan,xt as encodeDocName,jt as encodeFolderRoute,Be as encodeSkillRoute,Kr as ensureProjectGit,rr as ensureProjectSkillGitignore,S as errorResponse,De as evictStaleTrackerEntries,b as extractHeadings,Rn as extractOkBinaryPath,Nt as extractWikiLinksFromMarkdown,Gt as fallbackPaths,on as findEnclosingGitRoot,Me as findEnclosingProjectRoot,Oe as findNativeMarkdownlintFile,vr as flushFileLogger,vi as formatAuthRejectionWire,br as formatContributors,nr as formatContributorsFrom,we as formatPackRationale,sr as gcCheckpointRefs,Gr as getCurrentMcpLogger,Zt as getIngressContext,$r as getLocalDir,er as getLogFilePath,Yi as getLogger,Dn as getLogsDir,_a as getMachineId,Hi as getMeter,Xn as getMetrics,Di as getTracer,qr as handleCollabSocketError,yt as handleSpawnCursor,ui as hasForwardingHeaders,ge as hasGcLogLatch,s as iconFromClientName,sn as incrementCollabSocketFilteredError,_n as incrementServerObserverFire,An as initContent,kr as initShadowRepo,Vi as initTelemetry,Jt as initToleranceTelemetryWriter,zr as installPrettyZodErrors,Ki as installTestLoggers,Kt as installUserSkill,N as isAllowedApiOrigin,rt as isAllowedWorkspaceHostHeader,st as isConfigDoc,$t as isHocuspocusAuthRejectionReason,Qe as isHostAdmitted,bt as isKnownPackId,_t as isLinkIndexExcludedDoc,R as isLoopbackAddress,q as isManagedArtifactDoc,O as isOriginAdmitted,i as isOrphanMode,_e as isPairedWriteOrigin,Y as isPathWithinDir,ai as isPeerAdmitted,$i as isProcessAlive,Kn as isProjectRoot,fe as isReservedForUserTree,Le as isSelfWrite,wr as isSystemDoc,ci as isToleranceTelemetryEnabled,Qi as isValidLockPid,U as lastKnownHash,Pn as listRescueCheckpoints,X as listStarterPacks,Yt as loadCustomAgents,be as loadPrincipal,ha as lockBaseUrl,ra as lockFilePath,Ui as loggerFactory,qi as logsCurrentPath,Zi as logsPreviousPath,Ir as makeLazyEmbeddingsKeyStore,fa as markServerLockDraining,gt as mountMcpAndApi,Pi as normalizeFsPath,z as originGitHubHost,wn as packageVersionMajorMinor,fi as parseAuthRejectionWire,hr as parseGitVersion,et as parseHocuspocusAuthToken,de as parseKeepaliveConnectionId,ie as pathToDocName,ke as planSeed,Ht as prepareSingleFileOpen,qt as processCommand,_r as processUsage,Rr as readAllTargets,an as readBundleDecision,Re as readOwnNativeRules,da as readProcessLock,ca as readProcessLockDetailed,x as readProjectHeadState,Hr as readProjectLocalSemanticConfig,oa as readServerLock,$n as readServerPackageVersion,Xr as readSkillInstallStateSnapshot,Wn as readStateManifest,un as readTargetRecordedAt,bn as readTargetVersion,mn as readUiLock,pe as reconcile,kn as recordContributor,Bt as recordSkillInstallEvent,oe as registerAllTools,ve as registerWrite,aa as releaseProcessLock,ta as releaseServerLock,Wr as releaseUiLock,qe as removeLastKnownHash,gr as reportSkillInstall,yr as resetMetrics,u as resolveBundleEnabled,_i as resolveBundledSkillDir,hi as resolveContentDir,me as resolveCursorBinaryDefault,Er as resolveCursorSpawnInvocation,y as resolveEffectiveLinterConfig,Jr as resolveEmbeddingsCredential,Xt as resolveLockDir,Hn as resolveNativeConfigForDoc,W as resolveNativeMarkdownlintConfig,he as resolvePack,Pr as resolvePackageVersion,jn as resolveSkillInstallReportSettings,d as resolveUiInfo,Cn as restoreContributors,pi as restoreLifecycleFromConflictsJson,m as rewriteMarkdownLinksForDocumentRename,fn as rewriteWikiLinksForDocumentRename,Lr as runAuthReposSubprocess,rn as runAuthStatusSubprocess,At as runCloneSubprocess,Qn as runDeviceFlowSubprocess,dr as runWithMcpLogger,Ue as safeContentPath,Un as safeSubdir,Ut as safetyCheckpoint,Gn as sanitizeClientName,pr as saveInMemoryCheckpoint,Fr as saveVersion,A as seedBasenameIndex,fr as serializeError,Ci as setActiveSpanAttributes,Ke as setupServerObservers,tn as shadowGit,Bi as shutdownTelemetry,Wi as spansCurrentPath,Gi as spansPreviousPath,le as spawnDetached,Tr as splitMarkdownBlocks,xi as startWatcher,ft as streamingProblemEvent,Rt as swapContributors,Ye as teardownToleranceTelemetryWriter,Sn as toBroadcasterKey,ji as tracedAppendFileSync,Ii as tracedLinkSync,Oi as tracedMkdir,Mi as tracedMkdirSync,Ri as tracedRename,ki as tracedRenameSync,Fi as tracedRmSync,Ni as tracedRmdirSync,Ai as tracedUnlinkSync,Ei as tracedWriteFile,zi as tracedWriteFileSync,ri as trustSystemCertificates,en as untrackTrackedProjectSkillProjection,C as updateLastKnownHash,ia as updateProcessLockPort,ua as updateServerLockPort,ur as updateUiLockPort,Lt as validateAgentId,Tt as validateCloneInputs,Qt as validateSkillZip,pa as waitForServerLockDrain,Pt as withHiddenWindowsConsole,Ti as withSpan,wi as withSpanSync,Sr as writeBundleDecision,P as writeMarkdownlintRule,zt as writeRootGitignoreForNewRepo,g as writeStateManifest,ir as writeTargetVersion,pt as writeTracker};
1
+ import{$o as e,$s as t,Es as n,F as r,Xo as i,d as a,es as o,gs as s,ms as c,p as l,z as u}from"./src-DiueG9n0.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Bt as w,C as T,Ca as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Fr as W,Ft as G,G as K,Gi as q,Gn as J,Gr as Y,Gt as X,H as Z,Hi as Q,Hn as $,Hr as ee,Ht as te,I as ne,Ii as re,In as ie,It as ae,J as oe,Ji as se,Jn as ce,Jr as le,Jt as ue,K as de,Ki as fe,Kn as pe,Kr as me,Kt as he,L as ge,Li as _e,Ln as ve,Lt as ye,M as be,Mi as xe,Mn as Se,Mr as Ce,Mt as we,N as Te,Ni as Ee,Nn as De,Nr as Oe,Nt as ke,O as Ae,Oi as je,On as Me,Or as Ne,Ot as Pe,P as Fe,Pi as Ie,Pn as Le,Pr as Re,Pt as ze,Q as Be,Qi as Ve,Qn as He,Qr as Ue,Qt as We,R as Ge,Ri as Ke,Rn as qe,Rt as Je,S as Ye,Sa as Xe,Si as Ze,Sn as Qe,Sr as $e,St as et,T as tt,Ti as nt,Tn as rt,Tr as it,Tt as at,U as ot,Ui as st,Un as ct,Ur as lt,Ut as ut,V as dt,Vi as ft,Vn as pt,Vr as mt,Vt as ht,W as gt,Wi as _t,Wn as vt,Wr as yt,Wt as bt,X as xt,Xi as St,Xn as Ct,Xr as wt,Xt as Tt,Y as Et,Yi as Dt,Yn as Ot,Yr as kt,Yt as At,Z as jt,Zi as Mt,Zn as Nt,Zr as Pt,Zt as Ft,_ as It,_a as Lt,_i as Rt,_n as zt,_r as Bt,_t as Vt,a as Ht,aa as Ut,ai as Wt,an as Gt,ar as Kt,at as qt,b as Jt,ba as Yt,bi as Xt,bn as Zt,br as Qt,bt as $t,c as en,ca as tn,ci as nn,cn as rn,cr as an,d as on,da as sn,di as cn,dn as ln,dr as un,ea as dn,ei as fn,en as pn,er as mn,et as hn,f as gn,fa as _n,fi as vn,fn as yn,fr as bn,g as xn,ga as Sn,gi as Cn,gn as wn,gr as Tn,gt as En,h as Dn,ha as On,hi as kn,hn as An,hr as jn,ht as Mn,i as Nn,ia as Pn,ii as Fn,in as In,ir as Ln,it as Rn,j as zn,ji as Bn,jn as Vn,jr as Hn,jt as Un,k as Wn,ki as Gn,kn as Kn,kr as qn,kt as Jn,l as Yn,la as Xn,li as Zn,ln as Qn,lr as $n,m as er,ma as tr,mi as nr,mn as rr,mr as ir,mt as ar,n as or,na as sr,ni as cr,nn as lr,nr as ur,nt as dr,o as fr,oa as pr,oi as mr,on as hr,or as gr,ot as _r,p as vr,pa as yr,pi as br,pn as xr,pr as Sr,q as Cr,qi as wr,qn as Tr,qr as Er,qt as Dr,r as Or,ra as kr,ri as Ar,rn as jr,rr as Mr,rt as Nr,s as Pr,sa as Fr,si as Ir,sn as Lr,sr as Rr,st as zr,t as Br,ta as Vr,ti as Hr,tn as Ur,tr as Wr,tt as Gr,u as Kr,ua as qr,ui as Jr,un as Yr,ur as Xr,v as Zr,va as Qr,vi as $r,vn as ei,vr as ti,vt as ni,w as ri,wi as ii,wn as ai,wr as oi,wt as si,x as ci,xa as li,xn as ui,xr as di,xt as fi,y as pi,ya as mi,yi as hi,yn as gi,yr as _i,yt as vi,z as yi,zi as bi,zn as xi,zt as Si}from"./src-DVc0ORbR.mjs";import{C as Ci,E as wi,T as Ti,_ as Ei,b as Di,c as Oi,d as ki,g as Ai,i as ji,l as Mi,m as Ni,n as Pi,p as Fi,s as Ii,t as Li,u as Ri,v as zi,w as Bi,x as Vi,y as Hi}from"./fs-traced-RPXwxrA5.mjs";import{a as Ui,d as Wi,f as Gi,i as Ki,l as qi,n as Ji,r as Yi,t as Xi,u as Zi}from"./logger-CnfEoHs1.mjs";import{C as Qi,S as $i,_ as ea,a as ta,c as na,d as ra,g as ia,h as aa,i as oa,l as sa,m as ca,n as la,o as ua,p as da,r as fa,s as pa,t as ma,u as ha,v as ga,y as _a}from"./server-lock-XNc0dGvF.mjs";export{tr as AGENT_ID_MAX_LEN,On as AGENT_ID_RE,_ as AGENT_WRITE_ORIGIN,li as AcpPermissionStore,Qr as AcpRegistry,nt as AcpThreadManager,D as AgentFocusBroadcaster,Ze as AgentPresenceBroadcaster,Bn as AgentSessionCapacityError,xe as AgentSessionManager,Mn as AutoStartDisabledError,di as BUNDLE_IDS,$e as BUNDLE_SCOPE,k as BUNDLE_SKILL_NAME,Ct as BacklinkIndex,Q as CC1Broadcaster,s as CC1_CONTRACT_VERSION,Yr as CONFIG_FILENAME,vt as CONFLICT_MARKER_RE,lt as CURSOR_BUNDLE_PATHS_BY_PLATFORM,It as ConfigSchema,se as DEFAULT_CHECKPOINT_RETENTION,nn as DEFAULT_EMBEDDINGS_DIMENSIONS,G as DEFAULT_PACK_ID,dt as DocumentDurabilityState,Zn as EMBEDDINGS_API_KEY_ENV,ei as ExposureConsentError,mi as FEATURED_AGENT_IDS,Dt as FILE_SYSTEM_WRITER,ce as FILE_WATCHER_ORIGIN,cr as FileEmbeddingsBackend,Ft as GIT_PREFLIGHT_FAIL_SPAN_NAME,St as GIT_UPSTREAM_WRITER,Xe as GitDirAccessError,h as GitNotAvailableError,pn as GitTooOldError,En as HOCUSPOCUS_AUTH_REJECTION_REASONS,Vt as HocuspocusAuthRejection,ni as HocuspocusAuthTokenSchema,kt as INSTALLED_AGENTS_SCHEMES,c as LINEAGE_EPOCH_KEY,Ge as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ae as LOG_MD_TEMPLATE,at as MANAGED_RENAME_ORIGIN,L as MAX_ACP_THREADS,Ee as MAX_AGENT_SESSIONS,je as MCP_CONNECTION_ID_HEADER,i as MCP_SERVER_NAME,Ie as MIN_EVICTABLE_IDLE_MS,Ur as MIN_GIT_VERSION,Z as MISSING_OK_CONFIG_MESSAGE,E as MalformedGitPointerError,hn as McpLogger,ot as MissingOkConfigError,re as OBSERVER_SYNC_ORIGIN,ln as OK_OKIGNORE_TEMPLATE,e as ORPHAN_MODES,t as PROTOCOL_VERSION,Xi as PinoLogger,na as ProcessLockCollisionError,Yn as ProjectGitInitError,B as ROLLBACK_ORIGIN,yn as ROOT_GITIGNORE_TEMPLATE,ea as RUNTIME_VERSION,Mt as SERVICE_WRITER,Tn as SKILL_INSTALL_EVENTS_FILE_REL,r as SKILL_STATE_TARGETS,ye as STARTER_FOLDERS,Je as STARTER_FOLDER_FRONTMATTER_FILENAME,Si as STARTER_PACKS,w as STARTER_PACK_IDS,ht as STARTER_TEMPLATES,tt as STATE_MANIFEST_FILENAME,ga as STATE_SCHEMA_VERSION,n as SYSTEM_DOC_NAME,Dr as SeedPrerequisiteError,ue as SeedRootDirError,ma as ServerLockCollisionError,Br as SingleFileNotAFileError,or as SingleFileNotFoundError,Or as SingleFileNotMarkdownError,I as StateManifestError,Ot as TagIndex,oi as USER_GLOBAL_BUNDLE_IDS,He as UiLockCollisionError,F as __getShowAllWalkStatsForTesting,Pe as __resetShowAllWalkStatsForTesting,sa as acquireProcessLock,la as acquireServerLock,p as acquireUiLock,H as applyAgentMarkdownWrite,$ as applyExternalChange,ze as applySeed,j as assertCompatibleStateManifest,lr as assertGitAvailable,v as assertNeverDiskEvent,ii as attachAcpThreadSocket,ar as attachIdleShutdown,Zr as bootServer,Mr as buildAndOpenSkill,xr as buildConfigYmlContent,Et as buildExecResult,gi as buildIngressPolicy,M as buildOkMcpStdioCommand,ti as buildSkillZip,te as buildStarterFolderFrontmatterYaml,Ve as buildWipTree,it as bundleSkillMdPath,Ar as canonicalProjectKey,Vn as classifyEvents,Li as classifyFsPath,Fn as clearAllEmbeddingsKeys,cn as clearContributors,ut as coercePackId,a as colorFromSeed,f as commitUpstreamImport,dn as commitWip,Vr as commitWipFromTree,jr as compareSemver,Ne as composeEffectiveLinterConfig,qn as composeFrontmatterSchemasConfig,J as containsConflictMarkers,Se as contentHash,vn as contributorCount,Fe as countShadowObjects,V as countStaleAgentWipRefs,ne as countWipRefs,Jn as createApiExtension,si as createAssetServeMiddleware,K as createCollaborationHost,mt as createContentFilter,ee as createContentFilterAsync,Wt as createEmbeddingsSecretStore,Nn as createEphemeralProjectDir,ct as createExternalChangeHandler,gn as createFileLogger,yi as createLiveDerivedIndexExtension,Cr as createMcpHttpHandler,wt as createOsProbe,Te as createPersistenceExtension,T as createServer,zn as createServerObserverExtension,bi as createStreamingErrorWriter,Ji as createTestLogger,mr as describeStoredEmbeddingsKey,xn as detectClaudeDesktopPresence,In as detectGit,Ae as detectProjectShape,Ln as detectUserSkillHosts,Nr as discoverLockDirs,Ce as discoverMarkdownlintConfig,We as emitPreflightFailureSpan,xt as encodeDocName,jt as encodeFolderRoute,Be as encodeSkillRoute,Kr as ensureProjectGit,rr as ensureProjectSkillGitignore,S as errorResponse,De as evictStaleTrackerEntries,b as extractHeadings,Rn as extractOkBinaryPath,Nt as extractWikiLinksFromMarkdown,Gt as fallbackPaths,on as findEnclosingGitRoot,Me as findEnclosingProjectRoot,Oe as findNativeMarkdownlintFile,vr as flushFileLogger,vi as formatAuthRejectionWire,br as formatContributors,nr as formatContributorsFrom,we as formatPackRationale,sr as gcCheckpointRefs,Gr as getCurrentMcpLogger,Zt as getIngressContext,$r as getLocalDir,er as getLogFilePath,Yi as getLogger,Dn as getLogsDir,_a as getMachineId,Hi as getMeter,Xn as getMetrics,Di as getTracer,qr as handleCollabSocketError,yt as handleSpawnCursor,ui as hasForwardingHeaders,ge as hasGcLogLatch,l as iconFromClientName,sn as incrementCollabSocketFilteredError,_n as incrementServerObserverFire,An as initContent,kr as initShadowRepo,Vi as initTelemetry,Jt as initToleranceTelemetryWriter,zr as installPrettyZodErrors,Ki as installTestLoggers,Kt as installUserSkill,N as isAllowedApiOrigin,rt as isAllowedWorkspaceHostHeader,st as isConfigDoc,$t as isHocuspocusAuthRejectionReason,Qe as isHostAdmitted,bt as isKnownPackId,_t as isLinkIndexExcludedDoc,R as isLoopbackAddress,q as isManagedArtifactDoc,O as isOriginAdmitted,o as isOrphanMode,_e as isPairedWriteOrigin,Y as isPathWithinDir,ai as isPeerAdmitted,$i as isProcessAlive,Kn as isProjectRoot,fe as isReservedForUserTree,Le as isSelfWrite,wr as isSystemDoc,ci as isToleranceTelemetryEnabled,Qi as isValidLockPid,U as lastKnownHash,Pn as listRescueCheckpoints,X as listStarterPacks,Yt as loadCustomAgents,be as loadPrincipal,ha as lockBaseUrl,ra as lockFilePath,Ui as loggerFactory,qi as logsCurrentPath,Zi as logsPreviousPath,Ir as makeLazyEmbeddingsKeyStore,fa as markServerLockDraining,gt as mountMcpAndApi,Pi as normalizeFsPath,z as originGitHubHost,wn as packageVersionMajorMinor,fi as parseAuthRejectionWire,hr as parseGitVersion,et as parseHocuspocusAuthToken,de as parseKeepaliveConnectionId,ie as pathToDocName,ke as planSeed,Ht as prepareSingleFileOpen,qt as processCommand,_r as processUsage,Rr as readAllTargets,an as readBundleDecision,Re as readOwnNativeRules,da as readProcessLock,ca as readProcessLockDetailed,x as readProjectHeadState,Hr as readProjectLocalSemanticConfig,oa as readServerLock,$n as readServerPackageVersion,Xr as readSkillInstallStateSnapshot,Wn as readStateManifest,un as readTargetRecordedAt,bn as readTargetVersion,mn as readUiLock,pe as reconcile,kn as recordContributor,Bt as recordSkillInstallEvent,oe as registerAllTools,ve as registerWrite,aa as releaseProcessLock,ta as releaseServerLock,Wr as releaseUiLock,qe as removeLastKnownHash,gr as reportSkillInstall,yr as resetMetrics,u as resolveBundleEnabled,_i as resolveBundledSkillDir,hi as resolveContentDir,me as resolveCursorBinaryDefault,Er as resolveCursorSpawnInvocation,y as resolveEffectiveLinterConfig,Jr as resolveEmbeddingsCredential,Xt as resolveLockDir,Hn as resolveNativeConfigForDoc,W as resolveNativeMarkdownlintConfig,he as resolvePack,Pr as resolvePackageVersion,jn as resolveSkillInstallReportSettings,d as resolveUiInfo,Cn as restoreContributors,pi as restoreLifecycleFromConflictsJson,m as rewriteMarkdownLinksForDocumentRename,fn as rewriteWikiLinksForDocumentRename,Lr as runAuthReposSubprocess,rn as runAuthStatusSubprocess,At as runCloneSubprocess,Qn as runDeviceFlowSubprocess,dr as runWithMcpLogger,Ue as safeContentPath,Un as safeSubdir,Ut as safetyCheckpoint,Gn as sanitizeClientName,pr as saveInMemoryCheckpoint,Fr as saveVersion,A as seedBasenameIndex,fr as serializeError,Ci as setActiveSpanAttributes,Ke as setupServerObservers,tn as shadowGit,Bi as shutdownTelemetry,Wi as spansCurrentPath,Gi as spansPreviousPath,le as spawnDetached,Tr as splitMarkdownBlocks,xi as startWatcher,ft as streamingProblemEvent,Rt as swapContributors,Ye as teardownToleranceTelemetryWriter,Sn as toBroadcasterKey,ji as tracedAppendFileSync,Ii as tracedLinkSync,Oi as tracedMkdir,Mi as tracedMkdirSync,Ri as tracedRename,ki as tracedRenameSync,Fi as tracedRmSync,Ni as tracedRmdirSync,Ai as tracedUnlinkSync,Ei as tracedWriteFile,zi as tracedWriteFileSync,ri as trustSystemCertificates,en as untrackTrackedProjectSkillProjection,C as updateLastKnownHash,ia as updateProcessLockPort,ua as updateServerLockPort,ur as updateUiLockPort,Lt as validateAgentId,Tt as validateCloneInputs,Qt as validateSkillZip,pa as waitForServerLockDrain,Pt as withHiddenWindowsConsole,Ti as withSpan,wi as withSpanSync,Sr as writeBundleDecision,P as writeMarkdownlintRule,zt as writeRootGitignoreForNewRepo,g as writeStateManifest,ir as writeTargetVersion,pt as writeTracker};
@@ -0,0 +1 @@
1
+ import"./src-DiueG9n0.mjs";import"./src-CfKlTuR4.mjs";import"./acp-harness-probe-BsrCm6PN.mjs";import"./init-FysoPMTz.mjs";import"./write-project-skill-B0KKzsOU.mjs";import{n as e}from"./loader-D9ASHd7b.mjs";import"./skill-teardown-B6HJfl80.mjs";import"./preview-C3WQiD83.mjs";import"./mcp-migrate-event-BsswfOLm.mjs";export{e as loadConfig};
@@ -1,12 +1,12 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sleep-ChZE9826.mjs";import{Ks as i,Q as a,Xa as o,Z as s,qs as c}from"./src-B8SfUeFe.mjs";import{On as l,Zr as u,at as d,bi as f,it as p,ot as m,rt as h}from"./src-DZEg-Zy7.mjs";import{D as g,F as _,I as v,k as y}from"./fs-traced-RPXwxrA5.mjs";import{C as b,S as x,d as S,y as C}from"./server-lock-CyyeFKIF.mjs";import{t as w}from"./yazl-DZr4PyKA.mjs";import{t as T}from"./esm-DmX1RzAi.mjs";import{c as E}from"./colors-BsmVIwfM.mjs";import{n as D}from"./acp-harness-probe-8Sj9j5_f.mjs";import{E as ee,T as O,_ as k,o as A,w as j,x as M,y as N}from"./init-DyUOE5zl.mjs";import{n as te}from"./constants-B_VMjNrS.mjs";import{t as P}from"./is-object-ByG7RnjH.mjs";import{m as ne,p as re}from"./write-project-skill-DHATTSra.mjs";import"./loader-DGh4bdW9.mjs";import"./skill-teardown-DxeHIPsr.mjs";import"./preview-BbSnbtj5.mjs";import{execSync as ie,spawnSync as ae}from"node:child_process";import{basename as F,dirname as I,join as L,relative as oe,resolve as R,sep as se}from"node:path";import{cpSync as ce,createWriteStream as le,existsSync as z,lstatSync as ue,mkdirSync as B,mkdtempSync as de,readFileSync as V,readdirSync as H,readlinkSync as fe,rmSync as U,statSync as pe,writeFileSync as W}from"node:fs";import{arch as me,freemem as he,homedir as G,hostname as ge,platform as _e,release as ve,tmpdir as ye,totalmem as be,type as xe,uptime as Se}from"node:os";import"node:fs/promises";import{createHash as Ce}from"node:crypto";var we=n();const Te=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Ee(e,t,n=l){if(e!==void 0&&!Te.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let De=null;function Oe(e){De=e}function ke(){return De??process.cwd()}function Ae(){return L(G(),`.ok`,`bug-reports`)}function je(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Ae(),r=`${t}-bugreport`,i=L(n,`${r}.zip`);for(let e=2;z(i);e+=1)i=L(n,`${r}-${e}.zip`);return i}function Me(e,t){let n=L(e,`.ok`,`config.yml`);if(z(n))try{let e=V(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return z(L(e,`.ok`))?Ce(`sha256`).update(R(e)).digest(`hex`).slice(0,12):null}function Ne(){let e={timestamp:new Date().toISOString(),platform:_e(),osType:xe(),osRelease:ve(),hostname:`[redacted]`,uptime:Se(),freeMem:he(),totalMem:be(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ie(`sw_vers -productVersion 2>/dev/null`,u({encoding:`utf8`})).trim()}catch{}try{let t=L(__dirname,`..`,`..`,`package.json`);z(t)&&(e.okVersion=JSON.parse(V(t,`utf8`)).version)}catch{}return e}const Pe=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function Fe(e){let t=F(e);return Pe.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Ie(e,t){return ze(e,t).files}const Le=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function Re(e,t=D){let n=L(e,`${t}.ShipIt`);return z(n)?Le.map(e=>L(n,e)).filter(e=>z(e)):[]}function ze(e,t){if(!z(t))return{files:[],excludedByProjectSlug:0};let n=H(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>L(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(Fe),i=[],a=r.filter(t=>{try{return V(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!Fe(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Be(e){let t=L(e,`.ok`,`local`);return z(t)?{files:[`server.lock`,`last-spawn-error.log`,s].map(e=>L(t,e)).filter(e=>z(e))}:{files:[]}}function Ve(e){let t=L(e,`.ok`,`local`,`logs`);return z(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>L(t,e)).filter(e=>z(e))}:{files:[]}}function He(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=c(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function Ue(e){for(let t of e.files)try{He({zipfile:e.zipfile,name:`${e.prefix}/${F(t)}`,content:V(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function We(t){let{redact:n,outputPath:r,logger:a}=t,o=t.userLogsDir??L(G(),`.ok`,`logs`),s=t.projectDir?Me(t.projectDir,a):null;B(I(r),{recursive:!0}),a?.info({projectSlug:s},`gathering diagnostic data`);let c=Ne();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=ze(s,o),{files:d}=t.projectDir?Be(t.projectDir):{files:[]},{files:f}=t.projectDir?Ve(t.projectDir):{files:[]},p=t.shipItLogFiles??[];a?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length},`files collected`);let m=[],h=[],{ZipFile:g}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),_=new g;Ue({zipfile:_,files:[...l,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:a}),Ue({zipfile:_,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:a}),Ue({zipfile:_,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:a});for(let e of t.extraFiles??[])try{let t=V(e.sourcePath),n=`extra/${e.zipName??F(e.sourcePath)}`;_.addBuffer(t,n),h.push(n)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&He({zipfile:_,name:`note.txt`,content:t.note,redact:n,bundleFiles:h,redactions:m});let v=JSON.stringify(c,null,2);_.addBuffer(Buffer.from(v,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let y={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:h,redactions:m,sysinfo:c};_.addBuffer(Buffer.from(JSON.stringify(y,null,2),`utf8`),`MANIFEST.json`);let b=m.reduce((e,t)=>e+t.lineCount,0),x=new Set(p.map(e=>`logs/${F(e)}`)),S=h.filter(e=>x.has(e)),C=s?h.filter(e=>e.startsWith(`logs/`)&&!Fe(e)&&!x.has(e)):[],w=[`# Bug Report Bundle`,``,`Generated: ${y.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${y.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...C.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...C.map(e=>`- ${e}`),``]:[],...S.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...S.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${i.join(`, `)}`,b>0?`${b} line(s) were scrubbed across ${m.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
2
- `);_.addBuffer(Buffer.from(w,`utf8`),`README.md`),_.end();let T=le(r);return _.outputStream.pipe(T),await new Promise((e,t)=>{T.on(`close`,e),T.on(`error`,t)}),a?.info({bundlePath:r,fileCount:h.length,redactionCount:b},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:h,redactions:m,redactedLineCount:b,generatedAt:y.generatedAt}}}var Ge=e(w(),1),K=e(E(),1);function Ke(e){return v({absPath:y(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function qe({home:e=G(),env:n=process.env}={}){let i=Ke(e),{override:a,preferenceList:s}=g(n),{locale:c,source:l}=o({override:a,storedPreference:i,supportedLocales:r,preferenceList:s,autoDetectableLocales:t});return{preference:i,locale:c,source:l,systemLanguages:s}}function Je(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return Je(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!Ye(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function Xe(e,t){let n=V(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
1
+ import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sleep-ChZE9826.mjs";import{Q as i,Qa as a,Xs as o,Ys as s,Z as c}from"./src-DiueG9n0.mjs";import{On as l,Zr as u,at as d,bi as f,it as p,ot as m,rt as h}from"./src-DVc0ORbR.mjs";import{D as g,F as _,I as v,k as y}from"./fs-traced-RPXwxrA5.mjs";import{C as b,S as x,d as S,y as C}from"./server-lock-XNc0dGvF.mjs";import{t as w}from"./yazl-DZr4PyKA.mjs";import{t as T}from"./esm-DmX1RzAi.mjs";import{c as E}from"./colors-BsmVIwfM.mjs";import{n as D}from"./acp-harness-probe-BsrCm6PN.mjs";import{E as ee,T as O,_ as k,o as A,w as j,x as M,y as N}from"./init-FysoPMTz.mjs";import{n as te}from"./constants-6rxfoWpc.mjs";import{t as P}from"./is-object-ByG7RnjH.mjs";import{m as ne,p as re}from"./write-project-skill-B0KKzsOU.mjs";import"./loader-D9ASHd7b.mjs";import"./skill-teardown-B6HJfl80.mjs";import"./preview-C3WQiD83.mjs";import{execSync as ie,spawnSync as ae}from"node:child_process";import{basename as F,dirname as I,join as L,relative as oe,resolve as R,sep as se}from"node:path";import{cpSync as ce,createWriteStream as le,existsSync as z,lstatSync as ue,mkdirSync as B,mkdtempSync as de,readFileSync as V,readdirSync as H,readlinkSync as fe,rmSync as U,statSync as pe,writeFileSync as W}from"node:fs";import{arch as me,freemem as he,homedir as G,hostname as ge,platform as _e,release as ve,tmpdir as ye,totalmem as be,type as xe,uptime as Se}from"node:os";import"node:fs/promises";import{createHash as Ce}from"node:crypto";var we=n();const Te=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Ee(e,t,n=l){if(e!==void 0&&!Te.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let De=null;function Oe(e){De=e}function ke(){return De??process.cwd()}function Ae(){return L(G(),`.ok`,`bug-reports`)}function je(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Ae(),r=`${t}-bugreport`,i=L(n,`${r}.zip`);for(let e=2;z(i);e+=1)i=L(n,`${r}-${e}.zip`);return i}function Me(e,t){let n=L(e,`.ok`,`config.yml`);if(z(n))try{let e=V(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return z(L(e,`.ok`))?Ce(`sha256`).update(R(e)).digest(`hex`).slice(0,12):null}function Ne(){let e={timestamp:new Date().toISOString(),platform:_e(),osType:xe(),osRelease:ve(),hostname:`[redacted]`,uptime:Se(),freeMem:he(),totalMem:be(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ie(`sw_vers -productVersion 2>/dev/null`,u({encoding:`utf8`})).trim()}catch{}try{let t=L(__dirname,`..`,`..`,`package.json`);z(t)&&(e.okVersion=JSON.parse(V(t,`utf8`)).version)}catch{}return e}const Pe=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function Fe(e){let t=F(e);return Pe.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Ie(e,t){return ze(e,t).files}const Le=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function Re(e,t=D){let n=L(e,`${t}.ShipIt`);return z(n)?Le.map(e=>L(n,e)).filter(e=>z(e)):[]}function ze(e,t){if(!z(t))return{files:[],excludedByProjectSlug:0};let n=H(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>L(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(Fe),i=[],a=r.filter(t=>{try{return V(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!Fe(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Be(e){let t=L(e,`.ok`,`local`);return z(t)?{files:[`server.lock`,`last-spawn-error.log`,c].map(e=>L(t,e)).filter(e=>z(e))}:{files:[]}}function Ve(e){let t=L(e,`.ok`,`local`,`logs`);return z(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>L(t,e)).filter(e=>z(e))}:{files:[]}}function He(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=o(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function Ue(e){for(let t of e.files)try{He({zipfile:e.zipfile,name:`${e.prefix}/${F(t)}`,content:V(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function We(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??L(G(),`.ok`,`logs`),o=t.projectDir?Me(t.projectDir,i):null;B(I(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let c=Ne();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=ze(o,a),{files:d}=t.projectDir?Be(t.projectDir):{files:[]},{files:f}=t.projectDir?Ve(t.projectDir):{files:[]},p=t.shipItLogFiles??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length},`files collected`);let m=[],h=[],{ZipFile:g}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),_=new g;Ue({zipfile:_,files:[...l,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:i}),Ue({zipfile:_,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:i}),Ue({zipfile:_,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=V(e.sourcePath),n=`extra/${e.zipName??F(e.sourcePath)}`;_.addBuffer(t,n),h.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&He({zipfile:_,name:`note.txt`,content:t.note,redact:n,bundleFiles:h,redactions:m});let v=JSON.stringify(c,null,2);_.addBuffer(Buffer.from(v,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let y={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:h,redactions:m,sysinfo:c};_.addBuffer(Buffer.from(JSON.stringify(y,null,2),`utf8`),`MANIFEST.json`);let b=m.reduce((e,t)=>e+t.lineCount,0),x=new Set(p.map(e=>`logs/${F(e)}`)),S=h.filter(e=>x.has(e)),C=o?h.filter(e=>e.startsWith(`logs/`)&&!Fe(e)&&!x.has(e)):[],w=[`# Bug Report Bundle`,``,`Generated: ${y.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${y.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...C.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...C.map(e=>`- ${e}`),``]:[],...S.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...S.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${s.join(`, `)}`,b>0?`${b} line(s) were scrubbed across ${m.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
2
+ `);_.addBuffer(Buffer.from(w,`utf8`),`README.md`),_.end();let T=le(r);return _.outputStream.pipe(T),await new Promise((e,t)=>{T.on(`close`,e),T.on(`error`,t)}),i?.info({bundlePath:r,fileCount:h.length,redactionCount:b},`bundle written`),{zipPath:r,summary:{projectSlug:o,files:h,redactions:m,redactedLineCount:b,generatedAt:y.generatedAt}}}var Ge=e(w(),1),K=e(E(),1);function Ke(e){return v({absPath:y(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function qe({home:e=G(),env:n=process.env}={}){let i=Ke(e),{override:o,preferenceList:s}=g(n),{locale:c,source:l}=a({override:o,storedPreference:i,supportedLocales:r,preferenceList:s,autoDetectableLocales:t});return{preference:i,locale:c,source:l,systemLanguages:s}}function Je(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return Je(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!Ye(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function Xe(e,t){let n=V(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
3
3
  `),i=n.split(`
4
4
  `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=q(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}W(e,r?`${a.join(`
5
5
  `)}\n`:a.join(`
6
6
  `))}function Ze(e,t){let n=V(e,`utf-8`);if(n.trim().length!==0)try{let r=q(JSON.parse(n),t),i=n.endsWith(`
7
7
  `)?`
8
8
  `:``;W(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Je(n,t.contentDir);r!==n&&W(e,r)}}function Qe(e,t){let n=V(e,`utf-8`),r=Je(n,t.contentDir);r!==n&&W(e,r)}function $e(e){try{return H(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>L(e,t.name))}catch{return[]}}const et=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function tt(e){return/\.log\.\d+$/.test(e)}function nt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||tt(e)}function rt(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of $e(L(e.stagingDir,n)))nt(r)?Xe(r,t):r.endsWith(`.json`)?Ze(r,t):Qe(r,t);for(let n of $e(L(e.stagingDir,`state`))){let e=F(n);n.endsWith(`.jsonl`)?Xe(n,t):et.has(e)?Ze(n,t):Qe(n,t)}}const it=[`.ok`,`local`,`telemetry`],at=[`.ok`,`local`,`logs`],ot=[`.ok`,`local`,`loss-capture`],st=`spans-current.jsonl`,ct=`spans-prev.jsonl`,lt=`server-current.jsonl`,ut=`server-prev.jsonl`,dt=`loss-current.jsonl`,ft=`loss-prev.jsonl`;function pt(e){return L(e,...it,st)}function mt(e){return L(e,...it,ct)}function ht(e){return L(e,...at,lt)}function gt(e){return L(e,...at,ut)}function _t(e){return L(e,...ot,dt)}function vt(e){return L(e,...ot,ft)}const yt=1e3;async function bt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(yt)});return t.ok?await t.text():null}catch{return null}}async function xt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(yt)});return t.ok?await t.text():null}catch{return null}}async function St(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(yt)});return t.ok?await t.text():null}catch{return null}}function Ct(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
9
- `)}\n`:null}catch{return null}}function wt(e){let t=L(e,`.git`,`ok`);if(!z(t))return null;let n=ae(`git`,[`-C`,t,`log`,`--oneline`,`-50`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Tt(e){let t=L(e,`.git`,`ok`);if(!z(t))return null;let n=ae(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Et(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Dt(){return{nodeVersion:process.version,platform:_e(),arch:me()}}function Ot(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e){if(!z(e))return{};let t;try{t=(0,we.parse)(V(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!J(t))return{};let n=t.telemetry;if(!J(n))return{};let r=n.localSink;return J(r)?r:{}}function At(e){return typeof e==`boolean`?e:void 0}function jt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return jt(e.maxBytes)}function Mt(e){let t=kt(y(`project`,e)),n=kt(y(`project-local`,e));return{enabled:At(n.enabled)??At(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Nt(e){return Ce(`sha256`).update(e).digest(`hex`)}function Pt(e){let t=V(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Ft(e){let t=V(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X(e,t){if(!z(e))return!1;try{return B(I(t),{recursive:!0}),ce(e,t),!0}catch{return!1}}function It(e){let t=[],n=e=>{let r=H(e,{withFileTypes:!0});for(let i of r){let r=L(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Lt=new Set([`.jsonl`]);function Rt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Lt.has(e.slice(t))}const zt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Bt(e){if(tt(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:zt.has(e.slice(t))}function Vt(e){let t=[];for(let n of It(e)){let r=Ht(e,n);if(!Bt(r))continue;let{redacted:i,patterns:a,lineCount:o}=c(V(n,`utf-8`));a.length!==0&&(W(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Ht(e,t){return oe(e,t).split(se).join(`/`)}async function Ut(e){let t=R(e.contentDir),n=R(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??bt,o=r.fetchAgentEffects??xt,c=r.fetchWatcherRecent??St,l=r.readShadowHead??wt,u=r.readCheckpointRefs??Tt,d=r.now??(()=>new Date),f=r.okVersion??(()=>te),p=r.readDesktopEnv??Et,m=r.readLanguage??qe,h=r.readRuntime??Dt,g=r.isOtlpPushEnabled??Ot,_=de(L(ye(),`ok-bundle-`));try{B(L(_,`telemetry`),{recursive:!0}),B(L(_,`logs`),{recursive:!0}),B(L(_,`state`),{recursive:!0}),X(pt(n),L(_,`telemetry`,st)),X(mt(n),L(_,`telemetry`,ct)),X(ht(n),L(_,`logs`,lt)),X(gt(n),L(_,`logs`,ut));for(let t of e.userLogFiles??[])X(t,L(_,`logs`,F(t)));let v=L(n,`.ok`,`local`),y=L(v,`server.lock`),b=`not-running`,x=`no server.lock`,S=null;if(z(y)){X(y,L(_,`state`,`server.lock`));try{let e=V(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?S=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(S!==null){let e=await i(S);e===null?x=`agent-presence endpoint at :${S} unreachable`:(W(L(_,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await o(S);t!==null&&W(L(_,`state`,`agent-effects.json`),t);let n=await c(S);if(n!==null){let e=Ct(n);e!==null&&W(L(_,`state`,`watcher-recent.jsonl`),e)}}let C=l(t);C!==null&&W(L(_,`state`,`shadow-head.txt`),C);let w=u(t);w!==null&&W(L(_,`state`,`checkpoint-refs.txt`),w),X(_t(n),L(_,`state`,dt)),X(vt(n),L(_,`state`,ft)),X(L(v,`last-spawn-error.log`),L(_,`state`,`last-spawn-error.log`)),X(L(v,a),L(_,`state`,a)),X(L(v,s),L(_,`state`,s));let T=h(),E=p(),D=m(),ee={ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D}};W(L(_,`state`,`runtime.json`),`${JSON.stringify(ee,null,2)}\n`);let O=b===`running`?`running
9
+ `)}\n`:null}catch{return null}}function wt(e){let t=L(e,`.git`,`ok`);if(!z(t))return null;let n=ae(`git`,[`-C`,t,`log`,`--oneline`,`-50`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Tt(e){let t=L(e,`.git`,`ok`);if(!z(t))return null;let n=ae(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],u({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Et(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Dt(){return{nodeVersion:process.version,platform:_e(),arch:me()}}function Ot(){return process.env.OTEL_SDK_DISABLED===`false`}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e){if(!z(e))return{};let t;try{t=(0,we.parse)(V(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!J(t))return{};let n=t.telemetry;if(!J(n))return{};let r=n.localSink;return J(r)?r:{}}function At(e){return typeof e==`boolean`?e:void 0}function jt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y(e){if(J(e))return jt(e.maxBytes)}function Mt(e){let t=kt(y(`project`,e)),n=kt(y(`project-local`,e));return{enabled:At(n.enabled)??At(t.enabled)??!0,spansMaxBytes:Y(n.spans)??Y(t.spans)??52428800,logsMaxBytes:Y(n.logs)??Y(t.logs)??26214400}}function Nt(e){return Ce(`sha256`).update(e).digest(`hex`)}function Pt(e){let t=V(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Ft(e){let t=V(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X(e,t){if(!z(e))return!1;try{return B(I(t),{recursive:!0}),ce(e,t),!0}catch{return!1}}function It(e){let t=[],n=e=>{let r=H(e,{withFileTypes:!0});for(let i of r){let r=L(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Lt=new Set([`.jsonl`]);function Rt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Lt.has(e.slice(t))}const zt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Bt(e){if(tt(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:zt.has(e.slice(t))}function Vt(e){let t=[];for(let n of It(e)){let r=Ht(e,n);if(!Bt(r))continue;let{redacted:i,patterns:a,lineCount:s}=o(V(n,`utf-8`));a.length!==0&&(W(n,i),t.push({file:r,lineCount:s,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Ht(e,t){return oe(e,t).split(se).join(`/`)}async function Ut(e){let t=R(e.contentDir),n=R(e.projectDir??e.contentDir),r=e.deps??{},a=r.fetchAgentPresence??bt,o=r.fetchAgentEffects??xt,s=r.fetchWatcherRecent??St,l=r.readShadowHead??wt,u=r.readCheckpointRefs??Tt,d=r.now??(()=>new Date),f=r.okVersion??(()=>te),p=r.readDesktopEnv??Et,m=r.readLanguage??qe,h=r.readRuntime??Dt,g=r.isOtlpPushEnabled??Ot,_=de(L(ye(),`ok-bundle-`));try{B(L(_,`telemetry`),{recursive:!0}),B(L(_,`logs`),{recursive:!0}),B(L(_,`state`),{recursive:!0}),X(pt(n),L(_,`telemetry`,st)),X(mt(n),L(_,`telemetry`,ct)),X(ht(n),L(_,`logs`,lt)),X(gt(n),L(_,`logs`,ut));for(let t of e.userLogFiles??[])X(t,L(_,`logs`,F(t)));let v=L(n,`.ok`,`local`),y=L(v,`server.lock`),b=`not-running`,x=`no server.lock`,S=null;if(z(y)){X(y,L(_,`state`,`server.lock`));try{let e=V(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?S=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(S!==null){let e=await a(S);e===null?x=`agent-presence endpoint at :${S} unreachable`:(W(L(_,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await o(S);t!==null&&W(L(_,`state`,`agent-effects.json`),t);let n=await s(S);if(n!==null){let e=Ct(n);e!==null&&W(L(_,`state`,`watcher-recent.jsonl`),e)}}let C=l(t);C!==null&&W(L(_,`state`,`shadow-head.txt`),C);let w=u(t);w!==null&&W(L(_,`state`,`checkpoint-refs.txt`),w),X(_t(n),L(_,`state`,dt)),X(vt(n),L(_,`state`,ft)),X(L(v,`last-spawn-error.log`),L(_,`state`,`last-spawn-error.log`)),X(L(v,i),L(_,`state`,i)),X(L(v,c),L(_,`state`,c));let T=h(),E=p(),D=m(),ee={ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D}};W(L(_,`state`,`runtime.json`),`${JSON.stringify(ee,null,2)}\n`);let O=b===`running`?`running
10
10
  `:`not-running (${x})\n`;if(W(L(_,`state`,`server-status.txt`),O),e.processDir&&z(e.processDir)){let t=L(_,`process`);B(t,{recursive:!0}),ce(e.processDir,t,{recursive:!0})}let k=e.redact===!0;k&&rt({stagingDir:_,contentDir:t}),e.note&&W(L(_,`note.txt`),e.note);let A=null;e.scrubSecrets===!0&&(A=Vt(_));for(let t of e.extraFiles??[])X(t.sourcePath,L(_,`extra`,t.zipName??F(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let j=Mt(n),M=It(_),N=[],te=0,P=0;for(let e of M){let t=Ht(_,e),n=pe(e).size,r=Rt(t)?Pt(e):0;N.push({path:t,bytes:n,lines:r}),te+=n,t.startsWith(`telemetry/`)&&Rt(t)&&(P+=Ft(e))}let ne={applied:k};A!==null&&(ne.secretScrub=A);let re={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D},contentDir:{pathSha256:Nt(t),absolutePath:k?`<CONTENT_DIR>`:t},telemetry:{localSink:j,otlpPushEnabled:g()},redaction:ne,serverStatus:b,files:N};W(L(_,`manifest.json`),`${JSON.stringify(re,null,2)}\n`);let ie=M.some(e=>{try{return V(e,`utf-8`).includes(t)}catch{return!1}}),ae={totalBytes:te,fileCount:N.length,docNameCount:P,contentDirVisible:ie,redacted:k},I=!1;return{stagingDir:_,manifest:re,summary:ae,cleanup:()=>{I||(I=!0,U(_,{recursive:!0,force:!0}))}}}catch(e){throw U(_,{recursive:!0,force:!0}),e}}async function Wt(e){let{collected:t,outputPath:n}=e,r=I(n);if(!z(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Ge.ZipFile,a=It(t.stagingDir);for(let e of a){let n=Ht(t.stagingDir,e);i.addFile(e,n)}i.end();let o=le(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Gt(e,t){let n=L(e,`.ok`,`config.yml`);if(z(n))try{let t=(0,we.parse)(V(n,`utf-8`)),r=P(t)?t.content:void 0,i=P(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return R(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return R(e)}async function Kt(e,t,n,r){let i=Me(t,e.logger),a=await Ut({contentDir:Gt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...Ie(i,e.userLogsDir??L(G(),`.ok`,`logs`)),...Re(e.cachesDir??L(G(),`Library`,`Caches`))],deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{B(I(e.outputPath),{recursive:!0}),await Wt({collected:a,outputPath:e.outputPath});let t=a.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:i,files:a.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:a.manifest.createdAt}}}finally{a.cleanup()}}async function qt(e){let{projectDir:t}=e,n=e.readDesktopEnv??Et,r=e.readLanguage??qe;if(e.level===`full`&&t!==void 0)return Kt(e,t,n,r);let{zipPath:i,summary:a}=await We({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:Re(e.cachesDir??L(G(),`Library`,`Caches`)),logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:i,summary:{level:e.level,systemWide:t===void 0,projectSlug:a.projectSlug,files:a.files,redactions:a.redactions,redactedLineCount:a.redactedLineCount,generatedAt:a.generatedAt}}}function Z(e,t,n={}){let r=S(e,t);if(!z(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(V(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!b(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??x)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??C())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??ge();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Jt(e){return e.replace(/:\d+$/,``)}function Yt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Jt(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Jt(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Jt(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const Xt=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Zt(e){return L(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Qt={existsSync:e=>z(e),readFileSync:(e,t)=>V(e,t),lstatSync:e=>ue(e),readlinkSync:e=>fe(e)};function $t(e,t=Qt){let n=Zt(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function en(e){let t=e.replace(Xt,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function tn(e,t,n=Qt){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function nn(e){return re(e)||ne(e)||M(e)}const rn=10*1024*1024;function an(e,t,n,r){let i=A(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!nn(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(U(a,{force:!0}),{kind:`removed`}):e.format===`toml`?cn(a,o):e.format===`yaml`?sn(a,e.topLevelKey,o):on(a,e.topLevelKey,e.serverMapSubKey,o)}function on(e,t,n,r){let i;try{i=V(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=ee(i,k(t,n,r));return o?(_(e,a,{mode:j(e)}),{kind:`removed`}):{kind:`not-present`}}function sn(e,t,n){let r;try{r=V(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,we.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=O(a);a.trim()===``||a.endsWith(`
11
11
  `)?c.endsWith(`
12
12
  `)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
@@ -17,4 +17,4 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sle
17
17
  `).replace(/\n/g,`\r
18
18
  `));let u=`${i?``:``}${l}`;return u!==r&&_(e,u,{mode:j(e)}),{kind:`removed`}}function ln(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function un(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function dn(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:p(r),command:r,isDesktop:ln(r)}}function fn(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&fn(e)?`ui-orphan`:`stale`}const pn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function mn(e){switch(e){case`running`:return K.default.green(e);case`desktop`:return K.default.blue(e);case`foreign`:return K.default.cyan(e);case`ui-orphan`:return K.default.magenta(e);case`stale`:return K.default.yellow(e)}}function hn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function gn(e){return`${hn(e.server.usage)} | ${hn(e.ui?.usage??null)}`}function _n(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function vn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,_n(e),gn(e),t,String(n),un(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=mn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=K.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
19
19
  `)}async function yn(e={}){let t=e.discover??h,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??d,a=e.resolveUsage??m,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=dn(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(vn(e.all?s:s.filter(e=>pn.has(Q(e)))))}function bn(){return new T(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await yn({all:t.all===!0||e===`all`,json:t.json===!0})})}function xn(e,t,n={}){let r=n.isAlive??x,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function Sn(e){let t=e.inspect??(t=>Z(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=xn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Cn(e,t=x){let n=await h(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function wn(e){let t=Sn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Tn(e){return new T(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=Sn({lockDir:f(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await yn({});return}if(n===`all`){let e=await h();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Z(n,`server`),r=Z(n,`ui`);!$(e,x)&&!$(r,x)||(wn(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Cn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}wn(t);return}wn(f(R(ke(),n)))})}export{ke as _,Xt as a,$t as c,Z as d,qt as f,Ae as g,je as h,an as i,en as l,Wt as m,Tn as n,tn as o,Ut as p,bn as r,Zt as s,Sn as t,Yt as u,Oe as v,Ee as y};
20
- //# sourceMappingURL=src-D3IYzczj.mjs.map
20
+ //# sourceMappingURL=src-CfKlTuR4.mjs.map